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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
e997c499771a9943512b05fccfd79ae448e26dda | 1,332 | h | C | PrivateFrameworks/AOSUI/iCloudAccountResponse.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/AOSUI/iCloudAccountResponse.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/AOSUI/iCloudAccountResponse.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 1 | 2018-09-28T13:54:23.000Z | 2018-09-28T13:54:23.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSObject.h"
@class NSData, NSDictionary, NSError, NSHTTPURLResponse, NSNumber, NSString;
@interface iCloudAccountResponse : NSObject
{
NSDictionary *_responseDictionary;
NSHTTPURLResponse *_httpResponse;
NSError *_error;
long long _statusCode;
NSData *_data;
NSString *_protocolVersion;
NSNumber *_maxAge;
}
@property(readonly, nonatomic) NSNumber *maxAge; // @synthesize maxAge=_maxAge;
@property(readonly, nonatomic) NSString *protocolVersion; // @synthesize protocolVersion=_protocolVersion;
@property(readonly, nonatomic) NSHTTPURLResponse *httpResponse; // @synthesize httpResponse=_httpResponse;
@property(readonly, nonatomic) NSData *data; // @synthesize data=_data;
@property(readonly, nonatomic) long long statusCode; // @synthesize statusCode=_statusCode;
@property(retain, nonatomic) NSError *error; // @synthesize error=_error;
@property(readonly, nonatomic) NSDictionary *responseDictionary; // @synthesize responseDictionary=_responseDictionary;
- (void).cxx_destruct;
- (id)initWithHTTPResponse:(id)arg1 data:(id)arg2 bodyIsPlist:(BOOL)arg3;
- (id)initWithHTTPResponse:(id)arg1 data:(id)arg2;
- (void)_parsePlistResponse:(id)arg1;
@end
| 37 | 119 | 0.760511 |
8f4b218fc7707a7e87551f17d77cc08e824c563f | 251 | h | C | src/data/UOSMData.h | uorocketry/rocket-code-2020 | 06e3e56b79653f8c0c3af0cb422531d058a0f7ec | [
"MIT"
] | 8 | 2021-04-04T12:10:40.000Z | 2022-03-25T03:12:25.000Z | src/data/UOSMData.h | uorocketry/rocket-code-2020 | 06e3e56b79653f8c0c3af0cb422531d058a0f7ec | [
"MIT"
] | 104 | 2020-01-10T00:47:24.000Z | 2022-03-24T03:54:13.000Z | src/data/UOSMData.h | uorocketry/rocket-code-2020 | 06e3e56b79653f8c0c3af0cb422531d058a0f7ec | [
"MIT"
] | 4 | 2021-04-04T12:10:48.000Z | 2022-03-25T03:12:26.000Z | #pragma once
#include "../helpers/Types.h"
#include "../stateMachineLib/StateMachine.h"
struct UOSMData : public EventData
{
/** Keep in mind, this is NOT the time since unix epoch (1970), and not the
* system time */
time_point now;
}; | 22.818182 | 79 | 0.677291 |
6ba2b5dd9dad2f5540905797113286c190c50fb0 | 231 | h | C | OCExample/ProtocolServiceKit_Demo/LFLViewController.h | DevDragonLi/ProtocolServiceKit | cd39310a2d8c1a331d17c96fc51612a6e38e75d5 | [
"MIT"
] | 122 | 2020-08-17T06:01:31.000Z | 2022-03-30T06:42:23.000Z | OCExample/ProtocolServiceKit_Demo/LFLViewController.h | DevDragonLi/ProtocolServiceManger | cd39310a2d8c1a331d17c96fc51612a6e38e75d5 | [
"MIT"
] | 3 | 2020-08-18T11:45:21.000Z | 2021-01-13T10:45:25.000Z | OCExample/ProtocolServiceKit_Demo/LFLViewController.h | DevDragonLi/ProtocolServiceManger | cd39310a2d8c1a331d17c96fc51612a6e38e75d5 | [
"MIT"
] | 9 | 2020-08-17T05:55:51.000Z | 2022-03-14T05:55:18.000Z | //
// LFLViewController.h
// ProtocolServiceKit_Demo
//
// Created by DevdragonLi on 07/18/2020.
// Copyright (c) 2020 DevdragonLi. All rights reserved.
//
@import UIKit;
@interface LFLViewController : UIViewController
@end
| 16.5 | 56 | 0.731602 |
38cdffbc4c7bee101ccdb05c4cc01c7d6e693e4e | 3,017 | h | C | linux-2.6.16-unmod/include/asm-ia64/sn/pcidev.h | ut-osa/syncchar | eba20da163260b6ae1ef3e334ad2137873a8d625 | [
"BSD-3-Clause"
] | null | null | null | linux-2.6.16-unmod/include/asm-ia64/sn/pcidev.h | ut-osa/syncchar | eba20da163260b6ae1ef3e334ad2137873a8d625 | [
"BSD-3-Clause"
] | null | null | null | linux-2.6.16-unmod/include/asm-ia64/sn/pcidev.h | ut-osa/syncchar | eba20da163260b6ae1ef3e334ad2137873a8d625 | [
"BSD-3-Clause"
] | 1 | 2019-05-14T16:36:45.000Z | 2019-05-14T16:36:45.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) 1992 - 1997, 2000-2005 Silicon Graphics, Inc. All rights reserved.
*/
#ifndef _ASM_IA64_SN_PCI_PCIDEV_H
#define _ASM_IA64_SN_PCI_PCIDEV_H
#include <linux/pci.h>
/*
* In ia64, pci_dev->sysdata must be a *pci_controller. To provide access to
* the pcidev_info structs for all devices under a controller, we extend the
* definition of pci_controller, via sn_pci_controller, to include a list
* of pcidev_info.
*/
struct sn_pci_controller {
struct pci_controller pci_controller;
struct list_head pcidev_info;
};
#define SN_PCI_CONTROLLER(dev) ((struct sn_pci_controller *) dev->sysdata)
#define SN_PCIDEV_INFO(dev) sn_pcidev_info_get(dev)
#define SN_PCIBUS_BUSSOFT_INFO(pci_bus) \
(struct pcibus_info *)((struct pcibus_bussoft *)(PCI_CONTROLLER((pci_bus))->platform_data))
/*
* Given a pci_bus, return the sn pcibus_bussoft struct. Note that
* this only works for root busses, not for busses represented by PPB's.
*/
#define SN_PCIBUS_BUSSOFT(pci_bus) \
((struct pcibus_bussoft *)(PCI_CONTROLLER((pci_bus))->platform_data))
#define SN_PCIBUS_BUSSOFT_INFO(pci_bus) \
(struct pcibus_info *)((struct pcibus_bussoft *)(PCI_CONTROLLER((pci_bus))->platform_data))
/*
* Given a struct pci_dev, return the sn pcibus_bussoft struct. Note
* that this is not equivalent to SN_PCIBUS_BUSSOFT(pci_dev->bus) due
* due to possible PPB's in the path.
*/
#define SN_PCIDEV_BUSSOFT(pci_dev) \
(SN_PCIDEV_INFO(pci_dev)->pdi_host_pcidev_info->pdi_pcibus_info)
#define SN_PCIDEV_BUSPROVIDER(pci_dev) \
(SN_PCIDEV_INFO(pci_dev)->pdi_provider)
#define PCIIO_BUS_NONE 255 /* bus 255 reserved */
#define PCIIO_SLOT_NONE 255
#define PCIIO_FUNC_NONE 255
#define PCIIO_VENDOR_ID_NONE (-1)
struct pcidev_info {
u64 pdi_pio_mapped_addr[7]; /* 6 BARs PLUS 1 ROM */
u64 pdi_slot_host_handle; /* Bus and devfn Host pci_dev */
struct pcibus_bussoft *pdi_pcibus_info; /* Kernel common bus soft */
struct pcidev_info *pdi_host_pcidev_info; /* Kernel Host pci_dev */
struct pci_dev *pdi_linux_pcidev; /* Kernel pci_dev */
struct sn_irq_info *pdi_sn_irq_info;
struct sn_pcibus_provider *pdi_provider; /* sn pci ops */
struct pci_dev *host_pci_dev; /* host bus link */
struct list_head pdi_list; /* List of pcidev_info */
};
extern void sn_irq_fixup(struct pci_dev *pci_dev,
struct sn_irq_info *sn_irq_info);
extern void sn_irq_unfixup(struct pci_dev *pci_dev);
extern struct pcidev_info * sn_pcidev_info_get(struct pci_dev *);
extern void sn_pci_controller_fixup(int segment, int busnum,
struct pci_bus *bus);
extern void sn_bus_store_sysdata(struct pci_dev *dev);
extern void sn_bus_free_sysdata(void);
extern void sn_pci_fixup_slot(struct pci_dev *dev);
extern void sn_pci_unfixup_slot(struct pci_dev *dev);
extern void sn_irq_lh_init(void);
#endif /* _ASM_IA64_SN_PCI_PCIDEV_H */
| 36.349398 | 92 | 0.765993 |
1d34603c484cfb6df54f859c615dcac8de50c9e7 | 3,454 | c | C | src/aeten/concurrent/posix/ReentrantLock.c | aeten/aeten-core-c | 626fddf85797c5ca61b294beebb51926adb8c8b1 | [
"MIT"
] | null | null | null | src/aeten/concurrent/posix/ReentrantLock.c | aeten/aeten-core-c | 626fddf85797c5ca61b294beebb51926adb8c8b1 | [
"MIT"
] | null | null | null | src/aeten/concurrent/posix/ReentrantLock.c | aeten/aeten-core-c | 626fddf85797c5ca61b294beebb51926adb8c8b1 | [
"MIT"
] | null | null | null | #include "ReentrantLock.h"
#include <pthread.h>
#include <errno.h>
#define import
#include "concurrent/Condition.h"
#include "ReentrantLockCondition.h"
/*
@startuml(id=ReentrantLock)
!include concurrent/Lock.c
!include concurrent/Condition.c
namespace aeten.concurrent.posix {
class ReentrantLock implements aeten.concurrent.Lock {
+ {static} ReentrantLock() <<constructor>>
# void finalize() <<override>>
- mutex: pthread_mutex_t
}
}
@enduml
@startuml(id=ReentrantLockCondition)
!include concurrent/Condition.c
namespace aeten.concurrent.posix {
class ReentrantLockCondition implements aeten.concurrent.Condition {
+ {static} ReentrantLockCondition(pthread_mutex_t *mutex) <<constructor>>
- mutex: pthread_mutex_t*
- cond: pthread_cond_t
}
}
@enduml
*/
static struct timespec time_diff(struct timespec start, struct timespec end);
void ReentrantLock_new(ReentrantLock* self) {
pthread_mutex_t pthread_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutexattr_t mutex_init;
bzero(&mutex_init, sizeof(pthread_mutexattr_t));
pthread_mutexattr_init(&mutex_init);
pthread_mutexattr_settype(&mutex_init, PTHREAD_MUTEX_RECURSIVE_NP);
pthread_mutex_init(&pthread_mutex, &mutex_init);
self->_mutex = pthread_mutex;
}
void ReentrantLock_finalize(ReentrantLock* self) {
pthread_mutex_destroy(&self->_mutex);
}
void ReentrantLock_lock(ReentrantLock* self) {
pthread_mutex_lock(&self->_mutex);
}
bool ReentrantLock_tryLock(ReentrantLock* self) {
return (pthread_mutex_trylock(&self->_mutex) == 0);
}
void ReentrantLock_unlock(ReentrantLock* self) {
pthread_mutex_unlock(&self->_mutex);
}
Condition ReentrantLock_newCondition(ReentrantLock* self) {
return Condition_cast(new_ReentrantLockCondition(&self->_mutex));
}
void ReentrantLockCondition_new(ReentrantLockCondition* self, pthread_mutex_t *mutex) {
self->_mutex = mutex;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
self->_cond = cond;
}
void ReentrantLockCondition_await(ReentrantLockCondition* self) {
pthread_cond_wait(&self->_cond, self->_mutex);
}
uint64_t ReentrantLockCondition_awaitNanos(ReentrantLockCondition* self, uint64_t nanosTimeout) {
struct timespec from;
check(clock_gettime(CLOCK_REALTIME, &from) == 0, Error, "%m (errno: %u)", errno);
struct timespec end = {
from.tv_sec,
from.tv_nsec + nanosTimeout
};
while (end.tv_nsec >= 1000000000) {
end.tv_nsec -= 1000000000;
++end.tv_sec;
}
if (ReentrantLockCondition_awaitUntil(self, end)) {
struct timespec now, rest;
check(clock_gettime(CLOCK_REALTIME, &now) == 0, Error, "%m (errno: %u)", errno);
rest = time_diff(from, now);
return (rest.tv_sec * 1E9) + rest.tv_nsec;
}
return 0;
}
bool ReentrantLockCondition_awaitUntil(ReentrantLockCondition* self, struct timespec deadline) {
switch (pthread_cond_timedwait(&self->_cond, self->_mutex, &deadline)) {
case ETIMEDOUT:
return false;
case EINTR:
throw(InterruptException);
return true;
default:
return true;
}
}
void ReentrantLockCondition_signal(ReentrantLockCondition* self) {
pthread_cond_signal(&self->_cond);
}
void ReentrantLockCondition_signalAll(ReentrantLockCondition* self) {
pthread_cond_broadcast(&self->_cond);
}
struct timespec time_diff(struct timespec start, struct timespec end) {
struct timespec diff;
diff.tv_sec = end.tv_sec - start.tv_sec;
diff.tv_nsec = end.tv_nsec - start.tv_nsec;
while (diff.tv_nsec < 0 ) {
diff.tv_nsec += 1E9;
--diff.tv_sec;
}
return diff;
}
| 26.569231 | 97 | 0.766068 |
e1a0dff38f65d45b37251413475c181bd6e457b5 | 11,108 | h | C | src/tree/node.h | BohuTANG/cascadb | 28d61545074b8b064ec123f3e565cc47cbcda2a3 | [
"BSD-3-Clause"
] | 4 | 2015-11-27T00:12:50.000Z | 2022-03-14T01:59:59.000Z | src/tree/node.h | BohuTANG/cascadb | 28d61545074b8b064ec123f3e565cc47cbcda2a3 | [
"BSD-3-Clause"
] | null | null | null | src/tree/node.h | BohuTANG/cascadb | 28d61545074b8b064ec123f3e565cc47cbcda2a3 | [
"BSD-3-Clause"
] | null | null | null | // Copyright (c) 2013 The CascaDB Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.
#ifndef CASCADB_NODE_H_
#define CASCADB_NODE_H_
#include <vector>
#include <set>
#include "cascadb/slice.h"
#include "cascadb/comparator.h"
#include "serialize/layout.h"
#include "msg.h"
#include "record.h"
namespace cascadb {
#define NID_NIL ((bid_t)0)
#define NID_SCHEMA ((bid_t)1)
#define NID_START (NID_NIL + 2)
#define NID_LEAF_START (bid_t)((1LL << 48) + 1)
#define IS_LEAF(nid) ((nid) >= NID_LEAF_START)
class Tree;
class Pivot {
public:
Pivot() {}
Pivot(Slice k, bid_t c, MsgBuf* mb)
: key(k), child(c), msgbuf(mb)
{
}
Slice key;
Slice filter;
bid_t child;
// msgbuf, NULL if not loaded yet
MsgBuf *msgbuf;
// offset of msgbuf in block
uint32_t offset;
// length of msgbuf in block
uint32_t length;
// length of msgbuf before compression
uint32_t uncompressed_length;
// crc of msgbuf
uint32_t crc;
};
class Node {
public:
Node(const std::string& table_name, bid_t nid)
: table_name_(table_name), nid_(nid)
{
dirty_ = false;
dead_ = false;
flushing_ = false;
refcnt_ = 0;
pincnt_ = 0;
}
virtual ~Node() {}
// size of node in memory
virtual size_t size() = 0;
// size of node after serialization
virtual size_t estimated_buffer_size() = 0;
virtual bool read_from(BlockReader& reader, bool skeleton_only) = 0;
virtual bool write_to(BlockWriter& writer, size_t& skeleton_size) = 0;
/***************************
setter and getters
****************************/
bid_t nid()
{
return nid_;
}
const std::string& table_name()
{
return table_name_;
}
void set_dirty(bool dirty)
{
ScopedMutex lock(&mtx_);
if (!dirty_ && dirty) {
first_write_timestamp_ = now();
}
dirty_ = dirty;
}
bool is_dirty()
{
ScopedMutex lock(&mtx_);
return dirty_;
}
void set_dead()
{
ScopedMutex lock(&mtx_);
dead_ = true;
}
bool is_dead()
{
ScopedMutex lock(&mtx_);
return dead_;
}
void set_flushing(bool flushing)
{
ScopedMutex lock(&mtx_);
flushing_ = flushing;
}
bool is_flushing()
{
ScopedMutex lock(&mtx_);
return flushing_;
}
Time get_first_write_timestamp()
{
ScopedMutex lock(&mtx_);
return first_write_timestamp_;
}
Time get_last_used_timestamp()
{
ScopedMutex lock(&mtx_);
return last_used_timestamp_;
}
/***************************
countings/lock/latch
****************************/
void inc_ref()
{
ScopedMutex lock(&mtx_);
refcnt_ ++;
}
void dec_ref()
{
ScopedMutex lock(&mtx_);
refcnt_ --;
assert(refcnt_ >= 0);
last_used_timestamp_ = now();
}
int ref()
{
ScopedMutex lock(&mtx_);
return refcnt_;
}
void inc_pin()
{
ScopedMutex lock(&mtx_);
pincnt_ ++;
}
void dec_pin()
{
ScopedMutex lock(&mtx_);
pincnt_ --;
assert(pincnt_ >= 0);
}
int pin()
{
ScopedMutex lock(&mtx_);
return pincnt_;
}
// Read lock is locked when:
// 1) inner node is being written or read
// 2) leaf node is being read
void read_lock()
{
lock_.read_lock();
}
bool try_read_lock()
{
return lock_.try_read_lock();
}
// Write lock is locked when:
// 1) inner node is spliting or merging
// 2) leaf node is being written
// 3) node is flushed out
void write_lock()
{
lock_.write_lock();
}
bool try_write_lock()
{
return lock_.try_write_lock();
}
void unlock()
{
lock_.unlock();
}
protected:
std::string table_name_;
bid_t nid_;
// TODO: use atomic
Mutex mtx_;
bool dirty_;
bool dead_;
// flushing_ flag will protect the same node being
// written out concurrently
bool flushing_;
// the order of dirty nodes be flushed out
Time first_write_timestamp_;
// the order of clean nodes be evicted
Time last_used_timestamp_;
// reference counting, node can be destructed only
// when this count reaches 0
int refcnt_;
// the number of times a node has been pinned,
// a node should not be flushed out when pinned
int pincnt_;
// latch
RWLock lock_;
};
class SchemaNode : public Node {
public:
SchemaNode(const std::string& table_name)
: Node(table_name, NID_SCHEMA)
{
root_node_id = NID_NIL;
next_inner_node_id = NID_NIL;
next_leaf_node_id = NID_NIL;
tree_depth = 0;
}
size_t size();
size_t estimated_buffer_size();
bool read_from(BlockReader& reader, bool skeleton_only);
bool write_to(BlockWriter& writer, size_t& skeleton_size);
bid_t root_node_id;
bid_t next_inner_node_id;
bid_t next_leaf_node_id;
size_t tree_depth;
};
enum NodeStatus {
kNew,
kUnloaded,
kSkeletonLoaded,
kFullLoaded
};
class InnerNode;
class DataNode : public Node {
public:
DataNode(const std::string& table_name, bid_t nid, Tree *tree)
: Node(table_name, nid), tree_(tree), status_(kNew)
{
}
virtual ~DataNode() {};
// Merge messages cascading from parent
virtual bool cascade(MsgBuf *mb, InnerNode* parent) = 0;
// Find values buffered in this node and all descendants
virtual bool find(Slice key, Slice& value, InnerNode* parent) = 0;
virtual void lock_path(Slice key, std::vector<DataNode*>& path) = 0;
protected:
Tree *tree_;
NodeStatus status_;
};
class LeafNode;
class InnerNode : public DataNode {
public:
InnerNode(const std::string& table_name, bid_t nid, Tree *tree)
: DataNode(table_name, nid, tree),
bottom_(false),
first_child_(NID_NIL),
first_msgbuf_(NULL),
first_msgbuf_offset_(0),
first_msgbuf_length_(0),
first_msgbuf_uncompressed_length_(0),
pivots_sz_(0),
msgcnt_(0),
msgbufsz_(0)
{
assert(nid >= NID_START && nid < NID_LEAF_START);
}
virtual ~InnerNode();
// called for newly created root node only
void init_empty_root();
bool put(Slice key, Slice value)
{
return write(Msg(Put, key.clone(), value.clone()));
}
bool del(Slice key)
{
return write(Msg(Del, key.clone()));
}
virtual bool cascade(MsgBuf *mb, InnerNode* parent);
virtual bool find(Slice key, Slice& value, InnerNode* parent);
void add_pivot(Slice key, bid_t nid, std::vector<DataNode*>& path);
void rm_pivot(bid_t nid, std::vector<DataNode*>& path);
size_t pivot_size(Slice key);
size_t bloom_size(int n);
size_t size();
size_t estimated_buffer_size();
bool read_from(BlockReader& reader, bool skeleton_only);
bool write_to(BlockWriter& writer, size_t& skeleton_size);
void lock_path(Slice key, std::vector<DataNode*>& path);
protected:
friend class LeafNode;
bool write(const Msg& m);
int comp_pivot(Slice k, int i);
int find_pivot(Slice k);
MsgBuf* msgbuf(int idx);
MsgBuf* msgbuf(int idx, Slice& key);
bid_t child(int idx);
void set_child(int idx, bid_t c);
void insert_msgbuf(const Msg& m, int idx);
void insert_msgbuf(MsgBuf::Iterator begin, MsgBuf::Iterator end, int idx);
int find_msgbuf_maxcnt();
int find_msgbuf_maxsz();
void maybe_cascade();
void split(std::vector<DataNode*>& path);
bool load_msgbuf(int idx);
bool load_all_msgbuf();
bool load_all_msgbuf(BlockReader& reader);
bool read_msgbuf(BlockReader& reader,
size_t compressed_length,
size_t uncompressed_length,
MsgBuf *mb, Slice buffer);
bool write_msgbuf(BlockWriter& writer, MsgBuf *mb, Slice buffer);
// true if children're leaf nodes
bool bottom_;
bid_t first_child_;
MsgBuf* first_msgbuf_;
Slice first_filter_;
uint32_t first_msgbuf_offset_;
uint32_t first_msgbuf_length_;
uint32_t first_msgbuf_uncompressed_length_;
uint32_t first_msgbuf_crc_;
std::vector<Pivot> pivots_;
size_t pivots_sz_;
size_t msgcnt_;
size_t msgbufsz_;
};
class LeafNode : public DataNode {
public:
LeafNode(const std::string& table_name, bid_t nid, Tree *tree);
~LeafNode();
virtual bool cascade(MsgBuf *mb, InnerNode* parent);
virtual bool find(Slice key, Slice& value, InnerNode* parent);
size_t size();
size_t estimated_buffer_size();
bool read_from(BlockReader& reader, bool skeleton_only);
bool write_to(BlockWriter& writer, size_t& skeleton_size);
void lock_path(Slice key, std::vector<DataNode*>& path);
protected:
Record to_record(const Msg& msg);
void split(Slice anchor);
void merge(Slice anchor);
// refresh buckets_info_ after buckets_ is modified
void refresh_buckets_info();
bool read_buckets_info(BlockReader& reader);
bool write_buckets_info(BlockWriter& writer);
bool load_bucket(size_t idx);
bool load_all_buckets();
bool load_all_buckets(BlockReader& reader);
bool read_bucket(BlockReader& reader,
size_t compressed_length,
size_t uncompressed_length,
RecordBucket *bucket, Slice buffer);
bool read_bucket(BlockReader& reader,
RecordBucket *bucket);
bool write_bucket(BlockWriter& writer, RecordBucket *bucket, Slice buffer);
bool write_bucket(BlockWriter& writer, RecordBucket *bucket);
private:
// either spliting or merging to get tree balanced
bool balancing_;
bid_t left_sibling_;
bid_t right_sibling_;
// records're divided into buckets,
// each bucket can be loaded individually
struct BucketInfo{
Slice key;
Slice filter;
uint32_t offset;
uint32_t length;
uint32_t uncompressed_length;
uint32_t crc;
};
size_t buckets_info_size_;
std::vector<BucketInfo> buckets_info_;
RecordBuckets records_;
};
}
#endif
| 22.809035 | 79 | 0.587324 |
4bdf352abbe694e6abc7b439cd9e0c5ab6b2d043 | 5,009 | h | C | src/SharpSvn/Args/List.h | matherm-aboehm/SharpSvn | 11b1889ab71985b08c9a7338c9237ef8ef5c9e41 | [
"Apache-2.0"
] | 17 | 2021-04-08T13:54:54.000Z | 2022-03-08T07:43:30.000Z | src/SharpSvn/Args/List.h | AnkhSVN/SharpSvn | 8ed5ae9d2c8a1f3d61a5a5c2186524d83d47886d | [
"Apache-2.0"
] | 24 | 2021-05-18T09:23:45.000Z | 2022-03-28T09:55:42.000Z | src/SharpSvn/Args/List.h | matherm-aboehm/SharpSvn | 11b1889ab71985b08c9a7338c9237ef8ef5c9e41 | [
"Apache-2.0"
] | 8 | 2021-05-25T19:11:06.000Z | 2022-03-17T08:29:14.000Z | // Copyright 2007-2008 The SharpSvn Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
namespace SharpSvn {
/// <summary>Extended Parameter container for SvnClient.List</summary>
/// <threadsafety static="true" instance="false"/>
public ref class SvnListArgs : public SvnClientArgs
{
SvnRevision^ _revision;
SvnDepth _depth;
SvnDirEntryItems _entryItems;
bool _fetchLocks;
bool _includeExternals;
public:
DECLARE_EVENT(SvnListEventArgs^, List)
protected public:
virtual void OnList(SvnListEventArgs^ e)
{
List(this, e);
}
public:
SvnListArgs()
{
_depth = SvnDepth::Children;
_revision = SvnRevision::None;
_entryItems = SvnDirEntryItems::SvnListDefault;
}
virtual property SvnCommandType CommandType
{
virtual SvnCommandType get() override sealed
{
return SvnCommandType::List;
}
}
property SvnDepth Depth
{
SvnDepth get()
{
return _depth;
}
void set(SvnDepth value)
{
_depth = EnumVerifier::Verify(value);
}
}
property SvnRevision^ Revision
{
SvnRevision^ get()
{
return _revision;
}
void set(SvnRevision^ value)
{
if (value)
_revision = value;
else
_revision = SvnRevision::None;
}
}
property SvnDirEntryItems RetrieveEntries
{
SvnDirEntryItems get()
{
return _entryItems;
}
void set(SvnDirEntryItems value)
{
_entryItems = value;
}
}
property bool RetrieveLocks
{
bool get()
{
return _fetchLocks;
}
void set(bool value)
{
_fetchLocks = value;
}
}
property bool IncludeExternals
{
bool get()
{
return _includeExternals;
}
void set(bool value)
{
_includeExternals = value;
}
}
internal:
String^ _queryRoot;
Uri^ _repositoryRoot;
void Prepare(SvnTarget^ target, bool hasRevision)
{
_repositoryRoot = nullptr;
SvnUriTarget^ uriTarget = dynamic_cast<SvnUriTarget^>(target);
if (uriTarget && !hasRevision)
_queryRoot = SvnBase::UriToCanonicalString(uriTarget->Uri);
else
_queryRoot = nullptr;
}
Uri^ CalculateRepositoryRoot(const char* abs_path)
{
if (_repositoryRoot || !_queryRoot)
return _repositoryRoot;
String^ qr = _queryRoot;
_queryRoot = nullptr; // Only parse in the first call, which matches the exact request
String^ absPath = SvnBase::Utf8_PtrToString(abs_path+1);
String^ path;
if (absPath->Length > 0)
path = SvnBase::PathToUri(SvnBase::Utf8_PtrToString(abs_path+1))->ToString(); // Skip the initial '/'
else
path = "";
Uri^ rt;
if (path->Length == 0)
{
// Special case. The passed path is the solution root; EndsWith would always succeed
if (qr->Length > 0 && qr[qr->Length-1] != '/')
_repositoryRoot = gcnew Uri(qr + "/");
else
_repositoryRoot = gcnew Uri(qr);
}
else if (Uri::TryCreate(qr, UriKind::Absolute, rt))
{
int n = path->Length;
int up = 0;
while (--n > 0)
{
if (path[n] == '/')
up++;
}
if (qr[qr->Length-1] == '/')
up++;
else if (up == 0)
rt = gcnew Uri(rt, "./");
while (up-- > 0)
rt = gcnew Uri(rt, "../");
_repositoryRoot = rt;
}
return _repositoryRoot;
}
};
}
| 27.222826 | 117 | 0.486125 |
ef7bd400094e5a207ada3b5bda1644fdcd9c3869 | 12,562 | h | C | sololink/flightcode/mavlink/c_library/common/mavlink_msg_landing_target.h | meee1/OpenSolo | 6f299639adbad1e8d573c8ae1135832711b600e4 | [
"Apache-2.0"
] | 68 | 2019-09-23T03:27:05.000Z | 2022-03-12T03:00:41.000Z | sololink/flightcode/mavlink/c_library/common/mavlink_msg_landing_target.h | meee1/OpenSolo | 6f299639adbad1e8d573c8ae1135832711b600e4 | [
"Apache-2.0"
] | 22 | 2019-10-26T20:15:56.000Z | 2022-02-12T05:41:56.000Z | sololink/flightcode/mavlink/c_library/common/mavlink_msg_landing_target.h | meee1/OpenSolo | 6f299639adbad1e8d573c8ae1135832711b600e4 | [
"Apache-2.0"
] | 33 | 2019-09-29T19:52:19.000Z | 2022-03-12T03:00:43.000Z | // MESSAGE LANDING_TARGET PACKING
#define MAVLINK_MSG_ID_LANDING_TARGET 149
typedef struct __mavlink_landing_target_t
{
float angle_x; ///< X-axis angular offset (in radians) of the target from the center of the image
float angle_y; ///< Y-axis angular offset (in radians) of the target from the center of the image
float distance; ///< Distance to the target from the vehicle in meters
uint8_t target_num; ///< The ID of the target if multiple targets are present
uint8_t frame; ///< MAV_FRAME enum specifying the whether the following feilds are earth-frame, body-frame, etc.
} mavlink_landing_target_t;
#define MAVLINK_MSG_ID_LANDING_TARGET_LEN 14
#define MAVLINK_MSG_ID_149_LEN 14
#define MAVLINK_MSG_ID_LANDING_TARGET_CRC 255
#define MAVLINK_MSG_ID_149_CRC 255
#define MAVLINK_MESSAGE_INFO_LANDING_TARGET { \
"LANDING_TARGET", \
5, \
{ { "angle_x", NULL, MAVLINK_TYPE_FLOAT, 0, 0, offsetof(mavlink_landing_target_t, angle_x) }, \
{ "angle_y", NULL, MAVLINK_TYPE_FLOAT, 0, 4, offsetof(mavlink_landing_target_t, angle_y) }, \
{ "distance", NULL, MAVLINK_TYPE_FLOAT, 0, 8, offsetof(mavlink_landing_target_t, distance) }, \
{ "target_num", NULL, MAVLINK_TYPE_UINT8_T, 0, 12, offsetof(mavlink_landing_target_t, target_num) }, \
{ "frame", NULL, MAVLINK_TYPE_UINT8_T, 0, 13, offsetof(mavlink_landing_target_t, frame) }, \
} \
}
/**
* @brief Pack a landing_target message
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
*
* @param target_num The ID of the target if multiple targets are present
* @param frame MAV_FRAME enum specifying the whether the following feilds are earth-frame, body-frame, etc.
* @param angle_x X-axis angular offset (in radians) of the target from the center of the image
* @param angle_y Y-axis angular offset (in radians) of the target from the center of the image
* @param distance Distance to the target from the vehicle in meters
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_landing_target_pack(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg,
uint8_t target_num, uint8_t frame, float angle_x, float angle_y, float distance)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
char buf[MAVLINK_MSG_ID_LANDING_TARGET_LEN];
_mav_put_float(buf, 0, angle_x);
_mav_put_float(buf, 4, angle_y);
_mav_put_float(buf, 8, distance);
_mav_put_uint8_t(buf, 12, target_num);
_mav_put_uint8_t(buf, 13, frame);
memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
#else
mavlink_landing_target_t packet;
packet.angle_x = angle_x;
packet.angle_y = angle_y;
packet.distance = distance;
packet.target_num = target_num;
packet.frame = frame;
memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
#endif
msg->msgid = MAVLINK_MSG_ID_LANDING_TARGET;
#if MAVLINK_CRC_EXTRA
return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
#else
return mavlink_finalize_message(msg, system_id, component_id, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
#endif
}
/**
* @brief Pack a landing_target message on a channel
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param chan The MAVLink channel this message will be sent over
* @param msg The MAVLink message to compress the data into
* @param target_num The ID of the target if multiple targets are present
* @param frame MAV_FRAME enum specifying the whether the following feilds are earth-frame, body-frame, etc.
* @param angle_x X-axis angular offset (in radians) of the target from the center of the image
* @param angle_y Y-axis angular offset (in radians) of the target from the center of the image
* @param distance Distance to the target from the vehicle in meters
* @return length of the message in bytes (excluding serial stream start sign)
*/
static inline uint16_t mavlink_msg_landing_target_pack_chan(uint8_t system_id, uint8_t component_id, uint8_t chan,
mavlink_message_t* msg,
uint8_t target_num,uint8_t frame,float angle_x,float angle_y,float distance)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
char buf[MAVLINK_MSG_ID_LANDING_TARGET_LEN];
_mav_put_float(buf, 0, angle_x);
_mav_put_float(buf, 4, angle_y);
_mav_put_float(buf, 8, distance);
_mav_put_uint8_t(buf, 12, target_num);
_mav_put_uint8_t(buf, 13, frame);
memcpy(_MAV_PAYLOAD_NON_CONST(msg), buf, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
#else
mavlink_landing_target_t packet;
packet.angle_x = angle_x;
packet.angle_y = angle_y;
packet.distance = distance;
packet.target_num = target_num;
packet.frame = frame;
memcpy(_MAV_PAYLOAD_NON_CONST(msg), &packet, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
#endif
msg->msgid = MAVLINK_MSG_ID_LANDING_TARGET;
#if MAVLINK_CRC_EXTRA
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
#else
return mavlink_finalize_message_chan(msg, system_id, component_id, chan, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
#endif
}
/**
* @brief Encode a landing_target struct
*
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param msg The MAVLink message to compress the data into
* @param landing_target C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_landing_target_encode(uint8_t system_id, uint8_t component_id, mavlink_message_t* msg, const mavlink_landing_target_t* landing_target)
{
return mavlink_msg_landing_target_pack(system_id, component_id, msg, landing_target->target_num, landing_target->frame, landing_target->angle_x, landing_target->angle_y, landing_target->distance);
}
/**
* @brief Encode a landing_target struct on a channel
*
* @param system_id ID of this system
* @param component_id ID of this component (e.g. 200 for IMU)
* @param chan The MAVLink channel this message will be sent over
* @param msg The MAVLink message to compress the data into
* @param landing_target C-struct to read the message contents from
*/
static inline uint16_t mavlink_msg_landing_target_encode_chan(uint8_t system_id, uint8_t component_id, uint8_t chan, mavlink_message_t* msg, const mavlink_landing_target_t* landing_target)
{
return mavlink_msg_landing_target_pack_chan(system_id, component_id, chan, msg, landing_target->target_num, landing_target->frame, landing_target->angle_x, landing_target->angle_y, landing_target->distance);
}
/**
* @brief Send a landing_target message
* @param chan MAVLink channel to send the message
*
* @param target_num The ID of the target if multiple targets are present
* @param frame MAV_FRAME enum specifying the whether the following feilds are earth-frame, body-frame, etc.
* @param angle_x X-axis angular offset (in radians) of the target from the center of the image
* @param angle_y Y-axis angular offset (in radians) of the target from the center of the image
* @param distance Distance to the target from the vehicle in meters
*/
#ifdef MAVLINK_USE_CONVENIENCE_FUNCTIONS
static inline void mavlink_msg_landing_target_send(mavlink_channel_t chan, uint8_t target_num, uint8_t frame, float angle_x, float angle_y, float distance)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
char buf[MAVLINK_MSG_ID_LANDING_TARGET_LEN];
_mav_put_float(buf, 0, angle_x);
_mav_put_float(buf, 4, angle_y);
_mav_put_float(buf, 8, distance);
_mav_put_uint8_t(buf, 12, target_num);
_mav_put_uint8_t(buf, 13, frame);
#if MAVLINK_CRC_EXTRA
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, buf, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
#else
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, buf, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
#endif
#else
mavlink_landing_target_t packet;
packet.angle_x = angle_x;
packet.angle_y = angle_y;
packet.distance = distance;
packet.target_num = target_num;
packet.frame = frame;
#if MAVLINK_CRC_EXTRA
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, (const char *)&packet, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
#else
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, (const char *)&packet, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
#endif
#endif
}
#if MAVLINK_MSG_ID_LANDING_TARGET_LEN <= MAVLINK_MAX_PAYLOAD_LEN
/*
This varient of _send() can be used to save stack space by re-using
memory from the receive buffer. The caller provides a
mavlink_message_t which is the size of a full mavlink message. This
is usually the receive buffer for the channel, and allows a reply to an
incoming message with minimum stack space usage.
*/
static inline void mavlink_msg_landing_target_send_buf(mavlink_message_t *msgbuf, mavlink_channel_t chan, uint8_t target_num, uint8_t frame, float angle_x, float angle_y, float distance)
{
#if MAVLINK_NEED_BYTE_SWAP || !MAVLINK_ALIGNED_FIELDS
char *buf = (char *)msgbuf;
_mav_put_float(buf, 0, angle_x);
_mav_put_float(buf, 4, angle_y);
_mav_put_float(buf, 8, distance);
_mav_put_uint8_t(buf, 12, target_num);
_mav_put_uint8_t(buf, 13, frame);
#if MAVLINK_CRC_EXTRA
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, buf, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
#else
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, buf, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
#endif
#else
mavlink_landing_target_t *packet = (mavlink_landing_target_t *)msgbuf;
packet->angle_x = angle_x;
packet->angle_y = angle_y;
packet->distance = distance;
packet->target_num = target_num;
packet->frame = frame;
#if MAVLINK_CRC_EXTRA
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, (const char *)packet, MAVLINK_MSG_ID_LANDING_TARGET_LEN, MAVLINK_MSG_ID_LANDING_TARGET_CRC);
#else
_mav_finalize_message_chan_send(chan, MAVLINK_MSG_ID_LANDING_TARGET, (const char *)packet, MAVLINK_MSG_ID_LANDING_TARGET_LEN);
#endif
#endif
}
#endif
#endif
// MESSAGE LANDING_TARGET UNPACKING
/**
* @brief Get field target_num from landing_target message
*
* @return The ID of the target if multiple targets are present
*/
static inline uint8_t mavlink_msg_landing_target_get_target_num(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint8_t(msg, 12);
}
/**
* @brief Get field frame from landing_target message
*
* @return MAV_FRAME enum specifying the whether the following feilds are earth-frame, body-frame, etc.
*/
static inline uint8_t mavlink_msg_landing_target_get_frame(const mavlink_message_t* msg)
{
return _MAV_RETURN_uint8_t(msg, 13);
}
/**
* @brief Get field angle_x from landing_target message
*
* @return X-axis angular offset (in radians) of the target from the center of the image
*/
static inline float mavlink_msg_landing_target_get_angle_x(const mavlink_message_t* msg)
{
return _MAV_RETURN_float(msg, 0);
}
/**
* @brief Get field angle_y from landing_target message
*
* @return Y-axis angular offset (in radians) of the target from the center of the image
*/
static inline float mavlink_msg_landing_target_get_angle_y(const mavlink_message_t* msg)
{
return _MAV_RETURN_float(msg, 4);
}
/**
* @brief Get field distance from landing_target message
*
* @return Distance to the target from the vehicle in meters
*/
static inline float mavlink_msg_landing_target_get_distance(const mavlink_message_t* msg)
{
return _MAV_RETURN_float(msg, 8);
}
/**
* @brief Decode a landing_target message into a struct
*
* @param msg The message to decode
* @param landing_target C-struct to decode the message contents into
*/
static inline void mavlink_msg_landing_target_decode(const mavlink_message_t* msg, mavlink_landing_target_t* landing_target)
{
#if MAVLINK_NEED_BYTE_SWAP
landing_target->angle_x = mavlink_msg_landing_target_get_angle_x(msg);
landing_target->angle_y = mavlink_msg_landing_target_get_angle_y(msg);
landing_target->distance = mavlink_msg_landing_target_get_distance(msg);
landing_target->target_num = mavlink_msg_landing_target_get_target_num(msg);
landing_target->frame = mavlink_msg_landing_target_get_frame(msg);
#else
memcpy(landing_target, _MAV_PAYLOAD(msg), MAVLINK_MSG_ID_LANDING_TARGET_LEN);
#endif
}
| 41.052288 | 208 | 0.789604 |
33438635500c4b8a04d46b1b9c158444007c7fc1 | 12,102 | h | C | ugene/src/corelibs/U2Designer/src/DelegateEditors.h | iganna/lspec | c75cba3e4fa9a46abeecbf31b5d467827cf4fec0 | [
"MIT"
] | null | null | null | ugene/src/corelibs/U2Designer/src/DelegateEditors.h | iganna/lspec | c75cba3e4fa9a46abeecbf31b5d467827cf4fec0 | [
"MIT"
] | null | null | null | ugene/src/corelibs/U2Designer/src/DelegateEditors.h | iganna/lspec | c75cba3e4fa9a46abeecbf31b5d467827cf4fec0 | [
"MIT"
] | null | null | null | /**
* UGENE - Integrated Bioinformatics Tools.
* Copyright (C) 2008-2012 UniPro <ugene@unipro.ru>
* http://ugene.unipro.ru
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#ifndef _U2_WORKFLOW_URL_H_
#define _U2_WORKFLOW_URL_H_
#include <U2Lang/ConfigurationEditor.h>
#include <QtCore/QModelIndex>
#include <QtCore/QPointer>
#include <QtGui/QLineEdit>
#include <QtGui/QToolButton>
#include <QtGui/QDialog>
#include <QtGui/QListWidget>
#include <QtGui/QPushButton>
#include <QtGui/QSpinBox>
#include <QtGui/QComboBox>
#include <QtGui/QLineEdit>
#include <QtGui/QToolButton>
#include <QtGui/QHBoxLayout>
#include <QtGui/QVBoxLayout>
#include <QtGui/QFileDialog>
#include <QtCore/QCoreApplication>
#include <QtGui/QKeyEvent>
#include <QtGui/QTextEdit>
namespace U2 {
/**
* simple realization of configuration editor
*/
class U2DESIGNER_EXPORT DelegateEditor : public ConfigurationEditor {
Q_OBJECT
public:
DelegateEditor(const QMap<QString, PropertyDelegate*>& map) : delegates(map) {}
DelegateEditor(const QString& s, PropertyDelegate* d) {delegates.insert(s,d);}
virtual ~DelegateEditor() {qDeleteAll(delegates.values());}
virtual PropertyDelegate* getDelegate(const QString& name) {return delegates.value(name);}
virtual PropertyDelegate* removeDelegate( const QString & name ) {return delegates.take( name );}
virtual void addDelegate( PropertyDelegate * del, const QString & name ) { delegates.insert( name, del ); }
virtual void commit() {}
virtual ConfigurationEditor *clone() {return new ConfigurationEditor(*this);}
protected:
QMap<QString, PropertyDelegate*> delegates;
}; // DelegateEditor
class U2DESIGNER_EXPORT URLLineEdit : public QLineEdit {
Q_OBJECT
public:
URLLineEdit(const QString& filter, const QString& type, bool multi, bool isPath, bool saveFile, QWidget *parent, const QString &format = "");
protected:
void focusOutEvent ( QFocusEvent * event );
private slots:
void sl_onBrowse();
void sl_onBrowseWithAdding();
void sl_editingFinished();
signals:
void si_finished();
private:
QString FileFilter;
QString type;
bool multi;
bool isPath;
bool saveFile;
QString fileFormat;
void browse(bool addFiles = false);
void checkExtension(QString &name);
};
class U2DESIGNER_EXPORT URLDelegate : public PropertyDelegate {
Q_OBJECT
public:
URLDelegate(const QString& filter, const QString& type, bool multi = false, bool isPath = false, bool saveFile = true, QObject *parent = 0, const QString &format = "")
: PropertyDelegate(parent), FileFilter(filter), type(type), multi(multi), isPath(isPath), showButton( true ), saveFile(saveFile),
currentEditor(NULL), fileFormat(format) {
}
virtual ~URLDelegate() {}
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
virtual void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const;
virtual PropertyDelegate *clone() {
return new URLDelegate(FileFilter, type, multi, isPath, saveFile, parent(), fileFormat);
}
public slots:
void sl_showEditorButton( bool show );
void sl_commit();
void sl_formatChanged(const QString &newFormat);
protected:
QString FileFilter;
QString type;
bool multi;
bool isPath;
bool showButton;
bool saveFile; // sets when you need only 1 file for reading (is set with multi=false)
mutable QWidget* currentEditor;
QString text;
QString fileFormat;
private slots:
void sl_textChanged(const QString &text);
};
class U2DESIGNER_EXPORT SpinBoxDelegate : public PropertyDelegate {
Q_OBJECT
public:
SpinBoxDelegate(const QVariantMap& props = QVariantMap(), QObject *parent = 0) :
PropertyDelegate(parent), spinProperties(props), currentEditor(NULL) {}
virtual ~SpinBoxDelegate() {}
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const;
QVariant getDisplayValue(const QVariant&) const;
void setEditorProperty(const char* name, const QVariant& val);
virtual PropertyDelegate *clone() {
return new SpinBoxDelegate(spinProperties, parent());
}
signals:
void si_valueChanged(int);
private:
QVariantMap spinProperties;
mutable QPointer<QWidget> currentEditor;
};
class U2DESIGNER_EXPORT DoubleSpinBoxDelegate : public PropertyDelegate {
public:
DoubleSpinBoxDelegate(const QVariantMap& props = QVariantMap(), QObject *parent = 0) :
PropertyDelegate(parent), spinProperties(props) {}
virtual ~DoubleSpinBoxDelegate() {}
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const;
QVariant getDisplayValue(const QVariant&) const;
virtual PropertyDelegate *clone() {
return new DoubleSpinBoxDelegate(spinProperties, parent());
}
private:
QVariantMap spinProperties;
};
class U2DESIGNER_EXPORT ComboBoxDelegate : public PropertyDelegate {
Q_OBJECT
public:
ComboBoxDelegate(const QVariantMap& items, QObject *parent = 0) : PropertyDelegate(parent), items(items) {}
virtual ~ComboBoxDelegate() {}
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const;
QVariant getDisplayValue(const QVariant&) const;
virtual PropertyDelegate *clone() {
return new ComboBoxDelegate(items, parent());
}
signals:
void si_valueChanged( const QString & newVal ) const;
protected:
QVariantMap items;
};
class U2DESIGNER_EXPORT FileModeDelegate : public ComboBoxDelegate {
public:
FileModeDelegate(bool appendSupported, QObject *parent = 0);
virtual ~FileModeDelegate() {}
virtual PropertyDelegate *clone() {
return new FileModeDelegate(3 == items.size(), parent());
}
};
class U2DESIGNER_EXPORT SchemaRunModeDelegate : public ComboBoxDelegate {
Q_OBJECT
public:
static const QString THIS_COMPUTER_STR;
static const QString REMOTE_COMPUTER_STR;
public:
SchemaRunModeDelegate(QObject * parent = 0);
virtual ~SchemaRunModeDelegate() {}
virtual PropertyDelegate *clone() {
return new SchemaRunModeDelegate(parent());
}
public slots:
void sl_valueChanged( const QString & val );
signals:
void si_showOpenFileButton( bool show );
}; // SchemaRunModeDelegate
class U2DESIGNER_EXPORT AttributeScriptDelegate : public PropertyDelegate {
Q_OBJECT
public:
AttributeScriptDelegate(QObject *parent = 0);
virtual ~AttributeScriptDelegate();
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
QVariant getDisplayValue(const QVariant&) const;
static QString createScriptHeader(const AttributeScript & attrScript);
virtual PropertyDelegate *clone() {
return new AttributeScriptDelegate(parent());
}
private slots:
void sl_comboActivated(int);
}; // AttributeScriptDelegate
//class U2DESIGNER_EXPORT InputPortDataDelegate : public ComboBoxDelegate {
// Q_OBJECT
//public:
// InputPortDataDelegate(const QVariantMap& items, QObject *parent = NULL );
// virtual ~InputPortDataDelegate();
//
// QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
// void setEditorData(QWidget *editor, const QModelIndex &index) const;
// void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
// QVariant getDisplayValue(const QVariant&) const;
//
//}; // InputPortDataDelegatedes
class U2DESIGNER_EXPORT StingListEdit : public QLineEdit {
Q_OBJECT
public:
StingListEdit(QWidget *parent) : QLineEdit(parent) {}
protected:
void focusOutEvent(QFocusEvent *event);
signals:
void si_finished();
private slots:
void sl_onExpand();
};
class U2DESIGNER_EXPORT StringListDelegate : public PropertyDelegate {
Q_OBJECT
public:
StringListDelegate(QObject *parent = 0) : PropertyDelegate(parent), showButton(true) {}
virtual ~StringListDelegate() {}
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
virtual PropertyDelegate *clone() {
return new StringListDelegate(parent());
}
public slots:
void sl_showEditorButton(bool show);
void sl_commit();
private:
static const QString EDITOR;
bool showButton;
mutable QWidget *currentEditor;
};
class SelectorDialogHandler {
public:
virtual QDialog *createSelectorDialog(const QString& init) = 0;
virtual QString getSelectedString(QDialog *dlg) = 0;
};
class U2DESIGNER_EXPORT StringSelectorDelegate: public PropertyDelegate {
Q_OBJECT
public:
StringSelectorDelegate(const QString& _initValue, SelectorDialogHandler *_f, QObject *o = NULL):
PropertyDelegate(o), initValue(_initValue), f(_f) {}
virtual ~StringSelectorDelegate() {}
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const ;
virtual PropertyDelegate *clone() {
return new StringSelectorDelegate(initValue, f, parent());
}
private slots:
void sl_onClick();
void sl_commit();
private:
mutable QLineEdit *valueEdit;
mutable QWidget *currentEditor;
QString initValue;
bool multipleSelection;
SelectorDialogHandler *f;
};
class U2DESIGNER_EXPORT CharacterDelegate : public PropertyDelegate {
Q_OBJECT
public:
CharacterDelegate(QObject *parent = 0) : PropertyDelegate(parent) {}
virtual ~CharacterDelegate() {}
virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
virtual PropertyDelegate *clone() {
return new CharacterDelegate(parent());
}
}; // CharacterDelegate
}//namespace U2
#endif
| 32.532258 | 171 | 0.727648 |
c31d1cf6fd5800e76b044692bce6d142be8d2784 | 523 | h | C | medtree/medtree/Groups/Common/HomePageCommonCell.h | lihongli528628/yishu | 9d5efd4fff5296cbc3a3cb65f56fc9ea4e440705 | [
"MIT"
] | 1 | 2017-02-21T05:40:25.000Z | 2017-02-21T05:40:25.000Z | medtree/medtree/Groups/Common/HomePageCommonCell.h | lihongli528628/yishu | 9d5efd4fff5296cbc3a3cb65f56fc9ea4e440705 | [
"MIT"
] | null | null | null | medtree/medtree/Groups/Common/HomePageCommonCell.h | lihongli528628/yishu | 9d5efd4fff5296cbc3a3cb65f56fc9ea4e440705 | [
"MIT"
] | null | null | null | //
// HomePageCommonCell.h
// medtree
//
// Created by 陈升军 on 15/3/26.
// Copyright (c) 2015年 sam. All rights reserved.
//
#import "BaseCell.h"
@class BadgeView;
@interface HomePageCommonCell : BaseCell
{
UIImageView *headerImage;
UILabel *titleLab;
UIImageView *userImage;
UILabel *detailLab;
UILabel *bgDetailLab;
BadgeView *badgeView;
UIImageView *nextImage;
UILabel *decLab;
}
- (id)getDTO;
@end
| 18.678571 | 49 | 0.567878 |
8fcea111e595b7e00f54da136b1fa964ba54a981 | 276 | h | C | Pica/Setting/Controller/PCSettingController.h | qiu1993/Pica | 9e159ca4ac3b2556f06b647d1c515a2d87636a24 | [
"MIT"
] | 201 | 2020-11-12T09:12:01.000Z | 2022-03-31T04:42:01.000Z | Pica/Setting/Controller/PCSettingController.h | qiu1993/Pica | 9e159ca4ac3b2556f06b647d1c515a2d87636a24 | [
"MIT"
] | 24 | 2021-02-03T02:33:09.000Z | 2022-03-31T04:42:20.000Z | Pica/Setting/Controller/PCSettingController.h | qiu1993/Pica | 9e159ca4ac3b2556f06b647d1c515a2d87636a24 | [
"MIT"
] | 26 | 2020-11-29T04:40:23.000Z | 2022-03-08T12:16:20.000Z | //
// PCSettingController.h
// Pica
//
// Created by YueCheng on 2021/5/28.
// Copyright © 2021 fancy. All rights reserved.
//
#import "PCTableViewController.h"
NS_ASSUME_NONNULL_BEGIN
@interface PCSettingController : PCTableViewController
@end
NS_ASSUME_NONNULL_END
| 15.333333 | 54 | 0.757246 |
a66d534754f07e870423c82a5b6d07e63d7b2bac | 438 | h | C | CommonTools/Statistics/src/IncompleteGammaComplement.h | nistefan/cmssw | ea13af97f7f2117a4f590a5e654e06ecd9825a5b | [
"Apache-2.0"
] | 3 | 2018-08-24T19:10:26.000Z | 2019-02-19T11:45:32.000Z | CommonTools/Statistics/src/IncompleteGammaComplement.h | nistefan/cmssw | ea13af97f7f2117a4f590a5e654e06ecd9825a5b | [
"Apache-2.0"
] | 3 | 2018-08-23T13:40:24.000Z | 2019-12-05T21:16:03.000Z | CommonTools/Statistics/src/IncompleteGammaComplement.h | nistefan/cmssw | ea13af97f7f2117a4f590a5e654e06ecd9825a5b | [
"Apache-2.0"
] | 5 | 2018-08-21T16:37:52.000Z | 2020-01-09T13:33:17.000Z | #ifndef IncompleteGammaComplement_H
#define IncompleteGammaComplement_H
/** \class IncompleteGammaComplement
* Computes the complement Q(a,x)=1-P(a,x) of the incomplete gamma function.
* Computes its natural logarithm, useful for comparing very small values.
* source: Numerical Recipes
*/
class IncompleteGammaComplement {
public:
static float value( float a, float x );
static float ln( float a, float x );
};
#endif
| 21.9 | 78 | 0.748858 |
0a6794a50acb2fd1dd8e045125ede880eab6998a | 724 | h | C | tools/Packers/deps/sandbox/linux/SandboxLogging.h | fstudio/Phoenix | 28a7c6a3932fd7d6fea12770d0aa1e20bc70db7d | [
"MIT"
] | 8 | 2015-01-23T05:41:46.000Z | 2019-11-20T05:10:27.000Z | tools/Packers/deps/sandbox/linux/SandboxLogging.h | fstudio/Phoenix | 28a7c6a3932fd7d6fea12770d0aa1e20bc70db7d | [
"MIT"
] | null | null | null | tools/Packers/deps/sandbox/linux/SandboxLogging.h | fstudio/Phoenix | 28a7c6a3932fd7d6fea12770d0aa1e20bc70db7d | [
"MIT"
] | 4 | 2015-05-05T05:15:43.000Z | 2020-03-07T11:10:56.000Z | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_SandboxLogging_h
#define mozilla_SandboxLogging_h
#if defined(ANDROID)
#include <android/log.h>
#else
#include <stdio.h>
#endif
#if defined(ANDROID)
#define SANDBOX_LOG_ERROR(args...) __android_log_print(ANDROID_LOG_ERROR, "Sandbox", ## args)
#else
#define SANDBOX_LOG_ERROR(fmt, args...) fprintf(stderr, "Sandbox: " fmt "\n", ## args)
#endif
#endif // mozilla_SandboxLogging_h
| 31.478261 | 93 | 0.708564 |
1122228a4afe49ea22e988717d9d099c02dd8626 | 1,040 | c | C | ascii-to-flex.c | georgeweigt/story-of-mel | e4a82c27b85d22ad43281cbd425c0dfaff9b2b29 | [
"BSD-2-Clause"
] | null | null | null | ascii-to-flex.c | georgeweigt/story-of-mel | e4a82c27b85d22ad43281cbd425c0dfaff9b2b29 | [
"BSD-2-Clause"
] | null | null | null | ascii-to-flex.c | georgeweigt/story-of-mel | e4a82c27b85d22ad43281cbd425c0dfaff9b2b29 | [
"BSD-2-Clause"
] | 1 | 2021-07-07T12:42:32.000Z | 2021-07-07T12:42:32.000Z | // emit an array for converting ascii to flexowriter values
#include <stdio.h>
// p for print, converts flexowriter value to ascii
int ptab[128] = {
0, 0, 'Z', 'z', ')', '0', ' ', ' ',
0, 0, 'B', 'b', 'L', 'l', '_', '-',
0, 0, 'Y', 'y', '*', '2', '=', '+',
0, 0, 'R', 'r', '"', '3', ':', ';',
'\n', '\n', 'I', 'i', 0, '4', '?', '/',
'\b', '\b', 'D', 'd', '%', '5', ']', '.',
'\t', '\t', 'N', 'n', '$', '6', '[', ',',
0, 0, 'M', 'm', 0, '7', 'V', 'v',
0, 0, 'P', 'p', 0, '8', 'O', 'o',
0, 0, 'E', 'e', '(', '9', 'X', 'x',
0, 0, 'U', 'u', 'F', 'f', 0, 0,
0, 0, 'T', 't', 'G', 'g', 0, 0,
0, 0, 'H', 'h', 'J', 'j', 0, 0,
0, 0, 'C', 'c', 'K', 'k', 0, 0,
0, 0, 'A', 'a', 'Q', 'q', 0, 0,
0, 0, 'S', 's', 'W', 'w', 0, 0,
};
int rtab[128]; // r for read, converts ascii to flexowriter value
int
main()
{
int c, i;
rtab['1'] = 6; // ascii 1 same as l
for (i = 0; i < 128; i++) {
c = ptab[i];
if (c)
rtab[c] = i / 2;
}
for (i = 0; i < 128; i++) {
printf("\t%d,", rtab[i]);
if (i % 8 == 7)
printf("\n");
}
}
| 22.12766 | 65 | 0.347115 |
52d4cf50e0b65d0bb500e94b39e326c99844bc2e | 1,110 | c | C | simulator/parser/parser.c | agkaminski/AK6502 | d6dcde44aca60f772f1ab108ccd55d3f9400c6a6 | [
"BSD-3-Clause"
] | null | null | null | simulator/parser/parser.c | agkaminski/AK6502 | d6dcde44aca60f772f1ab108ccd55d3f9400c6a6 | [
"BSD-3-Clause"
] | null | null | null | simulator/parser/parser.c | agkaminski/AK6502 | d6dcde44aca60f772f1ab108ccd55d3f9400c6a6 | [
"BSD-3-Clause"
] | null | null | null | #include <string.h>
#include "common/error.h"
#include "parser.h"
#include "binary.h"
#include "ihex.h"
#include "srec.h"
static const char *srec_extentions[] = {
"s19", "s28", "s37", "s", "s1",
"s2", "s3", "sx", "srec", "mot"
};
static const char *get_extension(const char* str)
{
const char *ptr;
ptr = str + strlen(str);
for (; ptr > str; --ptr) {
if (*ptr == '.')
break;
}
if (ptr == str)
ptr = str + strlen(str);
DEBUG("File extentention: %s", ptr);
return ++ptr;
}
int parse_file(const char *path, u16 offset, u8 *buff, size_t bufflen)
{
const char *extension;
int i;
extension = get_extension(path);
if (strcmp(extension, "hex") == 0 || strcmp(extension, "ihex") == 0) {
DEBUG("Parsing as intel HEX file");
return ihex_parse(path, offset, buff, bufflen);
}
for (i = 0; i < sizeof(srec_extentions) / sizeof(srec_extentions[0]); ++i) {
if (strcmp(extension, srec_extentions[i]) == 0) {
DEBUG("Parsing as SREC file");
return srec_parse(path, offset, buff, bufflen);
}
}
DEBUG("Parsing as binary file");
return binary_parse(path, offset, buff, bufflen);
}
| 20.555556 | 77 | 0.628829 |
f8b25949595cddadf350c891bdaca62dac31bf14 | 369 | h | C | EherEmployee/EherEmployee/Controller/Main/TabBarControllerConfig.h | jackquan/EherEmployee | c62889eb0d335e1391f3446fdbc35b9f4f85a7d2 | [
"MIT"
] | null | null | null | EherEmployee/EherEmployee/Controller/Main/TabBarControllerConfig.h | jackquan/EherEmployee | c62889eb0d335e1391f3446fdbc35b9f4f85a7d2 | [
"MIT"
] | null | null | null | EherEmployee/EherEmployee/Controller/Main/TabBarControllerConfig.h | jackquan/EherEmployee | c62889eb0d335e1391f3446fdbc35b9f4f85a7d2 | [
"MIT"
] | null | null | null | //
// TabBarControllerConfig.h
// ERP
//
// Created by Luoqw on 2017/3/30.
// Copyright © 2017年 eheeher. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "CYLTabBarController.h"
#import "EherNavigationController.h"
@interface TabBarControllerConfig : NSObject
@property (nonatomic, readonly, strong) CYLTabBarController *tabBarController;
@end
| 20.5 | 78 | 0.756098 |
20c4e3b9ae46f9a106e76c1a2db023909f1561fc | 798 | h | C | Lab 1/Part 3/database.h | knu-3-tochanenko/Databases | 4cce8049d0b1d67c8fc54f3dacc9a1b1f5c1dc05 | [
"MIT"
] | null | null | null | Lab 1/Part 3/database.h | knu-3-tochanenko/Databases | 4cce8049d0b1d67c8fc54f3dacc9a1b1f5c1dc05 | [
"MIT"
] | null | null | null | Lab 1/Part 3/database.h | knu-3-tochanenko/Databases | 4cce8049d0b1d67c8fc54f3dacc9a1b1f5c1dc05 | [
"MIT"
] | null | null | null | #ifndef PART_3_DATABASE_H
#define PART_3_DATABASE_H
#include "tables.h"
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include "stdlib.h"
unsigned int countVendor(char *ptr, FILE **vendorFile);
unsigned int countOs(char *ptr, FILE **osFile);
unsigned int countAllOs(char *ptr, FILE **osFile);
bool removeVendor(char *ptr, FILE **vendorFile, FILE **osFile);
bool removeOs(char *ptr, FILE **vendorFile, FILE **osFile);
int getVendor(char *ptr, FILE **vendorFile);
int getOs(char *ptr, FILE **vendorFile, FILE **osFile);
int os_NUMBER;
bool insertVendor(char *ptr, FILE **vendorFile);
bool insertOs(char *ptr, FILE **vendorFile, FILE **osFile);
bool updateVendor(char *ptr, FILE **vendorFile);
bool updateOs(char *ptr, FILE **vendorFile, FILE** osFile);
#endif //PART_3_DATABASE_H
| 29.555556 | 63 | 0.736842 |
25b1dec1e9659348833422ceb7ddf3c8547fcd4b | 504 | h | C | Analysis/DataViewer/GainSpatial.h | konradotto/TS | bf088bd8432b1e3f4b8c8c083650a30d9ef2ae2e | [
"Apache-2.0"
] | 125 | 2015-01-22T05:43:23.000Z | 2022-03-22T17:15:59.000Z | Analysis/DataViewer/GainSpatial.h | konradotto/TS | bf088bd8432b1e3f4b8c8c083650a30d9ef2ae2e | [
"Apache-2.0"
] | 59 | 2015-02-10T09:13:06.000Z | 2021-11-11T02:32:38.000Z | Analysis/DataViewer/GainSpatial.h | konradotto/TS | bf088bd8432b1e3f4b8c8c083650a30d9ef2ae2e | [
"Apache-2.0"
] | 98 | 2015-01-17T01:25:10.000Z | 2022-03-18T17:29:42.000Z | /* Copyright (C) 2016 Ion Torrent Systems, Inc. All Rights Reserved */
#ifndef GAINSPATIAL_H
#define GAINSPATIAL_H
#include <QObject>
#include "SpatialPlot.h"
#include "qcustomplot.h"
class GainSpatial : public SpatialPlot
{
public:
GainSpatial(QWidget *parent);
void doConvert(int &loading);
void addMask(uint mask);
void RemoveMask(uint mask);
protected:
virtual float Get_Data(int idx, int y, int x);
private:
float *out=NULL;
uint mMask=0;
};
#endif // GAINSPATIAL_H
| 19.384615 | 70 | 0.710317 |
6eff5e364f7e0ec754965fe3e9fd7e6406c5c969 | 100 | h | C | netbsd/sys/arch/ofppc/include/int_limits.h | MarginC/kame | 2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30 | [
"BSD-3-Clause"
] | 91 | 2015-01-05T15:18:31.000Z | 2022-03-11T16:43:28.000Z | netbsd/sys/arch/ofppc/include/int_limits.h | MarginC/kame | 2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30 | [
"BSD-3-Clause"
] | 1 | 2016-02-25T15:57:55.000Z | 2016-02-25T16:01:02.000Z | netbsd/sys/arch/ofppc/include/int_limits.h | MarginC/kame | 2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30 | [
"BSD-3-Clause"
] | 21 | 2015-02-07T08:23:07.000Z | 2021-12-14T06:01:49.000Z | /* $NetBSD: int_limits.h,v 1.1 2001/04/15 15:29:10 kleink Exp $ */
#include <powerpc/int_limits.h>
| 25 | 66 | 0.68 |
ee38f19b2f3badfafb6bb8917250d757f93f6250 | 788 | h | C | source/ccvs.h | joecrop/joespice | 63c37fe1afb2e586bd4cfc4136eb9fa21baedc04 | [
"MIT"
] | null | null | null | source/ccvs.h | joecrop/joespice | 63c37fe1afb2e586bd4cfc4136eb9fa21baedc04 | [
"MIT"
] | null | null | null | source/ccvs.h | joecrop/joespice | 63c37fe1afb2e586bd4cfc4136eb9fa21baedc04 | [
"MIT"
] | null | null | null | /* information used to describe a single instance */
typedef struct ccvs{
char *name; /* pointer to character string naming this ccvs */
int pNode; /* number of positive node of ccvs */
int nNode; /* number of negative node of ccvs */
int cbranchNum ; /* number of control branch */
int branchNum ; /* number of ccvs branch */
double Rt; /* value of trans-resistance */
double *pb1n1; /*pointer to sparse-matrix location (pNode, pNode)*/
double *pb1n2; /*pointer to sparse-matrix location (pNode, nNode)*/
double *pn1b1; /*pointer to sparse-matrix location (nNode, nNode)*/
double *pn2b1; /*pointer to sparse-matrix location (nNode, pNode)*/
double *pb1b2; /*pointer to sparse-matrix location (nNode, pNode)*/
} ccvs ;
| 43.777778 | 75 | 0.658629 |
5a5ccdc8b17cccc8b34a84f8f4d6058420d8191d | 3,988 | c | C | d/deku/open/old/rec.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-07-19T05:24:44.000Z | 2021-11-18T04:08:19.000Z | d/deku/open/old/rec.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 4 | 2021-03-15T18:56:39.000Z | 2021-08-17T17:08:22.000Z | d/deku/open/old/rec.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-09-12T06:22:38.000Z | 2022-01-31T01:15:12.000Z | #include <std.h>
#include <objects.h>
inherit "/d/deku/inherits/vexia-lair.c";
int pulled;
void create() {
::create();
set_short("Reception Chamber");
set_long(
@KAYLA
The huge door swings into a dusty torchlit room with solid stone walls.
Torch brackets are set in the wall every 10' but only one holds a
burning torch. On the west side of the room, semicircular stairs lead
up to a 30' wide dais. In the western wall of the dais, another door
is set deeply into the wall.
KAYLA
);
set_exits(([
"south" : "/d/deku/open/cave_r1"
] ));
set_items(([
({"steps", "stairs"}) : "Chiseled into the steps of the dais are runes "
"or glyphs of some kind although you can't make out any meaning.",
({"door", "western door"}):"The western door is made of split oaken logs "
"bound together with iron strips and coated with some kind of sticky, "
"resilient pitch. Door latches and levers are iron. Perhaps you "
"could open it if you tried.",
({"torch", "torches", "brackets"}) :"Something does seem a little odd "
"about the bracket on the torch that's burning.",
"dais": "A raised platform that the steps lead up to. It's empty except "
"for the door on the west wall.",
] ));
}
void init() {
::init();
add_action("search","search");
add_action("open","open");
add_action("pull","pull");
add_action("pull","push");
add_action("pull","move");
}
int search(string str) {
if(!str) {
write("Search what?");
return 1;
}
if (str == "room" || str == "torch" || str == "bracket") {
write("You search the "+str+" and find that the bracket holding the "
"burning torch could be used as some kind of lever, maybe to "
"open some secret door.");
tell_room(ETP,TPQCN+" discovers a lever.",TP);
return 1;
}
}
int pull(string str) {
object obj;
if(!str) {
write("Push or move what?");
return 1;
}
if(sizeof(TP->query_attackers()) > 0){
write("There are monsters in the room, you cannot do that right now!");
return 1;
}
if (str == "lever") {
write("You must push or move the lever upward or downward.");
return 1;
}
if (str == "lever downward") {
write("You move the lever downward but nothing seems to happen.");
if(pulled) return 1;
tell_room(ETP,"While "+TPQCN+" moves the lever downward, you notice a small " "opening in the wall form and a scroll drop from it silently",TP);
obj=new("/d/magic/scroll");
obj->set_spell(3);
obj->move(TO);
pulled = 1;
return 1;
}
if (str == "lever upward") {
write("As you move the lever upward a secret door opens to the north.");
tell_room(ETP,TPQCN+" moves the lever upward.", TP);
tell_room(ETP,"A secret door opens to the north.", TP);
write("%^BOLD%^You move through the northern secret door, ready or not!");
TP->move_player("/d/deku/open/cave_r2");
tell_room(ETP, TPQCN+" disappears through the northern exit.", TP);
return 1;
}
}
int open(string str) {
if(!str) {
write("Open what?");
return 1;
}
if (str == "door") {
write("Open which door?");
return 1;
}
if (str != "west door" && str != "western door") {
write("You cannot open that!");
return 1;
}
write("You try to open the western door. What a mistake, for it was a trap!\n"
"Spears are lauched from both the north and south walls!!\n");
tell_room(ETP, TPQCN+" tries to open the western door.\n"
"What a mistake that was, for spears lauch from both the north and south "
"walls!!", TP);
TP->do_damage("torso",random(10));
return 1;
}
void reset() {
::reset();
pulled = 0;
if(!present("centaur") && !random(2)) {
new("/d/deku/monster/centaur")->move(TO);
new("/d/deku/monster/centaur")->move(TO);
new("/d/deku/monster/centaur")->move(TO);
if(!random(3)) new("/d/deku/monster/centaur")->move(TO);
}
}
| 31.401575 | 177 | 0.614343 |
e1515032fc6f6b52c7d046fdf86155c1e6250497 | 3,698 | h | C | thirdparty/grpc/include/google/protobuf/generated_message_bases.h | SakuraEngine/Sakura.Runtime | 5a397fb2b1285326c4216f522fe10e347bd566f7 | [
"MIT"
] | 29 | 2021-11-19T11:28:22.000Z | 2022-03-29T00:26:51.000Z | thirdparty/grpc/include/google/protobuf/generated_message_bases.h | SakuraEngine/Sakura.Runtime | 5a397fb2b1285326c4216f522fe10e347bd566f7 | [
"MIT"
] | null | null | null | thirdparty/grpc/include/google/protobuf/generated_message_bases.h | SakuraEngine/Sakura.Runtime | 5a397fb2b1285326c4216f522fe10e347bd566f7 | [
"MIT"
] | 1 | 2022-03-05T08:14:40.000Z | 2022-03-05T08:14:40.000Z | // Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This file contains helpers for generated code.
//
// Nothing in this file should be directly referenced by users of protobufs.
#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__
#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__
#include <google/protobuf/parse_context.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/arena.h>
#include <google/protobuf/generated_message_util.h>
#include <google/protobuf/message.h>
// Must come last:
#include <google/protobuf/port_def.inc>
namespace google {
namespace protobuf {
namespace internal {
// To save code size, protos without any fields are derived from ZeroFieldsBase
// rather than Message.
class PROTOBUF_EXPORT ZeroFieldsBase : public Message {
public:
PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear() final;
bool IsInitialized() const final { return true; }
size_t ByteSizeLong() const final;
int GetCachedSize() const final { return _cached_size_.Get(); }
const char* _InternalParse(const char* ptr,
internal::ParseContext* ctx) final;
::uint8_t* _InternalSerialize(::uint8_t* target,
io::EpsCopyOutputStream* stream) const final;
protected:
constexpr ZeroFieldsBase() {}
explicit ZeroFieldsBase(Arena* arena, bool is_message_owned)
: Message(arena, is_message_owned) {}
ZeroFieldsBase(const ZeroFieldsBase&) = delete;
ZeroFieldsBase& operator=(const ZeroFieldsBase&) = delete;
~ZeroFieldsBase() override;
void SetCachedSize(int size) const final { _cached_size_.Set(size); }
static void MergeImpl(Message* to, const Message& from);
static void CopyImpl(Message* to, const Message& from);
void InternalSwap(ZeroFieldsBase* other);
mutable internal::CachedSize _cached_size_;
};
} // namespace internal
} // namespace protobuf
} // namespace google
#include <google/protobuf/port_undef.inc>
#endif // GOOGLE_PROTOBUF_GENERATED_MESSAGE_BASES_H__
| 42.022727 | 80 | 0.742293 |
6e883437ecfb3d617c37aa1b4109f6d12960182c | 520 | c | C | test/test_xstr/test_xstr.c | Koos85/siridb-server | e245cec21f29fd649fb5c363d197012cdd5992f6 | [
"MIT"
] | null | null | null | test/test_xstr/test_xstr.c | Koos85/siridb-server | e245cec21f29fd649fb5c363d197012cdd5992f6 | [
"MIT"
] | null | null | null | test/test_xstr/test_xstr.c | Koos85/siridb-server | e245cec21f29fd649fb5c363d197012cdd5992f6 | [
"MIT"
] | null | null | null | #include "../test.h"
#include <xstr/xstr.h>
int main()
{
test_start("xstr");
/* xstr_to_double */
{
_assert (xstr_to_double("0.5", 3) == 0.5);
_assert (xstr_to_double("0.55", 3) == 0.5);
_assert (xstr_to_double("123.456", 7) == 123.456);
_assert (xstr_to_double("123", 3) == 123);
_assert (xstr_to_double("123.", 4) == 123);
_assert (xstr_to_double("123456.", 3) == 123);
_assert (xstr_to_double("-0.5", 3) == -0.5);
}
return test_end();
}
| 23.636364 | 58 | 0.532692 |
f598d42f292eb0974927e9983db877be609a811a | 6,264 | h | C | xdk-asf-3.51.0/sam/utils/cmsis/samg/samg55/include/instance/spi7.h | j3270/SAMD_Experiments | 5c242aff44fc8d7092322d7baf2dda450a78a9b7 | [
"MIT"
] | null | null | null | xdk-asf-3.51.0/sam/utils/cmsis/samg/samg55/include/instance/spi7.h | j3270/SAMD_Experiments | 5c242aff44fc8d7092322d7baf2dda450a78a9b7 | [
"MIT"
] | null | null | null | xdk-asf-3.51.0/sam/utils/cmsis/samg/samg55/include/instance/spi7.h | j3270/SAMD_Experiments | 5c242aff44fc8d7092322d7baf2dda450a78a9b7 | [
"MIT"
] | null | null | null | /**
* \file
*
* Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
*
* \asf_license_start
*
* \page License
*
* Subject to your compliance with these terms, you may use Microchip
* software and any derivatives exclusively with Microchip products.
* It is your responsibility to comply with third party license terms applicable
* to your use of third party software (including open source software) that
* may accompany Microchip software.
*
* THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES,
* WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE,
* INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY,
* AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE
* LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL
* LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE
* SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE
* POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT
* ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY
* RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
* THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
*
* \asf_license_stop
*
*/
/*
* Support and FAQ: visit <a href="https://www.microchip.com/support/">Microchip Support</a>
*/
#ifndef _SAMG55_SPI7_INSTANCE_
#define _SAMG55_SPI7_INSTANCE_
/* ========== Register definition for SPI7 peripheral ========== */
#if (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__))
#define REG_SPI7_CR (0x40034400U) /**< \brief (SPI7) SPI Control Register */
#define REG_SPI7_MR (0x40034404U) /**< \brief (SPI7) SPI Mode Register */
#define REG_SPI7_RDR (0x40034408U) /**< \brief (SPI7) SPI Receive Data Register */
#define REG_SPI7_TDR (0x4003440CU) /**< \brief (SPI7) SPI Transmit Data Register */
#define REG_SPI7_SR (0x40034410U) /**< \brief (SPI7) SPI Status Register */
#define REG_SPI7_IER (0x40034414U) /**< \brief (SPI7) SPI Interrupt Enable Register */
#define REG_SPI7_IDR (0x40034418U) /**< \brief (SPI7) SPI Interrupt Disable Register */
#define REG_SPI7_IMR (0x4003441CU) /**< \brief (SPI7) SPI Interrupt Mask Register */
#define REG_SPI7_CSR (0x40034430U) /**< \brief (SPI7) SPI Chip Select Register */
#define REG_SPI7_CMPR (0x40034448U) /**< \brief (SPI7) SPI Comparison Register */
#define REG_SPI7_WPMR (0x400344E4U) /**< \brief (SPI7) SPI Write Protection Mode Register */
#define REG_SPI7_WPSR (0x400344E8U) /**< \brief (SPI7) SPI Write Protection Status Register */
#define REG_SPI7_RPR (0x40034500U) /**< \brief (SPI7) Receive Pointer Register */
#define REG_SPI7_RCR (0x40034504U) /**< \brief (SPI7) Receive Counter Register */
#define REG_SPI7_TPR (0x40034508U) /**< \brief (SPI7) Transmit Pointer Register */
#define REG_SPI7_TCR (0x4003450CU) /**< \brief (SPI7) Transmit Counter Register */
#define REG_SPI7_RNPR (0x40034510U) /**< \brief (SPI7) Receive Next Pointer Register */
#define REG_SPI7_RNCR (0x40034514U) /**< \brief (SPI7) Receive Next Counter Register */
#define REG_SPI7_TNPR (0x40034518U) /**< \brief (SPI7) Transmit Next Pointer Register */
#define REG_SPI7_TNCR (0x4003451CU) /**< \brief (SPI7) Transmit Next Counter Register */
#define REG_SPI7_PTCR (0x40034520U) /**< \brief (SPI7) Transfer Control Register */
#define REG_SPI7_PTSR (0x40034524U) /**< \brief (SPI7) Transfer Status Register */
#else
#define REG_SPI7_CR (*(__O uint32_t*)0x40034400U) /**< \brief (SPI7) SPI Control Register */
#define REG_SPI7_MR (*(__IO uint32_t*)0x40034404U) /**< \brief (SPI7) SPI Mode Register */
#define REG_SPI7_RDR (*(__I uint32_t*)0x40034408U) /**< \brief (SPI7) SPI Receive Data Register */
#define REG_SPI7_TDR (*(__O uint32_t*)0x4003440CU) /**< \brief (SPI7) SPI Transmit Data Register */
#define REG_SPI7_SR (*(__I uint32_t*)0x40034410U) /**< \brief (SPI7) SPI Status Register */
#define REG_SPI7_IER (*(__O uint32_t*)0x40034414U) /**< \brief (SPI7) SPI Interrupt Enable Register */
#define REG_SPI7_IDR (*(__O uint32_t*)0x40034418U) /**< \brief (SPI7) SPI Interrupt Disable Register */
#define REG_SPI7_IMR (*(__I uint32_t*)0x4003441CU) /**< \brief (SPI7) SPI Interrupt Mask Register */
#define REG_SPI7_CSR (*(__IO uint32_t*)0x40034430U) /**< \brief (SPI7) SPI Chip Select Register */
#define REG_SPI7_CMPR (*(__IO uint32_t*)0x40034448U) /**< \brief (SPI7) SPI Comparison Register */
#define REG_SPI7_WPMR (*(__IO uint32_t*)0x400344E4U) /**< \brief (SPI7) SPI Write Protection Mode Register */
#define REG_SPI7_WPSR (*(__I uint32_t*)0x400344E8U) /**< \brief (SPI7) SPI Write Protection Status Register */
#define REG_SPI7_RPR (*(__IO uint32_t*)0x40034500U) /**< \brief (SPI7) Receive Pointer Register */
#define REG_SPI7_RCR (*(__IO uint32_t*)0x40034504U) /**< \brief (SPI7) Receive Counter Register */
#define REG_SPI7_TPR (*(__IO uint32_t*)0x40034508U) /**< \brief (SPI7) Transmit Pointer Register */
#define REG_SPI7_TCR (*(__IO uint32_t*)0x4003450CU) /**< \brief (SPI7) Transmit Counter Register */
#define REG_SPI7_RNPR (*(__IO uint32_t*)0x40034510U) /**< \brief (SPI7) Receive Next Pointer Register */
#define REG_SPI7_RNCR (*(__IO uint32_t*)0x40034514U) /**< \brief (SPI7) Receive Next Counter Register */
#define REG_SPI7_TNPR (*(__IO uint32_t*)0x40034518U) /**< \brief (SPI7) Transmit Next Pointer Register */
#define REG_SPI7_TNCR (*(__IO uint32_t*)0x4003451CU) /**< \brief (SPI7) Transmit Next Counter Register */
#define REG_SPI7_PTCR (*(__O uint32_t*)0x40034520U) /**< \brief (SPI7) Transfer Control Register */
#define REG_SPI7_PTSR (*(__I uint32_t*)0x40034524U) /**< \brief (SPI7) Transfer Status Register */
#endif /* (defined(__ASSEMBLY__) || defined(__IAR_SYSTEMS_ASM__)) */
#endif /* _SAMG55_SPI7_INSTANCE_ */
| 71.181818 | 113 | 0.675128 |
676502dfa865f1a306262cbfee6e4df8b3ac5464 | 482 | h | C | Source/LookAndFeel/MLProgressBar.h | afofo/madronalib | 14816a124c8d3a225540ffb408e602aa024fdb4b | [
"MIT"
] | null | null | null | Source/LookAndFeel/MLProgressBar.h | afofo/madronalib | 14816a124c8d3a225540ffb408e602aa024fdb4b | [
"MIT"
] | null | null | null | Source/LookAndFeel/MLProgressBar.h | afofo/madronalib | 14816a124c8d3a225540ffb408e602aa024fdb4b | [
"MIT"
] | null | null | null |
// MadronaLib: a C++ framework for DSP applications.
// Copyright (c) 2013 Madrona Labs LLC. http://www.madronalabs.com
// Distributed under the MIT license: http://madrona-labs.mit-license.org/
#ifndef __ML_PROGRESS_BAR__
#define __ML_PROGRESS_BAR__
#include "MLUI.h"
#include "MLWidget.h"
class MLProgressBar :
public Component,
public MLWidget
{
public:
MLProgressBar();
~MLProgressBar();
protected:
void paint (Graphics& g);
};
#endif //__ML_PROGRESS_BAR__ | 20.083333 | 74 | 0.732365 |
733c54e5106503c917c0ce0b9187633b48a5bf4e | 2,053 | c | C | G.729/G729(LD-CELP)/global.c | goodspeed24e/2011Corel | 4efb585a589ea5587a877f4184493b758fa6f9b2 | [
"MIT"
] | 1 | 2019-07-24T07:59:07.000Z | 2019-07-24T07:59:07.000Z | G.729/G729(LD-CELP)/global.c | goodspeed24e/2011Corel | 4efb585a589ea5587a877f4184493b758fa6f9b2 | [
"MIT"
] | null | null | null | G.729/G729(LD-CELP)/global.c | goodspeed24e/2011Corel | 4efb585a589ea5587a877f4184493b758fa6f9b2 | [
"MIT"
] | 6 | 2015-03-17T12:11:38.000Z | 2022-01-29T01:15:52.000Z | /*************************************************************************/
/* */
/* LD-CELP G.728 */
/* */
/* Low-Delay Code Excitation Linear Prediction speech compression. */
/* */
/* Copyright: Analog Devices, Inc., 1993 */
/* */
/* Author: Alex Zatsman. */
/* */
/* This program was written mostly for testing Analog Devices' g21k C */
/* compiler for the ADSP21000 architecture family. While the program */
/* works on Sparc and ADSP21020, it has NOT been tested with the */
/* official test data from CCITT/ITU. */
/* */
/* The program is distributed as is, WITHOUT ANY WARRANTY, EITHER */
/* EXPLICIT OR IMPLIED. */
/* */
/*************************************************************************/
#include "common.h"
/*
This data is used by both encoder and decoder. We have to define it
once for cases when encoder and decoder are linked together (like ezplay).
*/
#include "common.h"
ATOMIC(sf_coeff, LPC+1, COEFF_MEM);
ATOMIC(gp_coeff, LPCLG+1, COEFF_MEM);
ATOMIC(pwf_z_coeff, LPCW+1, COEFF_MEM);
ATOMIC(pwf_p_coeff, LPCW+1, COEFF_MEM);
ATOMIC(shape_energy, NCWD, dm);
ATOMIC(imp_resp, IDIM, dm);
real synspeech [QSIZE]; /* Synthesized Speech */
real qspeech [QSIZE]; /* Quantized Speech */
real log_gains[QSIZE/IDIM]; /* Logarithm of Gains */
int VOLATILE ffase = -4;
| 48.880952 | 76 | 0.38529 |
21e1028bc5ae54abd855927443a47ccbd13269d0 | 193 | h | C | StRoot/StBichsel/StBichselLinkDef.h | xiaohaijin/RHIC-STAR | a305cb0a6ac15c8165bd8f0d074d7075d5e58752 | [
"MIT"
] | 2 | 2018-12-24T19:37:00.000Z | 2022-02-28T06:57:20.000Z | StRoot/StBichsel/StBichselLinkDef.h | xiaohaijin/RHIC-STAR | a305cb0a6ac15c8165bd8f0d074d7075d5e58752 | [
"MIT"
] | null | null | null | StRoot/StBichsel/StBichselLinkDef.h | xiaohaijin/RHIC-STAR | a305cb0a6ac15c8165bd8f0d074d7075d5e58752 | [
"MIT"
] | null | null | null | #ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ enum Bichsel::EParTypes;
#pragma link C++ class StdEdxModel;
#endif
| 24.125 | 41 | 0.761658 |
34bbb940033d0d179e937a2320021afb38dec6fc | 819 | h | C | Classes/UI/TCListView.h | stevestreza/technicolor | 55044f13b6616dc3cf8d5a921d748dd39e7eaf77 | [
"MIT"
] | 1 | 2016-05-08T14:43:56.000Z | 2016-05-08T14:43:56.000Z | Classes/UI/TCListView.h | stevestreza/technicolor | 55044f13b6616dc3cf8d5a921d748dd39e7eaf77 | [
"MIT"
] | null | null | null | Classes/UI/TCListView.h | stevestreza/technicolor | 55044f13b6616dc3cf8d5a921d748dd39e7eaf77 | [
"MIT"
] | null | null | null | //
// TCListView.h
// Technicolor
//
// Created by Steve Streza on 12/20/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface TCListView : NSView {
NSScrollView *mParentScrollView;
NSMutableArray *mRows;
NSUInteger selectedRow;
}
@property NSUInteger selectedRow;
@property (readonly) NSScrollView *scrollView;
-(void)addRow:(NSView *)row;
-(void)insertRow:(NSView *)row atIndex:(NSUInteger)index;
-(void)removeRowAtIndex:(NSUInteger)index;
-(void)removeAllRows;
-(NSRect)frameForRowAtIndex:(NSUInteger)index;
-(NSSize)totalContentSize;
-(NSUInteger)indexOfPoint:(NSPoint)pt;
-(NSIndexSet *)displayingRows;
-(void)drawGridInRect:(NSRect)theRect;
-(void)drawGridLineAtY:(float)y width:(float)width;
-(void)drawSelectedBackgroundInRect:(NSRect)rect;
@end
| 21 | 58 | 0.759463 |
422e1ac97c17481e10eae104543af5e3a1fd6b69 | 1,182 | c | C | annum_of_pwn/006/bof.c | 0xmanjoos/hackerman_hackertime | e447f5dc3ffc1041905190756dad221c7f42c92f | [
"MIT"
] | 9 | 2021-05-05T04:07:13.000Z | 2022-02-16T17:34:37.000Z | annum_of_pwn/006/bof.c | 0xmanjoos/hackerman_hackertime | e447f5dc3ffc1041905190756dad221c7f42c92f | [
"MIT"
] | null | null | null | annum_of_pwn/006/bof.c | 0xmanjoos/hackerman_hackertime | e447f5dc3ffc1041905190756dad221c7f42c92f | [
"MIT"
] | 2 | 2021-03-18T22:51:12.000Z | 2021-12-03T19:26:02.000Z | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
// -no-pie
// ASLR on ; NX on ; CANARY on
void id_index() {
long id[]={0};
int index;
printf("What index is your id?: ");
scanf("%d", &index);
printf("%p", id[index]);
}
void id_update() {
puts("Feature is under maintenence!");
}
void intro() {
int len;
char src[256];
printf("Enter length of your id (MAX : 256): ");
scanf("%d", &len);
printf("Enter your id: ");
read(0,src,len);
if (strlen(src)>len) {
puts("Too large!");
exit(1);
}
}
void menu() {
int op;
while(1) {
printf("[1] intro\n[2] get id\n[3] update id\nEnter: ");
scanf("%d", &op);
switch (op) {
case 1:
intro();
break;
case 2:
id_index();
break;
case 3:
id_update();
break;
}
}
}
int main() {
menu();
return 0;
}
__attribute__((constructor))
void setup() { // for remote binary, sockets will buffer output
setvbuf(stdout, NULL, _IONBF, 0);
setvbuf(stdin, NULL, _IONBF, 0);
}
| 21.107143 | 64 | 0.488156 |
5131e21e9e4b8581630854bbf3cc9dd4c573065a | 311 | h | C | Xor/src/ChickenLogic.h | thegouldfish/MegaXor | 343b354eabd9e8961331d4581aa7390c7776ff4a | [
"MIT"
] | 3 | 2019-05-22T16:17:21.000Z | 2020-04-05T17:22:02.000Z | Xor/src/ChickenLogic.h | thegouldfish/MegaXor | 343b354eabd9e8961331d4581aa7390c7776ff4a | [
"MIT"
] | null | null | null | Xor/src/ChickenLogic.h | thegouldfish/MegaXor | 343b354eabd9e8961331d4581aa7390c7776ff4a | [
"MIT"
] | null | null | null | #ifndef _CHICKEN_LOGIC_H_
#define _CHICKEN_LOGIC_H_
#include <genesis.h>
void ChickenMakeSprite();
void ChickenSetup();
u8 ChickenPushUp(u16 x, u16 y);
u8 ChickenPushDown(u16 x, u16 y);
u8 ChickenUpdateMovement();
u8 ChickenUpdateLogic();
void ChickenFinishMovement();
void KillChicken(u16 x, u16 y);
#endif | 19.4375 | 33 | 0.778135 |
fd647a04aedd1ccab08ac8590d8c9233acb9888e | 878 | h | C | VVCheckAppVersion/VVCheckAppVersion.h | Steve-001/VVCheckAppVersion | bb002bbff8b31c6f9cba3afceeb03b7b7a1ef8d9 | [
"MIT"
] | null | null | null | VVCheckAppVersion/VVCheckAppVersion.h | Steve-001/VVCheckAppVersion | bb002bbff8b31c6f9cba3afceeb03b7b7a1ef8d9 | [
"MIT"
] | null | null | null | VVCheckAppVersion/VVCheckAppVersion.h | Steve-001/VVCheckAppVersion | bb002bbff8b31c6f9cba3afceeb03b7b7a1ef8d9 | [
"MIT"
] | null | null | null | //
// VVCheckAppVersion.h
//
//
// Created by zhx on 2018/5/10.
// Copyright © 2018年 zhx. All rights reserved.
// app版本号检测,强制更新
#import <Foundation/Foundation.h>
@class HXAppInfoModel;
@interface VVCheckAppVersion : NSObject
+ (void)cheakAppVersion:(NSString *)appID;
+ (void)cheakAppVersion:(NSString *)appID completionHandler:(void (^) (HXAppInfoModel *appInfo))handler;
+ (BOOL)isShouldUpdateOnlineVersion:(NSString *)onlineVersion currentVersion:(NSString *)currentVersion;
+ (void)showUpdateAppVersionAlterViewWithTrackViewUrl:(NSString *)trackViewUrl showCancelAction:(BOOL)showCancelAction;
@end
@interface HXAppInfoModel : NSObject
@property (nonatomic , copy) NSString * currentVersion;
@property (nonatomic , copy) NSString * onlineVersion;
@property (nonatomic , copy) NSString * trackViewUrl;
@property (nonatomic , assign) BOOL hasNewVersion;
@end
| 25.823529 | 119 | 0.767654 |
0a224f18ed2c3f4836ff4dbd9f7aa3e70c899577 | 2,630 | h | C | Alexa_for_IoT-Intro/components/basic_recorder/basic_recorder.h | mongonta0716/Core2-for-AWS-IoT-EduKit | 1db10dae9de50d28bb9d4bc7b6aedd74016108a9 | [
"MIT"
] | 188 | 2019-01-11T09:59:29.000Z | 2022-03-26T08:46:00.000Z | Alexa_for_IoT-Intro/components/basic_recorder/basic_recorder.h | mongonta0716/Core2-for-AWS-IoT-EduKit | 1db10dae9de50d28bb9d4bc7b6aedd74016108a9 | [
"MIT"
] | 139 | 2019-01-13T07:59:27.000Z | 2022-03-12T05:33:58.000Z | Alexa_for_IoT-Intro/components/basic_recorder/basic_recorder.h | mongonta0716/Core2-for-AWS-IoT-EduKit | 1db10dae9de50d28bb9d4bc7b6aedd74016108a9 | [
"MIT"
] | 75 | 2019-01-16T22:17:03.000Z | 2022-03-20T05:17:33.000Z | // Copyright 2018 Espressif Systems (Shanghai) PTE LTD
// All rights reserved.
#pragma once
#include <audio_codec.h>
#include <abstract_rb.h>
/**
* @brief Basic recorder events.
*
* These events are received by `event_cb` registered by applications.
*/
typedef enum basic_recorder_event {
RECORDER_EVENT_STARTED,
RECORDER_EVENT_STOPPED,
RECORDER_EVENT_FAILED,
RECORDER_EVENT_DOWNLOAD_COMPLETE,
RECORDER_EVENT_FETCH_ANCHOR,
RECORDER_EVENT_MAX,
} basic_recorder_event_t;
/* Basic recorder handle */
typedef void *basic_recorder_handle_t;
typedef ssize_t (*read_func_cb_t)(void *read_cb_data, void *data, int len, unsigned int wait);
typedef ssize_t (*write_func_cb_t)(void *write_cb_data, void *data, int len, unsigned int wait);
typedef int (*event_func_cb_t)(void *event_cb_data, basic_recorder_event_t event);
/**
* @brief Basic recorder config structure.
*
* Application must send pointer to this.
*/
typedef struct basic_recorder_config {
void *data; /* Not used for now */
} basic_recorder_cfg_t;
/**
* @brief `basic_recorder_record` config
*
* Must be provided to `basic_recorder_record`
*/
typedef struct basic_recorder_record_config {
audio_codec_type_t encoder_type;
event_func_cb_t event_cb;
read_func_cb_t read_cb;
write_func_cb_t write_cb;
void *event_cb_data;
void *read_cb_data;
void *write_cb_data;
} basic_recorder_record_config_t;
/**
* @brief Create a new instance of basic recorder.
*/
basic_recorder_handle_t basic_recorder_create(basic_recorder_cfg_t *basic_recorder_cfg);
/**
* @brief Add an initialized instance of codec to basic_recorder.
*
* Codec instance must be created by application.
*/
esp_err_t basic_recorder_add_codec(basic_recorder_handle_t handle, audio_codec_type_t type, audio_codec_t *base);
/**
* @brief Remove a codec instance from basic recorder.
*
* The codec must be destroyed by application.
*/
esp_err_t basic_recorder_remove_codec(basic_recorder_handle_t handle, audio_codec_type_t type);
/**
* @brief Start basic recorder with given record config.
*
* @note If recorder is already running, it will be stopped and will start with provided config.
*/
esp_err_t basic_recorder_record(basic_recorder_handle_t handle, basic_recorder_record_config_t *record_config);
/**
* @brief Trigger basic recorder stop.
*/
esp_err_t basic_recorder_stop(basic_recorder_handle_t handle);
/**
* @brief Destroy the recorder.
*
* All the structures of basic recorder will be cleaned up and then handle will be freed. Making it unusable.
*/
void basic_recorder_destroy(basic_recorder_handle_t handle);
| 27.978723 | 113 | 0.771103 |
74edeccc30e44be3bb7403aa2172387c04eae855 | 719 | h | C | src/mainwindow.h | JanSimek/GECKed | d25e5dac2b6a8c086c39e1a846fa21ec01b69505 | [
"MIT"
] | 1 | 2021-07-29T03:09:28.000Z | 2021-07-29T03:09:28.000Z | src/mainwindow.h | JanSimek/GECKed | d25e5dac2b6a8c086c39e1a846fa21ec01b69505 | [
"MIT"
] | null | null | null | src/mainwindow.h | JanSimek/GECKed | d25e5dac2b6a8c086c39e1a846fa21ec01b69505 | [
"MIT"
] | null | null | null | #ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QStandardItemModel>
#include "src/Format/Dat/File.h"
using namespace Falltergeist::Format;
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void on_actionExit_triggered();
void on_actionOpen_triggered();
void on_treeView_clicked(const QModelIndex &index);
private:
Ui::MainWindow *ui;
QStandardItemModel *fileTreeModel;
Dat::File *file;
void appendPath(QAbstractItemModel *const model, QStringList &fileParts,
const QModelIndex &parent = QModelIndex());
};
#endif // MAINWINDOW_H
| 18.921053 | 74 | 0.742698 |
1f5a450c79f3013422f3feafef9c42d4b4d76ac7 | 1,543 | h | C | poppler-21.11.0/qt6/src/poppler-qiodeviceinstream-private.h | stackoverflowed/multimodal | 95668d0b34d297e96b5ef76521e587578ef2581f | [
"MIT"
] | null | null | null | poppler-21.11.0/qt6/src/poppler-qiodeviceinstream-private.h | stackoverflowed/multimodal | 95668d0b34d297e96b5ef76521e587578ef2581f | [
"MIT"
] | null | null | null | poppler-21.11.0/qt6/src/poppler-qiodeviceinstream-private.h | stackoverflowed/multimodal | 95668d0b34d297e96b5ef76521e587578ef2581f | [
"MIT"
] | null | null | null | /* poppler-qiodeviceinstream-private.h: Qt6 interface to poppler
* Copyright (C) 2019 Alexander Volkov <a.volkov@rusbitech.ru>
*
* 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, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef POPPLER_QIODEVICEINSTREAM_PRIVATE_H
#define POPPLER_QIODEVICEINSTREAM_PRIVATE_H
#include "Object.h"
#include "Stream.h"
class QIODevice;
namespace Poppler {
class QIODeviceInStream : public BaseSeekInputStream
{
public:
QIODeviceInStream(QIODevice *device, Goffset startA, bool limitedA, Goffset lengthA, Object &&dictA);
~QIODeviceInStream() override;
BaseStream *copy() override;
Stream *makeSubStream(Goffset startA, bool limitedA, Goffset lengthA, Object &&dictA) override;
private:
Goffset currentPos() const override;
void setCurrentPos(Goffset offset) override;
Goffset read(char *buffer, Goffset count) override;
QIODevice *m_device;
};
}
#endif
| 31.489796 | 105 | 0.756967 |
ea2943070553bec879ef6df175340dcaa5a6ad5d | 2,640 | h | C | Algorithm/cloth/graph/AbstractGraphObject.h | dolphin-li/ClothDesigner | 82b186d6db320b645ac67a4d32d7746cc9bdd391 | [
"MIT"
] | 32 | 2016-12-13T05:49:12.000Z | 2022-02-04T06:15:47.000Z | Algorithm/cloth/graph/AbstractGraphObject.h | dolphin-li/ClothDesigner | 82b186d6db320b645ac67a4d32d7746cc9bdd391 | [
"MIT"
] | 2 | 2019-07-30T02:01:16.000Z | 2020-03-12T15:06:51.000Z | Algorithm/cloth/graph/AbstractGraphObject.h | dolphin-li/ClothDesigner | 82b186d6db320b645ac67a4d32d7746cc9bdd391 | [
"MIT"
] | 18 | 2017-11-16T13:37:06.000Z | 2022-03-11T08:13:46.000Z | #pragma once
#include <string>
#include <hash_map>
#include <hash_set>
#include <memory>
class TiXmlElement;
class TiXmlNode;
namespace ldp
{
// NOT THREAD SAFE
class AbstractGraphObject
{
public:
enum Type
{
TypeGraphPoint,
TypeGraphLine,
TypeGraphQuadratic,
TypeGraphCubic,
TypeGraphLoop,
TypeGraph,
TypeGraphsSewing,
Type_End
};
enum SelectOp
{
SelectThis,
SelectUnion,
SelectUnionInverse,
SelectAll,
SelectNone,
SelectInverse,
SelectEnd
};
typedef std::hash_map<size_t, AbstractGraphObject*> IdxObjMap;
typedef std::hash_map<Type, std::string> TypeStringMap;
typedef std::hash_set<size_t> IdxSet;
public:
AbstractGraphObject();
virtual ~AbstractGraphObject();
virtual AbstractGraphObject* clone()const;
virtual Type getType()const = 0;
virtual TiXmlElement* toXML(TiXmlNode* parent)const;
virtual void fromXML(TiXmlElement* self);
static AbstractGraphObject* create(Type type);
static AbstractGraphObject* create(std::string typeString);
std::string getTypeString()const;
size_t getId()const { return m_id; }
bool isSelected()const { return m_selected; }
void setSelected(bool s) { m_selected = s; }
bool isHighlighted()const { return m_highlighted; }
void setHighlighted(bool h) { m_highlighted = h; }
static AbstractGraphObject* getObjByIdx(size_t id)
{
auto iter = s_idxObjMap.find(id);
if (iter == s_idxObjMap.end())
return nullptr;
return iter->second;
}
bool isCurve()const { return getType() == TypeGraphCubic
|| getType() == TypeGraphLine || getType() == TypeGraphQuadratic; }
bool operator <(const AbstractGraphObject& rhs)const { return m_id < rhs.m_id; }
protected:
virtual AbstractGraphObject& operator = (const AbstractGraphObject& rhs) = delete;
AbstractGraphObject(const AbstractGraphObject& rhs) = delete;
void requireIdx();
void freeIdx();
private:
size_t m_id = 0;
bool m_selected = false;
bool m_highlighted = false;
public:
int m_flag = 0; // for others to tmporary usage
private:
static IdxObjMap s_idxObjMap;
static IdxSet s_freeIdx;
static size_t s_nextIdx;
static TypeStringMap s_typeStringMap;
static TypeStringMap generateTypeStringMap();
protected:
// for tmp idx maping when loading from files.
static IdxObjMap s_idxObjMap_loading;
size_t m_loadedId = 0;
protected:
static AbstractGraphObject* getObjByIdx_loading(size_t id)
{
auto iter = s_idxObjMap_loading.find(id);
if (iter == s_idxObjMap_loading.end())
return nullptr;
return iter->second;
}
};
typedef std::shared_ptr<AbstractGraphObject> AbstractGraphObjectPtr;
} | 26.666667 | 84 | 0.732197 |
5a111b00fb236582d913d631a1c8f4dcf1759f35 | 1,137 | h | C | TypedEngine/src/Input/InputManager.h | edovino/TypedEngine | 734c923ea28d541e05d9a73684bbbf2cbfb940d1 | [
"MIT"
] | null | null | null | TypedEngine/src/Input/InputManager.h | edovino/TypedEngine | 734c923ea28d541e05d9a73684bbbf2cbfb940d1 | [
"MIT"
] | 1 | 2020-05-06T21:36:36.000Z | 2020-05-06T21:36:36.000Z | TypedEngine/src/Input/InputManager.h | edovino/TypedEngine | 734c923ea28d541e05d9a73684bbbf2cbfb940d1 | [
"MIT"
] | 1 | 2020-05-01T17:16:46.000Z | 2020-05-01T17:16:46.000Z | #pragma once
enum class Key {
NONE,
A,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
L,
M,
N,
O,
P,
Q,
R,
S,
T,
U,
V,
W,
X,
Y,
Z,
SPACE,
APOSTROPHE,
COMMA,
MINUS,
PERIOD,
SLASH,
ZERO,
ONE,
TWO,
THREE,
FOUR,
FIVE,
SIX,
SEVEN,
EIGHT,
NINE,
SEMICOLON,
EQUAL,
LEFT_BRACKET,
RIGHT_BRACKET,
BACKSLASH,
GRAVE,
ESCAPE,
ENTER,
TAB,
BACKSPACE,
INSERT,
DELETE,
RIGHT,
LEFT,
DOWN,
UP,
PAGE_UP,
PAGE_DOWN,
HOME,
END,
CAPS_LOCK,
SCROLL_LOCK,
SHIFT
};
enum class MouseButton {
NONE,
ONE,
TWO,
MIDDLE
};
enum class Modifier {
NONE,
SHIFT,
CONTROL,
ALT,
};
class InputManager {
public:
virtual int convertKeyToValue(Key key, Modifier mod) = 0;
virtual int convertModifierToValue(Modifier mod) = 0;
virtual int convertMouseButtonToValue(MouseButton button) = 0;
virtual Key convertValueToKey(int value) = 0;
virtual Modifier convertValueToModifier(int value) = 0;
virtual MouseButton convertValueToMouseButton(int value) = 0;
};
| 11.84375 | 64 | 0.57168 |
738d045ea341796d0618c5ad21df47e2d5e8b87f | 541 | h | C | FocusManager/WindowsHandle.h | oneflyingfish/FocusManager | e9caa9b456aac31a3d6f097dddf35652b1d9b286 | [
"Apache-2.0"
] | 4 | 2021-04-11T03:19:29.000Z | 2022-01-17T05:30:16.000Z | FocusManager/WindowsHandle.h | oneflyingfish/FocusManager | e9caa9b456aac31a3d6f097dddf35652b1d9b286 | [
"Apache-2.0"
] | null | null | null | FocusManager/WindowsHandle.h | oneflyingfish/FocusManager | e9caa9b456aac31a3d6f097dddf35652b1d9b286 | [
"Apache-2.0"
] | null | null | null | #ifndef WINDOWSHANDLE_H
#define WINDOWSHANDLE_H
// 以下为win32 API库,不支持跨平台,"User32.dll"
#include"windows.h"
#include"winuser.h"
#include"TChar.h"
#include"psapi.h"
#include"HandleInfo.h"
#include"errhandlingapi.h"
class WindowsHandle
{
public:
static HandleInfo getCurrentSystemFocus(); // 获取当前焦点信息
static HandleInfo getHandleInfoFromHWND(HWND handle);
static void setHandleFocus(HandleInfo handle); // 使某个handle获取焦点
static bool setHandleMouseLocation(HandleInfo handleInfo); // 使鼠标自动定位到焦点处
};
#endif
| 24.590909 | 78 | 0.743068 |
34d6f3b8dc4698d6084012cf5a9b4f991cd7b206 | 1,441 | h | C | hnswlib/types.h | generall/hnswlib | e54e865b246fb97a9a1b865308124e0b547a102c | [
"Apache-2.0"
] | 10 | 2020-02-10T07:47:30.000Z | 2021-06-08T05:49:54.000Z | hnswlib/types.h | generall/hnswlib | e54e865b246fb97a9a1b865308124e0b547a102c | [
"Apache-2.0"
] | 1 | 2022-01-24T07:54:49.000Z | 2022-01-24T07:54:49.000Z | hnswlib/types.h | generall/hnswlib | e54e865b246fb97a9a1b865308124e0b547a102c | [
"Apache-2.0"
] | 3 | 2021-10-21T10:01:22.000Z | 2022-01-28T18:06:08.000Z | #pragma once
#include <fstream>
namespace hnswlib
{
typedef unsigned int tableint;
typedef size_t labeltype;
typedef size_t tagtype;
typedef std::unordered_set<tagtype> tagcontainer;
typedef std::vector<tableint> linkcontainer;
typedef std::vector<linkcontainer> layercontainer;
/**
* Used for defining conditions.
*
* (A | !B) & C -> [[(0, A), (1, B)], [(0, C)]]
*/
typedef std::pair<bool, tagtype> negable_tag_t;
typedef std::vector<negable_tag_t> or_condition_t;
typedef std::vector<or_condition_t> condition_t;
template <typename T>
static void writeBinaryPOD(std::ostream &out, const T &podRef)
{
out.write((char *)&podRef, sizeof(T));
}
template <typename T>
static void readBinaryPOD(std::istream &in, T &podRef)
{
in.read((char *)&podRef, sizeof(T));
}
template <typename T1, typename T2>
static void writeMap(std::ostream &out, const std::unordered_map<T1, T2> &podRef)
{
writeBinaryPOD(out, podRef.size());
for(const auto &pair : podRef) {
writeBinaryPOD(out, pair.first);
writeBinaryPOD(out, pair.second);
}
}
template <typename T1, typename T2>
static void readMap(std::istream &in, std::unordered_map<T1, T2> &podRef)
{
size_t size = 0;
readBinaryPOD(in, size);
for (size_t i = 0; i < size ; i++) {
T1 key;
T2 value;
readBinaryPOD(in, key);
readBinaryPOD(in, value);
podRef[key] = value;
}
}
} // namespace hnswlib | 23.241935 | 81 | 0.666898 |
34dac38d8b0573ceaf2f1a265c57f8aa908bc3fe | 789 | c | C | demos/projects/ESPRESSIF/aziotkit/components/azure-iot-kit-sensors/src/sensors/led.c | IPlayZed/iot-middleware-freertos-samples | bcfbaab143e5ece442b5d0d45712f2f681c3b237 | [
"MIT"
] | 18 | 2021-04-27T00:58:22.000Z | 2022-03-16T15:49:33.000Z | demos/projects/ESPRESSIF/aziotkit/components/azure-iot-kit-sensors/src/sensors/led.c | IPlayZed/iot-middleware-freertos-samples | bcfbaab143e5ece442b5d0d45712f2f681c3b237 | [
"MIT"
] | 48 | 2021-06-08T21:39:32.000Z | 2022-03-31T10:16:49.000Z | demos/projects/ESPRESSIF/aziotkit/components/azure-iot-kit-sensors/src/sensors/led.c | IPlayZed/iot-middleware-freertos-samples | bcfbaab143e5ece442b5d0d45712f2f681c3b237 | [
"MIT"
] | 17 | 2021-06-07T17:45:28.000Z | 2022-03-30T21:50:45.000Z | /* Copyright (c) Microsoft Corporation.
Licensed under the MIT License. */
#include "led.h"
#include "hal/gpio_types.h"
#include "driver/gpio.h"
#include "esp32/rom/gpio.h"
void initialize_leds()
{
gpio_pad_select_gpio(LED_GPIO_AZURE);
/* Set the GPIO as a push/pull output */
gpio_set_direction(LED_GPIO_AZURE, GPIO_MODE_OUTPUT);
gpio_pad_select_gpio(LED_GPIO_WIFI);
/* Set the GPIO as a push/pull output */
gpio_set_direction(LED_GPIO_WIFI, GPIO_MODE_OUTPUT);
}
void toggle_azure_led(uint32_t level)
{
/* LED on (output high) */
/* LED off (output low) */
gpio_set_level(LED_GPIO_AZURE, level);
}
void toggle_wifi_led(uint32_t level)
{
/* LED on (output high) */
/* LED off (output low) */
gpio_set_level(LED_GPIO_WIFI, level);
}
| 23.909091 | 57 | 0.698352 |
390e30a71ad4d10be3bde697398c75874383a451 | 12,782 | h | C | ZeroPoint6/include/Core/Vector.h | zero0/zp6 | 5410c68671c9bbffc0d72564b7ee285f20aa5c00 | [
"MIT"
] | null | null | null | ZeroPoint6/include/Core/Vector.h | zero0/zp6 | 5410c68671c9bbffc0d72564b7ee285f20aa5c00 | [
"MIT"
] | null | null | null | ZeroPoint6/include/Core/Vector.h | zero0/zp6 | 5410c68671c9bbffc0d72564b7ee285f20aa5c00 | [
"MIT"
] | null | null | null | //
// Created by phosg on 1/25/2022.
//
#ifndef ZP_VECTOR_H
#define ZP_VECTOR_H
#include "Core/Types.h"
#include "Core/Common.h"
#include "Core/Allocator.h"
namespace zp
{
template<MemoryLabel MemLabel, zp_size_t Alignment = kDefaultMemoryAlignment>
struct TypedMemoryLabelAllocator
{
void* allocate( zp_size_t size ) const
{
void* ptr = GetAllocator( MemLabel )->allocate( size, Alignment );
return ptr;
}
void free( void* ptr ) const
{
GetAllocator( MemLabel )->free( ptr );
}
};
template<typename T, typename Allocator = MemoryLabelAllocator>
class Vector
{
public:
static const zp_size_t npos = -1;
typedef T value_type;
typedef T& reference;
typedef const T& const_reference;
typedef T* pointer;
typedef const T* const_pointer;
typedef T* iterator;
typedef const T* const_iterator;
typedef Allocator allocator_value;
typedef const allocator_value& allocator_const_reference;
Vector();
explicit Vector( allocator_const_reference allocator );
explicit Vector( zp_size_t capacity );
Vector( zp_size_t capacity, allocator_const_reference allocator );
~Vector();
reference operator[]( zp_size_t index );
const_reference operator[]( zp_size_t index ) const;
const_reference at( zp_size_t index ) const;
zp_size_t size() const;
zp_bool_t isEmpty() const;
zp_bool_t isFixed() const;
void pushBack( const_reference val );
reference pushBackEmpty();
void pushFront( const_reference val );
reference pushFrontEmpty();
void popBack();
void popFront();
void eraseAt( zp_size_t index );
void eraseAtSwapBack( zp_size_t index );
zp_bool_t erase( const_reference val );
zp_bool_t eraseSwapBack( const_reference val );
zp_size_t eraseAll( const_reference val );
void clear();
void reset();
void resize_unsafe( zp_size_t size );
void reserve( zp_size_t size );
void destroy();
zp_size_t indexOf( const_reference val ) const;
zp_size_t lastIndexOf( const_reference val ) const;
pointer data();
const_pointer data() const;
T& front();
T& back();
const_reference front() const;
const_reference back() const;
iterator begin();
iterator end();
const_iterator begin() const;
const_iterator end() const;
private:
void ensureCapacity( zp_size_t capacity );
pointer m_data;
zp_size_t m_size;
zp_size_t m_capacity;
allocator_value m_allocator;
};
};
//
// Impl
//
namespace zp
{
template<typename T, typename Allocator>
Vector<T, Allocator>::Vector()
: m_data( nullptr )
, m_size( 0 )
, m_capacity( 0 )
, m_allocator( allocator_value())
{
}
template<typename T, typename Allocator>
Vector<T, Allocator>::Vector( allocator_const_reference allocator )
: m_data( nullptr )
, m_size( 0 )
, m_capacity( 0 )
, m_allocator( allocator )
{
}
template<typename T, typename Allocator>
Vector<T, Allocator>::Vector( zp_size_t capacity )
: m_data( nullptr )
, m_size( 0 )
, m_capacity( 0 )
, m_allocator( allocator_value())
{
ensureCapacity( capacity );
}
template<typename T, typename Allocator>
Vector<T, Allocator>::Vector( zp_size_t capacity, allocator_const_reference allocator )
: m_data( nullptr )
, m_size( 0 )
, m_capacity( 0 )
, m_allocator( allocator )
{
ensureCapacity( capacity );
}
template<typename T, typename Allocator>
Vector<T, Allocator>::~Vector()
{
destroy();
}
template<typename T, typename Allocator>
typename Vector<T, Allocator>::reference Vector<T, Allocator>::operator[]( zp_size_t index )
{
return m_data[ index ];
}
template<typename T, typename Allocator>
typename Vector<T, Allocator>::const_reference Vector<T, Allocator>::operator[]( zp_size_t index ) const
{
return m_data[ index ];
}
template<typename T, typename Allocator>
typename Vector<T, Allocator>::const_reference Vector<T, Allocator>::at( zp_size_t index ) const
{
return m_data[ index ];
}
template<typename T, typename Allocator>
zp_size_t Vector<T, Allocator>::size() const
{
return m_size;
}
template<typename T, typename Allocator>
zp_bool_t Vector<T, Allocator>::isEmpty() const
{
return m_size == 0;
}
template<typename T, typename Allocator>
zp_bool_t Vector<T, Allocator>::isFixed() const
{
return m_allocator.isFixed();
}
template<typename T, typename Allocator>
void Vector<T, Allocator>::pushBack( const_reference val )
{
if( m_size == m_capacity )
{
ensureCapacity( m_capacity * 2 );
}
m_data[ m_size++ ] = val;
}
template<typename T, typename Allocator>
typename Vector<T, Allocator>::reference Vector<T, Allocator>::pushBackEmpty()
{
if( m_size == m_capacity )
{
ensureCapacity( m_capacity * 2 );
}
new( m_data + m_size ) T();
return m_data[ m_size++ ];
}
template<typename T, typename Allocator>
void Vector<T, Allocator>::pushFront( const_reference val )
{
if( m_size == m_capacity )
{
ensureCapacity( m_capacity * 2 );
}
for( zp_size_t i = m_size + 1; i >= 1; --i )
{
m_data[ i ] = zp_move( m_data[ i - 1 ] );
}
++m_size;
m_data[ 0 ] = val;
}
template<typename T, typename Allocator>
typename Vector<T, Allocator>::reference Vector<T, Allocator>::pushFrontEmpty()
{
if( m_size == m_capacity )
{
ensureCapacity( m_capacity * 2 );
}
for( zp_size_t i = m_size + 1; i >= 1; --i )
{
m_data[ i ] = zp_move( m_data[ i - 1 ] );
}
++m_size;
new( m_data ) T();
return m_data[ 0 ];
}
template<typename T, typename Allocator>
void Vector<T, Allocator>::popBack()
{
if( m_size )
{
(m_data + --m_size)->~T();
}
}
template<typename T, typename Allocator>
void Vector<T, Allocator>::popFront()
{
if( m_size )
{
m_data->~T();
for( zp_size_t i = 1; i < m_size; ++i )
{
m_data[ i - 1 ] = zp_move( m_data[ i ] );
}
--m_size;
}
}
template<typename T, typename Allocator>
void Vector<T, Allocator>::eraseAt( zp_size_t index )
{
(m_data + index)->~T();
for( zp_size_t i = index + 1; i < m_size; ++i )
{
m_data[ i - 1 ] = zp_move( m_data[ i ] );
}
--m_size;
}
template<typename T, typename Allocator>
void Vector<T, Allocator>::eraseAtSwapBack( zp_size_t index )
{
(m_data + index)->~T();
m_data[ index ] = zp_move( m_data[ m_size - 1 ] );
--m_size;
}
template<typename T, typename Allocator>
zp_bool_t Vector<T, Allocator>::erase( const_reference val )
{
zp_size_t index = indexOf( val );
zp_bool_t found = index != npos;
if( found )
{
eraseAt( index );
}
return found;
}
template<typename T, typename Allocator>
zp_bool_t Vector<T, Allocator>::eraseSwapBack( const_reference val )
{
zp_size_t index = indexOf( val );
zp_bool_t found = index != npos;
if( found )
{
eraseAtSwapBack( index );
}
return found;
}
template<typename T, typename Allocator>
zp_size_t Vector<T, Allocator>::eraseAll( const_reference val )
{
zp_size_t numErased = 0;
for( zp_size_t i = 0; i < m_size; ++i )
{
T* t = m_data + i;
if( *t == val )
{
++numErased;
t->~T();
m_data[ i ] = zp_move( m_data[ m_size - 1 ] );
--m_size;
--i;
}
}
return numErased;
}
template<typename T, typename Allocator>
void Vector<T, Allocator>::clear()
{
iterator b = m_data;
iterator e = m_data + m_size;
for( ; b != e; ++b )
{
b->~T();
}
m_size = 0;
}
template<typename T, typename Allocator>
void Vector<T, Allocator>::reset()
{
m_size = 0;
}
template<typename T, typename Allocator>
void Vector<T, Allocator>::resize_unsafe( zp_size_t size )
{
ZP_ASSERT( size <= m_capacity );
m_size = size;
}
template<typename T, typename Allocator>
void Vector<T, Allocator>::reserve( zp_size_t size )
{
if( size > m_capacity )
{
ensureCapacity( size );
}
}
template<typename T, typename Allocator>
void Vector<T, Allocator>::destroy()
{
clear();
if( m_data )
{
m_allocator.free( m_data );
m_data = nullptr;
}
m_capacity = 0;
}
template<typename T, typename Allocator>
zp_size_t Vector<T, Allocator>::indexOf( const_reference val ) const
{
zp_size_t index = npos;
const_iterator b = m_data;
const_iterator e = m_data + m_size;
for( ; b != e; ++b )
{
if( *b == val )
{
index = b - m_data;
break;
}
}
return index;
}
template<typename T, typename Allocator>
zp_size_t Vector<T, Allocator>::lastIndexOf( const_reference val ) const
{
zp_size_t index = npos;
const_iterator b = m_data;
const_iterator e = m_data + m_size;
for( ; b != e; )
{
--e;
if( *e == val )
{
index = e - m_data;
break;
}
}
return index;
}
template<typename T, typename Allocator>
typename Vector<T, Allocator>::pointer Vector<T, Allocator>::data()
{
return m_data;
}
template<typename T, typename Allocator>
typename Vector<T, Allocator>::const_pointer Vector<T, Allocator>::data() const
{
return m_data;
}
template<typename T, typename Allocator>
typename Vector<T, Allocator>::reference Vector<T, Allocator>::front()
{
return m_data[ 0 ];
}
template<typename T, typename Allocator>
typename Vector<T, Allocator>::reference Vector<T, Allocator>::back()
{
return m_data[ m_size - 1 ];
}
template<typename T, typename Allocator>
typename Vector<T, Allocator>::const_reference Vector<T, Allocator>::front() const
{
return m_data[ 0 ];
}
template<typename T, typename Allocator>
typename Vector<T, Allocator>::const_reference Vector<T, Allocator>::back() const
{
return m_data[ m_size - 1 ];
}
template<typename T, typename Allocator>
typename Vector<T, Allocator>::iterator Vector<T, Allocator>::begin()
{
return m_data;
}
template<typename T, typename Allocator>
typename Vector<T, Allocator>::iterator Vector<T, Allocator>::end()
{
return m_data + m_size;
}
template<typename T, typename Allocator>
typename Vector<T, Allocator>::const_iterator Vector<T, Allocator>::begin() const
{
return m_data;
}
template<typename T, typename Allocator>
typename Vector<T, Allocator>::const_iterator Vector<T, Allocator>::end() const
{
return m_data + m_size;
}
template<typename T, typename Allocator>
void Vector<T, Allocator>::ensureCapacity( zp_size_t capacity )
{
capacity = capacity < 4 ? 4 : capacity;
pointer newArray = static_cast<pointer>( m_allocator.allocate( sizeof( T ) * capacity ));
zp_zero_memory_array( newArray, capacity );
if( m_data != nullptr )
{
for( zp_size_t i = 0; i != m_size; ++i )
{
newArray[ i ] = zp_move( m_data[ i ] );
}
m_allocator.free( m_data );
m_data = nullptr;
}
m_data = newArray;
m_capacity = capacity;
}
};
#endif //ZP_VECTOR_H
| 23.197822 | 108 | 0.555703 |
821e0cfeeb483bb04c7b64ea98bc60a8f8805fc3 | 4,714 | h | C | fpsgame/gui/external_libraries/powrprof.h | mrlitong/CPP-Game-engine-usage | 95697c4bfb507cfb38dbe0f632740e2a7eac71fb | [
"MIT"
] | 186 | 2017-07-26T12:53:29.000Z | 2021-09-10T04:00:39.000Z | fpsgame/gui/external_libraries/powrprof.h | mrlitong/CPP-Game-engine-usage | 95697c4bfb507cfb38dbe0f632740e2a7eac71fb | [
"MIT"
] | 1 | 2017-08-15T13:12:27.000Z | 2017-08-16T06:14:57.000Z | fpsgame/gui/external_libraries/powrprof.h | mrlitong/CPP-Game-engine-usage | 95697c4bfb507cfb38dbe0f632740e2a7eac71fb | [
"MIT"
] | 6 | 2017-02-15T10:19:26.000Z | 2017-03-15T03:17:15.000Z | /* Copyright (c) 2010 Wildfire Games
*
* 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.
*/
/*
* bring in powrprof library.
*/
#ifndef INCLUDED_POWRPROF
#define INCLUDED_POWRPROF
#include "lib/sysdep/os/win/win.h"
#include <powrprof.h>
// the VC7 headers are missing some parts:
// MinGW headers are already correct; only change on VC
#if MSC_VERSION && MSC_VERSION < 1400
#ifndef NTSTATUS
#define NTSTATUS long
#endif
#ifndef STATUS_SUCCESS
#define STATUS_SUCCESS 0
#endif
#if WINVER < 0x500
typedef enum {
SystemPowerPolicyAc,
SystemPowerPolicyDc,
VerifySystemPolicyAc,
VerifySystemPolicyDc,
SystemPowerCapabilities,
SystemBatteryState,
SystemPowerStateHandler,
ProcessorStateHandler,
SystemPowerPolicyCurrent,
AdministratorPowerPolicy,
SystemReserveHiberFile,
ProcessorInformation,
SystemPowerInformation,
ProcessorStateHandler2,
LastWakeTime, // Compare with KeQueryInterruptTime()
LastSleepTime, // Compare with KeQueryInterruptTime()
SystemExecutionState,
SystemPowerStateNotifyHandler,
ProcessorPowerPolicyAc,
ProcessorPowerPolicyDc,
VerifyProcessorPowerPolicyAc,
VerifyProcessorPowerPolicyDc,
ProcessorPowerPolicyCurrent,
SystemPowerStateLogging,
SystemPowerLoggingEntry
} POWER_INFORMATION_LEVEL;
typedef struct {
DWORD Granularity;
DWORD Capacity;
} BATTERY_REPORTING_SCALE, *PBATTERY_REPORTING_SCALE;
typedef enum _SYSTEM_POWER_STATE {
PowerSystemUnspecified = 0,
PowerSystemWorking = 1,
PowerSystemSleeping1 = 2,
PowerSystemSleeping2 = 3,
PowerSystemSleeping3 = 4,
PowerSystemHibernate = 5,
PowerSystemShutdown = 6,
PowerSystemMaximum = 7
} SYSTEM_POWER_STATE, *PSYSTEM_POWER_STATE;
typedef struct {
// Misc supported system features
BOOLEAN PowerButtonPresent;
BOOLEAN SleepButtonPresent;
BOOLEAN LidPresent;
BOOLEAN SystemS1;
BOOLEAN SystemS2;
BOOLEAN SystemS3;
BOOLEAN SystemS4; // hibernate
BOOLEAN SystemS5; // off
BOOLEAN HiberFilePresent;
BOOLEAN FullWake;
BOOLEAN VideoDimPresent;
BOOLEAN ApmPresent;
BOOLEAN UpsPresent;
// Processors
BOOLEAN ThermalControl;
BOOLEAN ProcessorThrottle;
BYTE ProcessorMinThrottle;
BYTE ProcessorMaxThrottle;
BYTE spare2[4];
// Disk
BOOLEAN DiskSpinDown;
BYTE spare3[8];
// System Battery
BOOLEAN SystemBatteriesPresent;
BOOLEAN BatteriesAreShortTerm;
BATTERY_REPORTING_SCALE BatteryScale[3];
// Wake
SYSTEM_POWER_STATE AcOnLineWake;
SYSTEM_POWER_STATE SoftLidWake;
SYSTEM_POWER_STATE RtcWake;
SYSTEM_POWER_STATE MinDeviceWakeState; // note this may change on driver load
SYSTEM_POWER_STATE DefaultLowLatencyWake;
} SYSTEM_POWER_CAPABILITIES, *PSYSTEM_POWER_CAPABILITIES;
#endif // WINVER < 0x500
typedef struct _SYSTEM_POWER_INFORMATION
{
ULONG MaxIdlenessAllowed;
ULONG Idleness;
ULONG TimeRemaining;
UCHAR CoolingMode;
} SYSTEM_POWER_INFORMATION, *PSYSTEM_POWER_INFORMATION;
// SPI.CoolingMode
#define PO_TZ_INVALID_MODE 0 // The system does not support CPU throttling,
// or there is no thermal zone defined [..]
#endif // #if MSC_VERSION
// neither VC7.1 nor MinGW define this
typedef struct _PROCESSOR_POWER_INFORMATION
{
ULONG Number;
ULONG MaxMhz;
ULONG CurrentMhz;
ULONG MhzLimit;
ULONG MaxIdleState;
ULONG CurrentIdleState;
} PROCESSOR_POWER_INFORMATION, *PPROCESSOR_POWER_INFORMATION;
#endif // #ifndef INCLUDED_POWRPROF
| 29.279503 | 87 | 0.730378 |
822d552672a286ab14d496c9a38a10fb3ca98635 | 2,390 | h | C | elenasrc2/elenagm/win32/directx12.h | drkameleon/elena-lang | 8585e93a3bc0b19f8d60029ffbe01311d0b711a3 | [
"MIT"
] | 193 | 2015-07-03T22:23:27.000Z | 2022-03-15T18:56:02.000Z | elenasrc2/elenagm/win32/directx12.h | drkameleon/elena-lang | 8585e93a3bc0b19f8d60029ffbe01311d0b711a3 | [
"MIT"
] | 531 | 2015-05-07T09:39:42.000Z | 2021-09-27T07:51:38.000Z | elenasrc2/elenagm/win32/directx12.h | drkameleon/elena-lang | 8585e93a3bc0b19f8d60029ffbe01311d0b711a3 | [
"MIT"
] | 31 | 2015-09-30T13:07:36.000Z | 2021-10-15T13:08:04.000Z | //---------------------------------------------------------------------------
// E L E N A P r o j e c t: ELENA Graphic Engine
//
// (C)2017, by Alexei Rakov
//---------------------------------------------------------------------------
#ifndef elenagm_d12H
#define elenagm_d12H 1
#include "elena.h"
#include "win32_common.h"
using namespace DirectX;
namespace _ELENA_
{
class D3D12Platform : public GraphicPlatform
{
static const UINT FrameCount = 3;
struct Vertex
{
XMFLOAT3 position;
XMFLOAT4 color;
};
path_t _rootPath;
int _width;
int _height;
float _aspectRatio;
// Pipeline objects.
CD3DX12_VIEWPORT _viewport;
CD3DX12_RECT _scissorRect;
ComPtr<ID3D12Device> _d3d12Device;
ComPtr<ID3D11On12Device> _d3d11On12Device;
ComPtr<ID3D11DeviceContext> _d3d11DeviceContext;
ComPtr<ID2D1Factory3> _d2dFactory;
ComPtr<ID2D1Device2> _d2dDevice;
ComPtr<ID2D1DeviceContext2> _d2dDeviceContext;
ComPtr<IDWriteFactory> _dWriteFactory;
ComPtr<ID3D12CommandQueue> _commandQueue;
ComPtr<IDXGISwapChain3> _swapChain;
ComPtr<ID3D12DescriptorHeap> _rtvHeap;
ComPtr<ID3D12Resource> _renderTargets[FrameCount];
ComPtr<ID3D11Resource> _wrappedBackBuffers[FrameCount];
ComPtr<ID2D1Bitmap1> _d2dRenderTargets[FrameCount];
ComPtr<ID3D12CommandAllocator> _commandAllocators[FrameCount];
ComPtr<ID3D12PipelineState> _pipelineState;
ComPtr<ID3D12GraphicsCommandList> _commandList;
ComPtr<ID3D12RootSignature> _rootSignature;
// App resources.
UINT _rtvDescriptorSize;
ComPtr<ID2D1SolidColorBrush> _textBrush;
ComPtr<IDWriteTextFormat> _textFormat;
ComPtr<ID3D12Resource> _vertexBuffer;
D3D12_VERTEX_BUFFER_VIEW _vertexBufferView;
// Synchronization objects.
UINT _frameIndex;
HANDLE _fenceEvent;
UINT64 _fenceValues[FrameCount];
ComPtr<ID3D12Fence> _fence;
void MoveToNextFrame();
void PopulateCommandList();
void RenderUI();
void WaitForGpu();
void InitPipeline();
public:
D3D12Platform(path_t rootPath, int width, int height);
virtual ~D3D12Platform() {}
virtual void Init(HWND hWnd);
virtual void* NewWidget(void* /* parent*/, int/* type*/) { return NULL; }
virtual int CloseWidget(void* /* handle*/) { return -1; }
void OnRender(HWND hWnd);
void OnDestroy();
};
} // _ELENA_
#endif // elenagm_d12H | 26.263736 | 77 | 0.686611 |
06b14c5f2de35d59565620997fe8af9681abdbc2 | 1,382 | c | C | src/mrg32k3a.c | tandriamil/bcs-aes256-ctr | 92ee1bf4088047a521be3e17849d2002f86ef83f | [
"MIT"
] | null | null | null | src/mrg32k3a.c | tandriamil/bcs-aes256-ctr | 92ee1bf4088047a521be3e17849d2002f86ef83f | [
"MIT"
] | null | null | null | src/mrg32k3a.c | tandriamil/bcs-aes256-ctr | 92ee1bf4088047a521be3e17849d2002f86ef83f | [
"MIT"
] | null | null | null | /**
* 32-bits Random number generator U(0,1): MRG32k3a
* Author: Pierre L'Ecuyer,
* Source: Good Parameter Sets for Combined Multiple Recursive Random
* Number Generators,
* Shorter version in Operations Research,
* 47, 1 (1999), 159--164.
*
* ====================================================================
* Update by Andriamilanto Tompoariniaina:
* - Code redesign and comments
* - The seed is now taken from the current time
**/
#include "mrg32k3a.h"
// Constants
#define NORM 2.328306549295728e-10
#define M1 4294967087.0
#define M2 4294944443.0
#define A12 1403580.0
#define A13N 810728.0
#define A21 527612.0
#define A23N 1370589.0
/**
* Get a pseudo-random double number
* EDIT: This uses the current time as seed
* \return A pseudo-random double number
*/
double MRG32k3a() {
// Update: Generate the seed from the current time
double SEED = time(NULL);
long k;
double p1, p2, s10 = SEED, s11 = SEED, s12 = SEED, s20 = SEED, s21 = SEED, s22 = SEED;
/* Component 1 */
p1 = A12 * s11 - A13N * s10;
k = p1 / M1;
p1 -= k * M1;
if (p1 < 0.0) p1 += M1;
s10 = s11;
s11 = s12;
s12 = p1;
/* Component 2 */
p2 = A21 * s22 - A23N * s20;
k = p2 / M2;
p2 -= k * M2;
if (p2 < 0.0) p2 += M2;
s20 = s21;
s21 = s22;
s22 = p2;
/* Combination */
if (p1 <= p2) return ((p1 - p2 + M1) * NORM);
else return ((p1 - p2) * NORM);
}
| 22.290323 | 87 | 0.596237 |
255596308e2919a7367937af42f7472043995390 | 1,099 | h | C | Chapter07/Example02/Example02/SpriteSet.h | ecofast/FocusOn2DInDirect3D-VC2008 | 74167d60190805445706420510e976897258f4ac | [
"BSD-2-Clause"
] | null | null | null | Chapter07/Example02/Example02/SpriteSet.h | ecofast/FocusOn2DInDirect3D-VC2008 | 74167d60190805445706420510e976897258f4ac | [
"BSD-2-Clause"
] | null | null | null | Chapter07/Example02/Example02/SpriteSet.h | ecofast/FocusOn2DInDirect3D-VC2008 | 74167d60190805445706420510e976897258f4ac | [
"BSD-2-Clause"
] | null | null | null | #ifndef __SPRITESET_H__
#define __SPRITESET_H__
#include "d3d9.h"
// vertex format description used for spriteset
const int SPRITESET_VERTEX_FVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1;
// custom vertex format for spriteset
struct SpriteSetVertex
{
float x, y, z, rhw;
DWORD diffuse;
float u, v;
};
// spriteset class
class CSpriteSet
{
private:
// destination device
IDirect3DDevice9* m_pDestinationDevice;
// textures
IDirect3DTexture9** m_pTextures;
// vertex array
SpriteSetVertex* m_Vertices;
// number of textures
int m_nTextureCount;
public:
// constructor
CSpriteSet(IDirect3DDevice9* pDevice, LPCWSTR FileName, D3DFORMAT Format);
// destructor
virtual ~CSpriteSet();
// load a bitmap
void Load(LPCWSTR FileName, D3DFORMAT Format);
// destroy current data
void Destroy();
// retrieve information
IDirect3DTexture9* GetTexture(int nImage);
SpriteSetVertex* GetVertex(int nImage, int nVertex);
int GetTextureCount();
// render
void PutSprite(int nImage, float x, float y, float angle = 0.0f, float scalex = 1.0f, float scaley = 1.0f);
};
#endif | 19.981818 | 108 | 0.747953 |
b525f10833b0de6b9783275c8487f789a66fd838 | 2,754 | h | C | molequeue/app/queues/uit/directorydownload.h | cygwin-lem/molequeue | 0511c9a5d6f7c0aaa728041945b8638dd9232d00 | [
"BSD-3-Clause"
] | 18 | 2017-02-28T13:24:03.000Z | 2022-03-11T17:58:08.000Z | molequeue/app/queues/uit/directorydownload.h | cygwin-lem/molequeue | 0511c9a5d6f7c0aaa728041945b8638dd9232d00 | [
"BSD-3-Clause"
] | 14 | 2015-12-28T21:16:21.000Z | 2021-09-11T00:38:40.000Z | molequeue/app/queues/uit/directorydownload.h | cygwin-lem/molequeue | 0511c9a5d6f7c0aaa728041945b8638dd9232d00 | [
"BSD-3-Clause"
] | 20 | 2015-01-29T16:35:47.000Z | 2021-04-09T02:05:23.000Z | /******************************************************************************
This source file is part of the MoleQueue project.
Copyright 2012 Kitware, Inc.
This source code is released under the New BSD License, (the "License").
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 UITDIRDOWNLOADER_H_
#define UITDIRDOWNLOADER_H_
#include "filesystemoperation.h"
#include <QtCore/QObject>
#include <QtNetwork/QNetworkReply>
#include <QtCore/QQueue>
#include <QtCore/QFileInfo>
namespace MoleQueue {
namespace Uit {
class Session;
/**
* @brief File system operation to download a directory from a remote UIT system.
*/
class DirectoryDownload : public FileSystemOperation
{
Q_OBJECT
public:
/**
* @param session The UIT session.
* @param parentObject The parent object.
*/
DirectoryDownload(Session *session, QObject *parentObject);
/**
* @return The remote path being downloaded.
*/
QString remotePath() const
{
return m_remotePath;
}
/**
* @param path The remote path to be downloaded.
*/
void setRemotePath(const QString& path)
{
m_remotePath = path;
}
/**
* @return The local path to download the directory to.
*/
QString localPath() const
{
return m_localPath;
}
/**
* @param path The local path to download the directory to.
*/
void setLocalPath(const QString& path)
{
m_localPath = path;
}
/**
* @return The download URL.
*/
QString url() const
{
return m_url;
}
/**
* @param The download URL to use.
*/
void setUrl(const QString& u)
{
m_url = u;
}
void start();
private slots:
void download(const QString &dir);
void downloadInternal();
void downloadNext();
/**
* Slot to process a directory listing.
*/
void processDirectoryListing();
/**
* Slot called when the current download request is complete.
*
* @param reply The reply used to read the file contents.
*/
void finished(QNetworkReply *reply);
private:
QString m_remotePath;
QString m_localPath;
QNetworkAccessManager *m_networkAccess;
QString m_url;
// Queue of directories to download.
QQueue<QString> m_directories;
// Queue of files to download.
QQueue<QString> m_files;
// The current local file path to write data to.
QString m_currentFilePath;
};
} /* namespace Uit */
} /* namespace MoleQueue */
#endif /* UITDIRDOWNLOADER_H_ */
| 21.857143 | 81 | 0.656137 |
b5b71f4b8276d939d8edb67fb770801730552170 | 70 | h | C | src/benchmarks/minife.h | hannesweisbach/hwvar | 51f1bb803a749f1e06f0059a1aa368dd29f3f2d4 | [
"BSD-2-Clause"
] | null | null | null | src/benchmarks/minife.h | hannesweisbach/hwvar | 51f1bb803a749f1e06f0059a1aa368dd29f3f2d4 | [
"BSD-2-Clause"
] | null | null | null | src/benchmarks/minife.h | hannesweisbach/hwvar | 51f1bb803a749f1e06f0059a1aa368dd29f3f2d4 | [
"BSD-2-Clause"
] | null | null | null | #pragma once
#include <benchmark.h>
extern benchmark_t minife_ops;
| 10 | 30 | 0.771429 |
be8ac977fd85f98c86be440761da62e8716661a7 | 5,711 | h | C | Source/Controllers/DBMessagingViewController.h | DevonBoyer/MessagingKit | 010b375f282228ef56da4f94fa093e79ced92d29 | [
"MIT"
] | 6 | 2015-01-09T00:04:41.000Z | 2015-01-27T00:35:03.000Z | Source/Controllers/DBMessagingViewController.h | devonboyer/DBMessagingKit | 010b375f282228ef56da4f94fa093e79ced92d29 | [
"MIT"
] | null | null | null | Source/Controllers/DBMessagingViewController.h | devonboyer/DBMessagingKit | 010b375f282228ef56da4f94fa093e79ced92d29 | [
"MIT"
] | null | null | null | //
// DBMessagingViewController.h
//
//
// GitHub
// https://github.com/DevonBoyer/MessagingKit
//
//
// Created by Devon Boyer on 2014-10-12.
// Copyright (c) 2014 Devon Boyer. All rights reserved.
//
// Released under an MIT license: http://opensource.org/licenses/MIT
//
#import <UIKit/UIKit.h>
#import "DBMessagingKitConstants.h"
#import "DBMessagingCollectionViewDataSource.h"
#import "DBMessagingCollectionViewDelegate.h"
#import "DBMessagingCollectionViewDelegateFlowLayout.h"
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
@class DBMessagingCollectionView;
@class DBInteractiveKeyboardController;
@class DBMessagingInputToolbar;
/**
* The 'DBMessagingViewController' class is an abstract class that represents a view controller whose content consists of
* a 'DBMessagingCollectionView' and 'DBMessagingInputToolbar' and is specialized to display a messaging interface.
*
* @warning This class is intended to be subclassed. You should not use it directly.
*/
@interface DBMessagingViewController : UIViewController <DBMessagingCollectionViewDataSource, DBMessagingCollectionViewDelegate, DBMessagingCollectionViewDelegateFlowLayout>
/**
* Returns your device's current location.
*
* @warning You must call [self.locationManager startUpdatingLocation] before trying to access the current location. Note that this
* will ask the user for the appropriate permission that has been configured in the info.plist.
*/
@property (strong, nonatomic, readonly) CLLocation *currentLocation;
/**
* Returns the location manager used to get your device's current location.
*/
@property (strong, nonatomic, readonly) CLLocationManager *locationManager;
/**
* Returns the collection view object managed by this view controller.
* This view controller is the collection view's data source and delegate.
*/
@property (strong, nonatomic, readonly) DBMessagingCollectionView *collectionView;
/**
* The keyboard controller object for the 'DBMessagingViewController'
*/
@property (strong, nonatomic, readonly) DBInteractiveKeyboardController *keyboardController;
/**
* Returns the messaging input view for the 'DBMessagingViewController'
*/
@property (strong, nonatomic, readonly) DBMessagingInputToolbar *messageInputToolbar;
/**
* Specifys the type of layout in which to display timestamps. The default value is 'DBMessagingTimestampStyleNone'.
*
* @warning You must specify the timestamp style before configuring any custom attributes. Currently changing the timestamp
* style at runtime is not supported.
*/
@property (assign, nonatomic) DBMessagingTimestampStyle timestampStyle;
/**
* Specifies whether or not to accept any auto-correct suggestions before sending a message.
*
* @discussion The default value is 'YES'.
*/
@property (nonatomic) BOOL acceptsAutoCorrectBeforeSending;
/**
* Specifies whether or not the view controller should automatically scroll to the most recent message
* when composing a new message and when sending or receiving a new message.
*
* @discussion The default value is 'YES', which allows the view controller to scroll automatically to the most recent message.
* Set to 'NO' if you want to manage scrolling yourself.
*/
@property (assign, nonatomic) BOOL automaticallyScrollsToMostRecentMessage;
/**
* Specifies whether or not the view controller should show the "load earlier messages" header view.
*
* @discussion Setting this property to 'YES' will show the header view immediately.
* Settings this property to 'NO' will hide the header view immediately. You will need to scroll to
* the top of the collection view in order to see the header.
*/
@property (nonatomic) BOOL showLoadMoreMessages;
/**
* Specifies whether or not the view controller should show the typing indicator for an incoming message.
*
* @discussion Setting this property to 'YES' will animate showing the typing indicator immediately.
* Setting this property to 'NO' will animate hiding the typing indicator immediately. You will need to scroll
* to the bottom of the collection view in order to see the typing indicator. You may use 'scrollToBottomAnimated:' for this.
*/
@property (nonatomic) BOOL showTypingIndicator;
/**
* A convenience method for returning the index path fo the latest message that was sent or recieved.
*
* @return Returns the indexPath for the latest message.
*/
- (NSIndexPath *)indexPathForLatestMessage;
/**
* Completes the sending of a new message by clearing the currently composed text,
* reloading the collection view, and scrolling to the newly sent message
* as specified by 'automaticallyScrollsToMostRecentMessage'.
*
* @discussion You should call this method after adding a new sent message
* to your data source and performing any related tasks.
*
* @see 'automaticallyScrollsToMostRecentMessage'.
*/
- (void)finishSendingMessage;
/**
* Completes the receiving of a new message by animating the typing indicator,
* animating the addition of a new collection view cell in the collection view,
* reloading the collection view, and scrolling to the newly received message
* as specified by 'automaticallyScrollsToMostRecentMessage'.
*
* @discussion You should call this method after adding a new received message
* to your data source and performing any related tasks.
*
* @see 'automaticallyScrollsToMostRecentMessage'.
*/
- (void)finishReceivingMessage;
/**
* Scrolls the collection view such that the bottom most cell is completely visible, above the 'inputToolbar'.
*
* @param animated Pass 'YES' if you want to animate scrolling, 'NO' if it should be immediate.
*/
- (void)scrollToBottomAnimated:(BOOL)animated;
@end
| 38.587838 | 173 | 0.772544 |
71ef02d43da35944fea1ca21a6143382a6214073 | 3,605 | h | C | qos-cpp/src/AudioStreamingTest.h | zafaco/nntool | 273b77164a7b471edc66e3b332c9485f4b964b5e | [
"Apache-2.0"
] | null | null | null | qos-cpp/src/AudioStreamingTest.h | zafaco/nntool | 273b77164a7b471edc66e3b332c9485f4b964b5e | [
"Apache-2.0"
] | 4 | 2021-09-14T11:34:53.000Z | 2022-03-02T12:04:58.000Z | qos-cpp/src/AudioStreamingTest.h | zafaco/nntool | 273b77164a7b471edc66e3b332c9485f4b964b5e | [
"Apache-2.0"
] | null | null | null | /***************************************************************************
* Copyright 2020 alladin-IT GmbH
*
* 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 AUDIOSTREAMINGTEST_H
#define AUDIOSTREAMINGTEST_H
#include <functional>
#include <future>
#include <chrono>
#include <string>
#include <vector>
#include <gst/gst.h>
class AudioStreamingTest {
public:
inline void initialize(std::string url, long long int const bufferDurationNs, long long int const playbackDurationNs) {
this->targetUrl = url;
this->bufferDurationNs = bufferDurationNs;
this->playbackDurationNs = playbackDurationNs;
}
std::string start();
void stop();
/**
* function has params: level, tag, message
* to be set on demand
*/
inline void setLogFunction(std::function<void(std::string, std::string, std::string)> logFunction) {
this->logFunction = logFunction;
}
/**
* Callback when a new thread is started for the first time (e.g. to register with JVM), to be set on demand
*/
inline void setOnThreadAttachCallback(std::function<void()> threadAttachCallback) {
this->threadAttachCallback = threadAttachCallback;
}
/**
* Callback when a new thread is ending (e.g. to unregister with JVM), to be set on demand
*/
inline void setOnThreadDetachCallback(std::function<void()> threadDetachCallback) {
this->threadDetachCallback = threadDetachCallback;
}
private:
const char * TAG = "AudioStreamingTest";
/* Structure to contain all our information, so we can pass it to callbacks */
typedef struct _CustomData
{
GstElement *pipeline; /* The running pipeline */
GMainContext *context; /* GLib context used to run the main loop */
GMainLoop *main_loop; /* GLib main loop */
gboolean initialized; /* To avoid informing the UI multiple times about the initialization */
} CustomData;
CustomData * data;
std::string targetUrl;
long long int bufferDurationNs = -1;
long long int playbackDurationNs = -1;
std::function<void()> threadAttachCallback;
std::function<void()> threadDetachCallback;
std::function<void(std::string, std::string, std::string)> logFunction;
bool isCurrentStall = false;
bool isFirstStall = true;
std::chrono::time_point<std::chrono::steady_clock> currentStallStart;
std::vector<long long int> stallDurations;
std::chrono::time_point<std::chrono::steady_clock> startCommandTime;
std::chrono::time_point<std::chrono::steady_clock> startPlayTime;
std::future<void> futureGstreamerMainLoop;
std::future<void> futurePlaybackStop;
std::string result;
static void basicCallback (GstBus * bus, GstMessage * msg, AudioStreamingTest test);
void messageCallback(GstBus * bus, GstMessage * msg);
void runAudioStreamingTest(CustomData * data);
void checkInitializationComplete(_CustomData *);
};
#endif //AUDIOSTREAMINGTEST_H
| 31.902655 | 123 | 0.669903 |
d544d7962cc94dd1933a336e0c13b8e0f343a906 | 4,097 | h | C | src/player/Render/VideoShader.h | daijh/Immersive-Video-Sample | 9f603b0384bfa1e7c55f862a2481b54835a1aaaf | [
"BSD-3-Clause"
] | null | null | null | src/player/Render/VideoShader.h | daijh/Immersive-Video-Sample | 9f603b0384bfa1e7c55f862a2481b54835a1aaaf | [
"BSD-3-Clause"
] | null | null | null | src/player/Render/VideoShader.h | daijh/Immersive-Video-Sample | 9f603b0384bfa1e7c55f862a2481b54835a1aaaf | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright (c) 2019, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the 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.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
//!
//! \file VideoShader.h
//! \brief Defines class for VideoShader.
//!
#ifndef _VIDEOSHADER_H_
#define _VIDEOSHADER_H_
#include <GL/glu.h>
#include <GL/glu_mangle.h>
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glext.h>
#include <GL/glcorearb.h>
#include <GLES3/gl3.h>
#include <GLES3/gl3ext.h>
#include <GLES3/gl3platform.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
#include "../Common.h"
VCD_NS_BEGIN
class VideoShader
{
public:
VideoShader()=default;
VideoShader(const std::string &vertexFileName, const std::string &fragmentFileName);
void Bind();
virtual ~VideoShader();
//! \brief Set uniform for an integer
//!
//! \param [in] name
//! The unifrom name
//! \param [in] value
//! The value which will be set
//! \return void
//! no return
//!
void SetUniform1i(const char *name, int32_t value);
//! \brief Set uniform for a float
//!
//! \param [in] name
//! The unifrom name
//! \param [in] value
//! The value which will be set
//! \return void
//! no return
//!
void SetUniform1f(const char *name, float value);
//! \brief Set uniform for a 2x2 matrix
//!
//! \param [in] name
//! The unifrom name
//! \param [in] matrix
//! The value which will be set
//! \return void
//! no return
//!
void SetUniformMatrix2f(const char *name, glm::mat2 matrix);
//! \brief Set uniform for a 3x3 matrix
//!
//! \param [in] name
//! The unifrom name
//! \param [in] matrix
//! The value which will be set
//! \return void
//! no return
//!
void SetUniformMatrix3f(const char *name, glm::mat3 matrix);
//! \brief Set uniform for a 4x4 matrix
//!
//! \param [in] name
//! The unifrom name
//! \param [in] matrix
//! The value which will be set
//! \return void
//! no return
//!
void SetUniformMatrix4f(const char *name, glm::mat4 matrix);
//! \brief Set attrib for vertex and coords
//!
//! \param [in] name
//! The unifrom name
//! \return uint32_t
//! attrib value
//!
uint32_t SetAttrib(const char *name);
protected:
private:
static const unsigned int NUM_SHADERS = 2;
VideoShader(const VideoShader &other) {}
void operator=(const VideoShader &other) {}
GLuint m_program;
GLuint m_shaders[NUM_SHADERS];
};
VCD_NS_END
#endif /* _VIDEOSHADER_H_ */
| 28.65035 | 88 | 0.642177 |
57e81a7a37f9294ff998e05f2446c462f33c968b | 27,372 | h | C | runtime/intrinsics_list.h | Paschalis/android-llvm | 317f7fd4b736a0511a2273a2487915c34cf8933e | [
"Apache-2.0"
] | 20 | 2021-06-24T16:38:42.000Z | 2022-01-20T16:15:57.000Z | runtime/intrinsics_list.h | Paschalis/android-llvm | 317f7fd4b736a0511a2273a2487915c34cf8933e | [
"Apache-2.0"
] | null | null | null | runtime/intrinsics_list.h | Paschalis/android-llvm | 317f7fd4b736a0511a2273a2487915c34cf8933e | [
"Apache-2.0"
] | 4 | 2021-11-03T06:01:12.000Z | 2022-02-24T02:57:31.000Z | /*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ART_RUNTIME_INTRINSICS_LIST_H_
#define ART_RUNTIME_INTRINSICS_LIST_H_
// This file defines the set of intrinsics that are supported by ART
// in the compiler and runtime. Neither compiler nor runtime has
// intrinsics for all methods here.
//
// The entries in the INTRINSICS_LIST below have the following format:
//
// 1. name
// 2. invocation-type (art::InvokeType value).
// 3. needs-environment (art::IntrinsicNeedsEnvironmentOrCache value)
// 4. side-effects (art::IntrinsicSideEffects value)
// 5. exception-info (art::::IntrinsicExceptions value)
// 6. declaring class descriptor
// 7. method name
// 8. method descriptor
//
// The needs-environment, side-effects and exception-info are compiler
// related properties (compiler/optimizing/nodes.h) that should not be
// used outside of the compiler.
//
// Note: adding a new intrinsic requires an art image version change,
// as the modifiers flag for some ArtMethods will need to be changed.
//
// Note: j.l.Integer.valueOf says kNoThrow even though it could throw an
// OOME. The kNoThrow should be renamed to kNoVisibleThrow, as it is ok to
// GVN Integer.valueOf (kNoSideEffects), and it is also OK to remove it if
// it's unused.
//
// Note: Thread.interrupted is marked with kAllSideEffects due to the lack
// of finer grain side effects representation.
// Intrinsics for methods with signature polymorphic behaviours.
#define SIGNATURE_POLYMORPHIC_INTRINSICS_LIST(V) \
V(MethodHandleInvokeExact, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/MethodHandle;", "invokeExact", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(MethodHandleInvoke, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/MethodHandle;", "invoke", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleCompareAndExchange, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "compareAndExchange", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleCompareAndExchangeAcquire, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "compareAndExchangeAcquire", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleCompareAndExchangeRelease, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "compareAndExchangeRelease", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleCompareAndSet, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "compareAndSet", "([Ljava/lang/Object;)Z") \
V(VarHandleGet, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "get", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetAcquire, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getAcquire", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetAndAdd, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getAndAdd", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetAndAddAcquire, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getAndAddAcquire", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetAndAddRelease, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getAndAddRelease", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetAndBitwiseAnd, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getAndBitwiseAnd", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetAndBitwiseAndAcquire, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getAndBitwiseAndAcquire", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetAndBitwiseAndRelease, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getAndBitwiseAndRelease", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetAndBitwiseOr, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getAndBitwiseOr", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetAndBitwiseOrAcquire, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getAndBitwiseOrAcquire", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetAndBitwiseOrRelease, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getAndBitwiseOrRelease", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetAndBitwiseXor, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getAndBitwiseXor", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetAndBitwiseXorAcquire, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getAndBitwiseXorAcquire", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetAndBitwiseXorRelease, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getAndBitwiseXorRelease", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetAndSet, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getAndSet", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetAndSetAcquire, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getAndSetAcquire", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetAndSetRelease, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getAndSetRelease", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetOpaque, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getOpaque", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleGetVolatile, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "getVolatile", "([Ljava/lang/Object;)Ljava/lang/Object;") \
V(VarHandleSet, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "set", "([Ljava/lang/Object;)V") \
V(VarHandleSetOpaque, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "setOpaque", "([Ljava/lang/Object;)V") \
V(VarHandleSetRelease, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "setRelease", "([Ljava/lang/Object;)V") \
V(VarHandleSetVolatile, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "setVolatile", "([Ljava/lang/Object;)V") \
V(VarHandleWeakCompareAndSet, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "weakCompareAndSet", "([Ljava/lang/Object;)Z") \
V(VarHandleWeakCompareAndSetAcquire, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "weakCompareAndSetAcquire", "([Ljava/lang/Object;)Z") \
V(VarHandleWeakCompareAndSetPlain, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "weakCompareAndSetPlain", "([Ljava/lang/Object;)Z") \
V(VarHandleWeakCompareAndSetRelease, kPolymorphic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/invoke/VarHandle;", "weakCompareAndSetRelease", "([Ljava/lang/Object;)Z")
// The complete list of intrinsics.
#define INTRINSICS_LIST(V) \
V(DoubleDoubleToRawLongBits, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Double;", "doubleToRawLongBits", "(D)J") \
V(DoubleDoubleToLongBits, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Double;", "doubleToLongBits", "(D)J") \
V(DoubleIsInfinite, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Double;", "isInfinite", "(D)Z") \
V(DoubleIsNaN, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Double;", "isNaN", "(D)Z") \
V(DoubleLongBitsToDouble, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Double;", "longBitsToDouble", "(J)D") \
V(FloatFloatToRawIntBits, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Float;", "floatToRawIntBits", "(F)I") \
V(FloatFloatToIntBits, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Float;", "floatToIntBits", "(F)I") \
V(FloatIsInfinite, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Float;", "isInfinite", "(F)Z") \
V(FloatIsNaN, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Float;", "isNaN", "(F)Z") \
V(FloatIntBitsToFloat, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Float;", "intBitsToFloat", "(I)F") \
V(IntegerReverse, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Integer;", "reverse", "(I)I") \
V(IntegerReverseBytes, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Integer;", "reverseBytes", "(I)I") \
V(IntegerBitCount, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Integer;", "bitCount", "(I)I") \
V(IntegerCompare, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Integer;", "compare", "(II)I") \
V(IntegerHighestOneBit, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Integer;", "highestOneBit", "(I)I") \
V(IntegerLowestOneBit, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Integer;", "lowestOneBit", "(I)I") \
V(IntegerNumberOfLeadingZeros, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Integer;", "numberOfLeadingZeros", "(I)I") \
V(IntegerNumberOfTrailingZeros, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Integer;", "numberOfTrailingZeros", "(I)I") \
V(IntegerRotateRight, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Integer;", "rotateRight", "(II)I") \
V(IntegerRotateLeft, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Integer;", "rotateLeft", "(II)I") \
V(IntegerSignum, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Integer;", "signum", "(I)I") \
V(LongReverse, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Long;", "reverse", "(J)J") \
V(LongReverseBytes, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Long;", "reverseBytes", "(J)J") \
V(LongBitCount, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Long;", "bitCount", "(J)I") \
V(LongCompare, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Long;", "compare", "(JJ)I") \
V(LongHighestOneBit, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Long;", "highestOneBit", "(J)J") \
V(LongLowestOneBit, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Long;", "lowestOneBit", "(J)J") \
V(LongNumberOfLeadingZeros, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Long;", "numberOfLeadingZeros", "(J)I") \
V(LongNumberOfTrailingZeros, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Long;", "numberOfTrailingZeros", "(J)I") \
V(LongRotateRight, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Long;", "rotateRight", "(JI)J") \
V(LongRotateLeft, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Long;", "rotateLeft", "(JI)J") \
V(LongSignum, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Long;", "signum", "(J)I") \
V(ShortReverseBytes, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Short;", "reverseBytes", "(S)S") \
V(MathAbsDouble, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "abs", "(D)D") \
V(MathAbsFloat, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "abs", "(F)F") \
V(MathAbsLong, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "abs", "(J)J") \
V(MathAbsInt, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "abs", "(I)I") \
V(MathMinDoubleDouble, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "min", "(DD)D") \
V(MathMinFloatFloat, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "min", "(FF)F") \
V(MathMinLongLong, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "min", "(JJ)J") \
V(MathMinIntInt, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "min", "(II)I") \
V(MathMaxDoubleDouble, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "max", "(DD)D") \
V(MathMaxFloatFloat, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "max", "(FF)F") \
V(MathMaxLongLong, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "max", "(JJ)J") \
V(MathMaxIntInt, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "max", "(II)I") \
V(MathCos, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "cos", "(D)D") \
V(MathSin, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "sin", "(D)D") \
V(MathAcos, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "acos", "(D)D") \
V(MathAsin, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "asin", "(D)D") \
V(MathAtan, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "atan", "(D)D") \
V(MathAtan2, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "atan2", "(DD)D") \
V(MathPow, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "pow", "(DD)D") \
V(MathCbrt, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "cbrt", "(D)D") \
V(MathCosh, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "cosh", "(D)D") \
V(MathExp, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "exp", "(D)D") \
V(MathExpm1, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "expm1", "(D)D") \
V(MathHypot, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "hypot", "(DD)D") \
V(MathLog, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "log", "(D)D") \
V(MathLog10, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "log10", "(D)D") \
V(MathNextAfter, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "nextAfter", "(DD)D") \
V(MathSinh, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "sinh", "(D)D") \
V(MathTan, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "tan", "(D)D") \
V(MathTanh, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "tanh", "(D)D") \
V(MathSqrt, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "sqrt", "(D)D") \
V(MathCeil, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "ceil", "(D)D") \
V(MathFloor, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "floor", "(D)D") \
V(MathRint, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "rint", "(D)D") \
V(MathRoundDouble, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "round", "(D)J") \
V(MathRoundFloat, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Math;", "round", "(F)I") \
V(SystemArrayCopyChar, kStatic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/System;", "arraycopy", "([CI[CII)V") \
V(SystemArrayCopy, kStatic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/System;", "arraycopy", "(Ljava/lang/Object;ILjava/lang/Object;II)V") \
V(ThreadCurrentThread, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Thread;", "currentThread", "()Ljava/lang/Thread;") \
V(MemoryPeekByte, kStatic, kNeedsEnvironmentOrCache, kReadSideEffects, kCanThrow, "Llibcore/io/Memory;", "peekByte", "(J)B") \
V(MemoryPeekIntNative, kStatic, kNeedsEnvironmentOrCache, kReadSideEffects, kCanThrow, "Llibcore/io/Memory;", "peekIntNative", "(J)I") \
V(MemoryPeekLongNative, kStatic, kNeedsEnvironmentOrCache, kReadSideEffects, kCanThrow, "Llibcore/io/Memory;", "peekLongNative", "(J)J") \
V(MemoryPeekShortNative, kStatic, kNeedsEnvironmentOrCache, kReadSideEffects, kCanThrow, "Llibcore/io/Memory;", "peekShortNative", "(J)S") \
V(MemoryPokeByte, kStatic, kNeedsEnvironmentOrCache, kWriteSideEffects, kCanThrow, "Llibcore/io/Memory;", "pokeByte", "(JB)V") \
V(MemoryPokeIntNative, kStatic, kNeedsEnvironmentOrCache, kWriteSideEffects, kCanThrow, "Llibcore/io/Memory;", "pokeIntNative", "(JI)V") \
V(MemoryPokeLongNative, kStatic, kNeedsEnvironmentOrCache, kWriteSideEffects, kCanThrow, "Llibcore/io/Memory;", "pokeLongNative", "(JJ)V") \
V(MemoryPokeShortNative, kStatic, kNeedsEnvironmentOrCache, kWriteSideEffects, kCanThrow, "Llibcore/io/Memory;", "pokeShortNative", "(JS)V") \
V(StringCharAt, kVirtual, kNeedsEnvironmentOrCache, kReadSideEffects, kCanThrow, "Ljava/lang/String;", "charAt", "(I)C") \
V(StringCompareTo, kVirtual, kNeedsEnvironmentOrCache, kReadSideEffects, kCanThrow, "Ljava/lang/String;", "compareTo", "(Ljava/lang/String;)I") \
V(StringEquals, kVirtual, kNeedsEnvironmentOrCache, kReadSideEffects, kCanThrow, "Ljava/lang/String;", "equals", "(Ljava/lang/Object;)Z") \
V(StringGetCharsNoCheck, kVirtual, kNeedsEnvironmentOrCache, kReadSideEffects, kCanThrow, "Ljava/lang/String;", "getCharsNoCheck", "(II[CI)V") \
V(StringIndexOf, kVirtual, kNeedsEnvironmentOrCache, kReadSideEffects, kNoThrow, "Ljava/lang/String;", "indexOf", "(I)I") \
V(StringIndexOfAfter, kVirtual, kNeedsEnvironmentOrCache, kReadSideEffects, kNoThrow, "Ljava/lang/String;", "indexOf", "(II)I") \
V(StringStringIndexOf, kVirtual, kNeedsEnvironmentOrCache, kReadSideEffects, kCanThrow, "Ljava/lang/String;", "indexOf", "(Ljava/lang/String;)I") \
V(StringStringIndexOfAfter, kVirtual, kNeedsEnvironmentOrCache, kReadSideEffects, kCanThrow, "Ljava/lang/String;", "indexOf", "(Ljava/lang/String;I)I") \
V(StringIsEmpty, kVirtual, kNeedsEnvironmentOrCache, kReadSideEffects, kNoThrow, "Ljava/lang/String;", "isEmpty", "()Z") \
V(StringLength, kVirtual, kNeedsEnvironmentOrCache, kReadSideEffects, kNoThrow, "Ljava/lang/String;", "length", "()I") \
V(StringNewStringFromBytes, kStatic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/StringFactory;", "newStringFromBytes", "([BIII)Ljava/lang/String;") \
V(StringNewStringFromChars, kStatic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/StringFactory;", "newStringFromChars", "(II[C)Ljava/lang/String;") \
V(StringNewStringFromString, kStatic, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/StringFactory;", "newStringFromString", "(Ljava/lang/String;)Ljava/lang/String;") \
V(StringBufferAppend, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/StringBuffer;", "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;") \
V(StringBufferLength, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kNoThrow, "Ljava/lang/StringBuffer;", "length", "()I") \
V(StringBufferToString, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/StringBuffer;", "toString", "()Ljava/lang/String;") \
V(StringBuilderAppend, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/StringBuilder;", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;") \
V(StringBuilderLength, kVirtual, kNeedsEnvironmentOrCache, kReadSideEffects, kNoThrow, "Ljava/lang/StringBuilder;", "length", "()I") \
V(StringBuilderToString, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/StringBuilder;", "toString", "()Ljava/lang/String;") \
V(UnsafeCASInt, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "compareAndSwapInt", "(Ljava/lang/Object;JII)Z") \
V(UnsafeCASLong, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "compareAndSwapLong", "(Ljava/lang/Object;JJJ)Z") \
V(UnsafeCASObject, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "compareAndSwapObject", "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z") \
V(UnsafeGet, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getInt", "(Ljava/lang/Object;J)I") \
V(UnsafeGetVolatile, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getIntVolatile", "(Ljava/lang/Object;J)I") \
V(UnsafeGetObject, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getObject", "(Ljava/lang/Object;J)Ljava/lang/Object;") \
V(UnsafeGetObjectVolatile, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getObjectVolatile", "(Ljava/lang/Object;J)Ljava/lang/Object;") \
V(UnsafeGetLong, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getLong", "(Ljava/lang/Object;J)J") \
V(UnsafeGetLongVolatile, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getLongVolatile", "(Ljava/lang/Object;J)J") \
V(UnsafePut, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "putInt", "(Ljava/lang/Object;JI)V") \
V(UnsafePutOrdered, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "putOrderedInt", "(Ljava/lang/Object;JI)V") \
V(UnsafePutVolatile, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "putIntVolatile", "(Ljava/lang/Object;JI)V") \
V(UnsafePutObject, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "putObject", "(Ljava/lang/Object;JLjava/lang/Object;)V") \
V(UnsafePutObjectOrdered, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "putOrderedObject", "(Ljava/lang/Object;JLjava/lang/Object;)V") \
V(UnsafePutObjectVolatile, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "putObjectVolatile", "(Ljava/lang/Object;JLjava/lang/Object;)V") \
V(UnsafePutLong, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "putLong", "(Ljava/lang/Object;JJ)V") \
V(UnsafePutLongOrdered, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "putOrderedLong", "(Ljava/lang/Object;JJ)V") \
V(UnsafePutLongVolatile, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "putLongVolatile", "(Ljava/lang/Object;JJ)V") \
V(UnsafeGetAndAddInt, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getAndAddInt", "(Ljava/lang/Object;JI)I") \
V(UnsafeGetAndAddLong, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getAndAddLong", "(Ljava/lang/Object;JJ)J") \
V(UnsafeGetAndSetInt, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getAndSetInt", "(Ljava/lang/Object;JI)I") \
V(UnsafeGetAndSetLong, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getAndSetLong", "(Ljava/lang/Object;JJ)J") \
V(UnsafeGetAndSetObject, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "getAndSetObject", "(Ljava/lang/Object;JLjava/lang/Object;)Ljava/lang/Object;") \
V(UnsafeLoadFence, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "loadFence", "()V") \
V(UnsafeStoreFence, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "storeFence", "()V") \
V(UnsafeFullFence, kVirtual, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Lsun/misc/Unsafe;", "fullFence", "()V") \
V(ReferenceGetReferent, kDirect, kNeedsEnvironmentOrCache, kAllSideEffects, kCanThrow, "Ljava/lang/ref/Reference;", "getReferent", "()Ljava/lang/Object;") \
V(IntegerValueOf, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/lang/Integer;", "valueOf", "(I)Ljava/lang/Integer;") \
V(ThreadInterrupted, kStatic, kNeedsEnvironmentOrCache, kAllSideEffects, kNoThrow, "Ljava/lang/Thread;", "interrupted", "()Z") \
V(VarHandleFullFence, kStatic, kNeedsEnvironmentOrCache, kWriteSideEffects, kNoThrow, "Ljava/lang/invoke/VarHandle;", "fullFence", "()V") \
V(VarHandleAcquireFence, kStatic, kNeedsEnvironmentOrCache, kWriteSideEffects, kNoThrow, "Ljava/lang/invoke/VarHandle;", "acquireFence", "()V") \
V(VarHandleReleaseFence, kStatic, kNeedsEnvironmentOrCache, kWriteSideEffects, kNoThrow, "Ljava/lang/invoke/VarHandle;", "releaseFence", "()V") \
V(VarHandleLoadLoadFence, kStatic, kNeedsEnvironmentOrCache, kWriteSideEffects, kNoThrow, "Ljava/lang/invoke/VarHandle;", "loadLoadFence", "()V") \
V(VarHandleStoreStoreFence, kStatic, kNeedsEnvironmentOrCache, kReadSideEffects, kNoThrow, "Ljava/lang/invoke/VarHandle;", "storeStoreFence", "()V") \
V(ReachabilityFence, kStatic, kNeedsEnvironmentOrCache, kWriteSideEffects, kNoThrow, "Ljava/lang/ref/Reference;", "reachabilityFence", "(Ljava/lang/Object;)V") \
V(CRC32Update, kStatic, kNeedsEnvironmentOrCache, kNoSideEffects, kNoThrow, "Ljava/util/zip/CRC32;", "update", "(II)I") \
V(CRC32UpdateBytes, kStatic, kNeedsEnvironmentOrCache, kReadSideEffects, kCanThrow, "Ljava/util/zip/CRC32;", "updateBytes", "(I[BII)I") \
V(CRC32UpdateByteBuffer, kStatic, kNeedsEnvironmentOrCache, kReadSideEffects, kNoThrow, "Ljava/util/zip/CRC32;", "updateByteBuffer", "(IJII)I") \
SIGNATURE_POLYMORPHIC_INTRINSICS_LIST(V)
#endif // ART_RUNTIME_INTRINSICS_LIST_H_
#undef ART_RUNTIME_INTRINSICS_LIST_H_ // #define is only for lint.
| 119.528384 | 213 | 0.765929 |
d5a2547d5e200ba3cff2aad0a7a8bd4eca26bee8 | 1,221 | h | C | src/port/AbstractPort.h | xXRadioHeadXx/start7 | ebe399f6bf1a68b6ad57e33de50cc2a61577a046 | [
"Apache-2.0"
] | null | null | null | src/port/AbstractPort.h | xXRadioHeadXx/start7 | ebe399f6bf1a68b6ad57e33de50cc2a61577a046 | [
"Apache-2.0"
] | null | null | null | src/port/AbstractPort.h | xXRadioHeadXx/start7 | ebe399f6bf1a68b6ad57e33de50cc2a61577a046 | [
"Apache-2.0"
] | null | null | null | #ifndef ABSTRACTPORT_H
#define ABSTRACTPORT_H
#include <QObject>
class QSettings;
enum Protocol {
UDP = 0
};
class AbstractPort : public QObject
{
Q_OBJECT
public:
enum Protocol {
UDP = 0,
TCP = 1,
SERIAL = 2
};
AbstractPort::Protocol protocol = AbstractPort::UDP;
AbstractPort::Protocol getProtocol() const {return protocol;}
void setProtocol(const AbstractPort::Protocol &value) { protocol = value; }
explicit AbstractPort(const AbstractPort::Protocol &protocol, QObject *parent = nullptr) : QObject(parent), protocol(protocol) {}
virtual void retranslate() {}
virtual void loadConfig(QSettings *config) = 0;
virtual void saveConfig(QSettings *config) = 0;
virtual bool open() = 0;
virtual void close() = 0;
// virtual QByteArray readAll() = 0;
// virtual void write(const QByteArray &data) = 0;
virtual bool portStatus(QString *string) = 0;
virtual bool isOpen() = 0;
signals:
void readyRead();
void portError();
void portChanged();
void readyRead(int index);
void portError(int index);
void portChanged(int index);
};
#endif // ABSTRACTPORT_H
| 24.42 | 134 | 0.641278 |
b9b6fd5d5f636a015e61b1ce3d96655f01097aff | 760 | h | C | aaaa/src/main/cpp/ru_exlmoto_aaaa_AAAANativeLibProxy.h | EXL/AdamantArmorAffectionAdventure | 77a407ebc34e9f6e6878be51a27d03be4d06db63 | [
"MIT"
] | 4 | 2017-04-26T18:23:01.000Z | 2020-01-13T15:42:52.000Z | aaaa/src/main/cpp/ru_exlmoto_aaaa_AAAANativeLibProxy.h | EXL/AdamantArmorAffectionAdventure | 77a407ebc34e9f6e6878be51a27d03be4d06db63 | [
"MIT"
] | null | null | null | aaaa/src/main/cpp/ru_exlmoto_aaaa_AAAANativeLibProxy.h | EXL/AdamantArmorAffectionAdventure | 77a407ebc34e9f6e6878be51a27d03be4d06db63 | [
"MIT"
] | 3 | 2017-09-20T11:13:16.000Z | 2020-07-12T07:10:53.000Z | /* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class ru_exlmoto_aaaa_AAAANativeLibProxy */
#ifndef _Included_ru_exlmoto_aaaa_AAAANativeLibProxy
#define _Included_ru_exlmoto_aaaa_AAAANativeLibProxy
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: ru_exlmoto_aaaa_AAAANativeLibProxy
* Method: AAAAJoystickButtonDown
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_ru_exlmoto_aaaa_AAAANativeLibProxy_AAAAJoystickButtonDown
(JNIEnv *, jclass, jint);
/*
* Class: ru_exlmoto_aaaa_AAAANativeLibProxy
* Method: AAAAJoystickButtonUp
* Signature: (I)V
*/
JNIEXPORT void JNICALL Java_ru_exlmoto_aaaa_AAAANativeLibProxy_AAAAJoystickButtonUp
(JNIEnv *, jclass, jint);
#ifdef __cplusplus
}
#endif
#endif
| 25.333333 | 85 | 0.786842 |
02cd22f5a10f03c72c3d9c640de8da4afa5bd70a | 9,361 | h | C | xapian/xapian-core-1.2.13/common/omenquireinternal.h | pgs7179/xapian_modified | 0229c9efb9eca19be4c9f463cd4b793672f24198 | [
"MIT"
] | 2 | 2021-01-13T21:17:42.000Z | 2021-01-13T21:17:42.000Z | xapian/xapian-core-1.2.13/common/omenquireinternal.h | Loslove55/tailbench | fbbf3f31e3f0af1bb7db7f07c2e7193b84abb1eb | [
"MIT"
] | null | null | null | xapian/xapian-core-1.2.13/common/omenquireinternal.h | Loslove55/tailbench | fbbf3f31e3f0af1bb7db7f07c2e7193b84abb1eb | [
"MIT"
] | null | null | null | /* omenquireinternal.h: Internals
*
* Copyright 1999,2000,2001 BrightStation PLC
* Copyright 2001,2002 Ananova Ltd
* Copyright 2002,2003,2004,2005,2006,2007,2008,2009,2010 Olly Betts
* Copyright 2009 Lemur Consulting Ltd
* Copyright 2011 Action Without Borders
*
* 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 St, Fifth Floor, Boston, MA 02110-1301
* USA
*/
#ifndef OM_HGUARD_OMENQUIREINTERNAL_H
#define OM_HGUARD_OMENQUIREINTERNAL_H
#include "xapian/database.h"
#include "xapian/document.h"
#include "xapian/enquire.h"
#include "xapian/query.h"
#include "xapian/keymaker.h"
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
using namespace std;
class OmExpand;
class MultiMatch;
namespace Xapian {
class ErrorHandler;
class TermIterator;
namespace Internal {
/** An item resulting from a query.
* This item contains the document id, and the weight calculated for
* the document.
*/
class MSetItem {
public:
MSetItem(Xapian::weight wt_, Xapian::docid did_)
: wt(wt_), did(did_), collapse_count(0) {}
MSetItem(Xapian::weight wt_, Xapian::docid did_, const string &key_)
: wt(wt_), did(did_), collapse_key(key_), collapse_count(0) {}
MSetItem(Xapian::weight wt_, Xapian::docid did_, const string &key_,
Xapian::doccount collapse_count_)
: wt(wt_), did(did_), collapse_key(key_),
collapse_count(collapse_count_) {}
void swap(MSetItem & o) {
std::swap(wt, o.wt);
std::swap(did, o.did);
std::swap(collapse_key, o.collapse_key);
std::swap(collapse_count, o.collapse_count);
std::swap(sort_key, o.sort_key);
}
/** Weight calculated. */
Xapian::weight wt;
/** Document id. */
Xapian::docid did;
/** Value which was used to collapse upon.
*
* If the collapse option is not being used, this will always
* have a null value.
*
* If the collapse option is in use, this will contain the collapse
* key's value for this particular item. If the key is not present
* for this item, the value will be a null string. Only one instance
* of each key value (apart from the null string) will be present in
* the items in the returned Xapian::MSet.
*/
string collapse_key;
/** Count of collapses done on collapse_key so far
*
* This is normally 0, and goes up for each collapse done
* It is not necessarily an indication of how many collapses
* might be done if an exhaustive match was done
*/
Xapian::doccount collapse_count;
/** Used when sorting by value. */
string sort_key;
/// Return a string describing this object.
string get_description() const;
};
}
/** Internals of enquire system.
* This allows the implementation of Xapian::Enquire to be hidden and reference
* counted.
*/
class Enquire::Internal : public Xapian::Internal::RefCntBase {
private:
/// The database which this enquire object uses.
const Xapian::Database db;
/// The user's query.
Query query;
/// The query length.
termcount qlen;
/// Copy not allowed
Internal(const Internal &);
/// Assignment not allowed
void operator=(const Internal &);
public:
typedef enum { REL, VAL, VAL_REL, REL_VAL } sort_setting;
Xapian::valueno collapse_key;
Xapian::doccount collapse_max;
Xapian::Enquire::docid_order order;
percent percent_cutoff;
Xapian::weight weight_cutoff;
Xapian::valueno sort_key;
sort_setting sort_by;
bool sort_value_forward;
KeyMaker * sorter;
/** The error handler, if set. (0 if not set).
*/
ErrorHandler * errorhandler;
/** The weight to use for this query.
*
* This is mutable so that the default BM25Weight object can be
* created lazily when first required.
*/
mutable Weight * weight;
vector<MatchSpy *> spies;
Internal(const Xapian::Database &databases, ErrorHandler * errorhandler_);
~Internal();
/** Request a document from the database.
*/
void request_doc(const Xapian::Internal::MSetItem &item) const;
/** Read a previously requested document from the database.
*/
Xapian::Document read_doc(const Xapian::Internal::MSetItem &item) const;
void set_query(const Query & query_, termcount qlen_);
const Query & get_query();
MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems,
Xapian::doccount check_at_least,
const RSet *omrset,
const MatchDecider *mdecider,
const MatchDecider *matchspy_legacy) const;
ESet get_eset(Xapian::termcount maxitems, const RSet & omrset, int flags,
double k, const ExpandDecider *edecider, Xapian::weight min_wt) const;
TermIterator get_matching_terms(Xapian::docid did) const;
TermIterator get_matching_terms(const Xapian::MSetIterator &it) const;
Xapian::doccount get_termfreq(const string &tname) const;
string get_description() const;
};
class MSet::Internal : public Xapian::Internal::RefCntBase {
public:
/// Factor to multiply weights by to convert them to percentages.
double percent_factor;
private:
/** The set of documents which have been requested but not yet
* collected.
*/
mutable set<Xapian::doccount> requested_docs;
/// Cache of documents, indexed by MSet index.
mutable map<Xapian::doccount, Xapian::Document> indexeddocs;
/// Read and cache the documents so far requested.
void read_docs() const;
/// Copy not allowed
Internal(const Internal &);
/// Assignment not allowed
void operator=(const Internal &);
public:
/// Xapian::Enquire reference, for getting documents.
Xapian::Internal::RefCntPtr<const Enquire::Internal> enquire;
/** A structure containing the term frequency and weight for a
* given query term.
*/
struct TermFreqAndWeight {
TermFreqAndWeight() { }
explicit TermFreqAndWeight(Xapian::doccount tf)
: termfreq(tf), termweight(0.0) { }
TermFreqAndWeight(Xapian::doccount tf, Xapian::weight wt)
: termfreq(tf), termweight(wt) { }
Xapian::doccount termfreq;
Xapian::weight termweight;
};
/** The term frequencies and weights returned by the match process.
*
* This map contains information for each term which was in
* the query.
*/
map<string, TermFreqAndWeight> termfreqandwts;
/// A list of items comprising the (selected part of the) MSet.
vector<Xapian::Internal::MSetItem> items;
/// Rank of first item in MSet.
Xapian::doccount firstitem;
Xapian::doccount matches_lower_bound;
Xapian::doccount matches_estimated;
Xapian::doccount matches_upper_bound;
Xapian::doccount uncollapsed_lower_bound;
Xapian::doccount uncollapsed_estimated;
Xapian::doccount uncollapsed_upper_bound;
Xapian::weight max_possible;
Xapian::weight max_attained;
Internal()
: percent_factor(0),
firstitem(0),
matches_lower_bound(0),
matches_estimated(0),
matches_upper_bound(0),
uncollapsed_lower_bound(0),
uncollapsed_estimated(0),
uncollapsed_upper_bound(0),
max_possible(0),
max_attained(0) {}
/// Note: destroys parameter items.
Internal(Xapian::doccount firstitem_,
Xapian::doccount matches_upper_bound_,
Xapian::doccount matches_lower_bound_,
Xapian::doccount matches_estimated_,
Xapian::doccount uncollapsed_upper_bound_,
Xapian::doccount uncollapsed_lower_bound_,
Xapian::doccount uncollapsed_estimated_,
Xapian::weight max_possible_,
Xapian::weight max_attained_,
vector<Xapian::Internal::MSetItem> &items_,
const map<string, TermFreqAndWeight> &termfreqandwts_,
Xapian::weight percent_factor_)
: percent_factor(percent_factor_),
termfreqandwts(termfreqandwts_),
firstitem(firstitem_),
matches_lower_bound(matches_lower_bound_),
matches_estimated(matches_estimated_),
matches_upper_bound(matches_upper_bound_),
uncollapsed_lower_bound(uncollapsed_lower_bound_),
uncollapsed_estimated(uncollapsed_estimated_),
uncollapsed_upper_bound(uncollapsed_upper_bound_),
max_possible(max_possible_),
max_attained(max_attained_) {
std::swap(items, items_);
}
/// get a document by index in MSet, via the cache.
Xapian::Document get_doc_by_index(Xapian::doccount index) const;
/// Converts a weight to a percentage weight
percent convert_to_percent_internal(Xapian::weight wt) const;
/// Return a string describing this object.
string get_description() const;
/** Fetch items specified into the document cache.
*/
void fetch_items(Xapian::doccount first, Xapian::doccount last) const;
};
class RSet::Internal : public Xapian::Internal::RefCntBase {
friend class Xapian::RSet;
private:
/// Items in the relevance set.
set<Xapian::docid> items;
public:
const set<Xapian::docid> & get_items() const { return items; }
/// Return a string describing this object.
string get_description() const;
};
}
#endif // OM_HGUARD_OMENQUIREINTERNAL_H
| 28.195783 | 80 | 0.728768 |
461dc4512f14dc580d88fee1ef8d040cab500b62 | 1,827 | h | C | src/quanodemodelitemtraits.h | juangburgos/QUaServerWidgets | bb7cd456e2d378ef3d468ae2e563d219a88c56aa | [
"MIT"
] | 3 | 2020-09-21T05:22:17.000Z | 2021-11-05T08:31:48.000Z | src/quanodemodelitemtraits.h | juangburgos/QUaServerWidgets | bb7cd456e2d378ef3d468ae2e563d219a88c56aa | [
"MIT"
] | null | null | null | src/quanodemodelitemtraits.h | juangburgos/QUaServerWidgets | bb7cd456e2d378ef3d468ae2e563d219a88c56aa | [
"MIT"
] | 1 | 2021-11-04T21:17:03.000Z | 2021-11-04T21:17:03.000Z | #ifndef QUANODEMODELITEMTRAITS_H
#define QUANODEMODELITEMTRAITS_H
#include <QUaBaseVariable>
#include <QUaModelItemTraits>
// specialized implementation for QUaNode*
template<>
inline QMetaObject::Connection
QUaModelItemTraits::DestroyCallback<QUaNode*, 0>(
QUaNode* node,
const std::function<void(void)> &callback)
{
if (!node)
{
return QMetaObject::Connection();
}
return QObject::connect(node, &QObject::destroyed,
[callback]() {
callback();
});
}
template<>
inline QMetaObject::Connection
QUaModelItemTraits::NewChildCallback<QUaNode*, 0>(
QUaNode* node,
const std::function<void(QUaNode*)> &callback)
{
if (!node)
{
return QMetaObject::Connection();
}
return QObject::connect(node, &QUaNode::childAdded,
[callback](QUaNode* child) {
callback(child);
});
}
template<>
inline QList<QUaNode*>
QUaModelItemTraits::GetChildren<QUaNode*, 0>(QUaNode* node)
{
if (!node)
{
return QList<QUaNode*>();
}
return node->browseChildren();
}
// overload to support default editor (QStyledItemDelegate::setEditorData)
// implement either this or ui->myview->setColumnEditor
// setColumnEditor has preference in case both implemented
template<>
inline bool
QUaModelItemTraits::SetData<QUaNode*, 0>(
QUaNode* node,
const int& column,
const QVariant& value)
{
Q_UNUSED(column);
QString strType(node->metaObject()->className());
// only set value for variables
if (strType.compare("QUaProperty", Qt::CaseSensitive) != 0 &&
strType.compare("QUaBaseDataVariable", Qt::CaseSensitive) != 0)
{
return false;
}
auto var = qobject_cast<QUaBaseVariable*>(node);
Q_CHECK_PTR(var);
var->setValue(value);
return true;
}
#endif // QUANODEMODELITEMTRAITS_H
| 23.727273 | 74 | 0.676519 |
f232fac01fe678daaf45cd4031b127aec0cd78c5 | 3,284 | h | C | src/controller/queue.h | ielomariala/RetroFish-MVC-Model | 4cd38ece1b23ee629d1e00943964677c740ce939 | [
"MIT"
] | 1 | 2021-09-18T00:40:51.000Z | 2021-09-18T00:40:51.000Z | src/controller/queue.h | ielomariala/RetroFish-MVC-Model | 4cd38ece1b23ee629d1e00943964677c740ce939 | [
"MIT"
] | null | null | null | src/controller/queue.h | ielomariala/RetroFish-MVC-Model | 4cd38ece1b23ee629d1e00943964677c740ce939 | [
"MIT"
] | null | null | null | /*
* Simple queue definitions.
*/
#define SIMPLEQ_HEAD(name, type) \
struct name { \
struct type *sqh_first; /* first element */ \
struct type **sqh_last; /* addr of last next element */ \
}
#define SIMPLEQ_HEAD_INITIALIZER(head) \
{ NULL, &(head).sqh_first }
#define SIMPLEQ_ENTRY(type) \
struct { \
struct type *sqe_next; /* next element */ \
}
/*
* Simple queue access methods.
*/
#define SIMPLEQ_FIRST(head) ((head)->sqh_first)
#define SIMPLEQ_END(head) NULL
#define SIMPLEQ_EMPTY(head) ((head)->sqh_first == SIMPLEQ_END(head))
#define SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
#define SIMPLEQ_FOREACH(var, head, field) \
for ((var) = ((head)->sqh_first); \
(var) != SIMPLEQ_END(head); \
(var) = ((var)->field.sqe_next))
#define SIMPLEQ_FOREACH_SAFE(var, head, field, next) \
for ((var) = ((head)->sqh_first); \
(var) != SIMPLEQ_END(head) && \
((next = ((var)->field.sqe_next)), 1); \
(var) = (next))
/*
* Simple queue functions.
*/
#define SIMPLEQ_INIT(head) do { \
(head)->sqh_first = NULL; \
(head)->sqh_last = &(head)->sqh_first; \
} while (/*CONSTCOND*/0)
#define SIMPLEQ_INSERT_HEAD(head, elm, field) do { \
if (((elm)->field.sqe_next = (head)->sqh_first) == NULL) \
(head)->sqh_last = &(elm)->field.sqe_next; \
(head)->sqh_first = (elm); \
} while (/*CONSTCOND*/0)
#define SIMPLEQ_INSERT_TAIL(head, elm, field) do { \
(elm)->field.sqe_next = NULL; \
*(head)->sqh_last = (elm); \
(head)->sqh_last = &(elm)->field.sqe_next; \
} while (/*CONSTCOND*/0)
#define SIMPLEQ_INSERT_AFTER(head, listelm, elm, field) do { \
if (((elm)->field.sqe_next = (listelm)->field.sqe_next) == NULL)\
(head)->sqh_last = &(elm)->field.sqe_next; \
(listelm)->field.sqe_next = (elm); \
} while (/*CONSTCOND*/0)
#define SIMPLEQ_REMOVE_HEAD(head, field) do { \
if (((head)->sqh_first = (head)->sqh_first->field.sqe_next) == NULL) \
(head)->sqh_last = &(head)->sqh_first; \
} while (/*CONSTCOND*/0)
#define SIMPLEQ_REMOVE_AFTER(head, elm, field) do { \
if (((elm)->field.sqe_next = (elm)->field.sqe_next->field.sqe_next) \
== NULL) \
(head)->sqh_last = &(elm)->field.sqe_next; \
} while (/*CONSTCOND*/0)
#define SIMPLEQ_REMOVE(head, elm, type, field) do { \
if ((head)->sqh_first == (elm)) { \
SIMPLEQ_REMOVE_HEAD((head), field); \
} else { \
struct type *curelm = (head)->sqh_first; \
while (curelm->field.sqe_next != (elm)) \
curelm = curelm->field.sqe_next; \
if ((curelm->field.sqe_next = \
curelm->field.sqe_next->field.sqe_next) == NULL) \
(head)->sqh_last = &(curelm)->field.sqe_next; \
} \
} while (/*CONSTCOND*/0)
#define SIMPLEQ_CONCAT(head1, head2) do { \
if (!SIMPLEQ_EMPTY((head2))) { \
*(head1)->sqh_last = (head2)->sqh_first; \
(head1)->sqh_last = (head2)->sqh_last; \
SIMPLEQ_INIT((head2)); \
} \
} while (/*CONSTCOND*/0)
#define SIMPLEQ_LAST(head, type, field) \
(SIMPLEQ_EMPTY((head)) ? \
NULL : \
((struct type *)(void *) \
((char *)((head)->sqh_last) - offsetof(struct type, field))))
| 32.84 | 72 | 0.5743 |
f272710dc96348ee19c3f07aedcb171d6fb0f1bd | 1,439 | h | C | SKVersionNumber.h | marcocpt/skim-app | ffb967ab7092e4269fc9592e7dbb801156f4d0df | [
"BSD-3-Clause"
] | null | null | null | SKVersionNumber.h | marcocpt/skim-app | ffb967ab7092e4269fc9592e7dbb801156f4d0df | [
"BSD-3-Clause"
] | null | null | null | SKVersionNumber.h | marcocpt/skim-app | ffb967ab7092e4269fc9592e7dbb801156f4d0df | [
"BSD-3-Clause"
] | null | null | null | //
// SKVersionNumber.h
// Skim
//
// Created by Christiaan Hofman on 2/15/07.
// Much of this code is copied and modified from OmniFoundation/OFVersionNumber and subject to the following copyright.
// Copyright 2004-2008 Omni Development, Inc. All rights reserved.
//
// This software may only be used and reproduced according to the
// terms in the file OmniSourceLicense.html, which should be
// distributed with this project and can also be found at
// <http://www.omnigroup.com/developer/sourcecode/sourcelicense/>.
//
// $Header$
#import <Foundation/Foundation.h>
enum {
SKReleaseVersionType,
SKReleaseCandidateVersionType,
SKBetaVersionType,
SKDevelopmentVersionType,
SKAlphaVersionType,
};
@interface SKVersionNumber : NSObject <NSCopying>
{
NSString *originalVersionString;
NSString *cleanVersionString;
NSUInteger componentCount;
NSInteger *components;
NSInteger releaseType;
}
+ (id)versionNumberWithVersionString:(NSString *)versionString;
- (id)initWithVersionString:(NSString *)versionString;
- (NSString *)originalVersionString;
- (NSString *)cleanVersionString;
- (NSUInteger)componentCount;
- (NSInteger)componentAtIndex:(NSUInteger)componentIndex;
- (NSInteger)releaseType;
- (BOOL)isRelease;
- (BOOL)isReleaseCandidate;
- (BOOL)isDevelopment;
- (BOOL)isBeta;
- (BOOL)isAlpha;
- (NSComparisonResult)compareToVersionNumber:(SKVersionNumber *)otherVersion;
@end
| 24.810345 | 119 | 0.758165 |
d14075b40caab3ae01d4cfd5892ca4dfe4fac2fd | 2,893 | h | C | P2P/nssocket.h | hbhzwj/zetasim | 55e6bc3d0db7949abbac222dbe2502e85072c6cb | [
"BSD-4-Clause-UC"
] | 1 | 2017-11-04T22:00:48.000Z | 2017-11-04T22:00:48.000Z | P2P/nssocket.h | hbhzwj/zetasim | 55e6bc3d0db7949abbac222dbe2502e85072c6cb | [
"BSD-4-Clause-UC"
] | null | null | null | P2P/nssocket.h | hbhzwj/zetasim | 55e6bc3d0db7949abbac222dbe2502e85072c6cb | [
"BSD-4-Clause-UC"
] | null | null | null | /* nssocket.h
* Jing Wang
* June, 2010
ZetaSim - A NS2 based Simulation suit for Zeta Protocol
Copright (C) 2010 Jing Wang
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Jing Wang
Department of Electronics and Information Engineering
Huazhong University of Science and Technology
Wuhan, Hubei, 430074
hbhzwj@gmail.com
*/
#ifndef NS_SOCKET_H
#define NS_SOCKET_H
#include "TypeDefine.h"
#include "udp.h"
#include <iostream>
#define MIN_INTERVAL_BETWEEN_TWO_PACKETS 0.002
typedef NodeAddr_t IpAddress;
typedef Port_t Port;
class ZetaMsger;
class NSSocket : public UdpAgent { // this socket APIs are based on UDP protocol, need to be changed in later version
public:
NSSocket () : UdpAgent(PT_ZETA) {
bind("packetSize_", &size_);
bind("dst_addr_", &dst_.addr_);
bind("dst_port_", &dst_.port_);
bind("agent_addr_", &here_.addr_);
bind("agent_port_", &here_.port_);
}
NSSocket (Application *app ) : UdpAgent(PT_ZETA) {
app_ = app;
bind("packetSize_", &size_);
bind("dst_addr_", &dst_.addr_);
bind("dst_port_", &dst_.port_);
bind("agent_addr_", &here_.addr_);
bind("agent_port_", &here_.port_);
}
RunState_t Bind (NodeAddr_t addr, Port_t port);
void connect (NodeAddr_t addr, Port_t port);
void SendPkt(Packet *p, Handler* h, const char* flags =0);
void SendPktTo (Packet *p, std::string name);
void SendPktTo (Packet* pkt, NodeAddr_t peerAddress, Port_t peerPort);
void SendMsgTo (unsigned int nbytes, PacketData* data, NodeAddr_t addr, Port_t port);
virtual void recv (Packet *pkt, Handler*);
void SetMsger (ZetaMsger* msger) { msger_ = msger; }
ZetaMsger *GetMsger() { return msger_; }
protected:
virtual int command(int argc, const char*const* argv) {
return ( UdpAgent::command(argc, argv) );
}
void debug(DebugLevel level, const char *fmt, ...);
protected:
ZetaMsger *msger_;
double schedulerSendTime;
};
typedef NSSocket Socket;
static class NSSocketClass : public TclClass {
public:
NSSocketClass() : TclClass("Agent/NSSocket") {}
TclObject* create(int, const char* const*) {
return (new NSSocket());
}
} class_ns_socket;
#endif
| 32.144444 | 117 | 0.707916 |
fa7f0616868caef8ba84d3ce2dd99bc06925e3be | 322 | c | C | Mod02-C/03-Perfect.c | kambleaa007/PG-DBDA | 2aeec3af5cb0b73b3a33e19e6007082fd56f9a04 | [
"MIT"
] | 12 | 2018-09-14T06:34:29.000Z | 2022-03-22T12:02:06.000Z | Mod02-C/03-Perfect.c | kambleaa007/PG-DBDA | 2aeec3af5cb0b73b3a33e19e6007082fd56f9a04 | [
"MIT"
] | null | null | null | Mod02-C/03-Perfect.c | kambleaa007/PG-DBDA | 2aeec3af5cb0b73b3a33e19e6007082fd56f9a04 | [
"MIT"
] | 4 | 2019-03-11T07:29:29.000Z | 2022-01-26T17:13:59.000Z | #include<stdio.h>
int main(){
int number,rem,sum=0,i;
printf("Enter a number \n");
scanf("%d",&number);
for(i=1;i<=(number-1);i++){
rem=number % i;
if(rem == 0){
sum = sum + i;
}
}
if(sum == number)
printf("Entered number is perfect number");
else
printf("Entered number is not perfect");
return 0;
}
| 17.888889 | 45 | 0.596273 |
7adce59fbcd32281102127769feb7520b04ead4f | 1,039 | h | C | master/xchat-gnome-0.1/xchat-2.0.8/src/common/text.h | AlexRogalskiy/DevArtifacts | 931aabb8cbf27656151c54856eb2ea7d1153203a | [
"MIT"
] | 4 | 2018-09-07T15:35:24.000Z | 2019-03-27T09:48:12.000Z | master/xchat-gnome-0.1/xchat-2.0.8/src/common/text.h | AlexRogalskiy/DevArtifacts | 931aabb8cbf27656151c54856eb2ea7d1153203a | [
"MIT"
] | 371 | 2020-03-04T21:51:56.000Z | 2022-03-31T20:59:11.000Z | master/xchat-gnome-0.1/xchat-2.0.8/src/common/text.h | AlexRogalskiy/DevArtifacts | 931aabb8cbf27656151c54856eb2ea7d1153203a | [
"MIT"
] | 3 | 2019-06-18T19:57:17.000Z | 2020-11-06T03:55:08.000Z | #include "textenums.h"
#ifndef XCHAT_TEXT_H
#define XCHAT_TEXT_H
#define EMIT_SIGNAL(i, sess, a, b, c, d, e) text_emit(i, sess, a, b, c, d)
#define WORD_URL 1
#define WORD_NICK 2
#define WORD_CHANNEL 3
#define WORD_HOST 4
#define WORD_EMAIL 5
#define WORD_DIALOG -1
struct text_event
{
char *name;
char **help;
int num_args;
char *sound;
char *def;
};
int text_word_check (char *word);
void PrintText (session *sess, char *text);
void PrintTextf (session *sess, char *format, ...);
void log_close (session *sess);
void log_open (session *sess);
void load_text_events (void);
void pevent_save (char *fn);
int pevt_build_string (const char *input, char **output, int *max_arg);
int pevent_load (char *filename);
void pevent_make_pntevts (void);
void text_emit (int index, session *sess, char *a, char *b, char *c, char *d);
int text_emit_by_name (char *name, session *sess, char *a, char *b, char *c, char *d);
char *text_validate (char **text, int *len);
int get_stamp_str (char *fmt, time_t tim, char **ret);
#endif
| 26.641026 | 86 | 0.708373 |
7a25976971d6c35ff9fac581e2f3df3a5413a072 | 24,341 | h | C | Kernel/Particles/BaseParticle.h | gustavo-castillo-bautista/Mercury | eeb402ccec8e487652229d4595c46ec84f6aefbb | [
"BSD-3-Clause"
] | null | null | null | Kernel/Particles/BaseParticle.h | gustavo-castillo-bautista/Mercury | eeb402ccec8e487652229d4595c46ec84f6aefbb | [
"BSD-3-Clause"
] | null | null | null | Kernel/Particles/BaseParticle.h | gustavo-castillo-bautista/Mercury | eeb402ccec8e487652229d4595c46ec84f6aefbb | [
"BSD-3-Clause"
] | null | null | null | //Copyright (c) 2013-2020, The MercuryDPM Developers Team. All rights reserved.
//For the list of developers, see <http://www.MercuryDPM.org/Team>.
//
//Redistribution and use in source and binary forms, with or without
//modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name MercuryDPM nor the
// names of its contributors may be used to endorse or promote products
// derived from this software without specific prior written permission.
//
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
//ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
//DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
//DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
//ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
//(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef BASEPARTICLE_H
#define BASEPARTICLE_H
#include <vector>
#include "Math/Vector.h"
#include "BaseInteractable.h"
#include "HGridCell.h"
#include "Species/ParticleSpecies.h"
class ParticleHandler;
class SpeciesHandler;
class HGrid;
class BaseInteraction;
#ifdef CONTACT_LIST_HGRID
class PossibleContact;
#endif
/*!
* \class BaseParticle
* \brief
* \details Since r3648, BaseParticle is an abstract class. Use
* SphericalParticle for a 'basic' particle.
*/
class BaseParticle : public BaseInteractable
{
public:
/*!
* \brief Basic Particle constructor, creates an Particle at (0,0,0) with radius, mass and inertia equal to 1
*/
BaseParticle();
/*!
* \brief Particle copy constructor, which accepts as input a reference to a Particle. It creates a copy of this Particle and all it's information. Usually it is better to use the copy() function for polymorfism.
*/
BaseParticle(const BaseParticle& p);
explicit BaseParticle(const ParticleSpecies* s);
/*!
* \brief Particle destructor, needs to be implemented and checked if it removes tangential spring information
*/
~BaseParticle() override;
/*!
* \brief Particle copy method. It calls to copy constructor of this Particle, useful for polymorfism
*/
virtual BaseParticle* copy() const = 0;
/*!
* \brief Get Particle volume function, which required a reference to the Species vector. It returns the volume of the Particle.
*/
virtual Mdouble getVolume() const;
/*!
* \brief Fix Particle function. It fixes a Particle by setting its inverse mass and inertia and velocities to zero
*/
void fixParticle();
/*!
* \brief Is fixed Particle function. It returns whether a Particle is fixed or not, by checking its inverse Mass.
* \details Checks whether a BaseParticle is fixed or not, by checking its inverse Mass.
* \return TRUE if particle is fixed, i.e. if the inverse mass (invMass_) is 0.
*/
bool isFixed() const override
{ return (invMass_ == 0.0); }
/*!
* \brief Indicates if this particle is a ghost in the MPI domain
*/
bool isMPIParticle() const;
/*!
* \brief Flags the mpi particle status
*/
void setMPIParticle(bool flag);
/*!
* \brief Indicates if the particle is in the communication zone of the mpi domain
*/
bool isInMPIDomain();
/*!
* \brief Flags the status of the particle if wether it is in the communication zone or not
*/
void setInMPIDomain(bool flag);
/*!
* \brief Indicates if the particle is in the periodic boundary communication zone
*/
bool isInPeriodicDomain() const;
/*!
* \brief Flags the status of the particle wether it is in the periodic communication zone or not
*/
void setInPeriodicDomain(bool flag);
/*!
* \brief Indicates if this particle is a ghost in the periodic boundary
*/
bool isPeriodicGhostParticle() const;
/*!
* \brief Flags the status of the particle to be a ghost in periodic boundary or not
*/
void setPeriodicGhostParticle(bool flag);
/*!
* \brief Indicates if this particle belongs to the maser boundary
*/
bool isMaserParticle() const;
/*!
* \brief Flags the status of the particle if it belongs to the maser boundary or not
*/
void setMaserParticle(bool flag);
/*!
* \brief Set the communication complexity of the particle
*/
void setCommunicationComplexity(unsigned complexity);
/*!
* \brief Obtains the communication complexity of the particle
*/
unsigned getCommunicationComplexity();
/*!
* \brief Set the periodic communication complexity of the particle
*/
void setPeriodicComplexity(std::vector<int> complexity);
/*!
* \brief Set the periodic communication complexity of the particle
*/
void setPeriodicComplexity(int index, int value);
/*!
* \brief Obtains the periodic communication complexity of the particle
*/
const std::vector<int>& getPeriodicComplexity();
/*!
* \brief Set the previous periodic communication complexity of the paritcle
*/
void setPreviousPeriodicComplexity(std::vector<int> complexity);
/*!
* \brief Sets the previous periodic communication complexity of the particle
*/
const std::vector<int>& getPreviousPeriodicComplexity() const;
/*!
* \brief Gets the periodic communication complexity of a certain boundary
*/
int getPeriodicComplexity(int index);
//void setCurrentPeriodicPosition(Vec3D position);
//Vec3D getCurrentPeriodicPosition();
/*!
* \brief Unfix Particle function, which required a reference to the Species vector. It unfixes a Particle by computing the Particles mass and inertia
*/
void unfix();
/*!
* \brief Particle read function, which accepts an std::istream as input.
*/
void read(std::istream& is) override;
/*!
* Should NOT BE USED by any user, only used to read old restart files!
* Is expected to be obsolete by Mercury 2.0. Please use BaseParticle::read() instead.
*/
virtual void oldRead(std::istream& is);
/*!
* \brief Particle print function, which accepts an std::ostream as input.
*/
void write(std::ostream& os) const override;
/*!
* \brief Returns the name of the object
*/
std::string getName() const override;
/*!
* \brief Sets some user-defined information about this object (by default, species ID).
*/
virtual void setInfo(Mdouble info);
/*!
* \brief Returns some user-defined information about this object (by default, species ID).
*/
virtual Mdouble getInfo() const;
/*!
* \brief Adds particle's HGrid level and cell coordinates to an ostream
*/
void printHGrid(std::ostream& os) const;
/*!
* \brief Returns particle's HGrid level
*/
unsigned int getHGridLevel() const
{ return hGridCell.getHGridLevel(); }
/*!
* \brief Returns pointer to next object in particle's HGrid level & cell
* \details Returns the next object in the particle's HGrid cell
* \return pointer to the next object in the particle's HGrid cell
*/
BaseParticle* getHGridNextObject() const
{ return hGridNextObject_; }
/*!
* \brief Returns pointer to previous object in particle's HGrid level & cell
* \details Returns the previous object in the particle's HGrid cell
* \return pointer to the previous object in the particle's HGrid cell
*/
BaseParticle* getHGridPrevObject() const
{ return hGridPrevObject_; }
#ifdef CONTACT_LIST_HGRID
/*!
* \brief
*/
PossibleContact* getFirstPossibleContact() const;
#endif
/*!
* \brief Returns particle's HGrid cell X-coordinate
* \return the particle's HGrid cell's X-coordinate
*/
int getHGridX() const
{ return hGridCell.getHGridX(); }
/*!
* \brief Returns particle's HGrid cell Y-coordinate
* \return the particle's HGrid cell's Y-coordinate
*/
int getHGridY() const
{ return hGridCell.getHGridY(); }
/*!
* \brief Returns particle's HGrid cell Z-coordinate
* \return the particle's HGrid cell's Z-coordinate
*/
int getHGridZ() const
{ return hGridCell.getHGridZ(); }
/*!
* \brief Returns the inverse of the particle's inertia tensor
* \return the inverse of the particle's inertia tensor
*/
MatrixSymmetric3D getInvInertia() const
{ return invInertia_; }
/*!
* \brief Returns the inverse of the particle's mass
* \return the inverse of the particle's mass
*/
Mdouble getInvMass() const override
{ return invMass_; }
Mdouble getCurvature(const Vec3D& labFixedCoordinates) const override
{ return 1.0/radius_; }
/*!
* \brief Calculates the particle's translational kinetic energy
* \return the particle's translational kinetic energy
*/
Mdouble getKineticEnergy() const;
/*!
* \brief Calculates the particle's rotational kinetic energy
* \return the particle's rotational kinetic energy
*/
Mdouble getRotationalEnergy() const;
/*!
* \brief Calculates the particle's gravitational energy
* \details Gravitational energy is the potential energy stored in teh particles position due to the gravity field. This is a relative term, so we need to define what zero energy means: The gravitational energy of a particle is zero when its center of mass is at the origin.
* \return the particle's gravitational energy
*/
Mdouble getGravitationalEnergy() const;
/*!
* \brief Returns the particle's mass
* \return the mass of the particle
*/
Mdouble getMass() const
{ return 1.0 / invMass_; }
Vec3D getMomentum() const
{ return getVelocity() / invMass_; }
MatrixSymmetric3D getInertia() const
{ return invInertia_.inverse(); }
Vec3D getAngularMomentum() const;
/*!
* \brief Returns the 'original' particle this one's a periodic copy of
* \details Returns a pointer to the 'original' particle if the current one is a 'periodic copy' used for a periodic boundary implementation.
\return pointer to original particle
*/
BaseParticle* getPeriodicFromParticle() const
{ return periodicFromParticle_; }
/*!
* \brief Returns the particle's radius
* \return the particle's radius
*/
Mdouble getRadius() const
{ return radius_; }
/*!
* \brief Returns the particle's interaction radius, which might be different
* from radius_ (e.g., when dealing with wet particles)
* \details Calculates the interaction radius of the particle (when it comes to
* interaction with other particles), including the effect of a possible additional
* 'interaction distance' besides the 'normal' radius. The interaction radius
* differs from the radius_, for example, when dealing with wet particles (i.e.
* particles with an additional liquid layer, which is dealt with in the particle's
* species).
* \return the particle's interaction radius for particle-particle interaction
*/
Mdouble getMaxInteractionRadius() const {
return getRadius() + getSpecies()->getMaxInteractionDistance() * 0.5;
}
/**
* \brief Returns the interactionDistance_ of the mixed species of this particle and the particle or wall i
*/
Mdouble getInteractionDistance(const BaseInteractable* i) const
{
//const auto mixedSpecies = getSpecies()->getHandler()->getMixedObject(getSpecies(),particle->getSpecies());
//return mixedSpecies->getInteractionDistance();
return getSpecies()->getMixedSpecies(i->getSpecies())->getInteractionDistance();
}
/**
* \brief returns the sum of the radii plus the interactionDistance
*/
Mdouble getSumOfInteractionRadii(const BaseParticle* particle) const {
return getRadius() + particle->getRadius() + getInteractionDistance((const BaseInteractable*)particle);
}
/**
* \brief returns the radius plus the interactionDistance
*/
Mdouble getWallInteractionRadius(const BaseWall* wall) const {
return getRadius() + getInteractionDistance((const BaseInteractable*)wall);
}
/*!
* \brief Returns the particle's displacement relative to the previous time step
* \details Returns the particle's displacement_, which is the difference between the current particle's position and its position in the previous time step.
* \return (reference to) the particle displacement vector
*/
const Vec3D& getDisplacement() const
{ return displacement_; }
/*!
* \brief Returns the particle's position in the previous time step
* \details Returns the particle's position in the previous time step.
* \return (reference to) the previous position of the particle
*/
const Vec3D& getPreviousPosition() const
{ return previousPosition_; }
/*!
* \brief
* \todo see .cc file.
* \TWH
*/
const Vec3D getDisplacement2(Mdouble xmin, Mdouble xmax, Mdouble ymin, Mdouble ymax, Mdouble zmin, Mdouble zmax,
Mdouble t) const;
/*!
* \brief
*/
virtual void setInertia();
/*!
* \brief Sets the particle's inertia_ (and adjusts invInertia_ accordingly)
*/
void setInertia(MatrixSymmetric3D inertia);
/*!
* \brief Sets the particle's inertia_ (and adjusts invInertia_ accordingly)
*/
void setInverseInertia(MatrixSymmetric3D inverseInertia);
/*!
* \brief Sets the particle's inertia_ to 'infinite' (1e20) and its invInertia_
* to 0.
*/
void setInfiniteInertia();
/*!
* \brief Assigns the pointer to the 'original' particle this one's a
* periodic copy of (used in periodic boundary condition implementations).
* \param[in] p pointer to the 'original' particle this one is a periodic copy of.
*
*/
void setPeriodicFromParticle(BaseParticle* p)
{ periodicFromParticle_ = p; };
/*!
* \brief Sets the particle's HGrid cell X-coordinate
* \details Set the x-index of the particle's hGrid cell position
* \param[in] x x-index of particle's HGrid cell
*/
void setHGridX(const int x)
{ hGridCell.setHGridX(x); }
/*!
* \brief Sets the particle's HGrid cell Y-coordinate
* \details Set the y-index of the particle's hGrid cell position
* \param[in] y y-index of particle's HGrid cell
*/
void setHGridY(const int y)
{ hGridCell.setHGridY(y); }
/*!
* \brief Sets the particle's HGrid cell Z-coordinate
* \details Set the y-index of the particle's hGrid cell position
* \param[in] z z-index of particle's HGrid cell
*/
void setHGridZ(const int z)
{ hGridCell.setHGridZ(z); }
/*!
* \brief Sets the particle's HGrid level
* \param[in] level the particle's HGrid level
*/
void setHGridLevel(const unsigned int level)
{ hGridCell.setHGridLevel(level); }
/*!
* \brief Sets the pointer to the next object in the particle's HGrid cell
* & level.
* \param[in] p pointer to the next object
*/
void setHGridNextObject(BaseParticle* p)
{ hGridNextObject_ = p; }
/*!
* \brief Sets the pointer to the previous object in the particle's HGrid cell
* & level.
* \param[in] p pointer to the previous object
*/
void setHGridPrevObject(BaseParticle* p)
{ hGridPrevObject_ = p; }
#ifdef CONTACT_LIST_HGRID
/*!
* \brief
*/
void setFirstPossibleContact(PossibleContact* PC);
#endif
/*!
* \brief Sets the particle's radius_ (and adjusts the mass_ accordingly,
* based on the particle's species)
*/
virtual void setRadius(Mdouble radius);
/*
* The below 6 functions had to be declared virtual here in order to allow access of these functions in ParticleHandler class in the function writeVTK.
*/
/*!
* \brief Only ustilised in case of superquadric particles. Had to create a virtual function to allow function access in writeVTK function in the particle handler.
*/
virtual Vec3D getAxes() const;
/*!
* \brief Only ustilised in case of superquadric particles. Had to create a virtual function to allow function access in writeVTK function in the particle handler.
*/
virtual Mdouble getExponentEps1() const;
/*!
* \brief Only ustilised in case of superquadric particles. Had to create a virtual function to allow function access in writeVTK function in the particle handler.
*/
virtual Mdouble getExponentEps2() const;
/*!
* \brief Only ustilised in case of superquadric particles.
*/
virtual void setAxes(const Vec3D& axes){ }
/*!
* \brief Only ustilised in case of superquadric particles.
*/
virtual void setExponents(const Mdouble& eps1, const Mdouble& eps2){}
//
/*!
* \brief Sets the particle's mass
* \deprecated Please do not set the mass yourself, but use
* ParticleSpecies->computeMass instead. That makes sure
*/
MERCURY_DEPRECATED
void setMass(Mdouble mass);
/*!
* \brief Sets the particle's mass
* This function should not be used, but is necessary to extend the CG
* toolbox to non-spherical particles.
*/
void setMassForP3Statistics(Mdouble mass);
/*!
* \brief Sets the particle's displacement (= difference between current
* position and that of the previous time step)
*/
void setDisplacement(const Vec3D& disp);
/*!
* \brief Sets the particle's position in the previous time step
*/
void setPreviousPosition(const Vec3D& pos);
/*!
* \brief Adds a vector to the particle's previousPosition_
*/
void movePrevious(const Vec3D& posMove);
/*!
* \brief Increases the particle's velocity_ by the given vector
*/
void accelerate(const Vec3D& vel);
/*!
* \brief Increases the particle's angularVelocity_ by the given vector
*/
void angularAccelerate(const Vec3D& angVel);
/*!
* \brief Adds a vector to the particle's displacement_
*/
void addDisplacement(const Vec3D& addDisp);
/*!
* \brief Sets the pointer to the particle's ParticleHandler
*/
void setHandler(ParticleHandler* handler);
/*!
* \brief Returns pointer to the particle's ParticleHandler
*/
ParticleHandler* getHandler() const;
/*!
* \brief Checks if particle is in interaction with given particle P, and if
* so, returns vector of pointer to the associated BaseInteraction object (else returns empty vector).
*/
BaseInteraction* getInteractionWith(BaseParticle* P, unsigned timeStamp, InteractionHandler* interactionHandler) override;
/*!
* \brief Get whether or not this particle is in contact with the given particle.
*/
virtual bool isInContactWith(const BaseParticle* P) const;
/*!
* \brief First step of <a href="http://en.wikipedia.org/wiki/Verlet_integration#Velocity_Verlet">Velocity Verlet</a>
* integration.
*
*/
void integrateBeforeForceComputation(double time, double timeStep);
/*!
* \brief Second step of <a href="http://en.wikipedia.org/wiki/Verlet_integration#Velocity_Verlet">Velocity Verlet</a>
* integration.
*/
void integrateAfterForceComputation(double time, double timeStep);
/*!
* \brief Returns the particle's dimensions (either 2 or 3).
*/
unsigned int getParticleDimensions() const;
/*!
* \deprecated Please use setSpecies(const ParticleSpecies*) instead.
*/
MERCURY_DEPRECATED
/// \todo MX: this index is used in the MPI transmission. This should be "undeprecated"
void setIndSpecies(unsigned int indSpecies) override;
/*!
* In addition to the functionality of BaseInteractable::setSpecies, this function sets the pointer to the
* particleHandler, which is needed to retrieve species information.
*/
///\todo TW: this function should also check if the particle is the correct particle for the species type
void setSpecies(const ParticleSpecies* species);
virtual unsigned getNumberOfFieldsVTK() const;
virtual std::string getTypeVTK(unsigned i) const;
virtual std::string getNameVTK(unsigned i) const;
virtual std::vector<Mdouble> getFieldVTK(unsigned i) const;
virtual void actionsAfterTimeStep()
{};
virtual bool isSphericalParticle() const {return false;}
//const HGridCell& getHGridCell() const;
const HGridCell& getHGridCell() const
{ return hGridCell; }
virtual void computeMass(const ParticleSpecies& s);
protected:
Mdouble radius_; ///Particle radius_
Mdouble invMass_; ///Inverse Particle mass (for computation optimization)
MatrixSymmetric3D invInertia_; ///Inverse Particle inverse inertia (for computation optimization)
private:
/*!
* \brief Pointer to the particle's ParticleHandler container
*/
ParticleHandler* handler_;
#ifdef CONTACT_LIST_HGRID
/*!
* \brief
*/
PossibleContact* firstPossibleContact;
#endif
/// All hGrid-information: the cell (x,y,z,level), and the previous and next particle in this cell compared to this
/// particle
HGridCell hGridCell;
BaseParticle* hGridNextObject_; ///Pointer to the next Particle in the same HGrid cell
BaseParticle* hGridPrevObject_; ///Pointer to the previous Particle in the same HGrid cell
///Particle attributes
BaseParticle* periodicFromParticle_; ///Pointer to originating Particle
//MPI particle attributes
bool isMPIParticle_; /// returns true if the particle acts as an MPI particle instead of a real particle
bool isInMPIDomain_; /// returns true if it flagged as being in MPI domain
unsigned communicationComplexity_; //Determins if the particle in the corner of a domain, rib, side or not at all
//Periodic boundary particle attributes
bool isInPeriodicDomain_; /// bool that indicates if a particle is in the periodic domain of any boundary
bool isPeriodicGhostParticle_; /// Indicates if the particle is a ghost particle of a periodic particle
std::vector<int> previousPeriodicComplexity_; /// Indicates the periodic complexity at previous time step
std::vector<int> periodicComplexity_; /// Indicates the periodic complexity at current time step. Used to update periodic status
bool isMaserParticle_; ///Indicates if this particle belongs to the maser boundary or is released into the wide open world.
Vec3D displacement_; ///Displacement (only used in StatisticsVector, StatisticsPoint)
Vec3D previousPosition_; /// Particle's position at previous time step
/*!
* Since ParticleSpecies is allowed to set the mass of a BaseParticle, it is
* a friend of this class.
*/
friend void ParticleSpecies::computeMass(BaseParticle*) const;
Mdouble info_; // by default, the species ID (if a species is set)
};
#endif
| 34.477337 | 278 | 0.673514 |
4f4cb4925eafe0e5c630dcbe91bdcd980674e922 | 168 | h | C | Pods/Target Support Files/Pods-AdMobSampleUITests/Pods-AdMobSampleUITests-umbrella.h | WorldDownTown/AdMobSample | eec92a5e71ee83b4eea4a029a8c6640bfbe38483 | [
"MIT"
] | 1 | 2018-01-15T08:07:33.000Z | 2018-01-15T08:07:33.000Z | Pods/Target Support Files/Pods-AdMobSampleUITests/Pods-AdMobSampleUITests-umbrella.h | WorldDownTown/AdMobSample | eec92a5e71ee83b4eea4a029a8c6640bfbe38483 | [
"MIT"
] | null | null | null | Pods/Target Support Files/Pods-AdMobSampleUITests/Pods-AdMobSampleUITests-umbrella.h | WorldDownTown/AdMobSample | eec92a5e71ee83b4eea4a029a8c6640bfbe38483 | [
"MIT"
] | null | null | null | #import <UIKit/UIKit.h>
FOUNDATION_EXPORT double Pods_AdMobSampleUITestsVersionNumber;
FOUNDATION_EXPORT const unsigned char Pods_AdMobSampleUITestsVersionString[];
| 24 | 77 | 0.869048 |
9451f2a69a79bd7be124374bb503d91adffba10f | 35,731 | c | C | stage0/stdlib/Std/Data/PersistentHashSet.c | 4e554c4c/lean4 | 162062b3dedecdfcd796cc3da9ffba26e74b7ddd | [
"Apache-2.0"
] | null | null | null | stage0/stdlib/Std/Data/PersistentHashSet.c | 4e554c4c/lean4 | 162062b3dedecdfcd796cc3da9ffba26e74b7ddd | [
"Apache-2.0"
] | null | null | null | stage0/stdlib/Std/Data/PersistentHashSet.c | 4e554c4c/lean4 | 162062b3dedecdfcd796cc3da9ffba26e74b7ddd | [
"Apache-2.0"
] | 1 | 2021-04-23T09:35:46.000Z | 2021-04-23T09:35:46.000Z | // Lean compiler output
// Module: Std.Data.PersistentHashSet
// Imports: Init Std.Data.PersistentHashMap
#include <lean/lean.h>
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wunused-label"
#elif defined(__GNUC__) && !defined(__CLANG__)
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
#ifdef __cplusplus
extern "C" {
#endif
lean_object* l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_foldM___spec__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_instInhabitedPersistentHashSet___rarg(lean_object*, lean_object*);
size_t l_USize_add(size_t, size_t);
uint8_t l_USize_decEq(size_t, size_t);
lean_object* lean_array_uget(lean_object*, size_t);
lean_object* l_Std_PersistentHashSet_size(lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_foldM___spec__2___rarg___lambda__2___boxed(lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_fold___spec__5(lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_foldM___spec__4___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Array_foldlMUnsafe___at_Std_PersistentHashSet_foldM___spec__3___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_foldM___spec__4___rarg___lambda__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_instEmptyCollectionPersistentHashSet___rarg(lean_object*, lean_object*);
uint8_t l_Std_PersistentHashSet_isEmpty___rarg(lean_object*);
lean_object* lean_array_get_size(lean_object*);
lean_object* l_Std_PersistentHashSet_fold___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_find_x3f(lean_object*);
lean_object* l_Std_PersistentHashSet_fold___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_fold___spec__2___rarg___lambda__1(lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_find_x3f___rarg(lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* lean_nat_add(lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_foldM___spec__1___rarg(lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_foldM___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_empty___rarg(lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_instInhabitedPersistentHashSet___rarg___boxed(lean_object*, lean_object*);
lean_object* lean_array_fget(lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_contains(lean_object*);
lean_object* l_Std_PersistentHashSet_isEmpty___rarg___boxed(lean_object*);
lean_object* l_Std_PersistentHashSet_contains___rarg(lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_fold___spec__1___rarg(lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_contains___rarg(lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_foldM___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_insert(lean_object*);
lean_object* l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_fold___spec__5___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_find_x3f_match__1(lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_fold___spec__2(lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_find_x3f_match__1___rarg(lean_object*, lean_object*, lean_object*);
lean_object* l_Array_foldlMUnsafe___at_Std_PersistentHashSet_foldM___spec__3___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_foldM___spec__2(lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_fold___spec__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Array_foldlMUnsafe_fold___at_Std_PersistentHashSet_fold___spec__4(lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_size___boxed(lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_empty(lean_object*);
lean_object* l_Array_foldlMUnsafe___at_Std_PersistentHashSet_fold___spec__3(lean_object*, lean_object*);
lean_object* l_Array_foldlMUnsafe_fold___rarg(lean_object*, lean_object*, lean_object*, size_t, size_t, lean_object*);
lean_object* l_Std_PersistentHashSet_instEmptyCollectionPersistentHashSet(lean_object*);
lean_object* l_Std_PersistentHashSet_erase(lean_object*);
lean_object* l_Std_PersistentHashSet_erase___rarg(lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_size___rarg___boxed(lean_object*);
lean_object* l_Array_foldlMUnsafe_fold___at_Std_PersistentHashSet_fold___spec__4___rarg(lean_object*, lean_object*, size_t, size_t, lean_object*);
lean_object* l_Array_foldlMUnsafe___at_Std_PersistentHashSet_fold___spec__3___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_foldM(lean_object*);
lean_object* l_Std_PersistentHashMap_insert___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_foldM___spec__1___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_isEmpty___boxed(lean_object*, lean_object*, lean_object*);
size_t lean_usize_of_nat(lean_object*);
lean_object* l_Std_PersistentHashSet_instInhabitedPersistentHashSet(lean_object*);
lean_object* l_Std_PersistentHashMap_findEntry_x3f___rarg(lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_insert___rarg(lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_fold(lean_object*);
lean_object* l_Std_PersistentHashSet_isEmpty(lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_fold___spec__2___rarg(lean_object*, lean_object*, lean_object*);
uint8_t lean_nat_dec_le(lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_size___rarg(lean_object*);
lean_object* l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_fold___spec__1(lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_empty___rarg(lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_erase___rarg(lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_foldM___spec__4___rarg___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_fold___spec__2___rarg___boxed(lean_object*, lean_object*, lean_object*);
lean_object* l_Array_foldlMUnsafe___at_Std_PersistentHashSet_fold___spec__3___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_foldM___spec__2___rarg(lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_foldM___spec__2___rarg___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_fold___spec__5___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Array_foldlMUnsafe___at_Std_PersistentHashSet_foldM___spec__3(lean_object*, lean_object*, lean_object*);
lean_object* l_Array_foldlMUnsafe_fold___at_Std_PersistentHashSet_fold___spec__4___rarg___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_foldM___spec__2___rarg___lambda__2(lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_instEmptyCollectionPersistentHashSet___rarg___boxed(lean_object*, lean_object*);
lean_object* l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_fold___spec__1___rarg___boxed(lean_object*, lean_object*, lean_object*);
uint8_t l_Std_PersistentHashMap_isEmpty___rarg(lean_object*);
lean_object* l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_foldM___spec__4(lean_object*, lean_object*);
lean_object* l_Std_PersistentHashSet_empty___rarg___boxed(lean_object*, lean_object*);
uint8_t lean_nat_dec_lt(lean_object*, lean_object*);
uint8_t l_Std_PersistentHashSet_isEmpty___rarg(lean_object* x_1) {
_start:
{
uint8_t x_2;
x_2 = l_Std_PersistentHashMap_isEmpty___rarg(x_1);
return x_2;
}
}
lean_object* l_Std_PersistentHashSet_isEmpty(lean_object* x_1, lean_object* x_2, lean_object* x_3) {
_start:
{
lean_object* x_4;
x_4 = lean_alloc_closure((void*)(l_Std_PersistentHashSet_isEmpty___rarg___boxed), 1, 0);
return x_4;
}
}
lean_object* l_Std_PersistentHashSet_isEmpty___rarg___boxed(lean_object* x_1) {
_start:
{
uint8_t x_2; lean_object* x_3;
x_2 = l_Std_PersistentHashSet_isEmpty___rarg(x_1);
lean_dec(x_1);
x_3 = lean_box(x_2);
return x_3;
}
}
lean_object* l_Std_PersistentHashSet_isEmpty___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) {
_start:
{
lean_object* x_4;
x_4 = l_Std_PersistentHashSet_isEmpty(x_1, x_2, x_3);
lean_dec(x_3);
lean_dec(x_2);
return x_4;
}
}
lean_object* l_Std_PersistentHashSet_empty___rarg(lean_object* x_1, lean_object* x_2) {
_start:
{
lean_object* x_3;
x_3 = l_Std_PersistentHashMap_empty___rarg(x_1, x_2);
return x_3;
}
}
lean_object* l_Std_PersistentHashSet_empty(lean_object* x_1) {
_start:
{
lean_object* x_2;
x_2 = lean_alloc_closure((void*)(l_Std_PersistentHashSet_empty___rarg___boxed), 2, 0);
return x_2;
}
}
lean_object* l_Std_PersistentHashSet_empty___rarg___boxed(lean_object* x_1, lean_object* x_2) {
_start:
{
lean_object* x_3;
x_3 = l_Std_PersistentHashSet_empty___rarg(x_1, x_2);
lean_dec(x_2);
lean_dec(x_1);
return x_3;
}
}
lean_object* l_Std_PersistentHashSet_instInhabitedPersistentHashSet___rarg(lean_object* x_1, lean_object* x_2) {
_start:
{
lean_object* x_3;
x_3 = l_Std_PersistentHashMap_empty___rarg(x_1, x_2);
return x_3;
}
}
lean_object* l_Std_PersistentHashSet_instInhabitedPersistentHashSet(lean_object* x_1) {
_start:
{
lean_object* x_2;
x_2 = lean_alloc_closure((void*)(l_Std_PersistentHashSet_instInhabitedPersistentHashSet___rarg___boxed), 2, 0);
return x_2;
}
}
lean_object* l_Std_PersistentHashSet_instInhabitedPersistentHashSet___rarg___boxed(lean_object* x_1, lean_object* x_2) {
_start:
{
lean_object* x_3;
x_3 = l_Std_PersistentHashSet_instInhabitedPersistentHashSet___rarg(x_1, x_2);
lean_dec(x_2);
lean_dec(x_1);
return x_3;
}
}
lean_object* l_Std_PersistentHashSet_instEmptyCollectionPersistentHashSet___rarg(lean_object* x_1, lean_object* x_2) {
_start:
{
lean_object* x_3;
x_3 = l_Std_PersistentHashMap_empty___rarg(x_1, x_2);
return x_3;
}
}
lean_object* l_Std_PersistentHashSet_instEmptyCollectionPersistentHashSet(lean_object* x_1) {
_start:
{
lean_object* x_2;
x_2 = lean_alloc_closure((void*)(l_Std_PersistentHashSet_instEmptyCollectionPersistentHashSet___rarg___boxed), 2, 0);
return x_2;
}
}
lean_object* l_Std_PersistentHashSet_instEmptyCollectionPersistentHashSet___rarg___boxed(lean_object* x_1, lean_object* x_2) {
_start:
{
lean_object* x_3;
x_3 = l_Std_PersistentHashSet_instEmptyCollectionPersistentHashSet___rarg(x_1, x_2);
lean_dec(x_2);
lean_dec(x_1);
return x_3;
}
}
lean_object* l_Std_PersistentHashSet_insert___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) {
_start:
{
lean_object* x_5; lean_object* x_6;
x_5 = lean_box(0);
x_6 = l_Std_PersistentHashMap_insert___rarg(x_1, x_2, x_3, x_4, x_5);
return x_6;
}
}
lean_object* l_Std_PersistentHashSet_insert(lean_object* x_1) {
_start:
{
lean_object* x_2;
x_2 = lean_alloc_closure((void*)(l_Std_PersistentHashSet_insert___rarg), 4, 0);
return x_2;
}
}
lean_object* l_Std_PersistentHashSet_erase___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) {
_start:
{
lean_object* x_5;
x_5 = l_Std_PersistentHashMap_erase___rarg(x_1, x_2, x_3, x_4);
return x_5;
}
}
lean_object* l_Std_PersistentHashSet_erase(lean_object* x_1) {
_start:
{
lean_object* x_2;
x_2 = lean_alloc_closure((void*)(l_Std_PersistentHashSet_erase___rarg), 4, 0);
return x_2;
}
}
lean_object* l_Std_PersistentHashSet_find_x3f_match__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) {
_start:
{
if (lean_obj_tag(x_1) == 0)
{
lean_object* x_4; lean_object* x_5;
lean_dec(x_2);
x_4 = lean_box(0);
x_5 = lean_apply_1(x_3, x_4);
return x_5;
}
else
{
lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9;
lean_dec(x_3);
x_6 = lean_ctor_get(x_1, 0);
lean_inc(x_6);
lean_dec(x_1);
x_7 = lean_ctor_get(x_6, 0);
lean_inc(x_7);
x_8 = lean_ctor_get(x_6, 1);
lean_inc(x_8);
lean_dec(x_6);
x_9 = lean_apply_2(x_2, x_7, x_8);
return x_9;
}
}
}
lean_object* l_Std_PersistentHashSet_find_x3f_match__1(lean_object* x_1, lean_object* x_2) {
_start:
{
lean_object* x_3;
x_3 = lean_alloc_closure((void*)(l_Std_PersistentHashSet_find_x3f_match__1___rarg), 3, 0);
return x_3;
}
}
lean_object* l_Std_PersistentHashSet_find_x3f___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) {
_start:
{
lean_object* x_5;
x_5 = l_Std_PersistentHashMap_findEntry_x3f___rarg(x_1, x_2, x_3, x_4);
if (lean_obj_tag(x_5) == 0)
{
lean_object* x_6;
x_6 = lean_box(0);
return x_6;
}
else
{
uint8_t x_7;
x_7 = !lean_is_exclusive(x_5);
if (x_7 == 0)
{
lean_object* x_8; lean_object* x_9;
x_8 = lean_ctor_get(x_5, 0);
x_9 = lean_ctor_get(x_8, 0);
lean_inc(x_9);
lean_dec(x_8);
lean_ctor_set(x_5, 0, x_9);
return x_5;
}
else
{
lean_object* x_10; lean_object* x_11; lean_object* x_12;
x_10 = lean_ctor_get(x_5, 0);
lean_inc(x_10);
lean_dec(x_5);
x_11 = lean_ctor_get(x_10, 0);
lean_inc(x_11);
lean_dec(x_10);
x_12 = lean_alloc_ctor(1, 1, 0);
lean_ctor_set(x_12, 0, x_11);
return x_12;
}
}
}
}
lean_object* l_Std_PersistentHashSet_find_x3f(lean_object* x_1) {
_start:
{
lean_object* x_2;
x_2 = lean_alloc_closure((void*)(l_Std_PersistentHashSet_find_x3f___rarg), 4, 0);
return x_2;
}
}
lean_object* l_Std_PersistentHashSet_contains___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) {
_start:
{
lean_object* x_5;
x_5 = l_Std_PersistentHashMap_contains___rarg(x_1, x_2, x_3, x_4);
return x_5;
}
}
lean_object* l_Std_PersistentHashSet_contains(lean_object* x_1) {
_start:
{
lean_object* x_2;
x_2 = lean_alloc_closure((void*)(l_Std_PersistentHashSet_contains___rarg), 4, 0);
return x_2;
}
}
lean_object* l_Std_PersistentHashSet_size___rarg(lean_object* x_1) {
_start:
{
lean_object* x_2;
x_2 = lean_ctor_get(x_1, 1);
lean_inc(x_2);
return x_2;
}
}
lean_object* l_Std_PersistentHashSet_size(lean_object* x_1, lean_object* x_2, lean_object* x_3) {
_start:
{
lean_object* x_4;
x_4 = lean_alloc_closure((void*)(l_Std_PersistentHashSet_size___rarg___boxed), 1, 0);
return x_4;
}
}
lean_object* l_Std_PersistentHashSet_size___rarg___boxed(lean_object* x_1) {
_start:
{
lean_object* x_2;
x_2 = l_Std_PersistentHashSet_size___rarg(x_1);
lean_dec(x_1);
return x_2;
}
}
lean_object* l_Std_PersistentHashSet_size___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) {
_start:
{
lean_object* x_4;
x_4 = l_Std_PersistentHashSet_size(x_1, x_2, x_3);
lean_dec(x_3);
lean_dec(x_2);
return x_4;
}
}
lean_object* l_Array_foldlMUnsafe___at_Std_PersistentHashSet_foldM___spec__3___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) {
_start:
{
uint8_t x_7;
x_7 = lean_nat_dec_lt(x_5, x_6);
if (x_7 == 0)
{
lean_object* x_8; lean_object* x_9; lean_object* x_10;
lean_dec(x_4);
lean_dec(x_2);
x_8 = lean_ctor_get(x_1, 0);
lean_inc(x_8);
lean_dec(x_1);
x_9 = lean_ctor_get(x_8, 1);
lean_inc(x_9);
lean_dec(x_8);
x_10 = lean_apply_2(x_9, lean_box(0), x_3);
return x_10;
}
else
{
lean_object* x_11; uint8_t x_12;
x_11 = lean_array_get_size(x_4);
x_12 = lean_nat_dec_le(x_6, x_11);
lean_dec(x_11);
if (x_12 == 0)
{
lean_object* x_13; lean_object* x_14; lean_object* x_15;
lean_dec(x_4);
lean_dec(x_2);
x_13 = lean_ctor_get(x_1, 0);
lean_inc(x_13);
lean_dec(x_1);
x_14 = lean_ctor_get(x_13, 1);
lean_inc(x_14);
lean_dec(x_13);
x_15 = lean_apply_2(x_14, lean_box(0), x_3);
return x_15;
}
else
{
size_t x_16; size_t x_17; lean_object* x_18;
x_16 = lean_usize_of_nat(x_5);
x_17 = lean_usize_of_nat(x_6);
x_18 = l_Array_foldlMUnsafe_fold___rarg(x_1, x_2, x_4, x_16, x_17, x_3);
return x_18;
}
}
}
}
lean_object* l_Array_foldlMUnsafe___at_Std_PersistentHashSet_foldM___spec__3(lean_object* x_1, lean_object* x_2, lean_object* x_3) {
_start:
{
lean_object* x_4;
x_4 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe___at_Std_PersistentHashSet_foldM___spec__3___rarg___boxed), 6, 0);
return x_4;
}
}
lean_object* l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_foldM___spec__4___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) {
_start:
{
lean_object* x_7; lean_object* x_8; lean_object* x_9;
x_7 = lean_unsigned_to_nat(1u);
x_8 = lean_nat_add(x_1, x_7);
x_9 = l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_foldM___spec__4___rarg(x_2, lean_box(0), x_3, x_4, x_5, lean_box(0), x_8, x_6);
return x_9;
}
}
lean_object* l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_foldM___spec__4___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) {
_start:
{
lean_object* x_9; uint8_t x_10;
x_9 = lean_array_get_size(x_4);
x_10 = lean_nat_dec_lt(x_7, x_9);
lean_dec(x_9);
if (x_10 == 0)
{
lean_object* x_11; lean_object* x_12; lean_object* x_13;
lean_dec(x_7);
lean_dec(x_5);
lean_dec(x_4);
lean_dec(x_3);
x_11 = lean_ctor_get(x_1, 0);
lean_inc(x_11);
lean_dec(x_1);
x_12 = lean_ctor_get(x_11, 1);
lean_inc(x_12);
lean_dec(x_11);
x_13 = lean_apply_2(x_12, lean_box(0), x_8);
return x_13;
}
else
{
lean_object* x_14; lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; lean_object* x_19;
x_14 = lean_array_fget(x_4, x_7);
x_15 = lean_array_fget(x_5, x_7);
x_16 = lean_ctor_get(x_1, 1);
lean_inc(x_16);
lean_inc(x_3);
x_17 = lean_apply_3(x_3, x_8, x_14, x_15);
x_18 = lean_alloc_closure((void*)(l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_foldM___spec__4___rarg___lambda__1___boxed), 6, 5);
lean_closure_set(x_18, 0, x_7);
lean_closure_set(x_18, 1, x_1);
lean_closure_set(x_18, 2, x_3);
lean_closure_set(x_18, 3, x_4);
lean_closure_set(x_18, 4, x_5);
x_19 = lean_apply_4(x_16, lean_box(0), lean_box(0), x_17, x_18);
return x_19;
}
}
}
lean_object* l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_foldM___spec__4(lean_object* x_1, lean_object* x_2) {
_start:
{
lean_object* x_3;
x_3 = lean_alloc_closure((void*)(l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_foldM___spec__4___rarg), 8, 0);
return x_3;
}
}
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_foldM___spec__2___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) {
_start:
{
switch (lean_obj_tag(x_4)) {
case 0:
{
lean_object* x_5; lean_object* x_6;
lean_dec(x_2);
x_5 = lean_ctor_get(x_4, 0);
lean_inc(x_5);
lean_dec(x_4);
x_6 = lean_apply_2(x_1, x_3, x_5);
return x_6;
}
case 1:
{
lean_object* x_7; lean_object* x_8;
x_7 = lean_ctor_get(x_4, 0);
lean_inc(x_7);
lean_dec(x_4);
x_8 = l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_foldM___spec__2___rarg(x_2, x_1, x_7, x_3);
return x_8;
}
default:
{
lean_object* x_9; lean_object* x_10; lean_object* x_11;
lean_dec(x_1);
x_9 = lean_ctor_get(x_2, 0);
lean_inc(x_9);
lean_dec(x_2);
x_10 = lean_ctor_get(x_9, 1);
lean_inc(x_10);
lean_dec(x_9);
x_11 = lean_apply_2(x_10, lean_box(0), x_3);
return x_11;
}
}
}
}
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_foldM___spec__2___rarg___lambda__2(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) {
_start:
{
lean_object* x_5;
x_5 = lean_apply_2(x_1, x_2, x_3);
return x_5;
}
}
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_foldM___spec__2___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) {
_start:
{
if (lean_obj_tag(x_3) == 0)
{
lean_object* x_5; lean_object* x_6; lean_object* x_7; lean_object* x_8; lean_object* x_9;
x_5 = lean_ctor_get(x_3, 0);
lean_inc(x_5);
lean_dec(x_3);
lean_inc(x_1);
x_6 = lean_alloc_closure((void*)(l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_foldM___spec__2___rarg___lambda__1), 4, 2);
lean_closure_set(x_6, 0, x_2);
lean_closure_set(x_6, 1, x_1);
x_7 = lean_array_get_size(x_5);
x_8 = lean_unsigned_to_nat(0u);
x_9 = l_Array_foldlMUnsafe___at_Std_PersistentHashSet_foldM___spec__3___rarg(x_1, x_6, x_4, x_5, x_8, x_7);
lean_dec(x_7);
return x_9;
}
else
{
lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14;
x_10 = lean_ctor_get(x_3, 0);
lean_inc(x_10);
x_11 = lean_ctor_get(x_3, 1);
lean_inc(x_11);
lean_dec(x_3);
x_12 = lean_alloc_closure((void*)(l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_foldM___spec__2___rarg___lambda__2___boxed), 4, 1);
lean_closure_set(x_12, 0, x_2);
x_13 = lean_unsigned_to_nat(0u);
x_14 = l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_foldM___spec__4___rarg(x_1, lean_box(0), x_12, x_10, x_11, lean_box(0), x_13, x_4);
return x_14;
}
}
}
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_foldM___spec__2(lean_object* x_1, lean_object* x_2, lean_object* x_3) {
_start:
{
lean_object* x_4;
x_4 = lean_alloc_closure((void*)(l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_foldM___spec__2___rarg), 4, 0);
return x_4;
}
}
lean_object* l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_foldM___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) {
_start:
{
lean_object* x_5; lean_object* x_6;
x_5 = lean_ctor_get(x_3, 0);
lean_inc(x_5);
lean_dec(x_3);
x_6 = l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_foldM___spec__2___rarg(x_1, x_2, x_5, x_4);
return x_6;
}
}
lean_object* l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_foldM___spec__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) {
_start:
{
lean_object* x_6;
x_6 = lean_alloc_closure((void*)(l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_foldM___spec__1___rarg), 4, 0);
return x_6;
}
}
lean_object* l_Std_PersistentHashSet_foldM___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) {
_start:
{
lean_object* x_9;
x_9 = l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_foldM___spec__1___rarg(x_5, x_6, x_8, x_7);
return x_9;
}
}
lean_object* l_Std_PersistentHashSet_foldM(lean_object* x_1) {
_start:
{
lean_object* x_2;
x_2 = lean_alloc_closure((void*)(l_Std_PersistentHashSet_foldM___rarg___boxed), 8, 0);
return x_2;
}
}
lean_object* l_Array_foldlMUnsafe___at_Std_PersistentHashSet_foldM___spec__3___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) {
_start:
{
lean_object* x_7;
x_7 = l_Array_foldlMUnsafe___at_Std_PersistentHashSet_foldM___spec__3___rarg(x_1, x_2, x_3, x_4, x_5, x_6);
lean_dec(x_6);
lean_dec(x_5);
return x_7;
}
}
lean_object* l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_foldM___spec__4___rarg___lambda__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) {
_start:
{
lean_object* x_7;
x_7 = l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_foldM___spec__4___rarg___lambda__1(x_1, x_2, x_3, x_4, x_5, x_6);
lean_dec(x_1);
return x_7;
}
}
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_foldM___spec__2___rarg___lambda__2___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) {
_start:
{
lean_object* x_5;
x_5 = l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_foldM___spec__2___rarg___lambda__2(x_1, x_2, x_3, x_4);
lean_dec(x_4);
return x_5;
}
}
lean_object* l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_foldM___spec__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) {
_start:
{
lean_object* x_6;
x_6 = l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_foldM___spec__1(x_1, x_2, x_3, x_4, x_5);
lean_dec(x_3);
lean_dec(x_2);
return x_6;
}
}
lean_object* l_Std_PersistentHashSet_foldM___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6, lean_object* x_7, lean_object* x_8) {
_start:
{
lean_object* x_9;
x_9 = l_Std_PersistentHashSet_foldM___rarg(x_1, x_2, x_3, x_4, x_5, x_6, x_7, x_8);
lean_dec(x_2);
lean_dec(x_1);
return x_9;
}
}
lean_object* l_Array_foldlMUnsafe_fold___at_Std_PersistentHashSet_fold___spec__4___rarg(lean_object* x_1, lean_object* x_2, size_t x_3, size_t x_4, lean_object* x_5) {
_start:
{
uint8_t x_6;
x_6 = x_3 == x_4;
if (x_6 == 0)
{
lean_object* x_7; lean_object* x_8; size_t x_9; size_t x_10;
x_7 = lean_array_uget(x_2, x_3);
lean_inc(x_1);
x_8 = lean_apply_2(x_1, x_5, x_7);
x_9 = 1;
x_10 = x_3 + x_9;
x_3 = x_10;
x_5 = x_8;
goto _start;
}
else
{
lean_dec(x_1);
return x_5;
}
}
}
lean_object* l_Array_foldlMUnsafe_fold___at_Std_PersistentHashSet_fold___spec__4(lean_object* x_1, lean_object* x_2) {
_start:
{
lean_object* x_3;
x_3 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe_fold___at_Std_PersistentHashSet_fold___spec__4___rarg___boxed), 5, 0);
return x_3;
}
}
lean_object* l_Array_foldlMUnsafe___at_Std_PersistentHashSet_fold___spec__3___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) {
_start:
{
uint8_t x_6;
x_6 = lean_nat_dec_lt(x_4, x_5);
if (x_6 == 0)
{
lean_dec(x_1);
return x_2;
}
else
{
lean_object* x_7; uint8_t x_8;
x_7 = lean_array_get_size(x_3);
x_8 = lean_nat_dec_le(x_5, x_7);
lean_dec(x_7);
if (x_8 == 0)
{
lean_dec(x_1);
return x_2;
}
else
{
size_t x_9; size_t x_10; lean_object* x_11;
x_9 = lean_usize_of_nat(x_4);
x_10 = lean_usize_of_nat(x_5);
x_11 = l_Array_foldlMUnsafe_fold___at_Std_PersistentHashSet_fold___spec__4___rarg(x_1, x_3, x_9, x_10, x_2);
return x_11;
}
}
}
}
lean_object* l_Array_foldlMUnsafe___at_Std_PersistentHashSet_fold___spec__3(lean_object* x_1, lean_object* x_2) {
_start:
{
lean_object* x_3;
x_3 = lean_alloc_closure((void*)(l_Array_foldlMUnsafe___at_Std_PersistentHashSet_fold___spec__3___rarg___boxed), 5, 0);
return x_3;
}
}
lean_object* l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_fold___spec__5___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) {
_start:
{
lean_object* x_7; uint8_t x_8;
x_7 = lean_array_get_size(x_2);
x_8 = lean_nat_dec_lt(x_5, x_7);
lean_dec(x_7);
if (x_8 == 0)
{
lean_dec(x_5);
lean_dec(x_1);
return x_6;
}
else
{
lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13;
x_9 = lean_array_fget(x_2, x_5);
x_10 = lean_array_fget(x_3, x_5);
lean_inc(x_1);
x_11 = lean_apply_3(x_1, x_6, x_9, x_10);
x_12 = lean_unsigned_to_nat(1u);
x_13 = lean_nat_add(x_5, x_12);
lean_dec(x_5);
x_4 = lean_box(0);
x_5 = x_13;
x_6 = x_11;
goto _start;
}
}
}
lean_object* l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_fold___spec__5(lean_object* x_1, lean_object* x_2) {
_start:
{
lean_object* x_3;
x_3 = lean_alloc_closure((void*)(l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_fold___spec__5___rarg___boxed), 6, 0);
return x_3;
}
}
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_fold___spec__2___rarg___lambda__1(lean_object* x_1, lean_object* x_2, lean_object* x_3) {
_start:
{
switch (lean_obj_tag(x_3)) {
case 0:
{
lean_object* x_4; lean_object* x_5;
x_4 = lean_ctor_get(x_3, 0);
lean_inc(x_4);
lean_dec(x_3);
x_5 = lean_apply_2(x_1, x_2, x_4);
return x_5;
}
case 1:
{
lean_object* x_6; lean_object* x_7;
x_6 = lean_ctor_get(x_3, 0);
lean_inc(x_6);
lean_dec(x_3);
x_7 = l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_fold___spec__2___rarg(x_1, x_6, x_2);
lean_dec(x_6);
return x_7;
}
default:
{
lean_dec(x_1);
return x_2;
}
}
}
}
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_fold___spec__2___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) {
_start:
{
if (lean_obj_tag(x_2) == 0)
{
lean_object* x_4; lean_object* x_5; lean_object* x_6; lean_object* x_7; lean_object* x_8;
x_4 = lean_ctor_get(x_2, 0);
x_5 = lean_alloc_closure((void*)(l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_fold___spec__2___rarg___lambda__1), 3, 1);
lean_closure_set(x_5, 0, x_1);
x_6 = lean_array_get_size(x_4);
x_7 = lean_unsigned_to_nat(0u);
x_8 = l_Array_foldlMUnsafe___at_Std_PersistentHashSet_fold___spec__3___rarg(x_5, x_3, x_4, x_7, x_6);
lean_dec(x_6);
return x_8;
}
else
{
lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13;
x_9 = lean_ctor_get(x_2, 0);
x_10 = lean_ctor_get(x_2, 1);
x_11 = lean_alloc_closure((void*)(l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_foldM___spec__2___rarg___lambda__2___boxed), 4, 1);
lean_closure_set(x_11, 0, x_1);
x_12 = lean_unsigned_to_nat(0u);
x_13 = l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_fold___spec__5___rarg(x_11, x_9, x_10, lean_box(0), x_12, x_3);
return x_13;
}
}
}
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_fold___spec__2(lean_object* x_1, lean_object* x_2) {
_start:
{
lean_object* x_3;
x_3 = lean_alloc_closure((void*)(l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_fold___spec__2___rarg___boxed), 3, 0);
return x_3;
}
}
lean_object* l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_fold___spec__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) {
_start:
{
lean_object* x_4; lean_object* x_5;
x_4 = lean_ctor_get(x_2, 0);
x_5 = l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_fold___spec__2___rarg(x_1, x_4, x_3);
return x_5;
}
}
lean_object* l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_fold___spec__1(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) {
_start:
{
lean_object* x_5;
x_5 = lean_alloc_closure((void*)(l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_fold___spec__1___rarg___boxed), 3, 0);
return x_5;
}
}
lean_object* l_Std_PersistentHashSet_fold___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) {
_start:
{
lean_object* x_7;
x_7 = l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_fold___spec__1___rarg(x_4, x_6, x_5);
return x_7;
}
}
lean_object* l_Std_PersistentHashSet_fold(lean_object* x_1) {
_start:
{
lean_object* x_2;
x_2 = lean_alloc_closure((void*)(l_Std_PersistentHashSet_fold___rarg___boxed), 6, 0);
return x_2;
}
}
lean_object* l_Array_foldlMUnsafe_fold___at_Std_PersistentHashSet_fold___spec__4___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) {
_start:
{
size_t x_6; size_t x_7; lean_object* x_8;
x_6 = lean_unbox_usize(x_3);
lean_dec(x_3);
x_7 = lean_unbox_usize(x_4);
lean_dec(x_4);
x_8 = l_Array_foldlMUnsafe_fold___at_Std_PersistentHashSet_fold___spec__4___rarg(x_1, x_2, x_6, x_7, x_5);
lean_dec(x_2);
return x_8;
}
}
lean_object* l_Array_foldlMUnsafe___at_Std_PersistentHashSet_fold___spec__3___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) {
_start:
{
lean_object* x_6;
x_6 = l_Array_foldlMUnsafe___at_Std_PersistentHashSet_fold___spec__3___rarg(x_1, x_2, x_3, x_4, x_5);
lean_dec(x_5);
lean_dec(x_4);
lean_dec(x_3);
return x_6;
}
}
lean_object* l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_fold___spec__5___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) {
_start:
{
lean_object* x_7;
x_7 = l_Std_PersistentHashMap_foldlMAux_traverse___at_Std_PersistentHashSet_fold___spec__5___rarg(x_1, x_2, x_3, x_4, x_5, x_6);
lean_dec(x_3);
lean_dec(x_2);
return x_7;
}
}
lean_object* l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_fold___spec__2___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) {
_start:
{
lean_object* x_4;
x_4 = l_Std_PersistentHashMap_foldlMAux___at_Std_PersistentHashSet_fold___spec__2___rarg(x_1, x_2, x_3);
lean_dec(x_2);
return x_4;
}
}
lean_object* l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_fold___spec__1___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3) {
_start:
{
lean_object* x_4;
x_4 = l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_fold___spec__1___rarg(x_1, x_2, x_3);
lean_dec(x_2);
return x_4;
}
}
lean_object* l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_fold___spec__1___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) {
_start:
{
lean_object* x_5;
x_5 = l_Std_PersistentHashMap_foldlM___at_Std_PersistentHashSet_fold___spec__1(x_1, x_2, x_3, x_4);
lean_dec(x_3);
lean_dec(x_2);
return x_5;
}
}
lean_object* l_Std_PersistentHashSet_fold___rarg___boxed(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5, lean_object* x_6) {
_start:
{
lean_object* x_7;
x_7 = l_Std_PersistentHashSet_fold___rarg(x_1, x_2, x_3, x_4, x_5, x_6);
lean_dec(x_6);
lean_dec(x_2);
lean_dec(x_1);
return x_7;
}
}
lean_object* initialize_Init(lean_object*);
lean_object* initialize_Std_Data_PersistentHashMap(lean_object*);
static bool _G_initialized = false;
lean_object* initialize_Std_Data_PersistentHashSet(lean_object* w) {
lean_object * res;
if (_G_initialized) return lean_io_result_mk_ok(lean_box(0));
_G_initialized = true;
res = initialize_Init(lean_io_mk_world());
if (lean_io_result_is_error(res)) return res;
lean_dec_ref(res);
res = initialize_Std_Data_PersistentHashMap(lean_io_mk_world());
if (lean_io_result_is_error(res)) return res;
lean_dec_ref(res);
return lean_io_result_mk_ok(lean_box(0));
}
#ifdef __cplusplus
}
#endif
| 36.684805 | 251 | 0.819345 |
9aedd171ea2143c197878ff756d5e3a21d3879b7 | 2,545 | h | C | common/protobuf/DcgmProtobuf.h | deepio/DCGM | d10273f18fb3d425da752ab6bb7e07af3d18caec | [
"Apache-2.0"
] | 85 | 2021-02-03T19:58:50.000Z | 2022-03-21T08:00:11.000Z | common/protobuf/DcgmProtobuf.h | deepio/DCGM | d10273f18fb3d425da752ab6bb7e07af3d18caec | [
"Apache-2.0"
] | 19 | 2021-03-19T08:13:58.000Z | 2022-03-17T02:50:41.000Z | common/protobuf/DcgmProtobuf.h | deepio/DCGM | d10273f18fb3d425da752ab6bb7e07af3d18caec | [
"Apache-2.0"
] | 17 | 2021-02-04T06:47:30.000Z | 2022-03-21T22:14:03.000Z | /*
* Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* File: DcgmProtobuf.h
*/
#ifndef DCGMPROTOBUF_H
#define DCGMPROTOBUF_H
#include "DcgmProtocol.h"
#include "dcgm.pb.h"
#include <iostream>
#include <vector>
class DcgmProtobuf
{
public:
DcgmProtobuf();
virtual ~DcgmProtobuf();
/*****************************************************************************
* Add command to the protobuf message to be sent over the network
* Returns !NULL on Success
* NULL on Error
*****************************************************************************/
dcgm::Command *AddCommand(unsigned int cmdType, unsigned int opMode, int id, int status);
/*****************************************************************************
This method returns the encoded message to be sent over socket*
*****************************************************************************/
dcgmReturn_t GetEncodedMessage(std::vector<char> &encodedMessage);
/*****************************************************************************
* Parse the received protobuf message. This method gets reference to all the
* commands in the message.
*****************************************************************************/
dcgmReturn_t ParseRecvdMessage(char *buf, int length, std::vector<dcgm::Command *> *pCommands);
/*****************************************************************************
* This method is used to get reference to all the commands in the protobuf message
*****************************************************************************/
int GetAllCommands(std::vector<dcgm::Command *> *pCommands);
protected:
dcgm::Msg *mpProtoMsg; /* Google protobuf format message */
char *mpEncodedMessage; /* Encoded message is stored in this buffer */
int mMsgType; /* Represents one of Request, Response or Notify */
};
#endif /* DCGMPROTOBUF_H */
| 39.765625 | 99 | 0.526916 |
fa27bb939c0b2aaab85b935465db699bba324f47 | 21,870 | h | C | include/swizzle/detail/glsl/vector_functions_adapter.h | gwiazdorrr/CxxSwizzle | de4332eb0e2fc4306d300bbc090b9a48ce2d939d | [
"MIT"
] | 140 | 2015-01-15T11:21:47.000Z | 2022-01-08T08:31:08.000Z | include/swizzle/detail/glsl/vector_functions_adapter.h | syoyo/CxxSwizzle | e70de1c1eda7e9ab497c9b3929edc9642e725dc0 | [
"MIT"
] | 4 | 2015-05-04T12:39:50.000Z | 2022-03-07T03:25:20.000Z | include/swizzle/detail/glsl/vector_functions_adapter.h | syoyo/CxxSwizzle | e70de1c1eda7e9ab497c9b3929edc9642e725dc0 | [
"MIT"
] | 13 | 2015-05-18T09:26:40.000Z | 2021-06-30T14:47:16.000Z | // CxxSwizzle
// Copyright (c) 2013-2015, Piotr Gwiazdowski <gwiazdorrr+github at gmail.com>
#pragma once
#include <cmath>
#include <swizzle/detail/utils.h>
#define CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(name) \
static vector_type call_##name(vector_arg_type x) { return construct_static(functor_##name{}, x); }
#define CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VV(name) \
static vector_type call_##name(vector_arg_type x, vector_arg_type y) { return construct_static(functor_##name{}, x, y); }
#define CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VS(name) \
static vector_type call_##name(vector_arg_type x, scalar_arg_type y) { return construct_static(functor_##name{}, x, y); }
#define CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_SV(name) \
static vector_type call_##name(scalar_arg_type x, vector_arg_type y) { return construct_static(functor_##name{}, x, y); }
#define CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VVV(name) \
static vector_type call_##name(vector_arg_type x, vector_arg_type y, vector_arg_type z) { return construct_static(functor_##name{}, x, y, z); }
#define CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VVS(name) \
static vector_type call_##name(vector_arg_type x, vector_arg_type y, scalar_arg_type z) { return construct_static(functor_##name{}, x, y, z); }
#define CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VSS(name) \
static vector_type call_##name(vector_arg_type x, scalar_arg_type y, scalar_arg_type z) { return construct_static(functor_##name{}, x, y, z); }
#define CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_SSV(name) \
static vector_type call_##name(scalar_arg_type x, scalar_arg_type y, vector_arg_type z) { return construct_static(functor_##name{}, x, y, z); }
namespace swizzle
{
namespace detail
{
namespace glsl
{
//! A class providing static functions matching GLSL's vector functions. Uses naive approach, i.e.
//! everything is done components-wise, using stdlib's math functions.
template <class Base, template <class, size_t> class VectorType, class ScalarType, size_t Size>
class vector_functions_adapter : public Base
{
public:
typedef VectorType<ScalarType, Size> vector_type;
typedef const VectorType<ScalarType, Size>& vector_arg_type;
typedef VectorType<bool, Size> bool_vector_type;
typedef ScalarType scalar_type;
typedef const ScalarType& scalar_arg_type;
private:
struct not_available;
//! Fires Func for each component an assigns back the result
template <typename Func, typename... Args>
static vector_type construct_static(Func func, Args&&... args)
{
vector_type result;
detail::static_for_with_static_call<0, Size>(func, result, std::forward<Args>(args)...);
return result;
}
template <class T, class Func>
static VectorType<T, Size> construct(Func func)
{
VectorType<T, Size> result;
detail::static_for<0, Size>([&](size_t i) -> void { result[i] = func(i); });
return result;
}
private:
struct functor_radians
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
result.at(i) = x.at(i) * scalar_type(3.14159265358979323846 / 180);
}
};
struct functor_degrees
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
result.at(i) = x.at(i) * scalar_type(180 / 3.14159265358979323846);
}
};
struct functor_mul
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x, scalar_arg_type y)
{
result.at(i) = x.at(i) * y;
}
};
struct functor_sin
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
using namespace std;
result.at(i) = sin(x.at(i));
}
};
struct functor_cos
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
using namespace std;
result.at(i) = cos(x.at(i));
}
};
struct functor_tan
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
using namespace std;
result.at(i) = tan(x.at(i));
}
};
struct functor_asin
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
using namespace std;
result.at(i) = asin(x.at(i));
}
};
struct functor_acos
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
using namespace std;
result.at(i) = acos(x.at(i));
}
};
struct functor_atan
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
using namespace std;
result.at(i) = atan(x.at(i));
}
template <size_t i> void operator()(vector_type& result, vector_arg_type y, vector_arg_type x)
{
using namespace std;
result.at(i) = atan2(y.at(i), x.at(i));
}
};
struct functor_pow
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x, scalar_arg_type y)
{
using namespace std;
result.at(i) = pow(x.at(i), y);
}
template <size_t i> void operator()(vector_type& result, vector_arg_type x, vector_arg_type y)
{
using namespace std;
result.at(i) = pow(x.at(i), y.at(i));
}
};
struct functor_abs
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
using namespace std;
result.at(i) = abs(x.at(i));
}
};
struct functor_exp
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
using namespace std;
result.at(i) = exp(x.at(i));
}
};
struct functor_log
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
using namespace std;
result.at(i) = log(x.at(i));
}
};
struct functor_exp2
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
using namespace std;
result.at(i) = exp2(x.at(i));
}
};
struct functor_log2
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
using namespace std;
result.at(i) = log2(x.at(i));
}
};
struct functor_sqrt
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
using namespace std;
result.at(i) = sqrt(x.at(i));
}
};
struct functor_inversesqrt
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
using namespace std;
result.at(i) = rsqrt(x.at(i));
}
};
struct functor_sign
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
using namespace std;
result.at(i) = sign(x.at(i));
}
};
struct functor_fract
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
using namespace std;
scalar_type xx = x.at(i);
result.at(i) = xx - floor(xx);
}
};
struct functor_mod
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x, vector_arg_type y)
{
operator() < i > (result, x, y.at(i));
}
template <size_t i> void operator()(vector_type& result, vector_arg_type x, scalar_arg_type y)
{
using namespace std;
auto xx = x.at(i);
result.at(i) = xx - y * floor(xx / y);
}
};
struct functor_min
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x, vector_arg_type y)
{
operator() < i > (result, x, y.at(i));
}
template <size_t i> void operator()(vector_type& result, vector_arg_type x, scalar_arg_type y)
{
using namespace std;
result.at(i) = min(x.at(i), y);
}
};
struct functor_max
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x, vector_arg_type y)
{
operator() < i > (result, x, y.at(i));
}
template <size_t i> void operator()(vector_type& result, vector_arg_type x, scalar_arg_type y)
{
using namespace std;
result.at(i) = max(x.at(i), y);
}
};
struct functor_clamp
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x, vector_arg_type a, vector_arg_type b)
{
operator() < i > (result, x, a.at(i), b.at(i));
}
template <size_t i> void operator()(vector_type& result, vector_arg_type x, scalar_arg_type a, scalar_arg_type b)
{
using namespace std;
result.at(i) = max(min(x.at(i), b), a);
}
};
struct functor_mix
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x, vector_arg_type y, vector_arg_type a)
{
operator() < i > (result, x, y, a.at(i));
}
template <size_t i> void operator()(vector_type& result, vector_arg_type x, vector_arg_type y, scalar_arg_type a)
{
using namespace std;
result.at(i) = x.at(i) + a * (y.at(i) - x.at(i));
}
};
struct functor_step
{
template <size_t i> void operator()(vector_type& result, vector_arg_type edge, vector_arg_type x)
{
operator() < i > (result, edge.at(i), x);
}
template <size_t i> void operator()(vector_type& result, scalar_arg_type edge, vector_arg_type x)
{
using namespace std;
result.at(i) = step(edge, x.at(i));
}
};
struct functor_smoothstep
{
template <size_t i> void operator()(vector_type& result, vector_arg_type edge0, vector_arg_type edge1, vector_arg_type x)
{
operator() < i > (result, edge0.at(i), edge1.at(i), x);
}
template <size_t i> void operator()(vector_type& result, scalar_arg_type edge0, scalar_arg_type edge1, vector_arg_type x)
{
using namespace std;
auto t = (x.at(i) - edge0) / (edge1 - edge0);
t = min(max(t, scalar_arg_type(0)), scalar_arg_type(1));
result.at(i) = t * t * (3 - 2 * t);
}
};
struct functor_dot
{
template <size_t i> void operator()(scalar_type& result, vector_arg_type x, vector_arg_type y)
{
result += x.at(i) * y.at(i);
}
};
struct functor_floor
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
using namespace std;
result.at(i) = floor(x.at(i));
}
};
struct functor_ceil
{
template <size_t i> void operator()(vector_type& result, vector_arg_type x)
{
using namespace std;
result.at(i) = ceil(x.at(i));
}
};
public:
// these functions do component-wise transform
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(degrees)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(radians)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(sin)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(cos)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(tan)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(asin)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(acos)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(atan)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VV(atan)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(abs)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VV(pow)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VS(pow)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(exp)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(log)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(exp2)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(log2)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(sqrt)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(inversesqrt)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(sign)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(fract)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(floor)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V(ceil)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VV(mod)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VS(mod)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VV(min)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VS(min)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VV(max)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VS(max)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VVV(clamp)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VSS(clamp)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VVV(mix)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VVS(mix)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VV(step)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_SV(step)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VVV(smoothstep)
CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_SSV(smoothstep)
// these are more complex
static vector_type call_reflect(vector_arg_type I, vector_arg_type N)
{
//return (I - 2 * call_dot(I, N) * N);
scalar_type dot2 = 2 * call_dot(I, N);
vector_type n = N;
n *= dot2;
vector_type i = I;
i -= n;
return i;
}
// Geometric functions
static scalar_type call_length(vector_arg_type x)
{
using namespace std;
scalar_type dot = call_dot(x, x);
return sqrt(dot);
}
static scalar_type call_distance(vector_arg_type p0, const vector_arg_type p1)
{
return call_length(p0 - p1);
}
static scalar_type call_dot(vector_arg_type x, vector_arg_type y)
{
scalar_type result = 0;
detail::static_for_with_static_call<0, Size>(functor_dot{}, result, x, y);
return result;
}
static vector_type call_normalize(vector_arg_type x)
{
using namespace std;
scalar_type dot = call_dot(x, x);
return vector_type(x) * rsqrt(dot);
}
static typename std::conditional<Size == 3, vector_type, not_available>::type call_cross(const vector_type& x, const vector_type& y)
{
auto rx = x[1] * y[2] - x[2] * y[1];
auto ry = x[2] * y[0] - x[0] * y[2];
auto rz = x[0] * y[1] - x[1] * y[0];
return vector_type(rx, ry, rz);
}
static bool_vector_type call_lessThan(vector_arg_type x, vector_arg_type y)
{
return construct<bool>([&](size_t i) -> bool { return x[i] < y[i]; });
}
static bool_vector_type call_lessThanEqual(vector_arg_type x, vector_arg_type y)
{
return construct<bool>([&](size_t i) -> bool { return x[i] <= y[i]; });
}
static bool_vector_type call_greaterThan(vector_arg_type x, vector_arg_type y)
{
return construct<bool>([&](size_t i) -> bool { return x[i] > y[i]; });
}
static bool_vector_type call_greaterThanEqual(vector_arg_type x, vector_arg_type y)
{
return construct<bool>([&](size_t i) -> bool { return x[i] >= y[i]; });
}
static bool_vector_type call_equal(vector_arg_type x, vector_arg_type y)
{
return construct<bool>([&](size_t i) -> bool { return x[i] == y[i]; });
}
static bool_vector_type call_notEqual(vector_arg_type x, vector_arg_type y)
{
return construct<bool>([&](size_t i) -> bool { return x[i] != y[i]; });
}
static bool call_any(typename std::conditional<std::is_same<ScalarType, bool>::value, vector_arg_type, not_available>::type x)
{
bool result = false;
detail::static_for<0, Size>([&](size_t i) -> void { result |= x[i]; });
return result;
}
static bool call_all(typename std::conditional< std::is_same<scalar_type, bool>::value, vector_arg_type, not_available>::type x)
{
bool result = true;
detail::static_for<0, Size>([&](size_t i) -> void { result &= x[i]; });
return result;
}
static vector_type call_not(typename std::conditional< std::is_same<scalar_type, bool>::value, vector_arg_type, not_available>::type x)
{
return construct<bool>([&](size_t i) -> bool { return !x[i]; });
}
};
}
}
}
#undef CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_V
#undef CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VV
#undef CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VS
#undef CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_SV
#undef CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VVV
#undef CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VVS
#undef CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_VSS
#undef CXXSWIZZLE_DETAIL_SIMPLE_TRANSFORM_SSV | 40.425139 | 151 | 0.481619 |
d250e03e050f70c4b8a492a7fd4d802dc12ecfcf | 7,513 | h | C | api/logic/BaseInstance.h | technic-void/MultiMC5 | 0c466bc530dc7e6da12d678d01677dfb23bdda92 | [
"Apache-2.0"
] | null | null | null | api/logic/BaseInstance.h | technic-void/MultiMC5 | 0c466bc530dc7e6da12d678d01677dfb23bdda92 | [
"Apache-2.0"
] | null | null | null | api/logic/BaseInstance.h | technic-void/MultiMC5 | 0c466bc530dc7e6da12d678d01677dfb23bdda92 | [
"Apache-2.0"
] | null | null | null | /* Copyright 2013-2021 MultiMC Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <cassert>
#include <QObject>
#include "QObjectPtr.h"
#include <QDateTime>
#include <QSet>
#include <QProcess>
#include "settings/SettingsObject.h"
#include "settings/INIFile.h"
#include "BaseVersionList.h"
#include "minecraft/auth/MojangAccount.h"
#include "MessageLevel.h"
#include "pathmatcher/IPathMatcher.h"
#include "net/Mode.h"
#include "multimc_logic_export.h"
#include "minecraft/launch/MinecraftServerTarget.h"
class QDir;
class Task;
class LaunchTask;
class BaseInstance;
// pointer for lazy people
typedef std::shared_ptr<BaseInstance> InstancePtr;
/*!
* \brief Base class for instances.
* This class implements many functions that are common between instances and
* provides a standard interface for all instances.
*
* To create a new instance type, create a new class inheriting from this class
* and implement the pure virtual functions.
*/
class MULTIMC_LOGIC_EXPORT BaseInstance : public QObject, public std::enable_shared_from_this<BaseInstance>
{
Q_OBJECT
protected:
/// no-touchy!
BaseInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir);
public: /* types */
enum class Status
{
Present,
Gone // either nuked or invalidated
};
public:
/// virtual destructor to make sure the destruction is COMPLETE
virtual ~BaseInstance() {};
virtual void saveNow() = 0;
/***
* the instance has been invalidated - it is no longer tracked by MultiMC for some reason,
* but it has not necessarily been deleted.
*
* Happens when the instance folder changes to some other location, or the instance is removed by external means.
*/
void invalidate();
/// The instance's ID. The ID SHALL be determined by MMC internally. The ID IS guaranteed to
/// be unique.
virtual QString id() const;
void setRunning(bool running);
bool isRunning() const;
int64_t totalTimePlayed() const;
int64_t lastTimePlayed() const;
void resetTimePlayed();
/// get the type of this instance
QString instanceType() const;
/// Path to the instance's root directory.
QString instanceRoot() const;
/// Path to the instance's game root directory.
virtual QString gameRoot() const
{
return instanceRoot();
}
QString name() const;
void setName(QString val);
/// Value used for instance window titles
QString windowTitle() const;
QString iconKey() const;
void setIconKey(QString val);
QString notes() const;
void setNotes(QString val);
QString getPreLaunchCommand();
QString getPostExitCommand();
QString getWrapperCommand();
/// guess log level from a line of game log
virtual MessageLevel::Enum guessLevel(const QString &line, MessageLevel::Enum level)
{
return level;
};
virtual QStringList extraArguments() const;
/// Traits. Normally inside the version, depends on instance implementation.
virtual QSet <QString> traits() const = 0;
/**
* Gets the time that the instance was last launched.
* Stored in milliseconds since epoch.
*/
qint64 lastLaunch() const;
/// Sets the last launched time to 'val' milliseconds since epoch
void setLastLaunch(qint64 val = QDateTime::currentMSecsSinceEpoch());
/*!
* \brief Gets this instance's settings object.
* This settings object stores instance-specific settings.
* \return A pointer to this instance's settings object.
*/
virtual SettingsObjectPtr settings() const;
/// returns a valid update task
virtual shared_qobject_ptr<Task> createUpdateTask(Net::Mode mode) = 0;
/// returns a valid launcher (task container)
virtual shared_qobject_ptr<LaunchTask> createLaunchTask(
AuthSessionPtr account, MinecraftServerTargetPtr serverToJoin) = 0;
/// returns the current launch task (if any)
shared_qobject_ptr<LaunchTask> getLaunchTask();
/*!
* Create envrironment variables for running the instance
*/
virtual QProcessEnvironment createEnvironment() = 0;
/*!
* Returns a matcher that can maps relative paths within the instance to whether they are 'log files'
*/
virtual IPathMatcher::Ptr getLogFileMatcher() = 0;
/*!
* Returns the root folder to use for looking up log files
*/
virtual QString getLogFileRoot() = 0;
virtual QString getStatusbarDescription() = 0;
/// FIXME: this really should be elsewhere...
virtual QString instanceConfigFolder() const = 0;
/// get variables this instance exports
virtual QMap<QString, QString> getVariables() const = 0;
virtual QString typeName() const = 0;
bool hasVersionBroken() const
{
return m_hasBrokenVersion;
}
void setVersionBroken(bool value)
{
if(m_hasBrokenVersion != value)
{
m_hasBrokenVersion = value;
emit propertiesChanged(this);
}
}
bool hasUpdateAvailable() const
{
return m_hasUpdate;
}
void setUpdateAvailable(bool value)
{
if(m_hasUpdate != value)
{
m_hasUpdate = value;
emit propertiesChanged(this);
}
}
bool hasCrashed() const
{
return m_crashed;
}
void setCrashed(bool value)
{
if(m_crashed != value)
{
m_crashed = value;
emit propertiesChanged(this);
}
}
virtual bool canLaunch() const;
virtual bool canEdit() const = 0;
virtual bool canExport() const = 0;
bool reloadSettings();
/**
* 'print' a verbose description of the instance into a QStringList
*/
virtual QStringList verboseDescription(AuthSessionPtr session, MinecraftServerTargetPtr serverToJoin) = 0;
Status currentStatus() const;
int getConsoleMaxLines() const;
bool shouldStopOnConsoleOverflow() const;
protected:
void changeStatus(Status newStatus);
signals:
/*!
* \brief Signal emitted when properties relevant to the instance view change
*/
void propertiesChanged(BaseInstance *inst);
void launchTaskChanged(shared_qobject_ptr<LaunchTask>);
void runningStatusChanged(bool running);
void statusChanged(Status from, Status to);
protected slots:
void iconUpdated(QString key);
protected: /* data */
QString m_rootDir;
SettingsObjectPtr m_settings;
// InstanceFlags m_flags;
bool m_isRunning = false;
shared_qobject_ptr<LaunchTask> m_launchProcess;
QDateTime m_timeStarted;
private: /* data */
Status m_status = Status::Present;
bool m_crashed = false;
bool m_hasUpdate = false;
bool m_hasBrokenVersion = false;
};
Q_DECLARE_METATYPE(shared_qobject_ptr<BaseInstance>)
//Q_DECLARE_METATYPE(BaseInstance::InstanceFlag)
//Q_DECLARE_OPERATORS_FOR_FLAGS(BaseInstance::InstanceFlags)
| 27.520147 | 117 | 0.690536 |
cfb7cbbf5b4585ab97aa00bd83d3d7392b0c2b07 | 470 | h | C | src/core/md_tracking_allocator.h | scanberg/mold | ae2a8be31010a10fc32b500c1caadc17c8387787 | [
"MIT"
] | null | null | null | src/core/md_tracking_allocator.h | scanberg/mold | ae2a8be31010a10fc32b500c1caadc17c8387787 | [
"MIT"
] | 2 | 2021-03-17T16:24:36.000Z | 2021-03-22T20:02:50.000Z | src/core/md_tracking_allocator.h | scanberg/mold | ae2a8be31010a10fc32b500c1caadc17c8387787 | [
"MIT"
] | 2 | 2021-03-17T12:01:12.000Z | 2021-03-19T14:38:22.000Z | #pragma once
#include <stdint.h>
struct md_allocator_i;
#ifdef __cplusplus
extern "C" {
#endif
// This is a tracking allocator which tracks every allocation and free to make sure that the correct amount of memory is freed and that non of the memory is leaked upon destruction.
struct md_allocator_i* md_tracking_allocator_create(struct md_allocator_i* backing);
void md_tracking_allocator_destroy(struct md_allocator_i* tracking_alloc);
#ifdef __cplusplus
}
#endif
| 26.111111 | 181 | 0.810638 |
cfd850bcb783e3ef8441a4e2e3f5b86799048438 | 88 | h | C | frameworks/cocos2d-x/cocos/quick_libs/src/extensions/lpack/lpack.h | gang544043963/-snake-I | 24f6798efd4d70c03438db57e5e2b79d20cead4e | [
"MIT"
] | 12 | 2016-03-07T01:12:55.000Z | 2019-09-21T10:40:12.000Z | frameworks/cocos2d-x/cocos/quick_libs/src/extensions/lpack/lpack.h | gang544043963/-snake-I | 24f6798efd4d70c03438db57e5e2b79d20cead4e | [
"MIT"
] | null | null | null | frameworks/cocos2d-x/cocos/quick_libs/src/extensions/lpack/lpack.h | gang544043963/-snake-I | 24f6798efd4d70c03438db57e5e2b79d20cead4e | [
"MIT"
] | 6 | 2016-03-10T12:31:58.000Z | 2017-03-16T09:16:35.000Z |
#ifndef __LUA_LPACK_H_
#define __LUA_LPACK_H_
int luaopen_pack(lua_State *L);
#endif
| 11 | 31 | 0.795455 |
2c9faededa2f551d123a95ae4b7acc0daa01e02d | 5,449 | h | C | Cpp/SDK/BP_BTR80_RUS_PKT_classes.h | MrManiak/Squad-SDK | 742feb5991ae43d6f0cedd2d6b32b949923ca4f9 | [
"Apache-2.0"
] | 1 | 2020-08-15T08:31:55.000Z | 2020-08-15T08:31:55.000Z | Cpp/SDK/BP_BTR80_RUS_PKT_classes.h | MrManiak/Squad-SDK | 742feb5991ae43d6f0cedd2d6b32b949923ca4f9 | [
"Apache-2.0"
] | 2 | 2020-08-15T08:43:56.000Z | 2021-01-15T05:04:48.000Z | Cpp/SDK/BP_BTR80_RUS_PKT_classes.h | MrManiak/Squad-SDK | 742feb5991ae43d6f0cedd2d6b32b949923ca4f9 | [
"Apache-2.0"
] | 2 | 2020-08-10T12:05:42.000Z | 2021-02-12T19:56:10.000Z | #pragma once
// Name: S, Version: b
#ifdef _MSC_VER
#pragma pack(push, 0x01)
#endif
/*!!HELPER_DEF!!*/
/*!!DEFINE!!*/
namespace UFT
{
//---------------------------------------------------------------------------
// Classes
//---------------------------------------------------------------------------
// BlueprintGeneratedClass BP_BTR80_RUS_PKT.BP_BTR80_RUS_PKT_C
// 0x0070 (FullSize[0x0A28] - InheritedSize[0x09B8])
class ABP_BTR80_RUS_PKT_C : public ASQVehicleWeapon
{
public:
struct FPointerToUberGraphFrame UberGraphFrame; // 0x09B8(0x0008) (ZeroConstructor, Transient, DuplicateTransient)
class USQTemperatureComponent* SQTemperature; // 0x09C0(0x0008) (BlueprintVisible, ZeroConstructor, InstancedReference, IsPlainOldData, NonTransactional, NoDestructor, HasGetValueTypeHash)
float ShutdownTemp; // 0x09C8(0x0004) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
float OverheatEffectTrigger_2; // 0x09CC(0x0004) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
float OverheatEffectTrigger_3; // 0x09D0(0x0004) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
unsigned char UnknownData_3N37[0x4]; // 0x09D4(0x0004) MISSED OFFSET (FIX SPACE BETWEEN PREVIOUS PROPERTY)
class UParticleSystemComponent* Overheat_1_Effect; // 0x09D8(0x0008) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, InstancedReference, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
class UParticleSystemComponent* Overheat_2_Effect; // 0x09E0(0x0008) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, InstancedReference, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
class UParticleSystemComponent* Overheat_3_Effect; // 0x09E8(0x0008) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, InstancedReference, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
class UAudioComponent* Overheat_1_Sound; // 0x09F0(0x0008) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, InstancedReference, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
class UAudioComponent* Overheat_2_Sound; // 0x09F8(0x0008) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, InstancedReference, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
class USoundCue* SoundTest; // 0x0A00(0x0008) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
class UAudioComponent* Overheat_3_Sound; // 0x0A08(0x0008) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, InstancedReference, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
struct FName Mesh1PReturnSection; // 0x0A10(0x0008) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
struct FName Mesh3PReturnSection; // 0x0A18(0x0008) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
struct FName SoldierMeshReturnSection; // 0x0A20(0x0008) (Edit, BlueprintVisible, ZeroConstructor, DisableEditOnInstance, IsPlainOldData, NoDestructor, HasGetValueTypeHash)
static UClass* StaticClass()
{
static auto ptr = UObject::FindClass("BlueprintGeneratedClass BP_BTR80_RUS_PKT.BP_BTR80_RUS_PKT_C");
return ptr;
}
void ResumeAnimations(class UAnimMontage* TripodAnim, class UAnimMontage* WeaponAnim, class UAnimMontage* SoldierAnim);
void StopAnimations(class ASQSoldier* Soldier);
void PlayAnimations(class UAnimMontage* TripodAnim, class UAnimMontage* WeaponAnim, class UAnimMontage* SoldierAnim, class ASQSoldier* Soldier, float* TripodAnimTime, float* WeaponAnimTime, float* SoldierAnimTime);
void BndEvt__SQTemperature_K2Node_ComponentBoundEvent_486_TemperatureIncrementDelegate__DelegateSignature(class USQTemperatureComponent* TriggeringComponent, float TriggeringTemp, bool bIsLowerTrigger);
void BlueprintOnFire(const struct FVector& Origin);
void BlueprintOnReload();
void SoldierEntersVehicle(class ASQSoldier* Soldier);
void SoldierLeavesVehicle(class ASQSoldier* Soldier);
void ExecuteUbergraph_BP_BTR80_RUS_PKT(int EntryPoint);
};
}
#ifdef _MSC_VER
#pragma pack(pop)
#endif
| 81.328358 | 264 | 0.636631 |
9635aa00aecd5398beb9b7763019c76945e7bebf | 331 | h | C | source/script/Script.h | dexter3k/Stranded2pp | 022df9becf9931f8437e81bb405bacf168884c8d | [
"MIT"
] | 1 | 2021-04-13T18:18:34.000Z | 2021-04-13T18:18:34.000Z | source/script/Script.h | SMemsky/Stranded2pp | 022df9becf9931f8437e81bb405bacf168884c8d | [
"MIT"
] | 2 | 2021-04-03T15:02:22.000Z | 2021-04-13T18:16:39.000Z | source/script/Script.h | SMemsky/Stranded2pp | 022df9becf9931f8437e81bb405bacf168884c8d | [
"MIT"
] | null | null | null | #pragma once
#include <string>
#include <vector>
namespace script
{
class Script
{
public:
Script() = default;
std::vector<std::string> const & getEventHandlers() const { return eventHandlers; };
bool hasHandlerForEvent(std::string const & event);
private:
std::vector<std::string> eventHandlers;
};
} // namespace script
| 15.761905 | 85 | 0.719033 |
9645745bc71ccf4655ae5662e924c767a8af9eb8 | 1,331 | h | C | third_party/WebKit/Source/modules/webusb/USBInTransferResult.h | Wzzzx/chromium-crosswalk | 768dde8efa71169f1c1113ca6ef322f1e8c9e7de | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 2 | 2019-01-28T08:09:58.000Z | 2021-11-15T15:32:10.000Z | third_party/WebKit/Source/modules/webusb/USBInTransferResult.h | maidiHaitai/haitaibrowser | a232a56bcfb177913a14210e7733e0ea83a6b18d | [
"BSD-3-Clause"
] | null | null | null | third_party/WebKit/Source/modules/webusb/USBInTransferResult.h | maidiHaitai/haitaibrowser | a232a56bcfb177913a14210e7733e0ea83a6b18d | [
"BSD-3-Clause"
] | 6 | 2020-09-23T08:56:12.000Z | 2021-11-18T03:40:49.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 USBInTransferResult_h
#define USBInTransferResult_h
#include "bindings/core/v8/ScriptWrappable.h"
#include "core/dom/DOMArrayBuffer.h"
#include "core/dom/DOMDataView.h"
#include "platform/heap/Handle.h"
#include "wtf/Vector.h"
#include "wtf/text/WTFString.h"
namespace blink {
class USBInTransferResult final
: public GarbageCollectedFinalized<USBInTransferResult>
, public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
static USBInTransferResult* create(const String& status, const Vector<uint8_t>& data)
{
return new USBInTransferResult(status, data);
}
USBInTransferResult(const String& status, const Vector<uint8_t>& data)
: m_status(status)
, m_data(DOMDataView::create(DOMArrayBuffer::create(data.data(), data.size()), 0, data.size()))
{
}
virtual ~USBInTransferResult() { }
String status() const { return m_status; }
DOMDataView* data() const { return m_data; }
DEFINE_INLINE_TRACE()
{
visitor->trace(m_data);
}
private:
const String m_status;
const Member<DOMDataView> m_data;
};
} // namespace blink
#endif // USBInTransferResult_h
| 26.098039 | 103 | 0.712246 |
c59abe31afe04b7b7dd7133f69a0a63a5cfee3ea | 527 | h | C | upgrade/patch/cputop/patch-sys-amd64-include-vmm.h | danmack/cbsd | a1348b8dbd976460d9292314a224e171faa535ec | [
"BSD-2-Clause"
] | null | null | null | upgrade/patch/cputop/patch-sys-amd64-include-vmm.h | danmack/cbsd | a1348b8dbd976460d9292314a224e171faa535ec | [
"BSD-2-Clause"
] | null | null | null | upgrade/patch/cputop/patch-sys-amd64-include-vmm.h | danmack/cbsd | a1348b8dbd976460d9292314a224e171faa535ec | [
"BSD-2-Clause"
] | null | null | null | --- vmm.h.bak 2018-03-16 17:40:37.873890000 +0300
+++ vmm.h 2018-03-16 17:51:38.786938000 +0300
@@ -181,6 +181,10 @@
void vm_destroy(struct vm *vm);
int vm_reinit(struct vm *vm);
const char *vm_name(struct vm *vm);
+void vm_get_topology(struct vm *vm, uint16_t *sockets, uint16_t *cores,
+ uint16_t *threads, uint16_t *maxcpus);
+int vm_set_topology(struct vm *vm, uint16_t sockets, uint16_t cores,
+ uint16_t threads, uint16_t maxcpus);
/*
* APIs that modify the guest memory map require all vcpus to be frozen.
| 37.642857 | 73 | 0.711575 |
5ce22a2c89a17a47e72490e95bddab852a2315dd | 4,175 | h | C | Sarah/alilib.h | Grinnell-CSC282/api-2017 | 140e64a05f3cd85f04b73b1f0e8e248da877f496 | [
"MIT"
] | null | null | null | Sarah/alilib.h | Grinnell-CSC282/api-2017 | 140e64a05f3cd85f04b73b1f0e8e248da877f496 | [
"MIT"
] | null | null | null | Sarah/alilib.h | Grinnell-CSC282/api-2017 | 140e64a05f3cd85f04b73b1f0e8e248da877f496 | [
"MIT"
] | null | null | null | /**
* alilib.h
* a library that handles arbitrarily large integers
*
* Function declarations by Sam Rebelsky
* http://www.cs.grinnell.edu/~rebelsky/musings/cnix-alint-library
*
* <insert appropritate open-source license>
*/
#ifndef __ALILIB_H__
#define __ALILIB_H__
// +------------+----------------------------------------------------
// | Definition |
// +------------+
struct ALInt
{
int ndigits;
int sign; // 1 for positive, -1 for negative
int digits[]; // Each represents one base-16 digit
};
typedef struct ALInt ALInt;
// +-----------+-----------------------------------------------------
// | Constants |
// +-----------+
#define LONG_MAX 100000.0
#define LONG_MIN 100000.0
#define INT_MAX 100000
#define INT_MIN 100000
#define DOUBLE_MAX 100000.0
#define DOUBLE_MIN 100000.0
// +------------+----------------------------------------------------
// | Procedures |
// +------------+
/**
* Initializes the library. The client must run this procedure before
* using the library.
*/
void ali_init();
/**
* Cleans up all memory that may have been allocated. The client must run
* this procedure when they are finished using the library.
*/
void ali_cleanup();
/**
* Free the memory associated with an ALInt. Afterwards,
* i should no longer be used.
*/
void ali_free (ALInt *i);
/**
* Creates a new ALInt from values for that integer.
*/
ALInt * ali_new(int new_ndigits, int new_sign, int new_digits[]);
/**
* Add two arbitrarily large integers, creating a newly allocated
* arbitrarily large integer. The client is responsible for freeing
* any memory associated with the new value using ali_free.
*/
ALInt * ali_add (ALInt *a, ALInt *b);
/**
* Subtract two arbitrarily large integers, creating a newly allocated
* arbitrarily large integer. The client is responsible for freeing
* any memory associated with the new value using ali_free.
*/
ALInt * ali_subtract (ALInt *a, ALInt *b);
/**
* Mutiply two arbitrarily large integers, creating a newly allocated
* arbitrarily large integer. The client is responsible for freeing
* any memory associated with the new value using ali_free.
*/
ALInt * ali_multiply (ALInt *a, ALInt *b);
/**
* Find the quotient two arbitrarily large integers, creating a
* newly allocated arbitrarily large integer. The client is responsible
* for freeing any memory associated with the new value using ali_free.
*/
ALInt * ali_quotient (ALInt *a, ALInt *b);
/**
* Find the remainder two arbitrarily large integers, creating a
* newly allocated arbitrarily large integer. The client is responsible
* for freeing any memory associated with the new value using ali_free.
*/
ALInt * ali_remainder (ALInt *a, ALInt *b);
/**
* Create a newly allocated ALInt whose value is i.
*/
ALInt * int2ali (int i);
/**
* Create a newly allocated ALInt whose value is i.
*/
ALInt * str2ali (char * s);
/**
* Create a newly allocated ALInt whose value is i.
*/
ALInt * long2ali (long l);
/**
* Create a newly allocated ALInt whose value is i.
*/
ALInt * double2ali (double d);
/**
* Find the long that corresponds to a. If a > LONG_MAX,
* returns LONG_MAX. If a < LONG_MIN, returns LONG_MIN.
*/
long ali2long (ALInt *a);
/**
* Find the double that corresponds to a. If a > DOUBLE_MAX,
* returns DOUBLE_MAX. If a < DOUBLE_MIN, returns DOUBLE_MIN.
*/
double ali2double (ALInt *a);
/**
* Find the int that corresponds to a. If a > INT_MAX,
* returns INT_MAX. If a < INT_MIN, returns INT_MIN.
*/
int ali2int (ALInt *a);
/**
* Convert a to string representation. Returns a newly-allocated
* string.
*/
char * ali2str (ALInt *a);
/**
* Determine whether the signs of a and b are the same or different.
* Returns an integer indicating --
* 0: +a + b
* 1: +a - b
* 2: -a + b
* 3: -a - b
*/
int find_signs(ALInt *a, ALInt *b);
/**
* Finds the bigger of two ALInts (by length) and returns it.
*/
ALInt * find_bigger(ALInt *a, ALInt *b);
/**
* Shifts an array of digits to get rid of any leading zeros and
* returns a new array without them
*/
int * remove_leading_zeroes(int array[], int arr_len);
#endif // __ALILIB_H__ | 25.150602 | 73 | 0.653413 |
65da8a357d5f07a3dbf49caf88dc22d385a1cade | 555 | h | C | PrivateFrameworks/VoiceServices/VSRecognitionResultHandlingRequest.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/VoiceServices/VSRecognitionResultHandlingRequest.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/VoiceServices/VSRecognitionResultHandlingRequest.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 1 | 2018-09-28T13:54:23.000Z | 2018-09-28T13:54:23.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSObject.h"
@class NSArray, VSRecognitionAction;
__attribute__((visibility("hidden")))
@interface VSRecognitionResultHandlingRequest : NSObject
{
id <VSRecognitionResultHandler> _handler;
NSArray *_results;
VSRecognitionAction *_action;
}
- (id)nextAction;
- (void)setNextAction:(id)arg1;
- (id)handler;
- (id)results;
- (void)dealloc;
- (id)initWithHandler:(id)arg1 results:(id)arg2;
@end
| 19.821429 | 83 | 0.704505 |
65f933de7b670cc8c34876cbc90d1d5b37eec277 | 42 | h | C | app/src/main/jni/Thirdparty/clapack/SRC/VARIANTS/qr/LL/blaswrap.h | BITLiuYu/ORBSLAM2Android | 14692a2ce08772f2bf33b5224e9ea81a6b2fbd19 | [
"Apache-2.0"
] | null | null | null | app/src/main/jni/Thirdparty/clapack/SRC/VARIANTS/qr/LL/blaswrap.h | BITLiuYu/ORBSLAM2Android | 14692a2ce08772f2bf33b5224e9ea81a6b2fbd19 | [
"Apache-2.0"
] | null | null | null | app/src/main/jni/Thirdparty/clapack/SRC/VARIANTS/qr/LL/blaswrap.h | BITLiuYu/ORBSLAM2Android | 14692a2ce08772f2bf33b5224e9ea81a6b2fbd19 | [
"Apache-2.0"
] | null | null | null | #include"../../../../INCLUDE/blaswrap.h"
| 21 | 41 | 0.547619 |
d0510a2d4d094e040bdcf4ac23ebc994bfd1a756 | 3,216 | c | C | examples/KPRCA_00073/src/list.c | li-xin-yi/cgc-cbs | eda14dc564ab0e57b44dfcd38a77d95086fee96f | [
"MIT"
] | 5 | 2019-06-11T13:06:42.000Z | 2022-02-21T15:37:22.000Z | examples/KPRCA_00073/src/list.c | li-xin-yi/cgc-cbs | eda14dc564ab0e57b44dfcd38a77d95086fee96f | [
"MIT"
] | 1 | 2021-11-20T03:46:09.000Z | 2021-11-22T16:42:52.000Z | examples/KPRCA_00073/src/list.c | li-xin-yi/cgc-cbs | eda14dc564ab0e57b44dfcd38a77d95086fee96f | [
"MIT"
] | 2 | 2020-11-06T23:16:00.000Z | 2022-02-20T01:12:40.000Z | /*
* Copyright (c) 2015 Kaprica Security, Inc.
*
* 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 "list.h"
#include "safe.h"
void AllocateAndInitializeListHead(list** List, void* Value)
{
if (!List)
return;
*List = xcalloc(1, sizeof(list));
(*List)->Value = Value;
}
void FreeList(list* List)
{
if (List)
{
if (List->Next)
{
FreeList(List->Next);
List->Next = NULL;
}
free(List);
}
}
size_t LenList(list* List)
{
size_t Len = 0;
for (; List; Len++)
List = List->Next;
return Len;
}
void AppendToList(list* List, void* Value)
{
if (!List)
return;
while (List->Next)
List = List->Next;
List->Next = xcalloc(1, sizeof(list));
List->Next->Value = Value;
}
void UniqAppendToList(list* List, void* Value)
{
while (List->Next)
{
if (List->Value == Value)
return;
else
List = List->Next;
}
if (List->Value != Value)
AppendToList(List, Value);
}
list* UniqExtendList(list* L1, list* L2)
{
list* Ret;
list* L1Walker;
if (!L1 && L2)
{
return L2;
}
else if (L1 && !L2)
{
return L1;
}
else if (L1 && L2)
{
Ret = L1;
while (L2)
{
L1Walker = L1;
while (L1Walker)
{
if (L1Walker->Value == L2->Value)
{
break;
}
else
{
// Check next value in L1
L1Walker = L1Walker->Next;
}
}
// Didn't find L2 value in L1.
if (!L1Walker)
{
AppendToList(L1, L2->Value);
}
// Move onto next value in L2 that we want to add.
L2 = L2->Next;
}
return Ret;
}
else
{
return NULL;
}
}
int CheckForCycle(list* List)
{
if (!List)
return 0;
list* Speedy = List->Next;
while (Speedy && List)
{
if (Speedy == List)
return 1;
if (Speedy->Next == NULL)
break;
Speedy = Speedy->Next->Next;
List = List->Next;
}
return 0;
}
void PrintList(FILE* Stream, list *List)
{
while (List)
{
if (List->Next)
fprintf(Stream, "%x:%s ", List, List->Value);
else
fprintf(Stream, "%x:%s\n", List, List->Value);
List = List->Next;
}
}
| 19.142857 | 80 | 0.602612 |
04fe44da24c22f6689622e9b8e36bed9fe2b670f | 31,359 | c | C | tags/rel_3_3/bbproxy/bbproxy.c | eagle-1/xymon | 2190e5b59c860fb1bb4e88075c61a1a25da04206 | [
"MIT"
] | null | null | null | tags/rel_3_3/bbproxy/bbproxy.c | eagle-1/xymon | 2190e5b59c860fb1bb4e88075c61a1a25da04206 | [
"MIT"
] | null | null | null | tags/rel_3_3/bbproxy/bbproxy.c | eagle-1/xymon | 2190e5b59c860fb1bb4e88075c61a1a25da04206 | [
"MIT"
] | null | null | null | /*----------------------------------------------------------------------------*/
/* Big Brother message proxy. */
/* */
/* Copyright (C) 2004 Henrik Storner <henrik@hswn.dk> */
/* */
/* This program is released under the GNU General Public License (GPL), */
/* version 2. See the file "COPYING" for details. */
/* */
/*----------------------------------------------------------------------------*/
static char rcsid[] = "$Id: bbproxy.c,v 1.32 2004-10-04 09:18:21 henrik Exp $";
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#if !defined(HPUX) /* HP-UX has select() and friends in sys/types.h */
#include <sys/select.h> /* Someday I'll move to GNU Autoconf for this ... */
#endif
#include <errno.h>
#include <sys/resource.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <netdb.h>
#include <ctype.h>
#include <signal.h>
#include "bbgen.h"
#include "util.h"
#include "debug.h"
/* These are dummy vars needed by stuff in util.c */
hostlist_t *hosthead = NULL;
link_t *linkhead = NULL;
link_t null_link = { "", "", "", NULL };
enum phase_t {
P_IDLE,
P_REQ_READING, /* Reading request data */
P_REQ_READY, /* Done reading request from client */
P_REQ_COMBINING,
P_REQ_CONNECTING, /* Connecting to server */
P_REQ_SENDING, /* Sending request data */
P_REQ_DONE, /* Done sending request data to server */
P_RESP_READING,
P_RESP_READY,
P_RESP_SENDING,
P_RESP_DONE,
P_CLEANUP
};
char *statename[P_CLEANUP+1] = {
"idle",
"reading from client",
"request from client OK",
"request combining",
"connecting to server",
"sending to server",
"request sent",
"reading from server",
"response from server OK",
"sending to client",
"response sent",
"cleanup"
};
typedef struct conn_t {
enum phase_t state;
int csocket;
struct sockaddr_in caddr;
struct in_addr *clientip, *serverip;
int snum;
int ssocket;
int conntries, sendtries;
int connectpending;
time_t conntime;
int madetocombo;
struct timeval timelimit, arrival;
unsigned char *buf, *bufp, *bufpsave;
unsigned int bufsize, buflen, buflensave;
struct conn_t *next;
} conn_t;
#define MAX_SERVERS 3
#define CONNECT_TRIES 3 /* How many connect-attempts against the server */
#define CONNECT_INTERVAL 8 /* Seconds between each connection attempt */
#define SEND_TRIES 2 /* How many times to try sending a message */
#define BUFSZ_READ 2048 /* Minimum #bytes that must be free when read'ing into a buffer */
#define BUFSZ_INC 8192 /* How much to grow the buffer when it is too small */
#define MAX_OPEN_SOCKS 256
#define MINIMUM_FOR_COMBO 2048 /* To start merging messages, at least have 2 KB free */
#define COMBO_DELAY 250000 /* Delay before sending a combo message (in microseconds) */
int keeprunning = 1;
time_t laststatus = 0;
char *logfile = NULL;
int logdetails = 0;
unsigned long msgs_timeout_from[P_CLEANUP+1] = { 0, };
void sigmisc_handler(int signum)
{
switch (signum) {
case SIGTERM:
errprintf("Caught TERM signal, terminating\n");
keeprunning = 0;
break;
case SIGHUP:
if (logfile) {
FILE *logfd = freopen(logfile, "a", stderr);
errprintf("Caught SIGHUP, reopening logfile\n");
}
break;
case SIGUSR1:
/* Trigger a status update */
laststatus = 0;
break;
case SIGUSR2:
logdetails = (1 - logdetails);
errprintf("Log details is %sabled\n", (logdetails ? "en" : "dis"));
break;
}
}
int overdue(struct timeval *now, struct timeval *limit)
{
if (now->tv_sec < limit->tv_sec) return 0;
else if (now->tv_sec > limit->tv_sec) return 1;
else return (now->tv_usec >= limit->tv_usec);
}
static int do_read(int sockfd, struct in_addr *addr, conn_t *conn, enum phase_t completedstate)
{
int n;
if ((conn->buflen + BUFSZ_READ + 1) > conn->bufsize) {
conn->bufsize += BUFSZ_INC;
conn->buf = realloc(conn->buf, conn->bufsize);
conn->bufp = conn->buf + conn->buflen;
}
n = read(sockfd, conn->bufp, (conn->bufsize - conn->buflen - 1));
if (n == -1) {
/* Error - abort */
errprintf("READ error from %s: %s\n", inet_ntoa(*addr), strerror(errno));
msgs_timeout_from[conn->state]++;
conn->state = P_CLEANUP;
return -1;
}
else if (n == 0) {
/* EOF - request is complete */
conn->state = completedstate;
}
else {
conn->buflen += n;
conn->bufp += n;
*conn->bufp = '\0';
}
return 0;
}
static int do_write(int sockfd, struct in_addr *addr, conn_t *conn, enum phase_t completedstate)
{
int n;
n = write(sockfd, conn->bufp, conn->buflen);
if (n == -1) {
/* Error - abort */
errprintf("WRITE error to %s: %s\n", inet_ntoa(*addr), strerror(errno));
msgs_timeout_from[conn->state]++;
conn->state = P_CLEANUP;
return -1;
}
else if (n >= 0) {
conn->buflen -= n;
conn->bufp += n;
if (conn->buflen == 0) {
conn->state = completedstate;
}
}
return 0;
}
void do_log(conn_t *conn)
{
char *rq, *eol, *delim;
char savechar;
rq = conn->buf+6;
if (strncmp(rq, "combo\n", 6) == 0) rq += 6;
eol = strchr(rq, '\n'); if (eol) *eol = '\0';
for (delim = rq; (*delim && isalpha((unsigned char) *delim)); delim++);
for (; (*delim && isspace((unsigned char) *delim)); delim++);
for (; (*delim && !isspace((unsigned char) *delim)); delim++);
savechar = *delim; *delim = '\0';
errprintf("%s : %s\n", inet_ntoa(*conn->clientip), rq);
*delim = savechar;
if (eol) *eol = '\n';
}
int main(int argc, char *argv[])
{
int daemonize = 1;
int timeout = 10;
int listenq = 512;
char *pidfile = "/var/run/bbproxy.pid";
char *proxyname = NULL;
char *proxynamesvc = "bbproxy";
int sockcount = 0;
int lsocket;
struct sockaddr_in laddr;
struct sockaddr_in bbdispaddr[MAX_SERVERS];
int bbdispcount = 0;
struct sockaddr_in bbpageraddr[MAX_SERVERS];
int bbpagercount = 0;
int opt;
conn_t *chead = NULL;
/* Statistics info */
time_t startuptime = time(NULL);
unsigned long msgs_total = 0;
unsigned long msgs_total_last = 0;
unsigned long msgs_combined = 0;
unsigned long msgs_merged = 0;
unsigned long msgs_delivered = 0;
unsigned long msgs_status = 0;
unsigned long msgs_page = 0;
unsigned long msgs_combo = 0;
unsigned long msgs_other = 0;
unsigned long msgs_recovered = 0;
struct timeval timeinqueue = { 0, 0 };
/* Dont save the output from errprintf() */
save_errbuf = 0;
memset(&laddr, 0, sizeof(laddr));
inet_aton("0.0.0.0", (struct in_addr *) &laddr.sin_addr.s_addr);
laddr.sin_port = htons(1984);
laddr.sin_family = AF_INET;
for (opt=1; (opt < argc); opt++) {
if (argnmatch(argv[opt], "--listen=")) {
char *locaddr, *p;
int locport;
locaddr = strchr(argv[opt], '=')+1;
p = strchr(locaddr, ':');
if (p) { locport = atoi(p+1); *p = '\0'; } else locport = 1984;
memset(&laddr, 0, sizeof(laddr));
laddr.sin_port = htons(locport);
laddr.sin_family = AF_INET;
if (inet_aton(locaddr, (struct in_addr *) &laddr.sin_addr.s_addr) == 0) {
errprintf("Invalid listen address %s\n", locaddr);
return 1;
}
}
else if (argnmatch(argv[opt], "--bbdisplay=")) {
char *ips, *ip1;
int port1;
ips = strdup(strchr(argv[opt], '=')+1);
ip1 = strtok(ips, ",");
while (ip1) {
char *p;
p = strchr(ip1, ':');
if (p) { port1 = atoi(p+1); *p = '\0'; } else port1 = 1984;
memset(&bbdispaddr[bbdispcount], 0, sizeof(bbdispaddr[bbdispcount]));
bbdispaddr[bbdispcount].sin_port = htons(port1);
bbdispaddr[bbdispcount].sin_family = AF_INET;
if (inet_aton(ip1, (struct in_addr *) &bbdispaddr[bbdispcount].sin_addr.s_addr) == 0) {
errprintf("Invalid remote address %s\n", ip1);
}
else {
bbdispcount++;
}
if (p) *p = ':';
ip1 = strtok(NULL, ",");
}
free(ips);
}
else if (argnmatch(argv[opt], "--bbpager=")) {
char *ips, *ip1;
int port1;
ips = strdup(strchr(argv[opt], '=')+1);
ip1 = strtok(ips, ",");
while (ip1) {
char *p;
p = strchr(ip1, ':');
if (p) { port1 = atoi(p+1); *p = '\0'; } else port1 = 1984;
memset(&bbpageraddr[bbpagercount], 0, sizeof(bbpageraddr[bbpagercount]));
bbpageraddr[bbpagercount].sin_port = htons(port1);
bbpageraddr[bbpagercount].sin_family = AF_INET;
if (inet_aton(ip1, (struct in_addr *) &bbpageraddr[bbpagercount].sin_addr.s_addr) == 0) {
errprintf("Invalid remote address %s\n", ip1);
}
else {
bbpagercount++;
}
if (p) *p = ':';
ip1 = strtok(NULL, ",");
}
free(ips);
}
else if (argnmatch(argv[opt], "--timeout=")) {
char *p = strchr(argv[opt], '=');
timeout = atoi(p+1);
}
else if (argnmatch(argv[opt], "--lqueue=")) {
char *p = strchr(argv[opt], '=');
listenq = atoi(p+1);
}
else if (strcmp(argv[opt], "--daemon") == 0) {
daemonize = 1;
}
else if (strcmp(argv[opt], "--no-daemon") == 0) {
daemonize = 0;
}
else if (argnmatch(argv[opt], "--pidfile=")) {
char *p = strchr(argv[opt], '=');
pidfile = strdup(p+1);
}
else if (argnmatch(argv[opt], "--logfile=")) {
char *p = strchr(argv[opt], '=');
logfile = strdup(p+1);
}
else if (strcmp(argv[opt], "--log-details") == 0) {
logdetails = 1;
}
else if (argnmatch(argv[opt], "--report=")) {
char *p1 = strchr(argv[opt], '=')+1;
if (strchr(p1, '.') == NULL) {
if (getenv("MACHINE") == NULL) {
errprintf("Environment variable MACHINE is undefined\n");
return 1;
}
proxyname = strdup(getenv("MACHINE"));
proxyname = (char *)realloc(proxyname, strlen(proxyname) + strlen(p1) + 1);
strcat(proxyname, ".");
strcat(proxyname, p1);
proxynamesvc = strdup(p1);
}
else {
proxyname = strdup(p1);
proxynamesvc = strchr(p1, '.')+1;
}
}
else if (strcmp(argv[opt], "--debug") == 0) {
debug = 1;
}
else if (strcmp(argv[opt], "--version") == 0) {
printf("bbproxy version %s\n", VERSION);
return 0;
}
else if (strcmp(argv[opt], "--help") == 0) {
printf("bbproxy version %s\n", VERSION);
printf("\nOptions:\n");
printf("\t--listen=IP[:port] : Listen address and portnumber\n");
printf("\t--bbdisplay=IP[:port] : BBDISPLAY server address and portnumber\n");
printf("\t--bbpager=IP[:port] : BBPAGER server address and portnumber\n");
printf("\t--report=[HOST.]SERVICE : Sends a BB status message about proxy activity\n");
printf("\t--timeout=N : Communications timeout (seconds)\n");
printf("\t--lqueue=N : Listen-queue size\n");
printf("\t--daemon : Run as a daemon\n");
printf("\t--no-daemon : Do not run as a daemon\n");
printf("\t--pidfile=FILENAME : Save proces-ID of daemon to FILENAME\n");
printf("\t--logfile=FILENAME : Log to FILENAME instead of stderr\n");
printf("\t--debug : Enable debugging output\n");
printf("\n");
return 0;
}
}
if (bbdispcount == 0) {
errprintf("No BBDISPLAY address given - aborting\n");
return 1;
}
if (bbpagercount == 0) {
int i;
for (i = 0; (i < bbdispcount); i++) {
memcpy(&bbpageraddr[i], &bbdispaddr[i], sizeof(bbpageraddr[i]));
bbpageraddr[i].sin_port = bbdispaddr[i].sin_port;
bbpageraddr[i].sin_family = bbdispaddr[i].sin_family;
bbpagercount++;
}
}
/* Set up a socket to listen for new connections */
lsocket = socket(AF_INET, SOCK_STREAM, 0);
if (lsocket == -1) {
errprintf("Cannot create listen socket (%s)\n", strerror(errno));
return 1;
}
opt = 1;
setsockopt(lsocket, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
fcntl(lsocket, F_SETFL, O_NONBLOCK);
if (bind(lsocket, (struct sockaddr *)&laddr, sizeof(laddr)) == -1) {
errprintf("Cannot bind to listen socket (%s)\n", strerror(errno));
return 1;
}
if (listen(lsocket, listenq) == -1) {
errprintf("Cannot listen (%s)\n", strerror(errno));
return 1;
}
/* Redirect logging to the logfile, if requested */
sigmisc_handler(SIGHUP);
errprintf("bbproxy version %s starting\n", VERSION);
errprintf("Listening on %s:%d\n", inet_ntoa(laddr.sin_addr), ntohs(laddr.sin_port));
{
int i;
char *p;
char srvrs[500];
for (i=0, srvrs[0] = '\0', p=srvrs; (i<bbdispcount); i++) {
p += sprintf(p, "%s:%d ", inet_ntoa(bbdispaddr[i].sin_addr), ntohs(bbdispaddr[i].sin_port));
}
errprintf("Sending to BBDISPLAY(s) %s\n", srvrs);
for (i=0, srvrs[0] = '\0', p=srvrs; (i<bbpagercount); i++) {
p += sprintf(p, "%s:%d ", inet_ntoa(bbpageraddr[i].sin_addr), ntohs(bbpageraddr[i].sin_port));
}
errprintf("Sending to BBPAGER(s) %s\n", srvrs);
}
if (daemonize) {
pid_t childpid;
fclose(stdin);
fclose(stdout);
/* Become a daemon */
childpid = fork();
if (childpid < 0) {
/* Fork failed */
errprintf("Could not fork\n");
exit(1);
}
else if (childpid > 0) {
/* Parent - save PID and exit */
FILE *fd = fopen(pidfile, "w");
if (fd) {
fprintf(fd, "%d\n", (int)childpid);
fclose(fd);
}
exit(0);
}
/* Child (daemon) continues here */
setsid();
}
setup_signalhandler(proxynamesvc);
signal(SIGHUP, sigmisc_handler);
signal(SIGTERM, sigmisc_handler);
signal(SIGUSR1, sigmisc_handler);
signal(SIGUSR2, sigmisc_handler);
do {
fd_set fdread, fdwrite;
int maxfd;
struct timeval tmo;
struct timezone tz;
int n, idx;
conn_t *cwalk;
time_t ctime;
time_t now;
int combining = 0;
/* See if it is time for a status report */
if (proxyname && ((now = time(NULL)) >= (laststatus+300))) {
conn_t *stentry = NULL;
int ccount = 0;
unsigned long bufspace = 0;
char runtime_s[30];
unsigned long runt = (unsigned long) (now-startuptime);
char *p;
sprintf(runtime_s, "%lu days, %02lu:%02lu:%02lu",
(runt/86400), ((runt % 86400) / 3600),
((runt % 3600) / 60), (runt % 60));
init_timestamp();
for (cwalk = chead; (cwalk); cwalk = cwalk->next) {
ccount++;
bufspace += cwalk->bufsize;
if (cwalk->state == P_IDLE) stentry = cwalk;
}
if (stentry) {
unsigned long avgtime; /* In millisecs */
avgtime = (timeinqueue.tv_sec*1000 + timeinqueue.tv_usec/1000) / (msgs_total - msgs_total_last);
sprintf(stentry->buf, "combo\nstatus %s green %s Proxy up %s\n\nProxy statistics\n\nIncoming messages : %10lu (%lu msgs/second)\nOutbound messages : %10lu\n\nIncoming message distribution\n- Combo messages : %10lu\n- Status messages : %10lu\n Messages merged : %10lu\n Resulting combos : %10lu\n- Page messages : %10lu\n- Other messages : %10lu\n\nProxy ressources\n- Connection table size : %10d\n- Buffer space : %10lu kByte\n",
proxyname, timestamp, runtime_s,
msgs_total, (msgs_total - msgs_total_last) / (now - laststatus),
msgs_delivered,
msgs_combo,
msgs_status, msgs_merged, msgs_combined,
msgs_page, msgs_other,
ccount, bufspace / 1024);
p = stentry->buf + strlen(stentry->buf);
p += sprintf(p, "\nTimeout/failure details\n");
p += sprintf(p, "- %-22s : %10lu\n", statename[P_REQ_READING], msgs_timeout_from[P_REQ_READING]);
p += sprintf(p, "- %-22s : %10lu\n", statename[P_REQ_CONNECTING], msgs_timeout_from[P_REQ_CONNECTING]);
p += sprintf(p, "- %-22s : %10lu\n", statename[P_REQ_SENDING], msgs_timeout_from[P_REQ_SENDING]);
p += sprintf(p, "- %-22s : %10lu\n", "recovered", msgs_recovered);
p += sprintf(p, "- %-22s : %10lu\n", statename[P_RESP_READING], msgs_timeout_from[P_RESP_READING]);
p += sprintf(p, "- %-22s : %10lu\n", statename[P_RESP_SENDING], msgs_timeout_from[P_RESP_SENDING]);
p += sprintf(p, "\n%-24s : %10lu.%03lu\n", "Average queue time",
(avgtime / 1000), (avgtime % 1000));
/* Clear the summary collection totals */
laststatus = now;
msgs_total_last = msgs_total;
timeinqueue.tv_sec = timeinqueue.tv_usec = 0;
stentry->buflen = strlen(stentry->buf);
stentry->bufp = stentry->buf;
stentry->state = P_REQ_READY;
}
}
FD_ZERO(&fdread);
FD_ZERO(&fdwrite);
maxfd = -1;
combining = 0;
for (cwalk = chead, idx=0; (cwalk); cwalk = cwalk->next, idx++) {
dprintf("state %d: %s\n", idx, statename[cwalk->state]);
switch (cwalk->state) {
case P_REQ_READING:
FD_SET(cwalk->csocket, &fdread);
if (cwalk->csocket > maxfd) maxfd = cwalk->csocket;
break;
case P_REQ_READY:
if (cwalk->buflen <= 6) {
/* Got an empty request - just drop it */
dprintf("Dropping empty request from %s\n", inet_ntoa(*cwalk->clientip));
cwalk->state = P_CLEANUP;
break;
}
if (logdetails) do_log(cwalk);
cwalk->conntries = CONNECT_TRIES;
cwalk->sendtries = SEND_TRIES;
cwalk->conntime = 0;
/*
* We now want to find out what kind of message we've got.
* If it's NOT a "status" message, just pass it along.
* For "status" messages, we want to try and merge many small
* messages into a "combo" message - so send those off the the
* P_REQ_COMBINING state for a while.
* If we are not going to send back a response to the client, we
* also close the client socket since it is no longer needed.
* Note that since we started out as optimists and put a "combo\n"
* at the front of the buffer, we need to skip that when looking at
* what type of message it is. Hence the "cwalk->buf+6".
*/
if ((strncmp(cwalk->buf+6, "query", 5) == 0) || (strncmp(cwalk->buf+6, "config", 6) == 0)) {
shutdown(cwalk->csocket, SHUT_RD);
msgs_other++;
cwalk->snum = 1; /* We only do these once! */
}
else {
if (cwalk->csocket >= 0) {
shutdown(cwalk->csocket, SHUT_RDWR);
close(cwalk->csocket); sockcount--;
cwalk->csocket = -1;
}
cwalk->snum = bbdispcount;
if (strncmp(cwalk->buf+6, "status", 6) == 0) {
msgs_status++;
gettimeofday(&cwalk->timelimit, &tz);
cwalk->timelimit.tv_usec += COMBO_DELAY;
if (cwalk->timelimit.tv_usec >= 1000000) {
cwalk->timelimit.tv_sec++;
cwalk->timelimit.tv_usec -= 1000000;
}
cwalk->state = P_REQ_COMBINING;
break;
}
else if (strncmp(cwalk->buf+6, "combo", 5) == 0) {
msgs_combo++;
}
else if (strncmp(cwalk->buf+6, "page", 4) == 0) {
cwalk->snum = bbpagercount;
msgs_page++;
}
else {
msgs_other++;
}
}
/*
* This wont be made into a combo message, so skip the "combo\n"
* and go off to send the message to the server.
*/
cwalk->bufp = cwalk->buf+6;
cwalk->buflen -= 6;
cwalk->bufpsave = cwalk->bufp;
cwalk->buflensave = cwalk->buflen;
cwalk->state = P_REQ_CONNECTING;
/* Fall through for non-status messages */
case P_REQ_CONNECTING:
/* Need to restore the bufp and buflen, as we may get here many times for one message */
cwalk->bufp = cwalk->bufpsave;
cwalk->buflen = cwalk->buflensave;
ctime = time(NULL);
if (ctime < (cwalk->conntime + CONNECT_INTERVAL)) {
dprintf("Delaying retry of connection\n");
break;
}
cwalk->conntries--;
cwalk->conntime = ctime;
if (cwalk->conntries < 0) {
errprintf("Server not responding, message lost\n");
cwalk->state = P_CLEANUP;
msgs_timeout_from[P_REQ_CONNECTING]++;
break;
}
cwalk->ssocket = socket(AF_INET, SOCK_STREAM, 0);
if (cwalk->ssocket == -1) {
dprintf("Could not get a socket - will try again\n");
break; /* Retry the next time around */
}
sockcount++;
fcntl(cwalk->ssocket, F_SETFL, O_NONBLOCK);
if (strncmp(cwalk->buf, "page", 4) == 0) {
int idx = (bbpagercount - cwalk->snum);
n = connect(cwalk->ssocket, (struct sockaddr *)&bbpageraddr[idx], sizeof(bbpageraddr[idx]));
cwalk->serverip = &bbpageraddr[idx].sin_addr;
dprintf("Connecting to BBPAGER at %s\n", inet_ntoa(*cwalk->serverip));
}
else {
int idx = (bbdispcount - cwalk->snum);
n = connect(cwalk->ssocket, (struct sockaddr *)&bbdispaddr[idx], sizeof(bbdispaddr[idx]));
cwalk->serverip = &bbdispaddr[idx].sin_addr;
dprintf("Connecting to BBDISPLAY at %s\n", inet_ntoa(*cwalk->serverip));
}
if ((n == 0) || ((n == -1) && (errno == EINPROGRESS))) {
cwalk->state = P_REQ_SENDING;
cwalk->connectpending = 1;
gettimeofday(&cwalk->timelimit, &tz);
cwalk->timelimit.tv_sec += timeout;
/* Fallthrough */
}
else {
/* Could not connect! Invoke retries */
dprintf("Connect to server failed: %s\n", strerror(errno));
close(cwalk->ssocket); sockcount--;
cwalk->ssocket = -1;
break;
}
/* No "break" here! */
case P_REQ_SENDING:
FD_SET(cwalk->ssocket, &fdwrite);
if (cwalk->ssocket > maxfd) maxfd = cwalk->ssocket;
break;
case P_REQ_DONE:
/* Request is off to the server */
shutdown(cwalk->ssocket, SHUT_WR);
cwalk->snum--;
if (cwalk->snum) {
/* More servers to do */
close(cwalk->ssocket); cwalk->ssocket = -1; sockcount--;
cwalk->conntries = CONNECT_TRIES;
cwalk->sendtries = SEND_TRIES;
cwalk->conntime = 0;
cwalk->state = P_REQ_CONNECTING;
break;
}
else {
/* All servers done */
cwalk->bufp = cwalk->buf; cwalk->buflen = 0;
memset(cwalk->buf, 0, cwalk->bufsize);
}
msgs_delivered++;
if (cwalk->sendtries < SEND_TRIES) {
errprintf("Recovered from write error after %d retries\n",
(SEND_TRIES - cwalk->sendtries));
msgs_recovered++;
}
if (cwalk->arrival.tv_sec > 0) {
struct timeval departure;
gettimeofday(&departure, &tz);
timeinqueue.tv_sec += (departure.tv_sec - cwalk->arrival.tv_sec);
if (departure.tv_usec >= cwalk->arrival.tv_usec) {
timeinqueue.tv_usec += (departure.tv_usec - cwalk->arrival.tv_usec);
}
else {
timeinqueue.tv_sec--;
timeinqueue.tv_usec += (1000000 + departure.tv_usec - cwalk->arrival.tv_usec);
}
if (timeinqueue.tv_usec > 1000000) {
timeinqueue.tv_sec++;
timeinqueue.tv_usec -= 1000000;
}
}
else {
errprintf("Odd ... this message was not timestamped\n");
}
if (cwalk->csocket < 0) {
cwalk->state = P_CLEANUP;
break;
}
else {
cwalk->state = P_RESP_READING;
gettimeofday(&cwalk->timelimit, &tz);
cwalk->timelimit.tv_sec += timeout;
}
/* Fallthrough */
case P_RESP_READING:
FD_SET(cwalk->ssocket, &fdread);
if (cwalk->ssocket > maxfd) maxfd = cwalk->ssocket;
break;
case P_RESP_READY:
shutdown(cwalk->ssocket, SHUT_RD);
close(cwalk->ssocket); sockcount--;
cwalk->ssocket = -1;
cwalk->bufp = cwalk->buf;
cwalk->state = P_RESP_SENDING;
gettimeofday(&cwalk->timelimit, &tz);
cwalk->timelimit.tv_sec += timeout;
/* Fall through */
case P_RESP_SENDING:
if (cwalk->buflen && (cwalk->csocket >= 0)) {
FD_SET(cwalk->csocket, &fdwrite);
if (cwalk->csocket > maxfd) maxfd = cwalk->csocket;
break;
}
else {
cwalk->state = P_RESP_DONE;
}
/* Fall through */
case P_RESP_DONE:
if (cwalk->csocket >= 0) {
shutdown(cwalk->csocket, SHUT_WR);
close(cwalk->csocket); sockcount--;
}
cwalk->csocket = -1;
cwalk->state = P_CLEANUP;
/* Fall through */
case P_CLEANUP:
if (cwalk->csocket >= 0) {
close(cwalk->csocket); sockcount--;
cwalk->csocket = -1;
}
if (cwalk->ssocket >= 0) {
close(cwalk->ssocket); sockcount--;
cwalk->ssocket = -1;
}
cwalk->arrival.tv_sec = cwalk->arrival.tv_usec = 0;
cwalk->bufp = cwalk->bufp;
cwalk->buflen = 0;
memset(cwalk->buf, 0, cwalk->bufsize);
memset(&cwalk->caddr, 0, sizeof(cwalk->caddr));
cwalk->madetocombo = 0;
cwalk->state = P_IDLE;
break;
case P_IDLE:
break;
case P_REQ_COMBINING:
/* See if we can combine some "status" messages into a "combo" */
combining++;
gettimeofday(&tmo, &tz);
if ((cwalk->buflen < MINIMUM_FOR_COMBO) && !overdue(&tmo, &cwalk->timelimit)) {
conn_t *cextra;
/* Are there any other messages in P_COMBINING state ? */
cextra = cwalk->next;
while (cextra && (cextra->state != P_REQ_COMBINING)) cextra = cextra->next;
if (cextra) {
/*
* Yep. It might be worthwhile to go for a combo.
*/
while (cextra && (cwalk->buflen < (MAXMSG-20))) {
if (strncmp(cextra->buf+6, "status", 6) == 0) {
int newsize;
/*
* Size of the new message - if the cextra one
* is merged - is the cwalk buffer, plus the
* two newlines separating messages in combo's,
* plus the cextra buffer except the leading
* "combo\n" of 6 bytes.
*/
newsize = cwalk->buflen + 2 + (cextra->buflen - 6);
if ((newsize < cwalk->bufsize) && (newsize < MAXMSG)) {
/*
* There's room for it. Add it to the
* cwalk buffer, but without the leading
* "combo\n" (we already have one of those).
*/
cwalk->madetocombo++;
strcat(cwalk->buf, "\n\n");
strcat(cwalk->buf, cextra->buf+6);
cwalk->buflen = newsize;
cextra->state = P_CLEANUP;
dprintf("Merged combo\n");
msgs_merged++;
}
}
/* Go to the next connection in the right state */
do {
cextra = cextra->next;
} while (cextra && (cextra->state != P_REQ_COMBINING));
}
}
}
else {
combining--;
cwalk->state = P_REQ_CONNECTING;
if (cwalk->madetocombo) {
/*
* Point the outgoing buffer pointer to the full
* message, including the "combo\n"
*/
cwalk->bufp = cwalk->buf;
cwalk->madetocombo++;
msgs_merged++; /* Count the proginal message also */
msgs_combined++;
dprintf("Now going to send combo from %d messages\n%s\n",
cwalk->madetocombo, cwalk->buf);
}
else {
/*
* Skip sending the "combo\n" at start of buffer.
*/
cwalk->bufp = cwalk->buf+6;
cwalk->buflen -= 6;
dprintf("No messages to combine - sending unchanged\n");
}
}
cwalk->bufpsave = cwalk->bufp;
cwalk->buflensave = cwalk->buflen;
break;
default:
break;
}
}
/* Add the listen-socket to the select() list, but only if we have room */
if (sockcount < MAX_OPEN_SOCKS) {
FD_SET(lsocket, &fdread);
if (lsocket > maxfd) maxfd = lsocket;
}
else {
static time_t lastlog = 0;
if ((now = time(NULL)) < (lastlog+30)) {
lastlog = now;
errprintf("Squelching incoming connections, sockcount=%d\n", sockcount);
}
}
if (combining) {
tmo.tv_sec = 0; tmo.tv_usec = COMBO_DELAY;
}
else {
tmo.tv_sec = 1; tmo.tv_usec = 0;
}
n = select(maxfd+1, &fdread, &fdwrite, NULL, &tmo);
if (n <= 0) {
gettimeofday(&tmo, &tz);
for (cwalk = chead; (cwalk); cwalk = cwalk->next) {
switch (cwalk->state) {
case P_REQ_READING:
case P_REQ_SENDING:
case P_RESP_READING:
case P_RESP_SENDING:
if (overdue(&tmo, &cwalk->timelimit)) {
cwalk->state = P_CLEANUP;
msgs_timeout_from[cwalk->state]++;
}
break;
default:
break;
}
}
}
else {
for (cwalk = chead; (cwalk); cwalk = cwalk->next) {
switch (cwalk->state) {
case P_REQ_READING:
if (FD_ISSET(cwalk->csocket, &fdread)) {
do_read(cwalk->csocket, cwalk->clientip, cwalk, P_REQ_READY);
}
break;
case P_REQ_SENDING:
if (FD_ISSET(cwalk->ssocket, &fdwrite)) {
if (cwalk->connectpending) {
int connres, connressize;
/* First time ready for write - check connect status */
cwalk->connectpending = 0;
connressize = sizeof(connres);
n = getsockopt(cwalk->ssocket, SOL_SOCKET, SO_ERROR, &connres, &connressize);
if (connres != 0) {
/* Connect failed! Invoke retries. */
dprintf("Connect to server failed: %s - retrying\n",
strerror(errno));
close(cwalk->ssocket); sockcount--;
cwalk->ssocket = -1;
cwalk->state = P_REQ_CONNECTING;
break;
}
}
if ( (do_write(cwalk->ssocket, cwalk->serverip, cwalk, P_REQ_DONE) == -1) &&
(cwalk->sendtries > 0) ) {
/*
* Got a "write" error after connecting.
* Try saving the situation by retrying the send later.
*/
dprintf("Attempting recovery from write error\n");
close(cwalk->ssocket); sockcount--; cwalk->ssocket = -1;
cwalk->sendtries--;
cwalk->state = P_REQ_CONNECTING;
cwalk->conntries = CONNECT_TRIES;
cwalk->conntime = time(NULL);
}
}
break;
case P_RESP_READING:
if (FD_ISSET(cwalk->ssocket, &fdread)) {
do_read(cwalk->ssocket, cwalk->serverip, cwalk, P_RESP_READY);
}
break;
case P_RESP_SENDING:
if (FD_ISSET(cwalk->csocket, &fdwrite)) {
do_write(cwalk->csocket, cwalk->clientip, cwalk, P_RESP_DONE);
}
break;
default:
break;
}
}
if (FD_ISSET(lsocket, &fdread)) {
/* New incoming connection */
conn_t *newconn;
int caddrsize;
dprintf("New connection\n");
for (cwalk = chead; (cwalk && (cwalk->state != P_IDLE)); cwalk = cwalk->next);
if (cwalk) {
newconn = cwalk;
}
else {
newconn = malloc(sizeof(conn_t));
newconn->next = chead;
chead = newconn;
newconn->bufsize = BUFSZ_INC;
newconn->buf = newconn->bufp = malloc(newconn->bufsize);
}
newconn->connectpending = 0;
newconn->madetocombo = 0;
newconn->snum = 0;
newconn->ssocket = -1;
newconn->serverip = NULL;
newconn->conntries = 0;
newconn->sendtries = 0;
newconn->timelimit.tv_sec = newconn->timelimit.tv_usec = 0;
/*
* Why this ? Because we like to merge small status messages
* into larger combo messages. So put a "combo\n" at the start
* of the buffer, and then don't send it if we decide it won't
* be a combo-message after all.
*/
strcpy(newconn->buf, "combo\n");
newconn->buflen = 6;
newconn->bufp = newconn->buf+6;
caddrsize = sizeof(newconn->caddr);
newconn->csocket = accept(lsocket, (struct sockaddr *)&newconn->caddr, &caddrsize);
if (newconn->csocket == -1) {
/* accept() failure. Yes, it does happen! */
dprintf("accept failure, ignoring connection (%s), sockcount=%d\n",
strerror(errno), sockcount);
newconn->state = P_IDLE;
}
else {
msgs_total++;
newconn->clientip = &newconn->caddr.sin_addr;
sockcount++;
fcntl(newconn->csocket, F_SETFL, O_NONBLOCK);
newconn->state = P_REQ_READING;
gettimeofday(&newconn->arrival, &tz);
newconn->timelimit.tv_sec = newconn->arrival.tv_sec + timeout;
newconn->timelimit.tv_usec = newconn->arrival.tv_usec;
}
}
}
} while (keeprunning);
if (pidfile) unlink(pidfile);
return 0;
}
| 29.44507 | 506 | 0.5975 |
30fdca49487e55c1e4fd03a435d496536f70201c | 901 | h | C | System/Library/Frameworks/CFNetwork.framework/NSHTTPCookieInternal_Data.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | 2 | 2021-11-02T09:23:27.000Z | 2022-03-28T08:21:57.000Z | System/Library/Frameworks/CFNetwork.framework/NSHTTPCookieInternal_Data.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | null | null | null | System/Library/Frameworks/CFNetwork.framework/NSHTTPCookieInternal_Data.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | 1 | 2022-03-28T08:21:59.000Z | 2022-03-28T08:21:59.000Z | /*
* This header is generated by classdump-dyld 1.5
* on Friday, April 30, 2021 at 11:34:54 AM Mountain Standard Time
* Operating System: Version 13.5.1 (Build 17F80)
* Image Source: /System/Library/Frameworks/CFNetwork.framework/CFNetwork
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley.
*/
#import <CFNetwork/CFNetwork-Structs.h>
#import <CFNetwork/NSHTTPCookieInternal.h>
@interface NSHTTPCookieInternal_Data : NSHTTPCookieInternal {
CompactHTTPCookieWithData* _fromData;
}
-(id)init;
-(void)dealloc;
-(HTTPCookie*)_inner;
-(id)_initWithProperties:(id)arg1 fromString:(BOOL)arg2 ;
-(id)_initWithCookie:(id)arg1 partition:(id)arg2 ;
-(id)_initWithHeader:(const CompactCookieHeaderRef)arg1 ;
@end
| 36.04 | 130 | 0.657048 |
45ff667536a85551b6cbda4c30f1e874f74c25e8 | 466 | h | C | csapex_core_plugins/src/text/text_input.h | AdrianZw/csapex_core_plugins | 1b23c90af7e552c3fc37c7dda589d751d2aae97f | [
"BSD-3-Clause"
] | 2 | 2016-09-02T15:33:22.000Z | 2019-05-06T22:09:33.000Z | csapex_core_plugins/src/text/text_input.h | AdrianZw/csapex_core_plugins | 1b23c90af7e552c3fc37c7dda589d751d2aae97f | [
"BSD-3-Clause"
] | 1 | 2021-02-14T19:53:30.000Z | 2021-02-14T19:53:30.000Z | csapex_core_plugins/src/text/text_input.h | AdrianZw/csapex_core_plugins | 1b23c90af7e552c3fc37c7dda589d751d2aae97f | [
"BSD-3-Clause"
] | 6 | 2016-10-12T00:55:23.000Z | 2021-02-10T17:49:25.000Z | #ifndef TEXT_INPUT_H
#define TEXT_INPUT_H
/// PROJECT
#include <csapex/model/node.h>
namespace csapex
{
class CSAPEX_EXPORT_PLUGIN TextInput : public Node
{
public:
TextInput();
void process() override;
void setup(csapex::NodeModifier& node_modifier) override;
void setupParameters(Parameterizable& parameters) override;
private:
Output* output_;
Event* event_;
std::string text_;
};
} // namespace csapex
#endif // TEXT_INPUT_H
| 16.642857 | 63 | 0.72103 |
34084cf30d168e9078e10632d043c63a7d121290 | 611 | h | C | SourceCode/am_addadmin.h | wuwei211x/LibraryManagementByQt | ee26bb80ed80898a839cabb23635f0fff872c457 | [
"MIT"
] | 8 | 2020-07-05T07:32:11.000Z | 2021-12-24T13:50:31.000Z | SourceCode/am_addadmin.h | wuwei211x/LibraryManagementByQt | ee26bb80ed80898a839cabb23635f0fff872c457 | [
"MIT"
] | 1 | 2021-11-09T14:53:34.000Z | 2021-11-25T15:43:57.000Z | SourceCode/am_addadmin.h | wuwei211x/LibraryManagementByQt | ee26bb80ed80898a839cabb23635f0fff872c457 | [
"MIT"
] | 2 | 2020-12-28T12:27:02.000Z | 2021-05-29T07:37:58.000Z | #ifndef AM_ADDADMIN_H
#define AM_ADDADMIN_H
#include <QWidget>
#include "Classes/Admin.h"
namespace Ui {
class am_AddAdmin;
}
class am_AddAdmin : public QWidget
{
Q_OBJECT
public:
explicit am_AddAdmin(QWidget *parent = nullptr);
~am_AddAdmin();
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
signals:
void sendAdmin_aa(Admin);
private slots:
void on_but_ok_clicked();
private:
Ui::am_AddAdmin *ui;
QPoint startPoint;
QPoint windowPoint;
bool isMove;
};
#endif // AM_ADDADMIN_H
| 17.970588 | 52 | 0.723404 |
e747dfbe050c0303eaebbb7b26f6d0d3a530e6fa | 1,404 | c | C | helper/commfile.c | redscarf2/sinstar_client | 4411edf9bd9258b8db278d02c5a656d9f4586165 | [
"MIT"
] | null | null | null | helper/commfile.c | redscarf2/sinstar_client | 4411edf9bd9258b8db278d02c5a656d9f4586165 | [
"MIT"
] | null | null | null | helper/commfile.c | redscarf2/sinstar_client | 4411edf9bd9258b8db278d02c5a656d9f4586165 | [
"MIT"
] | null | null | null | #include <windows.h>
#include <assert.h>
#include "..\include\commfile.h"
COMFILE CF_Init(LPBYTE pbyBuf,int nBufSize,int nValidSize,int nOffset)
{
COMFILE f;
f.pbyData=pbyBuf;
f.nBufSize=nBufSize;
f.nLen=nValidSize;
f.nOffset=nOffset;
return f;
}
int CF_Read(COMFILE *pcf,void *pBuf,int nSize)
{
int nReaded=pcf->nLen-pcf->nOffset;
if(nReaded>nSize) nReaded=nSize;
if(nReaded==0) return 0;
memcpy(pBuf,pcf->pbyData+pcf->nOffset ,nReaded);
pcf->nOffset+=nReaded;
return nReaded;
}
BYTE CF_ReadChar(COMFILE *pcf)
{
assert(!CF_EOF(pcf));
return pcf->pbyData[pcf->nOffset++];
}
int CF_Write(COMFILE *pcf,void *pBuf,int nSize)
{
int nWrited=nSize;
if(pcf->nOffset+nSize>pcf->nBufSize) nWrited=pcf->nBufSize-pcf->nOffset;
if(nWrited==0) return 0;
memcpy(pcf->pbyData+pcf->nOffset,pBuf,nWrited);
pcf->nOffset+=nWrited;
if(pcf->nOffset>pcf->nLen) pcf->nLen=pcf->nOffset;
return nWrited;
}
int CF_WriteChar(COMFILE *pcf,BYTE byData)
{
return CF_Write(pcf,&byData,1);
}
BOOL CF_EOF(COMFILE *pcf)
{
return pcf->nOffset==pcf->nLen;
}
int CF_Tell(COMFILE *pcf)
{
return pcf->nOffset;
}
int CF_Seek(COMFILE *pcf,int nOffset,int nOrigin)
{
int nNew=pcf->nOffset;
switch(nOrigin)
{
case SEEK_SET:nNew=nOffset;break;
case SEEK_CUR:nNew+=nOffset;break;
case SEEK_END:nNew=pcf->nLen+nOffset;break;
}
if(nNew>=0 && nNew<=pcf->nLen)
{
pcf->nOffset=nNew;
}
return pcf->nOffset;
}
| 19.232877 | 73 | 0.713675 |
bd82ba1cbdb01466c9eddcb241bcdd2eaa1015f4 | 1,240 | h | C | client/messaging/messaging.h | it300/Chimera600 | a5fbe0fb3e83c9a3855c29a5faaec8169965e4ad | [
"MIT"
] | 2 | 2020-11-11T03:04:26.000Z | 2021-03-03T10:16:32.000Z | client/messaging/messaging.h | it300/Chimera600 | a5fbe0fb3e83c9a3855c29a5faaec8169965e4ad | [
"MIT"
] | null | null | null | client/messaging/messaging.h | it300/Chimera600 | a5fbe0fb3e83c9a3855c29a5faaec8169965e4ad | [
"MIT"
] | null | null | null | #pragma once
#include <string>
#include "../../math/data_types.h"
/// Output a C string to the console while optionally using a color.
void console_out(const char *text, const ColorARGB &color = ColorARGB()) noexcept;
/// Output a C++ string to the console with a C++ string while optionally using a color.
void console_out(const std::string &text, const ColorARGB &color = ColorARGB()) noexcept;
/// Output a C string to the console using yellow text. This is used for warnings.
void console_out_warning(const char *text) noexcept;
/// Output a C++ string to the console using yellow text. This is used for warnings.
void console_out_warning(const std::string &text) noexcept;
/// Output a C string to the console using red text. This is used for errors.
void console_out_error(const char *text) noexcept;
/// Output a C++ string to the console using red text. This is used for errors.
void console_out_error(const std::string &text) noexcept;
/// Output a C string to the HUD.
void hud_message(const char *message) noexcept;
/// Output a wide string to the HUD.
void hud_message(const short *message) noexcept;
/// Output a C++ string to the HUD.
void hud_message(std::string message) noexcept;
| 37.575758 | 90 | 0.726613 |
83a832271b67a282ccb9336dbbe6dbf143b9090f | 1,123 | h | C | NanoTimeKitCompanion.framework/NTKSafeLocketReader.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | 4 | 2021-10-06T12:15:26.000Z | 2022-02-21T02:26:00.000Z | NanoTimeKitCompanion.framework/NTKSafeLocketReader.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | null | null | null | NanoTimeKitCompanion.framework/NTKSafeLocketReader.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | 1 | 2021-10-08T07:40:53.000Z | 2021-10-08T07:40:53.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/PrivateFrameworks/NanoTimeKitCompanion.framework/NanoTimeKitCompanion
*/
@interface NTKSafeLocketReader : NSObject {
NSString * _defaultPhotoPath;
<NTKSafeLocketReaderDelegate> * _delegate;
bool _isPhotoLibraryAvailable;
NPTOLocket * _locket;
}
@property (nonatomic) <NTKSafeLocketReaderDelegate> *delegate;
@property (nonatomic, readonly) bool firstUnlockHasOccurred;
@property (nonatomic, readonly) NPTOLocket *locket;
@property (nonatomic, readonly) unsigned long long numberOfLoadedPhotos;
@property (nonatomic, readonly) unsigned long long numberOfTotalPhotos;
- (void).cxx_destruct;
- (id)delegate;
- (bool)firstUnlockHasOccurred;
- (unsigned long long)indexOfPhotoWithIdentifier:(id)arg1;
- (id)initWithDefaultPhotoPath:(id)arg1;
- (long long)keyAssetIndex;
- (void)loadPhotoAtIndex:(unsigned long long)arg1 handler:(id /* block */)arg2;
- (id)locket;
- (unsigned long long)numberOfLoadedPhotos;
- (unsigned long long)numberOfTotalPhotos;
- (id)remoteCollectionIdentifier;
- (void)setDelegate:(id)arg1;
- (id)subtitle;
- (id)title;
@end
| 33.029412 | 95 | 0.779163 |
2309f464232a744a8aef05a08da4a018b632089b | 163 | h | C | Example/Pods/Target Support Files/WeakArray/WeakArray-umbrella.h | raumfeld/WeakArray | 558a52183a3daeef4ba51f0c41789631ec087fbc | [
"MIT"
] | null | null | null | Example/Pods/Target Support Files/WeakArray/WeakArray-umbrella.h | raumfeld/WeakArray | 558a52183a3daeef4ba51f0c41789631ec087fbc | [
"MIT"
] | null | null | null | Example/Pods/Target Support Files/WeakArray/WeakArray-umbrella.h | raumfeld/WeakArray | 558a52183a3daeef4ba51f0c41789631ec087fbc | [
"MIT"
] | 1 | 2018-12-22T19:56:06.000Z | 2018-12-22T19:56:06.000Z | #ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
FOUNDATION_EXPORT double WeakArrayVersionNumber;
FOUNDATION_EXPORT const unsigned char WeakArrayVersionString[];
| 18.111111 | 63 | 0.834356 |
03196bfe938d48e61cb3be69866f8a99bd307acc | 364 | h | C | src/Engine/Common.h | Bisjoe/bart-sdl-engine-e15 | 22c2481d7248559b25a94c01b7b7aff7993c29bd | [
"MIT"
] | null | null | null | src/Engine/Common.h | Bisjoe/bart-sdl-engine-e15 | 22c2481d7248559b25a94c01b7b7aff7993c29bd | [
"MIT"
] | null | null | null | src/Engine/Common.h | Bisjoe/bart-sdl-engine-e15 | 22c2481d7248559b25a94c01b7b7aff7993c29bd | [
"MIT"
] | null | null | null | #pragma once
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"
#include "SDL_mixer.h"
#include "Vector.h"
#include "Rectangle.h"
#define DEFAULT_WINDOW_TITLE "SDL Engine: "
#define DEFAULT_WINDOW_WIDTH 800
#define DEFAULT_WINDOW_HEIGHT 600 | 18.2 | 43 | 0.75 |
0342e2de76b0e8749e344556c101cb6831190af0 | 17,234 | c | C | sources/drivers/misc/mediatek/atf_log/atf_logger.c | fuldaros/paperplane_kernel_wileyfox-spark | bea244880d2de50f4ad14bb6fa5777652232c033 | [
"Apache-2.0"
] | 2 | 2018-03-09T23:59:27.000Z | 2018-04-01T07:58:39.000Z | sources/drivers/misc/mediatek/atf_log/atf_logger.c | fuldaros/paperplane_kernel_wileyfox-spark | bea244880d2de50f4ad14bb6fa5777652232c033 | [
"Apache-2.0"
] | null | null | null | sources/drivers/misc/mediatek/atf_log/atf_logger.c | fuldaros/paperplane_kernel_wileyfox-spark | bea244880d2de50f4ad14bb6fa5777652232c033 | [
"Apache-2.0"
] | 3 | 2017-06-24T20:23:09.000Z | 2018-03-25T04:30:11.000Z | #define DEBUG
#include <linux/module.h>
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <linux/miscdevice.h>
#include <linux/kernel.h> /* min() */
#include <linux/uaccess.h> /* copy_to_user() */
#include <linux/sched.h> /* TASK_INTERRUPTIBLE/signal_pending/schedule */
#include <linux/poll.h>
#include <linux/io.h> /* ioremap() */
#include <linux/of_fdt.h>
#include <linux/seq_file.h>
#include <asm/setup.h>
#include <linux/interrupt.h>
#include <linux/proc_fs.h>
#include <linux/atomic.h>
/*#define ATF_LOGGER_DEBUG*/
#define ATF_LOG_CTRL_BUF_SIZE 256
#define ATF_CRASH_MAGIC_NO 0xdead1abf
/*#define atf_log_lock() atomic_inc(&(atf_buf_vir_ctl->info.atf_buf_lock))*/
/*#define atf_log_unlock() atomic_dec(&(atf_buf_vir_ctl->info.atf_buf_lock))*/
#define atf_log_lock() ((void)0)
#define atf_log_unlock() ((void)0)
static unsigned char *atf_crash_log_buf;
static wait_queue_head_t atf_log_wq;
#ifdef __aarch64__
static void *_memcpy(void *dest, const void *src, size_t count)
{
char *tmp = dest;
const char *s = src;
while (count--)
*tmp++ = *s++;
return dest;
}
#define memcpy _memcpy
#endif
union atf_log_ctl_t {
struct {
unsigned int atf_buf_addr;
unsigned int atf_buf_size;
unsigned int atf_write_pos;
unsigned int atf_read_pos;
/* atf_spinlock_t atf_buf_lock; */
unsigned int atf_buf_lock;
unsigned int atf_buf_unread_size;
unsigned int atf_irq_count;
unsigned int atf_reader_alive;
unsigned long long atf_write_seq;
unsigned long long atf_read_seq;
unsigned int atf_aee_dbg_buf_addr;
unsigned int atf_aee_dbg_buf_size;
unsigned int atf_crash_log_addr;
unsigned int atf_crash_log_size;
unsigned int atf_crash_flag;
} info;
unsigned char data[ATF_LOG_CTRL_BUF_SIZE];
};
struct ipanic_atf_log_rec {
size_t total_size;
size_t has_read;
unsigned long start_idx;
};
union atf_log_ctl_t *atf_buf_vir_ctl;
unsigned long atf_buf_phy_ctl;
unsigned int atf_buf_len;
unsigned char *atf_log_vir_addr;
unsigned int atf_log_len;
unsigned int write_index;
unsigned int read_index;
static unsigned int pos_to_index(unsigned int pos)
{
return pos - (atf_buf_phy_ctl + ATF_LOG_CTRL_BUF_SIZE);
}
static unsigned int index_to_pos(unsigned int index)
{
return (atf_buf_phy_ctl + ATF_LOG_CTRL_BUF_SIZE) + index;
}
#if 0
static size_t atf_log_dump_nolock(unsigned char *buffer, unsigned int start, size_t size)
{
unsigned int len;
unsigned int least;
size_t skip = 0;
unsigned char *p = atf_log_vir_addr + start;
write_index = pos_to_index(atf_buf_vir_ctl->info.atf_write_pos);
least = (write_index + atf_buf_len - start) % atf_buf_len;
if (size > least)
size = least;
len = min(size, atf_log_len - start);
if (size == len) {
memcpy(buffer, atf_log_vir_addr + start, size);
} else {
size_t right = atf_log_len - start;
while (skip < right) {
if (*p != 0)
break;
p++;
skip++;
}
/* pr_notice("skip:%d, right:%d, %p\n", skip, right, p); */
memcpy(buffer, p, right - skip);
memcpy(buffer, atf_log_vir_addr, size - right);
return size - skip;
}
return size;
}
#endif
static size_t atf_log_dump_nolock(unsigned char *buffer, struct ipanic_atf_log_rec *rec, size_t size)
{
unsigned int len;
unsigned int least;
write_index = pos_to_index(atf_buf_vir_ctl->info.atf_write_pos);
/* find the first letter to read */
while ((write_index + atf_log_len - rec->start_idx) % atf_log_len > 0) {
if (*(atf_log_vir_addr + rec->start_idx) != 0)
break;
rec->start_idx++;
if (rec->start_idx == atf_log_len)
rec->start_idx = 0;
}
least = (write_index + atf_buf_len - rec->start_idx) % atf_buf_len;
if (size > least)
size = least;
len = min(size, (size_t)(atf_log_len - rec->start_idx));
if (size == len) {
memcpy(buffer, atf_log_vir_addr + rec->start_idx, size);
} else {
size_t right = atf_log_len - rec->start_idx;
memcpy(buffer, atf_log_vir_addr + rec->start_idx, right);
memcpy(buffer, atf_log_vir_addr, size - right);
}
rec->start_idx += size;
rec->start_idx %= atf_log_len;
return size;
}
/* static size_t atf_log_dump(unsigned char *buffer, unsigned int start, size_t size) */
static size_t atf_log_dump(unsigned char *buffer, struct ipanic_atf_log_rec *rec, size_t size)
{
size_t ret;
atf_log_lock();
/* ret = atf_log_dump_nolock(buffer, start, size); */
ret = atf_log_dump_nolock(buffer, rec, size);
atf_log_unlock();
/* show_data(atf_log_vir_addr, 24*1024, "atf_buf"); */
return ret;
}
size_t ipanic_atflog_buffer(void *data, unsigned char *buffer, size_t sz_buffer)
{
static bool last_read;
size_t count;
struct ipanic_atf_log_rec *rec = (struct ipanic_atf_log_rec *)data;
if (atf_buf_len == 0)
return 0;
/* pr_notice("ipanic_atf_log: need %d, rec:%d, %d, %lu\n",
sz_buffer, rec->total_size, rec->has_read, rec->start_idx); */
if (rec->total_size == rec->has_read || last_read) {
last_read = false;
return 0;
}
if (rec->has_read == 0) {
if (atf_buf_vir_ctl->info.atf_write_seq < atf_log_len
&& atf_buf_vir_ctl->info.atf_write_seq < sz_buffer)
rec->start_idx = 0;
else {
/* atf_log_lock(); */
write_index = pos_to_index(atf_buf_vir_ctl->info.atf_write_pos);
/* atf_log_unlock(); */
rec->start_idx = (write_index + atf_log_len - rec->total_size) % atf_log_len;
}
}
/* count = atf_log_dump_nolock(buffer, (rec->start_idx + rec->has_read) % atf_log_len, sz_buffer); */
/* count = atf_log_dump_nolock(buffer, rec, sz_buffer); */
count = atf_log_dump(buffer, rec, sz_buffer);
/* pr_notice("ipanic_atf_log: dump %d\n", count); */
rec->has_read += count;
if (count != sz_buffer)
last_read = true;
return count;
}
static ssize_t atf_log_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
{
wake_up_interruptible(&atf_log_wq);
return 1;
}
static ssize_t do_read_log_to_usr(char __user *buf, size_t count)
{
size_t len;
size_t least;
write_index = pos_to_index(atf_buf_vir_ctl->info.atf_write_pos);
read_index = pos_to_index(atf_buf_vir_ctl->info.atf_read_pos);
least = (write_index + atf_buf_len - read_index) % atf_buf_len;
if (count > least)
count = least;
len = min(count, (size_t)(atf_log_len - read_index));
if (count == len) {
if (copy_to_user(buf, atf_log_vir_addr + read_index, count))
return -EFAULT;
} else {
size_t right = atf_log_len - read_index;
if (copy_to_user(buf, atf_log_vir_addr + read_index, right))
return -EFAULT;
if (copy_to_user(buf, atf_log_vir_addr, count - right))
return -EFAULT;
}
read_index = (read_index + count) % atf_log_len;
return count;
}
static int atf_log_fix_reader(void)
{
if (atf_buf_vir_ctl->info.atf_write_seq < atf_log_len) {
atf_buf_vir_ctl->info.atf_read_seq = 0;
atf_buf_vir_ctl->info.atf_read_pos = index_to_pos(0);
} else {
atf_buf_vir_ctl->info.atf_read_seq = atf_buf_vir_ctl->info.atf_write_seq;
atf_buf_vir_ctl->info.atf_read_pos = atf_buf_vir_ctl->info.atf_write_pos;
}
return 0;
}
static int atf_log_open(struct inode *inode, struct file *file)
{
int ret;
ret = nonseekable_open(inode, file);
if (unlikely(ret))
return ret;
file->private_data = NULL;
atf_log_lock();
if (!atf_buf_vir_ctl->info.atf_reader_alive)
atf_log_fix_reader();
atf_buf_vir_ctl->info.atf_reader_alive++;
atf_log_unlock();
return 0;
}
static int atf_log_release(struct inode *ignored, struct file *file)
{
atf_buf_vir_ctl->info.atf_reader_alive--;
return 0;
}
static ssize_t atf_log_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
{
ssize_t ret;
unsigned int write_pos;
unsigned int read_pos;
DEFINE_WAIT(wait);
start:
while (1) {
atf_log_lock();
write_pos = atf_buf_vir_ctl->info.atf_write_pos;
read_pos = atf_buf_vir_ctl->info.atf_read_pos;
/* pr_notice("atf_log_read: wait in wq\n"); */
prepare_to_wait(&atf_log_wq, &wait, TASK_INTERRUPTIBLE);
ret = (write_pos == read_pos);
atf_log_unlock();
if (!ret)
break;
if (file->f_flags & O_NONBLOCK) {
ret = -EAGAIN;
break;
}
if (signal_pending(current)) {
ret = -EINTR;
break;
}
schedule();
}
finish_wait(&atf_log_wq, &wait);
/* pr_notice("atf_log_read: finish wait\n"); */
if (ret)
return ret;
atf_log_lock();
if (unlikely(write_pos == read_pos)) {
atf_log_unlock();
goto start;
}
ret = do_read_log_to_usr(buf, count);
atf_buf_vir_ctl->info.atf_read_pos = index_to_pos(read_index);
atf_buf_vir_ctl->info.atf_read_seq += ret;
atf_log_unlock();
/* pr_notice("atf_log_read: return %d, idx: %lu, readpos: %p, writepos: %p\n",
ret, read_index, atf_buf_vir_ctl->info.atf_read_pos,
atf_buf_vir_ctl->info.atf_write_pos); */
return ret;
}
static unsigned int atf_log_poll(struct file *file, poll_table *wait)
{
unsigned int ret = POLLOUT | POLLWRNORM;
if (!(file->f_mode & FMODE_READ))
return ret;
poll_wait(file, &atf_log_wq, wait);
atf_log_lock();
if (atf_buf_vir_ctl->info.atf_write_pos != atf_buf_vir_ctl->info.atf_read_pos)
ret |= POLLIN | POLLRDNORM;
atf_log_unlock();
return ret;
}
long atf_log_ioctl(struct file *flip, unsigned int cmd, unsigned long arg)
{
return 0;
}
static const struct file_operations atf_log_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = atf_log_ioctl,
.compat_ioctl = atf_log_ioctl,
.poll = atf_log_poll,
.read = atf_log_read,
.open = atf_log_open,
.release = atf_log_release,
.write = atf_log_write,
};
static struct miscdevice atf_log_dev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "atf_log",
.fops = &atf_log_fops,
.mode = 0644,
};
static int dt_scan_memory(unsigned long node, const char *uname, int depth, void *data)
{
char *type = (char *)of_get_flat_dt_prop(node, "device_type", NULL);
__be32 *reg, *endp;
int l;
/* We are scanning "memory" nodes only */
if (type == NULL) {
/*
* The longtrail doesn't have a device_type on the
* /memory node, so look for the node called /memory@0.
*/
if (depth != 1 || strcmp(uname, "memory@0") != 0)
return 0;
} else if (strcmp(type, "memory") != 0)
return 0;
reg = (__be32 *)of_get_flat_dt_prop(node, "reg", (int *)&l);
if (reg == NULL)
return 0;
endp = reg + (l / sizeof(__be32));
while ((endp - reg) >= (dt_root_addr_cells + dt_root_size_cells)) {
u64 base, size;
base = dt_mem_next_cell(dt_root_addr_cells, (const __be32 **)®);
size = dt_mem_next_cell(dt_root_size_cells, (const __be32 **)®);
if (size == 0)
continue;
/* pr_notice( */
/* "[PHY layout]DRAM size (dt) : 0x%llx - 0x%llx (0x%llx)\n", */
/* (unsigned long long)base, */
/* (unsigned long long)base + (unsigned long long)size - 1, */
/* (unsigned long long)size); */
}
*(unsigned long *)data = node;
return node;
}
unsigned long long atf_get_from_dt(unsigned long *phy_addr, unsigned int *len)
{
unsigned long node = 0;
struct mem_desc *mem_desc = NULL;
if (of_scan_flat_dt(dt_scan_memory, &node)) {
mem_desc = (struct mem_desc *)of_get_flat_dt_prop(node, "tee_reserved_mem", NULL);
if (mem_desc && mem_desc->size) {
pr_notice("ATF reserved memory: 0x%08llx - 0x%08llx (0x%llx)\n",
mem_desc->start, mem_desc->start+mem_desc->size - 1,
mem_desc->size);
}
}
if (mem_desc) {
*phy_addr = mem_desc->start;
*len = mem_desc->size;
}
return 0;
}
void show_atf_log_ctl(void)
{
pr_notice("atf_buf_addr(%p) = 0x%x\n", &(atf_buf_vir_ctl->info.atf_buf_addr),
atf_buf_vir_ctl->info.atf_buf_addr);
pr_notice("atf_buf_size(%p) = 0x%x\n", &(atf_buf_vir_ctl->info.atf_buf_size),
atf_buf_vir_ctl->info.atf_buf_size);
pr_notice("atf_write_pos(%p) = %u\n", &(atf_buf_vir_ctl->info.atf_write_pos),
atf_buf_vir_ctl->info.atf_write_pos);
pr_notice("atf_read_pos(%p) = %u\n", &(atf_buf_vir_ctl->info.atf_read_pos),
atf_buf_vir_ctl->info.atf_read_pos);
pr_notice("atf_buf_lock(%p) = %u\n", &(atf_buf_vir_ctl->info.atf_buf_lock),
atf_buf_vir_ctl->info.atf_buf_lock);
pr_notice("atf_buf_unread_size(%p) = %u\n", &(atf_buf_vir_ctl->info.atf_buf_unread_size),
atf_buf_vir_ctl->info.atf_buf_unread_size);
pr_notice("atf_irq_count(%p) = %u\n", &(atf_buf_vir_ctl->info.atf_irq_count),
atf_buf_vir_ctl->info.atf_irq_count);
pr_notice("atf_reader_alive(%p) = %u\n", &(atf_buf_vir_ctl->info.atf_reader_alive),
atf_buf_vir_ctl->info.atf_reader_alive);
pr_notice("atf_write_seq(%p) = %llu\n", &(atf_buf_vir_ctl->info.atf_write_seq),
atf_buf_vir_ctl->info.atf_write_seq);
pr_notice("atf_read_seq(%p) = %llu\n", &(atf_buf_vir_ctl->info.atf_read_seq),
atf_buf_vir_ctl->info.atf_read_seq);
}
#ifdef ATF_LOGGER_DEBUG
static void show_data(unsigned long addr, int nbytes, const char *name)
{
int i, j;
int nlines;
u32 *p;
/*
* don't attempt to dump non-kernel addresses or
* values that are probably just small negative numbers
*/
if (addr < PAGE_OFFSET || addr > -256UL)
return;
pr_debug("\n%s: %#lx:\n", name, addr);
/*
* round address down to a 32 bit boundary
* and always dump a multiple of 32 bytes
*/
p = (u32 *)(addr & ~(sizeof(u32) - 1));
nbytes += (addr & (sizeof(u32) - 1));
nlines = (nbytes + 31) / 32;
for (i = 0; i < nlines; i++) {
/*
* just display low 16 bits of address to keep
* each line of the dump < 80 characters
*/
pr_debug("%04lx ", (unsigned long)p & 0xffff);
for (j = 0; j < 8; j++) {
u32 data;
if (probe_kernel_address(p, data))
pr_debug(" ********");
else
pr_debug(" %08x", data);
++p;
}
pr_debug("\n");
}
}
#endif
static irqreturn_t ATF_log_irq_handler(int irq, void *dev_id)
{
if (!atf_buf_vir_ctl->info.atf_reader_alive)
pr_err("No alive reader, but still receive irq\n");
else
pr_info("ATF_log_irq triggered!\n");
wake_up_interruptible(&atf_log_wq);
return IRQ_HANDLED;
}
static const struct file_operations proc_atf_log_file_operations = {
.owner = THIS_MODULE,
.open = atf_log_open,
.read = atf_log_read,
.unlocked_ioctl = atf_log_ioctl,
.compat_ioctl = atf_log_ioctl,
.release = atf_log_release,
.poll = atf_log_poll,
};
static int atf_crash_show(struct seq_file *m, void *v)
{
seq_write(m, atf_crash_log_buf, atf_buf_vir_ctl->info.atf_crash_log_size);
return 0;
}
static int atf_crash_file_open(struct inode *inode, struct file *file)
{
return single_open(file, atf_crash_show, inode->i_private);
}
static const struct file_operations proc_atf_crash_file_operations = {
.owner = THIS_MODULE,
.open = atf_crash_file_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static struct proc_dir_entry *atf_log_proc_dir;
static struct proc_dir_entry *atf_log_proc_file;
static struct proc_dir_entry *atf_crash_proc_file;
static int __init atf_log_init(void)
{
/* register module driver */
int err;
err = misc_register(&atf_log_dev);
if (unlikely(err)) {
pr_err("atf_log: failed to register device");
return -1;
}
pr_notice("atf_log: inited");
/* get atf reserved memory(atf_buf_phy_ctl) from device */
atf_get_from_dt(&atf_buf_phy_ctl, &atf_buf_len); /* TODO */
if (atf_buf_len == 0) {
pr_err("No atf_log_buffer!\n");
return -1;
}
/* map control header */
atf_buf_vir_ctl = ioremap_wc(atf_buf_phy_ctl, ATF_LOG_CTRL_BUF_SIZE);
atf_log_len = atf_buf_vir_ctl->info.atf_buf_size;
/* map log buffer */
atf_log_vir_addr = ioremap_wc(atf_buf_phy_ctl + ATF_LOG_CTRL_BUF_SIZE, atf_log_len);
pr_notice("atf_buf_phy_ctl: 0x%lu\n", atf_buf_phy_ctl);
pr_notice("atf_buf_len: %u\n", atf_buf_len);
pr_notice("atf_buf_vir_ctl: %p\n", atf_buf_vir_ctl);
pr_notice("atf_log_vir_addr: %p\n", atf_log_vir_addr);
pr_notice("atf_log_len: %u\n", atf_log_len);
/* show_atf_log_ctl(); */
/* show_data(atf_buf_vir_ctl, 512, "atf_buf"); */
atf_buf_vir_ctl->info.atf_reader_alive = 0;
atf_buf_vir_ctl->info.atf_read_seq = 0;
/* initial wait queue */
init_waitqueue_head(&atf_log_wq);
if (request_irq(281, (irq_handler_t)ATF_log_irq_handler, IRQF_TRIGGER_NONE, "ATF_irq", NULL) != 0) {
pr_crit("Fail to request ATF_log_irq interrupt!\n");
return -1;
}
/* create /proc/atf_log */
atf_log_proc_dir = proc_mkdir("atf_log", NULL);
if (atf_log_proc_dir == NULL) {
pr_err("atf_log proc_mkdir failed\n");
return -ENOMEM;
}
/* create /proc/atf_log/atf_log */
atf_log_proc_file = proc_create("atf_log", 0444, atf_log_proc_dir, &proc_atf_log_file_operations);
if (atf_log_proc_file == NULL) {
pr_err("atf_log proc_create failed at atf_log\n");
return -ENOMEM;
}
if (atf_buf_vir_ctl->info.atf_crash_flag == ATF_CRASH_MAGIC_NO) {
atf_crash_proc_file = proc_create("atf_crash", 0444, atf_log_proc_dir, &proc_atf_crash_file_operations);
if (atf_crash_proc_file == NULL) {
pr_err("atf_log proc_create failed at atf_crash\n");
return -ENOMEM;
}
atf_buf_vir_ctl->info.atf_crash_flag = 0;
atf_crash_log_buf = ioremap_wc(atf_buf_vir_ctl->info.atf_crash_log_addr,
atf_buf_vir_ctl->info.atf_crash_log_size);
}
return 0;
}
static void __exit atf_log_exit(void)
{
/* deregister module driver */
int err;
err = misc_deregister(&atf_log_dev);
if (unlikely(err))
pr_err("atf_log: failed to unregister device");
pr_notice("atf_log: exited");
}
module_init(atf_log_init);
module_exit(atf_log_exit);
MODULE_DESCRIPTION("MEDIATEK Module ATF Logging Driver");
MODULE_AUTHOR("Ji Zhang<ji.zhang@mediatek.com>");
| 28.48595 | 106 | 0.709934 |
268ed8e158d35d121e99b72ec4e194a66166ed8e | 12,809 | c | C | Pract_04/isim/ps2ReceiverTest_isim_beh.exe.sim/work/a_1478122752_0000452272.c | BNeku/DAS | 8a11173538e15a5551bac1d4158191ecf4f0d44a | [
"MIT"
] | null | null | null | Pract_04/isim/ps2ReceiverTest_isim_beh.exe.sim/work/a_1478122752_0000452272.c | BNeku/DAS | 8a11173538e15a5551bac1d4158191ecf4f0d44a | [
"MIT"
] | null | null | null | Pract_04/isim/ps2ReceiverTest_isim_beh.exe.sim/work/a_1478122752_0000452272.c | BNeku/DAS | 8a11173538e15a5551bac1d4158191ecf4f0d44a | [
"MIT"
] | null | null | null | /**********************************************************************/
/* ____ ____ */
/* / /\/ / */
/* /___/ \ / */
/* \ \ \/ */
/* \ \ Copyright (c) 2003-2009 Xilinx, Inc. */
/* / / All Right Reserved. */
/* /---/ /\ */
/* \ \ / \ */
/* \___\/\___\ */
/***********************************************************************/
/* This file is designed for use with ISim build 0xc3576ebc */
#define XSI_HIDE_SYMBOL_SPEC true
#include "xsi.h"
#include <memory.h>
#ifdef __GNUC__
#include <stdlib.h>
#else
#include <malloc.h>
#define alloca _alloca
#endif
static const char *ng0 = "C:/hlocal/common/ps2receiver.vhd";
extern char *IEEE_P_2592010699;
unsigned char ieee_p_2592010699_sub_1605435078_503743352(char *, unsigned char , unsigned char );
unsigned char ieee_p_2592010699_sub_1690584930_503743352(char *, unsigned char );
unsigned char ieee_p_2592010699_sub_1744673427_503743352(char *, char *, unsigned int , unsigned int );
unsigned char ieee_p_2592010699_sub_2507238156_503743352(char *, unsigned char , unsigned char );
static void work_a_1478122752_0000452272_p_0(char *t0)
{
char t16[16];
char t17[16];
char *t1;
char *t2;
unsigned char t3;
unsigned char t4;
char *t5;
char *t6;
char *t7;
char *t8;
char *t9;
char *t10;
unsigned char t11;
char *t12;
unsigned int t13;
unsigned int t14;
unsigned int t15;
int t18;
unsigned int t19;
unsigned char t20;
char *t21;
char *t22;
char *t23;
LAB0: xsi_set_current_line(63, ng0);
t1 = (t0 + 1296U);
t2 = *((char **)t1);
t3 = *((unsigned char *)t2);
t4 = (t3 == (unsigned char)2);
if (t4 != 0)
goto LAB2;
LAB4: t1 = (t0 + 1416U);
t3 = ieee_p_2592010699_sub_1744673427_503743352(IEEE_P_2592010699, t1, 0U, 0U);
if (t3 != 0)
goto LAB5;
LAB6:
LAB3: t1 = (t0 + 5400);
*((int *)t1) = 1;
LAB1: return;
LAB2: xsi_set_current_line(64, ng0);
t1 = xsi_get_transient_memory(11U);
memset(t1, 0, 11U);
t5 = t1;
memset(t5, (unsigned char)3, 11U);
t6 = (t0 + 5528);
t7 = (t6 + 56U);
t8 = *((char **)t7);
t9 = (t8 + 56U);
t10 = *((char **)t9);
memcpy(t10, t1, 11U);
xsi_driver_first_trans_fast(t6);
goto LAB3;
LAB5: xsi_set_current_line(66, ng0);
t2 = (t0 + 2896U);
t5 = *((char **)t2);
t4 = *((unsigned char *)t5);
t11 = (t4 == (unsigned char)3);
if (t11 != 0)
goto LAB7;
LAB9: t1 = (t0 + 2576U);
t2 = *((char **)t1);
t3 = *((unsigned char *)t2);
t4 = (t3 == (unsigned char)3);
if (t4 != 0)
goto LAB10;
LAB11:
LAB8: goto LAB3;
LAB7: xsi_set_current_line(67, ng0);
t2 = xsi_get_transient_memory(11U);
memset(t2, 0, 11U);
t6 = t2;
memset(t6, (unsigned char)3, 11U);
t7 = (t0 + 5528);
t8 = (t7 + 56U);
t9 = *((char **)t8);
t10 = (t9 + 56U);
t12 = *((char **)t10);
memcpy(t12, t2, 11U);
xsi_driver_first_trans_fast(t7);
goto LAB8;
LAB10: xsi_set_current_line(71, ng0);
t1 = (t0 + 2416U);
t5 = *((char **)t1);
t11 = *((unsigned char *)t5);
t1 = (t0 + 2736U);
t6 = *((char **)t1);
t13 = (10 - 10);
t14 = (t13 * 1U);
t15 = (0 + t14);
t1 = (t6 + t15);
t8 = ((IEEE_P_2592010699) + 4024);
t9 = (t17 + 0U);
t10 = (t9 + 0U);
*((int *)t10) = 10;
t10 = (t9 + 4U);
*((int *)t10) = 1;
t10 = (t9 + 8U);
*((int *)t10) = -1;
t18 = (1 - 10);
t19 = (t18 * -1);
t19 = (t19 + 1);
t10 = (t9 + 12U);
*((unsigned int *)t10) = t19;
t7 = xsi_base_array_concat(t7, t16, t8, (char)99, t11, (char)97, t1, t17, (char)101);
t19 = (1U + 10U);
t20 = (11U != t19);
if (t20 == 1)
goto LAB12;
LAB13: t10 = (t0 + 5528);
t12 = (t10 + 56U);
t21 = *((char **)t12);
t22 = (t21 + 56U);
t23 = *((char **)t22);
memcpy(t23, t7, 11U);
xsi_driver_first_trans_fast(t10);
goto LAB8;
LAB12: xsi_size_not_matching(11U, t19, 0);
goto LAB13;
}
static void work_a_1478122752_0000452272_p_1(char *t0)
{
char *t1;
char *t2;
int t3;
unsigned int t4;
unsigned int t5;
unsigned int t6;
unsigned char t7;
char *t8;
char *t9;
int t10;
unsigned int t11;
unsigned int t12;
unsigned int t13;
unsigned char t14;
unsigned char t15;
char *t16;
char *t17;
int t18;
unsigned int t19;
unsigned int t20;
unsigned int t21;
unsigned char t22;
unsigned char t23;
char *t24;
char *t25;
int t26;
unsigned int t27;
unsigned int t28;
unsigned int t29;
unsigned char t30;
unsigned char t31;
char *t32;
char *t33;
int t34;
unsigned int t35;
unsigned int t36;
unsigned int t37;
unsigned char t38;
unsigned char t39;
char *t40;
char *t41;
int t42;
unsigned int t43;
unsigned int t44;
unsigned int t45;
unsigned char t46;
unsigned char t47;
char *t48;
char *t49;
int t50;
unsigned int t51;
unsigned int t52;
unsigned int t53;
unsigned char t54;
unsigned char t55;
char *t56;
char *t57;
int t58;
unsigned int t59;
unsigned int t60;
unsigned int t61;
unsigned char t62;
unsigned char t63;
char *t64;
char *t65;
int t66;
unsigned int t67;
unsigned int t68;
unsigned int t69;
unsigned char t70;
unsigned char t71;
char *t72;
char *t73;
int t74;
unsigned int t75;
unsigned int t76;
unsigned int t77;
unsigned char t78;
unsigned char t79;
char *t80;
char *t81;
char *t82;
char *t83;
char *t84;
char *t85;
LAB0: xsi_set_current_line(77, ng0);
LAB3: t1 = (t0 + 2736U);
t2 = *((char **)t1);
t3 = (0 - 10);
t4 = (t3 * -1);
t5 = (1U * t4);
t6 = (0 + t5);
t1 = (t2 + t6);
t7 = *((unsigned char *)t1);
t8 = (t0 + 2736U);
t9 = *((char **)t8);
t10 = (1 - 10);
t11 = (t10 * -1);
t12 = (1U * t11);
t13 = (0 + t12);
t8 = (t9 + t13);
t14 = *((unsigned char *)t8);
t15 = ieee_p_2592010699_sub_2507238156_503743352(IEEE_P_2592010699, t7, t14);
t16 = (t0 + 2736U);
t17 = *((char **)t16);
t18 = (2 - 10);
t19 = (t18 * -1);
t20 = (1U * t19);
t21 = (0 + t20);
t16 = (t17 + t21);
t22 = *((unsigned char *)t16);
t23 = ieee_p_2592010699_sub_2507238156_503743352(IEEE_P_2592010699, t15, t22);
t24 = (t0 + 2736U);
t25 = *((char **)t24);
t26 = (3 - 10);
t27 = (t26 * -1);
t28 = (1U * t27);
t29 = (0 + t28);
t24 = (t25 + t29);
t30 = *((unsigned char *)t24);
t31 = ieee_p_2592010699_sub_2507238156_503743352(IEEE_P_2592010699, t23, t30);
t32 = (t0 + 2736U);
t33 = *((char **)t32);
t34 = (4 - 10);
t35 = (t34 * -1);
t36 = (1U * t35);
t37 = (0 + t36);
t32 = (t33 + t37);
t38 = *((unsigned char *)t32);
t39 = ieee_p_2592010699_sub_2507238156_503743352(IEEE_P_2592010699, t31, t38);
t40 = (t0 + 2736U);
t41 = *((char **)t40);
t42 = (5 - 10);
t43 = (t42 * -1);
t44 = (1U * t43);
t45 = (0 + t44);
t40 = (t41 + t45);
t46 = *((unsigned char *)t40);
t47 = ieee_p_2592010699_sub_2507238156_503743352(IEEE_P_2592010699, t39, t46);
t48 = (t0 + 2736U);
t49 = *((char **)t48);
t50 = (6 - 10);
t51 = (t50 * -1);
t52 = (1U * t51);
t53 = (0 + t52);
t48 = (t49 + t53);
t54 = *((unsigned char *)t48);
t55 = ieee_p_2592010699_sub_2507238156_503743352(IEEE_P_2592010699, t47, t54);
t56 = (t0 + 2736U);
t57 = *((char **)t56);
t58 = (7 - 10);
t59 = (t58 * -1);
t60 = (1U * t59);
t61 = (0 + t60);
t56 = (t57 + t61);
t62 = *((unsigned char *)t56);
t63 = ieee_p_2592010699_sub_2507238156_503743352(IEEE_P_2592010699, t55, t62);
t64 = (t0 + 2736U);
t65 = *((char **)t64);
t66 = (8 - 10);
t67 = (t66 * -1);
t68 = (1U * t67);
t69 = (0 + t68);
t64 = (t65 + t69);
t70 = *((unsigned char *)t64);
t71 = ieee_p_2592010699_sub_2507238156_503743352(IEEE_P_2592010699, t63, t70);
t72 = (t0 + 2736U);
t73 = *((char **)t72);
t74 = (9 - 10);
t75 = (t74 * -1);
t76 = (1U * t75);
t77 = (0 + t76);
t72 = (t73 + t77);
t78 = *((unsigned char *)t72);
t79 = ieee_p_2592010699_sub_2507238156_503743352(IEEE_P_2592010699, t71, t78);
t80 = (t0 + 5592);
t81 = (t80 + 56U);
t82 = *((char **)t81);
t83 = (t82 + 56U);
t84 = *((char **)t83);
*((unsigned char *)t84) = t79;
xsi_driver_first_trans_fast(t80);
LAB2: t85 = (t0 + 5416);
*((int *)t85) = 1;
LAB1: return;
LAB4: goto LAB2;
}
static void work_a_1478122752_0000452272_p_2(char *t0)
{
char *t1;
char *t2;
int t3;
unsigned int t4;
unsigned int t5;
unsigned int t6;
unsigned char t7;
unsigned char t8;
char *t9;
char *t10;
char *t11;
char *t12;
char *t13;
char *t14;
LAB0: xsi_set_current_line(82, ng0);
LAB3: t1 = (t0 + 2736U);
t2 = *((char **)t1);
t3 = (0 - 10);
t4 = (t3 * -1);
t5 = (1U * t4);
t6 = (0 + t5);
t1 = (t2 + t6);
t7 = *((unsigned char *)t1);
t8 = ieee_p_2592010699_sub_1690584930_503743352(IEEE_P_2592010699, t7);
t9 = (t0 + 5656);
t10 = (t9 + 56U);
t11 = *((char **)t10);
t12 = (t11 + 56U);
t13 = *((char **)t12);
*((unsigned char *)t13) = t8;
xsi_driver_first_trans_fast(t9);
LAB2: t14 = (t0 + 5432);
*((int *)t14) = 1;
LAB1: return;
LAB4: goto LAB2;
}
static void work_a_1478122752_0000452272_p_3(char *t0)
{
char *t1;
char *t2;
unsigned char t3;
unsigned char t4;
char *t5;
char *t6;
char *t7;
char *t8;
char *t9;
unsigned char t10;
unsigned char t11;
unsigned char t12;
unsigned int t13;
unsigned int t14;
unsigned int t15;
char *t16;
char *t17;
char *t18;
LAB0: xsi_set_current_line(88, ng0);
t1 = (t0 + 1296U);
t2 = *((char **)t1);
t3 = *((unsigned char *)t2);
t4 = (t3 == (unsigned char)2);
if (t4 != 0)
goto LAB2;
LAB4: t1 = (t0 + 1416U);
t3 = ieee_p_2592010699_sub_1744673427_503743352(IEEE_P_2592010699, t1, 0U, 0U);
if (t3 != 0)
goto LAB5;
LAB6:
LAB3: t1 = (t0 + 5448);
*((int *)t1) = 1;
LAB1: return;
LAB2: xsi_set_current_line(89, ng0);
t1 = (t0 + 5720);
t5 = (t1 + 56U);
t6 = *((char **)t5);
t7 = (t6 + 56U);
t8 = *((char **)t7);
*((unsigned char *)t8) = (unsigned char)2;
xsi_driver_first_trans_fast_port(t1);
xsi_set_current_line(90, ng0);
t1 = xsi_get_transient_memory(8U);
memset(t1, 0, 8U);
t2 = t1;
memset(t2, (unsigned char)2, 8U);
t5 = (t0 + 5784);
t6 = (t5 + 56U);
t7 = *((char **)t6);
t8 = (t7 + 56U);
t9 = *((char **)t8);
memcpy(t9, t1, 8U);
xsi_driver_first_trans_fast_port(t5);
goto LAB3;
LAB5: xsi_set_current_line(92, ng0);
t2 = (t0 + 3056U);
t5 = *((char **)t2);
t4 = *((unsigned char *)t5);
t2 = (t0 + 2896U);
t6 = *((char **)t2);
t10 = *((unsigned char *)t6);
t11 = ieee_p_2592010699_sub_1605435078_503743352(IEEE_P_2592010699, t4, t10);
t12 = (t11 == (unsigned char)3);
if (t12 != 0)
goto LAB7;
LAB9:
LAB8: goto LAB3;
LAB7: xsi_set_current_line(93, ng0);
t2 = (t0 + 2736U);
t7 = *((char **)t2);
t13 = (10 - 8);
t14 = (t13 * 1U);
t15 = (0 + t14);
t2 = (t7 + t15);
t8 = (t0 + 5784);
t9 = (t8 + 56U);
t16 = *((char **)t9);
t17 = (t16 + 56U);
t18 = *((char **)t17);
memcpy(t18, t2, 8U);
xsi_driver_first_trans_fast_port(t8);
xsi_set_current_line(94, ng0);
t1 = (t0 + 5720);
t2 = (t1 + 56U);
t5 = *((char **)t2);
t6 = (t5 + 56U);
t7 = *((char **)t6);
*((unsigned char *)t7) = (unsigned char)3;
xsi_driver_first_trans_fast_port(t1);
goto LAB8;
}
extern void work_a_1478122752_0000452272_init()
{
static char *pe[] = {(void *)work_a_1478122752_0000452272_p_0,(void *)work_a_1478122752_0000452272_p_1,(void *)work_a_1478122752_0000452272_p_2,(void *)work_a_1478122752_0000452272_p_3};
xsi_register_didat("work_a_1478122752_0000452272", "isim/ps2ReceiverTest_isim_beh.exe.sim/work/a_1478122752_0000452272.didat");
xsi_register_executes(pe);
}
| 24.920233 | 187 | 0.521118 |
d8244d775434f6b6fb5f22e2afc182bb9d4b7034 | 10,927 | h | C | SDKs/CryCode/3.6.15/CryEngine/CryCommon/CREBreakableGlass.h | amrhead/FireNET | 34d439aa0157b0c895b20b2b664fddf4f9b84af1 | [
"BSD-2-Clause"
] | 4 | 2017-12-18T20:10:16.000Z | 2021-02-07T21:21:24.000Z | SDKs/CryCode/3.6.15/CryEngine/CryCommon/CREBreakableGlass.h | amrhead/FireNET | 34d439aa0157b0c895b20b2b664fddf4f9b84af1 | [
"BSD-2-Clause"
] | null | null | null | SDKs/CryCode/3.6.15/CryEngine/CryCommon/CREBreakableGlass.h | amrhead/FireNET | 34d439aa0157b0c895b20b2b664fddf4f9b84af1 | [
"BSD-2-Clause"
] | 3 | 2019-03-11T21:36:15.000Z | 2021-02-07T21:21:26.000Z | #ifndef _CRE_BREAKABLE_GLASS_
#define _CRE_BREAKABLE_GLASS_
#pragma once
// Debugging (This should *always* be committed disabled...)
#if !defined(RELEASE) && !defined(IS_FREESDK)
//#define GLASS_DEBUG_MODE
#endif
// Includes
#include "CREBreakableGlassHelpers.h"
// Forward decls
struct IRenderAuxGeom;
struct SAuxGeomRenderFlags;
struct SPipTangents;
class CCryNameR;
template <class T, uint N>
class FixedPodArray;
#if GLASSCFG_USE_HASH_GRID
template <class T, uint32 GridSize, uint32 BucketSize>
class CSpatialHashGrid;
#endif
// Typedefs
#if GLASSCFG_USE_HASH_GRID
typedef CSpatialHashGrid<uint8, GLASSCFG_HASH_GRID_SIZE, GLASSCFG_HASH_GRID_BUCKET_SIZE> TGlassHashGrid;
typedef CryFixedArray<uint8, GLASSCFG_HASH_GRID_BUCKET_SIZE> TGlassHashBucket;
#endif
typedef FixedPodArray<int, GLASSCFG_NUM_RADIAL_CRACKS> TRadialCrackArray;
typedef CryFixedArray<SGlassFragment, GLASSCFG_FRAGMENT_ARRAY_SIZE> TFragArray;
typedef CryFixedArray<uint8, GLASSCFG_FRAGMENT_ARRAY_SIZE> TFragIndexArray;
typedef FixedPodArray<uint8, GLASSCFG_FRAGMENT_ARRAY_SIZE> TFragIndexPodArray;
typedef FixedPodArray<uint8, GLASSCFG_NUM_RADIAL_CRACKS> TSubFragArray;
typedef CryFixedArray<SGlassImpactParams, GLASSCFG_MAX_NUM_IMPACTS> TImpactArray;
//==================================================================================================
// Name: SBreakableGlassREParams
// Desc: Breakable glass sim render element params
// Author: Chris Bunner
//==================================================================================================
struct SBreakableGlassREParams
{
SBreakableGlassREParams()
: centre(Vec3Constants<f32>::fVec3_Zero)
{
matrix.SetIdentity();
}
Vec3 centre;
Matrix34 matrix;
};//------------------------------------------------------------------------------------------------
//==================================================================================================
// Name: CREBreakableGlass
// Desc: Breakable glass sim render element
// Author: Chris Bunner
//==================================================================================================
class CREBreakableGlass : public CRendElementBase
{
public:
CREBreakableGlass();
virtual ~CREBreakableGlass();
// CRendElementBase interface
virtual void mfPrepare(bool bCheckOverflow);
virtual bool mfDraw(CShader* ef, SShaderPass* sfm);
// CREBreakableGlass interface
virtual bool InitialiseRenderElement(const SBreakableGlassInitParams& params);
virtual void ReleaseRenderElement();
virtual void Update(SBreakableGlassUpdateParams& params);
virtual void GetGlassState(SBreakableGlassState& state);
virtual void ApplyImpactToGlass(const SGlassImpactParams& params);
virtual void ApplyExplosionToGlass(const SGlassImpactParams& params);
virtual void SetCVars(const SBreakableGlassCVars* pCVars);
#ifdef GLASS_DEBUG_MODE
#ifndef NULL_RENDERER
virtual void DrawFragmentDebug(const uint fragIndex, const Matrix34& matrix, const uint8 buffId, const float alpha);
#else
virtual void DrawFragmentDebug(const uint fragIndex, const Matrix34& matrix, const uint8 buffId, const float alpha) {}
#endif
#endif
ILINE SBreakableGlassREParams* GetParams()
{
return &m_params;
}
private:
// Internal constants
static CCryNameR s_ImpactDecalParamName;
enum EGlassSurfaceSide
{
EGlassSurfaceSide_Center,
EGlassSurfaceSide_Front,
EGlassSurfaceSide_Back
};
// Core
void ResetTempCrackData();
void RT_UpdateBuffers(const int subFragIndex = -1);
// Random
void SeedRand();
float GetRandF();
float GetRandF(const uint index);
// Glass impact state/reaction
void HandleAdditionalImpact(const SGlassImpactParams& params);
void ShatterGlass();
void PlayShatterEffect(const uint8 fragIndex);
float CalculateBreakThreshold();
bool CheckForGlassBreak(const float breakThreshold, float& excessEnergy);
void CalculateImpactEnergies(const float totalEnergy, float& radialEnergy, float& circularEnergy);
// Crack pattern generation
uint GenerateCracksFromImpact(const uint8 parentFragIndex, const SGlassImpactParams& impact);
float PropagateRadialCrack(const uint startIndex, const uint currIndex, const uint localIndex, const float angle, const float energyPerStep);
uint GenerateRadialCracks(const float totalEnergy, const uint impactDepth, const float fragArea);
float GetImpactRadius(const SGlassImpactParams& impact);
float GetDecalRadius(const uint8 impactIndex);
// Fragment impacts
bool ApplyImpactToFragments(SGlassImpactParams& impact);
bool FindImpactFragment(const SGlassImpactParams& impact, uint8& fragIndex);
SGlassFragment* AddFragment();
void RemoveFragment(const uint8 fragIndex);
void RebuildChangedFragment(const uint8 fragIndex);
void GenerateSubFragments(const uint8 parentFragIndex, const SGlassImpactParams& impact);
void GenerateSubFragmentCracks(const uint8 parentFragIndex, const SGlassImpactParams& impact, TRadialCrackArray& fragIntersectPts);
bool CreateFragmentFromOutline(const Vec2* pOutline, const int outlineSize, const uint8 parentFragIndex, const bool forceLoose = false);
bool IsFragmentLoose(const SGlassFragment& frag);
bool IsFragmentWeaklyLinked(const SGlassFragment& frag);
void RemoveFragmentConnections(const uint8 fragIndex, PodArray<uint8>& connections);
void ConnectSubFragments(const uint8* pSubFrags, const uint8 numSubFrags);
void ReplaceFragmentConnections(const uint8 parentFragIndex, const uint8* pSubFrags, const uint8 numSubFrags);
void ConnectFragmentPair(const uint8 fragAIndex, const uint8 fragBIndex);
void FindLooseFragments(TGlassPhysFragmentArray* pPhysFrags, TGlassPhysFragmentInitArray* pPhysFragsInitData);
void TraverseStableConnection(const uint8 fragIndex, TFragIndexPodArray& stableFrags);
void PrePhysicalizeLooseFragment(TGlassPhysFragmentArray* pPhysFrags, TGlassPhysFragmentInitArray* pPhysFragsInitData, const uint8 fragIndex, const bool dampenVel, const bool noVel);
// Fragment hashing
void SetHashGridSize(const Vec2& size);
void HashFragment(const uint8 fragIndex, const bool remove = false);
void HashFragmentTriangle(const Vec2& a, const Vec2& b, const Vec2& c,
const uint8& triFrag, const bool removeTri = false);
void HashFragmentTriangleSpan(const struct STriEdge& a, const struct STriEdge& b,
const uint8& triFrag, const bool removeTri = false);
// Fragment management
void DeactivateFragment(const uint8 index, const uint32 bit);
// Geometry generation
void GenerateLoosePieces(const int numRadialCracks);
void GenerateStablePieces(const int numRadialCracks);
float GetClosestImpactDistance(const Vec2& pt);
void RebuildAllFragmentGeom();
void RehashAllFragmentData();
void ProcessFragmentGeomData();
void BuildFragmentTriangleData(const uint8 fragIndex, uint& pVertOffs, uint& pIndOffs, const EGlassSurfaceSide side = EGlassSurfaceSide_Center, const int subFragID = -1);
void BuildFragmentOutlineData(const uint8 fragIndex, uint& pVertOffs, uint& pIndOffs, const int subFragID = -1);
void GenerateDefaultPlaneGeom();
bool GenerateGeomFromFragment(const Vec2* pFragPts, const uint numPts);
void GenerateVertFromPoint(const Vec3& pt, const Vec2& uvOffset, SVF_P3F_C4B_T2F& vert, const bool impactDistInAlpha = false);
void GenerateTriangleTangent(const Vec3& triPt0, const Vec3& triPt1, const Vec3& triPt2, SPipTangents& tangent);
void PackTriangleTangent(const Vec3& tangent, const Vec3& binormal, SPipTangents& tanBin);
// Drawing
void UpdateImpactShaderConstants();
void SetImpactShaderConstants(CShader* pShader);
#ifdef GLASS_DEBUG_MODE
// Debug geometry
void GenerateImpactGeom(const SGlassImpactParams& impact);
void TransformPointList(PodArray<Vec3>& ptList, const bool inverse = false);
// Debug drawing
void DebugDraw(const bool wireframe, const bool data);
void DrawLooseGeom(IRenderAuxGeom* const pRenderer, SAuxGeomRenderFlags& flags);
void DrawOutlineGeom(IRenderAuxGeom* const pRenderer, SAuxGeomRenderFlags& flags);
void DrawFragmentDebug(IRenderAuxGeom* const pRenderer, SAuxGeomRenderFlags& flags);
void DrawFragmentConnectionDebug(IRenderAuxGeom* const pRenderer, SAuxGeomRenderFlags& flags);
void DrawDebugData(IRenderAuxGeom* const pRenderer, SAuxGeomRenderFlags& flags);
#endif
// Geometry buffer
struct SGlassGeom
{
void Clear()
{
m_verts.Clear();
m_inds.Clear();
m_tans.Clear();
}
void Free()
{
m_verts.Free();
m_inds.Free();
m_tans.Free();
}
PodArray<SVF_P3F_C4B_T2F> m_verts;
PodArray<uint16> m_inds;
PodArray<SPipTangents> m_tans;
};
// Physicalized fragment
struct SGlassPhysFragId
{
uint32 m_geomBufferId;
uint8 m_fragId;
};
// Shared data
static float s_loosenTimer;
static float s_impactTimer;
// Persistent data
TFragArray m_frags;
TImpactArray m_impactParams;
TFragIndexArray m_freeFragIndices;
SBreakableGlassInitParams m_glassParams;
SBreakableGlassREParams m_params;
SBreakableGlassDecalConstant m_decalPSConsts[GLASSCFG_MAX_NUM_IMPACT_DECALS];
// Temp crack generation data
Vec2 m_pointArray[GLASSCFG_MAX_NUM_CRACK_POINTS];
PodArray<Vec2*> m_radialCrackTrees[GLASSCFG_NUM_RADIAL_CRACKS];
// Temp fragment mesh data
SGlassGeom m_fragFullGeom[GLASSCFG_MAX_NUM_PHYS_FRAGMENTS];
SGlassPhysFragId m_fragGeomBufferIds[GLASSCFG_MAX_NUM_PHYS_FRAGMENTS];
volatile bool m_fragGeomRebuilt[GLASSCFG_MAX_NUM_PHYS_FRAGMENTS];
// Temp stable mesh data
SGlassGeom m_planeGeom;
SGlassGeom m_crackGeom;
#ifdef GLASS_DEBUG_MODE
// Debug drawing
PodArray<Vec3> m_impactLineList;
#endif
// Persistent data
static const SBreakableGlassCVars* s_pCVars;
Vec2 m_hashCellSize;
Vec2 m_hashCellInvSize;
Vec2 m_hashCellHalfSize;
Vec2 m_invUVRange;
#if GLASSCFG_USE_HASH_GRID
TGlassHashGrid* m_pHashGrid;
#endif
float m_invMaxGlassSize;
float m_impactEnergy;
uint32 m_geomBufferId;
uint32 m_seed;
// Fragment state bit arrays
uint32 m_fragsActive;
uint32 m_fragsLoose;
uint32 m_fragsFree;
uint32 m_lastFragBit;
// Shader constant state
uint8 m_numDecalImpacts;
uint8 m_numDecalPSConsts;
// Temp counts
uint8 m_pointArrayCount;
uint8 m_lastPhysFrag;
uint8 m_totalNumFrags;
uint8 m_lastFragIndex;
uint8 m_numLooseFrags;
// Glass state
bool m_shattered;
bool m_geomDirty;
volatile bool m_geomRebuilt; // Accessed by MT and RT
volatile bool m_geomBufferLost; // Accessed by MT and RT
volatile uint8 m_dirtyGeomBufferCount; // Accessed by MT and RT
volatile uint32 m_geomUpdateFrame;
};//------------------------------------------------------------------------------------------------
#endif // _CRE_BREAKABLE_GLASS_
| 35.36246 | 183 | 0.738172 |
af70c006b839704c01782206778d3285286d94c8 | 2,357 | h | C | AWS iOS SDK/EC2/Models/UAEC2LaunchSpecificationSpecification.h | unsignedapps/ua-aws-sdk-ios | dc742b022e5f1b37a30f269ba47d4fc1f25b3f47 | [
"MIT"
] | 2 | 2015-05-21T02:49:06.000Z | 2015-08-21T04:51:16.000Z | AWS iOS SDK/EC2/Models/UAEC2LaunchSpecificationSpecification.h | unsignedapps/ua-aws-sdk-ios | dc742b022e5f1b37a30f269ba47d4fc1f25b3f47 | [
"MIT"
] | 1 | 2015-08-21T04:44:10.000Z | 2016-01-01T03:21:47.000Z | AWS iOS SDK/EC2/Models/UAEC2LaunchSpecificationSpecification.h | unsignedapps/ua-aws-sdk-ios | dc742b022e5f1b37a30f269ba47d4fc1f25b3f47 | [
"MIT"
] | null | null | null | //
// UAEC2LaunchSpecificationSpecification.h
// AWS iOS SDK
//
// Copyright © Unsigned Apps 2014. See License file.
// Created by Rob Amos.
//
//
#import "UAEC2Model.h"
@class UAEC2SpotPlacement, UAEC2BlockDeviceMapping, UAEC2NetworkInterfaceSpecification, UAEC2IAMInstanceProfileSpecification;
@interface UAEC2LaunchSpecificationSpecification : UAEC2Model
@property (nonatomic, copy) NSString *imageID;
@property (nonatomic, copy) NSString *keyName;
@property (nonatomic, copy) NSString *userData;
@property (nonatomic, copy) NSString *decodedUserData;
@property (nonatomic, copy) NSString *addressingType;
@property (nonatomic, copy) NSString *instanceType;
@property (nonatomic, copy) UAEC2SpotPlacement *placement;
@property (nonatomic, copy) NSString *kernelID;
@property (nonatomic, copy) NSString *ramdiskID;
@property (nonatomic, strong) NSMutableArray *blockDeviceMappings;
@property (nonatomic) BOOL monitoringEnabled;
@property (nonatomic, copy) NSString *subnetID;
@property (nonatomic, strong) NSMutableArray *networkInterfaces;
@property (nonatomic, copy) UAEC2IAMInstanceProfileSpecification *iamInstanceProfile;
@property (nonatomic) BOOL ebsOptimized;
@property (nonatomic, strong) NSMutableArray *securityGroups;
/**
* Retrieves the UAEC2BlockDeviceMapping at the specified index.
**/
- (UAEC2BlockDeviceMapping *)blockDeviceMappingAtIndex:(NSUInteger)index;
/**
* Retrieves the UAEC2NetworkInterfaceSpecification at the specified index.
**/
- (UAEC2NetworkInterfaceSpecification *)networkInterfaceAtIndex:(NSUInteger)index;
/**
* Retrieves the NSString at the specified index.
**/
- (NSString *)securityGroupAtIndex:(NSUInteger)index;
/**
* Adds a BlockDeviceMapping to the blockDeviceMappings property.
*
* This will initialise blockDeviceMappings with an empty mutable array if necessary.
**/
- (void)addBlockDeviceMapping:(UAEC2BlockDeviceMapping *)blockDeviceMapping;
/**
* Adds a NetworkInterface to the networkInterfaces property.
*
* This will initialise networkInterfaces with an empty mutable array if necessary.
**/
- (void)addNetworkInterface:(UAEC2NetworkInterfaceSpecification *)networkInterface;
/**
* Adds a SecurityGroup to the securityGroups property.
*
* This will initialise securityGroups with an empty mutable array if necessary.
**/
- (void)addSecurityGroup:(NSString *)securityGroup;
@end
| 34.661765 | 125 | 0.793806 |
49654badc15f78e418009e87e7cbbc29a46d1946 | 1,205 | c | C | os/pc/ps2mouse.c | glycerine/inferno | 3e99b1ef540dfa554aef90378dbeac48f5187bf5 | [
"Unlicense"
] | 33 | 2015-03-10T17:30:43.000Z | 2021-04-26T07:57:23.000Z | arch/native/386/pc/ps2mouse.c | hall/inf | f8bddafa7feddbd6b818ec9c187221e51bb66e83 | [
"Apache-2.0"
] | 1 | 2015-03-06T15:14:11.000Z | 2015-03-06T15:18:16.000Z | arch/native/386/pc/ps2mouse.c | hall/inf | f8bddafa7feddbd6b818ec9c187221e51bb66e83 | [
"Apache-2.0"
] | 13 | 2015-01-06T21:12:18.000Z | 2019-10-31T19:08:34.000Z | #include "u.h"
#include "../port/lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "../port/error.h"
#include "io.h"
/*
* mouse types
*/
enum
{
Mouseother= 0,
Mouseserial= 1,
MousePS2= 2,
};
static int mousetype;
/*
* ps/2 mouse message is three bytes
*
* byte 0 - 0 0 SDY SDX 1 M R L
* byte 1 - DX
* byte 2 - DY
*
* shift & left button is the same as middle button
*/
static void
ps2mouseputc(int c, int shift)
{
static short msg[3];
static int nb;
static uchar b[] = {0, 1, 4, 5, 2, 3, 6, 7, 0, 1, 2, 5, 2, 3, 6, 7 };
int buttons, dx, dy;
/*
* check byte 0 for consistency
*/
if(nb==0 && (c&0xc8)!=0x08)
return;
msg[nb] = c;
if(++nb == 3){
nb = 0;
if(msg[0] & 0x10)
msg[1] |= 0xFF00;
if(msg[0] & 0x20)
msg[2] |= 0xFF00;
buttons = b[(msg[0]&7) | (shift ? 8 : 0)];
dx = msg[1];
dy = -msg[2];
mousetrack(buttons, dx, dy, 1);
}
return;
}
/*
* set up a ps2 mouse
*/
static void
ps2mouse(void)
{
if(mousetype == MousePS2)
return;
i8042auxenable(ps2mouseputc);
/* make mouse streaming, enabled */
i8042auxcmd(0xEA);
i8042auxcmd(0xF4);
mousetype = MousePS2;
}
void
ps2mouselink(void)
{
/*
* hack
*/
ps2mouse();
}
| 14.176471 | 70 | 0.576763 |
e4219c51df53756d4548249153e3ed600b41c82c | 14,370 | c | C | tests/perf_contended_mutex_rwlock.c | hu5980/mac_thread | 60d463e307b801016e1cf08b7ad68ffbbb88737a | [
"Apache-2.0"
] | 672 | 2019-10-09T11:15:13.000Z | 2021-09-21T10:02:33.000Z | libpthread-330.220.2/tests/perf_contended_mutex_rwlock.c | KaiserFeng/KFAppleOpenSource | 7ea6ab19f1492a2da262d3554f90882393f975a4 | [
"MIT"
] | 19 | 2019-11-05T03:32:31.000Z | 2021-07-15T11:16:25.000Z | libpthread-330.220.2/tests/perf_contended_mutex_rwlock.c | KaiserFeng/KFAppleOpenSource | 7ea6ab19f1492a2da262d3554f90882393f975a4 | [
"MIT"
] | 216 | 2019-10-10T01:47:36.000Z | 2021-09-23T07:56:54.000Z | #include <stdlib.h>
#include <stdio.h>
#include <stdatomic.h>
#include <math.h>
#include <unistd.h>
#include <sys/sysctl.h>
#include <mach/mach.h>
#include <pthread.h>
#include <pthread/pthread_spis.h>
#include <os/lock.h>
#include <darwintest.h>
// number of times the lock is taken per dt_stat batch
#define ITERATIONS_PER_DT_STAT_BATCH 10000ull
// number of times the contended mutex is taken per dt_stat batch
#define ITERATIONS_PER_DT_STAT_BATCH_CONTENDED_MUTEX 1000ull
// shift determining power of 2 factor of time spent by worker threads in the
// busy() function while outside of the lock vs inside the lock
#define OUTER_VS_INNER_SHIFT 4
// fraction of read lock vs write lock acquires
#define RDLOCK_FRACTION 0.99f
// maintain and print progress counters in between measurement batches
#define COUNTERS 0
// move the darwintest assertion code out of the straight line execution path
// since it is has non-trivial overhead and codegen impact even if the assertion
// is never triggered.
#define iferr(_e) if(__builtin_expect(!!(_e), 0))
#pragma mark -
uint64_t
random_busy_counts(unsigned int *seed, uint64_t *inner, uint64_t *outer)
{
uint64_t random = rand_r(seed);
const uint64_t of = (1 << OUTER_VS_INNER_SHIFT);
*inner = 0x4 + (random & (0x10 - 1));
*outer = 0x4 * of + ((random >> 4) & (0x10 * of - 1));
return random;
}
// By default busy() does cpu busy work for a passed in number of iterations
enum {
busy_is_nothing = 0,
busy_is_cpu_busy,
busy_is_cpu_yield,
};
static int busy_select = busy_is_cpu_busy;
static double
cpu_busy(uint64_t n)
{
double d = M_PI;
uint64_t i;
for (i = 0; i < n; i++) d *= M_PI;
return d;
}
static double
cpu_yield(uint64_t n)
{
uint64_t i;
for (i = 0; i < n; i++) {
#if defined(__arm__) || defined(__arm64__)
asm volatile("yield");
#elif defined(__x86_64__) || defined(__i386__)
asm volatile("pause");
#else
#error Unrecognized architecture
#endif
}
return 0;
}
__attribute__((noinline))
static double
busy(uint64_t n)
{
switch(busy_select) {
case busy_is_cpu_busy:
return cpu_busy(n);
case busy_is_cpu_yield:
return cpu_yield(n);
default:
return 0;
}
}
#pragma mark -
static semaphore_t ready_sem, start_sem, end_sem;
static uint32_t nthreads;
static _Atomic uint32_t active_thr;
static _Atomic int64_t todo;
uint64_t iterations_per_dt_stat_batch = ITERATIONS_PER_DT_STAT_BATCH;
#if COUNTERS
static _Atomic uint64_t total_locks, total_rdlocks, total_wrlocks;
#define ctr_inc(_t) atomic_fetch_add_explicit(&(_t), 1, memory_order_relaxed)
#else
#define ctr_inc(_t)
#endif
static uint32_t
ncpu(void)
{
static uint32_t activecpu, physicalcpu;
if (!activecpu) {
uint32_t n;
size_t s = sizeof(n);
sysctlbyname("hw.activecpu", &n, &s, NULL, 0);
activecpu = n;
s = sizeof(n);
sysctlbyname("hw.physicalcpu", &n, &s, NULL, 0);
physicalcpu = n;
}
return MIN(activecpu, physicalcpu);
}
__attribute__((noinline))
static void
threaded_bench(dt_stat_time_t s, int batch_size)
{
kern_return_t kr;
for (int i = 0; i < nthreads; i++) {
kr = semaphore_wait(ready_sem);
iferr (kr) {T_QUIET; T_ASSERT_MACH_SUCCESS(kr, "semaphore_wait");}
}
atomic_init(&active_thr, nthreads);
atomic_init(&todo, batch_size * iterations_per_dt_stat_batch);
dt_stat_token t = dt_stat_begin(s);
kr = semaphore_signal_all(start_sem);
iferr (kr) {T_QUIET; T_ASSERT_MACH_SUCCESS(kr, "semaphore_signal_all");}
kr = semaphore_wait(end_sem);
iferr (kr) {T_QUIET; T_ASSERT_MACH_SUCCESS(kr, "semaphore_wait");}
dt_stat_end_batch(s, batch_size, t);
}
static void
setup_threaded_bench(void* (*thread_fn)(void*), bool singlethreaded)
{
kern_return_t kr;
int r;
char *e;
if (singlethreaded) {
nthreads = 1;
} else {
if ((e = getenv("DT_STAT_NTHREADS"))) nthreads = strtoul(e, NULL, 0);
if (nthreads < 2) nthreads = ncpu();
}
if ((e = getenv("DT_STAT_CPU_BUSY"))) busy_select = strtoul(e, NULL, 0);
kr = semaphore_create(mach_task_self(), &ready_sem, SYNC_POLICY_FIFO, 0);
T_QUIET; T_ASSERT_MACH_SUCCESS(kr, "semaphore_create");
kr = semaphore_create(mach_task_self(), &start_sem, SYNC_POLICY_FIFO, 0);
T_QUIET; T_ASSERT_MACH_SUCCESS(kr, "semaphore_create");
kr = semaphore_create(mach_task_self(), &end_sem, SYNC_POLICY_FIFO, 0);
T_QUIET; T_ASSERT_MACH_SUCCESS(kr, "semaphore_create");
pthread_attr_t attr;
r = pthread_attr_init(&attr);
T_QUIET; T_ASSERT_POSIX_ZERO(r, "pthread_attr_init");
r = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
T_QUIET; T_ASSERT_POSIX_ZERO(r, "pthread_attr_setdetachstate");
for (int i = 0; i < nthreads; i++) {
pthread_t th;
r = pthread_create(&th, &attr, thread_fn, (void *)(uintptr_t)(i+1));
T_QUIET; T_ASSERT_POSIX_ZERO(r, "pthread_create");
}
}
#pragma mark -
static pthread_mutex_t mutex;
static void *
mutex_bench_thread(void * arg)
{
kern_return_t kr;
int r;
unsigned int seed;
volatile double dummy;
restart:
seed = (uintptr_t)arg; // each thread repeats its own sequence
kr = semaphore_wait_signal(start_sem, ready_sem);
T_QUIET; T_ASSERT_MACH_SUCCESS(kr, "semaphore_wait_signal");
while (atomic_fetch_sub_explicit(&todo, 1, memory_order_relaxed) > 0) {
uint64_t inner, outer;
random_busy_counts(&seed, &inner, &outer);
dummy = busy(outer);
r = pthread_mutex_lock(&mutex);
iferr (r) {T_QUIET; T_ASSERT_POSIX_ZERO(r, "mutex_lock");}
dummy = busy(inner);
r = pthread_mutex_unlock(&mutex);
iferr (r) {T_QUIET; T_ASSERT_POSIX_ZERO(r, "mutex_unlock");}
ctr_inc(total_locks);
}
if (atomic_fetch_sub_explicit(&active_thr, 1, memory_order_relaxed) == 1) {
kr = semaphore_signal(end_sem);
T_QUIET; T_ASSERT_MACH_SUCCESS(kr, "semaphore_signal");
}
goto restart;
}
static void
mutex_bench(bool singlethreaded)
{
int r;
int batch_size;
#if COUNTERS
uint64_t batch = 0;
#endif
setup_threaded_bench(mutex_bench_thread, singlethreaded);
pthread_mutexattr_t attr;
r = pthread_mutexattr_init(&attr);
T_QUIET; T_ASSERT_POSIX_ZERO(r, "mutexattr_init");
pthread_mutexattr_setpolicy_np(&attr, _PTHREAD_MUTEX_POLICY_FAIRSHARE);
T_QUIET; T_ASSERT_POSIX_ZERO(r, "mutexattr_setpolicy_np");
r = pthread_mutex_init(&mutex, &attr);
T_QUIET; T_ASSERT_POSIX_ZERO(r, "mutex_init");
dt_stat_time_t s = dt_stat_time_create("%llu pthread_mutex_lock & "
"pthread_mutex_unlock (fairshare) on %u thread%s",
iterations_per_dt_stat_batch, nthreads, nthreads > 1 ? "s" : "");
do {
batch_size = dt_stat_batch_size(s);
threaded_bench(s, batch_size);
#if COUNTERS
fprintf(stderr, "\rbatch: %4llu\t size: %4d\tmutexes: %8llu",
++batch, batch_size,
atomic_load_explicit(&total_locks, memory_order_relaxed));
#endif
} while (!dt_stat_stable(s));
#if COUNTERS
fprintf(stderr, "\n");
#endif
dt_stat_finalize(s);
}
T_DECL(perf_uncontended_mutex_bench, "Uncontended fairshare mutex",
T_META_TYPE_PERF, T_META_ALL_VALID_ARCHS(NO),
T_META_LTEPHASE(LTE_POSTINIT), T_META_CHECK_LEAKS(false))
{
mutex_bench(true);
}
T_DECL(perf_contended_mutex_bench, "Contended fairshare mutex",
T_META_TYPE_PERF, T_META_ALL_VALID_ARCHS(NO),
T_META_LTEPHASE(LTE_POSTINIT), T_META_CHECK_LEAKS(false))
{
iterations_per_dt_stat_batch = ITERATIONS_PER_DT_STAT_BATCH_CONTENDED_MUTEX;
mutex_bench(false);
}
#pragma mark -
static pthread_rwlock_t rwlock;
static void *
rwlock_bench_thread(void * arg)
{
kern_return_t kr;
int r;
unsigned int seed;
volatile double dummy;
const uint64_t rand_rdlock_max = (double)RAND_MAX * RDLOCK_FRACTION;
restart:
seed = (uintptr_t)arg; // each thread repeats its own sequence
kr = semaphore_wait_signal(start_sem, ready_sem);
T_QUIET; T_ASSERT_MACH_SUCCESS(kr, "semaphore_wait_signal");
while (atomic_fetch_sub_explicit(&todo, 1, memory_order_relaxed) > 0) {
uint64_t inner, outer;
uint64_t random = random_busy_counts(&seed, &inner, &outer);
dummy = busy(outer);
if (random < rand_rdlock_max) {
r = pthread_rwlock_rdlock(&rwlock);
iferr (r) {T_QUIET; T_ASSERT_POSIX_ZERO(r, "rwlock_rdlock");}
dummy = busy(inner);
r = pthread_rwlock_unlock(&rwlock);
iferr (r) {T_QUIET; T_ASSERT_POSIX_ZERO(r, "rwlock_unlock");}
ctr_inc(total_rdlocks);
} else {
r = pthread_rwlock_wrlock(&rwlock);
iferr (r) {T_QUIET; T_ASSERT_POSIX_ZERO(r, "rwlock_wrlock");}
dummy = busy(inner);
r = pthread_rwlock_unlock(&rwlock);
iferr (r) {T_QUIET; T_ASSERT_POSIX_ZERO(r, "rwlock_unlock");}
ctr_inc(total_wrlocks);
}
ctr_inc(total_locks);
}
if (atomic_fetch_sub_explicit(&active_thr, 1, memory_order_relaxed) == 1) {
kr = semaphore_signal(end_sem);
T_QUIET; T_ASSERT_MACH_SUCCESS(kr, "semaphore_signal");
}
goto restart;
}
static void
rwlock_bench(bool singlethreaded)
{
int r;
int batch_size;
#if COUNTERS
uint64_t batch = 0;
#endif
setup_threaded_bench(rwlock_bench_thread, singlethreaded);
r = pthread_rwlock_init(&rwlock, NULL);
T_QUIET; T_ASSERT_POSIX_ZERO(r, "rwlock_init");
dt_stat_time_t s = dt_stat_time_create("%llu pthread_rwlock_rd/wrlock & "
"pthread_rwlock_unlock (%.0f%% rdlock) on %u thread%s",
iterations_per_dt_stat_batch, RDLOCK_FRACTION * 100, nthreads,
nthreads > 1 ? "s" : "");
do {
batch_size = dt_stat_batch_size(s);
threaded_bench(s, batch_size);
#if COUNTERS
fprintf(stderr, "\rbatch: %4llu\t size: %4d\trwlocks: %8llu\t"
"rd: %8llu\twr: %8llu", ++batch, batch_size,
atomic_load_explicit(&total_locks, memory_order_relaxed),
atomic_load_explicit(&total_rdlocks, memory_order_relaxed),
atomic_load_explicit(&total_wrlocks, memory_order_relaxed));
#endif
} while (!dt_stat_stable(s));
#if COUNTERS
fprintf(stderr, "\n");
#endif
dt_stat_finalize(s);
}
T_DECL(perf_uncontended_rwlock_bench, "Uncontended rwlock",
T_META_TYPE_PERF, T_META_ALL_VALID_ARCHS(NO),
T_META_LTEPHASE(LTE_POSTINIT), T_META_CHECK_LEAKS(false))
{
rwlock_bench(true);
}
T_DECL(perf_contended_rwlock_bench, "Contended rwlock",
T_META_TYPE_PERF, T_META_ALL_VALID_ARCHS(NO),
T_META_LTEPHASE(LTE_POSTINIT), T_META_CHECK_LEAKS(false))
{
rwlock_bench(false);
}
#pragma mark -
static os_unfair_lock unfair_lock;
static void *
unfair_lock_bench_thread(void * arg)
{
kern_return_t kr;
unsigned int seed;
volatile double dummy;
restart:
seed = (uintptr_t)arg; // each thread repeats its own sequence
kr = semaphore_wait_signal(start_sem, ready_sem);
T_QUIET; T_ASSERT_MACH_SUCCESS(kr, "semaphore_wait_signal");
while (atomic_fetch_sub_explicit(&todo, 1, memory_order_relaxed) > 0) {
uint64_t inner, outer;
random_busy_counts(&seed, &inner, &outer);
dummy = busy(outer);
os_unfair_lock_lock(&unfair_lock);
dummy = busy(inner);
os_unfair_lock_unlock(&unfair_lock);
ctr_inc(total_locks);
}
if (atomic_fetch_sub_explicit(&active_thr, 1, memory_order_relaxed) == 1) {
kr = semaphore_signal(end_sem);
T_QUIET; T_ASSERT_MACH_SUCCESS(kr, "semaphore_signal");
}
goto restart;
}
static void
unfair_lock_bench(bool singlethreaded)
{
int r;
int batch_size;
#if COUNTERS
uint64_t batch = 0;
#endif
setup_threaded_bench(unfair_lock_bench_thread, singlethreaded);
dt_stat_time_t s = dt_stat_time_create("%llu os_unfair_lock_lock & "
"os_unfair_lock_unlock on %u thread%s",
iterations_per_dt_stat_batch, nthreads, nthreads > 1 ? "s" : "");
do {
batch_size = dt_stat_batch_size(s);
threaded_bench(s, batch_size);
#if COUNTERS
fprintf(stderr, "\rbatch: %4llu\t size: %4d\tunfair_locks: %8llu",
++batch, batch_size,
atomic_load_explicit(&total_locks, memory_order_relaxed));
#endif
} while (!dt_stat_stable(s));
#if COUNTERS
fprintf(stderr, "\n");
#endif
dt_stat_finalize(s);
}
T_DECL(perf_uncontended_unfair_lock_bench, "Unontended unfair lock",
T_META_TYPE_PERF, T_META_ALL_VALID_ARCHS(NO),
T_META_LTEPHASE(LTE_POSTINIT), T_META_CHECK_LEAKS(false))
{
unfair_lock_bench(true);
}
T_DECL(perf_contended_unfair_lock_bench, "Contended unfair lock",
T_META_TYPE_PERF, T_META_ALL_VALID_ARCHS(NO),
T_META_LTEPHASE(LTE_POSTINIT), T_META_CHECK_LEAKS(false))
{
unfair_lock_bench(false);
}
#pragma mark -
static pthread_mutex_t ffmutex;
static void *
ffmutex_bench_thread(void * arg)
{
kern_return_t kr;
int r;
unsigned int seed;
volatile double dummy;
restart:
seed = (uintptr_t)arg; // each thread repeats its own sequence
kr = semaphore_wait_signal(start_sem, ready_sem);
T_QUIET; T_ASSERT_MACH_SUCCESS(kr, "semaphore_wait_signal");
while (atomic_fetch_sub_explicit(&todo, 1, memory_order_relaxed) > 0) {
uint64_t inner, outer;
random_busy_counts(&seed, &inner, &outer);
dummy = busy(outer);
r = pthread_mutex_lock(&ffmutex);
iferr (r) {T_QUIET; T_ASSERT_POSIX_ZERO(r, "mutex_lock");}
dummy = busy(inner);
r = pthread_mutex_unlock(&ffmutex);
iferr (r) {T_QUIET; T_ASSERT_POSIX_ZERO(r, "mutex_unlock");}
ctr_inc(total_locks);
}
if (atomic_fetch_sub_explicit(&active_thr, 1, memory_order_relaxed) == 1) {
kr = semaphore_signal(end_sem);
T_QUIET; T_ASSERT_MACH_SUCCESS(kr, "semaphore_signal");
}
goto restart;
}
static void
ffmutex_bench(bool singlethreaded)
{
int r;
int batch_size;
#if COUNTERS
uint64_t batch = 0;
#endif
setup_threaded_bench(ffmutex_bench_thread, singlethreaded);
pthread_mutexattr_t attr;
r = pthread_mutexattr_init(&attr);
T_QUIET; T_ASSERT_POSIX_ZERO(r, "mutexattr_init");
pthread_mutexattr_setpolicy_np(&attr, _PTHREAD_MUTEX_POLICY_FIRSTFIT);
T_QUIET; T_ASSERT_POSIX_ZERO(r, "mutexattr_setpolicy_np");
r = pthread_mutex_init(&ffmutex, &attr);
T_QUIET; T_ASSERT_POSIX_ZERO(r, "mutex_init");
dt_stat_time_t s = dt_stat_time_create("%llu pthread_mutex_lock & "
"pthread_mutex_unlock (first-fit) on %u thread%s",
iterations_per_dt_stat_batch, nthreads, nthreads > 1 ? "s" : "");
do {
batch_size = dt_stat_batch_size(s);
threaded_bench(s, batch_size);
#if COUNTERS
fprintf(stderr, "\rbatch: %4llu\t size: %4d\tffmutexes: %8llu",
++batch, batch_size,
atomic_load_explicit(&total_locks, memory_order_relaxed));
#endif
} while (!dt_stat_stable(s));
#if COUNTERS
fprintf(stderr, "\n");
#endif
dt_stat_finalize(s);
}
T_DECL(perf_uncontended_ffmutex_bench, "Uncontended first-fit mutex",
T_META_TYPE_PERF, T_META_ALL_VALID_ARCHS(NO),
T_META_LTEPHASE(LTE_POSTINIT), T_META_CHECK_LEAKS(false))
{
ffmutex_bench(true);
}
T_DECL(perf_contended_ffmutex_bench, "Contended first-fit mutex",
T_META_TYPE_PERF, T_META_ALL_VALID_ARCHS(NO),
T_META_LTEPHASE(LTE_POSTINIT), T_META_CHECK_LEAKS(false))
{
ffmutex_bench(false);
}
| 27.634615 | 80 | 0.748643 |
17b950d935c411c032423bc271e1381c91eb208b | 28,166 | c | C | sys/dev/sound/pci/atiixp.c | cooljeanius/DragonFlyBSD | 4c4e823ecc4019d4536be9493e38fef118f9a8cf | [
"BSD-3-Clause"
] | null | null | null | sys/dev/sound/pci/atiixp.c | cooljeanius/DragonFlyBSD | 4c4e823ecc4019d4536be9493e38fef118f9a8cf | [
"BSD-3-Clause"
] | null | null | null | sys/dev/sound/pci/atiixp.c | cooljeanius/DragonFlyBSD | 4c4e823ecc4019d4536be9493e38fef118f9a8cf | [
"BSD-3-Clause"
] | null | null | null | /*-
* Copyright (c) 2005 Ariff Abdullah <ariff@FreeBSD.org>
* 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 AUTHOR 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 AUTHOR 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, WHETHERIN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD: src/sys/dev/sound/pci/atiixp.c,v 1.2.2.8 2007/11/06 02:08:25 ariff Exp $
*/
/*
* FreeBSD pcm driver for ATI IXP 150/200/250/300 AC97 controllers
*
* Features
* * 16bit playback / recording
* * 32bit native playback - yay!
* * 32bit native recording (seems broken on few hardwares)
*
* Issues / TODO:
* * SPDIF
* * Support for more than 2 channels.
* * VRA ? VRM ? DRA ?
* * 32bit native recording seems broken on few hardwares, most
* probably because of incomplete VRA/DRA cleanup.
*
*
* Thanks goes to:
*
* Shaharil @ SCAN Associates whom relentlessly providing me the
* mind blowing Acer Ferrari 4002 WLMi with this ATI IXP hardware.
*
* Reinoud Zandijk <reinoud@NetBSD.org> (auixp), which this driver is
* largely based upon although large part of it has been reworked. His
* driver is the primary reference and pretty much well documented.
*
* Takashi Iwai (ALSA snd-atiixp), for register definitions and some
* random ninja hackery.
*/
#include <dev/sound/pcm/sound.h>
#include <dev/sound/pcm/ac97.h>
#include <bus/pci/pcireg.h>
#include <bus/pci/pcivar.h>
#include <sys/sysctl.h>
#include <sys/endian.h>
#include <dev/sound/pci/atiixp.h>
struct atiixp_dma_op {
volatile uint32_t addr;
volatile uint16_t status;
volatile uint16_t size;
volatile uint32_t next;
};
struct atiixp_info;
struct atiixp_chinfo {
struct snd_dbuf *buffer;
struct pcm_channel *channel;
struct atiixp_info *parent;
struct atiixp_dma_op *sgd_table;
bus_addr_t sgd_addr;
uint32_t enable_bit, flush_bit, linkptr_bit, dma_dt_cur_bit;
uint32_t dma_segs;
uint32_t fmt;
int caps_32bit, dir, active;
};
struct atiixp_info {
device_t dev;
bus_space_tag_t st;
bus_space_handle_t sh;
bus_dma_tag_t parent_dmat;
bus_dma_tag_t sgd_dmat;
bus_dmamap_t sgd_dmamap;
bus_addr_t sgd_addr;
struct resource *reg, *irq;
int regtype, regid, irqid;
void *ih;
struct ac97_info *codec;
struct atiixp_chinfo pch;
struct atiixp_chinfo rch;
struct atiixp_dma_op *sgd_table;
struct intr_config_hook delayed_attach;
uint32_t bufsz;
uint32_t codec_not_ready_bits, codec_idx, codec_found;
uint32_t dma_segs;
int registered_channels;
sndlock_t lock;
};
#define atiixp_rd(_sc, _reg) \
bus_space_read_4((_sc)->st, (_sc)->sh, _reg)
#define atiixp_wr(_sc, _reg, _val) \
bus_space_write_4((_sc)->st, (_sc)->sh, _reg, _val)
#define atiixp_lock(_sc) snd_mtxlock((_sc)->lock)
#define atiixp_unlock(_sc) snd_mtxunlock((_sc)->lock)
#define atiixp_assert(_sc) snd_mtxassert((_sc)->lock)
static uint32_t atiixp_fmt_32bit[] = {
AFMT_STEREO | AFMT_S16_LE,
AFMT_STEREO | AFMT_S32_LE,
0
};
static uint32_t atiixp_fmt[] = {
AFMT_STEREO | AFMT_S16_LE,
0
};
static struct pcmchan_caps atiixp_caps_32bit = {
ATI_IXP_BASE_RATE,
ATI_IXP_BASE_RATE,
atiixp_fmt_32bit, 0
};
static struct pcmchan_caps atiixp_caps = {
ATI_IXP_BASE_RATE,
ATI_IXP_BASE_RATE,
atiixp_fmt, 0
};
static const struct {
uint16_t vendor;
uint16_t devid;
char *desc;
} atiixp_hw[] = {
{ ATI_VENDOR_ID, ATI_IXP_200_ID, "ATI IXP 200" },
{ ATI_VENDOR_ID, ATI_IXP_300_ID, "ATI IXP 300" },
{ ATI_VENDOR_ID, ATI_IXP_400_ID, "ATI IXP 400" },
{ ATI_VENDOR_ID, ATI_IXP_SB600_ID, "ATI IXP SB600" },
};
static void atiixp_enable_interrupts(struct atiixp_info *);
static void atiixp_disable_interrupts(struct atiixp_info *);
static void atiixp_reset_aclink(struct atiixp_info *);
static void atiixp_flush_dma(struct atiixp_info *, struct atiixp_chinfo *);
static void atiixp_enable_dma(struct atiixp_info *, struct atiixp_chinfo *);
static void atiixp_disable_dma(struct atiixp_info *, struct atiixp_chinfo *);
static int atiixp_waitready_codec(struct atiixp_info *);
static int atiixp_rdcd(kobj_t, void *, int);
static int atiixp_wrcd(kobj_t, void *, int, uint32_t);
static void *atiixp_chan_init(kobj_t, void *, struct snd_dbuf *,
struct pcm_channel *, int);
static int atiixp_chan_setformat(kobj_t, void *, uint32_t);
static int atiixp_chan_setspeed(kobj_t, void *, uint32_t);
static int atiixp_chan_setblocksize(kobj_t, void *, uint32_t);
static void atiixp_buildsgdt(struct atiixp_chinfo *);
static int atiixp_chan_trigger(kobj_t, void *, int);
static int atiixp_chan_getptr(kobj_t, void *);
static struct pcmchan_caps *atiixp_chan_getcaps(kobj_t, void *);
static void atiixp_intr(void *);
static void atiixp_dma_cb(void *, bus_dma_segment_t *, int, int);
static void atiixp_chip_pre_init(struct atiixp_info *);
static void atiixp_chip_post_init(void *);
static void atiixp_release_resource(struct atiixp_info *);
static int atiixp_pci_probe(device_t);
static int atiixp_pci_attach(device_t);
static int atiixp_pci_detach(device_t);
static int atiixp_pci_suspend(device_t);
static int atiixp_pci_resume(device_t);
/*
* ATI IXP helper functions
*/
static void
atiixp_enable_interrupts(struct atiixp_info *sc)
{
uint32_t value;
/* clear all pending */
atiixp_wr(sc, ATI_REG_ISR, 0xffffffff);
/* enable all relevant interrupt sources we can handle */
value = atiixp_rd(sc, ATI_REG_IER);
value |= ATI_REG_IER_IO_STATUS_EN;
/*
* Disable / ignore internal xrun/spdf interrupt flags
* since it doesn't interest us (for now).
*/
#if 0
value |= ATI_REG_IER_IN_XRUN_EN;
value |= ATI_REG_IER_OUT_XRUN_EN;
value |= ATI_REG_IER_SPDF_XRUN_EN;
value |= ATI_REG_IER_SPDF_STATUS_EN;
#endif
atiixp_wr(sc, ATI_REG_IER, value);
}
static void
atiixp_disable_interrupts(struct atiixp_info *sc)
{
/* disable all interrupt sources */
atiixp_wr(sc, ATI_REG_IER, 0);
/* clear all pending */
atiixp_wr(sc, ATI_REG_ISR, 0xffffffff);
}
static void
atiixp_reset_aclink(struct atiixp_info *sc)
{
uint32_t value, timeout;
/* if power is down, power it up */
value = atiixp_rd(sc, ATI_REG_CMD);
if (value & ATI_REG_CMD_POWERDOWN) {
/* explicitly enable power */
value &= ~ATI_REG_CMD_POWERDOWN;
atiixp_wr(sc, ATI_REG_CMD, value);
/* have to wait at least 10 usec for it to initialise */
DELAY(20);
};
/* perform a soft reset */
value = atiixp_rd(sc, ATI_REG_CMD);
value |= ATI_REG_CMD_AC_SOFT_RESET;
atiixp_wr(sc, ATI_REG_CMD, value);
/* need to read the CMD reg and wait aprox. 10 usec to init */
value = atiixp_rd(sc, ATI_REG_CMD);
DELAY(20);
/* clear soft reset flag again */
value = atiixp_rd(sc, ATI_REG_CMD);
value &= ~ATI_REG_CMD_AC_SOFT_RESET;
atiixp_wr(sc, ATI_REG_CMD, value);
/* check if the ac-link is working; reset device otherwise */
timeout = 10;
value = atiixp_rd(sc, ATI_REG_CMD);
while (!(value & ATI_REG_CMD_ACLINK_ACTIVE)
&& --timeout) {
#if 0
device_printf(sc->dev, "not up; resetting aclink hardware\n");
#endif
/* dip aclink reset but keep the acsync */
value &= ~ATI_REG_CMD_AC_RESET;
value |= ATI_REG_CMD_AC_SYNC;
atiixp_wr(sc, ATI_REG_CMD, value);
/* need to read CMD again and wait again (clocking in issue?) */
value = atiixp_rd(sc, ATI_REG_CMD);
DELAY(20);
/* assert aclink reset again */
value = atiixp_rd(sc, ATI_REG_CMD);
value |= ATI_REG_CMD_AC_RESET;
atiixp_wr(sc, ATI_REG_CMD, value);
/* check if its active now */
value = atiixp_rd(sc, ATI_REG_CMD);
};
if (timeout == 0)
device_printf(sc->dev, "giving up aclink reset\n");
#if 0
if (timeout != 10)
device_printf(sc->dev, "aclink hardware reset successful\n");
#endif
/* assert reset and sync for safety */
value = atiixp_rd(sc, ATI_REG_CMD);
value |= ATI_REG_CMD_AC_SYNC | ATI_REG_CMD_AC_RESET;
atiixp_wr(sc, ATI_REG_CMD, value);
}
static void
atiixp_flush_dma(struct atiixp_info *sc, struct atiixp_chinfo *ch)
{
atiixp_wr(sc, ATI_REG_FIFO_FLUSH, ch->flush_bit);
}
static void
atiixp_enable_dma(struct atiixp_info *sc, struct atiixp_chinfo *ch)
{
uint32_t value;
value = atiixp_rd(sc, ATI_REG_CMD);
if (!(value & ch->enable_bit)) {
value |= ch->enable_bit;
atiixp_wr(sc, ATI_REG_CMD, value);
}
}
static void
atiixp_disable_dma(struct atiixp_info *sc, struct atiixp_chinfo *ch)
{
uint32_t value;
value = atiixp_rd(sc, ATI_REG_CMD);
if (value & ch->enable_bit) {
value &= ~ch->enable_bit;
atiixp_wr(sc, ATI_REG_CMD, value);
}
}
/*
* AC97 interface
*/
static int
atiixp_waitready_codec(struct atiixp_info *sc)
{
int timeout = 500;
do {
if ((atiixp_rd(sc, ATI_REG_PHYS_OUT_ADDR) &
ATI_REG_PHYS_OUT_ADDR_EN) == 0)
return 0;
DELAY(1);
} while (timeout--);
return -1;
}
static int
atiixp_rdcd(kobj_t obj, void *devinfo, int reg)
{
struct atiixp_info *sc = devinfo;
uint32_t data;
int timeout;
if (atiixp_waitready_codec(sc))
return -1;
data = (reg << ATI_REG_PHYS_OUT_ADDR_SHIFT) |
ATI_REG_PHYS_OUT_ADDR_EN |
ATI_REG_PHYS_OUT_RW | sc->codec_idx;
atiixp_wr(sc, ATI_REG_PHYS_OUT_ADDR, data);
if (atiixp_waitready_codec(sc))
return -1;
timeout = 500;
do {
data = atiixp_rd(sc, ATI_REG_PHYS_IN_ADDR);
if (data & ATI_REG_PHYS_IN_READ_FLAG)
return data >> ATI_REG_PHYS_IN_DATA_SHIFT;
DELAY(1);
} while (timeout--);
if (reg < 0x7c)
device_printf(sc->dev, "codec read timeout! (reg 0x%x)\n", reg);
return -1;
}
static int
atiixp_wrcd(kobj_t obj, void *devinfo, int reg, uint32_t data)
{
struct atiixp_info *sc = devinfo;
if (atiixp_waitready_codec(sc))
return -1;
data = (data << ATI_REG_PHYS_OUT_DATA_SHIFT) |
(((uint32_t)reg) << ATI_REG_PHYS_OUT_ADDR_SHIFT) |
ATI_REG_PHYS_OUT_ADDR_EN | sc->codec_idx;
atiixp_wr(sc, ATI_REG_PHYS_OUT_ADDR, data);
return 0;
}
static kobj_method_t atiixp_ac97_methods[] = {
KOBJMETHOD(ac97_read, atiixp_rdcd),
KOBJMETHOD(ac97_write, atiixp_wrcd),
KOBJMETHOD_END
};
AC97_DECLARE(atiixp_ac97);
/*
* Playback / Record channel interface
*/
static void *
atiixp_chan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b,
struct pcm_channel *c, int dir)
{
struct atiixp_info *sc = devinfo;
struct atiixp_chinfo *ch;
int num;
atiixp_lock(sc);
if (dir == PCMDIR_PLAY) {
ch = &sc->pch;
ch->linkptr_bit = ATI_REG_OUT_DMA_LINKPTR;
ch->enable_bit = ATI_REG_CMD_OUT_DMA_EN | ATI_REG_CMD_SEND_EN;
ch->flush_bit = ATI_REG_FIFO_OUT_FLUSH;
ch->dma_dt_cur_bit = ATI_REG_OUT_DMA_DT_CUR;
/* Native 32bit playback working properly */
ch->caps_32bit = 1;
} else {
ch = &sc->rch;
ch->linkptr_bit = ATI_REG_IN_DMA_LINKPTR;
ch->enable_bit = ATI_REG_CMD_IN_DMA_EN | ATI_REG_CMD_RECEIVE_EN;
ch->flush_bit = ATI_REG_FIFO_IN_FLUSH;
ch->dma_dt_cur_bit = ATI_REG_IN_DMA_DT_CUR;
/* XXX Native 32bit recording appear to be broken */
ch->caps_32bit = 1;
}
ch->buffer = b;
ch->parent = sc;
ch->channel = c;
ch->dir = dir;
ch->dma_segs = sc->dma_segs;
atiixp_unlock(sc);
if (sndbuf_alloc(ch->buffer, sc->parent_dmat, sc->bufsz) == -1)
return NULL;
atiixp_lock(sc);
num = sc->registered_channels++;
ch->sgd_table = &sc->sgd_table[num * ch->dma_segs];
ch->sgd_addr = sc->sgd_addr +
(num * ch->dma_segs * sizeof(struct atiixp_dma_op));
atiixp_disable_dma(sc, ch);
atiixp_unlock(sc);
return ch;
}
static int
atiixp_chan_setformat(kobj_t obj, void *data, uint32_t format)
{
struct atiixp_chinfo *ch = data;
struct atiixp_info *sc = ch->parent;
uint32_t value;
atiixp_lock(sc);
if (ch->dir == PCMDIR_REC) {
value = atiixp_rd(sc, ATI_REG_CMD);
value &= ~ATI_REG_CMD_INTERLEAVE_IN;
if ((format & AFMT_32BIT) == 0)
value |= ATI_REG_CMD_INTERLEAVE_IN;
atiixp_wr(sc, ATI_REG_CMD, value);
} else {
value = atiixp_rd(sc, ATI_REG_OUT_DMA_SLOT);
value &= ~ATI_REG_OUT_DMA_SLOT_MASK;
/* We do not have support for more than 2 channels, _yet_. */
value |= ATI_REG_OUT_DMA_SLOT_BIT(3) |
ATI_REG_OUT_DMA_SLOT_BIT(4);
value |= 0x04 << ATI_REG_OUT_DMA_THRESHOLD_SHIFT;
atiixp_wr(sc, ATI_REG_OUT_DMA_SLOT, value);
value = atiixp_rd(sc, ATI_REG_CMD);
value &= ~ATI_REG_CMD_INTERLEAVE_OUT;
if ((format & AFMT_32BIT) == 0)
value |= ATI_REG_CMD_INTERLEAVE_OUT;
atiixp_wr(sc, ATI_REG_CMD, value);
value = atiixp_rd(sc, ATI_REG_6CH_REORDER);
value &= ~ATI_REG_6CH_REORDER_EN;
atiixp_wr(sc, ATI_REG_6CH_REORDER, value);
}
ch->fmt = format;
atiixp_unlock(sc);
return 0;
}
static int
atiixp_chan_setspeed(kobj_t obj, void *data, uint32_t spd)
{
/* XXX We're supposed to do VRA/DRA processing right here */
return ATI_IXP_BASE_RATE;
}
static int
atiixp_chan_setblocksize(kobj_t obj, void *data, uint32_t blksz)
{
struct atiixp_chinfo *ch = data;
struct atiixp_info *sc = ch->parent;
if (blksz > (sc->bufsz / ch->dma_segs))
blksz = sc->bufsz / ch->dma_segs;
sndbuf_resize(ch->buffer, ch->dma_segs, blksz);
return sndbuf_getblksz(ch->buffer);
}
static void
atiixp_buildsgdt(struct atiixp_chinfo *ch)
{
uint32_t addr, blksz;
int i;
addr = sndbuf_getbufaddr(ch->buffer);
blksz = sndbuf_getblksz(ch->buffer);
for (i = 0; i < ch->dma_segs; i++) {
ch->sgd_table[i].addr = htole32(addr + (i * blksz));
ch->sgd_table[i].status = htole16(0);
ch->sgd_table[i].size = htole16(blksz >> 2);
ch->sgd_table[i].next = htole32((uint32_t)ch->sgd_addr +
(((i + 1) % ch->dma_segs) *
sizeof(struct atiixp_dma_op)));
}
}
static int
atiixp_chan_trigger(kobj_t obj, void *data, int go)
{
struct atiixp_chinfo *ch = data;
struct atiixp_info *sc = ch->parent;
uint32_t value;
atiixp_lock(sc);
switch (go) {
case PCMTRIG_START:
atiixp_flush_dma(sc, ch);
atiixp_buildsgdt(ch);
atiixp_wr(sc, ch->linkptr_bit, 0);
atiixp_enable_dma(sc, ch);
atiixp_wr(sc, ch->linkptr_bit,
(uint32_t)ch->sgd_addr | ATI_REG_LINKPTR_EN);
break;
case PCMTRIG_STOP:
case PCMTRIG_ABORT:
atiixp_disable_dma(sc, ch);
atiixp_flush_dma(sc, ch);
break;
default:
atiixp_unlock(sc);
return 0;
break;
}
/* Update bus busy status */
value = atiixp_rd(sc, ATI_REG_IER);
if (atiixp_rd(sc, ATI_REG_CMD) & (
ATI_REG_CMD_SEND_EN | ATI_REG_CMD_RECEIVE_EN |
ATI_REG_CMD_SPDF_OUT_EN))
value |= ATI_REG_IER_SET_BUS_BUSY;
else
value &= ~ATI_REG_IER_SET_BUS_BUSY;
atiixp_wr(sc, ATI_REG_IER, value);
atiixp_unlock(sc);
return 0;
}
static int
atiixp_chan_getptr(kobj_t obj, void *data)
{
struct atiixp_chinfo *ch = data;
struct atiixp_info *sc = ch->parent;
uint32_t addr, align, retry, sz;
volatile uint32_t ptr;
addr = sndbuf_getbufaddr(ch->buffer);
align = (ch->fmt & AFMT_32BIT) ? 7 : 3;
retry = 100;
sz = sndbuf_getblksz(ch->buffer) * ch->dma_segs;
atiixp_lock(sc);
do {
ptr = atiixp_rd(sc, ch->dma_dt_cur_bit);
if (ptr < addr)
continue;
ptr -= addr;
if (ptr < sz && !(ptr & align))
break;
} while (--retry);
atiixp_unlock(sc);
#if 0
if (retry != 100) {
device_printf(sc->dev,
"%saligned hwptr: dir=PCMDIR_%s ptr=%u fmt=0x%08x retry=%d\n",
(ptr & align) ? "un" : "",
(ch->dir == PCMDIR_PLAY) ? "PLAY" : "REC", ptr,
ch->fmt, 100 - retry);
}
#endif
return (retry > 0) ? ptr : 0;
}
static struct pcmchan_caps *
atiixp_chan_getcaps(kobj_t obj, void *data)
{
struct atiixp_chinfo *ch = data;
if (ch->caps_32bit)
return &atiixp_caps_32bit;
return &atiixp_caps;
}
static kobj_method_t atiixp_chan_methods[] = {
KOBJMETHOD(channel_init, atiixp_chan_init),
KOBJMETHOD(channel_setformat, atiixp_chan_setformat),
KOBJMETHOD(channel_setspeed, atiixp_chan_setspeed),
KOBJMETHOD(channel_setblocksize, atiixp_chan_setblocksize),
KOBJMETHOD(channel_trigger, atiixp_chan_trigger),
KOBJMETHOD(channel_getptr, atiixp_chan_getptr),
KOBJMETHOD(channel_getcaps, atiixp_chan_getcaps),
KOBJMETHOD_END
};
CHANNEL_DECLARE(atiixp_chan);
/*
* PCI driver interface
*/
static void
atiixp_intr(void *p)
{
struct atiixp_info *sc = p;
uint32_t status, enable, detected_codecs;
atiixp_lock(sc);
status = atiixp_rd(sc, ATI_REG_ISR);
if (status == 0) {
atiixp_unlock(sc);
return;
}
if ((status & ATI_REG_ISR_IN_STATUS) && sc->rch.channel) {
atiixp_unlock(sc);
chn_intr(sc->rch.channel);
atiixp_lock(sc);
}
if ((status & ATI_REG_ISR_OUT_STATUS) && sc->pch.channel) {
atiixp_unlock(sc);
chn_intr(sc->pch.channel);
atiixp_lock(sc);
}
#if 0
if (status & ATI_REG_ISR_IN_XRUN) {
device_printf(sc->dev,
"Receive IN XRUN interrupt\n");
}
if (status & ATI_REG_ISR_OUT_XRUN) {
device_printf(sc->dev,
"Receive OUT XRUN interrupt\n");
}
#endif
if (status & CODEC_CHECK_BITS) {
/* mark missing codecs as not ready */
detected_codecs = status & CODEC_CHECK_BITS;
sc->codec_not_ready_bits |= detected_codecs;
/* disable detected interupt sources */
enable = atiixp_rd(sc, ATI_REG_IER);
enable &= ~detected_codecs;
atiixp_wr(sc, ATI_REG_IER, enable);
}
/* acknowledge */
atiixp_wr(sc, ATI_REG_ISR, status);
atiixp_unlock(sc);
}
static void
atiixp_dma_cb(void *p, bus_dma_segment_t *bds, int a, int b)
{
struct atiixp_info *sc = (struct atiixp_info *)p;
sc->sgd_addr = bds->ds_addr;
}
static void
atiixp_chip_pre_init(struct atiixp_info *sc)
{
uint32_t value;
atiixp_lock(sc);
/* disable interrupts */
atiixp_disable_interrupts(sc);
/* clear all DMA enables (preserving rest of settings) */
value = atiixp_rd(sc, ATI_REG_CMD);
value &= ~(ATI_REG_CMD_IN_DMA_EN | ATI_REG_CMD_OUT_DMA_EN |
ATI_REG_CMD_SPDF_OUT_EN );
atiixp_wr(sc, ATI_REG_CMD, value);
/* reset aclink */
atiixp_reset_aclink(sc);
sc->codec_not_ready_bits = 0;
/* enable all codecs to interrupt as well as the new frame interrupt */
atiixp_wr(sc, ATI_REG_IER, CODEC_CHECK_BITS);
atiixp_unlock(sc);
}
static void
atiixp_chip_post_init(void *arg)
{
struct atiixp_info *sc = (struct atiixp_info *)arg;
uint32_t subdev;
int i, timeout, found;
char status[SND_STATUSLEN];
atiixp_lock(sc);
if (sc->delayed_attach.ich_func) {
config_intrhook_disestablish(&sc->delayed_attach);
sc->delayed_attach.ich_func = NULL;
}
/* wait for the interrupts to happen */
timeout = 100;
while (--timeout) {
snd_mtxsleep(sc, sc->lock, 0, "ixpslp", 1);
if (sc->codec_not_ready_bits)
break;
}
atiixp_disable_interrupts(sc);
if (timeout == 0) {
device_printf(sc->dev,
"WARNING: timeout during codec detection; "
"codecs might be present but haven't interrupted\n");
atiixp_unlock(sc);
goto postinitbad;
}
found = 0;
/*
* ATI IXP can have upto 3 codecs, but single codec should be
* suffice for now.
*/
if (!(sc->codec_not_ready_bits &
ATI_REG_ISR_CODEC0_NOT_READY)) {
/* codec 0 present */
sc->codec_found++;
sc->codec_idx = 0;
found++;
}
if (!(sc->codec_not_ready_bits &
ATI_REG_ISR_CODEC1_NOT_READY)) {
/* codec 1 present */
sc->codec_found++;
}
if (!(sc->codec_not_ready_bits &
ATI_REG_ISR_CODEC2_NOT_READY)) {
/* codec 2 present */
sc->codec_found++;
}
atiixp_unlock(sc);
if (found == 0)
goto postinitbad;
/* create/init mixer */
sc->codec = AC97_CREATE(sc->dev, sc, atiixp_ac97);
if (sc->codec == NULL)
goto postinitbad;
subdev = (pci_get_subdevice(sc->dev) << 16) | pci_get_subvendor(sc->dev);
switch (subdev) {
case 0x11831043: /* ASUS A6R */
case 0x2043161f: /* Maxselect x710s - http://maxselect.ru/ */
ac97_setflags(sc->codec, ac97_getflags(sc->codec) | AC97_F_EAPD_INV);
break;
default:
break;
}
mixer_init(sc->dev, ac97_getmixerclass(), sc->codec);
if (pcm_register(sc->dev, sc, ATI_IXP_NPCHAN, ATI_IXP_NRCHAN))
goto postinitbad;
for (i = 0; i < ATI_IXP_NPCHAN; i++)
pcm_addchan(sc->dev, PCMDIR_PLAY, &atiixp_chan_class, sc);
for (i = 0; i < ATI_IXP_NRCHAN; i++)
pcm_addchan(sc->dev, PCMDIR_REC, &atiixp_chan_class, sc);
ksnprintf(status, SND_STATUSLEN, "at memory 0x%lx irq %ld %s",
rman_get_start(sc->reg), rman_get_start(sc->irq),
PCM_KLDSTRING(snd_atiixp));
pcm_setstatus(sc->dev, status);
atiixp_lock(sc);
atiixp_enable_interrupts(sc);
atiixp_unlock(sc);
return;
postinitbad:
atiixp_release_resource(sc);
}
static void
atiixp_release_resource(struct atiixp_info *sc)
{
if (sc == NULL)
return;
if (sc->codec) {
ac97_destroy(sc->codec);
sc->codec = NULL;
}
if (sc->ih) {
bus_teardown_intr(sc->dev, sc->irq, sc->ih);
sc->ih = NULL;
}
if (sc->reg) {
bus_release_resource(sc->dev, sc->regtype, sc->regid, sc->reg);
sc->reg = NULL;
}
if (sc->irq) {
bus_release_resource(sc->dev, SYS_RES_IRQ, sc->irqid, sc->irq);
sc->irq = NULL;
}
if (sc->parent_dmat) {
bus_dma_tag_destroy(sc->parent_dmat);
sc->parent_dmat = NULL;
}
if (sc->sgd_dmamap)
bus_dmamap_unload(sc->sgd_dmat, sc->sgd_dmamap);
if (sc->sgd_table) {
bus_dmamem_free(sc->sgd_dmat, sc->sgd_table, sc->sgd_dmamap);
sc->sgd_table = NULL;
}
sc->sgd_dmamap = NULL;
if (sc->sgd_dmat) {
bus_dma_tag_destroy(sc->sgd_dmat);
sc->sgd_dmat = NULL;
}
if (sc->lock) {
snd_mtxfree(sc->lock);
sc->lock = NULL;
}
}
static int
atiixp_pci_probe(device_t dev)
{
int i;
uint16_t devid, vendor;
vendor = pci_get_vendor(dev);
devid = pci_get_device(dev);
for (i = 0; i < NELEM(atiixp_hw); i++) {
if (vendor == atiixp_hw[i].vendor &&
devid == atiixp_hw[i].devid) {
device_set_desc(dev, atiixp_hw[i].desc);
return BUS_PROBE_DEFAULT;
}
}
return ENXIO;
}
static int
atiixp_pci_attach(device_t dev)
{
struct atiixp_info *sc;
int i;
sc = kmalloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO);
sc->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc");
sc->dev = dev;
/*
* Default DMA segments per playback / recording channel
*/
sc->dma_segs = ATI_IXP_DMA_CHSEGS;
pci_set_powerstate(dev, PCI_POWERSTATE_D0);
pci_enable_busmaster(dev);
sc->regid = PCIR_BAR(0);
sc->regtype = SYS_RES_MEMORY;
sc->reg = bus_alloc_resource_any(dev, sc->regtype, &sc->regid,
RF_ACTIVE);
if (!sc->reg) {
device_printf(dev, "unable to allocate register space\n");
goto bad;
}
sc->st = rman_get_bustag(sc->reg);
sc->sh = rman_get_bushandle(sc->reg);
sc->bufsz = pcm_getbuffersize(dev, 4096, ATI_IXP_DEFAULT_BUFSZ, 65536);
sc->irqid = 0;
sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irqid,
RF_ACTIVE | RF_SHAREABLE);
if (!sc->irq ||
snd_setup_intr(dev, sc->irq, INTR_MPSAFE,
atiixp_intr, sc, &sc->ih)) {
device_printf(dev, "unable to map interrupt\n");
goto bad;
}
/*
* Let the user choose the best DMA segments.
*/
if (resource_int_value(device_get_name(dev),
device_get_unit(dev), "dma_segs",
&i) == 0) {
if (i < ATI_IXP_DMA_CHSEGS_MIN)
i = ATI_IXP_DMA_CHSEGS_MIN;
if (i > ATI_IXP_DMA_CHSEGS_MAX)
i = ATI_IXP_DMA_CHSEGS_MAX;
sc->dma_segs = i;
}
/*
* round the value to the nearest ^2
*/
i = 0;
while (sc->dma_segs >> i)
i++;
sc->dma_segs = 1 << (i - 1);
if (sc->dma_segs < ATI_IXP_DMA_CHSEGS_MIN)
sc->dma_segs = ATI_IXP_DMA_CHSEGS_MIN;
else if (sc->dma_segs > ATI_IXP_DMA_CHSEGS_MAX)
sc->dma_segs = ATI_IXP_DMA_CHSEGS_MAX;
/*
* DMA tag for scatter-gather buffers and link pointers
*/
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
/*maxsize*/sc->bufsz, /*nsegments*/1, /*maxsegz*/0x3ffff,
/*flags*/0,
&sc->parent_dmat) != 0) {
device_printf(dev, "unable to create dma tag\n");
goto bad;
}
if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
/*lowaddr*/BUS_SPACE_MAXADDR_32BIT,
/*highaddr*/BUS_SPACE_MAXADDR,
/*filter*/NULL, /*filterarg*/NULL,
/*maxsize*/sc->dma_segs * ATI_IXP_NCHANS *
sizeof(struct atiixp_dma_op),
/*nsegments*/1, /*maxsegz*/0x3ffff,
/*flags*/0,
&sc->sgd_dmat) != 0) {
device_printf(dev, "unable to create dma tag\n");
goto bad;
}
if (bus_dmamem_alloc(sc->sgd_dmat, (void **)&sc->sgd_table,
BUS_DMA_NOWAIT, &sc->sgd_dmamap) == -1)
goto bad;
if (bus_dmamap_load(sc->sgd_dmat, sc->sgd_dmamap, sc->sgd_table,
sc->dma_segs * ATI_IXP_NCHANS *
sizeof(struct atiixp_dma_op),
atiixp_dma_cb, sc, 0))
goto bad;
atiixp_chip_pre_init(sc);
sc->delayed_attach.ich_func = atiixp_chip_post_init;
sc->delayed_attach.ich_arg = sc;
sc->delayed_attach.ich_desc = "snd_atiixp";
if (cold == 0 ||
config_intrhook_establish(&sc->delayed_attach) != 0) {
sc->delayed_attach.ich_func = NULL;
atiixp_chip_post_init(sc);
}
return 0;
bad:
atiixp_release_resource(sc);
return ENXIO;
}
static int
atiixp_pci_detach(device_t dev)
{
int r;
struct atiixp_info *sc;
sc = pcm_getdevinfo(dev);
if (sc != NULL) {
if (sc->codec != NULL) {
r = pcm_unregister(dev);
if (r)
return r;
}
sc->codec = NULL;
atiixp_disable_interrupts(sc);
atiixp_release_resource(sc);
kfree(sc, M_DEVBUF);
}
return 0;
}
static int
atiixp_pci_suspend(device_t dev)
{
struct atiixp_info *sc = pcm_getdevinfo(dev);
uint32_t value;
/* quickly disable interrupts and save channels active state */
atiixp_lock(sc);
atiixp_disable_interrupts(sc);
value = atiixp_rd(sc, ATI_REG_CMD);
sc->pch.active = (value & ATI_REG_CMD_SEND_EN) ? 1 : 0;
sc->rch.active = (value & ATI_REG_CMD_RECEIVE_EN) ? 1 : 0;
atiixp_unlock(sc);
/* stop everything */
if (sc->pch.channel && sc->pch.active)
atiixp_chan_trigger(NULL, &sc->pch, PCMTRIG_STOP);
if (sc->rch.channel && sc->rch.active)
atiixp_chan_trigger(NULL, &sc->rch, PCMTRIG_STOP);
/* power down aclink and pci bus */
atiixp_lock(sc);
value = atiixp_rd(sc, ATI_REG_CMD);
value |= ATI_REG_CMD_POWERDOWN | ATI_REG_CMD_AC_RESET;
atiixp_wr(sc, ATI_REG_CMD, ATI_REG_CMD_POWERDOWN);
pci_set_powerstate(dev, PCI_POWERSTATE_D3);
atiixp_unlock(sc);
return 0;
}
static int
atiixp_pci_resume(device_t dev)
{
struct atiixp_info *sc = pcm_getdevinfo(dev);
atiixp_lock(sc);
/* power up pci bus */
pci_set_powerstate(dev, PCI_POWERSTATE_D0);
pci_enable_io(dev, SYS_RES_MEMORY);
pci_enable_busmaster(dev);
/* reset / power up aclink */
atiixp_reset_aclink(sc);
atiixp_unlock(sc);
if (mixer_reinit(dev) == -1) {
device_printf(dev, "unable to reinitialize the mixer\n");
return ENXIO;
}
/*
* Resume channel activities. Reset channel format regardless
* of its previous state.
*/
if (sc->pch.channel) {
if (sc->pch.fmt)
atiixp_chan_setformat(NULL, &sc->pch, sc->pch.fmt);
if (sc->pch.active)
atiixp_chan_trigger(NULL, &sc->pch, PCMTRIG_START);
}
if (sc->rch.channel) {
if (sc->rch.fmt)
atiixp_chan_setformat(NULL, &sc->rch, sc->rch.fmt);
if (sc->rch.active)
atiixp_chan_trigger(NULL, &sc->rch, PCMTRIG_START);
}
/* enable interrupts */
atiixp_lock(sc);
atiixp_enable_interrupts(sc);
atiixp_unlock(sc);
return 0;
}
static device_method_t atiixp_methods[] = {
DEVMETHOD(device_probe, atiixp_pci_probe),
DEVMETHOD(device_attach, atiixp_pci_attach),
DEVMETHOD(device_detach, atiixp_pci_detach),
DEVMETHOD(device_suspend, atiixp_pci_suspend),
DEVMETHOD(device_resume, atiixp_pci_resume),
{ 0, 0 }
};
static driver_t atiixp_driver = {
"pcm",
atiixp_methods,
PCM_SOFTC_SIZE,
};
DRIVER_MODULE(snd_atiixp, pci, atiixp_driver, pcm_devclass, NULL, NULL);
MODULE_DEPEND(snd_atiixp, sound, SOUND_MINVER, SOUND_PREFVER, SOUND_MAXVER);
MODULE_VERSION(snd_atiixp, 1);
| 24.859665 | 85 | 0.711035 |
9de0d81ed54d5f6b1da450bfb9b2dff481b535c6 | 11,443 | h | C | tf2_src/public/panorama/localization/ilocalize.h | d3fc0n6/TeamFortress2 | 1b81dded673d49adebf4d0958e52236ecc28a956 | [
"MIT"
] | 4 | 2021-10-03T05:16:55.000Z | 2021-12-28T16:49:27.000Z | tf2_src/public/panorama/localization/ilocalize.h | Counter2828/TeamFortress2 | 1b81dded673d49adebf4d0958e52236ecc28a956 | [
"MIT"
] | null | null | null | tf2_src/public/panorama/localization/ilocalize.h | Counter2828/TeamFortress2 | 1b81dded673d49adebf4d0958e52236ecc28a956 | [
"MIT"
] | 3 | 2022-02-02T18:09:58.000Z | 2022-03-06T18:54:39.000Z | //=========== Copyright Valve Corporation, All rights reserved. ===============//
//
// Purpose:
//=============================================================================//
#ifndef PANORAMA_ILOCALIZE_H
#define PANORAMA_ILOCALIZE_H
#include "language.h"
#include "tier0/platform.h"
#include "tier1/interface.h"
#include "tier1/utlflags.h"
#include "tier1/utlsymbol.h"
#include "tier1/utlstring.h"
#include "tier1/utlmap.h"
#include "tier1/fileio.h"
#include "tier1/utlpriorityqueue.h"
#include "steam/steamtypes.h"
#if defined( SOURCE2_PANORAMA )
#include "currencyamount.h"
#else
#include "stime.h"
#include "constants.h"
#include "globals.h"
#include "amount.h"
#include "rtime.h"
#endif
#include "reliabletimer.h"
#include "language.h"
namespace panorama
{
//-----------------------------------------------------------------------------
// Purpose: type of variable data we are supporting
//-----------------------------------------------------------------------------
enum EPanelKeyType
{
k_ePanelVartype_None,
k_ePanelVartype_String,
k_ePanelVartype_Time,
k_ePanelVartype_Money,
k_ePanelVartype_Number,
k_ePanelVartype_Generic
};
// help function syntax for the generic key handler
typedef const char *( *PFNLocalizeDialogVariableHandler )( const CUtlString &sStringValue, int nIntValue, const IUIPanel *pPanel, const char *pszKey, void *pUserData );
enum EPanelKeyTimeModifiers
{
k_ePanelKeyTimeModifiers_ShortDate = 1 << 0,
k_ePanelKeyTimeModifiers_LongDate = 1 << 1,
k_ePanelKeyTimeModifiers_ShortTime = 1 << 2,
k_ePanelKeyTimeModifiers_LongTime = 1 << 3,
k_ePanelKeyTimeModifiers_DateTime = 1 << 4,
k_ePanelKeyTimeModifiers_Relative = 1 << 5,
k_ePanelKeyTimeModifiers_Duration = 1 << 6,
};
enum EStringTruncationStyle
{
k_eStringTruncationStyle_None,
k_eStringTruncationStyle_Rear, // prevent any chars being added above max length
k_eStringTruncationStyle_Front, // remove
};
enum EStringTransformStyle
{
k_eStringTransformStyle_None,
k_eStringTransformStyle_Uppercase,
k_eStringTransformStyle_Lowercase,
};
//-----------------------------------------------------------------------------
// Purpose: callback interface to help measuring strings
//-----------------------------------------------------------------------------
class ILocalizationStringSizeResolver
{
public:
virtual ~ILocalizationStringSizeResolver() {}
virtual int ResolveStringLengthInPixels( const char *pchString ) = 0;
};
const uint32 k_nLocalizeMaxChars = (uint32)~0;
class CPanelKeyValue;
class CLocalization;
class CPanel2D;
//-----------------------------------------------------------------------------
// Purpose: interface to final string data to display to users
//-----------------------------------------------------------------------------
class ILocalizationString
{
public:
virtual ~ILocalizationString() {}
// Get the length of the string in characters
virtual int Length() const = 0;
virtual bool IsEmpty() const = 0;
virtual const char *String() const = 0;
virtual const char *StringNoTransform() const = 0;
virtual operator const char *() const = 0;
// add this string on the end
virtual bool AppendText( const char *pchText ) = 0;
// done with this string, delete it
virtual void Release() const = 0;
virtual EStringTransformStyle GetTransformStyle() const = 0;
virtual const IUIPanel *GetOwningPanel() const = 0;
virtual uint32 GetMaxChars() const = 0;
virtual EStringTruncationStyle GetTruncationStyle() const = 0;
#ifdef DBGFLAG_VALIDATE
virtual void Validate( CValidator &validator, const tchar *pchName ) = 0;
#endif
protected:
// internal loc engine helpers, you won't call these
friend class CLocalization;
virtual void Recalculate( const CUtlString *pString ) = 0;
virtual bool BContainsDialogVariable( const CPanelKeyValue &key ) = 0;
};
class CLocStringSafePointer
{
public:
CLocStringSafePointer()
{
m_pString = NULL;
}
CLocStringSafePointer( const ILocalizationString *pLocString )
{
m_pString = pLocString;
}
CLocStringSafePointer &operator =( const ILocalizationString *pString )
{
if ( m_pString == pString )
return *this;
Clear();
m_pString = const_cast<ILocalizationString *>( pString );
return *this;
}
const ILocalizationString *operator ->( ) const
{
return Get();
}
const ILocalizationString *operator *( ) const
{
return Get();
}
operator const ILocalizationString*( ) const
{
return Get();
}
~CLocStringSafePointer()
{
Clear();
}
void Clear()
{
if ( m_pString )
{
m_pString->Release();
m_pString = NULL;
}
}
bool IsValid() { return m_pString != nullptr; }
const ILocalizationString *Get() const
{
return m_pString;
}
private:
const ILocalizationString *m_pString;
};
//-----------------------------------------------------------------------------
// Purpose: interface to localize strings
//-----------------------------------------------------------------------------
class IUILocalization
{
public:
// change the language used by the loc system
virtual bool SetLanguage( const char *pchLanguage ) = 0;
#if defined( SOURCE2_PANORAMA )
// add a loc file to the system, in the form of <prefix>_<language>.txt , i.e dota_french.txt, the files will be loaded from the panorama/localization folder of your mod
virtual bool BLoadLocalizationFile( const char *pchFilePrefix ) = 0;
#else
virtual ELanguage CurrentLanguage() = 0;
#endif
virtual void InstallCustomDialogVariableHandler( const char *pchCustomHandlerName, PFNLocalizeDialogVariableHandler pfnLocalizeFunc, void *pUserData = NULL ) = 0;
virtual void RemoveCustomDialogVariableHandler( const char *pchCustomHandlerName ) = 0;
// find the string corresponding to this localization token, or if we don't find it then just return back the string wrapped in a loc object
virtual const ILocalizationString *PchFindToken( const IUIPanel *pPanel, const char *pchToken, const uint32 ccMax , EStringTruncationStyle eTrunkStyle, EStringTransformStyle eTransformStyle, bool bAllowDialogVariable = false ) = 0;
// give me a localize string wrapper around this string, don't try and apply token localizing on it though, but do optionally allow it to have dialog variables that we parse in it
// be careful allowing dialog variable parsing, you want to sanitize any user input before allowing it
virtual const ILocalizationString *PchSetString( const IUIPanel *pPanel, const char *pchText, const uint32 ccMax, EStringTruncationStyle eTrunkStyle, EStringTransformStyle eTransformStyle, bool bAllowDialogVariable, bool bStringAlreadyFullyParsed ) = 0;
virtual const ILocalizationString *ChangeTransformStyleAndRelease( const ILocalizationString *pLocalizationString, EStringTransformStyle eTranformStyle ) = 0;
// copy an existing loc string without altering the ref count on the current
virtual ILocalizationString *CloneString( const IUIPanel *pPanel, const ILocalizationString *pLocToken ) = 0;
// return the raw, un-parsed, value for this loc token, returns NULL if we didn't have this token in a loc file from disk
virtual const char *PchFindRawString( const char *pchToken ) = 0;
virtual bool SetDialogVariable( const IUIPanel *pPanel, const char *pchKey, const char *pchValue ) = 0;
#if defined( SOURCE2_PANORAMA )
virtual bool SetDialogVariable( const IUIPanel *pPanel, const char *pchKey, time_t timeVal ) = 0;
virtual bool SetDialogVariable( const IUIPanel *pPanel, const char *pchKey, CCurrencyAmount amount ) = 0;
#else
virtual bool SetDialogVariable( const IUIPanel *pPanel, const char *pchKey, CRTime timeVal ) = 0;
virtual bool SetDialogVariable( const IUIPanel *pPanel, const char *pchKey, CAmount amount ) = 0;
#endif
virtual bool SetDialogVariable( const IUIPanel *pPanel, const char *pchKey, int nVal ) = 0;
// copy all the dialog vars to a new panel
virtual void CloneDialogVariables( const IUIPanel *pPanelFrom, IUIPanel *pPanelTo ) = 0;
// force a re-evaluation of a specific dialog variable
virtual void DirtyDialogVariable( const IUIPanel *pPanel, const char *pchKey ) = 0;
// given this loc string find the longest string in any language that we could display here and update to use it
virtual void SetLongestStringForToken( const ILocalizationString *pLocalizationString, ILocalizationStringSizeResolver *pResolver ) = 0;
};
//-----------------------------------------------------------------------------
// Purpose: Wrapper around ILocalizationString that will take care of making
// a copy if it ends up needing to be mutable.
//-----------------------------------------------------------------------------
class CMutableLocalizationString
{
public:
CMutableLocalizationString()
: m_bMutable( false )
, m_pString( NULL )
{
}
CMutableLocalizationString( ILocalizationString *pString )
: m_bMutable( true )
, m_pString( pString )
{
}
CMutableLocalizationString( const ILocalizationString *pString )
: m_bMutable( false )
, m_pString( const_cast< ILocalizationString * >( pString ) )
{
}
CMutableLocalizationString( const CMutableLocalizationString &other )
{
m_bMutable = true;
if ( other.m_pString )
{
m_pString = UILocalize()->CloneString( other.m_pString->GetOwningPanel(), other.m_pString );
}
else
{
m_pString = NULL;
}
}
~CMutableLocalizationString()
{
Clear();
}
const ILocalizationString *Get() const
{
return m_pString;
}
ILocalizationString *GetMutable()
{
if ( m_bMutable || !m_pString )
return m_pString;
ILocalizationString *pOldString = m_pString;
m_pString = UILocalize()->CloneString( pOldString->GetOwningPanel(), pOldString );
m_bMutable = true;
pOldString->Release();
return m_pString;
}
void Clear()
{
if ( m_pString )
{
m_pString->Release();
m_pString = NULL;
}
}
const ILocalizationString *Extract()
{
const ILocalizationString *pString = m_pString;
m_pString = NULL;
return pString;
}
ILocalizationString *ExtractMutable()
{
ILocalizationString *pString = GetMutable();
m_pString = NULL;
return pString;
}
// The -> operator is only overloaded to return a const string. If you need a mutable version, you must call GetMutable directly.
const ILocalizationString *operator ->() const
{
return Get();
}
explicit operator bool() const
{
return Get() != NULL;
}
bool operator ==( const CMutableLocalizationString &other ) const
{
return m_pString == other.m_pString;
}
bool operator !=( const CMutableLocalizationString &other ) const
{
return !( *this == other );
}
bool operator ==( const ILocalizationString *pString ) const
{
return m_pString == pString;
}
bool operator !=( const ILocalizationString *pString ) const
{
return !( *this == pString );
}
CMutableLocalizationString &operator =( const CMutableLocalizationString &other )
{
if ( other.m_pString == m_pString )
return *this;
Clear();
m_bMutable = true;
if ( other.m_pString )
{
m_pString = UILocalize()->CloneString( other.m_pString->GetOwningPanel(), other.m_pString );
}
else
{
m_pString = NULL;
}
return *this;
}
CMutableLocalizationString &operator =( const ILocalizationString *pString )
{
if ( m_pString == pString )
return *this;
Clear();
m_bMutable = false;
m_pString = const_cast< ILocalizationString * >( pString );
return *this;
}
private:
bool m_bMutable;
ILocalizationString *m_pString;;
};
} // namespace panorama
#endif // PANORAMA_ILOCALIZE_H
| 28.115479 | 254 | 0.688631 |
8d8dbe61e20047381ebb3ff07d02fb5ceca30f8b | 12,835 | c | C | dpdk/examples/load_balancer/init.c | yuzhuolong1993/mmtcp | c4f67178191b3c93b1efb364549f69041056ca15 | [
"BSD-3-Clause"
] | 287 | 2017-12-17T14:48:00.000Z | 2022-03-28T06:12:07.000Z | dpdk/examples/load_balancer/init.c | Tominous/jupiter | 1fd7df081f7b459ee5e951ff16ca1741f6c8e021 | [
"MIT"
] | 18 | 2017-12-18T15:50:59.000Z | 2020-05-14T09:19:38.000Z | dpdk/examples/load_balancer/init.c | Tominous/jupiter | 1fd7df081f7b459ee5e951ff16ca1741f6c8e021 | [
"MIT"
] | 109 | 2017-12-19T03:42:09.000Z | 2022-03-25T11:25:39.000Z | /* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2010-2014 Intel Corporation
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <sys/types.h>
#include <string.h>
#include <sys/queue.h>
#include <stdarg.h>
#include <errno.h>
#include <getopt.h>
#include <rte_common.h>
#include <rte_byteorder.h>
#include <rte_log.h>
#include <rte_memory.h>
#include <rte_memcpy.h>
#include <rte_eal.h>
#include <rte_launch.h>
#include <rte_atomic.h>
#include <rte_cycles.h>
#include <rte_prefetch.h>
#include <rte_lcore.h>
#include <rte_per_lcore.h>
#include <rte_branch_prediction.h>
#include <rte_interrupts.h>
#include <rte_random.h>
#include <rte_debug.h>
#include <rte_ether.h>
#include <rte_ethdev.h>
#include <rte_ring.h>
#include <rte_mempool.h>
#include <rte_mbuf.h>
#include <rte_string_fns.h>
#include <rte_ip.h>
#include <rte_tcp.h>
#include <rte_lpm.h>
#include "main.h"
static struct rte_eth_conf port_conf = {
.rxmode = {
.mq_mode = ETH_MQ_RX_RSS,
.split_hdr_size = 0,
.ignore_offload_bitfield = 1,
.offloads = (DEV_RX_OFFLOAD_CHECKSUM |
DEV_RX_OFFLOAD_CRC_STRIP),
},
.rx_adv_conf = {
.rss_conf = {
.rss_key = NULL,
.rss_hf = ETH_RSS_IP,
},
},
.txmode = {
.mq_mode = ETH_MQ_TX_NONE,
},
};
static void
app_assign_worker_ids(void)
{
uint32_t lcore, worker_id;
/* Assign ID for each worker */
worker_id = 0;
for (lcore = 0; lcore < APP_MAX_LCORES; lcore ++) {
struct app_lcore_params_worker *lp_worker = &app.lcore_params[lcore].worker;
if (app.lcore_params[lcore].type != e_APP_LCORE_WORKER) {
continue;
}
lp_worker->worker_id = worker_id;
worker_id ++;
}
}
static void
app_init_mbuf_pools(void)
{
unsigned socket, lcore;
/* Init the buffer pools */
for (socket = 0; socket < APP_MAX_SOCKETS; socket ++) {
char name[32];
if (app_is_socket_used(socket) == 0) {
continue;
}
snprintf(name, sizeof(name), "mbuf_pool_%u", socket);
printf("Creating the mbuf pool for socket %u ...\n", socket);
app.pools[socket] = rte_pktmbuf_pool_create(
name, APP_DEFAULT_MEMPOOL_BUFFERS,
APP_DEFAULT_MEMPOOL_CACHE_SIZE,
0, APP_DEFAULT_MBUF_DATA_SIZE, socket);
if (app.pools[socket] == NULL) {
rte_panic("Cannot create mbuf pool on socket %u\n", socket);
}
}
for (lcore = 0; lcore < APP_MAX_LCORES; lcore ++) {
if (app.lcore_params[lcore].type == e_APP_LCORE_DISABLED) {
continue;
}
socket = rte_lcore_to_socket_id(lcore);
app.lcore_params[lcore].pool = app.pools[socket];
}
}
static void
app_init_lpm_tables(void)
{
unsigned socket, lcore;
/* Init the LPM tables */
for (socket = 0; socket < APP_MAX_SOCKETS; socket ++) {
char name[32];
uint32_t rule;
if (app_is_socket_used(socket) == 0) {
continue;
}
struct rte_lpm_config lpm_config;
lpm_config.max_rules = APP_MAX_LPM_RULES;
lpm_config.number_tbl8s = 256;
lpm_config.flags = 0;
snprintf(name, sizeof(name), "lpm_table_%u", socket);
printf("Creating the LPM table for socket %u ...\n", socket);
app.lpm_tables[socket] = rte_lpm_create(
name,
socket,
&lpm_config);
if (app.lpm_tables[socket] == NULL) {
rte_panic("Unable to create LPM table on socket %u\n", socket);
}
for (rule = 0; rule < app.n_lpm_rules; rule ++) {
int ret;
ret = rte_lpm_add(app.lpm_tables[socket],
app.lpm_rules[rule].ip,
app.lpm_rules[rule].depth,
app.lpm_rules[rule].if_out);
if (ret < 0) {
rte_panic("Unable to add entry %u (%x/%u => %u) to the LPM table on socket %u (%d)\n",
(unsigned) rule,
(unsigned) app.lpm_rules[rule].ip,
(unsigned) app.lpm_rules[rule].depth,
(unsigned) app.lpm_rules[rule].if_out,
socket,
ret);
}
}
}
for (lcore = 0; lcore < APP_MAX_LCORES; lcore ++) {
if (app.lcore_params[lcore].type != e_APP_LCORE_WORKER) {
continue;
}
socket = rte_lcore_to_socket_id(lcore);
app.lcore_params[lcore].worker.lpm_table = app.lpm_tables[socket];
}
}
static void
app_init_rings_rx(void)
{
unsigned lcore;
/* Initialize the rings for the RX side */
for (lcore = 0; lcore < APP_MAX_LCORES; lcore ++) {
struct app_lcore_params_io *lp_io = &app.lcore_params[lcore].io;
unsigned socket_io, lcore_worker;
if ((app.lcore_params[lcore].type != e_APP_LCORE_IO) ||
(lp_io->rx.n_nic_queues == 0)) {
continue;
}
socket_io = rte_lcore_to_socket_id(lcore);
for (lcore_worker = 0; lcore_worker < APP_MAX_LCORES; lcore_worker ++) {
char name[32];
struct app_lcore_params_worker *lp_worker = &app.lcore_params[lcore_worker].worker;
struct rte_ring *ring = NULL;
if (app.lcore_params[lcore_worker].type != e_APP_LCORE_WORKER) {
continue;
}
printf("Creating ring to connect I/O lcore %u (socket %u) with worker lcore %u ...\n",
lcore,
socket_io,
lcore_worker);
snprintf(name, sizeof(name), "app_ring_rx_s%u_io%u_w%u",
socket_io,
lcore,
lcore_worker);
ring = rte_ring_create(
name,
app.ring_rx_size,
socket_io,
RING_F_SP_ENQ | RING_F_SC_DEQ);
if (ring == NULL) {
rte_panic("Cannot create ring to connect I/O core %u with worker core %u\n",
lcore,
lcore_worker);
}
lp_io->rx.rings[lp_io->rx.n_rings] = ring;
lp_io->rx.n_rings ++;
lp_worker->rings_in[lp_worker->n_rings_in] = ring;
lp_worker->n_rings_in ++;
}
}
for (lcore = 0; lcore < APP_MAX_LCORES; lcore ++) {
struct app_lcore_params_io *lp_io = &app.lcore_params[lcore].io;
if ((app.lcore_params[lcore].type != e_APP_LCORE_IO) ||
(lp_io->rx.n_nic_queues == 0)) {
continue;
}
if (lp_io->rx.n_rings != app_get_lcores_worker()) {
rte_panic("Algorithmic error (I/O RX rings)\n");
}
}
for (lcore = 0; lcore < APP_MAX_LCORES; lcore ++) {
struct app_lcore_params_worker *lp_worker = &app.lcore_params[lcore].worker;
if (app.lcore_params[lcore].type != e_APP_LCORE_WORKER) {
continue;
}
if (lp_worker->n_rings_in != app_get_lcores_io_rx()) {
rte_panic("Algorithmic error (worker input rings)\n");
}
}
}
static void
app_init_rings_tx(void)
{
unsigned lcore;
/* Initialize the rings for the TX side */
for (lcore = 0; lcore < APP_MAX_LCORES; lcore ++) {
struct app_lcore_params_worker *lp_worker = &app.lcore_params[lcore].worker;
unsigned port;
if (app.lcore_params[lcore].type != e_APP_LCORE_WORKER) {
continue;
}
for (port = 0; port < APP_MAX_NIC_PORTS; port ++) {
char name[32];
struct app_lcore_params_io *lp_io = NULL;
struct rte_ring *ring;
uint32_t socket_io, lcore_io;
if (app.nic_tx_port_mask[port] == 0) {
continue;
}
if (app_get_lcore_for_nic_tx(port, &lcore_io) < 0) {
rte_panic("Algorithmic error (no I/O core to handle TX of port %u)\n",
port);
}
lp_io = &app.lcore_params[lcore_io].io;
socket_io = rte_lcore_to_socket_id(lcore_io);
printf("Creating ring to connect worker lcore %u with TX port %u (through I/O lcore %u) (socket %u) ...\n",
lcore, port, (unsigned)lcore_io, (unsigned)socket_io);
snprintf(name, sizeof(name), "app_ring_tx_s%u_w%u_p%u", socket_io, lcore, port);
ring = rte_ring_create(
name,
app.ring_tx_size,
socket_io,
RING_F_SP_ENQ | RING_F_SC_DEQ);
if (ring == NULL) {
rte_panic("Cannot create ring to connect worker core %u with TX port %u\n",
lcore,
port);
}
lp_worker->rings_out[port] = ring;
lp_io->tx.rings[port][lp_worker->worker_id] = ring;
}
}
for (lcore = 0; lcore < APP_MAX_LCORES; lcore ++) {
struct app_lcore_params_io *lp_io = &app.lcore_params[lcore].io;
unsigned i;
if ((app.lcore_params[lcore].type != e_APP_LCORE_IO) ||
(lp_io->tx.n_nic_ports == 0)) {
continue;
}
for (i = 0; i < lp_io->tx.n_nic_ports; i ++){
unsigned port, j;
port = lp_io->tx.nic_ports[i];
for (j = 0; j < app_get_lcores_worker(); j ++) {
if (lp_io->tx.rings[port][j] == NULL) {
rte_panic("Algorithmic error (I/O TX rings)\n");
}
}
}
}
}
/* Check the link status of all ports in up to 9s, and print them finally */
static void
check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
{
#define CHECK_INTERVAL 100 /* 100ms */
#define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
uint16_t portid;
uint8_t count, all_ports_up, print_flag = 0;
struct rte_eth_link link;
uint32_t n_rx_queues, n_tx_queues;
printf("\nChecking link status");
fflush(stdout);
for (count = 0; count <= MAX_CHECK_TIME; count++) {
all_ports_up = 1;
for (portid = 0; portid < port_num; portid++) {
if ((port_mask & (1 << portid)) == 0)
continue;
n_rx_queues = app_get_nic_rx_queues_per_port(portid);
n_tx_queues = app.nic_tx_port_mask[portid];
if ((n_rx_queues == 0) && (n_tx_queues == 0))
continue;
memset(&link, 0, sizeof(link));
rte_eth_link_get_nowait(portid, &link);
/* print link status if flag set */
if (print_flag == 1) {
if (link.link_status)
printf(
"Port%d Link Up - speed %uMbps - %s\n",
portid, link.link_speed,
(link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
("full-duplex") : ("half-duplex\n"));
else
printf("Port %d Link Down\n", portid);
continue;
}
/* clear all_ports_up flag if any link down */
if (link.link_status == ETH_LINK_DOWN) {
all_ports_up = 0;
break;
}
}
/* after finally printing all link status, get out */
if (print_flag == 1)
break;
if (all_ports_up == 0) {
printf(".");
fflush(stdout);
rte_delay_ms(CHECK_INTERVAL);
}
/* set the print_flag if all ports up or timeout */
if (all_ports_up == 1 || count == (MAX_CHECK_TIME - 1)) {
print_flag = 1;
printf("done\n");
}
}
}
static void
app_init_nics(void)
{
unsigned socket;
uint32_t lcore;
uint16_t port;
uint8_t queue;
int ret;
uint32_t n_rx_queues, n_tx_queues;
/* Init NIC ports and queues, then start the ports */
for (port = 0; port < APP_MAX_NIC_PORTS; port ++) {
struct rte_mempool *pool;
uint16_t nic_rx_ring_size;
uint16_t nic_tx_ring_size;
struct rte_eth_rxconf rxq_conf;
struct rte_eth_txconf txq_conf;
struct rte_eth_dev_info dev_info;
struct rte_eth_conf local_port_conf = port_conf;
n_rx_queues = app_get_nic_rx_queues_per_port(port);
n_tx_queues = app.nic_tx_port_mask[port];
if ((n_rx_queues == 0) && (n_tx_queues == 0)) {
continue;
}
/* Init port */
printf("Initializing NIC port %u ...\n", port);
rte_eth_dev_info_get(port, &dev_info);
if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
local_port_conf.txmode.offloads |=
DEV_TX_OFFLOAD_MBUF_FAST_FREE;
ret = rte_eth_dev_configure(
port,
(uint8_t) n_rx_queues,
(uint8_t) n_tx_queues,
&local_port_conf);
if (ret < 0) {
rte_panic("Cannot init NIC port %u (%d)\n", port, ret);
}
rte_eth_promiscuous_enable(port);
nic_rx_ring_size = app.nic_rx_ring_size;
nic_tx_ring_size = app.nic_tx_ring_size;
ret = rte_eth_dev_adjust_nb_rx_tx_desc(
port, &nic_rx_ring_size, &nic_tx_ring_size);
if (ret < 0) {
rte_panic("Cannot adjust number of descriptors for port %u (%d)\n",
port, ret);
}
app.nic_rx_ring_size = nic_rx_ring_size;
app.nic_tx_ring_size = nic_tx_ring_size;
rxq_conf = dev_info.default_rxconf;
rxq_conf.offloads = local_port_conf.rxmode.offloads;
/* Init RX queues */
for (queue = 0; queue < APP_MAX_RX_QUEUES_PER_NIC_PORT; queue ++) {
if (app.nic_rx_queue_mask[port][queue] == 0) {
continue;
}
app_get_lcore_for_nic_rx(port, queue, &lcore);
socket = rte_lcore_to_socket_id(lcore);
pool = app.lcore_params[lcore].pool;
printf("Initializing NIC port %u RX queue %u ...\n",
port, queue);
ret = rte_eth_rx_queue_setup(
port,
queue,
(uint16_t) app.nic_rx_ring_size,
socket,
&rxq_conf,
pool);
if (ret < 0) {
rte_panic("Cannot init RX queue %u for port %u (%d)\n",
queue, port, ret);
}
}
txq_conf = dev_info.default_txconf;
txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
txq_conf.offloads = local_port_conf.txmode.offloads;
/* Init TX queues */
if (app.nic_tx_port_mask[port] == 1) {
app_get_lcore_for_nic_tx(port, &lcore);
socket = rte_lcore_to_socket_id(lcore);
printf("Initializing NIC port %u TX queue 0 ...\n",
port);
ret = rte_eth_tx_queue_setup(
port,
0,
(uint16_t) app.nic_tx_ring_size,
socket,
&txq_conf);
if (ret < 0) {
rte_panic("Cannot init TX queue 0 for port %d (%d)\n",
port,
ret);
}
}
/* Start port */
ret = rte_eth_dev_start(port);
if (ret < 0) {
rte_panic("Cannot start port %d (%d)\n", port, ret);
}
}
check_all_ports_link_status(APP_MAX_NIC_PORTS, (~0x0));
}
void
app_init(void)
{
app_assign_worker_ids();
app_init_mbuf_pools();
app_init_lpm_tables();
app_init_rings_rx();
app_init_rings_tx();
app_init_nics();
printf("Initialization completed.\n");
}
| 25.068359 | 110 | 0.671991 |
a5a21ed2473b525f474d74844e248e5d7f2bc9ba | 3,189 | h | C | lexer/lexer.h | skerys/Uni-CompilingMethods | e4357a0aea92960d202876920b3335a7a4c3ba3d | [
"MIT"
] | 5 | 2019-10-02T13:41:11.000Z | 2019-10-15T19:58:01.000Z | lexer/lexer.h | skerys/Uni-CompilingMethods | e4357a0aea92960d202876920b3335a7a4c3ba3d | [
"MIT"
] | null | null | null | lexer/lexer.h | skerys/Uni-CompilingMethods | e4357a0aea92960d202876920b3335a7a4c3ba3d | [
"MIT"
] | null | null | null | #pragma once
#include <string>
#include <map>
#include <variant>
#include <iostream>
#include <vector>
enum TokenType{
IDENT, LIT_BOOL, LIT_INT, LIT_FLOAT, LIT_STR, OP_PLUS, OP_INCREMENT, OP_MINUS, OP_DECREMENT, OP_L, OP_LE, OP_H, OP_HE, OP_ASSIGN, OP_E,
OP_PAREN_OPEN, OP_PAREN_CLOSE, OP_CB_OPEN, OP_CB_CLOSE, OP_SB_OPEN, OP_SB_CLOSE, OP_MULT, OP_DIV, OP_MOD, OP_LOGIC_AND, OP_LOGIC_OR, OP_LOGIC_NOT, OP_FIELD_ACCESS, OP_COMMA_SEP, OP_SEMICOLON_SEP, OP_NEWLINE_SEP,
KW_IF, KW_ELIF, KW_ELSE, KW_WHILE, KW_FOR, KW_RETURN, KW_BREAK, KW_NEXT, KW_READ, KW_WRITE, KW_CLASS, KW_PRIVATE, KW_PUBLIC, KW_FUNC, KW_INT, KW_FLOAT, KW_BOOL, KW_STRING, KW_VOID, KW_TRUE, KW_FALSE, NEWLINE, EOF_
};
const std::string TokenNames[] = {"IDENT", "LIT_BOOL", "LIT_INT", "LIT_FLOAT", "LIT_STR", "OP_PLUS", "OP_INCREMENT", "OP_MINUS", "OP_DECREMENT", "OP_L", "OP_LE", "OP_H", "OP_HE", "OP_ASSIGN", "OP_E",
"OP_PAREN_OPEN", "OP_PAREN_CLOSE", "OP_CB_OPEN", "OP_CB_CLOSE", "OP_SB_OPEN", "OP_SB_CLOSE", "OP_MULT", "OP_DIV", "OP_MOD", "OP_LOGIC_AND", "OP_LOGIC_OR", "OP_LOGIC_NOT",
"OP_FIELD_ACCESS", "OP_COMMA_SEP", "OP_SEMICOLON_SEP", "OP_NEWLINE_SEP",
"KW_IF", "KW_ELIF", "KW_ELSE", "KW_WHILE", "KW_FOR", "KW_RETURN", "KW_BREAK", "KW_NEXT", "KW_READ", "KW_WRITE", "KW_CLASS", "KW_PRIVATE", "KW_PUBLIC",
"KW_FUNC", "KW_INT", "KW_FLOAT", "KW_BOOL", "KW_STRING", "KW_VOID", "KW_TRUE", "KW_FALSE", "NEWLINE", "EOF"};
const std::map<std::string, TokenType> keywords = {
{"if", TokenType::KW_IF},
{"elif", TokenType::KW_ELIF},
{"else", TokenType::KW_ELSE},
{"while", TokenType::KW_WHILE},
{"for", TokenType::KW_FOR},
{"return", TokenType::KW_RETURN},
{"break", TokenType::KW_BREAK},
{"next", TokenType::KW_NEXT},
{"read", TokenType::KW_READ},
{"write", TokenType::KW_WRITE},
{"class", TokenType::KW_CLASS},
{"private", TokenType::KW_PRIVATE},
{"public", TokenType::KW_PUBLIC},
{"func", TokenType::KW_FUNC},
{"int", TokenType::KW_INT},
{"float", TokenType::KW_FLOAT},
{"bool", TokenType::KW_BOOL},
{"string", TokenType::KW_STRING},
{"void", TokenType::KW_VOID},
{"true", TokenType::KW_TRUE},
{"false", TokenType::KW_FALSE}
};
struct TokenValueVisitor
{
void operator()(int i) const {
std::cout << i;
}
void operator()(float f) const {
std::cout << f;
}
void operator()(const std::string& s) const {
std::cout << s;
}
};
struct Token{
int id;
TokenType type;
std::variant<int, float, std::string> value;
int line_no;
int column_no;
Token(){}
Token(TokenType _type, std::string _value, int _line_no) : type(_type), value(_value), line_no(_line_no) {}
};
std::vector<Token> lex_file(const char* path, bool printTokens);
enum State{
S_START, S_IDENT, S_LIT_INT, S_LIT_FLOAT, S_LIT_FLOAT_EXP_NEG, S_LIT_FLOAT_EXP, S_LIT_STR, S_ESCAPE_CHAR,
S_OP_PLUS, S_OP_MINUS, S_OP_LOW, S_OP_HIGH, S_OP_EQUAL, S_OP_OR, S_OP_AND, S_OP_DOT, S_OP_SLASH, S_COMMENT, S_MULTILINECOMMENT, S_MULTILINECOMMENT_EXIT
};
| 41.960526 | 217 | 0.648793 |
77699b181d1d6eedee4d7edc1c6657481ac4e061 | 550 | h | C | Alien Engine/Alien Engine/ComponentAudioListener.h | OverPowered-Team/Alien-GameEngine | 713a8846a95fdf253d0869bdcad4ecd006b2e166 | [
"MIT"
] | 7 | 2020-02-20T15:11:11.000Z | 2020-05-19T00:29:04.000Z | Alien Engine/Alien Engine/ComponentAudioListener.h | OverPowered-Team/Alien-GameEngine | 713a8846a95fdf253d0869bdcad4ecd006b2e166 | [
"MIT"
] | 125 | 2020-02-29T17:17:31.000Z | 2020-05-06T19:50:01.000Z | Alien Engine/Alien Engine/ComponentAudioListener.h | OverPowered-Team/Alien-GameEngine | 713a8846a95fdf253d0869bdcad4ecd006b2e166 | [
"MIT"
] | 1 | 2020-05-19T00:29:06.000Z | 2020-05-19T00:29:06.000Z | #pragma once
#include "Component.h"
#include "Globals.h"
#include "WwiseT.h"
class GameObject;
class ComponentAudioListener : public Component
{
public:
ComponentAudioListener(GameObject* parent);
~ComponentAudioListener();
void Update();
void UpdateListenerPos();
void Reset() override;
void OnEnable() override;
void OnDisable() override;
void SaveComponent(JSONArraypack* to_save) override;
void LoadComponent(JSONArraypack* to_load) override;
bool DrawInspector() override;
public:
WwiseT::AudioSource* listener = nullptr;
};
| 17.741935 | 53 | 0.765455 |
77cca8c95ffd30b7681b3a5386433781021b5e6c | 5,266 | c | C | winNativeHelper.c | Microeinstein/LuaNativeHelper | 6be01320face95eec104f8380b347b7c1fbc79f0 | [
"MIT"
] | 2 | 2018-10-04T23:05:42.000Z | 2021-12-06T04:05:19.000Z | winNativeHelper.c | Microeinstein/LuaNativeHelper | 6be01320face95eec104f8380b347b7c1fbc79f0 | [
"MIT"
] | null | null | null | winNativeHelper.c | Microeinstein/LuaNativeHelper | 6be01320face95eec104f8380b347b7c1fbc79f0 | [
"MIT"
] | null | null | null | //Native-code helper for Lua 5.3
//by Microeinstein
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"
#if defined(_MSC_VER)
//Microsoft
#define EXPORT __declspec(dllexport)
#define IMPORT __declspec(dllimport)
#elif defined(__GNUC__)
//GCC
#define EXPORT __attribute__((visibility("default")))
#define IMPORT
#else
#define EXPORT
#define IMPORT
#pragma warning Unknown dynamic link import/export semantics.
#endif
#define length(x) (sizeof(x) / sizeof((x)[0]))
typedef unsigned long long ulong;
typedef struct {
double s0, s1, s2, c;
int first;
} aleaData;
aleaData state;
int zfrs(int n, int s) {
if (s < 1)
return n;
n = n & 0x7FFFFFFF;
n = n >> s;
return n;
}
ulong getTick() {
SYSTEMTIME st;
FILETIME ft;
GetSystemTime(&st);
SystemTimeToFileTime(&st, &ft);
ulong res = (ulong)ft.dwHighDateTime;
res = res << (sizeof(DWORD) * 8);
res = res | ft.dwLowDateTime;
return res;
}
int clearAll() {
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD count;
DWORD cellCount;
COORD homeCoords = {0, 0};
if (hOut == INVALID_HANDLE_VALUE)
return 1;
if (!GetConsoleScreenBufferInfo(hOut, &csbi))
return 2;
cellCount = csbi.dwSize.X * csbi.dwSize.Y;
if (!FillConsoleOutputCharacter(hOut, (TCHAR)' ', cellCount, homeCoords, &count))
return 3;
if (!FillConsoleOutputAttribute(hOut, csbi.wAttributes, cellCount, homeCoords, &count))
return 4;
SetConsoleCursorPosition(hOut, homeCoords);
return 0;
}
int setCursor(int x, int y) {
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (hOut == INVALID_HANDLE_VALUE)
return 1;
COORD pos = {x, y};
SetConsoleCursorPosition(hOut, pos);
return 0;
}
int moveCursor(int x, int y) {
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO csbi;
if (hOut == INVALID_HANDLE_VALUE)
return 1;
if (!GetConsoleScreenBufferInfo(hOut, &csbi))
return 2;
COORD pos = csbi.dwCursorPosition;
pos.X += x;
pos.Y += y;
SetConsoleCursorPosition(hOut, pos);
return 0;
}
//Porting of the script obtained here: https://ss64.com/nt/syntax-random.html
double mash(const char *data, double **n) {
if (*n == NULL) {
*n = malloc(sizeof(double));
**n = 0xefc8249d;
}
double nn = **n;
for (int i = 0; data[i] != '\0'; i++) {
nn += (int)data[i];
double h = 0.02519603282416938 * nn;
nn = (int)h;
h -= nn;
h *= nn;
nn = (int)h;
h -= nn;
nn += h * 0x100000000L;
}
**n = nn;
return ((int)nn) * 2.3283064365386963e-10;
}
aleaData alea(const char *args[]) {
int len = length(args);
double s0, s1, s2;
double *n = NULL;
s0 = mash(" ", &n);
s1 = mash(" ", &n);
s2 = mash(" ", &n);
//printf("%lf\n%lf\n%lf\n\n", s0, s1, s2);
for (int i = 0; i < len; i++) {
s0 -= mash(args[i], &n);
if (s0 < 0)
s0 += 1;
s1 -= mash(args[i], &n);
if (s1 < 0)
s1 += 1;
s2 -= mash(args[i], &n);
if (s2 < 0)
s2 += 1;
}
free(n);
//printf("%lf\n%lf\n%lf\n\n", s0, s1, s2);
aleaData data = {s0, s1, s2, 1, 1};
return data;
}
double random(aleaData *data) {
double
s0 = data->s0,
s1 = data->s1,
s2 = data->s2,
c = data->c,
t;
int chk;
do {
t = 2091639 * s0 + c * 2.3283064365386963e-10;
s0 = s1;
s1 = s2;
c = (int)t;
s2 = t - c;
chk = s2 < 1e-7;
} while (data->first && chk);
data->s0 = s0;
data->s1 = s1;
data->s2 = s2;
data->c = c;
data->first = 0;
return s2;
}
int l_moveCursor(lua_State *L) {
int abs = (int)lua_toboolean(L, 1);
int x = (int)luaL_checknumber(L, 2);
int y = (int)luaL_checknumber(L, 3);
int ret;
if (abs) {
ret = setCursor(x, y);
} else {
ret = moveCursor(x, y);
}
if (ret != 0) {
lua_pushliteral(L, "winTermHelper: Internal error (move cursor)");
lua_error(L);
}
return 0;
}
int l_clearAll(lua_State *L) {
int ret = clearAll();
if (ret != 0) {
lua_pushliteral(L, "winTermHelper: Internal error (clear)");
lua_error(L);
}
return 0;
}
int l_timeTick(lua_State *L) {
ulong num = getTick();
lua_pushinteger(L, num);
return 1;
}
int l_random(lua_State *L) {
double num = random(&state);
lua_pushnumber(L, num);
return 1;
}
int EXPORT libinit(lua_State* L) {
ulong num = getTick();
char now[21];
sprintf(now, "%llu", num);
char to[15];
memcpy(to, now, 14);
to[15] = '\0';
const char *args[1] = { to };
state = alea(args);
//Ind(ic|ex)es starts at 1... damn lua
//1 (first element pushed), 2, 3...
lua_newtable(L);
lua_pushstring(L, "moveCursor");
lua_pushcfunction(L, l_moveCursor);
lua_settable(L, 1);
lua_pushstring(L, "clearAll");
lua_pushcfunction(L, l_clearAll);
lua_settable(L, 1);
lua_pushstring(L, "timeTick");
lua_pushcfunction(L, l_timeTick);
lua_settable(L, 1);
lua_pushstring(L, "random");
lua_pushcfunction(L, l_random);
lua_settable(L, 1);
lua_setglobal(L, "nativeHelper");
//lua_register(L, "wth_moveCursor", l_moveCursor);
//lua_register(L, "wth_clearAll", l_clearAll);
return 0;
} | 21.319838 | 89 | 0.604064 |
a05d37fed31b7bec963cff2d542d38802c35ede2 | 1,027 | h | C | include/gpu/GrSurfaceContext.h | vvuk/skia-1 | 59ed482af72beec6812b28d833d8bdf80ba32df7 | [
"BSD-3-Clause"
] | 1 | 2021-01-07T18:51:25.000Z | 2021-01-07T18:51:25.000Z | include/gpu/GrSurfaceContext.h | emilio/skia-1 | 59ed482af72beec6812b28d833d8bdf80ba32df7 | [
"BSD-3-Clause"
] | null | null | null | include/gpu/GrSurfaceContext.h | emilio/skia-1 | 59ed482af72beec6812b28d833d8bdf80ba32df7 | [
"BSD-3-Clause"
] | 1 | 2016-12-09T03:19:09.000Z | 2016-12-09T03:19:09.000Z | /*
* Copyright 2016 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef GrSurfaceContext_DEFINED
#define GrSurfaceContext_DEFINED
#include "SkRefCnt.h"
class GrAuditTrail;
class GrContext;
class GrSingleOwner;
class GrSurface;
struct SkIPoint;
struct SkIRect;
/**
* A helper object to orchestrate commands for a particular surface
*/
class SK_API GrSurfaceContext : public SkRefCnt {
public:
~GrSurfaceContext() override {}
virtual bool copySurface(GrSurface* src, const SkIRect& srcRect, const SkIPoint& dstPoint) = 0;
GrAuditTrail* auditTrail() { return fAuditTrail; }
protected:
GrSurfaceContext(GrContext*, GrAuditTrail*, GrSingleOwner*);
SkDEBUGCODE(GrSingleOwner* singleOwner() { return fSingleOwner; })
GrContext* fContext;
GrAuditTrail* fAuditTrail;
// In debug builds we guard against improper thread handling
SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;)
};
#endif
| 23.340909 | 99 | 0.734177 |
e2930e49b8bed3e3634beba1933bdf80698b9679 | 371 | h | C | XibaWeibo/XibaWeibo/XBStatusTableViewCell.h | daomul/AxibaWeibo | e3dc9f1a9dd4c33e2573bed7a098cd73296401d9 | [
"Apache-2.0"
] | null | null | null | XibaWeibo/XibaWeibo/XBStatusTableViewCell.h | daomul/AxibaWeibo | e3dc9f1a9dd4c33e2573bed7a098cd73296401d9 | [
"Apache-2.0"
] | null | null | null | XibaWeibo/XibaWeibo/XBStatusTableViewCell.h | daomul/AxibaWeibo | e3dc9f1a9dd4c33e2573bed7a098cd73296401d9 | [
"Apache-2.0"
] | null | null | null | //
// XBStatusTableViewCell.h
// XibaWeibo
//
// Created by K3CLOUDBOS on 15/8/2.
// Copyright (c) 2015年 axiba. All rights reserved.
//
#import <UIKit/UIKit.h>
@class XBStatusFrameModel;
@interface XBStatusTableViewCell : UITableViewCell
+(instancetype)cellWithTableView:(UITableView *)tableView;
@property (nonatomic,strong)XBStatusFrameModel *statusFrame;
@end
| 20.611111 | 60 | 0.760108 |
e2df111fa5658c780c7afb7a601a56bdad9a920f | 1,113 | h | C | DOS-Starter-Demo/controller.h | ttuna/m2qt | 614cc86765ccb2e096bf2bfbe12d03e311ec657f | [
"MIT"
] | null | null | null | DOS-Starter-Demo/controller.h | ttuna/m2qt | 614cc86765ccb2e096bf2bfbe12d03e311ec657f | [
"MIT"
] | null | null | null | DOS-Starter-Demo/controller.h | ttuna/m2qt | 614cc86765ccb2e096bf2bfbe12d03e311ec657f | [
"MIT"
] | null | null | null | #ifndef CONTROLLER_H
#define CONTROLLER_H
#include <QObject>
#include <QVariant>
#include <QVector>
#include <QMap>
#include <QDir>
#include <QSharedPointer>
#include "global.h"
class DriveStarter;
namespace M2QT {
class IM2Qt;
class SignalAgent;
}
class Controller final : public QObject
{
Q_OBJECT
public:
explicit Controller(QObject *parent = 0);
~Controller();
bool init(const QVariantMap& in_params);
void cleanup();
bool update(const QVariantMap& in_params);
bool isValid() const;
signals:
public slots:
bool createHandler(const QString &in_name, const QVariantMap &in_params);
void start();
void stop();
private slots:
void slotError(QString in_msg);
void slotWarning(QString in_msg);
void slotDebug(QString in_msg);
void slotInfo(QString in_msg);
void printMessage(const QString &in_msg);
private:
bool m_initialized = false;
M2QT::IM2Qt* m_p_m2qt;
M2QT::SignalAgent* m_p_signal_agent = nullptr;
QVector<QString> m_handler_names;
};
#endif // CONTROLLER_H
| 20.611111 | 78 | 0.67655 |
1252b45face162d02b6d553429475786055503ab | 1,096 | h | C | linux-2.6.16-unmod/include/linux/pm_legacy.h | ut-osa/syncchar | eba20da163260b6ae1ef3e334ad2137873a8d625 | [
"BSD-3-Clause"
] | null | null | null | linux-2.6.16-unmod/include/linux/pm_legacy.h | ut-osa/syncchar | eba20da163260b6ae1ef3e334ad2137873a8d625 | [
"BSD-3-Clause"
] | null | null | null | linux-2.6.16-unmod/include/linux/pm_legacy.h | ut-osa/syncchar | eba20da163260b6ae1ef3e334ad2137873a8d625 | [
"BSD-3-Clause"
] | 1 | 2019-05-14T16:36:45.000Z | 2019-05-14T16:36:45.000Z | #ifndef __LINUX_PM_LEGACY_H__
#define __LINUX_PM_LEGACY_H__
#include <linux/config.h>
#ifdef CONFIG_PM_LEGACY
extern int pm_active;
#define PM_IS_ACTIVE() (pm_active != 0)
/*
* Register a device with power management
*/
struct pm_dev __deprecated *
pm_register(pm_dev_t type, unsigned long id, pm_callback callback);
/*
* Unregister a device with power management
*/
void __deprecated pm_unregister(struct pm_dev *dev);
/*
* Unregister all devices with matching callback
*/
void __deprecated pm_unregister_all(pm_callback callback);
/*
* Send a request to all devices
*/
int __deprecated pm_send_all(pm_request_t rqst, void *data);
#else /* CONFIG_PM_LEGACY */
#define PM_IS_ACTIVE() 0
static inline struct pm_dev *pm_register(pm_dev_t type,
unsigned long id,
pm_callback callback)
{
return NULL;
}
static inline void pm_unregister(struct pm_dev *dev) {}
static inline void pm_unregister_all(pm_callback callback) {}
static inline int pm_send_all(pm_request_t rqst, void *data)
{
return 0;
}
#endif /* CONFIG_PM_LEGACY */
#endif /* __LINUX_PM_LEGACY_H__ */
| 19.22807 | 67 | 0.756387 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.