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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9a4b1ddb62afc2be2b1fd0a30174d19a847d37c0 | 1,976 | h | C | src/game.h | jmanly56/SFML-Project | 981e7bdd6f8bab2d32f55b72b67c5b7f1eeccd1b | [
"MIT"
] | 1 | 2019-11-21T04:13:45.000Z | 2019-11-21T04:13:45.000Z | src/game.h | jmanly56/SFML-Project | 981e7bdd6f8bab2d32f55b72b67c5b7f1eeccd1b | [
"MIT"
] | null | null | null | src/game.h | jmanly56/SFML-Project | 981e7bdd6f8bab2d32f55b72b67c5b7f1eeccd1b | [
"MIT"
] | null | null | null | #ifndef GAME_H
#define GAME_H
#define WIDTH 640
#define HEIGHT 860
#define DEFAULT_FPS 60
#define STARTTIME
#define LEVEL1 1
#define LEVEL2 20
#define LEVEL3 60
#define LEVEL4 120
#define LEVEL5 200
#include <iostream>
#include <vector>
#include <SFML/Graphics.hpp>
#include "gameobject.h"
#include "projectile.h"
#include "player.h"
class Audio;
class Graphics;
class Enemy;
class Game
{
public:
//Functions
Game();
~Game();
void run();
void testRun();
void cleanup();
void addGameObject(GameObject &object);
void init();
static sf::Time getDeltaTime();
friend class TestClass;
private:
//Constants
bool shouldClose;
bool gameOver;
bool startup;
static sf::Time deltaTime;
const std::string window_name = "Space Shooter";
//Game Objects
std::vector<GameObject*> gameObjects;
std::vector<Projectile*> projectiles;
std::vector<sf::Text *> texts;
void handleKeys(sf::Time elapsedTime);
void updateGameObjects();
void createEnemies(uint32_t quantity, int32_t moveSpeed, int32_t attackSpeed, uint32_t projectileSpeed, uint32_t lives, std::string texture_path);
Enemy *createEnemy(int32_t moveSpeed, int32_t attackSpeed, uint32_t projectileSpeed, uint32_t lives);
void enemyAttack();
void checkCollisions();
void initText();
void spawnEnemy();
void restart();
void manageLevel();
void startUp();
void startGame(sf::Vector2i mousePos);
sf::Clock spawnTimer;
float spawnSpeed = 4;
uint32_t spawnQuantity;
int maxEnemies;
int currentEnemiesSpawned;
int totalSpawnedEnemies;
std::string currentLevel;
int scoreNum;
int fireChance;
sf::Font *font;
sf::Text *score;
sf::Text *lives;
sf::Text *gameDone;
sf::Text *level;
sf::Text* startText;
Audio *audio;
Player *player;
GameObject *background;
GameObject* startButton;
Graphics *graphics;
sf::RenderWindow *window;
};
#endif // GAME_H
| 22.202247 | 150 | 0.69332 |
9a990346b981abf594860d15ee8ffa139494cf74 | 464 | h | C | SproutedUtilities.framework/Versions/A/Headers/NSParagraphStyle_PDAdditions.h | phildow/SproutedInterface | b46a6ed56e8f796b974df26a4406b4947bdfc9da | [
"Unlicense"
] | 1 | 2015-08-29T02:32:25.000Z | 2015-08-29T02:32:25.000Z | SproutedUtilities.framework/Versions/A/Headers/NSParagraphStyle_PDAdditions.h | phildow/SproutedInterface | b46a6ed56e8f796b974df26a4406b4947bdfc9da | [
"Unlicense"
] | null | null | null | SproutedUtilities.framework/Versions/A/Headers/NSParagraphStyle_PDAdditions.h | phildow/SproutedInterface | b46a6ed56e8f796b974df26a4406b4947bdfc9da | [
"Unlicense"
] | null | null | null | //
// NSParagraphStyle_PDAdditions.h
// SproutedUtilities
//
// Created by Philip Dow on 2/3/07.
// Copyright Sprouted. All rights reserved.
// All inquiries should be directed to developer@journler.com
//
#import <Cocoa/Cocoa.h>
@interface NSParagraphStyle (PDAdditions)
+ (NSParagraphStyle*) defaultParagraphStyleWithLineBreakMode:(NSLineBreakMode)lineBreak;
+ (NSParagraphStyle*) defaultParagraphStyleWithAlignment:(NSTextAlignment)textAlignment;
@end
| 24.421053 | 88 | 0.788793 |
5cd7b32604a86c00120af42a861618eacc986a18 | 2,648 | h | C | chrome/browser/ash/login/screens/enable_debugging_screen.h | DamieFC/chromium | 54ce2d3c77723697efd22cfdb02aea38f9dfa25c | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1 | 2020-10-18T02:33:40.000Z | 2020-10-18T02:33:40.000Z | chrome/browser/ash/login/screens/enable_debugging_screen.h | DamieFC/chromium | 54ce2d3c77723697efd22cfdb02aea38f9dfa25c | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 3 | 2021-05-17T16:28:52.000Z | 2021-05-21T22:42:22.000Z | chrome/browser/ash/login/screens/enable_debugging_screen.h | DamieFC/chromium | 54ce2d3c77723697efd22cfdb02aea38f9dfa25c | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | // Copyright (c) 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ASH_LOGIN_SCREENS_ENABLE_DEBUGGING_SCREEN_H_
#define CHROME_BROWSER_ASH_LOGIN_SCREENS_ENABLE_DEBUGGING_SCREEN_H_
#include <string>
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ash/login/screens/base_screen.h"
#include "chrome/browser/ui/webui/chromeos/login/enable_debugging_screen_handler.h"
namespace ash {
// Representation independent class that controls screen showing enable
// debugging screen to users.
class EnableDebuggingScreen : public BaseScreen {
public:
EnableDebuggingScreen(EnableDebuggingScreenView* view,
const base::RepeatingClosure& exit_callback);
~EnableDebuggingScreen() override;
// Called by EnableDebuggingScreenHandler.
void OnViewDestroyed(EnableDebuggingScreenView* view);
void HandleSetup(const std::string& password);
protected:
// BaseScreen:
void ShowImpl() override;
void HideImpl() override;
void OnUserAction(const std::string& action_id) override;
base::RepeatingClosure* exit_callback() { return &exit_callback_; }
private:
// Handle user actions
void HandleLearnMore();
void HandleRemoveRootFSProtection();
// Wait for cryptohomed before checking debugd. See http://crbug.com/440506
void WaitForCryptohome();
// Callback for UserDataAuthClient::WaitForServiceToBeAvailable
void OnCryptohomeDaemonAvailabilityChecked(bool service_is_available);
// Callback for DebugDaemonClient::WaitForServiceToBeAvailable
void OnDebugDaemonServiceAvailabilityChecked(bool service_is_available);
// Callback for DebugDaemonClient::EnableDebuggingFeatures().
void OnEnableDebuggingFeatures(bool success);
// Callback for DebugDaemonClient::QueryDebuggingFeatures().
void OnQueryDebuggingFeatures(bool success, int features_flag);
// Callback for DebugDaemonClient::RemoveRootfsVerification().
void OnRemoveRootfsVerification(bool success);
void UpdateUIState(EnableDebuggingScreenView::UIState state);
EnableDebuggingScreenView* view_;
base::RepeatingClosure exit_callback_;
base::WeakPtrFactory<EnableDebuggingScreen> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(EnableDebuggingScreen);
};
} // namespace ash
// TODO(https://crbug.com/1164001): remove after the //chrome/browser/chromeos
// source migration is finished.
namespace chromeos {
using ::ash::EnableDebuggingScreen;
}
#endif // CHROME_BROWSER_ASH_LOGIN_SCREENS_ENABLE_DEBUGGING_SCREEN_H_
| 33.1 | 83 | 0.796073 |
68482172e9025c7d71c2b9f2cdedb41a2177a1bd | 662 | h | C | worker/Tool/NSObject+UITool.h | pengfei923/LPFNetwork | f3646c86eb8b1ea0d355d35aaaba0750c883b66c | [
"MIT"
] | 1 | 2018-08-10T07:47:04.000Z | 2018-08-10T07:47:04.000Z | worker/Tool/NSObject+UITool.h | pengfei923/LPFNetwork | f3646c86eb8b1ea0d355d35aaaba0750c883b66c | [
"MIT"
] | null | null | null | worker/Tool/NSObject+UITool.h | pengfei923/LPFNetwork | f3646c86eb8b1ea0d355d35aaaba0750c883b66c | [
"MIT"
] | null | null | null | //
// NSObject+UITool.h
// Baili
//
// Created by xabaili on 15/12/12.
// Copyright © 2015年 Baili. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSObject (UITool)
/// 判断UITextField或UILabel中的内容是否为空
- (BOOL)contentIsEmptyWithTextFieldOrLabelArray:(NSArray *)array;
/// 判断UITextField或UILabel中的内容是否相等
- (BOOL)contentIsEqualWithTextFieldOrLabelArray:(NSArray *)array;
/**
* 获取通过xib设计的UIView或UITableViewCell高度
*
* @param nibName xib文件名
*
* @return cell的高度
*/
- (CGFloat)viewHeightWithNibName:(NSString *)nibName;
/// 去除导航栏底部横线
- (UIImageView *)findHairlineImageViewUnder:(UIView *)view;
/// 收起键盘
- (void)hideKeyboard;
@end
| 18.388889 | 65 | 0.732628 |
04c77e96895d250b03edf69b754fc235b1e360a1 | 32,234 | h | C | mitdevices/mitdevices_msg.h | fluffynukeit/mdsplus | a204d2e9d26554bb035945595210f2a57d187250 | [
"BSD-2-Clause"
] | 53 | 2015-01-05T08:55:13.000Z | 2022-03-30T07:43:41.000Z | mitdevices/mitdevices_msg.h | fluffynukeit/mdsplus | a204d2e9d26554bb035945595210f2a57d187250 | [
"BSD-2-Clause"
] | 1,231 | 2015-02-02T18:54:02.000Z | 2022-03-30T08:27:45.000Z | mitdevices/mitdevices_msg.h | fluffynukeit/mdsplus | a204d2e9d26554bb035945595210f2a57d187250 | [
"BSD-2-Clause"
] | 44 | 2015-05-24T20:18:06.000Z | 2022-02-07T13:51:04.000Z | #ifndef MDSMSG_CONSTANTS
#define MDSMSG_CONSTANTS
#define MSG_FATAL 0
#define MSG_SUCCESS 1
#define MSG_ERROR 2
#define MSG_INFO 3
#define MSG_WARNING 4
#define MSG_MASK 0x8008000
#define MSG_FACNUM_M 0x40000
#define MSG_MSGNUM_M 8
#endif
#define DEV$_BAD_ENDIDX \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_BAD_FILTER \
(MSG_MASK + 2015 * MSG_FACNUM_M + 2 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_BAD_FREQ \
(MSG_MASK + 2015 * MSG_FACNUM_M + 3 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_BAD_GAIN \
(MSG_MASK + 2015 * MSG_FACNUM_M + 4 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_BAD_HEADER \
(MSG_MASK + 2015 * MSG_FACNUM_M + 5 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_BAD_HEADER_IDX \
(MSG_MASK + 2015 * MSG_FACNUM_M + 6 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_BAD_MEMORIES \
(MSG_MASK + 2015 * MSG_FACNUM_M + 7 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_BAD_MODE \
(MSG_MASK + 2015 * MSG_FACNUM_M + 8 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_BAD_NAME \
(MSG_MASK + 2015 * MSG_FACNUM_M + 9 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_BAD_OFFSET \
(MSG_MASK + 2015 * MSG_FACNUM_M + 10 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_BAD_STARTIDX \
(MSG_MASK + 2015 * MSG_FACNUM_M + 11 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_NOT_TRIGGERED \
(MSG_MASK + 2015 * MSG_FACNUM_M + 12 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_FREQ_TOO_HIGH \
(MSG_MASK + 2015 * MSG_FACNUM_M + 13 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_INVALID_NOC \
(MSG_MASK + 2015 * MSG_FACNUM_M + 14 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_RANGE_MISMATCH \
(MSG_MASK + 2015 * MSG_FACNUM_M + 15 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_CAMACERR \
(MSG_MASK + 2015 * MSG_FACNUM_M + 16 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_BAD_VERBS \
(MSG_MASK + 2015 * MSG_FACNUM_M + 17 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_BAD_COMMANDS \
(MSG_MASK + 2015 * MSG_FACNUM_M + 18 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_CAM_ADNR \
(MSG_MASK + 2015 * MSG_FACNUM_M + 19 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_CAM_ERR \
(MSG_MASK + 2015 * MSG_FACNUM_M + 20 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_CAM_LOSYNC \
(MSG_MASK + 2015 * MSG_FACNUM_M + 21 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_CAM_LPE \
(MSG_MASK + 2015 * MSG_FACNUM_M + 22 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_CAM_TMO \
(MSG_MASK + 2015 * MSG_FACNUM_M + 23 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_CAM_TPE \
(MSG_MASK + 2015 * MSG_FACNUM_M + 24 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_CAM_STE \
(MSG_MASK + 2015 * MSG_FACNUM_M + 25 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_CAM_DERR \
(MSG_MASK + 2015 * MSG_FACNUM_M + 26 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_CAM_SQ \
(MSG_MASK + 2015 * MSG_FACNUM_M + 27 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_CAM_NOSQ \
(MSG_MASK + 2015 * MSG_FACNUM_M + 28 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_CAM_SX \
(MSG_MASK + 2015 * MSG_FACNUM_M + 29 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_CAM_NOSX \
(MSG_MASK + 2015 * MSG_FACNUM_M + 30 * MSG_MSGNUM_M + MSG_ERROR)
#define DEV$_INV_SETUP \
(MSG_MASK + 2015 * MSG_FACNUM_M + 31 * MSG_MSGNUM_M + MSG_ERROR)
#define RETICON$_NORMAL \
(MSG_MASK + 2015 * MSG_FACNUM_M + 51 * MSG_MSGNUM_M + MSG_SUCCESS)
#define RETICON$_BAD_FRAMES \
(MSG_MASK + 2015 * MSG_FACNUM_M + 52 * MSG_MSGNUM_M + MSG_ERROR)
#define RETICON$_BAD_FRAME_SELECT \
(MSG_MASK + 2015 * MSG_FACNUM_M + 53 * MSG_MSGNUM_M + MSG_ERROR)
#define RETICON$_BAD_NUM_STATES \
(MSG_MASK + 2015 * MSG_FACNUM_M + 54 * MSG_MSGNUM_M + MSG_ERROR)
#define RETICON$_BAD_PERIOD \
(MSG_MASK + 2015 * MSG_FACNUM_M + 55 * MSG_MSGNUM_M + MSG_ERROR)
#define RETICON$_BAD_PIXEL_SELECT \
(MSG_MASK + 2015 * MSG_FACNUM_M + 56 * MSG_MSGNUM_M + MSG_ERROR)
#define RETICON$_DATA_CORRUPTED \
(MSG_MASK + 2015 * MSG_FACNUM_M + 57 * MSG_MSGNUM_M + MSG_ERROR)
#define RETICON$_TOO_MANY_FRAMES \
(MSG_MASK + 2015 * MSG_FACNUM_M + 58 * MSG_MSGNUM_M + MSG_ERROR)
#define J221$_NORMAL \
(MSG_MASK + 2015 * MSG_FACNUM_M + 101 * MSG_MSGNUM_M + MSG_SUCCESS)
#define J221$_INVALID_DATA \
(MSG_MASK + 2015 * MSG_FACNUM_M + 102 * MSG_MSGNUM_M + MSG_WARNING)
#define J221$_NO_DATA \
(MSG_MASK + 2015 * MSG_FACNUM_M + 103 * MSG_MSGNUM_M + MSG_ERROR)
#define TIMING$_INVCLKFRQ \
(MSG_MASK + 2015 * MSG_FACNUM_M + 151 * MSG_MSGNUM_M + MSG_ERROR)
#define TIMING$_INVDELDUR \
(MSG_MASK + 2015 * MSG_FACNUM_M + 152 * MSG_MSGNUM_M + MSG_ERROR)
#define TIMING$_INVOUTCTR \
(MSG_MASK + 2015 * MSG_FACNUM_M + 153 * MSG_MSGNUM_M + MSG_ERROR)
#define TIMING$_INVPSEUDODEV \
(MSG_MASK + 2015 * MSG_FACNUM_M + 154 * MSG_MSGNUM_M + MSG_ERROR)
#define TIMING$_INVTRGMOD \
(MSG_MASK + 2015 * MSG_FACNUM_M + 155 * MSG_MSGNUM_M + MSG_ERROR)
#define TIMING$_NOPSEUDODEV \
(MSG_MASK + 2015 * MSG_FACNUM_M + 156 * MSG_MSGNUM_M + MSG_INFO)
#define TIMING$_TOO_MANY_EVENTS \
(MSG_MASK + 2015 * MSG_FACNUM_M + 157 * MSG_MSGNUM_M + MSG_ERROR)
#define TIMING$_INVDUTY \
(MSG_MASK + 2015 * MSG_FACNUM_M + 158 * MSG_MSGNUM_M + MSG_ERROR)
#define TIMING$_ \
(MSG_MASK + 2015 * MSG_FACNUM_M + 159 * MSG_MSGNUM_M + MSG_ERROR)
#define B2408$_NORMAL \
(MSG_MASK + 2015 * MSG_FACNUM_M + 201 * MSG_MSGNUM_M + MSG_SUCCESS)
#define B2408$_OVERFLOW \
(MSG_MASK + 2015 * MSG_FACNUM_M + 202 * MSG_MSGNUM_M + MSG_INFO)
#define B2408$_TRIG_LIM \
(MSG_MASK + 2015 * MSG_FACNUM_M + 203 * MSG_MSGNUM_M + MSG_WARNING)
#define FERA$_NORMAL \
(MSG_MASK + 2015 * MSG_FACNUM_M + 251 * MSG_MSGNUM_M + MSG_SUCCESS)
#define FERA$_DIGNOTSTRARRAY \
(MSG_MASK + 2015 * MSG_FACNUM_M + 252 * MSG_MSGNUM_M + MSG_ERROR)
#define FERA$_NODIG \
(MSG_MASK + 2015 * MSG_FACNUM_M + 253 * MSG_MSGNUM_M + MSG_ERROR)
#define FERA$_MEMNOTSTRARRAY \
(MSG_MASK + 2015 * MSG_FACNUM_M + 254 * MSG_MSGNUM_M + MSG_ERROR)
#define FERA$_NOMEM \
(MSG_MASK + 2015 * MSG_FACNUM_M + 255 * MSG_MSGNUM_M + MSG_ERROR)
#define FERA$_PHASE_LOST \
(MSG_MASK + 2015 * MSG_FACNUM_M + 256 * MSG_MSGNUM_M + MSG_ERROR)
#define FERA$_CONFUSED \
(MSG_MASK + 2015 * MSG_FACNUM_M + 257 * MSG_MSGNUM_M + MSG_WARNING)
#define FERA$_OVER_RUN \
(MSG_MASK + 2015 * MSG_FACNUM_M + 258 * MSG_MSGNUM_M + MSG_WARNING)
#define FERA$_OVERFLOW \
(MSG_MASK + 2015 * MSG_FACNUM_M + 259 * MSG_MSGNUM_M + MSG_INFO)
#define HM650$_NORMAL \
(MSG_MASK + 2015 * MSG_FACNUM_M + 301 * MSG_MSGNUM_M + MSG_SUCCESS)
#define HM650$_DLYCHNG \
(MSG_MASK + 2015 * MSG_FACNUM_M + 302 * MSG_MSGNUM_M + MSG_WARNING)
#define HV4032$_NORMAL \
(MSG_MASK + 2015 * MSG_FACNUM_M + 351 * MSG_MSGNUM_M + MSG_SUCCESS)
#define HV4032$_WRONG_POD_TYPE \
(MSG_MASK + 2015 * MSG_FACNUM_M + 352 * MSG_MSGNUM_M + MSG_ERROR)
#define HV1440$_NORMAL \
(MSG_MASK + 2015 * MSG_FACNUM_M + 401 * MSG_MSGNUM_M + MSG_SUCCESS)
#define HV1440$_WRONG_POD_TYPE \
(MSG_MASK + 2015 * MSG_FACNUM_M + 402 * MSG_MSGNUM_M + MSG_ERROR)
#define HV1440$_BAD_FRAME \
(MSG_MASK + 2015 * MSG_FACNUM_M + 403 * MSG_MSGNUM_M + MSG_ERROR)
#define HV1440$_BAD_RANGE \
(MSG_MASK + 2015 * MSG_FACNUM_M + 404 * MSG_MSGNUM_M + MSG_ERROR)
#define HV1440$_OUTRNG \
(MSG_MASK + 2015 * MSG_FACNUM_M + 405 * MSG_MSGNUM_M + MSG_ERROR)
#define HV1440$_STUCK \
(MSG_MASK + 2015 * MSG_FACNUM_M + 406 * MSG_MSGNUM_M + MSG_ERROR)
#define JOERGER$_BAD_PRE_TRIGGER \
(MSG_MASK + 2015 * MSG_FACNUM_M + 451 * MSG_MSGNUM_M + MSG_ERROR)
#define JOERGER$_BAD_ACT_MEMORY \
(MSG_MASK + 2015 * MSG_FACNUM_M + 452 * MSG_MSGNUM_M + MSG_ERROR)
#define JOERGER$_BAD_GAIN \
(MSG_MASK + 2015 * MSG_FACNUM_M + 453 * MSG_MSGNUM_M + MSG_ERROR)
#define U_OF_M$_BAD_WAVE_LENGTH \
(MSG_MASK + 2015 * MSG_FACNUM_M + 501 * MSG_MSGNUM_M + MSG_ERROR)
#define U_OF_M$_BAD_SLIT_WIDTH \
(MSG_MASK + 2015 * MSG_FACNUM_M + 502 * MSG_MSGNUM_M + MSG_ERROR)
#define U_OF_M$_BAD_NUM_SPECTRA \
(MSG_MASK + 2015 * MSG_FACNUM_M + 503 * MSG_MSGNUM_M + MSG_ERROR)
#define U_OF_M$_BAD_GRATING \
(MSG_MASK + 2015 * MSG_FACNUM_M + 504 * MSG_MSGNUM_M + MSG_ERROR)
#define U_OF_M$_BAD_EXPOSURE \
(MSG_MASK + 2015 * MSG_FACNUM_M + 505 * MSG_MSGNUM_M + MSG_ERROR)
#define U_OF_M$_BAD_FILTER \
(MSG_MASK + 2015 * MSG_FACNUM_M + 506 * MSG_MSGNUM_M + MSG_ERROR)
#define U_OF_M$_GO_FILE_ERROR \
(MSG_MASK + 2015 * MSG_FACNUM_M + 507 * MSG_MSGNUM_M + MSG_ERROR)
#define U_OF_M$_DATA_FILE_ERROR \
(MSG_MASK + 2015 * MSG_FACNUM_M + 508 * MSG_MSGNUM_M + MSG_ERROR)
#define IDL$_NORMAL \
(MSG_MASK + 2015 * MSG_FACNUM_M + 551 * MSG_MSGNUM_M + MSG_SUCCESS)
#define IDL$_ERROR \
(MSG_MASK + 2015 * MSG_FACNUM_M + 552 * MSG_MSGNUM_M + MSG_ERROR)
#define B5910A$_BAD_CHAN \
(MSG_MASK + 2015 * MSG_FACNUM_M + 601 * MSG_MSGNUM_M + MSG_ERROR)
#define B5910A$_BAD_CLOCK \
(MSG_MASK + 2015 * MSG_FACNUM_M + 602 * MSG_MSGNUM_M + MSG_ERROR)
#define B5910A$_BAD_ITERATIONS \
(MSG_MASK + 2015 * MSG_FACNUM_M + 603 * MSG_MSGNUM_M + MSG_ERROR)
#define B5910A$_BAD_NOC \
(MSG_MASK + 2015 * MSG_FACNUM_M + 604 * MSG_MSGNUM_M + MSG_ERROR)
#define B5910A$_BAD_SAMPS \
(MSG_MASK + 2015 * MSG_FACNUM_M + 605 * MSG_MSGNUM_M + MSG_ERROR)
#define J412$_NOT_SORTED \
(MSG_MASK + 2015 * MSG_FACNUM_M + 651 * MSG_MSGNUM_M + MSG_ERROR)
#define J412$_NO_DATA \
(MSG_MASK + 2015 * MSG_FACNUM_M + 652 * MSG_MSGNUM_M + MSG_ERROR)
#define J412$_BADCYCLES \
(MSG_MASK + 2015 * MSG_FACNUM_M + 653 * MSG_MSGNUM_M + MSG_ERROR)
#define TR16$_NORMAL \
(MSG_MASK + 2015 * MSG_FACNUM_M + 701 * MSG_MSGNUM_M + MSG_SUCCESS)
#define TR16$_BAD_MEMSIZE \
(MSG_MASK + 2015 * MSG_FACNUM_M + 702 * MSG_MSGNUM_M + MSG_ERROR)
#define TR16$_BAD_ACTIVEMEM \
(MSG_MASK + 2015 * MSG_FACNUM_M + 703 * MSG_MSGNUM_M + MSG_ERROR)
#define TR16$_BAD_ACTIVECHAN \
(MSG_MASK + 2015 * MSG_FACNUM_M + 704 * MSG_MSGNUM_M + MSG_ERROR)
#define TR16$_BAD_PTS \
(MSG_MASK + 2015 * MSG_FACNUM_M + 705 * MSG_MSGNUM_M + MSG_ERROR)
#define TR16$_BAD_FREQUENCY \
(MSG_MASK + 2015 * MSG_FACNUM_M + 706 * MSG_MSGNUM_M + MSG_ERROR)
#define TR16$_BAD_MASTER \
(MSG_MASK + 2015 * MSG_FACNUM_M + 707 * MSG_MSGNUM_M + MSG_ERROR)
#define TR16$_BAD_GAIN \
(MSG_MASK + 2015 * MSG_FACNUM_M + 708 * MSG_MSGNUM_M + MSG_ERROR)
#define A14$_NORMAL \
(MSG_MASK + 2015 * MSG_FACNUM_M + 751 * MSG_MSGNUM_M + MSG_SUCCESS)
#define A14$_BAD_CLK_DIVIDE \
(MSG_MASK + 2015 * MSG_FACNUM_M + 752 * MSG_MSGNUM_M + MSG_ERROR)
#define A14$_BAD_MODE \
(MSG_MASK + 2015 * MSG_FACNUM_M + 753 * MSG_MSGNUM_M + MSG_ERROR)
#define A14$_BAD_CLK_POLARITY \
(MSG_MASK + 2015 * MSG_FACNUM_M + 754 * MSG_MSGNUM_M + MSG_ERROR)
#define A14$_BAD_STR_POLARITY \
(MSG_MASK + 2015 * MSG_FACNUM_M + 755 * MSG_MSGNUM_M + MSG_ERROR)
#define A14$_BAD_STP_POLARITY \
(MSG_MASK + 2015 * MSG_FACNUM_M + 756 * MSG_MSGNUM_M + MSG_ERROR)
#define A14$_BAD_GATED \
(MSG_MASK + 2015 * MSG_FACNUM_M + 757 * MSG_MSGNUM_M + MSG_ERROR)
#define L6810$_NORMAL \
(MSG_MASK + 2015 * MSG_FACNUM_M + 801 * MSG_MSGNUM_M + MSG_SUCCESS)
#define L6810$_BAD_ACTIVECHAN \
(MSG_MASK + 2015 * MSG_FACNUM_M + 802 * MSG_MSGNUM_M + MSG_ERROR)
#define L6810$_BAD_ACTIVEMEM \
(MSG_MASK + 2015 * MSG_FACNUM_M + 803 * MSG_MSGNUM_M + MSG_ERROR)
#define L6810$_BAD_FREQUENCY \
(MSG_MASK + 2015 * MSG_FACNUM_M + 804 * MSG_MSGNUM_M + MSG_ERROR)
#define L6810$_BAD_FULL_SCALE \
(MSG_MASK + 2015 * MSG_FACNUM_M + 805 * MSG_MSGNUM_M + MSG_ERROR)
#define L6810$_BAD_MEMORIES \
(MSG_MASK + 2015 * MSG_FACNUM_M + 806 * MSG_MSGNUM_M + MSG_ERROR)
#define L6810$_BAD_COUPLING \
(MSG_MASK + 2015 * MSG_FACNUM_M + 807 * MSG_MSGNUM_M + MSG_ERROR)
#define L6810$_BAD_OFFSET \
(MSG_MASK + 2015 * MSG_FACNUM_M + 808 * MSG_MSGNUM_M + MSG_ERROR)
#define L6810$_BAD_SEGMENTS \
(MSG_MASK + 2015 * MSG_FACNUM_M + 809 * MSG_MSGNUM_M + MSG_ERROR)
#define L6810$_BAD_TRIG_DELAY \
(MSG_MASK + 2015 * MSG_FACNUM_M + 810 * MSG_MSGNUM_M + MSG_ERROR)
#define J_DAC$_OUTRNG \
(MSG_MASK + 2015 * MSG_FACNUM_M + 851 * MSG_MSGNUM_M + MSG_ERROR)
#define INCAA$_BAD_ACTIVE_CHANS \
(MSG_MASK + 2015 * MSG_FACNUM_M + 901 * MSG_MSGNUM_M + MSG_ERROR)
#define INCAA$_BAD_MASTER \
(MSG_MASK + 2015 * MSG_FACNUM_M + 902 * MSG_MSGNUM_M + MSG_ERROR)
#define INCAA$_BAD_EXT_1MHZ \
(MSG_MASK + 2015 * MSG_FACNUM_M + 903 * MSG_MSGNUM_M + MSG_ERROR)
#define INCAA$_BAD_PTSC \
(MSG_MASK + 2015 * MSG_FACNUM_M + 904 * MSG_MSGNUM_M + MSG_ERROR)
#define L8212$_BAD_HEADER \
(MSG_MASK + 2015 * MSG_FACNUM_M + 951 * MSG_MSGNUM_M + MSG_ERROR)
#define L8212$_BAD_MEMORIES \
(MSG_MASK + 2015 * MSG_FACNUM_M + 952 * MSG_MSGNUM_M + MSG_ERROR)
#define L8212$_BAD_NOC \
(MSG_MASK + 2015 * MSG_FACNUM_M + 953 * MSG_MSGNUM_M + MSG_ERROR)
#define L8212$_BAD_OFFSET \
(MSG_MASK + 2015 * MSG_FACNUM_M + 954 * MSG_MSGNUM_M + MSG_ERROR)
#define L8212$_BAD_PTS \
(MSG_MASK + 2015 * MSG_FACNUM_M + 955 * MSG_MSGNUM_M + MSG_ERROR)
#define L8212$_FREQ_TOO_HIGH \
(MSG_MASK + 2015 * MSG_FACNUM_M + 956 * MSG_MSGNUM_M + MSG_ERROR)
#define L8212$_INVALID_NOC \
(MSG_MASK + 2015 * MSG_FACNUM_M + 957 * MSG_MSGNUM_M + MSG_ERROR)
#define MPB$_BADTIME \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1001 * MSG_MSGNUM_M + MSG_ERROR)
#define MPB$_BADFREQ \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1002 * MSG_MSGNUM_M + MSG_ERROR)
#define L8828$_BAD_OFFSET \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1051 * MSG_MSGNUM_M + MSG_ERROR)
#define L8828$_BAD_PRETRIG \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1052 * MSG_MSGNUM_M + MSG_ERROR)
#define L8828$_BAD_ACTIVEMEM \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1053 * MSG_MSGNUM_M + MSG_ERROR)
#define L8828$_BAD_CLOCK \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1054 * MSG_MSGNUM_M + MSG_ERROR)
#define L8818$_BAD_OFFSET \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1101 * MSG_MSGNUM_M + MSG_ERROR)
#define L8818$_BAD_PRETRIG \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1102 * MSG_MSGNUM_M + MSG_ERROR)
#define L8818$_BAD_ACTIVEMEM \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1103 * MSG_MSGNUM_M + MSG_ERROR)
#define L8818$_BAD_CLOCK \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1104 * MSG_MSGNUM_M + MSG_ERROR)
#define J_TR612$_BAD_ACTMEM \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1111 * MSG_MSGNUM_M + MSG_ERROR)
#define J_TR612$_BAD_PRETRIG \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1112 * MSG_MSGNUM_M + MSG_ERROR)
#define J_TR612$_BAD_MODE \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1113 * MSG_MSGNUM_M + MSG_ERROR)
#define J_TR612$_BAD_FREQUENCY \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1114 * MSG_MSGNUM_M + MSG_ERROR)
#define L8206$_NODATA \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1151 * MSG_MSGNUM_M + MSG_WARNING)
#define H912$_BAD_CLOCK \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1161 * MSG_MSGNUM_M + MSG_ERROR)
#define H912$_BAD_BLOCKS \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1162 * MSG_MSGNUM_M + MSG_ERROR)
#define H912$_BAD_PTS \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1163 * MSG_MSGNUM_M + MSG_ERROR)
#define H908$_BAD_CLOCK \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1171 * MSG_MSGNUM_M + MSG_ERROR)
#define H908$_BAD_ACTIVE_CHANS \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1172 * MSG_MSGNUM_M + MSG_ERROR)
#define H908$_BAD_PTS \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1173 * MSG_MSGNUM_M + MSG_ERROR)
#define DSP2904$_CHANNEL_READ_ERROR \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1181 * MSG_MSGNUM_M + MSG_ERROR)
#define PY$_UNHANDLED_EXCEPTION \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1191 * MSG_MSGNUM_M + MSG_ERROR)
#define DT196B$_NO_SAMPLES \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1201 * MSG_MSGNUM_M + MSG_ERROR)
#define ACQ$_INITIALIZATION_ERROR \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1202 * MSG_MSGNUM_M + MSG_ERROR)
#define ACQ$_SETTINGS_NOT_LOADED \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1203 * MSG_MSGNUM_M + MSG_ERROR)
#define ACQ$_WRONG_TREE \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1204 * MSG_MSGNUM_M + MSG_ERROR)
#define ACQ$_WRONG_PATH \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1205 * MSG_MSGNUM_M + MSG_ERROR)
#define ACQ$_WRONG_SHOT \
(MSG_MASK + 2015 * MSG_FACNUM_M + 1206 * MSG_MSGNUM_M + MSG_ERROR)
#ifdef MSG_LIBRARY
#include <stdlib.h>
EXPORT int getmsg(int sts, char **facnam, char **msgnam, char **msgtext)
{
static struct msg
{
int sts;
char *facnam;
char *msgnam;
char *msgtext;
} msgs[] = {
{DEV$_BAD_ENDIDX, "DEV", "BAD_ENDIDX",
"unable to read end index for channel"},
{DEV$_BAD_FILTER, "DEV", "BAD_FILTER", "illegal filter selected"},
{DEV$_BAD_FREQ, "DEV", "BAD_FREQ",
"illegal digitization frequency selected"},
{DEV$_BAD_GAIN, "DEV", "BAD_GAIN", "illegal gain selected"},
{DEV$_BAD_HEADER, "DEV", "BAD_HEADER", "unable to read header selection"},
{DEV$_BAD_HEADER_IDX, "DEV", "BAD_HEADER_IDX",
"unknown header configuration index"},
{DEV$_BAD_MEMORIES, "DEV", "BAD_MEMORIES",
"unable to read number of memory modules"},
{DEV$_BAD_MODE, "DEV", "BAD_MODE", "illegal mode selected"},
{DEV$_BAD_NAME, "DEV", "BAD_NAME", "unable to read module name"},
{DEV$_BAD_OFFSET, "DEV", "BAD_OFFSET", "illegal offset selected"},
{DEV$_BAD_STARTIDX, "DEV", "BAD_STARTIDX",
"unable to read start index for channel"},
{DEV$_NOT_TRIGGERED, "DEV", "NOT_TRIGGERED",
"device was not triggered, check wires and triggering device"},
{DEV$_FREQ_TOO_HIGH, "DEV", "FREQ_TOO_HIGH",
"the frequency is set to high for the requested number of channels"},
{DEV$_INVALID_NOC, "DEV", "INVALID_NOC",
"the NOC (number of channels) requested is greater than the physical "
"number of channels"},
{DEV$_RANGE_MISMATCH, "DEV", "RANGE_MISMATCH",
"the range specified on the menu doesn't match the range setting on the "
"device"},
{DEV$_CAMACERR, "DEV", "CAMACERR", "Error doing CAMAC IO"},
{DEV$_BAD_VERBS, "DEV", "BAD_VERBS",
"Error reading interpreter list (:VERBS)"},
{DEV$_BAD_COMMANDS, "DEV", "BAD_COMMANDS", "Error reading command list"},
{DEV$_CAM_ADNR, "DEV", "CAM_ADNR",
"CAMAC: Address not recognized (2160)"},
{DEV$_CAM_ERR, "DEV", "CAM_ERR",
"CAMAC: Error reported by crate controler"},
{DEV$_CAM_LOSYNC, "DEV", "CAM_LOSYNC",
"CAMAC: Lost Syncronization error"},
{DEV$_CAM_LPE, "DEV", "CAM_LPE", "CAMAC: Longitudinal Parity error"},
{DEV$_CAM_TMO, "DEV", "CAM_TMO", "CAMAC: Highway time out error"},
{DEV$_CAM_TPE, "DEV", "CAM_TPE", "CAMAC: Transverse Parity error"},
{DEV$_CAM_STE, "DEV", "CAM_STE", "CAMAC: Serial Transmission error"},
{DEV$_CAM_DERR, "DEV", "CAM_DERR", "CAMAC: Delayed error from SCC"},
{DEV$_CAM_SQ, "DEV", "CAM_SQ", "CAMAC: I/O completion with Q = 1"},
{DEV$_CAM_NOSQ, "DEV", "CAM_NOSQ", "CAMAC: I/O completion with Q = 0"},
{DEV$_CAM_SX, "DEV", "CAM_SX", "CAMAC: I/O completion with X = 1"},
{DEV$_CAM_NOSX, "DEV", "CAM_NOSX", "CAMAC: I/O completion with X = 0"},
{DEV$_INV_SETUP, "DEV", "INV_SETUP", "device was not properly set up"},
{RETICON$_NORMAL, "RETICON", "NORMAL", "successful completion"},
{RETICON$_BAD_FRAMES, "RETICON", "BAD_FRAMES",
"frame count must be less than or equal to 2048"},
{RETICON$_BAD_FRAME_SELECT, "RETICON", "BAD_FRAME_SELECT",
"frame interval must be 1,2,4,8,16,32 or 64"},
{RETICON$_BAD_NUM_STATES, "RETICON", "BAD_NUM_STATES",
"number of states must be between 1 and 4"},
{RETICON$_BAD_PERIOD, "RETICON", "BAD_PERIOD",
"period must be .5,1,2,4,8,16,32,64,128,256,512,1024,2048,4096 or 8192 "
"msec"},
{RETICON$_BAD_PIXEL_SELECT, "RETICON", "BAD_PIXEL_SELECT",
"pixel selection must be an array of 256 boolean values"},
{RETICON$_DATA_CORRUPTED, "RETICON", "DATA_CORRUPTED",
"data in memory is corrupted or framing error detected, no data stored"},
{RETICON$_TOO_MANY_FRAMES, "RETICON", "TOO_MANY_FRAMES",
"over 8192 frame start indicators in data read from memory"},
{J221$_NORMAL, "J221", "NORMAL", "successful completion"},
{J221$_INVALID_DATA, "J221", "INVALID_DATA",
"ignoring invalid data in channel !SL"},
{J221$_NO_DATA, "J221", "NO_DATA",
"no valid data was found for any channel"},
{TIMING$_INVCLKFRQ, "TIMING", "INVCLKFRQ", "Invalid clock frequency"},
{TIMING$_INVDELDUR, "TIMING", "INVDELDUR",
"Invalid pulse delay or duration, must be less than 655 seconds"},
{TIMING$_INVOUTCTR, "TIMING", "INVOUTCTR",
"Invalid output mode selected"},
{TIMING$_INVPSEUDODEV, "TIMING", "INVPSEUDODEV",
"Invalid pseudo device attached to this decoder channel"},
{TIMING$_INVTRGMOD, "TIMING", "INVTRGMOD",
"Invalid trigger mode selected"},
{TIMING$_NOPSEUDODEV, "TIMING", "NOPSEUDODEV",
"No Pseudo device attached to this channel ... disabling"},
{TIMING$_TOO_MANY_EVENTS, "TIMING", "TOO_MANY_EVENTS",
"More than 16 events used by this decoder"},
{TIMING$_INVDUTY, "TIMING", "INVDUTY",
"Invalid duty cycle specified for clock"},
{TIMING$_, "TIMING", "", "<"},
{B2408$_NORMAL, "B2408", "NORMAL", "successful completion"},
{B2408$_OVERFLOW, "B2408", "OVERFLOW",
"Triggers received after overflow"},
{B2408$_TRIG_LIM, "B2408", "TRIG_LIM", "Trigger limit possibly exceeded"},
{FERA$_NORMAL, "FERA", "NORMAL", "successful completion"},
{FERA$_DIGNOTSTRARRAY, "FERA", "DIGNOTSTRARRAY",
"The digitizer names must be an array of strings"},
{FERA$_NODIG, "FERA", "NODIG", "The digitizer names must be specified"},
{FERA$_MEMNOTSTRARRAY, "FERA", "MEMNOTSTRARRAY",
"The memory names must be an array of strings"},
{FERA$_NOMEM, "FERA", "NOMEM", "The memory names must be specified"},
{FERA$_PHASE_LOST, "FERA", "PHASE_LOST",
"Data phase lost No FERA data stored"},
{FERA$_CONFUSED, "FERA", "CONFUSED",
"Fera Data inconsitant. Data for this point zered."},
{FERA$_OVER_RUN, "FERA", "OVER_RUN",
"Possible FERA memory overrun, too many triggers."},
{FERA$_OVERFLOW, "FERA", "OVERFLOW",
"Possible FERA data saturated. Data point zeroed"},
{HM650$_NORMAL, "HM650", "NORMAL", "successful completion"},
{HM650$_DLYCHNG, "HM650", "DLYCHNG",
"HM650 requested delay can not be processed by hardware."},
{HV4032$_NORMAL, "HV4032", "NORMAL", "successful completion"},
{HV4032$_WRONG_POD_TYPE, "HV4032", "WRONG_POD_TYPE",
"HV40321A n and p can only be used with the HV4032 device"},
{HV1440$_NORMAL, "HV1440", "NORMAL", "successful completion"},
{HV1440$_WRONG_POD_TYPE, "HV1440", "WRONG_POD_TYPE",
"HV1443 can only be used with the HV1440 device"},
{HV1440$_BAD_FRAME, "HV1440", "BAD_FRAME",
"HV1440 could not read the frame"},
{HV1440$_BAD_RANGE, "HV1440", "BAD_RANGE",
"HV1440 could not read the range"},
{HV1440$_OUTRNG, "HV1440", "OUTRNG", "HV1440 out of range"},
{HV1440$_STUCK, "HV1440", "STUCK", "HV1440 not responding with Q"},
{JOERGER$_BAD_PRE_TRIGGER, "JOERGER", "BAD_PRE_TRIGGER",
"bad pretrigger specified, specify a value of 0,1,2,3,4,5,6 or 7"},
{JOERGER$_BAD_ACT_MEMORY, "JOERGER", "BAD_ACT_MEMORY",
"bad active memory specified, specify a value of 1,2,3,4,5,6,7 or 8"},
{JOERGER$_BAD_GAIN, "JOERGER", "BAD_GAIN",
"bad gain specified, specify a value of 1,2,4 or 8"},
{U_OF_M$_BAD_WAVE_LENGTH, "U_OF_M", "BAD_WAVE_LENGTH",
"bad wave length specified, specify value between 0 and 13000"},
{U_OF_M$_BAD_SLIT_WIDTH, "U_OF_M", "BAD_SLIT_WIDTH",
"bad slit width specified, specify value between 0 and 500"},
{U_OF_M$_BAD_NUM_SPECTRA, "U_OF_M", "BAD_NUM_SPECTRA",
"bad number of spectra specified, specify value between 1 and 100"},
{U_OF_M$_BAD_GRATING, "U_OF_M", "BAD_GRATING",
"bad grating type specified, specify value between 1 and 5"},
{U_OF_M$_BAD_EXPOSURE, "U_OF_M", "BAD_EXPOSURE",
"bad exposure time specified, specify value between 30 and 3000"},
{U_OF_M$_BAD_FILTER, "U_OF_M", "BAD_FILTER",
"bad neutral density filter specified, specify value between 0 and 5"},
{U_OF_M$_GO_FILE_ERROR, "U_OF_M", "GO_FILE_ERROR",
"error creating new go file"},
{U_OF_M$_DATA_FILE_ERROR, "U_OF_M", "DATA_FILE_ERROR",
"error opening datafile"},
{IDL$_NORMAL, "IDL", "NORMAL", "successful completion"},
{IDL$_ERROR, "IDL", "ERROR", "IDL returned a non zero error code"},
{B5910A$_BAD_CHAN, "B5910A", "BAD_CHAN",
"error evaluating data for channel !SL"},
{B5910A$_BAD_CLOCK, "B5910A", "BAD_CLOCK",
"invalid internal clock range specified"},
{B5910A$_BAD_ITERATIONS, "B5910A", "BAD_ITERATIONS",
"invalid number of iterations specified"},
{B5910A$_BAD_NOC, "B5910A", "BAD_NOC",
"invalid number of active channels specified"},
{B5910A$_BAD_SAMPS, "B5910A", "BAD_SAMPS",
"number of samples specificed invalid"},
{J412$_NOT_SORTED, "J412", "NOT_SORTED",
"times specified for J412 module were not sorted"},
{J412$_NO_DATA, "J412", "NO_DATA",
"there were no times specifed for J412 module"},
{J412$_BADCYCLES, "J412", "BADCYCLES",
"The number of cycles must be 1 .. 255"},
{TR16$_NORMAL, "TR16", "NORMAL", "successful completion"},
{TR16$_BAD_MEMSIZE, "TR16", "BAD_MEMSIZE",
"Memory size must be in 128K, 256K, 512k, 1024K"},
{TR16$_BAD_ACTIVEMEM, "TR16", "BAD_ACTIVEMEM",
"Active Mem must be power of 2 8K to 1024K"},
{TR16$_BAD_ACTIVECHAN, "TR16", "BAD_ACTIVECHAN",
"Active channels must be in 1,2,4,8,16"},
{TR16$_BAD_PTS, "TR16", "BAD_PTS", "PTS must be power of 2 32 to 1024K"},
{TR16$_BAD_FREQUENCY, "TR16", "BAD_FREQUENCY", "Invalid clock frequency"},
{TR16$_BAD_MASTER, "TR16", "BAD_MASTER", "Master must be 0 or 1"},
{TR16$_BAD_GAIN, "TR16", "BAD_GAIN", "Gain must be 1, 2, 4, or 8"},
{A14$_NORMAL, "A14", "NORMAL", "successful completion"},
{A14$_BAD_CLK_DIVIDE, "A14", "BAD_CLK_DIVIDE",
"Clock divide must be one of 1,2,4,10,20,40, or 100"},
{A14$_BAD_MODE, "A14", "BAD_MODE", "Mode must be in the range of 0 to 4"},
{A14$_BAD_CLK_POLARITY, "A14", "BAD_CLK_POLARITY",
"Clock polarity must be either 0 (rising) or 1 (falling)"},
{A14$_BAD_STR_POLARITY, "A14", "BAD_STR_POLARITY",
"Start polarity must be either 0 (rising) or 1 (falling)"},
{A14$_BAD_STP_POLARITY, "A14", "BAD_STP_POLARITY",
"Stop polarity must be either 0 (rising) or 1 (falling)"},
{A14$_BAD_GATED, "A14", "BAD_GATED",
"Gated clock must be either 0 (not gated) or 1 (gated)"},
{L6810$_NORMAL, "L6810", "NORMAL", "successful completion"},
{L6810$_BAD_ACTIVECHAN, "L6810", "BAD_ACTIVECHAN",
"Active chans must be 1, 2, or 4"},
{L6810$_BAD_ACTIVEMEM, "L6810", "BAD_ACTIVEMEM",
"Active memory must be power of 2 LE 8192"},
{L6810$_BAD_FREQUENCY, "L6810", "BAD_FREQUENCY",
"Frequency must be in [0, .02, .05, .1, .2, .5, 1, 2, 5, 10, 20, 50, "
"100, 200, 500, 1000, 2000, 5000]"},
{L6810$_BAD_FULL_SCALE, "L6810", "BAD_FULL_SCALE",
"Full Scale must be in [.4096, 1.024, 2.048, 4.096, 10.24, 25.6, 51.2, "
"102.4]"},
{L6810$_BAD_MEMORIES, "L6810", "BAD_MEMORIES", "Memories must 1 .. 16"},
{L6810$_BAD_COUPLING, "L6810", "BAD_COUPLING",
"Channel source / coupling must be one of 0 .. 7"},
{L6810$_BAD_OFFSET, "L6810", "BAD_OFFSET",
"Offset must be between 0 and 255"},
{L6810$_BAD_SEGMENTS, "L6810", "BAD_SEGMENTS",
"Number of segments must be 1 .. 1024"},
{L6810$_BAD_TRIG_DELAY, "L6810", "BAD_TRIG_DELAY",
"Trigger delay must be between -8 and 247 in units of 8ths of segment "
"size"},
{J_DAC$_OUTRNG, "J_DAC", "OUTRNG",
"Joerger DAC Channels out of range. Bad chans code !XW"},
{INCAA$_BAD_ACTIVE_CHANS, "INCAA", "BAD_ACTIVE_CHANS",
"bad active channels selection"},
{INCAA$_BAD_MASTER, "INCAA", "BAD_MASTER",
"bad master selection, must be 0 or 1"},
{INCAA$_BAD_EXT_1MHZ, "INCAA", "BAD_EXT_1MHZ",
"bad ext 1mhz selection, must be 0 or 1"},
{INCAA$_BAD_PTSC, "INCAA", "BAD_PTSC", "bad PTSC setting"},
{L8212$_BAD_HEADER, "L8212", "BAD_HEADER",
"Invalid header jumper information (e.g. 49414944432)"},
{L8212$_BAD_MEMORIES, "L8212", "BAD_MEMORIES",
"Invalid number of memories, must be 1 .. 16"},
{L8212$_BAD_NOC, "L8212", "BAD_NOC", "Invalid number of active channels"},
{L8212$_BAD_OFFSET, "L8212", "BAD_OFFSET",
"Invalid offset must be one of (0, -2048, -4096)"},
{L8212$_BAD_PTS, "L8212", "BAD_PTS", "Invalid pts code, must be 0 .. 7"},
{L8212$_FREQ_TOO_HIGH, "L8212", "FREQ_TOO_HIGH",
"Frequency to high for selected number of channels"},
{L8212$_INVALID_NOC, "L8212", "INVALID_NOC",
"Invalid number of active channels"},
{MPB$_BADTIME, "MPB", "BADTIME", "Could not read time"},
{MPB$_BADFREQ, "MPB", "BADFREQ", "Could not read frequency"},
{L8828$_BAD_OFFSET, "L8828", "BAD_OFFSET",
"Offset for L8828 must be between 0 and 255"},
{L8828$_BAD_PRETRIG, "L8828", "BAD_PRETRIG",
"Pre trigger samples for L8828 must be betwwen 0 and 7 eighths"},
{L8828$_BAD_ACTIVEMEM, "L8828", "BAD_ACTIVEMEM",
"ACTIVEMEM must be beteen 16K and 2M"},
{L8828$_BAD_CLOCK, "L8828", "BAD_CLOCK",
"Invalid clock frequency specified."},
{L8818$_BAD_OFFSET, "L8818", "BAD_OFFSET",
"Offset for L8828 must be between 0 and 255"},
{L8818$_BAD_PRETRIG, "L8818", "BAD_PRETRIG",
"Pre trigger samples for L8828 must be betwwen 0 and 7 eighths"},
{L8818$_BAD_ACTIVEMEM, "L8818", "BAD_ACTIVEMEM",
"ACTIVEMEM must be beteen 16K and 2M"},
{L8818$_BAD_CLOCK, "L8818", "BAD_CLOCK",
"Invalid clock frequency specified."},
{J_TR612$_BAD_ACTMEM, "J_TR612", "BAD_ACTMEM",
"ACTMEM value out of range, must be 0-7 where 0=1/8th and 7 = all"},
{J_TR612$_BAD_PRETRIG, "J_TR612", "BAD_PRETRIG",
"PRETRIG value out of range, must be 0-7 where 0 = none and 7 = 7/8 "
"pretrigger samples"},
{J_TR612$_BAD_MODE, "J_TR612", "BAD_MODE",
"MODE value out of range, must be 0 (for normal) or 1 (for burst mode)"},
{J_TR612$_BAD_FREQUENCY, "J_TR612", "BAD_FREQUENCY",
"FREQUENCY value out of range, must be 0-4 where "
"0=3MHz,1=2MHz,2=1MHz,3=100KHz,4=external"},
{L8206$_NODATA, "L8206", "NODATA", "no data has been written to memory"},
{H912$_BAD_CLOCK, "H912", "BAD_CLOCK",
"Bad value specified in INT_CLOCK node, use Setup device to correct"},
{H912$_BAD_BLOCKS, "H912", "BAD_BLOCKS",
"Bad value specified in BLOCKS node, use Setup device to correct"},
{H912$_BAD_PTS, "H912", "BAD_PTS",
"Bad value specfiied in PTS node, must be an integer value between 1 "
"and 131071"},
{H908$_BAD_CLOCK, "H908", "BAD_CLOCK",
"Bad value specified in INT_CLOCK node, use Setup device to correct"},
{H908$_BAD_ACTIVE_CHANS, "H908", "BAD_ACTIVE_CHANS",
"Bad value specified in ACTIVE_CHANS node, use Setup device to correct"},
{H908$_BAD_PTS, "H908", "BAD_PTS",
"Bad value specfiied in PTS node, must be an integer value between 1 "
"and 131071"},
{DSP2904$_CHANNEL_READ_ERROR, "DSP2904", "CHANNEL_READ_ERROR",
"Error reading channel"},
{PY$_UNHANDLED_EXCEPTION, "PY", "UNHANDLED_EXCEPTION",
"Python device raised and exception, see log files for more details"},
{DT196B$_NO_SAMPLES, "DT196B", "NO_SAMPLES",
"Module did not acquire any samples"},
{ACQ$_INITIALIZATION_ERROR, "ACQ", "INITIALIZATION_ERROR",
"Error during module initialization"},
{ACQ$_WRONG_TREE, "ACQ", "WRONG_TREE",
"Attempt to store ACQ module into different tree than it was armed "
"with"},
{ACQ$_WRONG_PATH, "ACQ", "WRONG_PATH",
"Attempt to store ACQ module into different path than it was armed "
"with"},
{ACQ$_WRONG_SHOT, "ACQ", "WRONG_SHOT",
"Attempt to store ACQ module into different shot than it was armed "
"with"}};
size_t i;
int status = 0;
for (i = 0; i < sizeof(msgs) / sizeof(struct msg); i++)
{
if (msgs[i].sts == sts)
{
*facnam = msgs[i].facnam;
*msgnam = msgs[i].msgnam;
*msgtext = msgs[i].msgtext;
status = 1;
break;
}
}
return status;
}
#endif
| 49.897833 | 80 | 0.682106 |
a9e1db5be496a1c0c9528ca42adabe076bf9de2f | 454 | h | C | twitch_chat_ws2812b/secret.h | acrobotic/Ai_ESP32_Demos | 1d114b8e6f9432bd10e84cd51acbe356a9a4ecae | [
"MIT"
] | 40 | 2020-05-09T23:58:36.000Z | 2022-02-28T04:57:03.000Z | twitch_chat_ws2812b/secret.h | acrobotic/Ai_ESP32_Demos | 1d114b8e6f9432bd10e84cd51acbe356a9a4ecae | [
"MIT"
] | 1 | 2020-05-29T17:38:51.000Z | 2020-05-29T18:59:03.000Z | twitch_chat_ws2812b/secret.h | acrobotic/Ai_ESP32_Demos | 1d114b8e6f9432bd10e84cd51acbe356a9a4ecae | [
"MIT"
] | 26 | 2020-02-19T14:06:41.000Z | 2022-02-24T09:23:08.000Z | #define SSID "YOUR_SSID" // replace YOUR_SSID with your WiFi network name
#define PASS "YOUR_PASSWORD" // replace YOUR_PASSWORD with your WiFi password
#define TWITCH_OAUTH_TOKEN "YOUR_OAUTH_TOKEN" // per Twitch's API developer guide:
// https://twitchapps.com/tmi
#define TWITCH_NICK "YOUR_CHANNELS_NAME" // e.g., acrobotik
#define TWITCH_CHANNEL "#YOUR_CHANNELS_NAME" // e.g., #acrobotik
| 56.75 | 84 | 0.669604 |
30df6187ee026acf0fb9f12013fbde891d3bdd70 | 33,095 | c | C | linux-3.16/tools/perf/util/hist.c | jj1232727/system_call | 145315cdf532c45b6aa753d98260d2b1c0b63abc | [
"Unlicense"
] | null | null | null | linux-3.16/tools/perf/util/hist.c | jj1232727/system_call | 145315cdf532c45b6aa753d98260d2b1c0b63abc | [
"Unlicense"
] | null | null | null | linux-3.16/tools/perf/util/hist.c | jj1232727/system_call | 145315cdf532c45b6aa753d98260d2b1c0b63abc | [
"Unlicense"
] | null | null | null | #include "util.h"
#include "build-id.h"
#include "hist.h"
#include "session.h"
#include "sort.h"
#include "evsel.h"
#include "annotate.h"
#include <math.h>
static bool hists__filter_entry_by_dso(struct hists *hists,
struct hist_entry *he);
static bool hists__filter_entry_by_thread(struct hists *hists,
struct hist_entry *he);
static bool hists__filter_entry_by_symbol(struct hists *hists,
struct hist_entry *he);
struct callchain_param callchain_param = {
.mode = CHAIN_GRAPH_REL,
.min_percent = 0.5,
.order = ORDER_CALLEE,
.key = CCKEY_FUNCTION
};
u16 hists__col_len(struct hists *hists, enum hist_column col)
{
return hists->col_len[col];
}
void hists__set_col_len(struct hists *hists, enum hist_column col, u16 len)
{
hists->col_len[col] = len;
}
bool hists__new_col_len(struct hists *hists, enum hist_column col, u16 len)
{
if (len > hists__col_len(hists, col)) {
hists__set_col_len(hists, col, len);
return true;
}
return false;
}
void hists__reset_col_len(struct hists *hists)
{
enum hist_column col;
for (col = 0; col < HISTC_NR_COLS; ++col)
hists__set_col_len(hists, col, 0);
}
static void hists__set_unres_dso_col_len(struct hists *hists, int dso)
{
const unsigned int unresolved_col_width = BITS_PER_LONG / 4;
if (hists__col_len(hists, dso) < unresolved_col_width &&
!symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
!symbol_conf.dso_list)
hists__set_col_len(hists, dso, unresolved_col_width);
}
void hists__calc_col_len(struct hists *hists, struct hist_entry *h)
{
const unsigned int unresolved_col_width = BITS_PER_LONG / 4;
int symlen;
u16 len;
/*
* +4 accounts for '[x] ' priv level info
* +2 accounts for 0x prefix on raw addresses
* +3 accounts for ' y ' symtab origin info
*/
if (h->ms.sym) {
symlen = h->ms.sym->namelen + 4;
if (verbose)
symlen += BITS_PER_LONG / 4 + 2 + 3;
hists__new_col_len(hists, HISTC_SYMBOL, symlen);
} else {
symlen = unresolved_col_width + 4 + 2;
hists__new_col_len(hists, HISTC_SYMBOL, symlen);
hists__set_unres_dso_col_len(hists, HISTC_DSO);
}
len = thread__comm_len(h->thread);
if (hists__new_col_len(hists, HISTC_COMM, len))
hists__set_col_len(hists, HISTC_THREAD, len + 6);
if (h->ms.map) {
len = dso__name_len(h->ms.map->dso);
hists__new_col_len(hists, HISTC_DSO, len);
}
if (h->parent)
hists__new_col_len(hists, HISTC_PARENT, h->parent->namelen);
if (h->branch_info) {
if (h->branch_info->from.sym) {
symlen = (int)h->branch_info->from.sym->namelen + 4;
if (verbose)
symlen += BITS_PER_LONG / 4 + 2 + 3;
hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen);
symlen = dso__name_len(h->branch_info->from.map->dso);
hists__new_col_len(hists, HISTC_DSO_FROM, symlen);
} else {
symlen = unresolved_col_width + 4 + 2;
hists__new_col_len(hists, HISTC_SYMBOL_FROM, symlen);
hists__set_unres_dso_col_len(hists, HISTC_DSO_FROM);
}
if (h->branch_info->to.sym) {
symlen = (int)h->branch_info->to.sym->namelen + 4;
if (verbose)
symlen += BITS_PER_LONG / 4 + 2 + 3;
hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen);
symlen = dso__name_len(h->branch_info->to.map->dso);
hists__new_col_len(hists, HISTC_DSO_TO, symlen);
} else {
symlen = unresolved_col_width + 4 + 2;
hists__new_col_len(hists, HISTC_SYMBOL_TO, symlen);
hists__set_unres_dso_col_len(hists, HISTC_DSO_TO);
}
}
if (h->mem_info) {
if (h->mem_info->daddr.sym) {
symlen = (int)h->mem_info->daddr.sym->namelen + 4
+ unresolved_col_width + 2;
hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL,
symlen);
hists__new_col_len(hists, HISTC_MEM_DCACHELINE,
symlen + 1);
} else {
symlen = unresolved_col_width + 4 + 2;
hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL,
symlen);
}
if (h->mem_info->daddr.map) {
symlen = dso__name_len(h->mem_info->daddr.map->dso);
hists__new_col_len(hists, HISTC_MEM_DADDR_DSO,
symlen);
} else {
symlen = unresolved_col_width + 4 + 2;
hists__set_unres_dso_col_len(hists, HISTC_MEM_DADDR_DSO);
}
} else {
symlen = unresolved_col_width + 4 + 2;
hists__new_col_len(hists, HISTC_MEM_DADDR_SYMBOL, symlen);
hists__set_unres_dso_col_len(hists, HISTC_MEM_DADDR_DSO);
}
hists__new_col_len(hists, HISTC_MEM_LOCKED, 6);
hists__new_col_len(hists, HISTC_MEM_TLB, 22);
hists__new_col_len(hists, HISTC_MEM_SNOOP, 12);
hists__new_col_len(hists, HISTC_MEM_LVL, 21 + 3);
hists__new_col_len(hists, HISTC_LOCAL_WEIGHT, 12);
hists__new_col_len(hists, HISTC_GLOBAL_WEIGHT, 12);
if (h->transaction)
hists__new_col_len(hists, HISTC_TRANSACTION,
hist_entry__transaction_len());
}
void hists__output_recalc_col_len(struct hists *hists, int max_rows)
{
struct rb_node *next = rb_first(&hists->entries);
struct hist_entry *n;
int row = 0;
hists__reset_col_len(hists);
while (next && row++ < max_rows) {
n = rb_entry(next, struct hist_entry, rb_node);
if (!n->filtered)
hists__calc_col_len(hists, n);
next = rb_next(&n->rb_node);
}
}
static void he_stat__add_cpumode_period(struct he_stat *he_stat,
unsigned int cpumode, u64 period)
{
switch (cpumode) {
case PERF_RECORD_MISC_KERNEL:
he_stat->period_sys += period;
break;
case PERF_RECORD_MISC_USER:
he_stat->period_us += period;
break;
case PERF_RECORD_MISC_GUEST_KERNEL:
he_stat->period_guest_sys += period;
break;
case PERF_RECORD_MISC_GUEST_USER:
he_stat->period_guest_us += period;
break;
default:
break;
}
}
static void he_stat__add_period(struct he_stat *he_stat, u64 period,
u64 weight)
{
he_stat->period += period;
he_stat->weight += weight;
he_stat->nr_events += 1;
}
static void he_stat__add_stat(struct he_stat *dest, struct he_stat *src)
{
dest->period += src->period;
dest->period_sys += src->period_sys;
dest->period_us += src->period_us;
dest->period_guest_sys += src->period_guest_sys;
dest->period_guest_us += src->period_guest_us;
dest->nr_events += src->nr_events;
dest->weight += src->weight;
}
static void he_stat__decay(struct he_stat *he_stat)
{
he_stat->period = (he_stat->period * 7) / 8;
he_stat->nr_events = (he_stat->nr_events * 7) / 8;
/* XXX need decay for weight too? */
}
static bool hists__decay_entry(struct hists *hists, struct hist_entry *he)
{
u64 prev_period = he->stat.period;
u64 diff;
if (prev_period == 0)
return true;
he_stat__decay(&he->stat);
if (symbol_conf.cumulate_callchain)
he_stat__decay(he->stat_acc);
diff = prev_period - he->stat.period;
hists->stats.total_period -= diff;
if (!he->filtered)
hists->stats.total_non_filtered_period -= diff;
return he->stat.period == 0;
}
void hists__decay_entries(struct hists *hists, bool zap_user, bool zap_kernel)
{
struct rb_node *next = rb_first(&hists->entries);
struct hist_entry *n;
while (next) {
n = rb_entry(next, struct hist_entry, rb_node);
next = rb_next(&n->rb_node);
/*
* We may be annotating this, for instance, so keep it here in
* case some it gets new samples, we'll eventually free it when
* the user stops browsing and it agains gets fully decayed.
*/
if (((zap_user && n->level == '.') ||
(zap_kernel && n->level != '.') ||
hists__decay_entry(hists, n)) &&
!n->used) {
rb_erase(&n->rb_node, &hists->entries);
if (sort__need_collapse)
rb_erase(&n->rb_node_in, &hists->entries_collapsed);
--hists->nr_entries;
if (!n->filtered)
--hists->nr_non_filtered_entries;
hist_entry__free(n);
}
}
}
/*
* histogram, sorted on item, collects periods
*/
static struct hist_entry *hist_entry__new(struct hist_entry *template,
bool sample_self)
{
size_t callchain_size = 0;
struct hist_entry *he;
if (symbol_conf.use_callchain || symbol_conf.cumulate_callchain)
callchain_size = sizeof(struct callchain_root);
he = zalloc(sizeof(*he) + callchain_size);
if (he != NULL) {
*he = *template;
if (symbol_conf.cumulate_callchain) {
he->stat_acc = malloc(sizeof(he->stat));
if (he->stat_acc == NULL) {
free(he);
return NULL;
}
memcpy(he->stat_acc, &he->stat, sizeof(he->stat));
if (!sample_self)
memset(&he->stat, 0, sizeof(he->stat));
}
if (he->ms.map)
he->ms.map->referenced = true;
if (he->branch_info) {
/*
* This branch info is (a part of) allocated from
* sample__resolve_bstack() and will be freed after
* adding new entries. So we need to save a copy.
*/
he->branch_info = malloc(sizeof(*he->branch_info));
if (he->branch_info == NULL) {
free(he->stat_acc);
free(he);
return NULL;
}
memcpy(he->branch_info, template->branch_info,
sizeof(*he->branch_info));
if (he->branch_info->from.map)
he->branch_info->from.map->referenced = true;
if (he->branch_info->to.map)
he->branch_info->to.map->referenced = true;
}
if (he->mem_info) {
if (he->mem_info->iaddr.map)
he->mem_info->iaddr.map->referenced = true;
if (he->mem_info->daddr.map)
he->mem_info->daddr.map->referenced = true;
}
if (symbol_conf.use_callchain)
callchain_init(he->callchain);
INIT_LIST_HEAD(&he->pairs.node);
}
return he;
}
static u8 symbol__parent_filter(const struct symbol *parent)
{
if (symbol_conf.exclude_other && parent == NULL)
return 1 << HIST_FILTER__PARENT;
return 0;
}
static struct hist_entry *add_hist_entry(struct hists *hists,
struct hist_entry *entry,
struct addr_location *al,
bool sample_self)
{
struct rb_node **p;
struct rb_node *parent = NULL;
struct hist_entry *he;
int64_t cmp;
u64 period = entry->stat.period;
u64 weight = entry->stat.weight;
p = &hists->entries_in->rb_node;
while (*p != NULL) {
parent = *p;
he = rb_entry(parent, struct hist_entry, rb_node_in);
/*
* Make sure that it receives arguments in a same order as
* hist_entry__collapse() so that we can use an appropriate
* function when searching an entry regardless which sort
* keys were used.
*/
cmp = hist_entry__cmp(he, entry);
if (!cmp) {
if (sample_self)
he_stat__add_period(&he->stat, period, weight);
if (symbol_conf.cumulate_callchain)
he_stat__add_period(he->stat_acc, period, weight);
/*
* This mem info was allocated from sample__resolve_mem
* and will not be used anymore.
*/
zfree(&entry->mem_info);
/* If the map of an existing hist_entry has
* become out-of-date due to an exec() or
* similar, update it. Otherwise we will
* mis-adjust symbol addresses when computing
* the history counter to increment.
*/
if (he->ms.map != entry->ms.map) {
he->ms.map = entry->ms.map;
if (he->ms.map)
he->ms.map->referenced = true;
}
goto out;
}
if (cmp < 0)
p = &(*p)->rb_left;
else
p = &(*p)->rb_right;
}
he = hist_entry__new(entry, sample_self);
if (!he)
return NULL;
rb_link_node(&he->rb_node_in, parent, p);
rb_insert_color(&he->rb_node_in, hists->entries_in);
out:
if (sample_self)
he_stat__add_cpumode_period(&he->stat, al->cpumode, period);
if (symbol_conf.cumulate_callchain)
he_stat__add_cpumode_period(he->stat_acc, al->cpumode, period);
return he;
}
struct hist_entry *__hists__add_entry(struct hists *hists,
struct addr_location *al,
struct symbol *sym_parent,
struct branch_info *bi,
struct mem_info *mi,
u64 period, u64 weight, u64 transaction,
bool sample_self)
{
struct hist_entry entry = {
.thread = al->thread,
.comm = thread__comm(al->thread),
.ms = {
.map = al->map,
.sym = al->sym,
},
.cpu = al->cpu,
.cpumode = al->cpumode,
.ip = al->addr,
.level = al->level,
.stat = {
.nr_events = 1,
.period = period,
.weight = weight,
},
.parent = sym_parent,
.filtered = symbol__parent_filter(sym_parent) | al->filtered,
.hists = hists,
.branch_info = bi,
.mem_info = mi,
.transaction = transaction,
};
return add_hist_entry(hists, &entry, al, sample_self);
}
static int
iter_next_nop_entry(struct hist_entry_iter *iter __maybe_unused,
struct addr_location *al __maybe_unused)
{
return 0;
}
static int
iter_add_next_nop_entry(struct hist_entry_iter *iter __maybe_unused,
struct addr_location *al __maybe_unused)
{
return 0;
}
static int
iter_prepare_mem_entry(struct hist_entry_iter *iter, struct addr_location *al)
{
struct perf_sample *sample = iter->sample;
struct mem_info *mi;
mi = sample__resolve_mem(sample, al);
if (mi == NULL)
return -ENOMEM;
iter->priv = mi;
return 0;
}
static int
iter_add_single_mem_entry(struct hist_entry_iter *iter, struct addr_location *al)
{
u64 cost;
struct mem_info *mi = iter->priv;
struct hist_entry *he;
if (mi == NULL)
return -EINVAL;
cost = iter->sample->weight;
if (!cost)
cost = 1;
/*
* must pass period=weight in order to get the correct
* sorting from hists__collapse_resort() which is solely
* based on periods. We want sorting be done on nr_events * weight
* and this is indirectly achieved by passing period=weight here
* and the he_stat__add_period() function.
*/
he = __hists__add_entry(&iter->evsel->hists, al, iter->parent, NULL, mi,
cost, cost, 0, true);
if (!he)
return -ENOMEM;
iter->he = he;
return 0;
}
static int
iter_finish_mem_entry(struct hist_entry_iter *iter,
struct addr_location *al __maybe_unused)
{
struct perf_evsel *evsel = iter->evsel;
struct hist_entry *he = iter->he;
int err = -EINVAL;
if (he == NULL)
goto out;
hists__inc_nr_samples(&evsel->hists, he->filtered);
err = hist_entry__append_callchain(he, iter->sample);
out:
/*
* We don't need to free iter->priv (mem_info) here since
* the mem info was either already freed in add_hist_entry() or
* passed to a new hist entry by hist_entry__new().
*/
iter->priv = NULL;
iter->he = NULL;
return err;
}
static int
iter_prepare_branch_entry(struct hist_entry_iter *iter, struct addr_location *al)
{
struct branch_info *bi;
struct perf_sample *sample = iter->sample;
bi = sample__resolve_bstack(sample, al);
if (!bi)
return -ENOMEM;
iter->curr = 0;
iter->total = sample->branch_stack->nr;
iter->priv = bi;
return 0;
}
static int
iter_add_single_branch_entry(struct hist_entry_iter *iter __maybe_unused,
struct addr_location *al __maybe_unused)
{
/* to avoid calling callback function */
iter->he = NULL;
return 0;
}
static int
iter_next_branch_entry(struct hist_entry_iter *iter, struct addr_location *al)
{
struct branch_info *bi = iter->priv;
int i = iter->curr;
if (bi == NULL)
return 0;
if (iter->curr >= iter->total)
return 0;
al->map = bi[i].to.map;
al->sym = bi[i].to.sym;
al->addr = bi[i].to.addr;
return 1;
}
static int
iter_add_next_branch_entry(struct hist_entry_iter *iter, struct addr_location *al)
{
struct branch_info *bi;
struct perf_evsel *evsel = iter->evsel;
struct hist_entry *he = NULL;
int i = iter->curr;
int err = 0;
bi = iter->priv;
if (iter->hide_unresolved && !(bi[i].from.sym && bi[i].to.sym))
goto out;
/*
* The report shows the percentage of total branches captured
* and not events sampled. Thus we use a pseudo period of 1.
*/
he = __hists__add_entry(&evsel->hists, al, iter->parent, &bi[i], NULL,
1, 1, 0, true);
if (he == NULL)
return -ENOMEM;
hists__inc_nr_samples(&evsel->hists, he->filtered);
out:
iter->he = he;
iter->curr++;
return err;
}
static int
iter_finish_branch_entry(struct hist_entry_iter *iter,
struct addr_location *al __maybe_unused)
{
zfree(&iter->priv);
iter->he = NULL;
return iter->curr >= iter->total ? 0 : -1;
}
static int
iter_prepare_normal_entry(struct hist_entry_iter *iter __maybe_unused,
struct addr_location *al __maybe_unused)
{
return 0;
}
static int
iter_add_single_normal_entry(struct hist_entry_iter *iter, struct addr_location *al)
{
struct perf_evsel *evsel = iter->evsel;
struct perf_sample *sample = iter->sample;
struct hist_entry *he;
he = __hists__add_entry(&evsel->hists, al, iter->parent, NULL, NULL,
sample->period, sample->weight,
sample->transaction, true);
if (he == NULL)
return -ENOMEM;
iter->he = he;
return 0;
}
static int
iter_finish_normal_entry(struct hist_entry_iter *iter,
struct addr_location *al __maybe_unused)
{
struct hist_entry *he = iter->he;
struct perf_evsel *evsel = iter->evsel;
struct perf_sample *sample = iter->sample;
if (he == NULL)
return 0;
iter->he = NULL;
hists__inc_nr_samples(&evsel->hists, he->filtered);
return hist_entry__append_callchain(he, sample);
}
static int
iter_prepare_cumulative_entry(struct hist_entry_iter *iter __maybe_unused,
struct addr_location *al __maybe_unused)
{
struct hist_entry **he_cache;
callchain_cursor_commit(&callchain_cursor);
/*
* This is for detecting cycles or recursions so that they're
* cumulated only one time to prevent entries more than 100%
* overhead.
*/
he_cache = malloc(sizeof(*he_cache) * (PERF_MAX_STACK_DEPTH + 1));
if (he_cache == NULL)
return -ENOMEM;
iter->priv = he_cache;
iter->curr = 0;
return 0;
}
static int
iter_add_single_cumulative_entry(struct hist_entry_iter *iter,
struct addr_location *al)
{
struct perf_evsel *evsel = iter->evsel;
struct perf_sample *sample = iter->sample;
struct hist_entry **he_cache = iter->priv;
struct hist_entry *he;
int err = 0;
he = __hists__add_entry(&evsel->hists, al, iter->parent, NULL, NULL,
sample->period, sample->weight,
sample->transaction, true);
if (he == NULL)
return -ENOMEM;
iter->he = he;
he_cache[iter->curr++] = he;
callchain_append(he->callchain, &callchain_cursor, sample->period);
/*
* We need to re-initialize the cursor since callchain_append()
* advanced the cursor to the end.
*/
callchain_cursor_commit(&callchain_cursor);
hists__inc_nr_samples(&evsel->hists, he->filtered);
return err;
}
static int
iter_next_cumulative_entry(struct hist_entry_iter *iter,
struct addr_location *al)
{
struct callchain_cursor_node *node;
node = callchain_cursor_current(&callchain_cursor);
if (node == NULL)
return 0;
return fill_callchain_info(al, node, iter->hide_unresolved);
}
static int
iter_add_next_cumulative_entry(struct hist_entry_iter *iter,
struct addr_location *al)
{
struct perf_evsel *evsel = iter->evsel;
struct perf_sample *sample = iter->sample;
struct hist_entry **he_cache = iter->priv;
struct hist_entry *he;
struct hist_entry he_tmp = {
.cpu = al->cpu,
.thread = al->thread,
.comm = thread__comm(al->thread),
.ip = al->addr,
.ms = {
.map = al->map,
.sym = al->sym,
},
.parent = iter->parent,
};
int i;
struct callchain_cursor cursor;
callchain_cursor_snapshot(&cursor, &callchain_cursor);
callchain_cursor_advance(&callchain_cursor);
/*
* Check if there's duplicate entries in the callchain.
* It's possible that it has cycles or recursive calls.
*/
for (i = 0; i < iter->curr; i++) {
if (hist_entry__cmp(he_cache[i], &he_tmp) == 0) {
/* to avoid calling callback function */
iter->he = NULL;
return 0;
}
}
he = __hists__add_entry(&evsel->hists, al, iter->parent, NULL, NULL,
sample->period, sample->weight,
sample->transaction, false);
if (he == NULL)
return -ENOMEM;
iter->he = he;
he_cache[iter->curr++] = he;
callchain_append(he->callchain, &cursor, sample->period);
return 0;
}
static int
iter_finish_cumulative_entry(struct hist_entry_iter *iter,
struct addr_location *al __maybe_unused)
{
zfree(&iter->priv);
iter->he = NULL;
return 0;
}
const struct hist_iter_ops hist_iter_mem = {
.prepare_entry = iter_prepare_mem_entry,
.add_single_entry = iter_add_single_mem_entry,
.next_entry = iter_next_nop_entry,
.add_next_entry = iter_add_next_nop_entry,
.finish_entry = iter_finish_mem_entry,
};
const struct hist_iter_ops hist_iter_branch = {
.prepare_entry = iter_prepare_branch_entry,
.add_single_entry = iter_add_single_branch_entry,
.next_entry = iter_next_branch_entry,
.add_next_entry = iter_add_next_branch_entry,
.finish_entry = iter_finish_branch_entry,
};
const struct hist_iter_ops hist_iter_normal = {
.prepare_entry = iter_prepare_normal_entry,
.add_single_entry = iter_add_single_normal_entry,
.next_entry = iter_next_nop_entry,
.add_next_entry = iter_add_next_nop_entry,
.finish_entry = iter_finish_normal_entry,
};
const struct hist_iter_ops hist_iter_cumulative = {
.prepare_entry = iter_prepare_cumulative_entry,
.add_single_entry = iter_add_single_cumulative_entry,
.next_entry = iter_next_cumulative_entry,
.add_next_entry = iter_add_next_cumulative_entry,
.finish_entry = iter_finish_cumulative_entry,
};
int hist_entry_iter__add(struct hist_entry_iter *iter, struct addr_location *al,
struct perf_evsel *evsel, struct perf_sample *sample,
int max_stack_depth, void *arg)
{
int err, err2;
err = sample__resolve_callchain(sample, &iter->parent, evsel, al,
max_stack_depth);
if (err)
return err;
iter->evsel = evsel;
iter->sample = sample;
err = iter->ops->prepare_entry(iter, al);
if (err)
goto out;
err = iter->ops->add_single_entry(iter, al);
if (err)
goto out;
if (iter->he && iter->add_entry_cb) {
err = iter->add_entry_cb(iter, al, true, arg);
if (err)
goto out;
}
while (iter->ops->next_entry(iter, al)) {
err = iter->ops->add_next_entry(iter, al);
if (err)
break;
if (iter->he && iter->add_entry_cb) {
err = iter->add_entry_cb(iter, al, false, arg);
if (err)
goto out;
}
}
out:
err2 = iter->ops->finish_entry(iter, al);
if (!err)
err = err2;
return err;
}
int64_t
hist_entry__cmp(struct hist_entry *left, struct hist_entry *right)
{
struct perf_hpp_fmt *fmt;
int64_t cmp = 0;
perf_hpp__for_each_sort_list(fmt) {
if (perf_hpp__should_skip(fmt))
continue;
cmp = fmt->cmp(left, right);
if (cmp)
break;
}
return cmp;
}
int64_t
hist_entry__collapse(struct hist_entry *left, struct hist_entry *right)
{
struct perf_hpp_fmt *fmt;
int64_t cmp = 0;
perf_hpp__for_each_sort_list(fmt) {
if (perf_hpp__should_skip(fmt))
continue;
cmp = fmt->collapse(left, right);
if (cmp)
break;
}
return cmp;
}
void hist_entry__free(struct hist_entry *he)
{
zfree(&he->branch_info);
zfree(&he->mem_info);
zfree(&he->stat_acc);
free_srcline(he->srcline);
free(he);
}
/*
* collapse the histogram
*/
static bool hists__collapse_insert_entry(struct hists *hists __maybe_unused,
struct rb_root *root,
struct hist_entry *he)
{
struct rb_node **p = &root->rb_node;
struct rb_node *parent = NULL;
struct hist_entry *iter;
int64_t cmp;
while (*p != NULL) {
parent = *p;
iter = rb_entry(parent, struct hist_entry, rb_node_in);
cmp = hist_entry__collapse(iter, he);
if (!cmp) {
he_stat__add_stat(&iter->stat, &he->stat);
if (symbol_conf.cumulate_callchain)
he_stat__add_stat(iter->stat_acc, he->stat_acc);
if (symbol_conf.use_callchain) {
callchain_cursor_reset(&callchain_cursor);
callchain_merge(&callchain_cursor,
iter->callchain,
he->callchain);
}
hist_entry__free(he);
return false;
}
if (cmp < 0)
p = &(*p)->rb_left;
else
p = &(*p)->rb_right;
}
rb_link_node(&he->rb_node_in, parent, p);
rb_insert_color(&he->rb_node_in, root);
return true;
}
static struct rb_root *hists__get_rotate_entries_in(struct hists *hists)
{
struct rb_root *root;
pthread_mutex_lock(&hists->lock);
root = hists->entries_in;
if (++hists->entries_in > &hists->entries_in_array[1])
hists->entries_in = &hists->entries_in_array[0];
pthread_mutex_unlock(&hists->lock);
return root;
}
static void hists__apply_filters(struct hists *hists, struct hist_entry *he)
{
hists__filter_entry_by_dso(hists, he);
hists__filter_entry_by_thread(hists, he);
hists__filter_entry_by_symbol(hists, he);
}
void hists__collapse_resort(struct hists *hists, struct ui_progress *prog)
{
struct rb_root *root;
struct rb_node *next;
struct hist_entry *n;
if (!sort__need_collapse)
return;
root = hists__get_rotate_entries_in(hists);
next = rb_first(root);
while (next) {
if (session_done())
break;
n = rb_entry(next, struct hist_entry, rb_node_in);
next = rb_next(&n->rb_node_in);
rb_erase(&n->rb_node_in, root);
if (hists__collapse_insert_entry(hists, &hists->entries_collapsed, n)) {
/*
* If it wasn't combined with one of the entries already
* collapsed, we need to apply the filters that may have
* been set by, say, the hist_browser.
*/
hists__apply_filters(hists, n);
}
if (prog)
ui_progress__update(prog, 1);
}
}
static int hist_entry__sort(struct hist_entry *a, struct hist_entry *b)
{
struct perf_hpp_fmt *fmt;
int64_t cmp = 0;
perf_hpp__for_each_sort_list(fmt) {
if (perf_hpp__should_skip(fmt))
continue;
cmp = fmt->sort(a, b);
if (cmp)
break;
}
return cmp;
}
static void hists__reset_filter_stats(struct hists *hists)
{
hists->nr_non_filtered_entries = 0;
hists->stats.total_non_filtered_period = 0;
}
void hists__reset_stats(struct hists *hists)
{
hists->nr_entries = 0;
hists->stats.total_period = 0;
hists__reset_filter_stats(hists);
}
static void hists__inc_filter_stats(struct hists *hists, struct hist_entry *h)
{
hists->nr_non_filtered_entries++;
hists->stats.total_non_filtered_period += h->stat.period;
}
void hists__inc_stats(struct hists *hists, struct hist_entry *h)
{
if (!h->filtered)
hists__inc_filter_stats(hists, h);
hists->nr_entries++;
hists->stats.total_period += h->stat.period;
}
static void __hists__insert_output_entry(struct rb_root *entries,
struct hist_entry *he,
u64 min_callchain_hits)
{
struct rb_node **p = &entries->rb_node;
struct rb_node *parent = NULL;
struct hist_entry *iter;
if (symbol_conf.use_callchain)
callchain_param.sort(&he->sorted_chain, he->callchain,
min_callchain_hits, &callchain_param);
while (*p != NULL) {
parent = *p;
iter = rb_entry(parent, struct hist_entry, rb_node);
if (hist_entry__sort(he, iter) > 0)
p = &(*p)->rb_left;
else
p = &(*p)->rb_right;
}
rb_link_node(&he->rb_node, parent, p);
rb_insert_color(&he->rb_node, entries);
}
void hists__output_resort(struct hists *hists)
{
struct rb_root *root;
struct rb_node *next;
struct hist_entry *n;
u64 min_callchain_hits;
min_callchain_hits = hists->stats.total_period * (callchain_param.min_percent / 100);
if (sort__need_collapse)
root = &hists->entries_collapsed;
else
root = hists->entries_in;
next = rb_first(root);
hists->entries = RB_ROOT;
hists__reset_stats(hists);
hists__reset_col_len(hists);
while (next) {
n = rb_entry(next, struct hist_entry, rb_node_in);
next = rb_next(&n->rb_node_in);
__hists__insert_output_entry(&hists->entries, n, min_callchain_hits);
hists__inc_stats(hists, n);
if (!n->filtered)
hists__calc_col_len(hists, n);
}
}
static void hists__remove_entry_filter(struct hists *hists, struct hist_entry *h,
enum hist_filter filter)
{
h->filtered &= ~(1 << filter);
if (h->filtered)
return;
/* force fold unfiltered entry for simplicity */
h->ms.unfolded = false;
h->row_offset = 0;
hists->stats.nr_non_filtered_samples += h->stat.nr_events;
hists__inc_filter_stats(hists, h);
hists__calc_col_len(hists, h);
}
static bool hists__filter_entry_by_dso(struct hists *hists,
struct hist_entry *he)
{
if (hists->dso_filter != NULL &&
(he->ms.map == NULL || he->ms.map->dso != hists->dso_filter)) {
he->filtered |= (1 << HIST_FILTER__DSO);
return true;
}
return false;
}
void hists__filter_by_dso(struct hists *hists)
{
struct rb_node *nd;
hists->stats.nr_non_filtered_samples = 0;
hists__reset_filter_stats(hists);
hists__reset_col_len(hists);
for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
if (symbol_conf.exclude_other && !h->parent)
continue;
if (hists__filter_entry_by_dso(hists, h))
continue;
hists__remove_entry_filter(hists, h, HIST_FILTER__DSO);
}
}
static bool hists__filter_entry_by_thread(struct hists *hists,
struct hist_entry *he)
{
if (hists->thread_filter != NULL &&
he->thread != hists->thread_filter) {
he->filtered |= (1 << HIST_FILTER__THREAD);
return true;
}
return false;
}
void hists__filter_by_thread(struct hists *hists)
{
struct rb_node *nd;
hists->stats.nr_non_filtered_samples = 0;
hists__reset_filter_stats(hists);
hists__reset_col_len(hists);
for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
if (hists__filter_entry_by_thread(hists, h))
continue;
hists__remove_entry_filter(hists, h, HIST_FILTER__THREAD);
}
}
static bool hists__filter_entry_by_symbol(struct hists *hists,
struct hist_entry *he)
{
if (hists->symbol_filter_str != NULL &&
(!he->ms.sym || strstr(he->ms.sym->name,
hists->symbol_filter_str) == NULL)) {
he->filtered |= (1 << HIST_FILTER__SYMBOL);
return true;
}
return false;
}
void hists__filter_by_symbol(struct hists *hists)
{
struct rb_node *nd;
hists->stats.nr_non_filtered_samples = 0;
hists__reset_filter_stats(hists);
hists__reset_col_len(hists);
for (nd = rb_first(&hists->entries); nd; nd = rb_next(nd)) {
struct hist_entry *h = rb_entry(nd, struct hist_entry, rb_node);
if (hists__filter_entry_by_symbol(hists, h))
continue;
hists__remove_entry_filter(hists, h, HIST_FILTER__SYMBOL);
}
}
void events_stats__inc(struct events_stats *stats, u32 type)
{
++stats->nr_events[0];
++stats->nr_events[type];
}
void hists__inc_nr_events(struct hists *hists, u32 type)
{
events_stats__inc(&hists->stats, type);
}
void hists__inc_nr_samples(struct hists *hists, bool filtered)
{
events_stats__inc(&hists->stats, PERF_RECORD_SAMPLE);
if (!filtered)
hists->stats.nr_non_filtered_samples++;
}
static struct hist_entry *hists__add_dummy_entry(struct hists *hists,
struct hist_entry *pair)
{
struct rb_root *root;
struct rb_node **p;
struct rb_node *parent = NULL;
struct hist_entry *he;
int64_t cmp;
if (sort__need_collapse)
root = &hists->entries_collapsed;
else
root = hists->entries_in;
p = &root->rb_node;
while (*p != NULL) {
parent = *p;
he = rb_entry(parent, struct hist_entry, rb_node_in);
cmp = hist_entry__collapse(he, pair);
if (!cmp)
goto out;
if (cmp < 0)
p = &(*p)->rb_left;
else
p = &(*p)->rb_right;
}
he = hist_entry__new(pair, true);
if (he) {
memset(&he->stat, 0, sizeof(he->stat));
he->hists = hists;
rb_link_node(&he->rb_node_in, parent, p);
rb_insert_color(&he->rb_node_in, root);
hists__inc_stats(hists, he);
he->dummy = true;
}
out:
return he;
}
static struct hist_entry *hists__find_entry(struct hists *hists,
struct hist_entry *he)
{
struct rb_node *n;
if (sort__need_collapse)
n = hists->entries_collapsed.rb_node;
else
n = hists->entries_in->rb_node;
while (n) {
struct hist_entry *iter = rb_entry(n, struct hist_entry, rb_node_in);
int64_t cmp = hist_entry__collapse(iter, he);
if (cmp < 0)
n = n->rb_left;
else if (cmp > 0)
n = n->rb_right;
else
return iter;
}
return NULL;
}
/*
* Look for pairs to link to the leader buckets (hist_entries):
*/
void hists__match(struct hists *leader, struct hists *other)
{
struct rb_root *root;
struct rb_node *nd;
struct hist_entry *pos, *pair;
if (sort__need_collapse)
root = &leader->entries_collapsed;
else
root = leader->entries_in;
for (nd = rb_first(root); nd; nd = rb_next(nd)) {
pos = rb_entry(nd, struct hist_entry, rb_node_in);
pair = hists__find_entry(other, pos);
if (pair)
hist_entry__add_pair(pair, pos);
}
}
/*
* Look for entries in the other hists that are not present in the leader, if
* we find them, just add a dummy entry on the leader hists, with period=0,
* nr_events=0, to serve as the list header.
*/
int hists__link(struct hists *leader, struct hists *other)
{
struct rb_root *root;
struct rb_node *nd;
struct hist_entry *pos, *pair;
if (sort__need_collapse)
root = &other->entries_collapsed;
else
root = other->entries_in;
for (nd = rb_first(root); nd; nd = rb_next(nd)) {
pos = rb_entry(nd, struct hist_entry, rb_node_in);
if (!hist_entry__has_pairs(pos)) {
pair = hists__add_dummy_entry(leader, pos);
if (pair == NULL)
return -1;
hist_entry__add_pair(pos, pair);
}
}
return 0;
}
u64 hists__total_period(struct hists *hists)
{
return symbol_conf.filter_relative ? hists->stats.total_non_filtered_period :
hists->stats.total_period;
}
int parse_filter_percentage(const struct option *opt __maybe_unused,
const char *arg, int unset __maybe_unused)
{
if (!strcmp(arg, "relative"))
symbol_conf.filter_relative = true;
else if (!strcmp(arg, "absolute"))
symbol_conf.filter_relative = false;
else
return -1;
return 0;
}
int perf_hist_config(const char *var, const char *value)
{
if (!strcmp(var, "hist.percentage"))
return parse_filter_percentage(NULL, value, 0);
return 0;
}
| 23.388693 | 86 | 0.700771 |
088f7abe8ec2d5bc92c687eb6c863dab44e93110 | 2,795 | h | C | psp/src/include/perspective/context_two.h | datalytica/neutrino | bc885507a3248e81e8994ee699e94f6b11e1048d | [
"Apache-2.0"
] | null | null | null | psp/src/include/perspective/context_two.h | datalytica/neutrino | bc885507a3248e81e8994ee699e94f6b11e1048d | [
"Apache-2.0"
] | null | null | null | psp/src/include/perspective/context_two.h | datalytica/neutrino | bc885507a3248e81e8994ee699e94f6b11e1048d | [
"Apache-2.0"
] | null | null | null | /******************************************************************************
*
* Copyright (c) 2017, the Perspective Authors.
*
* This file is part of the Perspective library, distributed under the terms of
* the Apache License 2.0. The full license can be found in the LICENSE file.
*
*/
#pragma once
#include <perspective/base.h>
#include <perspective/context_base.h>
#include <perspective/sort_specification.h>
#include <perspective/path.h>
#include <perspective/shared_ptrs.h>
#include <perspective/sparse_tree_node.h>
#include <perspective/traversal_nodes.h>
namespace perspective
{
class PERSPECTIVE_EXPORT t_ctx2 : public t_ctxbase<t_ctx2>
{
public:
#include <perspective/context_common_decls.h>
t_ctx2();
t_ctx2(const t_schema& schema, const t_config& config);
~t_ctx2();
t_index open(t_header header, t_tvidx idx);
t_index close(t_header header, t_tvidx idx);
std::vector<t_tvidx> get_selected_indices() const;
void select_node(t_tvidx idx);
void deselect_node(t_tvidx idx);
void clear_selection();
t_totals get_totals() const;
std::vector<t_tvidx> get_ctraversal_indices() const;
t_uindex get_num_view_columns() const;
t_tscalvec get_row_path(t_tvidx idx) const;
t_tscalvec get_row_path(const t_tvnode& node) const;
t_tscalvec get_column_path(t_tvidx idx) const;
t_tscalvec get_column_path(const t_tvnode& node) const;
t_tscalvec get_column_path_userspace(t_tvidx idx) const;
t_pivotvec get_row_pivots() const;
t_pivotvec get_column_pivots() const;
t_aggspecvec get_aggregates() const;
void set_depth(t_header header, t_depth depth);
t_depth get_depth(t_header header) const;
using t_ctxbase<t_ctx2>::get_data;
t_uindex get_leaf_count(t_header header) const;
t_tscalvec get_leaf_data(t_uindex start_row, t_uindex end_row,
t_uindex start_col, t_uindex end_col) const;
protected:
t_cinfovec resolve_cells(const std::vector<t_uidxpair>& cells) const;
t_stree_sptr rtree();
t_stree_csptr rtree() const;
t_stree_sptr ctree();
t_stree_csptr ctree() const;
t_uindex is_rtree_idx(t_uindex idx) const;
t_uindex is_ctree_idx(t_uindex idx) const;
t_tvidx translate_column_index(t_tvidx idx) const;
t_uindex get_num_trees() const;
t_uindex calc_translated_colidx(t_uindex n_aggs, t_uindex cidx) const;
private:
t_trav_sptr m_rtraversal;
t_trav_sptr m_ctraversal;
t_sortsvec m_sortby;
t_bool m_rows_changed;
std::vector<t_stree_sptr> m_trees;
t_sortsvec m_row_sortby;
t_sortsvec m_column_sortby;
t_depth m_row_depth;
t_bool m_row_depth_set;
t_depth m_column_depth;
t_bool m_column_depth_set;
};
typedef std::shared_ptr<t_ctx2> t_ctx2_sptr;
} // end namespace perspective
| 28.232323 | 79 | 0.728444 |
d3c45dcb38cf65e8fb97bce80b9af75352783446 | 16,701 | c | C | src/binding/fortran/mpif_h/send_initf.c | jqswang/mpich-3.2 | 1716c9048bc79f87c7f220bc87cd256ce0a2e84a | [
"Unlicense"
] | 3 | 2020-05-22T04:17:23.000Z | 2020-07-17T04:14:25.000Z | mpich-3.3/src/binding/fortran/mpif_h/send_initf.c | ucd-plse/mpi-error-prop | 4367df88bcdc4d82c9a65b181d0e639d04962503 | [
"BSD-3-Clause"
] | null | null | null | mpich-3.3/src/binding/fortran/mpif_h/send_initf.c | ucd-plse/mpi-error-prop | 4367df88bcdc4d82c9a65b181d0e639d04962503 | [
"BSD-3-Clause"
] | null | null | null | /* -*- Mode: C; c-basic-offset:4 ; -*- */
/*
* (C) 2001 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*
* This file is automatically generated by buildiface
* DO NOT EDIT
*/
#include "mpi_fortimpl.h"
/* Begin MPI profiling block */
#if defined(USE_WEAK_SYMBOLS) && !defined(USE_ONLY_MPI_NAMES)
#if defined(HAVE_MULTIPLE_PRAGMA_WEAK)
extern FORT_DLL_SPEC void FORT_CALL MPI_SEND_INIT( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init__( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init_( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
#if defined(F77_NAME_UPPER)
#pragma weak MPI_SEND_INIT = PMPI_SEND_INIT
#pragma weak mpi_send_init__ = PMPI_SEND_INIT
#pragma weak mpi_send_init_ = PMPI_SEND_INIT
#pragma weak mpi_send_init = PMPI_SEND_INIT
#elif defined(F77_NAME_LOWER_2USCORE)
#pragma weak MPI_SEND_INIT = pmpi_send_init__
#pragma weak mpi_send_init__ = pmpi_send_init__
#pragma weak mpi_send_init_ = pmpi_send_init__
#pragma weak mpi_send_init = pmpi_send_init__
#elif defined(F77_NAME_LOWER_USCORE)
#pragma weak MPI_SEND_INIT = pmpi_send_init_
#pragma weak mpi_send_init__ = pmpi_send_init_
#pragma weak mpi_send_init_ = pmpi_send_init_
#pragma weak mpi_send_init = pmpi_send_init_
#else
#pragma weak MPI_SEND_INIT = pmpi_send_init
#pragma weak mpi_send_init__ = pmpi_send_init
#pragma weak mpi_send_init_ = pmpi_send_init
#pragma weak mpi_send_init = pmpi_send_init
#endif
#elif defined(HAVE_PRAGMA_WEAK)
#if defined(F77_NAME_UPPER)
extern FORT_DLL_SPEC void FORT_CALL MPI_SEND_INIT( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
#pragma weak MPI_SEND_INIT = PMPI_SEND_INIT
#elif defined(F77_NAME_LOWER_2USCORE)
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init__( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
#pragma weak mpi_send_init__ = pmpi_send_init__
#elif !defined(F77_NAME_LOWER_USCORE)
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
#pragma weak mpi_send_init = pmpi_send_init
#else
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init_( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
#pragma weak mpi_send_init_ = pmpi_send_init_
#endif
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
#if defined(F77_NAME_UPPER)
#pragma _HP_SECONDARY_DEF PMPI_SEND_INIT MPI_SEND_INIT
#elif defined(F77_NAME_LOWER_2USCORE)
#pragma _HP_SECONDARY_DEF pmpi_send_init__ mpi_send_init__
#elif !defined(F77_NAME_LOWER_USCORE)
#pragma _HP_SECONDARY_DEF pmpi_send_init mpi_send_init
#else
#pragma _HP_SECONDARY_DEF pmpi_send_init_ mpi_send_init_
#endif
#elif defined(HAVE_PRAGMA_CRI_DUP)
#if defined(F77_NAME_UPPER)
#pragma _CRI duplicate MPI_SEND_INIT as PMPI_SEND_INIT
#elif defined(F77_NAME_LOWER_2USCORE)
#pragma _CRI duplicate mpi_send_init__ as pmpi_send_init__
#elif !defined(F77_NAME_LOWER_USCORE)
#pragma _CRI duplicate mpi_send_init as pmpi_send_init
#else
#pragma _CRI duplicate mpi_send_init_ as pmpi_send_init_
#endif
#elif defined(HAVE_WEAK_ATTRIBUTE)
#if defined(F77_NAME_UPPER)
extern FORT_DLL_SPEC void FORT_CALL MPI_SEND_INIT( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("PMPI_SEND_INIT")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init__( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("PMPI_SEND_INIT")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init_( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("PMPI_SEND_INIT")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("PMPI_SEND_INIT")));
#elif defined(F77_NAME_LOWER_2USCORE)
extern FORT_DLL_SPEC void FORT_CALL MPI_SEND_INIT( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init__")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init__( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init__")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init_( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init__")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init__")));
#elif defined(F77_NAME_LOWER_USCORE)
extern FORT_DLL_SPEC void FORT_CALL MPI_SEND_INIT( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init_")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init__( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init_")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init_( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init_")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init_")));
#else
extern FORT_DLL_SPEC void FORT_CALL MPI_SEND_INIT( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init__( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init_( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init")));
#endif
#endif /* HAVE_PRAGMA_WEAK */
#endif /* USE_WEAK_SYMBOLS */
/* End MPI profiling block */
/* These definitions are used only for generating the Fortran wrappers */
#if defined(USE_WEAK_SYMBOLS) && defined(USE_ONLY_MPI_NAMES)
#if defined(HAVE_MULTIPLE_PRAGMA_WEAK)
extern FORT_DLL_SPEC void FORT_CALL MPI_SEND_INIT( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init__( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init_( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
#if defined(F77_NAME_UPPER)
#pragma weak mpi_send_init__ = MPI_SEND_INIT
#pragma weak mpi_send_init_ = MPI_SEND_INIT
#pragma weak mpi_send_init = MPI_SEND_INIT
#elif defined(F77_NAME_LOWER_2USCORE)
#pragma weak MPI_SEND_INIT = mpi_send_init__
#pragma weak mpi_send_init_ = mpi_send_init__
#pragma weak mpi_send_init = mpi_send_init__
#elif defined(F77_NAME_LOWER_USCORE)
#pragma weak MPI_SEND_INIT = mpi_send_init_
#pragma weak mpi_send_init__ = mpi_send_init_
#pragma weak mpi_send_init = mpi_send_init_
#else
#pragma weak MPI_SEND_INIT = mpi_send_init
#pragma weak mpi_send_init__ = mpi_send_init
#pragma weak mpi_send_init_ = mpi_send_init
#endif
#elif defined(HAVE_WEAK_ATTRIBUTE)
#if defined(F77_NAME_UPPER)
extern FORT_DLL_SPEC void FORT_CALL MPI_SEND_INIT( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init__( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("MPI_SEND_INIT")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init_( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("MPI_SEND_INIT")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("MPI_SEND_INIT")));
#elif defined(F77_NAME_LOWER_2USCORE)
extern FORT_DLL_SPEC void FORT_CALL MPI_SEND_INIT( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_send_init__")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init__( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init_( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_send_init__")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_send_init__")));
#elif defined(F77_NAME_LOWER_USCORE)
extern FORT_DLL_SPEC void FORT_CALL MPI_SEND_INIT( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_send_init_")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init__( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_send_init_")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init_( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_send_init_")));
#else
extern FORT_DLL_SPEC void FORT_CALL MPI_SEND_INIT( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_send_init")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init__( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_send_init")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init_( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("mpi_send_init")));
extern FORT_DLL_SPEC void FORT_CALL mpi_send_init( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
#endif
#endif
#endif
/* Map the name to the correct form */
#ifndef MPICH_MPI_FROM_PMPI
#if defined(USE_WEAK_SYMBOLS)
#if defined(HAVE_MULTIPLE_PRAGMA_WEAK)
/* Define the weak versions of the PMPI routine*/
#ifndef F77_NAME_UPPER
extern FORT_DLL_SPEC void FORT_CALL PMPI_SEND_INIT( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
#endif
#ifndef F77_NAME_LOWER_2USCORE
extern FORT_DLL_SPEC void FORT_CALL pmpi_send_init__( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
#endif
#ifndef F77_NAME_LOWER_USCORE
extern FORT_DLL_SPEC void FORT_CALL pmpi_send_init_( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
#endif
#ifndef F77_NAME_LOWER
extern FORT_DLL_SPEC void FORT_CALL pmpi_send_init( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * );
#endif
#if defined(F77_NAME_UPPER)
#pragma weak pmpi_send_init__ = PMPI_SEND_INIT
#pragma weak pmpi_send_init_ = PMPI_SEND_INIT
#pragma weak pmpi_send_init = PMPI_SEND_INIT
#elif defined(F77_NAME_LOWER_2USCORE)
#pragma weak PMPI_SEND_INIT = pmpi_send_init__
#pragma weak pmpi_send_init_ = pmpi_send_init__
#pragma weak pmpi_send_init = pmpi_send_init__
#elif defined(F77_NAME_LOWER_USCORE)
#pragma weak PMPI_SEND_INIT = pmpi_send_init_
#pragma weak pmpi_send_init__ = pmpi_send_init_
#pragma weak pmpi_send_init = pmpi_send_init_
#else
#pragma weak PMPI_SEND_INIT = pmpi_send_init
#pragma weak pmpi_send_init__ = pmpi_send_init
#pragma weak pmpi_send_init_ = pmpi_send_init
#endif /* Test on name mapping */
#elif defined(HAVE_WEAK_ATTRIBUTE)
#if defined(F77_NAME_UPPER)
extern FORT_DLL_SPEC void FORT_CALL pmpi_send_init__( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("PMPI_SEND_INIT")));
extern FORT_DLL_SPEC void FORT_CALL pmpi_send_init_( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("PMPI_SEND_INIT")));
extern FORT_DLL_SPEC void FORT_CALL pmpi_send_init( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("PMPI_SEND_INIT")));
#elif defined(F77_NAME_LOWER_2USCORE)
extern FORT_DLL_SPEC void FORT_CALL PMPI_SEND_INIT( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init__")));
extern FORT_DLL_SPEC void FORT_CALL pmpi_send_init_( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init__")));
extern FORT_DLL_SPEC void FORT_CALL pmpi_send_init( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init__")));
#elif defined(F77_NAME_LOWER_USCORE)
extern FORT_DLL_SPEC void FORT_CALL PMPI_SEND_INIT( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init_")));
extern FORT_DLL_SPEC void FORT_CALL pmpi_send_init__( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init_")));
extern FORT_DLL_SPEC void FORT_CALL pmpi_send_init( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init_")));
#else
extern FORT_DLL_SPEC void FORT_CALL PMPI_SEND_INIT( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init")));
extern FORT_DLL_SPEC void FORT_CALL pmpi_send_init__( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init")));
extern FORT_DLL_SPEC void FORT_CALL pmpi_send_init_( void*, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint *, MPI_Fint * ) __attribute__((weak,alias("pmpi_send_init")));
#endif /* Test on name mapping */
#endif /* HAVE_MULTIPLE_PRAGMA_WEAK */
#endif /* USE_WEAK_SYMBOLS */
#ifdef F77_NAME_UPPER
#define mpi_send_init_ PMPI_SEND_INIT
#elif defined(F77_NAME_LOWER_2USCORE)
#define mpi_send_init_ pmpi_send_init__
#elif !defined(F77_NAME_LOWER_USCORE)
#define mpi_send_init_ pmpi_send_init
#else
#define mpi_send_init_ pmpi_send_init_
#endif /* Test on name mapping */
#ifdef F77_USE_PMPI
/* This defines the routine that we call, which must be the PMPI version
since we're renaming the Fortran entry as the pmpi version. The MPI name
must be undefined first to prevent any conflicts with previous renamings. */
#undef MPI_Send_init
#define MPI_Send_init PMPI_Send_init
#endif
#else
#ifdef F77_NAME_UPPER
#define mpi_send_init_ MPI_SEND_INIT
#elif defined(F77_NAME_LOWER_2USCORE)
#define mpi_send_init_ mpi_send_init__
#elif !defined(F77_NAME_LOWER_USCORE)
#define mpi_send_init_ mpi_send_init
/* Else leave name alone */
#endif
#endif /* MPICH_MPI_FROM_PMPI */
/* Prototypes for the Fortran interfaces */
#include "fproto.h"
FORT_DLL_SPEC void FORT_CALL mpi_send_init_ ( void*v1, MPI_Fint *v2, MPI_Fint *v3, MPI_Fint *v4, MPI_Fint *v5, MPI_Fint *v6, MPI_Fint *v7, MPI_Fint *ierr ){
if (v1 == MPIR_F_MPI_BOTTOM) v1 = MPI_BOTTOM;
*ierr = MPI_Send_init( v1, (int)*v2, (MPI_Datatype)(*v3), (int)*v4, (int)*v5, (MPI_Comm)(*v6), (MPI_Request *)(v7) );
}
| 61.400735 | 193 | 0.766062 |
03671e608aa341fd265b617ac0acfb6df91fa1a0 | 87 | c | C | C/String/CaesarCypher.c | piovezan/SOpt | a5ec90796b7bdf98f0675457fc4bb99c8695bc40 | [
"MIT"
] | 148 | 2017-08-03T01:49:27.000Z | 2022-03-26T10:39:30.000Z | C/String/CaesarCypher.c | piovezan/SOpt | a5ec90796b7bdf98f0675457fc4bb99c8695bc40 | [
"MIT"
] | 3 | 2017-11-23T19:52:05.000Z | 2020-04-01T00:44:40.000Z | C/String/CaesarCypher.c | piovezan/SOpt | a5ec90796b7bdf98f0675457fc4bb99c8695bc40 | [
"MIT"
] | 59 | 2017-08-03T01:49:19.000Z | 2022-03-31T23:24:38.000Z | texto[i] + (texto[i] > 'c' ? -3 : 23)
//https://pt.stackoverflow.com/q/358403/101
| 21.75 | 43 | 0.563218 |
03baef30558e5b49033222fabd5d9a56e0680c3f | 231 | c | C | 717-2_sia-2-1.c | timp555/timp-717-2_sia | 259e5be82de72ad683791c55eaa0703357a697f9 | [
"BSD-3-Clause"
] | null | null | null | 717-2_sia-2-1.c | timp555/timp-717-2_sia | 259e5be82de72ad683791c55eaa0703357a697f9 | [
"BSD-3-Clause"
] | null | null | null | 717-2_sia-2-1.c | timp555/timp-717-2_sia | 259e5be82de72ad683791c55eaa0703357a697f9 | [
"BSD-3-Clause"
] | null | null | null | #include <stdio.h>
int main(){
int n, count=0, num;
scanf("%d", &n);
for (int i = 0; i < n; i++){
scanf("%d", &num);
if (num >= 0)
count++;
}
printf("%d\n", count);
return 0;
}
| 15.4 | 32 | 0.393939 |
d976ac20ae335809b3bae2754da3ab4c333ff72e | 1,594 | c | C | d/guilds/legion/hall/arena/arena18.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-07-19T05:24:44.000Z | 2021-11-18T04:08:19.000Z | d/guilds/legion/hall/arena/arena18.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 4 | 2021-03-15T18:56:39.000Z | 2021-08-17T17:08:22.000Z | d/guilds/legion/hall/arena/arena18.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-09-12T06:22:38.000Z | 2022-01-31T01:15:12.000Z | #include <std.h>
#include <arena.h>
#define BASE "/d/guilds/legion/hall/arena/"
int i;
string *rooms;
inherit ARENA;
void create(){
::create();
set_property("light", 2);
set_property("night light", 2);
set_property("indoors", 1);
set_property("no teleport", 1);
set_property("arena", 1);
set_property("deathmove", "/d/guilds/legion/hall/arena/arenah.c");
set_short("%^BOLD%^%^BLUE%^Arena of the Ancients");
set_long(
"Here in the middle of the bottom floor of the arena a great shimmering portal floats a foot off the ground. Glowing blue, as you peer into the portal you can see visions of several of the rooms of this arena flash past you. Perhaps if you %^BOLD%^%^BLUE%^dive portal%^RESET%^ you will be taken somplace new."
);
set_smell("default", "The arena is filled with a dark smoke.");
set_listen("default", "In the dark smoke, it is eerily silent.");
set_items( ([
"walls" : "These walls are pockmarked and battle damaged.",
]) );
set_exits( ([
"south" : "/d/guilds/legion/hall/arena/arena21.c",
]) );
}
void init() {
::init();
add_action("dive", "dive");
}
int dive(string str) {
if(!str) return notify_fail("dive where?");
if(str != "portal") return notify_fail("dive where?");
tell_room(ETP, "%^BLUE%^"+TPQCN+" dives into the portal and is gone!", TP);
tell_object(TP, "%^BLUE%^You dive into the portal and are whisked away!");
rooms = get_dir("/d/guilds/legion/hall/arena/");
i = random(sizeof(rooms));
TP->move_player(BASE+rooms[i]);
return 1;
}
| 31.254902 | 317 | 0.640527 |
9cd09c984d1f222c7b69563a8e688b9bc34b9f4d | 5,319 | c | C | src_main/public/parsifal/lib/samples/misc/helper.c | ArcadiusGFN/SourceEngine2007 | 51cd6d4f0f9ed901cb9b61456eb621a50ce44f55 | [
"bzip2-1.0.6"
] | 25 | 2018-02-28T15:04:42.000Z | 2021-08-16T03:49:00.000Z | src_main/public/parsifal/lib/samples/misc/helper.c | ArcadiusGFN/SourceEngine2007 | 51cd6d4f0f9ed901cb9b61456eb621a50ce44f55 | [
"bzip2-1.0.6"
] | 1 | 2019-09-20T11:06:03.000Z | 2019-09-20T11:06:03.000Z | src_main/public/parsifal/lib/samples/misc/helper.c | ArcadiusGFN/SourceEngine2007 | 51cd6d4f0f9ed901cb9b61456eb621a50ce44f55 | [
"bzip2-1.0.6"
] | 9 | 2019-07-31T11:58:20.000Z | 2021-08-31T11:18:15.000Z | /*
function: UTF8BufToLatin1
desc: converts buffer from UTF-8 to iso latin1
note: modifies the actual buffer, doesn't nul terminate
params:
buf - buffer to be converted
end - NULL if buf is nul terminated, buf+buflen otherwise
returns:
new length of buffer (shorter or equal to passed buf len)
note: NONLAT is character to be inserted when UTF8 char is > 255
It is possible to modify the actual buffer in Parsifal characters
handler i.e.
cbChars = UTF8BufToLatin1((XMLCH*)chars, (XMLCH*)chars+cbChars);
but it's recommended to do the conversion using copy buffer
*/
#define NONLAT '?'
#define UTF8LEN(c) \
(!(c & 0x80)) ? 1 : \
((unsigned int)c <= 0xdf) ? 2 : \
((unsigned int)c <= 0xef) ? 3 : \
((unsigned int)c <= 0xf7) ? 4 : \
((unsigned int)c <= 0xfb) ? 5 : 6
size_t UTF8BufToLatin1(XMLCH *buf, XMLCH *end)
{
int c, len;
XMLCH *o, *l;
o = l = buf;
for (len=0; *buf && buf!=end; buf+=len, o++) {
len = UTF8LEN(*buf);
if (len==1) *o = *buf;
else if (len==2) {
c = (*buf & 0x1F) << 6;
c |= buf[1] & 0x3F;
*o = (c>0xFF) ? NONLAT : (XMLCH)c;
}
else *o = NONLAT;
}
return o-l;
}
/*
function: GetBaseDir
desc: gets base directory from src
params:
dst - destination buffer (must have space for directory FILENAME_MAX?)
src - source usually pointer to some file/uri path
returns:
index of file/resource in src for example if src is "http://myorg/index.xml"
then returns 13 (src+13 points to index.xml)
if there is no basedir, returns 0 (and dst will be empty string)
*/
size_t GetBaseDir(XMLCH *dst, XMLCH *src)
{
XMLCH *s = strrchr(src, '/');
#ifdef _WIN32
if (!s) s = strrchr(src, '\\');
#endif
if (s) {
size_t i = (s-src)+1;
memcpy(dst, src, i);
dst[i] = '\0';
return i;
}
dst[0] = '\0';
return 0;
}
/*
function: ResolveBaseUri
desc: Can be used to resolve systemID in resolveEntityHandler
params:
parser - parser object
systemID - usually entity->systemID from resolveEntityHandler
base - usually base dir from GetBaseDir call (which is
called before parsing has been started)
returns:
pointer to baseuri, i.e. the usage in resolveEntityHandler:
XMLCH r[FILENAME_MAX];
XMLCH *uri = ResolveBaseUri(parser, entity->systemID, docbasedir);
if (uri != entity->systemID) {
strcpy(r, uri);
uri = strcat(r, entity->systemID);
}
... open the resource here i.e. fopen(r) ...
notes:
Real accurate base uri handling needs of course somekind of stack,
however ResolveBaseUri kind of approach should be sufficient for
most cases
*/
XMLCH *ResolveBaseUri(LPXMLPARSER parser, XMLCH *systemID, XMLCH *base)
{
XMLCH *s=systemID;
for (; *s; s++) {
if (*s == ':') return systemID; /* probably absolute */
if (*s == '/' || *s == '\\') break;
}
s = XMLParser_GetPrefixMapping(parser, "xml:base");
return (s) ? s : base;
}
/*
function: GetFormattedContext
desc: Builds formatted line info, example when called from errorHandler
and document contains invalid token (< unescaped in attribute value):
<e a="va<l"></e>
--------^
params:
col (output) - column pos in bytes (unlike parser->ErrorColumn for
example which is column in characters) OR column pos in characters if
outputUTF8 is True.
outputUTF8 - True: use character column value for output (output can
show UTF-8 characters) - uses parser->ErrorColumn/dtd->ErrorColumn if
parser->ErrorCode has been set.
False: Result will be shown in bytes (output doesn't show UTF-8)
returns:
Pointer to allocated format string - must be freed by the caller
NULL if string can't be build/allocated.
note: XMLParser_GetContextBytes data must be handled in a
special way like this 'cos it might contain NULs and tabs or it
can be all whitespace or input buffer might be too short for meaningful
visualization. Note also that buffer might be truncated with NUL right
after column position (col) because parsifal doesn't ensure that input
buffer contains full lines.
usage:
int col;
XMLCH *s = GetFormattedContext(parser, &col, 0);
if (s) {
printf("Context: %s\n", s);
free(s);
}
*/
XMLCH *GetFormattedContext(LPXMLPARSER parser, int *col, int outputUTF8)
{
int i, w, colb, cBytes;
XMLCH *s, *r;
if ((colb = XMLParser_GetContextBytes(parser, &s, &cBytes)) < 0)
return NULL;
for (i=0, w=1; i!=cBytes; i++) {
if (!s[i] || s[i]==0xD || s[i]==0xA) break;
if (w && !isspace(s[i])) w = 0; /* all-whitespace flag */
}
if (i < colb || i > 255 || w) return NULL;
if (outputUTF8) {
if (parser->ErrorCode) {
*col = (parser->ErrorCode == ERR_XMLP_VALIDATION) ?
((LPXMLDTDVALIDATOR)parser->UserData)->ErrorColumn :
parser->ErrorColumn;
}
else *col = XMLParser_GetCurrentColumn(parser);
if (*col==-1) return NULL;
(*col)--;
}
else *col = colb;
/* alloc row len + size for \n, arrow and NUL: */
if (!(r = malloc(i + *col + 3))) return NULL;
memcpy(r, s, i);
for (w=0; w<colb; w++) { /* remove tabs */
if (r[w]==0x9) r[w]=0x20;
}
r[i++]='\n';
if (*col) {
memset(r+i, '-', *col);
i+=*col;
}
r[i]='^';
r[++i]=0;
(*col)++; /* column is always 1-based */
return r;
} | 30.050847 | 81 | 0.631698 |
f008e3accff36b6efada2c366e714da7cbfa5ac5 | 11,547 | c | C | stage0/stdlib/Lean/Compiler/IR/CtorLayout.c | mattweingarten/lean4 | 178b3e5b52772d386385b31dbb6127b4c3aa0a4b | [
"Apache-2.0"
] | null | null | null | stage0/stdlib/Lean/Compiler/IR/CtorLayout.c | mattweingarten/lean4 | 178b3e5b52772d386385b31dbb6127b4c3aa0a4b | [
"Apache-2.0"
] | null | null | null | stage0/stdlib/Lean/Compiler/IR/CtorLayout.c | mattweingarten/lean4 | 178b3e5b52772d386385b31dbb6127b4c3aa0a4b | [
"Apache-2.0"
] | null | null | null | // Lean compiler output
// Module: Lean.Compiler.IR.CtorLayout
// Imports: Init Lean.Environment Lean.Compiler.IR.Format
#include <lean/lean.h>
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wunused-label"
#elif defined(__GNUC__) && !defined(__CLANG__)
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
#ifdef __cplusplus
extern "C" {
#endif
lean_object* l_Lean_IR_CtorFieldInfo_format___closed__7;
lean_object* l_Lean_IR_CtorFieldInfo_Lean_Compiler_IR_CtorLayout___instance__1;
lean_object* l_Lean_fmt___at_Lean_Position_Lean_Data_Position___instance__2___spec__1(lean_object*);
lean_object* l_Lean_IR_CtorFieldInfo_format_match__1___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
lean_object* l_Lean_IR_CtorFieldInfo_format___closed__6;
lean_object* l_Lean_fmt___at_Lean_IR_CtorFieldInfo_format___spec__1(lean_object*);
extern lean_object* l___private_Lean_Syntax_0__Lean_Syntax_formatInfo___closed__1;
lean_object* l_Lean_IR_CtorFieldInfo_format___closed__5;
extern lean_object* l_Lean_Format_join___closed__1;
lean_object* l_Lean_IR_CtorFieldInfo_Lean_Compiler_IR_CtorLayout___instance__1___closed__1;
extern lean_object* l___private_Lean_Compiler_IR_Format_0__Lean_IR_formatArg___closed__2;
lean_object* l_Lean_IR_CtorFieldInfo_format(lean_object*);
lean_object* l_Lean_IR_CtorFieldInfo_format___closed__3;
lean_object* l_Lean_IR_CtorFieldInfo_format___closed__1;
lean_object* l_Lean_IR_CtorFieldInfo_format___closed__8;
lean_object* l___private_Lean_Compiler_IR_Format_0__Lean_IR_formatIRType(lean_object*);
lean_object* l_Lean_fmt___at_Lean_IR_CtorFieldInfo_format___spec__1___boxed(lean_object*);
lean_object* l_Lean_IR_CtorFieldInfo_format___closed__4;
lean_object* l_Lean_IR_CtorFieldInfo_format___closed__2;
lean_object* l_Lean_IR_getCtorLayout___boxed(lean_object*, lean_object*);
lean_object* lean_ir_get_ctor_layout(lean_object*, lean_object*);
lean_object* l_Lean_IR_CtorFieldInfo_format_match__1(lean_object*);
lean_object* l_Lean_IR_CtorFieldInfo_format_match__1___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4, lean_object* x_5) {
_start:
{
switch (lean_obj_tag(x_1)) {
case 0:
{
lean_object* x_6; lean_object* x_7;
lean_dec(x_5);
lean_dec(x_4);
lean_dec(x_3);
x_6 = lean_box(0);
x_7 = lean_apply_1(x_2, x_6);
return x_7;
}
case 1:
{
lean_object* x_8; lean_object* x_9;
lean_dec(x_5);
lean_dec(x_4);
lean_dec(x_2);
x_8 = lean_ctor_get(x_1, 0);
lean_inc(x_8);
lean_dec(x_1);
x_9 = lean_apply_1(x_3, x_8);
return x_9;
}
case 2:
{
lean_object* x_10; lean_object* x_11;
lean_dec(x_5);
lean_dec(x_3);
lean_dec(x_2);
x_10 = lean_ctor_get(x_1, 0);
lean_inc(x_10);
lean_dec(x_1);
x_11 = lean_apply_1(x_4, x_10);
return x_11;
}
default:
{
lean_object* x_12; lean_object* x_13; lean_object* x_14; lean_object* x_15;
lean_dec(x_4);
lean_dec(x_3);
lean_dec(x_2);
x_12 = lean_ctor_get(x_1, 0);
lean_inc(x_12);
x_13 = lean_ctor_get(x_1, 1);
lean_inc(x_13);
x_14 = lean_ctor_get(x_1, 2);
lean_inc(x_14);
lean_dec(x_1);
x_15 = lean_apply_3(x_5, x_12, x_13, x_14);
return x_15;
}
}
}
}
lean_object* l_Lean_IR_CtorFieldInfo_format_match__1(lean_object* x_1) {
_start:
{
lean_object* x_2;
x_2 = lean_alloc_closure((void*)(l_Lean_IR_CtorFieldInfo_format_match__1___rarg), 5, 0);
return x_2;
}
}
lean_object* l_Lean_fmt___at_Lean_IR_CtorFieldInfo_format___spec__1(lean_object* x_1) {
_start:
{
lean_object* x_2;
x_2 = l___private_Lean_Compiler_IR_Format_0__Lean_IR_formatIRType(x_1);
return x_2;
}
}
static lean_object* _init_l_Lean_IR_CtorFieldInfo_format___closed__1() {
_start:
{
lean_object* x_1;
x_1 = lean_mk_string("obj@");
return x_1;
}
}
static lean_object* _init_l_Lean_IR_CtorFieldInfo_format___closed__2() {
_start:
{
lean_object* x_1; lean_object* x_2;
x_1 = l_Lean_IR_CtorFieldInfo_format___closed__1;
x_2 = lean_alloc_ctor(2, 1, 0);
lean_ctor_set(x_2, 0, x_1);
return x_2;
}
}
static lean_object* _init_l_Lean_IR_CtorFieldInfo_format___closed__3() {
_start:
{
lean_object* x_1;
x_1 = lean_mk_string("usize@");
return x_1;
}
}
static lean_object* _init_l_Lean_IR_CtorFieldInfo_format___closed__4() {
_start:
{
lean_object* x_1; lean_object* x_2;
x_1 = l_Lean_IR_CtorFieldInfo_format___closed__3;
x_2 = lean_alloc_ctor(2, 1, 0);
lean_ctor_set(x_2, 0, x_1);
return x_2;
}
}
static lean_object* _init_l_Lean_IR_CtorFieldInfo_format___closed__5() {
_start:
{
lean_object* x_1;
x_1 = lean_mk_string("scalar#");
return x_1;
}
}
static lean_object* _init_l_Lean_IR_CtorFieldInfo_format___closed__6() {
_start:
{
lean_object* x_1; lean_object* x_2;
x_1 = l_Lean_IR_CtorFieldInfo_format___closed__5;
x_2 = lean_alloc_ctor(2, 1, 0);
lean_ctor_set(x_2, 0, x_1);
return x_2;
}
}
static lean_object* _init_l_Lean_IR_CtorFieldInfo_format___closed__7() {
_start:
{
lean_object* x_1;
x_1 = lean_mk_string("@");
return x_1;
}
}
static lean_object* _init_l_Lean_IR_CtorFieldInfo_format___closed__8() {
_start:
{
lean_object* x_1; lean_object* x_2;
x_1 = l_Lean_IR_CtorFieldInfo_format___closed__7;
x_2 = lean_alloc_ctor(2, 1, 0);
lean_ctor_set(x_2, 0, x_1);
return x_2;
}
}
lean_object* l_Lean_IR_CtorFieldInfo_format(lean_object* x_1) {
_start:
{
switch (lean_obj_tag(x_1)) {
case 0:
{
lean_object* x_2;
x_2 = l___private_Lean_Compiler_IR_Format_0__Lean_IR_formatArg___closed__2;
return x_2;
}
case 1:
{
lean_object* x_3; lean_object* x_4; lean_object* x_5; lean_object* x_6; lean_object* x_7; lean_object* x_8;
x_3 = lean_ctor_get(x_1, 0);
lean_inc(x_3);
lean_dec(x_1);
x_4 = l_Lean_fmt___at_Lean_Position_Lean_Data_Position___instance__2___spec__1(x_3);
x_5 = l_Lean_IR_CtorFieldInfo_format___closed__2;
x_6 = lean_alloc_ctor(4, 2, 0);
lean_ctor_set(x_6, 0, x_5);
lean_ctor_set(x_6, 1, x_4);
x_7 = l_Lean_Format_join___closed__1;
x_8 = lean_alloc_ctor(4, 2, 0);
lean_ctor_set(x_8, 0, x_6);
lean_ctor_set(x_8, 1, x_7);
return x_8;
}
case 2:
{
lean_object* x_9; lean_object* x_10; lean_object* x_11; lean_object* x_12; lean_object* x_13; lean_object* x_14;
x_9 = lean_ctor_get(x_1, 0);
lean_inc(x_9);
lean_dec(x_1);
x_10 = l_Lean_fmt___at_Lean_Position_Lean_Data_Position___instance__2___spec__1(x_9);
x_11 = l_Lean_IR_CtorFieldInfo_format___closed__4;
x_12 = lean_alloc_ctor(4, 2, 0);
lean_ctor_set(x_12, 0, x_11);
lean_ctor_set(x_12, 1, x_10);
x_13 = l_Lean_Format_join___closed__1;
x_14 = lean_alloc_ctor(4, 2, 0);
lean_ctor_set(x_14, 0, x_12);
lean_ctor_set(x_14, 1, x_13);
return x_14;
}
default:
{
lean_object* x_15; lean_object* x_16; lean_object* x_17; lean_object* x_18; lean_object* x_19; lean_object* x_20; lean_object* x_21; lean_object* x_22; lean_object* x_23; lean_object* x_24; lean_object* x_25; lean_object* x_26; lean_object* x_27; lean_object* x_28; lean_object* x_29; lean_object* x_30;
x_15 = lean_ctor_get(x_1, 0);
lean_inc(x_15);
x_16 = lean_ctor_get(x_1, 1);
lean_inc(x_16);
x_17 = lean_ctor_get(x_1, 2);
lean_inc(x_17);
lean_dec(x_1);
x_18 = l_Lean_fmt___at_Lean_Position_Lean_Data_Position___instance__2___spec__1(x_15);
x_19 = l_Lean_IR_CtorFieldInfo_format___closed__6;
x_20 = lean_alloc_ctor(4, 2, 0);
lean_ctor_set(x_20, 0, x_19);
lean_ctor_set(x_20, 1, x_18);
x_21 = l_Lean_IR_CtorFieldInfo_format___closed__8;
x_22 = lean_alloc_ctor(4, 2, 0);
lean_ctor_set(x_22, 0, x_20);
lean_ctor_set(x_22, 1, x_21);
x_23 = l_Lean_fmt___at_Lean_Position_Lean_Data_Position___instance__2___spec__1(x_16);
x_24 = lean_alloc_ctor(4, 2, 0);
lean_ctor_set(x_24, 0, x_22);
lean_ctor_set(x_24, 1, x_23);
x_25 = l___private_Lean_Syntax_0__Lean_Syntax_formatInfo___closed__1;
x_26 = lean_alloc_ctor(4, 2, 0);
lean_ctor_set(x_26, 0, x_24);
lean_ctor_set(x_26, 1, x_25);
x_27 = l___private_Lean_Compiler_IR_Format_0__Lean_IR_formatIRType(x_17);
lean_dec(x_17);
x_28 = lean_alloc_ctor(4, 2, 0);
lean_ctor_set(x_28, 0, x_26);
lean_ctor_set(x_28, 1, x_27);
x_29 = l_Lean_Format_join___closed__1;
x_30 = lean_alloc_ctor(4, 2, 0);
lean_ctor_set(x_30, 0, x_28);
lean_ctor_set(x_30, 1, x_29);
return x_30;
}
}
}
}
lean_object* l_Lean_fmt___at_Lean_IR_CtorFieldInfo_format___spec__1___boxed(lean_object* x_1) {
_start:
{
lean_object* x_2;
x_2 = l_Lean_fmt___at_Lean_IR_CtorFieldInfo_format___spec__1(x_1);
lean_dec(x_1);
return x_2;
}
}
static lean_object* _init_l_Lean_IR_CtorFieldInfo_Lean_Compiler_IR_CtorLayout___instance__1___closed__1() {
_start:
{
lean_object* x_1;
x_1 = lean_alloc_closure((void*)(l_Lean_IR_CtorFieldInfo_format), 1, 0);
return x_1;
}
}
static lean_object* _init_l_Lean_IR_CtorFieldInfo_Lean_Compiler_IR_CtorLayout___instance__1() {
_start:
{
lean_object* x_1;
x_1 = l_Lean_IR_CtorFieldInfo_Lean_Compiler_IR_CtorLayout___instance__1___closed__1;
return x_1;
}
}
lean_object* l_Lean_IR_getCtorLayout___boxed(lean_object* x_1, lean_object* x_2) {
_start:
{
lean_object* x_3;
x_3 = lean_ir_get_ctor_layout(x_1, x_2);
lean_dec(x_2);
lean_dec(x_1);
return x_3;
}
}
lean_object* initialize_Init(lean_object*);
lean_object* initialize_Lean_Environment(lean_object*);
lean_object* initialize_Lean_Compiler_IR_Format(lean_object*);
static bool _G_initialized = false;
lean_object* initialize_Lean_Compiler_IR_CtorLayout(lean_object* w) {
lean_object * res;
if (_G_initialized) return lean_io_result_mk_ok(lean_box(0));
_G_initialized = true;
res = initialize_Init(lean_io_mk_world());
if (lean_io_result_is_error(res)) return res;
lean_dec_ref(res);
res = initialize_Lean_Environment(lean_io_mk_world());
if (lean_io_result_is_error(res)) return res;
lean_dec_ref(res);
res = initialize_Lean_Compiler_IR_Format(lean_io_mk_world());
if (lean_io_result_is_error(res)) return res;
lean_dec_ref(res);
l_Lean_IR_CtorFieldInfo_format___closed__1 = _init_l_Lean_IR_CtorFieldInfo_format___closed__1();
lean_mark_persistent(l_Lean_IR_CtorFieldInfo_format___closed__1);
l_Lean_IR_CtorFieldInfo_format___closed__2 = _init_l_Lean_IR_CtorFieldInfo_format___closed__2();
lean_mark_persistent(l_Lean_IR_CtorFieldInfo_format___closed__2);
l_Lean_IR_CtorFieldInfo_format___closed__3 = _init_l_Lean_IR_CtorFieldInfo_format___closed__3();
lean_mark_persistent(l_Lean_IR_CtorFieldInfo_format___closed__3);
l_Lean_IR_CtorFieldInfo_format___closed__4 = _init_l_Lean_IR_CtorFieldInfo_format___closed__4();
lean_mark_persistent(l_Lean_IR_CtorFieldInfo_format___closed__4);
l_Lean_IR_CtorFieldInfo_format___closed__5 = _init_l_Lean_IR_CtorFieldInfo_format___closed__5();
lean_mark_persistent(l_Lean_IR_CtorFieldInfo_format___closed__5);
l_Lean_IR_CtorFieldInfo_format___closed__6 = _init_l_Lean_IR_CtorFieldInfo_format___closed__6();
lean_mark_persistent(l_Lean_IR_CtorFieldInfo_format___closed__6);
l_Lean_IR_CtorFieldInfo_format___closed__7 = _init_l_Lean_IR_CtorFieldInfo_format___closed__7();
lean_mark_persistent(l_Lean_IR_CtorFieldInfo_format___closed__7);
l_Lean_IR_CtorFieldInfo_format___closed__8 = _init_l_Lean_IR_CtorFieldInfo_format___closed__8();
lean_mark_persistent(l_Lean_IR_CtorFieldInfo_format___closed__8);
l_Lean_IR_CtorFieldInfo_Lean_Compiler_IR_CtorLayout___instance__1___closed__1 = _init_l_Lean_IR_CtorFieldInfo_Lean_Compiler_IR_CtorLayout___instance__1___closed__1();
lean_mark_persistent(l_Lean_IR_CtorFieldInfo_Lean_Compiler_IR_CtorLayout___instance__1___closed__1);
l_Lean_IR_CtorFieldInfo_Lean_Compiler_IR_CtorLayout___instance__1 = _init_l_Lean_IR_CtorFieldInfo_Lean_Compiler_IR_CtorLayout___instance__1();
lean_mark_persistent(l_Lean_IR_CtorFieldInfo_Lean_Compiler_IR_CtorLayout___instance__1);
return lean_io_result_mk_ok(lean_box(0));
}
#ifdef __cplusplus
}
#endif
| 33.469565 | 304 | 0.827921 |
6f7baf00ba74a964dc4b255e3c89af5eb9d6cc17 | 10,984 | h | C | pages/benchmarks_page.h | marcocannici/scs | 799a4f7daed4294cd98c73df71676195e6c63de4 | [
"MIT"
] | 25 | 2017-06-30T15:31:33.000Z | 2021-04-21T20:12:18.000Z | pages/benchmarks_page.h | marcocannici/scs | 799a4f7daed4294cd98c73df71676195e6c63de4 | [
"MIT"
] | 34 | 2017-06-07T01:18:17.000Z | 2021-04-24T09:44:00.000Z | pages/benchmarks_page.h | marcocannici/scs | 799a4f7daed4294cd98c73df71676195e6c63de4 | [
"MIT"
] | 13 | 2017-06-07T01:16:09.000Z | 2021-06-07T09:12:56.000Z | /*
* The MIT License (MIT)
*
* Copyright (c) 2017 Pantelis Sopasakis (https://alphaville.github.io),
* Krina Menounou (https://www.linkedin.com/in/krinamenounou),
* Panagiotis Patrinos (http://homes.esat.kuleuven.be/~ppatrino)
*
* 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.
*
*/
/*! \page page_benchmark_results Benchmarks
*
* \tableofcontents
*
* \section benchmarks-dolan-more Dolan-Moré performance profiles
*
* In order to compare different solvers, we employ the [Dolan-Moré performance
* profile plot](https://pdfs.semanticscholar.org/54a2/0dbd409436be4f188dfa9a78949a1cac230d.pdf).
*
* Let us briefly introduce the Dolan-Moré performance profile plot.
*
* Let \f$P\f$ be a finite set of problems used as benchmarks and \f$S\f$ be a
* set of solvers we want to compare to one another.
*
* Let \f$t_{p,s}\f$ be the cost (e.g., runtime or flops) to solve a problem
* \f$p\f$ using a solver \f$s\f$.
*
* We define the ration between \f$t_{p,s}\f$ and the lowest observed cost to solve
* this problem using some solver \f$s\in S\f$:
*
* \f{eqnarray*}{
* r_{p,s} = \frac{t_{p,s}}{\min_{s \in S} t_{p,s}}.
* \f}
*
* If a solver \f$s\f$ does not solve a problem \f$p\f$, then we assign to \f$r_{p,s}\f$
* a very high value \f$r_M > r_{p,s}\f$ for all other \f$p,s\f$.
*
* The cumulative distribution of the performance ratio is the Dolan-Moré performance
* profile plot.
*
* In particular, define
*
* \f{eqnarray*}{
* \rho_s(\tau) = \frac{1}{n_p}\#\{p\in P: r_{p,s}\leq \tau\},
* \f}
*
* for \f$\tau\geq 1\f$ and where \f$n_p\f$ is the number of problems.
*
* The Dolan-Moré performance profile is the plot of \f$\rho_s\f$ vs \f$\tau\f$,
* typically on a logarithmic x-axis.
*
* <img src="images/dolan-more.png" alt="The Dolan More plot" width="60%"/>
*
*
* \section benchmark-results Benchmark results
*
* \subsection benchmark-parameters Benchmarking parameters
*
* In all benchmark results presented below we set the tolerance to \f$10^{-4}\f$.
*
* The \ref #scs_settings.max_iters "maximum number of iterations" was set to a
* very high value above which we may confidently tell the problem is unlikely
* to be solved (e.g., \f$10^6\f$).
*
* Given that different algorithms (SCS, SuperSCS using Broyden directions and
* SuperSCS using Anderson's acceleration) have a different per-iteration cost,
* we allow every algorithm to run for a give time (see
* \ref #scs_settings.max_time_milliseconds "max_time_milliseconds").
*
* After that maximum time has passed,
* if the algorithm has not converged we consider that it has failed to solve the
* problem.
*
*
* In Broyden's method we deactivated the K0 steps.
*
* \subsection benchmarks-lasso LASSO problems
*
* [1152 lasso problems](https://github.com/kul-forbes/scs/blob/master/tests/profiling_matlab/profile_runners/profile_runner_lasso.m)
*
*
* <div>
* <table border="0">
* <tr>
* <td style="padding:1px">
* <img src="images/lasso/lasso-broyden-50.png" alt="lasso-broyden-50" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/lasso/lasso-broyden-100.png" alt="lasso-broyden-100" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/lasso/lasso-anderson-5.png" alt="lasso-anderson-5" width="95%"/>
* </td>
* </tr>
* <tr>
* <td style="padding:1px">
* <img src="images/lasso/lasso-anderson-10.png" alt="lasso-anderson-10" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/lasso/lasso-anderson-15.png" alt="lasso-anderson-15" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/lasso/lasso-anderson-20.png" alt="lasso-anderson-20" width="95%"/>
* </td>
* </tr>
* </table>
* </div>
*
*
* \subsection benchmarks-pca1 Regularized PCA
*
* [288 regularized PCA problems](https://github.com/kul-forbes/scs/blob/master/tests/profiling_matlab/profile_runners/profile_runner_pca.m)
*
* <div>
* <table border="0">
* <tr>
* <td style="padding:1px">
* <img src="images/pca/pca-broyden-100.png" alt="pca-broyden-100" width="93%"/>
* </td>
* <td style="padding:1px">
* <img src="images/pca/pca-anderson-15.png" alt="pca-anderson-15" width="100%"/>
* </td>
* <td style="padding:1px">
* <img src="images/pca/pca-anderson-20.png" alt="pca-anderson-20" width="93%"/>
* </td>
* </tr>
* </table>
* </div>
*
*
* \subsection benchmarks-logreg Logistic regression problems
*
* [288 logistic regression problems](https://github.com/kul-forbes/scs/blob/master/tests/profiling_matlab/profile_runners/profile_runner_logreg.m)
*
* <div>
* <table border="0">
* <tr>
* <td style="padding:1px">
* <img src="images/logreg/logreg-broyden-50.png" alt="logreg-broyden-50" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/logreg/logreg-broyden-100.png" alt="logreg-broyden-100" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/logreg/logreg-anderson-5.png" alt="logreg-anderson-5" width="95%"/>
* </td>
* </tr>
* <tr>
* <td style="padding:1px">
* <img src="images/logreg/logreg-anderson-10.png" alt="logreg-anderson-10" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/logreg/logreg-anderson-15.png" alt="logreg-anderson-15" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/logreg/logreg-anderson-cmp.png" alt="logreg-anderson-cmp" width="95%"/>
* </td>
* </tr>
* </table>
* </div>
*
* \subsection benchmarks-sdp2 Semidefinite programming
*
* [48 SDP problems](https://github.com/kul-forbes/scs/blob/master/tests/profiling_matlab/profile_runners/profile_runner_sdp2.m)
*
* <div>
* <table border="0">
* <tr>
* <td style="padding:1px">
* <img src="images/sdp2/sdp2-broyden-50.png" alt="sdp-broyden-50" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/sdp2/sdp2-broyden-100.png" alt="sdp2-broyden-100" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/sdp2/sdp2-anderson-3.png" alt="sdp2-anderson-3" width="90%"/>
* </td>
* </tr>
* <tr>
* <td style="padding:1px">
* <img src="images/sdp2/sdp2-anderson-5.png" alt="sdp2-anderson-5" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/sdp2/sdp2-anderson-10.png" alt="sdp2-anderson-10" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/sdp2/sdp2-anderson-15.png" alt="sdp2-anderson-15" width="90%"/>
* </td>
* </tr>
* </table>
* </div>
*
* \subsection benchmarks-sdp2b Ill-conditioned SDPs
*
* [48 ill-conditioned SDP problems](https://github.com/kul-forbes/scs/blob/master/tests/profiling_matlab/profile_runners/profile_runner_sdp2b.m)
*
* <div>
* <table border="0">
* <tr>
* <td style="padding:1px">
* <img src="images/sdp2b/sdp2b-aa-3.png" alt="sdp2b-aa-5" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/sdp2b/sdp2b-aa-5.png" alt="sdp2b-aa-5" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/sdp2b/sdp2b-aa-10.png" alt="sdp2b-aa-10" width="90%"/>
* </td>
* </tr>
* <tr>
* <td style="padding:1px">
* <img src="images/sdp2b/sdp2b-aa-15.png" alt="sdp2b-aa-15" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/sdp2b/sdp2b-bro-50.png" alt="sdp2b-bro-50" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/sdp2b/sdp2b-bro-100.png" alt="sdp2b-bro-100" width="90%"/>
* </td>
* </tr>
* </table>
* </div>
*
* \subsection benchmarks-normcon Norm-constrained norm minimization
*
* [256 norm-constrained problems](https://github.com/kul-forbes/scs/blob/master/tests/profiling_matlab/profile_runners/profile_runner_normcon.m)
*
* <div>
* <table border="0">
* <tr>
* <td style="padding:1px">
* <img src="images/normcon_hard/nch-aa-3.png" alt="normcon-broyden-50" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/normcon_hard/nch-aa-5.png" alt="normcon-broyden-100" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/normcon_hard/nch-aa-10.png" alt="normcon-anderson-5" width="90%"/>
* </td>
* </tr>
* <tr>
* <td style="padding:1px">
* <img src="images/normcon_hard/nch-bro-50.png" alt="normcon-broyden-50" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/normcon_hard/nch-bro-100.png" alt="normcon-broyden-50" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/normcon_hard/nch-comp.png" alt="normcon-broyden-50" width="95%"/>
* </td>
* </tr>
* </table>
* </div>
*
* \section maros-meszaros Maros-Meszaros Problems
*
* We tested SuperSCS on the
* [Maros-Meszaros collection of QP problems](http://www.cuter.rl.ac.uk/Problems/marmes.html).
*
* <div>
* <table border="0">
* <tr>
* <td style="padding:1px">
* <img src="images/mm/mm-scs-vs-bro.png" alt="Maros-Meszaros: SCS vs SuperSCS/Broyden" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/mm/mm-scs-vs-aa.png" alt="Maros-Meszaros: SCS vs SuperSCS/AA" width="95%"/>
* </td>
* <td style="padding:1px">
* <img src="images/mm/mm-aa-vs-bro.png" alt="Maros-Meszaros: SuperSCS Broyden vs AA" width="95%"/>
* </td>
* </tr>
* </table>
* </div>
*
* Find details \ref page_maros_meszaros_results "here".
*/ | 37.488055 | 147 | 0.616806 |
6fdc12e5bf2a8fa862a89ecc9454f0e5e287ae12 | 4,595 | h | C | include/geometry/shapes/implementation/component/Triangle2D.h | thorbenlouw/CUP-CFD | d06f7673a1ed12bef24de4f1b828ef864fa45958 | [
"MIT"
] | 3 | 2021-06-24T10:20:12.000Z | 2021-07-18T14:43:19.000Z | include/geometry/shapes/implementation/component/Triangle2D.h | thorbenlouw/CUP-CFD | d06f7673a1ed12bef24de4f1b828ef864fa45958 | [
"MIT"
] | 2 | 2021-07-22T15:31:03.000Z | 2021-07-28T14:27:28.000Z | include/geometry/shapes/implementation/component/Triangle2D.h | thorbenlouw/CUP-CFD | d06f7673a1ed12bef24de4f1b828ef864fa45958 | [
"MIT"
] | 1 | 2021-07-22T15:24:24.000Z | 2021-07-22T15:24:24.000Z | /**
* @file
* @author University of Warwick
* @version 1.0
*
* @section LICENSE
*
* @section DESCRIPTION
*
* Description
*
* Declarations for the Triangle class
*/
#ifndef CUPCFD_GEOMETRY_SHAPES_TRIANGLE_2D_INCLUDE_H
#define CUPCFD_GEOMETRY_SHAPES_TRIANGLE_2D_INCLUDE_H
#include "EuclideanPoint.h"
#include "EuclideanVector.h"
#include "Triangle.h"
namespace euc = cupcfd::geometry::euclidean;
namespace cupcfd
{
namespace geometry
{
namespace shapes
{
/**
* Class for storing 2D triangle definition data and operations in a
* N-dimensional space.
*/
template <class T>
class Triangle2D : public Triangle<Triangle2D<T>, T, 2>
{
public:
// === Constructor/Deconstructors ===
/**
* Constructor - Build a triangle using the three provided points
* as a, b and c vertices.
*
* Edges should exist between ab, bc and ac.
*
* @tparam T The data type of the coordinate system
*/
Triangle2D(const euc::EuclideanPoint<T,2>& a,
const euc::EuclideanPoint<T,2>& b,
const euc::EuclideanPoint<T,2>& c);
/**
* Copy Constructor
*
* @tparam T The data type of the coordinate system
*/
Triangle2D(const Triangle2D& source);
/**
* Deconstructor
*
* @tparam T The data type of the coordinate system
*/
~Triangle2D();
// === Static Methods ===
/**
* Uses the barycentric method to determine whether a point lies inside the area of a
* 2D triangle defined by three points.
*
* www.drdobbs.com/database/triangle-intersection-tests/184404201
* https://www.youtube.com/watch?v=HYAgJN3x4GA
*
* This method can be used for triangles in a higher dimensionality space, but the triangle
* points would need to be rotated such that they all lie on a XY plane, and their XY
* dimensional components used instead.
*
* @param a Position of Point a of a triangle
* @param b Position of Point b of a triangle
* @param c Position of Point c of a triangle
* @param p The point to evaluate the position of
*
* @tparam T The data type of the coordinate system
*
* @return A boolean indicating whether the point lies inside the triangle vertices
* @retval true The point lies inside the triangle (or on one of the edges/vertices)
* @retval false The point does not lie inside the triangle
*/
__attribute__((warn_unused_result))
static bool isPointInsideBarycentric(
const euc::EuclideanPoint<T,2>& a,
const euc::EuclideanPoint<T,2>& b,
const euc::EuclideanPoint<T,2>& c,
const euc::EuclideanPoint<T,2>& p);
// === Concrete Methods ===
/**
* Determine whether a point lies within the three points of the triangle.
* Triangle edges/vertices are treated as inside the triangle for this purpose.
*
* If the dimensionality of the triangle is greater than 2D (e.g. 3D), then the point is
* projected to the same plane as the triangle for the purposes of this test
*
* @param p The point to evaluate the position of
*
* @tparam T The data type of the coordinate system
* @tparam N The dimension of the space the triangle is in (e.g. 2 for 2D, 3 for 3D...)
*
* @return A boolean indicating whether the point lies inside the triangle vertices
* @retval true The point lies inside the triangle (or on one of the edges/vertices)
* @retval false The point does not lie inside the triangle
*/
__attribute__((warn_unused_result))
bool isPointInside(const euc::EuclideanPoint<T,2>& p);
/**
* Determine whether a point lies within the three points of the triangle.
* Triangle edges/vertices are treated as inside the triangle for this purpose.
*
* Uses the direction of vector cross-products.
*
* @param p The point to evaluate the position of
*
* @tparam T The data type of the coordinate system
* @tparam N The dimension of the space the triangle is in (e.g. 2 for 2D, 3 for 3D...)
*
* @return A boolean indicating whether the point lies inside the triangle vertices
* @retval true The point lies inside the triangle (or on one of the edges/vertices)
* @retval false The point does not lie inside the triangle
*/
//bool isPointInsideCrossProduct(euc::EuclideanPoint<T,N> p);
};
}
}
}
// Include Header Level Definitions
#include "Triangle2D.ipp"
#endif
| 31.909722 | 96 | 0.652013 |
4e5d4af0c5961835231ca0226a83bf62e24da2ea | 474 | c | C | Sources/02XXX/2522/2522.c | DDManager/Baekjoon-Online-Judge | 7dd6d76838d3309bfe5bef46f1778c5776ebdf2a | [
"MIT"
] | 1 | 2019-07-02T09:07:58.000Z | 2019-07-02T09:07:58.000Z | Sources/02XXX/2522/2522.c | DDManager/BOJ-DDM-Code | 7dd6d76838d3309bfe5bef46f1778c5776ebdf2a | [
"MIT"
] | null | null | null | Sources/02XXX/2522/2522.c | DDManager/BOJ-DDM-Code | 7dd6d76838d3309bfe5bef46f1778c5776ebdf2a | [
"MIT"
] | 1 | 2021-10-18T07:29:44.000Z | 2021-10-18T07:29:44.000Z | /**
* BOJ 2522번 C언어 소스 코드
* 작성자 : 동동매니저 (DDManager)
*
* ※ 실행 결과
* 사용 메모리 : 1,116 KB / 131,072 KB
* 소요 시간 : 0 ms / 1,000 ms
*
* Copyright 2019. DDManager all rights reserved.
*/
#include <stdio.h>
int main(void){
int N,i,j;
scanf("%d",&N);
for(i=1;i<N;i++){
for(j=N-i;j>0;j--) putchar(' ');
for(j=0;j<i;j++) putchar('*');
puts("");
}
for(i=N;i>0;i--){
for(j=N-i;j>0;j--) putchar(' ');
for(j=0;j<i;j++) putchar('*');
puts("");
}
return 0;
} | 16.928571 | 50 | 0.5 |
ece2205d011329ab37ba456b3010b5ebd4881d3b | 34,484 | c | C | lisp/c/specials.c | snozawa/EusLisp | 021843b48ffcd029fcb6113d5022c703b6ce45fb | [
"BSD-3-Clause"
] | null | null | null | lisp/c/specials.c | snozawa/EusLisp | 021843b48ffcd029fcb6113d5022c703b6ce45fb | [
"BSD-3-Clause"
] | null | null | null | lisp/c/specials.c | snozawa/EusLisp | 021843b48ffcd029fcb6113d5022c703b6ce45fb | [
"BSD-3-Clause"
] | null | null | null | /*****************************************************************
/* specials.c
/* special-forms (let,let*,catch,throw,unwind-protect,...)
/* control structures,
/* macros ...
/*
/* Copyright: Toshihiro Matsui ETL, Umezono, Sakura-mura
/*
/* 1986
/* 1986-Dec let*
/* 1987-Mar special binding declaration
*****************************************************************/
static char *rcsid="@(#)$Id$";
#include "eus.h"
extern pointer MACRO,LAMBDA,LAMCLOSURE;
extern pointer K_FUNCTION_DOCUMENTATION;
extern struct bindframe *declare();
#ifdef EVAL_DEBUG
extern int evaldebug;
#endif
/*gensym*/
static pointer genhead;
static int genindex,tempindex=0;
static pointer QRETFROM,QEVAL,QPROGN,QIF;
/****************************************************************/
/* special forms
/****************************************************************/
pointer quote(ctx,arg)
register context *ctx;
register pointer arg;
{
#ifdef SPEC_DEBUG
printf( "quote:" ); hoge_print(arg);
#endif
return(carof(arg,E_MISMATCHARG));
}
pointer EVAL(ctx,n,argv)
register context *ctx;
int n;
register pointer argv[];
{ pointer env;
ckarg2(1,2);
if (n==2) env=argv[1]; else env=NULL;
#ifdef SPEC_DEBUG
printf( "EVAL:" );
hoge_print_sub(argv[0]);
if( env != NULL )
hoge_print_sub( env );
printf( "\n" );
#endif
return(eval2(ctx,argv[0],env));}
pointer PROGN(ctx,arg)
register context *ctx;
register pointer arg;
{
#ifdef SPEC_DEBUG
printf( "PROGN:" ); hoge_print( arg );
#endif
return(progn(ctx,arg));}
pointer PROG1(ctx,n,argv)
register context *ctx;
int n;
pointer *argv;
{
#ifdef SPEC_DEBUG
printf( "PROG1:" );
if( n >= 0 ) hoge_print_sub( argv[0] );
printf( "\n" );
#endif
return((n>=1)?argv[0]:NIL);}
pointer APPLY(ctx,n,argv)
register context *ctx;
int n;
register pointer argv[];
{ register pointer a,*spsave=ctx->vsp,fun=argv[0];
register int i=1,argc=n-2;
if (n<2) error(E_MISMATCHARG);
#ifdef SPEC_DEBUG
printf( "APPLY:" );
{ int i;
for( i = 0; i < n; i++ )
hoge_print_sub( argv[i] );
}
printf( "\n" );
#endif
if (issymbol(fun)) {
fun=fun->c.sym.spefunc;
if (fun==UNBOUND) error(E_UNDEF,argv[0]);}
while (i<n-1) ckpush(argv[i++]);
a=argv[i];
while (islist(a)) {
ckpush(ccar(a));
a=ccdr(a);
argc++;}
a=(pointer)ufuncall(ctx,(ctx->callfp?ctx->callfp->form:NIL),
fun,(pointer)spsave,NULL,argc);
ctx->vsp=spsave;
#ifdef SAFETY
take_care(a);
#endif
return(a);}
pointer FUNCALL(ctx,n,argv)
register context *ctx;
int n;
register pointer argv[];
{ register pointer fun=argv[0];
if (n<1) error(E_MISMATCHARG);
#if SPEC_DEBUG
printf( "FUNCALL:" );
{
int i;
for( i = 0; i < n; i++ )
hoge_print_sub( argv[i] );
}
printf( "\n" );
#endif
if (issymbol(fun)) {
if (fun->c.sym.spefunc==UNBOUND) error(E_UNDEF,fun);}
pointer_update(Spevalof(QEVALHOOK),NIL);
return((pointer)ufuncall(ctx,ctx->callfp->form,fun,(pointer)&argv[1],NULL,n-1));}
pointer FUNCTION_CLOSURE(ctx,arg)
register context *ctx;
pointer arg;
{ pointer funcname;
if (!islist(arg)) error(E_MISMATCHARG);
if (ccdr(arg)!=NIL) error(E_MISMATCHARG);
#ifdef SPEC_DEBUG
printf( "FUNCTION_CLOSURE:" );
hoge_print( arg );
#endif
arg=ccar(arg);
if (issymbol(arg)) { funcname=arg; arg=getfunc(ctx,arg);}
else funcname=NIL;
if (iscode(arg)) return(arg);
else if (ccar(arg)==LAMCLOSURE) return(arg);
else if (ccar(arg)==LAMBDA) {
arg=cons(ctx,makeint(hide_ptr(ctx->fletfp)),ccdr(arg));
arg=cons(ctx,makeint(hide_ptr(ctx->bindfp)),arg);
arg=cons(ctx,funcname,arg);
return(cons(ctx,LAMCLOSURE,arg));}
else error(E_ILLFUNC);}
pointer MACEXPAND2(ctx,n,argv)
register context *ctx;
int n;
register pointer argv[];
{ pointer mac,args,expander,*argp,result;
int noarg=0;
ckarg(1);
#ifdef SPEC_DEBUG
printf( "MACEXPAND2:" ); hoge_print( argv[0] );
#endif
if (!islist(argv[0])) return(argv[0]);
mac=ccar(argv[0]); args=ccdr(argv[0]);
if (issymbol(mac)) mac=getfunc(ctx,mac);
if (iscode(mac)) {
if (mac->c.code.subrtype!=(pointer)SUBR_MACRO) return(argv[0]);
expander=makecode(mac,(pointer (*)())mac->c.code.entry,SUBR_FUNCTION);
pointer_update(expander->c.code.entry,mac->c.code.entry);}
else if (carof(mac,E_NOLIST)==MACRO) expander=cons(ctx,LAMBDA,ccdr(mac));
else return(argv[0]);
vpush(expander);
argp=ctx->vsp;
while (islist(args)) { vpush(ccar(args)); args=ccdr(args); noarg++;}
GC_POINT;
mac=ufuncall(ctx,ctx->callfp->form,expander,(pointer)argp,NULL,noarg);
/* ???? ctx->lastalloc=mac; ????*/
ctx->vsp=argp-1;
return(mac);}
/****************************************************************/
/* mapping
/****************************************************************/
pointer MAPC(ctx,n,argv)
register context *ctx;
int n;
register pointer *argv;
{ register pointer a;
register int i;
if (n<2) error(E_MISMATCHARG);
#ifdef SPEC_DEBUG
printf( "MAPC:" );
{ int i;
for( i = 0; i < n; i++ )
hoge_print_sub( argv[i] );
}
printf( "\n" );
#endif
while (islist(argv[1])) {
i=1;
while (i<n) {
a=argv[i];
if (!islist(a)) error(E_NOLIST);
ckpush(ccar(a));
argv[i]=ccdr(a);
i++;}
i--;
GC_POINT;
ufuncall(ctx,ctx->callfp->form,argv[0],(pointer)(ctx->vsp - i),NULL,i);
ctx->vsp -= i;}
return(argv[1]);}
pointer MAPCAR(ctx,n,argv)
register context *ctx;
register int n;
register pointer *argv;
{ register pointer a,r;
register int rcount=0,i;
pointer (*subr)();
if (n<2) error(E_MISMATCHARG);
#ifdef SPEC_DEBUG
printf( "MAPCAR:" );
{ int i;
for( i = 0; i < n; i++ )
hoge_print_sub( argv[i] );
}
printf( "\n" );
#endif
while (islist(argv[1])) {
i=1;
while (i<n) {
a=argv[i];
if (!islist(a)) error(E_NOLIST);
ckpush(ccar(a));
argv[i]=ccdr(a);
i++;}
i--;
GC_POINT;
r=ufuncall(ctx,ctx->callfp->form,argv[0],(pointer)(ctx->vsp - i),NULL,i);
ctx->vsp -=i;
vpush(r);
rcount++;}
GC_POINT;
r=(pointer)stacknlist(ctx,rcount);
return(r);}
pointer MAPCAN(ctx,n,argv)
register context *ctx;
int n;
register pointer *argv;
{ register pointer a,r;
register int i,rcount=0;
pointer *spsave=ctx->vsp;
if (n<2) error(E_MISMATCHARG);
#ifdef SPEC_DEBUG
printf( "MAPCAN:" );
{ int i;
for( i = 0; i < n; i++ )
hoge_print_sub( argv[i] );
}
printf( "\n" );
#endif
while (islist(argv[1])) {
i=1;
while (i<n) {
a=argv[i];
if (!islist(a)) error(E_NOLIST);
ckpush(ccar(a));
argv[i]=ccdr(a);
i++;}
i--;
GC_POINT;
r=ufuncall(ctx,ctx->callfp->form,argv[0],(pointer)(ctx->vsp -i),NULL,i);
ctx->vsp -=i;
vpush(r);
rcount++;}
GC_POINT;
a=(pointer)NCONC(ctx,rcount,spsave);
ctx->vsp=spsave;
return(a);}
/****************************************************************/
/* SETQ
/****************************************************************/
pointer SETQ(ctx,arg)
register context *ctx;
register pointer arg;
{ register pointer var,val=NIL, *p;
#ifdef SPEC_DEBUG
printf( "SETQ:" ); hoge_print( arg );
#endif
while (iscons(arg)) {
var=ccar(arg); arg=ccdr(arg);
if (!islist(arg)) error(E_MISMATCHARG);
GC_POINT;
val=eval(ctx,ccar(arg)); arg=ccdr(arg);
if (issymbol(var)) setval(ctx,var,val);
else if (islist(var) && issymbol(ccdr(var)) && ccdr(var)!=NIL) {
vpush(val);
p=(pointer *)ovafptr(eval(ctx,ccar(var)),ccdr(var)); pointer_update(*p,vpop());}
else error(E_NOSYMBOL,var);}
return(val);}
/****************************************************************/
/* control structures
/****************************************************************/
pointer IF(ctx,arg)
register context *ctx;
register pointer arg;
{ register pointer rest;
rest=cdrof(arg, E_MISMATCHARG);
if (!iscons(rest)) return(NIL);
#ifdef SPEC_DEBUG
printf( "IF:" ); hoge_print( arg );
#endif
GC_POINT;
if (eval(ctx,ccar(arg))!=NIL) return(eval(ctx,ccar(rest)));
else {
rest=ccdr(rest);
if (iscons(rest)) return(eval(ctx,ccar(rest)));
else return(NIL); } }
pointer WHEN(ctx,n,argv)
register context *ctx;
int n;
pointer *argv;
{ pointer form=NIL;
int i;
if (n<1) error(E_MISMATCHARG);
#ifdef SPEC_DEBUG
printf( "WHEN:" );
{ int i;
for( i = 0; i < n; i++ )
hoge_print_sub( argv[i] );
}
printf( "\n" );
#endif
while (n>1) form=cons(ctx,argv[--n],form);
form=cons(ctx,QPROGN,form);
form=cons(ctx,argv[0],cons(ctx,form,NIL));
return(cons(ctx,QIF,form));}
pointer WHILE(ctx,arg)
register context *ctx;
pointer arg;
{ pointer cond,body,*spsave=ctx->vsp,result;
struct blockframe *myblock;
struct bindframe *bfp=ctx->bindfp;
jmp_buf whilejmp;
int i;
#ifdef SPEC_DEBUG
printf( "WHILE:" ); hoge_print(arg);
#endif
if (!islist(arg)) return(NIL);
cond=ccar(arg); body=ccdr(arg);
myblock=(struct blockframe *)
makeblock(ctx,BLOCKFRAME,NIL,(jmp_buf *)whilejmp,ctx->blkfp); /* ???? */
if ((result=(pointer)eussetjmp(whilejmp))==0) {
while (eval(ctx,cond)!=NIL) {GC_POINT;progn(ctx,body);}
result=NIL;}
else if ((eusinteger_t)result==1) result=makeint(0);
ctx->blkfp=myblock->dynklink;
ctx->vsp=spsave;
ctx->bindfp=bfp;
return(result);}
pointer COND(ctx,arg)
register context *ctx;
pointer arg;
{ register pointer clause,cond;
#ifdef SPEC_DEBUG
printf( "COND:" ); hoge_print(arg);
#endif
while (islist(arg)) {
clause=ccar(arg);
if (!islist(clause)) error(E_NOLIST);
GC_POINT;
cond=eval(ctx,ccar(clause));
if (cond!=NIL) if (islist(ccdr(clause))) return(progn(ctx,ccdr(clause)));
else return(cond);
arg=ccdr(arg);}
return(NIL);}
pointer PARLET(ctx,args) /*let special form*/
register context *ctx;
pointer args;
{ pointer vlist,vlistsave,var,init,body,result,decl,*spsave=ctx->vsp,*vinits;
register struct bindframe *env, *bfsave=ctx->bindfp, *declenv;
struct specialbindframe *sbfps=ctx->sbindfp;
int i=0,vcount=0;
#if defined(PARLET_DEBUG) || defined(DEBUG_COUNT)
static int count = 0;
count++;
#endif
#if defined(SPEC_DEBUG) || defined(PARLET_DEBUG)
printf( "PARLET:%d",count ); hoge_print(args);
#endif
vlist=carof(args,E_MISMATCHARG);
body=ccdr(args);
env=bfsave;
/*declaration*/
while (islist(body)) {
decl=ccar(body);
if (!islist(decl) || (ccar(decl)!=QDECLARE)) break;
env=declare(ctx,ccdr(decl),env); /*add special decl. to current env*/
body=ccdr(body);}
GC_POINT;
/*evaluate variable initializers*/
vlistsave=vlist;
vinits=ctx->vsp;
while (islist(vlist)) {
var=ccar(vlist); vlist=ccdr(vlist);
if (islist(var)) {
init=ccdr(var); var=ccar(var);
if (islist(init)) init=eval(ctx,ccar(init));
else init=NIL;}
else init=NIL;
vpush(init); vcount++;}
/*update bindings at once*/
GC_POINT;
vlist=vlistsave;
while (i<vcount) {
var=ccar(vlist); vlist=ccdr(vlist);
if (islist(var)) var=ccar(var);
env=vbind(ctx,var,vinits[i++],env,bfsave);}
result=progn(ctx,body); /*evaluate body*/
ctx->bindfp=bfsave; /*restore environments*/
ctx->vsp=spsave;
unbindspecial(ctx,(struct specialbindframe *)ctx->vsp);
/* unbindspecial(ctx,sbfps+1); */
return(result);}
pointer SEQLET(ctx,args) /* let* special form*/
register context *ctx;
pointer args;
{ pointer vlist,var,init,body,result,decl,*spsave=ctx->vsp;
register struct bindframe *bf=ctx->bindfp, *env;
struct specialbindframe *sbfps=ctx->sbindfp;
#ifdef SPEC_DEBUG
printf( "SEQLET:" ); hoge_print(args);
#endif
GC_POINT;
vlist=carof(args,E_MISMATCHARG);
body=ccdr(args);
env=bf; /*inherit lexical variable scope*/
/*declaration*/
while (islist(body)) {
decl=ccar(body);
if (!islist(decl) || (ccar(decl)!=QDECLARE)) break;
env=declare(ctx,ccdr(decl),env);
body=ccdr(body);}
/*bind let* variables*/
while (islist(vlist)) {
GC_POINT;
var=ccar(vlist); vlist=ccdr(vlist);
if (islist(var)) {
init=ccdr(var); var=ccar(var);
if (islist(init)) init=eval(ctx,ccar(init));
else init=NIL;}
else init=NIL;
env=vbind(ctx,var,init,env,bf);
}
/*evaluate body*/
result=progn(ctx,body);
/*restore environments*/
ctx->bindfp=bf;
ctx->vsp=spsave;
unbindspecial(ctx,(struct specialbindframe *)ctx->vsp);
/* unbindspecial(ctx,sbfps+1); */
return(result);}
pointer CATCH(ctx,arg) /*special form*/
register context *ctx;
pointer arg;
{ pointer tag,body,val;
jmp_buf catchbuf;
int i;
#ifdef SPEC_DEBUG
printf( "CATCH:" ); hoge_print(arg);
#endif
tag=carof(arg,E_MISMATCHARG); tag=eval(ctx,tag);
body=ccdr(arg);
mkcatchframe(ctx,tag,catchbuf);
if ((val=(pointer)eussetjmp(catchbuf))==0) val=progn(ctx,body);
else if ((eusinteger_t)val==1) val=makeint(0); /*longjmp cannot return 0*/
ctx->callfp=ctx->catchfp->cf;
ctx->bindfp=ctx->catchfp->bf;
ctx->fletfp=ctx->catchfp->ff;
ctx->vsp=(pointer *)ctx->catchfp;
ctx->catchfp=(struct catchframe *)*ctx->vsp;
#ifdef __RETURN_BARRIER
check_return_barrier(ctx);
#endif
return(val);}
void throw(ctx,tag,result)
register context *ctx;
register pointer tag,result;
{ register struct catchframe *cfp=ctx->catchfp;
while (cfp!=NULL)
if (cfp->label==tag) {
ctx->catchfp=cfp;
unwind(ctx,(pointer *)ctx->catchfp);
euslongjmp(*(ctx->catchfp->jbp),result);}
else cfp=cfp->nextcatch;}
pointer THROW(ctx,arg)
register context *ctx;
register pointer arg;
{
pointer tag,result;
#ifdef SPEC_DEBUG
printf( "THROW:" ); hoge_print(arg);
#endif
tag=carof(arg,E_MISMATCHARG);
arg=ccdr(arg);
result=carof(arg,E_MISMATCHARG);
GC_POINT;
tag=eval(ctx,tag);
GC_POINT;
result=eval(ctx,result);
throw(ctx,tag,result);
error(E_NOCATCHER,tag);}
pointer FLET(ctx,arg)
register context *ctx;
register pointer arg;
{ register pointer fns, fn;
register struct fletframe *ffp=ctx->fletfp;
pointer result;
#ifdef SPEC_DEBUG
printf( "FLET:" ); hoge_print(arg);
#endif
GC_POINT;
fns=ccar(arg);
while (iscons(fns)) {
fn=ccar(fns); fns=ccdr(fns);
makeflet(ctx,ccar(fn),ccdr(fn),ffp,ctx->fletfp);}
result=progn(ctx,ccdr(arg));
ctx->fletfp=ffp;
return(result);}
pointer LABELS(ctx,arg)
register context *ctx;
register pointer arg;
{ register pointer fns, fn;
register struct fletframe *ffp=ctx->fletfp, *ffpp;
pointer result;
#ifdef SPEC_DEBUG
printf( "LABELS:" ); hoge_print(arg);
#endif
GC_POINT;
fns=ccar(arg);
while (iscons(fns)) {
fn=ccar(fns); fns=ccdr(fns);
makeflet(ctx,ccar(fn),ccdr(fn),ctx->fletfp,ctx->fletfp);}
fns=ccar(arg); ffpp=ctx->fletfp;
while (iscons(fns)) { /*allow mutual references between labels functions*/
fn=ffpp->fclosure;
fn=ccdr(fn); fn=ccdr(fn); fn=ccdr(fn); ccar(fn)=makeint(hide_ptr(ctx->fletfp));
fns=ccdr(fns); ffpp=ffpp->lexlink;}
result=progn(ctx,ccdr(arg));
ctx->fletfp=ffp;
return(result);}
pointer RESET(ctx,n,argv)
register context *ctx;
int n;
pointer *argv;
{
#ifdef SPEC_DEBUG
printf( "RESET:" );
{ int i;
for( i = 0; i < n; i++ )
hoge_print_sub(argv[i] );
}
printf( "\n" );
#endif
throw(ctx,makeint(0),T);
error(E_USER,(pointer)"cannot reset");}
pointer EVALHOOK(ctx,n,argv)
register context *ctx;
int n;
pointer *argv;
{ pointer form,val,env, *vspsave=ctx->vsp;
struct specialbindframe *sbfps=ctx->sbindfp;
ckarg2(2,3);
#ifdef SPEC_DEBUG
printf( "EVALHOOK:" );
{ int i;
for( i = 0; i < n; i++ )
hoge_print_sub(argv[i] );
}
printf( "\n" );
#endif
if (n==3) env=argv[2]; else env=NULL;
form=argv[0];
GC_POINT;
if (islist(form)) {
ehbypass=1;
bindspecial(ctx,QEVALHOOK,argv[1]);
val=eval2(ctx,form,env);
unbindspecial(ctx,(struct specialbindframe *)vspsave);
/* unbindspecial(ctx,sbfps+1); */
return(val);}
else return(eval2(ctx,form,env));}
pointer BLOCK(ctx,arg) /*special form*/
register context *ctx;
register pointer arg; /*must be called via ufuncall*/
{ pointer name,result,*spsave=ctx->vsp;
struct blockframe *myblock;
struct bindframe *bfp=ctx->bindfp;
jmp_buf blkjmp;
#ifdef SPEC_DEBUG
printf( "BLOCK:" ); hoge_print(arg);
#endif
GC_POINT;
name=carof(arg,E_MISMATCHARG); arg=ccdr(arg);
if (!issymbol(name)) error(E_NOSYMBOL);
myblock=(struct blockframe *)makeblock(ctx,BLOCKFRAME,name,(jmp_buf *)blkjmp,ctx->blkfp); /* ???? */
if ((result=(pointer)eussetjmp(blkjmp))==0) result=progn(ctx,arg);
else if ((eusinteger_t)result==1) result=makeint(0);
ctx->blkfp=myblock->dynklink;
/*restorations of bindfp and callfp are caller's responsibility???*/
ctx->bindfp=bfp;
ctx->vsp=spsave;
return(result);}
pointer RETFROM(ctx,arg) /*special-form*/
register context *ctx;
pointer arg;
{ pointer name,result;
struct blockframe *blkfp_old, *blkfp_new;
#ifdef SPEC_DEBUG
printf( "RETFROM:" ); hoge_print(arg);
#endif
GC_POINT;
name=carof(arg,E_MISMATCHARG); arg=ccdr(arg);
blkfp_old = ctx->blkfp;
while (ctx->blkfp!=NULL)
if (ctx->blkfp->kind==BLOCKFRAME && ctx->blkfp->name==name) {
blkfp_new = ctx->blkfp;
ctx->blkfp = blkfp_old;
if (islist(arg)) result=eval(ctx,ccar(arg)); else result=NIL;
if (result==makeint(0)) result=(pointer)1;
ctx->blkfp = blkfp_new;
unwind(ctx,(pointer *)ctx->blkfp);
euslongjmp(*ctx->blkfp->jbp,result);}
else ctx->blkfp=ctx->blkfp->lexklink;
error(E_NOBLOCK);}
pointer RETURN(ctx,n,argv)
register context *ctx;
int n;
pointer argv[];
{ pointer result=NIL;
if (n==1) result=argv[0];
if (n>1) error(E_MISMATCHARG);
#ifdef SPEC_DEBUG
printf( "RETURN:" ); hoge_print(result);
#endif
return(cons(ctx,QRETFROM,cons(ctx,NIL,cons(ctx,result,NIL))));}
pointer UNWINDPROTECT(ctx,arg)
register context *ctx;
pointer arg;
{ pointer *spsave=ctx->vsp;
struct protectframe *oldprotfp=ctx->protfp;
pointer protform,cleanupform,cleaner,result;
if (!islist(arg)) error(E_NOLIST);
#ifdef SPEC_DEBUG
printf( "UNWINDPROTECT:" ); hoge_print(arg);
#endif
GC_POINT;
protform=ccar(arg);
if (islist(arg)) cleanupform=ccdr(arg); else cleanupform=NIL;
cleaner=cons(ctx,NIL,cleanupform);
cleaner=cons(ctx,makeint(hide_ptr(ctx->fletfp)),cleaner);
cleaner=cons(ctx,makeint(hide_ptr(ctx->bindfp)),cleaner);
cleaner=cons(ctx,NIL,cleaner);
cleaner=cons(ctx,LAMCLOSURE,cleaner);
/*(LAMDA-CLOSURE bindfp fletfp () . body) */
/*bug...blocks and special variable bindings are not saved*/
vpush(ctx->protfp); vpush(cleaner);
ctx->protfp=(struct protectframe *)spsave;
GC_POINT;
result=eval(ctx,protform);
ctx->vsp=spsave;
ctx->protfp=oldprotfp;
progn(ctx,cleanupform);
return(result);
}
pointer TAGBODY(ctx,arg)
register context *ctx;
pointer arg;
{ pointer p,golist=NIL,forms;
jmp_buf tagjmp;
struct blockframe *tagblock;
pointer *spsave=ctx->vsp, *tagspsave;
struct bindframe *bfpsave=ctx->bindfp;
#ifdef SPEC_DEBUG
printf( "TAGBODY:" ); hoge_print(arg);
#endif
GC_POINT;
p=forms=arg;
while (iscons(p)) {
if (!iscons(ccar(p))) golist=cons(ctx,p,golist);
p=ccdr(p);}
tagblock=(struct blockframe *)
makeblock(ctx,TAGBODYFRAME,golist,(jmp_buf*)tagjmp,ctx->blkfp); /* ???? */
tagspsave=ctx->vsp;
repeat:
if ((p=(pointer)eussetjmp(tagjmp))==0)
{
ctx->vsp=tagspsave;
ctx->bindfp=bfpsave;
while (iscons(forms)) {
GC_POINT;
p=ccar(forms);
if (iscons(p)) eval(ctx,p);
forms=ccdr(forms);} }
else { forms=ccdr(p); goto repeat;}
ctx->blkfp=tagblock->dynklink;
ctx->vsp=spsave;
return(NIL);}
pointer GO(ctx,arg)
register context *ctx;
pointer arg;
{ pointer tag,body;
#ifdef SPEC_DEBUG
printf( "GO:" ); hoge_print( arg );
#endif
tag=carof(arg,"GO TAG?");
while (ctx->blkfp!=NULL) {
if (ctx->blkfp->kind==TAGBODYFRAME &&
(body=(pointer)assq(tag,ctx->blkfp->name))!=NIL) {
unwind(ctx,(pointer *)ctx->blkfp);
euslongjmp(ctx->blkfp->jbp,body);}/* ???? */
/* euslongjmp(*(ctx->blkfp->jbp),body);} *//* ??? eus_rbar */
ctx->blkfp=ctx->blkfp->lexklink;}
error(E_USER,(pointer)"go tag not found");}
pointer EVALWHEN(ctx,arg)
register context *ctx;
pointer arg;
{ pointer situation,forms;
#ifdef SPEC_DEBUG
printf( "EVALWHEN:" ); hoge_print( arg );
#endif
situation=carof(arg,E_MISMATCHARG); forms=ccdr(arg);
while (islist(situation))
if (ccar(situation)==QEVAL) return(progn(ctx,forms));
else situation=ccdr(situation);
return(NIL);}
pointer THE(ctx,arg)
register context *ctx;
pointer arg;
{ pointer typeid,form,result;
#ifdef SPEC_DEBUG
printf( "THE:" ); hoge_print( arg );
#endif
typeid=carof(arg,E_MISMATCHARG); arg=ccdr(arg);
form=carof(arg,E_MISMATCHARG);
if (islist(ccdr(arg))) error(E_MISMATCHARG);
GC_POINT;
result=eval(ctx,form);
if (typeid==QINTEGER || typeid==QFIXNUM)
if (!isint(result)) error(E_NOINT);
else return(result);
else if (typeid==QFLOAT)
if (!isflt(result)) error(E_NONUMBER);
else return(result);
else if (typeid==QNUMBER)
if (!isnum(result)) error(E_NONUMBER);
else return(result);
else {
if (isnum(result)) error(E_NOOBJECT);
if (speval(typeid)!=classof(result)) error(E_TYPEMISMATCH);
else return(result);} }
pointer AND(ctx,arg) /*special form (should be macro)*/
register context *ctx;
register pointer arg;
{ register pointer r;
#ifdef SPEC_DEBUG
printf( "AND:" ); hoge_print( arg );
#endif
while (islist(arg)) {
GC_POINT;
if ((r=eval(ctx,ccar(arg)))==NIL) return(r);
arg=ccdr(arg); }
return(r);}
pointer OR(ctx,arg) /*special form (should be macro)*/
register context *ctx;
register pointer arg;
{ register pointer r;
#ifdef SPEC_DEBUG
printf( "OR:" ); hoge_print( arg );
#endif
while (islist(arg)) {
GC_POINT;
if ((r=eval(ctx,ccar(arg)))!=NIL) return(r);
arg=ccdr(arg); }
return(NIL);}
pointer PROCLAIM(ctx,n,argv)
register context *ctx;
int n;
pointer argv[];
{ pointer decl,var,curval;
int i=0,vt;
#ifdef SPEC_DEBUG
printf( "PROCLAIM:" );
{ int i;
for( i = 0; i < n; i++ )
hoge_print_sub( argv[i] );}
printf( "\n" );
#endif
GC_POINT;
while (i<n) {
decl=argv[i++];
if (!islist(decl)) error(E_DECLFORM);
if (ccar(decl)==QSPECIAL) {
decl=ccdr(decl);
while (islist(decl)) {
var=ccar(decl); decl=ccdr(decl);
if (!issymbol(var)) error(E_NOSYMBOL);
if (var->c.sym.vtype==V_CONSTANT) error(E_SETCONST);
else if (var->c.sym.vtype>=V_SPECIAL) {
if (debug)
fprintf(stderr, "%s has already been declared as special\n",
var->c.sym.pname->c.str.chars);}
else {
/*first time to change to a special var*/
curval=speval(var);
var->c.sym.vtype=makeint(special_index());
vt=intval(var->c.sym.vtype);
ctx->specials->c.vec.v[vt]=curval;}
/*V_SPECIAL*/}
} }
return(NIL);}
pointer DECLARE(arg)
pointer arg;
{ error(E_DECLARE); } /*just ignore when interpretting*/
/****************************************************************/
/* package
/****************************************************************/
pointer ALLPACKAGES(ctx,n,argv)
register context *ctx;
int n;
pointer argv[];
{ ckarg(0);
#ifdef SPEC_DEBUG
printf( "ALLPACKAGES:\n" );
#endif
return(pkglist);}
pointer FINDPACKAGE(ctx,n,argv)
register context *ctx;
int n;
register pointer *argv;
{ pointer pkg;
ckarg(1);
#ifdef SPEC_DEBUG
printf( "FINDPACKAGE:" ); hoge_print( argv[0] );
#endif
pkg=findpkg(argv[0]);
if (pkg) return(pkg); else return(NIL);}
pointer MAKEPACKAGE(ctx,n,argv)
register context *ctx;
int n;
pointer *argv;
{ pointer pkg,name,nick,use;
int i=0;
ckarg2(1,3);
#ifdef SPEC_DEBUG
printf( "MAKEPACKAGE:" );
{ int i;
for( i = 0; i < n; i++ )
hoge_print_sub( argv[i] );
}
#endif
name=argv[0];
if (n>1) nick=argv[1]; else nick=NIL;
if (n>2) use=argv[2]; else use=NIL;
pkg=makepkg(ctx,name,nick,use); /*pkg is protected from gc in pkglist*/
return(pkg);}
eusinteger_t sxhash(x)
pointer x;
{
eusinteger_t h=0;
int s,i;
numunion nu;
if (isstring(x)) return(rehash(x));
else if (issymbol(x)) return(rehash(x->c.sym.pname));
else if (isint(x)) return(intval(x));
else if (isflt(x)) {
nu.fval=fltval(x); return(nu.ival);}
else if (islist(x)) {
while (islist(x)) { h += sxhash(ccar(x)); x=ccdr(x);}}
else if (isvector(x)) {
s=vecsize(x);
switch( elmtypeof(x)) {
case ELM_BIT: s /= 8*sizeof(pointer); break;
case ELM_CHAR:
case ELM_BYTE: s /= sizeof(pointer); break;
case ELM_POINTER:
for (i=0; i<s; i++) h += sxhash(x->c.vec.v[i]);
return(h);}
for (i=0; i<s; i++) h += x->c.ivec.iv[i]; }
else { h=(eusinteger_t)x >> 2;}
return(h);}
pointer SXHASH(ctx,n,argv)
register context *ctx;
int n;
pointer argv[];
{ pointer h;
eusinteger_t m;
if (n==1) m=(eusinteger_t)1 << (WORD_SIZE-3);
else if (n==2) m=ckintval(argv[1]);
else error(E_MISMATCHARG);
#ifdef SPEC_DEBUG
printf( "SXHASH:" );
{ int i;
for( i = 0; i < n; i++ )
hoge_print_sub( argv[i] );
}
printf( "\n" );
#endif
m=(sxhash(argv[0]) & MAXPOSFIXNUM) % m;
return(makeint(m));}
/****************************************************************/
/* symbol attributes
/****************************************************************/
pointer SYMVALUE(ctx,n,argv)
register context *ctx;
int n;
register pointer argv[];
{ register pointer sy=argv[0],val;
ckarg(1);
if (!issymbol(sy)) error(E_NOSYMBOL);
val=speval(sy);
if (val==UNBOUND) error(E_UNBOUND,sy);
#ifdef SPEC_DEBUG
printf( "SYMVALUE:" );
{ int i;
for( i =0; i < n; i++ )
hoge_print_sub(argv[i] );
}
printf( "\n" );
#endif
return(val);}
pointer SYMBNDVALUE(ctx,n,argv)
register context *ctx;
int n;
register pointer argv[];
{ register pointer sy=argv[0],val;
ckarg(1);
if (!issymbol(sy)) error(E_NOSYMBOL);
val=SPEVALOF(sy);
if (val==UNBOUND) error(E_UNBOUND,sy);
return(val);}
pointer SETFUNC(ctx,n,argv)
register context *ctx;
int n;
register pointer *argv;
{ if (n!=2) error(E_MISMATCHARG);
if (!issymbol(argv[0])) error(E_NOSYMBOL);
#ifdef SPEC_DEBUG
printf( "SETFUNC:" ); hoge_print_sub(argv[0]); hoge_print(argv[1]);
#endif
setfunc(argv[0],argv[1]);
return(argv[1]);}
pointer SYMFUNC(ctx,n,argv)
register context *ctx;
int n;
pointer *argv;
{ ckarg(1);
if (!issymbol(argv[0])) error(E_NOSYMBOL);
#ifdef SPEC_DEBUG
printf( "SYMFUNC:" ); hoge_print( argv[0] );
#endif
return(getfunc(ctx,argv[0]));}
pointer MAKUNBOUND(ctx,n,argv)
register context *ctx;
int n;
pointer *argv;
{ ckarg(1);
if (!issymbol(argv[0])) error(E_NOSYMBOL);
#ifdef SPEC_DEBUG
printf( "MAKEUNBOUND:" ); hoge_print( argv[0] );
#endif
pointer_update(argv[0]->c.sym.speval,UNBOUND);
return(T);}
void set_special(ctx, var, val)
context *ctx;
pointer var, val;
{ pointer vt;
int x;
vt=var->c.sym.vtype;
if (vt==V_CONSTANT) error(E_SETCONST);
else if (vt==V_VARIABLE || vt==V_GLOBAL) {pointer_update(speval(var),val);}
else {
x=intval(vt);
pointer_update(ctx->specials->c.vec.v[x],val);} }
pointer SETSPECIAL(ctx,n,argv)
context *ctx;
int n;
pointer *argv;
{ pointer var, val;
ckarg(2);
var=argv[0]; val=argv[1];
if (!issymbol(var)) error(E_NOSYMBOL);
#ifdef SPEC_DEBUG
printf( "SETSPECIAL:" ); hoge_print_sub(var); hoge_print(val);
#endif
set_special(ctx, var, val);
return(val);}
pointer DEFUN(ctx,arg)
register context *ctx;
pointer arg;
{ pointer funcname;
extern pointer putprop();
#ifdef SPEC_DEBUG
printf( "DEFUN:" ); hoge_print( arg );
#endif
funcname=carof(arg,E_MISMATCHARG);
arg=ccdr(arg);
if (issymbol(funcname)) {pointer_update(funcname->c.sym.spefunc,cons(ctx,LAMBDA,arg));}
else error(E_NOSYMBOL);
putprop(ctx,funcname,
(isstring(ccar(ccdr(arg))))?(ccar(ccdr(arg))):(ccar(arg)),
K_FUNCTION_DOCUMENTATION);
return(funcname);}
pointer DEFMACRO(ctx,arg)
register context *ctx;
pointer arg;
{ pointer macname;
#ifdef SPEC_DEBUG
printf("DEFMACRO:" ); hoge_print(arg);
#endif
macname=carof(arg,E_MISMATCHARG);
arg=ccdr(arg);
if (issymbol(macname)) {pointer_update(macname->c.sym.spefunc,cons(ctx,MACRO,arg));}
else error(E_NOSYMBOL);
return(macname);}
pointer FINDSYMBOL(ctx,n,argv)
register context *ctx;
int n;
pointer argv[];
{ pointer str,sym,pkg;
ckarg2(1,2);
str=argv[0];
if (n==2) {
pkg=findpkg(argv[1]);
if (pkg==NULL) error(E_NOPACKAGE);}
else pkg=Spevalof(PACKAGE);
if (!ispackage(pkg)) error(E_NOPACKAGE);
if (!isstring(str)) error(E_NOSTRING);
#ifdef SPEC_DEBUG
printf( "FINDSYMBOL:" );
{ int i;
for( i = 0; i < n; i++ )
hoge_print_sub( argv[i] );
}
printf( "\n" );
#endif
sym=(pointer)findsymbol(str->c.str.chars,intval(str->c.str.length),
pkg->c.pkg.intsymvector,&n);
if (sym) return(sym);
else return(NIL);}
pointer INTERN(ctx,n,argv)
register context *ctx;
int n;
register pointer argv[];
{ register pointer str,sym,pkg;
int x;
ckarg2(1,3);
str=argv[0];
if (n>=2) pkg=findpkg(argv[1]);
else pkg=Spevalof(PACKAGE);
if (!isstring(str)) error(E_NOSTRING);
#ifdef SPEC_DEBUG
printf( "INTERN:" );
{ int i;
for( i = 0; i < n; i++ )
hoge_print_sub( argv[i] );
}
printf( "\n" );
#endif
return((pointer)intern(ctx,(char *)str->c.str.chars, strlength(str),pkg));}
pointer gensym(ctx)
register context *ctx;
{ byte buf[64];
sprintf((char *)buf,"%s%d",genhead->c.str.chars,genindex++);
return(makesymbol(ctx,(char *)buf,strlen(buf),NIL));}
pointer GENSYM(ctx,n,argv)
register context *ctx;
int n;
pointer argv[];
{
#ifdef SPEC_DEBUG
printf( "GENSYM:" );
{ int i;
for( i =0 ; i<n; i++ )
hoge_print_sub(argv[i] );
}
printf( "\n" );
#endif
if (n==1) {
n--;
if (isstring(argv[0])) {
if (intval(argv[0]->c.str.length)>50) error(E_LONGSTRING);
genhead=argv[0];}
else if (isint(argv[0])) genindex=intval(argv[0]);
else error(E_NOSTRING);
}
ckarg(0);
return(gensym(ctx));}
pointer GETPROP(ctx,n,argv)
register context *ctx;
int n;
register pointer argv[];
{ register pointer p,attr=argv[1];
ckarg2(2,3);
if (!ispropobj(argv[0]) || !ispropobj(attr)) error(E_NOSYMBOL);
#ifdef SPEC_DEBUG
printf( "GETPROP:" );
{ int i;
for( i = 0; i < n; i++ )
hoge_print_sub(argv[i] );
}
printf( "\n" );
#endif
p=argv[0]->c.sym.plist;
while (iscons(p))
if (ccar(ccar(p))==attr) return(ccdr(ccar(p)));
else p=ccdr(p);
if (n==3) return(argv[2]); else return(NIL);}
pointer EXPORT (ctx,n,argv) /*further name conflict checks should be
performed by EusLisp*/
register context *ctx;
int n;
register pointer argv[];
{ pointer sym, pkg;
ckarg2(1,2);
#ifdef SPEC_DEBUG
printf( "EXPORT:" );
{ int i;
for( i =0; i< n; i++ )
hoge_print_sub(argv[i]);
}
printf( "\n" );
#endif
sym=argv[0];
if (n==2) pkg = findpkg(argv[1]);
else pkg=Spevalof(PACKAGE);
if (!ispackage(pkg)) error(E_NOPACKAGE);
if (issymbol(sym)) export(sym,pkg);
else if (iscons(sym))
while (iscons(sym)) {
export(ccar(sym),pkg); sym=ccdr(sym);}
else error(E_NOSYMBOL);
return(T);}
pointer putprop(ctx,sym,val,attr)
register context *ctx;
register pointer sym,val,attr;
{ register pointer p;
p=sym->c.sym.plist;
while (iscons(p))
if (ccar(ccar(p))==attr) { pointer_update(ccdr(ccar(p)),val); return(val);}
else p=ccdr(p);
/* no such a property; create it */
p=cons(ctx,attr,val);
pointer_update(sym->c.sym.plist,cons(ctx,p,sym->c.sym.plist));
return(val);}
pointer PUTPROP(ctx,n,argv) /*(putprop sym val attr)*/
register context *ctx;
int n;
register pointer argv[];
{ register pointer p,pp;
ckarg(3);
if (!ispropobj(argv[0]) || !ispropobj(argv[2])) error(E_NOSYMBOL);
#ifdef SPEC_DEBUG
printf( "PUTPROP:" );
{ int i;
for( i =0 ; i < n; i++ )
hoge_print_sub(argv[i]);
}
printf( "\n" );
#endif
return(putprop(ctx,argv[0],argv[1],argv[2]));}
#ifdef EVAL_DEBUG
pointer EVALDEBUG(ctx,n,argv)
register context *ctx;
int n;
register pointer argv[];
{
ckarg2(0,1);
if( n == 1 ) {
evaldebug = ( argv[0] != NIL );
}
return evaldebug ? T : NIL;
}
#endif
/****************************************************************/
/* initialize
/****************************************************************/
void specials(ctx,mod)
register context *ctx;
pointer mod;
{
genindex=0;
genhead=makestring("G",1);
sysobj=cons(ctx,genhead,sysobj);
QUOTE=defspecial(ctx,"QUOTE",mod,quote);
QEVAL=defun(ctx,"EVAL",mod,EVAL);
defun(ctx,"APPLY",mod,APPLY);
defun(ctx,"FUNCALL",mod,FUNCALL);
QPROGN=defspecial(ctx,"PROGN",mod,progn);
defun(ctx,"PROG1",mod,PROG1);
FUNCTION=defspecial(ctx,"FUNCTION",mod,FUNCTION_CLOSURE);
defun(ctx,"MAPC",mod,MAPC);
defun(ctx,"MAPCAR",mod,MAPCAR);
defun(ctx,"MAPCAN",mod,MAPCAN);
defspecial(ctx,"SETQ",mod,SETQ);
QIF=defspecial(ctx,"IF",mod,IF);
defmacro(ctx,"WHEN",mod,WHEN);
defspecial(ctx,"COND",mod,COND);
defspecial(ctx,"WHILE",mod,WHILE);
defspecial(ctx,"LET",mod,PARLET);
defspecial(ctx,"LET*",mod,SEQLET);
defspecial(ctx,"UNWIND-PROTECT",mod,UNWINDPROTECT);
defspecial(ctx,"CATCH",mod,CATCH);
defspecial(ctx,"THROW",mod,THROW);
defspecial(ctx,"FLET",mod,FLET);
defspecial(ctx,"LABELS",mod,LABELS);
defspecial(ctx,"BLOCK",mod,BLOCK);
QRETFROM=defspecial(ctx,"RETURN-FROM",mod,RETFROM);
defmacro(ctx,"RETURN",mod,RETURN);
defspecial(ctx,"TAGBODY",mod,TAGBODY);
defspecial(ctx,"GO",mod,GO);
defun(ctx,"RESET",mod,RESET);
defun(ctx,"EVALHOOK",mod,EVALHOOK);
defun(ctx,"MACROEXPAND2",mod,MACEXPAND2);
defspecial(ctx,"EVAL-WHEN",mod,EVALWHEN);
defspecial(ctx,"THE",mod,THE);
QAND=defspecial(ctx,"AND",mod,AND);
QOR=defspecial(ctx,"OR",mod,OR);
defun(ctx,"PROCLAIM",mod,PROCLAIM);
defspecial(ctx,"DECLARE",mod,DECLARE);
defun(ctx,"SETFUNC",mod,SETFUNC);
defun(ctx,"SYMBOL-VALUE",mod,SYMVALUE);
defun(ctx,"SYMBOL-BOUND-VALUE",mod,SYMBNDVALUE);
defun(ctx,"SYMBOL-FUNCTION",mod,SYMFUNC);
defun(ctx,"MAKUNBOUND",mod,MAKUNBOUND);
defun(ctx,"SET",mod,SETSPECIAL);
defspecial(ctx,"DEFUN",mod,DEFUN);
defspecial(ctx,"DEFMACRO",mod,DEFMACRO);
defun(ctx,"FIND-SYMBOL",mod,FINDSYMBOL);
defun(ctx,"INTERN",mod,INTERN);
defun(ctx,"GENSYM",mod,GENSYM);
defun(ctx,"LIST-ALL-PACKAGES",mod,ALLPACKAGES);
defun(ctx,"FIND-PACKAGE",mod,FINDPACKAGE);
defunpkg(ctx,"MAKEPACKAGE",mod,MAKEPACKAGE,syspkg);
/* defun(ctx,"IN-PACKAGE",mod,INPACKAGE); */
defun(ctx,"SXHASH",mod,SXHASH);
defun(ctx,"GET",mod,GETPROP);
defun(ctx,"EXPORT",mod,EXPORT);
defun(ctx,"PUTPROP",mod,PUTPROP);
#ifdef EVAL_DEBUG
defun(ctx,"EVALDEBUG",mod,EVALDEBUG);
#endif
}
| 25.792072 | 102 | 0.631858 |
bd2b3626ce45c445b1ea1c6c6df0aa078be39e8e | 1,978 | h | C | src/asn/rrc/ASN_RRC_RRCRelease.h | aligungr/ue-ran-sim | 564f9d228723f03adfa2b02df2ea019bdf305085 | [
"MIT"
] | 16 | 2020-04-16T02:07:37.000Z | 2020-07-23T10:48:27.000Z | src/asn/rrc/ASN_RRC_RRCRelease.h | aligungr/ue-ran-sim | 564f9d228723f03adfa2b02df2ea019bdf305085 | [
"MIT"
] | 8 | 2020-07-13T17:11:35.000Z | 2020-08-03T16:46:31.000Z | src/asn/rrc/ASN_RRC_RRCRelease.h | aligungr/ue-ran-sim | 564f9d228723f03adfa2b02df2ea019bdf305085 | [
"MIT"
] | 9 | 2020-03-04T15:05:08.000Z | 2020-07-30T06:18:18.000Z | /*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "NR-RRC-Definitions"
* found in "asn/nr-rrc-15.6.0.asn1"
* `asn1c -fcompound-names -pdu=all -findirect-choice -fno-include-deps -gen-PER -no-gen-OER -no-gen-example -D rrc`
*/
#ifndef _ASN_RRC_RRCRelease_H_
#define _ASN_RRC_RRCRelease_H_
#include <asn_application.h>
/* Including external dependencies */
#include "ASN_RRC_RRC-TransactionIdentifier.h"
#include <constr_SEQUENCE.h>
#include <constr_CHOICE.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Dependencies */
typedef enum ASN_RRC_RRCRelease__criticalExtensions_PR {
ASN_RRC_RRCRelease__criticalExtensions_PR_NOTHING, /* No components present */
ASN_RRC_RRCRelease__criticalExtensions_PR_rrcRelease,
ASN_RRC_RRCRelease__criticalExtensions_PR_criticalExtensionsFuture
} ASN_RRC_RRCRelease__criticalExtensions_PR;
/* Forward declarations */
struct ASN_RRC_RRCRelease_IEs;
/* ASN_RRC_RRCRelease */
typedef struct ASN_RRC_RRCRelease {
ASN_RRC_RRC_TransactionIdentifier_t rrc_TransactionIdentifier;
struct ASN_RRC_RRCRelease__criticalExtensions {
ASN_RRC_RRCRelease__criticalExtensions_PR present;
union ASN_RRC_RRCRelease__ASN_RRC_criticalExtensions_u {
struct ASN_RRC_RRCRelease_IEs *rrcRelease;
struct ASN_RRC_RRCRelease__criticalExtensions__criticalExtensionsFuture {
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} *criticalExtensionsFuture;
} choice;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} criticalExtensions;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} ASN_RRC_RRCRelease_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_ASN_RRC_RRCRelease;
extern asn_SEQUENCE_specifics_t asn_SPC_ASN_RRC_RRCRelease_specs_1;
extern asn_TYPE_member_t asn_MBR_ASN_RRC_RRCRelease_1[2];
#ifdef __cplusplus
}
#endif
#endif /* _ASN_RRC_RRCRelease_H_ */
#include <asn_internal.h>
| 29.969697 | 117 | 0.81092 |
aecfed52d81e99532d002bee62004859ec0b3096 | 4,255 | h | C | packrat/lib/x86_64-w64-mingw32/3.2.1/Rcpp/include/RcppCommon.h | Fredin/El-Habla-de-Monterrey | dd3333663bf5f66a751033166137109f03b39ac7 | [
"MIT"
] | 1 | 2016-05-18T18:44:18.000Z | 2016-05-18T18:44:18.000Z | packrat/lib/x86_64-w64-mingw32/3.2.1/Rcpp/include/RcppCommon.h | Fredin/El-Habla-de-Monterrey | dd3333663bf5f66a751033166137109f03b39ac7 | [
"MIT"
] | null | null | null | packrat/lib/x86_64-w64-mingw32/3.2.1/Rcpp/include/RcppCommon.h | Fredin/El-Habla-de-Monterrey | dd3333663bf5f66a751033166137109f03b39ac7 | [
"MIT"
] | null | null | null | // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
//
// RcppCommon.h: Rcpp R/C++ interface class library -- common include and defines statements
//
// Copyright (C) 2008 - 2009 Dirk Eddelbuettel
// Copyright (C) 2009 - 2015 Dirk Eddelbuettel and Romain Francois
//
// This file is part of Rcpp.
//
// Rcpp 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.
//
// Rcpp 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 Rcpp. If not, see <http://www.gnu.org/licenses/>.
#ifndef RcppCommon_h
#define RcppCommon_h
// #define RCPP_DEBUG_LEVEL 1
// #define RCPP_DEBUG_MODULE_LEVEL 1
#include <Rcpp/r/headers.h>
/**
* \brief Rcpp API
*/
namespace Rcpp {
/**
* \brief traits used to dispatch wrap
*/
namespace traits {
} // traits
/**
* \brief internal implementation details
*/
namespace internal {
} // internal
} // Rcpp
#include <iterator>
#include <exception>
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <stdexcept>
#include <vector>
#include <deque>
#include <functional>
#include <numeric>
#include <algorithm>
#include <complex>
#include <limits>
#include <typeinfo>
#include <Rcpp/sprintf.h>
#include <R_ext/Callbacks.h>
#include <R_ext/Visibility.h>
#include <Rcpp/utils/tinyformat.h>
#include <Rmath.h>
#include <Rcpp/sugar/undoRmath.h>
namespace Rcpp {
SEXP Rcpp_eval(SEXP expr_, SEXP env = R_GlobalEnv);
class Module;
namespace traits {
template <typename T> class named_object;
}
inline SEXP Rcpp_PreserveObject(SEXP x) {
if (x != R_NilValue) {
R_PreserveObject(x);
}
return x;
}
inline void Rcpp_ReleaseObject(SEXP x) {
if (x != R_NilValue) {
R_ReleaseObject(x);
}
}
inline SEXP Rcpp_ReplaceObject(SEXP x, SEXP y) {
if (Rf_isNull(x)) {
Rcpp_PreserveObject(y);
} else if (Rf_isNull(y)) {
Rcpp_ReleaseObject(x);
} else {
// if we are setting to the same SEXP as we already have, do nothing
if (x != y) {
// the previous SEXP was not NULL, so release it
Rcpp_ReleaseObject(x);
// the new SEXP is not NULL, so preserve it
Rcpp_PreserveObject(y);
}
}
return y;
}
}
#include <Rcpp/storage/storage.h>
#include <Rcpp/protection/protection.h>
#include <Rcpp/routines.h>
#include <Rcpp/exceptions.h>
#include <Rcpp/proxy/proxy.h>
#include <Rcpp/lang.h>
#include <Rcpp/complex.h>
#include <Rcpp/barrier.h>
#define RcppExport extern "C"
#include <Rcpp/exceptions.h>
#include <Rcpp/Interrupt.h>
namespace Rcpp {
template <typename T> class object;
class String;
namespace internal {
template <typename Class> SEXP make_new_object(Class* ptr);
}
}
#include <Rcpp/longlong.h>
#include <Rcpp/internal/na.h>
#include <Rcpp/internal/NAComparator.h>
#include <Rcpp/internal/NAEquals.h>
#include <Rcpp/traits/traits.h>
#include <Rcpp/Named.h>
#include <Rcpp/internal/caster.h>
#include <Rcpp/internal/r_vector.h>
#include <Rcpp/r_cast.h>
#include <Rcpp/api/bones/bones.h>
#include <Rcpp/internal/export.h>
#include <Rcpp/internal/r_coerce.h>
#include <Rcpp/as.h>
#include <Rcpp/InputParameter.h>
#include <Rcpp/is.h>
#include <Rcpp/vector/VectorBase.h>
#include <Rcpp/vector/MatrixBase.h>
#include <Rcpp/internal/ListInitialization.h>
#include <Rcpp/internal/Proxy_Iterator.h>
#include <Rcpp/internal/SEXP_Iterator.h>
#include <Rcpp/internal/converter.h>
#include <Rcpp/print.h>
#include <Rcpp/algo.h>
#include <Rcpp/sugar/sugar_forward.h>
#include <Rcpp/iostream/Rstreambuf.h>
#include <Rcpp/internal/wrap.h>
#endif
| 23.508287 | 92 | 0.66792 |
648634bb5b78fd0a03cf5b19dfa5a7db8f673c4a | 2,849 | h | C | PrivateFrameworks/HomeUI.framework/HUItemCollectionViewController.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | 36 | 2016-04-20T04:19:04.000Z | 2018-10-08T04:12:25.000Z | PrivateFrameworks/HomeUI.framework/HUItemCollectionViewController.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | null | null | null | PrivateFrameworks/HomeUI.framework/HUItemCollectionViewController.h | shaojiankui/iOS10-Runtime-Headers | 6b0d842bed0c52c2a7c1464087b3081af7e10c43 | [
"MIT"
] | 10 | 2016-06-16T02:40:44.000Z | 2019-01-15T03:31:45.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/PrivateFrameworks/HomeUI.framework/HomeUI
*/
@interface HUItemCollectionViewController : HUCollectionViewController <HFItemManagerDelegate, HUItemManagerContainer> {
NSHashTable * _childViewControllersAtViewWillAppearTime;
NSHashTable * _childViewControllersAtViewWillDisappearTime;
bool _hasFinishedInitialLoad;
HFItemManager * _itemManager;
}
@property (nonatomic, retain) NSHashTable *childViewControllersAtViewWillAppearTime;
@property (nonatomic, retain) NSHashTable *childViewControllersAtViewWillDisappearTime;
@property (readonly, copy) NSString *debugDescription;
@property (readonly, copy) NSString *description;
@property (nonatomic) bool hasFinishedInitialLoad;
@property (readonly) unsigned long long hash;
@property (nonatomic, retain) HFItemManager *itemManager;
@property (readonly) Class superclass;
+ (unsigned long long)updateMode;
- (void).cxx_destruct;
- (void)_updateTitle;
- (id)allCellClasses;
- (bool)automaticallyUpdatesViewControllerTitle;
- (Class)cellClassForItem:(id)arg1 indexPath:(id)arg2;
- (id)childViewControllersAtViewWillAppearTime;
- (id)childViewControllersAtViewWillDisappearTime;
- (id)collectionView:(id)arg1 cellForItemAtIndexPath:(id)arg2;
- (long long)collectionView:(id)arg1 numberOfItemsInSection:(long long)arg2;
- (void)configureCell:(id)arg1 forItem:(id)arg2;
- (bool)hasFinishedInitialLoad;
- (id)initWithItemManager:(id)arg1 collectionViewLayout:(id)arg2;
- (id)itemManager;
- (void)itemManager:(id)arg1 didChangeOverallLoadingState:(unsigned long long)arg2;
- (void)itemManager:(id)arg1 didInsertItem:(id)arg2 atIndexPath:(id)arg3;
- (void)itemManager:(id)arg1 didInsertSections:(id)arg2;
- (void)itemManager:(id)arg1 didMoveItem:(id)arg2 fromIndexPath:(id)arg3 toIndexPath:(id)arg4;
- (void)itemManager:(id)arg1 didMoveSection:(long long)arg2 toSection:(long long)arg3;
- (void)itemManager:(id)arg1 didRemoveItem:(id)arg2 atIndexPath:(id)arg3;
- (void)itemManager:(id)arg1 didRemoveSections:(id)arg2;
- (void)itemManager:(id)arg1 didUpdateResultsForItem:(id)arg2 atIndexPath:(id)arg3;
- (void)itemManager:(id)arg1 didUpdateResultsForSourceItem:(id)arg2;
- (bool)itemManager:(id)arg1 performBatchUpdateBlock:(id /* block */)arg2;
- (long long)numberOfSectionsInCollectionView:(id)arg1;
- (void)recursivelyDisableItemUpdates:(bool)arg1 withReason:(id)arg2;
- (void)setChildViewControllersAtViewWillAppearTime:(id)arg1;
- (void)setChildViewControllersAtViewWillDisappearTime:(id)arg1;
- (void)setHasFinishedInitialLoad:(bool)arg1;
- (void)setItemManager:(id)arg1;
- (bool)shouldAutomaticallyForwardAppearanceMethods;
- (void)viewDidAppear:(bool)arg1;
- (void)viewDidDisappear:(bool)arg1;
- (void)viewDidLayoutSubviews;
- (void)viewDidLoad;
- (void)viewWillAppear:(bool)arg1;
- (void)viewWillDisappear:(bool)arg1;
@end
| 46.704918 | 120 | 0.802738 |
311c5e67dbebb486341c577fcb214ff0e4587913 | 1,724 | h | C | perl/x2p/str.h | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | 46 | 2015-12-04T17:12:58.000Z | 2022-03-11T04:30:49.000Z | perl/x2p/str.h | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | null | null | null | perl/x2p/str.h | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | 23 | 2016-10-24T09:18:14.000Z | 2022-02-25T02:11:35.000Z | /* $RCSfile: str.h,v $$Revision: 4.1 $$Date: 92/08/07 18:29:27 $
*
* Copyright (c) 1991-2001, Larry Wall
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
*
* $Log: str.h,v $
*/
struct string {
char * str_ptr; /* pointer to malloced string */
double str_nval; /* numeric value, if any */
int str_len; /* allocated size */
int str_cur; /* length of str_ptr as a C string */
union {
STR *str_next; /* while free, link to next free str */
} str_link;
char str_pok; /* state of str_ptr */
char str_nok; /* state of str_nval */
};
#define Nullstr Null(STR*)
/* the following macro updates any magic values this str is associated with */
#define STABSET(x) (x->str_link.str_magic && stabset(x->str_link.str_magic,x))
EXT STR **tmps_list;
EXT long tmps_max INIT(-1);
double str_2num ( STR *str );
char * str_2ptr ( STR *str );
char * str_append_till ( STR *str, char *from, int delim, char *keeplist );
void str_cat ( STR *str, char *ptr );
void str_chop ( STR *str, char *ptr );
void str_dec ( STR *str );
void str_free ( STR *str );
char * str_gets ( STR *str, FILE *fp );
void str_grow ( STR *str, int len );
void str_inc ( STR *str );
int str_len ( STR *str );
STR * str_make ( char *s );
STR * str_mortal ( STR *oldstr );
void str_ncat ( STR *str, char *ptr, int len );
STR * str_new ( int len );
STR * str_nmake ( double n );
void str_nset ( STR *str, char *ptr, int len );
void str_numset ( STR *str, double num );
void str_replace ( STR *str, STR *nstr );
void str_scat ( STR *dstr, STR *sstr );
void str_set ( STR *str, char *ptr );
void str_sset ( STR *dstr, STR *sstr );
| 31.925926 | 78 | 0.647332 |
237920d45141e407800d88083492000995709ebd | 1,937 | h | C | src/samples_library.h | turgu1/PIano | ee8491db3dd89ade0d99ca445b83b98d9b357886 | [
"Unlicense"
] | null | null | null | src/samples_library.h | turgu1/PIano | ee8491db3dd89ade0d99ca445b83b98d9b357886 | [
"Unlicense"
] | null | null | null | src/samples_library.h | turgu1/PIano | ee8491db3dd89ade0d99ca445b83b98d9b357886 | [
"Unlicense"
] | null | null | null | #include "copyright.h"
#ifndef SAMPLES_H
#define SAMPLES_H
#include "sample.h"
// Music Velocity Midi equivalencies
//
// ppp: 16 Piano Pianissimo
// pp: 32 Pianissimo
// p: 48 Piano
// mp: 64 Mezzo-piano
// mf: 80 Mezzo-forte
// f: 96 forte
// ff: 112 fortissimo
// fff: 127 forte fortissimo
//
/// Class SamplesLibrary is responsible of managing all samples that are part
/// of a library, insuring initial load of the first part of each sample data and
/// supplying the appropriate sample when a note to be played is requested by the
/// user. It maintains a vector of all potential notes (128 MIDI values) with, for
/// each note, the linked list of samples in the sort order of volume (or gain, or
/// attack level).
class SamplesLibrary : public NewHandlerSupport<SamplesLibrary> {
private:
samplep notes[128]; ///< Samples are linked to the appropriate note entry in this vector
void addToNotes(samplep sample); ///< Add a sample to a note
void clearDB(); ///< Clear the library
char * ext(char * fname); ///< Extract filename extension
static void outOfMemory(); ///< New operation handler when out of memory occurs
struct libStruct {
char * dirName;
struct libStruct * next;
} * libs;
struct libStruct * currentLib;
/// Load the library at location. This method uses the SndFile package to read
/// sample files into memory.
int loadLibrary(char * location);
public:
SamplesLibrary();
~SamplesLibrary();
void loadFirstLibrary();
void loadNextLibrary();
/// Returns the sample corresponding to the note and volume requested. Is a sample
/// is not available for the note, the sample for a lower closest note will be returned,
/// allowinf for further processing (scaling).
samplep getNote(char note, char volume);
/// Display the library structure to the user
void showNotes();
};
#endif
| 29.348485 | 90 | 0.68921 |
9ce7f3c0370d42035c1bdf949998eb523edefac2 | 183 | h | C | Wikipedia/Code/MWKHistoryEntry+WMFDatabaseStorable.h | the-sailor/wikipedia-ios | 1f8861fcedb0fbd273bfb497ef6e6b6c95ceab62 | [
"MIT"
] | null | null | null | Wikipedia/Code/MWKHistoryEntry+WMFDatabaseStorable.h | the-sailor/wikipedia-ios | 1f8861fcedb0fbd273bfb497ef6e6b6c95ceab62 | [
"MIT"
] | null | null | null | Wikipedia/Code/MWKHistoryEntry+WMFDatabaseStorable.h | the-sailor/wikipedia-ios | 1f8861fcedb0fbd273bfb497ef6e6b6c95ceab62 | [
"MIT"
] | 5 | 2016-10-11T20:06:21.000Z | 2019-07-17T17:43:17.000Z |
#import "MWKHistoryEntry.h"
#import "WMFDatabaseStorable.h"
@interface MWKHistoryEntry (WMFDatabaseStorable)<WMFDatabaseStorable>
+ (NSString*)databaseKeyForURL:(NSURL*)url;
@end
| 18.3 | 69 | 0.797814 |
23f29d0f5662fd3ced0377502333c78a5188e63a | 18,327 | h | C | games/godot/files/old_appkit_compat/AppKit/AppKit.h | davidlrichmond/macports-ports | c79eda419c3963c074e4e9ce31a95296636bd500 | [
"BSD-3-Clause"
] | 2 | 2020-06-24T16:31:10.000Z | 2022-02-27T15:11:44.000Z | games/godot/files/old_appkit_compat/AppKit/AppKit.h | davidlrichmond/macports-ports | c79eda419c3963c074e4e9ce31a95296636bd500 | [
"BSD-3-Clause"
] | 7 | 2019-07-04T06:44:06.000Z | 2020-11-15T14:19:38.000Z | games/godot/files/old_appkit_compat/AppKit/AppKit.h | davidlrichmond/macports-ports | c79eda419c3963c074e4e9ce31a95296636bd500 | [
"BSD-3-Clause"
] | 3 | 2019-08-29T20:51:42.000Z | 2019-08-29T21:12:51.000Z | /*
* Copyright (c) 2020 Jason Liu
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _MACPORTS_APPKIT_H_
#define _MACPORTS_APPKIT_H_
/*
* Compatibility mapping for old versions of AppKit. By using the
* mapping in this file, we can still compile newer versions of software
* using older versions of Mac OS X.
*
* Many AppKit enum constants were deprecated/renamed in macOS 10.12
* Sierra in order to make naming more consistent. The directives in
* this wrapper file replace the old enum names in the system AppKit
* header files with the new ones, so that code that has been written
* for newer versions of AppKit will still be able to be compiled on a
* system with a pre-10.12 AppKit SDK.
*
* References:
* * https://stackoverflow.com/a/44322273
* * https://lists.gnu.org/archive/html/emacs-devel/2016-08/msg00358.html
* * https://github.com/qemu/qemu/commit/4ba967ad7454c08d7e01b047d34d0c3d98f2a10d#diff-1fdc5419bda303ee3f720fb8ccdab2c3
* * https://patchwork.kernel.org/patch/9697563/
*
* Note that in the references cited above, the #define directives map
* the new enum names to the old names. This is because their directives
* are located in their own applications' source code files. However,
* our wrapper file performs the mapping in the opposite direction, and
* replaces the old enum names with the new names. This is because our
* file is patching the system AppKit header, instead of changing the
* application's source code to conform to an old system AppKit header.
*
* Also, note that our file only fixes the Objective-C header file. It
* does not affect the bridge metadata file (a.k.a. bridge support
* file), so any software that uses RubyCocoa or PyObjC to access AppKit
* will likely still be broken. This is despite the fact that gathering
* the list of enum names in our wrapper file was done by comparing the
* bridge metadata files taken from a macOS 10.11 and 10.12 machine,
* located at
* /System/Library/Frameworks/AppKit.framework/Resources/BridgeSupport/AppKit.bridgesupport
*
* Theoretically, you could use the 'gen_bridge_metadata' command to try
* to generate a new bridge support file, but this would only work if
* you went through and actually replaced the old enum names in ALL of
* AppKit's header files (not just AppKit.h, which is simply a top-level
* header that #includes a bunch of other headers), and our wrapper
* would not help in this regard. In addition, it's probably not a good
* idea to be using the 'gen_bridge_metadata' tool to replace the bridge
* support file in a system framework; it is really intended to be used
* by software authors who want to provide bridge support for RubyCocoa
* and PyObjC in frameworks generated by their own projects. In the
* future, if someone tries to create a MacPorts package for some piece
* of software that does use RubyCocoa or PyObjC to access AppKit, then
* a different sort of solution than this wrapper file may be needed for
* that scenario.
*
* References:
* * https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/RubyPythonCocoa/Articles/GenerateFrameworkMetadata.html
* * https://bugs.eclipse.org/bugs/show_bug.cgi?id=502090
* * Execute 'man gen_bridge_metadata' in a terminal window.
*/
/********************************************************************
* IMPORTANT NOTE *
* *
* This wrapper file is currently being used by a few ports: *
* Blender, MaterialX, and Godot. This file will eventually be *
* added to the MacPorts legacy support package. After it gets *
* added, we will be able to remove this file from the ports and *
* simply add the MacPorts legacy support package as a dependency *
* in the portfiles for Blender, MaterialX, and Godot. *
********************************************************************/
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200
/*
* Note: A small number of the #defines below are commented out because
* they cause compile errors when building Blender. MaterialX doesn't
* use them in its source, so they can be safely commented out without
* causing any ill effects.
*/
#define NS16BitBigEndianBitmapFormat NSBitmapFormatSixteenBitBigEndian
#define NS16BitLittleEndianBitmapFormat NSBitmapFormatSixteenBitLittleEndian
#define NS32BitBigEndianBitmapFormat NSBitmapFormatThirtyTwoBitBigEndian
#define NS32BitLittleEndianBitmapFormat NSBitmapFormatThirtyTwoBitLittleEndian
#define NSAlphaFirstBitmapFormat NSBitmapFormatAlphaFirst
#define NSAlphaNonpremultipliedBitmapFormat NSBitmapFormatAlphaNonpremultiplied
#define NSAlternateKeyMask NSEventModifierFlagOption
#define NSAnyEventMask NSEventMaskAny
#define NSAppKitDefined NSEventTypeAppKitDefined
#define NSAppKitDefinedMask NSEventMaskAppKitDefined
#define NSApplicationActivatedEventType NSEventSubtypeApplicationActivated
#define NSApplicationDeactivatedEventType NSEventSubtypeApplicationDeactivated
#define NSApplicationDefined NSEventTypeApplicationDefined
#define NSApplicationDefinedMask NSEventMaskApplicationDefined
#define NSBMPFileType NSBitmapImageFileTypeBMP
#define NSBorderlessWindowMask NSWindowStyleMaskBorderless
#define NSCMYKColorSpaceModel NSColorSpaceModelCMYK
#define NSCMYKModeColorPanel NSColorPanelModeCMYK
/* #define NSCenterTextAlignment NSTextAlignmentCenter */
#define NSCircularBezelStyle NSBezelStyleCircular
#define NSCircularSlider NSSliderTypeCircular
#define NSClosableWindowMask NSWindowStyleMaskClosable
#define NSColorListModeColorPanel NSColorPanelModeColorList
#define NSCommandKeyMask NSEventModifierFlagCommand
#define NSCompositeClear NSCompositingOperationClear
#define NSCompositeCopy NSCompositingOperationCopy
#define NSCompositeDestinationAtop NSCompositingOperationDestinationAtop
#define NSCompositeDestinationIn NSCompositingOperationDestinationIn
#define NSCompositeDestinationOut NSCompositingOperationDestinationOut
#define NSCompositeDestinationOver NSCompositingOperationDestinationOver
#define NSCompositeHighlight NSCompositingOperationHighlight
#define NSCompositePlusDarker NSCompositingOperationPlusDarker
#define NSCompositeSourceAtop NSCompositingOperationSourceAtop
#define NSCompositeSourceIn NSCompositingOperationSourceIn
#define NSCompositeSourceOut NSCompositingOperationSourceOut
#define NSCompositeSourceOver NSCompositingOperationSourceOver
#define NSCompositeXOR NSCompositingOperationXOR
#define NSControlKeyMask NSEventModifierFlagControl
#define NSCrayonModeColorPanel NSColorPanelModeCrayon
#define NSCriticalAlertStyle NSAlertStyleCritical
#define NSCursorPointingDevice NSPointingDeviceTypeCursor
#define NSCursorUpdate NSEventTypeCursorUpdate
#define NSCursorUpdateMask NSEventMaskCursorUpdate
#define NSCustomPaletteModeColorPanel NSColorPanelModeCustomPalette
/* #define NSDefaultTokenStyle NSTokenStyleDefault */
#define NSDeviceIndependentModifierFlagsMask NSEventModifierFlagDeviceIndependentFlagsMask
#define NSDeviceNColorSpaceModel NSColorSpaceModelDeviceN
#define NSDisclosureBezelStyle NSBezelStyleDisclosure
#define NSDocModalWindowMask NSWindowStyleMaskDocModalWindow
#define NSEraserPointingDevice NSPointingDeviceTypeEraser
#define NSFlagsChanged NSEventTypeFlagsChanged
#define NSFlagsChangedMask NSEventMaskFlagsChanged
#define NSFloatingPointSamplesBitmapFormat NSBitmapFormatFloatingPointSamples
#define NSFullScreenWindowMask NSWindowStyleMaskFullScreen
#define NSFullSizeContentViewWindowMask NSWindowStyleMaskFullSizeContentView
#define NSFunctionKeyMask NSEventModifierFlagFunction
#define NSGIFFileType NSBitmapImageFileTypeGIF
#define NSGrayColorSpaceModel NSColorSpaceModelGray
#define NSGrayModeColorPanel NSColorPanelModeGray
#define NSHSBModeColorPanel NSColorPanelModeHSB
#define NSHUDWindowMask NSWindowStyleMaskHUDWindow
#define NSHelpButtonBezelStyle NSBezelStyleHelpButton
#define NSHelpKeyMask NSEventModifierFlagHelp
#define NSIndexedColorSpaceModel NSColorSpaceModelIndexed
#define NSInformationalAlertStyle NSAlertStyleInformational
#define NSInlineBezelStyle NSBezelStyleInline
#define NSJPEG2000FileType NSBitmapImageFileTypeJPEG2000
#define NSJPEGFileType NSBitmapImageFileTypeJPEG
/* #define NSJustifiedTextAlignment NSTextAlignmentJustified */
#define NSKeyDown NSEventTypeKeyDown
#define NSKeyDownMask NSEventMaskKeyDown
#define NSKeyUp NSEventTypeKeyUp
#define NSKeyUpMask NSEventMaskKeyUp
#define NSLABColorSpaceModel NSColorSpaceModelLAB
#define NSLeftMouseDown NSEventTypeLeftMouseDown
#define NSLeftMouseDownMask NSEventMaskLeftMouseDown
#define NSLeftMouseDragged NSEventTypeLeftMouseDragged
#define NSLeftMouseDraggedMask NSEventMaskLeftMouseDragged
#define NSLeftMouseUp NSEventTypeLeftMouseUp
#define NSLeftMouseUpMask NSEventMaskLeftMouseUp
/* #define NSLeftTextAlignment NSTextAlignmentLeft */
#define NSLinearSlider NSSliderTypeLinear
#define NSMiniControlSize NSControlSizeMini
#define NSMiniaturizableWindowMask NSWindowStyleMaskMiniaturizable
/* #define NSMomentaryPushButton NSMomentaryLightButton */
#define NSMouseEntered NSEventTypeMouseEntered
#define NSMouseEnteredMask NSEventMaskMouseEntered
#define NSMouseEventSubtype NSEventSubtypeMouseEvent
#define NSMouseExited NSEventTypeMouseExited
#define NSMouseExitedMask NSEventMaskMouseExited
#define NSMouseMoved NSEventTypeMouseMoved
#define NSMouseMovedMask NSEventMaskMouseMoved
/* #define NSNaturalTextAlignment NSTextAlignmentNatural */
#define NSNoModeColorPanel NSColorPanelModeNone
#define NSNonactivatingPanelMask NSWindowStyleMaskNonactivatingPanel
#define NSNumericPadKeyMask NSEventModifierFlagNumericPad
#define NSOpenGLCPCurrentRendererID NSOpenGLContextParameterCurrentRendererID
#define NSOpenGLCPGPUFragmentProcessing NSOpenGLContextParameterGPUFragmentProcessing
#define NSOpenGLCPGPUVertexProcessing NSOpenGLContextParameterGPUVertexProcessing
#define NSOpenGLCPHasDrawable NSOpenGLContextParameterHasDrawable
#define NSOpenGLCPMPSwapsInFlight NSOpenGLContextParameterMPSwapsInFlight
#define NSOpenGLCPRasterizationEnable NSOpenGLContextParameterRasterizationEnable
#define NSOpenGLCPReclaimResources NSOpenGLContextParameterReclaimResources
#define NSOpenGLCPStateValidation NSOpenGLContextParameterStateValidation
#define NSOpenGLCPSurfaceBackingSize NSOpenGLContextParameterSurfaceBackingSize
#define NSOpenGLCPSurfaceOpacity NSOpenGLContextParameterSurfaceOpacity
#define NSOpenGLCPSurfaceOrder NSOpenGLContextParameterSurfaceOrder
#define NSOpenGLCPSurfaceSurfaceVolatile NSOpenGLContextParameterSurfaceSurfaceVolatile
#define NSOpenGLCPSwapInterval NSOpenGLContextParameterSwapInterval
#define NSOpenGLCPSwapRectangle NSOpenGLContextParameterSwapRectangle
#define NSOpenGLCPSwapRectangleEnable NSOpenGLContextParameterSwapRectangleEnable
#define NSOtherMouseDown NSEventTypeOtherMouseDown
#define NSOtherMouseDownMask NSEventMaskOtherMouseDown
#define NSOtherMouseDragged NSEventTypeOtherMouseDragged
#define NSOtherMouseDraggedMask NSEventMaskOtherMouseDragged
#define NSOtherMouseUp NSEventTypeOtherMouseUp
#define NSOtherMouseUpMask NSEventMaskOtherMouseUp
#define NSPNGFileType NSBitmapImageFileTypePNG
#define NSPatternColorSpaceModel NSColorSpaceModelPatterned
#define NSPenLowerSideMask NSEventButtonMaskPenLowerSide
#define NSPenPointingDevice NSPointingDeviceTypePen
#define NSPenTipMask NSEventButtonMaskPenTip
#define NSPenUpperSideMask NSEventButtonMaskPenUpperSide
#define NSPeriodic NSEventTypePeriodic
#define NSPowerOffEventType NSEventSubtypePowerOff
#define NSRGBColorSpaceModel NSColorSpaceModelRGB
#define NSRGBModeColorPanel NSColorPanelModeRGB
#define NSRecessedBezelStyle NSBezelStyleRecessed
#define NSRegularControlSize NSControlSizeRegular
#define NSRegularSquareBezelStyle NSBezelStyleRegularSquare
#define NSResizableWindowMask NSWindowStyleMaskResizable
#define NSRightMouseDown NSEventTypeRightMouseDown
#define NSRightMouseDownMask NSEventMaskRightMouseDown
#define NSRightMouseDragged NSEventTypeRightMouseDragged
#define NSRightMouseDraggedMask NSEventMaskRightMouseDragged
#define NSRightMouseUp NSEventTypeRightMouseUp
#define NSRightMouseUpMask NSEventMaskRightMouseUp
/* #define NSRightTextAlignment NSTextAlignmentRight */
#define NSRoundRectBezelStyle NSBezelStyleRoundRect
#define NSRoundedBezelStyle NSBezelStyleRounded
#define NSRoundedDisclosureBezelStyle NSBezelStyleRoundedDisclosure
/* #define NSRoundedTokenStyle NSTokenStyleRounded */
#define NSScreenChangedEventType NSEventSubtypeScreenChanged
#define NSScrollWheel NSEventTypeScrollWheel
#define NSShadowlessSquareBezelStyle NSBezelStyleShadowlessSquare
#define NSShiftKeyMask NSEventModifierFlagShift
#define NSSmallControlSize NSControlSizeSmall
#define NSSmallSquareBezelStyle NSBezelStyleSmallSquare
#define NSSystemDefined NSEventTypeSystemDefined
#define NSSystemDefinedMask NSEventMaskSystemDefined
#define NSTIFFFileType NSBitmapImageFileTypeTIFF
#define NSTabletPoint NSEventTypeTabletPoint
#define NSTabletPointEventSubtype NSEventSubtypeTabletPoint
#define NSTabletPointMask NSEventMaskTabletPoint
#define NSTabletProximity NSEventTypeTabletProximity
#define NSTabletProximityEventSubtype NSEventSubtypeTabletProximity
#define NSTabletProximityMask NSEventMaskTabletProximity
#define NSTexturedBackgroundWindowMask NSWindowStyleMaskTexturedBackground
#define NSTexturedRoundedBezelStyle NSBezelStyleTexturedRounded
#define NSTexturedSquareBezelStyle NSBezelStyleTexturedSquare
#define NSTickMarkAbove NSTickMarkPositionAbove
#define NSTickMarkBelow NSTickMarkPositionBelow
#define NSTickMarkLeft NSTickMarkPositionLeading
#define NSTickMarkRight NSTickMarkPositionTrailing
#define NSTitledWindowMask NSWindowStyleMaskTitled
#define NSTouchEventSubtype NSEventSubtypeTouch
#define NSUnifiedTitleAndToolbarWindowMask NSWindowStyleMaskUnifiedTitleAndToolbar
#define NSUnknownColorSpaceModel NSColorSpaceModelUnknown
#define NSUnknownPointingDevice NSPointingDeviceTypeUnknown
#define NSUtilityWindowMask NSWindowStyleMaskUtilityWindow
#define NSWarningAlertStyle NSAlertStyleWarning
#define NSWheelModeColorPanel NSColorPanelModeWheel
#define NSWindowExposedEventType NSEventSubtypeWindowExposed
#define NSWindowMovedEventType NSEventSubtypeWindowMoved
/*
* New enum: NSWindowStyleMask is an enumerated type that was introduced
* starting in macOS 10.12; there is no pre-existing equivalent enum
* type in macOS 10.11 and earlier. However, since this enum's typedef
* is essentially equivalent to that of an unsigned integer, we can
* substitute NSUInteger in older versions of macOS and things should
* still work.
*
* Reference: https://developer.apple.com/documentation/appkit/nswindowstylemask
*/
#define NSWindowStyleMask NSUInteger
#endif /* __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200 */
/* Include the primary system AppKit.h */
#include_next <AppKit/AppKit.h>
#endif /* _MACPORTS_APPKIT_H_ */
| 63.415225 | 135 | 0.726633 |
9b4d92f67df756c1da13fc4bf50eca84e8574afe | 39,683 | h | C | Source/net_conn.h | jcdubois/uC-TCP-IP | 4828512b0fab6c9754eb4b18bb35725a0db1fa96 | [
"Apache-2.0"
] | 32 | 2020-03-03T07:26:42.000Z | 2020-12-08T14:37:08.000Z | Source/net_conn.h | jcdubois/uC-TCP-IP | 4828512b0fab6c9754eb4b18bb35725a0db1fa96 | [
"Apache-2.0"
] | 18 | 2021-04-27T14:48:31.000Z | 2022-03-15T04:59:26.000Z | Source/net_conn.h | jcdubois/uC-TCP-IP | 4828512b0fab6c9754eb4b18bb35725a0db1fa96 | [
"Apache-2.0"
] | 44 | 2020-03-03T05:32:16.000Z | 2020-12-07T18:19:35.000Z | /*
*********************************************************************************************************
* uC/TCP-IP
* The Embedded TCP/IP Suite
*
* Copyright 2004-2021 Silicon Laboratories Inc. www.silabs.com
*
* SPDX-License-Identifier: APACHE-2.0
*
* This software is subject to an open source license and is distributed by
* Silicon Laboratories Inc. pursuant to the terms of the Apache License,
* Version 2.0 available at www.apache.org/licenses/LICENSE-2.0.
*
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* NETWORK CONNECTION MANAGEMENT
*
* Filename : net_conn.h
* Version : V3.06.01
*********************************************************************************************************
* Note(s) : (1) Supports network connections for local & remote addresses of the following :
*
* (a) Families :
* (1) IPv4 Connections
* (A) BSD 4.x Sockets
*
* (b) Connection types :
* (1) Datagram
* (2) Stream
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*********************************************************************************************************
* MODULE
*********************************************************************************************************
*********************************************************************************************************
*/
#ifndef NET_CONN_MODULE_PRESENT
#define NET_CONN_MODULE_PRESENT
/*
*********************************************************************************************************
*********************************************************************************************************
* INCLUDE FILES
*********************************************************************************************************
*********************************************************************************************************
*/
#include "net_cfg_net.h"
#include "net_def.h"
#include "net_sock.h"
#include "net_type.h"
#include "net_err.h"
#include "net_stat.h"
#include <lib_def.h>
#include <cpu.h>
#include <cpu_core.h>
/*
*********************************************************************************************************
*********************************************************************************************************
* EXTERNS
*********************************************************************************************************
*********************************************************************************************************
*/
#ifdef NET_CONN_MODULE
#define NET_CONN_EXT
#else
#define NET_CONN_EXT extern
#endif
/*
*********************************************************************************************************
*********************************************************************************************************
* DEFINES
*********************************************************************************************************
*********************************************************************************************************
*/
#if (defined(NET_IPv6_MODULE_EN))
#define NET_CONN_ADDR_LEN_MAX NET_SOCK_ADDR_LEN_IP_V6
#elif (defined(NET_IPv4_MODULE_EN))
#define NET_CONN_ADDR_LEN_MAX NET_SOCK_ADDR_LEN_IP_V4
#else
#define NET_CONN_ADDR_LEN_MAX 0
#endif
#if (defined(NET_IPv4_MODULE_EN) && defined(NET_IPv6_MODULE_EN))
#define NET_CONN_PROTOCOL_IP_NBR_MAX 2
#else
#define NET_CONN_PROTOCOL_IP_NBR_MAX 1
#endif
#ifdef NET_TCP_MODULE_EN
#define NET_CONN_PROTOCOL_TRANSPORT_NBR_MAX 2
#else
#define NET_CONN_PROTOCOL_TRANSPORT_NBR_MAX 1
#endif
#define NET_CONN_PROTOCOL_NBR_MAX NET_CONN_PROTOCOL_TRANSPORT_NBR_MAX + NET_CONN_PROTOCOL_IP_NBR_MAX
#define NET_CONN_ACCESSED_TH_MIN 10
#define NET_CONN_ACCESSED_TH_MAX 65000
#define NET_CONN_ACCESSED_TH_DFLT 100
/*
*********************************************************************************************************
* NETWORK CONNECTION PROTOCOL INDEX DEFINES
*********************************************************************************************************
*/
#define NET_CONN_PROTOCOL_MAX_MIN NET_SOCK_PROTO_MAX_MIN
#define NET_CONN_PROTOCOL_IX_IP_V4_UDP 0
#define NET_CONN_PROTOCOL_IX_IP_V4_TCP 1
#ifdef NET_IPv4_MODULE_EN
#define NET_CONN_PROTOCOL_IX_OFFSET 2
#else
#define NET_CONN_PROTOCOL_IX_OFFSET 0
#endif
#define NET_CONN_PROTOCOL_IX_IP_V6_UDP 0 + NET_CONN_PROTOCOL_IX_OFFSET
#define NET_CONN_PROTOCOL_IX_IP_V6_TCP 1 + NET_CONN_PROTOCOL_IX_OFFSET
/*
*********************************************************************************************************
* NETWORK CONNECTION ADDRESS DEFINES
*********************************************************************************************************
*/
#define NET_CONN_ADDR_IP_LEN_PORT NET_SOCK_ADDR_IP_LEN_PORT
#define NET_CONN_ADDR_IP_IX_BASE NET_SOCK_ADDR_IP_IX_BASE
#define NET_CONN_ADDR_IP_IX_PORT NET_SOCK_ADDR_IP_IX_PORT
#ifdef NET_IPv4_MODULE_EN
#define NET_CONN_ADDR_IP_V4_IX_ADDR NET_SOCK_ADDR_IP_V4_IX_ADDR
#define NET_CONN_ADDR_IP_V4_LEN_ADDR NET_SOCK_ADDR_IP_V4_LEN_ADDR
#define NET_CONN_ADDR_IP_V4_WILDCARD NET_SOCK_ADDR_IP_V4_WILDCARD
#define NET_CONN_ADDR_IP_V4_BROADCAST NET_SOCK_ADDR_IP_V4_BROADCAST
#endif
#ifdef NET_IPv6_MODULE_EN
#define NET_CONN_ADDR_IP_V6_IX_ADDR NET_SOCK_ADDR_IP_V6_IX_ADDR
#define NET_CONN_ADDR_IP_V6_LEN_ADDR NET_SOCK_ADDR_IP_V6_LEN_ADDR
#define NET_CONN_ADDR_IP_V6_WILDCARD NET_SOCK_ADDR_IP_V6_WILDCARD
#endif
/*
*********************************************************************************************************
* NETWORK CONNECTION FLAG DEFINES
*********************************************************************************************************
*/
/* ------------------ NET CONN FLAGS ------------------ */
#define NET_CONN_FLAG_NONE DEF_BIT_NONE
#define NET_CONN_FLAG_USED DEF_BIT_00 /* Conn cur used; i.e. NOT in free conn pool. */
/*
*********************************************************************************************************
* NETWORK CONNECTION TYPE DEFINES
*********************************************************************************************************
*/
#define NET_CONN_TYPE_CONN_NONE 0u
#define NET_CONN_TYPE_CONN_HALF 1u
#define NET_CONN_TYPE_CONN_FULL 2u
/*
*********************************************************************************************************
*********************************************************************************************************
* DATA TYPES
*********************************************************************************************************
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* NETWORK CONNECTION FAMILY DATA TYPE
*********************************************************************************************************
*/
typedef CPU_INT08U NET_CONN_FAMILY;
/*
*********************************************************************************************************
* NETWORK CONNECTION LIST INDEX DATA TYPE
*
* Note(s) : (1) NET_CONN_PROTOCOL_IX_NONE SHOULD be #define'd based on 'NET_CONN_PROTOCOL_IX' data type
* declared.
*********************************************************************************************************
*/
typedef CPU_INT08U NET_CONN_PROTOCOL_IX;
#define NET_CONN_PROTOCOL_IX_NONE DEF_INT_08U_MAX_VAL /* Define as max unsigned val (see Note #1). */
/*
*********************************************************************************************************
* NETWORK CONNECTION ADDRESS LENGTH DATA TYPE
*********************************************************************************************************
*/
typedef CPU_INT16U NET_CONN_ADDR_LEN;
/*
*********************************************************************************************************
* NETWORK CONNECTION LIST QUANTITY DATA TYPE
*********************************************************************************************************
*/
typedef CPU_INT08U NET_CONN_LIST_QTY; /* Defines max qty of conn lists to support. */
/*
*********************************************************************************************************
* NETWORK CONNECTION QUANTITY DATA TYPE
*
* Note(s) : (1) See also 'NETWORK CONNECTION IDENTIFICATION DATA TYPE Note #2b'.
*********************************************************************************************************
*/
typedef CPU_INT16S NET_CONN_QTY; /* Defines max qty of conns to support. */
/*
*********************************************************************************************************
* NETWORK CONNECTION IDENTIFICATION DATA TYPE
*
* Note(s) : (1) 'NET_CONN_ID' pre-defined in 'net_type.h' PRIOR to all other network modules that require
* network connection data type.
*
* (2) (a) The following network connection values are pre-#define'd in 'net_cfg_net.h' PRIOR
* to 'net_conn.h' based on other modules' configuration values :
*
* (1) NET_CONN_NBR_MIN
*
* (b) (1) NET_CONN_NBR_MAX SHOULD be #define'd based on 'NET_CONN_QTY' data type declared.
*
* (2) However, since network connection handle identifiers are data-typed as 16-bit
* signed integers; the maximum number of valid network connection identifiers, &
* therefore the maximum number of valid network connections, is the total number
* of non-negative values that 16-bit signed integers support.
*********************************************************************************************************
*/
/* CFG CONN NBR THs */
/* See Note #4. */
#ifdef NET_TCP_MODULE_EN
#if (NET_TCP_NBR_CONN > NET_SOCK_NBR_SOCK)
#define NET_CONN_SOCK_TCP_NBR NET_SOCK_NBR_SOCK
#else
#define NET_CONN_SOCK_TCP_NBR NET_TCP_NBR_CONN
#endif
#else
#define NET_CONN_SOCK_TCP_NBR 0
#endif
#ifdef NET_TCP_MODULE_EN
#define NET_CONN_NBR_MIN (NET_SOCK_NBR_SOCK + \
NET_TCP_NBR_CONN - \
NET_SOCK_CFG_SOCK_NBR_TCP)
#else
#define NET_CONN_NBR_MIN NET_SOCK_NBR_SOCK
#endif
#ifndef NET_TCP_CFG_NBR_CONN
#define NET_TCP_CFG_NBR_CONN 0u
#endif
#ifndef NET_CONN_CFG_NBR_CONN
#define NET_CONN_NBR_CONN NET_SOCK_NBR_SOCK + NET_TCP_CFG_NBR_CONN + \
(NET_SOCK_CFG_SOCK_NBR_TCP * NET_SOCK_CFG_CONN_ACCEPT_Q_SIZE_MAX)
#else
#define NET_CONN_NBR_CONN NET_CONN_CFG_NBR_CONN
#endif
#if 0 /* See Note #1. */
typedef CPU_INT16S NET_CONN_ID;
#endif
#if 0 /* See Note #2a1. */
#define NET_CONN_NBR_MIN 1
#endif
#define NET_CONN_NBR_MAX DEF_INT_16S_MAX_VAL /* See Note #2b. */
#define NET_CONN_ID_MIN 0
#define NET_CONN_ID_MAX (NET_CONN_NBR_CONN - 1)
/*
*********************************************************************************************************
* NETWORK CONNECTION LIST INDEX DATA TYPE
*********************************************************************************************************
*/
typedef NET_CONN_QTY NET_CONN_LIST_IX;
#define NET_CONN_LIST_IX_NONE -1
#define NET_CONN_LIST_IX_MIN 0
#define NET_CONN_LIST_IX_MAX (NET_CONN_NBR_CONN - 1)
/*
*********************************************************************************************************
* NETWORK CONNECTION CLOSE CODE DATA TYPE
*********************************************************************************************************
*/
typedef CPU_INT08U NET_CONN_CLOSE_CODE;
#define NET_CONN_CLOSE_NONE 0u
#define NET_CONN_CLOSE_ALL 1u
#define NET_CONN_CLOSE_BY_IF 2u
#define NET_CONN_CLOSE_BY_ADDR 3u
#define NET_CONN_CLOSE_HALF 10u /* Conn closed to tx's; open to rx's. */
#define NET_CONN_CLOSE_FULL 11u
/*
*********************************************************************************************************
* NETWORK CONNECTION FLAGS DATA TYPE
*********************************************************************************************************
*/
typedef NET_FLAGS NET_CONN_FLAGS;
/*
*********************************************************************************************************
* NETWORK CONNECTION DATA TYPE
*
* NET_CONN
* |-------------|
* | Conn Type |
* Previous |-------------|
* Connection <----------O |
* Chain Lists |-------------| Next
* | O----------> Connection
* Previous |-------------| Chain Lists
* Connection <----------O |
* |-------------| Next
* | O----------> Connection
* |-------------|
* | O----------> Connection
* |-------------| List
* | Conn IDs |
* |-------------|
* | IF Nbr |
* |-------------|
* | Family |
* | Protocol |
* |-------------|
* | Local |
* | Address |
* |-------------|
* | Remote |
* | Address |
* |-------------|
* | Accessed |
* | Counters |
* |-------------|
* |IP Tx Params |
* |-------------|
* | Flags |
* |-------------|
*
*
* Note(s) : (1) (a) (1) RFC #1122, Section 4.1.4 states that "an application-layer program MUST be
* able to set the ... [IP] TOS ... for sending a ... datagram, [which] must
* be passed transparently to the IP layer".
*
* (2) RFC #1122, Section 4.2.4.2 reiterates that :
*
* (A) "The application layer MUST be able to specify the [IP] Type-of-Service
* (TOS) for [packets] that are sent on a connection."
*
* (B) "It not required [sic], but the application SHOULD be able to change the
* [IP] TOS during the connection lifetime."
*
* (b) (1) (A) RFC #1122, Section 4.1.4 states that "an application-layer program MUST
* be able to set the [IP] TTL ... for sending a ... datagram, [which] must
* be passed transparently to the IP layer".
*
* (B) RFC #1122, Section 4.2.2.19 reiterates that "the [IP] TTL value used to
* send ... [packets] MUST be configurable".
*
* (2) RFC #1112, Section 6.1 states that "the service interface should provide a
* way for the upper-layer protocol to specify the IP time-to-live of an outgoing
* multicast datagram".
*
* (c) (1) (A) RFC #1122, Section 4.1.4 states that "an application-layer program MUST
* be able to set the ... IP options for sending a ... datagram, [which] must
* be passed transparently to the IP layer".
*
* (B) RFC #1122, Section 4.1.3.2 reiterates that "an application MUST be able
* to specify IP options to be sent ... and ... MUST pass these options to
* the IP layer".
*
* (C) RFC #1122, Section 4.2.3.8 adds that :
*
* (1) "A TCP MAY support the [IP] Time Stamp and Record Route options."
*
* (2) "An application MUST be able to specify a [IP] source route when it
* ... opens a TCP connection, and this MUST take precedence over a
* source route received in a datagram."
*
* (2) IP transmit options currently NOT implemented See 'net_tcp.h Note #1d'
*********************************************************************************************************
*/
/* --------------------- NET CONN --------------------- */
typedef struct net_conn NET_CONN;
struct net_conn {
NET_CONN *PrevChainPtr; /* Ptr to PREV conn chain list. */
NET_CONN *NextChainPtr; /* Ptr to NEXT conn chain list. */
NET_CONN *PrevConnPtr; /* Ptr to PREV conn. */
NET_CONN *NextConnPtr; /* Ptr to NEXT conn. */
NET_CONN **ConnList; /* Conn list. */
NET_CONN_ID ID; /* Net conn id. */
NET_CONN_ID ID_App; /* App layer conn id. */
NET_CONN_ID ID_AppClone; /* App layer conn id clone. */
NET_CONN_ID ID_Transport; /* Transport layer conn id. */
NET_IF_NBR IF_Nbr; /* IF nbr. */
NET_CONN_FAMILY Family; /* Conn family. */
NET_CONN_PROTOCOL_IX ProtocolIx; /* Conn protocol ix. */
CPU_INT08U AddrLocal[NET_CONN_ADDR_LEN_MAX]; /* Conn local addr. */
CPU_BOOLEAN AddrLocalValid; /* Conn local addr valid flag. */
CPU_INT08U AddrRemote[NET_CONN_ADDR_LEN_MAX]; /* Conn remote addr. */
CPU_BOOLEAN AddrRemoteValid; /* Conn remote addr valid flag. */
CPU_INT16U ConnChainAccessedCtr; /* Nbr conn chain head accesses. */
CPU_INT16U ConnAccessedCtr; /* Nbr conn accesses (non-chain head). */
NET_CONN_FLAGS Flags; /* Conn flags. */
#ifdef NET_IPv4_MODULE_EN
NET_IPv4_FLAGS TxIPv4Flags; /* Conn tx IPv4 flags. */
NET_IPv4_TOS TxIPv4TOS; /* Conn tx IPv4 TOS (see Note #2a). */
NET_IPv4_TTL TxIPv4TTL; /* Conn tx IPv4 TTL (see Note #2b1). */
#ifdef NET_MCAST_TX_MODULE_EN
NET_IPv4_TTL TxIPv4TTL_Multicast; /* Conn tx IPv4 TTL multicast (see Note #2b2). */
#endif
#endif
#ifdef NET_IPv6_MODULE_EN
NET_IPv6_FLAGS TxIPv6Flags; /* Conn tx IPv6 flags. */
NET_IPv6_TRAFFIC_CLASS TxIPv6TrafficClass; /* Conn tx IPv6 traffic class. */
NET_IPv6_FLOW_LABEL TxIPv6FlowLabel; /* Conn tx IPv6 flow label. */
NET_IPv6_HOP_LIM TxIPv6HopLim; /* Conn tx IPv6 hop lim. */
#ifdef NET_MCAST_TX_MODULE_EN
NET_IPv6_HOP_LIM TxIPv6HopLimMulticast; /* Conn tx IPv6 TTL multicast (see Note #2b2). */
#endif
#endif
};
/*
*********************************************************************************************************
* GLOBAL VARIABLES
*********************************************************************************************************
*/
NET_CONN_EXT NET_CONN NetConn_Tbl[NET_CONN_NBR_CONN];
NET_CONN_EXT NET_CONN *NetConn_PoolPtr; /* Ptr to pool of free net conns. */
NET_CONN_EXT NET_STAT_POOL NetConn_PoolStat;
/* Array of ptrs to net conn lists. */
NET_CONN_EXT NET_CONN *NetConn_ConnListHead[NET_CONN_PROTOCOL_NBR_MAX];
NET_CONN_EXT NET_CONN *NetConn_ConnListChainPtr; /* Ptr to cur conn list chain to update. */
NET_CONN_EXT NET_CONN *NetConn_ConnListConnPtr; /* Ptr to cur conn list conn to update. */
NET_CONN_EXT NET_CONN *NetConn_ConnListNextChainPtr; /* Ptr to next conn list chain to update. */
NET_CONN_EXT NET_CONN *NetConn_ConnListNextConnPtr; /* Ptr to next conn list conn to update. */
NET_CONN_EXT CPU_INT16U NetConn_AccessedTh_nbr; /* Nbr successful srch's to promote net conns. */
/* Conn addr wildcard cfg. */
NET_CONN_EXT CPU_BOOLEAN NetConn_AddrWildCardAvailv4;
#ifdef NET_IPv4_MODULE_EN
NET_CONN_EXT CPU_INT08U NetConn_AddrWildCardv4[NET_CONN_ADDR_LEN_MAX];
#endif
NET_CONN_EXT CPU_BOOLEAN NetConn_AddrWildCardAvailv6;
#ifdef NET_IPv6_MODULE_EN
NET_CONN_EXT CPU_INT08U NetConn_AddrWildCardv6[NET_CONN_ADDR_LEN_MAX];
#endif
/*
*********************************************************************************************************
*********************************************************************************************************
* FUNCTION PROTOTYPES
*********************************************************************************************************
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* EXTERNAL C LANGUAGE LINKAGE
*
* Note(s) : (1) C++ compilers MUST 'extern'ally declare ALL C function prototypes & variable/object
* declarations for correct C language linkage.
*********************************************************************************************************
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
*********************************************************************************************************
* INTERNAL FUNCTIONS
*********************************************************************************************************
*/
void NetConn_Init (void);
/* ------------ CFG FNCTS ------------- */
CPU_BOOLEAN NetConn_CfgAccessedTh (CPU_INT16U nbr_access);
/* ---------- CONN API FNCTS ---------- */
NET_CONN_ID NetConn_Get (NET_CONN_FAMILY family,
NET_CONN_PROTOCOL_IX protocol_ix,
NET_ERR *p_err);
void NetConn_Free (NET_CONN_ID conn_id);
void NetConn_Copy (NET_CONN_ID conn_id_dest,
NET_CONN_ID conn_id_src);
void NetConn_CloseFromApp (NET_CONN_ID conn_id,
CPU_BOOLEAN close_conn_transport);
void NetConn_CloseFromTransport (NET_CONN_ID conn_id,
CPU_BOOLEAN close_conn_app);
void NetConn_CloseAllConns (void);
void NetConn_CloseAllConnsByIF (NET_IF_NBR if_nbr);
void NetConn_CloseAllConnsByAddr (CPU_INT08U *p_addr,
NET_CONN_ADDR_LEN addr_len);
void NetConn_CloseAllConnsByAddrHandler(CPU_INT08U *p_addr,
NET_CONN_ADDR_LEN addr_len);
NET_IF_NBR NetConn_IF_NbrGet (NET_CONN_ID conn_id,
NET_ERR *p_err);
NET_CONN_ID NetConn_ID_AppGet (NET_CONN_ID conn_id,
NET_ERR *p_err);
void NetConn_ID_AppSet (NET_CONN_ID conn_id,
NET_CONN_ID conn_id_app,
NET_ERR *p_err);
NET_CONN_ID NetConn_ID_AppCloneGet (NET_CONN_ID conn_id,
NET_ERR *p_err);
void NetConn_ID_AppCloneSet (NET_CONN_ID conn_id,
NET_CONN_ID conn_id_app,
NET_ERR *p_err);
NET_CONN_ID NetConn_ID_TransportGet (NET_CONN_ID conn_id,
NET_ERR *p_err);
void NetConn_ID_TransportSet (NET_CONN_ID conn_id,
NET_CONN_ID conn_id_transport,
NET_ERR *p_err);
void NetConn_AddrLocalGet (NET_CONN_ID conn_id,
CPU_INT08U *p_addr_local,
NET_CONN_ADDR_LEN *p_addr_len,
NET_ERR *p_err);
void NetConn_AddrLocalSet (NET_CONN_ID conn_id,
NET_IF_NBR if_nbr,
CPU_INT08U *p_addr_local,
NET_CONN_ADDR_LEN addr_len,
CPU_BOOLEAN addr_over_wr,
NET_ERR *p_err);
void NetConn_AddrRemoteGet (NET_CONN_ID conn_id,
CPU_INT08U *p_addr_remote,
NET_CONN_ADDR_LEN *p_addr_len,
NET_ERR *p_err);
void NetConn_AddrRemoteSet (NET_CONN_ID conn_id,
CPU_INT08U *p_addr_remote,
NET_CONN_ADDR_LEN addr_len,
CPU_BOOLEAN addr_over_wr,
NET_ERR *p_err);
CPU_BOOLEAN NetConn_AddrRemoteCmp (NET_CONN_ID conn_id,
CPU_INT08U *p_addr_remote,
NET_CONN_ADDR_LEN addr_len,
NET_ERR *p_err);
#ifdef NET_IPv4_MODULE_EN
void NetConn_IPv4TxParamsGet (NET_CONN_ID conn_id,
NET_IPv4_FLAGS *p_ip_flags,
NET_IPv4_TOS *p_ip_tos,
NET_IPv4_TTL *p_ip_ttl,
NET_ERR *p_err);
NET_IPv4_FLAGS NetConn_IPv4TxFlagsGet (NET_CONN_ID conn_id,
NET_ERR *p_err);
void NetConn_IPv4TxFlagsSet (NET_CONN_ID conn_id,
NET_IPv4_FLAGS ip_flags,
NET_ERR *p_err);
NET_IPv4_TOS NetConn_IPv4TxTOS_Get (NET_CONN_ID conn_id,
NET_ERR *p_err);
void NetConn_IPv4TxTOS_Set (NET_CONN_ID conn_id,
NET_IPv4_TOS ip_tos,
NET_ERR *p_err);
NET_IPv4_TTL NetConn_IPv4TxTTL_Get (NET_CONN_ID conn_id,
NET_ERR *p_err);
void NetConn_IPv4TxTTL_Set (NET_CONN_ID conn_id,
NET_IPv4_TTL ip_ttl,
NET_ERR *p_err);
#ifdef NET_MCAST_TX_MODULE_EN
NET_IPv4_TTL NetConn_IPv4TxTTL_MulticastGet (NET_CONN_ID conn_id,
NET_ERR *p_err);
void NetConn_IPv4TxTTL_MulticastSet (NET_CONN_ID conn_id,
NET_IPv4_TTL ip_ttl,
NET_ERR *p_err);
#endif
#endif
#ifdef NET_IPv6_MODULE_EN
void NetConn_IPv6TxParamsGet (NET_CONN_ID conn_id,
NET_IPv6_TRAFFIC_CLASS *p_ip_traffic_class,
NET_IPv6_FLOW_LABEL *p_ip_flow_label,
NET_IPv6_HOP_LIM *p_ip_hop_lim,
NET_IPv6_FLAGS *p_ip_flags,
NET_ERR *p_err);
#ifdef NET_MCAST_TX_MODULE_EN
NET_IPv6_HOP_LIM NetConn_IPv6TxHopLimMcastGet (NET_CONN_ID conn_id,
NET_ERR *p_err);
void NetConn_IPv6TxHopLimMcastSet (NET_CONN_ID conn_id,
NET_IPv6_HOP_LIM ip_hop_lim,
NET_ERR *p_err);
#endif
#endif
/* -------- CONN STATUS FNCTS --------- */
CPU_BOOLEAN NetConn_IsUsed (NET_CONN_ID conn_id,
NET_ERR *p_err);
CPU_BOOLEAN NetConn_IsIPv6 (NET_CONN_ID conn_id,
NET_ERR *p_err);
CPU_BOOLEAN NetConn_IsPortUsed (NET_PORT_NBR port_nbr,
NET_PROTOCOL_TYPE protocol,
NET_ERR *p_err);
void NetConn_IsConn (NET_CONN_ID conn_id,
NET_ERR *p_err);
NET_STAT_POOL NetConn_PoolStatGet (void);
void NetConn_PoolStatResetMaxUsed (void);
/* --------- CONN LIST FNCTS ---------- */
NET_CONN_ID NetConn_Srch (NET_CONN_FAMILY family,
NET_CONN_PROTOCOL_IX protocol_ix,
CPU_INT08U *p_addr_local,
CPU_INT08U *p_addr_remote,
NET_CONN_ADDR_LEN addr_len,
NET_CONN_ID *p_conn_id_transport,
NET_CONN_ID *p_conn_id_app,
NET_ERR *p_err);
void NetConn_ListAdd (NET_CONN_ID conn_id,
NET_ERR *p_err);
void NetConn_ListUnlink (NET_CONN_ID conn_id,
NET_ERR *p_err);
/*
*********************************************************************************************************
* EXTERNAL C LANGUAGE LINKAGE END
*********************************************************************************************************
*/
#ifdef __cplusplus
}
#endif
/*
*********************************************************************************************************
*********************************************************************************************************
* CONFIGURATION ERRORS
*********************************************************************************************************
*********************************************************************************************************
*/
#ifndef NET_CONN_NBR_CONN
#error "NET_CONN_NBR_CONN not #define'd in 'net_cfg_net.h'"
#error " [MUST be >= NET_CONN_NBR_MIN] "
#error " [ && <= NET_CONN_NBR_MAX] "
#elif DEF_CHK_VAL(NET_CONN_NBR_CONN, \
NET_CONN_NBR_MIN, \
NET_CONN_NBR_MAX) != DEF_OK
#error "NET_CONN_NBR_CONN illegally #define'd in 'net_cfg.h'"
#error " [MUST be >= NET_CONN_NBR_MIN] "
#error " [ && <= NET_CONN_NBR_MAX] "
#endif
/*
*********************************************************************************************************
* MODULE END
*********************************************************************************************************
*/
#endif /* NET_CONN_MODULE_PRESENT */
| 48.690798 | 122 | 0.331653 |
bb0e4d5b470eb6967d35e841d0116c69babba8f3 | 1,423 | c | C | ch01-intro/exercises/ex01-17.c | ctasims/The-C-Programming-Language--Kernighan-and-Ritchie | 504cd6e41248635c7c2b19e8542d25c36177f651 | [
"MIT"
] | 9 | 2018-01-26T23:14:27.000Z | 2022-01-13T19:06:13.000Z | ch01-intro/exercises/ex01-17.c | ctasims/The-C-Programming-Language--Kernighan-and-Ritchie | 504cd6e41248635c7c2b19e8542d25c36177f651 | [
"MIT"
] | null | null | null | ch01-intro/exercises/ex01-17.c | ctasims/The-C-Programming-Language--Kernighan-and-Ritchie | 504cd6e41248635c7c2b19e8542d25c36177f651 | [
"MIT"
] | 4 | 2015-07-23T14:17:28.000Z | 2022-03-25T19:54:37.000Z | /*
* =====================================================================================
*
* Filename: ex01-17.c
*
* Description: Print all input lines longer than 80 characters
*
* Version: 1.0
* Created: 9/2/2013 9:44:14 PM
* Revision: none
* Compiler: gcc
*
* Author: Cianan A. Sims (), ctasims@gmail.com
* Organization:
*
* =====================================================================================
*/
#include <stdio.h>
#define MAXLINE 1000 /* maximum input line size. */
#define MINLEN 80 /* minimum required length for printing line */
int getline(char line[], int maxline);
/* Print longest input line */
main()
{
int len; /* current line length */
char line[MAXLINE]; /* current input line */
while ((len = getline(line, MAXLINE)) > 0)
if (len >= MINLEN) {
printf("%d: %s", len, line);
}
return 0;
}
/* getline: read a line into s, return length */
int getline(char s[], int lim)
{
int c, i;
/* get next char if it's not end of file or newline (check for overflow) */
for (i=0; i<lim-1 && (c=getchar()) != EOF && c!='\n'; ++i)
s[i] = c;
/* If newline, copy it and bump iter */
if (c == '\n') {
s[i] = c;
++i;
}
s[i] = '\0';
return i;
}
| 24.964912 | 89 | 0.430077 |
bb361bb8ab82cbe427b7fcaf5299b87e04c058f5 | 28,340 | c | C | release/src-rt/linux/linux-2.6/net/ipv4/netfilter/nf_nat_core.c | ghsecuritylab/tomato-sabai | 9027a38297d32e97dd386499cca4a583e25d1f9d | [
"Apache-2.0"
] | 278 | 2015-11-03T03:01:20.000Z | 2022-01-20T18:21:05.000Z | release/src-rt/linux/linux-2.6/net/ipv4/netfilter/nf_nat_core.c | kerpz/tomato | 60d3c74ab93d43d0e6a22f56f0876c0180c5c7d3 | [
"FSFAP"
] | 374 | 2015-11-03T12:37:22.000Z | 2021-12-17T14:18:08.000Z | release/src-rt/linux/linux-2.6/net/ipv4/netfilter/nf_nat_core.c | kerpz/tomato | 60d3c74ab93d43d0e6a22f56f0876c0180c5c7d3 | [
"FSFAP"
] | 96 | 2015-11-22T07:47:26.000Z | 2022-01-20T19:52:19.000Z | /* NAT for netfilter; shared with compatibility layer. */
/* (C) 1999-2001 Paul `Rusty' Russell
* (C) 2002-2006 Netfilter Core Team <coreteam@netfilter.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/types.h>
#include <linux/timer.h>
#include <linux/skbuff.h>
#include <linux/vmalloc.h>
#include <net/checksum.h>
#include <net/icmp.h>
#include <net/ip.h>
#include <net/tcp.h> /* For tcp_prot in getorigdst */
#include <linux/icmp.h>
#include <linux/udp.h>
#include <linux/jhash.h>
#include <linux/netfilter_ipv4.h>
#include <net/netfilter/nf_conntrack.h>
#include <net/netfilter/nf_conntrack_core.h>
#include <net/netfilter/nf_nat.h>
#include <net/netfilter/nf_nat_protocol.h>
#include <net/netfilter/nf_nat_core.h>
#include <net/netfilter/nf_nat_helper.h>
#include <net/netfilter/nf_conntrack_helper.h>
#include <net/netfilter/nf_conntrack_l3proto.h>
#include <net/netfilter/nf_conntrack_l4proto.h>
#include <linux/netfilter_ipv4/ipt_cone.h>
#ifdef HNDCTF
#include <linux/if.h>
#include <linux/if_vlan.h>
#include <typedefs.h>
#include <osl.h>
#include <ctf/hndctf.h>
#define NFC_CTF_ENABLED (1 << 31)
#endif /* HNDCTF */
#if 0
#define DEBUGP printk
#else
#define DEBUGP(format, args...)
#endif
static DEFINE_RWLOCK(nf_nat_lock);
static struct nf_conntrack_l3proto *l3proto = NULL;
/* Calculated at init based on memory size */
static unsigned int nf_nat_htable_size;
static struct list_head *bysource;
#define MAX_IP_NAT_PROTO 256
static struct nf_nat_protocol *nf_nat_protos[MAX_IP_NAT_PROTO];
static inline struct nf_nat_protocol *
__nf_nat_proto_find(u_int8_t protonum)
{
return rcu_dereference(nf_nat_protos[protonum]);
}
struct nf_nat_protocol *
nf_nat_proto_find_get(u_int8_t protonum)
{
struct nf_nat_protocol *p;
rcu_read_lock();
p = __nf_nat_proto_find(protonum);
if (!try_module_get(p->me))
p = &nf_nat_unknown_protocol;
rcu_read_unlock();
return p;
}
EXPORT_SYMBOL_GPL(nf_nat_proto_find_get);
void
nf_nat_proto_put(struct nf_nat_protocol *p)
{
module_put(p->me);
}
EXPORT_SYMBOL_GPL(nf_nat_proto_put);
/* We keep an extra hash for each conntrack, for fast searching. */
static inline unsigned int
hash_by_src(const struct nf_conntrack_tuple *tuple)
{
unsigned int hash;
/* Original src, to ensure we map it consistently if poss. */
hash = jhash_3words((__force u32)tuple->src.u3.ip,
(__force u32)tuple->src.u.all,
tuple->dst.protonum, 0);
return ((u64)hash * nf_nat_htable_size) >> 32;
}
#ifdef HNDCTF
extern int ipv4_conntrack_fastnat;
bool
ip_conntrack_is_ipc_allowed(struct sk_buff *skb, u_int32_t hooknum)
{
struct net_device *dev;
if (!ipv4_conntrack_fastnat || !CTF_ENAB(kcih))
return FALSE;
if (hooknum == NF_IP_PRE_ROUTING || hooknum == NF_IP_POST_ROUTING) {
dev = skb->dev;
if (dev->priv_flags & IFF_802_1Q_VLAN)
dev = VLAN_DEV_INFO(dev)->real_dev;
/* Add ipc entry if packet is received on ctf enabled interface
* and the packet is not a defrag'd one.
*/
if (ctf_isenabled(kcih, dev) && (skb->len <= dev->mtu))
skb->nfcache |= NFC_CTF_ENABLED;
}
/* Add the cache entries only if the device has registered and
* enabled ctf.
*/
if (skb->nfcache & NFC_CTF_ENABLED)
return TRUE;
return FALSE;
}
#ifdef CONFIG_BCM_NAT_MODULE
EXPORT_SYMBOL(ip_conntrack_is_ipc_allowed);
#endif
void
ip_conntrack_ipct_add(struct sk_buff *skb, u_int32_t hooknum,
struct nf_conn *ct, enum ip_conntrack_info ci,
struct nf_conntrack_tuple *manip)
{
ctf_ipc_t ipc_entry;
struct hh_cache *hh;
struct ethhdr *eth;
struct iphdr *iph;
struct tcphdr *tcph;
u_int32_t daddr;
struct rtable *rt;
struct nf_conn_help *help;
enum ip_conntrack_dir dir;
if ((skb == NULL) || (ct == NULL))
return;
/* Check CTF enabled */
if (!ip_conntrack_is_ipc_allowed(skb, hooknum))
return;
/* We only add cache entires for non-helper connections and at
* pre or post routing hooks.
*/
help = nfct_help(ct);
if ((help && help->helper) || (ct->ctf_flags & CTF_FLAGS_EXCLUDED) ||
((hooknum != NF_IP_PRE_ROUTING) && (hooknum != NF_IP_POST_ROUTING)))
return;
/* Add ipc entries for connections in established state only */
if ((ci != IP_CT_ESTABLISHED) && (ci != (IP_CT_ESTABLISHED+IP_CT_IS_REPLY)))
return;
iph = ip_hdr(skb);
if (iph->version != 4 ||
(iph->protocol != IPPROTO_TCP && iph->protocol != IPPROTO_UDP))
return;
if (iph->protocol == IPPROTO_TCP &&
ct->proto.tcp.state >= TCP_CONNTRACK_FIN_WAIT &&
ct->proto.tcp.state <= TCP_CONNTRACK_TIME_WAIT)
return;
dir = CTINFO2DIR(ci);
if (ct->ctf_flags & (1 << dir))
return;
/* Do route lookup for alias address if we are doing DNAT in this
* direction.
*/
daddr = iph->daddr;
if ((manip != NULL) && (HOOK2MANIP(hooknum) == IP_NAT_MANIP_DST))
daddr = manip->dst.u3.ip;
/* Find the destination interface */
if (skb->dst == NULL)
ip_route_input(skb, daddr, iph->saddr, iph->tos, skb->dev);
/* Ensure the packet belongs to a forwarding connection and it is
* destined to an unicast address.
*/
rt = (struct rtable *)skb->dst;
if ((rt == NULL) || (rt->u.dst.input != ip_forward) ||
(rt->rt_type != RTN_UNICAST) || (rt->u.dst.neighbour == NULL) ||
((rt->u.dst.neighbour->nud_state &
(NUD_PERMANENT|NUD_REACHABLE|NUD_STALE|NUD_DELAY|NUD_PROBE)) == 0))
return;
memset(&ipc_entry, 0, sizeof(ipc_entry));
/* Init the neighboring sender address */
memcpy(ipc_entry.sa.octet, eth_hdr(skb)->h_source, ETH_ALEN);
/* If the packet is received on a bridge device then save
* the bridge cache entry pointer in the ip cache entry.
* This will be referenced in the data path to update the
* live counter of brc entry whenever a received packet
* matches corresponding ipc entry matches.
*/
if ((skb->dev != NULL) && ctf_isbridge(kcih, skb->dev))
ipc_entry.brcp = ctf_brc_lkup(kcih, eth_hdr(skb)->h_source);
hh = skb->dst->hh;
if (hh != NULL) {
eth = (struct ethhdr *)(((unsigned char *)hh->hh_data) + 2);
memcpy(ipc_entry.dhost.octet, eth->h_dest, ETH_ALEN);
memcpy(ipc_entry.shost.octet, eth->h_source, ETH_ALEN);
} else {
memcpy(ipc_entry.dhost.octet, rt->u.dst.neighbour->ha, ETH_ALEN);
memcpy(ipc_entry.shost.octet, skb->dst->dev->dev_addr, ETH_ALEN);
}
tcph = ((struct tcphdr *)(((__u8 *)iph) + (iph->ihl << 2)));
/* Add ctf ipc entry for this direction */
ipc_entry.tuple.sip = iph->saddr;
ipc_entry.tuple.dip = iph->daddr;
ipc_entry.tuple.proto = iph->protocol;
ipc_entry.tuple.sp = tcph->source;
ipc_entry.tuple.dp = tcph->dest;
ipc_entry.next = NULL;
/* For vlan interfaces fill the vlan id and the tag/untag actions */
if (skb->dst->dev->priv_flags & IFF_802_1Q_VLAN) {
ipc_entry.txif = (void *)(VLAN_DEV_INFO(skb->dst->dev)->real_dev);
ipc_entry.vid = VLAN_DEV_INFO(skb->dst->dev)->vlan_id;
ipc_entry.action = ((VLAN_DEV_INFO(skb->dst->dev)->flags & 1) ?
CTF_ACTION_TAG : CTF_ACTION_UNTAG);
} else {
ipc_entry.txif = skb->dst->dev;
ipc_entry.action = CTF_ACTION_UNTAG;
}
/* Update the manip ip and port */
if (manip != NULL) {
if (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC) {
ipc_entry.nat.ip = manip->src.u3.ip;
ipc_entry.nat.port = manip->src.u.tcp.port;
ipc_entry.action |= CTF_ACTION_SNAT;
} else {
ipc_entry.nat.ip = manip->dst.u3.ip;
ipc_entry.nat.port = manip->dst.u.tcp.port;
ipc_entry.action |= CTF_ACTION_DNAT;
}
}
/* Do bridge cache lookup to determine outgoing interface
* and any vlan tagging actions if needed.
*/
if (ctf_isbridge(kcih, ipc_entry.txif)) {
ctf_brc_t *brcp;
brcp = ctf_brc_lkup(kcih, ipc_entry.dhost.octet);
if (brcp == NULL)
return;
else {
ipc_entry.action |= brcp->action;
ipc_entry.txif = brcp->txifp;
ipc_entry.vid = brcp->vid;
}
}
#ifdef DEBUG
printk("%s: Adding ipc entry for [%d]%u.%u.%u.%u:%u - %u.%u.%u.%u:%u\n", __FUNCTION__,
ipc_entry.tuple.proto,
NIPQUAD(ipc_entry.tuple.sip), ntohs(ipc_entry.tuple.sp),
NIPQUAD(ipc_entry.tuple.dip), ntohs(ipc_entry.tuple.dp));
printk("sa %02x:%02x:%02x:%02x:%02x:%02x\n",
ipc_entry.shost.octet[0], ipc_entry.shost.octet[1],
ipc_entry.shost.octet[2], ipc_entry.shost.octet[3],
ipc_entry.shost.octet[4], ipc_entry.shost.octet[5]);
printk("da %02x:%02x:%02x:%02x:%02x:%02x\n",
ipc_entry.dhost.octet[0], ipc_entry.dhost.octet[1],
ipc_entry.dhost.octet[2], ipc_entry.dhost.octet[3],
ipc_entry.dhost.octet[4], ipc_entry.dhost.octet[5]);
printk("[%d] vid: %d action %x\n", hooknum, ipc_entry.vid, ipc_entry.action);
if (manip != NULL)
printk("manip_ip: %u.%u.%u.%u manip_port %u\n",
NIPQUAD(ipc_entry.nat.ip), ntohs(ipc_entry.nat.port));
printk("txif: %s\n", ((struct net_device *)ipc_entry.txif)->name);
#endif
ctf_ipc_add(kcih, &ipc_entry);
/* Update the attributes flag to indicate a CTF conn */
ct->ctf_flags |= (CTF_FLAGS_CACHED | (1 << dir));
}
#ifdef CONFIG_BCM_NAT_MODULE
EXPORT_SYMBOL(ip_conntrack_ipct_add);
#endif
int
ip_conntrack_ipct_delete(struct nf_conn *ct, int ct_timeout)
{
ctf_ipc_t *ipct;
struct nf_conntrack_tuple *orig, *repl;
if (!CTF_ENAB(kcih))
return (0);
orig = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
if ((orig->dst.protonum != IPPROTO_TCP) && (orig->dst.protonum != IPPROTO_UDP))
return (0);
repl = &ct->tuplehash[IP_CT_DIR_REPLY].tuple;
/* If the refresh counter of ipc entry is non zero, it indicates
* that the packet transfer is active and we should not delete
* the conntrack entry.
*/
if (ct_timeout) {
ipct = ctf_ipc_lkup(kcih, orig->src.u3.ip, orig->dst.u3.ip,
orig->dst.protonum, orig->src.u.tcp.port,
orig->dst.u.tcp.port);
/* Postpone the deletion of ct entry if there are frames
* flowing in this direction.
*/
if ((ipct != NULL) && (ipct->live > 0)) {
ipct->live = 0;
ct->timeout.expires = jiffies + ct->expire_jiffies;
add_timer(&ct->timeout);
return (-1);
}
ipct = ctf_ipc_lkup(kcih, repl->src.u3.ip, repl->dst.u3.ip,
repl->dst.protonum, repl->src.u.tcp.port,
repl->dst.u.tcp.port);
if ((ipct != NULL) && (ipct->live > 0)) {
ipct->live = 0;
ct->timeout.expires = jiffies + ct->expire_jiffies;
add_timer(&ct->timeout);
return (-1);
}
}
/* If there are no packets over this connection for timeout period
* delete the entries.
*/
ctf_ipc_delete(kcih, orig->src.u3.ip, orig->dst.u3.ip, orig->dst.protonum,
orig->src.u.tcp.port, orig->dst.u.tcp.port);
ctf_ipc_delete(kcih, repl->src.u3.ip, repl->dst.u3.ip, repl->dst.protonum,
repl->src.u.tcp.port, repl->dst.u.tcp.port);
#ifdef DEBUG
printk("%s: Deleting the tuple %x %x %d %d %d\n",
__FUNCTION__, orig->src.u3.ip, orig->dst.u3.ip, orig->dst.protonum,
orig->src.u.tcp.port, orig->dst.u.tcp.port);
printk("%s: Deleting the tuple %x %x %d %d %d\n",
__FUNCTION__, repl->dst.u3.ip, repl->src.u3.ip, repl->dst.protonum,
repl->dst.u.tcp.port, repl->src.u.tcp.port);
#endif
return (0);
}
#endif /* HNDCTF */
/* Noone using conntrack by the time this called. */
static void nf_nat_cleanup_conntrack(struct nf_conn *conn)
{
struct nf_conn_nat *nat;
if (!(conn->status & IPS_NAT_DONE_MASK))
return;
nat = nfct_nat(conn);
write_lock_bh(&nf_nat_lock);
list_del(&nat->info.bysource);
write_unlock_bh(&nf_nat_lock);
/* Detach from cone list */
ipt_cone_cleanup_conntrack(nat);
}
/* Is this tuple already taken? (not by us) */
int
nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple,
const struct nf_conn *ignored_conntrack)
{
/* Conntrack tracking doesn't keep track of outgoing tuples; only
incoming ones. NAT means they don't have a fixed mapping,
so we invert the tuple and look for the incoming reply.
We could keep a separate hash if this proves too slow. */
struct nf_conntrack_tuple reply;
nf_ct_invert_tuplepr(&reply, tuple);
return nf_conntrack_tuple_taken(&reply, ignored_conntrack);
}
EXPORT_SYMBOL(nf_nat_used_tuple);
/* If we source map this tuple so reply looks like reply_tuple, will
* that meet the constraints of range. */
static int
in_range(const struct nf_conntrack_tuple *tuple,
const struct nf_nat_range *range)
{
struct nf_nat_protocol *proto;
int ret = 0;
/* If we are supposed to map IPs, then we must be in the
range specified, otherwise let this drag us onto a new src IP. */
if (range->flags & IP_NAT_RANGE_MAP_IPS) {
if (ntohl(tuple->src.u3.ip) < ntohl(range->min_ip) ||
ntohl(tuple->src.u3.ip) > ntohl(range->max_ip))
return 0;
}
rcu_read_lock();
proto = __nf_nat_proto_find(tuple->dst.protonum);
if (!(range->flags & IP_NAT_RANGE_PROTO_SPECIFIED) ||
proto->in_range(tuple, IP_NAT_MANIP_SRC,
&range->min, &range->max))
ret = 1;
rcu_read_unlock();
return ret;
}
static inline int
same_src(const struct nf_conn *ct,
const struct nf_conntrack_tuple *tuple)
{
const struct nf_conntrack_tuple *t;
t = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
return (t->dst.protonum == tuple->dst.protonum &&
t->src.u3.ip == tuple->src.u3.ip &&
t->src.u.all == tuple->src.u.all);
}
/* Only called for SRC manip */
static int
find_appropriate_src(const struct nf_conntrack_tuple *tuple,
struct nf_conntrack_tuple *result,
const struct nf_nat_range *range)
{
unsigned int h = hash_by_src(tuple);
struct nf_conn_nat *nat;
struct nf_conn *ct;
read_lock_bh(&nf_nat_lock);
list_for_each_entry(nat, &bysource[h], info.bysource) {
ct = (struct nf_conn *)((char *)nat - offsetof(struct nf_conn, data));
if (same_src(ct, tuple)) {
/* Copy source part from reply tuple. */
nf_ct_invert_tuplepr(result,
&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
result->dst = tuple->dst;
if (in_range(result, range)) {
read_unlock_bh(&nf_nat_lock);
return 1;
}
}
}
read_unlock_bh(&nf_nat_lock);
return 0;
}
/* For [FUTURE] fragmentation handling, we want the least-used
src-ip/dst-ip/proto triple. Fairness doesn't come into it. Thus
if the range specifies 1.2.3.4 ports 10000-10005 and 1.2.3.5 ports
1-65535, we don't do pro-rata allocation based on ports; we choose
the ip with the lowest src-ip/dst-ip/proto usage.
*/
static void
find_best_ips_proto(struct nf_conntrack_tuple *tuple,
const struct nf_nat_range *range,
const struct nf_conn *ct,
enum nf_nat_manip_type maniptype)
{
__be32 *var_ipp;
/* Host order */
u_int32_t minip, maxip, j;
/* No IP mapping? Do nothing. */
if (!(range->flags & IP_NAT_RANGE_MAP_IPS))
return;
if (maniptype == IP_NAT_MANIP_SRC)
var_ipp = &tuple->src.u3.ip;
else
var_ipp = &tuple->dst.u3.ip;
/* Fast path: only one choice. */
if (range->min_ip == range->max_ip) {
*var_ipp = range->min_ip;
return;
}
/* Hashing source and destination IPs gives a fairly even
* spread in practice (if there are a small number of IPs
* involved, there usually aren't that many connections
* anyway). The consistency means that servers see the same
* client coming from the same IP (some Internet Banking sites
* like this), even across reboots. */
minip = ntohl(range->min_ip);
maxip = ntohl(range->max_ip);
j = jhash_2words((__force u32)tuple->src.u3.ip,
(__force u32)tuple->dst.u3.ip, 0);
j = ((u64)j * (maxip - minip + 1)) >> 32;
*var_ipp = htonl(minip + j);
}
/* Manipulate the tuple into the range given. For NF_IP_POST_ROUTING,
* we change the source to map into the range. For NF_IP_PRE_ROUTING
* and NF_IP_LOCAL_OUT, we change the destination to map into the
* range. It might not be possible to get a unique tuple, but we try.
* At worst (or if we race), we will end up with a final duplicate in
* __ip_conntrack_confirm and drop the packet. */
static void
get_unique_tuple(struct nf_conntrack_tuple *tuple,
const struct nf_conntrack_tuple *orig_tuple,
const struct nf_nat_range *range,
struct nf_conn *ct,
enum nf_nat_manip_type maniptype)
{
struct nf_nat_protocol *proto;
/* 1) If this srcip/proto/src-proto-part is currently mapped,
and that same mapping gives a unique tuple within the given
range, use that.
This is only required for source (ie. NAT/masq) mappings.
So far, we don't do local source mappings, so multiple
manips not an issue. */
if (maniptype == IP_NAT_MANIP_SRC && !(range->flags & IP_NAT_RANGE_PROTO_RANDOM)) {
if (find_appropriate_src(orig_tuple, tuple, range)) {
DEBUGP("get_unique_tuple: Found current src map\n");
if (!nf_nat_used_tuple(tuple, ct))
return;
}
}
/* 2) Select the least-used IP/proto combination in the given
range. */
*tuple = *orig_tuple;
find_best_ips_proto(tuple, range, ct, maniptype);
/* 3) The per-protocol part of the manip is made to map into
the range to make a unique tuple. */
rcu_read_lock();
proto = __nf_nat_proto_find(orig_tuple->dst.protonum);
/* Only bother mapping if it's not already in range and unique */
if (!(range->flags & IP_NAT_RANGE_PROTO_RANDOM)) {
if (range->flags & IP_NAT_RANGE_PROTO_SPECIFIED) {
if (proto->in_range(tuple, maniptype, &range->min,
&range->max) &&
(range->min.all == range->max.all ||
!nf_nat_used_tuple(tuple, ct)))
goto out;
} else if (!nf_nat_used_tuple(tuple, ct)) {
goto out;
}
}
/* Last change: get protocol to try to obtain unique tuple. */
proto->unique_tuple(tuple, range, maniptype, ct);
out:
rcu_read_unlock();
}
unsigned int
nf_nat_setup_info(struct nf_conn *ct,
const struct nf_nat_range *range,
unsigned int hooknum)
{
struct nf_conntrack_tuple curr_tuple, new_tuple;
struct nf_conn_nat *nat = nfct_nat(ct);
struct nf_nat_info *info = &nat->info;
int have_to_hash = !(ct->status & IPS_NAT_DONE_MASK);
enum nf_nat_manip_type maniptype = HOOK2MANIP(hooknum);
NF_CT_ASSERT(hooknum == NF_IP_PRE_ROUTING ||
hooknum == NF_IP_POST_ROUTING ||
hooknum == NF_IP_LOCAL_IN ||
hooknum == NF_IP_LOCAL_OUT);
BUG_ON(nf_nat_initialized(ct, maniptype));
/* What we've got will look like inverse of reply. Normally
this is what is in the conntrack, except for prior
manipulations (future optimization: if num_manips == 0,
orig_tp =
conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple) */
nf_ct_invert_tuplepr(&curr_tuple,
&ct->tuplehash[IP_CT_DIR_REPLY].tuple);
get_unique_tuple(&new_tuple, &curr_tuple, range, ct, maniptype);
if (!nf_ct_tuple_equal(&new_tuple, &curr_tuple)) {
struct nf_conntrack_tuple reply;
/* Alter conntrack table so will recognize replies. */
nf_ct_invert_tuplepr(&reply, &new_tuple);
nf_conntrack_alter_reply(ct, &reply);
/* Non-atomic: we own this at the moment. */
if (maniptype == IP_NAT_MANIP_SRC)
ct->status |= IPS_SRC_NAT;
else
ct->status |= IPS_DST_NAT;
}
/* Place in source hash if this is the first time. */
if (have_to_hash) {
unsigned int srchash;
srchash = hash_by_src(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple);
write_lock_bh(&nf_nat_lock);
list_add(&info->bysource, &bysource[srchash]);
write_unlock_bh(&nf_nat_lock);
}
/* It's done. */
if (maniptype == IP_NAT_MANIP_DST)
set_bit(IPS_DST_NAT_DONE_BIT, &ct->status);
else
set_bit(IPS_SRC_NAT_DONE_BIT, &ct->status);
return NF_ACCEPT;
}
EXPORT_SYMBOL(nf_nat_setup_info);
/* Returns true if succeeded. */
static int
manip_pkt(u_int16_t proto,
struct sk_buff *skb,
unsigned int iphdroff,
const struct nf_conntrack_tuple *target,
enum nf_nat_manip_type maniptype)
{
struct iphdr *iph;
struct nf_nat_protocol *p;
if (!skb_make_writable(skb, iphdroff + sizeof(*iph)))
return 0;
iph = (void *)skb->data + iphdroff;
/* Manipulate protcol part. */
/* rcu_read_lock()ed by nf_hook_slow */
p = __nf_nat_proto_find(proto);
if (!p->manip_pkt(skb, iphdroff, target, maniptype))
return 0;
iph = (void *)skb->data + iphdroff;
if (maniptype == IP_NAT_MANIP_SRC) {
nf_csum_replace4(&iph->check, iph->saddr, target->src.u3.ip);
iph->saddr = target->src.u3.ip;
} else {
nf_csum_replace4(&iph->check, iph->daddr, target->dst.u3.ip);
iph->daddr = target->dst.u3.ip;
}
return 1;
}
#if defined(CONFIG_BCM_NAT) || defined(CONFIG_BCM_NAT_MODULE)
#ifndef CONFIG_BCM_NAT_MODULE
inline
#endif
int bcm_manip_pkt(u_int16_t proto,
struct sk_buff *skb,
unsigned int iphdroff,
const struct nf_conntrack_tuple *target,
enum nf_nat_manip_type maniptype)
{
return manip_pkt(proto, skb, iphdroff, target, maniptype);
}
#ifdef CONFIG_BCM_NAT_MODULE
EXPORT_SYMBOL(bcm_manip_pkt);
#endif
#endif
/* Do packet manipulations according to nf_nat_setup_info. */
unsigned int nf_nat_packet(struct nf_conn *ct,
enum ip_conntrack_info ctinfo,
unsigned int hooknum,
struct sk_buff *skb)
{
enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
unsigned long statusbit;
enum nf_nat_manip_type mtype = HOOK2MANIP(hooknum);
if (mtype == IP_NAT_MANIP_SRC)
statusbit = IPS_SRC_NAT;
else
statusbit = IPS_DST_NAT;
/* Invert if this is reply dir. */
if (dir == IP_CT_DIR_REPLY)
statusbit ^= IPS_NAT_MASK;
/* Non-atomic: these bits don't change. */
if (ct->status & statusbit) {
struct nf_conntrack_tuple target;
/* We are aiming to look like inverse of other direction. */
nf_ct_invert_tuplepr(&target, &ct->tuplehash[!dir].tuple);
#ifdef HNDCTF
ip_conntrack_ipct_add(skb, hooknum, ct, ctinfo, &target);
#endif /* HNDCTF */
if (!manip_pkt(target.dst.protonum, skb, 0, &target, mtype))
return NF_DROP;
} else {
#ifdef HNDCTF
#endif /* HNDCTF */
}
return NF_ACCEPT;
}
EXPORT_SYMBOL_GPL(nf_nat_packet);
/* Dir is direction ICMP is coming from (opposite to packet it contains) */
int nf_nat_icmp_reply_translation(struct nf_conn *ct,
enum ip_conntrack_info ctinfo,
unsigned int hooknum,
struct sk_buff *skb)
{
struct {
struct icmphdr icmp;
struct iphdr ip;
} *inside;
struct nf_conntrack_l4proto *l4proto;
struct nf_conntrack_tuple inner, target;
int hdrlen = ip_hdrlen(skb);
enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo);
unsigned long statusbit;
enum nf_nat_manip_type manip = HOOK2MANIP(hooknum);
if (!skb_make_writable(skb, hdrlen + sizeof(*inside)))
return 0;
inside = (void *)skb->data + hdrlen;
/* We're actually going to mangle it beyond trivial checksum
adjustment, so make sure the current checksum is correct. */
if (nf_ip_checksum(skb, hooknum, hdrlen, 0))
return 0;
/* Must be RELATED */
NF_CT_ASSERT(skb->nfctinfo == IP_CT_RELATED ||
skb->nfctinfo == IP_CT_RELATED+IP_CT_IS_REPLY);
/* Redirects on non-null nats must be dropped, else they'll
start talking to each other without our translation, and be
confused... --RR */
if (inside->icmp.type == ICMP_REDIRECT) {
/* If NAT isn't finished, assume it and drop. */
if ((ct->status & IPS_NAT_DONE_MASK) != IPS_NAT_DONE_MASK)
return 0;
if (ct->status & IPS_NAT_MASK)
return 0;
}
DEBUGP("icmp_reply_translation: translating error %p manp %u dir %s\n",
skb, manip, dir == IP_CT_DIR_ORIGINAL ? "ORIG" : "REPLY");
/* rcu_read_lock()ed by nf_hook_slow */
l4proto = __nf_ct_l4proto_find(PF_INET, inside->ip.protocol);
if (!nf_ct_get_tuple(skb, hdrlen + sizeof(struct icmphdr),
(hdrlen +
sizeof(struct icmphdr) + inside->ip.ihl * 4),
(u_int16_t)AF_INET, inside->ip.protocol,
&inner, l3proto, l4proto))
return 0;
/* Change inner back to look like incoming packet. We do the
opposite manip on this hook to normal, because it might not
pass all hooks (locally-generated ICMP). Consider incoming
packet: PREROUTING (DST manip), routing produces ICMP, goes
through POSTROUTING (which must correct the DST manip). */
if (!manip_pkt(inside->ip.protocol, skb, hdrlen + sizeof(inside->icmp),
&ct->tuplehash[!dir].tuple, !manip))
return 0;
if (skb->ip_summed != CHECKSUM_PARTIAL) {
/* Reloading "inside" here since manip_pkt inner. */
inside = (void *)skb->data + hdrlen;
inside->icmp.checksum = 0;
inside->icmp.checksum =
csum_fold(skb_checksum(skb, hdrlen,
skb->len - hdrlen, 0));
}
/* Change outer to look the reply to an incoming packet
* (proto 0 means don't invert per-proto part). */
if (manip == IP_NAT_MANIP_SRC)
statusbit = IPS_SRC_NAT;
else
statusbit = IPS_DST_NAT;
/* Invert if this is reply dir. */
if (dir == IP_CT_DIR_REPLY)
statusbit ^= IPS_NAT_MASK;
if (ct->status & statusbit) {
nf_ct_invert_tuplepr(&target, &ct->tuplehash[!dir].tuple);
if (!manip_pkt(0, skb, 0, &target, manip))
return 0;
}
return 1;
}
EXPORT_SYMBOL_GPL(nf_nat_icmp_reply_translation);
/* Protocol registration. */
int nf_nat_protocol_register(struct nf_nat_protocol *proto)
{
int ret = 0;
write_lock_bh(&nf_nat_lock);
if (nf_nat_protos[proto->protonum] != &nf_nat_unknown_protocol) {
ret = -EBUSY;
goto out;
}
rcu_assign_pointer(nf_nat_protos[proto->protonum], proto);
out:
write_unlock_bh(&nf_nat_lock);
return ret;
}
EXPORT_SYMBOL(nf_nat_protocol_register);
/* Noone stores the protocol anywhere; simply delete it. */
void nf_nat_protocol_unregister(struct nf_nat_protocol *proto)
{
write_lock_bh(&nf_nat_lock);
rcu_assign_pointer(nf_nat_protos[proto->protonum],
&nf_nat_unknown_protocol);
write_unlock_bh(&nf_nat_lock);
synchronize_rcu();
}
EXPORT_SYMBOL(nf_nat_protocol_unregister);
#if defined(CONFIG_NF_CT_NETLINK) || defined(CONFIG_NF_CT_NETLINK_MODULE)
int
nf_nat_port_range_to_nfattr(struct sk_buff *skb,
const struct nf_nat_range *range)
{
NFA_PUT(skb, CTA_PROTONAT_PORT_MIN, sizeof(__be16),
&range->min.tcp.port);
NFA_PUT(skb, CTA_PROTONAT_PORT_MAX, sizeof(__be16),
&range->max.tcp.port);
return 0;
nfattr_failure:
return -1;
}
EXPORT_SYMBOL_GPL(nf_nat_port_nfattr_to_range);
int
nf_nat_port_nfattr_to_range(struct nfattr *tb[], struct nf_nat_range *range)
{
int ret = 0;
/* we have to return whether we actually parsed something or not */
if (tb[CTA_PROTONAT_PORT_MIN-1]) {
ret = 1;
range->min.tcp.port =
*(__be16 *)NFA_DATA(tb[CTA_PROTONAT_PORT_MIN-1]);
}
if (!tb[CTA_PROTONAT_PORT_MAX-1]) {
if (ret)
range->max.tcp.port = range->min.tcp.port;
} else {
ret = 1;
range->max.tcp.port =
*(__be16 *)NFA_DATA(tb[CTA_PROTONAT_PORT_MAX-1]);
}
return ret;
}
EXPORT_SYMBOL_GPL(nf_nat_port_range_to_nfattr);
#endif
static int __init nf_nat_init(void)
{
size_t i;
/* Leave them the same for the moment. */
nf_nat_htable_size = nf_conntrack_htable_size;
/* One vmalloc for both hash tables */
bysource = vmalloc(sizeof(struct list_head) * nf_nat_htable_size);
if (!bysource)
return -ENOMEM;
/* Sew in builtin protocols. */
write_lock_bh(&nf_nat_lock);
for (i = 0; i < MAX_IP_NAT_PROTO; i++)
rcu_assign_pointer(nf_nat_protos[i], &nf_nat_unknown_protocol);
rcu_assign_pointer(nf_nat_protos[IPPROTO_TCP], &nf_nat_protocol_tcp);
rcu_assign_pointer(nf_nat_protos[IPPROTO_UDP], &nf_nat_protocol_udp);
rcu_assign_pointer(nf_nat_protos[IPPROTO_ICMP], &nf_nat_protocol_icmp);
write_unlock_bh(&nf_nat_lock);
for (i = 0; i < nf_nat_htable_size; i++) {
INIT_LIST_HEAD(&bysource[i]);
}
/* FIXME: Man, this is a hack. <SIGH> */
NF_CT_ASSERT(rcu_dereference(nf_conntrack_destroyed) == NULL);
rcu_assign_pointer(nf_conntrack_destroyed, nf_nat_cleanup_conntrack);
NF_CT_ASSERT(rcu_dereference(nf_ct_nat_offset) == NULL);
rcu_assign_pointer(nf_ct_nat_offset, nf_nat_get_offset);
/* Initialize fake conntrack so that NAT will skip it */
nf_conntrack_untracked.status |= IPS_NAT_DONE_MASK;
l3proto = nf_ct_l3proto_find_get((u_int16_t)AF_INET);
return 0;
}
/* Clear NAT section of all conntracks, in case we're loaded again. */
static int clean_nat(struct nf_conn *i, void *data)
{
struct nf_conn_nat *nat = nfct_nat(i);
if (!nat)
return 0;
memset(nat, 0, sizeof(*nat));
i->status &= ~(IPS_NAT_MASK | IPS_NAT_DONE_MASK | IPS_SEQ_ADJUST);
return 0;
}
static void __exit nf_nat_cleanup(void)
{
nf_ct_iterate_cleanup(&clean_nat, NULL);
rcu_assign_pointer(nf_conntrack_destroyed, NULL);
rcu_assign_pointer(nf_ct_nat_offset, NULL);
synchronize_rcu();
vfree(bysource);
nf_ct_l3proto_put(l3proto);
}
MODULE_LICENSE("GPL");
module_init(nf_nat_init);
module_exit(nf_nat_cleanup);
| 29.066667 | 87 | 0.704799 |
120a72880a030ee49cdb4e21bcd86caa7e7e23cc | 184 | h | C | autogen/loaderscfg.h | fengjixuchui/napoca | ed26609ab9a3ea12d12882b311dcb332dc759d32 | [
"Apache-2.0"
] | 170 | 2020-07-30T15:04:59.000Z | 2022-03-24T10:59:29.000Z | autogen/loaderscfg.h | CrisanAndreiLiviu/napoca | 6b7bf01f37280c1d531002e999bb74dc858bac11 | [
"Apache-2.0"
] | 3 | 2020-08-10T09:16:56.000Z | 2022-02-18T21:40:43.000Z | autogen/loaderscfg.h | CrisanAndreiLiviu/napoca | 6b7bf01f37280c1d531002e999bb74dc858bac11 | [
"Apache-2.0"
] | 44 | 2020-07-30T15:06:55.000Z | 2022-02-25T08:55:55.000Z | #ifndef _LOADERSCFG_H_
#define _LOADERSCFG_H_
#define CFG_ALLOWEDRETRIES 3
#define CFG_BYPASSHV 0
#endif
| 18.4 | 59 | 0.483696 |
29d8a4ed79dc729783a6c5f1bb063eeae9cdcb73 | 2,115 | c | C | modules/theoraplayer/native/theoraplayer/src/YUV/libyuv/yuv_libyuv.c | DrCox85/monkey2Ex | 5f19ad01a200b9259a16371c3a37cc2cf6a92c95 | [
"Zlib"
] | 140 | 2016-03-13T03:01:25.000Z | 2022-02-06T09:47:04.000Z | modules/theoraplayer/native/theoraplayer/src/YUV/libyuv/yuv_libyuv.c | DrCox85/monkey2Ex | 5f19ad01a200b9259a16371c3a37cc2cf6a92c95 | [
"Zlib"
] | 469 | 2016-05-15T07:01:56.000Z | 2020-05-29T23:58:59.000Z | modules/theoraplayer/native/theoraplayer/src/YUV/libyuv/yuv_libyuv.c | DrCox85/monkey2Ex | 5f19ad01a200b9259a16371c3a37cc2cf6a92c95 | [
"Zlib"
] | 72 | 2016-03-13T10:17:54.000Z | 2020-02-24T05:40:02.000Z | /// @file
/// @version 2.0
///
/// @section LICENSE
///
/// This program is free software; you can redistribute it and/or modify it under
/// the terms of the BSD license: http://opensource.org/licenses/BSD-3-Clause
//***** Mark was here *****
#define _YUV_LIBYUV 1
#ifdef _YUV_LIBYUV
#include <libyuv.h>
#include "yuv_util.h"
#include "yuv_libyuv.h"
void decodeRGB(struct Theoraplayer_PixelTransform* t)
{
I420ToRAW(t->y, t->yStride, t->u, t->uStride, t->v, t->vStride, t->out, t->w * 3, t->w, t->h);
}
void decodeRGBA(struct Theoraplayer_PixelTransform* t)
{
I420ToABGR(t->y, t->yStride, t->u, t->uStride, t->v, t->vStride, t->out, t->w * 4, t->w, t->h);
_decodeAlpha(incOut(t, 3), t->w * 4);
}
void decodeRGBX(struct Theoraplayer_PixelTransform* t)
{
I420ToABGR(t->y, t->yStride, t->u, t->uStride, t->v, t->vStride, t->out, t->w * 4, t->w, t->h);
}
void decodeARGB(struct Theoraplayer_PixelTransform* t)
{
I420ToBGRA(t->y, t->yStride, t->u, t->uStride, t->v, t->vStride, t->out, t->w * 4, t->w, t->h);
_decodeAlpha(t, t->w * 4);
}
void decodeXRGB(struct Theoraplayer_PixelTransform* t)
{
I420ToBGRA(t->y, t->yStride, t->u, t->uStride, t->v, t->vStride, t->out, t->w * 4, t->w, t->h);
}
void decodeBGR(struct Theoraplayer_PixelTransform* t)
{
I420ToRGB24(t->y, t->yStride, t->u, t->uStride, t->v, t->vStride, t->out, t->w * 3, t->w, t->h);
}
void decodeBGRA(struct Theoraplayer_PixelTransform* t)
{
I420ToARGB(t->y, t->yStride, t->u, t->uStride, t->v, t->vStride, t->out, t->w * 4, t->w, t->h);
_decodeAlpha(incOut(t, 3), t->w * 4);
}
void decodeBGRX(struct Theoraplayer_PixelTransform* t)
{
I420ToARGB(t->y, t->yStride, t->u, t->uStride, t->v, t->vStride, t->out, t->w * 4, t->w, t->h);
}
void decodeABGR(struct Theoraplayer_PixelTransform* t)
{
I420ToRGBA(t->y, t->yStride, t->u, t->uStride, t->v, t->vStride, t->out, t->w * 4, t->w, t->h);
_decodeAlpha(t, t->w * 4);
}
void decodeXBGR(struct Theoraplayer_PixelTransform* t)
{
I420ToRGBA(t->y, t->yStride, t->u, t->uStride, t->v, t->vStride, t->out, t->w * 4, t->w, t->h);
}
void initYUVConversionModule()
{
}
#endif
| 27.115385 | 99 | 0.633097 |
15e1e599580a113d73d43845a34072290ee80abc | 31,135 | h | C | ROMS/Nonlinear/t3dmix4_iso.h | hadfieldnz/roms-trunk-mgh | 3667befc1c79e695fcfa8ddcbe1a5fb6a3aab4ea | [
"MIT"
] | 3 | 2018-02-22T04:54:31.000Z | 2021-05-20T12:30:44.000Z | ROMS/Nonlinear/t3dmix4_iso.h | hadfieldnz/roms-trunk-mgh | 3667befc1c79e695fcfa8ddcbe1a5fb6a3aab4ea | [
"MIT"
] | 1 | 2018-07-10T17:41:51.000Z | 2018-07-10T17:41:51.000Z | ROMS/Nonlinear/t3dmix4_iso.h | hadfieldnz/roms-trunk-mgh | 3667befc1c79e695fcfa8ddcbe1a5fb6a3aab4ea | [
"MIT"
] | null | null | null | SUBROUTINE t3dmix4 (ng, tile)
!
!svn $Id$
!***********************************************************************
! Copyright (c) 2002-2021 The ROMS/TOMS Group !
! Licensed under a MIT/X style license !
! See License_ROMS.txt Hernan G. Arango !
!****************************************** Alexander F. Shchepetkin ***
! !
! This subroutine computes horizontal biharmonic mixing of tracers !
! along isopycnic surfaces. !
! !
!***********************************************************************
!
USE mod_param
#ifdef TS_MIX_CLIMA
USE mod_clima
#endif
#ifdef DIAGNOSTICS_TS
USE mod_diags
#endif
USE mod_grid
USE mod_mixing
USE mod_ocean
USE mod_stepping
!
! Imported variable declarations.
!
integer, intent(in) :: ng, tile
!
! Local variable declarations.
!
character (len=*), parameter :: MyFile = &
& __FILE__
!
#include "tile.h"
!
#ifdef PROFILE
CALL wclock_on (ng, iNLM, 29, __LINE__, MyFile)
#endif
CALL t3dmix4_tile (ng, tile, &
& LBi, UBi, LBj, UBj, &
& IminS, ImaxS, JminS, JmaxS, &
& nrhs(ng), nstp(ng), nnew(ng), &
#ifdef MASKING
& GRID(ng) % umask, &
& GRID(ng) % vmask, &
#endif
#ifdef WET_DRY
& GRID(ng) % umask_wet, &
& GRID(ng) % vmask_wet, &
#endif
& GRID(ng) % om_v, &
& GRID(ng) % on_u, &
& GRID(ng) % pm, &
& GRID(ng) % pn, &
& GRID(ng) % Hz, &
& GRID(ng) % z_r, &
#ifdef DIFF_3DCOEF
# ifdef TS_U3ADV_SPLIT
& MIXING(ng) % diff3d_u, &
& MIXING(ng) % diff3d_v, &
# else
& MIXING(ng) % diff3d_r, &
# endif
#else
& MIXING(ng) % diff4, &
#endif
& OCEAN(ng) % pden, &
#ifdef TS_MIX_CLIMA
& CLIMA(ng) % tclm, &
#endif
#ifdef DIAGNOSTICS_TS
& DIAGS(ng) % DiaTwrk, &
#endif
& OCEAN(ng) % t)
#ifdef PROFILE
CALL wclock_off (ng, iNLM, 29, __LINE__, MyFile)
#endif
!
RETURN
END SUBROUTINE t3dmix4
!
!***********************************************************************
SUBROUTINE t3dmix4_tile (ng, tile, &
& LBi, UBi, LBj, UBj, &
& IminS, ImaxS, JminS, JmaxS, &
& nrhs, nstp, nnew, &
#ifdef MASKING
& umask, vmask, &
#endif
#ifdef WET_DRY
& umask_wet, vmask_wet, &
#endif
& om_v, on_u, pm, pn, &
& Hz, z_r, &
#ifdef DIFF_3DCOEF
# ifdef TS_U3ADV_SPLIT
& diff3d_u, diff3d_v, &
# else
& diff3d_r, &
# endif
#else
& diff4, &
#endif
& pden, &
#ifdef TS_MIX_CLIMA
& tclm, &
#endif
#ifdef DIAGNOSTICS_TS
& DiaTwrk, &
#endif
& t)
!***********************************************************************
!
USE mod_param
USE mod_ncparam
USE mod_scalars
!
! Imported variable declarations.
!
integer, intent(in) :: ng, tile
integer, intent(in) :: LBi, UBi, LBj, UBj
integer, intent(in) :: IminS, ImaxS, JminS, JmaxS
integer, intent(in) :: nrhs, nstp, nnew
#ifdef ASSUMED_SHAPE
# ifdef MASKING
real(r8), intent(in) :: umask(LBi:,LBj:)
real(r8), intent(in) :: vmask(LBi:,LBj:)
# endif
# ifdef WET_DRY
real(r8), intent(in) :: umask_wet(LBi:,LBj:)
real(r8), intent(in) :: vmask_wet(LBi:,LBj:)
# endif
# ifdef DIFF_3DCOEF
# ifdef TS_U3ADV_SPLIT
real(r8), intent(in) :: diff3d_u(LBi:,LBj:,:)
real(r8), intent(in) :: diff3d_v(LBi:,LBj:,:)
# else
real(r8), intent(in) :: diff3d_r(LBi:,LBj:,:)
# endif
# else
real(r8), intent(in) :: diff4(LBi:,LBj:,:)
# endif
real(r8), intent(in) :: om_v(LBi:,LBj:)
real(r8), intent(in) :: on_u(LBi:,LBj:)
real(r8), intent(in) :: pm(LBi:,LBj:)
real(r8), intent(in) :: pn(LBi:,LBj:)
real(r8), intent(in) :: Hz(LBi:,LBj:,:)
real(r8), intent(in) :: z_r(LBi:,LBj:,:)
real(r8), intent(in) :: pden(LBi:,LBj:,:)
# ifdef TS_MIX_CLIMA
real(r8), intent(in) :: tclm(LBi:,LBj:,:,:)
# endif
# ifdef DIAGNOSTICS_TS
real(r8), intent(inout) :: DiaTwrk(LBi:,LBj:,:,:,:)
# endif
real(r8), intent(inout) :: t(LBi:,LBj:,:,:,:)
#else
# ifdef MASKING
real(r8), intent(in) :: umask(LBi:UBi,LBj:UBj)
real(r8), intent(in) :: vmask(LBi:UBi,LBj:UBj)
# endif
# ifdef WET_DRY
real(r8), intent(in) :: umask_wet(LBi:UBi,LBj:UBj)
real(r8), intent(in) :: vmask_wet(LBi:UBi,LBj:UBj)
# endif
# ifdef DIFF_3DCOEF
# ifdef TS_U3ADV_SPLIT
real(r8), intent(in) :: diff3d_u(LBi:UBi,LBj:UBj,N(ng))
real(r8), intent(in) :: diff3d_v(LBi:UBi,LBj:UBj,N(ng))
# else
real(r8), intent(in) :: diff3d_r(LBi:UBi,LBj:UBj,N(ng))
# endif
# else
real(r8), intent(in) :: diff4(LBi:UBi,LBj:UBj,NT(ng))
# endif
real(r8), intent(in) :: om_v(LBi:UBi,LBj:UBj)
real(r8), intent(in) :: on_u(LBi:UBi,LBj:UBj)
real(r8), intent(in) :: pm(LBi:UBi,LBj:UBj)
real(r8), intent(in) :: pn(LBi:UBi,LBj:UBj)
real(r8), intent(in) :: Hz(LBi:UBi,LBj:UBj,N(ng))
real(r8), intent(in) :: z_r(LBi:UBi,LBj:UBj,N(ng))
real(r8), intent(in) :: pden(LBi:UBi,LBj:UBj,N(ng))
# ifdef TS_MIX_CLIMA
real(r8), intent(in) :: tclm(LBi:UBi,LBj:UBj,N(ng),NT(ng))
# endif
# ifdef DIAGNOSTICS_TS
real(r8), intent(inout) :: DiaTwrk(LBi:UBi,LBj:UBj,N(ng),NT(ng), &
& NDT)
# endif
real(r8), intent(inout) :: t(LBi:UBi,LBj:UBj,N(ng),3,NT(ng))
#endif
!
! Local variable declarations.
!
integer :: Imin, Imax, Jmin, Jmax
integer :: i, itrc, j, k, k1, k2
real(r8), parameter :: eps = 0.5_r8
real(r8), parameter :: small = 1.0E-14_r8
real(r8), parameter :: slope_max = 0.0001_r8
real(r8), parameter :: strat_min = 0.1_r8
real(r8) :: cff, cff1, cff2, cff3, cff4, dife, difx
real(r8), dimension(IminS:ImaxS,JminS:JmaxS,N(ng)) :: LapT
real(r8), dimension(IminS:ImaxS,JminS:JmaxS) :: FE
real(r8), dimension(IminS:ImaxS,JminS:JmaxS) :: FX
real(r8), dimension(IminS:ImaxS,JminS:JmaxS,2) :: FS
real(r8), dimension(IminS:ImaxS,JminS:JmaxS,2) :: dRde
real(r8), dimension(IminS:ImaxS,JminS:JmaxS,2) :: dRdx
real(r8), dimension(IminS:ImaxS,JminS:JmaxS,2) :: dTde
real(r8), dimension(IminS:ImaxS,JminS:JmaxS,2) :: dTdr
real(r8), dimension(IminS:ImaxS,JminS:JmaxS,2) :: dTdx
#include "set_bounds.h"
!
!-----------------------------------------------------------------------
! Compute horizontal biharmonic diffusion along isopycnic surfaces.
! The biharmonic operator is computed by applying the harmonic
! operator twice.
!-----------------------------------------------------------------------
!
! Set local I- and J-ranges.
!
IF (EWperiodic(ng)) THEN
Imin=Istr-1
Imax=Iend+1
ELSE
Imin=MAX(Istr-1,1)
Imax=MIN(Iend+1,Lm(ng))
END IF
IF (NSperiodic(ng)) THEN
Jmin=Jstr-1
Jmax=Jend+1
ELSE
Jmin=MAX(Jstr-1,1)
Jmax=MIN(Jend+1,Mm(ng))
END IF
!
! Compute horizontal and density gradients. Notice the recursive
! blocking sequence. The vertical placement of the gradients is:
!
! dTdx,dTde(:,:,k1) k rho-points
! dTdx,dTde(:,:,k2) k+1 rho-points
! FS,dTdr(:,:,k1) k-1/2 W-points
! FS,dTdr(:,:,k2) k+1/2 W-points
!
#ifdef TS_MIX_STABILITY
! In order to increase stability, the biharmonic operator is applied
! as: 3/4 t(:,:,:,nrhs,:) + 1/4 t(:,:,:,nstp,:).
!
#endif
T_LOOP : DO itrc=1,NT(ng)
k2=1
K_LOOP1 : DO k=0,N(ng)
k1=k2
k2=3-k1
IF (k.lt.N(ng)) THEN
DO j=Jmin,Jmax
DO i=Imin,Imax+1
cff=0.5_r8*(pm(i,j)+pm(i-1,j))
#ifdef MASKING
cff=cff*umask(i,j)
#endif
#ifdef WET_DRY
cff=cff*umask_wet(i,j)
#endif
dRdx(i,j,k2)=cff*(pden(i ,j,k+1)- &
& pden(i-1,j,k+1))
#if defined TS_MIX_STABILITY
dTdx(i,j,k2)=cff*(0.75_r8*(t(i ,j,k+1,nrhs,itrc)- &
& t(i-1,j,k+1,nrhs,itrc))+ &
& 0.25_r8*(t(i ,j,k+1,nstp,itrc)- &
& t(i-1,j,k+1,nstp,itrc)))
#elif defined TS_MIX_CLIMA
IF (LtracerCLM(itrc,ng)) THEN
dTdx(i,j,k2)=cff*((t(i ,j,k+1,nrhs,itrc)- &
& tclm(i ,j,k+1,itrc))- &
& (t(i-1,j,k+1,nrhs,itrc)- &
& tclm(i-1,j,k+1,itrc)))
ELSE
dTdx(i,j,k2)=cff*(t(i ,j,k+1,nrhs,itrc)- &
& t(i-1,j,k+1,nrhs,itrc))
END IF
#else
dTdx(i,j,k2)=cff*(t(i ,j,k+1,nrhs,itrc)- &
& t(i-1,j,k+1,nrhs,itrc))
#endif
END DO
END DO
DO j=Jmin,Jmax+1
DO i=Imin,Imax
cff=0.5_r8*(pn(i,j)+pn(i,j-1))
#ifdef MASKING
cff=cff*vmask(i,j)
#endif
#ifdef WET_DRY
cff=cff*vmask_wet(i,j)
#endif
dRde(i,j,k2)=cff*(pden(i,j ,k+1)- &
& pden(i,j-1,k+1))
#if defined TS_MIX_STABILITY
dTde(i,j,k2)=cff*(0.75_r8*(t(i,j ,k+1,nrhs,itrc)- &
& t(i,j-1,k+1,nrhs,itrc))+ &
& 0.25_r8*(t(i,j ,k+1,nstp,itrc)- &
& t(i,j-1,k+1,nstp,itrc)))
#elif defined TS_MIX_CLIMA
IF (LtracerCLM(itrc,ng)) THEN
dTde(i,j,k2)=cff*((t(i,j ,k+1,nrhs,itrc)- &
& tclm(i,j ,k+1,itrc))- &
& (t(i,j-1,k+1,nrhs,itrc)- &
& tclm(i,j-1,k+1,itrc)))
ELSE
dTde(i,j,k2)=cff*(t(i,j ,k+1,nrhs,itrc)- &
& t(i,j-1,k+1,nrhs,itrc))
END IF
#else
dTde(i,j,k2)=cff*(t(i,j ,k+1,nrhs,itrc)- &
& t(i,j-1,k+1,nrhs,itrc))
#endif
END DO
END DO
END IF
IF ((k.eq.0).or.(k.eq.N(ng))) THEN
DO j=Jmin-1,Jmax+1
DO i=Imin-1,Imax+1
dTdr(i,j,k2)=0.0_r8
FS(i,j,k2)=0.0_r8
END DO
END DO
ELSE
DO j=Jmin-1,Jmax+1
DO i=Imin-1,Imax+1
#if defined TS_MIX_MAX_SLOPE
cff1=SQRT(dRdx(i,j,k2)**2+dRdx(i+1,j,k2)**2+ &
& dRdx(i,j,k1)**2+dRdx(i+1,j,k1)**2+ &
& dRde(i,j,k2)**2+dRde(i,j+1,k2)**2+ &
& dRde(i,j,k1)**2+dRde(i,j+1,k1)**2)
cff2=0.25_r8*slope_max* &
& (z_r(i,j,k+1)-z_r(i,j,k))*cff1
cff3=MAX(pden(i,j,k)-pden(i,j,k+1),small)
cff4=MAX(cff2,cff3)
cff=-1.0_r8/cff4
#elif defined TS_MIX_MIN_STRAT
cff1=MAX(pden(i,j,k)-pden(i,j,k+1), &
& strat_min*(z_r(i,j,k+1)-z_r(i,j,k)))
cff=-1.0_r8/cff1
#else
cff1=MAX(pden(i,j,k)-pden(i,j,k+1),eps)
cff=-1.0_r8/cff1
#endif
#if defined TS_MIX_STABILITY
dTdr(i,j,k2)=cff*(0.75_r8*(t(i,j,k+1,nrhs,itrc)- &
& t(i,j,k ,nrhs,itrc))+ &
& 0.25_r8*(t(i,j,k+1,nstp,itrc)- &
& t(i,j,k ,nstp,itrc)))
#elif defined TS_MIX_CLIMA
IF (LtracerCLM(itrc,ng)) THEN
dTdr(i,j,k2)=cff*((t(i,j,k+1,nrhs,itrc)- &
& tclm(i,j,k+1,itrc))- &
& (t(i,j,k ,nrhs,itrc)- &
& tclm(i,j,k ,itrc)))
ELSE
dTdr(i,j,k2)=cff*(t(i,j,k+1,nrhs,itrc)- &
& t(i,j,k ,nrhs,itrc))
END IF
#else
dTdr(i,j,k2)=cff*(t(i,j,k+1,nrhs,itrc)- &
& t(i,j,k ,nrhs,itrc))
#endif
FS(i,j,k2)=cff*(z_r(i,j,k+1)- &
& z_r(i,j,k ))
END DO
END DO
END IF
IF (k.gt.0) THEN
DO j=Jmin,Jmax
DO i=Imin,Imax+1
#ifdef DIFF_3DCOEF
# ifdef TS_U3ADV_SPLIT
cff=0.5_r8*diff3d_u(i,j,k)*on_u(i,j)
# else
cff=0.25_r8*(diff3d_r(i,j,k)+diff3d_r(i-1,j,k))* &
& on_u(i,j)
# endif
#else
cff=0.25_r8*(diff4(i,j,itrc)+diff4(i-1,j,itrc))* &
& on_u(i,j)
#endif
FX(i,j)=cff* &
& (Hz(i,j,k)+Hz(i-1,j,k))* &
& (dTdx(i,j,k1)- &
& 0.5_r8*(MAX(dRdx(i,j,k1),0.0_r8)* &
& (dTdr(i-1,j,k1)+ &
& dTdr(i ,j,k2))+ &
& MIN(dRdx(i,j,k1),0.0_r8)* &
& (dTdr(i-1,j,k2)+ &
& dTdr(i ,j,k1))))
END DO
END DO
DO j=Jmin,Jmax+1
DO i=Imin,Imax
#ifdef DIFF_3DCOEF
# ifdef TS_U3ADV_SPLIT
cff=0.5_r8*diff3d_v(i,j,k)*om_v(i,j)
# else
cff=0.25_r8*(diff3d_r(i,j,k)+diff3d_r(i,j-1,k))* &
& om_v(i,j)
# endif
#else
cff=0.25_r8*(diff4(i,j,itrc)+diff4(i,j-1,itrc))* &
& om_v(i,j)
#endif
FE(i,j)=cff* &
& (Hz(i,j,k)+Hz(i,j-1,k))* &
& (dTde(i,j,k1)- &
& 0.5_r8*(MAX(dRde(i,j,k1),0.0_r8)* &
& (dTdr(i,j-1,k1)+ &
& dTdr(i,j ,k2))+ &
& MIN(dRde(i,j,k1),0.0_r8)* &
& (dTdr(i,j-1,k2)+ &
& dTdr(i,j ,k1))))
END DO
END DO
IF (k.lt.N(ng)) THEN
DO j=Jmin,Jmax
DO i=Imin,Imax
#ifdef DIFF_3DCOEF
# ifdef TS_U3ADV_SPLIT
difx=0.125_r8*(diff3d_u(i,j,k )+diff3d_u(i+1,j,k )+ &
& diff3d_u(i,j,k+1)+diff3d_u(i+1,j,k+1))
dife=0.125_r8*(diff3d_v(i,j,k )+diff3d_v(i,j+1,k )+ &
& diff3d_v(i,j,k+1)+diff3d_v(i,j+1,k+1))
# else
difx=0.5_r8*diff3d_r(i,j,k)
dife=difx
# endif
#else
difx=0.5_r8*diff4(i,j,itrc)
dife=difx
#endif
cff1=MAX(dRdx(i ,j,k1),0.0_r8)
cff2=MAX(dRdx(i+1,j,k2),0.0_r8)
cff3=MIN(dRdx(i ,j,k2),0.0_r8)
cff4=MIN(dRdx(i+1,j,k1),0.0_r8)
cff=difx* &
& (cff1*(cff1*dTdr(i,j,k2)-dTdx(i ,j,k1))+ &
& cff2*(cff2*dTdr(i,j,k2)-dTdx(i+1,j,k2))+ &
& cff3*(cff3*dTdr(i,j,k2)-dTdx(i ,j,k2))+ &
& cff4*(cff4*dTdr(i,j,k2)-dTdx(i+1,j,k1)))
!
cff1=MAX(dRde(i,j ,k1),0.0_r8)
cff2=MAX(dRde(i,j+1,k2),0.0_r8)
cff3=MIN(dRde(i,j ,k2),0.0_r8)
cff4=MIN(dRde(i,j+1,k1),0.0_r8)
cff=cff+ &
& dife* &
& (cff1*(cff1*dTdr(i,j,k2)-dTde(i,j ,k1))+ &
& cff2*(cff2*dTdr(i,j,k2)-dTde(i,j+1,k2))+ &
& cff3*(cff3*dTdr(i,j,k2)-dTde(i,j ,k2))+ &
& cff4*(cff4*dTdr(i,j,k2)-dTde(i,j+1,k1)))
FS(i,j,k2)=cff*FS(i,j,k2)
END DO
END DO
END IF
!
! Compute first harmonic operator, without mixing coefficient.
! Multiply by the metrics of the second harmonic operator. Save
! into work array "LapT".
!
DO j=Jmin,Jmax
DO i=Imin,Imax
cff=pm(i,j)*pn(i,j)
cff1=1.0_r8/Hz(i,j,k)
LapT(i,j,k)=cff1*(cff* &
& (FX(i+1,j)-FX(i,j)+ &
& FE(i,j+1)-FE(i,j))+ &
& (FS(i,j,k2)-FS(i,j,k1)))
END DO
END DO
END IF
END DO K_LOOP1
!
! Apply boundary conditions (except periodic; closed or gradient)
! to the first harmonic operator.
!
IF (.not.(CompositeGrid(iwest,ng).or.EWperiodic(ng))) THEN
IF (DOMAIN(ng)%Western_Edge(tile)) THEN
IF (LBC(iwest,isTvar(itrc),ng)%closed) THEN
DO k=1,N(ng)
DO j=Jmin,Jmax
LapT(Istr-1,j,k)=0.0_r8
END DO
END DO
ELSE
DO k=1,N(ng)
DO j=Jmin,Jmax
LapT(Istr-1,j,k)=LapT(Istr,j,k)
END DO
END DO
END IF
END IF
END IF
!
IF (.not.(CompositeGrid(ieast,ng).or.EWperiodic(ng))) THEN
IF (DOMAIN(ng)%Eastern_Edge(tile)) THEN
IF (LBC(ieast,isTvar(itrc),ng)%closed) THEN
DO k=1,N(ng)
DO j=Jmin,Jmax
LapT(Iend+1,j,k)=0.0_r8
END DO
END DO
ELSE
DO k=1,N(ng)
DO j=Jmin,Jmax
LapT(Iend+1,j,k)=LapT(Iend,j,k)
END DO
END DO
END IF
END IF
END IF
!
IF (.not.(CompositeGrid(isouth,ng).or.NSperiodic(ng))) THEN
IF (DOMAIN(ng)%Southern_Edge(tile)) THEN
IF (LBC(isouth,isTvar(itrc),ng)%closed) THEN
DO k=1,N(ng)
DO i=Imin,Imax
LapT(i,Jstr-1,k)=0.0_r8
END DO
END DO
ELSE
DO k=1,N(ng)
DO i=Imin,Imax
LapT(i,Jstr-1,k)=LapT(i,Jstr,k)
END DO
END DO
END IF
END IF
END IF
!
IF (.not.(CompositeGrid(inorth,ng).or.NSperiodic(ng))) THEN
IF (DOMAIN(ng)%Northern_Edge(tile)) THEN
IF (LBC(inorth,isTvar(itrc),ng)%closed) THEN
DO k=1,N(ng)
DO i=Imin,Imax
LapT(i,Jend+1,k)=0.0_r8
END DO
END DO
ELSE
DO k=1,N(ng)
DO i=Imin,Imax
LapT(i,Jend+1,k)=LapT(i,Jend,k)
END DO
END DO
END IF
END IF
END IF
!
IF (.not.(CompositeGrid(isouth,ng).or.NSperiodic(ng).or. &
& CompositeGrid(iwest ,ng).or.EWperiodic(ng))) THEN
IF (DOMAIN(ng)%SouthWest_Corner(tile)) THEN
DO k=1,N(ng)
LapT(Istr-1,Jstr-1,k)=0.5_r8* &
& (LapT(Istr ,Jstr-1,k)+ &
& LapT(Istr-1,Jstr ,k))
END DO
END IF
END IF
IF (.not.(CompositeGrid(isouth,ng).or.NSperiodic(ng).or. &
& CompositeGrid(ieast ,ng).or.EWperiodic(ng))) THEN
IF (DOMAIN(ng)%SouthEast_Corner(tile)) THEN
DO k=1,N(ng)
LapT(Iend+1,Jstr-1,k)=0.5_r8* &
& (LapT(Iend ,Jstr-1,k)+ &
& LapT(Iend+1,Jstr ,k))
END DO
END IF
END IF
IF (.not.(CompositeGrid(inorth,ng).or.NSperiodic(ng).or. &
& CompositeGrid(iwest ,ng).or.EWperiodic(ng))) THEN
IF (DOMAIN(ng)%NorthWest_Corner(tile)) THEN
DO k=1,N(ng)
LapT(Istr-1,Jend+1,k)=0.5_r8* &
& (LapT(Istr ,Jend+1,k)+ &
& LapT(Istr-1,Jend ,k))
END DO
END IF
END IF
IF (.not.(CompositeGrid(inorth,ng).or.NSperiodic(ng).or. &
& CompositeGrid(ieast ,ng).or.EWperiodic(ng))) THEN
IF (DOMAIN(ng)%NorthEast_Corner(tile)) THEN
DO k=1,N(ng)
LapT(Iend+1,Jend+1,k)=0.5_r8* &
& (LapT(Iend ,Jend+1,k)+ &
& LapT(Iend+1,Jend ,k))
END DO
END IF
END IF
!
! Compute horizontal and density gradients associated with the
! second rotated harmonic operator.
!
k2=1
K_LOOP2: DO k=0,N(ng)
k1=k2
k2=3-k1
IF (k.lt.N(ng)) THEN
DO j=Jstr,Jend
DO i=Istr,Iend+1
cff=0.5_r8*(pm(i,j)+pm(i-1,j))
#ifdef MASKING
cff=cff*umask(i,j)
#endif
#ifdef WET_DRY
cff=cff*umask_wet(i,j)
#endif
dRdx(i,j,k2)=cff*(pden(i ,j,k+1)- &
& pden(i-1,j,k+1))
dTdx(i,j,k2)=cff*(LapT(i ,j,k+1)- &
& LapT(i-1,j,k+1))
END DO
END DO
DO j=Jstr,Jend+1
DO i=Istr,Iend
cff=0.5_r8*(pn(i,j)+pn(i,j-1))
#ifdef MASKING
cff=cff*vmask(i,j)
#endif
#ifdef WET_DRY
cff=cff*vmask_wet(i,j)
#endif
dRde(i,j,k2)=cff*(pden(i,j ,k+1)- &
& pden(i,j-1,k+1))
dTde(i,j,k2)=cff*(LapT(i,j ,k+1)- &
& LapT(i,j-1,k+1))
END DO
END DO
END IF
IF ((k.eq.0).or.(k.eq.N(ng))) THEN
DO j=Jstr-1,Jend+1
DO i=Istr-1,Iend+1
dTdr(i,j,k2)=0.0_r8
FS(i,j,k2)=0.0_r8
END DO
END DO
ELSE
DO j=Jstr-1,Jend+1
DO i=Istr-1,Iend+1
#if defined TS_MIX_MAX_SLOPE
cff1=SQRT(dRdx(i,j,k2)**2+dRdx(i+1,j,k2)**2+ &
& dRdx(i,j,k1)**2+dRdx(i+1,j,k1)**2+ &
& dRde(i,j,k2)**2+dRde(i,j+1,k2)**2+ &
& dRde(i,j,k1)**2+dRde(i,j+1,k1)**2)
cff2=0.25_r8*slope_max* &
& (z_r(i,j,k+1)-z_r(i,j,k))*cff1
cff3=MAX(pden(i,j,k)-pden(i,j,k+1),small)
cff4=MAX(cff2,cff3)
cff=-1.0_r8/cff4
#elif defined TS_MIX_MIN_STRAT
cff1=MAX(pden(i,j,k)-pden(i,j,k+1), &
& strat_min*(z_r(i,j,k+1)-z_r(i,j,k)))
cff=-1.0_r8/cff1
#else
cff1=MAX(pden(i,j,k)-pden(i,j,k+1),eps)
cff=-1.0_r8/cff1
#endif
dTdr(i,j,k2)=cff*(LapT(i,j,k+1)- &
& LapT(i,j,k ))
FS(i,j,k2)=cff*(z_r(i,j,k+1)- &
& z_r(i,j,k ))
END DO
END DO
END IF
!
! Compute components of the rotated tracer flux (T m4/s) along
! isopycnic surfaces.
!
IF (k.gt.0) THEN
DO j=Jstr,Jend
DO i=Istr,Iend+1
#ifdef DIFF_3DCOEF
# ifdef TS_U3ADV_SPLIT
cff=0.5_r8*diff3d_u(i,j,k)*on_u(i,j)
# else
cff=0.25_r8*(diff3d_r(i,j,k)+diff3d_r(i-1,j,k))* &
& on_u(i,j)
# endif
#else
cff=0.25_r8*(diff4(i,j,itrc)+diff4(i-1,j,itrc))* &
& on_u(i,j)
#endif
FX(i,j)=cff* &
& (Hz(i,j,k)+Hz(i-1,j,k))* &
& (dTdx(i,j,k1)- &
& 0.5_r8*(MAX(dRdx(i,j,k1),0.0_r8)* &
& (dTdr(i-1,j,k1)+ &
& dTdr(i ,j,k2))+ &
& MIN(dRdx(i,j,k1),0.0_r8)* &
& (dTdr(i-1,j,k2)+ &
& dTdr(i ,j,k1))))
END DO
END DO
DO j=Jstr,Jend+1
DO i=Istr,Iend
#ifdef DIFF_3DCOEF
# ifdef TS_U3ADV_SPLIT
cff=0.5_r8*diff3d_v(i,j,k)*om_v(i,j)
# else
cff=0.25_r8*(diff3d_r(i,j,k)+diff3d_r(i,j-1,k))* &
& om_v(i,j)
# endif
#else
cff=0.25_r8*(diff4(i,j,itrc)+diff4(i,j-1,itrc))* &
& om_v(i,j)
#endif
FE(i,j)=cff* &
& (Hz(i,j,k)+Hz(i,j-1,k))* &
& (dTde(i,j,k1)- &
& 0.5_r8*(MAX(dRde(i,j,k1),0.0_r8)* &
& (dTdr(i,j-1,k1)+ &
& dTdr(i,j ,k2))+ &
& MIN(dRde(i,j,k1),0.0_r8)* &
& (dTdr(i,j-1,k2)+ &
& dTdr(i,j ,k1))))
END DO
END DO
IF (k.lt.N(ng)) THEN
DO j=Jstr,Jend
DO i=Istr,Iend
#ifdef DIFF_3DCOEF
# ifdef TS_U3ADV_SPLIT
difx=0.125_r8*(diff3d_u(i,j,k )+diff3d_u(i+1,j,k )+ &
& diff3d_u(i,j,k+1)+diff3d_u(i+1,j,k+1))
dife=0.125_r8*(diff3d_v(i,j,k )+diff3d_v(i,j+1,k )+ &
& diff3d_v(i,j,k+1)+diff3d_v(i,j+1,k+1))
# else
difx=0.5_r8*diff3d_r(i,j,k)
dife=difx
# endif
#else
difx=0.5_r8*diff4(i,j,itrc)
dife=difx
#endif
cff1=MAX(dRdx(i ,j,k1),0.0_r8)
cff2=MAX(dRdx(i+1,j,k2),0.0_r8)
cff3=MIN(dRdx(i ,j,k2),0.0_r8)
cff4=MIN(dRdx(i+1,j,k1),0.0_r8)
cff=difx* &
& (cff1*(cff1*dTdr(i,j,k2)-dTdx(i ,j,k1))+ &
& cff2*(cff2*dTdr(i,j,k2)-dTdx(i+1,j,k2))+ &
& cff3*(cff3*dTdr(i,j,k2)-dTdx(i ,j,k2))+ &
& cff4*(cff4*dTdr(i,j,k2)-dTdx(i+1,j,k1)))
!
cff1=MAX(dRde(i,j ,k1),0.0_r8)
cff2=MAX(dRde(i,j+1,k2),0.0_r8)
cff3=MIN(dRde(i,j ,k2),0.0_r8)
cff4=MIN(dRde(i,j+1,k1),0.0_r8)
cff=cff+ &
& dife* &
& (cff1*(cff1*dTdr(i,j,k2)-dTde(i,j ,k1))+ &
& cff2*(cff2*dTdr(i,j,k2)-dTde(i,j+1,k2))+ &
& cff3*(cff3*dTdr(i,j,k2)-dTde(i,j ,k2))+ &
& cff4*(cff4*dTdr(i,j,k2)-dTde(i,j+1,k1)))
FS(i,j,k2)=cff*FS(i,j,k2)
END DO
END DO
END IF
!
! Time-step biharmonic, isopycnal diffusion term (m Tunits).
!
DO j=Jstr,Jend
DO i=Istr,Iend
cff=dt(ng)*pm(i,j)*pn(i,j)
cff1=cff*(FX(i+1,j )-FX(i,j))
cff2=cff*(FE(i ,j+1)-FE(i,j))
cff3=dt(ng)*(FS(i,j,k2)-FS(i,j,k1))
cff4=cff1+cff2+cff3
t(i,j,k,nnew,itrc)=t(i,j,k,nnew,itrc)-cff4
#ifdef DIAGNOSTICS_TS
DiaTwrk(i,j,k,itrc,iTxdif)=-cff1
DiaTwrk(i,j,k,itrc,iTydif)=-cff2
DiaTwrk(i,j,k,itrc,iTsdif)=-cff3
DiaTwrk(i,j,k,itrc,iThdif)=-cff4
#endif
END DO
END DO
END IF
END DO K_LOOP2
END DO T_LOOP
!
RETURN
END SUBROUTINE t3dmix4_tile
| 38.821696 | 73 | 0.370772 |
6383fe0b8ceec662b95333a66859ecee0e86bb94 | 1,299 | h | C | components/xtl/include/xtl/checked_delete.h | untgames/funner | c91614cda55fd00f5631d2bd11c4ab91f53573a3 | [
"MIT"
] | 7 | 2016-03-30T17:00:39.000Z | 2017-03-27T16:04:04.000Z | components/xtl/include/xtl/checked_delete.h | untgames/Funner | c91614cda55fd00f5631d2bd11c4ab91f53573a3 | [
"MIT"
] | 4 | 2017-11-21T11:25:49.000Z | 2018-09-20T17:59:27.000Z | components/xtl/include/xtl/checked_delete.h | untgames/Funner | c91614cda55fd00f5631d2bd11c4ab91f53573a3 | [
"MIT"
] | 4 | 2016-11-29T15:18:40.000Z | 2017-03-27T16:04:08.000Z | #ifndef XTL_CHECKED_DELETE_HEADER
#define XTL_CHECKED_DELETE_HEADER
namespace xtl
{
///////////////////////////////////////////////////////////////////////////////////////////////////
///Удаление с проверкой на "полноту" типа
///////////////////////////////////////////////////////////////////////////////////////////////////
template <class T> void checked_delete (T*);
template <class T> void checked_array_delete (T*);
///////////////////////////////////////////////////////////////////////////////////////////////////
///Функтор удаления объекта
///////////////////////////////////////////////////////////////////////////////////////////////////
template <class T> struct checked_deleter
{
typedef void result_type;
typedef T* argument_type;
void operator () (T* ptr) const { xtl::checked_delete (ptr); }
};
///////////////////////////////////////////////////////////////////////////////////////////////////
///Функтор удаления массива
///////////////////////////////////////////////////////////////////////////////////////////////////
template <class T> struct checked_array_deleter
{
typedef void result_type;
typedef T* argument_type;
void operator () (T* ptr) const { xtl::checked_array_delete (ptr); }
};
#include <xtl/detail/checked_delete.inl>
}
#endif
| 32.475 | 99 | 0.39184 |
9df55d81ac72514dc9a1c2b26beb1d02d0e2c9bc | 4,167 | h | C | include/commom/Snowflake.h | kkroid/PiRPC | 452d056635d94c815e9a5ef75678aeae172dc50e | [
"Apache-2.0"
] | null | null | null | include/commom/Snowflake.h | kkroid/PiRPC | 452d056635d94c815e9a5ef75678aeae172dc50e | [
"Apache-2.0"
] | null | null | null | include/commom/Snowflake.h | kkroid/PiRPC | 452d056635d94c815e9a5ef75678aeae172dc50e | [
"Apache-2.0"
] | null | null | null | /**
* 文件名称:Snowflake.h
* 文件标识:
* 摘 要:通过SnowFlake算法生成一个64位大小的分布式自增长id
*/
#ifndef __SNOWFLAKE_H__
#define __SNOWFLAKE_H__
#include <mutex>
#include <atomic>
#include <iostream>
//#define SNOWFLAKE_ID_WORKER_NO_LOCK
typedef uint32_t UInt;
typedef uint64_t UInt64;
#ifdef SNOWFLAKE_ID_WORKER_NO_LOCK
typedef std::atomic<UInt> AtomicUInt;
typedef std::atomic<UInt64> AtomicUInt64;
#else
typedef UInt AtomicUInt;
typedef UInt64 AtomicUInt64;
#endif
namespace PiRPC {
class Snowflake {
public:
Snowflake() {
m_HostId = 1;
m_WorkerId = 1;
sequence = 0;
lastTimestamp = 0;
}
~Snowflake() = default;
void setHostId(UInt HostId) {
m_HostId = HostId;
}
void setWorkerId(UInt workerId) {
m_WorkerId = workerId;
}
UInt64 nextId() {
return GetDistributedId();
}
static UInt64 GetTimeStamp() {
auto t = std::chrono::time_point_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now());
return t.time_since_epoch().count();
}
private:
static UInt64 tilNextMillis(UInt64 lastTimestamp) {
UInt64 timestamp = GetTimeStamp();
while (timestamp <= lastTimestamp) {
timestamp = GetTimeStamp();
}
return timestamp;
}
UInt64 GetDistributedId() {
#ifndef SNOWFLAKE_ID_WORKER_NO_LOCK
std::unique_lock<std::mutex> lock{mutex};
AtomicUInt64 timestamp{0};
#else
static AtomicUInt64 timestamp{ 0 };
#endif
timestamp = GetTimeStamp();
// 如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
if (timestamp < lastTimestamp) {
std::cout << "clock moved backwards. Refusing to generate id for " << lastTimestamp - timestamp
<< " milliseconds";
return 0;
}
if (lastTimestamp == timestamp) {
// 如果是同一时间生成的,则进行毫秒内序列
sequence = (sequence + 1) & sequenceMask;
if (0 == sequence) {
// 毫秒内序列溢出, 阻塞到下一个毫秒,获得新的时间戳
timestamp = tilNextMillis(lastTimestamp);
}
} else {
sequence = 0;
}
#ifndef SNOWFLAKE_ID_WORKER_NO_LOCK
lastTimestamp = timestamp;
#else
lastTimestamp = timestamp.load();
#endif
// 移位并通过或运算拼到一起组成64位的ID
return ((timestamp - twepoch) << timestampLeftShift)
| (m_HostId << hostIdShift)
| (m_WorkerId << workerIdShift)
| sequence;
}
private:
#ifndef SNOWFLAKE_ID_WORKER_NO_LOCK
std::mutex mutex;
#endif
/**
* 开始时间截 (2019-09-30 00:00:00.000)
*/
const UInt64 twepoch = 1569772800000UL;
/**
* worker进程映射id所占的位数
*/
const UInt workerIdBits = 5;
/**
* 服务器id所占的位数
*/
const UInt hostIdBits = 5;
/**
* 序列所占的位数
*/
const UInt sequenceBits = 12;
/**
* worker进程映射ID向左移12位
*/
const UInt workerIdShift = sequenceBits;
/**
* 服务器id向左移17位
*/
const UInt hostIdShift = workerIdShift + workerIdBits;
/**
* 时间截向左移22位
*/
const UInt timestampLeftShift = hostIdShift + hostIdBits;
/**
* 支持的worker进程映射id,结果是31
*/
const UInt maxWorkerId = -1 ^(-1 << workerIdBits);
/**
* 支持的服务器id,结果是31
*/
const UInt maxHostId = -1 ^(-1 << hostIdBits);
/**
* 生成序列的掩码,这里为4095
*/
const UInt sequenceMask = -1 ^(-1 << sequenceBits);
/**
* worker进程映射id(0~31)
*/
UInt m_WorkerId;
/**
* 服务器id(0~31)
*/
UInt m_HostId;
/**
* 毫秒内序列(0~4095)
*/
AtomicUInt sequence{0};
/**
* 上次生成ID的时间截
*/
AtomicUInt64 lastTimestamp{0};
};
}
#endif | 22.646739 | 120 | 0.519078 |
5b2d2052b0d6c32be86b25ab4ad08f7b3c004e52 | 519 | h | C | include/pokemon_storage_system.h | thechurchofcage/Complete-Fire-Red-Upgrade | e8bab9a1aab9d34c019940dab2015bac89ab8918 | [
"WTFPL"
] | null | null | null | include/pokemon_storage_system.h | thechurchofcage/Complete-Fire-Red-Upgrade | e8bab9a1aab9d34c019940dab2015bac89ab8918 | [
"WTFPL"
] | null | null | null | include/pokemon_storage_system.h | thechurchofcage/Complete-Fire-Red-Upgrade | e8bab9a1aab9d34c019940dab2015bac89ab8918 | [
"WTFPL"
] | null | null | null | #ifndef GUARD_POKEMON_STORAGE_SYSTEM_H
#define GUARD_POKEMON_STORAGE_SYSTEM_H
#include "global.h"
#define TOTAL_BOXES_COUNT 14
#define IN_BOX_COUNT 30
u8* GetBoxNamePtr(u8 boxNumber);
struct BoxPokemon *GetBoxedMonPtr(u8 boxId, u8 monPosition);
void SetBoxMonNickFromAnyBox(u8 boxId, u8 monPosition, u8 * newNick);
void CompactPartySlots(void);
u32 GetBoxMonDataFromAnyBox(u8 boxId, u8 monPosition, u32 request);
void sub_808BCB4(u8 boxId, u8 monPosition);
#endif // GUARD_POKEMON_STORAGE_SYSTEM_H
| 30.529412 | 69 | 0.797688 |
3e95b5c03d74fb23a63cb9aefb2eb4521c0b86d4 | 2,688 | h | C | src/log.h | wibbe/FoenixMCP | 363271e085495ae69a555ccd2ea7d73b3fff4943 | [
"BSD-3-Clause"
] | 6 | 2021-09-12T17:35:45.000Z | 2022-03-12T16:23:25.000Z | src/log.h | wibbe/FoenixMCP | 363271e085495ae69a555ccd2ea7d73b3fff4943 | [
"BSD-3-Clause"
] | 12 | 2021-09-12T17:55:31.000Z | 2021-12-30T10:22:54.000Z | src/log.h | wibbe/FoenixMCP | 363271e085495ae69a555ccd2ea7d73b3fff4943 | [
"BSD-3-Clause"
] | 5 | 2021-09-21T18:52:16.000Z | 2022-03-29T19:31:58.000Z | /*
* A logging utility...
*/
#ifndef __LOG_H
#define __LOG_H
#define LOG_FATAL 0 /* Log a critical or fatal event */
#define LOG_ERROR 1 /* Log an error */
#define LOG_INFO 2 /* Log miscellaneous information */
#define LOG_DEBUG 3 /* Log a debugging message */
#define LOG_TRACE 4 /* Log tracing information (like entry into a subroutine) */
#define LOG_VERBOSE 5 /* Log a truly verbose message... the sort you almost never want to bother with */
/*
* Return human readable message for an error number
*/
extern const char * err_message(short err_number);
/*
* Print an error message
*
* Inputs:
* channel = the number of the channel to print to
* message = a message string to print before the error
* err_number = the number of the error
*/
extern void err_print(short channel, const char * message, short err_number);
/*
* Display a panic screen
*
* Inputs:
* vector = the number of the vector that was called
*/
extern void panic(void);
/*
* Set the maximum level of verbosity in logging.
* To be printed, a message must have a level lower or equal to this level.
*
* Input:
* level = the maximum level of verbosity to log
*/
extern void log_setlevel(short level);
/*
* Log a message to the console
*
* Inputs:
* level = the severity of the message... the logging level will filter messages displayed
* message = the message to log
*/
extern void log(short level, char * message);
/*
* Log a message to the console
*
* Inputs:
* level = the severity of the message... the logging level will filter messages displayed
* message1 = the first part of the message to log
* message2 = the second part of the message to log
*/
extern void log2(short level, char * message1, char * message2);
/*
* Log a message to the console
*
* Inputs:
* level = the severity of the message... the logging level will filter messages displayed
* message1 = the first part of the message to log
* message2 = the second part of the message to log
* message3 = the third part of the message to log
*/
extern void log3(short level, const char * message1, const char * message2, const char * message3);
/*
* Log a message with a number
*
* Inputs:
* level = the severity of the message... the logging level will filter messages displayed
* message1 = the first part of the message to log
* n = the number to log
*/
extern void log_num(short level, char * message, int n);
/*
* Log a single character
*/
extern void log_c(short log_level, char c);
/*
* Send a message to the debugging channel
*/
#define DEBUG(m) log(LOG_DEBUG, m);
#define TRACE(m) log(LOG_TRACE, m);
#define TRACEC(c) log_c(LOG_TRACE, c);
#endif
| 26.88 | 106 | 0.697917 |
12eff0fe46b8b5e7e31ecd86b5238bd507ce6480 | 1,304 | h | C | Engine/Source/Runtime/Core/Public/WinRT/WinRTCriticalSection.h | PopCap/GameIdea | 201e1df50b2bc99afc079ce326aa0a44b178a391 | [
"BSD-2-Clause"
] | null | null | null | Engine/Source/Runtime/Core/Public/WinRT/WinRTCriticalSection.h | PopCap/GameIdea | 201e1df50b2bc99afc079ce326aa0a44b178a391 | [
"BSD-2-Clause"
] | 2 | 2015-06-21T17:38:11.000Z | 2015-06-22T20:54:42.000Z | Engine/Source/Runtime/Core/Public/WinRT/WinRTCriticalSection.h | PopCap/GameIdea | 201e1df50b2bc99afc079ce326aa0a44b178a391 | [
"BSD-2-Clause"
] | null | null | null | // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
/**
* This is the WinRT version of a critical section. It uses an aggregate
* CRITICAL_SECTION to implement its locking.
*/
class FWinRTCriticalSection
{
/**
* The WinRT specific critical section
*/
CRITICAL_SECTION CriticalSection;
public:
/**
* Constructor that initializes the aggregated critical section
*/
FORCEINLINE FWinRTCriticalSection()
{
#if USING_CODE_ANALYSIS
MSVC_PRAGMA( warning( suppress : 28125 ) ) // warning C28125: The function 'InitializeCriticalSection' must be called from within a try/except block: The requirement might be conditional.
#endif // USING_CODE_ANALYSIS
InitializeCriticalSectionEx(&CriticalSection, 4000, 0);
}
/**
* Destructor cleaning up the critical section
*/
FORCEINLINE ~FWinRTCriticalSection()
{
DeleteCriticalSection(&CriticalSection);
}
/**
* Locks the critical section
*/
FORCEINLINE void Lock()
{
// Spin first before entering critical section, causing ring-0 transition and context switch.
if( TryEnterCriticalSection(&CriticalSection) == 0 )
{
EnterCriticalSection(&CriticalSection);
}
}
/**
* Releases the lock on the critical seciton
*/
FORCEINLINE void Unlock()
{
LeaveCriticalSection(&CriticalSection);
}
};
| 22.877193 | 189 | 0.736963 |
3f1b932010036253f8f4796d4d255c6715fe76de | 4,755 | h | C | include/meta/parser/nodes/class.h | huangfeidian/meta | 0578c1a403bfeca438483623e332e1b38f1c988e | [
"BSD-3-Clause"
] | 19 | 2019-09-09T03:31:51.000Z | 2021-11-12T11:43:43.000Z | include/meta/parser/nodes/class.h | huangfeidian/meta | 0578c1a403bfeca438483623e332e1b38f1c988e | [
"BSD-3-Clause"
] | 1 | 2020-11-12T10:39:05.000Z | 2020-11-21T05:56:40.000Z | include/meta/parser/nodes/class.h | huangfeidian/meta | 0578c1a403bfeca438483623e332e1b38f1c988e | [
"BSD-3-Clause"
] | 6 | 2020-03-30T09:36:39.000Z | 2022-03-30T08:48:54.000Z | #pragma once
#include "type_info.h"
#include "forward.h"
namespace spiritsaway::meta::language
{
class class_node: public node_base
{
public:
class_node(const node* _in_node);
bool is_template() const;
const std::vector<std::string>& template_args() const;
const type_info* decl_type() const;
const std::vector<const type_info*> bases() const;
const std::vector<const class_node*> base_classes() const;
const callable_node* has_method_for(const std::string& _func_name, const std::vector<const type_info*>& _args) const;
const callable_node* has_static_method_for(const std::string& _func_name, const std::vector<const type_info*>& _args) const;
const variable_node* has_field(const std::string& _field_name) const;
const variable_node* has_static_field(const std::string& _field_name) const;
const callable_node* has_constructor_for(const std::vector<const type_info*>& _args) const;
json to_json() const;
public:
template <typename T>
std::vector<const variable_node*> query_fields_with_pred(const T& _pred) const;
template <typename T>
std::vector<const variable_node*> query_fields_with_pred_recursive(const T& _pred) const;
template <typename T>
std::vector<const callable_node*> query_method_with_pred(const T& _pred) const;
template <typename T>
std::vector<const callable_node*> query_method_with_pred_recursive(const T& _pred) const;
template <typename T1, typename T2>
std::unordered_map<const variable_node*, std::vector<const callable_node*>> query_method_recursive_with_fields(const T1& func_pred, const T2& field_pred, bool exclude_self) const;
private:
std::vector<std::string> _template_args;
std::unordered_map<std::string, const variable_node*> _fields;
std::unordered_map<std::string, const variable_node*> _static_fields;
std::multimap<std::string, const callable_node*> _methods;
std::multimap<std::string, const callable_node*> _static_methods;
std::vector<const callable_node*> _constructors;
callable_node* _destructor = nullptr;
std::vector<const type_info*> _bases;
void parse();
type_info* _decl_type = nullptr;
};
template <typename T>
std::vector<const variable_node*> class_node::query_fields_with_pred(const T& _pred) const
{
std::vector<const variable_node*> result;
for (const auto& i : _fields)
{
if (!i.second)
{
continue;
}
if (_pred(*i.second))
{
result.push_back(i.second);
}
}
return result;
}
template <typename T>
std::vector<const variable_node*> class_node::query_fields_with_pred_recursive(const T& _pred) const
{
std::vector<const variable_node*> result = query_fields_with_pred(_pred);
for (auto one_base : _bases)
{
auto one_class = one_base->related_class();
if (one_class)
{
const auto& temp_result = one_class->query_fields_with_pred_recursive(_pred);
std::copy(temp_result.begin(), temp_result.end(), std::back_inserter(result));
}
}
return result;
}
template <typename T>
std::vector<const callable_node*> class_node::query_method_with_pred(const T& _pred) const
{
std::vector<const callable_node*> result;
for (const auto& i : _methods)
{
if (!i.second)
{
continue;
}
if (_pred(*i.second))
{
result.push_back(i.second);
}
}
return result;
}
template <typename T>
std::vector<const callable_node*> class_node::query_method_with_pred_recursive(const T& _pred) const
{
std::vector<const callable_node*> result = query_method_with_pred(_pred);
for (auto one_base : _bases)
{
auto one_class = one_base->related_class();
if (one_class)
{
const auto& temp_result = one_class->query_method_with_pred_recursive(_pred);
std::copy(temp_result.begin(), temp_result.end(), std::back_inserter(result));
}
}
return result;
}
template <typename T1, typename T2>
std::unordered_map<const variable_node*, std::vector<const callable_node*>> class_node::query_method_recursive_with_fields(const T1& func_pred, const T2& field_pred, bool exclude_self) const
{
std::unordered_map<const variable_node*, std::vector<const callable_node*>> final_result;
if (!exclude_self)
{
auto root_result = query_method_with_pred_recursive(func_pred);
final_result[nullptr] = root_result;
}
for (const auto one_field : _fields)
{
auto cur_variable = one_field.second;
if (!field_pred(*cur_variable))
{
continue;
}
auto field_type = cur_variable->decl_type();
auto class_type = field_type->related_class();
if (!class_type)
{
continue;
}
auto temp_result = class_type->query_method_with_pred_recursive(func_pred);
if (temp_result.size())
{
final_result[cur_variable] = temp_result;
}
}
return final_result;
}
} | 32.128378 | 191 | 0.727234 |
3f9a1d6147516c9a01a0c8754a6888a709e29aa0 | 2,667 | h | C | Source/Urho3D/Engine/Application.h | pat2nav/Urho3D | cc0346f39bd365782d825e2e337a1f33bb225308 | [
"MIT"
] | null | null | null | Source/Urho3D/Engine/Application.h | pat2nav/Urho3D | cc0346f39bd365782d825e2e337a1f33bb225308 | [
"MIT"
] | null | null | null | Source/Urho3D/Engine/Application.h | pat2nav/Urho3D | cc0346f39bd365782d825e2e337a1f33bb225308 | [
"MIT"
] | null | null | null | // Copyright (c) 2008-2022 the Urho3D project
// License: MIT
/// \file
/// @nobindfile
#pragma once
#include "../Core/Context.h"
#include "../Core/Main.h"
#include "../Engine/Engine.h"
namespace Urho3D
{
class Engine;
/// Base class for creating applications which initialize the Urho3D engine and run a main loop until exited.
class URHO3D_API Application : public Object
{
URHO3D_OBJECT(Application, Object);
public:
/// Construct. Parse default engine parameters from the command line, and create the engine in an uninitialized state.
explicit Application(Context* context);
/// Setup before engine initialization. This is a chance to eg. modify the engine parameters. Call ErrorExit() to terminate without initializing the engine. Called by Application.
virtual void Setup() { }
/// Setup after engine initialization and before running the main loop. Call ErrorExit() to terminate without running the main loop. Called by Application.
virtual void Start() { }
/// Cleanup after the main loop. Called by Application.
virtual void Stop() { }
/// Initialize the engine and run the main loop, then return the application exit code. Catch out-of-memory exceptions while running.
int Run();
/// Show an error message (last log message if empty), terminate the main loop, and set failure exit code.
void ErrorExit(const String& message = String::EMPTY);
protected:
/// Handle log message.
void HandleLogMessage(StringHash eventType, VariantMap& eventData);
/// Urho3D engine.
SharedPtr<Engine> engine_;
/// Engine parameters map.
VariantMap engineParameters_;
/// Collected startup error log messages.
String startupErrors_;
/// Application exit code.
int exitCode_;
};
// Macro for defining a main function which creates a Context and the application, then runs it
#if !defined(IOS) && !defined(TVOS)
#define URHO3D_DEFINE_APPLICATION_MAIN(className) \
int RunApplication() \
{ \
Urho3D::SharedPtr<Urho3D::Context> context(new Urho3D::Context()); \
Urho3D::SharedPtr<className> application(new className(context)); \
return application->Run(); \
} \
URHO3D_DEFINE_MAIN(RunApplication())
#else
// On iOS/tvOS we will let this function exit, so do not hold the context and application in SharedPtr's
#define URHO3D_DEFINE_APPLICATION_MAIN(className) \
int RunApplication() \
{ \
Urho3D::Context* context = new Urho3D::Context(); \
className* application = new className(context); \
return application->Run(); \
} \
URHO3D_DEFINE_MAIN(RunApplication());
#endif
}
| 34.192308 | 184 | 0.702662 |
e9daa69bf5da253cbdf1424347ad93e43a1aead3 | 480 | h | C | pipe.h | robertdfrench/guarantee-resource-cleanup | 36ea824ed12e992b7304f0978034c5713f62e906 | [
"MIT"
] | null | null | null | pipe.h | robertdfrench/guarantee-resource-cleanup | 36ea824ed12e992b7304f0978034c5713f62e906 | [
"MIT"
] | null | null | null | pipe.h | robertdfrench/guarantee-resource-cleanup | 36ea824ed12e992b7304f0978034c5713f62e906 | [
"MIT"
] | null | null | null | #ifndef PIPE_H
#define PIPE_H
typedef struct {
int e;
} PipeAcquisitionFailure;
typedef struct {
int r;
int w;
} Pipe;
typedef struct {
int e;
} PipeReleaseFailureRead;
typedef struct {
int e;
} PipeReleaseFailureWrite;
int pipe_context(
int (*could_not_acquire)(PipeAcquisitionFailure, void*),
int (*success)(Pipe, void*),
int (*could_not_release_r)(PipeReleaseFailureRead, void*),
int (*could_not_release_w)(PipeReleaseFailureWrite, void*),
void* state
);
#endif
| 17.142857 | 60 | 0.74375 |
f5f11053231151b044b83dc9d610b7a7ce7887b8 | 13,561 | c | C | tests/mib_tests.c | JHG777000/marshmallow | 8a5c9523fbbafdd87db12aa21d7c394b001cb72f | [
"BSD-2-Clause"
] | 5 | 2019-03-19T22:24:22.000Z | 2021-07-14T15:21:06.000Z | tests/mib_tests.c | JHG777000/marshmallow | 8a5c9523fbbafdd87db12aa21d7c394b001cb72f | [
"BSD-2-Clause"
] | null | null | null | tests/mib_tests.c | JHG777000/marshmallow | 8a5c9523fbbafdd87db12aa21d7c394b001cb72f | [
"BSD-2-Clause"
] | null | null | null | /*
Copyright (c) 2018-2019 Jacob Gordon. 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 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.
*/
#include "marshmallow.h"
#include "marshmallow_codegen.h"
int main(int argc, const char **argv) {
codegen_backend backend = codegen_new_backend(get_backend(C),argv[1]) ;
cg_context my_context = cg_new_context() ;
cg_module my_module = cg_new_module(rkstr("mymod_mib")) ;
cg_add_module_to_context(my_module, my_context) ;
cg_variable my_class = cg_new_class(rkstr("myclass"), my_module) ;
cg_variable var_a = cg_new_variable(rkstr("var_a"), i32, -1, -1, 0, 0) ;
cg_variable var_b = cg_new_variable(rkstr("var_b"), i64, -1, -1, 0, 0) ;
cg_variable var_c = cg_new_variable(rkstr("var_c"), u64, -1, -1, 0, 0) ;
cg_variable var_d = cg_new_variable(rkstr("var_d"), array, -1, -1, 10, 0) ;
var_d->ptr = cg_new_variable(NULL, i32, -1, -1, 0, 0) ;
cg_add_class_element(var_a, my_class) ;
cg_add_class_element(var_b, my_class) ;
cg_add_class_element(var_c, my_class) ;
cg_add_class_element(var_d, my_class) ;
cg_routine other_routine = cg_new_routine(rkstr("other_routine"), 1) ;
cg_add_routine_declaration_to_module(other_routine, my_module) ;
cg_variable A = cg_new_variable(rkstr("A"), i32, -1, -1, 0, 0) ;
cg_variable B = cg_new_variable(rkstr("B"), i32, -1, -1, 0, 0) ;
cg_variable C = cg_new_variable(rkstr("C"), i32, -1, -1, 0, 0) ;
cg_variable D = cg_new_variable(rkstr("D"), i32, -1, -1, 0, 0) ;
cg_variable E = cg_new_variable(rkstr("E"), array, -1, -1, 10, 0) ;
E->ptr = cg_new_variable(NULL, i32, -1, -1, 0, 0) ;
cg_variable F = cg_new_variable(rkstr("F"), array, -1, -1, 10, 0) ;
F->ptr = cg_new_variable(NULL, array, -1, -1, 22, 0) ;
F->ptr->ptr = cg_new_variable(NULL, i32, -1, -1, 0, 0) ;
cg_variable G = cg_new_variable(rkstr("G"), class, -1, -1, 0, 0) ;
G->ptr = my_class ;
RKStore_AddItem(other_routine->parameters, A, "A") ;
RKStore_AddItem(other_routine->parameters, B, "B") ;
RKStore_AddItem(other_routine->parameters, C, "C") ;
RKStore_AddItem(other_routine->parameters, D, "D") ;
cg_add_variable_to_routine(E, other_routine) ;
cg_add_variable_to_routine(F, other_routine) ;
cg_add_variable_to_routine(G, other_routine) ;
cg_add_return_to_returns_in_routine(cg_new_variable(NULL,i32,-1,-1,0,0), other_routine) ;
cg_add_return_to_returns_in_routine(cg_new_variable(NULL,i32,-1,-1,0,0), other_routine) ;
cg_add_return_to_returns_in_routine(cg_new_variable(NULL,i32,-1,-1,0,0), other_routine) ;
cg_add_return_to_returns_in_routine(cg_new_variable(NULL,i32,-1,-1,0,0), other_routine) ;
cg_variable ERet = cg_new_variable(NULL, array, -1, -1, 10, 0) ;
ERet->ptr = cg_new_variable(NULL, i32, -1, -1, 0, 0) ;
cg_add_return_to_returns_in_routine(ERet, other_routine) ;
cg_add_routine_to_module(other_routine, my_module) ;
cg_variable section_var = cg_new_variable(NULL, i8, -1, -1, 0, 0) ;
section_var->is_literal = 1 ;
section_var->value = rkstr("loop") ;
cg_add_variable_to_routine(section_var, other_routine) ;
mib_add_statement(mib_group, other_routine, NULL) ;
mib_add_statement(cg_if, other_routine, NULL) ;
mib_add_statement(mib_var, other_routine, A) ;
mib_add_statement(mib_endgroup, other_routine, NULL) ;
mib_add_statement(mib_group, other_routine, NULL) ;
mib_add_statement(cg_section, other_routine, section_var) ;
mib_add_statement(cg_if, other_routine, NULL) ;
mib_add_statement(mib_group, other_routine, NULL) ;
mib_add_statement(mib_var, other_routine, A) ;
mib_add_statement(cg_lessthan, other_routine, NULL) ;
mib_add_statement(mib_var, other_routine, B) ;
mib_add_statement(mib_endgroup, other_routine, NULL) ;
mib_add_statement(mib_endgroup, other_routine, NULL) ;
mib_add_statement(mib_group, other_routine, NULL) ;
mib_add_statement(mib_var, other_routine, A) ;
mib_add_statement(cg_assignment, other_routine, NULL) ;
mib_add_statement(mib_group, other_routine, NULL) ;
mib_add_statement(mib_var, other_routine, A) ;
mib_add_statement(cg_add, other_routine, NULL) ;
mib_add_statement(mib_var, other_routine, B) ;
mib_add_statement(mib_endgroup, other_routine, NULL) ;
mib_add_statement(mib_exitgroup, other_routine, NULL) ;
mib_add_statement(cg_goto, other_routine, section_var) ;
mib_add_statement(cg_endif, other_routine, NULL) ;
mib_add_statement(cg_endif, other_routine, NULL) ;
mib_add_statement(mib_group, other_routine, NULL) ;
mib_add_statement(cg_return, other_routine, NULL) ;
mib_add_statement(mib_var, other_routine, A) ;
mib_add_statement(mib_var, other_routine, B) ;
mib_add_statement(mib_var, other_routine, C) ;
mib_add_statement(mib_var, other_routine, D) ;
mib_add_statement(mib_var, other_routine, E) ;
mib_add_statement(mib_endgroup, other_routine, NULL) ;
mib_generate_mob(other_routine) ;
mob_generate_mlb(other_routine) ;
cg_routine my_routine = cg_new_routine(rkstr("myroutine"), 1) ;
cg_add_routine_declaration_to_module(my_routine, my_module) ;
cg_add_return_to_returns_in_routine(cg_new_variable(NULL,i32,-1,-1,0,0), my_routine) ;
cg_add_return_to_returns_in_routine(cg_new_variable(NULL,i32,-1,-1,0,0), my_routine) ;
cg_add_routine_to_module(my_routine, my_module) ;
cg_variable x = cg_new_variable(rkstr("x"), i32, -1, -1, 0, 0) ;
x->value = rkstr("0") ;
cg_variable y = cg_new_variable(rkstr("y"), i32, -1, -1, 0, 0) ;
y->value = rkstr("0") ;
cg_variable z = cg_new_variable(rkstr("z"), i32, -1, -1, 0, 0) ;
z->value = rkstr("0") ;
cg_variable z2 = cg_new_variable(rkstr("z2"), i32, -1, -1, 0, 0) ;
z2->value = rkstr("0") ;
cg_variable z3 = cg_new_variable(rkstr("z3"), i32, -1, -1, 0, 0) ;
z3->value = rkstr("0") ;
cg_variable z4 = cg_new_variable(rkstr("z4"), i32, -1, -1, 0, 0) ;
z4->value = rkstr("0") ;
cg_variable call = cg_new_variable(NULL, collection, -1, -1, 0, 0) ;
call->values = RKList_NewList() ;
call->is_literal = 1 ;
cg_variable one = cg_new_variable(NULL, i32, -1, -1, 0, 0) ;
one->value = rkstr("1") ;
one->is_literal = 1 ;
cg_variable two = cg_new_variable(NULL, i32, -1, -1, 0, 0) ;
two->value = rkstr("2") ;
two->is_literal = 1 ;
cg_add_variable_to_routine(x, my_routine) ;
cg_add_variable_to_routine(y, my_routine) ;
cg_add_variable_to_routine(z, my_routine) ;
cg_add_variable_to_routine(z2, my_routine) ;
cg_add_variable_to_routine(z3, my_routine) ;
cg_add_variable_to_routine(z4, my_routine) ;
cg_add_variable_to_routine(call, my_routine) ;
cg_add_variable_to_routine(one, my_routine) ;
cg_add_variable_to_routine(two, my_routine) ;
RKList_AddToList(call->values, other_routine) ;
RKList_AddToList(call->values, one) ;
RKList_AddToList(call->values, two) ;
RKList_AddToList(call->values, x) ;
RKList_AddToList(call->values, y) ;
mib_add_statement(cg_call, my_routine, call) ;
mib_add_statement(mib_group, my_routine, NULL) ;
mib_add_statement(mib_var, my_routine, z) ;
mib_add_statement(cg_assignment, my_routine, NULL) ;
mib_add_statement(cg_get_return, my_routine, NULL) ;
mib_add_statement(mib_exitgroup, my_routine, NULL) ;
mib_add_statement(mib_group, my_routine, NULL) ;
mib_add_statement(mib_var, my_routine, z2) ;
mib_add_statement(cg_assignment, my_routine, NULL) ;
mib_add_statement(cg_get_return, my_routine, NULL) ;
mib_add_statement(mib_exitgroup, my_routine, NULL) ;
mib_add_statement(mib_group, my_routine, NULL) ;
mib_add_statement(mib_var, my_routine, z3) ;
mib_add_statement(cg_assignment, my_routine, NULL) ;
mib_add_statement(cg_get_return, my_routine, NULL) ;
mib_add_statement(mib_exitgroup, my_routine, NULL) ;
mib_add_statement(mib_group, my_routine, NULL) ;
mib_add_statement(mib_var, my_routine, z4) ;
mib_add_statement(cg_assignment, my_routine, NULL) ;
mib_add_statement(cg_get_return, my_routine, NULL) ;
mib_add_statement(mib_exitgroup, my_routine, NULL) ;
mib_add_statement(mib_group, my_routine, NULL) ;
mib_add_statement(cg_switch, my_routine, NULL) ;
mib_add_statement(mib_var, my_routine, z) ;
mib_add_statement(mib_endgroup, my_routine, NULL) ;
mib_add_statement(cg_case, my_routine, one) ;
mib_add_statement(mib_group, my_routine, NULL) ;
mib_add_statement(mib_var, my_routine, z2) ;
mib_add_statement(cg_mult, my_routine, NULL) ;
mib_add_statement(mib_var, my_routine, z) ;
mib_add_statement(mib_exitgroup, my_routine, NULL) ;
mib_add_statement(cg_endcase, my_routine, NULL) ;
mib_add_statement(cg_case, my_routine, two) ;
mib_add_statement(mib_group, my_routine, NULL) ;
mib_add_statement(mib_var, my_routine, z2) ;
mib_add_statement(cg_div, my_routine, NULL) ;
mib_add_statement(mib_var, my_routine, z) ;
mib_add_statement(mib_exitgroup, my_routine, NULL) ;
mib_add_statement(cg_endcase, my_routine, NULL) ;
mib_add_statement(cg_default, my_routine, NULL) ;
mib_add_statement(mib_group, my_routine, NULL) ;
mib_add_statement(mib_var, my_routine, z2) ;
mib_add_statement(cg_rem, my_routine, NULL) ;
mib_add_statement(mib_var, my_routine, z) ;
mib_add_statement(mib_exitgroup, my_routine, NULL) ;
mib_add_statement(cg_endcase, my_routine, NULL) ;
mib_add_statement(cg_endswitch, my_routine, NULL) ;
mib_add_statement(mib_group, my_routine, NULL) ;
mib_add_statement(mib_var, my_routine, x) ;
mib_add_statement(cg_assignment, my_routine, NULL) ;
mib_add_statement(mib_group, my_routine, NULL) ;
mib_add_statement(mib_var, my_routine, y) ;
mib_add_statement(cg_add, my_routine, NULL) ;
mib_add_statement(mib_group, my_routine, NULL) ;
mib_add_statement(mib_const, my_routine, one) ;
mib_add_statement(cg_add, my_routine, NULL) ;
mib_add_statement(mib_var, my_routine, x) ;
mib_add_statement(mib_endgroup, my_routine, NULL) ;
mib_add_statement(mib_endgroup, my_routine, NULL) ;
mib_add_statement(mib_exitgroup, my_routine, NULL) ;
mib_add_statement(mib_group, my_routine, NULL) ;
mib_add_statement(cg_if, my_routine, NULL) ;
mib_add_statement(mib_group, my_routine, NULL) ;
mib_add_statement(mib_var, my_routine, x) ;
mib_add_statement(cg_greaterthan, my_routine, NULL) ;
mib_add_statement(mib_var, my_routine, y) ;
mib_add_statement(mib_endgroup, my_routine, NULL) ;
mib_add_statement(mib_endgroup, my_routine, NULL) ;
mib_add_statement(cg_else, my_routine, NULL) ;
mib_add_statement(cg_endif, my_routine, NULL) ;
mib_add_statement(mib_group, my_routine, NULL) ;
mib_add_statement(cg_return, my_routine, NULL) ;
mib_add_statement(mib_const, my_routine, one) ;
mib_add_statement(mib_const, my_routine, two) ;
mib_add_statement(mib_endgroup, my_routine, NULL) ;
mib_generate_mob(my_routine) ;
mob_generate_mlb(my_routine) ;
cg_routine main = cg_new_routine(rkstr("main"), 1) ;
cg_add_return_to_returns_in_routine(cg_new_variable(NULL,i32,-1,-1,0,0), main) ;
cg_add_routine_to_module(main, my_module) ;
main->is_external = 1 ;
cg_variable zero = cg_new_variable(NULL, i32, -1, -1, 0, 0) ;
zero->value = rkstr("0") ;
zero->is_literal = 1 ;
cg_variable call2 = cg_new_variable(NULL, collection, -1, -1, 0, 0) ;
call2->values = RKList_NewList() ;
call2->is_literal = 1 ;
RKList_AddToList(call2->values, my_routine) ;
cg_add_variable_to_routine(zero, main) ;
cg_add_variable_to_routine(call2, main) ;
mib_add_statement(cg_call, main, call2) ;
mib_add_statement(mib_group, main, NULL) ;
mib_add_statement(cg_return, main, NULL) ;
mib_add_statement(mib_const, main, zero) ;
mib_add_statement(mib_endgroup, main, NULL) ;
mib_generate_mob(main) ;
mob_generate_mlb(main) ;
cg_give_context_to_backend(my_context, backend) ;
cg_destroy_context(my_context) ;
codegen_destroy_backend(backend) ;
return 0 ;
}
| 27.563008 | 156 | 0.714549 |
6a71c37f545e72460b84d756abaeb5f3622884c6 | 1,096 | h | C | mapHandler/src/resources/model/bodyshape/CollisionCompoundShapeReaderWriter.h | petitg1987/urchinEngine | a14a57ac49a19237d748d2eafc7c2a38a45b95d6 | [
"BSL-1.0"
] | 18 | 2020-06-12T00:04:46.000Z | 2022-01-11T14:56:19.000Z | mapHandler/src/resources/model/bodyshape/CollisionCompoundShapeReaderWriter.h | petitg1987/urchinEngine | a14a57ac49a19237d748d2eafc7c2a38a45b95d6 | [
"BSL-1.0"
] | null | null | null | mapHandler/src/resources/model/bodyshape/CollisionCompoundShapeReaderWriter.h | petitg1987/urchinEngine | a14a57ac49a19237d748d2eafc7c2a38a45b95d6 | [
"BSL-1.0"
] | 6 | 2020-08-16T15:58:41.000Z | 2022-03-05T13:17:50.000Z | #pragma once
#include <memory>
#include <UrchinCommon.h>
#include <UrchinPhysicsEngine.h>
#include <resources/model/bodyshape/CollisionShapeReaderWriter.h>
namespace urchin {
class CollisionCompoundShapeReaderWriter : public CollisionShapeReaderWriter {
public:
~CollisionCompoundShapeReaderWriter() override = default;
CollisionShape3D* loadFrom(const UdaChunk*, const UdaParser&) const override;
void writeOn(UdaChunk&, const CollisionShape3D&, UdaWriter&) const override;
private:
static void loadTransformOn(LocalizedCollisionShape&, const UdaChunk*, const UdaParser&);
static void writeTransformOn(UdaChunk&, const LocalizedCollisionShape&, UdaWriter&);
static constexpr char LOCALIZED_SHAPES[] = "localizedShapes";
static constexpr char LOCALIZED_SHAPE[] = "localizedShape";
static constexpr char TRANSFORM_TAG[] = "transform";
static constexpr char POSITION_TAG[] = "position";
static constexpr char COMPOUND_SHAPE_TAG[] = "shape";
};
}
| 36.533333 | 101 | 0.699818 |
585255b3e28953d60360d8352b2e747e37f07ca5 | 35,579 | h | C | Example/Pods/itmSDK/itmSDK/Frameworks/WSDirectRoom.framework/Headers/BigTalkMessage.pbobjc.h | Clintlin/AGScreenRecorder | 7cf5326d79f3363a3b09bca663d8c86a29163fc6 | [
"MIT"
] | null | null | null | Example/Pods/itmSDK/itmSDK/Frameworks/WSDirectRoom.framework/Headers/BigTalkMessage.pbobjc.h | Clintlin/AGScreenRecorder | 7cf5326d79f3363a3b09bca663d8c86a29163fc6 | [
"MIT"
] | null | null | null | Example/Pods/itmSDK/itmSDK/Frameworks/WSDirectRoom.framework/Headers/BigTalkMessage.pbobjc.h | Clintlin/AGScreenRecorder | 7cf5326d79f3363a3b09bca663d8c86a29163fc6 | [
"MIT"
] | null | null | null | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: BigTalkMessage.proto
// This CPP symbol can be defined to use imports that match up to the framework
// imports needed when using CocoaPods.
#if !defined(AIYOU_G_P_B_USE_PROTOBUF_FRAMEWORK_IMPORTS)
#define AIYOU_G_P_B_USE_PROTOBUF_FRAMEWORK_IMPORTS 0
#endif
#if AIYOU_G_P_B_USE_PROTOBUF_FRAMEWORK_IMPORTS
#import <Protobuf/AIYOU_G_P_BProtocolBuffers.h>
#else
#import "AIYOU_G_P_BProtocolBuffers.h"
#endif
#if GOOGLE_PROTOBUF_OBJC_VERSION < 30002
#error This file was generated by a newer version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
#if 30002 < GOOGLE_PROTOBUF_OBJC_MIN_SUPPORTED_VERSION
#error This file was generated by an older version of protoc which is incompatible with your Protocol Buffer library sources.
#endif
// @@protoc_insertion_point(imports)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
CF_EXTERN_C_BEGIN
@class BaseUserInfo;
@class Chat;
@class PagePB;
NS_ASSUME_NONNULL_BEGIN
#pragma mark - Enum BigTalkCommand
typedef AIYOU_G_P_B_ENUM(BigTalkCommand) {
/**
* Value used if any message's field encounters a value that is not defined
* by this enum. The message will also have C functions to get/set the rawValue
* of the field.
**/
BigTalkCommand_AIYOU_G_P_BUnrecognizedEnumeratorValue = kAIYOU_G_P_BUnrecognizedEnumeratorValue,
BigTalkCommand_UnUsed = 0,
/** 响应成功 */
BigTalkCommand_Success = 200,
/** 响应失败 */
BigTalkCommand_Fail = -200,
/** 功能未开放 */
BigTalkCommand_FailFnNotOpen = 189,
/** 发送P2P消息 */
BigTalkCommand_Rt10000 = 10000,
/** 接收P2P消息 */
BigTalkCommand_Rt10002 = 10002,
/** P2P历史消息 */
BigTalkCommand_Rt10003 = 10003,
/** 发送世界聊天 */
BigTalkCommand_Rt12000 = 12000,
/** 接收世界聊天 */
BigTalkCommand_Rt12002 = 12002,
/** 世界聊天历史消息 */
BigTalkCommand_Rt12003 = 12003,
/** 发送公会消息 */
BigTalkCommand_Rt13000 = 13000,
/** 接收公会消息 */
BigTalkCommand_Rt13001 = 13001,
/** 公会历史消息查询 */
BigTalkCommand_Rt13002 = 13002,
/** 发送群组聊天消息 */
BigTalkCommand_Rt14000 = 14000,
/** 接收群组聊天消息 */
BigTalkCommand_Rt14001 = 14001,
/** 群组聊天历史消息 */
BigTalkCommand_Rt14002 = 14002,
/** 创建群组聊天 */
BigTalkCommand_Rt14003 = 14003,
/** 拉人进群组,群组成员都可以邀请她人进入群组。无需对方同意。 */
BigTalkCommand_Rt14004 = 14004,
/** 退出群组,群组成员都可以退出群组 */
BigTalkCommand_Rt14005 = 14005,
/** 群组踢人,创建群组的人可以提其他成员 */
BigTalkCommand_Rt14006 = 14006,
/** 解散群组,创建群组的人可以解散群组 */
BigTalkCommand_Rt14007 = 14007,
/** 查询群组成员 */
BigTalkCommand_Rt14008 = 14008,
/** 修改群聊名称 */
BigTalkCommand_Rt14009 = 14009,
/** 查询我的群组 */
BigTalkCommand_Rt14010 = 14010,
/** 邀请进群通知。谁邀请了谁进群。发给所有群成员 */
BigTalkCommand_Msg14011 = 14011,
/** 退群通知。谁退群了 */
BigTalkCommand_Msg14012 = 14012,
/** 群解散通知 */
BigTalkCommand_Msg14013 = 14013,
/** 群名称改变通知 */
BigTalkCommand_Msg14014 = 14014,
/** 加入群组 */
BigTalkCommand_Rt14015 = 14015,
/** 查询离线消息 */
BigTalkCommand_Rt15000 = 15000,
/** 举报用户 */
BigTalkCommand_Rt15001 = 15001,
};
AIYOU_G_P_BEnumDescriptor *BigTalkCommand_EnumDescriptor(void);
/**
* Checks to see if the given value is defined by the enum or was not known at
* the time this source was generated.
**/
BOOL BigTalkCommand_IsValidValue(int32_t value);
#pragma mark - Enum Chat_MsgType
typedef AIYOU_G_P_B_ENUM(Chat_MsgType) {
/**
* Value used if any message's field encounters a value that is not defined
* by this enum. The message will also have C functions to get/set the rawValue
* of the field.
**/
Chat_MsgType_AIYOU_G_P_BUnrecognizedEnumeratorValue = kAIYOU_G_P_BUnrecognizedEnumeratorValue,
Chat_MsgType_Text = 0,
Chat_MsgType_Image = 1,
Chat_MsgType_Audio = 2,
Chat_MsgType_Video = 3,
Chat_MsgType_Link = 4,
};
AIYOU_G_P_BEnumDescriptor *Chat_MsgType_EnumDescriptor(void);
/**
* Checks to see if the given value is defined by the enum or was not known at
* the time this source was generated.
**/
BOOL Chat_MsgType_IsValidValue(int32_t value);
#pragma mark - Enum RichText_RichTextType
typedef AIYOU_G_P_B_ENUM(RichText_RichTextType) {
/**
* Value used if any message's field encounters a value that is not defined
* by this enum. The message will also have C functions to get/set the rawValue
* of the field.
**/
RichText_RichTextType_AIYOU_G_P_BUnrecognizedEnumeratorValue = kAIYOU_G_P_BUnrecognizedEnumeratorValue,
/** 网页 */
RichText_RichTextType_WebPage = 0,
/** 指令 */
RichText_RichTextType_Command = 1,
};
AIYOU_G_P_BEnumDescriptor *RichText_RichTextType_EnumDescriptor(void);
/**
* Checks to see if the given value is defined by the enum or was not known at
* the time this source was generated.
**/
BOOL RichText_RichTextType_IsValidValue(int32_t value);
#pragma mark - Enum request_15001_ReportType
typedef AIYOU_G_P_B_ENUM(request_15001_ReportType) {
/**
* Value used if any message's field encounters a value that is not defined
* by this enum. The message will also have C functions to get/set the rawValue
* of the field.
**/
request_15001_ReportType_AIYOU_G_P_BUnrecognizedEnumeratorValue = kAIYOU_G_P_BUnrecognizedEnumeratorValue,
/** 色情 */
request_15001_ReportType_Sexy = 0,
/** 辱骂 */
request_15001_ReportType_Abuse = 1,
/** 其他 */
request_15001_ReportType_Other = 2,
};
AIYOU_G_P_BEnumDescriptor *request_15001_ReportType_EnumDescriptor(void);
/**
* Checks to see if the given value is defined by the enum or was not known at
* the time this source was generated.
**/
BOOL request_15001_ReportType_IsValidValue(int32_t value);
#pragma mark - BigTalkMessageRoot
/**
* Exposes the extension registry for this file.
*
* The base class provides:
* @code
* + (AIYOU_G_P_BExtensionRegistry *)extensionRegistry;
* @endcode
* which is a @c AIYOU_G_P_BExtensionRegistry that includes all the extensions defined by
* this file and all files that it depends on.
**/
@interface BigTalkMessageRoot : AIYOU_G_P_BRootObject
@end
#pragma mark - Chat
typedef AIYOU_G_P_B_ENUM(Chat_FieldNumber) {
Chat_FieldNumber_MsgId = 1,
Chat_FieldNumber_MsgType = 2,
Chat_FieldNumber_FromTicketId = 3,
Chat_FieldNumber_FromNickName = 4,
Chat_FieldNumber_FromIcon = 5,
Chat_FieldNumber_ToTicketId = 6,
Chat_FieldNumber_Message = 7,
Chat_FieldNumber_CallTicketIdsArray = 8,
Chat_FieldNumber_Time = 9,
Chat_FieldNumber_SoundTime = 10,
Chat_FieldNumber_Thumbnail = 11,
};
/**
* *
* 消息对象
**/
@interface Chat : AIYOU_G_P_BMessage
/**
* *
* 本地msgid,校验使用
* 比如发送失败,可以重发此消息
**/
@property(nonatomic, readwrite, copy, null_resettable) NSString *msgId;
/**
* *
* 消息类型
**/
@property(nonatomic, readwrite) Chat_MsgType msgType;
/**
* *
* 发送方uid
* 每个消息都需要注明发送者。尤其是世界聊天,群聊
**/
@property(nonatomic, readwrite, copy, null_resettable) NSString *fromTicketId;
/**
* *
* 昵称
* 发送者昵称
**/
@property(nonatomic, readwrite, copy, null_resettable) NSString *fromNickName;
/**
* *
* 头像索引
* 发送者头像
**/
@property(nonatomic, readwrite, copy, null_resettable) NSString *fromIcon;
/**
* *
* 接收方uid
**/
@property(nonatomic, readwrite, copy, null_resettable) NSString *toTicketId;
/**
* *
* 消息内容
* 消息类型为text时,文本消息
**/
@property(nonatomic, readwrite, copy, null_resettable) NSString *message;
/** 缩略图地址 */
@property(nonatomic, readwrite, copy, null_resettable) NSString *thumbnail;
/**
* *
* 群聊时,被\@成员集合
**/
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<NSString*> *callTicketIdsArray;
/** The number of items in @c callTicketIdsArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger callTicketIdsArray_Count;
/**
* *
* 时间戳
**/
@property(nonatomic, readwrite) int64_t time;
/**
* *
* 音频时间
**/
@property(nonatomic, readwrite) int32_t soundTime;
@end
/**
* Fetches the raw value of a @c Chat's @c msgType property, even
* if the value was not defined by the enum at the time the code was generated.
**/
int32_t Chat_MsgType_RawValue(Chat *message);
/**
* Sets the raw value of an @c Chat's @c msgType property, allowing
* it to be set to a value that was not defined by the enum at the time the code
* was generated.
**/
void SetChat_MsgType_RawValue(Chat *message, int32_t value);
#pragma mark - RichText
typedef AIYOU_G_P_B_ENUM(RichText_FieldNumber) {
RichText_FieldNumber_Type = 1,
RichText_FieldNumber_Title = 2,
RichText_FieldNumber_Description_p = 3,
RichText_FieldNumber_URL = 4,
RichText_FieldNumber_Paras = 5,
RichText_FieldNumber_CommandId = 6,
};
@interface RichText : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) RichText_RichTextType type;
/** 标题 */
@property(nonatomic, readwrite, copy, null_resettable) NSString *title;
/** 描述 */
@property(nonatomic, readwrite, copy, null_resettable) NSString *description_p;
/** 网页地址 */
@property(nonatomic, readwrite, copy, null_resettable) NSString *URL;
/** 参数 */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableDictionary<NSString*, NSString*> *paras;
/** The number of items in @c paras without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger paras_Count;
/** 命令ID */
@property(nonatomic, readwrite) int32_t commandId;
@end
/**
* Fetches the raw value of a @c RichText's @c type property, even
* if the value was not defined by the enum at the time the code was generated.
**/
int32_t RichText_Type_RawValue(RichText *message);
/**
* Sets the raw value of an @c RichText's @c type property, allowing
* it to be set to a value that was not defined by the enum at the time the code
* was generated.
**/
void SetRichText_Type_RawValue(RichText *message, int32_t value);
#pragma mark - request_10000
typedef AIYOU_G_P_B_ENUM(request_10000_FieldNumber) {
request_10000_FieldNumber_Message = 1,
};
/**
* *
* 客户端发送P2P消息
**/
@interface request_10000 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite, strong, null_resettable) Chat *message;
/** Test to see if @c message has been set. */
@property(nonatomic, readwrite) BOOL hasMessage;
@end
#pragma mark - response_10000
typedef AIYOU_G_P_B_ENUM(response_10000_FieldNumber) {
response_10000_FieldNumber_Result = 1,
response_10000_FieldNumber_Message = 2,
response_10000_FieldNumber_MsgId = 3,
response_10000_FieldNumber_Time = 4,
};
@interface response_10000 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t result;
@property(nonatomic, readwrite, copy, null_resettable) NSString *message;
@property(nonatomic, readwrite, copy, null_resettable) NSString *msgId;
/** 发送时间 */
@property(nonatomic, readwrite) int64_t time;
@end
#pragma mark - response_10002
typedef AIYOU_G_P_B_ENUM(response_10002_FieldNumber) {
response_10002_FieldNumber_Message = 1,
};
/**
* 接收P2P消息
**/
@interface response_10002 : AIYOU_G_P_BMessage
/** P2P聊天体 */
@property(nonatomic, readwrite, strong, null_resettable) Chat *message;
/** Test to see if @c message has been set. */
@property(nonatomic, readwrite) BOOL hasMessage;
@end
#pragma mark - request_10003
typedef AIYOU_G_P_B_ENUM(request_10003_FieldNumber) {
request_10003_FieldNumber_Other = 1,
request_10003_FieldNumber_StartTime = 2,
request_10003_FieldNumber_EndTime = 3,
request_10003_FieldNumber_PagePb = 4,
};
/**
* *
* 拉取私聊历史消息
**/
@interface request_10003 : AIYOU_G_P_BMessage
/** 聊天人 */
@property(nonatomic, readwrite, copy, null_resettable) NSString *other;
/** 会话查询开始时间 */
@property(nonatomic, readwrite) int64_t startTime;
/** 会话查询结束时间 */
@property(nonatomic, readwrite) int64_t endTime;
/** 分页 */
@property(nonatomic, readwrite, strong, null_resettable) PagePB *pagePb;
/** Test to see if @c pagePb has been set. */
@property(nonatomic, readwrite) BOOL hasPagePb;
@end
#pragma mark - response_10003
typedef AIYOU_G_P_B_ENUM(response_10003_FieldNumber) {
response_10003_FieldNumber_ResultCode = 1,
response_10003_FieldNumber_ResultMessage = 2,
response_10003_FieldNumber_MessageArray = 3,
response_10003_FieldNumber_PagePb = 4,
};
@interface response_10003 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t resultCode;
@property(nonatomic, readwrite, copy, null_resettable) NSString *resultMessage;
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<Chat*> *messageArray;
/** The number of items in @c messageArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger messageArray_Count;
/** 分页 */
@property(nonatomic, readwrite, strong, null_resettable) PagePB *pagePb;
/** Test to see if @c pagePb has been set. */
@property(nonatomic, readwrite) BOOL hasPagePb;
@end
#pragma mark - request_12000
typedef AIYOU_G_P_B_ENUM(request_12000_FieldNumber) {
request_12000_FieldNumber_Message = 1,
};
/**
* *
* 发送世界聊天
**/
@interface request_12000 : AIYOU_G_P_BMessage
/**
* *
* Msg.Chat
**/
@property(nonatomic, readwrite, strong, null_resettable) Chat *message;
/** Test to see if @c message has been set. */
@property(nonatomic, readwrite) BOOL hasMessage;
@end
#pragma mark - response_12000
typedef AIYOU_G_P_B_ENUM(response_12000_FieldNumber) {
response_12000_FieldNumber_Result = 1,
response_12000_FieldNumber_MsgId = 2,
response_12000_FieldNumber_Message = 3,
};
@interface response_12000 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t result;
@property(nonatomic, readwrite, copy, null_resettable) NSString *msgId;
@property(nonatomic, readwrite, copy, null_resettable) NSString *message;
@end
#pragma mark - response_12002
typedef AIYOU_G_P_B_ENUM(response_12002_FieldNumber) {
response_12002_FieldNumber_Message = 1,
};
/**
* 接收世界消息
**/
@interface response_12002 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite, strong, null_resettable) Chat *message;
/** Test to see if @c message has been set. */
@property(nonatomic, readwrite) BOOL hasMessage;
@end
#pragma mark - request_12003
typedef AIYOU_G_P_B_ENUM(request_12003_FieldNumber) {
request_12003_FieldNumber_StartTime = 1,
request_12003_FieldNumber_EndTime = 2,
request_12003_FieldNumber_PagePb = 3,
};
/**
* *
* 查询世界聊天历史消息
**/
@interface request_12003 : AIYOU_G_P_BMessage
/** 会话查询开始时间 */
@property(nonatomic, readwrite) int64_t startTime;
/** 会话查询结束时间 */
@property(nonatomic, readwrite) int64_t endTime;
/** 分页 */
@property(nonatomic, readwrite, strong, null_resettable) PagePB *pagePb;
/** Test to see if @c pagePb has been set. */
@property(nonatomic, readwrite) BOOL hasPagePb;
@end
#pragma mark - response_12003
typedef AIYOU_G_P_B_ENUM(response_12003_FieldNumber) {
response_12003_FieldNumber_ResultCode = 1,
response_12003_FieldNumber_ResultMessage = 2,
response_12003_FieldNumber_MessageArray = 3,
response_12003_FieldNumber_PagePb = 4,
};
@interface response_12003 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t resultCode;
@property(nonatomic, readwrite, copy, null_resettable) NSString *resultMessage;
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<Chat*> *messageArray;
/** The number of items in @c messageArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger messageArray_Count;
/** 分页 */
@property(nonatomic, readwrite, strong, null_resettable) PagePB *pagePb;
/** Test to see if @c pagePb has been set. */
@property(nonatomic, readwrite) BOOL hasPagePb;
@end
#pragma mark - request_13000
typedef AIYOU_G_P_B_ENUM(request_13000_FieldNumber) {
request_13000_FieldNumber_GuildId = 1,
request_13000_FieldNumber_Message = 2,
};
/**
* *
* 公会聊天
**/
@interface request_13000 : AIYOU_G_P_BMessage
/** 公会id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *guildId;
@property(nonatomic, readwrite, strong, null_resettable) Chat *message;
/** Test to see if @c message has been set. */
@property(nonatomic, readwrite) BOOL hasMessage;
@end
#pragma mark - response_13000
typedef AIYOU_G_P_B_ENUM(response_13000_FieldNumber) {
response_13000_FieldNumber_ResultCode = 1,
response_13000_FieldNumber_ResultMessage = 2,
};
@interface response_13000 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t resultCode;
@property(nonatomic, readwrite, copy, null_resettable) NSString *resultMessage;
@end
#pragma mark - response_13001
typedef AIYOU_G_P_B_ENUM(response_13001_FieldNumber) {
response_13001_FieldNumber_GuildId = 1,
response_13001_FieldNumber_Message = 2,
};
/**
* 接收公会聊天消息
**/
@interface response_13001 : AIYOU_G_P_BMessage
/** 公会id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *guildId;
@property(nonatomic, readwrite, strong, null_resettable) Chat *message;
/** Test to see if @c message has been set. */
@property(nonatomic, readwrite) BOOL hasMessage;
@end
#pragma mark - request_13002
typedef AIYOU_G_P_B_ENUM(request_13002_FieldNumber) {
request_13002_FieldNumber_GuildId = 1,
request_13002_FieldNumber_StartTime = 2,
request_13002_FieldNumber_EndTime = 3,
request_13002_FieldNumber_PagePb = 4,
};
/**
* *
* 拉取公会历史消息
**/
@interface request_13002 : AIYOU_G_P_BMessage
/** 公会id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *guildId;
/** 会话查询开始时间 */
@property(nonatomic, readwrite) int64_t startTime;
/** 会话查询结束时间 */
@property(nonatomic, readwrite) int64_t endTime;
/** 分页 */
@property(nonatomic, readwrite, strong, null_resettable) PagePB *pagePb;
/** Test to see if @c pagePb has been set. */
@property(nonatomic, readwrite) BOOL hasPagePb;
@end
#pragma mark - response_13002
typedef AIYOU_G_P_B_ENUM(response_13002_FieldNumber) {
response_13002_FieldNumber_ResultCode = 1,
response_13002_FieldNumber_ResultMessage = 2,
response_13002_FieldNumber_MessageArray = 3,
response_13002_FieldNumber_PagePb = 4,
};
@interface response_13002 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t resultCode;
@property(nonatomic, readwrite, copy, null_resettable) NSString *resultMessage;
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<Chat*> *messageArray;
/** The number of items in @c messageArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger messageArray_Count;
/** 分页 */
@property(nonatomic, readwrite, strong, null_resettable) PagePB *pagePb;
/** Test to see if @c pagePb has been set. */
@property(nonatomic, readwrite) BOOL hasPagePb;
@end
#pragma mark - request_14000
typedef AIYOU_G_P_B_ENUM(request_14000_FieldNumber) {
request_14000_FieldNumber_BtId = 1,
request_14000_FieldNumber_Message = 2,
};
/**
* *
* 组队聊天
**/
@interface request_14000 : AIYOU_G_P_BMessage
/** 组队id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
@property(nonatomic, readwrite, strong, null_resettable) Chat *message;
/** Test to see if @c message has been set. */
@property(nonatomic, readwrite) BOOL hasMessage;
@end
#pragma mark - response_14000
typedef AIYOU_G_P_B_ENUM(response_14000_FieldNumber) {
response_14000_FieldNumber_ResultCode = 1,
response_14000_FieldNumber_ResultMessage = 2,
response_14000_FieldNumber_MsgId = 3,
};
@interface response_14000 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t resultCode;
@property(nonatomic, readwrite, copy, null_resettable) NSString *resultMessage;
/** 消息编号 */
@property(nonatomic, readwrite, copy, null_resettable) NSString *msgId;
@end
#pragma mark - response_14001
typedef AIYOU_G_P_B_ENUM(response_14001_FieldNumber) {
response_14001_FieldNumber_BtId = 1,
response_14001_FieldNumber_Message = 2,
};
/**
* 接收组队消息
**/
@interface response_14001 : AIYOU_G_P_BMessage
/** 组队id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
@property(nonatomic, readwrite, strong, null_resettable) Chat *message;
/** Test to see if @c message has been set. */
@property(nonatomic, readwrite) BOOL hasMessage;
@end
#pragma mark - request_14002
typedef AIYOU_G_P_B_ENUM(request_14002_FieldNumber) {
request_14002_FieldNumber_BtId = 1,
request_14002_FieldNumber_StartTime = 2,
request_14002_FieldNumber_EndTime = 3,
request_14002_FieldNumber_PagePb = 4,
};
/**
* *
* 拉取组队历史消息
**/
@interface request_14002 : AIYOU_G_P_BMessage
/** 公会id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
/** 会话查询开始时间 */
@property(nonatomic, readwrite) int64_t startTime;
/** 会话查询结束时间 */
@property(nonatomic, readwrite) int64_t endTime;
/** 分页 */
@property(nonatomic, readwrite, strong, null_resettable) PagePB *pagePb;
/** Test to see if @c pagePb has been set. */
@property(nonatomic, readwrite) BOOL hasPagePb;
@end
#pragma mark - response_14002
typedef AIYOU_G_P_B_ENUM(response_14002_FieldNumber) {
response_14002_FieldNumber_ResultCode = 1,
response_14002_FieldNumber_ResultMessage = 2,
response_14002_FieldNumber_MessageArray = 3,
response_14002_FieldNumber_PagePb = 4,
};
@interface response_14002 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t resultCode;
@property(nonatomic, readwrite, copy, null_resettable) NSString *resultMessage;
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<Chat*> *messageArray;
/** The number of items in @c messageArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger messageArray_Count;
/** 分页 */
@property(nonatomic, readwrite, strong, null_resettable) PagePB *pagePb;
/** Test to see if @c pagePb has been set. */
@property(nonatomic, readwrite) BOOL hasPagePb;
@end
#pragma mark - request_14003
typedef AIYOU_G_P_B_ENUM(request_14003_FieldNumber) {
request_14003_FieldNumber_Name = 1,
request_14003_FieldNumber_MembersArray = 2,
};
/**
* *
* 创建群组聊天
**/
@interface request_14003 : AIYOU_G_P_BMessage
/** 群组名称 */
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
/** 创建群组时,可以拉其他成员一起组建群组 */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<NSString*> *membersArray;
/** The number of items in @c membersArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger membersArray_Count;
@end
#pragma mark - response_14003
typedef AIYOU_G_P_B_ENUM(response_14003_FieldNumber) {
response_14003_FieldNumber_ResultCode = 1,
response_14003_FieldNumber_ResultMessage = 2,
response_14003_FieldNumber_BtId = 3,
response_14003_FieldNumber_Name = 4,
response_14003_FieldNumber_MembersArray = 5,
};
@interface response_14003 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t resultCode;
@property(nonatomic, readwrite, copy, null_resettable) NSString *resultMessage;
/** 群组ID */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
/** 群组名称 */
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
/** 创建群组时,可以拉其他成员一起组建群组 */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<NSString*> *membersArray;
/** The number of items in @c membersArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger membersArray_Count;
@end
#pragma mark - request_14004
typedef AIYOU_G_P_B_ENUM(request_14004_FieldNumber) {
request_14004_FieldNumber_BtId = 1,
request_14004_FieldNumber_MembersArray = 2,
};
/**
* *
* 拉人进群组
**/
@interface request_14004 : AIYOU_G_P_BMessage
/** 群组Id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
/** 被邀请进群组人员ID */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<NSString*> *membersArray;
/** The number of items in @c membersArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger membersArray_Count;
@end
#pragma mark - response_14004
typedef AIYOU_G_P_B_ENUM(response_14004_FieldNumber) {
response_14004_FieldNumber_ResultCode = 1,
response_14004_FieldNumber_ResultMessage = 2,
response_14004_FieldNumber_BtId = 3,
response_14004_FieldNumber_MembersArray = 4,
};
@interface response_14004 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t resultCode;
@property(nonatomic, readwrite, copy, null_resettable) NSString *resultMessage;
/** 群组Id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
/** 被邀请进群组人员ID */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<NSString*> *membersArray;
/** The number of items in @c membersArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger membersArray_Count;
@end
#pragma mark - request_14005
typedef AIYOU_G_P_B_ENUM(request_14005_FieldNumber) {
request_14005_FieldNumber_BtId = 1,
};
/**
* *
* 退出群组
**/
@interface request_14005 : AIYOU_G_P_BMessage
/** 群组Id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
@end
#pragma mark - response_14005
typedef AIYOU_G_P_B_ENUM(response_14005_FieldNumber) {
response_14005_FieldNumber_ResultCode = 1,
response_14005_FieldNumber_ResultMessage = 2,
response_14005_FieldNumber_BtId = 3,
};
@interface response_14005 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t resultCode;
@property(nonatomic, readwrite, copy, null_resettable) NSString *resultMessage;
/** 群组Id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
@end
#pragma mark - request_14006
typedef AIYOU_G_P_B_ENUM(request_14006_FieldNumber) {
request_14006_FieldNumber_BtId = 1,
request_14006_FieldNumber_Member = 2,
};
/**
* *
* 踢人,创建人可以踢人
**/
@interface request_14006 : AIYOU_G_P_BMessage
/** 群组Id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
/** 被踢成员ID */
@property(nonatomic, readwrite, copy, null_resettable) NSString *member;
@end
#pragma mark - response_14006
typedef AIYOU_G_P_B_ENUM(response_14006_FieldNumber) {
response_14006_FieldNumber_ResultCode = 1,
response_14006_FieldNumber_ResultMessage = 2,
response_14006_FieldNumber_BtId = 3,
response_14006_FieldNumber_Member = 4,
};
@interface response_14006 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t resultCode;
@property(nonatomic, readwrite, copy, null_resettable) NSString *resultMessage;
/** 群组Id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
/** 被踢成员ID */
@property(nonatomic, readwrite, copy, null_resettable) NSString *member;
@end
#pragma mark - request_14007
typedef AIYOU_G_P_B_ENUM(request_14007_FieldNumber) {
request_14007_FieldNumber_BtId = 1,
};
/**
* *
* 解散群组,创建人可以解散
**/
@interface request_14007 : AIYOU_G_P_BMessage
/** 群组Id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
@end
#pragma mark - response_14007
typedef AIYOU_G_P_B_ENUM(response_14007_FieldNumber) {
response_14007_FieldNumber_ResultCode = 1,
response_14007_FieldNumber_ResultMessage = 2,
response_14007_FieldNumber_BtId = 3,
};
@interface response_14007 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t resultCode;
@property(nonatomic, readwrite, copy, null_resettable) NSString *resultMessage;
/** 群组Id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
@end
#pragma mark - request_14008
typedef AIYOU_G_P_B_ENUM(request_14008_FieldNumber) {
request_14008_FieldNumber_BtId = 1,
};
/**
* *
* 查询群组成员
**/
@interface request_14008 : AIYOU_G_P_BMessage
/** 群组Id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
@end
#pragma mark - response_14008
typedef AIYOU_G_P_B_ENUM(response_14008_FieldNumber) {
response_14008_FieldNumber_ResultCode = 1,
response_14008_FieldNumber_ResultMessage = 2,
response_14008_FieldNumber_BtId = 3,
response_14008_FieldNumber_MembersArray = 4,
};
@interface response_14008 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t resultCode;
@property(nonatomic, readwrite, copy, null_resettable) NSString *resultMessage;
/** 群组Id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
/** 群组成员 */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<BaseUserInfo*> *membersArray;
/** The number of items in @c membersArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger membersArray_Count;
@end
#pragma mark - request_14009
typedef AIYOU_G_P_B_ENUM(request_14009_FieldNumber) {
request_14009_FieldNumber_BtId = 1,
request_14009_FieldNumber_Name = 2,
};
/**
* *
* 修改群组名称
**/
@interface request_14009 : AIYOU_G_P_BMessage
/** 群组Id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
@end
#pragma mark - response_14009
typedef AIYOU_G_P_B_ENUM(response_14009_FieldNumber) {
response_14009_FieldNumber_ResultCode = 1,
response_14009_FieldNumber_ResultMessage = 2,
response_14009_FieldNumber_BtId = 3,
response_14009_FieldNumber_Name = 4,
};
@interface response_14009 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t resultCode;
@property(nonatomic, readwrite, copy, null_resettable) NSString *resultMessage;
/** 群组Id */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
@end
#pragma mark - request_14010
/**
* *
* 查询我的群组
**/
@interface request_14010 : AIYOU_G_P_BMessage
@end
#pragma mark - response_14010
typedef AIYOU_G_P_B_ENUM(response_14010_FieldNumber) {
response_14010_FieldNumber_ResultCode = 1,
response_14010_FieldNumber_ResultMessage = 2,
response_14010_FieldNumber_TeamMap = 3,
};
@interface response_14010 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t resultCode;
@property(nonatomic, readwrite, copy, null_resettable) NSString *resultMessage;
/** btId:name 群组ID:群组名称 */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableDictionary<NSString*, NSString*> *teamMap;
/** The number of items in @c teamMap without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger teamMap_Count;
@end
#pragma mark - response_14011
typedef AIYOU_G_P_B_ENUM(response_14011_FieldNumber) {
response_14011_FieldNumber_BtId = 1,
response_14011_FieldNumber_From = 2,
response_14011_FieldNumber_ToListArray = 3,
};
/**
* *
* 邀请进群通知。谁邀请了谁进群。发给所有群成员
*
* *
**/
@interface response_14011 : AIYOU_G_P_BMessage
/** 群组ID */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
/** 邀请者 */
@property(nonatomic, readwrite, strong, null_resettable) BaseUserInfo *from;
/** Test to see if @c from has been set. */
@property(nonatomic, readwrite) BOOL hasFrom;
/** 被邀请者集合 */
@property(nonatomic, readwrite, strong, null_resettable) NSMutableArray<BaseUserInfo*> *toListArray;
/** The number of items in @c toListArray without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger toListArray_Count;
@end
#pragma mark - response_14012
typedef AIYOU_G_P_B_ENUM(response_14012_FieldNumber) {
response_14012_FieldNumber_BtId = 1,
response_14012_FieldNumber_Flag = 2,
response_14012_FieldNumber_From = 3,
response_14012_FieldNumber_To = 4,
};
/**
* *
* 退群,踢人通知
**/
@interface response_14012 : AIYOU_G_P_BMessage
/** 群组ID */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
/** true 主动退群,false 被踢 */
@property(nonatomic, readwrite) BOOL flag;
/** 踢人者。如果是主动退群,则为空 */
@property(nonatomic, readwrite, strong, null_resettable) BaseUserInfo *from;
/** Test to see if @c from has been set. */
@property(nonatomic, readwrite) BOOL hasFrom;
/** 被踢者,或主动退群者 */
@property(nonatomic, readwrite, strong, null_resettable) BaseUserInfo *to;
/** Test to see if @c to has been set. */
@property(nonatomic, readwrite) BOOL hasTo;
@end
#pragma mark - response_14013
typedef AIYOU_G_P_B_ENUM(response_14013_FieldNumber) {
response_14013_FieldNumber_BtId = 1,
};
/**
* *
* 群组解散通知
**/
@interface response_14013 : AIYOU_G_P_BMessage
/** 群组ID */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
@end
#pragma mark - response_14014
typedef AIYOU_G_P_B_ENUM(response_14014_FieldNumber) {
response_14014_FieldNumber_BtId = 1,
response_14014_FieldNumber_From = 2,
response_14014_FieldNumber_Name = 3,
};
/**
* *
* 修改群名通知
**/
@interface response_14014 : AIYOU_G_P_BMessage
/** 群组ID */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
/** 修改群名称者 */
@property(nonatomic, readwrite, strong, null_resettable) BaseUserInfo *from;
/** Test to see if @c from has been set. */
@property(nonatomic, readwrite) BOOL hasFrom;
/** 新的群名 */
@property(nonatomic, readwrite, copy, null_resettable) NSString *name;
@end
#pragma mark - request_14015
typedef AIYOU_G_P_B_ENUM(request_14015_FieldNumber) {
request_14015_FieldNumber_BtId = 1,
};
/**
* 加入群组
**/
@interface request_14015 : AIYOU_G_P_BMessage
/** 群组ID */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
@end
#pragma mark - response_14015
typedef AIYOU_G_P_B_ENUM(response_14015_FieldNumber) {
response_14015_FieldNumber_ResultCode = 1,
response_14015_FieldNumber_ResultMessage = 2,
response_14015_FieldNumber_BtId = 3,
};
@interface response_14015 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t resultCode;
@property(nonatomic, readwrite, copy, null_resettable) NSString *resultMessage;
/** 群组ID */
@property(nonatomic, readwrite, copy, null_resettable) NSString *btId;
@end
#pragma mark - request_15000
@interface request_15000 : AIYOU_G_P_BMessage
@end
#pragma mark - response_15000
typedef AIYOU_G_P_B_ENUM(response_15000_FieldNumber) {
response_15000_FieldNumber_ResultCode = 1,
response_15000_FieldNumber_ResultMessage = 2,
response_15000_FieldNumber_HistoryMessage = 3,
};
@interface response_15000 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t resultCode;
@property(nonatomic, readwrite, copy, null_resettable) NSString *resultMessage;
/** 离线消息,用户code对应响应未读消息 */
@property(nonatomic, readwrite, strong, null_resettable) AIYOU_G_P_BStringInt32Dictionary *historyMessage;
/** The number of items in @c historyMessage without causing the array to be created. */
@property(nonatomic, readonly) NSUInteger historyMessage_Count;
@end
#pragma mark - request_15001
typedef AIYOU_G_P_B_ENUM(request_15001_FieldNumber) {
request_15001_FieldNumber_TicketId = 1,
request_15001_FieldNumber_ReportType = 2,
};
@interface request_15001 : AIYOU_G_P_BMessage
/** 被举报人ID */
@property(nonatomic, readwrite, copy, null_resettable) NSString *ticketId;
@property(nonatomic, readwrite) request_15001_ReportType reportType;
@end
/**
* Fetches the raw value of a @c request_15001's @c reportType property, even
* if the value was not defined by the enum at the time the code was generated.
**/
int32_t request_15001_ReportType_RawValue(request_15001 *message);
/**
* Sets the raw value of an @c request_15001's @c reportType property, allowing
* it to be set to a value that was not defined by the enum at the time the code
* was generated.
**/
void Setrequest_15001_ReportType_RawValue(request_15001 *message, int32_t value);
#pragma mark - response_15001
typedef AIYOU_G_P_B_ENUM(response_15001_FieldNumber) {
response_15001_FieldNumber_ResultCode = 1,
response_15001_FieldNumber_ResultMessage = 2,
response_15001_FieldNumber_TicketId = 3,
};
@interface response_15001 : AIYOU_G_P_BMessage
@property(nonatomic, readwrite) int32_t resultCode;
@property(nonatomic, readwrite, copy, null_resettable) NSString *resultMessage;
/** 被举报人ID */
@property(nonatomic, readwrite, copy, null_resettable) NSString *ticketId;
@end
NS_ASSUME_NONNULL_END
CF_EXTERN_C_END
#pragma clang diagnostic pop
// @@protoc_insertion_point(global_scope)
| 25.377318 | 125 | 0.766604 |
55e8a8d4aba517fa6407acb0a6d0063df2f02615 | 612 | h | C | vidi/core/LoadProgressBar.h | stjordanis/ViDi | 91a001e024ee03a1a4fb07a8c11e6d66a04306f1 | [
"BSD-2-Clause"
] | 77 | 2016-10-29T23:00:23.000Z | 2021-12-26T13:15:22.000Z | vidi/core/LoadProgressBar.h | stjordanis/ViDi | 91a001e024ee03a1a4fb07a8c11e6d66a04306f1 | [
"BSD-2-Clause"
] | 2 | 2018-03-27T14:47:11.000Z | 2019-11-29T02:06:08.000Z | vidi/core/LoadProgressBar.h | stjordanis/ViDi | 91a001e024ee03a1a4fb07a8c11e6d66a04306f1 | [
"BSD-2-Clause"
] | 23 | 2016-10-30T23:28:38.000Z | 2021-12-23T08:34:56.000Z | #pragma once
#include <QtWidgets>
//autodeleting on finish
class LoadProgressBar : public QProgressBar
{
Q_OBJECT
public:
LoadProgressBar(QWidget *parent)
: QProgressBar(parent)
{
setValue(0);
setMaximum(100);
}
~LoadProgressBar()
{
printf("~LoadProgressBar\n");
}
public slots:
void setValue(int value)
{
if (value > minimum()) {
this->setVisible(true);
}
QProgressBar::setValue(value);
if (value >= maximum()) {
this->setVisible(false);
delete(this);
}
}
};
| 17.485714 | 43 | 0.545752 |
1d7195ef68abb8d93a1b1972c6d462bdabb85f00 | 4,952 | c | C | learn-cmus/history.c | liuluheng/codereading | 5ce1c16cac788856e51da97f3a4786d6f0edc633 | [
"MIT"
] | null | null | null | learn-cmus/history.c | liuluheng/codereading | 5ce1c16cac788856e51da97f3a4786d6f0edc633 | [
"MIT"
] | null | null | null | learn-cmus/history.c | liuluheng/codereading | 5ce1c16cac788856e51da97f3a4786d6f0edc633 | [
"MIT"
] | null | null | null | /*
* Copyright 2008-2013 Various Authors
* Copyright 2004-2005 Timo Hirvonen
*
* 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/>.
*/
#include "history.h"
#include "xmalloc.h"
#include "file.h"
#include "uchar.h"
#include "list.h"
#include "prog.h"
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
struct history_entry {
struct list_head node;
char *text;
};
static struct history_entry *history_entry_new(const char *text)
{
struct history_entry *new;
new = xnew(struct history_entry, 1);
new->text = xstrdup(text);
return new;
}
static void history_entry_free(struct history_entry *history)
{
free(history->text);
free(history);
}
void history_free(struct history *history)
{
struct list_head *item, *temp;
list_for_each_safe(item, temp, &history->head) {
struct history_entry *history_entry;
history_entry = list_entry(item, struct history_entry, node);
history_entry_free(history_entry);
}
}
static int history_add_tail(void *data, const char *line)
{
struct history *history = data;
if (history->lines < history->max_lines) {
struct history_entry *new;
new = history_entry_new(line);
list_add_tail(&new->node, &history->head);
history->lines++;
}
return 0;
}
void history_load(struct history *history, char *filename, int max_lines)
{
list_init(&history->head);
history->max_lines = max_lines;
history->lines = 0;
history->search_pos = NULL;
history->filename = filename;
file_for_each_line(filename, history_add_tail, history);
}
void history_save(struct history *history)
{
char filename_tmp[512];
struct list_head *item;
int fd;
ssize_t rc;
snprintf(filename_tmp, sizeof(filename_tmp), "%s.tmp", history->filename);
fd = open(filename_tmp, O_CREAT | O_WRONLY | O_TRUNC, 0666);
if (fd == -1)
return;
list_for_each(item, &history->head) {
struct history_entry *history_entry;
const char nl = '\n';
history_entry = list_entry(item, struct history_entry, node);
rc = write(fd, history_entry->text, strlen(history_entry->text));
if (rc == -1)
goto out;
rc = write(fd, &nl, 1);
if (rc == -1)
goto out;
}
out:
close(fd);
rc = rename(filename_tmp, history->filename);
if (rc)
warn_errno("renaming %s to %s", filename_tmp, history->filename);
}
void history_add_line(struct history *history, const char *line)
{
struct history_entry *new;
struct list_head *item;
new = history_entry_new(line);
list_add(&new->node, &history->head);
history->lines++;
/* remove identical */
item = history->head.next->next;
while (item != &history->head) {
struct list_head *next = item->next;
struct history_entry *hentry;
hentry = container_of(item, struct history_entry, node);
if (strcmp(hentry->text, new->text) == 0) {
list_del(item);
history_entry_free(hentry);
history->lines--;
}
item = next;
}
/* remove oldest if history is 'full' */
if (history->lines > history->max_lines) {
struct list_head *node;
struct history_entry *hentry;
node = history->head.prev;
list_del(node);
hentry = list_entry(node, struct history_entry, node);
history_entry_free(hentry);
history->lines--;
}
}
void history_reset_search(struct history *history)
{
history->search_pos = NULL;
}
const char *history_search_forward(struct history *history, const char *text)
{
struct list_head *item;
int search_len;
if (history->search_pos == NULL) {
/* first time to search. set search */
item = history->head.next;
} else {
item = history->search_pos->next;
}
search_len = strlen(text);
while (item != &history->head) {
struct history_entry *hentry;
hentry = list_entry(item, struct history_entry, node);
if (strncmp(text, hentry->text, search_len) == 0) {
history->search_pos = item;
return hentry->text;
}
item = item->next;
}
return NULL;
}
const char *history_search_backward(struct history *history, const char *text)
{
struct list_head *item;
int search_len;
if (history->search_pos == NULL)
return NULL;
item = history->search_pos->prev;
search_len = strlen(text);
while (item != &history->head) {
struct history_entry *hentry;
hentry = list_entry(item, struct history_entry, node);
if (strncmp(text, hentry->text, search_len) == 0) {
history->search_pos = item;
return hentry->text;
}
item = item->prev;
}
history->search_pos = NULL;
return NULL;
}
| 24.038835 | 78 | 0.706583 |
0ddc85b643a993c438c55a7d38f6b1d9b989be85 | 878 | h | C | onnxruntime/core/providers/cuda/math/gemm.h | hqucms/onnxruntime | 6e4e76414639f50836a64546603c8957227857b0 | [
"MIT"
] | 4 | 2019-06-06T23:48:57.000Z | 2021-06-03T11:51:45.000Z | onnxruntime/core/providers/cuda/math/gemm.h | hqucms/onnxruntime | 6e4e76414639f50836a64546603c8957227857b0 | [
"MIT"
] | 17 | 2020-07-21T11:13:27.000Z | 2022-03-27T02:37:05.000Z | onnxruntime/core/providers/cuda/math/gemm.h | hqucms/onnxruntime | 6e4e76414639f50836a64546603c8957227857b0 | [
"MIT"
] | 4 | 2021-06-05T19:52:22.000Z | 2021-11-30T13:58:13.000Z | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include "core/providers/cuda/cuda_common.h"
namespace onnxruntime {
namespace cuda {
template <typename T>
class Gemm final : public CudaKernel {
using Base = CudaKernel;
public:
Gemm(const OpKernelInfo& info) : CudaKernel(info) {
int64_t temp;
ORT_ENFORCE(info.GetAttr<int64_t>("transA", &temp).IsOK());
trans_A_ = (temp != 0);
ORT_ENFORCE(info.GetAttr<int64_t>("transB", &temp).IsOK());
trans_B_ = (temp != 0);
ORT_ENFORCE(info.GetAttr<float>("alpha", &alpha_).IsOK());
ORT_ENFORCE(info.GetAttr<float>("beta", &beta_).IsOK());
}
Status ComputeInternal(OpKernelContext* context) const override;
private:
bool trans_A_;
bool trans_B_;
float alpha_;
float beta_;
};
} // namespace cuda
} // namespace onnxruntime
| 23.72973 | 66 | 0.693622 |
5c22e8f71dd1e6addf9c5f029267179f5087d88b | 92,330 | c | C | src/wcc/wcc.c | Seabreg/wcc | f141963ff193d7e1931d41acde36d20d7221e74f | [
"MIT"
] | 1,714 | 2016-08-09T07:28:12.000Z | 2022-03-29T20:01:10.000Z | src/wcc/wcc.c | Seabreg/wcc | f141963ff193d7e1931d41acde36d20d7221e74f | [
"MIT"
] | 29 | 2016-08-09T14:38:48.000Z | 2021-12-29T08:29:49.000Z | src/wcc/wcc.c | Seabreg/wcc | f141963ff193d7e1931d41acde36d20d7221e74f | [
"MIT"
] | 118 | 2016-08-09T08:01:24.000Z | 2022-02-10T08:26:32.000Z | /**
*
* Witchcraft Compiler Collection
*
* Author: Jonathan Brossard - endrazine@gmail.com
*
*******************************************************************************
* The MIT License (MIT)
* Copyright (c) 2016 Jonathan Brossard
*
* 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.
*******************************************************************************
*
*/
#define __USE_GNU
#define _GNU_SOURCE
#include <bfd.h>
#include <dlfcn.h>
#include <elf.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/procfs.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/ucontext.h>
#include <unistd.h>
#include <utlist.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <libelf.h>
#include <gelf.h>
#include <nametotype.h>
#include <nametoalign.h>
#include <nametoentsz.h>
#include <nametolink.h>
#include <nametoinfo.h>
#include <arch.h>
#include <inttypes.h>
#include <config.h>
#define DEFAULT_STRNDX_SIZE 4096
// Valid flags for msec_t->flags
#define FLAG_BSS 1
#define FLAG_NOBIT 2
#define FLAG_NOWRITE 4
#define FLAG_TEXT 8
#define ifis(x) if(!strncmp(name, x, strlen(x)))
#define elis(x) else if(!strncmp(name, x, strlen(x)))
#define EXTRA_CREATED_SECTIONS 4
#define RELOC_X86_64 1
#define RELOC_X86_32 2
//#ifdef __x86_64__
#ifdef __LP64__ // Generic 64b
#define Elf_Ehdr Elf64_Ehdr
#define Elf_Shdr Elf64_Shdr
#define Elf_Sym Elf64_Sym
#define Elf_Addr Elf64_Addr
#define Elf_Sword Elf64_Sxword
#define Elf_Section Elf64_Half
#define ELF_ST_BIND ELF64_ST_BIND
#define ELF_ST_TYPE ELF64_ST_TYPE
#define Elf_Rel Elf64_Rel
#define Elf_Rela Elf64_Rela
#define ELF_R_SYM ELF64_R_SYM
#define ELF_R_TYPE ELF64_R_TYPE
#define ELF_R_INFO ELF64_R_INFO
#define Elf_Phdr Elf64_Phdr
#define Elf_Xword Elf64_Xword
#define Elf_Word Elf64_Word
#define Elf_Off Elf64_Off
#define ELFCLASS ELFCLASS64
#define ELFMACHINE EM_X86_64
#define CS_MODE CS_MODE_64
#define RELOC_MODE RELOC_X86_64
#else // Generic 32b
#define Elf_Ehdr Elf32_Ehdr
#define Elf_Shdr Elf32_Shdr
#define Elf_Sym Elf32_Sym
#define Elf_Addr Elf32_Addr
#define Elf_Sword Elf64_Sword
#define Elf_Section Elf32_Half
#define ELF_ST_BIND ELF32_ST_BIND
#define ELF_ST_TYPE ELF32_ST_TYPE
#define Elf_Rel Elf32_Rel
#define Elf_Rela Elf32_Rela
#define ELF_R_SYM ELF32_R_SYM
#define ELF_R_TYPE ELF32_R_TYPE
#define ELF_R_INFO ELF32_R_INFO
#define Elf_Phdr Elf32_Phdr
#define Elf_Xword Elf32_Xword
#define Elf_Word Elf32_Word
#define Elf_Off Elf32_Off
#define ELFCLASS ELFCLASS32
#define ELFMACHINE EM_386
#define CS_MODE CS_MODE_32
#define RELOC_MODE RELOC_X86_32
#endif
#define nullstr "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
unsigned int maxoldsec = 0, maxnewsec = 0;
unsigned int deltastrtab = 0;
char *allowed_sections[] = {
".rodata",
".data",
".text",
".load",
".strtab",
".symtab",
".comment",
".note.GNU-stack",
".rsrc",
".bss",
// ".rela.plt",
// ".rela.dyn"
};
char *blnames[] = {
"__init_array_start",
"__init_array_end",
"__libc_csu_init",
"__libc_csu_fini",
"__x86.get_pc_thunk.bx", // this is 32b only
".bss",
".comment",
".data",
".dynamic",
".fini",
".fini_array",
".got",
".got.plt",
".init",
".init_array",
".jcr",
".plt",
".plt.got",
".text",
"__GNU_EH_FRAME_HDR",
"__FRAME_END__",
".interp",
".note.ABI-tag",
".note.gnu.build-id",
".gnu.hash",
".dynsym",
".dynstr",
".gnu.version",
".gnu.version_r",
".rela.dyn",
".rela.plt",
".rodata",
".eh_frame_hdr",
".eh_frame",
"_ITM_registerTMCloneTable",
"_ITM_deregisterTMClone",
"_ITM_deregisterTMCloneTab",
"_Jv_RegisterClasses",
"_ITM_registerTMCloneTa",
"__cxa_finalize",
"_DYNAMIC",
"_GLOBAL_OFFSET_TABLE_",
"__JCR_END__",
"__JCR_LIST__",
"__TMC_END__",
"__bss_start",
"__data_start",
"_IO_stdin_used",
"__do_global_dtors_aux",
"__do_global_dtors_aux_fini_array_entry",
"__dso_handle",
"__frame_dummy_init_array_entry",
"__libc_csu_fini",
"_edata",
"_end",
"_fini",
"__fini",
"_init",
"_start",
"data_start",
"deregister_tm_clones",
"frame_dummy",
"register_tm_clones",
//"__libc_start_main",
"__gmon_start__"
};
/**
* Meta section header
*/
typedef struct msec_t {
char *name;
unsigned long int len;
unsigned char *data;
unsigned long int outoffset;
unsigned int flags; // See above
asection *s_bfd;
Elf_Shdr *s_elf;
struct msec_t *prev; // utlist.h
struct msec_t *next; // utlist.h
} msec_t;
/**
* Meta segment header
*/
typedef struct mseg_t {
Elf_Word p_type;
Elf_Word p_flags;
Elf_Off p_offset; // Segment file offset
Elf_Addr p_vaddr; // Segment virtual address
Elf_Addr p_paddr; // Segment physical address
Elf_Xword p_filesz; // Segment size in file
Elf_Xword p_memsz; // Segment size in memory
Elf_Xword p_align; // Segment alignment, file & memory
struct msec_t *prev; // utlist.h
struct msec_t *next; // utlist.h
} mseg_t;
typedef struct ctx_t {
/**
* Internal options
*/
char *binname;
unsigned int archsz; // Architecture size (64 or 32)
unsigned int shnum;
unsigned int phnum; // Number of program headers
char *strndx; // pointer to section string table in memory
unsigned int strndx_len; // length of section string table in bytes
unsigned int strndx_index; // offset of sections string table in binary
unsigned int start_shdrs; // Offset of section headers in output binary
unsigned int start_phdrs; // Offset of Program headers in output binary
int fdout;
bfd *abfd;
unsigned int corefile; // 1 if file is a core file
unsigned int base_address; // VMA Address of first PT_LOAD segment in memory
// Meta section headers (double linked list)
msec_t *mshdrs;
unsigned int mshnum;
// Meta segment headers (double linked list)
mseg_t *mphdrs;
unsigned int mphnum;
unsigned int has_relativerelocations; // 1 if binary has relative relocations (R_X86_64_RELATIVE)
/**
* User options
*/
char *opt_binname;
char *opt_interp;
unsigned int opt_arch;
unsigned int opt_static;
unsigned int opt_reloc;
unsigned int opt_strip;
unsigned int opt_sstrip;
unsigned int opt_exec;
unsigned int opt_core;
unsigned int opt_shared;
unsigned int opt_verbose;
unsigned long int opt_entrypoint;
unsigned char opt_poison;
unsigned int opt_original;
unsigned int opt_debug;
unsigned int opt_asmdebug;
unsigned int opt_flags; // used in setting eabi
} ctx_t;
/**
* Forwardd prototypes declarations
*/
int craft_section(ctx_t * ctx, msec_t * m);
unsigned int secindex_from_name(ctx_t * ctx, const char *name);
msec_t *section_from_name(ctx_t * ctx, char *name);
msec_t *section_from_addr(ctx_t * ctx, unsigned long int addr);
int print_bfd_sections(ctx_t * ctx);
unsigned int secindex_from_name(ctx_t * ctx, const char *name);
msec_t *section_from_index(ctx_t * ctx, unsigned int index);
unsigned int secindex_from_name_after_strip(ctx_t * ctx, const char *name);
int analyze_text(ctx_t * ctx, char *data, unsigned int datalen,
unsigned long int addr);
int save_reloc(ctx_t * ctx, Elf_Rela * r, unsigned int sindex, int has_addend);
/**
* Globals
*/
char *globalsymtab = 0;
int globalsymtablen = 0;
unsigned int globalsymtableoffset = 0;
char *globalstrtab = 0;
unsigned int globalstrtablen = 0;
unsigned int globalstrtableoffset = 0;
unsigned int globalsymindex = 0;
char *globalreloc = 0;
unsigned int globalreloclen = 0;
unsigned int globalrelocoffset = 0;
unsigned long int mintext = -1;
unsigned long int maxtext = 0;
unsigned long int textvma = 0;
unsigned long int mindata = -1;
unsigned long int maxdata = 0;
unsigned long int datavma = 0;
unsigned long int orig_text = 0;
unsigned long int orig_sz = 0;
/**
* Convert BFD permissions into regular octal perms
*/
static int parse_bfd_perm(int perm)
{
int heal_perm = 0;
heal_perm |= (perm & SEC_CODE ? 1 : 0);
heal_perm |= (perm & SEC_DATA ? 2 : 0);
heal_perm |= (perm & SEC_ALLOC ? 4 : 0);
heal_perm = (perm & SEC_READONLY ? heal_perm : 4);
return heal_perm;
}
/**
* Convert octal permissions into permissions consumable by mprotect()
*/
unsigned int protect_perms(unsigned int perms)
{
unsigned int memperms = 0;
switch (perms) {
case 7:
memperms = PROT_READ | PROT_WRITE | PROT_EXEC;
break;
case 6:
memperms = PROT_READ;
break;
case 5:
memperms = PROT_READ | PROT_EXEC;
break;
case 4:
memperms = PROT_READ | PROT_WRITE;
break;
default:
memperms = 0;
break;
}
return memperms;
}
struct symaddr {
struct symaddr *next;
char *name;
int addr;
} *symaddrs;
/*
typedef struct {
Elf_Word st_name;
unsigned char st_info;
unsigned char st_other;
Elf_Half st_shndx;
Elf_Addr st_value;
Elf_Xword st_size;
} Elf_Sym;
*/
void add_symaddr(ctx_t * ctx, const char *name, int addr, char symclass)
{
struct symaddr *sa;
Elf_Sym *s = 0;
unsigned long int nameptr = 0;
unsigned int i;
if (*name == '\0')
return;
// search this address in symbol table : duplicates here trigger a NULL ptr dereference in ld
for (i = 0; i < globalsymtablen / sizeof(Elf_Sym); i++) {
s = (Elf_Sym *) (globalsymtab + i * sizeof(Elf_Sym));
//
if ((s->st_value == addr - textvma) && (s->st_value != 0)) {
return; // already in symtab
}
}
// check if name is in blacklist
for (i = 0; i < sizeof(blnames) / sizeof(char *); i++) {
if ((strlen(name) == strlen(blnames[i]))
&& (!strncmp(name, blnames[i], strlen(blnames[i])))) {
return;
}
}
sa = (struct symaddr *) malloc(sizeof(struct symaddr));
memset(sa, 0, sizeof(struct symaddr));
sa->name = strdup(name);
sa->addr = addr;
sa->next = symaddrs;
symaddrs = sa;
if (ctx->opt_verbose) {
printf("%-20s\t\t%x\t\t%c\n", sa->name, sa->addr, symclass);
}
/**
* Append name to global string table
*/
if (globalstrtab == 0) {
globalstrtab = calloc(1, strlen(sa->name) + 3);
globalstrtablen++; // Start with a null byte
} else {
globalstrtab =
realloc(globalstrtab, globalstrtablen + strlen(sa->name) + 2);
}
memcpy(globalstrtab + globalstrtablen, sa->name, strlen(sa->name) + 1);
nameptr = globalstrtablen;
globalstrtablen += strlen(sa->name) + 1;
/**
* Append symbol to global symbol table
*/
if (globalsymtab == 0) {
globalsymtab = calloc(1, sizeof(Elf_Sym) * 2);
globalsymtablen += sizeof(Elf_Sym); // Skip 1 NULL entry
} else {
globalsymtab = realloc(globalsymtab, sizeof(Elf_Sym) + globalsymtablen);
}
s = (Elf_Sym *) (globalsymtab + globalsymtablen);
s->st_name = nameptr;
s->st_size = 100; // default function size... (in bytes)
s->st_value = addr;
s->st_info = 0;
s->st_other = 0;
s->st_shndx = 0;
switch (symclass) {
case 'T':
case 't':
case 'C':
case 'c':
// s->st_value = addr;
;
// adjust value from vma
msec_t *t = section_from_name(ctx, ".text");
// s->st_value -= t->s_elf->sh_addr;
if (ctx->opt_reloc) {
s->st_value -= t->s_bfd->vma;
//s->st_value -= orig_text;
s->st_shndx = 1; // index to .text
}
s->st_info = STT_FUNC;
break;
case 'D':
case 'd':
case 'B':
case 'b':
case 'V':
case 'v':
;
// adjust value from vma
// msec_t *t2 = section_from_addr(ctx, s->st_value);
// s->st_value -= t2->s_bfd->vma;
s->st_info = STT_OBJECT;
break;
case 'A':
case 'a':
s->st_info = STT_FILE;
break;
case 'R':
case 'r':
s->st_size = 0;
s->st_info = STT_SECTION;
break;
default:
break;
}
if (isupper(symclass)) {
s->st_info += 0x10;
}
globalsymtablen += sizeof(Elf_Sym);
return;
}
/**
* Add extra symbols
*/
int add_extra_symbols(ctx_t * ctx)
{
add_symaddr(ctx, "old_plt", textvma, 0x54);
add_symaddr(ctx, "old_text", orig_text, 0x54);
add_symaddr(ctx, "old_text_end", orig_text + maxtext - mintext, 0x54);
return 0;
}
/**
* Read symbol table.
* This is a two stages process : allocate the table, then read it
*/
int rd_symbols(ctx_t * ctx)
{
long storage_needed;
asymbol **symbol_table = NULL;
long number_of_symbols;
long i;
int ret = 0;
const char *sym_name;
int symclass;
int sym_value;
if (ctx->opt_verbose) {
printf("\n\n -- Reading symbols\n\n");
printf(" Symbol\t\t\t\taddress\t\tclass\n");
printf(" -----------------------------------------------------\n");
}
/**
* Process symbol table
*/
storage_needed = bfd_get_symtab_upper_bound(ctx->abfd);
if (storage_needed < 0) {
bfd_perror("warning: bfd_get_symtab_upper_bound");
ret = 0;
goto dynsym;
}
if (storage_needed == 0) {
fprintf(stderr, "warning: no symbols\n");
goto dynsym;
}
symbol_table = (asymbol **) malloc(storage_needed);
number_of_symbols = bfd_canonicalize_symtab(ctx->abfd, symbol_table);
if (number_of_symbols < 0) {
bfd_perror("warning: bfd_canonicalize_symtab");
ret = 0;
goto dynsym;
}
for (i = 0; i < number_of_symbols; i++) {
asymbol *asym = symbol_table[i];
sym_name = bfd_asymbol_name(asym);
symclass = bfd_decode_symclass(asym);
sym_value = bfd_asymbol_value(asym);
if (*sym_name == '\0') {
continue;
}
if (bfd_is_undefined_symclass(symclass)) {
continue;
}
if (!ctx->opt_strip) { // process additional symbols from symbol table
add_symaddr(ctx, sym_name, sym_value, symclass);
}
}
/**
* Process dynamic symbol table
*/
dynsym:
if (symbol_table) {
free(symbol_table);
}
symbol_table = NULL;
storage_needed = bfd_get_dynamic_symtab_upper_bound(ctx->abfd);
if (storage_needed < 0) {
bfd_perror("warning: bfd_get_dynamic_symtab_upper_bound");
ret = 0;
goto out;
}
if (storage_needed == 0) {
fprintf(stderr, "warning: no symbols\n");
goto out;
}
symbol_table = (asymbol **) malloc(storage_needed);
number_of_symbols = bfd_canonicalize_dynamic_symtab(ctx->abfd, symbol_table);
if (number_of_symbols < 0) {
bfd_perror("warning: bfd_canonicalize_symtab");
ret = 0;
goto dynsym;
}
for (i = 0; i < number_of_symbols; i++) {
asymbol *asym = symbol_table[i];
sym_name = bfd_asymbol_name(asym);
symclass = bfd_decode_symclass(asym);
sym_value = bfd_asymbol_value(asym);
if (*sym_name == '\0') {
continue;
}
if (bfd_is_undefined_symclass(symclass)) {
continue;
}
}
out:
if (symbol_table) {
free(symbol_table);
}
if (ctx->opt_verbose) {
printf("\n");
}
return ret;
}
/**
* Return section entry size from name
*/
int entszfromname(const char *name)
{
unsigned int i = 0;
for (i = 0; i < sizeof(nametosize) / sizeof(assoc_nametosz_t); i++) {
if (!strncmp(nametosize[i].name, name, strlen(name))) {
return nametosize[i].sz;
}
}
return 0;
}
/**
* Return max of two unsigned integers
*/
unsigned int max(unsigned int a, unsigned int b)
{
return a < b ? b : a;
}
/**
* Return a section from its name
*/
msec_t *section_from_name(ctx_t * ctx, char *name)
{
msec_t *s;
DL_FOREACH(ctx->mshdrs, s) {
if (!strncmp(s->name, name, max(strlen(name), strlen(s->name)))) {
return s;
}
}
return 0;
}
/**
* Return a section from its address
*/
msec_t *section_from_addr(ctx_t * ctx, unsigned long int addr)
{
msec_t *s;
DL_FOREACH(ctx->mshdrs, s) {
if ((s->s_bfd->vma) && (s->s_bfd->vma <= addr)
&& (s->s_bfd->vma + s->s_bfd->size > addr)) {
return s;
}
}
return 0;
}
/**
* Return a section from its index
*/
msec_t *section_from_index(ctx_t * ctx, unsigned int index)
{
msec_t *s;
unsigned int i = 1; // We count from 1
DL_FOREACH(ctx->mshdrs, s) {
if (index == i) {
return s;
}
i++;
}
return 0;
}
/**
* Return a section index from its name
*/
unsigned int secindex_from_name(ctx_t * ctx, const char *name)
{
msec_t *s;
unsigned int i = 1; // We count from 1
DL_FOREACH(ctx->mshdrs, s) {
if (!strncmp(s->name, name, max(strlen(name), strlen(s->name)))) {
return i;
}
i++;
}
return 0;
}
/**
* Return a section index (after strip) from its name
*/
unsigned int secindex_from_name_after_strip(ctx_t * ctx, const char *name)
{
msec_t *s;
unsigned int i = 1; // We count from 1
unsigned int j;
DL_FOREACH(ctx->mshdrs, s) {
if (!strncmp(s->name, name, max(strlen(name), strlen(s->name)))) {
return i;
}
for (j = 0; j < sizeof(allowed_sections) / sizeof(char *); j++) {
if (!strncmp(s->name, allowed_sections[j], strlen(allowed_sections[j]))) {
i++; // Ok, this section is allowed
break;
}
}
}
return 0;
}
char *sec_name_from_index_after_strip(ctx_t * ctx, unsigned int index)
{
msec_t *s;
unsigned int i = 0;
unsigned int j;
DL_FOREACH(ctx->mshdrs, s) {
for (j = 0; j < sizeof(allowed_sections) / sizeof(char *); j++) {
if (!strncmp(s->name, allowed_sections[j], strlen(allowed_sections[j]))) {
i++; // Ok, this section is allowed
break;
}
}
if (i == index) {
return s->name;
}
}
return NULL;
}
/**
* Return a section link from its name
*/
int link_from_name(ctx_t * ctx, const char *name)
{
unsigned int i = 0;
char *destsec = 0;
unsigned int d = 0;
for (i = 0; i < sizeof(nametolink) / sizeof(assoc_nametolink_t); i++) {
if (!strncmp(nametolink[i].name, name, strlen(name))) {
destsec = nametolink[i].dst;
}
}
if (!destsec) {
return 0;
}
d = secindex_from_name(ctx, destsec);
return d;
}
/**
* Return a section info from its name
*/
int info_from_name(ctx_t * ctx, const char *name)
{
unsigned int i = 0;
char *destsec = 0;
unsigned int d = 0;
for (i = 0; i < sizeof(nametoinfo) / sizeof(assoc_nametoinfo_t); i++) {
if (!strncmp(nametoinfo[i].name, name, strlen(name))) {
destsec = nametoinfo[i].dst;
}
}
if (!destsec) {
return 0;
}
d = secindex_from_name(ctx, destsec);
return d;
}
/**
* Return a section type from its name
*/
int typefromname(const char *name)
{
unsigned int i = 0;
for (i = 0; i < sizeof(nametotype) / sizeof(assoc_nametotype_t); i++) {
if (!strncmp(nametotype[i].name, name, strlen(name))) {
return nametotype[i].type;
}
}
return SHT_PROGBITS;
}
/**
* Return a section alignment from its name
*/
unsigned int alignfromname(const char *name)
{
unsigned int i = 0;
for (i = 0; i < sizeof(nametoalign) / sizeof(assoc_nametoalign_t); i++) {
if (!strncmp(nametoalign[i].name, name, strlen(name))) {
return nametoalign[i].alignment;
}
}
return 8;
}
/**
* Return Segment ptype
*/
unsigned int ptype_from_section(msec_t * ms)
{
// Return type based on section name
if (!strncmp(ms->name, ".interp", 7)) {
return PT_INTERP;
}
if (!strncmp(ms->name, ".dynamic", 8)) {
return PT_DYNAMIC;
}
if (!strncmp(ms->name, ".eh_frame_hdr", 13)) {
return PT_GNU_EH_FRAME;
}
switch (ms->s_elf->sh_type) {
case SHT_NULL:
return PT_NULL;
case SHT_PROGBITS:
return PT_LOAD;
case SHT_NOTE:
return PT_NOTE;
case SHT_DYNAMIC:
return PT_DYNAMIC;
case SHT_SYMTAB:
case SHT_STRTAB:
case SHT_RELA:
case SHT_HASH:
case SHT_NOBITS:
case SHT_REL:
case SHT_SHLIB:
case SHT_DYNSYM:
case SHT_NUM:
case SHT_LOSUNW:
case SHT_GNU_verdef:
case SHT_GNU_verneed:
case SHT_GNU_versym:
default:
break;
}
return PT_LOAD;
}
/**
* Return Segment flags based on a section
*/
unsigned int pflag_from_section(msec_t * ms)
{
unsigned int dperms = 0;
dperms = 0;
switch (ms->s_elf->sh_flags) {
case SHF_ALLOC | SHF_WRITE | SHF_EXECINSTR:
dperms = PF_R | PF_W | PF_X; // "rwx";
break;
case SHF_ALLOC:
dperms = PF_R; //"r--";
break;
case SHF_ALLOC | SHF_EXECINSTR:
dperms = PF_R | PF_X; // "r-x";
break;
case SHF_ALLOC | SHF_WRITE:
dperms = PF_R | PF_W; // "rw-"
break;
default:
dperms = 0; // "---"
break;
}
return dperms;
}
/**
* Helper sort routine for ELF Phdrs (pre-merge)
*/
int phdr_cmp_premerge(mseg_t * a, mseg_t * b)
{
if (a->p_type != b->p_type) {
return a->p_type - b->p_type;
} // Sort by type
return a->p_vaddr - b->p_vaddr; // else by vma
}
/**
* Helper sort routine for ELF Phdrs
*/
int phdr_cmp(mseg_t * a, mseg_t * b)
{
return a->p_vaddr - b->p_vaddr; // This is correct, see elf.pdf
}
/**
* Reorganise Program Headers :
* sort by p_offset
*/
int sort_phdrs(ctx_t * ctx)
{
DL_SORT(ctx->mphdrs, phdr_cmp);
return 0;
}
/**
* Helper sort routine for ELF Phdrs
*/
int sort_phdrs_premerge(ctx_t * ctx)
{
DL_SORT(ctx->mphdrs, phdr_cmp_premerge);
return 0;
}
/**
* Allocate Phdr
*/
mseg_t *alloc_phdr(msec_t * ms)
{
mseg_t *p;
Elf_Shdr *s;
s = ms->s_elf;
p = calloc(1, sizeof(mseg_t));
p->p_type = ptype_from_section(ms);
p->p_flags = pflag_from_section(ms);
p->p_offset = s->sh_offset;
p->p_vaddr = s->sh_addr;
p->p_paddr = s->sh_addr;
p->p_filesz = s->sh_size;
p->p_memsz = s->sh_size;
p->p_align = s->sh_addralign;
return p;
}
/**
* Create Program Headers based on ELF section headers
*/
int create_phdrs(ctx_t * ctx)
{
msec_t *ms, *tmp;
mseg_t *p = 0;
DL_FOREACH_SAFE(ctx->mshdrs, ms, tmp) {
p = alloc_phdr(ms);
if (p->p_type == PT_LOAD) {
unsigned int r = 0; // reminder
p->p_align = 0x200000;
// We need to align segment p_vaddr - p_offset on page boundaries
r = (p->p_vaddr - p->p_offset) % 4096;
p->p_vaddr -= r; // Adjust initial address
p->p_paddr -= r; // Adjust initial address
p->p_filesz += r; // Adjust size
p->p_memsz += r; // Adjust size
}
if (p->p_flags) {
// Add to linked list of segments
DL_APPEND(ctx->mphdrs, p);
ctx->mphnum++;
ctx->phnum++;
} else {
// Sections not mapped have no segment
free(p);
}
}
return 0;
}
/**
* Merge two consecutive Phdrs if:
* - their vma ranges overlap
* - Permissions match
* - Type of segment matches
*
* Note: assume phdrs have been sorted by increasing p_vaddr first
*/
int merge_phdrs(ctx_t * ctx)
{
mseg_t *ms, *n;
retry:
ms = ctx->mphdrs;
while (ms) {
if (ms->next) {
n = (mseg_t *) ms->next;
if (ms->p_flags != n->p_flags) {
goto skipseg;
}
if (ms->p_type != n->p_type) {
goto skipseg;
}
// merge sections into the first one :
// extend section
ms->p_filesz = n->p_filesz + (n->p_offset - ms->p_offset);
ms->p_memsz = ms->p_memsz + (n->p_offset - ms->p_offset);
// unlink deleted section from double linked list
if (n->next) {
n->next->prev = (void *) ms;
}
ms->next = n->next;
free(n);
ctx->mphnum--;
ctx->phnum--;
goto retry;
}
skipseg:
ms = (mseg_t *) ms->next;
}
return 0;
}
int adjust_baseaddress(ctx_t * ctx)
{
mseg_t *ms;
// find base address (first allocated PT_LOAD chunk)
ms = ctx->mphdrs;
while (ms) {
if ((ms->p_type == PT_LOAD) && (ms->p_flags == (PF_R))) {
if (ctx->base_address > (ms->p_vaddr & ~0xfff)) {
ctx->base_address = ms->p_vaddr & ~0xfff;
}
}
ms = (mseg_t *) ms->next;
}
if (ctx->base_address == 0) {
ctx->base_address = ctx->mphdrs->p_vaddr & ~0xfff;
}
if (ctx->opt_debug) {
printf("\n * first loadable segment at: 0x%x\n", ctx->base_address);
}
// patch load address of first chunk PT_LOAD allocated RX
ms = ctx->mphdrs;
while (ms) {
if ((ms->p_type == PT_LOAD) && (ms->p_flags == (PF_R | PF_X))) {
if (ctx->opt_debug) {
printf
(" -- patching base load address of first PT_LOAD Segment: %lu -->> %u\n",
ms->p_vaddr, ctx->base_address);
}
ms->p_vaddr = ctx->base_address;
ms->p_paddr = ctx->base_address;
ms->p_memsz += ms->p_offset;
ms->p_filesz += ms->p_offset;
ms->p_offset = 0;
break;
}
ms = (void *) ms->next;
}
return 0;
}
/**
* Read Program Headers from disk
*/
static unsigned int rd_phdrs(ctx_t * ctx)
{
struct stat sb;
char *p;
int fdin;
Elf_Ehdr *e = 0;
unsigned int i = 0;
int nread;
Elf_Phdr *phdr, *eph;
if (stat(ctx->binname, &sb) == -1) {
perror("stat");
exit(EXIT_FAILURE);
}
p = calloc(1, sb.st_size);
fdin = open(ctx->binname, O_RDONLY);
if (fdin <= 0) {
perror("open");
exit(-1);
}
nread = read(fdin, p, sb.st_size);
if (nread != sb.st_size) {
perror("read");
exit(EXIT_FAILURE);
}
close(fdin);
printf(" -- read: %u bytes\n", nread);
e = (Elf_Ehdr *) p;
phdr = (Elf_Phdr *) (p + e->e_phoff);
eph = phdr + e->e_phnum;
for (; phdr < eph; phdr++) {
// Add to linked list
// Create Meta section
mseg_t *ms = calloc(1, sizeof(mseg_t));
if (!ms) {
perror("calloc");
exit(EXIT_FAILURE);
}
memcpy(ms, phdr, sizeof(Elf_Phdr));
// Add to double linked list of msec_t Meta sections
DL_APPEND(ctx->mphdrs, ms);
ctx->mphnum++;
ctx->phnum++;
i++;
}
printf(" -- Original: %u\n", i);
return 0;
}
/**
* Create Program Headers from Sections
*/
static unsigned int mk_phdrs(ctx_t * ctx)
{
/**
* Create a segment per section
*/
create_phdrs(ctx);
/**
* Sort segments for merging
*/
sort_phdrs_premerge(ctx);
/**
* Merge segments with overlapping/consecutive memory chunks
*/
merge_phdrs(ctx);
sort_phdrs(ctx);
adjust_baseaddress(ctx);
sort_phdrs(ctx); // Need to resort after patching
merge_phdrs(ctx);
sort_phdrs(ctx); // Need to resort after patching
return 0;
}
/**
* Write Program Headers to disk
*/
static unsigned int write_phdrs(ctx_t * ctx)
{
unsigned int tmpm = 0;
// Goto end of file, align on 8 bytes boundaries
tmpm = lseek(ctx->fdout, 0x00, SEEK_END);
write(ctx->fdout, nullstr, 20);
if ((tmpm % 8) == 0) {
tmpm += 8;
}
tmpm &= ~0xf;
tmpm += sizeof(Elf_Phdr); // Prepend NULL section
ftruncate(ctx->fdout, tmpm);
ctx->start_phdrs = lseek(ctx->fdout, 0x00, SEEK_END);
ctx->phnum += 2;
if (ctx->opt_verbose) {
printf(" -- Writting %u segment headers\n", ctx->phnum);
}
// first entry is the program header itself
Elf_Phdr *phdr = calloc(1, sizeof(Elf_Phdr));
phdr->p_vaddr = ctx->base_address;
phdr->p_paddr = ctx->base_address;
phdr->p_type = PT_PHDR;
phdr->p_offset = ctx->start_phdrs;
phdr->p_flags = 5;
phdr->p_filesz = ctx->phnum * sizeof(Elf_Phdr);
phdr->p_memsz = ctx->phnum * sizeof(Elf_Phdr);
phdr->p_align = 8;
write(ctx->fdout, phdr, sizeof(Elf_Phdr));
// Copy all the Phdrs
mseg_t *p;
DL_FOREACH(ctx->mphdrs, p) {
write(ctx->fdout, p, sizeof(Elf_Phdr));
}
// Append a Program Header for the stack
phdr->p_vaddr = 0;
phdr->p_paddr = 0;
phdr->p_type = PT_GNU_STACK;
phdr->p_offset = 0;
phdr->p_flags = 3;
phdr->p_filesz = 0;
phdr->p_memsz = 0;
phdr->p_align = 0x10;
write(ctx->fdout, phdr, sizeof(Elf_Phdr));
return ctx->start_phdrs;
}
/**
* Write Original Program Headers to disk
*/
static unsigned int write_phdrs_original(ctx_t * ctx)
{
unsigned int tmpm = 0;
// Goto end of file, align on 8 bytes boundaries
tmpm = lseek(ctx->fdout, 0x00, SEEK_END);
write(ctx->fdout, nullstr, 20);
if ((tmpm % 8) == 0) {
tmpm += 8;
}
tmpm &= ~0xf;
ftruncate(ctx->fdout, tmpm);
ctx->start_phdrs = lseek(ctx->fdout, 0x00, SEEK_END);
mseg_t *p;
unsigned int i = 0;
DL_FOREACH(ctx->mphdrs, p) {
if (i == 0) { // First Phdr is the Program Header itself
p->p_offset = ctx->start_phdrs; // Patch offset of Program header
i = 1;
}
write(ctx->fdout, p, sizeof(Elf_Phdr));
}
return ctx->start_phdrs;
}
msec_t *mk_section(void)
{
msec_t *ms;
// allocate memory
ms = calloc(1, sizeof(msec_t));
if (!ms) {
perror("calloc");
exit(EXIT_FAILURE);
}
ms->s_elf = calloc(1, sizeof(Elf_Shdr));
if (!ms->s_elf) {
perror("calloc");
exit(EXIT_FAILURE);
}
return ms;
}
static int write_strtab_and_reloc(ctx_t * ctx)
{
unsigned int tmpm = 0;
if (ctx->opt_debug) {
printf(" * .strtab length:\t\t\t%u\n", globalstrtablen);
printf(" * .symtab length:\t\t\t%u\n", globalsymtablen);
}
// Goto end of file
tmpm = lseek(ctx->fdout, 0x00, SEEK_END);
write(ctx->fdout, nullstr, 20);
// align on 8 bytes boundaries
if ((tmpm % 8) == 0) {
tmpm += 8;
};
tmpm &= ~0xf;
// truncate
ftruncate(ctx->fdout, tmpm);
// write relocations to binary
tmpm = lseek(ctx->fdout, 0x00, SEEK_END);
globalrelocoffset = tmpm;
write(ctx->fdout, globalreloc, globalreloclen);
// write string table to binary
tmpm = lseek(ctx->fdout, 0x00, SEEK_END);
globalstrtableoffset = tmpm;
write(ctx->fdout, globalstrtab, globalstrtablen);
// write symbol table to binary
tmpm = lseek(ctx->fdout, 0x00, SEEK_END);
globalsymtableoffset = tmpm;
write(ctx->fdout, globalsymtab, globalsymtablen);
return 0;
}
char *reloc_htype_x86_64(int thetype)
{
char *htype;
switch (thetype) {
case R_X86_64_NONE:
htype = "R_X86_64_NONE";
break;
case R_X86_64_64:
htype = "R_X86_64_64";
break;
case R_X86_64_32:
htype = "R_X86_64_32";
break;
case R_X86_64_32S:
htype = "R_X86_64_32S";
break;
case R_X86_64_PC32:
htype = "R_X86_64_PC32";
break;
case R_X86_64_GOT32:
htype = "R_X86_64_GOT32";
break;
case R_X86_64_PLT32:
htype = "R_X86_64_PLT32";
break;
case R_X86_64_COPY:
htype = "R_X86_64_COPY";
break;
case R_X86_64_GLOB_DAT:
htype = "R_X86_64_GLOB_DAT";
break;
case R_X86_64_JUMP_SLOT:
htype = "R_X86_64_JUMP_SLOT";
break;
case R_X86_64_RELATIVE:
htype = "R_X86_64_RELATIVE";
break;
case R_X86_64_GOTPCREL:
htype = "R_X86_64_GOTPCREL";
break;
case R_X86_64_16:
htype = "R_X86_64_16";
break;
case R_X86_64_PC16:
htype = "R_X86_64_PC16";
break;
case R_X86_64_8:
htype = "R_X86_64_8";
break;
case R_X86_64_PC8:
htype = "R_X86_64_PC8";
break;
case R_X86_64_NUM:
htype = "R_X86_64_NUM";
break;
default:
htype = "Unknown";
break;
}
return htype;
}
char *reloc_htype_x86_32(int thetype)
{
char *htype;
switch (thetype) {
case R_386_NONE:
htype = "R_386_NONE";
break;
case R_386_32:
htype = "R_386_32";
break;
case R_386_PC32:
htype = "R_386_PC32";
break;
case R_386_GOT32:
htype = "R_386_GOT32";
break;
case R_386_PLT32:
htype = "R_386_PLT32";
break;
case R_386_COPY:
htype = "R_386_COPY";
break;
case R_386_GLOB_DAT:
htype = "R_386_GLOB_DAT";
break;
case R_386_JMP_SLOT:
htype = "R_386_JMP_SLOT";
break;
case R_386_RELATIVE:
htype = "R_386_RELATIVE";
break;
case R_386_GOTOFF:
htype = "R_386_GOTOFF";
break;
case R_386_GOTPC:
htype = "R_386_GOTPC";
break;
case R_386_NUM:
htype = "R_386_NUM";
break;
default:
htype = "Unknown";
break;
}
return htype;
}
char *reloc_htype(int thetype)
{
switch (RELOC_MODE) {
case RELOC_X86_64:
return reloc_htype_x86_64(thetype);
case RELOC_X86_32:
return reloc_htype_x86_32(thetype);
default:
return "UNKNOWN_RELOCATION";
break;
}
}
/**
* Parse relocations from a given section
*/
static int parse_reloc(ctx_t * ctx, msec_t * s)
{
Elf_Shdr *shdr;
Elf_Rela *r;
unsigned int sz;
unsigned int i;
char *htype = 0;
unsigned int sindex = 0;
unsigned int has_addend = 0;
shdr = s->s_elf;
sz = shdr->sh_size;
has_addend = (shdr->sh_type == SHT_RELA) ? 1 : 0; // SHT_RELA has addends, SHT_REL doesn't
if ((shdr->sh_type == SHT_RELA)
&& ((int)shdr->sh_entsize != entszfromname(".rela.dyn"))) {
printf("warning: strange relocation size: %lu != %u in %s\n",
shdr->sh_entsize, entszfromname(".rela.dyn"), s->name);
return -1;
}
if ((shdr->sh_type == SHT_REL)
&& ((int)shdr->sh_entsize != entszfromname(".rel.dyn"))) {
printf("warning: strange relocation size: %lu != %u in %s\n",
shdr->sh_entsize, entszfromname(".rel.dyn"), s->name);
return -1;
}
if ((shdr->sh_type == SHT_RELA)
&& ((int)shdr->sh_size % entszfromname(".rela.dyn"))) {
printf
("warning: strange relocation section size: %lu not a multiple of %u in %s\n",
shdr->sh_size, entszfromname(".rela.dyn"), s->name);
return -1;
}
if ((shdr->sh_type == SHT_REL) && (shdr->sh_size % entszfromname(".rel.dyn"))) {
printf
("warning: strange relocation section size: %lu not a multiple of %u in %s\n",
shdr->sh_size, entszfromname(".rel.dyn"), s->name);
return -1;
}
if (ctx->opt_verbose) {
printf("\t%s\tsize:%u\t%lu relocations\n", s->name, sz,
sz / shdr->sh_entsize);
}
for (i = 0; i < sz / shdr->sh_entsize; i++) {
r = s->data + i * shdr->sh_entsize;
htype = reloc_htype(ELF_R_TYPE(r->r_info));
if (ELF_R_TYPE(r->r_info) == R_X86_64_RELATIVE) {
if (ctx->opt_debug) {
printf("reloc[%u] %016lx\t%lu\t%s\t%u\taddend:%lx\t\n", i, r->r_offset,
r->r_info, htype, sindex, r->r_addend);
printf(" * Skipping relative relocation\n");
}
ctx->has_relativerelocations = 1; // Binary has relative relocations
continue; // Do not save relocation for R_X86_64_RELATIVE
} else {
sindex = ELF_R_SYM(r->r_info);
sindex += maxnewsec; // account for section references at top of symbol table
// write back sindex in symtab
ELF_R_INFO(sindex, ELF_R_TYPE(r->r_info));
}
if (ctx->opt_verbose) {
printf("reloc[%u] %016lx\t%lu\t%s\t%u\taddend:%lu\t\n", i, r->r_offset,
r->r_info, htype, sindex, r->r_addend);
}
save_reloc(ctx, r, sindex, has_addend);
}
if (ctx->opt_verbose) {
printf("\n");
}
return 0;
}
int fixup_strtab_and_symtab(ctx_t * ctx)
{
char *sname = 0;
Elf_Sym *s;
unsigned int i, sindex;
if (!globalsymtab) {
return 0;
}
if (!globalstrtab) {
return 0;
}
if (ctx->opt_debug) {
printf("\n -- Fixing strtab and symtab with delta of %u\n\n", deltastrtab);
}
for (sindex = maxnewsec + 1; sindex < (globalsymtablen / sizeof(Elf_Sym));
sindex++) {
// get symbol name from index
s = globalsymtab + sindex * sizeof(Elf_Sym);
s->st_name += deltastrtab; // fix symbol name offset in symbol table
/**
* check if name is in blacklist
*/
for (i = 0; i < sizeof(blnames) / sizeof(char *); i++) {
sname = (char *) (globalstrtab + s->st_name);
if ((s->st_name < globalstrtablen)
&& (strlen(sname) == strlen(blnames[i]))
&& (!strncmp(sname, blnames[i], strlen(blnames[i])))) {
if (ctx->opt_debug) {
printf(" * name blacklisted: %s at index %u\n", sname, sindex);
}
// generate new symbol name from old one
globalstrtab =
realloc(globalstrtab, globalstrtablen + strlen(sname) + 5);
sprintf(globalstrtab + globalstrtablen, "old_%s", sname);
s->st_name = globalstrtablen;
globalstrtablen += strlen(globalstrtab + globalstrtablen) + 1;
// change type and link information
s->st_info = ELF64_ST_INFO(STB_WEAK, STT_NOTYPE);
s->st_shndx = 0;
}
}
}
return 0;
}
int fixup_text(ctx_t * ctx)
{
msec_t *s;
if (ctx->opt_debug) {
printf(" -- Fixup .text\n\n");
}
DL_FOREACH(ctx->mshdrs, s) {
if (!strncmp(s->name, ".text", 6)) {
unsigned int newsz = datavma - textvma + maxdata - mindata;
if (ctx->opt_debug) {
printf
(" * .text section found, increasing size from 0x%lx to 0x%x (0x%lx)\n",
s->s_elf->sh_size, newsz, s->len);
}
s->s_elf->sh_size = newsz;
// extend data
s->data = realloc(s->data, newsz);
// pad
memset(s->data + s->len, 0x00, newsz - s->len);
s->s_elf->sh_offset = orig_sz;
s->outoffset = orig_sz;
// extend output file
ftruncate(ctx->fdout, s->outoffset + s->s_elf->sh_size);
s->len = newsz;
break;
}
}
return 0;
}
/**
* Parse relocations
*/
static unsigned int parse_relocations(ctx_t * ctx)
{
msec_t *s;
if (ctx->opt_verbose) {
printf("\n -- Parsing existing relocations\n\n");
}
DL_FOREACH(ctx->mshdrs, s) {
if ((s->s_elf) && (s->s_elf->sh_type == SHT_RELA)) { // relocations with addends
parse_reloc(ctx, s);
} else if ((s->s_elf) && (s->s_elf->sh_type == SHT_REL)) { // relocations without addends
parse_reloc(ctx, s);
}
}
if (ctx->opt_verbose) {
printf("\n");
}
return 0;
}
/**
* Append a symbol to global symbol table
*/
unsigned int append_sym(Elf_Sym * s)
{
if (globalsymtab == 0) {
globalsymtab = calloc(1, sizeof(Elf_Sym) * 2);
globalsymtablen += sizeof(Elf_Sym); // Skip 1 NULL entry
} else {
globalsymtab = realloc(globalsymtab, sizeof(Elf_Sym) + globalsymtablen);
}
memcpy(globalsymtab + globalsymtablen, s, sizeof(Elf_Sym));
globalsymtablen += sizeof(Elf_Sym);
return 0;
}
/**
* Append a string to symbol table, reports offset in strtab where this symbol will start
*/
unsigned int append_strtab(char *str)
{
unsigned int nameptr;
if (globalstrtab == 0) {
globalstrtab = calloc(1, strlen(str) + 3);
globalstrtablen++; // Start with a null byte
} else {
globalstrtab = realloc(globalstrtab, globalstrtablen + strlen(str) + 2);
}
memcpy(globalstrtab + globalstrtablen, str, strlen(str) + 1);
nameptr = globalstrtablen;
globalstrtablen += strlen(str) + 1;
return nameptr;
}
/**
* Create sections in symbol table/string table
*/
static int create_section_symbols(ctx_t * ctx)
{
msec_t *tmp;
msec_t *s;
unsigned int nameptr;
Elf_Sym *sym;
unsigned int i, n;
sym = calloc(1, sizeof(Elf_Sym));
DL_COUNT(ctx->mshdrs, tmp, maxoldsec); // count before stripping
for (i = 1; i <= maxoldsec; i++) {
s = section_from_index(ctx, i);
n = secindex_from_name_after_strip(ctx, s->name);
if (n > maxnewsec) {
maxnewsec = n;
}
}
// maxnewsec += EXTRA_CREATED_SECTIONS; // count sections not yet created
if (ctx->opt_debug) {
printf(" -- Max section index after stripping: %u\n", maxnewsec);
}
// Create symbol for section
for (i = 1; i <= maxnewsec; i++) {
char *newsname = 0;
newsname = sec_name_from_index_after_strip(ctx, i);
if (!newsname) {
switch (i - EXTRA_CREATED_SECTIONS - 1) {
case 1:
newsname = ".rela.all";
break;
case 2:
newsname = ".strtab";
break;
case 3:
newsname = ".symtab";
break;
case 4:
newsname = ".shstrtab";
break;
default:
newsname = ".unknown";
break;
}
}
nameptr = append_strtab(newsname);
if (ctx->opt_debug) {
printf("%u %s\n", i, newsname);
}
sym->st_name = nameptr;
sym->st_size = 0;
sym->st_value = 0;
sym->st_info = STT_SECTION;
sym->st_other = 0;
sym->st_shndx = i;
append_sym(sym);
}
free(sym);
deltastrtab = globalstrtablen;
if (ctx->opt_debug) {
printf(" -- Base sections symbol index: %u\n", 0);
printf(" -- Delta string table: %u\n", deltastrtab);
}
return 0;
}
static unsigned int process_text(ctx_t * ctx)
{
msec_t *t;
unsigned int delta;
t = section_from_name(ctx, ".text");
delta = orig_text - textvma;
// create section symbols
// create_section_symbols(ctx);
// parse text for relocations
analyze_text(ctx, (char *) (t->data + delta), maxtext - mintext - delta,
orig_text);
return 0;
}
/**
* Create Section Headers
*/
static unsigned int write_shdrs(ctx_t * ctx)
{
Elf_Shdr *shdr = 0;
unsigned int tmpm = 0;
msec_t *s;
/**
* Align section headers on 8 bytes boundaries
*/
// Goto end of file
tmpm = lseek(ctx->fdout, 0x00, SEEK_END);
write(ctx->fdout, nullstr, 20);
write(ctx->fdout, nullstr, 20);
write(ctx->fdout, nullstr, 20);
tmpm = lseek(ctx->fdout, 0x00, SEEK_END);
// align on 8 bytes boundaries
if ((tmpm % 8) == 0) {
tmpm += 8;
};
tmpm &= ~0xf;
tmpm += sizeof(Elf_Shdr); // Prepend a NULL section
// truncate
ftruncate(ctx->fdout, tmpm);
ctx->start_shdrs = lseek(ctx->fdout, 0x00, SEEK_END) - sizeof(Elf_Shdr); // New start of SHDRs
ctx->strndx[0] = 0;
ctx->strndx_len = 1;
/**
* Write each ELF section header
*/
DL_FOREACH(ctx->mshdrs, s) {
// append name to strndx
memcpy(ctx->strndx + ctx->strndx_len, s->name, strlen(s->name) + 1); // do copy the final "\x00"
s->s_elf->sh_name = ctx->strndx_len;
ctx->strndx_len += strlen(s->name) + 1;
// adjust section links and info
s->s_elf->sh_link = link_from_name(ctx, s->name); // Link to another section
s->s_elf->sh_info = info_from_name(ctx, s->name); // Additional section information
// write section header to binary
write(ctx->fdout, s->s_elf, sizeof(Elf_Shdr));
}
/**
* Add a section header for relocations
*/
// append name to strndx
memcpy(ctx->strndx + ctx->strndx_len, ".rela.all", 10);
shdr = calloc(1, sizeof(Elf_Shdr));
shdr->sh_name = ctx->strndx_len; // index in string table
shdr->sh_type = SHT_RELA; // Section type
shdr->sh_flags = 2; // Section flags
shdr->sh_addr = 0; // Section virtual addr at execution
shdr->sh_offset = globalrelocoffset; // Section file offset
shdr->sh_size = globalreloclen; // Section size in bytes
shdr->sh_link = ctx->shnum + 3; // Link to another section
shdr->sh_info = 1; // Additional section information : .text
shdr->sh_addralign = 8; // Section alignment
shdr->sh_entsize = entszfromname(".rela.plt"); // Entry size if section holds table
ctx->strndx_len += 10;
// append string table section header to binary
write(ctx->fdout, shdr, sizeof(Elf_Shdr));
free(shdr);
ctx->strndx_index = ctx->shnum + 1;
// append sections strint table to binary
// write(ctx->fdout, ctx->strndx, ctx->strndx_len);
/**
* Add a section header for string table
*/
// append name to strndx
memcpy(ctx->strndx + ctx->strndx_len, ".strtab", 8);
shdr = calloc(1, sizeof(Elf_Shdr));
shdr->sh_name = ctx->strndx_len; // index in string table
shdr->sh_type = SHT_STRTAB; // Section type
shdr->sh_flags = 0; // Section flags
shdr->sh_addr = 0; // Section virtual addr at execution
shdr->sh_offset = globalstrtableoffset; // Section file offset
shdr->sh_size = globalstrtablen; // Section size in bytes
shdr->sh_link = 0; // Link to another section
shdr->sh_info = 0; // Additional section information
shdr->sh_addralign = 1; // Section alignment
shdr->sh_entsize = entszfromname(".strtab"); // Entry size if section holds table
ctx->strndx_len += 8;
// append string table section header to binary
write(ctx->fdout, shdr, sizeof(Elf_Shdr));
free(shdr);
ctx->strndx_index = ctx->shnum + 1;
// append sections strint table to binary
// write(ctx->fdout, ctx->strndx, ctx->strndx_len);
/**
* Add a section header for symbol table
*/
// append name to strndx
memcpy(ctx->strndx + ctx->strndx_len, ".symtab", 8);
shdr = calloc(1, sizeof(Elf_Shdr));
shdr->sh_name = ctx->strndx_len; // index in string table
shdr->sh_type = SHT_SYMTAB; // Section type
shdr->sh_flags = 0; // Section flags
shdr->sh_addr = 0; // Section virtual addr at execution
shdr->sh_offset = globalsymtableoffset; // Section file offset
shdr->sh_size = globalsymtablen; // Section size in bytes
shdr->sh_link = ctx->shnum + 2; // Link to another section (strtab)
shdr->sh_info = ctx->shnum + 1; // Additional section information
shdr->sh_addralign = 8; // Section alignment
// shdr->sh_entsize = 0; // Entry size if section holds table
shdr->sh_entsize = entszfromname(".symtab"); // Entry size if section holds table
ctx->strndx_len += 8;
// append string table section header to binary
write(ctx->fdout, shdr, sizeof(Elf_Shdr));
free(shdr);
ctx->strndx_index = ctx->shnum + 1;
// append sections strint table to binary
// write(ctx->fdout, ctx->strndx, ctx->strndx_len);
/**
* Append an additional section header for the Section header string table
*/
// append name to strndx
memcpy(ctx->strndx + ctx->strndx_len, ".shstrtab", 10);
shdr = calloc(1, sizeof(Elf_Shdr));
shdr->sh_name = ctx->strndx_len; // index in string table
shdr->sh_type = SHT_STRTAB; // Section type
shdr->sh_flags = 0; // Section flags
shdr->sh_addr = 0; // Section virtual addr at execution
// shdr->sh_offset = lseek(ctx->fdout, 0x00, SEEK_END) + 64; // Section file offset
shdr->sh_offset = lseek(ctx->fdout, 0x00, SEEK_END) + sizeof(Elf_Shdr); // Section file offset
shdr->sh_size = ctx->strndx_len + 10; // Section size in bytes
shdr->sh_link = 0; // Link to another section
shdr->sh_info = 0; // Additional section information
shdr->sh_addralign = 1; // Section alignment
shdr->sh_entsize = 0; // Entry size if section holds table
ctx->strndx_len += 9 + 1;
// append string table section header to binary
write(ctx->fdout, shdr, sizeof(Elf_Shdr));
free(shdr);
ctx->strndx_index = ctx->shnum + 1;
// append sections strint table to binary
write(ctx->fdout, ctx->strndx, ctx->strndx_len);
if (ctx->opt_debug) {
printf(" * section headers at:\t\t\t0x%x\n", ctx->start_shdrs);
printf(" * section string table index:\t\t%u\n", ctx->shnum);
}
return ctx->start_shdrs;
}
/**
* Create ELF Headers
*/
static int mk_ehdr(ctx_t * ctx)
{
Elf_Ehdr *e = 0;
e = calloc(1, sizeof(Elf_Ehdr));
if (!e) {
perror("calloc");
exit(EXIT_FAILURE);
}
/**
* Set defaults
*/
// Set ELF signature
memcpy(e->e_ident, "\x7f\x45\x4c\x46\x02\x01\x01", 7);
e->e_ident[EI_CLASS] = ELFCLASS; // 64 or 32 bits
e->e_entry = bfd_get_start_address(ctx->abfd);
// Set type of ELF based on command line options and compilation target
e->e_type = ET_DYN; // Default is shared library
e->e_machine = ctx->opt_arch ? ctx->opt_arch : ELFMACHINE; // Default : idem compiler cpu, else, user specified
e->e_version = 0x1; // ABI Version, Always 1
e->e_phoff = ctx->start_phdrs;
e->e_shoff = ctx->start_shdrs;
e->e_flags = ctx->opt_flags; // default is null. Used in setting some EABI versions on ARM
e->e_ehsize = sizeof(Elf_Ehdr); // Size of this header
e->e_phentsize = sizeof(Elf_Phdr); // Size of each program header
e->e_phnum = ctx->phnum;
e->e_shentsize = sizeof(Elf_Shdr); // Size of each section header
e->e_shnum = ctx->shnum + 5; // We added a null section and a string table index + .strtab + .symtab + .rela.all
e->e_shstrndx = ctx->shnum + 4; // Sections Seader String table index is last valid
/**
* Now apply options
*/
if (ctx->opt_sstrip) {
e->e_shoff = 0;
e->e_shnum = 0;
e->e_shstrndx = 0; // Sections Seader String table index is last valid
e->e_shentsize = 0;
}
if ((ctx->opt_exec) || (ctx->opt_static)) {
e->e_type = ET_EXEC; // Executable
}
if (ctx->opt_shared) {
e->e_type = ET_DYN; // Shared library
}
if (ctx->opt_reloc) {
e->e_type = ET_REL; // Relocatable object
e->e_entry = 0;
e->e_phoff = 0;
e->e_phnum = 0;
e->e_phentsize = 0;
}
if (ctx->opt_core) {
e->e_type = ET_CORE; // Core file
}
// write ELF Header
lseek(ctx->fdout, 0x00, SEEK_SET);
write(ctx->fdout, e, sizeof(Elf_Ehdr));
return 0;
}
/**
* Write a section to disk
*/
static int write_section(ctx_t * ctx, msec_t * m)
{
unsigned int nwrite = 0;
// Go to correct offset in output binary
lseek(ctx->fdout, m->outoffset, SEEK_SET);
// write to fdout
nwrite = write(ctx->fdout, m->data, m->len);
if (nwrite != m->len) {
printf("write failed: %u != %lu %s\n", nwrite, m->len, strerror(errno));
exit(EXIT_FAILURE);
}
return nwrite;
}
static int rd_extended_text(ctx_t * ctx)
{
unsigned int i;
asection *s;
if (ctx->opt_debug) {
printf(" -- Finding .text segment boundaries\n\n");
printf(" index\t\tname\t\t\trange\tsize\tpermissions\toffset\n");
printf
("--------------------------------------------------------------------\n");
}
s = ctx->abfd->sections;
for (i = 0; i < ctx->shnum; i++) {
unsigned perms = parse_bfd_perm(s->flags);
if (perms == 5) {
if (ctx->opt_debug) {
printf(" [%2u] \t%-20s\t%012lx-%012lx %lu\t%s\t%lu\n", i + 1,
s->name, s->vma, s->vma + s->size, s->size, "RX",
s->filepos);
}
if ((unsigned long)s->filepos < mintext) {
mintext = s->filepos;
textvma = s->vma;
}
if ((unsigned long)s->filepos + s->size > maxtext) {
maxtext = s->filepos + s->size;
}
}
s = s->next;
}
if (ctx->opt_debug) {
printf(" --> .text future boundaries: offset:%lu sz:%lu vma:%lx\n\n",
mintext, maxtext - mintext, textvma);
}
return 0;
}
static int rd_extended_data(ctx_t * ctx)
{
unsigned int i, perms;
asection *s;
if (ctx->opt_debug) {
printf(" -- Finding .data segment boundaries\n\n");
printf(" index\t\tname\t\t\trange\tsize\tpermissions\toffset\n");
printf("--------------------------------------------------------------------\n");
}
s = ctx->abfd->sections;
for (i = 0; i < ctx->shnum; i++) {
perms = parse_bfd_perm(s->flags);
if (perms == 4) {
if (ctx->opt_debug) {
printf(" [%2u] \t%-20s\t%012lx-%012lx %lu\t%s\t%lu\n", i + 1,
s->name, s->vma, s->vma + s->size, s->size, "RW",
s->filepos);
}
if ((unsigned long)s->filepos < mindata) {
mindata = s->filepos;
datavma = s->vma;
}
if (s->filepos + s->size > maxdata) {
maxdata = s->filepos + s->size;
}
}
s = s->next;
}
if (ctx->opt_debug) {
printf(" --> .data future boundaries: offset:%lu sz:%lu vma:%lx\n\n",
mindata, maxdata - mindata, datavma);
}
return 0;
}
static int extend_text(ctx_t * ctx)
{
unsigned int i;
asection *s;
if (ctx->opt_debug) {
printf(" -- Extending .text\n\n");
}
s = ctx->abfd->sections;
for (i = 0; i < ctx->shnum; i++) {
if (!strncmp(s->name, ".text", 5)) {
orig_text = s->vma;
s->vma = textvma;
s->filepos = mintext;
s->flags = -1;
s->size = maxtext - mintext;
if (ctx->opt_debug) {
printf(" * extending section %s\n", s->name);
printf(" * new .text boundaries: offset:%lu sz:%lu vma:%lx\n\n",
mintext, s->size, textvma);
}
}
s = s->next;
}
return 0;
}
/**
* Display BFD memory sections
*/
int print_bfd_sections(ctx_t * ctx)
{
unsigned int i;
asection *s;
unsigned perms;
char *hperms;
if (ctx->opt_verbose) {
printf("\n -- Input binary sections\n\n");
printf
(" name address range pages perms offset\n");
printf
(" --------------------------------------------------------------------------------\n");
}
s = ctx->abfd->sections;
for (i = 0; i < ctx->shnum; i++) {
perms = parse_bfd_perm(s->flags);
switch (perms) {
case 7:
hperms = "rwx";
break;
case 6:
hperms = "r--";
break;
case 5:
hperms = "r-x";
break;
case 4:
hperms = "rw-";
break;
default:
hperms = "---";
break;
}
if (ctx->opt_verbose) {
printf(" [%2u] %-20s\t%012lx-%012lx %lu\t%s\t%lu\n", i + 1, s->name,
s->vma, s->vma + s->size, s->size, hperms, s->filepos);
}
s = s->next;
}
if (ctx->opt_verbose) {
printf("\n");
}
return 0;
}
/**
* Simple hexdump routine
*/
void hexdump(unsigned char *data, size_t size)
{
size_t i, j;
for (j = 0; j < size; j += 16) {
for (i = j; i < j + 16; i++) {
if (i < size) {
printf("%02x ", data[i] & 255);
} else {
printf(" ");
}
}
printf(" ");
for (i = j; i < j + 16; i++) {
if (i < size)
putchar(32 <= (data[i] & 127)
&& (data[i] & 127) < 127 ? data[i] & 127 : '.');
else
putchar(' ');
}
putchar('\n');
}
}
/**
* Open a binary the best way we can
*/
unsigned int open_best(ctx_t * ctx)
{
int formatok = 0;
// Open as object
formatok = bfd_check_format(ctx->abfd, bfd_object);
ctx->shnum = bfd_count_sections(ctx->abfd);
ctx->corefile = 0;
// Open as core file
if ((!formatok) || (!ctx->shnum)) {
formatok = bfd_check_format(ctx->abfd, bfd_core);
ctx->shnum = bfd_count_sections(ctx->abfd);
ctx->corefile = 1;
}
// Open as archive
if ((!formatok) || (!ctx->shnum)) {
formatok = bfd_check_format(ctx->abfd, bfd_archive);
ctx->shnum = bfd_count_sections(ctx->abfd);
ctx->corefile = 0;
}
if ((!formatok) || (!ctx->shnum)) {
printf(" -- couldn't find a format for %s\n", ctx->binname);
return 0;
}
return ctx->shnum;
}
/**
* Open destination binary
*/
int open_target(ctx_t * ctx)
{
int fd = 0;
struct stat sb;
char *newname;
char *p;
if (stat(ctx->binname, &sb) == -1) {
perror("stat");
exit(EXIT_FAILURE);
}
if ((ctx->opt_binname) && (strlen(ctx->opt_binname))) {
newname = ctx->opt_binname;
} else {
newname = calloc(1, strlen(ctx->binname) + 20);
sprintf(newname, "a.out");
}
if (ctx->opt_debug) {
printf(" -- Creating output file: %s\n\n", newname);
}
fd = open(newname, O_RDWR | O_CREAT | O_TRUNC, 0666);
if (fd <= 0) {
printf(" ERROR: open(%s) %s\n", newname, strerror(errno));
exit(EXIT_FAILURE);
}
// set end of file
ftruncate(fd, sb.st_size);
// Copy default content : poison bytes or original data
p = calloc(1, sb.st_size);
if (ctx->opt_poison) {
// map entire binary with poison byte
memset(p, ctx->opt_poison, sb.st_size);
} else {
// Default : copy original binary
int fdin = open(ctx->binname, O_RDONLY);
read(fdin, p, sb.st_size);
close(fdin);
}
lseek(fd, 0x00, SEEK_SET);
write(fd, p, sb.st_size);
free(p);
lseek(fd, 0x00, SEEK_SET);
ctx->fdout = fd;
return fd;
}
/**
* Write sections to disk
*/
int copy_body(ctx_t * ctx)
{
msec_t *s;
DL_FOREACH(ctx->mshdrs, s) {
write_section(ctx, s);
}
return 0;
}
/**
* Load a binary using bfd
*/
int load_binary(ctx_t * ctx)
{
ctx->abfd = bfd_openr(ctx->binname, NULL);
ctx->shnum = open_best(ctx);
ctx->archsz = bfd_get_arch_size(ctx->abfd);
if (ctx->opt_verbose) {
printf(" -- Architecture size: %u\n", ctx->archsz);
}
return 0;
}
/**
* Return section flags from its name
*/
int flags_from_name(const char *name)
{
ifis(".bss") {
return FLAG_BSS | FLAG_NOBIT | FLAG_NOWRITE;
}
elis(".text") {
return FLAG_TEXT;
}
return 0;
}
/**
* Craft Section header
*/
int craft_section(ctx_t * ctx, msec_t * m)
{
asection *s = m->s_bfd;
Elf_Shdr *shdr = m->s_elf;
unsigned int dalign = 0;
unsigned int dperms = 0;
unsigned perms = parse_bfd_perm(s->flags);
dperms = 0;
switch (perms & 0xf) {
case 7:
dperms = SHF_ALLOC | SHF_WRITE | SHF_EXECINSTR; // "rwx";
break;
case 6:
dperms = SHF_ALLOC; //"r--";
break;
case 5:
dperms = SHF_ALLOC | SHF_EXECINSTR; // "r-x";
break;
case 4:
dperms = SHF_ALLOC | SHF_WRITE; // "rw-"
break;
default:
dalign = 1;
dperms = 0; // "---"
break;
}
// append name to strndx
memcpy(ctx->strndx + ctx->strndx_len, s->name, strlen(s->name));
shdr->sh_name = ctx->strndx_len; // Section name (string tbl index)
shdr->sh_type = typefromname(s->name); // Section type
shdr->sh_flags = dperms; // Section flags
shdr->sh_addr = s->vma; // Section virtual addr at execution
if (ctx->opt_reloc) {
shdr->sh_addr = 0; // vma is null in relocatable files
}
shdr->sh_offset = s->filepos; // Section file offset
shdr->sh_size = s->size; // Section size in bytes
shdr->sh_addralign = dalign ? dalign : alignfromname(s->name); // Section alignment
shdr->sh_entsize = entszfromname(s->name); // Entry size if section holds table
ctx->strndx_len += strlen(s->name) + 1;
return 0;
}
/**
* Read a section from disk
*/
static int read_section(ctx_t * ctx, asection * s)
{
int fd = 0;
unsigned int n, nread = 0, nwrite = 0;
asection *buf;
unsigned int wantedsz = 0;
// Open input binary
fd = open(ctx->binname, O_RDONLY);
if (fd <= 0) {
printf("error: open(%s) : %s\n", ctx->binname, strerror(errno));
exit(0);
}
// Go to correct offset
lseek(fd, s->filepos, SEEK_SET);
// allocate tmp memory
wantedsz = s->size;
if (!strncmp(s->name, ".text", 5)) {
wantedsz = s->size;
}
buf = calloc(1, wantedsz);
// Create Meta section
msec_t *ms = calloc(1, sizeof(msec_t));
if (!ms) {
perror("calloc");
exit(EXIT_FAILURE);
}
ms->s_elf = calloc(1, sizeof(Elf_Shdr));
if (!ms->s_elf) {
perror("calloc");
exit(EXIT_FAILURE);
}
// read data from disk
if (!strncmp(s->name, ".bss", 4)) {
// SHT_NOBITS Section contains no data (Global Uninitialized Data)
n = 0;
buf = realloc(buf, 0);
} else {
// read from disk
n = 0;
nread = read(fd, buf, s->size);
while ((nread != 0) && (n <= s->size)) {
n += nread;
nread = read(fd, buf + n, s->size - n);
}
if ((n != s->size) && (!strncmp(s->name, ".text", 5))) {
n = s->size;
// initialized at 0x00 by calloc
} else if (n != s->size) {
printf("read failed: %u != %u\n", n, (unsigned int) s->size);
}
}
// fill Meta section
ms->s_bfd = s;
ms->len = n;
ms->name = strdup(s->name);
ms->data = (unsigned char *) buf;
ms->outoffset = s->filepos;
// fill ELF section
craft_section(ctx, ms);
ms->flags = flags_from_name(s->name);
// Add to double linked list of msec_t Meta sections
DL_APPEND(ctx->mshdrs, ms);
ctx->mshnum++;
// Close file descriptor
close(fd);
return nwrite;
}
/**
* Display sections
*/
int print_msec(ctx_t * ctx)
{
msec_t *ms;
unsigned int count;
DL_COUNT(ctx->mshdrs, ms, count);
printf(" -- %u elements\n", count);
DL_FOREACH(ctx->mshdrs, ms) {
printf("%s %lu\n", ms->name, ms->len);
}
return 0;
}
/**
* Read sections from input binary
*/
int rd_sections(ctx_t * ctx)
{
unsigned int i;
asection *s = ctx->abfd->sections;
for (i = 0; i < ctx->shnum; i++) {
read_section(ctx, s);
s = s->next;
}
return 0;
}
int save_dynstr(ctx_t * ctx, GElf_Shdr shdr, char *binary)
{
if (globalstrtab == 0) {
globalstrtab = calloc(1, shdr.sh_size + 3);
globalstrtablen++; // Start with a null byte
} else {
globalstrtab = realloc(globalstrtab, globalstrtablen + shdr.sh_size + 2);
}
memcpy(globalstrtab + globalstrtablen, binary + shdr.sh_offset,
shdr.sh_size + 1);
globalstrtablen += shdr.sh_size + 1;
return 0;
}
int save_dynsym(ctx_t * ctx, GElf_Shdr shdr, char *binary)
{
if (globalsymtab == 0) {
globalsymtab = calloc(1, sizeof(Elf_Sym) + shdr.sh_size);
// globalsymtablen += sizeof(Elf_Sym); // Skip 1 NULL entry
} else {
globalsymtab = realloc(globalsymtab, shdr.sh_size + globalsymtablen);
}
memcpy(globalsymtab + globalsymtablen,
binary + shdr.sh_offset + sizeof(Elf_Sym),
shdr.sh_size - sizeof(Elf_Sym));
globalsymtablen += shdr.sh_size - sizeof(Elf_Sym);
return 0;
}
int patch_symbol_index(ctx_t * ctx, Elf_Sym * s)
{
msec_t *sec;
// char *sname;
// sname = globalstrtab + s->st_name;
sec = section_from_index(ctx, s->st_shndx); // section related to this object
if (sec) {
// patch section index in symbol table
s->st_shndx = secindex_from_name_after_strip(ctx, sec->name);
} else {
// printf(" no section info for symbol: %s\n", sname);
}
return 0;
}
int fixup_symtab_section_index(ctx_t * ctx)
{
Elf_Sym *s;
unsigned int sindex;
for (sindex = maxnewsec + 1; sindex < globalsymtablen / sizeof(Elf_Sym);
sindex++) {
// get symbol name from index
s = globalsymtab + sindex * sizeof(Elf_Sym);
if (s->st_shndx) {
patch_symbol_index(ctx, s);
}
}
return 0;
}
int append_reloc(Elf_Rela * r)
{
unsigned int i;
Elf_Rela *s;
// search this address in reloc table
for (i = 0; i < globalreloclen / sizeof(Elf_Rela); i++) {
s = globalreloc + i * sizeof(Elf_Rela);
//
if (s->r_offset == r->r_offset) {
printf("warning: already have a relocation at %lu\n", r->r_offset);
return -1; // already in relocation section
}
}
// save relocation
if (!globalreloc) {
globalreloc = calloc(1, sizeof(Elf_Rela));
} else {
globalreloc = realloc(globalreloc, sizeof(Elf_Rela) + globalreloclen);
}
memcpy(globalreloc + globalreloclen, r, sizeof(Elf_Rela));
globalreloclen += sizeof(Elf_Rela);
return 0;
}
typedef struct gimport_t {
char *sname;
msec_t *sec;
Elf_Rela *r;
int rtype;
unsigned int sindex;
} gimport_t;
gimport_t **gimports = 0;
unsigned int gimportslen = 0;
int save_global_import(ctx_t * ctx, char *sname, msec_t * sec, Elf_Rela * r, unsigned int sindex)
{
int rtype;
gimport_t *g;
Elf_Rela *rnew;
rtype = ELF_R_TYPE(r->r_info);
if (ctx->opt_verbose) {
printf
("recording blobal import variable %s in section: %s\t%s\tat:%lu\toff:%lu\n",
sname, sec->name, reloc_htype(rtype), r->r_offset,
r->r_offset - textvma);
}
g = calloc(1, sizeof(gimport_t));
g->sname = strdup(sname);
g->sec = sec;
g->sindex = sindex; // index of symbol in symbol table
rnew = calloc(1, sizeof(Elf_Rela));
memcpy(rnew, r, sizeof(Elf_Rela));
g->r = rnew;
g->rtype = rtype;
if (!gimports) {
gimports = calloc(1, sizeof(gimport_t *));
} else {
gimports = realloc(gimports, sizeof(gimport_t *) * (gimportslen + 1));
}
gimports[gimportslen++] = g;
return 0;
}
/**
* Return index in global import matching this address
*/
int check_global_import(unsigned long int addr)
{
unsigned i;
if (addr < 4096) {
return -1;
}
for (i = 0; i < gimportslen; i++) {
if ((gimports[i]) && (gimports[i]->r) && (gimports[i]->r->r_offset == addr)) {
return i;
}
}
return -1;
}
int save_reloc(ctx_t * ctx, Elf_Rela * r, unsigned int sindex, int has_addend)
{
Elf_Sym *s;
char *sname = 0;
unsigned int i;
int rtype, outtype;
char *htype;
msec_t *sec;
Elf_Rela *rout;
rout = calloc(1, sizeof(Elf_Rela)); // Work on a copy of the relocation instead of the original one
memcpy(rout, r, sizeof(Elf_Rela));
if (!has_addend) {
rout->r_addend = 0;
};
// search symbol corresponding to this index
if (!globalsymtab) {
printf("warning: no symbol table for relocation index %u\n", sindex);
return 0;
}
if (sindex > globalsymtablen / sizeof(Elf_Sym)) { // verify index is within bound of symtab...
printf("warning: symbol index %u is out of bounds of symbol table\n",
sindex);
return 0;
}
if (!globalstrtab) {
printf("warning: no string table for relocation index %u\n", sindex);
return 0;
}
// get symbol name from index
s = globalsymtab + sindex * sizeof(Elf_Sym);
sname = globalstrtab + s->st_name;
// check if name is "old_" : if so, skip
if (!strncmp(sname, "old_", 4)) {
return -1;
}
// check if name is in blacklist
for (i = 0; i < sizeof(blnames) / sizeof(char *); i++) {
if ((strlen(sname) == strlen(blnames[i]))
&& (!strncmp(sname, blnames[i], strlen(blnames[i])))) {
if (ctx->opt_verbose) {
printf(" * name blacklisted: %s\n", sname);
}
return -1; // Name in blacklist
}
}
if (ctx->opt_debug) {
printf(" * adding relocation for: %s\n", sname);
}
/**
* Convert relocation depending on type and source section
*/
outtype = 0;
rtype = ELF_R_TYPE(rout->r_info);
sec = section_from_index(ctx, s->st_shndx); // section related to this object
if (sec) {
if (!strncmp(sec->name, ".bss", 4)) {
// Save global import
save_global_import(ctx, sname, sec, r, sindex);
return 0;
} else {
// Skip
if (ctx->opt_debug) {
printf
("warning: skipping unknown relocation for symbol: %s in section: %s\t%s\tat:%lu\toff:%lu\n",
sname, sec->name, reloc_htype(rtype), rout->r_offset,
rout->r_offset - textvma);
}
s->st_shndx = 0;
s->st_value = 0; // Actual value is null in this case
return 0;
}
} else if (rtype == R_X86_64_RELATIVE) {
if (ctx->opt_debug) {
printf(" * Not saving Relative relocation %lu %lu\n", rout->r_offset,
rout->r_addend);
}
// rout->r_offset -= textvma;
return 0;
} else { // Jump slots
if (ctx->opt_debug) {
printf(" no section info for symbol: %s\n", sname);
}
//#define R_386_JUMP_SLOT 7
#ifdef __x86_64__
outtype = R_X86_64_64;
#else
outtype = R_386_32;
//printf("textvma: %llx\n", textvma);
// rout->r_addend = +4;
#endif
rout->r_offset -= textvma;
rout->r_info = ELF_R_INFO(sindex, outtype);
}
if (ctx->opt_debug) {
htype = reloc_htype(outtype);
printf("-->> %016lx\t%lu\t%s\t%u\taddend:%lu\t\n\n", rout->r_offset,
rout->r_info, htype, sindex, rout->r_addend);
}
append_reloc(rout);
return 0;
}
#include <capstone/capstone.h>
static void print_string_hex(char *comment, unsigned char *str, size_t len)
{
unsigned char *c;
printf("%s", comment);
for (c = str; c < str + len; c++) {
printf("0x%02x ", *c & 0xff);
}
printf("\n");
}
static void print_insn_detail(ctx_t * ctx, csh handle, cs_mode mode,
cs_insn * ins)
{
int count, i;
cs_x86 *x86;
// detail can be NULL on "data" instruction if SKIPDATA option is turned ON
if (ins->detail == NULL)
return;
x86 = &(ins->detail->x86);
printf("\tAddress: %lu\n", ins->address);
printf("\tInstruction Length: %u\n", ins->size);
print_string_hex("\tPrefix:", x86->prefix, 4);
print_string_hex("\tOpcode:", x86->opcode, 4);
printf("\trex: 0x%x\n", x86->rex);
printf("\taddr_size: %u\n", x86->addr_size);
printf("\tmodrm: 0x%x\n", x86->modrm);
printf("\tdisp: 0x%x\n", x86->disp);
// SIB is not available in 16-bit mode
if ((mode & CS_MODE_16) == 0) {
printf("\tsib: 0x%x\n", x86->sib);
if (x86->sib_base != X86_REG_INVALID)
printf("\t\tsib_base: %s\n", cs_reg_name(handle, x86->sib_base));
if (x86->sib_index != X86_REG_INVALID)
printf("\t\tsib_index: %s\n", cs_reg_name(handle, x86->sib_index));
if (x86->sib_scale != 0)
printf("\t\tsib_scale: %d\n", x86->sib_scale);
}
// SSE code condition
if (x86->sse_cc != X86_SSE_CC_INVALID) {
printf("\tsse_cc: %u\n", x86->sse_cc);
}
// AVX code condition
if (x86->avx_cc != X86_AVX_CC_INVALID) {
printf("\tavx_cc: %u\n", x86->avx_cc);
}
// AVX Suppress All Exception
if (x86->avx_sae) {
printf("\tavx_sae: %u\n", x86->avx_sae);
}
// AVX Rounding Mode
if (x86->avx_rm != X86_AVX_RM_INVALID) {
printf("\tavx_rm: %u\n", x86->avx_rm);
}
count = cs_op_count(handle, ins, X86_OP_IMM);
if (count) {
printf("\timm_count: %u\n", count);
for (i = 1; i < count + 1; i++) {
int index = cs_op_index(handle, ins, X86_OP_IMM, i);
printf("\t\timms[%u]: 0x%" PRIx64 "\n", i, x86->operands[index].imm);
}
}
if (x86->op_count)
printf("\top_count: %u\n", x86->op_count);
for (i = 0; i < x86->op_count; i++) {
cs_x86_op *op = &(x86->operands[i]);
switch ((int) op->type) {
case X86_OP_REG:
printf("\t\toperands[%u].type: REG = %s\n", i,
cs_reg_name(handle, op->reg));
break;
case X86_OP_IMM:
printf("\t\toperands[%u].type: IMM = 0x%" PRIx64 "\n", i, op->imm);
break;
case X86_OP_MEM:
printf("\t\toperands[%u].type: MEM\n", i);
if (op->mem.segment != X86_REG_INVALID)
printf("\t\t\toperands[%u].mem.segment: REG = %s\n", i,
cs_reg_name(handle, op->mem.segment));
if (op->mem.base != X86_REG_INVALID)
printf("\t\t\toperands[%u].mem.base: REG = %s\n", i,
cs_reg_name(handle, op->mem.base));
if (op->mem.index != X86_REG_INVALID)
printf("\t\t\toperands[%u].mem.index: REG = %s\n", i,
cs_reg_name(handle, op->mem.index));
if (op->mem.scale != 1)
printf("\t\t\toperands[%u].mem.scale: %u\n", i, op->mem.scale);
if (op->mem.disp != 0)
printf("\t\t\toperands[%u].mem.disp: 0x%" PRIx64 "\n", i, op->mem.disp);
break;
default:
break;
}
// AVX broadcast type
if (op->avx_bcast != X86_AVX_BCAST_INVALID)
printf("\t\toperands[%u].avx_bcast: %u\n", i, op->avx_bcast);
// AVX zero opmask {z}
if (op->avx_zero_opmask != false)
printf("\t\toperands[%u].avx_zero_opmask: TRUE\n", i);
printf("\t\toperands[%u].size: %u\n", i, op->size);
}
printf("\n");
}
static int create_text_data_reloc(ctx_t * ctx, cs_insn * ins, msec_t * m,
unsigned int soff, int rip_relative, unsigned int argnum)
{
unsigned int sindex = 0;
unsigned int wheretowrite = 0;
unsigned int n = 0;
int gimport = -1;
cs_x86 *x86;
x86 = &(ins->detail->x86);
n = x86->op_count;
wheretowrite = ins->size - 4;
if (ctx->opt_debug) {
printf(" --> transforming relocation from section: %s at ", m->name);
printf("0x%" PRIx64 ":\t%s\t%s\tinslen:%u argoffset:%u\n", ins->address,
ins->mnemonic, ins->op_str, ins->size, wheretowrite);
}
sindex = secindex_from_name_after_strip(ctx, m->name);
if ((!strncmp(m->name, ".bss", 4)) && (n == 2) && (!rip_relative)) {
gimport = check_global_import(x86->operands[1].imm);
}
if (rip_relative) {
// printf(" ** destination: %lx\n", x86->operands[1]->mem.disp + ins->address + 7);
gimport = check_global_import(x86->operands[1].mem.disp + ins->address + 7);
if (ctx->opt_debug) {
printf("** global imports match : %d\n", gimport);
}
}
if ((gimport != -1) && (!rip_relative)) { // Relocation to .bss with a known global import
if (ctx->opt_debug) {
printf(" * known imported global : %s\n", gimports[gimport]->sname);
}
Elf_Rela *r = calloc(1, sizeof(Elf_Rela));
if (!r) {
perror("calloc");
exit(-1);
}
sindex = gimports[gimport]->sindex;
// reset string index in symbol table
Elf_Sym *st = 0;
st = globalsymtab + gimports[gimport]->sindex * sizeof(Elf_Sym);
st->st_shndx = 0;
st->st_value = 0;
r->r_info = ELF_R_INFO(gimports[gimport]->sindex, R_X86_64_PC32);
r->r_addend = 0; //-4;
r->r_offset = ins->address - textvma + wheretowrite;
// patch back binary
msec_t *t = section_from_name(ctx, ".text");
memset(t->data + r->r_offset, 0x00, 4);
if (ctx->opt_debug) {
printf("%" PRIx64 "\t%s+%u\t\t\t(%s %s)\n", ins->address, m->name, soff,
ins->mnemonic, ins->op_str);
printf("%012lx\t%012lx\t%s\t%012x\t%s+%u\n", r->r_offset, r->r_info,
"R_X86_64_32", 0, m->name, soff);
}
// append relocation
append_reloc(r);
free(r);
} else if ((gimport != -1) && (rip_relative)) { // Relocation to .bss with a known global import via rip relative
if (ctx->opt_debug) {
printf(" * known imported global (rip relative) : %s\n",
gimports[gimport]->sname);
}
Elf_Rela *r = calloc(1, sizeof(Elf_Rela));
if (!r) {
perror("calloc");
exit(-1);
}
sindex = gimports[gimport]->sindex;
// reset string index in symbol table
Elf_Sym *st = 0;
st = globalsymtab + gimports[gimport]->sindex * sizeof(Elf_Sym);
st->st_shndx = 0;
st->st_value = 0;
r->r_info = ELF_R_INFO(gimports[gimport]->sindex, R_X86_64_PC32);
r->r_addend = -4;
r->r_offset = ins->address - textvma + wheretowrite;
// patch back binary
msec_t *t = section_from_name(ctx, ".text");
memset(t->data + r->r_offset, 0x00, 4);
if (ctx->opt_debug) {
printf("%012lx\t%012lx\t%s\t%012x\t%s+%ld\n", r->r_offset, r->r_info,
"R_X86_64_32", 0, gimports[gimport]->sname, r->r_addend);
}
// append relocation
append_reloc(r);
free(r);
} else if (sindex) { // Any other local section relocation (.rodata, .data ...)
Elf_Rela *r = calloc(1, sizeof(Elf_Rela));
if (!r) {
perror("calloc");
exit(-1);
}
if (ctx->opt_debug) {
printf("new %s sindex:%u addent:%u, off:0x%lx\thasrel:%u\n",
rip_relative ? "rip relative local" : "local", sindex, soff,
ins->address - textvma + wheretowrite,
ctx->has_relativerelocations);
}
int newtype;
#ifdef __x86_64__
newtype = ctx->has_relativerelocations ? R_X86_64_PC32 : R_X86_64_32;
#else
#ifdef __i386__
newtype = R_386_32; //R_386_PLT32;//R_386_GOTOFF;//R_386_GOTPC; //R_386_GOT32; //R_386_COPY; //R_386_RELATIVE; //R_386_PC32; //R_386_GLOB_DAT; //R_386_32;
#endif
#endif
// patch back .text
msec_t *t = section_from_name(ctx, ".text");
if (argnum == 0) { // typically: cmp [rip+0xdeadbeef], 0 or something like mov qword ptr [rip+0xdeadbeef], rax
/*
* find at witch position we shall patch by scanning memory for the memory displacement
*/
for (wheretowrite = 0; wheretowrite <= ins->size; wheretowrite++) {
unsigned int searchval = x86->operands[0].mem.disp;
if (!memcmp
(t->data + (ins->address - textvma + wheretowrite), &searchval,
4)) {
// printf(" * patching instruction at offset: %u addend: %d relative:%d\n", wheretowrite, soff, rip_relative ? rip_relative : 0);
break;
}
}
// not found ? Fatal error
if (wheretowrite == ins->size) {
printf("error: can't find patch location\n");
exit(-1);
}
}
if (rip_relative) { // compute new addend and set reloc type
cs_x86_op *op = &(x86->operands[argnum]);
r->r_addend = ((op->mem.disp) + ins->address) - m->s_bfd->vma; // (rip + (immediate|displacement)) - m->s_bfd->vma; // dst - (section vma)
// printf("* new rip based addend : %llx\n", r->r_addend);
newtype = R_X86_64_PC32;
} else {
r->r_addend = soff; // default
}
r->r_info = ELF_R_INFO(sindex, newtype);
r->r_offset = ins->address - textvma + wheretowrite;
if ((argnum == 0) && (rip_relative)) { // write at custom location
memset(t->data + r->r_offset, 0x00, 4); // write back where computed previously
// r->r_addend = -4;
} else if (rip_relative) { // patch back register index (from rip to 0x00)
memset(t->data + r->r_offset, 0x00, 4); // write back 4 bytes (one 32b address) + 1 if relative (overwrite rip)
// r->r_addend = 0;//0x29a;
} else if (ELFMACHINE == EM_386) { // R_386_32 doesn't account for the addend : write it back to .text
memcpy(t->data + r->r_offset, &soff, 4);
} else {
memset(t->data + r->r_offset, 0x00, 4); // write back 4 bytes (one 32b address) + 1 if relative (overwrite rip)
}
/**
* FIXED : Problem : http://fossies.org/linux/glibc/sysdeps/x86_64/dl-machine.h line 452 : possible overflow in relocation amd64 when using type R_X86_64_32 : should be fixed
*
*/
// if (ctx->opt_verbose) {
// printf("%"PRIx64"\t%s+0x%lx\t\t\t(%s %s)\n",ins->address, m->name, soff, ins->mnemonic, ins->op_str);
// printf("%012lx\t%012lx\t%s\t%s+%u\n", r->r_offset, r->r_info, reloc_htype(newtype), m->name, soff);
// }
// append relocation
append_reloc(r);
free(r);
} else { // Unhandled relocation
if (ctx->opt_debug) {
printf("warning: unknown relocation section: %s at ", m->name);
printf("0x%" PRIx64 ":\t%s\t%s\n", ins->address, ins->mnemonic,
ins->op_str);
}
}
return 0;
}
int internal_function_store(ctx_t * ctx, unsigned long long int addr)
{
unsigned int i;
char buff[200];
Elf_Sym *s = 0;
memset(buff, 0x00, 200);
snprintf(buff, 200, "internal_%08llx", addr);
// search this symbol in string table
for (i = 0; i < globalstrtablen; i += strlen(globalstrtab + i) + 1) {
if (!strncmp(globalstrtab + i, buff, strlen(buff))) {
return -1; // already in strtab, hence in symtab
}
}
// search this address in symbol table
for (i = 0; i < globalsymtablen / sizeof(Elf_Sym); i++) {
s = globalsymtab + i * sizeof(Elf_Sym);
//
if (s->st_value == addr) {
return -1; // already in symtab
}
}
add_symaddr(ctx, buff, addr, 0x54);
return 0;
}
static void parse_text_data_reloc(ctx_t * ctx, csh ud, cs_mode mode,
cs_insn * ins)
{
int i;
cs_x86 *x86;
msec_t *m;
// detail can be NULL on "data" instruction if SKIPDATA option is turned ON
if (ins->detail == NULL)
return;
x86 = &(ins->detail->x86);
// if(ctx->opt_debug){
// printf("\t\tRELOC Address: %lu\n", ins->address);
// printf("\t\tRELOC operands.type: MEM, opcount:%u\n", x86->op_count);
// }
for (i = 0; i < x86->op_count; i++) {
cs_x86_op *op = &(x86->operands[i]);
m = 0;
switch ((int) op->type) {
case X86_OP_IMM:
;
m = section_from_addr(ctx, op->imm);
if (m) {
if (i == 1) { // only match arg=1 // second argument is of form [0xdeadbeef]
create_text_data_reloc(ctx, ins, m, op->imm - m->s_bfd->vma, 0, i);
} else if (i == 0) { // first argument is of form [0xdeadbeef]
if ((!strncmp(ins->mnemonic, "call", 4))
&& (!strncmp(m->name, ".text", 5))) {
// printf(" --> call to internal function at %lx\n", op->imm);
internal_function_store(ctx, op->imm);
} else {
// TODO instrument internal/cross sections jumps and calls
// printf("We have a problem: (dst section: %s)\n", m->name);
// printf("0x%llx %s %s\n", ins->address, ins->mnemonic, ins->op_str);
}
}
}
break;
case X86_OP_MEM:
;
m = section_from_addr(ctx, op->mem.disp + ins->address + 10 * ctx->has_relativerelocations); // assume rip relative
//printf("sec name: %s\t%lx\n", m ? m->name : "-", op->mem.disp + ins->address + 10*ctx->has_relativerelocations);
if ((m) && (m->name) && (strncmp(m->name, ".text", 5) || ctx->has_relativerelocations) && (cs_reg_name(ud, op->mem.base)) && (!strncmp(cs_reg_name(ud, op->mem.base), "rip", 3))) { // destination section can't be .text, must be rip relative
if (i == 1) { // only match arg=1
create_text_data_reloc(ctx, ins, m, op->mem.disp + ins->address - m->s_bfd->vma, 1, i); // Addressing is rip relative
break;
}
}
if (!strncmp(ins->mnemonic, "nop", 3)) { // ignore nops
break;
}
// handle write to 1st argument, which is a rip relative mapped section
if ((i == 0) && (m) && (m->name)
&& (strncmp(m->name, ".text", 5) || ctx->has_relativerelocations)
&& (cs_reg_name(ud, op->mem.base))
&& (!strncmp(cs_reg_name(ud, op->mem.base), "rip", 3))) {
// printf(" * handling 1st arg access : %llx %s %s (%s)\n",ins->address, ins->mnemonic, ins->op_str, m ? m->name : "-");
create_text_data_reloc(ctx, ins, m, op->mem.disp + ins->address - m->s_bfd->vma, 1, i); // Addressing is rip relative
break;
}
break;
case X86_OP_REG:
// case X86_OP_MEM:
default:
break;
}
}
}
int analyze_text(ctx_t * ctx, char *data, unsigned int datalen,
unsigned long int addr)
{
csh handle;
cs_insn *insn;
size_t count;
size_t j;
if (cs_open(CS_ARCH_X86, CS_MODE, &handle)) {
printf("error: Failed to initialize capstone library\n");
return -1;
}
// request disassembly details
cs_option(handle, CS_OPT_DETAIL, CS_OPT_ON);
count = cs_disasm(handle, (const uint8_t *)data, datalen - 1, addr, 0, &insn);
if (!count) {
printf("error: Cannot disassemble code\n");
return -1;
}
if (ctx->opt_asmdebug) {
printf(" -- parsing %lu instructions from %lx (.text) for relocations\n\n",
count, addr);
printf
("\n Offset Info Type Sym. Value Sym. Name + Addend\n");
}
// scan instructions for relocations
for (j = 0; j < count; j++) {
if (ctx->opt_asmdebug) {
printf("0x%" PRIx64 ":\t%s\t%s\n", insn[j].address, insn[j].mnemonic,
insn[j].op_str);
print_insn_detail(ctx, handle, CS_MODE, &insn[j]);
}
parse_text_data_reloc(ctx, handle, CS_MODE, &insn[j]);
}
cs_free(insn, count);
cs_close(&handle);
return 0;
}
/**
* Read original symtab + strtab. BDF doesn't do this
*/
int rd_symtab(ctx_t * ctx)
{
Elf *elf;
Elf_Scn *scn = NULL;
GElf_Shdr shdr;
int fd;
const char *binary;
struct stat sb;
size_t shstrndx;
char *sname = 0;
if (ctx->opt_debug) {
printf(" -- searching for .strtab/.symtab\n");
}
elf_version(EV_CURRENT);
fd = open(ctx->binname, O_RDONLY);
fstat(fd, &sb);
binary = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (binary == MAP_FAILED) {
perror("mmap");
exit(EXIT_FAILURE);
}
elf = elf_begin(fd, ELF_C_READ, NULL);
if (!elf) {
printf("error: not a valid ELF\n");
return -1;
}
if (elf_getshdrstrndx(elf, &shstrndx) != 0) {
printf("error: in elf_getshdrstrndx\n");
return -1;
}
while ((scn = elf_nextscn(elf, scn)) != NULL) {
gelf_getshdr(scn, &shdr);
sname = elf_strptr(elf, shstrndx, shdr.sh_name);
switch (shdr.sh_type) {
case SHT_SYMTAB:
if (ctx->opt_debug) {
printf(" * symbol table at offset:%lu, sz:%lu\n", shdr.sh_offset,
shdr.sh_size);
}
break;
case SHT_STRTAB:
if (!strncmp(sname, ".dynstr", 7)) {
if (ctx->opt_debug) {
printf(" * dynamic string table at offset:%lu, sz:%lu\n",
shdr.sh_offset, shdr.sh_size);
}
save_dynstr(ctx, shdr, binary);
} else {
if (ctx->opt_debug) {
printf(" * string table at offset:%lu, sz:%lu\n", shdr.sh_offset,
shdr.sh_size);
}
}
break;
case SHT_DYNSYM:
if (ctx->opt_debug) {
printf(" * dynamic symbol table at offset:%lu, sz:%lu\n",
shdr.sh_offset, shdr.sh_size);
}
save_dynsym(ctx, shdr, binary);
break;
default:
break;
}
}
elf_end(elf);
close(fd);
if ((ctx->opt_verbose) || (ctx->opt_debug)) {
printf("\n");
}
return 0;
}
/**
* Suppress a given section
*/
int rm_section(ctx_t * ctx, char *name)
{
msec_t *s;
msec_t *rmsec = 0;
DL_FOREACH(ctx->mshdrs, s) {
if (!strncmp(s->name, name, strlen(name))) {
rmsec = s;
break;
}
}
if (!rmsec) {
return 0;
} // Not found
DL_DELETE(ctx->mshdrs, rmsec);
ctx->shnum--;
ctx->mshnum--;
return 0;
}
/**
* Strip binary relocation data
*/
int strip_binary_reloc(ctx_t * ctx)
{
msec_t *s, *tmp;
unsigned int allowed, i;
if (ctx->opt_verbose) {
printf("\n -- Stripping\n\n");
}
DL_FOREACH_SAFE(ctx->mshdrs, s, tmp) {
allowed = 0;
for (i = 0; i < sizeof(allowed_sections) / sizeof(char *); i++) {
if (!strncmp(s->name, allowed_sections[i], strlen(allowed_sections[i]))) {
allowed = 1;
break;
}
}
if (!allowed) {
if (ctx->opt_verbose) {
printf(" * %s\n", s->name);
}
rm_section(ctx, s->name);
}
}
if (ctx->opt_verbose) {
printf("\n");
}
return 0;
}
/**
* Main routine
*/
unsigned int libify(ctx_t * ctx)
{
char const *target = NULL;
int is_pe64 = 0, is_pe32 = 0;
/**
*
* LOAD OPERATIONS
*
*/
/**
* Load each section of binary using bfd
*/
load_binary(ctx);
/**
* Print BFD sections
*/
print_bfd_sections(ctx);
/**
* Read .text segment boundaries
*/
rd_extended_text(ctx);
rd_extended_data(ctx);
extend_text(ctx);
/**
* Open target binary
*/
open_target(ctx);
/**
* Read sections from disk
*/
rd_sections(ctx);
create_section_symbols(ctx);
/**
* Read symtab + strtab : BFD doesn't do this
*/
rd_symtab(ctx);
fixup_strtab_and_symtab(ctx);
/**
* Read symbols
*/
target = bfd_get_target(ctx->abfd);
is_pe64 = (strcmp(target, "pe-x86-64") == 0
|| strcmp(target, "pei-x86-64") == 0);
is_pe32 = (strcmp(target, "pe-i386") == 0 || strcmp(target, "pei-i386") == 0
|| strcmp(target, "pe-arm-wince-little") == 0
|| strcmp(target, "pei-arm-wince-little") == 0);
if ((is_pe64) || (is_pe32)) {
printf("target: %s\n", target);
} else {
rd_symbols(ctx);
}
fixup_text(ctx);
/**
* Add extra symbols
*/
add_extra_symbols(ctx);
/**
* Parse relocations
*/
parse_relocations(ctx);
/**
* Fix section indexes in symtab
*/
fixup_symtab_section_index(ctx);
process_text(ctx);
/**
*
* PROCESSING
*
*/
/**
* Copy each section content in output file
*/
copy_body(ctx);
/**
* Relocation stripping
*/
if ((ctx->opt_static) || (ctx->opt_reloc)) {
rm_section(ctx, ".interp");
rm_section(ctx, ".dynamic");
}
if (ctx->opt_reloc) {
strip_binary_reloc(ctx);
}
/**
* Create Program Headers
*/
if (!ctx->opt_original) {
mk_phdrs(ctx); // Create Program Headers from sections
} else {
// Read Original Program Headers
rd_phdrs(ctx);
}
/**
*
* FINAL WRITE OPERATIONS
*
*/
/**
* Write strtab and symtab
*/
write_strtab_and_reloc(ctx);
/**
* Add section headers to output file
*/
if (!ctx->opt_sstrip) {
write_shdrs(ctx);
}
/**
* Add segment headers to output file
*/
if (!ctx->opt_reloc) {
if (!ctx->opt_original) {
write_phdrs(ctx);
} else {
write_phdrs_original(ctx);
}
}
/**
* Add ELF Header to output file
*/
mk_ehdr(ctx);
/**
* Finalize/Close/Cleanup
*/
return 0;
}
/**
* Print content of /proc/pid/maps
*/
int print_maps(void)
{
char cmd[1024];
sprintf(cmd, "cat /proc/%u/maps", getpid());
system(cmd);
return 0;
}
/**
* Initialize a reversing context
*/
ctx_t *ctx_init(void)
{
ctx_t *ctx;
bfd_init();
errno = 0;
ctx = calloc(1, sizeof(ctx_t));
if (!ctx) {
printf("error: calloc(): %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
/**
* Set default values
*/
ctx->strndx = calloc(1, DEFAULT_STRNDX_SIZE);
ctx->mshdrs = NULL;
return ctx;
}
int usage(char *name)
{
printf("Usage: %s [options] file\n", name);
printf("\noptions:\n\n");
printf(" -o, --output <output file>\n");
printf(" -m, --march <architecture>\n");
printf(" -e, --entrypoint <0xaddress>\n");
printf(" -i, --interpreter <interpreter>\n");
printf(" -p, --poison <poison>\n");
printf(" -s, --shared\n");
printf(" -c, --compile\n");
printf(" -S, --static\n");
printf(" -x, --strip\n");
printf(" -X, --sstrip\n");
printf(" -E, --exec\n");
printf(" -C, --core\n");
printf(" -O, --original\n");
printf(" -D, --disasm\n");
printf(" -d, --debug\n");
printf(" -h, --help\n");
printf(" -v, --verbose\n");
printf(" -V, --version\n");
printf("\n");
return 0;
}
int print_version(void)
{
printf("%s version:%s (%s %s)\n", WNAME, WVERSION, WTIME, WDATE);
return 0;
}
int desired_arch(ctx_t * ctx, char *name)
{
unsigned int i = 0;
for (i = 0; i < sizeof(wccarch) / sizeof(archi_t); i++) {
if (!strncmp(wccarch[i].name, name, strlen(name))) {
if (ctx->opt_verbose) {
printf(" * architecture: %s\n", name);
}
return wccarch[i].value;
}
}
printf("error: architecture %s not supported\n", name);
exit(EXIT_FAILURE);
return 0;
}
int ctx_getopt(ctx_t * ctx, int argc, char **argv)
{
const char *short_opt = "ho:i:scSEsxCvVXp:Odm:e:f:D";
int count = 0;
struct stat sb;
int c;
struct option long_opt[] = {
{"help", no_argument, NULL, 'h'},
{"march", required_argument, NULL, 'm'},
{"output", required_argument, NULL, 'o'},
{"shared", no_argument, NULL, 's'},
{"compile", no_argument, NULL, 'c'},
{"debug", no_argument, NULL, 'd'},
{"disasm", no_argument, NULL, 'D'},
{"static", no_argument, NULL, 'S'},
{"exec", no_argument, NULL, 'E'},
{"core", no_argument, NULL, 'C'},
{"strip", no_argument, NULL, 'x'},
{"sstrip", no_argument, NULL, 'X'},
{"entrypoint", required_argument, NULL, 'e'},
{"interpreter", required_argument, NULL, 'i'},
{"poison", required_argument, NULL, 'p'},
{"original", no_argument, NULL, 'O'},
{"verbose", no_argument, NULL, 'v'},
{"version", no_argument, NULL, 'V'},
{NULL, 0, NULL, 0}
};
// Parse options
if (argc < 2) {
print_version();
printf("\n");
usage(argv[0]);
exit(EXIT_SUCCESS);
}
while ((c = getopt_long(argc, argv, short_opt, long_opt, NULL)) != -1) {
count++;
switch (c) {
case -1: /* no more arguments */
case 0:
break;
case 'c':
ctx->opt_reloc = 1;
break;
case 'C':
ctx->opt_core = 1;
break;
case 'd':
ctx->opt_debug = 1;
ctx->opt_verbose = 1;
break;
case 'D':
ctx->opt_asmdebug = 1;
break;
case 'e':
ctx->opt_entrypoint = strtoul(optarg, NULL, 16);
count++;
break;
case 'E':
ctx->opt_exec = 1;
break;
case 'f':
ctx->opt_flags = strtoul(optarg, NULL, 16);
count++;
break;
case 'h':
usage(argv[0]);
exit(0);
break;
case 'i':
ctx->opt_interp = strdup(optarg);
count++;
break;
case 'm':
ctx->opt_arch = desired_arch(ctx, optarg);
count++;
break;
case 'o':
ctx->opt_binname = strdup(optarg);
count++;
break;
case 'O':
ctx->opt_original = 1;
break;
case 'p':
ctx->opt_poison = optarg[0];
count++;
break;
case 's':
ctx->opt_shared = 1;
break;
case 'S':
ctx->opt_static = 1;
break;
case 'v':
ctx->opt_verbose = 1;
break;
case 'V':
print_version();
exit(EXIT_SUCCESS);
break;
case 'x':
ctx->opt_strip = 1;
break;
case 'X':
ctx->opt_sstrip = 1;
break;
case ':':
case '?':
fprintf(stderr, "Try `%s --help' for more information.\n", argv[0]);
exit(-2);
default:
fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c);
fprintf(stderr, "Try `%s --help' for more information.\n", argv[0]);
exit(-2);
};
};
// arguments sanity checks
if (count >= argc - 1) {
fprintf(stderr, "error: No source binary found in arguments.\n");
fprintf(stderr, "Try `%s --help' for more information.\n", argv[0]);
exit(-2);
}
// verify target file exists
if (stat(argv[count + 1], &sb)) {
printf("error: Could not open file %s : %s\n", argv[count + 1],
strerror(errno));
exit(EXIT_FAILURE);
}
// store original size
orig_sz = sb.st_size;
if (ctx->opt_debug) {
printf(" -- Analysing: %s\n", argv[count + 1]);
}
// copy target file name
ctx->binname = strdup(argv[count + 1]);
return 0;
}
/**
* Application Entry Point
*/
int main(int argc, char **argv)
{
ctx_t *ctx;
ctx = ctx_init();
ctx_getopt(ctx, argc, argv);
libify(ctx);
return 0;
}
| 23.094047 | 245 | 0.607062 |
98267b424b48d6b7fe2f624783bcf3d7e9e2e4d5 | 1,886 | h | C | Tools/include/compat/cm-wc.h | steakknife/pcgeos | 95edd7fad36df400aba9bab1d56e154fc126044a | [
"Apache-2.0"
] | 504 | 2018-11-18T03:35:53.000Z | 2022-03-29T01:02:51.000Z | Tools/include/compat/cm-wc.h | steakknife/pcgeos | 95edd7fad36df400aba9bab1d56e154fc126044a | [
"Apache-2.0"
] | 96 | 2018-11-19T21:06:50.000Z | 2022-03-06T10:26:48.000Z | Tools/include/compat/cm-wc.h | steakknife/pcgeos | 95edd7fad36df400aba9bab1d56e154fc126044a | [
"Apache-2.0"
] | 73 | 2018-11-19T20:46:53.000Z | 2022-03-29T00:59:26.000Z | /***********************************************************************
*
* Copyright (c) Geoworks 1996 -- All Rights Reserved
*
* PROJECT: Tools
* MODULE: Unix compatibility library
* FILE: cm-wc.h
*
* AUTHOR: Jacob A. Gabrielson: May 3, 1996
*
* REVISION HISTORY:
* Name Date Description
* ---- ---- -----------
* JAG 5/ 3/96 Initial version
*
* DESCRIPTION:
* Do not include this file directly. It is meant to be included
* via config.h. See config.h for details.
*
*
* $Id: cm-bor.h,v 1.2 97/04/17 17:19:06 dbaumann Exp $
*
***********************************************************************/
#ifndef _CM_WC_H_
#define _CM_WC_H_
#ifndef __WATCOMC__
#error Why are you including this file?
#endif
/***********************************************************************
*
* Remap routine names with macros
*
***********************************************************************/
/***********************************************************************
*
* Define any routines provided by this compiler's runtime
*
***********************************************************************/
#include <math.h>
//#include <io.h>
#define HAVE_DIRENT
#define HAVE_BCMP
#define HAVE_BCOPY
#define HAVE_BZERO
#define HAVE_ISINF
#define HAVE_MKTEMP
/***********************************************************************
*
* Define compiler's behavior
*
***********************************************************************/
/* Borland likes char foo[], not char foo[0]. */
#define LABEL_IN_STRUCT
/* Borland doesn't allow arithmetic on void *. */
typedef char *genptr;
typedef void *genptrparam ;
/* Borland doesn't support the inline keyword in any obvious way. */
#define inline
/* Borland uses _popen() instead of popen() */
#define popen _popen
#define pclose _pclose
#define mktemp _mktemp
#endif /* _CM_WC_H_ */
| 24.815789 | 73 | 0.469247 |
817111599d51b8e9a86b7ecea729276c25e12c96 | 2,811 | h | C | example_audiodevice_switcher/src/ofApp.h | d3cod3/ofxPDSP | a64410c1dd0231de2a3fde6c81da6ea9043b3d11 | [
"MIT"
] | null | null | null | example_audiodevice_switcher/src/ofApp.h | d3cod3/ofxPDSP | a64410c1dd0231de2a3fde6c81da6ea9043b3d11 | [
"MIT"
] | null | null | null | example_audiodevice_switcher/src/ofApp.h | d3cod3/ofxPDSP | a64410c1dd0231de2a3fde6c81da6ea9043b3d11 | [
"MIT"
] | null | null | null | #pragma once
#include "ofMain.h"
#include "ofxPDSP.h"
#include "ofxImGui.h"
#include "imgui_plot.h"
class ofApp : public ofBaseApp, pdsp::Wrapper{
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void mouseEntered(int x, int y);
void mouseExited(int x, int y);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
void reloadEngine(int inDev, int outDev);
// pdsp modules
pdsp::Engine *engine;
ofSoundBuffer inputBuffer;
ofSoundBuffer emptyBuffer;
vector<ofSoundDevice> audioDevices;
vector<string> audioDevicesStringIN;
vector<string> audioDevicesStringOUT;
vector<int> audioDevicesID_IN;
vector<int> audioDevicesID_OUT;
ofSoundStream soundStreamIN;
ofSoundBuffer lastInputBuffer;
int audioINDev;
int audioOUTDev;
int audioGUIINIndex;
int audioGUIOUTIndex;
int audioSampleRate;
int audioBufferSize;
// GUI
ofxImGui::Gui gui;
float input_scope[1024];
private:
void audioProcess(float *input, int bufferSize, int nChannels);
mutable ofMutex audio_mutex;
};
//--------------------------------------------------------------
inline void drawWaveform(ImDrawList* drawList, ImVec2 dim, float* data, int dataSize, float thickness, ImU32 color){
// draw signal background
drawList->AddRectFilled(ImGui::GetWindowPos(),ImGui::GetWindowPos()+dim,IM_COL32_BLACK);
// draw signal plot
ImGuiEx::PlotConfig conf;
conf.values.ys = data;
conf.values.count = dataSize;
conf.values.color = color;
conf.scale.min = -1;
conf.scale.max = 1;
conf.tooltip.show = false;
conf.tooltip.format = "x=%.2f, y=%.2f";
conf.grid_x.show = false;
conf.grid_y.show = false;
conf.frame_size = ImVec2(dim.x, dim.y);
conf.line_thickness = thickness;
ImGuiEx::Plot("plot", conf);
}
//--------------------------------------------------------------
static inline float hardClip(float x){
float x1 = fabsf(x + 1.0f);
float x2 = fabsf(x - 1.0f);
return 0.5f * (x1 - x2);
}
| 31.233333 | 116 | 0.533974 |
6907ac47d9ab3364fc8cd3bce1afd91bb17465dc | 7,602 | h | C | Plugins/TobiiEyeX/Source/TobiiEyeX/Private/EyeXBlueprintLibrary.h | Temaran/EyeXforUE4 | ac37dd06fb23849a9aeb373b98090ded0cd49498 | [
"Zlib"
] | 9 | 2016-06-11T15:17:56.000Z | 2021-03-20T10:50:05.000Z | Plugins/TobiiEyeX/Source/TobiiEyeX/Private/EyeXBlueprintLibrary.h | Temaran/EyeXforUE4 | ac37dd06fb23849a9aeb373b98090ded0cd49498 | [
"Zlib"
] | 20 | 2017-02-07T14:20:29.000Z | 2017-03-29T05:46:31.000Z | Plugins/TobiiEyeX/Source/TobiiEyeX/Private/EyeXBlueprintLibrary.h | dschmidl/Forschungsseminar | f809a9571b46de3eec17dc6e77e526019a30a96b | [
"Zlib"
] | 2 | 2017-01-20T08:49:22.000Z | 2021-11-15T02:28:10.000Z | // Copyright 2014 Tobii Technology AB. All Rights Reserved.
#pragma once
#include "EyeXTypes.h"
#include "EyeXBlueprintLibrary.generated.h"
class IEyeXPlugin;
/**
* A blueprint library class to expose the functionality of the EyeX plugin to blueprints
* in all blueprint contexts.
*/
UCLASS()
class UEyeXBlueprintLibrary : public UBlueprintFunctionLibrary
{
GENERATED_UCLASS_BODY()
public:
/**
* Gets the latest eye-gaze data point of the specified mode.
*
* @param Mode - Specifies the kind of data processing to be applied by the EyeX Engine.
* Unfiltered: Unfiltered data from the eye tracker. The most responsive mode,
* but can jitter a lot.
* LightlyFiltered: A light filtering applied by the EyeX Engine. Less
* jittering but also slightly less responsive.
* @param GazePoint - The gaze point in viewport coordinates (pixels).
* @param TimeStamp - The time this data was created in milliseconds.
* @param bHasValue - Indicates whether the data point is valid.
*/
UFUNCTION(BlueprintPure, Category = "EyeX")
static void GetGazePoint(EEyeXGazePointDataMode::Type Mode, FVector2D& GazePoint, float& Timestamp, bool& bHasValue);
/**
* Gets the latest eye-gaze data point of the specified mode in 3D space.
* The origin of this coordinate system is in the center of the screen with the X-axis pointing
* into the screen (in the direction away from the user), the Y-axis to the right and the
* Z-axis pointing upwards.
* The data is in cm.
*
* @param Mode - Specifies the kind of data processing to be applied by the EyeX Engine.
* @param GazePoint - the gaze point in 3D coordinates.
* @param bHasValue - Indicates whether the data point is valid.
*/
UFUNCTION(BlueprintPure, Category = "EyeX")
static void Get3DGazePoint(EEyeXGazePointDataMode::Type Mode, FVector& GazePoint, bool& bHasValue);
/**
* Gets the last complete fixation.
* As soon as an ongoing fixation is complete it will be saved as the last fixation. While a new
* fixation is ongoing, the last fixation will not be changed.
* The unique BeginTimeStamp property can be used to compare if fixations are different from
* one another.
*
* @param Mode - Specifies the kind of data processing to be applied by the EyeX Engine.
* @param GazePoint - The gaze point in viewport coordinates (pixels).
* @param BeginTimeStamp - The time the fixation started in milliseconds.
* @param Duration - The total duration of this fixation in milliseconds.
* @param bHasValue - Indicates whether the data point is valid.
*/
UFUNCTION(BlueprintPure, Category = "EyeX")
static void GetLastFixation(EEyeXFixationDataMode::Type Mode, FVector2D& GazePoint, float& BeginTimeStamp, float& Duration, bool& bHasValue);
/**
* Gets the latest fixation data for the ongoing fixation.
* When a fixation is ongoing, the only changing properties are the gaze point and the duration.
* The gaze point converges towards the most likely point the eyes are lingering at, and the
* duration increases until the fixation reaches the fixation is complete. When the ongoing
* fixation is complete, it is set as the last fixation (retrievable with GetLastFixation), and
* the ongoing fixation is set to an invalid value until a new fixation has started.
*
* @param Mode - Specifies the kind of data processing to be applied by the EyeX Engine.
* @param GazePoint - The gaze point in viewport coordinates (pixels).
* @param BeginTimeStamp - The time the fixation started in milliseconds.
* @param Duration - The duration of this ongoing fixation since it began, in milliseconds.
* @param bHasValue - Indicates whether the data point is valid.
*/
UFUNCTION(BlueprintPure, Category = "EyeX")
static void GetOngoingFixation(EEyeXFixationDataMode::Type Mode, FVector2D& GazePoint, float& BeginTimeStamp, float& Duration, bool& bHasValue);
/**
* Gets the latest eye position data in 3D space.
* The origin of this coordinate system is in the center of the screen with the X-axis pointing
* into the screen (in the direction away from the user), the Y-axis to the right and the
* Z-axis pointing upwards.
* The data is in cm.
*
* @param LeftEye - The coordinate of the left eye in cm.
* @param RightEye - The coordinate of the right eye in cm.
* @param bIsLeftEyeValid - True if the left eye position contains valid data. Will be false if
* the tracker failed to detect the left eye.
* @param bIsRightEyeValid - True if the right eye position contains valid data. Will be false
* if the tracker failed to detect the right eye.
* @param TimeStamp - The time this data was created in milliseconds.
*/
UFUNCTION(BlueprintPure, Category = "EyeX")
static void GetEyePosition(FVector& LeftEye, FVector& RightEye, bool& bIsLeftEyeValid, bool& bIsRightEyeValid, float& TimeStamp);
/**
* Returns the rotation of the users head. Note that pitch cannot be calculated using the eye
* tracker and is always zero. Both eyes need to be tracked in order to calculate head rotation.
*
* @param Rotation - The rotation of the user's head.
* @param bHasValue - Indicates whether the data point is valid.
*/
UFUNCTION(BlueprintPure, Category = "EyeX")
static void GetHeadRotation(FRotator& Rotation, bool& bHasValue);
/**
* Returns the bounds of the screen where the eye tracker is mounted, in physical pixels.
*
* @param X - The X coordinate of the screen in physical pixels. The primary screen will have X = 0 and Y = 0.
* @param Y - The Y coordinate of the screen in physical pixels.
* @param Width - The width of the screen in physical pixels.
* @param Height - The height of the screen in physical pixels.
* @param bHasValue - Indicates whether the value is known.
*/
UFUNCTION(BlueprintPure, Category = "EyeX")
static void GetScreenBounds(int32& X, int32&Y, int32& Width, int32& Height, bool& bHasValue);
/**
* Returns the physical size of the display where the eye tracker is mounted, in millimeters.
*
* @param DisplaySize - The physical size of the display.
* @param bHasValue - Indicates whether the value is known.
*/
UFUNCTION(BlueprintPure, Category = "EyeX")
static void GetDisplaySize(FVector2D& DisplaySize, bool& bHasValue);
/**
* Returns the status of the eye tracking device.
*
* @param DeviceStatus - The device status.
*/
UFUNCTION(BlueprintPure, Category = "EyeX")
static void GetEyeTrackingDeviceStatus(TEnumAsByte<EEyeXDeviceStatus::Type>& DeviceStatus);
/**
* Returns the user presence (that is, whether the eye tracker can detect the user's eyes).
*
* @param UserPresence - The user presence status.
*/
UFUNCTION(BlueprintPure, Category = "EyeX")
static void GetUserPresence(TEnumAsByte<EEyeXUserPresence::Type>& UserPresence);
/**
* Gets the current emulation mode. The default is no emulation.
*
* @return The emulation mode.
*/
UFUNCTION(BlueprintPure, Category = "EyeX")
static TEnumAsByte<EEyeXEmulationMode::Type> GetEmulationMode();
/**
* Sets the emulation mode for the eye-gaze point. The default is no emulation.
*
* @param Mode - The emulation mode.
*/
UFUNCTION(BlueprintCallable, Category = "EyeX")
static void SetEmulationMode(TEnumAsByte<EEyeXEmulationMode::Type> Mode);
private:
static bool IsEyeXModuleAvailable();
private:
static IEyeXPlugin* EyeX;
};
| 44.197674 | 148 | 0.716917 |
500d69354725fa3444503050a61f450b5d35282c | 297 | h | C | Library/Socket/MUSocket.h | magic-unique/Tools | e779b4f7f4857d382053aa44408cd6b226d678d3 | [
"MIT"
] | 2 | 2015-11-03T10:35:13.000Z | 2015-11-05T08:54:45.000Z | Library/Socket/MUSocket.h | magic-unique/Tools | e779b4f7f4857d382053aa44408cd6b226d678d3 | [
"MIT"
] | null | null | null | Library/Socket/MUSocket.h | magic-unique/Tools | e779b4f7f4857d382053aa44408cd6b226d678d3 | [
"MIT"
] | null | null | null | //
// MUSocket.h
// Socket
//
// Created by 吴双 on 16/4/14.
// Copyright © 2016年 unique. All rights reserved.
//
#ifndef MUSocket_h
#define MUSocket_h
#import "MUSyncTCPServer.h"
#import "MUSyncUDPSocket.h"
#import "MUAsyncTCPServer.h"
#import "MUAsyncUDPSocket.h"
#endif /* MUSocket_h */
| 14.85 | 50 | 0.69697 |
1f8d10a46cf330c4291421fa160ee21087ba7b26 | 2,755 | h | C | format_string.h | clambassador/logserver | 79d20612418c6707da6b797db55be4804b76fe89 | [
"Apache-2.0"
] | null | null | null | format_string.h | clambassador/logserver | 79d20612418c6707da6b797db55be4804b76fe89 | [
"Apache-2.0"
] | null | null | null | format_string.h | clambassador/logserver | 79d20612418c6707da6b797db55be4804b76fe89 | [
"Apache-2.0"
] | null | null | null | #ifndef __FORMAT_STRING__H__
#define __FORMAT_STRING__H__
#include <algorithm>
#include <string>
using namespace std;
class FormatString : public string {
public:
FormatString() : string("") {}
virtual ~FormatString() {}
virtual void init(const string& val) {
assign(val);
for (size_t i = 0; i < length(); ++i) {
_fmt.push_back(0);
}
}
virtual void highlight() {
for (size_t i = 0; i < length(); ++i) {
_fmt[i] += 100;
}
if (length()) _fmt[0] = 10;
}
virtual void colour_function() {
for (size_t i = 1; i < length(); ++i) {
if (at(i) == ':') {
size_t j;
for (j = i + 1; j < length(); ++j) {
if (at(j) == ':') goto cont;
}
for (j = i; j < length(); --j) {
if (white_at(j)) break;
}
if (j >= length()) j = 0;
if (j + 1 < i) mark(COLON_COLOUR, j, i + 1 - j);
}
cont:;
}
for (size_t i = 1; i < length(); ++i) {
if (at(i) == ')' && at(i - 1) == '(') {
size_t j;
for (j = i - 2; j < length(); --j) {
if (white_at(j)) break;
}
if (j >= length()) j = 0;
mark(FUNCTION_COLOUR, j, i + 1 - j);
}
}
}
virtual void set_start(size_t pos) {
assert(_fmt.size() == length());
if (length() < pos) {
_fmt.clear();
assign("");
return;
}
for (size_t i = pos; i < _fmt.size(); ++i) {
_fmt[i - pos] = _fmt[i];
}
_fmt.resize(_fmt.size() - pos);
assign(substr(pos));
assert(_fmt.size() == length());
}
virtual void mark(int code, const string& keyword) {
string lowerkeyword, lowerline, line;
line.assign(static_cast<string>(*this));
lowerkeyword.resize(keyword.length());
lowerline.resize(length());
transform(keyword.begin(), keyword.end(),
lowerkeyword.begin(), ::tolower);
transform(line.begin(), line.end(),
lowerline.begin(), ::tolower);
mark(code, lowerkeyword, line);
mark(code, lowerkeyword, lowerline);
}
virtual void mark(int code, const string& keyword,
const string& line) {
size_t start_pos = 0;
while (npos !=
(start_pos = line.find(keyword, start_pos))) {
mark(code, start_pos, keyword.length());
++start_pos;
}
}
virtual int code(size_t pos) const {
return _fmt[pos];
}
virtual void add(const string& suffix, int code) {
append(suffix);
for (size_t i = 0; i < suffix.length(); ++i) {
_fmt.push_back(code);
}
}
protected:
virtual bool white_at(size_t i) const {
assert(i < length());
if (at(i) == ' ' || at(i) == '\t' || at(i) == '\n') return true;
return false;
}
virtual void mark(int code, size_t pos, size_t len) {
for (size_t i = pos; i < pos + len; ++i) {
if (_fmt[i] == 0)
_fmt[i] = code;
}
}
const int COLON_COLOUR = 5;
const int FUNCTION_COLOUR = 6;
vector<int> _fmt;
};
#endif // __FORMAT_STRING__H__
| 21.692913 | 66 | 0.56951 |
dd26e1dd36d2bbb276844277b6c4d6e134eca244 | 1,483 | c | C | OpenMP/Q8/prod-cons.c | sandeepnmenon/Parallel-Programming-Assignments | 7ec625bc8f7f252a03e3be5eb250870fd4424cd5 | [
"MIT"
] | null | null | null | OpenMP/Q8/prod-cons.c | sandeepnmenon/Parallel-Programming-Assignments | 7ec625bc8f7f252a03e3be5eb250870fd4424cd5 | [
"MIT"
] | null | null | null | OpenMP/Q8/prod-cons.c | sandeepnmenon/Parallel-Programming-Assignments | 7ec625bc8f7f252a03e3be5eb250870fd4424cd5 | [
"MIT"
] | 2 | 2018-09-28T04:58:05.000Z | 2018-10-14T14:47:35.000Z | #include <omp.h>
#include <stdio.h>
#define SIZE 100000
int flag = 0;
void fill_rand(int N,double A[])
{
for(int i=0;i<N;++i)
A[i] = 1;
printf("Producer populated data\n");
#pragma omp flush
flag = 1;
#pragma omp flush(flag)
}
double Sum_array(int N,double A[])
{
double sum = 0.0;
int p_flag;
while(1)
{
p_flag = 0;
#pragma omp flush(flag)
p_flag = flag;
if(p_flag)
break;
}
#pragma omp flush
for(int i=0;i<N;++i)
sum = sum + A[i];
printf("Consumer calculated Array sum\n" );
return sum;
}
double seq_prod_cons()
{
double A[SIZE];
fill_rand(SIZE,A);
double sum = Sum_array(SIZE,A);
return sum;
}
double parallel_prod_cons()
{
double A[SIZE];
double sum = 0.0;
omp_set_num_threads(2);
#pragma omp parallel sections
{
#pragma omp section
fill_rand(SIZE,A);
#pragma omp section
sum = Sum_array(SIZE,A);
}
return sum;
}
int main()
{
double time_taken_seq,time_taken_parallel,sum=0.0;
//Sequential Producer-Consumer
time_taken_seq = omp_get_wtime();
sum = seq_prod_cons();
time_taken_seq = omp_get_wtime() - time_taken_seq;
printf("In %lf seconds, Sequential code gives sum : %lf \n",time_taken_seq,sum);
//Parallel Producer-Consumer
time_taken_parallel = omp_get_wtime();
sum = parallel_prod_cons();
time_taken_parallel = omp_get_wtime() - time_taken_parallel;
printf("In %lf seconds, Parallel code gives sum : %lf \n",time_taken_parallel,sum);
printf("Speed up : %lf\n", time_taken_parallel/time_taken_seq);
} | 18.772152 | 84 | 0.690492 |
dd475e99115a77d0b1c998eb0adccc11521121bd | 2,689 | h | C | src/tcam-network/utils.h | xiaotiansf/tiscamera | 8451449788f7429621240e2bbce065d65c5ac10e | [
"Apache-2.0"
] | null | null | null | src/tcam-network/utils.h | xiaotiansf/tiscamera | 8451449788f7429621240e2bbce065d65c5ac10e | [
"Apache-2.0"
] | null | null | null | src/tcam-network/utils.h | xiaotiansf/tiscamera | 8451449788f7429621240e2bbce065d65c5ac10e | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2013 The Imaging Source Europe GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _UTILS_H_
#define _UTILS_H_
#include <string>
#include <vector>
#include <ifaddrs.h>
#include <linux/if.h>
#include <netdb.h>
// ip address, network byte order
typedef uint32_t ip4_address_t;
namespace tis
{
bool isRPFilterActive ();
/// @name startsWith
/// @param searchThrough - string that shall be examined
/// @param searchFor - string that shall be searched
/// @return true if strings starts with search
bool startsWith (const std::string& searchThrough, const std::string& searchFor);
/// @name int2ip
/// @param addr - ip4_address_t containing the IP
/// @return string containing IP
std::string int2ip (const ip4_address_t addr);
/// @name int2mac
/// @param mac - uint64 containing the mac address to be converted
/// @return string containing the mac address
std::string int2mac (const uint64_t mac);
/// @name readHexByte
/// @param beg - char sequence that shall be converted
/// @param end - end of sequence that shall not be exceeded
/// @return int containing the value of first chars
/// @brief reads the first chars of sequence and returns their integer value
unsigned int readHexByte (const char** beg, const char* end);
/// @name mac2int
/// @param mac - string containing the MAC that shall be converted
/// @return uint64_t containing the converted mac
uint64_t mac2int (const std::string& mac);
/// @name ip2int
/// @param ip - string containing the ip to be converted
/// @return ip as int or -1 on failure
ip4_address_t ip2int (const std::string& ip);
/// @name fillAddr
/// @param address - ip address from recipient
/// @param port - port to use
/// @return sockaddr_in
sockaddr_in fillAddr (const std::string &address, const unsigned short port);
/// @name isValidIpAddress
/// @param ipAddress - string containing IP that shall be checked
/// @return true if valid IP
bool isValidIpAddress (const std::string& ipAddress);
/// @name isValidIpMAC
/// @param mac - string containing mac that shall be checked
/// @return true if valid mac
bool isValidMAC (const std::string& mac);
} /* namespace tis */
#endif /* _UTILS_H_ */
| 30.908046 | 81 | 0.732242 |
97849be4f76485233acca48154b45c1af9523db6 | 21,850 | c | C | openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/systemd/1_242+AUTOINC+db2e367bfc-r0/git/src/nspawn/nspawn-network.c | sotaoverride/backup | ca53a10b72295387ef4948a9289cb78ab70bc449 | [
"Apache-2.0"
] | null | null | null | openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/systemd/1_242+AUTOINC+db2e367bfc-r0/git/src/nspawn/nspawn-network.c | sotaoverride/backup | ca53a10b72295387ef4948a9289cb78ab70bc449 | [
"Apache-2.0"
] | null | null | null | openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/systemd/1_242+AUTOINC+db2e367bfc-r0/git/src/nspawn/nspawn-network.c | sotaoverride/backup | ca53a10b72295387ef4948a9289cb78ab70bc449 | [
"Apache-2.0"
] | null | null | null | /* SPDX-License-Identifier: LGPL-2.1+ */
#include "nspawn-network.h"
#include <linux/veth.h>
#include <net/if.h>
#include <sys/file.h>
#include "alloc-util.h"
#include "ether-addr-util.h"
#include "lockfile-util.h"
#include "missing_network.h"
#include "netlink-util.h"
#include "sd-device.h"
#include "sd-id128.h"
#include "sd-netlink.h"
#include "siphash24.h"
#include "socket-util.h"
#include "stat-util.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
#define HOST_HASH_KEY \
SD_ID128_MAKE(1a, 37, 6f, c7, 46, ec, 45, 0b, ad, a3, d5, 31, 06, 60, 5d, \
b1)
#define CONTAINER_HASH_KEY \
SD_ID128_MAKE(c3, c4, f9, 19, b5, 57, b2, 1c, e6, cf, 14, 27, 03, 9c, ee, \
a2)
#define VETH_EXTRA_HOST_HASH_KEY \
SD_ID128_MAKE(48, c7, f6, b7, ea, 9d, 4c, 9e, b7, 28, d4, de, 91, d5, bf, \
66)
#define VETH_EXTRA_CONTAINER_HASH_KEY \
SD_ID128_MAKE(af, 50, 17, 61, ce, f9, 4d, 35, 84, 0d, 2b, 20, 54, be, ce, \
59)
#define MACVLAN_HASH_KEY \
SD_ID128_MAKE(00, 13, 6d, bc, 66, 83, 44, 81, bb, 0c, f9, 51, 1f, 24, a6, \
6f)
static int remove_one_link(sd_netlink* rtnl, const char* name)
{
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message* m = NULL;
int r;
if (isempty(name))
return 0;
r = sd_rtnl_message_new_link(rtnl, &m, RTM_DELLINK, 0);
if (r < 0)
return log_error_errno(r, "Failed to allocate netlink message: %m");
r = sd_netlink_message_append_string(m, IFLA_IFNAME, name);
if (r < 0)
return log_error_errno(r, "Failed to add netlink interface name: %m");
r = sd_netlink_call(rtnl, m, 0, NULL);
if (r == -ENODEV) /* Already gone */
return 0;
if (r < 0)
return log_error_errno(r, "Failed to remove interface %s: %m", name);
return 1;
}
static int generate_mac(const char* machine_name, struct ether_addr* mac,
sd_id128_t hash_key, uint64_t idx)
{
uint64_t result;
size_t l, sz;
uint8_t *v, *i;
int r;
l = strlen(machine_name);
sz = sizeof(sd_id128_t) + l;
if (idx > 0)
sz += sizeof(idx);
v = newa(uint8_t, sz);
/* fetch some persistent data unique to the host */
r = sd_id128_get_machine((sd_id128_t*)v);
if (r < 0)
return r;
/* combine with some data unique (on this host) to this
* container instance */
i = mempcpy(v + sizeof(sd_id128_t), machine_name, l);
if (idx > 0)
{
idx = htole64(idx);
memcpy(i, &idx, sizeof(idx));
}
/* Let's hash the host machine ID plus the container name. We
* use a fixed, but originally randomly created hash key here. */
result = htole64(siphash24(v, sz, hash_key.bytes));
assert_cc(ETH_ALEN <= sizeof(result));
memcpy(mac->ether_addr_octet, &result, ETH_ALEN);
/* see eth_random_addr in the kernel */
mac->ether_addr_octet[0] &= 0xfe; /* clear multicast bit */
mac->ether_addr_octet[0] |= 0x02; /* set local assignment bit (IEEE802) */
return 0;
}
static int add_veth(sd_netlink* rtnl, pid_t pid, const char* ifname_host,
const struct ether_addr* mac_host,
const char* ifname_container,
const struct ether_addr* mac_container)
{
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message* m = NULL;
int r;
assert(rtnl);
assert(ifname_host);
assert(mac_host);
assert(ifname_container);
assert(mac_container);
r = sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, 0);
if (r < 0)
return log_error_errno(r, "Failed to allocate netlink message: %m");
r = sd_netlink_message_append_string(m, IFLA_IFNAME, ifname_host);
if (r < 0)
return log_error_errno(r, "Failed to add netlink interface name: %m");
r = sd_netlink_message_append_ether_addr(m, IFLA_ADDRESS, mac_host);
if (r < 0)
return log_error_errno(r, "Failed to add netlink MAC address: %m");
r = sd_netlink_message_open_container(m, IFLA_LINKINFO);
if (r < 0)
return log_error_errno(r, "Failed to open netlink container: %m");
r = sd_netlink_message_open_container_union(m, IFLA_INFO_DATA, "veth");
if (r < 0)
return log_error_errno(r, "Failed to open netlink container: %m");
r = sd_netlink_message_open_container(m, VETH_INFO_PEER);
if (r < 0)
return log_error_errno(r, "Failed to open netlink container: %m");
r = sd_netlink_message_append_string(m, IFLA_IFNAME, ifname_container);
if (r < 0)
return log_error_errno(r, "Failed to add netlink interface name: %m");
r = sd_netlink_message_append_ether_addr(m, IFLA_ADDRESS, mac_container);
if (r < 0)
return log_error_errno(r, "Failed to add netlink MAC address: %m");
r = sd_netlink_message_append_u32(m, IFLA_NET_NS_PID, pid);
if (r < 0)
return log_error_errno(r, "Failed to add netlink namespace field: %m");
r = sd_netlink_message_close_container(m);
if (r < 0)
return log_error_errno(r, "Failed to close netlink container: %m");
r = sd_netlink_message_close_container(m);
if (r < 0)
return log_error_errno(r, "Failed to close netlink container: %m");
r = sd_netlink_message_close_container(m);
if (r < 0)
return log_error_errno(r, "Failed to close netlink container: %m");
r = sd_netlink_call(rtnl, m, 0, NULL);
if (r < 0)
return log_error_errno(r,
"Failed to add new veth interfaces (%s:%s): %m",
ifname_host, ifname_container);
return 0;
}
int setup_veth(const char* machine_name, pid_t pid, char iface_name[IFNAMSIZ],
bool bridge)
{
_cleanup_(sd_netlink_unrefp) sd_netlink* rtnl = NULL;
struct ether_addr mac_host, mac_container;
int r, i;
assert(machine_name);
assert(pid > 0);
assert(iface_name);
/* Use two different interface name prefixes depending whether
* we are in bridge mode or not. */
snprintf(iface_name, IFNAMSIZ - 1, "%s-%s", bridge ? "vb" : "ve",
machine_name);
r = generate_mac(machine_name, &mac_container, CONTAINER_HASH_KEY, 0);
if (r < 0)
return log_error_errno(r, "Failed to generate predictable MAC address "
"for container side: %m");
r = generate_mac(machine_name, &mac_host, HOST_HASH_KEY, 0);
if (r < 0)
return log_error_errno(
r, "Failed to generate predictable MAC address for host side: %m");
r = sd_netlink_open(&rtnl);
if (r < 0)
return log_error_errno(r, "Failed to connect to netlink: %m");
r = add_veth(rtnl, pid, iface_name, &mac_host, "host0", &mac_container);
if (r < 0)
return r;
i = (int)if_nametoindex(iface_name);
if (i <= 0)
return log_error_errno(errno, "Failed to resolve interface %s: %m",
iface_name);
return i;
}
int setup_veth_extra(const char* machine_name, pid_t pid, char** pairs)
{
_cleanup_(sd_netlink_unrefp) sd_netlink* rtnl = NULL;
uint64_t idx = 0;
char **a, **b;
int r;
assert(machine_name);
assert(pid > 0);
if (strv_isempty(pairs))
return 0;
r = sd_netlink_open(&rtnl);
if (r < 0)
return log_error_errno(r, "Failed to connect to netlink: %m");
STRV_FOREACH_PAIR(a, b, pairs)
{
struct ether_addr mac_host, mac_container;
r = generate_mac(machine_name, &mac_container,
VETH_EXTRA_CONTAINER_HASH_KEY, idx);
if (r < 0)
return log_error_errno(r,
"Failed to generate predictable MAC address "
"for container side of extra veth link: %m");
r = generate_mac(machine_name, &mac_host, VETH_EXTRA_HOST_HASH_KEY,
idx);
if (r < 0)
return log_error_errno(r,
"Failed to generate predictable MAC address "
"for container side of extra veth link: %m");
r = add_veth(rtnl, pid, *a, &mac_host, *b, &mac_container);
if (r < 0)
return r;
idx++;
}
return 0;
}
static int join_bridge(sd_netlink* rtnl, const char* veth_name,
const char* bridge_name)
{
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message* m = NULL;
int r, bridge_ifi;
assert(rtnl);
assert(veth_name);
assert(bridge_name);
bridge_ifi = (int)if_nametoindex(bridge_name);
if (bridge_ifi <= 0)
return -errno;
r = sd_rtnl_message_new_link(rtnl, &m, RTM_SETLINK, 0);
if (r < 0)
return r;
r = sd_rtnl_message_link_set_flags(m, IFF_UP, IFF_UP);
if (r < 0)
return r;
r = sd_netlink_message_append_string(m, IFLA_IFNAME, veth_name);
if (r < 0)
return r;
r = sd_netlink_message_append_u32(m, IFLA_MASTER, bridge_ifi);
if (r < 0)
return r;
r = sd_netlink_call(rtnl, m, 0, NULL);
if (r < 0)
return r;
return bridge_ifi;
}
static int create_bridge(sd_netlink* rtnl, const char* bridge_name)
{
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message* m = NULL;
int r;
r = sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, 0);
if (r < 0)
return r;
r = sd_netlink_message_append_string(m, IFLA_IFNAME, bridge_name);
if (r < 0)
return r;
r = sd_netlink_message_open_container(m, IFLA_LINKINFO);
if (r < 0)
return r;
r = sd_netlink_message_open_container_union(m, IFLA_INFO_DATA, "bridge");
if (r < 0)
return r;
r = sd_netlink_message_close_container(m);
if (r < 0)
return r;
r = sd_netlink_message_close_container(m);
if (r < 0)
return r;
r = sd_netlink_call(rtnl, m, 0, NULL);
if (r < 0)
return r;
return 0;
}
int setup_bridge(const char* veth_name, const char* bridge_name, bool create)
{
_cleanup_(release_lock_file) LockFile bridge_lock = LOCK_FILE_INIT;
_cleanup_(sd_netlink_unrefp) sd_netlink* rtnl = NULL;
int r, bridge_ifi;
unsigned n = 0;
assert(veth_name);
assert(bridge_name);
r = sd_netlink_open(&rtnl);
if (r < 0)
return log_error_errno(r, "Failed to connect to netlink: %m");
if (create)
{
/* We take a system-wide lock here, so that we can safely check whether
* there's still a member in the bridge before removing it, without
* risking interference from other nspawn instances. */
r = make_lock_file("/run/systemd/nspawn-network-zone", LOCK_EX,
&bridge_lock);
if (r < 0)
return log_error_errno(r, "Failed to take network zone lock: %m");
}
for (;;)
{
bridge_ifi = join_bridge(rtnl, veth_name, bridge_name);
if (bridge_ifi >= 0)
return bridge_ifi;
if (bridge_ifi != -ENODEV || !create || n > 10)
return log_error_errno(
bridge_ifi, "Failed to add interface %s to bridge %s: %m",
veth_name, bridge_name);
/* Count attempts, so that we don't enter an endless loop here. */
n++;
/* The bridge doesn't exist yet. Let's create it */
r = create_bridge(rtnl, bridge_name);
if (r < 0)
return log_error_errno(
r, "Failed to create bridge interface %s: %m", bridge_name);
/* Try again, now that the bridge exists */
}
}
int remove_bridge(const char* bridge_name)
{
_cleanup_(release_lock_file) LockFile bridge_lock = LOCK_FILE_INIT;
_cleanup_(sd_netlink_unrefp) sd_netlink* rtnl = NULL;
const char* path;
int r;
/* Removes the specified bridge, but only if it is currently empty */
if (isempty(bridge_name))
return 0;
r = make_lock_file("/run/systemd/nspawn-network-zone", LOCK_EX,
&bridge_lock);
if (r < 0)
return log_error_errno(r, "Failed to take network zone lock: %m");
path = strjoina("/sys/class/net/", bridge_name, "/brif");
r = dir_is_empty(path);
if (r == -ENOENT) /* Already gone? */
return 0;
if (r < 0)
return log_error_errno(r, "Can't detect if bridge %s is empty: %m",
bridge_name);
if (r == 0) /* Still populated, leave it around */
return 0;
r = sd_netlink_open(&rtnl);
if (r < 0)
return log_error_errno(r, "Failed to connect to netlink: %m");
return remove_one_link(rtnl, bridge_name);
}
static int parse_interface(const char* name)
{
_cleanup_(sd_device_unrefp) sd_device* d = NULL;
char ifi_str[2 + DECIMAL_STR_MAX(int)];
int ifi, r;
ifi = (int)if_nametoindex(name);
if (ifi <= 0)
return log_error_errno(errno, "Failed to resolve interface %s: %m",
name);
sprintf(ifi_str, "n%i", ifi);
r = sd_device_new_from_device_id(&d, ifi_str);
if (r < 0)
return log_error_errno(r, "Failed to get device for interface %s: %m",
name);
r = sd_device_get_is_initialized(d);
if (r < 0)
return log_error_errno(r,
"Failed to determine whether interface %s is "
"initialized or not: %m",
name);
if (r == 0)
{
log_error("Network interface %s is not initialized yet.", name);
return -EBUSY;
}
return ifi;
}
int move_network_interfaces(pid_t pid, char** ifaces)
{
_cleanup_(sd_netlink_unrefp) sd_netlink* rtnl = NULL;
char** i;
int r;
if (strv_isempty(ifaces))
return 0;
r = sd_netlink_open(&rtnl);
if (r < 0)
return log_error_errno(r, "Failed to connect to netlink: %m");
STRV_FOREACH(i, ifaces)
{
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message* m = NULL;
int ifi;
ifi = parse_interface(*i);
if (ifi < 0)
return ifi;
r = sd_rtnl_message_new_link(rtnl, &m, RTM_SETLINK, ifi);
if (r < 0)
return log_error_errno(r, "Failed to allocate netlink message: %m");
r = sd_netlink_message_append_u32(m, IFLA_NET_NS_PID, pid);
if (r < 0)
return log_error_errno(
r, "Failed to append namespace PID to netlink message: %m");
r = sd_netlink_call(rtnl, m, 0, NULL);
if (r < 0)
return log_error_errno(
r, "Failed to move interface %s to namespace: %m", *i);
}
return 0;
}
int setup_macvlan(const char* machine_name, pid_t pid, char** ifaces)
{
_cleanup_(sd_netlink_unrefp) sd_netlink* rtnl = NULL;
unsigned idx = 0;
char** i;
int r;
if (strv_isempty(ifaces))
return 0;
r = sd_netlink_open(&rtnl);
if (r < 0)
return log_error_errno(r, "Failed to connect to netlink: %m");
STRV_FOREACH(i, ifaces)
{
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message* m = NULL;
_cleanup_free_ char* n = NULL;
struct ether_addr mac;
int ifi;
ifi = parse_interface(*i);
if (ifi < 0)
return ifi;
r = generate_mac(machine_name, &mac, MACVLAN_HASH_KEY, idx++);
if (r < 0)
return log_error_errno(r,
"Failed to create MACVLAN MAC address: %m");
r = sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, 0);
if (r < 0)
return log_error_errno(r, "Failed to allocate netlink message: %m");
r = sd_netlink_message_append_u32(m, IFLA_LINK, ifi);
if (r < 0)
return log_error_errno(r,
"Failed to add netlink interface index: %m");
n = strappend("mv-", *i);
if (!n)
return log_oom();
strshorten(n, IFNAMSIZ - 1);
r = sd_netlink_message_append_string(m, IFLA_IFNAME, n);
if (r < 0)
return log_error_errno(r,
"Failed to add netlink interface name: %m");
r = sd_netlink_message_append_ether_addr(m, IFLA_ADDRESS, &mac);
if (r < 0)
return log_error_errno(r, "Failed to add netlink MAC address: %m");
r = sd_netlink_message_append_u32(m, IFLA_NET_NS_PID, pid);
if (r < 0)
return log_error_errno(r,
"Failed to add netlink namespace field: %m");
r = sd_netlink_message_open_container(m, IFLA_LINKINFO);
if (r < 0)
return log_error_errno(r, "Failed to open netlink container: %m");
r = sd_netlink_message_open_container_union(m, IFLA_INFO_DATA,
"macvlan");
if (r < 0)
return log_error_errno(r, "Failed to open netlink container: %m");
r = sd_netlink_message_append_u32(m, IFLA_MACVLAN_MODE,
MACVLAN_MODE_BRIDGE);
if (r < 0)
return log_error_errno(r, "Failed to append macvlan mode: %m");
r = sd_netlink_message_close_container(m);
if (r < 0)
return log_error_errno(r, "Failed to close netlink container: %m");
r = sd_netlink_message_close_container(m);
if (r < 0)
return log_error_errno(r, "Failed to close netlink container: %m");
r = sd_netlink_call(rtnl, m, 0, NULL);
if (r < 0)
return log_error_errno(r,
"Failed to add new macvlan interfaces: %m");
}
return 0;
}
int setup_ipvlan(const char* machine_name, pid_t pid, char** ifaces)
{
_cleanup_(sd_netlink_unrefp) sd_netlink* rtnl = NULL;
char** i;
int r;
if (strv_isempty(ifaces))
return 0;
r = sd_netlink_open(&rtnl);
if (r < 0)
return log_error_errno(r, "Failed to connect to netlink: %m");
STRV_FOREACH(i, ifaces)
{
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message* m = NULL;
_cleanup_free_ char* n = NULL;
int ifi;
ifi = parse_interface(*i);
if (ifi < 0)
return ifi;
r = sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, 0);
if (r < 0)
return log_error_errno(r, "Failed to allocate netlink message: %m");
r = sd_netlink_message_append_u32(m, IFLA_LINK, ifi);
if (r < 0)
return log_error_errno(r,
"Failed to add netlink interface index: %m");
n = strappend("iv-", *i);
if (!n)
return log_oom();
strshorten(n, IFNAMSIZ - 1);
r = sd_netlink_message_append_string(m, IFLA_IFNAME, n);
if (r < 0)
return log_error_errno(r,
"Failed to add netlink interface name: %m");
r = sd_netlink_message_append_u32(m, IFLA_NET_NS_PID, pid);
if (r < 0)
return log_error_errno(r,
"Failed to add netlink namespace field: %m");
r = sd_netlink_message_open_container(m, IFLA_LINKINFO);
if (r < 0)
return log_error_errno(r, "Failed to open netlink container: %m");
r = sd_netlink_message_open_container_union(m, IFLA_INFO_DATA,
"ipvlan");
if (r < 0)
return log_error_errno(r, "Failed to open netlink container: %m");
r = sd_netlink_message_append_u16(m, IFLA_IPVLAN_MODE, IPVLAN_MODE_L2);
if (r < 0)
return log_error_errno(r, "Failed to add ipvlan mode: %m");
r = sd_netlink_message_close_container(m);
if (r < 0)
return log_error_errno(r, "Failed to close netlink container: %m");
r = sd_netlink_message_close_container(m);
if (r < 0)
return log_error_errno(r, "Failed to close netlink container: %m");
r = sd_netlink_call(rtnl, m, 0, NULL);
if (r < 0)
return log_error_errno(r,
"Failed to add new ipvlan interfaces: %m");
}
return 0;
}
int veth_extra_parse(char*** l, const char* p)
{
_cleanup_free_ char *a = NULL, *b = NULL;
int r;
r = extract_first_word(&p, &a, ":", EXTRACT_DONT_COALESCE_SEPARATORS);
if (r < 0)
return r;
if (r == 0 || !ifname_valid(a))
return -EINVAL;
r = extract_first_word(&p, &b, ":", EXTRACT_DONT_COALESCE_SEPARATORS);
if (r < 0)
return r;
if (r == 0 || !ifname_valid(b))
{
free(b);
b = strdup(a);
if (!b)
return -ENOMEM;
}
if (p)
return -EINVAL;
r = strv_push_pair(l, a, b);
if (r < 0)
return -ENOMEM;
a = b = NULL;
return 0;
}
int remove_veth_links(const char* primary, char** pairs)
{
_cleanup_(sd_netlink_unrefp) sd_netlink* rtnl = NULL;
char **a, **b;
int r;
/* In some cases the kernel might pin the veth links between host and
* container even after the namespace
* died. Hence, let's better remove them explicitly too. */
if (isempty(primary) && strv_isempty(pairs))
return 0;
r = sd_netlink_open(&rtnl);
if (r < 0)
return log_error_errno(r, "Failed to connect to netlink: %m");
remove_one_link(rtnl, primary);
STRV_FOREACH_PAIR(a, b, pairs)
remove_one_link(rtnl, *a);
return 0;
}
| 30.179558 | 80 | 0.579039 |
5af77b737558185ca4112bd9b98279a4cf23f50a | 206 | h | C | Pod/Classes/UIImage/UIImage+TWGSizing.h | twg/TWGExtensions | 246a2178ae7d3ad7658f827d7709bb1247494566 | [
"MIT"
] | 1 | 2016-03-11T15:13:00.000Z | 2016-03-11T15:13:00.000Z | Pod/Classes/UIImage/UIImage+TWGSizing.h | twg/TWGExtensions | 246a2178ae7d3ad7658f827d7709bb1247494566 | [
"MIT"
] | 14 | 2016-03-11T18:54:29.000Z | 2017-03-23T16:18:17.000Z | Pod/Classes/UIImage/UIImage+TWGSizing.h | twg/TWGExtensions | 246a2178ae7d3ad7658f827d7709bb1247494566 | [
"MIT"
] | null | null | null |
@import UIKit;
@interface UIImage (TWGSizing)
- (UIImage *)twg_resizedImageToSize:(CGSize)destinationSize;
- (UIImage *)twg_resizedImageToFitInSize:(CGSize)boundingSize scaleIfSmaller:(BOOL)scale;
@end
| 20.6 | 89 | 0.796117 |
8764da3df6a6ea7d76d32de2de77ade9a4e77fd1 | 3,861 | h | C | examples/hello-world/rain-drops.h | dkdk-ryu/dali-sample | 0df14489613469ec3c57d9e5634df5138275e759 | [
"Apache-2.0"
] | null | null | null | examples/hello-world/rain-drops.h | dkdk-ryu/dali-sample | 0df14489613469ec3c57d9e5634df5138275e759 | [
"Apache-2.0"
] | null | null | null | examples/hello-world/rain-drops.h | dkdk-ryu/dali-sample | 0df14489613469ec3c57d9e5634df5138275e759 | [
"Apache-2.0"
] | null | null | null | #include <cairo.h>
#include <chrono>
#include <vector>
using namespace std;
struct RainOptions
{
int minR;
int maxR;
int maxDrops;
float rainChance;
int rainLimit;
int dropletsRate;
int dropletsSize[3];
float dropletsCleaningRadiusMultiplier;
bool raining;
int globalTimeScale;
int trailRate;
bool autoShrink;
float spawnArea[2];
float trailScaleRange[2];
float collisionRadius;
float collisionRadiusIncrease;
int dropFallMultiplier;
float collisionBoostMultiplier;
int collisionBoost;
RainOptions()
{
minR = 10;
maxR = 40;
maxDrops = 900;
rainChance = 0.3;
rainLimit = 3;
dropletsRate = 50;
dropletsSize[0] = 2;
dropletsSize[1] = 3;
dropletsSize[2] = 4;
dropletsCleaningRadiusMultiplier = 0.43;
raining = true;
globalTimeScale = 1;
trailRate = 1;
autoShrink = true;
spawnArea[0] = -0.1;
spawnArea[1] = 0.95;
trailScaleRange[0] = 0.2;
trailScaleRange[1] = 0.5;
collisionRadius = 0.65;
collisionRadiusIncrease = 0.01;
dropFallMultiplier = 1;
collisionBoostMultiplier = 0.05;
collisionBoost = 1;
}
};
struct Drop
{
double x;
double y;
double r;
int spreadX;
int spreadY;
int momentum;
int momentumX;
int lastSpawn;
int nextSpawn;
struct Drop* parent;
bool isNew;
bool killed;
int shrink;
Drop()
{
x = 0;
y = 0;
r = 0;
spreadX = 0;
spreadY = 0;
momentum = 0;
momentumX = 0;
lastSpawn = 0;
nextSpawn = 0;
parent = nullptr;
isNew = true;
killed = false;
shrink = 0;
}
};
class RainDrops
{
public:
RainDrops(int width, int height, float scale, RainOptions options);
void update();
unsigned char* getCanvas();
private:
void setupWeatherData();
void init();
int deltaR();
double area();
double areaMultiplier();
double random(double from, double to, unsigned char interpolationType);
bool chance(double c);
void updateDroplets(double timeScale);
void updateDrops(double timeScale);
void renderDropsGfx();
void clearCanvas();
double getRandom();
void drawDrop(cairo_t* ctx, Drop* drop);
void clearDroplets(double x, double y, double r = 30);
void drawDroplet(int x, int y, double r);
vector<Drop*> updateRain(double timeScale);
private:
int mWidth;
int mHeight;
float mScale;
RainOptions mOptions;
//TODO: init value
int mDropletsPixelDensity;
int mDropletsCounter;
double mTextureCleaningIterations;
uint64_t mLastRenderTime;
unsigned char* mCanvas;
cairo_surface_t* mSurface;
cairo_t* mCtx;
//forPNG
uint32_t mPngIndex;
unsigned char* mDropletsCanvas;
cairo_surface_t* mDropletsSurface;
cairo_t* mDropletsCtx;
unsigned char* mClearDropletsGfx; //canvas - //clearcanvas 한번만 그리고 더이상 업데이트할일이 없어서 ctx는 따로 저장하지 않음.
cairo_surface_t* mClearDropletsSurface;
cairo_t* mClearDropletsCtx;
vector<Drop*> mDrops;
vector<unsigned char*> mDropsGfx;
vector<cairo_surface_t*> mDropsSurfaces;
cairo_surface_t* mDropAlpha;
cairo_surface_t* mDropColor;
}; | 26.265306 | 103 | 0.542865 |
10007e8e71e168faf6e815bf8754c23fedad8173 | 326 | h | C | Connect/IMUI/JSQDemo/DemoMessagesViewController+XMPPDemo.h | younthu/Connect | 6b65e5e14a022f54f3e063c0a40a5cee792cf1a7 | [
"MIT"
] | null | null | null | Connect/IMUI/JSQDemo/DemoMessagesViewController+XMPPDemo.h | younthu/Connect | 6b65e5e14a022f54f3e063c0a40a5cee792cf1a7 | [
"MIT"
] | null | null | null | Connect/IMUI/JSQDemo/DemoMessagesViewController+XMPPDemo.h | younthu/Connect | 6b65e5e14a022f54f3e063c0a40a5cee792cf1a7 | [
"MIT"
] | null | null | null | //
// DemoMessagesViewController+XMPPDemo.h
// Connect
//
// Created by Zhiyong Yang on 4/14/15.
// Copyright (c) 2015 Andrew Yang. All rights reserved.
//
#import "DemoMessagesViewController.h"
@interface DemoMessagesViewController (XMPPDemo)
- (IMUser*)loginUser:(NSString*)userName password:(NSString*)password;
@end
| 23.285714 | 70 | 0.748466 |
8cdffcd5722c6b20bd7f04c15c058b5cc9ea44f8 | 1,818 | h | C | src/qtweetsearchresult.h | minimoog/QTweetLib | e8c62faccd38c694dcfc7a5d3e55982cf7daaffc | [
"Apache-2.0"
] | 43 | 2015-02-27T07:55:10.000Z | 2022-02-20T13:37:48.000Z | src/qtweetsearchresult.h | minimoog/QTweetLib | e8c62faccd38c694dcfc7a5d3e55982cf7daaffc | [
"Apache-2.0"
] | 3 | 2015-11-25T18:05:37.000Z | 2019-07-24T19:58:32.000Z | src/qtweetsearchresult.h | minimoog/QTweetLib | e8c62faccd38c694dcfc7a5d3e55982cf7daaffc | [
"Apache-2.0"
] | 14 | 2015-01-29T18:50:58.000Z | 2019-12-31T07:35:39.000Z | /* Copyright 2010 Antonie Jovanoski
*
* 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.
*
* Contact e-mail: Antonie Jovanoski <minimoog77_at_gmail.com>
*/
#ifndef QTWEETSEARCHRESULT_H
#define QTWEETSEARCHRESULT_H
#include <QVariant>
#include <QSharedDataPointer>
#include "qtweetlib_global.h"
class QTweetSearchResultData;
/**
* Stores search result
*/
class QTWEETLIBSHARED_EXPORT QTweetSearchResult
{
public:
QTweetSearchResult();
QTweetSearchResult(const QTweetSearchResult &);
QTweetSearchResult &operator=(const QTweetSearchResult &);
~QTweetSearchResult();
void setCreatedAt(const QString& twitterDate);
void setCreatedAt(const QDateTime& dateTime);
QDateTime createdAt() const;
void setFromUser(const QString& screenName);
QString fromUser() const;
void setId(qint64 id);
qint64 id() const;
void setLang(const QString& lang);
QString lang() const;
void setProfileImageUrl(const QString& url);
QString profileImageUrl() const;
void setSource(const QString& source);
QString source() const;
void setText(const QString& text);
QString text() const;
void setToUser(const QString& screenName);
QString toUser() const;
private:
QSharedDataPointer<QTweetSearchResultData> data;
};
#endif // QTWEETSEARCHRESULT_H
| 29.803279 | 75 | 0.741474 |
4916d1a25eae529407188eb32072fc2e4c5e68fb | 77 | h | C | esp01-continuous-firestore/src/calcFlightTime/calcFligthTime.h | CabraKill/HiHome-micro | 3b0a66bba5e20c4ff9d3001274890309b3d519ed | [
"MIT"
] | null | null | null | esp01-continuous-firestore/src/calcFlightTime/calcFligthTime.h | CabraKill/HiHome-micro | 3b0a66bba5e20c4ff9d3001274890309b3d519ed | [
"MIT"
] | null | null | null | esp01-continuous-firestore/src/calcFlightTime/calcFligthTime.h | CabraKill/HiHome-micro | 3b0a66bba5e20c4ff9d3001274890309b3d519ed | [
"MIT"
] | null | null | null | #include <Arduino.h>
unsigned long getFlightTime(unsigned long inicialTime); | 25.666667 | 55 | 0.818182 |
3cb21a2ba29f1289963add8e8f130b92333c72a4 | 1,267 | c | C | lib/linux-5.18-rc3-smdk/sound/soc/codecs/cs42l51-i2c.c | OpenMPDK/SMDK | 8f19d32d999731242cb1ab116a4cb445d9993b15 | [
"BSD-3-Clause"
] | 44 | 2022-03-16T08:32:31.000Z | 2022-03-31T16:02:35.000Z | releases/hanggai/src/linux-5.18/sound/soc/codecs/cs42l51-i2c.c | marmolak/gray486linux | 6403fc9d12cf6e8c6f42213ae287bc1e19b83e60 | [
"BSD-2-Clause"
] | 1 | 2022-03-29T02:30:28.000Z | 2022-03-30T03:40:46.000Z | releases/hanggai/src/linux-5.18/sound/soc/codecs/cs42l51-i2c.c | marmolak/gray486linux | 6403fc9d12cf6e8c6f42213ae287bc1e19b83e60 | [
"BSD-2-Clause"
] | 18 | 2022-03-19T04:41:04.000Z | 2022-03-31T03:32:12.000Z | // SPDX-License-Identifier: GPL-2.0-only
/*
* cs42l56.c -- CS42L51 ALSA SoC I2C audio driver
*
* Copyright 2014 CirrusLogic, Inc.
*
* Author: Brian Austin <brian.austin@cirrus.com>
*/
#include <linux/i2c.h>
#include <linux/module.h>
#include <sound/soc.h>
#include "cs42l51.h"
static struct i2c_device_id cs42l51_i2c_id[] = {
{"cs42l51", 0},
{}
};
MODULE_DEVICE_TABLE(i2c, cs42l51_i2c_id);
static int cs42l51_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct regmap_config config;
config = cs42l51_regmap;
return cs42l51_probe(&i2c->dev, devm_regmap_init_i2c(i2c, &config));
}
static int cs42l51_i2c_remove(struct i2c_client *i2c)
{
cs42l51_remove(&i2c->dev);
return 0;
}
static const struct dev_pm_ops cs42l51_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(cs42l51_suspend, cs42l51_resume)
};
static struct i2c_driver cs42l51_i2c_driver = {
.driver = {
.name = "cs42l51",
.of_match_table = cs42l51_of_match,
.pm = &cs42l51_pm_ops,
},
.probe = cs42l51_i2c_probe,
.remove = cs42l51_i2c_remove,
.id_table = cs42l51_i2c_id,
};
module_i2c_driver(cs42l51_i2c_driver);
MODULE_DESCRIPTION("ASoC CS42L51 I2C Driver");
MODULE_AUTHOR("Brian Austin, Cirrus Logic Inc, <brian.austin@cirrus.com>");
MODULE_LICENSE("GPL");
| 21.474576 | 75 | 0.737174 |
34604e181c3f16b3ae9954febb9730a3410019fa | 1,895 | c | C | d/islands/common/aramanth/room2.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-07-19T05:24:44.000Z | 2021-11-18T04:08:19.000Z | d/islands/common/aramanth/room2.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 4 | 2021-03-15T18:56:39.000Z | 2021-08-17T17:08:22.000Z | d/islands/common/aramanth/room2.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-09-12T06:22:38.000Z | 2022-01-31T01:15:12.000Z | #include <std.h>
inherit ROOM;
void create(){
::create();
set_property("light",3);
set_property("indoors",0);
set_terrain(BEACH);
set_travel(FRESH_BLAZE);
set_short("%^RED%^The rugged terrain of %^WHITE%^A%^BOLD%^%^RED%^r%^BLACK%^a%^WHITE%^m%^RED%^a%^RESET%^n%^RED%^t%^BOLD%^h %^RESET%^%^RED%^I%^BOLD%^s%^WHITE%^l%^BLACK%^a%^RESET%^n%^BOLD%^%^BLACK%^d%^RESET%^.");
set_long("%^RED%^The rugged terrain of %^WHITE%^A%^BOLD%^%^RED%^r%^BLACK%^a%^WHITE%^m%^RED%^a%^RESET%^n%^RED%^t%^BOLD%^h %^RESET%^%^RED%^I%^BOLD%^s%^WHITE%^l%^BLACK%^a%^RESET%^n%^BOLD%^%^BLACK%^d%^RESET%^.
%^ORANGE%^This part of the beach seems to be a transitionary one. The coarse %^RED%^rocky gravel%^ORANGE%^ gives way to soft, fine sand the further west you go. The jagged skyline of the island's many peaks is clearly visible from this point. %^BLUE%^The ocean meets the land on either side, here at the beach.
");
set_listen("default", "Waves gently break against the beach.");
set_exits(([
"west" : "/d/islands/common/aramanth/room1",
"east" : "/d/islands/common/aramanth/room3",
]));
set_items(([
"formations" : "Jagged formations of natural rock tower all around you.",
"rocks" : "The rocks here are very jagged.",
"skyline" : "The island looks almost like a thousand shards of granite were slammed into the ground in one massive strike by a giant.",
"formation" : "It looks almost perfectly like a sobbing boy if you look at it from just the right angle.",
"shale" : "Tiny sharp rock fragments and dust cover the ground.",
"ground" : "Tiny sharp rock fragments and dust cover the ground."
]));
}
void init() {
::init();
do_random_encounters(({"/d/islands/common/mon/bwyvern.c", "/d/islands/common/mon/skeleton.c", "/d/islands/common/mon/uwarrior.c", "/d/islands/common/mon/spiritdancer.c", "/d/islands/common/mon/crab.c"}),30,3);
}
| 54.142857 | 311 | 0.660686 |
427f87d75cf5e89d0ce2192e0f7a375a991ff6fc | 926 | h | C | src/Twitter.h | JChristensen/Twitter | 16f3b64a875e71fe59f2c69c7d20c136477d4d3d | [
"MIT"
] | null | null | null | src/Twitter.h | JChristensen/Twitter | 16f3b64a875e71fe59f2c69c7d20c136477d4d3d | [
"MIT"
] | null | null | null | src/Twitter.h | JChristensen/Twitter | 16f3b64a875e71fe59f2c69c7d20c136477d4d3d | [
"MIT"
] | 1 | 2020-04-18T19:30:24.000Z | 2020-04-18T19:30:24.000Z | /*
Twitter.cpp - Arduino library to Post messages to Twitter using OAuth.
Copyright (c) NeoCat 2010-2011. All right reserved.
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.
*/
// ver1.2.0 - Use <Udp.h> to support IDE 0019 or later
// ver1.3.0 - Support IDE 1.0
// ver1.3.1 - Add "Host:" header.
#ifndef TWITTER_H_INCLUDED
#define TWITTER_H_INCLUDED
#include <SPI.h>
#include <Ethernet.h>
class Twitter
{
private:
uint8_t parseStatus;
int statusCode;
const char *token;
EthernetClient client;
public:
Twitter(const char *token) : token(token) {}
bool post(const char *msg);
bool checkStatus(Print *debug = NULL);
int wait(Print *debug = NULL);
int status(void) { return statusCode; }
};
#endif
| 25.027027 | 72 | 0.667387 |
1fc675377b3c330875a57945497f89bf14f59bec | 355 | h | C | Unreal/Plugins/AirSim/Source/AirSimRoutePlanner/Utils/JSONUtils.h | TamedTornado/AirSim | 6e5b23060ace55ffcfbc3fb21f9abaf692e71b9b | [
"MIT"
] | null | null | null | Unreal/Plugins/AirSim/Source/AirSimRoutePlanner/Utils/JSONUtils.h | TamedTornado/AirSim | 6e5b23060ace55ffcfbc3fb21f9abaf692e71b9b | [
"MIT"
] | null | null | null | Unreal/Plugins/AirSim/Source/AirSimRoutePlanner/Utils/JSONUtils.h | TamedTornado/AirSim | 6e5b23060ace55ffcfbc3fb21f9abaf692e71b9b | [
"MIT"
] | null | null | null | #pragma once
class FJsonObject;
class JSONUtils
{
public:
static TSharedPtr<FJsonObject> GetJSONForVector(FVector InVector);
static FVector GetVectorFromJSON(TSharedPtr<FJsonObject> InJSONObj);
static TSharedPtr<FJsonObject> GetJSONForRotator(FRotator InRot);
static FRotator GetRotatorFromJSON(TSharedPtr<FJsonObject> InJSONObj);
};
| 22.1875 | 76 | 0.797183 |
99f6f4c8b137fba830d1b5a4ad6d8e0237bb8553 | 1,032 | c | C | llvm/tools/clang/test/Driver/whole-program-vtables.c | vusec/typesan | 831ca2af1a629e8ea93bb8c5b4215f12247b595c | [
"Apache-2.0"
] | 30 | 2016-09-06T06:58:43.000Z | 2021-12-23T11:59:38.000Z | llvm/tools/clang/test/Driver/whole-program-vtables.c | vusec/typesan | 831ca2af1a629e8ea93bb8c5b4215f12247b595c | [
"Apache-2.0"
] | 1 | 2018-05-15T00:55:37.000Z | 2018-05-15T00:55:37.000Z | llvm/tools/clang/test/Driver/whole-program-vtables.c | vusec/typesan | 831ca2af1a629e8ea93bb8c5b4215f12247b595c | [
"Apache-2.0"
] | 17 | 2016-10-24T06:08:16.000Z | 2022-02-18T17:27:14.000Z | // RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables -### %s 2>&1 | FileCheck --check-prefix=NO-LTO %s
// NO-LTO: invalid argument '-fwhole-program-vtables' only allowed with '-flto'
// RUN: %clang -target x86_64-unknown-linux -resource-dir=%S/Inputs/resource_dir -flto -fwhole-program-vtables -### -c %s 2>&1 | FileCheck --check-prefix=BLACKLIST %s
// BLACKLIST: "-fwhole-program-vtables-blacklist={{.*}}vtables_blacklist.txt"
// RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables-blacklist=nonexistent.txt -flto -fwhole-program-vtables -### -c %s 2>&1 | FileCheck --check-prefix=NON-EXISTENT-BLACKLIST %s
// NON-EXISTENT-BLACKLIST: no such file or directory: 'nonexistent.txt'
// RUN: %clang -target x86_64-unknown-linux -fwhole-program-vtables-blacklist=%S/Inputs/resource_dir/vtables_blacklist.txt -flto -fwhole-program-vtables -### -c %s 2>&1 | FileCheck --check-prefix=CUSTOM-BLACKLIST %s
// CUSTOM-BLACKLIST: "-fwhole-program-vtables-blacklist={{.*}}Inputs/resource_dir/vtables_blacklist.txt"
| 86 | 215 | 0.739341 |
ab5fe94089ae5b6f60c6bf5d95eb126b2e820325 | 961 | h | C | mmhy/MColor.h | was0107/Mmhy | 9ad2c0201d18932ac3d48b0230a5b75a2645e5d5 | [
"MIT"
] | 2 | 2016-05-16T09:01:33.000Z | 2016-06-14T04:33:43.000Z | mmhy/MColor.h | was0107/Mmhy | 9ad2c0201d18932ac3d48b0230a5b75a2645e5d5 | [
"MIT"
] | null | null | null | mmhy/MColor.h | was0107/Mmhy | 9ad2c0201d18932ac3d48b0230a5b75a2645e5d5 | [
"MIT"
] | null | null | null | //
// MColor.h
// mmhy
//
// Created by Micker on 2018/7/17.
// Copyright © 2018年 micker. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSUInteger, MGradientType) {
MGradientTypeH,
MGradientTypeV,
MGradientTypeC,
MGradientTypeClear,
MGradientTypeCount,
};
@interface MColor : NSObject
@property(nullable, copy) NSArray *colors;
@property(nullable, copy) NSArray<NSNumber *> *locations;
@property MGradientType gradientType;
@property BOOL isGradientColor;
@property(copy) NSString *name;
+ (instancetype) newColors:(NSString *) colors locations:(NSString *)locations type:(int)type name:(NSString *)name;
- (id) setColorString:(NSString *)stringColor;
- (id) setLocationString:(NSString *)stringLocation;
- (void) setMin:(CGPoint) min max:(CGPoint)max center:(CGPoint)center;
- (UInt32) colorAtX:(NSInteger)x y:(NSInteger)y;
- (UInt32) getColorAtIndex:(NSInteger) index;
@end
| 24.641026 | 116 | 0.73257 |
05e27d41e54edd1b3421bc73646b4f11e5aa7568 | 6,291 | h | C | TelinkSigMeshLib/SigLogger.h | thanhtunguet/react-native-telink-ble | 87f714fb4b2447cc7683e89a11c48818c30a1b14 | [
"MIT"
] | null | null | null | TelinkSigMeshLib/SigLogger.h | thanhtunguet/react-native-telink-ble | 87f714fb4b2447cc7683e89a11c48818c30a1b14 | [
"MIT"
] | null | null | null | TelinkSigMeshLib/SigLogger.h | thanhtunguet/react-native-telink-ble | 87f714fb4b2447cc7683e89a11c48818c30a1b14 | [
"MIT"
] | 1 | 2021-06-29T06:56:34.000Z | 2021-06-29T06:56:34.000Z | /********************************************************************************************************
* @file SigLogger.h
*
* @brief for TLSR chips
*
* @author telink
* @date Sep. 30, 2010
*
* @par Copyright (c) 2010, Telink Semiconductor (Shanghai) Co., Ltd.
* All rights reserved.
*
* The information contained herein is confidential and proprietary property of Telink
* Semiconductor (Shanghai) Co., Ltd. and is available under the terms
* of Commercial License Agreement between Telink Semiconductor (Shanghai)
* Co., Ltd. and the licensee in separate contract or the terms described here-in.
* This heading MUST NOT be removed from this file.
*
* Licensees are granted free, non-transferable use of the information in this
* file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided.
*
*******************************************************************************************************/
//
// SigLogger.h
// TelinkSigMeshLib
//
// Created by 梁家誌 on 2019/8/16.
// Copyright © 2019年 Telink. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/*
log 写法1:测试验证线程
*/
//# define TeLog(fmt, ...) TelinkLogWithFile((@"[%@][%s Line %d] " fmt), [NSThread currentThread], __func__, __LINE__, ##__VA_ARGS__);
//
//#define TeLogError(fmt, ...) if (SigLogger.share.logLevel & SigLogFlagError) {\
//TelinkLogWithFile((@"[Error][%@][%s Line %d] " fmt), [NSThread currentThread], __func__, __LINE__, ##__VA_ARGS__);\
//}
//
//#define TeLogWarn(fmt, ...) if (SigLogger.share.logLevel & SigLogFlagWarning) {\
//TelinkLogWithFile((@"[Warn][%@][%s Line %d] " fmt), [NSThread currentThread], __func__, __LINE__, ##__VA_ARGS__);\
//}
//
//#define TeLogInfo(fmt, ...) if (SigLogger.share.logLevel & SigLogFlagInfo) {\
//TelinkLogWithFile((@"[Info][%@][%s Line %d] " fmt), [NSThread currentThread], __func__, __LINE__, ##__VA_ARGS__);\
//}
//
//#define TeLogDebug(fmt, ...) if (SigLogger.share.logLevel & SigLogFlagDebug) {\
//TelinkLogWithFile((@"[Debug][%@][%s Line %d] " fmt), [NSThread currentThread], __func__, __LINE__, ##__VA_ARGS__);\
//}
//
//#define TeLogVerbose(fmt, ...) if (SigLogger.share.logLevel & SigLogFlagVerbose) {\
//TelinkLogWithFile((@"[Verbose][%@][%s Line %d] " fmt), [NSThread currentThread], __func__, __LINE__, ##__VA_ARGS__);\
//}
/*
log 写法2:
*/
# define TeLog(fmt, ...) TelinkLogWithFile(YES,(@"[%s Line %d] " fmt), __func__, __LINE__, ##__VA_ARGS__);
#define TeLogError(fmt, ...) if (SigLogger.share.logLevel & SigLogFlagError) {\
TelinkLogWithFile(SigLogger.share.logLevel & SigLogFlagError,(@"[Error][%s Line %d] " fmt), __func__, __LINE__, ##__VA_ARGS__);\
} else if (SigLogger.share.logLevel) {\
TelinkLogWithFile(NO,(@"[Error][%s Line %d] " fmt), __func__, __LINE__, ##__VA_ARGS__);\
}
#define TeLogWarn(fmt, ...) if (SigLogger.share.logLevel & SigLogFlagWarning) {\
TelinkLogWithFile(YES,(@"[Warn][%s Line %d] " fmt), __func__, __LINE__, ##__VA_ARGS__);\
} else if (SigLogger.share.logLevel) {\
TelinkLogWithFile(NO,(@"[Warn][%s Line %d] " fmt), __func__, __LINE__, ##__VA_ARGS__);\
}
#define TeLogInfo(fmt, ...) if (SigLogger.share.logLevel & SigLogFlagInfo) {\
TelinkLogWithFile(YES,(@"[Info][%s Line %d] " fmt), __func__, __LINE__, ##__VA_ARGS__);\
} else if (SigLogger.share.logLevel) {\
TelinkLogWithFile(NO,(@"[Info][%s Line %d] " fmt), __func__, __LINE__, ##__VA_ARGS__);\
}
#define TeLogDebug(fmt, ...) if (SigLogger.share.logLevel & SigLogFlagDebug) {\
TelinkLogWithFile(YES,(@"[Debug][%s Line %d] " fmt), __func__, __LINE__, ##__VA_ARGS__);\
} else if (SigLogger.share.logLevel) {\
TelinkLogWithFile(NO,(@"[Debug][%s Line %d] " fmt), __func__, __LINE__, ##__VA_ARGS__);\
}
#define TeLogVerbose(fmt, ...) if (SigLogger.share.logLevel & SigLogFlagVerbose) {\
TelinkLogWithFile(YES,(@"[Verbose][%s Line %d] " fmt), __func__, __LINE__, ##__VA_ARGS__);\
} else if (SigLogger.share.logLevel) {\
TelinkLogWithFile(NO,(@"[Verbose][%s Line %d] " fmt), __func__, __LINE__, ##__VA_ARGS__);\
}
typedef enum : NSUInteger {
/**
* 0...00001 SigLogFlagError
*/
SigLogFlagError = (1 << 0),
/**
* 0...00010 SigLogFlagWarning
*/
SigLogFlagWarning = (1 << 1),
/**
* 0...00100 SigLogFlagInfo
*/
SigLogFlagInfo = (1 << 2),
/**
* 0...01000 SigLogFlagDebug
*/
SigLogFlagDebug = (1 << 3),
/**
* 0...10000 SigLogFlagVerbose
*/
SigLogFlagVerbose = (1 << 4),
} SigLogFlag;
typedef enum : NSUInteger {
/**
* No logs
*/
SigLogLevelOff = 0,
/**
* Error logs only
*/
SigLogLevelError = (SigLogFlagError),
/**
* Error and warning logs
*/
SigLogLevelWarning = (SigLogLevelError | SigLogFlagWarning),
/**
* Error, warning and info logs
*/
SigLogLevelInfo = (SigLogLevelWarning | SigLogFlagInfo),
/**
* Error, warning, info and debug logs
*/
SigLogLevelDebug = (SigLogLevelInfo | SigLogFlagDebug),
/**
* Error, warning, info, debug and verbose logs
*/
SigLogLevelVerbose = (SigLogLevelDebug | SigLogFlagVerbose),
/**
* All logs (1...11111)
*/
SigLogLevelAll = NSUIntegerMax,
} SigLogLevel;
@interface SigLogger : NSObject
@property (assign,nonatomic,readonly) SigLogLevel logLevel;
+ (instancetype)new __attribute__((unavailable("please initialize by use .share or .share()")));
- (instancetype)init __attribute__((unavailable("please initialize by use .share or .share()")));
+ (SigLogger *)share;
/// 设置log等级,debug模式设置为SigLogLevelDebug即可,上架推荐使用SigLogLevelOff。
- (void)setSDKLogLevel:(SigLogLevel)logLevel;
/// 清除所有log
- (void)clearAllLog;
/// 获取特定长度的log字符串
- (NSString *)getLogStringWithLength:(NSInteger)length;
/// 缓存加密的json数据于iTunes中
void saveMeshJsonData(id data);
/// 解密iTunes中缓存的加密的json数据
- (NSString *)getDecryptTelinkSDKMeshJsonData;
- (NSString *)getDecryptTelinkSDKMeshJsonDataWithPassword:(NSString *)password;
/**
自定义打印,会自动写文件
*/
void TelinkLogWithFile(BOOL show,NSString *format, ...);
@end
NS_ASSUME_NONNULL_END
| 34.005405 | 134 | 0.627563 |
8219773737e33b7468e48ab8c8ff770c85a205bc | 4,628 | h | C | lib/include/instro/rose/utility/ASTHelper.h | jplehr/InstRO | 62a27e2c0cd24abc615e102c53bad08225aa8c0d | [
"BSD-3-Clause"
] | 3 | 2016-03-30T06:37:59.000Z | 2021-08-06T01:39:10.000Z | lib/include/instro/rose/utility/ASTHelper.h | jplehr/InstRO | 62a27e2c0cd24abc615e102c53bad08225aa8c0d | [
"BSD-3-Clause"
] | 13 | 2016-04-13T16:11:12.000Z | 2018-04-16T11:06:45.000Z | lib/include/instro/rose/utility/ASTHelper.h | jplehr/InstRO | 62a27e2c0cd24abc615e102c53bad08225aa8c0d | [
"BSD-3-Clause"
] | 1 | 2019-01-28T17:57:09.000Z | 2019-01-28T17:57:09.000Z | #ifndef INSTRO_ROSE_UTILITY_ASTHELPER_H
#define INSTRO_ROSE_UTILITY_ASTHELPER_H
#include "rose.h"
#include <string>
namespace InstRO {
namespace Rose {
namespace Utility {
/**
* \brief methods to simplify handling of AST nodes
* \author Roman
* \author JP Lehr
*/
namespace ASTHelper {
/* Return the defining declaration for a given declaration */
SgFunctionDeclaration* getDefiningDeclaration(SgFunctionDeclaration* oldDecl);
/* Return the first non-defining declaration for a given declaration */
SgFunctionDeclaration* getFirstNondefDeclaration(SgFunctionDeclaration* oldDecl);
/* Return the defining declaration for a given definition */
SgFunctionDeclaration* getDefiningDeclaration(SgFunctionDefinition* oldDef);
/* Return the first non-defining declaration for a given definition */
SgFunctionDeclaration* getFirstNondefDeclaration(SgFunctionDefinition* oldDef);
/* Return the definition for a given function call expression */
SgFunctionDefinition* getFunctionDefinition(SgFunctionCallExp* callExp);
/* Return the loop nesting level of a statement */
int getLoopNestingLevel(SgLocatedNode* n);
std::string nondefUnparseToString(SgFunctionDeclaration* funcDecl);
std::string nondefUnparseToString(SgFunctionDefinition* funcDef);
std::string getFunctionSignature(SgFunctionDefinition* funcDef);
/* private helper functions for loop-nesting level */
SgScopeStatement* getEnclosingLoop(SgLocatedNode* n);
bool isLoop(SgScopeStatement* scope);
bool isContainedInTemplateInstantiation(SgNode* node);
/** returns true if a void-returning function does not end with a return statement */
bool voidFunctionEndsWithoutReturn(SgFunctionDefinition *fDef);
bool isConstructor(SgFunctionDefinition* fDef);
bool isConstructor(SgFunctionDeclaration* fDecl);
bool isDestructor(SgFunctionDefinition* fDef);
bool isDestructor(SgFunctionDeclaration* fDecl);
/* Handles SgTemplateFunctionInstantiationDecl and SgTemplateMemberFunctionInstantiationDecl to dispatch the Consumer
* accordingly */
template <typename CallableFileInfoConsumer>
typename std::result_of<CallableFileInfoConsumer(Sg_File_Info*)>::type applyConsumerToTemplateInstantiationDecl(
CallableFileInfoConsumer cr, SgNode* node) {
SgTemplateInstantiationFunctionDecl* funcDecl =
SageInterface::getEnclosingNode<SgTemplateInstantiationFunctionDecl>(node, true);
SgTemplateInstantiationMemberFunctionDecl* memDecl =
SageInterface::getEnclosingNode<SgTemplateInstantiationMemberFunctionDecl>(node, true);
typename std::result_of<CallableFileInfoConsumer(Sg_File_Info*)>::type retVal;
if (funcDecl != nullptr) {
// FIXME It seems ROSE is unable to resolve the template in this situation
auto templDecl = funcDecl->get_templateDeclaration();
templDecl = isSgTemplateFunctionDeclaration(templDecl->get_definingDeclaration());
retVal = cr(templDecl->get_startOfConstruct());
}
if (memDecl != nullptr) {
auto templDecl = isSgTemplateMemberFunctionDeclaration(memDecl->get_templateDeclaration());
if (memDecl->isCompilerGenerated()) {
/* Since ROSE handles templates _very_ inconsistently we use the check on the file id to guide
* which Sg_File_Info object we want to use.
* -2 indicates a "compiler generated" filename
* -4 indicates a "NULL FILE" filename
*/
if ((templDecl->get_startOfConstruct()->get_file_id() == -2) ||
(templDecl->get_startOfConstruct()->get_file_id() == -4)) {
templDecl = isSgTemplateMemberFunctionDeclaration(templDecl->get_definingDeclaration());
}
}
retVal = cr(templDecl->get_startOfConstruct());
}
return retVal;
}
template <typename CallableFileInfoConsumer>
typename std::result_of<CallableFileInfoConsumer(SgInitializedName*)>::type applyConsumerToAssignInitializer(
CallableFileInfoConsumer cr, SgAssignInitializer* node) {
auto decl = isSgDeclarationStatement(node->get_parent()->get_parent());
auto initName = isSgInitializedName(node->get_parent());
if (decl != nullptr) {
// handle the case within an if statement
if (decl->isCompilerGenerated()) {
auto n = decl->get_parent();
auto ln = isSgLocatedNode(n);
if (ln == nullptr) {
throw std::string("The Assign initializer was in a weird position!");
}
return cr(initName);
}
// handle the "normal" assign initializer
return cr(initName);
}
throw std::string("The Assign initializer was in a weird position!");
}
/** Given a node it returns the file info if this node is either an if or a while. Returns nullptr otherwise */
Sg_File_Info* getFileInfoFromWhileOrIf(SgNode* n);
}
} // namespace Utility
} // namespace Rose
} // namespace InstRO
#endif // ASTHELPER_H
| 37.322581 | 117 | 0.785004 |
82779452d18beb5ee65545ecf73baeb1857d795a | 1,304 | h | C | arch/armv7-m/mach-stm32/boards/stm32f469i-disco/include/pinmap.h | onkwon/yaos | c9571f22b310002e16bb012215dfbfb84a1e264b | [
"Apache-2.0"
] | 40 | 2015-09-28T13:21:33.000Z | 2022-03-31T05:57:52.000Z | arch/armv7-m/mach-stm32/boards/stm32f469i-disco/include/pinmap.h | onkwon/yaos | c9571f22b310002e16bb012215dfbfb84a1e264b | [
"Apache-2.0"
] | 43 | 2015-08-04T06:27:55.000Z | 2019-10-06T05:58:24.000Z | arch/armv7-m/mach-stm32/boards/stm32f469i-disco/include/pinmap.h | onkwon/yaos | c9571f22b310002e16bb012215dfbfb84a1e264b | [
"Apache-2.0"
] | 18 | 2015-09-29T22:37:18.000Z | 2021-06-04T06:40:23.000Z | #ifndef __PINMAP_H__
#define __PINMAP_H__
/* 00: PA base 0
* 01: PB base 16
* 02: PC base 32
* 03: PD base 48
* 04: PE base 64
* 05: PF base 80
* 06: PG base 96
* 07: PH base 112
* 08: PI base 128
* 09: PJ base 144
* 10: PK base 160 */
#define PIN_STATUS_LED PIN_LED_BLUE
#define PIN_LED_GREEN 112//(96+6) /* PG.6 */
#define PIN_LED_ORANGE 52//(48+4) /* PD.4 */
#define PIN_LED_RED 53//(48+5) /* PD.5 */
#define PIN_LED_BLUE 163//(160+3) /* PK.3 */
/* UART */
#define PIN_UART6_TX (32+6) /* PC.6 */
#define PIN_UART6_RX (32+7) /* PC.7 */
#define PIN_LCD_RESET (112+7) /* PH.7 */
#define PIN_LCD_TEAR (144+2) /* PJ.2 */
#define PIN_LCD_BACKLIGHT (3) /* PA.3 */
/* Timer */
#define PIN_TIM2CH1 0 /* PA.0 */
#define PIN_TIM2CH2 1 /* PA.1 */
#define PIN_TIM2CH3 2 /* PA.2 */
#define PIN_TIM2CH4 3 /* PA.3 */
#define PIN_TIM3CH1 6 /* PA.6 */
#define PIN_TIM3CH2 7 /* PA.7 */
#define PIN_TIM3CH3 16 /* PB.0 */
#define PIN_TIM3CH4 17 /* PB.1 */
#define PIN_TIM4CH1 22 /* PB.6 */
#define PIN_TIM4CH2 23 /* PB.7 */
#define PIN_TIM4CH3 24 /* PB.8 */
#define PIN_TIM4CH4 25 /* PB.9 */
#define PIN_TIM5CH1 0 /* PA.0 */
#define PIN_TIM5CH2 PIN_TIM2CH2
#define PIN_TIM5CH3 PIN_TIM2CH3
#define PIN_TIM5CH4 PIN_TIM2CH4
#endif /* __PINMAP_H__ */
| 26.08 | 46 | 0.617331 |
fbeafdd9d6855cc7f96f631b432e7c621f019971 | 38 | h | C | CLHEP/Random/JamesRandom.h | brownd1978/FastSim | 05f590d72d8e7f71856fd833114a38b84fc7fd48 | [
"Apache-2.0"
] | null | null | null | CLHEP/Random/JamesRandom.h | brownd1978/FastSim | 05f590d72d8e7f71856fd833114a38b84fc7fd48 | [
"Apache-2.0"
] | null | null | null | CLHEP/Random/JamesRandom.h | brownd1978/FastSim | 05f590d72d8e7f71856fd833114a38b84fc7fd48 | [
"Apache-2.0"
] | null | null | null | #include "CLHEP/Random/JamesRandom.h"
| 19 | 37 | 0.789474 |
c20926989d3231a236ec96101d8e4503d830adfd | 5,033 | c | C | egltest.c | PojavLauncherTeam/virglrenderer | 7969c18b074916423b41d39636c1e35c038d6cd6 | [
"MIT"
] | 6 | 2021-11-10T08:54:29.000Z | 2022-03-18T06:43:59.000Z | egltest.c | Zethange/VirGL | 7969c18b074916423b41d39636c1e35c038d6cd6 | [
"MIT"
] | null | null | null | egltest.c | Zethange/VirGL | 7969c18b074916423b41d39636c1e35c038d6cd6 | [
"MIT"
] | 3 | 2022-02-01T13:20:23.000Z | 2022-03-11T14:08:13.000Z | // test based on https://github.com/matusnovak/rpi-opengl-without-x/blob/master/triangle.c
// clang egltest.c -lEGL build/vtest/libvirgl_test_server.so -o egltest
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static const EGLint configAttribs[] = {
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT, EGL_BLUE_SIZE, 8, EGL_GREEN_SIZE, 8,
EGL_RED_SIZE, 8, EGL_DEPTH_SIZE, 8,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, EGL_NONE};
// Width and height of the desired framebuffer
static const EGLint pbufferAttribs[] = {
EGL_WIDTH,
1280,
EGL_HEIGHT,
720,
EGL_NONE,
};
static const EGLint contextAttribs[] = {EGL_CONTEXT_CLIENT_VERSION, 3,
EGL_NONE};
static const char *eglGetErrorStr()
{
switch (eglGetError())
{
case EGL_SUCCESS:
return "The last function succeeded without error.";
case EGL_NOT_INITIALIZED:
return "EGL is not initialized, or could not be initialized, for the "
"specified EGL display connection.";
case EGL_BAD_ACCESS:
return "EGL cannot access a requested resource (for example a context "
"is bound in another thread).";
case EGL_BAD_ALLOC:
return "EGL failed to allocate resources for the requested operation.";
case EGL_BAD_ATTRIBUTE:
return "An unrecognized attribute or attribute value was passed in the "
"attribute list.";
case EGL_BAD_CONTEXT:
return "An EGLContext argument does not name a valid EGL rendering "
"context.";
case EGL_BAD_CONFIG:
return "An EGLConfig argument does not name a valid EGL frame buffer "
"configuration.";
case EGL_BAD_CURRENT_SURFACE:
return "The current surface of the calling thread is a window, pixel "
"buffer or pixmap that is no longer valid.";
case EGL_BAD_DISPLAY:
return "An EGLDisplay argument does not name a valid EGL display "
"connection.";
case EGL_BAD_SURFACE:
return "An EGLSurface argument does not name a valid surface (window, "
"pixel buffer or pixmap) configured for GL rendering.";
case EGL_BAD_MATCH:
return "Arguments are inconsistent (for example, a valid context "
"requires buffers not supplied by a valid surface).";
case EGL_BAD_PARAMETER:
return "One or more argument values are invalid.";
case EGL_BAD_NATIVE_PIXMAP:
return "A NativePixmapType argument does not refer to a valid native "
"pixmap.";
case EGL_BAD_NATIVE_WINDOW:
return "A NativeWindowType argument does not refer to a valid native "
"window.";
case EGL_CONTEXT_LOST:
return "A power management event has occurred. The application must "
"destroy all contexts and reinitialise OpenGL ES state and "
"objects to continue rendering.";
default:
break;
}
return "Unknown error!";
}
int vtest_main(int argc, char **argv);
int main(int argc, char **argv)
{
EGLDisplay display;
int major, minor;
int desiredWidth, desiredHeight;
GLuint program, vert, frag, vbo;
GLint posLoc, colorLoc, result;
if ((display = eglGetDisplay(EGL_DEFAULT_DISPLAY)) == EGL_NO_DISPLAY)
{
fprintf(stderr, "Failed to get EGL display! Error: %s\n",
eglGetErrorStr());
return EXIT_FAILURE;
}
if (eglInitialize(display, &major, &minor) == EGL_FALSE)
{
fprintf(stderr, "Failed to get EGL version! Error: %s\n",
eglGetErrorStr());
eglTerminate(display);
return EXIT_FAILURE;
}
printf("Initialized EGL version: %d.%d\n", major, minor);
EGLint numConfigs;
EGLConfig config;
if (!eglChooseConfig(display, configAttribs, &config, 1, &numConfigs))
{
fprintf(stderr, "Failed to get EGL config! Error: %s\n",
eglGetErrorStr());
eglTerminate(display);
return EXIT_FAILURE;
}
EGLSurface surface =
eglCreatePbufferSurface(display, config, pbufferAttribs);
if (surface == EGL_NO_SURFACE)
{
fprintf(stderr, "Failed to create EGL surface! Error: %s\n",
eglGetErrorStr());
eglTerminate(display);
return EXIT_FAILURE;
}
eglBindAPI(EGL_OPENGL_API);
EGLContext context =
eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs);
if (context == EGL_NO_CONTEXT)
{
fprintf(stderr, "Failed to create EGL context! Error: %s\n",
eglGetErrorStr());
eglDestroySurface(display, surface);
eglTerminate(display);
return EXIT_FAILURE;
}
eglMakeCurrent(display, surface, surface, context);
// init vtest
vtest_main(argc, argv);
// Cleanup
eglDestroyContext(display, context);
eglDestroySurface(display, surface);
eglTerminate(display);
return EXIT_SUCCESS;
}
| 33.553333 | 90 | 0.64693 |
61373db6dd8a3e2e0b48788ed620b2dd50a425b7 | 404 | c | C | rng/sfmt_86243.c | garymacindoe/cuda-cholesky | 3f0b7ea19f59db4c098df8db49f0e33915a467d4 | [
"MIT"
] | 5 | 2019-05-16T02:27:40.000Z | 2022-02-07T04:46:27.000Z | rng/sfmt_86243.c | garymacindoe/cuda-cholesky | 3f0b7ea19f59db4c098df8db49f0e33915a467d4 | [
"MIT"
] | null | null | null | rng/sfmt_86243.c | garymacindoe/cuda-cholesky | 3f0b7ea19f59db4c098df8db49f0e33915a467d4 | [
"MIT"
] | 2 | 2019-02-28T09:44:21.000Z | 2019-05-16T02:27:44.000Z | #define MEXP 86243
#define POS1 366
#define SL1 6
#define SL2 7
#define SR1 19
#define SR2 1
#define MSK1 0xfdbffbff
#define MSK2 0xbff7ff3f
#define MSK3 0xfd77efff
#define MSK4 0xbf9ff3ff
#define PARITY1 0x00000001
#define PARITY2 0x00000000
#define PARITY3 0x00000000
#define PARITY4 0xe9528d85
#define NAME "SIMD-oriented Fast Mersenne Twister 2^86243"
#define RNG_T sfmt_86243_t
#include "sfmt.c"
| 19.238095 | 58 | 0.799505 |
613fde09c45799acea5a2ccb3291fa5db63db0bf | 1,340 | h | C | pkg/s1ap/asn1/UEIdentityIndexValue.h | coreswitch/coreswitch | 69839bcdb18dbb0774da1458b4ffd20c16764e81 | [
"Apache-2.0"
] | 5 | 2019-09-06T06:45:28.000Z | 2021-01-26T17:15:11.000Z | pkg/s1ap/asn1/UEIdentityIndexValue.h | coreswitch/coreswitch | 69839bcdb18dbb0774da1458b4ffd20c16764e81 | [
"Apache-2.0"
] | 1 | 2021-07-21T04:59:52.000Z | 2021-07-21T04:59:52.000Z | pkg/s1ap/asn1/UEIdentityIndexValue.h | coreswitch/coreswitch | 69839bcdb18dbb0774da1458b4ffd20c16764e81 | [
"Apache-2.0"
] | 1 | 2020-04-27T08:48:53.000Z | 2020-04-27T08:48:53.000Z | /*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "S1AP-IEs"
* found in "r14.4.0/36413-e40.asn"
* `asn1c -pdu=all -fcompound-names -findirect-choice -fno-include-deps -no-gen-example`
*/
#ifndef _UEIdentityIndexValue_H_
#define _UEIdentityIndexValue_H_
#include <asn_application.h>
/* Including external dependencies */
#include <BIT_STRING.h>
#ifdef __cplusplus
extern "C" {
#endif
/* UEIdentityIndexValue */
typedef BIT_STRING_t UEIdentityIndexValue_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_UEIdentityIndexValue;
asn_struct_free_f UEIdentityIndexValue_free;
asn_struct_print_f UEIdentityIndexValue_print;
asn_constr_check_f UEIdentityIndexValue_constraint;
ber_type_decoder_f UEIdentityIndexValue_decode_ber;
der_type_encoder_f UEIdentityIndexValue_encode_der;
xer_type_decoder_f UEIdentityIndexValue_decode_xer;
xer_type_encoder_f UEIdentityIndexValue_encode_xer;
oer_type_decoder_f UEIdentityIndexValue_decode_oer;
oer_type_encoder_f UEIdentityIndexValue_encode_oer;
per_type_decoder_f UEIdentityIndexValue_decode_uper;
per_type_encoder_f UEIdentityIndexValue_encode_uper;
per_type_decoder_f UEIdentityIndexValue_decode_aper;
per_type_encoder_f UEIdentityIndexValue_encode_aper;
#ifdef __cplusplus
}
#endif
#endif /* _UEIdentityIndexValue_H_ */
#include <asn_internal.h>
| 29.130435 | 89 | 0.847761 |
b2836a3eff4a68fbb7d077f9c6fd7ee181d42afc | 3,188 | c | C | lib/trace/trace.c | lambdaxymox/barrelfish | 06a9f54721a8d96874a8939d8973178a562c342f | [
"MIT"
] | 111 | 2015-02-03T02:57:27.000Z | 2022-03-01T23:57:09.000Z | lib/trace/trace.c | lambdaxymox/barrelfish | 06a9f54721a8d96874a8939d8973178a562c342f | [
"MIT"
] | 12 | 2016-03-22T14:44:32.000Z | 2020-03-18T13:30:29.000Z | lib/trace/trace.c | lambdaxymox/barrelfish | 06a9f54721a8d96874a8939d8973178a562c342f | [
"MIT"
] | 55 | 2015-02-03T05:28:12.000Z | 2022-03-31T05:00:03.000Z | /**
* \file
* \brief System-wide tracing
*/
/*
* Copyright (c) 2007, 2008, 2009, 2010, ETH Zurich.
* All rights reserved.
*
* This file is distributed under the terms in the attached LICENSE file.
* If you do not find this file, copies can be found by writing to:
* ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group.
*/
#include <stdio.h>
#include <barrelfish/barrelfish.h>
#include <barrelfish/dispatch.h>
#include <barrelfish/dispatcher_arch.h>
#include <barrelfish/curdispatcher_arch.h>
#include <trace/trace.h>
#include <spawndomain/spawndomain.h>
STATIC_ASSERT_SIZEOF(struct trace_event, 16);
STATIC_ASSERT((sizeof(struct trace_buffer) <= TRACE_PERCORE_BUF_SIZE), "size mismatch");
/**
* \brief Initialize per-core tracing buffer
*
* This function creates a cap for the tracing buffer in taskcn.
* It is called from init at startup.
*
* Note that it does *not* map the buffer into its own vspace.
*/
errval_t trace_init(void)
{
errval_t err;
size_t bytes;
struct capref cap = {
.cnode = cnode_task,
.slot = TASKCN_SLOT_TRACEBUF
};
err = frame_create(cap, TRACE_ALLOC_SIZE, &bytes);
if (err_is_fail(err)) {
return err_push(err, TRACE_ERR_CREATE_CAP);
}
return SYS_ERR_OK;
}
/**
* \brief Turn off tracing for this domain
*/
errval_t trace_disable_domain(void)
{
dispatcher_handle_t handle = curdispatcher();
struct dispatcher_generic *disp = get_dispatcher_generic(handle);
disp->trace_buf = NULL;
return SYS_ERR_OK;
}
/**
* Sets up tracing framework for current dispatcher
*/
void trace_init_disp(void)
{
dispatcher_handle_t handle = curdispatcher();
struct dispatcher_generic *disp = get_dispatcher_generic(handle);
disp->trace_buf = (struct trace_buffer*)trace_buffer_va;
}
/**
* \brief Setup the tracing buffer for a child domain
*
* Assumes that the child domain is currently being spawned
* (because we rely on libspawndomain having the right state to
* allow us to map the trace buffer into the child's vspace).
*
* trace_init must already have been called
*/
errval_t trace_setup_child(struct cnoderef taskcn,
dispatcher_handle_t handle)
{
errval_t err;
// Pass tracing buffer cap to new domain
struct capref src = {
.cnode = cnode_task,
.slot = TASKCN_SLOT_TRACEBUF
};
struct capref dst = {
.cnode = taskcn,
.slot = TASKCN_SLOT_TRACEBUF
};
err = cap_copy(dst, src);
if (err_is_fail(err)) {
return err_push(err, TRACE_ERR_CAP_COPY);
}
return SYS_ERR_OK;
}
/**
* \brief Set up the trace buffer on the current core and notify the kernel.
*
* Clear the buffer. Return the cap for the buffer.
* Should be called once on each core.
*/
errval_t trace_setup_on_core(struct capref *retcap)
{
#ifdef __i386__
return TRACE_ERR_NO_BUFFER;
#endif
// Clear the buffer
trace_reset_buffer();
// Tell the kernel that the trace buffer exists
struct capref tracecap = {
.cnode = cnode_task,
.slot = TASKCN_SLOT_TRACEBUF
};
*retcap = tracecap;
return SYS_ERR_OK;
}
| 24.523077 | 88 | 0.686637 |
c917b693417f7a47e22fca9fb16d4534eeb345a7 | 2,477 | c | C | ATtiny167/main.c | LynXzp/ATmega2560-67-fast-software-PWM-channels | 7120cacebcfbe22be0c766a47cb0f06ae5e665d2 | [
"BSD-2-Clause"
] | null | null | null | ATtiny167/main.c | LynXzp/ATmega2560-67-fast-software-PWM-channels | 7120cacebcfbe22be0c766a47cb0f06ae5e665d2 | [
"BSD-2-Clause"
] | null | null | null | ATtiny167/main.c | LynXzp/ATmega2560-67-fast-software-PWM-channels | 7120cacebcfbe22be0c766a47cb0f06ae5e665d2 | [
"BSD-2-Clause"
] | null | null | null | #include <avr/io.h>
// #include <avr/interrupt.h>
// #include <avr/pgmspace.h>
// #include <avr/wdt.h>
#include <limits.h>
#define CLR_BIT(a,b) ((a) &=~(1<<(b)))
#define SET_BIT(a,b) ((a) |= (1<<(b)))
#define TST_BIT(a,b) ((a) & (1<<(b)))
#define CHANGE_BIT(a,b) ((a) ^= (1<<(b)))
#define F_CPU 16000000UL // 16 MHz
#ifndef ALIBC_OLD
#include <util/delay.h>
#else
#include <avr/delay.h>
#endif
uint8_t maxi[13]={251, 241, 239, 233, 229, 227, 223, 211, 199, 197, 193, 191, 181}; // prime numbers, using cicada cycles
uint8_t tcnt=1; // software TCNT - counter itself
uint8_t ocr[13]={1,1,1,1,1,1,1,1,1,1,1,1,1}; // software compare registers
int8_t direction[13]={1,1,1,1,1,1,1,1,1,1,1,1,1}; // direction - raising or faiding
uint16_t aditionalOffDelay[13]; // additional delay, because led ever with 1% is bright, and almost never real off
enum{LOW=0,HIGH=1};
static void digitalWrite(uint8_t pin,uint8_t voltage);
static void blink(int n);
int main(void)
{
DDRB|=0b01001111;
DDRA|=0b01111111;
while(1)
{ tcnt++;
for(uint8_t pin=0;pin<=12;pin+=1)
{
if(aditionalOffDelay[pin])
{ aditionalOffDelay[pin]--;
continue;
}
if(tcnt==0)
{ ocr[pin]+=direction[pin];
}
if(ocr[pin]>=maxi[pin])
{ ocr[pin]=maxi[pin]-1; direction[pin]=-1;
}
if(ocr[pin]<=0)
{ ocr[pin]=1; direction[pin]=1;
}
if((ocr[pin]==1)&&(tcnt==0))
{ aditionalOffDelay[pin]=1ULL*maxi[pin]*maxi[pin];
continue;
}
if(tcnt<ocr[pin])
{ digitalWrite(pin,HIGH);
}
else
digitalWrite(pin,LOW);
}
}
}
static void digitalWrite(uint8_t pin,uint8_t voltage)
{
switch (pin)
{ case 0: voltage ? SET_BIT(PORTB,0) : CLR_BIT(PORTB,0); break;
case 1: voltage ? SET_BIT(PORTB,1) : CLR_BIT(PORTB,1); break;
case 2: voltage ? SET_BIT(PORTB,2) : CLR_BIT(PORTB,2); break;
case 3: voltage ? SET_BIT(PORTB,6) : CLR_BIT(PORTB,6); break;
case 4: voltage ? SET_BIT(PORTB,3) : CLR_BIT(PORTB,3); break;
case 5: voltage ? SET_BIT(PORTA,7) : CLR_BIT(PORTA,7); break;
case 6: voltage ? SET_BIT(PORTA,0) : CLR_BIT(PORTA,0); break;
case 7: voltage ? SET_BIT(PORTA,1) : CLR_BIT(PORTA,1); break;
case 8: voltage ? SET_BIT(PORTA,2) : CLR_BIT(PORTA,2); break;
case 9: voltage ? SET_BIT(PORTA,3) : CLR_BIT(PORTA,3); break;
case 10:voltage ? SET_BIT(PORTA,4) : CLR_BIT(PORTA,4); break;
case 11:voltage ? SET_BIT(PORTA,5) : CLR_BIT(PORTA,5); break;
case 12:voltage ? SET_BIT(PORTA,6) : CLR_BIT(PORTA,6); break;
}
}
| 29.141176 | 121 | 0.636254 |
b517e561a14165cf75c07b43aea0f389d5225971 | 2,488 | c | C | 2-periodo/algoritimos-e-estruturas-de-dados-1/EX/Trabalho_AED1/Trabalho6-avaliacao/main.c | lucasmc64/the-graduation-journey | 46ed6a1b9a063186e6035c6ae6efe600eeb87592 | [
"MIT"
] | null | null | null | 2-periodo/algoritimos-e-estruturas-de-dados-1/EX/Trabalho_AED1/Trabalho6-avaliacao/main.c | lucasmc64/the-graduation-journey | 46ed6a1b9a063186e6035c6ae6efe600eeb87592 | [
"MIT"
] | 1 | 2021-04-08T13:15:01.000Z | 2021-04-08T13:15:01.000Z | 2-periodo/algoritimos-e-estruturas-de-dados-1/EX/Trabalho_AED1/Trabalho6-avaliacao/main.c | lucasmc64/the-graduation-journey | 46ed6a1b9a063186e6035c6ae6efe600eeb87592 | [
"MIT"
] | 1 | 2021-04-08T11:39:46.000Z | 2021-04-08T11:39:46.000Z | #include <stdio.h>
#include <stdlib.h>
#include "tad.h"
int main()
{
printf("Criando Lista!");
Lista *p;
p = cria_lista();
insere_ord_cabecalho(&p, 2);
insere_ord_cabecalho(&p, 4);
insere_ord_cabecalho(&p, 6);
printf("\nImprimindo Lista 1!\n");
imprime(&p);
int tamanho;
tamanho_lista(&p, &tamanho);
printf("\nO tamanho da Lista 1 e: %d\n", tamanho);
Lista *a;
a = cria_lista();
insere_ord_cabecalho(&a, 8);
printf("\nImprimindo Lista 2!\n");
imprime(&a);
tamanho;
tamanho_lista(&a, &tamanho);
printf("\nO tamanho da Lista 2 e: %d\n", tamanho);
printf("\nRemovendo pares da Lista 1!\n");
printf("\nImprimindo Lista 1!\n");
remove_par(&p);
imprime(&p);
printf("\nRemovendo pares da Lista 2!\n");
printf("\nImprimindo Lista 2!\n");
remove_par(&a);
imprime(&a);
insere_ord_cabecalho(&p, 8);
insere_ord_cabecalho(&p, 3);
insere_ord_cabecalho(&p, 2);
printf("\nImprimindo Lista 1!\n");
imprime(&p);
insere_ord_cabecalho(&a, 4);
insere_ord_cabecalho(&a, 6);
insere_ord_cabecalho(&a, 3);
printf("\nImprimindo Lista 2!\n");
imprime(&a);
int menorP;
menor_elemento(&p, &menorP);
printf("\nO menor elemento da Lista 1 e: %d\n", menorP);
printf("\nImprimindo Lista 1!\n");
imprime(&p);
int igual = verificar_igualdade(&p, &a);
if(igual == 1){
printf("\nA Lista 1 e a Lista 2 sao iguais!\n");
}else{
printf("\nA Lista 1 e a Lista 2 sao diferentes!\n");
}
printf("\nRemovendo pares da Lista 1!\n");
remove_par(&p);
printf("\nRemovendo pares da Lista 2!\n");
remove_par(&a);
igual = verificar_igualdade(&p, &a);
if(igual == 1){
printf("\nA Lista 1 e a Lista 2 sao iguais!\n");
}else{
printf("\nA Lista 1 e a Lista 2 sao diferentes!\n");
}
int tamanhoP;
tamanho_lista(&p, &tamanhoP);
printf("\nO tamanho da Lista 1 e: %d\n", tamanhoP);
printf("\nImprimindo Lista 1!\n");
imprime(&p);
Lista *panda;
panda = cria_lista();
int intercalou = intercala_listas(&p, &a, &panda);
if(intercalou == 0){
printf("Algo deu errado no intercala!");
system("pause");
exit(1);
}
printf("\nImprimindo Lista 3!\n");
imprime(&panda);
printf("\nRemovendo pares da Lista 3!\n");
remove_par(&panda);
printf("\nImprimindo Lista 3!\n");
imprime(&panda);
return 0;
}
| 23.037037 | 60 | 0.585209 |
b536d050883ba12806a340943640713d8b9f5ac8 | 2,109 | c | C | src/request.c | piaoqingbin/hietcd | 222ff7fcb0d8db8839ef03700cd01d57fead06f4 | [
"Apache-2.0"
] | 2 | 2015-07-16T02:06:36.000Z | 2016-06-06T11:26:27.000Z | src/request.c | piaoqingbin/hietcd | 222ff7fcb0d8db8839ef03700cd01d57fead06f4 | [
"Apache-2.0"
] | null | null | null | src/request.c | piaoqingbin/hietcd | 222ff7fcb0d8db8839ef03700cd01d57fead06f4 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) 2014-2015, Qingbin Piao <piaoqingbin at gmail dot com>
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * 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 Redis 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.
*/
#include <stdlib.h>
#include <string.h>
#include "request.h"
etcd_request *etcd_request_create(char *url, size_t len, const char *method)
{
etcd_request *req;
if (!(req = malloc(sizeof(etcd_request))))
return NULL;
req->url = strndup(url, len);
req->method = method;
req->data = NULL;
etcd_rq_init(&req->rq);
return req;
}
void etcd_request_destroy(etcd_request *req)
{
if (req->url) free(req->url);
if (req->data) free(req->data);
free(req);
}
| 37 | 78 | 0.728781 |
be26b66b73f5b940c9856351dee334437ad7046f | 11,252 | h | C | src/zombies/entity/anim/gun.h | gregtour/tedge-cpp | 45f47ec7017d2124463430f1e584d9fb0dc8bdd8 | [
"Apache-2.0"
] | 1 | 2016-10-31T15:02:32.000Z | 2016-10-31T15:02:32.000Z | src/zombies/entity/anim/gun.h | gregtour/tedge-cpp | 45f47ec7017d2124463430f1e584d9fb0dc8bdd8 | [
"Apache-2.0"
] | null | null | null | src/zombies/entity/anim/gun.h | gregtour/tedge-cpp | 45f47ec7017d2124463430f1e584d9fb0dc8bdd8 | [
"Apache-2.0"
] | 1 | 2021-02-22T22:03:49.000Z | 2021-02-22T22:03:49.000Z |
#define GUN_TRIANGLES 134
// ********** MESH DATA **********
// --- Mesh: Gun ---
Point3 Gun_vertex[] = {
{-0.375000, -0.071579, -0.710527},
{-0.375000, -0.349474, -0.710527},
{-0.532895, -0.071579, -0.710527},
{-0.532895, -0.349474, -0.710527},
{-0.375016, -0.018940, -0.678947},
{-0.532914, -0.018940, -0.678947},
{-0.532914, -0.356044, -0.710553},
{-0.375016, -0.356044, -0.710553},
{-0.393453, -0.141849, -0.054076},
{-0.439800, -0.205639, -0.054076},
{-0.460526, -0.141849, -0.054076},
{-0.393453, -0.141849, 1.482511},
{-0.460526, -0.141849, 1.482511},
{-0.439800, -0.205639, 1.482511},
{-0.393453, -0.141849, -0.054076},
{-0.439800, -0.205639, -0.054076},
{-0.439800, -0.205639, 1.482511},
{-0.514790, -0.181273, -0.054076},
{-0.514790, -0.181273, 1.482511},
{-0.514790, -0.181273, 1.482511},
{-0.514790, -0.181273, -0.054076},
{-0.514790, -0.102424, -0.054076},
{-0.514790, -0.102424, 1.482511},
{-0.514790, -0.102424, -0.054076},
{-0.514790, -0.102424, 1.482511},
{-0.439800, -0.078058, -0.054076},
{-0.439800, -0.078058, 1.482511},
{-0.439800, -0.078058, 1.482511},
{-0.439800, -0.078058, -0.054076},
{-0.393453, -0.141849, -0.054076},
{-0.393453, -0.141849, 1.482511},
{-0.393453, -0.263800, -0.060435},
{-0.439800, -0.327590, -0.060435},
{-0.460526, -0.263800, -0.060435},
{-0.415874, -0.263779, 1.422245},
{-0.460523, -0.263779, 1.422245},
{-0.446695, -0.306279, 1.422245},
{-0.393453, -0.263800, 0.415698},
{-0.439800, -0.327590, 0.415698},
{-0.514790, -0.303224, -0.060435},
{-0.496655, -0.290029, 1.422245},
{-0.514790, -0.303224, 0.415698},
{-0.514790, -0.224375, -0.060435},
{-0.496655, -0.237568, 1.422245},
{-0.514790, -0.224375, 0.415698},
{-0.439800, -0.200009, -0.060435},
{-0.446695, -0.221318, 1.422245},
{-0.439800, -0.200009, 0.415698},
{-0.433552, -0.346761, 0.455142},
{-0.373328, -0.263765, 0.455142},
{-0.531068, -0.315023, 0.455142},
{-0.531068, -0.212587, 0.455142},
{-0.433552, -0.180849, 0.455142},
{-0.433549, -0.346779, 1.290686},
{-0.373307, -0.263771, 1.290686},
{-0.531083, -0.315041, 1.290686},
{-0.531083, -0.212563, 1.290686},
{-0.433549, -0.180825, 1.290686},
{-0.438942, -0.330182, 1.343301},
{-0.390749, -0.263776, 1.343301},
{-0.516970, -0.304791, 1.343301},
{-0.516970, -0.222809, 1.343301},
{-0.438942, -0.197418, 1.343301},
{-0.438920, -0.330178, 1.382756},
{-0.390763, -0.263771, 1.382756},
{-0.516984, -0.304787, 1.382756},
{-0.516984, -0.222817, 1.382756},
{-0.438920, -0.197426, 1.382756},
{-0.532895, -0.071579, -0.006579},
{-0.532895, -0.349474, -0.006579},
{-0.375000, -0.071579, -0.006579},
{-0.375000, -0.349474, -0.006579},
{-0.532914, -0.018940, -0.038152},
{-0.375016, -0.018940, -0.038152},
{-0.504472, -0.520531, -0.105084},
{-0.504472, -0.540268, -0.335736},
{-0.403458, -0.520531, -0.105084},
{-0.403458, -0.540268, -0.335736},
{-0.532914, -0.356044, -0.006573},
{-0.375016, -0.356044, -0.006573},
{-0.504492, -0.356057, -0.105065},
{-0.504492, -0.356057, -0.335745},
{-0.403438, -0.356057, -0.105065},
{-0.403438, -0.356057, -0.335745}
};
Point2 Gun_uv[] = {
{0.779192, 0.346581},
{0.779192, 0.557957},
{0.779192, 0.346581},
{0.779192, 0.557957},
{0.750195, 0.306543},
{0.750195, 0.306543},
{0.779215, 0.562955},
{0.779215, 0.562955},
{0.068838, 0.033476},
{0.068838, 0.033476},
{0.068838, 0.033476},
{0.068838, 0.033476},
{0.068838, 0.033476},
{0.068838, 0.033476},
{0.068838, 0.083830},
{0.234398, 0.083830},
{0.234398, 0.033476},
{0.068838, 0.033476},
{0.068838, 0.033476},
{0.399958, 0.033476},
{0.399958, 0.083830},
{0.068838, 0.033476},
{0.068838, 0.033476},
{0.565517, 0.083830},
{0.565517, 0.033476},
{0.068838, 0.033476},
{0.068838, 0.033476},
{0.731077, 0.033476},
{0.731077, 0.083830},
{0.896637, 0.083830},
{0.896637, 0.033476},
{0.942256, 0.174685},
{0.942256, 0.221537},
{0.942256, 0.174685},
{0.108672, 0.174669},
{0.108672, 0.174669},
{0.108672, 0.205884},
{0.674568, 0.174685},
{0.674568, 0.221537},
{0.942256, 0.203641},
{0.108672, 0.193949},
{0.674568, 0.203641},
{0.942256, 0.145728},
{0.108672, 0.155418},
{0.674568, 0.145728},
{0.942256, 0.127832},
{0.108672, 0.143483},
{0.674568, 0.127832},
{0.652391, 0.235618},
{0.652391, 0.174659},
{0.652391, 0.212307},
{0.652391, 0.137070},
{0.652391, 0.113759},
{0.182637, 0.235631},
{0.182637, 0.174664},
{0.182637, 0.212320},
{0.182637, 0.137052},
{0.182637, 0.113741},
{0.153056, 0.223441},
{0.153056, 0.174667},
{0.153056, 0.204792},
{0.153056, 0.144578},
{0.153056, 0.125929},
{0.130874, 0.223438},
{0.130874, 0.174664},
{0.130874, 0.204789},
{0.130874, 0.144583},
{0.130874, 0.125935},
{0.132816, 0.346581},
{0.132816, 0.557957},
{0.132816, 0.346581},
{0.132816, 0.557957},
{0.161807, 0.306543},
{0.161807, 0.306543},
{0.223264, 0.688069},
{0.435053, 0.703082},
{0.223264, 0.688069},
{0.435053, 0.703082},
{0.132810, 0.562955},
{0.132810, 0.562955},
{0.223247, 0.562965},
{0.435061, 0.562965},
{0.223247, 0.562965},
{0.435061, 0.562965}
};
Point3 Gun_normal[] = {
{0.000000, 0.000000, -1.000000},
{0.447186, 0.460248, -0.766940},
{0.894371, 0.230328, -0.383470},
{-0.447247, 0.460011, -0.767046},
{-0.894495, 0.229759, -0.383523},
{-0.268107, -0.800690, -0.535736},
{-0.894419, 0.004398, -0.447208},
{0.447214, 0.002446, -0.894424},
{0.534499, -0.801817, -0.267206},
{0.000000, 0.000000, 1.000000},
{0.971904, 0.235376, 0.000000},
{0.971904, -0.235376, 0.000000},
{0.309017, -0.951056, 0.000000},
{-0.809017, -0.587785, 0.000000},
{-0.809017, 0.587785, 0.000000},
{-0.809017, 0.587785, 0.000000},
{0.309017, 0.951056, 0.000000},
{0.971904, 0.235376, 0.000000},
{0.971904, -0.235377, 0.000000},
{0.309017, -0.951057, 0.000000},
{-0.809017, -0.587785, 0.000000},
{-0.809017, 0.587785, 0.000000},
{0.309017, 0.951056, 0.000000},
{0.309017, 0.951057, 0.000000},
{0.291255, -0.926493, -0.238287},
{0.068225, -0.893199, -0.444455},
{0.870621, -0.210657, -0.444571},
{0.971187, -0.009076, -0.238148},
{-0.791269, -0.563280, -0.237925},
{-0.828480, -0.341313, -0.443989},
{-0.780459, 0.578208, -0.237823},
{-0.580670, 0.682397, -0.444024},
{0.308777, 0.920847, -0.238114},
{0.469507, 0.762743, -0.444732},
{0.308997, -0.937366, 0.160829},
{0.986988, 0.004325, 0.160736},
{-0.796185, -0.583311, 0.160742},
{-0.801057, 0.576609, 0.160717},
{0.300907, 0.939999, 0.160799},
{0.301104, -0.939935, 0.160809},
{0.986982, -0.003917, 0.160782},
{-0.801073, -0.576615, 0.160611},
{-0.796162, 0.583337, 0.160764},
{0.308858, 0.937407, 0.160855},
{0.309157, -0.906689, 0.286944},
{0.957906, 0.013847, 0.286749},
{-0.767051, -0.573922, 0.286786},
{-0.783067, 0.551961, 0.286611},
{0.283073, 0.915184, 0.286895},
{0.446226, -0.724006, 0.526021},
{0.826752, 0.200126, 0.525766},
{-0.551248, -0.647762, 0.525860},
{-0.786482, 0.323908, 0.525861},
{0.064930, 0.848075, 0.525882},
{1.000000, 0.000000, 0.000000},
{-1.000000, 0.000000, 0.000000},
{0.000000, 1.000000, 0.000000},
{0.000000, -0.996359, 0.085259},
{-0.894495, 0.229727, 0.383542},
{-0.447247, 0.459946, 0.767085},
{0.447186, 0.460183, 0.766979},
{0.894371, 0.230296, 0.383489},
{-0.535380, -0.801065, 0.267700},
{-0.447211, 0.002158, 0.894426},
{0.267449, -0.801770, 0.534449},
{0.894425, -0.001761, 0.447214},
{-0.267461, -0.801751, 0.534472},
{-0.534574, -0.801756, -0.267242},
{0.534558, -0.801750, 0.267291},
{0.267473, -0.801748, -0.534470},
{-0.894425, -0.000158, 0.447217},
{-0.447215, -0.000096, -0.894426},
{0.447212, -0.000159, 0.894428},
{0.894429, -0.000129, -0.447210}
};
long Gun_vidx[] = {
0, 1, 2,
1, 3, 2,
4, 0, 2,
4, 2, 5,
6, 3, 1,
6, 1, 7,
8, 9, 10,
11, 12, 13,
14, 11, 15,
11, 16, 15,
9, 17, 10,
13, 12, 18,
15, 16, 19,
15, 19, 20,
17, 21, 10,
18, 12, 22,
20, 19, 23,
19, 24, 23,
21, 25, 10,
22, 12, 26,
23, 24, 27,
23, 27, 28,
25, 8, 10,
26, 12, 11,
28, 27, 29,
27, 30, 29,
31, 32, 33,
34, 35, 36,
31, 37, 32,
37, 38, 32,
32, 39, 33,
36, 35, 40,
32, 38, 41,
32, 41, 39,
39, 42, 33,
40, 35, 43,
39, 41, 42,
41, 44, 42,
42, 45, 33,
43, 35, 46,
42, 44, 47,
42, 47, 45,
45, 31, 33,
46, 35, 34,
45, 47, 31,
47, 37, 31,
48, 38, 37,
48, 37, 49,
50, 41, 38,
50, 38, 48,
51, 44, 41,
51, 41, 50,
52, 47, 44,
52, 44, 51,
49, 37, 47,
49, 47, 52,
53, 48, 49,
53, 49, 54,
55, 50, 48,
55, 48, 53,
56, 51, 50,
56, 50, 55,
57, 52, 51,
57, 51, 56,
54, 49, 52,
54, 52, 57,
58, 53, 54,
58, 54, 59,
60, 55, 53,
60, 53, 58,
61, 56, 55,
61, 55, 60,
62, 57, 56,
62, 56, 61,
59, 54, 57,
59, 57, 62,
63, 58, 59,
63, 59, 64,
65, 60, 58,
65, 58, 63,
66, 61, 60,
66, 60, 65,
67, 62, 61,
67, 61, 66,
64, 59, 62,
64, 62, 67,
36, 63, 64,
36, 64, 34,
40, 65, 63,
40, 63, 36,
43, 66, 65,
43, 65, 40,
46, 67, 66,
46, 66, 43,
34, 64, 67,
34, 67, 46,
68, 69, 70,
69, 71, 70,
70, 71, 0,
71, 1, 0,
2, 3, 68,
3, 69, 68,
5, 72, 4,
72, 73, 4,
74, 75, 76,
75, 77, 76,
5, 2, 68,
5, 68, 72,
72, 68, 70,
72, 70, 73,
73, 70, 0,
73, 0, 4,
78, 69, 3,
78, 3, 6,
79, 71, 69,
79, 69, 78,
7, 1, 71,
7, 71, 79,
80, 78, 6,
80, 6, 81,
82, 79, 78,
82, 78, 80,
81, 6, 7,
81, 7, 83,
83, 7, 79,
83, 79, 82,
74, 80, 81,
74, 81, 75,
76, 82, 80,
76, 80, 74,
75, 81, 83,
75, 83, 77,
77, 83, 82,
77, 82, 76
};
long Gun_nidx[] = {
0, 0, 0,
0, 0, 0,
1, 2, 3,
1, 3, 4,
5, 6, 7,
5, 7, 8,
0, 0, 0,
9, 9, 9,
10, 11, 12,
11, 12, 12,
0, 0, 0,
9, 9, 9,
12, 12, 13,
12, 13, 13,
0, 0, 0,
9, 9, 9,
13, 13, 14,
13, 15, 14,
0, 0, 0,
9, 9, 9,
14, 15, 16,
14, 16, 16,
0, 0, 0,
9, 9, 9,
16, 16, 10,
16, 11, 10,
0, 0, 0,
9, 9, 9,
17, 18, 19,
18, 19, 19,
0, 0, 0,
9, 9, 9,
19, 19, 20,
19, 20, 20,
0, 0, 0,
9, 9, 9,
20, 20, 14,
20, 21, 14,
0, 0, 0,
9, 9, 9,
14, 21, 22,
14, 22, 23,
0, 0, 0,
9, 9, 9,
23, 22, 17,
22, 18, 17,
24, 25, 26,
24, 26, 27,
28, 29, 25,
28, 25, 24,
30, 31, 29,
30, 29, 28,
32, 33, 31,
32, 31, 30,
27, 26, 33,
27, 33, 32,
34, 24, 27,
34, 27, 35,
36, 28, 24,
36, 24, 34,
37, 30, 28,
37, 28, 36,
38, 32, 30,
38, 30, 37,
35, 27, 32,
35, 32, 38,
39, 34, 35,
39, 35, 40,
41, 36, 34,
41, 34, 39,
42, 37, 36,
42, 36, 41,
43, 38, 37,
43, 37, 42,
40, 35, 38,
40, 38, 43,
44, 39, 40,
44, 40, 45,
46, 41, 39,
46, 39, 44,
47, 42, 41,
47, 41, 46,
48, 43, 42,
48, 42, 47,
45, 40, 43,
45, 43, 48,
49, 44, 45,
49, 45, 50,
51, 46, 44,
51, 44, 49,
52, 47, 46,
52, 46, 51,
53, 48, 47,
53, 47, 52,
50, 45, 48,
50, 48, 53,
9, 9, 9,
9, 9, 9,
54, 54, 54,
54, 54, 54,
55, 55, 55,
55, 55, 55,
56, 56, 56,
56, 56, 56,
57, 57, 57,
57, 57, 57,
4, 3, 58,
4, 58, 59,
59, 58, 60,
59, 60, 61,
61, 60, 2,
61, 2, 1,
62, 63, 6,
62, 6, 5,
64, 65, 63,
64, 63, 62,
8, 7, 65,
8, 65, 64,
66, 62, 5,
66, 5, 67,
68, 64, 62,
68, 62, 66,
67, 5, 8,
67, 8, 69,
69, 8, 64,
69, 64, 68,
70, 66, 67,
70, 67, 71,
72, 68, 66,
72, 66, 70,
71, 67, 69,
71, 69, 73,
73, 69, 68,
73, 68, 72
};
| 21.071161 | 36 | 0.538215 |
be3aa1f4a38815a2fc1eee8d03338b269342387a | 1,102 | h | C | src/sounds/sounds.h | Press-Play-On-Tape/Logix | e1186dd2dc99e9c7699024312d62f0338cc88e74 | [
"BSD-3-Clause"
] | 4 | 2018-05-14T06:33:34.000Z | 2021-01-11T09:20:03.000Z | src/sounds/sounds.h | filmote/Logix | 83de79c48ba20082c3c6d8cbf365d082a46ce965 | [
"BSD-3-Clause"
] | null | null | null | src/sounds/sounds.h | filmote/Logix | 83de79c48ba20082c3c6d8cbf365d082a46ce965 | [
"BSD-3-Clause"
] | 1 | 2019-09-15T08:20:23.000Z | 2019-09-15T08:20:23.000Z | #pragma once
const uint16_t fail[] PROGMEM = {
NOTE_G1, 125, NOTE_REST, 50, NOTE_C1, 400, TONES_END
};
const uint16_t success[] PROGMEM = {
NOTE_C5, 125, NOTE_REST, 50, NOTE_E5, 500, NOTE_REST, 50, TONES_END
};
const uint16_t score[] PROGMEM = {
NOTE_E1, 59, NOTE_E1, 156, NOTE_REST, 7, NOTE_E1, 216, NOTE_REST, 1350, NOTE_G1, 216, NOTE_REST, 7, NOTE_G1, 216,
NOTE_REST, 455, NOTE_D1, 216, NOTE_REST, 7, NOTE_D1, 216, NOTE_REST, 455, NOTE_E1, 216, NOTE_REST, 7, NOTE_E1, 216,
NOTE_REST, 1350, NOTE_C2, 216, NOTE_REST, 7, NOTE_C2, 216, NOTE_REST, 455, NOTE_G1, 216, NOTE_REST, 7, NOTE_G1, 216,
NOTE_REST, 455, NOTE_E1, 216, NOTE_REST, 7, NOTE_E1, 216, NOTE_REST, 1350, NOTE_G1, 216, NOTE_REST, 7, NOTE_G1, 216,
NOTE_REST, 455, NOTE_D1, 208, NOTE_D1, 7, NOTE_REST, 7, NOTE_D1, 216, NOTE_REST, 201, NOTE_REST, 14, NOTE_REST, 242,
NOTE_E1, 219, NOTE_REST, 7, NOTE_E1, 219, NOTE_REST, 1371, NOTE_C2, 219, NOTE_REST, 7, NOTE_C2, 219, NOTE_REST, 462,
NOTE_B1, 219, NOTE_REST, 7, NOTE_B1, 219, NOTE_REST, 462, NOTE_E1, 219, NOTE_REST, 7, NOTE_E1, 219, NOTE_REST, 1371,
TONES_END
}; | 42.384615 | 118 | 0.705082 |
9c5dd3d36ef77f14cf6324391a09a454711b0efd | 30,985 | h | C | Parser.h | mary060196/CISC3160_Project | 96c3891c3b679764f1fff72649d8d4fa808a5ecb | [
"MIT"
] | null | null | null | Parser.h | mary060196/CISC3160_Project | 96c3891c3b679764f1fff72649d8d4fa808a5ecb | [
"MIT"
] | null | null | null | Parser.h | mary060196/CISC3160_Project | 96c3891c3b679764f1fff72649d8d4fa808a5ecb | [
"MIT"
] | null | null | null | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* Header File: Definition of the 'Parser' Class *
* CISC 3160 - Programming Languages - Fall 2019 - Toy Language Project *
* Author: *
* Miriam Briskman *
* Supervised by: *
* Professor Neng-Fa Zhou *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef PARSER_H
#define PARSER_H
#include <iostream> // ---> Input / Output streams controlling objects
#include <map> // ---> The map container
#include <string> // ---> "String types, character traits and a set of converting functions"
#include "Semantics.h" // ---> The "Semantics" (Semantic Analyzer) Object
#include "Symbol_Table_Row.h" // ---> The "Symbol_Table_Row" Object
#include "Tokenizer.h" // ---> The "Tokenizer" Object
using namespace std;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* The Parser Class *
* Purpose: *
* To create a parse tree and detect syntax errors. *
* Data Fields (private): *
* 1) 'symbolTable' (map pointer) - pointer to the Symbol Table map object. *
* 2) 't1' (Token) - a Token object holding the currently processed token by the Parser. *
* 3) 'myTokenizer' (Tokenizer) - the Tokenizer that the Parser uses. *
* 4) 'sAnalyzer' (Semantics) - the Semantic Analyzer that the Parser uses. *
* 5) 'errors' (int) - total number of errors detected by Parser and Semantic Analyzer. *
* 6) 'OpenParens' (int) - counts the number of open parentheses. *
* Functions (public): *
* 1) Constructor. Arguments: fileName(string), symbolTable (pointer to / address of map). *
* Functions (private): *
* 1) 'skipAfterNextSemicolon' - panic mode error recovery: parse after next semicolon. *
* 2) 'printErrorsHeader' - print the title of the error displaying section. *
* 3) 'printErrorsFooter' - print the total number of errors and footer of the error section. *
* 4) 'printSyntaxError' - print a syntax error based on the passed encoded 'message'. *
* 5) 'printErrorLine' - print the line and column on which the syntax error occured. *
* 6) 'matchID' - match a l-value of an assignment. *
* 7) 'matchAssign' - match an assignment symbol. *
* 8) 'matchExp' - match an expression. *
* 9) 'matchSemicolon' - match a semicolon. *
* 10) 'matchTerm' - match a term. *
* 11) 'matchExpPrime' - match expression prime. *
* 12) 'matchFact' - match a factor. *
* 13) 'matchTermPrime' - match term prime. *
* 14) 'printValuesOfVariables' - print all the variables's values at end of interpretation. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
class Parser
{
private:
/* Data Fields: */
map<string, Symbol_Table_Row>* symbolTable; // Pointer to the Symbol Table map object
Token t1; // The token whose info the parser will check at a time
Tokenizer myTokenizer; // The Tokenizer that the Parser uses
Semantics sAnalyzer; // The Semantic Analyzer that the Parser uses
int errors; // Number of errors detected by the parser
int OpenParens; // Counts the number of open parentheses
public:
/* Constructor */
Parser (string fileName, map<string, Symbol_Table_Row>* symbolTable)
{
this -> symbolTable = symbolTable;
this -> errors = 0;
this -> OpenParens = 0;
this -> t1 = Token ('0', "");
this -> myTokenizer = Tokenizer (fileName, symbolTable);
this -> sAnalyzer = Semantics (this -> symbolTable, &myTokenizer, &errors);
this -> myTokenizer.next (t1); // Retrieve the first token.
while (this -> t1.getType () != '5')
if (matchID () && matchAssign () && matchExp () && matchSemicolon ())
{
if (OpenParens > 0)
printSyntaxError (10);
myTokenizer.next(t1); // Retrieve the next token.
}
else
skipAfterNextSemicolon ();
if (this -> errors > 0)
printErrorsFooter ();
else
printValuesOfVariables ();
}
private:
/* Error Recovery Function */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'skipAfterNextSemicolon': *
* Input: None. *
* Output: Panic Mode Error Recovery: Continue Parsing after Next Semicolon. *
* No object is returned. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void skipAfterNextSemicolon (void)
{
while (t1.getType() != '5' && t1.getName()[0] != ';')
myTokenizer.next(t1); // Retrieve the next token.
myTokenizer.next(t1); // We need the token that is right after the semicolon.
sAnalyzer.initialize(); // Clear the information in the Semantic Analyzer.
OpenParens = 0;
}
/* Syntax Errors Printing Functions */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'printErrorsHeader': *
* Input: None. *
* Output: Print the header of the error messages' section *
* No object is returned. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void printErrorsHeader (void)
{
cout << "------------------------ ERRORS ------------------------" << endl;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'printErrorsFooter': *
* Input: None. *
* Output: Print the footer of the error messages' section *
* No object is returned. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void printErrorsFooter (void)
{
cout << "Totally: " << errors << " Errors."
<< endl << "--------------------------------------------------------" << endl;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'printSyntaxError': *
* Input: 'message' (char) - the type of compilation syntax error *
* 'type' (char) - either 's' (for sybmol) or 'n' (for number) *
* 'side' (char) - either 'l' (for left) or 'r' (for right) *
* Output: Display of the corresponding syntax error on the screen. *
* No object is returned. *
* Message encoding: *
* '0' -> If a prohibited character (symbol) was encountered *
* '1' -> If the left side of the assignment contains a symbol or literal *
* '2' -> If the left side of the assignment contains an extra variable *
* '3' -> If the right side of the assignment contains an extra expression *
* '4' -> If there is an extra closing parenthesis *
* '5' -> If there is an extra semicolon *
* '6' -> If there is an inappropriate expression before the semicolon *
* '7' -> If the semicolon is missing *
* '8' -> If there is a lone identifier without an assignment *
* '9' -> If there is no expression to the right of the assignment symbol *
* '10' -> If there are extra opening parentheses *
* '11' -> If there is an opening parenthesis without a binary symbol before it *
* '12' -> If there are too many assignment operators *
* '13' -> If there is a '*' after a binary operator *
* '14' -> If there is an inappropriate expression before a closing parenthesis *
* '15' -> If a semicolon comes before an assignment symbol *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void printSyntaxError (char message, char type = 's')
{
if (errors == 0)
printErrorsHeader();
errors++;
cout << endl << errors << ") Syntax Error:" << endl;
switch (message)
{
case 0: cout << "You are using a prohibited symbol: "
<< endl << endl << "\t" << t1.getName()[0] << " (ASCII "
<< (short)t1.getName()[0] << ")";
break;
case 1: cout << "The left hand side of an assignment cannot contain";
switch (type)
{
case 's': cout << endl << endl << "\t" << t1.getName() << " (ASCII "
<< (short)t1.getName()[0] << ")" << endl << endl
<< "(a symbol)";
break;
case 'n': cout << endl << endl << "\t" << t1.getName() << endl << endl
<< "(a literal)";
}
break;
case 2: cout << "There is an extra variable:" << endl << endl << "\t" << t1.getName();
break;
case 3: cout << "There is an extra expression:" << endl << endl << "\t" << t1.getName();
break;
case 4: cout << "There is an extra closing parenthesis" << endl << endl << "\t)";
break;
case 5: cout << "There is an extra semicolon" << endl << endl << "\t;";
break;
case 6: cout << "A semicolon" << endl << endl << "\t;" << endl << endl
<< "cannot come after an inappropriate expression";
break;
case 7: cout << "A semicolon" << endl << endl << "\t;" << endl << endl
<< "is missing";
break;
case 8: cout << "There is a lone identifier";
break;
case 9: cout << "There is no expression to the right of the assignment symbol";
break;
case 10: cout << "There are " << OpenParens << " extra opening parentheses";
break;
case 11: cout << "An opening parenthesis" << endl << endl << "\t(" << endl << endl
<< "cannot follow an expression without a binary operation";
break;
case 12: cout << "There is an extra assignment operator"
<< endl << endl << "\t=";
break;
case 13: cout << "A multiplication symbol" << endl << endl << "\t*" << endl << endl
<< "cannot follow another binary operation";
break;
case 14: cout << "A closing parenthesis" << endl << endl << "\t)" << endl << endl
<< "cannot come after an inappropriate expression";
break;
case 15: cout << "A semicolon" << endl << endl << "\t;" << endl << endl
<< "must not come before an assignment operator =";
}
cout << endl << endl << "on line " << myTokenizer.getCurrLine() << ":" << endl << endl;
if (message != 10) // Because we do not know which '(' is the excessive one.
printErrorLine ();
else
cout << "\t"
<< myTokenizer.getRemainingCode().substr(0, myTokenizer.getRemainingCode().find("\n"))
<< endl;
cout << endl << "--------------------------------------------------------" << endl;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'printErrorLine': *
* Input: None. *
* Output: Display of the corresponding syntax error's line on the screen. *
* No object is returned. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void printErrorLine (void)
{
// Extract the first line from the remaining code:
string firstLine
= myTokenizer.getRemainingCode().substr(0, myTokenizer.getRemainingCode().find("\n"));
// Replace tab characters with spaces (since we do not know how long is a tab):
while (firstLine.find("\t") != string::npos)
firstLine[firstLine.find("\t")] = ' ';
// Print that line:
cout << "\t" << firstLine << endl;
// Also, print a caret under the column of the error:
cout << "\t";
for (int i = 0; i < myTokenizer.getCurrCol(); i++)
cout << " ";
cout << "^" << endl;
}
/* Token Matching Functions */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'matchID': *
* Input: None. *
* Output: Match the l-value of the assignment (must be an identifier.) *
* Return 'true' if no errors were detected; return false otherwise. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
bool matchID (void)
{
switch (t1.getType())
{
case '1': sAnalyzer.process(t1, -1); // Call the Semantic Analyzer to process this.
myTokenizer.next(t1); // Retrieve the next token.
return true;
case '0': printSyntaxError (0);
break;
case '2': printSyntaxError (1, 'n');
break;
case '3': switch (t1.getName()[0])
{
case ';': printSyntaxError (5);
return false;
default: printSyntaxError (1, 's');
}
break;
}
myTokenizer.next(t1); // Retrieve the next token.
return false;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'matchAssign': *
* Input: None. *
* Output: Match the assignment symbol. *
* Return 'true' if no errors were detected; return false otherwise. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
bool matchAssign (void)
{
switch (t1.getType())
{
case '1': printSyntaxError (2);
break;
case '0': printSyntaxError (0);
break;
case '2': printSyntaxError (1, 'n');
break;
case '3': switch (t1.getName()[0])
{
case '=': myTokenizer.next(t1); // Retrieve the next token.
return true;
case ';': printSyntaxError (15);
return false;
default: printSyntaxError (1);
}
break;
case '5': printSyntaxError (8);
}
myTokenizer.next(t1); // Retrieve the next token.
return false;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'matchExp': *
* Input: None. *
* Output: Match an expression. *
* Return 'true' if no errors were detected; return false otherwise. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
bool matchExp (void)
{
if (t1.getType() == '5')
{
printSyntaxError (9);
return false;
}
if (matchTerm () && matchExpPrime ())
return true;
return false;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'matchSemicolon': *
* Input: None. *
* Output: Match a semicolon symbol. *
* Return 'true' if no errors were detected; return false otherwise. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
bool matchSemicolon (void)
{
sAnalyzer.process(t1, 4); // Call the Semantic Analyzer to process this.
return true;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'matchTerm': *
* Input: None. *
* Output: Match a term. *
* Return 'true' if no errors were detected; return false otherwise. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
bool matchTerm (void)
{
if (matchFact () && matchTermPrime ())
return true;
return false;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'matchExpPrime': *
* Input: None. *
* Output: Match a pattern following an expression (expression prime). *
* Return 'true' if no errors were detected; return false otherwise. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
bool matchExpPrime (void)
{
switch (t1.getType())
{
case '0': printSyntaxError (0);
break;
case '1':
case '2': printSyntaxError (3);
break;
case '3': switch (t1.getName()[0])
{
case ';':
case '*': return true;
case '(': printSyntaxError (11);
break;
case ')': if (OpenParens > 0)
{
OpenParens--;
sAnalyzer.process(t1, 4); // Call the Semantic Analyzer.
myTokenizer.next(t1); // Retrieve the next token.
return true;
}
else
{
printSyntaxError (4);
return false;
}
case '+':
case '-': sAnalyzer.process(t1, 3); // Call the Semantic Analyzer.
myTokenizer.next(t1); // Retrieve the next token.
if (matchTerm () && matchExpPrime ())
return true;
return false;
case '=': printSyntaxError (12);
// No default case since we covered all possible cases for type 3.
}
break;
case '5': printSyntaxError (7);
}
return false;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'matchFact': *
* Input: None. *
* Output: Match a factor. *
* Return 'true' if no errors were detected; return false otherwise. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
bool matchFact (void)
{
switch (t1.getType())
{
case '1':
case '2': sAnalyzer.process(t1, -1); // Call the Semantic Analyzer to process this.
myTokenizer.next(t1); // Retrieve the next token.
return true;
case '0': printSyntaxError (0);
break;
case '3': switch (t1.getName()[0])
{
case ';': printSyntaxError (6);
break;
case ')': printSyntaxError (14);
break;
case '(': OpenParens++;
sAnalyzer.process(t1, 0); // Call the Semantic Analyzer.
myTokenizer.next(t1); // Retrieve the next token.
if (matchExp ())
return true;
return false;
case '+':
case '-': sAnalyzer.process(t1, 1); // Call the Semantic Analyzer.
myTokenizer.next(t1); // Retrieve the next token.
if (matchFact ())
return true;
return false;
case '=': printSyntaxError (12);
break;
case '*': printSyntaxError (13);
// No default case since we covered all possible cases for type 3.
}
break;
case '5': printSyntaxError (7);
}
return false;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'matchTermPrime': *
* Input: None. *
* Output: Match a pattern following a term (term prime). *
* Return 'true' if no errors were detected; return false otherwise. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
bool matchTermPrime (void)
{
switch (t1.getType())
{
case '0': printSyntaxError (0);
break;
case '1':
case '2': printSyntaxError (3);
break;
case '3': switch (t1.getName()[0])
{
case '*': sAnalyzer.process(t1, 2); // Call the Semantic Analyzer.
myTokenizer.next(t1); // Retrieve the next token.
if (matchFact () && matchTermPrime ())
return true;
return false;
case ')': if (OpenParens > 0)
{
OpenParens--;
sAnalyzer.process(t1, 4); // Call the Semantic Analyzer.
myTokenizer.next(t1); // Retrieve the next token.
return true;
}
else
{
printSyntaxError (4);
return false;
}
case '+':
case '-':
case ';': return true;
case '(': printSyntaxError (11);
break;
case '=': printSyntaxError (12);
// No default case since we covered all possible cases for type 3.
}
break;
case '5': printSyntaxError (7);
}
return false;
}
/* Variables's Values Printing Function */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* 'printValuesOfVariables': *
* Input: None. *
* Output: Print the value of all the variables after the assignments were made. *
* No object is returned. *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void printValuesOfVariables (void)
{
for (map<string, Symbol_Table_Row>::iterator it = (*symbolTable).begin();
it != (*symbolTable).end();
it++)
cout << it->first << " = " << (it->second).getValue() << endl;
}
}; // End of the Parser class
#endif
| 59.019048 | 110 | 0.314539 |
84e487ec243e2b7a3a616d2991026b76ef7c882f | 1,913 | h | C | Code/Framework/AzCore/AzCore/Memory/MemoryComponent.h | aaarsene/o3de | 37e3b0226958974defd14dd6d808e8557dcd7345 | [
"Apache-2.0",
"MIT"
] | 1 | 2021-09-13T00:01:12.000Z | 2021-09-13T00:01:12.000Z | Code/Framework/AzCore/AzCore/Memory/MemoryComponent.h | aaarsene/o3de | 37e3b0226958974defd14dd6d808e8557dcd7345 | [
"Apache-2.0",
"MIT"
] | null | null | null | Code/Framework/AzCore/AzCore/Memory/MemoryComponent.h | aaarsene/o3de | 37e3b0226958974defd14dd6d808e8557dcd7345 | [
"Apache-2.0",
"MIT"
] | 1 | 2021-07-20T11:07:25.000Z | 2021-07-20T11:07:25.000Z | /*
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#ifndef AZCORE_MEMORY_COMPONENT_H
#define AZCORE_MEMORY_COMPONENT_H
#include <AzCore/Component/Component.h>
#include <AzCore/Math/Crc.h>
namespace AZ
{
/**
* Memory manager component. It will manager all memory managers.
* This is the only component that requires special care as memory managers
* must be operational for any system to operate. In addition this component doesn't have a factory
* as it's managed by the bootstrap component class.
*/
class MemoryComponent
: public Component
{
public:
AZ_COMPONENT(AZ::MemoryComponent, "{6F450DDA-6F4D-40fd-A93B-E5CCCDBC72AB}")
MemoryComponent();
virtual ~MemoryComponent();
//////////////////////////////////////////////////////////////////////////
// Component base
void Init() override;
void Activate() override;
void Deactivate() override;
//////////////////////////////////////////////////////////////////////////
private:
/// \ref ComponentDescriptor::GetProvidedServices
static void GetProvidedServices(ComponentDescriptor::DependencyArrayType& provided);
/// \ref ComponentDescriptor::GetIncompatibleServices
static void GetIncompatibleServices(ComponentDescriptor::DependencyArrayType& incompatible);
/// \ref ComponentDescriptor::Reflect
static void Reflect(ReflectContext* reflection);
// serialized data
bool m_isPoolAllocator;
bool m_isThreadPoolAllocator;
// non-serialized data
bool m_createdPoolAllocator;
bool m_createdThreadPoolAllocator;
};
}
#endif // AZCORE_MEMORY_COMPONENT_H
#pragma once
| 32.982759 | 158 | 0.641401 |
b9df1c61f0b9973f40442f4c3d5f9e021662c0d3 | 46,415 | h | C | src/chainparamsseeds.h | brocoinofficial/bitcoin | 323d4c09c090a0c74b2fbedfb2cd575f1dd839f3 | [
"MIT"
] | 6 | 2017-07-10T02:31:56.000Z | 2019-07-24T21:06:46.000Z | src/chainparamsseeds.h | brocoinofficial/bitcoin | 323d4c09c090a0c74b2fbedfb2cd575f1dd839f3 | [
"MIT"
] | 12 | 2021-12-14T01:00:25.000Z | 2022-03-24T01:49:23.000Z | src/chainparamsseeds.h | brocoinofficial/bitcoin | 323d4c09c090a0c74b2fbedfb2cd575f1dd839f3 | [
"MIT"
] | 5 | 2017-11-12T11:01:04.000Z | 2019-09-24T13:01:16.000Z | #ifndef BITCOIN_CHAINPARAMSSEEDS_H
#define BITCOIN_CHAINPARAMSSEEDS_H
/**
* List of fixed seed nodes for the bitcoin network
* AUTOGENERATED by contrib/seeds/generate-seeds.py
*
* Each line contains a BIP155 serialized (networkID, addr, port) tuple.
*/
static const uint8_t chainparams_seed_main[] = {
0x01,0x04,0x02,0x25,0x1e,0x90,0x22,0x49,
0x01,0x04,0x02,0x8a,0xae,0x9e,0x20,0x8d,
0x01,0x04,0x02,0x98,0x4e,0x7c,0x20,0x8d,
0x01,0x04,0x05,0x08,0x12,0x9a,0x20,0x8d,
0x01,0x04,0x05,0x2d,0x4a,0x32,0x20,0x8d,
0x01,0x04,0x05,0x4f,0x7b,0x03,0x20,0x8d,
0x01,0x04,0x05,0x66,0xa8,0xd9,0x56,0xcc,
0x01,0x04,0x05,0x67,0x89,0x92,0x24,0x75,
0x01,0x04,0x05,0x80,0x57,0x7e,0x20,0x8d,
0x01,0x04,0x05,0xac,0x84,0xc8,0x20,0x8d,
0x01,0x04,0x05,0xbc,0x3e,0x12,0x20,0x8d,
0x01,0x04,0x05,0xfe,0x65,0xe2,0x20,0x8e,
0x01,0x04,0x08,0xd2,0x12,0x38,0x20,0x8d,
0x01,0x04,0x08,0xd2,0x5c,0x20,0x20,0x8d,
0x01,0x04,0x0e,0x0d,0x22,0xe1,0x3f,0x35,
0x01,0x04,0x0e,0x27,0x97,0xa7,0x20,0x8d,
0x01,0x04,0x12,0xc4,0x4f,0x6c,0x20,0x8d,
0x01,0x04,0x12,0xda,0x8b,0x3a,0xbc,0xcd,
0x01,0x04,0x14,0xb8,0x0f,0x74,0x20,0xf1,
0x01,0x04,0x17,0xaf,0x00,0xdc,0x20,0x8d,
0x01,0x04,0x17,0xe9,0x6b,0x15,0x20,0x8d,
0x01,0x04,0x18,0x23,0x44,0xe5,0x20,0x8d,
0x01,0x04,0x18,0x25,0x03,0x1a,0x20,0x8d,
0x01,0x04,0x18,0x66,0x5b,0xcb,0x20,0x8d,
0x01,0x04,0x18,0x74,0x99,0x73,0x20,0x8d,
0x01,0x04,0x18,0x86,0x06,0xa5,0x20,0x8d,
0x01,0x04,0x18,0x9b,0xda,0x0d,0x20,0x8d,
0x01,0x04,0x18,0xa0,0x89,0xad,0x20,0x8d,
0x01,0x04,0x18,0xb1,0x6a,0x55,0x20,0x8d,
0x01,0x04,0x18,0xb8,0x00,0x92,0x20,0x8d,
0x01,0x04,0x18,0xc2,0xde,0x74,0x20,0x8d,
0x01,0x04,0x18,0xcd,0xd7,0xc0,0x20,0x8d,
0x01,0x04,0x1b,0x7c,0x6c,0x13,0x20,0x8d,
0x01,0x04,0x1f,0x0e,0x28,0x40,0x20,0x8d,
0x01,0x04,0x1f,0x2f,0xca,0x70,0x20,0x8d,
0x01,0x04,0x1f,0xa5,0x73,0x07,0x20,0x8d,
0x01,0x04,0x22,0x41,0x2d,0x9d,0x20,0x8d,
0x01,0x04,0x22,0x4e,0x30,0x68,0x20,0x8d,
0x01,0x04,0x22,0x50,0x86,0x44,0x20,0x8d,
0x01,0x04,0x22,0x65,0x84,0xc6,0x20,0x8d,
0x01,0x04,0x22,0xe3,0x44,0xd8,0x20,0x8d,
0x01,0x04,0x23,0x89,0xd4,0x16,0x20,0x8d,
0x01,0x04,0x23,0xe7,0xbe,0x86,0x20,0x8d,
0x01,0x04,0x25,0x01,0xd9,0x23,0x20,0x8d,
0x01,0x04,0x25,0x0f,0x3e,0x20,0x20,0x8d,
0x01,0x04,0x25,0x8f,0x76,0xae,0x20,0x8d,
0x01,0x04,0x25,0xc8,0x3b,0x43,0x20,0x8d,
0x01,0x04,0x25,0xcd,0x09,0xa5,0x20,0x8d,
0x01,0x04,0x26,0x17,0xb4,0xe4,0x20,0x8d,
0x01,0x04,0x26,0x41,0x77,0x1a,0x20,0x8d,
0x01,0x04,0x26,0x8d,0x86,0x8c,0x20,0x8d,
0x01,0x04,0x27,0x6d,0x7a,0x7f,0x20,0xfc,
0x01,0x04,0x29,0x4f,0x46,0x92,0x20,0x8d,
0x01,0x04,0x29,0xc1,0x7a,0xbf,0x20,0x8d,
0x01,0x04,0x2b,0xe1,0x3e,0x6b,0x20,0x8d,
0x01,0x04,0x2d,0x23,0x49,0x98,0x20,0x8d,
0x01,0x04,0x2d,0x2b,0x61,0x67,0x20,0x8d,
0x01,0x04,0x2d,0x3f,0x0a,0x34,0x4e,0x28,
0x01,0x04,0x2d,0x54,0x99,0x28,0x20,0x8d,
0x01,0x04,0x2d,0x5f,0x40,0xe1,0x20,0x8d,
0x01,0x04,0x2d,0x81,0xb4,0xd6,0x20,0x8d,
0x01,0x04,0x2d,0x9a,0xff,0xa2,0x20,0x8d,
0x01,0x04,0x2d,0xe2,0x50,0x66,0x20,0x8d,
0x01,0x04,0x2e,0x06,0x0a,0xe6,0x20,0x8d,
0x01,0x04,0x2e,0x17,0x57,0xda,0x20,0x8d,
0x01,0x04,0x2e,0x20,0x32,0x62,0x20,0x8d,
0x01,0x04,0x2e,0x2f,0x54,0x55,0x20,0x8d,
0x01,0x04,0x2e,0x30,0x7e,0x3a,0x20,0x8d,
0x01,0x04,0x2e,0x92,0xf8,0x59,0x20,0x8d,
0x01,0x04,0x2e,0xa5,0xdd,0xd1,0x24,0x75,
0x01,0x04,0x2e,0xa6,0x8e,0x02,0x20,0x8d,
0x01,0x04,0x2e,0xa6,0xa2,0x2d,0x4e,0x21,
0x01,0x04,0x2e,0xad,0x32,0x3a,0x20,0x8d,
0x01,0x04,0x2e,0xaf,0xb2,0x03,0x20,0x8d,
0x01,0x04,0x2e,0xbc,0x1e,0x76,0x20,0x8d,
0x01,0x04,0x2e,0xdb,0x78,0x3b,0x0e,0x59,
0x01,0x04,0x2e,0xe5,0xee,0xbb,0x20,0x8d,
0x01,0x04,0x2f,0x5d,0xe6,0xab,0x20,0x8d,
0x01,0x04,0x2f,0x64,0xa2,0xd2,0x47,0x9c,
0x01,0x04,0x2f,0x90,0x6a,0xf9,0x20,0x8d,
0x01,0x04,0x2f,0xbc,0x46,0xcd,0x20,0x8d,
0x01,0x04,0x2f,0xe3,0xe2,0xf2,0x20,0x8d,
0x01,0x04,0x32,0x02,0x0d,0xa4,0x20,0x8d,
0x01,0x04,0x32,0x05,0x2e,0xc3,0x20,0x8d,
0x01,0x04,0x32,0x2d,0x80,0x1c,0x20,0x8d,
0x01,0x04,0x33,0x94,0x99,0x3c,0x20,0x8d,
0x01,0x04,0x33,0x9a,0x3e,0x67,0x20,0x8d,
0x01,0x04,0x33,0x9a,0x83,0x12,0x20,0x8d,
0x01,0x04,0x33,0x9e,0x96,0x9b,0x20,0x8d,
0x01,0x04,0x33,0x9f,0x02,0xda,0x20,0x8d,
0x01,0x04,0x36,0xc6,0x13,0x22,0x20,0x8d,
0x01,0x04,0x3a,0x69,0xa8,0x29,0x20,0x8d,
0x01,0x04,0x3a,0x9e,0x00,0x56,0x20,0x8d,
0x01,0x04,0x3c,0xfb,0x81,0x3d,0x20,0x90,
0x01,0x04,0x3d,0xef,0x5b,0xfa,0x20,0x8d,
0x01,0x04,0x3e,0x1c,0xbe,0xc2,0x20,0x8d,
0x01,0x04,0x3e,0x98,0x3a,0x10,0x24,0xcd,
0x01,0x04,0x3e,0xab,0x81,0x20,0x20,0x8d,
0x01,0x04,0x3e,0xfb,0x36,0xa3,0x20,0x8d,
0x01,0x04,0x3f,0xf7,0x93,0xa6,0x20,0x8d,
0x01,0x04,0x40,0x21,0x44,0xb0,0x20,0x8d,
0x01,0x04,0x40,0x9c,0xc0,0x3d,0x20,0x8d,
0x01,0x04,0x40,0xbb,0xaf,0xe2,0x20,0x8d,
0x01,0x04,0x40,0xe9,0xf5,0x27,0x20,0x8d,
0x01,0x04,0x40,0xed,0x52,0x95,0x20,0x8d,
0x01,0x04,0x41,0x65,0xf7,0x1a,0x20,0x8d,
0x01,0x04,0x42,0x1d,0x81,0xda,0x20,0x8d,
0x01,0x04,0x42,0x31,0xcc,0x0b,0x20,0x8d,
0x01,0x04,0x42,0x3a,0xf3,0xd7,0x20,0x8d,
0x01,0x04,0x42,0x55,0xea,0x81,0x20,0x8d,
0x01,0x04,0x42,0x82,0x78,0x34,0x20,0x8d,
0x01,0x04,0x43,0x0a,0x79,0x91,0x20,0x8d,
0x01,0x04,0x43,0xd2,0xe4,0xcb,0x20,0x8d,
0x01,0x04,0x43,0xd5,0x57,0x15,0x20,0x8d,
0x01,0x04,0x44,0xb5,0x04,0x0c,0x20,0x8d,
0x01,0x04,0x45,0x07,0x7c,0x92,0x20,0x8d,
0x01,0x04,0x45,0x08,0xaf,0xc9,0x20,0x8d,
0x01,0x04,0x45,0x3b,0x12,0x16,0x20,0x8d,
0x01,0x04,0x45,0x77,0xc1,0x09,0x20,0x8d,
0x01,0x04,0x45,0x82,0xc9,0x1b,0x20,0x8d,
0x01,0x04,0x45,0x83,0x65,0xb0,0x20,0x8d,
0x01,0x04,0x46,0x0f,0xc2,0x20,0x20,0x8d,
0x01,0x04,0x46,0x40,0x1b,0x0c,0x20,0x8d,
0x01,0x04,0x48,0x1d,0xaa,0x97,0x20,0x8d,
0x01,0x04,0x48,0x4a,0x22,0x63,0x20,0x8d,
0x01,0x04,0x48,0x85,0xb1,0x77,0x20,0x8d,
0x01,0x04,0x49,0xa6,0x54,0xde,0x20,0x8d,
0x01,0x04,0x4a,0x43,0xf0,0xcc,0x20,0x8d,
0x01,0x04,0x4a,0x5b,0x73,0xe5,0x20,0x8d,
0x01,0x04,0x4a,0x76,0x89,0x77,0x20,0x8d,
0x01,0x04,0x4a,0xd5,0xfb,0xcb,0x20,0x8d,
0x01,0x04,0x4a,0xdc,0xff,0xbe,0x20,0x8d,
0x01,0x04,0x4c,0x0b,0x3c,0x9b,0x20,0x8d,
0x01,0x04,0x4c,0x42,0x90,0x7f,0x20,0x8d,
0x01,0x04,0x4d,0x46,0x10,0xf5,0x20,0x8d,
0x01,0x04,0x4d,0x55,0xcc,0x95,0x20,0x8d,
0x01,0x04,0x4d,0x69,0x57,0x61,0x20,0x8d,
0x01,0x04,0x4d,0x78,0x71,0x45,0x20,0xf1,
0x01,0x04,0x4d,0x78,0x71,0x47,0x20,0xf1,
0x01,0x04,0x4d,0x78,0x7a,0x74,0x20,0xf1,
0x01,0x04,0x4d,0x78,0x7a,0x76,0x20,0xf1,
0x01,0x04,0x4d,0xa2,0xbe,0x5a,0x20,0x8d,
0x01,0x04,0x4d,0xa7,0xf5,0xef,0xd8,0xf8,
0x01,0x04,0x4d,0xe8,0x29,0xbd,0x20,0x8d,
0x01,0x04,0x4e,0x14,0xe3,0xf9,0x20,0x8d,
0x01,0x04,0x4e,0x15,0xa7,0x08,0x20,0x8d,
0x01,0x04,0x4e,0x1b,0x8b,0x0d,0x20,0x8d,
0x01,0x04,0x4e,0x2b,0xd0,0x19,0x20,0x8d,
0x01,0x04,0x4e,0x3f,0x1c,0x92,0x20,0x8d,
0x01,0x04,0x4e,0x48,0xe4,0xef,0x20,0x8d,
0x01,0x04,0x4e,0x6c,0x66,0x08,0x20,0x8d,
0x01,0x04,0x4e,0x81,0x00,0x27,0x20,0x8d,
0x01,0x04,0x4e,0x81,0xa9,0x45,0x20,0x8d,
0x01,0x04,0x4f,0x4d,0xb6,0xb4,0x20,0x8d,
0x01,0x04,0x4f,0x4d,0xb6,0xb7,0x20,0x8d,
0x01,0x04,0x4f,0x6b,0xb2,0x3b,0x20,0x8d,
0x01,0x04,0x50,0x37,0xe1,0x9e,0x20,0x8d,
0x01,0x04,0x50,0x40,0xd3,0x66,0x20,0x8d,
0x01,0x04,0x50,0x40,0xd3,0x67,0x20,0x8d,
0x01,0x04,0x50,0x47,0x39,0x32,0x20,0x8d,
0x01,0x04,0x50,0x51,0x03,0x1b,0x20,0x8d,
0x01,0x04,0x50,0x52,0x37,0x2b,0x20,0x8d,
0x01,0x04,0x50,0x58,0xac,0xe3,0xfb,0x08,
0x01,0x04,0x50,0x59,0xcb,0xac,0x1f,0x41,
0x01,0x04,0x50,0x5d,0xd5,0xf6,0x20,0x8d,
0x01,0x04,0x50,0x93,0x52,0xa5,0x20,0x8d,
0x01,0x04,0x50,0xe5,0x1c,0x3c,0x20,0x8d,
0x01,0x04,0x50,0xf7,0xe9,0x28,0x20,0x8d,
0x01,0x04,0x50,0xff,0x08,0x5d,0x20,0x8d,
0x01,0x04,0x51,0x07,0x11,0xca,0x20,0x8d,
0x01,0x04,0x51,0x0a,0xf1,0xa5,0x20,0x8d,
0x01,0x04,0x51,0x15,0x56,0x9d,0x20,0x8d,
0x01,0x04,0x51,0xab,0x16,0x8f,0x20,0x8d,
0x01,0x04,0x51,0xed,0xce,0xe0,0x20,0x97,
0x01,0x04,0x52,0x45,0x17,0xc3,0x20,0x8d,
0x01,0x04,0x52,0x60,0x60,0x28,0x20,0x8d,
0x01,0x04,0x52,0x74,0x32,0x65,0x20,0x8d,
0x01,0x04,0x52,0x88,0x63,0x7a,0x20,0x8d,
0x01,0x04,0x52,0x95,0x61,0x19,0x44,0x9f,
0x01,0x04,0x52,0x9a,0x18,0xd1,0x20,0x8d,
0x01,0x04,0x52,0xa5,0xf1,0x32,0x20,0x8d,
0x01,0x04,0x52,0xc5,0xda,0xfd,0x20,0x8d,
0x01,0x04,0x52,0xca,0x44,0xe7,0x20,0x8d,
0x01,0x04,0x53,0x89,0x29,0x0a,0x20,0x8d,
0x01,0x04,0x53,0xd0,0x06,0xd3,0x20,0x8d,
0x01,0x04,0x53,0xd9,0x08,0x1f,0xad,0x84,
0x01,0x04,0x53,0xdc,0x6e,0x30,0x20,0x8d,
0x01,0x04,0x53,0xde,0x8a,0x55,0x20,0x8d,
0x01,0x04,0x53,0xf3,0xbf,0xc7,0x20,0x8d,
0x01,0x04,0x54,0x16,0x8b,0x39,0x20,0x8d,
0x01,0x04,0x54,0x1b,0x9b,0x11,0x20,0x8d,
0x01,0x04,0x54,0x4b,0x1c,0xf7,0x20,0x8d,
0x01,0x04,0x54,0x70,0x3c,0x10,0x20,0x8d,
0x01,0x04,0x54,0xd3,0x07,0x38,0x20,0x8d,
0x01,0x04,0x54,0xed,0x07,0xf9,0x20,0x8d,
0x01,0x04,0x55,0x17,0x33,0xb1,0x20,0x8d,
0x01,0x04,0x55,0x18,0x91,0xc6,0x20,0x8d,
0x01,0x04,0x55,0xb8,0x8a,0x6c,0x20,0x8d,
0x01,0x04,0x55,0xc2,0xee,0x86,0x20,0x8d,
0x01,0x04,0x55,0xc3,0x36,0x6e,0x20,0x8d,
0x01,0x04,0x55,0xd0,0x47,0x24,0x20,0x8d,
0x01,0x04,0x55,0xd0,0x47,0x27,0x20,0x8d,
0x01,0x04,0x55,0xd6,0x88,0x2d,0x20,0x8d,
0x01,0x04,0x55,0xd6,0xa1,0xfc,0x20,0x8d,
0x01,0x04,0x55,0xe3,0xf5,0x80,0x20,0x8d,
0x01,0x04,0x56,0x12,0x22,0xf3,0x20,0x8d,
0x01,0x04,0x56,0x14,0x32,0xaa,0x20,0x8d,
0x01,0x04,0x56,0x31,0x69,0x5a,0x20,0x8d,
0x01,0x04,0x56,0x4c,0x07,0x84,0x20,0x8d,
0x01,0x04,0x56,0x64,0x1a,0xbc,0x20,0x8d,
0x01,0x04,0x56,0x6a,0x8f,0x8f,0xd8,0x4d,
0x01,0x04,0x56,0x78,0x3a,0x42,0x20,0x8d,
0x01,0x04,0x56,0x85,0xfb,0xef,0x22,0xc5,
0x01,0x04,0x56,0x95,0x08,0x17,0x22,0xc5,
0x01,0x04,0x57,0x4e,0xc5,0xea,0x20,0x8d,
0x01,0x04,0x57,0x78,0x08,0x05,0x4e,0x28,
0x01,0x04,0x57,0x79,0x25,0x9c,0x20,0x8d,
0x01,0x04,0x58,0x52,0xb5,0x2c,0x20,0x8d,
0x01,0x04,0x58,0x57,0x5d,0x34,0x06,0x9b,
0x01,0x04,0x58,0x62,0xeb,0x86,0x20,0x8d,
0x01,0x04,0x58,0x88,0xbb,0xd6,0x20,0x8d,
0x01,0x04,0x58,0x93,0xf4,0xfa,0x20,0x8d,
0x01,0x04,0x58,0x94,0x99,0x94,0x20,0x8d,
0x01,0x04,0x58,0xd4,0x2d,0xa6,0x20,0x8d,
0x01,0x04,0x58,0xd4,0x37,0x8a,0x20,0x8d,
0x01,0x04,0x59,0x26,0x60,0x99,0x24,0x39,
0x01,0x04,0x59,0x2f,0xa1,0x87,0x20,0x8d,
0x01,0x04,0x59,0x58,0x3e,0xbe,0x20,0x8d,
0x01,0x04,0x59,0x9e,0x20,0x2c,0x20,0x8d,
0x01,0x04,0x59,0xa3,0x91,0xf0,0x20,0x8d,
0x01,0x04,0x59,0xa3,0xf9,0xea,0x0e,0x59,
0x01,0x04,0x59,0xb0,0xc4,0x50,0x20,0x8d,
0x01,0x04,0x59,0xd8,0x15,0x60,0x20,0x8d,
0x01,0x04,0x5a,0x54,0xe3,0xff,0x20,0x8d,
0x01,0x04,0x5a,0x92,0x82,0xd6,0x20,0x8d,
0x01,0x04,0x5a,0xfa,0x09,0x01,0x20,0x8d,
0x01,0x04,0x5b,0x5d,0xc2,0x9a,0x20,0x8d,
0x01,0x04,0x5b,0x6a,0xbc,0xe5,0x20,0x8d,
0x01,0x04,0x5b,0x7e,0x28,0x6d,0x20,0x8d,
0x01,0x04,0x5b,0x89,0x7f,0x7b,0x20,0x8d,
0x01,0x04,0x5b,0x93,0xe8,0x62,0x20,0x8d,
0x01,0x04,0x5b,0x98,0x7b,0x12,0x20,0x8d,
0x01,0x04,0x5b,0xb2,0x11,0x78,0x20,0x8d,
0x01,0x04,0x5b,0xcc,0x63,0xb2,0x20,0x8d,
0x01,0x04,0x5b,0xdf,0xaf,0x0e,0x20,0x8d,
0x01,0x04,0x5c,0x2a,0x6e,0xf2,0x20,0x8d,
0x01,0x04,0x5c,0x35,0x5a,0x54,0x20,0x8d,
0x01,0x04,0x5c,0xdd,0x9b,0xe4,0x20,0x8d,
0x01,0x04,0x5d,0x39,0x51,0xa2,0x20,0x8d,
0x01,0x04,0x5d,0x5f,0x58,0x0d,0x20,0x8d,
0x01,0x04,0x5d,0x67,0x0d,0x01,0x20,0x8d,
0x01,0x04,0x5d,0x7b,0xb4,0xa4,0x20,0x8d,
0x01,0x04,0x5d,0xbe,0x75,0x1a,0x20,0x8d,
0x01,0x04,0x5e,0x69,0x7d,0xf0,0x20,0x8d,
0x01,0x04,0x5e,0x6e,0x17,0xd7,0x20,0x8d,
0x01,0x04,0x5e,0x9a,0x9f,0x63,0x20,0x8d,
0x01,0x04,0x5e,0xbd,0xa1,0x77,0x20,0x8d,
0x01,0x04,0x5e,0xcb,0xff,0x46,0x20,0x8d,
0x01,0x04,0x5e,0xe8,0xad,0x5d,0x20,0x8d,
0x01,0x04,0x5f,0x4f,0x7a,0x63,0x20,0x8d,
0x01,0x04,0x5f,0x50,0x01,0x6e,0x20,0x8d,
0x01,0x04,0x5f,0x53,0x49,0x1f,0x20,0x8d,
0x01,0x04,0x5f,0x6e,0x85,0xdf,0x20,0x8d,
0x01,0x04,0x5f,0x6e,0xea,0x5d,0x20,0x8d,
0x01,0x04,0x5f,0xa4,0x41,0xc2,0x20,0x8d,
0x01,0x04,0x5f,0xa5,0x08,0xb6,0x20,0x8d,
0x01,0x04,0x5f,0xae,0xdb,0x65,0x20,0x8d,
0x01,0x04,0x5f,0xbf,0x82,0x64,0x20,0x8d,
0x01,0x04,0x5f,0xd6,0x35,0x9a,0x20,0x8d,
0x01,0x04,0x5f,0xd7,0xcd,0xb4,0x20,0x8d,
0x01,0x04,0x60,0x2b,0x82,0xea,0x20,0x8d,
0x01,0x04,0x62,0x19,0xc9,0x1f,0x20,0x8d,
0x01,0x04,0x62,0x80,0xf7,0xb6,0x20,0x8d,
0x01,0x04,0x62,0xab,0x15,0x81,0x20,0x8d,
0x01,0x04,0x63,0x93,0x87,0xa1,0x20,0x8d,
0x01,0x04,0x65,0x64,0xa3,0x76,0x20,0x87,
0x01,0x04,0x66,0x84,0xf5,0x10,0x20,0x8d,
0x01,0x04,0x66,0xb6,0xcc,0x60,0x20,0x8d,
0x01,0x04,0x66,0xb6,0xeb,0xf5,0x20,0x8d,
0x01,0x04,0x67,0x0e,0xf5,0xfa,0x20,0x8d,
0x01,0x04,0x67,0x2f,0xc0,0x0f,0x20,0x8d,
0x01,0x04,0x67,0x54,0x54,0xfa,0x20,0x8f,
0x01,0x04,0x67,0x63,0xa8,0x82,0x20,0x8d,
0x01,0x04,0x67,0x63,0xa8,0x8c,0x20,0x8d,
0x01,0x04,0x67,0xc6,0xc0,0x0e,0x4e,0x28,
0x01,0x04,0x67,0xe8,0x68,0xe3,0x20,0x8d,
0x01,0x04,0x68,0x8f,0x02,0xc3,0x20,0x8d,
0x01,0x04,0x68,0xac,0xeb,0xe3,0x20,0x8d,
0x01,0x04,0x68,0xee,0xdc,0xc7,0x20,0x8d,
0x01,0x04,0x6b,0x0b,0x73,0x44,0x20,0x8d,
0x01,0x04,0x6b,0xad,0xa6,0x2b,0x20,0x8d,
0x01,0x04,0x6c,0x04,0xd4,0x53,0x20,0x8d,
0x01,0x04,0x6d,0x88,0x49,0x61,0x20,0x8d,
0x01,0x04,0x6d,0xad,0x62,0x17,0x20,0x8d,
0x01,0x04,0x6d,0xbe,0x44,0x74,0x20,0x8d,
0x01,0x04,0x6d,0xeb,0xf6,0x3c,0x20,0x8d,
0x01,0x04,0x6d,0xf8,0xce,0x0d,0x20,0x8d,
0x01,0x04,0x6e,0x0c,0x40,0x60,0x20,0x8d,
0x01,0x04,0x6f,0x5a,0x8c,0x2e,0x20,0x8d,
0x01,0x04,0x6f,0x5a,0x9f,0xb8,0xc3,0x51,
0x01,0x04,0x71,0x6b,0xc9,0x83,0x20,0x8d,
0x01,0x04,0x73,0x2f,0x8d,0xfa,0x22,0xb5,
0x01,0x04,0x74,0x3a,0xab,0x43,0x20,0x8d,
0x01,0x04,0x74,0x57,0x39,0xda,0x20,0x8d,
0x01,0x04,0x74,0xca,0xa1,0x38,0x20,0x8d,
0x01,0x04,0x75,0x33,0x9f,0x82,0x20,0x8d,
0x01,0x04,0x76,0x67,0x7e,0x8c,0x6e,0xad,
0x01,0x04,0x79,0x2d,0xbe,0xd2,0x20,0x8d,
0x01,0x04,0x79,0x63,0xc1,0x19,0x20,0x8d,
0x01,0x04,0x7a,0x70,0x94,0x99,0x20,0x93,
0x01,0x04,0x7a,0x94,0x87,0xea,0x20,0x8d,
0x01,0x04,0x80,0x00,0xbe,0x1a,0x20,0x8d,
0x01,0x04,0x80,0x41,0xc2,0x88,0x20,0x8d,
0x01,0x04,0x81,0x7e,0xac,0x73,0x20,0x8d,
0x01,0x04,0x81,0xe2,0x7d,0x0a,0x20,0x8d,
0x01,0x04,0x83,0xbc,0x28,0xbf,0x20,0x8d,
0x01,0x04,0x86,0xc3,0xb9,0x34,0x20,0x8d,
0x01,0x04,0x87,0xb4,0x2c,0x3d,0x20,0x8d,
0x01,0x04,0x88,0x34,0x72,0x7b,0x20,0x8d,
0x01,0x04,0x88,0x38,0xaa,0x60,0x20,0x8d,
0x01,0x04,0x89,0x74,0xd5,0x8f,0x20,0x8d,
0x01,0x04,0x89,0xe2,0x22,0x2e,0x20,0x8d,
0x01,0x04,0x8a,0x2b,0xe9,0x39,0x20,0x8d,
0x01,0x04,0x8b,0x82,0x29,0x52,0x20,0x8d,
0x01,0x04,0x8c,0xbe,0x0c,0x81,0x20,0x8d,
0x01,0x04,0x8e,0x04,0x69,0x4d,0x20,0x8d,
0x01,0x04,0x8e,0x36,0xb5,0xda,0x20,0x8d,
0x01,0x04,0x8f,0xb1,0xe7,0xf7,0x20,0x8d,
0x01,0x04,0x8f,0xb2,0x40,0x0a,0x20,0x8d,
0x01,0x04,0x90,0x22,0xa1,0x41,0x47,0x9d,
0x01,0x04,0x92,0x04,0x7c,0x86,0x20,0x8d,
0x01,0x04,0x92,0x53,0x38,0x45,0x20,0x8d,
0x01,0x04,0x92,0x5a,0xc1,0x44,0x20,0x8d,
0x01,0x04,0x92,0xc4,0x37,0x9c,0x70,0xa1,
0x01,0x04,0x94,0x42,0x32,0x32,0x20,0x8f,
0x01,0x04,0x94,0xfb,0x01,0x14,0x20,0x97,
0x01,0x04,0x97,0x30,0x5f,0xd4,0x20,0x8d,
0x01,0x04,0x97,0xfc,0xc1,0xf5,0x20,0x8d,
0x01,0x04,0x98,0x2c,0x89,0x53,0x20,0x8d,
0x01,0x04,0x98,0x73,0xbf,0xc4,0x20,0x8d,
0x01,0x04,0x9a,0xdd,0x1f,0x56,0x20,0x8d,
0x01,0x04,0x9c,0x11,0x67,0x02,0x1f,0x98,
0x01,0x04,0x9d,0x8a,0x14,0x16,0x20,0x8d,
0x01,0x04,0x9e,0x3a,0xbc,0x25,0x20,0x8d,
0x01,0x04,0x9e,0x8c,0xd1,0x4f,0x20,0x8d,
0x01,0x04,0x9f,0x59,0xe6,0x80,0x20,0x8d,
0x01,0x04,0x9f,0xf6,0x19,0x34,0x20,0x8d,
0x01,0x04,0xa0,0x14,0x3b,0xfa,0x20,0xf1,
0x01,0x04,0xa2,0x00,0xea,0xbe,0x20,0x8d,
0x01,0x04,0xa2,0x3e,0x1a,0xda,0x20,0x8d,
0x01,0x04,0xa2,0xfa,0xbc,0xc2,0x20,0x8d,
0x01,0x04,0xa2,0xfb,0x46,0x52,0x20,0x8d,
0x01,0x04,0xa3,0x9e,0xce,0xff,0x20,0x8d,
0x01,0x04,0xa4,0x44,0x69,0x69,0x20,0x8d,
0x01,0x04,0xa5,0xe4,0xae,0x75,0x20,0x8d,
0x01,0x04,0xa6,0x3e,0x52,0x67,0x80,0x03,
0x01,0x04,0xa6,0x46,0x31,0x1a,0x20,0x8d,
0x01,0x04,0xa6,0x4e,0xf1,0x09,0x20,0x8d,
0x01,0x04,0xa6,0x4e,0xf1,0x19,0x20,0x8d,
0x01,0x04,0xa7,0x47,0x49,0xf4,0x20,0x8d,
0x01,0x04,0xa7,0xb3,0x93,0x9b,0x20,0x8d,
0x01,0x04,0xa8,0x5b,0xee,0x08,0x20,0x8d,
0x01,0x04,0xac,0x69,0x15,0xd8,0x20,0x8d,
0x01,0x04,0xac,0x75,0x69,0x5f,0x20,0x8d,
0x01,0x04,0xad,0x17,0x67,0x1e,0x1f,0x40,
0x01,0x04,0xad,0xcd,0x5c,0x97,0xd6,0x15,
0x01,0x04,0xad,0xcd,0x5c,0x9a,0xd6,0x15,
0x01,0x04,0xad,0xcd,0x5c,0x9d,0xd6,0x15,
0x01,0x04,0xad,0xd0,0x98,0xda,0x20,0x8d,
0x01,0x04,0xad,0xf1,0xe3,0xf3,0x20,0x8d,
0x01,0x04,0xae,0x03,0x04,0xe8,0x20,0x8d,
0x01,0x04,0xae,0x11,0x0b,0x16,0x20,0x8d,
0x01,0x04,0xae,0x58,0xf1,0xa7,0x20,0x8d,
0x01,0x04,0xae,0x72,0x66,0x29,0x20,0x8d,
0x01,0x04,0xae,0x72,0xfa,0x56,0x20,0x8d,
0x01,0x04,0xae,0x8e,0xbf,0x88,0x20,0x8d,
0x01,0x04,0xaf,0x27,0x48,0x57,0x20,0x8d,
0x01,0x04,0xb0,0x0c,0x10,0x87,0x20,0x8d,
0x01,0x04,0xb0,0x25,0x17,0x1e,0x20,0x8d,
0x01,0x04,0xb0,0x3e,0xb3,0xdd,0x20,0x8d,
0x01,0x04,0xb0,0x4a,0x88,0xed,0x20,0x8d,
0x01,0x04,0xb0,0x63,0x06,0xe2,0x20,0x8d,
0x01,0x04,0xb0,0xd4,0xb9,0x99,0x20,0x8d,
0x01,0x04,0xb1,0x51,0xec,0x75,0x20,0x8d,
0x01,0x04,0xb2,0x13,0x6a,0x1a,0x20,0x8d,
0x01,0x04,0xb2,0x15,0x76,0xb2,0x20,0x8d,
0x01,0x04,0xb2,0x21,0xe8,0x45,0x20,0x8d,
0x01,0x04,0xb2,0x4f,0x54,0x8b,0x20,0x8d,
0x01,0x04,0xb2,0x7c,0xa2,0xd1,0x20,0x8d,
0x01,0x04,0xb2,0x84,0x02,0xf6,0x20,0x8d,
0x01,0x04,0xb2,0x96,0x60,0x2e,0x20,0x8d,
0x01,0x04,0xb2,0xa2,0xd4,0x2c,0x20,0x8d,
0x01,0x04,0xb2,0xc1,0xe2,0x78,0x20,0x8d,
0x01,0x04,0xb2,0xec,0x89,0x3f,0x20,0x8d,
0x01,0x04,0xb4,0x96,0x2e,0xbb,0x20,0x8d,
0x01,0x04,0xb5,0xa4,0xd2,0xe4,0x21,0x52,
0x01,0x04,0xb7,0x6e,0xdc,0xd2,0x76,0x5d,
0x01,0x04,0xb8,0x5f,0x3a,0xa6,0x20,0x90,
0x01,0x04,0xb8,0xa4,0x93,0x52,0xa1,0x75,
0x01,0x04,0xb8,0xab,0xd0,0x6d,0x20,0x8d,
0x01,0x04,0xb9,0x11,0x8f,0xdc,0x20,0x8d,
0x01,0x04,0xb9,0x15,0xd9,0x31,0x20,0x8d,
0x01,0x04,0xb9,0x19,0x30,0xb8,0x20,0x8d,
0x01,0x04,0xb9,0x1c,0x60,0x10,0x20,0x8d,
0x01,0x04,0xb9,0x1f,0x88,0xf6,0x20,0x8d,
0x01,0x04,0xb9,0x40,0x74,0x0f,0x20,0x8d,
0x01,0x04,0xb9,0x44,0xf9,0x5b,0x20,0x8d,
0x01,0x04,0xb9,0x6c,0xf7,0xbe,0x20,0x8d,
0x01,0x04,0xb9,0x8d,0x3c,0x24,0x20,0x8d,
0x01,0x04,0xb9,0x94,0x03,0xe3,0x20,0x8d,
0x01,0x04,0xb9,0x94,0x91,0x4a,0x20,0x8d,
0x01,0x04,0xb9,0x9f,0x14,0x8f,0x20,0x8d,
0x01,0x04,0xb9,0xa7,0x71,0x3b,0x20,0x8d,
0x01,0x04,0xb9,0xb9,0x1a,0x8d,0x1f,0xaf,
0x01,0x04,0xb9,0xbd,0x84,0xb2,0xe1,0xb4,
0x01,0x04,0xb9,0xcc,0xc5,0x70,0x20,0x8d,
0x01,0x04,0xb9,0xd1,0x46,0x11,0x20,0x8d,
0x01,0x04,0xb9,0xdc,0x9c,0xc1,0x20,0x8d,
0x01,0x04,0xb9,0xee,0x81,0x71,0x20,0x8d,
0x01,0x04,0xb9,0xef,0xdd,0x05,0x20,0x8d,
0x01,0x04,0xb9,0xf4,0xd9,0x27,0x20,0x8d,
0x01,0x04,0xb9,0xfe,0x61,0xa4,0x20,0x8d,
0x01,0x04,0xba,0x21,0xa7,0x0b,0x20,0x8d,
0x01,0x04,0xbc,0x20,0x0e,0x1f,0x20,0x8e,
0x01,0x04,0xbc,0x2a,0x28,0xea,0x47,0x9d,
0x01,0x04,0xbc,0x86,0x08,0x24,0x20,0x8d,
0x01,0x04,0xbc,0x8a,0x58,0x0e,0x20,0x8d,
0x01,0x04,0xbc,0x9c,0x6e,0xef,0x20,0x8d,
0x01,0x04,0xbc,0xa5,0xf4,0x8f,0x20,0x8d,
0x01,0x04,0xbc,0xd5,0x44,0x26,0x20,0x8d,
0x01,0x04,0xbc,0xd6,0x81,0x41,0x4e,0x2c,
0x01,0x04,0xbc,0xf2,0x0f,0x4a,0x20,0x8d,
0x01,0x04,0xbc,0xf4,0x04,0x4e,0x20,0x8d,
0x01,0x04,0xbd,0x27,0x06,0x52,0x20,0x8d,
0x01,0x04,0xbd,0xcf,0x2e,0x20,0x20,0x8d,
0x01,0x04,0xbd,0xd4,0x79,0x4a,0x20,0x8d,
0x01,0x04,0xc0,0x03,0x0b,0x14,0x20,0x8d,
0x01,0x04,0xc0,0x41,0xaa,0x0f,0x20,0x8d,
0x01,0x04,0xc0,0x92,0x89,0x2c,0x20,0x8d,
0x01,0x04,0xc0,0xb6,0x9d,0x77,0x20,0x8d,
0x01,0x04,0xc0,0xbb,0x6d,0x8d,0x20,0x8d,
0x01,0x04,0xc0,0xe3,0x50,0x53,0x20,0x8d,
0x01,0x04,0xc1,0x0a,0xcb,0x17,0x20,0x8e,
0x01,0x04,0xc1,0x20,0x7f,0xa0,0xe4,0x6d,
0x01,0x04,0xc1,0x20,0x7f,0xa2,0xe4,0x6d,
0x01,0x04,0xc1,0x3a,0xc4,0xd4,0x20,0x8d,
0x01,0x04,0xc1,0x6a,0x1d,0x6a,0x20,0x8d,
0x01,0x04,0xc1,0x8a,0x9a,0x2b,0x20,0x8d,
0x01,0x04,0xc1,0xb2,0xaa,0xe8,0x20,0x8d,
0x01,0x04,0xc1,0xc4,0x25,0x3e,0x20,0x8d,
0x01,0x04,0xc1,0xde,0x82,0x0e,0x20,0x8d,
0x01,0x04,0xc1,0xea,0x32,0xe3,0x20,0x8d,
0x01,0x04,0xc2,0x0e,0xf6,0xcd,0x20,0x8d,
0x01,0x04,0xc2,0x87,0x87,0x45,0x20,0x8d,
0x01,0x04,0xc2,0x93,0x71,0xc9,0x20,0x8d,
0x01,0x04,0xc2,0xa5,0x1e,0x14,0x20,0x8d,
0x01,0x04,0xc2,0xdb,0x3e,0x17,0x20,0x8d,
0x01,0x04,0xc3,0x38,0x3f,0x04,0x20,0x8d,
0x01,0x04,0xc3,0x86,0xb7,0xbc,0x20,0x8d,
0x01,0x04,0xc3,0xd0,0x67,0x1e,0x20,0xfc,
0x01,0x04,0xc3,0xd0,0x67,0x1f,0x20,0xfc,
0x01,0x04,0xc6,0x01,0xe7,0x06,0x20,0x8d,
0x01,0x04,0xc6,0x0c,0x0e,0x88,0x20,0x8d,
0x01,0x04,0xc6,0x54,0xed,0x46,0x20,0x8d,
0x01,0x04,0xc6,0xb2,0x78,0x05,0x1f,0xb0,
0x01,0x04,0xc7,0x30,0x5c,0xb8,0x20,0x8d,
0x01,0x04,0xc7,0x44,0xc7,0x13,0x20,0x8d,
0x01,0x04,0xc7,0xb6,0xb8,0xcc,0x20,0x8d,
0x01,0x04,0xc7,0xbd,0xf2,0x8d,0x20,0x8d,
0x01,0x04,0xc7,0xf7,0x07,0xd0,0x20,0x8d,
0x01,0x04,0xc8,0x7a,0xb5,0x25,0x20,0x8d,
0x01,0x04,0xc9,0xbf,0x06,0x67,0x20,0x8d,
0x01,0x04,0xca,0x6b,0xdb,0x82,0x20,0x8d,
0x01,0x04,0xca,0x6c,0xd3,0x87,0x20,0x8d,
0x01,0x04,0xcb,0x5e,0x21,0x70,0x20,0x8d,
0x01,0x04,0xcb,0x82,0x30,0x75,0x22,0xb5,
0x01,0x04,0xcb,0x84,0x5e,0xc4,0x20,0x8d,
0x01,0x04,0xcb,0xa2,0x0d,0xb5,0x20,0x8c,
0x01,0x04,0xcc,0xbf,0xc9,0x2b,0x20,0x8d,
0x01,0x04,0xcc,0xe5,0x0a,0x5a,0x20,0x8d,
0x01,0x04,0xcd,0xb2,0x29,0x7c,0x20,0x8d,
0x01,0x04,0xce,0x37,0xb2,0x9d,0x20,0x8d,
0x01,0x04,0xce,0x7e,0xcb,0x08,0x20,0x8d,
0x01,0x04,0xce,0xae,0x73,0x60,0x20,0x8d,
0x01,0x04,0xce,0xdf,0x99,0x34,0x20,0x8d,
0x01,0x04,0xcf,0xbc,0x9f,0x19,0x20,0x8d,
0x01,0x04,0xcf,0xe5,0x2e,0x50,0x20,0x8d,
0x01,0x04,0xd1,0x3a,0x91,0x9d,0x20,0x8d,
0x01,0x04,0xd1,0x7e,0x51,0x93,0x20,0x8d,
0x01,0x04,0xd1,0x91,0x3f,0x96,0x20,0x8d,
0x01,0x04,0xd1,0xd1,0x0a,0x1e,0x20,0x8d,
0x01,0x04,0xd1,0xed,0x7f,0xe3,0x20,0x8d,
0x01,0x04,0xd4,0x63,0xe2,0x24,0x23,0x3c,
0x01,0x04,0xd4,0xb9,0x56,0x54,0x20,0x8d,
0x01,0x04,0xd4,0xe3,0xd3,0x57,0x20,0x8d,
0x01,0x04,0xd5,0x05,0x24,0x3a,0x20,0x8d,
0x01,0x04,0xd5,0x59,0xec,0xdb,0x20,0x8d,
0x01,0x04,0xd5,0x5d,0x91,0xb7,0x20,0x8d,
0x01,0x04,0xd5,0xd6,0x42,0xb6,0x20,0x8d,
0x01,0x04,0xd8,0x29,0xf9,0xb2,0x20,0x8d,
0x01,0x04,0xd8,0x92,0xfb,0x08,0x20,0x8d,
0x01,0x04,0xd8,0xf9,0x46,0x16,0x20,0x8d,
0x01,0x04,0xd9,0x0b,0xf0,0x04,0x20,0x8d,
0x01,0x04,0xd9,0x0f,0xb2,0x07,0x20,0x8d,
0x01,0x04,0xd9,0x18,0xe9,0x74,0x20,0x8d,
0x01,0x04,0xd9,0x40,0x94,0x62,0xc8,0xc9,
0x01,0x04,0xd9,0x71,0x79,0xa9,0x20,0x8d,
0x01,0x04,0xd9,0xaa,0x7c,0xaa,0x20,0x8d,
0x01,0x04,0xdc,0x84,0x87,0x36,0x20,0x8d,
0x01,0x04,0xdc,0xdd,0x3a,0x19,0x20,0x8d,
0x01,0x04,0xdc,0xe9,0xb2,0xc7,0x20,0x8d,
0x01,0x04,0xdd,0xdb,0x61,0x69,0x07,0xd1,
0x02,0x10,0x20,0x01,0x16,0x08,0x00,0x1b,0x00,0xf9,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x67,0x7b,
0x02,0x10,0x20,0x01,0x16,0x20,0x05,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x20,0x8d,
0x02,0x10,0x20,0x01,0x1b,0xc0,0x00,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x20,0x8d,
0x02,0x10,0x20,0x01,0x04,0x70,0x1f,0x0a,0x08,0x9a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x20,0x8d,
0x02,0x10,0x20,0x01,0x04,0x70,0xde,0x5a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xec,0x24,0x75,
0x02,0x10,0x20,0x01,0x4b,0x98,0x0d,0xc0,0x00,0x45,0x02,0x16,0x3e,0xff,0xfe,0xa2,0x95,0xcd,0x20,0x8d,
0x02,0x10,0x20,0x01,0x4d,0xd0,0x35,0x64,0x00,0x00,0xfd,0x76,0xc1,0xd3,0x18,0x54,0x5b,0xd9,0x20,0x8d,
0x02,0x10,0x20,0x01,0x4d,0xe8,0xb1,0xb2,0x00,0x01,0x00,0x00,0xde,0xad,0xbe,0xef,0x00,0x07,0x20,0x8d,
0x02,0x10,0x20,0x01,0x06,0x38,0xa0,0x00,0x41,0x40,0x00,0x00,0x00,0x00,0xff,0xff,0x01,0x91,0x20,0x8d,
0x02,0x10,0x20,0x01,0x06,0x48,0x28,0x00,0x01,0x31,0x4b,0x1f,0xf6,0xfc,0x20,0xf7,0xf9,0x9f,0x20,0x8d,
0x02,0x10,0x20,0x01,0x06,0x78,0x0c,0xc8,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x10,0x00,0x88,0x4e,0x28,
0x02,0x10,0x20,0x01,0x06,0x7c,0x26,0xb4,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x44,0x20,0x8d,
0x02,0x10,0x20,0x01,0x06,0x7c,0x2d,0xb8,0x00,0x13,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x92,0x20,0x8d,
0x02,0x10,0x20,0x01,0x07,0xc0,0x23,0x10,0x00,0x00,0xf8,0x16,0x3e,0xff,0xfe,0x6c,0x4f,0x58,0x20,0x8d,
0x02,0x10,0x20,0x01,0x08,0x18,0xea,0x1b,0x76,0x00,0xf0,0x53,0xaa,0xde,0xf4,0x7b,0xb7,0x01,0x20,0x8d,
0x02,0x10,0x20,0x01,0x08,0xf1,0x14,0x04,0x37,0x00,0x8e,0x49,0x71,0x5a,0x2e,0x09,0xb6,0x34,0x24,0xe4,
0x02,0x10,0x20,0x01,0x09,0x85,0x55,0xa0,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x20,0x8d,
0x02,0x10,0x20,0x01,0x09,0x99,0x02,0x70,0x2c,0x2c,0x0c,0x8b,0x3a,0x20,0x3f,0x2f,0x31,0x8f,0x20,0x8d,
0x02,0x10,0x20,0x01,0x0b,0x07,0x0a,0xc9,0x44,0x2b,0x79,0xd6,0xbb,0xbe,0xb3,0x7c,0xa7,0x83,0x20,0x8d,
0x02,0x10,0x20,0x02,0x2f,0x5b,0xa5,0xf9,0x00,0x00,0x00,0x00,0x00,0x00,0x2f,0x5b,0xa5,0xf9,0x22,0xb5,
0x02,0x10,0x20,0x02,0xb6,0xff,0x3d,0xca,0x00,0x00,0x00,0x00,0x00,0x00,0xb6,0xff,0x3d,0xca,0x6e,0xcc,
0x02,0x10,0x24,0x00,0x24,0x10,0xce,0xa2,0x0d,0x00,0x41,0xbc,0xc9,0xea,0x86,0x1b,0x51,0xee,0x20,0x8d,
0x02,0x10,0x24,0x00,0x3b,0x00,0x00,0x20,0x00,0x0c,0xba,0xcb,0x29,0xff,0xfe,0xab,0x88,0x86,0x20,0x8d,
0x02,0x10,0x24,0x01,0xd0,0x02,0x39,0x02,0x07,0x00,0xd7,0x2c,0x5e,0x22,0x4e,0x95,0x38,0x9d,0x20,0x8d,
0x02,0x10,0x24,0x03,0x62,0x00,0x88,0xa0,0xfb,0x17,0xf5,0xf2,0xd8,0xb5,0xb7,0xba,0xf4,0xd3,0x20,0x8d,
0x02,0x10,0x24,0x05,0x98,0x00,0xb9,0x10,0x5f,0x8e,0x18,0x30,0xf6,0x30,0x2c,0xc6,0x88,0xfb,0x20,0x8d,
0x02,0x10,0x24,0x05,0x98,0x00,0xb9,0x70,0xc6,0x4c,0x10,0x9f,0x74,0xe7,0xae,0x5f,0x87,0xc7,0x20,0x8d,
0x02,0x10,0x24,0x05,0xaa,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x20,0x8d,
0x02,0x10,0x24,0x07,0x88,0x00,0xbc,0x61,0x22,0x02,0xd6,0x3d,0x7e,0xff,0xfe,0x6c,0xdc,0x36,0x20,0x8d,
0x02,0x10,0x24,0x08,0x82,0x48,0x70,0x04,0xf8,0x31,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x3c,0x20,0x8d,
0x02,0x10,0x24,0x09,0x00,0x10,0xca,0x20,0x1d,0xf0,0x02,0x24,0xe8,0xff,0xfe,0x1f,0x60,0xd9,0x20,0x8d,
0x02,0x10,0x24,0x0b,0x00,0x11,0x43,0xa1,0xbd,0x00,0xe5,0x89,0xf8,0xa7,0x04,0x9b,0x3b,0x86,0x20,0x8d,
0x02,0x10,0x24,0x0d,0x00,0x1a,0x07,0x91,0x34,0x00,0xd6,0x5d,0x64,0xff,0xfe,0x28,0x92,0x7e,0x20,0x8d,
0x02,0x10,0x24,0x0d,0x00,0x1a,0x07,0x91,0x34,0x00,0xd6,0x81,0xd7,0xff,0xfe,0xf6,0xa2,0x1e,0x27,0x42,
0x02,0x10,0x26,0x00,0x17,0x00,0x5b,0x2b,0x00,0x5f,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x40,0x20,0x8d,
0x02,0x10,0x26,0x00,0x21,0x04,0x10,0x03,0xc5,0xab,0xdc,0x5e,0x90,0xff,0xfe,0x18,0x1d,0x08,0x20,0x8d,
0x02,0x10,0x26,0x00,0x3c,0x00,0xe0,0x02,0x2e,0x32,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x14,0x20,0x8d,
0x02,0x10,0x26,0x00,0x88,0x05,0x24,0x00,0x01,0x4e,0x12,0xdd,0xb1,0xff,0xfe,0xf2,0x30,0x13,0x20,0x8d,
0x02,0x10,0x26,0x02,0xff,0xb8,0x00,0x00,0x00,0x00,0x02,0x08,0x00,0x72,0x00,0x57,0x02,0x00,0x20,0x8d,
0x02,0x10,0x26,0x03,0x30,0x1f,0x1e,0xbf,0xe0,0x00,0xe2,0x3f,0x49,0xff,0xfe,0xe7,0x74,0x31,0x20,0x8d,
0x02,0x10,0x26,0x03,0x60,0x81,0x18,0x00,0x66,0x00,0x16,0xdd,0xa9,0xff,0xfe,0xee,0xb2,0xf3,0x20,0x8d,
0x02,0x10,0x26,0x04,0x13,0x80,0x10,0x00,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x20,0x8d,
0x02,0x10,0x26,0x04,0x45,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2e,0x06,0x1f,0xb0,
0x02,0x10,0x26,0x04,0x55,0x00,0xc1,0x34,0x40,0x00,0x72,0x85,0xc2,0xff,0xfe,0x4a,0xe1,0x43,0x80,0x1d,
0x02,0x10,0x26,0x04,0x55,0x00,0xc1,0x34,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xfc,0x80,0x1d,
0x02,0x10,0x26,0x04,0x7c,0x00,0x01,0x20,0x00,0x4b,0x00,0x00,0x00,0x00,0x00,0x00,0xeb,0x24,0x20,0x8d,
0x02,0x10,0x26,0x05,0x64,0x00,0x00,0x30,0xf2,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x8d,
0x02,0x10,0x26,0x05,0x6f,0x80,0x00,0x00,0x00,0x07,0xfc,0x1b,0xcc,0xff,0xfe,0x8a,0xd8,0x22,0x20,0x8d,
0x02,0x10,0x26,0x05,0xae,0x00,0x02,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x03,0x20,0x8d,
0x02,0x10,0x26,0x05,0xc0,0x00,0x2a,0x0a,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x20,0x8d,
0x02,0x10,0x26,0x05,0xf7,0x00,0x00,0xc0,0x08,0x27,0x02,0x25,0x90,0xff,0xfe,0xe3,0x34,0xa6,0x20,0x8d,
0x02,0x10,0x26,0x07,0x92,0x80,0x00,0x0b,0x07,0x3b,0x02,0x50,0x56,0xff,0xfe,0x14,0x25,0xb5,0x20,0x8d,
0x02,0x10,0x26,0x07,0xf2,0xf8,0xad,0x40,0x0b,0xc1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x20,0x8d,
0x02,0x10,0x26,0x07,0xfa,0x18,0x3a,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x8d,
0x02,0x10,0x26,0x20,0x01,0x1c,0x50,0x01,0x11,0x18,0xd2,0x67,0xe5,0xff,0xfe,0xe9,0xe6,0x73,0x20,0x8d,
0x02,0x10,0x26,0x20,0x01,0x1c,0x50,0x01,0x21,0x99,0xd2,0x67,0xe5,0xff,0xfe,0xe9,0xe6,0x73,0x20,0x8d,
0x02,0x10,0x26,0x20,0x00,0x06,0x20,0x03,0x01,0x05,0x02,0xd8,0x61,0xff,0xfe,0x0f,0x08,0x53,0x20,0x8d,
0x02,0x10,0x26,0x20,0x00,0x6e,0xa0,0x00,0x00,0x01,0x00,0x42,0x00,0x42,0x00,0x42,0x00,0x42,0x20,0x8d,
0x02,0x10,0x28,0x03,0xcf,0x00,0x0a,0xf8,0xf2,0x00,0xb8,0x9e,0xcf,0x34,0x92,0xc7,0x2d,0x26,0x20,0x8d,
0x02,0x10,0x28,0x04,0x01,0x4c,0x65,0xd1,0x40,0x2c,0xbc,0x53,0xbf,0x5d,0x06,0x8a,0x21,0x36,0x20,0x8d,
0x02,0x10,0x28,0x04,0x07,0xf1,0xe7,0x83,0xd4,0x01,0x66,0x1c,0x67,0xff,0xfe,0xba,0x55,0x47,0x20,0x8d,
0x02,0x10,0x28,0x04,0x0d,0x57,0x55,0x37,0x48,0x00,0x02,0x1e,0x67,0xff,0xfe,0xa8,0xd7,0x98,0x20,0x8d,
0x02,0x10,0x28,0x04,0x0d,0x57,0x55,0x37,0x48,0x00,0x36,0x15,0x9e,0xff,0xfe,0x23,0xd6,0x10,0x20,0x8d,
0x02,0x10,0x28,0x06,0x02,0xf0,0x20,0x80,0x06,0x2a,0x08,0x6f,0x1a,0x01,0xc4,0x4f,0x17,0x94,0x20,0x8d,
0x02,0x10,0x2a,0x00,0x10,0x28,0x83,0x82,0xbf,0x22,0x5f,0x7f,0xb7,0x8f,0x27,0x37,0x77,0x39,0x20,0x8d,
0x02,0x10,0x2a,0x00,0x12,0xe0,0x01,0x01,0x00,0x99,0x02,0x0c,0x29,0xff,0xfe,0x29,0xd0,0x3f,0x20,0x8d,
0x02,0x10,0x2a,0x00,0x13,0x28,0xe1,0x01,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x63,0x20,0x8d,
0x02,0x10,0x2a,0x00,0x16,0x30,0x00,0x10,0x10,0x03,0x00,0x00,0x0b,0x19,0xb0,0x0b,0xba,0xbe,0x20,0x8d,
0x02,0x10,0x2a,0x00,0x17,0x68,0x20,0x01,0x00,0x27,0x00,0x00,0x00,0x00,0x00,0x00,0xef,0x6a,0x20,0x8d,
0x02,0x10,0x2a,0x00,0x18,0x28,0xa0,0x04,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x66,0x20,0x8d,
0x02,0x10,0x2a,0x00,0x18,0x38,0x00,0x2a,0x14,0x00,0x92,0xe2,0xba,0xff,0xfe,0x4a,0xc4,0x16,0x20,0x8d,
0x02,0x10,0x2a,0x00,0x1c,0x10,0x00,0x02,0x07,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x17,0x56,0xcc,
0x02,0x10,0x2a,0x00,0x1f,0x40,0x50,0x01,0x01,0x08,0x5d,0x17,0x77,0x03,0xb0,0xf5,0x41,0x33,0x20,0x8d,
0x02,0x10,0x2a,0x00,0x60,0x20,0x15,0xdd,0xee,0x00,0xc8,0xc2,0x2c,0x77,0x17,0x49,0x35,0xdb,0x20,0x8d,
0x02,0x10,0x2a,0x00,0x60,0x20,0xb4,0x82,0x92,0x00,0x49,0x1a,0x35,0x8c,0xd8,0xf7,0x01,0xda,0x20,0x8d,
0x02,0x10,0x2a,0x00,0x71,0x45,0x00,0xc1,0x00,0x01,0xae,0x29,0x07,0x27,0x2b,0x87,0x0f,0x64,0x14,0x15,
0x02,0x10,0x2a,0x00,0x8a,0x60,0xe0,0x12,0x0a,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x21,0x20,0x8d,
0x02,0x10,0x2a,0x00,0xa0,0x40,0x01,0x00,0x00,0xf3,0x45,0xa5,0x0a,0xc0,0xfe,0xa3,0x71,0xe1,0x20,0x8d,
0x02,0x10,0x2a,0x01,0x04,0x88,0x20,0x00,0x98,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0d,0x20,0x8d,
0x02,0x10,0x2a,0x01,0x04,0x90,0x00,0x16,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x20,0x8d,
0x02,0x10,0x2a,0x01,0x52,0x00,0x00,0x6c,0x61,0x62,0x7a,0x61,0x74,0x6b,0x6f,0x2e,0x73,0x6b,0x20,0x8d,
0x02,0x10,0x2a,0x01,0x63,0x80,0xff,0xfe,0x00,0x73,0x04,0xe3,0xb3,0xcc,0xa8,0x71,0x36,0xd1,0x20,0x8d,
0x02,0x10,0x2a,0x01,0x07,0xa0,0x00,0x02,0x13,0x7c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x20,0x8d,
0x02,0x10,0x2a,0x01,0x07,0xc8,0xaa,0xc9,0x00,0xc9,0x50,0x54,0x00,0xff,0xfe,0xdf,0xff,0x95,0x20,0x8d,
0x02,0x10,0x2a,0x01,0x07,0xc8,0xd0,0x01,0x01,0xc1,0x50,0x54,0x00,0xff,0xfe,0xee,0x3e,0x1a,0x20,0x8d,
0x02,0x10,0x2a,0x01,0x87,0x40,0x00,0x01,0xff,0xc5,0x00,0x00,0x00,0x00,0x00,0x00,0x8c,0x6a,0x20,0x8d,
0x02,0x10,0x2a,0x01,0xcb,0x00,0x0d,0x3d,0x77,0x00,0x02,0x27,0x0e,0xff,0xfe,0x28,0xc5,0x65,0x20,0x8d,
0x02,0x10,0x2a,0x01,0x00,0xd0,0x00,0x00,0x00,0x1c,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x53,0x20,0x8d,
0x02,0x10,0x2a,0x01,0x00,0xd0,0xbe,0xf2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x20,0x8d,
0x02,0x10,0x2a,0x01,0x0e,0x0a,0x09,0xfb,0xb0,0xe0,0x54,0xf8,0x19,0x01,0x6e,0x83,0x62,0xc1,0x20,0x8d,
0x02,0x10,0x2a,0x01,0x0e,0x0a,0x0a,0xa7,0xc8,0xc0,0x96,0x79,0xaf,0xfa,0xb6,0xe5,0xef,0xc7,0x20,0x8d,
0x02,0x10,0x2a,0x02,0x13,0xb8,0xf0,0x00,0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x20,0x8d,
0x02,0x10,0x2a,0x02,0x01,0x68,0x63,0x28,0x00,0x00,0x02,0xa8,0x2c,0xff,0xfe,0x68,0xe3,0x2c,0x20,0x8d,
0x02,0x10,0x2a,0x02,0x27,0x80,0x90,0x00,0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x20,0x8d,
0x02,0x10,0x2a,0x02,0x2e,0x02,0x39,0x00,0x54,0x00,0xa0,0x99,0xe1,0xff,0xfe,0xb6,0x0d,0x0e,0x20,0x8d,
0x02,0x10,0x2a,0x02,0x03,0x90,0x90,0x00,0x00,0x00,0xaa,0xa1,0x59,0xff,0xfe,0x43,0xb5,0x7b,0x20,0x8d,
0x02,0x10,0x2a,0x02,0x00,0x58,0x00,0x97,0x7d,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x20,0x8d,
0x02,0x10,0x2a,0x02,0x6d,0x40,0x30,0x5e,0x06,0x01,0xde,0xa6,0x32,0xff,0xfe,0x44,0x4b,0x25,0x20,0x8d,
0x02,0x10,0x2a,0x02,0x7a,0x01,0x00,0x00,0x00,0x00,0x00,0x91,0x02,0x28,0x00,0x45,0x01,0x30,0x20,0x8d,
0x02,0x10,0x2a,0x02,0x7a,0xa0,0x16,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0xdc,0x8d,0xe0,0x20,0x8d,
0x02,0x10,0x2a,0x02,0x7b,0x40,0x3e,0x4d,0x99,0x8d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x20,0x8d,
0x02,0x10,0x2a,0x02,0x7b,0x40,0x59,0x2f,0xa1,0x87,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x20,0x8d,
0x02,0x10,0x2a,0x02,0x83,0x88,0xe5,0xc6,0xd3,0x80,0x02,0x01,0x2e,0xff,0xfe,0x82,0xb3,0xcc,0x20,0x8d,
0x02,0x10,0x2a,0x02,0x09,0xa0,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x10,0x20,0x8d,
0x02,0x10,0x2a,0x02,0xa3,0x11,0x81,0x43,0x8c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x20,0xa1,
0x02,0x10,0x2a,0x02,0x0a,0xf8,0xfa,0xb0,0x08,0x08,0x00,0x85,0x02,0x34,0x01,0x45,0x01,0x32,0x20,0x8d,
0x02,0x10,0x2a,0x02,0x0e,0x00,0xff,0xf0,0x05,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x20,0xfc,
0x02,0x10,0x2a,0x02,0x0e,0x00,0xff,0xf0,0x05,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x20,0xfc,
0x02,0x10,0x2a,0x02,0x0e,0x98,0x00,0x20,0x15,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x20,0x8d,
0x02,0x10,0x2a,0x03,0x40,0x00,0x00,0x47,0x00,0xf1,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x20,0x8d,
0x02,0x10,0x2a,0x03,0x60,0x00,0x08,0x70,0x00,0x00,0x00,0x46,0x00,0x23,0x00,0x87,0x02,0x18,0x20,0x8d,
0x02,0x10,0x2a,0x03,0x73,0x80,0x30,0x15,0x05,0x24,0xaf,0xc5,0xd3,0xbc,0x7c,0x66,0x8f,0x94,0x20,0x8d,
0x02,0x10,0x2a,0x03,0x0e,0xc0,0x00,0x00,0x09,0x28,0x8c,0x00,0x93,0xff,0xfe,0x84,0xa0,0x07,0x20,0x8d,
0x02,0x10,0x2a,0x03,0x0e,0xc0,0x00,0x00,0x09,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x01,0x20,0x8d,
0x02,0x10,0x2a,0x04,0x21,0x80,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xaa,0x20,0x8d,
0x02,0x10,0x2a,0x04,0x52,0xc0,0x01,0x01,0x02,0x9e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x8d,
0x02,0x10,0x2a,0x04,0x52,0xc0,0x01,0x03,0xc4,0x55,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x20,0x8d,
0x02,0x10,0x2a,0x04,0xbc,0x40,0x1d,0xc3,0x00,0x8d,0x00,0x00,0x00,0x00,0x00,0x02,0x10,0x01,0x20,0x8d,
0x02,0x10,0x2a,0x05,0x15,0x00,0x07,0x02,0x00,0x00,0x1c,0x00,0x40,0xff,0xfe,0x00,0x00,0x0c,0x20,0x8d,
0x02,0x10,0x2a,0x06,0xdd,0x00,0x00,0x10,0x00,0x03,0x02,0x25,0x90,0xff,0xfe,0x32,0x64,0xcc,0x20,0x8d,
0x02,0x10,0x2a,0x06,0xdd,0x00,0x00,0x01,0x00,0x22,0x02,0x25,0x90,0xff,0xfe,0x0e,0xbd,0x48,0x20,0x8d,
0x02,0x10,0x2a,0x07,0x6b,0x47,0x01,0x00,0x04,0x64,0x00,0x00,0x00,0x00,0x93,0x57,0xff,0xda,0x20,0x8d,
0x02,0x10,0x2a,0x07,0xa8,0x80,0x46,0x01,0x10,0x62,0xb4,0xb4,0xbd,0x2a,0x39,0xd4,0x7a,0xcf,0xc8,0xc9,
0x02,0x10,0x2a,0x07,0xab,0xc4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x09,0x46,0x20,0x8d,
0x02,0x10,0x2a,0x07,0xab,0xc4,0x00,0x00,0x00,0x00,0x00,0x89,0x02,0x34,0x01,0x80,0x01,0x94,0x20,0x8d,
0x02,0x10,0x2a,0x09,0x26,0x81,0x01,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x10,0x20,0x8d,
0x02,0x10,0x2a,0x0a,0xc8,0x01,0x00,0x01,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x83,0x20,0x8d,
0x02,0x10,0x2a,0x0b,0xf3,0x00,0x00,0x02,0x00,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x20,0x8d,
0x02,0x10,0x2a,0x0c,0x59,0xc0,0x00,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xa2,0x0e,0xe1,0x3a,
0x02,0x10,0x2a,0x0d,0x56,0x00,0x00,0x24,0x0a,0x8e,0x00,0x00,0x00,0x00,0x00,0x00,0xa9,0x1e,0xd8,0x4d,
0x02,0x10,0x2a,0x0d,0xeb,0x00,0x80,0x05,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x13,0x20,0x8d,
0x02,0x10,0x2a,0x10,0x47,0x40,0x00,0x45,0x00,0x01,0xa0,0x13,0xd1,0xff,0xfe,0x85,0x36,0xe3,0x20,0x8d,
0x02,0x10,0x2a,0x10,0x8b,0x40,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x20,0x8f,
0x02,0x10,0x2c,0x0f,0xf8,0xf0,0xda,0x51,0x00,0x00,0x70,0xc3,0xee,0xa9,0x97,0x17,0x95,0x79,0x20,0x8d,
0x04,0x20,0xd1,0xbb,0x02,0x8d,0x4d,0xd5,0x6a,0x20,0xc0,0xf9,0x16,0x2b,0x84,0x22,0x66,0xe0,0x89,0x45,0x60,0x37,0x52,0xe2,0x0b,0xa5,0xb4,0xf8,0x26,0xb3,0x8f,0x5a,0x30,0xed,0x20,0x8d,
0x04,0x20,0xd2,0x59,0x3b,0xd7,0x14,0x7e,0xd0,0x98,0xfe,0x9e,0xa5,0x69,0xf4,0x26,0x6d,0x72,0x6f,0xc3,0x76,0xce,0x1d,0x40,0x41,0xa2,0xa1,0xaf,0xf9,0x6e,0x57,0x2d,0x9d,0xc3,0x20,0x8d,
0x04,0x20,0xdf,0xd9,0xed,0x59,0xbf,0x1e,0x77,0x48,0x3c,0x13,0x3b,0xc5,0xc8,0x15,0x86,0x88,0x68,0xf0,0x08,0xe9,0xee,0x9b,0x3d,0xa4,0x33,0x0a,0x68,0x67,0x86,0x9d,0xe2,0x83,0x20,0x8d,
0x04,0x20,0xe9,0xbf,0xa7,0xbd,0x9b,0x54,0x54,0xe8,0xc8,0xae,0x78,0x99,0xa0,0xa3,0xf6,0x5d,0x78,0xe3,0x9e,0x5c,0xa7,0x18,0xb9,0x13,0x0c,0x04,0x9b,0xf3,0x7f,0x27,0x18,0xb0,0x20,0x8d,
0x04,0x20,0xf8,0x8d,0x64,0xd2,0xc8,0xe9,0x0f,0x51,0x03,0x1c,0x98,0x33,0x8f,0xe0,0x1e,0xe7,0xb6,0x16,0x8d,0x2a,0xf5,0xf3,0x19,0xce,0xdd,0x9e,0xee,0x17,0xc3,0x8f,0xd6,0xa1,0x20,0x8d,
0x04,0x20,0xfb,0xf1,0x17,0xd6,0x03,0x3b,0x01,0x8b,0x98,0xcf,0x16,0x20,0xde,0xaf,0x6c,0xed,0x60,0xab,0x6e,0x14,0x0b,0x58,0x6b,0x2d,0xf8,0x06,0x98,0x37,0x7a,0xff,0x7a,0x0f,0x20,0x8d,
0x04,0x20,0x0f,0xb9,0x71,0x05,0x64,0x83,0x2c,0x68,0x6a,0x9c,0xf0,0x4f,0xc3,0x90,0xcd,0x5c,0x73,0x9a,0xdd,0xb3,0xc6,0x42,0xca,0x09,0xbb,0xcc,0xfe,0x29,0x49,0x9f,0xc7,0x28,0x20,0x8d,
0x04,0x20,0x22,0x6e,0x42,0xe4,0xbd,0x2b,0xe5,0x3e,0x30,0xda,0x8a,0x03,0xf3,0x45,0x52,0xac,0x84,0xbf,0xbf,0xc5,0xaa,0x5f,0xe0,0x1b,0x26,0x28,0xb5,0x83,0x2e,0xed,0x4c,0xee,0x20,0x8d,
0x04,0x20,0x2a,0x47,0x8b,0xa0,0x4f,0x67,0x1d,0xcd,0x5d,0x84,0x1a,0xec,0xbd,0xd2,0xaa,0xe9,0x99,0x01,0x96,0x5d,0x4e,0xff,0x64,0x47,0xba,0xde,0xbf,0x56,0x89,0x39,0xac,0xde,0x20,0x8d,
0x04,0x20,0x2b,0xf3,0xe8,0xf5,0xef,0x90,0x14,0xab,0x61,0xe9,0x11,0x97,0x9f,0x18,0x4d,0xb4,0xff,0x89,0x94,0xf7,0x92,0x94,0x53,0xe6,0x9e,0xd4,0xdb,0x85,0x89,0x4d,0x3e,0xc9,0x20,0x8d,
0x04,0x20,0x2e,0x4e,0xde,0x51,0xd7,0x28,0x4b,0x29,0x7c,0xff,0x1f,0x8a,0x50,0xb7,0x5e,0xf0,0x81,0xcd,0xe8,0x8a,0x08,0x73,0x58,0x4e,0x43,0x1f,0x7b,0x85,0x9a,0xed,0xe2,0x68,0x20,0x8d,
0x04,0x20,0x35,0xdd,0xd0,0x36,0xa5,0x69,0x4a,0xd2,0xcc,0xb8,0xe9,0x62,0xa3,0x55,0xeb,0x86,0xe2,0xf3,0x03,0x48,0x26,0xe6,0x20,0xad,0xda,0xaa,0xff,0xde,0x16,0xad,0x39,0x9d,0x20,0x8d,
0x04,0x20,0x41,0x47,0x4e,0xc2,0xa1,0x71,0x63,0x3e,0x11,0x54,0x46,0x91,0x80,0xed,0x41,0x16,0x32,0x29,0x19,0x60,0xc9,0xef,0xa3,0xb7,0x96,0x2c,0x94,0xa8,0xdf,0x55,0xd7,0x21,0x20,0x8d,
0x04,0x20,0x44,0xf3,0xb7,0x5e,0x48,0x3c,0xbd,0xa6,0x52,0xaa,0x68,0xb5,0xbf,0xdc,0x01,0x5f,0x4b,0xeb,0x7a,0x25,0xcb,0x4a,0x70,0xbc,0x18,0x8c,0x97,0x5d,0x27,0x54,0x09,0x17,0x20,0x8d,
0x04,0x20,0x5c,0x52,0x7f,0x17,0x16,0x4c,0x27,0x36,0x2d,0x05,0xa1,0x19,0x0d,0xbe,0x87,0xab,0x24,0x7b,0xe7,0x38,0x3b,0xa1,0x7f,0xd1,0xd4,0x28,0x16,0x8e,0xfc,0x98,0x7d,0x08,0x20,0x8d,
0x04,0x20,0x67,0xc4,0x17,0xa5,0xcb,0x77,0xbd,0xaa,0x11,0x7f,0x8b,0xc0,0x81,0xf3,0xc0,0x96,0x9d,0x31,0x27,0x9c,0xad,0x6c,0x6d,0x98,0x42,0x70,0xdb,0x50,0x12,0x96,0x0b,0x36,0x20,0x8d,
0x04,0x20,0x73,0xdb,0x82,0xe0,0x88,0x40,0x49,0xd8,0x3b,0xa0,0xdd,0x83,0x7c,0x84,0x3c,0xb8,0xd0,0x03,0x0b,0x7a,0x08,0x44,0x4e,0x79,0xd6,0x61,0x23,0x31,0xa9,0xb3,0x07,0x58,0x20,0x8d,
0x04,0x20,0x75,0x93,0x21,0xdd,0x99,0x58,0x3c,0x3f,0xae,0x36,0x50,0x58,0x49,0xe2,0xd0,0xc3,0x3a,0x2c,0x4a,0xcf,0x41,0xc4,0x82,0x48,0xab,0xec,0x07,0x5d,0x56,0x2c,0xb4,0x8d,0x20,0x8d,
0x04,0x20,0x87,0xd4,0x66,0x0f,0xed,0xf9,0xf5,0xf1,0xcb,0x85,0x37,0xec,0xe1,0x19,0xa8,0xa4,0x03,0xb7,0x13,0x59,0xbb,0xf8,0xd2,0x93,0x92,0x50,0xfa,0x30,0x7a,0xd8,0x43,0xd0,0x20,0x8d,
0x04,0x20,0x8b,0xfe,0xad,0x19,0xdb,0x97,0x57,0x84,0xec,0xad,0x4f,0xb2,0xdf,0x69,0x53,0x04,0x57,0x19,0x16,0x7a,0x71,0xd7,0x2b,0xab,0x03,0xfd,0x76,0x4d,0xa0,0x70,0xc3,0xe7,0x20,0x8d,
0x04,0x20,0x96,0x25,0xde,0x4a,0xbc,0xbd,0x76,0x76,0xee,0x43,0x45,0x76,0xe0,0x0d,0x99,0x83,0xcd,0x83,0x8f,0x94,0xe5,0xde,0x7a,0xf2,0xf0,0x57,0xb8,0x25,0x54,0x17,0xcb,0x3b,0x20,0x8d,
0x04,0x20,0x98,0xc6,0x44,0x27,0x90,0x41,0xa6,0x98,0xf9,0x25,0x6c,0x59,0x0f,0x06,0x6d,0x44,0x59,0x0e,0xb2,0x46,0xb0,0xa4,0x37,0x88,0x69,0x8f,0xc1,0x32,0xcd,0x9f,0x15,0xd7,0x20,0x8d,
0x04,0x20,0xaa,0x3a,0x16,0x86,0xea,0x59,0x09,0x04,0x78,0xe5,0x10,0x92,0xe1,0x1d,0xad,0xf7,0x56,0x2b,0xac,0xb0,0x97,0x29,0x63,0x30,0xf4,0x1b,0xcf,0xde,0xf3,0x28,0x0a,0x29,0x20,0x8d,
0x04,0x20,0xbc,0x27,0xae,0x89,0xc1,0x67,0x73,0x0a,0x08,0x02,0xdf,0xb7,0xcc,0x94,0xc7,0x9f,0xf4,0x72,0x7a,0x9b,0x20,0x0c,0x5c,0x11,0x3d,0x22,0xd6,0x13,0x88,0x66,0x74,0xbf,0x20,0x8d,
0x05,0x20,0x07,0x61,0x26,0xd7,0x6c,0x05,0xbf,0xf6,0x2d,0x8c,0xca,0xc4,0x65,0xd3,0xd3,0xb2,0x49,0xe9,0xcc,0x53,0x1e,0xca,0x77,0x84,0xb6,0x10,0x5e,0xc2,0x5a,0xfe,0x28,0xb3,0x00,0x00,
0x05,0x20,0x0a,0x26,0x27,0x45,0xb1,0x1e,0xfc,0x27,0x03,0x32,0x0e,0x65,0x9e,0x3c,0x64,0x0e,0x33,0x50,0x3d,0x6c,0x90,0x17,0x0e,0x29,0xee,0x5a,0x58,0xdf,0x08,0xde,0xbf,0x73,0x00,0x00,
0x05,0x20,0x17,0x0c,0x56,0xce,0x72,0xa5,0xa0,0xe6,0x23,0x06,0xa3,0xc7,0x08,0x43,0x18,0xee,0x3a,0x46,0x35,0x5d,0x17,0xf6,0x78,0x96,0xa0,0x9c,0x51,0xef,0xbe,0x23,0xfd,0x71,0x00,0x00,
0x05,0x20,0x19,0xe7,0x0d,0x3f,0xfe,0x9e,0x0e,0x8e,0x73,0x40,0x40,0xc3,0xba,0x8f,0x41,0xaf,0xf1,0x7b,0xa6,0x83,0x1b,0xc3,0xa4,0xe0,0x6d,0x6c,0x57,0xa7,0x36,0x5d,0x09,0xce,0x00,0x00,
0x05,0x20,0x3e,0xe3,0xe0,0xa9,0xbc,0xf4,0x2e,0x59,0xd9,0x20,0xee,0xdf,0x74,0x61,0x4d,0x99,0x0c,0x5c,0x15,0x30,0x9b,0x72,0x16,0x79,0x15,0xf4,0x7a,0xca,0x34,0xcc,0x81,0x99,0x00,0x00,
0x05,0x20,0x3b,0x42,0x1c,0x25,0xf7,0xbf,0x79,0xed,0x6d,0x7d,0xef,0x65,0x30,0x7d,0xee,0x16,0x37,0x22,0x72,0x43,0x33,0x28,0x40,0xa3,0xaa,0xf4,0x48,0x49,0x67,0xb1,0x4b,0xfd,0x00,0x00,
0x05,0x20,0x4e,0x77,0x2e,0x12,0x91,0x67,0x6b,0x94,0xc4,0x92,0x2f,0x19,0x67,0x7d,0xcd,0x47,0x02,0xad,0xf8,0x60,0x72,0xed,0x73,0xf1,0x10,0x99,0x2c,0x05,0x61,0x66,0x55,0xd9,0x00,0x00,
0x05,0x20,0x53,0x94,0xa6,0x3e,0x14,0x82,0xd4,0xf9,0xd3,0xa7,0x53,0x33,0x05,0xce,0x72,0x64,0xed,0x74,0x09,0x63,0x8f,0x24,0xef,0xda,0x12,0xa1,0x55,0xe0,0xd8,0xbb,0xd3,0x58,0x00,0x00,
0x05,0x20,0x91,0x06,0xd1,0x9e,0xbd,0xab,0xc4,0x61,0xb3,0x0a,0xc2,0x3b,0x29,0xf3,0x10,0x38,0xee,0xbd,0x9d,0xe3,0x99,0x97,0x30,0x70,0x6e,0xe6,0xfb,0x6a,0x3c,0x07,0x3d,0xfd,0x00,0x00,
0x05,0x20,0xb5,0x83,0x6f,0xb6,0x11,0xd8,0x0e,0xa8,0x57,0xda,0x15,0x20,0x5b,0x1a,0x6d,0x21,0x15,0x5a,0xbd,0xb4,0x17,0x11,0xc2,0xfb,0x0e,0xfc,0xde,0xe8,0x26,0x56,0xa8,0xac,0x00,0x00,
0x05,0x20,0xcc,0xaf,0x6c,0x3b,0xd0,0x13,0x76,0x23,0xc3,0x36,0xbb,0x64,0x4a,0x4a,0x06,0x93,0x69,0x6d,0xb0,0x10,0x6e,0x66,0xa4,0x61,0xf8,0x2d,0xe7,0x80,0x72,0x4d,0x53,0x94,0x00,0x00,
0x06,0x10,0xfc,0x32,0x17,0xea,0xe4,0x15,0xc3,0xbf,0x98,0x08,0x14,0x9d,0xb5,0xa2,0xc9,0xaa,0x20,0x8d,
0x06,0x10,0xfc,0xc7,0xbe,0x49,0xcc,0xd1,0xdc,0x91,0x31,0x25,0xf0,0xda,0x45,0x7d,0x08,0xce,0x20,0x8d,
};
static const uint8_t chainparams_seed_test[] = {
0x04,0x20,0xdf,0x55,0xaa,0x83,0xd5,0xc5,0xb8,0xe7,0x75,0x78,0xd4,0x29,0x51,0x4b,0x26,0x1c,0x23,0xdf,0x28,0x4d,0x29,0x85,0x07,0xb5,0xe2,0x29,0x69,0x3e,0x25,0xbb,0x61,0xcf,0x47,0x9d,
0x04,0x20,0x0a,0xdd,0xa2,0x48,0xb5,0x56,0xa3,0x1f,0xca,0x3c,0x4c,0x9e,0xca,0x6e,0xb3,0xd5,0x5e,0x68,0xf6,0x28,0x31,0x57,0x24,0xfb,0x9d,0x2b,0x55,0x4f,0xd7,0x90,0x62,0xd3,0x47,0x9d,
0x04,0x20,0x2d,0x04,0xa1,0x4a,0xd4,0x7c,0x7b,0x16,0x2e,0xb7,0xd2,0xa1,0x08,0xc5,0xd2,0xbd,0x53,0x87,0x34,0xdc,0x38,0x26,0xca,0x56,0xf2,0xac,0xc5,0x62,0x70,0x72,0x3f,0x63,0x47,0x9d,
0x04,0x20,0x30,0x57,0x85,0xe0,0x02,0x4a,0xd1,0x31,0xeb,0x16,0x1b,0x1d,0xa8,0x43,0x0b,0xb4,0xc6,0xac,0x7d,0x46,0x24,0x0b,0x55,0x9d,0x16,0xe6,0x46,0x03,0x72,0xfe,0xd4,0xef,0x47,0x9d,
0x04,0x20,0x36,0x6c,0xf1,0xd2,0xbb,0xda,0xff,0x8c,0x93,0x61,0x10,0xf2,0x9d,0xa1,0xa4,0x0a,0x30,0x9b,0x0c,0x69,0x6d,0xaa,0xd4,0x9c,0xfd,0xb5,0x5b,0x5e,0x30,0x9f,0xf3,0x13,0x47,0x9d,
0x04,0x20,0x3e,0xe2,0xf3,0xe5,0xc5,0xbe,0x61,0xdd,0x4c,0x3e,0xdb,0x0d,0xd2,0xf9,0x42,0xe3,0x31,0xb2,0xa8,0x51,0x31,0xf6,0xce,0xc2,0x38,0x20,0x27,0x39,0x73,0x68,0x5a,0x42,0x47,0x9d,
0x04,0x20,0x51,0x79,0x05,0x9c,0x8a,0xdf,0x03,0xb5,0x1b,0x17,0xc3,0x86,0xb6,0x54,0xcc,0xe0,0x6e,0x58,0xa6,0x41,0x4c,0xcc,0x0c,0x60,0x08,0xa6,0x0f,0x1d,0x11,0xd8,0x29,0xa6,0x47,0x9d,
0x04,0x20,0x60,0xbe,0xae,0x7d,0xa3,0x4d,0x6a,0x71,0x1a,0x5d,0xe5,0x98,0x9c,0xde,0xa0,0x99,0x39,0x19,0xd3,0x01,0x0a,0x5d,0x1c,0x21,0x43,0x94,0x92,0x71,0x5d,0x77,0xd7,0xdf,0x47,0x9d,
0x04,0x20,0x64,0x4e,0x86,0xa1,0x02,0xa1,0x8a,0xef,0xb0,0xd1,0xb5,0x77,0x69,0xb9,0x6a,0xdc,0xdf,0x35,0x8a,0xda,0xa4,0x3e,0x83,0xfa,0x50,0xe6,0xca,0x0e,0x2b,0x99,0x0a,0x17,0x47,0x9d,
0x04,0x20,0xa2,0x28,0x3c,0x5a,0x5b,0x82,0x32,0x66,0x11,0xe5,0x71,0xff,0x6b,0x25,0x92,0x75,0xdd,0x7a,0x4f,0x90,0x8b,0x1d,0x34,0xa4,0xf1,0x6e,0xb9,0xfb,0xb5,0x2e,0x7c,0x7f,0x47,0x9d,
0x04,0x20,0xc8,0xb5,0x6a,0xba,0x02,0x26,0x45,0x12,0xfb,0x93,0x8a,0x51,0xe4,0xb0,0xf3,0x94,0xb7,0xc0,0x74,0x72,0xeb,0x67,0x91,0x9e,0x04,0x36,0x6a,0x4b,0xef,0x0d,0x88,0xfe,0x47,0x9d,
0x04,0x20,0xc8,0xfa,0xcd,0x8c,0xc3,0x6f,0x3c,0xd0,0x27,0x7e,0x7d,0xeb,0x51,0x01,0x65,0xb6,0x9e,0x02,0x09,0x64,0xf4,0x87,0x78,0x7b,0x8f,0x9d,0xaf,0x3b,0xa5,0xcc,0x56,0x2c,0x47,0x9d,
};
#endif // BITCOIN_CHAINPARAMSSEEDS_H
| 65.373239 | 184 | 0.73989 |
b60d3f045576f17590f5d86c9a1f9f6dabb4f182 | 906 | h | C | 3rd/chimera/test/dht.h | ShoufuLuo/csaw | 0d030d5ab93e61b62dff10b27a15c83fcfce3ff3 | [
"Apache-2.0"
] | null | null | null | 3rd/chimera/test/dht.h | ShoufuLuo/csaw | 0d030d5ab93e61b62dff10b27a15c83fcfce3ff3 | [
"Apache-2.0"
] | null | null | null | 3rd/chimera/test/dht.h | ShoufuLuo/csaw | 0d030d5ab93e61b62dff10b27a15c83fcfce3ff3 | [
"Apache-2.0"
] | null | null | null |
// message types
#define HELLO_MESSAGE 51
#define PUT_COMMAND 52
#define DHT_PUT_ROOT 53
#define DHT_PUT_NONROOT 54
#define DHT_GET_ROOT 55
#define GET_COMMAND 56
#define DHT_GET_NONROOT 57
#define DHT_DUMP_STATE 58
// excluding the root of the block
#define DHT_REPLICATION 3
// test specific details
#define HOSTS_FILE "./hosts"
#define BLOCKS_FILE "./blocks"
#define TEST_NETWORK_SIZE 100
#define BLOCKS_PER_FILE 10
#define FILES_PER_NODE 10
#define HASH_TABLE_SIZE 5000
#define ENTRY_SIZE 100
#define true 1
#define false 0
// malice types
#define MALICE_NONE 0
#define MALICE_ALL_BOOTSTRAP 1
typedef int bool;
typedef struct DhtMessage
{
char blockId[ENTRY_SIZE];
int hops;
bool hijacked;
}DhtMessage;
DhtMessage* get_new_dhtmessage(char *blockId)
{
DhtMessage *msg = (DhtMessage *) malloc(sizeof(DhtMessage));
msg->hops = 0;
msg->hijacked = false;
strcpy(msg->blockId, blockId);
}
| 18.875 | 61 | 0.774834 |
b3b734d707e9d1c834aeaea967051de9a2ffa441 | 12,776 | h | C | Core/Other.h | koz4k/soccer | 7bceea654b50c5c0e18effd38e79249bd295e0a4 | [
"MIT"
] | 1 | 2018-09-28T17:04:11.000Z | 2018-09-28T17:04:11.000Z | Core/Other.h | koz4k/soccer | 7bceea654b50c5c0e18effd38e79249bd295e0a4 | [
"MIT"
] | 1 | 2021-04-06T21:57:39.000Z | 2021-04-06T21:57:39.000Z | Core/Other.h | koz4k/soccer | 7bceea654b50c5c0e18effd38e79249bd295e0a4 | [
"MIT"
] | 3 | 2017-08-26T12:06:05.000Z | 2019-11-22T16:57:47.000Z | template <class T, class... Args>
T& Single(Args... args) {
static T o(args...);
return o;
}
template <class T> // Workaround for GCC bug - specialization needed...
T& Single() {
static T o;
return o;
}
int RegisterTypeNo__(const char *type);
template <class T>
int StaticTypeNo() {
static int typeno = RegisterTypeNo__(typeid(T).name());
return typeno;
}
template <class T>
class One : MoveableAndDeepCopyOption< One<T> > {
mutable T *ptr;
void Free() { if(ptr && ptr != (T*)1) delete ptr; }
template <class TT>
void Pick(One<TT>&& data) { ptr = data.Detach(); }
public:
void Attach(T *data) { Free(); ptr = data; }
T *Detach() { T *t = ptr; ptr = NULL; return t; }
void Clear() { Free(); ptr = NULL; }
void operator=(T *data) { Attach(data); }
template <class TT>
void operator=(One<TT>&& d) { if((void *)this != (void *)&d) { Free(); Pick(pick(d)); }}
const T *operator->() const { ASSERT(ptr); return ptr; }
T *operator->() { ASSERT(ptr); return ptr; }
const T *operator~() const { return ptr; }
T *operator~() { return ptr; }
const T& operator*() const { ASSERT(ptr); return *ptr; }
T& operator*() { ASSERT(ptr); return *ptr; }
template <class TT, class... Args>
TT& Create(Args... args) { TT *q = new TT(args...); Attach(q); return *q; }
template <class TT> // with C++ conforming compiler, this would not be needed - GCC bug workaround
TT& Create() { TT *q = new TT; Attach(q); return *q; }
template <class... Args>
T& Create(Args... args) { T *q = new T(args...); Attach(q); return *q; }
T& Create() { T *q = new T; Attach(q); return *q; }
template <class TT>
bool Is() const { return dynamic_cast<const TT *>(ptr); }
bool IsEmpty() const { return !ptr; }
operator bool() const { return ptr; }
String ToString() const { return ptr ? AsString(*ptr) : "<empty>"; }
One() { ptr = NULL; }
One(T *newt) { ptr = newt; }
template <class TT>
One(One<TT>&& p) { Pick(pick(p)); }
One(const One<T>& p, int) { ptr = p.IsEmpty() ? NULL : DeepCopyNew(*p); }
~One() { Free(); }
};
class Any : Moveable<Any> {
struct BaseData {
int typeno;
virtual ~BaseData() {}
};
template <class T>
struct Data : BaseData {
T data;
template <class... Args>
Data(Args... args) : data(args...) { typeno = StaticTypeNo<T>(); }
};
BaseData *ptr;
void Chk() const { ASSERT(ptr != (void *)1); }
void Pick(Any&& s) { ptr = s.ptr; const_cast<Any&>(s).ptr = NULL; }
public:
template <class T, class... Args> T& Create(Args... args) { Clear(); Data<T> *x = new Data<T>(args...); ptr = x; return x->data; }
template <class T> bool Is() const { return ptr && ptr->typeno == StaticTypeNo<T>(); }
template <class T> T& Get() { ASSERT(Is<T>()); Chk(); return ((Data<T>*)ptr)->data; }
template <class T> const T& Get() const { ASSERT(Is<T>()); Chk(); return ((Data<T>*)ptr)->data; }
void Clear() { if(ptr) delete ptr; ptr = NULL; }
bool IsEmpty() const { return ptr == NULL; }
void operator=(Any&& s) { if(this != &s) { Clear(); Pick(pick(s)); } }
Any(Any&& s) { Pick(pick(s)); }
Any() { ptr = NULL; }
~Any() { Clear(); }
};
class Bits : Moveable<Bits> {
mutable int alloc;
dword *bp;
public:
void Clear();
void Set(int i, bool b = true);
bool Get(int i) const { ASSERT(i >= 0 && alloc >= 0); int q = i >> 5;
return q < alloc ? bp[q] & (1 << (i & 31)) : false; }
bool operator[](int i) const { return Get(i); }
Bits() { bp = NULL; alloc = 0; }
~Bits() { Clear(); }
Bits(Bits&& b) { alloc = b.alloc; bp = b.bp; b.bp = NULL; }
void operator=(Bits&& b) { if(this != &b) { Clear(); alloc = b.alloc; bp = b.bp; b.bp = NULL; } }
#ifdef DEPRECATED
void Set(int i, bool b, int count) { while(count--) Set(i++, b); }
#endif
};
//# System dependent
template <class T>
class Mitor : Moveable< Mitor<T> > {
union {
mutable unsigned count;
mutable Vector<T> *vector;
};
byte elem0[sizeof(T)];
T& Get(int i) const;
void Pick(Mitor&& m);
void Copy(const Mitor& m);
void Chk() const { ASSERT(count != 2); }
public:
T& operator[](int i) { return Get(i); }
const T& operator[](int i) const { return Get(i); }
int GetCount() const;
T& Add();
void Add(const T& x);
void Clear();
void Shrink();
Mitor(Mitor&& m) { Pick(pick(m)); }
void operator=(Mitor&& m) { if(this != &m) { Clear(); Pick(pick(m)); } }
Mitor(Mitor& m, int) { Copy(m); }
Mitor() { count = 0; }
~Mitor() { Clear(); }
};
template <class T>
T& Mitor<T>::Get(int i) const
{
ASSERT(i >= 0 && i < GetCount());
return i == 0 ? *(T*)elem0 : (*const_cast<Vector<T>*>(vector))[i - 1];
}
template <class T>
void Mitor<T>::Pick(Mitor&& m)
{
m.Chk();
vector = m.vector;
memcpy(&elem0, &m.elem0, sizeof(T));
m.count = 2;
}
template <class T>
void Mitor<T>::Copy(const Mitor& m)
{
m.Chk();
if(m.count > 0)
DeepCopyConstruct(elem0, (const T*)m.elem0);
if(m.count > 1)
vector = new Vector<T>(*m.vector, 1);
}
template <class T>
int Mitor<T>::GetCount() const
{
Chk();
return count > 1 ? vector->GetCount() + 1 : count;
}
template <class T>
T& Mitor<T>::Add()
{
Chk();
if(count == 0) {
count = 1;
return *new(elem0) T;
}
if(count == 1)
vector = new Vector<T>;
return vector->Add();
}
template <class T>
void Mitor<T>::Add(const T& x)
{
Chk();
if(count == 0) {
count = 1;
new((T*) elem0) T(x);
}
else {
if(count == 1)
vector = new Vector<T>;
vector->Add(x);
}
}
template <class T>
void Mitor<T>::Clear()
{
if(count > 2)
delete vector;
if(count && count != 2)
((T*)elem0)->T::~T();
count = 0;
}
template <class T>
void Mitor<T>::Shrink()
{
if(count > 2)
vector->Shrink();
}
//#
template <class T, int N = 1>
struct Link {
T *link_prev[N];
T *link_next[N];
protected:
void LPN(int i) { link_prev[i]->link_next[i] = link_next[i]->link_prev[i] = (T *)this; }
public:
T *GetPtr() { return (T *) this; }
const T *GetPtr() const { return (const T *) this; }
T *GetNext(int i = 0) { return link_next[i]; }
T *GetPrev(int i = 0) { return link_prev[i]; }
const T *GetNext(int i = 0) const { return link_next[i]; }
const T *GetPrev(int i = 0) const { return link_prev[i]; }
void LinkSelf(int i = 0) { link_next[i] = link_prev[i] = (T *)this; }
void LinkSelfAll() { for(int i = 0; i < N; i++) LinkSelf(i); }
void Unlink(int i = 0) { link_next[i]->link_prev[i] = link_prev[i]; link_prev[i]->link_next[i] = link_next[i];
LinkSelf(i); }
void UnlinkAll() { for(int i = 0; i < N; i++) Unlink(i); }
void LinkBefore(Link *n, int i = 0) { link_next[i] = (T *)n; link_prev[i] = link_next[i]->link_prev[i]; LPN(i); }
void LinkAfter(Link *p, int i = 0) { link_prev[i] = (T *)p; link_next[i] = link_prev[i]->link_next[i]; LPN(i); }
T *InsertNext(int i = 0) { T *x = new T; x->LinkAfter(this, i); return x; }
T *InsertPrev(int i = 0) { T *x = new T; x->LinkBefore(this, i); return x; }
void DeleteList(int i = 0) { while(link_next[i] != GetPtr()) delete link_next[i]; }
bool InList(int i = 0) const { return link_next[i] != GetPtr(); }
bool IsEmpty(int i = 0) const { return !InList(i); }
Link() { LinkSelfAll(); }
~Link() { UnlinkAll(); }
private:
Link(const Link&);
void operator=(const Link&);
public:
#ifdef _DEBUG
void Dump() {
for(T *t = GetNext(); t != this; t = t->GetNext())
LOG(t);
LOG("-------------------------------------");
}
#endif
};
template <class T, int N = 1>
class LinkOwner : public Link<T, N> {
public:
~LinkOwner() { Link<T, N>::DeleteList(); }
};
template <class T, class K = String>
class LRUCache {
public:
struct Maker {
virtual K Key() const = 0;
virtual int Make(T& object) const = 0;
virtual ~Maker() {}
};
private:
struct Item : Moveable<Item> {
int prev, next;
int size;
One<T> data;
bool flag;
};
struct Key : Moveable<Key> {
K key;
const void *type;
bool operator==(const Key& b) const { return key == b.key && type == b.type; }
unsigned GetHashValue() const { return CombineHash(key, (uintptr_t)type); }
};
Index<Key> key;
Vector<Item> data;
int head;
int size;
int count;
int foundsize;
int newsize;
bool flag;
void Unlink(int i);
void LinkHead(int i);
public:
int GetSize() const { return size; }
int GetCount() const { return count; }
template <class P> void AdjustSize(P getsize);
T& GetLRU();
void DropLRU();
void Shrink(int maxsize, int maxcount = 30000);
template <class P> int Remove(P predicate);
template <class P> bool RemoveOne(P predicate);
T& Get(const Maker& m);
void Clear();
void ClearCounters();
int GetFoundSize() const { return foundsize; }
int GetNewSize() const { return newsize; }
LRUCache() { head = -1; size = 0; count = 0; ClearCounters(); }
};
template <class T, class K>
void LRUCache<T, K>::LinkHead(int i)
{
Item& m = data[i];
if(head >= 0) {
int tail = data[head].prev;
m.next = head;
m.prev = tail;
data[head].prev = i;
data[tail].next = i;
}
else
m.prev = m.next = i;
head = i;
count++;
}
template <class T, class K>
void LRUCache<T, K>::Unlink(int i)
{
Item& m = data[i];
if(m.prev == i)
head = -1;
else {
if(head == i)
head = m.next;
data[m.next].prev = m.prev;
data[m.prev].next = m.next;
}
count--;
}
template <class T, class K>
T& LRUCache<T, K>::GetLRU()
{
int tail = data[head].prev;
return *data[tail].data;
}
template <class T, class K>
void LRUCache<T, K>::DropLRU()
{
if(head >= 0) {
int tail = data[head].prev;
size -= data[tail].size;
data[tail].data.Clear();
Unlink(tail);
key.Unlink(tail);
}
}
template <class T, class K>
template <class P>
void LRUCache<T, K>::AdjustSize(P getsize)
{
size = 0;
count = 0;
for(int i = 0; i < data.GetCount(); i++)
if(!key.IsUnlinked(i)) {
size += (data[i].size = getsize(*data[i].data));
count++;
}
}
template <class T, class K>
template <class P>
int LRUCache<T, K>::Remove(P predicate)
{
int n = 0;
int i = 0;
while(i < data.GetCount())
if(!key.IsUnlinked(i) && predicate(*data[i].data)) {
size -= data[i].size;
Unlink(i);
key.Unlink(i);
n++;
break;
}
else
i++;
return n;
}
template <class T, class K>
template <class P>
bool LRUCache<T, K>::RemoveOne(P predicate)
{
int i = head;
if(i >= 0)
for(;;) {
int next = data[i].next;
if(predicate(*data[i].data)) {
size -= data[i].size;
Unlink(i);
key.Unlink(i);
return true;
}
if(i == next || next == head || next < 0)
break;
i = next;
}
return false;
}
template <class T, class K>
void LRUCache<T, K>::Shrink(int maxsize, int maxcount)
{
if(maxsize >= 0 && maxcount >= 0)
while(count > maxcount || size > maxsize)
DropLRU();
}
template <class T, class K>
void LRUCache<T, K>::Clear()
{
head = -1;
size = 0;
count = 0;
newsize = foundsize = 0;
key.Clear();
data.Clear();
}
template <class T, class K>
void LRUCache<T, K>::ClearCounters()
{
flag = !flag;
newsize = foundsize = 0;
}
template <class T, class K>
T& LRUCache<T, K>::Get(const Maker& m)
{
Key k;
k.key = m.Key();
k.type = &typeid(m);
int q = key.Find(k);
if(q < 0) {
q = key.Put(k);
Item& t = data.At(q);
t.size = m.Make(t.data.Create());
size += t.size;
newsize += t.size;
t.flag = flag;
}
else {
Item& t = data[q];
Unlink(q);
if(t.flag != flag) {
t.flag = flag;
foundsize += t.size;
}
}
LinkHead(q);
return *data[q].data;
}
| 24.711799 | 131 | 0.517689 |
7d07ef7ab680ddbc023b1622e96ca42807237610 | 3,598 | h | C | ARCHIVE/BRAINSRefacer/MaskFromLabelMapFilter.h | pnlbwh/BRAINSTools | a2fe63ab5b795f03da140a4081d1fef6314dab95 | [
"Apache-2.0"
] | null | null | null | ARCHIVE/BRAINSRefacer/MaskFromLabelMapFilter.h | pnlbwh/BRAINSTools | a2fe63ab5b795f03da140a4081d1fef6314dab95 | [
"Apache-2.0"
] | null | null | null | ARCHIVE/BRAINSRefacer/MaskFromLabelMapFilter.h | pnlbwh/BRAINSTools | a2fe63ab5b795f03da140a4081d1fef6314dab95 | [
"Apache-2.0"
] | 1 | 2022-02-08T05:39:46.000Z | 2022-02-08T05:39:46.000Z | #ifndef BRAINSTOOLS_MASKFROMLABELMAPFILTER_H
#define BRAINSTOOLS_MASKFROMLABELMAPFILTER_H
#include "itkImageToImageFilter.h"
#include "itkMacro.h"
#include "itkResampleImageFilter.h"
#include "itkNearestNeighborInterpolateImageFunction.h"
template <typename TImage, typename TAtlas, typename TOutputMask>
class MaskFromLabelMapFilter : public itk::ImageToImageFilter<TImage, TOutputMask>
{
public:
/** Standard class type alias. */
using Self = MaskFromLabelMapFilter;
using Superclass = itk::ImageToImageFilter<TImage, TImage>;
using Pointer = itk::SmartPointer<Self>;
itkNewMacro(Self);
itkTypeMacro(ImageFilterMultipleInputsDifferentType, ImageToImageFilter);
itkSetMacro(ReferenceImage, typename TImage::Pointer);
itkGetMacro(ReferenceImage, typename TImage::Pointer);
itkSetMacro(InputAtlas, typename TAtlas::Pointer);
itkGetMacro(InputAtlas, typename TAtlas::Pointer);
private:
typename TImage::Pointer m_ReferenceImage;
typename TAtlas::Pointer m_InputAtlas;
protected:
MaskFromLabelMapFilter() { this->SetInput(TImage::New()); };
~MaskFromLabelMapFilter() override{};
void
GenerateData() override
{
// resample LabelImage
typedef itk::NearestNeighborInterpolateImageFunction<TAtlas, double> NN_InterpolatorType;
typename NN_InterpolatorType::Pointer NN_interpolator = NN_InterpolatorType::New();
constexpr int Dimension = 3;
using IdentityTransformType = itk::IdentityTransform<double, Dimension>;
typename IdentityTransformType::Pointer identityTransform = IdentityTransformType::New();
using maskResamplerType = itk::ResampleImageFilter<TAtlas, TAtlas>;
typename maskResamplerType::Pointer maskResampler = maskResamplerType::New();
std::cout << "Resampling atlas map:" << std::endl;
maskResampler->SetInput(this->GetInputAtlas());
maskResampler->SetInterpolator(NN_interpolator);
maskResampler->SetTransform(identityTransform);
maskResampler->SetReferenceImage(this->GetReferenceImage());
maskResampler->UseReferenceImageOn();
maskResampler->Update();
using MaskFilterType = itk::BinaryThresholdImageFilter<TAtlas, TOutputMask>;
typename MaskFilterType::Pointer maskFilter = MaskFilterType::New();
maskFilter->SetInput(maskResampler->GetOutput());
maskFilter->SetOutsideValue(1);
maskFilter->SetInsideValue(0);
maskFilter->SetLowerThreshold(0);
maskFilter->SetUpperThreshold(0);
maskFilter->Update();
typename TOutputMask::Pointer maskResult = maskFilter->GetOutput();
typename TOutputMask::Pointer output = this->GetOutput();
output->SetRegions(maskResult->GetLargestPossibleRegion());
itk::Image<double, 3>::Pointer test = itk::Image<double, 3>::New();
output->SetOrigin(maskResult->GetOrigin());
output->SetSpacing(maskResult->GetSpacing());
output->SetDirection(maskResult->GetDirection());
output->Allocate();
typename itk::ImageRegionConstIterator<TOutputMask> maskResultIterator(maskResult,
maskResult->GetLargestPossibleRegion());
typename itk::ImageRegionIterator<TOutputMask> outputIterator(output, output->GetLargestPossibleRegion());
while (!outputIterator.IsAtEnd())
{
outputIterator.Set(maskResultIterator.Get());
++outputIterator;
++maskResultIterator;
}
};
private:
MaskFromLabelMapFilter(const Self &); // purposely not implemented
void
operator=(const Self &); // purposely not implemented
};
#endif // BRAINSTOOLS_MASKFROMLABELMAPFILTER_H
| 37.092784 | 118 | 0.740689 |
df8d39a280887cd370bf112b73ce59cb48927bcc | 1,656 | h | C | nt/iExp/Query.h | DICE-UNC/iRODS-FUSE-Mod | 8f8e965493a03bcb085df0b6467e7dfcce308d0f | [
"BSD-3-Clause"
] | 2 | 2015-03-10T13:13:55.000Z | 2019-09-16T11:02:51.000Z | nt/iExp/Query.h | DICE-UNC/iRODS-FUSE-Mod | 8f8e965493a03bcb085df0b6467e7dfcce308d0f | [
"BSD-3-Clause"
] | 1 | 2015-09-24T04:20:30.000Z | 2015-09-24T04:20:30.000Z | nt/iExp/Query.h | DICE-UNC/iRODS-FUSE-Mod | 8f8e965493a03bcb085df0b6467e7dfcce308d0f | [
"BSD-3-Clause"
] | 1 | 2019-09-16T11:03:31.000Z | 2019-09-16T11:03:31.000Z | #if !defined(AFX_QUERY_H__80896A70_163C_4700_8D14_3AAB4E38034E__INCLUDED_)
#define AFX_QUERY_H__80896A70_163C_4700_8D14_3AAB4E38034E__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Query.h : header file
//
#include "winiObjects.h"
#include <vector>
/////////////////////////////////////////////////////////////////////////////
// CQuery dialog
class CQuery : public CDialog
{
// Construction
public:
CQuery(WINI::ISession* session, WINI::INode* source, CWnd* pParent = NULL); // standard constructor
void Fill(WINI::INode* node);
// Dialog Data
//{{AFX_DATA(CQuery)
enum { IDD = IDD_QUERY };
CListBox m_List;
CComboBox m_Value;
CComboBox m_Operation;
CComboBox m_Attribute;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CQuery)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
public:
WINI::ISession* m_session;
WINI::INode* m_source;
WINI::IQueryNode* m_query;
protected:
std::vector<WINI::IMetadataNode*> m_list;
//WINI::IQueryOperator* m_qop;
WINI::IQueryOperator* m_qOp;
// Generated message map functions
//{{AFX_MSG(CQuery)
afx_msg void OnQueryAdd();
virtual BOOL OnInitDialog();
virtual void OnOK();
afx_msg void OnQueryRemove();
afx_msg void OnQueryAnd();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_QUERY_H__80896A70_163C_4700_8D14_3AAB4E38034E__INCLUDED_)
| 25.476923 | 103 | 0.690217 |
f2f3de5b90a4199608fb1c6f67ee7879c95dea7a | 372 | h | C | legacy/TL/TL/TLRPCaccount_setAccountTTL.h | miladajilian/MimMessenger | 72aca46135eed311f5f2fd3b711446a61b526548 | [
"MIT"
] | 6 | 2018-01-14T08:11:12.000Z | 2021-06-24T04:30:23.000Z | legacy/TL/TL/TLRPCaccount_setAccountTTL.h | miladajilian/MimMessenger | 72aca46135eed311f5f2fd3b711446a61b526548 | [
"MIT"
] | 1 | 2018-06-12T07:07:09.000Z | 2018-06-12T07:07:09.000Z | legacy/TL/TL/TLRPCaccount_setAccountTTL.h | miladajilian/MimMessenger | 72aca46135eed311f5f2fd3b711446a61b526548 | [
"MIT"
] | 6 | 2018-01-12T14:10:36.000Z | 2018-10-10T15:52:21.000Z | #import <Foundation/Foundation.h>
#import "TLObject.h"
#import "TLMetaRpc.h"
@class TLAccountDaysTTL;
@interface TLRPCaccount_setAccountTTL : TLMetaRpc
@property (nonatomic, retain) TLAccountDaysTTL *ttl;
- (Class)responseClass;
- (int)impliedResponseSignature;
@end
@interface TLRPCaccount_setAccountTTL$account_setAccountTTL : TLRPCaccount_setAccountTTL
@end
| 16.173913 | 88 | 0.801075 |
9ebb4a92254a7bcb3afc3ed819d2a39f9febf62e | 783 | h | C | src/apps/prepare4models/no_need_ut_here/shared_operations.h | boazsade/machine_learinig_models | eb1f9eda0e4e25a6d028b25682dfb20628a20624 | [
"MIT"
] | null | null | null | src/apps/prepare4models/no_need_ut_here/shared_operations.h | boazsade/machine_learinig_models | eb1f9eda0e4e25a6d028b25682dfb20628a20624 | [
"MIT"
] | null | null | null | src/apps/prepare4models/no_need_ut_here/shared_operations.h | boazsade/machine_learinig_models | eb1f9eda0e4e25a6d028b25682dfb20628a20624 | [
"MIT"
] | null | null | null | #pragma once
#include "libs/sources_handling/source_data.h"
#include "libs/sources_handling/input_data.h"
#include <iosfwd>
bool operator == (const source_data& left, const source_data& right);
bool operator != (const source_data& left, const source_data& right);
bool operator == (const input_data& left, const input_data& right);
bool operator != (const input_data& left, const input_data& right);
std::ostream& operator << (std::ostream& os, const source_data& sd);
std::ostream& operator << (std::ostream& os, source_data::iterator );
//std::ostream& operator << (std::ostream& os, const input_data& sd);
source_data make_test_data(unsigned int size, const source_data::id_type& id);
source_data from_double_array(const double* from, const double* to, const std::string& name);
| 52.2 | 93 | 0.754789 |
7fb8b626da299efd860545f5d41dbbc42739f7b9 | 31,857 | h | C | src/QMCWaveFunctions/WaveFunctionComponent.h | djstaros/qmcpack | 280f67e638bae280448b47fa618f05b848c530d2 | [
"NCSA"
] | null | null | null | src/QMCWaveFunctions/WaveFunctionComponent.h | djstaros/qmcpack | 280f67e638bae280448b47fa618f05b848c530d2 | [
"NCSA"
] | null | null | null | src/QMCWaveFunctions/WaveFunctionComponent.h | djstaros/qmcpack | 280f67e638bae280448b47fa618f05b848c530d2 | [
"NCSA"
] | null | null | null | //////////////////////////////////////////////////////////////////////////////////////
// This file is distributed under the University of Illinois/NCSA Open Source License.
// See LICENSE file in top directory for details.
//
// Copyright (c) 2020 QMCPACK developers.
//
// File developed by: Ken Esler, kpesler@gmail.com, University of Illinois at Urbana-Champaign
// Miguel Morales, moralessilva2@llnl.gov, Lawrence Livermore National Laboratory
// Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
// Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
// Raymond Clay III, j.k.rofling@gmail.com, Lawrence Livermore National Laboratory
// Mark A. Berrill, berrillma@ornl.gov, Oak Ridge National Laboratory
//
// File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
//////////////////////////////////////////////////////////////////////////////////////
#ifndef QMCPLUSPLUS_WAVEFUNCTIONCOMPONENT_H
#define QMCPLUSPLUS_WAVEFUNCTIONCOMPONENT_H
#include "Message/Communicate.h"
#include "Configuration.h"
#include "Particle/ParticleSet.h"
#include "Particle/VirtualParticleSet.h"
#include "Particle/DistanceTableData.h"
#include "OhmmsData/RecordProperty.h"
#include "QMCWaveFunctions/OrbitalSetTraits.h"
#include "Particle/MCWalkerConfiguration.h"
#include "type_traits/template_types.hpp"
#ifdef QMC_CUDA
#include "type_traits/CUDATypes.h"
#endif
/**@file WaveFunctionComponent.h
*@brief Declaration of WaveFunctionComponent
*/
namespace qmcplusplus
{
#ifdef QMC_CUDA
struct NLjob
{
int walker;
int elec;
int numQuadPoints;
NLjob(int w, int e, int n) : walker(w), elec(e), numQuadPoints(n) {}
};
#endif
///forward declaration of WaveFunctionComponent
class WaveFunctionComponent;
///forward declaration of DiffWaveFunctionComponent
class DiffWaveFunctionComponent;
typedef WaveFunctionComponent* WaveFunctionComponentPtr;
typedef DiffWaveFunctionComponent* DiffWaveFunctionComponentPtr;
/**@defgroup WaveFunctionComponent group
* @brief Classes which constitute a many-body trial wave function
*
* A many-body trial wave function is
* \f[
\Psi(\{ {\bf R}\}) = \prod_i \psi_{i}(\{ {\bf R}\}),
* \f]
* where \f$\Psi\f$s are represented by
* the derived classes from WaveFunctionComponent.
*/
/** @ingroup WaveFunctionComponent
* @brief An abstract class for a component of a many-body trial wave function
*
* mw_ prefix is a function name signature indicating it is for handling a batch of WaveFunctionComponent objects
* which are required to be base class pointers of the same derived class type.
* all the mw_ routines must be implemented in a way either stateless or maintains states of every walker.
*/
struct WaveFunctionComponent : public QMCTraits
{
/** enum for a update mode */
enum
{
ORB_PBYP_RATIO, /*!< particle-by-particle ratio only */
ORB_PBYP_ALL, /*!< particle-by-particle, update Value-Gradient-Laplacian */
ORB_PBYP_PARTIAL, /*!< particle-by-particle, update Value and Grdient */
ORB_WALKER, /*!< walker update */
ORB_ALLWALKER /*!< all walkers update */
};
typedef ParticleAttrib<ValueType> ValueVectorType;
typedef ParticleAttrib<GradType> GradVectorType;
typedef ParticleSet::Walker_t Walker_t;
typedef Walker_t::WFBuffer_t WFBufferType;
typedef Walker_t::Buffer_t BufferType;
typedef OrbitalSetTraits<RealType>::ValueMatrix_t RealMatrix_t;
typedef OrbitalSetTraits<ValueType>::ValueMatrix_t ValueMatrix_t;
typedef OrbitalSetTraits<ValueType>::GradMatrix_t GradMatrix_t;
typedef OrbitalSetTraits<ValueType>::HessType HessType;
typedef OrbitalSetTraits<ValueType>::HessVector_t HessVector_t;
// the value type for log(psi)
using LogValueType = std::complex<QTFull::RealType>;
// the value type for psi(r')/psi(r)
using PsiValueType = QTFull::ValueType;
/** flag to set the optimization mode */
bool IsOptimizing;
/** boolean to set optimization
*
* If true, this object is actively modified during optimization
*/
bool Optimizable;
/** true, if this component is fermionic */
bool is_fermionic;
/** current update mode */
int UpdateMode;
/** current \f$\log\phi \f$
*/
LogValueType LogValue;
/** Pointer to the differential WaveFunctionComponent of this object
*
* If dPsi=0, this WaveFunctionComponent is constant with respect to the optimizable variables
*/
DiffWaveFunctionComponentPtr dPsi;
/** A vector for \f$ \frac{\partial \nabla \log\phi}{\partial \alpha} \f$
*/
GradVectorType dLogPsi;
/** A vector for \f$ \frac{\partial \nabla^2 \log\phi}{\partial \alpha} \f$
*/
ValueVectorType d2LogPsi;
/** Name of the class derived from WaveFunctionComponent
*/
std::string ClassName;
///list of variables this WaveFunctionComponent handles
opt_variables_type myVars;
///Bytes in WFBuffer
size_t Bytes_in_WFBuffer;
/// default constructor
WaveFunctionComponent();
//WaveFunctionComponent(const WaveFunctionComponent& old);
///default destructor
virtual ~WaveFunctionComponent() {}
inline void setOptimizable(bool optimizeit) { Optimizable = optimizeit; }
///assign a differential WaveFunctionComponent
virtual void setDiffOrbital(DiffWaveFunctionComponentPtr d);
///assembles the full value
PsiValueType getValue() const { return LogToValue<PsiValueType>::convert(LogValue); }
/** check in optimizable parameters
* @param active a super set of optimizable variables
*
* Add the paramemters this WaveFunctionComponent manage to active.
*/
virtual void checkInVariables(opt_variables_type& active) = 0;
/** check out optimizable variables
*
* Update myVars index map
*/
virtual void checkOutVariables(const opt_variables_type& active) = 0;
/** reset the parameters during optimizations
*/
virtual void resetParameters(const opt_variables_type& active) = 0;
/** print the state, e.g., optimizables */
virtual void reportStatus(std::ostream& os) = 0;
/** reset properties, e.g., distance tables, for a new target ParticleSet
* @param P ParticleSet
*/
virtual void resetTargetParticleSet(ParticleSet& P) = 0;
/** evaluate the value of the WaveFunctionComponent from scratch
* @param P active ParticleSet
* @param G Gradients, \f$\nabla\ln\Psi\f$
* @param L Laplacians, \f$\nabla^2\ln\Psi\f$
* @return the log value
*
* Mainly for walker-by-walker move. The initial stage of particle-by-particle
* move also uses this.
*/
virtual LogValueType evaluateLog(ParticleSet& P,
ParticleSet::ParticleGradient_t& G,
ParticleSet::ParticleLaplacian_t& L) = 0;
/** evaluate from scratch the same type WaveFunctionComponent of multiple walkers
* @param WFC_list the list of WaveFunctionComponent pointers of the same component in a walker batch
* @param P_list the list of ParticleSet pointers in a walker batch
* @param G_list the list of Gradients pointers in a walker batch, \f$\nabla\ln\Psi\f$
* @param L_list the list of Laplacians pointers in a walker batch, \f$\nabla^2\ln\Psi\f$
* @@param values the log WF values of walkers in a batch
*/
virtual void mw_evaluateLog(const RefVector<WaveFunctionComponent>& WFC_list,
const RefVector<ParticleSet>& P_list,
const RefVector<ParticleSet::ParticleGradient_t>& G_list,
const RefVector<ParticleSet::ParticleLaplacian_t>& L_list)
{
#pragma omp parallel for
for (int iw = 0; iw < WFC_list.size(); iw++)
WFC_list[iw].get().evaluateLog(P_list[iw], G_list[iw], L_list[iw]);
}
/** recompute the value of the WaveFunctionComponents which require critical accuracy.
* needed for Slater Determinants but not needed for most types of WaveFunctionComponents
*/
virtual void recompute(ParticleSet& P) {}
// virtual void evaluateHessian(ParticleSet& P, IndexType iat, HessType& grad_grad_psi)
// {
// APP_ABORT("WaveFunctionComponent::evaluateHessian is not implemented");
// }
virtual void evaluateHessian(ParticleSet& P, HessVector_t& grad_grad_psi_all)
{
APP_ABORT("WaveFunctionComponent::evaluateHessian is not implemented in " + ClassName + " class.");
}
/** return the current gradient for the iat-th particle
* @param P quantum particle set
* @param iat particle index
* @return the gradient of the iat-th particle
*/
virtual GradType evalGrad(ParticleSet& P, int iat)
{
APP_ABORT("WaveFunctionComponent::evalGradient is not implemented in " + ClassName + " class.");
return GradType();
}
/** return the current spin gradient for the iat-th particle
* Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin.
* @param P quantum particle set
* @param iat particle index
* @return the spin gradient of the iat-th particle
*/
virtual GradType evalGradWithSpin(ParticleSet& P, int iat, ComplexType& spingrad) { return evalGrad(P, iat); }
/** compute the current gradients for the iat-th particle of multiple walkers
* @param WFC_list the list of WaveFunctionComponent pointers of the same component in a walker batch
* @param P_list the list of ParticleSet pointers in a walker batch
* @param iat particle index
* @param grad_now the list of gradients in a walker batch, \f$\nabla\ln\Psi\f$
*/
virtual void mw_evalGrad(const RefVector<WaveFunctionComponent>& WFC_list,
const RefVector<ParticleSet>& P_list,
int iat,
std::vector<GradType>& grad_now)
{
#pragma omp parallel for
for (int iw = 0; iw < WFC_list.size(); iw++)
grad_now[iw] = WFC_list[iw].get().evalGrad(P_list[iw].get(), iat);
}
/** return the logarithmic gradient for the iat-th particle
* of the source particleset
* @param Pquantum particle set
* @param iat particle index
* @return the gradient of the iat-th particle
*/
virtual GradType evalGradSource(ParticleSet& P, ParticleSet& source, int iat)
{
// unit_test_hamiltonian calls this function incorrectly; do not abort for now
// APP_ABORT("WaveFunctionComponent::evalGradSource is not implemented");
return GradType();
}
/** Adds the gradient w.r.t. the iat-th particle of the
* source particleset (ions) of the logarithmic gradient
* and laplacian w.r.t. the target paritlceset (electrons).
* @param P quantum particle set (electrons)
* @param source classical particle set (ions)
* @param iat particle index of source (ion)
* @param the ion gradient of the elctron gradient
* @param the ion gradient of the elctron laplacian.
* @return the log gradient of psi w.r.t. the source particle iat
*/
virtual GradType evalGradSource(ParticleSet& P,
ParticleSet& source,
int iat,
TinyVector<ParticleSet::ParticleGradient_t, OHMMS_DIM>& grad_grad,
TinyVector<ParticleSet::ParticleLaplacian_t, OHMMS_DIM>& lapl_grad)
{
return GradType();
}
/** evaluate the ratio of the new to old WaveFunctionComponent value and the new gradient
* @param P the active ParticleSet
* @param iat the index of a particle
* @param grad_iat Gradient for the active particle
*/
virtual PsiValueType ratioGrad(ParticleSet& P, int iat, GradType& grad_iat)
{
APP_ABORT("WaveFunctionComponent::ratioGrad is not implemented in " + ClassName + " class.");
return ValueType();
}
/** evaluate the ratio of the new to old WaveFunctionComponent value and the new spin gradient
* Default implementation assumes that WaveFunctionComponent does not explicitly depend on Spin.
* @param P the active ParticleSet
* @param iat the index of a particle
* @param grad_iat realspace gradient for the active particle
* @param spingrad_iat spin gradient for the active particle
*/
virtual PsiValueType ratioGradWithSpin(ParticleSet& P, int iat, GradType& grad_iat, ComplexType& spingrad_iat)
{
return ratioGrad(P, iat, grad_iat);
}
/** compute the ratio of the new to old WaveFunctionComponent value and the new gradient of multiple walkers
* @param WFC_list the list of WaveFunctionComponent pointers of the same component in a walker batch
* @param P_list the list of ParticleSet pointers in a walker batch
* @param iat particle index
* @param ratios the list of WF ratios of a walker batch, \f$ \Psi( \{ {\bf R}^{'} \} )/ \Psi( \{ {\bf R}\})\f$
* @param grad_now the list of new gradients in a walker batch, \f$\nabla\ln\Psi\f$
*/
virtual void mw_ratioGrad(const RefVector<WaveFunctionComponent>& WFC_list,
const RefVector<ParticleSet>& P_list,
int iat,
std::vector<PsiValueType>& ratios,
std::vector<GradType>& grad_new)
{
#pragma omp parallel for
for (int iw = 0; iw < WFC_list.size(); iw++)
ratios[iw] = WFC_list[iw].get().ratioGrad(P_list[iw], iat, grad_new[iw]);
}
/** a move for iat-th particle is accepted. Update the current content.
* @param P target ParticleSet
* @param iat index of the particle whose new position was proposed
* @param safe_to_delay if true, delayed accept is safe.
*/
virtual void acceptMove(ParticleSet& P, int iat, bool safe_to_delay = false) = 0;
/** moves of the iat-th particle on some walkers in a batch is accepted. Update the current content.
* Note that all the lists only include accepted walkers.
* @param WFC_list the list of WaveFunctionComponent pointers of the same component in a walker batch
* @param P_list the list of ParticleSet pointers in a walker batch
* @param iat particle index
* @param safe_to_delay if true, delayed accept is safe.
*/
virtual void mw_accept_rejectMove(const RefVector<WaveFunctionComponent>& WFC_list,
const RefVector<ParticleSet>& P_list,
int iat,
const std::vector<bool>& isAccepted,
bool safe_to_delay = false)
{
#pragma omp parallel for
for (int iw = 0; iw < WFC_list.size(); iw++)
if (isAccepted[iw])
WFC_list[iw].get().acceptMove(P_list[iw], iat, safe_to_delay);
else
WFC_list[iw].get().restore(iat);
}
/** complete all the delayed updates, must be called after each substep or step during pbyp move
*/
virtual void completeUpdates() {}
/** complete all the delayed updates for all the walkers in a batch
* must be called after each substep or step during pbyp move
*/
virtual void mw_completeUpdates(const RefVector<WaveFunctionComponent>& WFC_list)
{
#pragma omp parallel for
for (int iw = 0; iw < WFC_list.size(); iw++)
WFC_list[iw].get().completeUpdates();
}
/** If a move for iat-th particle is rejected, restore to the content.
* @param iat index of the particle whose new position was proposed
*
* Ye: hopefully we can gradually move away from restore
*/
virtual void restore(int iat) = 0;
/** evaluate the ratio of the new to old WaveFunctionComponent value
* @param P the active ParticleSet
* @param iat the index of a particle
* @return \f$ \psi( \{ {\bf R}^{'} \} )/ \psi( \{ {\bf R}\})\f$
*
* Specialized for particle-by-particle move
*/
virtual PsiValueType ratio(ParticleSet& P, int iat) = 0;
/** compute the ratio of the new to old WaveFunctionComponent value of multiple walkers
* @param WFC_list the list of WaveFunctionComponent pointers of the same component in a walker batch
* @param P_list the list of ParticleSet pointers in a walker batch
* @param iat particle index
* @param ratios the list of WF ratios of a walker batch, \f$ \Psi( \{ {\bf R}^{'} \} )/ \Psi( \{ {\bf R}\})\f$
*/
virtual void mw_calcRatio(const RefVector<WaveFunctionComponent>& WFC_list,
const RefVector<ParticleSet>& P_list,
int iat,
std::vector<PsiValueType>& ratios)
{
#pragma omp parallel for
for (int iw = 0; iw < WFC_list.size(); iw++)
ratios[iw] = WFC_list[iw].get().ratio(P_list[iw], iat);
}
/** For particle-by-particle move. Requests space in the buffer
* based on the data type sizes of the objects in this class.
* @param P particle set
* @param buf Anonymous storage
*/
virtual void registerData(ParticleSet& P, WFBufferType& buf) = 0;
/** For particle-by-particle move. Requests space in the buffer
* based on the data type sizes of the objects in this class.
* @param WFC_list the list of WaveFunctionComponent pointers of the same component in a walker batch
* @param P_list the list of ParticleSet pointers in a walker batch
* @param buf_list Anonymous storage
*/
virtual void mw_registerData(const std::vector<WaveFunctionComponent*>& WFC_list,
const std::vector<ParticleSet*>& P_list,
const RefVector<WFBufferType>& buf_list)
{
// We can't make this static but we can use a lambda with no capture to
// restrict access to *this scope
auto registerComponentData = [](WaveFunctionComponent& wfc, ParticleSet& pset, WFBufferType& wfb) {
wfc.registerData(pset, wfb);
};
for (int iw = 0; iw < WFC_list.size(); iw++)
registerComponentData(*(WFC_list[iw]), *(P_list[iw]), buf_list[iw]);
}
/** For particle-by-particle move. Put the objects of this class
* in the walker buffer or forward the memory cursor.
* @param P particle set
* @param buf Anonymous storage
* @param fromscratch request recomputing the precision critical
* pieces of wavefunction from scratch
* @return log value of the wavefunction.
*/
virtual LogValueType updateBuffer(ParticleSet& P, WFBufferType& buf, bool fromscratch = false) = 0;
/** For particle-by-particle move. Put the objects of this class
* in the walker buffer or forward the memory cursor.
* @param WFC_list the list of WaveFunctionComponent pointers of the same component in a walker batch
* @param P_list the list of ParticleSet pointers in a walker batch
* @param buf_list Anonymous storage
* @@param values the log WF values of walkers in a batch
* @param fromscratch request recomputing the precision critical
* pieces of wavefunction from scratch
*/
virtual void mw_updateBuffer(const RefVector<WaveFunctionComponent>& WFC_list,
const RefVector<ParticleSet>& P_list,
const RefVector<WFBufferType>& buf_list,
bool fromscratch = false)
{
#pragma omp parallel for
for (int iw = 0; iw < WFC_list.size(); iw++)
WFC_list[iw].get().updateBuffer(P_list[iw], buf_list[iw], fromscratch);
}
/** For particle-by-particle move. Copy data or attach memory
* from a walker buffer to the objects of this class.
* The log value, P.G and P.L contribution from the objects
* of this class are also added.
* @param P particle set
* @param buf Anonymous storage
*/
virtual void copyFromBuffer(ParticleSet& P, WFBufferType& buf) = 0;
/** For particle-by-particle move. Copy data or attach memory
* from a walker buffer to the objects of this class.
* @param P particle set
* @param buf Anonymous storage
*/
virtual void mw_copyFromBuffer(const RefVector<WaveFunctionComponent>& wfc_list,
const RefVector<ParticleSet>& p_list,
const RefVector<WFBufferType>& buf_list)
{
#pragma omp parallel for
for (int iw = 0; iw < wfc_list.size(); iw++)
wfc_list[iw].get().copyFromBuffer(p_list[iw], buf_list[iw]);
}
/** make clone
* @param tqp target Quantum ParticleSet
* @param deepcopy if true, make a decopy
*
* If not true, return a proxy class
*/
virtual WaveFunctionComponentPtr makeClone(ParticleSet& tqp) const;
/** Intended as a handle to break
*
*
*/
//virtual WaveFunctionComponentPtr makeThrScope(std::vector<std::pair<int,int>>& ptcl_group_indexes) const = 0;
/** Return the Chiesa kinetic energy correction
*/
virtual RealType KECorrection();
/** Compute derivatives of the wavefunction with respect to the optimizable
* parameters.
* @param P particle set
* @param optvars optimizable parameters
* @param dlogpsi array of derivatives of the log of the wavefunction
* @param dhpsioverpsi array of derivatives of the Laplacian of the wavefunction divided by the wavefunction.
* Note that this does not use the Laplacian of the log of the wavefunction, as in evaluateLog.
* Also the factor of -1/2 from the kinetic energy must be included here. The 1/m
* factor is applied in TrialWaveFunction.
*/
virtual void evaluateDerivatives(ParticleSet& P,
const opt_variables_type& optvars,
std::vector<ValueType>& dlogpsi,
std::vector<ValueType>& dhpsioverpsi);
/** Compute derivatives of rhe wavefunction with respect to the optimizable
* parameters
* @param P particle set
* @param optvars optimizable parameters
* @param dlogpsi array of derivatives of the log of the wavefunction
* Note: this function differs from the evaluateDerivatives function in the way that it only computes
* the derivative of the log of the wavefunction.
*/
virtual void evaluateDerivativesWF(ParticleSet& P,
const opt_variables_type& optvars,
std::vector<ValueType>& dlogpsi);
virtual void multiplyDerivsByOrbR(std::vector<ValueType>& dlogpsi)
{
RealType myrat = std::real(LogToValue<PsiValueType>::convert(LogValue));
for (int j = 0; j < myVars.size(); j++)
{
int loc = myVars.where(j);
dlogpsi[loc] *= myrat;
}
}
/** Calculates the derivatives of \f$ \grad(\textrm{log}(\psif)) \f$ with respect to
the optimizable parameters, and the dot product of this is then
performed with the passed-in G_in gradient vector. This object is then
returned as dgradlogpsi.
*/
virtual void evaluateGradDerivatives(const ParticleSet::ParticleGradient_t& G_in, std::vector<ValueType>& dgradlogpsi)
{
APP_ABORT("Need specialization of WaveFunctionComponent::evaluateGradDerivatives in " + ClassName + " class.\n");
}
virtual void finalizeOptimization() {}
/** evaluate the ratios of one virtual move with respect to all the particles
* @param P reference particleset
* @param ratios \f$ ratios[i]=\{{\bf R}\}\rightarrow {r_0,\cdots,r_i^p=pos,\cdots,r_{N-1}}\f$
*/
virtual void evaluateRatiosAlltoOne(ParticleSet& P, std::vector<ValueType>& ratios);
/** evaluate ratios to evaluate the non-local PP
* @param VP VirtualParticleSet
* @param ratios ratios with new positions VP.R[k] the VP.refPtcl
*/
virtual void evaluateRatios(const VirtualParticleSet& VP, std::vector<ValueType>& ratios);
/** evaluate ratios to evaluate the non-local PP multiple walkers
* @param wfc_list the list of WaveFunctionComponent references of the same component in a walker batch
* @param vp_list the list of VirtualParticleSet references in a walker batch
* @param ratios of all the virtual moves of all the walkers
*/
virtual void mw_evaluateRatios(const RefVector<WaveFunctionComponent>& wfc_list,
const RefVector<const VirtualParticleSet>& vp_list,
std::vector<std::vector<ValueType>>& ratios)
{
#pragma omp parallel for
for (int iw = 0; iw < wfc_list.size(); iw++)
wfc_list[iw].get().evaluateRatios(vp_list[iw], ratios[iw]);
}
/** evaluate ratios to evaluate the non-local PP
* @param VP VirtualParticleSet
* @param ratios ratios with new positions VP.R[k] the VP.refPtcl
* @param dratios \f$\partial_{\alpha}(\ln \Psi ({\bf R}^{\prime}) - \ln \Psi ({\bf R})) \f$
*/
virtual void evaluateDerivRatios(VirtualParticleSet& VP,
const opt_variables_type& optvars,
std::vector<ValueType>& ratios,
Matrix<ValueType>& dratios);
/////////////////////////////////////////////////////
// Functions for vectorized evaluation and updates //
/////////////////////////////////////////////////////
#ifdef QMC_CUDA
using CTS = CUDAGlobalTypes;
virtual void freeGPUmem() {}
virtual void recompute(MCWalkerConfiguration& W, bool firstTime) {}
virtual void reserve(PointerPool<gpu::device_vector<CTS::ValueType>>& pool, int kblocksize) {}
/** Evaluate the log of the WF for all walkers
* @param walkers vector of all walkers
* @param logPsi output vector of log(psi)
*/
virtual void addLog(MCWalkerConfiguration& W, std::vector<RealType>& logPsi)
{
APP_ABORT("Need specialization of WaveFunctionComponent::addLog for " + ClassName +
".\n Required CUDA functionality not implemented. Contact developers.\n");
}
/** Evaluate the wave-function ratio w.r.t. moving particle iat
* for all walkers
* @param walkers vector of all walkers
* @param iat particle which is moving
* @param psi_ratios output vector with psi_new/psi_old
*/
virtual void ratio(MCWalkerConfiguration& W, int iat, std::vector<ValueType>& psi_ratios)
{
APP_ABORT("Need specialization of WaveFunctionComponent::ratio for " + ClassName +
".\n Required CUDA functionality not implemented. Contact developers.\n");
}
// Returns the WF ratio and gradient w.r.t. iat for each walker
// in the respective vectors
virtual void ratio(MCWalkerConfiguration& W, int iat, std::vector<ValueType>& psi_ratios, std::vector<GradType>& grad)
{
APP_ABORT("Need specialization of WaveFunctionComponent::ratio for " + ClassName +
".\n Required CUDA functionality not implemented. Contact developers.\n");
}
virtual void ratio(MCWalkerConfiguration& W,
int iat,
std::vector<ValueType>& psi_ratios,
std::vector<GradType>& grad,
std::vector<ValueType>& lapl)
{
APP_ABORT("Need specialization of WaveFunctionComponent::ratio for " + ClassName +
".\n Required CUDA functionality not implemented. Contact developers.\n");
}
virtual void calcRatio(MCWalkerConfiguration& W,
int iat,
std::vector<ValueType>& psi_ratios,
std::vector<GradType>& grad,
std::vector<ValueType>& lapl)
{
APP_ABORT("Need specialization of WaveFunctionComponent::calcRatio for " + ClassName +
".\n Required CUDA functionality not implemented. Contact developers.\n");
}
virtual void addRatio(MCWalkerConfiguration& W,
int iat,
int k,
std::vector<ValueType>& psi_ratios,
std::vector<GradType>& grad,
std::vector<ValueType>& lapl)
{
APP_ABORT("Need specialization of WaveFunctionComponent::addRatio for " + ClassName +
".\n Required CUDA functionality not implemented. Contact developers.\n");
}
virtual void ratio(std::vector<Walker_t*>& walkers,
std::vector<int>& iatList,
std::vector<PosType>& rNew,
std::vector<ValueType>& psi_ratios,
std::vector<GradType>& grad,
std::vector<ValueType>& lapl)
{
APP_ABORT("Need specialization of WaveFunctionComponent::ratio for " + ClassName +
".\n Required CUDA functionality not implemented. Contact developers.\n");
}
virtual void addGradient(MCWalkerConfiguration& W, int iat, std::vector<GradType>& grad)
{
APP_ABORT("Need specialization of WaveFunctionComponent::addGradient for " + ClassName +
".\n Required CUDA functionality not implemented. Contact developers.\n");
}
virtual void calcGradient(MCWalkerConfiguration& W, int iat, int k, std::vector<GradType>& grad)
{
APP_ABORT("Need specialization of WaveFunctionComponent::calcGradient for " + ClassName +
".\n Required CUDA functionality not implemented. Contact developers.\n");
}
virtual void gradLapl(MCWalkerConfiguration& W, GradMatrix_t& grads, ValueMatrix_t& lapl)
{
APP_ABORT("Need specialization of WaveFunctionComponent::gradLapl for " + ClassName +
".\n Required CUDA functionality not implemented. Contact developers.\n");
}
virtual void det_lookahead(MCWalkerConfiguration& W,
std::vector<ValueType>& psi_ratios,
std::vector<GradType>& grad,
std::vector<ValueType>& lapl,
int iat,
int k,
int kd,
int nw)
{
APP_ABORT("Need specialization of WaveFunctionComponent::det_lookahead for " + ClassName +
".\n Required CUDA functionality not implemented. Contact developers.\n");
}
virtual void update(MCWalkerConfiguration* W, std::vector<Walker_t*>& walkers, int iat, std::vector<bool>* acc, int k)
{
APP_ABORT("Need specialization of WaveFunctionComponent::update for " + ClassName +
".\n Required CUDA functionality not implemented. Contact developers.\n");
}
virtual void update(const std::vector<Walker_t*>& walkers, const std::vector<int>& iatList)
{
APP_ABORT("Need specialization of WaveFunctionComponent::update for " + ClassName +
".\n Required CUDA functionality not implemented. Contact developers.\n");
}
virtual void NLratios(MCWalkerConfiguration& W,
std::vector<NLjob>& jobList,
std::vector<PosType>& quadPoints,
std::vector<ValueType>& psi_ratios)
{
APP_ABORT("Need specialization of WaveFunctionComponent::NLRatios for " + ClassName +
".\n Required CUDA functionality not implemented. Contact developers.\n");
}
virtual void NLratios(MCWalkerConfiguration& W,
gpu::device_vector<CUDA_PRECISION*>& Rlist,
gpu::device_vector<int*>& ElecList,
gpu::device_vector<int>& NumCoreElecs,
gpu::device_vector<CUDA_PRECISION*>& QuadPosList,
gpu::device_vector<CUDA_PRECISION*>& RatioList,
int numQuadPoints)
{
APP_ABORT("Need specialization of WaveFunctionComponent::NLRatios for " + ClassName +
".\n Required CUDA functionality not implemented. Contact developers.\n");
}
virtual void evaluateDerivatives(MCWalkerConfiguration& W,
const opt_variables_type& optvars,
RealMatrix_t& dgrad_logpsi,
RealMatrix_t& dhpsi_over_psi)
{
APP_ABORT("Need specialization of WaveFunctionComponent::evaluateDerivatives for " + ClassName +
".\n Required CUDA functionality not implemented. Contact developers.\n");
}
#endif
};
} // namespace qmcplusplus
#endif
| 42.646586 | 120 | 0.663747 |
3d1b472c876717c32a904bfa3b402d351896ffe8 | 4,533 | c | C | src/fs/xfs/xfsprogs-dev/db/agf.c | fengjixuchui/hydra | d49e652018a007bae9d22cb59dfa086deff7ad2f | [
"MIT"
] | 110 | 2019-08-21T04:23:22.000Z | 2022-01-20T16:08:36.000Z | src/fs/xfs/xfsprogs-dev/db/agf.c | fengjixuchui/hydra | d49e652018a007bae9d22cb59dfa086deff7ad2f | [
"MIT"
] | 16 | 2019-11-19T03:46:35.000Z | 2021-12-19T19:26:07.000Z | src/fs/xfs/xfsprogs-dev/db/agf.c | fengjixuchui/hydra | d49e652018a007bae9d22cb59dfa086deff7ad2f | [
"MIT"
] | 24 | 2019-09-30T21:38:08.000Z | 2021-11-22T00:22:18.000Z | /*
* Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
* 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.
*
* This program is distributed in the hope that it would 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 the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libxfs.h"
#include "command.h"
#include "type.h"
#include "faddr.h"
#include "fprint.h"
#include "field.h"
#include "io.h"
#include "bit.h"
#include "output.h"
#include "init.h"
#include "agf.h"
static int agf_f(int argc, char **argv);
static void agf_help(void);
static const cmdinfo_t agf_cmd =
{ "agf", NULL, agf_f, 0, 1, 1, N_("[agno]"),
N_("set address to agf header"), agf_help };
const field_t agf_hfld[] = {
{ "", FLDT_AGF, OI(0), C1, 0, TYP_NONE },
{ NULL }
};
#define OFF(f) bitize(offsetof(xfs_agf_t, agf_ ## f))
#define SZ(f) bitszof(xfs_agf_t, agf_ ## f)
const field_t agf_flds[] = {
{ "magicnum", FLDT_UINT32X, OI(OFF(magicnum)), C1, 0, TYP_NONE },
{ "versionnum", FLDT_UINT32D, OI(OFF(versionnum)), C1, 0, TYP_NONE },
{ "seqno", FLDT_AGNUMBER, OI(OFF(seqno)), C1, 0, TYP_NONE },
{ "length", FLDT_AGBLOCK, OI(OFF(length)), C1, 0, TYP_NONE },
{ "roots", FLDT_AGBLOCK, OI(OFF(roots)), CI(XFS_BTNUM_AGF),
FLD_ARRAY|FLD_SKIPALL, TYP_NONE },
{ "bnoroot", FLDT_AGBLOCK,
OI(OFF(roots) + XFS_BTNUM_BNO * SZ(roots[XFS_BTNUM_BNO])), C1, 0,
TYP_BNOBT },
{ "cntroot", FLDT_AGBLOCK,
OI(OFF(roots) + XFS_BTNUM_CNT * SZ(roots[XFS_BTNUM_CNT])), C1, 0,
TYP_CNTBT },
{ "rmaproot", FLDT_AGBLOCKNZ,
OI(OFF(roots) + XFS_BTNUM_RMAP * SZ(roots[XFS_BTNUM_RMAP])), C1, 0,
TYP_RMAPBT },
{ "refcntroot", FLDT_AGBLOCKNZ,
OI(OFF(refcount_root)), C1, 0,
TYP_REFCBT },
{ "levels", FLDT_UINT32D, OI(OFF(levels)), CI(XFS_BTNUM_AGF),
FLD_ARRAY|FLD_SKIPALL, TYP_NONE },
{ "bnolevel", FLDT_UINT32D,
OI(OFF(levels) + XFS_BTNUM_BNO * SZ(levels[XFS_BTNUM_BNO])), C1, 0,
TYP_NONE },
{ "cntlevel", FLDT_UINT32D,
OI(OFF(levels) + XFS_BTNUM_CNT * SZ(levels[XFS_BTNUM_CNT])), C1, 0,
TYP_NONE },
{ "rmaplevel", FLDT_UINT32D,
OI(OFF(levels) + XFS_BTNUM_RMAP * SZ(levels[XFS_BTNUM_RMAP])), C1, 0,
TYP_NONE },
{ "refcntlevel", FLDT_UINT32D,
OI(OFF(refcount_level)), C1, 0,
TYP_NONE },
{ "rmapblocks", FLDT_UINT32D,
OI(OFF(rmap_blocks)), C1, 0,
TYP_NONE },
{ "refcntblocks", FLDT_UINT32D,
OI(OFF(refcount_blocks)), C1, 0,
TYP_NONE },
{ "flfirst", FLDT_UINT32D, OI(OFF(flfirst)), C1, 0, TYP_NONE },
{ "fllast", FLDT_UINT32D, OI(OFF(fllast)), C1, 0, TYP_NONE },
{ "flcount", FLDT_UINT32D, OI(OFF(flcount)), C1, 0, TYP_NONE },
{ "freeblks", FLDT_EXTLEN, OI(OFF(freeblks)), C1, 0, TYP_NONE },
{ "longest", FLDT_EXTLEN, OI(OFF(longest)), C1, 0, TYP_NONE },
{ "btreeblks", FLDT_UINT32D, OI(OFF(btreeblks)), C1, 0, TYP_NONE },
{ "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE },
{ "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE },
{ "crc", FLDT_CRC, OI(OFF(crc)), C1, 0, TYP_NONE },
{ NULL }
};
static void
agf_help(void)
{
dbprintf(_(
"\n"
" set allocation group free block list\n"
"\n"
" Example:\n"
"\n"
" agf 2 - move location to AGF in 2nd filesystem allocation group\n"
"\n"
" Located in the second sector of each allocation group, the AGF\n"
" contains the root of two different freespace btrees:\n"
" The 'cnt' btree keeps track freespace indexed on section size.\n"
" The 'bno' btree tracks sections of freespace indexed on block number.\n"
));
}
static int
agf_f(
int argc,
char **argv)
{
xfs_agnumber_t agno;
char *p;
if (argc > 1) {
agno = (xfs_agnumber_t)strtoul(argv[1], &p, 0);
if (*p != '\0' || agno >= mp->m_sb.sb_agcount) {
dbprintf(_("bad allocation group number %s\n"), argv[1]);
return 0;
}
cur_agno = agno;
} else if (cur_agno == NULLAGNUMBER)
cur_agno = 0;
ASSERT(typtab[TYP_AGF].typnm == TYP_AGF);
set_cur(&typtab[TYP_AGF],
XFS_AG_DADDR(mp, cur_agno, XFS_AGF_DADDR(mp)),
XFS_FSS_TO_BB(mp, 1), DB_RING_ADD, NULL);
return 0;
}
void
agf_init(void)
{
add_command(&agf_cmd);
}
int
agf_size(
void *obj,
int startoff,
int idx)
{
return bitize(mp->m_sb.sb_sectsize);
}
| 29.822368 | 74 | 0.672182 |
368033014bb6e19a739af8f6f552c483b059c665 | 1,997 | h | C | ios/versioned-react-native/ABI32_0_0/ReactCommon/ABI32_0_0fabric/attributedstring/ABI32_0_0AttributedString.h | ThakurKarthik/expo | ed78ed4f07c950184a59422ebd95645253f44e3d | [
"Apache-2.0",
"MIT"
] | 2 | 2019-08-15T19:24:41.000Z | 2020-09-28T00:44:04.000Z | ios/versioned-react-native/ABI32_0_0/ReactCommon/ABI32_0_0fabric/attributedstring/ABI32_0_0AttributedString.h | ThakurKarthik/expo | ed78ed4f07c950184a59422ebd95645253f44e3d | [
"Apache-2.0",
"MIT"
] | 19 | 2020-04-07T07:36:24.000Z | 2022-03-26T09:32:12.000Z | ios/versioned-react-native/ABI32_0_0/ReactCommon/ABI32_0_0fabric/attributedstring/ABI32_0_0AttributedString.h | ThakurKarthik/expo | ed78ed4f07c950184a59422ebd95645253f44e3d | [
"Apache-2.0",
"MIT"
] | 1 | 2020-03-01T01:28:59.000Z | 2020-03-01T01:28:59.000Z | /**
* Copyright (c) 2015-present, Facebook, Inc.
*
* 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 <memory>
#include <ABI32_0_0fabric/ABI32_0_0attributedstring/TextAttributes.h>
#include <ABI32_0_0fabric/ABI32_0_0core/Sealable.h>
#include <ABI32_0_0fabric/ABI32_0_0core/ShadowNode.h>
#include <ABI32_0_0fabric/ABI32_0_0debug/DebugStringConvertible.h>
#include <folly/Optional.h>
namespace facebook {
namespace ReactABI32_0_0 {
class AttributedString;
using SharedAttributedString = std::shared_ptr<const AttributedString>;
/*
* Simple, cross-platfrom, ReactABI32_0_0-specific implementation of attributed string
* (aka spanned string).
* `AttributedString` is basically a list of `Fragments` which have `string` and
* `textAttributes` + `shadowNode` associated with the `string`.
*/
class AttributedString:
public Sealable,
public DebugStringConvertible {
public:
class Fragment {
public:
std::string string;
TextAttributes textAttributes;
SharedShadowNode shadowNode;
};
using Fragments = std::vector<Fragment>;
/*
* Appends and prepends a `fragment` to the string.
*/
void appendFragment(const Fragment &fragment);
void prependFragment(const Fragment &fragment);
/*
* Appends and prepends an `attributedString` (all its fragments) to
* the string.
*/
void appendAttributedString(const AttributedString &attributedString);
void prependAttributedString(const AttributedString &attributedString);
/*
* Returns read-only reference to a list of fragments.
*/
const Fragments &getFragments() const;
/*
* Returns a string constructed from all strings in all fragments.
*/
std::string getString() const;
#pragma mark - DebugStringConvertible
SharedDebugStringConvertibleList getDebugChildren() const override;
private:
Fragments fragments_;
};
} // namespace ReactABI32_0_0
} // namespace facebook
| 24.9625 | 86 | 0.75363 |
d21d4a264618972f8fd33ae6347ee5770044f86c | 1,119 | h | C | MBB1Yes2/MBB1/LoginUserResult.h | yanalucky/MBB | 90d300d57a2716e0444905395c11c686ebb29079 | [
"Apache-2.0"
] | null | null | null | MBB1Yes2/MBB1/LoginUserResult.h | yanalucky/MBB | 90d300d57a2716e0444905395c11c686ebb29079 | [
"Apache-2.0"
] | null | null | null | MBB1Yes2/MBB1/LoginUserResult.h | yanalucky/MBB | 90d300d57a2716e0444905395c11c686ebb29079 | [
"Apache-2.0"
] | null | null | null | //
// LoginUserResult.h
//
// Created by 豆蒙萌 on 15/10/14
// Copyright (c) 2015 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@class LoginUserTreatBooking, LoginUserOnlineAppraisal, LoginUserBodycheckBooking, LoginUserUser, LoginUserUserRecord;
@interface LoginUserResult : NSObject <NSCoding, NSCopying>
@property (nonatomic, strong) LoginUserTreatBooking *treatBooking;
@property (nonatomic, strong) NSArray *nurtureGuideList;
@property (nonatomic, strong) NSArray *userSalonList;
@property (nonatomic, strong) LoginUserOnlineAppraisal *onlineAppraisal;
@property (nonatomic, strong) LoginUserBodycheckBooking *bodycheckBooking;
@property (nonatomic, strong) NSArray *salonList;
@property (nonatomic, strong) NSString *sessionId;
@property (nonatomic, strong) LoginUserUser *user;
@property (nonatomic, strong) NSArray *bodycheckAppraisalList;
@property (nonatomic, strong) LoginUserUserRecord *userRecord;
+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict;
- (instancetype)initWithDictionary:(NSDictionary *)dict;
- (NSDictionary *)dictionaryRepresentation;
@end
| 37.3 | 118 | 0.803396 |
d25b5229307cbd481c259366522d984cb232cdda | 7,391 | c | C | src/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/BasicMathFunctions/arm_elementwise_add_s8.c | onderbedirhan/Arduino_TensorFlowLite-2.1.0 | 21582d4cbaec104dfa3dfd780d12ee91eced7d37 | [
"Apache-2.0"
] | 17 | 2021-07-19T08:01:19.000Z | 2021-09-05T13:23:52.000Z | arduino_x86_64/prj/person_detection_int8/tensorflow_lite/src/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/BasicMathFunctions/arm_elementwise_add_s8.c | BTS-MicroNet/BTS-magic-wand | 56869e6cf48893a06b529a892325fcf19b8ea17f | [
"MIT"
] | null | null | null | arduino_x86_64/prj/person_detection_int8/tensorflow_lite/src/tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Source/BasicMathFunctions/arm_elementwise_add_s8.c | BTS-MicroNet/BTS-magic-wand | 56869e6cf48893a06b529a892325fcf19b8ea17f | [
"MIT"
] | null | null | null | /*
* Copyright (C) 2010-2020 Arm Limited or its affiliates. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* 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
*
* 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.
*/
/* ----------------------------------------------------------------------
* Project: CMSIS NN Library
* Title: arm_elementwise_add_s8
* Description: Element wise add
*
* $Date: February 27, 2020
* $Revision: V.2.0.1
*
* Target Processor: Cortex-M cores
*
* -------------------------------------------------------------------- */
#include "tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/DSP/Include/arm_math.h"
#include "tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Include/arm_nnfunctions.h"
#include "tensorflow/lite/micro/tools/make/downloads/cmsis/CMSIS/NN/Include/arm_nnsupportfunctions.h"
#if defined(ARM_MATH_MVEI)
#include "arm_helium_utils.h"
#endif
#if defined(ARM_MATH_MVEI)
#define SAT_INPUT_VECT(__INPUT_V, __MULT, __SHIFT) \
__INPUT_V = arm_sat_doubling_high_mult_mve(__INPUT_V, __MULT); \
__INPUT_V = arm_divide_by_power_of_two_mve(__INPUT_V, -__SHIFT);
#endif
#define SAT_INPUT(__INPUT, __MULT, __SHIFT) \
__INPUT = arm_nn_sat_doubling_high_mult(__INPUT, __MULT); \
__INPUT = arm_nn_divide_by_power_of_two(__INPUT, -__SHIFT);
/**
* @ingroup groupNN
*/
/**
* @addtogroup BasicMath
* @{
*/
/*
* s8 element wise add
*
* Refer header file for details.
*
*/
/* Note: __SHIFT is expected to be <=0 */
arm_status
arm_elementwise_add_s8(const int8_t *input_1_vect,
const int8_t *input_2_vect,
const int32_t input_1_offset,
const int32_t input_1_mult,
const int32_t input_1_shift,
const int32_t input_2_offset,
const int32_t input_2_mult,
const int32_t input_2_shift,
const int32_t left_shift,
int8_t *output,
const int32_t out_offset,
const int32_t out_mult,
const int32_t out_shift,
const int32_t out_activation_min,
const int32_t out_activation_max,
const uint32_t block_size)
{
#if defined(ARM_MATH_MVEI)
int32_t count = (int32_t)block_size;
while (count > 0)
{
int32x4_t vect_1;
int32x4_t vect_2;
mve_pred16_t p = vctp32q((uint32_t)count);
vect_1 = vldrbq_z_s32(input_1_vect, p);
vect_2 = vldrbq_z_s32(input_2_vect, p);
vect_1 = vaddq_s32(vect_1, vdupq_n_s32(input_1_offset));
vect_2 = vaddq_s32(vect_2, vdupq_n_s32(input_2_offset));
vect_1 = vshlq_r_s32(vect_1, left_shift);
vect_2 = vshlq_r_s32(vect_2, left_shift);
SAT_INPUT_VECT(vect_1, input_1_mult, input_1_shift);
SAT_INPUT_VECT(vect_2, input_2_mult, input_2_shift);
vect_1 = vaddq_s32(vect_1, vect_2);
SAT_INPUT_VECT(vect_1, out_mult, out_shift);
vect_1 = vaddq_n_s32(vect_1, out_offset);
vect_1 = vmaxq_s32(vect_1, vdupq_n_s32(out_activation_min));
vect_1 = vminq_s32(vect_1, vdupq_n_s32(out_activation_max));
input_1_vect += 4;
input_2_vect += 4;
vstrbq_p_s32(output, vect_1, p);
output += 4;
count -= 4;
}
#else
uint32_t loop_count;
int32_t input_1;
int32_t input_2;
int32_t sum;
#if defined(ARM_MATH_DSP)
int32_t a_1, b_1, a_2, b_2;
int32_t offset_1_packed, offset_2_packed;
int8_t r1, r2, r3, r4;
offset_1_packed = (input_1_offset << 16U) | (input_1_offset & 0x0FFFFL);
offset_2_packed = (input_2_offset << 16U) | (input_2_offset & 0x0FFFFL);
loop_count = block_size >> 2;
while (loop_count > 0U)
{
/* 4 outputs are calculated in one loop. The order of calculation is follows the order of output sign extension
intrinsic */
input_1_vect = read_and_pad_reordered(input_1_vect, &b_1, &a_1);
input_2_vect = read_and_pad_reordered(input_2_vect, &b_2, &a_2);
a_1 = __SADD16(a_1, offset_1_packed);
b_1 = __SADD16(b_1, offset_1_packed);
a_2 = __SADD16(a_2, offset_2_packed);
b_2 = __SADD16(b_2, offset_2_packed);
/* Sum 1 */
input_1 = (int16_t)(b_1 & 0x0FFFFL) << left_shift;
SAT_INPUT(input_1, input_1_mult, input_1_shift);
input_2 = (int16_t)(b_2 & 0x0FFFFL) << left_shift;
SAT_INPUT(input_2, input_2_mult, input_2_shift);
sum = input_1 + input_2;
SAT_INPUT(sum, out_mult, out_shift);
sum += out_offset;
sum = MAX(sum, out_activation_min);
sum = MIN(sum, out_activation_max);
r1 = (q7_t)sum;
/* Sum 3 */
input_1 = (int16_t)((b_1 >> 16) & 0x0FFFFL) << left_shift;
SAT_INPUT(input_1, input_1_mult, input_1_shift);
input_2 = (int16_t)((b_2 >> 16) & 0x0FFFFL) << left_shift;
SAT_INPUT(input_2, input_2_mult, input_2_shift);
sum = input_1 + input_2;
SAT_INPUT(sum, out_mult, out_shift);
sum += out_offset;
sum = MAX(sum, out_activation_min);
sum = MIN(sum, out_activation_max);
r3 = (q7_t)sum;
/* Sum 2 */
input_1 = (int16_t)(a_1 & 0x0FFFFL) << left_shift;
SAT_INPUT(input_1, input_1_mult, input_1_shift);
input_2 = (int16_t)(a_2 & 0x0FFFFL) << left_shift;
SAT_INPUT(input_2, input_2_mult, input_2_shift);
sum = input_1 + input_2;
SAT_INPUT(sum, out_mult, out_shift);
sum += out_offset;
sum = MAX(sum, out_activation_min);
sum = MIN(sum, out_activation_max);
r2 = (q7_t)sum;
/* Sum 4 */
input_1 = (int16_t)((a_1 >> 16) & 0x0FFFFL) << left_shift;
SAT_INPUT(input_1, input_1_mult, input_1_shift);
input_2 = (int16_t)((a_2 >> 16) & 0x0FFFFL) << left_shift;
SAT_INPUT(input_2, input_2_mult, input_2_shift);
sum = input_1 + input_2;
SAT_INPUT(sum, out_mult, out_shift);
sum += out_offset;
sum = MAX(sum, out_activation_min);
sum = MIN(sum, out_activation_max);
r4 = (q7_t)sum;
write_q7x4_ia(&output, __PACKq7(r1, r2, r3, r4));
loop_count--;
}
loop_count = block_size & 0x3;
#else
loop_count = block_size;
#endif
while (loop_count > 0U)
{
/* C = A + B */
input_1 = (*input_1_vect++ + input_1_offset) << left_shift;
input_2 = (*input_2_vect++ + input_2_offset) << left_shift;
input_1 = arm_nn_sat_doubling_high_mult(input_1, input_1_mult);
input_1 = arm_nn_divide_by_power_of_two(input_1, -input_1_shift);
input_2 = arm_nn_sat_doubling_high_mult(input_2, input_2_mult);
input_2 = arm_nn_divide_by_power_of_two(input_2, -input_2_shift);
sum = input_1 + input_2;
SAT_INPUT(sum, out_mult, out_shift);
sum += out_offset;
sum = MAX(sum, out_activation_min);
sum = MIN(sum, out_activation_max);
*output++ = (q7_t)sum;
/* Decrement loop counter */
loop_count--;
}
#endif /* ARM_MATH_MVEI */
return (ARM_MATH_SUCCESS);
}
/**
* @} end of BasicMath group
*/
| 29.213439 | 115 | 0.650927 |
a9e9db86f3ab8a928b4154f37b92d8298ce89634 | 1,952 | c | C | component/common/example/rarp/example_rarp.c | AdamZhang0124/ambd_sdk_with_chip_non_NDA | 8b5ca7ef7433833f40e6a87ce20d41f92896e2b7 | [
"Apache-2.0"
] | 11 | 2020-05-22T14:54:41.000Z | 2021-09-29T02:32:03.000Z | component/common/example/rarp/example_rarp.c | AdamZhang0124/ambd_sdk_with_chip_non_NDA | 8b5ca7ef7433833f40e6a87ce20d41f92896e2b7 | [
"Apache-2.0"
] | 2 | 2020-07-18T11:02:34.000Z | 2020-09-23T08:23:38.000Z | component/common/example/rarp/example_rarp.c | AdamZhang0124/ambd_sdk_with_chip_non_NDA | 8b5ca7ef7433833f40e6a87ce20d41f92896e2b7 | [
"Apache-2.0"
] | 7 | 2020-05-24T10:28:48.000Z | 2021-06-15T16:35:38.000Z | #include "FreeRTOS.h"
#include "task.h"
#if defined(LWIP_VERSION_MAJOR) && (LWIP_VERSION_MAJOR >= 2)
#include <etharp.h>
#else
#include <netif/etharp.h>
#endif
#include "wifi_conf.h"
#define RARP_THREAD_STACK_SIZE 1024
const struct eth_addr macbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}};
extern struct netif xnetif[NET_IF_NUM];
void rarp_retrieve(uint8_t *rarp_ip, uint8_t *rarp_mac) {
printf("\n\rThe IP of device %02x:%02x:%02x:%02x:%02x:%02x is: %d.%d.%d.%d\r\n",
rarp_mac[0], rarp_mac[1], rarp_mac[2], rarp_mac[3], rarp_mac[4], rarp_mac[5],
rarp_ip[0], rarp_ip[1], rarp_ip[2], rarp_ip[3]);
}
static void rarp_thread(void *param)
{
/* To avoid gcc warnings */
( void ) param;
printf("\r\n\r\n\r\n>>>>>>>>>>>>>>>rarp example<<<<<<<<<<<<<<<<<\r\n\r\n\r\n");
vTaskDelay(10000);
while(wifi_is_ready_to_transceive(RTW_STA_INTERFACE) != RTW_SUCCESS){
printf("\r\n\r\n\r\n>>>>>>>>>>>>>>Wifi is disconnected!!Please connect!!<<<<<<<<<<<<<<<<<\r\n\r\n\r\n");
vTaskDelay(10000);
}
rarp_retrieve_hook_callback(rarp_retrieve);
for(int i = 0; i < 3; i ++){
printf("\n\r\n\retharp_raw: sending raw RARP packet.\n\r\n\r");
#if LWIP_VERSION_MAJOR >= 2
etharp_raw(&xnetif[0], (struct eth_addr *)xnetif[0].hwaddr, &macbroadcast,
(struct eth_addr *)xnetif[0].hwaddr, ip_2_ip4(IP_ADDR_ANY),
(struct eth_addr *)xnetif[0].hwaddr, ip_2_ip4(IP_ADDR_ANY), RARP_REQUEST);
#else
etharp_raw(&xnetif[0], (struct eth_addr *)xnetif[0].hwaddr, &macbroadcast,
(struct eth_addr *)xnetif[0].hwaddr, IP_ADDR_ANY,
(struct eth_addr *)xnetif[0].hwaddr, IP_ADDR_ANY, RARP_REQUEST);
#endif
vTaskDelay(1000);
}
vTaskDelete(NULL);
}
void example_rarp(void){
if(xTaskCreate(rarp_thread, ((const char*)"rarp_thread"), RARP_THREAD_STACK_SIZE, NULL, 1 , NULL) != pdPASS)
printf("\n\r%s xTaskCreate(rarp_thread) failed\n\r", __FUNCTION__);
return;
}
| 32.533333 | 113 | 0.652152 |
10dbf50cbb68dafcf674e1f022273c3ee35d8a5f | 1,425 | c | C | src/examples/proto_attributes_iterator.c | Montimage/mmt-dpi | 92ce3808ffc7f3d392e598e9e3db6433bae9b645 | [
"Apache-2.0"
] | 3 | 2022-01-31T09:38:29.000Z | 2022-02-13T19:58:16.000Z | src/examples/proto_attributes_iterator.c | Montimage/mmt-dpi | 92ce3808ffc7f3d392e598e9e3db6433bae9b645 | [
"Apache-2.0"
] | 1 | 2022-02-24T10:04:10.000Z | 2022-03-07T10:59:42.000Z | src/examples/proto_attributes_iterator.c | Montimage/mmt-dpi | 92ce3808ffc7f3d392e598e9e3db6433bae9b645 | [
"Apache-2.0"
] | null | null | null | /**
* This example is intened to provide the list of available protocols and for each protocol, the list of its attributes
*
* Compile this example with:
*
* gcc -o proto_attributes_iterator proto_attributes_iterator.c -I /opt/mmt/dpi/include -L /opt/mmt/dpi/lib -lmmt_core -ldl -lpcap
*
* Then execute the program:
*
* ./proto_attributes_iterator > proto_attr_output.txt
*
* The output in the file proto_attr_output.txt
*
* That is it!
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "mmt_core.h"
void attributes_iterator(attribute_metadata_t * attribute, uint32_t proto_id, void * args) {
printf("\tAttribute id %i --- Name %s \n", attribute->id, attribute->alias);
}
void protocols_iterator(uint32_t proto_id, void * args) {
printf("Protocol id %i --- Name %s\n", proto_id, get_protocol_name_by_id(proto_id));
iterate_through_protocol_attributes(proto_id, attributes_iterator, NULL);
}
int main(int argc, char** argv) {
printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");
printf("|\t\t MONTIMAGE\n");
printf("|\t MMT-SDK version: %s\n",mmt_version());
printf("|\t %s: built %s %s\n", argv[0], __DATE__, __TIME__);
printf("|\t http://montimage.com\n");
printf("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n");
init_extraction();
iterate_through_protocols(protocols_iterator, NULL);
close_extraction();
return (EXIT_SUCCESS);
}
| 30.319149 | 130 | 0.644912 |
10f35a91b4fd370f96e4e4c432551678a57c52b3 | 712 | h | C | GKCommerce/GKCommerce/GKAddressKit/GKAddressRepositoryMock.h | gokush/GKCommerce | 0b3e7e5ea922188bdcbe84a9e818307a34d1e567 | [
"MIT"
] | 70 | 2015-01-10T03:11:17.000Z | 2019-07-31T23:01:53.000Z | GKCommerce/GKCommerce/GKAddressKit/GKAddressRepositoryMock.h | gokush/GKCommerce | 0b3e7e5ea922188bdcbe84a9e818307a34d1e567 | [
"MIT"
] | 9 | 2015-01-29T09:05:06.000Z | 2015-03-27T03:48:48.000Z | GKCommerce/GKCommerce/GKAddressKit/GKAddressRepositoryMock.h | gokush/GKCommerce | 0b3e7e5ea922188bdcbe84a9e818307a34d1e567 | [
"MIT"
] | 35 | 2015-01-28T12:44:25.000Z | 2019-09-09T10:49:33.000Z | //
// GKAddressRepositoryMock.h
// GKAddressKitExample
//
// Created by 小悟空 on 2/23/15.
// Copyright (c) 2015 Goku. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "GKAddressRepository.h"
@interface GKAddressRepositoryMock : NSObject <GKAddressRepository>
@property (assign, nonatomic) BOOL createWillSuccess;
@property (assign, nonatomic) BOOL updateWillSuccess;
- (RACSignal *)findAddressesWithUser:(GKUser *)user;
- (RACSignal *)create:(GKAddress *)address;
- (RACSignal *)update:(GKAddress *)address;
- (RACSignal *)addQueue:(GKAddress *)address queue:(GKAddressQueue)aQueue;
- (RACSignal *)removeQueue:(GKAddress *)address queue:(GKAddressQueue)aQueue;
- (RACSignal *)queues;
@end
| 29.666667 | 77 | 0.752809 |
2c3f2e0c283105112b2a72b661dd69ee18f1d943 | 4,802 | h | C | src/method_dispatcher.h | awesomium/tutorial-framework | 238c8ffba01e26fe1c6d572e3c6f56d16a6ff1f6 | [
"MIT"
] | 11 | 2015-02-04T17:26:47.000Z | 2018-12-29T22:39:21.000Z | method_dispatcher.h | reterVision/sampleAwesomium | 9f1de67cc85dc297fb7708cc89dd10e7152afbc1 | [
"MIT"
] | 5 | 2015-07-03T07:22:49.000Z | 2017-05-10T19:20:10.000Z | UselessJournal/src/awe/method_dispatcher.h | vhexs/UselessJournal | 12611cac10597082b99c0e2de93402f235c9fa3d | [
"MIT"
] | 5 | 2016-01-12T07:25:50.000Z | 2021-01-01T21:53:24.000Z | #ifndef __METHOD_DISPATCHER_H__
#define __METHOD_DISPATCHER_H__
#include <Awesomium/WebCore.h>
#include "js_delegate.h"
#include <map>
/**
*
* Helper class that dispatches JSMethodHandler Events to C++ Callbacks.
*
* Here's an example of usage:
* MyClass my_class;
* MethodDispatcher dispatcher;
* my_web_view->set_js_method_handler(&dispatcher);
* dispatcher.Bind(js_object,
* WSLit("JSMethodName"),
* JSDelegate(&my_class, &MyClass::CPPMethodName));
*/
class MethodDispatcher : public Awesomium::JSMethodHandler {
public:
typedef std::pair<int, Awesomium::WebString> ObjectMethodKey;
typedef std::map<ObjectMethodKey, JSDelegate> BoundMethodMap;
typedef std::map<ObjectMethodKey, JSDelegateWithRetval> BoundMethodWithRetvalMap;
MethodDispatcher();
/**
* Bind a C++ Callback to a certain JavaScript method (with no return value).
*
* @param object The JavaScript Object.
* @param name The name of the function/method to define on the object.
* @param callback The C++ callback to invoke whenever the method is called
* from JavaScript (wrapped via JSDelegate).
*
* @note Callbacks wrapped via JSDelegate should match this function signature:
* void MyCallback(WebView* caller, const JSArray& args);
*/
void Bind(Awesomium::JSObject& object,
const Awesomium::WebString& name,
JSDelegate callback);
/**
* Bind a C++ Callback to a certain JavaScript method (with a return value).
*
* @param object The JavaScript Object.
* @param name The name of the function/method to define on the object.
* @param callback The C++ callback to invoke whenever the method is called
* from JavaScript (wrapped via JSDelegateWithRetval).
*
* @note Callbacks wrapped via JSDelegateWithRetval should match this function signature:
* JSValue MyCallback(WebView* caller, const JSArray& args);
*/
void BindWithRetval(Awesomium::JSObject& object,
const Awesomium::WebString& name,
JSDelegateWithRetval callback);
// Inherited from JSMethodHandler
void OnMethodCall(Awesomium::WebView* caller,
unsigned int remote_object_id,
const Awesomium::WebString& method_name,
const Awesomium::JSArray& args);
// Inherited from JSMethodHandler
Awesomium::JSValue OnMethodCallWithReturnValue(Awesomium::WebView* caller,
unsigned int remote_object_id,
const Awesomium::WebString& method_name,
const Awesomium::JSArray& args);
protected:
BoundMethodMap bound_methods_;
BoundMethodWithRetvalMap bound_methods_with_retval_;
};
MethodDispatcher::MethodDispatcher() {
}
void MethodDispatcher::Bind(Awesomium::JSObject& object,
const Awesomium::WebString& name,
JSDelegate callback) {
// We can't bind methods to local JSObjects
if (object.type() == Awesomium::kJSObjectType_Local)
return;
object.SetCustomMethod(name, false);
ObjectMethodKey key(object.remote_id(), name);
bound_methods_[key] = callback;
}
void MethodDispatcher::BindWithRetval(Awesomium::JSObject& object,
const Awesomium::WebString& name,
JSDelegateWithRetval callback) {
// We can't bind methods to local JSObjects
if (object.type() == Awesomium::kJSObjectType_Local)
return;
object.SetCustomMethod(name, true);
ObjectMethodKey key(object.remote_id(), name);
bound_methods_with_retval_[key] = callback;
}
void MethodDispatcher::OnMethodCall(Awesomium::WebView* caller,
unsigned int remote_object_id,
const Awesomium::WebString& method_name,
const Awesomium::JSArray& args) {
// Find the method that matches the object id + method name
std::map<ObjectMethodKey, JSDelegate>::iterator i =
bound_methods_.find(ObjectMethodKey(remote_object_id, method_name));
// Call the method
if (i != bound_methods_.end())
i->second(caller, args);
}
Awesomium::JSValue MethodDispatcher::OnMethodCallWithReturnValue(Awesomium::WebView* caller,
unsigned int remote_object_id,
const Awesomium::WebString& method_name,
const Awesomium::JSArray& args) {
// Find the method that matches the object id + method name
std::map<ObjectMethodKey, JSDelegateWithRetval>::iterator i =
bound_methods_with_retval_.find(ObjectMethodKey(remote_object_id, method_name));
// Call the method
if (i != bound_methods_with_retval_.end())
return i->second(caller, args);
return Awesomium::JSValue::Undefined();
}
#endif // __METHOD_DISPATCHER_H__
| 36.105263 | 92 | 0.682424 |
c87d14e7e1860363001ff5ccd78e87d8c47a46eb | 1,291 | h | C | cpio/test/list.h | johnno1962/mtar | 33fbb46e4d1296f9f37a8f7991c57bd22ef6c6bb | [
"Unlicense"
] | 29 | 2015-02-13T08:31:12.000Z | 2021-12-01T08:03:49.000Z | cpio/test/list.h | johnno1962/mtar | 33fbb46e4d1296f9f37a8f7991c57bd22ef6c6bb | [
"Unlicense"
] | 2 | 2015-08-19T19:25:38.000Z | 2018-02-20T15:01:32.000Z | cpio/test/list.h | johnno1962/mtar | 33fbb46e4d1296f9f37a8f7991c57bd22ef6c6bb | [
"Unlicense"
] | 7 | 2016-08-13T20:07:33.000Z | 2021-10-17T23:57:54.000Z | DEFINE_TEST(test_0)
DEFINE_TEST(test_basic)
DEFINE_TEST(test_cmdline)
DEFINE_TEST(test_extract_cpio_bz2)
DEFINE_TEST(test_extract_cpio_grz)
DEFINE_TEST(test_extract_cpio_gz)
DEFINE_TEST(test_extract_cpio_lrz)
DEFINE_TEST(test_extract_cpio_lz)
DEFINE_TEST(test_extract_cpio_lzma)
DEFINE_TEST(test_extract_cpio_lzo)
DEFINE_TEST(test_extract_cpio_xz)
DEFINE_TEST(test_extract_cpio_Z)
DEFINE_TEST(test_format_newc)
DEFINE_TEST(test_gcpio_compat)
DEFINE_TEST(test_option_0)
DEFINE_TEST(test_option_a)
DEFINE_TEST(test_option_b64encode)
DEFINE_TEST(test_option_B_upper)
DEFINE_TEST(test_option_c)
DEFINE_TEST(test_option_C_upper)
DEFINE_TEST(test_option_d)
DEFINE_TEST(test_option_f)
DEFINE_TEST(test_option_grzip)
DEFINE_TEST(test_option_help)
DEFINE_TEST(test_option_J_upper)
DEFINE_TEST(test_option_l)
DEFINE_TEST(test_option_lrzip)
DEFINE_TEST(test_option_L_upper)
DEFINE_TEST(test_option_lzma)
DEFINE_TEST(test_option_lzop)
DEFINE_TEST(test_option_m)
DEFINE_TEST(test_option_t)
DEFINE_TEST(test_option_u)
DEFINE_TEST(test_option_uuencode)
DEFINE_TEST(test_option_version)
DEFINE_TEST(test_option_xz)
DEFINE_TEST(test_option_y)
DEFINE_TEST(test_option_z)
DEFINE_TEST(test_option_Z_upper)
DEFINE_TEST(test_owner_parse)
DEFINE_TEST(test_passthrough_dotdot)
DEFINE_TEST(test_passthrough_reverse)
| 30.023256 | 37 | 0.902401 |
c8a73f277c0c0488067c09dc164f4c717690675d | 728 | h | C | include/kdtree.h | LARBologna/shape_registration | d06f75e9c4793a8879e203be03a431230ed41fc2 | [
"MIT"
] | null | null | null | include/kdtree.h | LARBologna/shape_registration | d06f75e9c4793a8879e203be03a431230ed41fc2 | [
"MIT"
] | null | null | null | include/kdtree.h | LARBologna/shape_registration | d06f75e9c4793a8879e203be03a431230ed41fc2 | [
"MIT"
] | null | null | null | /**
* @file kdtree.hpp
* @brief intializer for 3-axis kd-tree
* @authors Michael Willett
* @date 2016
* @copyright Michael Willett
*/
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <vector>
#include <glm/vec4.hpp>
#include <glm/glm.hpp>
#include <glm/gtc/type_ptr.hpp>
namespace KDTree
{
class Node {
public:
Node();
Node(glm::vec3 p, int state, int source);
int axis;
int left;
int right;
int parent;
glm::vec4 value;
};
void Create(std::vector<glm::vec3> input, Node *list);
void InsertList(std::vector<glm::vec3> input, Node *list, int idx, int parent);
}; | 18.2 | 80 | 0.662088 |
c8c3628541b7faf4a30d30dffb10e0e95c58b03a | 4,482 | c | C | src/kem/sike/compression/sike_compressed.c | 0xa5a5/liboqs | b4b262281cb92d13e1dcb29c18ebc51eadb0a521 | [
"MIT"
] | null | null | null | src/kem/sike/compression/sike_compressed.c | 0xa5a5/liboqs | b4b262281cb92d13e1dcb29c18ebc51eadb0a521 | [
"MIT"
] | null | null | null | src/kem/sike/compression/sike_compressed.c | 0xa5a5/liboqs | b4b262281cb92d13e1dcb29c18ebc51eadb0a521 | [
"MIT"
] | 1 | 2020-10-12T13:30:00.000Z | 2020-10-12T13:30:00.000Z | /********************************************************************************************
* SIDH: an efficient supersingular isogeny cryptography library
*
* Abstract: supersingular isogeny key encapsulation (SIKE) protocol using compression
*********************************************************************************************/
#include <string.h>
#include <oqs/common.h>
#include <oqs/sha3.h>
int crypto_kem_keypair(unsigned char *pk, unsigned char *sk) { // SIKE's key generation using compression
// Outputs: secret key sk (CRYPTO_SECRETKEYBYTES = MSG_BYTES + SECRETKEY_A_BYTES + CRYPTO_PUBLICKEYBYTES bytes)
// public key pk_comp (CRYPTO_PUBLICKEYBYTES bytes)
// Generate lower portion of secret key sk <- s||SK
OQS_randombytes(sk, MSG_BYTES);
random_mod_order_A(sk + MSG_BYTES); // Even random number
// Generate public key pk
EphemeralKeyGeneration_A(sk + MSG_BYTES, pk);
// Append public key pk to secret key sk
memcpy(&sk[MSG_BYTES + SECRETKEY_A_BYTES], pk, CRYPTO_PUBLICKEYBYTES);
return 0;
}
int crypto_kem_enc(unsigned char *ct, unsigned char *ss, const unsigned char *pk) { // SIKE's encapsulation using compression
// Input: public key pk (CRYPTO_PUBLICKEYBYTES bytes)
// Outputs: shared secret ss (CRYPTO_BYTES bytes)
// ciphertext message ct (CRYPTO_CIPHERTEXTBYTES = COMPRESSED_CHUNK_CT + MSG_BYTES bytes)
unsigned char ephemeralsk[SECRETKEY_B_BYTES] = {0};
unsigned char jinvariant[FP2_ENCODED_BYTES] = {0};
unsigned char h[MSG_BYTES];
unsigned char temp[CRYPTO_CIPHERTEXTBYTES + MSG_BYTES] = {0};
// Generate ephemeralsk <- G(m||pk) mod oB
OQS_randombytes(temp, MSG_BYTES);
memcpy(&temp[MSG_BYTES], pk, CRYPTO_PUBLICKEYBYTES);
OQS_SHA3_shake256(ephemeralsk, SECRETKEY_B_BYTES, temp, MSG_BYTES + CRYPTO_PUBLICKEYBYTES);
FormatPrivKey_B(ephemeralsk);
// Encrypt
EphemeralKeyGeneration_B(ephemeralsk, ct);
EphemeralSecretAgreement_B(ephemeralsk, pk, jinvariant);
OQS_SHA3_shake256(h, MSG_BYTES, jinvariant, FP2_ENCODED_BYTES);
for (int i = 0; i < MSG_BYTES; i++) {
ct[i + COMPRESSED_CHUNK_CT] = temp[i] ^ h[i];
}
// Generate shared secret ss <- H(m||ct)
memcpy(&temp[MSG_BYTES], ct, CRYPTO_CIPHERTEXTBYTES);
OQS_SHA3_shake256(ss, CRYPTO_BYTES, temp, CRYPTO_CIPHERTEXTBYTES + MSG_BYTES);
return 0;
}
int crypto_kem_dec(unsigned char *ss, const unsigned char *ct, const unsigned char *sk) { // SIKE's decapsulation using compression
// Input: secret key sk (CRYPTO_SECRETKEYBYTES = MSG_BYTES + SECRETKEY_A_BYTES + CRYPTO_PUBLICKEYBYTES bytes)
// compressed ciphertext message ct (CRYPTO_CIPHERTEXTBYTES = COMPRESSED_CHUNK_CT + MSG_BYTES bytes)
// Outputs: shared secret ss (CRYPTO_BYTES bytes)
unsigned char ephemeralsk_[SECRETKEY_B_BYTES] = {0};
unsigned char jinvariant_[FP2_ENCODED_BYTES] = {0}, h_[MSG_BYTES];
unsigned char c0_comp_[COMPRESSED_CHUNK_CT] = {0};
unsigned char temp[CRYPTO_CIPHERTEXTBYTES + MSG_BYTES] = {0};
// Decrypt
EphemeralSecretAgreement_A(sk + MSG_BYTES, ct, jinvariant_);
OQS_SHA3_shake256(h_, MSG_BYTES, jinvariant_, FP2_ENCODED_BYTES);
for (int i = 0; i < MSG_BYTES; i++) {
temp[i] = ct[i + COMPRESSED_CHUNK_CT] ^ h_[i];
}
// Generate ephemeralsk_ <- G(m||pk) mod oB
memcpy(&temp[MSG_BYTES], &sk[MSG_BYTES + SECRETKEY_A_BYTES], CRYPTO_PUBLICKEYBYTES);
OQS_SHA3_shake256(ephemeralsk_, SECRETKEY_B_BYTES, temp, MSG_BYTES + CRYPTO_PUBLICKEYBYTES);
FormatPrivKey_B(ephemeralsk_);
// Generate shared secret ss <- H(m||ct) or output ss <- H(s||ct)
EphemeralKeyGeneration_B(ephemeralsk_, c0_comp_);
if (memcmp(c0_comp_, ct, COMPRESSED_CHUNK_CT) != 0) {
memcpy(temp, sk, MSG_BYTES);
}
memcpy(&temp[MSG_BYTES], ct, CRYPTO_CIPHERTEXTBYTES);
OQS_SHA3_shake256(ss, CRYPTO_BYTES, temp, CRYPTO_CIPHERTEXTBYTES + MSG_BYTES);
return 0;
}
| 48.717391 | 222 | 0.604418 |
d949b13b5a5a69431991dfa1e2239230bc787e2e | 539 | h | C | LeaguevineResponseMeta.h | ultianalytics/UltimateIPhone | d52dd2136400d1d8840eb70e7f833bc8b363723a | [
"MIT"
] | null | null | null | LeaguevineResponseMeta.h | ultianalytics/UltimateIPhone | d52dd2136400d1d8840eb70e7f833bc8b363723a | [
"MIT"
] | null | null | null | LeaguevineResponseMeta.h | ultianalytics/UltimateIPhone | d52dd2136400d1d8840eb70e7f833bc8b363723a | [
"MIT"
] | null | null | null | //
// LeaguevineResponseMeta.h
// UltimateIPhone
//
// Created by james on 9/21/12.
// Copyright (c) 2012 Summit Hill Software. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface LeaguevineResponseMeta : NSObject
@property (nonatomic) int limit;
@property (nonatomic) int offset;
@property (nonatomic) int totalCount;
@property (nonatomic, strong) NSString* nextUrl;
@property (nonatomic, strong) NSString* previousUrl;
+(LeaguevineResponseMeta*)fromJson:(NSDictionary*) dict;
-(BOOL)hasMoreResults;
@end
| 21.56 | 65 | 0.74397 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.