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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1ff8aed66400dce4dc5f55887429e5c13c6bec3c | 280 | h | C | Example/MWTableViewCellSeparatorLine/MWAppDelegate.h | mw202/MWTableViewCellSeparatorLine | ebaad4e75f80b7fb501f9b42b862c195da9a4d62 | [
"MIT"
] | null | null | null | Example/MWTableViewCellSeparatorLine/MWAppDelegate.h | mw202/MWTableViewCellSeparatorLine | ebaad4e75f80b7fb501f9b42b862c195da9a4d62 | [
"MIT"
] | null | null | null | Example/MWTableViewCellSeparatorLine/MWAppDelegate.h | mw202/MWTableViewCellSeparatorLine | ebaad4e75f80b7fb501f9b42b862c195da9a4d62 | [
"MIT"
] | null | null | null | //
// MWAppDelegate.h
// MWTableViewCellSeparatorLine
//
// Created by LiY on 03/10/2022.
// Copyright (c) 2022 LiY. All rights reserved.
//
@import UIKit;
@interface MWAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
| 17.5 | 62 | 0.725 |
4ec63a2d29ac538666b57d13f926ab077e421a8d | 446 | h | C | testAssemblyAttributes/stdafx.h | casaletto/alby.assemblyShellExtension | e051f9179aae4ece950cd09c590b60f11cc9e844 | [
"MIT"
] | null | null | null | testAssemblyAttributes/stdafx.h | casaletto/alby.assemblyShellExtension | e051f9179aae4ece950cd09c590b60f11cc9e844 | [
"MIT"
] | null | null | null | testAssemblyAttributes/stdafx.h | casaletto/alby.assemblyShellExtension | e051f9179aae4ece950cd09c590b60f11cc9e844 | [
"MIT"
] | 1 | 2020-10-02T01:33:45.000Z | 2020-10-02T01:33:45.000Z | #pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include <io.h>
#include <fcntl.h>
#include <windows.h>
#include <comdef.h>
#include <atlbase.h>
#include <atlconv.h>
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <clocale>
#include <locale>
#include <codecvt>
#include <fstream>
#include <map>
#include <iomanip>
#include <ctime>
#include <algorithm>
| 15.928571 | 23 | 0.665919 |
e2fdb3b8f15a92e2e147266c7a52925a20169eca | 2,767 | h | C | test/performance-regression/full-apps/qmcpack/src/Estimators/LocalEnergyEstimatorHDF.h | FeiyangJin/hclib | d23c850dce914e2d80cae733670820812a1edeee | [
"BSD-3-Clause"
] | 55 | 2015-07-28T01:32:58.000Z | 2022-02-27T16:27:46.000Z | test/performance-regression/full-apps/qmcpack/src/Estimators/LocalEnergyEstimatorHDF.h | FeiyangJin/hclib | d23c850dce914e2d80cae733670820812a1edeee | [
"BSD-3-Clause"
] | 66 | 2015-06-15T20:38:19.000Z | 2020-08-26T00:11:43.000Z | test/performance-regression/full-apps/qmcpack/src/Estimators/LocalEnergyEstimatorHDF.h | FeiyangJin/hclib | d23c850dce914e2d80cae733670820812a1edeee | [
"BSD-3-Clause"
] | 26 | 2015-10-26T22:11:51.000Z | 2021-03-02T22:09:15.000Z | //////////////////////////////////////////////////////////////////
// (c) Copyright 2003- by Jeongnim Kim
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// Jeongnim Kim
// National Center for Supercomputing Applications &
// Materials Computation Center
// University of Illinois, Urbana-Champaign
// Urbana, IL 61801
// e-mail: jnkim@ncsa.uiuc.edu
//
// Supported by
// National Center for Supercomputing Applications, UIUC
// Materials Computation Center, UIUC
//////////////////////////////////////////////////////////////////
// -*- C++ -*-
#ifndef QMCPLUSPLUS_LOCALENERGYESTIMATOR_HDF_H
#define QMCPLUSPLUS_LOCALENERGYESTIMATOR_HDF_H
#include <Estimators/ScalarEstimatorBase.h>
#include <QMCHamiltonians/QMCHamiltonian.h>
#include <QMCHamiltonians/observable_helper.h>
namespace qmcplusplus
{
/** Handle an ensemble average of Hamiltonian components
*/
class LocalEnergyEstimatorHDF: public ScalarEstimatorBase
{
//typedef PooledData<T> BufferType;
//enum {ENERGY_INDEX, ENERGY_SQ_INDEX, POTENTIAL_INDEX, LE_MAX};
enum {ENERGY_INDEX, POTENTIAL_INDEX, LE_MAX};
//int LocalPotentialIndex;
int FirstHamiltonian;
int SizeOfHamiltonians;
///save the reference hamiltonian
const QMCHamiltonian& refH;
public:
/** constructor
* @param h QMCHamiltonian to define the components
*/
LocalEnergyEstimatorHDF(QMCHamiltonian& h);
inline void accumulate(const Walker_t& awalker, RealType wgt)
{
const RealType* restrict ePtr = awalker.getPropertyBase();
//weight of observables should take into account the walkers weight. For Pure DMC. In branching DMC set weights to 1.
RealType wwght= wgt* awalker.Weight;
// RealType wwght= wgt;
scalars[0](ePtr[LOCALENERGY],wwght);
scalars[1](ePtr[LOCALPOTENTIAL],wwght);
for(int target=2, source=FirstHamiltonian; target<scalars.size();
++target, ++source)
scalars[target](ePtr[source],wwght);
}
/*@{*/
inline void accumulate(const MCWalkerConfiguration& W
, WalkerIterator first, WalkerIterator last, RealType wgt)
{
for(; first!=last; ++first)
accumulate(**first,wgt);
}
void add2Record(RecordListType& record);
void registerObservables(vector<observable_helper*>& h5dec, hid_t gid);
ScalarEstimatorBase* clone();
/*@}*/
};
}
#endif
/***************************************************************************
* $RCSfile$ $Author: mcminis2 $
* $Revision: 3421 $ $Date: 2008-12-09 10:21:11 -0600 (Tue, 09 Dec 2008) $
* $Id: LocalEnergyEstimatorHDF.h 3421 2008-12-09 16:21:11Z mcminis2 $
***************************************************************************/
| 34.160494 | 121 | 0.603542 |
e8f36c2d14a5981481eb143e76eae0964144bece | 2,426 | h | C | build/ImageMagick-7.1.0-2/IMDelegates/ghostscript-9.54.0/cups/libs/cups/sspi-private.h | roMummy/imagemagick_lib_ios | 0e0e6fa77e06b471f5019d5b1b28caabd08d5e6a | [
"ImageMagick"
] | null | null | null | build/ImageMagick-7.1.0-2/IMDelegates/ghostscript-9.54.0/cups/libs/cups/sspi-private.h | roMummy/imagemagick_lib_ios | 0e0e6fa77e06b471f5019d5b1b28caabd08d5e6a | [
"ImageMagick"
] | null | null | null | build/ImageMagick-7.1.0-2/IMDelegates/ghostscript-9.54.0/cups/libs/cups/sspi-private.h | roMummy/imagemagick_lib_ios | 0e0e6fa77e06b471f5019d5b1b28caabd08d5e6a | [
"ImageMagick"
] | null | null | null | /*
* Private SSPI definitions for CUPS.
*
* Copyright 2010 by Apple Inc.
*
* These coded instructions, statements, and computer programs are the
* property of Apple Inc. and are protected by Federal copyright
* law. Distribution and use rights are outlined in the file "LICENSE.txt"
* which should have been included with this file. If this file is
* file is missing or damaged, see the license at "http://www.cups.org/".
*/
#ifndef _CUPS_SSPI_PRIVATE_H_
# define _CUPS_SSPI_PRIVATE_H_
/*
* Include necessary headers...
*/
# include <config.h>
# include <winsock2.h>
# include <ws2tcpip.h>
# include <wincrypt.h>
# include <wintrust.h>
# include <schannel.h>
# define SECURITY_WIN32
# include <security.h>
# include <sspi.h>
/*
* C++ magic...
*/
# ifdef __cplusplus
extern "C" {
# endif /* __cplusplus */
typedef struct /**** SSPI/SSL data structure ****/
{
SOCKET sock; /* TCP/IP socket */
CredHandle creds; /* Credentials */
CtxtHandle context; /* SSL context */
BOOL contextInitialized; /* Is context init'd? */
SecPkgContext_StreamSizes streamSizes; /* SSL data stream sizes */
BYTE *decryptBuffer; /* Data pre-decryption*/
size_t decryptBufferLength; /* Length of decrypt buffer */
size_t decryptBufferUsed; /* Bytes used in buffer */
BYTE *readBuffer; /* Data post-decryption */
size_t readBufferLength; /* Length of read buffer */
size_t readBufferUsed; /* Bytes used in buffer */
DWORD certFlags; /* Cert verification flags */
} _sspi_struct_t;
/*
* Prototypes...
*/
_sspi_struct_t *_sspiAlloc(void);
BOOL _sspiAccept(_sspi_struct_t *conn);
BOOL _sspiConnect(_sspi_struct_t *conn,
const CHAR *hostname);
void _sspiFree(_sspi_struct_t *conn);
BOOL _sspiGetCredentials(_sspi_struct_t *conn,
const LPWSTR containerName,
const TCHAR *commonName,
BOOL server);
int _sspiPending(_sspi_struct_t *conn);
int _sspiRead(_sspi_struct_t *conn,
void *buf, size_t len);
void _sspiSetAllowsAnyRoot(_sspi_struct_t *conn,
BOOL allow);
void _sspiSetAllowsExpiredCerts(_sspi_struct_t *conn,
BOOL allow);
int _sspiWrite(_sspi_struct_t *conn,
void *buf, size_t len);
# ifdef __cplusplus
}
# endif /* __cplusplus */
#endif /* !_CUPS_SSPI_PRIVATE_H_ */
| 29.228916 | 77 | 0.65911 |
053df636608d19f23e489d15234c2dc1a000e1e1 | 642 | c | C | 期末考试编程题:7-1 还原二叉树.c | Yuri0314/PTA-mooc | 9d493a799463e3531a4e435dd04e8352b7136981 | [
"MIT"
] | 78 | 2020-04-26T15:32:03.000Z | 2022-03-18T12:43:14.000Z | 期末考试编程题:7-1 还原二叉树.c | Yuri0314/PTA-mooc | 9d493a799463e3531a4e435dd04e8352b7136981 | [
"MIT"
] | 1 | 2021-02-24T08:18:43.000Z | 2021-03-20T14:20:01.000Z | 期末考试编程题:7-1 还原二叉树.c | Yuri0314/PTA-mooc | 9d493a799463e3531a4e435dd04e8352b7136981 | [
"MIT"
] | 27 | 2020-04-27T09:21:18.000Z | 2022-01-06T14:24:42.000Z | #include <stdio.h>
#include <stdlib.h>
#define MAXN 50
int GetHeight(char *a, char *b, int len); // 获取树的最大高度
int main()
{
int n;
char arr1[MAXN + 1], arr2[MAXN + 1];
scanf("%d", &n);
scanf("%s\n%s", arr1, arr2);
printf("%d", GetHeight(arr1, arr2, n));
return 0;
}
int GetHeight(char *a, char *b, int len)
{
int i, leftH, rightH;
if (len == 0) return 0;
else {
for (i = 0; i < len; ++i)
if (b[i] == a[0]) break;
leftH = GetHeight(a + 1, b, i) + 1;
rightH = GetHeight(a + 1 + i, b + 1 + i, len - i - 1) + 1;
return leftH > rightH ? leftH : rightH;
}
}
| 20.0625 | 66 | 0.495327 |
05a3bda7f767a0515290e19d27759b459f3e333b | 1,306 | h | C | server/PushServer.h | damaex/ownPush | 407e632c5e7983bcd9dae9efb8dc1eccdf60657d | [
"MIT"
] | null | null | null | server/PushServer.h | damaex/ownPush | 407e632c5e7983bcd9dae9efb8dc1eccdf60657d | [
"MIT"
] | null | null | null | server/PushServer.h | damaex/ownPush | 407e632c5e7983bcd9dae9efb8dc1eccdf60657d | [
"MIT"
] | null | null | null | #ifndef OWNPUSH_SERVER_H
#define OWNPUSH_SERVER_H
#include "Client.h"
#include "RestServer.h"
#include "ConnectionObject.h"
#include "ChallengeHandler.h"
constexpr auto OWNPUSH_PORT = 7951;
class PushServer : public IHandler, public std::enable_shared_from_this<IHandler> {
private:
Settings p_settings;
asio::ip::tcp::acceptor p_acceptor;
asio::ssl::context ssl_context;
std::shared_ptr<ILog> p_log;
std::vector<std::shared_ptr<Client>> p_clientList;
std::shared_ptr<RestServer> p_restServer;
ChallengeHandler p_challengeHandler;
void doAccept();
void removeClient(std::shared_ptr<IClient> cl) override;
void handleIncoming(std::shared_ptr<IClient> cl, const ConnectionObject &co);
void sendData(std::shared_ptr<IClient> cl, const ConnectionObject &co);
public:
explicit PushServer(asio::io_context &io_context, std::shared_ptr<ILog> log, std::shared_ptr<IUserProvider> userProvider);
void start();
void stop();
void incomingPushData(std::shared_ptr<IClient> cl, const std::string &data) override;
std::set<std::string> getConnectedClients() override;
bool checkConnectedClient(const std::string &id) override;
bool pushMessage(const std::string &id, const std::string &message) override;
};
#endif //OWNPUSH_SERVER_H
| 28.391304 | 126 | 0.742726 |
95855017a32b23a972a4504fcf51f75116cb3473 | 914 | h | C | include/keys/encrypted-type.h | tuxafgmur/OLD_Dhollmen_Kernel | 90ed4e2e3e6321de246fa193705ae40ede4e2d8e | [
"BSD-Source-Code"
] | 4 | 2016-07-01T04:50:02.000Z | 2021-11-14T21:29:42.000Z | include/keys/encrypted-type.h | tuxafgmur/OLD_Dhollmen_Kernel | 90ed4e2e3e6321de246fa193705ae40ede4e2d8e | [
"BSD-Source-Code"
] | null | null | null | include/keys/encrypted-type.h | tuxafgmur/OLD_Dhollmen_Kernel | 90ed4e2e3e6321de246fa193705ae40ede4e2d8e | [
"BSD-Source-Code"
] | 1 | 2020-04-03T14:00:39.000Z | 2020-04-03T14:00:39.000Z | /*
* Copyright (C) 2010 IBM Corporation
* Author: Mimi Zohar <zohar@us.ibm.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2 of the License.
*/
#ifndef _KEYS_ENCRYPTED_TYPE_H
#define _KEYS_ENCRYPTED_TYPE_H
#include <linux/key.h>
#include <linux/rcupdate.h>
struct encrypted_key_payload {
struct rcu_head rcu;
char *master_desc; /* datablob: master key name */
char *datalen; /* datablob: decrypted key length */
u8 *iv; /* datablob: iv */
u8 *encrypted_data; /* datablob: encrypted data */
unsigned short datablob_len; /* length of datablob */
unsigned short decrypted_datalen; /* decrypted data length */
u8 decrypted_data[0]; /* decrypted data + datablob + hmac */
};
extern struct key_type key_type_encrypted;
#endif /* _KEYS_ENCRYPTED_TYPE_H */
| 30.466667 | 71 | 0.734136 |
195ec00d5a4d89c58a1a56f3276d3287126a00a2 | 580 | h | C | shf-cpp/src/Game/Menu/Dialog.h | Upwinded/SHF | 797682152234251c9a32692324904c7aa8d90683 | [
"Zlib"
] | 71 | 2018-03-21T08:04:04.000Z | 2022-01-11T09:49:26.000Z | shf-cpp/src/Game/Menu/Dialog.h | Upwinded/SHF | 797682152234251c9a32692324904c7aa8d90683 | [
"Zlib"
] | 2 | 2018-08-28T08:26:02.000Z | 2019-04-06T14:29:39.000Z | shf-cpp/src/Game/Menu/Dialog.h | Upwinded/SHF | 797682152234251c9a32692324904c7aa8d90683 | [
"Zlib"
] | 25 | 2018-03-24T03:36:28.000Z | 2021-09-20T06:19:09.000Z | #pragma once
#include "../../Component/Component.h"
#include "../GameTypes.h"
class Dialog :
public Panel
{
public:
Dialog();
~Dialog();
ImageContainer * head1 = NULL;
ImageContainer * head2 = NULL;
TalkLabel * label = NULL;
int talkStrLen = 60;
int talkIndex = 0;
std::vector<TalkString> talkStr = {};
void init();
void setTalkStr(const std::wstring & wstr);
void setHead1(const std::string & fileName);
void setHead2(const std::string & fileName);
private:
virtual void freeResource();
virtual void onEvent();
virtual bool onHandleEvent(AEvent * e);
};
| 17.058824 | 45 | 0.687931 |
bf5d32f27cb42608a2ab49eefa3648616e856100 | 299 | h | C | src/warnings.h | Refuge89/CreatureScripter | 37a66ba2763bf6a48271577dd5ca6bb363f23948 | [
"MIT"
] | null | null | null | src/warnings.h | Refuge89/CreatureScripter | 37a66ba2763bf6a48271577dd5ca6bb363f23948 | [
"MIT"
] | null | null | null | src/warnings.h | Refuge89/CreatureScripter | 37a66ba2763bf6a48271577dd5ca6bb363f23948 | [
"MIT"
] | 1 | 2020-03-14T12:12:55.000Z | 2020-03-14T12:12:55.000Z | #ifndef WARNINGS_H
#define WARNINGS_H
#include <QMessageBox>
class Warnings
{
public:
static void Warning(QString warn,QMessageBox::Icon severity = QMessageBox::Warning);
static QString confirmBox(const QString &text, const QStringList &opts, QWidget *parent);
};
#endif // WARNINGS_H
| 17.588235 | 93 | 0.752508 |
db4ca241cb02356ce224adcd0ab895e44c93dd6a | 759 | h | C | firmware/main/tmc_driver.h | matthewlai/ESP32Stepper | daab2e9fe6a2cf8cfd7e39511d57c52c71dd1c8d | [
"Apache-2.0"
] | 2 | 2022-01-15T18:56:55.000Z | 2022-01-21T07:05:47.000Z | firmware/main/tmc_driver.h | matthewlai/ESP32Stepper | daab2e9fe6a2cf8cfd7e39511d57c52c71dd1c8d | [
"Apache-2.0"
] | null | null | null | firmware/main/tmc_driver.h | matthewlai/ESP32Stepper | daab2e9fe6a2cf8cfd7e39511d57c52c71dd1c8d | [
"Apache-2.0"
] | null | null | null | #ifndef TMC_DRIVER_H
#define TMC_DRIVER_H
class TMCDriver {
public:
virtual void Begin() = 0;
virtual void Stop() = 0;
virtual void SetMotorCurrent(float new_current_setting) = 0;
virtual uint32_t ReadStallGuardValue() = 0;
virtual void SetStallGuardFiltering(bool filter_on) = 0;
virtual void SetStallGuardThreshold(int8_t threshold) = 0;
virtual int StepsPerRev() = 0;
virtual void PrintDebugInfo() {}
// The default implementation of this function uses instantaneous
// StallGuard reading, but a better driver can have a latching flag
// that is set if stall is detected any time since the last clear.
virtual bool IsStalled() { return ReadStallGuardValue() == 0; }
virtual void ClearStallFlag() {}
};
#endif // TMC_DRIVER_H
| 33 | 69 | 0.743083 |
71bb98cc0e397c082d748c77b23e8e23e5c073d7 | 186 | h | C | include/bmp/playerexplodebmp.h | ant512/EarthShakerDS | c23920bb96652570616059ee4b807e82617c2385 | [
"MIT"
] | null | null | null | include/bmp/playerexplodebmp.h | ant512/EarthShakerDS | c23920bb96652570616059ee4b807e82617c2385 | [
"MIT"
] | null | null | null | include/bmp/playerexplodebmp.h | ant512/EarthShakerDS | c23920bb96652570616059ee4b807e82617c2385 | [
"MIT"
] | null | null | null | #ifndef _PLAYEREXPLODEBMP_H_
#define _PLAYEREXPLODEBMP_H_
#include <bitmapwrapper.h>
class PlayerExplodeBmp : public WoopsiGfx::BitmapWrapper {
public:
PlayerExplodeBmp();
};
#endif
| 15.5 | 58 | 0.801075 |
807c955e032b3c47607af1dd4adcf77fbdf66c2a | 6,120 | h | C | src/tools/dev/diagnostics/networktest/BGQ/vulcanio.h | visit-dav/vis | c08bc6e538ecd7d30ddc6399ec3022b9e062127e | [
"BSD-3-Clause"
] | 226 | 2018-12-29T01:13:49.000Z | 2022-03-30T19:16:31.000Z | src/tools/dev/diagnostics/networktest/BGQ/vulcanio.h | visit-dav/vis | c08bc6e538ecd7d30ddc6399ec3022b9e062127e | [
"BSD-3-Clause"
] | 5,100 | 2019-01-14T18:19:25.000Z | 2022-03-31T23:08:36.000Z | src/tools/dev/diagnostics/networktest/BGQ/vulcanio.h | visit-dav/vis | c08bc6e538ecd7d30ddc6399ec3022b9e062127e | [
"BSD-3-Clause"
] | 84 | 2019-01-24T17:41:50.000Z | 2022-03-10T10:01:46.000Z | "172.20.17.1", /*vulcanio1*/
"172.20.17.2", /*vulcanio2*/
"172.20.17.3", /*vulcanio3*/
"172.20.17.4", /*vulcanio4*/
"172.20.17.5", /*vulcanio5*/
"172.20.17.6", /*vulcanio6*/
"172.20.17.7", /*vulcanio7*/
"172.20.17.8", /*vulcanio8*/
"172.20.17.9", /*vulcanio9*/
"172.20.17.10", /*vulcanio10*/
"172.20.17.11", /*vulcanio11*/
"172.20.17.12", /*vulcanio12*/
"172.20.17.13", /*vulcanio13*/
"172.20.17.14", /*vulcanio14*/
"172.20.17.15", /*vulcanio15*/
"172.20.17.16", /*vulcanio16*/
"172.20.17.17", /*vulcanio17*/
"172.20.17.18", /*vulcanio18*/
"172.20.17.19", /*vulcanio19*/
"172.20.17.20", /*vulcanio20*/
"172.20.17.21", /*vulcanio21*/
"172.20.17.22", /*vulcanio22*/
"172.20.17.23", /*vulcanio23*/
"172.20.17.24", /*vulcanio24*/
"172.20.17.25", /*vulcanio25*/
"172.20.17.26", /*vulcanio26*/
"172.20.17.27", /*vulcanio27*/
"172.20.17.28", /*vulcanio28*/
"172.20.17.29", /*vulcanio29*/
"172.20.17.30", /*vulcanio30*/
"172.20.17.31", /*vulcanio31*/
"172.20.17.32", /*vulcanio32*/
"172.20.17.33", /*vulcanio33*/
"172.20.17.34", /*vulcanio34*/
"172.20.17.35", /*vulcanio35*/
"172.20.17.36", /*vulcanio36*/
"172.20.17.37", /*vulcanio37*/
"172.20.17.38", /*vulcanio38*/
"172.20.17.39", /*vulcanio39*/
"172.20.17.40", /*vulcanio40*/
"172.20.17.41", /*vulcanio41*/
"172.20.17.42", /*vulcanio42*/
"172.20.17.43", /*vulcanio43*/
"172.20.17.44", /*vulcanio44*/
"172.20.17.45", /*vulcanio45*/
"172.20.17.46", /*vulcanio46*/
"172.20.17.47", /*vulcanio47*/
"172.20.17.48", /*vulcanio48*/
"172.20.17.49", /*vulcanio49*/
"172.20.17.50", /*vulcanio50*/
"172.20.17.51", /*vulcanio51*/
"172.20.17.52", /*vulcanio52*/
"172.20.17.53", /*vulcanio53*/
"172.20.17.54", /*vulcanio54*/
"172.20.17.55", /*vulcanio55*/
"172.20.17.56", /*vulcanio56*/
"172.20.17.57", /*vulcanio57*/
"172.20.17.58", /*vulcanio58*/
"172.20.17.59", /*vulcanio59*/
"172.20.17.60", /*vulcanio60*/
"172.20.17.61", /*vulcanio61*/
"172.20.17.62", /*vulcanio62*/
"172.20.17.63", /*vulcanio63*/
"172.20.17.64", /*vulcanio64*/
"172.20.17.65", /*vulcanio65*/
"172.20.17.66", /*vulcanio66*/
"172.20.17.67", /*vulcanio67*/
"172.20.17.68", /*vulcanio68*/
"172.20.17.69", /*vulcanio69*/
"172.20.17.70", /*vulcanio70*/
"172.20.17.71", /*vulcanio71*/
"172.20.17.72", /*vulcanio72*/
"172.20.17.73", /*vulcanio73*/
"172.20.17.74", /*vulcanio74*/
"172.20.17.75", /*vulcanio75*/
"172.20.17.76", /*vulcanio76*/
"172.20.17.77", /*vulcanio77*/
"172.20.17.78", /*vulcanio78*/
"172.20.17.79", /*vulcanio79*/
"172.20.17.80", /*vulcanio80*/
"172.20.17.81", /*vulcanio81*/
"172.20.17.82", /*vulcanio82*/
"172.20.17.83", /*vulcanio83*/
"172.20.17.84", /*vulcanio84*/
"172.20.17.85", /*vulcanio85*/
"172.20.17.86", /*vulcanio86*/
"172.20.17.87", /*vulcanio87*/
"172.20.17.88", /*vulcanio88*/
"172.20.17.89", /*vulcanio89*/
"172.20.17.90", /*vulcanio90*/
"172.20.17.91", /*vulcanio91*/
"172.20.17.92", /*vulcanio92*/
"172.20.17.93", /*vulcanio93*/
"172.20.17.94", /*vulcanio94*/
"172.20.17.95", /*vulcanio95*/
"172.20.17.96", /*vulcanio96*/
"172.20.17.97", /*vulcanio97*/
"172.20.17.98", /*vulcanio98*/
"172.20.17.99", /*vulcanio99*/
"172.20.17.100", /*vulcanio100*/
"172.20.17.101", /*vulcanio101*/
"172.20.17.102", /*vulcanio102*/
"172.20.17.103", /*vulcanio103*/
"172.20.17.104", /*vulcanio104*/
"172.20.17.105", /*vulcanio105*/
"172.20.17.106", /*vulcanio106*/
"172.20.17.107", /*vulcanio107*/
"172.20.17.108", /*vulcanio108*/
"172.20.17.109", /*vulcanio109*/
"172.20.17.110", /*vulcanio110*/
"172.20.17.111", /*vulcanio111*/
"172.20.17.112", /*vulcanio112*/
"172.20.17.113", /*vulcanio113*/
"172.20.17.114", /*vulcanio114*/
"172.20.17.115", /*vulcanio115*/
"172.20.17.116", /*vulcanio116*/
"172.20.17.117", /*vulcanio117*/
"172.20.17.118", /*vulcanio118*/
"172.20.17.119", /*vulcanio119*/
"172.20.17.120", /*vulcanio120*/
"172.20.17.121", /*vulcanio121*/
"172.20.17.122", /*vulcanio122*/
"172.20.17.123", /*vulcanio123*/
"172.20.17.124", /*vulcanio124*/
"172.20.17.125", /*vulcanio125*/
"172.20.17.126", /*vulcanio126*/
"172.20.17.127", /*vulcanio127*/
"172.20.17.128", /*vulcanio128*/
"172.20.17.129", /*vulcanio129*/
"172.20.17.130", /*vulcanio130*/
"172.20.17.131", /*vulcanio131*/
"172.20.17.132", /*vulcanio132*/
"172.20.17.133", /*vulcanio133*/
"172.20.17.134", /*vulcanio134*/
"172.20.17.135", /*vulcanio135*/
"172.20.17.136", /*vulcanio136*/
"172.20.17.137", /*vulcanio137*/
"172.20.17.138", /*vulcanio138*/
"172.20.17.139", /*vulcanio139*/
"172.20.17.140", /*vulcanio140*/
"172.20.17.141", /*vulcanio141*/
"172.20.17.142", /*vulcanio142*/
"172.20.17.143", /*vulcanio143*/
"172.20.17.144", /*vulcanio144*/
"172.20.17.145", /*vulcanio145*/
"172.20.17.146", /*vulcanio146*/
"172.20.17.147", /*vulcanio147*/
"172.20.17.148", /*vulcanio148*/
"172.20.17.149", /*vulcanio149*/
"172.20.17.150", /*vulcanio150*/
"172.20.17.151", /*vulcanio151*/
"172.20.17.152", /*vulcanio152*/
"172.20.17.153", /*vulcanio153*/
"172.20.17.154", /*vulcanio154*/
"172.20.17.155", /*vulcanio155*/
"172.20.17.156", /*vulcanio156*/
"172.20.17.157", /*vulcanio157*/
"172.20.17.158", /*vulcanio158*/
"172.20.17.159", /*vulcanio159*/
"172.20.17.160", /*vulcanio160*/
"172.20.17.161", /*vulcanio161*/
"172.20.17.162", /*vulcanio162*/
"172.20.17.163", /*vulcanio163*/
"172.20.17.164", /*vulcanio164*/
"172.20.17.165", /*vulcanio165*/
"172.20.17.166", /*vulcanio166*/
"172.20.17.167", /*vulcanio167*/
"172.20.17.168", /*vulcanio168*/
"172.20.17.169", /*vulcanio169*/
"172.20.17.170", /*vulcanio170*/
"172.20.17.171", /*vulcanio171*/
"172.20.17.172", /*vulcanio172*/
"172.20.17.173", /*vulcanio173*/
"172.20.17.174", /*vulcanio174*/
"172.20.17.175", /*vulcanio175*/
"172.20.17.176", /*vulcanio176*/
"172.20.17.177", /*vulcanio177*/
"172.20.17.178", /*vulcanio178*/
"172.20.17.179", /*vulcanio179*/
"172.20.17.180", /*vulcanio180*/
"172.20.17.181", /*vulcanio181*/
"172.20.17.182", /*vulcanio182*/
"172.20.17.183", /*vulcanio183*/
"172.20.17.184", /*vulcanio184*/
"172.20.17.185", /*vulcanio185*/
"172.20.17.186", /*vulcanio186*/
"172.20.17.187", /*vulcanio187*/
"172.20.17.188", /*vulcanio188*/
"172.20.17.189", /*vulcanio189*/
"172.20.17.190", /*vulcanio190*/
"172.20.17.191", /*vulcanio191*/
"172.20.17.192" /*vulcanio192*/
| 31.709845 | 32 | 0.623529 |
80fadb63bbbf282f0a4d530f9a780c5ecfcb9377 | 129 | h | C | Last_Door/Intermediate/Build/Win64/Last_DoorEditor/Development/Engine/SharedPCH.Engine.h | sirius-team/Last_Door | 837540b4b6c9922aff84de65efb2aa697d2b6bfb | [
"MIT"
] | null | null | null | Last_Door/Intermediate/Build/Win64/Last_DoorEditor/Development/Engine/SharedPCH.Engine.h | sirius-team/Last_Door | 837540b4b6c9922aff84de65efb2aa697d2b6bfb | [
"MIT"
] | null | null | null | Last_Door/Intermediate/Build/Win64/Last_DoorEditor/Development/Engine/SharedPCH.Engine.h | sirius-team/Last_Door | 837540b4b6c9922aff84de65efb2aa697d2b6bfb | [
"MIT"
] | null | null | null | version https://git-lfs.github.com/spec/v1
oid sha256:32f589b71f4e592037285487063dd912d04a676c5ef412fc71036b7dd32fd5d2
size 6921
| 32.25 | 75 | 0.883721 |
57affe533bca9a23d5d6e3541761f2ddbb9dc33c | 6,350 | c | C | firmware/coreboot/src/soc/intel/skylake/vr_config.c | fabiojna02/OpenCellular | 45b6a202d6b2e2485c89955b9a6da920c4d56ddb | [
"CC-BY-4.0",
"BSD-3-Clause"
] | 1 | 2019-11-04T07:11:25.000Z | 2019-11-04T07:11:25.000Z | firmware/coreboot/src/soc/intel/skylake/vr_config.c | fabiojna02/OpenCellular | 45b6a202d6b2e2485c89955b9a6da920c4d56ddb | [
"CC-BY-4.0",
"BSD-3-Clause"
] | 13 | 2018-10-12T21:29:09.000Z | 2018-10-25T20:06:51.000Z | firmware/coreboot/src/soc/intel/skylake/vr_config.c | fabiojna02/OpenCellular | 45b6a202d6b2e2485c89955b9a6da920c4d56ddb | [
"CC-BY-4.0",
"BSD-3-Clause"
] | null | null | null | /*
* This file is part of the coreboot project.
*
* Copyright 2015 Google Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* 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.
*
*/
#include <arch/io.h>
#include <device/pci_ids.h>
#include <device/pci_ops.h>
#include <fsp/api.h>
#include <soc/ramstage.h>
#include <soc/vr_config.h>
#define KBLY_ICCMAX_SA VR_CFG_AMP(4.1)
#define KBLY_ICCMAX_CORE VR_CFG_AMP(24)
#define KBLY_ICCMAX_GTS_GTUS VR_CFG_AMP(24)
#define KBLR_ICCMAX_SA_U42 VR_CFG_AMP(6)
#define KBLU_ICCMAX_SA_U22 VR_CFG_AMP(4.5)
#define KBLR_ICCMAX_CORE_U42 VR_CFG_AMP(64)
#define KBLU_ICCMAX_CORE_U22_PREMIUM VR_CFG_AMP(32)
#define KBLU_ICCMAX_CORE_U22_BASE VR_CFG_AMP(29)
#define KBLUR_ICCMAX_GTS_GTUS VR_CFG_AMP(31)
enum kbl_sku {
KBL_Y_SKU,
KBL_R_SKU,
KBL_U_BASE_SKU,
KBL_U_PREMIUM_SKU,
};
/*
* Iccmax table from Doc #559100 Section 7.2 DC Specifications, the
* Iccmax is the same among KBL-Y but KBL-U/R.
* +----------------+-------------+---------------+------+-----+
* | Domain/Setting | SA | IA | GTUS | GTS |
* +----------------+-------------+---------------+------+-----+
* | IccMax(KBL-U/R)| 6A(U42) | 64A(U42) | 31A | 31A |
* | | 4.5A(Others)| 29A(P/C) | | |
* | | | 32A(i3/i5) | | |
* +----------------+-------------+---------------+------+-----+
* | IccMax(KBL-Y) | 4.1A | 24A | 24A | 24A |
* +----------------+-------------+---------------+------+-----+
*/
static const struct {
enum kbl_sku sku;
uint16_t icc_max[NUM_VR_DOMAINS];
}sku_icc_max_mapping[] = {
[KBL_Y_SKU] = {
.sku = KBL_Y_SKU,
.icc_max = {
KBLY_ICCMAX_SA,
KBLY_ICCMAX_CORE,
KBLY_ICCMAX_GTS_GTUS,
KBLY_ICCMAX_GTS_GTUS
}
},
[KBL_R_SKU] = {
.sku = KBL_R_SKU,
.icc_max = {
KBLR_ICCMAX_SA_U42,
KBLR_ICCMAX_CORE_U42,
KBLUR_ICCMAX_GTS_GTUS,
KBLUR_ICCMAX_GTS_GTUS
}
},
[KBL_U_BASE_SKU] = {
.sku = KBL_U_BASE_SKU,
.icc_max = {
KBLU_ICCMAX_SA_U22,
KBLU_ICCMAX_CORE_U22_BASE,
KBLUR_ICCMAX_GTS_GTUS,
KBLUR_ICCMAX_GTS_GTUS
}
},
[KBL_U_PREMIUM_SKU] = {
.sku = KBL_U_PREMIUM_SKU,
.icc_max = {
KBLU_ICCMAX_SA_U22,
KBLU_ICCMAX_CORE_U22_PREMIUM,
KBLUR_ICCMAX_GTS_GTUS,
KBLUR_ICCMAX_GTS_GTUS
}
},
};
/* Default values for domain configuration. PSI3 and PSI4 are disabled. */
static const struct vr_config default_configs[NUM_VR_DOMAINS] = {
[VR_SYSTEM_AGENT] = {
.vr_config_enable = 1,
.psi1threshold = VR_CFG_AMP(20),
.psi2threshold = VR_CFG_AMP(4),
.psi3threshold = VR_CFG_AMP(1),
.psi3enable = 0,
.psi4enable = 0,
.imon_slope = 0x0,
.imon_offset = 0x0,
.icc_max = VR_CFG_AMP(7),
.voltage_limit = 1520,
},
[VR_IA_CORE] = {
.vr_config_enable = 1,
.psi1threshold = VR_CFG_AMP(20),
.psi2threshold = VR_CFG_AMP(5),
.psi3threshold = VR_CFG_AMP(1),
.psi3enable = 0,
.psi4enable = 0,
.imon_slope = 0x0,
.imon_offset = 0x0,
.icc_max = VR_CFG_AMP(34),
.voltage_limit = 1520,
},
#if IS_ENABLED(CONFIG_PLATFORM_USES_FSP1_1)
[VR_RING] = {
.vr_config_enable = 1,
.psi1threshold = VR_CFG_AMP(20),
.psi2threshold = VR_CFG_AMP(5),
.psi3threshold = VR_CFG_AMP(1),
.psi3enable = 0,
.psi4enable = 0,
.imon_slope = 0x0,
.imon_offset = 0x0,
.icc_max = VR_CFG_AMP(34),
.voltage_limit = 1520,
},
#endif
[VR_GT_UNSLICED] = {
.vr_config_enable = 1,
.psi1threshold = VR_CFG_AMP(20),
.psi2threshold = VR_CFG_AMP(5),
.psi3threshold = VR_CFG_AMP(1),
.psi3enable = 0,
.psi4enable = 0,
.imon_slope = 0x0,
.imon_offset = 0x0,
.icc_max = VR_CFG_AMP(35),
.voltage_limit = 1520,
},
[VR_GT_SLICED] = {
.vr_config_enable = 1,
.psi1threshold = VR_CFG_AMP(20),
.psi2threshold = VR_CFG_AMP(5),
.psi3threshold = VR_CFG_AMP(1),
.psi3enable = 0,
.psi4enable = 0,
.imon_slope = 0x0,
.imon_offset = 0x0,
.icc_max = VR_CFG_AMP(35),
.voltage_limit = 1520,
},
};
static uint16_t get_dev_id(struct device *dev)
{
return pci_read_config16(dev, PCI_DEVICE_ID);
}
static int get_kbl_sku(void)
{
static int sku = -1;
uint16_t id;
if (sku != -1)
return sku;
id = get_dev_id(SA_DEV_ROOT);
if (id == PCI_DEVICE_ID_INTEL_KBL_U_R)
sku = KBL_R_SKU;
else if (id == PCI_DEVICE_ID_INTEL_KBL_ID_Y)
sku = KBL_Y_SKU;
else if (id == PCI_DEVICE_ID_INTEL_KBL_ID_U) {
id = get_dev_id(PCH_DEV_LPC);
if (id == PCI_DEVICE_ID_INTEL_SPT_LP_U_BASE_HDCP22)
sku = KBL_U_BASE_SKU;
else
sku = KBL_U_PREMIUM_SKU;
} else
/* Not one of the skus with available Icc max mapping. */
sku = -2;
return sku;
}
static uint16_t get_sku_icc_max(int domain, uint16_t board_icc_max)
{
/* If board provided non-zero value, use it. */
if (board_icc_max)
return board_icc_max;
/* Check if this SKU has a mapping table entry. */
int sku_id = get_kbl_sku();
if (sku_id < 0)
return 0;
return sku_icc_max_mapping[sku_id].icc_max[domain];
}
void fill_vr_domain_config(void *params,
int domain, const struct vr_config *chip_cfg)
{
FSP_SIL_UPD *vr_params = (FSP_SIL_UPD *)params;
const struct vr_config *cfg;
if (domain < 0 || domain >= NUM_VR_DOMAINS)
return;
/* Use device tree override if requested. */
if (chip_cfg->vr_config_enable)
cfg = chip_cfg;
else
cfg = &default_configs[domain];
vr_params->VrConfigEnable[domain] = cfg->vr_config_enable;
vr_params->Psi1Threshold[domain] = cfg->psi1threshold;
vr_params->Psi2Threshold[domain] = cfg->psi2threshold;
vr_params->Psi3Threshold[domain] = cfg->psi3threshold;
vr_params->Psi3Enable[domain] = cfg->psi3enable;
vr_params->Psi4Enable[domain] = cfg->psi4enable;
vr_params->ImonSlope[domain] = cfg->imon_slope;
vr_params->ImonOffset[domain] = cfg->imon_offset;
vr_params->IccMax[domain] = get_sku_icc_max(domain, cfg->icc_max);
vr_params->VrVoltageLimit[domain] = cfg->voltage_limit;
#if IS_ENABLED(CONFIG_PLATFORM_USES_FSP2_0)
vr_params->AcLoadline[domain] = cfg->ac_loadline;
vr_params->DcLoadline[domain] = cfg->dc_loadline;
#endif
}
| 26.793249 | 74 | 0.666457 |
41933d72199585ef809c7b60ad12d5052c010ef5 | 48,846 | c | C | cresql/resql.c | umit/resql | 140818a863a66a3656fc24997d50faaa4e214161 | [
"BSD-3-Clause"
] | null | null | null | cresql/resql.c | umit/resql | 140818a863a66a3656fc24997d50faaa4e214161 | [
"BSD-3-Clause"
] | null | null | null | cresql/resql.c | umit/resql | 140818a863a66a3656fc24997d50faaa4e214161 | [
"BSD-3-Clause"
] | null | null | null | /*
* BSD-3-Clause
*
* Copyright 2021 Ozan Tezcan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder 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 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.
*/
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 700
#endif
#if defined(_WIN32) || defined(_WIN64)
#include <afunix.h>
#include <windows.h>
#include <winsock2.h>
#include <Ws2tcpip.h>
#pragma comment(lib, "ws2_32.lib")
#pragma warning(disable : 4996)
#define rs_poll WSAPoll
typedef SOCKET sc_sock_int;
#else
#include <poll.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <time.h>
typedef int sc_sock_int;
#define rs_poll poll
#endif
#include "resql.h"
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
static uint64_t sc_time_mono_ms()
{
#if defined(_WIN32) || defined(_WIN64)
// System frequency does not change at run-time, cache it
static int64_t frequency = 0;
if (frequency == 0) {
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
assert(freq.QuadPart != 0);
frequency = freq.QuadPart;
}
LARGE_INTEGER count;
QueryPerformanceCounter(&count);
return (int64_t) (count.QuadPart * 1000) / frequency;
#else
int rc;
struct timespec ts;
rc = clock_gettime(CLOCK_MONOTONIC, &ts);
assert(rc == 0);
(void) rc;
return (uint64_t) ((uint64_t) ts.tv_sec * 1000 +
(uint64_t) ts.tv_nsec / 1000000);
#endif
}
static int sc_time_sleep(uint64_t millis)
{
#if defined(_WIN32) || defined(_WIN64)
Sleep((DWORD) millis);
return 0;
#else
int rc;
struct timespec t, rem;
rem.tv_sec = millis / 1000;
rem.tv_nsec = (millis % 1000) * 1000000;
do {
t = rem;
rc = nanosleep(&t, &rem);
} while (rc != 0 && errno == EINTR);
return rc;
#endif
}
struct sc_uri {
const char *str;
const char *scheme;
const char *host;
const char *userinfo;
const char *port;
const char *path;
const char *query;
const char *fragment;
char buf[];
};
static struct sc_uri *sc_uri_create(const char *str)
{
const char *s1 = "%.*s%.*s%.*s%.*s%.*s%.*s%.*s%.*s";
const char *s2 = "%.*s%c%.*s%c%.*s%c%.*s%c%.*s%c%.*s%c%.*s%c";
const char *authority = "//";
int diff, ret;
unsigned long val;
size_t full_len, parts_len;
size_t scheme_len, authority_len = 0, userinfo_len = 0;
size_t host_len = 0, port_len = 0, path_len;
size_t query_len = 0, fragment_len = 0;
char *scheme, *userinfo = "", *host = "", *port = "";
char *path, *query = "", *fragment = "";
char *ptr, *dest, *parse_end;
char *pos = (char *) str;
struct sc_uri *uri;
if (str == NULL || (ptr = strstr(pos, ":")) == NULL) {
return NULL;
}
scheme = pos;
scheme_len = ptr - str + 1;
pos = ptr + 1;
if (*pos == '/' && *(pos + 1) == '/') {
authority_len = 2;
pos += authority_len;
ptr = strchr(pos, '@');
if (ptr != NULL) {
userinfo = pos;
userinfo_len = ptr - pos + strlen("@");
pos = ptr + 1;
}
ptr = pos + strcspn(pos, *pos == '[' ? "]" : ":/?#");
host = pos;
host_len = ptr - pos + (*host == '[');
pos = host + host_len;
if (*host == '[' && *(host + host_len - 1) != ']') {
return NULL;
}
ptr = strchr(pos, ':');
if (ptr != NULL) {
if (*(ptr + 1) == '\0') {
return NULL;
}
errno = 0;
val = strtoul(ptr + 1, &parse_end, 10);
if (errno != 0 || val > 65536) {
return NULL;
}
port = ptr;
port_len = parse_end - ptr;
pos = port + port_len;
}
}
path = pos;
path_len = strcspn(path, "?#");
pos = path + path_len;
ptr = strchr(pos, '?');
if (ptr != NULL) {
query = ptr;
query_len = strcspn(query, "#");
pos = query + query_len;
}
if (*pos == '#') {
fragment = pos;
fragment_len = strlen(pos);
}
full_len = scheme_len + authority_len + userinfo_len + host_len +
port_len + path_len + query_len + fragment_len + 1;
parts_len = full_len - authority_len;
parts_len += 7; // NULL characters for each part.
parts_len -= (scheme_len != 0);
parts_len -= (userinfo_len != 0);
parts_len -= (port_len != 0);
parts_len -= (query_len != 0);
parts_len -= (fragment_len != 0);
uri = resql_malloc(sizeof(*uri) + parts_len + full_len);
if (uri == NULL) {
return NULL;
}
ret = snprintf(uri->buf, full_len, s1, scheme_len, scheme,
authority_len, authority, userinfo_len, userinfo,
host_len, host, port_len, port, path_len, path,
query_len, query, fragment_len, fragment);
if (ret < 0 || (size_t) ret != full_len - 1) {
goto error;
}
dest = uri->buf + strlen(uri->buf) + 1;
scheme_len -= (scheme_len != 0); // Skip ":"
userinfo_len -= (userinfo_len != 0); // Skip "@"
diff = port_len != 0;
port_len -= diff; // Skip ":"
port += diff; // Skip ":"
diff = (query_len != 0);
query_len -= diff; // Skip "?"
query += diff; // Skip "?"
diff = (fragment_len != 0);
fragment_len -= diff; // Skip "#"
fragment += diff; // Skip "#"
ret = sprintf(dest, s2, scheme_len, scheme, 0, userinfo_len, userinfo,
0, host_len, host, 0, port_len, port, 0, path_len, path,
0, query_len, query, 0, fragment_len, fragment, 0);
if (ret < 0 || (size_t) ret != parts_len - 1) {
goto error;
}
uri->str = uri->buf;
uri->scheme = dest;
uri->userinfo = dest + scheme_len + 1;
uri->host = uri->userinfo + userinfo_len + 1;
uri->port = uri->host + host_len + 1;
uri->path = uri->port + port_len + 1;
uri->query = uri->path + path_len + 1;
uri->fragment = uri->query + query_len + 1;
return uri;
error:
resql_free(uri);
return NULL;
}
static void sc_uri_destroy(struct sc_uri *uri)
{
resql_free(uri);
}
struct sc_str {
uint32_t len;
char buf[];
};
#define sc_str_meta(str) \
((struct sc_str *) ((char *) (str) -offsetof(struct sc_str, buf)))
#define sc_str_bytes(n) ((n) + sizeof(struct sc_str) + 1)
#ifndef SC_STR_MAX
#define SC_STR_MAX (UINT32_MAX - sizeof(struct sc_str) - 1)
#endif
static char *sc_str_create_len(const char *str, uint32_t len)
{
struct sc_str *c;
if (str == NULL) {
return NULL;
}
c = resql_malloc(sc_str_bytes(len));
if (c == NULL) {
return NULL;
}
memcpy(c->buf, str, len);
c->buf[len] = '\0';
c->len = len;
return c->buf;
}
static char *sc_str_create(const char *str)
{
size_t len;
if (str == NULL || (len = strlen(str)) > SC_STR_MAX) {
return NULL;
}
return sc_str_create_len(str, (uint32_t) len);
}
static void sc_str_destroy(char *str)
{
if (str == NULL) {
return;
}
resql_free(sc_str_meta(str));
}
static void swap(char *str, char *d)
{
char tmp;
char *c = str + sc_str_meta(str)->len;
tmp = *c;
*c = *d;
*d = tmp;
}
static const char *sc_str_token_begin(char *str, char **save, const char *delim)
{
char *it = str;
if (str == NULL) {
return NULL;
}
if (*save != NULL) {
it = *save;
swap(str, it);
if (*it == '\0') {
return NULL;
}
it++;
}
*save = it + strcspn(it, delim);
swap(str, *save);
return it;
}
static void sc_str_token_end(char *str, char **save)
{
char *end;
if (str == NULL) {
return;
}
end = str + sc_str_meta(str)->len;
if (*end == '\0') {
return;
}
swap(str, *save);
}
#define SC_BUF_CORRUPT 1u
#define SC_BUF_OOM 3u
#define SC_BUF_REF 8
#define SC_BUF_DATA 16
#define SC_BUF_READ (SC_BUF_REF | SC_BUF_DATA)
#ifndef SC_BUF_MAX
#define SC_BUF_MAX UINT32_MAX
#endif
struct sc_buf {
unsigned char *mem;
uint32_t cap;
uint32_t limit;
uint32_t rpos;
uint32_t wpos;
unsigned int err;
bool ref;
};
// clang-format off
static inline uint32_t sc_buf_8_len(uint8_t val) {(void) val; return 1;}
static inline uint32_t sc_buf_32_len(uint32_t val){(void) val; return 4;}
// clang-format on
static inline uint32_t sc_buf_str_len(const char *str)
{
const uint32_t bytes = sc_buf_32_len(UINT32_MAX) + sc_buf_8_len('\0');
if (str == NULL) {
return sc_buf_32_len(UINT32_MAX);
}
assert(strlen(str) <= INT32_MAX - 5);
return bytes + (uint32_t) strlen(str);
}
static struct sc_buf sc_buf_wrap(void *data, uint32_t len, int flag)
{
struct sc_buf b = {
.mem = data,
.cap = len,
.limit = flag & SC_BUF_REF ? len : SC_BUF_MAX,
.wpos = flag & SC_BUF_DATA ? len : 0,
.rpos = 0,
.ref = (bool) (flag & SC_BUF_REF),
.err = 0,
};
return b;
}
static bool sc_buf_init(struct sc_buf *b, uint32_t cap)
{
void *m = NULL;
*b = (struct sc_buf){0};
if (cap > 0) {
m = resql_calloc(1, cap);
if (m == NULL) {
return false;
}
}
*b = sc_buf_wrap(m, cap, 0);
return true;
}
static void sc_buf_term(struct sc_buf *b)
{
if (!b->ref) {
resql_free(b->mem);
}
}
static bool sc_buf_reserve(struct sc_buf *b, uint32_t len)
{
uint32_t size;
void *m;
if (b->wpos + len > b->cap) {
if (b->ref) {
goto err;
}
size = ((b->cap + len + 4095) / 4096) * 4096;
if (size > b->limit || b->cap >= SC_BUF_MAX - 4096) {
goto err;
}
m = resql_realloc(b->mem, size);
if (m == NULL) {
goto err;
}
b->cap = size;
b->mem = m;
}
return true;
err:
b->err |= SC_BUF_OOM;
return false;
}
static bool sc_buf_valid(struct sc_buf *b)
{
return b->err == 0;
}
static uint32_t sc_buf_quota(struct sc_buf *b)
{
return b->cap - b->wpos;
}
static uint32_t sc_buf_size(struct sc_buf *b)
{
return b->wpos - b->rpos;
}
static void sc_buf_clear(struct sc_buf *b)
{
b->rpos = 0;
b->wpos = 0;
b->err = 0;
}
static void sc_buf_mark_read(struct sc_buf *b, uint32_t len)
{
b->rpos += len;
}
static void sc_buf_mark_write(struct sc_buf *b, uint32_t len)
{
b->wpos += len;
}
static uint32_t sc_buf_rpos(struct sc_buf *b)
{
return b->rpos;
}
static void sc_buf_set_rpos(struct sc_buf *b, uint32_t pos)
{
if (pos > b->wpos) {
b->err |= SC_BUF_CORRUPT;
}
b->rpos = pos;
}
static void sc_buf_set_wpos(struct sc_buf *b, uint32_t pos)
{
if (pos > b->cap) {
b->err |= SC_BUF_CORRUPT;
}
b->wpos = pos;
}
static uint32_t sc_buf_wpos(struct sc_buf *b)
{
return b->wpos;
}
static void *sc_buf_rbuf(struct sc_buf *b)
{
return b->mem + b->rpos;
}
static void *sc_buf_wbuf(struct sc_buf *b)
{
return b->mem + b->wpos;
}
static uint32_t sc_buf_set_data(struct sc_buf *b, uint32_t offset,
const void *src, uint32_t len)
{
if (b->err != 0 || (offset + len > b->cap)) {
b->err |= SC_BUF_CORRUPT;
return 0;
}
memcpy(&b->mem[offset], src, len);
return len;
}
static void sc_buf_put_raw(struct sc_buf *b, const void *ptr, uint32_t len)
{
if (!sc_buf_reserve(b, len)) {
return;
}
b->wpos += sc_buf_set_data(b, b->wpos, ptr, len);
}
static uint16_t sc_buf_peek_8_pos(struct sc_buf *b, uint32_t pos, uint8_t *val)
{
if (pos + sizeof(*val) > b->wpos) {
b->err |= SC_BUF_CORRUPT;
*val = 0;
return 0;
}
*val = b->mem[pos];
return sizeof(*val);
}
static uint32_t sc_buf_peek_32_pos(struct sc_buf *b, uint32_t pos,
uint32_t *val)
{
unsigned char *p;
if (pos + sizeof(*val) > b->wpos) {
b->err |= SC_BUF_CORRUPT;
*val = 0;
return 0;
}
p = &b->mem[pos];
*val = (uint32_t) p[0] << 0 | (uint32_t) p[1] << 8 |
(uint32_t) p[2] << 16 | (uint32_t) p[3] << 24;
return sizeof(*val);
}
static uint32_t sc_buf_peek_64_pos(struct sc_buf *b, uint32_t pos,
uint64_t *val)
{
unsigned char *p;
if (pos + sizeof(*val) > b->wpos) {
b->err |= SC_BUF_CORRUPT;
*val = 0;
return 0;
}
p = &b->mem[pos];
*val = (uint64_t) p[0] << 0 | (uint64_t) p[1] << 8 |
(uint64_t) p[2] << 16 | (uint64_t) p[3] << 24 |
(uint64_t) p[4] << 32 | (uint64_t) p[5] << 40 |
(uint64_t) p[6] << 48 | (uint64_t) p[7] << 56;
return sizeof(*val);
}
static uint32_t sc_buf_set_8_pos(struct sc_buf *b, uint32_t pos,
const uint8_t *val)
{
if (b->err != 0 || (pos + sizeof(*val) > b->cap)) {
b->err |= SC_BUF_CORRUPT;
return 0;
}
b->mem[pos] = *val;
return sizeof(*val);
}
static uint32_t sc_buf_set_32_pos(struct sc_buf *b, uint32_t pos,
const uint32_t *val)
{
unsigned char *p;
if (b->err != 0 || (pos + sizeof(*val) > b->cap)) {
b->err |= SC_BUF_CORRUPT;
return 0;
}
p = &b->mem[pos];
p[0] = (unsigned char) (*val >> 0);
p[1] = (unsigned char) (*val >> 8);
p[2] = (unsigned char) (*val >> 16);
p[3] = (unsigned char) (*val >> 24);
return sizeof(*val);
}
static uint32_t sc_buf_set_64_pos(struct sc_buf *b, uint32_t pos,
const uint64_t *val)
{
unsigned char *p;
if (b->err != 0 || (pos + sizeof(*val) > b->cap)) {
b->err |= SC_BUF_CORRUPT;
return 0;
}
p = &b->mem[pos];
p[0] = (unsigned char) (*val >> 0);
p[1] = (unsigned char) (*val >> 8);
p[2] = (unsigned char) (*val >> 16);
p[3] = (unsigned char) (*val >> 24);
p[4] = (unsigned char) (*val >> 32);
p[5] = (unsigned char) (*val >> 40);
p[6] = (unsigned char) (*val >> 48);
p[7] = (unsigned char) (*val >> 56);
return sizeof(*val);
}
static uint32_t sc_buf_peek_32_at(struct sc_buf *b, uint32_t pos)
{
uint32_t val;
sc_buf_peek_32_pos(b, pos, &val);
return val;
}
static uint32_t sc_buf_peek_32(struct sc_buf *b)
{
return sc_buf_peek_32_at(b, b->rpos);
}
static void sc_buf_set_8_at(struct sc_buf *b, uint32_t pos, uint8_t val)
{
sc_buf_set_8_pos(b, pos, &val);
}
static void sc_buf_set_32_at(struct sc_buf *b, uint32_t pos, uint32_t val)
{
sc_buf_set_32_pos(b, pos, &val);
}
static void sc_buf_set_64_at(struct sc_buf *b, uint32_t pos, uint64_t val)
{
sc_buf_set_64_pos(b, pos, &val);
}
static uint8_t sc_buf_get_8(struct sc_buf *b)
{
uint8_t val;
b->rpos += sc_buf_peek_8_pos(b, b->rpos, &val);
return val;
}
static uint32_t sc_buf_get_32(struct sc_buf *b)
{
uint32_t val;
b->rpos += sc_buf_peek_32_pos(b, b->rpos, &val);
return val;
}
static uint64_t sc_buf_get_64(struct sc_buf *b)
{
uint64_t val;
b->rpos += sc_buf_peek_64_pos(b, b->rpos, &val);
return val;
}
static double sc_buf_get_double(struct sc_buf *b)
{
double d;
uint64_t val;
val = sc_buf_get_64(b);
memcpy(&d, &val, 8);
return d;
}
static const char *sc_buf_get_str(struct sc_buf *b)
{
int len;
const char *str;
len = sc_buf_get_32(b);
if (len == -1) {
return NULL;
}
if (b->rpos + len + 1 > b->wpos) {
b->err |= SC_BUF_CORRUPT;
return NULL;
}
str = (char *) b->mem + b->rpos;
b->rpos += len + 1;
return str;
}
static void *sc_buf_get_blob(struct sc_buf *b, uint32_t len)
{
void *blob;
if (len == 0) {
return NULL;
}
if (b->rpos + len > b->wpos) {
b->err |= SC_BUF_CORRUPT;
return NULL;
}
blob = b->mem + b->rpos;
b->rpos += len;
return blob;
}
static void sc_buf_put_8(struct sc_buf *b, uint8_t val)
{
if (!sc_buf_reserve(b, sizeof(val))) {
return;
}
b->wpos += sc_buf_set_8_pos(b, b->wpos, &val);
}
static void sc_buf_put_32(struct sc_buf *b, uint32_t val)
{
if (!sc_buf_reserve(b, sizeof(val))) {
return;
}
b->wpos += sc_buf_set_32_pos(b, b->wpos, &val);
}
static void sc_buf_put_64(struct sc_buf *b, uint64_t val)
{
if (!sc_buf_reserve(b, sizeof(val))) {
return;
}
b->wpos += sc_buf_set_64_pos(b, b->wpos, &val);
}
static void sc_buf_put_double(struct sc_buf *b, double val)
{
uint64_t sw;
memcpy(&sw, &val, 8);
sc_buf_put_64(b, sw);
}
static void sc_buf_put_str(struct sc_buf *b, const char *str)
{
size_t sz;
if (str == NULL) {
sc_buf_put_32(b, UINT32_MAX);
return;
}
sz = strlen(str);
if (sz >= UINT32_MAX) {
b->err |= SC_BUF_CORRUPT;
return;
}
sc_buf_put_32(b, (uint32_t) sz);
sc_buf_put_raw(b, str, (uint32_t) sz + sc_buf_8_len('\0'));
}
static void sc_buf_put_blob(struct sc_buf *b, const void *ptr, uint32_t len)
{
sc_buf_put_32(b, len);
sc_buf_put_raw(b, ptr, len);
}
#define SC_SOCK_BUF_SIZE 32768
enum sc_sock_ev
{
SC_SOCK_NONE = 0u,
SC_SOCK_READ = 1u,
SC_SOCK_WRITE = 2u,
};
enum sc_sock_family
{
SC_SOCK_INET = AF_INET,
SC_SOCK_INET6 = AF_INET6,
SC_SOCK_UNIX = AF_UNIX
};
struct sc_sock_fd {
sc_sock_int fd;
enum sc_sock_ev op;
int type; // user data
int index;
};
struct sc_sock {
struct sc_sock_fd fdt;
bool blocking;
int family;
char err[128];
};
#if defined(_WIN32) || defined(_WIN64)
#define sc_close(n) closesocket(n)
#define sc_unlink(n) DeleteFileA(n)
#define SC_ERR SOCKET_ERROR
#define SC_INVALID INVALID_SOCKET
#define SC_EAGAIN WSAEWOULDBLOCK
#define SC_EINPROGRESS WSAEINPROGRESS
#define SC_EINTR WSAEINTR
typedef int socklen_t;
static int sc_sock_err()
{
return WSAGetLastError();
}
static void sc_sock_errstr(struct sc_sock *s, int gai_err)
{
int rc;
DWORD err = WSAGetLastError();
LPSTR str = 0;
rc = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL, err, 0, (LPSTR) &str, 0, NULL);
if (rc != 0) {
strncpy(s->err, str, sizeof(s->err) - 1);
LocalFree(str);
}
}
static int sc_sock_set_blocking(struct sc_sock *s, bool blocking)
{
int mode = blocking ? 0 : 1;
int rc = ioctlsocket(s->fdt.fd, FIONBIO, &mode);
return rc == 0 ? 0 : -1;
}
static int sc_sock_startup()
{
int rc;
WSADATA data;
rc = WSAStartup(MAKEWORD(2, 2), &data);
if (rc != 0 ||
(LOBYTE(data.wVersion) != 2 || HIBYTE(data.wVersion) != 2)) {
return -1;
}
return 0;
}
static int sc_sock_cleanup()
{
int rc;
rc = WSACleanup();
return rc != 0 ? -1 : 0;
}
#else
#include <inttypes.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <sys/un.h>
#include <unistd.h>
#define sc_close(n) close(n)
#define sc_unlink(n) unlink(n)
#define SC_ERR (-1)
#define SC_INVALID (-1)
#define SC_EAGAIN EAGAIN
#define SC_EINPROGRESS EINPROGRESS
#define SC_EINTR EINTR
static int sc_sock_startup()
{
return 0;
}
static int sc_sock_cleanup()
{
return 0;
}
static int sc_sock_err()
{
return errno;
}
static void sc_sock_errstr(struct sc_sock *s, int gai_err)
{
const char *str;
str = gai_err ? gai_strerror(gai_err) : strerror(errno);
strncpy(s->err, str, sizeof(s->err) - 1);
}
static int sc_sock_set_blocking(struct sc_sock *s, bool blocking)
{
int flags;
flags = fcntl(s->fdt.fd, F_GETFL, 0);
if (flags == -1) {
return -1;
}
flags = blocking ? (flags & ~O_NONBLOCK) : (flags | O_NONBLOCK);
return (fcntl(s->fdt.fd, F_SETFL, flags) == 0) ? 0 : -1;
}
#endif
static void sc_sock_init(struct sc_sock *s, int type, bool blocking, int family)
{
s->fdt.fd = -1;
s->fdt.type = type;
s->fdt.op = SC_SOCK_NONE;
s->fdt.index = -1;
s->blocking = blocking;
s->family = family;
memset(s->err, 0, sizeof(s->err));
}
static int sc_sock_close(struct sc_sock *s)
{
int rc = 0;
if (s->fdt.fd != -1) {
rc = sc_close(s->fdt.fd);
s->fdt.fd = -1;
}
return (rc == 0) ? 0 : -1;
}
static int sc_sock_term(struct sc_sock *s)
{
int rc;
rc = sc_sock_close(s);
if (rc != 0) {
sc_sock_errstr(s, 0);
}
return rc;
}
static int sc_sock_set_rcvtimeo(struct sc_sock *s, int ms)
{
int rc;
void *p;
struct timeval tv = {
.tv_usec = ms % 1000,
.tv_sec = ms / 1000,
};
p = (void *) &tv;
rc = setsockopt(s->fdt.fd, SOL_SOCKET, SO_RCVTIMEO, p, sizeof(tv));
if (rc != 0) {
sc_sock_errstr(s, 0);
}
return rc;
}
static int sc_sock_set_sndtimeo(struct sc_sock *s, int ms)
{
int rc;
void *p;
struct timeval tv = {
.tv_usec = ms % 1000,
.tv_sec = ms / 1000,
};
p = (void *) &tv;
rc = setsockopt(s->fdt.fd, SOL_SOCKET, SO_SNDTIMEO, p, sizeof(tv));
if (rc != 0) {
sc_sock_errstr(s, 0);
}
return rc;
}
static int sc_sock_finish_connect(struct sc_sock *s)
{
int ret, rc;
socklen_t len = sizeof(ret);
rc = getsockopt(s->fdt.fd, SOL_SOCKET, SO_ERROR, (void *) &ret, &len);
if (rc != 0 || ret != 0) {
sc_sock_errstr(s, 0);
return -1;
}
return 0;
}
static int sc_sock_connect_unix(struct sc_sock *s, const char *addr)
{
const size_t len = strlen(addr);
int rc;
sc_sock_int fd;
struct sockaddr_un un = {
.sun_family = AF_UNIX,
};
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd == SC_INVALID) {
goto err;
}
s->fdt.fd = fd;
if (len >= sizeof(un.sun_path)) {
errno = EINVAL;
goto err;
}
strcpy(un.sun_path, addr);
rc = connect(s->fdt.fd, (struct sockaddr *) &un, sizeof(un));
if (rc != 0) {
goto err;
}
return 0;
err:
sc_sock_errstr(s, 0);
sc_sock_close(s);
return -1;
}
static int sc_sock_bind_src(struct sc_sock *s, const char *addr,
const char *port)
{
int rc;
struct addrinfo *p = NULL, *i;
struct addrinfo inf = {
.ai_family = AF_UNSPEC,
.ai_socktype = SOCK_STREAM,
};
rc = getaddrinfo(addr, port, &inf, &p);
if (rc != 0) {
goto gai_err;
}
for (i = p; i != NULL; i = i->ai_next) {
rc = bind(s->fdt.fd, i->ai_addr, (socklen_t) i->ai_addrlen);
if (rc != -1) {
break;
}
}
freeaddrinfo(p);
if (rc == -1) {
goto err;
}
return 0;
gai_err:
sc_sock_errstr(s, rc);
return -1;
err:
sc_sock_errstr(s, 0);
return -1;
}
static int sc_sock_connect(struct sc_sock *s, const char *dst_addr,
const char *dst_port, const char *src_addr,
const char *src_port)
{
int rc, rv = 0;
sc_sock_int fd;
void *tmp;
struct addrinfo *sinfo = NULL, *p;
struct addrinfo inf = {
.ai_family = AF_UNSPEC,
.ai_socktype = SOCK_STREAM,
};
if (s->family == AF_UNIX) {
return sc_sock_connect_unix(s, dst_addr);
}
rc = getaddrinfo(dst_addr, dst_port, &inf, &sinfo);
if (rc != 0) {
sc_sock_errstr(s, rc);
return -1;
}
for (p = sinfo; p != NULL; p = p->ai_next) {
fd = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
if (fd == SC_INVALID) {
continue;
}
s->family = p->ai_family;
s->fdt.fd = fd;
rc = sc_sock_set_blocking(s, s->blocking);
if (rc != 0) {
goto error;
}
tmp = (void *) &(int){1};
rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, tmp, sizeof(int));
if (rc != 0) {
goto error;
}
rc = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, tmp, sizeof(int));
if (rc != 0) {
goto error;
}
if (src_addr || src_port) {
rc = sc_sock_bind_src(s, src_addr, src_port);
if (rc != 0) {
goto bind_error;
}
}
rc = connect(s->fdt.fd, p->ai_addr, (socklen_t) p->ai_addrlen);
if (rc != 0) {
if (!s->blocking && (sc_sock_err() == SC_EINPROGRESS ||
sc_sock_err() == SC_EAGAIN)) {
errno = EAGAIN;
rv = -1;
goto end;
}
sc_sock_close(s);
continue;
}
goto end;
}
error:
sc_sock_errstr(s, 0);
bind_error:
rv = -1;
sc_sock_close(s);
end:
freeaddrinfo(sinfo);
return rv;
}
static int sc_sock_send(struct sc_sock *s, char *buf, int len, int flags)
{
int n, err;
if (len <= 0) {
return len;
}
retry:
n = (int) send(s->fdt.fd, buf, (size_t) len, flags);
if (n == SC_ERR) {
err = sc_sock_err();
if (err == SC_EINTR) {
goto retry;
}
if (err == SC_EAGAIN) {
errno = EAGAIN;
return -1;
}
sc_sock_errstr(s, 0);
n = -1;
}
return n;
}
static int sc_sock_recv(struct sc_sock *s, char *buf, int len, int flags)
{
int n, err;
if (len <= 0) {
return len;
}
retry:
n = (int) recv(s->fdt.fd, buf, (size_t) len, flags);
if (n == 0) {
errno = EOF;
return -1;
} else if (n == SC_ERR) {
err = sc_sock_err();
if (err == SC_EINTR) {
goto retry;
}
if (err == SC_EAGAIN) {
errno = EAGAIN;
return -1;
}
sc_sock_errstr(s, 0);
n = -1;
}
return n;
}
static const char *sc_sock_error(struct sc_sock *s)
{
s->err[sizeof(s->err) - 1] = '\0';
return s->err;
}
// clang-format off
enum msg_flag
{
MSG_FLAG_OK = 0x00,
MSG_FLAG_ERROR = 0x01,
MSG_FLAG_STMT = 0x02,
MSG_FLAG_STMT_ID = 0x03,
MSG_FLAG_STMT_PREPARE = 0x04,
MSG_FLAG_STMT_DEL_PREPARED = 0x05,
MSG_FLAG_OP = 0x06,
MSG_FLAG_OP_END = 0x07,
MSG_FLAG_ROW = 0x08,
MSG_FLAG_MSG_END = 0x09,
};
enum msg_param
{
MSG_BIND_INTEGER = 0x00,
MSG_BIND_FLOAT = 0x01,
MSG_BIND_TEXT = 0x02,
MSG_BIND_BLOB = 0x03,
MSG_BIND_NULL = 0x04
};
enum msg_bind
{
MSG_BIND_NAME = 0x00,
MSG_BIND_INDEX = 0x01,
MSG_BIND_END = 0x02,
};
enum msg_rc
{
MSG_OK = 0x00,
MSG_ERR = 0x01,
MSG_CLUSTER_NAME_MISMATCH = 0x02,
MSG_CORRUPT = 0x03,
MSG_UNEXPECTED = 0x04,
MSG_TIMEOUT = 0x05,
MSG_NOT_LEADER = 0x06,
MSG_DISK_FULL = 0x07,
};
// clang-format on
struct resql_result {
uint32_t next_result;
int changes;
int64_t last_row_id;
int row_count;
int remaining_rows;
uint32_t row_pos;
int column_count;
struct sc_buf buf;
struct resql_column *row;
int column_cap;
};
void resql_reset_rows(struct resql_result *rs)
{
sc_buf_set_rpos(&rs->buf, rs->row_pos);
rs->remaining_rows = rs->row_count;
}
bool resql_next(struct resql_result *rs)
{
enum msg_flag flag;
size_t size;
sc_buf_set_rpos(&rs->buf, rs->next_result);
if (sc_buf_get_8(&rs->buf) != MSG_FLAG_OP) {
return false;
}
rs->next_result = sc_buf_rpos(&rs->buf) + sc_buf_get_32(&rs->buf);
rs->row_count = -1;
rs->remaining_rows = -1;
rs->changes = sc_buf_get_32(&rs->buf);
rs->last_row_id = sc_buf_get_64(&rs->buf);
flag = (enum msg_flag) sc_buf_get_8(&rs->buf);
if (flag == MSG_FLAG_ROW) {
rs->column_count = sc_buf_get_32(&rs->buf);
assert(rs->column_cap >= 0);
if (rs->column_count > rs->column_cap) {
size = sizeof(*rs->row) * rs->column_count;
rs->row = resql_realloc(rs->row, size);
rs->column_cap = rs->column_count;
}
for (int i = 0; i < rs->column_count; i++) {
rs->row[i].name = sc_buf_get_str(&rs->buf);
}
rs->row_count = sc_buf_get_32(&rs->buf);
rs->remaining_rows = rs->row_count;
rs->row_pos = sc_buf_rpos(&rs->buf);
return true;
}
return flag == MSG_FLAG_OP_END;
}
struct resql_column *resql_row(struct resql_result *rs)
{
enum resql_type param;
if (rs->remaining_rows <= 0) {
return NULL;
}
rs->remaining_rows--;
for (int i = 0; i < rs->column_count; i++) {
param = (enum resql_type) sc_buf_get_8(&rs->buf);
switch (param) {
case RESQL_INTEGER:
rs->row[i].type = RESQL_INTEGER;
rs->row[i].len = -1;
rs->row[i].intval = sc_buf_get_64(&rs->buf);
break;
case RESQL_FLOAT:
rs->row[i].type = RESQL_FLOAT;
rs->row[i].len = -1;
rs->row[i].floatval = sc_buf_get_double(&rs->buf);
break;
case RESQL_TEXT:
rs->row[i].type = RESQL_TEXT;
rs->row[i].len = sc_buf_peek_32(&rs->buf);
rs->row[i].text = sc_buf_get_str(&rs->buf);
break;
case RESQL_BLOB:
rs->row[i].type = RESQL_BLOB;
rs->row[i].len = sc_buf_get_32(&rs->buf);
rs->row[i].blob = sc_buf_get_blob(
&rs->buf, (uint32_t) rs->row[i].len);
break;
case RESQL_NULL:
rs->row[i].type = RESQL_NULL;
rs->row[i].blob = NULL;
rs->row[i].len = -1;
break;
default:
return false;
break;
}
}
return rs->row;
}
int resql_row_count(struct resql_result *rs)
{
return rs->row_count;
}
int resql_changes(struct resql_result *rs)
{
return rs->changes;
}
int64_t resql_last_row_id(struct resql_result *rs)
{
return rs->last_row_id;
}
int resql_column_count(struct resql_result *rs)
{
return rs->column_count;
}
#define MSG_RC_LEN 1u
#define MSG_MAX_SIZE (2 * 1000 * 1000 * 1000)
#define MSG_SIZE_LEN 4
#define MSG_TYPE_LEN 1
#define MSG_FIXED_LEN (MSG_SIZE_LEN + MSG_TYPE_LEN)
#define MSG_SEQ_LEN 8
#define MSG_READONLY_LEN 1
#define MSG_CLIENT_REQ_HEADER (MSG_FIXED_LEN + MSG_SEQ_LEN + MSG_READONLY_LEN)
#define MSG_RESQL_STR "resql"
#define MSG_REMOTE_CLIENT 0
// clang-format off
enum msg_type
{
MSG_CONNECT_REQ = 0x00,
MSG_CONNECT_RESP = 0x01,
MSG_DISCONNECT_REQ = 0x02,
MSG_DISCONNECT_RESP = 0x03,
MSG_CLIENT_REQ = 0x04,
MSG_CLIENT_RESP = 0x05,
};
// clang-format on
struct msg_connect_resp {
enum msg_rc rc;
uint64_t sequence;
uint64_t term;
const char *nodes;
};
struct msg_disconnect_req {
enum msg_rc rc;
uint32_t flags;
};
struct msg_disconnect_resp {
enum msg_rc rc;
uint32_t flags;
};
struct msg_client_resp {
uint32_t len;
unsigned char *buf;
};
struct msg {
union {
struct msg_connect_resp connect_resp;
struct msg_disconnect_req disconnect_req;
struct msg_disconnect_resp disconnect_resp;
struct msg_client_resp client_resp;
};
enum msg_type type;
uint32_t len;
};
static int msg_len(struct sc_buf *buf)
{
if (sc_buf_size(buf) < MSG_SIZE_LEN) {
return -1;
}
return sc_buf_peek_32(buf);
}
static int msg_parse(struct sc_buf *buf, struct msg *msg)
{
uint32_t len;
void *p;
struct sc_buf tmp;
if (sc_buf_size(buf) < MSG_SIZE_LEN) {
return RESQL_PARTIAL;
}
len = sc_buf_peek_32(buf);
if (len > MSG_MAX_SIZE) {
return RESQL_INVALID;
}
if (len == 0) {
return RESQL_PARTIAL;
}
if (len > sc_buf_size(buf)) {
return RESQL_PARTIAL;
}
p = sc_buf_rbuf(buf);
sc_buf_mark_read(buf, len);
tmp = sc_buf_wrap(p, len, SC_BUF_READ);
msg->len = sc_buf_get_32(&tmp);
msg->type = (enum msg_type) sc_buf_get_8(&tmp);
switch (msg->type) {
case MSG_CONNECT_RESP:
msg->connect_resp.rc = (enum msg_rc) sc_buf_get_8(&tmp);
msg->connect_resp.sequence = sc_buf_get_64(&tmp);
msg->connect_resp.term = sc_buf_get_64(&tmp);
msg->connect_resp.nodes = sc_buf_get_str(&tmp);
break;
case MSG_DISCONNECT_REQ:
msg->disconnect_req.rc = (enum msg_rc) sc_buf_get_8(&tmp);
msg->disconnect_req.flags = sc_buf_get_32(&tmp);
break;
case MSG_DISCONNECT_RESP:
msg->disconnect_resp.rc = (enum msg_rc) sc_buf_get_8(&tmp);
msg->disconnect_resp.flags = sc_buf_get_32(&tmp);
break;
case MSG_CLIENT_RESP:
msg->client_resp.buf = sc_buf_rbuf(&tmp);
msg->client_resp.len = sc_buf_size(&tmp);
break;
default:
return RESQL_ERROR;
break;
}
return sc_buf_valid(&tmp) ? RESQL_OK : RESQL_ERROR;
}
static bool msg_create_connect_req(struct sc_buf *buf, const char *cluster_name,
const char *name)
{
uint32_t head = sc_buf_wpos(buf);
uint32_t len = MSG_SIZE_LEN + MSG_TYPE_LEN +
sc_buf_32_len(MSG_REMOTE_CLIENT) +
sc_buf_str_len(MSG_RESQL_STR) +
sc_buf_str_len(cluster_name) + sc_buf_str_len(name);
sc_buf_put_32(buf, len);
sc_buf_put_8(buf, MSG_CONNECT_REQ);
sc_buf_put_32(buf, MSG_REMOTE_CLIENT);
sc_buf_put_str(buf, MSG_RESQL_STR);
sc_buf_put_str(buf, cluster_name);
sc_buf_put_str(buf, name);
if (!sc_buf_valid(buf)) {
sc_buf_set_wpos(buf, head);
return false;
}
return true;
}
static bool msg_create_disconnect_req(struct sc_buf *buf, enum msg_rc rc,
uint32_t flags)
{
uint32_t head = sc_buf_wpos(buf);
uint32_t len = MSG_FIXED_LEN + MSG_RC_LEN + sc_buf_32_len(flags);
sc_buf_put_32(buf, len);
sc_buf_put_8(buf, MSG_DISCONNECT_REQ);
sc_buf_put_8(buf, rc);
sc_buf_put_32(buf, flags);
if (!sc_buf_valid(buf)) {
sc_buf_set_wpos(buf, head);
return false;
}
return true;
}
static bool msg_create_client_req_header(struct sc_buf *buf)
{
sc_buf_set_wpos(buf, MSG_CLIENT_REQ_HEADER);
return sc_buf_valid(buf);
}
static bool msg_finalize_client_req(struct sc_buf *buf, bool readonly,
uint64_t seq)
{
sc_buf_set_32_at(buf, 0, sc_buf_wpos(buf));
sc_buf_set_8_at(buf, 4, MSG_CLIENT_REQ);
sc_buf_set_8_at(buf, 5, (uint8_t) readonly);
sc_buf_set_64_at(buf, 6, seq);
return sc_buf_valid(buf);
}
struct resql {
char *name;
char *cluster_name;
char *source_addr;
char *source_port;
uint32_t timeout;
bool connected;
bool statement;
bool error;
uint64_t seq;
struct sc_sock sock;
struct sc_uri *uris[16];
int uri_count;
int uri_trial;
uint64_t uri_term;
struct resql_result rs;
struct sc_buf resp;
struct sc_buf req;
struct msg msg;
char err[256];
};
static void resql_disconnect(struct resql *c)
{
if (c->connected) {
c->connected = false;
sc_sock_term(&c->sock);
}
}
static void resql_reset(struct resql *c)
{
c->uri_term = 0;
c->uri_trial = 0;
c->error = false;
c->statement = false;
sc_buf_clear(&c->resp);
resql_disconnect(c);
resql_clear(c);
}
static void resql_err(struct resql *c, const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
vsnprintf(c->err, sizeof(c->err), fmt, va);
va_end(va);
}
static void resql_fatal(struct resql *c, const char *fmt, ...)
{
va_list va;
va_start(va, fmt);
vsnprintf(c->err, sizeof(c->err), fmt, va);
va_end(va);
resql_reset(c);
}
int resql_copy_uris(struct resql *c, struct msg *msg)
{
#define CAP 16
int count = 0;
const char *token;
char *save = NULL, *s;
struct sc_uri *uri;
struct sc_uri *uris[CAP];
if (c->uri_term < msg->connect_resp.term) {
s = sc_str_create(msg->connect_resp.nodes);
if (!s) {
return RESQL_OOM;
}
while ((token = sc_str_token_begin(s, &save, " ")) != NULL) {
uri = sc_uri_create(token);
if (!uri) {
continue;
}
uris[count++] = uri;
if (count == CAP) {
break;
}
}
sc_str_destroy(s);
if (count == 0) {
return RESQL_OK;
}
for (int i = 0; i < c->uri_count; i++) {
sc_uri_destroy(c->uris[i]);
}
memcpy(c->uris, uris, sizeof(uris));
c->uri_count = count;
c->uri_trial = 0;
c->uri_term = msg->connect_resp.term;
}
return RESQL_OK;
}
int resql_recv_connect_resp(struct resql *c)
{
bool b;
int rc, ret;
uint64_t seq;
struct msg msg;
struct sc_buf *resp = &c->resp;
sc_buf_clear(resp);
b = msg_create_connect_req(resp, c->cluster_name, c->name);
if (!b) {
resql_err(c, "out of memory");
return RESQL_FATAL;
}
rc = sc_sock_send(&c->sock, sc_buf_rbuf(resp), sc_buf_size(resp), 0);
if (rc < 0) {
resql_err(c, "sock send failure : %s ", strerror(errno));
return RESQL_ERROR;
}
sc_buf_clear(resp);
retry:
rc = sc_sock_recv(&c->sock, sc_buf_wbuf(resp), sc_buf_quota(resp), 0);
if (rc < 0) {
resql_err(c, "sock recv failure : %s ", strerror(errno));
return RESQL_ERROR;
}
sc_buf_mark_write(resp, (uint32_t) rc);
ret = msg_parse(resp, &msg);
if (ret == RESQL_PARTIAL) {
goto retry;
}
if (ret == RESQL_INVALID || msg.type != MSG_CONNECT_RESP) {
resql_err(c, "received malformed message.");
return RESQL_FATAL;
}
rc = resql_copy_uris(c, &msg);
if (rc != RESQL_OK) {
resql_err(c, "out of memory");
return RESQL_FATAL;
}
rc = msg.connect_resp.rc;
if (rc == MSG_CLUSTER_NAME_MISMATCH) {
resql_err(c, "cluster name mismatch");
return RESQL_FATAL;
}
if (rc != MSG_OK) {
resql_err(c, "connection has been rejected (%d).", rc);
return RESQL_ERROR;
}
if (sc_buf_size(&c->req) == 0) {
c->seq = msg.connect_resp.sequence;
} else {
seq = msg.connect_resp.sequence;
if (seq != c->seq && seq != c->seq - 1) {
resql_err(c,
"Client does not exist on the server "
"anymore.(%" PRIu64 ",%" PRIu64 ")",
seq, c->seq);
c->seq = seq;
return RESQL_FATAL;
}
}
c->connected = true;
return RESQL_OK;
}
int resql_connect(struct resql *c)
{
int rc, family;
const char *host;
struct sc_uri *uri;
if (c->connected) {
c->connected = false;
sc_sock_term(&c->sock);
}
uri = c->uris[c->uri_trial % c->uri_count];
c->uri_trial++;
family = strcmp(uri->scheme, "unix") == 0 ? SC_SOCK_UNIX :
*uri->host == '[' ? SC_SOCK_INET6 :
SC_SOCK_INET;
host = family == SC_SOCK_UNIX ? uri->path : uri->host;
sc_sock_init(&c->sock, 0, false, family);
rc = sc_sock_connect(&c->sock, host, uri->port, c->source_addr,
c->source_port);
if (rc < 0 && errno == EAGAIN) {
struct pollfd fds = {
.fd = c->sock.fdt.fd,
.events = POLLOUT,
};
retry:
rc = rs_poll(&fds, 1, 3000);
if (rc < 0 && errno == EINTR) {
goto retry;
}
rc = (rc != 1) ? -1 : sc_sock_finish_connect(&c->sock);
}
if (rc != 0) {
rc = RESQL_ERROR;
goto sock_error;
}
rc = sc_sock_set_blocking(&c->sock, true);
if (rc != 0) {
goto sock_fatal;
}
rc = sc_sock_set_sndtimeo(&c->sock, 3000);
if (rc != 0) {
goto sock_fatal;
}
rc = sc_sock_set_rcvtimeo(&c->sock, 3000);
if (rc != 0) {
goto sock_fatal;
}
rc = resql_recv_connect_resp(c);
if (rc != RESQL_OK) {
goto cleanup;
}
return RESQL_OK;
sock_fatal:
rc = RESQL_FATAL;
sock_error:
resql_err(c, sc_sock_error(&c->sock));
cleanup:
sc_sock_term(&c->sock);
return rc;
}
int resql_init()
{
return sc_sock_startup();
}
int resql_term()
{
return sc_sock_cleanup();
}
static void resql_generate_name(struct resql *c, char *dest)
{
static char charset[] = "0123456789"
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
unsigned int num, len;
size_t sz = sizeof(c); // NOLINT
uint64_t ts;
uint32_t generated[40] = {0};
char *end, *p = (char *) generated;
ts = sc_time_mono_ms();
num = (unsigned int) ((rand() % 16) + 8 + (ts % 4));
len = (num % 16) + 8;
end = p + (sizeof(generated[0]) * len);
memcpy(p, &c, sz);
p += sz;
memcpy(p, &ts, sizeof(ts));
p += sizeof(ts);
while (p + sizeof(num) < end) {
num = (unsigned int) rand();
memcpy(p, &num, sizeof(num));
p += sizeof(num);
}
for (unsigned int i = 0; i < len; i++) {
dest[i] = charset[generated[i] % (sizeof(charset) - 1)];
}
dest[len] = '\0';
}
int resql_create(struct resql **client, struct resql_config *conf)
{
bool b;
int rc;
uint64_t start;
char *uris, *save = NULL;
const char *token;
char name[32];
const char *user = conf->client_name;
struct resql *c;
struct sc_uri *u;
c = resql_calloc(1, sizeof(*c));
if (!c) {
return RESQL_OOM;
}
if (!conf->client_name) {
resql_generate_name(c, name);
user = name;
}
*client = c;
b = sc_buf_init(&c->resp, 1024);
b |= sc_buf_init(&c->req, 1024);
if (!b) {
goto oom;
}
c->rs = (struct resql_result){0};
c->name = sc_str_create(user);
c->cluster_name = sc_str_create(
conf->cluster_name ? conf->cluster_name : "cluster");
c->source_addr = sc_str_create(conf->outgoing_addr);
c->source_port = sc_str_create(conf->outgoing_port);
if (!c->name || !c->cluster_name ||
(!c->source_addr && conf->outgoing_addr) ||
(!c->source_port && conf->outgoing_port)) {
goto oom;
}
c->timeout = conf->timeout_millis != 0 ? conf->timeout_millis :
UINT32_MAX;
c->uri_count = 0;
c->uri_trial = 0;
uris = sc_str_create(conf->urls ? conf->urls : "tcp://127.0.0.1:7600");
if (!uris) {
goto oom;
}
while ((token = sc_str_token_begin(uris, &save, " ")) != NULL) {
u = sc_uri_create(token);
if (u == NULL) {
rc = RESQL_CONFIG_ERROR;
resql_err(c, "Cannot parse : %s", token);
sc_str_destroy(uris);
goto error;
}
c->uris[c->uri_count++] = u;
if (c->uri_count + 1 ==
sizeof(c->uris) / sizeof(struct sc_uri *)) {
break;
}
}
sc_str_token_end(uris, &save);
sc_str_destroy(uris);
*client = c;
start = sc_time_mono_ms();
while (true) {
if (sc_time_mono_ms() - start > c->timeout) {
return RESQL_ERROR;
}
rc = resql_connect(c);
if (rc == RESQL_OK) {
break;
}
if (rc == RESQL_FATAL) {
resql_reset(c);
return RESQL_ERROR;
}
sc_time_sleep(500);
}
resql_clear(c);
return RESQL_OK;
oom:
rc = RESQL_OOM;
resql_err(c, "Out of memory.");
error:
return rc;
}
int resql_shutdown(struct resql *c)
{
if (!c) {
return RESQL_OK;
}
if (c->connected) {
sc_buf_clear(&c->req);
msg_create_disconnect_req(&c->req, MSG_OK, 0);
sc_sock_send(&c->sock, sc_buf_rbuf(&c->req),
sc_buf_size(&c->req), 0);
sc_sock_term(&c->sock);
}
sc_str_destroy(c->name);
sc_str_destroy(c->cluster_name);
sc_str_destroy(c->source_addr);
sc_str_destroy(c->source_port);
for (int i = 0; i < c->uri_count; i++) {
sc_uri_destroy(c->uris[i]);
}
c->uri_count = 0;
resql_free(c->rs.row);
sc_buf_term(&c->req);
sc_buf_term(&c->resp);
resql_free(c);
return RESQL_OK;
}
const char *resql_errstr(struct resql *c)
{
c->err[sizeof(c->err) - 1] = '\0';
return c->err;
}
int resql_send_req(struct resql *c, struct sc_buf *resp)
{
bool b;
int rc, n;
uint8_t flag;
uint64_t start = sc_time_mono_ms();
retry_op:
if (sc_time_mono_ms() - start > c->timeout) {
resql_err(c, "Operation timeout.");
return RESQL_ERROR;
}
if (!c->connected) {
rc = resql_connect(c);
if (rc == RESQL_FATAL) {
resql_reset(c);
return RESQL_ERROR;
}
if (rc != RESQL_OK) {
sc_time_sleep(500);
goto retry_op;
}
}
n = sc_sock_send(&c->sock, sc_buf_rbuf(&c->req), sc_buf_size(&c->req),
0);
if (n < 0) {
c->connected = false;
sc_sock_term(&c->sock);
goto retry_op;
}
sc_buf_clear(&c->resp);
retry_recv:
n = sc_sock_recv(&c->sock, sc_buf_wbuf(&c->resp),
sc_buf_quota(&c->resp), 0);
if (n <= 0) {
c->connected = false;
sc_sock_term(&c->sock);
goto retry_op;
}
sc_buf_mark_write(&c->resp, (uint32_t) n);
rc = msg_parse(&c->resp, &c->msg);
if (rc == RESQL_PARTIAL) {
rc = msg_len(&c->resp);
if (rc != -1) {
b = sc_buf_reserve(&c->resp, (uint32_t) rc);
if (!b) {
resql_fatal(c, "Out of memory.");
return RESQL_ERROR;
}
}
goto retry_recv;
}
resql_clear(c);
if (rc == RESQL_ERROR || rc == RESQL_INVALID) {
resql_fatal(c, "Out of memory.");
return RESQL_ERROR;
}
*resp = sc_buf_wrap(c->msg.client_resp.buf, c->msg.client_resp.len,
SC_BUF_READ);
flag = sc_buf_get_8(resp);
if (flag == MSG_FLAG_ERROR) {
resql_err(c, sc_buf_get_str(resp));
return RESQL_SQL_ERROR;
}
return RESQL_OK;
}
int resql_prepare(struct resql *c, const char *sql, resql_stmt *stmt)
{
int rc;
enum msg_flag flag;
uint32_t size;
uint64_t id;
struct sc_buf tmp;
if (c->statement) {
resql_err(c, "'Prepare' must be a single operation.");
resql_clear(c);
return RESQL_SQL_ERROR;
}
sc_buf_put_8(&c->req, MSG_FLAG_OP);
sc_buf_put_8(&c->req, MSG_FLAG_STMT_PREPARE);
sc_buf_put_str(&c->req, sql);
sc_buf_put_8(&c->req, MSG_FLAG_OP_END);
sc_buf_put_8(&c->req, MSG_FLAG_MSG_END);
c->seq++;
msg_finalize_client_req(&c->req, false, c->seq);
sc_buf_set_rpos(&c->req, 0);
rc = resql_send_req(c, &tmp);
if (rc != RESQL_OK) {
return rc;
}
flag = sc_buf_get_8(&tmp);
if (flag != MSG_FLAG_OP) {
goto error;
}
size = sc_buf_get_32(&tmp);
(void) size;
id = sc_buf_get_64(&tmp);
if (!sc_buf_valid(&tmp)) {
goto error;
}
if (sc_buf_get_8(&tmp) != MSG_FLAG_OP_END &&
sc_buf_get_8(&tmp) != MSG_FLAG_MSG_END) {
goto error;
}
*stmt = id;
return RESQL_OK;
error:
resql_fatal(c, "Received malformed response");
return RESQL_ERROR;
}
int resql_del_prepared(struct resql *c, resql_stmt *stmt)
{
int rc;
uint8_t flag;
uint32_t size;
struct sc_buf tmp;
if (c->statement) {
resql_err(c, "'Delete prepared' must be a single operation.");
resql_clear(c);
return RESQL_SQL_ERROR;
}
sc_buf_put_8(&c->req, MSG_FLAG_OP);
sc_buf_put_8(&c->req, MSG_FLAG_STMT_DEL_PREPARED);
sc_buf_put_64(&c->req, *stmt);
sc_buf_put_8(&c->req, MSG_FLAG_OP_END);
sc_buf_put_8(&c->req, MSG_FLAG_MSG_END);
c->seq++;
msg_finalize_client_req(&c->req, false, c->seq);
sc_buf_set_rpos(&c->req, 0);
*stmt = 0;
rc = resql_send_req(c, &tmp);
if (rc != RESQL_OK) {
return rc;
}
flag = sc_buf_get_8(&tmp);
if (flag != MSG_FLAG_OP) {
goto error;
}
size = sc_buf_get_32(&tmp);
(void) size;
if (sc_buf_get_8(&tmp) != MSG_FLAG_OP_END &&
sc_buf_get_8(&tmp) != MSG_FLAG_MSG_END) {
goto error;
}
return RESQL_OK;
error:
resql_fatal(c, "Received malformed response");
return RESQL_ERROR;
}
void resql_bind_param_int(resql *c, const char *param, int64_t val)
{
if (!c->statement) {
c->error = true;
resql_err(c, "missing statement before binding");
return;
}
sc_buf_put_8(&c->req, MSG_BIND_NAME);
sc_buf_put_str(&c->req, param);
sc_buf_put_8(&c->req, MSG_BIND_INTEGER);
sc_buf_put_64(&c->req, (uint64_t) val);
}
void resql_bind_param_float(resql *c, const char *param, double val)
{
if (!c->statement) {
c->error = true;
resql_err(c, "missing statement before binding");
return;
}
sc_buf_put_8(&c->req, MSG_BIND_NAME);
sc_buf_put_str(&c->req, param);
sc_buf_put_8(&c->req, MSG_BIND_FLOAT);
sc_buf_put_double(&c->req, val);
}
void resql_bind_param_text(resql *c, const char *param, const char *val)
{
if (!c->statement) {
c->error = true;
resql_err(c, "missing statement before binding");
return;
}
sc_buf_put_8(&c->req, MSG_BIND_NAME);
sc_buf_put_str(&c->req, param);
sc_buf_put_8(&c->req, MSG_BIND_TEXT);
sc_buf_put_str(&c->req, val);
}
void resql_bind_param_blob(resql *c, const char *param, int len, void *data)
{
if (!c->statement) {
c->error = true;
resql_err(c, "missing statement before binding");
return;
}
sc_buf_put_8(&c->req, MSG_BIND_NAME);
sc_buf_put_str(&c->req, param);
sc_buf_put_8(&c->req, MSG_BIND_BLOB);
sc_buf_put_blob(&c->req, data, (uint32_t) len);
}
void resql_bind_param_null(resql *c, const char *param)
{
if (!c->statement) {
c->error = true;
resql_err(c, "missing statement before binding");
return;
}
sc_buf_put_8(&c->req, MSG_BIND_NAME);
sc_buf_put_str(&c->req, param);
sc_buf_put_8(&c->req, MSG_BIND_NULL);
}
void resql_bind_index_int(resql *c, int index, int64_t val)
{
if (!c->statement) {
c->error = true;
resql_err(c, "missing statement before binding");
return;
}
sc_buf_put_8(&c->req, MSG_BIND_INDEX);
sc_buf_put_32(&c->req, (uint32_t) index);
sc_buf_put_8(&c->req, MSG_BIND_INTEGER);
sc_buf_put_64(&c->req, (uint64_t) val);
}
void resql_bind_index_float(resql *c, int index, double val)
{
if (!c->statement) {
c->error = true;
resql_err(c, "missing statement before binding");
return;
}
sc_buf_put_8(&c->req, MSG_BIND_INDEX);
sc_buf_put_32(&c->req, (uint32_t) index);
sc_buf_put_8(&c->req, MSG_BIND_FLOAT);
sc_buf_put_double(&c->req, val);
}
void resql_bind_index_text(resql *c, int index, const char *val)
{
if (!c->statement) {
c->error = true;
resql_err(c, "missing statement before binding");
return;
}
sc_buf_put_8(&c->req, MSG_BIND_INDEX);
sc_buf_put_32(&c->req, (uint32_t) index);
sc_buf_put_8(&c->req, MSG_BIND_TEXT);
sc_buf_put_str(&c->req, val);
}
void resql_bind_index_blob(resql *c, int index, int len, void *data)
{
if (!c->statement) {
c->error = true;
resql_err(c, "missing statement before binding");
return;
}
sc_buf_put_8(&c->req, MSG_BIND_INDEX);
sc_buf_put_32(&c->req, (uint32_t) index);
sc_buf_put_8(&c->req, MSG_BIND_BLOB);
sc_buf_put_blob(&c->req, data, (uint32_t) len);
}
void resql_bind_index_null(resql *c, int index)
{
if (!c->statement) {
c->error = true;
resql_err(c, "missing statement before binding");
return;
}
sc_buf_put_8(&c->req, MSG_BIND_INDEX);
sc_buf_put_32(&c->req, (uint32_t) index);
sc_buf_put_8(&c->req, MSG_BIND_NULL);
}
void resql_put_prepared(struct resql *c, const resql_stmt *stmt)
{
if (c->statement) {
sc_buf_put_8(&c->req, MSG_BIND_END);
sc_buf_put_8(&c->req, MSG_FLAG_OP_END);
}
sc_buf_put_8(&c->req, MSG_FLAG_OP);
sc_buf_put_8(&c->req, MSG_FLAG_STMT_ID);
sc_buf_put_64(&c->req, *stmt);
c->statement = true;
}
void resql_put_sql(struct resql *c, const char *sql)
{
if (c->statement) {
sc_buf_put_8(&c->req, MSG_BIND_END);
sc_buf_put_8(&c->req, MSG_FLAG_OP_END);
}
sc_buf_put_8(&c->req, MSG_FLAG_OP);
sc_buf_put_8(&c->req, MSG_FLAG_STMT);
sc_buf_put_str(&c->req, sql);
c->statement = true;
}
int resql_exec(struct resql *c, bool readonly, struct resql_result **rs)
{
int rc = RESQL_SQL_ERROR;
struct sc_buf tmp;
*rs = NULL;
if (!c->statement) {
resql_err(c, "Missing statement.");
goto error;
}
if (c->error) {
goto error;
}
if (!sc_buf_valid(&c->req)) {
resql_err(c, "Out of memory!.");
goto error;
}
sc_buf_put_8(&c->req, MSG_BIND_END);
sc_buf_put_8(&c->req, MSG_FLAG_OP_END);
sc_buf_put_8(&c->req, MSG_FLAG_MSG_END);
c->statement = false;
if (!readonly) {
c->seq++;
}
msg_finalize_client_req(&c->req, readonly, c->seq);
sc_buf_set_rpos(&c->req, 0);
rc = resql_send_req(c, &tmp);
if (rc != RESQL_OK) {
goto error;
}
c->rs.buf = tmp;
c->rs.next_result = sc_buf_rpos(&c->rs.buf);
resql_next(&c->rs);
*rs = &c->rs;
return RESQL_OK;
error:
resql_clear(c);
return rc;
}
void resql_clear(struct resql *c)
{
c->error = false;
c->statement = false;
sc_buf_clear(&c->req);
msg_create_client_req_header(&c->req);
}
| 19.200472 | 80 | 0.645191 |
cb2309db11e399a585882d722c33a4cc6a04e8e4 | 1,419 | h | C | head/thulac/thulac_segment.h | thunlp/THUCKE | 3a82e599f1fc07b8a12437abb1a50dfe391b5b36 | [
"MIT"
] | 118 | 2017-02-09T09:45:06.000Z | 2022-03-31T18:28:01.000Z | head/thulac/thulac_segment.h | thunlp/THUCKE | 3a82e599f1fc07b8a12437abb1a50dfe391b5b36 | [
"MIT"
] | 9 | 2017-01-17T02:12:26.000Z | 2022-03-19T08:10:22.000Z | head/thulac/thulac_segment.h | thunlp/THUCKE | 3a82e599f1fc07b8a12437abb1a50dfe391b5b36 | [
"MIT"
] | 17 | 2016-11-14T08:45:13.000Z | 2021-05-09T12:29:30.000Z | #include "timeword.h"
#include "verbword.h"
#include "negword.h"
using namespace thulac;
class CThulacSegment{
Character separator;
bool useT2S;
bool seg_only;
bool useFilter;
std::string prefix;
/*
permm::Model* cws_model;
DAT* cws_dat;
char** cws_label_info;
int** cws_pocs_to_tags;
*/
permm::Model* tagging_model;
DAT* tagging_dat;
char** tagging_label_info;
int** tagging_pocs_to_tags;
Preprocesser* preprocesser;
Postprocesser* ns_dict;
Postprocesser* user_dict;
Postprocesser* idiom_dict;
Punctuation* punctuation;
NegWord* negword;
TimeWord* timeword;
VerbWord* verbword;
Filter* filter;
public:
CThulacSegment():
separator ('_'),
useT2S (false),
seg_only (false),
useFilter (false),
/*
cws_model (NULL),
cws_dat (NULL),
cws_label_info (NULL),
cws_pocs_to_tags (NULL),
*/
tagging_model (NULL),
tagging_dat (NULL),
tagging_label_info (NULL),
tagging_pocs_to_tags (NULL),
preprocesser (NULL),
ns_dict (NULL),
idiom_dict (NULL),
timeword (NULL),
negword (NULL),
verbword (NULL),
punctuation (NULL),
filter(NULL){}
~CThulacSegment();
bool Init(std::string inPath);
void setT2S(bool needT2S);
void setDelimiter(char ch);
void setOnlySeg(bool onlySeg);
void setUseFilter(bool usefilter);
bool addUserDict(std::string inPath, std::string inTag);
std::string segment(std::string inText);
void get_pocs_to_tags(const char*);
};
| 17.962025 | 57 | 0.717407 |
3bc1d2e011fd235d5c786c7f7fb5f55936906d31 | 364 | h | C | JEngine/Timing.h | hariudkmr/zombie_project | 70c88d59d687bbc73fb9c12bb921e59881d72cfb | [
"MIT"
] | null | null | null | JEngine/Timing.h | hariudkmr/zombie_project | 70c88d59d687bbc73fb9c12bb921e59881d72cfb | [
"MIT"
] | null | null | null | JEngine/Timing.h | hariudkmr/zombie_project | 70c88d59d687bbc73fb9c12bb921e59881d72cfb | [
"MIT"
] | null | null | null | #pragma once
namespace JEngine {
class FpsLimiter {
public:
FpsLimiter();
void init(float targetFps);
void setTargetFPS(float targetFps);
void begin();
// will return FPS
float end();
private:
// float _timeElapsed;
float _fps;
float _frameTime;
float _targetFps;
unsigned int _startTicks;
};
} // namespace JEngine | 15.826087 | 38 | 0.659341 |
b474bda6912c064f5d11ab1401276fed977f5a28 | 3,781 | c | C | quantum/process_keycode/process_auto_shift.c | fzf/qmk_toolbox | 10d6b425bd24b45002555022baf16fb11254118b | [
"MIT"
] | null | null | null | quantum/process_keycode/process_auto_shift.c | fzf/qmk_toolbox | 10d6b425bd24b45002555022baf16fb11254118b | [
"MIT"
] | null | null | null | quantum/process_keycode/process_auto_shift.c | fzf/qmk_toolbox | 10d6b425bd24b45002555022baf16fb11254118b | [
"MIT"
] | null | null | null | /* Copyright 2017 Jeremy Cowgar
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef AUTO_SHIFT_ENABLE
# include <stdio.h>
# include "process_auto_shift.h"
static bool autoshift_enabled = true;
static uint16_t autoshift_time = 0;
static uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT;
static uint16_t autoshift_lastkey = KC_NO;
void autoshift_timer_report(void) {
char display[8];
snprintf(display, 8, "\n%d\n", autoshift_timeout);
send_string((const char *)display);
}
void autoshift_on(uint16_t keycode) {
autoshift_time = timer_read();
autoshift_lastkey = keycode;
}
void autoshift_flush(void) {
if (autoshift_lastkey != KC_NO) {
uint16_t elapsed = timer_elapsed(autoshift_time);
if (elapsed > autoshift_timeout) {
tap_code16(LSFT(autoshift_lastkey));
} else {
tap_code(autoshift_lastkey);
}
autoshift_time = 0;
autoshift_lastkey = KC_NO;
}
}
void autoshift_enable(void) { autoshift_enabled = true; }
void autoshift_disable(void) {
autoshift_enabled = false;
autoshift_flush();
}
void autoshift_toggle(void) {
if (autoshift_enabled) {
autoshift_enabled = false;
autoshift_flush();
} else {
autoshift_enabled = true;
}
}
bool get_autoshift_state(void) { return autoshift_enabled; }
uint16_t get_autoshift_timeout(void) { return autoshift_timeout; }
void set_autoshift_timeout(uint16_t timeout) { autoshift_timeout = timeout; }
bool process_auto_shift(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch (keycode) {
case KC_ASUP:
autoshift_timeout += 5;
return true;
case KC_ASDN:
autoshift_timeout -= 5;
return true;
case KC_ASRP:
autoshift_timer_report();
return true;
case KC_ASTG:
autoshift_toggle();
return true;
case KC_ASON:
autoshift_enable();
return true;
case KC_ASOFF:
autoshift_disable();
return true;
# ifndef NO_AUTO_SHIFT_ALPHA
case KC_A ... KC_Z:
# endif
# ifndef NO_AUTO_SHIFT_NUMERIC
case KC_1 ... KC_0:
# endif
# ifndef NO_AUTO_SHIFT_SPECIAL
case KC_TAB:
case KC_MINUS ... KC_SLASH:
case KC_NONUS_BSLASH:
# endif
autoshift_flush();
if (!autoshift_enabled) return true;
# ifndef AUTO_SHIFT_MODIFIERS
if (get_mods()) {
return true;
}
# endif
autoshift_on(keycode);
// We need some extra handling here for OSL edge cases
# if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING)
clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
# endif
return false;
default:
autoshift_flush();
return true;
}
} else {
autoshift_flush();
}
return true;
}
#endif
| 26.815603 | 77 | 0.613859 |
fe9b015a852f19be215417ae23c84a559931ace3 | 463 | h | C | BookDataStore.framework/BDSOSTransaction.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | 4 | 2021-10-06T12:15:26.000Z | 2022-02-21T02:26:00.000Z | BookDataStore.framework/BDSOSTransaction.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | null | null | null | BookDataStore.framework/BDSOSTransaction.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/BookDataStore.framework/BookDataStore
*/
@interface BDSOSTransaction : NSObject {
NSObject<OS_os_transaction> * _osTransaction;
}
@property (nonatomic, retain) NSObject<OS_os_transaction> *osTransaction;
- (void).cxx_destruct;
- (void)dealloc;
- (void)endTransaction;
- (id)initWithTransactionName:(const char *)arg1;
- (id)osTransaction;
- (void)setOsTransaction:(id)arg1;
@end
| 24.368421 | 81 | 0.766739 |
f2add55d762a11bc5737398554981a9b6516ae37 | 21,269 | c | C | Json4C/Json4C.c | qisijie/Json4C | d248dec800f374192cb173a7fc108216e389e43d | [
"MIT"
] | null | null | null | Json4C/Json4C.c | qisijie/Json4C | d248dec800f374192cb173a7fc108216e389e43d | [
"MIT"
] | null | null | null | Json4C/Json4C.c | qisijie/Json4C | d248dec800f374192cb173a7fc108216e389e43d | [
"MIT"
] | null | null | null | // Json4C.c: 定义应用程序的入口点。
//
#include "Json4C.h"
static void* (*Json4C_malloc)(size_t sz) = malloc;
static void (*Json4C_free)(void* ptr) = free;
static const char* endPosition;
char* Json4C_GetEndPosition()
{
return endPosition;
}
Json4C* Json4C_New_Item()
{
Json4C* node = (Json4C*)Json4C_malloc(sizeof(Json4C));
if (node)
memset(node, 0, sizeof(Json4C));
return node;
}
const char* skip(const char* in)
{
while (in && *in && (unsigned char)*in <= 32)
in++;
return in;
}
void Json4C_Detele(Json4C* c)
{
Json4C* next;
while (c)
{
next = c->next;
if (c->child)
Json4C_Detele(c->child);
if (c->valueString)
Json4C_free(c->valueString);
if(c->string)
Json4C_free(c->string);
Json4C_free(c);
c = next;
}
}
const char* parse_string(Json4C* item, const char* str)
{
const char* ptr = str + 1;
char* ptr2;
char* out;
int lenth = 0;
if (*str != '\"')
{
endPosition = str;
return NULL;
}
while (*ptr != '\"' && *ptr && ++lenth)
{
if (*ptr++ == '\\')
ptr++;
}
out = (char*)Json4C_malloc(lenth + 1);
if (!out)
return NULL;
ptr = str + 1;
ptr2 = out;
while (*ptr != '\"' && *ptr)
{
if (*ptr != '\\')
*ptr2++ = *ptr++;
else
{
ptr++;
switch (*ptr)
{
case 'a':
*ptr2++ = '\a';
break;
case 'b':
*ptr2++ = '\b';
break;
case 'f':
*ptr2++ = '\f';
break;
case 'n':
*ptr2++ = '\n';
break;
case 'r':
*ptr2++ = '\r';
break;
case 't':
*ptr2++ = '\t';
break;
case 'v':
*ptr2++ = '\v';
break;
default:
*ptr2++ = *ptr;
break;
}
ptr++;
}
}
*ptr2 = 0;
if (*ptr == '\"')
ptr++;
item->valueString = out;
item->tpye = Json4C_String;
return ptr;
}
const char* parse_number(Json4C* item, const char* num)
{
double n = 0;//最终的数字
int sign = 1;//正负号
int signSubScale = 1;
int scale = 0;
int subscale = 1;
if (*num == '-')
{
sign = -1;
num++;
}
if (*num == '0')
num++;
if (*num >= '0' && *num <= '9')
{
//eg.123
do
{
n = (n * 10.0) + (*num++ - '0');
} while (*num >= '0' && *num <= '9');
}
if (*num == '.' && num[1] >= '0' && num[1] <= '9')
{
//eg.123.456
num++;
do
{
n = (n * 10.0) + (*num++ - '0');
scale--;
} while (*num >= '0' && *num <= '9');
}
if (*num == 'e' || *num == 'E')
{
//eg.123e456 123e-456
num++;
if (*num == '+')
num++;
else if (*num == '-')
{
signSubScale = -1;
num++;
}
do
{
subscale = (subscale * 10.0) + (*num++ - '0');
} while (*num >= '0' && *num <= '9');
}
n = sign * n * pow(10.0, (scale + signSubScale * subscale));
item->valueDouble = n;
item->valueInt = (int)n;
item->tpye = Json4C_Number;
return num;
}
const char* parse_array(Json4C* item, const char* value)
{
//eg.["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
Json4C* child;
if (*value != '[')
{
endPosition = value;
return NULL;
}
item->tpye = Json4C_Array;
value = skip(value + 1);
if (*value == ']')//防止[]的出现
return value + 1;
item->child = child = Json4C_New_Item();
if (!item->child)
return NULL;
value = skip(parse_value(child,skip(value)));
if (!value)
return NULL;
while (*value == ',')
{
Json4C* new_item;
if (!(new_item = Json4C_New_Item()))
return NULL;
child->next = new_item;
new_item->prev = child;
child = new_item;
value = skip(parse_value(child, skip(value + 1)));
if (!value)
return NULL;
}
if (*value == ']')
return value + 1;
endPosition = value;
return NULL;
}
const char* parse_object(Json4C* item, const char* value)
{
Json4C* child;
if (*value != '{')
{
endPosition = value;
return NULL;
}
item->tpye = Json4C_Object;
value = skip(value + 1);
if (*value == '}')
return value + 1;
item->child = child = Json4C_New_Item();
if (!item->child)
return NULL;
value = skip(parse_string(child, skip(value)));
if (!value)
return NULL;
child->string = child->valueString;
child->valueString = NULL;
if (*value != ':')
{
endPosition = value;
return NULL;
}
value = skip(parse_value(child, skip(value + 1)));
if (!value)
return NULL;
while (*value == ',')
{
Json4C* new_item;
if (!(new_item = Json4C_New_Item()))
return NULL;
child->next = new_item;
new_item->prev = child;
child = new_item;
value = skip(parse_string(child, skip(value + 1)));
if (!value)
return NULL;
child->string = child->valueString;
child->valueString = NULL;
if (*value != ':')
{
endPosition = value;
return NULL;
}
value = skip(parse_value(child, skip(value + 1)));
if (!value)
return NULL;
}
if (*value == '}')
return value + 1;
endPosition = value;
return NULL;
}
const char* parse_value(Json4C* item, const char* value)
{
if (!value)
return NULL;
if (!strncmp(value, "false", 5))
{
item->tpye = Json4C_False;
return value + 5;
}
if (!strncmp(value, "true", 4))
{
item->tpye = Json4C_True;
item->valueInt = 1;
return value + 4;
}
if (!strncmp(value, "null", 4))
{
item->tpye = Json4C_Null;
return value + 4;
}
if (*value == '\"')
return parse_string(item, value);
if (*value == '-' || (*value >= '0' && *value <= '9'))
return parse_number(item, value);
if (*value == '[')
return parse_array(item, value);
if (*value == '{')
return parse_object(item, value);
endPosition = value;
return NULL;
}
Json4C* Json4C_Parse(const char* value)
{
return Json4C_ParseWithOptions(value, 0, 0);
}
Json4C* Json4C_ParseWithOptions(const char* value,const char** return_parse_end,int require_null_terminated)
{
const char* end = NULL;
Json4C* c = Json4C_New_Item();
endPosition = NULL;
if (!c)
return NULL;
end = parse_value(c,skip(value));
if (!end)
{
Json4C_Detele(c);
return NULL;
}
if (require_null_terminated)
{
end = skip(end);
if (*end)
{
Json4C_Detele(c);
endPosition = end;
return NULL;
}
}
if (return_parse_end)
{
*return_parse_end = end;
}
return c;
}
//---------------------------------------------
char* print_value(Json4C* item, int deepth, int fmt)
{
char* out = NULL;
if (!item)
return NULL;
switch ((item->tpye) & 255)
{
case Json4C_False:
out = Json4C_strdup("false");
break;
case Json4C_True:
out = Json4C_strdup("true");
break;
case Json4C_Null:
out = Json4C_strdup("null");
break;
case Json4C_Number:
out = print_number(item);
break;
case Json4C_String:
out = print_string(item,0);
break;
case Json4C_Array:
out = print_array(item,deepth,fmt);
break;
case Json4C_Object:
out = print_object(item, deepth, fmt);
break;
default:
break;
}
}
char* Json4C_strdup(const char* str)
{
char* copy = NULL;
size_t lenth;
lenth = strlen(str);
copy = (char*)Json4C_malloc(lenth + 1);
if (!copy)
return NULL;
memcpy(copy, str, lenth + 1);
return copy;
}
char* print_number(Json4C* item)
{
char* str = NULL;
double dbl = item->valueDouble;
if (dbl == 0)
{
str = (char*)Json4C_malloc(2);
if (str)
strcpy(str, "0");
}
//整数
else if ((fabs((double)(item->valueInt) - dbl) <= DBL_EPSILON) && dbl <= INT_MAX && dbl >= INT_MAX)
{
str = (char*)Json4C_malloc(21);
if (str)
sprintf(str, "%d", item->valueInt);
}
//浮点数
else
{
str = (char*)Json4C_malloc(64);
if (str)
{
//123.456
if (fabs(fabs(dbl) - dbl) <= DBL_EPSILON && fabs(dbl) < 1.0e60)
sprintf(str, "%.0f", dbl);
else if (fabs(dbl) < 1.0e-6 || fabs(1.0e9))
sprintf(str, "%e", dbl);
else
sprintf(str, "%f", dbl);
}
}
return str;
}
char* print_string(Json4C* item, int isName)
{
char* str = (isName > 1) ? item->valueString : item->string;
char* ptr, * ptr2, * out;
unsigned char token;
int flag = 0,lenth = 0;
for (ptr = str; *ptr; ptr++)
{
flag |= (*ptr > 0 && *ptr < 32) || (*ptr == '\"') || (*ptr == '\\') ? 1 : 0;
}
if (!flag)
{
lenth = ptr - str;
out = (char*)Json4C_malloc(lenth + 2 + 1);//2给"",1给\0
if (!out)
return NULL;
ptr2 = out;
*ptr2++ = '\"';
strcpy(ptr2, str);
ptr2[lenth] = '\"';
ptr2[lenth + 1] = '\0';
return out;
}
if (!str)
{
out = (char*)Json4C_malloc(3);
if (!out)
return NULL;
strcpy(out, "\"\"");
return out;
}
ptr = str;
while ((token = *ptr) && ++lenth)
{
//printf("i am in while");
if (strchr("\a\b\f\n\r\t\v\\\'\"\?", token))
lenth++;
else if (token < 32)
{
lenth += 5;
ptr++;
}
}
out = (char*)Json4C_malloc(lenth + 3);
if (!out)
return NULL;
ptr2 = out;
ptr = str;
*ptr2++ = '\"';
while (*ptr)
{
if ((unsigned char)*ptr > 31 && *ptr != '\"' && *ptr != '\\')
{
*ptr2 = *ptr++;
}
else
{
*ptr2 = '\\';
switch (token = *ptr)
{
case '\a':
*ptr2++ = '\a';
break;
case '\b':
*ptr2++ = '\b';
break;
case '\f':
*ptr2++ = '\f';
break;
case '\n':
*ptr2++ = '\n';
break;
case '\r':
*ptr2++ = '\r';
break;
case '\t':
*ptr2++ = '\t';
break;
case '\v':
*ptr2++ = '\v';
break;
case '\\':
*ptr2++ = '\\';
break;
case '\'':
*ptr2++ = '\'';
break;
case '\"':
*ptr2++ = '\"';
break;
case '\?':
*ptr2++ = '\?';
break;
default:
sprintf(str, "u%04x", token);
ptr2++;
break;
}
}
}
*ptr2++ = '\"';
*ptr2++ = '\0';
return out;
}
char* print_array(Json4C* item, int deepth, int fmt)
{
char** entries;//char *entries[];
char* out = NULL, * ptr, * ret;
int lenth = 5, i = 0, isFail = 0, templenth = 0;//"[]"\0 共5个
Json4C* child = item->child;
int numEntries = 0;
while (child)
{
//广度优先
numEntries++;
child = child->next;
}
if (!numEntries)
{
out = (char*)Json4C_malloc(3);//[]\0 共3个
if (out)
strcpy(out, "[]");
return 0;
}
entries = (char**)Json4C_malloc(numEntries * sizeof(char*));
if (!entries)
return NULL;
memset(entries, 0, numEntries * sizeof(char*));
child = item->child;
while (child)
{
ret = print_value(child, deepth + 1, fmt);
entries[i++] = ret;
if (ret)
lenth += strlen(ret) + 2 + (fmt ? 1 : 0);
else
{
isFail = 1;
}
child = child->next;
}
if (!isFail)
out = (char*)Json4C_malloc(lenth);
if (!out)
isFail = 1;
if (isFail)
{
for (i = 0; i < numEntries; i++)
{
if (entries[i])
Json4C_free(entries[i]);
}
Json4C_free(entries);
return NULL;
}
*out = '[';
ptr = out + 1;
*ptr = '\0';
for (int i = 0; i < numEntries; i++)
{
templenth = strlen(entries[i]);
memcpy(ptr, entries[i], templenth);
ptr += templenth;
if (i != numEntries - 1)
{
*ptr++ = ',';
if (fmt)
*ptr++ = ' ';
*ptr = '\0';
}
Json4C_free(entries[i]);
}
Json4C_free(entries);
*ptr++ = ']';
*ptr++ = '\0';
return out;
}
char* print_object(Json4C* item, int deepth, int fmt)
{
char** entries = NULL, ** names = NULL;
char* out = NULL, * ptr, * ret, * str;
int lenth = 7, i = 0, isFail = 0, templenth = 0;//"{\n\t}"\0 共7个
Json4C* child = item->child;
int numEntries = 0;
while (child)
{
numEntries++;
child = child->next;
}
if (!numEntries)
{
out = (char*)Json4C_malloc(fmt ? deepth + 4 : 3);
if (!out)
return NULL;
ptr = out;
*ptr++ = '{';
if (fmt)
{
*ptr++ = '\n';
for (i = 0; i < deepth - 1; i++)
{
*ptr++ = '\t';
}
}
*ptr++ = '}';
*ptr++ = '\0';
return out;
}
entries = (char**)Json4C_malloc(numEntries * sizeof(char*));
if (!entries)
return NULL;
names = (char**)Json4C_malloc(numEntries * sizeof(char*));
if (!names)
{
Json4C_free(entries);
return NULL;
}
memset(entries, 0, numEntries * sizeof(char*));
memset(names, 0, numEntries * sizeof(char*));
child = item->child;
deepth++;
if (fmt)
lenth += deepth;
while (child)
{
names[i] = str = print_string(child,1);
entries[i++] = ret = print_value(child, deepth, fmt);
if (str && ret)
lenth += strlen(ret) + strlen(str) + 2 + (fmt ? 2 + deepth : 0);//"" 共2个
else
isFail = 1;
child = child->next;
}
if (!isFail)
out = (char*)Json4C_malloc(lenth);
if (!out)
isFail = 1;
if (isFail)
{
for (i = 0; i < numEntries; i++)
{
if (names[i])
Json4C_free(names[i]);
if (entries[i])
Json4C_free(entries[i]);
}
Json4C_free(names);
Json4C_free(entries);
return NULL;
}
*out = '{';
ptr = out + 1;
if (fmt)
*ptr++ = '\n';
*ptr = '\0';
for (i = 0; i < numEntries; i++)
{
if (fmt)
for (int j = 0; j < deepth; j++)
*ptr++ = '\t';
templenth = strlen(names[i]);
memcpy(ptr, names[i], templenth);
ptr += templenth;
*ptr++ = ':';
if (fmt)
*ptr++ = '\t';
strcpy(ptr, entries[i]);
ptr += strlen(entries[i]);
if (i != numEntries - 1)
*ptr++ = ',';
if (fmt)
*ptr++ = '\n';
*ptr = '\0';
Json4C_free(names[i]);
Json4C_free(entries[i]);
}
Json4C_free(names);
Json4C_free(entries);
if (fmt)
{
for (i = 0; i < deepth - 1; i++)
{
*ptr++ = '\t';
}
}
*ptr++ = '}';
*ptr++ = '\0';
return out;
}
char* Json4C_Print(Json4C* item)
{
return print_value(item,0,1);
}
//---------------------------------------------
Json4C* Json4C_CreateObject(void)
{
Json4C* item = Json4C_New_Item();
if (item)
item->tpye = Json4C_Object;
return item;
}
Json4C* Json4C_CreateString(const char* str)
{
Json4C* item = Json4C_New_Item();
if (item)
{
item->tpye = Json4C_String;
item->valueString = Json4C_strdup(str);
}
return item;
}
Json4C* Json4C_CreateNumber(double num)
{
Json4C* item = Json4C_New_Item();
if (item)
{
item->tpye = Json4C_Number;
item->valueDouble = num;
item->valueInt = (int)num;
}
return item;
}
Json4C* Json4C_CreateArray(void)
{
Json4C* item = Json4C_New_Item();
if (item)
item->tpye = Json4C_Array;
return item;
}
Json4C* Json4C_CreateBool(int b)
{
Json4C* item = Json4C_New_Item();
if (item)
item->tpye = b ? Json4C_True : Json4C_False;
return item;
}
Json4C* Json4C_CreateTrue(void)
{
Json4C* item = Json4C_New_Item();
if (item)
item->tpye = Json4C_True;
return item;
}
Json4C* Json4C_CreateFalse(void)
{
Json4C* item = Json4C_New_Item();
if (item)
item->tpye = Json4C_False;
return item;
}
Json4C* Json4C_CreateNull(void)
{
Json4C* item = Json4C_New_Item();
if (item)
item->tpye = Json4C_Null;
return item;
}
void suffix_object(Json4C* prev, Json4C* item)
{
prev->next = item;
item->prev = prev;
}
void Json4C_AddItemToObject(Json4C* object, const char* str, Json4C* item)
{
if (!item)
return;
if (!item->string)
Json4C_free(item->string);
item->string = Json4C_strdup(str);
Json4C_AddItemToArray(object, item);
}
void Json4C_AddItemToArray(Json4C* arr, Json4C* item)
{
Json4C* c = arr->child;
if (!item)
return;
if (!c)
arr->child = item;
else
{
while (c && c->next)
c = c->next;
suffix_object(c, item);
}
}
//---------------------------------------------
Json4C* Json4C_DetachItemFromArray(Json4C* arr, int which)
{
Json4C* c = arr->child;
while (c && which>0)
{
c = c->next;
which--;
}
if (!c)
return NULL;
if (c->prev)
c->prev->next = c->next;
if (c->next)
c->next->prev = c->prev;
if (c == arr->child)
arr->child = c->next;
c->prev = c->next = NULL;
return c;
}
void Json4C_DeteleItemFromArray(Json4C* arr, int which)
{
Json4C_Detele(Json4C_DetachItemFromArray(arr, which));
}
Json4C* Json4C_DetachItemFromObject(Json4C* object, const char* str)
{
int i = 0;
Json4C* c = object->child;
while(c && Json4C_strcasecmp(c->string,str))
{
i++;
c = c->next;
}
if (c)
{
return Json4C_DetachItemFromArray(object, i);
}
return NULL;
}
void Json4C_DeteleItemFromObject(Json4C* object, int which)
{
Json4C_Detele(Json4C_DetachItemFromObject(object, which));
}
int Json4C_strcasecmp(const char* str1, const char* str2)
{
int ret;
if (!str1)
return (str1 == str2) ? NULL : 1;
if (!str2)
return 1;
for (; tolower(str1) == tolower(str2); ++str1, ++str2)
{
if (*str1 == 0)
return 0;
}
ret = tolower(*(const unsigned char*)str1) - tolower(*(const unsigned char*)str2);
return ret;
}
//---------------------------------------------
void Json4C_InsertItemInArray(Json4C* arr, int which, Json4C* newItem)
{
Json4C* c = arr->child;
while (c && which > 0)
{
c = c->next;
which--;
}
if (!c)
{
Json4C_AddItemToArray(arr, newItem);
return;
}
newItem->next = c;
newItem->prev = c->prev;
c->prev = newItem;
if (c == arr->child)
arr->child = newItem;
else
newItem->prev->next = newItem;
}
void Json4C_ReplaceItemInArray(Json4C* arr, int which, Json4C* newItem)
{
Json4C* c = arr->child;
while (c && which > 0)
{
c = c->next;
which--;
}
if (!c)
return;
newItem->next = c->next;
newItem->prev = c->prev;
if (newItem->next)
newItem->next->prev = newItem;
if (c == arr->child)
arr->child = newItem;
else
newItem->prev->next = newItem;
c->next = c->prev = NULL;
Json4C_Detele(c);
}
void Json4C_ReplaceItemObject(Json4C* object, const char* str, Json4C* newItem)
{
int i = 0;
Json4C* c = object->child;
while (c && Json4C_strcasecmp(c->string, str))
{
i++;
c = c->next;
}
if (c)
{
newItem->string = Json4C_strdup(str);
Json4C_ReplaceItemInArray(object, i, newItem);
}
} | 20.236917 | 108 | 0.449433 |
cc24a4e014a9f80b239b142bf2736763d8931e99 | 950 | h | C | ios/LiquidPlatformKit.framework/Headers/LDCReconcileManifestViewController.h | LiquidAnalytics/ld-api-examples | 82a3c6c3c0948fc7e134f65a3db86ee2014ec3c2 | [
"Apache-2.0"
] | null | null | null | ios/LiquidPlatformKit.framework/Headers/LDCReconcileManifestViewController.h | LiquidAnalytics/ld-api-examples | 82a3c6c3c0948fc7e134f65a3db86ee2014ec3c2 | [
"Apache-2.0"
] | null | null | null | ios/LiquidPlatformKit.framework/Headers/LDCReconcileManifestViewController.h | LiquidAnalytics/ld-api-examples | 82a3c6c3c0948fc7e134f65a3db86ee2014ec3c2 | [
"Apache-2.0"
] | null | null | null | //
// LDCReconcileManifestViewController.h
// LDCore
//
// Created by David Ellis on 10/29/2013.
// Copyright (c) 2013 Liquid Analytics. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "LSCReconcileManifestEventLogger.h"
@protocol LDCReconcileViewControllerDataSource;
@interface LDCReconcileManifestViewController : UIViewController <LSCReconcileManifestEventLoggerDelegate>
@property (weak) id<LDCReconcileViewControllerDataSource> datasource;
@end
@protocol LDCReconcileViewControllerDataSource <NSObject>
- (void)syncReconcileViewController:(LDCReconcileManifestViewController *)reconcileViewController timesForLastReconcile:(void (^)(NSDate *startDate, NSDate *endDate))block;
- (NSString *)syncLabelTextForReconcileViewController:(LDCReconcileManifestViewController *)syncLogViewController;
- (void)syncReconcileViewController:(LDCReconcileManifestViewController *)syncLogViewController didPressSyncButton:(id)sender;
@end | 33.928571 | 172 | 0.832632 |
d1607b49e671f9e345f4db923b5ea6eddcd5804c | 1,868 | h | C | libyul/optimiser/DeadCodeEliminator.h | MrChico/solidity | 5b4ea1eb895d5edc9a24ee5c6f96d8580eceec08 | [
"MIT"
] | null | null | null | libyul/optimiser/DeadCodeEliminator.h | MrChico/solidity | 5b4ea1eb895d5edc9a24ee5c6f96d8580eceec08 | [
"MIT"
] | 1 | 2020-06-17T14:24:49.000Z | 2020-06-17T14:24:49.000Z | libyul/optimiser/DeadCodeEliminator.h | MrChico/solidity | 5b4ea1eb895d5edc9a24ee5c6f96d8580eceec08 | [
"MIT"
] | null | null | null | /*
This file is part of solidity.
solidity is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
solidity 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 solidity. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Optimisation stage that removes unused variables and functions.
*/
#pragma once
#include <libyul/optimiser/ASTWalker.h>
#include <libyul/YulString.h>
#include <map>
#include <set>
namespace solidity::yul
{
struct Dialect;
struct OptimiserStepContext;
/**
* Optimisation stage that removes unreachable code
*
* Unreachable code is any code within a block which is preceded by a
* leave, return, invalid, break, continue, selfdestruct or revert.
*
* Function definitions are retained as they might be called by earlier
* code and thus are considered reachable.
*
* Because variables declared in a for loop's init block have their scope extended to the loop body,
* we require ForLoopInitRewriter to run before this step.
*
* Prerequisite: ForLoopInitRewriter, Function Hoister, Function Grouper
*/
class DeadCodeEliminator: public ASTModifier
{
public:
static constexpr char const* name{"DeadCodeEliminator"};
static void run(OptimiserStepContext&, Block& _ast);
using ASTModifier::operator();
void operator()(ForLoop& _for) override;
void operator()(Block& _block) override;
private:
DeadCodeEliminator(Dialect const& _dialect): m_dialect(_dialect) {}
Dialect const& m_dialect;
};
}
| 28.738462 | 100 | 0.764989 |
4a8738fef4ae5090305263844581d8b2d1bd2b90 | 188 | h | C | torch/csrc/jit/codegen/cuda/ir_all_nodes.h | wenhaopeter/read_pytorch_code | 491f989cd918cf08874dd4f671fb7f0142a0bc4f | [
"Intel",
"X11"
] | null | null | null | torch/csrc/jit/codegen/cuda/ir_all_nodes.h | wenhaopeter/read_pytorch_code | 491f989cd918cf08874dd4f671fb7f0142a0bc4f | [
"Intel",
"X11"
] | null | null | null | torch/csrc/jit/codegen/cuda/ir_all_nodes.h | wenhaopeter/read_pytorch_code | 491f989cd918cf08874dd4f671fb7f0142a0bc4f | [
"Intel",
"X11"
] | null | null | null | #pragma once
#include <torch/csrc/jit/codegen/cuda/ir_base_nodes.h>
#include <torch/csrc/jit/codegen/cuda/ir_interface_nodes.h>
#include <torch/csrc/jit/codegen/cuda/ir_internal_nodes.h>
| 31.333333 | 59 | 0.803191 |
2e035fa9e5d5b2f788d04ebb6e3cc4fd0017a7c5 | 6,767 | c | C | src/mmath/mat2d.c | Tarik02/mmath | aa23cd1e1e53882efb4dacd48676921b11dcf048 | [
"MIT"
] | null | null | null | src/mmath/mat2d.c | Tarik02/mmath | aa23cd1e1e53882efb4dacd48676921b11dcf048 | [
"MIT"
] | null | null | null | src/mmath/mat2d.c | Tarik02/mmath | aa23cd1e1e53882efb4dacd48676921b11dcf048 | [
"MIT"
] | null | null | null | #include "mmath/mat2d.h"
#include "mmath_private.h"
mat2d *mat2d_create() {
mat2d *out = malloc(sizeof(mat2d));
return mat2d_identity(out);
}
void mat2d_free(mat2d *a) {
free(a);
}
mat2d *mat2d_clone(const mat2d *a) {
mat2d *out = mat2d_create();
mat2d_copy(out, a);
return out;
}
mat2d *mat2d_from_values(float a, float b, float c, float d, float tx, float ty) {
return mat2d_set(mat2d_create(), a, b, c, d, tx, ty);
}
mat2d *mat2d_copy(mat2d *out, const mat2d *a) {
memcpy(out->data, a->data, sizeof(a->data));
return out;
}
mat2d *mat2d_identity(mat2d *out) {
return mat2d_set(out, 1.f, 0.f, 0.f, 1.f, 0.f, 0.f);
}
mat2d *mat2d_set(mat2d *out, float a, float b, float c, float d, float tx, float ty) {
out->a = a;
out->b = b;
out->c = c;
out->d = d;
out->tx = tx;
out->ty = ty;
return out;
}
mat2d *mat2d_invert(mat2d *out, const mat2d *a) {
float det = mat2d_determinant(a);
if (det == 0.f) {
return NULL;
}
det = 1.f / det;
out->data[0] = a->d * det;
out->data[1] = -a->b * det;
out->data[2] = -a->c * det;
out->data[3] = a->a * det;
out->data[4] = (a->c * a->ty - a->d * a->tx) * det;
out->data[5] = (a->b * a->tx - a->a * a->ty) * det;
return out;
}
float mat2d_determinant(const mat2d *a) {
return a->data[0] * a->data[3] - a->data[2] * a->data[1];
}
mat2d *mat2d_multiply(mat2d *out, const mat2d *a, const mat2d *b) {
float a0 = a->data[0];
float a1 = a->data[1];
float a2 = a->data[2];
float a3 = a->data[3];
float a4 = a->data[4];
float a5 = a->data[5];
float b0 = b->data[0];
float b1 = b->data[1];
float b2 = b->data[2];
float b3 = b->data[3];
float b4 = b->data[4];
float b5 = b->data[5];
out->data[0] = a0 * b0 + a2 * b1;
out->data[1] = a1 * b0 + a3 * b1;
out->data[2] = a0 * b2 + a2 * b3;
out->data[3] = a1 * b2 + a3 * b3;
out->data[4] = a0 * b4 + a2 * b5 + a4;
out->data[5] = a1 * b4 + a3 * b5 + a5;
return out;
}
mat2d *mat2d_rotate(mat2d *out, const mat2d *a, float angle) {
float a0 = a->data[0];
float a1 = a->data[1];
float a2 = a->data[2];
float a3 = a->data[3];
float a4 = a->data[4];
float a5 = a->data[5];
float s = sinf(angle);
float c = cosf(angle);
out->data[0] = a0 * c + a2 * s;
out->data[1] = a1 * c + a3 * s;
out->data[2] = a0 * -s + a2 * c;
out->data[3] = a1 * -s + a3 * c;
out->data[4] = a4;
out->data[5] = a5;
return out;
}
mat2d *mat2d_scale(mat2d *out, const mat2d *a, const vec2 *v) {
float a0 = a->data[0];
float a1 = a->data[1];
float a2 = a->data[2];
float a3 = a->data[3];
float a4 = a->data[4];
float a5 = a->data[5];
float v0 = v->data[0];
float v1 = v->data[1];
out->data[0] = a0 * v0;
out->data[1] = a1 * v0;
out->data[2] = a2 * v1;
out->data[3] = a3 * v1;
out->data[4] = a4;
out->data[5] = a5;
return out;
}
mat2d *mat2d_translate(mat2d *out, const mat2d *a, const vec2 *v) {
float a0 = a->data[0];
float a1 = a->data[1];
float a2 = a->data[2];
float a3 = a->data[3];
float a4 = a->data[4];
float a5 = a->data[5];
float v0 = v->data[0];
float v1 = v->data[1];
out->data[0] = a0;
out->data[1] = a1;
out->data[2] = a2;
out->data[3] = a3;
out->data[4] = a0 * v0 + a2 * v1 + a4;
out->data[5] = a1 * v0 + a3 * v1 + a5;
return out;
}
mat2d *mat2d_from_rotation(mat2d *out, float angle) {
float s = sinf(angle);
float c = cosf(angle);
out->data[0] = c;
out->data[1] = s;
out->data[2] = -s;
out->data[3] = c;
out->data[4] = 0;
out->data[5] = 0;
return out;
}
mat2d *mat2d_from_scaling(mat2d *out, const vec2 *v) {
out->data[0] = v->data[0];
out->data[1] = 0;
out->data[2] = 0;
out->data[3] = v->data[1];
out->data[4] = 0;
out->data[5] = 0;
return out;
}
mat2d *mat2d_from_translation(mat2d *out, const vec2 *v) {
out->data[0] = 1;
out->data[1] = 0;
out->data[2] = 0;
out->data[3] = 1;
out->data[4] = v->data[0];
out->data[5] = v->data[1];
return out;
}
float mat2d_frob(const mat2d *a) {
float a0 = a->data[0];
float a1 = a->data[1];
float a2 = a->data[2];
float a3 = a->data[3];
float a4 = a->data[4];
float a5 = a->data[5];
return sqrtf(a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3 + a4 * a4 + a5 * a5 + 1);
}
mat2d *mat2d_add(mat2d *out, const mat2d *a, const mat2d *b) {
out->data[0] = a->data[0] + b->data[0];
out->data[1] = a->data[1] + b->data[1];
out->data[2] = a->data[2] + b->data[2];
out->data[3] = a->data[3] + b->data[3];
out->data[4] = a->data[4] + b->data[4];
out->data[5] = a->data[5] + b->data[5];
return out;
}
mat2d *mat2d_subtract(mat2d *out, const mat2d *a, const mat2d *b) {
out->data[0] = a->data[0] - b->data[0];
out->data[1] = a->data[1] - b->data[1];
out->data[2] = a->data[2] - b->data[2];
out->data[3] = a->data[3] - b->data[3];
out->data[4] = a->data[4] - b->data[4];
out->data[5] = a->data[5] - b->data[5];
return out;
}
mat2d *mat2d_multiply_scalar(mat2d *out, const mat2d *a, float scale) {
out->data[0] = a->data[0] * scale;
out->data[1] = a->data[1] * scale;
out->data[2] = a->data[2] * scale;
out->data[3] = a->data[3] * scale;
out->data[4] = a->data[4] * scale;
out->data[5] = a->data[5] * scale;
return out;
}
mat2d *mat2d_multiply_scalar_and_add(mat2d *out, const mat2d *a, const mat2d *b, float scale) {
out->data[0] = a->data[0] + (b->data[0] * scale);
out->data[1] = a->data[1] + (b->data[1] * scale);
out->data[2] = a->data[2] + (b->data[2] * scale);
out->data[3] = a->data[3] + (b->data[3] * scale);
out->data[4] = a->data[4] + (b->data[4] * scale);
out->data[5] = a->data[5] + (b->data[5] * scale);
return out;
}
bool mat2d_exact_equals(const mat2d *a, const mat2d *b) {
return (
a->data[0] == b->data[0] &&
a->data[1] == b->data[1] &&
a->data[2] == b->data[2] &&
a->data[3] == b->data[3] &&
a->data[4] == b->data[4] &&
a->data[5] == b->data[5]
);
}
bool mat2d_equals(const mat2d *a, const mat2d *b) {
float a0 = a->data[0];
float a1 = a->data[1];
float a2 = a->data[2];
float a3 = a->data[3];
float a4 = a->data[4];
float a5 = a->data[5];
float b0 = b->data[0];
float b1 = b->data[1];
float b2 = b->data[2];
float b3 = b->data[3];
float b4 = b->data[4];
float b5 = b->data[5];
return (
fabsf(a0 - b0) <= MMATH_EPSILON * fmaxf(1.0f, fmaxf(fabsf(a0), fabsf(b0))) &&
fabsf(a1 - b1) <= MMATH_EPSILON * fmaxf(1.0f, fmaxf(fabsf(a1), fabsf(b1))) &&
fabsf(a2 - b2) <= MMATH_EPSILON * fmaxf(1.0f, fmaxf(fabsf(a2), fabsf(b2))) &&
fabsf(a3 - b3) <= MMATH_EPSILON * fmaxf(1.0f, fmaxf(fabsf(a3), fabsf(b3))) &&
fabsf(a4 - b4) <= MMATH_EPSILON * fmaxf(1.0f, fmaxf(fabsf(a4), fabsf(b4))) &&
fabsf(a5 - b5) <= MMATH_EPSILON * fmaxf(1.0f, fmaxf(fabsf(a5), fabsf(b5)))
);
}
| 25.344569 | 95 | 0.543963 |
44f101df9ddb6e119cf6e8bf601de26d22e50516 | 3,492 | h | C | 3rdparty/QxOrm/include/QxTraits/qx_traits.h | kevinlq/QxOrm_Example | 25c8c535a7602c0102e76df48969bb64f7711175 | [
"Apache-2.0"
] | 2 | 2021-06-07T10:07:57.000Z | 2021-07-20T23:02:55.000Z | 3rdparty/QxOrm/include/QxTraits/qx_traits.h | kevinlq/QxOrm_Example | 25c8c535a7602c0102e76df48969bb64f7711175 | [
"Apache-2.0"
] | null | null | null | 3rdparty/QxOrm/include/QxTraits/qx_traits.h | kevinlq/QxOrm_Example | 25c8c535a7602c0102e76df48969bb64f7711175 | [
"Apache-2.0"
] | null | null | null | /****************************************************************************
**
** https://www.qxorm.com/
** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
**
** This file is part of the QxOrm library
**
** This software is provided 'as-is', without any express or implied
** warranty. In no event will the authors be held liable for any
** damages arising from the use of this software
**
** Commercial Usage
** Licensees holding valid commercial QxOrm licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Lionel Marty
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file 'license.gpl3.txt' included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met : http://www.gnu.org/copyleft/gpl.html
**
** If you are unsure which license is appropriate for your use, or
** if you have questions regarding the use of this file, please contact :
** contact@qxorm.com
**
****************************************************************************/
#ifndef _QX_TRAITS_H_
#define _QX_TRAITS_H_
#ifdef _MSC_VER
#pragma once
#endif
#include <QxTraits/get_base_class.h>
#include <QxTraits/get_primary_key.h>
#include <QxTraits/get_class_name.h>
#include <QxTraits/get_class_name_primitive.h>
#include <QxTraits/is_container.h>
#include <QxTraits/is_ptr_base_of.h>
#include <QxTraits/is_ptr_to_pod.h>
#include <QxTraits/is_qt_hash.h>
#include <QxTraits/is_qt_linked_list.h>
#include <QxTraits/is_qt_list.h>
#include <QxTraits/is_qt_map.h>
#include <QxTraits/is_qt_multi_hash.h>
#include <QxTraits/is_qt_multi_map.h>
#include <QxTraits/is_qt_set.h>
#include <QxTraits/is_qt_shared_data_ptr.h>
#include <QxTraits/is_qt_shared_ptr.h>
#include <QxTraits/is_qt_scoped_ptr.h>
#include <QxTraits/is_qt_vector.h>
#include <QxTraits/is_qt_weak_ptr.h>
#include <QxTraits/is_qt_variant_compatible.h>
#include <QxTraits/is_qx_collection.h>
#include <QxTraits/is_qx_pod.h>
#include <QxTraits/is_qx_registered.h>
#include <QxTraits/is_smart_ptr.h>
#include <QxTraits/is_std_list.h>
#include <QxTraits/is_std_map.h>
#include <QxTraits/is_std_set.h>
#include <QxTraits/is_std_vector.h>
#include <QxTraits/archive_wide_traits.h>
#include <QxTraits/archive_printable.h>
#include <QxTraits/remove_attr.h>
#include <QxTraits/remove_smart_ptr.h>
#include <QxTraits/construct_ptr.h>
#include <QxTraits/construct_null_qvariant.h>
#include <QxTraits/get_sql_type.h>
#include <QxTraits/generic_container.h>
#include <QxTraits/is_valid_primary_key.h>
#include <QxTraits/is_qx_dao_ptr.h>
#include <QxTraits/is_equal.h>
#include <QxTraits/qt_meta_object.h>
#include <QxTraits/is_std_shared_ptr.h>
#include <QxTraits/is_std_unique_ptr.h>
#include <QxTraits/is_std_unordered_map.h>
#include <QxTraits/is_std_unordered_set.h>
#include <QxTraits/is_std_weak_ptr.h>
#ifdef _QX_ENABLE_BOOST
#include <QxTraits/is_boost_intrusive_ptr.h>
#include <QxTraits/is_boost_scoped_ptr.h>
#include <QxTraits/is_boost_shared_ptr.h>
#include <QxTraits/is_boost_unordered_map.h>
#include <QxTraits/is_boost_unordered_set.h>
#include <QxTraits/is_boost_weak_ptr.h>
#endif // _QX_ENABLE_BOOST
#endif // _QX_TRAITS_H_
| 36.757895 | 77 | 0.758018 |
2f52300c8f61beef4ebca5ffffa4d527cadf67aa | 672 | h | C | gui/Dialogs.h | NiklasWang/Uranium | dee2480496ccf4a5aa11502d0b9ed2fdfeb647fe | [
"Apache-2.0"
] | 1 | 2019-07-10T05:14:54.000Z | 2019-07-10T05:14:54.000Z | gui/Dialogs.h | NiklasWang/Uranium | dee2480496ccf4a5aa11502d0b9ed2fdfeb647fe | [
"Apache-2.0"
] | 4 | 2019-05-27T05:43:16.000Z | 2019-08-27T13:59:22.000Z | gui/Dialogs.h | NiklasWang/Uranium | dee2480496ccf4a5aa11502d0b9ed2fdfeb647fe | [
"Apache-2.0"
] | 1 | 2019-05-31T04:29:25.000Z | 2019-05-31T04:29:25.000Z | #ifndef _DIALOGS_H
#define _DIALOGS_H
#include <QString>
namespace uranium {
class MainWindow;
// only one main window in this application
extern MainWindow *gMW;
extern int32_t gCurMonitorScale;
enum MessageType {
MESSAGE_TYPE_INFORMATION,
MESSAGE_TYPE_QUESTION,
MESSAGE_TYPE_WARNING,
MESSAGE_TYPE_ERROR,
MESSAGE_TYPE_CRITICAL,
MESSAGE_TYPE_MAX_INVALID,
};
int32_t showError(const QString &msg);
int32_t showWarning(const QString &msg);
int32_t showCritical(const QString &msg);
int32_t showQuestion(const QString &msg);
int32_t showInformation(const QString &msg);
int32_t showDialog(MessageType type, const QString &msg);
}
#endif
| 17.230769 | 57 | 0.778274 |
2b73ccda947ac13a38a7b0f7645280872c371c28 | 2,716 | h | C | genAlgo.h | meening42/GeneticAlgorithm | 86a1f7957727e491fc8fec5a22946892402b6544 | [
"MIT"
] | null | null | null | genAlgo.h | meening42/GeneticAlgorithm | 86a1f7957727e491fc8fec5a22946892402b6544 | [
"MIT"
] | null | null | null | genAlgo.h | meening42/GeneticAlgorithm | 86a1f7957727e491fc8fec5a22946892402b6544 | [
"MIT"
] | null | null | null |
/***************************************************************
* @file GA.h
* @brief GENETIC ALGORITHM
* @author Copyright (C) 2020 Marko A.
* @version v0.0.1
***************************************************************/
#ifndef GA_H_INCUDED
#define GA_H_INCUDED
/* ==================================================================== */
/* ========================== include files =========================== */
/* ==================================================================== */
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <assert.h>
#include <float.h>
/* ==================================================================== */
/* ============================ constants ============================= */
/* ==================================================================== */
//#define NUM_OF_INDIVIDUALS 100
//#define NUM_OF_GENERATIONS 100
#define MAX_TABLE_LEN 1000
#define MAX_TABLE_WITDH 5
#define MAX_CHROMOSOMES 10
#define MAX_GENERATIONS 1000
#define NUM_OF_INDIV 100
#define MAX_MUTATION_PROB 6
#define MUTATION_STEP 0.5
#define MUTATION_INIT_PROB 0.1
#define PRICE_MUTATION_TRESHOLD 0.0005f
#define ELITES 2 // TODO Check elites smaller than num of individuas
#define BITS_IN_CHROMOSOME 15 // TODO check min 2 max 15 !!!
#define PRICE_AVRG_WINDOW 5
/* ==================================================================== */
/* ============================ STRUCTURES ============================ */
/* ==================================================================== */
typedef struct GA_individual{
uint16_t chromosome[MAX_CHROMOSOMES];
float parameters[MAX_CHROMOSOMES];
float price;
bool paired;
}GA_individual;
typedef struct GA_ChromosomeRange{
float low;
float up;
bool used;
}GA_ChromosomeRange;
/* ==================================================================== */
/* ==================== GA function prototypes ======================== */
/* ==================================================================== */
void GA_init(float (*fitnesFunction)(float*), float priceTr);
void GA_compute();
void GA_setChromMappingRange(int indx, float inLow, float inUp);
/// PRINT
void GA_printPopulation(int numIndv);
void GA_printIndividual();
void GA_printBest();
void GA_printSearchTable(int tLength,float table[][5]);
/// INPUT / OUTPUT
void GA_IOFileInit();
void GA_IOfileClose();
void GA_readTable(char* fileName, int tColumns, int tLength);
void GA_clearFiles();
void GA_outputPrice();
void GA_outputPriceAvrg();
void GA_outputPopulation();
void GA_outputMutation();
void GA_outputBestParameters();
#endif /* GA_H_INCUDED */
| 29.846154 | 86 | 0.486745 |
d894673f195b6c579d05c3a05496e43dd7f9b18a | 1,988 | h | C | ironstack_agent/gui/input_textbox.h | zteo-phd-software/ironstack | 649f82ddcbb82831796fa2a1e1d1b8cc0f94a8e0 | [
"BSD-3-Clause"
] | null | null | null | ironstack_agent/gui/input_textbox.h | zteo-phd-software/ironstack | 649f82ddcbb82831796fa2a1e1d1b8cc0f94a8e0 | [
"BSD-3-Clause"
] | null | null | null | ironstack_agent/gui/input_textbox.h | zteo-phd-software/ironstack | 649f82ddcbb82831796fa2a1e1d1b8cc0f94a8e0 | [
"BSD-3-Clause"
] | null | null | null | #pragma once
#include <atomic>
#include <condition_variable>
#include <mutex>
#include <string>
#include "gui_component.h"
using namespace std;
namespace gui {
class input_textbox : public gui_component, public input_component {
public:
// constructor and destructor
input_textbox();
virtual ~input_textbox();
// input mode options
void set_modal(bool modal_status);
bool is_modal() const;
// setup string to be displayed above the line input
void set_description(const string& desc, uint32_t max_lines);
// setup string to be displayed to the left of the line input
void set_prefix(const string& prefix);
// setup buffer
void set_buffer_size(uint32_t size);
// set the focus/blur colors
void set_input_box_color(const color_t& focus_color, const color_t& blur_color);
// blocks until user types in an input
// the bool return value indicates if enter was hit (meaning the input was sent)
// the string return value indicates the input that was typed in
pair<bool, string> wait_for_input(int timeout_ms=-1);
// overriden from gui component class
virtual void commit_all();
virtual void render();
// overriden from the input component class
virtual void process_keypress(const keystroke& key);
virtual void on_focus();
virtual void on_blur();
private:
// disallow copies
input_textbox(const input_textbox& other);
input_textbox& operator=(const input_textbox& other);
// state
mutable mutex box_lock;
mutable condition_variable box_cond;
atomic_bool modal;
bool has_focus;
color_t focus_color;
color_t blur_color;
string description;
string prefix;
uint32_t desc_lines;
uint32_t input_buf_size;
char* input_buf;
bool text_entered;
uint32_t write_offset;
};
};
| 28.4 | 89 | 0.661972 |
4d45f93d3acc1266908553648a8b6caffc41b021 | 4,115 | h | C | src/Leviathan_Editor/GeneratedFiles/ui_Leviathan_Editor.h | wakare/Leviathan | 8a488f014d6235c5c6e6422c9f53c82635b7ebf7 | [
"MIT"
] | 3 | 2019-03-05T13:05:30.000Z | 2019-12-16T05:56:21.000Z | src/Leviathan_Editor/GeneratedFiles/ui_Leviathan_Editor.h | wakare/Leviathan | 8a488f014d6235c5c6e6422c9f53c82635b7ebf7 | [
"MIT"
] | null | null | null | src/Leviathan_Editor/GeneratedFiles/ui_Leviathan_Editor.h | wakare/Leviathan | 8a488f014d6235c5c6e6422c9f53c82635b7ebf7 | [
"MIT"
] | null | null | null | /********************************************************************************
** Form generated from reading UI file 'Leviathan_Editor.ui'
**
** Created by: Qt User Interface Compiler version 5.10.0
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_LEVIATHAN_EDITOR_H
#define UI_LEVIATHAN_EDITOR_H
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenu>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QToolBar>
#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
class Ui_Leviathan_EditorClass
{
public:
QWidget *centralWidget;
QMenuBar *menuBar;
QMenu *menuFile;
QMenu *menuEdit;
QMenu *menuView;
QMenu *menuWindow;
QMenu *menuTool;
QMenu *menuHelp;
QToolBar *mainToolBar;
QStatusBar *statusBar;
void setupUi(QMainWindow *Leviathan_EditorClass)
{
if (Leviathan_EditorClass->objectName().isEmpty())
Leviathan_EditorClass->setObjectName(QStringLiteral("Leviathan_EditorClass"));
Leviathan_EditorClass->resize(1066, 839);
centralWidget = new QWidget(Leviathan_EditorClass);
centralWidget->setObjectName(QStringLiteral("centralWidget"));
Leviathan_EditorClass->setCentralWidget(centralWidget);
menuBar = new QMenuBar(Leviathan_EditorClass);
menuBar->setObjectName(QStringLiteral("menuBar"));
menuBar->setGeometry(QRect(0, 0, 1066, 21));
menuFile = new QMenu(menuBar);
menuFile->setObjectName(QStringLiteral("menuFile"));
menuEdit = new QMenu(menuBar);
menuEdit->setObjectName(QStringLiteral("menuEdit"));
menuView = new QMenu(menuBar);
menuView->setObjectName(QStringLiteral("menuView"));
menuWindow = new QMenu(menuBar);
menuWindow->setObjectName(QStringLiteral("menuWindow"));
menuTool = new QMenu(menuBar);
menuTool->setObjectName(QStringLiteral("menuTool"));
menuHelp = new QMenu(menuBar);
menuHelp->setObjectName(QStringLiteral("menuHelp"));
Leviathan_EditorClass->setMenuBar(menuBar);
mainToolBar = new QToolBar(Leviathan_EditorClass);
mainToolBar->setObjectName(QStringLiteral("mainToolBar"));
Leviathan_EditorClass->addToolBar(Qt::TopToolBarArea, mainToolBar);
statusBar = new QStatusBar(Leviathan_EditorClass);
statusBar->setObjectName(QStringLiteral("statusBar"));
Leviathan_EditorClass->setStatusBar(statusBar);
menuBar->addAction(menuFile->menuAction());
menuBar->addAction(menuEdit->menuAction());
menuBar->addAction(menuView->menuAction());
menuBar->addAction(menuWindow->menuAction());
menuBar->addAction(menuTool->menuAction());
menuBar->addAction(menuHelp->menuAction());
retranslateUi(Leviathan_EditorClass);
QMetaObject::connectSlotsByName(Leviathan_EditorClass);
} // setupUi
void retranslateUi(QMainWindow *Leviathan_EditorClass)
{
Leviathan_EditorClass->setWindowTitle(QApplication::translate("Leviathan_EditorClass", "Leviathan_Editor", nullptr));
menuFile->setTitle(QApplication::translate("Leviathan_EditorClass", "File", nullptr));
menuEdit->setTitle(QApplication::translate("Leviathan_EditorClass", "Edit", nullptr));
menuView->setTitle(QApplication::translate("Leviathan_EditorClass", "View", nullptr));
menuWindow->setTitle(QApplication::translate("Leviathan_EditorClass", "Window", nullptr));
menuTool->setTitle(QApplication::translate("Leviathan_EditorClass", "Tool", nullptr));
menuHelp->setTitle(QApplication::translate("Leviathan_EditorClass", "Help", nullptr));
} // retranslateUi
};
namespace Ui {
class Leviathan_EditorClass: public Ui_Leviathan_EditorClass {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_LEVIATHAN_EDITOR_H
| 39.951456 | 125 | 0.691616 |
06649b2ec15b17c96b97a5b88af9713169cf6f4d | 935 | h | C | YLCleaner/Xcode-RuntimeHeaders/DocSetViewing/DVBookmarksArrayController.h | liyong03/YLCleaner | 7453187a884c8e783bda1af82cbbb51655ec41c6 | [
"MIT"
] | 1 | 2019-02-15T02:16:35.000Z | 2019-02-15T02:16:35.000Z | YLCleaner/Xcode-RuntimeHeaders/DocSetViewing/DVBookmarksArrayController.h | liyong03/YLCleaner | 7453187a884c8e783bda1af82cbbb51655ec41c6 | [
"MIT"
] | null | null | null | YLCleaner/Xcode-RuntimeHeaders/DocSetViewing/DVBookmarksArrayController.h | liyong03/YLCleaner | 7453187a884c8e783bda1af82cbbb51655ec41c6 | [
"MIT"
] | null | null | null | /*
* Generated by class-dump 3.3.4 (64 bit).
*
* class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2011 by Steve Nygard.
*/
#import "NSArrayController.h"
@class DVBookmarksOutlineViewController, NSTableView;
@interface DVBookmarksArrayController : NSArrayController
{
NSTableView *tableView;
DVBookmarksOutlineViewController *controller;
}
@property(retain, nonatomic) DVBookmarksOutlineViewController *controller; // @synthesize controller;
- (BOOL)tableView:(id)arg1 acceptDrop:(id)arg2 row:(int)arg3 dropOperation:(unsigned long long)arg4;
- (unsigned long long)tableView:(id)arg1 validateDrop:(id)arg2 proposedRow:(int)arg3 proposedDropOperation:(unsigned long long)arg4;
- (BOOL)tableView:(id)arg1 writeRowsWithIndexes:(id)arg2 toPasteboard:(id)arg3;
- (id)moveObjectsInArrangedObjectsFromIndexes:(id)arg1 toIndex:(unsigned int)arg2;
- (void)awakeFromNib;
- (void)objectDidEndEditing:(id)arg1;
@end
| 34.62963 | 132 | 0.773262 |
a214382b25d0fa9defe4aab193102ceceb749356 | 3,195 | h | C | src/virtualization/lib/guest_interaction/test/operation_test_lib.h | allansrc/fuchsia | a2c235b33fc4305044d496354a08775f30cdcf37 | [
"BSD-2-Clause"
] | 210 | 2019-02-05T12:45:09.000Z | 2022-03-28T07:59:06.000Z | src/virtualization/lib/guest_interaction/test/operation_test_lib.h | allansrc/fuchsia | a2c235b33fc4305044d496354a08775f30cdcf37 | [
"BSD-2-Clause"
] | 56 | 2021-06-03T03:16:25.000Z | 2022-03-20T01:07:44.000Z | src/virtualization/lib/guest_interaction/test/operation_test_lib.h | allansrc/fuchsia | a2c235b33fc4305044d496354a08775f30cdcf37 | [
"BSD-2-Clause"
] | 73 | 2019-03-06T18:55:23.000Z | 2022-03-26T12:04:51.000Z | // Copyright 2019 The Fuchsia 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 SRC_VIRTUALIZATION_LIB_GUEST_INTERACTION_TEST_OPERATION_TEST_LIB_H_
#define SRC_VIRTUALIZATION_LIB_GUEST_INTERACTION_TEST_OPERATION_TEST_LIB_H_
#include <errno.h>
#include <fcntl.h>
#include <lib/async-loop/cpp/loop.h>
#include <lib/async-loop/default.h>
#include <lib/fit/function.h>
#include <lib/syslog/cpp/macros.h>
#include <lib/zx/clock.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <zircon/status.h>
#include <iostream>
#include <memory>
#include <thread>
#include <grpc/support/log.h>
#include "src/virtualization/lib/guest_interaction/proto/guest_interaction.grpc.pb.h"
#include <grpc++/grpc++.h>
// Helper macro used in tests to wait for next event on GRPC completion queues
// and assert on the returned values.
#define ASSERT_GRPC_CQ_NEXT(cq, expect_tag, expect_ok) \
{ \
bool ok__; \
void* tag__; \
ASSERT_TRUE((cq)->Next(&tag__, &ok__)); \
ASSERT_EQ(tag__, static_cast<void*>(expect_tag)); \
ASSERT_EQ(ok__, expect_ok); \
}
class AsyncEndToEndTest : public testing::Test {
protected:
AsyncEndToEndTest()
: client_cq_(std::make_unique<grpc::CompletionQueue>()),
service_(std::make_unique<GuestInteractionService::AsyncService>()) {
// Setup server
grpc::ServerBuilder builder;
builder.RegisterService(service_.get());
server_cq_ = builder.AddCompletionQueue();
server_ = builder.BuildAndStart();
// Setup stub
grpc::ChannelArguments args;
std::shared_ptr<grpc::Channel> channel = server_->InProcessChannel(args);
stub_ = GuestInteractionService::NewStub(channel);
}
void TearDown() override {
server_->Shutdown();
void* tag;
bool regular_event;
server_cq_->Shutdown();
while (server_cq_->Next(&tag, ®ular_event)) {
static_cast<CallData*>(tag)->Proceed(false);
EXPECT_FALSE(regular_event) << "Unexpected remaining event in server cq";
}
client_cq_->Shutdown();
while (client_cq_->Next(&tag, ®ular_event)) {
EXPECT_FALSE(regular_event) << "Unexpected remaining event in client cq";
}
}
void RunLoopUntil(fit::function<bool()> check) {
constexpr zx::duration kLoopStep = zx::msec(10);
while (!check()) {
zx_status_t status = loop_.Run(zx::deadline_after(kLoopStep), true);
ASSERT_TRUE(status == ZX_ERR_TIMED_OUT || status == ZX_OK)
<< "Failed to run loop " << zx_status_get_string(status);
}
}
const std::unique_ptr<grpc::CompletionQueue> client_cq_;
const std::unique_ptr<GuestInteractionService::AsyncService> service_;
std::unique_ptr<grpc::ServerCompletionQueue> server_cq_;
std::unique_ptr<GuestInteractionService::Stub> stub_;
std::unique_ptr<grpc::Server> server_;
async::Loop loop_ = async::Loop(&kAsyncLoopConfigAttachToCurrentThread);
};
#endif // SRC_VIRTUALIZATION_LIB_GUEST_INTERACTION_TEST_OPERATION_TEST_LIB_H_
| 34.728261 | 85 | 0.685759 |
9e5d469925ff66ddfdcc7d3ebeb21dd11a5e4754 | 3,382 | h | C | Dependencies/Header/mysql/server/private/tztime.h | GabrielLins64/SimpleERP | 8a25bdab32bd58a866f429b7f541e0e0617ef2e1 | [
"Apache-2.0"
] | null | null | null | Dependencies/Header/mysql/server/private/tztime.h | GabrielLins64/SimpleERP | 8a25bdab32bd58a866f429b7f541e0e0617ef2e1 | [
"Apache-2.0"
] | null | null | null | Dependencies/Header/mysql/server/private/tztime.h | GabrielLins64/SimpleERP | 8a25bdab32bd58a866f429b7f541e0e0617ef2e1 | [
"Apache-2.0"
] | 2 | 2022-02-27T14:00:01.000Z | 2022-03-31T06:24:22.000Z | #ifndef TZTIME_INCLUDED
#define TZTIME_INCLUDED
/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
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; version 2 of the License.
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-1335 USA */
#ifdef USE_PRAGMA_INTERFACE
#pragma interface /* gcc class interface */
#endif
#include "my_time.h" /* my_time_t */
#include "mysql_time.h" /* MYSQL_TIME */
#include "sql_list.h" /* Sql_alloc */
#include "sql_string.h" /* String */
class THD;
#if !defined(TESTTIME) && !defined(TZINFO2SQL)
class THD;
/**
This class represents abstract time zone and provides
basic interface for MYSQL_TIME <-> my_time_t conversion.
Actual time zones which are specified by DB, or via offset
or use system functions are its descendants.
*/
class Time_zone: public Sql_alloc
{
public:
Time_zone() {} /* Remove gcc warning */
/**
Converts local time in broken down MYSQL_TIME representation to
my_time_t (UTC seconds since Epoch) represenation.
Returns 0 in case of error. May set error_code to ER_WARN_DATA_OUT_OF_RANGE
or ER_WARN_INVALID_TIMESTAMP, see TIME_to_timestamp())
*/
virtual my_time_t TIME_to_gmt_sec(const MYSQL_TIME *t,
uint *error_code) const = 0;
/**
Converts time in my_time_t representation to local time in
broken down MYSQL_TIME representation.
*/
virtual void gmt_sec_to_TIME(MYSQL_TIME *tmp, my_time_t t) const = 0;
/**
Because of constness of String returned by get_name() time zone name
have to be already zeroended to be able to use String::ptr() instead
of c_ptr().
*/
virtual const String * get_name() const = 0;
/**
We need this only for surpressing warnings, objects of this type are
allocated on MEM_ROOT and should not require destruction.
*/
virtual ~Time_zone() {};
protected:
static inline void adjust_leap_second(MYSQL_TIME *t);
};
extern Time_zone * my_tz_UTC;
extern MYSQL_PLUGIN_IMPORT Time_zone * my_tz_SYSTEM;
extern Time_zone * my_tz_OFFSET0;
extern Time_zone * my_tz_find(THD *thd, const String *name);
extern my_bool my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap);
extern void my_tz_free();
extern my_time_t sec_since_epoch_TIME(MYSQL_TIME *t);
/**
Number of elements in table list produced by my_tz_get_table_list()
(this table list contains tables which are needed for dynamical loading
of time zone descriptions). Actually it is imlementation detail that
should not be used anywhere outside of tztime.h and tztime.cc.
*/
static const int MY_TZ_TABLES_COUNT= 4;
#endif /* !defined(TESTTIME) && !defined(TZINFO2SQL) */
#endif /* TZTIME_INCLUDED */
| 35.978723 | 91 | 0.705795 |
fa2fc92277570e99e0badcec0d4e24e307bcb744 | 5,012 | h | C | src/runtime/Classes/CodedInputStream.h | wittech/protobuf-objc | 2c84f7e06c1cdabc3e2207d73dfbc9a65afb5200 | [
"Apache-2.0"
] | null | null | null | src/runtime/Classes/CodedInputStream.h | wittech/protobuf-objc | 2c84f7e06c1cdabc3e2207d73dfbc9a65afb5200 | [
"Apache-2.0"
] | null | null | null | src/runtime/Classes/CodedInputStream.h | wittech/protobuf-objc | 2c84f7e06c1cdabc3e2207d73dfbc9a65afb5200 | [
"Apache-2.0"
] | null | null | null | // Protocol Buffers for Objective C
//
// Copyright 2010 Booyah Inc.
// Copyright 2008 Cyrus Najmabadi
//
// 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.
@class PBExtensionRegistry2;
@class PBUnknownFieldSetBuilder2;
@protocol PBMessageBuilder;
/**
* Reads and decodes protocol message fields.
*
* This class contains two kinds of methods: methods that read specific
* protocol message constructs and field types (e.g. {@link #readTag()} and
* {@link #readInt32()}) and methods that read low-level values (e.g.
* {@link #readRawVarint32()} and {@link #readRawBytes}). If you are reading
* encoded protocol messages, you should use the former methods, but if you are
* reading some other format of your own design, use the latter.
*
* @author Cyrus Najmabadi
*/
@interface PBCodedInputStream2 : NSObject {
@private
NSMutableData* buffer;
SInt32 bufferSize;
SInt32 bufferSizeAfterLimit;
SInt32 bufferPos;
NSInputStream* input;
SInt32 lastTag;
/**
* The total number of bytes read before the current buffer. The total
* bytes read up to the current position can be computed as
* {@code totalBytesRetired + bufferPos}.
*/
SInt32 totalBytesRetired;
/** The absolute position of the end of the current message. */
SInt32 currentLimit;
/** See setRecursionLimit() */
SInt32 recursionDepth;
SInt32 recursionLimit;
/** See setSizeLimit() */
SInt32 sizeLimit;
}
+ (PBCodedInputStream2*) streamWithData:(NSData*) data;
+ (PBCodedInputStream2*) streamWithInputStream:(NSInputStream*) input;
/**
* Attempt to read a field tag, returning zero if we have reached EOF.
* Protocol message parsers use this to read tags, since a protocol message
* may legally end wherever a tag occurs, and zero is not a valid tag number.
*/
- (SInt32) readTag;
- (BOOL) refillBuffer:(BOOL) mustSucceed;
- (Float64) readDouble;
- (Float32) readFloat;
- (SInt64) readUInt64;
- (SInt32) readUInt32;
- (SInt64) readInt64;
- (SInt32) readInt32;
- (SInt64) readFixed64;
- (SInt32) readFixed32;
- (SInt32) readEnum;
- (SInt32) readSFixed32;
- (SInt64) readSFixed64;
- (SInt32) readSInt32;
- (SInt64) readSInt64;
/**
* Read one byte from the input.
*
* @throws InvalidProtocolBuffer The end of the stream or the current
* limit was reached.
*/
- (int8_t) readRawByte;
/**
* Read a raw Varint from the stream. If larger than 32 bits, discard the
* upper bits.
*/
- (SInt32) readRawVarint32;
- (SInt64) readRawVarint64;
- (SInt32) readRawLittleEndian32;
- (SInt64) readRawLittleEndian64;
/**
* Read a fixed size of bytes from the input.
*
* @throws InvalidProtocolBuffer The end of the stream or the current
* limit was reached.
*/
- (NSData*) readRawData:(SInt32) size;
/**
* Reads and discards a single field, given its tag value.
*
* @return {@code false} if the tag is an endgroup tag, in which case
* nothing is skipped. Otherwise, returns {@code true}.
*/
- (BOOL) skipField:(SInt32) tag;
/**
* Reads and discards {@code size} bytes.
*
* @throws InvalidProtocolBuffer The end of the stream or the current
* limit was reached.
*/
- (void) skipRawData:(SInt32) size;
/**
* Reads and discards an entire message. This will read either until EOF
* or until an endgroup tag, whichever comes first.
*/
- (void) skipMessage;
- (BOOL) isAtEnd;
- (SInt32) pushLimit:(SInt32) byteLimit;
- (void) recomputeBufferSizeAfterLimit;
- (void) popLimit:(SInt32) oldLimit;
- (SInt32) bytesUntilLimit;
/** Read an embedded message field value from the stream. */
- (void) readMessage:(id<PBMessageBuilder>) builder extensionRegistry:(PBExtensionRegistry2*) extensionRegistry;
- (BOOL) readBool;
- (NSString*) readString;
- (NSData*) readData;
- (void) readGroup:(SInt32) fieldNumber builder:(id<PBMessageBuilder>) builder extensionRegistry:(PBExtensionRegistry2*) extensionRegistry;
/**
* Reads a {@code group} field value from the stream and merges it into the
* given {@link UnknownFieldSet}.
*/
- (void) readUnknownGroup:(SInt32) fieldNumber builder:(PBUnknownFieldSetBuilder2*) builder;
/**
* Verifies that the last call to readTag() returned the given tag value.
* This is used to verify that a nested group ended with the correct
* end tag.
*
* @throws InvalidProtocolBuffer {@code value} does not match the
* last tag.
*/
- (void) checkLastTagWas:(SInt32) value;
@end
| 30.011976 | 139 | 0.70012 |
fa38d8885f0b425798b53f2a88158c928c356e15 | 2,960 | c | C | kernel/kernel-4.9/drivers/staging/fbtft/fb_ili9486.c | rubedos/l4t_R32.5.1_viper | 6aed0062084d9031546f946e63fc74303555e0a6 | [
"MIT"
] | 55 | 2019-12-20T03:25:14.000Z | 2022-01-16T07:19:47.000Z | kernel/kernel-4.9/drivers/staging/fbtft/fb_ili9486.c | rubedos/l4t_R32.5.1_viper | 6aed0062084d9031546f946e63fc74303555e0a6 | [
"MIT"
] | 2 | 2020-11-02T08:01:00.000Z | 2022-03-27T02:59:18.000Z | kernel/kernel-4.9/drivers/staging/fbtft/fb_ili9486.c | rubedos/l4t_R32.5.1_viper | 6aed0062084d9031546f946e63fc74303555e0a6 | [
"MIT"
] | 11 | 2020-08-06T03:59:45.000Z | 2022-02-25T02:31:59.000Z | /*
* FB driver for the ILI9486 LCD Controller
*
* Copyright (C) 2014 Noralf Tronnes
*
* 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.
*/
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <video/mipi_display.h>
#include "fbtft.h"
#define DRVNAME "fb_ili9486"
#define WIDTH 320
#define HEIGHT 480
/* this init sequence matches PiScreen */
static int default_init_sequence[] = {
/* Interface Mode Control */
-1, 0xb0, 0x0,
-1, MIPI_DCS_EXIT_SLEEP_MODE,
-2, 250,
/* Interface Pixel Format */
-1, MIPI_DCS_SET_PIXEL_FORMAT, 0x55,
/* Power Control 3 */
-1, 0xC2, 0x44,
/* VCOM Control 1 */
-1, 0xC5, 0x00, 0x00, 0x00, 0x00,
/* PGAMCTRL(Positive Gamma Control) */
-1, 0xE0, 0x0F, 0x1F, 0x1C, 0x0C, 0x0F, 0x08, 0x48, 0x98,
0x37, 0x0A, 0x13, 0x04, 0x11, 0x0D, 0x00,
/* NGAMCTRL(Negative Gamma Control) */
-1, 0xE1, 0x0F, 0x32, 0x2E, 0x0B, 0x0D, 0x05, 0x47, 0x75,
0x37, 0x06, 0x10, 0x03, 0x24, 0x20, 0x00,
/* Digital Gamma Control 1 */
-1, 0xE2, 0x0F, 0x32, 0x2E, 0x0B, 0x0D, 0x05, 0x47, 0x75,
0x37, 0x06, 0x10, 0x03, 0x24, 0x20, 0x00,
-1, MIPI_DCS_EXIT_SLEEP_MODE,
-1, MIPI_DCS_SET_DISPLAY_ON,
/* end marker */
-3
};
static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
{
write_reg(par, MIPI_DCS_SET_COLUMN_ADDRESS,
xs >> 8, xs & 0xFF, xe >> 8, xe & 0xFF);
write_reg(par, MIPI_DCS_SET_PAGE_ADDRESS,
ys >> 8, ys & 0xFF, ye >> 8, ye & 0xFF);
write_reg(par, MIPI_DCS_WRITE_MEMORY_START);
}
static int set_var(struct fbtft_par *par)
{
switch (par->info->var.rotate) {
case 0:
write_reg(par, MIPI_DCS_SET_ADDRESS_MODE,
0x80 | (par->bgr << 3));
break;
case 90:
write_reg(par, MIPI_DCS_SET_ADDRESS_MODE,
0x20 | (par->bgr << 3));
break;
case 180:
write_reg(par, MIPI_DCS_SET_ADDRESS_MODE,
0x40 | (par->bgr << 3));
break;
case 270:
write_reg(par, MIPI_DCS_SET_ADDRESS_MODE,
0xE0 | (par->bgr << 3));
break;
default:
break;
}
return 0;
}
static struct fbtft_display display = {
.regwidth = 8,
.width = WIDTH,
.height = HEIGHT,
.init_sequence = default_init_sequence,
.fbtftops = {
.set_addr_win = set_addr_win,
.set_var = set_var,
},
};
FBTFT_REGISTER_DRIVER(DRVNAME, "ilitek,ili9486", &display);
MODULE_ALIAS("spi:" DRVNAME);
MODULE_ALIAS("platform:" DRVNAME);
MODULE_ALIAS("spi:ili9486");
MODULE_ALIAS("platform:ili9486");
MODULE_DESCRIPTION("FB driver for the ILI9486 LCD Controller");
MODULE_AUTHOR("Noralf Tronnes");
MODULE_LICENSE("GPL");
| 26.19469 | 79 | 0.69223 |
cfa3a81d699e4792cedc420d1c1d62f12db61e4c | 6,465 | c | C | linux-3.0/drivers/net/wireless/bcm4329/bcmsdstd_linux.c | spartan263/vizio_oss | 74270002d874391148119b48882db6816e7deedc | [
"Linux-OpenIB"
] | 4 | 2016-07-01T04:50:02.000Z | 2021-11-14T21:29:42.000Z | linux-3.0/drivers/net/wireless/bcm4329/bcmsdstd_linux.c | spartan263/vizio_oss | 74270002d874391148119b48882db6816e7deedc | [
"Linux-OpenIB"
] | null | null | null | linux-3.0/drivers/net/wireless/bcm4329/bcmsdstd_linux.c | spartan263/vizio_oss | 74270002d874391148119b48882db6816e7deedc | [
"Linux-OpenIB"
] | null | null | null | /*
* 'Standard' SDIO HOST CONTROLLER driver - linux portion
*
* Copyright (C) 1999-2010, Broadcom Corporation
*
* Unless you and Broadcom execute a separate written software license
* agreement governing use of this software, this software is licensed to you
* under the terms of the GNU General Public License version 2 (the "GPL"),
* available at http://www.broadcom.com/licenses/GPLv2.php, with the
* following added to such license:
*
* As a special exception, the copyright holders of this software give you
* permission to link this software with independent modules, and to copy and
* distribute the resulting executable under terms of your choice, provided that
* you also meet, for each linked independent module, the terms and conditions of
* the license of that module. An independent module is a module which is not
* derived from this software. The special exception does not apply to any
* modifications of the software.
*
* Notwithstanding the above, under no circumstances may you combine this
* software in any way with any other Broadcom software provided under a license
* other than the GPL, without Broadcom's express prior written consent.
*
* $Id: //DTV/MP_BR/DTV_X_IDTV0801_002200_2_001_2_001_1210_001/chiling/kernel/linux-3.0/drivers/net/wireless/bcm4329/bcmsdstd_linux.c#1 $
*/
#include <typedefs.h>
#include <pcicfg.h>
#include <bcmutils.h>
#include <sdio.h> /* SDIO Specs */
#include <bcmsdbus.h> /* bcmsdh to/from specific controller APIs */
#include <sdiovar.h> /* to get msglevel bit values */
#include <linux/sched.h> /* request_irq() */
#include <bcmsdstd.h>
struct sdos_info {
sdioh_info_t *sd;
spinlock_t lock;
wait_queue_head_t intr_wait_queue;
};
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0))
#define BLOCKABLE() (!in_atomic())
#else
#define BLOCKABLE() (!in_interrupt())
#endif
/* Interrupt handler */
static irqreturn_t
sdstd_isr(int irq, void *dev_id
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
, struct pt_regs *ptregs
#endif
)
{
sdioh_info_t *sd;
struct sdos_info *sdos;
bool ours;
sd = (sdioh_info_t *)dev_id;
if (!sd->card_init_done) {
sd_err(("%s: Hey Bogus intr...not even initted: irq %d\n", __FUNCTION__, irq));
return IRQ_RETVAL(FALSE);
} else {
ours = check_client_intr(sd);
/* For local interrupts, wake the waiting process */
if (ours && sd->got_hcint) {
sd_trace(("INTR->WAKE\n"));
sdos = (struct sdos_info *)sd->sdos_info;
wake_up_interruptible(&sdos->intr_wait_queue);
}
return IRQ_RETVAL(ours);
}
}
/* Register with Linux for interrupts */
int
sdstd_register_irq(sdioh_info_t *sd, uint irq)
{
sd_trace(("Entering %s: irq == %d\n", __FUNCTION__, irq));
if (request_irq(irq, sdstd_isr, IRQF_SHARED, "bcmsdstd", sd) < 0) {
sd_err(("%s: request_irq() failed\n", __FUNCTION__));
return ERROR;
}
return SUCCESS;
}
/* Free Linux irq */
void
sdstd_free_irq(uint irq, sdioh_info_t *sd)
{
free_irq(irq, sd);
}
/* Map Host controller registers */
uint32 *
sdstd_reg_map(osl_t *osh, int32 addr, int size)
{
return (uint32 *)REG_MAP(addr, size);
}
void
sdstd_reg_unmap(osl_t *osh, int32 addr, int size)
{
REG_UNMAP((void*)(uintptr)addr);
}
int
sdstd_osinit(sdioh_info_t *sd)
{
struct sdos_info *sdos;
sdos = (struct sdos_info*)MALLOC(sd->osh, sizeof(struct sdos_info));
sd->sdos_info = (void*)sdos;
if (sdos == NULL)
return BCME_NOMEM;
sdos->sd = sd;
spin_lock_init(&sdos->lock);
init_waitqueue_head(&sdos->intr_wait_queue);
return BCME_OK;
}
void
sdstd_osfree(sdioh_info_t *sd)
{
struct sdos_info *sdos;
ASSERT(sd && sd->sdos_info);
sdos = (struct sdos_info *)sd->sdos_info;
MFREE(sd->osh, sdos, sizeof(struct sdos_info));
}
/* Interrupt enable/disable */
SDIOH_API_RC
sdioh_interrupt_set(sdioh_info_t *sd, bool enable)
{
ulong flags;
struct sdos_info *sdos;
sd_trace(("%s: %s\n", __FUNCTION__, enable ? "Enabling" : "Disabling"));
sdos = (struct sdos_info *)sd->sdos_info;
ASSERT(sdos);
if (!(sd->host_init_done && sd->card_init_done)) {
sd_err(("%s: Card & Host are not initted - bailing\n", __FUNCTION__));
return SDIOH_API_RC_FAIL;
}
if (enable && !(sd->intr_handler && sd->intr_handler_arg)) {
sd_err(("%s: no handler registered, will not enable\n", __FUNCTION__));
return SDIOH_API_RC_FAIL;
}
/* Ensure atomicity for enable/disable calls */
spin_lock_irqsave(&sdos->lock, flags);
sd->client_intr_enabled = enable;
if (enable && !sd->lockcount)
sdstd_devintr_on(sd);
else
sdstd_devintr_off(sd);
spin_unlock_irqrestore(&sdos->lock, flags);
return SDIOH_API_RC_SUCCESS;
}
/* Protect against reentrancy (disable device interrupts while executing) */
void
sdstd_lock(sdioh_info_t *sd)
{
ulong flags;
struct sdos_info *sdos;
sdos = (struct sdos_info *)sd->sdos_info;
ASSERT(sdos);
sd_trace(("%s: %d\n", __FUNCTION__, sd->lockcount));
spin_lock_irqsave(&sdos->lock, flags);
if (sd->lockcount) {
sd_err(("%s: Already locked! called from %p\n",
__FUNCTION__,
__builtin_return_address(0)));
ASSERT(sd->lockcount == 0);
}
sdstd_devintr_off(sd);
sd->lockcount++;
spin_unlock_irqrestore(&sdos->lock, flags);
}
/* Enable client interrupt */
void
sdstd_unlock(sdioh_info_t *sd)
{
ulong flags;
struct sdos_info *sdos;
sd_trace(("%s: %d, %d\n", __FUNCTION__, sd->lockcount, sd->client_intr_enabled));
ASSERT(sd->lockcount > 0);
sdos = (struct sdos_info *)sd->sdos_info;
ASSERT(sdos);
spin_lock_irqsave(&sdos->lock, flags);
if (--sd->lockcount == 0 && sd->client_intr_enabled) {
sdstd_devintr_on(sd);
}
spin_unlock_irqrestore(&sdos->lock, flags);
}
uint16
sdstd_waitbits(sdioh_info_t *sd, uint16 norm, uint16 err, bool yield)
{
struct sdos_info *sdos;
sdos = (struct sdos_info *)sd->sdos_info;
#ifndef BCMSDYIELD
ASSERT(!yield);
#endif
sd_trace(("%s: int 0x%02x err 0x%02x yield %d canblock %d\n",
__FUNCTION__, norm, err, yield, BLOCKABLE()));
/* Clear the "interrupt happened" flag and last intrstatus */
sd->got_hcint = FALSE;
sd->last_intrstatus = 0;
#ifdef BCMSDYIELD
if (yield && BLOCKABLE()) {
/* Enable interrupts, wait for the indication, then disable */
sdstd_intrs_on(sd, norm, err);
wait_event_interruptible(sdos->intr_wait_queue, (sd->got_hcint));
sdstd_intrs_off(sd, norm, err);
} else
#endif /* BCMSDYIELD */
{
sdstd_spinbits(sd, norm, err);
}
sd_trace(("%s: last_intrstatus 0x%04x\n", __FUNCTION__, sd->last_intrstatus));
return sd->last_intrstatus;
}
| 25.654762 | 137 | 0.709513 |
cfc550be7c1cdd6695de0d0ef109cbb06f6d13ab | 30,051 | h | C | XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb.h | TheSeven/embeddedsw | 23eb39df101391b896adf20fa9d6c5aee27b0adc | [
"BSD-3-Clause"
] | 1 | 2021-10-30T00:13:33.000Z | 2021-10-30T00:13:33.000Z | XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb.h | fpgadeveloper/embeddedsw | 23eb39df101391b896adf20fa9d6c5aee27b0adc | [
"BSD-3-Clause"
] | null | null | null | XilinxProcessorIPLib/drivers/ycrcb2rgb/src/xycrcb2rgb.h | fpgadeveloper/embeddedsw | 23eb39df101391b896adf20fa9d6c5aee27b0adc | [
"BSD-3-Clause"
] | 1 | 2020-06-04T18:11:26.000Z | 2020-06-04T18:11:26.000Z | /******************************************************************************
*
* Copyright (C) 2012 - 2014 Xilinx, Inc. All rights reserved.
*
* 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.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or
* (b) that interact with a Xilinx device through a bus or interconnect.
*
* 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
* XILINX 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.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in
* this Software without prior written authorization from Xilinx.
*
******************************************************************************/
/*****************************************************************************/
/**
*
* @file xycrcb2rgb.h
* @addtogroup ycrcb2rgb_v7_1
* @{
* @details
*
* This header file contains identifiers and register-level driver functions
* (or macros), range macros, structure typedefs that can be used to access the
* Xilinx YCRCB2RGB core.
*
* The YCrCb to RGB Color-Space Convertor core is a simplified 3x3 matrix
* multiplier converts three input color samples to three output samples in a
* single clock cycle. The core supports four common format conversions as well
* as a custom mode that allows for a user-defined transform. The core is
* capable of a maximum resolution of 7680 columns by 7680 rows with 8, 10, 12,
* or 16 bits per pixel.
*
* <b>Initialization & Configuration</b>
*
* The device driver enables higher layer software (e.g., an application) to
* communicate to the YCRCB2RGB core.
*
* XYCrCb2Rgb_CfgInitialize() API is used to initialize the YCRCB2RGB core.
* The user needs to first call the XYCrCb2Rgb_LookupConfig() API which returns
* the Configuration structure pointer which is passed as a parameter to the
* XYCrCb2Rgb_CfgInitialize() API.
*
* <b> Interrupts </b>
*
* The driver provides an interrupt handler XYCrCb2Rgb_IntrHandler for handling
* the interrupt from the YCRCB2RGB core. The users of this driver have to
* register this handler with the interrupt system and provide the callback
* functions by using XYCrCb2Rgb_SetCallBack API.
*
* <b> Virtual Memory </b>
*
* This driver supports Virtual Memory. The RTOS is responsible for calculating
* the correct device base address in Virtual Memory space.
*
* <b> Threads </b>
*
* This driver is not thread safe. Any needs for threads or thread mutual
* exclusion must be satisfied by the layer above this driver.
*
* <b> Asserts </b>
*
* Asserts are used within all Xilinx drivers to enforce constraints on argument
* values. Asserts can be turned off on a system-wide basis by defining, at
* compile time, the NDEBUG identifier. By default, asserts are turned on and it
* is recommended that users leave asserts on during development.
*
* <b> Building the driver </b>
*
* The XYCrCb2Rgb driver is composed of several source files. This allows the user
* to build and link only those parts of the driver that are necessary.
*
*<pre>
* MODIFICATION HISTORY:
*
* Ver Who Date Changes
* ----- ------ -------- -------------------------------------------------------
* 5.00a tb 02/28/12 Updated for YCRCB2RGB V5.00.a
* 5.01a bao 12/28/12 Converted from xio.h to xil_io.h, translating basic
* types, MB cache functions, exceptions and assertions
* to xil_io format.
* 6.0 adk 19/12/13 Updated as per the New Tcl API's
* 7.0 adk 01/31/14 Changed the file name from "ycrcb2rgb.h" to
* "xycrcb2rgb.h".
*
* Moved register offsets and bit definitions from
* ycrcb2rgb.h file to xycrcb2rgb_hw.h file.
*
* Removed YCC_TIMING_STATUS register offset because this
* register is not present in latest product guide.
*
* Removed following function macros:
* YCC_Enable, YCC_Disable, YCC_RegUpdateEnable,
* YCC_RegUpdateDisable, YCC_Reset, YCC_ClearReset,
* YCC_AutoSyncReset, ycc_max..
*
* Removed following functions:
* YCC_select_standard, YCC_coefficient_translation,
* YCC_set_coefficients, YCC_get_coefficients.
*
* Added following handler types as enum:
* XYCC_HANDLER_PROCSTART, XYCC_HANDLER_FRAMEDONE,
* XYCC_HANDLER_ERROR.
*
* Added following standard types as enum:
* XYCC_STANDARD_ITU_601_SD, XYCC_STANDARD_ITU_709_NTSC,
* XYCC_STANDARD_ITU_709_PAL, XYCC_STANDARD_YUV,
* XYCC_STANDARD_CUSTOM.
*
* Added following output ranges as enum:
* XYCC_TV_16_TO_240, XYCC_STUDIO_16_TO_235,
* XYCC_GRAPHICS_0_TO_255.
*
* Added range macros for ActiveSize, RGBMAX, RGBMIN,
* ROFFSET, GOFFSET, BOFFSET registers.
*
* Added following function macros:
* XYCrCb2Rgb_IntrEnable, XYCrCb2Rgb_IntrDisable,
* XYCrCb2Rgb_StatusGetPending, XYCrCb2Rgb_IntrGetPending,
* XYCrCb2Rgb_IntrClear, XYCrCb2Rgb_Reset,
* XYCrCb2Rgb_Enable, XYCrCb2Rgb_Disable,
* XYCrCb2Rgb_Start, XYCrCb2Rgb_Stop,
* XYCrCb2Rgb_RegUpdateEnable,
* XYCrCb2Rgb_RegUpdateDisable,
* XYCrCb2Rgb_SyncReset, XYCrCb2Rgb_Max
*
* Added core, configuration and coefficient structure.
* Renamed ycc_coef_inputs -> XYCrCb2Rgb_Coef_Inputs and
* ycc_coef_outputs - > XYCrCb2Rgb_Coef_Outputs.
*
* Added callback functions typedef.
*
* Implemented XYCrCb2Rgb_LookupConfig in
* xycrcb2rgb_sinit.c
* Implemented XYCrCb2Rgb_SelfTest in
* xycrcb2rgb_selftest.c
* Implemented XYCrCb2Rgb_IntrHandler,
* XYCrCb2Rgb_SetCallBack in xycrcb2rgb_intr.c.
*
* Implemented following functions in xycrcb2rgb.c:
* XYCrCb2Rgb_CfgInitialize, XYCrCb2Rgb_EnableDbgByPass,
* XYCrCb2Rgb_IsDbgByPassEnabled,
* XYCrCb2Rgb_DisableDbgBypass,
* XYCrCb2Rgb_EnableDbgTestPattern,
* XYCrCb2Rgb_IsDbgTestPatternEnabled,
* XYCrCb2Rgb_DisableDbgTestPattern,
* XYCrCb2Rgb_GetVersion, XYCrCb2Rgb_GetDbgFrameCount,
* XYCrCb2Rgb_GetDbgLineCount,
* XYCrCb2Rgb_GetDbgPixelCount, XYCrCb2Rgb_Setup,
* XYCrCb2Rgb_SetActiveSize, XYCrCb2Rgb_GetActiveSize,
* XYCrCb2Rgb_SetRGBMax, XYCrCb2Rgb_GetRGBMax,
* XYCrCb2Rgb_SetRGBMin, XYCrCb2Rgb_GetRGBMin,
* XYCrCb2Rgb_SetROffset, XYCrCb2Rgb_GetROffset,
* XYCrCb2Rgb_SetGOffset, XYCrCb2Rgb_GetGOffset,
* XYCrCb2Rgb_SetBOffset, XYCrCb2Rgb_GetBOffset,
* XYCrCb2Rgb_SetCoefs, XYCrCb2Rgb_GetCoefs,
* XYCrCb2Rgb_Select_Standard,
* XYCrCb2Rgb_Coefficient_Translation,
* XYCrCb2Rgb_Select_OutputRange.
* 7.1 ms 01/31/17 Updated the parameter naming from
* XPAR_YCRCB2RGB_NUM_INSTANCES to
* XPAR_XYCRCB2RGB_NUM_INSTANCES to avoid compilation
* failure for XPAR_YCRCB2RGB_NUM_INSTANCES
* as the tools are generating
* XPAR_XYCRCB2RGB_NUM_INSTANCES in the generated
* xycrcb2rgb_g.c for fixing MISRA-C files. This is a
* fix for CR-967548 based on the update in the tools.
* ms 03/17/17 Added readme.txt file in examples folder for doxygen
* generation.
*</pre>
*
******************************************************************************/
#ifndef XYCRCB2RGB_H_
#define XYCRCB2RGB_H_ /**< Prevent circular inclusions by using protection
* macros */
#ifdef __cplusplus
extern "C" {
#endif
/***************************** Include Files *********************************/
#include "xycrcb2rgb_hw.h"
#include "xil_assert.h"
#include "xstatus.h"
/************************** Constant Definitions *****************************/
/** @name Handler Types
* @{
*/
/**
* These constants specify different types of handler and used to differentiate
* interrupt requests from core.
*/
enum {
XYCC_HANDLER_PROCSTART = 1, /**< A processing start event interrupt
* type */
XYCC_HANDLER_FRAMEDONE, /**< A frame done event interrupt
* type */
XYCC_HANDLER_ERROR /**< An error condition interrupt
* type */
} ;
/*@}*/
/** @name Standard Types
* @{
*/
/**
*
* These constants specify different types of standards used to represent
* standard color encoding.
*/
enum XYcc_Standards {
XYCC_STANDARD_ITU_601_SD = 0, /**< Standard ITU 601 SD. */
XYCC_STANDARD_ITU_709_NTSC, /**< Standard ITU 709 NTSC. */
XYCC_STANDARD_ITU_709_PAL, /**< Standard ITU 709 PAL. */
XYCC_STANDARD_YUV, /**< Standard YUV. */
XYCC_STANDARD_CUSTOM /**< Standard Custom. */
} ;
/*@}*/
/** @name Output Ranges
* @{
*/
/**
*
* These constants specify different ranges used for studio equipment,
* television and computer graphics respectively.
*/
enum XYcc_OutputRanges {
XYCC_TV_16_TO_240 = 0, /**< 16 to 240, for Television. */
XYCC_STUDIO_16_TO_235, /**< 16 to 235, for Studio Equipment. */
XYCC_GRAPHICS_0_TO_255 /**< 0 to 255, for Computer Graphics. */
} ;
/*@}*/
/** Active Size (VxH) range macros
* @{
*/
#define XYCC_ACT_SIZE_FIRST 32 /**< Starting value for H/V */
#define XYCC_ACT_SIZE_LAST 8192 /**< Ending value for H/V */
/*@}*/
/** RGBMAX, RGBMIN range macros
* @{
*/
#define XYCC_RGBMAX_MIN_FIRST 0 /**< Starting value for
* RGBMAX/RGBMIN */
#define XYCC_RGBMAX_MIN_LAST 255 /**< Ending value for RGBMAX/RGBMIN */
/*@}*/
/** ROFFSET, GOFFSET, BOFFSET range macros
* @{
*/
#define XYCC_RGBOFFSET_FIRST 0 /**< Starting value for ROFFSET/
* GOFFSET/BOFFSET */
#define XYCC_RGBOFFSET_LAST 255 /**< Ending value for ROFFSET/
* GOFFSET/BOFFSET */
/*@}*/
/***************** Macros (Inline Functions) Definitions *********************/
/*****************************************************************************/
/**
*
* This macro enables the YCrCb2Rgb core.
*
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance.
*
* @return None.
*
* @note C-style signature:
* void XYCrCb2Rgb_Enable(*XYCrCb2Rgb InstancePtr)
*
******************************************************************************/
#define XYCrCb2Rgb_Enable(InstancePtr) \
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
(XYCC_CONTROL_OFFSET), \
XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
(XYCC_CONTROL_OFFSET)) | (XYCC_CTL_SW_EN_MASK))
/*****************************************************************************/
/**
*
* This macro disables the YCrCb2Rgb core.
*
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance.
*
* @return None.
*
* @note C-style signature:
* void XYCrCb2Rgb_Disable(*XYCrCb2Rgb InstancePtr)
*
******************************************************************************/
#define XYCrCb2Rgb_Disable(InstancePtr) \
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
(XYCC_CONTROL_OFFSET), \
(XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
(XYCC_CONTROL_OFFSET)) & (~(XYCC_CTL_SW_EN_MASK))))
/*****************************************************************************/
/**
*
* This macro starts the YCrCb2Rgb core.
*
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance.
*
* @return None.
*
* @note C-style signature:
* void XYCrCb2Rgb_Start(*XYCrCb2Rgb InstancePtr)
*
******************************************************************************/
#define XYCrCb2Rgb_Start XYCrCb2Rgb_Enable
/*****************************************************************************/
/**
*
* This macro stops the YCrCb2Rgb core.
*
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance.
*
* @return None.
*
* @note C-style signature:
* void XYCrCb2Rgb_Stop(*XYCrCb2Rgb InstancePtr)
*
******************************************************************************/
#define XYCrCb2Rgb_Stop XYCrCb2Rgb_Disable
/*****************************************************************************/
/**
*
* This macro enables copying from updated processor register values to
* the active set at the end of each AXI-Stream frame.
*
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance.
*
* @return None.
*
* @note C-style signature:
* void XYCrCb2Rgb_RegUpdateEnable(*XYCrCb2Rgb InstancePtr)
*
******************************************************************************/
#define XYCrCb2Rgb_RegUpdateEnable(InstancePtr) \
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
(XYCC_CONTROL_OFFSET), \
(XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
(XYCC_CONTROL_OFFSET)) | (XYCC_CTL_RUE_MASK)))
/*****************************************************************************/
/**
*
* This macro disables copying from updated processor register values to
* the active set at the end of each AXI-Stream frame.
*
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance.
*
* @return None.
*
* @note C-style signature:
* void XYCrCb2Rgb_RegUpdateDisable(*XYCrCb2Rgb InstancePtr)
*
******************************************************************************/
#define XYCrCb2Rgb_RegUpdateDisable(InstancePtr) \
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
(XYCC_CONTROL_OFFSET), \
(XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
(XYCC_CONTROL_OFFSET)) & (~(XYCC_CTL_RUE_MASK))))
/*****************************************************************************/
/**
*
* This macro resets a the YCrCb2Rgb core, but differs from XYCrCb2Rgb_Reset()
* in that it automatically synchronizes to the VBlank_in input of the core to
* prevent tearing.
*
* On the next rising-edge of VBlank_in following a call to
* XYCrCb2Rgb_SyncReset(), all of the core's configuration registers and
* outputs will be reset, then the reset flag will be immediately released,
* allowing the core to immediately resume default operation.
*
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance.
*
* @return None.
*
* @note C-style signature:
* void XYCrCb2Rgb_SyncReset(*XYCrCb2Rgb InstancePtr)
*
******************************************************************************/
#define XYCrCb2Rgb_SyncReset(InstancePtr) \
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
(XYCC_CONTROL_OFFSET), (XYCC_CTL_AUTORESET_MASK))
/*****************************************************************************/
/**
*
* This macro resets the YCrCb2Rgb core.. This reset effects the core
* immediately and may cause image tearing.
*
* @param InstancePtr is a pointer to the XYCrCb2Rgb instance.
*
* @return None.
*
* @note C-style signature:
* void XYCrCb2Rgb_Reset(XYCrCb2Rgb *InstancePtr)
*
******************************************************************************/
#define XYCrCb2Rgb_Reset(InstancePtr) \
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
(XYCC_CONTROL_OFFSET), (XYCC_CTL_RESET_MASK))
/*****************************************************************************/
/**
*
* This function macro enables individual interrupts of the YCRCB2RGB core by
* updating the IRQ_ENABLE register.
*
* @param InstancePtr is a pointer to the YCrCb2Rgb core instance
* to be worked on.
* @param IntrType is the bit-mask of the interrupts to be enabled.
* Bit positions of 1 will be enabled. Bit positions of 0 will
* keep the previous setting. This mask is formed by OR'ing
* XYCC_IXR_*_MASK bits defined in xycrcb2rgb_hw.h.
*
* @return None
*
* @note C-style signature:
* void XYCrCb2Rgb_IntrEnable(XYCrCb2Rgb *InstancePtr,
* u32 IntrType)
*
* The existing enabled interrupt(s) will remain enabled.
*
******************************************************************************/
#define XYCrCb2Rgb_IntrEnable(InstancePtr, IntrType) \
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
(XYCC_IRQ_EN_OFFSET), (((IntrType) & \
(XYCC_IXR_ALLINTR_MASK)) | \
(XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
(XYCC_IRQ_EN_OFFSET)))))
/*****************************************************************************/
/**
*
* This function macro disables individual interrupts of the YCRCB2RGB core by
* updating the IRQ_ENABLE register.
*
* @param InstancePtr is a pointer to the YCrCb2Rgb core instance
* to be worked on.
* @param IntrType is the bit-mask of the interrupts to be disabled.
* Bit positions of 1 will be disabled. Bit positions of 0 will
* keep the previous setting. This mask is formed by OR'ing
* XYCC_IXR_*_MASK bits defined in xycrcb2rgb_hw.h.
*
* @return None
*
* @note C-style signature:
* void XYCrCb2Rgb_IntrDisable(XYCrCb2Rgb *InstancePtr,
* u32 IntrType)
*
* Any other interrupt not covered by parameter IntrType, if
* enabled before this macro is called, will remain enabled.
*
******************************************************************************/
#define XYCrCb2Rgb_IntrDisable(InstancePtr, IntrType) \
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
(XYCC_IRQ_EN_OFFSET),\
XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
(XYCC_IRQ_EN_OFFSET)) & \
((~(IntrType)) & (XYCC_IXR_ALLINTR_MASK)))
/*****************************************************************************/
/**
*
* This function macro returns the pending interrupt status of the YCRCB2RGB
* core read from the Status register.
*
* @param InstancePtr is a pointer to the YCrCb2Rgb core instance
* to be worked on.
*
* @return The status of pending interrupts of the YCRCB2RGB core.
* Use XYCC_IXR_*_MASK constants defined in xycrcb2rgb_hw.h to
* interpret this value.
*
* @note C-style signature:
* XYCrCb2Rgb_StatusGePending(XYCC *InstancePtr)
*
******************************************************************************/
#define XYCrCb2Rgb_StatusGetPending(InstancePtr) \
XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
(XYCC_STATUS_OFFSET)) & (XYCC_IXR_ALLINTR_MASK)
/*****************************************************************************/
/**
*
* This function macro returns the pending interrupts of the YCRCB2RGB core for
* the interrupts that have been enabled.
*
* @param InstancePtr is a pointer to the YCrCb2Rgb core instance
* to be worked on.
*
* @return The pending interrupts of the YCRCB2RGB core. Use
* XYCC_IXR_*_MASK constants defined in xycrcb2rgb_hw.h to
* interpret this value. The returned value is a logical AND of
* the contents of the STATUS register and the IRQ_ENABLE
* register.
*
* @note C-style signature:
* u32 XYCC_IntrGetPending(XYCC *InstancePtr)
*
******************************************************************************/
#define XYCrCb2Rgb_IntrGetPending(InstancePtr) \
XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
(XYCC_IRQ_EN_OFFSET)) & \
(XYCrCb2Rgb_ReadReg((InstancePtr)->Config.BaseAddress, \
(XYCC_STATUS_OFFSET)) & \
((u32)(XYCC_IXR_ALLINTR_MASK)))
/*****************************************************************************/
/**
*
* This function macro clears/acknowledges pending interrupts of the YCRCB2RGB
* core in the Status register. Bit positions of 1 will be cleared.
*
* @param InstancePtr is a pointer to the YCRCB2RGB core instance
* to be worked on.
*
* @param IntrType is the pending interrupts to clear/acknowledge.
* Use OR'ing of XYCC_IXR_*_MASK constants defined in
* xycrcb2rgb_hw.h to create this parameter value.
*
* @return None.
*
* @note C-style signature:
* void XYCrCb2Rgb_IntrClear(XYCC *InstancePtr, u32 IntrType)
*
******************************************************************************/
#define XYCrCb2Rgb_IntrClear(InstancePtr, IntrType) \
XYCrCb2Rgb_WriteReg((InstancePtr)->Config.BaseAddress, \
(XYCC_STATUS_OFFSET), \
(IntrType) & (XYCC_IXR_ALLINTR_MASK))
/*****************************************************************************/
/**
*
* This macro identifies maximum number from given numbers.
*
* @param Num1 is a a u32 number.
* @param Num2 is a a u32 number.
*
* @return Maximum number from given two numbers.
*
* @note C-style signature:
* u32 XYCrCb2Rgb_Max(u32 Num1, u32 Num2)
*
******************************************************************************/
#define XYCrCb2Rgb_Max(Num1, Num2) (((Num1) > (Num2)) ? (Num1) : (Num2))
/*****************************************************************************/
/**************************** Type Definitions *******************************/
/**
* This typedef contains configuration information for a YCrCb2Rgb core.
* Each YCrCb2Rgb core should have a configuration structure associated.
*/
typedef struct {
u16 DeviceId; /**< DeviceId is the unique ID
* of the YCRCB2RGB core */
u32 BaseAddress; /**< BaseAddress is the physical base
* address of the YCRCB2RGB core
* registers */
u32 SlaveAxisVideoFormat; /**< Slave Axis Video Format */
u32 MasterAxisVideoFormat; /**< Master Axis Video Format */
u16 HasDebug; /**< Debugging support */
u16 HasIntcIf; /**< Interrupt controller support */
u32 MaxCols; /**< Maximum number of columns */
u32 ActiveCols; /**< Active number of columns */
u32 ActiveRows; /**< Active number of rows */
u32 MWidth; /**< MWidht */
u32 CoefRange; /**< Coefficient range */
u32 ACoef; /**< A Coefficient */
u32 BCoef; /**< B Coefficient */
u32 CCoef; /**< C Coefficient */
u32 DCoef; /**< D Coefficient */
u32 ROffset; /**< R Offset */
u32 GOffset; /**< G Offset */
u32 BOffset; /**< B Offset */
u16 HasClip; /**< Clipping support */
u16 HasClamp; /**< Clamping support */
u16 RgbMax; /**< RGB Max value */
u16 RgbMin; /**< RGB Min value */
u32 SlaveAxiClkFreqHz; /**< Slave Axis Clock frequency
* in Hz */
u32 StandardSelection; /**< Standard Selection */
u32 OutputRange; /**< Output Range */
} XYCrCb2Rgb_Config;
/*****************************************************************************/
/**
*
* Callback type for all interrupts except error interrupt.
*
* @param CallBackRef is a callback reference passed in by the upper
* layer when setting the callback functions, and passed back to
* the upper layer when the callback is invoked.
*
* @return None.
*
* @note None.
*
******************************************************************************/
typedef void (*XYCrCb2Rgb_CallBack)(void *CallBackRef);
/*****************************************************************************/
/**
*
* Callback type for error interrupt.
*
* @param CallBackRef is a callback reference passed in by the upper
* layer when setting the callback functions, and passed back to
* the upper layer when the callback is invoked.
* @param ErrorMask is a bit mask indicating the cause of the error. Its
* value equals 'OR'ing one or more XYCC_IXR_*_MASK values defined
* in xycrcb2rgb_hw.h.
*
* @return None.
*
* @note None.
*
******************************************************************************/
typedef void (*XYCrCb2Rgb_ErrorCallBack)(void *CallBackRef, u32 ErrorMask);
/*****************************************************************************/
/**
* The XYCrCb2Rgb driver instance data structure. A pointer to an instance data
* structure is passed around by functions to refer to a specific driver
* instance.
*/
typedef struct {
XYCrCb2Rgb_Config Config; /**< Hardware configuration */
u32 IsReady; /**< Device and the driver instance are initialized */
u16 HSize; /**< Active Video Horizontal Size */
u16 VSize; /**< Active Video Vertical Size */
/* IRQ Callbacks Here */
XYCrCb2Rgb_CallBack ProcStartCallBack; /**< Callback for Processing
* start interrupt */
void *ProcStartRef; /**< To be passed to Process start interrupt
* callback */
XYCrCb2Rgb_CallBack FrameDoneCallBack; /**< Callback for Frame Done
* interrupt */
void *FrameDoneRef; /**< To be passed to the Frame Done interrupt
* callback */
XYCrCb2Rgb_ErrorCallBack ErrCallBack; /**< Callback for Error
* interrupt */
void *ErrRef; /**< To be passed to the Error interrupt callback */
u32 StandardSelection; /**< Standard Selection */
u32 OutputRange; /**< Output Range */
} XYCrCb2Rgb;
/**
*
* YCrCb2Rgb input coefficient
*/
struct XYCrCb2Rgb_Coef_Inputs {
/* Pre-translated coefficient/offset data */
double ACoef; /**< [ 0.0 - 1.0 ] 0.0 < ACOEFF + BCOEFF < 1.0 */
double BCoef; /**< [ 0.0 - 1.0 ] 0.0 < ACOEFF + BCOEFF < 1.0 */
double CCoef; /**< [ 0.0 - 1.0 ] */
double DCoef; /**< [ 0.0 - 1.0 ] */
u32 YOffset; /**< Offset for the Luminance Channel */
u32 CbOffset; /**< Offset for the Chrominance Channels */
u32 CrOffset; /**< Offset for the Chrominance Channels */
u32 RgbMax; /**< RGB Clipping */
u32 RgbMin; /**< RGB Clamping */
} ;
/**
*
* YCrCb2Rgb output coefficient
*/
struct XYCrCb2Rgb_Coef_Outputs {
/* Translated coefficient/offset data */
u32 ACoef; /**< Translated ACoef */
u32 BCoef; /**< Translated BCoef */
u32 CCoef; /**< Translated CCoef */
u32 DCoef; /**< Translated DCoef */
u32 ROffset; /**< Translated Offset for the R Channel */
u32 GOffset; /**< Translated Offset for the G Channel */
u32 BOffset; /**< Translated Offset for the B Channel */
u32 RgbMax; /**< Translated RGB Clipping */
u32 RgbMin; /**< Translated RGB Clamping */
} ;
/**
*
* YCrCb2Rgb coefficients
*/
struct XYCrCb2Rgb_Coefficients {
double ACoef; /**< [ 0.0 - 1.0 ] 0.0 < ACOEFF + BCOEFF < 1.0 */
double BCoef; /**< [ 0.0 - 1.0 ] 0.0 < ACOEFF + BCOEFF < 1.0 */
double CCoef; /**< [ 0.0 - 1.0 ] */
double DCoef; /**< [ 0.0 - 1.0 ] */
} ;
/************************** Function Prototypes ******************************/
/*
* Initialization function implemented in xycrcb2rgb_sinit.c
*/
XYCrCb2Rgb_Config *XYCrCb2Rgb_LookupConfig(u16 DeviceId);
/* Following functions implemented in xycrcb2rgb.c */
int XYCrCb2Rgb_CfgInitialize(XYCrCb2Rgb *InstancePtr,
XYCrCb2Rgb_Config *CfgPtr, u32 EffectiveAddr);
void XYCrCb2Rgb_EnableDbgByPass(XYCrCb2Rgb *InstancePtr);
int XYCrCb2Rgb_IsDbgByPassEnabled(XYCrCb2Rgb *InstancePtr);
void XYCrCb2Rgb_DisableDbgBypass(XYCrCb2Rgb *InstancePtr);
void XYCrCb2Rgb_EnableDbgTestPattern(XYCrCb2Rgb *InstancePtr);
int XYCrCb2Rgb_IsDbgTestPatternEnabled(XYCrCb2Rgb *InstancePtr);
void XYCrCb2Rgb_DisableDbgTestPattern(XYCrCb2Rgb *InstancePtr);
u32 XYCrCb2Rgb_GetVersion(XYCrCb2Rgb *InstancePtr);
u32 XYCrCb2Rgb_GetDbgFrameCount(XYCrCb2Rgb *InstancePtr);
u32 XYCrCb2Rgb_GetDbgLineCount(XYCrCb2Rgb *InstancePtr);
u32 XYCrCb2Rgb_GetDbgPixelCount(XYCrCb2Rgb *InstancePtr);
void XYCrCb2Rgb_Setup(XYCrCb2Rgb *InstancePtr);
void XYCrCb2Rgb_SetActiveSize(XYCrCb2Rgb *InstancePtr, u16 HSize, u16 VSize);
void XYCrCb2Rgb_GetActiveSize(XYCrCb2Rgb *InstancePtr, u16 *HSize, u16 *VSize);
void XYCrCb2Rgb_SetRGBMax(XYCrCb2Rgb *InstancePtr, u32 RGBMax);
u32 XYCrCb2Rgb_GetRGBMax(XYCrCb2Rgb *InstancePtr);
void XYCrCb2Rgb_SetRGBMin(XYCrCb2Rgb *InstancePtr, u32 RGBMin);
u32 XYCrCb2Rgb_GetRGBMin(XYCrCb2Rgb *InstancePtr);
void XYCrCb2Rgb_SetROffset(XYCrCb2Rgb *InstancePtr, u32 ROffset);
u32 XYCrCb2Rgb_GetROffset(XYCrCb2Rgb *InstancePtr);
void XYCrCb2Rgb_SetGOffset(XYCrCb2Rgb *InstancePtr, u32 GOffset);
u32 XYCrCb2Rgb_GetGOffset(XYCrCb2Rgb *InstancePtr);
void XYCrCb2Rgb_SetBOffset(XYCrCb2Rgb *InstancePtr, u32 BOffset);
u32 XYCrCb2Rgb_GetBOffset(XYCrCb2Rgb *InstancePtr);
void XYCrCb2Rgb_SetCoefs(XYCrCb2Rgb *InstancePtr,
struct XYCrCb2Rgb_Coefficients *Coef);
void XYCrCb2Rgb_GetCoefs(XYCrCb2Rgb *InstancePtr,
struct XYCrCb2Rgb_Coefficients *Coef);
void XYCrCb2Rgb_Select_Standard(XYCrCb2Rgb *InstancePtr,
enum XYcc_Standards StandardSel,
enum XYcc_OutputRanges InputRange, u32 DataWidth,
struct XYCrCb2Rgb_Coef_Inputs *CoefIn);
u32 XYCrCb2Rgb_Coefficient_Translation(XYCrCb2Rgb *InstancePtr,
struct XYCrCb2Rgb_Coef_Inputs *CoefIn,
struct XYCrCb2Rgb_Coef_Outputs *CoefOut,
u32 DataWidth, u32 MWidth);
void XYCrCb2Rgb_Select_OutputRange(XYCrCb2Rgb *InstancePtr,
enum XYcc_OutputRanges Range);
/* Self-test function implemented in xycrcb2rgb_selftest.c */
int XYCrCb2Rgb_SelfTest(XYCrCb2Rgb *InstancePtr);
/* Interrupt related functions implemented in xycrcb2rgb_intr.c */
void XYCrCb2Rgb_IntrHandler(void *InstancePtr);
int XYCrCb2Rgb_SetCallBack(XYCrCb2Rgb *InstancePtr, u32 HandlerType,
void *CallBackFunc, void *CallBackRef);
/************************** Variable Declarations ****************************/
#ifdef __cplusplus
}
#endif
#endif /* End of protection macro */
/** @} */
| 37.237918 | 81 | 0.622109 |
3c358cfee7b0b6aab2f4ed6d0d74d0d264a15f58 | 12,330 | h | C | external/include/Random123/aes.h | RSE-Cambridge/sodecl | 5921588747836810e2dfd89975f36b514ecadb7d | [
"BSD-3-Clause"
] | 13 | 2018-01-19T14:08:33.000Z | 2021-04-08T06:40:58.000Z | external/include/Random123/aes.h | RSE-Cambridge/sodecl | 5921588747836810e2dfd89975f36b514ecadb7d | [
"BSD-3-Clause"
] | 11 | 2017-10-23T13:40:27.000Z | 2020-08-02T07:50:08.000Z | external/include/Random123/aes.h | RSE-Cambridge/sodecl | 5921588747836810e2dfd89975f36b514ecadb7d | [
"BSD-3-Clause"
] | 4 | 2018-05-15T15:07:26.000Z | 2021-04-08T06:41:01.000Z | /*
Copyright 2010-2011, D. E. Shaw Research.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions, and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions, and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of D. E. Shaw Research nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __Random123_aes_dot_hpp__
#define __Random123_aes_dot_hpp__
#include "features/compilerfeatures.h"
#include "array.h"
/* Implement a bona fide AES block cipher. It's minimally
// checked against the test vector in FIPS-197 in ut_aes.cpp. */
#if R123_USE_AES_NI
/** @ingroup AESNI */
typedef struct r123array1xm128i aesni1xm128i_ctr_t;
/** @ingroup AESNI */
typedef struct r123array1xm128i aesni1xm128i_ukey_t;
/** @ingroup AESNI */
typedef struct r123array4x32 aesni4x32_ukey_t;
/** @ingroup AESNI */
enum r123_enum_aesni1xm128i { aesni1xm128i_rounds = 10 };
/** \cond HIDDEN_FROM_DOXYGEN */
R123_STATIC_INLINE __m128i AES_128_ASSIST (__m128i temp1, __m128i temp2) {
__m128i temp3;
temp2 = _mm_shuffle_epi32 (temp2 ,0xff);
temp3 = _mm_slli_si128 (temp1, 0x4);
temp1 = _mm_xor_si128 (temp1, temp3);
temp3 = _mm_slli_si128 (temp3, 0x4);
temp1 = _mm_xor_si128 (temp1, temp3);
temp3 = _mm_slli_si128 (temp3, 0x4);
temp1 = _mm_xor_si128 (temp1, temp3);
temp1 = _mm_xor_si128 (temp1, temp2);
return temp1;
}
R123_STATIC_INLINE void aesni1xm128iexpand(aesni1xm128i_ukey_t uk, __m128i ret[11])
{
__m128i rkey = uk.v[0].m;
__m128i tmp2;
ret[0] = rkey;
tmp2 = _mm_aeskeygenassist_si128(rkey, 0x1);
rkey = AES_128_ASSIST(rkey, tmp2);
ret[1] = rkey;
tmp2 = _mm_aeskeygenassist_si128(rkey, 0x2);
rkey = AES_128_ASSIST(rkey, tmp2);
ret[2] = rkey;
tmp2 = _mm_aeskeygenassist_si128(rkey, 0x4);
rkey = AES_128_ASSIST(rkey, tmp2);
ret[3] = rkey;
tmp2 = _mm_aeskeygenassist_si128(rkey, 0x8);
rkey = AES_128_ASSIST(rkey, tmp2);
ret[4] = rkey;
tmp2 = _mm_aeskeygenassist_si128(rkey, 0x10);
rkey = AES_128_ASSIST(rkey, tmp2);
ret[5] = rkey;
tmp2 = _mm_aeskeygenassist_si128(rkey, 0x20);
rkey = AES_128_ASSIST(rkey, tmp2);
ret[6] = rkey;
tmp2 = _mm_aeskeygenassist_si128(rkey, 0x40);
rkey = AES_128_ASSIST(rkey, tmp2);
ret[7] = rkey;
tmp2 = _mm_aeskeygenassist_si128(rkey, 0x80);
rkey = AES_128_ASSIST(rkey, tmp2);
ret[8] = rkey;
tmp2 = _mm_aeskeygenassist_si128(rkey, 0x1b);
rkey = AES_128_ASSIST(rkey, tmp2);
ret[9] = rkey;
tmp2 = _mm_aeskeygenassist_si128(rkey, 0x36);
rkey = AES_128_ASSIST(rkey, tmp2);
ret[10] = rkey;
}
/** \endcond */
#ifdef __cplusplus
/** @ingroup AESNI */
struct aesni1xm128i_key_t{
__m128i k[11];
aesni1xm128i_key_t(){
aesni1xm128i_ukey_t uk;
uk.v[0].m = _mm_setzero_si128();
aesni1xm128iexpand(uk, k);
}
aesni1xm128i_key_t(const aesni1xm128i_ukey_t& uk){
aesni1xm128iexpand(uk, k);
}
aesni1xm128i_key_t(const aesni4x32_ukey_t& uk){
aesni1xm128i_ukey_t uk128;
uk128.v[0].m = _mm_set_epi32(uk.v[3], uk.v[2], uk.v[1], uk.v[0]);
aesni1xm128iexpand(uk128, k);
}
aesni1xm128i_key_t& operator=(const aesni1xm128i_ukey_t& uk){
aesni1xm128iexpand(uk, k);
return *this;
}
aesni1xm128i_key_t& operator=(const aesni4x32_ukey_t& uk){
aesni1xm128i_ukey_t uk128;
uk128.v[0].m = _mm_set_epi32(uk.v[3], uk.v[2], uk.v[1], uk.v[0]);
aesni1xm128iexpand(uk128, k);
return *this;
}
};
#else
typedef struct {
__m128i k[11];
}aesni1xm128i_key_t;
/** @ingroup AESNI */
R123_STATIC_INLINE aesni1xm128i_key_t aesni1xm128ikeyinit(aesni1xm128i_ukey_t uk){
aesni1xm128i_key_t ret;
aesni1xm128iexpand(uk, ret.k);
return ret;
}
#endif
/** @ingroup AESNI */
R123_STATIC_INLINE aesni1xm128i_ctr_t aesni1xm128i(aesni1xm128i_ctr_t in, aesni1xm128i_key_t k) {
__m128i x = _mm_xor_si128(k.k[0], in.v[0].m);
x = _mm_aesenc_si128(x, k.k[1]);
x = _mm_aesenc_si128(x, k.k[2]);
x = _mm_aesenc_si128(x, k.k[3]);
x = _mm_aesenc_si128(x, k.k[4]);
x = _mm_aesenc_si128(x, k.k[5]);
x = _mm_aesenc_si128(x, k.k[6]);
x = _mm_aesenc_si128(x, k.k[7]);
x = _mm_aesenc_si128(x, k.k[8]);
x = _mm_aesenc_si128(x, k.k[9]);
x = _mm_aesenclast_si128(x, k.k[10]);
{
aesni1xm128i_ctr_t ret;
ret.v[0].m = x;
return ret;
}
}
/** @ingroup AESNI */
R123_STATIC_INLINE aesni1xm128i_ctr_t aesni1xm128i_R(unsigned R, aesni1xm128i_ctr_t in, aesni1xm128i_key_t k){
R123_ASSERT(R==10);
return aesni1xm128i(in, k);
}
/** @ingroup AESNI */
typedef struct r123array4x32 aesni4x32_ctr_t;
/** @ingroup AESNI */
typedef aesni1xm128i_key_t aesni4x32_key_t;
/** @ingroup AESNI */
enum r123_enum_aesni4x32 { aesni4x32_rounds = 10 };
/** @ingroup AESNI */
R123_STATIC_INLINE aesni4x32_key_t aesni4x32keyinit(aesni4x32_ukey_t uk){
aesni1xm128i_ukey_t uk128;
aesni4x32_key_t ret;
uk128.v[0].m = _mm_set_epi32(uk.v[3], uk.v[2], uk.v[1], uk.v[0]);
aesni1xm128iexpand(uk128, ret.k);
return ret;
}
/** @ingroup AESNI */
/** The aesni4x32_R function provides a C API to the @ref AESNI "AESNI" CBRNG, allowing the number of rounds to be specified explicitly **/
R123_STATIC_INLINE aesni4x32_ctr_t aesni4x32_R(unsigned int Nrounds, aesni4x32_ctr_t c, aesni4x32_key_t k){
aesni1xm128i_ctr_t c128;
c128.v[0].m = _mm_set_epi32(c.v[3], c.v[2], c.v[1], c.v[0]);
c128 = aesni1xm128i_R(Nrounds, c128, k);
_mm_storeu_si128((__m128i*)&c.v[0], c128.v[0].m);
return c;
}
#define aesni4x32_rounds aesni1xm128i_rounds
/** The aesni4x32 macro provides a C API to the @ref AESNI "AESNI" CBRNG, uses the default number of rounds i.e. \c aesni4x32_rounds **/
/** @ingroup AESNI */
#define aesni4x32(c,k) aesni4x32_R(aesni4x32_rounds, c, k)
#ifdef __cplusplus
namespace r123{
/**
@defgroup AESNI ARS and AESNI Classes and Typedefs
The ARS4x32, ARS1xm128i, AESNI4x32 and AESNI1xm128i classes export the member functions, typedefs and
operator overloads required by a @ref CBRNG "CBRNG" class.
ARS1xm128i and AESNI1xm128i are based on the AES block cipher and rely on the AES-NI hardware instructions
available on some some new (2011) CPUs.
The ARS1xm128i CBRNG and the use of AES for random number generation are described in
<a href="http://dl.acm.org/citation.cfm?doid=2063405"><i>Parallel Random Numbers: As Easy as 1, 2, 3</i> </a>.
Although it uses some cryptographic primitives, ARS1xm128i uses a cryptographically weak key schedule and is \b not suitable for cryptographic use.
@class AESNI1xm128i
@ingroup AESNI
AESNI exports the member functions, typedefs and operator overloads required by a @ref CBRNG class.
AESNI1xm128i uses the crypotgraphic AES round function, including the cryptographic key schedule.
In contrast to the other CBRNGs in the Random123 library, the AESNI1xm128i_R::key_type is opaque
and is \b not identical to the AESNI1xm128i_R::ukey_type. Creating a key_type, using either the constructor
or assignment operator, is significantly more time-consuming than running the bijection (hundreds
of clock cycles vs. tens of clock cycles).
AESNI1xm128i is only available when the feature-test macro R123_USE_AES_NI is true, which
should occur only when the compiler is configured to generate AES-NI instructions (or
when defaults are overridden by compile-time, compiler-command-line options).
As of September 2011, the authors know of no statistical flaws with AESNI1xm128i. It
would be an event of major cryptographic note if any such flaws were ever found.
*/
struct AESNI1xm128i{
typedef aesni1xm128i_ctr_t ctr_type;
typedef aesni1xm128i_ukey_t ukey_type;
typedef aesni1xm128i_key_t key_type;
static const unsigned int rounds=10;
ctr_type operator()(ctr_type ctr, key_type key) const{
return aesni1xm128i(ctr, key);
}
};
/* @class AESNI4x32 */
struct AESNI4x32{
typedef aesni4x32_ctr_t ctr_type;
typedef aesni4x32_ukey_t ukey_type;
typedef aesni4x32_key_t key_type;
static const unsigned int rounds=10;
ctr_type operator()(ctr_type ctr, key_type key) const{
return aesni4x32(ctr, key);
}
};
/** @ingroup AESNI
@class AESNI1xm128i_R
AESNI1xm128i_R is provided for completeness, but is only instantiable with ROUNDS=10, in
which case it is identical to AESNI1xm128i */
template <unsigned ROUNDS=10>
struct AESNI1xm128i_R : public AESNI1xm128i{
R123_STATIC_ASSERT(ROUNDS==10, "AESNI1xm128i_R<R> is only valid with R=10");
};
/** @class AESNI4x32_R **/
template <unsigned ROUNDS=10>
struct AESNI4x32_R : public AESNI4x32{
R123_STATIC_ASSERT(ROUNDS==10, "AESNI4x32_R<R> is only valid with R=10");
};
} // namespace r123
#endif /* __cplusplus */
#endif /* R123_USE_AES_NI */
#if R123_USE_AES_OPENSSL
#include <openssl/aes.h>
typedef struct r123array16x8 aesopenssl16x8_ctr_t;
typedef struct r123array16x8 aesopenssl16x8_ukey_t;
#ifdef __cplusplus
struct aesopenssl16x8_key_t{
AES_KEY k;
aesopenssl16x8_key_t(){
aesopenssl16x8_ukey_t ukey={{}};
AES_set_encrypt_key((const unsigned char *)&ukey.v[0], 128, &k);
}
aesopenssl16x8_key_t(const aesopenssl16x8_ukey_t& ukey){
AES_set_encrypt_key((const unsigned char *)&ukey.v[0], 128, &k);
}
aesopenssl16x8_key_t& operator=(const aesopenssl16x8_ukey_t& ukey){
AES_set_encrypt_key((const unsigned char *)&ukey.v[0], 128, &k);
return *this;
}
};
#else
typedef struct aesopenssl16x8_key_t{
AES_KEY k;
}aesopenssl16x8_key_t;
R123_STATIC_INLINE struct aesopenssl16x8_key_t aesopenssl16x8keyinit(aesopenssl16x8_ukey_t uk){
aesopenssl16x8_key_t ret;
AES_set_encrypt_key((const unsigned char *)&uk.v[0], 128, &ret.k);
return ret;
}
#endif
R123_STATIC_INLINE R123_FORCE_INLINE(aesopenssl16x8_ctr_t aesopenssl16x8_R(aesopenssl16x8_ctr_t ctr, aesopenssl16x8_key_t key));
R123_STATIC_INLINE
aesopenssl16x8_ctr_t aesopenssl16x8_R(aesopenssl16x8_ctr_t ctr, aesopenssl16x8_key_t key){
aesopenssl16x8_ctr_t ret;
AES_encrypt((const unsigned char*)&ctr.v[0], (unsigned char *)&ret.v[0], &key.k);
return ret;
}
#define aesopenssl16x8_rounds aesni4x32_rounds
#define aesopenssl16x8(c,k) aesopenssl16x8_R(aesopenssl16x8_rounds)
#ifdef __cplusplus
namespace r123{
struct AESOpenSSL16x8{
typedef aesopenssl16x8_ctr_t ctr_type;
typedef aesopenssl16x8_key_t key_type;
typedef aesopenssl16x8_ukey_t ukey_type;
static const unsigned int rounds=10;
ctr_type operator()(const ctr_type& in, const key_type& k){
ctr_type out;
AES_encrypt((const unsigned char *)&in[0], (unsigned char *)&out[0], &k.k);
return out;
}
};
} // namespace r123
#endif /* __cplusplus */
#endif /* R123_USE_AES_OPENSSL */
#endif
| 35.73913 | 148 | 0.709408 |
96251e8dad16a2dc9f282d056eed04ba9271b4da | 1,873 | h | C | include/jvcr_ecm_01/consts.h | cat-in-the-dark/ludum_43_game | 737bc08e6e2b7e3a92bb958b7c0a8ec0674d5a20 | [
"MIT"
] | null | null | null | include/jvcr_ecm_01/consts.h | cat-in-the-dark/ludum_43_game | 737bc08e6e2b7e3a92bb958b7c0a8ec0674d5a20 | [
"MIT"
] | null | null | null | include/jvcr_ecm_01/consts.h | cat-in-the-dark/ludum_43_game | 737bc08e6e2b7e3a92bb958b7c0a8ec0674d5a20 | [
"MIT"
] | null | null | null | #ifndef JVCR_ECM_01_CONSTS_H
#define JVCR_ECM_01_CONSTS_H
#define DISPLAY_WIDTH 256u
#define DISPLAY_HEIGHT 144u
#define DISPLAY_CHANNELS 4u
#define SPRITE_WIDTH 8u
#define SPRITE_HEIGHT 8u
#define TILE_WIDTH 8u
#define TILE_HEIGHT 8u
#define SCREEN_START 0x0
// To avoid 4bit settings, and simplify code we allocate 8 bits for color instead of 4 bits.
#define SCREEN_SIZE 0x9000 // 256x144 4-bit screen.
#define SCREEN_END (SCREEN_START+SCREEN_SIZE)
#define PALETTE_START SCREEN_END
#define PALETTE_LEN 32u // colors count
#define PALETTE_UNIT 4u // color size in bytes
#define PALETTE_SIZE (PALETTE_LEN*PALETTE_UNIT) // 16 x 24-bit RGBA color values
#define PALETTE_END (PALETTE_START+PALETTE_SIZE)
#define PALETTE_MAP_START PALETTE_END
#define PALETTE_MAP_SIZE 0x0008 // 16 x 4-bit color indexes
#define PALETTE_MAP_END (PALETTE_MAP_START+PALETTE_MAP_SIZE)
#define SPRITES_START PALETTE_MAP_END
#define SPRITE_BOX_WIDTH 64
#define SPRITE_BOX_HEIGHT 128
#define SPRITES_SIZE SPRITE_BOX_WIDTH*SPRITE_BOX_HEIGHT*SPRITE_WIDTH*SPRITE_HEIGHT // 1024 8x8 4bit sprites
#define SPRITES_END (SPRITES_START+SPRITES_SIZE)
#define MAP_START SPRITES_END
#define MAP_SIZE 0x9000 // 8x8 240x136 map cells
#define MAP_END (MAP_START+MAP_SIZE)
#define FONTS_START MAP_END
#define FONT_WIDTH 5
#define FONT_HEIGHT 7
#define FONT_SPACING 1
#define FONTS_UNIT 8u // 8 bytes
#define FONTS_LEN 256u
#define FONTS_SIZE (FONTS_UNIT*FONTS_LEN) // 8 bytes per symbol, 256 symbols
#define FONTS_END (FONTS_START+FONTS_SIZE)
#define GAMEPADS_START FONTS_END
#define GAMEPADS_SIZE 0x0004 // 4 gamepads x 8 buttons (Up Down Left Right A B X Y)
#define GAMEPADS_END (GAMEPADS_START+GAMEPADS_SIZE)
#define KEYBOARD_START GAMEPADS_END
#define KEYBOARD_SIZE 0x0004
#define KEYBOARD_END (KEYBOARD_START + KEYBOARD_SIZE)
#define RAM_SIZE (KEYBOARD_END-SCREEN_START)
#endif //JVCR_ECM_01_CONSTS_H
| 32.859649 | 107 | 0.822744 |
d0ec3d752e319f69410a8746386e9286630db96e | 1,722 | h | C | GomokuServer/GomokuServer/include/aws/gamelift/server/LogParameters.h | grecheg/aws-gamelift-sample | 8ced06ae741c0633e9e8525c138633c0b1388352 | [
"Apache-2.0"
] | 68 | 2016-09-28T23:57:00.000Z | 2022-01-12T04:02:38.000Z | GomokuServer/GomokuServer/include/aws/gamelift/server/LogParameters.h | grecheg/aws-gamelift-sample | 8ced06ae741c0633e9e8525c138633c0b1388352 | [
"Apache-2.0"
] | 5 | 2016-09-30T12:29:35.000Z | 2019-03-02T10:23:48.000Z | GomokuServer/GomokuServer/include/aws/gamelift/server/LogParameters.h | grecheg/aws-gamelift-sample | 8ced06ae741c0633e9e8525c138633c0b1388352 | [
"Apache-2.0"
] | 22 | 2016-09-29T23:20:48.000Z | 2020-08-06T04:22:16.000Z | /*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <aws/gamelift/common/GameLift_EXPORTS.h>
#ifndef GAMELIFT_USE_STD
#ifndef MAX_LOG_PATHS
#define MAX_LOG_PATHS 10
#endif
#ifndef MAX_PATH_LENGTH
#define MAX_PATH_LENGTH 1024
#endif
#endif
namespace Aws
{
namespace GameLift
{
namespace Server
{
class LogParameters
{
#ifdef GAMELIFT_USE_STD
public:
AWS_GAMELIFT_API LogParameters() {}
AWS_GAMELIFT_API LogParameters(const std::vector<std::string> &logPaths) : m_logPaths(logPaths){}
AWS_GAMELIFT_API std::vector<std::string> getLogPaths() const { return m_logPaths; }
private:
std::vector<std::string> m_logPaths;
};
#else
public:
AWS_GAMELIFT_API LogParameters() : m_count(0) {}
AWS_GAMELIFT_API LogParameters(const char** logPaths, int count);
AWS_GAMELIFT_API int getLogPathCount() const { return m_count; }
AWS_GAMELIFT_API const char* getLogPath(int index) const { return index < m_count ? m_logPaths[index] : nullptr; }
private:
char m_logPaths[MAX_LOG_PATHS][MAX_PATH_LENGTH];
int m_count;
};
#endif
} // namespace Server
} // namespace GameLift
} // namespace Aws
| 28.7 | 122 | 0.707317 |
d2d186d13f248ae1b71dcf5ac7fa33a589eb53fe | 159 | h | C | MGR_PBR/src/Moon.h | KosssteK/master-thesis | d3c3f6f3b1f5c56e047da63b00927d948974c32a | [
"MIT"
] | null | null | null | MGR_PBR/src/Moon.h | KosssteK/master-thesis | d3c3f6f3b1f5c56e047da63b00927d948974c32a | [
"MIT"
] | null | null | null | MGR_PBR/src/Moon.h | KosssteK/master-thesis | d3c3f6f3b1f5c56e047da63b00927d948974c32a | [
"MIT"
] | null | null | null | #pragma once
#include "engine/Container.h"
#include "engine/Object.h"
class Moon : public CAT::Container
{
public:
CAT::Object moon;
Moon();
~Moon();
};
| 11.357143 | 34 | 0.672956 |
3015d26aaf2aab81928f3212588a14ecc230c6c7 | 1,619 | h | C | include/spdlog/details/log_msg_buffer.h | hy05190134/fmm | d33adfd2e37d20778941ca41911c738873ff7bfd | [
"Apache-2.0"
] | 545 | 2017-11-13T11:45:24.000Z | 2022-03-31T12:31:54.000Z | include/spdlog/details/log_msg_buffer.h | hy05190134/fmm | d33adfd2e37d20778941ca41911c738873ff7bfd | [
"Apache-2.0"
] | 198 | 2017-12-28T14:54:27.000Z | 2022-03-31T10:54:31.000Z | include/spdlog/details/log_msg_buffer.h | hy05190134/fmm | d33adfd2e37d20778941ca41911c738873ff7bfd | [
"Apache-2.0"
] | 145 | 2018-01-17T14:29:42.000Z | 2022-03-16T03:06:47.000Z | // Copyright(c) 2015-present, Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#include "spdlog/details/log_msg.h"
#include "spdlog/fmt/bundled/core.h"
namespace spdlog {
namespace details {
// extend log_msg with internal buffer to store its payload.
// this is needed since log_msg holds string_views that points to stack data.
class log_msg_buffer : public log_msg
{
fmt::basic_memory_buffer<char, 200> buffer;
void update_string_views()
{
logger_name = string_view_t{buffer.data(), logger_name.size()};
payload = string_view_t{logger_name.end(), payload.size()};
}
public:
log_msg_buffer() = default;
explicit log_msg_buffer(const log_msg &orig_msg)
: log_msg{orig_msg}
{
buffer.append(logger_name.begin(), logger_name.end());
buffer.append(payload.begin(), payload.end());
update_string_views();
}
log_msg_buffer(const log_msg_buffer &other)
: log_msg{other}
{
buffer.append(logger_name.begin(), logger_name.end());
buffer.append(payload.begin(), payload.end());
update_string_views();
}
log_msg_buffer(log_msg_buffer &&other)
: log_msg{std::move(other)}
, buffer{std::move(other.buffer)}
{
update_string_views();
}
log_msg_buffer &operator=(log_msg_buffer &&other)
{
log_msg::operator=(std::move(other));
buffer = std::move(other.buffer);
update_string_views();
return *this;
}
};
} // namespace details
} // namespace spdlog | 26.983333 | 77 | 0.659666 |
fdb123296c446081d41e72d200025ec7e6bf4395 | 343 | h | C | 0mqmap/tags.h | mkiefel/worker_pool | 2f9973841d3098cc9077991143186ec764a00809 | [
"BSD-2-Clause"
] | null | null | null | 0mqmap/tags.h | mkiefel/worker_pool | 2f9973841d3098cc9077991143186ec764a00809 | [
"BSD-2-Clause"
] | null | null | null | 0mqmap/tags.h | mkiefel/worker_pool | 2f9973841d3098cc9077991143186ec764a00809 | [
"BSD-2-Clause"
] | null | null | null | #ifndef _TAGS_50C8919F7B4A_
#define _TAGS_50C8919F7B4A_
enum JobTags {
JOB_BUSY = 1,
JOB_DONE = 2,
JOB_QUEUED = 3,
JOB_WAIT = 4
};
enum QueueTags {
QUEUE_HEARTBEAT_TAG = 11,
QUEUE_JOB_TAG = 12,
QUEUE_KILL_TAG = 13
};
enum WorkerTags {
WORKER_HEARTBEAT_TAG = 21,
WORKER_UPDATE_TAG = 22
};
#endif /* _TAGS_50C8919F7B4A_ */
| 14.913043 | 32 | 0.708455 |
ca68f9bc3b3ed2108eae34f3207610691107ec5b | 37,893 | c | C | ckrdraw.c | OS2World/GAME-BOARD-Checkers | 8e57f034149818c4ac251a7aba20f89b514f04b7 | [
"BSD-3-Clause"
] | null | null | null | ckrdraw.c | OS2World/GAME-BOARD-Checkers | 8e57f034149818c4ac251a7aba20f89b514f04b7 | [
"BSD-3-Clause"
] | null | null | null | ckrdraw.c | OS2World/GAME-BOARD-Checkers | 8e57f034149818c4ac251a7aba20f89b514f04b7 | [
"BSD-3-Clause"
] | null | null | null | /*--------------------------------------------------------
CKRDRAW.C -- Ckd Board Drawing Functions, Version 0.40
(c) 1990, Charles Petzold
--------------------------------------------------------*/
#define INCL_WIN
#define INCL_GPI
#include <os2.h>
#include <stdlib.h>
#include "checkers.h"
#include "ckrdraw.h"
/*----------------------------------------
Defines for board and piece dimensions
----------------------------------------*/
#define BRD_HORZFRONT 500
#define BRD_HORZBACK 350
#define BRD_VERT 300
#define BRD_EDGE 75
#define BRD_HORZMARGIN 250
#define BRD_FRONTMARGIN 250
#define BRD_BACKMARGIN 250
#define PIECE_XAXIS (BRD_HORZBACK - 50)
#define PIECE_YAXIS (BRD_VERT - 50)
#define PIECE_HEIGHT 50
/*-------------------------------------
Global variables external to module
-------------------------------------*/
extern HAB hab ;
/*-------------------------------------
Global variables internal to module
-------------------------------------*/
// Background, board, and piece colors
static LONG clrBackground = CLR_CYAN ;
static LONG clrBlackSquare = CLR_DARKGREEN ;
static LONG clrWhiteSquare = CLR_PALEGRAY ;
static LONG clrBlackPiece = CLR_RED ;
static LONG clrWhitePiece = CLR_WHITE ;
// Text strings for saving colors to OS2.INI
static CHAR szApplication [] = "Checkers" ;
static CHAR szClrBackground [] = "Background Color" ;
static CHAR szClrBlackSquare [] = "Black Square Color" ;
static CHAR szClrWhiteSquare [] = "White Square Color" ;
static CHAR szClrBlackPiece [] = "Black Piece Color" ;
static CHAR szClrWhitePiece [] = "White Piece Color" ;
// Original viewport for adjusting board to window size
static RECTL rclOrigViewport ;
// Bitmaps for drawing pieces
static HDC hdcMemory, hdcMemory2 ;
static HPS hpsMemory, hpsMemory2 ;
static HBITMAP ahbmPiece[2][2], ahbmMask[2], ahbmSave[2], ahbmMove[2] ;
static SIZEL sizlPiece[2], sizlMove[2] ;
/*-------------------------------------------------------------
CkdQueryBoardDimensions: Obtains size of board with margins
-------------------------------------------------------------*/
VOID CkdQueryBoardDimensions (SIZEL *psizlPage)
{
psizlPage->cx = 8 * BRD_HORZFRONT + 2 * BRD_HORZMARGIN ;
psizlPage->cy = 8 * BRD_VERT + BRD_FRONTMARGIN + BRD_BACKMARGIN ;
}
/*-----------------------------------------------------------
CkdQuerySquareOrigin: Obtains lower left corner of square
-----------------------------------------------------------*/
static VOID CkdQuerySquareOrigin (SHORT x, SHORT y, POINTL *pptl)
{
pptl->x = BRD_HORZMARGIN + y * (BRD_HORZFRONT - BRD_HORZBACK) / 2 +
x * (y * BRD_HORZBACK + (8 - y) * BRD_HORZFRONT) / 8 ;
pptl->y = BRD_FRONTMARGIN + y * BRD_VERT ;
}
/*-----------------------------------------------------
CkdQuerySquareCoords: Obtains coordinates of square
-----------------------------------------------------*/
static VOID CkdQuerySquareCoords (SHORT x, SHORT y, POINTL aptl[])
{
CkdQuerySquareOrigin (x, y, aptl + 0) ;
CkdQuerySquareOrigin (x + 1, y, aptl + 1) ;
CkdQuerySquareOrigin (x + 1, y + 1, aptl + 2) ;
CkdQuerySquareOrigin (x, y + 1, aptl + 3) ;
}
/*-----------------------------------------------
CkdDrawBoardSquare: Draws one square of board
-----------------------------------------------*/
static LONG CkdDrawBoardSquare (HPS hps, SHORT x, SHORT y)
{
AREABUNDLE abnd ;
LINEBUNDLE lbnd ;
LONG lReturn ;
POINTL aptl[4] ;
GpiSavePS (hps) ;
if (x < 0 || x >= 8 || y < 0 || y >= 8)
{
GpiSetColor (hps, clrBackground) ;
}
else
{
lbnd.lColor = CLR_BLACK ;
GpiSetAttrs (hps, PRIM_LINE, LBB_COLOR, 0L, &lbnd) ;
abnd.lColor = (x + y) & 1 ? clrWhiteSquare : clrBlackSquare ;
GpiSetAttrs (hps, PRIM_AREA, LBB_COLOR, 0L, &abnd) ;
}
GpiBeginArea (hps, BA_ALTERNATE | BA_BOUNDARY) ;
CkdQuerySquareCoords (x, y, aptl) ;
GpiMove (hps, aptl + 3) ;
GpiPolyLine (hps, 4L, aptl) ;
lReturn = GpiEndArea (hps) ;
GpiRestorePS (hps, -1L) ;
return lReturn ;
}
/*----------------------------------------------------
CkdDrawAllBoardSquares: Draws all squares of board
----------------------------------------------------*/
static LONG CkdDrawAllBoardSquares (HPS hps)
{
SHORT x, y ;
for (y = 0 ; y < 8 ; y++)
for (x = 0 ; x < 8 ; x++)
if (CkdDrawBoardSquare (hps, x, y) == GPI_HITS)
return MAKELONG (x, y) ;
return MAKELONG (-1, -1) ;
}
/*------------------------------------------
CkdRenderPiece: Draws piece PS at (0, 0)
------------------------------------------*/
static VOID CkdRenderPiece (HPS hps, LONG lColor, LONG lColorLine, SHORT sKing)
{
ARCPARAMS arcp ;
AREABUNDLE abnd ;
LINEBUNDLE lbnd ;
POINTL ptl, aptlArc[2] ;
SHORT s ;
GpiSavePS (hps) ;
// Set colors for areas and outlines
abnd.lColor = lColor ;
GpiSetAttrs (hps, PRIM_AREA, ABB_COLOR, 0L, &abnd) ;
lbnd.lColor = lColorLine ;
GpiSetAttrs (hps, PRIM_LINE, LBB_COLOR, 0L, &lbnd) ;
// Set arc parameters
arcp.lP = PIECE_XAXIS / 2 ;
arcp.lQ = PIECE_YAXIS / 2 ;
arcp.lR = 0 ;
arcp.lS = 0 ;
GpiSetArcParams (hps, &arcp) ;
// draw the piece
for (s = 0 ; s <= sKing ; s++)
{
GpiBeginArea (hps, BA_ALTERNATE | BA_BOUNDARY) ;
ptl.x = 0 ;
ptl.y = PIECE_YAXIS / 2 + (s + 1) * PIECE_HEIGHT ;
GpiMove (hps, &ptl) ;
ptl.y -= PIECE_HEIGHT ;
GpiLine (hps, &ptl) ;
aptlArc[0].x = PIECE_XAXIS / 2 ;
aptlArc[0].y = s * PIECE_HEIGHT ;
aptlArc[1].x = PIECE_XAXIS ;
aptlArc[1].y = PIECE_YAXIS / 2 + s * PIECE_HEIGHT ;
GpiPointArc (hps, aptlArc) ;
ptl.x = PIECE_XAXIS ;
ptl.y = PIECE_YAXIS / 2 + (s + 1) * PIECE_HEIGHT ;
GpiLine (hps, &ptl) ;
GpiEndArea (hps) ;
}
ptl.x = PIECE_XAXIS / 2 ;
ptl.y = PIECE_YAXIS / 2 + (sKing ? 2 : 1) * PIECE_HEIGHT ;
GpiMove (hps, &ptl) ;
GpiFullArc (hps, DRO_OUTLINEFILL, MAKEFIXED (1,0)) ;
GpiRestorePS (hps, -1L) ;
}
/*----------------------------------------------------------
CkdRenderPieceBitmap: Draws piece on bitmap in memory PS
----------------------------------------------------------*/
static VOID CkdRenderPieceBitmap (HPS hpsMemory, LONG lColorBack, LONG lColor,
LONG lColorLine, SHORT sKing)
{
POINTL ptl ;
GpiSavePS (hpsMemory) ;
// Draw background of bitmap
GpiSetColor (hpsMemory, lColorBack) ;
ptl.x = 0 ;
ptl.y = 0 ;
GpiMove (hpsMemory, &ptl) ;
ptl.x = PIECE_XAXIS ;
ptl.y = PIECE_YAXIS + (sKing + 1) * PIECE_HEIGHT ;
GpiBox (hpsMemory, DRO_FILL, &ptl, 0L, 0L) ;
CkdRenderPiece (hpsMemory, lColor, lColorLine, sKing) ;
GpiRestorePS (hpsMemory, -1L) ;
}
/*------------------------------------------------------
CkdQuerySquareCenter: Obtains center of board square
------------------------------------------------------*/
static VOID CkdQuerySquareCenter (SHORT x, SHORT y, POINTL *pptlCenter)
{
POINTL aptl[4] ;
CkdQuerySquareCoords (x, y, aptl) ;
pptlCenter->x = (aptl[0].x + aptl[1].x + aptl[2].x + aptl[3].x) / 4 ;
pptlCenter->y = (aptl[1].y + aptl[2].y) / 2 ;
}
/*---------------------------------------------------------------------
CkdPieceOriginFromCenter: Converts center of square to piece origin
---------------------------------------------------------------------*/
static VOID CkdPieceOriginFromCenter (POINTL *pptl)
{
pptl->x -= PIECE_XAXIS / 2 ;
pptl->y -= PIECE_YAXIS / 2 ;
}
/*-----------------------------------------------------------------
CkdPieceOriginFromCenter: Same as above, but device coordinates
-----------------------------------------------------------------*/
static VOID CkdPieceOriginFromCenterDevice (POINTL *pptlOrg, POINTL *pptlCntr)
{
pptlOrg->x = pptlCntr->x - sizlPiece[0].cx / 2 ;
pptlOrg->y = pptlCntr->y - sizlPiece[0].cy / 2 ;
}
/*----------------------------------------------------------------
CkdQuerySquarePieceOrigin: Obtains origin of piece on a square
----------------------------------------------------------------*/
static VOID CkdQuerySquarePieceOrigin (SHORT x, SHORT y, POINTL *pptlOrigin)
{
CkdQuerySquareCenter (x, y, pptlOrigin) ;
CkdPieceOriginFromCenter (pptlOrigin) ;
}
/*-------------------------------------------------------------
CkdShowPiece: Draws a piece on the screen at specific point
-------------------------------------------------------------*/
static VOID CkdShowPiece (HPS hps, POINTL *pptlOrg, SHORT sColor, SHORT sKing)
{
POINTL aptl[3] ;
// Write out mask with bitwise AND
aptl[0] = *pptlOrg ;
aptl[1].x = pptlOrg->x + sizlPiece[sKing].cx ;
aptl[1].y = pptlOrg->y + sizlPiece[sKing].cy ;
aptl[2].x = 0 ;
aptl[2].y = 0 ;
GpiSetBitmap (hpsMemory, ahbmMask[sKing]) ;
GpiBitBlt (hps, hpsMemory, 3L, aptl, ROP_SRCAND, BBO_IGNORE) ;
// Write out piece with bitwise OR
aptl[0] = *pptlOrg ;
aptl[1].x = pptlOrg->x + sizlPiece[sKing].cx ;
aptl[1].y = pptlOrg->y + sizlPiece[sKing].cy ;
aptl[2].x = 0 ;
aptl[2].y = 0 ;
GpiSetBitmap (hpsMemory, ahbmPiece[sColor][sKing]) ;
GpiBitBlt (hps, hpsMemory, 3L, aptl, ROP_SRCPAINT, BBO_IGNORE) ;
GpiSetBitmap (hpsMemory, NULL) ;
}
/*---------------------------------------------------------------------
CkdDrawOnePiece: Draws a piece on the board at specific coordinates
---------------------------------------------------------------------*/
static VOID CkdDrawOnePiece (HPS hps, SHORT x, SHORT y,
BOARD *pbrd, SHORT sBottom)
{
POINTL ptlOrigin ;
SHORT i, sKing ;
i = CkdConvertCoordsToIndex (x, y, sBottom) ;
if (i == -1)
return ;
CkdQuerySquarePieceOrigin (x, y, &ptlOrigin) ;
GpiConvert (hps, CVTC_PAGE, CVTC_DEVICE, 1L, &ptlOrigin) ;
sKing = pbrd->ulKing & 1L << i ? 1 : 0 ;
if (pbrd->ulBlack & 1L << i)
CkdShowPiece (hps, &ptlOrigin, BLACK, sKing) ;
if (pbrd->ulWhite & 1L << i)
CkdShowPiece (hps, &ptlOrigin, WHITE, sKing) ;
}
/*------------------------------------------------------------------
CkdPointInsideTrapezoid: Determines if point is inside trapezoid
------------------------------------------------------------------*/
static BOOL CkdPointInsideTrapezoid (POINTL *pptl, POINTL aptl[])
{
if (pptl->x < aptl[0].x || pptl->x >= aptl[1].x)
return FALSE ;
if (pptl->y < aptl[0].y || pptl->y >= aptl[2].y)
return FALSE ;
if (pptl->x < (aptl[0].x * (aptl[3].y - pptl->y) +
aptl[3].x * (pptl->y - aptl[0].y)) /
(aptl[3].y - aptl[0].y))
return FALSE ;
if (pptl->x >= (aptl[1].x * (aptl[3].y - pptl->y) +
aptl[2].x * (pptl->y - aptl[0].y)) /
(aptl[3].y - aptl[0].y))
return FALSE ;
return TRUE ;
}
/*----------------------------------------------------
ColorDlgProc: Dialog procedure for changing colors
----------------------------------------------------*/
MRESULT EXPENTRY ColorDlgProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
{
static LONG *pclr ;
static SHORT sColor ;
CHAR *pchHeading ;
switch (msg)
{
case WM_INITDLG:
switch (* (PSHORT) PVOIDFROMMP (mp2))
{
case IDM_COLOR_BACKGROUND:
pchHeading = "Window Background Color" ;
pclr = &clrBackground ;
break ;
case IDM_COLOR_BLACK_SQUARE:
pchHeading = "Black Square Color" ;
pclr = &clrBlackSquare ;
break ;
case IDM_COLOR_WHITE_SQUARE:
pchHeading = "White Square Color" ;
pclr = &clrWhiteSquare ;
break ;
case IDM_COLOR_BLACK_PIECE:
pchHeading = "Black Piece Color" ;
pclr = &clrBlackPiece ;
break ;
case IDM_COLOR_WHITE_PIECE:
pchHeading = "White Piece Color" ;
pclr = &clrWhitePiece ;
break ;
}
WinSetDlgItemText (hwnd, IDD_HEADING, pchHeading) ;
sColor = (SHORT) *pclr ;
WinSendDlgItemMsg (hwnd, IDD_COLOR + sColor, BM_SETCHECK,
MPFROM2SHORT (TRUE, 0), NULL) ;
WinSetFocus (HWND_DESKTOP,
WinWindowFromID (hwnd, IDD_COLOR + sColor)) ;
return MRFROMSHORT (1) ;
case WM_CONTROL:
sColor = SHORT1FROMMP (mp1) - IDD_COLOR ;
return 0 ;
case WM_COMMAND:
switch (COMMANDMSG(&msg)->cmd)
{
case DID_OK:
*pclr = (LONG) sColor ;
WinDismissDlg (hwnd, TRUE) ;
return 0 ;
case DID_CANCEL:
WinDismissDlg (hwnd, FALSE) ;
return 0 ;
}
break ;
}
return WinDefDlgProc (hwnd, msg, mp1, mp2) ;
}
/*-------------------------------------------------
CkdCreatePS: Create PS for checker board window
-------------------------------------------------*/
HPS CkdCreatePS (HWND hwnd)
{
HDC hdc ;
HPS hps ;
SIZEL sizlPage ;
USHORT sDataSize ;
CkdQueryBoardDimensions (&sizlPage) ;
// Create PS and save original viewport
hdc = WinOpenWindowDC (hwnd) ;
hps = GpiCreatePS (hab, hdc, &sizlPage,
PU_ARBITRARY | GPIF_DEFAULT |
GPIT_MICRO | GPIA_ASSOC) ;
GpiQueryPageViewport (hps, &rclOrigViewport) ;
// Create memory DC's and PS's
hdcMemory = DevOpenDC (hab, OD_MEMORY, "*", 0L, NULL, NULL) ;
hpsMemory = GpiCreatePS (hab, hdcMemory, &sizlPage,
PU_ARBITRARY | GPIF_DEFAULT |
GPIT_MICRO | GPIA_ASSOC) ;
hdcMemory2 = DevOpenDC (hab, OD_MEMORY, "*", 0L, NULL, NULL) ;
hpsMemory2 = GpiCreatePS (hab, hdcMemory2, &sizlPage,
PU_ARBITRARY | GPIF_DEFAULT |
GPIT_MICRO | GPIA_ASSOC) ;
// Get colors from OS2.INI
sDataSize = sizeof (LONG) ;
WinQueryProfileData (hab, szApplication, szClrBackground,
&clrBackground, &sDataSize) ;
sDataSize = sizeof (LONG) ;
WinQueryProfileData (hab, szApplication, szClrBlackSquare,
&clrBlackSquare, &sDataSize) ;
sDataSize = sizeof (LONG) ;
WinQueryProfileData (hab, szApplication, szClrWhiteSquare,
&clrWhiteSquare, &sDataSize) ;
sDataSize = sizeof (LONG) ;
WinQueryProfileData (hab, szApplication, szClrBlackPiece,
&clrBlackPiece, &sDataSize) ;
sDataSize = sizeof (LONG) ;
WinQueryProfileData (hab, szApplication, szClrWhitePiece,
&clrWhitePiece, &sDataSize) ;
return hps ;
}
/*-------------------------------------------------------
CkdResizePS: Change page viewport for new window size
-------------------------------------------------------*/
VOID CkdResizePS (HPS hps, HWND hwnd)
{
LONG lScale ;
RECTL rclWindow, rclViewport ;
WinQueryWindowRect (hwnd, &rclWindow) ;
// Calculate scaling factor
lScale = min (65536L * rclWindow.xRight / rclOrigViewport.xRight,
65536L * rclWindow.yTop / rclOrigViewport.yTop) ;
// Adjust page viewport of window PS
rclViewport.xLeft = 0 ;
rclViewport.yBottom = 0 ;
rclViewport.xRight = lScale * rclOrigViewport.xRight / 65536L ;
rclViewport.yTop = lScale * rclOrigViewport.yTop / 65536L ;
rclViewport.xLeft = (rclWindow.xRight - rclViewport.xRight) / 2 ;
rclViewport.yBottom = (rclWindow.yTop - rclViewport.yTop) / 2 ;
rclViewport.xRight += rclViewport.xLeft ;
rclViewport.yTop += rclViewport.yBottom ;
GpiSetPageViewport (hps, &rclViewport) ;
// Similarly for memory PS's
rclViewport.xRight -= rclViewport.xLeft ;
rclViewport.yTop -= rclViewport.yBottom ;
rclViewport.xLeft = 0 ;
rclViewport.yBottom = 0 ;
GpiSetPageViewport (hpsMemory, &rclViewport) ;
GpiSetPageViewport (hpsMemory2, &rclViewport) ;
}
/*---------------------------------------------------
CkdDestroyPS: Destroy PS for checker board window
---------------------------------------------------*/
BOOL CkdDestroyPS (HPS hps)
{
// Save colors in OS2.INI
WinWriteProfileData (hab, szApplication, szClrBackground,
&clrBackground, sizeof (LONG)) ;
WinWriteProfileData (hab, szApplication, szClrBlackSquare,
&clrBlackSquare, sizeof (LONG)) ;
WinWriteProfileData (hab, szApplication, szClrWhiteSquare,
&clrWhiteSquare, sizeof (LONG)) ;
WinWriteProfileData (hab, szApplication, szClrBlackPiece,
&clrBlackPiece, sizeof (LONG)) ;
WinWriteProfileData (hab, szApplication, szClrWhitePiece,
&clrWhitePiece, sizeof (LONG)) ;
// Destroy memory PS's and close DC's
GpiDestroyPS (hpsMemory) ;
GpiDestroyPS (hpsMemory2) ;
DevCloseDC (hdcMemory) ;
DevCloseDC (hdcMemory2) ;
// Destroy screen PS
return GpiDestroyPS (hps) ;
}
/*-----------------------------------------------------------
CkdSetStandardColors: Sets colors to tournament standards
-----------------------------------------------------------*/
VOID CkdSetStandardColors (VOID)
{
clrBackground = CLR_CYAN ;
clrBlackSquare = CLR_DARKGREEN ;
clrWhiteSquare = CLR_PALEGRAY ;
clrBlackPiece = CLR_RED ;
clrWhitePiece = CLR_WHITE ;
}
/*------------------------------------------------------------
CkdCreatePieces: Creates bitmaps to use for drawing pieces
------------------------------------------------------------*/
VOID CkdCreatePieces (HPS hps)
{
BITMAPINFOHEADER bmp ;
LONG alBitmapFormat[2] ;
SHORT sColor, sKing ;
// Get bitmap format of video display
GpiQueryDeviceBitmapFormats (hps, 2L, alBitmapFormat) ;
// Loop through possible color and size combinations
for (sKing = 0 ; sKing < 2 ; sKing++)
{
// Determine pixel dimensions of bitmaps
sizlPiece[sKing].cx = PIECE_XAXIS ;
sizlPiece[sKing].cy = PIECE_YAXIS + (sKing + 1) * PIECE_HEIGHT ;
GpiConvert (hpsMemory, CVTC_PAGE, CVTC_DEVICE, 1L,
(PPOINTL) &sizlPiece[sKing]) ;
sizlPiece[sKing].cx ++ ;
sizlPiece[sKing].cy ++ ;
sizlMove[sKing].cx = 2 * sizlPiece[sKing].cx ;
sizlMove[sKing].cy = 2 * sizlPiece[sKing].cy ;
// Set up BITMAPINFOHEADER structure
bmp.cbFix = sizeof bmp ;
bmp.cx = (SHORT) sizlPiece[sKing].cx ;
bmp.cy = (SHORT) sizlPiece[sKing].cy ;
bmp.cPlanes = (SHORT) alBitmapFormat[0] ;
bmp.cBitCount = (SHORT) alBitmapFormat[1] ;
// Create ahbmPiece bitmaps
for (sColor = BLACK ; sColor <= WHITE ; sColor++)
{
ahbmPiece[sColor][sKing] =
GpiCreateBitmap (hps, &bmp, 0L, 0L, NULL) ;
GpiSetBitmap (hpsMemory, ahbmPiece[sColor][sKing]) ;
CkdRenderPieceBitmap (hpsMemory, CLR_FALSE,
sColor ? clrWhitePiece : clrBlackPiece,
CLR_BLACK, sKing) ;
}
// Create ahbmMask bitmaps
ahbmMask[sKing] = GpiCreateBitmap (hps, &bmp, 0L, 0L, NULL) ;
GpiSetBitmap (hpsMemory, ahbmMask[sKing]) ;
CkdRenderPieceBitmap (hpsMemory, CLR_TRUE, CLR_FALSE, CLR_FALSE, sKing) ;
// Create ahbmSave bitmaps
ahbmSave[sKing] = GpiCreateBitmap (hps, &bmp, 0L, 0L, NULL) ;
// Create ahbmMove bitmaps
bmp.cbFix = sizeof bmp ;
bmp.cx = (SHORT) sizlMove[sKing].cx ;
bmp.cy = (SHORT) sizlMove[sKing].cy ;
bmp.cPlanes = (SHORT) alBitmapFormat[0] ;
bmp.cBitCount = (SHORT) alBitmapFormat[1] ;
ahbmMove[sKing] = GpiCreateBitmap (hps, &bmp, 0L, 0L, NULL) ;
}
GpiSetBitmap (hpsMemory, NULL) ;
}
/*---------------------------------------------------
CkdDestroyPieces: Destroy bitmaps used for pieces
---------------------------------------------------*/
VOID CkdDestroyPieces (VOID)
{
SHORT sColor, sKing ;
for (sKing = 0 ; sKing < 2 ; sKing++)
{
for (sColor = BLACK ; sColor <= WHITE ; sColor++)
if (ahbmPiece[sColor][sKing] != NULL)
GpiDeleteBitmap (ahbmPiece[sColor][sKing]) ;
if (ahbmMask[sKing] != NULL)
GpiDeleteBitmap (ahbmMask[sKing]) ;
if (ahbmSave[sKing] != NULL)
GpiDeleteBitmap (ahbmSave[sKing]) ;
if (ahbmMove[sKing] != NULL)
GpiDeleteBitmap (ahbmMove[sKing]) ;
}
}
/*--------------------------------------------------------------------
CkdDrawWindowBackground: Fills entire window with background color
--------------------------------------------------------------------*/
VOID CkdDrawWindowBackground (HPS hps, HWND hwnd)
{
RECTL rcl ;
WinQueryWindowRect (hwnd, &rcl) ;
WinFillRect (hps, &rcl, clrBackground) ;
}
/*-----------------------------------------------------------
CkdDrawWholeBoard: Draws the board squares and front edge
-----------------------------------------------------------*/
VOID CkdDrawWholeBoard (HPS hps)
{
AREABUNDLE abnd ;
LINEBUNDLE lbnd ;
SHORT x ;
POINTL aptl[4] ;
CkdDrawAllBoardSquares (hps) ;
GpiSavePS (hps) ;
lbnd.lColor = CLR_BLACK ;
GpiSetAttrs (hps, PRIM_LINE, LBB_COLOR, 0L, &lbnd) ;
for (x = 0 ; x < 8 ; x++)
{
CkdQuerySquareCoords (x, 0, aptl) ;
aptl[2].x = aptl[1].x ;
aptl[2].y = aptl[1].y - BRD_EDGE ;
aptl[3].x = aptl[0].x ;
aptl[3].y = aptl[0].y - BRD_EDGE ;
abnd.lColor = x & 1 ? clrWhiteSquare : clrBlackSquare ;
GpiSetAttrs (hps, PRIM_AREA, LBB_COLOR, 0L, &abnd) ;
GpiBeginArea (hps, BA_ALTERNATE | BA_BOUNDARY) ;
GpiMove (hps, aptl + 3) ;
GpiPolyLine (hps, 4L, aptl) ;
GpiEndArea (hps) ;
}
GpiRestorePS (hps, -1L) ;
}
/*-----------------------------------------------------
CkdDrawAllPieces: Draws all the pieces on the board
-----------------------------------------------------*/
VOID CkdDrawAllPieces (HPS hps, BOARD *pbrd, SHORT sBottom)
{
SHORT x, y ;
for (y = 0 ; y < 8 ; y++)
for (x = 0 ; x < 8 ; x++)
CkdDrawOnePiece (hps, x, y, pbrd, sBottom) ;
}
/*---------------------------------------------------------------------
CkdErasePiece: Erases piece from board by drawing the board squares
---------------------------------------------------------------------*/
VOID CkdErasePiece (HPS hps, SHORT x, SHORT y)
{
CkdDrawBoardSquare (hps, x, y + 1) ;
CkdDrawBoardSquare (hps, x, y) ;
}
/*---------------------------------------------------------------
CkdQueryHitCoords: Obtains coords from mouse pointer position
---------------------------------------------------------------*/
VOID CkdQueryHitCoords (HPS hps, POINTL ptlMouse, SHORT *px, SHORT *py)
{
POINTL aptl[4] ;
SHORT x, y ;
GpiConvert (hps, CVTC_DEVICE, CVTC_PAGE, 1L, &ptlMouse) ;
for (y = 0 ; y < 8 ; y++)
for (x = 0 ; x < 8 ; x++)
{
CkdQuerySquareCoords (x, y, aptl) ;
if (CkdPointInsideTrapezoid (&ptlMouse, aptl))
{
*px = x ;
*py = y ;
return ;
}
}
*px = -1 ;
*py = -1 ;
}
/*-----------------------------------------------------------------------
CkdConvertCoordsToIndex: Obtains index (0-31) from square coordinates
-----------------------------------------------------------------------*/
SHORT CkdConvertCoordsToIndex (SHORT x, SHORT y, SHORT sBottom)
{
if (x < 0 || x > 7 || y < 0 || y > 7)
return -1 ;
if ((x - (y & 1)) & 1)
return -1 ;
if (sBottom == WHITE)
{
x = 7 - x ;
y = 7 - y ;
}
return 3 ^ (4 * y + (x - (y & 1)) / 2) ;
}
/*-----------------------------------------------------------------------
CkdConvertIndexToCoords: Obtains square coordinates from index (0-31)
-----------------------------------------------------------------------*/
VOID CkdConvertIndexToCoords (SHORT i, SHORT *px, SHORT *py, SHORT sBottom)
{
if (i <= 0 || i >= 32)
{
*px = -1 ;
*py = -1 ;
}
*py = i / 4 ;
*px = 2 * ((i ^ 3) % 4) + (*py & 1) ;
if (sBottom == WHITE)
{
*px = 7 - *px ;
*py = 7 - *py ;
}
}
/*----------------------------------------------------
CkdDragSave: Saves screen area when dragging piece
----------------------------------------------------*/
VOID CkdDragSave (HPS hps, POINTL *pptlMouse, SHORT sKing)
{
POINTL ptlOrigin, aptl[3] ;
CkdPieceOriginFromCenterDevice (&ptlOrigin, pptlMouse) ;
aptl[0].x = 0 ;
aptl[0].y = 0 ;
aptl[1].x = sizlPiece[sKing].cx ;
aptl[1].y = sizlPiece[sKing].cy ;
aptl[2] = ptlOrigin ;
GpiSetBitmap (hpsMemory, ahbmSave[sKing]) ;
GpiBitBlt (hpsMemory, hps, 3L, aptl, ROP_SRCCOPY, BBO_IGNORE) ;
GpiSetBitmap (hpsMemory, NULL) ;
}
/*----------------------------------------------------------
CkdDragRestore: Restores screen area when dragging piece
----------------------------------------------------------*/
VOID CkdDragRestore (HPS hps, POINTL *pptlMouse, SHORT sKing)
{
POINTL ptlOrigin, aptl[3] ;
CkdPieceOriginFromCenterDevice (&ptlOrigin, pptlMouse) ;
aptl[0] = ptlOrigin ;
aptl[1].x = ptlOrigin.x + sizlPiece[sKing].cx ;
aptl[1].y = ptlOrigin.y + sizlPiece[sKing].cy ;
aptl[2].x = 0 ;
aptl[2].y = 0 ;
GpiSetBitmap (hpsMemory, ahbmSave[sKing]) ;
GpiBitBlt (hps, hpsMemory, 3L, aptl, ROP_SRCCOPY, BBO_IGNORE) ;
GpiSetBitmap (hpsMemory, NULL) ;
}
/*-------------------------------------------------------------
CkdDragShow: Shows piece in new position when being dragged
-------------------------------------------------------------*/
VOID CkdDragShow (HPS hps, POINTL *pptlMouse, SHORT sColor, SHORT sKing)
{
POINTL ptlOrigin, aptl[3] ;
CkdPieceOriginFromCenterDevice (&ptlOrigin, pptlMouse) ;
// Write out mask with bitwise AND
aptl[0] = ptlOrigin ;
aptl[1].x = ptlOrigin.x + sizlPiece[sKing].cx ;
aptl[1].y = ptlOrigin.y + sizlPiece[sKing].cy ;
aptl[2].x = 0 ;
aptl[2].y = 0 ;
GpiSetBitmap (hpsMemory, ahbmMask[sKing]) ;
GpiBitBlt (hps, hpsMemory, 3L, aptl, ROP_SRCAND, BBO_IGNORE) ;
// Write out piece with bitwise OR
aptl[0] = ptlOrigin ;
aptl[1].x = ptlOrigin.x + sizlPiece[sKing].cx ;
aptl[1].y = ptlOrigin.y + sizlPiece[sKing].cy ;
aptl[2].x = 0 ;
aptl[2].y = 0 ;
GpiSetBitmap (hpsMemory, ahbmPiece[sColor][sKing]) ;
GpiBitBlt (hps, hpsMemory, 3L, aptl, ROP_SRCPAINT, BBO_IGNORE) ;
GpiSetBitmap (hpsMemory, NULL) ;
}
/*-------------------------------------------------------------
CkdDragMove: Moves piece from one part of screen to another
-------------------------------------------------------------*/
VOID CkdDragMove (HPS hps, POINTL *pptlFrom, POINTL *pptlTo,
SHORT sColor, SHORT sKing)
{
POINTL ptlCenter, ptlOrigin, aptl[3], ptlFrom, ptlTo ;
if ((labs (pptlFrom->x - pptlTo->x) > sizlPiece[sKing].cx) ||
(labs (pptlFrom->y - pptlTo->y) > sizlPiece[sKing].cy))
{
CkdDragRestore (hps, pptlFrom, sKing) ;
CkdDragSave (hps, pptlTo, sKing) ;
CkdDragShow (hps, pptlTo, sColor, sKing) ;
return ;
}
ptlCenter.x = min (pptlFrom->x, pptlTo->x) ;
ptlCenter.y = min (pptlFrom->y, pptlTo->y) ;
CkdPieceOriginFromCenterDevice (&ptlOrigin, &ptlCenter) ;
// Copy screen into ahbmMove bitmap in hpsMemory2
aptl[0].x = 0 ;
aptl[0].y = 0 ;
aptl[1].x = sizlMove[sKing].cx ;
aptl[1].y = sizlMove[sKing].cy ;
aptl[2] = ptlOrigin ;
GpiSetBitmap (hpsMemory2, ahbmMove[sKing]) ;
GpiBitBlt (hpsMemory2, hps, 3L, aptl, ROP_SRCCOPY, BBO_IGNORE) ;
// Do restore, save, & show to hpsMemory2
ptlFrom.x = pptlFrom->x - ptlOrigin.x ;
ptlFrom.y = pptlFrom->y - ptlOrigin.y ;
ptlTo.x = pptlTo->x - ptlOrigin.x ;
ptlTo.y = pptlTo->y - ptlOrigin.y ;
CkdDragRestore (hpsMemory2, &ptlFrom, sKing) ;
CkdDragSave (hpsMemory2, &ptlTo, sKing) ;
CkdDragShow (hpsMemory2, &ptlTo, sColor, sKing) ;
// Copy ahbmMove bitmap in hpsMemory2 to screen
aptl[0] = ptlOrigin ;
aptl[1].x = ptlOrigin.x + sizlMove[sKing].cx ;
aptl[1].y = ptlOrigin.y + sizlMove[sKing].cy ;
aptl[2].x = 0 ;
aptl[2].y = 0 ;
GpiBitBlt (hps, hpsMemory2, 3L, aptl, ROP_SRCCOPY, BBO_IGNORE) ;
GpiSetBitmap (hpsMemory2, NULL) ;
}
/*-----------------------------------------------
CkdDragDeposit: Displays piece at end of drag
-----------------------------------------------*/
VOID CkdDragDeposit (HPS hps, SHORT x, SHORT y, SHORT sColor, SHORT sKing)
{
POINTL ptlOrigin ;
CkdQuerySquarePieceOrigin (x, y, &ptlOrigin) ;
GpiConvert (hps, CVTC_PAGE, CVTC_DEVICE, 1L, &ptlOrigin) ;
CkdShowPiece (hps, &ptlOrigin, sColor, sKing) ;
}
/*----------------------------------------------------
CkdQueryNearestXYFromPoint: For keyboard interface
----------------------------------------------------*/
VOID CkdQueryNearestXYFromPoint (HPS hps, POINTL *pptlMouse, SHORT *px,
SHORT *py)
{
POINTL ptl, aptlSquare[4] ;
SHORT x, y ;
ptl = *pptlMouse ;
GpiConvert (hps, CVTC_DEVICE, CVTC_PAGE, 1L, &ptl) ;
for (y = 0 ; y < 7 ; y++)
{
CkdQuerySquareCoords (0, y, aptlSquare) ;
if (aptlSquare[3].y > ptl.y)
break ;
}
for (x = 0 ; x < 7 ; x++)
{
CkdQuerySquareCoords (x, y, aptlSquare) ;
if ((aptlSquare[0].x + aptlSquare[1].x) / 2 > ptl.x)
break ;
}
*px = x ;
*py = y ;
}
/*----------------------------------------------------
CkdSlightOffsetFromXY: For keyboard interface
----------------------------------------------------*/
VOID CkdQuerySlightOffsetFromXY (HPS hps, SHORT x, SHORT y, POINTL *pptl)
{
POINTL ptlCenter, ptlOrigin ;
CkdQuerySquareCenter (x, y, &ptlCenter) ;
CkdQuerySquareOrigin (x, y, &ptlOrigin) ;
pptl->x = (3 * ptlCenter.x + ptlOrigin.x) / 4 ;
pptl->y = (3 * ptlCenter.y + ptlOrigin.y) / 4 ;
GpiConvert (hps, CVTC_PAGE, CVTC_DEVICE, 1L, pptl) ;
}
/*--------------------------------------------------
CkdExternalSave: Save area (for external moves)
--------------------------------------------------*/
VOID CkdExternalSave (HPS hps, SHORT x, SHORT y, SHORT sKing)
{
POINTL ptl ;
CkdQuerySquareCenter (x, y, &ptl) ;
GpiConvert (hps, CVTC_PAGE, CVTC_DEVICE, 1L, &ptl) ;
CkdDragSave (hps, &ptl, sKing) ;
}
/*----------------------------------------------------------
CkdExternalShow: Show piece bitmap (for external moves)
----------------------------------------------------------*/
VOID CkdExternalShow (HPS hps, SHORT x, SHORT y, SHORT sColor, SHORT sKing)
{
POINTL ptl ;
CkdQuerySquareCenter (x, y, &ptl) ;
GpiConvert (hps, CVTC_PAGE, CVTC_DEVICE, 1L, &ptl) ;
CkdDragShow (hps, &ptl, sColor, sKing) ;
}
/*--------------------------------------------------------
CkdExternalRestore: Restore area (for external moves)
--------------------------------------------------------*/
VOID CkdExternalRestore (HPS hps, SHORT x, SHORT y, SHORT sKing)
{
POINTL ptl ;
CkdQuerySquareCenter (x, y, &ptl) ;
GpiConvert (hps, CVTC_PAGE, CVTC_DEVICE, 1L, &ptl) ;
CkdDragRestore (hps, &ptl, sKing) ;
}
/*---------------------------------------------------
CkdExternalMove: Move piece (for external moves)
---------------------------------------------------*/
VOID CkdExternalMove (HPS hps, SHORT sTimerBeg, SHORT sTimerEnd,
SHORT sTimerColor, SHORT sTimerKing,
SHORT sBottom, SHORT sTimerInc,
SHORT sTimerSteps)
{
POINTL ptlBeg, ptlEnd, ptlFrom, ptlTo ;
SHORT x, y ;
CkdConvertIndexToCoords (sTimerBeg, &x, &y, sBottom) ;
CkdQuerySquareCenter (x, y, &ptlBeg) ;
GpiConvert (hps, CVTC_PAGE, CVTC_DEVICE, 1L, &ptlBeg) ;
CkdConvertIndexToCoords (sTimerEnd, &x, &y, sBottom) ;
CkdQuerySquareCenter (x, y, &ptlEnd) ;
GpiConvert (hps, CVTC_PAGE, CVTC_DEVICE, 1L, &ptlEnd) ;
ptlFrom.x = ( sTimerInc * ptlEnd.x +
(sTimerSteps - sTimerInc) * ptlBeg.x) / sTimerSteps ;
ptlFrom.y = ( sTimerInc * ptlEnd.y +
(sTimerSteps - sTimerInc) * ptlBeg.y) / sTimerSteps ;
ptlTo.x = ((sTimerInc + 1) * ptlEnd.x +
(sTimerSteps - sTimerInc - 1) * ptlBeg.x) / sTimerSteps ;
ptlTo.y = ((sTimerInc + 1) * ptlEnd.y +
(sTimerSteps - sTimerInc - 1) * ptlBeg.y) / sTimerSteps ;
CkdDragMove (hps, &ptlFrom, &ptlTo, sTimerColor, sTimerKing) ;
}
/*------------------------------------------------------
CkdDrawOnePieceDirect: Draw piece (for setup board)
------------------------------------------------------*/
VOID CkdDrawOnePieceDirect (HPS hps, SHORT x, SHORT y, BOARD *pbrd,
SHORT sBottom)
{
MATRIXLF matlf ;
POINTL ptlOrigin ;
SHORT i, sPiece, sKing ;
ULONG ulBit ;
i = CkdConvertCoordsToIndex (x, y, sBottom) ;
if (i == -1)
return ;
CkdQuerySquarePieceOrigin (x, y, &ptlOrigin) ;
ulBit = 1L << i ;
if (pbrd->ulBlack & ulBit)
sPiece = BLACK ;
else if (pbrd->ulWhite & ulBit)
sPiece = WHITE ;
else
return ;
sKing = pbrd->ulKing & ulBit ? 1 : 0 ;
// Move origin of PS
GpiTranslate (hps, &matlf, TRANSFORM_REPLACE, &ptlOrigin) ;
GpiSetModelTransformMatrix (hps, 9L, &matlf, TRANSFORM_REPLACE) ;
// Render the piece on the board
CkdRenderPiece (hps, sPiece ? clrWhitePiece : clrBlackPiece,
CLR_BLACK, sKing) ;
// Restore origin of PS
GpiSetModelTransformMatrix (hps, 0L, NULL, TRANSFORM_REPLACE) ;
}
/*------------------------------------------------------------
CkdDrawAllPiecesDirect: Draw all pieces (for setup board)
------------------------------------------------------------*/
VOID CkdDrawAllPiecesDirect (HPS hps, BOARD *pbrd, SHORT sBottom)
{
SHORT x, y ;
for (y = 0 ; y < 8 ; y++)
for (x = 0 ; x < 8 ; x++)
CkdDrawOnePieceDirect (hps, x, y, pbrd, sBottom) ;
}
| 32.359522 | 83 | 0.468556 |
30f36c8cd46455f6a555a3b7beea8be178cd377b | 12,859 | h | C | src/credentials/tests/CHIPCert_test_vectors.h | kowsisoundhar12/connectedhomeip | d1a4bb722b2ad3a9b8a52255b97d99f3c78100ac | [
"Apache-2.0"
] | null | null | null | src/credentials/tests/CHIPCert_test_vectors.h | kowsisoundhar12/connectedhomeip | d1a4bb722b2ad3a9b8a52255b97d99f3c78100ac | [
"Apache-2.0"
] | 6 | 2022-01-19T03:58:32.000Z | 2022-01-21T06:49:15.000Z | src/credentials/tests/CHIPCert_test_vectors.h | kowsisoundhar12/connectedhomeip | d1a4bb722b2ad3a9b8a52255b97d99f3c78100ac | [
"Apache-2.0"
] | 2 | 2021-12-02T09:08:00.000Z | 2021-12-03T07:31:44.000Z | /*
*
* Copyright (c) 2020-2021 Project CHIP Authors
* Copyright (c) 2019 Google LLC.
* Copyright (c) 2016-2017 Nest Labs, Inc.
* 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
* This file contains definitions of test certificates used by various unit tests.
*
*/
#pragma once
#include <credentials/CHIPCert.h>
#include <credentials/CHIPCertificateSet.h>
#include <lib/support/CodeUtils.h>
namespace chip {
namespace TestCerts {
using namespace chip::Credentials;
enum TestCert
{
kNone = 0,
kRoot01 = 1,
kRoot02 = 2,
kICA01 = 3,
kICA02 = 4,
kICA01_1 = 5,
kFWSign01 = 6,
kNode01_01 = 7,
kNode01_02 = 8,
kNode02_01 = 9,
kNode02_02 = 10,
kNode02_03 = 11,
kNode02_04 = 12,
kNode02_05 = 13,
kNode02_06 = 14,
kNode02_07 = 15,
kNode02_08 = 16,
};
// Special flags to alter how certificates are fetched/loaded.
enum class TestCertLoadFlags : uint8_t
{
kDERForm = 0x01,
kSuppressIsCA = 0x02,
kSuppressKeyUsage = 0x04,
kSuppressKeyCertSign = 0x08,
kSetPathLenConstZero = 0x10,
kSetAppDefinedCertType = 0x20,
};
extern CHIP_ERROR GetTestCert(uint8_t certType, BitFlags<TestCertLoadFlags> certLoadFlags, ByteSpan & cert);
extern const char * GetTestCertName(uint8_t certType);
extern CHIP_ERROR GetTestCertPubkey(uint8_t certType, ByteSpan & pubkey);
extern CHIP_ERROR GetTestCertSKID(uint8_t certType, ByteSpan & skid);
extern CHIP_ERROR GetTestCertAKID(uint8_t certType, ByteSpan & akid);
extern CHIP_ERROR LoadTestCert(ChipCertificateSet & certSet, uint8_t certType, BitFlags<TestCertLoadFlags> certLoadFlags,
BitFlags<CertDecodeFlags> decodeFlags);
extern const uint8_t gTestCerts[];
extern const size_t gNumTestCerts;
// ------------------------------ DECLARATIONS ----------------------------------------
extern const uint8_t sTestCert_Root01_Chip[];
extern const size_t sTestCert_Root01_Chip_Len;
extern const uint8_t sTestCert_Root01_DER[];
extern const size_t sTestCert_Root01_DER_Len;
extern const uint8_t sTestCert_Root01_PublicKey[];
extern const size_t sTestCert_Root01_PublicKey_Len;
extern const uint8_t sTestCert_Root01_PrivateKey[];
extern const size_t sTestCert_Root01_PrivateKey_Len;
extern const uint8_t sTestCert_Root01_SubjectKeyId[];
extern const size_t sTestCert_Root01_SubjectKeyId_Len;
extern const uint8_t sTestCert_Root01_AuthorityKeyId[];
extern const size_t sTestCert_Root01_AuthorityKeyId_Len;
extern const uint8_t sTestCert_Root02_Chip[];
extern const size_t sTestCert_Root02_Chip_Len;
extern const uint8_t sTestCert_Root02_DER[];
extern const size_t sTestCert_Root02_DER_Len;
extern const uint8_t sTestCert_Root02_PublicKey[];
extern const size_t sTestCert_Root02_PublicKey_Len;
extern const uint8_t sTestCert_Root02_PrivateKey[];
extern const size_t sTestCert_Root02_PrivateKey_Len;
extern const uint8_t sTestCert_Root02_SubjectKeyId[];
extern const size_t sTestCert_Root02_SubjectKeyId_Len;
extern const uint8_t sTestCert_Root02_AuthorityKeyId[];
extern const size_t sTestCert_Root02_AuthorityKeyId_Len;
extern const uint8_t sTestCert_ICA01_Chip[];
extern const size_t sTestCert_ICA01_Chip_Len;
extern const uint8_t sTestCert_ICA01_DER[];
extern const size_t sTestCert_ICA01_DER_Len;
extern const uint8_t sTestCert_ICA01_PublicKey[];
extern const size_t sTestCert_ICA01_PublicKey_Len;
extern const uint8_t sTestCert_ICA01_PrivateKey[];
extern const size_t sTestCert_ICA01_PrivateKey_Len;
extern const uint8_t sTestCert_ICA01_SubjectKeyId[];
extern const size_t sTestCert_ICA01_SubjectKeyId_Len;
extern const uint8_t sTestCert_ICA01_AuthorityKeyId[];
extern const size_t sTestCert_ICA01_AuthorityKeyId_Len;
extern const uint8_t sTestCert_ICA02_Chip[];
extern const size_t sTestCert_ICA02_Chip_Len;
extern const uint8_t sTestCert_ICA02_DER[];
extern const size_t sTestCert_ICA02_DER_Len;
extern const uint8_t sTestCert_ICA02_PublicKey[];
extern const size_t sTestCert_ICA02_PublicKey_Len;
extern const uint8_t sTestCert_ICA02_PrivateKey[];
extern const size_t sTestCert_ICA02_PrivateKey_Len;
extern const uint8_t sTestCert_ICA02_SubjectKeyId[];
extern const size_t sTestCert_ICA02_SubjectKeyId_Len;
extern const uint8_t sTestCert_ICA02_AuthorityKeyId[];
extern const size_t sTestCert_ICA02_AuthorityKeyId_Len;
extern const uint8_t sTestCert_ICA01_1_Chip[];
extern const size_t sTestCert_ICA01_1_Chip_Len;
extern const uint8_t sTestCert_ICA01_1_DER[];
extern const size_t sTestCert_ICA01_1_DER_Len;
extern const uint8_t sTestCert_ICA01_1_PublicKey[];
extern const size_t sTestCert_ICA01_1_PublicKey_Len;
extern const uint8_t sTestCert_ICA01_1_PrivateKey[];
extern const size_t sTestCert_ICA01_1_PrivateKey_Len;
extern const uint8_t sTestCert_ICA01_1_SubjectKeyId[];
extern const size_t sTestCert_ICA01_1_SubjectKeyId_Len;
extern const uint8_t sTestCert_ICA01_1_AuthorityKeyId[];
extern const size_t sTestCert_ICA01_1_AuthorityKeyId_Len;
extern const uint8_t sTestCert_FWSign01_Chip[];
extern const size_t sTestCert_FWSign01_Chip_Len;
extern const uint8_t sTestCert_FWSign01_DER[];
extern const size_t sTestCert_FWSign01_DER_Len;
extern const uint8_t sTestCert_FWSign01_PublicKey[];
extern const size_t sTestCert_FWSign01_PublicKey_Len;
extern const uint8_t sTestCert_FWSign01_PrivateKey[];
extern const size_t sTestCert_FWSign01_PrivateKey_Len;
extern const uint8_t sTestCert_FWSign01_SubjectKeyId[];
extern const size_t sTestCert_FWSign01_SubjectKeyId_Len;
extern const uint8_t sTestCert_FWSign01_AuthorityKeyId[];
extern const size_t sTestCert_FWSign01_AuthorityKeyId_Len;
extern const uint8_t sTestCert_Node01_01_Chip[];
extern const size_t sTestCert_Node01_01_Chip_Len;
extern const uint8_t sTestCert_Node01_01_DER[];
extern const size_t sTestCert_Node01_01_DER_Len;
extern const uint8_t sTestCert_Node01_01_PublicKey[];
extern const size_t sTestCert_Node01_01_PublicKey_Len;
extern const uint8_t sTestCert_Node01_01_PrivateKey[];
extern const size_t sTestCert_Node01_01_PrivateKey_Len;
extern const uint8_t sTestCert_Node01_01_SubjectKeyId[];
extern const size_t sTestCert_Node01_01_SubjectKeyId_Len;
extern const uint8_t sTestCert_Node01_01_AuthorityKeyId[];
extern const size_t sTestCert_Node01_01_AuthorityKeyId_Len;
extern const uint8_t sTestCert_Node01_01_Err01_Chip[];
extern const size_t sTestCert_Node01_01_Err01_Chip_Len;
extern const uint8_t sTestCert_Node01_02_Chip[];
extern const size_t sTestCert_Node01_02_Chip_Len;
extern const uint8_t sTestCert_Node01_02_DER[];
extern const size_t sTestCert_Node01_02_DER_Len;
extern const uint8_t sTestCert_Node01_02_PublicKey[];
extern const size_t sTestCert_Node01_02_PublicKey_Len;
extern const uint8_t sTestCert_Node01_02_PrivateKey[];
extern const size_t sTestCert_Node01_02_PrivateKey_Len;
extern const uint8_t sTestCert_Node01_02_SubjectKeyId[];
extern const size_t sTestCert_Node01_02_SubjectKeyId_Len;
extern const uint8_t sTestCert_Node01_02_AuthorityKeyId[];
extern const size_t sTestCert_Node01_02_AuthorityKeyId_Len;
extern const uint8_t sTestCert_Node02_01_Chip[];
extern const size_t sTestCert_Node02_01_Chip_Len;
extern const uint8_t sTestCert_Node02_01_DER[];
extern const size_t sTestCert_Node02_01_DER_Len;
extern const uint8_t sTestCert_Node02_01_PublicKey[];
extern const size_t sTestCert_Node02_01_PublicKey_Len;
extern const uint8_t sTestCert_Node02_01_PrivateKey[];
extern const size_t sTestCert_Node02_01_PrivateKey_Len;
extern const uint8_t sTestCert_Node02_01_SubjectKeyId[];
extern const size_t sTestCert_Node02_01_SubjectKeyId_Len;
extern const uint8_t sTestCert_Node02_01_AuthorityKeyId[];
extern const size_t sTestCert_Node02_01_AuthorityKeyId_Len;
extern const uint8_t sTestCert_Node02_02_Chip[];
extern const size_t sTestCert_Node02_02_Chip_Len;
extern const uint8_t sTestCert_Node02_02_DER[];
extern const size_t sTestCert_Node02_02_DER_Len;
extern const uint8_t sTestCert_Node02_02_PublicKey[];
extern const size_t sTestCert_Node02_02_PublicKey_Len;
extern const uint8_t sTestCert_Node02_02_PrivateKey[];
extern const size_t sTestCert_Node02_02_PrivateKey_Len;
extern const uint8_t sTestCert_Node02_02_SubjectKeyId[];
extern const size_t sTestCert_Node02_02_SubjectKeyId_Len;
extern const uint8_t sTestCert_Node02_02_AuthorityKeyId[];
extern const size_t sTestCert_Node02_02_AuthorityKeyId_Len;
extern const uint8_t sTestCert_Node02_03_Chip[];
extern const size_t sTestCert_Node02_03_Chip_Len;
extern const uint8_t sTestCert_Node02_03_DER[];
extern const size_t sTestCert_Node02_03_DER_Len;
extern const uint8_t sTestCert_Node02_03_PublicKey[];
extern const size_t sTestCert_Node02_03_PublicKey_Len;
extern const uint8_t sTestCert_Node02_03_PrivateKey[];
extern const size_t sTestCert_Node02_03_PrivateKey_Len;
extern const uint8_t sTestCert_Node02_03_SubjectKeyId[];
extern const size_t sTestCert_Node02_03_SubjectKeyId_Len;
extern const uint8_t sTestCert_Node02_03_AuthorityKeyId[];
extern const size_t sTestCert_Node02_03_AuthorityKeyId_Len;
extern const uint8_t sTestCert_Node02_04_Chip[];
extern const size_t sTestCert_Node02_04_Chip_Len;
extern const uint8_t sTestCert_Node02_04_DER[];
extern const size_t sTestCert_Node02_04_DER_Len;
extern const uint8_t sTestCert_Node02_04_PublicKey[];
extern const size_t sTestCert_Node02_04_PublicKey_Len;
extern const uint8_t sTestCert_Node02_04_PrivateKey[];
extern const size_t sTestCert_Node02_04_PrivateKey_Len;
extern const uint8_t sTestCert_Node02_04_SubjectKeyId[];
extern const size_t sTestCert_Node02_04_SubjectKeyId_Len;
extern const uint8_t sTestCert_Node02_04_AuthorityKeyId[];
extern const size_t sTestCert_Node02_04_AuthorityKeyId_Len;
extern const uint8_t sTestCert_Node02_05_Chip[];
extern const size_t sTestCert_Node02_05_Chip_Len;
extern const uint8_t sTestCert_Node02_05_DER[];
extern const size_t sTestCert_Node02_05_DER_Len;
extern const uint8_t sTestCert_Node02_05_PublicKey[];
extern const size_t sTestCert_Node02_05_PublicKey_Len;
extern const uint8_t sTestCert_Node02_05_PrivateKey[];
extern const size_t sTestCert_Node02_05_PrivateKey_Len;
extern const uint8_t sTestCert_Node02_05_SubjectKeyId[];
extern const size_t sTestCert_Node02_05_SubjectKeyId_Len;
extern const uint8_t sTestCert_Node02_05_AuthorityKeyId[];
extern const size_t sTestCert_Node02_05_AuthorityKeyId_Len;
extern const uint8_t sTestCert_Node02_06_Chip[];
extern const size_t sTestCert_Node02_06_Chip_Len;
extern const uint8_t sTestCert_Node02_06_DER[];
extern const size_t sTestCert_Node02_06_DER_Len;
extern const uint8_t sTestCert_Node02_06_PublicKey[];
extern const size_t sTestCert_Node02_06_PublicKey_Len;
extern const uint8_t sTestCert_Node02_06_PrivateKey[];
extern const size_t sTestCert_Node02_06_PrivateKey_Len;
extern const uint8_t sTestCert_Node02_06_SubjectKeyId[];
extern const size_t sTestCert_Node02_06_SubjectKeyId_Len;
extern const uint8_t sTestCert_Node02_06_AuthorityKeyId[];
extern const size_t sTestCert_Node02_06_AuthorityKeyId_Len;
extern const uint8_t sTestCert_Node02_07_Chip[];
extern const size_t sTestCert_Node02_07_Chip_Len;
extern const uint8_t sTestCert_Node02_07_DER[];
extern const size_t sTestCert_Node02_07_DER_Len;
extern const uint8_t sTestCert_Node02_07_PublicKey[];
extern const size_t sTestCert_Node02_07_PublicKey_Len;
extern const uint8_t sTestCert_Node02_07_PrivateKey[];
extern const size_t sTestCert_Node02_07_PrivateKey_Len;
extern const uint8_t sTestCert_Node02_07_SubjectKeyId[];
extern const size_t sTestCert_Node02_07_SubjectKeyId_Len;
extern const uint8_t sTestCert_Node02_07_AuthorityKeyId[];
extern const size_t sTestCert_Node02_07_AuthorityKeyId_Len;
extern const uint8_t sTestCert_Node02_08_Chip[];
extern const size_t sTestCert_Node02_08_Chip_Len;
extern const uint8_t sTestCert_Node02_08_DER[];
extern const size_t sTestCert_Node02_08_DER_Len;
extern const uint8_t sTestCert_Node02_08_PublicKey[];
extern const size_t sTestCert_Node02_08_PublicKey_Len;
extern const uint8_t sTestCert_Node02_08_PrivateKey[];
extern const size_t sTestCert_Node02_08_PrivateKey_Len;
extern const uint8_t sTestCert_Node02_08_SubjectKeyId[];
extern const size_t sTestCert_Node02_08_SubjectKeyId_Len;
extern const uint8_t sTestCert_Node02_08_AuthorityKeyId[];
extern const size_t sTestCert_Node02_08_AuthorityKeyId_Len;
} // namespace TestCerts
} // namespace chip
| 43.442568 | 121 | 0.843223 |
aa4d67a91d08347fa4c3efa0810a9f6660eae2f7 | 763 | h | C | src/esp/core/RigidState.h | qureshinomaan/habitat-sim | df2540b658d0444e84bbc7a0c3fb995f8d523b52 | [
"MIT"
] | 1 | 2020-07-23T03:39:27.000Z | 2020-07-23T03:39:27.000Z | src/esp/core/RigidState.h | qureshinomaan/habitat-sim | df2540b658d0444e84bbc7a0c3fb995f8d523b52 | [
"MIT"
] | null | null | null | src/esp/core/RigidState.h | qureshinomaan/habitat-sim | df2540b658d0444e84bbc7a0c3fb995f8d523b52 | [
"MIT"
] | 1 | 2021-07-06T05:32:03.000Z | 2021-07-06T05:32:03.000Z | // Copyright (c) Facebook, Inc. and its affiliates.
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
#pragma once
#include <Magnum/Magnum.h>
#include <Magnum/Math/Quaternion.h>
#include "esp.h"
namespace esp {
namespace core {
/**
* @brief describes the state of a rigid object as a composition of rotation
* (quaternion) and translation.
*/
struct RigidState {
RigidState(){};
RigidState(const Magnum::Quaternion& _rotation,
const Magnum::Vector3& _translation)
: rotation(_rotation), translation(_translation){};
Magnum::Quaternion rotation;
Magnum::Vector3 translation;
ESP_SMART_POINTERS(RigidState)
};
} // namespace core
} // namespace esp
| 24.612903 | 76 | 0.719528 |
106d50fdfb26c774ed4d6c7de7f1588e7290f9bc | 3,174 | h | C | subsys/net/ip/udp_internal.h | maxvankessel/zephyr | 769d91b922b736860244b22e25328d91d9a17657 | [
"Apache-2.0"
] | 7 | 2021-07-27T00:12:02.000Z | 2022-03-09T14:40:13.000Z | subsys/net/ip/udp_internal.h | maxvankessel/zephyr | 769d91b922b736860244b22e25328d91d9a17657 | [
"Apache-2.0"
] | 114 | 2021-06-21T03:38:38.000Z | 2021-07-08T05:27:34.000Z | subsys/net/ip/udp_internal.h | maxvankessel/zephyr | 769d91b922b736860244b22e25328d91d9a17657 | [
"Apache-2.0"
] | 11 | 2020-12-14T22:12:05.000Z | 2022-03-23T08:43:10.000Z | /** @file
@brief UDP data handler
This is not to be included by the application and is only used by
core IP stack.
*/
/*
* Copyright (c) 2017 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __UDP_INTERNAL_H
#define __UDP_INTERNAL_H
#include <zephyr/types.h>
#include <net/net_core.h>
#include <net/net_ip.h>
#include <net/net_pkt.h>
#include <net/net_context.h>
#include "connection.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Create UDP packet into net_pkt
*
* Note: pkt's cursor should be set a the right position.
* (i.e. after IP header)
*
* @param pkt Network packet
* @param src_port Destination port in network byte order.
* @param dst_port Destination port in network byte order.
*
* @return 0 on success, negative errno otherwise.
*/
#if defined(CONFIG_NET_NATIVE_UDP)
int net_udp_create(struct net_pkt *pkt, uint16_t src_port, uint16_t dst_port);
#else
static inline int net_udp_create(struct net_pkt *pkt,
uint16_t src_port, uint16_t dst_port)
{
ARG_UNUSED(pkt);
ARG_UNUSED(src_port);
ARG_UNUSED(dst_port);
return 0;
}
#endif
/**
* @brief Finalize UDP packet
*
* Note: calculates final length and setting up the checksum.
*
* @param pkt Network packet
*
* @return 0 on success, negative errno otherwise.
*/
#if defined(CONFIG_NET_NATIVE_UDP)
int net_udp_finalize(struct net_pkt *pkt);
#else
static inline int net_udp_finalize(struct net_pkt *pkt)
{
ARG_UNUSED(pkt);
return 0;
}
#endif
/**
* @brief Get pointer to UDP header in net_pkt
*
* @param pkt Network packet
* @param udp_access Helper variable for accessing UDP header
*
* @return UDP header on success, NULL on error
*/
#if defined(CONFIG_NET_NATIVE_UDP)
struct net_udp_hdr *net_udp_input(struct net_pkt *pkt,
struct net_pkt_data_access *udp_access);
#else
static inline
struct net_udp_hdr *net_udp_input(struct net_pkt *pkt,
struct net_pkt_data_access *udp_access)
{
ARG_UNUSED(pkt);
ARG_UNUSED(udp_access);
return NULL;
}
#endif
/**
* @brief Register a callback to be called when UDP packet
* is received corresponding to received packet.
*
* @param family Protocol family
* @param remote_addr Remote address of the connection end point.
* @param local_addr Local address of the connection end point.
* @param remote_port Remote port of the connection end point.
* @param local_port Local port of the connection end point.
* @param cb Callback to be called
* @param user_data User data supplied by caller.
* @param handle UDP handle that can be used when unregistering
*
* @return Return 0 if the registration succeed, <0 otherwise.
*/
int net_udp_register(uint8_t family,
const struct sockaddr *remote_addr,
const struct sockaddr *local_addr,
uint16_t remote_port,
uint16_t local_port,
net_conn_cb_t cb,
void *user_data,
struct net_conn_handle **handle);
/**
* @brief Unregister UDP handler.
*
* @param handle Handle from registering.
*
* @return Return 0 if the unregistration succeed, <0 otherwise.
*/
int net_udp_unregister(struct net_conn_handle *handle);
#ifdef __cplusplus
}
#endif
#endif /* __UDP_INTERNAL_H */
| 23.167883 | 78 | 0.730624 |
b752b91ed158ec51989622b7770b7420b0252d00 | 134 | h | C | duniverse/base/hash_types/src/internalhash.h | emillon/opam-monorepo | 243f2310ad01722df7a29fc0d497d8834fb71ec1 | [
"0BSD"
] | 641 | 2016-09-16T15:51:06.000Z | 2022-03-31T19:30:56.000Z | duniverse/base/hash_types/src/internalhash.h | emillon/opam-monorepo | 243f2310ad01722df7a29fc0d497d8834fb71ec1 | [
"0BSD"
] | 121 | 2016-09-17T07:30:00.000Z | 2022-03-03T21:00:03.000Z | duniverse/base/hash_types/src/internalhash.h | emillon/opam-monorepo | 243f2310ad01722df7a29fc0d497d8834fb71ec1 | [
"0BSD"
] | 95 | 2016-09-16T23:31:38.000Z | 2022-03-19T01:35:06.000Z | #include <stdint.h>
#include <caml/mlvalues.h>
CAMLexport uint32_t Base_internalhash_fold_blob(uint32_t h, mlsize_t len, uint8_t *s);
| 33.5 | 86 | 0.798507 |
a28a4f6956bc9cc90ab8c3d17ea68a74168b883b | 7,255 | h | C | async/wiki/async/IoService.h | Rahul18728/cerl | 8d90c03b2ffe397021bcb8c7198c713acf840bb4 | [
"MIT"
] | 443 | 2015-03-14T06:04:45.000Z | 2022-01-10T01:30:56.000Z | async/wiki/async/IoService.h | Rahul18728/cerl | 8d90c03b2ffe397021bcb8c7198c713acf840bb4 | [
"MIT"
] | null | null | null | async/wiki/async/IoService.h | Rahul18728/cerl | 8d90c03b2ffe397021bcb8c7198c713acf840bb4 | [
"MIT"
] | 125 | 2015-03-14T13:08:04.000Z | 2021-12-08T13:03:29.000Z | /*
@encoding utf8
@ns cerl
@*/
// -------------------------------------------------------------------------
// macro CerlIoService
/** 获得纤程的 FiberData 指针。不建议直接使用该宏。
@arg fiber
一个\<cerl::Fiber>对象句柄。
@return
返回纤程的 FiberData 指针。
@*/
#define CerlFiberData(fiber)
/** 获得纤程的序号。内部使用,不建议直接使用该宏。
@arg fiber
一个\<cerl::Fiber>对象句柄。
@return
返回该 Fiber 的序号。
@*/
#define CerlFiberSerialNo(fiber)
/** 获得纤程的 IoService 对象。
@arg fiber
一个\<Fibers>的句柄。
@return
返回 Fiber 的 \<IoService> 对象。
@*/
#define CerlIoService(fiber)
/** 获取纤程的 IoService 对象。
@arg lpParam
\<Fibers> 参数指针。
@return
返回 Fiber 的 \<IoService> 对象。
@*/
#define CerlFiberParamService(lpParam)
/** 获得为 Fiber 分配内存的内存分配器。
@arg fiber
一个 \<Fibers> 的句柄。
@return
返回 Fiber 使用的内存分配器。
@*/
#define CerlFiberAllocator(fiber)
/** 获取纤程所使用的内存池集合。
@arg fiber
一个 \<Fibers> 的句柄。
@return
返回该纤程所使用的内存池集合。
@see Pools
@*/
#define CerlMemPools(fiber)
/** 获取 Fiber 的 Log。
@arg fiber
一个 \<Fibers> 的句柄。
@return
返回该纤程的 Log。
@*/
#define CerlDefaultLog(fiber)
/** 获取纤程的 Timeout 值。
@arg fiber
一个 \<Fibers> 的句柄。
@return
返回该纤程的 Timeout 值。
@*/
#define CerlIoTimeout(fiber)
// -------------------------------------------------------------------------
// class IoService
/** IoService是为实现I/O操作而设计的,实现的主要功能包括:I/O管理、Task管理和Fiber调度
其中:Task,任务,是用来处理计算消耗型任务或者不可间断性I/O事件(如DB操作),
IoService提供的Task管理的工作就是负责向TaskPool投递任务消息。
使用Task的目的就是为了提高请求的吞吐量,减少请求的阻塞。
Fiber,纤程,用来处理I/O操作(包括文件I/O和socket I/O),
IoService提供的Fiber调度就是执行纤程执行权的切换。
纤程拥有三个状态:运行状态、等待状态、阻塞状态。
运行状态:该纤程目前正持有执行权。
等待状态:该纤程执行的消息已经被post到IoService的消息队列中,即将调度执行。
阻塞状态:该纤程执行了yield,将执行权移交,等待唤醒。
使用Fiber的目的是为了通过纤程执行权的切换确保CPU的效率。
此外,IoService还维护了I/O完成消息队列,存放I/O完成消息,并协助纤程的调度。
@see cerl::TaskPool, cerl::Fibers, cerl::IoCompletionPort
@*/
class IoService
{
BlockPool recycle;
Pools pools;
Fiber self; // 主Fiber句柄
/** IoService初始化。
@remark
分配并初始化与 Fiber 相关的对象。
@*/
IoService();
/** 构造一条消息。
@arg [in] fiber
消息中指定的要通过调度获得执行权的纤程。
@return
返回一个打包的消息。
@remark
messageOfSchedule在异步I/O操作的过程中,被IO操作的发起者调用,构造IO完成消息。
异步操作的流程中涉及到messageOfSchedule的部分:
使用messageOfSchedule构造一条消息==>执行异步操作==>异步操作完成时post这条消息。
因此,messageOfSchedule其实是WorkFiber提前构造好的,表示异步操作已经完成的消息,
但这条消息将在异步操作完成后才真正进行投递。之所以事先构造任务完成的消息的原因是:
避免跨线程的内存分配与释放,可以使用单线程的内存池;避免malloc的重入问题。
@*/
ScheduleMessage cerl_call messageOfSchedule(Fiber fiber);
/** 向消息队列post一个消息,该消息用于唤醒某个处于阻塞状态的纤程。
@arg [in] fiber
被唤醒的纤程。
@remark
scheduleFiber的应用场景:
如果某个纤程曾经使用yield函数使自己阻塞,当前拥有执行权的纤程或线程如果发现
被阻塞纤程的条件已经满足,那么可以使用scheduleFiber将阻塞的纤程唤醒。
@see cerl::yield, cerl::schedule
@*/
void scheduleFiber(Fiber fiber);
/** 向消息队列 post 一个任务,该任务由用户自定义的 run() 函数处理。
@arg [in] task
用户自定义的任务,该任务必须派生自 IoService::Task 类并继承实现 run() 函数。
@arg [in] uToken
默认值为0。
@remark
@*/
void cerl_mtcall postTask(Task* task, DWORD uToken = 0);
/** 向消息队列post一个退出IoService::run循环的消息。
@remark
quit消息一旦被执行,IoService::run循环将会立即结束,即使消息队列中还有其他的消息没有处理。
@*/
void quit();
/** 唤醒一个纤程去执行。
@arg [in] sn
纤程的序号。
@arg [in] fiberToWakeup
需求唤醒来执行的纤程。
@remark
resumeFiber 确保 fiberToWakeup 序号和 sn 一致,否则不唤醒纤程。
@*/
void cerl_call resumeFiber(FiberSerialNo sn, Fiber fiberToWakeup);
/** 根据输入的参数创建一个新的工作者纤程,将当前拥有执行权的纤程放入队列中等待下一次调度,
并把执行权切换到新创建的纤程。
@arg [in] self
当前拥有执行权的纤程。
@arg [in] lpStartAddress
新创建纤程的回调函数的地址。
@arg [in] startParam
新创建纤程携带的参数。
@arg [in] dwStackSize
为新创建纤程设置栈,如果设置为0,采用默认大小。
@return
返回一个指向新创建纤程的指针。
@remark
startFiber的应用场景:
如果纤程要对某个特定事件的发生进行处理,可以调度startFiber构造一个纤程来处理事件,
典型情况就是网络服务器在Accept一个连接请求后,调用startFiber来处理这个网络连接。
@see cerl::startFiber
@*/
Fiber cerl_call startFiber(Fiber self, FiberCallback lpStartAddress, void* startParam = NULL, size_t dwStackSize = 0);
/** 向消息队列post一个销毁当前的纤程的消息,之后把执行权切换到指定的纤程。
@arg [in] self
当前拥有执行权的纤程。
@arg [in] fiberSwitchTo
要通过调度获得执行权的纤程。
@remark
exitFiberAndSwitch的应用场景:
典型的情况就是一个纤程等待另外一个纤程执行完毕之后才能够继续执行,
当被等待的纤程执行完毕后,调用此函数将会转移执行权到等待的纤程。
@*/
void cerl_call exitFiberAndSwitch(Fiber self, Fiber fiberSwitchTo);
/** 向消息队列post一个销毁当前的纤程的消息,并把执行权切换到schedule fiber。
@arg [in] self
当前拥有执行权的fiber。
@remark
调用 exitFiberAndSwitch 函数,切换到当前 IoService 所持有的纤程。
@*/
void cerl_call exitFiber(Fiber self);
/** 当前纤程放弃执行权进入阻塞状态。
@arg [in] self
当前拥有执行权的纤程。
@remark
yield应用场景:
当纤程必须等待某条件的满足才能继续执行时,需要执行yield交出执行权,进入阻塞状态。
典型的情况就是当前纤程在发送异步IO操作请求后,调用yield等待IO操作的完成。
@see cerl::yield, cerl::schedule
@*/
void cerl_call yield(Fiber self);
/** run函数主要负责IoService的调度。她在获得执行权后将从IoService消息队列中取出消息,
如果没有消息则等待;如果有消息要处理,则根据消息的不同类型来处理消息,
在处理完消息后继续从消息队列取消息并调度执行;直到\<quit>函数被调用时run函数才退出。
@remark
运行run函数将启动IoService的管理和调度功能,即IoService开始工作。
需要注意的是,run函数不能单独使用,在run调用之前需要事先构造好纤程并向消息队列post消息,
否则run函数将会一直从空队列中取消息。用户通常可以使用带有参数的run来启动IoService。
@see run(lpStartAddress,startParam,dwStackSize)
@*/
void run();
/** 和\<run>函数功能基本相同,不同的是:该函数会根据输入的参数来创建纤程,
并将该纤程的调度消息post到消息队列中,这样,IoService在运行后就能立即调度执行该纤程。
@brief
@arg [in] lpStartAddress
纤程的回调函数地址。
@arg [in] startParam
纤程携带的参数。
@arg [in] dwStackSize
设置纤程的栈大小,如果设置为0,采用默认大小。
@see run()
@*/
void run(FiberCallback lpStartAddress, void* startParam = NULL, size_t dwStackSize = 0);
/** Session 接口,startSession 时需要传入 Session 模板对象。
@*/
// struct Session{
// void cerl_call run(Fiber self) const;
// };
/** 启动一个 Session,在 Session 中只有一个 IoService 模式中调用 Session 对象的 run() 函数。
@remark
单 IoService 的情况下 startSession 的作用就是 startFiber。
@arg self
当前纤程对象。
@arg session
SessionT 模板类型对象。
@arg dwStackSize
创建 Fiber 时的栈大小,缺省为0。
@*/
template <class SessionT>
void cerl_call startSession(Fiber self, const SessionT& session, size_t dwStackSize = 0);
/** IoServicePool 初始化的时候会调用本函数,在Session中只有一个 IoService 模式中什么都不用做。
@*/
void cerl_call start(size_t nThread = 1);
};
/** 根据输入的参数创建一个新的工作者纤程,将当前拥有执行权的纤程放入队列中等待下一次调度,
并把执行权切换到新创建的纤程。
@arg [in] self
当前拥有执行权的纤程。
@arg [in] lpStartAddress
新创建纤程的回调函数的地址。
@arg [in] startParam
新创建纤程携带的参数。
@arg [in] dwStackSize
为新创建纤程设置栈,如果设置为0,采用默认大小。
@return
返回一个指向新创建纤程的指针。
@remark
startFiber的应用场景:
如果纤程要对某个特定事件的发生进行处理,可以调度startFiber构造一个纤程来处理事件,
典型情况就是网络服务器在Accept一个连接请求后,调用startFiber来处理这个网络连接。
@*/
Fiber cerl_call startFiber(Fiber self, FiberCallback lpStartAddress, void* startParam = NULL, size_t dwStackSize = 0);
/** 向消息队列post一个销毁纤程的消息,并把执行权切换到schedule fiber。
@arg [in] self
一个\<Fiber>句柄。
@*/
void cerl_call exitFiber(Fiber self);
/** 当前纤程放弃执行权进入阻塞状态。
@arg [in] self
当前拥有执行权的纤程。
@remark
yield应用场景:
当纤程必须等待某条件的满足才能继续执行时,需要执行yield交出执行权,进入阻塞状态。
典型的情况就是当前纤程在发送异步IO操作请求后,调用yield等待IO操作的完成。
@see cerl::schedule
@*/
void cerl_call yield(Fiber self);
/** 当前纤程临时放弃执行权(但并没有进入阻塞状态),等待下一次调度。
@arg [in] self
当前拥有执行权的纤程。
@remark
schedule一般发生在一个纤程执行一个花费时间较长的运算时调用(占用过长的处理时间),
以主动出让执行权,等待下一次调度。schedule和yield都放弃执行权,但是两者不同之处在于
schedule并不等待某种条件的满足,只要有机会它仍然参与调度。但是yield的纤程在等待的条
件没有达成时,是不会参与纤程调度的。
@see cerl::yield
@*/
void cerl_call schedule(Fiber self);
// -------------------------------------------------------------------------
// class FiberParam
/** FiberParam描述了纤程及其携带的参数,FiberParam在纤程回调函数中使用,其主要工作包括:
1.提供纤程携带的参数;2.提供当前纤程;3.在FiberParam析构的时候提供纤程的退出清理工作,
将执行权由当前纤程切换至Schedule Fiber,并将纤程销毁。
@*/
class FiberParam
{
//@members
Fiber const self;
void* const val;
IoService* const service;
//@end
/** FiberParam初始化:设定纤程以及纤程携带的参数。
@arg [in] lpParam
纤程回调函数携带的参数。
@*/
FiberParam(LPVOID lpParam);
};
| 22.4613 | 119 | 0.735493 |
2ec33bc199993193ca1990255edb38309516d55c | 809 | h | C | TinLin-Demo/Demo/Utils/Extension/MBProgressHUD+TLExtension.h | TinLin-24/TinLin-Demo | 4bf69b815867ba04a6d30fa6d7f1c0458a742668 | [
"MIT"
] | null | null | null | TinLin-Demo/Demo/Utils/Extension/MBProgressHUD+TLExtension.h | TinLin-24/TinLin-Demo | 4bf69b815867ba04a6d30fa6d7f1c0458a742668 | [
"MIT"
] | null | null | null | TinLin-Demo/Demo/Utils/Extension/MBProgressHUD+TLExtension.h | TinLin-24/TinLin-Demo | 4bf69b815867ba04a6d30fa6d7f1c0458a742668 | [
"MIT"
] | null | null | null | //
//
// MBProgressHUD+TLExtension.m
//
// Created by apple on 16/5/10.
// Copyright © 2016年 TinLin. All rights reserved.
//
#import <MBProgressHUD/MBProgressHUD.h>
@interface MBProgressHUD (TLExtension)
/// in window
/// 提示信息
+ (MBProgressHUD *)tl_showTips:(NSString *)tipStr;
/// 提示错误
+ (MBProgressHUD *)tl_showErrorTips:(NSError *)error;
/// 进度view
+ (MBProgressHUD *)tl_showProgressHUD:(NSString *)titleStr;
/// 隐藏hud
+ (void)tl_hideHUD;
/// in special view
/// 提示信息
+ (MBProgressHUD *)tl_showTips:(NSString *)tipStr addedToView:(UIView *)view;
/// 提示错误
+ (MBProgressHUD *)tl_showErrorTips:(NSError *)error addedToView:(UIView *)view;
/// 进度view
+ (MBProgressHUD *)tl_showProgressHUD:(NSString *)titleStr addedToView:(UIView *)view;
/// 隐藏hud
+ (void)tl_hideHUDForView:(UIView *)view;
@end
| 19.731707 | 86 | 0.70581 |
ebe4cef17941a4cfb335c78881fdff9d15237572 | 6,539 | h | C | urdf_model/include/urdf_model/joint.h | jeoseo/urdfdom_headers | f07af514965ead707b48670ecce2f563ea58124f | [
"BSD-3-Clause"
] | null | null | null | urdf_model/include/urdf_model/joint.h | jeoseo/urdfdom_headers | f07af514965ead707b48670ecce2f563ea58124f | [
"BSD-3-Clause"
] | null | null | null | urdf_model/include/urdf_model/joint.h | jeoseo/urdfdom_headers | f07af514965ead707b48670ecce2f563ea58124f | [
"BSD-3-Clause"
] | null | null | null | /*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2008, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the Willow Garage nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/
/* Author: Wim Meeussen */
#ifndef URDF_INTERFACE_JOINT_H
#define URDF_INTERFACE_JOINT_H
#include <string>
#include <vector>
#include "urdf_model/pose.h"
#include "urdf_model/types.h"
namespace urdf{
class Link;
class JointDynamics
{
public:
JointDynamics() { this->clear(); };
double damping;
double friction;
void clear()
{
damping = 0;
friction = 0;
};
};
class JointLimits
{
public:
JointLimits() { this->clear(); };
double lower;
double upper;
double effort;
double velocity;
void clear()
{
lower = 0;
upper = 0;
effort = 0;
velocity = 0;
};
};
/// \brief Parameters for Joint Safety Controllers
class JointSafety
{
public:
/// clear variables on construction
JointSafety() { this->clear(); };
///
/// IMPORTANT: The safety controller support is very much PR2 specific, not intended for generic usage.
///
/// Basic safety controller operation is as follows
///
/// current safety controllers will take effect on joints outside the position range below:
///
/// position range: [JointSafety::soft_lower_limit + JointLimits::velocity / JointSafety::k_position,
/// JointSafety::soft_uppper_limit - JointLimits::velocity / JointSafety::k_position]
///
/// if (joint_position is outside of the position range above)
/// velocity_limit_min = -JointLimits::velocity + JointSafety::k_position * (joint_position - JointSafety::soft_lower_limit)
/// velocity_limit_max = JointLimits::velocity + JointSafety::k_position * (joint_position - JointSafety::soft_upper_limit)
/// else
/// velocity_limit_min = -JointLimits::velocity
/// velocity_limit_max = JointLimits::velocity
///
/// velocity range: [velocity_limit_min + JointLimits::effort / JointSafety::k_velocity,
/// velocity_limit_max - JointLimits::effort / JointSafety::k_velocity]
///
/// if (joint_velocity is outside of the velocity range above)
/// effort_limit_min = -JointLimits::effort + JointSafety::k_velocity * (joint_velocity - velocity_limit_min)
/// effort_limit_max = JointLimits::effort + JointSafety::k_velocity * (joint_velocity - velocity_limit_max)
/// else
/// effort_limit_min = -JointLimits::effort
/// effort_limit_max = JointLimits::effort
///
/// Final effort command sent to the joint is saturated by [effort_limit_min,effort_limit_max]
///
/// Please see wiki for more details: http://www.ros.org/wiki/pr2_controller_manager/safety_limits
///
double soft_upper_limit;
double soft_lower_limit;
double k_position;
double k_velocity;
void clear()
{
soft_upper_limit = 0;
soft_lower_limit = 0;
k_position = 0;
k_velocity = 0;
};
};
class JointCalibration
{
public:
JointCalibration() { this->clear(); };
double reference_position;
DoubleSharedPtr rising, falling;
void clear()
{
reference_position = 0;
};
};
class JointMimic
{
public:
JointMimic() { this->clear(); };
double offset;
double multiplier;
std::string joint_name;
void clear()
{
offset = 0.0;
multiplier = 0.0;
joint_name.clear();
};
};
class Joint
{
public:
Joint() { this->clear(); };
std::string name;
enum
{
UNKNOWN, REVOLUTE, CONTINUOUS, PRISMATIC, FLOATING, PLANAR, FIXED, CONTINUUM
} type;
/// \brief type_ meaning of axis_
/// ------------------------------------------------------
/// UNKNOWN unknown type
/// REVOLUTE rotation axis
/// PRISMATIC translation axis
/// FLOATING N/A
/// PLANAR plane normal axis
/// FIXED N/A
/// CONTINUUM N/A, defined in arma_urdf
Vector3 axis;
/// child Link element
/// child link frame is the same as the Joint frame
std::string child_link_name;
/// parent Link element
/// origin specifies the transform from Parent Link to Joint Frame
std::string parent_link_name;
/// transform from Parent Link frame to Joint frame
Pose parent_to_joint_origin_transform;
/// Joint Dynamics
JointDynamicsSharedPtr dynamics;
/// Joint Limits
JointLimitsSharedPtr limits;
/// Unsupported Hidden Feature
JointSafetySharedPtr safety;
/// Unsupported Hidden Feature
JointCalibrationSharedPtr calibration;
/// Option to Mimic another Joint
JointMimicSharedPtr mimic;
void clear()
{
this->axis.clear();
this->child_link_name.clear();
this->parent_link_name.clear();
this->parent_to_joint_origin_transform.clear();
this->dynamics.reset();
this->limits.reset();
this->safety.reset();
this->calibration.reset();
this->mimic.reset();
this->type = UNKNOWN;
};
};
}
#endif
| 28.185345 | 130 | 0.667839 |
d6e9e2774e2dbb192db72a5238d22ddc004776aa | 5,029 | h | C | arduino_codes/clear_ros_node/libraries/ros_lib/ublox_msgs/NavSVINFO_SV.h | AUROVA-LAB/aurova_clear | 29b637044b2970d42b1ae83088aebf8895e751e0 | [
"MIT"
] | 3 | 2021-01-15T03:12:11.000Z | 2021-08-31T00:58:37.000Z | arduino_codes/clear_ros_node/libraries/ros_lib/ublox_msgs/NavSVINFO_SV.h | AUROVA-LAB/CLEAR | 29b637044b2970d42b1ae83088aebf8895e751e0 | [
"MIT"
] | null | null | null | arduino_codes/clear_ros_node/libraries/ros_lib/ublox_msgs/NavSVINFO_SV.h | AUROVA-LAB/CLEAR | 29b637044b2970d42b1ae83088aebf8895e751e0 | [
"MIT"
] | 2 | 2019-02-22T10:14:50.000Z | 2021-08-31T00:58:36.000Z | #ifndef _ROS_ublox_msgs_NavSVINFO_SV_h
#define _ROS_ublox_msgs_NavSVINFO_SV_h
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include "ros/msg.h"
namespace ublox_msgs
{
class NavSVINFO_SV : public ros::Msg
{
public:
typedef uint8_t _chn_type;
_chn_type chn;
typedef uint8_t _svid_type;
_svid_type svid;
typedef uint8_t _flags_type;
_flags_type flags;
typedef uint8_t _quality_type;
_quality_type quality;
typedef uint8_t _cno_type;
_cno_type cno;
typedef int8_t _elev_type;
_elev_type elev;
typedef int16_t _azim_type;
_azim_type azim;
typedef int32_t _prRes_type;
_prRes_type prRes;
enum { FLAGS_SV_USED = 1 };
enum { FLAGS_DIFF_CORR = 2 };
enum { FLAGS_ORBIT_AVAIL = 4 };
enum { FLAGS_ORBIT_EPH = 8 };
enum { FLAGS_UNHEALTHY = 16 };
enum { FLAGS_ORBIT_ALM = 32 };
enum { FLAGS_ORBIT_AOP = 64 };
enum { FLAGS_SMOOTHED = 128 };
enum { QUALITY_IDLE = 0 };
enum { QUALITY_SEARCHING = 1 };
enum { QUALITY_ACQUIRED = 2 };
enum { QUALITY_DETECTED = 3 };
enum { QUALITY_CODE_LOCK = 4 };
enum { QUALITY_CODE_AND_CARRIER_LOCKED1 = 5 };
enum { QUALITY_CODE_AND_CARRIER_LOCKED2 = 6 };
enum { QUALITY_CODE_AND_CARRIER_LOCKED3 = 7 };
NavSVINFO_SV():
chn(0),
svid(0),
flags(0),
quality(0),
cno(0),
elev(0),
azim(0),
prRes(0)
{
}
virtual int serialize(unsigned char *outbuffer) const
{
int offset = 0;
*(outbuffer + offset + 0) = (this->chn >> (8 * 0)) & 0xFF;
offset += sizeof(this->chn);
*(outbuffer + offset + 0) = (this->svid >> (8 * 0)) & 0xFF;
offset += sizeof(this->svid);
*(outbuffer + offset + 0) = (this->flags >> (8 * 0)) & 0xFF;
offset += sizeof(this->flags);
*(outbuffer + offset + 0) = (this->quality >> (8 * 0)) & 0xFF;
offset += sizeof(this->quality);
*(outbuffer + offset + 0) = (this->cno >> (8 * 0)) & 0xFF;
offset += sizeof(this->cno);
union {
int8_t real;
uint8_t base;
} u_elev;
u_elev.real = this->elev;
*(outbuffer + offset + 0) = (u_elev.base >> (8 * 0)) & 0xFF;
offset += sizeof(this->elev);
union {
int16_t real;
uint16_t base;
} u_azim;
u_azim.real = this->azim;
*(outbuffer + offset + 0) = (u_azim.base >> (8 * 0)) & 0xFF;
*(outbuffer + offset + 1) = (u_azim.base >> (8 * 1)) & 0xFF;
offset += sizeof(this->azim);
union {
int32_t real;
uint32_t base;
} u_prRes;
u_prRes.real = this->prRes;
*(outbuffer + offset + 0) = (u_prRes.base >> (8 * 0)) & 0xFF;
*(outbuffer + offset + 1) = (u_prRes.base >> (8 * 1)) & 0xFF;
*(outbuffer + offset + 2) = (u_prRes.base >> (8 * 2)) & 0xFF;
*(outbuffer + offset + 3) = (u_prRes.base >> (8 * 3)) & 0xFF;
offset += sizeof(this->prRes);
return offset;
}
virtual int deserialize(unsigned char *inbuffer)
{
int offset = 0;
this->chn = ((uint8_t) (*(inbuffer + offset)));
offset += sizeof(this->chn);
this->svid = ((uint8_t) (*(inbuffer + offset)));
offset += sizeof(this->svid);
this->flags = ((uint8_t) (*(inbuffer + offset)));
offset += sizeof(this->flags);
this->quality = ((uint8_t) (*(inbuffer + offset)));
offset += sizeof(this->quality);
this->cno = ((uint8_t) (*(inbuffer + offset)));
offset += sizeof(this->cno);
union {
int8_t real;
uint8_t base;
} u_elev;
u_elev.base = 0;
u_elev.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
this->elev = u_elev.real;
offset += sizeof(this->elev);
union {
int16_t real;
uint16_t base;
} u_azim;
u_azim.base = 0;
u_azim.base |= ((uint16_t) (*(inbuffer + offset + 0))) << (8 * 0);
u_azim.base |= ((uint16_t) (*(inbuffer + offset + 1))) << (8 * 1);
this->azim = u_azim.real;
offset += sizeof(this->azim);
union {
int32_t real;
uint32_t base;
} u_prRes;
u_prRes.base = 0;
u_prRes.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
u_prRes.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
u_prRes.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
u_prRes.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
this->prRes = u_prRes.real;
offset += sizeof(this->prRes);
return offset;
}
const char * getType(){ return "ublox_msgs/NavSVINFO_SV"; };
const char * getMD5(){ return "fd3d8150f431e87f504da9aafff163a1"; };
};
}
#endif | 33.304636 | 73 | 0.518592 |
0328fc24018c06ac1956fa9f7212058792ca889c | 36,823 | h | C | rt1064_fw/src/hw/driver/sdmmc/inc/fsl_sdmmc_host.h | chcbaram/rt1064 | 0ae18f4aade0773e8ac8f53ad1b6005f6400fdff | [
"Apache-2.0"
] | 1 | 2021-05-03T21:17:01.000Z | 2021-05-03T21:17:01.000Z | rt1064_fw/src/hw/driver/sdmmc/inc/fsl_sdmmc_host.h | chcbaram/rt1064 | 0ae18f4aade0773e8ac8f53ad1b6005f6400fdff | [
"Apache-2.0"
] | null | null | null | rt1064_fw/src/hw/driver/sdmmc/inc/fsl_sdmmc_host.h | chcbaram/rt1064 | 0ae18f4aade0773e8ac8f53ad1b6005f6400fdff | [
"Apache-2.0"
] | 1 | 2021-05-04T07:05:59.000Z | 2021-05-04T07:05:59.000Z | /*
* Copyright (c) 2015, Freescale Semiconductor, Inc.
* Copyright 2016-2018 NXP
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _FSL_SDMMC_HOST_H
#define _FSL_SDMMC_HOST_H
#include "fsl_common.h"
#include "bsp.h"
#if defined(FSL_FEATURE_SOC_SDHC_COUNT) && FSL_FEATURE_SOC_SDHC_COUNT > 0U
#include "fsl_sdhc.h"
#elif defined(FSL_FEATURE_SOC_SDIF_COUNT) && FSL_FEATURE_SOC_SDIF_COUNT > 0U
#include "fsl_sdif.h"
#elif defined(FSL_FEATURE_SOC_USDHC_COUNT) && FSL_FEATURE_SOC_USDHC_COUNT > 0U
#include "fsl_usdhc.h"
#endif
/*!
* @addtogroup SDMMCHOST
* @{
*/
/*******************************************************************************
* Definitions
******************************************************************************/
/*! @brief Middleware adapter version. */
#define FSL_SDMMC_HOST_ADAPTER_VERSION (MAKE_VERSION(2U, 2U, 14U)) /*2.2.14*/
/* Common definition for support and not support macro */
#define SDMMCHOST_NOT_SUPPORT 0U /*!< use this define to indicate the host not support feature*/
#define SDMMCHOST_SUPPORT 1U /*!< use this define to indicate the host support feature*/
/* Common definition for board support SDR104/HS200/HS400 frequency */
/* SDR104 mode freq */
#if defined BOARD_SD_HOST_SUPPORT_SDR104_FREQ
#define SDMMCHOST_SUPPORT_SDR104_FREQ BOARD_SD_HOST_SUPPORT_SDR104_FREQ
#else
#define SDMMCHOST_SUPPORT_SDR104_FREQ SD_CLOCK_208MHZ
#endif
/* HS200 mode freq */
#if defined BOARD_SD_HOST_SUPPORT_HS200_FREQ
#define SDMMCHOST_SUPPORT_HS200_FREQ BOARD_SD_HOST_SUPPORT_HS200_FREQ
#else
#define SDMMCHOST_SUPPORT_HS200_FREQ MMC_CLOCK_HS200
#endif
/* HS400 mode freq */
#if defined BOARD_SD_HOST_SUPPORT_HS400_FREQ
#define SDMMCHOST_SUPPORT_HS400_FREQ BOARD_SD_HOST_SUPPORT_HS400_FREQ
#else
#define SDMMCHOST_SUPPORT_HS400_FREQ MMC_CLOCK_HS400
#endif
/* Common definition for SDMMCHOST transfer complete timeout */
#define SDMMCHOST_TRANSFER_COMPLETE_TIMEOUT (500U)
/* Common definition for card detect timeout */
#define SDMMCHOST_CARD_DETECT_TIMEOUT (~0U)
/* Common definition for IRQ */
#if defined(__CORTEX_M)
#define SDMMCHOST_SET_IRQ_PRIORITY(id, priority) (NVIC_SetPriority(id, priority))
#else
#define SDMMCHOST_SET_IRQ_PRIORITY(id, priority) (GIC_SetPriority(id, priority))
#endif
#define SDMMCHOST_ENABLE_IRQ(id) (EnableIRQ(id))
/*********************************************************SDHC**********************************************************/
#if (defined(FSL_FEATURE_SOC_SDHC_COUNT) && (FSL_FEATURE_SOC_SDHC_COUNT > 0U))
/*define host baseaddr ,clk freq, IRQ number*/
#define MMC_HOST_BASEADDR BOARD_SDHC_BASEADDR
#define MMC_HOST_CLK_FREQ BOARD_SDHC_CLK_FREQ
#define MMC_HOST_IRQ BOARD_SDHC_IRQ
#define SD_HOST_BASEADDR BOARD_SDHC_BASEADDR
#define SD_HOST_CLK_FREQ BOARD_SDHC_CLK_FREQ
#define SD_HOST_IRQ BOARD_SDHC_IRQ
/* define for card bus speed/strength cnofig */
#define CARD_BUS_FREQ_50MHZ (0U)
#define CARD_BUS_FREQ_100MHZ0 (0U)
#define CARD_BUS_FREQ_100MHZ1 (0U)
#define CARD_BUS_FREQ_200MHZ (0U)
#define CARD_BUS_STRENGTH_0 (0U)
#define CARD_BUS_STRENGTH_1 (0U)
#define CARD_BUS_STRENGTH_2 (0U)
#define CARD_BUS_STRENGTH_3 (0U)
#define CARD_BUS_STRENGTH_4 (0U)
#define CARD_BUS_STRENGTH_5 (0U)
#define CARD_BUS_STRENGTH_6 (0U)
#define CARD_BUS_STRENGTH_7 (0U)
#define SDMMCHOST_TYPE SDHC_Type
#define SDMMCHOST_CONFIG sdhc_host_t
#define SDMMCHOST_TRANSFER sdhc_transfer_t
#define SDMMCHOST_COMMAND sdhc_command_t
#define SDMMCHOST_DATA sdhc_data_t
#define SDMMCHOST_BUS_WIDTH_TYPE sdhc_data_bus_width_t
#define SDMMCHOST_CAPABILITY sdhc_capability_t
#define SDMMCHOST_BOOT_CONFIG sdhc_boot_config_t
#define CARD_DATA0_STATUS_MASK (kSDHC_Data0LineLevelFlag)
#define CARD_DATA0_NOT_BUSY (kSDHC_Data0LineLevelFlag)
#define CARD_DATA1_STATUS_MASK (kSDHC_Data1LineLevelFlag)
#define CARD_DATA2_STATUS_MASK (kSDHC_Data2LineLevelFlag)
#define CARD_DATA3_STATUS_MASK (kSDHC_Data3LineLevelFlag)
#define kSDMMCHOST_DATABUSWIDTH1BIT kSDHC_DataBusWidth1Bit /*!< 1-bit mode */
#define kSDMMCHOST_DATABUSWIDTH4BIT kSDHC_DataBusWidth4Bit /*!< 4-bit mode */
#define kSDMMCHOST_DATABUSWIDTH8BIT kSDHC_DataBusWidth8Bit /*!< 8-bit mode */
#define SDMMCHOST_STANDARD_TUNING_START (0U) /*!< standard tuning start point */
#define SDMMCHOST_TUINIG_STEP (1U) /*!< standard tuning step */
#define SDMMCHOST_RETUNING_TIMER_COUNT (4U) /*!< Re-tuning timer */
#define SDMMCHOST_TUNING_DELAY_MAX (0x7FU)
#define SDMMCHOST_RETUNING_REQUEST (1U)
#define SDMMCHOST_TUNING_ERROR (2U)
/* function pointer define */
#define SDMMCHOST_TRANSFER_FUNCTION sdhc_transfer_function_t
#define GET_SDMMCHOST_CAPABILITY(base, capability) (SDHC_GetCapability(base, capability))
#define GET_SDMMCHOST_STATUS(base) (SDHC_GetPresentStatusFlags(base))
#define SDMMCHOST_SET_CARD_CLOCK(base, sourceClock_HZ, busClock_HZ) (SDHC_SetSdClock(base, sourceClock_HZ, busClock_HZ))
#define SDMMCHOST_SET_CARD_BUS_WIDTH(base, busWidth) (SDHC_SetDataBusWidth(base, busWidth))
#define SDMMCHOST_SEND_CARD_ACTIVE(base, timeout) (SDHC_SetCardActive(base, timeout))
#define SDMMCHOST_SWITCH_VOLTAGE180V(base, enable18v)
#define SDMMCHOST_SWITCH_VOLTAGE120V(base, enable12v)
#define SDMMCHOST_CONFIG_IO_STRENGTH(speed, strength)
#define SDMMCHOST_EXECUTE_STANDARD_TUNING_ENABLE(base, flag)
#define SDMMCHOST_EXECUTE_STANDARD_TUNING_STATUS(base) (0U)
#define SDMMCHOST_EXECUTE_STANDARD_TUNING_RESULT(base) (1U)
#define SDMMCHOST_CONFIG_SD_IO(speed, strength)
#define SDMMCHOST_CONFIG_MMC_IO(speed, strength)
#define SDMMCHOST_ENABLE_DDR_MODE(base, flag, nibblePos)
#define SDMMCHOST_FORCE_SDCLOCK_ON(base, enable)
#define SDMMCHOST_EXECUTE_MANUAL_TUNING_ENABLE(base, flag)
#define SDMMCHOST_ADJUST_MANUAL_TUNING_DELAY(base, delay)
#define SDMMCHOST_AUTO_MANUAL_TUNING_ENABLE(base, flag)
#define SDMMCHOST_ENABLE_CARD_CLOCK(base, enable) (SDHC_EnableSdClock(base, enable))
#define SDMMCHOST_RESET_TUNING(base, timeout)
#define SDMMCHOST_CHECK_TUNING_ERROR(base) (0U)
#define SDMMCHOST_ADJUST_TUNING_DELAY(base, delay)
#define SDMMCHOST_MAX_TUNING_DELAY_CELL (0U)
#define SDMMCHOST_AUTO_STANDARD_RETUNING_TIMER(base)
#define SDMMCHOST_TRANSFER_DATA_ERROR kStatus_SDHC_TransferDataFailed
#define SDMMCHOST_TRANSFER_CMD_ERROR kStatus_SDHC_SendCommandFailed
#define SDMMCHOST_ENABLE_HS400_MODE(base, flag)
#define SDMMCHOST_RESET_STROBE_DLL(base)
#define SDMMCHOST_ENABLE_STROBE_DLL(base, flag)
#define SDMMCHOST_CONFIG_STROBE_DLL(base, delay, updateInterval)
#define SDMMCHOST_GET_STROBE_DLL_STATUS(base)
/* sd card power */
#define SDMMCHOST_INIT_SD_POWER()
#define SDMMCHOST_ENABLE_SD_POWER(enable)
#define SDMMCHOST_SWITCH_VCC_TO_180V()
#define SDMMCHOST_SWITCH_VCC_TO_330V()
/* mmc card power */
#define SDMMCHOST_INIT_MMC_POWER()
#define SDMMCHOST_ENABLE_MMC_POWER(enable)
#define SDMMCHOST_ENABLE_TUNING_FLAG(data)
#define SDMMCHOST_ENABLE_BOOT_FLAG(data)
#define SDMMCHOST_ENABLE_BOOT_CONTINOUS_FLAG(data)
#define SDMMCHOST_GET_HOST_CONFIG_BLOCK_SIZE(config) (0U)
#define SDMMCHOST_GET_HOST_CONFIG_BLOCK_COUNT(config) (0U)
#define SDMMCHOST_GET_HOST_CONFIG_BOOT_MODE(config) (0U)
#define SDMMCHOST_EMPTY_CMD_FLAG(command)
#define SDMMCHOST_CARD_DETECT_GPIO_INTERRUPT_HANDLER BOARD_SDHC_CD_PORT_IRQ_HANDLER
#define SDMMCHOST_CARD_DETECT_IRQ BOARD_SDHC_CD_PORT_IRQ
/* sd card detect through host CD */
#define SDMMCHOST_CARD_DETECT_INSERT_ENABLE(base) (SDHC_EnableInterruptStatus(base, kSDHC_CardInsertionFlag))
#define SDMMCHOST_CARD_DETECT_REMOVE_ENABLE(base) (SDHC_EnableInterruptStatus(base, kSDHC_CardRemovalFlag))
#define SDMMCHOST_CARD_DETECT_INSERT_STATUS(base) (SDHC_GetInterruptStatusFlags(base) & kSDHC_CardInsertionFlag)
#define SDMMCHOST_CARD_DETECT_REMOVE_STATUS(base) (SDHC_GetInterruptStatusFlags(base, kSDHC_CardRemovalFlag))
#define SDMMCHOST_CARD_DETECT_INSERT_INTERRUPT_ENABLE(base) (SDHC_EnableInterruptSignal(base, kSDHC_CardInsertionFlag))
#define SDMMCHOST_CARD_DETECT_INSERT_INTERRUPT_DISABLE(base) \
(SDHC_DisableInterruptSignal(base, kSDHC_CardInsertionFlag))
#define SDMMCHOST_CARD_DETECT_REMOVE_INTERRUPT_ENABLE(base) (SDHC_EnableInterruptSignal(base, kSDHC_CardRemovalFlag))
#define SDMMCHOST_CARD_DETECT_DATA3_ENABLE(base, flag) (SDHC_CardDetectByData3(base, flag))
#define SDMMCHOST_ENABLE_MMC_BOOT(base, flag)
#define SDMMCHOST_SETMMCBOOTCONFIG(base, config) (SDHC_SetMmcBootConfig(base, config))
/* define card detect pin voltage level when card inserted */
#if defined BOARD_SDHC_CARD_INSERT_CD_LEVEL
#define SDMMCHOST_CARD_INSERT_CD_LEVEL BOARD_SDHC_CARD_INSERT_CD_LEVEL
#else
#define SDMMCHOST_CARD_INSERT_CD_LEVEL (0U)
#endif
#define SDMMCHOST_AUTO_TUNING_ENABLE(base, flag)
#define SDMMCHOST_ENABLE_SDIO_INT(base) \
SDHC_EnableInterruptStatus(base, kSDHC_CardInterruptFlag); \
SDHC_EnableInterruptSignal(base, kSDHC_CardInterruptFlag)
#define SDMMCHOST_DISABLE_SDIO_INT(base) \
SDHC_DisableInterruptStatus(base, kSDHC_CardInterruptFlag); \
SDHC_DisableInterruptSignal(base, kSDHC_CardInterruptFlag)
/*! @brief SDHC host capability*/
enum _host_capability
{
kSDMMCHOST_SupportAdma = kSDHC_SupportAdmaFlag,
kSDMMCHOST_SupportHighSpeed = kSDHC_SupportHighSpeedFlag,
kSDMMCHOST_SupportDma = kSDHC_SupportDmaFlag,
kSDMMCHOST_SupportSuspendResume = kSDHC_SupportSuspendResumeFlag,
kSDMMCHOST_SupportV330 = kSDHC_SupportV330Flag,
kSDMMCHOST_SupportV300 = SDMMCHOST_NOT_SUPPORT,
kSDMMCHOST_SupportV180 = SDMMCHOST_NOT_SUPPORT,
kSDMMCHOST_SupportV120 = SDMMCHOST_NOT_SUPPORT,
kSDMMCHOST_Support4BitBusWidth = kSDHC_Support4BitFlag,
kSDMMCHOST_Support8BitBusWidth = kSDHC_Support8BitFlag,
kSDMMCHOST_SupportDDR50 = SDMMCHOST_NOT_SUPPORT,
kSDMMCHOST_SupportSDR104 = SDMMCHOST_NOT_SUPPORT,
kSDMMCHOST_SupportSDR50 = SDMMCHOST_NOT_SUPPORT,
kSDMMCHOST_SupportHS200 = SDMMCHOST_NOT_SUPPORT,
kSDMMCHOST_SupportHS400 = SDMMCHOST_NOT_SUPPORT,
};
/* Endian mode. */
#define SDHC_ENDIAN_MODE kSDHC_EndianModeLittle
/* DMA mode */
#define SDHC_DMA_MODE kSDHC_DmaModeAdma2
/* address align */
#define SDMMCHOST_DMA_BUFFER_ADDR_ALIGN (SDHC_ADMA2_ADDRESS_ALIGN)
/* Read/write watermark level. The bigger value indicates DMA has higher read/write performance. */
#define SDHC_READ_WATERMARK_LEVEL (0x80U)
#define SDHC_WRITE_WATERMARK_LEVEL (0x80U)
/* ADMA table length united as word.
*
* SD card driver can't support ADMA1 transfer mode currently.
* One ADMA2 table item occupy two words which can transfer maximum 0xFFFFU bytes one time.
* The more data to be transferred in one time, the bigger value of SDHC_ADMA_TABLE_WORDS need to be set.
*/
#define SDHC_ADMA_TABLE_WORDS (8U)
/*********************************************************SDIF**********************************************************/
#elif (defined(FSL_FEATURE_SOC_SDIF_COUNT) && (FSL_FEATURE_SOC_SDIF_COUNT > 0U))
/*define host baseaddr ,clk freq, IRQ number*/
#define MMC_HOST_BASEADDR BOARD_SDIF_BASEADDR
#define MMC_HOST_CLK_FREQ BOARD_SDIF_CLK_FREQ
#define MMC_HOST_IRQ BOARD_SDIF_IRQ
#define SD_HOST_BASEADDR BOARD_SDIF_BASEADDR
#define SD_HOST_CLK_FREQ BOARD_SDIF_CLK_FREQ
#define SD_HOST_IRQ BOARD_SDIF_IRQ
/* define for card bus speed/strength cnofig */
#define CARD_BUS_FREQ_50MHZ (0U)
#define CARD_BUS_FREQ_100MHZ0 (0U)
#define CARD_BUS_FREQ_100MHZ1 (0U)
#define CARD_BUS_FREQ_200MHZ (0U)
#define CARD_BUS_STRENGTH_0 (0U)
#define CARD_BUS_STRENGTH_1 (0U)
#define CARD_BUS_STRENGTH_2 (0U)
#define CARD_BUS_STRENGTH_3 (0U)
#define CARD_BUS_STRENGTH_4 (0U)
#define CARD_BUS_STRENGTH_5 (0U)
#define CARD_BUS_STRENGTH_6 (0U)
#define CARD_BUS_STRENGTH_7 (0U)
#define SDMMCHOST_TYPE SDIF_Type
#define SDMMCHOST_CONFIG sdif_host_t
#define SDMMCHOST_TRANSFER sdif_transfer_t
#define SDMMCHOST_COMMAND sdif_command_t
#define SDMMCHOST_DATA sdif_data_t
#define SDMMCHOST_BUS_WIDTH_TYPE sdif_bus_width_t
#define SDMMCHOST_CAPABILITY sdif_capability_t
#define SDMMCHOST_BOOT_CONFIG void
#define CARD_DATA0_STATUS_MASK SDIF_STATUS_DATA_BUSY_MASK
#define CARD_DATA0_NOT_BUSY 0U
#define CARD_DATA1_STATUS_MASK (0U)
#define CARD_DATA2_STATUS_MASK (0U)
#define CARD_DATA3_STATUS_MASK (0U)
#define kSDMMCHOST_DATABUSWIDTH1BIT kSDIF_Bus1BitWidth /*!< 1-bit mode */
#define kSDMMCHOST_DATABUSWIDTH4BIT kSDIF_Bus4BitWidth /*!< 4-bit mode */
#define kSDMMCHOST_DATABUSWIDTH8BIT kSDIF_Bus8BitWidth /*!< 8-bit mode */
#define SDMMCHOST_STANDARD_TUNING_START (0U) /*!< standard tuning start point */
#define SDMMCHOST_TUINIG_STEP (1U) /*!< standard tuning step */
#define SDMMCHOST_RETUNING_TIMER_COUNT (4U) /*!< Re-tuning timer */
#define SDMMCHOST_TUNING_DELAY_MAX (0x7FU)
#define SDMMCHOST_RETUNING_REQUEST (1U)
#define SDMMCHOST_TUNING_ERROR (2U)
/* function pointer define */
#define SDMMCHOST_TRANSFER_FUNCTION sdif_transfer_function_t
#define GET_SDMMCHOST_CAPABILITY(base, capability) (SDIF_GetCapability(base, capability))
#define GET_SDMMCHOST_STATUS(base) (SDIF_GetControllerStatus(base))
#define SDMMCHOST_SET_CARD_CLOCK(base, sourceClock_HZ, busClock_HZ) \
(SDIF_SetCardClock(base, sourceClock_HZ, busClock_HZ))
#define SDMMCHOST_SET_CARD_BUS_WIDTH(base, busWidth) (SDIF_SetCardBusWidth(base, busWidth))
#define SDMMCHOST_SEND_CARD_ACTIVE(base, timeout) (SDIF_SendCardActive(base, timeout))
#define SDMMCHOST_SWITCH_VOLTAGE180V(base, enable18v)
#define SDMMCHOST_SWITCH_VOLTAGE120V(base, enable12v)
#define SDMMCHOST_CONFIG_IO_STRENGTH(speed, strength)
#define SDMMCHOST_EXECUTE_STANDARD_TUNING_ENABLE(base, flag)
#define SDMMCHOST_EXECUTE_STANDARD_TUNING_STATUS(base) (0U)
#define SDMMCHOST_EXECUTE_STANDARD_TUNING_RESULT(base) (1U)
#define SDMMCHOST_CONFIG_SD_IO(speed, strength)
#define SDMMCHOST_CONFIG_MMC_IO(speed, strength)
#define SDMMCHOST_ENABLE_DDR_MODE(base, flag, nibblePos)
#define SDMMCHOST_FORCE_SDCLOCK_ON(base, enable)
#define SDMMCHOST_EXECUTE_MANUAL_TUNING_ENABLE(base, flag)
#define SDMMCHOST_ADJUST_MANUAL_TUNING_DELAY(base, delay)
#define SDMMCHOST_AUTO_MANUAL_TUNING_ENABLE(base, flag)
#define SDMMCHOST_ENABLE_CARD_CLOCK(base, enable) (SDIF_EnableCardClock(base, enable))
#define SDMMCHOST_RESET_TUNING(base, timeout)
#define SDMMCHOST_CHECK_TUNING_ERROR(base) (0U)
#define SDMMCHOST_ADJUST_TUNING_DELAY(base, delay)
#define SDMMCHOST_AUTO_STANDARD_RETUNING_TIMER(base)
#define SDMMCHOST_MAX_TUNING_DELAY_CELL (0U)
#define SDMMCHOST_ENABLE_HS400_MODE(base, flag)
#define SDMMCHOST_RESET_STROBE_DLL(base)
#define SDMMCHOST_ENABLE_STROBE_DLL(base, flag)
#define SDMMCHOST_CONFIG_STROBE_DLL(base, delay, updateInterval)
#define SDMMCHOST_GET_STROBE_DLL_STATUS(base)
/* sd card power */
#define SDMMCHOST_INIT_SD_POWER()
#define SDMMCHOST_ENABLE_SD_POWER(enable)
#define SDMMCHOST_SWITCH_VCC_TO_180V()
#define SDMMCHOST_SWITCH_VCC_TO_330V()
/* mmc card power */
#define SDMMCHOST_INIT_MMC_POWER()
#define SDMMCHOST_ENABLE_MMC_POWER(enable)
#define SDMMCHOST_ENABLE_TUNING_FLAG(data)
#define SDMMCHOST_ENABLE_MMC_BOOT(base, flag)
#define SDMMCHOST_SETMMCBOOTCONFIG(base, config)
#define SDMMCHOST_ENABLE_BOOT_FLAG(data)
#define SDMMCHOST_ENABLE_BOOT_CONTINOUS_FLAG(data)
#define SDMMCHOST_GET_HOST_CONFIG_BLOCK_SIZE(config) (0U)
#define SDMMCHOST_GET_HOST_CONFIG_BLOCK_COUNT(config) (0U)
#define SDMMCHOST_GET_HOST_CONFIG_BOOT_MODE(config) (0U)
#define SDMMCHOST_EMPTY_CMD_FLAG(command)
#define SDMMCHOST_CARD_DETECT_STATUS() BOARD_SDIF_CD_STATUS()
#define SDMMCHOST_CARD_DETECT_INIT() BOARD_SDIF_CD_GPIO_INIT()
#define SDMMCHOST_CARD_DETECT_INTERRUPT_STATUS() BOARD_SDIF_CD_INTERRUPT_STATUS()
#define SDMMCHOST_CARD_DETECT_INTERRUPT_CLEAR(flag) BOARD_SDIF_CD_CLEAR_INTERRUPT(flag)
#define SDMMCHOST_CARD_DETECT_GPIO_INTERRUPT_HANDLER BOARD_SDIF_CD_PORT_IRQ_HANDLER
#define SDMMCHOST_CARD_DETECT_IRQ BOARD_SDIF_CD_PORT_IRQ
#define SDMMCHOST_TRANSFER_DATA_ERROR kStatus_SDIF_DataTransferFail
#define SDMMCHOST_TRANSFER_CMD_ERROR kStatus_SDIF_SendCmdFail
/* define card detect pin voltage level when card inserted */
#if defined BOARD_SDIF_CARD_INSERT_CD_LEVEL
#define SDMMCHOST_CARD_INSERT_CD_LEVEL BOARD_SDIF_CARD_INSERT_CD_LEVEL
#else
#define SDMMCHOST_CARD_INSERT_CD_LEVEL (0U)
#endif
#define SDMMCHOST_AUTO_TUNING_ENABLE(base, flag)
/* sd card detect through host CD */
#define SDMMCHOST_CARD_DETECT_INSERT_ENABLE(base) (SDIF_EnableInterrupt(base, kSDIF_CardDetect))
#define SDMMCHOST_CARD_DETECT_INSERT_STATUS(base, data3) (SDIF_DetectCardInsert(base, data3))
#define SDMMCHOST_ENABLE_SDIO_INT(base)
#define SDMMCHOST_DISABLE_SDIO_INT(base)
/*! @brief SDIF host capability*/
enum _host_capability
{
kSDMMCHOST_SupportHighSpeed = kSDIF_SupportHighSpeedFlag,
kSDMMCHOST_SupportDma = kSDIF_SupportDmaFlag,
kSDMMCHOST_SupportSuspendResume = kSDIF_SupportSuspendResumeFlag,
kSDMMCHOST_SupportV330 = kSDIF_SupportV330Flag,
kSDMMCHOST_SupportV300 = SDMMCHOST_NOT_SUPPORT,
kSDMMCHOST_SupportV180 = SDMMCHOST_NOT_SUPPORT,
kSDMMCHOST_SupportV120 = SDMMCHOST_NOT_SUPPORT,
kSDMMCHOST_Support4BitBusWidth = kSDIF_Support4BitFlag,
kSDMMCHOST_Support8BitBusWidth =
SDMMCHOST_NOT_SUPPORT, /* mask the 8 bit here,user can change depend on your board */
kSDMMCHOST_SupportDDR50 = SDMMCHOST_NOT_SUPPORT,
kSDMMCHOST_SupportSDR104 = SDMMCHOST_NOT_SUPPORT,
kSDMMCHOST_SupportSDR50 = SDMMCHOST_NOT_SUPPORT,
kSDMMCHOST_SupportHS200 = SDMMCHOST_NOT_SUPPORT,
kSDMMCHOST_SupportHS400 = SDMMCHOST_NOT_SUPPORT,
};
/*! @brief DMA table length united as word
* One dma table item occupy four words which can transfer maximum 2*8188 bytes in dual DMA mode
* and 8188 bytes in chain mode
* The more data to be transferred in one time, the bigger value of SDHC_ADMA_TABLE_WORDS need to be set.
* user need check the DMA descriptor table lenght if bigger enough.
*/
#define SDIF_DMA_TABLE_WORDS (0x40U)
/* address align */
#define SDMMCHOST_DMA_BUFFER_ADDR_ALIGN (4U)
/*********************************************************USDHC**********************************************************/
#elif (defined(FSL_FEATURE_SOC_USDHC_COUNT) && (FSL_FEATURE_SOC_USDHC_COUNT > 0U))
/*define host baseaddr ,clk freq, IRQ number*/
#define MMC_HOST_BASEADDR BOARD_MMC_HOST_BASEADDR
#define MMC_HOST_CLK_FREQ BOARD_MMC_HOST_CLK_FREQ
#define MMC_HOST_IRQ BOARD_MMC_HOST_IRQ
#define SD_HOST_BASEADDR BOARD_SD_HOST_BASEADDR
#define SD_HOST_CLK_FREQ BOARD_SD_HOST_CLK_FREQ
#define SD_HOST_IRQ BOARD_SD_HOST_IRQ
#define SDMMCHOST_TYPE USDHC_Type
#define SDMMCHOST_CONFIG usdhc_host_t
#define SDMMCHOST_TRANSFER usdhc_transfer_t
#define SDMMCHOST_COMMAND usdhc_command_t
#define SDMMCHOST_DATA usdhc_data_t
#define SDMMCHOST_BOOT_CONFIG usdhc_boot_config_t
#define CARD_DATA0_STATUS_MASK (kUSDHC_Data0LineLevelFlag)
#define CARD_DATA1_STATUS_MASK (kUSDHC_Data1LineLevelFlag)
#define CARD_DATA2_STATUS_MASK (kUSDHC_Data2LineLevelFlag)
#define CARD_DATA3_STATUS_MASK (kUSDHC_Data3LineLevelFlag)
#define CARD_DATA0_NOT_BUSY (kUSDHC_Data0LineLevelFlag)
#define SDMMCHOST_BUS_WIDTH_TYPE usdhc_data_bus_width_t
#define SDMMCHOST_CAPABILITY usdhc_capability_t
#define kSDMMCHOST_DATABUSWIDTH1BIT kUSDHC_DataBusWidth1Bit /*!< 1-bit mode */
#define kSDMMCHOST_DATABUSWIDTH4BIT kUSDHC_DataBusWidth4Bit /*!< 4-bit mode */
#define kSDMMCHOST_DATABUSWIDTH8BIT kUSDHC_DataBusWidth8Bit /*!< 8-bit mode */
#if defined BOARD_SDMMC_NEED_MANUAL_TUNING
#define SDMMC_ENABLE_SOFTWARE_TUNING
#endif
#define SDMMCHOST_STANDARD_TUNING_START (10U) /*!< standard tuning start point */
#define SDMMCHOST_TUINIG_STEP (2U) /*!< standard tuning step */
#define SDMMCHOST_RETUNING_TIMER_COUNT (0U) /*!< Re-tuning timer */
#define SDMMCHOST_TUNING_DELAY_MAX (0x7FU)
#define SDMMCHOST_RETUNING_REQUEST kStatus_USDHC_ReTuningRequest
#define SDMMCHOST_TUNING_ERROR kStatus_USDHC_TuningError
#define SDMMCHOST_TRANSFER_DATA_ERROR kStatus_USDHC_TransferDataFailed
#define SDMMCHOST_TRANSFER_CMD_ERROR kStatus_USDHC_SendCommandFailed
/* define for card bus speed/strength cnofig */
#define CARD_BUS_FREQ_50MHZ (0U)
#define CARD_BUS_FREQ_100MHZ0 (1U)
#define CARD_BUS_FREQ_100MHZ1 (2U)
#define CARD_BUS_FREQ_200MHZ (3U)
#define CARD_BUS_STRENGTH_0 (0U)
#define CARD_BUS_STRENGTH_1 (1U)
#define CARD_BUS_STRENGTH_2 (2U)
#define CARD_BUS_STRENGTH_3 (3U)
#define CARD_BUS_STRENGTH_4 (4U)
#define CARD_BUS_STRENGTH_5 (5U)
#define CARD_BUS_STRENGTH_6 (6U)
#define CARD_BUS_STRENGTH_7 (7U)
#define SDMMCHOST_STROBE_DLL_DELAY_TARGET (7U)
#define SDMMCHOST_STROBE_DLL_DELAY_UPDATE_INTERVAL (4U)
/* function pointer define */
#define SDMMCHOST_TRANSFER_FUNCTION usdhc_transfer_function_t
#define GET_SDMMCHOST_CAPABILITY(base, capability) (USDHC_GetCapability(base, capability))
#define GET_SDMMCHOST_STATUS(base) (USDHC_GetPresentStatusFlags(base))
#define SDMMCHOST_SET_CARD_CLOCK(base, sourceClock_HZ, busClock_HZ) \
(USDHC_SetSdClock(base, sourceClock_HZ, busClock_HZ))
#define SDMMCHOST_ENABLE_CARD_CLOCK(base, enable)
#define SDMMCHOST_FORCE_SDCLOCK_ON(base, enable) (USDHC_ForceClockOn(base, enable))
#define SDMMCHOST_SET_CARD_BUS_WIDTH(base, busWidth) (USDHC_SetDataBusWidth(base, busWidth))
#define SDMMCHOST_SEND_CARD_ACTIVE(base, timeout) (USDHC_SetCardActive(base, timeout))
#define SDMMCHOST_SWITCH_VOLTAGE180V(base, enable18v) (UDSHC_SelectVoltage(base, enable18v))
#define SDMMCHOST_SWITCH_VOLTAGE120V(base, enable12v)
#if ((defined(FSL_FEATURE_USDHC_HAS_SDR50_MODE) && (FSL_FEATURE_USDHC_HAS_SDR50_MODE)) || \
(defined(FSL_FEATURE_USDHC_HAS_HS400_MODE) && (FSL_FEATURE_USDHC_HAS_HS400_MODE)) || \
(defined(FSL_FEATURE_USDHC_HAS_SDR104_MODE) && (FSL_FEATURE_USDHC_HAS_SDR104_MODE)))
#define SDMMCHOST_CONFIG_SD_IO(speed, strength) BOARD_SD_Pin_Config(speed, strength)
#define SDMMCHOST_CONFIG_MMC_IO(speed, strength) BOARD_MMC_Pin_Config(speed, strength)
#else
#define SDMMCHOST_CONFIG_SD_IO(speed, strength)
#define SDMMCHOST_CONFIG_MMC_IO(speed, strength)
#endif
#define SDMMCHOST_SWITCH_VCC_TO_180V()
#define SDMMCHOST_SWITCH_VCC_TO_330V()
#if defined(FSL_FEATURE_USDHC_HAS_SDR50_MODE) && (!FSL_FEATURE_USDHC_HAS_SDR50_MODE)
#define SDMMCHOST_EXECUTE_STANDARD_TUNING_STATUS(base) (0U)
#define SDMMCHOST_EXECUTE_STANDARD_TUNING_RESULT(base) (1U)
#define SDMMCHOST_AUTO_STANDARD_RETUNING_TIMER(base)
#define SDMMCHOST_EXECUTE_STANDARD_TUNING_ENABLE(base, flag)
#define SDMMCHOST_CHECK_TUNING_ERROR(base) (0U)
#define SDMMCHOST_ADJUST_TUNING_DELAY(base, delay)
#define SDMMCHOST_AUTO_TUNING_ENABLE(base, flag)
#else
#define SDMMCHOST_EXECUTE_STANDARD_TUNING_ENABLE(base, flag) \
(USDHC_EnableStandardTuning(base, SDMMCHOST_STANDARD_TUNING_START, SDMMCHOST_TUINIG_STEP, flag))
#define SDMMCHOST_EXECUTE_STANDARD_TUNING_STATUS(base) (USDHC_GetExecuteStdTuningStatus(base))
#define SDMMCHOST_EXECUTE_STANDARD_TUNING_RESULT(base) (USDHC_CheckStdTuningResult(base))
#define SDMMCHOST_AUTO_STANDARD_RETUNING_TIMER(base) (USDHC_SetRetuningTimer(base, SDMMCHOST_RETUNING_TIMER_COUNT))
#define SDMMCHOST_EXECUTE_MANUAL_TUNING_ENABLE(base, flag) (USDHC_EnableManualTuning(base, flag))
#define SDMMCHOST_ADJUST_TUNING_DELAY(base, delay) (USDHC_AdjustDelayForManualTuning(base, delay))
#define SDMMCHOST_AUTO_TUNING_ENABLE(base, flag) (USDHC_EnableAutoTuning(base, flag))
#define SDMMCHOST_CHECK_TUNING_ERROR(base) (USDHC_CheckTuningError(base))
#endif
#define SDMMCHOST_MAX_TUNING_DELAY_CELL (128U)
#define SDMMCHOST_AUTO_TUNING_CONFIG(base) (USDHC_EnableAutoTuningForCmdAndData(base))
#define SDMMCHOST_RESET_TUNING(base, timeout) \
{ \
(USDHC_Reset(base, kUSDHC_ResetTuning | kUSDHC_ResetData | kUSDHC_ResetCommand, timeout)); \
}
#define SDMMCHOST_ENABLE_DDR_MODE(base, flag, nibblePos) (USDHC_EnableDDRMode(base, flag, nibblePos))
#if FSL_FEATURE_USDHC_HAS_HS400_MODE
#define SDMMCHOST_ENABLE_HS400_MODE(base, flag) (USDHC_EnableHS400Mode(base, flag))
#define SDMMCHOST_RESET_STROBE_DLL(base) (USDHC_ResetStrobeDLL(base))
#define SDMMCHOST_ENABLE_STROBE_DLL(base, flag) (USDHC_EnableStrobeDLL(base, flag))
#define SDMMCHOST_CONFIG_STROBE_DLL(base, delay, updateInterval) (USDHC_ConfigStrobeDLL(base, delay, updateInterval))
#define SDMMCHOST_GET_STROBE_DLL_STATUS (base)(USDHC_GetStrobeDLLStatus(base))
#else
#define SDMMCHOST_ENABLE_HS400_MODE(base, flag)
#define SDMMCHOST_RESET_STROBE_DLL(base)
#define SDMMCHOST_ENABLE_STROBE_DLL(base, flag)
#define SDMMCHOST_CONFIG_STROBE_DLL(base, delay, updateInterval)
#define SDMMCHOST_GET_STROBE_DLL_STATUS(base)
#endif
#define SDMMCHOST_ENABLE_MMC_BOOT(base, flag) (USDHC_EnableMmcBoot(base, flag))
#define SDMMCHOST_SETMMCBOOTCONFIG(base, config) (USDHC_SetMmcBootConfig(base, config))
/* sd card power */
#define SDMMCHOST_INIT_SD_POWER() BOARD_USDHC_SDCARD_POWER_CONTROL_INIT()
#define SDMMCHOST_ENABLE_SD_POWER(enable) gpioPinWrite(SD_PIN_PWREN, enable)
/* mmc card power */
#define SDMMCHOST_INIT_MMC_POWER() BOARD_USDHC_MMCCARD_POWER_CONTROL_INIT()
#define SDMMCHOST_ENABLE_MMC_POWER(enable) BOARD_USDHC_MMCCARD_POWER_CONTROL(enable)
/* sd card detect through gpio */
#define SDMMCHOST_CARD_DETECT_GPIO_STATUS() BOARD_USDHC_CD_STATUS()
#define SDMMCHOST_CARD_DETECT_GPIO_INIT() BOARD_USDHC_CD_GPIO_INIT()
#define SDMMCHOST_CARD_DETECT_GPIO_INTERRUPT_STATUS() BOARD_USDHC_CD_INTERRUPT_STATUS()
#define SDMMCHOST_CARD_DETECT_GPIO_INTERRUPT_STATUS_CLEAR(flag) BOARD_USDHC_CD_CLEAR_INTERRUPT(flag)
#define SDMMCHOST_CARD_DETECT_GPIO_INTERRUPT_HANDLER BOARD_USDHC_CD_PORT_IRQ_HANDLER
#define SDMMCHOST_CARD_DETECT_GPIO_IRQ BOARD_USDHC_CD_PORT_IRQ
/* sd card detect through host CD */
#define SDMMCHOST_CARD_DETECT_INSERT_ENABLE(base) (USDHC_EnableInterruptStatus(base, kUSDHC_CardInsertionFlag))
#define SDMMCHOST_CARD_DETECT_REMOVE_ENABLE(base) (USDHC_EnableInterruptStatus(base, kUSDHC_CardRemovalFlag))
#define SDMMCHOST_CARD_DETECT_INSERT_STATUS(base) (USDHC_DetectCardInsert(base))
#define SDMMCHOST_CARD_DETECT_REMOVE_STATUS(base) (USDHC_GetInterruptStatusFlags(base, kUSDHC_CardRemovalFlag))
#define SDMMCHOST_CARD_DETECT_INSERT_INTERRUPT_ENABLE(base) \
(USDHC_EnableInterruptSignal(base, kUSDHC_CardInsertionFlag))
#define SDMMCHOST_CARD_DETECT_REMOVE_INTERRUPT_ENABLE(base) (USDHC_EnableInterruptSignal(base, kUSDHC_CardRemovalFlag))
#define SDMMCHOST_CARD_DETECT_DATA3_ENABLE(base, flag) (USDHC_CardDetectByData3(base, flag))
/* define card detect pin voltage level when card inserted */
#if defined BOARD_USDHC_CARD_INSERT_CD_LEVEL
#define SDMMCHOST_CARD_INSERT_CD_LEVEL BOARD_USDHC_CARD_INSERT_CD_LEVEL
#else
#define SDMMCHOST_CARD_INSERT_CD_LEVEL (0U)
#endif
#define SDMMCHOST_ENABLE_TUNING_FLAG(data) (data.dataType = kUSDHC_TransferDataTuning)
#define SDMMCHOST_ENABLE_BOOT_FLAG(data) (data.dataType = kUSDHC_TransferDataBoot)
#define SDMMCHOST_ENABLE_BOOT_CONTINOUS_FLAG(data) (data.dataType = kUSDHC_TransferDataBootcontinous)
#define SDMMCHOST_GET_HOST_CONFIG_BLOCK_SIZE(config) (config->blockSize)
#define SDMMCHOST_GET_HOST_CONFIG_BLOCK_COUNT(config) (config->blockCount)
#define SDMMCHOST_GET_HOST_CONFIG_BOOT_MODE(config) (config->bootMode)
#define SDMMCHOST_EMPTY_CMD_FLAG(command) (command.type = kCARD_CommandTypeEmpty)
#define SDMMCHOST_ENABLE_SDIO_INT(base) \
USDHC_EnableInterruptStatus(base, kUSDHC_CardInterruptFlag); \
USDHC_EnableInterruptSignal(base, kUSDHC_CardInterruptFlag)
#define SDMMCHOST_DISABLE_SDIO_INT(base) \
USDHC_DisableInterruptStatus(base, kUSDHC_CardInterruptFlag); \
USDHC_DisableInterruptSignal(base, kUSDHC_CardInterruptFlag)
/*! @brief USDHC host capability*/
enum _host_capability
{
kSDMMCHOST_SupportAdma = kUSDHC_SupportAdmaFlag,
kSDMMCHOST_SupportHighSpeed = kUSDHC_SupportHighSpeedFlag,
kSDMMCHOST_SupportDma = kUSDHC_SupportDmaFlag,
kSDMMCHOST_SupportSuspendResume = kUSDHC_SupportSuspendResumeFlag,
kSDMMCHOST_SupportV330 = kUSDHC_SupportV330Flag, /* this define should depend on your board config */
kSDMMCHOST_SupportV300 = kUSDHC_SupportV300Flag, /* this define should depend on your board config */
#if defined(BOARD_SD_SUPPORT_180V) && !BOARD_SD_SUPPORT_180V
kSDMMCHOST_SupportV180 = SDMMCHOST_NOT_SUPPORT, /* this define should depend on you board config */
#else
kSDMMCHOST_SupportV180 = kUSDHC_SupportV180Flag, /* this define should depend on you board config */
#endif
kSDMMCHOST_SupportV120 = SDMMCHOST_NOT_SUPPORT,
kSDMMCHOST_Support4BitBusWidth = kUSDHC_Support4BitFlag,
#if defined(BOARD_MMC_SUPPORT_8BIT_BUS)
#if BOARD_MMC_SUPPORT_8BIT_BUS
kSDMMCHOST_Support8BitBusWidth = kUSDHC_Support8BitFlag,
#else
kSDMMCHOST_Support8BitBusWidth = SDMMCHOST_NOT_SUPPORT,
#endif
#else
kSDMMCHOST_Support8BitBusWidth = kUSDHC_Support8BitFlag,
#endif
kSDMMCHOST_SupportDDR50 = kUSDHC_SupportDDR50Flag,
kSDMMCHOST_SupportSDR104 = kUSDHC_SupportSDR104Flag,
kSDMMCHOST_SupportSDR50 = kUSDHC_SupportSDR50Flag,
kSDMMCHOST_SupportHS200 = kUSDHC_SupportSDR104Flag,
#if FSL_FEATURE_USDHC_HAS_HS400_MODE
kSDMMCHOST_SupportHS400 = SDMMCHOST_SUPPORT
#else
kSDMMCHOST_SupportHS400 = SDMMCHOST_NOT_SUPPORT,
#endif
};
/* Endian mode. */
#define USDHC_ENDIAN_MODE kUSDHC_EndianModeLittle
/* DMA mode */
#define USDHC_DMA_MODE kUSDHC_DmaModeAdma2
/* address align */
#define SDMMCHOST_DMA_BUFFER_ADDR_ALIGN (USDHC_ADMA2_ADDRESS_ALIGN)
/* Read/write watermark level. The bigger value indicates DMA has higher read/write performance. */
#define USDHC_READ_WATERMARK_LEVEL (0x80U)
#define USDHC_WRITE_WATERMARK_LEVEL (0x80U)
/* ADMA table length united as word.
*
* One ADMA2 table item occupy two words which can transfer maximum 0xFFFFU bytes one time.
* The more data to be transferred in one time, the bigger value of SDHC_ADMA_TABLE_WORDS need to be set.
*/
#define USDHC_ADMA_TABLE_WORDS (8U) /* define the ADMA descriptor table length */
#define USDHC_ADMA2_ADDR_ALIGN (4U) /* define the ADMA2 descriptor table addr align size */
#define USDHC_READ_BURST_LEN (8U) /*!< number of words USDHC read in a single burst */
#define USDHC_WRITE_BURST_LEN (8U) /*!< number of words USDHC write in a single burst */
#define USDHC_DATA_TIMEOUT (0xFU) /*!< data timeout counter value */
#endif /* (defined(FSL_FEATURE_SOC_SDHC_COUNT) && (FSL_FEATURE_SOC_SDHC_COUNT > 0U)) */
/*! @brief card detect callback definition */
typedef void (*sdmmchost_cd_callback_t)(bool isInserted, void *userData);
/*! @brief host Endian mode
* corresponding to driver define
*/
enum _sdmmchost_endian_mode
{
kSDMMCHOST_EndianModeBig = 0U, /*!< Big endian mode */
kSDMMCHOST_EndianModeHalfWordBig = 1U, /*!< Half word big endian mode */
kSDMMCHOST_EndianModeLittle = 2U, /*!< Little endian mode */
};
/*! @brief sd card detect type */
typedef enum _sdmmchost_detect_card_type
{
kSDMMCHOST_DetectCardByGpioCD, /*!< sd card detect by CD pin through GPIO */
kSDMMCHOST_DetectCardByHostCD, /*!< sd card detect by CD pin through host */
kSDMMCHOST_DetectCardByHostDATA3, /*!< sd card detect by DAT3 pin through host */
} sdmmchost_detect_card_type_t;
/*! @brief sd card detect */
typedef struct _sdmmchost_detect_card
{
sdmmchost_detect_card_type_t cdType; /*!< card detect type */
uint32_t cdTimeOut_ms; /*!< card detect timeout which allow 0 - 0xFFFFFFF, value 0 will return immediately, value
0xFFFFFFFF will block until card is insert */
sdmmchost_cd_callback_t cardInserted; /*!< card inserted callback which is meaningful for interrupt case */
sdmmchost_cd_callback_t cardRemoved; /*!< card removed callback which is meaningful for interrupt case */
void *userData; /*!< user data */
} sdmmchost_detect_card_t;
/*! @brief card power control function pointer */
typedef void (*sdmmchost_pwr_t)(void);
/*! @brief card power control */
typedef struct _sdmmchost_pwr_card
{
sdmmchost_pwr_t powerOn; /*!< power on function pointer */
uint32_t powerOnDelay_ms; /*!< power on delay */
sdmmchost_pwr_t powerOff; /*!< power off function pointer */
uint32_t powerOffDelay_ms; /*!< power off delay */
} sdmmchost_pwr_card_t;
/*! @brief card interrupt function pointer */
typedef void (*sdmmchost_card_int_callback_t)(void *userData);
/*! @brief card interrupt application callback */
typedef struct _sdmmchost_card_int
{
void *userData; /*!< user data */
sdmmchost_card_int_callback_t cardInterrupt; /*!< card int call back */
} sdmmchost_card_int_t;
/*! @brief card switch voltage function pointer */
typedef void (*sdmmchost_card_switch_voltage_t)(void);
/*! @brief card switch voltage function collection */
typedef struct _sdmmchost_card_switch_voltage_func
{
sdmmchost_card_switch_voltage_t cardSignalLine1V8; /*!< switch to 1.8v function pointer */
sdmmchost_card_switch_voltage_t cardSignalLine3V3; /*!<switch to 3.3V function pointer */
} sdmmchost_card_switch_voltage_func_t;
/*! @brief card user parameter, user can define the parameter according the board, card capability */
typedef struct _sdmmhostcard_usr_param
{
const sdmmchost_detect_card_t *cd; /*!< card detect type */
const sdmmchost_pwr_card_t *pwr; /*!< power control configuration */
const sdmmchost_card_int_t *cardInt; /*!< call back function for card interrupt */
const sdmmchost_card_switch_voltage_func_t *cardVoltage; /*!< card voltage switch function */
} sdmmhostcard_usr_param_t;
/*! @ brief specifiy card user parameter name*/
typedef sdmmhostcard_usr_param_t sdcard_usr_param_t;
typedef sdmmhostcard_usr_param_t sdiocard_usr_param_t;
typedef sdmmhostcard_usr_param_t mmccard_usr_param_t;
/*******************************************************************************
* API
******************************************************************************/
#if defined(__cplusplus)
extern "C" {
#endif
/*!
* @name adaptor function
* @{
*/
/*!
* @brief host not support function, this function is used for host not support feature
* @param void parameter ,used to avoid build warning
* @retval kStatus_Fail ,host do not suppport
*/
static inline status_t SDMMCHOST_NotSupport(void *parameter)
{
parameter = parameter;
return kStatus_Success;
}
/*!
* @brief Detect card insert, only need for SD cases.
* @param base the pointer to host base address
* @param cd card detect configuration
* @param waitCardStatus status which user want to wait
* @retval kStatus_Success detect card insert
* @retval kStatus_Fail card insert event fail
*/
status_t SDMMCHOST_WaitCardDetectStatus(SDMMCHOST_TYPE *hostBase,
const sdmmchost_detect_card_t *cd,
bool waitCardStatus);
/*!
* @brief check card is present or not.
* @retval true card is present
* @retval false card is not present
*/
bool SDMMCHOST_IsCardPresent(void);
/*!
* @brief Init host controller.
* @param host the pointer to host structure in card structure.
* @param userData specific user data
* @retval kStatus_Success host init success
* @retval kStatus_Fail event fail
*/
status_t SDMMCHOST_Init(SDMMCHOST_CONFIG *host, void *userData);
/*!
* @brief reset host controller.
* @param host base address.
*/
void SDMMCHOST_Reset(SDMMCHOST_TYPE *base);
/*!
* @brief host controller error recovery.
* @param host base address.
*/
void SDMMCHOST_ErrorRecovery(SDMMCHOST_TYPE *base);
/*!
* @brief Deinit host controller.
* @param host the pointer to host structure in card structure.
*/
void SDMMCHOST_Deinit(void *host);
/*!
* @brief host power off card function.
* @param base host base address.
* @param pwr depend on user define power configuration.
*/
void SDMMCHOST_PowerOffCard(SDMMCHOST_TYPE *base, const sdmmchost_pwr_card_t *pwr);
/*!
* @brief host power on card function.
* @param base host base address.
* @param pwr depend on user define power configuration.
*/
void SDMMCHOST_PowerOnCard(SDMMCHOST_TYPE *base, const sdmmchost_pwr_card_t *pwr);
/*!
* @brief SDMMC host delay function.
* @param milliseconds delay counter.
*/
void SDMMCHOST_Delay(uint32_t milliseconds);
/*!
* @brief SDMMC host receive tuning block.
* @param base host base address.
* @param tuningCmd, tuning cmd.
* @param revBuf buffer to receive data.
* @param size data size to receive.
*/
status_t SDMMCHOST_ReceiveTuningBlock(SDMMCHOST_TYPE *base, uint32_t tuningCmd, uint32_t *revBuf, uint32_t size);
extern void BOARD_SD_Pin_Config(uint32_t speed, uint32_t strength);
extern void BOARD_MMC_Pin_Config(uint32_t speed, uint32_t strength);
/* @} */
#if defined(__cplusplus)
}
#endif
/* @} */
#endif /* _FSL_SDMMC_HOST_H */
| 45.516687 | 122 | 0.7932 |
03cb847242ddf64dc2c4278cfd6065fe99c6550a | 373 | c | C | 6-recursion/fib-re.c | courses-at-nju-by-hfwei/c-pl-coding-2 | 7a9f3b286657cbf3acc776926e17aba93f06ef58 | [
"MIT"
] | 3 | 2021-12-20T14:15:33.000Z | 2022-03-31T13:54:09.000Z | 6-recursion/fib-re.c | courses-at-nju-by-hfwei/c-pl-coding-2 | 7a9f3b286657cbf3acc776926e17aba93f06ef58 | [
"MIT"
] | null | null | null | 6-recursion/fib-re.c | courses-at-nju-by-hfwei/c-pl-coding-2 | 7a9f3b286657cbf3acc776926e17aba93f06ef58 | [
"MIT"
] | 2 | 2021-11-06T02:46:13.000Z | 2021-12-13T02:02:51.000Z | #include <stdio.h>
/**
* file: fib.c
*
* Recursively computing the n-th Fibonacci number
*
* Created by hengxin on 11/13/21.
*/
int Fib(int n);
int main() {
int n;
scanf("%d", &n);
printf("Fib(%d) = %d\n", n, Fib(n));
return 0;
}
int Fib(int n) {
if (n == 0) {
return 0;
}
if (n == 1) {
return 1;
}
return Fib(n - 1) + Fib(n - 2);
}
| 11.30303 | 50 | 0.49866 |
83f50fb98fa09424fe45332e2a6010378e5c371d | 1,510 | c | C | src/stinger/x86-full-empty.c | ogreen/StreamingBC | 5c20b869f0c51bb14a7e34a69fada88bb05beb24 | [
"BSD-3-Clause"
] | null | null | null | src/stinger/x86-full-empty.c | ogreen/StreamingBC | 5c20b869f0c51bb14a7e34a69fada88bb05beb24 | [
"BSD-3-Clause"
] | null | null | null | src/stinger/x86-full-empty.c | ogreen/StreamingBC | 5c20b869f0c51bb14a7e34a69fada88bb05beb24 | [
"BSD-3-Clause"
] | null | null | null | /* x86 Emulation of Full Empty Bits Using atomic check-and-swap.
*
* NOTES:
* - Using these functions means that the MARKER value defined
* below must be reserved in your application and CANNOT be
* considered a normal value. Feel free to change the value to
* suit your application.
* - Do not compile this file with optimization. There are loops
* that do not make sense in a serial context. The compiler will
* optimize them out.
* - Improper use of these functions can and will result in deadlock.
*
* author: rmccoll3@gatech.edu
*/
#include "x86-full-empty.h"
#if !defined(__MTA__) /* x86 only */
int64_t
readfe(int64_t * v) {
int64_t val;
while(1) {
val = *v;
while(val == MARKER) {
val = *v;
}
if(val == stinger_int64_cas(v, val, MARKER))
break;
}
return val;
}
int64_t
writeef(int64_t * v, int64_t new_val) {
int64_t val;
while(1) {
val = *v;
while(val != MARKER) {
val = *v;
}
if(MARKER == stinger_int64_cas(v, MARKER, new_val))
break;
}
return val;
}
int64_t
readff(int64_t * v) {
int64_t val = *v;
while(val == MARKER) {
val = *v;
}
return val;
}
int64_t
writeff(int64_t * v, int64_t new_val) {
int64_t val;
while(1) {
val = *v;
while(val == MARKER) {
val = *v;
}
if(val == stinger_int64_cas(v, val, new_val))
break;
}
return val;
}
int64_t
writexf(int64_t * v, int64_t new_val) {
*v = new_val;
return new_val;
}
#endif /* x86 only */
| 19.113924 | 69 | 0.616556 |
64220e7a7f429dd5f1e2e8a62cd2401f77bddbcc | 4,418 | c | C | components/x264/x264-snapshot-20181221-2245-stable/filters/filters.c | plkumar/esp32-homekit-camera | 9ae7bf0482bfa08eec7a7e52a920a2664e19f7d6 | [
"MIT"
] | 286 | 2019-01-09T14:33:32.000Z | 2022-03-29T00:18:28.000Z | components/x264/x264-snapshot-20181221-2245-stable/filters/filters.c | jangolen/esp32-homekit-camera | 8a2f6e5e92c148853f681b427cd7c73e30ec3f57 | [
"MIT"
] | 95 | 2019-01-13T13:14:12.000Z | 2022-03-26T16:15:50.000Z | components/x264/x264-snapshot-20181221-2245-stable/filters/filters.c | jangolen/esp32-homekit-camera | 8a2f6e5e92c148853f681b427cd7c73e30ec3f57 | [
"MIT"
] | 71 | 2019-01-07T22:56:17.000Z | 2022-03-03T19:53:37.000Z | /*****************************************************************************
* filters.c: common filter functions
*****************************************************************************
* Copyright (C) 2010-2018 x264 project
*
* Authors: Diogo Franco <diogomfranco@gmail.com>
* Steven Walters <kemuri9@gmail.com>
* Henrik Gramner <henrik@gramner.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at licensing@x264.com.
*****************************************************************************/
#include "filters.h"
#define RETURN_IF_ERROR( cond, ... ) RETURN_IF_ERR( cond, "options", NULL, __VA_ARGS__ )
char **x264_split_options( const char *opt_str, const char * const *options )
{
int opt_count = 0, options_count = 0, found_named = 0, size = 0;
const char *opt = opt_str;
if( !opt_str )
return NULL;
while( options[options_count] )
options_count++;
do
{
int length = strcspn( opt, "=," );
if( opt[length] == '=' )
{
const char * const *option = options;
while( *option && (strlen( *option ) != length || strncmp( opt, *option, length )) )
option++;
RETURN_IF_ERROR( !*option, "Invalid option '%.*s'\n", length, opt );
found_named = 1;
length += strcspn( opt + length, "," );
}
else
{
RETURN_IF_ERROR( opt_count >= options_count, "Too many options given\n" );
RETURN_IF_ERROR( found_named, "Ordered option given after named\n" );
size += strlen( options[opt_count] ) + 1;
}
opt_count++;
opt += length;
} while( *opt++ );
int offset = 2 * (opt_count+1) * sizeof(char*);
size += offset + (opt - opt_str);
char **opts = calloc( 1, size );
RETURN_IF_ERROR( !opts, "malloc failed\n" );
#define insert_opt( src, length )\
do {\
opts[i++] = memcpy( (char*)opts + offset, src, length );\
offset += length + 1;\
src += length + 1;\
} while( 0 )
for( int i = 0; i < 2*opt_count; )
{
int length = strcspn( opt_str, "=," );
if( opt_str[length] == '=' )
{
insert_opt( opt_str, length );
length = strcspn( opt_str, "," );
}
else
{
const char *option = options[i/2];
int option_length = strlen( option );
insert_opt( option, option_length );
}
insert_opt( opt_str, length );
}
assert( offset == size );
return opts;
}
char *x264_get_option( const char *name, char **split_options )
{
if( split_options )
{
int last_i = -1;
for( int i = 0; split_options[i]; i += 2 )
if( !strcmp( split_options[i], name ) )
last_i = i;
if( last_i >= 0 && split_options[last_i+1][0] )
return split_options[last_i+1];
}
return NULL;
}
int x264_otob( const char *str, int def )
{
if( str )
return !strcasecmp( str, "true" ) || !strcmp( str, "1" ) || !strcasecmp( str, "yes" );
return def;
}
double x264_otof( const char *str, double def )
{
double ret = def;
if( str )
{
char *end;
ret = strtod( str, &end );
if( end == str || *end != '\0' )
ret = def;
}
return ret;
}
int x264_otoi( const char *str, int def )
{
int ret = def;
if( str )
{
char *end;
ret = strtol( str, &end, 0 );
if( end == str || *end != '\0' )
ret = def;
}
return ret;
}
char *x264_otos( char *str, char *def )
{
return str ? str : def;
}
| 29.453333 | 96 | 0.536895 |
23b8667219d04df44ec969d245017ddeaeb7880c | 1,499 | h | C | Kernel/FileSystem/Custody.h | ramjeewan/serenity | dde10f534f5d6631dd5b43facfc0ccdfc31890d8 | [
"BSD-2-Clause"
] | null | null | null | Kernel/FileSystem/Custody.h | ramjeewan/serenity | dde10f534f5d6631dd5b43facfc0ccdfc31890d8 | [
"BSD-2-Clause"
] | null | null | null | Kernel/FileSystem/Custody.h | ramjeewan/serenity | dde10f534f5d6631dd5b43facfc0ccdfc31890d8 | [
"BSD-2-Clause"
] | null | null | null | #pragma once
#include <AK/AKString.h>
#include <AK/Badge.h>
#include <AK/InlineLinkedList.h>
#include <AK/RefCounted.h>
#include <AK/RefPtr.h>
class Inode;
class VFS;
// FIXME: Custody needs some locking.
class Custody : public RefCounted<Custody>
, public InlineLinkedListNode<Custody> {
public:
static Custody* get_if_cached(Custody* parent, const StringView& name);
static NonnullRefPtr<Custody> get_or_create(Custody* parent, const StringView& name, Inode&);
static NonnullRefPtr<Custody> create(Custody* parent, const StringView& name, Inode& inode)
{
return adopt(*new Custody(parent, name, inode));
}
~Custody();
Custody* parent() { return m_parent.ptr(); }
const Custody* parent() const { return m_parent.ptr(); }
Inode& inode() { return *m_inode; }
const Inode& inode() const { return *m_inode; }
const String& name() const { return m_name; }
String absolute_path() const;
bool is_deleted() const { return m_deleted; }
bool is_mounted_on() const { return m_mounted_on; }
void did_delete(Badge<VFS>);
void did_mount_on(Badge<VFS>);
void did_rename(Badge<VFS>, const String& name);
// For InlineLinkedListNode.
Custody* m_next { nullptr };
Custody* m_prev { nullptr };
private:
Custody(Custody* parent, const StringView& name, Inode&);
RefPtr<Custody> m_parent;
String m_name;
NonnullRefPtr<Inode> m_inode;
bool m_deleted { false };
bool m_mounted_on { false };
};
| 28.283019 | 97 | 0.684456 |
143148922d7077c1f56dc8afbe7c83974396812b | 788 | h | C | Demo/Pods/Headers/Public/ZDToolKit/ZDDispatchSourceMerge.h | faimin/ZDUtility | d00c94805fdf0fe8ceaf8c12bfc7021f5d91f3a9 | [
"MIT"
] | 6 | 2016-04-21T05:50:54.000Z | 2019-07-24T01:18:45.000Z | Demo/Pods/Headers/Public/ZDToolKit/ZDDispatchSourceMerge.h | faimin/ZDUtility | d00c94805fdf0fe8ceaf8c12bfc7021f5d91f3a9 | [
"MIT"
] | 1 | 2017-12-13T07:03:35.000Z | 2017-12-13T10:17:53.000Z | Demo/Pods/Headers/Public/ZDToolKit/ZDDispatchSourceMerge.h | faimin/ZDUtility | d00c94805fdf0fe8ceaf8c12bfc7021f5d91f3a9 | [
"MIT"
] | 5 | 2017-11-21T10:12:30.000Z | 2022-03-31T07:57:51.000Z | //
// ZDDispatchSourceMerge.h
// ZDToolKit
//
// Created by Zero.D.Saber on 2018/5/18.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, MDDispatchSourceMergeType) {
MDDispatchSourceMergeType_NULL,
MDDispatchSourceMergeType_UI,
MDDispatchSourceMergeType_DATA,
};
@protocol ZDDispatchSourceMergeDelegate <NSObject>
@optional
- (void)refreshUI;
- (void)refreshData;
@end
@interface ZDDispatchSourceMerge : NSObject
@property (nonatomic, weak, readonly) id<ZDDispatchSourceMergeDelegate> delegate;
- (instancetype)initWithSourceType:(MDDispatchSourceMergeType)type onQueue:(nullable dispatch_queue_t)onQueue delegate:(id<ZDDispatchSourceMergeDelegate>)delegate;
- (void)merge;
- (void)clearSource;
@end
NS_ASSUME_NONNULL_END
| 20.736842 | 163 | 0.796954 |
37de984a1283b875df7cf9cfca652c7fd9435a58 | 1,615 | c | C | src/main.c | Dusan-Krehel/ldcopy | dc79d7572a4149a13beee5e1280377a7c539eafe | [
"CC0-1.0"
] | 2 | 2016-10-06T05:23:01.000Z | 2019-12-01T16:56:11.000Z | src/main.c | Dusan-Krehel/ldcopy | dc79d7572a4149a13beee5e1280377a7c539eafe | [
"CC0-1.0"
] | null | null | null | src/main.c | Dusan-Krehel/ldcopy | dc79d7572a4149a13beee5e1280377a7c539eafe | [
"CC0-1.0"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../config.h"
#include "copy.h"
#include "ldd.h"
#include "libraries.h"
#ifndef STRING_LANG
#define STRING_LANG 300
#endif // STRING_LANG
void usage(const char *argv_0)
{
fprintf(stderr,
"Usage: %s PATH_TO_PROGRAM ROOT_PATH\n\n"
"Description:"
"\n\tLdcopy is a small program to copy (tree) all shared "
"library "
"\n\tinto destination directory ROOT_PATH. If in destination "
"\n\tdirectory existing another version of library, then don't "
"\n\tcopy, but create symbolic link. existing library."
"\n"
"\nArguments:"
"\n\tPATH_TO_PROGRAM:"
"\n\t - Full path to binary program, where will copy library"
"\n"
"\n"
"\tROOT_PATH:"
"\n\t - Root path, where will then store library"
"\n\t - If no exist, then will created."
"\n"
"\nVersion:"
"\n\t" PACKAGE_VERSION
"\n"
"\nExample:\n"
"\t%s /bin/bash /tmp/"
"\n"
"\n"
"Contact:\n"
"\t" PACKAGE_BUGREPORT "\n",
argv_0,argv_0,argv_0);
}
int main(int argc, char **argv)
{
if(argc != 3)
{
usage(argv[0]);
return;
}
char *path;
int lenght;
t_libraries *libraries;
libraries=ldd_get(argv[1]);
if(libraries == NULL)
return 1;
/* if argv[2] dont have on end '/', then appeding */
lenght=strlen(argv[2]);
if(argv[2][lenght-1] != '/')
{
path=(char *) malloc(lenght+1);
if(path == NULL)
return 1;
strncpy(path, argv[2], lenght);
path[lenght]='/';
path[lenght+1]='\0';
copy(libraries, path);
free(path);
}
else
copy(libraries, argv[2]);
libraries_free(libraries);
return 0;
}
| 19.22619 | 66 | 0.623529 |
e42d210ce9a9817f91462d618763a4170d64d1f8 | 1,515 | h | C | System/Library/PrivateFrameworks/PassKitCore.framework/PKDiffHunk.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | 1 | 2020-11-04T15:43:01.000Z | 2020-11-04T15:43:01.000Z | System/Library/PrivateFrameworks/PassKitCore.framework/PKDiffHunk.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/PassKitCore.framework/PKDiffHunk.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | /*
* This header is generated by classdump-dyld 1.0
* on Sunday, September 27, 2020 at 11:40:25 AM Mountain Standard Time
* Operating System: Version 14.0 (Build 18A373)
* Image Source: /System/Library/PrivateFrameworks/PassKitCore.framework/PassKitCore
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos.
*/
#import <libobjc.A.dylib/NSSecureCoding.h>
@class NSString;
@interface PKDiffHunk : NSObject <NSSecureCoding> {
NSString* _key;
id _oldValue;
id _newValue;
NSString* _message;
}
@property (nonatomic,retain) NSString * key; //@synthesize key=_key - In the implementation block
@property (nonatomic,retain) id valueOld; //@synthesize oldValue=_oldValue - In the implementation block
@property (nonatomic,retain) id valueNew; //@synthesize newValue=_newValue - In the implementation block
@property (nonatomic,retain) NSString * message; //@synthesize message=_message - In the implementation block
+(BOOL)supportsSecureCoding;
+(id)hunkWithKey:(id)arg1 oldValue:(id)arg2 newValue:(id)arg3 message:(id)arg4 ;
-(NSString *)key;
-(void)setKey:(NSString *)arg1 ;
-(void)setValueOld:(id)arg1 ;
-(id)valueOld;
-(id)valueNew;
-(void)setValueNew:(id)arg1 ;
-(BOOL)isEqualToDiffHunk:(id)arg1 ;
-(void)setMessage:(NSString *)arg1 ;
-(long long)compare:(id)arg1 ;
-(BOOL)isEqual:(id)arg1 ;
-(id)initWithCoder:(id)arg1 ;
-(void)encodeWithCoder:(id)arg1 ;
-(unsigned long long)hash;
-(NSString *)message;
@end
| 34.431818 | 124 | 0.716172 |
17ef181254643cb78a05865312486bf9048e1d88 | 1,014 | h | C | dev/ScrollPresenter/ScrollControllerScrollByRequestedEventArgs.h | MarkIvanDev/microsoft-ui-xaml | 35e7100197efac14d647beb8d584b5766c279790 | [
"MIT"
] | 1 | 2020-07-12T15:33:44.000Z | 2020-07-12T15:33:44.000Z | dev/ScrollPresenter/ScrollControllerScrollByRequestedEventArgs.h | maxkatz6/microsoft-ui-xaml | 78fa7f674364e7c3e0facd424760826d284296b6 | [
"MIT"
] | null | null | null | dev/ScrollPresenter/ScrollControllerScrollByRequestedEventArgs.h | maxkatz6/microsoft-ui-xaml | 78fa7f674364e7c3e0facd424760826d284296b6 | [
"MIT"
] | 1 | 2020-07-30T12:37:40.000Z | 2020-07-30T12:37:40.000Z | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#pragma once
#include "ScrollControllerScrollByRequestedEventArgs.g.h"
class ScrollControllerScrollByRequestedEventArgs :
public winrt::implementation::ScrollControllerScrollByRequestedEventArgsT<ScrollControllerScrollByRequestedEventArgs>
{
public:
~ScrollControllerScrollByRequestedEventArgs()
{
SCROLLPRESENTER_TRACE_VERBOSE(nullptr, TRACE_MSG_METH, METH_NAME, this);
}
ScrollControllerScrollByRequestedEventArgs(
double offsetDelta,
winrt::ScrollingScrollOptions const & options);
double OffsetDelta() const;
winrt::ScrollingScrollOptions Options() const;
winrt::ScrollInfo Info() const;
void Info(winrt::ScrollInfo info);
private:
double m_offsetDelta{ 0.0 };
winrt::ScrollingScrollOptions m_options{ nullptr };
winrt::ScrollInfo m_info{ -1 };
};
| 32.709677 | 122 | 0.741617 |
9df2635093a558caa80955d0ebb13267b323eeee | 26,091 | h | C | generated/CPP14ParserBaseVisitor.h | maoxiezhao/CjingPreparser | cda6c6301a6eff9222d0b33097d8aa666d300f2f | [
"MIT"
] | null | null | null | generated/CPP14ParserBaseVisitor.h | maoxiezhao/CjingPreparser | cda6c6301a6eff9222d0b33097d8aa666d300f2f | [
"MIT"
] | null | null | null | generated/CPP14ParserBaseVisitor.h | maoxiezhao/CjingPreparser | cda6c6301a6eff9222d0b33097d8aa666d300f2f | [
"MIT"
] | null | null | null |
// Generated from CPP14Parser.g4 by ANTLR 4.8
#pragma once
#include "antlr4-runtime.h"
#include "CPP14ParserVisitor.h"
namespace antlrcpptest {
/**
* This class provides an empty implementation of CPP14ParserVisitor, which can be
* extended to create a visitor which only needs to handle a subset of the available methods.
*/
class CPP14ParserBaseVisitor : public CPP14ParserVisitor {
public:
virtual antlrcpp::Any visitTranslationUnit(CPP14Parser::TranslationUnitContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitPrimaryExpression(CPP14Parser::PrimaryExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitIdExpression(CPP14Parser::IdExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitUnqualifiedId(CPP14Parser::UnqualifiedIdContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitQualifiedId(CPP14Parser::QualifiedIdContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitNestedNameSpecifier(CPP14Parser::NestedNameSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitLambdaExpression(CPP14Parser::LambdaExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitLambdaIntroducer(CPP14Parser::LambdaIntroducerContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitLambdaCapture(CPP14Parser::LambdaCaptureContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitCaptureDefault(CPP14Parser::CaptureDefaultContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitCaptureList(CPP14Parser::CaptureListContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitCapture(CPP14Parser::CaptureContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitSimpleCapture(CPP14Parser::SimpleCaptureContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitInitcapture(CPP14Parser::InitcaptureContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitLambdaDeclarator(CPP14Parser::LambdaDeclaratorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitPostfixExpression(CPP14Parser::PostfixExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTypeIdOfTheTypeId(CPP14Parser::TypeIdOfTheTypeIdContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitExpressionList(CPP14Parser::ExpressionListContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitPseudoDestructorName(CPP14Parser::PseudoDestructorNameContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitUnaryExpression(CPP14Parser::UnaryExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitUnaryOperator(CPP14Parser::UnaryOperatorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitNewExpression(CPP14Parser::NewExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitNewPlacement(CPP14Parser::NewPlacementContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitNewTypeId(CPP14Parser::NewTypeIdContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitNewDeclarator(CPP14Parser::NewDeclaratorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitNoPointerNewDeclarator(CPP14Parser::NoPointerNewDeclaratorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitNewInitializer(CPP14Parser::NewInitializerContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitDeleteExpression(CPP14Parser::DeleteExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitNoExceptExpression(CPP14Parser::NoExceptExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitCastExpression(CPP14Parser::CastExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitPointerMemberExpression(CPP14Parser::PointerMemberExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitMultiplicativeExpression(CPP14Parser::MultiplicativeExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitAdditiveExpression(CPP14Parser::AdditiveExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitShiftExpression(CPP14Parser::ShiftExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitShiftOperator(CPP14Parser::ShiftOperatorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitRelationalExpression(CPP14Parser::RelationalExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitEqualityExpression(CPP14Parser::EqualityExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitAndExpression(CPP14Parser::AndExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitExclusiveOrExpression(CPP14Parser::ExclusiveOrExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitInclusiveOrExpression(CPP14Parser::InclusiveOrExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitLogicalAndExpression(CPP14Parser::LogicalAndExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitLogicalOrExpression(CPP14Parser::LogicalOrExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitConditionalExpression(CPP14Parser::ConditionalExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitAssignmentExpression(CPP14Parser::AssignmentExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitAssignmentOperator(CPP14Parser::AssignmentOperatorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitExpression(CPP14Parser::ExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitConstantExpression(CPP14Parser::ConstantExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitStatement(CPP14Parser::StatementContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitLabeledStatement(CPP14Parser::LabeledStatementContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitExpressionStatement(CPP14Parser::ExpressionStatementContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitCompoundStatement(CPP14Parser::CompoundStatementContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitStatementSeq(CPP14Parser::StatementSeqContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitSelectionStatement(CPP14Parser::SelectionStatementContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitCondition(CPP14Parser::ConditionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitIterationStatement(CPP14Parser::IterationStatementContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitForInitStatement(CPP14Parser::ForInitStatementContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitForRangeDeclaration(CPP14Parser::ForRangeDeclarationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitForRangeInitializer(CPP14Parser::ForRangeInitializerContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitJumpStatement(CPP14Parser::JumpStatementContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitDeclarationStatement(CPP14Parser::DeclarationStatementContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitDeclarationseq(CPP14Parser::DeclarationseqContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitDeclaration(CPP14Parser::DeclarationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitBlockDeclaration(CPP14Parser::BlockDeclarationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitAliasDeclaration(CPP14Parser::AliasDeclarationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitSimpleDeclaration(CPP14Parser::SimpleDeclarationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitStaticAssertDeclaration(CPP14Parser::StaticAssertDeclarationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitEmptyDeclaration(CPP14Parser::EmptyDeclarationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitAttributeDeclaration(CPP14Parser::AttributeDeclarationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitDeclSpecifier(CPP14Parser::DeclSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitDeclSpecifierSeq(CPP14Parser::DeclSpecifierSeqContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitStorageClassSpecifier(CPP14Parser::StorageClassSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitFunctionSpecifier(CPP14Parser::FunctionSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTypedefName(CPP14Parser::TypedefNameContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTypeSpecifier(CPP14Parser::TypeSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTrailingTypeSpecifier(CPP14Parser::TrailingTypeSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTypeSpecifierSeq(CPP14Parser::TypeSpecifierSeqContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTrailingTypeSpecifierSeq(CPP14Parser::TrailingTypeSpecifierSeqContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitSimpleTypeSpecifier(CPP14Parser::SimpleTypeSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTheTypeName(CPP14Parser::TheTypeNameContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitDecltypeSpecifier(CPP14Parser::DecltypeSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitElaboratedTypeSpecifier(CPP14Parser::ElaboratedTypeSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitEnumName(CPP14Parser::EnumNameContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitEnumSpecifier(CPP14Parser::EnumSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitEnumHead(CPP14Parser::EnumHeadContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitOpaqueEnumDeclaration(CPP14Parser::OpaqueEnumDeclarationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitEnumkey(CPP14Parser::EnumkeyContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitEnumbase(CPP14Parser::EnumbaseContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitEnumeratorList(CPP14Parser::EnumeratorListContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitEnumeratorDefinition(CPP14Parser::EnumeratorDefinitionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitEnumerator(CPP14Parser::EnumeratorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitNamespaceName(CPP14Parser::NamespaceNameContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitOriginalNamespaceName(CPP14Parser::OriginalNamespaceNameContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitNamespaceDefinition(CPP14Parser::NamespaceDefinitionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitNamespaceAlias(CPP14Parser::NamespaceAliasContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitNamespaceAliasDefinition(CPP14Parser::NamespaceAliasDefinitionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitQualifiednamespacespecifier(CPP14Parser::QualifiednamespacespecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitUsingDeclaration(CPP14Parser::UsingDeclarationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitUsingDirective(CPP14Parser::UsingDirectiveContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitAsmDefinition(CPP14Parser::AsmDefinitionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitLinkageSpecification(CPP14Parser::LinkageSpecificationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitAttributeSpecifierSeq(CPP14Parser::AttributeSpecifierSeqContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitAttributeSpecifier(CPP14Parser::AttributeSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitAlignmentspecifier(CPP14Parser::AlignmentspecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitAttributeList(CPP14Parser::AttributeListContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitAttribute(CPP14Parser::AttributeContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitAttributeNamespace(CPP14Parser::AttributeNamespaceContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitAttributeArgumentClause(CPP14Parser::AttributeArgumentClauseContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitBalancedTokenSeq(CPP14Parser::BalancedTokenSeqContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitBalancedtoken(CPP14Parser::BalancedtokenContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitInitDeclaratorList(CPP14Parser::InitDeclaratorListContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitInitDeclarator(CPP14Parser::InitDeclaratorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitDeclarator(CPP14Parser::DeclaratorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitPointerDeclarator(CPP14Parser::PointerDeclaratorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitNoPointerDeclarator(CPP14Parser::NoPointerDeclaratorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitParametersAndQualifiers(CPP14Parser::ParametersAndQualifiersContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTrailingReturnType(CPP14Parser::TrailingReturnTypeContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitPointerOperator(CPP14Parser::PointerOperatorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitCvqualifierseq(CPP14Parser::CvqualifierseqContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitCvQualifier(CPP14Parser::CvQualifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitRefqualifier(CPP14Parser::RefqualifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitDeclaratorid(CPP14Parser::DeclaratoridContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTheTypeId(CPP14Parser::TheTypeIdContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitAbstractDeclarator(CPP14Parser::AbstractDeclaratorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitPointerAbstractDeclarator(CPP14Parser::PointerAbstractDeclaratorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitNoPointerAbstractDeclarator(CPP14Parser::NoPointerAbstractDeclaratorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitAbstractPackDeclarator(CPP14Parser::AbstractPackDeclaratorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitNoPointerAbstractPackDeclarator(CPP14Parser::NoPointerAbstractPackDeclaratorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitParameterDeclarationClause(CPP14Parser::ParameterDeclarationClauseContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitParameterDeclarationList(CPP14Parser::ParameterDeclarationListContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitParameterDeclaration(CPP14Parser::ParameterDeclarationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitFunctionDefinition(CPP14Parser::FunctionDefinitionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitFunctionBody(CPP14Parser::FunctionBodyContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitInitializer(CPP14Parser::InitializerContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitBraceOrEqualInitializer(CPP14Parser::BraceOrEqualInitializerContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitInitializerClause(CPP14Parser::InitializerClauseContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitInitializerList(CPP14Parser::InitializerListContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitBracedInitList(CPP14Parser::BracedInitListContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitClassName(CPP14Parser::ClassNameContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitClassSpecifier(CPP14Parser::ClassSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitClassHead(CPP14Parser::ClassHeadContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitClassHeadName(CPP14Parser::ClassHeadNameContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitClassVirtSpecifier(CPP14Parser::ClassVirtSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitClassKey(CPP14Parser::ClassKeyContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitMemberSpecification(CPP14Parser::MemberSpecificationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitMemberdeclaration(CPP14Parser::MemberdeclarationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitMemberDeclaratorList(CPP14Parser::MemberDeclaratorListContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitMemberDeclarator(CPP14Parser::MemberDeclaratorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitVirtualSpecifierSeq(CPP14Parser::VirtualSpecifierSeqContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitVirtualSpecifier(CPP14Parser::VirtualSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitPureSpecifier(CPP14Parser::PureSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitBaseClause(CPP14Parser::BaseClauseContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitBaseSpecifierList(CPP14Parser::BaseSpecifierListContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitBaseSpecifier(CPP14Parser::BaseSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitClassOrDeclType(CPP14Parser::ClassOrDeclTypeContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitBaseTypeSpecifier(CPP14Parser::BaseTypeSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitAccessSpecifier(CPP14Parser::AccessSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitConversionFunctionId(CPP14Parser::ConversionFunctionIdContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitConversionTypeId(CPP14Parser::ConversionTypeIdContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitConversionDeclarator(CPP14Parser::ConversionDeclaratorContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitConstructorInitializer(CPP14Parser::ConstructorInitializerContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitMemInitializerList(CPP14Parser::MemInitializerListContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitMemInitializer(CPP14Parser::MemInitializerContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitMeminitializerid(CPP14Parser::MeminitializeridContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitOperatorFunctionId(CPP14Parser::OperatorFunctionIdContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitLiteralOperatorId(CPP14Parser::LiteralOperatorIdContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTemplateDeclaration(CPP14Parser::TemplateDeclarationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTemplateparameterList(CPP14Parser::TemplateparameterListContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTemplateParameter(CPP14Parser::TemplateParameterContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTypeParameter(CPP14Parser::TypeParameterContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitSimpleTemplateId(CPP14Parser::SimpleTemplateIdContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTemplateId(CPP14Parser::TemplateIdContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTemplateName(CPP14Parser::TemplateNameContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTemplateArgumentList(CPP14Parser::TemplateArgumentListContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTemplateArgument(CPP14Parser::TemplateArgumentContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTypeNameSpecifier(CPP14Parser::TypeNameSpecifierContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitExplicitInstantiation(CPP14Parser::ExplicitInstantiationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitExplicitSpecialization(CPP14Parser::ExplicitSpecializationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTryBlock(CPP14Parser::TryBlockContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitFunctionTryBlock(CPP14Parser::FunctionTryBlockContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitHandlerSeq(CPP14Parser::HandlerSeqContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitHandler(CPP14Parser::HandlerContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitExceptionDeclaration(CPP14Parser::ExceptionDeclarationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitThrowExpression(CPP14Parser::ThrowExpressionContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitExceptionSpecification(CPP14Parser::ExceptionSpecificationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitDynamicExceptionSpecification(CPP14Parser::DynamicExceptionSpecificationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTypeIdList(CPP14Parser::TypeIdListContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitNoeExceptSpecification(CPP14Parser::NoeExceptSpecificationContext *ctx) override {
return visitChildren(ctx);
}
virtual antlrcpp::Any visitTheOperator(CPP14Parser::TheOperatorContext *ctx) override {
return visitChildren(ctx);
}
};
} // namespace antlrcpptest
| 33.622423 | 129 | 0.779771 |
77fdd2f86b106d7615d5b131d5d80118c1e66e9d | 1,877 | h | C | arduino/IoT.h | nzchicken/tasker | 2b6c85d4bb5c6d1e9f00d21621186ef9e28aff75 | [
"MIT"
] | 1 | 2019-02-15T11:15:22.000Z | 2019-02-15T11:15:22.000Z | arduino/IoT.h | nzchicken/tasker | 2b6c85d4bb5c6d1e9f00d21621186ef9e28aff75 | [
"MIT"
] | null | null | null | arduino/IoT.h | nzchicken/tasker | 2b6c85d4bb5c6d1e9f00d21621186ef9e28aff75 | [
"MIT"
] | null | null | null | #ifndef IOT.H
#define IOT.H
//This before line needs to be adjusted in PubSubClient.h
//#define MQTT_MAX_PACKET_SIZE 512
#include <Stream.h>
#include <PubSubClient.h>
#include "AWSWebSocketClient.h"
extern "C" {
#include "user_interface.h"
}
//const char *publish_topic = "$aws/things/tasker/shadow/update";
//MQTT config
const int maxMQTTMessageHandlers = 1;
class IoT {
public:
IoT(char *thingName, char *ep, char *key, char *secret, char *region = "eu-central-1", int port = 443, std::function<void()> connectedCB = NULL)
: thingName(thingName), ep(ep), key(key), secret(secret), region(region), port(port), connectedCallback(connectedCB) {
awsWSclient = new AWSWebSocketClient(1000);
mqttclient = new PubSubClient(*awsWSclient);
sprintf(topics[0], "$aws/things/%s/shadow/update/accepted", thingName);
sprintf(topics[1], "$aws/things/%s/shadow/update/rejected", thingName);
sprintf(topics[2], "$aws/things/%s/shadow/update/delta", thingName);
sprintf(topics[3], "$aws/things/%s/shadow/get/accepted", thingName);
sprintf(topics[4], "$aws/things/%s/shadow/get/rejected", thingName);
sprintf(publishTopic, "$aws/things/%s/shadow/update", thingName);
sprintf(getTopic, "$aws/things/%s/shadow/get", thingName);
};
void setup();
void loop();
bool connectToMQTT();
void subscribeToTopics();
void setCallback(MQTT_CALLBACK_SIGNATURE);
void setConnectedCallback(std::function<void()> callback);
void sendState(char *state);
void getState();
char* generateClientID();
private:
char *thingName, *ep, *key, *secret, *region;
char topics[5][64], publishTopic[64], getTopic[64];
int port;
AWSWebSocketClient *awsWSclient;
PubSubClient *mqttclient;
MQTT_CALLBACK_SIGNATURE;
std::function<void()> connectedCallback;
};
#endif
| 31.283333 | 148 | 0.683005 |
cbe68411ae3fadb108cbf3ab2b709a9342d2ce4d | 1,736 | h | C | imtest/iOS_IMKit/Headers/RCContactNotificationMessage.h | caicai0/CAIAutoCoding | 0534759fb5a62680e91ea5af1f7aac7dbb651024 | [
"MIT"
] | 1 | 2015-04-10T13:37:38.000Z | 2015-04-10T13:37:38.000Z | mckuai/TencentOpenApi_IOS_Bundle.bundle/Headers/RCContactNotificationMessage.h | BGDigital/mckuai2.0 | f255d12724235047b70a44a558d50329750f4018 | [
"MIT"
] | null | null | null | mckuai/TencentOpenApi_IOS_Bundle.bundle/Headers/RCContactNotificationMessage.h | BGDigital/mckuai2.0 | f255d12724235047b70a44a558d50329750f4018 | [
"MIT"
] | null | null | null | //
// RCContactNotificationMessage.h
// iOS-IMLib
//
// Created by xugang on 14/11/28.
// Copyright (c) 2014年 RongCloud. All rights reserved.
//
#import "RCNotificationMessage.h"
#define RCContactNotificationMessageIdentifier @"RC:ContactNtf"
#define ContactNotificationMessage_ContactOperationRequest @"Request" // 加好友请求。
#define ContactNotificationMessage_ContactOperationAcceptResponse @"AcceptResponse" // 加好友请求。
#define ContactNotificationMessage_ContactOperationRejectResponse @"RejectResponse" // 加好友请求。
/**
* 好友消息类。
*/
@interface RCContactNotificationMessage : RCNotificationMessage
/**
* 操作名,对应 ContactOperationXxxx,或自己传任何字符串。
*/
@property(nonatomic, strong) NSString *operation; // 操作名,对应 ContactOperationXxxx,或自己传任何字符串。
/**
* 请求者或者响应者的 UserId。
*/
@property(nonatomic, strong) NSString *sourceUserId; // 请求者或者响应者的 UserId。
/**
* 被请求者或者被响应者的 UserId。
*/
@property(nonatomic, strong) NSString *targetUserId; // 被请求者或者被响应者的 UserId。
/**
* 请求或者响应消息,如添加理由或拒绝理由。
*/
@property(nonatomic, strong) NSString *message; // 请求或者响应消息,如添加理由或拒绝理由。
/**
* 附加信息。
*/
@property(nonatomic, strong) NSString *extra; // 附加信息。
/**
* 构造方法
*
* @param operation 操作名,对应 ContactOperationXxxx,或自己传任何字符串。
* @param sourceUserId 请求者或者响应者的 UserId。
* @param targetUserId 被请求者或者被响应者的 UserId。
* @param message 请求或者响应消息,如添加理由或拒绝理由。
* @param extra 附加信息。
*
* @return 类实例
*/
+(instancetype)notificationWithOperation:(NSString*)operation
sourceUserId:(NSString *)sourceUserId
targetUserId:(NSString *)targetUserId
message:(NSString*)message
extra:(NSString*)extra;
@end
| 28.933333 | 93 | 0.684332 |
1292172fa15746f4a761382f92aec6d2cac522d0 | 2,376 | h | C | OrionUO/Gumps/GumpSkills.h | BryanNoller/OrionUO | 5985315969c5f3c7c7552392d9d40d4b24b718e2 | [
"MIT"
] | 169 | 2016-09-16T22:24:34.000Z | 2022-03-27T09:58:20.000Z | OrionUO/Gumps/GumpSkills.h | BryanNoller/OrionUO | 5985315969c5f3c7c7552392d9d40d4b24b718e2 | [
"MIT"
] | 104 | 2016-10-26T23:02:52.000Z | 2021-10-02T17:36:04.000Z | OrionUO/Gumps/GumpSkills.h | BryanNoller/OrionUO | 5985315969c5f3c7c7552392d9d40d4b24b718e2 | [
"MIT"
] | 111 | 2016-09-16T22:25:30.000Z | 2022-03-28T07:01:40.000Z | /***********************************************************************************
**
** GumpSkills.h
**
** Copyright (C) August 2016 Hotride
**
************************************************************************************
*/
//----------------------------------------------------------------------------------
#pragma once
#include <SDL_events.h>
//----------------------------------------------------------------------------------
class CGumpSkills : public CGumpBaseScroll
{
private:
static constexpr int ID_GS_SHOW_REAL = 1;
static constexpr int ID_GS_SHOW_CAP = 2;
static constexpr int ID_GS_BUTTON_NEW_GROUP = 3;
static constexpr int ID_GS_LOCK_MOVING = 4;
static constexpr int ID_GS_GROUP_MINIMIZE = 10000;
static constexpr int ID_GS_GROUP = 11000;
static constexpr int ID_GS_SKILL_BUTTON = 12000;
static constexpr int ID_GS_SKILL = 13000;
static constexpr int ID_GS_SKILL_STATE = 14000;
bool m_ShowReal{ false };
bool m_ShowCap{ false };
//Получить группу над курсором
class CSkillGroupObject *GetGroupUnderCursor(int &index);
CGUIGumppic *m_BottomLine{ NULL };
CGUIGumppic *m_Comment{ NULL };
CGUIButton *m_CreateGroup{ NULL };
CGUIText *m_SkillSum{ NULL };
CGUICheckbox *m_CheckboxShowReal{ NULL };
CGUICheckbox *m_CheckboxShowCap{ NULL };
void UpdateGroupPositions();
void SetGroupTextFromEntry();
protected:
virtual void CalculateGumpState();
virtual void UpdateHeight();
public:
CGumpSkills(short x, short y, bool minimized, int height);
virtual ~CGumpSkills();
void UpdateGroupText();
CGUISkillGroup *GetSkillGroup(int index);
CGUISkillItem *GetSkill(int index);
void UpdateSkillValue(int index);
void UpdateSkillValues();
void UpdateSkillsSum();
void Init();
virtual void InitToolTip();
virtual void PrepareContent();
GUMP_BUTTON_EVENT_H;
GUMP_CHECKBOX_EVENT_H;
GUMP_TEXT_ENTRY_EVENT_H;
virtual void OnLeftMouseButtonUp();
virtual bool OnLeftMouseButtonDoubleClick();
#if USE_WISP
virtual void OnCharPress(const WPARAM &wParam, const LPARAM &lParam);
virtual void OnKeyDown(const WPARAM &wParam, const LPARAM &lParam);
#else
virtual void OnTextInput(const SDL_TextInputEvent &ev) override;
virtual void OnKeyDown(const SDL_KeyboardEvent &ev) override;
#endif
};
| 28.626506 | 84 | 0.621633 |
3fe91825dfca981a43a962c1574c8f0830c38dde | 2,010 | h | C | tesseract_ros_examples/include/tesseract_ros_examples/basic_cartesian_example.h | KevinWarburton/tesseract_ros | 1864c1d7b1f84828cd0c228927f23bada798a451 | [
"BSD-2-Clause",
"Apache-2.0"
] | 1 | 2020-04-02T22:15:06.000Z | 2020-04-02T22:15:06.000Z | tesseract_ros_examples/include/tesseract_ros_examples/basic_cartesian_example.h | cbw36/tesseract_ros | a430b59ef95220232628e4e2266f0a31e82134de | [
"Apache-2.0",
"BSD-2-Clause"
] | 1 | 2021-07-22T15:59:52.000Z | 2021-08-30T22:40:19.000Z | tesseract_ros_examples/include/tesseract_ros_examples/basic_cartesian_example.h | cbw36/tesseract_ros | a430b59ef95220232628e4e2266f0a31e82134de | [
"Apache-2.0",
"BSD-2-Clause"
] | null | null | null | /**
* @file basic_cartesian_example.h
* @brief Basic example leveraging trajopt and tesseract for cartesian planning
*
* @author Levi Armstrong
* @date July 22, 2018
* @version TODO
* @bug No known bugs
*
* @copyright Copyright (c) 2017, Southwest Research Institute
*
* @par License
* Software License Agreement (Apache License)
* @par
* 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
* @par
* 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 TESSERACT_ROS_EXAMPLES_BASIC_CARTESIAN_EXAMPLE_H
#define TESSERACT_ROS_EXAMPLES_BASIC_CARTESIAN_EXAMPLE_H
#include <tesseract_common/macros.h>
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#include <string>
#include <ros/ros.h>
TESSERACT_COMMON_IGNORE_WARNINGS_POP
#include <tesseract_ros_examples/example.h>
namespace tesseract_ros_examples
{
/**
* @brief Basic example leveraging trajopt and tesseract for cartesian planning
*/
class BasicCartesianExample : public Example
{
public:
BasicCartesianExample(const ros::NodeHandle& nh, bool plotting, bool rviz);
~BasicCartesianExample() override = default;
BasicCartesianExample(const BasicCartesianExample&) = default;
BasicCartesianExample& operator=(const BasicCartesianExample&) = default;
BasicCartesianExample(BasicCartesianExample&&) = default;
BasicCartesianExample& operator=(BasicCartesianExample&&) = default;
bool run() override;
private:
ros::NodeHandle nh_;
tesseract_environment::Command::Ptr addPointCloud();
};
} // namespace tesseract_ros_examples
#endif // TESSERACT_ROS_EXAMPLES_BASIC_CARTESIAN_EXAMPLE_H
| 32.419355 | 79 | 0.78209 |
e245c7c33e4aa5511df1e6a968928d5cfca3788f | 515 | h | C | src/comm/twi/twi.h | argarak/swams | e75c4f2dfc9db2226f3318108538dd08a4b68072 | [
"Apache-2.0"
] | 1 | 2021-03-29T17:01:07.000Z | 2021-03-29T17:01:07.000Z | src/comm/twi/twi.h | argarak/swams | e75c4f2dfc9db2226f3318108538dd08a4b68072 | [
"Apache-2.0"
] | 1 | 2018-07-20T12:40:17.000Z | 2018-07-20T12:40:17.000Z | src/comm/twi/twi.h | argarak/swams | e75c4f2dfc9db2226f3318108538dd08a4b68072 | [
"Apache-2.0"
] | null | null | null | #ifndef _H_TWI
#define _H_TWI
#include <stdlib.h>
#include <inttypes.h>
#include "../../macros.h"
#define TWI_NOT_COMPLETE ((TWCR & (1 << TWINT)) == 0)
#define SCL_PIN C,5
#define SDA_PIN C,4
/* Taken from TWI Arduino library. */
#ifndef TWI_BUFFER_LENGTH
#define TWI_BUFFER_LENGTH 32
#endif
namespace TWI {
extern volatile uint8_t writeAddress;
void Init();
void SetAddress(uint8_t address);
void Start();
void Stop();
void Write(uint8_t data);
uint8_t Read();
uint8_t Status();
}
#endif
| 15.147059 | 53 | 0.693204 |
6a14d428dba99b86ee5c0765c087c1105d8a2770 | 127 | h | C | platform/darwin/src/MGLTileSet_Private.h | mapzak/mapbox-gl-native-android-minimod | 83f1350747be9a60eb0275bd1a8dcb8e5f027abe | [
"BSL-1.0",
"Apache-2.0"
] | null | null | null | platform/darwin/src/MGLTileSet_Private.h | mapzak/mapbox-gl-native-android-minimod | 83f1350747be9a60eb0275bd1a8dcb8e5f027abe | [
"BSL-1.0",
"Apache-2.0"
] | null | null | null | platform/darwin/src/MGLTileSet_Private.h | mapzak/mapbox-gl-native-android-minimod | 83f1350747be9a60eb0275bd1a8dcb8e5f027abe | [
"BSL-1.0",
"Apache-2.0"
] | null | null | null | #import "MGLTileSet.h"
#include <mbgl/util/tileset.hpp>
@interface MGLTileSet (Private)
- (mbgl::Tileset)mbglTileset;
@end | 14.111111 | 32 | 0.732283 |
3a953068d4c598b113f965e4055dff8c51b1e608 | 41,884 | c | C | vcf/src/Graphics/art_svp_wind.c | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | 46 | 2015-12-04T17:12:58.000Z | 2022-03-11T04:30:49.000Z | vcf/src/Graphics/art_svp_wind.c | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | null | null | null | vcf/src/Graphics/art_svp_wind.c | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | 23 | 2016-10-24T09:18:14.000Z | 2022-02-25T02:11:35.000Z | /* Libart_LGPL - library of basic graphic primitives
* Copyright (C) 1998-2000 Raph Levien
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/* Primitive intersection and winding number operations on sorted
vector paths.
These routines are internal to libart, used to construct operations
like intersection, union, and difference. */
#include <stdio.h> /* for printf of debugging info */
#include <string.h> /* for memcpy */
#include <math.h>
#include "art_misc.h"
#include "art_rect.h"
#include "art_svp.h"
#include "art_svp_wind.h"
#define noVERBOSE
#define PT_EQ(p1,p2) ((p1).x == (p2).x && (p1).y == (p2).y)
#define PT_CLOSE(p1,p2) (fabs ((p1).x - (p2).x) < 1e-6 && fabs ((p1).y - (p2).y) < 1e-6)
/* return nonzero and set *p to the intersection point if the lines
z0-z1 and z2-z3 intersect each other. */
static int
intersect_lines (ArtPoint z0, ArtPoint z1, ArtPoint z2, ArtPoint z3,
ArtPoint *p)
{
double a01, b01, c01;
double a23, b23, c23;
double d0, d1, d2, d3;
double det;
/* if the vectors share an endpoint, they don't intersect */
if (PT_EQ (z0, z2) || PT_EQ (z0, z3) || PT_EQ (z1, z2) || PT_EQ (z1, z3))
return 0;
#if 0
if (PT_CLOSE (z0, z2) || PT_CLOSE (z0, z3) || PT_CLOSE (z1, z2) || PT_CLOSE (z1, z3))
return 0;
#endif
/* find line equations ax + by + c = 0 */
a01 = z0.y - z1.y;
b01 = z1.x - z0.x;
c01 = -(z0.x * a01 + z0.y * b01);
/* = -((z0.y - z1.y) * z0.x + (z1.x - z0.x) * z0.y)
= (z1.x * z0.y - z1.y * z0.x) */
d2 = a01 * z2.x + b01 * z2.y + c01;
d3 = a01 * z3.x + b01 * z3.y + c01;
if ((d2 > 0) == (d3 > 0))
return 0;
a23 = z2.y - z3.y;
b23 = z3.x - z2.x;
c23 = -(z2.x * a23 + z2.y * b23);
d0 = a23 * z0.x + b23 * z0.y + c23;
d1 = a23 * z1.x + b23 * z1.y + c23;
if ((d0 > 0) == (d1 > 0))
return 0;
/* now we definitely know that the lines intersect */
/* solve the two linear equations ax + by + c = 0 */
det = 1.0 / (a01 * b23 - a23 * b01);
p->x = det * (c23 * b01 - c01 * b23);
p->y = det * (c01 * a23 - c23 * a01);
return 1;
}
#define EPSILON 1e-6
static double
trap_epsilon (double v)
{
const double epsilon = EPSILON;
if (v < epsilon && v > -epsilon) return 0;
else return v;
}
/* Determine the order of line segments z0-z1 and z2-z3.
Return +1 if z2-z3 lies entirely to the right of z0-z1,
-1 if entirely to the left,
or 0 if overlap.
The case analysis in this function is quite ugly. The fact that it's
almost 200 lines long is ridiculous.
Ok, so here's the plan to cut it down:
First, do a bounding line comparison on the x coordinates. This is pretty
much the common case, and should go quickly. It also takes care of the
case where both lines are horizontal.
Then, do d0 and d1 computation, but only if a23 is nonzero.
Finally, do d2 and d3 computation, but only if a01 is nonzero.
Fall through to returning 0 (this will happen when both lines are
horizontal and they overlap).
*/
static int
x_order (ArtPoint z0, ArtPoint z1, ArtPoint z2, ArtPoint z3)
{
double a01, b01, c01;
double a23, b23, c23;
double d0, d1, d2, d3;
if (z0.y == z1.y)
{
if (z2.y == z3.y)
{
double x01min, x01max;
double x23min, x23max;
if (z0.x > z1.x)
{
x01min = z1.x;
x01max = z0.x;
}
else
{
x01min = z0.x;
x01max = z1.x;
}
if (z2.x > z3.x)
{
x23min = z3.x;
x23max = z2.x;
}
else
{
x23min = z2.x;
x23max = z3.x;
}
if (x23min >= x01max) return 1;
else if (x01min >= x23max) return -1;
else return 0;
}
else
{
/* z0-z1 is horizontal, z2-z3 isn't */
a23 = z2.y - z3.y;
b23 = z3.x - z2.x;
c23 = -(z2.x * a23 + z2.y * b23);
if (z3.y < z2.y)
{
a23 = -a23;
b23 = -b23;
c23 = -c23;
}
d0 = trap_epsilon (a23 * z0.x + b23 * z0.y + c23);
d1 = trap_epsilon (a23 * z1.x + b23 * z1.y + c23);
if (d0 > 0)
{
if (d1 >= 0) return 1;
else return 0;
}
else if (d0 == 0)
{
if (d1 > 0) return 1;
else if (d1 < 0) return -1;
else printf ("case 1 degenerate\n");
return 0;
}
else /* d0 < 0 */
{
if (d1 <= 0) return -1;
else return 0;
}
}
}
else if (z2.y == z3.y)
{
/* z2-z3 is horizontal, z0-z1 isn't */
a01 = z0.y - z1.y;
b01 = z1.x - z0.x;
c01 = -(z0.x * a01 + z0.y * b01);
/* = -((z0.y - z1.y) * z0.x + (z1.x - z0.x) * z0.y)
= (z1.x * z0.y - z1.y * z0.x) */
if (z1.y < z0.y)
{
a01 = -a01;
b01 = -b01;
c01 = -c01;
}
d2 = trap_epsilon (a01 * z2.x + b01 * z2.y + c01);
d3 = trap_epsilon (a01 * z3.x + b01 * z3.y + c01);
if (d2 > 0)
{
if (d3 >= 0) return -1;
else return 0;
}
else if (d2 == 0)
{
if (d3 > 0) return -1;
else if (d3 < 0) return 1;
else printf ("case 2 degenerate\n");
return 0;
}
else /* d2 < 0 */
{
if (d3 <= 0) return 1;
else return 0;
}
}
/* find line equations ax + by + c = 0 */
a01 = z0.y - z1.y;
b01 = z1.x - z0.x;
c01 = -(z0.x * a01 + z0.y * b01);
/* = -((z0.y - z1.y) * z0.x + (z1.x - z0.x) * z0.y)
= -(z1.x * z0.y - z1.y * z0.x) */
if (a01 > 0)
{
a01 = -a01;
b01 = -b01;
c01 = -c01;
}
/* so now, (a01, b01) points to the left, thus a01 * x + b01 * y + c01
is negative if the point lies to the right of the line */
d2 = trap_epsilon (a01 * z2.x + b01 * z2.y + c01);
d3 = trap_epsilon (a01 * z3.x + b01 * z3.y + c01);
if (d2 > 0)
{
if (d3 >= 0) return -1;
}
else if (d2 == 0)
{
if (d3 > 0) return -1;
else if (d3 < 0) return 1;
else
fprintf (stderr, "colinear!\n");
}
else /* d2 < 0 */
{
if (d3 <= 0) return 1;
}
a23 = z2.y - z3.y;
b23 = z3.x - z2.x;
c23 = -(z2.x * a23 + z2.y * b23);
if (a23 > 0)
{
a23 = -a23;
b23 = -b23;
c23 = -c23;
}
d0 = trap_epsilon (a23 * z0.x + b23 * z0.y + c23);
d1 = trap_epsilon (a23 * z1.x + b23 * z1.y + c23);
if (d0 > 0)
{
if (d1 >= 0) return 1;
}
else if (d0 == 0)
{
if (d1 > 0) return 1;
else if (d1 < 0) return -1;
else
fprintf (stderr, "colinear!\n");
}
else /* d0 < 0 */
{
if (d1 <= 0) return -1;
}
return 0;
}
/* similar to x_order, but to determine whether point z0 + epsilon lies to
the left of the line z2-z3 or to the right */
static int
x_order_2 (ArtPoint z0, ArtPoint z1, ArtPoint z2, ArtPoint z3)
{
double a23, b23, c23;
double d0, d1;
a23 = z2.y - z3.y;
b23 = z3.x - z2.x;
c23 = -(z2.x * a23 + z2.y * b23);
if (a23 > 0)
{
a23 = -a23;
b23 = -b23;
c23 = -c23;
}
d0 = a23 * z0.x + b23 * z0.y + c23;
if (d0 > EPSILON)
return -1;
else if (d0 < -EPSILON)
return 1;
d1 = a23 * z1.x + b23 * z1.y + c23;
if (d1 > EPSILON)
return -1;
else if (d1 < -EPSILON)
return 1;
if (z0.x <= z2.x && z1.x <= z2.x && z0.x <= z3.x && z1.x <= z3.x)
return -1;
if (z0.x >= z2.x && z1.x >= z2.x && z0.x >= z3.x && z1.x >= z3.x)
return 1;
fprintf (stderr, "x_order_2: colinear!\n");
return 0;
}
#ifdef DEAD_CODE
/* Traverse the vector path, keeping it in x-sorted order.
This routine doesn't actually do anything - it's just here for
explanatory purposes. */
void
traverse (ArtSVP *vp)
{
int *active_segs;
int n_active_segs;
int *cursor;
int seg_idx;
double y;
int tmp1, tmp2;
int asi;
int i, j;
active_segs = art_new (int, vp->n_segs);
cursor = art_new (int, vp->n_segs);
n_active_segs = 0;
seg_idx = 0;
y = vp->segs[0].points[0].y;
while (seg_idx < vp->n_segs || n_active_segs > 0)
{
printf ("y = %g\n", y);
/* delete segments ending at y from active list */
for (i = 0; i < n_active_segs; i++)
{
asi = active_segs[i];
if (vp->segs[asi].n_points - 1 == cursor[asi] &&
vp->segs[asi].points[cursor[asi]].y == y)
{
printf ("deleting %d\n", asi);
n_active_segs--;
for (j = i; j < n_active_segs; j++)
active_segs[j] = active_segs[j + 1];
i--;
}
}
/* insert new segments into the active list */
while (seg_idx < vp->n_segs && y == vp->segs[seg_idx].points[0].y)
{
cursor[seg_idx] = 0;
printf ("inserting %d\n", seg_idx);
for (i = 0; i < n_active_segs; i++)
{
asi = active_segs[i];
if (x_order (vp->segs[asi].points[cursor[asi]],
vp->segs[asi].points[cursor[asi] + 1],
vp->segs[seg_idx].points[0],
vp->segs[seg_idx].points[1]) == -1)
break;
}
tmp1 = seg_idx;
for (j = i; j < n_active_segs; j++)
{
tmp2 = active_segs[j];
active_segs[j] = tmp1;
tmp1 = tmp2;
}
active_segs[n_active_segs] = tmp1;
n_active_segs++;
seg_idx++;
}
/* all active segs cross the y scanline (considering segs to be
closed on top and open on bottom) */
for (i = 0; i < n_active_segs; i++)
{
asi = active_segs[i];
printf ("%d (%g, %g) - (%g, %g) %s\n", asi,
vp->segs[asi].points[cursor[asi]].x,
vp->segs[asi].points[cursor[asi]].y,
vp->segs[asi].points[cursor[asi] + 1].x,
vp->segs[asi].points[cursor[asi] + 1].y,
vp->segs[asi].dir ? "v" : "^");
}
/* advance y to the next event */
if (n_active_segs == 0)
{
if (seg_idx < vp->n_segs)
y = vp->segs[seg_idx].points[0].y;
/* else we're done */
}
else
{
asi = active_segs[0];
y = vp->segs[asi].points[cursor[asi] + 1].y;
for (i = 1; i < n_active_segs; i++)
{
asi = active_segs[i];
if (y > vp->segs[asi].points[cursor[asi] + 1].y)
y = vp->segs[asi].points[cursor[asi] + 1].y;
}
if (seg_idx < vp->n_segs && y > vp->segs[seg_idx].points[0].y)
y = vp->segs[seg_idx].points[0].y;
}
/* advance cursors to reach new y */
for (i = 0; i < n_active_segs; i++)
{
asi = active_segs[i];
while (cursor[asi] < vp->segs[asi].n_points - 1 &&
y >= vp->segs[asi].points[cursor[asi] + 1].y)
cursor[asi]++;
}
printf ("\n");
}
art_free (cursor);
art_free (active_segs);
}
#endif
/* I believe that the loop will always break with i=1.
I think I'll want to change this from a simple sorted list to a
modified stack. ips[*][0] will get its own data structure, and
ips[*] will in general only be allocated if there is an intersection.
Finally, the segment can be traced through the initial point
(formerly ips[*][0]), backwards through the stack, and finally
to cursor + 1.
This change should cut down on allocation bandwidth, and also
eliminate the iteration through n_ipl below.
*/
static void
insert_ip (int seg_i, int *n_ips, int *n_ips_max, ArtPoint **ips, ArtPoint ip)
{
int i;
ArtPoint tmp1, tmp2;
int n_ipl;
ArtPoint *ipl;
n_ipl = n_ips[seg_i]++;
if (n_ipl == n_ips_max[seg_i])
art_expand (ips[seg_i], ArtPoint, n_ips_max[seg_i]);
ipl = ips[seg_i];
for (i = 1; i < n_ipl; i++)
if (ipl[i].y > ip.y)
break;
tmp1 = ip;
for (; i <= n_ipl; i++)
{
tmp2 = ipl[i];
ipl[i] = tmp1;
tmp1 = tmp2;
}
}
/* test active segment (i - 1) against i for intersection, if
so, add intersection point to both ips lists. */
static void
intersect_neighbors (int i, int *active_segs,
int *n_ips, int *n_ips_max, ArtPoint **ips,
int *cursor, ArtSVP *vp)
{
ArtPoint z0, z1, z2, z3;
int asi01, asi23;
ArtPoint ip;
asi01 = active_segs[i - 1];
z0 = ips[asi01][0];
if (n_ips[asi01] == 1)
z1 = vp->segs[asi01].points[cursor[asi01] + 1];
else
z1 = ips[asi01][1];
asi23 = active_segs[i];
z2 = ips[asi23][0];
if (n_ips[asi23] == 1)
z3 = vp->segs[asi23].points[cursor[asi23] + 1];
else
z3 = ips[asi23][1];
if (intersect_lines (z0, z1, z2, z3, &ip))
{
#ifdef VERBOSE
printf ("new intersection point: (%g, %g)\n", ip.x, ip.y);
#endif
insert_ip (asi01, n_ips, n_ips_max, ips, ip);
insert_ip (asi23, n_ips, n_ips_max, ips, ip);
}
}
/* Add a new point to a segment in the svp.
Here, we also check to make sure that the segments satisfy nocross.
However, this is only valuable for debugging, and could possibly be
removed.
*/
static void
svp_add_point (ArtSVP *svp, int *n_points_max,
ArtPoint p, int *seg_map, int *active_segs, int n_active_segs,
int i)
{
int asi, asi_left, asi_right;
int n_points, n_points_left, n_points_right;
ArtSVPSeg *seg;
asi = seg_map[active_segs[i]];
seg = &svp->segs[asi];
n_points = seg->n_points;
/* find out whether neighboring segments share a point */
if (i > 0)
{
asi_left = seg_map[active_segs[i - 1]];
n_points_left = svp->segs[asi_left].n_points;
if (n_points_left > 1 &&
PT_EQ (svp->segs[asi_left].points[n_points_left - 2],
svp->segs[asi].points[n_points - 1]))
{
/* ok, new vector shares a top point with segment to the left -
now, check that it satisfies ordering invariant */
if (x_order (svp->segs[asi_left].points[n_points_left - 2],
svp->segs[asi_left].points[n_points_left - 1],
svp->segs[asi].points[n_points - 1],
p) < 1)
{
#ifdef VERBOSE
printf ("svp_add_point: cross on left!\n");
#endif
}
}
}
if (i + 1 < n_active_segs)
{
asi_right = seg_map[active_segs[i + 1]];
n_points_right = svp->segs[asi_right].n_points;
if (n_points_right > 1 &&
PT_EQ (svp->segs[asi_right].points[n_points_right - 2],
svp->segs[asi].points[n_points - 1]))
{
/* ok, new vector shares a top point with segment to the right -
now, check that it satisfies ordering invariant */
if (x_order (svp->segs[asi_right].points[n_points_right - 2],
svp->segs[asi_right].points[n_points_right - 1],
svp->segs[asi].points[n_points - 1],
p) > -1)
{
#ifdef VERBOSE
printf ("svp_add_point: cross on right!\n");
#endif
}
}
}
if (n_points_max[asi] == n_points)
art_expand (seg->points, ArtPoint, n_points_max[asi]);
seg->points[n_points] = p;
if (p.x < seg->bbox.x0)
seg->bbox.x0 = p.x;
else if (p.x > seg->bbox.x1)
seg->bbox.x1 = p.x;
seg->bbox.y1 = p.y;
seg->n_points++;
}
#if 0
/* find where the segment (currently at i) is supposed to go, and return
the target index - if equal to i, then there is no crossing problem.
"Where it is supposed to go" is defined as following:
Delete element i, re-insert at position target (bumping everything
target and greater to the right).
*/
static int
find_crossing (int i, int *active_segs, int n_active_segs,
int *cursor, ArtPoint **ips, int *n_ips, ArtSVP *vp)
{
int asi, asi_left, asi_right;
ArtPoint p0, p1;
ArtPoint p0l, p1l;
ArtPoint p0r, p1r;
int target;
asi = active_segs[i];
p0 = ips[asi][0];
if (n_ips[asi] == 1)
p1 = vp->segs[asi].points[cursor[asi] + 1];
else
p1 = ips[asi][1];
for (target = i; target > 0; target--)
{
asi_left = active_segs[target - 1];
p0l = ips[asi_left][0];
if (n_ips[asi_left] == 1)
p1l = vp->segs[asi_left].points[cursor[asi_left] + 1];
else
p1l = ips[asi_left][1];
if (!PT_EQ (p0, p0l))
break;
#ifdef VERBOSE
printf ("point matches on left (%g, %g) - (%g, %g) x (%g, %g) - (%g, %g)!\n",
p0l.x, p0l.y, p1l.x, p1l.y, p0.x, p0.y, p1.x, p1.y);
#endif
if (x_order (p0l, p1l, p0, p1) == 1)
break;
#ifdef VERBOSE
printf ("scanning to the left (i=%d, target=%d)\n", i, target);
#endif
}
if (target < i) return target;
for (; target < n_active_segs - 1; target++)
{
asi_right = active_segs[target + 1];
p0r = ips[asi_right][0];
if (n_ips[asi_right] == 1)
p1r = vp->segs[asi_right].points[cursor[asi_right] + 1];
else
p1r = ips[asi_right][1];
if (!PT_EQ (p0, p0r))
break;
#ifdef VERBOSE
printf ("point matches on left (%g, %g) - (%g, %g) x (%g, %g) - (%g, %g)!\n",
p0.x, p0.y, p1.x, p1.y, p0r.x, p0r.y, p1r.x, p1r.y);
#endif
if (x_order (p0r, p1r, p0, p1) == 1)
break;
#ifdef VERBOSE
printf ("scanning to the right (i=%d, target=%d)\n", i, target);
#endif
}
return target;
}
#endif
/* This routine handles the case where the segment changes its position
in the active segment list. Generally, this will happen when the
segment (defined by i and cursor) shares a top point with a neighbor,
but breaks the ordering invariant.
Essentially, this routine sorts the lines [start..end), all of which
share a top point. This is implemented as your basic insertion sort.
This routine takes care of intersecting the appropriate neighbors,
as well.
A first argument of -1 immediately returns, which helps reduce special
casing in the main unwind routine.
*/
static void
fix_crossing (int start, int end, int *active_segs, int n_active_segs,
int *cursor, ArtPoint **ips, int *n_ips, int *n_ips_max,
ArtSVP *vp, int *seg_map,
ArtSVP **p_new_vp, int *pn_segs_max,
int **pn_points_max)
{
int i, j;
int target;
int asi, asj;
ArtPoint p0i, p1i;
ArtPoint p0j, p1j;
int swap = 0;
#ifdef VERBOSE
int k;
#endif
ArtPoint *pts;
#ifdef VERBOSE
printf ("fix_crossing: [%d..%d)", start, end);
for (k = 0; k < n_active_segs; k++)
printf (" %d", active_segs[k]);
printf ("\n");
#endif
if (start == -1)
return;
for (i = start + 1; i < end; i++)
{
asi = active_segs[i];
if (cursor[asi] < vp->segs[asi].n_points - 1) {
p0i = ips[asi][0];
if (n_ips[asi] == 1)
p1i = vp->segs[asi].points[cursor[asi] + 1];
else
p1i = ips[asi][1];
for (j = i - 1; j >= start; j--)
{
asj = active_segs[j];
if (cursor[asj] < vp->segs[asj].n_points - 1)
{
p0j = ips[asj][0];
if (n_ips[asj] == 1)
p1j = vp->segs[asj].points[cursor[asj] + 1];
else
p1j = ips[asj][1];
/* we _hope_ p0i = p0j */
if (x_order_2 (p0j, p1j, p0i, p1i) == -1)
break;
}
}
target = j + 1;
/* target is where active_seg[i] _should_ be in active_segs */
if (target != i)
{
swap = 1;
#ifdef VERBOSE
printf ("fix_crossing: at %i should be %i\n", i, target);
#endif
/* let's close off all relevant segments */
for (j = i; j >= target; j--)
{
asi = active_segs[j];
/* First conjunct: this isn't the last point in the original
segment.
Second conjunct: this isn't the first point in the new
segment (i.e. already broken).
*/
if (cursor[asi] < vp->segs[asi].n_points - 1 &&
(*p_new_vp)->segs[seg_map[asi]].n_points != 1)
{
int seg_num;
/* so break here */
#ifdef VERBOSE
printf ("closing off %d\n", j);
#endif
pts = art_new (ArtPoint, 16);
pts[0] = ips[asi][0];
seg_num = art_svp_add_segment (p_new_vp, pn_segs_max,
pn_points_max,
1, vp->segs[asi].dir,
pts,
NULL);
(*pn_points_max)[seg_num] = 16;
seg_map[asi] = seg_num;
}
}
/* now fix the ordering in active_segs */
asi = active_segs[i];
for (j = i; j > target; j--)
active_segs[j] = active_segs[j - 1];
active_segs[j] = asi;
}
}
}
if (swap && start > 0)
{
int as_start;
as_start = active_segs[start];
if (cursor[as_start] < vp->segs[as_start].n_points)
{
#ifdef VERBOSE
printf ("checking intersection of %d, %d\n", start - 1, start);
#endif
intersect_neighbors (start, active_segs,
n_ips, n_ips_max, ips,
cursor, vp);
}
}
if (swap && end < n_active_segs)
{
int as_end;
as_end = active_segs[end - 1];
if (cursor[as_end] < vp->segs[as_end].n_points)
{
#ifdef VERBOSE
printf ("checking intersection of %d, %d\n", end - 1, end);
#endif
intersect_neighbors (end, active_segs,
n_ips, n_ips_max, ips,
cursor, vp);
}
}
if (swap)
{
#ifdef VERBOSE
printf ("fix_crossing return: [%d..%d)", start, end);
for (k = 0; k < n_active_segs; k++)
printf (" %d", active_segs[k]);
printf ("\n");
#endif
}
}
/* Return a new sorted vector that covers the same area as the
argument, but which satisfies the nocross invariant.
Basically, this routine works by finding the intersection points,
and cutting the segments at those points.
Status of this routine:
Basic correctness: Seems ok.
Numerical stability: known problems in the case of points falling
on lines, and colinear lines. For actual use, randomly perturbing
the vertices is currently recommended.
Speed: pretty good, although a more efficient priority queue, as
well as bbox culling of potential intersections, are two
optimizations that could help.
Precision: pretty good, although the numerical stability problems
make this routine unsuitable for precise calculations of
differences.
*/
/* Here is a more detailed description of the algorithm. It follows
roughly the structure of traverse (above), but is obviously quite
a bit more complex.
Here are a few important data structures:
A new sorted vector path (new_svp).
For each (active) segment in the original, a list of intersection
points.
Of course, the original being traversed.
The following invariants hold (in addition to the invariants
of the traverse procedure).
The new sorted vector path lies entirely above the y scan line.
The new sorted vector path keeps the nocross invariant.
For each active segment, the y scan line crosses the line from the
first to the second of the intersection points (where the second
point is cursor + 1 if there is only one intersection point).
The list of intersection points + the (cursor + 1) point is kept
in nondecreasing y order.
Of the active segments, none of the lines from first to second
intersection point cross the 1st ip..2nd ip line of the left or
right neighbor. (However, such a line may cross further
intersection points of the neighbors, or segments past the
immediate neighbors).
Of the active segments, all lines from 1st ip..2nd ip are in
strictly increasing x_order (this is very similar to the invariant
of the traverse procedure, but is explicitly stated here in terms
of ips). (this basically says that nocross holds on the active
segments)
The combination of the new sorted vector path, the path through all
the intersection points to cursor + 1, and [cursor + 1, n_points)
covers the same area as the argument.
Another important data structure is mapping from original segment
number to new segment number.
The algorithm is perhaps best understood as advancing the cursors
while maintaining these invariants. Here's roughly how it's done.
When deleting segments from the active list, those segments are added
to the new sorted vector path. In addition, the neighbors may intersect
each other, so they are intersection tested (see below).
When inserting new segments, they are intersection tested against
their neighbors. The top point of the segment becomes the first
intersection point.
Advancing the cursor is just a bit different from the traverse
routine, as the cursor may advance through the intersection points
as well. Only when there is a single intersection point in the list
does the cursor advance in the original segment. In either case,
the new vector is intersection tested against both neighbors. It
also causes the vector over which the cursor is advancing to be
added to the new svp.
Two steps need further clarification:
Intersection testing: the 1st ip..2nd ip lines of the neighbors
are tested to see if they cross (using intersect_lines). If so,
then the intersection point is added to the ip list of both
segments, maintaining the invariant that the list of intersection
points is nondecreasing in y).
Adding vector to new svp: if the new vector shares a top x
coordinate with another vector, then it is checked to see whether
it is in order. If not, then both segments are "broken," and then
restarted. Note: in the case when both segments are in the same
order, they may simply be swapped without breaking.
For the time being, I'm going to put some of these operations into
subroutines. If it turns out to be a performance problem, I could
try to reorganize the traverse procedure so that each is only
called once, and inline them. But if it's not a performance
problem, I'll just keep it this way, because it will probably help
to make the code clearer, and I believe this code could use all the
clarity it can get. */
/**
* art_svp_uncross: Resolve self-intersections of an svp.
* @vp: The original svp.
*
* Finds all the intersections within @vp, and constructs a new svp
* with new points added at these intersections.
*
* This routine needs to be redone from scratch with numerical robustness
* in mind. I'm working on it.
*
* Return value: The new svp.
**/
ArtSVP *
art_svp_uncross (ArtSVP *vp)
{
int *active_segs;
int n_active_segs;
int *cursor;
int seg_idx;
double y;
int tmp1, tmp2;
int asi;
int i, j;
/* new data structures */
/* intersection points; invariant: *ips[i] is only allocated if
i is active */
int *n_ips, *n_ips_max;
ArtPoint **ips;
/* new sorted vector path */
int n_segs_max, seg_num;
ArtSVP *new_vp;
int *n_points_max;
/* mapping from argument to new segment numbers - again, only valid
if active */
int *seg_map;
double y_curs;
ArtPoint p_curs;
int first_share;
double share_x;
ArtPoint *pts;
n_segs_max = 16;
new_vp = (ArtSVP *)art_alloc (sizeof(ArtSVP) +
(n_segs_max - 1) * sizeof(ArtSVPSeg));
new_vp->n_segs = 0;
if (vp->n_segs == 0)
return new_vp;
active_segs = art_new (int, vp->n_segs);
cursor = art_new (int, vp->n_segs);
seg_map = art_new (int, vp->n_segs);
n_ips = art_new (int, vp->n_segs);
n_ips_max = art_new (int, vp->n_segs);
ips = art_new (ArtPoint *, vp->n_segs);
n_points_max = art_new (int, n_segs_max);
n_active_segs = 0;
seg_idx = 0;
y = vp->segs[0].points[0].y;
while (seg_idx < vp->n_segs || n_active_segs > 0)
{
#ifdef VERBOSE
printf ("y = %g\n", y);
#endif
/* maybe move deletions to end of loop (to avoid so much special
casing on the end of a segment)? */
/* delete segments ending at y from active list */
for (i = 0; i < n_active_segs; i++)
{
asi = active_segs[i];
if (vp->segs[asi].n_points - 1 == cursor[asi] &&
vp->segs[asi].points[cursor[asi]].y == y)
{
do
{
#ifdef VERBOSE
printf ("deleting %d\n", asi);
#endif
art_free (ips[asi]);
n_active_segs--;
for (j = i; j < n_active_segs; j++)
active_segs[j] = active_segs[j + 1];
if (i < n_active_segs)
asi = active_segs[i];
else
break;
}
while (vp->segs[asi].n_points - 1 == cursor[asi] &&
vp->segs[asi].points[cursor[asi]].y == y);
/* test intersection of neighbors */
if (i > 0 && i < n_active_segs)
intersect_neighbors (i, active_segs,
n_ips, n_ips_max, ips,
cursor, vp);
i--;
}
}
/* insert new segments into the active list */
while (seg_idx < vp->n_segs && y == vp->segs[seg_idx].points[0].y)
{
#ifdef VERBOSE
printf ("inserting %d\n", seg_idx);
#endif
cursor[seg_idx] = 0;
for (i = 0; i < n_active_segs; i++)
{
asi = active_segs[i];
if (x_order_2 (vp->segs[seg_idx].points[0],
vp->segs[seg_idx].points[1],
vp->segs[asi].points[cursor[asi]],
vp->segs[asi].points[cursor[asi] + 1]) == -1)
break;
}
/* Create and initialize the intersection points data structure */
n_ips[seg_idx] = 1;
n_ips_max[seg_idx] = 2;
ips[seg_idx] = art_new (ArtPoint, n_ips_max[seg_idx]);
ips[seg_idx][0] = vp->segs[seg_idx].points[0];
/* Start a new segment in the new vector path */
pts = art_new (ArtPoint, 16);
pts[0] = vp->segs[seg_idx].points[0];
seg_num = art_svp_add_segment (&new_vp, &n_segs_max,
&n_points_max,
1, vp->segs[seg_idx].dir,
pts,
NULL);
n_points_max[seg_num] = 16;
seg_map[seg_idx] = seg_num;
tmp1 = seg_idx;
for (j = i; j < n_active_segs; j++)
{
tmp2 = active_segs[j];
active_segs[j] = tmp1;
tmp1 = tmp2;
}
active_segs[n_active_segs] = tmp1;
n_active_segs++;
if (i > 0)
intersect_neighbors (i, active_segs,
n_ips, n_ips_max, ips,
cursor, vp);
if (i + 1 < n_active_segs)
intersect_neighbors (i + 1, active_segs,
n_ips, n_ips_max, ips,
cursor, vp);
seg_idx++;
}
/* all active segs cross the y scanline (considering segs to be
closed on top and open on bottom) */
#ifdef VERBOSE
for (i = 0; i < n_active_segs; i++)
{
asi = active_segs[i];
printf ("%d ", asi);
for (j = 0; j < n_ips[asi]; j++)
printf ("(%g, %g) - ",
ips[asi][j].x,
ips[asi][j].y);
printf ("(%g, %g) %s\n",
vp->segs[asi].points[cursor[asi] + 1].x,
vp->segs[asi].points[cursor[asi] + 1].y,
vp->segs[asi].dir ? "v" : "^");
}
#endif
/* advance y to the next event
Note: this is quadratic. We'd probably get decent constant
factor speed improvement by caching the y_curs values. */
if (n_active_segs == 0)
{
if (seg_idx < vp->n_segs)
y = vp->segs[seg_idx].points[0].y;
/* else we're done */
}
else
{
asi = active_segs[0];
if (n_ips[asi] == 1)
y = vp->segs[asi].points[cursor[asi] + 1].y;
else
y = ips[asi][1].y;
for (i = 1; i < n_active_segs; i++)
{
asi = active_segs[i];
if (n_ips[asi] == 1)
y_curs = vp->segs[asi].points[cursor[asi] + 1].y;
else
y_curs = ips[asi][1].y;
if (y > y_curs)
y = y_curs;
}
if (seg_idx < vp->n_segs && y > vp->segs[seg_idx].points[0].y)
y = vp->segs[seg_idx].points[0].y;
}
first_share = -1;
share_x = 0; /* to avoid gcc warning, although share_x is never
used when first_share is -1 */
/* advance cursors to reach new y */
for (i = 0; i < n_active_segs; i++)
{
asi = active_segs[i];
if (n_ips[asi] == 1)
p_curs = vp->segs[asi].points[cursor[asi] + 1];
else
p_curs = ips[asi][1];
if (p_curs.y == y)
{
svp_add_point (new_vp, n_points_max,
p_curs, seg_map, active_segs, n_active_segs, i);
n_ips[asi]--;
for (j = 0; j < n_ips[asi]; j++)
ips[asi][j] = ips[asi][j + 1];
if (n_ips[asi] == 0)
{
ips[asi][0] = p_curs;
n_ips[asi] = 1;
cursor[asi]++;
}
if (first_share < 0 || p_curs.x != share_x)
{
/* this is where crossings are detected, and if
found, the active segments switched around. */
fix_crossing (first_share, i,
active_segs, n_active_segs,
cursor, ips, n_ips, n_ips_max, vp, seg_map,
&new_vp,
&n_segs_max, &n_points_max);
first_share = i;
share_x = p_curs.x;
}
if (cursor[asi] < vp->segs[asi].n_points - 1)
{
if (i > 0)
intersect_neighbors (i, active_segs,
n_ips, n_ips_max, ips,
cursor, vp);
if (i + 1 < n_active_segs)
intersect_neighbors (i + 1, active_segs,
n_ips, n_ips_max, ips,
cursor, vp);
}
}
else
{
/* not on a cursor point */
fix_crossing (first_share, i,
active_segs, n_active_segs,
cursor, ips, n_ips, n_ips_max, vp, seg_map,
&new_vp,
&n_segs_max, &n_points_max);
first_share = -1;
}
}
/* fix crossing on last shared group */
fix_crossing (first_share, i,
active_segs, n_active_segs,
cursor, ips, n_ips, n_ips_max, vp, seg_map,
&new_vp,
&n_segs_max, &n_points_max);
#ifdef VERBOSE
printf ("\n");
#endif
}
/* not necessary to sort, new segments only get added at y, which
increases monotonically */
#if 0
qsort (&new_vp->segs, new_vp->n_segs, sizeof (svp_seg), svp_seg_compare);
{
int k;
for (k = 0; k < new_vp->n_segs - 1; k++)
{
printf ("(%g, %g) - (%g, %g) %s (%g, %g) - (%g, %g)\n",
new_vp->segs[k].points[0].x,
new_vp->segs[k].points[0].y,
new_vp->segs[k].points[1].x,
new_vp->segs[k].points[1].y,
svp_seg_compare (&new_vp->segs[k], &new_vp->segs[k + 1]) > 1 ? ">": "<",
new_vp->segs[k + 1].points[0].x,
new_vp->segs[k + 1].points[0].y,
new_vp->segs[k + 1].points[1].x,
new_vp->segs[k + 1].points[1].y);
}
}
#endif
art_free (n_points_max);
art_free (seg_map);
art_free (n_ips_max);
art_free (n_ips);
art_free (ips);
art_free (cursor);
art_free (active_segs);
return new_vp;
}
#define noVERBOSE
/* Rewind a svp satisfying the nocross invariant.
The winding number of a segment is defined as the winding number of
the points to the left while travelling in the direction of the
segment. Therefore it preincrements and postdecrements as a scan
line is traversed from left to right.
Status of this routine:
Basic correctness: Was ok in gfonted. However, this code does not
yet compute bboxes for the resulting svp segs.
Numerical stability: known problems in the case of horizontal
segments in polygons with any complexity. For actual use, randomly
perturbing the vertices is recommended.
Speed: good.
Precision: good, except that no attempt is made to remove "hair".
Doing random perturbation just makes matters worse.
*/
/**
* art_svp_rewind_uncrossed: Rewind an svp satisfying the nocross invariant.
* @vp: The original svp.
* @rule: The winding rule.
*
* Creates a new svp with winding number of 0 or 1 everywhere. The @rule
* argument specifies a rule for how winding numbers in the original
* @vp map to the winding numbers in the result.
*
* With @rule == ART_WIND_RULE_NONZERO, the resulting svp has a
* winding number of 1 where @vp has a nonzero winding number.
*
* With @rule == ART_WIND_RULE_INTERSECT, the resulting svp has a
* winding number of 1 where @vp has a winding number greater than
* 1. It is useful for computing intersections.
*
* With @rule == ART_WIND_RULE_ODDEVEN, the resulting svp has a
* winding number of 1 where @vp has an odd winding number. It is
* useful for implementing the even-odd winding rule of the
* PostScript imaging model.
*
* With @rule == ART_WIND_RULE_POSITIVE, the resulting svp has a
* winding number of 1 where @vp has a positive winding number. It is
* usefull for implementing asymmetric difference.
*
* This routine needs to be redone from scratch with numerical robustness
* in mind. I'm working on it.
*
* Return value: The new svp.
**/
ArtSVP *
art_svp_rewind_uncrossed (ArtSVP *vp, ArtWindRule rule)
{
int *active_segs;
int n_active_segs;
int *cursor;
int seg_idx;
double y;
int tmp1, tmp2;
int asi;
int i, j;
ArtSVP *new_vp;
int n_segs_max;
int *winding;
int left_wind;
int wind;
int keep, invert;
#ifdef VERBOSE
print_svp (vp);
#endif
n_segs_max = 16;
new_vp = (ArtSVP *)art_alloc (sizeof(ArtSVP) +
(n_segs_max - 1) * sizeof(ArtSVPSeg));
new_vp->n_segs = 0;
if (vp->n_segs == 0)
return new_vp;
winding = art_new (int, vp->n_segs);
active_segs = art_new (int, vp->n_segs);
cursor = art_new (int, vp->n_segs);
n_active_segs = 0;
seg_idx = 0;
y = vp->segs[0].points[0].y;
while (seg_idx < vp->n_segs || n_active_segs > 0)
{
#ifdef VERBOSE
printf ("y = %g\n", y);
#endif
/* delete segments ending at y from active list */
for (i = 0; i < n_active_segs; i++)
{
asi = active_segs[i];
if (vp->segs[asi].n_points - 1 == cursor[asi] &&
vp->segs[asi].points[cursor[asi]].y == y)
{
#ifdef VERBOSE
printf ("deleting %d\n", asi);
#endif
n_active_segs--;
for (j = i; j < n_active_segs; j++)
active_segs[j] = active_segs[j + 1];
i--;
}
}
/* insert new segments into the active list */
while (seg_idx < vp->n_segs && y == vp->segs[seg_idx].points[0].y)
{
#ifdef VERBOSE
printf ("inserting %d\n", seg_idx);
#endif
cursor[seg_idx] = 0;
for (i = 0; i < n_active_segs; i++)
{
asi = active_segs[i];
if (x_order_2 (vp->segs[seg_idx].points[0],
vp->segs[seg_idx].points[1],
vp->segs[asi].points[cursor[asi]],
vp->segs[asi].points[cursor[asi] + 1]) == -1)
break;
}
/* Determine winding number for this segment */
if (i == 0)
left_wind = 0;
else if (vp->segs[active_segs[i - 1]].dir)
left_wind = winding[active_segs[i - 1]];
else
left_wind = winding[active_segs[i - 1]] - 1;
if (vp->segs[seg_idx].dir)
wind = left_wind + 1;
else
wind = left_wind;
winding[seg_idx] = wind;
switch (rule)
{
case ART_WIND_RULE_NONZERO:
keep = (wind == 1 || wind == 0);
invert = (wind == 0);
break;
case ART_WIND_RULE_INTERSECT:
keep = (wind == 2);
invert = 0;
break;
case ART_WIND_RULE_ODDEVEN:
keep = 1;
invert = !(wind & 1);
break;
case ART_WIND_RULE_POSITIVE:
keep = (wind == 1);
invert = 0;
break;
default:
keep = 0;
invert = 0;
break;
}
if (keep)
{
ArtPoint *points, *new_points;
int n_points;
int new_dir;
#ifdef VERBOSE
printf ("keeping segment %d\n", seg_idx);
#endif
n_points = vp->segs[seg_idx].n_points;
points = vp->segs[seg_idx].points;
new_points = art_new (ArtPoint, n_points);
memcpy (new_points, points, n_points * sizeof (ArtPoint));
new_dir = vp->segs[seg_idx].dir ^ invert;
art_svp_add_segment (&new_vp, &n_segs_max,
NULL,
n_points, new_dir, new_points,
&vp->segs[seg_idx].bbox);
}
tmp1 = seg_idx;
for (j = i; j < n_active_segs; j++)
{
tmp2 = active_segs[j];
active_segs[j] = tmp1;
tmp1 = tmp2;
}
active_segs[n_active_segs] = tmp1;
n_active_segs++;
seg_idx++;
}
#ifdef VERBOSE
/* all active segs cross the y scanline (considering segs to be
closed on top and open on bottom) */
for (i = 0; i < n_active_segs; i++)
{
asi = active_segs[i];
printf ("%d:%d (%g, %g) - (%g, %g) %s %d\n", asi,
cursor[asi],
vp->segs[asi].points[cursor[asi]].x,
vp->segs[asi].points[cursor[asi]].y,
vp->segs[asi].points[cursor[asi] + 1].x,
vp->segs[asi].points[cursor[asi] + 1].y,
vp->segs[asi].dir ? "v" : "^",
winding[asi]);
}
#endif
/* advance y to the next event */
if (n_active_segs == 0)
{
if (seg_idx < vp->n_segs)
y = vp->segs[seg_idx].points[0].y;
/* else we're done */
}
else
{
asi = active_segs[0];
y = vp->segs[asi].points[cursor[asi] + 1].y;
for (i = 1; i < n_active_segs; i++)
{
asi = active_segs[i];
if (y > vp->segs[asi].points[cursor[asi] + 1].y)
y = vp->segs[asi].points[cursor[asi] + 1].y;
}
if (seg_idx < vp->n_segs && y > vp->segs[seg_idx].points[0].y)
y = vp->segs[seg_idx].points[0].y;
}
/* advance cursors to reach new y */
for (i = 0; i < n_active_segs; i++)
{
asi = active_segs[i];
while (cursor[asi] < vp->segs[asi].n_points - 1 &&
y >= vp->segs[asi].points[cursor[asi] + 1].y)
cursor[asi]++;
}
#ifdef VERBOSE
printf ("\n");
#endif
}
art_free (cursor);
art_free (active_segs);
art_free (winding);
return new_vp;
}
| 27.215075 | 89 | 0.577022 |
3ab0d8a4da164b327c8b465e687e7498f09e4841 | 1,044 | h | C | resources/Wireshark/WiresharkDissectorFoo/ui/ssl_key_export.h | joshis1/C_Programming | 4a8003321251448a167bfca0b595c5eeab88608d | [
"MIT"
] | 2 | 2020-09-11T05:51:42.000Z | 2020-12-31T11:42:02.000Z | resources/Wireshark/WiresharkDissectorFoo/ui/ssl_key_export.h | joshis1/C_Programming | 4a8003321251448a167bfca0b595c5eeab88608d | [
"MIT"
] | null | null | null | resources/Wireshark/WiresharkDissectorFoo/ui/ssl_key_export.h | joshis1/C_Programming | 4a8003321251448a167bfca0b595c5eeab88608d | [
"MIT"
] | null | null | null | /* export_sslkeys.h
*
* SSL session key utilities. Copied from ui/gkt/export_sslkeys.c
* by Sake Blok <sake@euronet.nl> (20110526)
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __SSL_KEY_EXPORT_H__
#define __SSL_KEY_EXPORT_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/** Return the number of available SSL session keys.
*
* @return The number of available SSL session keys.
*/
extern int ssl_session_key_count(void);
/** Dump our SSL Session Keys to a string
*
* @return A string containing all the SSL Session Keys. Must be freed with
* g_free().
*/
extern gchar* ssl_export_sessions(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __SSL_KEY_EXPORT_H__ */
/*
* Editor modelines
*
* Local Variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
| 20.470588 | 75 | 0.708812 |
3874be17ca8ac1240bae3a301c1f0c2173cded71 | 1,271 | h | C | apps/generated_areas/include/mc_check_checkresult_list.h | georgeslabreche/ccsdsmo-malc | c22389af78ddc8ceddcbb262afcb213ef50226ff | [
"MIT"
] | null | null | null | apps/generated_areas/include/mc_check_checkresult_list.h | georgeslabreche/ccsdsmo-malc | c22389af78ddc8ceddcbb262afcb213ef50226ff | [
"MIT"
] | 65 | 2021-08-30T23:10:05.000Z | 2022-03-27T19:50:33.000Z | apps/generated_areas/include/mc_check_checkresult_list.h | tanagraspace/ccsdsmo-malc-sepp-apps | f616b3e06522ea995e12904161ce3d298e96f6ff | [
"MIT"
] | null | null | null | #ifndef __MC_CHECK_CHECKRESULT_LIST_H_INCLUDED__
#define __MC_CHECK_CHECKRESULT_LIST_H_INCLUDED__
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
// default constructor
mc_check_checkresult_list_t * mc_check_checkresult_list_new(unsigned int element_count);
// destructor, free the list, its content and its elements
void mc_check_checkresult_list_destroy(mc_check_checkresult_list_t ** self_p);
// fields accessors for composite list mc_check_checkresult_list
unsigned int mc_check_checkresult_list_get_element_count(mc_check_checkresult_list_t * self);
mc_check_checkresult_t ** mc_check_checkresult_list_get_content(mc_check_checkresult_list_t * self);
// encoding functions related to transport malbinary
int mc_check_checkresult_list_add_encoding_length_malbinary(mc_check_checkresult_list_t * self, mal_encoder_t * encoder, void * cursor);
int mc_check_checkresult_list_encode_malbinary(mc_check_checkresult_list_t * self, mal_encoder_t * encoder, void * cursor);
int mc_check_checkresult_list_decode_malbinary(mc_check_checkresult_list_t * self, mal_decoder_t * decoder, void * cursor);
// test function
void mc_check_checkresult_list_test(bool verbose);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // __MC_CHECK_CHECKRESULT_LIST_H_INCLUDED__
| 39.71875 | 136 | 0.852872 |
cded9b70e10752eb162f34ad5329da785f57ae35 | 2,870 | h | C | Inc/main.h | Phillweston/Drone_Master_PID | 7a3decc0337f144ab54feddff3f17064f3291ea9 | [
"BSD-3-Clause"
] | 1 | 2021-08-03T11:02:08.000Z | 2021-08-03T11:02:08.000Z | Inc/main.h | Phillweston/Drone_Master_PID | 7a3decc0337f144ab54feddff3f17064f3291ea9 | [
"BSD-3-Clause"
] | null | null | null | Inc/main.h | Phillweston/Drone_Master_PID | 7a3decc0337f144ab54feddff3f17064f3291ea9 | [
"BSD-3-Clause"
] | 2 | 2020-11-01T06:29:34.000Z | 2022-03-28T04:33:13.000Z | /* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.h
* @brief : Header for main.c file.
* This file contains the common defines of the application.
******************************************************************************
* @attention
*
* <h2><center>© Copyright (c) 2020 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32g0xx_hal.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */
/* USER CODE END ET */
/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */
/* USER CODE END EC */
/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */
/* USER CODE END EM */
/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */
/* Private defines -----------------------------------------------------------*/
#define TX_Pin GPIO_PIN_2
#define TX_GPIO_Port GPIOA
#define RX_Pin GPIO_PIN_3
#define RX_GPIO_Port GPIOA
#define START_Pin GPIO_PIN_4
#define START_GPIO_Port GPIOA
#define M4_Pin GPIO_PIN_8
#define M4_GPIO_Port GPIOA
#define L4_Pin GPIO_PIN_9
#define L4_GPIO_Port GPIOA
#define L3_Pin GPIO_PIN_6
#define L3_GPIO_Port GPIOC
#define M3_Pin GPIO_PIN_11
#define M3_GPIO_Port GPIOA
#define SWCLK_Pin GPIO_PIN_14
#define SWCLK_GPIO_Port GPIOA
#define M2_Pin GPIO_PIN_3
#define M2_GPIO_Port GPIOB
#define L2_Pin GPIO_PIN_4
#define L2_GPIO_Port GPIOB
#define L1_Pin GPIO_PIN_5
#define L1_GPIO_Port GPIOB
#define M1_Pin GPIO_PIN_6
#define M1_GPIO_Port GPIOB
#define SDA_Pin GPIO_PIN_7
#define SDA_GPIO_Port GPIOB
#define SCL_Pin GPIO_PIN_8
#define SCL_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */
/* USER CODE END Private defines */
#ifdef __cplusplus
}
#endif
#endif /* __MAIN_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
| 28.7 | 80 | 0.535889 |
35bf832172728a0669da3f6056489bc94e8404f2 | 280 | h | C | src/HAL/include/e6a2.h | QIU1995NONAME/Q20161106_Project0 | f321c52496996e94bc8bd52805721e922da4151c | [
"MIT"
] | 4 | 2016-11-11T04:47:05.000Z | 2019-01-23T14:14:00.000Z | src/HAL/include/e6a2.h | QIU1995NONAME/Q20161106_Project0 | f321c52496996e94bc8bd52805721e922da4151c | [
"MIT"
] | null | null | null | src/HAL/include/e6a2.h | QIU1995NONAME/Q20161106_Project0 | f321c52496996e94bc8bd52805721e922da4151c | [
"MIT"
] | null | null | null | #ifndef __E6A2_H__
#define __E6A2_H__
#include "stm32f10x.h"
namespace QIU {
namespace PJ0 {
/**
* 只有中断可以赋予这个变量0以外的值
*/
extern s32 e6a2_var;
/**
* 编码器E6A2计数清零
*/
extern void e6a2_reset(void);
/**
* 读取编码器E6A2当前的计数值
*/
extern s32 e6a2_read(void);
}
}
#endif // __E6A2_H__
| 11.2 | 29 | 0.692857 |
b4e11cf26881706e7efd15fd8413a995208f622f | 1,754 | h | C | SynpaySDK-iOS/SynpaySDK.framework/Headers/SynpaySDK.h | SYNSoftWareDept/SynpaySDK-iOS | bdfa088048a74e973951c60cf05afc3773ed5315 | [
"MIT"
] | 2 | 2021-11-20T16:56:46.000Z | 2021-12-02T06:09:11.000Z | SynpaySDK-iOS/SynpaySDK.framework/Headers/SynpaySDK.h | SYNSoftWareDept/SynpaySDK-iOS | bdfa088048a74e973951c60cf05afc3773ed5315 | [
"MIT"
] | null | null | null | SynpaySDK-iOS/SynpaySDK.framework/Headers/SynpaySDK.h | SYNSoftWareDept/SynpaySDK-iOS | bdfa088048a74e973951c60cf05afc3773ed5315 | [
"MIT"
] | null | null | null | //
// SynpaySDK.h
// SynpaySDK
//
// Created by Objective on 2021/11/10.
//
// 1640242345
// 1640244362
#import <Foundation/Foundation.h>
#import <SYNPaySDK/SynpayConfig.h>
#define SYNSharedPaySDK [SynpaySDK sharedSDK]
NS_ASSUME_NONNULL_BEGIN
@interface SynpaySDK : NSObject
/// SDK单例
+ (instancetype)sharedSDK;
/// SDK版本
- (NSString *)sdkVersion;
- (void)setThirdExtendInfo:(NSDictionary *)extentInfo;
/// 初始化SDK
/// @param config SDK必要配置信息
/// @param completion 调用结果回调block
- (void)startSDKWithConfig:(SynpayConfig *)config
completion:(void (^)(NSDictionary *result))completion;
/// 更新用户token
/// @param token 用户token
/// @param completion 调用结果回调block
- (void)updateUserToken:(NSString *)token
completion:(void (^)(NSDictionary *result))completion;
/// 获取支付列表
/// @param completion 调用结果回调block
- (void)getPayTypes:(void (^)(NSDictionary *result))completion;
/// 获取联机码
/// @param typeId 支付方式id
/// @param completion 调用结果回调block
- (void)getOnlineCodeByTypeId:(NSString *)typeId
completion:(void (^)(NSDictionary *result))completion;
/// 获取脱机码
/// @param typeId 支付方式id
/// @param completion 调用结果回调block
- (void)getOfflineCodeByTypeId:(NSString *)typeId
completion:(void (^)(NSDictionary *result))completion;
/// 获取复合码 注:联机码有可能获取失败
/// @param typeId 支付方式id
/// @param completion 调用结果回调block
- (void)getCompoundCodeByTypeId:(NSString *)typeId
completion:(void (^)(NSDictionary *result))completion;
/// 监听联机码消费结果
/// @param barcode 联机码
/// @param completion 调用结果回调block
- (void)observeBarcode:(NSString *)barcode
completion:(void (^)(NSDictionary *result))completion;
/// 关闭监听
- (void)closeObserveBarcode;
@end
NS_ASSUME_NONNULL_END
| 23.386667 | 75 | 0.694983 |
dca78f52fc9a18d4be9ca7cc7c8d41cd7795a48a | 7,754 | c | C | clang/test/Driver/sparc-as.c | ornata/llvm-project | 494913b8b4e4bce0b3525e5569d8e486e82b9a52 | [
"Apache-2.0"
] | null | null | null | clang/test/Driver/sparc-as.c | ornata/llvm-project | 494913b8b4e4bce0b3525e5569d8e486e82b9a52 | [
"Apache-2.0"
] | null | null | null | clang/test/Driver/sparc-as.c | ornata/llvm-project | 494913b8b4e4bce0b3525e5569d8e486e82b9a52 | [
"Apache-2.0"
] | null | null | null | // Make sure Sparc does use the integrated assembler by default.
// RUN: %clang --target=sparc-linux -### -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=IAS %s
// RUN: %clang --target=sparc-linux -fintegrated-as -### -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=IAS %s
// RUN: %clang --target=sparc-linux -fno-integrated-as -### -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=NO-IAS %s
// IAS-NOT: "-no-integrated-as"
// NO-IAS: "-no-integrated-as"
// RUN: %clang --target=sparc--netbsd \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC %s
// RUN: %clang -mcpu=v8 --target=sparc--netbsd \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-V8 %s
// RUN: %clang -mcpu=supersparc --target=sparc--netbsd \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-V8 %s
// RUN: %clang -mcpu=sparclite --target=sparc--netbsd \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-SPARCLITE %s
// RUN: %clang -mcpu=f934 --target=sparc--netbsd \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-SPARCLITE %s
// RUN: %clang -mcpu=hypersparc --target=sparc--netbsd \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-V8 %s
// RUN: %clang -mcpu=sparclite86x --target=sparc--netbsd \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-SPARCLITE %s
// RUN: %clang -mcpu=sparclet --target=sparc--netbsd \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-SPARCLET %s
// RUN: %clang -mcpu=tsc701 --target=sparc--netbsd \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-SPARCLET %s
// RUN: %clang -mcpu=v9 --target=sparc--netbsd \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-V8PLUS %s
// RUN: %clang -mcpu=ultrasparc --target=sparc--netbsd \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-V8PLUS %s
// RUN: %clang -mcpu=ultrasparc3 --target=sparc--netbsd \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-V8PLUS %s
// RUN: %clang -mcpu=niagara --target=sparc--netbsd \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-V8PLUSB %s
// RUN: %clang -mcpu=niagara2 --target=sparc--netbsd \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-V8PLUSB %s
// RUN: %clang -mcpu=niagara3 --target=sparc--netbsd \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-V8PLUSD %s
// RUN: %clang -mcpu=niagara4 --target=sparc--netbsd \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-V8PLUSD %s
// RUN: %clang -mcpu=ma2100 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=ma2150 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=ma2155 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=ma2450 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=ma2455 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=ma2x5x --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=ma2080 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=ma2085 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=ma2480 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=ma2485 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=ma2x8x --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=myriad2 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=myriad2.1 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=myriad2.2 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=myriad2.3 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=leon2 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-V8 %s
// RUN: %clang -mcpu=at697e --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-V8 %s
// RUN: %clang -mcpu=at697f --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-V8 %s
// RUN: %clang -mcpu=leon3 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=ut699 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-V8 %s
// RUN: %clang -mcpu=gr712rc --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=leon4 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// RUN: %clang -mcpu=gr740 --target=sparc \
// RUN: -no-integrated-as --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
// RUN: | FileCheck -check-prefix=SPARC-LEON %s
// SPARC: as{{.*}}" "-32" "-Av8" "-o"
// SPARC-V8: as{{.*}}" "-32" "-Av8" "-o"
// SPARC-LEON: as{{.*}}" "-32" "-Aleon" "-o"
// SPARC-SPARCLITE: as{{.*}}" "-32" "-Asparclite" "-o"
// SPARC-SPARCLET: as{{.*}}" "-32" "-Asparclet" "-o"
// SPARC-V8PLUS: as{{.*}}" "-32" "-Av8plus" "-o"
// SPARC-V8PLUSB: as{{.*}}" "-32" "-Av8plusb" "-o"
// SPARC-V8PLUSD: as{{.*}}" "-32" "-Av8plusd" "-o"
| 43.318436 | 78 | 0.645473 |
98312c922ae1823500bcf680466ee0f79707e512 | 5,499 | h | C | KSExtensibleManagedObject.h | karelia/KSExtensibleManagedObject | 149dae1694074e60548b5730ea1176f9b39c9fb8 | [
"MIT"
] | null | null | null | KSExtensibleManagedObject.h | karelia/KSExtensibleManagedObject | 149dae1694074e60548b5730ea1176f9b39c9fb8 | [
"MIT"
] | null | null | null | KSExtensibleManagedObject.h | karelia/KSExtensibleManagedObject | 149dae1694074e60548b5730ea1176f9b39c9fb8 | [
"MIT"
] | null | null | null | //
// KSExtensibleManagedObject.h
//
// Created by Mike Abdullah
// Copyright © 2007 Karelia Software
//
// 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.
//
// A special kind of managed object that allows you to use -valueForKey: and
// -setValueForKey: using any key. If the object does not normally accept this
// key, it is stored internally in a dictionary and then archived as data.
#import <CoreData/CoreData.h>
@interface KSExtensibleManagedObject : NSManagedObject
{
@private
NSMutableDictionary *_extensibleProperties;
}
#pragma mark Extensible Properties
/**
Retrieves a value from the extensible properties store.
@param key The key to lookup. Must not be `nil`.
@result The value corresponding to `key`. Might be `nil`.
*/
- (id)extensiblePropertyForKey:(NSString *)key __attribute((nonnull(1)));
/**
Retrieves a copy of the extensible properties store.
@result All the extensible properties currently stored.
*/
- (NSDictionary *)extensibleProperties;
/**
Stores an extensible property.
@param value The value to store. Should not be `nil`.
@param key The key to store. Must not be `nil`.
*/
- (void)setExtensibleProperty:(id)value forKey:(NSString *)key __attribute((nonnull(1,2)));
/**
Removes an extensible property.
@param key The key to remove from the extensible properties store. Must not be `nil`.
*/
- (void)removeExtensiblePropertyForKey:(NSString *)key __attribute((nonnull(1)));
/**
Invoked automatically when an extensible properties is reset due to an undo or redo state change.
Default implementation does nothing, but should call `super` first when
overriding for future compatibility.
@param key The key for whose values has changed.
*/
- (void)awakeFromExtensiblePropertyUndoUpdateForKey:(NSString *)key __attribute((nonnull(1)));
#pragma mark KVC/KVO Integration
/**
Whether a given extensible property should be made KVC and KVO compliant.
Whenever a method such as `-valueForUndefinedKey:` or
`-setValue:forUndefinedKey:` is called, the receiver will call this method to
define the behaviour. If you return `YES`, the value will be stored/retrieved
in/from extensible properties, and appropriate KVO notifications posted. If not,
`super`'s implementation will be invoked (i.e. `NSUndefinedKeyException` is
raised).
@param key The key being queried.
@result Default implementation returns `NO` for all keys.
*/
- (BOOL)usesExtensiblePropertiesForUndefinedKey:(NSString *)key __attribute((nonnull(1)));
#pragma mark Core Data Integration
/**
An extension to `-[NSManagedObject committedValuesForKeys:]` that can include extensible properties too.
@param keys The keys to retrieve. Pass `nil` to retrieve all keys/values.
@param flag Whether to include extensible properties in the list of changed values.
@result The values last committed to disk.
*/
- (NSDictionary *)committedValuesForKeys:(NSArray *)keys includeExtensibleProperties:(BOOL)flag;
/**
An extension to `-[NSManagedObject changedValues]` that can include extensible properties too.
@param flag Whether to include extensible properties in the list of changed values.
@result The changed values.
*/
- (NSDictionary *)changedValuesIncludingExtensibleProperties:(BOOL)flag;
#pragma mark Extensible Property Storage
/**
Unarchives extensible properties.
Subclasses can override to perform their own custom unarchiving.
@param propertiesData The serialized extensible properties.
@result The deserialized extensible properties.
*/
+ (NSDictionary *)unarchiveExtensibleProperties:(NSData *)propertiesData;
/**
Archives extensible properties.
Subclasses can override to perform their own custom archiving.
@param properties The extensible properties.
@result Deserialized representation of the extensible properties.
*/
+ (NSData *)archiveExtensibleProperties:(NSDictionary *)properties;
/**
Override this method to store extensible properties using a different key.
@result The key under which to store the archived representation of the extensible properties. By default this is `extensiblePropertiesData`.
*/
+ (NSString *)extensiblePropertiesDataKey;
#pragma mark KVO Debugging
// Implements my suggestion from http://www.mikeabdullah.net/managed-object-kvo.html
// Please DO NOT turn this on for release builds as Apple could easily break your app
+ (BOOL)logsObserversWhenTurningIntoFault;
+ (void)setLogsObserversWhenTurningIntoFault:(BOOL)flag;
@end
| 34.584906 | 142 | 0.76814 |
cce1cb0d2f1949174ae79fd05f08004b91804c69 | 18,732 | h | C | src/phymod/chip/eagle/tier1/eagle_tsc_pll_config_c.h | lguohan/SDKLT | 37acbc80e162bdfc7f7d5fb0833178f4f7a8afd4 | [
"Apache-2.0"
] | 2 | 2018-01-31T07:21:32.000Z | 2018-01-31T07:21:49.000Z | src/phymod/chip/eagle/tier1/eagle_tsc_pll_config_c.h | lguohan/SDKLT | 37acbc80e162bdfc7f7d5fb0833178f4f7a8afd4 | [
"Apache-2.0"
] | null | null | null | src/phymod/chip/eagle/tier1/eagle_tsc_pll_config_c.h | lguohan/SDKLT | 37acbc80e162bdfc7f7d5fb0833178f4f7a8afd4 | [
"Apache-2.0"
] | 3 | 2021-07-13T08:29:18.000Z | 2022-01-14T06:14:56.000Z | /*******************************************************************************
*******************************************************************************
* File Name : eagle_pll_config.c *
* Created On : 14/07/2013 *
* Created By : Kiran Divakar *
* Description : Eagle PLL Configuration API *
* Revision : $Id: eagle_pll_config.c 1103 2015-08-14 16:57:21Z kirand $ *
* *
* Copyright: (c) 2018 Broadcom. All Rights Reserved. "Broadcom" refers to
* Broadcom Limited and/or its subsidiaries.
*
* Broadcom Switch Software License
*
* This license governs the use of the accompanying Broadcom software. Your
* use of the software indicates your acceptance of the terms and conditions
* of this license. If you do not agree to the terms and conditions of this
* license, do not use the software.
* 1. Definitions
* "Licensor" means any person or entity that distributes its Work.
* "Software" means the original work of authorship made available under
* this license.
* "Work" means the Software and any additions to or derivative works of
* the Software that are made available under this license.
* The terms "reproduce," "reproduction," "derivative works," and
* "distribution" have the meaning as provided under U.S. copyright law.
* Works, including the Software, are "made available" under this license
* by including in or with the Work either (a) a copyright notice
* referencing the applicability of this license to the Work, or (b) a copy
* of this license.
* 2. Grant of Copyright License
* Subject to the terms and conditions of this license, each Licensor
* grants to you a perpetual, worldwide, non-exclusive, and royalty-free
* copyright license to reproduce, prepare derivative works of, publicly
* display, publicly perform, sublicense and distribute its Work and any
* resulting derivative works in any form.
* 3. Grant of Patent License
* Subject to the terms and conditions of this license, each Licensor
* grants to you a perpetual, worldwide, non-exclusive, and royalty-free
* patent license to make, have made, use, offer to sell, sell, import, and
* otherwise transfer its Work, in whole or in part. This patent license
* applies only to the patent claims licensable by Licensor that would be
* infringed by Licensor's Work (or portion thereof) individually and
* excluding any combinations with any other materials or technology.
* If you institute patent litigation against any Licensor (including a
* cross-claim or counterclaim in a lawsuit) to enforce any patents that
* you allege are infringed by any Work, then your patent license from such
* Licensor to the Work shall terminate as of the date such litigation is
* filed.
* 4. Redistribution
* You may reproduce or distribute the Work only if (a) you do so under
* this License, (b) you include a complete copy of this License with your
* distribution, and (c) you retain without modification any copyright,
* patent, trademark, or attribution notices that are present in the Work.
* 5. Derivative Works
* You may specify that additional or different terms apply to the use,
* reproduction, and distribution of your derivative works of the Work
* ("Your Terms") only if (a) Your Terms provide that the limitations of
* Section 7 apply to your derivative works, and (b) you identify the
* specific derivative works that are subject to Your Terms.
* Notwithstanding Your Terms, this license (including the redistribution
* requirements in Section 4) will continue to apply to the Work itself.
* 6. Trademarks
* This license does not grant any rights to use any Licensor's or its
* affiliates' names, logos, or trademarks, except as necessary to
* reproduce the notices described in this license.
* 7. Limitations
* Platform. The Work and any derivative works thereof may only be used, or
* intended for use, with a Broadcom switch integrated circuit.
* No Reverse Engineering. You will not use the Work to disassemble,
* reverse engineer, decompile, or attempt to ascertain the underlying
* technology of a Broadcom switch integrated circuit.
* 8. Termination
* If you violate any term of this license, then your rights under this
* license (including the license grants of Sections 2 and 3) will
* terminate immediately.
* 9. Disclaimer of Warranty
* THE WORK IS PROVIDED "AS IS" WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WARRANTIES OR CONDITIONS OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR
* NON-INFRINGEMENT. YOU BEAR THE RISK OF UNDERTAKING ANY ACTIVITIES UNDER
* THIS LICENSE. SOME STATES' CONSUMER LAWS DO NOT ALLOW EXCLUSION OF AN
* IMPLIED WARRANTY, SO THIS DISCLAIMER MAY NOT APPLY TO YOU.
* 10. Limitation of Liability
* EXCEPT AS PROHIBITED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO LEGAL
* THEORY, WHETHER IN TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE
* SHALL ANY LICENSOR BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT,
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
* OR RELATED TO THIS LICENSE, THE USE OR INABILITY TO USE THE WORK
* (INCLUDING BUT NOT LIMITED TO LOSS OF GOODWILL, BUSINESS INTERRUPTION,
* LOST PROFITS OR DATA, COMPUTER FAILURE OR MALFUNCTION, OR ANY OTHER
* COMMERCIAL DAMAGES OR LOSSES), EVEN IF THE LICENSOR HAS BEEN ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGES.
*
* *
* No portions of this material may be reproduced in any form without *
* the written permission of: *
* Broadcom Corporation *
* 5300 California Avenue *
* Irvine, CA 92617 *
* *
* All information contained in this document is Broadcom Corporation *
* company private proprietary, and trade secret. *
*/
/** @file
* Eagle PLL Configuration
*/
#include "eagle_tsc_enum.h"
err_code_t eagle_tsc_configure_pll( const phymod_access_t *pa, enum eagle_tsc_pll_enum pll_cfg){
/* KVH VCO Range */
/* 00 11.5 - 13.125 */
/* 01 10.3125 - <11.5 */
/* 10 9.375 - <10.3125 */
/* 11 8.125 - < 9.375 */
/* CKBWVCO Range */
/* 00 12.5 */
/* 10 10.625 - 11.5G */
/* 01 9.375 - 10.3125G */
/* 11 <9.375G */
#ifndef ATE_LOG
uint8_t reset_state;
#endif
/* Use this to restore defaults if reprogramming the PLL under dp-reset (typically Auto-Neg FW) */
EFUN(wrc_pll_mode ( 0xA));
EFUN(wrc_ams_pll_fracn_ndiv_int( 0x0));
EFUN(wrc_ams_pll_fracn_div_h ( 0x0));
EFUN(wrc_ams_pll_fracn_div_l ( 0x0));
EFUN(wrc_ams_pll_fracn_bypass ( 0x0));
EFUN(wrc_ams_pll_fracn_divrange( 0x0));
EFUN(wrc_ams_pll_fracn_sel ( 0x0));
EFUN(wrc_ams_pll_ditheren ( 0x0));
EFUN(wrc_ams_pll_force_kvh_bw ( 0x0));
EFUN(wrc_ams_pll_kvh_force ( 0x0));
EFUN(wrc_ams_pll_2rx_clkbw ( 0x0));
EFUN(wrc_ams_pll_vco_div2 ( 0x0));
EFUN(wrc_ams_pll_vco_div4 ( 0x0));
EFUN(wrc_ams_pll_refclk_doubler( 0x0));
EFUN(wrc_ams_pll_fp3_ctrl ( 0x0));
EFUN(wrc_ams_pll_fp3_rh ( 0x0));
/* Use core_s_rstb to re-initialize all registers to default before calling this function. */
#ifndef ATE_LOG
ESTM(reset_state = rdc_core_dp_reset_state());
if (reset_state < 7) {
EFUN_PRINTF(("ERROR: eagle_tsc_configure_pll( pa, ..) called without core_dp_s_rstb=0\n"));
return _error(ERR_CODE_CORE_DP_NOT_RESET);
}
#endif
switch (pll_cfg) {
/******************/
/* Integer Mode */
/******************/
case EAGLE_TSC_pll_div_80x_refc125: /* pll_mode<3:0> 1101 VCO 10G REF 125 MHz */
EFUN(wrc_pll_mode( 0xD));
EFUN(wrc_ams_pll_force_kvh_bw( 0x1));
EFUN(wrc_ams_pll_2rx_clkbw( 0x1));
EFUN(wrc_ams_pll_kvh_force( 0x2));
EFUN(wrc_ams_pll_vco_div2( 0x0));
break;
case EAGLE_TSC_pll_div_80x_refc106: /* pll_mode<3:0> 1101 VCO 8.5G REF 106.25MHz */
EFUN(wrc_pll_mode( 0xD));
EFUN(wrc_ams_pll_force_kvh_bw( 0x1));
EFUN(wrc_ams_pll_2rx_clkbw( 0x3));
EFUN(wrc_ams_pll_kvh_force( 0x3));
EFUN(wrc_ams_pll_vco_div2( 0x0));
break;
case EAGLE_TSC_pll_div_80x:
case EAGLE_TSC_pll_div_80x_refc156: /* pll_mode<3:0> 1101 VCO 12.5G REF 156.25MHz */
EFUN(wrc_pll_mode( 0xD));
EFUN(wrc_ams_pll_force_kvh_bw( 0x1));
EFUN(wrc_ams_pll_2rx_clkbw( 0x0));
EFUN(wrc_ams_pll_kvh_force( 0x2));
EFUN(wrc_ams_pll_vco_div2( 0x0));
break;
case EAGLE_TSC_pll_div_46x: /* pll_mode<3:0> 0000 VCO 5.75G REF 125 MHz */
EFUN(wrc_pll_mode( 0x0));
break;
case EAGLE_TSC_pll_div_50x: /* pll_mode<3:0> 0101 VCO 6.25G REF 125 MHz */
EFUN(wrc_pll_mode( 0x5));
break;
case EAGLE_TSC_pll_div_68x: /* pll_mode<3:0> 1011 VCO 8.5G REF 125 MHz */
EFUN(wrc_pll_mode( 0xB));
break;
case EAGLE_TSC_pll_div_92x: /* pll_mode<3:0> 1110 VCO 11.5G REF 125 MHz */
EFUN(wrc_pll_mode( 0xE));
break;
case EAGLE_TSC_pll_div_100x: /* pll_mode<3:0> 1111 VCO 12.5G REF 125 MHz */
EFUN(wrc_pll_mode( 0xF));
break;
case EAGLE_TSC_pll_div_40x: /* pll_mode<3:0> 0010 VCO 6.25G REF 156.25MHz */
EFUN(wrc_pll_mode( 0x2));
EFUN(wrc_ams_pll_force_kvh_bw( 0x1));
EFUN(wrc_ams_pll_2rx_clkbw( 0x3));
EFUN(wrc_ams_pll_kvh_force( 0x2));
EFUN(wrc_ams_pll_vco_div2( 0x1));
break;
case EAGLE_TSC_pll_div_42x: /* pll_mode<3:0> 0011 VCO 6.5625G REF 156.25MHz */
EFUN(wrc_pll_mode( 0x3));
EFUN(wrc_ams_pll_force_kvh_bw( 0x1));
EFUN(wrc_ams_pll_2rx_clkbw( 0x3));
EFUN(wrc_ams_pll_kvh_force( 0x2));
EFUN(wrc_ams_pll_vco_div2( 0x1));
break;
case EAGLE_TSC_pll_div_52x: /* pll_mode<3:0> 0110 VCO 8.125G REF 156.25MHz */
EFUN(wrc_pll_mode( 0x6));
break;
/* 5.0G mode NOT verified by digital team or DVT */
/* case EAGLE_TSC_pll_div_32x: *//* pll_mode<3:0> 0111 VCO 5.0G REF 156.25MHz */
/* EFUN(wrc_pll_mode ( 0x7)); */
/* break; */
/* 3.125G mode NOT verified by digital team or DVT */
/* case EAGLE_TSC_pll_div_20x: *//* pll_mode<3:0> 0100 VCO 3.125G REF 156.25MHz */
/* EFUN(wrc_pll_mode ( 0x4)); */
/* break; */
case EAGLE_TSC_pll_div_60x:
/* pll_mode<3:0> 1000 VCO 9.375 G REF 156.25MHz */
EFUN(wrc_pll_mode( 0x8));
break;
case EAGLE_TSC_pll_div_64x_refc161:
/* pll_mode<3:0> 1001 VCO 10.3125G REF 161.13MHz */
EFUN(wrc_pll_mode( 0x9));
EFUN(wrc_ams_pll_force_kvh_bw( 0x1));
EFUN(wrc_ams_pll_2rx_clkbw( 0x1));
EFUN(wrc_ams_pll_kvh_force( 0x2));
EFUN(wrc_ams_pll_vco_div2( 0x0));
break;
case EAGLE_TSC_pll_div_64x:
case EAGLE_TSC_pll_div_64x_refc156:
/* pll_mode<3:0> 1001 VCO 10G REF 156.25MHzMHz */
EFUN(wrc_pll_mode( 0x9));
EFUN(wrc_ams_pll_force_kvh_bw( 0x1));
EFUN(wrc_ams_pll_2rx_clkbw( 0x1));
EFUN(wrc_ams_pll_kvh_force( 0x1));
EFUN(wrc_ams_pll_vco_div2( 0x0));
break;
case EAGLE_TSC_pll_div_66x:
/* pll_mode<3:0> 1010 VCO 10.3125G REF 156.25MHz */
EFUN(wrc_pll_mode( 0xA));
break;
case EAGLE_TSC_pll_div_70x:
/* pll_mode<3:0> 1100 VCO 10.9375G REF 156.25MHz */
EFUN(wrc_pll_mode( 0xC));
break;
case EAGLE_TSC_pll_div_72x:
/* pll_mode<3:0> 0001 VCO 11.25 G REF 156.25MHz */
EFUN(wrc_pll_mode( 0x1));
break;
/*****************/
/* Frac-N Mode */
/*****************/
case EAGLE_TSC_pll_div_82p5x: /* DIV 82.5 VCO 10.3125G REF 125 MHz */
EFUN(wrc_ams_pll_fracn_ndiv_int( 0x52));
EFUN(wrc_ams_pll_fracn_div_l(0x0000));
EFUN(wrc_ams_pll_fracn_div_h( 0x2));
EFUN(wrc_ams_pll_fracn_bypass( 0x0));
EFUN(wrc_ams_pll_fracn_divrange( 0x0));
EFUN(wrc_ams_pll_fracn_sel( 0x1));
EFUN(wrc_ams_pll_ditheren( 0x1));
EFUN(wrc_ams_pll_force_kvh_bw( 0x1));
EFUN(wrc_ams_pll_2rx_clkbw( 0x1));
EFUN(wrc_ams_pll_kvh_force( 0x1));
EFUN(wrc_ams_pll_vco_div2( 0x0));
EFUN(wrc_ams_pll_vco_div4( 0x0));
EFUN(wrc_ams_pll_refclk_doubler( 0x0));
EFUN(wrc_ams_pll_fp3_ctrl( 0x3));
EFUN(wrc_ams_pll_fp3_rh( 0x1));
break;
case EAGLE_TSC_pll_div_87p5x: /* DIV 87.5 VCO 10.9375G REF 125 MHz */
EFUN(wrc_ams_pll_fracn_ndiv_int( 0x57));
EFUN(wrc_ams_pll_fracn_div_l(0x0000));
EFUN(wrc_ams_pll_fracn_div_h( 0x2));
EFUN(wrc_ams_pll_fracn_bypass( 0x0));
EFUN(wrc_ams_pll_fracn_divrange( 0x0));
EFUN(wrc_ams_pll_fracn_sel( 0x1));
EFUN(wrc_ams_pll_ditheren( 0x1));
EFUN(wrc_ams_pll_force_kvh_bw( 0x1));
EFUN(wrc_ams_pll_2rx_clkbw( 0x2));
EFUN(wrc_ams_pll_kvh_force( 0x1));
EFUN(wrc_ams_pll_vco_div2( 0x0));
EFUN(wrc_ams_pll_vco_div4( 0x0));
EFUN(wrc_ams_pll_refclk_doubler( 0x0));
EFUN(wrc_ams_pll_fp3_ctrl( 0x3));
EFUN(wrc_ams_pll_fp3_rh( 0x1));
break;
case EAGLE_TSC_pll_div_73p6x: /* DIV 73.6 VCO 11.5G REF 156.25MHz */
EFUN(wrc_ams_pll_fracn_ndiv_int( 0x49));
EFUN(wrc_ams_pll_fracn_div_l(0x6666));
EFUN(wrc_ams_pll_fracn_div_h( 0x2));
EFUN(wrc_ams_pll_fracn_bypass( 0x0));
EFUN(wrc_ams_pll_fracn_divrange( 0x0));
EFUN(wrc_ams_pll_fracn_sel( 0x1));
EFUN(wrc_ams_pll_ditheren( 0x1));
EFUN(wrc_ams_pll_force_kvh_bw( 0x1));
EFUN(wrc_ams_pll_2rx_clkbw( 0x2));
EFUN(wrc_ams_pll_kvh_force( 0x0));
EFUN(wrc_ams_pll_vco_div2( 0x0));
EFUN(wrc_ams_pll_vco_div4( 0x0));
EFUN(wrc_ams_pll_refclk_doubler( 0x0));
EFUN(wrc_ams_pll_fp3_ctrl( 0x3));
EFUN(wrc_ams_pll_fp3_rh( 0x1));
break;
case EAGLE_TSC_pll_div_36p8x: /* DIV 73.6 VCO 11.5G/2 REF 156.25MHz */
EFUN(wrc_ams_pll_fracn_ndiv_int( 0x49));
EFUN(wrc_ams_pll_fracn_div_l(0x6666));
EFUN(wrc_ams_pll_fracn_div_h( 0x2));
EFUN(wrc_ams_pll_fracn_bypass( 0x0));
EFUN(wrc_ams_pll_fracn_divrange( 0x0));
EFUN(wrc_ams_pll_fracn_sel( 0x1));
EFUN(wrc_ams_pll_ditheren( 0x1));
EFUN(wrc_ams_pll_force_kvh_bw( 0x1));
EFUN(wrc_ams_pll_kvh_force( 0x0));
EFUN(wrc_ams_pll_2rx_clkbw( 0x3));
EFUN(wrc_ams_pll_vco_div2( 0x1));
EFUN(wrc_ams_pll_vco_div4( 0x0));
EFUN(wrc_ams_pll_refclk_doubler( 0x0));
EFUN(wrc_ams_pll_fp3_ctrl( 0x3));
EFUN(wrc_ams_pll_fp3_rh( 0x1));
break;
case EAGLE_TSC_pll_div_199p04x: /* DIV 199.04 VCO 9.952G REF 25 MHz */
EFUN(wrc_ams_pll_fracn_ndiv_int( 0xc7));
EFUN(wrc_ams_pll_fracn_div_l(0x28f5));
EFUN(wrc_ams_pll_fracn_div_h( 0x0));
EFUN(wrc_ams_pll_fracn_bypass( 0x0));
EFUN(wrc_ams_pll_fracn_divrange( 0x0));
EFUN(wrc_ams_pll_fracn_sel( 0x1));
EFUN(wrc_ams_pll_ditheren( 0x1));
EFUN(wrc_ams_pll_force_kvh_bw( 0x1));
EFUN(wrc_ams_pll_2rx_clkbw( 0x1));
EFUN(wrc_ams_pll_kvh_force( 0x2));
EFUN(wrc_ams_pll_vco_div2( 0x0));
EFUN(wrc_ams_pll_vco_div4( 0x0));
EFUN(wrc_ams_pll_refclk_doubler( 0x1));
EFUN(wrc_ams_pll_fp3_ctrl( 0x3));
EFUN(wrc_ams_pll_fp3_rh( 0x1));
break;
/*******************************/
/* Invalid 'pll_cfg' Selector */
/*******************************/
default: /* Invalid pll_cfg value */
return _error(ERR_CODE_INVALID_PLL_CFG);
break;
} /* switch (pll_cfg) */
return ERR_CODE_NONE;
} /* eagle_tsc_configure_pll */
err_code_t eagle_tsc_get_pll_div_from_enum (enum eagle_tsc_pll_enum pll_cfg, uint32_t *new_pll_div){
switch (pll_cfg) {
/******************/
/* Integer Mode */
/******************/
case EAGLE_TSC_pll_div_80x_refc125: /* pll_mode<3:0> 1101 VCO 10G REF 125 MHz */
*new_pll_div = 0xD;
break;
case EAGLE_TSC_pll_div_80x_refc106: /* pll_mode<3:0> 1101 VCO 8.5G REF 106.25MHz */
*new_pll_div = 0xD;
break;
case EAGLE_TSC_pll_div_80x:
case EAGLE_TSC_pll_div_80x_refc156: /* pll_mode<3:0> 1101 VCO 12.5G REF 156.25MHz */
*new_pll_div = 0xD;
break;
case EAGLE_TSC_pll_div_46x: /* pll_mode<3:0> 0000 VCO 5.75G REF 125 MHz */
*new_pll_div = 0x0;
break;
case EAGLE_TSC_pll_div_50x: /* pll_mode<3:0> 0101 VCO 6.25G REF 125 MHz */
*new_pll_div = 0x5;
break;
case EAGLE_TSC_pll_div_68x: /* pll_mode<3:0> 1011 VCO 8.5G REF 125 MHz */
*new_pll_div = 0xB;
break;
case EAGLE_TSC_pll_div_92x: /* pll_mode<3:0> 1110 VCO 11.5G REF 125 MHz */
*new_pll_div = 0xE;
break;
case EAGLE_TSC_pll_div_100x: /* pll_mode<3:0> 1111 VCO 12.5G REF 125 MHz */
*new_pll_div = 0xF;
break;
case EAGLE_TSC_pll_div_40x: /* pll_mode<3:0> 0010 VCO 6.25G REF 156.25MHz */
*new_pll_div = 0x2;
break;
case EAGLE_TSC_pll_div_42x: /* pll_mode<3:0> 0011 VCO 6.5625G REF 156.25MHz */
*new_pll_div = 0x3;
break;
case EAGLE_TSC_pll_div_52x: /* pll_mode<3:0> 0110 VCO 8.125G REF 156.25MHz */
*new_pll_div = 0x6;
break;
/* 5.0G mode NOT verified by digital team or DVT */
/* case EAGLE_TSC_pll_div_32x: *//* pll_mode<3:0> 0111 VCO 5.0G REF 156.25MHz */
/* EFUN(wrc_pll_mode ( 0x7)); */
/* break; */
/* 3.125G mode NOT verified by digital team or DVT */
/* case EAGLE_TSC_pll_div_20x: *//* pll_mode<3:0> 0100 VCO 3.125G REF 156.25MHz */
/* EFUN(wrc_pll_mode ( 0x4)); */
/* break; */
case EAGLE_TSC_pll_div_60x:
/* pll_mode<3:0> 1000 VCO 9.375 G REF 156.25MHz */
*new_pll_div = 0x8;
break;
case EAGLE_TSC_pll_div_64x_refc161:
/* pll_mode<3:0> 1001 VCO 10.3125G REF 161.13MHz */
*new_pll_div = 0x9;
break;
case EAGLE_TSC_pll_div_64x:
case EAGLE_TSC_pll_div_64x_refc156:
/* pll_mode<3:0> 1001 VCO 10G REF 156.25MHzMHz */
*new_pll_div = 0x9;
break;
case EAGLE_TSC_pll_div_66x:
/* pll_mode<3:0> 1010 VCO 10.3125G REF 156.25MHz */
*new_pll_div = 0xA;
break;
case EAGLE_TSC_pll_div_70x:
/* pll_mode<3:0> 1100 VCO 10.9375G REF 156.25MHz */
*new_pll_div = 0xC;
break;
case EAGLE_TSC_pll_div_72x:
/* pll_mode<3:0> 0001 VCO 11.25 G REF 156.25MHz */
*new_pll_div = 0x1;
break;
default: /* Invalid pll_cfg value */
return _error(ERR_CODE_INVALID_PLL_CFG);
break;
}
return ERR_CODE_NONE;
}
| 43.461717 | 100 | 0.654068 |
e609b4a0588914db01e9b8d81550977454562981 | 11,473 | h | C | src/tools/qstring.h | sandsmark/qt1 | e62eef42291be80065a7f824530aa42b79917a8d | [
"Xnet",
"X11"
] | 18 | 2018-02-16T16:57:26.000Z | 2022-02-10T21:23:47.000Z | src/tools/qstring.h | sandsmark/qt1 | e62eef42291be80065a7f824530aa42b79917a8d | [
"Xnet",
"X11"
] | 2 | 2018-08-12T12:46:38.000Z | 2020-06-19T16:30:06.000Z | src/tools/qstring.h | sandsmark/qt1 | e62eef42291be80065a7f824530aa42b79917a8d | [
"Xnet",
"X11"
] | 7 | 2018-06-22T01:17:58.000Z | 2021-09-02T21:05:28.000Z | /****************************************************************************
** $Id: qstring.h,v 2.10.2.4 1999/02/17 21:27:16 warwick Exp $
**
** Definition of extended char array operations, and QByteArray and
** QString classes
**
** Created : 920609
**
** Copyright (C) 1992-1999 Troll Tech AS. All rights reserved.
**
** This file is part of Qt Free Edition, version 1.45.
**
** See the file LICENSE included in the distribution for the usage
** and distribution terms, or http://www.troll.no/free-license.html.
**
** IMPORTANT NOTE: You may NOT copy this file or any part of it into
** your own programs or libraries.
**
** Please see http://www.troll.no/pricing.html for information about
** Qt Professional Edition, which is this same library but with a
** license which allows creation of commercial/proprietary software.
**
*****************************************************************************/
#ifndef QSTRING_H
#define QSTRING_H
#ifndef QT_H
#include "qarray.h"
#endif // QT_H
#include <string.h>
#if defined(_OS_SUN_) && defined(_CC_GNU_)
#include <strings.h>
#endif
/*****************************************************************************
Fixes and workarounds for some platforms
*****************************************************************************/
#if defined(_OS_HPUX_)
// HP-UX has badly defined strstr() etc.
inline char *hack_strstr( const char *s1, const char *s2 )
{ return (char *)strstr(s1, s2); }
inline char *hack_strchr( const char *s, int c )
{ return (char *)strchr(s, c); }
inline char *hack_strrchr( const char *s, int c )
{ return (char *)strrchr(s, c); }
#define strstr hack_strstr
#define strchr hack_strchr
#define strrchr hack_strrchr
#endif
/*****************************************************************************
Safe and portable C string functions; extensions to standard string.h
*****************************************************************************/
Q_EXPORT void *qmemmove( void *dst, const void *src, uint len );
#if defined(_OS_SUN_) || defined(_CC_OC_)
#define memmove qmemmove
#endif
Q_EXPORT char *qstrdup( const char * );
Q_EXPORT inline uint cstrlen( const char *str )
{ return strlen(str); }
Q_EXPORT inline uint qstrlen( const char *str )
{ return str ? strlen(str) : 0; }
#undef strlen
#define strlen qstrlen
Q_EXPORT inline char *cstrcpy( char *dst, const char *src )
{ return strcpy(dst,src); }
Q_EXPORT inline char *qstrcpy( char *dst, const char *src )
{ return src ? strcpy(dst, src) : 0; }
#undef strcpy
#define strcpy qstrcpy
Q_EXPORT char *qstrncpy( char *dst, const char *src, uint len );
Q_EXPORT inline int cstrcmp( const char *str1, const char *str2 )
{ return strcmp(str1,str2); }
Q_EXPORT inline int qstrcmp( const char *str1, const char *str2 )
{ return (str1 && str2) ? strcmp(str1,str2) : (int)((long)str2 - (long)str1); }
#undef strcmp
#define strcmp qstrcmp
Q_EXPORT inline int cstrncmp( const char *str1, const char *str2, uint len )
{ return strncmp(str1,str2,len); }
Q_EXPORT inline int qstrncmp( const char *str1, const char *str2, uint len )
{ return (str1 && str2) ? strncmp(str1,str2,len) :
(int)((long)str2 - (long)str1); }
#undef strncmp
#define strncmp qstrncmp
Q_EXPORT int qstricmp( const char *, const char * );
Q_EXPORT int qstrnicmp( const char *, const char *, uint len );
#undef stricmp
#define stricmp qstricmp
#undef strnicmp
#define strnicmp qstrnicmp
// qchecksum: Internet checksum
#if 1 /* OBSOLETE */
#if !defined(QT_CLEAN_NAMESPACE)
Q_EXPORT UINT16 qchecksum( const char *s, uint len );
#endif
#endif
Q_EXPORT Q_UINT16 qChecksum( const char *s, uint len );
/*****************************************************************************
QByteArray class
*****************************************************************************/
#if defined(USE_TEMPLATECLASS)
#if defined(Q_TEMPLATEDLL)
template class Q_EXPORT QArray<char>;
typedef QArray<char> QByteArray;
#else
#define QByteArray QArrayT<char>
#endif
#else
Q_DECLARE(QArrayM,char);
#define QByteArray QArrayM(char)
#endif
/*****************************************************************************
QByteArray stream functions
*****************************************************************************/
Q_EXPORT QDataStream &operator<<( QDataStream &, const QByteArray & );
Q_EXPORT QDataStream &operator>>( QDataStream &, QByteArray & );
/*****************************************************************************
QString class
*****************************************************************************/
class QRegExp;
class Q_EXPORT QString : public QByteArray // string class
{
public:
QString() {} // make null string
QString( int size ); // allocate size incl. \0
QString( const QString &s ) : QByteArray( s ) {}
QString( const char *str ); // deep copy
QString( const char *str, uint maxlen ); // deep copy, max length
QString &operator=( const QString &s ); // shallow copy
QString &operator=( const char *str ); // deep copy
bool isNull() const;
bool isEmpty() const;
uint length() const;
bool resize( uint newlen );
bool truncate( uint pos );
bool fill( char c, int len = -1 );
QString copy() const;
QString &sprintf( const char *format, ... );
int find( char c, int index=0, bool cs=TRUE ) const;
int find( const char *str, int index=0, bool cs=TRUE ) const;
int find( const QRegExp &, int index=0 ) const;
int findRev( char c, int index=-1, bool cs=TRUE) const;
int findRev( const char *str, int index=-1, bool cs=TRUE) const;
int findRev( const QRegExp &, int index=-1 ) const;
int contains( char c, bool cs=TRUE ) const;
int contains( const char *str, bool cs=TRUE ) const;
int contains( const QRegExp & ) const;
QString left( uint len ) const;
QString right( uint len ) const;
QString mid( uint index, uint len) const;
QString leftJustify( uint width, char fill=' ', bool trunc=FALSE)const;
QString rightJustify( uint width, char fill=' ',bool trunc=FALSE)const;
QString lower() const;
QString upper() const;
QString stripWhiteSpace() const;
QString simplifyWhiteSpace() const;
QString &insert( uint index, const char * );
QString &insert( uint index, char );
QString &append( const char * );
QString &prepend( const char * );
QString &remove( uint index, uint len );
QString &replace( uint index, uint len, const char * );
QString &replace( const QRegExp &, const char * );
short toShort( bool *ok=0 ) const;
ushort toUShort( bool *ok=0 ) const;
int toInt( bool *ok=0 ) const;
uint toUInt( bool *ok=0 ) const;
long toLong( bool *ok=0 ) const;
ulong toULong( bool *ok=0 ) const;
float toFloat( bool *ok=0 ) const;
double toDouble( bool *ok=0 ) const;
QString &setStr( const char *s );
QString &setNum( short );
QString &setNum( ushort );
QString &setNum( int );
QString &setNum( uint );
QString &setNum( long );
QString &setNum( ulong );
QString &setNum( float, char f='g', int prec=6 );
QString &setNum( double, char f='g', int prec=6 );
bool setExpand( uint index, char c );
operator const char *() const;
QString &operator+=( const char *str );
QString &operator+=( char c );
};
/*****************************************************************************
QString stream functions
*****************************************************************************/
Q_EXPORT QDataStream &operator<<( QDataStream &, const QString & );
Q_EXPORT QDataStream &operator>>( QDataStream &, QString & );
/*****************************************************************************
QString inline functions
*****************************************************************************/
inline QString &QString::operator=( const QString &s )
{ return (QString&)assign( s ); }
inline QString &QString::operator=( const char *str )
{ return (QString&)duplicate( str, strlen(str)+1 ); }
inline bool QString::isNull() const
{ return data() == 0; }
inline bool QString::isEmpty() const
{ return data() == 0 || *data() == '\0'; }
inline uint QString::length() const
{ return strlen( data() ); }
inline bool QString::truncate( uint pos )
{ return resize(pos+1); }
inline QString QString::copy() const
{ return QString( data() ); }
inline QString &QString::prepend( const char *s )
{ return insert(0,s); }
inline QString &QString::append( const char *s )
{ return operator+=(s); }
inline QString &QString::setNum( short n )
{ return setNum((long)n); }
inline QString &QString::setNum( ushort n )
{ return setNum((ulong)n); }
inline QString &QString::setNum( int n )
{ return setNum((long)n); }
inline QString &QString::setNum( uint n )
{ return setNum((ulong)n); }
inline QString &QString::setNum( float n, char f, int prec )
{ return setNum((double)n,f,prec); }
inline QString::operator const char *() const
{ return (const char *)data(); }
/*****************************************************************************
QString non-member operators
*****************************************************************************/
Q_EXPORT inline bool operator==( const QString &s1, const QString &s2 )
{ return strcmp(s1.data(),s2.data()) == 0; }
Q_EXPORT inline bool operator==( const QString &s1, const char *s2 )
{ return strcmp(s1.data(),s2) == 0; }
Q_EXPORT inline bool operator==( const char *s1, const QString &s2 )
{ return strcmp(s1,s2.data()) == 0; }
Q_EXPORT inline bool operator!=( const QString &s1, const QString &s2 )
{ return strcmp(s1.data(),s2.data()) != 0; }
Q_EXPORT inline bool operator!=( const QString &s1, const char *s2 )
{ return strcmp(s1.data(),s2) != 0; }
Q_EXPORT inline bool operator!=( const char *s1, const QString &s2 )
{ return strcmp(s1,s2.data()) != 0; }
Q_EXPORT inline bool operator<( const QString &s1, const char *s2 )
{ return strcmp(s1.data(),s2) < 0; }
Q_EXPORT inline bool operator<( const char *s1, const QString &s2 )
{ return strcmp(s1,s2.data()) < 0; }
Q_EXPORT inline bool operator<=( const QString &s1, const char *s2 )
{ return strcmp(s1.data(),s2) <= 0; }
Q_EXPORT inline bool operator<=( const char *s1, const QString &s2 )
{ return strcmp(s1,s2.data()) <= 0; }
Q_EXPORT inline bool operator>( const QString &s1, const char *s2 )
{ return strcmp(s1.data(),s2) > 0; }
Q_EXPORT inline bool operator>( const char *s1, const QString &s2 )
{ return strcmp(s1,s2.data()) > 0; }
Q_EXPORT inline bool operator>=( const QString &s1, const char *s2 )
{ return strcmp(s1.data(),s2) >= 0; }
Q_EXPORT inline bool operator>=( const char *s1, const QString &s2 )
{ return strcmp(s1,s2.data()) >= 0; }
Q_EXPORT inline QString operator+( const QString &s1, const QString &s2 )
{
QString tmp( s1.data() );
tmp += s2;
return tmp;
}
Q_EXPORT inline QString operator+( const QString &s1, const char *s2 )
{
QString tmp( s1.data() );
tmp += s2;
return tmp;
}
Q_EXPORT inline QString operator+( const char *s1, const QString &s2 )
{
QString tmp( s1 );
tmp += s2;
return tmp;
}
Q_EXPORT inline QString operator+( const QString &s1, char c2 )
{
QString tmp( s1.data() );
tmp += c2;
return tmp;
}
Q_EXPORT inline QString operator+( char c1, const QString &s2 )
{
QString tmp;
tmp += c1;
tmp += s2;
return tmp;
}
#endif // QSTRING_H
| 30.192105 | 79 | 0.587118 |
e61f185fe6a0f75adb0a0e5547956570e75fd011 | 1,261 | h | C | Eudora71/Eudora/NameToolBarDialog.h | dusong7/eudora-win | 850a6619e6b0d5abc770bca8eb5f3b9001b7ccd2 | [
"BSD-3-Clause-Clear"
] | 10 | 2018-05-23T10:43:48.000Z | 2021-12-02T17:59:48.000Z | Eudora71/Eudora/NameToolBarDialog.h | ivanagui2/hermesmail-code | 34387722d5364163c71b577fc508b567de56c5f6 | [
"BSD-3-Clause-Clear"
] | 1 | 2019-03-19T03:56:36.000Z | 2021-05-26T18:36:03.000Z | Eudora71/Eudora/NameToolBarDialog.h | ivanagui2/hermesmail-code | 34387722d5364163c71b577fc508b567de56c5f6 | [
"BSD-3-Clause-Clear"
] | 11 | 2018-05-23T10:43:53.000Z | 2021-12-27T15:42:58.000Z | #if !defined(AFX_NAMETOOLBARDIALOG_H__74A8B311_75A7_11D1_A828_0060972F7459__INCLUDED_)
#define AFX_NAMETOOLBARDIALOG_H__74A8B311_75A7_11D1_A828_0060972F7459__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// NameToolBarDialog.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CNameToolBarDialog dialog
class CNameToolBarDialog : public CDialog
{
// Construction
public:
CNameToolBarDialog(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CNameToolBarDialog)
enum { IDD = IDD_NAME_TOOLBAR };
CString m_szName;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CNameToolBarDialog)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(CNameToolBarDialog)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_NAMETOOLBARDIALOG_H__74A8B311_75A7_11D1_A828_0060972F7459__INCLUDED_)
| 26.829787 | 103 | 0.739889 |
50881e19d3f8d1f70589ace145c59ab891c9a25b | 15,173 | c | C | tests/unit-core/test-api-binary-operations-comparisons.c | rerobika/jerryscript | bc091e174206b26e3ff71a9833e37527579b035f | [
"Apache-2.0"
] | 1 | 2021-09-23T04:48:42.000Z | 2021-09-23T04:48:42.000Z | tests/unit-core/test-api-binary-operations-comparisons.c | rerobika/jerryscript | bc091e174206b26e3ff71a9833e37527579b035f | [
"Apache-2.0"
] | 1 | 2021-12-07T15:40:08.000Z | 2021-12-07T15:40:08.000Z | tests/unit-core/test-api-binary-operations-comparisons.c | rerobika/jerryscript | bc091e174206b26e3ff71a9833e37527579b035f | [
"Apache-2.0"
] | null | null | null | /* Copyright JS Foundation and other contributors, http://js.foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "jerryscript.h"
#include "test-common.h"
#define T(op, lhs, rhs, res) \
{ op, lhs, rhs, res }
typedef struct
{
jerry_binary_operation_t op;
jerry_value_t lhs;
jerry_value_t rhs;
bool expected;
} test_entry_t;
int
main (void)
{
TEST_INIT ();
jerry_init (JERRY_INIT_EMPTY);
jerry_value_t obj1 = jerry_eval ((const jerry_char_t *) "o={x:1};o", 9, JERRY_PARSE_NO_OPTS);
jerry_value_t obj2 = jerry_eval ((const jerry_char_t *) "o={x:1};o", 9, JERRY_PARSE_NO_OPTS);
jerry_value_t err1 = jerry_create_error (JERRY_ERROR_SYNTAX, (const jerry_char_t *) "error");
test_entry_t tests[] =
{
/* Testing strict equal comparison */
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_number (5.0), jerry_create_number (5.0), true),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_number (3.1), jerry_create_number (10), false),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_number (3.1), jerry_create_undefined (), false),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_number (3.1), jerry_create_boolean (true), false),
T (JERRY_BIN_OP_STRICT_EQUAL,
jerry_create_string ((const jerry_char_t *) "example string"),
jerry_create_string ((const jerry_char_t *) "example string"),
true),
T (JERRY_BIN_OP_STRICT_EQUAL,
jerry_create_string ((const jerry_char_t *) "example string"),
jerry_create_undefined (),
false),
T (JERRY_BIN_OP_STRICT_EQUAL,
jerry_create_string ((const jerry_char_t *) "example string"),
jerry_create_null (),
false),
T (JERRY_BIN_OP_STRICT_EQUAL,
jerry_create_string ((const jerry_char_t *) "example string"),
jerry_create_number (5.0),
false),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_undefined (), jerry_create_undefined (), true),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_undefined (), jerry_create_null (), false),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_null (), jerry_create_null (), true),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_boolean (true), jerry_create_boolean (true), true),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_boolean (true), jerry_create_boolean (false), false),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_boolean (false), jerry_create_boolean (true), false),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_boolean (false), jerry_create_boolean (false), true),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (obj1), jerry_acquire_value (obj1), true),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (obj1), jerry_acquire_value (obj2), false),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (obj2), jerry_acquire_value (obj1), false),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (obj1), jerry_create_null (), false),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (obj1), jerry_create_undefined (), false),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (obj1), jerry_create_boolean (true), false),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (obj1), jerry_create_boolean (false), false),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (obj1), jerry_create_number (5.0), false),
T (JERRY_BIN_OP_STRICT_EQUAL,
jerry_acquire_value (obj1),
jerry_create_string ((const jerry_char_t *) "example string"),
false),
/* Testing equal comparison */
T (JERRY_BIN_OP_EQUAL, jerry_create_number (5.0), jerry_create_number (5.0), true),
T (JERRY_BIN_OP_EQUAL, jerry_create_number (3.1), jerry_create_number (10), false),
T (JERRY_BIN_OP_EQUAL, jerry_create_number (3.1), jerry_create_undefined (), false),
T (JERRY_BIN_OP_EQUAL, jerry_create_number (3.1), jerry_create_boolean (true), false),
T (JERRY_BIN_OP_EQUAL,
jerry_create_string ((const jerry_char_t *) "example string"),
jerry_create_string ((const jerry_char_t *) "example string"),
true),
T (JERRY_BIN_OP_EQUAL,
jerry_create_string ((const jerry_char_t *) "example string"),
jerry_create_undefined (),
false),
T (JERRY_BIN_OP_EQUAL,
jerry_create_string ((const jerry_char_t *) "example string"),
jerry_create_null (),
false),
T (JERRY_BIN_OP_EQUAL,
jerry_create_string ((const jerry_char_t *) "example string"),
jerry_create_number (5.0),
false),
T (JERRY_BIN_OP_EQUAL, jerry_create_undefined (), jerry_create_undefined (), true),
T (JERRY_BIN_OP_EQUAL, jerry_create_undefined (), jerry_create_null (), true),
T (JERRY_BIN_OP_EQUAL, jerry_create_null (), jerry_create_null (), true),
T (JERRY_BIN_OP_EQUAL, jerry_create_boolean (true), jerry_create_boolean (true), true),
T (JERRY_BIN_OP_EQUAL, jerry_create_boolean (true), jerry_create_boolean (false), false),
T (JERRY_BIN_OP_EQUAL, jerry_create_boolean (false), jerry_create_boolean (true), false),
T (JERRY_BIN_OP_EQUAL, jerry_create_boolean (false), jerry_create_boolean (false), true),
T (JERRY_BIN_OP_EQUAL, jerry_acquire_value (obj1), jerry_acquire_value (obj1), true),
T (JERRY_BIN_OP_EQUAL, jerry_acquire_value (obj1), jerry_acquire_value (obj2), false),
T (JERRY_BIN_OP_EQUAL, jerry_acquire_value (obj2), jerry_acquire_value (obj1), false),
T (JERRY_BIN_OP_EQUAL, jerry_acquire_value (obj1), jerry_create_null (), false),
T (JERRY_BIN_OP_EQUAL, jerry_acquire_value (obj1), jerry_create_undefined (), false),
T (JERRY_BIN_OP_EQUAL, jerry_acquire_value (obj1), jerry_create_boolean (true), false),
T (JERRY_BIN_OP_EQUAL, jerry_acquire_value (obj1), jerry_create_boolean (false), false),
T (JERRY_BIN_OP_EQUAL, jerry_acquire_value (obj1), jerry_create_number (5.0), false),
T (JERRY_BIN_OP_EQUAL,
jerry_acquire_value (obj1),
jerry_create_string ((const jerry_char_t *) "example string"),
false),
/* Testing less comparison */
T (JERRY_BIN_OP_LESS, jerry_create_number (5.0), jerry_create_number (5.0), false),
T (JERRY_BIN_OP_LESS, jerry_create_number (3.1), jerry_create_number (10), true),
T (JERRY_BIN_OP_LESS, jerry_create_number (3.1), jerry_create_undefined (), false),
T (JERRY_BIN_OP_LESS, jerry_create_number (3.1), jerry_create_boolean (true), false),
T (JERRY_BIN_OP_LESS,
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_string ((const jerry_char_t *) "2"),
true),
T (JERRY_BIN_OP_LESS,
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_undefined (),
false),
T (JERRY_BIN_OP_LESS,
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_null (),
false),
T (JERRY_BIN_OP_LESS,
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_number (5.0),
true),
T (JERRY_BIN_OP_LESS, jerry_create_undefined (), jerry_create_undefined (), false),
T (JERRY_BIN_OP_LESS, jerry_create_undefined (), jerry_create_null (), false),
T (JERRY_BIN_OP_LESS, jerry_create_null (), jerry_create_null (), false),
T (JERRY_BIN_OP_LESS, jerry_create_boolean (true), jerry_create_boolean (true), false),
T (JERRY_BIN_OP_LESS, jerry_create_boolean (true), jerry_create_boolean (false), false),
T (JERRY_BIN_OP_LESS, jerry_create_boolean (false), jerry_create_boolean (true), true),
T (JERRY_BIN_OP_LESS, jerry_create_boolean (false), jerry_create_boolean (false), false),
/* Testing less or equal comparison */
T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_number (5.0), jerry_create_number (5.0), true),
T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_number (5.1), jerry_create_number (5.0), false),
T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_number (3.1), jerry_create_number (10), true),
T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_number (3.1), jerry_create_undefined (), false),
T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_number (3.1), jerry_create_boolean (true), false),
T (JERRY_BIN_OP_LESS_EQUAL,
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_string ((const jerry_char_t *) "2"),
true),
T (JERRY_BIN_OP_LESS_EQUAL,
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_string ((const jerry_char_t *) "1"),
true),
T (JERRY_BIN_OP_LESS_EQUAL,
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_undefined (),
false),
T (JERRY_BIN_OP_LESS_EQUAL,
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_null (),
false),
T (JERRY_BIN_OP_LESS_EQUAL,
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_number (5.0),
true),
T (JERRY_BIN_OP_LESS_EQUAL,
jerry_create_string ((const jerry_char_t *) "5.0"),
jerry_create_number (5.0),
true),
T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_undefined (), jerry_create_undefined (), false),
T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_undefined (), jerry_create_null (), false),
T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_null (), jerry_create_null (), true),
T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_boolean (true), jerry_create_boolean (true), true),
T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_boolean (true), jerry_create_boolean (false), false),
T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_boolean (false), jerry_create_boolean (true), true),
T (JERRY_BIN_OP_LESS_EQUAL, jerry_create_boolean (false), jerry_create_boolean (false), true),
/* Testing greater comparison */
T (JERRY_BIN_OP_GREATER, jerry_create_number (5.0), jerry_create_number (5.0), false),
T (JERRY_BIN_OP_GREATER, jerry_create_number (10), jerry_create_number (3.1), true),
T (JERRY_BIN_OP_GREATER, jerry_create_number (3.1), jerry_create_undefined (), false),
T (JERRY_BIN_OP_GREATER, jerry_create_number (3.1), jerry_create_boolean (true), true),
T (JERRY_BIN_OP_GREATER,
jerry_create_string ((const jerry_char_t *) "2"),
jerry_create_string ((const jerry_char_t *) "1"),
true),
T (JERRY_BIN_OP_GREATER,
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_string ((const jerry_char_t *) "2"),
false),
T (JERRY_BIN_OP_GREATER,
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_undefined (),
false),
T (JERRY_BIN_OP_GREATER,
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_null (),
true),
T (JERRY_BIN_OP_GREATER,
jerry_create_number (5.0),
jerry_create_string ((const jerry_char_t *) "1"),
true),
T (JERRY_BIN_OP_GREATER, jerry_create_undefined (), jerry_create_undefined (), false),
T (JERRY_BIN_OP_GREATER, jerry_create_undefined (), jerry_create_null (), false),
T (JERRY_BIN_OP_GREATER, jerry_create_null (), jerry_create_null (), false),
T (JERRY_BIN_OP_GREATER, jerry_create_boolean (true), jerry_create_boolean (true), false),
T (JERRY_BIN_OP_GREATER, jerry_create_boolean (true), jerry_create_boolean (false), true),
T (JERRY_BIN_OP_GREATER, jerry_create_boolean (false), jerry_create_boolean (true), false),
T (JERRY_BIN_OP_GREATER, jerry_create_boolean (false), jerry_create_boolean (false), false),
/* Testing greater or equal comparison */
T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_number (5.0), jerry_create_number (5.0), true),
T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_number (5.0), jerry_create_number (5.1), false),
T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_number (10), jerry_create_number (3.1), true),
T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_number (3.1), jerry_create_undefined (), false),
T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_number (3.1), jerry_create_boolean (true), true),
T (JERRY_BIN_OP_GREATER_EQUAL,
jerry_create_string ((const jerry_char_t *) "2"),
jerry_create_string ((const jerry_char_t *) "1"),
true),
T (JERRY_BIN_OP_GREATER_EQUAL,
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_string ((const jerry_char_t *) "1"),
true),
T (JERRY_BIN_OP_GREATER_EQUAL,
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_undefined (),
false),
T (JERRY_BIN_OP_GREATER_EQUAL,
jerry_create_string ((const jerry_char_t *) "1"),
jerry_create_null (),
true),
T (JERRY_BIN_OP_GREATER_EQUAL,
jerry_create_number (5.0),
jerry_create_string ((const jerry_char_t *) "1"),
true),
T (JERRY_BIN_OP_GREATER_EQUAL,
jerry_create_string ((const jerry_char_t *) "5.0"),
jerry_create_number (5.0),
true),
T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_undefined (), jerry_create_undefined (), false),
T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_undefined (), jerry_create_null (), false),
T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_null (), jerry_create_null (), true),
T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_boolean (true), jerry_create_boolean (true), true),
T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_boolean (true), jerry_create_boolean (false), true),
T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_boolean (false), jerry_create_boolean (true), false),
T (JERRY_BIN_OP_GREATER_EQUAL, jerry_create_boolean (false), jerry_create_boolean (false), true),
};
for (uint32_t idx = 0; idx < sizeof (tests) / sizeof (test_entry_t); idx++)
{
jerry_value_t result = jerry_binary_operation (tests[idx].op, tests[idx].lhs, tests[idx].rhs);
TEST_ASSERT (!jerry_value_is_error (result));
TEST_ASSERT (jerry_value_is_true (result) == tests[idx].expected);
jerry_release_value (tests[idx].lhs);
jerry_release_value (tests[idx].rhs);
jerry_release_value (result);
}
test_entry_t error_tests[] =
{
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (err1), jerry_acquire_value (err1), true),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_acquire_value (err1), jerry_create_undefined (), true),
T (JERRY_BIN_OP_STRICT_EQUAL, jerry_create_undefined (), jerry_acquire_value (err1), true),
};
for (uint32_t idx = 0; idx < sizeof (error_tests) / sizeof (test_entry_t); idx++)
{
jerry_value_t result = jerry_binary_operation (tests[idx].op, error_tests[idx].lhs, error_tests[idx].rhs);
TEST_ASSERT (jerry_value_is_error (result) == error_tests[idx].expected);
jerry_release_value (error_tests[idx].lhs);
jerry_release_value (error_tests[idx].rhs);
jerry_release_value (result);
}
jerry_release_value (obj1);
jerry_release_value (obj2);
jerry_release_value (err1);
jerry_cleanup ();
return 0;
} /* main */
| 50.745819 | 110 | 0.719831 |
0a14c6d38d212e47b181d909915eb9384e0446a0 | 367 | c | C | d/barriermnts/lothwaite/rooms/b12.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-07-19T05:24:44.000Z | 2021-11-18T04:08:19.000Z | d/barriermnts/lothwaite/rooms/b12.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 4 | 2021-03-15T18:56:39.000Z | 2021-08-17T17:08:22.000Z | d/barriermnts/lothwaite/rooms/b12.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-09-12T06:22:38.000Z | 2022-01-31T01:15:12.000Z | //b12.c - Lothwaite barrows. Circe 4/29/04
#include <std.h>
#include "../lothwaite.h"
inherit BARROWS;
void create(){
::create();
set_long( ::query_long()+"\n%^BLUE%^The passageway descends into "+
"dimness to the northwest and climbs steadily to the east.\n");
set_exits(([
"northwest" : PATHEXIT"b11",
"east" : PATHEXIT"b13",
]));
} | 26.214286 | 70 | 0.621253 |
135f1b6d4bc689b793035a4c43deec7333be06cd | 1,691 | h | C | include/c/methods/callbacks/ModCallbacks.h | MarkusRannare/modio-sdk | 70220009ac6c375bebd4b807de1e7f8a19680a41 | [
"MIT"
] | 42 | 2017-11-14T19:45:20.000Z | 2019-02-03T02:43:24.000Z | include/c/methods/callbacks/ModCallbacks.h | MarkusRannare/modio-sdk | 70220009ac6c375bebd4b807de1e7f8a19680a41 | [
"MIT"
] | 16 | 2019-05-09T02:14:02.000Z | 2020-09-03T05:35:49.000Z | include/c/methods/callbacks/ModCallbacks.h | MarkusRannare/modio-sdk | 70220009ac6c375bebd4b807de1e7f8a19680a41 | [
"MIT"
] | 15 | 2019-07-15T04:26:01.000Z | 2020-09-12T03:58:19.000Z | #ifndef MODIO_MODCALLBACKS_H
#define MODIO_MODCALLBACKS_H
#include "../../../Globals.h"
#include "../../../wrappers/MinizipWrapper.h"
#include "../../../wrappers/CurlWrapper.h"
#include "../../schemas/ModioResponse.h"
#include "../../schemas/ModioMod.h"
#include "../../../ModUtility.h"
#include "../../../ModioUtility.h"
struct GetModParams
{
void* object;
void (*callback)(void* object, ModioResponse response, ModioMod mod);
};
struct GetAllModsParams
{
std::string url;
bool is_cache;
std::vector<void*> objects;
std::vector<void(*)(void* object, ModioResponse response, ModioMod mods[], u32 mods_size)> callbacks;
};
struct AddModParams
{
void* object;
void (*callback)(void* object, ModioResponse response, ModioMod mod);
};
struct CallbackParamReturnsId
{
void* object;
u32 mod_id;
void (*callback)(void* object, ModioResponse response, u32 mod_id);
};
extern std::map< u32,GetModParams* > get_mod_callbacks;
extern std::map< u32,AddModParams* > add_mod_callbacks;
extern std::map< u32,GenericRequestParams* > delete_mod_callbacks;
extern std::map< u32,GetAllModsParams* > get_all_mods_callbacks;
extern std::map< u32,CallbackParamReturnsId* > return_id_callbacks;
void modioOnGetMod(u32 call_number, u32 response_code, nlohmann::json response_json);
void modioOnGetAllMods(u32 call_number, u32 response_code, nlohmann::json response_json);
void modioOnModAdded(u32 call_number, u32 response_code, nlohmann::json response_json);
void modioOnModDeleted(u32 call_number, u32 response_code, nlohmann::json response_json);
void modioOnReturnIdCallback(u32 call_number, u32 response_code, nlohmann::json response_json);
void clearModCallbackParams();
#endif
| 31.314815 | 103 | 0.758131 |
fb4e90a8b2149135cd1e53edd0084b838969720e | 1,941 | c | C | openbsd/sys/arch/sgi/pci/pciide_machdep.c | MarginC/kame | 2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30 | [
"BSD-3-Clause"
] | 91 | 2015-01-05T15:18:31.000Z | 2022-03-11T16:43:28.000Z | openbsd/sys/arch/sgi/pci/pciide_machdep.c | MarginC/kame | 2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30 | [
"BSD-3-Clause"
] | 1 | 2016-02-25T15:57:55.000Z | 2016-02-25T16:01:02.000Z | openbsd/sys/arch/sgi/pci/pciide_machdep.c | MarginC/kame | 2ef74fe29e4cca9b4a87a1d5041191a9e2e8be30 | [
"BSD-3-Clause"
] | 21 | 2015-02-07T08:23:07.000Z | 2021-12-14T06:01:49.000Z | /* $OpenBSD: pciide_machdep.c,v 1.2 2004/08/10 19:16:18 deraadt Exp $ */
/*
* Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
*
* 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 ``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 BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pciidereg.h>
#include <dev/pci/pciidevar.h>
#include <dev/isa/isavar.h>
void *
pciide_machdep_compat_intr_establish(dev, pa, chan, func, arg)
struct device *dev;
struct pci_attach_args *pa;
int chan;
int (*func) __P((void *));
void *arg;
{
void *cookie = (void *)4;
return (cookie);
}
void
pciide_machdep_compat_intr_disestablish(pc, p)
pci_chipset_tag_t pc;
void *p;
{
}
| 34.052632 | 77 | 0.74137 |
5ab2d0799adf967f99233b73d45b3de4f3e1bfcf | 392 | h | C | OMESetUp/Window1Controller.h | msyk/OME | 79bad6964ac4516ec03714597700884878052fda | [
"MIT"
] | null | null | null | OMESetUp/Window1Controller.h | msyk/OME | 79bad6964ac4516ec03714597700884878052fda | [
"MIT"
] | null | null | null | OMESetUp/Window1Controller.h | msyk/OME | 79bad6964ac4516ec03714597700884878052fda | [
"MIT"
] | null | null | null | //
// $Id: Window1Controller.h,v 1.3 2007/10/02 13:45:36 msyk Exp $
//
// Window1Controller.h for OMESetUp
//
// Created by Shinya Wakimoto.
// Revision 1.1, Sun Jul 24 16:49:45 2005 UTC
// Copyright (c) 2005, Shinya Wakimoto. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <OME/OME.h>
@interface Window1Controller : NSWindowController
- (IBAction)nextPage:(id)sender;
@end
| 20.631579 | 65 | 0.696429 |
de01c94aba8536e32b8027ae4299f2846a675d92 | 4,870 | h | C | src/math/median.h | rsrg/ac_sc_grinder | 8f356d63a9e19cb0ab96740df264dba7830b99a6 | [
"MIT"
] | 80 | 2018-12-05T17:01:27.000Z | 2022-03-28T01:27:50.000Z | src/math/median.h | rsrg/ac_sc_grinder | 8f356d63a9e19cb0ab96740df264dba7830b99a6 | [
"MIT"
] | 6 | 2018-08-19T23:13:51.000Z | 2021-08-08T00:09:19.000Z | src/math/median.h | rsrg/ac_sc_grinder | 8f356d63a9e19cb0ab96740df264dba7830b99a6 | [
"MIT"
] | 22 | 2018-08-29T16:05:01.000Z | 2020-11-23T06:09:31.000Z | #ifndef __MEDIAN_TEMPLATE__
#define __MEDIAN_TEMPLATE__
// Iteratively calculates median for up to SIZE data, and ignores the rest after
// overflow.
//
// Useful for interrupt-driven data fill, to minimize possible locks.
// Worst case ~ scan of 1/2 collected elements.
//
// How it works (in general): https://stackoverflow.com/a/15319593/1031804
template <typename T, int SIZE>
class MedianIteratorTemplate {
public:
MedianIteratorTemplate() {
reset();
}
void reset()
{
heap_lo_len = 0;
heap_hi_len = 0;
heap_lo_max_idx = 0;
heap_hi_min_idx = 0;
}
T result()
{
int total_len = heap_lo_len + heap_hi_len;
// If not enougth data, create result manually
switch (total_len){
case 0: return 0;
case 1: return heap_lo[0];
case 2: return (heap_lo[0] + heap_hi[0]) / 2;
}
if (total_len & 0x01)
{
return (heap_lo_len > heap_hi_len) ? heap_lo[heap_lo_max_idx] : heap_hi[heap_hi_min_idx];
}
return (heap_lo[heap_lo_max_idx] + heap_hi[heap_hi_min_idx]) / 2;
}
void add(T val) {
// Process special cases
switch (heap_lo_len + heap_hi_len) {
case 0:
// First data => push to low heap
heap_lo[0] = val;
heap_lo_len = 1;
return;
case 1:
// Second data => low and high heaps should contain per 1 element each
// at the end. Reorder if needed.
if (val < heap_lo[0])
{
heap_hi[0] = heap_lo[0];
heap_lo[0] = val;
}
else heap_hi[0] = val;
heap_hi_len = 1;
return;
case SIZE:
// If all buffers occupied - stop accepting new data
return;
}
// Now we have enough to start with safe min/max searches.
T lo_max_val = heap_lo[heap_lo_max_idx];
T hi_min_val = heap_hi[heap_hi_min_idx];
if (val < lo_max_val)
{
// New value must go to low heap
if (heap_lo_len > heap_hi_len)
{
// Ups... curent size "too big" => transfer existing max to high heap
// (and put new value to it's place)
heap_hi[heap_hi_len] = lo_max_val;
heap_hi_min_idx = heap_hi_len;
heap_hi_len++;
// Need refresh max after such update
heap_lo[heap_lo_max_idx] = val;
heap_lo_max_idx = get_heap_lo_max_idx();
}
else
{
// Just add value to low heap
heap_lo[heap_lo_len++] = val;
}
}
else if (val >= hi_min_val)
{
// New value must go to high heap
if (heap_hi_len > heap_lo_len)
{
// Ups... curent size "too big" => transfer existing min to low heap
// (and put new value to it's place)
heap_lo[heap_lo_len] = hi_min_val;
heap_lo_max_idx = heap_lo_len;
heap_lo_len++;
// Need refresh min after such update
heap_hi[heap_hi_min_idx] = val;
heap_hi_min_idx = get_heap_hi_min_idx();
}
else
{
// Just add value to heap_hi
heap_hi[heap_hi_len++] = val;
}
}
else
{
// Value is somewhere "between" heaps => try push to lower heap,
// if it's size is not too big
if (heap_lo_len > heap_hi_len)
{
// No space in low heap => push to high one
heap_hi[heap_hi_len] = val;
heap_hi_min_idx = heap_hi_len;
heap_hi_len++;
}
else
{
heap_lo[heap_lo_len] = val;
heap_lo_max_idx = heap_lo_len;
heap_lo_len++;
}
}
}
private:
T heap_lo[SIZE / 2 + (SIZE & 1)];
int heap_lo_len;
int heap_lo_max_idx;
T heap_hi[SIZE / 2 + (SIZE & 1)];
int heap_hi_len;
int heap_hi_min_idx;
int get_heap_lo_max_idx()
{
int i, idx;
i = idx = heap_lo_len - 1;
T val = heap_lo[i];
while (i--) {
int tmp = heap_lo[i];
if (tmp > val) { val = tmp; idx = i; }
}
return idx;
}
int get_heap_hi_min_idx()
{
int i, idx;
i = idx = heap_hi_len - 1;
T val = heap_hi[i];
while (i--) {
int tmp = heap_hi[i];
if (tmp < val) { val = tmp; idx = i; }
}
return idx;
}
};
#endif
| 27.359551 | 101 | 0.486653 |
2047ae592870e1f414abcb93f5b39f582b6e0c1e | 162 | h | C | Projekt/mpiHelper.h | wjch-krl/prir | 796abca6c2fd4d92e785ce75c7dbd7750b7f34d7 | [
"MIT"
] | null | null | null | Projekt/mpiHelper.h | wjch-krl/prir | 796abca6c2fd4d92e785ce75c7dbd7750b7f34d7 | [
"MIT"
] | null | null | null | Projekt/mpiHelper.h | wjch-krl/prir | 796abca6c2fd4d92e785ce75c7dbd7750b7f34d7 | [
"MIT"
] | null | null | null | //
// Created by Wojciech Król on 24.01.2016.
//
#ifndef PROJEKT_MPIHELPER_H
#define PROJEKT_MPIHELPER_H
#include "mpiHelper.cpp"
#endif //PROJEKT_MPIHELPER_H
| 14.727273 | 42 | 0.765432 |
eea8888f0a615a550af263cb9571c23ed2fc77ba | 2,189 | h | C | src/utils/histogram_2d.h | h2ssh/Vulcan | cc46ec79fea43227d578bee39cb4129ad9bb1603 | [
"MIT"
] | 6 | 2020-03-29T09:37:01.000Z | 2022-01-20T08:56:31.000Z | src/utils/histogram_2d.h | h2ssh/Vulcan | cc46ec79fea43227d578bee39cb4129ad9bb1603 | [
"MIT"
] | 1 | 2021-03-05T08:00:50.000Z | 2021-03-05T08:00:50.000Z | src/utils/histogram_2d.h | h2ssh/Vulcan | cc46ec79fea43227d578bee39cb4129ad9bb1603 | [
"MIT"
] | 11 | 2019-05-13T00:04:38.000Z | 2022-01-20T08:56:38.000Z | /* Copyright (C) 2010-2019, The Regents of The University of Michigan.
All rights reserved.
This software was developed as part of the The Vulcan project in the Intelligent Robotics Lab
under the direction of Benjamin Kuipers, kuipers@umich.edu. Use of this code is governed by an
MIT-style License that can be found at "https://github.com/h2ssh/Vulcan".
*/
#ifndef UTILS_HISTOGRAM_2D_H
#define UTILS_HISTOGRAM_2D_H
#include <utils/cell_grid.h>
#include <vector>
namespace vulcan
{
namespace utils
{
/**
*
*/
class Histogram2D
{
public:
/**
* Create a histogram with a fixed range of values.
*
* \pre minValue < maxValue
* \pre numBins > 0
* \param minValue Minimum value that can go in the histogram
* \param maxValue Maximum value for the histogram
* \param numBins Numbers of bins for the histogram
*/
Histogram2D(double minX, double maxX, double minY, double maxY, int numBins);
/**
* addValue adds another value to the stored histogram data.
*/
void addValue(double x, double y);
/**
* Normalize the count of bins to the range [0, 1].
*
* NOTE: Normalization is destructive and can only occur once. Add all values and then normalize right now.
*
* Attempts to normalize multiple times will fail with a warning.
*
* \return True if normalization was performed. False otherwise.
*/
bool normalize(void);
/**
* Find the maximum value stored in a histogram bin.
*/
double max(void) const;
/**
* clear clears all data from the histogram.
*/
void clear(void);
/**
* Retrieve the number of values added to the histogram.
*/
std::size_t numValues(void) const { return values_.size(); }
/**
* Draw the histogram using Gnuplot.
*/
void plot(const std::string& title,
const std::string& xLabel,
const std::string& yLabel,
double maxCbrange);
private:
utils::CellGrid<double> bins_;
std::vector<Point<double>> values_;
bool isNormalized_ = false;
};
} // namespace utils
} // namespace vulcan
#endif // UTILS_HISTOGRAM_2D_H
| 24.595506 | 110 | 0.652353 |
7c51fb69965a645287be326d1464967d1b94f147 | 809 | h | C | src/blinkit/blink_impl/posix_thread.h | titilima/blink | 2de70073edfe0e1e0aaf2bb22b5d6abd9b776fad | [
"MIT"
] | 13 | 2020-04-21T13:14:00.000Z | 2021-11-13T14:55:12.000Z | src/blinkit/blink_impl/posix_thread.h | titilima/blink | 2de70073edfe0e1e0aaf2bb22b5d6abd9b776fad | [
"MIT"
] | null | null | null | src/blinkit/blink_impl/posix_thread.h | titilima/blink | 2de70073edfe0e1e0aaf2bb22b5d6abd9b776fad | [
"MIT"
] | 4 | 2020-04-21T13:15:43.000Z | 2021-11-13T14:55:00.000Z | // -------------------------------------------------
// BlinKit - BlinKit Library
// -------------------------------------------------
// File Name: posix_thread.h
// Description: PosixThread Class
// Author: Ziming Li
// Created: 2020-04-19
// -------------------------------------------------
// Copyright (C) 2020 MingYang Software Technology.
// -------------------------------------------------
#ifndef BLINKIT_BLINKIT_POSIX_THREAD_H
#define BLINKIT_BLINKIT_POSIX_THREAD_H
#pragma once
#include "blinkit/blink_impl/thread_impl.h"
namespace BlinKit {
class PosixThread final : public ThreadImpl
{
private:
// Thread overrides
std::shared_ptr<base::SingleThreadTaskRunner> GetTaskRunner(void) const override;
};
} // namespace BlinKit
#endif // BLINKIT_BLINKIT_POSIX_THREAD_H
| 26.096774 | 85 | 0.557478 |
1051e8cd6d6c2507080719af87d30412637b1543 | 21,524 | h | C | tools/usbboot/include/omap4/hw.h | lambdaxymox/barrelfish | 06a9f54721a8d96874a8939d8973178a562c342f | [
"MIT"
] | 111 | 2015-02-03T02:57:27.000Z | 2022-03-01T23:57:09.000Z | tools/usbboot/include/omap4/hw.h | lambdaxymox/barrelfish | 06a9f54721a8d96874a8939d8973178a562c342f | [
"MIT"
] | 12 | 2016-03-22T14:44:32.000Z | 2020-03-18T13:30:29.000Z | tools/usbboot/include/omap4/hw.h | lambdaxymox/barrelfish | 06a9f54721a8d96874a8939d8973178a562c342f | [
"MIT"
] | 55 | 2015-02-03T05:28:12.000Z | 2022-03-31T05:00:03.000Z | /*
* cpu.h
*
* Copyright(c) 2010 Texas Instruments. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name Texas Instruments nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _OMAP44XX_CPU_H
#define _OMAP44XX_CPU_H
/*
* 4430 specific Section
*/
/* Stuff on L3 Interconnect */
/* L3 Firewall */
#define A_REQINFOPERM0 (SMX_APE_BASE + 0x05048)
#define A_READPERM0 (SMX_APE_BASE + 0x05050)
#define A_WRITEPERM0 (SMX_APE_BASE + 0x05058)
#define OMAP44XX_SDRC_BASE 0x6D000000
#define OMAP44XX_SMS_BASE 0x6C000000
#define SMX_APE_BASE 0x68000000
#define OMAP44XX_GPMC_BASE 0x50000000
#define OMAP44XX_DMM_BASE 0x4E000000
#define OMAP44XX_L4_IO_BASE 0x4A000000
#define OMAP44XX_WAKEUP_L4_IO_BASE 0x4A300000
#define OMAP44XX_L4_PER 0x48000000
/*
* L4 Peripherals - L4 Wakeup and L4 Core now
*/
/* CONTROL */
#define OMAP44XX_CTRL_GEN_BASE (OMAP44XX_L4_IO_BASE+0x2000)
#define OMAP44XX_CTRL_PADCONF_CORE_BASE 0x4a100000
/* PL310 */
#define OMAP44XX_PL310_BASE 0x48242000
/* TAP information dont know for 3430*/
#define OMAP44XX_TAP_BASE (0x49000000) /*giving some junk for virtio */
/* UART */
#define OMAP44XX_UART1 (OMAP44XX_L4_PER+0x6a000)
#define OMAP44XX_UART2 (OMAP44XX_L4_PER+0x6c000)
#define OMAP44XX_UART3 (OMAP44XX_L4_PER+0x20000)
#define OMAP44XX_UART4 (OMAP44XX_L4_PER+0x6e000)
/* General Purpose Timers */
#define OMAP44XX_GPT1 0x48318000
#define OMAP44XX_GPT2 0x48032000
#define OMAP44XX_GPT3 0x48034000
#define OMAP44XX_GPT4 0x48036000
#define OMAP44XX_GPT5 0x40138000
#define OMAP44XX_GPT6 0x4013A000
#define OMAP44XX_GPT7 0x4013C000
#define OMAP44XX_GPT8 0x4013E000
#define OMAP44XX_GPT9 0x48040000
#define OMAP44XX_GPT10 0x48086000
#define OMAP44XX_GPT11 0x48088000
#define OMAP44XX_GPT12 0x48304000
/* WatchDog Timers (1 secure, 3 GP) */
#define WD1_BASE 0x4A322000
#define WD2_BASE 0x4A314000
#define WD3_BASE 0x40130000
/* 32KTIMER */
#define SYNC_32KTIMER_BASE (0x48320000)
#define S32K_CR (SYNC_32KTIMER_BASE+0x10)
/* Register offsets of common modules */
/* Control */
#define CONTROL_ID_CODE (OMAP44XX_CTRL_GEN_BASE + 0x204)
#define CONTROL_STATUS (OMAP44XX_CTRL_GEN_BASE + 0x2C4)
/* PL310 */
#define OMAP44XX_PL310_AUX_CTRL (OMAP44XX_PL310_BASE + 0x104)
/* Tap Information */
#define TAP_IDCODE_REG (OMAP44XX_TAP_BASE+0x204)
#define PRODUCTION_ID (OMAP44XX_TAP_BASE+0x208)
/* device type */
#define DEVICE_MASK (0x03 << 8)
#define TST_DEVICE 0x0
#define EMU_DEVICE 0x1
#define HS_DEVICE 0x2
#define GP_DEVICE 0x3
/* GPMC CS3/cs4/cs6 not avaliable */
#define GPMC_BASE (OMAP44XX_GPMC_BASE)
#define GPMC_SYSCONFIG (OMAP44XX_GPMC_BASE+0x10)
#define GPMC_IRQSTATUS (OMAP44XX_GPMC_BASE+0x18)
#define GPMC_IRQENABLE (OMAP44XX_GPMC_BASE+0x1C)
#define GPMC_TIMEOUT_CONTROL (OMAP44XX_GPMC_BASE+0x40)
#define GPMC_CONFIG (OMAP44XX_GPMC_BASE+0x50)
#define GPMC_STATUS (OMAP44XX_GPMC_BASE+0x54)
#define GPMC_CONFIG_CS0 (OMAP44XX_GPMC_BASE+0x60)
#define GPMC_CONFIG_WIDTH (0x30)
#define GPMC_CONFIG1 (0x00)
#define GPMC_CONFIG2 (0x04)
#define GPMC_CONFIG3 (0x08)
#define GPMC_CONFIG4 (0x0C)
#define GPMC_CONFIG5 (0x10)
#define GPMC_CONFIG6 (0x14)
#define GPMC_CONFIG7 (0x18)
#define GPMC_NAND_CMD (0x1C)
#define GPMC_NAND_ADR (0x20)
#define GPMC_NAND_DAT (0x24)
#define GPMC_ECC_CONFIG (0x1F4)
#define GPMC_ECC_CONTROL (0x1F8)
#define GPMC_ECC_SIZE_CONFIG (0x1FC)
#define GPMC_ECC1_RESULT (0x200)
#define GPMC_ECC2_RESULT (0x204)
#define GPMC_ECC3_RESULT (0x208)
#define GPMC_ECC4_RESULT (0x20C)
#define GPMC_ECC5_RESULT (0x210)
#define GPMC_ECC6_RESULT (0x214)
#define GPMC_ECC7_RESULT (0x218)
#define GPMC_ECC8_RESULT (0x21C)
#define GPMC_ECC9_RESULT (0x220)
#define GPMC_PREFETCH_CONFIG1 (0x1e0)
#define GPMC_PREFETCH_CONFIG2 (0x1e4)
#define GPMC_PREFETCH_CONTROL (0x1ec)
#define GPMC_PREFETCH_STATUS (0x1f0)
/* GPMC Mapping */
# define FLASH_BASE 0x10000000 /* NOR flash (aligned to 256 Meg) */
# define FLASH_BASE_SDPV1 0x04000000 /* NOR flash (aligned to 64 Meg) */
# define FLASH_BASE_SDPV2 0x10000000 /* NOR flash (aligned to 256 Meg) */
# define DEBUG_BASE 0x08000000 /* debug board */
# define NAND_BASE 0x30000000 /* NAND addr (actual size small port)*/
# define PISMO2_BASE 0x18000000 /* PISMO2 CS1/2 */
# define ONENAND_MAP 0x20000000 /* OneNand addr (actual size small port */
/* DMM */
#define DMM_SYSCONFIG (OMAP44XX_DMM_BASE+0x10)
#define DMM_LISA_MAP (OMAP44XX_DMM_BASE+0x100)
/* SMS */
#define SMS_SYSCONFIG (OMAP44XX_SMS_BASE+0x10)
#define SMS_RG_ATT0 (OMAP44XX_SMS_BASE+0x48)
#define SMS_CLASS_ARB0 (OMAP44XX_SMS_BASE+0xD0)
#define BURSTCOMPLETE_GROUP7 (1<<31)
#define SDRC_CS_CFG (OMAP44XX_SDRC_BASE+0x40)
#define OMAP44XX_SDRC_CS0 0x80000000
#define SDRC_POWER (OMAP44XX_SDRC_BASE+0x70)
#define SDRC_MCFG_0 (OMAP44XX_SDRC_BASE+0x80)
#define SDRC_MR_0 (OMAP44XX_SDRC_BASE+0x84)
/* timer regs offsets (32 bit regs) */
#define TIDR 0x0 /* r */
#define TIOCP_CFG 0x10 /* rw */
#define TISTAT 0x14 /* r */
#define TISR 0x18 /* rw */
#define TIER 0x1C /* rw */
#define TWER 0x20 /* rw */
#define TCLR 0x24 /* rw */
#define TCRR 0x28 /* rw */
#define TLDR 0x2C /* rw */
#define TTGR 0x30 /* rw */
#define TWPS 0x34 /* r */
#define TMAR 0x38 /* rw */
#define TCAR1 0x3c /* r */
#define TSICR 0x40 /* rw */
#define TCAR2 0x44 /* r */
#define GPT_EN 0x03 /* enable sys_clk NO-prescale /1 */
/* Watchdog */
#define WWPS 0x34 /* r */
#define WSPR 0x48 /* rw */
#define WD_UNLOCK1 0xAAAA
#define WD_UNLOCK2 0x5555
/* FIXME */
#define PRM_RSTCTRL 0x48307250
/* PRCM */
#define CM_SYS_CLKSEL 0x4a306110
/* PRM.CKGEN module registers */
#define CM_ABE_PLL_REF_CLKSEL 0x4a30610c
#define OMAP44XX_WKUP_CTRL_BASE 0x4A31E000
/* PRM.WKUP_CM module registers */
#define CM_WKUP_CLKSTCTRL 0x4a307800
#define CM_WKUP_L4WKUP_CLKCTRL 0x4a307820
#define CM_WKUP_WDT1_CLKCTRL 0x4a307828
#define CM_WKUP_WDT2_CLKCTRL 0x4a307830
#define CM_WKUP_GPIO1_CLKCTRL 0x4a307838
#define CM_WKUP_TIMER1_CLKCTRL 0x4a307840
#define CM_WKUP_TIMER12_CLKCTRL 0x4a307848
#define CM_WKUP_SYNCTIMER_CLKCTRL 0x4a307850
#define CM_WKUP_USIM_CLKCTRL 0x4a307858
#define CM_WKUP_SARRAM_CLKCTRL 0x4a307860
#define CM_WKUP_KEYBOARD_CLKCTRL 0x4a307878
#define CM_WKUP_RTC_CLKCTRL 0x4a307880
#define CM_WKUP_BANDGAP_CLKCTRL 0x4a307888
/* CM1.CKGEN module registers */
#define CM_CLKSEL_CORE 0x4a004100
#define CM_CLKSEL_ABE 0x4a004108
#define CM_DLL_CTRL 0x4a004110
#define CM_CLKMODE_DPLL_CORE 0x4a004120
#define CM_IDLEST_DPLL_CORE 0x4a004124
#define CM_AUTOIDLE_DPLL_CORE 0x4a004128
#define CM_CLKSEL_DPLL_CORE 0x4a00412c
#define CM_DIV_M2_DPLL_CORE 0x4a004130
#define CM_DIV_M3_DPLL_CORE 0x4a004134
#define CM_DIV_M4_DPLL_CORE 0x4a004138
#define CM_DIV_M5_DPLL_CORE 0x4a00413c
#define CM_DIV_M6_DPLL_CORE 0x4a004140
#define CM_DIV_M7_DPLL_CORE 0x4a004144
#define CM_SSC_DELTAMSTEP_DPLL_CORE 0x4a004148
#define CM_SSC_MODFREQDIV_DPLL_CORE 0x4a00414c
#define CM_EMU_OVERRIDE_DPLL_CORE 0x4a004150
#define CM_CLKMODE_DPLL_MPU 0x4a004160
#define CM_IDLEST_DPLL_MPU 0x4a004164
#define CM_AUTOIDLE_DPLL_MPU 0x4a004168
#define CM_CLKSEL_DPLL_MPU 0x4a00416c
#define CM_DIV_M2_DPLL_MPU 0x4a004170
#define CM_SSC_DELTAMSTEP_DPLL_MPU 0x4a004188
#define CM_SSC_MODFREQDIV_DPLL_MPU 0x4a00418c
#define CM_BYPCLK_DPLL_MPU 0x4a00419c
#define CM_CLKMODE_DPLL_IVA 0x4a0041a0
#define CM_IDLEST_DPLL_IVA 0x4a0041a4
#define CM_AUTOIDLE_DPLL_IVA 0x4a0041a8
#define CM_CLKSEL_DPLL_IVA 0x4a0041ac
#define CM_DIV_M4_DPLL_IVA 0x4a0041b8
#define CM_DIV_M5_DPLL_IVA 0x4a0041bc
#define CM_SSC_DELTAMSTEP_DPLL_IVA 0x4a0041c8
#define CM_SSC_MODFREQDIV_DPLL_IVA 0x4a0041cc
#define CM_BYPCLK_DPLL_IVA 0x4a0041dc
#define CM_CLKMODE_DPLL_ABE 0x4a0041e0
#define CM_IDLEST_DPLL_ABE 0x4a0041e4
#define CM_AUTOIDLE_DPLL_ABE 0x4a0041e8
#define CM_CLKSEL_DPLL_ABE 0x4a0041ec
#define CM_DIV_M2_DPLL_ABE 0x4a0041f0
#define CM_DIV_M3_DPLL_ABE 0x4a0041f4
#define CM_SSC_DELTAMSTEP_DPLL_ABE 0x4a004208
#define CM_SSC_MODFREQDIV_DPLL_ABE 0x4a00420c
#define CM_CLKMODE_DPLL_DDRPHY 0x4a004220
#define CM_IDLEST_DPLL_DDRPHY 0x4a004224
#define CM_AUTOIDLE_DPLL_DDRPHY 0x4a004228
#define CM_CLKSEL_DPLL_DDRPHY 0x4a00422c
#define CM_DIV_M2_DPLL_DDRPHY 0x4a004230
#define CM_DIV_M4_DPLL_DDRPHY 0x4a004238
#define CM_DIV_M5_DPLL_DDRPHY 0x4a00423c
#define CM_DIV_M6_DPLL_DDRPHY 0x4a004240
#define CM_SSC_DELTAMSTEP_DPLL_DDRPHY 0x4a004248
/* CM1.ABE register offsets */
#define CM1_ABE_CLKSTCTRL 0x4a004500
#define CM1_ABE_L4ABE_CLKCTRL 0x4a004520
#define CM1_ABE_AESS_CLKCTRL 0x4a004528
#define CM1_ABE_PDM_CLKCTRL 0x4a004530
#define CM1_ABE_DMIC_CLKCTRL 0x4a004538
#define CM1_ABE_MCASP_CLKCTRL 0x4a004540
#define CM1_ABE_MCBSP1_CLKCTRL 0x4a004548
#define CM1_ABE_MCBSP2_CLKCTRL 0x4a004550
#define CM1_ABE_MCBSP3_CLKCTRL 0x4a004558
#define CM1_ABE_SLIMBUS_CLKCTRL 0x4a004560
#define CM1_ABE_TIMER5_CLKCTRL 0x4a004568
#define CM1_ABE_TIMER6_CLKCTRL 0x4a004570
#define CM1_ABE_TIMER7_CLKCTRL 0x4a004578
#define CM1_ABE_TIMER8_CLKCTRL 0x4a004580
#define CM1_ABE_WDT3_CLKCTRL 0x4a004588
/* CM1.DSP register offsets */
#define DSP_CLKSTCTRL 0x4a004400
#define DSP_DSP_CLKCTRL 0x4a004420
/* CM2.CKGEN module registers */
#define CM_CLKSEL_DUCATI_ISS_ROOT 0x4a008100
#define CM_CLKSEL_USB_60MHz 0x4a008104
#define CM_SCALE_FCLK 0x4a008108
#define CM_CORE_DVFS_PERF1 0x4a008110
#define CM_CORE_DVFS_PERF2 0x4a008114
#define CM_CORE_DVFS_PERF3 0x4a008118
#define CM_CORE_DVFS_PERF4 0x4a00811c
#define CM_CORE_DVFS_CURRENT 0x4a008124
#define CM_IVA_DVFS_PERF_TESLA 0x4a008128
#define CM_IVA_DVFS_PERF_IVAHD 0x4a00812c
#define CM_IVA_DVFS_PERF_ABE 0x4a008130
#define CM_IVA_DVFS_CURRENT 0x4a008138
#define CM_CLKMODE_DPLL_PER 0x4a008140
#define CM_IDLEST_DPLL_PER 0x4a008144
#define CM_AUTOIDLE_DPLL_PER 0x4a008148
#define CM_CLKSEL_DPLL_PER 0x4a00814c
#define CM_DIV_M2_DPLL_PER 0x4a008150
#define CM_DIV_M3_DPLL_PER 0x4a008154
#define CM_DIV_M4_DPLL_PER 0x4a008158
#define CM_DIV_M5_DPLL_PER 0x4a00815c
#define CM_DIV_M6_DPLL_PER 0x4a008160
#define CM_DIV_M7_DPLL_PER 0x4a008164
#define CM_SSC_DELTAMSTEP_DPLL_PER 0x4a008168
#define CM_SSC_MODFREQDIV_DPLL_PER 0x4a00816c
#define CM_EMU_OVERRIDE_DPLL_PER 0x4a008170
#define CM_CLKMODE_DPLL_USB 0x4a008180
#define CM_IDLEST_DPLL_USB 0x4a008184
#define CM_AUTOIDLE_DPLL_USB 0x4a008188
#define CM_CLKSEL_DPLL_USB 0x4a00818c
#define CM_DIV_M2_DPLL_USB 0x4a008190
#define CM_SSC_DELTAMSTEP_DPLL_USB 0x4a0081a8
#define CM_SSC_MODFREQDIV_DPLL_USB 0x4a0081ac
#define CM_CLKDCOLDO_DPLL_USB 0x4a0081b4
#define CM_CLKMODE_DPLL_UNIPRO 0x4a0081c0
#define CM_IDLEST_DPLL_UNIPRO 0x4a0081c4
#define CM_AUTOIDLE_DPLL_UNIPRO 0x4a0081c8
#define CM_CLKSEL_DPLL_UNIPRO 0x4a0081cc
#define CM_DIV_M2_DPLL_UNIPRO 0x4a0081d0
#define CM_SSC_DELTAMSTEP_DPLL_UNIPRO 0x4a0081e8
#define CM_SSC_MODFREQDIV_DPLL_UNIPRO 0x4a0081ec
/* CM2.CORE module registers */
#define CM_L3_1_CLKSTCTRL 0x4a008700
#define CM_L3_1_DYNAMICDEP 0x4a008708
#define CM_L3_1_L3_1_CLKCTRL 0x4a008720
#define CM_L3_2_CLKSTCTRL 0x4a008800
#define CM_L3_2_DYNAMICDEP 0x4a008808
#define CM_L3_2_L3_2_CLKCTRL 0x4a008820
#define CM_L3_2_GPMC_CLKCTRL 0x4a008828
#define CM_L3_2_OCMC_RAM_CLKCTRL 0x4a008830
#define CM_DUCATI_CLKSTCTRL 0x4a008900
#define CM_DUCATI_STATICDEP 0x4a008904
#define CM_DUCATI_DYNAMICDEP 0x4a008908
#define CM_DUCATI_DUCATI_CLKCTRL 0x4a008920
#define CM_SDMA_CLKSTCTRL 0x4a008a00
#define CM_SDMA_STATICDEP 0x4a008a04
#define CM_SDMA_DYNAMICDEP 0x4a008a08
#define CM_SDMA_SDMA_CLKCTRL 0x4a008a20
#define CM_MEMIF_CLKSTCTRL 0x4a008b00
#define CM_MEMIF_DMM_CLKCTRL 0x4a008b20
#define CM_MEMIF_EMIF_FW_CLKCTRL 0x4a008b28
#define CM_MEMIF_EMIF_1_CLKCTRL 0x4a008b30
#define CM_MEMIF_EMIF_2_CLKCTRL 0x4a008b38
#define CM_MEMIF_DLL_CLKCTRL 0x4a008b40
#define CM_MEMIF_EMIF_H1_CLKCTRL 0x4a008b50
#define CM_MEMIF_EMIF_H2_CLKCTRL 0x4a008b58
#define CM_MEMIF_DLL_H_CLKCTRL 0x4a008b60
#define CM_D2D_CLKSTCTRL 0x4a008c00
#define CM_D2D_STATICDEP 0x4a008c04
#define CM_D2D_DYNAMICDEP 0x4a008c08
#define CM_D2D_SAD2D_CLKCTRL 0x4a008c20
#define CM_D2D_MODEM_ICR_CLKCTRL 0x4a008c28
#define CM_D2D_SAD2D_FW_CLKCTRL 0x4a008c30
#define CM_L4CFG_CLKSTCTRL 0x4a008d00
#define CM_L4CFG_DYNAMICDEP 0x4a008d08
#define CM_L4CFG_L4_CFG_CLKCTRL 0x4a008d20
#define CM_L4CFG_HW_SEM_CLKCTRL 0x4a008d28
#define CM_L4CFG_MAILBOX_CLKCTRL 0x4a008d30
#define CM_L4CFG_SAR_ROM_CLKCTRL 0x4a008d38
#define CM_L3INSTR_CLKSTCTRL 0x4a008e00
#define CM_L3INSTR_L3_3_CLKCTRL 0x4a008e20
#define CM_L3INSTR_L3_INSTR_CLKCTRL 0x4a008e28
#define CM_L3INSTR_OCP_WP1_CLKCTRL 0x4a008e40
/* CM2.L4PER register offsets */
#define CM_L4PER_CLKSTCTRL 0x4a009400
#define CM_L4PER_DYNAMICDEP 0x4a009408
#define CM_L4PER_ADC_CLKCTRL 0x4a009420
#define CM_L4PER_DMTIMER10_CLKCTRL 0x4a009428
#define CM_L4PER_DMTIMER11_CLKCTRL 0x4a009430
#define CM_L4PER_DMTIMER2_CLKCTRL 0x4a009438
#define CM_L4PER_DMTIMER3_CLKCTRL 0x4a009440
#define CM_L4PER_DMTIMER4_CLKCTRL 0x4a009448
#define CM_L4PER_DMTIMER9_CLKCTRL 0x4a009450
#define CM_L4PER_ELM_CLKCTRL 0x4a009458
#define CM_L4PER_GPIO2_CLKCTRL 0x4a009460
#define CM_L4PER_GPIO3_CLKCTRL 0x4a009468
#define CM_L4PER_GPIO4_CLKCTRL 0x4a009470
#define CM_L4PER_GPIO5_CLKCTRL 0x4a009478
#define CM_L4PER_GPIO6_CLKCTRL 0x4a009480
#define CM_L4PER_HDQ1W_CLKCTRL 0x4a009488
#define CM_L4PER_HECC1_CLKCTRL 0x4a009490
#define CM_L4PER_HECC2_CLKCTRL 0x4a009498
#define CM_L4PER_I2C1_CLKCTRL 0x4a0094a0
#define CM_L4PER_I2C2_CLKCTRL 0x4a0094a8
#define CM_L4PER_I2C3_CLKCTRL 0x4a0094b0
#define CM_L4PER_I2C4_CLKCTRL 0x4a0094b8
#define CM_L4PER_L4PER_CLKCTRL 0x4a0094c0
#define CM_L4PER_MCASP2_CLKCTRL 0x4a0094d0
#define CM_L4PER_MCASP3_CLKCTRL 0x4a0094d8
#define CM_L4PER_MCBSP4_CLKCTRL 0x4a0094e0
#define CM_L4PER_MGATE_CLKCTRL 0x4a0094e8
#define CM_L4PER_MCSPI1_CLKCTRL 0x4a0094f0
#define CM_L4PER_MCSPI2_CLKCTRL 0x4a0094f8
#define CM_L4PER_MCSPI3_CLKCTRL 0x4a009500
#define CM_L4PER_MCSPI4_CLKCTRL 0x4a009508
#define CM_L4PER_MMCSD3_CLKCTRL 0x4a009520
#define CM_L4PER_MMCSD4_CLKCTRL 0x4a009528
#define CM_L4PER_MSPROHG_CLKCTRL 0x4a009530
#define CM_L4PER_SLIMBUS2_CLKCTRL 0x4a009538
#define CM_L4PER_UART1_CLKCTRL 0x4a009540
#define CM_L4PER_UART2_CLKCTRL 0x4a009548
#define CM_L4PER_UART3_CLKCTRL 0x4a009550
#define CM_L4PER_UART4_CLKCTRL 0x4a009558
#define CM_L4PER_MMCSD5_CLKCTRL 0x4a009560
#define CM_L4PER_I2C5_CLKCTRL 0x4a009568
#define CM_L4SEC_CLKSTCTRL 0x4a009580
#define CM_L4SEC_STATICDEP 0x4a009584
#define CM_L4SEC_DYNAMICDEP 0x4a009588
#define CM_L4SEC_AES1_CLKCTRL 0x4a0095a0
#define CM_L4SEC_AES2_CLKCTRL 0x4a0095a8
#define CM_L4SEC_DES3DES_CLKCTRL 0x4a0095b0
#define CM_L4SEC_PKAEIP29_CLKCTRL 0x4a0095b8
#define CM_L4SEC_RNG_CLKCTRL 0x4a0095c0
#define CM_L4SEC_SHA2MD51_CLKCTRL 0x4a0095c8
#define CM_L4SEC_CRYPTODMA_CLKCTRL 0x4a0095d8
/* CM2.IVAHD */
#define IVAHD_CLKSTCTRL 0x4a008f00
#define IVAHD_IVAHD_CLKCTRL 0x4a008f20
#define IVAHD_SL2_CLKCTRL 0x4a008f28
/* CM2.L3INIT */
#define CM_L3INIT_HSMMC1_CLKCTRL 0x4a009328
#define CM_L3INIT_HSMMC2_CLKCTRL 0x4a009330
#define CM_L3INIT_HSI_CLKCTRL 0x4a009338
#define CM_L3INIT_UNIPRO1_CLKCTRL 0x4a009340
#define CM_L3INIT_HSUSBHOST_CLKCTRL 0x4a009358
#define CM_L3INIT_HSUSBOTG_CLKCTRL 0x4a009360
#define CM_L3INIT_HSUSBTLL_CLKCTRL 0x4a009368
#define CM_L3INIT_P1500_CLKCTRL 0x4a009378
#define CM_L3INIT_FSUSB_CLKCTRL 0x4a0093d0
#define CM_L3INIT_USBPHY_CLKCTRL 0x4a0093e0
/* CM2.CAM */
#define CM_CAM_CLKSTCTRL 0x4a009000
#define CM_CAM_ISS_CLKCTRL 0x4a009020
#define CM_CAM_FDIF_CLKCTRL 0x4a009028
/* CM2.DSS */
#define CM_DSS_CLKSTCTRL 0x4a009100
#define CM_DSS_DSS_CLKCTRL 0x4a009120
#define CM_DSS_DEISS_CLKCTRL 0x4a009128
/* CM2.SGX */
#define CM_SGX_CLKSTCTRL 0x4a009200
#define CM_SGX_SGX_CLKCTRL 0x4a009220
/* SMX-APE */
#define PM_RT_APE_BASE_ADDR_ARM (SMX_APE_BASE + 0x10000)
#define PM_GPMC_BASE_ADDR_ARM (SMX_APE_BASE + 0x12400)
#define PM_OCM_RAM_BASE_ADDR_ARM (SMX_APE_BASE + 0x12800)
#define PM_OCM_ROM_BASE_ADDR_ARM (SMX_APE_BASE + 0x12C00)
#define PM_IVA2_BASE_ADDR_ARM (SMX_APE_BASE + 0x14000)
#define RT_REQ_INFO_PERMISSION_1 (PM_RT_APE_BASE_ADDR_ARM + 0x68)
#define RT_READ_PERMISSION_0 (PM_RT_APE_BASE_ADDR_ARM + 0x50)
#define RT_WRITE_PERMISSION_0 (PM_RT_APE_BASE_ADDR_ARM + 0x58)
#define RT_ADDR_MATCH_1 (PM_RT_APE_BASE_ADDR_ARM + 0x60)
#define GPMC_REQ_INFO_PERMISSION_0 (PM_GPMC_BASE_ADDR_ARM + 0x48)
#define GPMC_READ_PERMISSION_0 (PM_GPMC_BASE_ADDR_ARM + 0x50)
#define GPMC_WRITE_PERMISSION_0 (PM_GPMC_BASE_ADDR_ARM + 0x58)
#define OCM_REQ_INFO_PERMISSION_0 (PM_OCM_RAM_BASE_ADDR_ARM + 0x48)
#define OCM_READ_PERMISSION_0 (PM_OCM_RAM_BASE_ADDR_ARM + 0x50)
#define OCM_WRITE_PERMISSION_0 (PM_OCM_RAM_BASE_ADDR_ARM + 0x58)
#define OCM_ADDR_MATCH_2 (PM_OCM_RAM_BASE_ADDR_ARM + 0x80)
#define IVA2_REQ_INFO_PERMISSION_0 (PM_IVA2_BASE_ADDR_ARM + 0x48)
#define IVA2_READ_PERMISSION_0 (PM_IVA2_BASE_ADDR_ARM + 0x50)
#define IVA2_WRITE_PERMISSION_0 (PM_IVA2_BASE_ADDR_ARM + 0x58)
#define IVA2_REQ_INFO_PERMISSION_1 (PM_IVA2_BASE_ADDR_ARM + 0x68)
#define IVA2_READ_PERMISSION_1 (PM_IVA2_BASE_ADDR_ARM + 0x70)
#define IVA2_WRITE_PERMISSION_1 (PM_IVA2_BASE_ADDR_ARM + 0x78)
#define IVA2_REQ_INFO_PERMISSION_2 (PM_IVA2_BASE_ADDR_ARM + 0x88)
#define IVA2_READ_PERMISSION_2 (PM_IVA2_BASE_ADDR_ARM + 0x90)
#define IVA2_WRITE_PERMISSION_2 (PM_IVA2_BASE_ADDR_ARM + 0x98)
#define IVA2_REQ_INFO_PERMISSION_3 (PM_IVA2_BASE_ADDR_ARM + 0xA8)
#define IVA2_READ_PERMISSION_3 (PM_IVA2_BASE_ADDR_ARM + 0xB0)
#define IVA2_WRITE_PERMISSION_3 (PM_IVA2_BASE_ADDR_ARM + 0xB8)
/* I2C base */
#define I2C_BASE1 (OMAP44XX_L4_PER + 0x70000)
#define I2C_BASE2 (OMAP44XX_L4_PER + 0x72000)
#define I2C_BASE3 (OMAP44XX_L4_PER + 0x60000)
/* EMIF and DMM registers */
#define EMIF1_BASE 0x4c000000
#define EMIF2_BASE 0x4d000000
#define DMM_BASE 0x4e000000
#define MA_BASE 0x482AF000
/* EMIF */
#define EMIF_MOD_ID_REV 0x0000
#define EMIF_STATUS 0x0004
#define EMIF_SDRAM_CONFIG 0x0008
#define EMIF_LPDDR2_NVM_CONFIG 0x000C
#define EMIF_SDRAM_REF_CTRL 0x0010
#define EMIF_SDRAM_REF_CTRL_SHDW 0x0014
#define EMIF_SDRAM_TIM_1 0x0018
#define EMIF_SDRAM_TIM_1_SHDW 0x001C
#define EMIF_SDRAM_TIM_2 0x0020
#define EMIF_SDRAM_TIM_2_SHDW 0x0024
#define EMIF_SDRAM_TIM_3 0x0028
#define EMIF_SDRAM_TIM_3_SHDW 0x002C
#define EMIF_LPDDR2_NVM_TIM 0x0030
#define EMIF_LPDDR2_NVM_TIM_SHDW 0x0034
#define EMIF_PWR_MGMT_CTRL 0x0038
#define EMIF_PWR_MGMT_CTRL_SHDW 0x003C
#define EMIF_LPDDR2_MODE_REG_DATA 0x0040
#define EMIF_LPDDR2_MODE_REG_CFG 0x0050
#define EMIF_L3_CONFIG 0x0054
#define EMIF_L3_CFG_VAL_1 0x0058
#define EMIF_L3_CFG_VAL_2 0x005C
#define IODFT_TLGC 0x0060
#define EMIF_PERF_CNT_1 0x0080
#define EMIF_PERF_CNT_2 0x0084
#define EMIF_PERF_CNT_CFG 0x0088
#define EMIF_PERF_CNT_SEL 0x008C
#define EMIF_PERF_CNT_TIM 0x0090
#define EMIF_READ_IDLE_CTRL 0x0098
#define EMIF_READ_IDLE_CTRL_SHDW 0x009c
#define EMIF_ZQ_CONFIG 0x00C8
#define EMIF_DDR_PHY_CTRL_1 0x00E4
#define EMIF_DDR_PHY_CTRL_1_SHDW 0x00E8
#define EMIF_DDR_PHY_CTRL_2 0x00EC
#define DMM_LISA_MAP_0 0x0040
#define DMM_LISA_MAP_1 0x0044
#define DMM_LISA_MAP_2 0x0048
#define DMM_LISA_MAP_3 0x004C
#ifndef __ASSEMBLY__
/* structure for ddr timings */
struct ddr_regs{
u32 tim1;
u32 tim2;
u32 tim3;
u32 phy_ctrl_1;
u32 ref_ctrl;
u32 config_init;
u32 config_final;
u32 zq_config;
u8 mr1;
u8 mr2;
};
/* Used to index into DPLL parameter tables */
struct dpll_param {
unsigned int m;
unsigned int n;
unsigned int m2;
unsigned int m3;
unsigned int m4;
unsigned int m5;
unsigned int m6;
unsigned int m7;
};
void omap4_ddr_init(const struct ddr_regs *ddr1,
const struct ddr_regs *ddr2);
#endif
#endif
| 35.933222 | 76 | 0.811699 |
09f018353935c4423fb7f2069c3b45535ebb1113 | 833 | h | C | System/Library/Frameworks/ContactsUI.framework/CNDatePickerContainerView.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | 2 | 2021-11-02T09:23:27.000Z | 2022-03-28T08:21:57.000Z | System/Library/Frameworks/ContactsUI.framework/CNDatePickerContainerView.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | null | null | null | System/Library/Frameworks/ContactsUI.framework/CNDatePickerContainerView.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:36:03 AM Mountain Standard Time
* Operating System: Version 13.5.1 (Build 17F80)
* Image Source: /System/Library/Frameworks/ContactsUI.framework/ContactsUI
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley.
*/
#import <UIKitCore/UIView.h>
@class UIDatePicker;
@interface CNDatePickerContainerView : UIView {
UIDatePicker* _datePicker;
}
@property (nonatomic,readonly) UIDatePicker * datePicker; //@synthesize datePicker=_datePicker - In the implementation block
-(UIDatePicker *)datePicker;
-(id)initWithDatePicker:(id)arg1 ;
@end
| 34.708333 | 137 | 0.631453 |
e593144dd0580ca9f7fce8a669e7d463586b3aad | 1,963 | h | C | actor-apps/core-async-cocoa/src/im/actor/model/api/updates/UpdateMessageDateChanged.h | DragonStuff/actor-platform | d262e6bb3c18b20eb35551313bce16c471cd2928 | [
"MIT"
] | null | null | null | actor-apps/core-async-cocoa/src/im/actor/model/api/updates/UpdateMessageDateChanged.h | DragonStuff/actor-platform | d262e6bb3c18b20eb35551313bce16c471cd2928 | [
"MIT"
] | null | null | null | actor-apps/core-async-cocoa/src/im/actor/model/api/updates/UpdateMessageDateChanged.h | DragonStuff/actor-platform | d262e6bb3c18b20eb35551313bce16c471cd2928 | [
"MIT"
] | null | null | null | //
// Generated by the J2ObjC translator. DO NOT EDIT!
// source: /Users/ex3ndr/Develop/actor-platform/actor-apps/core/src/main/java/im/actor/model/api/updates/UpdateMessageDateChanged.java
//
#ifndef _APUpdateMessageDateChanged_H_
#define _APUpdateMessageDateChanged_H_
#include "J2ObjC_header.h"
#include "im/actor/model/network/parser/Update.h"
@class APPeer;
@class BSBserValues;
@class BSBserWriter;
@class IOSByteArray;
#define APUpdateMessageDateChanged_HEADER 163
@interface APUpdateMessageDateChanged : APUpdate
#pragma mark Public
- (instancetype)init;
- (instancetype)initWithAPPeer:(APPeer *)peer
withLong:(jlong)rid
withLong:(jlong)date;
+ (APUpdateMessageDateChanged *)fromBytesWithByteArray:(IOSByteArray *)data;
- (jlong)getDate;
- (jint)getHeaderKey;
- (APPeer *)getPeer;
- (jlong)getRid;
- (void)parseWithBSBserValues:(BSBserValues *)values;
- (void)serializeWithBSBserWriter:(BSBserWriter *)writer;
- (NSString *)description;
@end
J2OBJC_EMPTY_STATIC_INIT(APUpdateMessageDateChanged)
J2OBJC_STATIC_FIELD_GETTER(APUpdateMessageDateChanged, HEADER, jint)
FOUNDATION_EXPORT APUpdateMessageDateChanged *APUpdateMessageDateChanged_fromBytesWithByteArray_(IOSByteArray *data);
FOUNDATION_EXPORT void APUpdateMessageDateChanged_initWithAPPeer_withLong_withLong_(APUpdateMessageDateChanged *self, APPeer *peer, jlong rid, jlong date);
FOUNDATION_EXPORT APUpdateMessageDateChanged *new_APUpdateMessageDateChanged_initWithAPPeer_withLong_withLong_(APPeer *peer, jlong rid, jlong date) NS_RETURNS_RETAINED;
FOUNDATION_EXPORT void APUpdateMessageDateChanged_init(APUpdateMessageDateChanged *self);
FOUNDATION_EXPORT APUpdateMessageDateChanged *new_APUpdateMessageDateChanged_init() NS_RETURNS_RETAINED;
J2OBJC_TYPE_LITERAL_HEADER(APUpdateMessageDateChanged)
typedef APUpdateMessageDateChanged ImActorModelApiUpdatesUpdateMessageDateChanged;
#endif // _APUpdateMessageDateChanged_H_
| 29.742424 | 168 | 0.82272 |
735728b34aa418600c2844b7baef9d276e702e00 | 12,546 | h | C | src/tstools/tspPluginExecutor.h | mypopydev/tsduck | 38e29aa7ba82d0d07ca926a4e37a7f6d167089d3 | [
"BSD-2-Clause"
] | null | null | null | src/tstools/tspPluginExecutor.h | mypopydev/tsduck | 38e29aa7ba82d0d07ca926a4e37a7f6d167089d3 | [
"BSD-2-Clause"
] | null | null | null | src/tstools/tspPluginExecutor.h | mypopydev/tsduck | 38e29aa7ba82d0d07ca926a4e37a7f6d167089d3 | [
"BSD-2-Clause"
] | null | null | null | //----------------------------------------------------------------------------
//
// TSDuck - The MPEG Transport Stream Toolkit
// Copyright (c) 2005-2019, Thierry Lelegard
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
// THE POSSIBILITY OF SUCH DAMAGE.
//
//----------------------------------------------------------------------------
//!
//! @file
//! Transport stream processor: Execution context of a plugin
//!
//----------------------------------------------------------------------------
#pragma once
#include "tspOptions.h"
#include "tspJointTermination.h"
#include "tsPlugin.h"
#include "tsResidentBuffer.h"
#include "tsUserInterrupt.h"
#include "tsRingNode.h"
#include "tsCondition.h"
#include "tsMutex.h"
#include "tsThread.h"
namespace ts {
namespace tsp {
//!
//! Execution context of a tsp plugin.
//!
//! @anchor PacketBufferModel
//!
//! Data model
//! ----------
//! There is a global buffer for TS packets. The input thread writes incoming
//! packets here. All packet processors update them and the output thread
//! picks them for the same place.
//!
//! The buffer is an array of ts::TSPacket. It is managed in a circular way.
//! It is divided into logical areas, one per processor (including input
//! and output). These logical areas are sliding windows which move when
//! packets are processed.
//!
//! Each sliding window is defined by the index of its first packet
//! (_pkt_first) and its size in packets (_pkt_cnt).
//!
//! @anchor PacketBufferDiagram
//! Flat (non-circular) view of the buffer:
//!
//! @code
//! output->_pkt_first proc_1->_pkt_first
//! | |
//! | proc_N->_pkt_first | input->_pkt_first
//! | | | |
//! V V V V
//! +----------+----------+-------+----------+---------+
//! +-> | output | proc N | ... | proc 1 | input | ->-+
//! | +----------+----------+-------+----------+---------+ |
//! | |
//! +-------------------------------------------------------------+
//! @endcode
//!
//! When a thread terminates the processing of a bunch of packets, it moves
//! up its first index and, consequently, decreases the sizes of its area
//! and accordingly increases the size of the area of the next processor.
//!
//! The modification of the starting index and size of any area must be
//! performed under the protection of the global mutex. There is one global
//! mutex for simplicity. The resulting bottleneck is not so important since
//! updating a few pointers is fast.
//!
//! When the sliding window of a processor is empty, the processor thread
//! sleeps on its "_to_do" condition variable. Consequently, when a thread
//! passes packets to the next processor (ie. increases the size of the sliding
//! window of the next processor), it must notify the _to_do condition variable
//! of the next thread.
//!
//! When a packet processor decides to drop a packet, the synchronization
//! byte (first byte of the packet, normally 0x47) is reset to zero. When
//! a packet processor or the output processor encounters a packet starting
//! with a zero byte, it ignores it.
//!
//! All PluginExecutors are chained in a ring. The first one is input and
//! the last one is output. The output points back to the input so that the
//! output processor can easily pass free packets to be reused by the input
//! processor.
//!
//! The "_input_end" indicates that there is no more packet to process
//! after those in the processor's area. This condition is signaled by
//! the previous processor in the chain. All processors, except the output
//! processor, may signal this condition to their successor.
//!
//! The "_aborted" indicates that the current processor has encountered an
//! error and has ceased to accept packets. This condition is checked by
//! the previous processor in the chain (which, in turn, will declare itself
//! as aborted). All processors, except the input processor may signal this
//! condition. In case of error, all processors should also declare an
//! "_input_end" to their successor.
//!
//! @ingroup plugin
//!
class PluginExecutor: public JointTermination, public RingNode
{
TS_NOBUILD_NOCOPY(PluginExecutor);
public:
//!
//! TS packet are accessed in a memory-resident buffer.
//!
typedef ResidentBuffer<TSPacket> PacketBuffer;
//!
//! Metadata for TS packet are accessed in a memory-resident buffer.
//! A packet and its metadata have the same index in their respective buffer.
//!
typedef ResidentBuffer<TSPacketMetadata> PacketMetadataBuffer;
//!
//! Constructor.
//! @param [in,out] options Command line options for tsp.
//! @param [in] pl_options Command line options for this plugin.
//! @param [in] attributes Creation attributes for the thread executing this plugin.
//! @param [in,out] global_mutex Global mutex to synchronize access to the packet buffer.
//!
PluginExecutor(Options* options,
const PluginOptions* pl_options,
const ThreadAttributes& attributes,
Mutex& global_mutex);
//!
//! Virtual destructor.
//!
virtual ~PluginExecutor();
//!
//! Set the initial state of the buffer for this plugin.
//! Must be executed in synchronous environment, before starting all executor threads.
//! @param [in] buffer Address of the packet buffer.
//! @param [in] metadata Address of the packet metadata buffer.
//! @param [in] pkt_first Starting index of packets area for this plugin.
//! @param [in] pkt_cnt Size of packets area for this plugin.
//! @param [in] input_end If true, there is no more packet after current ones.
//! @param [in] aborted If true, there was a packet processor error, aborted.
//! @param [in] bitrate Input bitrate (set by previous packet processor).
//!
void initBuffer(PacketBuffer* buffer,
PacketMetadataBuffer* metadata,
size_t pkt_first,
size_t pkt_cnt,
bool input_end,
bool aborted,
BitRate bitrate);
//!
//! Inform if all plugins should use defaults for real-time.
//! @param [in] on True if all plugins should use defaults for real-time.
//!
void setRealTimeForAll(bool on)
{
_use_realtime = on;
}
//!
//! This method sets the current packet processor in an abort state.
//!
void setAbort();
//!
//! Check if the plugin a real time one.
//! @return True if the plugin usually requires real-time responsiveness.
//!
bool isRealTime() const;
protected:
PacketBuffer* _buffer; //!< Description of shared packet buffer.
PacketMetadataBuffer* _metadata; //!< Description of shared packet metadata buffer.
//!
//! Pass processed packets to the next packet processor.
//!
//! This method is invoked by a subclass to indicate that some packets
//! have been processed by this packet process and shall be passed to
//! the next processor.
//!
//! Note that, if the caller thread is the output processor, the semantic of
//! the operation is "these buffers are no longer used and can be reused by
//! the input thread".
//!
//! @param [in] count Number of packets to pass to next processor.
//! @param [in] bitrate Bitrate, as computed by this processor or passed
//! from the previous processor. To be passed to next processor.
//! @param [in] input_end If true, this processor will no longer produce packets.
//! @param [in] aborted if true, this processor has encountered an error and will cease to accept packets.
//! @return True when the processor shall continue, false when it shall stop.
//!
bool passPackets(size_t count, BitRate bitrate, bool input_end, bool aborted);
//!
//! Wait for something to do.
//!
//! This method is invoked by a subclass when it has nothing to do.
//! This method makes the calling processor thread waiting for packets
//! to process or some error condition.
//!
//! Always return a contiguous array of packets. If the circular buffer
//! wrap-over occurs in the middle of the caller's area, only return the
//! first part, up the buffer's highest address. The next call to waitWork()
//! will return the second part.
//!
//! @param [out] pkt_first Index of first packet to process in the buffer.
//! @param [out] pkt_cnt Number of packets to process in the buffer.
//! @param [out] bitrate Current bitrate, as computed from previous processors.
//! @param [out] input_end The previous processor indicates that no more packets will be produced.
//! @param [out] aborted The *next* processor indicates that it aborts and will no longer accept packets.
//! @param [out] timeout No packet could be returned within the timeout specified by the plugin and
//! the plugin requested an abort.
//!
void waitWork(size_t& pkt_first, size_t& pkt_cnt, BitRate& bitrate, bool& input_end, bool& aborted, bool &timeout);
private:
Condition _to_do; // Notify processor to do something
// The following private data must be accessed exclusively under the protection of the global mutex.
size_t _pkt_first; // Starting index of packets area
size_t _pkt_cnt; // Size of packets area
bool _input_end; // No more packet after current ones
BitRate _bitrate; // Input bitrate (set by previous plugin)
};
}
}
| 50.184 | 127 | 0.569106 |
487a46d5ab978ea3544743e642871813c6893f64 | 3,330 | h | C | clf_object_recognition_merger/include/clf_object_recognition_merger/oobb_calculate.h | CentralLabFacilities/clf_object_recognition | f4579980682687c3706c1dded8a255903795097d | [
"Apache-2.0"
] | 2 | 2019-01-22T05:00:05.000Z | 2019-01-22T05:00:20.000Z | clf_object_recognition_merger/include/clf_object_recognition_merger/oobb_calculate.h | CentralLabFacilities/clf_object_recognition | f4579980682687c3706c1dded8a255903795097d | [
"Apache-2.0"
] | null | null | null | clf_object_recognition_merger/include/clf_object_recognition_merger/oobb_calculate.h | CentralLabFacilities/clf_object_recognition | f4579980682687c3706c1dded8a255903795097d | [
"Apache-2.0"
] | null | null | null | #pragma once
#include <Eigen/Eigenvalues> // for SelfAdjointEigenSolver
#include <pcl_conversions/pcl_conversions.h>
#include <pcl/point_types.h>
#include <pcl/PCLPointCloud2.h>
#include <pcl/conversions.h>
#include <pcl/common/common.h>
#include <pcl/common/transforms.h> // for transformPointCloud
#include <vision_msgs/BoundingBox3D.h>
#include <sensor_msgs/PointCloud2.h>
namespace OOBB_Calculate
{
vision_msgs::BoundingBox3D calculate(sensor_msgs::PointCloud2 cloud)
{
vision_msgs::BoundingBox3D ret;
// http://codextechnicanum.blogspot.com/2015/04/find-minimum-oriented-bounding-box-of.html
pcl::PCLPointCloud2 pcl_pc2;
pcl_conversions::toPCL(cloud, pcl_pc2);
pcl::PointCloud<pcl::PointXYZ>::Ptr temp_cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::fromPCLPointCloud2(pcl_pc2, *temp_cloud);
if (temp_cloud->size() < 3)
{
ROS_ERROR_STREAM("cloud to small, could not create BB");
return ret;
}
Eigen::Vector4f pcaCentroid;
pcl::compute3DCentroid(*temp_cloud, pcaCentroid);
Eigen::Matrix3f covariance;
computeCovarianceMatrixNormalized(*temp_cloud, pcaCentroid, covariance);
Eigen::SelfAdjointEigenSolver<Eigen::Matrix3f> eigen_solver(covariance, Eigen::ComputeEigenvectors);
Eigen::Matrix3f eigenVectorsPCA = eigen_solver.eigenvectors();
eigenVectorsPCA.col(2) = eigenVectorsPCA.col(0).cross(eigenVectorsPCA.col(1));
// Note that getting the eigenvectors can also be obtained via the PCL PCA interface with something like:
// pcl::PointCloud<pcl::PointXYZ>::Ptr cloudPCAprojection (new pcl::PointCloud<pcl::PointXYZ>);
// pcl::PCA<pcl::PointXYZ> pca;
// pca.setInputCloud(temp_cloud);
// pca.project(*temp_cloud, *cloudPCAprojection);
// std::cerr << std::endl << "PCLEigenVectors: " << pca.getEigenVectors() << std::endl;
// std::cerr << std::endl << "EigenVectors: " << eigenVectorsPCA << std::endl;
// Transform the original cloud to the origin where the principal components correspond to the axes.
Eigen::Matrix4f projectionTransform(Eigen::Matrix4f::Identity());
projectionTransform.block<3, 3>(0, 0) = eigenVectorsPCA.transpose();
projectionTransform.block<3, 1>(0, 3) = -1.f * (projectionTransform.block<3, 3>(0, 0) * pcaCentroid.head<3>());
pcl::PointCloud<pcl::PointXYZ>::Ptr cloudPointsProjected(new pcl::PointCloud<pcl::PointXYZ>);
pcl::transformPointCloud(*temp_cloud, *cloudPointsProjected, projectionTransform);
// Get the minimum and maximum points of the transformed cloud.
pcl::PointXYZ minPoint, maxPoint;
pcl::getMinMax3D(*cloudPointsProjected, minPoint, maxPoint);
const Eigen::Vector3f meanDiagonal = 0.5f * (maxPoint.getVector3fMap() + minPoint.getVector3fMap());
// Final transform
const Eigen::Quaternionf bboxQuaternion(eigenVectorsPCA);
const Eigen::Vector3f bboxTransform = eigenVectorsPCA * meanDiagonal + pcaCentroid.head<3>();
ret.size.x = maxPoint.x - minPoint.x;
ret.size.y = maxPoint.y - minPoint.y;
ret.size.z = maxPoint.z - minPoint.z;
ret.center.position.x = bboxTransform[0];
ret.center.position.y = bboxTransform[1];
ret.center.position.z = bboxTransform[2];
ret.center.orientation.w = (double)bboxQuaternion.w();
ret.center.orientation.x = bboxQuaternion.x();
ret.center.orientation.y = bboxQuaternion.y();
ret.center.orientation.z = bboxQuaternion.z();
return ret;
}
}
| 41.625 | 113 | 0.746547 |
bc2ff7cd2c139c40cd7d21de174c9f99912cdadc | 2,398 | c | C | meltdown/GP/main.c | Mashiro1995/TEApot | a5ec85cf90e771919ce0aeccf66fb26d4790f16b | [
"Apache-2.0"
] | 7 | 2020-10-26T09:10:11.000Z | 2021-12-23T11:00:09.000Z | meltdown/GP/main.c | Mashiro1995/TEApot | a5ec85cf90e771919ce0aeccf66fb26d4790f16b | [
"Apache-2.0"
] | 1 | 2021-12-31T05:17:50.000Z | 2021-12-31T05:17:50.000Z | meltdown/GP/main.c | github-3rr0r/TEApot | a5ec85cf90e771919ce0aeccf66fb26d4790f16b | [
"Apache-2.0"
] | null | null | null | #define _GNU_SOURCE
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sched.h>
#include "libcache/cache.h"
#include "lib/global.h"
int main(int argc, char **argv)
{
PREPARE();
// print CR3 register content
// int temp = system("sudo insmod ../../libcr3/kernel_module.ko");
// pid_t pid = getpid();
pid_t pid = 1;
char pid_s[64];
// get CR3 register for running process
sprintf(pid_s, "echo %zd > /proc/cr3; cat /proc/cr3", (size_t)pid);
// sprintf(pid_s, "echo %zd > /proc/cr3", (size_t)pid);
printf("CR3: ");
fflush(stdout);
int temp = system(pid_s);
// Flush our shared memory
flush_shared_memory();
int result = 0;
start_time = time(NULL);
int r;
for (r = 0; r < MAX_TRY_TIMES; r++)
{
// Start TSX
if (try_start())
{
// Null pointer access prolongs transient window
maccess(0);
// Encode content of the CR3 register in the cache
// 将mem放入ebx,保护rax,将cr3写入rax,和0xff000与放入rax,访问mem+rax的内存(得到cr3的中间两位)
asm volatile(
"movq %%cr3, %%rax\n"
"andq $0xff000, %%rax\n"
"movq (%%rbx,%%rax,1), %%rbx\n"
:
: "b"(mem)
: "rax");
try_abort();
}
try_end();
// Recover data from the cache
result = cache_decode();
if (result != 0)
{
passed_count++;
if (passed_count <= 10)
{
printf("%x ", result);
}
}
if (time(NULL) - start_time > timeout)
{
printf(ANSI_COLOR_YELLOW "Meltdown_GP: Timeout" ANSI_COLOR_RESET "\n");
exit(-1);
}
}
int exit_result = 0;
// temp = system("sudo rmmod ../../libcr3/kernel_module.ko");
if (passed_count > 0)
{
printf("\nPlease check whether the output is equal to CR3[4:3] manually!\n");
}
if ((double)passed_count / MAX_TRY_TIMES > 0.3)
{
printf(ANSI_COLOR_RED "Meltdown_GP: Perhaps Vulnerable" ANSI_COLOR_RESET "\n");
exit_result = EXIT_SUCCESS;
}
else
{
printf(ANSI_COLOR_GREEN "Meltdown_GP: Not Vulnerable" ANSI_COLOR_RESET "\n");
exit_result = EXIT_FAILURE;
}
exit(exit_result);
}
| 27.25 | 87 | 0.534195 |
90c6c38fb02f52275d13e06956a334ae5d29ff35 | 204 | h | C | src/ngx_http_ssdb_handler.h | feifeiiiiiiiiiii/ssdb-nginx-module | 9f6e249c4368b5ea784ef130ad74b7209417ccea | [
"Apache-2.0"
] | null | null | null | src/ngx_http_ssdb_handler.h | feifeiiiiiiiiiii/ssdb-nginx-module | 9f6e249c4368b5ea784ef130ad74b7209417ccea | [
"Apache-2.0"
] | null | null | null | src/ngx_http_ssdb_handler.h | feifeiiiiiiiiiii/ssdb-nginx-module | 9f6e249c4368b5ea784ef130ad74b7209417ccea | [
"Apache-2.0"
] | null | null | null | #ifndef NGX_HTTP_SSDB_HANDLER_H
#define NGX_HTTP_SSDB_HANDLER_H
#include <ngx_core.h>
#include <ngx_http.h>
ngx_int_t ngx_http_ssdb_handler(ngx_http_request_t *r);
#endif /* NGX_HTTP_SSDB_HANDLER_H */
| 20.4 | 55 | 0.818627 |
093baf11f60a92771d4572ff6cdc6854115e5006 | 1,240 | h | C | ManekiNeko/Classes/UtilTools/MNDeviceInfo.h | jacktionary/ManekiNeko | 5584e8e165837f67a94dc10e5a38a54268a49909 | [
"MIT"
] | null | null | null | ManekiNeko/Classes/UtilTools/MNDeviceInfo.h | jacktionary/ManekiNeko | 5584e8e165837f67a94dc10e5a38a54268a49909 | [
"MIT"
] | null | null | null | ManekiNeko/Classes/UtilTools/MNDeviceInfo.h | jacktionary/ManekiNeko | 5584e8e165837f67a94dc10e5a38a54268a49909 | [
"MIT"
] | null | null | null | //
// DeviceInfo.h
// CyouSDK
//
// Created by Alien Wang on 14-8-22.
// Copyright (c) 2014年 Hard Time. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface MNDeviceInfo : NSObject
/*
* 获取系统版本号
*/
+ (float)systemVersion;
/*
* 获取用户设备唯一标识
*/
+ (NSString *)deviceID;
/*
* 获取当前时间
*/
+(NSString *)getDate;
/*
* 获取app bundleID
*/
+(NSString *)bundleID;
/*
* 获取MAC地址 唯一表示
*/
+(NSString *)macAddress;
/*
* 获取操作系统类型
*/
+(NSString *)systemName;
/*
* 获取设备名称
*/
+(NSString *)deviceName;
/*
* 获取设备类型
*/
+(NSString *)deviceModelName;
/*
* 获取设备分辨率
*/
+(NSString *)resolution;
/*
* 获取运营商标示
*/
+(NSString *)carrier;
/*
* 获取当前联网方式。
* wifi/3g/nonetwork
*/
+(NSString *)checkNetWoriking;
/*
* 判断设备是否越狱
*/
+(NSString *)checkJailBroken;
/*
* 检查是否连接到网络
*/
+(BOOL) isConnectedToNetwork;
/*
* 获取开机时间
*/
+ (NSString *)getLaunchSystemTime;
/*
* 手机总容量
*/
+ (NSNumber *)diskSpaceTotal;
/*
* 手机剩余可用容量
*/
+ (NSNumber *)diskSpaceAvaliable;
/*
* 手机可用电量
*/
+ (double)batteryAvaliable;
/*
* 获得当前所有进程信息(jailbreak可用)
*/
+ (NSArray *)runningProcesses;
/*
* 获得手机安装的app list(jailbreak可用)
*/
+(NSArray *)installedApp;
/*
* 获取所有安装application
*/
+ (NSArray *)allApplications;
@end
| 10.689655 | 55 | 0.61129 |
513f9285cc878a1693a8871cffa8174edd2a7085 | 1,684 | c | C | benchmarks/vmg-crustache_test.c | pointhi/benchmarks | 68899480c0fc8d361079a81edc6d816d5f17d58e | [
"UPL-1.0"
] | 7 | 2018-12-10T02:41:43.000Z | 2020-06-18T06:13:59.000Z | benchmarks/vmg-crustache_test.c | pointhi/benchmarks | 68899480c0fc8d361079a81edc6d816d5f17d58e | [
"UPL-1.0"
] | 23 | 2018-06-07T07:46:27.000Z | 2018-08-06T17:57:39.000Z | benchmarks/vmg-crustache_test.c | pointhi/benchmarks | 68899480c0fc8d361079a81edc6d816d5f17d58e | [
"UPL-1.0"
] | 2 | 2018-06-07T08:04:52.000Z | 2018-06-07T09:06:21.000Z | #include "chayai.h" // first include!
#include <string.h>
#include <assert.h>
#include "vmg-crustache/src/crustache.h"
#define TEMPLATE "<h1>{{header}}</h1>\n"\
"{{#bug}}\n"\
"{{/bug}}\n"\
"\n"\
"{{#items}}\n"\
" {{#first}}\n"\
" <li><strong>{{name}}</strong></li>\n"\
" {{/first}}\n"\
" {{#link}}\n"\
" <li><a href=\"{{url}}\">{{name}}</a></li>\n"\
" {{/link}}\n"\
"{{/items}}\n"\
"\n"\
"{{#empty}}\n"\
" <p>The list is empty.</p>\n"\
"{{/empty}}"
int crustache_context_find(crustache_var *var, void *context, const char *key, size_t key_size) {
if(strncmp("header", key, key_size) == 0
|| strncmp("name", key, key_size) == 0
|| strncmp("url", key, key_size) == 0) {
var->type = CRUSTACHE_VAR_STR;
var->data = (void*)key;
var->size = key_size;
} else {
var->type = CRUSTACHE_VAR_CONTEXT;
var->data = "";
}
return 0;
}
BENCHMARK(vmg, crustache, 100, 10) {
crustache_template* templt;
crustache_api api = {
crustache_context_find,
NULL,
NULL,
NULL,
NULL,
0
};
int error = crustache_new(&templt, &api, TEMPLATE, sizeof(TEMPLATE));
assert(error == 0);
struct buf *buf = bufnew(128);
crustache_var var;
var.type = CRUSTACHE_VAR_CONTEXT;
var.size = 0;
for(int i = 0; i < 5000; i++) {
error = crustache_render(buf, templt, &var);
assert(error == 0);
}
assert(buf->size == 670000);
bufrelease(buf);
crustache_free(templt);
}
int main(int argc, char** argv) {
REGISTER_BENCHMARK(vmg, crustache);
RUN_BENCHMARKS(argc, argv);
return 0;
}
| 20.790123 | 97 | 0.537411 |
51a57d0239e11c70ecaabae28ca91b04177bca01 | 1,514 | h | C | remoting/ios/keychain_wrapper.h | metux/chromium-deb | 3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | remoting/ios/keychain_wrapper.h | metux/chromium-deb | 3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | remoting/ios/keychain_wrapper.h | metux/chromium-deb | 3c08e9b89a1b6f95f103a61ff4f528dbcd57fc42 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | // Copyright 2017 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 REMOTING_IOS_KEYCHAIN_WRAPPER_H_
#define REMOTING_IOS_KEYCHAIN_WRAPPER_H_
#import <Foundation/Foundation.h>
@class UserInfo;
extern NSString* const kKeychainPairingId;
extern NSString* const kKeychainPairingSecret;
typedef void (^PairingCredentialsCallback)(NSString* pairingId,
NSString* secret);
// Class to abstract the details from how iOS wants to write to the keychain.
// TODO(nicholss): This will have to be futher refactored when we integrate
// with the private Google auth.
@interface KeychainWrapper : NSObject
// Save a refresh token to the keychain.
- (void)setRefreshToken:(NSString*)refreshToken;
// Get the refresh token from the keychain, if there is one.
- (NSString*)refreshToken;
// Save the pairing credentials for the given host id.
- (void)commitPairingCredentialsForHost:(NSString*)host
id:(NSString*)pairingId
secret:(NSString*)secret;
// Get the pairing credentials for the given host id.
- (NSDictionary*)pairingCredentialsForHost:(NSString*)host;
// Reset the keychain and the cache.
- (void)resetKeychainItem;
// Access to the singleton shared instance from this property.
@property(nonatomic, readonly, class) KeychainWrapper* instance;
@end
#endif // REMOTING_IOS_KEYCHAIN_WRAPPER_H_
| 36.047619 | 77 | 0.729855 |
aba91ad1345fd252d73d267360be7ca00bbb7754 | 39 | h | C | tests/fixtures/func1.h | jayvdb/lcov-tool | fecc2c7eff95cc2c0d897c7f4a66a67e8c4866f7 | [
"Apache-2.0",
"MIT"
] | 4 | 2017-09-04T12:03:35.000Z | 2021-06-02T12:38:16.000Z | tests/fixtures/func1.h | jayvdb/lcov-tool | fecc2c7eff95cc2c0d897c7f4a66a67e8c4866f7 | [
"Apache-2.0",
"MIT"
] | 10 | 2015-07-06T16:04:31.000Z | 2018-04-12T05:31:14.000Z | tests/fixtures/func1.h | holyshared/lcov-merge | 4b21e54cf4195cf2f71d60ed9c03f68a42d71400 | [
"Apache-2.0",
"MIT"
] | 1 | 2022-01-28T03:15:19.000Z | 2022-01-28T03:15:19.000Z | extern void func1(int con1, int con2);
| 19.5 | 38 | 0.74359 |
3944752dc022cfb20be5569fca6de315e92fd3a8 | 3,970 | c | C | libcfx/Generated/cfx_completion_callback.c | hgthirty/chromiumfx | 39274871c40f087fe2f416b4b74dccd9ab81553b | [
"BSD-3-Clause"
] | null | null | null | libcfx/Generated/cfx_completion_callback.c | hgthirty/chromiumfx | 39274871c40f087fe2f416b4b74dccd9ab81553b | [
"BSD-3-Clause"
] | null | null | null | libcfx/Generated/cfx_completion_callback.c | hgthirty/chromiumfx | 39274871c40f087fe2f416b4b74dccd9ab81553b | [
"BSD-3-Clause"
] | null | null | null | // Copyright (c) 2014-2015 Wolfgang Borgsmüller
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder 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 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.
// Generated file. Do not edit.
// cef_completion_callback
typedef struct _cfx_completion_callback_t {
cef_completion_callback_t cef_completion_callback;
unsigned int ref_count;
gc_handle_t gc_handle;
} cfx_completion_callback_t;
void CEF_CALLBACK _cfx_completion_callback_add_ref(struct _cef_base_t* base) {
InterlockedIncrement(&((cfx_completion_callback_t*)base)->ref_count);
}
int CEF_CALLBACK _cfx_completion_callback_release(struct _cef_base_t* base) {
int count = InterlockedDecrement(&((cfx_completion_callback_t*)base)->ref_count);
if(!count) {
cfx_gc_handle_free(((cfx_completion_callback_t*)base)->gc_handle);
free(base);
return 1;
}
return 0;
}
int CEF_CALLBACK _cfx_completion_callback_has_one_ref(struct _cef_base_t* base) {
return ((cfx_completion_callback_t*)base)->ref_count == 1 ? 1 : 0;
}
static cfx_completion_callback_t* cfx_completion_callback_ctor(gc_handle_t gc_handle) {
cfx_completion_callback_t* ptr = (cfx_completion_callback_t*)calloc(1, sizeof(cfx_completion_callback_t));
if(!ptr) return 0;
ptr->cef_completion_callback.base.size = sizeof(cef_completion_callback_t);
ptr->cef_completion_callback.base.add_ref = _cfx_completion_callback_add_ref;
ptr->cef_completion_callback.base.release = _cfx_completion_callback_release;
ptr->cef_completion_callback.base.has_one_ref = _cfx_completion_callback_has_one_ref;
ptr->ref_count = 1;
ptr->gc_handle = gc_handle;
return ptr;
}
static gc_handle_t cfx_completion_callback_get_gc_handle(cfx_completion_callback_t* self) {
return self->gc_handle;
}
// on_complete
void (CEF_CALLBACK *cfx_completion_callback_on_complete_callback)(gc_handle_t self);
void CEF_CALLBACK cfx_completion_callback_on_complete(cef_completion_callback_t* self) {
cfx_completion_callback_on_complete_callback(((cfx_completion_callback_t*)self)->gc_handle);
}
static void cfx_completion_callback_set_managed_callback(cef_completion_callback_t* self, int index, void* callback) {
switch(index) {
case 0:
if(callback && !cfx_completion_callback_on_complete_callback)
cfx_completion_callback_on_complete_callback = (void (CEF_CALLBACK *)(gc_handle_t self)) callback;
self->on_complete = callback ? cfx_completion_callback_on_complete : 0;
break;
}
}
| 42.688172 | 118 | 0.771033 |
823b6705b0fd99a7b34bdcbef83654da9470f34a | 1,462 | c | C | srcs/token/lst/token_lst_print.c | JonathanDUFOUR/minishell | c89664f92795752c1f6fcf8dec72ea15e848006c | [
"MIT"
] | null | null | null | srcs/token/lst/token_lst_print.c | JonathanDUFOUR/minishell | c89664f92795752c1f6fcf8dec72ea15e848006c | [
"MIT"
] | null | null | null | srcs/token/lst/token_lst_print.c | JonathanDUFOUR/minishell | c89664f92795752c1f6fcf8dec72ea15e848006c | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* token_lst_print.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jodufour <jodufour@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/02 00:50:50 by jodufour #+# #+# */
/* Updated: 2022/01/20 14:12:49 by jodufour ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include "t_token_lst.h"
/*
Print the given token `lst` data
*/
void token_lst_print(t_token_lst const *const lst)
{
t_token const *curr;
printf("%s:\n", __func__);
if (1)
printf("%15s: %p\n", "lst->head", lst->head);
if (1)
printf("%15s: %p\n", "lst->tail", lst->tail);
if (1)
printf("%15s: %zu\n\n", "lst->size", lst->size);
curr = lst->head;
if (curr)
printf("==========================================\n");
while (curr)
{
token_print(curr);
curr = curr->next;
printf("==========================================\n");
}
}
| 36.55 | 80 | 0.269494 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.