hexsha stringlengths 40 40 | size int64 5 2.72M | ext stringclasses 5
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 3 976 | max_stars_repo_name stringlengths 5 113 | max_stars_repo_head_hexsha stringlengths 40 78 | 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:01:43 2022-03-31 23:59:48 ⌀ | max_stars_repo_stars_event_max_datetime stringdate 2015-01-01 00:06:24 2022-03-31 23:59:53 ⌀ | max_issues_repo_path stringlengths 3 976 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 78 | 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 976 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 78 | 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:19 2022-03-31 23:59:49 ⌀ | max_forks_repo_forks_event_max_datetime stringdate 2015-01-03 12:00:57 2022-03-31 23:59:49 ⌀ | content stringlengths 5 2.72M | avg_line_length float64 1.38 573k | max_line_length int64 2 1.01M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ff90261eaca3452d005761356afeae69764f8b94 | 382 | h | C | inc/networking.h | n7jti/azure-sphere-iot-bubble-machine | b81e8786a22a4002db3cb8d095337abca8c08012 | [
"MIT"
] | 1 | 2020-10-20T16:38:34.000Z | 2020-10-20T16:38:34.000Z | inc/networking.h | n7jti/azure-sphere-iot-bubble-machine | b81e8786a22a4002db3cb8d095337abca8c08012 | [
"MIT"
] | null | null | null | inc/networking.h | n7jti/azure-sphere-iot-bubble-machine | b81e8786a22a4002db3cb8d095337abca8c08012 | [
"MIT"
] | null | null | null | /* Copyright (c) Alan Ludwig
Portions are based on the Azure Sphere IoT Sample which is (c) Microsoft Corp
Licensed under the MIT License. */
#pragma once
// Azure IoT SDK
#include <iothub_client_core_common.h>
#include <iothub_device_client_ll.h>
#include <iothub_client_options.h>
#include <iothubtransportmqtt.h>
#include <iothub.h>
#include <azure_sphere_provisioning.h> | 29.384615 | 80 | 0.774869 |
ff92579603dc680763ad8833880f33ac99fa40d6 | 1,152 | h | C | source/sfbgui.h | FollowerOfBigboss/sfb_reader | 491b39fedaf92d764545627acf6d2d0ffc79253c | [
"Unlicense"
] | null | null | null | source/sfbgui.h | FollowerOfBigboss/sfb_reader | 491b39fedaf92d764545627acf6d2d0ffc79253c | [
"Unlicense"
] | null | null | null | source/sfbgui.h | FollowerOfBigboss/sfb_reader | 491b39fedaf92d764545627acf6d2d0ffc79253c | [
"Unlicense"
] | null | null | null | #ifndef SFBGUI_H
#define SFBGUI_H
#include <iostream>
#include <QWidget>
#include <QApplication>
#include <QString>
#include <QMainWindow>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
#include <QLabel>
#include <QLineEdit>
#include <QMenu>
#include <QMenuBar>
#include <QMessageBox>
#include <QFileDialog>
#include <QDropEvent>
#include <QMimeData>
#include "sfb.h"
class SFBGui : public QMainWindow {
Q_OBJECT
public:
SFBGui();
protected:
void dragEnterEvent(QDragEnterEvent* event) override;
void dragLeaveEvent(QDragLeaveEvent* event) override;
void dropEvent(QDropEvent* event) override;
private:
QVBoxLayout* vbox;
QHBoxLayout* hbox[9];
QPushButton* SaveButton;
QLabel* PropLabel[9];
QLineEdit* LineEdit[9];
QAction *Actions[6];
SFB sfb;
bool FileCreateMode = false;
bool FileOpened = false;
void* create_ptr = nullptr;
void SetLineEdits();
void GetFromLineEdits();
private slots:
void OnActionOpen();
void OnActionCreate();
void OnActionSave();
void OnActionSaveAs();
void OnActionClose();
void OnActionExit();
};
#endif
| 17.19403 | 57 | 0.706597 |
94e147375c273576af3a845c774c509803d46e02 | 253 | h | C | Demo_PhotoAlbum/CV + headerView/XXCustomCVVC.h | 33cun/UICollectionViewFlowLayout | db6a7cc6d8a0632a1811bc4127ce67811b4fdcfd | [
"MIT"
] | null | null | null | Demo_PhotoAlbum/CV + headerView/XXCustomCVVC.h | 33cun/UICollectionViewFlowLayout | db6a7cc6d8a0632a1811bc4127ce67811b4fdcfd | [
"MIT"
] | null | null | null | Demo_PhotoAlbum/CV + headerView/XXCustomCVVC.h | 33cun/UICollectionViewFlowLayout | db6a7cc6d8a0632a1811bc4127ce67811b4fdcfd | [
"MIT"
] | null | null | null | //
// XXCustomCVVC.h
// Demo_PhotoAlbum
//
// Created by 肖鑫 on 2020/7/15.
// Copyright © 2020 Eleven. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XXCustomCVVC : UIViewController
@end
NS_ASSUME_NONNULL_END
| 14.055556 | 49 | 0.731225 |
94e28c2aac7a898fbbe36b0513894a53f6819a72 | 339 | h | C | firmware/gpio_led_driver.h | Yugontech/SenStick | 9ebd86a342a2c66c2759ba030dbd84c82bab5f2e | [
"MIT"
] | 28 | 2016-08-05T02:11:14.000Z | 2021-03-01T05:15:39.000Z | firmware/gpio_led_driver.h | Yugontech/SenStick | 9ebd86a342a2c66c2759ba030dbd84c82bab5f2e | [
"MIT"
] | 28 | 2016-08-05T03:02:09.000Z | 2017-10-18T00:04:01.000Z | firmware/gpio_led_driver.h | Yugontech/SenStick | 9ebd86a342a2c66c2759ba030dbd84c82bab5f2e | [
"MIT"
] | 5 | 2016-08-05T17:59:33.000Z | 2019-06-16T07:41:22.000Z | #ifndef gpio_led_driver_h
#define gpio_led_driver_h
#include <ble.h>
#include "senstick_types.h"
#include "gpio_button_monitoring.h"
void initLEDDriver(void);
// observer
void ledDriver_observeControlCommand(senstick_control_command_t command);
void ledDriver_observeButtonStatus(ButtonStatus_t status);
#endif /* gpio_led_driver_h */
| 22.6 | 73 | 0.828909 |
94e70404adc95b269c46651fad51ef0f8be2eec3 | 2,231 | h | C | Code/Common/itkBloxPixel.h | kiranhs/ITKv4FEM-Kiran | 0e4ab3b61b5fc4c736f04a73dd19e41390f20152 | [
"BSD-3-Clause"
] | 1 | 2018-04-15T13:32:43.000Z | 2018-04-15T13:32:43.000Z | Code/Common/itkBloxPixel.h | kiranhs/ITKv4FEM-Kiran | 0e4ab3b61b5fc4c736f04a73dd19e41390f20152 | [
"BSD-3-Clause"
] | null | null | null | Code/Common/itkBloxPixel.h | kiranhs/ITKv4FEM-Kiran | 0e4ab3b61b5fc4c736f04a73dd19e41390f20152 | [
"BSD-3-Clause"
] | null | null | null | /*=========================================================================
Program: Insight Segmentation & Registration Toolkit
Module: itkBloxPixel.h
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Insight Software Consortium. All rights reserved.
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef __itkBloxPixel_h
#define __itkBloxPixel_h
#include <list>
#include "itkBloxItem.h"
namespace itk
{
/**
* \class BloxPixel
* \brief Holds a linked list of BloxItem's
*
* itk::BloxPixel is a specialized "value added" version of the basic STL list
* intended as a base class for all pixels stored in itk::BloxImage derived
* classes.
* A particular type of itk::BloxImage is fully specialized by setting the type
* of itk::BloxPixel that it holds, so in some sense this is the most important
* class in the blox hierarchy.
*
* It is assumed that particular itk::BloxPixel derived types will add
* functionality to this base class; for example, eigenanalysis of core atom
* populations in itk::BloxCoreAtomPixel
*
* \ingroup ImageObjects
*/
template <typename TItemType>
class BloxPixel : public std::list<TItemType*>
{
public:
/** Delete all entries in the list, then clear the list. */
void DeleteListEntries();
/** Get the number of items stored in the blox. */
unsigned long int GetSize()
{return static_cast<unsigned long>( this->size() ); }
BloxPixel();
~BloxPixel();
};
} // end namespace itk
// Define instantiation macro for this template.
#define ITK_TEMPLATE_BloxPixel(_, EXPORT, x, y) namespace itk { \
_(1(class EXPORT BloxPixel< ITK_TEMPLATE_1 x >)) \
namespace Templates { typedef BloxPixel< ITK_TEMPLATE_1 x > \
BloxPixel##y; } \
}
#if ITK_TEMPLATE_EXPLICIT
# include "Templates/itkBloxPixel+-.h"
#endif
#if ITK_TEMPLATE_TXX
# include "itkBloxPixel.txx"
#endif
#endif
| 28.240506 | 79 | 0.667862 |
94e7c2304ef759f3adaff64322f7192beb0329bc | 1,503 | c | C | datastructures/stack/stack.c | ODyckhoff/C-Util | 6ad514f778f70f3c6f6c86d2526a6be86252356e | [
"MIT"
] | null | null | null | datastructures/stack/stack.c | ODyckhoff/C-Util | 6ad514f778f70f3c6f6c86d2526a6be86252356e | [
"MIT"
] | null | null | null | datastructures/stack/stack.c | ODyckhoff/C-Util | 6ad514f778f70f3c6f6c86d2526a6be86252356e | [
"MIT"
] | null | null | null |
/* stack.c */
/* BEGIN STACK
* ===========
* Stacks are a first in, last out (FILO) datastructure,
* so you must ensure that items only get added to and
* removed from the end of the stack. These functions
* are called "unshift" and "shift".
*
* Also provided are "isEmpty" and "isFull" functions, which
* make life easier when you can determine that there's no
* point trying to shift an item off an empty stack, or unshift
* an item into a full stack.
*
*/
#include <stdlib.h>
#include <stdio.h>
#include "stack.h"
stack_t *stack_init( int size ) {
if( size == 0 )
size = DEFAULT_SIZE;
stack_t *s = malloc( sizeof( stack_t ) );
if( s == NULL ) {
fprintf( stderr, "malloc failed." );
return NULL;
}
s->max = size;
s->count = 0;
s->elements = malloc( size * sizeof( s_ele_t ) );
return q;
}
int stack_unshift( stack_t *stack, s_ele_t item ) {
if( stack_isFull( stack ) )
return 1;
else {
stack->elements[ count ] = item;
stack->count++;
}
return 0;
}
s_ele_t stack_shift( stack_t *stack ) {
s_ele_t item;
if( stack_isEmpty( stack ) )
return NULL;
else {
item = stack->elements[ count - 1 ];
stack->elements[ count - 1 ] = NULL;
stack->count--;
}
return item;
}
int stack_isEmtpy( stack_t *stack ) {
return ( stack->count == 0 );
}
int stack_isFull( stack_t *stack ) {
return ( stack->count == stack->max );
}
| 22.102941 | 65 | 0.582834 |
94e970709ac0cea200d381fb9f59f02f34e69ec2 | 947 | c | C | components/mbedtls/port/aes/dma/esp_aes_gdma_impl.c | iPlon-org/esp-idf | a5227db2a75102ca1a17860188c3c352a529a01b | [
"Apache-2.0"
] | 8,747 | 2016-08-18T14:58:24.000Z | 2022-03-31T20:58:55.000Z | components/mbedtls/port/aes/dma/esp_aes_gdma_impl.c | iPlon-org/esp-idf | a5227db2a75102ca1a17860188c3c352a529a01b | [
"Apache-2.0"
] | 8,603 | 2016-08-20T08:55:56.000Z | 2022-03-31T23:04:01.000Z | components/mbedtls/port/aes/dma/esp_aes_gdma_impl.c | iPlon-org/esp-idf | a5227db2a75102ca1a17860188c3c352a529a01b | [
"Apache-2.0"
] | 6,380 | 2016-08-18T18:17:00.000Z | 2022-03-31T22:25:57.000Z | // Copyright 2020 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "esp_aes_dma_priv.h"
#include "hal/gdma_ll.h"
#include "esp_crypto_shared_gdma.h"
esp_err_t esp_aes_dma_start(const lldesc_t *input, const lldesc_t *output)
{
return esp_crypto_shared_gdma_start(input, output, GDMA_TRIG_PERIPH_AES);
}
bool esp_aes_dma_done(const lldesc_t *output)
{
return (output->owner == 0);
}
| 33.821429 | 77 | 0.756072 |
94ea39677a73fa786fd80215a714145a0f9e2013 | 5,623 | h | C | src/node_snap7_client.h | Qbitz/node-snap7-micro-client | d049aea43cb6239753e1ea0ed942854d0eadfd6f | [
"MIT"
] | 133 | 2015-02-19T04:49:23.000Z | 2022-02-23T22:15:53.000Z | src/node_snap7_client.h | Qbitz/node-snap7-micro-client | d049aea43cb6239753e1ea0ed942854d0eadfd6f | [
"MIT"
] | 76 | 2015-02-21T09:41:56.000Z | 2022-03-03T11:59:15.000Z | src/node_snap7_client.h | Qbitz/node-snap7-micro-client | d049aea43cb6239753e1ea0ed942854d0eadfd6f | [
"MIT"
] | 51 | 2015-03-02T21:48:09.000Z | 2022-03-17T12:10:36.000Z | /*
* Copyright (c) 2019, Mathias Küsel
* MIT License <https://github.com/mathiask88/node-snap7/blob/master/LICENSE>
*/
#ifndef SRC_NODE_SNAP7_CLIENT_H_
#define SRC_NODE_SNAP7_CLIENT_H_
#include <snap7.h>
#include <node.h>
#include <nan.h>
namespace node_snap7 {
enum DataIOFunction { READAREA = 1, WRITEAREA, READMULTI, WRITEMULTI
, PLCSTATUS, GETPROTECTION, CLEARSESSIONPW, SETSESSIONPW, PLCSTOP
, PLCCOLDSTART, PLCHOTSTART, GETCPINFO, GETCPUINFO, GETORDERCODE
, SETPLCSYSTEMDATETIME, GETPLCDATETIME, COMPRESS, COPYRAMTOROM
, SETPLCDATETIME, DBFILL, DBGET, DELETEBLOCK, DOWNLOAD, FULLUPLOAD
, UPLOAD, LISTBLOCKSOFTYPE, GETAGBLOCKINFO, LISTBLOCKS, CONNECT
, CONNECTTO, READSZLLIST, READSZL
};
class S7Client : public Nan::ObjectWrap {
public:
S7Client();
static NAN_MODULE_INIT(Init);
static NAN_METHOD(New);
// Control functions
static NAN_METHOD(Connect);
static NAN_METHOD(ConnectTo);
static NAN_METHOD(SetConnectionParams);
static NAN_METHOD(SetConnectionType);
static NAN_METHOD(Disconnect);
static NAN_METHOD(GetParam);
static NAN_METHOD(SetParam);
// Data I/O Main functions
static NAN_METHOD(ReadArea);
static NAN_METHOD(WriteArea);
static NAN_METHOD(ReadMultiVars);
static NAN_METHOD(WriteMultiVars);
// Directory functions
static NAN_METHOD(ListBlocks);
static NAN_METHOD(GetAgBlockInfo);
static NAN_METHOD(GetPgBlockInfo);
static NAN_METHOD(ListBlocksOfType);
// Blocks functions
static NAN_METHOD(Upload);
static NAN_METHOD(FullUpload);
static NAN_METHOD(Download);
static NAN_METHOD(Delete);
static NAN_METHOD(DBGet);
static NAN_METHOD(DBFill);
// Date/Time functions
static NAN_METHOD(GetPlcDateTime);
static NAN_METHOD(SetPlcDateTime);
static NAN_METHOD(SetPlcSystemDateTime);
// System Info functions
static NAN_METHOD(GetOrderCode);
static NAN_METHOD(GetCpuInfo);
static NAN_METHOD(GetCpInfo);
static NAN_METHOD(ReadSZL);
static NAN_METHOD(ReadSZLList);
// Control functions
static NAN_METHOD(PlcHotStart);
static NAN_METHOD(PlcColdStart);
static NAN_METHOD(PlcStop);
static NAN_METHOD(CopyRamToRom);
static NAN_METHOD(Compress);
// Security functions
static NAN_METHOD(GetProtection);
static NAN_METHOD(SetSessionPassword);
static NAN_METHOD(ClearSessionPassword);
// Properties
static NAN_METHOD(ExecTime);
static NAN_METHOD(LastError);
static NAN_METHOD(PDURequested);
static NAN_METHOD(PDULength);
static NAN_METHOD(PlcStatus);
static NAN_METHOD(Connected);
static NAN_METHOD(ErrorText);
// Internal Helper functions
static int GetByteCountFromWordLen(int WordLen);
v8::Local<v8::Array> S7DataItemToArray(PS7DataItem Items, int len
, bool readMulti);
v8::Local<v8::Object> S7ProtectionToObject(PS7Protection S7Protection);
v8::Local<v8::Object> S7CpInfoToObject(PS7CpInfo CpInfo);
v8::Local<v8::Object> S7CpuInfoToObject(PS7CpuInfo CpuInfo);
v8::Local<v8::Object> S7OrderCodeToObject(PS7OrderCode OrderCode);
v8::Local<v8::Object> S7BlockInfoToObject(PS7BlockInfo BlockInfo);
v8::Local<v8::Object> S7BlocksListToObject(PS7BlocksList BlocksList);
v8::Local<v8::Array> S7BlocksOfTypeToArray(PS7BlocksOfType BlocksList
, int count);
v8::Local<v8::Array> S7SZLListToArray(PS7SZLList SZLList, int count);
static void FreeCallback(char *data, void* hint);
static void FreeCallbackSZL(char *data, void* hint);
uv_mutex_t mutex;
TS7Client *snap7Client;
private:
~S7Client();
static Nan::Persistent<v8::FunctionTemplate> constructor;
};
class IOWorker : public Nan::AsyncWorker {
public:
// No args
IOWorker(Nan::Callback *callback, S7Client *s7client, DataIOFunction caller)
: Nan::AsyncWorker(callback), s7client(s7client), caller(caller) {}
// 1 args
IOWorker(Nan::Callback *callback, S7Client *s7client, DataIOFunction caller
, void *arg1)
: Nan::AsyncWorker(callback), s7client(s7client), caller(caller)
, pData(arg1) {}
IOWorker(Nan::Callback *callback, S7Client *s7client, DataIOFunction caller
, int arg1)
: Nan::AsyncWorker(callback), s7client(s7client), caller(caller)
, int1(arg1) {}
// 2 args
IOWorker(Nan::Callback *callback, S7Client *s7client, DataIOFunction caller
, void *arg1, int arg2)
: Nan::AsyncWorker(callback), s7client(s7client), caller(caller)
, pData(arg1), int1(arg2) {}
IOWorker(Nan::Callback *callback, S7Client *s7client, DataIOFunction caller
, int arg1, int arg2)
: Nan::AsyncWorker(callback), s7client(s7client), caller(caller)
, int1(arg1), int2(arg2) {}
// 3 args
IOWorker(Nan::Callback *callback, S7Client *s7client, DataIOFunction caller
, void *arg1, int arg2, int arg3)
: Nan::AsyncWorker(callback), s7client(s7client), caller(caller)
, pData(arg1), int1(arg2), int2(arg3) {}
// 4 args
IOWorker(Nan::Callback *callback, S7Client *s7client, DataIOFunction caller
, void *arg1, int arg2, int arg3, int arg4)
: Nan::AsyncWorker(callback), s7client(s7client), caller(caller)
, pData(arg1), int1(arg2), int2(arg3), int3(arg4) {}
// 6 args
IOWorker(Nan::Callback *callback, S7Client *s7client, DataIOFunction caller
, void *arg1, int arg2, int arg3, int arg4, int arg5, int arg6)
: Nan::AsyncWorker(callback), s7client(s7client), caller(caller)
, pData(arg1), int1(arg2), int2(arg3), int3(arg4), int4(arg5), int5(arg6) {}
~IOWorker() {}
private:
void Execute();
void HandleOKCallback();
S7Client *s7client;
DataIOFunction caller;
void *pData;
int int1, int2, int3, int4, int5, returnValue;
};
} // namespace node_snap7
#endif // SRC_NODE_SNAP7_CLIENT_H_
| 34.496933 | 80 | 0.741597 |
94edd40378b69474e207199ac3919732bf520142 | 270 | c | C | tests/picoc/26_character_constants.c | dibyendumajumdar/dmr_c | 649df517c9169931d5423d1c77010ea0d2d4768e | [
"MIT"
] | 51 | 2017-03-26T21:16:18.000Z | 2022-03-10T03:15:36.000Z | tests/picoc/26_character_constants.c | dibyendumajumdar/dmr_c | 649df517c9169931d5423d1c77010ea0d2d4768e | [
"MIT"
] | 33 | 2017-01-20T01:02:38.000Z | 2018-07-09T07:21:37.000Z | tests/picoc/26_character_constants.c | dibyendumajumdar/dmr_c | 649df517c9169931d5423d1c77010ea0d2d4768e | [
"MIT"
] | 2 | 2017-11-05T20:08:51.000Z | 2019-07-07T14:36:51.000Z | extern int printf(const char *fmt, ...);
int main(void)
{
printf("%d\n", '\1');
printf("%d\n", '\10');
printf("%d\n", '\100');
printf("%d\n", '\x01');
printf("%d\n", '\x0e');
printf("%d\n", '\x10');
printf("%d\n", '\x40');
printf("test \x407\n");
return 0;
}
| 16.875 | 40 | 0.496296 |
94ee86c5ba11c7a9af1c111769fdd89ace8a7a4c | 672 | h | C | Main/StackWalker/GraphCreator.h | Shiv98/StackWalker | e29222e57820cac6cfe4f1a5da3c2cb2bc7d4d42 | [
"BSD-2-Clause"
] | null | null | null | Main/StackWalker/GraphCreator.h | Shiv98/StackWalker | e29222e57820cac6cfe4f1a5da3c2cb2bc7d4d42 | [
"BSD-2-Clause"
] | null | null | null | Main/StackWalker/GraphCreator.h | Shiv98/StackWalker | e29222e57820cac6cfe4f1a5da3c2cb2bc7d4d42 | [
"BSD-2-Clause"
] | null | null | null | #pragma once
#ifndef _GraphCreator_H_
#define _GraphCreator_H_
#include "CallTreeNode.h"
#include <map>
#include <string>
#include <vector>
std::shared_ptr<CallTreeNode> GetBranch(std::vector<std::string> callStack);
//CallTreeNode* GetBranch(CallTreeNode* parent, std::vector<std::string> callStack);
std::shared_ptr<CallTreeNode> CreateTree(std::string key,
std::vector<std::vector<std::string>> values);
void CreateGraphAndJSON(std::map<std::string, std::vector<std::vector<std::string>>> callTrees);
CallTreeNode SetPercentages(CallTreeNode* root, int rootSampleCount);
#endif // !_GraphCreator_H_
| 37.333333 | 96 | 0.700893 |
94efac03338a61555ee140e04cdddf3ef4fa719c | 233 | h | C | bmf/shared/activities/BMFMapActivity.h | vCrespoP/BMF | e42ed1bc7f383af621f4bf9fd98a22f4acdea66d | [
"MIT"
] | null | null | null | bmf/shared/activities/BMFMapActivity.h | vCrespoP/BMF | e42ed1bc7f383af621f4bf9fd98a22f4acdea66d | [
"MIT"
] | null | null | null | bmf/shared/activities/BMFMapActivity.h | vCrespoP/BMF | e42ed1bc7f383af621f4bf9fd98a22f4acdea66d | [
"MIT"
] | null | null | null | //
// BMFMapActivity.h
// BMF
//
// Created by Jose Manuel Sánchez Peñarroja on 14/03/14.
// Copyright (c) 2014 José Manuel Sánchez. All rights reserved.
//
#import "BMFActivity.h"
@interface BMFMapActivity : BMFActivity
@end
| 16.642857 | 64 | 0.703863 |
94f19392c9c4dcd0c2820a9986c617478451a54d | 687 | h | C | android-sercd/project/jni/unix.h | jyushion/android-serialport-api | a535d231af3109ec3d2682dbaf072c046123389e | [
"Apache-2.0"
] | null | null | null | android-sercd/project/jni/unix.h | jyushion/android-serialport-api | a535d231af3109ec3d2682dbaf072c046123389e | [
"Apache-2.0"
] | null | null | null | android-sercd/project/jni/unix.h | jyushion/android-serialport-api | a535d231af3109ec3d2682dbaf072c046123389e | [
"Apache-2.0"
] | 1 | 2019-12-10T11:29:48.000Z | 2019-12-10T11:29:48.000Z | /*
* sercd UNIX support
* Copyright 2008 Peter Åstrand <astrand@cendio.se> for Cendio AB
* see file COPYING for license details
*/
#ifndef WIN32
#ifndef SERCD_UNIX_H
#define SERCD_UNIX_H
#include <syslog.h>
#include <sys/ioctl.h> /* ioctl */
#include <netinet/in.h> /* htonl */
#include <netinet/ip.h> /* IPTOS_LOWDELAY */
#include <arpa/inet.h> /* inet_addr */
#include <sys/socket.h> /* setsockopt */
#define PORTHANDLE int
#define SERCD_SOCKET int
#define closesocket close
/* Default modem state polling in milliseconds (100 msec should be enough) */
#define DEFAULT_POLL_INTERVAL 100
#endif /* SERCD_UNIX_H */
#endif /* WIN32 */
| 23.689655 | 77 | 0.673945 |
94f1ca5b4dbd7fed8913ecd7a79188f495c5cd16 | 1,746 | h | C | repos/plywood/src/runtime/ply-runtime/thread/impl/Thread_POSIX.h | tiaanl/plywood | c3a77306cdeb590ebf2ff193ca8965a4bd7de3e7 | [
"MIT"
] | 742 | 2020-05-26T12:34:24.000Z | 2022-03-14T07:22:36.000Z | repos/plywood/src/runtime/ply-runtime/thread/impl/Thread_POSIX.h | tiaanl/plywood | c3a77306cdeb590ebf2ff193ca8965a4bd7de3e7 | [
"MIT"
] | 18 | 2020-05-27T20:29:15.000Z | 2022-01-17T00:19:45.000Z | repos/plywood/src/runtime/ply-runtime/thread/impl/Thread_POSIX.h | tiaanl/plywood | c3a77306cdeb590ebf2ff193ca8965a4bd7de3e7 | [
"MIT"
] | 51 | 2020-05-26T15:30:00.000Z | 2021-12-15T01:02:25.000Z | /*------------------------------------
///\ Plywood C++ Framework
\\\/ https://plywood.arc80.com/
------------------------------------*/
#pragma once
#include <ply-runtime/Core.h>
#include <pthread.h>
#include <time.h>
#include <string.h>
namespace ply {
#define PLY_THREAD_STARTCALL
class Thread_POSIX {
private:
pthread_t m_handle;
bool m_attached = false;
template <typename Callable>
struct Wrapper {
Callable callable;
// POSIX thread entry point
static PLY_NO_INLINE void* start(void* param) {
Wrapper* wrapper = (Wrapper*) param;
wrapper->callable();
delete wrapper;
return nullptr;
}
};
public:
PLY_INLINE Thread_POSIX() {
memset(&m_handle, 0, sizeof(m_handle));
}
template <typename Callable>
PLY_INLINE void run(Callable&& callable) {
PLY_ASSERT(!m_attached);
Wrapper<Callable>* wrapper = new Wrapper<Callable>{std::forward<Callable>(callable)};
pthread_create(&m_handle, NULL, Wrapper<Callable>::start, wrapper);
m_attached = true;
}
template <typename Callable>
PLY_INLINE Thread_POSIX(Callable&& callable) {
run(std::forward<Callable>(callable));
}
PLY_INLINE ~Thread_POSIX() {
if (m_attached)
pthread_detach(m_handle);
}
PLY_INLINE bool isValid() const {
return m_attached;
}
PLY_INLINE void join() {
PLY_ASSERT(m_attached);
void* retVal;
pthread_join(m_handle, &retVal);
memset(&m_handle, 0, sizeof(m_handle));
m_attached = false;
}
#if !PLY_TARGET_MINGW
static PLY_DLL_ENTRY void sleepMillis(ureg millis);
#endif
};
} // namespace ply
| 23.594595 | 93 | 0.595074 |
94f36d43949030d33939bd248fc63b94b1c9b212 | 4,679 | c | C | src/hash.c | alexceder/libds | 760316c1cf0ea261d3c2ebf7e59e43b68a483c62 | [
"MIT",
"Unlicense"
] | null | null | null | src/hash.c | alexceder/libds | 760316c1cf0ea261d3c2ebf7e59e43b68a483c62 | [
"MIT",
"Unlicense"
] | null | null | null | src/hash.c | alexceder/libds | 760316c1cf0ea261d3c2ebf7e59e43b68a483c62 | [
"MIT",
"Unlicense"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hash.h"
size_t _hash_func(char *key, size_t size) {
unsigned int hash = 0;
int c;
while ((c = *key++)) {
hash += 37 * hash + c;
}
return hash % size;
}
size_t _probe_hash_func(size_t current_key, size_t size) {
return (LINEAR_PROBE_STRIDE + current_key) % size;
}
int _is_prime(size_t n) {
size_t i, q;
for (i = 3; ; i += 2) {
q = n / i;
if (q < i)
return 1;
if (n == q * i)
return 0;
}
return 1;
}
size_t _next_prime(size_t n) {
if (n <= 2)
return 2;
if (!(n & 1))
++n;
for ( ; 0 == _is_prime(n); n += 2);
return n;
}
bucket *_bucket_create(char *key, char *value) {
bucket *b = malloc(sizeof(bucket));
b->key = strdup(key);
b->value = strdup(value);
return b;
}
htable *htable_create() {
htable *ht = malloc(sizeof(htable));
ht->capacity = MIN_HASH_SIZE;
ht->size = 0;
ht->buckets = calloc(ht->capacity, sizeof(bucket *));
return ht;
}
void htable_destroy(htable *ht) {
htable_clear(ht);
free(ht->buckets);
free(ht);
}
int htable_is_empty(htable *ht) {
return 0 == ht->size;
}
size_t htable_size(htable *ht) {
return ht->size;
}
size_t htable_capacity(htable *ht) {
return ht->capacity;
}
bucket *htable_find(htable *ht, char *key) {
size_t hash_key = _hash_func(key, ht->capacity);
while (NULL != ht->buckets[hash_key]) {
/* key found */
if (0 == strcmp(ht->buckets[hash_key]->key, key)) {
return ht->buckets[hash_key];
}
/* leverage linear probing */
hash_key = _probe_hash_func(hash_key, ht->capacity);
}
return NULL;
}
char *htable_get(htable *ht, char *key) {
bucket *b = htable_find(ht, key);
if (NULL != b)
return b->value;
return NULL;
}
size_t htable_count(htable *ht, char *key) {
/* the name of this method might be misleading, however
* if keys where not unique it would make more sense.
* Since that is the case it can only return
* true or false as 0 or 1 */
return NULL != htable_get(ht, key);
}
bucket *htable_insert(htable *ht, char *key, char *value) {
size_t hash_key;
if (htable_load_factor(ht) > MAX_LOAD_FACTOR) htable_rehash(ht);
hash_key = _hash_func(key, ht->capacity);
while (NULL != ht->buckets[hash_key]) {
/* overwrite this key */
if (0 == strcmp(ht->buckets[hash_key]->key, key)) {
ht->buckets[hash_key]->value = realloc(ht->buckets[hash_key]->value, sizeof(char)*(strlen(value)+1));
strcpy(ht->buckets[hash_key]->value, value);
return ht->buckets[hash_key];
}
/* leverage linear probing */
hash_key = _probe_hash_func(hash_key, ht->capacity);
if (NULL == ht->buckets[hash_key]) break;
}
ht->buckets[hash_key] = _bucket_create(key, value);
ht->size++;
return ht->buckets[hash_key];
}
void htable_clear(htable *ht) {
size_t i;
for (i = 0; i < ht->capacity; ++i) {
if (NULL != ht->buckets[i]) {
free(ht->buckets[i]->value);
free(ht->buckets[i]->key);
free(ht->buckets[i]);
ht->buckets[i] = NULL;
}
}
ht->buckets = realloc(ht->buckets, sizeof(char *)*MIN_HASH_SIZE);
ht->capacity = MIN_HASH_SIZE;
ht->size = 0;
}
void htable_erase(htable *ht, char *key) {
/* TODO Try and figure out a way to utilize the find function */
size_t hash_key = _hash_func(key, ht->capacity);
while (NULL != ht->buckets[hash_key]) {
if (0 == strcmp(ht->buckets[hash_key]->key, key)) {
free(ht->buckets[hash_key]->value);
free(ht->buckets[hash_key]->key);
free(ht->buckets[hash_key]);
ht->buckets[hash_key] = NULL;
ht->size--;
return;
}
hash_key = _probe_hash_func(hash_key, ht->capacity);
}
}
float htable_load_factor(htable *ht) {
return ht->size / (float) ht->capacity;
}
void htable_rehash(htable *ht) {
size_t old_size, i;
bucket **old_buckets;
old_size = ht->capacity;
old_buckets = ht->buckets;
ht->size = 0;
ht->capacity = _next_prime(ht->capacity * 2);
ht->buckets = calloc(ht->capacity, sizeof(bucket *));
for (i = 0; i < old_size; ++i) {
if (NULL != old_buckets[i]) {
htable_insert(ht, old_buckets[i]->key, old_buckets[i]->value);
free(old_buckets[i]->value);
free(old_buckets[i]->key);
free(old_buckets[i]);
}
}
free(old_buckets);
}
| 24.369792 | 113 | 0.569994 |
94f3ff89cf35e1062da49020ba24cea26da96c0c | 705 | h | C | Source/DlgSystemEditor/Private/Factories/DlgEventCustomFactory.h | derossm/DlgSystem | 69d4539067fa4c5c8cc26cdb7cc019cf0576cd5a | [
"MIT"
] | 200 | 2021-03-17T11:15:05.000Z | 2022-03-31T23:45:09.000Z | Source/DlgSystemEditor/Private/Factories/DlgEventCustomFactory.h | derossm/DlgSystem | 69d4539067fa4c5c8cc26cdb7cc019cf0576cd5a | [
"MIT"
] | 1 | 2019-10-28T05:37:21.000Z | 2019-10-28T08:19:12.000Z | Source/DlgSystemEditor/Private/Factories/DlgEventCustomFactory.h | derossm/DlgSystem | 69d4539067fa4c5c8cc26cdb7cc019cf0576cd5a | [
"MIT"
] | 38 | 2021-03-17T13:29:18.000Z | 2022-03-04T19:32:52.000Z | // Copyright Csaba Molnar, Daniel Butum. All Rights Reserved.
#pragma once
#include "Factories/Factory.h"
#include "DlgEventCustomFactory.generated.h"
class UDlgEventCustom;
UCLASS()
class DLGSYSTEMEDITOR_API UDlgEventCustomFactory : public UFactory
{
GENERATED_BODY()
public:
UDlgEventCustomFactory(const FObjectInitializer& ObjectInitializer);
//
// UFactory interface
//
bool ConfigureProperties() override;
UObject* FactoryCreateNew(
UClass* Class,
UObject* InParent,
FName Name,
EObjectFlags Flags,
UObject* Context,
FFeedbackContext* Warn
) override;
private:
// Holds the template of the class we are building
UPROPERTY()
TSubclassOf<UDlgEventCustom> ParentClass;
};
| 19.054054 | 69 | 0.77305 |
94fe9d260986b9fed9ac38d39dea895b275658ac | 2,441 | h | C | mugsy-seqan/projects/library/seqan/store/store_annotation.h | kloetzl/mugsy | 8ccdf32858a7a5ab2f7b9b084d2190970feb97ec | [
"Artistic-2.0"
] | null | null | null | mugsy-seqan/projects/library/seqan/store/store_annotation.h | kloetzl/mugsy | 8ccdf32858a7a5ab2f7b9b084d2190970feb97ec | [
"Artistic-2.0"
] | null | null | null | mugsy-seqan/projects/library/seqan/store/store_annotation.h | kloetzl/mugsy | 8ccdf32858a7a5ab2f7b9b084d2190970feb97ec | [
"Artistic-2.0"
] | null | null | null | /*==========================================================================
SeqAn - The Library for Sequence Analysis
http://www.seqan.de
============================================================================
Copyright (C) 2007
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
============================================================================
$Id$
==========================================================================*/
#ifndef SEQAN_HEADER_STORE_ANNOTATION_H
#define SEQAN_HEADER_STORE_ANNOTATION_H
namespace SEQAN_NAMESPACE_MAIN
{
//////////////////////////////////////////////////////////////////////////////
// Annotation Store
//////////////////////////////////////////////////////////////////////////////
template <typename TPos, typename TSpec = void>
struct AnnotationStoreElement
{
typedef typename Id<AnnotationStoreElement>::Type TId;
static const TId INVALID_ID;
static const TPos INVALID_POS;
TId parentId;
TId contigId;
TPos beginPos; // begin position of the gapped sequence in gapped contig sequence
TPos endPos; // end position of ..., for reverse aligned reads holds end < begin
AnnotationStoreElement() : parentId(INVALID_ID), contigId(INVALID_ID), beginPos(INVALID_POS), endPos(INVALID_POS) {}
};
//////////////////////////////////////////////////////////////////////////////
template <typename TPos, typename TSpec>
const typename Id<AnnotationStoreElement<TPos, TSpec> >::Type
AnnotationStoreElement<TPos, TSpec>::INVALID_ID = SupremumValue<typename Id<AnnotationStoreElement<TPos, TSpec> >::Type>::VALUE;
template <typename TPos, typename TSpec>
const TPos
AnnotationStoreElement<TPos, TSpec>::INVALID_POS = SupremumValue<TPos>::VALUE;
//////////////////////////////////////////////////////////////////////////////
}// namespace SEQAN_NAMESPACE_MAIN
#endif //#ifndef SEQAN_HEADER_...
| 38.746032 | 129 | 0.542401 |
a203d527837d3a19dd496dc0e3f6d59331be63d8 | 1,774 | h | C | Classes/Gameplay/Engine/GameLogic.h | inspoy/MineWar | 7fada56de8cb6854fab092096e9f5da7d0b1b28a | [
"Apache-2.0"
] | 1 | 2018-03-14T15:03:12.000Z | 2018-03-14T15:03:12.000Z | Classes/Gameplay/Engine/GameLogic.h | inspoy/MineWar | 7fada56de8cb6854fab092096e9f5da7d0b1b28a | [
"Apache-2.0"
] | null | null | null | Classes/Gameplay/Engine/GameLogic.h | inspoy/MineWar | 7fada56de8cb6854fab092096e9f5da7d0b1b28a | [
"Apache-2.0"
] | null | null | null | //----------------------------------------------------------
//
// Echo Entertainment @ 2014
// All Rights Reserved
//
//----------------------------------------------------------
#ifndef ECHO_GAMEPLAY_GAMELOGIC_H__INCLUDED
#define ECHO_GAMEPLAY_GAMELOGIC_H__INCLUDED
#include "Precompiled.h"
#include "cocos2d.h"
namespace Echo
{
class GameScene;
class BaseGameController;
typedef std::map<StdString, std::vector<BaseGameController*> > ControllerMap;
class GameLogic
{
public:
ECHO_DECLARE_SINGLETON(GameLogic);
public:
bool init();
void update(float dt);
GameScene* switchScene(String sceneName, bool dontSwitch = false, bool noEffect =false);
void setCurrentScene(GameScene* pScene);
template<class _T>
_T getCurrentScene()
{
_T ret = dynamic_cast<_T>(m_currentScene);
return ret;
}
void registerGameController(BaseGameController* pController);
void unregisterGameController(BaseGameController* pController);
// other
String getCurLevelName();
void setCurLevelName(String levelName);
// tools
u32 getNewUid();
private:
cocos2d::Director* getDirector();
void onKeyPressed(cocos2d::EventKeyboard::KeyCode code, cocos2d::Event* event);
void onKeyReleased(cocos2d::EventKeyboard::KeyCode code, cocos2d::Event* event);
private:
cocos2d::Director* m_director;
GameScene* m_currentScene;
String m_currentSceneName;
ControllerMap m_gameControllerMap;
String m_curLevelName;
u32 m_uidCount;
u32 m_shotCount;
};
}
#endif | 26.477612 | 97 | 0.586809 |
a204517b8cf5b91c6524e9ad67ba6c39dc341ee8 | 10,209 | h | C | drivers/pwm/bcm2836/bcm2836pwm.h | christopherco/rpi-iotcore | 2cf15e428e743dd7f7742f7511725741640c5be3 | [
"MIT"
] | 89 | 2018-12-22T15:34:45.000Z | 2021-12-16T20:07:29.000Z | drivers/pwm/bcm2836/bcm2836pwm.h | christopherco/rpi-iotcore | 2cf15e428e743dd7f7742f7511725741640c5be3 | [
"MIT"
] | 31 | 2021-01-10T16:04:10.000Z | 2022-03-12T08:04:21.000Z | drivers/pwm/bcm2836/bcm2836pwm.h | christopherco/rpi-iotcore | 2cf15e428e743dd7f7742f7511725741640c5be3 | [
"MIT"
] | 42 | 2016-02-18T21:55:54.000Z | 2018-11-27T07:12:01.000Z | /*++
Copyright (c) Microsoft Corporation All Rights Reserved
Abstract:
This file contains the public device path names and
IOCTL definitions for BCM2836 PWM driver.
--*/
#ifndef _BCM2836PWM_H
#define _BCM2836PWM_H
#if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
//
// Device path names
//
#define BCM_PWM_NAME L"BCM2836PWM"
#define BCM_PWM_SYMBOLIC_NAME L"\\DosDevices\\" BCM_PWM_NAME
#define BCM_PWM_USERMODE_PATH L"\\\\.\\" BCM_PWM_NAME
#define BCM_PWM_USERMODE_PATH_SIZE sizeof(BCM_PWM_USERMODE_PATH)
//
// IOCTL codes
//
#define FILE_DEVICE_PWM_PERIPHERAL 0x400
//
// Set PWM clock configuration
//
// Input buffer:
// lpInBuffer - pointer to a variable of type BCM_PWM_CLOCK_CONFIG
// nInBufferSize - sizeof(BCM_PWM_CLOCK_CONFIG)
//
// Output buffer:
// None
//
#define IOCTL_BCM_PWM_SET_CLOCKCONFIG CTL_CODE(FILE_DEVICE_PWM_PERIPHERAL, 0x700, METHOD_BUFFERED, FILE_WRITE_DATA)
//
// Get PWM clock configuration
//
// Input buffer:
// None
//
// Output buffer:
// lpOutBuffer - pointer to a variable of type BCM_PWM_CLOCK_CONFIG
// nOutBufferSize - sizeof(BCM_PWM_CLOCK_CONFIG)
//
#define IOCTL_BCM_PWM_GET_CLOCKCONFIG CTL_CODE(FILE_DEVICE_PWM_PERIPHERAL, 0x701, METHOD_BUFFERED, FILE_WRITE_DATA)
//
// Set PWM channel configuration
// The field channel in the input variable specifies for which channel the configuration should be applied.
//
// Input buffer:
// lpInBuffer - pointer to a variable of type BCM_PWM_CHANNEL_CONFIG
// nInBufferSize - sizeof(BCM_PWM_CHANNEL_CONFIG)
//
// Output buffer:
// None
//
#define IOCTL_BCM_PWM_SET_CHANNELCONFIG CTL_CODE(FILE_DEVICE_PWM_PERIPHERAL, 0x702, METHOD_BUFFERED, FILE_WRITE_DATA)
//
// Get PWM channel configuration
// The input value of type BCM_PWM_CHANNEL specifies for which channel the configuration should be returned.
// If this field is set to a value different than BCM_PWM_CHANNEL_CHANNEL1 or BCM_PWM_CHANNEL_CHANNEL2,
// then STATUS_INVALID_PARAMETER is returned.
//
// Input buffer:
// lpInBuffer - pointer to a variable of type BCM_PWM_CHANNEL
// nInBufferSize - sizeof(BCM_PWM_CHANNEL)
//
// Output buffer:
// lpOutBuffer - pointer to a struct of type BCM_PWM_CHANNEL_CONFIG
// nOutBufferSize - sizeof(BCM_PWM_CHANNEL_CONFIG)
//
#define IOCTL_BCM_PWM_GET_CHANNELCONFIG CTL_CODE(FILE_DEVICE_PWM_PERIPHERAL, 0x703, METHOD_BUFFERED, FILE_WRITE_DATA)
//
// Set PWM duty register value
// The field channel in the input variable specifies for which channel the duty value should be set.
//
// Input buffer:
// lpInBuffer - pointer to a variable of type BCM_PWM_SET_DUTY_REGISTER
// nInBufferSize - sizeof(BCM_PWM_SET_DUTY_REGISTER)
//
// Output buffer:
// None
//
#define IOCTL_BCM_PWM_SET_DUTY_REGISTER CTL_CODE(FILE_DEVICE_PWM_PERIPHERAL, 0x704, METHOD_BUFFERED, FILE_WRITE_DATA)
//
// Get duty register value
// The input value of type BCM_PWM_CHANNEL specifies for which channel the configuration should be returned.
// If this field is set to a value different than BCM_PWM_CHANNEL_CHANNEL1 or BCM_PWM_CHANNEL_CHANNEL2,
// then STATUS_INVALID_PARAMETER is returned.
//
// Input buffer:
// lpInBuffer - pointer to a variable of type BCM_PWM_CHANNEL
// nInBufferSize - sizeof(BCM_PWM_CHANNEL)
//
// Output buffer:
// lpOutBuffer - pointer to a variable of type BCM_PWM_DUTY_REGISTER
// nOutBufferSize - sizeof(BCM_PWM_DUTY_REGISTER)
//
#define IOCTL_BCM_PWM_GET_DUTY_REGISTER CTL_CODE(FILE_DEVICE_PWM_PERIPHERAL, 0x705, METHOD_BUFFERED, FILE_WRITE_DATA)
//
// Start PWM signal generator
// The input value of type BCM_PWM_CHANNEL specifies for which channel the generator should be started.
// If the channels are not configured using the duty register or if the PWM generator of the specified channel(s)
// is already running, STATUS_DEVICE_CONFIGURATION_ERROR is returned.
//
// Input buffer:
// lpInBuffer - pointer to a variable of type BCM_PWM_CHANNEL
// nInBufferSize - sizeof(BCM_PWM_CHANNEL)
//
// Output buffer:
// None
//
#define IOCTL_BCM_PWM_START CTL_CODE(FILE_DEVICE_PWM_PERIPHERAL, 0x706, METHOD_BUFFERED, FILE_WRITE_DATA)
//
// Stop PWM signal generator
// The input value of type BCM_PWM_CHANNEL specifies for which channel the generator should be stopped.
// If the channels are not configured using the duty register or write via IOCTL calls or if the PWM generator
// of the specified channel(s) is already stopped, STATUS_DEVICE_CONFIGURATION_ERROR is returned.
//
// Input buffer:
// lpInBuffer - pointer to a variable of type BCM_PWM_CHANNEL
// nInBufferSize - sizeof(BCM_PWM_CHANNEL)
//
// Output buffer:
// None
//
#define IOCTL_BCM_PWM_STOP CTL_CODE(FILE_DEVICE_PWM_PERIPHERAL, 0x707, METHOD_BUFFERED, FILE_WRITE_DATA)
//
// Aquire PWM for audio operation. This will prevent any register PWM calls till PWM is released with an
// IOCTL_BCM_PWM_RELEASE_AUDIO call. PWM clock and channel settings are saved and restored in the IOCTL_BCM_PWM_RELEASE_AUDIO
// call.
//
// Input buffer:
// None
//
// Output buffer:
// None
//
#define IOCTL_BCM_PWM_AQUIRE_AUDIO CTL_CODE(FILE_DEVICE_PWM_PERIPHERAL, 0x708, METHOD_BUFFERED, FILE_WRITE_DATA)
//
// Put PWM back into register operation mode and restores the clock and channel settings to the values before the
// IOCTL_BCM_PWM_AQUIRE_AUDIO call.
//
// Input buffer:
// None
//
// Output buffer:
// None
//
#define IOCTL_BCM_PWM_RELEASE_AUDIO CTL_CODE(FILE_DEVICE_PWM_PERIPHERAL, 0x709, METHOD_BUFFERED, FILE_WRITE_DATA)
//
// Initializes PWM for audio playback. This includes configuration of the PWM channels and setup of the DMA control blocks.
//
// Input buffer:
// lpInBuffer - pointer to a variable of type BCM_PWM_AUDIO_CONFIG
// nInBufferSize - sizeof(BCM_PWM_AUDIO_CONFIG)
//
// Output buffer:
// None
//
#define IOCTL_BCM_PWM_INITIALIZE_AUDIO CTL_CODE(FILE_DEVICE_PWM_PERIPHERAL, 0x70A, METHOD_BUFFERED, FILE_WRITE_DATA)
//
// Register an event for notification by the driver. During the allocation the driver receives the number of
// notifications sent per buffer.
// Note: this call is only working if called from kernel mode.
//
// Input buffer:
// lpInBuffer - pointer to a event handle
// nInBufferSize - sizeof an event handle
//
// Output buffer:
// None
//
#define IOCTL_BCM_PWM_REGISTER_AUDIO_NOTIFICATION CTL_CODE(FILE_DEVICE_PWM_PERIPHERAL, 0x70B, METHOD_BUFFERED, FILE_WRITE_DATA)
//
// Unregister an event for notification by the driver.
//
// Input buffer:
// lpInBuffer - pointer to a event handle
// nInBufferSize - sizeof an event handle
//
// Output buffer:
// None
//
#define IOCTL_BCM_PWM_UNREGISTER_AUDIO_NOTIFICATION CTL_CODE(FILE_DEVICE_PWM_PERIPHERAL, 0x70C, METHOD_BUFFERED, FILE_WRITE_DATA)
//
// Start audio DMA for both channels of the PWM controller.
//
// Input buffer:
// None
//
// Output buffer:
// None
//
#define IOCTL_BCM_PWM_START_AUDIO CTL_CODE(FILE_DEVICE_PWM_PERIPHERAL, 0x70D, METHOD_BUFFERED, FILE_WRITE_DATA)
//
// Stop audio DMA for both channels of the PWM controller.
//
// Input buffer:
// None
//
// Output buffer:
// None
//
#define IOCTL_BCM_PWM_STOP_AUDIO CTL_CODE(FILE_DEVICE_PWM_PERIPHERAL, 0x70E, METHOD_BUFFERED, FILE_WRITE_DATA)
//
// Pause audio DMA for both channels of the PWM controller.
//
// Input buffer:
// None
//
// Output buffer:
// None
//
#define IOCTL_BCM_PWM_PAUSE_AUDIO CTL_CODE(FILE_DEVICE_PWM_PERIPHERAL, 0x70F, METHOD_BUFFERED, FILE_WRITE_DATA)
//
// Resume audio DMA for both channels of the PWM controller.
//
// Input buffer:
// None
//
// Output buffer:
// None
//
#define IOCTL_BCM_PWM_RESUME_AUDIO CTL_CODE(FILE_DEVICE_PWM_PERIPHERAL, 0x710, METHOD_BUFFERED, FILE_WRITE_DATA)
typedef enum _BCM_PWM_CHANNEL {
BCM_PWM_CHANNEL_CHANNEL1,
BCM_PWM_CHANNEL_CHANNEL2,
BCM_PWM_CHANNEL_ALLCHANNELS,
} BCM_PWM_CHANNEL;
typedef enum _BCM_PWM_DUTYMODE {
BCM_PWM_DUTYMODE_MARKSPACE,
BCM_PWM_DUTYMODE_PWM,
} BCM_PWM_DUTYMODE;
typedef enum _BCM_PWM_REPEATMODE {
BCM_PWM_REPEATMODE_OFF,
BCM_PWM_REPEATMODE_ON,
} BCM_PWM_REPEATMODE;
typedef enum _BCM_PWM_POLARITY {
BCM_PWM_POLARITY_NORMAL,
BCM_PWM_POLARITY_INVERTED,
} BCM_PWM_POLARITY;
typedef enum _BCM_PWM_SILENCELEVEL {
BCM_PWM_SILENCELEVEL_LOW,
BCM_PWM_SILENCELEVEL_HIGH,
} BCM_PWM_SILENCELEVEL;
typedef enum _BCM_PWM_MODE {
BCM_PWM_MODE_PWM,
BCM_PWM_MODE_SERIALISER,
} BCM_PWM_MODE;
typedef enum _BCM_PWM_CLOCKSOURCE {
BCM_PWM_CLOCKSOURCE_PLLC,
BCM_PWM_CLOCKSOURCE_PLLD,
} BCM_PWM_CLOCKSOURCE;
typedef struct _BCM_PWM_CLOCK_CONFIG {
BCM_PWM_CLOCKSOURCE ClockSource;
ULONG Divisor;
} BCM_PWM_CLOCK_CONFIG, *PBCM_PWM_CLOCK_CONFIG;
typedef struct _BCM_PWM_CHANNEL_CONFIG {
BCM_PWM_CHANNEL Channel;
ULONG Range;
BCM_PWM_DUTYMODE DutyMode;
BCM_PWM_MODE Mode;
BCM_PWM_POLARITY Polarity;
BCM_PWM_REPEATMODE Repeat;
BCM_PWM_SILENCELEVEL Silence;
} BCM_PWM_CHANNEL_CONFIG, *PBCM_PWM_CHANNEL_CONFIG;
typedef struct _BCM_PWM_SET_DUTY_REGISTER {
BCM_PWM_CHANNEL Channel;
ULONG Duty;
} BCM_PWM_SET_DUTY_REGISTER, *PBCM_PWM_SET_DUTY_REGISTER;
typedef struct _BCM_PWM_PACKET_LINK_INFO {
PVOID LinkPtr;
ULONG LinkValue;
} BCM_PWM_PACKET_LINK_INFO, *PBCM_PWM_PACKET_LINK_INFO;
typedef struct _BCM_PWM_AUDIO_CONFIG {
ULONG RequestedBufferSize;
ULONG NotificationsPerBuffer;
ULONG PwmRange;
PVOID DmaBuffer;
PBOOLEAN DmaRestartRequired;
PBCM_PWM_PACKET_LINK_INFO DmaPacketLinkInfo;
ULONG DmaNumPackets;
PULONG DmaPacketsInUse;
PULONG DmaPacketsToPrime;
PULONG DmaPacketsProcessed;
PLARGE_INTEGER DmaLastProcessedPacketTime;
} BCM_PWM_AUDIO_CONFIG, *PBCM_PWM_AUDIO_CONFIG;
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif
#endif | 30.204142 | 129 | 0.741601 |
a20571883d4a15519e940cd10d3b4251b80ae056 | 406 | h | C | modules/scene_manager/include/nav_msgs/srv/get_map__request.h | Omnirobotic/godot | d50b5d047bbf6c68fc458c1ad097321ca627185d | [
"CC-BY-3.0",
"Apache-2.0",
"MIT"
] | 1 | 2020-05-19T14:33:49.000Z | 2020-05-19T14:33:49.000Z | ros2_mod_ws/install/include/nav_msgs/srv/get_map__request.h | mintforpeople/robobo-ros2-ios-port | 1a5650304bd41060925ebba41d6c861d5062bfae | [
"Apache-2.0"
] | 3 | 2019-11-14T12:20:06.000Z | 2020-08-07T13:51:10.000Z | modules/scene_manager/include/nav_msgs/srv/get_map__request.h | Omnirobotic/godot | d50b5d047bbf6c68fc458c1ad097321ca627185d | [
"CC-BY-3.0",
"Apache-2.0",
"MIT"
] | null | null | null | // generated from rosidl_generator_c/resource/msg.h.em
// generated code does not contain a copyright notice
#ifndef NAV_MSGS__SRV__GET_MAP__REQUEST_H_
#define NAV_MSGS__SRV__GET_MAP__REQUEST_H_
#include "nav_msgs/srv/get_map__request__struct.h"
#include "nav_msgs/srv/get_map__request__functions.h"
#include "nav_msgs/srv/get_map__request__type_support.h"
#endif // NAV_MSGS__SRV__GET_MAP__REQUEST_H_
| 33.833333 | 56 | 0.849754 |
a205ccf8a30a0ab5f4ca83f165a96a1ee8b7aed1 | 1,930 | h | C | Hazel/Src/Hazel/Renderer/EditorCamera.h | monaboiste/Hazel | 3b91f7941de6d123c988c2f962aaa5589ab64161 | [
"Apache-2.0"
] | 1 | 2021-06-25T08:11:32.000Z | 2021-06-25T08:11:32.000Z | Hazel/Src/Hazel/Renderer/EditorCamera.h | monaboiste/Hazel | 3b91f7941de6d123c988c2f962aaa5589ab64161 | [
"Apache-2.0"
] | 2 | 2021-02-17T13:20:11.000Z | 2021-02-17T13:31:13.000Z | Hazel/Src/Hazel/Renderer/EditorCamera.h | monaboiste/hazel-private-branch | 3b91f7941de6d123c988c2f962aaa5589ab64161 | [
"Apache-2.0"
] | null | null | null | #pragma once
#include "Hazel/Renderer/Camera.h"
#include "Hazel/Core/Timestep.h"
#include "Hazel/Events/Event.h"
#include "Hazel/Events/MouseEvent.h"
#include <glm/gtc/matrix_transform.hpp>
namespace Hazel {
class EditorCamera : public Camera
{
public:
EditorCamera() = default;
EditorCamera(float fov, float aspectRatio, float nearClip, float farClip);
void OnUpdate(Timestep ts);
void OnEvent(Event& e);
float GetDistance() const { return m_distance; }
void SetDistance(float distance) { m_distance = distance; }
void SetViewportSize(float width, float height) { m_viewportWidth = width; m_viewportHeight = height; UpdateProjection(); }
const glm::mat4& GetView() const { return m_view; }
glm::mat4 GetViewProjection() const { return m_projection * m_view; }
glm::vec3 GetUpDirection() const;
glm::vec3 GetForwardDirection() const;
glm::vec3 GetRightDirection() const;
const glm::vec3& GetPosition() const { return m_position; }
glm::quat GetOrientation() const;
float GetPitch() const { return m_pitch; }
float GetYaw() const { return m_yaw; }
private:
void UpdateProjection();
void UpdateView();
bool OnMouseScrolled(MouseScrolledEvent& e);
void MousePan(const glm::vec2& delta);
void MouseRotate(const glm::vec2& delta);
void MouseZoom(float delta);
glm::vec3 CalculatePosition() const;
std::pair<float, float> PanSpeed() const;
float RotationSpeed() const;
float ZoomSpeed() const;
private:
float m_fov = 45.0f;
float m_aspectRatio = 1.778f;
float m_nearClip = 0.1f;
float m_farClip = 1000.0f;
float m_viewportWidth = 1280.0f;
float m_viewportHeight = 720.0f;
float m_distance = 10.0f;
float m_pitch = 0.0f;
float m_yaw = 0.0f;
glm::mat4 m_view;
glm::mat4 m_projection;
glm::vec3 m_position = { 0.0f, 0.0f, 0.0f };
glm::vec3 m_focalPoint = { 0.0f, 0.0f, 10.0f };
glm::vec2 m_initialMousePosition = { 0.0f, 0.0f };
};
} | 26.081081 | 125 | 0.707772 |
a20b9570e3e418ccaff314ea0f5a05dfb864244c | 467 | c | C | base/numeral_system.c | VinkDong/c-example | cbfb240a3e4af9786a3b1f7844556dc20eae9cc2 | [
"MIT"
] | null | null | null | base/numeral_system.c | VinkDong/c-example | cbfb240a3e4af9786a3b1f7844556dc20eae9cc2 | [
"MIT"
] | null | null | null | base/numeral_system.c | VinkDong/c-example | cbfb240a3e4af9786a3b1f7844556dc20eae9cc2 | [
"MIT"
] | null | null | null | # include <stdio.h>
// this is show `进制` but i don't know how to translate it
int main()
{
int a = 050;
int b = 50;
int c = 0x50;
//there has no method to define
printf("this is decimal %%o -> %%d number %d\n",a);
printf("this is a octonary %o\n",a);
printf("this is a octonary number and start with 1 :%#o\n",b);
printf("this is a hexadecima number %x\n",c);
printf("this is a hexadecima number and start with 0x: %#x\n",b);
}
| 27.470588 | 69 | 0.599572 |
a20d763e829d02bc6b77fa46e6ef63fbceeb10c7 | 1,928 | c | C | libraries/circular_buffer/circular_buffer.c | adityasiyengar/c_programming | d65bf2791b131e88d901368db21a18e9e66ae682 | [
"Unlicense"
] | null | null | null | libraries/circular_buffer/circular_buffer.c | adityasiyengar/c_programming | d65bf2791b131e88d901368db21a18e9e66ae682 | [
"Unlicense"
] | null | null | null | libraries/circular_buffer/circular_buffer.c | adityasiyengar/c_programming | d65bf2791b131e88d901368db21a18e9e66ae682 | [
"Unlicense"
] | null | null | null | #include <stdlib.h>
#include <stdint.h>
#include "circular_buffer.h"
uint16_t circular_buffer_push(circular_buffer_t *buffer, uint8_t *data, uint16_t length)
{
uint16_t count = 0U, current_write, current_read;
current_write = buffer->write;
current_read = buffer->read;
if ((current_write - current_read + length) > CIRCULAR_BUFFER_SIZE)
{
length = CIRCULAR_BUFFER_SIZE - (current_write - current_read);
}
for (count = 0U; count < length; count++)
{
buffer->data[current_write % CIRCULAR_BUFFER_SIZE] = data[count];
current_write++;
}
buffer->write = current_write;
return count;
}
uint16_t circular_buffer_pop(uint8_t *data, circular_buffer_t *buffer, uint16_t length)
{
uint16_t count, next_read = buffer->read, next_write = buffer->write;
if (length > (next_write - next_read))
{
length = next_write - next_read;
}
if (data != NULL)
{
for (count = 0U; count < length; count++)
{
data[count] = buffer->data[buffer->read % CIRCULAR_BUFFER_SIZE];
buffer->read++;
}
}
else
{
count = length;
buffer->read += length;
}
return count;
}
uint16_t circular_buffer_peak(uint8_t *data, uint16_t startposition, circular_buffer_t *buffer, uint16_t length)
{
uint16_t count = 0U, next_read = buffer->read, next_write = buffer->write;
if(next_write-next_read <= startposition)
return 0;
next_read += startposition;
if (length > (next_write - next_read))
{
length = next_write - next_read;
}
for (count = 0U; count < length; count++)
{
data[count] = buffer->data[next_read % CIRCULAR_BUFFER_SIZE];
next_read++;
}
return count;
}
uint16_t compute_circular_buffer_read_space(circular_buffer_t *buffer)
{
uint16_t read = buffer->read, write = buffer->write;
return (write-read);
}
uint16_t compute_circular_buffer_write_space(circular_buffer_t *buffer)
{
uint16_t read = buffer->read, write = buffer->write;
return (CIRCULAR_BUFFER_SIZE - (write - read));
} | 22.418605 | 112 | 0.71473 |
a20d9f7595c0fc9d36ac38aa83a0a664912d2e0f | 4,522 | h | C | src/utils.h | MiftahurRidho/tugas | cb343939d3f5731d8c1509beb90c051c63a83903 | [
"Unlicense",
"MS-PL"
] | 87 | 2015-01-04T13:57:18.000Z | 2022-03-21T16:07:05.000Z | src/utils.h | MiftahurRidho/tugas | cb343939d3f5731d8c1509beb90c051c63a83903 | [
"Unlicense",
"MS-PL"
] | null | null | null | src/utils.h | MiftahurRidho/tugas | cb343939d3f5731d8c1509beb90c051c63a83903 | [
"Unlicense",
"MS-PL"
] | 60 | 2015-01-15T06:16:39.000Z | 2022-03-31T22:23:12.000Z | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* utils.h:
*
* Contact:
* Moonlight List (moonlight-list@lists.ximian.com)
*
* Copyright 2007 Novell, Inc. (http://www.novell.com)
*
* See the LICENSE file included with the distribution for details.
*/
#ifndef __UTILS_H__
#define __UTILS_H__
#include <glib.h>
#include <cairo.h>
#include <sys/types.h>
#include "downloader.h"
#include "zip/unzip.h"
namespace Moonlight {
G_BEGIN_DECLS
typedef gboolean (*Stream_CanSeek) (void *handle);
typedef gboolean (*Stream_CanRead) (void *handle);
typedef gint64 (*Stream_Length) (void *handle);
typedef gint64 (*Stream_Position) (void *handle);
typedef gint32 (*Stream_Read) (void *handle, void *buffer, gint32 offset, gint32 count);
typedef void (*Stream_Write) (void *handle, void *buffer, gint32 offset, gint32 count);
typedef void (*Stream_Seek) (void *handle, gint64 offset, gint32 origin);
typedef void (*Stream_Close) (void *handle);
struct ManagedStreamCallbacks {
void *handle;
Stream_CanSeek CanSeek;
Stream_CanRead CanRead;
Stream_Length Length;
Stream_Position Position;
Stream_Read Read;
Stream_Write Write;
Stream_Seek Seek;
Stream_Close Close;
};
class MOON_API ManagedUnzip {
public:
/* @GeneratePInvoke */
static gboolean StreamToStream (ManagedStreamCallbacks *source, ManagedStreamCallbacks *dest, const char *partname);
static gboolean StreamToStreamFirstFile (ManagedStreamCallbacks *source, ManagedStreamCallbacks *dest);
static gboolean IsCurrentFileValid (unzFile zipFile);
/* @GeneratePInvoke */
static gboolean StreamToStreamNthFile (ManagedStreamCallbacks *source, ManagedStreamCallbacks *dest, int file);
static gboolean ExtractToStream (unzFile zipFile, ManagedStreamCallbacks *dest);
};
G_GNUC_INTERNAL void g_ptr_array_insert (GPtrArray *array, guint index, void *item);
G_GNUC_INTERNAL void g_ptr_array_insert_sorted (GPtrArray *array, GCompareFunc cmp, void *item);
void MergeSort (void *base, size_t nmemb, size_t size, GCompareFunc compare);
enum CanonMode {
CanonModeNone,
CanonModeXap,
CanonModeResource
};
bool UnzipByteArrayToDir (GByteArray *array, const char *dir, CanonMode mode);
bool ExtractFile (unzFile zip, int fd);
bool ExtractAll (unzFile zip, const char *dir, CanonMode mode);
char *MakeTempDir (char *tmpdir);
char *CreateTempDir (const char *filename);
int RemoveDir (const char *dir);
int CopyFileTo (const char *filename, int fd);
bool UInt32TryParse (const char *str, gint32 *retval, int *err);
bool Int32TryParse (const char *str, gint32 *retval, int *err);
int write_all (int fd, const char *buf, size_t len);
cairo_t *measuring_context_create (void);
void measuring_context_destroy (cairo_t *cr);
GArray *double_garray_from_str (const char *s, gint max);
/*
* Returns a pointer to the first token found.
*
* @input: the input string
* @c: output, upon return contains the first character not in the token.
* @end: output, upon return contains a pointer to the remaining input (NULL if no more data)
*
* Note: the input string is modified.
*/
char *parse_rfc_1945_token (char *input, char *c, char **end);
/*
* Returns a pointer to the unquoted string.
*
* @input: the input string
* @c: output, upon return contains the first character not in the quoted string.
* @end: output, upon return contains a pointer to the remaining input (NULL if no more data)
*
* Note: the input string is modified.
*/
char *parse_rfc_1945_quoted_string (char *input, char *c, char **end);
G_END_DECLS
class TextStream {
protected:
char buffer[4096];
size_t buflen;
char *bufptr;
GIConv cd;
char *textbuf;
char *textbufptr;
int textbufsize;
int fd;
bool eof;
bool fmode;
bool ReadBOM (bool force);
ssize_t ReadInternal (char *buf, ssize_t n);
public:
TextStream ();
~TextStream ();
bool OpenBuffer (const char *buf, int size);
bool OpenFile (const char *filename, bool force);
void Close ();
bool Eof ();
ssize_t Read (char *buf, size_t n);
};
typedef void (*CancelCallback) (HttpRequest *request, void *context);
class Cancellable {
private:
CancelCallback cancel_cb;
HttpRequest *request;
void *context;
public:
Cancellable ();
~Cancellable ();
void Cancel ();
void SetCancelFuncAndData (CancelCallback cb, HttpRequest *user_data, void *context);
HttpRequest *GetRequest () { return request; }
};
};
#endif /* __UTILS_H__ */
| 26.916667 | 117 | 0.721583 |
a20f5aeb5430c77516d5424ec5b534a101626f9f | 1,011 | c | C | lib/wizards/nalle/area2/monsters/rat.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | lib/wizards/nalle/area2/monsters/rat.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | lib/wizards/nalle/area2/monsters/rat.c | vlehtola/questmud | 8bc3099b5ad00a9e0261faeb6637c76b521b6dbe | [
"MIT"
] | null | null | null | inherit "obj/monster";
reset(arg) {
string chat_str, a_chat_str;
object money;
::reset(arg);
if (arg) { return; }
set_level(6);
set_name("Rat");
set_alias("rat");
set_short("A pestilent rat");
set_long("A dirty rat, ridden with fleas, observes you with bulging deformed eyes.\n");
set_al(-2);
set_aggressive(0);
set_move_at_random(0);
if (!chat_str) {
chat_str = allocate(3);
chat_str[0] =
"The rat runs into the shadows.\n";
chat_str[1] =
"The rat starts nibbling on the limb of a dead leper.\n";
chat_str[2] =
"The smell of decomposing corpses makes you nauseous.\n";
}
if (!a_chat_str) {
a_chat_str = allocate(1);
a_chat_str[0] = "The rat waves its tail in anger.\n";
}
load_chat(10, chat_str);
load_a_chat(10, a_chat_str);
money = clone_object("obj/money");
call_other(money, "set_money", random(5));
move_object(money, this_object());
}
| 27.324324 | 91 | 0.594461 |
a21126a677eb6311a8a28b61187c19ce3eace129 | 2,908 | h | C | GUISupport/QtQuick/QQuickVTKInteractorAdapter.h | cclauss/VTK | f62a52cce9044159efb4adb7cc0cfd7ec0bc8b6d | [
"BSD-3-Clause"
] | 1,755 | 2015-01-03T06:55:00.000Z | 2022-03-29T05:23:26.000Z | GUISupport/QtQuick/QQuickVTKInteractorAdapter.h | cclauss/VTK | f62a52cce9044159efb4adb7cc0cfd7ec0bc8b6d | [
"BSD-3-Clause"
] | 29 | 2015-04-23T20:58:30.000Z | 2022-03-02T16:16:42.000Z | GUISupport/QtQuick/QQuickVTKInteractorAdapter.h | cclauss/VTK | f62a52cce9044159efb4adb7cc0cfd7ec0bc8b6d | [
"BSD-3-Clause"
] | 1,044 | 2015-01-05T22:48:27.000Z | 2022-03-31T02:38:26.000Z | /*=========================================================================
Program: Visualization Toolkit
Module: QQuickVTKInteractorAdapter.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#ifndef QQuickVTKInteractorAdapter_h
#define QQuickVTKInteractorAdapter_h
// VTK includes
#include "QVTKInteractorAdapter.h"
#include "vtkGUISupportQtQuickModule.h" // for export macro
// Qt includes
#include <QList> // for QList
#include <QPointer> // for QPointer
// Forward declarations
class QEnterEvent;
class QEvent;
class QFocusEvent;
class QHoverEvent;
class QKeyEvent;
class QMouseEvent;
class QQuickItem;
class QQuickWindow;
class QWheelEvent;
class vtkRenderWindowInteractor;
class vtkRenderer;
/**
* @class QQuickVTKInteractorAdapter
* @brief Intermediate class that handles relaying Qt events to VTK
*/
class VTKGUISUPPORTQTQUICK_EXPORT QQuickVTKInteractorAdapter : public QVTKInteractorAdapter
{
Q_OBJECT
typedef QVTKInteractorAdapter Superclass;
public:
QQuickVTKInteractorAdapter(QObject* parent = nullptr);
void setQQuickWindow(QQuickWindow* win);
void QueueHoverEvent(QQuickItem* item, QHoverEvent* e);
void QueueKeyEvent(QQuickItem* item, QKeyEvent* e);
void QueueFocusEvent(QQuickItem* item, QFocusEvent* e);
void QueueMouseEvent(QQuickItem* item, QMouseEvent* e);
void QueueGeometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry);
void QueueWheelEvent(QQuickItem* item, QWheelEvent* e);
void ProcessEvents(vtkRenderWindowInteractor* interactor);
/*
* Map the event position to VTK display coordinates
* The mapping considers the following:
* - VTK widgets expect display coordinates, not viewport/local coordinates
* - vtkRenderWindowInteractor flips Y before processing the event.
* Because of the inherent flip in the superclass, the mapping does not flip Y implicitly.
* To map and flip Y, use mapEventPositionFlipY.
*
* \sa mapEventPositionFlipY
*/
static QPointF mapEventPosition(QQuickItem* item, const QPointF& localPos);
/*
* Map the event position to VTK display coordinates and flip the Y axis to switch the point from
* the Qt coordinate reference system to VTK's.
*
* \sa mapEventPosition
*/
static QPointF mapEventPositionFlipY(QQuickItem* item, const QPointF& localPos);
protected:
void QueueEvent(QEvent* e);
private:
QPointer<QQuickWindow> m_qwindow;
QList<QEvent*> m_queuedEvents;
Q_DISABLE_COPY(QQuickVTKInteractorAdapter)
};
#endif // QQuickVTKInteractorAdapter_h
| 31.268817 | 99 | 0.736933 |
a212ccb584155889fde1c4899c5b90af3b57d726 | 401 | h | C | editor/VandaEngine1/CustomRichEditCtrl.h | ehsankamrani/vandaengine | 854430e41db6df1f4fcad9c19718fd8dfcc2c3cb | [
"MIT"
] | 12 | 2021-06-22T11:28:12.000Z | 2022-03-21T00:56:33.000Z | editor/VandaEngine1/CustomRichEditCtrl.h | ehsankamrani/vandaengine | 854430e41db6df1f4fcad9c19718fd8dfcc2c3cb | [
"MIT"
] | null | null | null | editor/VandaEngine1/CustomRichEditCtrl.h | ehsankamrani/vandaengine | 854430e41db6df1f4fcad9c19718fd8dfcc2c3cb | [
"MIT"
] | 1 | 2018-10-05T08:17:29.000Z | 2018-10-05T08:17:29.000Z | //Copyright (C) 2022 Ehsan Kamrani
//This file is licensed and distributed under MIT license
#pragma once
// CCustomRichEditCtrl
class CCustomRichEditCtrl : public CRichEditCtrl
{
DECLARE_DYNAMIC(CCustomRichEditCtrl)
public:
CCustomRichEditCtrl();
virtual ~CCustomRichEditCtrl();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
};
| 16.708333 | 63 | 0.783042 |
a21306881640de402dd601dd0ebd7962b9cb84bf | 2,849 | h | C | applications/physbam/physbam-lib/Public_Library/PhysBAM_Geometry/Topology/POLYGON_MESH.h | schinmayee/nimbus | 170cd15e24a7a88243a6ea80aabadc0fc0e6e177 | [
"BSD-3-Clause"
] | 20 | 2017-07-03T19:09:09.000Z | 2021-09-10T02:53:56.000Z | PhysBAM/Public_Library/PhysBAM_Geometry/Topology/POLYGON_MESH.h | uwgraphics/PhysicsBasedModeling-Core | dbc65b8e93b1a3d69fcc82aba06d28dc6c0adb8b | [
"BSD-3-Clause"
] | null | null | null | PhysBAM/Public_Library/PhysBAM_Geometry/Topology/POLYGON_MESH.h | uwgraphics/PhysicsBasedModeling-Core | dbc65b8e93b1a3d69fcc82aba06d28dc6c0adb8b | [
"BSD-3-Clause"
] | 9 | 2017-09-17T02:05:06.000Z | 2020-01-31T00:12:01.000Z | //#####################################################################
// Copyright 2006, Eftychios Sifakis.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
// Class POLYGON_MESH
//#####################################################################
#ifndef __POLYGON_MESH__
#define __POLYGON_MESH__
#include <PhysBAM_Tools/Arrays/ARRAY.h>
#include <PhysBAM_Tools/Data_Structures/PAIR.h>
namespace PhysBAM{
class SEGMENT_MESH;
class POLYGON_MESH
{
public:
int number_nodes; // number of nodes in the mesh
ARRAY<ARRAY<ARRAY<int> > > elements; // for each polygon, loop component, and vertex
SEGMENT_MESH* segment_mesh; // elements guaranteed to be lexographically ordered
ARRAY<ARRAY<ARRAY<PAIR<int,bool> > > >* element_oriented_edges; // true indicates that the element has the edge oriented as in the segment mesh
ARRAY<ARRAY<int> >* edge_elements; // for each element in segment mesh indicates which polygon elements contain it
POLYGON_MESH(); // simplest constructor - null mesh
POLYGON_MESH(const int number_nodes_input,const ARRAY<ARRAY<ARRAY<int> > >& polygon_list);
POLYGON_MESH(const POLYGON_MESH& mesh);
virtual ~POLYGON_MESH();
private:
void operator=(const POLYGON_MESH&); // use Initialize_Mesh instead
public:
void Initialize_Mesh(const int number_nodes_input,const ARRAY<ARRAY<ARRAY<int> > >& polygon_list) // construct a mesh given a list of polygons
{Clean_Memory();number_nodes=number_nodes_input;elements=polygon_list;}
void Initialize_Mesh(const POLYGON_MESH& mesh) // works with the copy constructor
{Initialize_Mesh(mesh.number_nodes,mesh.elements);}
void Add_Nodes(const int new_nodes)
{Set_Number_Nodes(number_nodes+new_nodes);}
//#####################################################################
virtual void Clean_Memory();
virtual void Delete_Auxiliary_Structures();
virtual void Refresh_Auxiliary_Structures();
virtual bool Assert_Consistent() const;
virtual void Set_Number_Nodes(const int number_nodes_input);
void Initialize_Segment_Mesh();
void Initialize_Element_Oriented_Edges();
void Initialize_Edge_Elements();
bool Oriented_Edge_In_Element(const int node1,const int node2,const int element) const;
int Elements_On_Edge(const int node1,const int node2,ARRAY<int>* elements_on_edge) const;
int Elements_On_Oriented_Edge(const int node1,const int node2,ARRAY<int>* elements_on_oriented_edge) const;
int Opposite_Oriented_Element(const int element) const;
void Split_Polygon_Edge(const int node1,const int node2,const int new_node);
//#####################################################################
};
}
#endif
| 46.704918 | 147 | 0.673219 |
a2146b38d374376ae6f18c7553f23f1257454a5b | 10,514 | c | C | findpat/tools/findpat.c | kapow-argentina/findpat | 6975efb4414197bf91babd7775bb8c48d2befd0f | [
"MIT"
] | null | null | null | findpat/tools/findpat.c | kapow-argentina/findpat | 6975efb4414197bf91babd7775bb8c48d2befd0f | [
"MIT"
] | null | null | null | findpat/tools/findpat.c | kapow-argentina/findpat | 6975efb4414197bf91babd7775bb8c48d2befd0f | [
"MIT"
] | 1 | 2021-12-13T03:01:32.000Z | 2021-12-13T03:01:32.000Z | #include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libp2zip.h"
#include "bwt.h"
#include "lcp.h"
#include "mrs.h"
#include "mmrs.h"
#include "common.h"
#include "macros.h"
/* SAVE_TRIPLES guarda los patrones en un archivo 'triples.dat', for debug */
/* # define SAVE_TRIPLES */
#define BWT 0
#define OBWT 1
#define MRS 0
#define MMRS 1
/* set<int> */
#define SET_INT_SZ 1024
typedef struct str_set_int {
int cnt[SET_INT_SZ];
int cap, l, tot;
int* vec;
} set_int;
void set_int_clear(set_int* this) {
memset(this->cnt, 0, sizeof(this->cnt));
this->l = 0;
this->tot = 0;
}
void set_int_create(set_int* this) {
this->cap = 128;
this->vec = pz_malloc(this->cap*2*sizeof(int));
set_int_clear(this);
}
void set_int_destroy(set_int* this) {
pz_free(this->vec);
}
void set_int_resize(set_int* this, int ncap) {
int *p = pz_malloc(ncap*2*sizeof(int));
memcpy(p, this->vec, this->l*2*sizeof(int));
pz_free(this->vec);
this->vec = p;
this->cap = ncap;
}
void set_int_add(set_int* this, int x) {
int i;
this->tot++;
if (x < SET_INT_SZ) { this->cnt[x]++; return; }
forn(i, this->l) if (this->vec[2*i] == x) { this->vec[2*i+1]++; return; }
if (this->l == this->cap) set_int_resize(this, 2*this->cap);
this->vec[2*this->l] = x;
this->vec[2*this->l+1] = 1;
this->l++;
}
/* General options */
int files_gz=1;
int files_fa=1;
int strip_n=1;
char* save_bwt = NULL;
#define ONLY_LEFT 1
#define ONLY_RIGHT 2
#define ONLY_BOTH 3
#define ONLY_ALL 0
struct dto_findpat_struct {
/* general options */
uint* r;
uchar* s;
int trac_pos, full_pos, middle, only;
/* full mode (-p) */
int mode_full;
FILE* f_p;
char* fn_p;
int ml_p;
/* statistics mode (-S) */
int mode_stats;
FILE* f_S;
char* fn_S;
int ml_S;
/* small-statistics mode (-s) */
int mode_small;
FILE* f_s;
char* fn_s;
set_int si;
int llen, ml_s;
};
typedef struct dto_findpat_struct dto_findpat;
void dfp_create(dto_findpat* this) {
this->mode_full = 0;
this->mode_stats = 0;
this->mode_small = 0;
this->only = ONLY_ALL;
this->trac_pos = 1;
this->full_pos = 1;
this->r = NULL;
this->s = NULL;
this->fn_p = this->fn_S = this->fn_s = NULL;
this->llen = -1;
this->middle = 0;
}
void dfp_destroy(dto_findpat* this) {
if (this->fn_p) { pz_free(this->fn_p); this->fn_p = 0; }
if (this->fn_S) { pz_free(this->fn_S); this->fn_S = 0; }
if (this->fn_s) { pz_free(this->fn_s); this->fn_s = 0; }
if (this->mode_small) set_int_destroy(&(this->si));
}
#define DFP_OK 1
#define DFP_NOT_FULL 2
#define DFP_NOT_STATS 3
#define DFP_NOT_SMALL 4
int dfp_open(dto_findpat* this) {
if (this->mode_full) {
this->f_p = fopen(this->fn_p, "wt");
if (!this->f_p) return DFP_NOT_FULL;
}
if (this->mode_stats) {
this->f_S = fopen(this->fn_S, "wt");
if (!this->f_S) {
if (this->mode_full) fclose(this->f_p);
return DFP_NOT_STATS;
}
}
if (this->mode_small) {
this->f_s = fopen(this->fn_s, "wt");
if (!this->f_s) {
if (this->mode_full) fclose(this->f_p);
if (this->mode_stats) fclose(this->f_S);
return DFP_NOT_SMALL;
}
}
if (this->mode_small) {
fprintf(this->f_s, "len\treps\t#pats\n");
set_int_create(&(this->si));
}
if (this->mode_stats) {
fprintf(this->f_S, "len\treps\t#<\t#>\n");
}
return DFP_OK;
}
void dfp_print_pats(FILE* f, set_int* si, int len);
void dfp_close(dto_findpat* this) {
if (this->mode_full) fclose(this->f_p);
if (this->mode_stats) fclose(this->f_S);
if (this->mode_small) {
dfp_print_pats(this->f_s, &(this->si), this->llen);
fclose(this->f_s);
}
}
ppz_status pz;
void dfp_print_pats(FILE* f, set_int* si, int len) {
int i;
forn(i, SET_INT_SZ) if (si->cnt[i]) fprintf(f, "%u\t%u\t%u\n", len, i, si->cnt[i]);
forn(i, si->l) fprintf(f, "%u\t%u\t%u\n", len, si->vec[2*i], si->vec[2*i+1]);
set_int_clear(si);
}
#ifdef SAVE_TRIPLES
FILE* f_triples;
#endif
void dfp_output(uint l, uint i, uint n, void* vdfp) {
uint j;
dto_findpat* dfp = (dto_findpat*)vdfp;
int cn[2]; cn[0] = cn[1] = 0;
forn(j, n) cn[dfp->r[i+j] >= dfp->middle]++;
if (dfp->only == ONLY_BOTH && (!cn[0] || !cn[1])) return;
if (dfp->only == ONLY_LEFT && cn[1]) return;
if (dfp->only == ONLY_RIGHT && cn[0]) return;
if (dfp->mode_stats) { // Print statistics mode
fprintf(dfp->f_S,"%u\t%u\t%u\t%u\n", l, n, cn[0], cn[1]);
}
if (dfp->mode_small) { // Print small statistics mode
if (l != dfp->llen) {
dfp_print_pats(dfp->f_s, &(dfp->si), dfp->llen);
dfp->llen = l;
}
set_int_add(&dfp->si, n);
}
if (dfp->mode_full) { // Print expanded (full mode)
forn(j,l) fprintf(dfp->f_p, "%c", dfp->s[dfp->r[i]+j]);
fprintf(dfp->f_p," #%u (%u)\n", n, l);
if (dfp->full_pos) {
fprintf(dfp->f_p," ");
forn(j,n) fprintf(dfp->f_p, " %c%d", (dfp->r[i+j]<dfp->middle?'<':'>'),
((dfp->trac_pos)?
(dfp->r[i+j]<dfp->middle?ppz_trac_convert(&pz, dfp->r[i+j]):ppz_trac_convert(&pz, dfp->r[i+j])-pz.trac_middle):
(dfp->r[i+j]<dfp->middle?dfp->r[i+j]:dfp->r[i+j]-dfp->middle))
);
fprintf(dfp->f_p,"\n");
}
}
#ifdef SAVE_TRIPLES
/*
uint data[3] = {l, i, n};
fwrite(data, 3, sizeof(uint), f_triples);
*/
if (l >= 1) fprintf(f_triples, "%u\t%d\n", l, n);
#endif
}
const char* prefixes[4][3] = {
{"full", "stat", "smal"},
{"fullL", "statL", "smalL"},
{"fullR", "statR", "smalR"},
{"full2", "stat2", "smal2"} };
void findpat(const char* in1, const char* in2, const char* outn, uint ml, dto_findpat* dfp, int flags) {
/*Read file and get BWT*/
uint n;
uint *p, *r, *h;
char* bwtf = NULL;
const char* prefix[3];
int dfp_open_err;
memcpy(prefix, prefixes[dfp->only], sizeof(prefix));
ppz_create(&pz);
pz.fa_input = files_fa;
pz.gz_input = files_gz;
pz.fa_strip_n = strip_n;
pz.use_terminator = 1;
pz.use_separator = 1;
pz.trac_positions = dfp->trac_pos;
/* Try to load the precalculated BWT */
bwtf = std_name(outn, NULL, in1, in2, "bwt");
if (save_bwt == NULL) save_bwt = bwtf;
if (ppz_load_bwt(&pz, save_bwt)) {
/* BWT loaded from file */
ppz_trac_load(&pz, in1);
ppz_trac_load(&pz, in2);
} else {
ppz_load_file2(&pz, in1, in2);
if (flags & 1) ppz_obwt(&pz);
else ppz_bwt(&pz);
ppz_write_stats(&pz, "findpat.txt");
// ppz_save_bwt(&pz, save_bwt);
}
pz_free(bwtf);
srand(31416);
n=pz.data.n;
p=pz.p;
r=pz.r;
// Obtiene src.
uchar *src = pz.s; // (uchar*)pz_malloc(n * sizeof(uchar));
// memcpy(src, ((uchar*)(p+n))-n, n);
/* Computes p[] and saves r[]*/
// forn(i, n) p[r[i]] = i;
// DBGu(n); DBGun(p, n); DBGun(r, n); DBGcn(src, n);
// DBGun(pz.trac_buf, pz.trac_size*2);
h = (uint*)pz_malloc(n*sizeof(uint));
dfp->middle = pz.data.long_input_a;
fprintf(stderr,"start lcp\n");
memcpy(h, r, n*sizeof(uint));
lcp(n, src, h, p);
fprintf(stderr,"start mrs\n");
dfp->r = r;
dfp->s = src;
dfp->fn_p = std_name(outn, prefix[0], in1, in2, "txt");
dfp->fn_S = std_name(outn, prefix[1], in1, in2, "txt");
dfp->fn_s = std_name(outn, prefix[2], in1, in2, "txt");
dfp_open_err = dfp_open(dfp);
if (dfp_open_err != DFP_OK) {
if (dfp_open_err == DFP_NOT_FULL) {
fprintf(stderr, "Could not open output file %s.\n", dfp->fn_p);
} else if (dfp_open_err == DFP_NOT_STATS) {
fprintf(stderr, "Could not open output file %s.\n", dfp->fn_S);
} else if (dfp_open_err == DFP_NOT_SMALL) {
fprintf(stderr, "Could not open output file %s.\n", dfp->fn_s);
} else {
fprintf(stderr, "Undetermined error when opening output files.\n");
}
return;
}
if (flags & 2) mmrs(src, n, r, h, ml, dfp_output, dfp);
else mrs(src, n, r, h, p, ml, dfp_output, dfp);
dfp_close(dfp);
pz_free(h);
//pz_free(src);
ppz_destroy(&pz);
}
int main(int argc, char* argv[]) {
fprintf(stderr, "findpat - rev%d\n", SVNREVISION);
char* files[4];
int nf = 0, i, bwtv = BWT, mrsv = MRS;
uint ml = -1;
dto_findpat dfp;
dfp_create(&dfp);
int flag2 = 0, flagl = 0, flagr = 0;
#ifdef SAVE_TRIPLES
f_triples = fopen("triples.dat", "wt");
#endif
forsn(i, 1, argc) {
if (0);
else cmdline_var(i, "z", files_gz)
else cmdline_var(i, "f", files_fa)
else cmdline_var(i, "r", dfp.trac_pos)
else cmdline_var(i, "2", flag2)
else cmdline_var(i, "L", flagl)
else cmdline_var(i, "R", flagr)
else cmdline_var(i, "S", dfp.mode_stats)
else cmdline_var(i, "s", dfp.mode_small)
else cmdline_var(i, "p", dfp.mode_full)
else cmdline_var(i, "o", dfp.full_pos)
else cmdline_opt_1(i, "--obwt") { bwtv = OBWT; }
else cmdline_opt_1(i, "--mmrs") { mrsv = MMRS; }
else cmdline_opt_2(i, "--bwt") { save_bwt = argv[i]; }
else cmdline_opt_2(i, "--no-strip-n") { strip_n = 0; }
else if (cmdline_is_opt(i)) {
fprintf(stderr, "%s: Unknown option: %s\n", argv[0], argv[i]);
return 1;
}
else { // Default parameter
if (nf == 4) {
fprintf(stderr, "%s: Too many parameters: %s\n", argv[0], argv[i]);
return 1;
}
files[nf++] = argv[i];
}
}
if (nf == 4) {
ml = atoi(files[3]);
}
if (nf != 4 || ml <= 0 || (flag2 + flagr + flagl > 1)) {
fprintf(stderr, "Use: %s [options] <input1> <input2> <output> <min_length>\n", argv[0]);
fprintf(stderr, "Options: (-/+ before the option activates/deactivates the option)\n"
" f Treats the input as FASTA files when possible (default is on).\n"
" z Treats the input as a compressed gzip file. If it's not compressed ignores this flag.\n"
" L | R | 2 Print only patterns in left/right/both file(s) (default is print all). Only use one of these.\n"
" o Print position of each ocurrence of each pattern in full mode (default is on).\n"
" r Show real positions of patterns long lists of Ns (default is on)\n"
"\n"
" Output options:\n"
" S Print in statistics mode (one line for each pattern with len and count).\n"
" s Print in small-statistics mode (one line for each pair len/count indicating ocurrences).\n"
" p Print in full mode (patterns and positions).\n"
"\n"
" Other options:\n"
" --bwt <file.bwt> Uses <file.bwt> as precalculated BWT.\n"
" --obwt Uses the optimized bwt algorithm.\n"
" --mmrs Only finds the maximal maximal repeated substrings\n"
);
return 1;
}
if (flag2) dfp.only = ONLY_BOTH;
else if (flagl) dfp.only = ONLY_LEFT;
else if (flagr) dfp.only = ONLY_RIGHT;
else dfp.only = ONLY_ALL;
if (!dfp.mode_full && !dfp.mode_small && !dfp.mode_stats) dfp.mode_full = 1; // If none set, set full.
dfp.ml_p = dfp.ml_S = dfp.ml_s = ml;
findpat(files[0], files[1], files[2], ml, &dfp, bwtv + (mrsv << 1) );
dfp_destroy(&dfp);
#ifdef SAVE_TRIPLES
fclose(f_triples);
#endif
return 0;
}
| 26.219451 | 116 | 0.625547 |
a2149bc66b868f9926acf84dc5f37650d2eeb250 | 607 | h | C | UnityServices/Ads/WebPlayer/UADSWebPlayerView.h | katoorukavya/unity-ads-ios | 52f6e80d00113304e5f52731e6b3a49e202bfc3c | [
"Apache-2.0"
] | 4 | 2017-10-08T10:54:11.000Z | 2019-12-10T20:48:31.000Z | UnityServices/Ads/WebPlayer/UADSWebPlayerView.h | katoorukavya/unity-ads-ios | 52f6e80d00113304e5f52731e6b3a49e202bfc3c | [
"Apache-2.0"
] | null | null | null | UnityServices/Ads/WebPlayer/UADSWebPlayerView.h | katoorukavya/unity-ads-ios | 52f6e80d00113304e5f52731e6b3a49e202bfc3c | [
"Apache-2.0"
] | 1 | 2017-10-08T10:34:56.000Z | 2017-10-08T10:34:56.000Z | #import <UIKit/UIKit.h>
@interface UADSWebPlayerView : UIView
- (instancetype)initWithFrame:(CGRect)frame viewId:(NSString*)viewId webPlayerSettings:(NSDictionary*)webPlayerSettings;
-(void)loadUrl:(NSString*)url;
-(void)loadData:(NSString*)data mimeType:(NSString *)mimeType encoding:(NSString *)encoding;
-(void)loadData:(NSString*)data mimeType:(NSString *)mimeType encoding:(NSString *)encoding baseUrl:(NSString *)baseUrl;
-(void)setWebPlayerSettings:(NSDictionary*)webPlayerSettings;
-(void)setEventSettings:(NSDictionary*)eventSettings;
-(void)receiveEvent:(NSString *)params;
- (void)destroy;
@end
| 46.692308 | 120 | 0.792422 |
a218003f9101c20b4ac30f45ceff339b1eab0088 | 13,496 | c | C | linux_packages/source/hypre-2.9.0b/src/babel/bHYPREClient-F90/sidl_bool_fStub.c | pangkeji/warp3d | 8b273b337e557f734298940a63291697cd561d02 | [
"NCSA"
] | 75 | 2015-07-06T18:14:20.000Z | 2022-01-24T02:54:32.000Z | linux_packages/source/hypre-2.9.0b/src/babel/bHYPREClient-F90/sidl_bool_fStub.c | pangkeji/warp3d | 8b273b337e557f734298940a63291697cd561d02 | [
"NCSA"
] | 15 | 2017-04-07T18:09:58.000Z | 2022-02-28T01:48:33.000Z | linux_packages/source/hypre-2.9.0b/src/babel/bHYPREClient-F90/sidl_bool_fStub.c | pangkeji/warp3d | 8b273b337e557f734298940a63291697cd561d02 | [
"NCSA"
] | 41 | 2015-05-24T23:24:54.000Z | 2021-12-13T22:07:45.000Z | /*********************************************************************
* File: sidl_bool_fStub.c
* Copyright: (C) 2001-2004 The Regents of the University of California
* Description: FORTRAN API for arrays of bool
* Revision: $Revision: 1.1 $
*
* AUTOMATICALLY GENERATED BY genfortranarrays.py
**********************************************************************/
#include "sidl_header.h"
#ifndef included_babel_config_h
#include "babel_config.h"
#endif
#include "sidlfortran.h"
#ifndef included_sidlType_h
#include "sidlType.h"
#endif
#ifndef included_sidlArray_h
#include "sidlArray.h"
#endif
#ifndef FORTRAN90_DISABLED
#include "sidlf90array.h"
#endif
#include <stdlib.h>
#include <stddef.h>
#ifndef FORTRAN90_DISABLED
/*---------------------------------------------------------------------*
* Fortran 90 Array Routines
*---------------------------------------------------------------------*/
#include "sidl_bool_fAbbrev.h"
void
SIDLFortran90Symbol(sidl_bool__array_createcol_m,
SIDL_BOOL__ARRAY_CREATECOL_M,
sidl_bool__array_createCol_m)
(int32_t *dimen, int32_t lower[], int32_t upper[], int64_t *result)
{
*result = (ptrdiff_t)
sidl_bool__array_createCol(*dimen, lower, upper);
}
void
SIDLFortran90Symbol(sidl_bool__array_createrow_m,
SIDL_BOOL__ARRAY_CREATEROW_M,
sidl_bool__array_createRow_m)
(int32_t *dimen, int32_t lower[], int32_t upper[], int64_t *result)
{
*result = (ptrdiff_t)
sidl_bool__array_createRow(*dimen, lower, upper);
}
void
SIDLFortran90Symbol(sidl_bool__array_create1d_m,
SIDL_BOOL__ARRAY_CREATE1D_M,
sidl_bool__array_create1d_m)
(int32_t *len, int64_t *result)
{
*result = (ptrdiff_t)
sidl_bool__array_create1d(*len);
}
void
SIDLFortran90Symbol(sidl_bool__array_create2drow_m,
SIDL_BOOL__ARRAY_CREATE2DROW_M,
sidl_bool__array_create2dRow_m)
(int32_t *m, int32_t *n, int64_t *result)
{
*result = (ptrdiff_t)
sidl_bool__array_create2dRow(*m, *n);
}
void
SIDLFortran90Symbol(sidl_bool__array_create2dcol_m,
SIDL_BOOL__ARRAY_CREATE2DCOL_M,
sidl_bool__array_create2dCol_m)
(int32_t *m, int32_t *n, int64_t *result)
{
*result = (ptrdiff_t)
sidl_bool__array_create2dCol(*m, *n);
}
void
SIDLFortran90Symbol(sidl_bool__array_ensure_m,
SIDL_BOOL__ARRAY_ENSURE_M,
sidl_bool__array_ensure_m)
(int64_t *src, int32_t *dimen, int32_t *ordering, int64_t *result)
{
*result = (ptrdiff_t)
sidl_bool__array_ensure((struct sidl_bool__array*)(ptrdiff_t)*src,
*dimen, (int)*ordering);
}
void
SIDLFortran90Symbol(sidl_bool__array_smartcopy_m,
SIDL_BOOL__ARRAY_SMARTCOPY_M,
sidl_bool__array_smartCopy_m)
(int64_t *src, int64_t *result)
{
*result = (ptrdiff_t)
sidl_bool__array_smartCopy((struct sidl_bool__array*)(ptrdiff_t)*src);
}
void
SIDLFortran90Symbol(sidl_bool__array_slice_m,
SIDL_BOOL__ARRAY_SLICE_M,
sidl_bool__array_slice_m)
(int64_t *src, int32_t *dimen, int32_t numElem[], int32_t srcStart[],
int32_t srcStride[], int32_t newStart[], int64_t *result)
{
*result = (ptrdiff_t)
sidl_bool__array_slice((struct sidl_bool__array *)(ptrdiff_t)*src,
*dimen, numElem, srcStart, srcStride, newStart);
}
void
SIDLFortran90Symbol(sidl_bool__array_cast_m,
SIDL_BOOL__ARRAY_CAST_M,
sidl_bool__array_cast_m)
(int64_t *array, int32_t *dimen, int64_t *result)
{
struct sidl_bool__array *tmp =
sidl_bool__array_cast((struct sidl__array *)(ptrdiff_t)*array);
*result = ((tmp && (sidlArrayDim(tmp) == *dimen)) ? (ptrdiff_t)tmp : 0);
}
void
SIDLFortran90Symbol(sidl_bool__array_copy_m,
SIDL_BOOL__ARRAY_COPY_M,
sidl_bool__array_copy_m)
(int64_t *src, int64_t *dest)
{
sidl_bool__array_copy((struct sidl_bool__array*)(ptrdiff_t)*src,
(struct sidl_bool__array*)(ptrdiff_t)*dest);
}
void
SIDLFortran90Symbol(sidl_bool__array_iscolumnorder_m,
SIDL_BOOL__ARRAY_ISCOLUMNORDER_M,
sidl_bool__array_isColumnOrder_m)
(int64_t *array, sidl_bool *result)
{
*result = (
sidl_bool__array_isColumnOrder((struct sidl_bool__array *)(ptrdiff_t)*array)
? SIDL_F90_TRUE : SIDL_F90_FALSE);
}
void
SIDLFortran90Symbol(sidl_bool__array_isroworder_m,
SIDL_BOOL__ARRAY_ISROWORDER_M,
sidl_bool__array_isRowOrder_m)
(int64_t *array, sidl_bool *result)
{
*result = (
sidl_bool__array_isRowOrder((struct sidl_bool__array *)(ptrdiff_t)*array)
? SIDL_F90_TRUE : SIDL_F90_FALSE);
}
void
SIDLFortran90Symbol(sidl_bool__array_dimen_m,
SIDL_BOOL__ARRAY_DIMEN_M,
sidl_bool__array_dimen_m)
(int64_t *array, int32_t *result)
{
*result =
sidl_bool__array_dimen((struct sidl_bool__array *)(ptrdiff_t)*array);
}
void
SIDLFortran90Symbol(sidl_bool__array_stride_m,
SIDL_BOOL__ARRAY_STRIDE_M,
sidl_bool__array_stride_m)
(int64_t *array, int32_t *index, int32_t *result)
{
*result =
sidl_bool__array_stride((struct sidl_bool__array *)(ptrdiff_t)*array, *index);
}
void
SIDLFortran90Symbol(sidl_bool__array_lower_m,
SIDL_BOOL__ARRAY_LOWER_M,
sidl_bool__array_lower_m)
(int64_t *array, int32_t*ind, int32_t *result)
{
*result =
sidl_bool__array_lower((struct sidl_bool__array *)(ptrdiff_t)*array, *ind);
}
void
SIDLFortran90Symbol(sidl_bool__array_upper_m,
SIDL_BOOL__ARRAY_UPPER_M,
sidl_bool__array_upper_m)
(int64_t *array, int32_t *ind, int32_t *result)
{
*result =
sidl_bool__array_upper((struct sidl_bool__array *)(ptrdiff_t)*array, *ind);
}
void
SIDLFortran90Symbol(sidl_bool__array_length_m,
SIDL_BOOL__ARRAY_LENGTH_M,
sidl_bool__array_length_m)
(int64_t *array, int32_t *ind, int32_t *result)
{
*result =
sidl_bool__array_length((struct sidl_bool__array *)(ptrdiff_t)*array, *ind);
}
void
SIDLFortran90Symbol(sidl_bool__array_deleteref_m,
SIDL_BOOL__ARRAY_DELETEREF_M,
sidl_bool__array_deleteRef_m)
(int64_t *array)
{
sidl_bool__array_deleteRef((struct sidl_bool__array*)(ptrdiff_t)*array);
}
void
SIDLFortran90Symbol(sidl_bool__array_addref_m,
SIDL_BOOL__ARRAY_ADDREF_M,
sidl_bool__array_addRef_m)
(int64_t *array)
{
sidl_bool__array_addRef((struct sidl_bool__array*)(ptrdiff_t)*array);
}
void
SIDLFortran90Symbol(sidl_bool__array_get1_m,
SIDL_BOOL__ARRAY_GET1_M,
sidl_bool__array_get1_m)
(int64_t *array, int32_t *i1,
sidl_bool *result)
{
sidl_bool tmp =
sidl_bool__array_get1((struct sidl_bool__array *)(ptrdiff_t)*array, *i1);
*result = (tmp ? SIDL_F90_TRUE : SIDL_F90_FALSE);
}
void
SIDLFortran90Symbol(sidl_bool__array_set1_m,
SIDL_BOOL__ARRAY_SET1_M,
sidl_bool__array_set1_m)
(int64_t *array, int32_t *i1,
sidl_bool *value)
{
sidl_bool tmp = ((*value == SIDL_F90_TRUE) ? TRUE : FALSE);
sidl_bool__array_set1((struct sidl_bool__array *)(ptrdiff_t)*array,
*i1,
tmp);
}
void
SIDLFortran90Symbol(sidl_bool__array_get2_m,
SIDL_BOOL__ARRAY_GET2_M,
sidl_bool__array_get2_m)
(int64_t *array, int32_t *i1,
int32_t *i2,
sidl_bool *result)
{
sidl_bool tmp =
sidl_bool__array_get2((struct sidl_bool__array *)(ptrdiff_t)*array, *i1,
*i2);
*result = (tmp ? SIDL_F90_TRUE : SIDL_F90_FALSE);
}
void
SIDLFortran90Symbol(sidl_bool__array_set2_m,
SIDL_BOOL__ARRAY_SET2_M,
sidl_bool__array_set2_m)
(int64_t *array, int32_t *i1,
int32_t *i2,
sidl_bool *value)
{
sidl_bool tmp = ((*value == SIDL_F90_TRUE) ? TRUE : FALSE);
sidl_bool__array_set2((struct sidl_bool__array *)(ptrdiff_t)*array,
*i1,
*i2,
tmp);
}
void
SIDLFortran90Symbol(sidl_bool__array_get3_m,
SIDL_BOOL__ARRAY_GET3_M,
sidl_bool__array_get3_m)
(int64_t *array, int32_t *i1,
int32_t *i2,
int32_t *i3,
sidl_bool *result)
{
sidl_bool tmp =
sidl_bool__array_get3((struct sidl_bool__array *)(ptrdiff_t)*array, *i1,
*i2,
*i3);
*result = (tmp ? SIDL_F90_TRUE : SIDL_F90_FALSE);
}
void
SIDLFortran90Symbol(sidl_bool__array_set3_m,
SIDL_BOOL__ARRAY_SET3_M,
sidl_bool__array_set3_m)
(int64_t *array, int32_t *i1,
int32_t *i2,
int32_t *i3,
sidl_bool *value)
{
sidl_bool tmp = ((*value == SIDL_F90_TRUE) ? TRUE : FALSE);
sidl_bool__array_set3((struct sidl_bool__array *)(ptrdiff_t)*array,
*i1,
*i2,
*i3,
tmp);
}
void
SIDLFortran90Symbol(sidl_bool__array_get4_m,
SIDL_BOOL__ARRAY_GET4_M,
sidl_bool__array_get4_m)
(int64_t *array, int32_t *i1,
int32_t *i2,
int32_t *i3,
int32_t *i4,
sidl_bool *result)
{
sidl_bool tmp =
sidl_bool__array_get4((struct sidl_bool__array *)(ptrdiff_t)*array, *i1,
*i2,
*i3,
*i4);
*result = (tmp ? SIDL_F90_TRUE : SIDL_F90_FALSE);
}
void
SIDLFortran90Symbol(sidl_bool__array_set4_m,
SIDL_BOOL__ARRAY_SET4_M,
sidl_bool__array_set4_m)
(int64_t *array, int32_t *i1,
int32_t *i2,
int32_t *i3,
int32_t *i4,
sidl_bool *value)
{
sidl_bool tmp = ((*value == SIDL_F90_TRUE) ? TRUE : FALSE);
sidl_bool__array_set4((struct sidl_bool__array *)(ptrdiff_t)*array,
*i1,
*i2,
*i3,
*i4,
tmp);
}
void
SIDLFortran90Symbol(sidl_bool__array_get5_m,
SIDL_BOOL__ARRAY_GET5_M,
sidl_bool__array_get5_m)
(int64_t *array, int32_t *i1,
int32_t *i2,
int32_t *i3,
int32_t *i4,
int32_t *i5,
sidl_bool *result)
{
sidl_bool tmp =
sidl_bool__array_get5((struct sidl_bool__array *)(ptrdiff_t)*array, *i1,
*i2,
*i3,
*i4,
*i5);
*result = (tmp ? SIDL_F90_TRUE : SIDL_F90_FALSE);
}
void
SIDLFortran90Symbol(sidl_bool__array_set5_m,
SIDL_BOOL__ARRAY_SET5_M,
sidl_bool__array_set5_m)
(int64_t *array, int32_t *i1,
int32_t *i2,
int32_t *i3,
int32_t *i4,
int32_t *i5,
sidl_bool *value)
{
sidl_bool tmp = ((*value == SIDL_F90_TRUE) ? TRUE : FALSE);
sidl_bool__array_set5((struct sidl_bool__array *)(ptrdiff_t)*array,
*i1,
*i2,
*i3,
*i4,
*i5,
tmp);
}
void
SIDLFortran90Symbol(sidl_bool__array_get6_m,
SIDL_BOOL__ARRAY_GET6_M,
sidl_bool__array_get6_m)
(int64_t *array, int32_t *i1,
int32_t *i2,
int32_t *i3,
int32_t *i4,
int32_t *i5,
int32_t *i6,
sidl_bool *result)
{
sidl_bool tmp =
sidl_bool__array_get6((struct sidl_bool__array *)(ptrdiff_t)*array, *i1,
*i2,
*i3,
*i4,
*i5,
*i6);
*result = (tmp ? SIDL_F90_TRUE : SIDL_F90_FALSE);
}
void
SIDLFortran90Symbol(sidl_bool__array_set6_m,
SIDL_BOOL__ARRAY_SET6_M,
sidl_bool__array_set6_m)
(int64_t *array, int32_t *i1,
int32_t *i2,
int32_t *i3,
int32_t *i4,
int32_t *i5,
int32_t *i6,
sidl_bool *value)
{
sidl_bool tmp = ((*value == SIDL_F90_TRUE) ? TRUE : FALSE);
sidl_bool__array_set6((struct sidl_bool__array *)(ptrdiff_t)*array,
*i1,
*i2,
*i3,
*i4,
*i5,
*i6,
tmp);
}
void
SIDLFortran90Symbol(sidl_bool__array_get7_m,
SIDL_BOOL__ARRAY_GET7_M,
sidl_bool__array_get7_m)
(int64_t *array, int32_t *i1,
int32_t *i2,
int32_t *i3,
int32_t *i4,
int32_t *i5,
int32_t *i6,
int32_t *i7,
sidl_bool *result)
{
sidl_bool tmp =
sidl_bool__array_get7((struct sidl_bool__array *)(ptrdiff_t)*array, *i1,
*i2,
*i3,
*i4,
*i5,
*i6,
*i7);
*result = (tmp ? SIDL_F90_TRUE : SIDL_F90_FALSE);
}
void
SIDLFortran90Symbol(sidl_bool__array_set7_m,
SIDL_BOOL__ARRAY_SET7_M,
sidl_bool__array_set7_m)
(int64_t *array, int32_t *i1,
int32_t *i2,
int32_t *i3,
int32_t *i4,
int32_t *i5,
int32_t *i6,
int32_t *i7,
sidl_bool *value)
{
sidl_bool tmp = ((*value == SIDL_F90_TRUE) ? TRUE : FALSE);
sidl_bool__array_set7((struct sidl_bool__array *)(ptrdiff_t)*array,
*i1,
*i2,
*i3,
*i4,
*i5,
*i6,
*i7,
tmp);
}
void
SIDLFortran90Symbol(sidl_bool__array_set_m,
SIDL_BOOL__ARRAY_SET_M,
sidl_bool__array_set_m)
(int64_t *array, int32_t indices[], sidl_bool *value)
{
sidl_bool tmp = ((*value == SIDL_F90_TRUE) ? TRUE : FALSE);
sidl_bool__array_set((struct sidl_bool__array *)(ptrdiff_t)*array, indices, tmp);
}
void
SIDLFortran90Symbol(sidl_bool__array_get_m,
SIDL_BOOL__ARRAY_GET_M,
sidl_bool__array_get_m)
(int64_t *array, int32_t indices[], sidl_bool *value)
{
sidl_bool tmp =
sidl_bool__array_get((struct sidl_bool__array *)(ptrdiff_t)*array, indices);
*value = (tmp ? SIDL_F90_TRUE : SIDL_F90_FALSE);
}
#endif /* not FORTRAN90_DISABLED */
| 25.179104 | 83 | 0.642931 |
a2196dbaabbac576ace6dc1a1458568e43d85da8 | 6,183 | h | C | OpenCL/inc_cipher_aes.h | ekmixon/hashcat | 14f78d9910a103c996a0d8af6f969bb0640b3d6c | [
"MIT"
] | null | null | null | OpenCL/inc_cipher_aes.h | ekmixon/hashcat | 14f78d9910a103c996a0d8af6f969bb0640b3d6c | [
"MIT"
] | null | null | null | OpenCL/inc_cipher_aes.h | ekmixon/hashcat | 14f78d9910a103c996a0d8af6f969bb0640b3d6c | [
"MIT"
] | null | null | null | /**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#ifndef _INC_CIPHER_AES_H
#define _INC_CIPHER_AES_H
DECLSPEC void aes128_ExpandKey (PRIVATE_AS u32 *ks, PRIVATE_AS const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3);
DECLSPEC void aes128_InvertKey (PRIVATE_AS u32 *ks, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3);
DECLSPEC void aes128_set_encrypt_key (PRIVATE_AS u32 *ks, PRIVATE_AS const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3);
DECLSPEC void aes128_set_decrypt_key (PRIVATE_AS u32 *ks, PRIVATE_AS const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3);
DECLSPEC void aes128_encrypt (PRIVATE_AS const u32 *ks, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4);
DECLSPEC void aes128_decrypt (PRIVATE_AS const u32 *ks, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4);
DECLSPEC void aes192_ExpandKey (PRIVATE_AS u32 *ks, PRIVATE_AS const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3);
DECLSPEC void aes192_InvertKey (PRIVATE_AS u32 *ks, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3);
DECLSPEC void aes192_set_encrypt_key (PRIVATE_AS u32 *ks, PRIVATE_AS const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3);
DECLSPEC void aes192_set_decrypt_key (PRIVATE_AS u32 *ks, PRIVATE_AS const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3);
DECLSPEC void aes192_encrypt (PRIVATE_AS const u32 *ks, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4);
DECLSPEC void aes192_decrypt (PRIVATE_AS const u32 *ks, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4);
DECLSPEC void aes256_ExpandKey (PRIVATE_AS u32 *ks, PRIVATE_AS const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3);
DECLSPEC void aes256_InvertKey (PRIVATE_AS u32 *ks, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3);
DECLSPEC void aes256_set_encrypt_key (PRIVATE_AS u32 *ks, PRIVATE_AS const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3);
DECLSPEC void aes256_set_decrypt_key (PRIVATE_AS u32 *ks, PRIVATE_AS const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3);
DECLSPEC void aes256_encrypt (PRIVATE_AS const u32 *ks, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4);
DECLSPEC void aes256_decrypt (PRIVATE_AS const u32 *ks, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4);
DECLSPEC void AES128_set_encrypt_key (PRIVATE_AS u32 *ks, PRIVATE_AS const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3);
DECLSPEC void AES128_set_decrypt_key (PRIVATE_AS u32 *ks, PRIVATE_AS const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3);
DECLSPEC void AES128_encrypt (PRIVATE_AS const u32 *ks, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4);
DECLSPEC void AES128_decrypt (PRIVATE_AS const u32 *ks, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4);
DECLSPEC void AES192_set_encrypt_key (PRIVATE_AS u32 *ks, PRIVATE_AS const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3);
DECLSPEC void AES192_set_decrypt_key (PRIVATE_AS u32 *ks, PRIVATE_AS const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3);
DECLSPEC void AES192_encrypt (PRIVATE_AS const u32 *ks, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4);
DECLSPEC void AES192_decrypt (PRIVATE_AS const u32 *ks, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4);
DECLSPEC void AES256_set_encrypt_key (PRIVATE_AS u32 *ks, PRIVATE_AS const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3);
DECLSPEC void AES256_set_decrypt_key (PRIVATE_AS u32 *ks, PRIVATE_AS const u32 *ukey, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3);
DECLSPEC void AES256_encrypt (PRIVATE_AS const u32 *ks, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, SHM_TYPE u32 *s_te0, SHM_TYPE u32 *s_te1, SHM_TYPE u32 *s_te2, SHM_TYPE u32 *s_te3, SHM_TYPE u32 *s_te4);
DECLSPEC void AES256_decrypt (PRIVATE_AS const u32 *ks, PRIVATE_AS const u32 *in, PRIVATE_AS u32 *out, SHM_TYPE u32 *s_td0, SHM_TYPE u32 *s_td1, SHM_TYPE u32 *s_td2, SHM_TYPE u32 *s_td3, SHM_TYPE u32 *s_td4);
#endif // _INC_CIPHER_AES_H
| 150.804878 | 254 | 0.777131 |
a222d9d2331a0e84332ac2236ca6ab4a178bdd20 | 2,861 | h | C | src/main/include/twist.h | ericawood/IntegratedDeepSpaceCode | 41722e5645d7de5bae9d3a9b5f13d74b960433f5 | [
"BSD-3-Clause"
] | null | null | null | src/main/include/twist.h | ericawood/IntegratedDeepSpaceCode | 41722e5645d7de5bae9d3a9b5f13d74b960433f5 | [
"BSD-3-Clause"
] | null | null | null | src/main/include/twist.h | ericawood/IntegratedDeepSpaceCode | 41722e5645d7de5bae9d3a9b5f13d74b960433f5 | [
"BSD-3-Clause"
] | 1 | 2019-03-20T01:10:41.000Z | 2019-03-20T01:10:41.000Z | #ifndef TWIST_H
#define TWIST_H
#include "ctre/Phoenix.h"
#include "frc/WPILib.h"
#include <ctre/Phoenix.h>
#include <iostream>
#include <cmath>
#include <frc/Joystick.h>
#include <chrono>
#include <PID.h>
#include <AHRS.h>
#include <socket.h>
#include <string>
#include <cmath>
class Twist {
public:
Twist(TalonSRX* talon_left, TalonSRX* talon_right, PID *pid, AHRS *navx, Socket *client, frc::Joystick *joystick)
:talon_left(talon_left), talon_right(talon_right), pid(pid), navx(navx), client(client), joystick(joystick) {
};
int auto_align();
void wipe();
void begin_turn(int direction_begin);
void straight_away();
void end_turn(int direction_turnend);
void final_turn_go(int direction_turnend);
int mode = 0;
float angle_bot_turns_begin_from_jetson;
float angle_bot_turns_end_from_jetson;
float to_travel_distance_mm_from_jetson;
float to_travel_distance_in_from_jetson;
float left_depth_from_jetson;
float right_depth_from_jetson;
private:
TalonSRX *talon_right, *talon_left;
frc::Joystick *joystick;
PID *pid;
AHRS *navx;
Socket *client;
//O is path; 1 is depth wiggle
const float enc_per_eight_feet = ((2681 + 2579) / 2.0 );
const float encoder_counts_per_inch = enc_per_eight_feet / (8 * 12.0);
//center to destination distance in inches (from Jetson)
//angle bot should turn before it travels (from Jetson)
float angle_bot_has_turned_begin; //Angle the bot has turned before it travels (from NavX)
float to_travel_distance_enc; //center to destination distance in encoder counts
float angle_bot_has_turned_end; //Angle the bot has turned after it travels (from NavX)
//angle bot should turn after it travels (from Jetson)
float left_position_enc;
float right_position_enc;
//(from Jetson)
//(from Jetson)
float speed_ratio;
float stop_left_depth;
float stop_right_depth;
float max_left_error;
float max_right_error;
bool buttonstate = 0;
bool togglestate = 0;
bool align_state = 0;
int auto_align_mode = 0;
int direction;
int direction_to_turn;
int direction_end;
float thirty_speed = 150; //30% percent output velocity
float twenty_speed = 126; //20% percent output velocity
float ten_speed = 63; //10% percent output velocity
float velocity_turn;
float begin_yaw;
//Possiblility for turning Speed Control
float max_turn_velocity = 200.0;
float min_turn_velocity = 175.0;
float max_angle = 18.0; //Where it will start slowing
float min_angle = 3.0; //Where we will stop
float change_angle = 5 - min_angle;
float change_velocity = max_turn_velocity - min_turn_velocity;
float velocity_constant = change_velocity / change_angle;
float d_constant = 123;
float old_angle;
float new_angle;
float old_change_in_angle = 0;
float new_change_in_angle = 0;
float change_in_change = 0;
};
#endif | 30.115789 | 115 | 0.742048 |
a223739d1424855aede38894fca7df5f8106aa73 | 1,699 | h | C | PrivateFrameworks/SearchFoundation/_SFPBProductInventory.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/SearchFoundation/_SFPBProductInventory.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/SearchFoundation/_SFPBProductInventory.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 1 | 2018-09-28T13:54:23.000Z | 2018-09-28T13:54:23.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "PBCodable.h"
#import "NSSecureCoding.h"
#import "_SFPBProductInventory.h"
@class NSData, NSString, _SFPBDate;
@interface _SFPBProductInventory : PBCodable <_SFPBProductInventory, NSSecureCoding>
{
int _type;
int _availabilityStatus;
float _distance;
int _distanceUnit;
NSString *_storeId;
_SFPBDate *_timestamp;
NSString *_storeName;
NSString *_storeAddress;
}
@property(copy, nonatomic) NSString *storeAddress; // @synthesize storeAddress=_storeAddress;
@property(copy, nonatomic) NSString *storeName; // @synthesize storeName=_storeName;
@property(retain, nonatomic) _SFPBDate *timestamp; // @synthesize timestamp=_timestamp;
@property(nonatomic) int distanceUnit; // @synthesize distanceUnit=_distanceUnit;
@property(nonatomic) float distance; // @synthesize distance=_distance;
@property(nonatomic) int availabilityStatus; // @synthesize availabilityStatus=_availabilityStatus;
@property(copy, nonatomic) NSString *storeId; // @synthesize storeId=_storeId;
@property(nonatomic) int type; // @synthesize type=_type;
- (void).cxx_destruct;
- (id)initWithDictionary:(id)arg1;
- (id)initWithJSON:(id)arg1;
@property(readonly, nonatomic) NSData *jsonData;
- (id)dictionaryRepresentation;
@property(readonly) unsigned long long hash;
- (BOOL)isEqual:(id)arg1;
- (void)writeTo:(id)arg1;
- (BOOL)readFrom:(id)arg1;
- (id)initWithFacade:(id)arg1;
// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) Class superclass;
@end
| 32.673077 | 99 | 0.756327 |
a2257a5aa4a3005899cea57b0e10655ccf387cc0 | 9,790 | h | C | src/chrono_models/vehicle/feda/FEDA_DoubleWishbone.h | Benatti1991/chrono | d927a7fae8ed2f4e6695cacaef28c605fcd9ffaf | [
"BSD-3-Clause"
] | 1,383 | 2015-02-04T14:17:40.000Z | 2022-03-30T04:58:16.000Z | src/chrono_models/vehicle/feda/FEDA_DoubleWishbone.h | Benatti1991/chrono | d927a7fae8ed2f4e6695cacaef28c605fcd9ffaf | [
"BSD-3-Clause"
] | 245 | 2015-01-11T15:30:51.000Z | 2022-03-30T21:28:54.000Z | src/chrono_models/vehicle/feda/FEDA_DoubleWishbone.h | Benatti1991/chrono | d927a7fae8ed2f4e6695cacaef28c605fcd9ffaf | [
"BSD-3-Clause"
] | 351 | 2015-02-04T14:17:47.000Z | 2022-03-30T04:42:52.000Z | // =============================================================================
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2014 projectchrono.org
// All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file at the top level of the distribution and at
// http://projectchrono.org/license-chrono.txt.
//
// =============================================================================
// Authors: Radu Serban, Justin Madsen, Daniel Melanz, Rainer Gericke
// =============================================================================
//
// Front and Rear FEDA suspension subsystems (double A-arm)
//
// These concrete suspension subsystems are defined with respect to right-handed
// frames with X pointing towards the front, Y to the left, and Z up (as imposed
// by the base class ChDoubleWishbone) and origins at the midpoint between the
// lower control arms' connection points to the chassis.
//
// All point locations are provided for the left half of the suspension.
//
// =============================================================================
#ifndef FEDA_DOUBLEWISHBONE_H
#define FEDA_DOUBLEWISHBONE_H
#include "chrono_vehicle/wheeled_vehicle/suspension/ChDoubleWishbone.h"
#include "chrono_models/ChApiModels.h"
namespace chrono {
namespace vehicle {
namespace feda {
/// @addtogroup vehicle_models_feda
/// @{
/// Full double wishbone front suspension for the FEDA vehicle.
/// The control arms are modeled using rigid bodies.
class CH_MODELS_API FEDA_DoubleWishboneFront : public ChDoubleWishbone {
public:
FEDA_DoubleWishboneFront(const std::string& name, int rideHeightMode = 2, int damperMode = 1);
~FEDA_DoubleWishboneFront();
virtual double getSpindleMass() const override { return m_spindleMass; }
virtual double getUCAMass() const override { return m_UCAMass; }
virtual double getLCAMass() const override { return m_LCAMass; }
virtual double getUprightMass() const override { return m_uprightMass; }
virtual double getSpindleRadius() const override { return m_spindleRadius; }
virtual double getSpindleWidth() const override { return m_spindleWidth; }
virtual double getUCARadius() const override { return m_UCARadius; }
virtual double getLCARadius() const override { return m_LCARadius; }
virtual double getUprightRadius() const override { return m_uprightRadius; }
virtual const ChVector<>& getSpindleInertia() const override { return m_spindleInertia; }
virtual const ChVector<>& getUCAInertiaMoments() const override { return m_UCAInertiaMoments; }
virtual const ChVector<>& getUCAInertiaProducts() const override { return m_UCAInertiaProducts; }
virtual const ChVector<>& getLCAInertiaMoments() const override { return m_LCAInertiaMoments; }
virtual const ChVector<>& getLCAInertiaProducts() const override { return m_LCAInertiaProducts; }
virtual const ChVector<>& getUprightInertiaMoments() const override { return m_uprightInertiaMoments; }
virtual const ChVector<>& getUprightInertiaProducts() const override { return m_uprightInertiaProducts; }
virtual double getAxleInertia() const override { return m_axleInertia; }
virtual double getSpringRestLength() const override { return m_springRestLength; }
virtual std::shared_ptr<ChLinkTSDA::ForceFunctor> getSpringForceFunctor() const override { return m_springForceCB; }
virtual std::shared_ptr<ChLinkTSDA::ForceFunctor> getShockForceFunctor() const override { return m_shockForceCB; }
virtual void Initialize(
std::shared_ptr<ChChassis> chassis, ///< [in] associated chassis subsystem
std::shared_ptr<ChSubchassis> subchassis, ///< [in] associated subchassis subsystem (may be null)
std::shared_ptr<ChSteering> steering, ///< [in] associated steering subsystem (may be null)
const ChVector<>& location, ///< [in] location relative to the chassis frame
double left_ang_vel = 0, ///< [in] initial angular velocity of left wheel
double right_ang_vel = 0 ///< [in] initial angular velocity of right wheel
) override;
private:
virtual const ChVector<> getLocation(PointId which) override;
std::shared_ptr<ChLinkTSDA::ForceFunctor> m_springForceCB;
std::shared_ptr<ChLinkTSDA::ForceFunctor> m_shockForceCB;
ChLinkTSDA::ODE* m_shockODE;
static const double m_spindleMass;
static const double m_UCAMass;
static const double m_LCAMass;
static const double m_uprightMass;
static const double m_spindleRadius;
static const double m_spindleWidth;
static const double m_UCARadius;
static const double m_LCARadius;
static const double m_uprightRadius;
static const ChVector<> m_spindleInertia;
static const ChVector<> m_UCAInertiaMoments;
static const ChVector<> m_UCAInertiaProducts;
static const ChVector<> m_LCAInertiaMoments;
static const ChVector<> m_LCAInertiaProducts;
static const ChVector<> m_uprightInertiaMoments;
static const ChVector<> m_uprightInertiaProducts;
static const double m_axleInertia;
static const double m_springCoefficient;
static const double m_springRestLength;
static const double m_springF0;
static const double m_bumpstop_clearance;
static const double m_reboundstop_clearance;
static const double m_air_pressure[3];
int m_ride_height_mode;
int m_damper_mode;
};
// -----------------------------------------------------------------------------
/// Full double wishbone rear suspension for the FEDA vehicle.
/// The control arms are modeled using rigid bodies.
class CH_MODELS_API FEDA_DoubleWishboneRear : public ChDoubleWishbone {
public:
FEDA_DoubleWishboneRear(const std::string& name, int rideHeightMode = 2, int damperMode = 2);
~FEDA_DoubleWishboneRear();
virtual double getSpindleMass() const override { return m_spindleMass; }
virtual double getUCAMass() const override { return m_UCAMass; }
virtual double getLCAMass() const override { return m_LCAMass; }
virtual double getUprightMass() const override { return m_uprightMass; }
virtual double getSpindleRadius() const override { return m_spindleRadius; }
virtual double getSpindleWidth() const override { return m_spindleWidth; }
virtual double getUCARadius() const override { return m_UCARadius; }
virtual double getLCARadius() const override { return m_LCARadius; }
virtual double getUprightRadius() const override { return m_uprightRadius; }
virtual const ChVector<>& getSpindleInertia() const override { return m_spindleInertia; }
virtual const ChVector<>& getUCAInertiaMoments() const override { return m_UCAInertiaMoments; }
virtual const ChVector<>& getUCAInertiaProducts() const override { return m_UCAInertiaProducts; }
virtual const ChVector<>& getLCAInertiaMoments() const override { return m_LCAInertiaMoments; }
virtual const ChVector<>& getLCAInertiaProducts() const override { return m_LCAInertiaProducts; }
virtual const ChVector<>& getUprightInertiaMoments() const override { return m_uprightInertiaMoments; }
virtual const ChVector<>& getUprightInertiaProducts() const override { return m_uprightInertiaProducts; }
virtual double getAxleInertia() const override { return m_axleInertia; }
virtual double getSpringRestLength() const override { return m_springRestLength; }
virtual std::shared_ptr<ChLinkTSDA::ForceFunctor> getSpringForceFunctor() const override { return m_springForceCB; }
virtual std::shared_ptr<ChLinkTSDA::ForceFunctor> getShockForceFunctor() const override { return m_shockForceCB; }
virtual void Initialize(
std::shared_ptr<ChChassis> chassis, ///< [in] associated chassis subsystem
std::shared_ptr<ChSubchassis> subchassis, ///< [in] associated subchassis subsystem (may be null)
std::shared_ptr<ChSteering> steering, ///< [in] associated steering subsystem (may be null)
const ChVector<>& location, ///< [in] location relative to the chassis frame
double left_ang_vel = 0, ///< [in] initial angular velocity of left wheel
double right_ang_vel = 0 ///< [in] initial angular velocity of right wheel
) override;
private:
virtual const ChVector<> getLocation(PointId which) override;
std::shared_ptr<ChLinkTSDA::ForceFunctor> m_springForceCB;
std::shared_ptr<ChLinkTSDA::ForceFunctor> m_shockForceCB;
ChLinkTSDA::ODE* m_shockODE;
static const double m_spindleMass;
static const double m_UCAMass;
static const double m_LCAMass;
static const double m_uprightMass;
static const double m_spindleRadius;
static const double m_spindleWidth;
static const double m_UCARadius;
static const double m_LCARadius;
static const double m_uprightRadius;
static const ChVector<> m_spindleInertia;
static const ChVector<> m_UCAInertiaMoments;
static const ChVector<> m_UCAInertiaProducts;
static const ChVector<> m_LCAInertiaMoments;
static const ChVector<> m_LCAInertiaProducts;
static const ChVector<> m_uprightInertiaMoments;
static const ChVector<> m_uprightInertiaProducts;
static const double m_axleInertia;
static const double m_springCoefficient;
static const double m_springRestLength;
static const double m_springF0;
static const double m_bumpstop_clearance;
static const double m_reboundstop_clearance;
static const double m_air_pressure[3];
int m_ride_height_mode;
int m_damper_mode;
};
/// @} vehicle_models_feda
} // namespace feda
} // end namespace vehicle
} // end namespace chrono
#endif
| 45.534884 | 120 | 0.714811 |
a226637cd04393a3c81afcf9107ac962f37a73b8 | 2,354 | h | C | toolkit/Source/src/gs2d/src/Math/Color.h | LuizTedesco/ethanon | c140bd360092dcdf11b242a11dee67e79fbbd025 | [
"Unlicense"
] | 64 | 2015-01-02T12:27:29.000Z | 2022-03-07T03:23:33.000Z | toolkit/Source/src/gs2d/src/Math/Color.h | theomission/ethanon | c140bd360092dcdf11b242a11dee67e79fbbd025 | [
"Unlicense"
] | 5 | 2015-03-31T00:09:29.000Z | 2022-03-07T18:16:42.000Z | toolkit/Source/src/gs2d/src/Math/Color.h | theomission/ethanon | c140bd360092dcdf11b242a11dee67e79fbbd025 | [
"Unlicense"
] | 40 | 2015-01-14T09:47:56.000Z | 2022-02-07T22:07:24.000Z | /*--------------------------------------------------------------------------------------
Ethanon Engine (C) Copyright 2008-2013 Andre Santee
http://ethanonengine.com/
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the
Software without restriction, including without limitation the rights to use, copy,
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------------*/
#ifndef GS2D_COLOR_H_
#define GS2D_COLOR_H_
#include "../Types.h"
namespace gs2d {
#pragma warning(push)
#pragma warning(disable:4201)
struct Color
{
Color();
Color(const GS_DWORD color);
Color(const GS_BYTE na, const GS_BYTE nr, const GS_BYTE ng, const GS_BYTE nb);
void SetColor(const GS_BYTE na, const GS_BYTE nr, const GS_BYTE ng, const GS_BYTE nb);
void SetColor(const GS_DWORD color);
Color &operator = (GS_DWORD color);
operator GS_DWORD () const;
void SetAlpha(const GS_BYTE na);
void SetRed(const GS_BYTE nr);
void SetGreen(const GS_BYTE ng);
void SetBlue(const GS_BYTE nb);
union
{
struct
{
GS_BYTE b, g, r, a;
};
GS_DWORD color;
};
};
#pragma warning( pop )
unsigned long ARGB(const GS_BYTE a, const GS_BYTE r, const GS_BYTE g, const GS_BYTE b);
namespace constant {
const Color ZERO(0x0);
const Color BLACK(0xFF000000);
const Color WHITE(0xFFFFFFFF);
const Color RED(0xFFFF0000);
const Color GREEN(0xFF00FF00);
const Color BLUE(0xFF0000FF);
const Color YELLOW(0xFFFFFF00);
} // constant
} // gs2d
#endif
| 32.246575 | 88 | 0.703908 |
a22687b3f47bdf2ba31afbdda3da2bf094f5b39b | 470 | h | C | Mars/Scene1.h | Dan0net/opengl-mars | 4d6368aaf02f355c2a27bbbc7241517810c23e0e | [
"MIT"
] | null | null | null | Mars/Scene1.h | Dan0net/opengl-mars | 4d6368aaf02f355c2a27bbbc7241517810c23e0e | [
"MIT"
] | null | null | null | Mars/Scene1.h | Dan0net/opengl-mars | 4d6368aaf02f355c2a27bbbc7241517810c23e0e | [
"MIT"
] | null | null | null | //
// Scene1.h
// Mars
//
// Created by Daniel M.C. on 16/12/2012.
// Copyright (c) 2012 Daniel M.C. All rights reserved.
//
#ifndef __Mars__Scene1__
#define __Mars__Scene1__
#include "Scene.h"
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/glm.hpp>
class Scene1: public Scene {
protected:
float LENGTH = 5.0f;
public:
void create();
void render(float);
void destroy();
};
#endif /* defined(__Mars__Scene1__) */
| 16.785714 | 55 | 0.682979 |
a22baa17b45479ffbf61d155ffa3496601573cf9 | 10,154 | c | C | blades/gnunet/src/namestore/test_namestore_api_lookup_shadow_filter.c | krattai/AEBL | a7b12c97479e1236d5370166b15ca9f29d7d4265 | [
"BSD-2-Clause"
] | 4 | 2016-04-26T03:43:54.000Z | 2016-11-17T08:09:04.000Z | blades/gnunet/src/namestore/test_namestore_api_lookup_shadow_filter.c | krattai/AEBL | a7b12c97479e1236d5370166b15ca9f29d7d4265 | [
"BSD-2-Clause"
] | 17 | 2015-01-05T21:06:22.000Z | 2015-12-07T20:45:44.000Z | blades/gnunet/src/namestore/test_namestore_api_lookup_shadow_filter.c | krattai/AEBL | a7b12c97479e1236d5370166b15ca9f29d7d4265 | [
"BSD-2-Clause"
] | 3 | 2016-04-26T03:43:55.000Z | 2020-11-06T11:02:08.000Z | /*
This file is part of GNUnet.
Copyright (C) 2012 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet 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 GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
/**
* @file namestore/test_namestore_api_lookup_shadow_filter.c
* @brief testcase for namestore_api.c: store a record with short expiration
* and a shadow record, perform lookup:
* - when active record is valid, expect only active record
* - when active record is expired, expect shadow record only
*/
#include "platform.h"
#include "gnunet_namecache_service.h"
#include "gnunet_namestore_service.h"
#include "gnunet_testing_lib.h"
#define TEST_NAME "dummy.dummy.gnunet"
#define TEST_RECORD_TYPE 1234
#define TEST_RECORD_DATALEN 123
#define TEST_RECORD_DATA 'a'
#define TEST_SHADOW_RECORD_DATA 'b'
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 100)
#define EXPIRATION GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
static struct GNUNET_NAMESTORE_Handle *nsh;
static struct GNUNET_NAMECACHE_Handle *nch;
static struct GNUNET_SCHEDULER_Task * endbadly_task;
static struct GNUNET_SCHEDULER_Task * delayed_lookup_task;
static struct GNUNET_CRYPTO_EcdsaPrivateKey *privkey;
static struct GNUNET_CRYPTO_EcdsaPublicKey pubkey;
static int res;
static struct GNUNET_NAMESTORE_QueueEntry *nsqe;
static struct GNUNET_NAMECACHE_QueueEntry *ncqe;
static struct GNUNET_NAMECACHE_QueueEntry *ncqe_shadow;
static struct GNUNET_GNSRECORD_Data records[2];
static struct GNUNET_TIME_Absolute record_expiration;
static struct GNUNET_HashCode derived_hash;
static struct GNUNET_CRYPTO_EcdsaPublicKey pubkey;
static char *directory;
static void
cleanup ()
{
if (NULL != nsh)
{
GNUNET_NAMESTORE_disconnect (nsh);
nsh = NULL;
}
if (NULL != nch)
{
GNUNET_NAMECACHE_disconnect (nch);
nch = NULL;
}
if (NULL != privkey)
{
GNUNET_free (privkey);
privkey = NULL;
}
GNUNET_SCHEDULER_shutdown ();
}
/**
* Re-establish the connection to the service.
*
* @param cls handle to use to re-connect.
*/
static void
endbadly (void *cls)
{
if (NULL != delayed_lookup_task)
{
GNUNET_SCHEDULER_cancel (delayed_lookup_task);
delayed_lookup_task = NULL;
}
if (NULL != nsqe)
{
GNUNET_NAMESTORE_cancel (nsqe);
nsqe = NULL;
}
if (NULL != ncqe)
{
GNUNET_NAMECACHE_cancel (ncqe);
ncqe = NULL;
}
cleanup ();
res = 1;
}
static void
end (void *cls)
{
cleanup ();
res = 0;
}
static void
rd_decrypt_cb (void *cls,
unsigned int rd_count,
const struct GNUNET_GNSRECORD_Data *rd)
{
struct GNUNET_GNSRECORD_Data *expected_rd = cls;
char rd_cmp_data[TEST_RECORD_DATALEN];
if (1 != rd_count)
{
GNUNET_SCHEDULER_add_now (&endbadly, NULL);
GNUNET_break (0);
return;
}
if (NULL == rd)
{
GNUNET_SCHEDULER_add_now (&endbadly, NULL);
GNUNET_break (0);
return;
}
if (expected_rd == &records[0])
{
/* Expecting active record */
memset (rd_cmp_data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
if (TEST_RECORD_TYPE != rd[0].record_type)
{
GNUNET_SCHEDULER_add_now (&endbadly, NULL);
GNUNET_break (0);
return;
}
if (TEST_RECORD_DATALEN != rd[0].data_size)
{
GNUNET_SCHEDULER_add_now (&endbadly, NULL);
GNUNET_break (0);
return;
}
if (0 != memcmp (&rd_cmp_data, rd[0].data, TEST_RECORD_DATALEN))
{
GNUNET_SCHEDULER_add_now (&endbadly, NULL);
GNUNET_break (0);
return;
}
if (0 != (GNUNET_GNSRECORD_RF_SHADOW_RECORD & rd[0].flags))
{
GNUNET_SCHEDULER_add_now (&endbadly, NULL);
GNUNET_break (0);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Block was decrypted successfully with active record\n");
}
if (expected_rd == &records[1])
{
/* Expecting shadow record but without shadow flag*/
memset (rd_cmp_data, TEST_SHADOW_RECORD_DATA, TEST_RECORD_DATALEN);
if (TEST_RECORD_TYPE != rd[0].record_type)
{
GNUNET_SCHEDULER_add_now (&endbadly, NULL);
GNUNET_break (0);
return;
}
if (TEST_RECORD_DATALEN != rd[0].data_size)
{
GNUNET_SCHEDULER_add_now (&endbadly, NULL);
GNUNET_break (0);
return;
}
if (0 != memcmp (&rd_cmp_data, rd[0].data, TEST_RECORD_DATALEN))
{
GNUNET_SCHEDULER_add_now (&endbadly, NULL);
GNUNET_break (0);
return;
}
if (0 != (GNUNET_GNSRECORD_RF_SHADOW_RECORD & rd[0].flags))
{
GNUNET_SCHEDULER_add_now (&endbadly, NULL);
GNUNET_break (0);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Block was decrypted successfully with former shadow record \n");
GNUNET_SCHEDULER_add_now (&end, NULL );
}
}
static void
name_lookup_active_proc (void *cls,
const struct GNUNET_GNSRECORD_Block *block)
{
struct GNUNET_GNSRECORD_Data *expected_rd = cls;
GNUNET_assert (NULL != expected_rd);
ncqe = NULL;
ncqe_shadow = NULL;
if (endbadly_task != NULL)
{
GNUNET_SCHEDULER_cancel (endbadly_task);
endbadly_task = NULL;
}
if (NULL == block)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Namestore returned no block\n"));
if (endbadly_task != NULL)
GNUNET_SCHEDULER_cancel (endbadly_task);
endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Namestore returned block, decrypting \n");
GNUNET_assert (GNUNET_OK == GNUNET_GNSRECORD_block_decrypt(block,
&pubkey, TEST_NAME, &rd_decrypt_cb, expected_rd));
}
static void
name_lookup_shadow (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Performing lookup for shadow record \n");
delayed_lookup_task = NULL;
ncqe_shadow = GNUNET_NAMECACHE_lookup_block (nch, &derived_hash,
&name_lookup_active_proc, &records[1]);
}
static void
put_cont (void *cls, int32_t success, const char *emsg)
{
nsqe = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Name store added record for `%s': %s\n",
TEST_NAME,
(success == GNUNET_OK) ? "SUCCESS" : "FAIL");
/* Create derived hash */
GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey);
GNUNET_GNSRECORD_query_from_public_key (&pubkey, TEST_NAME, &derived_hash);
if (0 == GNUNET_TIME_absolute_get_remaining(record_expiration).rel_value_us )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Test to too long to store records, cannot run test!\n");
GNUNET_SCHEDULER_add_now (&end, NULL );
return;
}
/* Lookup active record now */
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Performing lookup for active record \n");
ncqe = GNUNET_NAMECACHE_lookup_block (nch, &derived_hash,
&name_lookup_active_proc, &records[0]);
delayed_lookup_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (EXPIRATION, 2), &name_lookup_shadow, NULL);
}
static void
run (void *cls,
const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_TESTING_Peer *peer)
{
char *hostkey_file;
directory = NULL;
GNUNET_assert (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS", "GNUNET_TEST_HOME", &directory));
GNUNET_DISK_directory_remove (directory);
endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
&endbadly, NULL);
GNUNET_asprintf (&hostkey_file,
"zonefiles%s%s",
DIR_SEPARATOR_STR,
"N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file);
privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file (hostkey_file);
GNUNET_free (hostkey_file);
GNUNET_assert (privkey != NULL);
GNUNET_CRYPTO_ecdsa_key_get_public (privkey, &pubkey);
record_expiration = GNUNET_TIME_absolute_add(GNUNET_TIME_absolute_get(), EXPIRATION);
records[0].expiration_time = record_expiration.abs_value_us;
records[0].record_type = TEST_RECORD_TYPE;
records[0].data_size = TEST_RECORD_DATALEN;
records[0].data = GNUNET_malloc (TEST_RECORD_DATALEN);
records[0].flags = GNUNET_GNSRECORD_RF_NONE;
memset ((char *) records[0].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
records[1].expiration_time = GNUNET_TIME_absolute_get().abs_value_us + 1000000000;
records[1].record_type = TEST_RECORD_TYPE;
records[1].data_size = TEST_RECORD_DATALEN;
records[1].data = GNUNET_malloc (TEST_RECORD_DATALEN);
records[1].flags = GNUNET_GNSRECORD_RF_SHADOW_RECORD;
memset ((char *) records[1].data, TEST_SHADOW_RECORD_DATA, TEST_RECORD_DATALEN);
nsh = GNUNET_NAMESTORE_connect (cfg);
nch = GNUNET_NAMECACHE_connect (cfg);
GNUNET_break (NULL != nsh);
GNUNET_break (NULL != nch);
nsqe = GNUNET_NAMESTORE_records_store (nsh, privkey, TEST_NAME,
2, records, &put_cont, NULL);
if (NULL == nsqe)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Namestore cannot store no block\n"));
}
GNUNET_free ((void *) records[0].data);
GNUNET_free ((void *) records[1].data);
}
int
main (int argc, char *argv[])
{
res = 1;
if (0 !=
GNUNET_TESTING_peer_run ("test-namestore-api",
"test_namestore_api.conf",
&run,
NULL))
{
res = 1;
}
if (NULL != directory)
{
GNUNET_DISK_directory_remove (directory);
GNUNET_free (directory);
}
return res;
}
/* end of test_namestore_api_lookup_shadow_filter.c */
| 27.667575 | 128 | 0.6948 |
a23744b75f8a7c9820b5f0655e48c478f4c56cda | 804 | c | C | d/ravenloft/town/bar06.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-07-19T05:24:44.000Z | 2021-11-18T04:08:19.000Z | d/ravenloft/town/bar06.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 4 | 2021-03-15T18:56:39.000Z | 2021-08-17T17:08:22.000Z | d/ravenloft/town/bar06.c | Dbevan/SunderingShadows | 6c15ec56cef43c36361899bae6dc08d0ee907304 | [
"MIT"
] | 13 | 2019-09-12T06:22:38.000Z | 2022-01-31T01:15:12.000Z | // Coded by Bane
// bar06.c
#include <std.h>
inherit ROOM;
void create(){
::create();
set_short("Village of Barovia");
set_long(
"%^RED%^"
"You stand on a small dirt path. To the west you "+
"see a few buildings standing at the edge of the "+
"village. To the east the path continues into a "+
"dark forest. On either side of the path lies fields "+
"of dead grass and crops."
"%^RESET%^"
);
set_property("light",2);
set_property("indoors",0);
set_property("no teleport",1);
set_listen("default","The sounds of wolves howling in the distance sends a shiver up your spine.");
set_smell("default","You can smell smoke drifting towards you from the village.");
set_exits( ([
"west":"/d/ravenloft/town/bar08",
"east":"/d/ravenloft/town/bar05",
]) );
}
| 29.777778 | 103 | 0.651741 |
a238e1dc061f2201c6a773b2b0542cec472b1743 | 1,008 | c | C | C/chapter3/escape.c | yimng/personal-stuff | 48b426ea6b8d22c5e63b3528a146bf3562c5b4a9 | [
"MIT"
] | 1 | 2017-06-26T01:23:38.000Z | 2017-06-26T01:23:38.000Z | C/chapter3/escape.c | yimng/LEARN | 48b426ea6b8d22c5e63b3528a146bf3562c5b4a9 | [
"MIT"
] | null | null | null | C/chapter3/escape.c | yimng/LEARN | 48b426ea6b8d22c5e63b3528a146bf3562c5b4a9 | [
"MIT"
] | null | null | null | void escape(char s[], char t[])
{
int i, j;
for (i = j = 0; t[i] != '\0'; i++)
{
switch(t[i])
{
case '\n':
s[j++] = '\\';
s[j++] = 'n';
break;
case '\t':
s[j++] = '\\';
s[j++] = 't';
break;
default:
s[j++] = t[i];
break;
}
}
s[j] = '\0';
}
void unescape(char s[], char t[])
{
int i, j;
for (i = j = 0; t[i] != '\0'; i++)
if (t[i] != '\\')
s[j++] = t[i];
else
switch(t[++i]) {
case 'n':
s[j++] = '\n';
break;
case 't':
s[j++] = '\t';
break;
default:
s[j++] = '\\';
s[j++] = t[i];
break;
}
s[j] = '\0';
}
| 22.4 | 39 | 0.194444 |
a23afcfc0fe3bc3e6dd9724198ee2ea33db4edde | 20,865 | c | C | lib/barrelfish/aos_rpc.c | renlord/ethz-aos2015 | 0c3face3ba42784e8feacebfec0fbefc083800b1 | [
"MIT"
] | 1 | 2021-02-25T13:59:00.000Z | 2021-02-25T13:59:00.000Z | lib/barrelfish/aos_rpc.c | renlord/ethz-aos2015 | 0c3face3ba42784e8feacebfec0fbefc083800b1 | [
"MIT"
] | null | null | null | lib/barrelfish/aos_rpc.c | renlord/ethz-aos2015 | 0c3face3ba42784e8feacebfec0fbefc083800b1 | [
"MIT"
] | null | null | null | /**
* \file
* \brief Implementation of AOS rpc-like messaging
*/
/*
* Copyright (c) 2013, 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, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
*/
#include <barrelfish/aos_rpc.h>
#include <barrelfish/paging.h>
#include <barrelfish/barrelfish.h>
#include <barrelfish/cspace.h>
#define FIRSTEP_BUFLEN 20u
#define MIN(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })
static void clean_aos_rpc_msgbuf(struct aos_rpc *rpc);
static void spawnd_recv_handler(void *rpc_void)
{
struct aos_rpc *rpc = (struct aos_rpc *)rpc_void;
struct capref remote_cap;
struct lmp_recv_msg msg = LMP_RECV_MSG_INIT;
uint32_t rpc_code;
errval_t err = aos_retrieve_msg(&rpc->spawnd_lc, &remote_cap,
&rpc_code, &msg);
if (err_is_fail(err)) {
debug_printf("Could not receive msg from init: %s\n",
err_getstring(err));
err_print_calltrace(err);
local_rpc.return_cap = NULL_CAP;
return;
}
lmp_chan_register_recv(&rpc->spawnd_lc, get_default_waitset(),
MKCLOSURE(spawnd_recv_handler, rpc));
switch(rpc_code){
case PROCESS_GET_NAME:
{
// if this event is triggered, check the buffer for the full
// text.
rpc->wait_event = false;
break;
}
case PROCESS_GET_NO_OF_PIDS:
{
rpc->msg_buf[0] = (char) msg.words[0];
break;
}
case PROCESS_GET_PID:
{
rpc->msg_buf[0] = (char) msg.words[0];
break;
}
case SEND_TEXT:
{
for(uint8_t i = 0; i < 8; i++){
rpc->msg_buf[rpc->char_count] = msg.words[i];
rpc->char_count++;
if (msg.words[i] == '\0') {
rpc->char_count = 0;
break;
}
}
break;
}
default:
debug_printf("Could not handle rpc code %d from spawnd\n",
rpc_code);
}
}
static void init_recv_handler(void *rpc_void)
{
struct aos_rpc *rpc = (struct aos_rpc *)rpc_void;
struct capref remote_cap = NULL_CAP;
struct lmp_recv_msg msg = LMP_RECV_MSG_INIT;
errval_t err = lmp_chan_recv(&rpc->init_lc, &msg, &remote_cap);
if (err_is_fail(err)) {
debug_printf("Could not receive msg from init: %s\n",
err_getstring(err));
err_print_calltrace(err);
rpc->return_cap = NULL_CAP;
return;
}
if (msg.buf.msglen == 0){
debug_printf("Bad msg for init.\n");
rpc->return_cap = NULL_CAP;
return;
}
uint32_t code = msg.buf.words[0];
switch(code) {
case REGISTER_CHANNEL:
{
if (capref_is_null(remote_cap)) {
debug_printf("Received endpoint cap was null.\n");
return;
}
rpc->init_lc.remote_cap = remote_cap;
break;
}
case SEND_TEXT:
{
for(uint8_t i = 1; i < 9; i++){
rpc->msg_buf[rpc->char_count] = msg.buf.words[i];
rpc->char_count++;
if (msg.buf.words[i] == '\0') {
rpc->char_count = 0;
break;
}
}
break;
}
case REQUEST_RAM_CAP:
{
if (capref_is_null(remote_cap)) {
debug_printf("Remote_cap is NULL\n");
return;
}
rpc->return_cap = remote_cap;
rpc->ret_bits = msg.buf.words[1];
break;
}
case REQUEST_DEV_CAP:
{
if (capref_is_null(remote_cap)) {
debug_printf("remote_cap is NULL\n");
return;
}
rpc->return_cap = remote_cap;
rpc->ret_bits = msg.buf.words[1];
break;
}
case SERIAL_PUT_CHAR:
{
// Init will never reply to this event!
break;
}
case SERIAL_GET_CHAR:
{
rpc->msg_buf[0] = msg.buf.words[1];
break;
}
case PROCESS_SPAWN:
{
// expecting a pid to be returned and success/failure
rpc->msg_buf[0] = (char)msg.buf.words[1];
if (msg.buf.words[1] == true) {
rpc->msg_buf[1] = (char)msg.buf.words[2];
}
break;
}
case PROCESS_GET_NAME:
{
// if this event is triggered, check the buffer for the full
// text.
rpc->wait_event = false;
break;
}
case PROCESS_GET_NO_OF_PIDS:
{
rpc->msg_buf[0] = (char) msg.buf.words[1];
break;
}
case PROCESS_GET_PID:
{
rpc->msg_buf[0] = (char) msg.buf.words[1];
break;
}
default:
{
debug_printf("Wrong rpc code!\n");
}
}
// Re-allocate
if (!capref_is_null(remote_cap)){
err = lmp_chan_alloc_recv_slot(&rpc->init_lc);
if (err_is_fail(err)){
debug_printf("Could not allocate receive slot: %s.\n",
err_getstring(err));
err_print_calltrace(err);
return;
}
}
// Register our receive handler
err = lmp_chan_register_recv(&rpc->init_lc, get_default_waitset(),
MKCLOSURE(init_recv_handler, rpc));
if (err_is_fail(err)){
debug_printf("Could not register receive handler!\n");
err_print_calltrace(err);
return;
}
}
errval_t aos_rpc_send_string(struct aos_rpc *rpc, const char *string)
{
struct lmp_chan init_lc = rpc->init_lc;
size_t slen = strlen(string) + 1; // adjust for null-character
size_t rlen = 0;
char buf[8];
errval_t err;
while (rlen < slen) {
size_t chunk_size = MIN(slen-rlen, 8);
memcpy(buf, string, chunk_size);
err = lmp_chan_send(&init_lc, LMP_SEND_FLAGS_DEFAULT, NULL_CAP,
9, SEND_TEXT, buf[0], buf[1], buf[2],
buf[3], buf[4], buf[5], buf[6], buf[7]);
if (err_is_fail(err)) {
return err;
}
string = &(string[8]);
rlen += 8;
}
return SYS_ERR_OK;
}
errval_t aos_rpc_get_ram_cap(struct aos_rpc *rpc, size_t req_bits,
struct capref *dest, size_t *ret_bits)
{
// Allocate receive slot
errval_t err = lmp_chan_alloc_recv_slot(&rpc->init_lc);
if (err_is_fail(err)){
debug_printf("Could not allocate receive slot: %s.\n",
err_getstring(err));
err_print_calltrace(err);
return err_push(err, LIB_ERR_LMP_ALLOC_RECV_SLOT);
}
// Request frame cap from init
err = lmp_chan_send2(&rpc->init_lc, LMP_SEND_FLAGS_DEFAULT,
NULL_CAP, REQUEST_RAM_CAP,
req_bits); // TODO transfer error code
if (err_is_fail(err)) {
debug_printf("Could not send msg to init: %s.\n",
err_getstring(err));
err_print_calltrace(err);
return err_push(err, LIB_ERR_LMP_CHAN_SEND);
}
// Listen for response from init. When recv_handler returns,
// cap should be in rpc->return_cap
event_dispatch(get_default_waitset());
*dest = rpc->return_cap;
*ret_bits = rpc->ret_bits;
return SYS_ERR_OK;
}
errval_t aos_rpc_get_dev_cap(struct aos_rpc *rpc, lpaddr_t paddr,
size_t length, struct capref *retcap,
size_t *retlen)
{
// TODO (milestone 4): implement functionality to request device memory
// capability.
// Allocate recieve slot
errval_t err = lmp_chan_alloc_recv_slot(&rpc->init_lc);
if (err_is_fail(err)){
debug_printf("Could not allocate receive slot: %s.\n",
err_getstring(err));
err_print_calltrace(err);
return err_push(err, LIB_ERR_LMP_ALLOC_RECV_SLOT);
}
// Send request to init
err = lmp_chan_send3(&rpc->init_lc, LMP_SEND_FLAGS_DEFAULT,
NULL_CAP, REQUEST_DEV_CAP, paddr,
length);
if (err_is_fail(err)) {
debug_printf("Could not send dev cap request to init: %s.\n",
err_getstring(err));
err_print_calltrace(err);
return err_push(err, LIB_ERR_LMP_CHAN_SEND);
}
// Listen for response from init. When recv_handler returns,
// cap should be in rpc->return_cap
event_dispatch(get_default_waitset());
/* MEMORY STUFF HAPPENS HERE */
// allocate space in Virtual Memory for the Device Memory
// void *va = //malloc(length);
// void *va = (void *)(1UL<<30);
// we then compute the slot offset from the base page table using the virtual address
// provided.
// assert that the requested device physical address is greater than 0x40000000
// assert(paddr > 0x40000000);
// uint64_t start = (uint64_t) (paddr - 0x40000000);
// err = paging_map_user_device(get_current_paging_state(), (lvaddr_t) va,
// rpc->return_cap, start, length, VREGION_FLAGS_READ_WRITE);
// if (err_is_fail(err)) {
// debug_printf("failed to map memory device to local virtual memory. %s\n",
// err_getstring(err));
// err_print_calltrace(err);
// }
*retcap = rpc->return_cap;
*retlen = rpc->ret_bits;
return SYS_ERR_OK;
}
errval_t aos_rpc_serial_getchar(struct aos_rpc *chan, char *retc)
{
// TODO (milestone 4): implement functionality to request a character from
// the serial driver.
struct lmp_chan init_lc = chan->init_lc;
errval_t err;
err = lmp_chan_send1(&init_lc, LMP_SEND_FLAGS_DEFAULT, NULL_CAP,
SERIAL_GET_CHAR);
if (err_is_fail(err)) {
debug_printf("failed to get serial input from init. %s\n",
err_getstring(err));
err_print_calltrace(err);
return err;
}
// listen for response from init. When recv_handler returns,
// character should be in chan->msg_buf[2]
event_dispatch(get_default_waitset());
*retc = chan->msg_buf[0];
return SYS_ERR_OK;
}
errval_t aos_rpc_serial_putchar(struct aos_rpc *chan, char c)
{
// TODO (milestone 4): implement functionality to send a character to the
// serial port.
struct lmp_chan init_lc = chan->init_lc;
errval_t err;
err = lmp_chan_send2(&init_lc, LMP_SEND_FLAGS_DEFAULT, NULL_CAP,
SERIAL_PUT_CHAR, c);
if (err_is_fail(err)) {
return err;
}
return SYS_ERR_OK;
}
errval_t aos_rpc_process_spawn(struct aos_rpc *chan, char *name,
coreid_t coreid, domainid_t *newpid)
{
// TODO (milestone 5): implement spawn new process rpc
struct lmp_chan spawnd_lc = chan->spawnd_lc;
errval_t err;
err = aos_chan_send_string(&chan->spawnd_lc, name);
if (err_is_fail(err)) {
DEBUG_ERR(err, "fail to send process name to init.\n");
return err;
}
err = lmp_chan_send2(&spawnd_lc, LMP_SEND_FLAGS_DEFAULT, NULL_CAP,
PROCESS_SPAWN, coreid);
if (err_is_fail(err)) {
DEBUG_ERR(err, "fail to send PROCESS_SPAWN event to init.\n");
return err;
}
event_dispatch(get_default_waitset());
if (chan->msg_buf[0] == true) {
*newpid = chan->msg_buf[1];
} else {
debug_printf("spawn failed.\n");
}
clean_aos_rpc_msgbuf(chan);
return SYS_ERR_OK;
}
errval_t aos_rpc_process_get_name(struct aos_rpc *chan, domainid_t pid,
char **name)
{
// TODO (milestone 5): implement name lookup for process given a process
// id
errval_t err;
err = lmp_chan_send2(&chan->spawnd_lc, LMP_SEND_FLAGS_DEFAULT, NULL_CAP,
PROCESS_GET_NAME, pid);
if (err_is_fail(err)) {
DEBUG_ERR(err, "fail to send PROCESS_GET_NAME event to init.\n");
return err;
}
chan->wait_event = true;
while (chan->wait_event) {
event_dispatch(get_default_waitset());
}
memcpy(*name, chan->msg_buf, strlen((char *)chan->msg_buf));
clean_aos_rpc_msgbuf(chan);
return SYS_ERR_OK;
}
errval_t aos_rpc_process_get_all_pids(struct aos_rpc *chan,
domainid_t **pids, size_t *pid_count)
{
errval_t err;
err = lmp_chan_send1(&chan->spawnd_lc, LMP_SEND_FLAGS_DEFAULT, NULL_CAP,
PROCESS_GET_NO_OF_PIDS);
if (err_is_fail(err)) {
DEBUG_ERR(err, "fail to send PROCESS_GET_ALL_PIDS event to init.\n");
return err;
}
// 1. get pid_count
event_dispatch(get_default_waitset());
*pid_count = chan->msg_buf[0];
// clean_aos_rpc_msgbuf(chan);
err = paging_alloc(get_current_paging_state(),
(void**) pids,
*pid_count * sizeof(domainid_t));
if (err_is_fail(err)){
// FIXME push err to stack and return
err_print_calltrace(err);
abort();
}
domainid_t *pids_deref = *pids;
// 2. TO BE OPTIMIZED: Right now ask for pids one at a time instead of
// getting as many as possible in each msg
for (size_t i = 0; i < *pid_count; i++) {
lmp_chan_send2(&chan->spawnd_lc, LMP_SEND_FLAGS_DEFAULT, NULL_CAP,
PROCESS_GET_PID, i);
event_dispatch(get_default_waitset());
pids_deref[i] = chan->msg_buf[0];
}
return SYS_ERR_OK;
}
errval_t aos_rpc_open(struct aos_rpc *chan, char *path, int *fd)
{
// TODO (milestone 7): implement file open
return SYS_ERR_OK;
}
errval_t aos_rpc_readdir(struct aos_rpc *chan, char* path,
struct aos_dirent **dir, size_t *elem_count)
{
// TODO (milestone 7): implement readdir
return SYS_ERR_OK;
}
errval_t aos_rpc_read(struct aos_rpc *chan, int fd, size_t position, size_t size,
void** buf, size_t *buflen)
{
// TODO (milestone 7): implement file read
return SYS_ERR_OK;
}
errval_t aos_rpc_close(struct aos_rpc *chan, int fd)
{
// TODO (milestone 7): implement file close
return SYS_ERR_OK;
}
errval_t aos_rpc_write(struct aos_rpc *chan, int fd, size_t position, size_t *size,
void *buf, size_t buflen)
{
// TODO (milestone 7): implement file write
return SYS_ERR_OK;
}
errval_t aos_rpc_create(struct aos_rpc *chan, char *path, int *fd)
{
// TODO (milestone 7): implement file create
return SYS_ERR_OK;
}
errval_t aos_rpc_delete(struct aos_rpc *chan, char *path)
{
// TODO (milestone 7): implement file delete
return SYS_ERR_OK;
}
//
errval_t aos_setup_channel(struct lmp_chan *lc, struct capref remote_cap,
struct event_closure ec)
{
// Initialize LMP channel
lmp_chan_init(lc);
// Setup endpoint and allocate associated capability
struct capref ep_cap;
struct lmp_endpoint *my_ep;
errval_t err = endpoint_create(FIRSTEP_BUFLEN, &ep_cap, &my_ep);
if(err_is_fail(err)){
return err;
}
// Set relevant members of LMP channel
lc->endpoint = my_ep;
lc->local_cap = ep_cap;
lc->remote_cap = remote_cap;
// Allocate the slot for receiving
err = lmp_chan_alloc_recv_slot(lc);
if (err_is_fail(err)){
return err;
}
// Register our receive handler
err = lmp_chan_register_recv(lc, get_default_waitset(), ec);
if (err_is_fail(err)){
return err;
}
return SYS_ERR_OK;
}
errval_t aos_retrieve_msg(struct lmp_chan *lc, struct capref *remote_cap,
uint32_t *rpc_code, struct lmp_recv_msg *msg)
{
// Retrieve message
errval_t err = lmp_chan_recv(lc, msg, remote_cap);
if (err_is_fail(err)) {
debug_printf("Could not retrieve message: %s.\n",
err_getstring(err));
err_print_calltrace(err);
return err;
}
// Re-allocate
if (!capref_is_null(*remote_cap)){
err = lmp_chan_alloc_recv_slot(lc);
if (err_is_fail(err)){
debug_printf("Could not allocate receive slot: %s.\n",
err_getstring(err));
err_print_calltrace(err);
return err;
}
}
if (msg->buf.msglen == 0){
*rpc_code = -1;
return SYS_ERR_OK; // FIXME change to 'wrong format'
}
// Retrieve rpc code
*rpc_code = msg->words[0];
// Shift remaining buffer
for(uint32_t i = 0; i < (msg->buf.msglen)-1; i++){
msg->words[i] = msg->words[i+1];
}
msg->buf.msglen--;
return SYS_ERR_OK;
}
errval_t aos_chan_send_string(struct lmp_chan *lc, const char *string)
{
size_t slen = strlen(string) + 1; // adjust for null-character
size_t rlen = 0;
char buf[8];
errval_t err;
while (rlen < slen) {
size_t chunk_size = ((slen-rlen) < 8) ? (slen-rlen) : 8;
memcpy(buf, string, chunk_size);
err = lmp_chan_send(lc, LMP_SEND_FLAGS_DEFAULT, NULL_CAP,
9, SEND_TEXT, buf[0], buf[1], buf[2],
buf[3], buf[4], buf[5], buf[6], buf[7]);
if (err_is_fail(err)) {
return err;
}
string = &(string[8]);
rlen += 8;
}
return SYS_ERR_OK;
}
/**
* The caller should configure
* the right LMP Channel configs prior to calling this init
* function.
*/
errval_t aos_rpc_init(struct aos_rpc *rpc)
{
// Get waitset for memeater
struct waitset *ws = get_default_waitset();
waitset_init(ws);
rpc->char_count = 0;
// register in paging state
struct paging_state *st = get_current_paging_state();
st->rpc = rpc;
errval_t err = aos_setup_channel(&rpc->init_lc, cap_initep,
MKCLOSURE(init_recv_handler, rpc));
if (err_is_fail(err)) {
debug_printf("Could not setup channel for init.\n");
err_print_calltrace(err);
return err;
}
struct capref cap_spawndep = {
.cnode = cnode_task,
.slot = TASKCN_SLOT_SPAWNDEP,
};
err = aos_setup_channel(&rpc->spawnd_lc, cap_spawndep,
MKCLOSURE(spawnd_recv_handler, rpc));
if (err_is_fail(err)) {
debug_printf("Could not setup channel for init.\n");
err_print_calltrace(err);
return err;
}
// Register channel at init
err = lmp_chan_send2(&rpc->init_lc, LMP_SEND_FLAGS_DEFAULT,
rpc->init_lc.local_cap, REGISTER_CHANNEL,
disp_get_domain_id());
if (err_is_fail(err)) {
debug_printf("Could not register by init.\n");
err_print_calltrace(err);
return err;
}
if (strcmp("spawnd", disp_name()) == 0){
debug_printf("spawnd rpc setup done.\n");
return SYS_ERR_OK;
}
// Wait for init to send back new, dedicated endpoint
event_dispatch(get_default_waitset());
// Register channel at spawnd
err = lmp_chan_send1(&rpc->spawnd_lc, LMP_SEND_FLAGS_DEFAULT,
rpc->spawnd_lc.local_cap, REGISTER_CHANNEL);
if (err_is_fail(err)) {
debug_printf("Could not register by spawnd.\n");
err_print_calltrace(err);
return err;
}
// NOTICE: We don't wait for dedicated endpoint from spawnd, since
// this was created when this process was spawned
debug_printf("%s rpc setup done.\n", disp_name());
return SYS_ERR_OK;
}
// /**
// * \brief registers a custom recv handler for a given userspace application
// * all userspace app may not necessarily have the same interfaces nor deal with
// * all events dealt by init.
// */
// errval_t aos_rpc_register_recv_handler(struct aos_rpc *rpc, void *recv_handler)
// {
// assert(recv_handler != NULL && rpc != NULL);
//
// rpc->recv_handler = recv_handler;
//
// return SYS_ERR_OK;
// }
//
// /**
// * \brief registers a custom send handler for a given userspace application
// */
// errval_t aos_rpc_register_send_handler(struct aos_rpc *rpc, void *send_handler)
// {
// assert(send_handler != NULL && rpc != NULL);
//
// rpc->send_handler = send_handler;
//
// return SYS_ERR_OK;
// }
//
static void clean_aos_rpc_msgbuf(struct aos_rpc *rpc)
{
memset(rpc->msg_buf, '\0', AOS_RPC_MSGBUF_LEN);
}
| 27.562748 | 89 | 0.582123 |
a23ce9c729839f6445b6c33f6eb8b50656c49441 | 3,784 | h | C | thirdparty/cctools/as/fixes.h | smirn0v/dohol | 4b7db2ddfad7a11c78d0512a76dbc2e48bcedb1c | [
"MIT"
] | 132 | 2019-06-06T07:13:12.000Z | 2022-03-23T11:27:43.000Z | thirdparty/cctools/as/fixes.h | smirn0v/dohol | 4b7db2ddfad7a11c78d0512a76dbc2e48bcedb1c | [
"MIT"
] | 3 | 2019-07-19T04:46:20.000Z | 2022-03-24T01:53:07.000Z | thirdparty/cctools/as/fixes.h | smirn0v/dohol | 4b7db2ddfad7a11c78d0512a76dbc2e48bcedb1c | [
"MIT"
] | 29 | 2019-06-23T06:14:00.000Z | 2022-01-04T06:38:40.000Z | #ifndef _FIXES_H_
#define _FIXES_H_
/* fixes.h (was write.h in the original GAS)
Copyright (C) 1987 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS 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 1, or (at your option)
any later version.
GAS 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 GAS; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/*
* For machines with machine dependent relocation types (encoded in the r_type
* field of a relocation_info struct) they use NO_RELOC in assembling
* instructions which they want to indicate have no relocation.
*/
#define NO_RELOC 0x10 /* above the range of r_type:4 */
/*
* FixSs may be built up in any order.
*/
struct fix {
fragS *fx_frag; /* which frag? */
int32_t fx_where; /* where is the 1st byte to fix up? */
symbolS *fx_addsy; /* NULL or Symbol whose value we add in */
symbolS *fx_subsy; /* NULL or Symbol whose value we subtract */
#if defined(I386) && defined(ARCH64)
symbolS *fx_localsy; /* NULL or pseudo-symbol for this fixup */
#endif
signed_expr_t
fx_offset; /* absolute number we add in */
struct fix *fx_next; /* NULL or -> next fixS */
char fx_size; /* how many bytes are involved? */
char fx_pcrel; /* TRUE: pc-relative. */
char fx_pcrel_reloc;/* force a pc-relative relocatation entry */
char fx_r_type; /* relocation type */
int32_t fx_value; /* the relocated value placed in the frag */
char *file; /* the file name this came from for errors */
unsigned int line; /* the line number this came from for errors */
/* FROM write.h line 82 */
/* Has this relocation already been applied? */
unsigned fx_done : 1,
/* Non-zero if we have the special assembly time constant expression
of the difference of two symbols defined in the same section then divided
by exactly 2. */
fx_sectdiff_divide_by_two : 1;
/* FROM write.h line 133 */
/* This field is sort of misnamed. It appears to be a sort of random
scratch field, for use by the back ends. The main gas code doesn't
do anything but initialize it to zero. The use of it does need to
be coordinated between the cpu and format files, though. E.g., some
coff targets pass the `addend' field from the cpu file via this
field. I don't know why the `fx_offset' field above can't be used
for that; investigate later and document. KR */
valueT fx_addnumber;
/* FROM write.h line 142 */
/* The location of the instruction which created the reloc, used
in error messages. */
#ifdef NOTYET
char *fx_file;
unsigned fx_line;
#else
#define fx_file file
#define fx_line line
void *tc_fix_data;
#endif
};
typedef struct fix fixS;
extern fixS *fix_new(
fragS *frag, /* which frag? */
int where, /* where in that frag? */
int size, /* 1, 2 or 4 bytes */
symbolS *add_symbol, /* X_add_symbol */
symbolS *sub_symbol, /* X_subtract_symbol */
signed_target_addr_t
offset, /* X_add_number */
int pcrel, /* TRUE if PC-relative */
int pcrel_reloc, /* TRUE if must have relocation entry */
int r_type); /* relocation type */
/* FROM write.h line 210 */
#include "expr.h"
extern fixS *fix_new_exp
(fragS * frag, int where, int size, expressionS *exp, int pcrel,
int pcrel_reloc, int r_type);
#endif /* _FIXES_H_ */
| 36.737864 | 78 | 0.700846 |
a23d35276c7ce6d40a4957b6ab3eabbd595117be | 1,689 | h | C | src/bin/rafi-sim/System.h | fjt7tdmi/rafi-1st | 46574c843335ccea7fe2a1201dd2d9245e414136 | [
"Apache-2.0"
] | 2 | 2019-12-31T00:45:11.000Z | 2020-09-22T04:30:25.000Z | src/bin/rafi-sim/System.h | fjt7tdmi/rafi-1st | 46574c843335ccea7fe2a1201dd2d9245e414136 | [
"Apache-2.0"
] | null | null | null | src/bin/rafi-sim/System.h | fjt7tdmi/rafi-1st | 46574c843335ccea7fe2a1201dd2d9245e414136 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2018 Akifumi Fujita
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <rafi/emu.h>
#include <rafi/trace.h>
#include "VCore.h"
namespace rafi { namespace sim {
class System final : public trace::ILoggerTarget
{
public:
explicit System(VCore* pCore, size_t ramSize);
virtual ~System();
void SetHostIoAddr(paddr_t hostIoAddr);
void LoadFileToMemory(const char* path);
void Reset();
void ProcessPositiveEdge();
void ProcessNegativeEdge();
void UpdateSignal();
void ClearEventList();
bool IsOpRetired() const;
// ILoggerTarget
virtual uint32_t GetHostIoValue() const override;
virtual uint64_t GetPc() const override;
virtual void CopyIntReg(trace::NodeIntReg32* pOut) const override;
virtual void CopyIntReg(trace::NodeIntReg64* pOut) const override;
virtual void CopyFpReg(trace::NodeFpReg* pOut) const override;
virtual const trace::EventList& GetEventList() const override;
private:
static const paddr_t AddrRam = 0x80000000;
VCore* m_pCore;
paddr_t m_HostIoAddr;
trace::EventList m_EventList;
emu::Bus m_Bus;
emu::Ram m_Ram;
};
}}
| 25.590909 | 75 | 0.718769 |
a2421c1a7ad2f7e5657ce38276312d7baf5cd515 | 5,031 | c | C | llpv1e/Process_Control/02_fork_1.c | yuweijun/books | 5be0fec3adce236875fef0f9e1ed8d91ef4acbfe | [
"MIT"
] | 1 | 2018-07-02T12:03:02.000Z | 2018-07-02T12:03:02.000Z | llpv1e/Process_Control/02_fork_1.c | yuweijun/books | 5be0fec3adce236875fef0f9e1ed8d91ef4acbfe | [
"MIT"
] | null | null | null | llpv1e/Process_Control/02_fork_1.c | yuweijun/books | 5be0fec3adce236875fef0f9e1ed8d91ef4acbfe | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
/*
Un processo esistente puo' creare un nuovo processo invocando la system call
fork(), il nuovo processo creato dalla fork() e' chiamato "Child Process"
(Processo figlio), mentre il processo generatore e' chiamato "Parent Process"
(Processo padre); la fork() e' chiamata una volta ma ritorna due volte, una
nel padre e una nel figlio, infatti il PID del figlio e' assegnato al padre
mentre il PID del figlio assume valore 0.
Perche' la fork() ritorna due volte? Un processo puo' avere uno o piu' figli, il
valore di ritorno della fork() e' l'unico modo per individuare l'ultimo 'nato';
un figlio invece ha sempre un solo padre, individuabile mediante getppid(), per
cui gli si assegna pid 0, che nessun altro processo puo' avere.
HEADER : <unistd.h>
PROTOTYPE : pid_t fork(void);
SEMANTICS : La funzione fork() crea un processo duplicando il processo chiamante
, il nuovo processo e' chiamato processo figlio, mentre il processo
chiamante e' il processo genitore.
RETURNS : 0 nel figlio e il PID del figlio nel padre in caso di successo, -1
in caso di errore
--------------------------------------------------------------------------------
Il Child Process e' una copia del data segment, dello stack e dello heap del
Parent Process, tale copia e' ad uso e consumo del Child Process e pertanto non
vi e' condivisione col Parent Process; la sezione text segment invece e'
condivisa tra Parent Process e Child Process, per gli altri segmenti invece
il kernel Linux utilizza la tecnica del "copy on write", ossia ogni pagina
viene realmente ed effettivamente copiata per il nuovo processo se e solo se
tale pagina e' stata scritta.
Il Sistema Operativo assegna due porzioni di memoria private, una per il
Parent Process, l'altra per il Child Process, pertanto qualora uno dei due
processi dovesse modificare una *propria* variabile, tale modifica non
sarebbe visibile ad entrambi; i file aperti invece sono condivisi, per cui
una eventuale modifica ad un file sarebbe ad entrambi visibile.
L'implementazione della SystemCall fork() puo' essere diversa a seconda del
sistema UNIX utilizzato; l'header da utilizzare e' <unistd.h>.
pid_t e' un tipo di dato definito in <sys/types.h>, sarebbe stato lo stesso
se si fosse utilizzato un altro tipo di dato intero, tuttavia e' sempre
consigliabile utilizzare i tipi proposti per una maggiore portabilita'.
Condivisione dei file (File sharing):
I file descriptors aperti nel padre sono duplicati nel figlio, come se fosse
utilizzata la funzione dup()[1], infatti essi condividono sia la file table,
sia la posizione (offset) all'interno file stesso, che peraltro e' di
fondamentale importanza qualora due o piu' processi volessero scrivere sul
medesimo file. Tuttavia e' estremamente importante ricordare che se padre e
figlio volessero interagire con lo stesso file descriptor e senza
nessun meccanismo di sincronizzazione, il risultato sarebbe un mix delle due
scritture sul file, e quindi poco coerente; pertanto, sebbene possibile,
non e' certamente il metodo piu' adatto.
Vi sono solo due casi in cui e' possibile gestire file despritors dopo una
chiamata a fork():
1 - Il padre aspetta che il figlio completi la propria esecuzione;
2 - Il padre ed il figlio proseguono indipendentemente l'un l'altro.
Implementazione:
Il kernel conserva una lista di tutti i processi attivi in una tabella, detta
"process table", ciascuna voce all'interno di questa tabella e' definita dalla
struttura "task_struct" implementata nell'header <linux/sched.h>, tale struttura
gestisce diverse informazioni, dallo stato del processo alla priorita', dal PID
alla policy e via discorrendo, in pratica tutto cio' che riguarda un processo.
Quale' il compito dello scheduler?
Non vi e' certezza se sara' eseguito prima il padre o prima il figlio, questo
dipende dal comportamento dello schedulatore dei processi; e' lo scheduler che
decide, secondo specifici algoritmi, basati anche sulla priorita', quale
processo debba essere messo in esecuzione - e' come se fosse un vigile urbano,
e' lui che dirige il traffico -; viene eseguito quando:
- Si invoca una System Call;
- Si verifica un Interruput;
- Si chiama esplicitamente;
- altre circostanze.
*/
int main(int argc, char* argv[])
{
pid_t pid;
/* Si crea un processo figlio */
pid = fork();
switch (pid) {
case -1:
fprintf(stderr, "Err.(%s) fork() failed\n", strerror(errno));
exit(EXIT_FAILURE);
case 0:
printf("(PID %ld) Figlio in esecuzione, il Padre: %ld - pid=%ld\n",
(long)getpid(), (long)getppid(), (long)pid);
exit(EXIT_SUCCESS);
default:
printf("(PID %ld) Padre in esecuzione, il Padre: %ld - pid=%ld\n",
(long)getpid(), (long)getppid(), (long)pid);
sleep(1);
exit(EXIT_SUCCESS);
}
return (EXIT_SUCCESS);
}
/*
[1] Files-and-Directories: 13_duplicate_file_descriptor.c
*/
| 43 | 80 | 0.735639 |
a2460a7ddf07acbeea2e84d53d93f49cac4c5764 | 1,559 | h | C | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/StandInfo.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | 5 | 2020-03-29T12:08:37.000Z | 2021-05-26T05:20:11.000Z | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/StandInfo.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | null | null | null | AliPayForDebug/AliPayForDebug/AlipayWallet_Headers/StandInfo.h | ceekay1991/AliPayForDebug | 5795e5db31e5b649d4758469b752585e63e84d94 | [
"MIT"
] | 5 | 2020-04-17T03:24:04.000Z | 2022-03-30T05:42:17.000Z | //
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Sep 17 2017 16:24:48).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard.
//
#import "APDPBGeneratedMessage.h"
@class NSString, PBMapStringString;
@interface StandInfo : APDPBGeneratedMessage
{
}
+ (CDStruct_af61540b *)_fieldInfos;
// Remaining properties
@property(retain, nonatomic) NSString *actionText; // @dynamic actionText;
@property(retain, nonatomic) NSString *actionUrl; // @dynamic actionUrl;
@property(nonatomic) _Bool closeAble; // @dynamic closeAble;
@property(nonatomic) _Bool closeRemeber; // @dynamic closeRemeber;
@property(retain, nonatomic) PBMapStringString *contextInfo; // @dynamic contextInfo;
@property(readonly) _Bool hasActionText; // @dynamic hasActionText;
@property(readonly) _Bool hasActionUrl; // @dynamic hasActionUrl;
@property(readonly) _Bool hasCloseAble; // @dynamic hasCloseAble;
@property(readonly) _Bool hasCloseRemeber; // @dynamic hasCloseRemeber;
@property(readonly) _Bool hasContextInfo; // @dynamic hasContextInfo;
@property(readonly) _Bool hasIcon; // @dynamic hasIcon;
@property(readonly) _Bool hasInfo; // @dynamic hasInfo;
@property(readonly) _Bool hasTitle; // @dynamic hasTitle;
@property(readonly) _Bool hasType; // @dynamic hasType;
@property(retain, nonatomic) NSString *icon; // @dynamic icon;
@property(retain, nonatomic) NSString *info; // @dynamic info;
@property(retain, nonatomic) NSString *title; // @dynamic title;
@property(retain, nonatomic) NSString *type; // @dynamic type;
@end
| 39.974359 | 90 | 0.755613 |
a2463fb6d3d6e9dfd2f94d3793693e9b473930bb | 4,063 | c | C | fatfs_sdio.c | nzc21489/sd_pico | 62f126ccffd28f63260daf1b886c70a661a3530f | [
"MIT"
] | null | null | null | fatfs_sdio.c | nzc21489/sd_pico | 62f126ccffd28f63260daf1b886c70a661a3530f | [
"MIT"
] | null | null | null | fatfs_sdio.c | nzc21489/sd_pico | 62f126ccffd28f63260daf1b886c70a661a3530f | [
"MIT"
] | null | null | null | /*
* The MIT License (MIT)
*
* Copyright (c) 2022 nzc21489
*
* 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.
*
*/
#pragma GCC optimize("O2")
#include <stdio.h>
#include "pico/sdio.h"
#include "ff.h"
#include "diskio.h"
#include <string.h>
DSTATUS Stat = STA_NOINIT;
DSTATUS disk_status(
BYTE pdrv /* [IN] Physical drive number */
)
{
if (pdrv != 0)
{
return STA_NOINIT; /* Supports only single drive */
}
else
{
return Stat;
}
}
DSTATUS disk_initialize(
BYTE pdrv /* Physical drive nmuber (0) */
)
{
if (pdrv != 0)
{
return STA_NOINIT;
}
#ifdef sdio_4pin
if (sd_init_4pins() == 0)
#else
if (sd_init_1pin() == 0)
#endif
{
sd_set_clock_divider(3);
Stat &= ~STA_NOINIT; /* Clear STA_NOINIT */
}
else
{
Stat = STA_NOINIT;
}
return Stat;
}
DRESULT disk_read(
BYTE pdrv, /* Physical drive nmuber (0) */
BYTE *buff, /* Pointer to the data buffer to store read data */
LBA_t sector, /* Start sector number (LBA) */
UINT count /* Sector count (1..128) */
)
{
if (pdrv != 0)
{
return STA_NOINIT;
}
sd_set_clock_divider(3);
if (Stat == 0)
{
for (int i = 0; i < count; i++)
{
uint32_t tmp_bff[512/4];
if (sd_readblocks_sync(&tmp_bff[0], sector + i, 1) == 0)
{
memcpy((uint8_t *)buff + 512 * i, tmp_bff, 512);
}
else
{
printf("read error\n");
return RES_ERROR;
}
}
return RES_OK;
}
else
{
printf("Stat error\n");
return RES_ERROR;
}
}
DRESULT disk_write(
BYTE pdrv, /* Physical drive nmuber (0) */
const BYTE *buff, /* Pointer to the data to be written */
LBA_t sector, /* Start sector number (LBA) */
UINT count /* Sector count (1..128) */
)
{
if (pdrv != 0)
{
return STA_NOINIT;
}
sd_set_clock_divider(30);
if (Stat == 0)
{
if (sd_writeblocks_async((uint32_t *)buff, sector, count) != 0)
{
return RES_ERROR;
}
static int timeout = 10;
int rc;
while (!sd_write_complete(&rc))
{
printf("Waiting for completion\n");
if (!--timeout)
{
return RES_ERROR;
}
}
return RES_OK;
}
else
{
return RES_ERROR;
}
}
DRESULT disk_ioctl(
BYTE pdrv, /* Physical drive nmuber (0) */
BYTE cmd, /* Control code */
void *buff /* Buffer to send/receive data block */
)
{
switch (cmd)
{
case CTRL_SYNC:
return RES_OK;
case GET_SECTOR_COUNT:
*((DWORD *)buff) = 0;
return RES_ERROR;
case GET_SECTOR_SIZE:
*((WORD *)buff) = 512;
return RES_OK;
case GET_BLOCK_SIZE:
return RES_ERROR;
}
return RES_ERROR;
}
DWORD get_fattime(void)
{
return 0;
}
| 22.954802 | 80 | 0.575683 |