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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
51159fabdfd94af7f27ae66a774c2b4847c629a1 | 254 | h | C | util/led/finish.h | wyan/ack | cf1b02d26cdfaff4417011c49d112b8dfc877df2 | [
"BSD-3-Clause"
] | 282 | 2015-07-01T10:17:17.000Z | 2022-03-31T02:14:30.000Z | util/led/finish.h | wyan/ack | cf1b02d26cdfaff4417011c49d112b8dfc877df2 | [
"BSD-3-Clause"
] | 176 | 2016-06-07T06:46:55.000Z | 2022-03-19T21:40:17.000Z | util/led/finish.h | wyan/ack | cf1b02d26cdfaff4417011c49d112b8dfc877df2 | [
"BSD-3-Clause"
] | 58 | 2015-12-02T16:29:18.000Z | 2022-01-26T17:54:35.000Z | /*
* finish.h
*
* Created on: 2018-11-17
* Author: Carl Eric Codere
*/
#ifndef __FINISH_H_INCLUDED__
#define __FINISH_H_INCLUDED__
void finish(void);
void do_crs(struct outname *base, unsigned int count);
#endif /* __FINISH_H_INCLUDED__ */
| 16.933333 | 54 | 0.712598 |
5775065499cdb26d2f396c7ae930973797c1b6dc | 6,894 | c | C | src/twda-estimate.c | shuangyinli/TWDA | a9cfc8379011f2a65467ea3723f1704f0d2adc76 | [
"Apache-2.0"
] | 2 | 2016-02-22T15:06:49.000Z | 2020-06-03T01:18:39.000Z | src/twda-estimate.c | shuangyinli/TWDA | a9cfc8379011f2a65467ea3723f1704f0d2adc76 | [
"Apache-2.0"
] | 1 | 2019-03-21T03:07:51.000Z | 2019-03-21T03:07:51.000Z | src/twda-estimate.c | shuangyinli/TWDA | a9cfc8379011f2a65467ea3723f1704f0d2adc76 | [
"Apache-2.0"
] | 2 | 2017-03-29T08:13:23.000Z | 2021-01-14T21:48:38.000Z | /*=============================================================================
# Author: Shuangyin Li
# Email: shuangyinli@cse.ust.hk
# School: Sun Yat-sen University
=============================================================================*/
#include "twda-estimate.h"
double likehood(Document** corpus, sslda_model* model) {
int num_docs = model->num_docs;
double lik = 0.0;
for (int d = 0; d < num_docs; d++) {
double temp_lik = compute_doc_likehood2(corpus[d],model);
lik += temp_lik;
corpus[d]->lik = temp_lik;
}
return lik;
}
double compute_doc_likehood2(Document* doc, sslda_model* model) {
double* log_topic = doc->topic;
double* log_theta = model->log_theta;
double* log_phi = model->log_phi;
double* rou = doc->rou;
double sigma_rou = 0;
int num_topics = model->num_topics;
int num_words = model->num_words;
memset(log_topic, 0, sizeof(double) * num_topics);
bool* reset_log_topic = new bool[num_topics];
memset(reset_log_topic, false, sizeof(bool) * num_topics);
double sigma_xi = 0;
double* xi = doc->xi;
int doc_num_lables = doc->num_labels;
double lik = 0.0;
for (int i = 0; i < doc_num_lables; i++) {
sigma_xi += xi[i];
}
for(int i=0; i<num_topics; i++){
sigma_rou += rou[i];
}
for (int i = 0; i < doc_num_lables-1; i++) {
int labelid = doc->labels_ptr[i];
for (int k = 0; k < num_topics; k++) {
if (!reset_log_topic[k]) {
log_topic[k] = log_theta[labelid * num_topics + k] + log(xi[i]) - log(sigma_xi);
reset_log_topic[k] = true;
}
else log_topic[k] = util::log_sum(log_topic[k], log_theta[labelid * num_topics + k] + log(xi[i]) - log(sigma_xi));
}
}
//int last_tagid = doc->labels_ptr[doc_num_lables];
for(int k = 0; k < num_topics; k++){
double tem_rou = log(rou[k] / sigma_rou);
double tem_xi = log(xi[doc_num_lables-1]) - log(sigma_xi);
double tem_tk = log_topic[k];
log_topic[k] = util::log_sum(tem_tk, tem_rou + tem_xi);
}
int doc_num_words = doc->num_words;
for (int i = 0; i < doc_num_words; i++) {
double temp = 0;
int wordid = doc->words_ptr[i];
temp = log_topic[0] + log_phi[wordid];
for (int k = 1; k < num_topics; k++) temp = util::log_sum(temp, log_topic[k] + log_phi[k * num_words + wordid]);
lik += temp * doc->words_cnt_ptr[i];
}
delete[] reset_log_topic;
return lik;
}
double compute_doc_likehood(Document* doc, sslda_model* model) {
double* log_topic = doc->topic;
double* log_theta = model->log_theta;
double* log_phi = model->log_phi;
int num_topics = model->num_topics;
int num_words = model->num_words;
memset(log_topic, 0, sizeof(double) * num_topics);
bool* reset_log_topic = new bool[num_topics];
memset(reset_log_topic, false, sizeof(bool) * num_topics);
double sigma_xi = 0;
double* xi = doc->xi;
int doc_num_lables = doc->num_labels;
double lik = 0.0;
for (int i = 0; i < doc_num_lables; i++) {
sigma_xi += xi[i];
}
for (int i = 0; i < doc_num_lables; i++) {
int labelid = doc->labels_ptr[i];
//double temp = log_theta[labelid * num_topics] + log(xi[i]) - log(sigma_xi);
for (int k = 0; k < num_topics; k++) {
if (!reset_log_topic[k]) {
log_topic[k] = log_theta[labelid * num_topics + k] + log(xi[i]) - log(sigma_xi);
reset_log_topic[k] = true;
}
else log_topic[k] = util::log_sum(log_topic[k], log_theta[labelid * num_topics + k] + log(xi[i]) - log(sigma_xi));
}
}
int doc_num_words = doc->num_words;
for (int i = 0; i < doc_num_words; i++) {
double temp = 0;
int wordid = doc->words_ptr[i];
temp = log_topic[0] + log_phi[wordid];
for (int k = 1; k < num_topics; k++) temp = util::log_sum(temp, log_topic[k] + log_phi[k * num_words + wordid]);
lik += temp * doc->words_cnt_ptr[i];
}
delete[] reset_log_topic;
return lik;
}
double cal_precision(Document** corpus, Document** unlabel_corpus, sslda_model* model,char* tmp_dir,int num_round) {
int num_correct = 0;
int num_labels = model->num_labels;
int num_docs = model->num_docs;
char filename[1000];
FILE* fp=NULL;
if (tmp_dir) {
sprintf(filename,"%s/%d.xi",tmp_dir, num_round);
fp = fopen(filename,"w");
}
for (int d = 0; d < num_docs; d++) {
Document* doc = unlabel_corpus[d];
int max_xi_labelid = 0;
int xi_value = doc->xi[0];
double sigma_xi = doc->xi[0];
for (int l = 1; l < num_labels; l++) {
sigma_xi += doc->xi[l];
if (xi_value < doc->xi[l]) {
xi_value = doc->xi[l];
max_xi_labelid = l;
}
}
if (max_xi_labelid == corpus[d]->labels_ptr[0]) num_correct += 1;
for (int l = 0; fp && l < num_labels; l++) {
if(fp) fprintf(fp,"%lf ",doc->xi[l]/sigma_xi);
}
if (fp) fprintf(fp,"\n");
}
if (fp) fclose(fp);
return double(num_correct)/num_docs;
}
static double* sorted_array_ptr = NULL;
bool cmp(int i, int j) {
return sorted_array_ptr[i] > sorted_array_ptr[j];
}
double cal_map(Document** corpus, Document** unlabel_corpus, sslda_model* model, int at_num, char* tmp_dir, int num_round) {
int num_labels = model->num_labels;
int num_docs = model->num_docs;
char filename[1000];
FILE* fp = NULL;
if (tmp_dir) {
sprintf(filename, "%s/%d.xi", tmp_dir, num_round);
fp = fopen(filename, "w");
}
int* idx = new int[num_labels];
for (int i = 0; i < num_labels; i++) idx[i] = i;
double map = 0.0;
for (int d = 0; d < num_docs; d++) {
Document* doc = unlabel_corpus[d];
sorted_array_ptr = doc->xi;
std::sort(idx, idx + num_labels, cmp);
int correct_cnt = 0;
double ap = 0;
for (int j = 0; j < at_num; j++) {
bool correct = false;
for (int k = 0; !correct && k < corpus[d]->num_labels; k++) {
if (corpus[d]->labels_ptr[k] == idx[j]) correct = true;
}
if (correct) {
correct_cnt ++;
ap += double(correct_cnt)/(j+1);
}
}
ap /= std::min(corpus[d]->num_labels, at_num);
map+=ap;
double sigma_xi = 0.0;
for (int l = 0; fp && l < num_labels; l++) sigma_xi += doc->xi[l];
for (int l = 0; fp && l < num_labels; l++) {
if(fp) fprintf(fp,"%lf ",doc->xi[l]/sigma_xi);
}
if (fp) fprintf(fp,"\n");
}
if(fp) fclose(fp);
return map/num_docs;
}
| 35.173469 | 126 | 0.543516 |
57818117074487ed996c955df5073364f73cc5c2 | 2,067 | h | C | include/string.h | weiss/original-bsd | b44636d7febc9dcf553118bd320571864188351d | [
"Unlicense"
] | 114 | 2015-01-18T22:55:52.000Z | 2022-02-17T10:45:02.000Z | include/string.h | JamesLinus/original-bsd | b44636d7febc9dcf553118bd320571864188351d | [
"Unlicense"
] | null | null | null | include/string.h | JamesLinus/original-bsd | b44636d7febc9dcf553118bd320571864188351d | [
"Unlicense"
] | 29 | 2015-11-03T22:05:22.000Z | 2022-02-08T15:36:37.000Z | /*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* %sccs.include.redist.c%
*
* @(#)string.h 8.1 (Berkeley) 06/02/93
*/
#ifndef _STRING_H_
#define _STRING_H_
#include <machine/ansi.h>
#ifdef _BSD_SIZE_T_
typedef _BSD_SIZE_T_ size_t;
#undef _BSD_SIZE_T_
#endif
#ifndef NULL
#define NULL 0
#endif
#include <sys/cdefs.h>
__BEGIN_DECLS
void *memchr __P((const void *, int, size_t));
int memcmp __P((const void *, const void *, size_t));
void *memcpy __P((void *, const void *, size_t));
void *memmove __P((void *, const void *, size_t));
void *memset __P((void *, int, size_t));
char *strcat __P((char *, const char *));
char *strchr __P((const char *, int));
int strcmp __P((const char *, const char *));
int strcoll __P((const char *, const char *));
char *strcpy __P((char *, const char *));
size_t strcspn __P((const char *, const char *));
char *strerror __P((int));
size_t strlen __P((const char *));
char *strncat __P((char *, const char *, size_t));
int strncmp __P((const char *, const char *, size_t));
char *strncpy __P((char *, const char *, size_t));
char *strpbrk __P((const char *, const char *));
char *strrchr __P((const char *, int));
size_t strspn __P((const char *, const char *));
char *strstr __P((const char *, const char *));
char *strtok __P((char *, const char *));
size_t strxfrm __P((char *, const char *, size_t));
/* Nonstandard routines */
#ifndef _ANSI_SOURCE
int bcmp __P((const void *, const void *, size_t));
void bcopy __P((const void *, void *, size_t));
void bzero __P((void *, size_t));
int ffs __P((int));
char *index __P((const char *, int));
void *memccpy __P((void *, const void *, int, size_t));
char *rindex __P((const char *, int));
int strcasecmp __P((const char *, const char *));
char *strdup __P((const char *));
void strmode __P((int, char *));
int strncasecmp __P((const char *, const char *, size_t));
char *strsep __P((char **, const char *));
void swab __P((const void *, void *, size_t));
#endif
__END_DECLS
#endif /* _STRING_H_ */
| 30.397059 | 69 | 0.661345 |
f165ffe67e2443e67d4b241e6a02110e7e79d978 | 566 | h | C | Deezer/DeezerSDK/include/NSBundle+DZRBundle.h | drewsdav/Kleene-iOS | 85c77c26784bb294d404ebf4636c4f3a5b2c470d | [
"Apache-2.0"
] | 6 | 2019-07-21T05:14:38.000Z | 2020-10-30T00:20:51.000Z | Deezer/DeezerSDK/include/NSBundle+DZRBundle.h | drewsdav/Kleene-iOS | 85c77c26784bb294d404ebf4636c4f3a5b2c470d | [
"Apache-2.0"
] | null | null | null | Deezer/DeezerSDK/include/NSBundle+DZRBundle.h | drewsdav/Kleene-iOS | 85c77c26784bb294d404ebf4636c4f3a5b2c470d | [
"Apache-2.0"
] | 2 | 2022-01-26T08:06:10.000Z | 2022-02-11T05:19:39.000Z | //
// NSBundle+DZRBundle.h
// Deezer
//
// Created by GFaure on 10/06/2014.
// Copyright (c) 2014 Deezer. All rights reserved.
//
#import <Foundation/Foundation.h>
@class UIImage;
/*! Access SDK bundeld resources */
@interface NSBundle (DZRBundle)
/*! Singleton method to get a handle on the resources bundle. */
+ (NSBundle*)dzrBundle;
/*! Load images from the bundle.
Images are cached and requesting several time the image should provide the same
pointer.
!param name The name of the requested image.
*/
- (UIImage*)imageNamed:(NSString*)name;
@end
| 22.64 | 80 | 0.713781 |
01c6c9e5091aa1e08f0ffc4c945e4c65c838f866 | 1,197 | h | C | include/cdotc/CTFE/CTFEEngine.h | jonaszell97/cdotc | 089b1161155118a0b78637883f0a6a04c6e9b436 | [
"MIT"
] | 1 | 2020-05-29T12:34:33.000Z | 2020-05-29T12:34:33.000Z | include/cdotc/CTFE/CTFEEngine.h | jonaszell97/cdotc | 089b1161155118a0b78637883f0a6a04c6e9b436 | [
"MIT"
] | null | null | null | include/cdotc/CTFE/CTFEEngine.h | jonaszell97/cdotc | 089b1161155118a0b78637883f0a6a04c6e9b436 | [
"MIT"
] | null | null | null | #ifndef CDOT_CTFEENGINE_H
#define CDOT_CTFEENGINE_H
#include "cdotc/Basic/Variant.h"
#include "cdotc/Diagnostics/Diagnostics.h"
#include <llvm/ADT/ArrayRef.h>
#include <llvm/ADT/SmallPtrSet.h>
namespace cdot {
namespace ast {
class SemaPass;
class CallableDecl;
} // namespace ast
namespace il {
class Function;
class Constant;
} // namespace il
namespace ctfe {
class EngineImpl;
class Value;
struct CTFEResult {
explicit CTFEResult(il::Constant* Val) : Val(Val), HadError(false) {}
CTFEResult() : Val(nullptr), HadError(true) {}
bool hadError() const { return HadError; }
operator bool() const { return !hadError(); }
il::Constant* getVal() const { return Val; }
private:
il::Constant* Val;
bool HadError;
};
inline CTFEResult CTFEError() { return CTFEResult(); }
class CTFEEngine {
public:
explicit CTFEEngine(ast::SemaPass& SP);
~CTFEEngine();
CTFEResult evaluateFunction(il::Function* F, llvm::ArrayRef<Value> args,
SourceLocation loc = {});
Value CTFEValueFromVariant(Variant const& V, const QualType& Ty);
private:
EngineImpl* pImpl;
};
} // namespace ctfe
} // namespace cdot
#endif // CDOT_CTFEENGINE_H
| 19.622951 | 75 | 0.694236 |
4a1000a126d15e31ab20722571380a83aa5a59e2 | 6,052 | c | C | test/unit/libmbc.unit.c | fossabot/mbc | f562201fe0263d647615ce3ebbdacf5d0a5e50b6 | [
"Apache-2.0"
] | null | null | null | test/unit/libmbc.unit.c | fossabot/mbc | f562201fe0263d647615ce3ebbdacf5d0a5e50b6 | [
"Apache-2.0"
] | 3 | 2017-04-02T17:52:36.000Z | 2021-02-12T19:59:28.000Z | test/unit/libmbc.unit.c | fossabot/mbc | f562201fe0263d647615ce3ebbdacf5d0a5e50b6 | [
"Apache-2.0"
] | 2 | 2017-04-02T12:21:46.000Z | 2021-02-12T19:55:45.000Z | #include <libmbc.c>
#include <ctest.h>
CTEST(libmbc, mbc_set_user_key__no_complement) {
ASSERT_TRUE(mbc_set_user_key((uint8_t[]){0x22}, 1));
ASSERT_NOT_NULL(xor_key);
ASSERT_NOT_NULL(swap_key);
ASSERT_DATA((uint8_t[]){0x22}, 1, xor_key, xor_key_size);
ASSERT_DATA((uint8_t[]){0x06}, 1, swap_key, swap_key_size); // 00100010 → 010 001 = swap 2 with 1 → 0000 0110 → 0x06
mbc_free();
}
CTEST(libmbc, mbc_set_user_key__complement) {
ASSERT_TRUE(mbc_set_user_key((uint8_t[]){0x2d}, 1));
ASSERT_NOT_NULL(xor_key);
ASSERT_NOT_NULL(swap_key);
ASSERT_DATA((uint8_t[]){0x2d}, 1, xor_key, xor_key_size);
ASSERT_DATA((uint8_t[]){0x22}, 1, swap_key, swap_key_size); // 00101101 → 101 001 = swap 5 with 1 → 0010 0010 → 0x22
mbc_free();
}
CTEST(libmbc, mbc_set_user_key__complement_indifferent) {
ASSERT_TRUE(mbc_set_user_key((uint8_t[]){0x47}, 1));
ASSERT_NOT_NULL(xor_key);
ASSERT_NOT_NULL(swap_key);
ASSERT_DATA((uint8_t[]){0x47}, 1, xor_key, xor_key_size);
ASSERT_DATA((uint8_t[]){0x18}, 1, swap_key, swap_key_size); // 01000111 → 100 011 = swap 4 with 3 → 0001 1000 → 0x18
mbc_free();
}
CTEST(libmbc, mbc_set_user_key__empty) {
mbc_set_user_key((uint8_t[]){}, 0);
ASSERT_EQUAL(0, xor_key_size);
ASSERT_EQUAL(0, swap_key_size);
mbc_free();
}
CTEST(libmbc, mbc_free) {
mbc_free();
ASSERT_EQUAL(0, xor_key_size);
ASSERT_EQUAL(0, swap_key_size);
ASSERT_NULL(xor_key);
}
CTEST(libmbc, mbc_raw_to_hex__uppercase) {
char* hex = mbc_raw_to_hex((uint8_t[]){0x00, 0x0a, 0x61}, 3, true);
ASSERT_NOT_NULL(hex);
ASSERT_STR("000A61", hex);
free(hex);
}
CTEST(libmbc, mbc_raw_to_hex__lowercase) {
char* hex = mbc_raw_to_hex((uint8_t[]){0x00, 0x0a, 0x61}, 3, false);
ASSERT_NOT_NULL(hex);
ASSERT_STR("000a61", hex);
free(hex);
}
CTEST(libmbc, mbc_raw_to_hex__empty) {
char* hex = mbc_raw_to_hex((uint8_t[]){}, 0, false);
ASSERT_NOT_NULL(hex);
ASSERT_STR("", hex);
free(hex);
}
CTEST(libmbc, mbc_hex_to_raw) {
size_t n;
uint8_t* raw = mbc_hex_to_raw("000a61B2f", &n);
ASSERT_NOT_NULL(raw);
ASSERT_DATA(((uint8_t[]){0x00, 0x0a, 0x61, 0xb2}), 4, raw, n);
free(raw);
}
CTEST(libmbc, mbc_hex_to_raw__empty) {
size_t n;
uint8_t* raw = mbc_hex_to_raw("", &n);
//ASSERT_NULL(raw); // TODO
ASSERT_EQUAL(0, n);
free(raw);
}
CTEST(libmbc, mbc_encode_inplace__null_key) {
uint8_t data[] = {0x5d};
ASSERT_TRUE(mbc_set_user_key((uint8_t[]){0x00}, 1));
mbc_encode_inplace(data, 1);
ASSERT_DATA((uint8_t[]){0x5d}, 1, data, 1);
mbc_free();
}
CTEST(libmbc, mbc_decode_inplace__null_key) {
uint8_t data[] = {0x5d};
ASSERT_TRUE(mbc_set_user_key((uint8_t[]){0x00}, 1));
mbc_decode_inplace(data, 1);
ASSERT_DATA((uint8_t[]){0x5d}, 1, data, 1);
mbc_free();
}
CTEST(libmbc, mbc_encode__matching_sizes) {
ASSERT_TRUE(mbc_set_user_key((uint8_t[]){0x2d}, 1));
// swap: 1-5
// xor: 0x2d
uint8_t* encoded = mbc_encode((uint8_t[]){0x12}, 1); // swap 0001 0010 → 0011 0000 ^ 0010 1101 → 0001 1101
ASSERT_DATA((uint8_t[]){0x1d}, 1, encoded, 1);
free(encoded);
mbc_free();
}
CTEST(libmbc, mbc_decode__matching_sizes) {
ASSERT_TRUE(mbc_set_user_key((uint8_t[]){0x2d}, 1));
// xor: 0x2d
// swap: 1-5
uint8_t* decoded = mbc_decode((uint8_t[]){0x1d}, 1); // 0001 1101 ^ 0010 1101 → swap 0011 0000 → 0001 0010
ASSERT_DATA((uint8_t[]){0x12}, 1, decoded, 1);
free(decoded);
mbc_free();
}
CTEST(libmbc, mbc_encode__longer_key) {
ASSERT_TRUE(mbc_set_user_key((uint8_t[]){0x2d, 0x47}, 2));
// swap: 1-5 3-4
// xor: 0x2d 0x47 → 0x6a
uint8_t* encoded = mbc_encode((uint8_t[]){0x12}, 1); // swap 0001 0010 → 0010 1000 ^ 0110 1010 → 0100 0010
ASSERT_DATA((uint8_t[]){0x42}, 1, encoded, 1);
free(encoded);
mbc_free();
}
CTEST(libmbc, mbc_decode__longer_key) {
ASSERT_TRUE(mbc_set_user_key((uint8_t[]){0x2d, 0x47}, 2));
// xor: 0x2d 0x47 → 0x6a
// swap: 1-5 3-4
uint8_t* decoded = mbc_decode((uint8_t[]){0x42}, 1); // 0100 0010 ^ 0110 1010 → swap 0010 1000 → 0001 0010
ASSERT_DATA((uint8_t[]){0x12}, 1, decoded, 1);
free(decoded);
mbc_free();
}
CTEST(libmbc, mbc_encode__longer_data) {
ASSERT_TRUE(mbc_set_user_key((uint8_t[]){0x47}, 1));
// swap: 3-4
// xor: 0x47
uint8_t* encoded = mbc_encode((uint8_t[]){0x57, 0x5a}, 2);
// swap 0101 0111 → 0100 1111 ^ 0100 0111 → 0000 1000
// swap 0101 1010 → 0101 1010 ^ 0100 0111 → 0001 1101
ASSERT_DATA(((uint8_t[]){0x08, 0x1d}), 2, encoded, 2);
free(encoded);
mbc_free();
}
CTEST(libmbc, mbc_decode__longer_data) {
ASSERT_TRUE(mbc_set_user_key((uint8_t[]){0x47}, 1));
// xor: 0x47
// swap: 3-4
uint8_t* decoded = mbc_decode((uint8_t[]){0x08, 0x1d}, 2);
// 0000 1000 ^ 0100 0111 → swap 0100 1111 → 0101 0111
// 0001 1101 ^ 0100 0111 → swap 0101 1010 → 0101 1010
ASSERT_DATA(((uint8_t[]){0x57, 0x5a}), 2, decoded, 2);
free(decoded);
mbc_free();
}
CTEST(libmbc, mbc_encode_to_hex) {
ASSERT_TRUE(mbc_set_user_key((uint8_t[]){0x47}, 1));
// swap: 3-4
// xor: 0x47
char* encoded = mbc_encode_to_hex((uint8_t[]){0x57, 0xe2}, 2, false);
// swap 0101 0111 → 0100 1111 ^ 0100 0111 → 0000 1000
// swap 1110 0010 → 1110 0010 ^ 0100 0111 → 1010 0101
ASSERT_STR("08a5", encoded);
free(encoded);
mbc_free();
}
CTEST(libmbc, mbc_encode_to_hex__empty) {
ASSERT_TRUE(mbc_set_user_key((uint8_t[]){0x47}, 1));
// swap: 3-4
// xor: 0x47
char* encoded = mbc_encode_to_hex((uint8_t[]){}, 0, false);
ASSERT_STR("", encoded);
free(encoded);
mbc_free();
}
CTEST(libmbc, mbc_decode_from_hex) {
size_t dec_size;
ASSERT_TRUE(mbc_set_user_key((uint8_t[]){0x47}, 1));
// xor: 0x47
// swap: 3-4
uint8_t* decoded = mbc_decode_from_hex("08a5", &dec_size);
// 0000 1000 ^ 0100 0111 → swap 0100 1111 → 0101 0111
// 1010 0101 ^ 0100 0111 → swap 1110 0010 → 1110 0010
ASSERT_DATA(((uint8_t[]){0x57, 0xe2}), 2, decoded, dec_size);
free(decoded);
mbc_free();
}
CTEST(libmbc, mbc_decode_from_hex__empty) {
size_t dec_size;
ASSERT_TRUE(mbc_set_user_key((uint8_t[]){0x47}, 1));
// xor: 0x47
// swap: 3-4
uint8_t* decoded = mbc_decode_from_hex("", &dec_size);
//ASSERT_NULL(decoded); // TODO
ASSERT_EQUAL(0, dec_size);
free(decoded);
mbc_free();
}
| 28.682464 | 117 | 0.687211 |
6289aa1596f370a6c3b9c353fa0bf40137eb6bbf | 352 | h | C | Laigu-SDK-files/LGChatViewController/TableCells/CellView/LGBotMenuRichMessageCell.h | laigukf/LaigukfSDK-iOS | 9e639dcb8764c2715b256906a793c119fb6813b8 | [
"MIT"
] | null | null | null | Laigu-SDK-files/LGChatViewController/TableCells/CellView/LGBotMenuRichMessageCell.h | laigukf/LaigukfSDK-iOS | 9e639dcb8764c2715b256906a793c119fb6813b8 | [
"MIT"
] | 1 | 2021-06-28T02:55:00.000Z | 2021-06-28T02:55:00.000Z | Laigu-SDK-files/LGChatViewController/TableCells/CellView/LGBotMenuRichMessageCell.h | laigukf/LaigukfSDK-iOS | 9e639dcb8764c2715b256906a793c119fb6813b8 | [
"MIT"
] | null | null | null | //
// LGNewRichText1.h
// LGEcoboostSDK-test
//
// Created by zhangshunxing on 2020/5/12.
// Copyright © 2020 zhangshunxing. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "LGChatBaseCell.h"
#import "LGEmbededWebView.h"
NS_ASSUME_NONNULL_BEGIN
@interface LGBotMenuRichMessageCell : LGChatBaseCell
@end
NS_ASSUME_NONNULL_END
| 17.6 | 56 | 0.769886 |
92200f719af66fe1c982836d3439657164750f98 | 95 | h | C | ChainResponsibilityPattern/level.h | coologic/CppDesignPattern | f958610cded28264d0a6f90067e1d2ff3dc70eae | [
"MIT"
] | 63 | 2020-02-21T05:34:04.000Z | 2022-03-18T05:39:53.000Z | ChainResponsibilityPattern/level.h | jhonconal/CppDesignPattern | 79b55b20ffab670d2197be7ee66b4044c5dc965b | [
"MIT"
] | null | null | null | ChainResponsibilityPattern/level.h | jhonconal/CppDesignPattern | 79b55b20ffab670d2197be7ee66b4044c5dc965b | [
"MIT"
] | 26 | 2020-04-01T06:17:29.000Z | 2022-01-11T03:42:26.000Z | #ifndef LEVEL_H
#define LEVEL_H
enum Level {
Level1 = 0,
Level2,
};
#endif // LEVEL_H
| 11.875 | 17 | 0.631579 |
784fc0d1eb3485094f7d14b40c54bf60af3a5a53 | 822 | h | C | libtex/src/main/jni/port/jni_help.h | JMSS-Unknown/AndroidLaTeXMath | 96987de5984ca4d9b8a3e5ded4d756c82715802a | [
"Apache-2.0"
] | 59 | 2019-01-24T15:16:36.000Z | 2022-03-25T09:13:41.000Z | libtex/src/main/jni/port/jni_help.h | JMSS-Unknown/AndroidLaTeXMath | 96987de5984ca4d9b8a3e5ded4d756c82715802a | [
"Apache-2.0"
] | 7 | 2019-09-10T10:55:15.000Z | 2021-06-01T11:56:56.000Z | libtex/src/main/jni/port/jni_help.h | JMSS-Unknown/AndroidLaTeXMath | 96987de5984ca4d9b8a3e5ded4d756c82715802a | [
"Apache-2.0"
] | 15 | 2019-03-11T13:25:30.000Z | 2022-03-09T01:57:49.000Z | #ifndef JNI_HELP_INCLUDED
#define JNI_HELP_INCLUDED
#include <jni.h>
#ifndef NELEM
#define NELEM(x) ((int)(sizeof(x) / sizeof((x)[0])))
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* Register one or more native methods with a particular class.
* "className" looks like "java/lang/String". Aborts on failure.
* TODO: fix all callers and change the return type to void.
*/
int jniRegisterNativeMethods(
C_JNIEnv* env, const char* className,
const JNINativeMethod* gMethods, int numMethods);
#ifdef __cplusplus
}
#endif
#if defined(__cplusplus)
inline int jniRegisterNativeMethods(
JNIEnv* env, const char* className,
const JNINativeMethod* gMethods, int numMethods) {
return jniRegisterNativeMethods(&env->functions, className, gMethods, numMethods);
}
#endif
#endif // JNI_HELP_INCLUDED
| 22.833333 | 86 | 0.739659 |
7f6bb5d81d41b9ced410dc94f5fa8b0ce873433b | 611 | c | C | builtin/exit.c | shlyakpavel/mrsh | 188ae610bbd1e277fbfd25e60ea687c69a648de4 | [
"MIT"
] | null | null | null | builtin/exit.c | shlyakpavel/mrsh | 188ae610bbd1e277fbfd25e60ea687c69a648de4 | [
"MIT"
] | null | null | null | builtin/exit.c | shlyakpavel/mrsh | 188ae610bbd1e277fbfd25e60ea687c69a648de4 | [
"MIT"
] | null | null | null | #include <errno.h>
#include <mrsh/builtin.h>
#include <stdio.h>
#include <stdlib.h>
#include "builtin.h"
static const char exit_usage[] = "usage: exit [n]\n";
int builtin_exit(struct mrsh_state *state, int argc, char *argv[]) {
if (argc > 2) {
fprintf(stderr, exit_usage);
return 1;
}
int status = 0;
if (argc > 1) {
char *endptr;
errno = 0;
long status_long = strtol(argv[1], &endptr, 10);
if (endptr[0] != '\0' || errno != 0 ||
status_long < 0 || status_long > 255) {
fprintf(stderr, exit_usage);
return 1;
}
status = (int)status_long;
}
state->exit = status;
return 0;
}
| 19.709677 | 68 | 0.620295 |
fa50c6753d3772e1f26afa66784ddbd9a50065d3 | 16,437 | c | C | ports/teensy/uart.c | c0d3z3r0/pycopy | d1d42db5afe3927767479285b50418f70e213027 | [
"MIT"
] | 1 | 2020-10-27T21:38:47.000Z | 2020-10-27T21:38:47.000Z | ports/teensy/uart.c | BigCircleLaw/micropython | 383adb654cfd4b818240ba197fdf25166401c343 | [
"MIT"
] | 3 | 2019-07-28T17:39:44.000Z | 2019-08-20T12:12:13.000Z | ports/teensy/uart.c | BigCircleLaw/micropython | 383adb654cfd4b818240ba197fdf25166401c343 | [
"MIT"
] | 1 | 2020-11-19T20:44:32.000Z | 2020-11-19T20:44:32.000Z | /*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2013, 2014 Damien P. George
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdio.h>
#include <string.h>
#include "py/runtime.h"
#include "bufhelper.h"
#include "uart.h"
/// \moduleref pyb
/// \class UART - duplex serial communication bus
///
/// UART implements the standard UART/USART duplex serial communications protocol. At
/// the physical level it consists of 2 lines: RX and TX.
///
/// See usage model of I2C. UART is very similar. Main difference is
/// parameters to init the UART bus:
///
/// from pyb import UART
///
/// uart = UART(1, 9600) # init with given baudrate
/// uart.init(9600, bits=8, stop=1, parity=None) # init with given parameters
///
/// Bits can be 8 or 9, stop can be 1 or 2, parity can be None, 0 (even), 1 (odd).
///
/// Extra method:
///
/// uart.any() # returns True if any characters waiting
struct _pyb_uart_obj_t {
mp_obj_base_t base;
pyb_uart_t uart_id;
bool is_enabled;
// UART_HandleTypeDef uart;
};
pyb_uart_obj_t *pyb_uart_global_debug = NULL;
// assumes Init parameters have been set up correctly
bool uart_init2(pyb_uart_obj_t *uart_obj) {
#if 0
USART_TypeDef *UARTx = NULL;
uint32_t GPIO_Pin = 0;
uint8_t GPIO_AF_UARTx = 0;
GPIO_TypeDef *GPIO_Port = NULL;
switch (uart_obj->uart_id) {
// USART1 is on PA9/PA10 (CK on PA8), PB6/PB7
case PYB_UART_1:
UARTx = USART1;
GPIO_AF_UARTx = GPIO_AF7_USART1;
#if defined(PYBV4) || defined(PYBV10)
GPIO_Port = GPIOB;
GPIO_Pin = GPIO_PIN_6 | GPIO_PIN_7;
#else
GPIO_Port = GPIOA;
GPIO_Pin = GPIO_PIN_9 | GPIO_PIN_10;
#endif
__USART1_CLK_ENABLE();
break;
// USART2 is on PA2/PA3 (CK on PA4), PD5/PD6 (CK on PD7)
case PYB_UART_2:
UARTx = USART2;
GPIO_AF_UARTx = GPIO_AF7_USART2;
GPIO_Port = GPIOA;
GPIO_Pin = GPIO_PIN_2 | GPIO_PIN_3;
__USART2_CLK_ENABLE();
break;
// USART3 is on PB10/PB11 (CK on PB12), PC10/PC11 (CK on PC12), PD8/PD9 (CK on PD10)
case PYB_UART_3:
UARTx = USART3;
GPIO_AF_UARTx = GPIO_AF7_USART3;
#if defined(PYBV3) || defined(PYBV4) | defined(PYBV10)
GPIO_Port = GPIOB;
GPIO_Pin = GPIO_PIN_10 | GPIO_PIN_11;
#else
GPIO_Port = GPIOD;
GPIO_Pin = GPIO_PIN_8 | GPIO_PIN_9;
#endif
__USART3_CLK_ENABLE();
break;
// UART4 is on PA0/PA1, PC10/PC11
case PYB_UART_4:
UARTx = UART4;
GPIO_AF_UARTx = GPIO_AF8_UART4;
GPIO_Port = GPIOA;
GPIO_Pin = GPIO_PIN_0 | GPIO_PIN_1;
__UART4_CLK_ENABLE();
break;
// USART6 is on PC6/PC7 (CK on PC8)
case PYB_UART_6:
UARTx = USART6;
GPIO_AF_UARTx = GPIO_AF8_USART6;
GPIO_Port = GPIOC;
GPIO_Pin = GPIO_PIN_6 | GPIO_PIN_7;
__USART6_CLK_ENABLE();
break;
default:
return false;
}
// init GPIO
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.Pin = GPIO_Pin;
GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
GPIO_InitStructure.Mode = GPIO_MODE_AF_PP;
GPIO_InitStructure.Pull = GPIO_PULLUP;
GPIO_InitStructure.Alternate = GPIO_AF_UARTx;
HAL_GPIO_Init(GPIO_Port, &GPIO_InitStructure);
// init UARTx
uart_obj->uart.Instance = UARTx;
HAL_UART_Init(&uart_obj->uart);
uart_obj->is_enabled = true;
#endif
return true;
}
bool uart_init(pyb_uart_obj_t *uart_obj, uint32_t baudrate) {
#if 0
UART_HandleTypeDef *uh = &uart_obj->uart;
memset(uh, 0, sizeof(*uh));
uh->Init.BaudRate = baudrate;
uh->Init.WordLength = UART_WORDLENGTH_8B;
uh->Init.StopBits = UART_STOPBITS_1;
uh->Init.Parity = UART_PARITY_NONE;
uh->Init.Mode = UART_MODE_TX_RX;
uh->Init.HwFlowCtl = UART_HWCONTROL_NONE;
uh->Init.OverSampling = UART_OVERSAMPLING_16;
#endif
return uart_init2(uart_obj);
}
mp_uint_t uart_rx_any(pyb_uart_obj_t *uart_obj) {
#if 0
return __HAL_UART_GET_FLAG(&uart_obj->uart, UART_FLAG_RXNE);
#else
return 0;
#endif
}
int uart_rx_char(pyb_uart_obj_t *uart_obj) {
uint8_t ch;
#if 0
if (HAL_UART_Receive(&uart_obj->uart, &ch, 1, 0) != HAL_OK) {
ch = 0;
}
#else
ch = 'A';
#endif
return ch;
}
void uart_tx_char(pyb_uart_obj_t *uart_obj, int c) {
#if 0
uint8_t ch = c;
HAL_UART_Transmit(&uart_obj->uart, &ch, 1, 100000);
#endif
}
void uart_tx_str(pyb_uart_obj_t *uart_obj, const char *str) {
#if 0
HAL_UART_Transmit(&uart_obj->uart, (uint8_t *)str, strlen(str), 100000);
#endif
}
void uart_tx_strn(pyb_uart_obj_t *uart_obj, const char *str, uint len) {
#if 0
HAL_UART_Transmit(&uart_obj->uart, (uint8_t *)str, len, 100000);
#endif
}
void uart_tx_strn_cooked(pyb_uart_obj_t *uart_obj, const char *str, uint len) {
for (const char *top = str + len; str < top; str++) {
if (*str == '\n') {
uart_tx_char(uart_obj, '\r');
}
uart_tx_char(uart_obj, *str);
}
}
/******************************************************************************/
/* MicroPython bindings */
STATIC void pyb_uart_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
pyb_uart_obj_t *self = self_in;
if (!self->is_enabled) {
mp_printf(print, "UART(%lu)", self->uart_id);
} else {
#if 0
mp_printf(print, "UART(%lu, baudrate=%u, bits=%u, stop=%u",
self->uart_id, self->uart.Init.BaudRate,
self->uart.Init.WordLength == UART_WORDLENGTH_8B ? 8 : 9,
self->uart.Init.StopBits == UART_STOPBITS_1 ? 1 : 2);
if (self->uart.Init.Parity == UART_PARITY_NONE) {
mp_print_str(print, ", parity=None)");
} else {
mp_printf(print, ", parity=%u)", self->uart.Init.Parity == UART_PARITY_EVEN ? 0 : 1);
}
#endif
}
}
/// \method init(baudrate, *, bits=8, stop=1, parity=None)
///
/// Initialise the SPI bus with the given parameters:
///
/// - `baudrate` is the clock rate.
/// - `bits` is the number of bits per byte, 8 or 9.
/// - `stop` is the number of stop bits, 1 or 2.
/// - `parity` is the parity, `None`, 0 (even) or 1 (odd).
STATIC const mp_arg_t pyb_uart_init_args[] = {
{ MP_QSTR_baudrate, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = 9600} },
{ MP_QSTR_bits, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 8} },
{ MP_QSTR_stop, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 1} },
{ MP_QSTR_parity, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} },
};
#define PYB_UART_INIT_NUM_ARGS MP_ARRAY_SIZE(pyb_uart_init_args)
STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// parse args
mp_arg_val_t vals[PYB_UART_INIT_NUM_ARGS];
mp_arg_parse_all(n_args, args, kw_args, PYB_UART_INIT_NUM_ARGS, pyb_uart_init_args, vals);
#if 0
// set the UART configuration values
memset(&self->uart, 0, sizeof(self->uart));
UART_InitTypeDef *init = &self->uart.Init;
init->BaudRate = vals[0].u_int;
init->WordLength = vals[1].u_int == 8 ? UART_WORDLENGTH_8B : UART_WORDLENGTH_9B;
switch (vals[2].u_int) {
case 1:
init->StopBits = UART_STOPBITS_1;
break;
default:
init->StopBits = UART_STOPBITS_2;
break;
}
if (vals[3].u_obj == mp_const_none) {
init->Parity = UART_PARITY_NONE;
} else {
mp_int_t parity = mp_obj_get_int(vals[3].u_obj);
init->Parity = (parity & 1) ? UART_PARITY_ODD : UART_PARITY_EVEN;
}
init->Mode = UART_MODE_TX_RX;
init->HwFlowCtl = UART_HWCONTROL_NONE;
init->OverSampling = UART_OVERSAMPLING_16;
// init UART (if it fails, it's because the port doesn't exist)
if (!uart_init2(self)) {
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("UART port %d does not exist"), self->uart_id);
}
#endif
return mp_const_none;
}
/// \classmethod \constructor(bus, ...)
///
/// Construct a UART object on the given bus. `bus` can be 1-6, or 'XA', 'XB', 'YA', or 'YB'.
/// With no additional parameters, the UART object is created but not
/// initialised (it has the settings from the last initialisation of
/// the bus, if any). If extra arguments are given, the bus is initialised.
/// See `init` for parameters of initialisation.
///
/// The physical pins of the UART busses are:
///
/// - `UART(4)` is on `XA`: `(TX, RX) = (X1, X2) = (PA0, PA1)`
/// - `UART(1)` is on `XB`: `(TX, RX) = (X9, X10) = (PB6, PB7)`
/// - `UART(6)` is on `YA`: `(TX, RX) = (Y1, Y2) = (PC6, PC7)`
/// - `UART(3)` is on `YB`: `(TX, RX) = (Y9, Y10) = (PB10, PB11)`
/// - `UART(2)` is on: `(TX, RX) = (X3, X4) = (PA2, PA3)`
STATIC mp_obj_t pyb_uart_make_new(const mp_obj_type_t *type, uint n_args, uint n_kw, const mp_obj_t *args) {
// check arguments
mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true);
// create object
pyb_uart_obj_t *o = m_new_obj(pyb_uart_obj_t);
o->base.type = &pyb_uart_type;
// work out port
o->uart_id = 0;
#if 0
if (mp_obj_is_str(args[0])) {
const char *port = mp_obj_str_get_str(args[0]);
if (0) {
#if defined(PYBV10)
} else if (strcmp(port, "XA") == 0) {
o->uart_id = PYB_UART_XA;
} else if (strcmp(port, "XB") == 0) {
o->uart_id = PYB_UART_XB;
} else if (strcmp(port, "YA") == 0) {
o->uart_id = PYB_UART_YA;
} else if (strcmp(port, "YB") == 0) {
o->uart_id = PYB_UART_YB;
#endif
} else {
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("UART port %s does not exist"), port);
}
} else {
o->uart_id = mp_obj_get_int(args[0]);
}
#endif
if (n_args > 1 || n_kw > 0) {
// start the peripheral
mp_map_t kw_args;
mp_map_init_fixed_table(&kw_args, n_kw, args + n_args);
pyb_uart_init_helper(o, n_args - 1, args + 1, &kw_args);
}
return o;
}
STATIC mp_obj_t pyb_uart_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
return pyb_uart_init_helper(args[0], n_args - 1, args + 1, kw_args);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_uart_init_obj, 1, pyb_uart_init);
/// \method deinit()
/// Turn off the UART bus.
STATIC mp_obj_t pyb_uart_deinit(mp_obj_t self_in) {
//pyb_uart_obj_t *self = self_in;
// TODO
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_uart_deinit_obj, pyb_uart_deinit);
/// \method any()
/// Return `True` if any characters waiting, else `False`.
STATIC mp_obj_t pyb_uart_any(mp_obj_t self_in) {
pyb_uart_obj_t *self = self_in;
if (uart_rx_any(self)) {
return mp_const_true;
} else {
return mp_const_false;
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_uart_any_obj, pyb_uart_any);
/// \method send(send, *, timeout=5000)
/// Send data on the bus:
///
/// - `send` is the data to send (an integer to send, or a buffer object).
/// - `timeout` is the timeout in milliseconds to wait for the send.
///
/// Return value: `None`.
STATIC const mp_arg_t pyb_uart_send_args[] = {
{ MP_QSTR_send, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 5000} },
};
#define PYB_UART_SEND_NUM_ARGS MP_ARRAY_SIZE(pyb_uart_send_args)
STATIC mp_obj_t pyb_uart_send(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// TODO assumes transmission size is 8-bits wide
pyb_uart_obj_t *self = args[0];
// parse args
mp_arg_val_t vals[PYB_UART_SEND_NUM_ARGS];
mp_arg_parse_all(n_args - 1, args + 1, kw_args, PYB_UART_SEND_NUM_ARGS, pyb_uart_send_args, vals);
#if 0
// get the buffer to send from
mp_buffer_info_t bufinfo;
uint8_t data[1];
pyb_buf_get_for_send(vals[0].u_obj, &bufinfo, data);
// send the data
HAL_StatusTypeDef status = HAL_UART_Transmit(&self->uart, bufinfo.buf, bufinfo.len, vals[1].u_int);
if (status != HAL_OK) {
// TODO really need a HardwareError object, or something
mp_raise_msg_varg(&mp_type_Exception, MP_ERROR_TEXT("HAL_UART_Transmit failed with code %d"), status);
}
#else
(void)self;
#endif
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_uart_send_obj, 1, pyb_uart_send);
/// \method recv(recv, *, timeout=5000)
///
/// Receive data on the bus:
///
/// - `recv` can be an integer, which is the number of bytes to receive,
/// or a mutable buffer, which will be filled with received bytes.
/// - `timeout` is the timeout in milliseconds to wait for the receive.
///
/// Return value: if `recv` is an integer then a new buffer of the bytes received,
/// otherwise the same buffer that was passed in to `recv`.
#if 0
STATIC const mp_arg_t pyb_uart_recv_args[] = {
{ MP_QSTR_recv, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_timeout, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 5000} },
};
#define PYB_UART_RECV_NUM_ARGS MP_ARRAY_SIZE(pyb_uart_recv_args)
#endif
STATIC mp_obj_t pyb_uart_recv(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
// TODO assumes transmission size is 8-bits wide
pyb_uart_obj_t *self = args[0];
#if 0
// parse args
mp_arg_val_t vals[PYB_UART_RECV_NUM_ARGS];
mp_arg_parse_all(n_args - 1, args + 1, kw_args, PYB_UART_RECV_NUM_ARGS, pyb_uart_recv_args, vals);
// get the buffer to receive into
mp_buffer_info_t bufinfo;
mp_obj_t o_ret = pyb_buf_get_for_recv(vals[0].u_obj, &bufinfo);
// receive the data
HAL_StatusTypeDef status = HAL_UART_Receive(&self->uart, bufinfo.buf, bufinfo.len, vals[1].u_int);
if (status != HAL_OK) {
// TODO really need a HardwareError object, or something
mp_raise_msg_varg(&mp_type_Exception, MP_ERROR_TEXT("HAL_UART_Receive failed with code %d"), status);
}
// return the received data
if (o_ret == MP_OBJ_NULL) {
return vals[0].u_obj;
} else {
return mp_obj_str_builder_end(o_ret);
}
#else
(void)self;
return mp_const_none;
#endif
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_uart_recv_obj, 1, pyb_uart_recv);
STATIC const mp_rom_map_elem_t pyb_uart_locals_dict_table[] = {
// instance methods
{ MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&pyb_uart_init_obj) },
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&pyb_uart_deinit_obj) },
{ MP_ROM_QSTR(MP_QSTR_any), MP_ROM_PTR(&pyb_uart_any_obj) },
{ MP_ROM_QSTR(MP_QSTR_send), MP_ROM_PTR(&pyb_uart_send_obj) },
{ MP_ROM_QSTR(MP_QSTR_recv), MP_ROM_PTR(&pyb_uart_recv_obj) },
};
STATIC MP_DEFINE_CONST_DICT(pyb_uart_locals_dict, pyb_uart_locals_dict_table);
const mp_obj_type_t pyb_uart_type = {
{ &mp_type_type },
.name = MP_QSTR_UART,
.print = pyb_uart_print,
.make_new = pyb_uart_make_new,
.locals_dict = (mp_obj_t)&pyb_uart_locals_dict,
};
| 33.273279 | 114 | 0.641662 |
d250b8ae553a2faebea26c79ddaf71ed6e83b4e8 | 2,831 | h | C | BLSmoke/Vender/StaticLibrary/GizWifiSDK.framework/Versions/A/Headers/GizDeviceJointActionCenter.h | zhufeng19940210/BLSmoke | 135fd0f9ac6beb0dc9332328198216cbb6346580 | [
"MIT"
] | null | null | null | BLSmoke/Vender/StaticLibrary/GizWifiSDK.framework/Versions/A/Headers/GizDeviceJointActionCenter.h | zhufeng19940210/BLSmoke | 135fd0f9ac6beb0dc9332328198216cbb6346580 | [
"MIT"
] | null | null | null | BLSmoke/Vender/StaticLibrary/GizWifiSDK.framework/Versions/A/Headers/GizDeviceJointActionCenter.h | zhufeng19940210/BLSmoke | 135fd0f9ac6beb0dc9332328198216cbb6346580 | [
"MIT"
] | null | null | null | //
// GizDeviceJointActionCenter.h
// GizWifiSDK
//
// Created by Tom on 2017/6/20.
// Copyright © 2017年 gizwits. All rights reserved.
//
#import <GizWifiSDK/GizDeviceJointAction.h>
@class GizWifiDevice;
@protocol GizDeviceJointActionCenterDelegate <NSObject>
@optional
/**
联动列表回调。添加联动、删除联动、同步更新联动列表、联动列表变化上报都使用该回调接口
@param jointActionOwner 触发回调的GizWifiDevice对象
@param result 详细见 GizWifiErrorCode 枚举定义。GIZ_SDK_SUCCESS 表示成功同时jointActionList为最新的联动列表;其他为失败并且jointActionList大小为0
@param jointActionList 联动列表,是GizDeviceJointAction对象数组
@see 触发函数 [GizDeviceJointActionCenter addJointAction:jointActionName:jointActionRule:]
@see 触发函数 [GizDeviceJointActionCenter removeJointAction:jointAction:]
@see 触发函数 [GizDeviceJointActionCenter updateJointActions:]
@see GizWifiErrorCode
*/
- (void)didUpdateJointActions:(GizWifiDevice * _Nullable)jointActionOwner result:(NSError * _Nonnull)result jointActionList:(NSArray <GizDeviceJointAction *>* _Nullable)jointActionList;
@end
@interface GizDeviceJointActionCenter : NSObject
/**
联动列表Map。Key为设备对象即jointActionOwner,value为这个jointActionOwner设备上的联动列表。联动列表缓存了GizDeviceJointAction对象。使用时,要根据设备对象查找联动列表
*/
@property (class, strong, nonatomic, readonly) NSMapTable<GizWifiDevice *, NSArray<GizDeviceJointAction *>*>* _Nullable jointActionListMap;
/**
GizDeviceJointActionCenterDelegate委托
*/
@property (class, weak, nonatomic) id <GizDeviceJointActionCenterDelegate> _Nullable delegate;
/**
添加联动。添加成功后会被分配一个联动ID,此时会返回最新的联动列表,失败时返回错误信息
@param jointActionOwner 联动的管理者,参见GizDeviceJointAction类中jointActionOwner变量的描述。此参数不能填nil
@param jointActionName 联动名称。此参数为选填参数,如果不指定名称此参数填nil,App也可以在成功添加联动以后再修改名称
@param enabled 是否开启联动。true为开启,false为关闭
@param jointActionRule 联动规则,是GizDeviceJointActionRule对象。此参数为选填参数,如果不指定联动规则此参数填nil,App也可以在成功添加联动以后再添加联动规则
@see 回调 [GizDeviceJointActionCenterDelegate didUpdateJointActions:result:jointActionList:]
*/
+ (void)addJointAction:(GizWifiDevice * _Nonnull)jointActionOwner jointActionName:(NSString * _Nullable)jointActionName enabled:(BOOL)enabled jointActionRule:(GizDeviceJointActionRule * _Nullable)jointActionRule;
/**
删除联动。删除成功时返回最新的联动列表,删除失败时返回错误信息
@param jointActionOwner 联动的管理者,参见GizDeviceJointAction类中jointActionOwner变量的描述。此参数不能填nil
@param jointAction 待删除的联动。参见GizDeviceJointAction类中jointAction变量的描述。此参数不能填nil
@see 回调 [GizDeviceJointActionCenterDelegate didUpdateJointActions:result:jointActionList:]
*/
+ (void)removeJointAction:(GizWifiDevice * _Nonnull)jointActionOwner jointAction:(GizDeviceJointAction * _Nonnull)jointAction;
/**
更新联动列表。更新成功时返回最新的联动列表,更新失败时返回错误信息
@param jointActionOwner 联动的管理者,参见GizDeviceJointAction类中jointActionOwner变量的描述。此参数不能填nil
@see 回调 [GizDeviceJointActionCenterDelegate didUpdateJointActions:result:jointActionList:]
*/
+ (void)updateJointActions:(GizWifiDevice * _Nonnull)jointActionOwner;
@end
| 41.632353 | 212 | 0.845638 |
3224a33c85712e0e8996ba390612a3a0afe2556c | 6,865 | h | C | iOS/Classes/Native/UnityEngine_UnityEngine_SocialPlatforms_Impl_Leade1185876199.h | mopsicus/unity-share-plugin-ios-android | 3ee99aef36034a1e4d7b156172953f9b4dfa696f | [
"MIT"
] | 11 | 2016-07-22T19:58:09.000Z | 2021-09-21T12:51:40.000Z | iOS/Classes/Native/UnityEngine_UnityEngine_SocialPlatforms_Impl_Leade1185876199.h | mopsicus/unity-share-plugin-ios-android | 3ee99aef36034a1e4d7b156172953f9b4dfa696f | [
"MIT"
] | 1 | 2018-05-07T14:32:13.000Z | 2018-05-08T09:15:30.000Z | iOS/Classes/Native/UnityEngine_UnityEngine_SocialPlatforms_Impl_Leade1185876199.h | mopsicus/unity-share-plugin-ios-android | 3ee99aef36034a1e4d7b156172953f9b4dfa696f | [
"MIT"
] | null | null | null | #pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
// UnityEngine.SocialPlatforms.IScore
struct IScore_t4279057999;
// UnityEngine.SocialPlatforms.IScore[]
struct IScoreU5BU5D_t250104726;
// System.String
struct String_t;
// System.String[]
struct StringU5BU5D_t4054002952;
#include "mscorlib_System_Object4170816371.h"
#include "UnityEngine_UnityEngine_SocialPlatforms_UserScope1608660171.h"
#include "UnityEngine_UnityEngine_SocialPlatforms_Range1533311935.h"
#include "UnityEngine_UnityEngine_SocialPlatforms_TimeScope1305796361.h"
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma clang diagnostic ignored "-Wunused-variable"
#endif
// UnityEngine.SocialPlatforms.Impl.Leaderboard
struct Leaderboard_t1185876199 : public Il2CppObject
{
public:
// System.Boolean UnityEngine.SocialPlatforms.Impl.Leaderboard::m_Loading
bool ___m_Loading_0;
// UnityEngine.SocialPlatforms.IScore UnityEngine.SocialPlatforms.Impl.Leaderboard::m_LocalUserScore
Il2CppObject * ___m_LocalUserScore_1;
// System.UInt32 UnityEngine.SocialPlatforms.Impl.Leaderboard::m_MaxRange
uint32_t ___m_MaxRange_2;
// UnityEngine.SocialPlatforms.IScore[] UnityEngine.SocialPlatforms.Impl.Leaderboard::m_Scores
IScoreU5BU5D_t250104726* ___m_Scores_3;
// System.String UnityEngine.SocialPlatforms.Impl.Leaderboard::m_Title
String_t* ___m_Title_4;
// System.String[] UnityEngine.SocialPlatforms.Impl.Leaderboard::m_UserIDs
StringU5BU5D_t4054002952* ___m_UserIDs_5;
// System.String UnityEngine.SocialPlatforms.Impl.Leaderboard::<id>k__BackingField
String_t* ___U3CidU3Ek__BackingField_6;
// UnityEngine.SocialPlatforms.UserScope UnityEngine.SocialPlatforms.Impl.Leaderboard::<userScope>k__BackingField
int32_t ___U3CuserScopeU3Ek__BackingField_7;
// UnityEngine.SocialPlatforms.Range UnityEngine.SocialPlatforms.Impl.Leaderboard::<range>k__BackingField
Range_t1533311935 ___U3CrangeU3Ek__BackingField_8;
// UnityEngine.SocialPlatforms.TimeScope UnityEngine.SocialPlatforms.Impl.Leaderboard::<timeScope>k__BackingField
int32_t ___U3CtimeScopeU3Ek__BackingField_9;
public:
inline static int32_t get_offset_of_m_Loading_0() { return static_cast<int32_t>(offsetof(Leaderboard_t1185876199, ___m_Loading_0)); }
inline bool get_m_Loading_0() const { return ___m_Loading_0; }
inline bool* get_address_of_m_Loading_0() { return &___m_Loading_0; }
inline void set_m_Loading_0(bool value)
{
___m_Loading_0 = value;
}
inline static int32_t get_offset_of_m_LocalUserScore_1() { return static_cast<int32_t>(offsetof(Leaderboard_t1185876199, ___m_LocalUserScore_1)); }
inline Il2CppObject * get_m_LocalUserScore_1() const { return ___m_LocalUserScore_1; }
inline Il2CppObject ** get_address_of_m_LocalUserScore_1() { return &___m_LocalUserScore_1; }
inline void set_m_LocalUserScore_1(Il2CppObject * value)
{
___m_LocalUserScore_1 = value;
Il2CppCodeGenWriteBarrier(&___m_LocalUserScore_1, value);
}
inline static int32_t get_offset_of_m_MaxRange_2() { return static_cast<int32_t>(offsetof(Leaderboard_t1185876199, ___m_MaxRange_2)); }
inline uint32_t get_m_MaxRange_2() const { return ___m_MaxRange_2; }
inline uint32_t* get_address_of_m_MaxRange_2() { return &___m_MaxRange_2; }
inline void set_m_MaxRange_2(uint32_t value)
{
___m_MaxRange_2 = value;
}
inline static int32_t get_offset_of_m_Scores_3() { return static_cast<int32_t>(offsetof(Leaderboard_t1185876199, ___m_Scores_3)); }
inline IScoreU5BU5D_t250104726* get_m_Scores_3() const { return ___m_Scores_3; }
inline IScoreU5BU5D_t250104726** get_address_of_m_Scores_3() { return &___m_Scores_3; }
inline void set_m_Scores_3(IScoreU5BU5D_t250104726* value)
{
___m_Scores_3 = value;
Il2CppCodeGenWriteBarrier(&___m_Scores_3, value);
}
inline static int32_t get_offset_of_m_Title_4() { return static_cast<int32_t>(offsetof(Leaderboard_t1185876199, ___m_Title_4)); }
inline String_t* get_m_Title_4() const { return ___m_Title_4; }
inline String_t** get_address_of_m_Title_4() { return &___m_Title_4; }
inline void set_m_Title_4(String_t* value)
{
___m_Title_4 = value;
Il2CppCodeGenWriteBarrier(&___m_Title_4, value);
}
inline static int32_t get_offset_of_m_UserIDs_5() { return static_cast<int32_t>(offsetof(Leaderboard_t1185876199, ___m_UserIDs_5)); }
inline StringU5BU5D_t4054002952* get_m_UserIDs_5() const { return ___m_UserIDs_5; }
inline StringU5BU5D_t4054002952** get_address_of_m_UserIDs_5() { return &___m_UserIDs_5; }
inline void set_m_UserIDs_5(StringU5BU5D_t4054002952* value)
{
___m_UserIDs_5 = value;
Il2CppCodeGenWriteBarrier(&___m_UserIDs_5, value);
}
inline static int32_t get_offset_of_U3CidU3Ek__BackingField_6() { return static_cast<int32_t>(offsetof(Leaderboard_t1185876199, ___U3CidU3Ek__BackingField_6)); }
inline String_t* get_U3CidU3Ek__BackingField_6() const { return ___U3CidU3Ek__BackingField_6; }
inline String_t** get_address_of_U3CidU3Ek__BackingField_6() { return &___U3CidU3Ek__BackingField_6; }
inline void set_U3CidU3Ek__BackingField_6(String_t* value)
{
___U3CidU3Ek__BackingField_6 = value;
Il2CppCodeGenWriteBarrier(&___U3CidU3Ek__BackingField_6, value);
}
inline static int32_t get_offset_of_U3CuserScopeU3Ek__BackingField_7() { return static_cast<int32_t>(offsetof(Leaderboard_t1185876199, ___U3CuserScopeU3Ek__BackingField_7)); }
inline int32_t get_U3CuserScopeU3Ek__BackingField_7() const { return ___U3CuserScopeU3Ek__BackingField_7; }
inline int32_t* get_address_of_U3CuserScopeU3Ek__BackingField_7() { return &___U3CuserScopeU3Ek__BackingField_7; }
inline void set_U3CuserScopeU3Ek__BackingField_7(int32_t value)
{
___U3CuserScopeU3Ek__BackingField_7 = value;
}
inline static int32_t get_offset_of_U3CrangeU3Ek__BackingField_8() { return static_cast<int32_t>(offsetof(Leaderboard_t1185876199, ___U3CrangeU3Ek__BackingField_8)); }
inline Range_t1533311935 get_U3CrangeU3Ek__BackingField_8() const { return ___U3CrangeU3Ek__BackingField_8; }
inline Range_t1533311935 * get_address_of_U3CrangeU3Ek__BackingField_8() { return &___U3CrangeU3Ek__BackingField_8; }
inline void set_U3CrangeU3Ek__BackingField_8(Range_t1533311935 value)
{
___U3CrangeU3Ek__BackingField_8 = value;
}
inline static int32_t get_offset_of_U3CtimeScopeU3Ek__BackingField_9() { return static_cast<int32_t>(offsetof(Leaderboard_t1185876199, ___U3CtimeScopeU3Ek__BackingField_9)); }
inline int32_t get_U3CtimeScopeU3Ek__BackingField_9() const { return ___U3CtimeScopeU3Ek__BackingField_9; }
inline int32_t* get_address_of_U3CtimeScopeU3Ek__BackingField_9() { return &___U3CtimeScopeU3Ek__BackingField_9; }
inline void set_U3CtimeScopeU3Ek__BackingField_9(int32_t value)
{
___U3CtimeScopeU3Ek__BackingField_9 = value;
}
};
#ifdef __clang__
#pragma clang diagnostic pop
#endif
| 46.385135 | 176 | 0.833649 |
36f6fca33637ee9f31fb3a67c7822da16daeca9c | 7,042 | h | C | spectangular/svd.h | DPSablowski/Spectangular | 39a1c3c3731de6dd276a77610611c65739c1dc27 | [
"Apache-2.0"
] | 3 | 2021-02-02T18:05:26.000Z | 2021-09-27T19:25:42.000Z | spectangular/svd.h | DPSablowski/Spectangular | 39a1c3c3731de6dd276a77610611c65739c1dc27 | [
"Apache-2.0"
] | 1 | 2021-09-28T13:39:50.000Z | 2021-09-28T13:39:50.000Z | spectangular/svd.h | DPSablowski/Spectangular | 39a1c3c3731de6dd276a77610611c65739c1dc27 | [
"Apache-2.0"
] | null | null | null | struct SVD {
Int m,n;
MatDoub u,v;
VecDoub w;
Doub eps, tsh;
SVD(MatDoub_I &a) : m(a.nrows()), n(a.ncols()), u(a), v(n,n), w(n) {
eps = numeric_limits<Doub>::epsilon();
decompose();
reorder();
tsh = 0.5*sqrt(m+n+1.)*w[0]*eps;
}
void solve(VecDoub_I &b, VecDoub_O &x, Doub thresh);
void solve(MatDoub_I &b, MatDoub_O &x, Doub thresh);
Int rank(Doub thresh);
Int nullity(Doub thresh);
MatDoub range(Doub thresh);
MatDoub nullspace(Doub thresh);
Doub inv_condition() {
return (w[0] <= 0. || w[n-1] <= 0.) ? 0. : w[n-1]/w[0];
}
void decompose();
void reorder();
Doub pythag(const Doub a, const Doub b);
};
void SVD::solve(VecDoub_I &b, VecDoub_O &x, Doub thresh = -1.) {
Int i,j,jj;
Doub s;
if (b.size() != m || x.size() != n) throw("SVD::solve bad sizes");
VecDoub tmp(n);
tsh = (thresh >= 0. ? thresh : 0.5*sqrt(m+n+1.)*w[0]*eps);
for (j=0;j<n;j++) {
s=0.0;
if (w[j] > tsh) {
for (i=0;i<m;i++) s += u[i][j]*b[i];
s /= w[j];
}
tmp[j]=s;
}
for (j=0;j<n;j++) {
s=0.0;
for (jj=0;jj<n;jj++) s += v[j][jj]*tmp[jj];
x[j]=s;
}
}
void SVD::solve(MatDoub_I &b, MatDoub_O &x, Doub thresh = -1.)
{
int i,j,p=b.ncols();
if (b.nrows() != m || x.nrows() != n || x.ncols() != p)
throw("SVD::solve bad sizes");
VecDoub xx(n),bcol(m);
for (j=0;j<p;j++) {
for (i=0;i<m;i++) bcol[i] = b[i][j];
solve(bcol,xx,thresh);
for (i=0;i<n;i++) x[i][j] = xx[i];
}
}
Int SVD::rank(Doub thresh = -1.) {
Int j,nr=0;
tsh = (thresh >= 0. ? thresh : 0.5*sqrt(m+n+1.)*w[0]*eps);
for (j=0;j<n;j++) if (w[j] > tsh) nr++;
return nr;
}
Int SVD::nullity(Doub thresh = -1.) {
Int j,nn=0;
tsh = (thresh >= 0. ? thresh : 0.5*sqrt(m+n+1.)*w[0]*eps);
for (j=0;j<n;j++) if (w[j] <= tsh) nn++;
return nn;
}
MatDoub SVD::range(Doub thresh = -1.){
Int i,j,nr=0;
MatDoub rnge(m,rank(thresh));
for (j=0;j<n;j++) {
if (w[j] > tsh) {
for (i=0;i<m;i++) rnge[i][nr] = u[i][j];
nr++;
}
}
return rnge;
}
MatDoub SVD::nullspace(Doub thresh = -1.){
Int j,jj,nn=0;
MatDoub nullsp(n,nullity(thresh));
for (j=0;j<n;j++) {
if (w[j] <= tsh) {
for (jj=0;jj<n;jj++) nullsp[jj][nn] = v[jj][j];
nn++;
}
}
return nullsp;
}
void SVD::decompose() {
cout<<"decompose"<<endl;
bool flag;
Int i,its,j,jj,k,l,nm;
Doub anorm,c,f,g,h,s,scale,x,y,z;
VecDoub rv1(n);
g = scale = anorm = 0.0;
for (i=0;i<n;i++) {
l=i+2;
rv1[i]=scale*g;
g=s=scale=0.0;
if (i < m) {
for (k=i;k<m;k++) scale += abs(u[k][i]);
if (scale != 0.0) {
for (k=i;k<m;k++) {
u[k][i] /= scale;
s += u[k][i]*u[k][i];
}
f=u[i][i];
g = -SIGN(sqrt(s),f);
h=f*g-s;
u[i][i]=f-g;
for (j=l-1;j<n;j++) {
for (s=0.0,k=i;k<m;k++) s += u[k][i]*u[k][j];
f=s/h;
for (k=i;k<m;k++) u[k][j] += f*u[k][i];
}
for (k=i;k<m;k++) u[k][i] *= scale;
}
}
cout<<"w"<<endl;
w[i]=scale *g;
g=s=scale=0.0;
if (i+1 <= m && i+1 != n) {
for (k=l-1;k<n;k++) scale += abs(u[i][k]);
if (scale != 0.0) {
for (k=l-1;k<n;k++) {
u[i][k] /= scale;
s += u[i][k]*u[i][k];
}
f=u[i][l-1];
g = -SIGN(sqrt(s),f);
h=f*g-s;
u[i][l-1]=f-g;
for (k=l-1;k<n;k++) rv1[k]=u[i][k]/h;
for (j=l-1;j<m;j++) {
for (s=0.0,k=l-1;k<n;k++) s += u[j][k]*u[i][k];
for (k=l-1;k<n;k++) u[j][k] += s*rv1[k];
}
for (k=l-1;k<n;k++) u[i][k] *= scale;
}
}
anorm=MAX(anorm,(abs(w[i])+abs(rv1[i])));
}
for (i=n-1;i>=0;i--) {
if (i < n-1) {
if (g != 0.0) {
for (j=l;j<n;j++)
v[j][i]=(u[i][j]/u[i][l])/g;
for (j=l;j<n;j++) {
for (s=0.0,k=l;k<n;k++) s += u[i][k]*v[k][j];
for (k=l;k<n;k++) v[k][j] += s*v[k][i];
}
}
for (j=l;j<n;j++) v[i][j]=v[j][i]=0.0;
}
cout<<"v"<<endl;
v[i][i]=1.0;
g=rv1[i];
l=i;
}
for (i=MIN(m,n)-1;i>=0;i--) {
l=i+1;
g=w[i];
for (j=l;j<n;j++) u[i][j]=0.0;
if (g != 0.0) {
g=1.0/g;
for (j=l;j<n;j++) {
for (s=0.0,k=l;k<m;k++) s += u[k][i]*u[k][j];
f=(s/u[i][i])*g;
for (k=i;k<m;k++) u[k][j] += f*u[k][i];
}
for (j=i;j<m;j++) u[j][i] *= g;
} else for (j=i;j<m;j++) u[j][i]=0.0;
++u[i][i];
}
for (k=n-1;k>=0;k--) {
for (its=0;its<30;its++) {
flag=true;
for (l=k;l>=0;l--) {
nm=l-1;
if (l == 0 || abs(rv1[l]) <= eps*anorm) {
flag=false;
break;
}
if (abs(w[nm]) <= eps*anorm) break;
}
if (flag) {
c=0.0;
s=1.0;
for (i=l;i<k+1;i++) {
f=s*rv1[i];
rv1[i]=c*rv1[i];
if (abs(f) <= eps*anorm) break;
g=w[i];
h=pythag(f,g);
w[i]=h;
h=1.0/h;
c=g*h;
s = -f*h;
for (j=0;j<m;j++) {
y=u[j][nm];
z=u[j][i];
u[j][nm]=y*c+z*s;
u[j][i]=z*c-y*s;
}
}
}
cout<<"z"<<endl;
z=w[k];
if (l == k) {
if (z < 0.0) {
w[k] = -z;
for (j=0;j<n;j++) v[j][k] = -v[j][k];
}
break;
}
if (its == 29){
cout<<"no convergence in 30 svdcmp iterations";
return;
}
x=w[l];
nm=k-1;
y=w[nm];
g=rv1[nm];
h=rv1[k];
f=((y-z)*(y+z)+(g-h)*(g+h))/(2.0*h*y);
g=pythag(f,1.0);
f=((x-z)*(x+z)+h*((y/(f+SIGN(g,f)))-h))/x;
c=s=1.0;
for (j=l;j<=nm;j++) {
i=j+1;
g=rv1[i];
y=w[i];
h=s*g;
g=c*g;
z=pythag(f,h);
rv1[j]=z;
c=f/z;
s=h/z;
f=x*c+g*s;
g=g*c-x*s;
h=y*s;
y *= c;
for (jj=0;jj<n;jj++) {
x=v[jj][j];
z=v[jj][i];
v[jj][j]=x*c+z*s;
v[jj][i]=z*c-x*s;
}
z=pythag(f,h);
w[j]=z;
if (z) {
z=1.0/z;
c=f*z;
s=h*z;
}
f=c*g+s*y;
x=c*y-s*g;
for (jj=0;jj<m;jj++) {
y=u[jj][j];
z=u[jj][i];
u[jj][j]=y*c+z*s;
u[jj][i]=z*c-y*s;
}
}
rv1[l]=0.0;
rv1[k]=f;
w[k]=x;
}
}
}
void SVD::reorder() {
Int i,j,k,s,inc=1;
Doub sw;
VecDoub su(m), sv(n);
do { inc *= 3; inc++; } while (inc <= n);
do {
inc /= 3;
for (i=inc;i<n;i++) {
sw = w[i];
for (k=0;k<m;k++) su[k] = u[k][i];
for (k=0;k<n;k++) sv[k] = v[k][i];
j = i;
while (w[j-inc] < sw) {
w[j] = w[j-inc];
for (k=0;k<m;k++) u[k][j] = u[k][j-inc];
for (k=0;k<n;k++) v[k][j] = v[k][j-inc];
j -= inc;
if (j < inc) break;
}
w[j] = sw;
for (k=0;k<m;k++) u[k][j] = su[k];
for (k=0;k<n;k++) v[k][j] = sv[k];
}
} while (inc > 1);
for (k=0;k<n;k++) {
s=0;
for (i=0;i<m;i++) if (u[i][k] < 0.) s++;
for (j=0;j<n;j++) if (v[j][k] < 0.) s++;
if (s > (m+n)/2) {
for (i=0;i<m;i++) u[i][k] = -u[i][k];
for (j=0;j<n;j++) v[j][k] = -v[j][k];
}
}
}
Doub SVD::pythag(const Doub a, const Doub b) {
Doub absa=abs(a), absb=abs(b);
return (absa > absb ? absa*sqrt(1.0+SQR(absb/absa)) :
(absb == 0.0 ? 0.0 : absb*sqrt(1.0+SQR(absa/absb))));
}
| 21.801858 | 70 | 0.403437 |
324a4762495eb80781f1bc01cef55ce14a99b55d | 9,796 | h | C | System/Library/PrivateFrameworks/CoreRC.framework/CoreCECDevice.h | lechium/tvOS145Headers | 9940da19adb0017f8037853e9cfccbe01b290dd5 | [
"MIT"
] | 5 | 2021-04-29T04:31:43.000Z | 2021-08-19T18:59:58.000Z | System/Library/PrivateFrameworks/CoreRC.framework/CoreCECDevice.h | lechium/tvOS145Headers | 9940da19adb0017f8037853e9cfccbe01b290dd5 | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/CoreRC.framework/CoreCECDevice.h | lechium/tvOS145Headers | 9940da19adb0017f8037853e9cfccbe01b290dd5 | [
"MIT"
] | 1 | 2022-03-19T11:16:23.000Z | 2022-03-19T11:16:23.000Z | /*
* This header is generated by classdump-dyld 1.5
* on Wednesday, April 28, 2021 at 9:11:25 PM Mountain Standard Time
* Operating System: Version 14.5 (Build 18L204)
* Image Source: /System/Library/PrivateFrameworks/CoreRC.framework/CoreRC
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley.
*/
#import <CoreRC/CoreRC-Structs.h>
#import <CoreRC/CoreRCDevice.h>
@class NSDictionary;
@interface CoreCECDevice : CoreRCDevice {
unsigned char _logicalAddress;
BOOL _isActiveSource;
BOOL _systemAudioControlEnabled;
BOOL _audioReturnChannelControlEnabled;
BOOL _audioMuteStatus;
unsigned long long _physicalAddress;
unsigned long long _deviceType;
unsigned long long _cecVersion;
unsigned long long _vendorID;
unsigned long long _allDeviceTypes;
NSDictionary* _rcProfile;
unsigned long long _powerStatus;
unsigned long long _deckStatus;
unsigned long long _audioVolumeStatus;
NSDictionary* _audioFormats;
unsigned long long _audioFormatsCount;
unsigned long long _deviceFeatures;
unsigned long long _knownDeviceFeatures;
}
@property (assign,nonatomic) unsigned char logicalAddress; //@synthesize logicalAddress=_logicalAddress - In the implementation block
@property (assign,nonatomic) unsigned long long physicalAddress; //@synthesize physicalAddress=_physicalAddress - In the implementation block
@property (assign,nonatomic) unsigned long long deviceType; //@synthesize deviceType=_deviceType - In the implementation block
@property (assign,nonatomic) unsigned long long cecVersion; //@synthesize cecVersion=_cecVersion - In the implementation block
@property (assign,nonatomic) unsigned long long vendorID; //@synthesize vendorID=_vendorID - In the implementation block
@property (assign,nonatomic) unsigned long long powerStatus; //@synthesize powerStatus=_powerStatus - In the implementation block
@property (assign,nonatomic) unsigned long long deckStatus; //@synthesize deckStatus=_deckStatus - In the implementation block
@property (assign,nonatomic) unsigned long long allDeviceTypes; //@synthesize allDeviceTypes=_allDeviceTypes - In the implementation block
@property (assign,nonatomic) unsigned long long deviceFeatures; //@synthesize deviceFeatures=_deviceFeatures - In the implementation block
@property (assign,nonatomic) unsigned long long knownDeviceFeatures; //@synthesize knownDeviceFeatures=_knownDeviceFeatures - In the implementation block
@property (nonatomic,copy) NSDictionary * rcProfile; //@synthesize rcProfile=_rcProfile - In the implementation block
@property (assign,nonatomic) BOOL audioReturnChannelControlEnabled; //@synthesize audioReturnChannelControlEnabled=_audioReturnChannelControlEnabled - In the implementation block
@property (assign,nonatomic) unsigned long long audioVolumeStatus; //@synthesize audioVolumeStatus=_audioVolumeStatus - In the implementation block
@property (assign,nonatomic) BOOL audioMuteStatus; //@synthesize audioMuteStatus=_audioMuteStatus - In the implementation block
@property (nonatomic,copy) NSDictionary * audioFormats; //@synthesize audioFormats=_audioFormats - In the implementation block
@property (assign,nonatomic) unsigned long long audioFormatsCount; //@synthesize audioFormatsCount=_audioFormatsCount - In the implementation block
@property (assign,nonatomic) BOOL isActiveSource; //@synthesize isActiveSource=_isActiveSource - In the implementation block
@property (nonatomic,readonly) BOOL isUnregistered;
@property (nonatomic,readonly) BOOL systemAudioControlEnabled; //@synthesize systemAudioControlEnabled=_systemAudioControlEnabled - In the implementation block
@property (nonatomic,readonly) BOOL isCEC2Device;
+(BOOL)supportsSecureCoding;
-(id)description;
-(void)dealloc;
-(void)encodeWithCoder:(id)arg1 ;
-(id)initWithCoder:(id)arg1 ;
-(id)delegate;
-(void)setDelegate:(id)arg1 ;
-(id)initWithDevice:(id)arg1 ;
-(unsigned long long)deviceType;
-(void)setDeviceType:(unsigned long long)arg1 ;
-(unsigned long long)vendorID;
-(void)setVendorID:(unsigned long long)arg1 ;
-(unsigned long long)deviceFeatures;
-(unsigned long long)powerStatus;
-(NSDictionary *)audioFormats;
-(void)setPowerStatus:(unsigned long long)arg1 ;
-(unsigned long long)allDeviceTypes;
-(unsigned long long)physicalAddress;
-(unsigned char)logicalAddress;
-(BOOL)setPowerStatus:(unsigned long long)arg1 error:(id*)arg2 ;
-(BOOL)setSystemAudioControlEnabled:(BOOL)arg1 error:(id*)arg2 ;
-(BOOL)refreshPropertiesOfDevice:(id)arg1 error:(id*)arg2 ;
-(BOOL)isActiveSource;
-(BOOL)setAudioVolumeStatus:(unsigned long long)arg1 error:(id*)arg2 ;
-(BOOL)setAudioMuteStatus:(BOOL)arg1 error:(id*)arg2 ;
-(BOOL)makeActiveSourceWithTVMenus:(BOOL)arg1 error:(id*)arg2 ;
-(BOOL)systemAudioModeRequest:(unsigned long long)arg1 error:(id*)arg2 ;
-(BOOL)performStandbyWithTargetDevice:(id)arg1 error:(id*)arg2 ;
-(unsigned long long)cecVersion;
-(BOOL)resignActiveSource:(id*)arg1 ;
-(id)initWithBus:(id)arg1 local:(BOOL)arg2 logicalAddress:(unsigned char)arg3 physicalAddress:(unsigned long long)arg4 attributes:(id)arg5 ;
-(void)shouldAssertActiveSource;
-(void)setIsActiveSource:(BOOL)arg1 ;
-(void)deckControlPlayHasBeenReceived:(unsigned long long)arg1 fromDevice:(id)arg2 ;
-(void)deckControlCommandHasBeenReceived:(unsigned long long)arg1 fromDevice:(id)arg2 ;
-(void)deckControlStatusHasBeenUpdated:(unsigned long long)arg1 fromDevice:(id)arg2 ;
-(void)featureAbort:(id)arg1 ;
-(void)standbyRequestHasBeenReceived:(id)arg1 ;
-(void)receivedRequestAudioReturnChannelStatusChangeTo:(unsigned long long)arg1 fromDevice:(id)arg2 ;
-(void)requestAudioReturnChannelStatusChangeTo:(unsigned long long)arg1 didFinishWithResult:(BOOL)arg2 error:(id)arg3 ;
-(void)receivedRequestSystemAudioModeStatusChangeTo:(unsigned long long)arg1 fromDevice:(id)arg2 ;
-(void)requestSystemAudioModeStatusChangeTo:(unsigned long long)arg1 didFinishWithResult:(BOOL)arg2 error:(id)arg3 ;
-(id)initWithBus:(id)arg1 local:(BOOL)arg2 ;
-(BOOL)isUnregistered;
-(id)mergeProperties;
-(void)setPhysicalAddress:(unsigned long long)arg1 ;
-(void)setLogicalAddress:(unsigned char)arg1 ;
-(NSDictionary *)rcProfile;
-(unsigned long long)deckStatus;
-(BOOL)systemAudioControlEnabled;
-(BOOL)audioReturnChannelControlEnabled;
-(unsigned long long)audioVolumeStatus;
-(BOOL)audioMuteStatus;
-(unsigned long long)audioFormatsCount;
-(void)notifyDelegateActiveSourceStatusHasChanged;
-(BOOL)refreshProperties:(id)arg1 ofDevice:(id)arg2 error:(id*)arg3 ;
-(void)willChangePowerStatus:(unsigned long long)arg1 ;
-(void)didChangePowerStatus:(unsigned long long)arg1 ;
-(void)notifyDelegateDeckControlCommandHasBeenReceived:(id)arg1 command:(unsigned long long)arg2 ;
-(void)notifyDelegateDeckControlPlayHasBeenReceived:(id)arg1 playMode:(unsigned long long)arg2 ;
-(void)notifyDelegateDeckControlStatusHasBeenUpdated:(id)arg1 deckInfo:(unsigned long long)arg2 ;
-(void)notifyDelegateFeatureAbort:(id)arg1 ;
-(void)notifyDelegateShouldAssertActiveSource;
-(void)notifyDelegateStandbyRequestHasBeenReceived:(id)arg1 ;
-(void)notifyDelegateReceivedRequestSystemAudioModeStatusChangeTo:(unsigned long long)arg1 fromDevice:(id)arg2 ;
-(void)notifyDelegateRequestSystemAudioModeStatusChangeTo:(unsigned long long)arg1 didFinishWithResult:(BOOL)arg2 error:(id)arg3 ;
-(void)notifyDelegateReceivedRequestAudioReturnChannelStatusChangeTo:(unsigned long long)arg1 fromDevice:(id)arg2 ;
-(void)notifyDelegateRequestAudioReturnChannelStatusChangeTo:(unsigned long long)arg1 didFinishWithResult:(BOOL)arg2 error:(id)arg3 ;
-(BOOL)isCEC2Device;
-(id)initWithBus:(id)arg1 local:(BOOL)arg2 logicalAddress:(unsigned char)arg3 physicalAddress:(unsigned long long)arg4 deviceType:(unsigned long long)arg5 ;
-(void)setDeckStatus:(unsigned long long)arg1 ;
-(BOOL)deckControlSetDeckStatus:(unsigned long long)arg1 error:(id*)arg2 ;
-(BOOL)deckControlCommandWithMode:(unsigned long long)arg1 target:(id)arg2 error:(id*)arg3 ;
-(BOOL)deckControlPlayWithMode:(unsigned long long)arg1 target:(id)arg2 error:(id*)arg3 ;
-(BOOL)deckControlRefreshStatus:(id)arg1 requestType:(unsigned long long)arg2 error:(id*)arg3 ;
-(BOOL)refreshDevices:(id*)arg1 ;
-(BOOL)requestActiveSource:(id*)arg1 ;
-(BOOL)setAudioReturnChannelControlEnabled:(BOOL)arg1 error:(id*)arg2 ;
-(BOOL)requestAudioReturnChannelStatusChangeTo:(unsigned long long)arg1 error:(id*)arg2 ;
-(BOOL)setSupportedAudioFormats:(const CoreCECAudioFormat*)arg1 count:(unsigned long long)arg2 error:(id*)arg3 ;
-(BOOL)setSupportedAudioFormats:(id)arg1 error:(id*)arg2 ;
-(BOOL)requestSystemAudioModeStatusChangeTo:(unsigned long long)arg1 error:(id*)arg2 ;
-(unsigned long long)featureSupportStatus:(unsigned long long)arg1 ;
-(void)setFeature:(unsigned long long)arg1 supportStatus:(unsigned long long)arg2 ;
-(void)setCecVersion:(unsigned long long)arg1 ;
-(void)setAllDeviceTypes:(unsigned long long)arg1 ;
-(void)setRcProfile:(NSDictionary *)arg1 ;
-(void)setAudioReturnChannelControlEnabled:(BOOL)arg1 ;
-(void)setAudioVolumeStatus:(unsigned long long)arg1 ;
-(void)setAudioMuteStatus:(BOOL)arg1 ;
-(void)setAudioFormats:(NSDictionary *)arg1 ;
-(void)setAudioFormatsCount:(unsigned long long)arg1 ;
-(void)setDeviceFeatures:(unsigned long long)arg1 ;
-(unsigned long long)knownDeviceFeatures;
-(void)setKnownDeviceFeatures:(unsigned long long)arg1 ;
@end
| 63.61039 | 192 | 0.77011 |
c5d464629695d89c7490ee852238039df358f9d8 | 406 | h | C | BinSort2/StudentRecord.h | BigWhiteCat/data-structure-and-algorithm | 41374b1e2e78cf422f7c09c97ca3cf96a0793572 | [
"MIT"
] | null | null | null | BinSort2/StudentRecord.h | BigWhiteCat/data-structure-and-algorithm | 41374b1e2e78cf422f7c09c97ca3cf96a0793572 | [
"MIT"
] | null | null | null | BinSort2/StudentRecord.h | BigWhiteCat/data-structure-and-algorithm | 41374b1e2e78cf422f7c09c97ca3cf96a0793572 | [
"MIT"
] | null | null | null | #ifndef STUDENTRECORD_H
#define STUDENTRECORD_H
#include <iostream>
#include <string>
struct StudentRecord {
operator int() const {
return score;
}
int score;
std::string *name;
};
inline std::ostream &operator<<(std::ostream &out, const StudentRecord &record) {
std::cout << record.score << " " << *record.name << std::endl;
return out;
}
#endif // STUDENTRECORD_H
| 18.454545 | 81 | 0.64532 |
303c09cc8912b6b528db9ae0c1824337f91d9ea1 | 1,733 | h | C | third_party/tests/Earlgrey_Verilator_0_1/src/lowrisc_dv_dpi_tcp_server_0.1/tcp_server.h | parzival3/Surelog | cf126533ebfb2af7df321057af9e3535feb30487 | [
"Apache-2.0"
] | 156 | 2019-11-16T17:29:55.000Z | 2022-01-21T05:41:13.000Z | third_party/tests/Earlgrey_Verilator_0_1/src/lowrisc_dv_dpi_tcp_server_0.1/tcp_server.h | parzival3/Surelog | cf126533ebfb2af7df321057af9e3535feb30487 | [
"Apache-2.0"
] | 414 | 2021-06-11T07:22:01.000Z | 2022-03-31T22:06:14.000Z | third_party/tests/Earlgrey_Verilator_0_1/src/lowrisc_dv_dpi_tcp_server_0.1/tcp_server.h | parzival3/Surelog | cf126533ebfb2af7df321057af9e3535feb30487 | [
"Apache-2.0"
] | 30 | 2019-11-18T16:31:40.000Z | 2021-12-26T01:22:51.000Z | // Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
/**
* Functions to create and interact with a threaded TCP server
*
* This is intended to be used by simulation add-on DPI modules to provide
* basic TCP socket communication between a host and simulated peripherals.
*/
#ifndef TCP_SERVER_H_
#define TCP_SERVER_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
struct tcp_server_ctx;
/**
* Non-blocking read of a byte from a connected client
*
* @param ctx tcp server context object
* @param dat byte received
* @return true if a byte was read
*/
bool tcp_server_read(struct tcp_server_ctx *ctx, char *dat);
/**
* Write a byte to a connected client
*
* The write is internally buffered and so does not block if the client is not
* ready to accept data, but does block if the buffer is full.
*
* @param ctx tcp server context object
* @param dat byte to send
*/
void tcp_server_write(struct tcp_server_ctx *ctx, char dat);
/**
* Create a new TCP server instance
*
* @param display_name C string description of server
* @param listen_port On which port the server should listen
* @return A pointer to the created context struct
*/
tcp_server_ctx *tcp_server_create(const char *display_name, int listen_port);
/**
* Shut down the server and free all reserved memory
*
* @param ctx tcp server context object
*/
void tcp_server_close(struct tcp_server_ctx *ctx);
/**
* Instruct the server to disconnect a client
*
* @param ctx tcp server context object
*/
void tcp_server_client_close(struct tcp_server_ctx *ctx);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // TCP_SERVER_H_
| 24.757143 | 78 | 0.739758 |
652e1bbe508f636829ecf33705433de32233884e | 848 | h | C | client/UserClient.h | vinx13/ExchangeSimulator | de3fec00970075630514c978a7402fc8e1e905ab | [
"BSD-3-Clause"
] | 2 | 2016-04-25T05:42:58.000Z | 2016-05-06T12:51:16.000Z | client/UserClient.h | vinx13/ExchangeSimulator | de3fec00970075630514c978a7402fc8e1e905ab | [
"BSD-3-Clause"
] | null | null | null | client/UserClient.h | vinx13/ExchangeSimulator | de3fec00970075630514c978a7402fc8e1e905ab | [
"BSD-3-Clause"
] | null | null | null | #ifndef EXCHANGESIMULATOR_CLIENT_USERCLIENT_H
#define EXCHANGESIMULATOR_CLIENT_USERCLIENT_H
#include "Client.h"
#include <string>
class UserClient : public Client {
public:
UserClient(const std::string &config);
virtual void start() override;
bool isvalid(const std::string &cmd);
void printUsage() const;
private:
std::string client_;
void readClientName();
void onQueryQuote(const std::string &cmd);
void onBuy(const std::string &cmdbody);
void onSell(const std::string &cmdbody);
Fix42::MessagePtr generateOrder(const std::string &cmdbody);
void onQueryOrder(const std::string &cmdbody);
void doMainLoop();
void onQueryList();
void handleCmd(const std::string &cmd);
bool isOrderAccepted(Fix42::MessagePtr message);
};
#endif //EXCHANGESIMULATOR_CLIENT_USERCLIENT_H
| 19.272727 | 64 | 0.71934 |
65350afe9e39f006f74641d6c0321cc074046eea | 30,752 | c | C | test_unishox2.c | leafgarden/Unishox | 21b5ff61e92da337899861ea01eddec48040892c | [
"Apache-2.0"
] | null | null | null | test_unishox2.c | leafgarden/Unishox | 21b5ff61e92da337899861ea01eddec48040892c | [
"Apache-2.0"
] | null | null | null | test_unishox2.c | leafgarden/Unishox | 21b5ff61e92da337899861ea01eddec48040892c | [
"Apache-2.0"
] | null | null | null | #ifdef _MSC_VER
#include <windows.h>
#else
#include <sys/time.h>
#endif
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdint.h>
#include "unishox2.h"
typedef unsigned char byte;
int unishox2_compress_preset_lines(const char *in, int len, char *out, int preset, struct us_lnk_lst *prev_lines) {
switch (preset) {
case 0:
return unishox2_compress_lines(in, len, out, USX_PSET_DFLT, prev_lines);
case 1:
return unishox2_compress_lines(in, len, out, USX_PSET_ALPHA_ONLY, prev_lines);
case 2:
return unishox2_compress_lines(in, len, out, USX_PSET_ALPHA_NUM_ONLY, prev_lines);
case 3:
return unishox2_compress_lines(in, len, out, USX_PSET_ALPHA_NUM_SYM_ONLY, prev_lines);
case 4:
return unishox2_compress_lines(in, len, out, USX_PSET_ALPHA_NUM_SYM_ONLY_TXT, prev_lines);
case 5:
return unishox2_compress_lines(in, len, out, USX_PSET_FAVOR_ALPHA, prev_lines);
case 6:
return unishox2_compress_lines(in, len, out, USX_PSET_FAVOR_DICT, prev_lines);
case 7:
return unishox2_compress_lines(in, len, out, USX_PSET_FAVOR_SYM, prev_lines);
case 8:
return unishox2_compress_lines(in, len, out, USX_PSET_FAVOR_UMLAUT, prev_lines);
case 9:
return unishox2_compress_lines(in, len, out, USX_PSET_NO_DICT, prev_lines);
case 10:
return unishox2_compress_lines(in, len, out, USX_PSET_NO_UNI, prev_lines);
case 11:
return unishox2_compress_lines(in, len, out, USX_PSET_NO_UNI_FAVOR_TEXT, prev_lines);
case 12:
return unishox2_compress_lines(in, len, out, USX_PSET_URL, prev_lines);
case 13:
return unishox2_compress_lines(in, len, out, USX_PSET_JSON, prev_lines);
case 14:
return unishox2_compress_lines(in, len, out, USX_PSET_JSON_NO_UNI, prev_lines);
case 15:
return unishox2_compress_lines(in, len, out, USX_PSET_XML, prev_lines);
case 16:
return unishox2_compress_lines(in, len, out, USX_PSET_HTML, prev_lines);
}
return 0;
}
int unishox2_decompress_preset_lines(const char *in, int len, char *out, int preset, struct us_lnk_lst *prev_lines) {
switch (preset) {
case 0:
return unishox2_decompress_lines(in, len, out, USX_PSET_DFLT, prev_lines);
case 1:
return unishox2_decompress_lines(in, len, out, USX_PSET_ALPHA_ONLY, prev_lines);
case 2:
return unishox2_decompress_lines(in, len, out, USX_PSET_ALPHA_NUM_ONLY, prev_lines);
case 3:
return unishox2_decompress_lines(in, len, out, USX_PSET_ALPHA_NUM_SYM_ONLY, prev_lines);
case 4:
return unishox2_decompress_lines(in, len, out, USX_PSET_ALPHA_NUM_SYM_ONLY_TXT, prev_lines);
case 5:
return unishox2_decompress_lines(in, len, out, USX_PSET_FAVOR_ALPHA, prev_lines);
case 6:
return unishox2_decompress_lines(in, len, out, USX_PSET_FAVOR_DICT, prev_lines);
case 7:
return unishox2_decompress_lines(in, len, out, USX_PSET_FAVOR_SYM, prev_lines);
case 8:
return unishox2_decompress_lines(in, len, out, USX_PSET_FAVOR_UMLAUT, prev_lines);
case 9:
return unishox2_decompress_lines(in, len, out, USX_PSET_NO_DICT, prev_lines);
case 10:
return unishox2_decompress_lines(in, len, out, USX_PSET_NO_UNI, prev_lines);
case 11:
return unishox2_decompress_lines(in, len, out, USX_PSET_NO_UNI_FAVOR_TEXT, prev_lines);
case 12:
return unishox2_decompress_lines(in, len, out, USX_PSET_URL, prev_lines);
case 13:
return unishox2_decompress_lines(in, len, out, USX_PSET_JSON, prev_lines);
case 14:
return unishox2_decompress_lines(in, len, out, USX_PSET_JSON_NO_UNI, prev_lines);
case 15:
return unishox2_decompress_lines(in, len, out, USX_PSET_XML, prev_lines);
case 16:
return unishox2_decompress_lines(in, len, out, USX_PSET_HTML, prev_lines);
}
return 0;
}
int test_ushx_cd(char *input, int preset) {
char cbuf[200];
char dbuf[250];
int len = strlen(input);
int clen = unishox2_compress_preset_lines(input, len, cbuf, preset, NULL);
printf("\n\n");
int dlen = unishox2_decompress_preset_lines(cbuf, clen, dbuf, preset, NULL);
dbuf[dlen] = '\0';
float perc;
if (dlen != len) {
printf("Fail len: %d, %d:\n%s\n%s\n", len, dlen, input, dbuf);
return 0;
}
if (strncmp(input, dbuf, len)) {
printf("Fail cmp:\n%s\n%s\n", input, dbuf);
return 0;
}
perc = (len - clen);
perc /= len;
perc *= 100;
printf("%s: %d/%d=", input, clen, len);
printf("%.2f%%\n", perc);
return 1;
}
int is_empty(const char *s) {
while (*s != '\0') {
if (!isspace((unsigned char)*s))
return 0;
s++;
}
return 1;
}
// From https://stackoverflow.com/questions/19758270/read-varint-from-linux-sockets#19760246
// Encode an unsigned 64-bit varint. Returns number of encoded bytes.
// 'buffer' must have room for up to 10 bytes.
int encode_unsigned_varint(uint8_t *buffer, uint64_t value) {
int encoded = 0;
do {
uint8_t next_byte = value & 0x7F;
value >>= 7;
if (value)
next_byte |= 0x80;
buffer[encoded++] = next_byte;
} while (value);
return encoded;
}
uint64_t decode_unsigned_varint(const uint8_t *data, int *decoded_bytes) {
int i = 0;
uint64_t decoded_value = 0;
int shift_amount = 0;
do {
decoded_value |= (uint64_t)(data[i] & 0x7F) << shift_amount;
shift_amount += 7;
} while ((data[i++] & 0x80) != 0);
*decoded_bytes = i;
return decoded_value;
}
void print_string_as_hex(char *in, int len) {
int l;
byte bit;
printf("String in hex:\n");
for (l=0; l<len; l++) {
printf("%x, ", (unsigned char) in[l]);
}
printf("\n");
}
void print_compressed(char *in, int len) {
int l;
byte bit;
printf("Compressed bytes in decimal:\n");
for (l=0; l<len; l++) {
printf("%u, ", (unsigned char) in[l]);
}
printf("\n\nCompressed bytes in binary:\n");
for (l=0; l<len*8; l++) {
bit = (in[l/8]>>(7-l%8))&0x01;
printf("%d", bit);
if (l%8 == 7) printf(" ");
}
printf("\n");
}
uint32_t getTimeVal() {
#ifdef _MSC_VER
return GetTickCount() * 1000;
#else
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec * 1000000) + tv.tv_usec;
#endif
}
double timedifference(uint32_t t0, uint32_t t1) {
double ret = t1;
ret -= t0;
ret /= 1000;
return ret;
}
int main(int argv, char *args[]) {
char cbuf[4096];
char dbuf[8192];
long len, tot_len, clen, ctot, dlen, l;
float perc;
FILE *fp, *wfp;
int bytes_read;
char c_in;
uint32_t tStart;
tStart = getTimeVal();
if (argv >= 4 && strcmp(args[1], "-c") == 0) {
int preset = 0;
if (argv > 4)
preset = atoi(args[4]);
tot_len = 0;
ctot = 0;
fp = fopen(args[2], "rb");
if (fp == NULL) {
perror(args[2]);
return 1;
}
wfp = fopen(args[3], "wb+");
if (wfp == NULL) {
perror(args[3]);
return 1;
}
do {
bytes_read = fread(cbuf, 1, sizeof(cbuf), fp);
if (bytes_read > 0) {
clen = unishox2_compress_preset_lines(cbuf, bytes_read, dbuf, preset, NULL);
ctot += clen;
tot_len += bytes_read;
if (clen > 0) {
fputc(clen >> 8, wfp);
fputc(clen & 0xFF, wfp);
if (clen != fwrite(dbuf, 1, clen, wfp)) {
perror("fwrite");
return 1;
}
}
}
} while (bytes_read > 0);
perc = (tot_len-ctot);
perc /= tot_len;
perc *= 100;
printf("\nBytes (Compressed/Original=Savings%%): %ld/%ld=", ctot, tot_len);
printf("%.2f%%\n", perc);
} else
if (argv >= 4 && strcmp(args[1], "-d") == 0) {
int preset = 0;
if (argv > 4)
preset = atoi(args[4]);
fp = fopen(args[2], "rb");
if (fp == NULL) {
perror(args[2]);
return 1;
}
wfp = fopen(args[3], "wb+");
if (wfp == NULL) {
perror(args[3]);
return 1;
}
do {
//memset(dbuf, 0, sizeof(dbuf));
int len_to_read = fgetc(fp) << 8;
len_to_read += fgetc(fp);
bytes_read = fread(dbuf, 1, len_to_read, fp);
if (bytes_read > 0) {
dlen = unishox2_decompress_preset_lines(dbuf, bytes_read, cbuf, preset, NULL);
if (dlen > 0) {
if (dlen != fwrite(cbuf, 1, dlen, wfp)) {
perror("fwrite");
return 1;
}
}
}
} while (bytes_read > 0);
} else
if (argv >= 4 && (strcmp(args[1], "-g") == 0 ||
strcmp(args[1], "-G") == 0)) {
int preset = 0;
if (argv > 4)
preset = atoi(args[4]);
if (strcmp(args[1], "-g") == 0)
preset = 9; // = USX_PSET_NO_DICT;
fp = fopen(args[2], "r");
if (fp == NULL) {
perror(args[2]);
return 1;
}
sprintf(cbuf, "%s.h", args[3]);
wfp = fopen(cbuf, "w+");
if (wfp == NULL) {
perror(args[3]);
return 1;
}
tot_len = 0;
ctot = 0;
struct us_lnk_lst *cur_line = NULL;
fputs("#ifndef __", wfp);
fputs(args[3], wfp);
fputs("_UNISHOX2_COMPRESSED__\n", wfp);
fputs("#define __", wfp);
fputs(args[3], wfp);
fputs("_UNISHOX2_COMPRESSED__\n", wfp);
int line_ctr = 0;
int max_len = 0;
while (fgets(cbuf, sizeof(cbuf), fp) != NULL) {
// compress the line and look in previous lines
// add to linked list
len = strlen(cbuf);
if (cbuf[len - 1] == '\n' || cbuf[len - 1] == '\r') {
len--;
cbuf[len] = 0;
}
if (is_empty(cbuf))
continue;
if (len > 0) {
struct us_lnk_lst *ll;
ll = cur_line;
cur_line = (struct us_lnk_lst *) malloc(sizeof(struct us_lnk_lst));
cur_line->data = (char *) malloc(len + 1);
strncpy(cur_line->data, cbuf, len);
cur_line->previous = ll;
clen = unishox2_compress_preset_lines(cbuf, len, dbuf, preset, cur_line);
if (clen > 0) {
perc = (len-clen);
perc /= len;
perc *= 100;
//print_compressed(dbuf, clen);
printf("len: %ld/%ld=", clen, len);
printf("%.2f %s\n", perc, cbuf);
tot_len += len;
ctot += clen;
char short_buf[strlen(args[3]) + 100];
snprintf(short_buf, sizeof(short_buf), "const byte %s_%d[] PROGMEM = {", args[3], line_ctr++);
fputs(short_buf, wfp);
int len_len = encode_unsigned_varint((byte *) short_buf, clen);
for (int i = 0; i < len_len; i++) {
snprintf(short_buf, 10, "%u, ", (byte) short_buf[i]);
fputs(short_buf, wfp);
}
for (int i = 0; i < clen; i++) {
if (i) {
strcpy(short_buf, ", ");
fputs(short_buf, wfp);
}
snprintf(short_buf, 6, "%u", (byte) dbuf[i]);
fputs(short_buf, wfp);
}
strcpy(short_buf, "};\n");
fputs(short_buf, wfp);
}
if (len > max_len)
max_len = len;
dlen = unishox2_decompress_preset_lines(dbuf, clen, cbuf, preset, cur_line);
cbuf[dlen] = 0;
printf("\n%s\n", cbuf);
}
}
perc = (tot_len-ctot);
perc /= tot_len;
perc *= 100;
printf("\nBytes (Compressed/Original=Savings%%): %ld/%ld=", ctot, tot_len);
printf("%.2f%%\n", perc);
char short_buf[strlen(args[3]) + 100];
snprintf(short_buf, sizeof(short_buf), "const byte * const %s[] PROGMEM = {", args[3]);
fputs(short_buf, wfp);
for (int i = 0; i < line_ctr; i++) {
if (i) {
strcpy(short_buf, ", ");
fputs(short_buf, wfp);
}
snprintf(short_buf, strlen(args[3]) + 15, "%s_%d", args[3], i);
fputs(short_buf, wfp);
}
strcpy(short_buf, "};\n");
fputs(short_buf, wfp);
snprintf(short_buf, sizeof(short_buf), "#define %s_line_count %d\n", args[3], line_ctr);
fputs(short_buf, wfp);
snprintf(short_buf, sizeof(short_buf), "#define %s_max_len %d\n", args[3], max_len);
fputs(short_buf, wfp);
fputs("#endif\n", wfp);
} else
if (argv >= 2 && strcmp(args[1], "-t") == 0) {
int preset = 0;
if (argv > 2)
preset = atoi(args[2]);
// Basic
if (!test_ushx_cd("Hello", preset)) return 1;
if (!test_ushx_cd("Hello World", preset)) return 1;
if (!test_ushx_cd("The quick brown fox jumped over the lazy dog", preset)) return 1;
if (!test_ushx_cd("HELLO WORLD", preset)) return 1;
if (!test_ushx_cd("HELLO WORLD HELLO WORLD", preset)) return 1;
// Numbers
if (!test_ushx_cd("Hello1", preset)) return 1;
if (!test_ushx_cd("Hello1 World2", preset)) return 1;
if (!test_ushx_cd("Hello123", preset)) return 1;
if (!test_ushx_cd("12345678", preset)) return 1;
if (!test_ushx_cd("12345678 12345678", preset)) return 1;
if (!test_ushx_cd("HELLO WORLD 1234 hello world12", preset)) return 1;
if (!test_ushx_cd("HELLO 234 WORLD", preset)) return 1;
if (!test_ushx_cd("9 HELLO, WORLD", preset)) return 1;
if (!test_ushx_cd("H1e2l3l4o5 w6O7R8L9D", preset)) return 1;
if (!test_ushx_cd("8+80=88", preset)) return 1;
// Symbols
if (!test_ushx_cd("~!@#$%^&*()_+=-`;'\\|\":,./?><", preset)) return 1;
if (!test_ushx_cd("if (!test_ushx_cd(\"H1e2l3l4o5 w6O7R8L9D\", preset)) return 1;", preset)) return 1;
if (!test_ushx_cd("Hello\tWorld\tHow\tare\tyou?", preset)) return 1;
if (!test_ushx_cd("Hello~World~How~are~you?", preset)) return 1;
if (!test_ushx_cd("Hello\rWorld\rHow\rare\ryou?", preset)) return 1;
// Repeat
if (!test_ushx_cd("-----------------///////////////", preset)) return 1;
if (!test_ushx_cd("-----------------Hello World1111111111112222222abcdef12345abcde1234_////////Hello World///////", preset)) return 1;
// Nibbles
if (!test_ushx_cd("fa01b51e-7ecc-4e3e-be7b-918a4c2c891c", preset)) return 1;
if (!test_ushx_cd("Fa01b51e-7ecc-4e3e-be7b-918a4c2c891c", preset)) return 1;
if (!test_ushx_cd("fa01b51e-7ecc-4e3e-be7b-9182c891c", preset)) return 1;
if (!test_ushx_cd("760FBCA3-272E-4F1A-BF88-8472DF6BD994", preset)) return 1;
if (!test_ushx_cd("760FBCA3-272E-4F1A-BF88-8472DF6Bd994", preset)) return 1;
if (!test_ushx_cd("760FBCA3-272E-4F1A-BF88-8472DF6Bg994", preset)) return 1;
if (!test_ushx_cd("FBCA3-272E-4F1A-BF88-8472DF6BD994", preset)) return 1;
if (!test_ushx_cd("Hello 1 5347a688-d8bf-445d-86d1-b470f95b007fHello World", preset)) return 1;
if (!test_ushx_cd("01234567890123", preset)) return 1;
// Templates
if (!test_ushx_cd("2020-12-31", preset)) return 1;
if (!test_ushx_cd("1934-02", preset)) return 1;
if (!test_ushx_cd("2020-12-31T12:23:59.234Z", preset)) return 1;
if (!test_ushx_cd("1899-05-12T23:59:59.23434", preset)) return 1;
if (!test_ushx_cd("1899-05-12T23:59:59", preset)) return 1;
if (!test_ushx_cd("2020-12-31T12:23:59.234Zfa01b51e-7ecc-4e3e-be7b-918a4c2c891c", preset)) return 1;
if (!test_ushx_cd("顔に(993) 345-3495あり", preset)) return 1;
if (!test_ushx_cd("HELLO(993) 345-3495WORLD", preset)) return 1;
if (!test_ushx_cd("顔に1899-05-12T23:59:59あり", preset)) return 1;
if (!test_ushx_cd("HELLO1899-05-12T23:59:59WORLD", preset)) return 1;
if (!test_ushx_cd("Cada buhonero alaba sus agujas. - A peddler praises his needles (wares).", preset)) return 1;
if (!test_ushx_cd("Cada gallo canta en su muladar. - Each rooster sings on its dung-heap.", preset)) return 1;
if (!test_ushx_cd("Cada martes tiene su domingo. - Each Tuesday has its Sunday.", preset)) return 1;
if (!test_ushx_cd("Cada uno habla de la feria como le va en ella. - Our way of talking about things reflects our relevant experience, good or bad.", preset)) return 1;
if (!test_ushx_cd("Dime con quien andas y te diré quién eres.. - Tell me who you walk with, and I will tell you who you are.", preset)) return 1;
if (!test_ushx_cd("Donde comen dos, comen tres. - You can add one person more in any situation you are managing.", preset)) return 1;
if (!test_ushx_cd("El amor es ciego. - Love is blind", preset)) return 1;
if (!test_ushx_cd("El amor todo lo iguala. - Love smoothes life out.", preset)) return 1;
if (!test_ushx_cd("El tiempo todo lo cura. - Time cures all.", preset)) return 1;
if (!test_ushx_cd("La avaricia rompe el saco. - Greed bursts the sack.", preset)) return 1;
if (!test_ushx_cd("La cara es el espejo del alma. - The face is the mirror of the soul.", preset)) return 1;
if (!test_ushx_cd("La diligencia es la madre de la buena ventura. - Diligence is the mother of good fortune.", preset)) return 1;
if (!test_ushx_cd("La fe mueve montañas. - Faith moves mountains.", preset)) return 1;
if (!test_ushx_cd("La mejor palabra siempre es la que queda por decir. - The best word is the one left unsaid.", preset)) return 1;
if (!test_ushx_cd("La peor gallina es la que más cacarea. - The worst hen is the one that clucks the most.", preset)) return 1;
if (!test_ushx_cd("La sangre sin fuego hierve. - Blood boils without fire.", preset)) return 1;
if (!test_ushx_cd("La vida no es un camino de rosas. - Life is not a path of roses.", preset)) return 1;
if (!test_ushx_cd("Las burlas se vuelven veras. - Bad jokes become reality.", preset)) return 1;
if (!test_ushx_cd("Las desgracias nunca vienen solas. - Misfortunes never come one at a time.", preset)) return 1;
if (!test_ushx_cd("Lo comido es lo seguro. - You can only be really certain of what is already in your belly.", preset)) return 1;
if (!test_ushx_cd("Los años no pasan en balde. - Years don't pass in vain.", preset)) return 1;
if (!test_ushx_cd("Los celos son malos consejeros. - Jealousy is a bad counsellor.", preset)) return 1;
if (!test_ushx_cd("Los tiempos cambian. - Times change.", preset)) return 1;
if (!test_ushx_cd("Mañana será otro día. - Tomorrow will be another day.", preset)) return 1;
if (!test_ushx_cd("Ningún jorobado ve su joroba. - No hunchback sees his own hump.", preset)) return 1;
if (!test_ushx_cd("No cantan dos gallos en un gallinero. - Two roosters do not crow in a henhouse.", preset)) return 1;
if (!test_ushx_cd("No hay harina sin salvado. - No flour without bran.", preset)) return 1;
if (!test_ushx_cd("No por mucho madrugar, amanece más temprano.. - No matter if you rise early because it does not sunrise earlier.", preset)) return 1;
if (!test_ushx_cd("No se puede hacer tortilla sin romper los huevos. - One can't make an omelette without breaking eggs.", preset)) return 1;
if (!test_ushx_cd("No todas las verdades son para dichas. - Not every truth should be said.", preset)) return 1;
if (!test_ushx_cd("No todo el monte es orégano. - The whole hillside is not covered in spice.", preset)) return 1;
if (!test_ushx_cd("Nunca llueve a gusto de todos. - It never rains to everyone's taste.", preset)) return 1;
if (!test_ushx_cd("Perro ladrador, poco mordedor.. - A dog that barks often seldom bites.", preset)) return 1;
if (!test_ushx_cd("Todos los caminos llevan a Roma. - All roads lead to Rome.", preset)) return 1;
// Unicode
if (!test_ushx_cd("案ずるより産むが易し。 - Giving birth to a baby is easier than worrying about it.", preset)) return 1;
if (!test_ushx_cd("出る杭は打たれる。 - The stake that sticks up gets hammered down.", preset)) return 1;
if (!test_ushx_cd("知らぬが仏。 - Not knowing is Buddha. - Ignorance is bliss.", preset)) return 1;
if (!test_ushx_cd("見ぬが花。 - Not seeing is a flower. - Reality can't compete with imagination.", preset)) return 1;
if (!test_ushx_cd("花は桜木人は武士 - Of flowers, the cherry blossom; of men, the warrior.", preset)) return 1;
if (!test_ushx_cd("小洞不补,大洞吃苦 - A small hole not mended in time will become a big hole much more difficult to mend.", preset)) return 1;
if (!test_ushx_cd("读万卷书不如行万里路 - Reading thousands of books is not as good as traveling thousands of miles", preset)) return 1;
if (!test_ushx_cd("福无重至,祸不单行 - Fortune does not come twice. Misfortune does not come alone.", preset)) return 1;
if (!test_ushx_cd("风向转变时,有人筑墙,有人造风车 - When the wind changes, some people build walls and have artificial windmills.", preset)) return 1;
if (!test_ushx_cd("父债子还 - Father's debt, son to give back.", preset)) return 1;
if (!test_ushx_cd("害人之心不可有 - Do not harbour intentions to hurt others.", preset)) return 1;
if (!test_ushx_cd("今日事,今日毕 - Things of today, accomplished today.", preset)) return 1;
if (!test_ushx_cd("空穴来风,未必无因 - Where there's smoke, there's fire.", preset)) return 1;
if (!test_ushx_cd("良药苦口 - Good medicine tastes bitter.", preset)) return 1;
if (!test_ushx_cd("人算不如天算 - Man proposes and God disposes", preset)) return 1;
if (!test_ushx_cd("师傅领进门,修行在个人 - Teachers open the door. You enter by yourself.", preset)) return 1;
if (!test_ushx_cd("授人以鱼不如授之以渔 - Teach a man to take a fish is not equal to teach a man how to fish.", preset)) return 1;
if (!test_ushx_cd("树倒猢狲散 - When the tree falls, the monkeys scatter.", preset)) return 1;
if (!test_ushx_cd("水能载舟,亦能覆舟 - Not only can water float a boat, it can sink it also.", preset)) return 1;
if (!test_ushx_cd("朝被蛇咬,十年怕井绳 - Once bitten by a snake for a snap dreads a rope for a decade.", preset)) return 1;
if (!test_ushx_cd("一分耕耘,一分收获 - If one does not plow, there will be no harvest.", preset)) return 1;
if (!test_ushx_cd("有钱能使鬼推磨 - If you have money you can make the devil push your grind stone.", preset)) return 1;
if (!test_ushx_cd("一失足成千古恨,再回头已百年身 - A single slip may cause lasting sorrow.", preset)) return 1;
if (!test_ushx_cd("自助者天助 - Those who help themselves, God will help.", preset)) return 1;
if (!test_ushx_cd("早起的鸟儿有虫吃 - Early bird gets the worm.", preset)) return 1;
if (!test_ushx_cd("This is first line,\r\nThis is second line", preset)) return 1;
if (!test_ushx_cd("{\"menu\": {\n \"id\": \"file\",\n \"value\": \"File\",\n \"popup\": {\n \"menuitem\": [\n {\"value\": \"New\", \"onclick\": \"CreateNewDoc()\"},\n {\"value\": \"Open\", \"onclick\": \"OpenDoc()\"},\n {\"value\": \"Close\", \"onclick\": \"CloseDoc()\"}\n ]\n }\n}}", preset)) return 1;
if (!test_ushx_cd("{\"menu\": {\r\n \"id\": \"file\",\r\n \"value\": \"File\",\r\n \"popup\": {\r\n \"menuitem\": [\r\n {\"value\": \"New\", \"onclick\": \"CreateNewDoc()\"},\r\n {\"value\": \"Open\", \"onclick\": \"OpenDoc()\"},\r\n {\"value\":\"Close\", \"onclick\": \"CloseDoc()\"}\r\n ]\r\n }\r\n}}", preset)) return 1;
if (!test_ushx_cd("https://siara.cc", preset)) return 1;
if (!test_ushx_cd("符号\"δ\"表", preset)) return 1;
if (!test_ushx_cd("学者地”[3]。学者", preset)) return 1;
if (!test_ushx_cd("한데......아무", preset)) return 1;
// English
if (!test_ushx_cd("Beauty is not in the face. Beauty is a light in the heart.", preset)) return 1;
// Spanish
if (!test_ushx_cd("La belleza no está en la cara. La belleza es una luz en el corazón.", preset)) return 1;
// French
if (!test_ushx_cd("La beauté est pas dans le visage. La beauté est la lumière dans le coeur.", preset)) return 1;
// Portugese
if (!test_ushx_cd("A beleza não está na cara. A beleza é a luz no coração.", preset)) return 1;
// Dutch
if (!test_ushx_cd("Schoonheid is niet in het gezicht. Schoonheid is een licht in het hart.", preset)) return 1;
// German
if (!test_ushx_cd("Schönheit ist nicht im Gesicht. Schönheit ist ein Licht im Herzen.", preset)) return 1;
// Spanish
if (!test_ushx_cd("La belleza no está en la cara. La belleza es una luz en el corazón.", preset)) return 1;
// French
if (!test_ushx_cd("La beauté est pas dans le visage. La beauté est la lumière dans le coeur.", preset)) return 1;
// Italian
if (!test_ushx_cd("La bellezza non è in faccia. La bellezza è la luce nel cuore.", preset)) return 1;
// Swedish
if (!test_ushx_cd("Skönhet är inte i ansiktet. Skönhet är ett ljus i hjärtat.", preset)) return 1;
// Romanian
if (!test_ushx_cd("Frumusețea nu este în față. Frumusețea este o lumină în inimă.", preset)) return 1;
// Ukranian
if (!test_ushx_cd("Краса не в особі. Краса - це світло в серці.", preset)) return 1;
// Greek
if (!test_ushx_cd("Η ομορφιά δεν είναι στο πρόσωπο. Η ομορφιά είναι ένα φως στην καρδιά.", preset)) return 1;
// Turkish
if (!test_ushx_cd("Güzellik yüzünde değil. Güzellik, kalbin içindeki bir ışıktır.", preset)) return 1;
// Polish
if (!test_ushx_cd("Piękno nie jest na twarzy. Piękno jest światłem w sercu.", preset)) return 1;
// Africans
if (!test_ushx_cd("Skoonheid is nie in die gesig nie. Skoonheid is 'n lig in die hart.", preset)) return 1;
// Swahili
if (!test_ushx_cd("Beauty si katika uso. Uzuri ni nuru moyoni.", preset)) return 1;
// Zulu
if (!test_ushx_cd("Ubuhle abukho ebusweni. Ubuhle bungukukhanya enhliziyweni.", preset)) return 1;
// Somali
if (!test_ushx_cd("Beauty ma aha in wajiga. Beauty waa iftiin ah ee wadnaha.", preset)) return 1;
// Russian
if (!test_ushx_cd("Красота не в лицо. Красота - это свет в сердце.", preset)) return 1;
// Arabic
if (!test_ushx_cd("الجمال ليس في الوجه. الجمال هو النور الذي في القلب.", preset)) return 1;
// Persian
if (!test_ushx_cd("زیبایی در چهره نیست. زیبایی نور در قلب است.", preset)) return 1;
// Pashto
if (!test_ushx_cd("ښکلا په مخ کې نه ده. ښکلا په زړه کی یوه رڼا ده.", preset)) return 1;
// Azerbaijani
if (!test_ushx_cd("Gözəllik üzdə deyil. Gözəllik qəlbdə bir işıqdır.", preset)) return 1;
// Uzbek
if (!test_ushx_cd("Go'zallik yuzida emas. Go'zallik - qalbdagi nur.", preset)) return 1;
// Kurdish
if (!test_ushx_cd("Bedewî ne di rû de ye. Bedewî di dil de ronahiyek e.", preset)) return 1;
// Urdu
if (!test_ushx_cd("خوبصورتی چہرے میں نہیں ہے۔ خوبصورتی دل میں روشنی ہے۔", preset)) return 1;
// Hindi
if (!test_ushx_cd("सुंदरता चेहरे में नहीं है। सौंदर्य हृदय में प्रकाश है।", preset)) return 1;
// Bangla
if (!test_ushx_cd("সৌন্দর্য মুখে নেই। সৌন্দর্য হৃদয় একটি আলো।", preset)) return 1;
// Punjabi
if (!test_ushx_cd("ਸੁੰਦਰਤਾ ਚਿਹਰੇ ਵਿੱਚ ਨਹੀਂ ਹੈ. ਸੁੰਦਰਤਾ ਦੇ ਦਿਲ ਵਿਚ ਚਾਨਣ ਹੈ.", preset)) return 1;
// Telugu
if (!test_ushx_cd("అందం ముఖంలో లేదు. అందం హృదయంలో ఒక కాంతి.", preset)) return 1;
// Tamil
if (!test_ushx_cd("அழகு முகத்தில் இல்லை. அழகு என்பது இதயத்தின் ஒளி.", preset)) return 1;
// Marathi
if (!test_ushx_cd("सौंदर्य चेहरा नाही. सौंदर्य हे हृदयातील एक प्रकाश आहे.", preset)) return 1;
// Kannada
if (!test_ushx_cd("ಸೌಂದರ್ಯವು ಮುಖದ ಮೇಲೆ ಇಲ್ಲ. ಸೌಂದರ್ಯವು ಹೃದಯದಲ್ಲಿ ಒಂದು ಬೆಳಕು.", preset)) return 1;
// Gujarati
if (!test_ushx_cd("સુંદરતા ચહેરા પર નથી. સુંદરતા હૃદયમાં પ્રકાશ છે.", preset)) return 1;
// Malayalam
if (!test_ushx_cd("സൗന്ദര്യം മുഖത്ത് ഇല്ല. സൗന്ദര്യം ഹൃദയത്തിലെ ഒരു പ്രകാശമാണ്.", preset)) return 1;
// Nepali
if (!test_ushx_cd("सौन्दर्य अनुहारमा छैन। सौन्दर्य मुटुको उज्यालो हो।", preset)) return 1;
// Sinhala
if (!test_ushx_cd("රූපලාවන්ය මුහුණේ නොවේ. රූපලාවන්ය හදවත තුළ ඇති ආලෝකය වේ.", preset)) return 1;
// Chinese
if (!test_ushx_cd("美是不是在脸上。 美是心中的亮光。", preset)) return 1;
// Javanese
if (!test_ushx_cd("Beauty ora ing pasuryan. Kaendahan iku cahya ing sajroning ati.", preset)) return 1;
// Japanese
if (!test_ushx_cd("美は顔にありません。美は心の中の光です。", preset)) return 1;
// Filipino
if (!test_ushx_cd("Ang kagandahan ay wala sa mukha. Ang kagandahan ay ang ilaw sa puso.", preset)) return 1;
// Korean
if (!test_ushx_cd("아름다움은 얼굴에 없습니다。아름다움은 마음의 빛입니다。", preset)) return 1;
// Vietnam
if (!test_ushx_cd("Vẻ đẹp không nằm trong khuôn mặt. Vẻ đẹp là ánh sáng trong tim.", preset)) return 1;
// Thai
if (!test_ushx_cd("ความงามไม่ได้อยู่ที่ใบหน้า ความงามเป็นแสงสว่างในใจ", preset)) return 1;
// Burmese
if (!test_ushx_cd("အလှအပမျက်နှာပေါ်မှာမဟုတ်ပါဘူး။ အလှအပစိတ်နှလုံးထဲမှာအလင်းကိုဖြစ်ပါတယ်။", preset)) return 1;
// Malay
if (!test_ushx_cd("Kecantikan bukan di muka. Kecantikan adalah cahaya di dalam hati.", preset)) return 1;
// Emoji
if (!test_ushx_cd("🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣🤣", preset)) return 1;
if (!test_ushx_cd("😀😃😄😁😆😅🤣😂🙂🙃😉😊😇🥰😍🤩😘😗😚😙😋😛😜🤪😝🤑🤗🤭🤫🤔🤐🤨😐😑😶😏😒🙄😬🤥😌😔😪🤤😴😷🤒🤕🤢", preset)) return 1;
// Binary
if (!test_ushx_cd("Hello\x80\x83\xAE\xBC\xBD\xBE", preset)) return 1;
} else
if (argv == 2 || (argv == 3 && atoi(args[2]) > 0)) {
int preset = 0;
if (argv >= 3)
preset = atoi(args[2]);
len = strlen(args[1]);
printf("String: %s, Len:%ld\n", args[1], len);
//print_string_as_hex(args[1], len);
memset(cbuf, 0, sizeof(cbuf));
ctot = unishox2_compress_preset_lines(args[1], len, cbuf, preset, NULL);
print_compressed(cbuf, ctot);
memset(dbuf, 0, sizeof(dbuf));
dlen = unishox2_decompress_preset_lines(cbuf, ctot, dbuf, preset, NULL);
dbuf[dlen] = 0;
printf("\nDecompressed: %s\n", dbuf);
//print_compressed(dbuf, dlen);
perc = (len-ctot);
perc /= len;
perc *= 100;
printf("\nBytes (Compressed/Original=Savings%%): %ld/%ld=", ctot, len);
printf("%.2f%%\n", perc);
} else {
printf("Unishox (byte format version: %s)\n", UNISHOX_VERSION);
printf("----------------------------------\n");
printf("Usage: unishox2 \"string\" [preset_number]\n");
printf(" (or)\n");
printf(" unishox2 [action] [in_file] [out_file] [preset_number]\n");
printf("\n");
printf(" [action]:\n");
printf(" -t run tests\n");
printf(" -c compress\n");
printf(" -d decompress\n");
printf(" -g generate C header file\n");
printf(" -G generate C header file using additional compression (slower)\n");
printf("\n");
printf(" [preset_number]:\n");
printf(" 0 Optimum - favors all including JSON, XML, URL and HTML (default)\n");
printf(" 1 Alphabets [a-z], [A-Z] and space only\n");
printf(" 2 Alphanumeric [a-z], [A-Z], [0-9], [.,/()-=+$%%#] and space only\n");
printf(" 3 Alphanumeric and symbols only\n");
printf(" 4 Alphanumeric and symbols only (Favor English text)\n");
printf(" 5 Favor Alphabets\n");
printf(" 6 Favor Dictionary coding\n");
printf(" 7 Favor Symbols\n");
printf(" 8 Favor Umlaut\n");
printf(" 9 No dictionary\n");
printf(" 10 No Unicode\n");
printf(" 11 No Unicode, favour English text\n");
printf(" 12 Favor URLs\n");
printf(" 13 Favor JSON\n");
printf(" 14 Favor JSON (No Unicode)\n");
printf(" 15 Favor XML\n");
printf(" 16 Favor HTML\n");
return 1;
}
printf("\nElapsed: %0.3lf ms\n", timedifference(tStart, getTimeVal()));
return 0;
}
| 44.439306 | 352 | 0.623472 |
ca6c298191adc4f058080061b5c64cb648eeb39e | 372 | h | C | Classes/UniversalQueue/UMQueueNull.h | andreasfink/ulib | 04242ae1731fe17c2989d497076576487ee346aa | [
"MIT"
] | 3 | 2016-12-25T12:21:25.000Z | 2020-06-18T11:45:44.000Z | Classes/UniversalQueue/UMQueueNull.h | andreasfink/ulib | 04242ae1731fe17c2989d497076576487ee346aa | [
"MIT"
] | 2 | 2017-03-01T17:25:34.000Z | 2021-08-18T13:30:07.000Z | Classes/UniversalQueue/UMQueueNull.h | andreasfink/ulib | 04242ae1731fe17c2989d497076576487ee346aa | [
"MIT"
] | 2 | 2016-11-04T07:40:19.000Z | 2017-04-12T03:50:07.000Z | //
// UMQueueNull.h
// ulib
//
// Copyright © 2017 Andreas Fink (andreas@fink.org). All rights reserved.
//
//
#import "UMQueueSingle.h"
/*!
@class UMQueueNull
@brief A UMQueueNull is a variant of UMQueueSingle where everything is discarded.
Useful if you need to pass a queue but you dont really need the output.
*/
@interface UMQueueNull : UMQueueSingle
@end
| 18.6 | 82 | 0.717742 |
aa725fcbffbdaf8c510cc7eb1ed58625a5d9ba53 | 315 | h | C | MagicianApprentice/MagicianApprentice/Ignite.h | vandalo/MagicianApprentice | d8f0419399fd6579960ad1b85028ecfc88a83e25 | [
"MIT"
] | null | null | null | MagicianApprentice/MagicianApprentice/Ignite.h | vandalo/MagicianApprentice | d8f0419399fd6579960ad1b85028ecfc88a83e25 | [
"MIT"
] | null | null | null | MagicianApprentice/MagicianApprentice/Ignite.h | vandalo/MagicianApprentice | d8f0419399fd6579960ad1b85028ecfc88a83e25 | [
"MIT"
] | null | null | null | #ifndef __Ignite__
#define __Ignite__
#include <string>
#include <list>
#include "Entity.h"
#include "Spell.h"
class Ignite : public Spell
{
public:
Ignite(const char* name, const char* description, Entity* parent, Entity* must, int mana, int cd, const char* nameSpell);
void effect(Player* player);
};
#endif | 18.529412 | 122 | 0.726984 |
a29240a5012f751e20a41bc368a01ba04b4631b0 | 14,728 | h | C | libsafs/io_interface.h | kjhyun824/uncertain-graph-engine | 17aa1b8b5d03b03200583797ab0cfb4a42ff8845 | [
"Apache-2.0"
] | 140 | 2015-01-02T21:28:55.000Z | 2015-12-22T01:25:03.000Z | libsafs/io_interface.h | kjhyun824/uncertain-graph-engine | 17aa1b8b5d03b03200583797ab0cfb4a42ff8845 | [
"Apache-2.0"
] | 160 | 2016-11-07T18:37:33.000Z | 2020-03-10T22:57:07.000Z | libsafs/io_interface.h | kjhyun824/uncertain-graph-engine | 17aa1b8b5d03b03200583797ab0cfb4a42ff8845 | [
"Apache-2.0"
] | 25 | 2016-11-14T04:31:29.000Z | 2020-07-28T04:58:44.000Z | #ifndef __IO_INTERFACE_H__
#define __IO_INTERFACE_H__
/*
* Copyright 2014 Open Connectome Project (http://openconnecto.me)
* Written by Da Zheng (zhengda1936@gmail.com)
*
* This file is part of SAFSlib.
*
* 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 <stdlib.h>
#include <vector>
#include <memory>
#include "config_map.h"
#include "safs_exception.h"
#include "common.h"
#include "concurrency.h"
#include "thread.h"
#include "io_request.h"
#include "comm_exception.h"
#include "safs_header.h"
namespace safs
{
class io_request;
/**
* The callback interface to notify the completion of I/O requests.
*/
class callback
{
public:
typedef std::shared_ptr<callback> ptr;
virtual ~callback() {
}
/**
* The user-defined code is invoked on the completed I/O requests.
* \param reqs an array of completed I/O requests.
* \param num the number of I/O requests in the array.
*/
virtual int invoke(io_request *reqs[], int num) = 0;
};
/**
* The I/O status for an I/O request.
* Right now, it's not used.
*/
class io_status
{
long status: 8;
long priv_data: 56;
public:
io_status() {
status = 0;
priv_data = 0;
}
io_status(int status) {
this->status = status;
priv_data = 0;
}
void set_priv_data(long data) {
priv_data = data;
}
long get_priv_data() const {
return priv_data;
}
io_status &operator=(int status) {
this->status = status;
return *this;
}
bool operator==(int status) {
return this->status == status;
}
};
enum
{
IO_OK,
IO_PENDING = -1,
IO_FAIL = -2,
IO_UNSUPPORTED = -3,
};
/**
* This defines the method of accessing a SAFS file. There are six options.
*/
enum {
/*
* The three methods below are used internally or for testing only.
*/
READ_ACCESS,
DIRECT_ACCESS,
AIO_ACCESS,
/**
* This method is equivalent to Linux direct I/O. It accesses data
* in a SAFS file without caching. It only supports asynchronous I/O.
*/
REMOTE_ACCESS,
/**
* This method is equivalent to Linux buffered I/O. It accesses data
* in a SAFS file with caching. It supports both synchronous I/O and
* asynchronous I/O.
*/
GLOBAL_CACHE_ACCESS,
/**
* This method also accesses a SAFS file with caching. It localizes
* data access in the page cache. The implementation of this method
* is incomplete right now, so it shouldn't be used.
*/
PART_GLOBAL_ACCESS,
/**
* This method accesses a SAFS file with asynchronous user-task interface,
* but without page cache.
*/
DIRECT_COMP_ACCESS,
};
class file_io_factory;
class io_select;
/**
* This class defines the interface of accessing a SAFS file.
* An I/O instance is not thread-safe, so we need to create an instance
* for each thread. In the case of asynchronous I/O, the user-defined
* callback function is guaranteed to be invoked in the same threads
* as the I/O request was issued.
*/
class io_interface
{
safs_header header;
thread *curr; // the thread where the IO instance runs.
// This is an index for locating this IO object in a global table.
int io_idx;
int max_num_pending_ios;
static atomic_integer io_counter;
// Keep the I/O factory alive.
std::shared_ptr<file_io_factory> io_factory;
protected:
io_interface(thread *t, const safs_header &header) {
this->header = header;
this->curr = t;
this->io_idx = io_counter.inc(1) - 1;
max_num_pending_ios = params.get_max_num_pending_ios();
}
public:
typedef std::shared_ptr<io_interface> ptr;
virtual ~io_interface();
const safs_header &get_header() const {
return header;
}
int get_block_size() const {
if (header.is_valid())
return header.get_block_size();
else
return params.get_RAID_block_size();
}
/*
* This stores the I/O factory that creates the I/O instance.
* The main purpose is to keep the I/O factory alive.
*/
void set_owner(std::shared_ptr<file_io_factory> io_factory) {
this->io_factory = io_factory;
}
/**
* This method get the thread that the I/O instance is associated with.
* \return the thread.
*/
thread *get_thread() const {
assert(curr);
return curr;
}
/**
* This method gets the NUMA node that the I/O instance is used.
* \return the NUMA node id.
*/
int get_node_id() const {
assert(curr);
return curr->get_node_id();
}
/**
* This method gets the ID of the I/O instance.
* \return the ID of the I/O instance.
*/
int get_io_id() const {
return io_idx;
}
/**
* This method gets the number of requests still allowed to be sent to
* the IO instance.
* \return the number of requests.
*/
int get_remaining_io_slots() const {
return get_max_num_pending_ios() - num_pending_ios();
}
/**
* This method returns the ID of the file being accessed by the IO
* instance.
* \return the file ID.
*/
virtual int get_file_id() const = 0;
/**
* This method is called when the I/O instance is destroyed.
*/
virtual void cleanup() {
}
/*
* This method prints the current state of the IO instance.
* For the sake of performance, the method may not be thread-safe.
* It should be used with caution.
*/
virtual void print_state() {
}
virtual io_interface *clone(thread *t) const {
return NULL;
}
/**
* This method indicates whether it supports asynchronous IO interface.
* \return boolean.
*/
virtual bool support_aio() {
return false;
}
/**
* The asynchronous IO should implement some of the following methods.
*/
/**
* The main interface of sending asynchronous I/O requests.
* \param requests an array of I/O requests to be issued.
* \param num the number of I/O requests to be issued.
* \param status an array of I/O status, one for each I/O request.
*/
virtual void access(io_request *requests, int num, io_status *status = NULL) {
throw unsupported_exception();
}
/**
* This method flushes I/O requests.
* When requests are passed to the access method, an IO layer may buffer
* the requests. This method guarantees that all requests are flushed to
* the underlying devices.
*/
virtual void flush_requests() {
throw unsupported_exception();
}
/**
* This method waits for at least the specified number of requests
* issued by the access method to complete.
* \param the number of requests that need to be completed.
*/
virtual int wait4complete(int num) {
throw unsupported_exception();
}
/**
* This method gets the number of I/O requests pending in the I/O instance.
* \return the number of pending I/O requests.
*/
virtual int num_pending_ios() const {
throw unsupported_exception();
}
/**
* This method gets the maximal number of I/O requests allowed to
* be pending in the I/O instance.
* \return the maximal number of pending I/O requests.
*/
virtual int get_max_num_pending_ios() const {
return max_num_pending_ios;
}
/**
* This method sets the maximal number of I/O requests allowed to be
* pending in the I/O instance.
* \param the maximal number of I/O requests.
*/
virtual void set_max_num_pending_ios(int max) {
this->max_num_pending_ios = max;
}
/**
* \internal
* This method gives the underlying layer an interface to notify
* the current IO of the completed requests.
* The method may be called by multiple threads, so it has to be made
* thread-safe.
* The requests should be issued by this IO.
*/
virtual void notify_completion(io_request *reqs[], int num) {
if (have_callback())
get_callback().invoke(reqs, num);
}
/**
* This method sets the callback if the class supports the asynchronous
* I/O.
* \param cb the user-defined callback.
* \return false if the class doesn't support async I/O.
*/
virtual bool set_callback(callback::ptr cb) {
throw unsupported_exception();
}
virtual bool have_callback() const {
return false;
}
/**
* This method gets the user-defined callback.
* \return the user-defined callback.
*/
virtual callback &get_callback() {
throw unsupported_exception();
}
/**
* The synchronous IO interface.
* \param buf the data buffer.
* \param off the location in the file where data should be read
* from or written to.
* \param size the size of data.
* \param access_method whether to read or write.
* \return I/O status for the request.
*/
virtual io_status access(char *buf, off_t off, ssize_t size,
int access_method) {
return IO_UNSUPPORTED;
}
virtual std::shared_ptr<io_select> create_io_select() const {
return std::shared_ptr<io_select>();
}
};
/**
* This is equivalent to select() in Linux.
* Users can register multiple I/O instances to this object and wait
* for I/O completion from all of the I/O instances.
* Each type of I/O instance has its own io_select. Users have to add
* an I/O instance to the right I/O select.
*/
class io_select
{
public:
typedef std::shared_ptr<io_select> ptr;
/**
* Add an I/O instance to the I/O select.
* If the type of I/O instance doesn't match with the I/O select,
* the registration fails.
*/
virtual bool add_io(io_interface::ptr io) = 0;
/**
* The total number of pending I/O requests in all of the registered
* I/O instances.
*/
virtual int num_pending_ios() const = 0;
virtual int wait4complete(int num_to_complete) = 0;
};
/**
* This function creates an I/O instance from the I/O factory.
* \param factory the I/O factory for creating an I/O instance.
* \return an I/O instance.
*/
io_interface::ptr create_io(std::shared_ptr<file_io_factory> factory, thread *t);
class comp_io_scheduler;
/**
* This class creates an I/O scheduler used in the page cache.
*/
class comp_io_sched_creator
{
public:
typedef std::shared_ptr<comp_io_sched_creator> ptr;
/**
* This method creates a I/O scheduler on the specifies NUMA node.
* \param node_id the NUMA node ID.
* \return the I/O scheduler.
*/
virtual std::shared_ptr<comp_io_scheduler> create(int node_id) const = 0;
};
/**
* This class defines the interface of creating I/O instances of accessing
* a file.
*/
class file_io_factory
{
safs_header header;
comp_io_sched_creator::ptr creator;
// The name of the file.
const std::string name;
/*
* This method creates an I/O instance for the specified thread.
* \param t the thread where the I/O instance can be used.
* \return the I/O instance.
*/
virtual io_interface::ptr create_io(thread *t) = 0;
/*
* This method is to notify the I/O factory that an I/O instance is destroyed.
* \param io the I/O instance to be destroyed.
*/
virtual void destroy_io(io_interface &io) = 0;
public:
typedef std::shared_ptr<file_io_factory> shared_ptr;
file_io_factory(const std::string _name);
virtual ~file_io_factory() {
}
const safs_header &get_header() const {
return header;
}
/**
* This method sets an I/O scheduler creator in the I/O factory.
* An I/O scheduler only works in the page cache, so it has no effect
* if the I/O instance doesn't have a page cache.
* \param creater the I/O scheduler creator.
*/
void set_sched_creator(comp_io_sched_creator::ptr creator) {
this->creator = creator;
}
/**
* This method gets an I/O scheduler creator in the I/O factory.
* \return the I/O scheduler creator.
*/
comp_io_sched_creator::ptr get_sched_creator() const {
return creator;
}
/**
* This method gets the name of the SAFS file that the I/O instances
* in the I/O factory access.
* \return the file name.
*/
const std::string &get_name() const {
return name;
}
/**
* This method gets the Id of the file associated with the I/O factory.
* \return the file ID.
*/
virtual int get_file_id() const = 0;
virtual void print_state() {
}
virtual void collect_stat(io_interface &) {
}
virtual void print_statistics() const {
}
/**
* This method gets the size of the file accessed by the I/O factory.
* \return the file size.
*/
virtual ssize_t get_file_size() const;
friend io_interface::ptr create_io(file_io_factory::shared_ptr factory, thread *t);
friend class io_interface;
};
class cache_config;
class RAID_config;
io_select::ptr create_io_select(const std::vector<io_interface::ptr> &ios);
size_t wait4ios(safs::io_select::ptr select, size_t max_pending_ios);
/**
* This function creates an I/O factory of the specified I/O method.
* \param file_name the SAFS file accessed by the I/O factory.
* \param access_option the I/O method of accessing the SAFS file.
* The I/O method can be one of REMOTE_ACCESS, GLOBAL_CACHE_ACCESS and
* PART_GLOBAL_ACCESS.
*/
file_io_factory::shared_ptr create_io_factory(const std::string &file_name,
const int access_option);
/**
* This function initializes SAFS. It should be called at the beginning
* of a program. It can be invoked multiple times. If it is executed multiple
* time successfully, destroy_io_system() needs to be invoked the same number
* of times to complete clean up the I/O system.
* \param map the SAFS configuration.
* \param with_cache determine whether the I/O system is initialized with
* page cache.
*/
void init_io_system(config_map::ptr map, bool with_cache = true);
/**
* This function destroys SAFS. It should be called at the end of a program.
*/
void destroy_io_system();
/**
* This function tells whether SAFS is initialized successfully.
*/
bool is_safs_init();
/**
* This function gets the RAID configuration of SAFS.
*/
const RAID_config &get_sys_RAID_conf();
/**
* Get the CPU cores that are used for I/O dedicatedly.
*/
const std::vector<int> &get_io_cpus();
/**
* \internal
* This method print the I/O statistic information. It's used for debugging.
*/
void print_io_thread_stat();
/**
* This function prints the summary info on I/O statistics in the system.
*/
void print_io_summary();
/**
* The users can set the weight of a file. The file weight is used by
* the page cache. The file with a higher weight can have its data in
* the page cache longer.
* This function isn't thread-safe and should be used before I/O instances
* are created.
* \param file_name The file name.
* \param weight The new weight of the file.
*/
void set_file_weight(const std::string &file_name, int weight);
/**
* This gets the string that indicates the features compiled into SAFS.
*/
std::string get_supported_features();
}
#endif
| 25.047619 | 84 | 0.706953 |
4e531aa38e2faf1e5a8576d83ec16b286fee2820 | 6,683 | h | C | source/src/dns-common/message/DnsMessage.h | gkcity/tinymdns | 6f27dab36e9afc1fe5f6c4842404957a446d95e0 | [
"MIT"
] | null | null | null | source/src/dns-common/message/DnsMessage.h | gkcity/tinymdns | 6f27dab36e9afc1fe5f6c4842404957a446d95e0 | [
"MIT"
] | null | null | null | source/src/dns-common/message/DnsMessage.h | gkcity/tinymdns | 6f27dab36e9afc1fe5f6c4842404957a446d95e0 | [
"MIT"
] | 2 | 2019-12-02T03:11:45.000Z | 2020-06-02T11:22:59.000Z | /**
* Copyright (C) 2013-2015
*
* @author jxfengzi@gmail.com
* @date 2013-11-19
*
* @file DNSDnsMessage.h
*
* @remark
* set tabstop=4
* set shiftwidth=4
* set expandtab
*/
#ifndef __DNS_MESSAGE_H__
#define __DNS_MESSAGE_H__
#include <tiny_base.h>
#include <TinyList.h>
TINY_BEGIN_DECLS
/**
* https://tools.ietf.org/html/rfc1035
* 4. MESSAGES
*
* 4.1. Format
*
* All communications inside of the domain protocol are carried in a single
* format called a message. The top level format of message is divided
* into 5 sections (some of which are empty in certain cases) shown below:
*
* +---------------------+
* | Header |
* +---------------------+
* | Question | the question for the name server
* +---------------------+
* | Answer | RRs answering the question
* +---------------------+
* | Authority | RRs pointing toward an authority
* +---------------------+
* | Additional | RRs holding additional information
* +---------------------+
*
* The header section is always present. The header includes fields that
* specify which of the remaining sections are present, and also specify
* whether the message is a query or a response, a standard query or some
* other opcode, etc.
*
* The names of the sections after the header are derived from their use in
* standard queries. The question section contains fields that describe a
* question to a name server. These fields are a query type (QTYPE), a
* query class (QCLASS), and a query domain name (QNAME). The last three
* sections have the same format: a possibly empty list of concatenated
* resource records (RRs). The answer section contains RRs that answer the
* question; the authority section contains RRs that point toward an
* authoritative name server; the additional records section contains RRs
* which relate to the query, but are not strictly answers for the
* question.
*/
typedef struct _FlagBits
{
uint16_t RCODE:4; // Response code
uint16_t Z:3; // Reserved for future use. Must be zero in all queries and responses.
uint16_t RA:1; // Recursion Available
uint16_t RD:1; // Recursion Desired
uint16_t TC:1; // Truncated
uint16_t AA:1; // Authoritative Answer
uint16_t Opcode:4; // QUERY | IQUERY | STATUS
uint16_t QR:1; // query (0), or a response (1).
} FlagBits;
typedef union _DnsFlag
{
FlagBits bits;
uint16_t value;
} DnsFlag;
typedef struct _Header
{
uint16_t ID;
DnsFlag FLAG;
uint16_t QDCOUNT; // the number of entries in the question section.
uint16_t ANCOUNT; // the number of resource records in the answer section.
uint16_t NSCOUNT; // the number of name server resource records in the authority records section.
uint16_t ARCOUNT; // the number of resource records in the additional records section.
} Header;
/**
* https://tools.ietf.org/html/rfc1035
* QR: query (0), or a response (1).
*/
#define QR_QUERY 0
#define QR_RESPONSE 1
/**
* https://tools.ietf.org/html/rfc1035
* OPCODE A four bit field that specifies kind of query in this
* message. This value is set by the originator of a query
* and copied into the response. The values are:
*
* 0 a standard query (QUERY)
* 1 an inverse query (IQUERY)
* 2 a server status request (STATUS)
* 3-15 reserved for future use
*/
#define QPCODE_QUERY 0
#define QPCODE_IQUERY 1
#define QPCODE_STATUS 2
#define OPCODE_UNASSIGNED 3 // Unassigned
#define OPCODE_NOTIFY 4 // [RFC1996]
#define OPCODE_UPDATE 5 // [RFC2136]
/**
* https://tools.ietf.org/html/rfc1035
* RCODE Response code - this 4 bit field is set as part of
* responses. The values have the following
* interpretation:
*
* 0 No error condition
* 1 Format error - The name server was
* unable to interpret the query.
* 2 Server failure - The name server was
* unable to process this query due to a
* problem with the name server.
* 3 Name Error - Meaningful only for
* responses from an authoritative name
* server, this code signifies that the
* domain name referenced in the query does
* not exist.
* 4 Not Implemented - The name server does
* not support the requested kind of query.
* 5 Refused - The name server refuses to
* perform the specified operation for
* policy reasons. For example, a name
* server may not wish to provide the
* information to the particular requester,
* or a name server may not wish to perform
* a particular operation (e.g., zone
* transfer) for particular data.
* 6-15 Reserved for future use.
*/
#define RCODE_NO_ERROR 0
#define RCODE_FORMAT_ERROR 1
#define RCODE_SERVER_FAILURE 2
#define RCODE_NAME_ERROR 3
#define RCODE_NOT_IMPLEMENTED 4
#define RCODE_REFUSED 5
typedef struct _DnsMessage
{
Header header;
TinyList questions;
TinyList answers;
TinyList authorities;
TinyList additionals;
bool unicast;
} DnsMessage;
TINY_LOR
TinyRet DnsMessage_Construct(DnsMessage *thiz);
TINY_LOR
void DnsMessage_Dispose(DnsMessage *thiz);
TINY_LOR
DnsMessage * DnsMessage_New(void);
TINY_LOR
void DnsMessage_Delete(DnsMessage *thiz);
TINY_LOR
TinyRet DnsMessage_Parse(DnsMessage *thiz, const void *buf, uint32_t len);
TINY_LOR
uint32_t DnsMessage_ToBytes(DnsMessage *thiz, uint8_t *buf, uint32_t length, uint32_t offset);
TINY_END_DECLS
#endif /* __DNS_MESSAGE_H__ */ | 36.519126 | 115 | 0.561724 |
084aabd1083233b682b956c2cc43b5b30be2ca2a | 1,810 | h | C | source/gameengine/Ketsji/KX_PythonComponent.h | aseer95/upbge | f99d5f781f3c2cded0c7fc8ef387908fd35af505 | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | source/gameengine/Ketsji/KX_PythonComponent.h | aseer95/upbge | f99d5f781f3c2cded0c7fc8ef387908fd35af505 | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | source/gameengine/Ketsji/KX_PythonComponent.h | aseer95/upbge | f99d5f781f3c2cded0c7fc8ef387908fd35af505 | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | /**
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef __KX_PYCOMPONENT_H__
#define __KX_PYCOMPONENT_H__
#ifdef WITH_PYTHON
# include "EXP_Value.h"
class KX_GameObject;
struct PythonComponent;
class KX_PythonComponent : public CValue {
Py_Header
private : PythonComponent *m_pc;
KX_GameObject *m_gameobj;
std::string m_name;
bool m_init;
public:
KX_PythonComponent(const std::string &name);
virtual ~KX_PythonComponent();
// stuff for cvalue related things
virtual std::string GetName();
virtual CValue *GetReplica();
void ProcessReplica();
KX_GameObject *GetGameObject() const;
void SetGameObject(KX_GameObject *gameobj);
void SetBlenderPythonComponent(PythonComponent *pc);
void Start();
void Update();
static PyObject *py_component_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
// Attributes
static PyObject *pyattr_get_object(PyObjectPlus *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
};
#endif // WITH_PYTHON
#endif // __KX_PYCOMPONENT_H__
| 26.617647 | 94 | 0.735912 |
0c0f7d02aea37a2abc760e9bc58a960b882880fc | 3,674 | h | C | include/rw/_bitmask.h | Hower91/Apache-C-Standard-Library-4.2.x | 4d9011d60dbb38b3ff80dcfe54dccd3a4647d9d3 | [
"Apache-2.0"
] | null | null | null | include/rw/_bitmask.h | Hower91/Apache-C-Standard-Library-4.2.x | 4d9011d60dbb38b3ff80dcfe54dccd3a4647d9d3 | [
"Apache-2.0"
] | null | null | null | include/rw/_bitmask.h | Hower91/Apache-C-Standard-Library-4.2.x | 4d9011d60dbb38b3ff80dcfe54dccd3a4647d9d3 | [
"Apache-2.0"
] | null | null | null | /***************************************************************************
*
* _bitmask.h - helper definitions for bitmask types
*
* This is an internal header file used to implement the C++ Standard
* Library. It should never be #included directly by a program.
*
* $Id: //stdlib/dev/include/rw/_bitmask.h#6 $
*
***************************************************************************
*
* Copyright (c) 1994-2005 Quovadx, Inc., acting through its Rogue Wave
* Software division. 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 _RWSTD_BITMASK_H_INCLUDED
#define _RWSTD_BITMASK_H_INCLUDED
#include <rw/_defs.h>
#ifndef _RWSTD_NO_STATIC_CONST_MEMBER_INIT
# define _RWSTD_BITMASK_ENUM(Bitmask) Bitmask
# define _RWSTD_DEFINE_BITMASK_OPERATORS(Bitmask) \
\
inline Bitmask& operator&= (Bitmask &__lhs, Bitmask __rhs) { \
return __lhs = Bitmask (long (__lhs) & __rhs); \
} \
\
inline Bitmask& operator|= (Bitmask &__lhs, Bitmask __rhs) { \
return __lhs = Bitmask (long (__lhs) | __rhs); \
} \
\
inline Bitmask& operator^= (Bitmask &__lhs, Bitmask __rhs) { \
return __lhs = Bitmask (long (__lhs) ^ __rhs); \
} \
\
inline Bitmask operator& (Bitmask __lhs, Bitmask __rhs) { \
return __lhs &= __rhs; \
} \
\
inline Bitmask operator| (Bitmask __lhs, Bitmask __rhs) { \
return __lhs |= __rhs; \
} \
\
inline Bitmask operator^ (Bitmask __lhs, Bitmask __rhs) { \
return __lhs ^= __rhs; \
} \
\
inline Bitmask operator~ (Bitmask __rhs) { \
return Bitmask (~long (__rhs)); \
} \
typedef void __rw_unused_typedef
#else // if defined (_RWSTD_NO_STATIC_CONST_MEMBER_INIT)
# define _RWSTD_BITMASK_ENUM(ignore) int
# define _RWSTD_DEFINE_BITMASK_OPERATORS(ignore) \
typedef void __rw_unused_typedef
#endif // _RWSTD_NO_STATIC_CONST_MEMBER_INIT
#endif // _RWSTD_BITMASK_H_INCLUDED
| 48.342105 | 76 | 0.429777 |
08f8e5c406f4129535a63e94cc4769f3b4d00c7d | 2,611 | h | C | machine/qemu/sources/u-boot/drivers/video/nexell/soc/s5pxx18_soc_lvds.h | muddessir/framework | 5b802b2dd7ec9778794b078e748dd1f989547265 | [
"MIT"
] | 1 | 2021-11-21T19:56:29.000Z | 2021-11-21T19:56:29.000Z | machine/qemu/sources/u-boot/drivers/video/nexell/soc/s5pxx18_soc_lvds.h | muddessir/framework | 5b802b2dd7ec9778794b078e748dd1f989547265 | [
"MIT"
] | null | null | null | machine/qemu/sources/u-boot/drivers/video/nexell/soc/s5pxx18_soc_lvds.h | muddessir/framework | 5b802b2dd7ec9778794b078e748dd1f989547265 | [
"MIT"
] | null | null | null | /* SPDX-License-Identifier: GPL-2.0+
*
* Copyright (C) 2016 Nexell Co., Ltd.
*
* Author: junghyun, kim <jhkim@nexell.co.kr>
*/
#ifndef _S5PXX18_SOC_LVDS_H_
#define _S5PXX18_SOC_LVDS_H_
/*
* refter to s5pxx18_soc_disptop.h
*
* #define NUMBER_OF_LVDS_MODULE 1
* #define PHY_BASEADDR_LVDS_MODULE 0xC010A000
*/
#define PHY_BASEADDR_LVDS_LIST \
{ PHY_BASEADDR_LVDS_MODULE }
struct nx_lvds_register_set {
u32 lvdsctrl0;
u32 lvdsctrl1;
u32 lvdsctrl2;
u32 lvdsctrl3;
u32 lvdsctrl4;
u32 _reserved0[3];
u32 lvdsloc0;
u32 lvdsloc1;
u32 lvdsloc2;
u32 lvdsloc3;
u32 lvdsloc4;
u32 lvdsloc5;
u32 lvdsloc6;
u32 _reserved1;
u32 lvdslocmask0;
u32 lvdslocmask1;
u32 lvdslocpol0;
u32 lvdslocpol1;
u32 lvdstmode0;
u32 lvdstmode1;
u32 _reserved2[2];
};
int nx_lvds_initialize(void);
u32 nx_lvds_get_number_of_module(void);
u32 nx_lvds_get_size_of_register_set(void);
void nx_lvds_set_base_address(u32 module_index, void *base_address);
void *nx_lvds_get_base_address(u32 module_index);
u32 nx_lvds_get_physical_address(u32 module_index);
int nx_lvds_open_module(u32 module_index);
int nx_lvds_close_module(u32 module_index);
int nx_lvds_check_busy(u32 module_index);
void nx_lvds_set_lvdsctrl0(u32 module_index, u32 regvalue);
void nx_lvds_set_lvdsctrl1(u32 module_index, u32 regvalue);
void nx_lvds_set_lvdsctrl2(u32 module_index, u32 regvalue);
void nx_lvds_set_lvdsctrl3(u32 module_index, u32 regvalue);
void nx_lvds_set_lvdsctrl4(u32 module_index, u32 regvalue);
u32 nx_lvds_get_lvdsctrl0(u32 module_index);
u32 nx_lvds_get_lvdsctrl1(u32 module_index);
u32 nx_lvds_get_lvdsctrl2(u32 module_index);
u32 nx_lvds_get_lvdsctrl3(u32 module_index);
u32 nx_lvds_get_lvdsctrl4(u32 module_index);
void nx_lvds_set_lvdstmode0(u32 module_index, u32 regvalue);
void nx_lvds_set_lvdsloc0(u32 module_index, u32 regvalue);
void nx_lvds_set_lvdsloc1(u32 module_index, u32 regvalue);
void nx_lvds_set_lvdsloc2(u32 module_index, u32 regvalue);
void nx_lvds_set_lvdsloc3(u32 module_index, u32 regvalue);
void nx_lvds_set_lvdsloc4(u32 module_index, u32 regvalue);
void nx_lvds_set_lvdsloc5(u32 module_index, u32 regvalue);
void nx_lvds_set_lvdsloc6(u32 module_index, u32 regvalue);
void nx_lvds_set_lvdslocmask0(u32 module_index, u32 regvalue);
void nx_lvds_set_lvdslocmask1(u32 module_index, u32 regvalue);
void nx_lvds_set_lvdslocpol0(u32 module_index, u32 regvalue);
void nx_lvds_set_lvdslocpol1(u32 module_index, u32 regvalue);
void nx_lvds_set_lvdslocpol1(u32 module_index, u32 regvalue);
void nx_lvds_set_lvdsdummy(u32 module_index, u32 regvalue);
u32 nx_lvds_get_lvdsdummy(u32 module_index);
#endif
| 31.083333 | 68 | 0.820758 |
8361b4b2a74d7d2d261cff3b2dfd2ac29da0d6dd | 287 | h | C | ios/Wrapper/F2Utils.h | ckid/F2Native | 7303e8585329cc371de148c10ba3e4eb15ce047e | [
"MIT"
] | null | null | null | ios/Wrapper/F2Utils.h | ckid/F2Native | 7303e8585329cc371de148c10ba3e4eb15ce047e | [
"MIT"
] | null | null | null | ios/Wrapper/F2Utils.h | ckid/F2Native | 7303e8585329cc371de148c10ba3e4eb15ce047e | [
"MIT"
] | 1 | 2020-12-30T05:30:30.000Z | 2020-12-30T05:30:30.000Z | #import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
#define XGSafeString(str) (str.length > 0 ? str : @"")
#define XGSafeJson(json) (json.length > 0 ? json : @"[]")
@interface F2Utils : NSObject
+ (NSString *)toJsonString:(NSDictionary *)jsonDict;
@end
NS_ASSUME_NONNULL_END
| 19.133333 | 57 | 0.721254 |
4d246531604fff9c9de6a6c86b040fba9a3832ea | 436 | c | C | Quadrante.c | viniciusfre/linguagem-c | e3c9a37a1284be5d7d53a7eb46e01a46d5ce4be7 | [
"MIT"
] | null | null | null | Quadrante.c | viniciusfre/linguagem-c | e3c9a37a1284be5d7d53a7eb46e01a46d5ce4be7 | [
"MIT"
] | null | null | null | Quadrante.c | viniciusfre/linguagem-c | e3c9a37a1284be5d7d53a7eb46e01a46d5ce4be7 | [
"MIT"
] | null | null | null | #include <stdio.h>
int main() {
int X,Y;
while(scanf("%d %d",&X,&Y)!=EOF){
if(X == 0 || Y==0){
break;
}else{
if(X > 0 && Y > 0){
printf("primeiro\n");
}
if(X < 0 && Y > 0){
printf("segundo\n");
}
if(X < 0 && Y < 0){
printf("terceiro\n");
}
if(X > 0 && Y < 0){
printf("quarto\n");
}
}
}
return 0;
} | 14.533333 | 33 | 0.332569 |
231290088b3c51ebefb22216ed0078e4b1de741e | 2,961 | h | C | src/vlibmemory/socket_client.h | amithbraj/vpp | edf1da94dc099c6e2ab1d455ce8652fada3cdb04 | [
"Apache-2.0"
] | 751 | 2017-07-13T06:16:46.000Z | 2022-03-30T09:14:35.000Z | src/vlibmemory/socket_client.h | amithbraj/vpp | edf1da94dc099c6e2ab1d455ce8652fada3cdb04 | [
"Apache-2.0"
] | 63 | 2018-06-11T09:48:35.000Z | 2021-01-05T09:11:03.000Z | src/vlibmemory/socket_client.h | amithbraj/vpp | edf1da94dc099c6e2ab1d455ce8652fada3cdb04 | [
"Apache-2.0"
] | 479 | 2017-07-13T06:17:26.000Z | 2022-03-31T18:20:43.000Z | /*
*------------------------------------------------------------------
* Copyright (c) 2018 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*------------------------------------------------------------------
*/
#ifndef SRC_VLIBMEMORY_SOCKET_CLIENT_H_
#define SRC_VLIBMEMORY_SOCKET_CLIENT_H_
#include <vppinfra/file.h>
#include <vppinfra/time.h>
#include <vlibmemory/memory_shared.h>
typedef struct
{
int socket_fd;
int socket_enable; /**< Can temporarily disable the connection
but still can keep it around... */
u32 client_index; /**< Client index allocated by VPP */
clib_socket_t client_socket;
u32 socket_buffer_size;
u8 *socket_tx_buffer;
u8 *socket_rx_buffer;
u32 socket_tx_nbytes;
int control_pings_outstanding;
u8 *name;
clib_time_t clib_time;
ssvm_private_t memfd_segment;
int want_shm_pthread;
} socket_client_main_t;
extern socket_client_main_t socket_client_main;
#define SOCKET_CLIENT_DEFAULT_BUFFER_SIZE 4096
int vl_socket_client_connect (char *socket_path, char *client_name,
u32 socket_buffer_size);
void vl_socket_client_disconnect (void);
void vl_socket_client_enable_disable (int enable);
int vl_socket_client_read (int wait);
int vl_socket_client_write (void);
void *vl_socket_client_msg_alloc (int nbytes);
int vl_socket_client_init_shm (vl_api_shm_elem_config_t * config,
int want_pthread);
clib_error_t *vl_socket_client_recv_fd_msg (int fds[], int n_fds, u32 wait);
/*
* Socket client apis that explicitly pass socket main as an argument
*/
int vl_socket_client_connect2 (socket_client_main_t * scm, char *socket_path,
char *client_name, u32 socket_buffer_size);
void vl_socket_client_disconnect2 (socket_client_main_t * scm);
void vl_socket_client_enable_disable2 (socket_client_main_t * scm,
int enable);
int vl_socket_client_read2 (socket_client_main_t * scm, int wait);
int vl_socket_client_write2 (socket_client_main_t * scm);
void *vl_socket_client_msg_alloc2 (socket_client_main_t * scm, int nbytes);
int vl_socket_client_init_shm2 (socket_client_main_t * scm,
vl_api_shm_elem_config_t * config,
int want_pthread);
clib_error_t *vl_socket_client_recv_fd_msg2 (socket_client_main_t * scm,
int fds[], int n_fds, u32 wait);
#endif /* SRC_VLIBMEMORY_SOCKET_CLIENT_H_ */
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/
| 33.269663 | 77 | 0.732185 |
d6f834e409c4cd734c29c3e87671fff6875525bc | 224 | h | C | src/nbl/video/COpenGLRenderpass.h | devshgraphicsprogramming/Nabla | 5588c69ac714734ca50b5d3c1409fed88b258bff | [
"Apache-2.0"
] | null | null | null | src/nbl/video/COpenGLRenderpass.h | devshgraphicsprogramming/Nabla | 5588c69ac714734ca50b5d3c1409fed88b258bff | [
"Apache-2.0"
] | null | null | null | src/nbl/video/COpenGLRenderpass.h | devshgraphicsprogramming/Nabla | 5588c69ac714734ca50b5d3c1409fed88b258bff | [
"Apache-2.0"
] | null | null | null | #ifndef __NBL_C_OPENGL_RENDERPASS_H_INCLUDED__
#define __NBL_C_OPENGL_RENDERPASS_H_INCLUDED__
#include "nbl/video/IGPURenderpass.h"
namespace nbl {
namespace video
{
using COpenGLRenderpass = IGPURenderpass;
}
}
#endif
| 14 | 46 | 0.825893 |
d904c9933b2eb590eeec8b0b60e788ad93c2e2b6 | 11,230 | c | C | FW/edk2-ws/edk2/CryptoPkg/Library/OpensslLib/openssl/krb5/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c | daxx-linux/edk-Lab_Material_FW | 0c92b0b861e33d949a73e3be96929570e6c7ec61 | [
"BSD-2-Clause"
] | 1 | 2022-02-16T01:28:20.000Z | 2022-02-16T01:28:20.000Z | FW/edk2-ws/edk2/CryptoPkg/Library/OpensslLib/openssl/krb5/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c | daxx-linux/edk-Lab_Material_FW | 0c92b0b861e33d949a73e3be96929570e6c7ec61 | [
"BSD-2-Clause"
] | null | null | null | FW/edk2-ws/edk2/CryptoPkg/Library/OpensslLib/openssl/krb5/src/plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c | daxx-linux/edk-Lab_Material_FW | 0c92b0b861e33d949a73e3be96929570e6c7ec61 | [
"BSD-2-Clause"
] | 2 | 2021-07-04T02:59:41.000Z | 2021-07-18T08:07:16.000Z | /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/* plugins/kdb/ldap/libkdb_ldap/kdb_ldap_conn.c */
/*
* Copyright (c) 2004-2005, Novell, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * 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.
* * The copyright holder's name is not 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.
*/
#include "autoconf.h"
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "ldap_main.h"
#include "ldap_service_stash.h"
#include <kdb5.h>
#ifdef HAVE_SASL_SASL_H
#include <sasl/sasl.h>
#endif
/* Ensure that we have the parameters we need to authenticate to the LDAP
* server. Read the password if necessary. */
static krb5_error_code
validate_context(krb5_context context, krb5_ldap_context *ctx)
{
krb5_error_code ret;
if (ctx->sasl_mech != NULL) {
/* Read the password for use as the SASL secret if we can, but do not
* require one as not all mechanisms need it. */
if (ctx->bind_pwd == NULL && ctx->sasl_authcid != NULL &&
ctx->service_password_file != NULL) {
(void)krb5_ldap_readpassword(context, ctx->service_password_file,
ctx->sasl_authcid, &ctx->bind_pwd);
}
return 0;
}
/* For a simple bind, a DN and password are required. */
if (ctx->bind_dn == NULL) {
k5_setmsg(context, EINVAL, _("LDAP bind dn value missing"));
return EINVAL;
}
if (ctx->bind_pwd == NULL && ctx->service_password_file == NULL) {
k5_setmsg(context, EINVAL, _("LDAP bind password value missing"));
return EINVAL;
}
if (ctx->bind_pwd == NULL && ctx->service_password_file != NULL) {
ret = krb5_ldap_readpassword(context, ctx->service_password_file,
ctx->bind_dn, &ctx->bind_pwd);
if (ret) {
k5_prependmsg(context, ret,
_("Error reading password from stash"));
return ret;
}
}
/* An empty password is not allowed. */
if (*ctx->bind_pwd == '\0') {
k5_setmsg(context, EINVAL, _("Service password length is zero"));
return EINVAL;
}
return 0;
}
/*
* Internal Functions called by init functions.
*/
#ifdef HAVE_SASL_SASL_H
static int
interact(LDAP *ld, unsigned flags, void *defaults, void *sin)
{
sasl_interact_t *in = NULL;
krb5_ldap_context *ctx = defaults;
for (in = sin; in != NULL && in->id != SASL_CB_LIST_END; in++) {
if (in->id == SASL_CB_AUTHNAME)
in->result = ctx->sasl_authcid;
else if (in->id == SASL_CB_USER)
in->result = ctx->sasl_authzid;
else if (in->id == SASL_CB_GETREALM)
in->result = ctx->sasl_realm;
else if (in->id == SASL_CB_PASS)
in->result = ctx->bind_pwd;
else
return LDAP_OTHER;
in->len = (in->result != NULL) ? strlen(in->result) : 0;
}
return LDAP_SUCCESS;
}
#else /* HAVE_SASL_SASL_H */
/* We can't define an interaction function, so only non-interactive mechs like
* EXTERNAL can work. */
static int
interact(LDAP *ld, unsigned flags, void *defaults, void *sin)
{
return LDAP_OTHER;
}
#endif
static krb5_error_code
authenticate(krb5_ldap_context *ctx, krb5_ldap_server_handle *server)
{
int st;
struct berval bv;
if (ctx->sasl_mech != NULL) {
st = ldap_sasl_interactive_bind_s(server->ldap_handle, NULL,
ctx->sasl_mech, NULL, NULL,
LDAP_SASL_QUIET, interact, ctx);
if (st != LDAP_SUCCESS) {
k5_setmsg(ctx->kcontext, KRB5_KDB_ACCESS_ERROR,
_("Cannot bind to LDAP server '%s' with SASL mechanism "
"'%s': %s"), server->server_info->server_name,
ctx->sasl_mech, ldap_err2string(st));
return KRB5_KDB_ACCESS_ERROR;
}
} else {
/* Do a simple bind with DN and password. */
bv.bv_val = ctx->bind_pwd;
bv.bv_len = strlen(ctx->bind_pwd);
st = ldap_sasl_bind_s(server->ldap_handle, ctx->bind_dn, NULL, &bv,
NULL, NULL, NULL);
if (st != LDAP_SUCCESS) {
k5_setmsg(ctx->kcontext, KRB5_KDB_ACCESS_ERROR,
_("Cannot bind to LDAP server '%s' as '%s': %s"),
server->server_info->server_name, ctx->bind_dn,
ldap_err2string(st));
return KRB5_KDB_ACCESS_ERROR;
}
}
return 0;
}
static krb5_error_code
initialize_server(krb5_ldap_context *ldap_context, krb5_ldap_server_info *info)
{
krb5_ldap_server_handle *server;
krb5_error_code ret;
int st;
server = calloc(1, sizeof(krb5_ldap_server_handle));
if (server == NULL)
return ENOMEM;
server->server_info = info;
st = ldap_initialize(&server->ldap_handle, info->server_name);
if (st) {
free(server);
k5_setmsg(ldap_context->kcontext, KRB5_KDB_ACCESS_ERROR,
_("Cannot create LDAP handle for '%s': %s"),
info->server_name, ldap_err2string(st));
return KRB5_KDB_ACCESS_ERROR;
}
ret = authenticate(ldap_context, server);
if (ret) {
info->server_status = OFF;
time(&info->downtime);
free(server);
return ret;
}
server->server_info_update_pending = FALSE;
server->next = info->ldap_server_handles;
info->ldap_server_handles = server;
info->num_conns++;
info->server_status = ON;
return 0;
}
/*
* initialization for data base routines.
*/
krb5_error_code
krb5_ldap_db_init(krb5_context context, krb5_ldap_context *ctx)
{
krb5_error_code ret;
int i, version = LDAP_VERSION3;
unsigned int conns;
krb5_ldap_server_info *info;
struct timeval local_timelimit = { 10, 0 };
ret = validate_context(context, ctx);
if (ret)
return ret;
#ifdef LDAP_OPT_DEBUG_LEVEL
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &ctx->ldap_debug);
#endif
ldap_set_option(NULL, LDAP_OPT_PROTOCOL_VERSION, &version);
#ifdef LDAP_OPT_NETWORK_TIMEOUT
ldap_set_option(NULL, LDAP_OPT_NETWORK_TIMEOUT, &local_timelimit);
#elif defined LDAP_X_OPT_CONNECT_TIMEOUT
ldap_set_option(NULL, LDAP_X_OPT_CONNECT_TIMEOUT, &local_timelimit);
#endif
HNDL_LOCK(ctx);
for (i = 0; ctx->server_info_list[i] != NULL; i++) {
info = ctx->server_info_list[i];
if (info->server_status == NOTSET) {
krb5_clear_error_message(context);
#ifdef LDAP_MOD_INCREMENT
info->modify_increment = has_modify_increment(context,
info->server_name);
#else
info->modify_increment = 0;
#endif
for (conns = 0; conns < ctx->max_server_conns; conns++) {
ret = initialize_server(ctx, info);
if (ret)
break;
}
/* If we opened a connection, don't try any more servers. */
if (info->server_status == ON)
break;
}
}
HNDL_UNLOCK(ctx);
return ret;
}
/*
* get a single handle. Do not lock the mutex
*/
krb5_error_code
krb5_ldap_db_single_init(krb5_ldap_context *ldap_context)
{
krb5_error_code st=0;
int cnt=0;
krb5_ldap_server_info *server_info=NULL;
while (ldap_context->server_info_list[cnt] != NULL) {
server_info = ldap_context->server_info_list[cnt];
if ((server_info->server_status == NOTSET || server_info->server_status == ON)) {
if (server_info->num_conns < ldap_context->max_server_conns-1) {
st = initialize_server(ldap_context, server_info);
if (st == LDAP_SUCCESS)
goto cleanup;
}
}
++cnt;
}
/* If we are here, try to connect to all the servers */
cnt = 0;
while (ldap_context->server_info_list[cnt] != NULL) {
server_info = ldap_context->server_info_list[cnt];
st = initialize_server(ldap_context, server_info);
if (st == LDAP_SUCCESS)
goto cleanup;
++cnt;
}
cleanup:
return (st);
}
krb5_error_code
krb5_ldap_rebind(krb5_ldap_context *ldap_context,
krb5_ldap_server_handle **ldap_server_handle)
{
krb5_ldap_server_handle *handle = *ldap_server_handle;
ldap_unbind_ext_s(handle->ldap_handle, NULL, NULL);
if (ldap_initialize(&handle->ldap_handle,
handle->server_info->server_name) != LDAP_SUCCESS ||
authenticate(ldap_context, handle) != 0) {
return krb5_ldap_request_next_handle_from_pool(ldap_context,
ldap_server_handle);
}
return LDAP_SUCCESS;
}
/*
* DAL API functions
*/
krb5_error_code
krb5_ldap_lib_init()
{
return 0;
}
krb5_error_code
krb5_ldap_lib_cleanup()
{
/* right now, no cleanup required */
return 0;
}
krb5_error_code
krb5_ldap_free_ldap_context(krb5_ldap_context *ldap_context)
{
if (ldap_context == NULL)
return 0;
free(ldap_context->container_dn);
ldap_context->container_dn = NULL;
krb5_ldap_free_realm_params(ldap_context->lrparams);
ldap_context->lrparams = NULL;
krb5_ldap_free_server_params(ldap_context);
return 0;
}
krb5_error_code
krb5_ldap_close(krb5_context context)
{
kdb5_dal_handle *dal_handle=NULL;
krb5_ldap_context *ldap_context=NULL;
if (context == NULL ||
context->dal_handle == NULL ||
context->dal_handle->db_context == NULL)
return 0;
dal_handle = context->dal_handle;
ldap_context = (krb5_ldap_context *) dal_handle->db_context;
dal_handle->db_context = NULL;
krb5_ldap_free_ldap_context(ldap_context);
return 0;
}
| 30.68306 | 89 | 0.630543 |
0360405e3e332e90748c0f7a37fd5f67349444cc | 3,767 | c | C | src/condor_filetransfer_plugins/curl_plugin.c | neurodebian/htcondor | 113a5c9921a4fce8a21e3ab96b2c1ba47441bf39 | [
"Apache-2.0"
] | 1 | 2017-02-13T01:25:34.000Z | 2017-02-13T01:25:34.000Z | src/condor_filetransfer_plugins/curl_plugin.c | neurodebian/htcondor | 113a5c9921a4fce8a21e3ab96b2c1ba47441bf39 | [
"Apache-2.0"
] | 1 | 2021-04-06T04:19:40.000Z | 2021-04-06T04:19:40.000Z | src/condor_filetransfer_plugins/curl_plugin.c | neurodebian/htcondor | 113a5c9921a4fce8a21e3ab96b2c1ba47441bf39 | [
"Apache-2.0"
] | 2 | 2016-05-24T17:12:13.000Z | 2017-02-13T01:25:35.000Z | #ifdef WIN32
#include <windows.h>
#define CURL_STATICLIB // this has to match the way the curl library was built.
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#endif
#include <curl/curl.h>
#include <string.h>
int main(int argc, char **argv) {
CURL *handle = NULL;
int rval = -1;
FILE *file = NULL;
int diagnostic = 0;
if(argc == 2 && strcmp(argv[1], "-classad") == 0) {
printf("%s",
"PluginVersion = \"0.1\"\n"
"PluginType = \"FileTransfer\"\n"
"SupportedMethods = \"http,ftp,file\"\n"
);
return 0;
}
if ((argc > 3) && ! strcmp(argv[3],"-diagnostic")) {
diagnostic = 1;
} else if(argc != 3) {
return -1;
}
// Initialize win32 socket libraries, but not ssl
curl_global_init(CURL_GLOBAL_WIN32);
if ( (handle = curl_easy_init()) == NULL ) {
return -1;
}
if ( !strncasecmp( argv[1], "http://", 7 ) ||
!strncasecmp( argv[1], "ftp://", 6 ) ||
!strncasecmp( argv[1], "file://", 7 ) ) {
// Input transfer: URL -> file
int close_output = 1;
if ( ! strcmp(argv[2],"-")) {
file = stdout;
close_output = 0;
if (diagnostic) { fprintf(stderr, "fetching %s to stdout\n", argv[1]); }
} else {
file = fopen(argv[2], "w");
close_output = 1;
if (diagnostic) { fprintf(stderr, "fetching %s to %s\n", argv[1], argv[2]); }
}
if(file) {
curl_easy_setopt(handle, CURLOPT_URL, argv[1]);
curl_easy_setopt(handle, CURLOPT_WRITEDATA, file);
curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, -1);
// Does curl protect against redirect loops otherwise? It's
// unclear how to tune this constant.
// curl_easy_setopt(handle, CURLOPT_MAXREDIRS, 1000);
rval = curl_easy_perform(handle);
if (diagnostic && rval) {
fprintf(stderr, "curl_easy_perform returned CURLcode %d: %s\n",
rval, curl_easy_strerror((CURLcode)rval));
}
if (close_output) {
fclose(file); file = NULL;
}
if( rval == 0 ) {
char * finalURL = NULL;
rval = curl_easy_getinfo( handle, CURLINFO_EFFECTIVE_URL, & finalURL );
if( rval == 0 ) {
if( strstr( finalURL, "http" ) == finalURL ) {
long httpCode = 0;
rval = curl_easy_getinfo( handle, CURLINFO_RESPONSE_CODE, & httpCode );
if( rval == 0 ) {
if( httpCode != 200 ) { rval = 1; }
}
}
}
}
}
} else {
// Output transfer: file -> URL
int close_input = 1;
if ( ! strcmp(argv[1],"-")) {
file = stdin;
close_input = 0;
if (diagnostic) { fprintf(stderr, "sending stdin to %s\n", argv[2]); }
} else {
file = fopen(argv[1], "r");
close_input = 1;
if (diagnostic) { fprintf(stderr, "sending %s to %s\n", argv[1], argv[2]); }
}
if(file) {
curl_easy_setopt(handle, CURLOPT_URL, argv[2]);
curl_easy_setopt(handle, CURLOPT_UPLOAD, 1);
curl_easy_setopt(handle, CURLOPT_READDATA, file);
curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, -1);
// Does curl protect against redirect loops otherwise? It's
// unclear how to tune this constant.
// curl_easy_setopt(handle, CURLOPT_MAXREDIRS, 1000);
rval = curl_easy_perform(handle);
if (diagnostic && rval) {
fprintf(stderr, "curl_easy_perform returned CURLcode %d: %s\n",
rval, curl_easy_strerror((CURLcode)rval));
}
if (close_input) {
fclose(file); file = NULL;
}
if( rval == 0 ) {
char * finalURL = NULL;
rval = curl_easy_getinfo( handle, CURLINFO_EFFECTIVE_URL, & finalURL );
if( rval == 0 ) {
if( strstr( finalURL, "http" ) == finalURL ) {
long httpCode = 0;
rval = curl_easy_getinfo( handle, CURLINFO_RESPONSE_CODE, & httpCode );
if( rval == 0 ) {
if( httpCode != 200 ) { rval = 1; }
}
}
}
}
}
}
curl_easy_cleanup(handle);
curl_global_cleanup();
return rval; // 0 on success
}
| 26.342657 | 80 | 0.612158 |
c150d883376732dd4276f432488a44ff5767b153 | 1,805 | h | C | bitmatrix.h | SiwenFeng/qrcode | a93b8d7fa982c4baa6d0741074e9da40ac5e6007 | [
"MIT"
] | 7 | 2019-11-22T17:22:04.000Z | 2021-07-18T01:34:05.000Z | bitmatrix.h | SiwenFeng/qrcode | a93b8d7fa982c4baa6d0741074e9da40ac5e6007 | [
"MIT"
] | 2 | 2019-12-16T15:58:04.000Z | 2019-12-16T15:59:36.000Z | bitmatrix.h | SiwenFeng/qrcode | a93b8d7fa982c4baa6d0741074e9da40ac5e6007 | [
"MIT"
] | 4 | 2019-11-18T05:05:30.000Z | 2021-04-07T08:00:58.000Z | #ifndef _BITMATRIX_H
#define _BITMATRIX_H
#include <stdint.h>
#include "errors.h"
#include "logs.h"
#define WHITE 0
#define BLACK 1
struct bit_matrix {
unsigned int width;
unsigned int height;
u_int8_t* matrix;
};
/**
* Allocates and returns a bit matrix of the given size where
* all the bits are initialized to 0, i.e. white.
* Returns NULL in case of memory allocation error.
*/
struct bit_matrix* create_bit_matrix(unsigned int width, unsigned int height);
/**
* Frees the memory associated to the given bit matrix.
*/
void free_bit_matrix(struct bit_matrix* bm);
/**
* Returns 1 if the pixel at the given coordinates is black; 0 otherwise.
* Terminates the program if the coordinates are out of bounds.
*/
u_int8_t is_black(struct bit_matrix* bm, unsigned int x, unsigned int y);
/**
* Sets the given value normalized to 1 (black) or 0 (white) at the given coordinates
* or terminates the program if the coordinates are out of bounds.
*/
void set_color(struct bit_matrix* bm, u_int8_t value, unsigned int x, unsigned int y);
/**
* Given a null-terminated array of null-terminated strings containing
* either '*' or ' ', this function will create the corresponding bit matrix
* by converting '*' to 1 and ' ' to 0. This is meant for test purposes.
*
* @param data A null-terminated string array where all strings must have the
* same length and only contain '*' or ' '
* @param bm Where to store the result
* @return SUCCESS on success
* DECODING_ERROR if the given array violates the criteria
* MEMORY_ERROR in case of memory allocation error
*/
int create_from_string(const char* data[], struct bit_matrix* *bm);
/**
* Debug prints the matrix.
*/
void print_matrix(LogLevel level, struct bit_matrix* matrix);
#endif
| 26.15942 | 86 | 0.716343 |
145015b6b4c889e813cdf95079e3ad97b41daacc | 1,510 | h | C | KCLocationUtil/KCLocationManager.h | kumarc-123/KCLocationUtil | c7b945909e34f94e89b557ea4da0614da24a0558 | [
"MIT"
] | 1 | 2016-04-22T09:34:17.000Z | 2016-04-22T09:34:17.000Z | KCLocationUtil/KCLocationManager.h | kumarc-123/KCLocationUtil | c7b945909e34f94e89b557ea4da0614da24a0558 | [
"MIT"
] | null | null | null | KCLocationUtil/KCLocationManager.h | kumarc-123/KCLocationUtil | c7b945909e34f94e89b557ea4da0614da24a0558 | [
"MIT"
] | null | null | null | //
// KCLocationManager.h
// KCLocationUtil
//
// Created by Kumar C on 4/19/16.
// Copyright © 2016 Kumar C. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
typedef void (^KCLocationHandler) (BOOL success, CLLocationCoordinate2D fromLocation, CLLocationCoordinate2D toLocation, NSString * _Nullable errorMessage);
typedef void (^KCGeoCodeHandler) (BOOL success, CLPlacemark * _Nullable placemark , NSString * _Nullable errorMessage);
@interface KCLocationManager : NSObject
@property (nonatomic, assign, readonly) CLLocationCoordinate2D userLocation;
@property (nullable, nonatomic, copy, readonly) NSString *applicationName;
- (void) reverseGeocode : (CLLocationCoordinate2D) location2D completion : (nonnull KCGeoCodeHandler) complation;
- (void) reverseGeocodeUserLocation : (nonnull KCGeoCodeHandler) complation;
- (void) getCurrentLocationWithCompletion : (nonnull KCLocationHandler) completion;
- (CLLocationDistance) distanceFromCurrentLocationToLocation2D : (CLLocationCoordinate2D) toLocation2D;
- (CLLocationDistance) distanceFromLocation2D : (CLLocationCoordinate2D) fromLocation2D toLocation2D : (CLLocationCoordinate2D) toLocation2D;
+ (nonnull instancetype) sharedManager;
+ (nonnull instancetype) withAppName : (nonnull NSString *) applicationName;
- (nonnull NSString *) getErrorMessageForError : (CLError) errorCode;
- (nonnull NSString *) getErrorMessageForMKError : (MKErrorCode) errorCode;
@end
| 35.952381 | 156 | 0.797351 |
5313af06770fbddd80cfa68398fd2ad9466ada9c | 10,302 | c | C | src/comm/transport/udpip/udp_data_sender.c | OpenOCF/iochibity | bc70260d5b86c36d2e3799367c49e1ddb0c2b3f1 | [
"Apache-2.0"
] | 7 | 2017-05-15T23:09:07.000Z | 2020-04-02T16:00:24.000Z | src/comm/transport/udpip/udp_data_sender.c | OpenOCF/iochibity | bc70260d5b86c36d2e3799367c49e1ddb0c2b3f1 | [
"Apache-2.0"
] | null | null | null | src/comm/transport/udpip/udp_data_sender.c | OpenOCF/iochibity | bc70260d5b86c36d2e3799367c49e1ddb0c2b3f1 | [
"Apache-2.0"
] | 2 | 2020-01-02T11:51:56.000Z | 2020-01-23T08:56:50.000Z | /** @file udp_data_sender.c
*
*/
#include "udp_data_sender.h"
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef HAVE_NET_IF_H
#include <net/if.h>
#endif
#if INTERFACE
#include <inttypes.h>
#endif
#include <errno.h>
#define TAG "UDPSEND"
static int32_t CAQueueIPData(bool isMulticast, const CAEndpoint_t *endpoint,
const void *data, uint32_t dataLength)
{
VERIFY_NON_NULL_RET(endpoint, TAG, "remoteEndpoint", -1);
VERIFY_NON_NULL_RET(data, TAG, "data", -1);
if (0 == dataLength)
{
OIC_LOG(ERROR, TAG, "Invalid Data Length");
return -1;
}
// VERIFY_NON_NULL_RET(udp_sendQueueHandle, TAG, "sendQueueHandle", -1);
// Create IPData to add to queue
CAIPData_t *ipData = CACreateIPData(endpoint, data, dataLength, isMulticast);
if (!ipData)
{
OIC_LOG(ERROR, TAG, "Failed to create ipData!");
return -1;
}
// Add message to send queue
CAQueueingThreadAddData(&udp_sendQueueHandle, ipData, sizeof(CAIPData_t));
return dataLength;
}
#ifdef __WITH_DTLS__
ssize_t CAIPPacketSendCB(CAEndpoint_t *endpoint, const void *data, size_t dataLength)
{
VERIFY_NON_NULL_RET(endpoint, TAG, "endpoint is NULL", -1);
VERIFY_NON_NULL_RET(data, TAG, "data is NULL", -1);
CAIPSendData(endpoint, data, dataLength, false);
return dataLength;
}
#endif
int32_t CASendIPUnicastData(const CAEndpoint_t *endpoint,
const void *data, uint32_t dataLength,
CADataType_t dataType)
{
(void)dataType;
return CAQueueIPData(false, endpoint, data, dataLength);
}
int32_t CASendIPMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t dataLength,
CADataType_t dataType)
{
(void)dataType;
return CAQueueIPData(true, endpoint, data, dataLength);
}
LOCAL void udp_send_data(CASocketFd_t fd, /* @was sendData */
const CAEndpoint_t *endpoint,
const void *data, size_t dlen,
const char *cast, const char *fam)
{
OIC_LOG_V(DEBUG, TAG, "IN %s", __func__);
if (!endpoint)
{
OIC_LOG(DEBUG, TAG, "endpoint is null");
// @rewrite: no need to use g_ipErrorHandler, we just call CAIPErrorHandler directly
/* if (g_ipErrorHandler) */
/* { */
/* g_ipErrorHandler(endpoint, data, dlen, CA_STATUS_INVALID_PARAM); */
/* } */
CAErrorHandler(endpoint, data, dlen, CA_STATUS_INVALID_PARAM);
//CAIPErrorHandler(endpoint, data, dlen, CA_STATUS_INVALID_PARAM);
return;
}
(void)cast; // eliminates release warning
(void)fam;
struct sockaddr_storage sock = { .ss_family = 0 };
CAConvertNameToAddr(endpoint->addr, endpoint->port, &sock);
socklen_t socklen = 0;
if (sock.ss_family == AF_INET6)
{
socklen = sizeof(struct sockaddr_in6);
}
else
{
socklen = sizeof(struct sockaddr_in);
}
PORTABLE_sendto(fd, data, dlen, 0, &sock, socklen, endpoint, cast, fam);
}
void CAIPSendData(CAEndpoint_t *endpoint, const void *data, size_t datalen,
bool isMulticast)
{
OIC_LOG_V(DEBUG, TAG, "%s ENTRY", __func__);
VERIFY_NON_NULL_VOID(endpoint, TAG, "endpoint is NULL");
VERIFY_NON_NULL_VOID(data, TAG, "data is NULL");
bool isSecure = (endpoint->flags & CA_SECURE) != 0;
if (isMulticast)
{
OIC_LOG_V(DEBUG, TAG, "%s multicasting", __func__);
endpoint->port = isSecure ? CA_SECURE_COAP : CA_COAP;
u_arraylist_t *iflist = udp_get_ifs_for_rtm_newaddr(0);
if (!iflist)
{
OIC_LOG_V(ERROR, TAG, "get interface info failed: %s", strerror(errno));
return;
}
if ((endpoint->flags & CA_IPV6) && udp_ipv6_is_enabled)
{
sendMulticastData6(iflist, endpoint, data, datalen);
}
if ((endpoint->flags & CA_IPV4) && udp_ipv4_is_enabled)
{
sendMulticastData4(iflist, endpoint, data, datalen);
}
u_arraylist_destroy(iflist);
}
else
{
if (!endpoint->port) // unicast discovery
{
endpoint->port = isSecure ? CA_SECURE_COAP : CA_COAP;
}
CASocketFd_t fd;
if (udp_ipv6_is_enabled && (endpoint->flags & CA_IPV6))
{
fd = isSecure ? udp_u6s.fd : udp_u6.fd;
#ifndef __WITH_DTLS__
fd = udp_u6.fd;
#endif
udp_send_data(fd, endpoint, data, datalen, "unicast", "ipv6");
}
if (udp_ipv4_is_enabled && (endpoint->flags & CA_IPV4))
{
fd = isSecure ? udp_u4s.fd : udp_u4.fd;
#ifndef __WITH_DTLS__
fd = udp_u4.fd;
#endif
udp_send_data(fd, endpoint, data, datalen, "unicast", "ipv4");
}
}
OIC_LOG_V(DEBUG, TAG, "%s EXIT", __func__);
}
void sendMulticastData6(const u_arraylist_t *iflist,
CAEndpoint_t *endpoint,
const void *data, size_t datalen)
{
OIC_LOG_V(DEBUG, TAG, "%s ENTRY", __func__);
if (!endpoint)
{
OIC_LOG(DEBUG, TAG, "endpoint is null");
return;
}
int scope = endpoint->flags & CA_SCOPE_MASK;
char *ipv6mcname = ipv6mcnames[scope];
if (!ipv6mcname)
{
OIC_LOG_V(INFO, TAG, "IPv6 multicast scope invalid: %d", scope);
return;
}
OICStrcpy(endpoint->addr, sizeof(endpoint->addr), ipv6mcname);
CASocketFd_t fd = udp_u6.fd;
size_t len = u_arraylist_length(iflist);
for (size_t i = 0; i < len; i++)
{
CAInterface_t *ifitem = (CAInterface_t *)u_arraylist_get(iflist, i);
if (!ifitem)
{
continue;
}
if ((ifitem->flags & IFF_UP_RUNNING_FLAGS) != IFF_UP_RUNNING_FLAGS)
{
continue;
}
if (ifitem->family != AF_INET6)
{
continue;
}
int index = ifitem->index;
if (setsockopt(fd, IPPROTO_IPV6, IPV6_MULTICAST_IF, OPTVAL_T(&index), sizeof (index)))
{
OIC_LOG_V(ERROR, TAG, "setsockopt6 failed: %s", CAIPS_GET_ERROR);
return;
}
udp_send_data(fd, endpoint, data, datalen, "multicast", "ipv6");
}
}
void sendMulticastData4(const u_arraylist_t *iflist,
CAEndpoint_t *endpoint,
const void *data, size_t datalen)
{
OIC_LOG_V(DEBUG, TAG, "%s ENTRY", __func__);
VERIFY_NON_NULL_VOID(endpoint, TAG, "endpoint is NULL");
#if defined(USE_IP_MREQN)
struct ip_mreqn mreq = { .imr_multiaddr = IPv4MulticastAddress,
.imr_address.s_addr = htonl(INADDR_ANY),
.imr_ifindex = 0};
#else
struct ip_mreq mreq = { .imr_multiaddr.s_addr = IPv4MulticastAddress.s_addr,
.imr_interface = {{0}}};
#endif
OICStrcpy(endpoint->addr, sizeof(endpoint->addr), IPv4_MULTICAST);
CASocketFd_t fd = udp_u4.fd;
size_t len = u_arraylist_length(iflist);
for (size_t i = 0; i < len; i++)
{
CAInterface_t *ifitem = (CAInterface_t *)u_arraylist_get(iflist, i);
if (!ifitem)
{
continue;
}
if ((ifitem->flags & IFF_UP_RUNNING_FLAGS) != IFF_UP_RUNNING_FLAGS)
{
continue;
}
if (ifitem->family != AF_INET)
{
continue;
}
#if defined(USE_IP_MREQN)
mreq.imr_ifindex = ifitem->index;
#else
mreq.imr_interface.s_addr = htonl(ifitem->index);
#endif
if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, OPTVAL_T(&mreq), sizeof (mreq)))
{
OIC_LOG_V(ERROR, TAG, "send IP_MULTICAST_IF failed: %s (using default)",
CAIPS_GET_ERROR);
}
udp_send_data(fd, endpoint, data, datalen, "multicast", "ipv4");
}
}
void CAIPSendDataThread(void *threadData)
{
OIC_LOG_V(DEBUG, TAG, "%s ENTRY (udp_sendQueueHandle)", __func__);
CAIPData_t *ipData = (CAIPData_t *) threadData;
if (!ipData)
{
OIC_LOG(DEBUG, TAG, "Invalid ip data!");
return;
}
if (ipData->isMulticast)
{
//Processing for sending multicast
OIC_LOG(DEBUG, TAG, "Sending Multicast");
CAIPSendData(ipData->remoteEndpoint, ipData->data, ipData->dataLen, true);
}
else
{
//Processing for sending unicast
OIC_LOG(DEBUG, TAG, "Sending Unicast");
#ifdef __WITH_DTLS__
if (ipData->remoteEndpoint && ipData->remoteEndpoint->flags & CA_SECURE)
{
OIC_LOG(DEBUG, TAG, "Sending encrypted");
CAResult_t result = CAencryptSsl(ipData->remoteEndpoint, ipData->data, ipData->dataLen);
if (CA_STATUS_OK != result)
{
OIC_LOG_V(ERROR, TAG, "CAencryptSsl failed: %d", result);
}
OIC_LOG_V(DEBUG, TAG, "CAencryptSsl returned with result[%d]", result);
}
else
{
OIC_LOG(DEBUG, TAG, "Sending unencrypted");
CAIPSendData(ipData->remoteEndpoint, ipData->data, ipData->dataLen, false);
}
#else
CAIPSendData(ipData->remoteEndpoint, ipData->data, ipData->dataLen, false);
#endif
}
}
// create IP packet for sending
CAIPData_t *CACreateIPData(const CAEndpoint_t *remoteEndpoint, const void *data,
uint32_t dataLength, bool isMulticast)
{
VERIFY_NON_NULL_RET(remoteEndpoint, TAG, "remoteEndpoint is NULL", NULL);
VERIFY_NON_NULL_RET(data, TAG, "IPData is NULL", NULL);
CAIPData_t *ipData = (CAIPData_t *) OICMalloc(sizeof(*ipData));
if (!ipData)
{
OIC_LOG(ERROR, TAG, "Memory allocation failed!");
return NULL;
}
ipData->remoteEndpoint = CACloneEndpoint(remoteEndpoint);
ipData->data = (void *) OICMalloc(dataLength);
if (!ipData->data)
{
OIC_LOG(ERROR, TAG, "Memory allocation failed!");
CAFreeIPData(ipData);
return NULL;
}
memcpy(ipData->data, data, dataLength);
ipData->dataLen = dataLength;
ipData->isMulticast = isMulticast;
return ipData;
}
void CAFreeIPData(CAIPData_t *ipData)
{
VERIFY_NON_NULL_VOID(ipData, TAG, "ipData is NULL");
CAFreeEndpoint(ipData->remoteEndpoint);
OICFree(ipData->data);
OICFree(ipData);
}
void CADataDestroyer(void *data, uint32_t size)
{
if (size < sizeof(CAIPData_t))
{
OIC_LOG_V(ERROR, TAG, "Destroy data too small %p %d", data, size);
}
CAIPData_t *etdata = (CAIPData_t *) data;
CAFreeIPData(etdata);
}
| 28.380165 | 100 | 0.621142 |
88bdde0c430f2198028f7c777e036282205e8f37 | 88,135 | c | C | experimentations/perf_kwan/des_kwan_output_sep_cstsbox.c | DadaIsCrazy/usuba | 5ecbf056d7d8bd77462d29309c85f897f36d0f49 | [
"MIT"
] | 41 | 2018-06-22T18:19:20.000Z | 2021-11-14T16:24:15.000Z | experimentations/perf_kwan/des_kwan_output_sep_cstsbox.c | DadaIsCrazy/usuba | 5ecbf056d7d8bd77462d29309c85f897f36d0f49 | [
"MIT"
] | 2 | 2018-06-22T17:55:02.000Z | 2020-07-10T21:54:32.000Z | experimentations/perf_kwan/des_kwan_output_sep_cstsbox.c | DadaIsCrazy/usuba | 5ecbf056d7d8bd77462d29309c85f897f36d0f49 | [
"MIT"
] | 3 | 2019-04-02T22:19:25.000Z | 2021-12-03T02:36:23.000Z | /*
* Generated S-box files.
*
* Produced by Matthew Kwan - March 1998
*/
/*
To generate this from the original code:
perl -p0i~ -E ' s/\s*s(\d+) \(((\s*\S+\s*\^\s*\S+\s*,)+)/my@v;$n=$1;@pre=map{push@v,"t".++$c;" unsigned long t$c = $_;\n"} ($2=~m%\S+\s*\^\s*\w+%g);"@pre"." s$n(".(join",",@v).","/ge' des_kwan.c
perl -pe 's%\s*(s\d)(.*?)(&.*)%my(@p,@n,@c);$f=$1;$s=$2;for($3=~/&(\w+)/g){$v=out.++$i;push@p," unsigned long $v;";push@n," $_ = $_ ^ $v;";push@c,"\&$v";}; join("\n",@p) . ("\n $f$s") . join(",",@c) . ");\n" . join("\n",@n)%e' des_kwan.c > des_kwan_output_sep.c
*/
static void s1 (unsigned long a1,unsigned long a2,unsigned long a3,unsigned long a4,unsigned long a5,unsigned long a6,unsigned long* out1,unsigned long* out2,unsigned long* out3,unsigned long* out4) {
unsigned long x1;
unsigned long x2;
unsigned long x3;
unsigned long x4;
unsigned long x5;
unsigned long x6;
unsigned long x7;
unsigned long x8;
unsigned long x9;
unsigned long x10;
unsigned long x11;
unsigned long x12;
unsigned long x13;
unsigned long x14;
unsigned long x15;
unsigned long x16;
unsigned long x17;
unsigned long x18;
unsigned long x19;
unsigned long x20;
unsigned long x21;
unsigned long x22;
unsigned long x23;
unsigned long x24;
unsigned long x25;
unsigned long x26;
unsigned long x27;
unsigned long x28;
unsigned long x29;
unsigned long x30;
unsigned long x31;
unsigned long x32;
unsigned long x33;
unsigned long x34;
unsigned long x35;
unsigned long x36;
unsigned long x37;
unsigned long x38;
unsigned long x39;
unsigned long x40;
unsigned long x41;
unsigned long x42;
unsigned long x43;
unsigned long x44;
unsigned long x45;
unsigned long x46;
unsigned long x47;
unsigned long x48;
unsigned long x49;
unsigned long x50;
unsigned long x51;
unsigned long x52;
unsigned long x53;
unsigned long x54;
unsigned long x55;
unsigned long x56;
unsigned long x57;
unsigned long x58;
unsigned long x59;
unsigned long x60;
unsigned long x61;
unsigned long x62;
unsigned long x63;
x1 = ~(a4);
x2 = ~(a1);
x3 = (a3) ^ (a4);
x4 = (x2) ^ (x3);
x5 = (x2) | (a3);
x6 = (x1) & (x5);
x7 = (x6) | (a6);
x8 = (x7) ^ (x4);
x9 = (x2) | (x1);
x10 = (x9) & (a6);
x11 = (x10) ^ (x7);
x12 = (x11) | (a2);
x13 = (x12) ^ (x8);
x14 = (x13) ^ (x9);
x15 = (x14) | (a6);
x16 = (x15) ^ (x1);
x17 = ~(x14);
x18 = (x3) & (x17);
x19 = (x18) | (a2);
x20 = (x19) ^ (x16);
x21 = (x20) | (a5);
x22 = (x21) ^ (x13);
*out4 = x22;
x23 = (x4) | (a3);
x24 = ~(x23);
x25 = (x24) | (a6);
x26 = (x25) ^ (x6);
x27 = (x8) & (x1);
x28 = (x27) | (a2);
x29 = (x28) ^ (x26);
x30 = (x8) | (x1);
x31 = (x6) ^ (x30);
x32 = (x14) & (x5);
x33 = (x8) ^ (x32);
x34 = (x33) & (a2);
x35 = (x34) ^ (x31);
x36 = (x35) | (a5);
x37 = (x36) ^ (x29);
*out1 = x37;
x38 = (x10) & (a3);
x39 = (x4) | (x38);
x40 = (x33) & (a3);
x41 = (x25) ^ (x40);
x42 = (x41) | (a2);
x43 = (x42) ^ (x39);
x44 = (x26) | (a3);
x45 = (x14) ^ (x44);
x46 = (x8) | (a1);
x47 = (x20) ^ (x46);
x48 = (x47) | (a2);
x49 = (x48) ^ (x45);
x50 = (x49) & (a5);
x51 = (x50) ^ (x43);
*out2 = x51;
x52 = (x40) ^ (x8);
x53 = (x11) ^ (a3);
x54 = (x5) & (x53);
x55 = (x54) | (a2);
x56 = (x55) ^ (x52);
x57 = (x4) | (a6);
x58 = (x38) ^ (x57);
x59 = (x56) & (x13);
x60 = (x59) & (a2);
x61 = (x60) ^ (x58);
x62 = (x61) & (a5);
x63 = (x62) ^ (x56);
*out3 = x63;
}
static void s2 (unsigned long a1,unsigned long a2,unsigned long a3,unsigned long a4,unsigned long a5,unsigned long a6,unsigned long* out1,unsigned long* out2,unsigned long* out3,unsigned long* out4) {
unsigned long x1;
unsigned long x2;
unsigned long x3;
unsigned long x4;
unsigned long x5;
unsigned long x6;
unsigned long x7;
unsigned long x8;
unsigned long x9;
unsigned long x10;
unsigned long x11;
unsigned long x12;
unsigned long x13;
unsigned long x14;
unsigned long x15;
unsigned long x16;
unsigned long x17;
unsigned long x18;
unsigned long x19;
unsigned long x20;
unsigned long x21;
unsigned long x22;
unsigned long x23;
unsigned long x24;
unsigned long x25;
unsigned long x26;
unsigned long x27;
unsigned long x28;
unsigned long x29;
unsigned long x30;
unsigned long x31;
unsigned long x32;
unsigned long x33;
unsigned long x34;
unsigned long x35;
unsigned long x36;
unsigned long x37;
unsigned long x38;
unsigned long x39;
unsigned long x40;
unsigned long x41;
unsigned long x42;
unsigned long x43;
unsigned long x44;
unsigned long x45;
unsigned long x46;
unsigned long x47;
unsigned long x48;
unsigned long x49;
unsigned long x50;
unsigned long x51;
unsigned long x52;
unsigned long x53;
unsigned long x54;
unsigned long x55;
unsigned long x56;
x1 = ~(a5);
x2 = ~(a1);
x3 = (a6) ^ (a5);
x4 = (x2) ^ (x3);
x5 = (a2) ^ (x4);
x6 = (x1) | (a6);
x7 = (x2) | (x6);
x8 = (x7) & (a2);
x9 = (x8) ^ (a6);
x10 = (x9) & (a3);
x11 = (x10) ^ (x5);
x12 = (x9) & (a2);
x13 = (x6) ^ (a5);
x14 = (x13) | (a3);
x15 = (x14) ^ (x12);
x16 = (x15) & (a4);
x17 = (x16) ^ (x11);
*out2 = x17;
x18 = (a1) | (a5);
x19 = (x18) | (a6);
x20 = (x19) ^ (x13);
x21 = (a2) ^ (x20);
x22 = (x4) | (a6);
x23 = (x17) & (x22);
x24 = (x23) | (a3);
x25 = (x24) ^ (x21);
x26 = (x2) | (a6);
x27 = (x2) & (a5);
x28 = (x27) | (a2);
x29 = (x28) ^ (x26);
x30 = (x27) ^ (x3);
x31 = (x19) ^ (x2);
x32 = (x31) & (a2);
x33 = (x32) ^ (x30);
x34 = (x33) & (a3);
x35 = (x34) ^ (x29);
x36 = (x35) | (a4);
x37 = (x36) ^ (x25);
*out3 = x37;
x38 = (x32) & (x21);
x39 = (x5) ^ (x38);
x40 = (x15) | (a1);
x41 = (x13) ^ (x40);
x42 = (x41) | (a3);
x43 = (x42) ^ (x39);
x44 = (x41) | (x28);
x45 = (x44) & (a4);
x46 = (x45) ^ (x43);
*out1 = x46;
x47 = (x21) & (x19);
x48 = (x26) ^ (x47);
x49 = (x33) & (a2);
x50 = (x21) ^ (x49);
x51 = (x50) & (a3);
x52 = (x51) ^ (x48);
x53 = (x28) & (x18);
x54 = (x50) & (x53);
x55 = (x54) | (a4);
x56 = (x55) ^ (x52);
*out4 = x56;
}
static void s3 (unsigned long a1,unsigned long a2,unsigned long a3,unsigned long a4,unsigned long a5,unsigned long a6,unsigned long* out1,unsigned long* out2,unsigned long* out3,unsigned long* out4) {
unsigned long x1;
unsigned long x2;
unsigned long x3;
unsigned long x4;
unsigned long x5;
unsigned long x6;
unsigned long x7;
unsigned long x8;
unsigned long x9;
unsigned long x10;
unsigned long x11;
unsigned long x12;
unsigned long x13;
unsigned long x14;
unsigned long x15;
unsigned long x16;
unsigned long x17;
unsigned long x18;
unsigned long x19;
unsigned long x20;
unsigned long x21;
unsigned long x22;
unsigned long x23;
unsigned long x24;
unsigned long x25;
unsigned long x26;
unsigned long x27;
unsigned long x28;
unsigned long x29;
unsigned long x30;
unsigned long x31;
unsigned long x32;
unsigned long x33;
unsigned long x34;
unsigned long x35;
unsigned long x36;
unsigned long x37;
unsigned long x38;
unsigned long x39;
unsigned long x40;
unsigned long x41;
unsigned long x42;
unsigned long x43;
unsigned long x44;
unsigned long x45;
unsigned long x46;
unsigned long x47;
unsigned long x48;
unsigned long x49;
unsigned long x50;
unsigned long x51;
unsigned long x52;
unsigned long x53;
unsigned long x54;
unsigned long x55;
unsigned long x56;
unsigned long x57;
x1 = ~(a5);
x2 = ~(a6);
x3 = (a3) & (a5);
x4 = (a6) ^ (x3);
x5 = (x1) & (a4);
x6 = (x5) ^ (x4);
x7 = (a2) ^ (x6);
x8 = (x1) & (a3);
x9 = (x2) ^ (a5);
x10 = (x9) | (a4);
x11 = (x10) ^ (x8);
x12 = (x11) & (x7);
x13 = (x11) ^ (a5);
x14 = (x7) | (x13);
x15 = (x14) & (a4);
x16 = (x15) ^ (x12);
x17 = (x16) & (a2);
x18 = (x17) ^ (x11);
x19 = (x18) & (a1);
x20 = (x19) ^ (x7);
*out4 = x20;
x21 = (a4) ^ (a3);
x22 = (x9) ^ (x21);
x23 = (x4) | (x2);
x24 = (x8) ^ (x23);
x25 = (x24) | (a2);
x26 = (x25) ^ (x22);
x27 = (x23) ^ (a6);
x28 = (a4) | (x27);
x29 = (x15) ^ (a3);
x30 = (x5) | (x29);
x31 = (x30) | (a2);
x32 = (x31) ^ (x28);
x33 = (x32) | (a1);
x34 = (x33) ^ (x26);
*out1 = x34;
x35 = (x9) ^ (a3);
x36 = (x5) | (x35);
x37 = (x29) | (x4);
x38 = (a4) ^ (x37);
x39 = (x38) | (a2);
x40 = (x39) ^ (x36);
x41 = (x11) & (a6);
x42 = (x6) | (x41);
x43 = (x38) ^ (x34);
x44 = (x41) ^ (x43);
x45 = (x44) & (a2);
x46 = (x45) ^ (x42);
x47 = (x46) | (a1);
x48 = (x47) ^ (x40);
*out3 = x48;
x49 = (x38) | (x2);
x50 = (x13) ^ (x49);
x51 = (x28) ^ (x27);
x52 = (x51) | (a2);
x53 = (x52) ^ (x50);
x54 = (x23) & (x12);
x55 = (x52) & (x54);
x56 = (x55) | (a1);
x57 = (x56) ^ (x53);
*out2 = x57;
}
static void s4 (unsigned long a1,unsigned long a2,unsigned long a3,unsigned long a4,unsigned long a5,unsigned long a6,unsigned long* out1,unsigned long* out2,unsigned long* out3,unsigned long* out4) {
unsigned long x1;
unsigned long x2;
unsigned long x3;
unsigned long x4;
unsigned long x5;
unsigned long x6;
unsigned long x7;
unsigned long x8;
unsigned long x9;
unsigned long x10;
unsigned long x11;
unsigned long x12;
unsigned long x13;
unsigned long x14;
unsigned long x15;
unsigned long x16;
unsigned long x17;
unsigned long x18;
unsigned long x19;
unsigned long x20;
unsigned long x21;
unsigned long x22;
unsigned long x23;
unsigned long x24;
unsigned long x25;
unsigned long x26;
unsigned long x27;
unsigned long x28;
unsigned long x29;
unsigned long x30;
unsigned long x31;
unsigned long x32;
unsigned long x33;
unsigned long x34;
unsigned long x35;
unsigned long x36;
unsigned long x37;
unsigned long x38;
unsigned long x39;
unsigned long x40;
unsigned long x41;
unsigned long x42;
x1 = ~(a1);
x2 = ~(a3);
x3 = (a3) | (a1);
x4 = (x3) & (a5);
x5 = (x4) ^ (x1);
x6 = (a3) | (a2);
x7 = (x6) ^ (x5);
x8 = (a5) & (a1);
x9 = (x3) ^ (x8);
x10 = (x9) & (a2);
x11 = (x10) ^ (a5);
x12 = (x11) & (a4);
x13 = (x12) ^ (x7);
x14 = (x4) ^ (x2);
x15 = (x14) & (a2);
x16 = (x15) ^ (x9);
x17 = (x14) & (x5);
x18 = (x2) ^ (a5);
x19 = (x18) | (a2);
x20 = (x19) ^ (x17);
x21 = (x20) | (a4);
x22 = (x21) ^ (x16);
x23 = (x22) & (a6);
x24 = (x23) ^ (x13);
*out2 = x24;
x25 = ~(x13);
x26 = (x22) | (a6);
x27 = (x26) ^ (x25);
*out1 = x27;
x28 = (x11) & (a2);
x29 = (x17) ^ (x28);
x30 = (x10) ^ (a3);
x31 = (x19) ^ (x30);
x32 = (x31) & (a4);
x33 = (x32) ^ (x29);
x34 = (x33) ^ (x25);
x35 = (x34) & (a2);
x36 = (x35) ^ (x24);
x37 = (x34) | (a4);
x38 = (x37) ^ (x36);
x39 = (x38) & (a6);
x40 = (x39) ^ (x33);
*out4 = x40;
x41 = (x38) ^ (x26);
x42 = (x40) ^ (x41);
*out3 = x42;
}
static void s5 (unsigned long a1,unsigned long a2,unsigned long a3,unsigned long a4,unsigned long a5,unsigned long a6,unsigned long* out1,unsigned long* out2,unsigned long* out3,unsigned long* out4) {
unsigned long x1;
unsigned long x2;
unsigned long x3;
unsigned long x4;
unsigned long x5;
unsigned long x6;
unsigned long x7;
unsigned long x8;
unsigned long x9;
unsigned long x10;
unsigned long x11;
unsigned long x12;
unsigned long x13;
unsigned long x14;
unsigned long x15;
unsigned long x16;
unsigned long x17;
unsigned long x18;
unsigned long x19;
unsigned long x20;
unsigned long x21;
unsigned long x22;
unsigned long x23;
unsigned long x24;
unsigned long x25;
unsigned long x26;
unsigned long x27;
unsigned long x28;
unsigned long x29;
unsigned long x30;
unsigned long x31;
unsigned long x32;
unsigned long x33;
unsigned long x34;
unsigned long x35;
unsigned long x36;
unsigned long x37;
unsigned long x38;
unsigned long x39;
unsigned long x40;
unsigned long x41;
unsigned long x42;
unsigned long x43;
unsigned long x44;
unsigned long x45;
unsigned long x46;
unsigned long x47;
unsigned long x48;
unsigned long x49;
unsigned long x50;
unsigned long x51;
unsigned long x52;
unsigned long x53;
unsigned long x54;
unsigned long x55;
unsigned long x56;
unsigned long x57;
unsigned long x58;
unsigned long x59;
unsigned long x60;
unsigned long x61;
unsigned long x62;
x1 = ~(a6);
x2 = ~(a3);
x3 = (x2) | (x1);
x4 = (a4) ^ (x3);
x5 = (x3) & (a1);
x6 = (x5) ^ (x4);
x7 = (a4) | (a6);
x8 = (a3) ^ (x7);
x9 = (x7) | (a3);
x10 = (x9) | (a1);
x11 = (x10) ^ (x8);
x12 = (x11) & (a5);
x13 = (x12) ^ (x6);
x14 = ~(x4);
x15 = (a6) & (x14);
x16 = (x15) | (a1);
x17 = (x16) ^ (x8);
x18 = (x17) | (a5);
x19 = (x18) ^ (x10);
x20 = (x19) | (a2);
x21 = (x20) ^ (x13);
*out3 = x21;
x22 = (x15) | (x2);
x23 = (a6) ^ (x22);
x24 = (x22) ^ (a4);
x25 = (x24) & (a1);
x26 = (x25) ^ (x23);
x27 = (x11) ^ (a1);
x28 = (x22) & (x27);
x29 = (x28) | (a5);
x30 = (x29) ^ (x26);
x31 = (x27) | (a4);
x32 = ~(x31);
x33 = (x32) | (a2);
x34 = (x33) ^ (x30);
*out2 = x34;
x35 = (x15) ^ (x2);
x36 = (x35) & (a1);
x37 = (x36) ^ (x14);
x38 = (x7) ^ (x5);
x39 = (x34) & (x38);
x40 = (x39) | (a5);
x41 = (x40) ^ (x37);
x42 = (x5) ^ (x2);
x43 = (x16) & (x42);
x44 = (x27) & (x4);
x45 = (x44) & (a5);
x46 = (x45) ^ (x43);
x47 = (x46) | (a2);
x48 = (x47) ^ (x41);
*out1 = x48;
x49 = (x48) & (x24);
x50 = (x5) ^ (x49);
x51 = (x30) ^ (x11);
x52 = (x50) | (x51);
x53 = (x52) & (a5);
x54 = (x53) ^ (x50);
x55 = (x19) ^ (x14);
x56 = (x34) ^ (x55);
x57 = (x16) ^ (x4);
x58 = (x30) & (x57);
x59 = (x58) & (a5);
x60 = (x59) ^ (x56);
x61 = (x60) | (a2);
x62 = (x61) ^ (x54);
*out4 = x62;
}
static void s6 (unsigned long a1,unsigned long a2,unsigned long a3,unsigned long a4,unsigned long a5,unsigned long a6,unsigned long* out1,unsigned long* out2,unsigned long* out3,unsigned long* out4) {
unsigned long x1;
unsigned long x2;
unsigned long x3;
unsigned long x4;
unsigned long x5;
unsigned long x6;
unsigned long x7;
unsigned long x8;
unsigned long x9;
unsigned long x10;
unsigned long x11;
unsigned long x12;
unsigned long x13;
unsigned long x14;
unsigned long x15;
unsigned long x16;
unsigned long x17;
unsigned long x18;
unsigned long x19;
unsigned long x20;
unsigned long x21;
unsigned long x22;
unsigned long x23;
unsigned long x24;
unsigned long x25;
unsigned long x26;
unsigned long x27;
unsigned long x28;
unsigned long x29;
unsigned long x30;
unsigned long x31;
unsigned long x32;
unsigned long x33;
unsigned long x34;
unsigned long x35;
unsigned long x36;
unsigned long x37;
unsigned long x38;
unsigned long x39;
unsigned long x40;
unsigned long x41;
unsigned long x42;
unsigned long x43;
unsigned long x44;
unsigned long x45;
unsigned long x46;
unsigned long x47;
unsigned long x48;
unsigned long x49;
unsigned long x50;
unsigned long x51;
unsigned long x52;
unsigned long x53;
unsigned long x54;
unsigned long x55;
unsigned long x56;
unsigned long x57;
x1 = ~(a2);
x2 = ~(a5);
x3 = (a6) ^ (a2);
x4 = (x2) ^ (x3);
x5 = (a1) ^ (x4);
x6 = (a6) & (a5);
x7 = (x1) | (x6);
x8 = (x5) & (a5);
x9 = (x8) & (a1);
x10 = (x9) ^ (x7);
x11 = (x10) & (a4);
x12 = (x11) ^ (x5);
x13 = (x10) ^ (a6);
x14 = (a1) & (x13);
x15 = (a6) & (a2);
x16 = (a5) ^ (x15);
x17 = (x16) & (a1);
x18 = (x17) ^ (x2);
x19 = (x18) | (a4);
x20 = (x19) ^ (x14);
x21 = (x20) & (a3);
x22 = (x21) ^ (x12);
*out2 = x22;
x23 = (x18) ^ (a6);
x24 = (x23) & (a1);
x25 = (x24) ^ (a5);
x26 = (x17) ^ (a2);
x27 = (x6) | (x26);
x28 = (x27) & (a4);
x29 = (x28) ^ (x25);
x30 = ~(x26);
x31 = (x29) | (a6);
x32 = ~(x31);
x33 = (x32) & (a4);
x34 = (x33) ^ (x30);
x35 = (x34) & (a3);
x36 = (x35) ^ (x29);
*out4 = x36;
x37 = (x34) ^ (x6);
x38 = (x23) & (a5);
x39 = (x5) ^ (x38);
x40 = (x39) | (a4);
x41 = (x40) ^ (x37);
x42 = (x24) | (x16);
x43 = (x1) ^ (x42);
x44 = (x24) ^ (x15);
x45 = (x31) ^ (x44);
x46 = (x45) | (a4);
x47 = (x46) ^ (x43);
x48 = (x47) | (a3);
x49 = (x48) ^ (x41);
*out1 = x49;
x50 = (x38) | (x5);
x51 = (x6) ^ (x50);
x52 = (x31) & (x8);
x53 = (x52) | (a4);
x54 = (x53) ^ (x51);
x55 = (x43) & (x30);
x56 = (x55) | (a3);
x57 = (x56) ^ (x54);
*out3 = x57;
}
static void s7 (unsigned long a1,unsigned long a2,unsigned long a3,unsigned long a4,unsigned long a5,unsigned long a6,unsigned long* out1,unsigned long* out2,unsigned long* out3,unsigned long* out4) {
unsigned long x1;
unsigned long x2;
unsigned long x3;
unsigned long x4;
unsigned long x5;
unsigned long x6;
unsigned long x7;
unsigned long x8;
unsigned long x9;
unsigned long x10;
unsigned long x11;
unsigned long x12;
unsigned long x13;
unsigned long x14;
unsigned long x15;
unsigned long x16;
unsigned long x17;
unsigned long x18;
unsigned long x19;
unsigned long x20;
unsigned long x21;
unsigned long x22;
unsigned long x23;
unsigned long x24;
unsigned long x25;
unsigned long x26;
unsigned long x27;
unsigned long x28;
unsigned long x29;
unsigned long x30;
unsigned long x31;
unsigned long x32;
unsigned long x33;
unsigned long x34;
unsigned long x35;
unsigned long x36;
unsigned long x37;
unsigned long x38;
unsigned long x39;
unsigned long x40;
unsigned long x41;
unsigned long x42;
unsigned long x43;
unsigned long x44;
unsigned long x45;
unsigned long x46;
unsigned long x47;
unsigned long x48;
unsigned long x49;
unsigned long x50;
unsigned long x51;
unsigned long x52;
unsigned long x53;
unsigned long x54;
unsigned long x55;
unsigned long x56;
unsigned long x57;
x1 = ~(a2);
x2 = ~(a5);
x3 = (a4) & (a2);
x4 = (a5) ^ (x3);
x5 = (a3) ^ (x4);
x6 = (x4) & (a4);
x7 = (a2) ^ (x6);
x8 = (x7) & (a3);
x9 = (x8) ^ (a1);
x10 = (x9) | (a6);
x11 = (x10) ^ (x5);
x12 = (x2) & (a4);
x13 = (a2) | (x12);
x14 = (x2) | (a2);
x15 = (x14) & (a3);
x16 = (x15) ^ (x13);
x17 = (x11) ^ (x6);
x18 = (x17) | (a6);
x19 = (x18) ^ (x16);
x20 = (x19) & (a1);
x21 = (x20) ^ (x11);
*out1 = x21;
x22 = (x21) | (a2);
x23 = (x6) ^ (x22);
x24 = (x15) ^ (x23);
x25 = (x6) ^ (x5);
x26 = (x12) | (x25);
x27 = (x26) | (a6);
x28 = (x27) ^ (x24);
x29 = (x19) & (x1);
x30 = (x26) & (x23);
x31 = (x30) & (a6);
x32 = (x31) ^ (x29);
x33 = (x32) | (a1);
x34 = (x33) ^ (x28);
*out4 = x34;
x35 = (x16) & (a4);
x36 = (x1) | (x35);
x37 = (x36) & (a6);
x38 = (x37) ^ (x11);
x39 = (x13) & (a4);
x40 = (x7) | (a3);
x41 = (x40) ^ (x39);
x42 = (x24) | (x1);
x43 = (x42) | (a6);
x44 = (x43) ^ (x41);
x45 = (x44) | (a1);
x46 = (x45) ^ (x38);
*out2 = x46;
x47 = (x44) ^ (x8);
x48 = (x15) ^ (x6);
x49 = (x48) | (a6);
x50 = (x49) ^ (x47);
x51 = (x44) ^ (x19);
x52 = (x25) ^ (a4);
x53 = (x46) & (x52);
x54 = (x53) & (a6);
x55 = (x54) ^ (x51);
x56 = (x55) | (a1);
x57 = (x56) ^ (x50);
*out3 = x57;
}
static void s8 (unsigned long a1,unsigned long a2,unsigned long a3,unsigned long a4,unsigned long a5,unsigned long a6,unsigned long* out1,unsigned long* out2,unsigned long* out3,unsigned long* out4) {
unsigned long x1;
unsigned long x2;
unsigned long x3;
unsigned long x4;
unsigned long x5;
unsigned long x6;
unsigned long x7;
unsigned long x8;
unsigned long x9;
unsigned long x10;
unsigned long x11;
unsigned long x12;
unsigned long x13;
unsigned long x14;
unsigned long x15;
unsigned long x16;
unsigned long x17;
unsigned long x18;
unsigned long x19;
unsigned long x20;
unsigned long x21;
unsigned long x22;
unsigned long x23;
unsigned long x24;
unsigned long x25;
unsigned long x26;
unsigned long x27;
unsigned long x28;
unsigned long x29;
unsigned long x30;
unsigned long x31;
unsigned long x32;
unsigned long x33;
unsigned long x34;
unsigned long x35;
unsigned long x36;
unsigned long x37;
unsigned long x38;
unsigned long x39;
unsigned long x40;
unsigned long x41;
unsigned long x42;
unsigned long x43;
unsigned long x44;
unsigned long x45;
unsigned long x46;
unsigned long x47;
unsigned long x48;
unsigned long x49;
unsigned long x50;
unsigned long x51;
unsigned long x52;
unsigned long x53;
unsigned long x54;
x1 = ~(a1);
x2 = ~(a4);
x3 = (x1) ^ (a3);
x4 = (x1) | (a3);
x5 = (x2) ^ (x4);
x6 = (x5) | (a5);
x7 = (x6) ^ (x3);
x8 = (x5) | (x1);
x9 = (x8) ^ (x2);
x10 = (x9) & (a5);
x11 = (x10) ^ (x8);
x12 = (x11) & (a2);
x13 = (x12) ^ (x7);
x14 = (x9) ^ (x6);
x15 = (x9) & (x3);
x16 = (x8) & (a5);
x17 = (x16) ^ (x15);
x18 = (x17) | (a2);
x19 = (x18) ^ (x14);
x20 = (x19) | (a6);
x21 = (x20) ^ (x13);
*out1 = x21;
x22 = (x3) | (a5);
x23 = (x2) & (x22);
x24 = ~(a3);
x25 = (x8) & (x24);
x26 = (x4) & (a5);
x27 = (x26) ^ (x25);
x28 = (x27) | (a2);
x29 = (x28) ^ (x23);
x30 = (x29) & (a6);
x31 = (x30) ^ (x13);
*out4 = x31;
x32 = (x6) ^ (x5);
x33 = (x22) ^ (x32);
x34 = (x13) | (a4);
x35 = (x34) & (a2);
x36 = (x35) ^ (x33);
x37 = (x33) & (a1);
x38 = (x8) ^ (x37);
x39 = (x23) ^ (a1);
x40 = (x7) & (x39);
x41 = (x40) & (a2);
x42 = (x41) ^ (x38);
x43 = (x42) | (a6);
x44 = (x43) ^ (x36);
*out3 = x44;
x45 = (x10) ^ (a1);
x46 = (x22) ^ (x45);
x47 = ~(x7);
x48 = (x8) & (x47);
x49 = (x48) | (a2);
x50 = (x49) ^ (x46);
x51 = (x29) ^ (x19);
x52 = (x38) | (x51);
x53 = (x52) & (a6);
x54 = (x53) ^ (x50);
*out2 = x54;
}
/*
* Bitslice implementation of DES.
*
* Checks that the plaintext bits p[0] .. p[63]
* encrypt to the ciphertext bits c[0] .. c[63]
* given the key bits k0 .. k55
*/
void
deseval (
const unsigned long *p,
unsigned long *c,
const unsigned long *k
) {
unsigned long l0 = p[6];
unsigned long l1 = p[14];
unsigned long l2 = p[22];
unsigned long l3 = p[30];
unsigned long l4 = p[38];
unsigned long l5 = p[46];
unsigned long l6 = p[54];
unsigned long l7 = p[62];
unsigned long l8 = p[4];
unsigned long l9 = p[12];
unsigned long l10 = p[20];
unsigned long l11 = p[28];
unsigned long l12 = p[36];
unsigned long l13 = p[44];
unsigned long l14 = p[52];
unsigned long l15 = p[60];
unsigned long l16 = p[2];
unsigned long l17 = p[10];
unsigned long l18 = p[18];
unsigned long l19 = p[26];
unsigned long l20 = p[34];
unsigned long l21 = p[42];
unsigned long l22 = p[50];
unsigned long l23 = p[58];
unsigned long l24 = p[0];
unsigned long l25 = p[8];
unsigned long l26 = p[16];
unsigned long l27 = p[24];
unsigned long l28 = p[32];
unsigned long l29 = p[40];
unsigned long l30 = p[48];
unsigned long l31 = p[56];
unsigned long r0 = p[7];
unsigned long r1 = p[15];
unsigned long r2 = p[23];
unsigned long r3 = p[31];
unsigned long r4 = p[39];
unsigned long r5 = p[47];
unsigned long r6 = p[55];
unsigned long r7 = p[63];
unsigned long r8 = p[5];
unsigned long r9 = p[13];
unsigned long r10 = p[21];
unsigned long r11 = p[29];
unsigned long r12 = p[37];
unsigned long r13 = p[45];
unsigned long r14 = p[53];
unsigned long r15 = p[61];
unsigned long r16 = p[3];
unsigned long r17 = p[11];
unsigned long r18 = p[19];
unsigned long r19 = p[27];
unsigned long r20 = p[35];
unsigned long r21 = p[43];
unsigned long r22 = p[51];
unsigned long r23 = p[59];
unsigned long r24 = p[1];
unsigned long r25 = p[9];
unsigned long r26 = p[17];
unsigned long r27 = p[25];
unsigned long r28 = p[33];
unsigned long r29 = p[41];
unsigned long r30 = p[49];
unsigned long r31 = p[57];
unsigned long k0 = k[0];
unsigned long k1 = k[1];
unsigned long k2 = k[2];
unsigned long k3 = k[3];
unsigned long k4 = k[4];
unsigned long k5 = k[5];
unsigned long k6 = k[6];
unsigned long k7 = k[7];
unsigned long k8 = k[8];
unsigned long k9 = k[9];
unsigned long k10 = k[10];
unsigned long k11 = k[11];
unsigned long k12 = k[12];
unsigned long k13 = k[13];
unsigned long k14 = k[14];
unsigned long k15 = k[15];
unsigned long k16 = k[16];
unsigned long k17 = k[17];
unsigned long k18 = k[18];
unsigned long k19 = k[19];
unsigned long k20 = k[20];
unsigned long k21 = k[21];
unsigned long k22 = k[22];
unsigned long k23 = k[23];
unsigned long k24 = k[24];
unsigned long k25 = k[25];
unsigned long k26 = k[26];
unsigned long k27 = k[27];
unsigned long k28 = k[28];
unsigned long k29 = k[29];
unsigned long k30 = k[30];
unsigned long k31 = k[31];
unsigned long k32 = k[32];
unsigned long k33 = k[33];
unsigned long k34 = k[34];
unsigned long k35 = k[35];
unsigned long k36 = k[36];
unsigned long k37 = k[37];
unsigned long k38 = k[38];
unsigned long k39 = k[39];
unsigned long k40 = k[40];
unsigned long k41 = k[41];
unsigned long k42 = k[42];
unsigned long k43 = k[43];
unsigned long k44 = k[44];
unsigned long k45 = k[45];
unsigned long k46 = k[46];
unsigned long k47 = k[47];
unsigned long k48 = k[48];
unsigned long k49 = k[49];
unsigned long k50 = k[50];
unsigned long k51 = k[51];
unsigned long k52 = k[52];
unsigned long k53 = k[53];
unsigned long k54 = k[54];
unsigned long k55 = k[55];
unsigned long k56 = k[56];
unsigned long k57 = k[57];
unsigned long k58 = k[58];
unsigned long k59 = k[59];
unsigned long k60 = k[60];
unsigned long k61 = k[61];
unsigned long k62 = k[62];
unsigned long k63 = k[63];
unsigned long t1 = r31 ^ k47;
unsigned long t2 = r0 ^ k11;
unsigned long t3 = r1 ^ k26;
unsigned long t4 = r2 ^ k3;
unsigned long t5 = r3 ^ k13;
unsigned long t6 = r4 ^ k41;
unsigned long out1;
unsigned long out2;
unsigned long out3;
unsigned long out4;
s1(t1,t2,t3,t4,t5,t6, &out1,&out2,&out3,&out4);
l8 = l8 ^ out1;
l16 = l16 ^ out2;
l22 = l22 ^ out3;
l30 = l30 ^ out4;
unsigned long t7 = r3 ^ k27;
unsigned long t8 = r4 ^ k6;
unsigned long t9 = r5 ^ k54;
unsigned long t10 = r6 ^ k48;
unsigned long t11 = r7 ^ k39;
unsigned long t12 = r8 ^ k19;
unsigned long out5;
unsigned long out6;
unsigned long out7;
unsigned long out8;
s2(t7,t8,t9,t10,t11,t12, &out5,&out6,&out7,&out8);
l12 = l12 ^ out5;
l27 = l27 ^ out6;
l1 = l1 ^ out7;
l17 = l17 ^ out8;
unsigned long t13 = r7 ^ k53;
unsigned long t14 = r8 ^ k25;
unsigned long t15 = r9 ^ k33;
unsigned long t16 = r10 ^ k34;
unsigned long t17 = r11 ^ k17;
unsigned long t18 = r12 ^ k5;
unsigned long out9;
unsigned long out10;
unsigned long out11;
unsigned long out12;
s3(t13,t14,t15,t16,t17,t18, &out9,&out10,&out11,&out12);
l23 = l23 ^ out9;
l15 = l15 ^ out10;
l29 = l29 ^ out11;
l5 = l5 ^ out12;
unsigned long t19 = r11 ^ k4;
unsigned long t20 = r12 ^ k55;
unsigned long t21 = r13 ^ k24;
unsigned long t22 = r14 ^ k32;
unsigned long t23 = r15 ^ k40;
unsigned long t24 = r16 ^ k20;
unsigned long out13;
unsigned long out14;
unsigned long out15;
unsigned long out16;
s4(t19,t20,t21,t22,t23,t24, &out13,&out14,&out15,&out16);
l25 = l25 ^ out13;
l19 = l19 ^ out14;
l9 = l9 ^ out15;
l0 = l0 ^ out16;
unsigned long t25 = r15 ^ k36;
unsigned long t26 = r16 ^ k31;
unsigned long t27 = r17 ^ k21;
unsigned long t28 = r18 ^ k8;
unsigned long t29 = r19 ^ k23;
unsigned long t30 = r20 ^ k52;
unsigned long out17;
unsigned long out18;
unsigned long out19;
unsigned long out20;
s5(t25,t26,t27,t28,t29,t30, &out17,&out18,&out19,&out20);
l7 = l7 ^ out17;
l13 = l13 ^ out18;
l24 = l24 ^ out19;
l2 = l2 ^ out20;
unsigned long t31 = r19 ^ k14;
unsigned long t32 = r20 ^ k29;
unsigned long t33 = r21 ^ k51;
unsigned long t34 = r22 ^ k9;
unsigned long t35 = r23 ^ k35;
unsigned long t36 = r24 ^ k30;
unsigned long out21;
unsigned long out22;
unsigned long out23;
unsigned long out24;
s6(t31,t32,t33,t34,t35,t36, &out21,&out22,&out23,&out24);
l3 = l3 ^ out21;
l28 = l28 ^ out22;
l10 = l10 ^ out23;
l18 = l18 ^ out24;
unsigned long t37 = r23 ^ k2;
unsigned long t38 = r24 ^ k37;
unsigned long t39 = r25 ^ k22;
unsigned long t40 = r26 ^ k0;
unsigned long t41 = r27 ^ k42;
unsigned long t42 = r28 ^ k38;
unsigned long out25;
unsigned long out26;
unsigned long out27;
unsigned long out28;
s7(t37,t38,t39,t40,t41,t42, &out25,&out26,&out27,&out28);
l31 = l31 ^ out25;
l11 = l11 ^ out26;
l21 = l21 ^ out27;
l6 = l6 ^ out28;
unsigned long t43 = r27 ^ k16;
unsigned long t44 = r28 ^ k43;
unsigned long t45 = r29 ^ k44;
unsigned long t46 = r30 ^ k1;
unsigned long t47 = r31 ^ k7;
unsigned long t48 = r0 ^ k28;
unsigned long out29;
unsigned long out30;
unsigned long out31;
unsigned long out32;
s8(t43,t44,t45,t46,t47,t48, &out29,&out30,&out31,&out32);
l4 = l4 ^ out29;
l26 = l26 ^ out30;
l14 = l14 ^ out31;
l20 = l20 ^ out32;
unsigned long t49 = l31 ^ k54;
unsigned long t50 = l0 ^ k18;
unsigned long t51 = l1 ^ k33;
unsigned long t52 = l2 ^ k10;
unsigned long t53 = l3 ^ k20;
unsigned long t54 = l4 ^ k48;
unsigned long out33;
unsigned long out34;
unsigned long out35;
unsigned long out36;
s1(t49,t50,t51,t52,t53,t54, &out33,&out34,&out35,&out36);
r8 = r8 ^ out33;
r16 = r16 ^ out34;
r22 = r22 ^ out35;
r30 = r30 ^ out36;
unsigned long t55 = l3 ^ k34;
unsigned long t56 = l4 ^ k13;
unsigned long t57 = l5 ^ k4;
unsigned long t58 = l6 ^ k55;
unsigned long t59 = l7 ^ k46;
unsigned long t60 = l8 ^ k26;
unsigned long out37;
unsigned long out38;
unsigned long out39;
unsigned long out40;
s2(t55,t56,t57,t58,t59,t60, &out37,&out38,&out39,&out40);
r12 = r12 ^ out37;
r27 = r27 ^ out38;
r1 = r1 ^ out39;
r17 = r17 ^ out40;
unsigned long t61 = l7 ^ k3;
unsigned long t62 = l8 ^ k32;
unsigned long t63 = l9 ^ k40;
unsigned long t64 = l10 ^ k41;
unsigned long t65 = l11 ^ k24;
unsigned long t66 = l12 ^ k12;
unsigned long out41;
unsigned long out42;
unsigned long out43;
unsigned long out44;
s3(t61,t62,t63,t64,t65,t66, &out41,&out42,&out43,&out44);
r23 = r23 ^ out41;
r15 = r15 ^ out42;
r29 = r29 ^ out43;
r5 = r5 ^ out44;
unsigned long t67 = l11 ^ k11;
unsigned long t68 = l12 ^ k5;
unsigned long t69 = l13 ^ k6;
unsigned long t70 = l14 ^ k39;
unsigned long t71 = l15 ^ k47;
unsigned long t72 = l16 ^ k27;
unsigned long out45;
unsigned long out46;
unsigned long out47;
unsigned long out48;
s4(t67,t68,t69,t70,t71,t72, &out45,&out46,&out47,&out48);
r25 = r25 ^ out45;
r19 = r19 ^ out46;
r9 = r9 ^ out47;
r0 = r0 ^ out48;
unsigned long t73 = l15 ^ k43;
unsigned long t74 = l16 ^ k38;
unsigned long t75 = l17 ^ k28;
unsigned long t76 = l18 ^ k15;
unsigned long t77 = l19 ^ k30;
unsigned long t78 = l20 ^ k0;
unsigned long out49;
unsigned long out50;
unsigned long out51;
unsigned long out52;
s5(t73,t74,t75,t76,t77,t78, &out49,&out50,&out51,&out52);
r7 = r7 ^ out49;
r13 = r13 ^ out50;
r24 = r24 ^ out51;
r2 = r2 ^ out52;
unsigned long t79 = l19 ^ k21;
unsigned long t80 = l20 ^ k36;
unsigned long t81 = l21 ^ k31;
unsigned long t82 = l22 ^ k16;
unsigned long t83 = l23 ^ k42;
unsigned long t84 = l24 ^ k37;
unsigned long out53;
unsigned long out54;
unsigned long out55;
unsigned long out56;
s6(t79,t80,t81,t82,t83,t84, &out53,&out54,&out55,&out56);
r3 = r3 ^ out53;
r28 = r28 ^ out54;
r10 = r10 ^ out55;
r18 = r18 ^ out56;
unsigned long t85 = l23 ^ k9;
unsigned long t86 = l24 ^ k44;
unsigned long t87 = l25 ^ k29;
unsigned long t88 = l26 ^ k7;
unsigned long t89 = l27 ^ k49;
unsigned long t90 = l28 ^ k45;
unsigned long out57;
unsigned long out58;
unsigned long out59;
unsigned long out60;
s7(t85,t86,t87,t88,t89,t90, &out57,&out58,&out59,&out60);
r31 = r31 ^ out57;
r11 = r11 ^ out58;
r21 = r21 ^ out59;
r6 = r6 ^ out60;
unsigned long t91 = l27 ^ k23;
unsigned long t92 = l28 ^ k50;
unsigned long t93 = l29 ^ k51;
unsigned long t94 = l30 ^ k8;
unsigned long t95 = l31 ^ k14;
unsigned long t96 = l0 ^ k35;
unsigned long out61;
unsigned long out62;
unsigned long out63;
unsigned long out64;
s8(t91,t92,t93,t94,t95,t96, &out61,&out62,&out63,&out64);
r4 = r4 ^ out61;
r26 = r26 ^ out62;
r14 = r14 ^ out63;
r20 = r20 ^ out64;
unsigned long t97 = r31 ^ k11;
unsigned long t98 = r0 ^ k32;
unsigned long t99 = r1 ^ k47;
unsigned long t100 = r2 ^ k24;
unsigned long t101 = r3 ^ k34;
unsigned long t102 = r4 ^ k5;
unsigned long out65;
unsigned long out66;
unsigned long out67;
unsigned long out68;
s1(t97,t98,t99,t100,t101,t102, &out65,&out66,&out67,&out68);
l8 = l8 ^ out65;
l16 = l16 ^ out66;
l22 = l22 ^ out67;
l30 = l30 ^ out68;
unsigned long t103 = r3 ^ k48;
unsigned long t104 = r4 ^ k27;
unsigned long t105 = r5 ^ k18;
unsigned long t106 = r6 ^ k12;
unsigned long t107 = r7 ^ k3;
unsigned long t108 = r8 ^ k40;
unsigned long out69;
unsigned long out70;
unsigned long out71;
unsigned long out72;
s2(t103,t104,t105,t106,t107,t108, &out69,&out70,&out71,&out72);
l12 = l12 ^ out69;
l27 = l27 ^ out70;
l1 = l1 ^ out71;
l17 = l17 ^ out72;
unsigned long t109 = r7 ^ k17;
unsigned long t110 = r8 ^ k46;
unsigned long t111 = r9 ^ k54;
unsigned long t112 = r10 ^ k55;
unsigned long t113 = r11 ^ k13;
unsigned long t114 = r12 ^ k26;
unsigned long out73;
unsigned long out74;
unsigned long out75;
unsigned long out76;
s3(t109,t110,t111,t112,t113,t114, &out73,&out74,&out75,&out76);
l23 = l23 ^ out73;
l15 = l15 ^ out74;
l29 = l29 ^ out75;
l5 = l5 ^ out76;
unsigned long t115 = r11 ^ k25;
unsigned long t116 = r12 ^ k19;
unsigned long t117 = r13 ^ k20;
unsigned long t118 = r14 ^ k53;
unsigned long t119 = r15 ^ k4;
unsigned long t120 = r16 ^ k41;
unsigned long out77;
unsigned long out78;
unsigned long out79;
unsigned long out80;
s4(t115,t116,t117,t118,t119,t120, &out77,&out78,&out79,&out80);
l25 = l25 ^ out77;
l19 = l19 ^ out78;
l9 = l9 ^ out79;
l0 = l0 ^ out80;
unsigned long t121 = r15 ^ k2;
unsigned long t122 = r16 ^ k52;
unsigned long t123 = r17 ^ k42;
unsigned long t124 = r18 ^ k29;
unsigned long t125 = r19 ^ k44;
unsigned long t126 = r20 ^ k14;
unsigned long out81;
unsigned long out82;
unsigned long out83;
unsigned long out84;
s5(t121,t122,t123,t124,t125,t126, &out81,&out82,&out83,&out84);
l7 = l7 ^ out81;
l13 = l13 ^ out82;
l24 = l24 ^ out83;
l2 = l2 ^ out84;
unsigned long t127 = r19 ^ k35;
unsigned long t128 = r20 ^ k50;
unsigned long t129 = r21 ^ k45;
unsigned long t130 = r22 ^ k30;
unsigned long t131 = r23 ^ k1;
unsigned long t132 = r24 ^ k51;
unsigned long out85;
unsigned long out86;
unsigned long out87;
unsigned long out88;
s6(t127,t128,t129,t130,t131,t132, &out85,&out86,&out87,&out88);
l3 = l3 ^ out85;
l28 = l28 ^ out86;
l10 = l10 ^ out87;
l18 = l18 ^ out88;
unsigned long t133 = r23 ^ k23;
unsigned long t134 = r24 ^ k31;
unsigned long t135 = r25 ^ k43;
unsigned long t136 = r26 ^ k21;
unsigned long t137 = r27 ^ k8;
unsigned long t138 = r28 ^ k0;
unsigned long out89;
unsigned long out90;
unsigned long out91;
unsigned long out92;
s7(t133,t134,t135,t136,t137,t138, &out89,&out90,&out91,&out92);
l31 = l31 ^ out89;
l11 = l11 ^ out90;
l21 = l21 ^ out91;
l6 = l6 ^ out92;
unsigned long t139 = r27 ^ k37;
unsigned long t140 = r28 ^ k9;
unsigned long t141 = r29 ^ k38;
unsigned long t142 = r30 ^ k22;
unsigned long t143 = r31 ^ k28;
unsigned long t144 = r0 ^ k49;
unsigned long out93;
unsigned long out94;
unsigned long out95;
unsigned long out96;
s8(t139,t140,t141,t142,t143,t144, &out93,&out94,&out95,&out96);
l4 = l4 ^ out93;
l26 = l26 ^ out94;
l14 = l14 ^ out95;
l20 = l20 ^ out96;
unsigned long t145 = l31 ^ k25;
unsigned long t146 = l0 ^ k46;
unsigned long t147 = l1 ^ k4;
unsigned long t148 = l2 ^ k13;
unsigned long t149 = l3 ^ k48;
unsigned long t150 = l4 ^ k19;
unsigned long out97;
unsigned long out98;
unsigned long out99;
unsigned long out100;
s1(t145,t146,t147,t148,t149,t150, &out97,&out98,&out99,&out100);
r8 = r8 ^ out97;
r16 = r16 ^ out98;
r22 = r22 ^ out99;
r30 = r30 ^ out100;
unsigned long t151 = l3 ^ k5;
unsigned long t152 = l4 ^ k41;
unsigned long t153 = l5 ^ k32;
unsigned long t154 = l6 ^ k26;
unsigned long t155 = l7 ^ k17;
unsigned long t156 = l8 ^ k54;
unsigned long out101;
unsigned long out102;
unsigned long out103;
unsigned long out104;
s2(t151,t152,t153,t154,t155,t156, &out101,&out102,&out103,&out104);
r12 = r12 ^ out101;
r27 = r27 ^ out102;
r1 = r1 ^ out103;
r17 = r17 ^ out104;
unsigned long t157 = l7 ^ k6;
unsigned long t158 = l8 ^ k3;
unsigned long t159 = l9 ^ k11;
unsigned long t160 = l10 ^ k12;
unsigned long t161 = l11 ^ k27;
unsigned long t162 = l12 ^ k40;
unsigned long out105;
unsigned long out106;
unsigned long out107;
unsigned long out108;
s3(t157,t158,t159,t160,t161,t162, &out105,&out106,&out107,&out108);
r23 = r23 ^ out105;
r15 = r15 ^ out106;
r29 = r29 ^ out107;
r5 = r5 ^ out108;
unsigned long t163 = l11 ^ k39;
unsigned long t164 = l12 ^ k33;
unsigned long t165 = l13 ^ k34;
unsigned long t166 = l14 ^ k10;
unsigned long t167 = l15 ^ k18;
unsigned long t168 = l16 ^ k55;
unsigned long out109;
unsigned long out110;
unsigned long out111;
unsigned long out112;
s4(t163,t164,t165,t166,t167,t168, &out109,&out110,&out111,&out112);
r25 = r25 ^ out109;
r19 = r19 ^ out110;
r9 = r9 ^ out111;
r0 = r0 ^ out112;
unsigned long t169 = l15 ^ k16;
unsigned long t170 = l16 ^ k7;
unsigned long t171 = l17 ^ k1;
unsigned long t172 = l18 ^ k43;
unsigned long t173 = l19 ^ k31;
unsigned long t174 = l20 ^ k28;
unsigned long out113;
unsigned long out114;
unsigned long out115;
unsigned long out116;
s5(t169,t170,t171,t172,t173,t174, &out113,&out114,&out115,&out116);
r7 = r7 ^ out113;
r13 = r13 ^ out114;
r24 = r24 ^ out115;
r2 = r2 ^ out116;
unsigned long t175 = l19 ^ k49;
unsigned long t176 = l20 ^ k9;
unsigned long t177 = l21 ^ k0;
unsigned long t178 = l22 ^ k44;
unsigned long t179 = l23 ^ k15;
unsigned long t180 = l24 ^ k38;
unsigned long out117;
unsigned long out118;
unsigned long out119;
unsigned long out120;
s6(t175,t176,t177,t178,t179,t180, &out117,&out118,&out119,&out120);
r3 = r3 ^ out117;
r28 = r28 ^ out118;
r10 = r10 ^ out119;
r18 = r18 ^ out120;
unsigned long t181 = l23 ^ k37;
unsigned long t182 = l24 ^ k45;
unsigned long t183 = l25 ^ k2;
unsigned long t184 = l26 ^ k35;
unsigned long t185 = l27 ^ k22;
unsigned long t186 = l28 ^ k14;
unsigned long out121;
unsigned long out122;
unsigned long out123;
unsigned long out124;
s7(t181,t182,t183,t184,t185,t186, &out121,&out122,&out123,&out124);
r31 = r31 ^ out121;
r11 = r11 ^ out122;
r21 = r21 ^ out123;
r6 = r6 ^ out124;
unsigned long t187 = l27 ^ k51;
unsigned long t188 = l28 ^ k23;
unsigned long t189 = l29 ^ k52;
unsigned long t190 = l30 ^ k36;
unsigned long t191 = l31 ^ k42;
unsigned long t192 = l0 ^ k8;
unsigned long out125;
unsigned long out126;
unsigned long out127;
unsigned long out128;
s8(t187,t188,t189,t190,t191,t192, &out125,&out126,&out127,&out128);
r4 = r4 ^ out125;
r26 = r26 ^ out126;
r14 = r14 ^ out127;
r20 = r20 ^ out128;
unsigned long t193 = r31 ^ k39;
unsigned long t194 = r0 ^ k3;
unsigned long t195 = r1 ^ k18;
unsigned long t196 = r2 ^ k27;
unsigned long t197 = r3 ^ k5;
unsigned long t198 = r4 ^ k33;
unsigned long out129;
unsigned long out130;
unsigned long out131;
unsigned long out132;
s1(t193,t194,t195,t196,t197,t198, &out129,&out130,&out131,&out132);
l8 = l8 ^ out129;
l16 = l16 ^ out130;
l22 = l22 ^ out131;
l30 = l30 ^ out132;
unsigned long t199 = r3 ^ k19;
unsigned long t200 = r4 ^ k55;
unsigned long t201 = r5 ^ k46;
unsigned long t202 = r6 ^ k40;
unsigned long t203 = r7 ^ k6;
unsigned long t204 = r8 ^ k11;
unsigned long out133;
unsigned long out134;
unsigned long out135;
unsigned long out136;
s2(t199,t200,t201,t202,t203,t204, &out133,&out134,&out135,&out136);
l12 = l12 ^ out133;
l27 = l27 ^ out134;
l1 = l1 ^ out135;
l17 = l17 ^ out136;
unsigned long t205 = r7 ^ k20;
unsigned long t206 = r8 ^ k17;
unsigned long t207 = r9 ^ k25;
unsigned long t208 = r10 ^ k26;
unsigned long t209 = r11 ^ k41;
unsigned long t210 = r12 ^ k54;
unsigned long out137;
unsigned long out138;
unsigned long out139;
unsigned long out140;
s3(t205,t206,t207,t208,t209,t210, &out137,&out138,&out139,&out140);
l23 = l23 ^ out137;
l15 = l15 ^ out138;
l29 = l29 ^ out139;
l5 = l5 ^ out140;
unsigned long t211 = r11 ^ k53;
unsigned long t212 = r12 ^ k47;
unsigned long t213 = r13 ^ k48;
unsigned long t214 = r14 ^ k24;
unsigned long t215 = r15 ^ k32;
unsigned long t216 = r16 ^ k12;
unsigned long out141;
unsigned long out142;
unsigned long out143;
unsigned long out144;
s4(t211,t212,t213,t214,t215,t216, &out141,&out142,&out143,&out144);
l25 = l25 ^ out141;
l19 = l19 ^ out142;
l9 = l9 ^ out143;
l0 = l0 ^ out144;
unsigned long t217 = r15 ^ k30;
unsigned long t218 = r16 ^ k21;
unsigned long t219 = r17 ^ k15;
unsigned long t220 = r18 ^ k2;
unsigned long t221 = r19 ^ k45;
unsigned long t222 = r20 ^ k42;
unsigned long out145;
unsigned long out146;
unsigned long out147;
unsigned long out148;
s5(t217,t218,t219,t220,t221,t222, &out145,&out146,&out147,&out148);
l7 = l7 ^ out145;
l13 = l13 ^ out146;
l24 = l24 ^ out147;
l2 = l2 ^ out148;
unsigned long t223 = r19 ^ k8;
unsigned long t224 = r20 ^ k23;
unsigned long t225 = r21 ^ k14;
unsigned long t226 = r22 ^ k31;
unsigned long t227 = r23 ^ k29;
unsigned long t228 = r24 ^ k52;
unsigned long out149;
unsigned long out150;
unsigned long out151;
unsigned long out152;
s6(t223,t224,t225,t226,t227,t228, &out149,&out150,&out151,&out152);
l3 = l3 ^ out149;
l28 = l28 ^ out150;
l10 = l10 ^ out151;
l18 = l18 ^ out152;
unsigned long t229 = r23 ^ k51;
unsigned long t230 = r24 ^ k0;
unsigned long t231 = r25 ^ k16;
unsigned long t232 = r26 ^ k49;
unsigned long t233 = r27 ^ k36;
unsigned long t234 = r28 ^ k28;
unsigned long out153;
unsigned long out154;
unsigned long out155;
unsigned long out156;
s7(t229,t230,t231,t232,t233,t234, &out153,&out154,&out155,&out156);
l31 = l31 ^ out153;
l11 = l11 ^ out154;
l21 = l21 ^ out155;
l6 = l6 ^ out156;
unsigned long t235 = r27 ^ k38;
unsigned long t236 = r28 ^ k37;
unsigned long t237 = r29 ^ k7;
unsigned long t238 = r30 ^ k50;
unsigned long t239 = r31 ^ k1;
unsigned long t240 = r0 ^ k22;
unsigned long out157;
unsigned long out158;
unsigned long out159;
unsigned long out160;
s8(t235,t236,t237,t238,t239,t240, &out157,&out158,&out159,&out160);
l4 = l4 ^ out157;
l26 = l26 ^ out158;
l14 = l14 ^ out159;
l20 = l20 ^ out160;
unsigned long t241 = l31 ^ k53;
unsigned long t242 = l0 ^ k17;
unsigned long t243 = l1 ^ k32;
unsigned long t244 = l2 ^ k41;
unsigned long t245 = l3 ^ k19;
unsigned long t246 = l4 ^ k47;
unsigned long out161;
unsigned long out162;
unsigned long out163;
unsigned long out164;
s1(t241,t242,t243,t244,t245,t246, &out161,&out162,&out163,&out164);
r8 = r8 ^ out161;
r16 = r16 ^ out162;
r22 = r22 ^ out163;
r30 = r30 ^ out164;
unsigned long t247 = l3 ^ k33;
unsigned long t248 = l4 ^ k12;
unsigned long t249 = l5 ^ k3;
unsigned long t250 = l6 ^ k54;
unsigned long t251 = l7 ^ k20;
unsigned long t252 = l8 ^ k25;
unsigned long out165;
unsigned long out166;
unsigned long out167;
unsigned long out168;
s2(t247,t248,t249,t250,t251,t252, &out165,&out166,&out167,&out168);
r12 = r12 ^ out165;
r27 = r27 ^ out166;
r1 = r1 ^ out167;
r17 = r17 ^ out168;
unsigned long t253 = l7 ^ k34;
unsigned long t254 = l8 ^ k6;
unsigned long t255 = l9 ^ k39;
unsigned long t256 = l10 ^ k40;
unsigned long t257 = l11 ^ k55;
unsigned long t258 = l12 ^ k11;
unsigned long out169;
unsigned long out170;
unsigned long out171;
unsigned long out172;
s3(t253,t254,t255,t256,t257,t258, &out169,&out170,&out171,&out172);
r23 = r23 ^ out169;
r15 = r15 ^ out170;
r29 = r29 ^ out171;
r5 = r5 ^ out172;
unsigned long t259 = l11 ^ k10;
unsigned long t260 = l12 ^ k4;
unsigned long t261 = l13 ^ k5;
unsigned long t262 = l14 ^ k13;
unsigned long t263 = l15 ^ k46;
unsigned long t264 = l16 ^ k26;
unsigned long out173;
unsigned long out174;
unsigned long out175;
unsigned long out176;
s4(t259,t260,t261,t262,t263,t264, &out173,&out174,&out175,&out176);
r25 = r25 ^ out173;
r19 = r19 ^ out174;
r9 = r9 ^ out175;
r0 = r0 ^ out176;
unsigned long t265 = l15 ^ k44;
unsigned long t266 = l16 ^ k35;
unsigned long t267 = l17 ^ k29;
unsigned long t268 = l18 ^ k16;
unsigned long t269 = l19 ^ k0;
unsigned long t270 = l20 ^ k1;
unsigned long out177;
unsigned long out178;
unsigned long out179;
unsigned long out180;
s5(t265,t266,t267,t268,t269,t270, &out177,&out178,&out179,&out180);
r7 = r7 ^ out177;
r13 = r13 ^ out178;
r24 = r24 ^ out179;
r2 = r2 ^ out180;
unsigned long t271 = l19 ^ k22;
unsigned long t272 = l20 ^ k37;
unsigned long t273 = l21 ^ k28;
unsigned long t274 = l22 ^ k45;
unsigned long t275 = l23 ^ k43;
unsigned long t276 = l24 ^ k7;
unsigned long out181;
unsigned long out182;
unsigned long out183;
unsigned long out184;
s6(t271,t272,t273,t274,t275,t276, &out181,&out182,&out183,&out184);
r3 = r3 ^ out181;
r28 = r28 ^ out182;
r10 = r10 ^ out183;
r18 = r18 ^ out184;
unsigned long t277 = l23 ^ k38;
unsigned long t278 = l24 ^ k14;
unsigned long t279 = l25 ^ k30;
unsigned long t280 = l26 ^ k8;
unsigned long t281 = l27 ^ k50;
unsigned long t282 = l28 ^ k42;
unsigned long out185;
unsigned long out186;
unsigned long out187;
unsigned long out188;
s7(t277,t278,t279,t280,t281,t282, &out185,&out186,&out187,&out188);
r31 = r31 ^ out185;
r11 = r11 ^ out186;
r21 = r21 ^ out187;
r6 = r6 ^ out188;
unsigned long t283 = l27 ^ k52;
unsigned long t284 = l28 ^ k51;
unsigned long t285 = l29 ^ k21;
unsigned long t286 = l30 ^ k9;
unsigned long t287 = l31 ^ k15;
unsigned long t288 = l0 ^ k36;
unsigned long out189;
unsigned long out190;
unsigned long out191;
unsigned long out192;
s8(t283,t284,t285,t286,t287,t288, &out189,&out190,&out191,&out192);
r4 = r4 ^ out189;
r26 = r26 ^ out190;
r14 = r14 ^ out191;
r20 = r20 ^ out192;
unsigned long t289 = r31 ^ k10;
unsigned long t290 = r0 ^ k6;
unsigned long t291 = r1 ^ k46;
unsigned long t292 = r2 ^ k55;
unsigned long t293 = r3 ^ k33;
unsigned long t294 = r4 ^ k4;
unsigned long out193;
unsigned long out194;
unsigned long out195;
unsigned long out196;
s1(t289,t290,t291,t292,t293,t294, &out193,&out194,&out195,&out196);
l8 = l8 ^ out193;
l16 = l16 ^ out194;
l22 = l22 ^ out195;
l30 = l30 ^ out196;
unsigned long t295 = r3 ^ k47;
unsigned long t296 = r4 ^ k26;
unsigned long t297 = r5 ^ k17;
unsigned long t298 = r6 ^ k11;
unsigned long t299 = r7 ^ k34;
unsigned long t300 = r8 ^ k39;
unsigned long out197;
unsigned long out198;
unsigned long out199;
unsigned long out200;
s2(t295,t296,t297,t298,t299,t300, &out197,&out198,&out199,&out200);
l12 = l12 ^ out197;
l27 = l27 ^ out198;
l1 = l1 ^ out199;
l17 = l17 ^ out200;
unsigned long t301 = r7 ^ k48;
unsigned long t302 = r8 ^ k20;
unsigned long t303 = r9 ^ k53;
unsigned long t304 = r10 ^ k54;
unsigned long t305 = r11 ^ k12;
unsigned long t306 = r12 ^ k25;
unsigned long out201;
unsigned long out202;
unsigned long out203;
unsigned long out204;
s3(t301,t302,t303,t304,t305,t306, &out201,&out202,&out203,&out204);
l23 = l23 ^ out201;
l15 = l15 ^ out202;
l29 = l29 ^ out203;
l5 = l5 ^ out204;
unsigned long t307 = r11 ^ k24;
unsigned long t308 = r12 ^ k18;
unsigned long t309 = r13 ^ k19;
unsigned long t310 = r14 ^ k27;
unsigned long t311 = r15 ^ k3;
unsigned long t312 = r16 ^ k40;
unsigned long out205;
unsigned long out206;
unsigned long out207;
unsigned long out208;
s4(t307,t308,t309,t310,t311,t312, &out205,&out206,&out207,&out208);
l25 = l25 ^ out205;
l19 = l19 ^ out206;
l9 = l9 ^ out207;
l0 = l0 ^ out208;
unsigned long t313 = r15 ^ k31;
unsigned long t314 = r16 ^ k49;
unsigned long t315 = r17 ^ k43;
unsigned long t316 = r18 ^ k30;
unsigned long t317 = r19 ^ k14;
unsigned long t318 = r20 ^ k15;
unsigned long out209;
unsigned long out210;
unsigned long out211;
unsigned long out212;
s5(t313,t314,t315,t316,t317,t318, &out209,&out210,&out211,&out212);
l7 = l7 ^ out209;
l13 = l13 ^ out210;
l24 = l24 ^ out211;
l2 = l2 ^ out212;
unsigned long t319 = r19 ^ k36;
unsigned long t320 = r20 ^ k51;
unsigned long t321 = r21 ^ k42;
unsigned long t322 = r22 ^ k0;
unsigned long t323 = r23 ^ k2;
unsigned long t324 = r24 ^ k21;
unsigned long out213;
unsigned long out214;
unsigned long out215;
unsigned long out216;
s6(t319,t320,t321,t322,t323,t324, &out213,&out214,&out215,&out216);
l3 = l3 ^ out213;
l28 = l28 ^ out214;
l10 = l10 ^ out215;
l18 = l18 ^ out216;
unsigned long t325 = r23 ^ k52;
unsigned long t326 = r24 ^ k28;
unsigned long t327 = r25 ^ k44;
unsigned long t328 = r26 ^ k22;
unsigned long t329 = r27 ^ k9;
unsigned long t330 = r28 ^ k1;
unsigned long out217;
unsigned long out218;
unsigned long out219;
unsigned long out220;
s7(t325,t326,t327,t328,t329,t330, &out217,&out218,&out219,&out220);
l31 = l31 ^ out217;
l11 = l11 ^ out218;
l21 = l21 ^ out219;
l6 = l6 ^ out220;
unsigned long t331 = r27 ^ k7;
unsigned long t332 = r28 ^ k38;
unsigned long t333 = r29 ^ k35;
unsigned long t334 = r30 ^ k23;
unsigned long t335 = r31 ^ k29;
unsigned long t336 = r0 ^ k50;
unsigned long out221;
unsigned long out222;
unsigned long out223;
unsigned long out224;
s8(t331,t332,t333,t334,t335,t336, &out221,&out222,&out223,&out224);
l4 = l4 ^ out221;
l26 = l26 ^ out222;
l14 = l14 ^ out223;
l20 = l20 ^ out224;
unsigned long t337 = l31 ^ k24;
unsigned long t338 = l0 ^ k20;
unsigned long t339 = l1 ^ k3;
unsigned long t340 = l2 ^ k12;
unsigned long t341 = l3 ^ k47;
unsigned long t342 = l4 ^ k18;
unsigned long out225;
unsigned long out226;
unsigned long out227;
unsigned long out228;
s1(t337,t338,t339,t340,t341,t342, &out225,&out226,&out227,&out228);
r8 = r8 ^ out225;
r16 = r16 ^ out226;
r22 = r22 ^ out227;
r30 = r30 ^ out228;
unsigned long t343 = l3 ^ k4;
unsigned long t344 = l4 ^ k40;
unsigned long t345 = l5 ^ k6;
unsigned long t346 = l6 ^ k25;
unsigned long t347 = l7 ^ k48;
unsigned long t348 = l8 ^ k53;
unsigned long out229;
unsigned long out230;
unsigned long out231;
unsigned long out232;
s2(t343,t344,t345,t346,t347,t348, &out229,&out230,&out231,&out232);
r12 = r12 ^ out229;
r27 = r27 ^ out230;
r1 = r1 ^ out231;
r17 = r17 ^ out232;
unsigned long t349 = l7 ^ k5;
unsigned long t350 = l8 ^ k34;
unsigned long t351 = l9 ^ k10;
unsigned long t352 = l10 ^ k11;
unsigned long t353 = l11 ^ k26;
unsigned long t354 = l12 ^ k39;
unsigned long out233;
unsigned long out234;
unsigned long out235;
unsigned long out236;
s3(t349,t350,t351,t352,t353,t354, &out233,&out234,&out235,&out236);
r23 = r23 ^ out233;
r15 = r15 ^ out234;
r29 = r29 ^ out235;
r5 = r5 ^ out236;
unsigned long t355 = l11 ^ k13;
unsigned long t356 = l12 ^ k32;
unsigned long t357 = l13 ^ k33;
unsigned long t358 = l14 ^ k41;
unsigned long t359 = l15 ^ k17;
unsigned long t360 = l16 ^ k54;
unsigned long out237;
unsigned long out238;
unsigned long out239;
unsigned long out240;
s4(t355,t356,t357,t358,t359,t360, &out237,&out238,&out239,&out240);
r25 = r25 ^ out237;
r19 = r19 ^ out238;
r9 = r9 ^ out239;
r0 = r0 ^ out240;
unsigned long t361 = l15 ^ k45;
unsigned long t362 = l16 ^ k8;
unsigned long t363 = l17 ^ k2;
unsigned long t364 = l18 ^ k44;
unsigned long t365 = l19 ^ k28;
unsigned long t366 = l20 ^ k29;
unsigned long out241;
unsigned long out242;
unsigned long out243;
unsigned long out244;
s5(t361,t362,t363,t364,t365,t366, &out241,&out242,&out243,&out244);
r7 = r7 ^ out241;
r13 = r13 ^ out242;
r24 = r24 ^ out243;
r2 = r2 ^ out244;
unsigned long t367 = l19 ^ k50;
unsigned long t368 = l20 ^ k38;
unsigned long t369 = l21 ^ k1;
unsigned long t370 = l22 ^ k14;
unsigned long t371 = l23 ^ k16;
unsigned long t372 = l24 ^ k35;
unsigned long out245;
unsigned long out246;
unsigned long out247;
unsigned long out248;
s6(t367,t368,t369,t370,t371,t372, &out245,&out246,&out247,&out248);
r3 = r3 ^ out245;
r28 = r28 ^ out246;
r10 = r10 ^ out247;
r18 = r18 ^ out248;
unsigned long t373 = l23 ^ k7;
unsigned long t374 = l24 ^ k42;
unsigned long t375 = l25 ^ k31;
unsigned long t376 = l26 ^ k36;
unsigned long t377 = l27 ^ k23;
unsigned long t378 = l28 ^ k15;
unsigned long out249;
unsigned long out250;
unsigned long out251;
unsigned long out252;
s7(t373,t374,t375,t376,t377,t378, &out249,&out250,&out251,&out252);
r31 = r31 ^ out249;
r11 = r11 ^ out250;
r21 = r21 ^ out251;
r6 = r6 ^ out252;
unsigned long t379 = l27 ^ k21;
unsigned long t380 = l28 ^ k52;
unsigned long t381 = l29 ^ k49;
unsigned long t382 = l30 ^ k37;
unsigned long t383 = l31 ^ k43;
unsigned long t384 = l0 ^ k9;
unsigned long out253;
unsigned long out254;
unsigned long out255;
unsigned long out256;
s8(t379,t380,t381,t382,t383,t384, &out253,&out254,&out255,&out256);
r4 = r4 ^ out253;
r26 = r26 ^ out254;
r14 = r14 ^ out255;
r20 = r20 ^ out256;
unsigned long t385 = r31 ^ k6;
unsigned long t386 = r0 ^ k27;
unsigned long t387 = r1 ^ k10;
unsigned long t388 = r2 ^ k19;
unsigned long t389 = r3 ^ k54;
unsigned long t390 = r4 ^ k25;
unsigned long out257;
unsigned long out258;
unsigned long out259;
unsigned long out260;
s1(t385,t386,t387,t388,t389,t390, &out257,&out258,&out259,&out260);
l8 = l8 ^ out257;
l16 = l16 ^ out258;
l22 = l22 ^ out259;
l30 = l30 ^ out260;
unsigned long t391 = r3 ^ k11;
unsigned long t392 = r4 ^ k47;
unsigned long t393 = r5 ^ k13;
unsigned long t394 = r6 ^ k32;
unsigned long t395 = r7 ^ k55;
unsigned long t396 = r8 ^ k3;
unsigned long out261;
unsigned long out262;
unsigned long out263;
unsigned long out264;
s2(t391,t392,t393,t394,t395,t396, &out261,&out262,&out263,&out264);
l12 = l12 ^ out261;
l27 = l27 ^ out262;
l1 = l1 ^ out263;
l17 = l17 ^ out264;
unsigned long t397 = r7 ^ k12;
unsigned long t398 = r8 ^ k41;
unsigned long t399 = r9 ^ k17;
unsigned long t400 = r10 ^ k18;
unsigned long t401 = r11 ^ k33;
unsigned long t402 = r12 ^ k46;
unsigned long out265;
unsigned long out266;
unsigned long out267;
unsigned long out268;
s3(t397,t398,t399,t400,t401,t402, &out265,&out266,&out267,&out268);
l23 = l23 ^ out265;
l15 = l15 ^ out266;
l29 = l29 ^ out267;
l5 = l5 ^ out268;
unsigned long t403 = r11 ^ k20;
unsigned long t404 = r12 ^ k39;
unsigned long t405 = r13 ^ k40;
unsigned long t406 = r14 ^ k48;
unsigned long t407 = r15 ^ k24;
unsigned long t408 = r16 ^ k4;
unsigned long out269;
unsigned long out270;
unsigned long out271;
unsigned long out272;
s4(t403,t404,t405,t406,t407,t408, &out269,&out270,&out271,&out272);
l25 = l25 ^ out269;
l19 = l19 ^ out270;
l9 = l9 ^ out271;
l0 = l0 ^ out272;
unsigned long t409 = r15 ^ k52;
unsigned long t410 = r16 ^ k15;
unsigned long t411 = r17 ^ k9;
unsigned long t412 = r18 ^ k51;
unsigned long t413 = r19 ^ k35;
unsigned long t414 = r20 ^ k36;
unsigned long out273;
unsigned long out274;
unsigned long out275;
unsigned long out276;
s5(t409,t410,t411,t412,t413,t414, &out273,&out274,&out275,&out276);
l7 = l7 ^ out273;
l13 = l13 ^ out274;
l24 = l24 ^ out275;
l2 = l2 ^ out276;
unsigned long t415 = r19 ^ k2;
unsigned long t416 = r20 ^ k45;
unsigned long t417 = r21 ^ k8;
unsigned long t418 = r22 ^ k21;
unsigned long t419 = r23 ^ k23;
unsigned long t420 = r24 ^ k42;
unsigned long out277;
unsigned long out278;
unsigned long out279;
unsigned long out280;
s6(t415,t416,t417,t418,t419,t420, &out277,&out278,&out279,&out280);
l3 = l3 ^ out277;
l28 = l28 ^ out278;
l10 = l10 ^ out279;
l18 = l18 ^ out280;
unsigned long t421 = r23 ^ k14;
unsigned long t422 = r24 ^ k49;
unsigned long t423 = r25 ^ k38;
unsigned long t424 = r26 ^ k43;
unsigned long t425 = r27 ^ k30;
unsigned long t426 = r28 ^ k22;
unsigned long out281;
unsigned long out282;
unsigned long out283;
unsigned long out284;
s7(t421,t422,t423,t424,t425,t426, &out281,&out282,&out283,&out284);
l31 = l31 ^ out281;
l11 = l11 ^ out282;
l21 = l21 ^ out283;
l6 = l6 ^ out284;
unsigned long t427 = r27 ^ k28;
unsigned long t428 = r28 ^ k0;
unsigned long t429 = r29 ^ k1;
unsigned long t430 = r30 ^ k44;
unsigned long t431 = r31 ^ k50;
unsigned long t432 = r0 ^ k16;
unsigned long out285;
unsigned long out286;
unsigned long out287;
unsigned long out288;
s8(t427,t428,t429,t430,t431,t432, &out285,&out286,&out287,&out288);
l4 = l4 ^ out285;
l26 = l26 ^ out286;
l14 = l14 ^ out287;
l20 = l20 ^ out288;
unsigned long t433 = l31 ^ k20;
unsigned long t434 = l0 ^ k41;
unsigned long t435 = l1 ^ k24;
unsigned long t436 = l2 ^ k33;
unsigned long t437 = l3 ^ k11;
unsigned long t438 = l4 ^ k39;
unsigned long out289;
unsigned long out290;
unsigned long out291;
unsigned long out292;
s1(t433,t434,t435,t436,t437,t438, &out289,&out290,&out291,&out292);
r8 = r8 ^ out289;
r16 = r16 ^ out290;
r22 = r22 ^ out291;
r30 = r30 ^ out292;
unsigned long t439 = l3 ^ k25;
unsigned long t440 = l4 ^ k4;
unsigned long t441 = l5 ^ k27;
unsigned long t442 = l6 ^ k46;
unsigned long t443 = l7 ^ k12;
unsigned long t444 = l8 ^ k17;
unsigned long out293;
unsigned long out294;
unsigned long out295;
unsigned long out296;
s2(t439,t440,t441,t442,t443,t444, &out293,&out294,&out295,&out296);
r12 = r12 ^ out293;
r27 = r27 ^ out294;
r1 = r1 ^ out295;
r17 = r17 ^ out296;
unsigned long t445 = l7 ^ k26;
unsigned long t446 = l8 ^ k55;
unsigned long t447 = l9 ^ k6;
unsigned long t448 = l10 ^ k32;
unsigned long t449 = l11 ^ k47;
unsigned long t450 = l12 ^ k3;
unsigned long out297;
unsigned long out298;
unsigned long out299;
unsigned long out300;
s3(t445,t446,t447,t448,t449,t450, &out297,&out298,&out299,&out300);
r23 = r23 ^ out297;
r15 = r15 ^ out298;
r29 = r29 ^ out299;
r5 = r5 ^ out300;
unsigned long t451 = l11 ^ k34;
unsigned long t452 = l12 ^ k53;
unsigned long t453 = l13 ^ k54;
unsigned long t454 = l14 ^ k5;
unsigned long t455 = l15 ^ k13;
unsigned long t456 = l16 ^ k18;
unsigned long out301;
unsigned long out302;
unsigned long out303;
unsigned long out304;
s4(t451,t452,t453,t454,t455,t456, &out301,&out302,&out303,&out304);
r25 = r25 ^ out301;
r19 = r19 ^ out302;
r9 = r9 ^ out303;
r0 = r0 ^ out304;
unsigned long t457 = l15 ^ k7;
unsigned long t458 = l16 ^ k29;
unsigned long t459 = l17 ^ k23;
unsigned long t460 = l18 ^ k38;
unsigned long t461 = l19 ^ k49;
unsigned long t462 = l20 ^ k50;
unsigned long out305;
unsigned long out306;
unsigned long out307;
unsigned long out308;
s5(t457,t458,t459,t460,t461,t462, &out305,&out306,&out307,&out308);
r7 = r7 ^ out305;
r13 = r13 ^ out306;
r24 = r24 ^ out307;
r2 = r2 ^ out308;
unsigned long t463 = l19 ^ k16;
unsigned long t464 = l20 ^ k0;
unsigned long t465 = l21 ^ k22;
unsigned long t466 = l22 ^ k35;
unsigned long t467 = l23 ^ k37;
unsigned long t468 = l24 ^ k1;
unsigned long out309;
unsigned long out310;
unsigned long out311;
unsigned long out312;
s6(t463,t464,t465,t466,t467,t468, &out309,&out310,&out311,&out312);
r3 = r3 ^ out309;
r28 = r28 ^ out310;
r10 = r10 ^ out311;
r18 = r18 ^ out312;
unsigned long t469 = l23 ^ k28;
unsigned long t470 = l24 ^ k8;
unsigned long t471 = l25 ^ k52;
unsigned long t472 = l26 ^ k2;
unsigned long t473 = l27 ^ k44;
unsigned long t474 = l28 ^ k36;
unsigned long out313;
unsigned long out314;
unsigned long out315;
unsigned long out316;
s7(t469,t470,t471,t472,t473,t474, &out313,&out314,&out315,&out316);
r31 = r31 ^ out313;
r11 = r11 ^ out314;
r21 = r21 ^ out315;
r6 = r6 ^ out316;
unsigned long t475 = l27 ^ k42;
unsigned long t476 = l28 ^ k14;
unsigned long t477 = l29 ^ k15;
unsigned long t478 = l30 ^ k31;
unsigned long t479 = l31 ^ k9;
unsigned long t480 = l0 ^ k30;
unsigned long out317;
unsigned long out318;
unsigned long out319;
unsigned long out320;
s8(t475,t476,t477,t478,t479,t480, &out317,&out318,&out319,&out320);
r4 = r4 ^ out317;
r26 = r26 ^ out318;
r14 = r14 ^ out319;
r20 = r20 ^ out320;
unsigned long t481 = r31 ^ k34;
unsigned long t482 = r0 ^ k55;
unsigned long t483 = r1 ^ k13;
unsigned long t484 = r2 ^ k47;
unsigned long t485 = r3 ^ k25;
unsigned long t486 = r4 ^ k53;
unsigned long out321;
unsigned long out322;
unsigned long out323;
unsigned long out324;
s1(t481,t482,t483,t484,t485,t486, &out321,&out322,&out323,&out324);
l8 = l8 ^ out321;
l16 = l16 ^ out322;
l22 = l22 ^ out323;
l30 = l30 ^ out324;
unsigned long t487 = r3 ^ k39;
unsigned long t488 = r4 ^ k18;
unsigned long t489 = r5 ^ k41;
unsigned long t490 = r6 ^ k3;
unsigned long t491 = r7 ^ k26;
unsigned long t492 = r8 ^ k6;
unsigned long out325;
unsigned long out326;
unsigned long out327;
unsigned long out328;
s2(t487,t488,t489,t490,t491,t492, &out325,&out326,&out327,&out328);
l12 = l12 ^ out325;
l27 = l27 ^ out326;
l1 = l1 ^ out327;
l17 = l17 ^ out328;
unsigned long t493 = r7 ^ k40;
unsigned long t494 = r8 ^ k12;
unsigned long t495 = r9 ^ k20;
unsigned long t496 = r10 ^ k46;
unsigned long t497 = r11 ^ k4;
unsigned long t498 = r12 ^ k17;
unsigned long out329;
unsigned long out330;
unsigned long out331;
unsigned long out332;
s3(t493,t494,t495,t496,t497,t498, &out329,&out330,&out331,&out332);
l23 = l23 ^ out329;
l15 = l15 ^ out330;
l29 = l29 ^ out331;
l5 = l5 ^ out332;
unsigned long t499 = r11 ^ k48;
unsigned long t500 = r12 ^ k10;
unsigned long t501 = r13 ^ k11;
unsigned long t502 = r14 ^ k19;
unsigned long t503 = r15 ^ k27;
unsigned long t504 = r16 ^ k32;
unsigned long out333;
unsigned long out334;
unsigned long out335;
unsigned long out336;
s4(t499,t500,t501,t502,t503,t504, &out333,&out334,&out335,&out336);
l25 = l25 ^ out333;
l19 = l19 ^ out334;
l9 = l9 ^ out335;
l0 = l0 ^ out336;
unsigned long t505 = r15 ^ k21;
unsigned long t506 = r16 ^ k43;
unsigned long t507 = r17 ^ k37;
unsigned long t508 = r18 ^ k52;
unsigned long t509 = r19 ^ k8;
unsigned long t510 = r20 ^ k9;
unsigned long out337;
unsigned long out338;
unsigned long out339;
unsigned long out340;
s5(t505,t506,t507,t508,t509,t510, &out337,&out338,&out339,&out340);
l7 = l7 ^ out337;
l13 = l13 ^ out338;
l24 = l24 ^ out339;
l2 = l2 ^ out340;
unsigned long t511 = r19 ^ k30;
unsigned long t512 = r20 ^ k14;
unsigned long t513 = r21 ^ k36;
unsigned long t514 = r22 ^ k49;
unsigned long t515 = r23 ^ k51;
unsigned long t516 = r24 ^ k15;
unsigned long out341;
unsigned long out342;
unsigned long out343;
unsigned long out344;
s6(t511,t512,t513,t514,t515,t516, &out341,&out342,&out343,&out344);
l3 = l3 ^ out341;
l28 = l28 ^ out342;
l10 = l10 ^ out343;
l18 = l18 ^ out344;
unsigned long t517 = r23 ^ k42;
unsigned long t518 = r24 ^ k22;
unsigned long t519 = r25 ^ k7;
unsigned long t520 = r26 ^ k16;
unsigned long t521 = r27 ^ k31;
unsigned long t522 = r28 ^ k50;
unsigned long out345;
unsigned long out346;
unsigned long out347;
unsigned long out348;
s7(t517,t518,t519,t520,t521,t522, &out345,&out346,&out347,&out348);
l31 = l31 ^ out345;
l11 = l11 ^ out346;
l21 = l21 ^ out347;
l6 = l6 ^ out348;
unsigned long t523 = r27 ^ k1;
unsigned long t524 = r28 ^ k28;
unsigned long t525 = r29 ^ k29;
unsigned long t526 = r30 ^ k45;
unsigned long t527 = r31 ^ k23;
unsigned long t528 = r0 ^ k44;
unsigned long out349;
unsigned long out350;
unsigned long out351;
unsigned long out352;
s8(t523,t524,t525,t526,t527,t528, &out349,&out350,&out351,&out352);
l4 = l4 ^ out349;
l26 = l26 ^ out350;
l14 = l14 ^ out351;
l20 = l20 ^ out352;
unsigned long t529 = l31 ^ k48;
unsigned long t530 = l0 ^ k12;
unsigned long t531 = l1 ^ k27;
unsigned long t532 = l2 ^ k4;
unsigned long t533 = l3 ^ k39;
unsigned long t534 = l4 ^ k10;
unsigned long out353;
unsigned long out354;
unsigned long out355;
unsigned long out356;
s1(t529,t530,t531,t532,t533,t534, &out353,&out354,&out355,&out356);
r8 = r8 ^ out353;
r16 = r16 ^ out354;
r22 = r22 ^ out355;
r30 = r30 ^ out356;
unsigned long t535 = l3 ^ k53;
unsigned long t536 = l4 ^ k32;
unsigned long t537 = l5 ^ k55;
unsigned long t538 = l6 ^ k17;
unsigned long t539 = l7 ^ k40;
unsigned long t540 = l8 ^ k20;
unsigned long out357;
unsigned long out358;
unsigned long out359;
unsigned long out360;
s2(t535,t536,t537,t538,t539,t540, &out357,&out358,&out359,&out360);
r12 = r12 ^ out357;
r27 = r27 ^ out358;
r1 = r1 ^ out359;
r17 = r17 ^ out360;
unsigned long t541 = l7 ^ k54;
unsigned long t542 = l8 ^ k26;
unsigned long t543 = l9 ^ k34;
unsigned long t544 = l10 ^ k3;
unsigned long t545 = l11 ^ k18;
unsigned long t546 = l12 ^ k6;
unsigned long out361;
unsigned long out362;
unsigned long out363;
unsigned long out364;
s3(t541,t542,t543,t544,t545,t546, &out361,&out362,&out363,&out364);
r23 = r23 ^ out361;
r15 = r15 ^ out362;
r29 = r29 ^ out363;
r5 = r5 ^ out364;
unsigned long t547 = l11 ^ k5;
unsigned long t548 = l12 ^ k24;
unsigned long t549 = l13 ^ k25;
unsigned long t550 = l14 ^ k33;
unsigned long t551 = l15 ^ k41;
unsigned long t552 = l16 ^ k46;
unsigned long out365;
unsigned long out366;
unsigned long out367;
unsigned long out368;
s4(t547,t548,t549,t550,t551,t552, &out365,&out366,&out367,&out368);
r25 = r25 ^ out365;
r19 = r19 ^ out366;
r9 = r9 ^ out367;
r0 = r0 ^ out368;
unsigned long t553 = l15 ^ k35;
unsigned long t554 = l16 ^ k2;
unsigned long t555 = l17 ^ k51;
unsigned long t556 = l18 ^ k7;
unsigned long t557 = l19 ^ k22;
unsigned long t558 = l20 ^ k23;
unsigned long out369;
unsigned long out370;
unsigned long out371;
unsigned long out372;
s5(t553,t554,t555,t556,t557,t558, &out369,&out370,&out371,&out372);
r7 = r7 ^ out369;
r13 = r13 ^ out370;
r24 = r24 ^ out371;
r2 = r2 ^ out372;
unsigned long t559 = l19 ^ k44;
unsigned long t560 = l20 ^ k28;
unsigned long t561 = l21 ^ k50;
unsigned long t562 = l22 ^ k8;
unsigned long t563 = l23 ^ k38;
unsigned long t564 = l24 ^ k29;
unsigned long out373;
unsigned long out374;
unsigned long out375;
unsigned long out376;
s6(t559,t560,t561,t562,t563,t564, &out373,&out374,&out375,&out376);
r3 = r3 ^ out373;
r28 = r28 ^ out374;
r10 = r10 ^ out375;
r18 = r18 ^ out376;
unsigned long t565 = l23 ^ k1;
unsigned long t566 = l24 ^ k36;
unsigned long t567 = l25 ^ k21;
unsigned long t568 = l26 ^ k30;
unsigned long t569 = l27 ^ k45;
unsigned long t570 = l28 ^ k9;
unsigned long out377;
unsigned long out378;
unsigned long out379;
unsigned long out380;
s7(t565,t566,t567,t568,t569,t570, &out377,&out378,&out379,&out380);
r31 = r31 ^ out377;
r11 = r11 ^ out378;
r21 = r21 ^ out379;
r6 = r6 ^ out380;
unsigned long t571 = l27 ^ k15;
unsigned long t572 = l28 ^ k42;
unsigned long t573 = l29 ^ k43;
unsigned long t574 = l30 ^ k0;
unsigned long t575 = l31 ^ k37;
unsigned long t576 = l0 ^ k31;
unsigned long out381;
unsigned long out382;
unsigned long out383;
unsigned long out384;
s8(t571,t572,t573,t574,t575,t576, &out381,&out382,&out383,&out384);
r4 = r4 ^ out381;
r26 = r26 ^ out382;
r14 = r14 ^ out383;
r20 = r20 ^ out384;
unsigned long t577 = r31 ^ k5;
unsigned long t578 = r0 ^ k26;
unsigned long t579 = r1 ^ k41;
unsigned long t580 = r2 ^ k18;
unsigned long t581 = r3 ^ k53;
unsigned long t582 = r4 ^ k24;
unsigned long out385;
unsigned long out386;
unsigned long out387;
unsigned long out388;
s1(t577,t578,t579,t580,t581,t582, &out385,&out386,&out387,&out388);
l8 = l8 ^ out385;
l16 = l16 ^ out386;
l22 = l22 ^ out387;
l30 = l30 ^ out388;
unsigned long t583 = r3 ^ k10;
unsigned long t584 = r4 ^ k46;
unsigned long t585 = r5 ^ k12;
unsigned long t586 = r6 ^ k6;
unsigned long t587 = r7 ^ k54;
unsigned long t588 = r8 ^ k34;
unsigned long out389;
unsigned long out390;
unsigned long out391;
unsigned long out392;
s2(t583,t584,t585,t586,t587,t588, &out389,&out390,&out391,&out392);
l12 = l12 ^ out389;
l27 = l27 ^ out390;
l1 = l1 ^ out391;
l17 = l17 ^ out392;
unsigned long t589 = r7 ^ k11;
unsigned long t590 = r8 ^ k40;
unsigned long t591 = r9 ^ k48;
unsigned long t592 = r10 ^ k17;
unsigned long t593 = r11 ^ k32;
unsigned long t594 = r12 ^ k20;
unsigned long out393;
unsigned long out394;
unsigned long out395;
unsigned long out396;
s3(t589,t590,t591,t592,t593,t594, &out393,&out394,&out395,&out396);
l23 = l23 ^ out393;
l15 = l15 ^ out394;
l29 = l29 ^ out395;
l5 = l5 ^ out396;
unsigned long t595 = r11 ^ k19;
unsigned long t596 = r12 ^ k13;
unsigned long t597 = r13 ^ k39;
unsigned long t598 = r14 ^ k47;
unsigned long t599 = r15 ^ k55;
unsigned long t600 = r16 ^ k3;
unsigned long out397;
unsigned long out398;
unsigned long out399;
unsigned long out400;
s4(t595,t596,t597,t598,t599,t600, &out397,&out398,&out399,&out400);
l25 = l25 ^ out397;
l19 = l19 ^ out398;
l9 = l9 ^ out399;
l0 = l0 ^ out400;
unsigned long t601 = r15 ^ k49;
unsigned long t602 = r16 ^ k16;
unsigned long t603 = r17 ^ k38;
unsigned long t604 = r18 ^ k21;
unsigned long t605 = r19 ^ k36;
unsigned long t606 = r20 ^ k37;
unsigned long out401;
unsigned long out402;
unsigned long out403;
unsigned long out404;
s5(t601,t602,t603,t604,t605,t606, &out401,&out402,&out403,&out404);
l7 = l7 ^ out401;
l13 = l13 ^ out402;
l24 = l24 ^ out403;
l2 = l2 ^ out404;
unsigned long t607 = r19 ^ k31;
unsigned long t608 = r20 ^ k42;
unsigned long t609 = r21 ^ k9;
unsigned long t610 = r22 ^ k22;
unsigned long t611 = r23 ^ k52;
unsigned long t612 = r24 ^ k43;
unsigned long out405;
unsigned long out406;
unsigned long out407;
unsigned long out408;
s6(t607,t608,t609,t610,t611,t612, &out405,&out406,&out407,&out408);
l3 = l3 ^ out405;
l28 = l28 ^ out406;
l10 = l10 ^ out407;
l18 = l18 ^ out408;
unsigned long t613 = r23 ^ k15;
unsigned long t614 = r24 ^ k50;
unsigned long t615 = r25 ^ k35;
unsigned long t616 = r26 ^ k44;
unsigned long t617 = r27 ^ k0;
unsigned long t618 = r28 ^ k23;
unsigned long out409;
unsigned long out410;
unsigned long out411;
unsigned long out412;
s7(t613,t614,t615,t616,t617,t618, &out409,&out410,&out411,&out412);
l31 = l31 ^ out409;
l11 = l11 ^ out410;
l21 = l21 ^ out411;
l6 = l6 ^ out412;
unsigned long t619 = r27 ^ k29;
unsigned long t620 = r28 ^ k1;
unsigned long t621 = r29 ^ k2;
unsigned long t622 = r30 ^ k14;
unsigned long t623 = r31 ^ k51;
unsigned long t624 = r0 ^ k45;
unsigned long out413;
unsigned long out414;
unsigned long out415;
unsigned long out416;
s8(t619,t620,t621,t622,t623,t624, &out413,&out414,&out415,&out416);
l4 = l4 ^ out413;
l26 = l26 ^ out414;
l14 = l14 ^ out415;
l20 = l20 ^ out416;
unsigned long t625 = l31 ^ k19;
unsigned long t626 = l0 ^ k40;
unsigned long t627 = l1 ^ k55;
unsigned long t628 = l2 ^ k32;
unsigned long t629 = l3 ^ k10;
unsigned long t630 = l4 ^ k13;
unsigned long out417;
unsigned long out418;
unsigned long out419;
unsigned long out420;
s1(t625,t626,t627,t628,t629,t630, &out417,&out418,&out419,&out420);
r8 = r8 ^ out417;
r16 = r16 ^ out418;
r22 = r22 ^ out419;
r30 = r30 ^ out420;
unsigned long t631 = l3 ^ k24;
unsigned long t632 = l4 ^ k3;
unsigned long t633 = l5 ^ k26;
unsigned long t634 = l6 ^ k20;
unsigned long t635 = l7 ^ k11;
unsigned long t636 = l8 ^ k48;
unsigned long out421;
unsigned long out422;
unsigned long out423;
unsigned long out424;
s2(t631,t632,t633,t634,t635,t636, &out421,&out422,&out423,&out424);
r12 = r12 ^ out421;
r27 = r27 ^ out422;
r1 = r1 ^ out423;
r17 = r17 ^ out424;
unsigned long t637 = l7 ^ k25;
unsigned long t638 = l8 ^ k54;
unsigned long t639 = l9 ^ k5;
unsigned long t640 = l10 ^ k6;
unsigned long t641 = l11 ^ k46;
unsigned long t642 = l12 ^ k34;
unsigned long out425;
unsigned long out426;
unsigned long out427;
unsigned long out428;
s3(t637,t638,t639,t640,t641,t642, &out425,&out426,&out427,&out428);
r23 = r23 ^ out425;
r15 = r15 ^ out426;
r29 = r29 ^ out427;
r5 = r5 ^ out428;
unsigned long t643 = l11 ^ k33;
unsigned long t644 = l12 ^ k27;
unsigned long t645 = l13 ^ k53;
unsigned long t646 = l14 ^ k4;
unsigned long t647 = l15 ^ k12;
unsigned long t648 = l16 ^ k17;
unsigned long out429;
unsigned long out430;
unsigned long out431;
unsigned long out432;
s4(t643,t644,t645,t646,t647,t648, &out429,&out430,&out431,&out432);
r25 = r25 ^ out429;
r19 = r19 ^ out430;
r9 = r9 ^ out431;
r0 = r0 ^ out432;
unsigned long t649 = l15 ^ k8;
unsigned long t650 = l16 ^ k30;
unsigned long t651 = l17 ^ k52;
unsigned long t652 = l18 ^ k35;
unsigned long t653 = l19 ^ k50;
unsigned long t654 = l20 ^ k51;
unsigned long out433;
unsigned long out434;
unsigned long out435;
unsigned long out436;
s5(t649,t650,t651,t652,t653,t654, &out433,&out434,&out435,&out436);
r7 = r7 ^ out433;
r13 = r13 ^ out434;
r24 = r24 ^ out435;
r2 = r2 ^ out436;
unsigned long t655 = l19 ^ k45;
unsigned long t656 = l20 ^ k1;
unsigned long t657 = l21 ^ k23;
unsigned long t658 = l22 ^ k36;
unsigned long t659 = l23 ^ k7;
unsigned long t660 = l24 ^ k2;
unsigned long out437;
unsigned long out438;
unsigned long out439;
unsigned long out440;
s6(t655,t656,t657,t658,t659,t660, &out437,&out438,&out439,&out440);
r3 = r3 ^ out437;
r28 = r28 ^ out438;
r10 = r10 ^ out439;
r18 = r18 ^ out440;
unsigned long t661 = l23 ^ k29;
unsigned long t662 = l24 ^ k9;
unsigned long t663 = l25 ^ k49;
unsigned long t664 = l26 ^ k31;
unsigned long t665 = l27 ^ k14;
unsigned long t666 = l28 ^ k37;
unsigned long out441;
unsigned long out442;
unsigned long out443;
unsigned long out444;
s7(t661,t662,t663,t664,t665,t666, &out441,&out442,&out443,&out444);
r31 = r31 ^ out441;
r11 = r11 ^ out442;
r21 = r21 ^ out443;
r6 = r6 ^ out444;
unsigned long t667 = l27 ^ k43;
unsigned long t668 = l28 ^ k15;
unsigned long t669 = l29 ^ k16;
unsigned long t670 = l30 ^ k28;
unsigned long t671 = l31 ^ k38;
unsigned long t672 = l0 ^ k0;
unsigned long out445;
unsigned long out446;
unsigned long out447;
unsigned long out448;
s8(t667,t668,t669,t670,t671,t672, &out445,&out446,&out447,&out448);
r4 = r4 ^ out445;
r26 = r26 ^ out446;
r14 = r14 ^ out447;
r20 = r20 ^ out448;
unsigned long t673 = r31 ^ k33;
unsigned long t674 = r0 ^ k54;
unsigned long t675 = r1 ^ k12;
unsigned long t676 = r2 ^ k46;
unsigned long t677 = r3 ^ k24;
unsigned long t678 = r4 ^ k27;
unsigned long out449;
unsigned long out450;
unsigned long out451;
unsigned long out452;
s1(t673,t674,t675,t676,t677,t678, &out449,&out450,&out451,&out452);
l8 = l8 ^ out449;
l16 = l16 ^ out450;
l22 = l22 ^ out451;
l30 = l30 ^ out452;
unsigned long t679 = r3 ^ k13;
unsigned long t680 = r4 ^ k17;
unsigned long t681 = r5 ^ k40;
unsigned long t682 = r6 ^ k34;
unsigned long t683 = r7 ^ k25;
unsigned long t684 = r8 ^ k5;
unsigned long out453;
unsigned long out454;
unsigned long out455;
unsigned long out456;
s2(t679,t680,t681,t682,t683,t684, &out453,&out454,&out455,&out456);
l12 = l12 ^ out453;
l27 = l27 ^ out454;
l1 = l1 ^ out455;
l17 = l17 ^ out456;
unsigned long t685 = r7 ^ k39;
unsigned long t686 = r8 ^ k11;
unsigned long t687 = r9 ^ k19;
unsigned long t688 = r10 ^ k20;
unsigned long t689 = r11 ^ k3;
unsigned long t690 = r12 ^ k48;
unsigned long out457;
unsigned long out458;
unsigned long out459;
unsigned long out460;
s3(t685,t686,t687,t688,t689,t690, &out457,&out458,&out459,&out460);
l23 = l23 ^ out457;
l15 = l15 ^ out458;
l29 = l29 ^ out459;
l5 = l5 ^ out460;
unsigned long t691 = r11 ^ k47;
unsigned long t692 = r12 ^ k41;
unsigned long t693 = r13 ^ k10;
unsigned long t694 = r14 ^ k18;
unsigned long t695 = r15 ^ k26;
unsigned long t696 = r16 ^ k6;
unsigned long out461;
unsigned long out462;
unsigned long out463;
unsigned long out464;
s4(t691,t692,t693,t694,t695,t696, &out461,&out462,&out463,&out464);
l25 = l25 ^ out461;
l19 = l19 ^ out462;
l9 = l9 ^ out463;
l0 = l0 ^ out464;
unsigned long t697 = r15 ^ k22;
unsigned long t698 = r16 ^ k44;
unsigned long t699 = r17 ^ k7;
unsigned long t700 = r18 ^ k49;
unsigned long t701 = r19 ^ k9;
unsigned long t702 = r20 ^ k38;
unsigned long out465;
unsigned long out466;
unsigned long out467;
unsigned long out468;
s5(t697,t698,t699,t700,t701,t702, &out465,&out466,&out467,&out468);
l7 = l7 ^ out465;
l13 = l13 ^ out466;
l24 = l24 ^ out467;
l2 = l2 ^ out468;
unsigned long t703 = r19 ^ k0;
unsigned long t704 = r20 ^ k15;
unsigned long t705 = r21 ^ k37;
unsigned long t706 = r22 ^ k50;
unsigned long t707 = r23 ^ k21;
unsigned long t708 = r24 ^ k16;
unsigned long out469;
unsigned long out470;
unsigned long out471;
unsigned long out472;
s6(t703,t704,t705,t706,t707,t708, &out469,&out470,&out471,&out472);
l3 = l3 ^ out469;
l28 = l28 ^ out470;
l10 = l10 ^ out471;
l18 = l18 ^ out472;
unsigned long t709 = r23 ^ k43;
unsigned long t710 = r24 ^ k23;
unsigned long t711 = r25 ^ k8;
unsigned long t712 = r26 ^ k45;
unsigned long t713 = r27 ^ k28;
unsigned long t714 = r28 ^ k51;
unsigned long out473;
unsigned long out474;
unsigned long out475;
unsigned long out476;
s7(t709,t710,t711,t712,t713,t714, &out473,&out474,&out475,&out476);
l31 = l31 ^ out473;
l11 = l11 ^ out474;
l21 = l21 ^ out475;
l6 = l6 ^ out476;
unsigned long t715 = r27 ^ k2;
unsigned long t716 = r28 ^ k29;
unsigned long t717 = r29 ^ k30;
unsigned long t718 = r30 ^ k42;
unsigned long t719 = r31 ^ k52;
unsigned long t720 = r0 ^ k14;
unsigned long out477;
unsigned long out478;
unsigned long out479;
unsigned long out480;
s8(t715,t716,t717,t718,t719,t720, &out477,&out478,&out479,&out480);
l4 = l4 ^ out477;
l26 = l26 ^ out478;
l14 = l14 ^ out479;
l20 = l20 ^ out480;
unsigned long t721 = l31 ^ k40;
unsigned long t722 = l0 ^ k4;
unsigned long t723 = l1 ^ k19;
unsigned long t724 = l2 ^ k53;
unsigned long t725 = l3 ^ k6;
unsigned long t726 = l4 ^ k34;
unsigned long out481;
unsigned long out482;
unsigned long out483;
unsigned long out484;
s1(t721,t722,t723,t724,t725,t726, &out481,&out482,&out483,&out484);
r8 = r8 ^ out481;
r16 = r16 ^ out482;
r22 = r22 ^ out483;
r30 = r30 ^ out484;
unsigned long t727 = l3 ^ k20;
unsigned long t728 = l4 ^ k24;
unsigned long t729 = l5 ^ k47;
unsigned long t730 = l6 ^ k41;
unsigned long t731 = l7 ^ k32;
unsigned long t732 = l8 ^ k12;
unsigned long out485;
unsigned long out486;
unsigned long out487;
unsigned long out488;
s2(t727,t728,t729,t730,t731,t732, &out485,&out486,&out487,&out488);
r12 = r12 ^ out485;
r27 = r27 ^ out486;
r1 = r1 ^ out487;
r17 = r17 ^ out488;
unsigned long t733 = l7 ^ k46;
unsigned long t734 = l8 ^ k18;
unsigned long t735 = l9 ^ k26;
unsigned long t736 = l10 ^ k27;
unsigned long t737 = l11 ^ k10;
unsigned long t738 = l12 ^ k55;
unsigned long out489;
unsigned long out490;
unsigned long out491;
unsigned long out492;
s3(t733,t734,t735,t736,t737,t738, &out489,&out490,&out491,&out492);
r23 = r23 ^ out489;
r15 = r15 ^ out490;
r29 = r29 ^ out491;
r5 = r5 ^ out492;
unsigned long t739 = l11 ^ k54;
unsigned long t740 = l12 ^ k48;
unsigned long t741 = l13 ^ k17;
unsigned long t742 = l14 ^ k25;
unsigned long t743 = l15 ^ k33;
unsigned long t744 = l16 ^ k13;
unsigned long out493;
unsigned long out494;
unsigned long out495;
unsigned long out496;
s4(t739,t740,t741,t742,t743,t744, &out493,&out494,&out495,&out496);
r25 = r25 ^ out493;
r19 = r19 ^ out494;
r9 = r9 ^ out495;
r0 = r0 ^ out496;
unsigned long t745 = l15 ^ k29;
unsigned long t746 = l16 ^ k51;
unsigned long t747 = l17 ^ k14;
unsigned long t748 = l18 ^ k1;
unsigned long t749 = l19 ^ k16;
unsigned long t750 = l20 ^ k45;
unsigned long out497;
unsigned long out498;
unsigned long out499;
unsigned long out500;
s5(t745,t746,t747,t748,t749,t750, &out497,&out498,&out499,&out500);
r7 = r7 ^ out497;
r13 = r13 ^ out498;
r24 = r24 ^ out499;
r2 = r2 ^ out500;
unsigned long t751 = l19 ^ k7;
unsigned long t752 = l20 ^ k22;
unsigned long t753 = l21 ^ k44;
unsigned long t754 = l22 ^ k2;
unsigned long t755 = l23 ^ k28;
unsigned long t756 = l24 ^ k23;
unsigned long out501;
unsigned long out502;
unsigned long out503;
unsigned long out504;
s6(t751,t752,t753,t754,t755,t756, &out501,&out502,&out503,&out504);
r3 = r3 ^ out501;
r28 = r28 ^ out502;
r10 = r10 ^ out503;
r18 = r18 ^ out504;
unsigned long t757 = l23 ^ k50;
unsigned long t758 = l24 ^ k30;
unsigned long t759 = l25 ^ k15;
unsigned long t760 = l26 ^ k52;
unsigned long t761 = l27 ^ k35;
unsigned long t762 = l28 ^ k31;
unsigned long out505;
unsigned long out506;
unsigned long out507;
unsigned long out508;
s7(t757,t758,t759,t760,t761,t762, &out505,&out506,&out507,&out508);
r31 = r31 ^ out505;
r11 = r11 ^ out506;
r21 = r21 ^ out507;
r6 = r6 ^ out508;
unsigned long t763 = l27 ^ k9;
unsigned long t764 = l28 ^ k36;
unsigned long t765 = l29 ^ k37;
unsigned long t766 = l30 ^ k49;
unsigned long t767 = l31 ^ k0;
unsigned long t768 = l0 ^ k21;
unsigned long out509;
unsigned long out510;
unsigned long out511;
unsigned long out512;
s8(t763,t764,t765,t766,t767,t768, &out509,&out510,&out511,&out512);
r4 = r4 ^ out509;
r26 = r26 ^ out510;
r14 = r14 ^ out511;
r20 = r20 ^ out512;
c[5] = l8;
c[3] = l16;
c[51] = l22;
c[49] = l30;
c[37] = l12;
c[25] = l27;
c[15] = l1;
c[11] = l17;
c[59] = l23;
c[61] = l15;
c[41] = l29;
c[47] = l5;
c[9] = l25;
c[27] = l19;
c[13] = l9;
c[7] = l0;
c[63] = l7;
c[45] = l13;
c[1] = l24;
c[23] = l2;
c[31] = l3;
c[33] = l28;
c[21] = l10;
c[19] = l18;
c[57] = l31;
c[29] = l11;
c[43] = l21;
c[55] = l6;
c[39] = l4;
c[17] = l26;
c[53] = l14;
c[35] = l20;
c[4] = r8;
c[2] = r16;
c[50] = r22;
c[48] = r30;
c[36] = r12;
c[24] = r27;
c[14] = r1;
c[10] = r17;
c[58] = r23;
c[60] = r15;
c[40] = r29;
c[46] = r5;
c[8] = r25;
c[26] = r19;
c[12] = r9;
c[6] = r0;
c[62] = r7;
c[44] = r13;
c[0] = r24;
c[22] = r2;
c[30] = r3;
c[32] = r28;
c[20] = r10;
c[18] = r18;
c[56] = r31;
c[28] = r11;
c[42] = r21;
c[54] = r6;
c[38] = r4;
c[16] = r26;
c[52] = r14;
c[34] = r20;
}
| 27.13516 | 271 | 0.591207 |
159c69304b8423b52010c97b252ff7095f13641c | 1,884 | h | C | tools/BC5/INCLUDE/generic.h | binary-manu/rpm | 0ae38a115bf53cf9bdb962031011f7a6627c0215 | [
"MIT"
] | null | null | null | tools/BC5/INCLUDE/generic.h | binary-manu/rpm | 0ae38a115bf53cf9bdb962031011f7a6627c0215 | [
"MIT"
] | 1 | 2020-07-10T17:11:34.000Z | 2020-07-23T17:46:24.000Z | tools/BC5/INCLUDE/generic.h | binary-manu/rpm | 0ae38a115bf53cf9bdb962031011f7a6627c0215 | [
"MIT"
] | null | null | null | /* generic.h -- for faking generic class declarations
When type templates are implemented in C++, this will probably go away.
*/
/*
* C/C++ Run Time Library - Version 8.0
*
* Copyright (c) 1990, 1997 by Borland International
* All Rights Reserved.
*
*/
/* $Revision: 8.1 $ */
#ifndef __cplusplus
#error Must use C++ for classes
#endif
#ifndef __GENERIC_H
#define __GENERIC_H
#if !defined(___DEFS_H)
#include <_defs.h>
#endif
#if !defined(RC_INVOKED)
#if defined(__STDC__)
#pragma warn -nak
#endif
#endif
// token-pasting macros; ANSI requires an extra level of indirection
#define _Paste2(z, y) _Paste2_x(z, y)
#define _Paste2_x(z, y) z##y
#define _Paste3(z, y, x) _Paste3_x(z, y, x)
#define _Paste3_x(z, y, x) z##y##x
#define _Paste4(z, y, x, w) _Paste4_x(z, y, x, w)
#define _Paste4_x(z, y, x, w) z##y##x##w
// macros for declaring and implementing classes
#define name2 _Paste2
#define declare(z, y) _Paste2(z, declare)(y)
#define implement(z, y) _Paste2(z, implement)(y)
#define declare2(z, y, x) _Paste2(z, declare2)(y, x)
#define implement2(z, y, x) _Paste2(z, implement2)(y, x)
// macros for declaring error-handling functions
extern _RTLENTRY genericerror(int, char _FAR *); // not implemented ***
typedef int _RTLENTRY (_FAR *GPT)(int, char _FAR *);
#define set_handler(gen, tp, z) _Paste4(set_, tp, gen, _handler)(z)
#define errorhandler(gen, tp) _Paste3(tp, gen, handler)
#define callerror(gen, tp, z, y) (*errorhandler(gen, tp))(z, y)
/*
* function genericerror is not documented in the AT&T release, and
* is not supplied. If you can document any expected behavior, we
* will try to adjust our implementation accordingly.
*/
#if !defined(RC_INVOKED)
#if defined(__STDC__)
#pragma warn .nak
#endif
#endif
#endif /* __GENERIC_H */
| 26.166667 | 76 | 0.660297 |
63be4c33db8fcafcd05fea1c38174568dc4d64b4 | 1,464 | c | C | d/tharis/caverns/cavern24.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-07-19T05:24:44.000Z | 2021-11-18T04:08:19.000Z | d/tharis/caverns/cavern24.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 4 | 2021-03-15T18:56:39.000Z | 2021-08-17T17:08:22.000Z | d/tharis/caverns/cavern24.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-09-12T06:22:38.000Z | 2022-01-31T01:15:12.000Z | #include <std.h>
inherit ROOM;
void create(){
::create();
set_name("Tharis caverns");
set_short("A dark cavern");
set_long(
"You have entered a dark dreary cave. The ceiling hangs very low, "+
"you have to hunch over to avoid hitting your head. This room has "+
"an overabundance of bugs. Spiders, centipedes, beetles, and other "+
"various insects covers the floor and walls. With the dim lighting it "+
"almost seems as if the cave itself lives."
);
set_property("light",2);
set_property("indoors",1);
set_property("no teleport",1);
set_smell("default","The smell of decaying flesh drifts through the cavern.");
set_listen("default","Squirming insects can be heard from all over the cave.");
set_exits( ([
"west":"/d/tharis/caverns/cavern21",
"north":"/d/tharis/caverns/cavern25"
]) );
}
void init(){
::init();
add_action("bugs","look");
}
int bugs(string str){
if(!str || str !="at bugs") return 0;
tell_object(TP,"You bend over to take a close look at the insects and they swarm onto your body!");
TP->do_damage("torso",roll_dice(2,10));
tell_room(environment(TP),""+TP->query_cap_name()+" bends over to look at the insects and they swarm onto "+TP->query_possessive()+" body!",TP);
tell_object(TP,"You quickly beat them off of you!");
tell_room(environment(TP),""+TP->query_cap_name()+" quickly beats the insects off of "+TP->query_possessive()+" body!",TP);
return 1;
}
| 39.567568 | 148 | 0.67418 |
63d1fe64f61a7329fd69165eb166e5b95ae729c3 | 836 | h | C | Frameworks/ContactsFoundation.framework/Headers/CNLaunchServicesAdapter.h | CarlAmbroselli/barcelona | 9bd087575935485a4c26674c2414d7ef20d7e168 | [
"Apache-2.0"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | Frameworks/ContactsFoundation.framework/Headers/CNLaunchServicesAdapter.h | CarlAmbroselli/barcelona | 9bd087575935485a4c26674c2414d7ef20d7e168 | [
"Apache-2.0"
] | 20 | 2021-09-03T13:38:34.000Z | 2022-03-17T13:24:39.000Z | Frameworks/ContactsFoundation.framework/Headers/CNLaunchServicesAdapter.h | CarlAmbroselli/barcelona | 9bd087575935485a4c26674c2414d7ef20d7e168 | [
"Apache-2.0"
] | 2 | 2022-02-13T08:35:11.000Z | 2022-03-17T01:56:47.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
@class CNApplicationProxy, NSData, NSDictionary, NSString, NSURL;
@protocol CNLaunchServicesAdapter
- (void)openSensitiveURLInBackground:(NSURL *)arg1 withOptions:(NSDictionary *)arg2 withReply:(void (^)(BOOL, NSError *))arg3;
- (void)openUserActivityData:(NSData *)arg1 inApplication:(CNApplicationProxy *)arg2 withReply:(void (^)(BOOL, NSError *))arg3;
- (void)applicationForBundleIdentifier:(NSString *)arg1 withReply:(void (^)(CNApplicationProxy *, NSError *))arg2;
- (void)applicationsAvailableForHandlingURLScheme:(NSString *)arg1 withReply:(void (^)(NSArray *, NSError *))arg2;
- (void)applicationsForUserActivityType:(NSString *)arg1 withReply:(void (^)(NSArray *, NSError *))arg2;
@end
| 49.176471 | 127 | 0.741627 |
4b115bde8a9826b4c15bea4d428a53cd8f3b3702 | 915 | h | C | version.h | schdub/mitmproxy2pcap | e0ee20bd7bc07b503ccbf670191a85a6b719368b | [
"MIT"
] | null | null | null | version.h | schdub/mitmproxy2pcap | e0ee20bd7bc07b503ccbf670191a85a6b719368b | [
"MIT"
] | null | null | null | version.h | schdub/mitmproxy2pcap | e0ee20bd7bc07b503ccbf670191a85a6b719368b | [
"MIT"
] | null | null | null | #pragma once
#define _VERSION_MAJOR_ 0
#define _VERSION_MINOR_ 1
#define _VERSION_BUILDS_ 20
#define _VERSION_REVISION_ 12
#define _PRODVERSION_MAJOR_ 1
#define _PRODVERSION_MINOR_ 0
#define _PRODVERSION_BUILDS_ 0
#define _PRODVERSION_REVISION_ 0
#define _LOCAL_TEST_ENV_ 0
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define _VERSION_ TOSTRING(_VERSION_MAJOR_) \
"." TOSTRING(_VERSION_MINOR_) \
"." TOSTRING(_VERSION_BUILDS_) \
"." TOSTRING(_VERSION_REVISION_)
#define _PRODVERSION_ TOSTRING(_PRODVERSION_MAJOR_) \
"." TOSTRING(_PRODVERSION_MINOR_)
#define _PROD_NAME_ "mflow"
#define _PROD_DESCRIPTION_ "tool for mitmproxy flow files"
#define _ORGANIZATION_NAME_ "Oleg V. Polivets"
#define _PROD_COPYRIGHT_ "(c) " _ORGANIZATION_NAME_ ", 2018."
| 30.5 | 66 | 0.673224 |
b72592be7a19da6a3075d141d688e5e48ae3e598 | 1,247 | c | C | barco.c | william220436/Barco-Funciones | 204d30e067ac18d50de0f15a32f5254856e99bef | [
"MIT"
] | null | null | null | barco.c | william220436/Barco-Funciones | 204d30e067ac18d50de0f15a32f5254856e99bef | [
"MIT"
] | null | null | null | barco.c | william220436/Barco-Funciones | 204d30e067ac18d50de0f15a32f5254856e99bef | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <time.h>
void bienvenida();
void navegarAlSur(int *x, int *y){
printf("Navegando al SUR! \n");
*x = *x+0;
*y-=10;
}
void navegarAlNorte(int *x, int *y){
printf("Navegando al Norte \n");
*x= *x+0;
*y=*y+6;
}
void navegarAlEste(int *x, int *y){
printf("Navegando al Este \n");
*x=*x+6;
*y=*y+0;
}
void navegarAlOeste(int *x, int *y){
printf("Navegando al Oeste \n");
*x=*x-9;
*y=*y+0;
}
void imprimirPosicion(int x, int y){
printf("La posicion actual del barco es: %d, %d \n", x, y);
printf("\n");
}
int main() {
int x = 0;
int y = 0;
bienvenida();
imprimirPosicion(x, y);
navegarAlSur(&x, &y);
imprimirPosicion(x, y);
printf("El valor de X es: %d \n", x);
printf("La direccion de X es: %p \n", &x);
int *direccion_x = &x;
printf("La direccion de X guardada en otra variable es: %p \n", direccion_x);
navegarAlSur(&x, &y);
imprimirPosicion(x, y);
navegarAlNorte(&x,&y);
imprimirPosicion(x,y);
navegarAlEste(&x,&y);
imprimirPosicion(x,y);
navegarAlOeste(&x,&y);
imprimirPosicion(x,y);
return 0;
}
void bienvenida(){
printf("Bienvenido al barco! \n");
}
| 18.893939 | 81 | 0.57097 |
5b7478261d8b95bd99f32df1b2211719cc7a30b5 | 1,535 | h | C | loader/unknown_function_handling.h | Iglu47/Vulkan-Loader | b383c5131e713e3a190a268fe0aaa310ad8e6236 | [
"Apache-2.0"
] | null | null | null | loader/unknown_function_handling.h | Iglu47/Vulkan-Loader | b383c5131e713e3a190a268fe0aaa310ad8e6236 | [
"Apache-2.0"
] | null | null | null | loader/unknown_function_handling.h | Iglu47/Vulkan-Loader | b383c5131e713e3a190a268fe0aaa310ad8e6236 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) 2022 The Khronos Group Inc.
* Copyright (c) 2022 Valve Corporation
* Copyright (c) 2022 LunarG, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author: Jon Ashburn <jon@lunarg.com>
* Author: Courtney Goeltzenleuchter <courtney@LunarG.com>
* Author: Mark Young <marky@lunarg.com>
* Author: Lenny Komow <lenny@lunarg.com>
* Author: Charles Giessen <charles@lunarg.com>
*/
#pragma once
#include "loader_common.h"
void loader_init_dispatch_dev_ext(struct loader_instance *inst, struct loader_device *dev);
void *loader_dev_ext_gpa(struct loader_instance *inst, const char *funcName);
void *loader_phys_dev_ext_gpa_tramp(struct loader_instance *inst, const char *funcName);
void *loader_phys_dev_ext_gpa_term(struct loader_instance *inst, const char *funcName);
void *loader_phys_dev_ext_gpa_term_no_check(struct loader_instance *inst, const char *funcName);
void loader_free_dev_ext_table(struct loader_instance *inst);
void loader_free_phys_dev_ext_table(struct loader_instance *inst); | 41.486486 | 96 | 0.775244 |
a050532d18aa67fdd57de31412ac2504ab018237 | 19 | h | C | sdk/win32/include/arch/epstruct.h | doyaGu/C0501Q_HWJL01 | 07a71328bd9038453cbb1cf9c276a3dd1e416d63 | [
"MIT"
] | 1 | 2021-10-09T08:05:50.000Z | 2021-10-09T08:05:50.000Z | sdk/win32/include/arch/epstruct.h | doyaGu/C0501Q_HWJL01 | 07a71328bd9038453cbb1cf9c276a3dd1e416d63 | [
"MIT"
] | null | null | null | sdk/win32/include/arch/epstruct.h | doyaGu/C0501Q_HWJL01 | 07a71328bd9038453cbb1cf9c276a3dd1e416d63 | [
"MIT"
] | null | null | null | #pragma pack(pop)
| 9.5 | 18 | 0.684211 |
272cc0b63a4c58a71704836faaffb3c202fe78ed | 1,063 | c | C | oskar/sky/src/oskar_sky_generate_random_power_law.c | i4Ds/OSKAR | 70bab06fd63729608420e29dc18512c954126bf0 | [
"BSD-3-Clause"
] | 46 | 2015-12-15T14:24:16.000Z | 2022-01-24T16:54:49.000Z | oskar/sky/src/oskar_sky_generate_random_power_law.c | i4Ds/OSKAR | 70bab06fd63729608420e29dc18512c954126bf0 | [
"BSD-3-Clause"
] | 37 | 2016-08-04T17:53:03.000Z | 2022-03-10T10:22:01.000Z | oskar/sky/src/oskar_sky_generate_random_power_law.c | i4Ds/OSKAR | 70bab06fd63729608420e29dc18512c954126bf0 | [
"BSD-3-Clause"
] | 32 | 2016-05-09T10:30:11.000Z | 2022-01-26T07:55:27.000Z | /*
* Copyright (c) 2016-2021, The OSKAR Developers.
* See the LICENSE file at the top-level directory of this distribution.
*/
#include "sky/oskar_sky.h"
#include "sky/oskar_generate_random_coordinate.h"
#include "math/oskar_random_power_law.h"
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
oskar_Sky* oskar_sky_generate_random_power_law(int precision, int num_sources,
double flux_min_jy, double flux_max_jy, double power, int seed,
int* status)
{
oskar_Sky* sky = 0;
int i = 0;
if (*status) return 0;
/* Create a temporary sky model. */
srand(seed);
sky = oskar_sky_create(precision, OSKAR_CPU, num_sources, status);
for (i = 0; i < num_sources; ++i)
{
double ra = 0.0, dec = 0.0, b = 0.0;
oskar_generate_random_coordinate(&ra, &dec);
b = oskar_random_power_law(flux_min_jy, flux_max_jy, power);
oskar_sky_set_source(sky, i, ra, dec, b, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, status);
}
return sky;
}
#ifdef __cplusplus
}
#endif
| 25.926829 | 78 | 0.649106 |
e92b167643f40f87838f724e55f26b4c632bb1b9 | 3,169 | h | C | src/activitymanager/activity/schedule/IntervalSchedule.h | webosce/activitymanager | dd631ba54d8970545ccb284ee35bbcd11afb2441 | [
"Apache-2.0"
] | 2 | 2018-03-22T19:11:12.000Z | 2019-05-06T05:13:47.000Z | src/activitymanager/activity/schedule/IntervalSchedule.h | webosce/activitymanager | dd631ba54d8970545ccb284ee35bbcd11afb2441 | [
"Apache-2.0"
] | 2 | 2018-05-01T16:03:26.000Z | 2019-07-01T20:26:19.000Z | src/activitymanager/activity/schedule/IntervalSchedule.h | webosce/activitymanager | dd631ba54d8970545ccb284ee35bbcd11afb2441 | [
"Apache-2.0"
] | 5 | 2018-03-22T19:11:15.000Z | 2021-06-19T14:38:20.000Z | // Copyright (c) 2009-2018 LG Electronics, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#ifndef __INTERVAL_SCHEDULE_H__
#define __INTERVAL_SCHEDULE_H__
#include "Schedule.h"
/*
* Interval Schedule items have a defined start time, and potentially an
* end time.
*
* "interval" specifies how often (in seconds) the Activity should run.
*
* "smart" specifies that the the Schedule should be scheduled with other
* items on a similar interval. In order to ensure they align, only
* particular intervals will be supported. The interval will be rounded
* *UP* to the nearest interval. Initially supported intervals:
* N days, 12 hours, 6 hours, 2 hours, 1 hour, 30 minutes, 15 minutes,
* 10 minutes, 5 minutes.
*
*/
class IntervalSchedule: public Schedule {
public:
IntervalSchedule(std::shared_ptr<Activity> activity,
time_t start,
unsigned interval,
time_t end);
virtual ~IntervalSchedule();
virtual time_t getNextStartTime() const;
virtual void calcNextStartTime();
virtual time_t getBaseStartTime() const;
virtual bool isInterval() const;
void setSkip(bool skip);
void setLastFinishedTime(time_t finished);
/* INTERFACE: ACTIVITY ----> SCHEDULE */
virtual void informActivityFinished();
/* END INTERFACE */
virtual bool shouldReschedule() const;
virtual MojErr toJson(MojObject& rep, unsigned long flags) const;
static unsigned stringToInterval(const char *intervalStr, bool smart = false);
static std::string intervalToString(unsigned interval);
protected:
time_t m_end;
unsigned m_interval;
bool m_skip;
time_t m_nextStart;
time_t m_lastFinished;
};
class PreciseIntervalSchedule: public IntervalSchedule {
public:
PreciseIntervalSchedule(std::shared_ptr<Activity> activity,
time_t start,
unsigned interval,
time_t end);
virtual ~PreciseIntervalSchedule();
virtual time_t getBaseStartTime() const;
virtual MojErr toJson(MojObject& rep, unsigned long flags) const;
};
class RelativeIntervalSchedule: public IntervalSchedule {
public:
RelativeIntervalSchedule(std::shared_ptr<Activity> activity,
time_t start,
unsigned interval,
time_t end);
virtual ~RelativeIntervalSchedule();
virtual time_t getBaseStartTime() const;
virtual MojErr toJson(MojObject& rep, unsigned long flags) const;
};
#endif /* __INTERVAL_SCHEDULE_H__ */
| 29.616822 | 82 | 0.687599 |
e9b4fdbe537fa77b054a94bfbfcf6d10d6d8f2c2 | 889 | h | C | src/PowerSupply.h | morphogencc/ofxColorKinetics | e6ee15ef278ef1fbdd6ddedc7ca66171be694ac7 | [
"MIT"
] | 2 | 2016-05-17T15:37:11.000Z | 2021-03-02T07:18:39.000Z | src/PowerSupply.h | morphogencc/ofxColorKinetics | e6ee15ef278ef1fbdd6ddedc7ca66171be694ac7 | [
"MIT"
] | 1 | 2016-02-21T05:44:46.000Z | 2016-03-26T03:28:40.000Z | src/PowerSupply.h | morphogencc/ofxColorKinetics | e6ee15ef278ef1fbdd6ddedc7ca66171be694ac7 | [
"MIT"
] | 2 | 2016-03-01T16:20:52.000Z | 2018-01-17T20:05:57.000Z | #pragma once
#include <string>
#include <memory>
#include <map>
#include "Fixture.h"
#include "KinetPacket.h"
#include "ofxUDPManager.h"
namespace ofxColorKinetics {
class PowerSupply {
public:
static std::shared_ptr<PowerSupply> make(std::string ip_address, int port);
~PowerSupply();
bool connect();
std::string getIpAddress();
int getPort();
void setKinetVersion(uint16_t version);
void addFixture(std::shared_ptr<Fixture> fixture);
int getNumberOfFixtures();
std::vector<std::shared_ptr<Fixture> > getFixtures();
std::shared_ptr<Fixture> getFixture(int starting_address);
void clearFixtures();
void tick(unsigned char port = 0x00);
protected:
PowerSupply(std::string ip_address, int port);
std::string mIpAddress;
int mPort;
std::vector<std::shared_ptr<Fixture> > mFixtures;
std::unique_ptr<KinetPacket> mKinet;
ofxUDPManager mUdpSocket;
};
}
| 26.147059 | 77 | 0.737908 |
d40e339b621b2f6c7be0ac24a5723ded19408ee3 | 47,683 | h | C | lib/Containers/AssocMulti.h | corona3000/arangodb | e4d5a5d2d7e83b1a094c5ac01706a13fdecfc1da | [
"Apache-2.0"
] | null | null | null | lib/Containers/AssocMulti.h | corona3000/arangodb | e4d5a5d2d7e83b1a094c5ac01706a13fdecfc1da | [
"Apache-2.0"
] | null | null | null | lib/Containers/AssocMulti.h | corona3000/arangodb | e4d5a5d2d7e83b1a094c5ac01706a13fdecfc1da | [
"Apache-2.0"
] | null | null | null | ////////////////////////////////////////////////////////////////////////////////
/// DISCLAIMER
///
/// Copyright 2014-2016 ArangoDB GmbH, Cologne, Germany
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Martin Schoenert
/// @author Max Neunhoeffer
/// @author Dan Larkin-York
////////////////////////////////////////////////////////////////////////////////
#ifndef ARANGODB_CONTAINERS_ASSOC_MULTI_H
#define ARANGODB_CONTAINERS_ASSOC_MULTI_H 1
#include <cstdint>
#include <thread>
// Activate for additional debugging:
// #define ARANGODB_CHECK_MULTI_POINTER_HASH 1
#ifdef ARANGODB_CHECK_MULTI_POINTER_HASH
#include <iostream>
#endif
#include <velocypack/Builder.h>
#include <velocypack/velocypack-aliases.h>
#include "Basics/LocalTaskQueue.h"
#include "Basics/Mutex.h"
#include "Basics/MutexLocker.h"
#include "Basics/PerformanceLogScope.h"
#include "Basics/debugging.h"
#include "Basics/error.h"
#include "Basics/prime-numbers.h"
#include "Basics/voc-errors.h"
#include "Containers/details/AssocHelpers.h"
#include "Containers/details/AssocMultiHelpers.h"
#include "Containers/details/IndexBucket.h"
#include "Logger/Logger.h"
namespace arangodb {
namespace containers {
////////////////////////////////////////////////////////////////////////////////
/// @brief associative array of pointers, tolerating repeated keys.
///
/// This is a data structure that can store pointers to elements. Each element
/// has a unique key (for example a certain attribute) and multiple
/// elements in the associative array can have the same key. Every element
/// can be at most once in the array.
/// We want to offer constant time complexity for the following
/// operations:
/// - insert pointer to a element into the array
/// - lookup pointer to a element in the array
/// - delete pointer to a element from the array
/// - find one pointer to a element with a given key
/// Furthermore, we want to offer O(n) complexity for the following
/// operation:
/// - find all pointers whose elements have a given key k, where n is
/// the number of elements in the array with this key
/// To this end, we use a hash table and ask the user to provide the following:
/// - a way to hash elements by their keys, and to hash keys themselves,
/// - a way to hash elements by their full identity
/// - a way to compare a key to the key of a given element
/// - a way to compare two elements, either by their keys or by their full
/// identities.
/// To avoid unnecessary comparisons the user can guarantee that s/he will
/// only try to store non-identical elements into the array. This enables
/// the code to skip comparisons which would otherwise be necessary to
/// ensure uniqueness.
/// The idea of the algorithm is as follows: Each slot in the hash table
/// contains a pointer to the actual element, as well as two unsigned
/// integers "prev" and "next" (being indices in the hash table) to
/// organize a linked list of entries, *within the same hash table*. All
/// elements with the same key are kept in a doubly linked list. The first
/// element in such a linked list is kept at the position determined by
/// its hash with respect to its key (or in the first free slot after this
/// position). All further elements in such a linked list are kept at the
/// position determined by its hash with respect to its full identity
/// (or in the first free slot after this position). Provided the hash
/// table is large enough and the hash functions distribute well enough,
/// this gives the proposed complexity.
///
////////////////////////////////////////////////////////////////////////////////
template <class Key, class Element, class IndexType, bool useHashCache, class AssocMultiHelper>
class AssocMulti {
private:
using UserData = void;
public:
static IndexType const INVALID_INDEX = ((IndexType)0) - 1;
using CallbackElementFuncType = std::function<bool(Element&)>;
private:
using EntryType = Entry<Element, IndexType, useHashCache>;
using Bucket = IndexBucket<EntryType, IndexType>;
AssocMultiHelper _helper;
std::vector<Bucket> _buckets;
size_t _bucketsMask;
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
uint64_t _nrFinds; // statistics: number of lookup calls
uint64_t _nrAdds; // statistics: number of insert calls
uint64_t _nrRems; // statistics: number of remove calls
uint64_t _nrResizes; // statistics: number of resizes
uint64_t _nrProbes; // statistics: number of misses in FindElementPlace
// and LookupByElement, used by insert, lookup and
// remove
uint64_t _nrProbesF; // statistics: number of misses while looking up
uint64_t _nrProbesD; // statistics: number of misses while removing
#endif
std::function<std::string()> _contextCallback;
IndexType _initialSize;
public:
AssocMulti(AssocMultiHelper&& helper, size_t numberBuckets = 1, IndexType initialSize = 64,
std::function<std::string()> contextCallback = []() -> std::string {
return "";
})
: _helper(std::move(helper)),
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
_nrFinds(0),
_nrAdds(0),
_nrRems(0),
_nrResizes(0),
_nrProbes(0),
_nrProbesF(0),
_nrProbesD(0),
#endif
_contextCallback(contextCallback),
_initialSize(initialSize) {
// Make the number of buckets a power of two:
size_t ex = 0;
size_t nr = 1;
numberBuckets >>= 1;
while (numberBuckets > 0) {
ex += 1;
numberBuckets >>= 1;
nr <<= 1;
}
numberBuckets = nr;
_bucketsMask = nr - 1;
_buckets.resize(numberBuckets);
try {
for (size_t j = 0; j < numberBuckets; j++) {
_buckets[j].allocate(_initialSize);
}
} catch (...) {
_buckets.clear();
throw;
}
}
~AssocMulti() { _buckets.clear(); }
//////////////////////////////////////////////////////////////////////////////
/// @brief return the memory used by the hash table
//////////////////////////////////////////////////////////////////////////////
size_t memoryUsage() const {
size_t res = 0;
for (auto& b : _buckets) {
res += b.memoryUsage();
}
return res;
}
//////////////////////////////////////////////////////////////////////////////
/// @brief size(), return the number of items stored
//////////////////////////////////////////////////////////////////////////////
size_t size() const {
size_t res = 0;
for (auto& b : _buckets) {
res += static_cast<size_t>(b._nrUsed);
}
return res;
}
//////////////////////////////////////////////////////////////////////////////
/// @brief Appends information about statistics in the given VPackBuilder
//////////////////////////////////////////////////////////////////////////////
void appendToVelocyPack(VPackBuilder& builder) {
builder.add("buckets", VPackValue(VPackValueType::Array));
for (auto& b : _buckets) {
builder.openObject();
builder.add("nrAlloc", VPackValue(b._nrAlloc));
builder.add("nrUsed", VPackValue(b._nrUsed));
builder.close();
}
builder.close(); // buckets
builder.add("nrBuckets", VPackValue(_buckets.size()));
builder.add("totalUsed", VPackValue(size()));
}
//////////////////////////////////////////////////////////////////////////////
/// @brief capacity(), return the number of allocated items
//////////////////////////////////////////////////////////////////////////////
size_t capacity() const {
size_t res = 0;
for (auto& b : _buckets) {
res += static_cast<size_t>(b._nrAlloc);
}
return res;
}
//////////////////////////////////////////////////////////////////////////////
/// @brief return the element at position.
/// this may return a default-constructed Element if not found
//////////////////////////////////////////////////////////////////////////////
Element at(Bucket& b, size_t position) const {
return b._table[position].value;
}
//////////////////////////////////////////////////////////////////////////////
/// @brief adds a key/element to the array
//////////////////////////////////////////////////////////////////////////////
Element insert(UserData* userData, Element const& element, bool overwrite, bool checkEquality) {
// if the checkEquality flag is not set, we do not check for element
// equality we use this flag to speed up initial insertion into the
// index, i.e. when the index is built for a collection and we know
// for sure no duplicate elements will be inserted
#ifdef ARANGODB_CHECK_MULTI_POINTER_HASH
check(userData, true, true);
#endif
// compute the hash by the key only first
uint64_t hashByKey = _helper.HashElement(element, true);
Bucket& b = _buckets[hashByKey & _bucketsMask];
auto result = doInsert(userData, element, hashByKey, b, overwrite, checkEquality);
#ifdef ARANGODB_CHECK_MULTI_POINTER_HASH
check(userData, true, true);
#endif
return result;
}
//////////////////////////////////////////////////////////////////////////////
/// @brief adds multiple elements to the array
//////////////////////////////////////////////////////////////////////////////
void batchInsert(std::function<void*()> const& contextCreator,
std::function<void(void*)> const& contextDestroyer,
std::shared_ptr<std::vector<Element> const> data,
std::shared_ptr<basics::LocalTaskQueue> queue) {
if (data->empty()) {
// nothing to do
return;
}
std::vector<Element> const& elements = *(data.get());
// set the number of partitioners sensibly
size_t numThreads = _buckets.size();
if (elements.size() < numThreads) {
numThreads = elements.size();
}
size_t const chunkSize = elements.size() / numThreads;
typedef std::vector<std::pair<Element, uint64_t>> DocumentsPerBucket;
typedef MultiInserterTask<Element, IndexType, useHashCache> Inserter;
typedef MultiPartitionerTask<Element, IndexType, useHashCache> Partitioner;
// allocate working space and coordination tools for tasks
std::shared_ptr<std::vector<arangodb::Mutex>> bucketMapLocker;
bucketMapLocker.reset(new std::vector<arangodb::Mutex>(_buckets.size()));
std::shared_ptr<std::vector<std::atomic<size_t>>> bucketFlags;
bucketFlags.reset(new std::vector<std::atomic<size_t>>(_buckets.size()));
for (size_t i = 0; i < bucketFlags->size(); i++) {
(*bucketFlags)[i] = numThreads;
}
std::shared_ptr<std::vector<std::shared_ptr<Inserter>>> inserters;
inserters.reset(new std::vector<std::shared_ptr<Inserter>>);
inserters->reserve(_buckets.size());
std::shared_ptr<std::vector<std::vector<DocumentsPerBucket>>> allBuckets;
allBuckets.reset(new std::vector<std::vector<DocumentsPerBucket>>(_buckets.size()));
auto doInsertBinding = [&](UserData* userData, Element const& element,
uint64_t hashByKey, Bucket& b, bool const overwrite,
bool const checkEquality) -> Element {
return doInsert(userData, element, hashByKey, b, overwrite, checkEquality);
};
try {
// create inserter tasks to be dispatched later by partitioners
for (size_t i = 0; i < allBuckets->size(); i++) {
std::shared_ptr<Inserter> worker;
worker.reset(new Inserter(queue, contextDestroyer, &_buckets, doInsertBinding,
i, contextCreator(), allBuckets));
inserters->emplace_back(worker);
}
// enqueue partitioner tasks
for (size_t i = 0; i < numThreads; ++i) {
size_t lower = i * chunkSize;
size_t upper = (i + 1) * chunkSize;
if (i + 1 == numThreads) {
// last chunk. account for potential rounding errors
upper = elements.size();
} else if (upper > elements.size()) {
upper = elements.size();
}
std::shared_ptr<Partitioner> worker;
worker.reset(new Partitioner(queue, AssocMultiHelper::HashElement, contextDestroyer,
data, lower, upper, contextCreator(), bucketFlags,
bucketMapLocker, allBuckets, inserters));
queue->enqueue(worker);
}
} catch (...) {
queue->setStatus(TRI_ERROR_INTERNAL);
}
#ifdef ARANGODB_CHECK_MULTI_POINTER_HASH
{
auto& checkFn = check;
auto callback = [&contextCreator, &contextDestroyer, &checkFn]() -> void {
if (queue->status() == TRI_ERROR_NO_ERROR) {
void* userData = contextCreator();
checkFn(userData, true, true);
contextDestroyer(userData);
}
};
std::shared_ptr<arangodb::basics::LocalCallbackTask> cbTask;
cbTask.reset(new arangodb::basics::LocalCallbackTask(queue, callback));
queue->enqueueCallback(cbTask);
}
#endif
}
void truncate(CallbackElementFuncType callback) {
for (auto& b : _buckets) {
invokeOnAllElements(callback, b);
b.deallocate();
b.allocate(_initialSize);
}
}
/// @brief a method to iterate over all elements in the hash
void invokeOnAllElements(CallbackElementFuncType const& callback) {
for (auto& b : _buckets) {
if (b._table == nullptr || b._nrUsed == 0) {
continue;
}
if (!invokeOnAllElements(callback, b)) {
return;
}
}
}
/// @brief a method to iterate over all elements in the hash
bool invokeOnAllElements(CallbackElementFuncType const& callback, Bucket& b) {
for (size_t i = 0; i < b._nrAlloc; ++i) {
if (!b._table[i].value) {
continue;
}
if (!callback(b._table[i].value)) {
return false;
}
}
return true;
}
private:
//////////////////////////////////////////////////////////////////////////////
/// @brief adds a key/element to the array
//////////////////////////////////////////////////////////////////////////////
Element doInsert(UserData* userData, Element const& element, uint64_t hashByKey,
Bucket& b, bool const overwrite, bool const checkEquality) {
// if the checkEquality flag is not set, we do not check for element
// equality we use this flag to speed up initial insertion into the
// index, i.e. when the index is built for a collection and we know
// for sure no duplicate elements will be inserted
// if we were adding and the table is more than 2/3 full, extend it
if (2 * b._nrAlloc < 3 * b._nrUsed) {
resizeInternal(userData, b, 2 * b._nrAlloc + 1);
}
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
// update statistics
_nrAdds++;
#endif
IndexType hashIndex = hashToIndex(hashByKey);
IndexType i = hashIndex % b._nrAlloc;
// If this slot is free, just use it:
if (!b._table[i].value) {
b._table[i].value = element;
b._table[i].next = INVALID_INDEX;
b._table[i].prev = INVALID_INDEX;
if (useHashCache) {
b._table[i].writeHashCache(hashByKey);
}
b._nrUsed++;
// no collision generated here!
return Element();
}
// Now find the first slot with an entry with the same key
// that is the start of a linked list, or a free slot:
while (b._table[i].value &&
(b._table[i].prev != INVALID_INDEX ||
(useHashCache && b._table[i].readHashCache() != hashByKey) ||
!_helper.IsEqualElementElementByKey(userData, element, b._table[i].value))) {
i = incr(b, i);
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
// update statistics
_ProbesA++;
#endif
}
// If this is free, we are the first with this key:
if (!b._table[i].value) {
b._table[i].value = element;
b._table[i].next = INVALID_INDEX;
b._table[i].prev = INVALID_INDEX;
if (useHashCache) {
b._table[i].writeHashCache(hashByKey);
}
b._nrUsed++;
// no collision generated here either!
return Element();
}
// Otherwise, entry i points to the beginning of the linked
// list of which we want to make element a member. Perhaps an
// equal element is right here:
if (checkEquality &&
_helper.IsEqualElementElement(userData, element, b._table[i].value)) {
Element old = b._table[i].value;
if (overwrite) {
TRI_ASSERT(!useHashCache || b._table[i].readHashCache() == hashByKey);
b._table[i].value = element;
}
return old;
}
// Now find a new home for element in this linked list:
uint64_t hashByElm;
IndexType j = findElementPlace(userData, b, element, checkEquality, hashByElm);
Element old = b._table[j].value;
// if we found an element, return
if (old) {
if (overwrite) {
if (useHashCache) {
b._table[j].writeHashCache(hashByElm);
}
b._table[j].value = element;
}
return old;
}
// add a new element to the associative array and linked list (in pos 2):
b._table[j].value = element;
b._table[j].next = b._table[i].next;
b._table[j].prev = i;
if (useHashCache) {
b._table[j].writeHashCache(hashByElm);
}
b._table[i].next = j;
// Finally, we need to find the successor to patch it up:
if (b._table[j].next != INVALID_INDEX) {
b._table[b._table[j].next].prev = j;
}
b._nrUsed++;
b._nrCollisions++;
return Element();
}
//////////////////////////////////////////////////////////////////////////////
/// @brief insertFirst, special version of insert, when it is known that the
/// element is the first in the hash with its key, and the hash of the key
/// is already known. This is for example the case when resizing.
//////////////////////////////////////////////////////////////////////////////
IndexType insertFirst(UserData* userData, Bucket& b, Element const& element,
uint64_t hashByKey) {
#ifdef ARANGODB_CHECK_MULTI_POINTER_HASH
check(userData, true, true);
#endif
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
// update statistics
_nrAdds++;
#endif
IndexType hashIndex = hashToIndex(hashByKey);
IndexType i = hashIndex % b._nrAlloc;
// If this slot is free, just use it:
if (!b._table[i].value) {
b._table[i].value = element;
b._table[i].next = INVALID_INDEX;
b._table[i].prev = INVALID_INDEX;
if (useHashCache) {
b._table[i].writeHashCache(hashByKey);
}
b._nrUsed++;
// no collision generated here!
#ifdef ARANGODB_CHECK_MULTI_POINTER_HASH
check(userData, true, true);
#endif
return i;
}
// Now find the first slot with an entry with the same key
// that is the start of a linked list, or a free slot:
while (b._table[i].value) {
i = incr(b, i);
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
// update statistics
_ProbesA++;
#endif
}
// We are the first with this key:
b._table[i].value = element;
b._table[i].next = INVALID_INDEX;
b._table[i].prev = INVALID_INDEX;
if (useHashCache) {
b._table[i].writeHashCache(hashByKey);
}
b._nrUsed++;
// no collision generated here either!
#ifdef ARANGODB_CHECK_MULTI_POINTER_HASH
check(userData, true, true);
#endif
return i;
}
//////////////////////////////////////////////////////////////////////////////
/// @brief insertFurther, special version of insert, when it is known
/// that the element is not the first in the hash with its key, and
/// the hash of the key and the element is already known. This is for
/// example the case when resizing.
//////////////////////////////////////////////////////////////////////////////
void insertFurther(UserData* userData, Bucket& b, Element const& element,
uint64_t hashByKey, uint64_t hashByElm, IndexType firstPosition) {
#ifdef ARANGODB_CHECK_MULTI_POINTER_HASH
check(userData, true, true);
#endif
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
// update statistics
_nrAdds++;
#endif
// We already know the beginning of the doubly linked list:
// Now find a new home for element in this linked list:
IndexType hashIndex = hashToIndex(hashByElm);
IndexType j = hashIndex % b._nrAlloc;
while (b._table[j].value) {
j = incr(b, j);
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
_nrProbes++;
#endif
}
// add the element to the hash and linked list (in pos 2):
b._table[j].value = element;
b._table[j].next = b._table[firstPosition].next;
b._table[j].prev = firstPosition;
if (useHashCache) {
b._table[j].writeHashCache(hashByElm);
}
b._table[firstPosition].next = j;
// Finally, we need to find the successor to patch it up:
if (b._table[j].next != INVALID_INDEX) {
b._table[b._table[j].next].prev = j;
}
b._nrUsed++;
b._nrCollisions++;
#ifdef ARANGODB_CHECK_MULTI_POINTER_HASH
check(userData, true, true);
#endif
}
//////////////////////////////////////////////////////////////////////////////
/// @brief lookups an element given an element
//////////////////////////////////////////////////////////////////////////////
public:
Element lookup(UserData* userData, Element const& element) const {
IndexType i;
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
// update statistics
_nrFinds++;
#endif
Bucket* b;
i = lookupByElement(userData, element, b);
return b->_table[i].value;
}
//////////////////////////////////////////////////////////////////////////////
/// @brief lookups an element given a key
//////////////////////////////////////////////////////////////////////////////
std::vector<Element>* lookupByKey(UserData* userData, Key const* key,
size_t limit = 0) const {
auto result = std::make_unique<std::vector<Element>>();
lookupByKey(userData, key, *result, limit);
return result.release();
}
//////////////////////////////////////////////////////////////////////////////
/// @brief lookups an element given a key
/// Accepts a result vector as input. The result of this lookup will
/// be appended to the given vector.
/// This function returns as soon as limit many elements are inside
/// the given vector, no matter if the come from this lookup or
/// have been in the result before.
//////////////////////////////////////////////////////////////////////////////
void lookupByKey(UserData* userData, Key const* key,
std::vector<Element>& result, size_t limit = 0) const {
if (limit > 0 && result.size() >= limit) {
return;
}
// compute the hash
uint64_t hashByKey = _helper.HashKey(key);
Bucket const& b = _buckets[hashByKey & _bucketsMask];
IndexType hashIndex = hashToIndex(hashByKey);
IndexType i = hashIndex % b._nrAlloc;
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
// update statistics
_nrFinds++;
#endif
// search the table
while (b._table[i].value &&
(b._table[i].prev != INVALID_INDEX ||
(useHashCache && b._table[i].readHashCache() != hashByKey) ||
!_helper.IsEqualKeyElement(userData, key, b._table[i].value))) {
i = incr(b, i);
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
_nrProbesF++;
#endif
}
if (b._table[i].value) {
// We found the beginning of the linked list:
do {
result.push_back(b._table[i].value);
i = b._table[i].next;
} while (i != INVALID_INDEX && (limit == 0 || result.size() < limit));
}
// return whatever we found
}
//////////////////////////////////////////////////////////////////////////////
/// @brief looks up all elements with the same key as a given element
//////////////////////////////////////////////////////////////////////////////
std::vector<Element>* lookupWithElementByKey(UserData* userData, Element const& element,
size_t limit = 0) const {
auto result = std::make_unique<std::vector<Element>>();
lookupWithElementByKey(userData, element, *result, limit);
return result.release();
}
//////////////////////////////////////////////////////////////////////////////
/// @brief looks up all elements with the same key as a given element
/// Accepts a result vector as input. The result of this lookup will
/// be appended to the given vector.
/// This function returns as soon as limit many elements are inside
/// the given vector, no matter if the come from this lookup or
/// have been in the result before.
//////////////////////////////////////////////////////////////////////////////
void lookupWithElementByKey(UserData* userData, Element const& element,
std::vector<Element>& result, size_t limit = 0) const {
if (limit > 0 && result.size() >= limit) {
// The vector is full, nothing to do.
return;
}
// compute the hash
uint64_t hashByKey = _helper.HashElement(element, true);
Bucket const& b = _buckets[hashByKey & _bucketsMask];
IndexType hashIndex = hashToIndex(hashByKey);
IndexType i = hashIndex % b._nrAlloc;
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
// update statistics
_nrFinds++;
#endif
// search the table
while (b._table[i].value &&
(b._table[i].prev != INVALID_INDEX ||
(useHashCache && b._table[i].readHashCache() != hashByKey) ||
!_helper.IsEqualElementElementByKey(userData, element, b._table[i].value))) {
i = incr(b, i);
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
_nrProbesF++;
#endif
}
if (b._table[i].value) {
// We found the beginning of the linked list:
do {
result.push_back(b._table[i].value);
i = b._table[i].next;
} while (i != INVALID_INDEX && (limit == 0 || result.size() < limit));
}
// return whatever we found
}
//////////////////////////////////////////////////////////////////////////////
/// @brief looks up all elements with the same key as a given element,
/// continuation
//////////////////////////////////////////////////////////////////////////////
std::vector<Element>* lookupWithElementByKeyContinue(UserData* userData,
Element const& element,
size_t limit = 0) const {
auto result = std::make_unique<std::vector<Element>>();
lookupWithElementByKeyContinue(userData, element, *result.get(), limit);
return result.release();
}
//////////////////////////////////////////////////////////////////////////////
/// @brief looks up all elements with the same key as a given element,
/// continuation.
/// Accepts a result vector as input. The result of this lookup will
/// be appended to the given vector.
/// This function returns as soon as limit many elements are inside
/// the given vector, no matter if the come from this lookup or
/// have been in the result before.
//////////////////////////////////////////////////////////////////////////////
void lookupWithElementByKeyContinue(UserData* userData, Element const& element,
std::vector<Element>& result, size_t limit = 0) const {
if (limit > 0 && result.size() >= limit) {
// The vector is full, nothing to do.
return;
}
uint64_t hashByKey = _helper.HashElement(element, true);
Bucket const& b = _buckets[hashByKey & _bucketsMask];
uint64_t hashByElm;
IndexType i = findElementPlace(userData, b, element, true, hashByElm);
if (!b._table[i].value) {
// This can only happen if the element was the first in its doubly
// linked list (after all, the caller guaranteed that element was
// the last of a previous lookup). To cover this case, we have to
// look in the position given by the hashByKey:
i = hashToIndex(hashByKey) % b._nrAlloc;
// Now find the first slot with an entry with the same key
// that is the start of a linked list, or a free slot:
while (b._table[i].value &&
(b._table[i].prev != INVALID_INDEX ||
(useHashCache && b._table[i].readHashCache() != hashByKey) ||
!_helper.IsEqualElementElementByKey(userData, element, b._table[i].value))) {
i = incr(b, i);
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
_nrProbes++;
#endif
}
if (!b._table[i].value) {
// This cannot really happen, but we handle it gracefully anyway
return;
}
}
// continue search of the table
while (true) {
i = b._table[i].next;
if (i == INVALID_INDEX || (limit != 0 && result.size() >= limit)) {
break;
}
result.push_back(b._table[i].value);
}
// return whatever we found
return;
}
//////////////////////////////////////////////////////////////////////////////
/// @brief looks up all elements with the same key as a given element,
/// continuation
//////////////////////////////////////////////////////////////////////////////
std::vector<Element>* lookupByKeyContinue(UserData* userData, Element const& element,
size_t limit = 0) const {
return lookupWithElementByKeyContinue(userData, element, limit);
}
//////////////////////////////////////////////////////////////////////////////
/// @brief looks up all elements with the same key as a given element,
/// continuation
/// Accepts a result vector as input. The result of this lookup will
/// be appended to the given vector.
/// This function returns as soon as limit many elements are inside
/// the given vector, no matter if the come from this lookup or
/// have been in the result before.
//////////////////////////////////////////////////////////////////////////////
void lookupByKeyContinue(UserData* userData, Element const& element,
std::vector<Element>& result, size_t limit = 0) const {
lookupWithElementByKeyContinue(userData, element, result, limit);
}
//////////////////////////////////////////////////////////////////////////////
/// @brief removes an element from the array, caller is responsible to free
/// it
//////////////////////////////////////////////////////////////////////////////
Element remove(UserData* userData, Element const& element) {
IndexType j = 0;
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
// update statistics
_nrRems++;
#endif
#ifdef ARANGODB_CHECK_MULTI_POINTER_HASH
check(userData, true, true);
#endif
Bucket* b;
IndexType i = lookupByElement(userData, element, b);
if (!b->_table[i].value) {
return Element();
}
Element old = b->_table[i].value;
// We have to delete entry i
if (b->_table[i].prev == INVALID_INDEX) {
// This is the first in its linked list.
j = b->_table[i].next;
if (j == INVALID_INDEX) {
// The only one in its linked list, simply remove it and heal
// the hole:
invalidateEntry(*b, i);
#ifdef ARANGODB_CHECK_MULTI_POINTER_HASH
check(userData, false, false);
#endif
healHole(userData, *b, i);
// this element did not create a collision
} else {
// There is at least one successor in position j.
b->_table[j].prev = INVALID_INDEX;
moveEntry(*b, j, i);
if (useHashCache) {
// We need to exchange the hashCache value by that of the key:
b->_table[i].writeHashCache(_helper.HashElement(b->_table[i].value, true));
}
#ifdef ARANGODB_CHECK_MULTI_POINTER_HASH
check(userData, false, false);
#endif
healHole(userData, *b, j);
b->_nrCollisions--; // one collision less
}
} else {
// This one is not the first in its linked list
j = b->_table[i].prev;
b->_table[j].next = b->_table[i].next;
j = b->_table[i].next;
if (j != INVALID_INDEX) {
// We are not the last in the linked list.
b->_table[j].prev = b->_table[i].prev;
}
invalidateEntry(*b, i);
#ifdef ARANGODB_CHECK_MULTI_POINTER_HASH
check(userData, false, false);
#endif
healHole(userData, *b, i);
b->_nrCollisions--;
}
b->_nrUsed--;
#ifdef ARANGODB_CHECK_MULTI_POINTER_HASH
check(userData, true, true);
#endif
// return success
return old;
}
//////////////////////////////////////////////////////////////////////////////
/// @brief resize the array
//////////////////////////////////////////////////////////////////////////////
int resize(UserData* userData, size_t size) noexcept {
size /= _buckets.size();
for (auto& b : _buckets) {
if (2 * (2 * size + 1) < 3 * b._nrUsed) {
return TRI_ERROR_BAD_PARAMETER;
}
try {
resizeInternal(userData, b, 2 * size + 1);
} catch (...) {
return TRI_ERROR_OUT_OF_MEMORY;
}
}
return TRI_ERROR_NO_ERROR;
}
//////////////////////////////////////////////////////////////////////////////
/// @brief return selectivity, this is a number s with 0.0 < s <= 1.0. If
/// s == 1.0 this means that every document is identified uniquely by its
/// key. It is computed as
/// number of different keys/number of elements in table
//////////////////////////////////////////////////////////////////////////////
double selectivity() {
size_t nrUsed = 0;
size_t nrCollisions = 0;
for (auto& b : _buckets) {
nrUsed += b._nrUsed;
nrCollisions += b._nrCollisions;
}
return nrUsed > 0
? static_cast<double>(nrUsed - nrCollisions) / static_cast<double>(nrUsed)
: 1.0;
}
//////////////////////////////////////////////////////////////////////////////
/// @brief iteration over all pointers in the hash array, the callback
/// function is called on the Element for each thingy stored in the hash
//////////////////////////////////////////////////////////////////////////////
void iterate(UserData* userData, std::function<void(Element&)> callback) {
for (auto& b : _buckets) {
for (IndexType i = 0; i < b._nrAlloc; i++) {
if (b._table[i].value) {
callback(userData, b._table[i].value);
}
}
}
}
private:
//////////////////////////////////////////////////////////////////////////////
/// @brief increment IndexType by 1 modulo _nrAlloc:
//////////////////////////////////////////////////////////////////////////////
inline IndexType incr(Bucket const& b, IndexType i) const {
IndexType dummy = (++i) - b._nrAlloc;
return i < b._nrAlloc ? i : dummy;
}
//////////////////////////////////////////////////////////////////////////////
/// @brief resize the array, internal method
//////////////////////////////////////////////////////////////////////////////
void resizeInternal(UserData* userData, Bucket& b, size_t targetSize) {
std::string const cb(_contextCallback());
targetSize = TRI_NearPrime(targetSize);
PerformanceLogScope logScope(std::string("multi hash-resize ") + cb +
", target size: " + std::to_string(targetSize));
Bucket copy;
copy.allocate(targetSize);
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
_nrResizes++;
#endif
// table is already clear by allocate, copy old data
if (b._nrUsed > 0) {
EntryType* oldTable = b._table;
IndexType const oldAlloc = b._nrAlloc;
TRI_ASSERT(oldAlloc > 0);
for (IndexType j = 0; j < oldAlloc; j++) {
if (oldTable[j].value && oldTable[j].prev == INVALID_INDEX) {
// This is a "first" one in its doubly linked list:
uint64_t hashByKey;
if (useHashCache) {
hashByKey = oldTable[j].readHashCache();
} else {
hashByKey = _helper.HashElement(oldTable[j].value, true);
}
IndexType insertPosition =
insertFirst(userData, copy, oldTable[j].value, hashByKey);
// Now walk to the end of the list:
IndexType k = j;
while (oldTable[k].next != INVALID_INDEX) {
k = oldTable[k].next;
}
// Now insert all of them backwards, not repeating k:
while (k != j) {
uint64_t hashByElm;
if (useHashCache) {
hashByElm = oldTable[k].readHashCache();
} else {
hashByElm = _helper.HashElement(oldTable[k].value, false);
}
insertFurther(userData, copy, oldTable[k].value, hashByKey,
hashByElm, insertPosition);
k = oldTable[k].prev;
}
}
}
}
b = std::move(copy);
}
#ifdef ARANGODB_CHECK_MULTI_POINTER_HASH
//////////////////////////////////////////////////////////////////////////////
/// @brief internal debugging check function
//////////////////////////////////////////////////////////////////////////////
bool check(UserData* userData, bool checkCount, bool checkPositions) const {
std::cout << "Performing AssocMulti check " << checkCount << checkPositions
<< std::endl;
bool ok = true;
for (auto& b : _buckets) {
IndexType i, ii, j, k;
IndexType count = 0;
for (i = 0; i < b._nrAlloc; i++) {
if (b._table[i].value) {
count++;
if (b._table[i].prev != INVALID_INDEX) {
if (b._table[b._table[i].prev].next != i) {
std::cout << "Alarm prev " << i << std::endl;
ok = false;
}
}
if (b._table[i].next != INVALID_INDEX) {
if (b._table[b._table[i].next].prev != i) {
std::cout << "Alarm next " << i << std::endl;
ok = false;
}
}
ii = i;
j = b._table[ii].next;
while (j != INVALID_INDEX) {
if (j == i) {
std::cout << "Alarm cycle " << i << std::endl;
ok = false;
break;
}
ii = j;
j = b._table[ii].next;
}
}
}
if (checkCount && count != b._nrUsed) {
std::cout << "Alarm _nrUsed wrong " << b._nrUsed << " != " << count
<< "!" << std::endl;
ok = false;
}
if (checkPositions) {
for (i = 0; i < b._nrAlloc; i++) {
if (b._table[i].value) {
IndexType hashIndex;
if (b._table[i].prev == INVALID_INDEX) {
// We are the first in a linked list.
uint64_t hashByKey = _helper.HashElement(b._table[i].value, true);
hashIndex = hashToIndex(hashByKey);
j = hashIndex % b._nrAlloc;
if (useHashCache && b._table[i].readHashCache() != hashByKey) {
std::cout << "Alarm hashCache wrong " << i << std::endl;
}
for (k = j; k != i;) {
if (!b._table[k].value ||
(b._table[k].prev == INVALID_INDEX &&
_helper.IsEqualElementElementByKey(userData, b._table[i].value,
b._table[k].value))) {
ok = false;
std::cout << "Alarm pos bykey: " << i << std::endl;
}
k = incr(b, k);
}
} else {
// We are not the first in a linked list.
uint64_t hashByElm = _helper.HashElement(b._table[i].value, false);
hashIndex = hashToIndex(hashByElm);
j = hashIndex % b._nrAlloc;
if (useHashCache && b._table[i].readHashCache() != hashByElm) {
std::cout << "Alarm hashCache wrong " << i << std::endl;
}
for (k = j; k != i;) {
if (!b._table[k].value ||
_helper.IsEqualElementElement(userData, b._table[i].value,
b._table[k].value)) {
ok = false;
std::cout << "Alarm unique: " << k << ", " << i << std::endl;
}
k = incr(b, k);
}
}
}
}
}
}
if (!ok) {
std::cout << "Something is wrong!" << std::endl;
}
return ok;
}
#endif
//////////////////////////////////////////////////////////////////////////////
/// @brief find an element or its place using the element hash function
//////////////////////////////////////////////////////////////////////////////
inline IndexType findElementPlace(UserData* userData, Bucket const& b,
Element const& element, bool checkEquality,
uint64_t& hashByElm) const {
// This either finds a place to store element or an entry in
// the table that is equal to element. If checkEquality is
// set to false, the caller guarantees that there is no entry
// that compares equal to element in the table, which saves a
// lot of element comparisons. This function always returns a
// pointer into the table, which is either empty or points to
// an entry that compares equal to element.
hashByElm = _helper.HashElement(element, false);
IndexType hashindex = hashToIndex(hashByElm);
IndexType i = hashindex % b._nrAlloc;
while (b._table[i].value &&
(!checkEquality || (useHashCache && b._table[i].readHashCache() != hashByElm) ||
!_helper.IsEqualElementElement(userData, element, b._table[i].value))) {
i = incr(b, i);
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
_nrProbes++;
#endif
}
return i;
}
//////////////////////////////////////////////////////////////////////////////
/// @brief find an element or its place by key or element identity
//////////////////////////////////////////////////////////////////////////////
IndexType lookupByElement(UserData* userData, Element const& element, Bucket*& buck) const {
// This performs a complete lookup for an element. It returns a slot
// number. This slot is either empty or contains an element that
// compares equal to element.
uint64_t hashByKey = _helper.HashElement(element, true);
Bucket const& b = _buckets[hashByKey & _bucketsMask];
buck = const_cast<Bucket*>(&b);
IndexType hashIndex = hashToIndex(hashByKey);
IndexType i = hashIndex % b._nrAlloc;
// Now find the first slot with an entry with the same key
// that is the start of a linked list, or a free slot:
while (b._table[i].value &&
(b._table[i].prev != INVALID_INDEX ||
(useHashCache && b._table[i].readHashCache() != hashByKey) ||
!_helper.IsEqualElementElementByKey(userData, element, b._table[i].value))) {
i = incr(b, i);
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
_nrProbes++;
#endif
}
if (b._table[i].value) {
// It might be right here!
if (_helper.IsEqualElementElement(userData, element, b._table[i].value)) {
return i;
}
// Now we have to look for it in its hash position:
uint64_t hashByElm;
IndexType j = findElementPlace(userData, b, element, true, hashByElm);
// We have either found an equal element or nothing:
return j;
}
// If we get here, no element with the same key is in the array, so
// we will not be able to find it anywhere!
return i;
}
//////////////////////////////////////////////////////////////////////////////
/// @brief helper to decide whether something is between to places
//////////////////////////////////////////////////////////////////////////////
static inline bool isBetween(IndexType from, IndexType x, IndexType to) {
// returns whether or not x is behind from and before or equal to
// to in the cyclic order. If x is equal to from, then the result is
// always false. If from is equal to to, then the result is always
// true.
return (from < to) ? (from < x && x <= to) : (x > from || x <= to);
}
//////////////////////////////////////////////////////////////////////////////
/// @brief helper to invalidate a slot
//////////////////////////////////////////////////////////////////////////////
inline void invalidateEntry(Bucket& b, IndexType i) {
b._table[i].value = Element();
b._table[i].next = INVALID_INDEX;
b._table[i].prev = INVALID_INDEX;
if (useHashCache) {
b._table[i].writeHashCache(0);
}
}
//////////////////////////////////////////////////////////////////////////////
/// @brief helper to move an entry from one slot to another
//////////////////////////////////////////////////////////////////////////////
inline void moveEntry(Bucket& b, IndexType from, IndexType to) {
// Moves an entry, adjusts the linked lists, but does not take care
// for the hole. to must be unused. from can be any element in a
// linked list.
b._table[to] = b._table[from];
if (b._table[to].prev != INVALID_INDEX) {
b._table[b._table[to].prev].next = to;
}
if (b._table[to].next != INVALID_INDEX) {
b._table[b._table[to].next].prev = to;
}
invalidateEntry(b, from);
}
//////////////////////////////////////////////////////////////////////////////
/// @brief helper to heal a hole where we deleted something
//////////////////////////////////////////////////////////////////////////////
void healHole(UserData* userData, Bucket& b, IndexType i) {
IndexType j = incr(b, i);
while (b._table[j].value) {
// Find out where this element ought to be:
// If it is the start of one of the linked lists, we need to hash
// by key, otherwise, we hash by the full identity of the element:
uint64_t hash = _helper.HashElement(b._table[j].value, b._table[j].prev == INVALID_INDEX);
IndexType hashIndex = hashToIndex(hash);
IndexType k = hashIndex % b._nrAlloc;
if (!isBetween(i, k, j)) {
// we have to move j to i:
moveEntry(b, j, i);
i = j; // Now heal this hole at j,
// j will be incremented right away
}
j = incr(b, j);
#ifdef ARANGODB_ASSOCMULTI_INTERNAL_STATS
_nrProbesD++;
#endif
}
}
//////////////////////////////////////////////////////////////////////////////
/// @brief convert a 64bit hash value to an index of type IndexType
//////////////////////////////////////////////////////////////////////////////
inline IndexType hashToIndex(uint64_t const h) const {
return static_cast<IndexType>(sizeof(IndexType) == 8 ? h : TRI_64To32(h));
}
};
} // namespace containers
} // namespace arangodb
#endif
| 36.260837 | 98 | 0.546778 |
ace9e377865c5cb0ab93e6a988dae1b8335143cf | 3,920 | c | C | src/mem.c | artnum/STore | 890a649313513558231e383dc2173d0507ab56b9 | [
"BSD-2-Clause"
] | null | null | null | src/mem.c | artnum/STore | 890a649313513558231e383dc2173d0507ab56b9 | [
"BSD-2-Clause"
] | 1 | 2019-08-05T09:14:18.000Z | 2019-08-05T09:14:18.000Z | src/mem.c | artnum/STore | 890a649313513558231e383dc2173d0507ab56b9 | [
"BSD-2-Clause"
] | null | null | null | #include "mem.h"
#include "debug.h"
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
/**
* A pointer can have up to 200 refcounted copy of itself. A room is
* kept for duplicate (which increase refcount). Doing this, a pointer
* can have 200 copies + 55 duplicates and each duplicate can have
* 200 copies + 55 duplicates and so on.
*/
#define MEM_REFCOUNT_MAX 255
#define MEM_COPY_MAX 200
#define MEM_HEADER_LENGTH (sizeof(uint8_t) + sizeof(size_t) + \
sizeof(void *))
#define MEM_PTR(ptr) (void *)((ptr) + MEM_HEADER_LENGTH)
#define MEM_ORIGIN(ptr) (void *)((ptr) - MEM_HEADER_LENGTH)
#define MEM_REFCOUNT(ptr) (uint8_t *)((ptr) - sizeof(uint8_t) - \
sizeof(size_t) - sizeof(void *))
#define MEM_LENGTH(ptr) (size_t *)((ptr) - sizeof(size_t) - \
sizeof(void *))
#define MEM_PARENT(ptr) (void **)((ptr) - sizeof(void *))
void * _mem_alloc (const size_t len) {
if (len <= 0) { return NULL; }
void * ptr = malloc(len + MEM_HEADER_LENGTH);
if (ptr == NULL) { return NULL; }
*MEM_REFCOUNT(MEM_PTR(ptr)) = 1;
*MEM_LENGTH(MEM_PTR(ptr)) = len;
*MEM_PARENT(MEM_PTR(ptr)) = NULL;
DEBUG("New allocation of size %ld with overhead of %ld (%f%%)", len, MEM_HEADER_LENGTH, (float)100 * MEM_HEADER_LENGTH / len);
return MEM_PTR(ptr);
}
void *mem_alloc(const size_t len) {
void *ptr = _mem_alloc(len);
if (ptr == NULL) { return NULL; }
memset(ptr, 0, len);
return ptr;
}
void mem_free (void * ptr) {
DEBUG("Free of %p", ptr);
if (ptr == NULL) { return; }
*MEM_REFCOUNT(ptr) -= 1;
if (*MEM_REFCOUNT(ptr) == 0) {
if (*MEM_PARENT(ptr) != NULL) {
mem_free(*MEM_PARENT(ptr));
}
/* reset to zero memory before freeing */
memset(ptr, 0, *MEM_LENGTH(ptr));
DEBUG("Effective free of %p", ptr);
free(MEM_ORIGIN(ptr));
}
}
/* mem_cpy doesn't increment *MEM_REFCOUNT(*MEM_PARENT(ptr)) has copy
is not another reference of parent but another reference of child
*/
void * mem_cpy (void * ptr) {
void * new_ptr = NULL;
if (*MEM_REFCOUNT(ptr) < MEM_COPY_MAX) {
*MEM_REFCOUNT(ptr) += 1;
new_ptr = ptr;
} else {
DEBUG("Maximum copy reached for %p", ptr);
new_ptr = mem_dup(ptr);
}
return new_ptr;
}
void * _mem_dup (void * ptr, int pRefCountInc) {
if (ptr == NULL) { return NULL; }
void * new_ptr = _mem_alloc(*MEM_LENGTH(ptr));
if (new_ptr) {
memcpy(new_ptr, ptr, *MEM_LENGTH(ptr));
}
if (pRefCountInc && *MEM_REFCOUNT(ptr) < MEM_REFCOUNT_MAX) {
*MEM_PARENT(new_ptr) = ptr;
*MEM_REFCOUNT(ptr) += 1;
}
return new_ptr;
}
void * mem_dup (void * ptr) {
return _mem_dup(ptr, 1);
}
void * mem_resize (void * ptr, const size_t len) {
void * new_ptr = NULL;
if (ptr == NULL && len < 0) { return NULL; }
if (ptr == NULL && len > 0) { return mem_alloc(len); }
if (ptr != NULL && len == 0) { mem_free(ptr); return NULL; }
new_ptr = mem_alloc(len);
if (*MEM_PARENT(ptr) != NULL) {
*MEM_PARENT(new_ptr) = *MEM_PARENT(ptr);
/* increase reference count of parent because ptr and new_ptr are
distinct child of *MEM_PARENT(ptr). */
*MEM_REFCOUNT(*MEM_PARENT(ptr)) += 1;
}
if (*MEM_LENGTH(new_ptr) <= *MEM_LENGTH(ptr)) {
memcpy(new_ptr, ptr, *MEM_LENGTH(new_ptr));
} else {
memcpy(new_ptr, ptr, *MEM_LENGTH(ptr));
}
mem_free(ptr);
return new_ptr;
}
void * mem_mine (void * ptr) {
if (ptr == NULL) { return NULL; }
if (*MEM_REFCOUNT(ptr) > 1) {
*MEM_REFCOUNT(ptr) -= 1;
return mem_dup(ptr);
} else {
return (void *)ptr;
}
}
void * mem_reset (void * ptr) {
void * parent = NULL;
if (ptr == NULL) { return NULL; }
if (*MEM_PARENT(ptr) != NULL) {
parent = *MEM_PARENT(ptr);
mem_free(ptr);
if (*MEM_REFCOUNT(parent) + 1 < MEM_REFCOUNT_MAX) {
*MEM_REFCOUNT(parent) += 1;
} else {
parent = _mem_dup(parent, 0);
}
} else {
parent = ptr;
}
return parent;
}
| 27.034483 | 128 | 0.623469 |
3a264da0ee962072d9726d253bd40528152604c9 | 4,757 | h | C | src/doc/dox_comments/header_files/chacha20_poly1305.h | djp952/prebuilt-wolfssl | b3df82d34af6c71eef47bbd22931b049e13beac4 | [
"AML"
] | 1 | 2022-03-17T13:34:08.000Z | 2022-03-17T13:34:08.000Z | src/doc/dox_comments/header_files/chacha20_poly1305.h | djp952/prebuilt-wolfssl | b3df82d34af6c71eef47bbd22931b049e13beac4 | [
"AML"
] | null | null | null | src/doc/dox_comments/header_files/chacha20_poly1305.h | djp952/prebuilt-wolfssl | b3df82d34af6c71eef47bbd22931b049e13beac4 | [
"AML"
] | null | null | null | /*!
\ingroup ChaCha20Poly1305
\brief This function encrypts an input message, inPlaintext, using the
ChaCha20 stream cipher, into the output buffer, outCiphertext. It
also performs Poly-1305 authentication (on the cipher text), and
stores the generated authentication tag in the output buffer, outAuthTag.
\return 0 Returned upon successfully encrypting the message
\return BAD_FUNC_ARG returned if there is an error during the encryption
process
\param inKey pointer to a buffer containing the 32 byte key to use
for encryption
\param inIv pointer to a buffer containing the 12 byte iv to use for
encryption
\param inAAD pointer to the buffer containing arbitrary length additional
authenticated data (AAD)
\param inAADLen length of the input AAD
\param inPlaintext pointer to the buffer containing the plaintext to
encrypt
\param inPlaintextLen the length of the plain text to encrypt
\param outCiphertext pointer to the buffer in which to store the ciphertext
\param outAuthTag pointer to a 16 byte wide buffer in which to store the
authentication tag
_Example_
\code
byte key[] = { // initialize 32 byte key };
byte iv[] = { // initialize 12 byte key };
byte inAAD[] = { // initialize AAD };
byte plain[] = { // initialize message to encrypt };
byte cipher[sizeof(plain)];
byte authTag[16];
int ret = wc_ChaCha20Poly1305_Encrypt(key, iv, inAAD, sizeof(inAAD),
plain, sizeof(plain), cipher, authTag);
if(ret != 0) {
// error running encrypt
}
\endcode
\sa wc_ChaCha20Poly1305_Decrypt
\sa wc_ChaCha_*
\sa wc_Poly1305*
*/
WOLFSSL_API
int wc_ChaCha20Poly1305_Encrypt(
const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
const byte* inAAD, const word32 inAADLen,
const byte* inPlaintext, const word32 inPlaintextLen,
byte* outCiphertext,
byte outAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE]);
/*!
\ingroup ChaCha20Poly1305
\brief This function decrypts input ciphertext, inCiphertext, using the
ChaCha20 stream cipher, into the output buffer, outPlaintext. It also
performs Poly-1305 authentication, comparing the given inAuthTag to an
authentication generated with the inAAD (arbitrary length additional
authentication data). Note: If the generated authentication tag does
not match the supplied authentication tag, the text is not decrypted.
\return 0 Returned upon successfully decrypting the message
\return BAD_FUNC_ARG Returned if any of the function arguments do not
match what is expected
\return MAC_CMP_FAILED_E Returned if the generated authentication tag
does not match the supplied inAuthTag.
\param inKey pointer to a buffer containing the 32 byte key to use for
decryption
\param inIv pointer to a buffer containing the 12 byte iv to use for
decryption
\param inAAD pointer to the buffer containing arbitrary length additional
authenticated data (AAD)
\param inAADLen length of the input AAD
\param inCiphertext pointer to the buffer containing the ciphertext to
decrypt
\param outCiphertextLen the length of the ciphertext to decrypt
\param inAuthTag pointer to the buffer containing the 16 byte digest
for authentication
\param outPlaintext pointer to the buffer in which to store the plaintext
_Example_
\code
byte key[] = { // initialize 32 byte key };
byte iv[] = { // initialize 12 byte key };
byte inAAD[] = { // initialize AAD };
byte cipher[] = { // initialize with received ciphertext };
byte authTag[16] = { // initialize with received authentication tag };
byte plain[sizeof(cipher)];
int ret = wc_ChaCha20Poly1305_Decrypt(key, iv, inAAD, sizeof(inAAD),
cipher, sizeof(cipher), plain, authTag);
if(ret == MAC_CMP_FAILED_E) {
// error during authentication
} else if( ret != 0) {
// error with function arguments
}
\endcode
\sa wc_ChaCha20Poly1305_Encrypt
\sa wc_ChaCha_*
\sa wc_Poly1305*
*/
WOLFSSL_API
int wc_ChaCha20Poly1305_Decrypt(
const byte inKey[CHACHA20_POLY1305_AEAD_KEYSIZE],
const byte inIV[CHACHA20_POLY1305_AEAD_IV_SIZE],
const byte* inAAD, const word32 inAADLen,
const byte* inCiphertext, const word32 inCiphertextLen,
const byte inAuthTag[CHACHA20_POLY1305_AEAD_AUTHTAG_SIZE],
byte* outPlaintext);
| 39.31405 | 80 | 0.686147 |
b1f40c6dd80f545a962673966f1103d929b6857c | 174 | h | C | Example/Pods/Target Support Files/Pods-UIMessageView_Example/Pods-UIMessageView_Example-umbrella.h | AppEaseLtd/UIMessageView | c082f1c529509fbbac018109b296abfcab1e49c4 | [
"MIT"
] | null | null | null | Example/Pods/Target Support Files/Pods-UIMessageView_Example/Pods-UIMessageView_Example-umbrella.h | AppEaseLtd/UIMessageView | c082f1c529509fbbac018109b296abfcab1e49c4 | [
"MIT"
] | null | null | null | Example/Pods/Target Support Files/Pods-UIMessageView_Example/Pods-UIMessageView_Example-umbrella.h | AppEaseLtd/UIMessageView | c082f1c529509fbbac018109b296abfcab1e49c4 | [
"MIT"
] | null | null | null | #import <UIKit/UIKit.h>
FOUNDATION_EXPORT double Pods_UIMessageView_ExampleVersionNumber;
FOUNDATION_EXPORT const unsigned char Pods_UIMessageView_ExampleVersionString[];
| 24.857143 | 80 | 0.873563 |
0dd4b8477d2df5734f2dc670342635d6f889b41e | 3,089 | h | C | MAX30105.h | metanav/AVRIoT.X | f44adaca6dbdf5222b91116cfaf4510859fb2d1e | [
"MIT"
] | 1 | 2022-02-13T15:40:36.000Z | 2022-02-13T15:40:36.000Z | MAX30105.h | metanav/AVRIoT.X | f44adaca6dbdf5222b91116cfaf4510859fb2d1e | [
"MIT"
] | null | null | null | MAX30105.h | metanav/AVRIoT.X | f44adaca6dbdf5222b91116cfaf4510859fb2d1e | [
"MIT"
] | null | null | null | /*
* File: MAX30105.h
* Author: naveen
*
* Created on January 3, 2021, 7:46 PM
*/
#ifndef MAX30105_H
#define MAX30105_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include "i2c_simple_master.h"
#include "delay.h"
#include "time_service.h"
# include <string.h>
// OK
#define MAX30105_ADDRESS 0x57 //7-bit I2C Address
#define I2C_SPEED_STANDARD 100000
#define I2C_SPEED_FAST 400000
#define STORAGE_SIZE 4 //Each long is 4 bytes so limit this to fit on your micro
#define I2C_BUFFER_LENGTH 32
bool MAX30105_begin();
uint32_t MAX30105_getRed(void); //Returns immediate red value
uint32_t MAX30105_getIR(void); //Returns immediate IR value
uint32_t MAX30105_getGreen(void); //Returns immediate green value
bool MAX30105_safeCheck(uint8_t maxTimeToCheck); //Given a max amount of time, check for new data
void MAX30105_bitMask(uint8_t reg, uint8_t mask, uint8_t thing);
// Configuration
void MAX30105_softReset();
void MAX30105_setLEDMode(uint8_t mode);
void MAX30105_setADCRange(uint8_t adcRange);
void MAX30105_setSampleRate(uint8_t sampleRate);
void MAX30105_setPulseWidth(uint8_t pulseWidth);
void MAX30105_setPulseAmplitudeRed(uint8_t value);
void MAX30105_setPulseAmplitudeIR(uint8_t value);
void MAX30105_setPulseAmplitudeGreen(uint8_t value);
void MAX30105_setPulseAmplitudeProximity(uint8_t value);
//FIFO Configuration
void MAX30105_setFIFOAverage(uint8_t samples);
void MAX30105_enableFIFORollover();
void MAX30105_disableFIFORollover();
void MAX30105_setFIFOAlmostFull(uint8_t samples);
//FIFO Reading
uint16_t MAX30105_check(void); //Checks for new data and fills FIFO
uint8_t MAX30105_available(void); //Tells caller how many new samples are available (head - tail)
void MAX30105_nextSample(void); //Advances the tail of the sense array
uint32_t MAX30105_getFIFORed(void); //Returns the FIFO sample pointed to by tail
uint32_t MAX30105_getFIFOIR(void); //Returns the FIFO sample pointed to by tail
uint32_t MAX30105_getFIFOGreen(void); //Returns the FIFO sample pointed to by tail
uint8_t MAX30105_getWritePointer(void);
uint8_t MAX30105_getReadPointer(void);
void MAX30105_clearFIFO(void); //Sets the read/write pointers to zero
// Detecting ID/Revision
uint8_t MAX30105_getRevisionID();
uint8_t MAX30105_readPartID();
// Setup the IC with user selectable settings
void MAX30105_setup(uint8_t powerLevel, uint8_t sampleAverage, uint8_t ledMode, int sampleRate, int pulseWidth, int adcRange);
//activeLEDs is the number of channels turned on, and can be 1 to 3. 2 is common for Red+IR.
uint8_t MAX30105_activeLEDs; //Gets set during setup. Allows check() to calculate how many bytes to read from FIFO
uint8_t MAX30105_revisionID;
void MAX30105_readRevisionID();
typedef struct MAX30105_Record
{
uint32_t red[STORAGE_SIZE];
uint32_t IR[STORAGE_SIZE];
uint32_t green[STORAGE_SIZE];
uint8_t head;
uint8_t tail;
} MAX30105_sense_struct; //This is our circular buffer of readings from the sensor
MAX30105_sense_struct MAX30105_sense;
#ifdef __cplusplus
}
#endif
#endif /* MAX30105_H */
| 31.845361 | 126 | 0.791195 |
3d8083712031350e0a58ab87c3108d2dd6ce0ff6 | 1,129 | h | C | mac/TeamTalk/preference/DDOptionsBase.h | cuiguanghui/Team-Talk | 829eaa9293c17bb12b177a5fa5b1c1072c0b183e | [
"Apache-2.0"
] | 368 | 2019-05-07T08:25:00.000Z | 2022-03-31T07:23:55.000Z | mac/TeamTalk/preference/DDOptionsBase.h | cuiguanghui/Team-Talk | 829eaa9293c17bb12b177a5fa5b1c1072c0b183e | [
"Apache-2.0"
] | 5 | 2019-12-09T08:25:07.000Z | 2022-01-27T08:21:13.000Z | mac/TeamTalk/preference/DDOptionsBase.h | cuiguanghui/Team-Talk | 829eaa9293c17bb12b177a5fa5b1c1072c0b183e | [
"Apache-2.0"
] | 256 | 2019-05-08T04:14:59.000Z | 2022-03-28T07:02:30.000Z | //
// DDOptionsBase.h
// Duoduo
//
// Created by zuoye on 14-2-17.
// Copyright (c) 2014年 zuoye. All rights reserved.
//
@interface DDOptionsBase : NSObject{
NSString *filename;
NSMutableDictionary *storage;
}
-(DDOptionsBase *)initWithFileName:(NSString *)fileName;
-(void)save;
-(BOOL)readBoolValueForKey:(NSString *)key;
-(BOOL)readBoolValueForKey:(NSString *)key defaultValue:(BOOL)value;
-(void)writeBoolValue:(BOOL)value forKey:(NSString *)key;
-(int16_t)readUInt16ValueForKey:(NSString *)key ;
-(int16_t)readUInt16ValueForKey:(NSString *)key defaultValue: (unsigned short) value;
-(void)writeUInt16Value:(NSUInteger)uintValue forKey:(NSString *)key;
-(int32_t)readUInt32ValueForKey:(NSString *)key;
-(int32_t)readUInt32ValueForKey:(NSString *)key defaultValue:(int32_t)value;
-(void)writeUInt32Value:(unsigned int)value forKey:(NSString *)key;
-(NSString*)readStringForKey:(NSString *)key;
-(void)writeString:(NSString *)obj forKey:(NSString *)key;
-(void)writeObject:(id)obj forKey:(NSString *)key;
-(void)writeNSData:(NSData *)da forKey:(NSString *)key;
-(NSData *)readNSDataForKey:(NSString *)key;
@end
| 34.212121 | 85 | 0.749336 |
c0931dc0daf6ed974c4115ccfa01b46128dcde00 | 4,102 | h | C | vendor/newrelic/axiom/nr_rules.h | robertprast/c-sdk | fe05ae84e4fe9caaae9c8f5bfaaeb31efba4d566 | [
"Apache-2.0"
] | 60 | 2019-04-23T17:13:42.000Z | 2022-02-11T21:47:49.000Z | vendor/newrelic/axiom/nr_rules.h | robertprast/c-sdk | fe05ae84e4fe9caaae9c8f5bfaaeb31efba4d566 | [
"Apache-2.0"
] | 32 | 2019-04-23T17:54:58.000Z | 2022-02-11T21:40:54.000Z | vendor/newrelic/axiom/nr_rules.h | robertprast/c-sdk | fe05ae84e4fe9caaae9c8f5bfaaeb31efba4d566 | [
"Apache-2.0"
] | 29 | 2019-04-23T17:54:00.000Z | 2022-02-18T17:12:21.000Z | /*
* This file contains structures and functions for URL rules, metrics rules,
* and transaction name rules.
*/
#ifndef NR_RULES_HDR
#define NR_RULES_HDR
#include <stdint.h>
#include "util_object.h"
typedef struct _nrrules_t nrrules_t;
/*
* Rule Flags
*/
#define NR_RULE_EACH_SEGMENT 0x00000001 /* Match each segment */
#define NR_RULE_IGNORE 0x00000002 /* Ignore this URL */
#define NR_RULE_REPLACE_ALL \
0x00000004 /* Replace entire metric with substitution */
#define NR_RULE_TERMINATE \
0x00000008 /* Terminate the rule chain if this rule applied */
#define NR_RULE_HAS_ALTS 0x00000010 /* Does this rule have | alternatives */
#define NR_RULE_HAS_CAPTURES \
0x00000020 /* Does this rule have \0-9 captures \
*/
/*
* If New Relic's backend does not specify an eval_order for a rule,
* we'll use this one.
*/
#define NR_RULE_DEFAULT_ORDER 99999
/*
* Purpose : Create a new rules table, with enough initial space for the given
* number of rules.
*
* Params : 1. The number of rules to initially allocate space for.
*
* Returns : A pointer to the newly created table or NULL on error.
*
* Notes : The argument provided can be used when the number of rules is
* known in advance. If rules beyond this number are added, the add
* function will extend the array 8 rules at a time.
*/
extern nrrules_t* nr_rules_create(int num);
/*
* Purpose : Create a new rules table from a generic object.
*
* Returns : A pointer to the newly created rules or NULL on error.
*/
extern nrrules_t* nr_rules_create_from_obj(const nrobj_t* obj);
/*
* Purpose : Destroy an existing rules table, releasing all resources.
*
* Params : 1. A pointer to the return of nr_rules_create() above.
*
* Returns : Nothing.
*
* Notes : Will set the variable that the argument points to to NULL after it
* has done its work.
*/
extern void nr_rules_destroy(nrrules_t** rules_p);
/*
* Purpose : Add a new rule to a rule table.
*
* Params : 1. The rule table to add the rule to.
* 2. The flags for this rule (see NR_RULE_* above).
* 3. The rule processing order.
* 4. The string to match.
* 5. The replacement string. Required unless the IGNORE flag is set.
*
* Returns : NR_SUCCESS or NR_FAILURE.
*
* Notes : Flags like NR_RULE_HAS_ALTS and NR_RULE_HAS_CAPTURES are important
* for speed purposes when the rules are being processed.
*/
extern nr_status_t nr_rules_add(nrrules_t* rules,
uint32_t flags,
int order,
const char* match,
const char* repl);
/*
* Purpose : Sort the rules table in rule processing order.
*
* Params : 1. The rule table to sort.
*
* Returns : Nothing.
*
* Notes : After adding 1 or more rules to a table, before it can be used the
* table must be sorted, according to the rule processing order field.
* If two rules have the same processing order field their exact
* ordering within the table is indeterminate and random. However,
* lower numbered rules will always appear before any higher numbered
* rule.
*/
extern void nr_rules_sort(nrrules_t* rules);
/*
* Purpose : Apply rules to a string.
*
* Params : 1. The rules to apply.
* 2. The input string.
* 3. Pointer to location to return changed string. Optional.
*
* Returns : One of the nr_rules_result_t values. If NR_RULES_RESULT_CHANGED
* is returned, then a malloc-ed string with the changed result will
* be returned through the 'new_name' parameter.
*/
typedef enum _nr_rules_result_t {
NR_RULES_RESULT_IGNORE = 1,
NR_RULES_RESULT_UNCHANGED = 2,
NR_RULES_RESULT_CHANGED = 3
} nr_rules_result_t;
extern nr_rules_result_t nr_rules_apply(const nrrules_t* rules,
const char* name,
char** new_name);
#endif /* NR_RULES_HDR */
| 32.816 | 80 | 0.654315 |
dbc81e6428aa7140bf529de338d40c4d1e84bec7 | 278 | h | C | Classes_Android/GameOver.h | OscarLeif/Parkour | 43181fd8cb87bc236db1d7aa7170993182f925b5 | [
"Apache-2.0"
] | 4 | 2016-01-03T16:19:39.000Z | 2021-01-14T06:25:23.000Z | Classes_Android/GameOver.h | OscarLeif/Parkour | 43181fd8cb87bc236db1d7aa7170993182f925b5 | [
"Apache-2.0"
] | null | null | null | Classes_Android/GameOver.h | OscarLeif/Parkour | 43181fd8cb87bc236db1d7aa7170993182f925b5 | [
"Apache-2.0"
] | 5 | 2016-03-16T08:13:41.000Z | 2021-05-27T16:15:32.000Z | #ifndef __GameOver__H__
#define __GameOver__H__
#include "cocos2d.h"
USING_NS_CC;
class GameOver : cocos2d::Layer{
public:
virtual bool init();
static cocos2d::Scene* scene();
CREATE_FUNC(GameOver);
void createBG();
void reStart(cocos2d::Object *sneder);
};/**/
#endif | 15.444444 | 39 | 0.730216 |
a361496e25720b5f8cf56f7e06dabaa3689bc4f5 | 5,334 | c | C | release/src-rt-6.x.4708/router/nfs-utils/support/misc/tcpwrapper.c | afeng11/tomato-arm | 1ca18a88480b34fd495e683d849f46c2d47bb572 | [
"FSFAP"
] | 278 | 2015-11-03T03:01:20.000Z | 2022-01-20T18:21:05.000Z | release/src-rt-6.x.4708/router/nfs-utils/support/misc/tcpwrapper.c | afeng11/tomato-arm | 1ca18a88480b34fd495e683d849f46c2d47bb572 | [
"FSFAP"
] | 374 | 2015-11-03T12:37:22.000Z | 2021-12-17T14:18:08.000Z | release/src-rt-6.x.4708/router/nfs-utils/support/misc/tcpwrapper.c | afeng11/tomato-arm | 1ca18a88480b34fd495e683d849f46c2d47bb572 | [
"FSFAP"
] | 96 | 2015-11-22T07:47:26.000Z | 2022-01-20T19:52:19.000Z | /* This is copied from portmap 4.0-29 in RedHat. */
/*
* pmap_check - additional portmap security.
*
* Always reject non-local requests to update the portmapper tables.
*
* Refuse to forward mount requests to the nfs mount daemon. Otherwise, the
* requests would appear to come from the local system, and nfs export
* restrictions could be bypassed.
*
* Refuse to forward requests to the nfsd process.
*
* Refuse to forward requests to NIS (YP) daemons; The only exception is the
* YPPROC_DOMAIN_NONACK broadcast rpc call that is used to establish initial
* contact with the NIS server.
*
* Always allocate an unprivileged port when forwarding a request.
*
* If compiled with -DCHECK_PORT, require that requests to register or
* unregister a privileged port come from a privileged port. This makes it
* more difficult to replace a critical service by a trojan.
*
* If compiled with -DHOSTS_ACCESS, reject requests from hosts that are not
* authorized by the /etc/hosts.{allow,deny} files. The local system is
* always treated as an authorized host. The access control tables are never
* consulted for requests from the local system, and are always consulted
* for requests from other hosts.
*
* Author: Wietse Venema (wietse@wzv.win.tue.nl), dept. of Mathematics and
* Computing Science, Eindhoven University of Technology, The Netherlands.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_LIBWRAP
#include <tcpwrapper.h>
#include <unistd.h>
#include <string.h>
#include <rpc/rpc.h>
#include <rpc/pmap_prot.h>
#include <syslog.h>
#include <netdb.h>
#include <pwd.h>
#include <sys/types.h>
#include <sys/signal.h>
#include <sys/queue.h>
#include <sys/stat.h>
#include <tcpd.h>
#include "xlog.h"
#ifdef SYSV40
#include <netinet/in.h>
#include <rpc/rpcent.h>
#endif
static void logit(int severity, struct sockaddr_in *addr,
u_long procnum, u_long prognum, char *text);
static int check_files(void);
#define log_bad_host(addr, proc, prog) \
logit(LOG_WARNING, addr, proc, prog, "request from unauthorized host")
#define ALLOW 1
#define DENY 0
typedef struct _haccess_t {
TAILQ_ENTRY(_haccess_t) list;
int access;
struct in_addr addr;
} haccess_t;
#define HASH_TABLE_SIZE 1021
typedef struct _hash_head {
TAILQ_HEAD(host_list, _haccess_t) h_head;
} hash_head;
hash_head haccess_tbl[HASH_TABLE_SIZE];
static haccess_t *haccess_lookup(struct sockaddr_in *addr, u_long);
static void haccess_add(struct sockaddr_in *addr, u_long, int);
inline unsigned int strtoint(char *str)
{
unsigned int n = 0;
int len = strlen(str);
int i;
for (i=0; i < len; i++)
n+=((int)str[i])*i;
return n;
}
static inline int hashint(unsigned int num)
{
return num % HASH_TABLE_SIZE;
}
#define HASH(_addr, _prog) \
hashint((strtoint((_addr))+(_prog)))
void haccess_add(struct sockaddr_in *addr, u_long prog, int access)
{
hash_head *head;
haccess_t *hptr;
int hash;
hptr = (haccess_t *)malloc(sizeof(haccess_t));
if (hptr == NULL)
return;
hash = HASH(inet_ntoa(addr->sin_addr), prog);
head = &(haccess_tbl[hash]);
hptr->access = access;
hptr->addr.s_addr = addr->sin_addr.s_addr;
if (TAILQ_EMPTY(&head->h_head))
TAILQ_INSERT_HEAD(&head->h_head, hptr, list);
else
TAILQ_INSERT_TAIL(&head->h_head, hptr, list);
}
haccess_t *haccess_lookup(struct sockaddr_in *addr, u_long prog)
{
hash_head *head;
haccess_t *hptr;
int hash;
hash = HASH(inet_ntoa(addr->sin_addr), prog);
head = &(haccess_tbl[hash]);
TAILQ_FOREACH(hptr, &head->h_head, list) {
if (hptr->addr.s_addr == addr->sin_addr.s_addr)
return hptr;
}
return NULL;
}
int
good_client(daemon, addr)
char *daemon;
struct sockaddr_in *addr;
{
struct request_info req;
request_init(&req, RQ_DAEMON, daemon, RQ_CLIENT_SIN, addr, 0);
sock_methods(&req);
if (hosts_access(&req))
return ALLOW;
return DENY;
}
/* check_files - check to see if either access files have changed */
static int check_files()
{
static time_t allow_mtime, deny_mtime;
struct stat astat, dstat;
int changed = 0;
if (stat("/etc/hosts.allow", &astat) < 0)
astat.st_mtime = 0;
if (stat("/etc/hosts.deny", &dstat) < 0)
dstat.st_mtime = 0;
if(!astat.st_mtime || !dstat.st_mtime)
return changed;
if (astat.st_mtime != allow_mtime)
changed = 1;
else if (dstat.st_mtime != deny_mtime)
changed = 1;
allow_mtime = astat.st_mtime;
deny_mtime = dstat.st_mtime;
return changed;
}
/* check_default - additional checks for NULL, DUMP, GETPORT and unknown */
int
check_default(daemon, addr, proc, prog)
char *daemon;
struct sockaddr_in *addr;
u_long proc;
u_long prog;
{
haccess_t *acc = NULL;
int changed = check_files();
acc = haccess_lookup(addr, prog);
if (acc && changed == 0)
return (acc->access);
if (!(from_local(addr) || good_client(daemon, addr))) {
log_bad_host(addr, proc, prog);
if (acc)
acc->access = FALSE;
else
haccess_add(addr, prog, FALSE);
return (FALSE);
}
if (acc)
acc->access = TRUE;
else
haccess_add(addr, prog, TRUE);
return (TRUE);
}
/* logit - report events of interest via the syslog daemon */
static void logit(int severity, struct sockaddr_in *addr,
u_long procnum, u_long prognum, char *text)
{
syslog(severity, "connect from %s denied: %s",
inet_ntoa(addr->sin_addr), text);
}
#endif
| 23.919283 | 77 | 0.710536 |
ed74a33129d58d9974664ff29fe9bf0b67e41056 | 551 | h | C | Example/Pods/Target Support Files/WLCategories/WLCategories-umbrella.h | Nomeqc/WLCategories | 20d98efa1c2af12883c4679400cffb915b38611d | [
"MIT"
] | null | null | null | Example/Pods/Target Support Files/WLCategories/WLCategories-umbrella.h | Nomeqc/WLCategories | 20d98efa1c2af12883c4679400cffb915b38611d | [
"MIT"
] | null | null | null | Example/Pods/Target Support Files/WLCategories/WLCategories-umbrella.h | Nomeqc/WLCategories | 20d98efa1c2af12883c4679400cffb915b38611d | [
"MIT"
] | null | null | null | #ifdef __OBJC__
#import <UIKit/UIKit.h>
#else
#ifndef FOUNDATION_EXPORT
#if defined(__cplusplus)
#define FOUNDATION_EXPORT extern "C"
#else
#define FOUNDATION_EXPORT extern
#endif
#endif
#endif
#import "NSArray+WLAdditions.h"
#import "NSObject+WLNotificationObserve.h"
#import "UIAlertController+WLAdditions.h"
#import "UIButton+WLAddition.h"
#import "UILabel+WLAddition.h"
#import "UIView+WLAddition.h"
#import "WLCategories.h"
FOUNDATION_EXPORT double WLCategoriesVersionNumber;
FOUNDATION_EXPORT const unsigned char WLCategoriesVersionString[];
| 22.958333 | 66 | 0.814882 |
81e63960f391c9dfd0bd3ab7c34e2ba43c4b37ee | 15,306 | c | C | kernel/kernel-4.9/drivers/iio/imu/inv_mpu/dmpDefaultMPU6050.c | rubedos/l4t_R32.5.1_viper | 6aed0062084d9031546f946e63fc74303555e0a6 | [
"MIT"
] | null | null | null | kernel/kernel-4.9/drivers/iio/imu/inv_mpu/dmpDefaultMPU6050.c | rubedos/l4t_R32.5.1_viper | 6aed0062084d9031546f946e63fc74303555e0a6 | [
"MIT"
] | null | null | null | kernel/kernel-4.9/drivers/iio/imu/inv_mpu/dmpDefaultMPU6050.c | rubedos/l4t_R32.5.1_viper | 6aed0062084d9031546f946e63fc74303555e0a6 | [
"MIT"
] | null | null | null | /*
* Copyright (C) 2012 Invensense, Inc.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* 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.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include "inv_mpu_iio.h"
#include "dmpKey.h"
#include "dmpmap.h"
#define CFG_OUT_PRESS (1823)
#define CFG_PED_ENABLE (1936)
#define CFG_OUT_GYRO (1755)
#define CFG_PEDSTEP_DET (2417)
#define OUT_GYRO_DAT (1764)
#define CFG_FIFO_INT (1934)
#define OUT_CPASS_DAT (1798)
#define CFG_AUTH (1051)
#define OUT_ACCL_DAT (1730)
#define FCFG_1 (1078)
#define FCFG_3 (1103)
#define FCFG_2 (1082)
#define CFG_OUT_CPASS (1789)
#define FCFG_7 (1089)
#define CFG_OUT_3QUAT (1617)
#define OUT_PRESS_DAT (1832)
#define OUT_3QUAT_DAT (1627)
#define CFG_7 (1300)
#define OUT_PQUAT_DAT (1696)
#define CFG_OUT_6QUAT (1652)
#define CFG_PED_INT (2406)
#define SMD_TP2 (1265)
#define SMD_TP1 (1244)
#define CFG_MOTION_BIAS (1302)
#define CFG_OUT_ACCL (1721)
#define CFG_OUT_STEPDET (1587)
#define OUT_6QUAT_DAT (1662)
#define CFG_OUT_PQUAT (1687)
#define D_0_22 (22+512)
#define D_0_24 (24+512)
#define D_0_36 (36)
#define D_0_52 (52)
#define D_0_96 (96)
#define D_0_104 (104)
#define D_0_108 (108)
#define D_0_163 (163)
#define D_0_188 (188)
#define D_0_192 (192)
#define D_0_224 (224)
#define D_0_228 (228)
#define D_0_232 (232)
#define D_0_236 (236)
#define D_1_2 (256 + 2)
#define D_1_4 (256 + 4)
#define D_1_8 (256 + 8)
#define D_1_10 (256 + 10)
#define D_1_24 (256 + 24)
#define D_1_28 (256 + 28)
#define D_1_36 (256 + 36)
#define D_1_40 (256 + 40)
#define D_1_44 (256 + 44)
#define D_1_72 (256 + 72)
#define D_1_74 (256 + 74)
#define D_1_79 (256 + 79)
#define D_1_88 (256 + 88)
#define D_1_90 (256 + 90)
#define D_1_92 (256 + 92)
#define D_1_96 (256 + 96)
#define D_1_98 (256 + 98)
#define D_1_106 (256 + 106)
#define D_1_108 (256 + 108)
#define D_1_112 (256 + 112)
#define D_1_128 (256 + 144)
#define D_1_152 (256 + 12)
#define D_1_160 (256 + 160)
#define D_1_176 (256 + 176)
#define D_1_178 (256 + 178)
#define D_1_218 (256 + 218)
#define D_1_232 (256 + 232)
#define D_1_236 (256 + 236)
#define D_1_240 (256 + 240)
#define D_1_244 (256 + 244)
#define D_1_250 (256 + 250)
#define D_1_252 (256 + 252)
#define D_2_12 (512 + 12)
#define D_2_96 (512 + 96)
#define D_2_108 (512 + 108)
#define D_2_208 (512 + 208)
#define D_2_224 (512 + 224)
#define D_2_236 (512 + 236)
#define D_2_244 (512 + 244)
#define D_2_248 (512 + 248)
#define D_2_252 (512 + 252)
#define CPASS_BIAS_X (30 * 16 + 4)
#define CPASS_BIAS_Y (30 * 16 + 8)
#define CPASS_BIAS_Z (30 * 16 + 12)
#define CPASS_MTX_00 (32 * 16 + 4)
#define CPASS_MTX_01 (32 * 16 + 8)
#define CPASS_MTX_02 (36 * 16 + 12)
#define CPASS_MTX_10 (33 * 16)
#define CPASS_MTX_11 (33 * 16 + 4)
#define CPASS_MTX_12 (33 * 16 + 8)
#define CPASS_MTX_20 (33 * 16 + 12)
#define CPASS_MTX_21 (34 * 16 + 4)
#define CPASS_MTX_22 (34 * 16 + 8)
#define D_EXT_GYRO_BIAS_X (61 * 16)
#define D_EXT_GYRO_BIAS_Y (61 * 16 + 4)
#define D_EXT_GYRO_BIAS_Z (61 * 16 + 8)
#define D_ACT0 (40 * 16)
#define D_ACSX (40 * 16 + 4)
#define D_ACSY (40 * 16 + 8)
#define D_ACSZ (40 * 16 + 12)
#define FLICK_MSG (45 * 16 + 4)
#define FLICK_COUNTER (45 * 16 + 8)
#define FLICK_LOWER (45 * 16 + 12)
#define FLICK_UPPER (46 * 16 + 12)
#define D_SMD_ENABLE (18 * 16)
#define D_SMD_MOT_THLD (21 * 16 + 8)
#define D_SMD_DELAY_THLD (21 * 16 + 4)
#define D_SMD_DELAY2_THLD (21 * 16 + 12)
#define D_SMD_EXE_STATE (22 * 16)
#define D_SMD_DELAY_CNTR (21 * 16)
#define D_WF_GESTURE_TIME_THRSH (25 * 16 + 8)
#define D_WF_GESTURE_TILT_ERROR (25 * 16 + 12)
#define D_WF_GESTURE_TILT_THRSH (26 * 16 + 8)
#define D_WF_GESTURE_TILT_REJECT_THRSH (26 * 16 + 12)
#define D_AUTH_OUT (992)
#define D_AUTH_IN (996)
#define D_AUTH_A (1000)
#define D_AUTH_B (1004)
#define D_PEDSTD_BP_B (768 + 0x1C)
#define D_PEDSTD_BP_A4 (768 + 0x40)
#define D_PEDSTD_BP_A3 (768 + 0x44)
#define D_PEDSTD_BP_A2 (768 + 0x48)
#define D_PEDSTD_BP_A1 (768 + 0x4C)
#define D_PEDSTD_SB (768 + 0x28)
#define D_PEDSTD_SB_TIME (768 + 0x2C)
#define D_PEDSTD_PEAKTHRSH (768 + 0x98)
#define D_PEDSTD_TIML (768 + 0x2A)
#define D_PEDSTD_TIMH (768 + 0x2E)
#define D_PEDSTD_PEAK (768 + 0X94)
#define D_PEDSTD_STEPCTR (768 + 0x60)
#define D_PEDSTD_STEPCTR2 (58 * 16 + 8)
#define D_PEDSTD_TIMECTR (964)
#define D_PEDSTD_DECI (768 + 0xA0)
#define D_PEDSTD_SB2 (60 * 16 + 14)
#define D_STPDET_TIMESTAMP (28 * 16 + 8)
#define D_PEDSTD_DRIVE_STATE (58)
#define D_HOST_NO_MOT (976)
#define D_ACCEL_BIAS (660)
#define D_BM_BATCH_CNTR (27 * 16 + 4)
#define D_BM_BATCH_THLD (27 * 16 + 12)
#define D_BM_ENABLE (28 * 16 + 6)
#define D_BM_NUMWORD_TOFILL (28 * 16 + 4)
#define D_SO_DATA (4 * 16 + 2)
#define D_P_HW_ID (22 * 16 + 10)
#define D_P_INIT (22 * 16 + 2)
#define D_DMP_RUN_CNTR (24*16)
#define D_ODR_S0 (45*16+8)
#define D_ODR_S1 (45*16+12)
#define D_ODR_S2 (45*16+10)
#define D_ODR_S3 (45*16+14)
#define D_ODR_S4 (46*16+8)
#define D_ODR_S5 (46*16+12)
#define D_ODR_S6 (46*16+10)
#define D_ODR_S7 (46*16+14)
#define D_ODR_S8 (42*16+8)
#define D_ODR_S9 (42*16+12)
#define D_ODR_CNTR_S0 (45*16)
#define D_ODR_CNTR_S1 (45*16+4)
#define D_ODR_CNTR_S2 (45*16+2)
#define D_ODR_CNTR_S3 (45*16+6)
#define D_ODR_CNTR_S4 (46*16)
#define D_ODR_CNTR_S5 (46*16+4)
#define D_ODR_CNTR_S6 (46*16+2)
#define D_ODR_CNTR_S7 (46*16+6)
#define D_ODR_CNTR_S8 (42*16)
#define D_ODR_CNTR_S9 (42*16+4)
#define D_FS_LPQ0 (59*16)
#define D_FS_LPQ1 (59*16 + 4)
#define D_FS_LPQ2 (59*16 + 8)
#define D_FS_LPQ3 (59*16 + 12)
#define D_FS_Q0 (12*16)
#define D_FS_Q1 (12*16 + 4)
#define D_FS_Q2 (12*16 + 8)
#define D_FS_Q3 (12*16 + 12)
#define D_FS_9Q0 (2*16)
#define D_FS_9Q1 (2*16 + 4)
#define D_FS_9Q2 (2*16 + 8)
#define D_FS_9Q3 (2*16 + 12)
static const struct tKeyLabel dmpTConfig[] = {
{KEY_CFG_OUT_ACCL, CFG_OUT_ACCL},
{KEY_CFG_OUT_GYRO, CFG_OUT_GYRO},
{KEY_CFG_OUT_3QUAT, CFG_OUT_3QUAT},
{KEY_CFG_OUT_6QUAT, CFG_OUT_6QUAT},
{KEY_CFG_OUT_PQUAT, CFG_OUT_PQUAT},
{KEY_CFG_PED_ENABLE, CFG_PED_ENABLE},
{KEY_CFG_FIFO_INT, CFG_FIFO_INT},
{KEY_CFG_AUTH, CFG_AUTH},
{KEY_FCFG_1, FCFG_1},
{KEY_FCFG_3, FCFG_3},
{KEY_FCFG_2, FCFG_2},
{KEY_FCFG_7, FCFG_7},
{KEY_CFG_7, CFG_7},
{KEY_CFG_MOTION_BIAS, CFG_MOTION_BIAS},
{KEY_CFG_PEDSTEP_DET, CFG_PEDSTEP_DET},
{KEY_D_0_22, D_0_22},
{KEY_D_0_96, D_0_96},
{KEY_D_0_104, D_0_104},
{KEY_D_0_108, D_0_108},
{KEY_D_1_36, D_1_36},
{KEY_D_1_40, D_1_40},
{KEY_D_1_44, D_1_44},
{KEY_D_1_72, D_1_72},
{KEY_D_1_74, D_1_74},
{KEY_D_1_79, D_1_79},
{KEY_D_1_88, D_1_88},
{KEY_D_1_90, D_1_90},
{KEY_D_1_92, D_1_92},
{KEY_D_1_160, D_1_160},
{KEY_D_1_176, D_1_176},
{KEY_D_1_218, D_1_218},
{KEY_D_1_232, D_1_232},
{KEY_D_1_250, D_1_250},
{KEY_DMP_SH_TH_Y, DMP_SH_TH_Y},
{KEY_DMP_SH_TH_X, DMP_SH_TH_X},
{KEY_DMP_SH_TH_Z, DMP_SH_TH_Z},
{KEY_DMP_ORIENT, DMP_ORIENT},
{KEY_D_AUTH_OUT, D_AUTH_OUT},
{KEY_D_AUTH_IN, D_AUTH_IN},
{KEY_D_AUTH_A, D_AUTH_A},
{KEY_D_AUTH_B, D_AUTH_B},
{KEY_CPASS_BIAS_X, CPASS_BIAS_X},
{KEY_CPASS_BIAS_Y, CPASS_BIAS_Y},
{KEY_CPASS_BIAS_Z, CPASS_BIAS_Z},
{KEY_CPASS_MTX_00, CPASS_MTX_00},
{KEY_CPASS_MTX_01, CPASS_MTX_01},
{KEY_CPASS_MTX_02, CPASS_MTX_02},
{KEY_CPASS_MTX_10, CPASS_MTX_10},
{KEY_CPASS_MTX_11, CPASS_MTX_11},
{KEY_CPASS_MTX_12, CPASS_MTX_12},
{KEY_CPASS_MTX_20, CPASS_MTX_20},
{KEY_CPASS_MTX_21, CPASS_MTX_21},
{KEY_CPASS_MTX_22, CPASS_MTX_22},
{KEY_D_ACT0, D_ACT0},
{KEY_D_ACSX, D_ACSX},
{KEY_D_ACSY, D_ACSY},
{KEY_D_ACSZ, D_ACSZ},
{KEY_D_PEDSTD_BP_B, D_PEDSTD_BP_B},
{KEY_D_PEDSTD_BP_A4, D_PEDSTD_BP_A4},
{KEY_D_PEDSTD_BP_A3, D_PEDSTD_BP_A3},
{KEY_D_PEDSTD_BP_A2, D_PEDSTD_BP_A2},
{KEY_D_PEDSTD_BP_A1, D_PEDSTD_BP_A1},
{KEY_D_PEDSTD_SB, D_PEDSTD_SB},
{KEY_D_PEDSTD_SB_TIME, D_PEDSTD_SB_TIME},
{KEY_D_PEDSTD_PEAKTHRSH, D_PEDSTD_PEAKTHRSH},
{KEY_D_PEDSTD_TIML, D_PEDSTD_TIML},
{KEY_D_PEDSTD_TIMH, D_PEDSTD_TIMH},
{KEY_D_PEDSTD_PEAK, D_PEDSTD_PEAK},
{KEY_D_PEDSTD_STEPCTR, D_PEDSTD_STEPCTR},
{KEY_D_PEDSTD_STEPCTR2, D_PEDSTD_STEPCTR2},
{KEY_D_PEDSTD_TIMECTR, D_PEDSTD_TIMECTR},
{KEY_D_PEDSTD_DECI, D_PEDSTD_DECI},
{KEY_D_PEDSTD_SB2, D_PEDSTD_SB2},
{KEY_D_PEDSTD_DRIVE_STATE, D_PEDSTD_DRIVE_STATE},
{KEY_D_STPDET_TIMESTAMP, D_STPDET_TIMESTAMP},
{KEY_D_HOST_NO_MOT, D_HOST_NO_MOT},
{KEY_D_ACCEL_BIAS, D_ACCEL_BIAS},
{KEY_CFG_EXT_GYRO_BIAS_X, D_EXT_GYRO_BIAS_X},
{KEY_CFG_EXT_GYRO_BIAS_Y, D_EXT_GYRO_BIAS_Y},
{KEY_CFG_EXT_GYRO_BIAS_Z, D_EXT_GYRO_BIAS_Z},
{KEY_CFG_PED_INT, CFG_PED_INT},
{KEY_SMD_ENABLE, D_SMD_ENABLE},
{KEY_SMD_ACCEL_THLD, D_SMD_MOT_THLD},
{KEY_SMD_DELAY_THLD, D_SMD_DELAY_THLD},
{KEY_SMD_DELAY2_THLD, D_SMD_DELAY2_THLD},
{KEY_SMD_ENABLE_TESTPT1, SMD_TP1},
{KEY_SMD_ENABLE_TESTPT2, SMD_TP2},
{KEY_SMD_EXE_STATE, D_SMD_EXE_STATE},
{KEY_SMD_DELAY_CNTR, D_SMD_DELAY_CNTR},
{KEY_BM_ENABLE, D_BM_ENABLE},
{KEY_BM_BATCH_CNTR, D_BM_BATCH_CNTR},
{KEY_BM_BATCH_THLD, D_BM_BATCH_THLD},
{KEY_BM_NUMWORD_TOFILL, D_BM_NUMWORD_TOFILL},
{KEY_SO_DATA, D_SO_DATA},
{KEY_P_INIT, D_P_INIT},
{KEY_CFG_OUT_CPASS, CFG_OUT_CPASS},
{KEY_CFG_OUT_PRESS, CFG_OUT_PRESS},
{KEY_CFG_OUT_STEPDET, CFG_OUT_STEPDET},
{KEY_CFG_3QUAT_ODR, D_ODR_S1},
{KEY_CFG_6QUAT_ODR, D_ODR_S2},
{KEY_CFG_PQUAT6_ODR, D_ODR_S3},
{KEY_CFG_ACCL_ODR, D_ODR_S4},
{KEY_CFG_GYRO_ODR, D_ODR_S5},
{KEY_CFG_CPASS_ODR, D_ODR_S6},
{KEY_CFG_PRESS_ODR, D_ODR_S7},
{KEY_CFG_9QUAT_ODR, D_ODR_S8},
{KEY_CFG_PQUAT9_ODR, D_ODR_S9},
{KEY_ODR_CNTR_3QUAT, D_ODR_CNTR_S1},
{KEY_ODR_CNTR_6QUAT, D_ODR_CNTR_S2},
{KEY_ODR_CNTR_PQUAT, D_ODR_CNTR_S3},
{KEY_ODR_CNTR_ACCL, D_ODR_CNTR_S4},
{KEY_ODR_CNTR_GYRO, D_ODR_CNTR_S5},
{KEY_ODR_CNTR_CPASS, D_ODR_CNTR_S6},
{KEY_ODR_CNTR_PRESS, D_ODR_CNTR_S7},
{KEY_ODR_CNTR_9QUAT, D_ODR_CNTR_S8},
{KEY_ODR_CNTR_PQUAT9, D_ODR_CNTR_S9},
{KEY_DMP_RUN_CNTR, D_DMP_RUN_CNTR},
{KEY_DMP_LPQ0, D_FS_LPQ0},
{KEY_DMP_LPQ1, D_FS_LPQ1},
{KEY_DMP_LPQ2, D_FS_LPQ2},
{KEY_DMP_LPQ3, D_FS_LPQ3},
{KEY_DMP_Q0, D_FS_Q0},
{KEY_DMP_Q1, D_FS_Q1},
{KEY_DMP_Q2, D_FS_Q2},
{KEY_DMP_Q3, D_FS_Q3},
{KEY_DMP_9Q0, D_FS_9Q0},
{KEY_DMP_9Q1, D_FS_9Q1},
{KEY_DMP_9Q2, D_FS_9Q2},
{KEY_DMP_9Q3, D_FS_9Q3},
{KEY_TEST_01, OUT_ACCL_DAT},
{KEY_TEST_02, OUT_GYRO_DAT},
{KEY_TEST_03, OUT_CPASS_DAT},
{KEY_TEST_04, OUT_PRESS_DAT},
{KEY_TEST_05, OUT_3QUAT_DAT},
{KEY_TEST_06, OUT_6QUAT_DAT},
{KEY_TEST_07, OUT_PQUAT_DAT}
};
#define NUM_LOCAL_KEYS (sizeof(dmpTConfig)/sizeof(dmpTConfig[0]))
static struct tKeyLabel keys[NUM_KEYS];
unsigned short inv_dmp_get_address(unsigned short key)
{
static int isSorted;
if (!isSorted) {
int kk;
for (kk = 0; kk < NUM_KEYS; ++kk) {
keys[kk].addr = 0xffff;
keys[kk].key = kk;
}
for (kk = 0; kk < NUM_LOCAL_KEYS; ++kk)
keys[dmpTConfig[kk].key].addr = dmpTConfig[kk].addr;
isSorted = 1;
}
if (key >= NUM_KEYS) {
pr_err("ERROR!! key not exist=%d!\n", key);
return 0xffff;
}
if (0xffff == keys[key].addr)
pr_err("ERROR!!key not local=%d!\n", key);
return keys[key].addr;
}
| 40.068063 | 71 | 0.53626 |
815ad4c9eff5394948c9a757d10dac2925c9a22a | 1,747 | h | C | src/Storages/Sto_EEPROM.h | unicab369/esp_mess | 459ba88355f917c05264abc02ea959b203d7046d | [
"MIT"
] | 1 | 2021-08-17T15:51:44.000Z | 2021-08-17T15:51:44.000Z | src/Storages/Sto_EEPROM.h | unicab369/esp_mess | 459ba88355f917c05264abc02ea959b203d7046d | [
"MIT"
] | null | null | null | src/Storages/Sto_EEPROM.h | unicab369/esp_mess | 459ba88355f917c05264abc02ea959b203d7046d | [
"MIT"
] | null | null | null | #include <EEPROM.h>
#define EEPROM_SIZE 512
void EEPROM_begin() {
EEPROM.begin(EEPROM_SIZE);
}
void EEPROM_WriteBytes(int address, void *value, size_t len) {
byte* val = (byte*) value;
// Serial.print("\n*Write at addr: "); Serial.println(address);
for (byte i=0; i<len; i++) {
EEPROM.write(address+i, val[i]);
// Serial.print("*Write: "); Serial.println(val[i], HEX);
}
}
void EEPROM_ReadBytes(int address, void *value, size_t len) {
byte* val = (byte*) value;
// Serial.print("\n*Read at addr: "); Serial.println(address);
for (byte i=0; i<len; i++) {
byte read = EEPROM.read(address+i);
val[i] = read;
// Serial.print("*Read: "); Serial.println(read, HEX);
}
}
void EEPROM_clearResetCnt() {
int val1 = 1;
int val2 = 0;
EEPROM.write(0, 0xDD);
EEPROM.write(1, 0xDD);
EEPROM_WriteBytes(2, &val1, 2);
EEPROM_WriteBytes(4, &val2, 2);
EEPROM.commit();
}
void EEPROM_getResetCnt(uint16_t &slot1, uint16_t &slot2) {
if (EEPROM.read(0) != 0xDD && EEPROM.read(1) != 0xDD) {
return;
}
EEPROM_ReadBytes(2, &slot1, 2);
EEPROM_ReadBytes(4, &slot2, 2);
}
long EEPROM_updateResetCnt() {
uint16_t slot1 = 0;
uint16_t slot2 = 0;
EEPROM_begin();
// EEPROM_clearResetCnt();
EEPROM_getResetCnt(slot1, slot2);
// Serial.print("\n*Slot1: "); Serial.println(slot1);
// Serial.print("*Slot2: "); Serial.println(slot2);
if (slot1 == 0) {
EEPROM_clearResetCnt();
} else if (slot1 < slot2) {
slot1++;
EEPROM_WriteBytes(2, &slot1, 2);
} else {
slot2++;
EEPROM_WriteBytes(4, &slot2, 2);
}
EEPROM.commit();
return slot1 + slot2;
} | 23.931507 | 67 | 0.583858 |
c285c4a7ee970c4033dd201d325aaa7cf8c50c88 | 377 | h | C | Webauthn/AttestationObject.h | artur00231/webauthn | 445e9042330d724dc58e95e53799d62011687375 | [
"BSL-1.0"
] | null | null | null | Webauthn/AttestationObject.h | artur00231/webauthn | 445e9042330d724dc58e95e53799d62011687375 | [
"BSL-1.0"
] | null | null | null | Webauthn/AttestationObject.h | artur00231/webauthn | 445e9042330d724dc58e95e53799d62011687375 | [
"BSL-1.0"
] | null | null | null | #pragma once
#include "AuthenticatorData.h"
#include "Attestation.h"
#include <string>
namespace webauthn
{
class AttestationObject
{
public:
Attestation::Format format{};
AuthenticatorData authenticator_data{};
static AttestationObject fromCbor(const std::vector<std::byte>& data);
std::vector<std::byte> toCbor() const;
private:
};
}
| 16.391304 | 73 | 0.689655 |
525dcba5b25ab6d9d4b8d5a5376e6718a1b261ef | 396 | h | C | XVim2/XcodeHeader/IDEKit/IDEFindNavigatorRolloverRowViewDelegate-Protocol.h | haozhiyu1990/XVim2 | 3f37d905d51c22fbd86c36e42d8ee1813829b00c | [
"MIT"
] | 2,453 | 2017-09-07T00:07:49.000Z | 2022-03-29T22:32:10.000Z | XVim2/XcodeHeader/IDEKit/IDEFindNavigatorRolloverRowViewDelegate-Protocol.h | haozhiyu1990/XVim2 | 3f37d905d51c22fbd86c36e42d8ee1813829b00c | [
"MIT"
] | 373 | 2017-09-20T04:16:11.000Z | 2022-03-26T17:01:37.000Z | XVim2/XcodeHeader/IDEKit/IDEFindNavigatorRolloverRowViewDelegate-Protocol.h | haozhiyu1990/XVim2 | 3f37d905d51c22fbd86c36e42d8ee1813829b00c | [
"MIT"
] | 260 | 2017-09-16T15:31:41.000Z | 2022-02-07T02:52:29.000Z | //
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 30 2020 21:18:12).
//
// Copyright (C) 1997-2019 Steve Nygard.
//
#import <IDEKit/NSObject-Protocol.h>
@class IDEFindNavigatorRolloverRowView;
@protocol IDEFindNavigatorRolloverRowViewDelegate <NSObject>
- (void)findNavigatorRolloverRowView:(IDEFindNavigatorRolloverRowView *)arg1 updateMouseInside:(BOOL)arg2;
@end
| 26.4 | 106 | 0.772727 |
ea3275fcde14e45c371ea9212f6f322a0c27cb73 | 1,644 | h | C | src/trusted/gio/gio_shm_unbounded.h | MicrohexHQ/nacl_contracts | 3efab5eecb3cf7ba43f2d61000e65918aa4ba77a | [
"BSD-3-Clause"
] | 6 | 2015-02-06T23:41:01.000Z | 2015-10-21T03:08:51.000Z | src/trusted/gio/gio_shm_unbounded.h | MicrohexHQ/nacl_contracts | 3efab5eecb3cf7ba43f2d61000e65918aa4ba77a | [
"BSD-3-Clause"
] | null | null | null | src/trusted/gio/gio_shm_unbounded.h | MicrohexHQ/nacl_contracts | 3efab5eecb3cf7ba43f2d61000e65918aa4ba77a | [
"BSD-3-Clause"
] | 1 | 2019-10-02T08:41:50.000Z | 2019-10-02T08:41:50.000Z | /*
* Copyright 2010 The Native Client Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can
* be found in the LICENSE file.
*/
/*
* Subclass of the gio object for use in trusted code. Provides write
* buffering into a shared memory object that may grow as needed.
*/
#ifndef NATIVE_CLIENT_SRC_TRUSTED_GIO_WRAPPED_DESC_GIO_SHM_UNBOUNDED_H_
#define NATIVE_CLIENT_SRC_TRUSTED_GIO_WRAPPED_DESC_GIO_SHM_UNBOUNDED_H_
#include "native_client/src/include/nacl_base.h"
#include "native_client/src/shared/gio/gio.h"
#include "native_client/src/trusted/gio/gio_shm.h"
EXTERN_C_BEGIN
struct NaClGioShm;
struct NaClGioShmUnbounded {
/* public */
struct Gio base;
struct NaClGioShm *ngsp;
/* private */
size_t shm_avail_sz;
size_t shm_written;
size_t io_offset; /* deal with seeks */
};
/*
* When the NaClGioShmUnbounded buffer writes are all done,
* NaClGioShmUnboundedGetNaClDesc is used to obtain the NaClDesc
* pointer -- caller is responsible for taking another reference with
* NaClDescRef, if the lifetime must extend beyond that of the
* NaClGioShmUnbounded object -- and the actual size. Actual size is
* the largest offset written, not number of bytes written, due to
* Seek and the potential of overlapping Writes (or gaps).
*/
struct NaClDesc *NaClGioShmUnboundedGetNaClDesc(
struct NaClGioShmUnbounded *self,
size_t *written);
int NaClGioShmUnboundedCtor(struct NaClGioShmUnbounded *self);
EXTERN_C_END
#endif /* NATIVE_CLIENT_SRC_TRUSTED_GIO_WRAPPED_DESC_GIO_SHM_UNBOUNDED_H_ */
| 28.842105 | 77 | 0.747567 |
7cd2db6e3558b11748e9001fd0bf524b88c446ce | 583 | h | C | include/OPS_Core/Plugins/PluginManager.h | czen/open-ops | b1ab8da354c4aecc0fe76a562395f5861bffc207 | [
"BSD-3-Clause"
] | 23 | 2017-08-01T14:29:48.000Z | 2019-10-09T22:27:38.000Z | include/OPS_Core/Plugins/PluginManager.h | czen/open-ops | b1ab8da354c4aecc0fe76a562395f5861bffc207 | [
"BSD-3-Clause"
] | 2 | 2017-08-06T08:34:18.000Z | 2017-08-08T16:27:38.000Z | include/OPS_Core/Plugins/PluginManager.h | czen/open-ops | b1ab8da354c4aecc0fe76a562395f5861bffc207 | [
"BSD-3-Clause"
] | 2 | 2017-08-08T12:25:06.000Z | 2019-09-16T15:18:18.000Z | #ifndef _PLUGIN_MANAGER_H_INCLUDED_
#define _PLUGIN_MANAGER_H_INCLUDED_
#include <list>
#include <string>
namespace OPS
{
namespace Core
{
class PluginManager
{
public:
inline PluginManager() {}
void setPluginLoadOrder(const std::list<std::string>& loadOrderedPluginNames);
void initializePlugins() const;
void terminatePlugins() const;
private:
PluginManager(const PluginManager& );
PluginManager& operator =(const PluginManager& );
private:
std::list<std::string> m_loadOrderedPluginNames;
};
}
}
#endif // _PLUGIN_MANAGER_H_INCLUDED_
| 16.657143 | 81 | 0.737564 |
86c1fa553fa1b5584ebf531fa5d46e30f472a234 | 1,672 | c | C | LeetCode/c in sort/array/4sum.c | Leoyuseu/Code | 34edfbbfb7875b3ed06de393c192c1f13a5074f4 | [
"BSD-Source-Code"
] | null | null | null | LeetCode/c in sort/array/4sum.c | Leoyuseu/Code | 34edfbbfb7875b3ed06de393c192c1f13a5074f4 | [
"BSD-Source-Code"
] | null | null | null | LeetCode/c in sort/array/4sum.c | Leoyuseu/Code | 34edfbbfb7875b3ed06de393c192c1f13a5074f4 | [
"BSD-Source-Code"
] | null | null | null | /**
* Return an array of arrays of size *returnSize.
* Note: The returned array must be malloced, assume caller calls free().
*/
static int cmp(const void *a, const void *b)
{
return *(const int *)a - *(const int *)b;
}
int *get_4sum(int a, int b, int c, int d)
{
int *ret = (int *)malloc(sizeof(int) * 4);
ret[0] = a;
ret[1] = b;
ret[2] = c;
ret[3] = d;
return ret;
}
int** fourSum(int* nums, int numsSize, int target, int* returnSize) {
int i,j,start,end;
int sum;
int **arr;
int size = 0;
int count = 500;
arr = (int **)malloc(sizeof(int *) * count);
qsort(nums,numsSize, sizeof(int),cmp);
for(i = 0; i < numsSize - 3; ++i){
if(i > 0 && nums[i] == nums[i-1])
continue;
for(j = i + 1; j < numsSize - 2; ++j){
if(j > i + 1 && nums[j] == nums[j-1])
continue;
start = j + 1;
end = numsSize - 1;
while(start < end){
if(start > j + 1 && nums[start] == nums[start-1]){
start++;
continue;
}
sum = nums[i] + nums[j] + nums[start] + nums[end];
if(sum == target){
arr[size++] = get_4sum(nums[i],nums[j],nums[start],nums[end]);
if(size >= count){
count <<= 1;
arr = realloc(arr,sizeof(int *) * count);
}
}
if(sum > target)
--end;
else
++start;
}
}
}
*returnSize = size;
return arr;
}
| 24.955224 | 82 | 0.419856 |
40190bcd8cd4f5c3e08fcb8ba9d12258ce4b5fc7 | 3,032 | h | C | isis/src/qisis/objs/ShapeReader/ShapeReader.h | ihumphrey-usgs/ISIS3_old | 284cc442b773f8369d44379ee29a9b46961d8108 | [
"Unlicense"
] | 134 | 2018-01-18T00:16:24.000Z | 2022-03-24T03:53:33.000Z | isis/src/qisis/objs/ShapeReader/ShapeReader.h | ihumphrey-usgs/ISIS3_old | 284cc442b773f8369d44379ee29a9b46961d8108 | [
"Unlicense"
] | 3,825 | 2017-12-11T21:27:34.000Z | 2022-03-31T21:45:20.000Z | isis/src/qisis/objs/ShapeReader/ShapeReader.h | ihumphrey-usgs/ISIS3_old | 284cc442b773f8369d44379ee29a9b46961d8108 | [
"Unlicense"
] | 164 | 2017-11-30T21:15:44.000Z | 2022-03-23T10:22:29.000Z | #ifndef ShapeReader_H
#define ShapeReader_H
#include <QObject>
#include <QPointer>
// This is the parent of the inner class
#include <functional>
#include "ShapeDisplayProperties.h"
#include "ShapeList.h"
#include "ProgressBar.h"
#include "PvlObject.h"
template <typename A> class QFutureWatcher;
class QMutex;
class QProgressBar;
class QStringList;
class QVariant;
namespace Isis {
class PvlObject;
/**
* @brief
*
* @author 2016-07-25 Tracie Sucharski
*
* @ingroup Visualization Tools
*
* @internal
*/
class ShapeReader : public QObject {
Q_OBJECT
public:
ShapeReader(QMutex *cameraMutex, bool requireFootprints = false, QObject *parent = NULL);
virtual ~ShapeReader();
QList<QAction *> actions(ShapeDisplayProperties::Property relevantDispProperties);
QProgressBar *progress();
signals:
void shapesReady(ShapeList shapes);
public slots:
void read(PvlObject shapesObj);
void read(QStringList shapeFileNames);
void setSafeFileOpen(bool safeFileOpen);
private slots:
void shapesReady(int);
void mappedFinished();
//void setSmallNumberOfOpenShapes(bool useSmallNumber);
private:
Q_DISABLE_COPY(ShapeReader)
template <typename Iterator>
void read(Iterator begin, Iterator end) {
int numNewEntries = 0;
while (begin != end) {
m_backlog.append(qVariantFromValue(*begin));
numNewEntries++;
begin++;
}
m_progress->setRange(0, m_progress->maximum() + numNewEntries);
start();
}
void initProgress();
void start();
void readSettings();
void writeSettings();
private:
/**
* Variant Internal Format: (QString|PvlObject). This stores what we
* haven't started reading yet in QtConcurrent.
*/
QPointer<QAction> m_askAlphaAct;
QList<QVariant> m_backlog;
QMutex *m_cameraMutex;
QPointer<QAction> m_openFilledAct;
QPointer<ProgressBar> m_progress;
QPointer<QAction> m_safeFileOpenAct;
QFutureWatcher<Shape *> * m_watcher;
bool m_safeFileOpen;
bool m_openFilled;
int m_defaultAlpha;
bool m_requireFootprints;
bool m_mappedRunning;
private:
/**
* Converts from file name or project representation to Shape *. This is designed to work
* with QtConcurrentMap.
*
* @author 2012-??-?? ???
*
* @internal
*/
class VariantToShapeFunctor : public std::unary_function<
const QVariant &, Shape *> {
public:
VariantToShapeFunctor(QMutex *cameraMutex, bool requireFootprints, QThread *targetThread,
bool openFilled, int defaultAlpha);
Shape *operator()(const QVariant &);
private:
QMutex *m_mutex;
QThread *m_targetThread;
int m_defaultAlpha;
bool m_openFilled;
bool m_requireFootprints;
};
};
};
#endif
| 23.323077 | 99 | 0.636544 |
3cbea1745a12824e7f4ee4c041915d8f7d6556eb | 17,444 | c | C | primitives.c | azetoy/Tetris-GL4Dummies | 6b1b5c18b93dab7d66cdc77475ca6bcdf8f8c232 | [
"MIT"
] | null | null | null | primitives.c | azetoy/Tetris-GL4Dummies | 6b1b5c18b93dab7d66cdc77475ca6bcdf8f8c232 | [
"MIT"
] | null | null | null | primitives.c | azetoy/Tetris-GL4Dummies | 6b1b5c18b93dab7d66cdc77475ca6bcdf8f8c232 | [
"MIT"
] | null | null | null | /*!\file primitives.c
* \brief raster "maison" utilisant l'algo du tracé de droite Br'65.
*
* ATTENTION CE CODE EST LE RÉSULTAT OBTENU SUITE À CE QUI A ÉTÉ FAIT
* EN COURS, IL A ÉTÉ LÉGÈREMENT CORRIGÉ ET COMPLÉTÉ POUR ÊTRE
* FONCTIONNEL MAIS IL N'Y A AUCUNE GARANTIE QUE TOUTES LES SITUATIONS
* AIENT ÉTÉ CORRIGÉES.
*
* \author Farès BELHADJ, amsi@up8.edu
* \date November 24, 2020.
*/
#include "moteur.h"
#include <assert.h>
/* bloc de fonctions locales (static) */
static inline void fillTriangle(surface_t * s, triangle_t * t);
static inline void abscisses(surface_t * s, vertex_t * p0, vertex_t * p1, vertex_t * absc, int replace);
static inline void drawHLine(surface_t * s, vertex_t * vG, vertex_t * vD);
static inline void shading_none(surface_t * s, GLuint * pcolor, vertex_t * v);
static inline void shading_only_tex(surface_t * s, GLuint * pcolor, vertex_t * v);
static inline void shading_only_color_CM(surface_t * s, GLuint * pcolor, vertex_t * v);
static inline void shading_only_color(surface_t * s, GLuint * pcolor, vertex_t * v);
static inline void shading_all_CM(surface_t * s, GLuint * pcolor, vertex_t * v);
static inline void shading_all(surface_t * s, GLuint * pcolor, vertex_t * v);
static inline void interpolate(vertex_t * r, vertex_t * a, vertex_t * b, float fa, float fb, int s, int e);
static inline void metainterpolate_none(vertex_t * r, vertex_t * a, vertex_t * b, float fa, float fb);
static inline void metainterpolate_only_tex(vertex_t * r, vertex_t * a, vertex_t * b, float fa, float fb);
static inline void metainterpolate_only_color(vertex_t * r, vertex_t * a, vertex_t * b, float fa, float fb);
static inline void metainterpolate_all(vertex_t * r, vertex_t * a, vertex_t * b, float fa, float fb);
static inline GLuint rgba(GLubyte r, GLubyte g, GLubyte b, GLubyte a);
static inline GLubyte red(GLuint c);
static inline GLubyte green(GLuint c);
static inline GLubyte blue(GLuint c);
static inline GLubyte alpha(GLuint c);
static void pquit(void);
/*!\brief la texture courante à utiliser en cas de mapping de texture */
static GLuint * _tex = NULL;
/*!\brief la largeur de la texture courante à utiliser en cas de
* mapping de texture */
static GLuint _texW = 0;
/*!\brief la hauteur de la texture courante à utiliser en cas de
* mapping de texture */
static GLuint _texH = 0;
/*!\brief un buffer de depth pour faire le z-test */
static float * _depth = NULL;
/*!\brief flag pour savoir s'il faut ou non corriger l'interpolation
* par rapport à la profondeur en cas de projection en
* perspective */
static int _perpective_correction = 0;
/*!\brief transforme et rastérise l'ensemble des triangles de la
* surface. */
void transform_n_raster(surface_t * s, float * mvMat, float * projMat) {
int i;
/* la première fois allouer le depth buffer */
if(_depth == NULL) {
_depth = calloc(gl4dpGetWidth() * gl4dpGetHeight(), sizeof *_depth);
assert(_depth);
atexit(pquit);
}
/* si projMat[15] est à 1, c'est une projection orthogonale, pas
* besoin de correction de perspective */
_perpective_correction = projMat[15] == 1.0f ? 0 : 1;
/* le viewport est fixe ; \todo peut devenir paramétrable ... */
float viewport[] = { 0.0f, 0.0f, (float)gl4dpGetWidth(), (float)gl4dpGetHeight() };
stransform(s, mvMat, projMat, viewport);
/* mettre en place la texture qui sera utilisée pour mapper la surface */
if(s->options & SO_USE_TEXTURE)
setTexture(s->texId);
for(i = 0; i < s->n; ++i) {
/* si le triangle est déclaré CULL (par exemple en backface), le rejeter */
if(s->t[i].state & PS_CULL ) continue;
/* on rejette aussi les triangles complètement out */
if(s->t[i].state & PS_TOTALLY_OUT) continue;
/* "hack" pas terrible permettant de rejeter les triangles
* partiellement out dont au moins un sommet est TOO_FAR (trop
* éloigné). Voir le fichier transformations.c pour voir comment
* améliorer ce traitement. */
if( s->t[i].state & PS_PARTIALLY_OUT &&
( (s->t[i].v[0].state & PS_TOO_FAR) ||
(s->t[i].v[1].state & PS_TOO_FAR) ||
(s->t[i].v[2].state & PS_TOO_FAR) ) )
continue;
fillTriangle(s, &(s->t[i]));
}
}
/*!\brief effacer le buffer de profondeur (à chaque frame) pour
* réaliser le z-test */
void clearDepth(void) {
if(_depth) {
memset(_depth, 0, gl4dpGetWidth() * gl4dpGetHeight() * sizeof *_depth);
}
}
/*!\brief met en place une texture pour être mappée sur la surface en cours */
void setTexture(GLuint screen) {
GLuint oldId = gl4dpGetTextureId(); /* au cas où */
gl4dpSetScreen(screen);
_tex = gl4dpGetPixels();
_texW = gl4dpGetWidth();
_texH = gl4dpGetHeight();
gl4dpSetScreen(oldId);
}
/*!\brief met à jour la fonction d'interpolation et de coloriage
* (shadingfunc) de la surface en fonction de ses options */
void updatesfuncs(surface_t * s) {
int t;
if(s->options & SO_USE_TEXTURE) {
s->interpolatefunc = (t = s->options & SO_COLOR_MATERIAL) ? metainterpolate_all : metainterpolate_only_tex;
s->shadingfunc = (s->options & SO_USE_COLOR) ? (t ? shading_all_CM : shading_all) : shading_only_tex;
} else {
s->interpolatefunc = (t = s->options & SO_COLOR_MATERIAL) ? metainterpolate_only_color : metainterpolate_none;
s->shadingfunc = (s->options & SO_USE_COLOR) ? (t ? shading_only_color_CM : shading_only_color) : shading_none;;
}
}
/*!\brief fonction principale de ce fichier, elle dessine un triangle
* rempli à l'écran en calculant l'ensemble des gradients
* (interpolations bilinaires des attributs du sommet).
*/
inline void fillTriangle(surface_t * s, triangle_t * t) {
vertex_t * aG = NULL, * aD = NULL;
int bas, median, haut, n, signe, i, h = gl4dpGetHeight();
if(t->v[0].y < t->v[1].y) {
if(t->v[0].y < t->v[2].y) {
bas = 0;
if(t->v[1].y < t->v[2].y) {
median = 1;
haut = 2;
} else {
median = 2;
haut = 1;
}
} else {
bas = 2;
median = 0;
haut = 1;
}
} else { /* p0 au dessus de p1 */
if(t->v[1].y < t->v[2].y) {
bas = 1;
if(t->v[0].y < t->v[2].y) {
median = 0;
haut = 2;
} else {
median = 2;
haut = 0;
}
} else {
bas = 2;
median = 1;
haut = 0;
}
}
n = t->v[haut].y - t->v[bas].y + 1;
aG = malloc(n * sizeof *aG);
assert(aG);
aD = malloc(n * sizeof *aD);
assert(aD);
/* est-ce que Pm est à gauche (+) ou à droite (-) de la droite (Pb->Ph) ? */
/*MAJ, idée TODO?, un produit vectoriel pourrait s'avérer mieux */
if(t->v[haut].x == t->v[bas].x /*MAJ*/ || t->v[haut].y == t->v[bas].y) {
/* eq de la droite x = t->v[haut].x; MAJ ou y = t->v[haut].y; */
signe = (t->v[median].x > t->v[haut].x) ? -1 : 1;
} else {
/* eq ax + y + c = 0 */
float a, c, x;
a = (t->v[haut].y - t->v[bas].y) / (float)(t->v[bas].x - t->v[haut].x);
c = -a * t->v[haut].x - t->v[haut].y;
/*MAJ on trouve le x sur la droite au même y que le median et on compare */
x = -(c + t->v[median].y) / a;
signe = (t->v[median].x >= x) ? -1 : 1;
}
if(signe < 0) { /* aG reçoit Ph->Pb, et aD reçoit Ph->Pm puis Pm vers Pb */
abscisses(s, &(t->v[haut]), &(t->v[bas]), aG, 1);
abscisses(s, &(t->v[haut]), &(t->v[median]), aD, 1);
abscisses(s, &(t->v[median]), &(t->v[bas]), &aD[t->v[haut].y - t->v[median].y], 0);
} else { /* aG reçoit Ph->Pm puis Pm vers Pb, et aD reçoit Ph->Pb */
abscisses(s, &(t->v[haut]), &(t->v[bas]), aD, 1);
abscisses(s, &(t->v[haut]), &(t->v[median]), aG, 1);
abscisses(s, &(t->v[median]), &(t->v[bas]), &aG[t->v[haut].y - t->v[median].y], 0);
}
/* printf pouvant être utile en cas de DEBUG */
/* printf("signe: %d, haut = %d (%d, %d), median = %d (%d, %d), bas = %d (%d, %d)\n", signe, */
/* haut, t->v[haut].x, t->v[haut].y, median, t->v[median].x, t->v[median].y, bas, t->v[bas].x, t->v[bas].y); */
for(i = 0; i < n; ++i) {
if( aG[i].y >= 0 && aG[i].y < h &&
( (aG[i].z >= 0 && aG[i].z <= 1) || (aD[i].z >= 0 && aD[i].z <= 1) ) )
drawHLine(s, &aG[i], &aD[i]);
}
free(aG);
free(aD);
}
/*!\brief utilise Br'65 pour determiner les abscisses des segments du
* triangle à remplir (par \a drawHLine).
*/
inline void abscisses(surface_t * s, vertex_t * p0, vertex_t * p1, vertex_t * absc, int replace) {
int u = p1->x - p0->x, v = p1->y - p0->y, pasX = u < 0 ? -1 : 1, pasY = v < 0 ? -1 : 1;
float dmax = sqrtf(u * u + v * v), p;
u = abs(u); v = abs(v);
if(u > v) { // 1er octan
if(replace) {
int objX = (u + 1) * pasX;
int delta = u - 2 * v, incH = -2 * v, incO = 2 * u - 2 * v;
for (int x = 0, y = 0, k = 0; x != objX; x += pasX) {
absc[k].x = x + p0->x;
absc[k].y = y + p0->y;
p = sqrtf(x * x + y * y) / dmax;
s->interpolatefunc(&absc[k], p0, p1, 1.0f - p, p);
if(delta < 0) {
++k;
y += pasY;
delta += incO;
} else
delta += incH;
}
} else {
int objX = (u + 1) * pasX;
int delta = u - 2 * v, incH = -2 * v, incO = 2 * u - 2 * v;
for (int x = 0, y = 0, k = 0, done = 0; x != objX; x += pasX) {
if(!done) {
absc[k].x = x + p0->x;
absc[k].y = y + p0->y;
p = sqrtf(x * x + y * y) / dmax;
s->interpolatefunc(&absc[k], p0, p1, 1.0f - p, p);
done = 1;
}
if(delta < 0) {
++k;
done = 0;
y += pasY;
delta += incO;
} else
delta += incH;
}
}
} else { // 2eme octan
int objY = (v + 1) * pasY;
int delta = v - 2 * u, incH = -2 * u, incO = 2 * v - 2 * u;
for (int x = 0, y = 0, k = 0; y != objY; y += pasY) {
absc[k].x = x + p0->x;
absc[k].y = y + p0->y;
p = sqrtf(x * x + y * y) / dmax;
s->interpolatefunc(&absc[k], p0, p1, 1.0f - p, p);
++k;
if(delta < 0) {
x += pasX;
delta += incO;
} else
delta += incH;
}
}
}
/*!\brief remplissage par droite horizontale entre deux abscisses */
inline void drawHLine(surface_t * s, vertex_t * vG, vertex_t * vD) {
int w = gl4dpGetWidth(), x, yw = vG->y * w;
GLuint * image = gl4dpGetPixels();
float dmax = vD->x - vG->x, p, deltap;
vertex_t v;
/* il reste d'autres optims possibles */
for(x = vG->x, p = 0.0f, deltap = 1.0f / dmax; x <= vD->x; ++x, p += deltap)
if(x >= 0 && x < w) {
s->interpolatefunc(&v, vG, vD, 1.0f - p, p);
if(v.z < 0 || v.z > 1 || v.z < _depth[yw + x]) { continue; }
s->shadingfunc(s, &image[yw + x], &v);
_depth[yw + x] = v.z;
}
}
/*!\brief aucune couleur n'est inscrite */
inline void shading_none(surface_t * s, GLuint * pcolor, vertex_t * v) {
//vide pour l'instant, à prévoir le z-buffer
}
/*!\brief la couleur du pixel est tirée uniquement de la texture */
inline void shading_only_tex(surface_t * s, GLuint * pcolor, vertex_t * v) {
int xt, yt, ct;
GLubyte r, g, b, a;
xt = (int)(v->texCoord.x * (_texW - EPSILON));
if(xt < 0) {
xt = xt % (-_texW);
while(xt < 0) xt += _texW;
} else
xt = xt % _texW;
yt = (int)(v->texCoord.y * (_texH - EPSILON));
if(yt < 0) {
yt = yt % (-_texH);
while(yt < 0) yt += _texH;
} else
yt = yt % _texH;
ct = yt * _texW + xt;
*pcolor = _tex[yt * _texW + xt];
r = (GLubyte)( red(_tex[ct]) * v->li);
g = (GLubyte)(green(_tex[ct]) * v->li);
b = (GLubyte)( blue(_tex[ct]) * v->li);
a = (GLubyte) alpha(_tex[ct]);
*pcolor = rgba(r, g, b, a);
}
/*!\brief la couleur du pixel est tirée de la couleur interpolée */
inline void shading_only_color_CM(surface_t * s, GLuint * pcolor, vertex_t * v) {
GLubyte r, g, b, a;
r = (GLubyte)(v->li * v->icolor.x * (255 + EPSILON));
g = (GLubyte)(v->li * v->icolor.y * (255 + EPSILON));
b = (GLubyte)(v->li * v->icolor.z * (255 + EPSILON));
a = (GLubyte)(v->icolor.w * (255 + EPSILON));
*pcolor = rgba(r, g, b, a);
}
/*!\brief la couleur du pixel est tirée de la couleur diffuse de la
* surface */
inline void shading_only_color(surface_t * s, GLuint * pcolor, vertex_t * v) {
GLubyte r, g, b, a;
r = (GLubyte)(v->li * s->dcolor.x * (255 + EPSILON));
g = (GLubyte)(v->li * s->dcolor.y * (255 + EPSILON));
b = (GLubyte)(v->li * s->dcolor.z * (255 + EPSILON));
a = (GLubyte)(s->dcolor.w * (255 + EPSILON));
*pcolor = rgba(r, g, b, a);
}
/*!\brief la couleur du pixel est le produit de la couleur interpolée
* et de la texture */
inline void shading_all_CM(surface_t * s, GLuint * pcolor, vertex_t * v) {
GLubyte r, g, b, a;
int xt, yt, ct;
xt = (int)(v->texCoord.x * (_texW - EPSILON));
if(xt < 0) {
xt = xt % (-_texW);
while(xt < 0) xt += _texW;
} else
xt = xt % _texW;
yt = (int)(v->texCoord.y * (_texH - EPSILON));
if(yt < 0) {
yt = yt % (-_texH);
while(yt < 0) yt += _texH;
} else
yt = yt % _texH;
ct = yt * _texW + xt;
r = (GLubyte)(( red(_tex[ct]) + EPSILON) * v->li * v->icolor.x);
g = (GLubyte)((green(_tex[ct]) + EPSILON) * v->li * v->icolor.y);
b = (GLubyte)(( blue(_tex[ct]) + EPSILON) * v->li * v->icolor.z);
a = (GLubyte)((alpha(_tex[ct]) + EPSILON) * v->icolor.w);
*pcolor = rgba(r, g, b, a);
}
/*!\brief la couleur du pixel est le produit de la couleur diffuse
* de la surface et de la texture */
inline void shading_all(surface_t * s, GLuint * pcolor, vertex_t * v) {
GLubyte r, g, b, a;
int xt, yt, ct;
xt = (int)(v->texCoord.x * (_texW - EPSILON));
if(xt < 0) {
xt = xt % (-_texW);
while(xt < 0) xt += _texW;
} else
xt = xt % _texW;
yt = (int)(v->texCoord.y * (_texH - EPSILON));
if(yt < 0) {
yt = yt % (-_texH);
while(yt < 0) yt += _texH;
} else
yt = yt % _texH;
ct = yt * _texW + xt;
r = (GLubyte)(( red(_tex[ct]) + EPSILON) * v->li * s->dcolor.x);
g = (GLubyte)((green(_tex[ct]) + EPSILON) * v->li * s->dcolor.y);
b = (GLubyte)(( blue(_tex[ct]) + EPSILON) * v->li * s->dcolor.z);
a = (GLubyte)((alpha(_tex[ct]) + EPSILON) * s->dcolor.w);
*pcolor = rgba(r, g, b, a);
}
/*!\brief interpolation de plusieurs floattants (entre \a s et \a e)
* de la structure vertex_t en utilisant \a a et \a b, les
* facteurs \a fa et \a fb, le tout dans \a r
* \todo un pointeur de fonction pour éviter un test s'il faut
* un _perpective_correction != 0 ??? */
inline void interpolate(vertex_t * r, vertex_t * a, vertex_t * b, float fa, float fb, int s, int e) {
int i;
float * pr = (float *)&(r->texCoord);
float * pa = (float *)&(a->texCoord);
float * pb = (float *)&(b->texCoord);
/* Correction de l'interpolation par rapport à la perspective, le z
* joue un rôle dans les distances, il est nécessaire de le
* réintégrer en modifiant les facteurs de proportion.
* lien utile : https://www.scratchapixel.com/lessons/3d-basic-rendering/rasterization-practical-implementation/perspective-correct-interpolation-vertex-attributes
*/
if(_perpective_correction) {
float z = 1.0f / (fa / a->zmod + fb / b->zmod);
fa = z * fa / a->zmod; fb = z * fb / b->zmod;
}
for(i = s; i <= e; ++i)
pr[i] = fa * pa[i] + fb * pb[i];
}
/*!\brief meta-fonction pour appeler \a interpolate, demande
* uniquement l'interpolation des z */
inline void metainterpolate_none(vertex_t * r, vertex_t * a, vertex_t * b, float fa, float fb) {
interpolate(r, a, b, fa, fb, 6, 8);
}
/*!\brief meta-fonction pour appeler \a interpolate, demande
* uniquement l'interpolation des coord. de texture et les z */
inline void metainterpolate_only_tex(vertex_t * r, vertex_t * a, vertex_t * b, float fa, float fb) {
interpolate(r, a, b, fa, fb, 0, 1);
interpolate(r, a, b, fa, fb, 6, 8);
}
/*!\brief meta-fonction pour appeler \a interpolate, demande
* uniquement l'interpolation des couleurs et les z */
inline void metainterpolate_only_color(vertex_t * r, vertex_t * a, vertex_t * b, float fa, float fb) {
interpolate(r, a, b, fa, fb, 2, 8);
}
/*!\brief meta-fonction pour appeler \a interpolate, demande
* l'interpolation de l'ensemble des attributs */
inline void metainterpolate_all(vertex_t * r, vertex_t * a, vertex_t * b, float fa, float fb) {
interpolate(r, a, b, fa, fb, 0, 8);
}
GLuint rgba(GLubyte r, GLubyte g, GLubyte b, GLubyte a) {
return RGBA(r, g, b, a);
}
GLubyte red(GLuint c) {
return RED(c);
}
GLubyte green(GLuint c) {
return GREEN(c);
}
GLubyte blue(GLuint c) {
return BLUE(c);
}
GLubyte alpha(GLuint c) {
return ALPHA(c);
}
/*!\brief tracé de droite dans grille écran selon l'algorithme Br'65.
*
* \deprecated ne gère pas le sommet en général (dans l'espace 3D).
*/
void drawLine(int x0, int y0, int x1, int y1, GLuint color) {
int u = x1 - x0, v = y1 - y0, pasX = u < 0 ? -1 : 1, pasY = v < 0 ? -1 : 1;
int w = gl4dpGetWidth();
GLuint * image = gl4dpGetPixels();
u = abs(u); v = abs(v);
if(u > v) { // 1er octan
int objX = (u + 1) * pasX;
int delta = u - 2 * v, incH = -2 * v, incO = 2 * u - 2 * v;
for (int x = 0, y = 0; x != objX; x += pasX) {
if(IN_SCREEN(x + x0, y0 + y))
image[(y0 + y) * w + x + x0] = color;
if(delta < 0) {
y += pasY;
delta += incO;
} else
delta += incH;
}
} else { // 2eme octan
int objY = (v + 1) * pasY;
int delta = v - 2 * u, incH = -2 * u, incO = 2 * v - 2 * u;
for (int x = 0, y = 0; y != objY; y += pasY) {
if(IN_SCREEN(x + x0, y0 + y))
image[(y0 + y) * w + x + x0] = color;
if(delta < 0) {
x += pasX;
delta += incO;
} else
delta += incH;
}
}
}
/*!\brief au moment de quitter le programme désallouer la mémoire
* utilisée pour _depth */
void pquit(void) {
if(_depth) {
free(_depth);
_depth = NULL;
}
}
| 35.6 | 166 | 0.589486 |
1efff7675ffbe75241e6033167e94dff3ac1b84a | 3,422 | h | C | pj_tflite_hand_mediapipe/image_processor/meidapipe/ssd_anchors_calculator.h | Pandinosaurus/play_with_tflite | 929ecd734bff329ee57cbc6474b6b25f4eaf120e | [
"Apache-2.0"
] | 152 | 2020-07-21T01:46:39.000Z | 2022-03-31T05:53:36.000Z | pj_tflite_hand_mediapipe/ImageProcessor/meidapipe/ssd_anchors_calculator.h | chiminghui/play_with_tflite | 6359e7a4677ae70418f653a77e478d1fae1e3d40 | [
"Apache-2.0"
] | 32 | 2020-08-18T08:50:20.000Z | 2022-03-30T16:38:41.000Z | pj_tflite_hand_mediapipe/ImageProcessor/meidapipe/ssd_anchors_calculator.h | chiminghui/play_with_tflite | 6359e7a4677ae70418f653a77e478d1fae1e3d40 | [
"Apache-2.0"
] | 34 | 2020-09-14T11:23:24.000Z | 2022-03-06T14:59:22.000Z | // Refecence: mediapipe\framework\formats\object_detection\anchor.proto
class Anchor {
public:
// Encoded anchor box center.
float _x_center;
float _y_center;
// Encoded anchor box height.
float _h;
// Encoded anchor box width.
float _w;
void set_x_center(float __x_center) { _x_center = __x_center; }
void set_y_center(float __y_center) { _y_center = __y_center; }
void set_h(float __h) { _h = __h; }
void set_w(float __w) { _w = __w; }
float x_center() const { return _x_center; }
float y_center() const { return _y_center; }
float h() const { return _h; }
float w() const { return _w; }
};
// Refecence: mediapipe\graphs\hand_tracking\subgraphs\hand_detection_gpu.pbtxt
class SsdAnchorsCalculatorOptions {
private:
int _num_layers;
float _min_scale;
float _max_scale;
int _input_size_height;
int _input_size_width;
float _anchor_offset_x;
float _anchor_offset_y;
int _strides_size;
std::vector<int>_strides;
int _aspect_ratios_size;
std::vector<float>_aspect_ratios;
bool _fixed_anchor_size;
float _interpolated_scale_aspect_ratio;
bool _reduce_boxes_in_lowest_layer;
std::vector<int>_feature_map_width;
int _feature_map_width_size;
std::vector<int>_feature_map_height;
int _feature_map_height_size;
public:
SsdAnchorsCalculatorOptions() {
_num_layers = 5;
_min_scale = 0.1171875;
_max_scale = 0.75;
_input_size_height = 256;
_input_size_width = 256;
_anchor_offset_x = 0.5;
_anchor_offset_y = 0.5;
_strides.push_back(8);
_strides.push_back(16);
_strides.push_back(32);
_strides.push_back(32);
_strides.push_back(32);
_strides_size = (int)_strides.size();
_aspect_ratios.push_back(1.0);
_aspect_ratios_size = (int)_aspect_ratios.size();
_fixed_anchor_size = true;
_interpolated_scale_aspect_ratio = 1.0;
_reduce_boxes_in_lowest_layer = false;
_feature_map_width.clear();
_feature_map_width_size = (int)_feature_map_width.size();
_feature_map_height.clear();
_feature_map_height_size = (int)_feature_map_height.size();
}
int num_layers() const { return _num_layers; }
float min_scale() const { return _min_scale; }
float max_scale() const { return _max_scale; }
int input_size_height() const { return _input_size_height; }
int input_size_width() const { return _input_size_width; }
float anchor_offset_x() const { return _anchor_offset_x; }
float anchor_offset_y() const { return _anchor_offset_y; }
int strides_size() const { return _strides_size; }
int strides(int index) const { return _strides[index]; }
int aspect_ratios_size() const { return _aspect_ratios_size; }
float aspect_ratios(int index) const { return _aspect_ratios[index]; }
bool fixed_anchor_size() const { return _fixed_anchor_size; }
float interpolated_scale_aspect_ratio() const { return _interpolated_scale_aspect_ratio;}
bool reduce_boxes_in_lowest_layer() const { return _reduce_boxes_in_lowest_layer; }
int feature_map_width_size() const { return _feature_map_width_size; }
int feature_map_height_size() const { return _feature_map_height_size; }
int feature_map_width(int index) const { return _feature_map_width[index]; }
int feature_map_height(int index) const { return _feature_map_height[index]; }
};
namespace mediapipe {
int GenerateAnchors(std::vector<Anchor>* anchors, const SsdAnchorsCalculatorOptions& options);
} | 34.918367 | 96 | 0.748685 |
21c97847824a6272f80f2ec4f59f35f9c7ef362a | 740 | h | C | src/util/choc.h | itiel/min-vm | 45a04ffa2b2b6da0c26ac24c08bf7c0f6ee7759a | [
"MIT"
] | 1 | 2021-08-18T14:46:32.000Z | 2021-08-18T14:46:32.000Z | src/util/choc.h | itiel/min-vm | 45a04ffa2b2b6da0c26ac24c08bf7c0f6ee7759a | [
"MIT"
] | null | null | null | src/util/choc.h | itiel/min-vm | 45a04ffa2b2b6da0c26ac24c08bf7c0f6ee7759a | [
"MIT"
] | null | null | null | /*
. Author: Itiel Lopez - itiel@soyitiel.com
. Created: 22/08/2021
*/
/*
. Check for the occurrence of a character
. inside a string
*/
#ifndef _CHOC_H_
#define _CHOC_H_
/*
. char_occur()
.
. Recomended use:
.
. #include <stdio.h>
.
. int main() {
.
. if (char_occur('c', "ABCDabcd")) {
.
. printf("Character found\n");
.
. return 0;
.
. }
.
. printf("Character not found\n");
.
. return 0;
. }
*/
int char_occur (char ch, char * str) {
for (; *str; str++) {
if (ch == *str) {
return 1;
}
}
return 0;
}
#endif /* #ifndef _CHOC_H_ */
| 14.230769 | 46 | 0.431081 |
347bd8616711f0aeff3ee90e01e601ad2936767f | 243 | h | C | src/mysetjmp.h | YutaroOrikasa/user-thread | 2d82ee257115e67630f5743ceb169441854fac22 | [
"MIT"
] | null | null | null | src/mysetjmp.h | YutaroOrikasa/user-thread | 2d82ee257115e67630f5743ceb169441854fac22 | [
"MIT"
] | 2 | 2017-05-02T07:02:23.000Z | 2017-05-20T09:32:52.000Z | src/mysetjmp.h | YutaroOrikasa/user-thread | 2d82ee257115e67630f5743ceb169441854fac22 | [
"MIT"
] | null | null | null | #ifndef MYSETJMP_H_
#define MYSETJMP_H_
struct context {
uint64_t regs[8];
};
#ifdef __cplusplus
extern "C" {
#endif
uint64_t mysetjmp(context& ctx);
void mylongjmp(context& ctx);
#ifdef __cplusplus
}
#endif
#endif /* MYSETJMP_H_ */
| 11.571429 | 32 | 0.716049 |
0958ba51ade9fb1e552268f5d0496e1443acdf67 | 1,142 | h | C | third_party/blink/renderer/platform/graphics/canvas_metrics.h | zipated/src | 2b8388091c71e442910a21ada3d97ae8bc1845d3 | [
"BSD-3-Clause"
] | 2,151 | 2020-04-18T07:31:17.000Z | 2022-03-31T08:39:18.000Z | third_party/blink/renderer/platform/graphics/canvas_metrics.h | cangulcan/src | 2b8388091c71e442910a21ada3d97ae8bc1845d3 | [
"BSD-3-Clause"
] | 395 | 2020-04-18T08:22:18.000Z | 2021-12-08T13:04:49.000Z | third_party/blink/renderer/platform/graphics/canvas_metrics.h | cangulcan/src | 2b8388091c71e442910a21ada3d97ae8bc1845d3 | [
"BSD-3-Clause"
] | 338 | 2020-04-18T08:03:10.000Z | 2022-03-29T12:33:22.000Z | // Copyright 2015 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 THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_CANVAS_METRICS_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_CANVAS_METRICS_H_
#include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/wtf/allocator.h"
namespace blink {
class PLATFORM_EXPORT CanvasMetrics {
STATIC_ONLY(CanvasMetrics);
public:
enum CanvasContextUsage {
kCanvasCreated = 0,
kGPUAccelerated2DCanvasImageBufferCreated = 1,
kUnaccelerated2DCanvasImageBufferCreated = 3,
kAccelerated2DCanvasGPUContextLost = 4,
kUnaccelerated2DCanvasImageBufferCreationFailed = 5,
kGPUAccelerated2DCanvasImageBufferCreationFailed = 6,
kGPUAccelerated2DCanvasDeferralDisabled = 8,
kGPUAccelerated2DCanvasSurfaceCreationFailed = 9,
kNumberOfUsages
};
static void CountCanvasContextUsage(const CanvasContextUsage);
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_CANVAS_METRICS_H_
| 32.628571 | 73 | 0.817863 |
0993351775f1a1b1bbd75b4af4c45e885f069e1d | 2,294 | h | C | classdump_Safari/OneStepBookmarkingButtonController.h | inket/smartPins | 2f9a68dccf8b605f863a680488ed4c6c428f4a52 | [
"MIT"
] | 2 | 2016-09-29T09:50:04.000Z | 2016-09-29T19:39:11.000Z | classdump_Safari/OneStepBookmarkingButtonController.h | inket/smartPins | 2f9a68dccf8b605f863a680488ed4c6c428f4a52 | [
"MIT"
] | null | null | null | classdump_Safari/OneStepBookmarkingButtonController.h | inket/smartPins | 2f9a68dccf8b605f863a680488ed4c6c428f4a52 | [
"MIT"
] | null | null | null | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard.
//
#import <objc/NSObject.h>
#import <Safari/NSMenuDelegate-Protocol.h>
@class NSMenu, NSString, OneStepBookmarkingButton;
__attribute__((visibility("hidden")))
@interface OneStepBookmarkingButtonController : NSObject <NSMenuDelegate>
{
NSMenu *_dynamicOneStepBookmarkingMenu;
OneStepBookmarkingButton *_oneStepBookmarkingButton;
}
@property(nonatomic) __weak OneStepBookmarkingButton *oneStepBookmarkingButton; // @synthesize oneStepBookmarkingButton=_oneStepBookmarkingButton;
- (void).cxx_destruct;
- (void)menuDidClose:(id)arg1;
- (void)menuNeedsUpdate:(id)arg1;
- (void)handleButtonDrag:(id)arg1 mouseDownEvent:(id)arg2;
- (id)oneStepBookmarkingButtonActionDescription;
- (void)updateOneStepBookmarkingButton;
- (void)_addBookmarkToFolder:(id)arg1;
- (void)_addBookmarkToTopSites:(id)arg1;
- (void)_addBookmarkToReadingList:(id)arg1;
- (void)oneClickAddBookmark:(id)arg1;
- (unsigned long long)_oneStepBookmarkingDefaultDestination;
- (unsigned long long)_bookmarkDestinationForRepresentedObject:(id)arg1;
- (void)_didSelectOneStepBookmarkMenuItemWithIdentifier:(id)arg1 makeDefault:(BOOL)arg2;
- (unsigned long long)_insertionLocationForNewBookmarkInFolder:(id)arg1 destinationFolder:(id *)arg2;
- (void)_addBookmarkWithoutAskingToFolder:(id)arg1 andMakeDefault:(BOOL)arg2;
- (void)_addBookmarkToTopSitesWithoutAskingAndMakeDefault:(BOOL)arg1;
- (void)_addBookmarkToReadingListWithoutAskingAndMakeDefault:(BOOL)arg1;
- (void)_addOneStepBookmarkingMenuItemsForBookmarkFolder:(id)arg1 toMenu:(id)arg2 indentationLevel:(unsigned long long)arg3;
- (id)_representedObjectForOneStepBookmarkingMenuItemWithUserDefaultKey:(id)arg1;
- (void)_addTopSitesMenuItemToMenu:(id)arg1;
- (void)_setUpOneStepBookmarkingMenu:(id)arg1;
- (id)_oneStepBookmarkingTopSiteMenuItemIcon;
- (id)_oneStepBookmarkingBookmarkMenuItemIcon;
- (id)_oneStepBookmarkingReadingListMenuItemIcon;
- (BOOL)_canAddBookmark;
- (id)_dynamicOneStepBookmarkingMenu;
// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(readonly) Class superclass;
@end
| 40.964286 | 146 | 0.81517 |
f6274a0e63eefd211c1ed064bc50344920be84b8 | 4,323 | h | C | ZedWeeMeProject/OpenEars.framework/Versions/A/Headers/LanguageModelGenerator.h | QuinnEbert/ZedWeeMe | c53d04b6613ddd2af9f63982f1267909510de754 | [
"Apache-2.0"
] | 2 | 2015-04-07T07:33:59.000Z | 2015-08-31T14:16:01.000Z | Framework/OpenEars.framework/Versions/A/Headers/LanguageModelGenerator.h | bepitulaz/calegnyampah | 5075922cfd92f3e8fa16e17b8420b0be17b1aa6c | [
"MIT"
] | null | null | null | Framework/OpenEars.framework/Versions/A/Headers/LanguageModelGenerator.h | bepitulaz/calegnyampah | 5075922cfd92f3e8fa16e17b8420b0be17b1aa6c | [
"MIT"
] | null | null | null | // OpenEars
// http://www.politepix.com/openears
//
// LanguageModelGenerator.h
// OpenEars
//
// LanguageModelGenerator is a class which creates new grammars
//
// Copyright Politepix UG (haftungsbeschränkt) 2012. All rights reserved.
// http://www.politepix.com
// Contact at http://www.politepix.com/contact
//
// This file is licensed under the Politepix Shared Source license found in the root of the source distribution.
/**
@class LanguageModelGenerator
@brief The class that generates the vocabulary the PocketsphinxController is able to understand.
## Usage examples
> What to add to your implementation:
@htmlinclude LanguageModelGenerator_Implementation.txt
> How to use the class methods:
@htmlinclude LanguageModelGenerator_Calls.txt
*/
@class GraphemeGenerator;
@interface LanguageModelGenerator : NSObject {
/**Set this to TRUE to get verbose output*/
BOOL verboseLanguageModelGenerator;
/**Advanced: if you are using your own acoustic model or an custom dictionary contained within an acoustic model and these don't use the same phonemes as the English or Spanish acoustic models, you will need to set useFallbackMethod to FALSE so that no attempt is made to use the English or Spanish fallback method for finding pronunciations of words which don't appear in the custom acoustic model's phonetic dictionary.*/
BOOL useFallbackMethod;
/**\cond HIDDEN_SYMBOLS*/
NSMutableCharacterSet *sanitizeDictionaryCharacterSet;
NSString *pathToCachesDirectory;
GraphemeGenerator *graphemeGenerator;
BOOL outputDMP;
/**\endcond*/
}
@property(nonatomic,assign) BOOL verboseLanguageModelGenerator;
@property(nonatomic,assign) BOOL useFallbackMethod;
/**\cond HIDDEN_SYMBOLS*/
@property(nonatomic,retain) NSMutableCharacterSet *sanitizeDictionaryCharacterSet;
@property(nonatomic,copy) NSString * pathToCachesDirectory;
@property(nonatomic,retain) GraphemeGenerator *graphemeGenerator;
@property(nonatomic,assign) BOOL outputDMP;
/**\endcond*/
/**Generate a language model from an array of NSStrings which are the words and phrases you want PocketsphinxController or PocketsphinxController+RapidEars to understand, using your chosen acoustic model. Putting a phrase in as a string makes it somewhat more probable that the phrase will be recognized as a phrase when spoken. fileName is the way you want the output files to be named, for instance if you enter "MyDynamicLanguageModel" you will receive files output to your Caches directory titled MyDynamicLanguageModel.dic, MyDynamicLanguageModel.arpa, and MyDynamicLanguageModel.DMP. The error that this method returns contains the paths to the files that were created in a successful generation effort in its userInfo when NSError == noErr. The words and phrases in languageModelArray must be written with capital letters exclusively, for instance "word" must appear in the array as "WORD". */
- (NSError *) generateLanguageModelFromArray:(NSArray *)languageModelArray withFilesNamed:(NSString *)fileName forAcousticModelAtPath:(NSString *)acousticModelPath;
/**Generate a language model from a text file containing words and phrases you want PocketsphinxController to understand, using your chosen acoustic model. The file should be formatted with every word or contiguous phrase on its own line with a line break afterwards. Putting a phrase in on its own line makes it somewhat more probable that the phrase will be recognized as a phrase when spoken. Give the correct full path to the text file as a string. fileName is the way you want the output files to be named, for instance if you enter "MyDynamicLanguageModel" you will receive files output to your Caches directory titled MyDynamicLanguageModel.dic, MyDynamicLanguageModel.arpa, and MyDynamicLanguageModel.DMP. The error that this method returns contains the paths to the files that were created in a successful generation effort in its userInfo when NSError == noErr. The words and phrases in languageModelArray must be written with capital letters exclusively, for instance "word" must appear in the array as "WORD". */
- (NSError *) generateLanguageModelFromTextFile:(NSString *)pathToTextFile withFilesNamed:(NSString *)fileName forAcousticModelAtPath:(NSString *)acousticModelPath;
@end
| 58.418919 | 1,024 | 0.793893 |
56d7554f050e8f730e912e2826ab7f83aaea4263 | 2,610 | h | C | src/extended/cds_visitor_api.h | satta/genometools | 3955d63c95e142c2475e1436206fddf0eb29185d | [
"BSD-2-Clause"
] | 202 | 2015-01-08T10:09:57.000Z | 2022-03-31T09:45:44.000Z | src/extended/cds_visitor_api.h | satta/genometools | 3955d63c95e142c2475e1436206fddf0eb29185d | [
"BSD-2-Clause"
] | 286 | 2015-01-05T16:29:27.000Z | 2022-03-30T21:19:03.000Z | src/extended/cds_visitor_api.h | satta/genometools | 3955d63c95e142c2475e1436206fddf0eb29185d | [
"BSD-2-Clause"
] | 56 | 2015-01-19T11:33:22.000Z | 2022-03-21T21:47:05.000Z | /*
Copyright (c) 2006-2011 Gordon Gremme <gordon@gremme.org>
Copyright (c) 2006-2008 Center for Bioinformatics, University of Hamburg
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef CDS_VISITOR_API_H
#define CDS_VISITOR_API_H
/* <GtCDSVisitor> is a <GtNodeVisitor> that adds CDS features for the
longest ORFs in a <GtFeatureNode>. */
typedef struct GtCDSVisitor GtCDSVisitor;
#include "extended/node_visitor_api.h"
#include "extended/region_mapping_api.h"
const GtNodeVisitorClass* gt_cds_visitor_class(void);
/* Create a new <GtCDSVisitor> with the given <region_mapping> for sequence,
<minorflen> minimum ORF length, <source> as the source string.
If <start_codon> is <true> a frame has to start with a start codon,
otherwise a frame can start everywhere (i.e., at the first amino acid or
after a stop codon). If <final_stop_codon> is <true> the last ORF must
end with a stop codon, otherwise it can be ``open''.
Takes ownership of <region_mapping>. */
GtNodeVisitor* gt_cds_visitor_new(GtRegionMapping *region_mapping,
unsigned int minorflen,
GtStr *source, bool start_codon,
bool final_stop_codon,
bool generic_start_codons);
/* Sets <region_mapping> to be the region mapping specifying the sequence for
<cds_visitor>. Does not take ownership of <region_mapping>. */
void gt_cds_visitor_set_region_mapping(GtCDSVisitor
*cds_visitor,
GtRegionMapping
*region_mapping);
#define gt_cds_visitor_cast(GV)\
gt_node_visitor_cast(gt_cds_visitor_class(), GV)
#endif
| 48.333333 | 77 | 0.652107 |
ab504a15c5da5b86c654031e4ddf22aa2e2bda5c | 99 | h | C | src/ofxDemo.h | markkorput/ofxDemo | 4dc945a96c012497c05e6fab0cabb19da363191b | [
"MIT"
] | 1 | 2017-04-17T21:38:05.000Z | 2017-04-17T21:38:05.000Z | src/ofxDemo.h | markkorput/ofxDemo | 4dc945a96c012497c05e6fab0cabb19da363191b | [
"MIT"
] | null | null | null | src/ofxDemo.h | markkorput/ofxDemo | 4dc945a96c012497c05e6fab0cabb19da363191b | [
"MIT"
] | null | null | null | #include "ofxDemo/DemoManager.h"
#include "ofxDemo/AbstractDemo.h"
#include "ofxDemo/ParamsDemo.h"
| 24.75 | 33 | 0.787879 |
258f493c680e2e27ce680427678fdf75a089be30 | 1,059 | h | C | HadesMP/Engine/Enums/rtti.h | SystematicSkid/Hades-LuaLoader | d57a8d2f4b3bd684af473d045afddee6778b7090 | [
"MIT"
] | 7 | 2021-01-01T09:12:43.000Z | 2022-01-11T19:22:13.000Z | HadesMP/Engine/Enums/rtti.h | SystematicSkid/HadesMP | d57a8d2f4b3bd684af473d045afddee6778b7090 | [
"MIT"
] | null | null | null | HadesMP/Engine/Enums/rtti.h | SystematicSkid/HadesMP | d57a8d2f4b3bd684af473d045afddee6778b7090 | [
"MIT"
] | 1 | 2020-12-17T19:06:22.000Z | 2020-12-17T19:06:22.000Z | #pragma once
namespace engine
{
enum RttiType
{
Component = 0x1,
Effect = 0x2,
Weapon = 0x4,
GameEvent = 0x8,
IUndoRedoRecord = 0x10,
Thing = 0x21,
Animation = 0x41,
Light = 0x81,
Obstacle = 0x121,
Unit = 0x221,
Projectile = 0x421,
ArcProjectile = 0xC21,
BeamProjectile = 0x1421,
HomingProjectile = 0x2421,
InstantProjectile = 0x4421,
LobProjectile = 0x8421,
SkyProjectile = 0x10421,
BookAnimation = 0x20041,
SlideAnimation = 0x60041,
ConstantAnimation = 0x80041,
DatalessAnimation = 0x100041,
PlayerUnit = 0x200221,
TagEffect = 0x22,
CharmEffect = 0x42,
SpeedEffect = 0x82,
WeaponFireEffect = 0x102,
InvulnerableEffect = 0x202,
DamageOverTimeEffect = 0x402,
DelayedKnockbackEffect = 0x802,
ProjectileDefenseEffect = 0x1002,
DamageOverDistanceEffect = 0x2002,
BlinkWeapon = 0x24,
GunWeapon = 0x44,
RamWeapon = 0x84,
DelayedGameEvent = 0x28,
ScriptUpdateGameEvent = 0x48,
UpdateGameEvent = 0x88,
PersistentGameEvent = 0x108,
UndoTransaction = 0x30,
UndoRedoRecord = 0x50,
};
} | 22.0625 | 36 | 0.717658 |
66c0ad67f27c116385307388a5c6a631871959fb | 1,196 | h | C | source/bsys/actionbatching/actionbatching.h | bluebackblue/brownie | 917fcc71e5b0a807c0a8dab22a9ca7f3b0d60917 | [
"MIT"
] | null | null | null | source/bsys/actionbatching/actionbatching.h | bluebackblue/brownie | 917fcc71e5b0a807c0a8dab22a9ca7f3b0d60917 | [
"MIT"
] | null | null | null | source/bsys/actionbatching/actionbatching.h | bluebackblue/brownie | 917fcc71e5b0a807c0a8dab22a9ca7f3b0d60917 | [
"MIT"
] | null | null | null | #pragma once
/**
* Copyright (c) blueback
* Released under the MIT License
* https://github.com/bluebackblue/brownie/blob/master/LICENSE.txt
* http://bbbproject.sakura.ne.jp/wordpress/mitlicense
* @brief アクションのバッチ処理。
*/
/** include
*/
#pragma warning(push)
#pragma warning(disable:4464)
#include "../types/types.h"
#pragma warning(pop)
/** include
*/
#include "./actionbatching_actionlist.h"
#include "./actionbatching_actionitem_delay.h"
#include "./actionbatching_actionitem_debuglog.h"
#include "./actionbatching_actionitem_call.h"
/** NBsys::NActionBatching
*/
#if(BSYS_ACTIONBATCHING_ENABLE)
namespace NBsys{namespace NActionBatching
{
/** ActionBatching
*/
class ActionBatching
{
private:
/** worklist
*/
STLList<sharedptr<ActionBatching_ActionList>>::Type worklist;
public:
/** constructor
*/
ActionBatching();
/** destructor
*/
nonvirtual ~ActionBatching();
public:
/** Update
*/
void Update(f32 a_delta);
/** StartBatching
*/
void StartBatching(sharedptr<ActionBatching_ActionList>& a_actionlist);
/** IsBusy
*/
bool IsBusy() const;
};
}}
#endif
| 16.383562 | 74 | 0.663043 |
0fb90994ee3b5dccb440df65e4f581ef3917d8e8 | 249 | c | C | gcc-gcc-7_3_0-release/gcc/testsuite/gcc.dg/cpp/pr34859.c | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | 7 | 2020-05-02T17:34:05.000Z | 2021-10-17T10:15:18.000Z | gcc-gcc-7_3_0-release/gcc/testsuite/gcc.dg/cpp/pr34859.c | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | null | null | null | gcc-gcc-7_3_0-release/gcc/testsuite/gcc.dg/cpp/pr34859.c | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | 2 | 2020-07-27T00:22:36.000Z | 2021-04-01T09:41:02.000Z | /* PR c++/34859.
It is ok to redefine __STDC_CONSTANT_MACROS and __STDC_LIMIT_MACROS. */
/* { dg-do preprocess } */
#define __STDC_CONSTANT_MACROS 1
#define __STDC_CONSTANT_MACROS 1
#define __STDC_LIMIT_MACROS 1
#define __STDC_LIMIT_MACROS 1
| 22.636364 | 75 | 0.771084 |
0fc4b07cae450c40791f424298e9045857b73c87 | 2,540 | h | C | System/Library/PrivateFrameworks/IMAVCore.framework/IMAVCallManager.h | lechium/tvOS10Headers | f0c99993da6cc502d36fdc5cb4ff90d94b12bf67 | [
"MIT"
] | 4 | 2017-03-23T00:01:54.000Z | 2018-08-04T20:16:32.000Z | System/Library/PrivateFrameworks/IMAVCore.framework/IMAVCallManager.h | lechium/tvOS10Headers | f0c99993da6cc502d36fdc5cb4ff90d94b12bf67 | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/IMAVCore.framework/IMAVCallManager.h | lechium/tvOS10Headers | f0c99993da6cc502d36fdc5cb4ff90d94b12bf67 | [
"MIT"
] | 4 | 2017-05-14T16:23:26.000Z | 2019-12-21T15:07:59.000Z | /*
* This header is generated by classdump-dyld 1.0
* on Wednesday, March 22, 2017 at 9:07:20 AM Mountain Standard Time
* Operating System: Version 10.1 (Build 14U593)
* Image Source: /System/Library/PrivateFrameworks/IMAVCore.framework/IMAVCore
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
@class IMPowerAssertion, NSMutableArray, NSMutableDictionary, NSDate, NSArray;
@interface IMAVCallManager : NSObject {
IMPowerAssertion* _powerAssertion;
NSMutableArray* _chatArray;
NSMutableArray* _acChatProxyArray;
NSMutableArray* _avChatProxyArray;
NSMutableDictionary* _guidToACChatProxyMap;
NSMutableDictionary* _guidToAVChatProxyMap;
NSDate* _lastCallStateChange;
int _avToken;
int _acToken;
unsigned _avCallState;
unsigned _acCallState;
unsigned _telephonyCallState;
unsigned _globalCallState;
}
@property (assign,setter=_setTelephonyCallState:,nonatomic) unsigned _telephonyCallState; //@synthesize telephonyCallState=_telephonyCallState - In the implementation block
@property (nonatomic,retain,readonly) NSArray * _FTCalls;
@property (nonatomic,readonly) unsigned callState;
@property (nonatomic,readonly) BOOL hasActiveCall;
@property (nonatomic,retain,readonly) NSArray * calls;
+(id)sharedInstance;
-(void)dealloc;
-(id)init;
-(BOOL)hasActiveCall;
-(NSArray *)calls;
-(unsigned)callState;
-(void)_updateACChatProxyWithInfo:(id)arg1 ;
-(void)_updateAVChatProxyWithInfo:(id)arg1 ;
-(void)_updateOverallChatState;
-(void)_addIMAVChatToChatList:(id)arg1 ;
-(void)_addAVChatProxy:(id)arg1 ;
-(void)_addACChatProxy:(id)arg1 ;
-(void)_removeIMAVChatFromChatList:(id)arg1 ;
-(void)_sendProxyUpdate;
-(unsigned)_callState;
-(BOOL)_hasActiveFaceTimeCall;
-(BOOL)_hasActiveAudioCall;
-(void)_updateAVCallState;
-(void)_updateACCallState;
-(void)_setTelephonyCallState:(unsigned)arg1 ;
-(void)_setAVCallState:(unsigned)arg1 ;
-(void)_setACCallState:(unsigned)arg1 ;
-(void)_setAVCallState:(unsigned)arg1 quietly:(BOOL)arg2 ;
-(void)_setACCallState:(unsigned)arg1 quietly:(BOOL)arg2 ;
-(void)__setTelephonyCallState:(unsigned)arg1 ;
-(NSArray *)_FTCalls;
-(id)_mutableFTCalls;
-(id)_copyMutableFTCalls;
-(void)_postStateChangeNamed:(id)arg1 fromState:(unsigned)arg2 toState:(unsigned)arg3 postType:(BOOL)arg4 type:(unsigned)arg5 ;
-(unsigned)_telephonyCallState;
-(void)_postStateChangeIfNecessary;
-(id)_calls;
-(unsigned)_callStateForType:(unsigned)arg1 ;
-(id)_nonRetainingChatList;
-(BOOL)_hasActiveTelephonyCall;
-(id)_activeFaceTimeCall;
-(id)_activeAudioCall;
@end
| 34.324324 | 185 | 0.796063 |
8441a72eb395871a714316bb3c3ee77fd602830f | 14,237 | c | C | pciheader.c | joseljim/PCI_Header | 77d57e4a75cfbdb3fccad160fc6be43063ad0b93 | [
"MIT"
] | null | null | null | pciheader.c | joseljim/PCI_Header | 77d57e4a75cfbdb3fccad160fc6be43063ad0b93 | [
"MIT"
] | null | null | null | pciheader.c | joseljim/PCI_Header | 77d57e4a75cfbdb3fccad160fc6be43063ad0b93 | [
"MIT"
] | null | null | null | // ================================================================================== //
// MIT License
//
// Copyright (c) 2022 José Luis Jiménez, Rodolfo Casillas and Erick Contreras
//
// 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.
// ================================================================================== //
// ================================================================================== //
// pciheader -- Prints the header of a PCI(e) device
// Author(s): Jose Luis Jimenez, Rodolfo Casillas, Erick Contreras
// A01633245 A01229493 A01630105
// ================================================================================== //
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "lib/pci.h"
// TODO:
// Investigate the final address of the PCI header and complete the define below
#define PCI_HEADER_FINAL_ADDRESS 0x40
struct config_space_bitfield {
char name[64];
unsigned int offset;
unsigned int size;
};
void print_pci_header(struct pci_dev *pdev);
struct pci_dev * search_device(struct pci_access *pacc, u8 bus, u8 slot, u8 func);
void int_2_hexstr(u32 value, unsigned int size, char *destination);
int convert_hexstring(char *hexstring);
// TODO:
// Explain what this struct is
// Explain what each column (field) of this struct represents
// This struct contains all the registers of a PCI type 0 header (endpoint)
// First column represents the registers, second column the offsets and the third column represents the size (in Bytes)
struct config_space_bitfield type_0_header[] = {
{"Vendor ID", 0x0, 2},
{"Device ID", 0x2, 2},
{"Command", 0x4, 2},
{"Status", 0x6, 2},
{"Revision ID", 0x8, 1},
{"Class Code", 0xA, 3},
{"Cache Line S", 0xC, 1},
{"Lat. Timer", 0xD, 1}, // Found error: Lat. Timer goes after Cache Line S, confirmed the mismatch with online documentation, so the order was fixed
{"Header Type", 0xE, 1},
{"BIST", 0xF, 1},
{"BAR 0", 0x10, 4},
{"BAR 1", 0x14, 4},
{"BAR 2", 0x18, 4},
{"BAR 3", 0x1C, 4},
{"BAR 4", 0x20, 4},
{"BAR 5", 0x24, 4},
{"Cardbus CIS Pointer", 0x28, 4},
{"Subsystem Vendor ID", 0x2C, 2},
{"Subsystem ID", 0x2E, 2},
{"Expansion ROM Address", 0x30, 4},
{"Cap. Pointer", 0x34, 1},
{"Reserved", 0x35, 3},
{"Reserved", 0x38, 4},
{"IRQ", 0x3C, 1},
{"IRQ Pin", 0x3D, 1},
{"Min Gnt.", 0x3E, 1},
{"Max Lat.", 0x3F, 1},
{"End", 0x40, 5},
};
// TODO:
// Explain what this struct is
// Explain what each column (field) of this struct represents
// This struct contains all the registers of a PCI type 1 header (Bridge)
// First column represents the registers, second column the offsets and the third column represents the size (in Bytes)
struct config_space_bitfield type_1_header[] = {
{"Vendor ID", 0x0, 2},
{"Device ID", 0x2, 2},
{"Command", 0x4, 2},
{"Status", 0x6, 2},
{"Revision ID", 0x8, 1},
{"Class Code", 0xA, 3},
{"Cache Line S", 0xC, 1},
{"Lat. Timer", 0xD, 1}, // Found error: Lat. Timer goes after Cache Line S, confirmed the mismatch with online documentation, so the order was fixed
{"Header Type", 0xE, 1},
{"BIST", 0xF, 1},
{"BAR 0", 0x10, 4},
{"BAR 1", 0x14, 4},
{"Primary Bus", 0x18, 1}, // Found error: Primary bus goes before Secondary Bus, confirmed the mismatch with online documentation, so the order was fixed
{"Secondary Bus", 0x19, 1},
{"Sub Bus", 0x1A, 1},
{"Sec Lat timer", 0x1B, 1},
{"IO Base", 0x1C, 1},
{"IO Limit", 0x1D, 1},
{"Sec. Status", 0x1E, 2},
{"Memory Base", 0x20, 2}, // Found error: Memory base goes before Memory limit, confirmed the mismatch with online documentation, so the order was fixed
{"Memory Limit", 0x22, 2},
{"Pref. Memory Base", 0x24, 2}, // Found error: Pref. Memory base goes before Pref. Memory limit, confirmed the mismatch with online documentation, so the order was fixed
{"Pref. Memory Limit", 0x26, 2},
{"Pref. Memory Base U", 0x28, 4},
{"Pref. Memory Base L", 0x2C, 4},
{"IO Base Upper", 0x30, 2},
{"IO Limit Upper", 0x32, 2},
{"Cap. Pointer", 0x34, 1},
{"Reserved", 0x35, 3},
{"Exp. ROM Base Addr", 0x38, 4},
{"IRQ Line", 0x3C, 1},
{"IRQ Pin", 0x3D, 1},
{"Min Gnt.", 0x3E, 1},
{"Max Lat.", 0x3F, 1},
{"End", 0x40, 5},
};
struct config_space_bitfield *types[2] = {&type_0_header[0], &type_1_header[0]}; // pointer to both types of headers (endpoint and bridges)
// function to print the pci header once all the information is obtained
void print_pci_header(struct pci_dev *pdev) {
u8 header_type = 0;
u32 value;
u32 bitfield_value;
u64 mask;
unsigned int pci_header_address;
unsigned int space_available;
unsigned int padding;
unsigned int bitfield = 0;
unsigned int bitfield_copy;
int j;
struct config_space_bitfield *ptr;
char str_value[16];
const char *ctypes[] = {"n Endpoint", " Bridge"};
if(pdev == NULL){ // exit if no device is given as parameter
return;
}
// TODO:
// Explain what the following code does
// This function retrieves the type of PCI device we are delaing with, either endpoint or bridge,
// by using the mask PCI_HEADER_TYPE which determines the position where this information is available
header_type = pci_read_byte(pdev, PCI_HEADER_TYPE) & 0x1;
// here we hold a pointer to the corresponding type of pci device
ptr = types[header_type];
// TODO:
// Print the following message:
// Selected device <bus>:<device>:<function> is a <type>
// Substitute <bus> <device> and <function> with the values of bus, device and function, respectively
// Substitute <type> with either Endpoint or Bridge, accordingly
printf("Selected device %x:%x:%x is a%s\n", pdev->bus, pdev->dev, pdev->func, ctypes[header_type]);
printf("|-----------------------------------------------------------|\t\t|-----------------------------------------------------------|\n");
printf("| Byte 0 | Byte 1 | Byte 2 | Byte 3 |\t\t| Byte 0 | Byte 1 | Byte 2 | Byte 3 |\n");
printf("|-----------------------------------------------------------|\t\t|-----------------------------------------------------------|\tAddress\n");
for(pci_header_address=0; pci_header_address<PCI_HEADER_FINAL_ADDRESS; pci_header_address+=4){ // iterate through all the registers of the header
bitfield_copy = bitfield;
putchar('|');
while(ptr[bitfield].offset < pci_header_address+4){
space_available = 14 * ptr[bitfield].size + (ptr[bitfield].size -1);
padding = (space_available - strlen(ptr[bitfield].name)) / 2;
for(j=0; j<(int) padding; j++){
putchar(' ');
}
// TODO:
// Print name of PCI configuration register
// printf("%s", /*???*/);
printf("%s", ptr[bitfield].name);
for(j=(int) padding + strlen(ptr[bitfield].name); j<(int) space_available; j++){
putchar(' ');
}
putchar('|');
bitfield++;
}
// TODO:
// Explain what this function does
// This function retrieves the value of the corresponding PCI register using the corresponding address
// the long option is used since not all register contain information with size of a byte
value = pci_read_long(pdev, pci_header_address);
bitfield = bitfield_copy;
printf("\t\t|");
while(ptr[bitfield].offset < pci_header_address+4){
if(ptr[bitfield].size == 5){
break;
}
// TODO:
// Explain the purpose of the following line
// This line generates a mask according to the number of bits that are present in each register of the PCI header,
// so that all the information of the register is obtained
mask = ((1L<<(ptr[bitfield].size * 8))-1) << (8*(ptr[bitfield].offset - pci_header_address));
bitfield_value = (value & mask) >> (8*(ptr[bitfield].offset - pci_header_address));
space_available = 14 * ptr[bitfield].size + ptr[bitfield].size -1;
padding = (space_available - ( 2 + ptr[bitfield].size)) / 2;
for(j=0; j<(int) padding; j++){
putchar(' ');
}
int_2_hexstr(bitfield_value, ptr[bitfield].size, str_value);
printf("%s", str_value);
for(j=(int) padding+strlen(str_value); j<(int) space_available; j++){
putchar(' ');
}
putchar('|');
bitfield++;
}
printf("\t0x%02x", pci_header_address);
printf("\n|-----------------------------------------------------------|\t\t|-----------------------------------------------------------|\n");
}
}
// function to access the PCI device depending on the arguments bus, slot and function
struct pci_dev * search_device(struct pci_access *pacc, u8 bus, u8 slot, u8 func) {
struct pci_dev *dev;
for(dev = pacc->devices; dev != NULL; dev = dev->next){
if((dev-> bus == bus) && (dev->dev == slot) && (dev->func == func)){
return dev;
}
}
return NULL;
}
// function to convert an int to a string representing a hex value
void int_2_hexstr(u32 value, unsigned int size, char *destination) {
const char letters[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
unsigned int i;
/* Init string */
strcpy(destination, "0x");
for(i=0; i<size; i++){
strcat(destination, "00");
}
i=2+2*size - 1;
while((value > 0) && (i>1)){
destination[i] = letters[(value & 0xf)];
value = value >> 4;
i--;
}
}
// function to convert a string representign a number to an integer
int convert_hexstring(char *hexstring) {
int number;
if(strstr(hexstring, "0x") == NULL)
number = (int) strtol(hexstring, NULL, 16);
else
number = (int) strtol(hexstring, NULL, 0);
return number;
}
int main(int argc, char *argv[])
{
struct pci_access *pacc;
struct pci_dev *dev;
u8 bus;
u8 slot;
u8 func;
// Check arguments
// Verify that all 4 arguments are passed to the program
// 1st arg is the name of the program
// 2nd arg is Bus number to search for
// 3rd arg is Device number to search for within the bus
// 4th arg is Function number to search for within the device
if(argc != 4){
printf("Three Arguments must be passed!\n");
printf("Usage: %s [bus] [device] [function]\n", argv[0]);
printf("With:\n");
printf("\tbus:\tBus number of device to print PCI Header\n");
printf("\tdevice:\tDevice number of device to print PCI Header\n");
printf("\tbus:\tFunction number of device to print PCI Header\n");
return -1;
}
// TODO:
// Explain what the following function calls do
// pci_alloc() of struct pci_access hold necessary information for the access that is going to done to the PCI device
pacc = pci_alloc();
// pci_init() initializes said access
pci_init(pacc);
// pci_scan_bus() scans the device that was previously accessed with the configurations made by the two functions above
pci_scan_bus(pacc);
// parse user input
bus = convert_hexstring(argv[1]);
slot = convert_hexstring(argv[2]);
func = convert_hexstring(argv[3]);
// TODO:
// Complete the function call for searching the device provided by the user
//dev = search_device(/*???*/, /*???*/, /*???*/, /*???*/,);
dev = search_device(pacc, bus, slot, func);
if(dev == NULL) {
printf("No device found with %x:%x:%x\n", bus, slot, func); // error check if device is not found
return -1;
}
// pci_fill_info returns the values of the known fields of the PCI device
pci_fill_info(dev,PCI_FILL_IDENT | PCI_FILL_CLASS);
print_pci_header(dev); // print PCI header
// pci_cleanup() terminates the access previously initiated once everything is complete
pci_cleanup(pacc);
return 0;
}
| 41.386628 | 183 | 0.549835 |
68f7a35b5069895f9daaa715309393d4ff73934e | 9,017 | c | C | src/main.c | sachu92/TSVHistogram-mpi | 657ef78cc5d57d54f169241cecad09d44ad880c8 | [
"MIT"
] | null | null | null | src/main.c | sachu92/TSVHistogram-mpi | 657ef78cc5d57d54f169241cecad09d44ad880c8 | [
"MIT"
] | null | null | null | src/main.c | sachu92/TSVHistogram-mpi | 657ef78cc5d57d54f169241cecad09d44ad880c8 | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mpi.h"
#include "tsv_helper.h"
#define BYTESINMB 1048576
int main (int argc, char *argv[])
{
int i;
int mpi_rank, mpi_num_procs;
int column;
int num_bins;
int local_error_flag = 0;
int global_error_flag = 0;
int file_read_done_flag = 0;
int first_read_from_file_flag = 1;
int num_cols_in_line = 0;
FILE * data_file = NULL;
size_t file_read_result;
size_t file_size;
size_t buffer_size;
size_t chunk_size;
size_t current_pos_in_file;
long chunk_processed_line_count;
long buffer_processed_line_count = 0;
long data_processed_line_count = 0;
long chunk_discarded_line_count;
long buffer_discarded_line_count = 0;
long data_discarded_line_count = 0;
long *chunk_bins = NULL;
long *buffer_bins = NULL;
long *data_bins = NULL;
char *buffer = NULL;
char *chunk = NULL;
char error_message[100];
char file_size_string[100];
char num_cols_buffer[256];
double data_min = 1e42, data_max = -1e42;
double bin_width;
// Initialize MPI environment
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
MPI_Comm_size(MPI_COMM_WORLD, &mpi_num_procs);
chunk_size = 50*BYTESINMB;
buffer_size = mpi_num_procs*chunk_size;
if(mpi_rank == 0) // root node
{
if(argc < 6)
{
global_error_flag = 1;
sprintf(error_message, "Usage: %s <column> <min-value> <max-value> <num-bins> <file>\n", argv[0]);
}
if(!global_error_flag)
{
column = atof(argv[1]);
data_min = atof(argv[2]);
data_max = atof(argv[3]);
num_bins = atof(argv[4]);
data_file = fopen(argv[5], "r");
if (data_file == NULL)
{
global_error_flag = 1;
strcpy(error_message, "Cannot open file.");
}
}
if(!global_error_flag)
{
// obtain file size:
fseek (data_file , 0 , SEEK_END);
file_size = ftell (data_file);
rewind (data_file);
getSizeInHumanReadableForm(file_size,file_size_string);
buffer = (char*) malloc(sizeof(char)*buffer_size);
if(buffer == NULL)
{
global_error_flag = 1;
strcpy(error_message, "Cannot allocate memory for buffer.");
}
}
if(!global_error_flag)
{
data_bins = (long*) malloc(sizeof(long)*num_bins);
buffer_bins = (long*) malloc(sizeof(long)*num_bins);
if(data_bins == NULL || buffer_bins == NULL)
{
global_error_flag = 1;
strcpy(error_message, "Cannot allocate memory for bins.");
}
else
{
for(i = 0;i < num_bins;i++)
data_bins[i] = 0;
}
}
}
MPI_Bcast(&global_error_flag, 1, MPI_INT, 0, MPI_COMM_WORLD);
if(!global_error_flag)
{
MPI_Bcast(&file_size, 1, MPI_LONG, 0, MPI_COMM_WORLD);
chunk = (char *) malloc(sizeof(char)*chunk_size);
chunk_bins = (long *)malloc(sizeof(long)*num_bins);
if(chunk == NULL || chunk_bins == NULL)
local_error_flag = 1;
MPI_Reduce(&local_error_flag, &global_error_flag, 1, MPI_INT, MPI_MAX, 0, MPI_COMM_WORLD);
if(mpi_rank == 0)
{
if(global_error_flag)
strcpy(error_message, "Cannot allocate memory for chunk in one of the procs.");
}
}
MPI_Bcast(&global_error_flag, 1, MPI_INT, 0, MPI_COMM_WORLD);
if(!global_error_flag)
{
MPI_Bcast(&column, 1, MPI_INT, 0, MPI_COMM_WORLD);
MPI_Bcast(&num_bins, 1, MPI_INT, 0, MPI_COMM_WORLD);
MPI_Bcast(&data_max, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
MPI_Bcast(&data_min, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);
bin_width = (data_max - data_min) / (num_bins - 1);
current_pos_in_file = 1;
while(current_pos_in_file < file_size)
{
if(mpi_rank == 0)
{
if(current_pos_in_file + buffer_size >= file_size)
{
buffer_size = (file_size - current_pos_in_file);
if(buffer_size == 0)
file_read_done_flag = 2;
else
{
file_read_done_flag = 1;
chunk_size = (int) (buffer_size / mpi_num_procs);
}
}
if(file_read_done_flag < 2)
{
// printf("Reading file at %ld of %ld, buffer size is %ld...\n", current_pos_in_file, file_size, buffer_size);
// allocate memory to contain a chunk of file:
file_read_result = fread(buffer, 1, buffer_size, data_file);
if (file_read_result != buffer_size)
{
global_error_flag = 1;
sprintf(error_message, "Cannot read from file. diff = %ld", buffer_size-file_read_result);
}
if(first_read_from_file_flag == 1)
{
//Copy the initial portion of string in buffer to a new buffer to process number of lines.
memcpy(num_cols_buffer, buffer, 255);
getNumColsInLine(num_cols_buffer, &num_cols_in_line);
first_read_from_file_flag = 0;
}
}
current_pos_in_file += buffer_size;
}
MPI_Bcast(&file_read_done_flag, 1, MPI_INT, 0, MPI_COMM_WORLD);
if(file_read_done_flag > 1)
break;
MPI_Bcast(&global_error_flag, 1, MPI_INT, 0, MPI_COMM_WORLD);
if(!global_error_flag)
{
MPI_Bcast(&num_cols_in_line, 1, MPI_INT, 0, MPI_COMM_WORLD);
MPI_Bcast(¤t_pos_in_file, 1, MPI_LONG, 0, MPI_COMM_WORLD);
MPI_Scatter(buffer, chunk_size, MPI_CHAR, chunk, chunk_size, MPI_CHAR, 0, MPI_COMM_WORLD);
// getMinMaxInChunk(chunk, column, num_cols_in_line, &chunk_min, &chunk_max, &chunk_processed_line_count, &chunk_discarded_line_count);
// clear bins
for(i = 0;i < num_bins;i++)
{
// printf("Rank %d, bin %d of %d.\n", mpi_rank, i, num_bins);
chunk_bins[i] = 0;
}
sortDataIntoBins(chunk, column, num_cols_in_line, data_min, data_max, bin_width, chunk_bins, &chunk_processed_line_count, &chunk_discarded_line_count);
// MPI_Reduce(&chunk_min, &buffer_min, 1, MPI_DOUBLE, MPI_MIN, 0, MPI_COMM_WORLD);
// MPI_Reduce(&chunk_max, &buffer_max, 1, MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
MPI_Reduce(chunk_bins, buffer_bins, num_bins, MPI_LONG, MPI_SUM, 0, MPI_COMM_WORLD);
MPI_Reduce(&chunk_processed_line_count, &buffer_processed_line_count, 1, MPI_LONG, MPI_SUM, 0, MPI_COMM_WORLD);
MPI_Reduce(&chunk_discarded_line_count, &buffer_discarded_line_count, 1, MPI_LONG, MPI_SUM, 0, MPI_COMM_WORLD);
if(mpi_rank == 0)
{
// if(buffer_min < data_min)
// data_min = buffer_min;
// if(buffer_max > data_max)
// data_max = buffer_max;
for(i = 0;i < num_bins;i++)
data_bins[i] += buffer_bins[i];
data_processed_line_count += buffer_processed_line_count;
data_discarded_line_count += buffer_discarded_line_count;
}
}
}
}
if(chunk)
free(chunk);
if(chunk_bins)
free(chunk_bins);
if(mpi_rank == 0)
{
if(!global_error_flag)
{
// printf("data min = %e, data max = %e\n", data_min, data_max);
printf("# Output of %s %s %s %s %s %s\n", argv[0], argv[1], argv[2], argv[3], argv[4], argv[5]);
printf("# Data file size = %s\n", file_size_string);
printf("# Number of lines processed = %ld\n", data_processed_line_count);
printf("# Number of lines discarded = %ld\n", data_discarded_line_count);
for(i = 0;i < num_bins;i++)
printf("%.5lf\t%.5lf\n", data_min + bin_width*i, ((double)data_bins[i])/((double)data_processed_line_count));
}
// terminate
if(data_file)
fclose (data_file);
if(buffer)
free (buffer);
if(buffer_bins)
free(buffer_bins);
if(data_bins)
free(data_bins);
if(global_error_flag)
printf("\n%s\n", error_message);
}
MPI_Finalize();
return 0;
}
| 37.106996 | 167 | 0.546967 |
571e830becefe506aad6a53f01a6faf5da033ee0 | 6,415 | h | C | ds/AATreeImpl.h | jumbuna/data-structures-algorithms | e6f9ecca13cc77ddf11fc645fc9e362b80862674 | [
"MIT"
] | 1 | 2020-07-11T09:06:52.000Z | 2020-07-11T09:06:52.000Z | ds/AATreeImpl.h | jumbuna/data-structures-algorithms | e6f9ecca13cc77ddf11fc645fc9e362b80862674 | [
"MIT"
] | null | null | null | ds/AATreeImpl.h | jumbuna/data-structures-algorithms | e6f9ecca13cc77ddf11fc645fc9e362b80862674 | [
"MIT"
] | null | null | null | #include "AATree.h"
namespace jumbuna {
template<class T>
AANode<T>::AANode(T element, BstNode<T> *parent)
:BstNode<T> (element, parent)
{
//leaf nodes have a level of 1 by default
level = 1;
}
template<class T>
AANode<T>* AANode<T>::getLeftChild() {
return BstNode<T>::leftChild ? static_cast<AANode*> (BstNode<T>::leftChild) : nullptr;
}
template<class T>
AANode<T>* AANode<T>::getRightChild() {
return BstNode<T>::rightChild ? static_cast<AANode*> (BstNode<T>::rightChild) : nullptr;
}
template<class T>
AANode<T>* AANode<T>::getParent() {
return BstNode<T>::parent ? static_cast<AANode*> (BstNode<T>::parent) : nullptr;
}
template<class T, class C>
bool AATree<T, C>::leftHorizontalLinkExists(aaNode *candidate) {
//left-child has same level as parent
aaNode *leftChild = candidate->getLeftChild();
if(leftChild) {
if(leftChild->level == candidate->level) {
return true;
}
}
return false;
}
template<class T, class C>
bool AATree<T, C>::rightHorizontalLinkExists(aaNode *candidate) {
//right-grandchild has same level as grandparent
aaNode *rightChild = candidate->getRightChild();
if(rightChild) {
aaNode *rightGrandChild = rightChild->getRightChild();
if(rightGrandChild) {
if(rightGrandChild->level == candidate->level) {
return true;
}
}
}
return false;
}
template<class T, class C>
void AATree<T, C>::split(aaNode *candidate) {
//fix a right horizontal link by doing a left rotation abot the parent/rightchild
if(rightHorizontalLinkExists(candidate)) {
aaNode *rightChild = candidate->getRightChild();
BstUtility<T, C>::rightRightCase(rightChild, this);
rightChild->level += 1;
}
}
template<class T, class C>
void AATree<T, C>::skew(aaNode *candidate) {
//fix a left horizontal link by doing a right rotation about the leftchild
if(leftHorizontalLinkExists(candidate)) {
Node *leftChild = candidate->getLeftChild();
BstUtility<T, C>::leftLeftCase(leftChild, this);
}
}
template<class T, class C>
void AATree<T, C>::insert(Node *candidate, Node *parent, T element) {
//first insert sice root is null
if(!candidate && !parent) {
BinarySearchTree<T, C>::root = nodeAllocator.create(element, parent);
return;
}
//reached insertion point
if(!candidate) {
if(BinarySearchTree<T, C>::comparator(parent->element, element)) {
parent->leftChild = nodeAllocator.create(element, parent);
}else {
parent->rightChild = nodeAllocator.create(element, parent);
}
return;
}
//internal node
if(BinarySearchTree<T, C>::comparator(candidate->element, element)) {
insert(candidate->leftChild, candidate, element);
}else {
insert(candidate->rightChild, candidate, element);
}
//balance the tree
skew(static_cast<aaNode*> (candidate));
split(static_cast<aaNode*> (candidate));
}
template<class T, class C>
void AATree<T, C>::remove(Node *candidate, T element) {
if(!candidate) {
//executed only when a search is not done before removing begin
return;
}
if(candidate->element == element) {
Node *parent = candidate->parent;
//leafnode or leftchild only
if(!candidate->rightChild) {
Node *leftChild = candidate->leftChild;
if(parent) {
if(parent->leftChild == candidate) {
parent->leftChild = leftChild;
}else {
parent->rightChild = leftChild;
}
}else {
BinarySearchTree<T, C>::root = leftChild;
}
if(leftChild) {
leftChild->parent = parent;
}
//free memory
nodeAllocator.destroy(static_cast<aaNode*> (candidate));
return;
}else if(!candidate->leftChild) {
//leafnode/ rightchild only
Node *rightChild = candidate->rightChild;
if(parent) {
if(parent->leftChild == candidate) {
parent->leftChild = rightChild;
}else {
parent->rightChild = rightChild;
}
}else {
BinarySearchTree<T, C>::root = rightChild;
}
if(rightChild) {
rightChild->parent = parent;
}
//free memory
nodeAllocator.destroy(static_cast<aaNode*> (candidate));
return;
}else {
//internal node
//find successor from left side
T successor = BstUtility<T, C>::preOrderSuccessor(candidate->leftChild);
candidate->element = successor;
remove(candidate->leftChild, successor);
}
}else {
//traverse the tree to find the target node
if(BinarySearchTree<T, C>::comparator(candidate->element, element)) {
remove(candidate->leftChild, element);
}else {
remove(candidate->rightChild, element);
}
}
//balance the tree
updateLevel(static_cast<aaNode*> (candidate));
skew(static_cast<aaNode*> (candidate));
split(static_cast<aaNode*> (candidate));
}
template<class T, class C>
void AATree<T, C>::updateLevel(aaNode *candidate) {
//if parent is 2 levels higher than any of its children then reduce parents level by 1
//if rightchild had same level as parent then also reduce by 1
std::size_t leftLevel, rightLevel;
leftLevel = rightLevel = 0;
if(candidate->leftChild) {
leftLevel = (*candidate->getLeftChild()).level;
}
if(candidate->rightChild) {
rightLevel = (*candidate->getRightChild()).level;
}
if(candidate->level - std::min(leftLevel, rightLevel) == 2) {
if(candidate->getRightChild()) {
if(rightLevel == candidate->level) {
(*candidate->getRightChild()).level -= 1;
}
}
candidate->level -= 1;
}
}
template<class T, class C>
AATree<T, C>::AATree(std::size_t noOfelements)
:BinarySearchTree<T, C> ()
{
//allocate exact amount of memory to hold the nodes
nodeAllocator.numberOfChunks = noOfelements;
}
template<class T, class C>
void AATree<T, C>::insert(T element) {
insert(BinarySearchTree<T, C>::root, BinarySearchTree<T, C>::root, element);
++BinarySearchTree<T, C>::nodeCount;
}
template<class T, class C>
void AATree<T, C>::remove(T element) {
if(contains(element)) {
remove(BinarySearchTree<T, C>::root, element);
--BinarySearchTree<T, C>::nodeCount;
}
}
template<class T, class C>
bool AATree<T, C>::contains(T element) {
return BstUtility<T, C>::contains(BinarySearchTree<T, C>::root, element) != nullptr;
}
template<class T, class C>
std::size_t AATree<T, C>::size() {
return BinarySearchTree<T, C>::nodeCount;
}
template<class T, class C>
Vector<T> AATree<T, C>::treeTraversal(TraversalOrder order) {
return BstUtility<T, C>::treeTraversal(BinarySearchTree<T, C>::root, order);
}
template<class T, class C>
void AATree<T, C>::clear() {
nodeAllocator.reset();
BinarySearchTree<T, C>::root = nullptr;
BinarySearchTree<T, C>::nodeCount = 0;
}
} | 27.770563 | 89 | 0.695713 |
22da0387b07e4d3e592589ea5749cdf5b1815a2b | 1,544 | h | C | Final_Fantasy_Mystery_World/Final_Fantasy_Mystery_World/m1Collisions.h | polarpathgames/Polar-Path | cf0eed03bbd6478c4fdd1eb074f48a2ceb78e0d6 | [
"MIT"
] | 9 | 2019-03-05T07:26:04.000Z | 2019-10-09T15:57:45.000Z | Final_Fantasy_Mystery_World/Final_Fantasy_Mystery_World/m1Collisions.h | polarpathgames/Polar-Path | cf0eed03bbd6478c4fdd1eb074f48a2ceb78e0d6 | [
"MIT"
] | 114 | 2019-03-10T09:35:12.000Z | 2019-06-10T21:39:12.000Z | Final_Fantasy_Mystery_World/Final_Fantasy_Mystery_World/m1Collisions.h | polarpathgames/Polar-Path | cf0eed03bbd6478c4fdd1eb074f48a2ceb78e0d6 | [
"MIT"
] | 3 | 2019-02-25T16:12:40.000Z | 2019-11-19T20:48:06.000Z | #ifndef __m1Collisions_H__
#define __m1Collisions_H__
#include "m1Module.h"
#include "SDL/include/SDL_rect.h"
#include <vector>
#include <list>
enum COLLIDER_TYPE
{
COLLIDER_NONE,
COLLIDER_PLAYER,
COLLIDER_SHOP,
COLLIDER_HOME,
COLLIDER_NEXT_A,
COLLIDER_NEXT_B,
COLLIDER_LAST_A,
COLLIDER_LAST_B,
COLLIDER_MENU_QUEST,
COLLIDER_QUEST_ICE,
COLLIDER_CUTSCENE_BRIDGE,
COLLIDER_BED,
COLLIDER_QUEST_FIRE,
COLLIDER_MAX
};
enum class ColliderInfo {
ENTER,
STAY,
EXIT,
};
struct Collider
{
SDL_Rect rect;
bool to_delete = false;
COLLIDER_TYPE type;
ColliderInfo info = ColliderInfo::ENTER;
m1Module* callback = nullptr;
bool enable = true;
std::list<Collider*> collisions;
Collider(SDL_Rect rectangle, COLLIDER_TYPE type, m1Module* callback = nullptr) :
rect(rectangle),
type(type),
callback(callback)
{}
void SetPos(int x, int y)
{
rect.x = x;
rect.y = y;
}
void SetShape(int w, int h)
{
rect.w = w;
rect.h = h;
}
void SetType(COLLIDER_TYPE type)
{
this->type = type;
}
bool CheckCollision(const SDL_Rect& r) const;
};
class m1Collision : public m1Module
{
public:
m1Collision();
~m1Collision();
bool PreUpdate();
bool Update(float dt);
bool CleanUp();
Collider* AddCollider(SDL_Rect rect, COLLIDER_TYPE type, m1Module* callback = nullptr);
bool DeleteCollider(Collider* col);
std::vector<Collider*> GetColliders();
/*std::vector<Collider*> Setcollider();*/
void DebugDraw();
private:
std::vector<Collider*> colliders;
bool matrix[COLLIDER_MAX][COLLIDER_MAX];
};
#endif | 16.083333 | 88 | 0.726036 |
22f9b8cc68e4b4380d855fd91861ae82cbec3583 | 351 | h | C | MgpWallet/TaiYiToken/我的/Huobi/View/HuobiRightTypTwoCell.h | mangochain2020/mangowallet-ios | 8481187bd16efd1f313bc77691aa0ecd47eebd8f | [
"MIT"
] | 1 | 2021-03-03T03:07:47.000Z | 2021-03-03T03:07:47.000Z | MgpWallet/TaiYiToken/我的/Huobi/View/HuobiRightTypTwoCell.h | mangochain2020/mangowallet-ios | 8481187bd16efd1f313bc77691aa0ecd47eebd8f | [
"MIT"
] | null | null | null | MgpWallet/TaiYiToken/我的/Huobi/View/HuobiRightTypTwoCell.h | mangochain2020/mangowallet-ios | 8481187bd16efd1f313bc77691aa0ecd47eebd8f | [
"MIT"
] | 3 | 2020-12-27T07:45:04.000Z | 2021-03-03T03:07:49.000Z | //
// HuobiRightTypTwoCell.h
// TaiYiToken
//
// Created by 张元一 on 2019/3/15.
// Copyright © 2019 admin. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface HuobiRightTypTwoCell : UITableViewCell
@property(nonatomic,strong)UILabel *leftlb;
@property(nonatomic,strong)UILabel *rightlb;
@end
NS_ASSUME_NONNULL_END
| 18.473684 | 49 | 0.763533 |
2ab39a305ad000f75d70857ab4cddc16cb67c5ec | 1,475 | h | C | Source/Classes/Query/NotionSort.h | DavidDeBels/NotionClient | cbe54347118ae88d1d56858fb0108eb2e7e0b8d2 | [
"MIT"
] | 12 | 2021-05-16T01:15:51.000Z | 2021-09-17T00:27:40.000Z | Source/Classes/Query/NotionSort.h | DavidDeBels/NotionClient | cbe54347118ae88d1d56858fb0108eb2e7e0b8d2 | [
"MIT"
] | null | null | null | Source/Classes/Query/NotionSort.h | DavidDeBels/NotionClient | cbe54347118ae88d1d56858fb0108eb2e7e0b8d2 | [
"MIT"
] | 2 | 2021-06-02T18:31:33.000Z | 2021-06-20T05:08:24.000Z | //
// NotionSort.h
// NotionClient
//
// Created by David De Bels on 20/05/2021.
//
#import <Foundation/Foundation.h>
#import "NotionTypes.h"
#import "NotionSerializable.h"
NS_ASSUME_NONNULL_BEGIN
/// MARK: - NotionSort Interface
@interface NotionSort : NSObject <NotionSerializable>
/// The sort type, either property, created time or last edited time. Default is property.
@property (nonatomic, assign, readonly) NotionSortType type;
/// The sort direction, either ascending or descending. Default is ascending.
@property (nonatomic, assign, readwrite) NotionSortDirection direction;
/// The name of the property on which to sort. Is nil if type is not property.
@property (nonatomic, copy, readonly, nullable) NSString *propertyName;
/// MARK: Convenience Init
+ (NotionSort *)ascendingOnProperty:(NSString *)propertyName NS_SWIFT_NAME(ascendingOnProperty(name:));
+ (NotionSort *)descendingOnProperty:(NSString *)propertyName NS_SWIFT_NAME(descendingOnProperty(name:));
+ (NotionSort *)ascendingOnCreatedTime NS_SWIFT_NAME(ascendingOnCreatedTime());
+ (NotionSort *)descendingOnCreatedTime NS_SWIFT_NAME(descendingOnCreatedTime());
+ (NotionSort *)ascendingOnLastEditedTime NS_SWIFT_NAME(ascendingOnLastEditedTime());
+ (NotionSort *)descendingOnLastEditedTime NS_SWIFT_NAME(descendingOnLastEditedTime());
/// MARK: Init
- (instancetype)init NS_UNAVAILABLE;
/// MARK: Serialize
- (NSMutableDictionary *)serializedObject;
@end
NS_ASSUME_NONNULL_END
| 28.365385 | 105 | 0.781017 |
621c18472095f3d48c8d36ae0458cc27c4798b83 | 1,218 | h | C | src/include/instruments/instr_slow_query.h | opengauss-mirror/openGauss-graph | 6beb138fd00abdbfddc999919f90371522118008 | [
"MulanPSL-1.0"
] | 360 | 2020-06-30T14:47:34.000Z | 2022-03-31T15:21:53.000Z | src/include/instruments/instr_slow_query.h | opengauss-mirror/openGauss-graph | 6beb138fd00abdbfddc999919f90371522118008 | [
"MulanPSL-1.0"
] | 4 | 2020-06-30T15:09:16.000Z | 2020-07-14T06:20:03.000Z | src/include/instruments/instr_slow_query.h | opengauss-mirror/openGauss-graph | 6beb138fd00abdbfddc999919f90371522118008 | [
"MulanPSL-1.0"
] | 133 | 2020-06-30T14:47:36.000Z | 2022-03-25T15:29:00.000Z | /*
* Copyright (c) 2020 Huawei Technologies Co.,Ltd.
*
* openGauss is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
* -------------------------------------------------------------------------
*
* instr_slow_query.h
*
* IDENTIFICATION
* src/include/instruments/instr_slow_query.h
*
* -------------------------------------------------------------------------
*/
#ifndef INSTR_SLOW_QUERY_H
#define INSTR_SLOW_QUERY_H
#include "nodes/parsenodes.h"
#include "pgstat.h"
#include "c.h"
void ReportQueryStatus(void);
void WLMSetSessionSlowInfo(WLMStmtDetail* pDetail);
void exec_auto_explain(QueryDesc *queryDesc);
void exec_explain_plan(QueryDesc *queryDesc);
void print_duration(const QueryDesc *queryDesc);
void explain_querydesc(ExplainState *es, QueryDesc *queryDesc);
#endif
| 32.052632 | 87 | 0.659278 |
28b0794e9fd67f5484d580517c3a3bfb808cd45f | 75 | c | C | 100.c | hdubey/295-C-Questions | b9086e57c55d0347d0992ee5aa8bae7c61250820 | [
"Unlicense"
] | 1 | 2020-11-10T15:45:45.000Z | 2020-11-10T15:45:45.000Z | 100.c | hdubey/295-C-Questions | b9086e57c55d0347d0992ee5aa8bae7c61250820 | [
"Unlicense"
] | null | null | null | 100.c | hdubey/295-C-Questions | b9086e57c55d0347d0992ee5aa8bae7c61250820 | [
"Unlicense"
] | null | null | null | #include<stdio.h>
main()
{
int i=10;
printf("%d %d",i+++i,i---i);
} | 12.5 | 30 | 0.466667 |
fad7946dd4a7d7a0e049132f913d39a04dd5a077 | 2,309 | h | C | Induction/Controllers/EMFDatabaseViewController.h | nickruta/Induction | 602a536337faaf59d891d8e42ba7acbb668dea76 | [
"MIT"
] | 1 | 2017-01-15T22:19:45.000Z | 2017-01-15T22:19:45.000Z | Induction/Controllers/EMFDatabaseViewController.h | nickruta/Induction | 602a536337faaf59d891d8e42ba7acbb668dea76 | [
"MIT"
] | null | null | null | Induction/Controllers/EMFDatabaseViewController.h | nickruta/Induction | 602a536337faaf59d891d8e42ba7acbb668dea76 | [
"MIT"
] | 1 | 2018-09-18T21:49:26.000Z | 2018-09-18T21:49:26.000Z | // EMFDatabaseViewController.h
//
// Copyright (c) 2012 Mattt Thompson (http://mattt.me)
//
// 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.
#import <Cocoa/Cocoa.h>
#import "DBAdapter.h"
@class EMFExploreTableViewController;
@class EMFQueryViewController;
@class EMFVisualizeViewController;
@class SQLResultsTableViewController;
enum _DBDatabaseViewTabs {
ExploreTab,
QueryTab,
VisualizeTab,
} DBDatabaseViewTabs;
@interface EMFDatabaseViewController : NSViewController <NSOutlineViewDelegate, NSSplitViewDelegate>
@property (strong, nonatomic) id <DBDatabase> database;
@property (strong, nonatomic, readonly) NSArray *sourceListNodes;
@property (weak, nonatomic) IBOutlet NSToolbar *toolbar;
@property (weak, nonatomic) IBOutlet NSOutlineView *outlineView;
@property (weak, nonatomic) IBOutlet NSTabView *tabView;
@property (weak, nonatomic) IBOutlet NSToolbarItem *databasesToolbarItem;
@property (strong, nonatomic) IBOutlet EMFExploreTableViewController *exploreViewController;
@property (strong, nonatomic) IBOutlet EMFQueryViewController *queryViewController;
@property (strong, nonatomic) IBOutlet EMFVisualizeViewController *visualizeViewController;
- (IBAction)explore:(id)sender;
- (IBAction)query:(id)sender;
- (IBAction)visualize:(id)sender;
@end
| 39.810345 | 100 | 0.786488 |
785df5d131b27e87debd7061bfb4a01aa5d3f26a | 7,396 | h | C | code_reading/oceanbase-master/src/sql/engine/ob_serializable_function.h | wangcy6/weekly_read | 3a8837ee9cd957787ee1785e4066dd623e02e13a | [
"Apache-2.0"
] | null | null | null | code_reading/oceanbase-master/src/sql/engine/ob_serializable_function.h | wangcy6/weekly_read | 3a8837ee9cd957787ee1785e4066dd623e02e13a | [
"Apache-2.0"
] | null | null | null | code_reading/oceanbase-master/src/sql/engine/ob_serializable_function.h | wangcy6/weekly_read | 3a8837ee9cd957787ee1785e4066dd623e02e13a | [
"Apache-2.0"
] | 1 | 2020-10-18T12:59:31.000Z | 2020-10-18T12:59:31.000Z | /**
* Copyright (c) 2021 OceanBase
* OceanBase CE is licensed under Mulan PubL v2.
* You can use this software according to the terms and conditions of the Mulan PubL v2.
* You may obtain a copy of Mulan PubL v2 at:
* http://license.coscl.org.cn/MulanPubL-2.0
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PubL v2 for more details.
*/
#ifndef OCEANBASE_ENGINE_OB_SERIALIZABLE_FUNCTION_H_
#define OCEANBASE_ENGINE_OB_SERIALIZABLE_FUNCTION_H_
#include "lib/utility/serialization.h"
#include "lib/hash_func/murmur_hash.h"
namespace oceanbase {
namespace sql {
struct ObSerializeFuncTag {};
typedef void (*serializable_function)(ObSerializeFuncTag&);
// serialize help macro, can be used in OB_SERIALIZE_MEMBER like this:
// OB_SERIALIZE_MEMBER(Foo, SER_FUNC(func_));
#define SER_FUNC(f) *(oceanbase::sql::serializable_function*)(&f)
// Serialize function array (SFA) id define, append only (before OB_SFA_MAX)
// can not delete or reorder.
#define SER_FUNC_ARRAY_ID_ENUM \
OB_SFA_MIN, OB_SFA_ALL_MISC, OB_SFA_DATUM_NULLSAFE_CMP, OB_SFA_DATUM_NULLSAFE_STR_CMP, OB_SFA_EXPR_BASIC, \
OB_SFA_EXPR_STR_BASIC, OB_SFA_RELATION_EXPR_EVAL, OB_SFA_RELATION_EXPR_EVAL_STR, OB_SFA_DATUM_CMP, \
OB_SFA_DATUM_CMP_STR, OB_SFA_DATUM_CAST_ORACLE_IMPLICIT, OB_SFA_DATUM_CAST_ORACLE_EXPLICIT, \
OB_SFA_DATUM_CAST_MYSQL_IMPLICIT, OB_SFA_DATUM_CAST_MYSQL_ENUMSET_IMPLICIT, OB_SFA_SQL_EXPR_EVAL, \
OB_SFA_SQL_EXPR_ABS_EVAL, OB_SFA_SQL_EXPR_NEG_EVAL, OB_SFA_MAX
enum ObSerFuncArrayID { SER_FUNC_ARRAY_ID_ENUM };
// add unused ObSerFuncArrayID here
#define UNUSED_SER_FUNC_ARRAY_ID_ENUM OB_SFA_MIN, OB_SFA_MAX
class ObFuncSerialization {
public:
// called before worker threads started.
static void init()
{
get_hash_table();
}
// used in REG_SER_FUNC_ARRAY macro, can not used directly
static bool reg_func_array(const ObSerFuncArrayID id, void** array, const int64_t size);
// get serialize index by function pointer
// return zero if fun is NULL
// return non zero fun is serializable
// return OB_INVALID_INDEX if function is not serializable
static uint64_t get_serialize_index(void* func);
// get function by serialize index
// return NULL if %idx out of bound.
OB_INLINE static void* get_serialize_func(const uint64_t idx);
//
// Convert N x N two dimension array to single dimension array which index is stable
// while N extending. e.g:
//
// 00 01 02
// 10 11 12 ==> 00 01 10 11 02 20 12 21 22
// 20 21 22
//
//
// Usage:
//
// fuc_array[N][N][2] can convert to ser_func_array[N * N][2] with:
// convert_NxN_function_array(ser_func_array, func_array, N, 2, 0, 2).
//
// func_array[N][N][2] extend to func_array[N][N][3], the serialize function array should
// split into to array:
// ser_func_array0[N * N][2] with: convert_NxN_array(ser_func_array0, func_array, N, 3, 0, 2).
// ser_func_array1[N * N][2] with: convert_NxN_array(ser_func_array0, func_array, N, 3, 2, 1).
//
//
static bool convert_NxN_array(void** dst, void** src, const int64_t n, const int64_t row_size = 1,
const int64_t copy_row_idx = 0, const int64_t copy_row_cnt = 1);
struct FuncIdx {
void* func_;
uint64_t idx_;
};
struct FuncIdxTable {
FuncIdx* buckets_;
uint64_t bucket_size_;
uint64_t bucket_size_mask_;
};
private:
const static int64_t ARRAY_IDX_SHIFT_BIT = 32;
struct FuncArray {
void** funcs_;
int64_t size_;
};
static uint64_t get_array_idx(const uint64_t idx)
{
return idx >> ARRAY_IDX_SHIFT_BIT;
}
static uint64_t get_func_idx(const uint64_t idx)
{
return idx & ((1ULL << ARRAY_IDX_SHIFT_BIT) - 1);
}
static uint64_t make_combine_idx(const uint64_t array_idx, const uint64_t func_idx)
{
return (array_idx << ARRAY_IDX_SHIFT_BIT) | (((1ULL << ARRAY_IDX_SHIFT_BIT) - 1) & func_idx);
}
static inline uint64_t hash(const void* func)
{
return common::murmurhash(&func, sizeof(func), 0);
}
static const FuncIdxTable& get_hash_table()
{
static FuncIdxTable* g_table = NULL;
if (OB_UNLIKELY(NULL == g_table)) {
g_table = &create_hash_table();
check_hash_table_valid();
}
return *g_table;
}
static void check_hash_table_valid();
// create hash table never fail, return a default empty hash table if OOM.
static FuncIdxTable& create_hash_table();
static FuncArray g_all_func_arrays[OB_SFA_MAX];
};
inline uint64_t ObFuncSerialization::get_serialize_index(void* func)
{
uint64_t idx = 0;
if (OB_LIKELY(0 != func)) {
const FuncIdxTable& ht = get_hash_table();
const uint64_t hash_val = hash(func);
for (uint64_t i = 0; i < ht.bucket_size_; i++) {
const FuncIdx& fi = ht.buckets_[(hash_val + i) & ht.bucket_size_mask_];
if (fi.func_ == func) {
idx = fi.idx_;
break;
} else if (NULL == fi.func_) {
idx = common::OB_INVALID_INDEX;
break;
}
}
}
return idx;
}
OB_INLINE void* ObFuncSerialization::get_serialize_func(const uint64_t idx)
{
void* func = NULL;
if (OB_LIKELY(idx > 0)) {
const uint64_t array_idx = get_array_idx(idx);
const uint64_t func_idx = get_func_idx(idx);
if (OB_UNLIKELY(array_idx >= OB_SFA_MAX) || OB_UNLIKELY(func_idx >= g_all_func_arrays[array_idx].size_)) {
int ret = common::OB_ERR_UNEXPECTED;
SQL_ENG_LOG(WARN, "function not found", K(ret), K(idx), K(array_idx), K(func_idx));
} else {
func = g_all_func_arrays[array_idx].funcs_[func_idx];
}
}
return func;
}
#define REG_SER_FUNC_ARRAY(id, array, size) \
static_assert(id >= 0 && id < OB_SFA_MAX, "too big id" #id); \
bool g_reg_ser_func_##id = ObFuncSerialization::reg_func_array(id, reinterpret_cast<void**>(array), size);
} // end namespace sql
namespace common {
namespace serialization {
inline int64_t encoded_length(sql::serializable_function)
{
return sizeof(uint64_t);
}
inline int encode(char* buf, const int64_t buf_len, int64_t& pos, sql::serializable_function func)
{
int ret = OB_SUCCESS;
const uint64_t idx = sql::ObFuncSerialization::get_serialize_index(reinterpret_cast<void*>(func));
if (OB_UNLIKELY(OB_INVALID_INDEX == idx)) {
ret = OB_INVALID_INDEX;
SQL_LOG(WARN, "function not serializable", K(ret), KP(func));
} else {
ret = encode_i64(buf, buf_len, pos, idx);
}
return ret;
}
inline int decode(const char* buf, const int64_t data_len, int64_t& pos, sql::serializable_function& func)
{
int ret = OB_SUCCESS;
uint64_t idx = 0;
ret = decode_i64(buf, data_len, pos, reinterpret_cast<int64_t*>(&idx));
if (OB_SUCC(ret)) {
if (OB_UNLIKELY(0 == idx)) {
func = NULL;
} else {
func = reinterpret_cast<sql::serializable_function>(sql::ObFuncSerialization::get_serialize_func(idx));
if (NULL == func) {
ret = OB_ERR_UNEXPECTED;
SQL_LOG(WARN, "function not found by idx", K(ret), K(idx));
}
}
}
return ret;
}
} // end namespace serialization
} // end namespace common
} // end namespace oceanbase
#endif // OCEANBASE_ENGINE_OB_SERIALIZABLE_FUNCTION_H_
| 32.296943 | 110 | 0.697945 |
9afa963d69c66fb1155c644007d953ea176d6c74 | 1,231 | h | C | EXAMPLES/Indy/FingerClient/main.h | earthsiege2/borland-cpp-ide | 09bcecc811841444338e81b9c9930c0e686f9530 | [
"Unlicense",
"FSFAP",
"Apache-1.1"
] | 1 | 2022-01-13T01:03:55.000Z | 2022-01-13T01:03:55.000Z | EXAMPLES/Indy/FingerClient/main.h | earthsiege2/borland-cpp-ide | 09bcecc811841444338e81b9c9930c0e686f9530 | [
"Unlicense",
"FSFAP",
"Apache-1.1"
] | null | null | null | EXAMPLES/Indy/FingerClient/main.h | earthsiege2/borland-cpp-ide | 09bcecc811841444338e81b9c9930c0e686f9530 | [
"Unlicense",
"FSFAP",
"Apache-1.1"
] | null | null | null | //---------------------------------------------------------------------------
#ifndef mainH
#define mainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
#include <IdBaseComponent.hpp>
#include <IdComponent.hpp>
#include <IdFinger.hpp>
#include <IdTCPClient.hpp>
#include <IdTCPConnection.hpp>
//---------------------------------------------------------------------------
class TfrmFingerDemo : public TForm
{
__published: // IDE-managed Components
TLabel *lblQuerry;
TLabel *lblInstructions;
TEdit *edtQuerry;
TMemo *mmoQuerryResults;
TCheckBox *chkVerboseQuerry;
TBitBtn *bbtnQuerry;
TIdFinger *IdFngFinger;
void __fastcall bbtnQuerryClick(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TfrmFingerDemo(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TfrmFingerDemo *frmFingerDemo;
//---------------------------------------------------------------------------
#endif
| 34.194444 | 78 | 0.472786 |
b143e25454ab5c98f2e8b85d258c118ce9ce07da | 4,980 | c | C | driver/level2/zgbmv_k.c | drhpc/OpenBLAS | 9721b57ecfd194f1a4aaa08d715735cd9e8ad8b6 | [
"BSD-3-Clause"
] | 4,392 | 2015-01-02T18:15:45.000Z | 2022-03-29T12:14:38.000Z | driver/level2/zgbmv_k.c | drhpc/OpenBLAS | 9721b57ecfd194f1a4aaa08d715735cd9e8ad8b6 | [
"BSD-3-Clause"
] | 2,067 | 2015-01-01T03:50:01.000Z | 2022-03-31T18:59:43.000Z | driver/level2/zgbmv_k.c | drhpc/OpenBLAS | 9721b57ecfd194f1a4aaa08d715735cd9e8ad8b6 | [
"BSD-3-Clause"
] | 1,564 | 2015-01-01T01:32:27.000Z | 2022-03-30T07:12:54.000Z | /*********************************************************************/
/* Copyright 2009, 2010 The University of Texas at Austin. */
/* 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 UNIVERSITY OF TEXAS AT */
/* AUSTIN ``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 UNIVERSITY OF TEXAS AT */
/* AUSTIN 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. */
/* */
/* The views and conclusions contained in the software and */
/* documentation are those of the authors and should not be */
/* interpreted as representing official policies, either expressed */
/* or implied, of The University of Texas at Austin. */
/*********************************************************************/
#include <stdio.h>
#include <ctype.h>
#include "common.h"
#ifndef XCONJ
#ifndef CONJ
#define ZAXPY AXPYU_K
#define ZDOT DOTU_K
#else
#define ZAXPY AXPYC_K
#define ZDOT DOTC_K
#endif
#else
#ifndef CONJ
#define ZAXPY AXPYU_K
#define ZDOT DOTC_K
#else
#define ZAXPY AXPYC_K
#define ZDOT DOTU_K
#endif
#endif
#ifndef TRANS
#define M m
#define N n
#else
#define N m
#define M n
#endif
void CNAME(BLASLONG m, BLASLONG n, BLASLONG ku, BLASLONG kl, FLOAT alpha_r, FLOAT alpha_i,
FLOAT *a, BLASLONG lda,
FLOAT *x, BLASLONG incx, FLOAT *y, BLASLONG incy, void *buffer){
BLASLONG i, offset_u, offset_l, start, end, length;
FLOAT *X = x;
FLOAT *Y = y;
FLOAT *gemvbuffer = (FLOAT *)buffer;
FLOAT *bufferY = gemvbuffer;
FLOAT *bufferX = gemvbuffer;
#ifdef TRANS
OPENBLAS_COMPLEX_FLOAT temp;
#endif
if (incy != 1) {
Y = bufferY;
bufferX = (FLOAT *)(((BLASLONG)bufferY + M * sizeof(FLOAT) * 2 + 4095) & ~4095);
// gemvbuffer = bufferX;
COPY_K(M, y, incy, Y, 1);
}
if (incx != 1) {
X = bufferX;
// gemvbuffer = (FLOAT *)(((BLASLONG)bufferX + N * sizeof(FLOAT) * 2 + 4095) & ~4095);
COPY_K(N, x, incx, X, 1);
}
offset_u = ku;
offset_l = ku + m;
for (i = 0; i < MIN(n, m + ku); i++) {
start = MAX(offset_u, 0);
end = MIN(offset_l, ku + kl + 1);
length = end - start;
#ifndef TRANS
ZAXPY(length, 0, 0,
#ifndef XCONJ
alpha_r * X[i * 2 + 0] - alpha_i * X[i * 2 + 1],
alpha_i * X[i * 2 + 0] + alpha_r * X[i * 2 + 1],
#else
alpha_r * X[i * 2 + 0] + alpha_i * X[i * 2 + 1],
alpha_i * X[i * 2 + 0] - alpha_r * X[i * 2 + 1],
#endif
a + start * 2, 1, Y + (start - offset_u) * 2, 1, NULL, 0);
#else
#ifndef XCONJ
temp = ZDOT(length, a + start * 2, 1, X + (start - offset_u) * 2, 1);
#else
temp = ZDOT(length, X + (start - offset_u) * 2, 1, a + start * 2, 1);
#endif
#if !defined(XCONJ) || !defined(CONJ)
Y[i * 2 + 0] += alpha_r * CREAL(temp) - alpha_i * CIMAG(temp);
Y[i * 2 + 1] += alpha_i * CREAL(temp) + alpha_r * CIMAG(temp);
#else
Y[i * 2 + 0] += alpha_r * CREAL(temp) + alpha_i * CIMAG(temp);
Y[i * 2 + 1] += alpha_i * CREAL(temp) - alpha_r * CIMAG(temp);
#endif
#endif
offset_u --;
offset_l --;
a += lda * 2;
}
if (incy != 1) {
COPY_K(M, Y, 1, y, incy);
}
return;
}
| 34.109589 | 90 | 0.52249 |
58a56b3d32abf5835c4d628fb59947001667deaa | 511 | h | C | pointimposters/NdfImposters/NdfImposterLibraryTests/ObbObbIntersection.h | reinago/sndfs | 0d152e6bf4f63d1468c8e91915a4ff970c978882 | [
"MIT"
] | null | null | null | pointimposters/NdfImposters/NdfImposterLibraryTests/ObbObbIntersection.h | reinago/sndfs | 0d152e6bf4f63d1468c8e91915a4ff970c978882 | [
"MIT"
] | null | null | null | pointimposters/NdfImposters/NdfImposterLibraryTests/ObbObbIntersection.h | reinago/sndfs | 0d152e6bf4f63d1468c8e91915a4ff970c978882 | [
"MIT"
] | 1 | 2021-11-19T15:30:43.000Z | 2021-11-19T15:30:43.000Z | #pragma once
#include<vector>
#include <glm/vec2.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
class ObbObbIntersection
{
public:
ObbObbIntersection();
~ObbObbIntersection();
bool TestIntersection3D(std::vector<glm::vec3> obbA,std::vector<glm::vec3> obbB);
private:
int WhichSide(std::vector<glm::vec3> S, glm::vec3 D, glm::vec3 P);
void computeMesh(std::vector<glm::vec3> obbA, std::vector<glm::vec3>& nA, std::vector<int>& fA, std::vector<std::pair<int, int>>& eA);
};
| 25.55 | 135 | 0.716243 |
25209d81a4d5f1faea37db981a00cb1c179f8895 | 1,230 | h | C | resources/home/dnanexus/root/include/TKeyMapFile.h | edawson/parliament2 | 2632aa3484ef64c9539c4885026b705b737f6d1e | [
"Apache-2.0"
] | null | null | null | resources/home/dnanexus/root/include/TKeyMapFile.h | edawson/parliament2 | 2632aa3484ef64c9539c4885026b705b737f6d1e | [
"Apache-2.0"
] | null | null | null | resources/home/dnanexus/root/include/TKeyMapFile.h | edawson/parliament2 | 2632aa3484ef64c9539c4885026b705b737f6d1e | [
"Apache-2.0"
] | 1 | 2020-05-28T23:01:44.000Z | 2020-05-28T23:01:44.000Z | // @(#)root/io:$Id$
// Author: Rene Brun 23/07/97
/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TKeyMapFile
#define ROOT_TKeyMapFile
#include "TNamed.h"
class TBrowser;
class TMapFile;
class TKeyMapFile : public TNamed {
private:
TKeyMapFile(const TKeyMapFile&); // TKeyMapFile objects are not copiable.
TKeyMapFile& operator=(const TKeyMapFile&); // TKeyMapFile objects are not copiable.
TMapFile *fMapFile; ///< Pointer to map file
public:
TKeyMapFile();
TKeyMapFile(const char *name, const char *classname, TMapFile *mapfile);
virtual ~TKeyMapFile() {;}
virtual void Browse(TBrowser *b);
ClassDef(TKeyMapFile,0); //Utility class for browsing TMapFile objects.
};
#endif
| 32.368421 | 87 | 0.512195 |
c977a86c2c652bb24f771296762540838f22b704 | 544 | h | C | linsched-linsched-alpha/arch/mips/include/asm/hardirq.h | usenixatc2021/SoftRefresh_Scheduling | 589ba06c8ae59538973c22edf28f74a59d63aa14 | [
"MIT"
] | 55 | 2019-12-20T03:25:14.000Z | 2022-01-16T07:19:47.000Z | linsched-linsched-alpha/arch/mips/include/asm/hardirq.h | usenixatc2021/SoftRefresh_Scheduling | 589ba06c8ae59538973c22edf28f74a59d63aa14 | [
"MIT"
] | 13 | 2021-07-10T04:36:17.000Z | 2022-03-03T10:50:05.000Z | linsched-linsched-alpha/arch/mips/include/asm/hardirq.h | usenixatc2021/SoftRefresh_Scheduling | 589ba06c8ae59538973c22edf28f74a59d63aa14 | [
"MIT"
] | 36 | 2015-02-13T00:58:22.000Z | 2021-08-19T08:08:07.000Z | /*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Copyright (C) 1997, 98, 99, 2000, 01, 05 Ralf Baechle (ralf@linux-mips.org)
* Copyright (C) 1999, 2000 Silicon Graphics, Inc.
* Copyright (C) 2001 MIPS Technologies, Inc.
*/
#ifndef _ASM_HARDIRQ_H
#define _ASM_HARDIRQ_H
extern void ack_bad_irq(unsigned int irq);
#define ack_bad_irq ack_bad_irq
#include <asm-generic/hardirq.h>
#endif /* _ASM_HARDIRQ_H */
| 28.631579 | 78 | 0.733456 |
9c31497fa06e3e150a9313efb7103bcb054174da | 303 | c | C | test/function.c | Kazhuu/llvm-outerloop-vectorization-test | 1f4f981c7c24ed0bff449025c5d84237f92bbe8b | [
"MIT"
] | 1 | 2020-09-24T15:58:41.000Z | 2020-09-24T15:58:41.000Z | test/function.c | Kazhuu/llvm-outerloop-vectorization-test | 1f4f981c7c24ed0bff449025c5d84237f92bbe8b | [
"MIT"
] | null | null | null | test/function.c | Kazhuu/llvm-outerloop-vectorization-test | 1f4f981c7c24ed0bff449025c5d84237f92bbe8b | [
"MIT"
] | null | null | null | void foo(const double* restrict in_a,
const double* restrict in_b,
double* restrict out)
{
for (int i = 0; i < 1000; ++i) {
double a = in_a[i];
double b = in_b[i];
for (int j = 0; j < 10000; ++j) {
a = a + b;
}
out[i] = a;
}
}
| 21.642857 | 41 | 0.432343 |
028b0486bea9b6b5ebfa5f5d0c145e254b46b4d8 | 4,871 | h | C | qqtw/qqheaders7.2/ClickRecordViewController.h | onezens/QQTweak | 04b9efd1d93eba8ef8fec5cf9a20276637765777 | [
"MIT"
] | 5 | 2018-02-20T14:24:17.000Z | 2020-08-06T09:31:21.000Z | qqtw/qqheaders7.2/ClickRecordViewController.h | onezens/QQTweak | 04b9efd1d93eba8ef8fec5cf9a20276637765777 | [
"MIT"
] | 1 | 2020-06-10T07:49:16.000Z | 2020-06-12T02:08:35.000Z | qqtw/qqheaders7.2/ClickRecordViewController.h | onezens/SmartQQ | 04b9efd1d93eba8ef8fec5cf9a20276637765777 | [
"MIT"
] | null | null | null | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "UIViewController.h"
#import "QQAudioPlayDelegate.h"
#import "QQAudioSessionManagerDelegate.h"
#import "QQCircularProgressViewDelegate.h"
#import "QQPttRecorderDelegate.h"
#import "QQPttTouchDelegate.h"
#import "QQVoiceAnimDelegate.h"
#import "UIAlertViewDelegate.h"
#import "UICollectionViewDataSource.h"
#import "UICollectionViewDelegate.h"
#import "UIScrollViewDelegate.h"
#import "VoiceChangeDelegate.h"
#import "VolumeMeterDelegate.h"
@class NSString, NSTimer, QQAudioPlayView, QQChangeVoicePlayPanel, QQMessageModel, QQPttRecordBtn, QQPttRecorder, QQVoicePlayAnimationView, UIActivityIndicatorView, UIButton, UILabel, UIScrollView, UIView;
@interface ClickRecordViewController : UIViewController <QQPttRecorderDelegate, QQAudioSessionManagerDelegate, QQAudioPlayDelegate, QQPttTouchDelegate, VoiceChangeDelegate, UIAlertViewDelegate, UICollectionViewDataSource, UICollectionViewDelegate, QQCircularProgressViewDelegate, VolumeMeterDelegate, QQVoiceAnimDelegate, UIScrollViewDelegate>
{
UIView *_bgView;
UIView *_sheetView;
UIActivityIndicatorView *_indicator;
UIButton *_btnStart;
UIButton *_btnRecord;
UIButton *_btnCancel;
UIButton *_btnSend;
UILabel *_labelBeginText;
UILabel *_labelTime;
UILabel *_preparingTipsLable;
QQVoicePlayAnimationView *_voicePlayAnimView;
_Bool _bDeviceOk;
NSTimer *_timer;
double _recordTime;
_Bool _bRecording;
_Bool _voiceChange;
_Bool _bShort;
_Bool _bFristFail;
_Bool _bLessthanIPhone5;
struct CGRect _contentFrame;
id <ClickRecordViewProtocol> _recordDelegate;
long long _maxRecordTimeLength;
NSString *_uuid;
QQMessageModel *_pttMessageModel;
QQAudioPlayView *_audioPlayView;
_Bool *_isMaskViewShowed;
QQPttRecorder *_recorder;
int _xo;
int _pttFormat;
_Bool _hasSetPttFormat;
id _chatViewController;
QQPttRecordBtn *_pushButton;
UIScrollView *_scrollView;
QQChangeVoicePlayPanel *_voiceChangePlayPanel;
}
- (void).cxx_destruct;
- (id)GenMessageModel;
- (id)InitPttRecorder:(double)arg1;
- (void)LogoutNotification;
- (void)OnCancel;
- (void)OnSend;
- (void)alertView:(id)arg1 clickedButtonAtIndex:(long long)arg2;
- (void)applicationEnterBackground;
- (_Bool)attachMainView:(id)arg1 frame:(struct CGRect)arg2;
- (_Bool)checkAndShowGroupAudioChattingTips;
- (void)configAccTimeLAbel;
- (void)ctrClickReport;
- (void)dealWithIntterrupt;
- (void)dealloc;
- (float)getCurrentVoicePeakPower;
- (double)getRecordTime;
- (void)hideAudioMask;
- (void)initRecordArgu;
- (id)initWithChatViewController:(id)arg1;
- (id)initWithDelegate:(id)arg1;
- (void)isDeviceOk;
@property(nonatomic) _Bool *isMaskViewShowed; // @synthesize isMaskViewShowed=_isMaskViewShowed;
- (_Bool)isOnAuditionState;
- (void)loadView;
- (_Bool)needShowVoiceAnimation;
- (void)onAuthResult:(id)arg1;
- (void)onClickRecordBtn:(id)arg1;
- (void)onClickStartBtn:(id)arg1;
- (void)onDeviceReady:(id)arg1;
- (void)onPlayedTime:(int)arg1;
- (void)onRecordBeInterrupt;
- (void)onRecordCancel:(id)arg1;
- (void)onRecordData:(id)arg1 recordTime:(double)arg2;
- (void)onRecordEnd:(id)arg1 send:(_Bool)arg2;
- (void)onRecordFailed:(id)arg1;
- (void)onRecordReady:(id)arg1;
- (void)onRecordTimeOut:(id)arg1;
- (void)onRecordTooShort:(id)arg1;
- (void)onRfreshVoiceChangePanel;
- (double)peakPowerLevel;
- (void)pttUploaderNotificationHandle:(id)arg1;
- (void)publicAccReport:(id)arg1 withExfield:(id)arg2;
@property(readonly, nonatomic) QQPttRecorder *recorder; // @dynamic recorder;
- (_Bool)registeListener;
- (void)resetToStart;
- (void)send;
- (void)sendPtt;
- (void)setPttFormat:(int)arg1;
- (void)setSendBtnTitle:(id)arg1;
- (_Bool)shouldAutorotate;
- (void)show;
- (void)showAudioMask;
- (void)showAudioPlayView;
- (void)showVoiceChangePanel;
- (_Bool)startRecorde;
- (_Bool)startRecording;
- (void)startTimer;
- (_Bool)stopRecording;
- (void)timerAdvanced:(id)arg1;
- (void)touchBegin:(id)arg1;
- (void)touchCancel:(id)arg1;
- (void)touchEnd:(id)arg1;
- (void)touchMove:(id)arg1;
- (_Bool)unregisteListener;
- (void)updateTimeLabel:(int)arg1;
- (void)uploadPtt;
- (void)videoReqInterrupt;
- (void)viewWillDisappear:(_Bool)arg1;
// Remaining properties
@property(nonatomic) _Bool bDeviceOk; // @dynamic bDeviceOk;
@property(nonatomic) _Bool bRecording; // @dynamic bRecording;
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(nonatomic) long long maxRecordTimeLength; // @dynamic maxRecordTimeLength;
@property(readonly) Class superclass;
@property(retain, nonatomic) NSString *uuid; // @dynamic uuid;
@property(nonatomic) _Bool voiceChange; // @dynamic voiceChange;
@end
| 33.826389 | 343 | 0.770478 |
7ed4e9064a259c5d6dd49560952ce61985ad6233 | 601 | h | C | ENTBoostChat/public/GifView.h | qhf012607/IMchat | c29b67822b3ad8c99e34de02970bcffde26c7c6f | [
"MIT"
] | null | null | null | ENTBoostChat/public/GifView.h | qhf012607/IMchat | c29b67822b3ad8c99e34de02970bcffde26c7c6f | [
"MIT"
] | null | null | null | ENTBoostChat/public/GifView.h | qhf012607/IMchat | c29b67822b3ad8c99e34de02970bcffde26c7c6f | [
"MIT"
] | null | null | null | //
// GifView.h
// ENTBoostChat
//
// Created by zhong zf on 14/11/19.
// Copyright (c) 2014年 EB. All rights reserved.
//
// 播放gif文件
#import <UIKit/UIKit.h>
@interface GifView : UIView
@property(nonatomic) float repeatCount; //重复播放次数
///**初始化
// * @param center 位置中心点
// * @param fileURL gif文件访问路径
// */
//- (id)initWithCenter:(CGPoint)center fileURL:(NSURL*)fileURL;
//设置gif文件访问路径
- (void)setFileURL:(NSURL*)fileURL;
///开始播放动画
- (void)startAnimation;
///停止播放动画
- (void)stopAnimation;
///**获取gif各帧列表
// * @param fileURL gif文件访问路径
// */
//+ (NSArray*)framesInGif:(NSURL*)fileURL;
@end
| 15.025 | 63 | 0.66223 |
acfe901e8ba52393c69b7767cfca4f4f14719f4f | 847 | h | C | tests/api_v2/types/copy/Header.h | asherikov/ariles | cab7f0498f036fbb15ae152804ead56200af5d45 | [
"Apache-2.0"
] | 4 | 2020-03-08T17:09:25.000Z | 2021-05-02T08:53:14.000Z | tests/api_v2/types/copy/Header.h | asherikov/ariles | cab7f0498f036fbb15ae152804ead56200af5d45 | [
"Apache-2.0"
] | 12 | 2019-09-19T09:35:51.000Z | 2021-07-08T18:49:20.000Z | tests/api_v2/types/copy/Header.h | asherikov/ariles | cab7f0498f036fbb15ae152804ead56200af5d45 | [
"Apache-2.0"
] | 3 | 2020-06-02T08:14:47.000Z | 2021-05-02T08:54:09.000Z | #pragma once
#include <string>
#include <vector>
namespace std_msgs
{
template <class ContainerAllocator>
struct Header_
{
typedef Header_<ContainerAllocator> Type;
Header_() : seq(0), stamp(), frame_id()
{
}
Header_(const ContainerAllocator &_alloc) : seq(0), stamp(), frame_id(_alloc)
{
(void)_alloc;
}
typedef uint32_t _seq_type;
_seq_type seq;
typedef uint64_t _stamp_type;
_stamp_type stamp;
typedef std::
basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other>
_frame_id_type;
_frame_id_type frame_id;
}; // struct Header_
typedef ::std_msgs::Header_<std::allocator<void> > Header;
} // namespace std_msgs
| 21.717949 | 117 | 0.598583 |
4ab5635313251993f14b9c745e45049f68423e8b | 289 | h | C | unsorted_include_todo/efx/ArgDopingSmoke.h | projectPiki/pikmin2 | a431d992acde856d092889a515ecca0e07a3ea7c | [
"Unlicense"
] | 33 | 2021-12-08T11:10:59.000Z | 2022-03-26T19:59:37.000Z | unsorted_include_todo/efx/ArgDopingSmoke.h | projectPiki/pikmin2 | a431d992acde856d092889a515ecca0e07a3ea7c | [
"Unlicense"
] | 6 | 2021-12-22T17:54:31.000Z | 2022-01-07T21:43:18.000Z | unsorted_include_todo/efx/ArgDopingSmoke.h | projectPiki/pikmin2 | a431d992acde856d092889a515ecca0e07a3ea7c | [
"Unlicense"
] | 2 | 2022-01-04T06:00:49.000Z | 2022-01-26T07:27:28.000Z | #ifndef _EFX_ARGDOPINGSMOKE_H
#define _EFX_ARGDOPINGSMOKE_H
/*
__vt__Q23efx14ArgDopingSmoke:
.4byte 0
.4byte 0
.4byte getName__Q23efx14ArgDopingSmokeFv
*/
namespace efx {
struct ArgDopingSmoke {
virtual void getName(); // _00
// _00 VTBL
};
} // namespace efx
#endif
| 14.45 | 44 | 0.723183 |
44a33ef2cd69b7a003f01a3531550adbe9723ae0 | 9,130 | c | C | myShell.c | T3r1jj/myShell | e0da3667187fb928f7f503a306f43828157ee92a | [
"Apache-2.0"
] | null | null | null | myShell.c | T3r1jj/myShell | e0da3667187fb928f7f503a306f43828157ee92a | [
"Apache-2.0"
] | null | null | null | myShell.c | T3r1jj/myShell | e0da3667187fb928f7f503a306f43828157ee92a | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2014 Damian Terlecki.
*
* 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 "myShellQueue.h"
#include "myShell.h"
Queue history;
void print_error_exit(char* error) {
perror(error);
exit(EXIT_FAILURE);
}
void print_error_clean_exit(char* error){
deleteQueue(history);
perror(error);
exit(EXIT_FAILURE);
}
void print_errors_clean_exit(char* error1, char* error2){
deleteQueue(history);
fprintf(stderr, "%s%s", error1, error2);
exit(EXIT_FAILURE);
}
void executeCommand(char **cmdArgv, char *file, int newDescriptor) {
int commandDescriptor;
if (newDescriptor == STDIN_FILENO) {
commandDescriptor = open(file, O_RDONLY, 0600);
if (commandDescriptor == -1) {
print_error_clean_exit("open");
}
if (dup2(commandDescriptor, STDIN_FILENO) == -1) {
print_error_clean_exit("dup2");
}
close(commandDescriptor);
}
if (newDescriptor == STDOUT_FILENO) {
commandDescriptor = open(file, O_CREAT | O_TRUNC | O_WRONLY, 0600);
if (commandDescriptor == -1) {
print_error_clean_exit("open");
}
if (dup2(commandDescriptor, STDOUT_FILENO) == -1) {
print_error_clean_exit("dup2");
}
close(commandDescriptor);
}
if (execvp(cmdArgv[0], cmdArgv) == -1){
if (errno == ENOENT) {
print_errors_clean_exit(cmdArgv[0], ": command or program not found\n");
} else {
print_error_clean_exit(cmdArgv[0]);
}
}
}
int forkPipeExec(int inFd, int outFd, char **cmdArgv) {
pid_t pid;
if ((pid = fork ()) == 0) {
if (inFd != STDIN_FILENO) {
if (dup2(inFd, 0) == -1) {
print_error_clean_exit("dup2");
}
close (inFd);
}
if (outFd != STDOUT_FILENO) {
if (dup2(outFd, 1) == -1) {
print_error_clean_exit("dup2");
}
close (outFd);
}
executeCommand(cmdArgv, "STANDARD", NO_REDIRECTION);
exit(EXIT_SUCCESS);
} else if (pid == -1) {
print_error_clean_exit("fork");
} else {
return pid; // Rodzic zwraca pid utworzonego potomka
}
}
int nextCmdOffset(int n, char** cmdArgv) {
int i = 0;
while(i<ARGC)
if(strcmp("|",cmdArgv[i])==0) {
cmdArgv[i] = NULL;
return i+1;
} else if(strcmp(">>",cmdArgv[i])==0) {
cmdArgv[i] = NULL;
return i+1;
} else {
i++;
}
}
int handleForking(int pipesCount, int redirect, int plane, char** cmdArgv) {
int i;
pid_t pid;
int status;
pid = fork ();
if (pid == -1) {
print_error_exit("fork");
} else if (pid == 0) {
if (plane == BACKGROUND) {
if (setpgid(0,0) == -1) {
perror("setpgid()");
}
}
int pipeInFd, pipeFd [2];
int offset = 0;
int tempOffset = 0;
pipeInFd = STDIN_FILENO;
for (i = 0; i < pipesCount; ++i) {
if (pipe(pipeFd) == -1) {
print_error_clean_exit("pipe");
}
tempOffset = nextCmdOffset(i, cmdArgv + offset);
forkPipeExec(pipeInFd, pipeFd[1], cmdArgv + offset);
offset += tempOffset;
close(pipeFd[1]);
close(pipeInFd);
pipeInFd = pipeFd[0];
}
if (pipeInFd != STDIN_FILENO) {
if (dup2(pipeInFd, STDIN_FILENO) == -1) {
print_error_clean_exit("dup2");
}
close(pipeInFd);
}
if (redirect == 1) {
int offsetRed = offset + nextCmdOffset(0, cmdArgv + offset);
executeCommand(cmdArgv+offset, cmdArgv[offsetRed], STDOUT_FILENO);
exit(EXIT_SUCCESS);
} else {
executeCommand(cmdArgv+offset, "STANDARD", NO_REDIRECTION);
exit(EXIT_SUCCESS);
}
} else {
if (plane == FOREGROUND) {
int err;
while(!(err = wait4(pid, &status, WNOHANG, NULL)));
if (err == -1 && errno == ECHILD) {
errno = 0;
} else if (err == -1) {
perror("wait4");
}
}
}
}
void deleteZombies(int sig) {
pid_t pid;
int status;
while ((pid = waitpid(-1, &status, WNOHANG)) > 0);
if (pid == -1 && errno == ECHILD) {
errno = 0;
} else if (pid == -1) {
perror("waitpid");
}
}
void tokenize(char* line, char **cmdArgv, Queue *q) {
int j,i;
char *cmdHistory = strdup(line);
for (i=0; i<ARGC; i++) {
cmdArgv[i]=NULL;
}
i = 0;
char* token = strtok(line, " ");
while(token && i<ARGC) {
cmdArgv[i++] = token;
token = strtok(NULL, " ");
}
if(cmdArgv[0]!=NULL) {
addLine(&history, cmdHistory);
}
free(cmdHistory);
}
void readline(char* line, int length) {
line[0]='\0';
fgets(line, length, stdin);
line[strlen(line)-1]='\0';
}
void changeDir(char **cmdArgv) {
if (cmdArgv[1] == NULL) {
if (chdir(getenv("HOME")) == -1)
perror("chdir");
} else {
if (chdir(cmdArgv[1]) == -1) {
perror(cmdArgv[1]);
}
}
}
void handleCommand(char **cmdArgv) {
if (cmdArgv[0]==NULL) {
return;
}
if (strcmp("exit", cmdArgv[0]) == 0) {
deleteQueue(history);
exit(EXIT_SUCCESS);
}
if (strcmp("cd", cmdArgv[0]) == 0) {
changeDir(cmdArgv);
return;
}
int plane;
int pipesCount = 0;
int redirect = 0;
int i = 0;
while (cmdArgv[i] != NULL && i < ARGC) {
if (strcmp("|", cmdArgv[i]) == 0) {
pipesCount++;
} else if (strcmp(">>", cmdArgv[i]) == 0) {
redirect++;
}
i++;
}
if (strcmp("&", cmdArgv[i-1]) == 0) {
plane = BACKGROUND;
cmdArgv[i-1] = NULL;
} else {
plane = FOREGROUND;
}
handleForking(pipesCount,redirect,plane,cmdArgv);
return;
}
void shellPrompt() {
char currDir[512];
if (getcwd(currDir, 512) == NULL) {
perror("getcwd");
}
printf("SHELL: %s@-%s :> ",getenv("USER"), currDir);
}
void printHistory(int sig) {
printf("\n");
printQueue(history);
}
int readScriptLine(int fd, char* buffer) {
int i = 1;
if(!read(fd, buffer, 1)) return EOF;
while (buffer[0] == '#') {
while (buffer[0] != '\n') {
if(!read(fd, buffer, 1)) return EOF;
}
if(!read(fd, buffer, 1)) return EOF;
}
while (buffer[i-1] != '\n') {
if(!read(fd, buffer+i, 1)) return EOF;
i++;
}
buffer[i-1] = '\0';
return i-1;
}
void handleScript(char* source, char** cmdArgv, char* historyPath) {
if (source == NULL) return;
char *buffer = calloc(LINE_LEN, sizeof(char));
int fd = open(source+2, O_RDONLY, 0600);
int EOFcheck = readScriptLine(fd, buffer);
while (EOFcheck != EOF) {
tokenize(buffer, cmdArgv, &history);
saveQueue(history, historyPath);
handleCommand(cmdArgv);
EOFcheck = readScriptLine(fd, buffer);
}
free(buffer);
deleteQueue(history);
close(fd);
exit(EXIT_SUCCESS);
}
int main(int argc, char *argv[]) {
char *cmdArgv[ARGC];
initQueue(&history);
int i;
for (i = 0; i<ARGC; i++) {
cmdArgv[i]=NULL;
}
char line[LINE_LEN];
char historyPath[256];
strcpy(historyPath, getenv("PWD"));
strcat(historyPath, "/MyShellHistory.txt");
struct sigaction childSig;
memset (&childSig, '\0', sizeof(childSig));
childSig.sa_handler = deleteZombies;
childSig.sa_flags = SA_RESTART;
if (sigaction(SIGCHLD, &childSig, NULL) == -1) {
print_error_clean_exit("sigaction");
}
struct sigaction historySig;
memset (&historySig, '\0', sizeof(historySig));
sigaddset(&historySig.sa_mask, SIGCHLD);
historySig.sa_handler = printHistory;
historySig.sa_flags = SA_RESTART;
if (sigaction(SIGINT, &historySig, NULL) < 0) {
perror ("Sigaction: printing history - broken");
}
handleScript(argv[1], cmdArgv, historyPath);
while (1) {
shellPrompt();
readline(line, LINE_LEN);
tokenize(line, cmdArgv, &history);
saveQueue(history, historyPath);
handleCommand(cmdArgv);
}
}
| 27.172619 | 88 | 0.531325 |
2f4ae8f8233d0c44ca3bcbe02a0cbdd7b999d73a | 23,377 | c | C | src/dsp/soundfile/d_codec.c | jogawebb/Spaghettis | 78f21ba3065ce316ef0cb84e94aecc9e8787343d | [
"Zlib",
"BSD-2-Clause",
"BSD-3-Clause"
] | 47 | 2017-09-05T02:49:22.000Z | 2022-01-20T08:11:47.000Z | src/dsp/soundfile/d_codec.c | jogawebb/Spaghettis | 78f21ba3065ce316ef0cb84e94aecc9e8787343d | [
"Zlib",
"BSD-2-Clause",
"BSD-3-Clause"
] | 106 | 2018-05-16T14:58:52.000Z | 2022-01-12T13:57:24.000Z | src/dsp/soundfile/d_codec.c | jogawebb/Spaghettis | 78f21ba3065ce316ef0cb84e94aecc9e8787343d | [
"Zlib",
"BSD-2-Clause",
"BSD-3-Clause"
] | 11 | 2018-05-16T06:44:51.000Z | 2021-11-10T07:04:46.000Z |
/* Copyright (c) 1997-2020 Miller Puckette and others. */
/* < https://opensource.org/licenses/BSD-3-Clause > */
// -----------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
// MARK: -
#include "../../m_spaghettis.h"
#include "../../m_core.h"
#include "../../d_dsp.h"
// -----------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
#include "d_soundfile.h"
// -----------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
/* Note that 2-3 bytes per sample is assumed LPCM. */
/* Likewise, 4 bytes per sample is assumed 32-bit IEEE float. */
// -----------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
#define SOUNDFILE_SCALE (1.0 / (1024.0 * 1024.0 * 1024.0 * 2.0))
// -----------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
// MARK: -
static inline int soundfile_encodeLinear16Value (float f, float k)
{
int v = (int)(32768.0 + (f * k));
v -= 32768;
return PD_CLAMP (v, -32767, 32767);
}
static inline void soundfile_encodeLinear16BigEndian (float f, float k, unsigned char *p)
{
int v = soundfile_encodeLinear16Value (f, k);
p[0] = 0xff & (v >> 8);
p[1] = 0xff & (v);
}
static inline void soundfile_encodeLinear16LittleEndian (float f, float k, unsigned char *p)
{
int v = soundfile_encodeLinear16Value (f, k);
p[0] = 0xff & (v);
p[1] = 0xff & (v >> 8);
}
// -----------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
static inline int soundfile_encodeLinear24Value (float f, float k)
{
int v = (int)(8388608.0 + (f * k));
v -= 8388608;
return PD_CLAMP (v, -8388607, 8388607);
}
static inline void soundfile_encodeLinear24BigEndian (float f, float k, unsigned char *p)
{
int v = soundfile_encodeLinear24Value (f, k);
p[0] = 0xff & (v >> 16);
p[1] = 0xff & (v >> 8);
p[2] = 0xff & (v);
}
static inline void soundfile_encodeLinear24LittleEndian (float f, float k, unsigned char *p)
{
int v = soundfile_encodeLinear24Value (f, k);
p[0] = 0xff & (v);
p[1] = 0xff & (v >> 8);
p[2] = 0xff & (v >> 16);
}
// -----------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
static inline void soundfile_encodeFloat32BigEndian (float f, float k, unsigned char *p)
{
t_rawcast32 z;
z.z_f = f * k;
p[0] = 0xff & (z.z_i >> 24);
p[1] = 0xff & (z.z_i >> 16);
p[2] = 0xff & (z.z_i >> 8);
p[3] = 0xff & (z.z_i);
}
static inline void soundfile_encodeFloat32LittleEndian (float f, float k, unsigned char *p)
{
t_rawcast32 z;
z.z_f = f * k;
p[0] = 0xff & (z.z_i);
p[1] = 0xff & (z.z_i >> 8);
p[2] = 0xff & (z.z_i >> 16);
p[3] = 0xff & (z.z_i >> 24);
}
// -----------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
// MARK: -
void soundfile_encode32Linear16 (int numberOfChannels,
float **v,
unsigned char *t,
int numberOfFrames,
int onset,
int bytesPerSample,
int isBigEndian,
float normalFactor)
{
int i, j;
unsigned char *p1 = t;
unsigned char *p2 = NULL;
float *s = NULL;
int bytesPerFrame = bytesPerSample * numberOfChannels;
float k = (float)(normalFactor * 32768.0);
int offset = onset;
if (isBigEndian) {
for (i = 0; i < numberOfChannels; i++) {
for (j = 0, p2 = p1, s = v[i] + offset; j < numberOfFrames; j++, p2 += bytesPerFrame, s++) {
soundfile_encodeLinear16BigEndian (*s, k, p2);
}
p1 += bytesPerSample;
}
} else {
for (i = 0; i < numberOfChannels; i++) {
for (j = 0, p2 = p1, s = v[i] + offset; j < numberOfFrames; j++, p2 += bytesPerFrame, s++) {
soundfile_encodeLinear16LittleEndian (*s, k, p2);
}
p1 += bytesPerSample;
}
}
}
void soundfile_encode32Linear24 (int numberOfChannels,
float **v,
unsigned char *t,
int numberOfFrames,
int onset,
int bytesPerSample,
int isBigEndian,
float normalFactor)
{
int i, j;
unsigned char *p1 = t;
unsigned char *p2 = NULL;
float *s = NULL;
int bytesPerFrame = bytesPerSample * numberOfChannels;
float k = (float)(normalFactor * 8388608.0);
int offset = onset;
if (isBigEndian) {
for (i = 0; i < numberOfChannels; i++) {
for (j = 0, p2 = p1, s = v[i] + offset; j < numberOfFrames; j++, p2 += bytesPerFrame, s++) {
soundfile_encodeLinear24BigEndian (*s, k, p2);
}
p1 += bytesPerSample;
}
} else {
for (i = 0; i < numberOfChannels; i++) {
for (j = 0, p2 = p1, s = v[i] + offset; j < numberOfFrames; j++, p2 += bytesPerFrame, s++) {
soundfile_encodeLinear24LittleEndian (*s, k, p2);
}
p1 += bytesPerSample;
}
}
}
void soundfile_encode32Float (int numberOfChannels,
float **v,
unsigned char *t,
int numberOfFrames,
int onset,
int bytesPerSample,
int isBigEndian,
float normalFactor)
{
int i, j;
unsigned char *p1 = t;
unsigned char *p2 = NULL;
float *s = NULL;
int bytesPerFrame = bytesPerSample * numberOfChannels;
int offset = onset;
if (isBigEndian) {
for (i = 0; i < numberOfChannels; i++) {
for (j = 0, p2 = p1, s = v[i] + offset; j < numberOfFrames; j++, p2 += bytesPerFrame, s++) {
soundfile_encodeFloat32BigEndian (*s, normalFactor, p2);
}
p1 += bytesPerSample;
}
} else {
for (i = 0; i < numberOfChannels; i++) {
for (j = 0, p2 = p1, s = v[i] + offset; j < numberOfFrames; j++, p2 += bytesPerFrame, s++) {
soundfile_encodeFloat32LittleEndian (*s, normalFactor, p2);
}
p1 += bytesPerSample;
}
}
}
void soundfile_encode32 (int numberOfChannels,
float **v,
unsigned char *t,
int numberOfFrames,
int onset,
int bytesPerSample,
int isBigEndian,
float normalFactor)
{
if (bytesPerSample == 2) {
soundfile_encode32Linear16 (numberOfChannels,
v,
t,
numberOfFrames,
onset,
bytesPerSample,
isBigEndian,
normalFactor);
} else if (bytesPerSample == 3) {
soundfile_encode32Linear24 (numberOfChannels,
v,
t,
numberOfFrames,
onset,
bytesPerSample,
isBigEndian,
normalFactor);
} else if (bytesPerSample == 4) {
soundfile_encode32Float (numberOfChannels,
v,
t,
numberOfFrames,
onset,
bytesPerSample,
isBigEndian,
normalFactor);
} else {
PD_BUG;
}
}
// -----------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
// MARK: -
void soundfile_encode64Linear16 (int numberOfChannels,
t_word **v,
unsigned char *t,
int numberOfFrames,
int onset,
int bytesPerSample,
int isBigEndian,
float normalFactor)
{
int i, j;
unsigned char *p1 = t;
unsigned char *p2 = NULL;
int bytesPerFrame = bytesPerSample * numberOfChannels;
float k = (float)(normalFactor * 32768.0);
int offset = onset;
if (isBigEndian) {
for (i = 0; i < numberOfChannels; i++) {
for (j = 0, p2 = p1; j < numberOfFrames; j++, p2 += bytesPerFrame) {
double f = w_getFloat (v[i] + offset + j);
soundfile_encodeLinear16BigEndian (f, k, p2);
}
p1 += bytesPerSample;
}
} else {
for (i = 0; i < numberOfChannels; i++) {
for (j = 0, p2 = p1; j < numberOfFrames; j++, p2 += bytesPerFrame) {
double f = w_getFloat (v[i] + offset + j);
soundfile_encodeLinear16LittleEndian (f, k, p2);
}
p1 += bytesPerSample;
}
}
}
void soundfile_encode64Linear24 (int numberOfChannels,
t_word **v,
unsigned char *t,
int numberOfFrames,
int onset,
int bytesPerSample,
int isBigEndian,
float normalFactor)
{
int i, j;
unsigned char *p1 = t;
unsigned char *p2 = NULL;
int bytesPerFrame = bytesPerSample * numberOfChannels;
float k = (float)(normalFactor * 8388608.0);
int offset = onset;
if (isBigEndian) {
for (i = 0; i < numberOfChannels; i++) {
for (j = 0, p2 = p1; j < numberOfFrames; j++, p2 += bytesPerFrame) {
double f = w_getFloat (v[i] + offset + j);
soundfile_encodeLinear24BigEndian (f, k, p2);
}
p1 += bytesPerSample;
}
} else {
for (i = 0; i < numberOfChannels; i++) {
for (j = 0, p2 = p1; j < numberOfFrames; j++, p2 += bytesPerFrame) {
double f = w_getFloat (v[i] + offset + j);
soundfile_encodeLinear24LittleEndian (f, k, p2);
}
p1 += bytesPerSample;
}
}
}
void soundfile_encode64Float (int numberOfChannels,
t_word **v,
unsigned char *t,
int numberOfFrames,
int onset,
int bytesPerSample,
int isBigEndian,
float normalFactor)
{
int i, j;
unsigned char *p1 = t;
unsigned char *p2 = NULL;
int bytesPerFrame = bytesPerSample * numberOfChannels;
int offset = onset;
if (isBigEndian) {
for (i = 0; i < numberOfChannels; i++) {
for (j = 0, p2 = p1; j < numberOfFrames; j++, p2 += bytesPerFrame) {
double f = w_getFloat (v[i] + offset + j);
soundfile_encodeFloat32BigEndian (f, normalFactor, p2);
}
p1 += bytesPerSample;
}
} else {
for (i = 0; i < numberOfChannels; i++) {
for (j = 0, p2 = p1; j < numberOfFrames; j++, p2 += bytesPerFrame) {
double f = w_getFloat (v[i] + offset + j);
soundfile_encodeFloat32LittleEndian (f, normalFactor, p2);
}
p1 += bytesPerSample;
}
}
}
void soundfile_encode64 (int numberOfChannels,
t_word **v,
unsigned char *t,
int numberOfFrames,
int onset,
int bytesPerSample,
int isBigEndian,
float normalFactor)
{
if (bytesPerSample == 2) {
soundfile_encode64Linear16 (numberOfChannels,
v,
t,
numberOfFrames,
onset,
bytesPerSample,
isBigEndian,
normalFactor);
} else if (bytesPerSample == 3) {
soundfile_encode64Linear24 (numberOfChannels,
v,
t,
numberOfFrames,
onset,
bytesPerSample,
isBigEndian,
normalFactor);
} else if (bytesPerSample == 4) {
soundfile_encode64Float (numberOfChannels,
v,
t,
numberOfFrames,
onset,
bytesPerSample,
isBigEndian,
normalFactor);
} else {
PD_BUG;
}
}
// -----------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
// MARK: -
/* Left operand of the shift operator is promote to the int type (assumed 32-bit). */
static inline float soundfile_decodeLinear16BigEndian (unsigned char *p)
{
return (float)(SOUNDFILE_SCALE * ((p[0] << 24) | (p[1] << 16)));
}
static inline float soundfile_decodeLinear16LittleEndian (unsigned char *p)
{
return (float)(SOUNDFILE_SCALE * ((p[1] << 24) | (p[0] << 16)));
}
// -----------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
static inline float soundfile_decodeLinear24BigEndian (unsigned char *p)
{
return (float)(SOUNDFILE_SCALE * ((p[0] << 24) | (p[1] << 16) | (p[2] << 8)));
}
static inline float soundfile_decodeLinear24LittleEndian (unsigned char *p)
{
return (float)(SOUNDFILE_SCALE * ((p[2] << 24) | (p[1] << 16) | (p[0] << 8)));
}
// -----------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
static inline float soundfile_decodeFloat32BigEndian (unsigned char *p)
{
t_rawcast32 z;
z.z_i = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | (p[3]);
return z.z_f;
}
static inline float soundfile_decodeFloat32LittleEndian (unsigned char *p)
{
t_rawcast32 z;
z.z_i = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | (p[0]);
return z.z_f;
}
// -----------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
// MARK: -
void soundfile_decode32Linear16 (int numberOfChannels,
int n,
float **v,
unsigned char *t,
int numberOfFrames,
int onset,
int bytesPerSample,
int isBigEndian)
{
int i, j;
unsigned char *p1 = t;
unsigned char *p2 = NULL;
float *s = NULL;
int channels = PD_MIN (numberOfChannels, n);
int bytesPerFrame = bytesPerSample * numberOfChannels;
int offset = onset;
if (isBigEndian) {
for (i = 0; i < channels; i++) {
for (j = 0, p2 = p1, s = v[i] + offset; j < numberOfFrames; j++, p2 += bytesPerFrame, s++) {
*s = soundfile_decodeLinear16BigEndian (p2);
}
p1 += bytesPerSample;
}
} else {
for (i = 0; i < channels; i++) {
for (j = 0, p2 = p1, s = v[i] + offset; j < numberOfFrames; j++, p2 += bytesPerFrame, s++) {
*s = soundfile_decodeLinear16LittleEndian (p2);
}
p1 += bytesPerSample;
}
}
}
void soundfile_decode32Linear24 (int numberOfChannels,
int n,
float **v,
unsigned char *t,
int numberOfFrames,
int onset,
int bytesPerSample,
int isBigEndian)
{
int i, j;
unsigned char *p1 = t;
unsigned char *p2 = NULL;
float *s = NULL;
int channels = PD_MIN (numberOfChannels, n);
int bytesPerFrame = bytesPerSample * numberOfChannels;
int offset = onset;
if (isBigEndian) {
for (i = 0; i < channels; i++) {
for (j = 0, p2 = p1, s = v[i] + offset; j < numberOfFrames; j++, p2 += bytesPerFrame, s++) {
*s = soundfile_decodeLinear24BigEndian (p2);
}
p1 += bytesPerSample;
}
} else {
for (i = 0; i < channels; i++) {
for (j = 0, p2 = p1, s = v[i] + offset; j < numberOfFrames; j++, p2 += bytesPerFrame, s++) {
*s = soundfile_decodeLinear24LittleEndian (p2);
}
p1 += bytesPerSample;
}
}
}
void soundfile_decode32Float (int numberOfChannels,
int n,
float **v,
unsigned char *t,
int numberOfFrames,
int onset,
int bytesPerSample,
int isBigEndian)
{
int i, j;
unsigned char *p1 = t;
unsigned char *p2 = NULL;
float *s = NULL;
int channels = PD_MIN (numberOfChannels, n);
int bytesPerFrame = bytesPerSample * numberOfChannels;
int offset = onset;
if (isBigEndian) {
for (i = 0; i < channels; i++) {
for (j = 0, p2 = p1, s = v[i] + offset; j < numberOfFrames; j++, p2 += bytesPerFrame, s++) {
*s = soundfile_decodeFloat32BigEndian (p2);
}
p1 += bytesPerSample;
}
} else {
for (i = 0; i < channels; i++) {
for (j = 0, p2 = p1, s = v[i] + offset; j < numberOfFrames; j++, p2 += bytesPerFrame, s++) {
*s = soundfile_decodeFloat32LittleEndian (p2);
}
p1 += bytesPerSample;
}
}
}
void soundfile_decode32 (int numberOfChannels,
float **v,
unsigned char *t,
int numberOfFrames,
int onset,
int bytesPerSample,
int isBigEndian,
int n)
{
if (bytesPerSample == 2) {
soundfile_decode32Linear16 (numberOfChannels,
n,
v,
t,
numberOfFrames,
onset,
bytesPerSample,
isBigEndian);
} else if (bytesPerSample == 3) {
soundfile_decode32Linear24 (numberOfChannels,
n,
v,
t,
numberOfFrames,
onset,
bytesPerSample,
isBigEndian);
} else if (bytesPerSample == 4) {
soundfile_decode32Float (numberOfChannels,
n,
v,
t,
numberOfFrames,
onset,
bytesPerSample,
isBigEndian);
} else {
PD_BUG;
}
/* Set to zero the supernumerary channels. */
{
int i, j;
float *s = NULL;
for (i = numberOfChannels; i < n; i++) {
for (j = 0, s = v[i] + onset; j < numberOfFrames; j++, s++) {
*s = 0.0;
}
}
}
}
// -----------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
// MARK: -
void soundfile_decode64Linear16 (int numberOfChannels,
int n,
t_word **v,
unsigned char *t,
int numberOfFrames,
int onset,
int bytesPerSample,
int isBigEndian)
{
int i, j;
unsigned char *p1 = t;
unsigned char *p2 = NULL;
int channels = PD_MIN (numberOfChannels, n);
int bytesPerFrame = bytesPerSample * numberOfChannels;
int offset = onset;
if (isBigEndian) {
for (i = 0; i < channels; i++) {
for (j = 0, p2 = p1; j < numberOfFrames; j++, p2 += bytesPerFrame) {
w_setFloat (v[i] + offset + j, soundfile_decodeLinear16BigEndian (p2));
}
p1 += bytesPerSample;
}
} else {
for (i = 0; i < channels; i++) {
for (j = 0, p2 = p1; j < numberOfFrames; j++, p2 += bytesPerFrame) {
w_setFloat (v[i] + offset + j, soundfile_decodeLinear16LittleEndian (p2));
}
p1 += bytesPerSample;
}
}
}
void soundfile_decode64Linear24 (int numberOfChannels,
int n,
t_word **v,
unsigned char *t,
int numberOfFrames,
int onset,
int bytesPerSample,
int isBigEndian)
{
int i, j;
unsigned char *p1 = t;
unsigned char *p2 = NULL;
int channels = PD_MIN (numberOfChannels, n);
int bytesPerFrame = bytesPerSample * numberOfChannels;
int offset = onset;
if (isBigEndian) {
for (i = 0; i < channels; i++) {
for (j = 0, p2 = p1; j < numberOfFrames; j++, p2 += bytesPerFrame) {
w_setFloat (v[i] + offset + j, soundfile_decodeLinear24BigEndian (p2));
}
p1 += bytesPerSample;
}
} else {
for (i = 0; i < channels; i++) {
for (j = 0, p2 = p1; j < numberOfFrames; j++, p2 += bytesPerFrame) {
w_setFloat (v[i] + offset + j, soundfile_decodeLinear24LittleEndian (p2));
}
p1 += bytesPerSample;
}
}
}
void soundfile_decode64Float (int numberOfChannels,
int n,
t_word **v,
unsigned char *t,
int numberOfFrames,
int onset,
int bytesPerSample,
int isBigEndian)
{
int i, j;
unsigned char *p1 = t;
unsigned char *p2 = NULL;
int channels = PD_MIN (numberOfChannels, n);
int bytesPerFrame = bytesPerSample * numberOfChannels;
int offset = onset;
if (isBigEndian) {
for (i = 0; i < channels; i++) {
for (j = 0, p2 = p1; j < numberOfFrames; j++, p2 += bytesPerFrame) {
w_setFloat (v[i] + offset + j, soundfile_decodeFloat32BigEndian (p2));
}
p1 += bytesPerSample;
}
} else {
for (i = 0; i < channels; i++) {
for (j = 0, p2 = p1; j < numberOfFrames; j++, p2 += bytesPerFrame) {
w_setFloat (v[i] + offset + j, soundfile_decodeFloat32LittleEndian (p2));
}
p1 += bytesPerSample;
}
}
}
void soundfile_decode64 (int numberOfChannels,
t_word **v,
unsigned char *t,
int numberOfFrames,
int onset,
int bytesPerSample,
int isBigEndian,
int n)
{
if (bytesPerSample == 2) {
soundfile_decode64Linear16 (numberOfChannels,
n,
v,
t,
numberOfFrames,
onset,
bytesPerSample,
isBigEndian);
} else if (bytesPerSample == 3) {
soundfile_decode64Linear24 (numberOfChannels,
n,
v,
t,
numberOfFrames,
onset,
bytesPerSample,
isBigEndian);
} else if (bytesPerSample == 4) {
soundfile_decode64Float (numberOfChannels,
n,
v,
t,
numberOfFrames,
onset,
bytesPerSample,
isBigEndian);
} else {
PD_BUG;
}
/* Set to zero the supernumerary channels. */
{
int i, j;
for (i = numberOfChannels; i < n; i++) {
for (j = 0; j < numberOfFrames; j++) { w_setFloat (v[i] + onset + j, 0.0); }
}
}
}
// -----------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------
| 27.405627 | 110 | 0.452753 |
7a957318721b46e64864fab68b3088b2fcb4859f | 2,687 | c | C | hellfireos-master/app/test_double/test_double.c | jpchagas/hfa3 | 60de070bc0d94ab7848c54b2f5d9e89b766dc0fa | [
"Apache-2.0"
] | null | null | null | hellfireos-master/app/test_double/test_double.c | jpchagas/hfa3 | 60de070bc0d94ab7848c54b2f5d9e89b766dc0fa | [
"Apache-2.0"
] | null | null | null | hellfireos-master/app/test_double/test_double.c | jpchagas/hfa3 | 60de070bc0d94ab7848c54b2f5d9e89b766dc0fa | [
"Apache-2.0"
] | null | null | null | #include <hellfire.h>
double epsilon(void){
double x = 1.0;
while ((1.0 + (x / 2.0)) > 1.0)
x = x / 2.0;
return x;
}
void doit(double a, double x){
char buf[30], buf2[30];
ftoa(a, buf, 6); ftoa(x, buf2, 6); printf("\n\na = %s, x = %s\n", buf , buf2);
ftoa(x, buf, 6); printf("\nx = %s", buf);
ftoa((a + x) - a, buf, 6); printf("\n(a + x) - a = %s", buf);
ftoa(4.0 * (a + x) - 3.0 * x - 3.0, buf, 6); printf("\n4.0 * (a + x) - 3 * x - 3 = %s", buf);
ftoa(0.2 * (a + x) + 0.8 * x - 0.15, buf, 6); printf("\n0.2 * (a + x) + 0.8 * x - 0.15 = %s", buf);
ftoa(x / (a + x), buf, 6); printf("\nx / (a + x) = %s", buf);
ftoa(1.0 - a / (a + x), buf, 6); printf("\n1.0 - a / (a + x) = %s", buf);
ftoa(1.0 / ( a / x + 1), buf, 6); printf("\n1.0 / ( a / x + 1) = %s", buf);
ftoa((1.0 - (a + 0.1 * x) / (a + x)) / 0.9, buf, 6); printf("\n(1.0 - (a + 0.1 * x) / (a + x)) / 0.9 = %s", buf);
ftoa(a / ( a + x), buf, 6); printf("\na / ( a + x) = %s", buf);
ftoa(1.0 - x / (a + x), buf, 6); printf("\n1.0 - x / (a + x) = %s", buf);
ftoa(1.0 / (1.0 + x / a), buf, 6); printf("\n1.0 / (1 + x / a) = %s", buf);
ftoa((a + x / 10.0) / (a + x) - 0.1 * x / (a + x), buf, 6); printf("\n(a + x / 10.0) / (a + x) - 0.1 * x / (a + x) = %s", buf);
ftoa(log((a + x) / a), buf, 6); printf("\nlog((a + x) / a)) = %s", buf);
ftoa(log(a + x) - log(a), buf, 6); printf("\nlog(a + x) - log(a) = %s", buf);
ftoa(log(1.0 + x / a), buf, 6); printf("\nlog(1.0 + x / a) = %s", buf);
ftoa(-log(1.0 - x / (a + x)), buf, 6); printf("\n-log(1.0 - x / (a + x)) = %s", buf);
printf("\n");
}
void testfp(void){
int i;
double a, x;
char buf[30];
ftoa(epsilon(), buf, 6);
printf("\nmachine epsilon: %s", buf);
a = 3.0 / 4.0;
for (i = -10; i > -13; i--){
x = pow(3.0, i);
doit(a, x);
}
}
int fac(int n){
int i, f;
for (i = 1, f = 1; i <= n; i++)
f = f * i;
return f;
}
int euler(){
int i;
double e;
int8_t buf[30];
e = 0;
for (i = 0; i < 13; i++){
e += 1.0 / (double)fac(i);
ftoa(e, buf, 6);
printf("[%d] - e = %s\n", i, buf);
}
return 0;
}
void task(){
uint32_t i = 0;
while (1){
printf("\ntest %d", i++);
testfp();
euler();
delay_ms(1000);
}
}
void app_main(void)
{
hf_spawn(task, 0, 0, 0, "task", 2048);
}
| 29.206522 | 128 | 0.362486 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.