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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
a2e75987f09840389bbf2850475ef881c9820490 | 286 | h | C | MMNotificationCenterDemo/AppDelegate.h | cky113999742/NotificationCenterDemo | aa576ba12a42b33b960d69bab2f07042e0161f3d | [
"MIT"
] | null | null | null | MMNotificationCenterDemo/AppDelegate.h | cky113999742/NotificationCenterDemo | aa576ba12a42b33b960d69bab2f07042e0161f3d | [
"MIT"
] | null | null | null | MMNotificationCenterDemo/AppDelegate.h | cky113999742/NotificationCenterDemo | aa576ba12a42b33b960d69bab2f07042e0161f3d | [
"MIT"
] | null | null | null | //
// AppDelegate.h
// MMNotificationCenterDemo
//
// Created by Cuikeyi on 2017/7/20.
// Copyright © 2017年 MOMO. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
| 15.888889 | 60 | 0.716783 |
a2eba6167066cefd06e27a86e3b38ed6f7f84039 | 7,509 | h | C | chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h | junmin-zhu/chromium-rivertrail | eb1a57aca71fe68d96e48af8998dcfbe45171ee1 | [
"BSD-3-Clause"
] | null | null | null | chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h | junmin-zhu/chromium-rivertrail | eb1a57aca71fe68d96e48af8998dcfbe45171ee1 | [
"BSD-3-Clause"
] | null | null | null | chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h | junmin-zhu/chromium-rivertrail | eb1a57aca71fe68d96e48af8998dcfbe45171ee1 | [
"BSD-3-Clause"
] | 1 | 2020-11-04T07:27:33.000Z | 2020-11-04T07:27:33.000Z | // Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ui/omnibox/omnibox_popup_model.h"
#include "chrome/browser/ui/omnibox/omnibox_popup_view.h"
#include "chrome/browser/ui/views/omnibox/omnibox_result_view_model.h"
#include "ui/base/animation/animation_delegate.h"
#include "ui/base/animation/slide_animation.h"
#include "ui/gfx/font.h"
#include "ui/views/view.h"
#include "webkit/glue/window_open_disposition.h"
struct AutocompleteMatch;
class OmniboxEditModel;
class OmniboxResultView;
class OmniboxView;
class Profile;
namespace views {
class BubbleBorder;
}
// A view representing the contents of the autocomplete popup.
class OmniboxPopupContentsView : public views::View,
public OmniboxResultViewModel,
public OmniboxPopupView,
public ui::AnimationDelegate {
public:
// Factory method for creating the AutocompletePopupView.
static OmniboxPopupView* Create(const gfx::Font& font,
OmniboxView* omnibox_view,
OmniboxEditModel* edit_model,
views::View* location_bar);
// Returns the bounds the popup should be shown at. This is the display bounds
// and includes offsets for the dropshadow which this view's border renders.
gfx::Rect GetPopupBounds() const;
virtual void LayoutChildren();
// Overridden from OmniboxPopupView:
virtual bool IsOpen() const OVERRIDE;
virtual void InvalidateLine(size_t line) OVERRIDE;
virtual void UpdatePopupAppearance() OVERRIDE;
virtual gfx::Rect GetTargetBounds() OVERRIDE;
virtual void PaintUpdatesNow() OVERRIDE;
virtual void OnDragCanceled() OVERRIDE;
// Overridden from OmniboxResultViewModel:
virtual bool IsSelectedIndex(size_t index) const OVERRIDE;
virtual bool IsHoveredIndex(size_t index) const OVERRIDE;
virtual gfx::Image GetIconIfExtensionMatch(size_t index) const OVERRIDE;
// Overridden from ui::AnimationDelegate:
virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
// Overridden from views::View:
virtual void Layout() OVERRIDE;
virtual views::View* GetEventHandlerForPoint(
const gfx::Point& point) OVERRIDE;
virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE;
virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseCaptureLost() OVERRIDE;
virtual void OnMouseMoved(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE;
virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
virtual ui::EventResult OnGestureEvent(
const ui::GestureEvent& event) OVERRIDE;
protected:
OmniboxPopupContentsView(const gfx::Font& font,
OmniboxView* omnibox_view,
OmniboxEditModel* edit_model,
views::View* location_bar);
virtual ~OmniboxPopupContentsView();
virtual void PaintResultViews(gfx::Canvas* canvas);
// Calculates the height needed to show all the results in the model.
virtual int CalculatePopupHeight();
virtual OmniboxResultView* CreateResultView(
OmniboxResultViewModel* model,
int model_index,
const gfx::Font& font,
const gfx::Font& bold_font);
// Overridden from views::View:
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
// This method should not be triggered directly as we paint our children
// in an un-conventional way inside OnPaint. We use a separate canvas to
// paint the children. Hence we override this method to a no-op so that
// the view hierarchy does not "accidentally" trigger this.
virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE;
scoped_ptr<OmniboxPopupModel> model_;
private:
class AutocompletePopupWidget;
// Call immediately after construction.
void Init();
// Returns true if the model has a match at the specified index.
bool HasMatchAt(size_t index) const;
// Returns the match at the specified index within the popup model.
const AutocompleteMatch& GetMatchAtIndex(size_t index) const;
// Fill a path for the contents' roundrect. |bounding_rect| is the rect that
// bounds the path.
void MakeContentsPath(gfx::Path* path, const gfx::Rect& bounding_rect);
// Updates the window's blur region for the current size.
void UpdateBlurRegion();
// Makes the contents of the canvas slightly transparent.
void MakeCanvasTransparent(gfx::Canvas* canvas);
// Called when the line at the specified index should be opened with the
// provided disposition.
void OpenIndex(size_t index, WindowOpenDisposition disposition);
// Find the index of the match under the given |point|, specified in window
// coordinates. Returns OmniboxPopupModel::kNoMatch if there isn't a match at
// the specified point.
size_t GetIndexForPoint(const gfx::Point& point);
// Processes a located event (e.g. mouse/gesture) and sets the selection/hover
// state of a line in the list.
void UpdateLineEvent(const ui::LocatedEvent& event,
bool should_set_selected_line);
// Opens an entry from the list depending on the event and the selected
// disposition.
void OpenSelectedLine(const ui::LocatedEvent& event,
WindowOpenDisposition disposition);
// Returns the target bounds given the specified content height.
gfx::Rect CalculateTargetBounds(int h);
// The popup that contains this view. We create this, but it deletes itself
// when its window is destroyed. This is a WeakPtr because it's possible for
// the OS to destroy the window and thus delete this object before we're
// deleted, or without our knowledge.
base::WeakPtr<AutocompletePopupWidget> popup_;
// The edit view that invokes us.
OmniboxView* omnibox_view_;
Profile* profile_;
// An object that the popup positions itself against.
views::View* location_bar_;
// Our border, which can compute our desired bounds.
const views::BubbleBorder* bubble_border_;
// The font that we should use for result rows. This is based on the font used
// by the edit that created us.
gfx::Font result_font_;
// The font used for portions that match the input.
gfx::Font result_bold_font_;
// If the user cancels a dragging action (i.e. by pressing ESC), we don't have
// a convenient way to release mouse capture. Instead we use this flag to
// simply ignore all remaining drag events, and the eventual mouse release
// event. Since OnDragCanceled() can be called when we're not dragging, this
// flag is reset to false on a mouse pressed event, to make sure we don't
// erroneously ignore the next drag.
bool ignore_mouse_drag_;
// The popup sizes vertically using an animation when the popup is getting
// shorter (not larger, that makes it look "slow").
ui::SlideAnimation size_animation_;
gfx::Rect start_bounds_;
gfx::Rect target_bounds_;
DISALLOW_COPY_AND_ASSIGN(OmniboxPopupContentsView);
};
#endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_
| 39.730159 | 80 | 0.735118 |
a2ebe163d50f49eb17a1790fd7a05f2121d21b57 | 529 | h | C | Pod/Classes/Formatters/SWUriFormatter.h | KhizhniakovM/swig | 4670c876496aeb79df11975baba44b7231bc54d7 | [
"MIT"
] | 10 | 2015-02-13T01:00:45.000Z | 2020-04-23T12:01:55.000Z | Pod/Classes/Formatters/SWUriFormatter.h | KhizhniakovM/swig | 4670c876496aeb79df11975baba44b7231bc54d7 | [
"MIT"
] | 7 | 2015-01-29T21:24:45.000Z | 2017-06-22T02:33:39.000Z | Pod/Classes/Formatters/SWUriFormatter.h | KhizhniakovM/swig | 4670c876496aeb79df11975baba44b7231bc54d7 | [
"MIT"
] | 9 | 2015-02-05T05:53:35.000Z | 2019-10-02T08:35:08.000Z | //
// SWUriFormatter.h
// swig
//
// Created by Pierre-Marc Airoldi on 2014-08-21.
// Copyright (c) 2014 PeteAppDesigns. All rights reserved.
//
#import <Foundation/Foundation.h>
//TODO actually make it an nsformatter
@class SWAccount, SWContact;
@interface SWUriFormatter : NSObject
+(NSString *)sipUri:(NSString *)uri;
+(NSString *)sipUri:(NSString *)uri fromAccount:(SWAccount *)account;
+(NSString *)sipUri:(NSString *)uri withDisplayName:(NSString *)displayName;
+(SWContact *)contactFromURI:(NSString *)uri;
@end
| 23 | 76 | 0.727788 |
a2ece573b37d4862d0a526f30fb41c392075e3e4 | 478 | h | C | CommonFMDBUtilDemo/Pods/Headers/Public/CJNetwork/CJDataMemoryCacheManager.h | dvlproad/CJDatabase | 2e1a5498ae87a8df49bcf6f43ebe014b9ec83bcf | [
"MIT"
] | null | null | null | CommonFMDBUtilDemo/Pods/Headers/Public/CJNetwork/CJDataMemoryCacheManager.h | dvlproad/CJDatabase | 2e1a5498ae87a8df49bcf6f43ebe014b9ec83bcf | [
"MIT"
] | null | null | null | CommonFMDBUtilDemo/Pods/Headers/Public/CJNetwork/CJDataMemoryCacheManager.h | dvlproad/CJDatabase | 2e1a5498ae87a8df49bcf6f43ebe014b9ec83bcf | [
"MIT"
] | 1 | 2019-10-28T09:51:12.000Z | 2019-10-28T09:51:12.000Z | //
// CJDataMemoryCacheManager.h
// CommonFMDBUtilDemo
//
// Created by ciyouzen on 7/31/15.
// Copyright (c) 2015 dvlproad. All rights reserved.
//
#import <Foundation/Foundation.h>
/**
* 可拓展的内存缓存策略
*/
@interface CJDataMemoryCacheManager : NSObject
/**
* 将数据写入内存
*
* @param data 数据
* @param key 键值
*/
+ (void)writeData:(id)data forKey:(NSString *)key;
/**
* 从内存中读取数据
*
* @param key 键值
*
* @return 数据
*/
+ (id)readDataWithKey:(NSString *)key;
@end
| 14.058824 | 53 | 0.638075 |
a2ecfebb73e5c64019289d1fdb96d152f532181f | 656 | h | C | YLCleaner/Xcode-RuntimeHeaders/DevToolsInterface/PBXProjectTemplateClonerWizardProxy.h | liyong03/YLCleaner | 7453187a884c8e783bda1af82cbbb51655ec41c6 | [
"MIT"
] | 1 | 2019-02-15T02:16:35.000Z | 2019-02-15T02:16:35.000Z | YLCleaner/Xcode-RuntimeHeaders/DevToolsInterface/PBXProjectTemplateClonerWizardProxy.h | liyong03/YLCleaner | 7453187a884c8e783bda1af82cbbb51655ec41c6 | [
"MIT"
] | null | null | null | YLCleaner/Xcode-RuntimeHeaders/DevToolsInterface/PBXProjectTemplateClonerWizardProxy.h | liyong03/YLCleaner | 7453187a884c8e783bda1af82cbbb51655ec41c6 | [
"MIT"
] | null | null | null | /*
* Generated by class-dump 3.3.4 (64 bit).
*
* class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2011 by Steve Nygard.
*/
#import "NSObject.h"
#import "PBXWizardProxies-Protocol.h"
@class NSString;
@interface PBXProjectTemplateClonerWizardProxy : NSObject <PBXWizardProxies>
{
NSString *_templateProjectPath;
NSString *_templateName;
}
+ (id)proxyWithTemplateProjectPath:(id)arg1 templateName:(id)arg2;
- (id)icon;
- (id)_defaultIcon;
- (id)wizardDescription;
- (id)instantiateWizardWithParent:(id)arg1;
- (id)categorizedWizardNames;
- (void)dealloc;
- (id)initWithTemplateProjectPath:(id)arg1 templateName:(id)arg2;
@end
| 21.866667 | 83 | 0.733232 |
a2ee57b27451acf2b9d2bff31e83de9d39c3d483 | 517 | h | C | BTClassicDevice.h | Chrysus/ESP32-OBDII | 7119314e5f603f85b96317c7664e9da8cf7fe84c | [
"MIT"
] | null | null | null | BTClassicDevice.h | Chrysus/ESP32-OBDII | 7119314e5f603f85b96317c7664e9da8cf7fe84c | [
"MIT"
] | null | null | null | BTClassicDevice.h | Chrysus/ESP32-OBDII | 7119314e5f603f85b96317c7664e9da8cf7fe84c | [
"MIT"
] | 1 | 2020-09-07T13:02:06.000Z | 2020-09-07T13:02:06.000Z | #include <Arduino.h>
// BTClassicDevice Class
class BTClassicDevice {
public:
// Constructors
BTClassicDevice();
BTClassicDevice(BTClassicDevice *device);
BTClassicDevice(void *param); //<< param should be a esp_bt_gap_cb_param_t*
~BTClassicDevice();
void UpdateDevice(BTClassicDevice *device);
uint8_t device_name_len;
char *device_name;
uint8_t mac_address[6];
void SetDeviceName(char *device_name, uint8_t len);
void SetDeviceAddress(uint8_t *device_address);
void printInfo();
};
| 20.68 | 77 | 0.748549 |
a2ee6587610b973d1cf7c78740d962c626a79fce | 7,033 | h | C | media/webrtc/webrtcmediaengine.h | MIPS/external-chromium_org-third_party-libjingle-source-talk | 06a093c73d10bd918baa95312974108bf37b54b4 | [
"BSL-1.0",
"BSD-3-Clause"
] | null | null | null | media/webrtc/webrtcmediaengine.h | MIPS/external-chromium_org-third_party-libjingle-source-talk | 06a093c73d10bd918baa95312974108bf37b54b4 | [
"BSL-1.0",
"BSD-3-Clause"
] | null | null | null | media/webrtc/webrtcmediaengine.h | MIPS/external-chromium_org-third_party-libjingle-source-talk | 06a093c73d10bd918baa95312974108bf37b54b4 | [
"BSL-1.0",
"BSD-3-Clause"
] | null | null | null | /*
* libjingle
* Copyright 2011 Google Inc.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TALK_MEDIA_WEBRTCMEDIAENGINE_H_
#define TALK_MEDIA_WEBRTCMEDIAENGINE_H_
#include "talk/media/base/mediaengine.h"
#include "talk/media/webrtc/webrtcexport.h"
namespace webrtc {
class AudioDeviceModule;
class VideoCaptureModule;
}
namespace cricket {
class WebRtcVideoDecoderFactory;
class WebRtcVideoEncoderFactory;
}
#if !defined(LIBPEERCONNECTION_LIB) && \
!defined(LIBPEERCONNECTION_IMPLEMENTATION)
WRME_EXPORT
cricket::MediaEngineInterface* CreateWebRtcMediaEngine(
webrtc::AudioDeviceModule* adm, webrtc::AudioDeviceModule* adm_sc,
cricket::WebRtcVideoEncoderFactory* encoder_factory,
cricket::WebRtcVideoDecoderFactory* decoder_factory);
WRME_EXPORT
void DestroyWebRtcMediaEngine(cricket::MediaEngineInterface* media_engine);
namespace cricket {
class WebRtcMediaEngine : public cricket::MediaEngineInterface {
public:
WebRtcMediaEngine(
webrtc::AudioDeviceModule* adm,
webrtc::AudioDeviceModule* adm_sc,
cricket::WebRtcVideoEncoderFactory* encoder_factory,
cricket::WebRtcVideoDecoderFactory* decoder_factory)
: delegate_(CreateWebRtcMediaEngine(
adm, adm_sc, encoder_factory, decoder_factory)) {
}
virtual ~WebRtcMediaEngine() {
DestroyWebRtcMediaEngine(delegate_);
}
virtual bool Init(talk_base::Thread* worker_thread) OVERRIDE {
return delegate_->Init(worker_thread);
}
virtual void Terminate() OVERRIDE {
delegate_->Terminate();
}
virtual int GetCapabilities() OVERRIDE {
return delegate_->GetCapabilities();
}
virtual VoiceMediaChannel* CreateChannel() OVERRIDE {
return delegate_->CreateChannel();
}
virtual VideoMediaChannel* CreateVideoChannel(
VoiceMediaChannel* voice_media_channel) OVERRIDE {
return delegate_->CreateVideoChannel(voice_media_channel);
}
virtual SoundclipMedia* CreateSoundclip() OVERRIDE {
return delegate_->CreateSoundclip();
}
virtual bool SetAudioOptions(int options) OVERRIDE {
return delegate_->SetAudioOptions(options);
}
virtual bool SetVideoOptions(int options) OVERRIDE {
return delegate_->SetVideoOptions(options);
}
virtual bool SetAudioDelayOffset(int offset) OVERRIDE {
return delegate_->SetAudioDelayOffset(offset);
}
virtual bool SetDefaultVideoEncoderConfig(
const VideoEncoderConfig& config) OVERRIDE {
return delegate_->SetDefaultVideoEncoderConfig(config);
}
virtual bool SetSoundDevices(
const Device* in_device, const Device* out_device) OVERRIDE {
return delegate_->SetSoundDevices(in_device, out_device);
}
virtual bool GetOutputVolume(int* level) OVERRIDE {
return delegate_->GetOutputVolume(level);
}
virtual bool SetOutputVolume(int level) OVERRIDE {
return delegate_->SetOutputVolume(level);
}
virtual int GetInputLevel() OVERRIDE {
return delegate_->GetInputLevel();
}
virtual bool SetLocalMonitor(bool enable) OVERRIDE {
return delegate_->SetLocalMonitor(enable);
}
virtual bool SetLocalRenderer(VideoRenderer* renderer) OVERRIDE {
return delegate_->SetLocalRenderer(renderer);
}
virtual const std::vector<AudioCodec>& audio_codecs() OVERRIDE {
return delegate_->audio_codecs();
}
virtual const std::vector<RtpHeaderExtension>&
audio_rtp_header_extensions() OVERRIDE {
return delegate_->audio_rtp_header_extensions();
}
virtual const std::vector<VideoCodec>& video_codecs() OVERRIDE {
return delegate_->video_codecs();
}
virtual const std::vector<RtpHeaderExtension>&
video_rtp_header_extensions() OVERRIDE {
return delegate_->video_rtp_header_extensions();
}
virtual void SetVoiceLogging(int min_sev, const char* filter) OVERRIDE {
delegate_->SetVoiceLogging(min_sev, filter);
}
virtual void SetVideoLogging(int min_sev, const char* filter) OVERRIDE {
delegate_->SetVideoLogging(min_sev, filter);
}
virtual bool RegisterVoiceProcessor(
uint32 ssrc, VoiceProcessor* video_processor,
MediaProcessorDirection direction) OVERRIDE {
return delegate_->RegisterVoiceProcessor(ssrc, video_processor, direction);
}
virtual bool UnregisterVoiceProcessor(
uint32 ssrc, VoiceProcessor* video_processor,
MediaProcessorDirection direction) OVERRIDE {
return delegate_->UnregisterVoiceProcessor(ssrc, video_processor,
direction);
}
virtual VideoFormat GetStartCaptureFormat() const OVERRIDE {
return delegate_->GetStartCaptureFormat();
}
virtual sigslot::repeater2<VideoCapturer*, CaptureState>&
SignalVideoCaptureStateChange() {
return delegate_->SignalVideoCaptureStateChange();
}
private:
cricket::MediaEngineInterface* delegate_;
};
} // namespace cricket
#else
#include "talk/media/webrtc/webrtcvideoengine.h"
#include "talk/media/webrtc/webrtcvoiceengine.h"
namespace cricket {
typedef CompositeMediaEngine<WebRtcVoiceEngine, WebRtcVideoEngine>
WebRtcCompositeMediaEngine;
class WebRtcMediaEngine : public WebRtcCompositeMediaEngine {
public:
WebRtcMediaEngine(webrtc::AudioDeviceModule* adm,
webrtc::AudioDeviceModule* adm_sc,
WebRtcVideoEncoderFactory* encoder_factory,
WebRtcVideoDecoderFactory* decoder_factory) {
voice_.SetAudioDeviceModule(adm, adm_sc);
video_.SetVoiceEngine(&voice_);
video_.EnableTimedRender();
video_.SetExternalEncoderFactory(encoder_factory);
video_.SetExternalDecoderFactory(decoder_factory);
}
};
} // namespace cricket
#endif // !defined(LIBPEERCONNECTION_LIB) &&
// !defined(LIBPEERCONNECTION_IMPLEMENTATION)
#endif // TALK_MEDIA_WEBRTCMEDIAENGINE_H_
| 36.066667 | 80 | 0.765676 |
a2eeeba217418ee976bf1d92d9b3d7bd11920bb6 | 5,698 | c | C | src/interfaces/ecpg/preproc/parser.c | lmwnshn/postgres | 649750d995eb953c505077ac4baa73b243f68002 | [
"PostgreSQL"
] | 23 | 2015-06-10T22:09:31.000Z | 2022-02-08T11:55:06.000Z | src/interfaces/ecpg/preproc/parser.c | lmwnshn/postgres | 649750d995eb953c505077ac4baa73b243f68002 | [
"PostgreSQL"
] | 4 | 2020-12-09T05:20:51.000Z | 2021-01-10T01:57:28.000Z | src/interfaces/ecpg/preproc/parser.c | lmwnshn/postgres | 649750d995eb953c505077ac4baa73b243f68002 | [
"PostgreSQL"
] | 6 | 2017-07-13T19:18:34.000Z | 2022-03-28T09:51:09.000Z | /*-------------------------------------------------------------------------
*
* parser.c
* Main entry point/driver for PostgreSQL grammar
*
* This should match src/backend/parser/parser.c, except that we do not
* need to bother with re-entrant interfaces.
*
* Note: ECPG doesn't report error location like the backend does.
* This file will need work if we ever want it to.
*
*
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* src/interfaces/ecpg/preproc/parser.c
*
*-------------------------------------------------------------------------
*/
#include "postgres_fe.h"
#include "preproc_extern.h"
#include "preproc.h"
static bool have_lookahead; /* is lookahead info valid? */
static int lookahead_token; /* one-token lookahead */
static YYSTYPE lookahead_yylval; /* yylval for lookahead token */
static YYLTYPE lookahead_yylloc; /* yylloc for lookahead token */
static char *lookahead_yytext; /* start current token */
static bool check_uescapechar(unsigned char escape);
static bool ecpg_isspace(char ch);
/*
* Intermediate filter between parser and base lexer (base_yylex in scan.l).
*
* This filter is needed because in some cases the standard SQL grammar
* requires more than one token lookahead. We reduce these cases to one-token
* lookahead by replacing tokens here, in order to keep the grammar LALR(1).
*
* Using a filter is simpler than trying to recognize multiword tokens
* directly in scan.l, because we'd have to allow for comments between the
* words. Furthermore it's not clear how to do that without re-introducing
* scanner backtrack, which would cost more performance than this filter
* layer does.
*
* We also use this filter to convert UIDENT and USCONST sequences into
* plain IDENT and SCONST tokens. While that could be handled by additional
* productions in the main grammar, it's more efficient to do it like this.
*/
int
filtered_base_yylex(void)
{
int cur_token;
int next_token;
YYSTYPE cur_yylval;
YYLTYPE cur_yylloc;
char *cur_yytext;
/* Get next token --- we might already have it */
if (have_lookahead)
{
cur_token = lookahead_token;
base_yylval = lookahead_yylval;
base_yylloc = lookahead_yylloc;
base_yytext = lookahead_yytext;
have_lookahead = false;
}
else
cur_token = base_yylex();
/*
* If this token isn't one that requires lookahead, just return it.
*/
switch (cur_token)
{
case NOT:
case NULLS_P:
case WITH:
case UIDENT:
case USCONST:
break;
default:
return cur_token;
}
/* Save and restore lexer output variables around the call */
cur_yylval = base_yylval;
cur_yylloc = base_yylloc;
cur_yytext = base_yytext;
/* Get next token, saving outputs into lookahead variables */
next_token = base_yylex();
lookahead_token = next_token;
lookahead_yylval = base_yylval;
lookahead_yylloc = base_yylloc;
lookahead_yytext = base_yytext;
base_yylval = cur_yylval;
base_yylloc = cur_yylloc;
base_yytext = cur_yytext;
have_lookahead = true;
/* Replace cur_token if needed, based on lookahead */
switch (cur_token)
{
case NOT:
/* Replace NOT by NOT_LA if it's followed by BETWEEN, IN, etc */
switch (next_token)
{
case BETWEEN:
case IN_P:
case LIKE:
case ILIKE:
case SIMILAR:
cur_token = NOT_LA;
break;
}
break;
case NULLS_P:
/* Replace NULLS_P by NULLS_LA if it's followed by FIRST or LAST */
switch (next_token)
{
case FIRST_P:
case LAST_P:
cur_token = NULLS_LA;
break;
}
break;
case WITH:
/* Replace WITH by WITH_LA if it's followed by TIME or ORDINALITY */
switch (next_token)
{
case TIME:
case ORDINALITY:
cur_token = WITH_LA;
break;
}
break;
case UIDENT:
case USCONST:
/* Look ahead for UESCAPE */
if (next_token == UESCAPE)
{
/* Yup, so get third token, which had better be SCONST */
const char *escstr;
/*
* Again save and restore lexer output variables around the
* call
*/
cur_yylval = base_yylval;
cur_yylloc = base_yylloc;
cur_yytext = base_yytext;
/* Get third token */
next_token = base_yylex();
if (next_token != SCONST)
mmerror(PARSE_ERROR, ET_ERROR, "UESCAPE must be followed by a simple string literal");
/*
* Save and check escape string, which the scanner returns
* with quotes
*/
escstr = base_yylval.str;
if (strlen(escstr) != 3 || !check_uescapechar(escstr[1]))
mmerror(PARSE_ERROR, ET_ERROR, "invalid Unicode escape character");
base_yylval = cur_yylval;
base_yylloc = cur_yylloc;
base_yytext = cur_yytext;
/* Combine 3 tokens into 1 */
base_yylval.str = psprintf("%s UESCAPE %s", base_yylval.str, escstr);
/* Clear have_lookahead, thereby consuming all three tokens */
have_lookahead = false;
}
if (cur_token == UIDENT)
cur_token = IDENT;
else if (cur_token == USCONST)
cur_token = SCONST;
break;
}
return cur_token;
}
/*
* check_uescapechar() and ecpg_isspace() should match their equivalents
* in pgc.l.
*/
/* is 'escape' acceptable as Unicode escape character (UESCAPE syntax) ? */
static bool
check_uescapechar(unsigned char escape)
{
if (isxdigit(escape)
|| escape == '+'
|| escape == '\''
|| escape == '"'
|| ecpg_isspace(escape))
return false;
else
return true;
}
/*
* ecpg_isspace() --- return true if flex scanner considers char whitespace
*/
static bool
ecpg_isspace(char ch)
{
if (ch == ' ' ||
ch == '\t' ||
ch == '\n' ||
ch == '\r' ||
ch == '\f')
return true;
return false;
}
| 24.560345 | 91 | 0.668305 |
a2f19f96a37f1531a2f8bae7016e8d01f623c950 | 515 | h | C | Assets/header/WCDBConfigPerformance.h | NuolanNuolan/IPAPatch-master | 0f1821950c9b26d504c73681673901b8efa1e44c | [
"MIT"
] | 5 | 2017-09-21T06:56:18.000Z | 2021-01-02T22:15:23.000Z | Assets/header/WCDBConfigPerformance.h | NuolanNuolan/IPAPatch-master | 0f1821950c9b26d504c73681673901b8efa1e44c | [
"MIT"
] | null | null | null | Assets/header/WCDBConfigPerformance.h | NuolanNuolan/IPAPatch-master | 0f1821950c9b26d504c73681673901b8efa1e44c | [
"MIT"
] | 5 | 2017-11-14T03:18:42.000Z | 2019-12-30T03:09:35.000Z | //
// Generated by class-dump 3.5 (64 bit) (Debug version compiled Mar 29 2017 23:22:24).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard.
//
#import <objc/NSObject.h>
@interface WCDBConfigPerformance : NSObject
{
_Bool m_report;
int m_count;
}
+ (void)initialize;
@property(nonatomic) int m_count; // @synthesize m_count;
@property(nonatomic) _Bool m_report; // @synthesize m_report;
- (const map_0e718273 *)getValueTagIndexMap;
- (id)getValueTypeTable;
@end
| 22.391304 | 90 | 0.706796 |
a2f213a50c3e7b40ad3730933ce8e764b600bb72 | 1,187 | h | C | src/xrGame/ui/UIServerInfo.h | clayne/xray-16 | 32ebf81a252c7179e2824b2874f911a91e822ad1 | [
"OML",
"Linux-OpenIB"
] | 2 | 2015-02-23T10:43:02.000Z | 2015-06-11T14:45:08.000Z | src/xrGame/ui/UIServerInfo.h | clayne/xray-16 | 32ebf81a252c7179e2824b2874f911a91e822ad1 | [
"OML",
"Linux-OpenIB"
] | 17 | 2022-01-25T08:58:23.000Z | 2022-03-28T17:18:28.000Z | src/xrGame/ui/UIServerInfo.h | clayne/xray-16 | 32ebf81a252c7179e2824b2874f911a91e822ad1 | [
"OML",
"Linux-OpenIB"
] | 1 | 2015-06-05T20:04:00.000Z | 2015-06-05T20:04:00.000Z | #ifndef UISERVER_INFO_INCLUDED
#define UISERVER_INFO_INCLUDED
#include "UIDialogWnd.h"
#include "xrUICore/Callbacks/UIWndCallback.h"
class CUIStatic;
class CUIScrollView;
class CUI3tButton;
class CUI3tButton;
class CUITextWnd;
class CUIServerInfo : public CUIDialogWnd, public CUIWndCallback
{
public:
CUIServerInfo();
virtual ~CUIServerInfo();
virtual void SendMessage(CUIWindow* pWnd, s16 msg, void* pData = NULL);
void Init();
void SetServerLogo(u8 const* data_ptr, u32 const data_size);
void SetServerRules(u8 const* data_ptr, u32 const data_size);
bool HasInfo() { return m_dds_file_created; };
virtual bool OnKeyboardAction(int dik, EUIMessages keyboard_action);
private:
void InitCallbacks();
void OnSpectatorBtnClick(CUIWindow* w, void* d);
void OnNextBtnClick(CUIWindow* w, void* d);
static char const* tmp_logo_file_name;
bool m_dds_file_created;
CUIStatic* m_caption;
CUIStatic* m_background;
CUIScrollView* m_text_desc;
CUITextWnd* m_text_body;
CUIStatic* m_image;
CUI3tButton* m_btn_spectator;
CUI3tButton* m_btn_next;
}; // class CUIServerInfo
#endif //#ifndef UISERVER_INFO_INCLUDED
| 26.377778 | 75 | 0.749789 |
a2f37297ff20a3f1008e42e5f47550371a3be227 | 291 | h | C | KidsTC/KidsTC/Business/Main/Article/ArticleUserCenter/ArticleUserCenterViewController.h | zhpigh/KidsTC_Objective-C | ef095ae4d7fd7c3a69565ba5f0eb44f9e93e40b6 | [
"MIT"
] | null | null | null | KidsTC/KidsTC/Business/Main/Article/ArticleUserCenter/ArticleUserCenterViewController.h | zhpigh/KidsTC_Objective-C | ef095ae4d7fd7c3a69565ba5f0eb44f9e93e40b6 | [
"MIT"
] | null | null | null | KidsTC/KidsTC/Business/Main/Article/ArticleUserCenter/ArticleUserCenterViewController.h | zhpigh/KidsTC_Objective-C | ef095ae4d7fd7c3a69565ba5f0eb44f9e93e40b6 | [
"MIT"
] | 1 | 2018-09-18T07:26:36.000Z | 2018-09-18T07:26:36.000Z | //
// ArticleUserCenterViewController.h
// KidsTC
//
// Created by zhanping on 2016/9/13.
// Copyright © 2016年 zhanping. All rights reserved.
//
#import "ViewController.h"
@interface ArticleUserCenterViewController : ViewController
@property (nonatomic, strong) NSString *userId;
@end
| 20.785714 | 59 | 0.749141 |
a2f3ecd4d4ffdd6d3e2192fbfd942b6dab6cdb83 | 1,825 | h | C | modules/cmake/Source/cmTargetLinkLibrariesCommand.h | reliefs/brominer | b37b7131de16ab199fb4bb56a578cef43f9afc30 | [
"MIT"
] | 1 | 2018-07-23T10:54:50.000Z | 2018-07-23T10:54:50.000Z | cmake/Source/cmTargetLinkLibrariesCommand.h | mygirl8893/modules | 0acff384551043ebbf6337b732d586266cff7026 | [
"MIT"
] | null | null | null | cmake/Source/cmTargetLinkLibrariesCommand.h | mygirl8893/modules | 0acff384551043ebbf6337b732d586266cff7026 | [
"MIT"
] | 1 | 2018-06-04T08:50:33.000Z | 2018-06-04T08:50:33.000Z | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#ifndef cmTargetLinkLibrariesCommand_h
#define cmTargetLinkLibrariesCommand_h
#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
#include <vector>
#include "cmCommand.h"
#include "cmTargetLinkLibraryType.h"
class cmExecutionStatus;
class cmTarget;
/** \class cmTargetLinkLibrariesCommand
* \brief Specify a list of libraries to link into executables.
*
* cmTargetLinkLibrariesCommand is used to specify a list of libraries to link
* into executable(s) or shared objects. The names of the libraries
* should be those defined by the LIBRARY(library) command(s).
*
* Additionally, it allows to propagate usage-requirements (including link
* libraries) from one target into another.
*/
class cmTargetLinkLibrariesCommand : public cmCommand
{
public:
/**
* This is a virtual constructor for the command.
*/
cmCommand* Clone() override { return new cmTargetLinkLibrariesCommand; }
/**
* This is called when the command is first encountered in
* the CMakeLists.txt file.
*/
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
private:
void LinkLibraryTypeSpecifierWarning(int left, int right);
static const char* LinkLibraryTypeNames[3];
cmTarget* Target;
enum ProcessingState
{
ProcessingLinkLibraries,
ProcessingPlainLinkInterface,
ProcessingKeywordLinkInterface,
ProcessingPlainPublicInterface,
ProcessingKeywordPublicInterface,
ProcessingPlainPrivateInterface,
ProcessingKeywordPrivateInterface
};
ProcessingState CurrentProcessingState;
bool HandleLibrary(const std::string& lib, cmTargetLinkLibraryType llt);
};
#endif
| 28.515625 | 78 | 0.762192 |
a2f5651ceb1758c2d7ed8add5a9e5d9fbaba61cb | 14,183 | h | C | platforms/m3/prc_v18/software/include/PRCv18.h | lab11/M-ulator | 95b49c6194678c74accca4a20af71380efbcac5f | [
"Apache-2.0",
"MIT"
] | 19 | 2015-01-26T10:47:23.000Z | 2021-08-13T11:07:54.000Z | platforms/m3/prc_v18/software/include/PRCv18.h | lab11/M-ulator | 95b49c6194678c74accca4a20af71380efbcac5f | [
"Apache-2.0",
"MIT"
] | 14 | 2015-08-24T02:35:46.000Z | 2021-05-05T03:53:44.000Z | platforms/m3/prc_v18/software/include/PRCv18.h | lab11/M-ulator | 95b49c6194678c74accca4a20af71380efbcac5f | [
"Apache-2.0",
"MIT"
] | 9 | 2015-05-27T23:27:35.000Z | 2020-10-05T22:02:43.000Z | //*******************************************************************
//Author: Yejoong Kim
//Description: PRCv18 header file
//*******************************************************************
#ifndef PRCV18_H
#define PRCV18_H
#define PRCv18
//*********************************************************
// Boolean Constants
//*********************************************************
#define TRUE 1
#define FALSE 0
//*********************************************************
// GOC Data Address
//*********************************************************
#define GOC_DATA_IRQ ((volatile uint32_t *) 0x8C)
//*********************************************************
// M0 Interrupts
//---------------------------------------------------------
// NOTE: These values must be consistent with files below:
// vectors.s, PRCv18.v, PRCv18_debug.v
//*********************************************************
#define IRQ_WAKEUP 0
#define IRQ_SOFT_RESET 1
#define IRQ_GOCEP 2
#define IRQ_TIMER32 3
#define IRQ_TIMER16 4
#define IRQ_MBUS_TX 5
#define IRQ_MBUS_RX 6
#define IRQ_MBUS_FWD 7
#define IRQ_REG0 8
#define IRQ_REG1 9
#define IRQ_REG2 10
#define IRQ_REG3 11
#define IRQ_REG4 12
#define IRQ_REG5 13
#define IRQ_REG6 14
#define IRQ_REG7 15
#define IRQ_MBUS_MEM 16
//*********************************************************
// ARMv6 Architecture NVIC Registers
//*********************************************************
#define NVIC_ISER ((volatile uint32_t *) 0xE000E100) // Interrupt Set-Enable Register
#define NVIC_ICER ((volatile uint32_t *) 0xE000E180) // Interrupt Clear-Enable Register
#define NVIC_ISPR ((volatile uint32_t *) 0xE000E200) // Interrupt Set-Pending Register
#define NVIC_ICPR ((volatile uint32_t *) 0xE000E280) // Interrupt Clear-Pending Register
#define NVIC_IPR0 ((volatile uint32_t *) 0xE000E400) // Interrupt Priority Register
#define NVIC_IPR1 ((volatile uint32_t *) 0xE000E404) // Interrupt Priority Register
#define NVIC_IPR2 ((volatile uint32_t *) 0xE000E408) // Interrupt Priority Register
#define NVIC_IPR3 ((volatile uint32_t *) 0xE000E40C) // Interrupt Priority Register
#define NVIC_IPR4 ((volatile uint32_t *) 0xE000E410) // Interrupt Priority Register
#define NVIC_IPR5 ((volatile uint32_t *) 0xE000E414) // Interrupt Priority Register
#define NVIC_IPR6 ((volatile uint32_t *) 0xE000E418) // Interrupt Priority Register
#define NVIC_IPR7 ((volatile uint32_t *) 0xE000E41C) // Interrupt Priority Register
//*********************************************************
// ARMv6 Architecture System Control and ID Registers
//*********************************************************
#define SCID_ACTLR ((volatile uint32_t *) 0xE000E008) // The Auxiliary Control Register
#define SCID_CPUID ((volatile uint32_t *) 0xE000ED00) // CPUID Base Register
#define SCID_ICSR ((volatile uint32_t *) 0xE000ED04) // Interrupt Control State Register
#define SCID_VTOR ((volatile uint32_t *) 0xE000ED08) // Vector Table Offset Register
#define SCID_AIRCR ((volatile uint32_t *) 0xE000ED0C) // Application Interrupt and Reset Control Register
#define SCID_SCR ((volatile uint32_t *) 0xE000ED10) // Optional System Control Register
#define SCID_CCR ((volatile uint32_t *) 0xE000ED14) // Configuration and Control Register
#define SCID_SHPR2 ((volatile uint32_t *) 0xE000ED1C) // System Handler Priority Register 2
#define SCID_SHPR3 ((volatile uint32_t *) 0xE000ED20) // System Handler Priority Register 3
#define SCID_SHCSR ((volatile uint32_t *) 0xE000ED24) // System Handler Control and State Regsiter
#define SCID_DFSR ((volatile uint32_t *) 0xE000ED30) // Debug Fault Status Register
//*********************************************************
// Register File MMIO Addresses
//*********************************************************
#define REG0 ((volatile uint32_t *) 0xA0000000)
#define REG1 ((volatile uint32_t *) 0xA0000004)
#define REG2 ((volatile uint32_t *) 0xA0000008)
#define REG3 ((volatile uint32_t *) 0xA000000C)
#define REG4 ((volatile uint32_t *) 0xA0000010)
#define REG5 ((volatile uint32_t *) 0xA0000014)
#define REG6 ((volatile uint32_t *) 0xA0000018)
#define REG7 ((volatile uint32_t *) 0xA000001C)
#define REG_GOC_CHIP_ID ((volatile uint32_t *) 0xA0000020)
#define REG_MBUS_BITS ((volatile uint32_t *) 0xA0000024)
#define REG_FLAGS ((volatile uint32_t *) 0xA0000028)
#define REG_CLKGEN_TUNE ((volatile uint32_t *) 0xA000002C)
#define REG_PUF_CHIP_ID ((volatile uint32_t *) 0xA0000034)
#define REG_GOC_TIMEOUT ((volatile uint32_t *) 0xA0000038)
#define REG_GOCEP_FLAG ((volatile uint32_t *) 0xA000003C)
#define REG_RUN_CPU ((volatile uint32_t *) 0xA0000040)
#define REG_WUPT_CONFIG ((volatile uint32_t *) 0xA0000044)
#define REG_WUPT_VAL ((volatile uint32_t *) 0xA0000048)
#define REG_SYS_CONF ((volatile uint32_t *) 0xA000006C)
#define REG_SRAM0_TUNE ((volatile uint32_t *) 0xA0000070)
#define REG_MBUS_FLAG ((volatile uint32_t *) 0xA0000078)
#define REG_MBUS_WD ((volatile uint32_t *) 0xA000007C)
#define REG_STR1_BUFL ((volatile uint32_t *) 0xA00000A4)
#define REG_STR1_BUFU ((volatile uint32_t *) 0xA00000A8)
#define REG_STR1_EN ((volatile uint32_t *) 0xA00000AC)
#define REG_STR1_OFF ((volatile uint32_t *) 0xA00000B0)
#define REG_STR0_BUFL ((volatile uint32_t *) 0xA00000B4)
#define REG_STR0_BUFU ((volatile uint32_t *) 0xA00000B8)
#define REG_STR0_EN ((volatile uint32_t *) 0xA00000BC)
#define REG_STR0_OFF ((volatile uint32_t *) 0xA00000C0)
#define REG_BLK_WR ((volatile uint32_t *) 0xA00000CC)
#define REG_CHIP_ID ((volatile uint32_t *) 0xA00000FC)
//*********************************************************
// TIMER16 MMIO Addresses
//*********************************************************
#define TIMER16_GO ((volatile uint32_t *) 0xA0001000)
#define TIMER16_CMP0 ((volatile uint32_t *) 0xA0001004)
#define TIMER16_CMP1 ((volatile uint32_t *) 0xA0001008)
#define TIMER16_IRQEN ((volatile uint32_t *) 0xA000100C)
#define TIMER16_CNT ((volatile uint32_t *) 0xA0001010)
#define TIMER16_STAT ((volatile uint32_t *) 0xA0001014)
//*********************************************************
// TIMER32 MMIO Addresses
//*********************************************************
#define TIMER32_GO ((volatile uint32_t *) 0xA0001100)
#define TIMER32_CMP ((volatile uint32_t *) 0xA0001104)
#define TIMER32_ROI ((volatile uint32_t *) 0xA0001108)
#define TIMER32_CNT ((volatile uint32_t *) 0xA000110C)
#define TIMER32_STAT ((volatile uint32_t *) 0xA0001110)
//*********************************************************
// TIMERWD (Watch-Dog Tiimer) MMIO Addresses
//*********************************************************
#define TIMERWD_GO ((volatile uint32_t *) 0xA0001200)
#define TIMERWD_CNT ((volatile uint32_t *) 0xA0001204)
//*********************************************************
// Wake-Up Timer Reset MMIO Addresses
//*********************************************************
#define WUPT_RESET ((volatile uint32_t *) 0xA0001300)
#define WUPT_VAL ((volatile uint32_t *) 0xA0001300)
//*********************************************************
// MBus Watchdog Timer
//*********************************************************
#define MBCWD_RESET_REQ ((volatile uint32_t *) 0xA0001500)
#define MBCWD_RESET ((volatile uint32_t *) 0xA0001504)
//*********************************************************
// PRC/PREv18 System Registers
//*********************************************************
#define SREG_CONF_HALT ((volatile uint32_t *) 0xA000A000)
#define SREG_MBUS_TX_IRQ ((volatile uint32_t *) 0xA000A004)
#define SREG_WAKEUP_SOURCE ((volatile uint32_t *) 0xA000A008) // Read-Only
//*********************************************************
// PRC/PREv18 System Control
//*********************************************************
#define SCTR_REG_HALT_ADDR ((volatile uint32_t *) 0xAFFFF000)
#define SCTR_REG_RESUME_ADDR ((volatile uint32_t *) 0xAFFFF004)
#define SCTR_REG_CLR_WUP_PEND_REQ ((volatile uint32_t *) 0xAFFFF008)
#define SCTR_REG_CLR_WUP_SOURCE ((volatile uint32_t *) 0xAFFFF00C)
#define SCTR_CMD_HALT_CPU 0xBAADF00D
#define SCTR_CMD_RESUME_CPU 0xCAFEF00D
//*********************************************************
// SREG_CONF_HALT Values
//*********************************************************
#define HALT_UNTIL_REG0 0x0
#define HALT_UNTIL_REG1 0x1
#define HALT_UNTIL_REG2 0x2
#define HALT_UNTIL_REG3 0x3
#define HALT_UNTIL_REG4 0x4
#define HALT_UNTIL_REG5 0x5
#define HALT_UNTIL_REG6 0x6
#define HALT_UNTIL_REG7 0x7
#define HALT_UNTIL_MEM_WR 0x8
#define HALT_UNTIL_MBUS_TX 0x9
#define HALT_UNTIL_MBUS_RX 0xA
#define HALT_UNTIL_MBUS_FWD 0xB
#define HALT_UNTIL_MBUS_TRX 0xC
#define HALT_DISABLE 0xF
//*********************************************************
// INCLUDES...
//*********************************************************
#include <stdint.h>
#include <stdbool.h>
#include "PRCv18_RF.h"
//*********************************************************
// FUNCTIONS
//*********************************************************
/**
* @brief Insert 'nop's
*
* @param ticks Num of 'nop's to be inserted. The actual idle time would be 2*ticks cycles due to the 'for' loop.
*
* @usage delay(100);
*/
void delay(unsigned ticks);
/**
* @brief Wait for interrupt
*
* @param N/A
*
* @usage WFI();
*/
void WFI();
/**
* @brief Enable all interrupts
*
* @param N/A
*
* @usage enable_all_irq();
*/
void enable_all_irq();
/**
* @brief Disable all interrupts
*
* @param N/A
*
* @usage disable_all_irq();
*/
void disable_all_irq();
/**
* @brief Clear all pending interrupts
*
* @param N/A
*
* @usage clear_all_pend_irq();
*/
void clear_all_pend_irq();
/**
* @brief Set flag
*
* @param bit_idx bit index into which the value is written
* value flag value
*
* @usage set_flag(0, 1);
*/
uint32_t set_flag(uint32_t bit_idx, uint32_t value);
/**
* @brief Get flag
*
* @param bit_idx bit index in Flag Register to read
*
* @usage get_flag(0);
*/
uint8_t get_flag(uint32_t bit_idx);
/**
* @brief Set a new SREG_CONF_HALT value
*
* @param new_config 4-bit SREG_CONF_HALT value
*
* @usage set_halt_config(0x9);
* set_halt_config(HALT_UNTIL_MBUS_RX);
*/
void set_halt_config(uint8_t new_config);
/**
* @brief Return the current SREG_CONF_HALT value
*
* @param N/A
*
* @usage uint8_t current_halt_cpu_setting = get_current_halt_config();
*/
uint8_t get_current_halt_config(void);
/**
* @brief This configures SREG_CONF_HALT like below:
* SREG_CONF_HALT = reg_id;
*
* @param reg_id 8-bit Register interrupt masking pattern
*
* @usage set_halt_until_reg(0xF0);
*/
void set_halt_until_reg(uint32_t reg_id);
/**
* @brief This configures SREG_CONF_HALT like below:
* SREG_CONF_HALT = HALT_UNTIL_MEM_WR;
*
* @param N/A
*
* @usage set_halt_until_mem_wr();
*/
void set_halt_until_mem_wr(void);
/**
* @brief This configures SREG_CONF_HALT like below:
* SREG_CONF_HALT = HALT_UNTIL_MBUS_RX;
*
* @param N/A
*
* @usage set_halt_until_mbus_rx();
*/
void set_halt_until_mbus_rx(void);
/**
* @brief This configures SREG_CONF_HALT like below:
* SREG_CONF_HALT = HALT_UNTIL_MBUS_TX;
*
* @param N/A
*
* @usage set_halt_until_mbus_tx();
*/
void set_halt_until_mbus_tx(void);
/**
* @brief This configures SREG_CONF_HALT like below:
* SREG_CONF_HALT = HALT_UNTIL_MBUS_TRX;
*
* @param N/A
*
* @usage set_halt_until_mbus_trx();
*/
void set_halt_until_mbus_trx(void);
/**
* @brief This configures SREG_CONF_HALT like below:
* SREG_CONF_HALT = HALT_UNTIL_MBUS_FWD;
*
* @param N/A
*
* @usage set_halt_until_mbus_fwd();
*/
void set_halt_until_mbus_fwd(void);
/**
* @brief This configures SREG_CONF_HALT like below:
* SREG_CONF_HALT = HALT_DISABLE;
*
* @param N/A
*
* @usage set_halt_disable();
*/
void set_halt_disable(void);
/**
* @brief Immediately put CPU in halt. CPU resumes its operation when the event specifiedin SREG_CONF_HALT occurs.
*
* @param N/A
*
* @usage halt_cpu();
*/
void halt_cpu(void);
/**
* @brief Configure the 16-bit timer
*
* @param cmp0 Number0 to compare
* @param cmp1 Number1 to compare
* @param irq_en Interrupt Enable
* @param cnt Manually set the timer counter
* @param status Manually set the timer status
*/
void config_timer16(uint32_t cmp0, uint32_t cmp1, uint8_t irq_en, uint32_t cnt, uint32_t status);
/**
* @brief Configure the 32-bit timer
*
* @param cmp Number0 to compare
* @param roi Reset on Interrupt
* @param cnt Manually set the timer counter
* @param status Manually set the timer status
*/
void config_timer32(uint32_t cmp, uint8_t roi, uint32_t cnt, uint32_t status);
/**
* @brief Configure the Watch-Dog timer
*
* @param cnt Manually set the timer counter
*/
void config_timerwd(uint32_t cnt);
/**
* @brief Disables the Watch-Dog timer
*
*/
void disable_timerwd();
/**
* @brief Configure the wake-up timer
*
* @param timestamp Counter value at which the timer generates an interrupt
* @param irq_en Interrupt Enable
* @param reset 1 will reset the wake-up timer
*/
void set_wakeup_timer( uint32_t timestamp, uint8_t irq_en, uint8_t reset );
/**
* @brief Write into ARB debug register
* !!! THIS IS FOR VERILOG SIM ONLY !!!
*
* @param id debug id (informational use only)
* code debug code (informational use only)
*/
void arb_debug_reg (uint8_t id, uint32_t code);
#endif // PRCV18_H
| 32.755196 | 121 | 0.590425 |
a2f5f5f4bf9a5d2558f80cc0825644cd14e67379 | 2,622 | h | C | src/ram/Conjunction.h | hyunsukimsokcho/souffle | 3a60ce40455f38ded069d28de8405236b94529ed | [
"UPL-1.0"
] | null | null | null | src/ram/Conjunction.h | hyunsukimsokcho/souffle | 3a60ce40455f38ded069d28de8405236b94529ed | [
"UPL-1.0"
] | null | null | null | src/ram/Conjunction.h | hyunsukimsokcho/souffle | 3a60ce40455f38ded069d28de8405236b94529ed | [
"UPL-1.0"
] | null | null | null | /*
* Souffle - A Datalog Compiler
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved
* Licensed under the Universal Permissive License v 1.0 as shown at:
* - https://opensource.org/licenses/UPL
* - <souffle root>/licenses/SOUFFLE-UPL.txt
*/
/************************************************************************
*
* @file Conjunction.h
*
* Defines a class for evaluating conditions in the Relational Algebra
* Machine.
*
***********************************************************************/
#pragma once
#include "ram/Condition.h"
#include "ram/Node.h"
#include "ram/NodeMapper.h"
#include "utility/ContainerUtil.h"
#include "utility/MiscUtil.h"
#include <cassert>
#include <memory>
#include <sstream>
#include <utility>
#include <vector>
namespace souffle {
/**
* @class RamConjunction
* @brief A conjunction of conditions
*
* Condition of the form "LHS and RHS", where LHS
* and RHS are conditions
*
* For example:
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~
* C1 AND C2 AND C3
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Is a RamConjunction, which may have LHS "C1"
* and RHS "C2 AND C3"
*/
class RamConjunction : public RamCondition {
public:
RamConjunction(std::unique_ptr<RamCondition> l, std::unique_ptr<RamCondition> r)
: lhs(std::move(l)), rhs(std::move(r)) {
assert(lhs != nullptr && "left-hand side of conjunction is a nullptr");
assert(rhs != nullptr && "right-hand side of conjunction is a nullptr");
}
/** @brief Get left-hand side of conjunction */
const RamCondition& getLHS() const {
return *lhs;
}
/** @brief Get right-hand side of conjunction */
const RamCondition& getRHS() const {
return *rhs;
}
std::vector<const RamNode*> getChildNodes() const override {
return {lhs.get(), rhs.get()};
}
RamConjunction* clone() const override {
return new RamConjunction(souffle::clone(lhs), souffle::clone(rhs));
}
void apply(const RamNodeMapper& map) override {
lhs = map(std::move(lhs));
rhs = map(std::move(rhs));
}
protected:
void print(std::ostream& os) const override {
os << "(" << *lhs << " AND " << *rhs << ")";
}
bool equal(const RamNode& node) const override {
const auto& other = static_cast<const RamConjunction&>(node);
return equal_ptr(lhs, other.lhs) && equal_ptr(rhs, other.rhs);
}
/** Left-hand side of conjunction */
std::unique_ptr<RamCondition> lhs;
/** Right-hand side of conjunction */
std::unique_ptr<RamCondition> rhs;
};
} // end of namespace souffle
| 27.3125 | 84 | 0.594584 |
a2f651d0655dec455f2649b1db3d047739d8db57 | 12,394 | h | C | 3rdParty/DirectFB/lib/voodoo/message.h | rohmer/LVGL_UI_Creator | 37a19be55e1de95d56717786a27506d8c78fd1ae | [
"MIT"
] | 33 | 2019-09-17T20:57:56.000Z | 2021-11-20T21:50:51.000Z | 3rdParty/DirectFB/lib/voodoo/message.h | rohmer/LVGL_UI_Creator | 37a19be55e1de95d56717786a27506d8c78fd1ae | [
"MIT"
] | 4 | 2019-10-21T08:38:11.000Z | 2021-11-17T16:53:08.000Z | 3rdParty/DirectFB/lib/voodoo/message.h | rohmer/LVGL_UI_Creator | 37a19be55e1de95d56717786a27506d8c78fd1ae | [
"MIT"
] | 16 | 2019-09-25T04:25:04.000Z | 2022-03-28T07:46:18.000Z | /*
(c) Copyright 2012-2013 DirectFB integrated media GmbH
(c) Copyright 2001-2013 The world wide DirectFB Open Source Community (directfb.org)
(c) Copyright 2000-2004 Convergence (integrated media) GmbH
All rights reserved.
Written by Denis Oliver Kropp <dok@directfb.org>,
Andreas Shimokawa <andi@directfb.org>,
Marek Pikarski <mass@directfb.org>,
Sven Neumann <neo@directfb.org>,
Ville Syrjälä <syrjala@sci.fi> and
Claudio Ciccani <klan@users.sf.net>.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __VOODOO__MESSAGE_H__
#define __VOODOO__MESSAGE_H__
#include <voodoo/types.h>
#include <direct/debug.h>
#include <direct/memcpy.h>
#define VOODOO_MSG_ALIGN(i) (((i) + 3) & ~3)
typedef enum {
VMBT_NONE,
VMBT_ID,
VMBT_INT,
VMBT_UINT,
VMBT_DATA,
VMBT_ODATA,
VMBT_STRING
} VoodooMessageBlockType;
typedef enum {
VREQ_NONE = 0x00000000,
VREQ_RESPOND = 0x00000001,
VREQ_ASYNC = 0x00000002,
VREQ_QUEUE = 0x00000004
} VoodooRequestFlags;
typedef enum {
VMSG_SUPER,
VMSG_REQUEST,
VMSG_RESPONSE,
VMSG_DISCOVER, // temporary solution for compatibility
VMSG_SENDINFO, // temporary solution for compatibility
} VoodooMessageType;
struct __V_VoodooMessageHeader {
int size;
VoodooMessageSerial serial;
VoodooMessageType type;
};
struct __V_VoodooSuperMessage {
VoodooMessageHeader header;
};
struct __V_VoodooRequestMessage {
VoodooMessageHeader header;
VoodooInstanceID instance;
VoodooMethodID method;
VoodooRequestFlags flags;
};
struct __V_VoodooResponseMessage {
VoodooMessageHeader header;
VoodooMessageSerial request;
DirectResult result;
VoodooInstanceID instance;
};
typedef struct {
int magic;
const char *msg;
const char *ptr;
} VoodooMessageParser;
#define __VOODOO_PARSER_PROLOG( parser, req_type ) \
const char *_vp_ptr; \
VoodooMessageBlockType _vp_type; \
int _vp_length; \
VoodooMessageParser *_parser = &parser; \
\
D_MAGIC_ASSERT( _parser, VoodooMessageParser ); \
\
(void)_vp_type; \
\
_vp_ptr = _parser->ptr; \
\
/* Read message block type. */ \
_vp_type = *(const VoodooMessageBlockType*) _vp_ptr; \
\
D_ASSERT( _vp_type == (req_type) ); \
\
/* Read data block length. */ \
_vp_length = *(const s32*) (_vp_ptr + 4)
#define __VOODOO_PARSER_EPILOG( parser ) \
/* Advance message data pointer. */ \
_parser->ptr += 8 + VOODOO_MSG_ALIGN(_vp_length)
#define VOODOO_PARSER_BEGIN( parser, message ) \
do { \
const VoodooMessageHeader *_vp_header = (const VoodooMessageHeader *) (message); \
VoodooMessageParser *_parser = &parser; \
\
D_ASSERT( (message) != NULL ); \
D_ASSERT( _vp_header->type == VMSG_REQUEST || _vp_header->type == VMSG_RESPONSE ); \
\
_parser->msg = (const char*)(message); \
_parser->ptr = _parser->msg + (_vp_header->type == VMSG_REQUEST ? \
sizeof(VoodooRequestMessage) : sizeof(VoodooResponseMessage)); \
\
D_MAGIC_SET_ONLY( _parser, VoodooMessageParser ); \
} while (0)
#define VOODOO_PARSER_GET_ID( parser, ret_id ) \
do { \
__VOODOO_PARSER_PROLOG( parser, VMBT_ID ); \
\
D_ASSERT( _vp_length == 4 ); \
\
/* Read the ID. */ \
(ret_id) = *(const u32*) (_vp_ptr + 8); \
\
__VOODOO_PARSER_EPILOG( parser ); \
} while (0)
#define VOODOO_PARSER_GET_INT( parser, ret_int ) \
do { \
__VOODOO_PARSER_PROLOG( parser, VMBT_INT ); \
\
D_ASSERT( _vp_length == 4 ); \
\
/* Read the integer. */ \
(ret_int) = *(const s32*) (_vp_ptr + 8); \
\
__VOODOO_PARSER_EPILOG( parser ); \
} while (0)
#define VOODOO_PARSER_GET_UINT( parser, ret_uint ) \
do { \
__VOODOO_PARSER_PROLOG( parser, VMBT_UINT ); \
\
D_ASSERT( _vp_length == 4 ); \
\
/* Read the unsigned integer. */ \
(ret_uint) = *(const u32*) (_vp_ptr + 8); \
\
__VOODOO_PARSER_EPILOG( parser ); \
} while (0)
#define VOODOO_PARSER_GET_DATA( parser, ret_data ) \
do { \
__VOODOO_PARSER_PROLOG( parser, VMBT_DATA ); \
\
/*D_ASSERT( _vp_length > 0 );*/ \
\
/* Return pointer to data. */ \
(ret_data) = (__typeof__(ret_data))(_vp_ptr + 8); \
\
__VOODOO_PARSER_EPILOG( parser ); \
} while (0)
#define VOODOO_PARSER_READ_DATA( parser, dst, max_len ) \
do { \
__VOODOO_PARSER_PROLOG( parser, VMBT_DATA ); \
\
/*D_ASSERT( _vp_length > 0 );*/ \
D_ASSERT( _vp_length <= max_len ); \
\
/* Copy data block. */ \
direct_memcpy( (dst), _vp_ptr + 8, _vp_length ); \
\
__VOODOO_PARSER_EPILOG( parser ); \
} while (0)
#define VOODOO_PARSER_COPY_DATA( parser, ret_data ) \
do { \
__VOODOO_PARSER_PROLOG( parser, VMBT_DATA ); \
\
/*D_ASSERT( _vp_length > 0 );*/ \
\
/* Allocate memory on the stack. */ \
(ret_data) = alloca( _vp_length ); \
\
/* Copy data block. */ \
direct_memcpy( (ret_data), _vp_ptr + 8, _vp_length ); \
\
__VOODOO_PARSER_EPILOG( parser ); \
} while (0)
#define VOODOO_PARSER_GET_ODATA( parser, ret_data ) \
do { \
__VOODOO_PARSER_PROLOG( parser, VMBT_ODATA ); \
\
D_ASSERT( _vp_length >= 0 ); \
\
/* Return pointer to data or NULL. */ \
if (_vp_length) \
(ret_data) = (__typeof__(ret_data))(_vp_ptr + 8); \
else \
(ret_data) = NULL; \
\
__VOODOO_PARSER_EPILOG( parser ); \
} while (0)
#define VOODOO_PARSER_GET_STRING( parser, ret_string ) \
do { \
__VOODOO_PARSER_PROLOG( parser, VMBT_STRING ); \
\
D_ASSERT( _vp_length > 0 ); \
\
/* Return pointer to string. */ \
(ret_string) = (const char*) (_vp_ptr + 8); \
\
__VOODOO_PARSER_EPILOG( parser ); \
} while (0)
#define VOODOO_PARSER_END( parser ) \
do { \
VoodooMessageParser *_parser = &parser; \
\
D_MAGIC_ASSERT( _parser, VoodooMessageParser ); \
\
D_ASSUME( *(const u32*) (_parser->ptr) == VMBT_NONE ); \
\
D_MAGIC_CLEAR( _parser ); \
} while (0)
#endif
| 46.074349 | 96 | 0.354446 |
a2f68afbc3ef9dd0aeb0378cdca18e8d0d5d2e07 | 4,488 | h | C | tools-src/gnu/gcc/gcc/config/dsp16xx/dsp16xx-protos.h | enfoTek/tomato.linksys.e2000.nvram-mod | 2ce3a5217def49d6df7348522e2bfda702b56029 | [
"FSFAP"
] | 80 | 2015-01-02T10:14:04.000Z | 2021-06-07T06:29:49.000Z | tools-src/gnu/gcc/gcc/config/dsp16xx/dsp16xx-protos.h | unforgiven512/tomato | 96f09fab4929c6ddde5c9113f1b2476ad37133c4 | [
"FSFAP"
] | 9 | 2015-05-14T11:03:12.000Z | 2018-01-04T07:12:58.000Z | tools-src/gnu/gcc/gcc/config/dsp16xx/dsp16xx-protos.h | unforgiven512/tomato | 96f09fab4929c6ddde5c9113f1b2476ad37133c4 | [
"FSFAP"
] | 69 | 2015-01-02T10:45:56.000Z | 2021-09-06T07:52:13.000Z | /* Definitions of target machine for GNU compiler. AT&T DSP1600.
Copyright (C) 2000 Free Software Foundation, Inc.
Contributed by Michael Collison (collison@world.std.com).
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC 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 GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifdef RTX_CODE
extern struct rtx_def *gen_compare_reg PARAMS ((enum rtx_code, rtx, rtx));
extern int call_address_operand PARAMS ((rtx, enum machine_mode));
extern int arith_reg_operand PARAMS ((rtx, enum machine_mode));
extern int symbolic_address_operand PARAMS ((rtx, enum machine_mode));
extern int Y_address_operand PARAMS ((rtx, enum machine_mode));
extern int sp_operand PARAMS ((rtx, enum machine_mode));
extern int sp_operand2 PARAMS ((rtx, enum machine_mode));
extern int nonmemory_arith_operand PARAMS ((rtx, enum machine_mode));
extern int dsp16xx_comparison_operator PARAMS ((rtx, enum machine_mode));
extern int unx_comparison_operator PARAMS ((rtx, enum machine_mode));
extern int signed_comparison_operator PARAMS ((rtx, enum machine_mode));
extern void notice_update_cc PARAMS ((rtx));
extern void double_reg_from_memory PARAMS ((rtx[]));
extern void double_reg_to_memory PARAMS ((rtx[]));
extern enum rtx_code next_cc_user_code PARAMS ((rtx));
extern int next_cc_user_unsigned PARAMS ((rtx));
extern struct rtx_def *gen_tst_reg PARAMS ((rtx));
extern const char *output_block_move PARAMS ((rtx[]));
extern enum reg_class preferred_reload_class PARAMS ((rtx, enum reg_class));
extern enum reg_class secondary_reload_class PARAMS ((enum reg_class,
enum machine_mode, rtx));
extern int emit_move_sequence PARAMS ((rtx *, enum machine_mode));
extern void print_operand PARAMS ((FILE *, rtx, int));
extern void print_operand_address PARAMS ((FILE *, rtx));
extern void output_dsp16xx_float_const PARAMS ((rtx *));
extern void emit_1600_core_shift PARAMS ((enum rtx_code, rtx *, int));
extern int dsp16xx_address_cost PARAMS ((rtx));
extern int symbolic_address_p PARAMS ((rtx));
extern int uns_comparison_operator PARAMS ((rtx, enum machine_mode));
#endif /* RTX_CODE */
#ifdef TREE_CODE
extern struct rtx_def *dsp16xx_function_arg PARAMS ((CUMULATIVE_ARGS,
enum machine_mode,
tree, int));
extern void dsp16xx_function_arg_advance PARAMS ((CUMULATIVE_ARGS *,
enum machine_mode,
tree, int));
#endif /* TREE_CODE */
extern void dsp16xx_invalid_register_for_compare PARAMS ((void));
extern int class_max_nregs PARAMS ((enum reg_class, enum machine_mode));
extern enum reg_class limit_reload_class PARAMS ((enum reg_class, enum machine_mode));
extern int dsp16xx_register_move_cost PARAMS ((enum reg_class, enum reg_class));
extern int dsp16xx_makes_calls PARAMS ((void));
extern long compute_frame_size PARAMS ((int));
extern int dsp16xx_call_saved_register PARAMS ((int));
extern int dsp16xx_call_saved_register PARAMS ((int));
extern void init_emulation_routines PARAMS ((void));
extern int ybase_regs_ever_used PARAMS ((void));
extern void override_options PARAMS ((void));
extern int dsp16xx_starting_frame_offset PARAMS ((void));
extern int initial_frame_pointer_offset PARAMS ((void));
extern void asm_output_common PARAMS ((FILE *, const char *, int, int));
extern void asm_output_local PARAMS ((FILE *, const char *, int, int));
extern void asm_output_float PARAMS ((FILE *, double));
extern void dsp16xx_file_start PARAMS ((void));
extern void coff_dsp16xx_file_start PARAMS ((FILE *));
extern void luxworks_dsp16xx_file_start PARAMS ((FILE *));
extern struct rtx_def *(*dsp16xx_compare_gen) PARAMS (());
extern int hard_regno_mode_ok PARAMS ((int, enum machine_mode));
extern enum reg_class dsp16xx_reg_class_from_letter PARAMS ((int));
extern int regno_reg_class PARAMS ((int));
extern void function_prologue PARAMS ((FILE *, int));
extern void function_epilogue PARAMS ((FILE *, int));
extern int num_1600_core_shifts PARAMS ((int));
| 49.318681 | 86 | 0.777184 |
a2f791350fd43306db32b0e8c69bb25a48fd83de | 3,627 | h | C | SRC/vbMultimedia/vbGraphicObject.h | GlisGames/vbEngine | 239659e154c08d1867418e611891a7961dbe8258 | [
"MIT"
] | null | null | null | SRC/vbMultimedia/vbGraphicObject.h | GlisGames/vbEngine | 239659e154c08d1867418e611891a7961dbe8258 | [
"MIT"
] | null | null | null | SRC/vbMultimedia/vbGraphicObject.h | GlisGames/vbEngine | 239659e154c08d1867418e611891a7961dbe8258 | [
"MIT"
] | null | null | null | #ifndef VBGRAPHICOBJECT_H
#define VBGRAPHICOBJECT_H
#include "basetypes.h"
#include "vbLivingObject.h"
#include "vbTween.h"
enum gObjectType
{
TYPE_NONE = 0,
TYPE_TEXTURE = 0x1,
TYPE_CONTAINER = 0x2,
TYPE_SEQUENCE = 0x4,
TYPE_TEXT = 0x8,
TYPE_LIVING_OBJECT = 0x10,
// TYPE_TEXT_ALFONS = 0x20,
};
enum class posRule
{
POS_ABSOLUTE = 0,
POS_CANVAS_RELATIVE = 1,
POS_PIVOT_RELATIVE = 2
};
enum class transformRegRule
{
REG_TOP_LEFT = 0,
REG_CENTER = 1,
REG_POINT = 2
};
class vbContainer;
class vbGraphicObject;
class styleElement;
class gObjectList : public std::vector<vbGraphicObject*> //std::map<std::string, vbGraphicObject*>
{
private:
public:
gObjectList()
{
this->owner = NULL;
}
BOOL toSort = TRUE;
std::map<std::string, vbGraphicObject*> goMap;
vbContainer* owner = NULL;
gObjectList::iterator findit(vbGraphicObject* o);
void removeit(vbGraphicObject* o);
void sortMe();
};
typedef gObjectList::iterator gObjectIndex;
class vbProperties
{
public:
float scale = 1.0f;
float rotation = 0.0f;
Vector2 position = { 0,0 };
WORD width = 0;
WORD height = 0;
Color colour = WHITE;
BOOL visible = TRUE;
BOOL canBeClicked = TRUE;
};
class vbGraphicObject: public vbGameObject, public vbProperties
{
private:
Vector2 _calculateAbsolutePosition();
// Layers get printed from the smallest to the highest
// means that layer 0 is printer on the back of layer 1
// layer with the highest value gets printed on top
// NOTE:
// The draw() function gets called from the smalles layer to the highest
// The update() function gets called from the highest to the smallest
int layer = 0;
BOOL _isClicked = FALSE;
BOOL _isMouseDown = FALSE;
public:
vbGraphicObject();
~vbGraphicObject();
vbProperties transformed;
virtual void setup();
virtual void update();
virtual void draw();
//properties transformed;
void sendToBack();
void moveToFront();
void sendBackwards();
void moveForward();
void setLayer(WORD l);
void applyStyle(styleElement* prop);
vbTweenMap tweens;
vbTween* addtween(const char* name, vbTween tw) { return this->tweens.addtween(name, tw); };
std::string name;
Vector2 getAbsolutePosition();
WORD getLayer();
BOOL inheritTransformations = TRUE;
Vector2 pivot = { 0,0 };
BOOL useCenterCoordinates = FALSE; //the printing coordinates are refered to the center of the image rather than the top left
posRule positioningRule = posRule::POS_ABSOLUTE;
transformRegRule regPointRule = transformRegRule::REG_CENTER;
Color fallbackColour = WHITE; //colour to be restored in case of changes
BOOL debugBox = FALSE;
gObjectType type = TYPE_NONE;
gObjectList *parentList = NULL;
class vbContainer* parentContainer = NULL; //forward declaration
void setParams(Vector2 position, WORD rotation, BYTE zoom, Color tint);
bool operator < (const vbGraphicObject& str) const
{
return (layer < str.layer);
}
bool operator > (const vbGraphicObject& str) const
{
return (layer > str.layer);
}
bool operator < (const vbGraphicObject* str) const
{
return (layer < str->layer);
}
bool operator > (const vbGraphicObject* str) const
{
return (layer > str->layer);
}
struct minLayer
{
inline bool operator() (const vbGraphicObject* s1, const vbGraphicObject* s2)
{
return ((s1->layer) > s2->layer);
}
};
void setClick(BOOL on)
{
this->_isClicked = on;
}
void setMouseDown(BOOL on)
{
this->_isMouseDown = on;
}
BOOL isClickable = FALSE;
BOOL isClicked();
BOOL isMouseDown();
BOOL isMouseOver();
vbGraphicObject* getChild(const char* sname);
vbGraphicObject* getObject(const char* sname);
};
#endif // !VBGRAPHICOBJECT_H | 22.955696 | 126 | 0.727874 |
a2f7da7f7fb5043653604c259cbc319796233b43 | 344 | h | C | Example/YXKit/Test.h | GImperialSeal/YXKit | ec0907462342c49205eae13f161a0892fd60e656 | [
"MIT"
] | null | null | null | Example/YXKit/Test.h | GImperialSeal/YXKit | ec0907462342c49205eae13f161a0892fd60e656 | [
"MIT"
] | null | null | null | Example/YXKit/Test.h | GImperialSeal/YXKit | ec0907462342c49205eae13f161a0892fd60e656 | [
"MIT"
] | null | null | null | //
// Test.h
// YXKit_Example
//
// Created by 顾玉玺 on 2019/1/9.
// Copyright © 2019年 18637780521@163.com. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface Test : NSObject
@property (nonatomic) short a;
@property (nonatomic) long c;
@property (nonatomic) short b;
@end
NS_ASSUME_NONNULL_END
| 15.636364 | 63 | 0.723837 |
a2f88038200b70e874d09362f2f3917f576979e9 | 296 | h | C | MMsgDistributeDemo/MMsgDistributeDemo/MTestObject.h | tiantiankaixin/MBlogDemo | 939852f505e1ee39468359388926f30e4617f827 | [
"MIT"
] | 5 | 2020-06-04T07:26:36.000Z | 2021-12-08T08:59:09.000Z | MMsgDistributeDemo/MMsgDistributeDemo/MTestObject.h | tiantiankaixin/MBlogDemo | 939852f505e1ee39468359388926f30e4617f827 | [
"MIT"
] | null | null | null | MMsgDistributeDemo/MMsgDistributeDemo/MTestObject.h | tiantiankaixin/MBlogDemo | 939852f505e1ee39468359388926f30e4617f827 | [
"MIT"
] | 4 | 2020-06-08T08:09:54.000Z | 2021-05-19T11:08:06.000Z | //
// MTestObject.h
// MMsgDistributeDemo
//
// Created by mal on 2019/9/16.
// Copyright © 2019 mal. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "MTestProtocol.h"
NS_ASSUME_NONNULL_BEGIN
@interface MTestObject : NSObject<MTestPorotocol>
@end
NS_ASSUME_NONNULL_END
| 15.578947 | 49 | 0.743243 |
a2fa950a4e921c8899f8d64291be3e65d8c12c35 | 2,652 | h | C | include/ipmitool/ipmi_sunoem.h | tomasharkema/ipmitool | b0f7af46916edeec5a15a3de8fca267a70659372 | [
"BSD-3-Clause-No-Nuclear-Warranty"
] | null | null | null | include/ipmitool/ipmi_sunoem.h | tomasharkema/ipmitool | b0f7af46916edeec5a15a3de8fca267a70659372 | [
"BSD-3-Clause-No-Nuclear-Warranty"
] | null | null | null | include/ipmitool/ipmi_sunoem.h | tomasharkema/ipmitool | b0f7af46916edeec5a15a3de8fca267a70659372 | [
"BSD-3-Clause-No-Nuclear-Warranty"
] | null | null | null | /*
* Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Redistribution of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of Sun Microsystems, Inc. or the names of
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
* SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE
* FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
* OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL
* SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
* OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
* PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
* LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
* EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#pragma once
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <ipmitool/ipmi.h>
#include <ipmitool/ipmi_sdr.h>
#define IPMI_NETFN_SUNOEM 0x2e
#define IPMI_SUNOEM_SET_SSH_KEY 0x01
#define IPMI_SUNOEM_DEL_SSH_KEY 0x02
#define IPMI_SUNOEM_GET_HEALTH_STATUS 0x10
#define IPMI_SUNOEM_CLI 0x19
#define IPMI_SUNOEM_SET_FAN_SPEED 0x20
#define IPMI_SUNOEM_LED_GET 0x21
#define IPMI_SUNOEM_LED_SET 0x22
#define IPMI_SUNOEM_ECHO 0x23
#define IPMI_SUNOEM_VERSION 0x24
#define IPMI_SUNOEM_NACNAME 0x29
#define IPMI_SUNOEM_GETVAL 0x2A
#define IPMI_SUNOEM_SETVAL 0x2C
#define IPMI_SUNOEM_SENSOR_SET 0x3A
#define IPMI_SUNOEM_SET_FAN_MODE 0x41
#define IPMI_SUNOEM_CORE_TUNNEL 0x44
/*
* Error codes of sunoem functions
*/
typedef enum {
SUNOEM_EC_SUCCESS = 0,
SUNOEM_EC_INVALID_ARG = 1,
SUNOEM_EC_BMC_NOT_RESPONDING = 2,
SUNOEM_EC_BMC_CCODE_NONZERO = 3
} sunoem_ec_t;
int ipmi_sunoem_main(FILE *file, struct ipmi_intf *, int, char **);
| 37.885714 | 79 | 0.762821 |
a2fb034176257b927c0085c90bbba723f06db68d | 2,921 | c | C | base_station/ChibiOS_16.1.4/os/hal/ports/SPC5/SPC57EMxx_HSM/hal_lld.c | raphaelchang/quadthingy-software | c242db06f3b45f3e69efe2a9a9d928256ed9d573 | [
"Apache-2.0"
] | 1 | 2020-10-14T00:26:19.000Z | 2020-10-14T00:26:19.000Z | quadrotor/ChibiOS_16.1.4/os/hal/ports/SPC5/SPC57EMxx_HSM/hal_lld.c | raphaelchang/quadthingy-software | c242db06f3b45f3e69efe2a9a9d928256ed9d573 | [
"Apache-2.0"
] | null | null | null | quadrotor/ChibiOS_16.1.4/os/hal/ports/SPC5/SPC57EMxx_HSM/hal_lld.c | raphaelchang/quadthingy-software | c242db06f3b45f3e69efe2a9a9d928256ed9d573 | [
"Apache-2.0"
] | 3 | 2017-01-10T01:53:32.000Z | 2021-06-15T07:38:50.000Z | /*
SPC5 HAL - Copyright (C) 2013 STMicroelectronics
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* @file SPC57EMxx_HSM/hal_lld.c
* @brief SPC57EMxx_HSM HAL subsystem low level driver source.
*
* @addtogroup HAL
* @{
*/
#include "hal.h"
/*===========================================================================*/
/* Driver exported variables. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver local variables and types. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
/*===========================================================================*/
/* Driver interrupt handlers. */
/*===========================================================================*/
/**
* @brief PIT channel 0 interrupt handler.
*
* @isr
*/
OSAL_IRQ_HANDLER(vector8) {
OSAL_IRQ_PROLOGUE();
osalSysLockFromISR();
osalOsTimerHandlerI();
osalSysUnlockFromISR();
/* Resets the PIT channel 0 IRQ flag.*/
PIT_HSM.TIMER[0].TFLG.R = 1;
OSAL_IRQ_EPILOGUE();
}
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/**
* @brief Low level HAL driver initialization.
*
* @notapi
*/
void hal_lld_init(void) {
uint32_t n;
/* HSM PIT channel 0 initialization for Kernel ticks.*/
n = 100000000 / OSAL_ST_FREQUENCY - 1;
PIT_HSM.MCR.R = 1;
PIT_HSM.TIMER[0].LDVAL.R = n;
PIT_HSM.TIMER[0].CVAL.R = n;
PIT_HSM.TIMER[0].TFLG.R = 1; /* Interrupt flag cleared. */
PIT_HSM.TIMER[0].TCTRL.R = 3; /* Timer active, interrupt enabled. */
/* HSM PIT interrupt vector enabled.*/
INTC_PSR(8) = SPC5_PIT0_IRQ_PRIORITY;
}
/** @} */
| 33.574713 | 80 | 0.411845 |
0c0175dbfa3402edae8e28a2016f6923a46e7de0 | 2,572 | h | C | linsched-linsched-alpha/arch/arm/mach-s5p64x0/include/mach/map.h | usenixatc2021/SoftRefresh_Scheduling | 589ba06c8ae59538973c22edf28f74a59d63aa14 | [
"MIT"
] | 47 | 2015-03-10T23:21:52.000Z | 2022-02-17T01:04:14.000Z | linsched-linsched-alpha/arch/arm/mach-s5p64x0/include/mach/map.h | usenixatc2021/SoftRefresh_Scheduling | 589ba06c8ae59538973c22edf28f74a59d63aa14 | [
"MIT"
] | 1 | 2020-05-28T13:06:06.000Z | 2020-05-28T13:13:15.000Z | linsched-linsched-alpha/arch/arm/mach-s5p64x0/include/mach/map.h | usenixatc2021/SoftRefresh_Scheduling | 589ba06c8ae59538973c22edf28f74a59d63aa14 | [
"MIT"
] | 19 | 2015-02-25T19:50:05.000Z | 2021-10-05T14:35:54.000Z | /* linux/arch/arm/mach-s5p64x0/include/mach/map.h
*
* Copyright (c) 2009-2011 Samsung Electronics Co., Ltd.
* http://www.samsung.com
*
* S5P64X0 - Memory map definitions
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#ifndef __ASM_ARCH_MAP_H
#define __ASM_ARCH_MAP_H __FILE__
#include <plat/map-base.h>
#include <plat/map-s5p.h>
#define S5P64X0_PA_SDRAM 0x20000000
#define S5P64X0_PA_CHIPID 0xE0000000
#define S5P64X0_PA_SYSCON 0xE0100000
#define S5P64X0_PA_GPIO 0xE0308000
#define S5P64X0_PA_VIC0 0xE4000000
#define S5P64X0_PA_VIC1 0xE4100000
#define S5P64X0_PA_SROMC 0xE7000000
#define S5P64X0_PA_PDMA 0xE9000000
#define S5P64X0_PA_TIMER 0xEA000000
#define S5P64X0_PA_RTC 0xEA100000
#define S5P64X0_PA_WDT 0xEA200000
#define S5P6440_PA_IIC0 0xEC104000
#define S5P6440_PA_IIC1 0xEC20F000
#define S5P6450_PA_IIC0 0xEC100000
#define S5P6450_PA_IIC1 0xEC200000
#define S5P64X0_PA_SPI0 0xEC400000
#define S5P64X0_PA_SPI1 0xEC500000
#define S5P64X0_PA_HSOTG 0xED100000
#define S5P64X0_PA_HSMMC(x) (0xED800000 + ((x) * 0x100000))
#define S5P64X0_PA_FB 0xEE000000
#define S5P64X0_PA_I2S 0xF2000000
#define S5P6450_PA_I2S1 0xF2800000
#define S5P6450_PA_I2S2 0xF2900000
#define S5P64X0_PA_PCM 0xF2100000
#define S5P64X0_PA_ADC 0xF3000000
/* Compatibiltiy Defines */
#define S3C_PA_HSMMC0 S5P64X0_PA_HSMMC(0)
#define S3C_PA_HSMMC1 S5P64X0_PA_HSMMC(1)
#define S3C_PA_HSMMC2 S5P64X0_PA_HSMMC(2)
#define S3C_PA_IIC S5P6440_PA_IIC0
#define S3C_PA_IIC1 S5P6440_PA_IIC1
#define S3C_PA_RTC S5P64X0_PA_RTC
#define S3C_PA_WDT S5P64X0_PA_WDT
#define S3C_PA_FB S5P64X0_PA_FB
#define S3C_PA_SPI0 S5P64X0_PA_SPI0
#define S3C_PA_SPI1 S5P64X0_PA_SPI1
#define S5P_PA_CHIPID S5P64X0_PA_CHIPID
#define S5P_PA_SROMC S5P64X0_PA_SROMC
#define S5P_PA_SYSCON S5P64X0_PA_SYSCON
#define S5P_PA_TIMER S5P64X0_PA_TIMER
#define SAMSUNG_PA_ADC S5P64X0_PA_ADC
/* UART */
#define S5P6440_PA_UART(x) (0xEC000000 + ((x) * S3C_UART_OFFSET))
#define S5P6450_PA_UART(x) ((x < 5) ? (0xEC800000 + ((x) * S3C_UART_OFFSET)) : (0xEC000000))
#define S5P_PA_UART0 S5P6450_PA_UART(0)
#define S5P_PA_UART1 S5P6450_PA_UART(1)
#define S5P_PA_UART2 S5P6450_PA_UART(2)
#define S5P_PA_UART3 S5P6450_PA_UART(3)
#define S5P_PA_UART4 S5P6450_PA_UART(4)
#define S5P_PA_UART5 S5P6450_PA_UART(5)
#define S5P_SZ_UART SZ_256
#define S3C_VA_UARTx(x) (S3C_VA_UART + ((x) * S3C_UART_OFFSET))
#endif /* __ASM_ARCH_MAP_H */
| 26.791667 | 92 | 0.803655 |
0c01a0bab5e3f0044f980fe7f9cc6170eea3176b | 6,702 | c | C | third-party/libfabric/libfabric-src/prov/efa/src/efa_domain.c | nldias/chapel | 3a63044cd50b639dca8e851d4a505546b57bc299 | [
"ECL-2.0",
"Apache-2.0"
] | 3 | 2019-10-03T21:04:56.000Z | 2019-10-04T01:22:53.000Z | third-party/libfabric/libfabric-src/prov/efa/src/efa_domain.c | nldias/chapel | 3a63044cd50b639dca8e851d4a505546b57bc299 | [
"ECL-2.0",
"Apache-2.0"
] | 30 | 2017-01-20T21:37:45.000Z | 2017-03-28T21:11:56.000Z | third-party/libfabric/libfabric-src/prov/efa/src/efa_domain.c | nldias/chapel | 3a63044cd50b639dca8e851d4a505546b57bc299 | [
"ECL-2.0",
"Apache-2.0"
] | 2 | 2020-02-27T21:06:13.000Z | 2020-04-21T11:19:31.000Z | /*
* Copyright (c) 2013-2015 Intel Corporation, Inc. All rights reserved.
* Copyright (c) 2017-2020 Amazon.com, Inc. or its affiliates. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "config.h"
#include <ofi_util.h>
#include "efa.h"
#include "rxr_cntr.h"
static int efa_domain_close(fid_t fid)
{
struct efa_domain *domain;
int ret;
domain = container_of(fid, struct efa_domain,
util_domain.domain_fid.fid);
if (efa_mr_cache_enable)
ofi_mr_cache_cleanup(&domain->cache);
if (domain->ibv_pd) {
ret = -ibv_dealloc_pd(domain->ibv_pd);
if (ret) {
EFA_INFO_ERRNO(FI_LOG_DOMAIN, "ibv_dealloc_pd", ret);
return ret;
}
domain->ibv_pd = NULL;
}
ret = ofi_domain_close(&domain->util_domain);
if (ret)
return ret;
fi_freeinfo(domain->info);
free(domain->qp_table);
free(domain);
return 0;
}
static int efa_open_device_by_name(struct efa_domain *domain, const char *name)
{
struct efa_context **ctx_list;
int i, ret = -FI_ENODEV;
int name_len;
int num_ctx;
if (!name)
return -FI_EINVAL;
ctx_list = efa_device_get_context_list(&num_ctx);
if (!ctx_list)
return -errno;
if (domain->type == EFA_DOMAIN_RDM)
name_len = strlen(name) - strlen(efa_rdm_domain.suffix);
else
name_len = strlen(name) - strlen(efa_dgrm_domain.suffix);
for (i = 0; i < num_ctx; i++) {
ret = strncmp(name, ctx_list[i]->ibv_ctx->device->name, name_len);
if (!ret) {
domain->ctx = ctx_list[i];
break;
}
}
efa_device_free_context_list(ctx_list);
return ret;
}
static struct fi_ops efa_fid_ops = {
.size = sizeof(struct fi_ops),
.close = efa_domain_close,
.bind = fi_no_bind,
.control = fi_no_control,
.ops_open = fi_no_ops_open,
};
static struct fi_ops_domain efa_domain_ops = {
.size = sizeof(struct fi_ops_domain),
.av_open = efa_av_open,
.cq_open = efa_cq_open,
.endpoint = efa_ep_open,
.scalable_ep = fi_no_scalable_ep,
.cntr_open = efa_cntr_open,
.poll_open = fi_no_poll_open,
.stx_ctx = fi_no_stx_context,
.srx_ctx = fi_no_srx_context,
.query_atomic = fi_no_query_atomic,
.query_collective = fi_no_query_collective,
};
int efa_domain_open(struct fid_fabric *fabric_fid, struct fi_info *info,
struct fid_domain **domain_fid, void *context)
{
struct efa_domain *domain;
struct efa_fabric *fabric;
const struct fi_info *fi;
size_t qp_table_size;
int ret;
fi = efa_get_efa_info(info->domain_attr->name);
if (!fi)
return -FI_EINVAL;
fabric = container_of(fabric_fid, struct efa_fabric,
util_fabric.fabric_fid);
ret = ofi_check_domain_attr(&efa_prov, fabric_fid->api_version,
fi->domain_attr, info);
if (ret)
return ret;
domain = calloc(1, sizeof(*domain));
if (!domain)
return -FI_ENOMEM;
qp_table_size = roundup_power_of_two(info->domain_attr->ep_cnt);
domain->qp_table_sz_m1 = qp_table_size - 1;
domain->qp_table = calloc(qp_table_size, sizeof(*domain->qp_table));
if (!domain->qp_table) {
ret = -FI_ENOMEM;
goto err_free_domain;
}
ret = ofi_domain_init(fabric_fid, info, &domain->util_domain,
context);
if (ret)
goto err_free_qp_table;
domain->info = fi_dupinfo(info);
if (!domain->info) {
ret = -FI_ENOMEM;
goto err_close_domain;
}
if (EFA_EP_TYPE_IS_RDM(info))
domain->type = EFA_DOMAIN_RDM;
else
domain->type = EFA_DOMAIN_DGRAM;
ret = efa_open_device_by_name(domain, info->domain_attr->name);
if (ret)
goto err_free_info;
domain->ibv_pd = ibv_alloc_pd(domain->ctx->ibv_ctx);
if (!domain->ibv_pd) {
ret = -errno;
goto err_free_info;
}
domain->util_domain.domain_fid.fid.ops = &efa_fid_ops;
domain->util_domain.domain_fid.ops = &efa_domain_ops;
/* RMA mr_modes are being removed, since EFA layer
* does not have RMA capabilities. Hence, adding FI_MR_VIRT_ADDR
* until RMA capabilities are added to EFA layer
*/
domain->util_domain.mr_map.mode |= FI_MR_VIRT_ADDR;
/*
* ofi_domain_init() would have stored the EFA mr_modes in the mr_map,
* but we need the rbtree insertions and lookups to use EFA provider's
* specific key, so unset the FI_MR_PROV_KEY bit for mr_map.
*/
domain->util_domain.mr_map.mode &= ~FI_MR_PROV_KEY;
domain->fab = fabric;
*domain_fid = &domain->util_domain.domain_fid;
if (efa_mr_cache_enable) {
if (!efa_mr_max_cached_count)
efa_mr_max_cached_count = info->domain_attr->mr_cnt *
EFA_MR_CACHE_LIMIT_MULT;
if (!efa_mr_max_cached_size)
efa_mr_max_cached_size = domain->ctx->max_mr_size *
EFA_MR_CACHE_LIMIT_MULT;
cache_params.max_cnt = efa_mr_max_cached_count;
cache_params.max_size = efa_mr_max_cached_size;
domain->cache.entry_data_size = sizeof(struct efa_mr);
domain->cache.add_region = efa_mr_cache_entry_reg;
domain->cache.delete_region = efa_mr_cache_entry_dereg;
ret = ofi_mr_cache_init(&domain->util_domain, uffd_monitor,
&domain->cache);
if (!ret) {
domain->util_domain.domain_fid.mr = &efa_domain_mr_cache_ops;
EFA_INFO(FI_LOG_DOMAIN, "EFA MR cache enabled, max_cnt: %zu max_size: %zu\n",
cache_params.max_cnt, cache_params.max_size);
return 0;
}
}
domain->util_domain.domain_fid.mr = &efa_domain_mr_ops;
efa_mr_cache_enable = 0;
return 0;
err_free_info:
fi_freeinfo(domain->info);
err_close_domain:
ofi_domain_close(&domain->util_domain);
err_free_qp_table:
free(domain->qp_table);
err_free_domain:
free(domain);
return ret;
}
| 28.641026 | 83 | 0.722919 |
0c01b330c295943163e93c7affd6c9f848a184c8 | 1,059 | h | C | OpenGLDLL/GLFunctions/ATI/ATI_draw_buffers_Include.h | bilke/UniCAVE | 9a20535aaa78bbae9b5b4f718de2fd625b920a56 | [
"MIT"
] | 468 | 2015-04-13T19:03:57.000Z | 2022-03-23T00:11:24.000Z | OpenGLDLL/GLFunctions/ATI/ATI_draw_buffers_Include.h | deakinshaun/UniCAVE-Deakin | 8dc184d7dd598d4554627b8564cae99975ef3dc2 | [
"MIT"
] | 12 | 2015-05-25T11:15:21.000Z | 2020-10-26T02:46:50.000Z | OpenGLDLL/GLFunctions/ATI/ATI_draw_buffers_Include.h | deakinshaun/UniCAVE-Deakin | 8dc184d7dd598d4554627b8564cae99975ef3dc2 | [
"MIT"
] | 67 | 2015-04-22T13:22:48.000Z | 2022-03-05T01:11:02.000Z | #define GLI_INCLUDE_ATI_DRAW_BUFFERS
/* Now in the ARB version
enum Main {
GL_MAX_DRAW_BUFFERS_ATI = 0x8824,
GL_DRAW_BUFFER0_ATI = 0x8825,
GL_DRAW_BUFFER1_ATI = 0x8826,
GL_DRAW_BUFFER2_ATI = 0x8827,
GL_DRAW_BUFFER3_ATI = 0x8828,
GL_DRAW_BUFFER4_ATI = 0x8829,
GL_DRAW_BUFFER5_ATI = 0x882A,
GL_DRAW_BUFFER6_ATI = 0x882B,
GL_DRAW_BUFFER7_ATI = 0x882C,
GL_DRAW_BUFFER8_ATI = 0x882D,
GL_DRAW_BUFFER9_ATI = 0x882E,
GL_DRAW_BUFFER10_ATI = 0x882F,
GL_DRAW_BUFFER11_ATI = 0x8830,
GL_DRAW_BUFFER12_ATI = 0x8831,
GL_DRAW_BUFFER13_ATI = 0x8832,
GL_DRAW_BUFFER14_ATI = 0x8833,
GL_DRAW_BUFFER15_ATI = 0x8834,
};
*/
void glDrawBuffersATI(GLsizei n, const GLenum *bufs);
| 35.3 | 53 | 0.508026 |
0c01dc3e4a17c51d4d210083bc9645f02d88fc63 | 1,337 | h | C | CO2Sensor.h | TheisNiklas/Projekt-ATmega16 | 6ec28e94c514ed7aa5a2b0c47bc0934187d8adb1 | [
"MIT"
] | null | null | null | CO2Sensor.h | TheisNiklas/Projekt-ATmega16 | 6ec28e94c514ed7aa5a2b0c47bc0934187d8adb1 | [
"MIT"
] | null | null | null | CO2Sensor.h | TheisNiklas/Projekt-ATmega16 | 6ec28e94c514ed7aa5a2b0c47bc0934187d8adb1 | [
"MIT"
] | null | null | null | enum CO2_Error_t
{
CO2_NOERROR = 0,
CO2_ERROR = 1
};
typedef enum CO2_Error_t CO2_Error_t;
enum CO2_AutocalibMode_t
{
CO2_AUTOCAL_INACTIVE = 0,
CO2_AUTOCAL_ACTIVE = 1
};
typedef enum CO2_AutocalibMode_t CO2_AutocalibMode_t;
enum CO2_MeasurementState_t
{
CO2_MEAS_STOPPED = 0,
CO2_MEAS_RUNNING = 1
};
typedef enum CO2_MeasurementState_t CO2_MeasurementState_t;
struct SensorData_t
{
//uint8_t new_data_available_u8;
float co2_value_f;
float humidity_value_f;
float temperature_value_f;
CO2_AutocalibMode_t AutocalibMode_en;
CO2_MeasurementState_t MeasState_en;
uint16_t firmware_version_u16;
};
typedef struct SensorData_t SensorData_t;
struct SensorConfigData_t
{
uint16_t meas_interval_in_sec_u16;
uint16_t ambient_pressure_in_mbar_u16;
uint16_t altitude_in_m_u16;
uint16_t temp_offset_u16;
};
typedef struct SensorConfigData_t SensorConfigData_t;
CO2_Error_t CO2_InitSensor(SensorData_t *SensorData_st);
CO2_Error_t CO2_ConfigSensor(SensorConfigData_t *SensorConfigData_st);
CO2_Error_t CO2_StartMeasurement(void);
CO2_Error_t CO2_StopMeasurement(void);
CO2_Error_t CO2_UpdateMeasData(void);
CO2_Error_t CO2_UpdateSensorParameterData(void);
CO2_Error_t CO2_StartAutoCalibrationMode(void);
CO2_Error_t CO2_StopAutoCalibrationMode(void);
CO2_Error_t CO2_SetCO2CalibrationValue(uint16_t Co2_concentration_in_ppm);
| 24.759259 | 74 | 0.853403 |
0c03eb8061bc753ebf8613afea2668dafcc83fc1 | 744 | h | C | System/Library/PrivateFrameworks/ShazamInsights.framework/SQRegionQuery.h | lechium/tvOS144Headers | e22dcf52662ae03002e3a6d57273f54e74013cb0 | [
"MIT"
] | 2 | 2021-04-15T10:50:21.000Z | 2021-08-19T19:00:09.000Z | System/Library/PrivateFrameworks/ShazamInsights.framework/SQRegionQuery.h | lechium/tvOS144Headers | e22dcf52662ae03002e3a6d57273f54e74013cb0 | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/ShazamInsights.framework/SQRegionQuery.h | lechium/tvOS144Headers | e22dcf52662ae03002e3a6d57273f54e74013cb0 | [
"MIT"
] | null | null | null | /*
* This header is generated by classdump-dyld 1.5
* on Wednesday, April 14, 2021 at 2:35:53 PM Mountain Standard Time
* Operating System: Version 14.4 (Build 18K802)
* Image Source: /System/Library/PrivateFrameworks/ShazamInsights.framework/ShazamInsights
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley.
*/
#import <ShazamInsights/SQQuery.h>
@interface SQRegionQuery : SQQuery
-(void)regionsForLocation:(id)arg1 withCompletionHandler:(/*^block*/id)arg2 ;
-(void)regionsForCountryCode:(id)arg1 withCompletionHandler:(/*^block*/id)arg2 ;
@end
| 46.5 | 130 | 0.633065 |
0c0614c474e2a6ec5b8fb515e4c239c9f3634af7 | 9,504 | h | C | usermods/usermod_v2_auto_save/usermod_v2_auto_save.h | PLCHome/WLED | 1d657f619dcf624d7eded2b3c19b7e200bc99889 | [
"MIT"
] | null | null | null | usermods/usermod_v2_auto_save/usermod_v2_auto_save.h | PLCHome/WLED | 1d657f619dcf624d7eded2b3c19b7e200bc99889 | [
"MIT"
] | 1 | 2022-02-17T01:46:40.000Z | 2022-02-17T01:46:40.000Z | usermods/usermod_v2_auto_save/usermod_v2_auto_save.h | PLCHome/WLED | 1d657f619dcf624d7eded2b3c19b7e200bc99889 | [
"MIT"
] | null | null | null | #pragma once
#include "wled.h"
// v2 Usermod to automatically save settings
// to configurable preset after a change to any of
//
// * brightness
// * effect speed
// * effect intensity
// * mode (effect)
// * palette
//
// but it will wait for configurable number of seconds, a "settle"
// period in case there are other changes (any change will
// extend the "settle" window).
//
// It can be configured to load auto saved preset at startup,
// during the first `loop()`.
//
// AutoSaveUsermod is standalone, but if FourLineDisplayUsermod
// is installed, it will notify the user of the saved changes.
// format: "~ MM-DD HH:MM:SS ~"
#define PRESET_NAME_BUFFER_SIZE 25
class AutoSaveUsermod : public Usermod {
private:
bool firstLoop = true;
bool initDone = false;
bool enabled = true;
// configurable parameters
uint16_t autoSaveAfterSec = 15; // 15s by default
uint8_t autoSavePreset = 250; // last possible preset
bool applyAutoSaveOnBoot = false; // do we load auto-saved preset on boot?
// If we've detected the need to auto save, this will be non zero.
unsigned long autoSaveAfter = 0;
uint8_t knownBrightness = 0;
uint8_t knownEffectSpeed = 0;
uint8_t knownEffectIntensity = 0;
uint8_t knownMode = 0;
uint8_t knownPalette = 0;
#ifdef USERMOD_FOUR_LINE_DISPLAY
FourLineDisplayUsermod* display;
#endif
// strings to reduce flash memory usage (used more than twice)
static const char _name[];
static const char _autoSaveEnabled[];
static const char _autoSaveAfterSec[];
static const char _autoSavePreset[];
static const char _autoSaveApplyOnBoot[];
void inline saveSettings() {
char presetNameBuffer[PRESET_NAME_BUFFER_SIZE];
updateLocalTime();
sprintf_P(presetNameBuffer,
PSTR("~ %02d-%02d %02d:%02d:%02d ~"),
month(localTime), day(localTime),
hour(localTime), minute(localTime), second(localTime));
savePreset(autoSavePreset, true, presetNameBuffer);
}
void inline displayOverlay() {
#ifdef USERMOD_FOUR_LINE_DISPLAY
if (display != nullptr) {
display->wakeDisplay();
display->overlay("Settings", "Auto Saved", 1500);
}
#endif
}
public:
// gets called once at boot. Do all initialization that doesn't depend on
// network here
void setup() {
#ifdef USERMOD_FOUR_LINE_DISPLAY
// This Usermod has enhanced funcionality if
// FourLineDisplayUsermod is available.
display = (FourLineDisplayUsermod*) usermods.lookup(USERMOD_ID_FOUR_LINE_DISP);
#endif
initDone = true;
if (enabled && applyAutoSaveOnBoot) applyPreset(autoSavePreset);
knownBrightness = bri;
knownEffectSpeed = effectSpeed;
knownEffectIntensity = effectIntensity;
knownMode = strip.getMainSegment().mode;
knownPalette = strip.getMainSegment().palette;
}
// gets called every time WiFi is (re-)connected. Initialize own network
// interfaces here
void connected() {}
/*
* Da loop.
*/
void loop() {
if (!autoSaveAfterSec || !enabled || strip.isUpdating() || currentPreset>0) return; // setting 0 as autosave seconds disables autosave
unsigned long now = millis();
uint8_t currentMode = strip.getMainSegment().mode;
uint8_t currentPalette = strip.getMainSegment().palette;
unsigned long wouldAutoSaveAfter = now + autoSaveAfterSec*1000;
if (knownBrightness != bri) {
knownBrightness = bri;
autoSaveAfter = wouldAutoSaveAfter;
} else if (knownEffectSpeed != effectSpeed) {
knownEffectSpeed = effectSpeed;
autoSaveAfter = wouldAutoSaveAfter;
} else if (knownEffectIntensity != effectIntensity) {
knownEffectIntensity = effectIntensity;
autoSaveAfter = wouldAutoSaveAfter;
} else if (knownMode != currentMode) {
knownMode = currentMode;
autoSaveAfter = wouldAutoSaveAfter;
} else if (knownPalette != currentPalette) {
knownPalette = currentPalette;
autoSaveAfter = wouldAutoSaveAfter;
}
if (autoSaveAfter && now > autoSaveAfter) {
autoSaveAfter = 0;
// Time to auto save. You may have some flickry?
saveSettings();
displayOverlay();
}
}
/*
* addToJsonInfo() can be used to add custom entries to the /json/info part of the JSON API.
* Creating an "u" object allows you to add custom key/value pairs to the Info section of the WLED web UI.
* Below it is shown how this could be used for e.g. a light sensor
*/
//void addToJsonInfo(JsonObject& root) {
//JsonObject user = root["u"];
//if (user.isNull()) user = root.createNestedObject("u");
//JsonArray data = user.createNestedArray(F("Autosave"));
//data.add(F("Loaded."));
//}
/*
* addToJsonState() can be used to add custom entries to the /json/state part of the JSON API (state object).
* Values in the state object may be modified by connected clients
*/
//void addToJsonState(JsonObject& root) {
//}
/*
* readFromJsonState() can be used to receive data clients send to the /json/state part of the JSON API (state object).
* Values in the state object may be modified by connected clients
*/
//void readFromJsonState(JsonObject& root) {
// if (!initDone) return; // prevent crash on boot applyPreset()
//}
/*
* addToConfig() can be used to add custom persistent settings to the cfg.json file in the "um" (usermod) object.
* It will be called by WLED when settings are actually saved (for example, LED settings are saved)
* If you want to force saving the current state, use serializeConfig() in your loop().
*
* CAUTION: serializeConfig() will initiate a filesystem write operation.
* It might cause the LEDs to stutter and will cause flash wear if called too often.
* Use it sparingly and always in the loop, never in network callbacks!
*
* addToConfig() will also not yet add your setting to one of the settings pages automatically.
* To make that work you still have to add the setting to the HTML, xml.cpp and set.cpp manually.
*
* I highly recommend checking out the basics of ArduinoJson serialization and deserialization in order to use custom settings!
*/
void addToConfig(JsonObject& root) {
// we add JSON object: {"Autosave": {"autoSaveAfterSec": 10, "autoSavePreset": 99}}
JsonObject top = root.createNestedObject(FPSTR(_name)); // usermodname
top[FPSTR(_autoSaveEnabled)] = enabled;
top[FPSTR(_autoSaveAfterSec)] = autoSaveAfterSec; // usermodparam
top[FPSTR(_autoSavePreset)] = autoSavePreset; // usermodparam
top[FPSTR(_autoSaveApplyOnBoot)] = applyAutoSaveOnBoot;
DEBUG_PRINTLN(F("Autosave config saved."));
}
/*
* readFromConfig() can be used to read back the custom settings you added with addToConfig().
* This is called by WLED when settings are loaded (currently this only happens once immediately after boot)
*
* readFromConfig() is called BEFORE setup(). This means you can use your persistent values in setup() (e.g. pin assignments, buffer sizes),
* but also that if you want to write persistent values to a dynamic buffer, you'd need to allocate it here instead of in setup.
* If you don't know what that is, don't fret. It most likely doesn't affect your use case :)
*
* The function should return true if configuration was successfully loaded or false if there was no configuration.
*/
bool readFromConfig(JsonObject& root) {
// we look for JSON object: {"Autosave": {"enabled": true, "autoSaveAfterSec": 10, "autoSavePreset": 250, ...}}
JsonObject top = root[FPSTR(_name)];
if (top.isNull()) {
DEBUG_PRINT(FPSTR(_name));
DEBUG_PRINTLN(F(": No config found. (Using defaults.)"));
return false;
}
enabled = top[FPSTR(_autoSaveEnabled)] | enabled;
autoSaveAfterSec = top[FPSTR(_autoSaveAfterSec)] | autoSaveAfterSec;
autoSaveAfterSec = (uint16_t) min(3600,max(10,(int)autoSaveAfterSec)); // bounds checking
autoSavePreset = top[FPSTR(_autoSavePreset)] | autoSavePreset;
autoSavePreset = (uint8_t) min(250,max(100,(int)autoSavePreset)); // bounds checking
applyAutoSaveOnBoot = top[FPSTR(_autoSaveApplyOnBoot)] | applyAutoSaveOnBoot;
DEBUG_PRINT(FPSTR(_name));
DEBUG_PRINTLN(F(" config (re)loaded."));
// use "return !top["newestParameter"].isNull();" when updating Usermod with new features
return true;
}
/*
* getId() allows you to optionally give your V2 usermod an unique ID (please define it in const.h!).
* This could be used in the future for the system to determine whether your usermod is installed.
*/
uint16_t getId() {
return USERMOD_ID_AUTO_SAVE;
}
};
// strings to reduce flash memory usage (used more than twice)
const char AutoSaveUsermod::_name[] PROGMEM = "Autosave";
const char AutoSaveUsermod::_autoSaveEnabled[] PROGMEM = "enabled";
const char AutoSaveUsermod::_autoSaveAfterSec[] PROGMEM = "autoSaveAfterSec";
const char AutoSaveUsermod::_autoSavePreset[] PROGMEM = "autoSavePreset";
const char AutoSaveUsermod::_autoSaveApplyOnBoot[] PROGMEM = "autoSaveApplyOnBoot";
| 40.271186 | 144 | 0.673401 |
0c07abf50e31b7dba05f0d6102382b5440ad569e | 46,808 | h | C | Peripherals/STM32F446/include/LibreUCpp/Peripherals/RTC.h | LibreUCpp/LibreUCpp | e28d7e4beeee6c32af2e04fc587ac77219e7a05a | [
"MIT"
] | null | null | null | Peripherals/STM32F446/include/LibreUCpp/Peripherals/RTC.h | LibreUCpp/LibreUCpp | e28d7e4beeee6c32af2e04fc587ac77219e7a05a | [
"MIT"
] | null | null | null | Peripherals/STM32F446/include/LibreUCpp/Peripherals/RTC.h | LibreUCpp/LibreUCpp | e28d7e4beeee6c32af2e04fc587ac77219e7a05a | [
"MIT"
] | null | null | null | #pragma once
#include <stdint.h>
#include <unistd.h>
namespace LibreUCpp {
namespace Peripherals {
struct __attribute__((aligned(4), packed)) RTC_T
{
static constexpr size_t INSTANCE_SIZE = 160;
static constexpr size_t PADDED_INSTANCE_SIZE = 160;
static constexpr intptr_t BASE_ADDRESS = 0x40002800;
static constexpr intptr_t ADDR_OFFSET_TR = 0x00;
static constexpr intptr_t ADDR_OFFSET_DR = 0x04;
static constexpr intptr_t ADDR_OFFSET_CR = 0x08;
static constexpr intptr_t ADDR_OFFSET_ISR = 0x0c;
static constexpr intptr_t ADDR_OFFSET_PRER = 0x10;
static constexpr intptr_t ADDR_OFFSET_WUTR = 0x14;
static constexpr intptr_t ADDR_OFFSET_CALIBR = 0x18;
static constexpr intptr_t ADDR_OFFSET_ALRMAR = 0x1c;
static constexpr intptr_t ADDR_OFFSET_ALRMBR = 0x20;
static constexpr intptr_t ADDR_OFFSET_WPR = 0x24;
static constexpr intptr_t ADDR_OFFSET_SSR = 0x28;
static constexpr intptr_t ADDR_OFFSET_SHIFTR = 0x2c;
static constexpr intptr_t ADDR_OFFSET_TSTR = 0x30;
static constexpr intptr_t ADDR_OFFSET_TSDR = 0x34;
static constexpr intptr_t ADDR_OFFSET_TSSSR = 0x38;
static constexpr intptr_t ADDR_OFFSET_CALR = 0x3c;
static constexpr intptr_t ADDR_OFFSET_TAFCR = 0x40;
static constexpr intptr_t ADDR_OFFSET_ALRMASSR = 0x44;
static constexpr intptr_t ADDR_OFFSET_ALRMBSSR = 0x48;
static constexpr intptr_t ADDR_OFFSET_BKP0R = 0x50;
static constexpr intptr_t ADDR_OFFSET_BKP1R = 0x54;
static constexpr intptr_t ADDR_OFFSET_BKP2R = 0x58;
static constexpr intptr_t ADDR_OFFSET_BKP3R = 0x5c;
static constexpr intptr_t ADDR_OFFSET_BKP4R = 0x60;
static constexpr intptr_t ADDR_OFFSET_BKP5R = 0x64;
static constexpr intptr_t ADDR_OFFSET_BKP6R = 0x68;
static constexpr intptr_t ADDR_OFFSET_BKP7R = 0x6c;
static constexpr intptr_t ADDR_OFFSET_BKP8R = 0x70;
static constexpr intptr_t ADDR_OFFSET_BKP9R = 0x74;
static constexpr intptr_t ADDR_OFFSET_BKP10R = 0x78;
static constexpr intptr_t ADDR_OFFSET_BKP11R = 0x7c;
static constexpr intptr_t ADDR_OFFSET_BKP12R = 0x80;
static constexpr intptr_t ADDR_OFFSET_BKP13R = 0x84;
static constexpr intptr_t ADDR_OFFSET_BKP14R = 0x88;
static constexpr intptr_t ADDR_OFFSET_BKP15R = 0x8c;
static constexpr intptr_t ADDR_OFFSET_BKP16R = 0x90;
static constexpr intptr_t ADDR_OFFSET_BKP17R = 0x94;
static constexpr intptr_t ADDR_OFFSET_BKP18R = 0x98;
static constexpr intptr_t ADDR_OFFSET_BKP19R = 0x9c;
volatile union TR_T // TR: time register
{
uint32_t reg;
struct __attribute__((packed)) TR_BIT_T
{
unsigned SU : 4; // bits 0..3 Second units in BCD format
unsigned ST : 3; // bits 4..6 Second tens in BCD format
unsigned : 1; // bit 7 unused
unsigned MNU : 4; // bits 8..11 Minute units in BCD format
unsigned MNT : 3; // bits 12..14 Minute tens in BCD format
unsigned : 1; // bit 15 unused
unsigned HU : 4; // bits 16..19 Hour units in BCD format
unsigned HT : 2; // bits 20..21 Hour tens in BCD format
unsigned PM : 1; // bit 22 AM/PM notation
unsigned : 9; // bits 23..31 unused
} bit;
static constexpr unsigned SU_POS = 0;
static constexpr unsigned SU_MASK = 0x0000000f;
static constexpr unsigned SU(unsigned value) { return (value << 0); }
static constexpr unsigned ST_POS = 4;
static constexpr unsigned ST_MASK = 0x00000070;
static constexpr unsigned ST(unsigned value) { return (value << 4); }
static constexpr unsigned MNU_POS = 8;
static constexpr unsigned MNU_MASK = 0x00000f00;
static constexpr unsigned MNU(unsigned value) { return (value << 8); }
static constexpr unsigned MNT_POS = 12;
static constexpr unsigned MNT_MASK = 0x00007000;
static constexpr unsigned MNT(unsigned value) { return (value << 12); }
static constexpr unsigned HU_POS = 16;
static constexpr unsigned HU_MASK = 0x000f0000;
static constexpr unsigned HU(unsigned value) { return (value << 16); }
static constexpr unsigned HT_POS = 20;
static constexpr unsigned HT_MASK = 0x00300000;
static constexpr unsigned HT(unsigned value) { return (value << 20); }
static constexpr unsigned PM_POS = 22;
static constexpr unsigned PM_MASK = 0x00400000;
static constexpr unsigned PM(unsigned value) { return (value << 22); }
} TR;
volatile union DR_T // DR: date register
{
uint32_t reg;
struct __attribute__((packed)) DR_BIT_T
{
unsigned DU : 4; // bits 0..3 Date units in BCD format
unsigned DT : 2; // bits 4..5 Date tens in BCD format
unsigned : 2; // bits 6..7 unused
unsigned MU : 4; // bits 8..11 Month units in BCD format
unsigned MT : 1; // bit 12 Month tens in BCD format
unsigned WDU : 3; // bits 13..15 Week day units
unsigned YU : 4; // bits 16..19 Year units in BCD format
unsigned YT : 4; // bits 20..23 Year tens in BCD format
unsigned : 8; // bits 24..31 unused
} bit;
static constexpr unsigned DU_POS = 0;
static constexpr unsigned DU_MASK = 0x0000000f;
static constexpr unsigned DU(unsigned value) { return (value << 0); }
static constexpr unsigned DT_POS = 4;
static constexpr unsigned DT_MASK = 0x00000030;
static constexpr unsigned DT(unsigned value) { return (value << 4); }
static constexpr unsigned MU_POS = 8;
static constexpr unsigned MU_MASK = 0x00000f00;
static constexpr unsigned MU(unsigned value) { return (value << 8); }
static constexpr unsigned MT_POS = 12;
static constexpr unsigned MT_MASK = 0x00001000;
static constexpr unsigned MT(unsigned value) { return (value << 12); }
static constexpr unsigned WDU_POS = 13;
static constexpr unsigned WDU_MASK = 0x0000e000;
static constexpr unsigned WDU(unsigned value) { return (value << 13); }
static constexpr unsigned YU_POS = 16;
static constexpr unsigned YU_MASK = 0x000f0000;
static constexpr unsigned YU(unsigned value) { return (value << 16); }
static constexpr unsigned YT_POS = 20;
static constexpr unsigned YT_MASK = 0x00f00000;
static constexpr unsigned YT(unsigned value) { return (value << 20); }
} DR;
volatile union CR_T // CR: control register
{
uint32_t reg;
struct __attribute__((packed)) CR_BIT_T
{
unsigned WCKSEL : 3; // bits 0..2 Wakeup clock selection
unsigned TSEDGE : 1; // bit 3 Time-stamp event active edge
unsigned REFCKON : 1; // bit 4 Reference clock detection enable (50 or 60 Hz)
unsigned : 1; // bit 5 unused
unsigned FMT : 1; // bit 6 Hour format
unsigned DCE : 1; // bit 7 Coarse digital calibration enable
unsigned ALRAE : 1; // bit 8 Alarm A enable
unsigned ALRBE : 1; // bit 9 Alarm B enable
unsigned WUTE : 1; // bit 10 Wakeup timer enable
unsigned TSE : 1; // bit 11 Time stamp enable
unsigned ALRAIE : 1; // bit 12 Alarm A interrupt enable
unsigned ALRBIE : 1; // bit 13 Alarm B interrupt enable
unsigned WUTIE : 1; // bit 14 Wakeup timer interrupt enable
unsigned TSIE : 1; // bit 15 Time-stamp interrupt enable
unsigned ADD1H : 1; // bit 16 Add 1 hour (summer time change)
unsigned SUB1H : 1; // bit 17 Subtract 1 hour (winter time change)
unsigned BKP : 1; // bit 18 Backup
unsigned : 1; // bit 19 unused
unsigned POL : 1; // bit 20 Output polarity
unsigned OSEL : 2; // bits 21..22 Output selection
unsigned COE : 1; // bit 23 Calibration output enable
unsigned : 8; // bits 24..31 unused
} bit;
static constexpr unsigned WCKSEL_POS = 0;
static constexpr unsigned WCKSEL_MASK = 0x00000007;
static constexpr unsigned WCKSEL(unsigned value) { return (value << 0); }
static constexpr unsigned TSEDGE_POS = 3;
static constexpr unsigned TSEDGE_MASK = 0x00000008;
static constexpr unsigned TSEDGE(unsigned value) { return (value << 3); }
static constexpr unsigned REFCKON_POS = 4;
static constexpr unsigned REFCKON_MASK = 0x00000010;
static constexpr unsigned REFCKON(unsigned value) { return (value << 4); }
static constexpr unsigned FMT_POS = 6;
static constexpr unsigned FMT_MASK = 0x00000040;
static constexpr unsigned FMT(unsigned value) { return (value << 6); }
static constexpr unsigned DCE_POS = 7;
static constexpr unsigned DCE_MASK = 0x00000080;
static constexpr unsigned DCE(unsigned value) { return (value << 7); }
static constexpr unsigned ALRAE_POS = 8;
static constexpr unsigned ALRAE_MASK = 0x00000100;
static constexpr unsigned ALRAE(unsigned value) { return (value << 8); }
static constexpr unsigned ALRBE_POS = 9;
static constexpr unsigned ALRBE_MASK = 0x00000200;
static constexpr unsigned ALRBE(unsigned value) { return (value << 9); }
static constexpr unsigned WUTE_POS = 10;
static constexpr unsigned WUTE_MASK = 0x00000400;
static constexpr unsigned WUTE(unsigned value) { return (value << 10); }
static constexpr unsigned TSE_POS = 11;
static constexpr unsigned TSE_MASK = 0x00000800;
static constexpr unsigned TSE(unsigned value) { return (value << 11); }
static constexpr unsigned ALRAIE_POS = 12;
static constexpr unsigned ALRAIE_MASK = 0x00001000;
static constexpr unsigned ALRAIE(unsigned value) { return (value << 12); }
static constexpr unsigned ALRBIE_POS = 13;
static constexpr unsigned ALRBIE_MASK = 0x00002000;
static constexpr unsigned ALRBIE(unsigned value) { return (value << 13); }
static constexpr unsigned WUTIE_POS = 14;
static constexpr unsigned WUTIE_MASK = 0x00004000;
static constexpr unsigned WUTIE(unsigned value) { return (value << 14); }
static constexpr unsigned TSIE_POS = 15;
static constexpr unsigned TSIE_MASK = 0x00008000;
static constexpr unsigned TSIE(unsigned value) { return (value << 15); }
static constexpr unsigned ADD1H_POS = 16;
static constexpr unsigned ADD1H_MASK = 0x00010000;
static constexpr unsigned ADD1H(unsigned value) { return (value << 16); }
static constexpr unsigned SUB1H_POS = 17;
static constexpr unsigned SUB1H_MASK = 0x00020000;
static constexpr unsigned SUB1H(unsigned value) { return (value << 17); }
static constexpr unsigned BKP_POS = 18;
static constexpr unsigned BKP_MASK = 0x00040000;
static constexpr unsigned BKP(unsigned value) { return (value << 18); }
static constexpr unsigned POL_POS = 20;
static constexpr unsigned POL_MASK = 0x00100000;
static constexpr unsigned POL(unsigned value) { return (value << 20); }
static constexpr unsigned OSEL_POS = 21;
static constexpr unsigned OSEL_MASK = 0x00600000;
static constexpr unsigned OSEL(unsigned value) { return (value << 21); }
static constexpr unsigned COE_POS = 23;
static constexpr unsigned COE_MASK = 0x00800000;
static constexpr unsigned COE(unsigned value) { return (value << 23); }
} CR;
volatile union ISR_T // ISR: initialization and status register
{
uint32_t reg;
struct __attribute__((packed)) ISR_BIT_T
{
unsigned ALRAWF : 1; // bit 0 Alarm A write flag
unsigned ALRBWF : 1; // bit 1 Alarm B write flag
unsigned WUTWF : 1; // bit 2 Wakeup timer write flag
unsigned SHPF : 1; // bit 3 Shift operation pending
unsigned INITS : 1; // bit 4 Initialization status flag
unsigned RSF : 1; // bit 5 Registers synchronization flag
unsigned INITF : 1; // bit 6 Initialization flag
unsigned INIT : 1; // bit 7 Initialization mode
unsigned ALRAF : 1; // bit 8 Alarm A flag
unsigned ALRBF : 1; // bit 9 Alarm B flag
unsigned WUTF : 1; // bit 10 Wakeup timer flag
unsigned TSF : 1; // bit 11 Time-stamp flag
unsigned TSOVF : 1; // bit 12 Time-stamp overflow flag
unsigned TAMP1F : 1; // bit 13 Tamper detection flag
unsigned TAMP2F : 1; // bit 14 TAMPER2 detection flag
unsigned : 1; // bit 15 unused
unsigned RECALPF : 1; // bit 16 Recalibration pending Flag
unsigned : 15; // bits 17..31 unused
} bit;
static constexpr unsigned ALRAWF_POS = 0;
static constexpr unsigned ALRAWF_MASK = 0x00000001;
static constexpr unsigned ALRAWF(unsigned value) { return (value << 0); }
static constexpr unsigned ALRBWF_POS = 1;
static constexpr unsigned ALRBWF_MASK = 0x00000002;
static constexpr unsigned ALRBWF(unsigned value) { return (value << 1); }
static constexpr unsigned WUTWF_POS = 2;
static constexpr unsigned WUTWF_MASK = 0x00000004;
static constexpr unsigned WUTWF(unsigned value) { return (value << 2); }
static constexpr unsigned SHPF_POS = 3;
static constexpr unsigned SHPF_MASK = 0x00000008;
static constexpr unsigned SHPF(unsigned value) { return (value << 3); }
static constexpr unsigned INITS_POS = 4;
static constexpr unsigned INITS_MASK = 0x00000010;
static constexpr unsigned INITS(unsigned value) { return (value << 4); }
static constexpr unsigned RSF_POS = 5;
static constexpr unsigned RSF_MASK = 0x00000020;
static constexpr unsigned RSF(unsigned value) { return (value << 5); }
static constexpr unsigned INITF_POS = 6;
static constexpr unsigned INITF_MASK = 0x00000040;
static constexpr unsigned INITF(unsigned value) { return (value << 6); }
static constexpr unsigned INIT_POS = 7;
static constexpr unsigned INIT_MASK = 0x00000080;
static constexpr unsigned INIT(unsigned value) { return (value << 7); }
static constexpr unsigned ALRAF_POS = 8;
static constexpr unsigned ALRAF_MASK = 0x00000100;
static constexpr unsigned ALRAF(unsigned value) { return (value << 8); }
static constexpr unsigned ALRBF_POS = 9;
static constexpr unsigned ALRBF_MASK = 0x00000200;
static constexpr unsigned ALRBF(unsigned value) { return (value << 9); }
static constexpr unsigned WUTF_POS = 10;
static constexpr unsigned WUTF_MASK = 0x00000400;
static constexpr unsigned WUTF(unsigned value) { return (value << 10); }
static constexpr unsigned TSF_POS = 11;
static constexpr unsigned TSF_MASK = 0x00000800;
static constexpr unsigned TSF(unsigned value) { return (value << 11); }
static constexpr unsigned TSOVF_POS = 12;
static constexpr unsigned TSOVF_MASK = 0x00001000;
static constexpr unsigned TSOVF(unsigned value) { return (value << 12); }
static constexpr unsigned TAMP1F_POS = 13;
static constexpr unsigned TAMP1F_MASK = 0x00002000;
static constexpr unsigned TAMP1F(unsigned value) { return (value << 13); }
static constexpr unsigned TAMP2F_POS = 14;
static constexpr unsigned TAMP2F_MASK = 0x00004000;
static constexpr unsigned TAMP2F(unsigned value) { return (value << 14); }
static constexpr unsigned RECALPF_POS = 16;
static constexpr unsigned RECALPF_MASK = 0x00010000;
static constexpr unsigned RECALPF(unsigned value) { return (value << 16); }
} ISR;
volatile union PRER_T // PRER: prescaler register
{
uint32_t reg;
struct __attribute__((packed)) PRER_BIT_T
{
unsigned PREDIV_S : 15; // bits 0..14 Synchronous prescaler factor
unsigned : 1; // bit 15 unused
unsigned PREDIV_A : 7; // bits 16..22 Asynchronous prescaler factor
unsigned : 9; // bits 23..31 unused
} bit;
static constexpr unsigned PREDIV_S_POS = 0;
static constexpr unsigned PREDIV_S_MASK = 0x00007fff;
static constexpr unsigned PREDIV_S(unsigned value) { return (value << 0); }
static constexpr unsigned PREDIV_A_POS = 16;
static constexpr unsigned PREDIV_A_MASK = 0x007f0000;
static constexpr unsigned PREDIV_A(unsigned value) { return (value << 16); }
} PRER;
volatile union WUTR_T // WUTR: wakeup timer register
{
uint32_t reg;
struct __attribute__((packed)) WUTR_BIT_T
{
unsigned WUT : 16; // bits 0..15 Wakeup auto-reload value bits
unsigned : 16; // bits 16..31 unused
} bit;
static constexpr unsigned WUT_POS = 0;
static constexpr unsigned WUT_MASK = 0x0000ffff;
static constexpr unsigned WUT(unsigned value) { return (value << 0); }
} WUTR;
volatile union CALIBR_T // CALIBR: calibration register
{
uint32_t reg;
struct __attribute__((packed)) CALIBR_BIT_T
{
unsigned DC : 5; // bits 0..4 Digital calibration
unsigned : 2; // bits 5..6 unused
unsigned DCS : 1; // bit 7 Digital calibration sign
unsigned : 24; // bits 8..31 unused
} bit;
static constexpr unsigned DC_POS = 0;
static constexpr unsigned DC_MASK = 0x0000001f;
static constexpr unsigned DC(unsigned value) { return (value << 0); }
static constexpr unsigned DCS_POS = 7;
static constexpr unsigned DCS_MASK = 0x00000080;
static constexpr unsigned DCS(unsigned value) { return (value << 7); }
} CALIBR;
volatile union ALRMAR_T // ALRMAR: alarm A register
{
uint32_t reg;
struct __attribute__((packed)) ALRMAR_BIT_T
{
unsigned SU : 4; // bits 0..3 Second units in BCD format
unsigned ST : 3; // bits 4..6 Second tens in BCD format
unsigned MSK1 : 1; // bit 7 Alarm A seconds mask
unsigned MNU : 4; // bits 8..11 Minute units in BCD format
unsigned MNT : 3; // bits 12..14 Minute tens in BCD format
unsigned MSK2 : 1; // bit 15 Alarm A minutes mask
unsigned HU : 4; // bits 16..19 Hour units in BCD format
unsigned HT : 2; // bits 20..21 Hour tens in BCD format
unsigned PM : 1; // bit 22 AM/PM notation
unsigned MSK3 : 1; // bit 23 Alarm A hours mask
unsigned DU : 4; // bits 24..27 Date units or day in BCD format
unsigned DT : 2; // bits 28..29 Date tens in BCD format
unsigned WDSEL : 1; // bit 30 Week day selection
unsigned MSK4 : 1; // bit 31 Alarm A date mask
} bit;
static constexpr unsigned SU_POS = 0;
static constexpr unsigned SU_MASK = 0x0000000f;
static constexpr unsigned SU(unsigned value) { return (value << 0); }
static constexpr unsigned ST_POS = 4;
static constexpr unsigned ST_MASK = 0x00000070;
static constexpr unsigned ST(unsigned value) { return (value << 4); }
static constexpr unsigned MSK1_POS = 7;
static constexpr unsigned MSK1_MASK = 0x00000080;
static constexpr unsigned MSK1(unsigned value) { return (value << 7); }
static constexpr unsigned MNU_POS = 8;
static constexpr unsigned MNU_MASK = 0x00000f00;
static constexpr unsigned MNU(unsigned value) { return (value << 8); }
static constexpr unsigned MNT_POS = 12;
static constexpr unsigned MNT_MASK = 0x00007000;
static constexpr unsigned MNT(unsigned value) { return (value << 12); }
static constexpr unsigned MSK2_POS = 15;
static constexpr unsigned MSK2_MASK = 0x00008000;
static constexpr unsigned MSK2(unsigned value) { return (value << 15); }
static constexpr unsigned HU_POS = 16;
static constexpr unsigned HU_MASK = 0x000f0000;
static constexpr unsigned HU(unsigned value) { return (value << 16); }
static constexpr unsigned HT_POS = 20;
static constexpr unsigned HT_MASK = 0x00300000;
static constexpr unsigned HT(unsigned value) { return (value << 20); }
static constexpr unsigned PM_POS = 22;
static constexpr unsigned PM_MASK = 0x00400000;
static constexpr unsigned PM(unsigned value) { return (value << 22); }
static constexpr unsigned MSK3_POS = 23;
static constexpr unsigned MSK3_MASK = 0x00800000;
static constexpr unsigned MSK3(unsigned value) { return (value << 23); }
static constexpr unsigned DU_POS = 24;
static constexpr unsigned DU_MASK = 0x0f000000;
static constexpr unsigned DU(unsigned value) { return (value << 24); }
static constexpr unsigned DT_POS = 28;
static constexpr unsigned DT_MASK = 0x30000000;
static constexpr unsigned DT(unsigned value) { return (value << 28); }
static constexpr unsigned WDSEL_POS = 30;
static constexpr unsigned WDSEL_MASK = 0x40000000;
static constexpr unsigned WDSEL(unsigned value) { return (value << 30); }
static constexpr unsigned MSK4_POS = 31;
static constexpr unsigned MSK4_MASK = 0x80000000;
static constexpr unsigned MSK4(unsigned value) { return (value << 31); }
} ALRMAR;
volatile union ALRMBR_T // ALRMBR: alarm B register
{
uint32_t reg;
struct __attribute__((packed)) ALRMBR_BIT_T
{
unsigned SU : 4; // bits 0..3 Second units in BCD format
unsigned ST : 3; // bits 4..6 Second tens in BCD format
unsigned MSK1 : 1; // bit 7 Alarm B seconds mask
unsigned MNU : 4; // bits 8..11 Minute units in BCD format
unsigned MNT : 3; // bits 12..14 Minute tens in BCD format
unsigned MSK2 : 1; // bit 15 Alarm B minutes mask
unsigned HU : 4; // bits 16..19 Hour units in BCD format
unsigned HT : 2; // bits 20..21 Hour tens in BCD format
unsigned PM : 1; // bit 22 AM/PM notation
unsigned MSK3 : 1; // bit 23 Alarm B hours mask
unsigned DU : 4; // bits 24..27 Date units or day in BCD format
unsigned DT : 2; // bits 28..29 Date tens in BCD format
unsigned WDSEL : 1; // bit 30 Week day selection
unsigned MSK4 : 1; // bit 31 Alarm B date mask
} bit;
static constexpr unsigned SU_POS = 0;
static constexpr unsigned SU_MASK = 0x0000000f;
static constexpr unsigned SU(unsigned value) { return (value << 0); }
static constexpr unsigned ST_POS = 4;
static constexpr unsigned ST_MASK = 0x00000070;
static constexpr unsigned ST(unsigned value) { return (value << 4); }
static constexpr unsigned MSK1_POS = 7;
static constexpr unsigned MSK1_MASK = 0x00000080;
static constexpr unsigned MSK1(unsigned value) { return (value << 7); }
static constexpr unsigned MNU_POS = 8;
static constexpr unsigned MNU_MASK = 0x00000f00;
static constexpr unsigned MNU(unsigned value) { return (value << 8); }
static constexpr unsigned MNT_POS = 12;
static constexpr unsigned MNT_MASK = 0x00007000;
static constexpr unsigned MNT(unsigned value) { return (value << 12); }
static constexpr unsigned MSK2_POS = 15;
static constexpr unsigned MSK2_MASK = 0x00008000;
static constexpr unsigned MSK2(unsigned value) { return (value << 15); }
static constexpr unsigned HU_POS = 16;
static constexpr unsigned HU_MASK = 0x000f0000;
static constexpr unsigned HU(unsigned value) { return (value << 16); }
static constexpr unsigned HT_POS = 20;
static constexpr unsigned HT_MASK = 0x00300000;
static constexpr unsigned HT(unsigned value) { return (value << 20); }
static constexpr unsigned PM_POS = 22;
static constexpr unsigned PM_MASK = 0x00400000;
static constexpr unsigned PM(unsigned value) { return (value << 22); }
static constexpr unsigned MSK3_POS = 23;
static constexpr unsigned MSK3_MASK = 0x00800000;
static constexpr unsigned MSK3(unsigned value) { return (value << 23); }
static constexpr unsigned DU_POS = 24;
static constexpr unsigned DU_MASK = 0x0f000000;
static constexpr unsigned DU(unsigned value) { return (value << 24); }
static constexpr unsigned DT_POS = 28;
static constexpr unsigned DT_MASK = 0x30000000;
static constexpr unsigned DT(unsigned value) { return (value << 28); }
static constexpr unsigned WDSEL_POS = 30;
static constexpr unsigned WDSEL_MASK = 0x40000000;
static constexpr unsigned WDSEL(unsigned value) { return (value << 30); }
static constexpr unsigned MSK4_POS = 31;
static constexpr unsigned MSK4_MASK = 0x80000000;
static constexpr unsigned MSK4(unsigned value) { return (value << 31); }
} ALRMBR;
volatile union WPR_T // WPR: write protection register
{
uint32_t reg;
struct __attribute__((packed)) WPR_BIT_T
{
unsigned KEY : 8; // bits 0..7 Write protection key
unsigned : 24; // bits 8..31 unused
} bit;
static constexpr unsigned KEY_POS = 0;
static constexpr unsigned KEY_MASK = 0x000000ff;
static constexpr unsigned KEY(unsigned value) { return (value << 0); }
} WPR;
volatile union SSR_T // SSR: sub second register
{
uint32_t reg;
struct __attribute__((packed)) SSR_BIT_T
{
unsigned SS : 16; // bits 0..15 Sub second value
unsigned : 16; // bits 16..31 unused
} bit;
static constexpr unsigned SS_POS = 0;
static constexpr unsigned SS_MASK = 0x0000ffff;
static constexpr unsigned SS(unsigned value) { return (value << 0); }
} SSR;
volatile union SHIFTR_T // SHIFTR: shift control register
{
uint32_t reg;
struct __attribute__((packed)) SHIFTR_BIT_T
{
unsigned SUBFS : 15; // bits 0..14 Subtract a fraction of a second
unsigned : 16; // bits 15..30 unused
unsigned ADD1S : 1; // bit 31 Add one second
} bit;
static constexpr unsigned SUBFS_POS = 0;
static constexpr unsigned SUBFS_MASK = 0x00007fff;
static constexpr unsigned SUBFS(unsigned value) { return (value << 0); }
static constexpr unsigned ADD1S_POS = 31;
static constexpr unsigned ADD1S_MASK = 0x80000000;
static constexpr unsigned ADD1S(unsigned value) { return (value << 31); }
} SHIFTR;
volatile union TSTR_T // TSTR: time stamp time register
{
uint32_t reg;
struct __attribute__((packed)) TSTR_BIT_T
{
unsigned TAMP1E : 1; // bit 0 Tamper 1 detection enable
unsigned TAMP1TRG : 1; // bit 1 Active level for tamper 1
unsigned TAMPIE : 1; // bit 2 Tamper interrupt enable
unsigned : 13; // bits 3..15 unused
unsigned TAMP1INSEL : 1; // bit 16 TAMPER1 mapping
unsigned TSINSEL : 1; // bit 17 TIMESTAMP mapping
unsigned ALARMOUTTYPE : 1; // bit 18 AFO_ALARM output type
unsigned : 13; // bits 19..31 unused
} bit;
static constexpr unsigned TAMP1E_POS = 0;
static constexpr unsigned TAMP1E_MASK = 0x00000001;
static constexpr unsigned TAMP1E(unsigned value) { return (value << 0); }
static constexpr unsigned TAMP1TRG_POS = 1;
static constexpr unsigned TAMP1TRG_MASK = 0x00000002;
static constexpr unsigned TAMP1TRG(unsigned value) { return (value << 1); }
static constexpr unsigned TAMPIE_POS = 2;
static constexpr unsigned TAMPIE_MASK = 0x00000004;
static constexpr unsigned TAMPIE(unsigned value) { return (value << 2); }
static constexpr unsigned TAMP1INSEL_POS = 16;
static constexpr unsigned TAMP1INSEL_MASK = 0x00010000;
static constexpr unsigned TAMP1INSEL(unsigned value) { return (value << 16); }
static constexpr unsigned TSINSEL_POS = 17;
static constexpr unsigned TSINSEL_MASK = 0x00020000;
static constexpr unsigned TSINSEL(unsigned value) { return (value << 17); }
static constexpr unsigned ALARMOUTTYPE_POS = 18;
static constexpr unsigned ALARMOUTTYPE_MASK = 0x00040000;
static constexpr unsigned ALARMOUTTYPE(unsigned value) { return (value << 18); }
} TSTR;
volatile union TSDR_T // TSDR: time stamp date register
{
uint32_t reg;
struct __attribute__((packed)) TSDR_BIT_T
{
unsigned DU : 4; // bits 0..3 Date units in BCD format
unsigned DT : 2; // bits 4..5 Date tens in BCD format
unsigned : 2; // bits 6..7 unused
unsigned MU : 4; // bits 8..11 Month units in BCD format
unsigned MT : 1; // bit 12 Month tens in BCD format
unsigned WDU : 3; // bits 13..15 Week day units
unsigned : 16; // bits 16..31 unused
} bit;
static constexpr unsigned DU_POS = 0;
static constexpr unsigned DU_MASK = 0x0000000f;
static constexpr unsigned DU(unsigned value) { return (value << 0); }
static constexpr unsigned DT_POS = 4;
static constexpr unsigned DT_MASK = 0x00000030;
static constexpr unsigned DT(unsigned value) { return (value << 4); }
static constexpr unsigned MU_POS = 8;
static constexpr unsigned MU_MASK = 0x00000f00;
static constexpr unsigned MU(unsigned value) { return (value << 8); }
static constexpr unsigned MT_POS = 12;
static constexpr unsigned MT_MASK = 0x00001000;
static constexpr unsigned MT(unsigned value) { return (value << 12); }
static constexpr unsigned WDU_POS = 13;
static constexpr unsigned WDU_MASK = 0x0000e000;
static constexpr unsigned WDU(unsigned value) { return (value << 13); }
} TSDR;
volatile union TSSSR_T // TSSSR: timestamp sub second register
{
uint32_t reg;
struct __attribute__((packed)) TSSSR_BIT_T
{
unsigned SS : 16; // bits 0..15 Sub second value
unsigned : 16; // bits 16..31 unused
} bit;
static constexpr unsigned SS_POS = 0;
static constexpr unsigned SS_MASK = 0x0000ffff;
static constexpr unsigned SS(unsigned value) { return (value << 0); }
} TSSSR;
volatile union CALR_T // CALR: calibration register
{
uint32_t reg;
struct __attribute__((packed)) CALR_BIT_T
{
unsigned CALM : 9; // bits 0..8 Calibration minus
unsigned : 4; // bits 9..12 unused
unsigned CALW16 : 1; // bit 13 Use a 16-second calibration cycle period
unsigned CALW8 : 1; // bit 14 Use an 8-second calibration cycle period
unsigned CALP : 1; // bit 15 Increase frequency of RTC by 488.5 ppm
unsigned : 16; // bits 16..31 unused
} bit;
static constexpr unsigned CALM_POS = 0;
static constexpr unsigned CALM_MASK = 0x000001ff;
static constexpr unsigned CALM(unsigned value) { return (value << 0); }
static constexpr unsigned CALW16_POS = 13;
static constexpr unsigned CALW16_MASK = 0x00002000;
static constexpr unsigned CALW16(unsigned value) { return (value << 13); }
static constexpr unsigned CALW8_POS = 14;
static constexpr unsigned CALW8_MASK = 0x00004000;
static constexpr unsigned CALW8(unsigned value) { return (value << 14); }
static constexpr unsigned CALP_POS = 15;
static constexpr unsigned CALP_MASK = 0x00008000;
static constexpr unsigned CALP(unsigned value) { return (value << 15); }
} CALR;
volatile union TAFCR_T // TAFCR: tamper and alternate function configuration register
{
uint32_t reg;
struct __attribute__((packed)) TAFCR_BIT_T
{
unsigned TAMP1E : 1; // bit 0 Tamper 1 detection enable
unsigned TAMP1TRG : 1; // bit 1 Active level for tamper 1
unsigned TAMPIE : 1; // bit 2 Tamper interrupt enable
unsigned TAMP2E : 1; // bit 3 Tamper 2 detection enable
unsigned TAMP2TRG : 1; // bit 4 Active level for tamper 2
unsigned : 2; // bits 5..6 unused
unsigned TAMPTS : 1; // bit 7 Activate timestamp on tamper detection event
unsigned TAMPFREQ : 3; // bits 8..10 Tamper sampling frequency
unsigned TAMPFLT : 2; // bits 11..12 Tamper filter count
unsigned TAMPPRCH : 2; // bits 13..14 Tamper precharge duration
unsigned TAMPPUDIS : 1; // bit 15 TAMPER pull-up disable
unsigned TAMP1INSEL : 1; // bit 16 TAMPER1 mapping
unsigned TSINSEL : 1; // bit 17 TIMESTAMP mapping
unsigned ALARMOUTTYPE : 1; // bit 18 AFO_ALARM output type
unsigned : 13; // bits 19..31 unused
} bit;
static constexpr unsigned TAMP1E_POS = 0;
static constexpr unsigned TAMP1E_MASK = 0x00000001;
static constexpr unsigned TAMP1E(unsigned value) { return (value << 0); }
static constexpr unsigned TAMP1TRG_POS = 1;
static constexpr unsigned TAMP1TRG_MASK = 0x00000002;
static constexpr unsigned TAMP1TRG(unsigned value) { return (value << 1); }
static constexpr unsigned TAMPIE_POS = 2;
static constexpr unsigned TAMPIE_MASK = 0x00000004;
static constexpr unsigned TAMPIE(unsigned value) { return (value << 2); }
static constexpr unsigned TAMP2E_POS = 3;
static constexpr unsigned TAMP2E_MASK = 0x00000008;
static constexpr unsigned TAMP2E(unsigned value) { return (value << 3); }
static constexpr unsigned TAMP2TRG_POS = 4;
static constexpr unsigned TAMP2TRG_MASK = 0x00000010;
static constexpr unsigned TAMP2TRG(unsigned value) { return (value << 4); }
static constexpr unsigned TAMPTS_POS = 7;
static constexpr unsigned TAMPTS_MASK = 0x00000080;
static constexpr unsigned TAMPTS(unsigned value) { return (value << 7); }
static constexpr unsigned TAMPFREQ_POS = 8;
static constexpr unsigned TAMPFREQ_MASK = 0x00000700;
static constexpr unsigned TAMPFREQ(unsigned value) { return (value << 8); }
static constexpr unsigned TAMPFLT_POS = 11;
static constexpr unsigned TAMPFLT_MASK = 0x00001800;
static constexpr unsigned TAMPFLT(unsigned value) { return (value << 11); }
static constexpr unsigned TAMPPRCH_POS = 13;
static constexpr unsigned TAMPPRCH_MASK = 0x00006000;
static constexpr unsigned TAMPPRCH(unsigned value) { return (value << 13); }
static constexpr unsigned TAMPPUDIS_POS = 15;
static constexpr unsigned TAMPPUDIS_MASK = 0x00008000;
static constexpr unsigned TAMPPUDIS(unsigned value) { return (value << 15); }
static constexpr unsigned TAMP1INSEL_POS = 16;
static constexpr unsigned TAMP1INSEL_MASK = 0x00010000;
static constexpr unsigned TAMP1INSEL(unsigned value) { return (value << 16); }
static constexpr unsigned TSINSEL_POS = 17;
static constexpr unsigned TSINSEL_MASK = 0x00020000;
static constexpr unsigned TSINSEL(unsigned value) { return (value << 17); }
static constexpr unsigned ALARMOUTTYPE_POS = 18;
static constexpr unsigned ALARMOUTTYPE_MASK = 0x00040000;
static constexpr unsigned ALARMOUTTYPE(unsigned value) { return (value << 18); }
} TAFCR;
volatile union ALRMASSR_T // ALRMASSR: alarm A sub second register
{
uint32_t reg;
struct __attribute__((packed)) ALRMASSR_BIT_T
{
unsigned SS : 15; // bits 0..14 Sub seconds value
unsigned : 9; // bits 15..23 unused
unsigned MASKSS : 4; // bits 24..27 Mask the most-significant bits starting at this bit
unsigned : 4; // bits 28..31 unused
} bit;
static constexpr unsigned SS_POS = 0;
static constexpr unsigned SS_MASK = 0x00007fff;
static constexpr unsigned SS(unsigned value) { return (value << 0); }
static constexpr unsigned MASKSS_POS = 24;
static constexpr unsigned MASKSS_MASK = 0x0f000000;
static constexpr unsigned MASKSS(unsigned value) { return (value << 24); }
} ALRMASSR;
volatile union ALRMBSSR_T // ALRMBSSR: alarm B sub second register
{
uint32_t reg;
struct __attribute__((packed)) ALRMBSSR_BIT_T
{
unsigned SS : 15; // bits 0..14 Sub seconds value
unsigned : 9; // bits 15..23 unused
unsigned MASKSS : 4; // bits 24..27 Mask the most-significant bits starting at this bit
unsigned : 4; // bits 28..31 unused
} bit;
static constexpr unsigned SS_POS = 0;
static constexpr unsigned SS_MASK = 0x00007fff;
static constexpr unsigned SS(unsigned value) { return (value << 0); }
static constexpr unsigned MASKSS_POS = 24;
static constexpr unsigned MASKSS_MASK = 0x0f000000;
static constexpr unsigned MASKSS(unsigned value) { return (value << 24); }
} ALRMBSSR;
uint8_t Reserved1[4];
volatile union BKP0R_T // BKP0R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP0R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP0R;
volatile union BKP1R_T // BKP1R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP1R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP1R;
volatile union BKP2R_T // BKP2R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP2R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP2R;
volatile union BKP3R_T // BKP3R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP3R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP3R;
volatile union BKP4R_T // BKP4R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP4R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP4R;
volatile union BKP5R_T // BKP5R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP5R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP5R;
volatile union BKP6R_T // BKP6R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP6R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP6R;
volatile union BKP7R_T // BKP7R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP7R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP7R;
volatile union BKP8R_T // BKP8R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP8R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP8R;
volatile union BKP9R_T // BKP9R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP9R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP9R;
volatile union BKP10R_T // BKP10R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP10R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP10R;
volatile union BKP11R_T // BKP11R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP11R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP11R;
volatile union BKP12R_T // BKP12R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP12R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP12R;
volatile union BKP13R_T // BKP13R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP13R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP13R;
volatile union BKP14R_T // BKP14R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP14R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP14R;
volatile union BKP15R_T // BKP15R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP15R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP15R;
volatile union BKP16R_T // BKP16R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP16R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP16R;
volatile union BKP17R_T // BKP17R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP17R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP17R;
volatile union BKP18R_T // BKP18R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP18R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP18R;
volatile union BKP19R_T // BKP19R: backup register
{
uint32_t reg;
struct __attribute__((packed)) BKP19R_BIT_T
{
unsigned BKP : 32; // bits 0..31 BKP
} bit;
static constexpr unsigned BKP_POS = 0;
static constexpr unsigned BKP_MASK = 0xffffffff;
static constexpr unsigned BKP(unsigned value) { return (value << 0); }
} BKP19R;
}; // struct RTC_T
static_assert(sizeof(RTC_T) == RTC_T::PADDED_INSTANCE_SIZE, "invalid peripheral register struct");
} // namespace Peripherals
} // namespace LibreUCpp | 46.808 | 99 | 0.627884 |
0c07ac7b0a73cf8099893250352ab13c36877235 | 267 | h | C | include/ismcts/tree/policies.h | sfranzen/ismcsolver | efeccdc691d5fca9c539071e733204ceee3c25ca | [
"MIT"
] | 10 | 2019-04-02T14:46:19.000Z | 2022-03-01T00:07:21.000Z | include/ismcts/tree/policies.h | sfranzen/ismcsolver | efeccdc691d5fca9c539071e733204ceee3c25ca | [
"MIT"
] | 9 | 2019-04-18T19:57:47.000Z | 2019-08-12T20:05:13.000Z | include/ismcts/tree/policies.h | sfranzen/ismcsolver | efeccdc691d5fca9c539071e733204ceee3c25ca | [
"MIT"
] | 1 | 2020-10-31T20:54:44.000Z | 2020-10-31T20:54:44.000Z | /*
* Copyright (C) 2019 Steven Franzen <sfranzen85@gmail.com>
* This file is subject to the terms of the MIT License; see the LICENSE file in
* the root directory of this distribution.
*/
#include "exp3.h"
#include "ucb1.h"
#include "d_ucb.h"
#include "sw_ucb.h"
| 26.7 | 80 | 0.715356 |
0c07d33da748a81f6d52d338a2814a4b40c727e2 | 466 | h | C | FuelMeDriver/FuelMeDriver/Classes/ViewControllers/Add Car/DriverCarDetailsViewController.h | ride-austin/ios-driver | a6f61487fbca2460bb19c78e6d40f03493593e66 | [
"MIT"
] | 3 | 2020-07-25T21:10:30.000Z | 2020-12-03T05:14:17.000Z | FuelMeDriver/FuelMeDriver/Classes/ViewControllers/Add Car/DriverCarDetailsViewController.h | ride-austin/ios-driver | a6f61487fbca2460bb19c78e6d40f03493593e66 | [
"MIT"
] | null | null | null | FuelMeDriver/FuelMeDriver/Classes/ViewControllers/Add Car/DriverCarDetailsViewController.h | ride-austin/ios-driver | a6f61487fbca2460bb19c78e6d40f03493593e66 | [
"MIT"
] | 7 | 2020-06-16T20:45:07.000Z | 2021-06-06T18:09:27.000Z | //
// DriverCarDetailsViewController.h
// Ride
//
// Created by Abdul Rehman on 16/05/2016.
// Copyright © 2016 RideAustin.com. All rights reserved.
//
#import "BaseDocumentViewController.h"
#import "Car.h"
@interface DriverCarDetailsViewController : BaseDocumentViewController
@property(nonatomic,strong) IBOutlet UITextView *carDescription;
- (id)initWithUserData:(NSMutableDictionary*)userData andRegistrationConfig:(ConfigRegistration *)regConfig;
@end
| 24.526316 | 108 | 0.787554 |
0c0b7456214810d072e995a302cd2a4d11bb941a | 473 | h | C | Example/Pods/Target Support Files/CMLibrary/CMLibrary-umbrella.h | adityaaggarwal1/CMLibrary | b2ac7397c450fd6e5a6db7f1af88ab65ed249f74 | [
"MIT"
] | 2 | 2015-09-23T16:38:08.000Z | 2015-10-07T09:25:52.000Z | Example/Pods/Target Support Files/CMLibrary/CMLibrary-umbrella.h | adityaaggarwal1/CMLibrary | b2ac7397c450fd6e5a6db7f1af88ab65ed249f74 | [
"MIT"
] | null | null | null | Example/Pods/Target Support Files/CMLibrary/CMLibrary-umbrella.h | adityaaggarwal1/CMLibrary | b2ac7397c450fd6e5a6db7f1af88ab65ed249f74 | [
"MIT"
] | null | null | null | #import <UIKit/UIKit.h>
#import "CacheModel.h"
#import "CacheManager.h"
#import "CMLibraryConstants.h"
#import "Loader.h"
#import "AsyncImageView.h"
#import "ProgressView.h"
#import "Reachability.h"
#import "CMLibraryUtility.h"
#import "WebserviceCall.h"
#import "WebserviceResponse.h"
#import "XMLDictionary.h"
#import "AuthToken.h"
#import "FXKeychain.h"
FOUNDATION_EXPORT double CMLibraryVersionNumber;
FOUNDATION_EXPORT const unsigned char CMLibraryVersionString[];
| 23.65 | 63 | 0.788584 |
0c0c06a23110ee06cfeadba1ce6cc7115cd42adb | 2,419 | h | C | cmd/starter/c/include/message.h | ShamrockLee/apptainer | ae6e3946acbff47e6767aca015ea5001170b5a4f | [
"Apache-2.0"
] | 188 | 2021-11-30T14:37:03.000Z | 2022-03-31T11:19:16.000Z | cmd/starter/c/include/message.h | ShamrockLee/apptainer | ae6e3946acbff47e6767aca015ea5001170b5a4f | [
"Apache-2.0"
] | 180 | 2021-11-30T14:51:15.000Z | 2022-03-31T23:00:29.000Z | cmd/starter/c/include/message.h | ShamrockLee/apptainer | ae6e3946acbff47e6767aca015ea5001170b5a4f | [
"Apache-2.0"
] | 42 | 2021-11-30T13:49:26.000Z | 2022-03-29T08:22:50.000Z | /*
* Copyright (c) Contributors to the Apptainer project, established as
* Apptainer a Series of LF Projects LLC.
* For website terms of use, trademark policy, privacy policy and other
* project policies see https://lfprojects.org/policies
* Copyright (c) 2017-2019, SyLabs, Inc. All rights reserved.
*
* Copyright (c) 2016-2017, The Regents of the University of California,
* through Lawrence Berkeley National Laboratory (subject to receipt of any
* required approvals from the U.S. Dept. of Energy). All rights reserved.
*
* This software is licensed under a customized 3-clause BSD license. Please
* consult LICENSE.md file distributed with the sources of this project regarding
* your rights to use or distribute this software.
*
* NOTICE. This Software was developed under funding from the U.S. Department of
* Energy and the U.S. Government consequently retains certain rights. As such,
* the U.S. Government has been granted for itself and others acting on its
* behalf a paid-up, nonexclusive, irrevocable, worldwide license in the Software
* to reproduce, distribute copies to the public, prepare derivative works, and
* perform publicly and display publicly, and to permit other to do so.
*/
#ifndef _APPTAINER_MESSAGE_H
#define _APPTAINER_MESSAGE_H
#define ABRT -4
#define ERROR -3
#define WARNING -2
#define LOG -1
#define INFO 1
#define VERBOSE 2
#define VERBOSE1 2
#define VERBOSE2 3
#define VERBOSE3 4
#define DEBUG 5
#define NO_COLOR 90
#define ANSI_COLOR_RED "\x1b[31m"
#define ANSI_COLOR_GREEN "\x1b[32m"
#define ANSI_COLOR_YELLOW "\x1b[33m"
#define ANSI_COLOR_BLUE "\x1b[34m"
#define ANSI_COLOR_MAGENTA "\x1b[35m"
#define ANSI_COLOR_CYAN "\x1b[36m"
#define ANSI_COLOR_GRAY "\x1b[37m"
#define ANSI_COLOR_LIGHTGRAY "\x1b[90m"
#define ANSI_COLOR_LIGHTRED "\x1b[91m"
#define ANSI_COLOR_LIGHTGREEN "\x1b[92m"
#define ANSI_COLOR_LIGHTYELLOW "\x1b[93m"
#define ANSI_COLOR_LIGHTBLUE "\x1b[94m"
#define ANSI_COLOR_LIGHTMAGENTA "\x1b[95m"
#define ANSI_COLOR_LIGHTCYAN "\x1b[96m"
#define ANSI_COLOR_RESET "\x1b[0m"
#define MSGLVL_ENV "APPTAINER_MESSAGELEVEL"
void _print(int level, const char *function, const char *file, char *format, ...) __attribute__ ((__format__(printf, 4, 5)));
#define apptainer_message(a,b...) _print(a, __func__, __FILE__, b)
#endif /*_APPTAINER_MESSAGE_H */
| 39.016129 | 125 | 0.737495 |
0c0ca7c0ab8686878990e1da520ff02515657161 | 1,006 | h | C | ShFlyKit/Classes/Map/BaiduMap/SDKs/BaiduMapAPI_Search.framework/Headers/BMKBusLineSearchResult.h | ihsh/SHFlyKit | f35a792d75f5d45d787f4e74b6cda359722f7092 | [
"MIT"
] | 7 | 2019-07-16T02:50:18.000Z | 2020-12-19T08:21:06.000Z | OC/Pods/BaiduMapKit/BaiduMapKit/BaiduMapAPI_Search.framework/Headers/BMKBusLineSearchResult.h | jamgzj/resourceObject | 6675662d80f675316ff2f89df0b29c499aeb6383 | [
"Apache-2.0"
] | 7 | 2020-07-17T14:33:41.000Z | 2022-02-26T14:20:32.000Z | OC/Pods/BaiduMapKit/BaiduMapKit/BaiduMapAPI_Search.framework/Headers/BMKBusLineSearchResult.h | jamgzj/resourceObject | 6675662d80f675316ff2f89df0b29c499aeb6383 | [
"Apache-2.0"
] | 4 | 2019-07-16T02:50:22.000Z | 2021-05-24T12:21:48.000Z | //
// BMKBusLineSearchResult.h
// BaiduMapAPI_Search
//
// Created by DanielBey on 2019/1/23.
// Copyright © 2019 Baidu. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "BMKRouteSearchType.h"
/// 公共交通路线查询结果类
@interface BMKBusLineResult : NSObject
/// 公交公司名称
@property (nonatomic, copy) NSString *busCompany;
/// 公交线路名称
@property (nonatomic, copy) NSString *busLineName;
/// 公交线路方向
@property (nonatomic, copy) NSString *busLineDirection;
/// 公交线路uid
@property (nonatomic, copy) NSString *uid;
/// 公交路线首班车时间
@property (nonatomic, copy) NSString *startTime;
/// 公交路线末班车时间
@property (nonatomic, copy) NSString *endTime;
/// 公交路线是否有月票
@property (nonatomic, assign) int isMonTicket;
/// 起步票价
@property (nonatomic, assign) CGFloat basicPrice;
/// 全程票价
@property (nonatomic, assign) CGFloat totalPrice;
/// 所有公交站点信息,成员类型为BMKBusStation
@property (nonatomic, copy) NSArray <BMKBusStation *> *busStations;
/// 公交路线分段信息,成员类型为BMKBusStep
@property (nonatomic, copy) NSArray <BMKBusStep *> *busSteps;
@end
| 26.473684 | 67 | 0.741551 |
0c0cb81910bd6aa1dddd0d874b0387565c3592b2 | 990 | h | C | Category/Pods/Headers/Public/BeCategory/NSString+Pinyin.h | choseusername/Util | 12161faf34ca1c2f8ce4fc66b3454ab03d9b5f46 | [
"MIT"
] | null | null | null | Category/Pods/Headers/Public/BeCategory/NSString+Pinyin.h | choseusername/Util | 12161faf34ca1c2f8ce4fc66b3454ab03d9b5f46 | [
"MIT"
] | null | null | null | Category/Pods/Headers/Public/BeCategory/NSString+Pinyin.h | choseusername/Util | 12161faf34ca1c2f8ce4fc66b3454ab03d9b5f46 | [
"MIT"
] | null | null | null | //
// NSString+Pinyin.h
// base
//
// Created by wangshuguan on 15/6/13.
// Copyright (c) 2015年 wsg. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSString(Pinyin)
/*!
@brief 从字典源获取拼音 useage: NSLog(@"%@",[@"王书倌" pinyinFromSource:[[ShareHandle shareHandle] pinyinSourceDic]]);
@param sourceDictionary 源数据,一般是[[ShareHandle shareHandle] pinyinSourceDic]
@return 得到的拼音
*/
- (NSString *)pinyinFromSource:(NSDictionary *)sourceDictionary;
/**
* 拼音字符串
*
* @return 拼音
*/
-(NSString *)pinyin __deprecated_msg("该方法是系统方法的的拼音拓展,效率较慢,采用 pinyinFromSource:");
/**
* 拼音的第一个字符,相当于“我们”wm
*
*/
-(NSString *)pinyinFirstLettersWithSource:(NSDictionary *)sourceDictionary;
/**
* 字符串中的第几个字符
*
* @param index 字符的序列
*
* @return 字符串
*/
-(NSString *)stringAtIndex:(NSUInteger)index;
/**
* unicode转换成utf8格式的字符串
*
*/
-(NSString *)stringFromUnicode;
/**
* 第一个字符大写的方法
*
* @return 返回第一个字符大写,注意里面不能写中文
*/
-(NSString *)capitalizedFirstCharacterString;
@end
| 19.411765 | 109 | 0.693939 |
0c0ea1c4e1539f795c2146f403ea4f8f614e89a4 | 401 | h | C | BigShow1949/Classes/10 - UIKit/UIScrollView/MutableMenuTableView/RootViewController.h | Kssss/learnBox | 81fff48ca8422eab118ffbbb478011bea963f6e5 | [
"Apache-2.0"
] | 1 | 2017-05-03T07:44:30.000Z | 2017-05-03T07:44:30.000Z | BigShow1949/Classes/10 - UIKit/UIScrollView/MutableMenuTableView/RootViewController.h | Kssss/learnBox | 81fff48ca8422eab118ffbbb478011bea963f6e5 | [
"Apache-2.0"
] | null | null | null | BigShow1949/Classes/10 - UIKit/UIScrollView/MutableMenuTableView/RootViewController.h | Kssss/learnBox | 81fff48ca8422eab118ffbbb478011bea963f6e5 | [
"Apache-2.0"
] | null | null | null | //
// RootViewController.h
// MutableMenuTableView
//
// Created by 张国庆 on 16/4/27.
// Copyright © 2016年 zgq. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "MenuData.h"
#import "MenuItemCell.h"
#import "SecondViewController.h"
@interface RootViewController : UIViewController
@property (nonatomic,strong)NSIndexPath *myIndexPath;
@property (nonatomic,strong)MenuData *menuData;
@end
| 20.05 | 53 | 0.74813 |
0c10754bbfded5431ab1843e7cc74a05edcb7605 | 347 | h | C | programming/c/udp_socket/udp_socket.h | owalch/linux | faf6cc6381085d5b48e828cebdc476c21852b404 | [
"BSD-2-Clause"
] | null | null | null | programming/c/udp_socket/udp_socket.h | owalch/linux | faf6cc6381085d5b48e828cebdc476c21852b404 | [
"BSD-2-Clause"
] | null | null | null | programming/c/udp_socket/udp_socket.h | owalch/linux | faf6cc6381085d5b48e828cebdc476c21852b404 | [
"BSD-2-Clause"
] | null | null | null | /**
* @brief This module implements a simple UDP socket listener.
* @author Oliver Walch
* @date 2016-03-02
*/
#ifndef UDP_SOCKET_H_
#define UDP_SOCKET_H_
#ifdef __cplusplus
extern "C" {
#endif
#define UDP_PORT 18264 /* UDP port */
#define BUFSIZE 2048 /* Incomming buffer size */
#ifdef __cplusplus
}
#endif
#endif /* UDP_SOCKET_H_ */
| 16.52381 | 62 | 0.706052 |
0c11896b0aede1bc4f36b923c5c04322b78b1ec5 | 2,647 | h | C | util/RegExpParser.h | erikleitch/cpputil | 6dbd4bdbaaa60d911d166b68fdad6af6afd04963 | [
"MIT"
] | 1 | 2018-11-01T05:15:31.000Z | 2018-11-01T05:15:31.000Z | util/RegExpParser.h | erikleitch/cpputil | 6dbd4bdbaaa60d911d166b68fdad6af6afd04963 | [
"MIT"
] | null | null | null | util/RegExpParser.h | erikleitch/cpputil | 6dbd4bdbaaa60d911d166b68fdad6af6afd04963 | [
"MIT"
] | 2 | 2017-05-02T19:35:55.000Z | 2018-03-07T00:54:51.000Z | #ifndef GCP_UTIL_REGEXPPARSER_H
#define GCP_UTIL_REGEXPPARSER_H
/**
* @file RegExpParser.h
*
* Tagged: Sat Oct 2 16:22:41 UTC 2004
*
* @author
*/
#include <string>
namespace gcp {
namespace util {
class RegExpParser {
public:
/**
* Constructor with RegExp string
*/
RegExpParser(std::string regexp);
/**
* Destructor.
*/
virtual ~RegExpParser();
/**
* This is the top level matching routine. It returns true if
* the string in this RegExpParser matches the string, otherwise
* it returns false.
*/
bool matches(std::string matchString);
private:
// The reg exp string to match
std::string regExpString_;
// Utility pointer to the above
char* regExpPtr_;
// Private recursion method for matching a string
bool matches(char* matchString, bool incrementRegExpPtr=true);
/**
* Try to match a single character ch with a [] regexp character list.
* Return 1 on success, 0 on failure. Normally *was_error is returned
* as 0, but if there is a regexp syntax error it is returned as 1.
* The regexp can be formed of any arrangement of the following:
*
* A-Z : Any capital letter between the two characters provided.
* a-z : Any lower case letter between the two characters provided.
* 1-9 : Any digit between the numbers specified.
* adbc : Any charcter from the specified list.
* ^ : When placed before any of the above, the match will succede
* : if the character is not one of those specified. Characters
* : may be escaped to remove any special meanings or to include
* : control characters etc..
*/
bool matchSingle(char *start_ptr, char *end_ptr, char ch);
/**
* Given an input string, return either the first character or
* if that first character is a \ return the corresponding
* escaped character. If there is an error return '\0'. The
* pointer into the input string will be returned via the
* second argument, incremented to the point just after the
* last character used. The flag, 'wasEscaped' is returned as
* 1 if the returned character was an escape sequence, and 0
* otherwise.
*/
char getNextChar(char *string, char **tail, bool& wasEscaped);
}; // End class RegExpParser
} // End namespace util
} // End namespace gcp
#endif // End #ifndef GCP_UTIL_REGEXPPARSER_H
| 30.425287 | 76 | 0.613525 |
0c11badd2473556b6aa0b589fb5b8479459d3013 | 914 | h | C | Include/Protocol/KeypadDevice.h | yifengling0/Lumia950XLPkg | 307dabfd577db31ce4e3b0bbd53ec8f0bd58471a | [
"BSD-2-Clause"
] | 11 | 2015-09-12T15:50:39.000Z | 2021-07-31T21:37:51.000Z | Include/Protocol/KeypadDevice.h | yifengling0/Lumia950XLPkg | 307dabfd577db31ce4e3b0bbd53ec8f0bd58471a | [
"BSD-2-Clause"
] | 1 | 2018-04-29T14:10:54.000Z | 2018-04-29T14:10:54.000Z | Include/Protocol/KeypadDevice.h | yifengling0/Lumia950XLPkg | 307dabfd577db31ce4e3b0bbd53ec8f0bd58471a | [
"BSD-2-Clause"
] | 5 | 2017-09-19T02:45:10.000Z | 2020-10-30T04:12:04.000Z | #ifndef __PROTOCOL_KEYPAD_DEVICE_H__
#define __PROTOCOL_KEYPAD_DEVICE_H__
#include <Protocol/SimpleTextInEx.h>
#define KEYPAD_DEVICE_PROTOCOL_GUID \
{ 0xb27625b5, 0x0b6c, 0x4614, { 0xaa, 0x3c, 0x33, 0x13, 0xb5, 0x1d, 0x36, 0x46 } }
typedef struct _KEYPAD_DEVICE_PROTOCOL KEYPAD_DEVICE_PROTOCOL;
typedef struct _KEYPAD_RETURN_API KEYPAD_RETURN_API;
typedef VOID (EFIAPI *PUSH_EFI_KEY_BUF_TAIL) (KEYPAD_RETURN_API *This, EFI_KEY_DATA *KeyData);
struct _KEYPAD_RETURN_API {
PUSH_EFI_KEY_BUF_TAIL PushEfikeyBufTail;
};
typedef EFI_STATUS (EFIAPI *KEYPAD_RESET)(KEYPAD_DEVICE_PROTOCOL *This);
typedef EFI_STATUS (EFIAPI *KEYPAD_GET_KEYS)(KEYPAD_DEVICE_PROTOCOL *This, KEYPAD_RETURN_API *KeypadReturnApi, UINT64 Delta);
struct _KEYPAD_DEVICE_PROTOCOL {
KEYPAD_RESET Reset;
KEYPAD_GET_KEYS GetKeys;
};
extern EFI_GUID gEFIDroidKeypadDeviceProtocolGuid;
#endif
| 30.466667 | 126 | 0.786652 |
0c11bc19e8e46ea19aa46e9057c67f37d1cf659f | 4,298 | c | C | HiMem/src/main/cpp/xdl/xdl_linker.c | r4b3rt/HiMem | 2c86260ba32dcef6b4c218c5fba3cfff4a4a8df3 | [
"Apache-2.0"
] | 106 | 2020-11-15T10:32:56.000Z | 2022-03-28T06:24:07.000Z | HiMem/src/main/cpp/xdl/xdl_linker.c | r4b3rt/HiMem | 2c86260ba32dcef6b4c218c5fba3cfff4a4a8df3 | [
"Apache-2.0"
] | 1 | 2021-04-25T10:30:32.000Z | 2022-03-04T05:41:34.000Z | HiMem/src/main/cpp/xdl/xdl_linker.c | r4b3rt/HiMem | 2c86260ba32dcef6b4c218c5fba3cfff4a4a8df3 | [
"Apache-2.0"
] | 14 | 2020-11-16T01:31:31.000Z | 2022-02-18T22:17:46.000Z | // Copyright (c) 2020-present, HexHacking Team. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// 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.
//
// Created by caikelun on 2021-02-21.
#include <stdbool.h>
#include <pthread.h>
#include <stdio.h>
#include <dlfcn.h>
#include "xdl_linker.h"
#include "xdl.h"
#include "xdl_util.h"
#define XDL_LINKER_SYM_MUTEX "__dl__ZL10g_dl_mutex"
#define XDL_LINKER_SYM_DLOPEN_EXT_N "__dl__ZL10dlopen_extPKciPK17android_dlextinfoPv"
#define XDL_LINKER_SYM_DO_DLOPEN_N "__dl__Z9do_dlopenPKciPK17android_dlextinfoPv"
#define XDL_LINKER_SYM_DLOPEN_O "__dl__Z8__dlopenPKciPKv"
#define XDL_LINKER_SYM_LOADER_DLOPEN_P "__loader_dlopen"
typedef void *(*xdl_linker_dlopen_n_t)(const char *, int, const void *, void *);
typedef void *(*xdl_linker_dlopen_o_t)(const char *, int, const void *);
static pthread_mutex_t *xdl_linker_mutex = NULL;
static void *xdl_linker_dlopen = NULL;
static void xdl_linker_init(void)
{
static bool inited = false;
if(inited) return;
inited = true;
void *handle = xdl_open(XDL_UTIL_LINKER_BASENAME, XDL_DEFAULT);
if(NULL == handle) return;
int api_level = xdl_util_get_api_level();
if(__ANDROID_API_L__ == api_level || __ANDROID_API_L_MR1__ == api_level)
{
// == Android 5.x
xdl_linker_mutex = (pthread_mutex_t *)xdl_dsym(handle, XDL_LINKER_SYM_MUTEX, NULL);
}
else if(__ANDROID_API_N__ == api_level || __ANDROID_API_N_MR1__ == api_level)
{
// == Android 7.x
xdl_linker_dlopen = xdl_dsym(handle, XDL_LINKER_SYM_DLOPEN_EXT_N, NULL);
if(NULL == xdl_linker_dlopen)
{
xdl_linker_dlopen = xdl_dsym(handle, XDL_LINKER_SYM_DO_DLOPEN_N, NULL);
xdl_linker_mutex = (pthread_mutex_t *)xdl_dsym(handle, XDL_LINKER_SYM_MUTEX, NULL);
}
}
else if(__ANDROID_API_O__ == api_level || __ANDROID_API_O_MR1__ == api_level)
{
// == Android 8.x
xdl_linker_dlopen = xdl_dsym(handle, XDL_LINKER_SYM_DLOPEN_O, NULL);
}
else if(api_level >= __ANDROID_API_P__)
{
// >= Android 9.0
xdl_linker_dlopen = xdl_sym(handle, XDL_LINKER_SYM_LOADER_DLOPEN_P, NULL);
}
xdl_close(handle);
}
void xdl_linker_lock(void)
{
xdl_linker_init();
if(NULL != xdl_linker_mutex) pthread_mutex_lock(xdl_linker_mutex);
}
void xdl_linker_unlock(void)
{
if(NULL != xdl_linker_mutex) pthread_mutex_unlock(xdl_linker_mutex);
}
void *xdl_linker_load(const char *filename)
{
int api_level = xdl_util_get_api_level();
if(api_level <= __ANDROID_API_M__)
{
// <= Android 6.0
return dlopen(filename, RTLD_NOW);
}
else
{
xdl_linker_init();
if(NULL == xdl_linker_dlopen) return NULL;
void *caller = (void *)snprintf;
if(__ANDROID_API_N__ == api_level || __ANDROID_API_N_MR1__ == api_level)
{
// == Android 7.x
xdl_linker_lock();
void *handle = ((xdl_linker_dlopen_n_t)xdl_linker_dlopen)(filename, RTLD_NOW, NULL, caller);
xdl_linker_unlock();
return handle;
}
else
{
// >= Android 8.0
return ((xdl_linker_dlopen_o_t)xdl_linker_dlopen)(filename, RTLD_NOW, caller);
}
}
}
| 34.384 | 104 | 0.69637 |
0c13f47acd21192ccb4b891ebfb6d14189fa4941 | 1,266 | h | C | src/stt/stt_dice_expression.h | katesalazar/bat | 3c84a3c2263f3d40147411843c066b9313b967b4 | [
"Apache-2.0"
] | 1 | 2019-06-04T22:39:37.000Z | 2019-06-04T22:39:37.000Z | src/stt/stt_dice_expression.h | katesalazar/bat | 3c84a3c2263f3d40147411843c066b9313b967b4 | [
"Apache-2.0"
] | null | null | null | src/stt/stt_dice_expression.h | katesalazar/bat | 3c84a3c2263f3d40147411843c066b9313b967b4 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 2018-2019 Mercedes Catherine Salazar
*
* 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.
*
* src/stt/stt_dice_expression.h: Amara syntax tree dice expression.
*/
#ifndef __AMARA__SYNTAX_TREE__DICE_EXPRESSION__H__
#define __AMARA__SYNTAX_TREE__DICE_EXPRESSION__H__
/* For `typedef struct stt_dice_expression { ... }
* stt_dice_expression;`. */
#include "stt_forward_declarations.h"
#include "../brt/natural.h"
/** FIXME REMOVE THIS */
stt_dice_expression *
stt_dice_expression_exhaustive_constructor(
const struct natural * left_hand_side,
const struct natural * right_hand_side)
__attribute__((warn_unused_result))
;
/** FIXME REMOVE THIS */
void
stt_dice_expression_destructor(stt_dice_expression * dice_expression)
;
#endif
| 30.142857 | 75 | 0.767773 |
0c14566807d99e4886bd51e42886afee538a8ecf | 4,852 | h | C | rt-cluster-rendering/libraries/centropy/includes/centropy.h | KernelOverseer/RTBench | f46bdbcefc2ec389100d800a30b0f297f19034f9 | [
"MIT"
] | null | null | null | rt-cluster-rendering/libraries/centropy/includes/centropy.h | KernelOverseer/RTBench | f46bdbcefc2ec389100d800a30b0f297f19034f9 | [
"MIT"
] | null | null | null | rt-cluster-rendering/libraries/centropy/includes/centropy.h | KernelOverseer/RTBench | f46bdbcefc2ec389100d800a30b0f297f19034f9 | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* centropy.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: merras <merras@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/29 19:19:14 by merras #+# #+# */
/* Updated: 2020/01/25 15:24:41 by merras ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef CENTROPY_H
# define CENTROPY_H
# include <string.h>
# include <stdlib.h>
# include <fcntl.h>
# include <sys/stat.h>
# include <unistd.h>
# define F_GET(x, f) (x & (1 << f))
# define F_BGET(x, f) (x & f)
# define F_SET(x, f) (x |= (1 << f))
# define F_BSET(x, f) (x |= f)
# define F_UNSET(x, f) (x &= ~(1 << f))
# define F_BUNSET(x, f) (x &= ~f)
void *ft_memset(void *b, int c, size_t len);
void ft_bzero(void *s, size_t n);
void *ft_memcpy(void *dst, const void *src, size_t n);
char *ft_strncpy(char *dst, const char *src, size_t len);
void *ft_memccpy(void *dst, const void *src, int c, size_t n);
void *ft_memmove(void *dst, const void *src, size_t len);
size_t ft_strlen(const char *s);
char *ft_strdup(const char *src);
void *ft_memchr(const void *s, int c, size_t n);
int ft_strcmp(const char *s1s, const char *s2s);
char *ft_strcpy(char *dst, const char *src);
int ft_memcmp(const void *s1, const void *s2, size_t n);
char *ft_strcat(char *s1, const char *s2);
char *ft_strncat(char *s1, const char *s2, size_t n);
size_t ft_strlcat(char *dest, char *src, unsigned int size);
char *ft_strchr(const char *s, int c);
char *ft_strrchr(const char *s, int c);
char *ft_strstr(const char *haystack, const char *needle);
char *ft_strnstr(const char *haysta, const char *need, size_t len);
int ft_strncmp(const char *s1s, const char *s2s, size_t n);
int ft_atoi(const char *str);
int ft_isalpha(int c);
int ft_isdigit(int c);
int ft_isalnum(int c);
int ft_isascii(int c);
int ft_isprint(int c);
int ft_tolower(int c);
int ft_toupper(int c);
void *ft_memalloc(size_t size);
void ft_memdel(void **ap);
char *ft_strnew(size_t size);
void ft_strdel(char **as);
void ft_strclr(char *s);
void ft_striter(char *s, void (*f)(char *));
void ft_striteri(char *s, void (*f)(unsigned int, char *));
char *ft_strmap(char const *s, char (*f)(char));
char *ft_strmapi(char const *s, char (*f)(unsigned int, char));
int ft_strequ(char const *s1, char const *s2);
int ft_strnequ(char const *s1, char const *s2, size_t n);
char *ft_strsub(char const *s, unsigned int start, size_t len);
char *ft_strjoin(char *s1, char *s2);
char *ft_strtrim(char const *s);
int ft_wordscount(char const *s, char c);
int *ft_wordslens(char const *s, char c);
char *ft_noc(char *str, char c);
char **ft_strsplit(char const *s, char c);
int ft_digitscount(long long int n);
char *ft_itoa(int n);
void ft_putchar(char c);
int ft_putchar_int(int c);
void ft_putstr(char const *s);
void ft_putnbr(int n);
void ft_putendl(char const *s);
void ft_putchar_fd(char c, int fd);
void ft_putstr_fd(char const *s, int fd);
void ft_putnbr_fd(int n, int fd);
void ft_putendl_fd(char const *s, int fd);
typedef struct s_3tuple
{
int i;
int j;
int k;
} t_3tuple;
typedef struct s_string
{
char *string;
struct s_string *next;
struct s_string *prev;
} t_string;
void t_string_push(t_string **head, char *string);
t_string *array_to_t_string(char **array);
char *ft_strjoin_free(char *s1, char *s2, int p);
void t_string_del(t_string *list);
int t_string_length(t_string *list);
void t_string_pop(t_string **head);
t_string *t_string_create_node(t_string node_value);
void t_string_del_node(t_string **head, t_string *node);
char **t_string_to_array(t_string *list);
void free_char_array(char **p);
int current_segment_size(char *raw, char delimiter, int index);
int array_length(char **array);
void print_array(char **array);
int is_flag(char *flag, char *supported);
int isalnum_check(char *str);
t_string *t_string_copy(t_string *list);
int is_directory(char *filename);
int ft_isnumber(char *string);
# define POSITIVE_NEGATIVE 0
int ft_isanumber(char *string, int flags);
# define SIGN 0
# define DOT 1
# define FIRST_ITERATION 2
# define PRECISION 3
double ft_atof(char *string, int precision);
#endif
| 37.323077 | 80 | 0.579143 |
0c1763e9d7e95036e912a0dfc58334e4da82964f | 4,145 | h | C | libutl/TSkipList.h | Brillist/libutl | e55c2af091ba1101a1d0608db2830e279ec95d16 | [
"MIT"
] | 1 | 2021-09-14T06:12:58.000Z | 2021-09-14T06:12:58.000Z | libutl/TSkipList.h | Brillist/libutl | e55c2af091ba1101a1d0608db2830e279ec95d16 | [
"MIT"
] | null | null | null | libutl/TSkipList.h | Brillist/libutl | e55c2af091ba1101a1d0608db2830e279ec95d16 | [
"MIT"
] | 2 | 2019-05-13T23:04:31.000Z | 2021-09-14T06:12:59.000Z | #pragma once
////////////////////////////////////////////////////////////////////////////////////////////////////
#include <libutl/TSkipListIt.h>
////////////////////////////////////////////////////////////////////////////////////////////////////
UTL_NS_BEGIN;
////////////////////////////////////////////////////////////////////////////////////////////////////
/**
Template version of SkipList.
TSkipList's main purpose is to minimize the need for typecasts.
\author Adam McKee
\ingroup collection
*/
////////////////////////////////////////////////////////////////////////////////////////////////////
template <class T>
class TSkipList : public SkipList
{
UTL_CLASS_DECL_TPL(TSkipList, T, SkipList);
UTL_CLASS_DEFID;
public:
/**
Constructor.
\param owner \b owner flag
\param multiSet (optional : true) \b multiSet flag
\param ordering (optional) ordering
*/
TSkipList(bool owner, bool multiSet = true, Ordering* ordering = nullptr);
bool
add(const T& object)
{
return super::add(const_cast<T&>(object));
}
bool
add(const T* object)
{
return super::add(const_cast<T*>(object));
}
void
add(const Collection& collection)
{
super::add(collection);
}
TSkipListIt<T>
begin() const
{
TSkipListIt<T> res;
res.copy(SkipList::begin());
return res;
}
TSkipListIt<T>
end() const
{
TSkipListIt<T> res;
res.copy(SkipList::end());
return res;
}
TSkipListIt<T>
begin()
{
TSkipListIt<T> res;
res.copy(SkipList::begin());
return res;
}
TSkipListIt<T>
end()
{
TSkipListIt<T> res;
res.copy(SkipList::end());
return res;
}
/** See find(). */
T*
findT(const Object& key) const
{
return utl::cast<T>(SkipList::find(key));
}
TSkipListIt<T>
findIt(const Object& key) const
{
TSkipListIt<T> res;
res.copy(SkipList::findIt(key));
return res;
}
TSkipListIt<T>
findIt(const Object& key)
{
TSkipListIt<T> res;
res.copy(SkipList::findIt(key));
return res;
}
void
findFirstIt(const Object& key, BidIt& it, bool insert = false) const
{
super::findFirstIt(key, it);
}
virtual void
findFirstIt(const Object& key, BidIt& it, bool insert = false)
{
super::findFirstIt(key, it, insert);
}
TSkipListIt<T>
findFirstIt(const Object& key, bool insert = false) const
{
TSkipListIt<T> res;
res.copy(SkipList::findFirstIt(key, insert));
return res;
}
TSkipListIt<T>
findFirstIt(const Object& key, bool insert = false)
{
TSkipListIt<T> res;
res.copy(SkipList::findFirstIt(key, insert));
return res;
}
void
findLastIt(const Object& key, BidIt& it) const
{
super::findLastIt(key, it);
}
virtual void
findLastIt(const Object& key, BidIt& it)
{
super::findLastIt(key, it);
}
TSkipListIt<T>
findLastIt(const Object& key) const
{
TSkipListIt<T> res;
res.copy(SkipList::findLastIt(key));
return res;
}
TSkipListIt<T>
findLastIt(const Object& key)
{
TSkipListIt<T> res;
res.copy(SkipList::findLastIt(key));
return res;
}
bool
remove(const Object& key)
{
return super::remove(key);
}
public:
typedef T type;
typedef TSkipListIt<T> iterator;
typedef T* value_type; // for STL
};
////////////////////////////////////////////////////////////////////////////////////////////////////
template <class T>
TSkipList<T>::TSkipList(bool owner, bool multiSet, Ordering* ordering)
: SkipList(owner, multiSet, ordering)
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
UTL_NS_END;
////////////////////////////////////////////////////////////////////////////////////////////////////
UTL_CLASS_IMPL_TPL(utl::TSkipList, T);
| 21.25641 | 100 | 0.47696 |
0c17af819de43cdb9c273fa3b6c0b32cc69bc54c | 827 | c | C | swarp.c | ibabushkin/swarp-fork | fc7d0b2ac69a3bd09aaecd2e15e32414c733cc77 | [
"MIT"
] | null | null | null | swarp.c | ibabushkin/swarp-fork | fc7d0b2ac69a3bd09aaecd2e15e32414c733cc77 | [
"MIT"
] | null | null | null | swarp.c | ibabushkin/swarp-fork | fc7d0b2ac69a3bd09aaecd2e15e32414c733cc77 | [
"MIT"
] | null | null | null | /* (C)opyright MMIV-MMV Anselm R. Garbe <garbeam at gmail dot com>
* See LICENSE file for license details.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <X11/Xlib.h>
int
main(int argc, char **argv) {
int x, y;
Display *dpy;
if((argc == 2) && !strncmp(argv[1], "-v", 3)) {
fputs("swarp-"VERSION", (C)opyright MMVI Anselm R. Garbe\n", stdout);
exit(EXIT_SUCCESS);
}
if(argc != 3)
goto Usage;
if(!(dpy = XOpenDisplay(0))) {
fputs("swarp: cannot open display\n", stderr);
exit(EXIT_FAILURE);
}
if((sscanf(argv[1], "%d", &x) != 1) || (sscanf(argv[2], "%d", &y) != 1)) {
Usage:
fputs("usage: swarp <x> <y> [-v]\n", stderr);
exit(EXIT_FAILURE);
}
XWarpPointer(dpy, None, RootWindow(dpy, DefaultScreen(dpy)), 0, 0, 0, 0, x, y);
XCloseDisplay(dpy);
return 0;
}
| 23.628571 | 80 | 0.614268 |
0c192df22c215ede53ac71966aae7d33814e9212 | 1,492 | h | C | Source/NativeWindow/Windows/ServicesImpl/WindowsResourceService.h | cameled/GacUI | 939856c1045067dc7b78eb80cdb7174ae5c76799 | [
"RSA-MD"
] | 2,342 | 2015-04-01T22:12:53.000Z | 2022-03-31T07:00:33.000Z | Source/NativeWindow/Windows/ServicesImpl/WindowsResourceService.h | cameled/GacUI | 939856c1045067dc7b78eb80cdb7174ae5c76799 | [
"RSA-MD"
] | 68 | 2015-04-04T15:42:06.000Z | 2022-03-29T04:33:51.000Z | Source/NativeWindow/Windows/ServicesImpl/WindowsResourceService.h | cameled/GacUI | 939856c1045067dc7b78eb80cdb7174ae5c76799 | [
"RSA-MD"
] | 428 | 2015-04-02T00:25:48.000Z | 2022-03-25T16:37:56.000Z | /***********************************************************************
Vczh Library++ 3.0
Developer: Zihan Chen(vczh)
GacUI::Native Window::Windows Implementation
Interfaces:
***********************************************************************/
#ifndef VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSRESOURCESERVICE
#define VCZH_PRESENTATION_WINDOWS_SERVICESIMPL_WINDOWSRESOURCESERVICE
#include "..\..\GuiNativeWindow.h"
#include "..\WinNativeDpiAwareness.h"
namespace vl
{
namespace presentation
{
namespace windows
{
class WindowsCursor : public Object, public INativeCursor
{
protected:
HCURSOR handle;
bool isSystemCursor;
SystemCursorType systemCursorType;
public:
WindowsCursor(HCURSOR _handle);
WindowsCursor(SystemCursorType type);
bool IsSystemCursor()override;
SystemCursorType GetSystemCursorType()override;
HCURSOR GetCursorHandle();
};
class WindowsResourceService : public Object, public INativeResourceService
{
protected:
collections::Array<Ptr<WindowsCursor>> systemCursors;
FontProperties defaultFont;
public:
WindowsResourceService();
INativeCursor* GetSystemCursor(INativeCursor::SystemCursorType type)override;
INativeCursor* GetDefaultSystemCursor()override;
FontProperties GetDefaultFont()override;
void SetDefaultFont(const FontProperties& value)override;
};
}
}
}
#endif | 28.150943 | 88 | 0.651475 |
0c197a3e7e305499f06a0ab54fe56494ca72ab8c | 4,738 | h | C | DK/DKFoundation/DKXMLDocument.h | hhg128/DKGL | c61bc6546ac5655da97462cc532a9034ba08516d | [
"PSF-2.0",
"BSD-3-Clause"
] | null | null | null | DK/DKFoundation/DKXMLDocument.h | hhg128/DKGL | c61bc6546ac5655da97462cc532a9034ba08516d | [
"PSF-2.0",
"BSD-3-Clause"
] | null | null | null | DK/DKFoundation/DKXMLDocument.h | hhg128/DKGL | c61bc6546ac5655da97462cc532a9034ba08516d | [
"PSF-2.0",
"BSD-3-Clause"
] | null | null | null | //
// File: DKXMLDocument.h
// Author: Hongtae Kim (tiff2766@gmail.com)
//
// Copyright (c) 2004-2014 Hongtae Kim. All rights reserved.
//
#pragma once
#include "../DKinclude.h"
#include "DKObject.h"
#include "DKString.h"
#include "DKData.h"
#include "DKXMLParser.h"
////////////////////////////////////////////////////////////////////////////////
// DKXMLDocument
// XML DOM class, provides parse and generate DOM of XML, HTML.
// this class uses DKXMLParser internally. (see DKXMLParser.h)
// this class provides DOM includes DTD.
////////////////////////////////////////////////////////////////////////////////
namespace DKFoundation
{
class DKGL_API DKXMLDocument
{
public:
enum Type
{
TypeXML,
TypeHTML,
};
struct Namespace
{
DKString prefix;
DKString URI;
};
struct Attribute
{
DKObject<Namespace> ns;
DKString name;
DKString value;
};
class Node
{
public:
virtual ~Node(void) {}
enum NodeType
{
NodeTypeUnknown = 0,
NodeTypeInstruction,
NodeTypeDocTypeDecl,
NodeTypeElementDecl,
NodeTypeAttributeDecl,
NodeTypeComment,
NodeTypeElement,
NodeTypeCData, // CDATA section strings ignored by parser.
NodeTypePCData, // Parsed Character Data. (some symbols will be translated.)
};
NodeType Type(void) const;
virtual DKString Export(void) const = 0;
protected:
Node(NodeType t) : type(t) {}
private:
const NodeType type;
};
struct CData : public Node
{
CData(void) : Node(NodeTypeCData) {}
DKStringU8 value; // UTF-8 string
DKString Export(void) const;
};
struct PCData : public Node
{
PCData(void) : Node(NodeTypePCData) {}
DKString value;
DKString Export(void) const;
};
struct Comment : public Node
{
Comment(void) : Node(NodeTypeComment) {}
DKString value;
DKString Export(void) const;
};
struct Element : public Node
{
Element(void) : Node(NodeTypeElement) {}
DKObject<Namespace> ns;
DKString name;
DKArray<Attribute> attributes;
DKArray<Namespace> namespaces;
DKArray<DKObject<Node>> nodes;
DKString Export(void) const;
DKString Export(DKArray<Namespace>& writtenNS) const;
};
struct Instruction : public Node
{
Instruction(void) : Node(NodeTypeInstruction) {}
DKString target;
DKString data;
DKString Export(void) const;
};
struct ElementDecl : public Node // DTD Element
{
ElementDecl(void) : Node(NodeTypeElementDecl) {}
DKXMLParser::ElementDecl decl;
DKXMLParser::ElementContentDecl contents;
DKString Export(void) const;
};
struct AttributeDecl : public Node // DTD
{
AttributeDecl(void) : Node(NodeTypeAttributeDecl) {}
DKXMLParser::AttributeDecl decl;
DKArray<DKString> enumeratedValues;
DKString Export(void) const;
};
struct DocTypeDecl : public Node
{
DocTypeDecl(void) : Node(NodeTypeDocTypeDecl) {}
DKString name;
DKString externalID;
DKString systemID;
DKArray<DKObject<Node>> nodes;
DKString Export(void) const;
};
DKXMLDocument(void);
DKXMLDocument(DocTypeDecl* dtd, Element* root);
DKXMLDocument(Element* root);
~DKXMLDocument(void);
// open and create object with URL or file.
static DKObject<DKXMLDocument> Open(Type t, const DKString& fileOrURL, DKString* desc = NULL);
// When reading HTML from buffer, they should be encoded with UTF-8.
// becouse XML has encoding information, but HTML does not.
static DKObject<DKXMLDocument> Open(Type t, const DKData* buffer, DKString* desc = NULL);
static DKObject<DKXMLDocument> Open(Type t, DKStream* stream, DKString* desc = NULL);
DKObject<DKData> Export(DKStringEncoding e) const;
size_t Export(DKStringEncoding e, DKStream* output) const;
////////////////////////////////////////////////////////////////////////////////
Element* RootElement(void);
const Element* RootElement(void) const;
void SetRootElement(Element* e);
// DTD subset
void SetDTD(DocTypeDecl* d);
DocTypeDecl* DTD(void);
const DocTypeDecl* DTD(void) const;
private:
DKArray<DKObject<Node>> nodes; // all nodes of DOM.
class DocumentBuilder;
};
typedef DKXMLDocument::Namespace DKXMLNamespace;
typedef DKXMLDocument::Attribute DKXMLAttribute;
typedef DKXMLDocument::Node DKXMLNode;
typedef DKXMLDocument::CData DKXMLCData;
typedef DKXMLDocument::PCData DKXMLPCData;
typedef DKXMLDocument::Comment DKXMLComment;
typedef DKXMLDocument::Element DKXMLElement;
typedef DKXMLDocument::Instruction DKXMLInstruction;
typedef DKXMLDocument::ElementDecl DKXMLElementDecl;
typedef DKXMLDocument::AttributeDecl DKXMLAttributeDecl;
typedef DKXMLDocument::DocTypeDecl DKXMLDocTypeDecl;
}
| 28.371257 | 96 | 0.66927 |
0c1a44f48f9b4f86256d225a91f3b11334044b6d | 2,917 | c | C | Openharmony v1.0/third_party/ltp/testcases/kernel/sound/snd_seq01.c | clkbit123/TheOpenHarmony | 0e6bcd9dee9f1a2481d762966b8bbd24baad6159 | [
"MIT"
] | 1 | 2022-02-15T08:51:55.000Z | 2022-02-15T08:51:55.000Z | hihope_neptune-oh_hid/00_src/v0.3/third_party/ltp/testcases/kernel/sound/snd_seq01.c | dawmlight/vendor_oh_fun | bc9fb50920f06cd4c27399f60076f5793043c77d | [
"Apache-2.0"
] | null | null | null | hihope_neptune-oh_hid/00_src/v0.3/third_party/ltp/testcases/kernel/sound/snd_seq01.c | dawmlight/vendor_oh_fun | bc9fb50920f06cd4c27399f60076f5793043c77d | [
"Apache-2.0"
] | null | null | null | // SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2018 SUSE LLC <nstange@suse.de>
* Copyright (C) 2020 SUSE LLC <mdoucha@suse.cz>
*
* CVE-2018-7566
*
* Test for race condition when initializing client pool on /dev/snd/seq
* Kernel crash fixed in:
*
* commit d15d662e89fc667b90cd294b0eb45694e33144da
* Author: Takashi Iwai <tiwai@suse.de>
* Date: Mon Feb 12 15:20:51 2018 +0100
*
* ALSA: seq: Fix racy pool initializations
*/
#include <linux/types.h>
#include <time.h>
#include <sound/asound.h>
#include <sound/asequencer.h>
#include "tst_test.h"
#include "tst_fuzzy_sync.h"
#include "tst_taint.h"
static int fd = -1;
static int client_id;
static struct snd_seq_remove_events rminfo = {
.remove_mode = SNDRV_SEQ_REMOVE_OUTPUT
};
static struct snd_seq_event ssev = {
.flags = SNDRV_SEQ_TIME_STAMP_TICK | SNDRV_SEQ_TIME_MODE_REL,
.queue = 0,
.type = SNDRV_SEQ_EVENT_USR0,
.time = { .tick = 10 }
};
static struct tst_fzsync_pair fzsync_pair;
static void reinit_pool(int pool_size)
{
struct snd_seq_client_pool pconf = {
.output_pool = pool_size,
.client = client_id
};
ioctl(fd, SNDRV_SEQ_IOCTL_SET_CLIENT_POOL, &pconf);
}
static void race_ioctl(void)
{
reinit_pool(512);
}
static void race_write(void)
{
TEST(write(fd, &ssev, sizeof(ssev)));
}
void (*testfunc_list[])(void) = {race_ioctl, race_write};
static void setup(void)
{
struct snd_seq_queue_info qconf = { .queue = 0 };
tst_taint_init(TST_TAINT_W | TST_TAINT_D);
errno = 0;
fd = open("/dev/snd/seq", O_RDWR);
if (fd == -1 && (errno == ENOENT || errno == EACCES))
tst_brk(TCONF | TERRNO, "Cannot open /dev/snd/seq");
if (fd < 0)
tst_brk(TBROK | TERRNO, "Cannot open /dev/snd/seq");
SAFE_IOCTL(fd, SNDRV_SEQ_IOCTL_CLIENT_ID, &client_id);
SAFE_IOCTL(fd, SNDRV_SEQ_IOCTL_CREATE_QUEUE, &qconf);
ssev.dest.client = client_id;
fzsync_pair.exec_loops = 1000000;
tst_fzsync_pair_init(&fzsync_pair);
}
static void cleanup(void)
{
if (fd >= 0)
SAFE_CLOSE(fd);
tst_fzsync_pair_cleanup(&fzsync_pair);
}
static void *thread_run(void *arg)
{
while (tst_fzsync_run_b(&fzsync_pair)) {
tst_fzsync_start_race_b(&fzsync_pair);
reinit_pool(10);
tst_fzsync_end_race_b(&fzsync_pair);
}
return arg;
}
static void run(unsigned int n)
{
tst_fzsync_pair_reset(&fzsync_pair, thread_run);
while (tst_fzsync_run_a(&fzsync_pair)) {
reinit_pool(5);
SAFE_IOCTL(fd, SNDRV_SEQ_IOCTL_REMOVE_EVENTS, &rminfo);
tst_fzsync_start_race_a(&fzsync_pair);
testfunc_list[n]();
tst_fzsync_end_race_a(&fzsync_pair);
if (tst_taint_check()) {
tst_res(TFAIL, "Kernel is vulnerable");
return;
}
}
tst_res(TPASS, "Nothing bad happened, probably");
}
static struct tst_test test = {
.test = run,
.tcnt = ARRAY_SIZE(testfunc_list),
.setup = setup,
.cleanup = cleanup,
.timeout = 120,
.tags = (const struct tst_tag[]) {
{"linux-git", "d15d662e89fc"},
{"CVE", "2018-7566"},
{}
}
};
| 21.607407 | 72 | 0.708948 |
0c1a9f768edce085a77c3329b0ac7587d9369c9c | 3,995 | h | C | include/QtGui/qgraphicslinearlayout.h | 219-design/build_qt4_binaries_armv5tejl_sbc6000x | 0d33869719a56ce4e9c7009f825c7d3c79869f36 | [
"MIT"
] | null | null | null | include/QtGui/qgraphicslinearlayout.h | 219-design/build_qt4_binaries_armv5tejl_sbc6000x | 0d33869719a56ce4e9c7009f825c7d3c79869f36 | [
"MIT"
] | null | null | null | include/QtGui/qgraphicslinearlayout.h | 219-design/build_qt4_binaries_armv5tejl_sbc6000x | 0d33869719a56ce4e9c7009f825c7d3c79869f36 | [
"MIT"
] | null | null | null | /****************************************************************************
**
** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License versions 2.0 or 3.0 as published by the Free
** Software Foundation and appearing in the file LICENSE.GPL included in
** the packaging of this file. Please review the following information
** to ensure GNU General Public Licensing requirements will be met:
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html. In addition, as a special
** exception, Nokia gives you certain additional rights. These rights
** are described in the Nokia Qt GPL Exception version 1.3, included in
** the file GPL_EXCEPTION.txt in this package.
**
** Qt for Windows(R) Licensees
** As a special exception, Nokia, as the sole copyright holder for Qt
** Designer, grants users of the Qt/Eclipse Integration plug-in the
** right for the Qt/Eclipse Integration to link to functionality
** provided by Qt Designer and its related libraries.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
**
****************************************************************************/
#ifndef QGRAPHICSLINEARLAYOUT_H
#define QGRAPHICSLINEARLAYOUT_H
#include <QtGui/qgraphicsitem.h>
#include <QtGui/qgraphicslayout.h>
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
QT_MODULE(Gui)
#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
class QGraphicsLinearLayoutPrivate;
class Q_GUI_EXPORT QGraphicsLinearLayout : public QGraphicsLayout
{
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing)
public:
QGraphicsLinearLayout(QGraphicsLayoutItem *parent = 0);
QGraphicsLinearLayout(Qt::Orientation orientation, QGraphicsLayoutItem *parent = 0);
virtual ~QGraphicsLinearLayout();
void setOrientation(Qt::Orientation orientation);
Qt::Orientation orientation() const;
inline void addItem(QGraphicsLayoutItem *item) { insertItem(-1, item); }
inline void addStretch(int stretch = 1) { insertStretch(-1, stretch); }
void insertItem(int index, QGraphicsLayoutItem *item);
void insertStretch(int index, int stretch = 1);
void removeItem(QGraphicsLayoutItem *item);
void removeAt(int index);
void setSpacing(qreal spacing);
qreal spacing() const;
void setItemSpacing(int index, qreal spacing);
qreal itemSpacing(int index) const;
void setStretchFactor(QGraphicsLayoutItem *item, int stretch);
int stretchFactor(QGraphicsLayoutItem *item) const;
void setAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment);
Qt::Alignment alignment(QGraphicsLayoutItem *item) const;
void setGeometry(const QRectF &rect);
int count() const;
QGraphicsLayoutItem *itemAt(int index) const;
void invalidate();
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
#if 0 // ###
Q5SizePolicy::ControlTypes controlTypes(LayoutSide side) const;
#endif
#ifdef QT_DEBUG
void dump(int indent = 0) const;
#endif
protected:
#if 0
QSize contentsSizeHint(Qt::SizeHint which, const QSize &constraint = QSize()) const;
#endif
private:
Q_DISABLE_COPY(QGraphicsLinearLayout)
Q_DECLARE_PRIVATE(QGraphicsLinearLayout)
};
#endif
QT_END_NAMESPACE
QT_END_HEADER
#endif
| 33.291667 | 99 | 0.729662 |
0c1dfc5bb6b2939d5e1a6a664c376d58811282ed | 530 | h | C | src/raymath/headers/disk.h | Michionlion/rayterm-cpu | 29820aac88b64cdc44117f23cfcb46cd74b6f7ad | [
"MIT"
] | 1 | 2019-05-14T05:33:53.000Z | 2019-05-14T05:33:53.000Z | src/raymath/headers/disk.h | Michionlion/rayterm-cpu | 29820aac88b64cdc44117f23cfcb46cd74b6f7ad | [
"MIT"
] | null | null | null | src/raymath/headers/disk.h | Michionlion/rayterm-cpu | 29820aac88b64cdc44117f23cfcb46cd74b6f7ad | [
"MIT"
] | null | null | null | #ifndef _RAYMATH_DISK_H_
#define _RAYMATH_DISK_H_
#include "geometry.h"
#include "intersection.h"
#include "types.h"
struct disk : geometry {
vector center;
vector normal;
scalar radius;
scalar radius_sqr;
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
disk(const vector& c, const vector& n, scalar r)
: center(c), normal(n), radius(r), radius_sqr(r * r){};
void intersects(ray r, intersection& record);
using geometry::intersects;
texcoord compute_texcoord(const intersection& record);
};
#endif
| 23.043478 | 63 | 0.703774 |
0c203740d703c2204d68b9943d584b3d4ad098a7 | 4,295 | h | C | include/Allegro_Output.h | acmgit/DDD_Linux | 9555535a0876e53a4f457ba4c409446a01ec939f | [
"CC0-1.0"
] | null | null | null | include/Allegro_Output.h | acmgit/DDD_Linux | 9555535a0876e53a4f457ba4c409446a01ec939f | [
"CC0-1.0"
] | null | null | null | include/Allegro_Output.h | acmgit/DDD_Linux | 9555535a0876e53a4f457ba4c409446a01ec939f | [
"CC0-1.0"
] | null | null | null | #ifndef ALLEGRO_OUTPUT_H
#define ALLEGRO_OUTPUT_H
#include "Console.h"
#include "Statuswindow.h"
#include "Playfield.h"
#include "DDD_Screen.h"
#include "Soundinterface.h"
#include <allegro/gfx.h>
#include <allegro/graphics.h>
#include <allegro/font.h>
#include <string>
class Allegro_Output
{
public:
struct screenData
{
int screenWidth;
int screenHeight;
int screenDepth;
bool Fullscreen;
};
struct tileData
{
int Sheetpos_x;
int Sheetpos_y;
int Column;
int Row;
bool transparency;
BITMAP *Sheet;
};
struct gfx_Object
{
int Sheetpos_x;
int Sheetpos_y;
int Destinationpos_x;
int Destinationpos_y;
int Width;
int Height;
bool transparency;
BITMAP *Sheet;
};
struct gfx_Text
{
int Pos_x;
int Pos_y;
int Foregroundcolor;
int Backgroundcolor;
std::string Text;
bool toConvert; // Flag, if true, then the Text will be converted to the special DDD_Text.
};
Allegro_Output(const screenData &Data);
~Allegro_Output();
// Screenfunctions
void clear_Screen(bool Virtual); // Clears the Virtual Screen if true, else the Display
void render_Screen(); // Renders the whole virtual Screen to Display
// write Functions
void write_OnScreen(gfx_Text *Text);
void write_OnConsole(const int FCol, const int BCol, const std::string &CText, const bool nextLine);
void write_Status();
// Function to fill the Statusscreen. the Statusscreen will be shown with the command write_Status.
void add_StatusLine(const int &Row, const int &Tab, const int &FCol, const int &BCol, const std::string &SText);
// drawing Functions
void render_Object(gfx_Object *Object);
void render_Tile(const tileData &Tile);
// Faderfunctions
void screen_FadeIn(const int speed, BITMAP *to_Fadein); // Fade's the given Screen (to_Fadein) in
void screen_FadeOut(const int speed, BITMAP *to_Fadeout); // Fade's the given Screen (to_Fadeout) out with an black Screen
void set_Faderpause(const int Pause); // set's the Fader to wait in Milliseconds between the Faderphases
// div. Setter
void set_Font(FONT *newFont);
void set_Palette(PALETTE *newPalette);
void set_Console(const int &Pos_x, const int &Pos_y, const int &TextHeight, const int &Rows);
void set_Statuswindow(const int &Pos_x, const int &Pos_y, const int &TextHeight, const int &Rows);
void set_Playfieldwindow(const int &Pos_x, const int &Pos_y, const int &Tilewidth, const int &Tileheight, const int &Tilecolumns, const int &Tilerows);
// Soundfunctions
void change_Volume(const float &Volume, const bool &increment);
void play_Musicfile(const std::string &Filename, const float &Volume);
void play_Musickey(const std::string &Keyname, const float &Volume);
void pause_Music();
void stop_Music();
void play_Music();
void play_Sound(const std::string Soundname);
// div. Getter
int get_ScreenWidth();
int get_ScreenHeight();
int get_ScreenDepth();
BITMAP *get_VirtualScreen();
private:
std::string convert_Text(std::string Text); // converts a Text to the special DDD_Text
// Helpfunction for convert_Text
void replace_all(std::string& text, const std::string& fnd, const std::string& rep);
BITMAP *Display;
BITMAP *VirtualScreen;
FONT *currFont;
DDD_Screen *outputScreen;
Console *outputConsole;
Statuswindow *outputStatus;
Playfield *outputPlayfield;
Soundinterface *outputSound;
int Screenwidth;
int Screenheight;
int Screendepth;
}; // Allegro_Output
#endif // ALLEGRO_OUTPUT_H
| 32.052239 | 159 | 0.598603 |
0c23759a0d5e0a6d77cbc7338cab6c51e182e3f4 | 2,902 | c | C | src/gazetteer_data.c | oschwald/libpostal | 66b32ee377f247d326831eeb988216a316bd4aac | [
"MIT"
] | null | null | null | src/gazetteer_data.c | oschwald/libpostal | 66b32ee377f247d326831eeb988216a316bd4aac | [
"MIT"
] | 3 | 2021-03-25T22:59:06.000Z | 2021-12-13T20:22:28.000Z | src/gazetteer_data.c | oschwald/libpostal | 66b32ee377f247d326831eeb988216a316bd4aac | [
"MIT"
] | null | null | null | // Only need these for the in-memory dictionaries
gazetteer_t gazetteer_config[] = {
{DICTIONARY_ACADEMIC_DEGREE, LIBPOSTAL_ADDRESS_NAME},
{DICTIONARY_AMBIGUOUS_EXPANSION, LIBPOSTAL_ADDRESS_NONE},
{DICTIONARY_BUILDING_TYPE, LIBPOSTAL_ADDRESS_NAME | LIBPOSTAL_ADDRESS_HOUSE_NUMBER | LIBPOSTAL_ADDRESS_STREET | LIBPOSTAL_ADDRESS_UNIT},
{DICTIONARY_CATEGORY, LIBPOSTAL_ADDRESS_CATEGORY},
{DICTIONARY_CHAIN, LIBPOSTAL_ADDRESS_NAME},
{DICTIONARY_COMPANY_TYPE, LIBPOSTAL_ADDRESS_NAME},
{DICTIONARY_CONCATENATED_PREFIX_SEPARABLE, LIBPOSTAL_ADDRESS_ANY},
{DICTIONARY_CONCATENATED_SUFFIX_INSEPARABLE, LIBPOSTAL_ADDRESS_ANY},
{DICTIONARY_CONCATENATED_SUFFIX_SEPARABLE, LIBPOSTAL_ADDRESS_ANY},
{DICTIONARY_CROSS_STREET, LIBPOSTAL_ADDRESS_STREET},
{DICTIONARY_DIRECTIONAL, LIBPOSTAL_ADDRESS_ANY},
{DICTIONARY_ELISION, LIBPOSTAL_ADDRESS_ANY},
{DICTIONARY_ENTRANCE, LIBPOSTAL_ADDRESS_ENTRANCE},
{DICTIONARY_GIVEN_NAME, LIBPOSTAL_ADDRESS_STREET | LIBPOSTAL_ADDRESS_NAME},
{DICTIONARY_HOUSE_NUMBER, LIBPOSTAL_ADDRESS_HOUSE_NUMBER},
{DICTIONARY_LEVEL_NUMBERED, LIBPOSTAL_ADDRESS_LEVEL},
{DICTIONARY_LEVEL_STANDALONE, LIBPOSTAL_ADDRESS_LEVEL},
{DICTIONARY_LEVEL_MEZZANINE, LIBPOSTAL_ADDRESS_LEVEL},
{DICTIONARY_LEVEL_BASEMENT, LIBPOSTAL_ADDRESS_LEVEL},
{DICTIONARY_LEVEL_SUB_BASEMENT, LIBPOSTAL_ADDRESS_LEVEL},
{DICTIONARY_NEAR, LIBPOSTAL_ADDRESS_NEAR},
{DICTIONARY_NULL, LIBPOSTAL_ADDRESS_ANY},
{DICTIONARY_NAMED_ORGANIZATION, LIBPOSTAL_ADDRESS_NAME},
{DICTIONARY_NAMED_PERSON, LIBPOSTAL_ADDRESS_NAME | LIBPOSTAL_ADDRESS_STREET},
{DICTIONARY_NO_NUMBER, LIBPOSTAL_ADDRESS_HOUSE_NUMBER},
{DICTIONARY_NUMBER, LIBPOSTAL_ADDRESS_HOUSE_NUMBER | LIBPOSTAL_ADDRESS_UNIT | LIBPOSTAL_ADDRESS_LEVEL | LIBPOSTAL_ADDRESS_STAIRCASE | LIBPOSTAL_ADDRESS_ENTRANCE},
{DICTIONARY_PERSONAL_SUFFIX, LIBPOSTAL_ADDRESS_NAME | LIBPOSTAL_ADDRESS_STREET},
{DICTIONARY_PERSONAL_TITLE, LIBPOSTAL_ADDRESS_NAME | LIBPOSTAL_ADDRESS_STREET},
{DICTIONARY_PLACE_NAME, LIBPOSTAL_ADDRESS_NAME | LIBPOSTAL_ADDRESS_STREET},
{DICTIONARY_POST_OFFICE, LIBPOSTAL_ADDRESS_PO_BOX},
{DICTIONARY_POSTAL_CODE, LIBPOSTAL_ADDRESS_POSTAL_CODE},
{DICTIONARY_QUALIFIER, LIBPOSTAL_ADDRESS_STREET},
{DICTIONARY_STAIRCASE, LIBPOSTAL_ADDRESS_STAIRCASE},
{DICTIONARY_STOPWORD, LIBPOSTAL_ADDRESS_ANY},
{DICTIONARY_STREET_TYPE, LIBPOSTAL_ADDRESS_STREET},
{DICTIONARY_SURNAME, LIBPOSTAL_ADDRESS_STREET | LIBPOSTAL_ADDRESS_NAME},
{DICTIONARY_SYNONYM, LIBPOSTAL_ADDRESS_ANY},
{DICTIONARY_TOPONYM, LIBPOSTAL_ADDRESS_NAME | LIBPOSTAL_ADDRESS_STREET | LIBPOSTAL_ADDRESS_TOPONYM},
{DICTIONARY_UNIT_NUMBERED, LIBPOSTAL_ADDRESS_UNIT},
{DICTIONARY_UNIT_STANDALONE, LIBPOSTAL_ADDRESS_UNIT},
{DICTIONARY_UNIT_DIRECTION, LIBPOSTAL_ADDRESS_UNIT}
};
#define NUM_DICTIONARY_TYPES sizeof(gazetteer_config) / sizeof(gazetteer_t)
| 59.22449 | 166 | 0.831151 |
0c27bdcbf32a4c76ea1ca4509acf4702d55b3644 | 1,092 | h | C | PhysicsTools/RecoAlgos/plugins/CandCommonVertexFitter.h | PKUfudawei/cmssw | 8fbb5ce74398269c8a32956d7c7943766770c093 | [
"Apache-2.0"
] | 1 | 2021-11-30T16:24:46.000Z | 2021-11-30T16:24:46.000Z | PhysicsTools/RecoAlgos/plugins/CandCommonVertexFitter.h | PKUfudawei/cmssw | 8fbb5ce74398269c8a32956d7c7943766770c093 | [
"Apache-2.0"
] | 4 | 2021-11-29T13:57:56.000Z | 2022-03-29T06:28:36.000Z | PhysicsTools/RecoAlgos/plugins/CandCommonVertexFitter.h | PKUfudawei/cmssw | 8fbb5ce74398269c8a32956d7c7943766770c093 | [
"Apache-2.0"
] | 1 | 2022-02-27T06:12:26.000Z | 2022-02-27T06:12:26.000Z | #ifndef RecoAlgos_CandKalmanVertexFitter_h
#define RecoAlgos_CandKalmanVertexFitter_h
#include "CommonTools/UtilAlgos/interface/EventSetupInitTrait.h"
#include "PhysicsTools/RecoUtils/interface/CandCommonVertexFitter.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
namespace reco {
namespace modules {
template <typename Fitter>
struct CandVertexFitterEventSetupInit {
explicit CandVertexFitterEventSetupInit(edm::ConsumesCollector iC) : magToken_(iC.esConsumes()) {}
void init(CandCommonVertexFitter<Fitter>& fitter, const edm::Event& evt, const edm::EventSetup& es) {
fitter.set(&es.getData(magToken_));
}
edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> magToken_;
};
template <typename Fitter>
struct EventSetupInit<CandCommonVertexFitter<Fitter> > {
typedef CandVertexFitterEventSetupInit<Fitter> type;
};
} // namespace modules
} // namespace reco
#endif
| 39 | 108 | 0.752747 |
0c28635b513b5eb04d442e7f1bd1aee886941051 | 2,792 | c | C | lib/lcdio/lcdio.c | therealjacinto/6502-be-computer | 66b87dcb52badda42c544ed200b562781ed7ed7c | [
"MIT"
] | 1 | 2020-08-20T04:37:02.000Z | 2020-08-20T04:37:02.000Z | lib/lcdio/lcdio.c | therealjacinto/6502-be-computer | 66b87dcb52badda42c544ed200b562781ed7ed7c | [
"MIT"
] | null | null | null | lib/lcdio/lcdio.c | therealjacinto/6502-be-computer | 66b87dcb52badda42c544ed200b562781ed7ed7c | [
"MIT"
] | null | null | null | /*
* Desctiption: Functions that control the HD44780U LCD
*
* Author: therealjacinto
* Date: 2022-03-03
*/
#include "iochip/iochip.h"
#define E 128 /* 10000000 Enable bit via PORTA */
#define RW 64 /* 01000000 Read/Write bit via PORTA */
#define RS 32 /* 00100000 Register Select bit via PORTA */
/*
* Function: wait_for_lcd
* -----------------------
* Queries LCD infinitely until the busy flag is cleared.
*/
void wait_for_lcd()
{
unsigned char busy = 1;
set_data_direction_port_b(0);
do
{
set_data_port_a(RW); /* Set read bit */
set_data_port_a(RW | E); /* Enable read */
busy = get_data_port_b() & 128; /* Mask busy flag */
} while (busy != 0);
set_data_port_a(RW); /* Clear enable bit */
}
/*
* Function: send_lcd_instruction
* -------------------------------
* Send an instruction code to the LCD.
*
* instruction: instruction code
*/
void send_lcd_instruction(unsigned char instruction)
{
/* Verify busy flag is clear */
wait_for_lcd();
/* Push instruction on data bus */
set_data_direction_port_b(255);
set_data_port_b(instruction);
/* Enable instruction */
set_data_port_a(0); /* Clear RS/RW/E bits */
set_data_port_a(E); /* Set E bit to send instruction */
set_data_port_a(0); /* Clear RS/RW/E bits */
}
/*
* Function: reset_lcd
* --------------------
* Initialize LCD and clear display.
*/
void reset_lcd()
{
set_data_direction_port_a(224);
send_lcd_instruction(56); /* Set 8-bit mode; 2-line display; 5x8 font */
send_lcd_instruction(14); /* Display on; cursor on; blink off */
send_lcd_instruction(6); /* Increment and shift cursor; don't shift */
/* display */
send_lcd_instruction(1); /* Clear display */
}
/*
* Function: print_char_to_lcd
* ----------------------------
* Print single character to LCD. Assumes LCD has been initialized.
*
* character: char to print
*/
void print_char_to_lcd(unsigned char character) {
/* Verify busy flag is clear */
wait_for_lcd();
/* Push character on data bus */
set_data_direction_port_b(255);
set_data_port_b(character);
/* Enable character */
set_data_port_a(RS); /* Set RS; Clear RW/E bits */
set_data_port_a(RS | E); /* Set E bit to send instruction */
set_data_port_a(RS); /* Clear E bit */
}
/*
* Function: print_message_to_lcd
* -------------------------------
* Print string to LCD. Assumes the LCD has been initialized.
*
* character: char to print
*/
void print_message_to_lcd(char *message) {
set_data_direction_port_a(224);
int i = 0;
while (message[i] != 0)
{
print_char_to_lcd(message[i]);
i++;
}
}
| 26.339623 | 76 | 0.598854 |
0c29236dde96ed42003a775773735318d76ba2b0 | 10,589 | h | C | llvm/include/llvm/Analysis/DominatorInternals.h | clairechingching/ScaffCC | 737ae90f85d9fe79819d66219747d27efa4fa5b9 | [
"BSD-2-Clause"
] | 16 | 2015-09-08T08:49:11.000Z | 2019-07-20T14:46:20.000Z | llvm/include/llvm/Analysis/DominatorInternals.h | clairechingching/ScaffCC | 737ae90f85d9fe79819d66219747d27efa4fa5b9 | [
"BSD-2-Clause"
] | 1 | 2020-02-22T09:59:21.000Z | 2020-02-22T09:59:21.000Z | llvm/include/llvm/Analysis/DominatorInternals.h | clairechingching/ScaffCC | 737ae90f85d9fe79819d66219747d27efa4fa5b9 | [
"BSD-2-Clause"
] | 7 | 2016-05-26T17:31:46.000Z | 2020-11-04T06:39:23.000Z | //=== llvm/Analysis/DominatorInternals.h - Dominator Calculation -*- C++ -*-==//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_ANALYSIS_DOMINATOR_INTERNALS_H
#define LLVM_ANALYSIS_DOMINATOR_INTERNALS_H
#include "llvm/Analysis/Dominators.h"
#include "llvm/ADT/SmallPtrSet.h"
//===----------------------------------------------------------------------===//
//
// DominatorTree construction - This pass constructs immediate dominator
// information for a flow-graph based on the algorithm described in this
// document:
//
// A Fast Algorithm for Finding Dominators in a Flowgraph
// T. Lengauer & R. Tarjan, ACM TOPLAS July 1979, pgs 121-141.
//
// This implements the O(n*log(n)) versions of EVAL and LINK, because it turns
// out that the theoretically slower O(n*log(n)) implementation is actually
// faster than the almost-linear O(n*alpha(n)) version, even for large CFGs.
//
//===----------------------------------------------------------------------===//
namespace llvm {
template<class GraphT>
unsigned DFSPass(DominatorTreeBase<typename GraphT::NodeType>& DT,
typename GraphT::NodeType* V, unsigned N) {
// This is more understandable as a recursive algorithm, but we can't use the
// recursive algorithm due to stack depth issues. Keep it here for
// documentation purposes.
#if 0
InfoRec &VInfo = DT.Info[DT.Roots[i]];
VInfo.DFSNum = VInfo.Semi = ++N;
VInfo.Label = V;
Vertex.push_back(V); // Vertex[n] = V;
for (succ_iterator SI = succ_begin(V), E = succ_end(V); SI != E; ++SI) {
InfoRec &SuccVInfo = DT.Info[*SI];
if (SuccVInfo.Semi == 0) {
SuccVInfo.Parent = V;
N = DTDFSPass(DT, *SI, N);
}
}
#else
bool IsChildOfArtificialExit = (N != 0);
SmallVector<std::pair<typename GraphT::NodeType*,
typename GraphT::ChildIteratorType>, 32> Worklist;
Worklist.push_back(std::make_pair(V, GraphT::child_begin(V)));
while (!Worklist.empty()) {
typename GraphT::NodeType* BB = Worklist.back().first;
typename GraphT::ChildIteratorType NextSucc = Worklist.back().second;
typename DominatorTreeBase<typename GraphT::NodeType>::InfoRec &BBInfo =
DT.Info[BB];
// First time we visited this BB?
if (NextSucc == GraphT::child_begin(BB)) {
BBInfo.DFSNum = BBInfo.Semi = ++N;
BBInfo.Label = BB;
DT.Vertex.push_back(BB); // Vertex[n] = V;
if (IsChildOfArtificialExit)
BBInfo.Parent = 1;
IsChildOfArtificialExit = false;
}
// store the DFS number of the current BB - the reference to BBInfo might
// get invalidated when processing the successors.
unsigned BBDFSNum = BBInfo.DFSNum;
// If we are done with this block, remove it from the worklist.
if (NextSucc == GraphT::child_end(BB)) {
Worklist.pop_back();
continue;
}
// Increment the successor number for the next time we get to it.
++Worklist.back().second;
// Visit the successor next, if it isn't already visited.
typename GraphT::NodeType* Succ = *NextSucc;
typename DominatorTreeBase<typename GraphT::NodeType>::InfoRec &SuccVInfo =
DT.Info[Succ];
if (SuccVInfo.Semi == 0) {
SuccVInfo.Parent = BBDFSNum;
Worklist.push_back(std::make_pair(Succ, GraphT::child_begin(Succ)));
}
}
#endif
return N;
}
template<class GraphT>
typename GraphT::NodeType*
Eval(DominatorTreeBase<typename GraphT::NodeType>& DT,
typename GraphT::NodeType *VIn, unsigned LastLinked) {
typename DominatorTreeBase<typename GraphT::NodeType>::InfoRec &VInInfo =
DT.Info[VIn];
if (VInInfo.DFSNum < LastLinked)
return VIn;
SmallVector<typename GraphT::NodeType*, 32> Work;
SmallPtrSet<typename GraphT::NodeType*, 32> Visited;
if (VInInfo.Parent >= LastLinked)
Work.push_back(VIn);
while (!Work.empty()) {
typename GraphT::NodeType* V = Work.back();
typename DominatorTreeBase<typename GraphT::NodeType>::InfoRec &VInfo =
DT.Info[V];
typename GraphT::NodeType* VAncestor = DT.Vertex[VInfo.Parent];
// Process Ancestor first
if (Visited.insert(VAncestor) && VInfo.Parent >= LastLinked) {
Work.push_back(VAncestor);
continue;
}
Work.pop_back();
// Update VInfo based on Ancestor info
if (VInfo.Parent < LastLinked)
continue;
typename DominatorTreeBase<typename GraphT::NodeType>::InfoRec &VAInfo =
DT.Info[VAncestor];
typename GraphT::NodeType* VAncestorLabel = VAInfo.Label;
typename GraphT::NodeType* VLabel = VInfo.Label;
if (DT.Info[VAncestorLabel].Semi < DT.Info[VLabel].Semi)
VInfo.Label = VAncestorLabel;
VInfo.Parent = VAInfo.Parent;
}
return VInInfo.Label;
}
template<class FuncT, class NodeT>
void Calculate(DominatorTreeBase<typename GraphTraits<NodeT>::NodeType>& DT,
FuncT& F) {
typedef GraphTraits<NodeT> GraphT;
unsigned N = 0;
bool MultipleRoots = (DT.Roots.size() > 1);
if (MultipleRoots) {
typename DominatorTreeBase<typename GraphT::NodeType>::InfoRec &BBInfo =
DT.Info[NULL];
BBInfo.DFSNum = BBInfo.Semi = ++N;
BBInfo.Label = NULL;
DT.Vertex.push_back(NULL); // Vertex[n] = V;
}
// Step #1: Number blocks in depth-first order and initialize variables used
// in later stages of the algorithm.
for (unsigned i = 0, e = static_cast<unsigned>(DT.Roots.size());
i != e; ++i)
N = DFSPass<GraphT>(DT, DT.Roots[i], N);
// it might be that some blocks did not get a DFS number (e.g., blocks of
// infinite loops). In these cases an artificial exit node is required.
MultipleRoots |= (DT.isPostDominator() && N != GraphTraits<FuncT*>::size(&F));
// When naively implemented, the Lengauer-Tarjan algorithm requires a separate
// bucket for each vertex. However, this is unnecessary, because each vertex
// is only placed into a single bucket (that of its semidominator), and each
// vertex's bucket is processed before it is added to any bucket itself.
//
// Instead of using a bucket per vertex, we use a single array Buckets that
// has two purposes. Before the vertex V with preorder number i is processed,
// Buckets[i] stores the index of the first element in V's bucket. After V's
// bucket is processed, Buckets[i] stores the index of the next element in the
// bucket containing V, if any.
SmallVector<unsigned, 32> Buckets;
Buckets.resize(N + 1);
for (unsigned i = 1; i <= N; ++i)
Buckets[i] = i;
for (unsigned i = N; i >= 2; --i) {
typename GraphT::NodeType* W = DT.Vertex[i];
typename DominatorTreeBase<typename GraphT::NodeType>::InfoRec &WInfo =
DT.Info[W];
// Step #2: Implicitly define the immediate dominator of vertices
for (unsigned j = i; Buckets[j] != i; j = Buckets[j]) {
typename GraphT::NodeType* V = DT.Vertex[Buckets[j]];
typename GraphT::NodeType* U = Eval<GraphT>(DT, V, i + 1);
DT.IDoms[V] = DT.Info[U].Semi < i ? U : W;
}
// Step #3: Calculate the semidominators of all vertices
// initialize the semi dominator to point to the parent node
WInfo.Semi = WInfo.Parent;
typedef GraphTraits<Inverse<NodeT> > InvTraits;
for (typename InvTraits::ChildIteratorType CI =
InvTraits::child_begin(W),
E = InvTraits::child_end(W); CI != E; ++CI) {
typename InvTraits::NodeType *N = *CI;
if (DT.Info.count(N)) { // Only if this predecessor is reachable!
unsigned SemiU = DT.Info[Eval<GraphT>(DT, N, i + 1)].Semi;
if (SemiU < WInfo.Semi)
WInfo.Semi = SemiU;
}
}
// If V is a non-root vertex and sdom(V) = parent(V), then idom(V) is
// necessarily parent(V). In this case, set idom(V) here and avoid placing
// V into a bucket.
if (WInfo.Semi == WInfo.Parent) {
DT.IDoms[W] = DT.Vertex[WInfo.Parent];
} else {
Buckets[i] = Buckets[WInfo.Semi];
Buckets[WInfo.Semi] = i;
}
}
if (N >= 1) {
typename GraphT::NodeType* Root = DT.Vertex[1];
for (unsigned j = 1; Buckets[j] != 1; j = Buckets[j]) {
typename GraphT::NodeType* V = DT.Vertex[Buckets[j]];
DT.IDoms[V] = Root;
}
}
// Step #4: Explicitly define the immediate dominator of each vertex
for (unsigned i = 2; i <= N; ++i) {
typename GraphT::NodeType* W = DT.Vertex[i];
typename GraphT::NodeType*& WIDom = DT.IDoms[W];
if (WIDom != DT.Vertex[DT.Info[W].Semi])
WIDom = DT.IDoms[WIDom];
}
if (DT.Roots.empty()) return;
// Add a node for the root. This node might be the actual root, if there is
// one exit block, or it may be the virtual exit (denoted by (BasicBlock *)0)
// which postdominates all real exits if there are multiple exit blocks, or
// an infinite loop.
typename GraphT::NodeType* Root = !MultipleRoots ? DT.Roots[0] : 0;
DT.DomTreeNodes[Root] = DT.RootNode =
new DomTreeNodeBase<typename GraphT::NodeType>(Root, 0);
// Loop over all of the reachable blocks in the function...
for (unsigned i = 2; i <= N; ++i) {
typename GraphT::NodeType* W = DT.Vertex[i];
DomTreeNodeBase<typename GraphT::NodeType> *BBNode = DT.DomTreeNodes[W];
if (BBNode) continue; // Haven't calculated this node yet?
typename GraphT::NodeType* ImmDom = DT.getIDom(W);
assert(ImmDom || DT.DomTreeNodes[NULL]);
// Get or calculate the node for the immediate dominator
DomTreeNodeBase<typename GraphT::NodeType> *IDomNode =
DT.getNodeForBlock(ImmDom);
// Add a new tree node for this BasicBlock, and link it as a child of
// IDomNode
DomTreeNodeBase<typename GraphT::NodeType> *C =
new DomTreeNodeBase<typename GraphT::NodeType>(W, IDomNode);
DT.DomTreeNodes[W] = IDomNode->addChild(C);
}
// Free temporary memory used to construct idom's
DT.IDoms.clear();
DT.Info.clear();
std::vector<typename GraphT::NodeType*>().swap(DT.Vertex);
DT.updateDFSNumbers();
}
}
#endif
| 36.513793 | 80 | 0.619416 |
0c296acdb1b645e1db1cc01cd19b202bb96ea14c | 3,563 | h | C | Cores/Yabause/yabause/src/qt/QtYabause.h | werminghoff/Provenance | de61b4a64a3eb8e2774e0a8ed53488c6c7aa6cb2 | [
"BSD-3-Clause"
] | 2 | 2021-02-04T22:41:57.000Z | 2021-03-27T07:28:02.000Z | Cores/Yabause/yabause/src/qt/QtYabause.h | werminghoff/Provenance | de61b4a64a3eb8e2774e0a8ed53488c6c7aa6cb2 | [
"BSD-3-Clause"
] | null | null | null | Cores/Yabause/yabause/src/qt/QtYabause.h | werminghoff/Provenance | de61b4a64a3eb8e2774e0a8ed53488c6c7aa6cb2 | [
"BSD-3-Clause"
] | 3 | 2019-02-19T12:55:12.000Z | 2019-05-30T08:33:23.000Z | /* Copyright 2005 Guillaume Duhamel
Copyright 2005-2006, 2013 Theo Berkau
Copyright 2008 Filipe Azevedo <pasnox@gmail.com>
This file is part of Yabause.
Yabause is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Yabause 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 Yabause; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef QTYABAUSE_H
#define QTYABAUSE_H
extern "C"
{
#ifdef Q_OS_WIN
#include <qt_windows.h>
#endif
#include "../yabause.h"
#include "../peripheral.h"
#include "../sh2core.h"
#include "../sh2int.h"
#include "../vidogl.h"
#include "../vidsoft.h"
#include "../cs0.h"
#include "../cdbase.h"
#include "../scsp.h"
#include "../scspdsp.h"
#include "../scu.h"
#include "../sndal.h"
#ifdef HAVE_DIRECTSOUND
#include "../snddx.h"
#endif
#include "../sndsdl.h"
#if HAVE_DIRECTINPUT
#include "../perdx.h"
#endif
#include "../persdljoy.h"
#include "../permacjoy.h"
#include "../perlinuxjoy.h"
#include "../debug.h"
#include "../m68kcore.h"
#include "../m68kc68k.h"
#include "../vdp1.h"
#include "../vdp2.h"
#include "../cs2.h"
#include "../cheat.h"
#include "../memory.h"
#include "../bios.h"
#include "../m68kd.h"
#include "../sh2d.h"
#include "../sh2iasm.h"
#include "../vdp2debug.h"
#include "PerQt.h"
#ifdef ARCH_IS_MACOSX
#include "../sndmac.h"
#endif
}
#include <QString>
#include <QMap>
class UIYabause;
class Settings;
class VolatileSettings;
class QWidget;
typedef struct
{
QString file;
QString name;
} translation_struct;
namespace QtYabause
{
UIYabause* mainWindow( bool create = true );
Settings* settings( bool create = true );
VolatileSettings* volatileSettings( bool create = true );
QList <translation_struct> getTranslationList();
int setTranslationFile();
int logTranslation();
void closeTranslation();
QString translate( const QString& string );
void retranslateWidgetOnly( QWidget* widget );
void retranslateWidget( QWidget* widget );
void retranslateApplication();
// get cd serial
const char* getCurrentCdSerial();
// get core by id
M68K_struct* getM68KCore( int id );
SH2Interface_struct* getSH2Core( int id );
PerInterface_struct* getPERCore( int id );
CDInterface* getCDCore( int id );
SoundInterface_struct* getSNDCore( int id );
VideoInterface_struct* getVDICore( int id );
// default cores
CDInterface defaultCDCore();
SoundInterface_struct defaultSNDCore();
VideoInterface_struct defaultVIDCore();
OSD_struct defaultOSDCore();
PerInterface_struct defaultPERCore();
SH2Interface_struct defaultSH2Core();
// padsbits
QMap<uint, PerPad_struct*>* portPadsBits( uint portNumber );
void clearPadsBits();
QMap<uint, PerAnalog_struct*>* portAnalogBits( uint portNumber );
void clear3DAnalogBits();
QMap<uint, PerGun_struct*>* portGunBits( uint portNumber );
void clearGunBits();
QMap<uint, PerMouse_struct*>* portMouseBits( uint portNumber );
void clearMouseBits();
};
#endif // QTYABAUSE_H
| 26.589552 | 79 | 0.69913 |
0c2bfb905f2c48805a6023c32b64da51787d4006 | 303 | h | C | Librerias/newLibCAD/libLEDs.h | lumalisan/bbmanu | 60668acac695c4bd677fd4bcee30f2b7a1b1b160 | [
"MIT"
] | null | null | null | Librerias/newLibCAD/libLEDs.h | lumalisan/bbmanu | 60668acac695c4bd677fd4bcee30f2b7a1b1b160 | [
"MIT"
] | null | null | null | Librerias/newLibCAD/libLEDs.h | lumalisan/bbmanu | 60668acac695c4bd677fd4bcee30f2b7a1b1b160 | [
"MIT"
] | null | null | null |
/* ================================ */
/* Libreria LEDs */
/* ================================ */
#define NUMLEDS 6
void initLEDs();
void onLED(unsigned char numLED);
void offLED(unsigned char numLED);
void toggleLED(unsigned char numLED);
void printNumInLED(unsigned char number);
| 21.642857 | 42 | 0.524752 |
0c2e67df4a2ab27ac4d291a51143199e5283695b | 398 | h | C | Acun3D/Light.h | Catchouli-old/Acun3D | 1a34791d30528a442d9734de31b0bcac86cb32d5 | [
"MIT"
] | 1 | 2018-11-15T18:53:44.000Z | 2018-11-15T18:53:44.000Z | Acun3D/Light.h | Catchouli-old/Acun3D | 1a34791d30528a442d9734de31b0bcac86cb32d5 | [
"MIT"
] | null | null | null | Acun3D/Light.h | Catchouli-old/Acun3D | 1a34791d30528a442d9734de31b0bcac86cb32d5 | [
"MIT"
] | null | null | null | #ifndef __LIGHT_H__
#define __LIGHT_H__
#include "LightTypes.h"
#include "Vector.h"
#include "Colour.h"
namespace a3d
{
struct Light
{
public:
const LightType& getType() const;
const Colour& getColour() const;
const Colour& getColourVector() const;
protected:
Light(LightType type, Colour colour);
private:
LightType _type;
Colour _colour;
Colour _colourVector;
};
}
#endif | 14.740741 | 40 | 0.723618 |
0c2e8cea9ff07919c45351b48e933bf44bd9c8ce | 24,095 | h | C | 2.4/include/java/util/ArrayList.h | yaohb/J2ObjCAuto | 8b5252896999f367066e3f68226620f78c020923 | [
"MIT"
] | null | null | null | 2.4/include/java/util/ArrayList.h | yaohb/J2ObjCAuto | 8b5252896999f367066e3f68226620f78c020923 | [
"MIT"
] | null | null | null | 2.4/include/java/util/ArrayList.h | yaohb/J2ObjCAuto | 8b5252896999f367066e3f68226620f78c020923 | [
"MIT"
] | null | null | null | //
// Generated by the J2ObjC translator. DO NOT EDIT!
// source: android/platform/libcore/ojluni/src/main/java/java/util/ArrayList.java
//
#include "J2ObjC_header.h"
#pragma push_macro("INCLUDE_ALL_JavaUtilArrayList")
#ifdef RESTRICT_JavaUtilArrayList
#define INCLUDE_ALL_JavaUtilArrayList 0
#else
#define INCLUDE_ALL_JavaUtilArrayList 1
#endif
#undef RESTRICT_JavaUtilArrayList
#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#if __has_feature(nullability)
#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wnullability"
#pragma GCC diagnostic ignored "-Wnullability-completeness"
#endif
#if !defined (JavaUtilArrayList_) && (INCLUDE_ALL_JavaUtilArrayList || defined(INCLUDE_JavaUtilArrayList))
#define JavaUtilArrayList_
#define RESTRICT_JavaUtilAbstractList 1
#define INCLUDE_JavaUtilAbstractList 1
#include "java/util/AbstractList.h"
#define RESTRICT_JavaUtilList 1
#define INCLUDE_JavaUtilList 1
#include "java/util/List.h"
#define RESTRICT_JavaUtilRandomAccess 1
#define INCLUDE_JavaUtilRandomAccess 1
#include "java/util/RandomAccess.h"
#define RESTRICT_JavaIoSerializable 1
#define INCLUDE_JavaIoSerializable 1
#include "java/io/Serializable.h"
@class IOSObjectArray;
@protocol JavaUtilCollection;
@protocol JavaUtilComparator;
@protocol JavaUtilFunctionConsumer;
@protocol JavaUtilFunctionPredicate;
@protocol JavaUtilFunctionUnaryOperator;
@protocol JavaUtilIterator;
@protocol JavaUtilListIterator;
@protocol JavaUtilSpliterator;
/*!
@brief Resizable-array implementation of the <tt>List</tt> interface.Implements
all optional list operations, and permits all elements, including
<tt>null</tt>.
In addition to implementing the <tt>List</tt> interface,
this class provides methods to manipulate the size of the array that is
used internally to store the list. (This class is roughly equivalent to
<tt>Vector</tt>, except that it is unsynchronized.)
<p>The <tt>size</tt>, <tt>isEmpty</tt>, <tt>get</tt>, <tt>set</tt>,
<tt>iterator</tt>, and <tt>listIterator</tt> operations run in constant
time. The <tt>add</tt> operation runs in <i>amortized constant time</i>,
that is, adding n elements requires O(n) time. All of the other operations
run in linear time (roughly speaking). The constant factor is low compared
to that for the <tt>LinkedList</tt> implementation.
<p>Each <tt>ArrayList</tt> instance has a <i>capacity</i>. The capacity is
the size of the array used to store the elements in the list. It is always
at least as large as the list size. As elements are added to an ArrayList,
its capacity grows automatically. The details of the growth policy are not
specified beyond the fact that adding an element has constant amortized
time cost.
<p>An application can increase the capacity of an <tt>ArrayList</tt> instance
before adding a large number of elements using the <tt>ensureCapacity</tt>
operation. This may reduce the amount of incremental reallocation.
<p><strong>Note that this implementation is not synchronized.</strong>
If multiple threads access an <tt>ArrayList</tt> instance concurrently,
and at least one of the threads modifies the list structurally, it
<i>must</i> be synchronized externally. (A structural modification is
any operation that adds or deletes one or more elements, or explicitly
resizes the backing array; merely setting the value of an element is not
a structural modification.) This is typically accomplished by
synchronizing on some object that naturally encapsulates the list.
If no such object exists, the list should be "wrapped" using the
<code>Collections.synchronizedList</code>
method. This is best done at creation time, to prevent accidental
unsynchronized access to the list:@code
List list = Collections.synchronizedList(new ArrayList(...));
@endcode
<p><a name="fail-fast">
The iterators returned by this class's <code>iterator</code> and
<code>listIterator</code> methods are <em>fail-fast</em>:</a>
if the list is structurally modified at any time after the iterator is
created, in any way except through the iterator's own
<code>remove</code> or
<code>add</code> methods, the iterator will throw a
<code>ConcurrentModificationException</code>. Thus, in the face of
concurrent modification, the iterator fails quickly and cleanly, rather
than risking arbitrary, non-deterministic behavior at an undetermined
time in the future.
<p>Note that the fail-fast behavior of an iterator cannot be guaranteed
as it is, generally speaking, impossible to make any hard guarantees in the
presence of unsynchronized concurrent modification. Fail-fast iterators
throw <code>ConcurrentModificationException</code> on a best-effort basis.
Therefore, it would be wrong to write a program that depended on this
exception for its correctness: <i>the fail-fast behavior of iterators
should be used only to detect bugs.</i>
<p>This class is a member of the
<a href="{@@docRoot}openjdk-redirect.html?v=8&path=/technotes/guides/collections/index.html">
Java Collections Framework</a>.
@author Josh Bloch
@author Neal Gafter
- seealso: Collection
- seealso: List
- seealso: LinkedList
- seealso: Vector
@since 1.2
*/
@interface JavaUtilArrayList : JavaUtilAbstractList < JavaUtilList, JavaUtilRandomAccess, NSCopying, JavaIoSerializable > {
@public
/*!
@brief The array buffer into which the elements of the ArrayList are stored.
The capacity of the ArrayList is the length of this array buffer. Any
empty ArrayList with elementData == DEFAULTCAPACITY_EMPTY_ELEMENTDATA
will be expanded to DEFAULT_CAPACITY when the first element is added.
*/
IOSObjectArray *elementData_;
}
#pragma mark Public
/*!
@brief Constructs an empty list with an initial capacity of ten.
*/
- (instancetype __nonnull)init;
/*!
@brief Constructs a list containing the elements of the specified
collection, in the order they are returned by the collection's
iterator.
@param c the collection whose elements are to be placed into this list
@throw NullPointerExceptionif the specified collection is null
*/
- (instancetype __nonnull)initWithJavaUtilCollection:(id<JavaUtilCollection>)c;
/*!
@brief Constructs an empty list with the specified initial capacity.
@param initialCapacity the initial capacity of the list
@throw IllegalArgumentExceptionif the specified initial capacity
is negative
*/
- (instancetype __nonnull)initWithInt:(jint)initialCapacity;
/*!
@brief Appends the specified element to the end of this list.
@param e element to be appended to this list
@return <tt>true</tt> (as specified by <code>Collection.add</code>)
*/
- (jboolean)addWithId:(id)e;
/*!
@brief Inserts the specified element at the specified position in this
list.Shifts the element currently at that position (if any) and
any subsequent elements to the right (adds one to their indices).
@param index index at which the specified element is to be inserted
@param element element to be inserted
@throw IndexOutOfBoundsException
*/
- (void)addWithInt:(jint)index
withId:(id)element;
/*!
@brief Appends all of the elements in the specified collection to the end of
this list, in the order that they are returned by the
specified collection's Iterator.The behavior of this operation is
undefined if the specified collection is modified while the operation
is in progress.
(This implies that the behavior of this call is
undefined if the specified collection is this list, and this
list is nonempty.)
@param c collection containing elements to be added to this list
@return <tt>true</tt> if this list changed as a result of the call
@throw NullPointerExceptionif the specified collection is null
*/
- (jboolean)addAllWithJavaUtilCollection:(id<JavaUtilCollection>)c;
/*!
@brief Inserts all of the elements in the specified collection into this
list, starting at the specified position.Shifts the element
currently at that position (if any) and any subsequent elements to
the right (increases their indices).
The new elements will appear
in the list in the order that they are returned by the
specified collection's iterator.
@param index index at which to insert the first element from the specified collection
@param c collection containing elements to be added to this list
@return <tt>true</tt> if this list changed as a result of the call
@throw IndexOutOfBoundsException
@throw NullPointerExceptionif the specified collection is null
*/
- (jboolean)addAllWithInt:(jint)index
withJavaUtilCollection:(id<JavaUtilCollection>)c;
/*!
@brief Removes all of the elements from this list.The list will
be empty after this call returns.
*/
- (void)clear;
/*!
@brief Returns a shallow copy of this <tt>ArrayList</tt> instance.
(The
elements themselves are not copied.)
@return a clone of this <tt>ArrayList</tt> instance
*/
- (id __nonnull)java_clone;
/*!
@brief Returns <tt>true</tt> if this list contains the specified element.
More formally, returns <tt>true</tt> if and only if this list contains
at least one element <tt>e</tt> such that
<tt>(o==null ? e==null : o.equals(e))</tt>.
@param o element whose presence in this list is to be tested
@return <tt>true</tt> if this list contains the specified element
*/
- (jboolean)containsWithId:(id)o;
/*!
@brief Increases the capacity of this <tt>ArrayList</tt> instance, if
necessary, to ensure that it can hold at least the number of elements
specified by the minimum capacity argument.
@param minCapacity the desired minimum capacity
*/
- (void)ensureCapacityWithInt:(jint)minCapacity;
- (void)forEachWithJavaUtilFunctionConsumer:(id<JavaUtilFunctionConsumer>)action;
/*!
@brief Returns the element at the specified position in this list.
@param index index of the element to return
@return the element at the specified position in this list
@throw IndexOutOfBoundsException
*/
- (id)getWithInt:(jint)index;
/*!
@brief Returns the index of the first occurrence of the specified element
in this list, or -1 if this list does not contain the element.
More formally, returns the lowest index <tt>i</tt> such that
<tt>(o==null ? get(i)==null : o.equals(get(i)))</tt>,
or -1 if there is no such index.
*/
- (jint)indexOfWithId:(id)o;
/*!
@brief Returns <tt>true</tt> if this list contains no elements.
@return <tt>true</tt> if this list contains no elements
*/
- (jboolean)isEmpty;
/*!
@brief Returns an iterator over the elements in this list in proper sequence.
<p>The returned iterator is <a href="#fail-fast"><i>fail-fast</i></a>.
@return an iterator over the elements in this list in proper sequence
*/
- (id<JavaUtilIterator> __nonnull)iterator;
/*!
@brief Returns the index of the last occurrence of the specified element
in this list, or -1 if this list does not contain the element.
More formally, returns the highest index <tt>i</tt> such that
<tt>(o==null ? get(i)==null : o.equals(get(i)))</tt>,
or -1 if there is no such index.
*/
- (jint)lastIndexOfWithId:(id)o;
/*!
@brief Returns a list iterator over the elements in this list (in proper
sequence).
<p>The returned list iterator is <a href="#fail-fast"><i>fail-fast</i></a>.
- seealso: #listIterator(int)
*/
- (id<JavaUtilListIterator> __nonnull)listIterator;
/*!
@brief Returns a list iterator over the elements in this list (in proper
sequence), starting at the specified position in the list.
The specified index indicates the first element that would be
returned by an initial call to <code>next</code>.
An initial call to <code>previous</code> would
return the element with the specified index minus one.
<p>The returned list iterator is <a href="#fail-fast"><i>fail-fast</i></a>.
@throw IndexOutOfBoundsException
*/
- (id<JavaUtilListIterator> __nonnull)listIteratorWithInt:(jint)index;
/*!
@brief Removes the element at the specified position in this list.
Shifts any subsequent elements to the left (subtracts one from their
indices).
@param index the index of the element to be removed
@return the element that was removed from the list
@throw IndexOutOfBoundsException
*/
- (id)removeWithInt:(jint)index;
/*!
@brief Removes the first occurrence of the specified element from this list,
if it is present.If the list does not contain the element, it is
unchanged.
More formally, removes the element with the lowest index
<tt>i</tt> such that
<tt>(o==null ? get(i)==null : o.equals(get(i)))</tt>
(if such an element exists). Returns <tt>true</tt> if this list
contained the specified element (or equivalently, if this list
changed as a result of the call).
@param o element to be removed from this list, if present
@return <tt>true</tt> if this list contained the specified element
*/
- (jboolean)removeWithId:(id)o;
/*!
@brief Removes from this list all of its elements that are contained in the
specified collection.
@param c collection containing elements to be removed from this list
@return <code>true</code> if this list changed as a result of the call
@throw ClassCastExceptionif the class of an element of this list
is incompatible with the specified collection
(<a href="Collection.html#optional-restrictions">optional</a>)
@throw NullPointerExceptionif this list contains a null element and the
specified collection does not permit null elements
(<a href="Collection.html#optional-restrictions">optional</a>),
or if the specified collection is null
- seealso: Collection#contains(Object)
*/
- (jboolean)removeAllWithJavaUtilCollection:(id<JavaUtilCollection>)c;
- (jboolean)removeIfWithJavaUtilFunctionPredicate:(id<JavaUtilFunctionPredicate>)filter;
- (void)replaceAllWithJavaUtilFunctionUnaryOperator:(id<JavaUtilFunctionUnaryOperator>)operator_;
/*!
@brief Retains only the elements in this list that are contained in the
specified collection.In other words, removes from this list all
of its elements that are not contained in the specified collection.
@param c collection containing elements to be retained in this list
@return <code>true</code> if this list changed as a result of the call
@throw ClassCastExceptionif the class of an element of this list
is incompatible with the specified collection
(<a href="Collection.html#optional-restrictions">optional</a>)
@throw NullPointerExceptionif this list contains a null element and the
specified collection does not permit null elements
(<a href="Collection.html#optional-restrictions">optional</a>),
or if the specified collection is null
- seealso: Collection#contains(Object)
*/
- (jboolean)retainAllWithJavaUtilCollection:(id<JavaUtilCollection>)c;
/*!
@brief Replaces the element at the specified position in this list with
the specified element.
@param index index of the element to replace
@param element element to be stored at the specified position
@return the element previously at the specified position
@throw IndexOutOfBoundsException
*/
- (id)setWithInt:(jint)index
withId:(id)element;
/*!
@brief Returns the number of elements in this list.
@return the number of elements in this list
*/
- (jint)size;
- (void)sortWithJavaUtilComparator:(id<JavaUtilComparator>)c;
/*!
@brief Creates a <em><a href="Spliterator.html#binding">late-binding</a></em>
and <em>fail-fast</em> <code>Spliterator</code> over the elements in this
list.
<p>The <code>Spliterator</code> reports <code>Spliterator.SIZED</code>,
<code>Spliterator.SUBSIZED</code>, and <code>Spliterator.ORDERED</code>.
Overriding implementations should document the reporting of additional
characteristic values.
@return a <code>Spliterator</code> over the elements in this list
@since 1.8
*/
- (id<JavaUtilSpliterator> __nonnull)spliterator;
/*!
@brief Returns a view of the portion of this list between the specified
<code>fromIndex</code>, inclusive, and <code>toIndex</code>, exclusive.
(If
<code>fromIndex</code> and <code>toIndex</code> are equal, the returned list is
empty.) The returned list is backed by this list, so non-structural
changes in the returned list are reflected in this list, and vice-versa.
The returned list supports all of the optional list operations.
<p>This method eliminates the need for explicit range operations (of
the sort that commonly exist for arrays). Any operation that expects
a list can be used as a range operation by passing a subList view
instead of a whole list. For example, the following idiom
removes a range of elements from a list:
@code
list.subList(from, to).clear();
@endcode
Similar idioms may be constructed for <code>indexOf(Object)</code> and
<code>lastIndexOf(Object)</code>, and all of the algorithms in the
<code>Collections</code> class can be applied to a subList.
<p>The semantics of the list returned by this method become undefined if
the backing list (i.e., this list) is <i>structurally modified</i> in
any way other than via the returned list. (Structural modifications are
those that change the size of this list, or otherwise perturb it in such
a fashion that iterations in progress may yield incorrect results.)
@throw IndexOutOfBoundsException
@throw IllegalArgumentException
*/
- (id<JavaUtilList> __nonnull)subListWithInt:(jint)fromIndex
withInt:(jint)toIndex;
/*!
@brief Returns an array containing all of the elements in this list
in proper sequence (from first to last element).
<p>The returned array will be "safe" in that no references to it are
maintained by this list. (In other words, this method must allocate
a new array). The caller is thus free to modify the returned array.
<p>This method acts as bridge between array-based and collection-based
APIs.
@return an array containing all of the elements in this list in
proper sequence
*/
- (IOSObjectArray * __nonnull)toArray;
/*!
@brief Returns an array containing all of the elements in this list in proper
sequence (from first to last element); the runtime type of the returned
array is that of the specified array.If the list fits in the
specified array, it is returned therein.
Otherwise, a new array is
allocated with the runtime type of the specified array and the size of
this list.
<p>If the list fits in the specified array with room to spare
(i.e., the array has more elements than the list), the element in
the array immediately following the end of the collection is set to
<tt>null</tt>. (This is useful in determining the length of the
list <i>only</i> if the caller knows that the list does not contain
any null elements.)
@param a the array into which the elements of the list are to be stored, if it is big enough; otherwise, a new array of the
same runtime type is allocated for this purpose.
@return an array containing the elements of the list
@throw ArrayStoreExceptionif the runtime type of the specified array
is not a supertype of the runtime type of every element in
this list
@throw NullPointerExceptionif the specified array is null
*/
- (IOSObjectArray * __nonnull)toArrayWithNSObjectArray:(IOSObjectArray *)a;
/*!
@brief Trims the capacity of this <tt>ArrayList</tt> instance to be the
list's current size.An application can use this operation to minimize
the storage of an <tt>ArrayList</tt> instance.
*/
- (void)trimToSize;
#pragma mark Protected
/*!
@brief Removes from this list all of the elements whose index is between
<code>fromIndex</code>, inclusive, and <code>toIndex</code>, exclusive.
Shifts any succeeding elements to the left (reduces their index).
This call shortens the list by <code>(toIndex - fromIndex)</code> elements.
(If <code>toIndex==fromIndex</code>, this operation has no effect.)
@throw IndexOutOfBoundsExceptionif <code>fromIndex</code> or
<code>toIndex</code> is out of range
(<code>fromIndex < 0 ||
fromIndex >= size() ||
toIndex > size() ||
toIndex < fromIndex</code>
)
*/
- (void)removeRangeWithInt:(jint)fromIndex
withInt:(jint)toIndex;
#pragma mark Package-Private
+ (void)subListRangeCheckWithInt:(jint)fromIndex
withInt:(jint)toIndex
withInt:(jint)size;
@end
J2OBJC_STATIC_INIT(JavaUtilArrayList)
J2OBJC_FIELD_SETTER(JavaUtilArrayList, elementData_, IOSObjectArray *)
FOUNDATION_EXPORT void JavaUtilArrayList_initWithInt_(JavaUtilArrayList *self, jint initialCapacity);
FOUNDATION_EXPORT JavaUtilArrayList *new_JavaUtilArrayList_initWithInt_(jint initialCapacity) NS_RETURNS_RETAINED;
FOUNDATION_EXPORT JavaUtilArrayList *create_JavaUtilArrayList_initWithInt_(jint initialCapacity);
FOUNDATION_EXPORT void JavaUtilArrayList_init(JavaUtilArrayList *self);
FOUNDATION_EXPORT JavaUtilArrayList *new_JavaUtilArrayList_init(void) NS_RETURNS_RETAINED;
FOUNDATION_EXPORT JavaUtilArrayList *create_JavaUtilArrayList_init(void);
FOUNDATION_EXPORT void JavaUtilArrayList_initWithJavaUtilCollection_(JavaUtilArrayList *self, id<JavaUtilCollection> c);
FOUNDATION_EXPORT JavaUtilArrayList *new_JavaUtilArrayList_initWithJavaUtilCollection_(id<JavaUtilCollection> c) NS_RETURNS_RETAINED;
FOUNDATION_EXPORT JavaUtilArrayList *create_JavaUtilArrayList_initWithJavaUtilCollection_(id<JavaUtilCollection> c);
FOUNDATION_EXPORT void JavaUtilArrayList_subListRangeCheckWithInt_withInt_withInt_(jint fromIndex, jint toIndex, jint size);
J2OBJC_TYPE_LITERAL_HEADER(JavaUtilArrayList)
#endif
#if !defined (JavaUtilArrayList_ArrayListSpliterator_) && (INCLUDE_ALL_JavaUtilArrayList || defined(INCLUDE_JavaUtilArrayList_ArrayListSpliterator))
#define JavaUtilArrayList_ArrayListSpliterator_
#define RESTRICT_JavaUtilSpliterator 1
#define INCLUDE_JavaUtilSpliterator 1
#include "java/util/Spliterator.h"
@class JavaUtilArrayList;
@protocol JavaUtilComparator;
@protocol JavaUtilFunctionConsumer;
/*!
@brief Index-based split-by-two, lazily initialized Spliterator
*/
@interface JavaUtilArrayList_ArrayListSpliterator : NSObject < JavaUtilSpliterator >
#pragma mark Public
- (jint)characteristics;
- (jlong)estimateSize;
- (void)forEachRemainingWithJavaUtilFunctionConsumer:(id<JavaUtilFunctionConsumer>)action;
- (jboolean)tryAdvanceWithJavaUtilFunctionConsumer:(id<JavaUtilFunctionConsumer>)action;
- (JavaUtilArrayList_ArrayListSpliterator *)trySplit;
#pragma mark Package-Private
/*!
@brief Create new spliterator covering the given range
*/
- (instancetype __nonnull)initWithJavaUtilArrayList:(JavaUtilArrayList *)list
withInt:(jint)origin
withInt:(jint)fence
withInt:(jint)expectedModCount;
// Disallowed inherited constructors, do not use.
- (instancetype __nonnull)init NS_UNAVAILABLE;
@end
J2OBJC_EMPTY_STATIC_INIT(JavaUtilArrayList_ArrayListSpliterator)
FOUNDATION_EXPORT void JavaUtilArrayList_ArrayListSpliterator_initWithJavaUtilArrayList_withInt_withInt_withInt_(JavaUtilArrayList_ArrayListSpliterator *self, JavaUtilArrayList *list, jint origin, jint fence, jint expectedModCount);
FOUNDATION_EXPORT JavaUtilArrayList_ArrayListSpliterator *new_JavaUtilArrayList_ArrayListSpliterator_initWithJavaUtilArrayList_withInt_withInt_withInt_(JavaUtilArrayList *list, jint origin, jint fence, jint expectedModCount) NS_RETURNS_RETAINED;
FOUNDATION_EXPORT JavaUtilArrayList_ArrayListSpliterator *create_JavaUtilArrayList_ArrayListSpliterator_initWithJavaUtilArrayList_withInt_withInt_withInt_(JavaUtilArrayList *list, jint origin, jint fence, jint expectedModCount);
J2OBJC_TYPE_LITERAL_HEADER(JavaUtilArrayList_ArrayListSpliterator)
#endif
#if __has_feature(nullability)
#pragma clang diagnostic pop
#endif
#pragma clang diagnostic pop
#pragma pop_macro("INCLUDE_ALL_JavaUtilArrayList")
| 40.908319 | 245 | 0.764847 |
0c2f357880318b0ea4f1fa3167f7333dea68b1b0 | 4,204 | c | C | src/sss.c | RiddleAndCode/sss | 7926a05abae9f29b735d37da741be795b5e77865 | [
"MIT"
] | null | null | null | src/sss.c | RiddleAndCode/sss | 7926a05abae9f29b735d37da741be795b5e77865 | [
"MIT"
] | null | null | null | src/sss.c | RiddleAndCode/sss | 7926a05abae9f29b735d37da741be795b5e77865 | [
"MIT"
] | null | null | null | /*
* AEAD wrapper around the Secret shared data
*
* Author: Daan Sprenkels <hello@dsprenkels.com>
*
* This module implements a AEAD wrapper around some secret shared data,
* allowing the data to be in any format. (Directly secret-sharing requires the
* message to be picked uniformly in the message space.)
*
* The NaCl cryptographic library is used for the encryption. The encryption
* scheme that is used for wrapping the message is salsa20/poly1305. Because
* we are using an ephemeral key, we are using a zero'd nonce.
*/
//#include "randombytes.h"
#include "tweetnacl.h"
#include "sss.h"
#include "tweetnacl.h"
#include <assert.h>
#include <string.h>
/*
* These assertions may be considered overkill, but would if the tweetnacl API
* ever change we *really* want to prevent buffer overflow vulnerabilities.
*/
#if crypto_secretbox_KEYBYTES != 32
# error "crypto_secretbox_KEYBYTES size is invalid"
#endif
/*
* Nonce for the `crypto_secretbox` authenticated encryption.
* The nonce is constant (zero), because we are using an ephemeral key.
*/
static const unsigned char nonce[crypto_secretbox_NONCEBYTES] = { 0 };
/*
* Return a mutable pointer to the ciphertext part of this Share
*/
static uint8_t* get_ciphertext(sss_Share *share) {
return &((uint8_t*) share)[sss_KEYSHARE_LEN];
}
/*
* Return a mutable pointer to the Keyshare part of this Share
*/
static sss_Keyshare* get_keyshare(sss_Share *share) {
return (sss_Keyshare*) &share[0];
}
/*
* Return a const pointer to the ciphertext part of this Share
*/
static const uint8_t* get_ciphertext_const(const sss_Share *share) {
return &((const uint8_t*) share)[sss_KEYSHARE_LEN];
}
/*
* Return a const pointer to the Keyshare part of this Share
*/
static const sss_Keyshare* get_keyshare_const(const sss_Share *share) {
return (const sss_Keyshare*) &share[0];
}
/*
* Create `n` shares with theshold `k` and write them to `out`
*/
void sss_create_shares(sss_Share *out, const unsigned char *data,
uint8_t n, uint8_t k) {
unsigned char key[32];
unsigned char m[crypto_secretbox_ZEROBYTES + sss_MLEN] = { 0 };
unsigned long long mlen = sizeof(m); /* length includes zero-bytes */
unsigned char c[mlen];
int tmp;
sss_Keyshare keyshares[n];
size_t idx;
/* Generate a random encryption key */
randombytes(key, sizeof(key));
/* AEAD encrypt the data with the key */
memcpy(&m[crypto_secretbox_ZEROBYTES], data, sss_MLEN);
tmp = crypto_secretbox(c, m, mlen, nonce, key);
assert(tmp == 0); /* should always happen */
/* Generate KeyShares */
sss_create_keyshares(keyshares, key, n, k);
/* Build regular shares */
for (idx = 0; idx < n; idx++) {
memcpy(get_keyshare(&out[idx]), &keyshares[idx][0],
sss_KEYSHARE_LEN);
memcpy(get_ciphertext(&out[idx]),
&c[crypto_secretbox_BOXZEROBYTES], sss_CLEN);
}
}
/*
* Combine `k` shares pointed to by `shares` and write the result to `data`
*
* This function returns -1 if any of the shares were corrupted or if the number
* of shares was too low. It is not possible to detect which of these errors
* did occur.
*/
int sss_combine_shares(uint8_t *data, const sss_Share *shares, uint8_t k) {
unsigned char key[crypto_secretbox_KEYBYTES];
unsigned char c[crypto_secretbox_BOXZEROBYTES + sss_CLEN] = { 0 };
unsigned long long clen = sizeof(c);
unsigned char m[clen];
sss_Keyshare keyshares[k];
size_t idx;
int ret = 0;
/* Check if all ciphertexts are the same */
if (k < 1) {
return -1;
}
for (idx = 1; idx < k; idx++) {
if (memcmp(get_ciphertext_const(&shares[0]),
get_ciphertext_const(&shares[idx]), sss_CLEN) != 0) {
return -1;
}
}
/* Restore the key */
for (idx = 0; idx < k; idx++) {
memcpy(&keyshares[idx], get_keyshare_const(&shares[idx]),
sss_KEYSHARE_LEN);
}
sss_combine_keyshares(key, (const sss_Keyshare*) keyshares, k);
/* Decrypt the ciphertext */
memcpy(&c[crypto_secretbox_BOXZEROBYTES],
&shares[0][sss_KEYSHARE_LEN], sss_CLEN);
ret |= crypto_secretbox_open(m, c, clen, nonce, key);
memcpy(data, &m[crypto_secretbox_ZEROBYTES], sss_MLEN);
return ret;
}
| 28.405405 | 80 | 0.693387 |
0c2fef23256990457122edfaee07d38d45fbfa4f | 577 | h | C | hikyuu_cpp/hikyuu/trade_sys/profitgoal/imp/FixedPercentProfitGoal.h | waruqi/hikyuu | 5d252eafff3e4e9ab41af4e2c492b38ff764214d | [
"MIT"
] | 1 | 2019-05-12T23:48:13.000Z | 2019-05-12T23:48:13.000Z | hikyuu_cpp/hikyuu/trade_sys/profitgoal/imp/FixedPercentProfitGoal.h | allen9mu/hikyuu | bed68183029e5a653e3e0ad53510036605e1d610 | [
"MIT"
] | 1 | 2019-04-16T03:23:15.000Z | 2019-04-16T03:23:15.000Z | hikyuu_cpp/hikyuu/trade_sys/profitgoal/imp/FixedPercentProfitGoal.h | archya/hikyuu | 2305a977a78bab832bf8fcb4d66482dfef442c9d | [
"MIT"
] | 1 | 2020-03-31T16:45:23.000Z | 2020-03-31T16:45:23.000Z | /*
* FixedPercentProfitGoal.h
*
* Created on: 2016年5月6日
* Author: Administrator
*/
#ifndef TRADE_SYS_PROFITGOAL_IMP_FIXEDPERCENTPROFITGOAL_H_
#define TRADE_SYS_PROFITGOAL_IMP_FIXEDPERCENTPROFITGOAL_H_
#include "../ProfitGoalBase.h"
namespace hku {
class FixedPercentProfitGoal: public ProfitGoalBase {
PROFITGOAL_IMP(FixedPercentProfitGoal)
PROFIT_GOAL_NO_PRIVATE_MEMBER_SERIALIZATION
public:
FixedPercentProfitGoal();
virtual ~FixedPercentProfitGoal();
};
} /* namespace hku */
#endif /* TRADE_SYS_PROFITGOAL_IMP_FIXEDPERCENTPROFITGOAL_H_ */
| 21.37037 | 63 | 0.790295 |
0c313bbf928f0efd6d54e718156b2882822fbb88 | 1,851 | h | C | generic/tclstuff.h | RubyLane/parse_args | 887774eceb2fb14b7db9df91974e8ec081203707 | [
"TCL"
] | 5 | 2018-01-11T12:56:22.000Z | 2020-01-04T15:49:39.000Z | generic/tclstuff.h | RubyLane/parse_args | 887774eceb2fb14b7db9df91974e8ec081203707 | [
"TCL"
] | 3 | 2018-05-10T16:41:23.000Z | 2022-02-28T08:03:37.000Z | generic/tclstuff.h | RubyLane/parse_args | 887774eceb2fb14b7db9df91974e8ec081203707 | [
"TCL"
] | 3 | 2017-04-16T11:30:31.000Z | 2022-01-06T09:13:21.000Z | // Written by Cyan Ogilvie, and placed in the public domain
#ifndef _TCLSTUFF_H
#define _TCLSTUFF_H
#include "tcl.h"
#define NEW_CMD( tcl_cmd, c_cmd ) \
Tcl_CreateObjCommand( interp, tcl_cmd, \
(Tcl_ObjCmdProc *) c_cmd, \
(ClientData *) NULL, NULL );
#define THROW_ERROR(...) \
{ \
Tcl_Obj *res; \
res = Tcl_GetObjResult( interp ); \
Tcl_AppendStringsToObj( res, __VA_ARGS__, NULL ); \
return TCL_ERROR; \
}
#define THROW_ERROR_LABEL( label, var, ... ) \
{ \
Tcl_Obj *res; \
res = Tcl_GetObjResult( interp ); \
Tcl_AppendStringsToObj( res, __VA_ARGS__, NULL ); \
var = TCL_ERROR; \
goto label; \
}
// convenience macro to check the number of arguments passed to a function
// implementing a tcl command against the number expected, and to throw
// a tcl error if they don't match. Note that the value of expected does
// not include the objv[0] object (the function itself)
#define CHECK_ARGS(expected, msg) \
if (objc != expected + 1) { \
Tcl_Obj *res; \
res = Tcl_GetObjResult( interp ); \
Tcl_AppendStringsToObj( res, "Wrong # of arguments. Must be \"", \
msg, "\"", NULL ); \
return TCL_ERROR; \
}
// A rather frivolous macro that just enhances readability for a common case
#ifdef DEBUG
#warning Using DEBUG version of TEST_OK
#define TEST_OK( cmd ) \
if ((cmd) != TCL_OK) { \
fprintf( stderr, "TEST_OK() returned TCL_ERROR\n" ); \
return TCL_ERROR; \
}
#define TEST_OK_LABEL( label, var, cmd ) \
if ((cmd) != TCL_OK) { \
var = TCL_ERROR; \
goto label; \
}
#else
#define TEST_OK( cmd ) \
if ((cmd) != TCL_OK) return TCL_ERROR;
#endif
#define TEST_OK_LABEL( label, var, cmd ) \
if ((cmd) != TCL_OK) { \
var = TCL_ERROR; \
goto label; \
}
#define UNREF(ref) \
if ((ref) != NULL) { \
Tcl_DecrRefCount(ref); \
(ref) = NULL; \
}
#endif
| 24.68 | 76 | 0.643976 |
0c3163a8e3c41cfff26b73b4de9f043a08cc8b6b | 1,570 | c | C | CodeChef/Contest/That_Is_My_Score.c | GSri30/Competetive_programming | 0dc1681500a80b6f0979d0dc9f749357ee07bcb8 | [
"MIT"
] | 22 | 2020-01-03T17:32:00.000Z | 2021-11-07T09:31:44.000Z | CodeChef/Contest/That_Is_My_Score.c | GSri30/Competetive_programming | 0dc1681500a80b6f0979d0dc9f749357ee07bcb8 | [
"MIT"
] | 10 | 2020-09-30T09:41:18.000Z | 2020-10-11T11:25:09.000Z | CodeChef/Contest/That_Is_My_Score.c | GSri30/Competetive_programming | 0dc1681500a80b6f0979d0dc9f749357ee07bcb8 | [
"MIT"
] | 25 | 2019-10-14T19:25:01.000Z | 2021-05-26T08:12:20.000Z | #include<stdio.h>
#include<stdlib.h>
int main()
{
int test;
scanf("%d",&test);
while(test > 0)
{
int attempts;
scanf("%d",&attempts);
int sum = 0;
int q[attempts];
int scores[attempts];
int max1 = 0;
int max2 = 0;
int max3 = 0;
int max4 = 0;
int max5 = 0;
int max6 = 0;
int max7 = 0;
int max8 = 0;
int i = 0;
for(i = 0;i < attempts;i++)
{
scanf("%d%d",&q[i],&scores[i]);
if(q[i] == 1)
{
if(scores[i] > max1)
{
max1 = scores[i];
}
}
else if(q[i] == 2)
{
if(scores[i] > max2)
{
max2 = scores[i];
}
}
else if(q[i] == 3)
{
if(scores[i] > max3)
{
max3 = scores[i];
}
}
else if(q[i] == 4)
{
if(scores[i] > max4)
{
max4 = scores[i];
}
}
else if(q[i] == 5)
{
if(scores[i] > max5)
{
max5 = scores[i];
}
}
else if(q[i] == 6)
{
if(scores[i] > max6)
{
max6 = scores[i];
}
}
else if(q[i] == 7)
{
if(scores[i] > max7)
{
max7 = scores[i];
}
}
else if(q[i] == 8)
{
if(scores[i] > max8)
{
max8 = scores[i];
}
}
else
{
sum += 0;
}
}
sum = max1 + max2 + max3 + max4 + max5 + max6 + max7 + max8;
printf("%d\n",sum);
test --;
}
return 0;
}
| 16.526316 | 64 | 0.348408 |
0c323240a57f4064d4011c8288f8ea42bfe0cfac | 903 | h | C | Example/Pods/Headers/Private/EDKeyboardHandler/EDKeyboardHandler.h | merend/EDKeyboardHandler | 1d3eb651aefaf9cb0e14ccdc0bfdd9baa1fc6f5a | [
"MIT"
] | 5 | 2016-04-28T07:48:51.000Z | 2020-02-14T06:56:49.000Z | Example/Pods/Headers/Private/EDKeyboardHandler/EDKeyboardHandler.h | merend/EDKeyboardHandler | 1d3eb651aefaf9cb0e14ccdc0bfdd9baa1fc6f5a | [
"MIT"
] | null | null | null | Example/Pods/Headers/Private/EDKeyboardHandler/EDKeyboardHandler.h | merend/EDKeyboardHandler | 1d3eb651aefaf9cb0e14ccdc0bfdd9baa1fc6f5a | [
"MIT"
] | null | null | null | //
// UIView+Keyboard.h
//
// Created by Eren Demirbüken on 25/12/15.
// Copyright © 2015 Eren Demirbüken. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef enum : NSUInteger {
KeyboardStatusDidShow,
KeyboardStatusWillShow,
KeyboardStatusDidHide,
KeyboardStatusWillHide,
} KeyboardStatus;
@interface KeyboardInfo:NSObject
@property (nonatomic,readonly) NSTimeInterval animationDuration;
@property (nonatomic,readonly) CGRect keyboardFrame;
@property (nonatomic,readonly) UIViewAnimationCurve animationCurve;
@property (nonatomic,readonly) KeyboardStatus status;
@end
@protocol KeyboardHandlerDelegate <NSObject>
@optional
- (void)currentKeyboardInfo:(KeyboardInfo *) keyboardInfo;
@end
@interface EDKeyboardHandler:NSObject
- (instancetype) initWithDelegate:(id<KeyboardHandlerDelegate>)theDelegate;
- (void)listenWithBlock:(void (^)(KeyboardInfo *))block;
@end
| 22.02439 | 75 | 0.777409 |
0c3331aa5436ddb0e8a306297605a601c6992c23 | 5,756 | c | C | benchmarks/Angha_original/extr_res_findzonecut_get_soa/extr_res_findzonecut_get_soa.c | ComputerSystemsLab/OptimizationCache | 9c30ae120673e57b772ea42e29e087f775aa9de9 | [
"Apache-2.0"
] | 2 | 2021-03-11T00:46:25.000Z | 2021-07-08T16:44:58.000Z | benchmarks/Angha_original/extr_res_findzonecut_get_soa/extr_res_findzonecut_get_soa.c | ComputerSystemsLab/OptimizationCache | 9c30ae120673e57b772ea42e29e087f775aa9de9 | [
"Apache-2.0"
] | null | null | null | benchmarks/Angha_original/extr_res_findzonecut_get_soa/extr_res_findzonecut_get_soa.c | ComputerSystemsLab/OptimizationCache | 9c30ae120673e57b772ea42e29e087f775aa9de9 | [
"Apache-2.0"
] | null | null | null | #define NULL ((void*)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t; typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1
/* Forward declarations */
/* Type definitions */
typedef scalar_t__ u_int ;
typedef int /*<<< orphan*/ u_char ;
typedef int /*<<< orphan*/ rrset_ns ;
typedef int /*<<< orphan*/ res_state ;
typedef int ns_sect ;
typedef int /*<<< orphan*/ ns_rr ;
typedef int /*<<< orphan*/ ns_msg ;
typedef scalar_t__ ns_class ;
/* Variables and functions */
int /*<<< orphan*/ DPRINTF (char*) ;
int /*<<< orphan*/ EDESTADDRREQ ;
int /*<<< orphan*/ EMSGSIZE ;
int /*<<< orphan*/ EPROTOTYPE ;
int NS_MAXDNAME ;
int /*<<< orphan*/ NS_MAXMSG ;
int /*<<< orphan*/ abort () ;
int do_query (int /*<<< orphan*/ ,char const*,scalar_t__,scalar_t__,int /*<<< orphan*/ *,int /*<<< orphan*/ *) ;
int /*<<< orphan*/ errno ;
int /*<<< orphan*/ free (int /*<<< orphan*/ *) ;
int /*<<< orphan*/ * malloc (int /*<<< orphan*/ ) ;
int /*<<< orphan*/ ns_f_rcode ;
scalar_t__ ns_makecanon (char const*,char*,int) ;
int ns_msg_count (int /*<<< orphan*/ ,int) ;
int /*<<< orphan*/ ns_msg_end (int /*<<< orphan*/ ) ;
scalar_t__ ns_msg_getflag (int /*<<< orphan*/ ,int /*<<< orphan*/ ) ;
scalar_t__ ns_name_uncompress (int /*<<< orphan*/ *,int /*<<< orphan*/ ,int /*<<< orphan*/ const*,char*,size_t) ;
int /*<<< orphan*/ ns_o_query ;
scalar_t__ ns_parserr (int /*<<< orphan*/ *,int,int,int /*<<< orphan*/ *) ;
scalar_t__ ns_r_noerror ;
scalar_t__ ns_rr_class (int /*<<< orphan*/ ) ;
char* ns_rr_name (int /*<<< orphan*/ ) ;
int /*<<< orphan*/ * ns_rr_rdata (int /*<<< orphan*/ ) ;
scalar_t__ ns_rr_type (int /*<<< orphan*/ ) ;
#define ns_s_an 129
int ns_s_max ;
#define ns_s_ns 128
int /*<<< orphan*/ ns_samedomain (char const*,char const*) ;
int ns_samename (char const*,char const*) ;
scalar_t__ ns_t_cname ;
scalar_t__ ns_t_dname ;
scalar_t__ ns_t_soa ;
int /*<<< orphan*/ p_class (scalar_t__) ;
int /*<<< orphan*/ p_section (int,int /*<<< orphan*/ ) ;
scalar_t__ save_ns (int /*<<< orphan*/ ,int /*<<< orphan*/ *,int,char*,scalar_t__,int,int /*<<< orphan*/ *) ;
int /*<<< orphan*/ strcpy (char*,char const*) ;
int strlen (char const*) ;
__attribute__((used)) static int
get_soa(res_state statp, const char *dname, ns_class class, int opts,
char *zname, size_t zsize, char *mname, size_t msize,
rrset_ns *nsrrsp)
{
char tname[NS_MAXDNAME];
u_char *resp = NULL;
int n, i, ancount, nscount;
ns_sect sect;
ns_msg msg;
u_int rcode;
/*
* Find closest enclosing SOA, even if it's for the root zone.
*/
/* First canonicalize dname (exactly one unescaped trailing "."). */
if (ns_makecanon(dname, tname, sizeof tname) < 0)
goto cleanup;
dname = tname;
resp = malloc(NS_MAXMSG);
if (resp == NULL)
goto cleanup;
/* Now grovel the subdomains, hunting for an SOA answer or auth. */
for (;;) {
/* Leading or inter-label '.' are skipped here. */
while (*dname == '.')
dname++;
/* Is there an SOA? */
n = do_query(statp, dname, class, ns_t_soa, resp, &msg);
if (n < 0) {
DPRINTF(("get_soa: do_query('%s', %s) failed (%d)",
dname, p_class(class), n));
goto cleanup;
}
if (n > 0) {
DPRINTF(("get_soa: CNAME or DNAME found"));
sect = ns_s_max, n = 0;
} else {
rcode = ns_msg_getflag(msg, ns_f_rcode);
ancount = ns_msg_count(msg, ns_s_an);
nscount = ns_msg_count(msg, ns_s_ns);
if (ancount > 0 && rcode == ns_r_noerror)
sect = ns_s_an, n = ancount;
else if (nscount > 0)
sect = ns_s_ns, n = nscount;
else
sect = ns_s_max, n = 0;
}
for (i = 0; i < n; i++) {
const char *t;
const u_char *rdata;
ns_rr rr;
if (ns_parserr(&msg, sect, i, &rr) < 0) {
DPRINTF(("get_soa: ns_parserr(%s, %d) failed",
p_section(sect, ns_o_query), i));
goto cleanup;
}
if (ns_rr_type(rr) == ns_t_cname ||
ns_rr_type(rr) == ns_t_dname)
break;
if (ns_rr_type(rr) != ns_t_soa ||
ns_rr_class(rr) != class)
continue;
t = ns_rr_name(rr);
switch (sect) {
case ns_s_an:
if (ns_samedomain(dname, t) == 0) {
DPRINTF(
("get_soa: ns_samedomain('%s', '%s') == 0",
dname, t)
);
errno = EPROTOTYPE;
goto cleanup;
}
break;
case ns_s_ns:
if (ns_samename(dname, t) == 1 ||
ns_samedomain(dname, t) == 0) {
DPRINTF(
("get_soa: ns_samename() || !ns_samedomain('%s', '%s')",
dname, t)
);
errno = EPROTOTYPE;
goto cleanup;
}
break;
default:
abort();
}
if (strlen(t) + 1 > zsize) {
DPRINTF(("get_soa: zname(%lu) too small (%lu)",
(unsigned long)zsize,
(unsigned long)strlen(t) + 1));
errno = EMSGSIZE;
goto cleanup;
}
strcpy(zname, t);
rdata = ns_rr_rdata(rr);
if (ns_name_uncompress(resp, ns_msg_end(msg), rdata,
mname, msize) < 0) {
DPRINTF(("get_soa: ns_name_uncompress failed")
);
goto cleanup;
}
if (save_ns(statp, &msg, ns_s_ns,
zname, class, opts, nsrrsp) < 0) {
DPRINTF(("get_soa: save_ns failed"));
goto cleanup;
}
free(resp);
return (0);
}
/* If we're out of labels, then not even "." has an SOA! */
if (*dname == '\0')
break;
/* Find label-terminating "."; top of loop will skip it. */
while (*dname != '.') {
if (*dname == '\\')
if (*++dname == '\0') {
errno = EMSGSIZE;
goto cleanup;
}
dname++;
}
}
DPRINTF(("get_soa: out of labels"));
errno = EDESTADDRREQ;
cleanup:
if (resp != NULL)
free(resp);
return (-1);
} | 28.924623 | 116 | 0.588082 |
0c33dba9d38b825a72d37e76963f10288a80c6c1 | 727 | c | C | src/cmd/snap.c | szhilkin/openvsx-2.0 | e6dbf87a4171ba0210ecd08c13d9e5fdeff9b70a | [
"BSD-2-Clause"
] | null | null | null | src/cmd/snap.c | szhilkin/openvsx-2.0 | e6dbf87a4171ba0210ecd08c13d9e5fdeff9b70a | [
"BSD-2-Clause"
] | null | null | null | src/cmd/snap.c | szhilkin/openvsx-2.0 | e6dbf87a4171ba0210ecd08c13d9e5fdeff9b70a | [
"BSD-2-Clause"
] | null | null | null | // Copyright © 2010 Coraid, Inc.
// All rights reserved.
// Snapshot a volume
#include <u.h>
#include <libc.h>
#include <bio.h>
#include <ctype.h>
#include "vsxcmds.h"
void
usage(void)
{
fprint(2,"usage: %s LV [...]\n", argv0);
exits("usage");
}
int
snap(char *lv)
{
char buf[128];
if (islv(lv) == 0) {
werrstr("%s is not an LV", lv);
return -1;
}
if (readfile(buf, 128, "/n/xlate/lv/%s/snap", lv) < 0) {
werrstr("LV %s: %r", lv);
return -1;
}
return 0;
}
void
main (int argc, char **argv)
{
ARGBEGIN {
default:
usage();
} ARGEND
if (serieserr(argc, argv, Noto) < 0)
errfatal("%r");
if (argc == 0)
usage();
while(argc-- > 0)
if (snap(*argv++) < 0)
errskip(argc, argv);
exits(nil);
}
| 14.254902 | 57 | 0.568088 |
0c357d05f639ec784981c9624f24a3ff587de2e6 | 272 | h | C | IToBoardComm.h | OOOOOldZhu/qt_test | b861d88c682d67a861d47d5aea8c61be8b06f6c3 | [
"MIT"
] | null | null | null | IToBoardComm.h | OOOOOldZhu/qt_test | b861d88c682d67a861d47d5aea8c61be8b06f6c3 | [
"MIT"
] | null | null | null | IToBoardComm.h | OOOOOldZhu/qt_test | b861d88c682d67a861d47d5aea8c61be8b06f6c3 | [
"MIT"
] | null | null | null | #ifndef TOBOARDCOMM_H
#define TOBOARDCOMM_H
#include <QByteArray>
#include <QObject>
class IToBoardComm: public QObject
{
public:
virtual void init() = 0;
virtual void send(QByteArray arr) = 0;
virtual void closeComm() = 0;
};
#endif // TOBOARDCOMM_H
| 12.363636 | 42 | 0.694853 |
0c35cad61a5fa90fa73afd4382e071d3c5376124 | 553 | h | C | YXJLinksButton_iOS/YXJLinksButton_iOS.h | stubbornnessness/YXJLinksButton | c514e876342cfd3c2c7a5087c5c6408fc1fcfe69 | [
"Apache-2.0"
] | 16 | 2016-08-19T09:55:49.000Z | 2021-08-24T01:55:36.000Z | EasySwift_iOS/3party/YXJLinksButton_iOS.framework/Headers/YXJLinksButton_iOS.h | mohsinalimat/EasySwift | 898647e4540bb89913530c6ae285db2cd8fa3397 | [
"Apache-2.0"
] | 2 | 2016-10-22T17:12:12.000Z | 2018-09-25T08:11:23.000Z | EasySwift_iOS/3party/YXJLinksButton_iOS.framework/Headers/YXJLinksButton_iOS.h | mohsinalimat/EasySwift | 898647e4540bb89913530c6ae285db2cd8fa3397 | [
"Apache-2.0"
] | 3 | 2016-09-25T07:45:14.000Z | 2018-12-12T08:09:56.000Z | //
// YXJLinksButton_iOS.h
// YXJLinksButton_iOS
//
// Created by yuanxiaojun on 2016/11/3.
// Copyright © 2016年 袁晓钧. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for YXJLinksButton_iOS.
FOUNDATION_EXPORT double YXJLinksButton_iOSVersionNumber;
//! Project version string for YXJLinksButton_iOS.
FOUNDATION_EXPORT const unsigned char YXJLinksButton_iOSVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <YXJLinksButton_iOS/PublicHeader.h>
| 27.65 | 143 | 0.786618 |
0c35f06651b737eabe8732d09cb45447297d420d | 5,676 | h | C | PrivateFrameworks/C2/C2RequestOptions.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/C2/C2RequestOptions.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/C2/C2RequestOptions.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 1 | 2018-09-28T13:54:23.000Z | 2018-09-28T13:54:23.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSObject.h"
#import "NSCopying.h"
#import "NSSecureCoding.h"
@class C2MetricOptions, NSDictionary, NSString, NSURL;
@interface C2RequestOptions : NSObject <NSCopying, NSSecureCoding>
{
BOOL __allowsExpensiveAccess;
BOOL __allowsPowerNapScheduling;
BOOL _useAdaptiveTimeouts;
BOOL _tlsPinning;
BOOL _allowRouting;
BOOL _allowExpiredDNSBehavior;
BOOL __allowsRetryForBackgroundDataTasks;
BOOL _redactRemoteEndpointFromNetworkMetrics;
BOOL _outOfProcessDiscretionary;
BOOL _metricRequest;
long long _qualityOfService;
NSString *_outOfProcessPoolName;
double __timeoutIntervalForRequest;
double __timeoutIntervalForResource;
NSString *__sourceApplicationBundleIdentifier;
NSString *__sourceApplicationSecondaryIdentifier;
NSString *__appleIDContextSessionIdentifier;
unsigned long long _discretionaryNetworkBehavior;
unsigned long long _duetPreClearedMode;
NSString *_identifier;
NSDictionary *_resolvedEndpointsWithHostname;
C2MetricOptions *_metricOptions;
NSURL *_c2MetricsEndpoint;
unsigned long long _c2MetricsReportFrequency;
unsigned long long _c2MetricsReportFrequencyBase;
NSString *_originalHost;
NSURL *_invokedURL;
CDUnknownBlockType _testBehavior_sessionGroupCreated;
}
+ (BOOL)supportsSecureCoding;
+ (BOOL)triesteMetricsEnabled;
+ (id)stringForDuetPreClearedMode:(unsigned long long)arg1;
+ (id)stringForDiscretionaryNetworkBehavior:(unsigned long long)arg1;
+ (id)stringForQualityOfService:(long long)arg1;
@property(copy, nonatomic) CDUnknownBlockType testBehavior_sessionGroupCreated; // @synthesize testBehavior_sessionGroupCreated=_testBehavior_sessionGroupCreated;
@property(copy, nonatomic) NSURL *invokedURL; // @synthesize invokedURL=_invokedURL;
@property(nonatomic) BOOL metricRequest; // @synthesize metricRequest=_metricRequest;
@property(copy, nonatomic) NSString *originalHost; // @synthesize originalHost=_originalHost;
@property(nonatomic) unsigned long long c2MetricsReportFrequencyBase; // @synthesize c2MetricsReportFrequencyBase=_c2MetricsReportFrequencyBase;
@property(nonatomic) unsigned long long c2MetricsReportFrequency; // @synthesize c2MetricsReportFrequency=_c2MetricsReportFrequency;
@property(copy, nonatomic) NSURL *c2MetricsEndpoint; // @synthesize c2MetricsEndpoint=_c2MetricsEndpoint;
@property(nonatomic) BOOL outOfProcessDiscretionary; // @synthesize outOfProcessDiscretionary=_outOfProcessDiscretionary;
@property(nonatomic) BOOL redactRemoteEndpointFromNetworkMetrics; // @synthesize redactRemoteEndpointFromNetworkMetrics=_redactRemoteEndpointFromNetworkMetrics;
@property(copy, nonatomic) C2MetricOptions *metricOptions; // @synthesize metricOptions=_metricOptions;
@property(copy, nonatomic) NSDictionary *resolvedEndpointsWithHostname; // @synthesize resolvedEndpointsWithHostname=_resolvedEndpointsWithHostname;
@property(copy, nonatomic) NSString *identifier; // @synthesize identifier=_identifier;
@property(nonatomic) BOOL _allowsRetryForBackgroundDataTasks; // @synthesize _allowsRetryForBackgroundDataTasks=__allowsRetryForBackgroundDataTasks;
@property(nonatomic) unsigned long long duetPreClearedMode; // @synthesize duetPreClearedMode=_duetPreClearedMode;
@property(nonatomic) unsigned long long discretionaryNetworkBehavior; // @synthesize discretionaryNetworkBehavior=_discretionaryNetworkBehavior;
@property(nonatomic) BOOL allowExpiredDNSBehavior; // @synthesize allowExpiredDNSBehavior=_allowExpiredDNSBehavior;
@property(nonatomic) BOOL allowRouting; // @synthesize allowRouting=_allowRouting;
@property(nonatomic) BOOL tlsPinning; // @synthesize tlsPinning=_tlsPinning;
@property(copy, nonatomic) NSString *_appleIDContextSessionIdentifier; // @synthesize _appleIDContextSessionIdentifier=__appleIDContextSessionIdentifier;
@property(copy, nonatomic) NSString *_sourceApplicationSecondaryIdentifier; // @synthesize _sourceApplicationSecondaryIdentifier=__sourceApplicationSecondaryIdentifier;
@property(copy, nonatomic) NSString *_sourceApplicationBundleIdentifier; // @synthesize _sourceApplicationBundleIdentifier=__sourceApplicationBundleIdentifier;
@property(nonatomic) BOOL useAdaptiveTimeouts; // @synthesize useAdaptiveTimeouts=_useAdaptiveTimeouts;
@property(nonatomic) double _timeoutIntervalForResource; // @synthesize _timeoutIntervalForResource=__timeoutIntervalForResource;
@property(nonatomic) double _timeoutIntervalForRequest; // @synthesize _timeoutIntervalForRequest=__timeoutIntervalForRequest;
@property(nonatomic) BOOL _allowsPowerNapScheduling; // @synthesize _allowsPowerNapScheduling=__allowsPowerNapScheduling;
@property(nonatomic) BOOL _allowsExpensiveAccess; // @synthesize _allowsExpensiveAccess=__allowsExpensiveAccess;
@property(copy, nonatomic) NSString *outOfProcessPoolName; // @synthesize outOfProcessPoolName=_outOfProcessPoolName;
@property(nonatomic) long long qualityOfService; // @synthesize qualityOfService=_qualityOfService;
- (void).cxx_destruct;
- (id)initWithCoder:(id)arg1;
- (void)encodeWithCoder:(id)arg1;
- (unsigned long long)hash;
- (BOOL)isEqual:(id)arg1;
@property(readonly, nonatomic) double emptySessionExpiryInSeconds;
- (id)decorateTask:(id)arg1;
- (id)copyAndDecorateRequest:(id)arg1;
- (id)sessionConfigurationWithName:(id)arg1;
- (void)setOutOfProcess:(BOOL)arg1;
@property(readonly, nonatomic) BOOL outOfProcess;
- (id)defaultSessionConfigurationWithName:(id)arg1;
- (id)sessionConfigurationNameWithRouteHost:(id)arg1;
- (id)copyWithZone:(struct _NSZone *)arg1;
- (id)init;
@end
| 58.515464 | 168 | 0.831395 |
0c36478f874c889eab8fc0277f4fc5f8374bd4e8 | 4,432 | h | C | player/include/umod/umod.h | AntonioND/umod-player | 9200027a3b6cb70f4efef38012dbd916fa3606fa | [
"MIT"
] | 7 | 2021-02-16T00:09:03.000Z | 2021-07-15T06:46:03.000Z | player/include/umod/umod.h | AntonioND/umod-player | 9200027a3b6cb70f4efef38012dbd916fa3606fa | [
"MIT"
] | null | null | null | player/include/umod/umod.h | AntonioND/umod-player | 9200027a3b6cb70f4efef38012dbd916fa3606fa | [
"MIT"
] | 1 | 2022-02-02T18:49:13.000Z | 2022-02-02T18:49:13.000Z | // SPDX-License-Identifier: MIT
//
// Copyright (c) 2021 Antonio Niño Díaz
#ifndef UMOD_UMOD_H__
#define UMOD_UMOD_H__
#include <stddef.h>
#include <stdint.h>
// Global functions
// ================
// Initialize player and set up the desired sample rate.
void UMOD_Init(uint32_t sample_rate);
// Load a pack file to be used from this point. When switching between pack
// files, make sure that there are no songs or SFXs being played. It returns 0
// on success.
int UMOD_LoadPack(const void *pack);
// Fills the specified buffers with audio data to be sent to the output device.
void UMOD_Mix(int8_t *left_buffer, int8_t *right_buffer, size_t buffer_size);
// Song API
// ========
#define UMOD_SONG_CHANNELS (8)
// Set master volume for all the song channels. Values: 0 - 256.
void UMOD_Song_SetMasterVolume(int volume);
// Plays the specified song (MOD_xxx defines, etc). It stops the currently
// played song if any. It returns 0 on success.
int UMOD_Song_Play(uint32_t index);
// It returns 1 if there is currently a song being played, 0 otheriwse.
int UMOD_Song_IsPlaying(void);
// It returns 1 if the current song is paused, 0 otheriwse.
int UMOD_Song_IsPaused(void);
// It pauses a song if it is being played. It returns 0 on success. This
// function fails if there is no song being played, or if it is already paused.
int UMOD_Song_Pause(void);
// It resumes a song if it is paused. It returns 0 on success. This function
// fails if there is no paused song.
int UMOD_Song_Resume(void);
// Stops the song currently being played.
void UMOD_Song_Stop(void);
// SFX API
// =======
#define UMOD_SFX_CHANNELS (4)
#define UMOD_HANDLE_INVALID 0
typedef uint32_t umod_handle;
typedef enum {
// WAV files may contain loop information or not. If a WAV file contains
// loop information, this value will let the mixer loop the sample as
// expected. If it doesn't have information, it will be played once.
UMOD_LOOP_DEFAULT = 0,
// In WAV files with no loop information, this tells the mixer to loop the
// whole waveform. In WAV files with loop information, it does nothing.
UMOD_LOOP_ENABLE = 1,
// This value disables looping even in WAV effects that have loop
// information. Note that it isn't possible to enable looping afterwards.
UMOD_LOOP_DISABLE = 2
} umod_loop_type;
// Set master volume for all the SFX channels. Values: 0 - 256 (it is clamped if
// it's outside of this range).
void UMOD_SFX_SetMasterVolume(int volume);
// Play SFX that corresponds to the specified SFX_xxx define. It returns a
// handle that can be used to modify this effect while it is being played. In
// the case of one-shot sounds, the handle stops being valid after the sound
// ends.
//
// Note that using an invalid handle won't crash any function, but it won't
// affect any other effect being played in the same channel.
//
// This function returns UMOD_HANDLE_INVALID if the SFX doesn't exist, or if
// there are no available channels.
umod_handle UMOD_SFX_Play(uint32_t index, umod_loop_type loop_type);
// Set volume for the specified effect. Values: 0 - 255 (it is clamped if it's
// outside this range). Returns 0 on success. It can fail if the handle is
// invalid or if the SFX has already finished.
int UMOD_SFX_SetVolume(umod_handle handle, int volume);
// Set panning for the specified effect. Values: 0 (left) - 255 (right). Returns
// 0 on success. It can fail if the handle is invalid or if the SFX has already
// finished.
int UMOD_SFX_SetPanning(umod_handle handle, int panning);
// Set new playback frequency of the SFX. Multiplier in fixed point format
// 16.16. It returns 0 on success.
int UMOD_SFX_SetFrequencyMultiplier(umod_handle handle, uint32_t multiplier);
// Release the channel playing this SFX. When a channel is released, it means it
// is available for another SFX. If a new SFX is requested and no other channels
// are free, the SFXs in the released channels will be used. It returns 0 on
// success.
int UMOD_SFX_Release(umod_handle handle);
// Returns 1 if the specified SFX is being played, 0 otherwise.
int UMOD_SFX_IsPlaying(umod_handle handle);
// Stop playing the specified sound. Returns 0 on success. It can fail if the
// handle is invalid or if the SFX has already finished.
int UMOD_SFX_Stop(umod_handle handle);
// Stop playing all active sound effects.
void UMOD_SFX_StopAll(void);
#endif // UMOD_UMOD_H__
| 35.456 | 80 | 0.744585 |
0c364bdc99baaedd9c55540c801fbceb2526ac66 | 12,084 | h | C | src/xrGame/object_actions.h | clayne/xray-16 | 32ebf81a252c7179e2824b2874f911a91e822ad1 | [
"OML",
"Linux-OpenIB"
] | 2 | 2015-02-23T10:43:02.000Z | 2015-06-11T14:45:08.000Z | src/xrGame/object_actions.h | clayne/xray-16 | 32ebf81a252c7179e2824b2874f911a91e822ad1 | [
"OML",
"Linux-OpenIB"
] | 17 | 2022-01-25T08:58:23.000Z | 2022-03-28T17:18:28.000Z | src/xrGame/object_actions.h | clayne/xray-16 | 32ebf81a252c7179e2824b2874f911a91e822ad1 | [
"OML",
"Linux-OpenIB"
] | 1 | 2015-06-05T20:04:00.000Z | 2015-06-05T20:04:00.000Z | ////////////////////////////////////////////////////////////////////////////
// Module : object_actions.h
// Created : 12.03.2004
// Modified : 26.03.2004
// Author : Dmitriy Iassenev
// Description : Object actions
////////////////////////////////////////////////////////////////////////////
#pragma once
#include "action_base.h"
class CAI_Stalker;
class CInventoryItem;
class CFoodItem;
class CWeaponMagazined;
class CWeapon;
//////////////////////////////////////////////////////////////////////////
// CObjectActionBase
//////////////////////////////////////////////////////////////////////////
template <typename _item_type>
class CObjectActionBase : public CActionBase<CAI_Stalker>
{
protected:
typedef CActionBase<CAI_Stalker> inherited;
typedef GraphEngineSpace::_solver_condition_type _condition_type;
typedef GraphEngineSpace::_solver_value_type _value_type;
protected:
_item_type* m_item;
public:
IC CObjectActionBase(_item_type* item, CAI_Stalker* owner, CPropertyStorage* storage, LPCSTR action_name = "");
virtual void initialize();
IC void set_property(_condition_type condition_id, _value_type value);
IC CAI_Stalker& object() const;
void prevent_weapon_state_switch_ugly();
void stop_hiding_operation_if_any() const;
};
class CGameObject;
typedef CObjectActionBase<CGameObject> CSObjectActionBase;
//////////////////////////////////////////////////////////////////////////
// CObjectActionMember
//////////////////////////////////////////////////////////////////////////
template <typename _item_type>
class CObjectActionMember : public CObjectActionBase<_item_type>
{
protected:
using inherited = CObjectActionBase<_item_type>;
public:
using _condition_type = typename inherited::_condition_type;
using _value_type = typename inherited::_value_type;
protected:
_condition_type m_condition_id;
_value_type m_value;
public:
IC CObjectActionMember(_item_type* item, CAI_Stalker* owner, CPropertyStorage* storage,
_condition_type condition_id, _value_type value, LPCSTR action_name = "");
virtual void execute();
};
//////////////////////////////////////////////////////////////////////////
// CObjectActionCommand
//////////////////////////////////////////////////////////////////////////
class CObjectActionCommand : public CObjectActionBase<CInventoryItem>
{
protected:
typedef CObjectActionBase<CInventoryItem> inherited;
protected:
u32 m_command;
public:
CObjectActionCommand(
CInventoryItem* item, CAI_Stalker* owner, CPropertyStorage* storage, u32 command, LPCSTR action_name = "");
virtual void initialize();
};
//////////////////////////////////////////////////////////////////////////
// CObjectActionShow
//////////////////////////////////////////////////////////////////////////
class CObjectActionShow : public CObjectActionBase<CInventoryItem>
{
protected:
typedef CObjectActionBase<CInventoryItem> inherited;
private:
CWeapon* m_weapon;
public:
CObjectActionShow(CInventoryItem* item, CAI_Stalker* owner, CPropertyStorage* storage, LPCSTR action_name = "");
virtual void initialize();
virtual void execute();
};
//////////////////////////////////////////////////////////////////////////
// CObjectActionHide
//////////////////////////////////////////////////////////////////////////
class CObjectActionHide : public CObjectActionBase<CInventoryItem>
{
protected:
typedef CObjectActionBase<CInventoryItem> inherited;
public:
CObjectActionHide(CInventoryItem* item, CAI_Stalker* owner, CPropertyStorage* storage, LPCSTR action_name = "");
virtual void execute();
virtual void finalize();
};
//////////////////////////////////////////////////////////////////////////
// CObjectActionReload
//////////////////////////////////////////////////////////////////////////
class CObjectActionReload : public CObjectActionBase<CInventoryItem>
{
protected:
typedef CObjectActionBase<CInventoryItem> inherited;
protected:
_condition_type m_type;
public:
CObjectActionReload(CInventoryItem* item, CAI_Stalker* owner, CPropertyStorage* storage, _condition_type type,
LPCSTR action_name = "");
virtual void initialize();
virtual void execute();
};
//////////////////////////////////////////////////////////////////////////
// CObjectActionFire
//////////////////////////////////////////////////////////////////////////
class CObjectActionFire : public CObjectActionBase<CInventoryItem>
{
protected:
typedef CObjectActionBase<CInventoryItem> inherited;
protected:
_condition_type m_type;
public:
CObjectActionFire(CInventoryItem* item, CAI_Stalker* owner, CPropertyStorage* storage, _condition_type type,
LPCSTR action_name = "");
virtual void initialize();
virtual void execute();
virtual void finalize();
};
//////////////////////////////////////////////////////////////////////////
// CObjectActionFireNoReload
//////////////////////////////////////////////////////////////////////////
class CObjectActionFireNoReload : public CObjectActionBase<CInventoryItem>
{
protected:
typedef CObjectActionBase<CInventoryItem> inherited;
protected:
_condition_type m_type;
bool m_fired;
public:
CObjectActionFireNoReload(CInventoryItem* item, CAI_Stalker* owner, CPropertyStorage* storage, _condition_type type,
LPCSTR action_name = "");
virtual void initialize();
virtual void execute();
virtual void finalize();
};
//////////////////////////////////////////////////////////////////////////
// CObjectActionStrapping
//////////////////////////////////////////////////////////////////////////
class CObjectActionStrapping : public CObjectActionBase<CInventoryItem>
{
protected:
typedef CObjectActionBase<CInventoryItem> inherited;
private:
bool m_callback_removed;
private:
void on_animation_end();
public:
CObjectActionStrapping(
CInventoryItem* item, CAI_Stalker* owner, CPropertyStorage* storage, LPCSTR action_name = "");
virtual ~CObjectActionStrapping();
virtual void initialize();
virtual void execute();
virtual void finalize();
};
//////////////////////////////////////////////////////////////////////////
// CObjectActionStrappingToIdle
//////////////////////////////////////////////////////////////////////////
class CObjectActionStrappingToIdle : public CObjectActionBase<CInventoryItem>
{
protected:
typedef CObjectActionBase<CInventoryItem> inherited;
private:
bool m_callback_removed;
private:
void on_animation_end();
public:
CObjectActionStrappingToIdle(
CInventoryItem* item, CAI_Stalker* owner, CPropertyStorage* storage, LPCSTR action_name = "");
virtual ~CObjectActionStrappingToIdle();
virtual void initialize();
virtual void execute();
virtual void finalize();
};
//////////////////////////////////////////////////////////////////////////
// CObjectActionUnstrapping
//////////////////////////////////////////////////////////////////////////
class CObjectActionUnstrapping : public CObjectActionBase<CInventoryItem>
{
protected:
typedef CObjectActionBase<CInventoryItem> inherited;
private:
bool m_callback_removed;
private:
void on_animation_end();
public:
CObjectActionUnstrapping(
CInventoryItem* item, CAI_Stalker* owner, CPropertyStorage* storage, LPCSTR action_name = "");
virtual ~CObjectActionUnstrapping();
virtual void initialize();
virtual void execute();
virtual void finalize();
};
//////////////////////////////////////////////////////////////////////////
// CObjectActionUnstrappingToIdle
//////////////////////////////////////////////////////////////////////////
class CObjectActionUnstrappingToIdle : public CObjectActionBase<CInventoryItem>
{
protected:
typedef CObjectActionBase<CInventoryItem> inherited;
private:
bool m_callback_removed;
private:
void on_animation_end();
public:
CObjectActionUnstrappingToIdle(
CInventoryItem* item, CAI_Stalker* owner, CPropertyStorage* storage, LPCSTR action_name = "");
virtual ~CObjectActionUnstrappingToIdle();
virtual void initialize();
virtual void execute();
virtual void finalize();
};
//////////////////////////////////////////////////////////////////////////
// CObjectActionQueueWait
//////////////////////////////////////////////////////////////////////////
class CObjectActionQueueWait : public CObjectActionBase<CInventoryItem>
{
protected:
typedef CObjectActionBase<CInventoryItem> inherited;
protected:
_condition_type m_type;
CWeaponMagazined* m_magazined;
public:
CObjectActionQueueWait(CInventoryItem* item, CAI_Stalker* owner, CPropertyStorage* storage, _condition_type type,
LPCSTR action_name = "");
virtual void initialize();
virtual void execute();
virtual void finalize();
};
//////////////////////////////////////////////////////////////////////////
// CObjectActionSwitch
//////////////////////////////////////////////////////////////////////////
class CObjectActionSwitch : public CObjectActionBase<CInventoryItem>
{
protected:
typedef CObjectActionBase<CInventoryItem> inherited;
protected:
_condition_type m_type;
public:
CObjectActionSwitch(CInventoryItem* item, CAI_Stalker* owner, CPropertyStorage* storage, _condition_type type,
LPCSTR action_name = "");
virtual void initialize();
virtual void execute();
virtual void finalize();
};
//////////////////////////////////////////////////////////////////////////
// CObjectActionDrop
//////////////////////////////////////////////////////////////////////////
class CObjectActionDrop : public CObjectActionBase<CInventoryItem>
{
protected:
typedef CObjectActionBase<CInventoryItem> inherited;
public:
CObjectActionDrop(CInventoryItem* item, CAI_Stalker* owner, CPropertyStorage* storage, LPCSTR action_name = "");
virtual void initialize();
};
//////////////////////////////////////////////////////////////////////////
// CObjectActionAim
//////////////////////////////////////////////////////////////////////////
class CObjectActionAim : public CObjectActionMember<CInventoryItem>
{
protected:
typedef CObjectActionMember<CInventoryItem> inherited;
private:
CWeaponMagazined* m_weapon;
public:
CObjectActionAim(CInventoryItem* item, CAI_Stalker* owner, CPropertyStorage* storage, _condition_type condition_id,
_value_type value, LPCSTR action_name = "");
virtual void initialize();
virtual void execute();
};
//////////////////////////////////////////////////////////////////////////
// CObjectActionIdle
//////////////////////////////////////////////////////////////////////////
class CObjectActionIdle : public CObjectActionBase<CInventoryItem>
{
protected:
typedef CObjectActionBase<CInventoryItem> inherited;
public:
CObjectActionIdle(CInventoryItem* item, CAI_Stalker* owner, CPropertyStorage* storage, LPCSTR action_name = "");
virtual void initialize();
};
//////////////////////////////////////////////////////////////////////////
// CObjectActionIdleMissile
//////////////////////////////////////////////////////////////////////////
class CObjectActionIdleMissile : public CObjectActionBase<CInventoryItem>
{
protected:
typedef CObjectActionBase<CInventoryItem> inherited;
public:
CObjectActionIdleMissile(
CInventoryItem* item, CAI_Stalker* owner, CPropertyStorage* storage, LPCSTR action_name = "");
virtual void initialize();
};
//////////////////////////////////////////////////////////////////////////
// CObjectActionThrowMissile
//////////////////////////////////////////////////////////////////////////
class CObjectActionThrowMissile : public CObjectActionBase<CInventoryItem>
{
protected:
typedef CObjectActionBase<CInventoryItem> inherited;
public:
CObjectActionThrowMissile(
CInventoryItem* item, CAI_Stalker* owner, CPropertyStorage* storage, LPCSTR action_name = "");
virtual void initialize();
virtual void execute();
};
#include "object_actions_inline.h"
| 30.515152 | 120 | 0.57423 |
0c367837d5c3c683c1a5971b6b6329fbc3956188 | 6,318 | h | C | xen/xen-4.2.2/tools/qemu-xen-traditional/target-i386/helper.h | zhiming-shen/Xen-Blanket-NG | 47e59d9bb92e8fdc60942df526790ddb983a5496 | [
"Apache-2.0"
] | 3 | 2019-08-31T19:58:24.000Z | 2020-10-02T06:50:22.000Z | xen/xen-4.2.2/tools/qemu-xen-traditional/target-i386/helper.h | zhiming-shen/Xen-Blanket-NG | 47e59d9bb92e8fdc60942df526790ddb983a5496 | [
"Apache-2.0"
] | 1 | 2020-10-16T19:13:49.000Z | 2020-10-16T19:13:49.000Z | xen-4.6.0/tools/qemu-xen-traditional/target-i386/helper.h | StanPlatinum/ROP-detection-inside-VMs | 7b39298dd0791711cbd78fd0730b819b755cc995 | [
"MIT"
] | 1 | 2019-05-27T09:47:18.000Z | 2019-05-27T09:47:18.000Z | #include "def-helper.h"
DEF_HELPER_FLAGS_1(cc_compute_all, TCG_CALL_PURE, i32, int)
DEF_HELPER_FLAGS_1(cc_compute_c, TCG_CALL_PURE, i32, int)
DEF_HELPER_0(lock, void)
DEF_HELPER_0(unlock, void)
DEF_HELPER_2(write_eflags, void, tl, i32)
DEF_HELPER_0(read_eflags, tl)
DEF_HELPER_1(divb_AL, void, tl)
DEF_HELPER_1(idivb_AL, void, tl)
DEF_HELPER_1(divw_AX, void, tl)
DEF_HELPER_1(idivw_AX, void, tl)
DEF_HELPER_1(divl_EAX, void, tl)
DEF_HELPER_1(idivl_EAX, void, tl)
#ifdef TARGET_X86_64
DEF_HELPER_1(mulq_EAX_T0, void, tl)
DEF_HELPER_1(imulq_EAX_T0, void, tl)
DEF_HELPER_2(imulq_T0_T1, tl, tl, tl)
DEF_HELPER_1(divq_EAX, void, tl)
DEF_HELPER_1(idivq_EAX, void, tl)
#endif
DEF_HELPER_1(aam, void, int)
DEF_HELPER_1(aad, void, int)
DEF_HELPER_0(aaa, void)
DEF_HELPER_0(aas, void)
DEF_HELPER_0(daa, void)
DEF_HELPER_0(das, void)
DEF_HELPER_1(lsl, tl, tl)
DEF_HELPER_1(lar, tl, tl)
DEF_HELPER_1(verr, void, tl)
DEF_HELPER_1(verw, void, tl)
DEF_HELPER_1(lldt, void, int)
DEF_HELPER_1(ltr, void, int)
DEF_HELPER_2(load_seg, void, int, int)
DEF_HELPER_3(ljmp_protected, void, int, tl, int)
DEF_HELPER_4(lcall_real, void, int, tl, int, int)
DEF_HELPER_4(lcall_protected, void, int, tl, int, int)
DEF_HELPER_1(iret_real, void, int)
DEF_HELPER_2(iret_protected, void, int, int)
DEF_HELPER_2(lret_protected, void, int, int)
DEF_HELPER_1(read_crN, tl, int)
DEF_HELPER_2(write_crN, void, int, tl)
DEF_HELPER_1(lmsw, void, tl)
DEF_HELPER_0(clts, void)
DEF_HELPER_2(movl_drN_T0, void, int, tl)
DEF_HELPER_1(invlpg, void, tl)
DEF_HELPER_3(enter_level, void, int, int, tl)
#ifdef TARGET_X86_64
DEF_HELPER_3(enter64_level, void, int, int, tl)
#endif
DEF_HELPER_0(sysenter, void)
DEF_HELPER_1(sysexit, void, int)
#ifdef TARGET_X86_64
DEF_HELPER_1(syscall, void, int)
DEF_HELPER_1(sysret, void, int)
#endif
DEF_HELPER_1(hlt, void, int)
DEF_HELPER_1(monitor, void, tl)
DEF_HELPER_1(mwait, void, int)
DEF_HELPER_0(debug, void)
DEF_HELPER_2(raise_interrupt, void, int, int)
DEF_HELPER_1(raise_exception, void, int)
DEF_HELPER_0(cli, void)
DEF_HELPER_0(sti, void)
DEF_HELPER_0(set_inhibit_irq, void)
DEF_HELPER_0(reset_inhibit_irq, void)
DEF_HELPER_2(boundw, void, tl, int)
DEF_HELPER_2(boundl, void, tl, int)
DEF_HELPER_0(rsm, void)
DEF_HELPER_1(into, void, int)
DEF_HELPER_1(cmpxchg8b, void, tl)
#ifdef TARGET_X86_64
DEF_HELPER_1(cmpxchg16b, void, tl)
#endif
DEF_HELPER_0(single_step, void)
DEF_HELPER_0(cpuid, void)
DEF_HELPER_0(rdtsc, void)
DEF_HELPER_0(rdpmc, void)
DEF_HELPER_0(rdmsr, void)
DEF_HELPER_0(wrmsr, void)
DEF_HELPER_1(check_iob, void, i32)
DEF_HELPER_1(check_iow, void, i32)
DEF_HELPER_1(check_iol, void, i32)
DEF_HELPER_2(outb, void, i32, i32)
DEF_HELPER_1(inb, tl, i32)
DEF_HELPER_2(outw, void, i32, i32)
DEF_HELPER_1(inw, tl, i32)
DEF_HELPER_2(outl, void, i32, i32)
DEF_HELPER_1(inl, tl, i32)
DEF_HELPER_2(svm_check_intercept_param, void, i32, i64)
DEF_HELPER_2(vmexit, void, i32, i64)
DEF_HELPER_3(svm_check_io, void, i32, i32, i32)
DEF_HELPER_2(vmrun, void, int, int)
DEF_HELPER_0(vmmcall, void)
DEF_HELPER_1(vmload, void, int)
DEF_HELPER_1(vmsave, void, int)
DEF_HELPER_0(stgi, void)
DEF_HELPER_0(clgi, void)
DEF_HELPER_0(skinit, void)
DEF_HELPER_1(invlpga, void, int)
/* x86 FPU */
DEF_HELPER_1(flds_FT0, void, i32)
DEF_HELPER_1(fldl_FT0, void, i64)
DEF_HELPER_1(fildl_FT0, void, s32)
DEF_HELPER_1(flds_ST0, void, i32)
DEF_HELPER_1(fldl_ST0, void, i64)
DEF_HELPER_1(fildl_ST0, void, s32)
DEF_HELPER_1(fildll_ST0, void, s64)
DEF_HELPER_0(fsts_ST0, i32)
DEF_HELPER_0(fstl_ST0, i64)
DEF_HELPER_0(fist_ST0, s32)
DEF_HELPER_0(fistl_ST0, s32)
DEF_HELPER_0(fistll_ST0, s64)
DEF_HELPER_0(fistt_ST0, s32)
DEF_HELPER_0(fisttl_ST0, s32)
DEF_HELPER_0(fisttll_ST0, s64)
DEF_HELPER_1(fldt_ST0, void, tl)
DEF_HELPER_1(fstt_ST0, void, tl)
DEF_HELPER_0(fpush, void)
DEF_HELPER_0(fpop, void)
DEF_HELPER_0(fdecstp, void)
DEF_HELPER_0(fincstp, void)
DEF_HELPER_1(ffree_STN, void, int)
DEF_HELPER_0(fmov_ST0_FT0, void)
DEF_HELPER_1(fmov_FT0_STN, void, int)
DEF_HELPER_1(fmov_ST0_STN, void, int)
DEF_HELPER_1(fmov_STN_ST0, void, int)
DEF_HELPER_1(fxchg_ST0_STN, void, int)
DEF_HELPER_0(fcom_ST0_FT0, void)
DEF_HELPER_0(fucom_ST0_FT0, void)
DEF_HELPER_0(fcomi_ST0_FT0, void)
DEF_HELPER_0(fucomi_ST0_FT0, void)
DEF_HELPER_0(fadd_ST0_FT0, void)
DEF_HELPER_0(fmul_ST0_FT0, void)
DEF_HELPER_0(fsub_ST0_FT0, void)
DEF_HELPER_0(fsubr_ST0_FT0, void)
DEF_HELPER_0(fdiv_ST0_FT0, void)
DEF_HELPER_0(fdivr_ST0_FT0, void)
DEF_HELPER_1(fadd_STN_ST0, void, int)
DEF_HELPER_1(fmul_STN_ST0, void, int)
DEF_HELPER_1(fsub_STN_ST0, void, int)
DEF_HELPER_1(fsubr_STN_ST0, void, int)
DEF_HELPER_1(fdiv_STN_ST0, void, int)
DEF_HELPER_1(fdivr_STN_ST0, void, int)
DEF_HELPER_0(fchs_ST0, void)
DEF_HELPER_0(fabs_ST0, void)
DEF_HELPER_0(fxam_ST0, void)
DEF_HELPER_0(fld1_ST0, void)
DEF_HELPER_0(fldl2t_ST0, void)
DEF_HELPER_0(fldl2e_ST0, void)
DEF_HELPER_0(fldpi_ST0, void)
DEF_HELPER_0(fldlg2_ST0, void)
DEF_HELPER_0(fldln2_ST0, void)
DEF_HELPER_0(fldz_ST0, void)
DEF_HELPER_0(fldz_FT0, void)
DEF_HELPER_0(fnstsw, i32)
DEF_HELPER_0(fnstcw, i32)
DEF_HELPER_1(fldcw, void, i32)
DEF_HELPER_0(fclex, void)
DEF_HELPER_0(fwait, void)
DEF_HELPER_0(fninit, void)
DEF_HELPER_1(fbld_ST0, void, tl)
DEF_HELPER_1(fbst_ST0, void, tl)
DEF_HELPER_0(f2xm1, void)
DEF_HELPER_0(fyl2x, void)
DEF_HELPER_0(fptan, void)
DEF_HELPER_0(fpatan, void)
DEF_HELPER_0(fxtract, void)
DEF_HELPER_0(fprem1, void)
DEF_HELPER_0(fprem, void)
DEF_HELPER_0(fyl2xp1, void)
DEF_HELPER_0(fsqrt, void)
DEF_HELPER_0(fsincos, void)
DEF_HELPER_0(frndint, void)
DEF_HELPER_0(fscale, void)
DEF_HELPER_0(fsin, void)
DEF_HELPER_0(fcos, void)
DEF_HELPER_2(fstenv, void, tl, int)
DEF_HELPER_2(fldenv, void, tl, int)
DEF_HELPER_2(fsave, void, tl, int)
DEF_HELPER_2(frstor, void, tl, int)
DEF_HELPER_2(fxsave, void, tl, int)
DEF_HELPER_2(fxrstor, void, tl, int)
DEF_HELPER_1(bsf, tl, tl)
DEF_HELPER_1(bsr, tl, tl)
/* MMX/SSE */
DEF_HELPER_0(enter_mmx, void)
DEF_HELPER_0(emms, void)
DEF_HELPER_2(movq, void, ptr, ptr)
#define SHIFT 0
#include "ops_sse_header.h"
#define SHIFT 1
#include "ops_sse_header.h"
DEF_HELPER_2(rclb, tl, tl, tl)
DEF_HELPER_2(rclw, tl, tl, tl)
DEF_HELPER_2(rcll, tl, tl, tl)
DEF_HELPER_2(rcrb, tl, tl, tl)
DEF_HELPER_2(rcrw, tl, tl, tl)
DEF_HELPER_2(rcrl, tl, tl, tl)
#ifdef TARGET_X86_64
DEF_HELPER_2(rclq, tl, tl, tl)
DEF_HELPER_2(rcrq, tl, tl, tl)
#endif
#include "def-helper.h"
| 28.981651 | 59 | 0.79139 |
0c371f9a8d1e57a2129c92bc1b6882f4e7185f41 | 17,146 | c | C | Demos/Bonus/wincon/wincon.c | tcxs/php4delphi | 041fed9bb6898faed25076f6ff893bfee93e41cd | [
"PHP-3.0"
] | 19 | 2015-08-10T15:42:28.000Z | 2021-11-23T02:04:02.000Z | Demos/Bonus/wincon/wincon.c | tcxs/php4delphi | 041fed9bb6898faed25076f6ff893bfee93e41cd | [
"PHP-3.0"
] | 2 | 2018-06-22T12:45:58.000Z | 2020-11-30T09:05:57.000Z | Demos/Bonus/wincon/wincon.c | tcxs/php4delphi | 041fed9bb6898faed25076f6ff893bfee93e41cd | [
"PHP-3.0"
] | 13 | 2015-05-02T14:39:20.000Z | 2021-11-18T19:50:05.000Z | #ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_wincon.h"
#include <wincon.h>
#include "zend_alloc.h"
/* True global resources - no need for thread safety here */
static int le_wincon;
/* {{{ wincon_functions[]
*
* Every user visible function must have an entry in wincon_functions[].
*/
function_entry wincon_functions[] = {
PHP_FE(allocconsole, NULL)
PHP_FE(createconsolescreenbuffer, NULL)
PHP_FE(fillconsoleoutputattribute, NULL)
PHP_FE(getstdhandle, NULL)
PHP_FE(setconsoletitle, NULL)
PHP_FE(readconsole, NULL)
PHP_FE(flushconsoleinputbuffer, NULL)
PHP_FE(freeconsole, NULL)
PHP_FE(generateconsolectrlevent, NULL)
PHP_FE(getconsolecp, NULL)
PHP_FE(getconsolecursorsize, NULL)
PHP_FE(getconsolecursorvisible, NULL)
PHP_FE(getconsolemode, NULL)
PHP_FE(getconsoleoutputcp, NULL)
PHP_FE(getconsolescreenbufferinfo, NULL)
PHP_FE(getconsoletitle, NULL)
PHP_FE(getnumberofconsoleinputevents, NULL)
PHP_FE(setconsolecp, NULL)
PHP_FE(setconsoletextattribute, NULL)
PHP_FE(writeconsole, NULL)
PHP_FE(setconsoleoutputcp, NULL)
PHP_FE(setstdhandle, NULL)
PHP_FE(setconsolemode, NULL)
PHP_FE(setconsolecursorposition, NULL)
PHP_FE(setconsolecursorinfo, NULL)
PHP_FE(writeconsoleoutputcharacter, NULL)
{NULL, NULL, NULL}
};
/* }}} */
/* {{{ wincon_module_entry
*/
zend_module_entry wincon_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
"php_wincon",
wincon_functions,
PHP_MINIT(wincon),
PHP_MSHUTDOWN(wincon),
PHP_RINIT(wincon),
PHP_RSHUTDOWN(wincon),
PHP_MINFO(wincon),
#if ZEND_MODULE_API_NO >= 20010901
"1.1",
#endif
STANDARD_MODULE_PROPERTIES
};
/* }}} */
#ifdef COMPILE_DL_WINCON
ZEND_GET_MODULE(wincon)
#endif
/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(wincon)
{
REGISTER_LONG_CONSTANT("STD_INPUT_HANDLE", STD_INPUT_HANDLE, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STD_OUTPUT_HANDLE", STD_OUTPUT_HANDLE, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("STD_ERROR_HANDLE", STD_ERROR_HANDLE, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CTRL_C_EVENT", CTRL_C_EVENT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("CTRL_BREAK_EVENT", CTRL_BREAK_EVENT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ENABLE_LINE_INPUT", ENABLE_LINE_INPUT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ENABLE_ECHO_INPUT", ENABLE_ECHO_INPUT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ENABLE_PROCESSED_INPUT", ENABLE_PROCESSED_INPUT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ENABLE_WINDOW_INPUT", ENABLE_WINDOW_INPUT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ENABLE_MOUSE_INPUT", ENABLE_MOUSE_INPUT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ENABLE_PROCESSED_OUTPUT", ENABLE_PROCESSED_OUTPUT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ENABLE_WRAP_AT_EOL_OUTPUT", ENABLE_WRAP_AT_EOL_OUTPUT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("BACKGROUND_BLUE", BACKGROUND_BLUE, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FOREGROUND_BLUE", FOREGROUND_BLUE, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("BACKGROUND_GREEN", BACKGROUND_GREEN, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FOREGROUND_GREEN", FOREGROUND_GREEN, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("BACKGROUND_RED", BACKGROUND_RED, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FOREGROUND_RED", FOREGROUND_RED, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("BACKGROUND_INTENSITY", BACKGROUND_INTENSITY, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FOREGROUND_INTENSITY", FOREGROUND_INTENSITY, CONST_CS|CONST_PERSISTENT);
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
PHP_MSHUTDOWN_FUNCTION(wincon)
{
return SUCCESS;
}
/* }}} */
/* {{{ PHP_RINIT_FUNCTION
*/
PHP_RINIT_FUNCTION(wincon)
{
return SUCCESS;
}
/* }}} */
/* {{{ PHP_RSHUTDOWN_FUNCTION
*/
PHP_RSHUTDOWN_FUNCTION(wincon)
{
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(wincon)
{
php_info_print_table_start();
php_info_print_table_header(2, "Windows console support", "enabled");
php_info_print_table_end();
/* Remove comments if you have entries in php.ini
DISPLAY_INI_ENTRIES();
*/
}
/* }}} */
/* {{{ proto bool AllocConsole(void)
*/
PHP_FUNCTION(allocconsole)
{
RETURN_BOOL(AllocConsole());
}
/* {{{ proto long createconsolescreenbuffer(int desiredaccess; int sharemode; int flags)
*/
PHP_FUNCTION(createconsolescreenbuffer)
{
zval **desiredaccess;
zval **sharemode;
zval **flags;
long ret;
int ac = ZEND_NUM_ARGS();
if (ac != 2 || zend_get_parameters_ex(ac, &desiredaccess, &sharemode, &flags) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(desiredaccess);
convert_to_long_ex(sharemode);
convert_to_long_ex(flags);
ret = (long)CreateConsoleScreenBuffer(Z_LVAL_PP(desiredaccess), Z_LVAL_PP(sharemode), NULL, Z_LVAL_PP(flags), NULL);
RETURN_LONG(ret);
}
/* {{{ proto bool fillconsoleoutputattribute(int consoleoutput, int attribute, int len, int x, int y)
*/
PHP_FUNCTION(fillconsoleoutputattribute)
{
zval **consoleoutput;
zval **attribute;
zval **len;
zval **x;
zval **y;
DWORD dw;
COORD coord;
int ac = ZEND_NUM_ARGS();
if (ac != 5 || zend_get_parameters_ex(ac, &consoleoutput, &attribute, &len, &x, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(consoleoutput);
convert_to_long_ex(attribute);
convert_to_long_ex(len);
convert_to_long_ex(x);
convert_to_long_ex(y);
coord.X = (short)Z_LVAL_PP(x);
coord.Y = (short)Z_LVAL_PP(y);
RETURN_BOOL(FillConsoleOutputAttribute((HANDLE)Z_LVAL_PP(consoleoutput), (WORD)Z_LVAL_PP(attribute), Z_LVAL_PP(len), coord, &dw));
}
/* {{{ proto long getstdhandle(int stdhandle)
*/
PHP_FUNCTION(getstdhandle)
{
zval **stdhandle;
int ac = ZEND_NUM_ARGS();
if (ac != 1 || zend_get_parameters_ex(ac, &stdhandle) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(stdhandle);
RETURN_LONG((long)GetStdHandle(Z_LVAL_PP(stdhandle)));
}
/* {{{ proto bool setconsoletitle(string title)
*/
PHP_FUNCTION(setconsoletitle)
{
zval **title;
int ac = ZEND_NUM_ARGS();
if (ac != 1 || zend_get_parameters_ex(ac, &title) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(title);
RETURN_BOOL(SetConsoleTitle(Z_STRVAL_PP(title)));
}
/* {{{ proto string readconsole(int consoleinput, int buflen)
*/
PHP_FUNCTION(readconsole)
{
char *buffer;
DWORD buflen;
zval **zbuflen;
zval **consoleinput;
DWORD cr;
int ac = ZEND_NUM_ARGS();
if (ac != 2 || zend_get_parameters_ex(ac, &consoleinput, &zbuflen) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(zbuflen);
convert_to_long_ex(consoleinput);
buflen = (DWORD)Z_LVAL_PP(zbuflen);
buffer = emalloc(buflen);
ReadConsole( (HANDLE)Z_LVAL_PP(consoleinput), buffer, buflen, &cr, NULL);
ZVAL_STRING(return_value, buffer, TRUE);
efree(buffer);
}
/* {{{ proto bool flushconsoleinputbuffer(int consoleinput)
*/
PHP_FUNCTION(flushconsoleinputbuffer)
{
zval **consoleinput;
int ac = ZEND_NUM_ARGS();
if (ac != 1 || zend_get_parameters_ex(ac, &consoleinput) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(consoleinput);
RETURN_BOOL(FlushConsoleInputBuffer((HANDLE)Z_LVAL_PP(consoleinput)));
}
/* {{{ proto bool freeconsole(void)
*/
PHP_FUNCTION(freeconsole)
{
RETURN_BOOL(FreeConsole());
}
/* {{{ proto bool generateconsolectrlevent(int ctrlevent, int processgroupid)
*/
PHP_FUNCTION(generateconsolectrlevent)
{
zval **ctrlevent;
zval **processgroupid;
int ac = ZEND_NUM_ARGS();
if (ac != 2 || zend_get_parameters_ex(ac, &ctrlevent, &processgroupid) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(ctrlevent);
convert_to_long_ex(processgroupid);
RETURN_BOOL(GenerateConsoleCtrlEvent(Z_LVAL_PP(ctrlevent), Z_LVAL_PP(processgroupid)));
}
/* {{{ proto int getconsolecp(void)
*/
PHP_FUNCTION(getconsolecp)
{
RETURN_LONG(GetConsoleCP());
}
/* {{{ proto long getconsolecursorsize(int consoleoutput)
*/
PHP_FUNCTION(getconsolecursorsize)
{
zval **consoleoutput;
CONSOLE_CURSOR_INFO cursorinfo;
int ac = ZEND_NUM_ARGS();
if (ac != 1 || zend_get_parameters_ex(ac, &consoleoutput) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(consoleoutput);
GetConsoleCursorInfo((HANDLE)Z_LVAL_PP(consoleoutput), &cursorinfo);
RETURN_LONG(cursorinfo.dwSize);
}
/* {{{ proto bool getconsolecursorvisible(int consoleoutput)
*/
PHP_FUNCTION(getconsolecursorvisible)
{
zval **consoleoutput;
CONSOLE_CURSOR_INFO cursorinfo;
int ac = ZEND_NUM_ARGS();
if (ac != 1 || zend_get_parameters_ex(ac, &consoleoutput) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(consoleoutput);
GetConsoleCursorInfo((HANDLE)Z_LVAL_PP(consoleoutput), &cursorinfo);
RETURN_BOOL(cursorinfo.bVisible);
}
/* {{{ proto int getconsolemode(int consolehandle)
*/
PHP_FUNCTION(getconsolemode)
{
zval **consolehandle;
DWORD flags;
int ac = ZEND_NUM_ARGS();
if (ac != 1 || zend_get_parameters_ex(ac, &consolehandle) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(consolehandle);
GetConsoleMode((HANDLE)Z_LVAL_PP(consolehandle), &flags);
RETURN_LONG(flags);
}
/* {{{ proto int getconsoleoutputcp(void)
*/
PHP_FUNCTION(getconsoleoutputcp)
{
RETURN_LONG(GetConsoleOutputCP());
}
/* {{{ proto array getconsolescreenbufferinfo(int consoleoutput)
*/
PHP_FUNCTION(getconsolescreenbufferinfo)
{
zval **consoleoutput;
zval *size;
zval *cursorposition;
zval *srwindow;
zval *maxwinsize;
CONSOLE_SCREEN_BUFFER_INFO bufferinfo;
int ac = ZEND_NUM_ARGS();
if (ac != 1 || zend_get_parameters_ex(ac, &consoleoutput) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(consoleoutput);
GetConsoleScreenBufferInfo((HANDLE)Z_LVAL_PP(consoleoutput), &bufferinfo);
array_init(return_value);
MAKE_STD_ZVAL(size);
MAKE_STD_ZVAL(cursorposition);
MAKE_STD_ZVAL(srwindow);
MAKE_STD_ZVAL(maxwinsize);
array_init(size);
array_init(cursorposition);
array_init(srwindow);
array_init(maxwinsize);
add_assoc_long(size, "x", bufferinfo.dwSize.X);
add_assoc_long(size, "y", bufferinfo.dwSize.Y);
add_assoc_long(cursorposition, "x", bufferinfo.dwCursorPosition.X);
add_assoc_long(cursorposition, "y", bufferinfo.dwCursorPosition.Y);
add_assoc_zval(return_value, "dwsize", size);
add_assoc_zval(return_value, "dwcursorposition", cursorposition);
add_assoc_long(return_value, "wattributes", bufferinfo.wAttributes);
add_assoc_long(srwindow, "left", bufferinfo.srWindow.Left);
add_assoc_long(srwindow, "top", bufferinfo.srWindow.Top);
add_assoc_long(srwindow, "right", bufferinfo.srWindow.Right);
add_assoc_long(srwindow, "bottom", bufferinfo.srWindow.Bottom);
add_assoc_zval(return_value, "srwindow", srwindow);
add_assoc_long(maxwinsize, "x", bufferinfo.dwMaximumWindowSize.X);
add_assoc_long(maxwinsize, "y", bufferinfo.dwMaximumWindowSize.Y);
add_assoc_zval(return_value, "dwmaximumwindowsize", maxwinsize);
}
/* {{{ proto string getconsoletitle(int buflen)
*/
PHP_FUNCTION(getconsoletitle)
{
char *buffer;
DWORD buflen;
zval **zbuflen;
int ac = ZEND_NUM_ARGS();
if (ac != 1 || zend_get_parameters_ex(ac, &zbuflen) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(zbuflen);
buflen = (DWORD)Z_LVAL_PP(zbuflen);
buffer = emalloc(buflen);
GetConsoleTitle(buffer, buflen);
ZVAL_STRING(return_value, buffer, TRUE);
efree(buffer);
}
/* {{{ proto int getnumberofconsoleevents(int consoleinput)
*/
PHP_FUNCTION(getnumberofconsoleinputevents)
{
zval **consoleinput;
DWORD numberofevents;
int ac = ZEND_NUM_ARGS();
if (ac != 1 || zend_get_parameters_ex(ac, &consoleinput) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(consoleinput);
GetNumberOfConsoleInputEvents((HANDLE)Z_LVAL_PP(consoleinput), &numberofevents);
RETURN_LONG(numberofevents);
}
/* {{{ proto bool setconsolecp(int codepage)
*/
PHP_FUNCTION(setconsolecp)
{
zval **codepage;
int ac = ZEND_NUM_ARGS();
if (ac != 1 || zend_get_parameters_ex(ac, &codepage) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(codepage);
RETURN_BOOL(SetConsoleCP(Z_LVAL_PP(codepage)));
}
/* {{{ proto bool writeconsole(int consoleoutput, string str)
*/
PHP_FUNCTION(writeconsole)
{
zval **consoleoutput;
zval **str;
DWORD nNumberOfCharsToWrite; // number of characters to write
DWORD NumberOfCharsWritten; // number of characters written
int ac = ZEND_NUM_ARGS();
if (ac != 2 || zend_get_parameters_ex(ac, &consoleoutput, &str) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(consoleoutput);
convert_to_string_ex(str);
nNumberOfCharsToWrite = Z_STRLEN_PP(str);
RETURN_BOOL(WriteConsole((HANDLE)Z_LVAL_PP(consoleoutput), Z_STRVAL_PP(str), nNumberOfCharsToWrite, &NumberOfCharsWritten, NULL));
}
/* {{{ proto bool setconsoleattribute(int consoleoutput int attributes)
*/
PHP_FUNCTION(setconsoletextattribute)
{
zval **consoleoutput;
zval **attributes;
int ac = ZEND_NUM_ARGS();
if (ac != 2 || zend_get_parameters_ex(ac, &consoleoutput, &attributes) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(consoleoutput);
convert_to_long_ex(attributes);
RETURN_BOOL(SetConsoleTextAttribute((HANDLE)Z_LVAL_PP(consoleoutput), (WORD)Z_LVAL_PP(attributes)));
}
/* {{{ proto bool setconsoleoutputcp(int codepageid)
*/
PHP_FUNCTION(setconsoleoutputcp)
{
zval **codepageid;
int ac=ZEND_NUM_ARGS();
if (ac != 1 || zend_get_parameters_ex(ac, &codepageid) == FAILURE) {
WRONG_PARAM_COUNT;
}
RETURN_BOOL(SetConsoleOutputCP(Z_LVAL_PP(codepageid)));
}
/* {{{ proto bool setstdhandle(int stdhandle, int hHandle)
*/
PHP_FUNCTION(setstdhandle)
{
zval **stdhandle;
zval **hHandle;
int ac = ZEND_NUM_ARGS();
if (ac != 2 || zend_get_parameters_ex(ac, &stdhandle, &hHandle) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(stdhandle);
convert_to_long_ex(hHandle);
RETURN_BOOL(SetStdHandle(Z_LVAL_PP(stdhandle), (HANDLE)Z_LVAL_PP(hHandle)));
}
/* {{{ proto bool setconsolemode(int consolehandle, int mode)
*/
PHP_FUNCTION(setconsolemode)
{
zval **consolehandle;
zval **mode;
int ac = ZEND_NUM_ARGS();
if (ac != 2 || zend_get_parameters_ex(ac, &consolehandle, &mode) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(consolehandle);
convert_to_long_ex(mode);
RETURN_BOOL(SetConsoleMode((HANDLE)Z_LVAL_PP(consolehandle), Z_LVAL_PP(mode)));
}
/* {{{ proto bool setconsolecursorposition(int consoleoutput, int x, int y)
*/
PHP_FUNCTION(setconsolecursorposition)
{
zval **consoleoutput;
zval **x;
zval **y;
COORD coord;
int ac = ZEND_NUM_ARGS();
if (ac != 3 || zend_get_parameters_ex(ac, &consoleoutput, &x, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(consoleoutput);
convert_to_long_ex(x);
convert_to_long_ex(y);
coord.X = (short)Z_LVAL_PP(x);
coord.Y = (short)Z_LVAL_PP(y);
RETURN_BOOL(SetConsoleCursorPosition((HANDLE)Z_LVAL_PP(consoleoutput), coord));
}
/* {{{ proto bool setconsolecursorinfo(int consoleoutput, int size, bool visible)
*/
PHP_FUNCTION(setconsolecursorinfo)
{
zval **consoleoutput;
zval **size;
zval **visible;
CONSOLE_CURSOR_INFO cursorinfo;
int ac = ZEND_NUM_ARGS();
if (ac != 3 || zend_get_parameters_ex(ac, &consoleoutput, &size, &visible) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(consoleoutput);
convert_to_long_ex(size);
convert_to_boolean_ex(visible);
cursorinfo.dwSize = Z_LVAL_PP(size);
cursorinfo.bVisible = Z_BVAL_PP(visible);
RETURN_BOOL(SetConsoleCursorInfo((HANDLE)Z_LVAL_PP(consoleoutput), &cursorinfo));
}
/* {{{ proto bool writeconsoleoutputcharacter(int consoleoutput, string arg, int x, int y)
*/
PHP_FUNCTION(writeconsoleoutputcharacter)
{
zval **consoleoutput;
zval **characters;
zval **x;
zval **y;
COORD coord;
int n;
int len;
int ac = ZEND_NUM_ARGS();
if (ac != 4 || zend_get_parameters_ex(ac, &consoleoutput, &characters, &x, &y) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(consoleoutput);
convert_to_long_ex(x);
convert_to_long_ex(y);
convert_to_string_ex(characters);
len = Z_STRLEN_PP(characters);
coord.X = (short)Z_LVAL_PP(x);
coord.Y = (short)Z_LVAL_PP(y);
RETURN_BOOL(WriteConsoleOutputCharacter((HANDLE)Z_LVAL_PP(consoleoutput), Z_STRVAL_PP(characters), len, coord, &n));
}
/* }}} */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
| 25.706147 | 132 | 0.723142 |
0c37e45185d0e00b30bbef8a8a47bb2c8cd8e73b | 555 | h | C | src/common.h | jonco3/dynamic | 76d10b012a7860595c7d9abbdf542c7d8f2a4d53 | [
"MIT"
] | 1 | 2020-11-26T23:37:19.000Z | 2020-11-26T23:37:19.000Z | src/common.h | jonco3/dynamic | 76d10b012a7860595c7d9abbdf542c7d8f2a4d53 | [
"MIT"
] | null | null | null | src/common.h | jonco3/dynamic | 76d10b012a7860595c7d9abbdf542c7d8f2a4d53 | [
"MIT"
] | null | null | null | #ifndef __COMMON_H__
#define __COMMON_H__
#include "value.h"
#include <string>
using namespace std;
struct Env;
extern bool debugMode;
extern void init1();
extern void init2(const string& internalsPath);
extern void final();
extern string readFile(string filename);
extern void printException(Value value);
extern Env* createTopLevel();
extern bool execModule(string text, string filename, Traced<Env*> global,
MutableTraced<Value> resultOut);
extern bool execModule(string text, string filename, Traced<Env*> global);
#endif
| 23.125 | 74 | 0.751351 |
0c38fd0f5ab135c5fdcc57992ca6d19fea746945 | 891 | h | C | QCC_Base/MACRO/MACRO_NOTICE.h | qxc122/QCC_Base | 3262eb3b3f901d4a9b85c5887994bec8332ac9b1 | [
"MIT"
] | 1 | 2017-04-01T01:50:58.000Z | 2017-04-01T01:50:58.000Z | QCC_Base/MACRO/MACRO_NOTICE.h | qxc122/QCC_Base | 3262eb3b3f901d4a9b85c5887994bec8332ac9b1 | [
"MIT"
] | null | null | null | QCC_Base/MACRO/MACRO_NOTICE.h | qxc122/QCC_Base | 3262eb3b3f901d4a9b85c5887994bec8332ac9b1 | [
"MIT"
] | null | null | null | //
// MACRO_NOTICE.h
// portal
//
// Created by Store on 2017/8/31.
// Copyright © 2017年 qxc122@126.com. All rights reserved.
//
#ifndef MACRO_NOTICE_h
#define MACRO_NOTICE_h
#define LOGIN_EXIT_NOTIFICATION @"LOGIN_EXIT_NOTIFICATION"
#define GET_NEW_TOKEN_NOTIFICATION @"GET_NEW_TOKEN_NOTIFICATION" //获取了新的token
#define ADD_BANK_CARD_SUCCESS @"ADD_BANK_CARD_SUCCESS" // 添加银行卡成功
#define TheTeachingPageIsDisplayed @"TheTeachingPageIsDisplayed" //该显示教学页面了
/////////////////////////////////////////////////////////////////////
#define CHANGE_NAME_NOTIFICATION @"CHANGE_NAME_NOTIFICATION" //更改名字 和 名字
#define NETWORK_FROM_CONNECTION_TO_CONNECTION_NOTIFICATION @"NETWORK_FROM_CONNECTION_TO_CONNECTION_NOTIFICATION" //网络从无连接到连接
#define TPAY_PAYMENT_NOTIFICATION @"TPAY_PAYMENT_NOTIFICATION" // T钱包支付
#define GO_FOR_A_STROLL @"GO_FOR_A_STROLL" //
#endif /* MACRO_NOTICE_h */
| 28.741935 | 125 | 0.738496 |
0c39848b8a2333cdeab48a43637d8024be27d7a8 | 6,525 | c | C | thirdparty/webm/src/vp8/decoder/detokenize.c | WowaBBS/CrashRpt | edcec3751df1e0d4e92a71560ff5b91b0abafd1e | [
"BSD-3-Clause"
] | 37 | 2017-06-01T23:38:05.000Z | 2020-11-06T02:29:47.000Z | thirdparty/webm/src/vp8/decoder/detokenize.c | WowaBBS/CrashRpt | edcec3751df1e0d4e92a71560ff5b91b0abafd1e | [
"BSD-3-Clause"
] | 11 | 2017-07-26T01:22:37.000Z | 2021-01-08T07:27:02.000Z | thirdparty/webm/src/vp8/decoder/detokenize.c | WowaBBS/CrashRpt | edcec3751df1e0d4e92a71560ff5b91b0abafd1e | [
"BSD-3-Clause"
] | 20 | 2018-01-07T00:13:08.000Z | 2021-01-08T07:54:03.000Z | /*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "vp8/common/blockd.h"
#include "onyxd_int.h"
#include "vpx_mem/vpx_mem.h"
#include "vpx_ports/mem.h"
#include "detokenize.h"
void vp8_reset_mb_tokens_context(MACROBLOCKD *x)
{
ENTROPY_CONTEXT *a_ctx = ((ENTROPY_CONTEXT *)x->above_context);
ENTROPY_CONTEXT *l_ctx = ((ENTROPY_CONTEXT *)x->left_context);
vpx_memset(a_ctx, 0, sizeof(ENTROPY_CONTEXT_PLANES)-1);
vpx_memset(l_ctx, 0, sizeof(ENTROPY_CONTEXT_PLANES)-1);
/* Clear entropy contexts for Y2 blocks */
if (!x->mode_info_context->mbmi.is_4x4)
{
a_ctx[8] = l_ctx[8] = 0;
}
}
/*
------------------------------------------------------------------------------
Residual decoding (Paragraph 13.2 / 13.3)
*/
static const uint8_t kBands[16 + 1] = {
0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7,
0 /* extra entry as sentinel */
};
static const uint8_t kCat3[] = { 173, 148, 140, 0 };
static const uint8_t kCat4[] = { 176, 155, 140, 135, 0 };
static const uint8_t kCat5[] = { 180, 157, 141, 134, 130, 0 };
static const uint8_t kCat6[] =
{ 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129, 0 };
static const uint8_t* const kCat3456[] = { kCat3, kCat4, kCat5, kCat6 };
static const uint8_t kZigzag[16] = {
0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
};
#define VP8GetBit vp8dx_decode_bool
#define NUM_PROBAS 11
#define NUM_CTX 3
typedef const uint8_t (*ProbaArray)[NUM_CTX][NUM_PROBAS]; // for const-casting
static int GetSigned(BOOL_DECODER *br, int value_to_sign)
{
int split = (br->range + 1) >> 1;
VP8_BD_VALUE bigsplit = (VP8_BD_VALUE)split << (VP8_BD_VALUE_SIZE - 8);
int v;
if(br->count < 0)
vp8dx_bool_decoder_fill(br);
if ( br->value < bigsplit )
{
br->range = split;
v= value_to_sign;
}
else
{
br->range = br->range-split;
br->value = br->value-bigsplit;
v = -value_to_sign;
}
br->range +=br->range;
br->value +=br->value;
br->count--;
return v;
}
/*
Returns the position of the last non-zero coeff plus one
(and 0 if there's no coeff at all)
*/
static int GetCoeffs(BOOL_DECODER *br, ProbaArray prob,
int ctx, int n, int16_t* out)
{
const uint8_t* p = prob[n][ctx];
if (!VP8GetBit(br, p[0]))
{ /* first EOB is more a 'CBP' bit. */
return 0;
}
while (1)
{
++n;
if (!VP8GetBit(br, p[1]))
{
p = prob[kBands[n]][0];
}
else
{ /* non zero coeff */
int v, j;
if (!VP8GetBit(br, p[2]))
{
p = prob[kBands[n]][1];
v = 1;
}
else
{
if (!VP8GetBit(br, p[3]))
{
if (!VP8GetBit(br, p[4]))
{
v = 2;
}
else
{
v = 3 + VP8GetBit(br, p[5]);
}
}
else
{
if (!VP8GetBit(br, p[6]))
{
if (!VP8GetBit(br, p[7]))
{
v = 5 + VP8GetBit(br, 159);
} else
{
v = 7 + 2 * VP8GetBit(br, 165);
v += VP8GetBit(br, 145);
}
}
else
{
const uint8_t* tab;
const int bit1 = VP8GetBit(br, p[8]);
const int bit0 = VP8GetBit(br, p[9 + bit1]);
const int cat = 2 * bit1 + bit0;
v = 0;
for (tab = kCat3456[cat]; *tab; ++tab)
{
v += v + VP8GetBit(br, *tab);
}
v += 3 + (8 << cat);
}
}
p = prob[kBands[n]][2];
}
j = kZigzag[n - 1];
out[j] = GetSigned(br, v);
if (n == 16 || !VP8GetBit(br, p[0]))
{ /* EOB */
return n;
}
}
if (n == 16)
{
return 16;
}
}
}
int vp8_decode_mb_tokens(VP8D_COMP *dx, MACROBLOCKD *x)
{
BOOL_DECODER *bc = x->current_bc;
const FRAME_CONTEXT * const fc = &dx->common.fc;
char *eobs = x->eobs;
int i;
int nonzeros;
int eobtotal = 0;
short *qcoeff_ptr;
ProbaArray coef_probs;
ENTROPY_CONTEXT *a_ctx = ((ENTROPY_CONTEXT *)x->above_context);
ENTROPY_CONTEXT *l_ctx = ((ENTROPY_CONTEXT *)x->left_context);
ENTROPY_CONTEXT *a;
ENTROPY_CONTEXT *l;
int skip_dc = 0;
qcoeff_ptr = &x->qcoeff[0];
if (!x->mode_info_context->mbmi.is_4x4)
{
a = a_ctx + 8;
l = l_ctx + 8;
coef_probs = fc->coef_probs [1];
nonzeros = GetCoeffs(bc, coef_probs, (*a + *l), 0, qcoeff_ptr + 24 * 16);
*a = *l = (nonzeros > 0);
eobs[24] = nonzeros;
eobtotal += nonzeros - 16;
coef_probs = fc->coef_probs [0];
skip_dc = 1;
}
else
{
coef_probs = fc->coef_probs [3];
skip_dc = 0;
}
for (i = 0; i < 16; ++i)
{
a = a_ctx + (i&3);
l = l_ctx + ((i&0xc)>>2);
nonzeros = GetCoeffs(bc, coef_probs, (*a + *l), skip_dc, qcoeff_ptr);
*a = *l = (nonzeros > 0);
nonzeros += skip_dc;
eobs[i] = nonzeros;
eobtotal += nonzeros;
qcoeff_ptr += 16;
}
coef_probs = fc->coef_probs [2];
a_ctx += 4;
l_ctx += 4;
for (i = 16; i < 24; ++i)
{
a = a_ctx + ((i > 19)<<1) + (i&1);
l = l_ctx + ((i > 19)<<1) + ((i&3)>1);
nonzeros = GetCoeffs(bc, coef_probs, (*a + *l), 0, qcoeff_ptr);
*a = *l = (nonzeros > 0);
eobs[i] = nonzeros;
eobtotal += nonzeros;
qcoeff_ptr += 16;
}
return eobtotal;
}
| 26.632653 | 82 | 0.463142 |
0c3a9dbf3a04a6663b1b2123b868fa79ccb8c55f | 6,089 | c | C | Firmware/J2B_synthesizer_3.0/src/envelope2.c | ElektorLabs/J2B-Synthesizer | 0965db8223e373e6d5762315510f9b3f39941121 | [
"CC0-1.0"
] | 8 | 2015-06-05T21:34:30.000Z | 2021-01-27T11:34:22.000Z | Firmware/J2B_synthesizer_3.0/src/envelope2.c | ElektorLabs/J2B-Synthesizer | 0965db8223e373e6d5762315510f9b3f39941121 | [
"CC0-1.0"
] | null | null | null | Firmware/J2B_synthesizer_3.0/src/envelope2.c | ElektorLabs/J2B-Synthesizer | 0965db8223e373e6d5762315510f9b3f39941121 | [
"CC0-1.0"
] | 4 | 2016-09-29T12:19:30.000Z | 2019-07-29T00:36:33.000Z | /*
Copyright 2013 Paul Soulsby www.soulsbysynths.com
This file is part of Atmegatron.
Atmegatron is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Atmegatron 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 Atmegatron. If not, see <http://www.gnu.org/licenses/>.
*/
//****** BIPOLAR ENVELOPE - for filter and pitch***********
#include "atmegatron.h"
#if PRODUCT==ATMEGATRON || PRODUCT==ATCYCLOTRON || PRODUCT==DELAYERTRON
#if PRODUCT==ATCYCLOTRON
//This now works as a set of 16 presets. The preset values are below
const byte envA_preset[16] = { 0, 0, 0, 0, 0, 3, 3, 5, 5, 7, 7, 7,11,11,15,15};
const byte envDR_preset[16] = { 3, 5, 7, 7,11, 0, 3, 0, 7, 0, 3, 7, 0, 5, 0,15};
const byte envS_preset[16] = { 0, 0, 0, 7, 0, 0, 0,15, 0, 0, 0, 7,15, 0,15, 0};
byte fenv_preset = 2;
#define FENV_DR (381)
#endif /* PRODUCT */
#if PRODUCT==ATMEGATRON || PRODUCT==DELAYERTRON
#define FENV_DR (400)
#endif /* PRODUCT */
//lets and gets
unsigned int fenv_A = 0; //attack (in ticks)
unsigned int fenv_DR = FENV_DR; //decay AND release (in ticks) (only reason for this is because there's not enough functions on function dial for both)
signed char fenv_S = 0; //sustain (-127 - 127)
signed char fenv_level = 0; //the current output level of the env. between -127 and 127
boolean fenv_invert = false; //envelope invert mode
//local filt env vars
unsigned int fenv_curtick; //current tick through env shape
//unsigned long fenv_starttick; //tick that env started at
byte fenv_curstate = 0; //0 = off, 1 = triggering, 2 = holding, 3 = releasing ;
boolean fenv_changed = true; //used to only calc Env when it's been triggered
signed char fenv_Rstart = 0; //incase key up before decay finishes
//lets and gets
#if PRODUCT==ATCYCLOTRON
//fenv preset
void Fenv_Let_Preset(byte newamt)
{ //0-31
if (newamt!=fenv_preset)
{
fenv_preset = newamt;
fenv_A = Hardware_Get_envADR(envA_preset[fenv_preset]);
fenv_DR = Hardware_Get_envADR(envDR_preset[fenv_preset]);
fenv_S = Hardware_Get_envS(envS_preset[fenv_preset]);
fenv_changed = true;
}
}
byte Fenv_Get_Preset(void)
{
return fenv_preset;
}
#endif /* PRODUCT */
#if PRODUCT==ATMEGATRON || PRODUCT==DELAYERTRON
//set attack (in ticks)
void Fenv_Let_A(unsigned int newA)
{
if (newA!=fenv_A)
{
fenv_A = newA;
fenv_changed = true;
}
}
unsigned int Fenv_Get_A(void)
{
return fenv_A;
}
//set decay and release (in ticks)
void Fenv_Let_DR(unsigned int newDR)
{
if (newDR!=fenv_DR)
{
fenv_DR = newDR;
fenv_changed = true;
}
}
unsigned int Fenv_Get_DR(void)
{
return fenv_DR;
}
//set sustain (0-127) -127 - 0 is obtained by turning on invert mode
void Fenv_Let_S(signed char newS)
{
if (newS!=fenv_S)
{
fenv_S = newS;
fenv_changed = true;
}
}
signed char Fenv_Get_S(void)
{
return fenv_S;
}
#endif /* PRODUCT */
//set invert mode
void Fenv_Let_Invert(boolean newinv)
{
if (newinv!=fenv_invert)
{
fenv_invert = newinv;
fenv_changed = true;
}
}
boolean Fenv_Get_Invert(void)
{
return fenv_invert;
}
//get current level of env (-127 - 127)
signed char Fenv_Get_Level(void)
{
//invert output value if invert mode is on
if (fenv_invert==true)
{
return -fenv_level;
}
else
{
return fenv_level;
}
}
//meat
//trigger the (start of) envelope
void FEnv_Trigger(void)
{
fenv_curtick = 0;
//fenv_starttick = master_tick;
fenv_curstate = 1;
fenv_changed = true;
}
//trigger release stage of envelope
void FEnv_Release(void)
{
fenv_curtick = 0;
//fenv_starttick = master_tick;
fenv_Rstart = fenv_level;
fenv_curstate = 3;
fenv_changed = true;
}
//calculate env output level
void FEnv_CalcVal(void)
{
if (fenv_changed==true){ //is envelope actually doing something?
switch (fenv_curstate){
case 0: //idle
fenv_level = 0;
fenv_changed = false;
break;
case 1:
fenv_curtick += master_tickspassed; //triggering
if (fenv_curtick>=fenv_A+fenv_DR){ //update tick
fenv_level = fenv_S; //if attack + decay ticks passed, then onto sustain
fenv_curstate = 2;
}
else if (fenv_curtick>=fenv_A){ //if attack ticks passed, then onto decay
fenv_level = map(fenv_curtick,fenv_A,fenv_A+fenv_DR,127,fenv_S);
}
else{ //otherwise must be doing attack
fenv_level = map(fenv_curtick,0,fenv_A,0,127);
}
break;
case 2: //holding
fenv_level = fenv_S; //make sure level = sustain level
fenv_changed = false; //only need to do this once
break;
case 3: //releasing
fenv_curtick += master_tickspassed;
if (fenv_curtick>=fenv_DR){ //if release ticks passed, then go back to idle
fenv_level = 0;
fenv_curstate = 0;
}
else{ //otherwise must be releasing
fenv_level = map(fenv_curtick,0,fenv_DR,fenv_Rstart,0);
}
break;
}
}
}
#endif /* PRODUCT */
| 27.304933 | 164 | 0.597635 |
0c3ad37020dc02e4aa996debf4413d49fd8ec90d | 15,359 | h | C | fdp2bin/lzss.h | Cancer52/flamedriver | 9ee6cf02c137dcd63e85a559907284283421e7ba | [
"0BSD"
] | 9 | 2017-10-09T20:28:45.000Z | 2021-06-29T21:19:20.000Z | fdp2bin/lzss.h | Cancer52/flamedriver | 9ee6cf02c137dcd63e85a559907284283421e7ba | [
"0BSD"
] | 12 | 2018-08-01T13:52:20.000Z | 2022-02-21T02:19:37.000Z | fdp2bin/lzss.h | Cancer52/flamedriver | 9ee6cf02c137dcd63e85a559907284283421e7ba | [
"0BSD"
] | 2 | 2018-02-17T19:50:36.000Z | 2019-10-30T19:28:06.000Z | /* -*- Mode: C++; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
* Copyright (C) Flamewing 2013-2015 <flamewing.sonic@gmail.com>
*
* This program 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 program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _LZSS_H_
#define _LZSS_H_
#include <iosfwd>
#include <limits>
#include <list>
#include <string>
#include <vector>
#include "bigendian_io.h"
#include "bitstream.h"
/*
* Class representing an edge in the LZSS-compression graph. An edge (u, v)
* indicates that there is a sliding window match that covers all the characters
* in the [u, v) range (half-open) -- that is, node v is not part of the match.
* Each node is a character in the file, and is represented by its position.
*/
class AdjListNode {
private:
// The first character after the match ends.
size_t destnode;
// Cost, in bits, of "covering" all of the characters in the match.
size_t weight;
// How many characters back does the match begin at.
size_t distance;
// How long the match is.
size_t length;
public:
// Constructors.
AdjListNode() noexcept
: destnode(1), weight(std::numeric_limits<size_t>::max()), distance(1),
length(1) {
}
AdjListNode(size_t dest, size_t dist, size_t len, size_t wgt) noexcept
: destnode(dest), weight(wgt), distance(dist), length(len) {
}
AdjListNode(AdjListNode const &other) noexcept = default;
AdjListNode(AdjListNode &&other) noexcept = default;
AdjListNode &operator=(AdjListNode const &other) noexcept = default;
AdjListNode &operator=(AdjListNode &&other) noexcept = default;
// Getters.
size_t get_dest() const noexcept {
return destnode;
}
size_t get_weight() const noexcept {
return weight;
}
size_t get_distance() const noexcept {
return distance;
}
size_t get_length() const noexcept {
return length;
}
// Comparison operator. Lowest weight first, on tie, break by shortest
// length, on further tie break by distance. Used only on the multimap.
bool operator<(AdjListNode const &other) const noexcept {
if (weight < other.weight)
return true;
else if (weight > other.weight)
return false;
if (length < other.length)
return true;
else if (length > other.length)
return false;
else
return distance < other.distance;
}
};
/*
* Graph structure for optimal LZSS encoding. This graph is a directed acyclic
* graph (DAG) by construction, and is automatically sorted topologically.
* The template parameter is an adaptor class/structure with the following
* members:
* struct LZSSAdaptor {
* typedef unsigned char stream_t;
* typedef unsigned short descriptor_t;
* typedef littleendian<descriptor_t> descriptor_endian_t;
* constexpr static size_t NumDescBits = sizeof(descriptor_t) * 8;
* // Number of bits used in descriptor bitfield to signal the end-of-file
* // marker sequence.
* constexpr static size_t NumTermBits = 2;
* // Flag that tells the compressor that new descriptor fields are needed
* // as soon as the last bit in the previous one is used up.
* constexpr static size_t NeedEarlyDescriptor = 1;
* // Flag that marks the descriptor bits as being in little-endian bit
* // order (that is, lowest bits come out first).
* constexpr static size_t DescriptorLittleEndianBits = 1;
* // Size of the search buffer.
* constexpr static size_t SearchBufSize = 8192;
* // Size of the look-ahead buffer.
* constexpr static size_t LookAheadBufSize = 256;
* // Total size of the sliding window.
* constexpr static size_t SlidingWindowSize = SearchBufSize + LookAheadBufSize;
* // Computes the cost of a symbolwise encoding, that is, the cost of encoding
* // one single symbol..
* constexpr static size_t symbolwise_weight() noexcept;
* // Computes the cost of covering all of the "len" vertices starting from
* // "off" vertices ago, for matches with len > 1.
* // A return of "std::numeric_limits<size_t>::max()" means "infinite",
* // or "no edge".
* static size_t dictionary_weight(size_t dist, size_t len) noexcept;
* // Given an edge, computes how many bits are used in the descriptor field.
* static size_t desc_bits(AdjListNode const &edge) noexcept;
* // Function that finds extra matches in the data that are specific to the
* // given encoder and not general LZSS dictionary matches.
* static void extra_matches(stream_t const *data, size_t basenode,
* size_t ubound, size_t lbound,
* LZSSGraph<KosinskiAdaptor>::MatchVector &matches) noexcept;
* };
*/
template<typename Adaptor>
class LZSSGraph {
public:
typedef std::list<AdjListNode> AdjList;
typedef std::vector<AdjListNode> MatchVector;
private:
// Source file data and its size; one node per character in source file.
typename Adaptor::stream_t const *data;
size_t const nlen;
// Account for padding at end of file, if any.
size_t const Padding;
// Adjacency lists for all the nodes in the graph.
std::vector<AdjList> adjs;
/*
* TODO: Improve speed with a smarter way to perform matches.
* This is the main workhorse and bottleneck: it finds the least costly way
* to reach all possible nodes reachable from the basenode and inserts them
* into a map.
*/
MatchVector find_matches(size_t basenode) const noexcept {
static_assert(noexcept(Adaptor::symbolwise_weight()),
"Adaptor::symbolwise_weight() is not noexcept");
static_assert(noexcept(Adaptor::dictionary_weight(basenode, basenode)),
"Adaptor::dictionary_weight() is not noexcept");
// Upper and lower bounds for sliding window, starting node.
size_t ubound = std::min(Adaptor::LookAheadBufSize, nlen - basenode),
lbound = basenode > Adaptor::SearchBufSize ? basenode - Adaptor::SearchBufSize : 0,
ii = basenode - 1;
// This is what we produce.
MatchVector matches(ubound);
// Start with the literal/symbolwise encoding of the current node.
size_t wgt = Adaptor::symbolwise_weight();
matches[0] = AdjListNode(basenode + 1, 0, 1, wgt);
// Get extra dictionary matches dependent on specific encoder.
static_assert(noexcept(Adaptor::extra_matches(data, basenode, ubound, lbound, matches)),
"Adaptor::extra_matches() is not noexcept");
Adaptor::extra_matches(data, basenode, ubound, lbound, matches);
// First node is special.
if (basenode == 0) {
return matches;
}
do {
// Keep looking for dictionary matches.
size_t jj = 0;
while (data[ii + jj] == data[basenode + jj]) {
++jj;
// We have found a match that links (basenode) with
// (basenode + jj) with length (jj) and distance (basenode-ii).
// Add it to the list if it is a better match.
size_t wgt = Adaptor::dictionary_weight(basenode - ii, jj);
AdjListNode &best = matches[jj - 1];
if (wgt < best.get_weight()) {
best = std::move(AdjListNode(basenode + jj, basenode - ii, jj, wgt));
}
// We can find no more matches with the current starting node.
if (jj >= ubound)
break;
}
} while (ii-- > lbound);
return matches;
}
public:
// Constructor: creates the graph from the input file.
LZSSGraph(unsigned char const *dt, size_t const size,
size_t const pad) noexcept
: data(reinterpret_cast<typename Adaptor::stream_t const *>(dt)),
nlen(size / sizeof(typename Adaptor::stream_t)), Padding(pad * 8 - 1) {
// Making space for all nodes.
adjs.resize(nlen);
for (size_t ii = 0; ii < nlen; ii++) {
// Find all matches for all subsequent nodes.
MatchVector const matches = find_matches(ii);
for (MatchVector::const_iterator it = matches.begin();
it != matches.end(); ++it) {
// Insert the best (lowest cost) edge linking these two nodes.
if (it->get_weight() != std::numeric_limits<size_t>::max()) {
adjs[ii].push_back(*it);
}
}
}
}
/*
* This function returns the shortest path through the file.
*/
AdjList find_optimal_parse() const noexcept {
static_assert(noexcept(Adaptor::desc_bits(AdjListNode())),
"Adaptor::desc_bits() is not noexcept");
static_assert(noexcept(Adaptor::get_padding(0, 0)),
"Adaptor::get_padding() is not noexcept");
// Auxiliary data structures:
// * The parent of a node is the node that reaches that node with the
// lowest cost from the start of the file.
std::vector<size_t> parents(nlen + 1);
// * This is the edge used to go from the parent of a node to said node.
std::vector<AdjListNode> pedges(nlen + 1);
// * This is the total cost to reach the edge. They start as high as
// possible for all nodes but the first, which starts at 0.
std::vector<size_t> costs(nlen + 1, std::numeric_limits<size_t>::max());
costs[0] = 0;
// * And this is a vector that tallies up the amount of unused bits in
// the descriptor bitfield for the shortest path up to this node.
// After tallying up the ending node, the end-of-file marker may cause
// an additional dummy descriptor bitfield to be emitted; this vector
// is used to counteract that.
std::vector<size_t> desccosts(nlen + 1, 0);
// Since the LZSS graph is a topologically-sorted DAG by construction,
// computing the shortest distance is very quick and easy: just go
// through the nodes in order and update the distances.
for (size_t ii = 0; ii < nlen; ii++) {
// Get the adjacency list for this node.
AdjList const &list = adjs[ii];
// Get remaining unused descriptor bits up to this node.
size_t basedesc = desccosts[ii];
for (AdjList::const_iterator it = list.begin();
it != list.end(); ++it) {
// Need destination ID and edge weight.
size_t nextnode = it->get_dest(), wgt = it->get_weight();
// Compute remaining unused bits from using this edge.
size_t desccost = basedesc + Adaptor::desc_bits(*it);
desccost %= Adaptor::NumDescBits;
if (nextnode == nlen) {
// This is the ending node. Add the descriptor bits for the
// end-of-file marker and wrap the descriptor.
desccost += Adaptor::NumTermBits;
desccost %= Adaptor::NumDescBits;
// If the descriptor bitfield had exactly 0 bits left after
// this, we may need to emit a new descriptor bitfield (the
// full Adaptor::NumDescBits bits). Otherwise, we need to
// pads the last descriptor bitfield to full size. This line
// accomplishes both.
if (Adaptor::NeedEarlyDescriptor != 0 || desccost > 0) {
wgt += (Adaptor::NumDescBits - desccost);
}
// Compensate for the Adaptor's padding, if any.
wgt += Adaptor::get_padding(costs[ii] + wgt, Padding);
}
// Is the cost to reach the target node through this edge less
// than the current cost?
if (costs[nextnode] > costs[ii] + wgt) {
// If so, update the data structures with new best edge.
costs[nextnode] = costs[ii] + wgt;
parents[nextnode] = ii;
pedges[nextnode] = *it;
desccosts[nextnode] = desccost;
}
}
}
// This is what we will produce.
AdjList parselist;
for (size_t ii = nlen; ii != 0;) {
// Insert the edge up front...
parselist.push_front(pedges[ii]);
// ... and switch to parent node.
ii = parents[ii];
}
// We are done: this is the optimal parsing of the input file, giving
// *the* best possible compressed file size.
return parselist;
}
};
/*
* This class abstracts away an LZSS output stream composed of one or more bytes
* in a descriptor bitfield, followed by byte parameters. It manages the output
* by buffering the bytes until a descriptor field is full, at which point it
* writes the descriptor field and flushes the output buffer.
*/
template <typename Adaptor>
class LZSSOStream {
private:
typedef typename Adaptor::descriptor_t descriptor_t;
typedef typename Adaptor::descriptor_endian_t BitWriter;
// Where we will output to.
std::ostream &out;
// Internal bitstream output buffer.
obitstream<descriptor_t, Adaptor::DescriptorLittleEndianBits != 0,
BitWriter> bits;
// Internal parameter buffer.
std::string buffer;
public:
// Constructor.
LZSSOStream(std::ostream &Dst) noexcept : out(Dst), bits(out) {
}
// Destructor: writes anything that hasn't been written.
~LZSSOStream() noexcept {
// We need a dummy descriptor field if we have exactly zero bits left
// on the previous descriptor field; this is because the decoder will
// immediately fetch a new descriptor field when the previous one has
// expired, and we don't want it to be the terminating sequence.
// First, save current state.
bool needdummydesc = !bits.have_waiting_bits();
// Now, flush the queue if needed.
bits.flush();
if (Adaptor::NeedEarlyDescriptor != 0 && needdummydesc) {
// We need to add a dummy descriptor field; so add it.
for (size_t ii = 0; ii < sizeof(descriptor_t); ii++) {
out.put(0x00);
}
}
// Now write the terminating sequence if it wasn't written already.
out.write(buffer.c_str(), buffer.size());
}
// Writes a bit to the descriptor bitfield. When the descriptor field is
// full, outputs it and the output parameter buffer.
void descbit(descriptor_t bit) noexcept {
if (Adaptor::NeedEarlyDescriptor != 0) {
if (bits.push(bit)) {
out.write(buffer.c_str(), buffer.size());
buffer.clear();
}
} else {
if (!bits.have_waiting_bits()) {
out.write(buffer.c_str(), buffer.size());
buffer.clear();
}
bits.push(bit);
}
}
// Puts a byte in the output buffer.
void putbyte(size_t c) noexcept {
Write1(buffer, c);
}
};
/*
* This class abstracts away an LZSS input stream composed of one or more bytes
* in a descriptor bitfield, followed by byte parameters. It manages the input
* by reading a descriptor field when one is required (as defined by the adaptor
* class), so that bytes can be read when needed from the input stream.
*/
template <typename Adaptor>
class LZSSIStream {
private:
typedef typename Adaptor::descriptor_t descriptor_t;
typedef typename Adaptor::descriptor_endian_t BitWriter;
// Where we will input to.
std::istream ∈
// Internal bitstream input buffer.
ibitstream<descriptor_t, Adaptor::NeedEarlyDescriptor != 0,
Adaptor::DescriptorLittleEndianBits != 0, BitWriter> bits;
// Internal parameter buffer.
std::string buffer;
public:
// Constructor.
LZSSIStream(std::istream &Src) noexcept : in(Src), bits(in) {
}
// Destructor: writes anything that hasn't been written.
~LZSSIStream() noexcept {
}
// Writes a bit to the descriptor bitfield. When the descriptor field is
// full, inputs it and the input parameter buffer.
descriptor_t descbit() noexcept {
return bits.pop();
}
// Puts a byte in the input buffer.
unsigned char getbyte() noexcept {
return Read1(in);
}
};
#endif // _LZSS_H_
| 38.687657 | 92 | 0.693795 |
0c3c0a3a58d839fe661dbdb2ac912e606a5f0658 | 3,443 | h | C | code/framework/libnop_gbench/include/semaphore_cbcl.h | Feupos/utfprct-tex | 8ed2994fd907e3bef93d5f734d58731cd0ef64e2 | [
"LPPL-1.3c"
] | null | null | null | code/framework/libnop_gbench/include/semaphore_cbcl.h | Feupos/utfprct-tex | 8ed2994fd907e3bef93d5f734d58731cd0ef64e2 | [
"LPPL-1.3c"
] | null | null | null | code/framework/libnop_gbench/include/semaphore_cbcl.h | Feupos/utfprct-tex | 8ed2994fd907e3bef93d5f734d58731cd0ef64e2 | [
"LPPL-1.3c"
] | null | null | null | #pragma once
#include "libnop/framework.h"
class Semaphore_CBCL
{
public:
NOP::SharedAttribute<int> atSeconds;
private:
NOP::SharedAttribute<int> atHVSS;
NOP::SharedAttribute<int> atSemaphoreState;
NOP::SharedAttribute<int> atVVSS;
const NOP::SharedPremise prSeconds;
const NOP::SharedPremise prSemaphoreState;
NOP::SharedRule rlCBCL1;
const NOP::SharedPremise prSecondsCBCL6;
const NOP::SharedPremise prSemaphoreStateCBCL6;
NOP::SharedRule rlCBCL10;
const NOP::SharedPremise prSeconds7;
const NOP::SharedPremise prSemaphoreState7;
const NOP::SharedPremise prVehicleSensorState7;
NOP::SharedRule rlCBCL11;
const NOP::SharedPremise prSeconds7Full;
const NOP::SharedPremise prSemaphoreState7Full;
const NOP::SharedPremise prVehicleSensorState7Full;
NOP::SharedRule rlCBCL12;
const NOP::SharedPremise prSeconds8;
const NOP::SharedPremise prSecondsSup8;
const NOP::SharedPremise prSemaphoreState8;
const NOP::SharedPremise prVehicleSensorState8;
NOP::SharedRule rlCBCL13;
const NOP::SharedPremise prSeconds8Full;
const NOP::SharedPremise prSecondsSup8Full;
const NOP::SharedPremise prSemaphoreState8Full;
const NOP::SharedPremise prVehicleSensorState8Full;
NOP::SharedRule rlCBCL14;
const NOP::SharedPremise prSeconds9;
const NOP::SharedPremise prSemaphoreState9;
const NOP::SharedPremise prVehicleSensorState9;
NOP::SharedRule rlCBCL15;
const NOP::SharedPremise prSeconds9Full;
const NOP::SharedPremise prSemaphoreState9Full;
const NOP::SharedPremise prVehicleSensorState9Full;
NOP::SharedRule rlCBCL16;
const NOP::SharedPremise prSeconds10;
const NOP::SharedPremise prSecondsSup10;
const NOP::SharedPremise prSemaphoreState10;
const NOP::SharedPremise prVehicleSensorState10;
NOP::SharedRule rlCBCL17;
const NOP::SharedPremise prSeconds10Full;
const NOP::SharedPremise prSecondsSup10Full;
const NOP::SharedPremise prSemaphoreState10Full;
const NOP::SharedPremise prVehicleSensorState10Full;
NOP::SharedRule rlCBCL18;
const NOP::SharedPremise prSeconds2;
const NOP::SharedPremise prSemaphoreState2;
NOP::SharedRule rlCBCL2;
const NOP::SharedPremise prSecondsCBCL2;
const NOP::SharedPremise prSemaphoreStateCBCL2;
NOP::SharedRule rlCBCL3;
const NOP::SharedPremise prSeconds3;
const NOP::SharedPremise prSemaphoreState3;
NOP::SharedRule rlCBCL4;
const NOP::SharedPremise prSecondsCBCL3;
const NOP::SharedPremise prSemaphoreStateCBCL3;
NOP::SharedRule rlCBCL5;
const NOP::SharedPremise prSeconds4;
const NOP::SharedPremise prSemaphoreState4;
NOP::SharedRule rlCBCL6;
const NOP::SharedPremise prSeconds5;
const NOP::SharedPremise prSemaphoreState5;
NOP::SharedRule rlCBCL7;
const NOP::SharedPremise prSecondsCBCL5;
const NOP::SharedPremise prSemaphoreStateCBCL5;
NOP::SharedRule rlCBCL8;
const NOP::SharedPremise prSeconds6;
const NOP::SharedPremise prSemaphoreState6;
NOP::SharedRule rlCBCL9;
public:
Semaphore_CBCL();
private:
void mtHTLG();
void mtHTLGCBCL();
void mtHTLR();
void mtHTLY();
void mtHTLYCBCL();
void mtRT();
void mtVTLG();
void mtVTLGCBCL();
void mtVTLR();
void mtVTLY();
void mtVTLYCBCL();
};
| 35.864583 | 57 | 0.730177 |
0c3cc03c61fa307e0b1ca829aeab3a94268f3a73 | 3,360 | h | C | kernel/2.6.32/fs/ocfs2/dlm/userdlm.h | haizhenhan/Kepler | d15293a7ef69f44b1fe61d5cdeceb0bd73f0d315 | [
"BSD-3-Clause"
] | 55 | 2015-01-20T00:09:45.000Z | 2021-08-19T05:40:27.000Z | linux/linux-2.6.32/fs/ocfs2/dlm/userdlm.h | jwegan/TCP-RST-Guard | 8734350ef09b0cd79e72797ffa009d75441886bb | [
"MIT"
] | 1 | 2017-04-22T18:17:57.000Z | 2017-09-15T11:28:26.000Z | linux/linux-2.6.32/fs/ocfs2/dlm/userdlm.h | jwegan/TCP-RST-Guard | 8734350ef09b0cd79e72797ffa009d75441886bb | [
"MIT"
] | 36 | 2015-02-13T00:58:22.000Z | 2021-08-19T08:08:07.000Z | /* -*- mode: c; c-basic-offset: 8; -*-
* vim: noexpandtab sw=8 ts=8 sts=0:
*
* userdlm.h
*
* Userspace dlm defines
*
* Copyright (C) 2002, 2004 Oracle. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 021110-1307, USA.
*/
#ifndef USERDLM_H
#define USERDLM_H
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/types.h>
#include <linux/workqueue.h>
/* user_lock_res->l_flags flags. */
#define USER_LOCK_ATTACHED (0x00000001) /* we have initialized
* the lvb */
#define USER_LOCK_BUSY (0x00000002) /* we are currently in
* dlm_lock */
#define USER_LOCK_BLOCKED (0x00000004) /* blocked waiting to
* downconvert*/
#define USER_LOCK_IN_TEARDOWN (0x00000008) /* we're currently
* destroying this
* lock. */
#define USER_LOCK_QUEUED (0x00000010) /* lock is on the
* workqueue */
#define USER_LOCK_IN_CANCEL (0x00000020)
struct user_lock_res {
spinlock_t l_lock;
int l_flags;
#define USER_DLM_LOCK_ID_MAX_LEN 32
char l_name[USER_DLM_LOCK_ID_MAX_LEN];
int l_namelen;
int l_level;
unsigned int l_ro_holders;
unsigned int l_ex_holders;
struct dlm_lockstatus l_lksb;
int l_requested;
int l_blocking;
wait_queue_head_t l_event;
struct work_struct l_work;
};
extern struct workqueue_struct *user_dlm_worker;
void user_dlm_lock_res_init(struct user_lock_res *lockres,
struct dentry *dentry);
int user_dlm_destroy_lock(struct user_lock_res *lockres);
int user_dlm_cluster_lock(struct user_lock_res *lockres,
int level,
int lkm_flags);
void user_dlm_cluster_unlock(struct user_lock_res *lockres,
int level);
void user_dlm_write_lvb(struct inode *inode,
const char *val,
unsigned int len);
void user_dlm_read_lvb(struct inode *inode,
char *val,
unsigned int len);
struct dlm_ctxt *user_dlm_register_context(struct qstr *name,
struct dlm_protocol_version *proto);
void user_dlm_unregister_context(struct dlm_ctxt *dlm);
struct dlmfs_inode_private {
struct dlm_ctxt *ip_dlm;
struct user_lock_res ip_lockres; /* unused for directories. */
struct inode *ip_parent;
struct inode ip_vfs_inode;
};
static inline struct dlmfs_inode_private *
DLMFS_I(struct inode *inode)
{
return container_of(inode,
struct dlmfs_inode_private,
ip_vfs_inode);
}
struct dlmfs_filp_private {
int fp_lock_level;
};
#define DLMFS_MAGIC 0x76a9f425
#endif /* USERDLM_H */
| 29.473684 | 68 | 0.675298 |
0c3dce85261724fe10f0fc2919db49a7f005974f | 7,215 | h | C | aws-cpp-sdk-cloudfront/include/aws/cloudfront/model/FieldLevelEncryptionProfile.h | neil-b/aws-sdk-cpp | 1602b75abbca880b770c12788f6d2bac0c87176a | [
"Apache-2.0"
] | null | null | null | aws-cpp-sdk-cloudfront/include/aws/cloudfront/model/FieldLevelEncryptionProfile.h | neil-b/aws-sdk-cpp | 1602b75abbca880b770c12788f6d2bac0c87176a | [
"Apache-2.0"
] | null | null | null | aws-cpp-sdk-cloudfront/include/aws/cloudfront/model/FieldLevelEncryptionProfile.h | neil-b/aws-sdk-cpp | 1602b75abbca880b770c12788f6d2bac0c87176a | [
"Apache-2.0"
] | 1 | 2020-11-04T03:18:11.000Z | 2020-11-04T03:18:11.000Z | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/cloudfront/CloudFront_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <aws/core/utils/DateTime.h>
#include <aws/cloudfront/model/FieldLevelEncryptionProfileConfig.h>
#include <utility>
namespace Aws
{
namespace Utils
{
namespace Xml
{
class XmlNode;
} // namespace Xml
} // namespace Utils
namespace CloudFront
{
namespace Model
{
/**
* <p>A complex data type for field-level encryption profiles.</p><p><h3>See
* Also:</h3> <a
* href="http://docs.aws.amazon.com/goto/WebAPI/cloudfront-2019-03-26/FieldLevelEncryptionProfile">AWS
* API Reference</a></p>
*/
class AWS_CLOUDFRONT_API FieldLevelEncryptionProfile
{
public:
FieldLevelEncryptionProfile();
FieldLevelEncryptionProfile(const Aws::Utils::Xml::XmlNode& xmlNode);
FieldLevelEncryptionProfile& operator=(const Aws::Utils::Xml::XmlNode& xmlNode);
void AddToNode(Aws::Utils::Xml::XmlNode& parentNode) const;
/**
* <p>The ID for a field-level encryption profile configuration which includes a
* set of profiles that specify certain selected data fields to be encrypted by
* specific public keys.</p>
*/
inline const Aws::String& GetId() const{ return m_id; }
/**
* <p>The ID for a field-level encryption profile configuration which includes a
* set of profiles that specify certain selected data fields to be encrypted by
* specific public keys.</p>
*/
inline bool IdHasBeenSet() const { return m_idHasBeenSet; }
/**
* <p>The ID for a field-level encryption profile configuration which includes a
* set of profiles that specify certain selected data fields to be encrypted by
* specific public keys.</p>
*/
inline void SetId(const Aws::String& value) { m_idHasBeenSet = true; m_id = value; }
/**
* <p>The ID for a field-level encryption profile configuration which includes a
* set of profiles that specify certain selected data fields to be encrypted by
* specific public keys.</p>
*/
inline void SetId(Aws::String&& value) { m_idHasBeenSet = true; m_id = std::move(value); }
/**
* <p>The ID for a field-level encryption profile configuration which includes a
* set of profiles that specify certain selected data fields to be encrypted by
* specific public keys.</p>
*/
inline void SetId(const char* value) { m_idHasBeenSet = true; m_id.assign(value); }
/**
* <p>The ID for a field-level encryption profile configuration which includes a
* set of profiles that specify certain selected data fields to be encrypted by
* specific public keys.</p>
*/
inline FieldLevelEncryptionProfile& WithId(const Aws::String& value) { SetId(value); return *this;}
/**
* <p>The ID for a field-level encryption profile configuration which includes a
* set of profiles that specify certain selected data fields to be encrypted by
* specific public keys.</p>
*/
inline FieldLevelEncryptionProfile& WithId(Aws::String&& value) { SetId(std::move(value)); return *this;}
/**
* <p>The ID for a field-level encryption profile configuration which includes a
* set of profiles that specify certain selected data fields to be encrypted by
* specific public keys.</p>
*/
inline FieldLevelEncryptionProfile& WithId(const char* value) { SetId(value); return *this;}
/**
* <p>The last time the field-level encryption profile was updated.</p>
*/
inline const Aws::Utils::DateTime& GetLastModifiedTime() const{ return m_lastModifiedTime; }
/**
* <p>The last time the field-level encryption profile was updated.</p>
*/
inline bool LastModifiedTimeHasBeenSet() const { return m_lastModifiedTimeHasBeenSet; }
/**
* <p>The last time the field-level encryption profile was updated.</p>
*/
inline void SetLastModifiedTime(const Aws::Utils::DateTime& value) { m_lastModifiedTimeHasBeenSet = true; m_lastModifiedTime = value; }
/**
* <p>The last time the field-level encryption profile was updated.</p>
*/
inline void SetLastModifiedTime(Aws::Utils::DateTime&& value) { m_lastModifiedTimeHasBeenSet = true; m_lastModifiedTime = std::move(value); }
/**
* <p>The last time the field-level encryption profile was updated.</p>
*/
inline FieldLevelEncryptionProfile& WithLastModifiedTime(const Aws::Utils::DateTime& value) { SetLastModifiedTime(value); return *this;}
/**
* <p>The last time the field-level encryption profile was updated.</p>
*/
inline FieldLevelEncryptionProfile& WithLastModifiedTime(Aws::Utils::DateTime&& value) { SetLastModifiedTime(std::move(value)); return *this;}
/**
* <p>A complex data type that includes the profile name and the encryption
* entities for the field-level encryption profile.</p>
*/
inline const FieldLevelEncryptionProfileConfig& GetFieldLevelEncryptionProfileConfig() const{ return m_fieldLevelEncryptionProfileConfig; }
/**
* <p>A complex data type that includes the profile name and the encryption
* entities for the field-level encryption profile.</p>
*/
inline bool FieldLevelEncryptionProfileConfigHasBeenSet() const { return m_fieldLevelEncryptionProfileConfigHasBeenSet; }
/**
* <p>A complex data type that includes the profile name and the encryption
* entities for the field-level encryption profile.</p>
*/
inline void SetFieldLevelEncryptionProfileConfig(const FieldLevelEncryptionProfileConfig& value) { m_fieldLevelEncryptionProfileConfigHasBeenSet = true; m_fieldLevelEncryptionProfileConfig = value; }
/**
* <p>A complex data type that includes the profile name and the encryption
* entities for the field-level encryption profile.</p>
*/
inline void SetFieldLevelEncryptionProfileConfig(FieldLevelEncryptionProfileConfig&& value) { m_fieldLevelEncryptionProfileConfigHasBeenSet = true; m_fieldLevelEncryptionProfileConfig = std::move(value); }
/**
* <p>A complex data type that includes the profile name and the encryption
* entities for the field-level encryption profile.</p>
*/
inline FieldLevelEncryptionProfile& WithFieldLevelEncryptionProfileConfig(const FieldLevelEncryptionProfileConfig& value) { SetFieldLevelEncryptionProfileConfig(value); return *this;}
/**
* <p>A complex data type that includes the profile name and the encryption
* entities for the field-level encryption profile.</p>
*/
inline FieldLevelEncryptionProfile& WithFieldLevelEncryptionProfileConfig(FieldLevelEncryptionProfileConfig&& value) { SetFieldLevelEncryptionProfileConfig(std::move(value)); return *this;}
private:
Aws::String m_id;
bool m_idHasBeenSet;
Aws::Utils::DateTime m_lastModifiedTime;
bool m_lastModifiedTimeHasBeenSet;
FieldLevelEncryptionProfileConfig m_fieldLevelEncryptionProfileConfig;
bool m_fieldLevelEncryptionProfileConfigHasBeenSet;
};
} // namespace Model
} // namespace CloudFront
} // namespace Aws
| 39.642857 | 209 | 0.718087 |
0c3f2faac1c0b466c47ebfef70c689ee79ceb911 | 1,775 | h | C | OrbitLinuxTracing/ContextSwitchManager.h | karupayun/orbit | 12e12f3125588c0318c2a3788a69f8b706cd1bdc | [
"BSD-2-Clause"
] | null | null | null | OrbitLinuxTracing/ContextSwitchManager.h | karupayun/orbit | 12e12f3125588c0318c2a3788a69f8b706cd1bdc | [
"BSD-2-Clause"
] | null | null | null | OrbitLinuxTracing/ContextSwitchManager.h | karupayun/orbit | 12e12f3125588c0318c2a3788a69f8b706cd1bdc | [
"BSD-2-Clause"
] | null | null | null | // Copyright (c) 2020 The Orbit Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ORBIT_LINUX_TRACING_CONTEXT_SWITCH_MANAGER_H_
#define ORBIT_LINUX_TRACING_CONTEXT_SWITCH_MANAGER_H_
#include <OrbitBase/Logging.h>
#include <OrbitLinuxTracing/Events.h>
#include "absl/container/flat_hash_map.h"
namespace LinuxTracing {
// For each core, keeps the last context switch into a process and matches it
// with the next context switch away from a process to produce SchedulingSlice
// events. It assumes that context switches for the same core come in order.
class ContextSwitchManager {
public:
ContextSwitchManager() = default;
ContextSwitchManager(const ContextSwitchManager&) = delete;
ContextSwitchManager& operator=(const ContextSwitchManager&) = delete;
ContextSwitchManager(ContextSwitchManager&&) = default;
ContextSwitchManager& operator=(ContextSwitchManager&&) = default;
void ProcessContextSwitchIn(pid_t pid, pid_t tid, uint16_t core,
uint64_t timestamp_ns);
std::optional<SchedulingSlice> ProcessContextSwitchOut(pid_t pid, pid_t tid,
uint16_t core,
uint64_t timestamp_ns);
void Clear() { open_switches_by_core_.clear(); }
private:
struct OpenSwitchIn {
OpenSwitchIn(pid_t pid, pid_t tid, uint64_t timestamp_ns)
: pid(pid), tid(tid), timestamp_ns(timestamp_ns) {}
pid_t pid;
pid_t tid;
uint64_t timestamp_ns;
};
absl::flat_hash_map<uint16_t, OpenSwitchIn> open_switches_by_core_;
};
} // namespace LinuxTracing
#endif // ORBIT_LINUX_TRACING_CONTEXT_SWITCH_MANAGER_H_
| 34.134615 | 80 | 0.715493 |
0c417cde6ccd94a21750d608b6365ae51c9bfc11 | 183 | h | C | www/src/ios/CsIPay88.h | shivasakte92/ionic-frontend | d3d519e769e92c7f176518c6e5a5f742b1bdafdb | [
"MIT"
] | null | null | null | www/src/ios/CsIPay88.h | shivasakte92/ionic-frontend | d3d519e769e92c7f176518c6e5a5f742b1bdafdb | [
"MIT"
] | null | null | null | www/src/ios/CsIPay88.h | shivasakte92/ionic-frontend | d3d519e769e92c7f176518c6e5a5f742b1bdafdb | [
"MIT"
] | null | null | null | #import <Cordova/CDV.h>
#import "Ipay.h"
#import "IpayPayment.h"
@interface CsIPay88 : CDVPlugin <PaymentResultDelegate>
- (void) makepayment: (CDVInvokedUrlCommand*)command;
@end
| 18.3 | 55 | 0.754098 |
0c41cd94dc1950ae4fd12be05b968b20fc847852 | 3,360 | h | C | chat-uikit/Classes/Common/EaseKitDefine.h | AgoraIO-Usecase/AgoraChat-UIKit-ios | 7b9833e2f015bf1ca941bc86fbdfea428fe29f1f | [
"MIT"
] | null | null | null | chat-uikit/Classes/Common/EaseKitDefine.h | AgoraIO-Usecase/AgoraChat-UIKit-ios | 7b9833e2f015bf1ca941bc86fbdfea428fe29f1f | [
"MIT"
] | 1 | 2022-03-22T05:58:59.000Z | 2022-03-22T05:58:59.000Z | chat-uikit/Classes/Common/EaseKitDefine.h | AgoraIO-Usecase/AgoraChat-UIKit-ios | 7b9833e2f015bf1ca941bc86fbdfea428fe29f1f | [
"MIT"
] | 8 | 2022-01-13T07:00:47.000Z | 2022-03-14T03:03:08.000Z | //
// EaseKitDefine.h
// Pods
//
// Created by liu001 on 2022/5/12.
//
#ifndef EaseKitDefine_h
#define EaseKitDefine_h
#define kIsBangsScreen ({\
BOOL isBangsScreen = NO; \
if (@available(iOS 11.0, *)) { \
UIWindow *window = [[UIApplication sharedApplication].windows firstObject]; \
isBangsScreen = window.safeAreaInsets.bottom > 0; \
} \
isBangsScreen; \
})
#define EaseKitVIEWTOPMARGIN (kIsBangsScreen ? 34.f : 0.f)
#define EaseKitScreenHeight [[UIScreen mainScreen] bounds].size.height
#define EaseKitScreenWidth [[UIScreen mainScreen] bounds].size.width
#define EaseKitIs_iphone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define EaseKitIs_iPhoneX EaseKitScreenWidth >=375.0f && EaseKitScreenHeight >=812.0f&& EaseKitIs_iphone
#define EaseKitStatusBarHeight (CGFloat)(EaseKitIs_iPhoneX?(44.0):(20.0))
#define EaseKitNavBarHeight (44)
#define EaseKitNavBarAndStatusBarHeight (CGFloat)(EaseKitIs_iPhoneX?(88.0):(64.0))
#define EaseKitTabBarHeight (CGFloat)(EaseKitIs_iPhoneX?(49.0 + 34.0):(49.0))
#define EaseKitTopBarSafeHeight (CGFloat)(EaseKitIs_iPhoneX?(44.0):(0))
#define EaseKitBottomSafeHeight (CGFloat)(EaseKitIs_iPhoneX?(34.0):(0))
#define EaseKitTopBarDifHeight (CGFloat)(EaseKitIs_iPhoneX?(24.0):(0))
#define EaseKitNavAndTabHeight (EaseKitNavBarAndStatusBarHeight + EaseKitTabBarHeight)
#define EaseKitScreenHeight [[UIScreen mainScreen] bounds].size.height
#define EaseKitScreenWidth [[UIScreen mainScreen] bounds].size.width
#define EaseKitRGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)]
// rgb颜色转换(16进制->10进制)
#define EaseKitCOLOR_HEXA(__RGB,__ALPHA) [UIColor colorWithRed:((float)((__RGB & 0xFF0000) >> 16))/255.0 green:((float)((__RGB & 0xFF00) >> 8))/255.0 blue:((float)(__RGB & 0xFF))/255.0 alpha:__ALPHA]
#define EaseKitCOLOR_HEX(__RGB) EaseKitCOLOR_HEXA(__RGB,1.0f)
//weak & strong self
#define EaseKit_WS __weak __typeof(&*self)weakSelf = self;
#define EaseKit_SS(WKSELF) __strong __typeof(&*self)strongSelf = WKSELF;
#define EaseKit_ONE_PX (1.0f / [UIScreen mainScreen].scale)
#define EaseKitImageWithName(imageName) [UIImage imageNamed:imageName]
#define EaseKitPadding 10.0f
//fonts
#define EaseKitNFont(__SIZE) [UIFont systemFontOfSize:__SIZE] //system font with size
#define EaseKitIFont(__SIZE) [UIFont italicSystemFontOfSize:__SIZE] //system font with size
#define EaseKitBFont(__SIZE) [UIFont boldSystemFontOfSize:__SIZE]//system bold font with size
#define EaseKitFont(__NAME, __SIZE) [UIFont fontWithName:__NAME size:__SIZE] //font with name and size
#define EaseKitTextLabelGrayColor EaseKitCOLOR_HEX(0x999999)
#define EaseKitDefaultSystemLightGrayColor EaseKitRGBACOLOR(197, 197, 197, 1)
#define EaseKitDefaultSystemTextGrayColor EaseKitRGBACOLOR(197, 197, 197, 1)
#define EaseKitDefaultSystemTextColor EaseKitRGBACOLOR(38, 38, 38, 1)
#define EaseKitDefaultSystemBgColor EaseKitRGBACOLOR(51, 51, 51, 1)
#define EaseKitDefaultSystemLightGrayColor EaseKitRGBACOLOR(197, 197, 197, 1)
#define EaseKitDefaultLoginButtonColor EaseKitRGBACOLOR(25, 163, 255, 1)
#define EaseKitBlackAlphaColor [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4]
#define EaseKitWhiteAlphaColor [UIColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.74]
#endif /* EaseKitDefine_h */
| 39.529412 | 199 | 0.76994 |
0c422f795b107a46c8198f73fb3c388f67b2a04e | 2,820 | h | C | drivers/muic/universal/muic_vps.h | CaelestisZ/IrisCore | 6f0397e43335434ee58e418c9d1528833c57aea2 | [
"MIT"
] | 1 | 2020-06-28T00:49:21.000Z | 2020-06-28T00:49:21.000Z | drivers/muic/universal/muic_vps.h | CaelestisZ/AetherAura | 1b30acb7e6921042722bc4aff160dc63a975abc2 | [
"MIT"
] | null | null | null | drivers/muic/universal/muic_vps.h | CaelestisZ/AetherAura | 1b30acb7e6921042722bc4aff160dc63a975abc2 | [
"MIT"
] | 4 | 2020-05-26T12:40:11.000Z | 2021-07-15T06:46:33.000Z | #ifndef _MUIC_VPS_H_
#define _MUIC_VPS_H_
/* MUIC Output of USB Charger Detection */
typedef enum {
/* No Valid voltage at VB (Vvb < Vvbdet) */
CHGTYP_NO_VOLTAGE = 0x00,
/* Unknown (D+/D- does not present a valid USB charger signature) */
CHGTYP_USB = 0x01,
/* Charging Downstream Port */
CHGTYP_CDP = 0x02,
/* Dedicated Charger (D+/D- shorted) */
CHGTYP_DEDICATED_CHARGER = 0x03,
/* Special 500mA charger, max current 500mA */
CHGTYP_500MA = 0x04,
/* Special 1A charger, max current 1A */
CHGTYP_1A = 0x05,
/* Special charger - 3.3V bias on D+/D- */
CHGTYP_SPECIAL_3_3V_CHARGER = 0x06,
/* Reserved */
CHGTYP_RFU = 0x07,
/* Any charger w/o USB */
CHGTYP_UNOFFICIAL_CHARGER = 0xfc,
/* Any charger type */
CHGTYP_ANY = 0xfd,
/* Don't care charger type */
CHGTYP_DONTCARE = 0xfe,
CHGTYP_MAX,
CHGTYP_INIT,
CHGTYP_MIN = CHGTYP_NO_VOLTAGE
} chgtyp_t;
#define MDEV(name) ATTACHED_DEV_##name##_MUIC
/*
* VPS attribute field.
b'xxxxxxxx_xxxxxxx_xxxx_xxfs_cccc_vvvv
x: undefined
f: factory device
s: supported
c: com port
v: vbus
*/
#define VPS_CHGDET_BITN 10
#define VPS_FAC_BITN 9
#define VPS_SUP_BITN 8
#define VPS_COM_BITN 4
#define VPS_VBUS_BITN 0
#define VPS_CHGDET_MASK 0x1
#define VPS_FAC_MASK 0x1
#define VPS_SUP_MASK 0x1
#define VPS_COM_MASK 0xF
#define VPS_VBUS_MASK 0xF
#define MATTR(com,vbus) \
(com << VPS_COM_BITN) | \
(vbus << VPS_VBUS_BITN)
#define MATTR_TO_VBUS(a) ((a >> VPS_VBUS_BITN) & VPS_VBUS_MASK)
#define MATTR_TO_COM(a) ((a >> VPS_COM_BITN) & VPS_COM_MASK)
#define MATTR_TO_FACT(a) ((a >> VPS_FAC_BITN) & VPS_FAC_MASK)
#define MATTR_TO_SUPP(a) ((a >> VPS_SUP_BITN) & VPS_SUP_MASK)
#define MATTR_TO_CDET(a) ((a >> VPS_CHGDET_BITN) & VPS_CHGDET_MASK)
#define MATTR_CDET (1 << VPS_CHGDET_BITN)
#define MATTR_SUPP (1 << VPS_SUP_BITN)
#define MATTR_FACT (1 << VPS_FAC_BITN)
#define MATTR_CDET_SUPP ((1 << VPS_CHGDET_BITN) | MATTR_SUPP)
#define MATTR_FACT_SUPP ((1 << VPS_FAC_BITN) | MATTR_SUPP)
enum vps_vbvolt{
VB_LOW = 0,
VB_HIGH = 1,
VB_CHK = 2,
VB_ANY = 3,
};
enum vps_com{
VCOM_OPEN = COM_OPEN_WITH_V_BUS,
VCOM_USB = COM_USB_AP,
VCOM_AUDIO = COM_AUDIO,
VCOM_UART = COM_UART_AP,
VCOM_USB_CP = COM_USB_CP,
VCOM_UART_CP = COM_UART_CP,
};
struct vps_cfg {
char *name;
int attr;
};
struct vps_tbl_data {
u8 adc;
char *rid;
struct vps_cfg *cfg;
};
extern bool vps_name_to_mdev(const char *name, int *sdev);
extern void vps_update_supported_attr(muic_attached_dev_t mdev, bool supported);
extern bool vps_is_supported_dev(muic_attached_dev_t mdev);
extern int vps_find_attached_dev(muic_data_t *pmuic, muic_attached_dev_t *pdev, int *pintr);
extern void vps_show_table(void);
extern void vps_show_supported_list(void);
extern int vps_resolve_dev(muic_data_t *pmuic, muic_attached_dev_t *pbuf, int *pintr);
#endif
| 26.35514 | 92 | 0.732624 |
0c429c1f99f2be673a0768f09e2de191285f34b8 | 4,300 | h | C | ZMClass/mp_framework/mpsdk_remotemanagement.framework/Headers/RemoteManagementCommand.h | zziazm/ZMClass | 096bf05660ea937a4c5f321313f495c882fc4afb | [
"MIT"
] | null | null | null | ZMClass/mp_framework/mpsdk_remotemanagement.framework/Headers/RemoteManagementCommand.h | zziazm/ZMClass | 096bf05660ea937a4c5f321313f495c882fc4afb | [
"MIT"
] | null | null | null | ZMClass/mp_framework/mpsdk_remotemanagement.framework/Headers/RemoteManagementCommand.h | zziazm/ZMClass | 096bf05660ea937a4c5f321313f495c882fc4afb | [
"MIT"
] | null | null | null | /**
* Copyright (c) 2018, MasterCard International Incorporated and/or its
* affiliates. All rights reserved.
*
* The contents of this file may only be used subject to the MasterCard
* Mobile Payment SDK for MCBP and/or MasterCard Mobile MPP UI SDK
* Materials License.
*
* Please refer to the file LICENSE.TXT for full details.
*
* TO THE EXTENT PERMITTED BY LAW, 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
* NON INFRINGEMENT. TO THE EXTENT PERMITTED BY LAW, IN NO EVENT SHALL
* MASTERCARD OR ITS AFFILIATES 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.
**/
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from RemoteManagementCommand.djinni
#import "mpsdk_remotemanagement/CommandFailureAction.h"
#import "mpsdk_remotemanagement/CommandStatus.h"
#import "mpsdk_remotemanagement/CommandSuccessAction.h"
#import "mpsdk_componentinterface/HttpMethod.h"
#import "mpsdk_remotemanagement/CommandSuccessAction.h"
#import "mpsdk_remotemanagement/CommandFailureAction.h"
#import "mpsdk_remotemanagement/CommandStatus.h"
#import "mpsdk_componentinterface/HttpMethod.h"
#import <Foundation/Foundation.h>
@class CmsDRequest;
@class CmsDRequest;
/**
* Auto-generated Djinni interface for ::mpsdk::remotemanagement::commands::RemoteManagementCommand_t
*
* Represents a remote management command that can be sent to the CMS-D
*
*/
@interface RemoteManagementCommand : NSObject
- (id _Nonnull)init;
/**
*
* Retrieve the unique request Id for this command
* @returns the unique request Id
*
*/
- (NSString* _Nonnull)getRequestId;
/**
*
* Executes the command
*
*/
- (void)execute;
/**
*
* Cancels the execution of the command
*
*/
- (void)cancel;
/**
*
* Retrieves the Http Method of this command
* @returns the http error
*
*/
- (HttpMethod)getHttpMethod;
/**
*
* Encrypts the request using the transport key as
* @param requestJson the json representation of the request
* @returns the protected request, ready to be sent
*
*/
- (CmsDRequest* _Nonnull)encryptRequest:(NSString* _Nonnull)requestJson;
/**
*
* Executes the request
* @param requestJson the JSON request data ready to be sent
*
*/
- (void)executeRequest:(NSString* _Nullable)requestJson;
/**
*
* Indicates whether or not the command was successfully completed, or if there was an error
* @returns true if the command was successful, false otherwise
*
*/
- (CommandStatus)getStatus;
/**
*
* If the command has failed, this method should return an appropriate action to perform
* @returns the recommended action to perform in the case of failure
*
*/
- (CommandFailureAction)getRecommendedCommandFailureAction;
/**
*
* If the command has been successful, this method should return an appropriate action to perform
* @returns the recommended action to perform in the case of success
*
*/
- (CommandSuccessAction)getRecommendedCommandSuccessAction;
/**
*
* If the command fails, contains the error code
* @returns the error code
*
*/
- (NSString* _Nullable)getErrorCode;
/**
*
* Any command for which the CMS-D must be contacted in order to retrieve the status must
* allow the task ID to be retrieved in order to be used with GetTaskStatus
* @returns the task ID assigned when the command was created
*
*/
- (NSString* _Nullable)getTaskId;
/**
*
* Set the number of retires remaining
* @param retriesRemaining The number of retries remaining
*
*/
- (void)setRetriesRemaining:(int32_t)retriesRemaining;
/**
*
* Gets the milli seconds delay in retry attempt
* @returns time in milli seconds
*
*/
- (int32_t)getCurrentRetryInterval;
/**
*
* Set the command status of the command
* @param commandStatus The command's new status
*
*/
- (void)setCommandStatus:(CommandStatus)commandStatus;
/**
*
* Retrieve the URL used for this command
*
* @return the URL used for this command
*
*/
- (NSString* _Nonnull)getCommandUrl;
- (BOOL)isSessionRequired;
@end
| 25.146199 | 101 | 0.734651 |
0c4304066cdbc6526204cfce3d82798c137ec50e | 981 | h | C | GoogleWifi Headers/TAGPBEnumOptions.h | LemaMichael/BetterGoogleWifi | b02a0adc35d80f1fa9443874d12de483c3d63c06 | [
"MIT"
] | 1 | 2022-01-25T13:08:30.000Z | 2022-01-25T13:08:30.000Z | GoogleWifi Headers/TAGPBEnumOptions.h | LemaMichael/BetterGoogleWifi | b02a0adc35d80f1fa9443874d12de483c3d63c06 | [
"MIT"
] | null | null | null | GoogleWifi Headers/TAGPBEnumOptions.h | LemaMichael/BetterGoogleWifi | b02a0adc35d80f1fa9443874d12de483c3d63c06 | [
"MIT"
] | null | null | null | //
// 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 "TAGPBGeneratedMessage.h"
@class NSString, TAGPBMutableArray;
@interface TAGPBEnumOptions : TAGPBGeneratedMessage
{
}
+ (id)descriptor;
// Remaining properties
@property(nonatomic) _Bool allowAlias; // @dynamic allowAlias;
@property(nonatomic) _Bool deprecated; // @dynamic deprecated;
@property(nonatomic) _Bool hasAllowAlias; // @dynamic hasAllowAlias;
@property(nonatomic) _Bool hasDeprecated; // @dynamic hasDeprecated;
@property(nonatomic) _Bool hasProto1Name; // @dynamic hasProto1Name;
@property(nonatomic) _Bool hasUninterpretedOptionArray; // @dynamic hasUninterpretedOptionArray;
@property(retain, nonatomic) NSString *proto1Name; // @dynamic proto1Name;
@property(retain, nonatomic) TAGPBMutableArray *uninterpretedOptionArray; // @dynamic uninterpretedOptionArray;
@end
| 33.827586 | 111 | 0.771662 |
0c432a88d5da374b79505724744689f57c2edf95 | 1,975 | h | C | src/extras/MIMEInfo.h | xiaolaba/ESP-Mail-Client_SD_MMC_workaround | 26de8565b7f0b0f4e3cdfcf652ac07a5245a383d | [
"MIT"
] | 85 | 2020-12-03T21:00:27.000Z | 2022-03-31T13:43:57.000Z | src/extras/MIMEInfo.h | noorhaq/ESP-Mail-Client | 379c793e5e76871bc9a7d332c8083a63ba1aa9a5 | [
"MIT"
] | 70 | 2020-12-08T11:41:11.000Z | 2022-03-24T15:16:20.000Z | src/extras/MIMEInfo.h | noorhaq/ESP-Mail-Client | 379c793e5e76871bc9a7d332c8083a63ba1aa9a5 | [
"MIT"
] | 26 | 2020-12-10T08:30:16.000Z | 2022-03-08T14:39:39.000Z | #ifndef MIMEInfo_H
#define MIMEInfo_H
#include <Arduino.h>
enum esp_mail_file_extension
{
esp_mail_file_extension_html,
esp_mail_file_extension_htm,
esp_mail_file_extension_css,
esp_mail_file_extension_txt,
esp_mail_file_extension_js,
esp_mail_file_extension_json,
esp_mail_file_extension_png,
esp_mail_file_extension_gif,
esp_mail_file_extension_jpg,
esp_mail_file_extension_ico,
esp_mail_file_extension_svg,
esp_mail_file_extension_ttf,
esp_mail_file_extension_otf,
esp_mail_file_extension_woff,
esp_mail_file_extension_woff2,
esp_mail_file_extension_eot,
esp_mail_file_extension_sfnt,
esp_mail_file_extension_xml,
esp_mail_file_extension_pdf,
esp_mail_file_extension_zip,
esp_mail_file_extension_gz,
esp_mail_file_extension_appcache,
esp_mail_file_extension_none,
esp_mail_file_extension_maxType
};
struct esp_mail_mime_prop_t
{
char endsWith[10];
char mimeType[50];
};
const struct esp_mail_mime_prop_t mimeinfo[esp_mail_file_extension_maxType] PROGMEM =
{
{".html", "text/html"},
{".htm", "text/html"},
{".css", "text/css"},
{".txt", "text/plain"},
{".js", "application/javascript"},
{".json", "application/json"},
{".png", "image/png"},
{".gif", "image/gif"},
{".jpg", "image/jpeg"},
{".ico", "image/x-icon"},
{".svg", "image/svg+xml"},
{".ttf", "application/x-font-ttf"},
{".otf", "application/x-font-opentype"},
{".woff", "application/font-woff"},
{".woff2", "application/font-woff2"},
{".eot", "application/vnd.ms-fontobject"},
{".sfnt", "application/font-sfnt"},
{".xml", "text/xml"},
{".pdf", "application/pdf"},
{".zip", "application/zip"},
{".gz", "application/x-gzip"},
{".appcache", "text/cache-manifest"},
{"", "application/octet-stream"}};
#endif
| 29.924242 | 86 | 0.647089 |
0c435b7a0db9c24ad0a99a788e93ce2331fccdf6 | 65,627 | c | C | dk_apps/src/ip/ble/hl/src/profiles/lan/lans/lans_task.c | troye-wangshan/testing | 4a896546b22500633033ae1735ca37e53329aa75 | [
"CC-BY-3.0"
] | null | null | null | dk_apps/src/ip/ble/hl/src/profiles/lan/lans/lans_task.c | troye-wangshan/testing | 4a896546b22500633033ae1735ca37e53329aa75 | [
"CC-BY-3.0"
] | null | null | null | dk_apps/src/ip/ble/hl/src/profiles/lan/lans/lans_task.c | troye-wangshan/testing | 4a896546b22500633033ae1735ca37e53329aa75 | [
"CC-BY-3.0"
] | null | null | null | /**
****************************************************************************************
*
* @file lans_task.c
*
* @brief Location and Navigation Profile Sensor Task Implementation.
*
* Copyright (C) RivieraWaves 2009-2014
*
* $ Rev $
*
****************************************************************************************
*/
/**
****************************************************************************************
* @addtogroup LANSTASK
* @{
****************************************************************************************
*/
/*
* INCLUDE FILES
****************************************************************************************
*/
#include "lan_common.h"
#if (BLE_LN_SENSOR)
#include "gapc.h"
#include "gattc.h"
#include "gattc_task.h"
#include "atts_util.h"
#include "attm_util.h"
#include "lans.h"
#include "lans_task.h"
#include "prf_utils.h"
#include <math.h>
/*
* CYCLING POWER SERVICE ATTRIBUTES
****************************************************************************************
*/
/// Location and Navigation Sensor Service
static const att_svc_desc_t lans_lns_svc = ATT_SVC_LOCATION_AND_NAVIGATION;
/// LN Feature characteristic value
static const struct att_char_desc lans_ln_feat_char = ATT_CHAR(ATT_CHAR_PROP_RD,
LANP_LANS_LN_FEAT_CHAR,
ATT_CHAR_LN_FEAT);
/// Location and Speed characteristic value
static const struct att_char_desc lans_loc_speed_char = ATT_CHAR(ATT_CHAR_PROP_NTF,
LANP_LANS_LOC_SPEED_CHAR,
ATT_CHAR_LOC_SPEED);
/// Position quality characteristic value
static const struct att_char_desc lans_pos_q_char = ATT_CHAR(ATT_CHAR_PROP_RD,
LANP_LANS_POS_Q_CHAR,
ATT_CHAR_POS_QUALITY);
/// LN Control Point characteristic value
static const struct att_char_desc lans_ln_ctnl_pt_char = ATT_CHAR(ATT_CHAR_PROP_WR | ATT_CHAR_PROP_IND,
LANP_LANS_LN_CTNL_PT_CHAR,
ATT_CHAR_LN_CNTL_PT);
/// Navigation
static const struct att_char_desc lans_navigation_char = ATT_CHAR(ATT_CHAR_PROP_NTF,
LANP_LANS_NAVIG_CHAR,
ATT_CHAR_NAVIGATION);
/// Full LANS Database Description - Used to add attributes into the database
static const struct attm_desc lans_att_db[LNS_IDX_NB] =
{
/// Location and Navigation Service Declaration
[LNS_IDX_SVC] = {ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), sizeof(lans_lns_svc),
sizeof(lans_lns_svc), (uint8_t *)&lans_lns_svc},
/// LN Feature Characteristic Declaration
[LNS_IDX_LN_FEAT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), sizeof(lans_ln_feat_char),
sizeof(lans_ln_feat_char), (uint8_t *)&lans_ln_feat_char},
/// LN Feature Characteristic Value
[LNS_IDX_LN_FEAT_VAL] = {ATT_CHAR_LN_FEAT, PERM(RD, ENABLE), sizeof(uint32_t),
0, NULL},
/// Location and Speed Characteristic Declaration
[LNS_IDX_LOC_SPEED_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), sizeof(lans_loc_speed_char),
sizeof(lans_loc_speed_char), (uint8_t *)&lans_loc_speed_char},
/// Location and Speed Characteristic Value
[LNS_IDX_LOC_SPEED_VAL] = {ATT_CHAR_LOC_SPEED, PERM(NTF, ENABLE), LANP_LAN_LOC_SPEED_MAX_LEN,
0, NULL},
/// Location and Speed Characteristic - Client Characteristic Configuration Descriptor
[LNS_IDX_LOC_SPEED_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WR, ENABLE), sizeof(uint16_t),
0, NULL},
/// Position Quality Characteristic Declaration
[LNS_IDX_POS_Q_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), sizeof(lans_pos_q_char),
sizeof(lans_pos_q_char), (uint8_t *)&lans_pos_q_char},
/// Position Quality Characteristic Value
[LNS_IDX_POS_Q_VAL] = {ATT_CHAR_POS_QUALITY, PERM(RD, ENABLE), LANP_LAN_POSQ_MAX_LEN,
0, NULL},
/// LN Control Point Characteristic Declaration
[LNS_IDX_LN_CTNL_PT_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), sizeof(lans_ln_ctnl_pt_char),
sizeof(lans_ln_ctnl_pt_char), (uint8_t *)&lans_ln_ctnl_pt_char},
/// LN Control Point Characteristic Value - The response has the maximal length
[LNS_IDX_LN_CTNL_PT_VAL] = {ATT_CHAR_LN_CNTL_PT, PERM(WR, ENABLE) | PERM(IND, ENABLE), LANP_LAN_LN_CNTL_PT_RSP_MAX_LEN,
0, NULL},
/// LN Control Point Characteristic - Client Characteristic Configuration Descriptor
[LNS_IDX_LN_CTNL_PT_IND_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WR, ENABLE), sizeof(uint16_t),
0, NULL},
/// Navigation Characteristic Declaration
[LNS_IDX_NAVIGATION_CHAR] = {ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE), sizeof(lans_navigation_char),
sizeof(lans_navigation_char), (uint8_t *)&lans_navigation_char},
/// Navigation Characteristic Value
[LNS_IDX_NAVIGATION_VAL] = {ATT_CHAR_NAVIGATION, PERM(NTF, ENABLE), LANP_LAN_NAVIGATION_MAX_LEN,
0, NULL},
/// Navigation Characteristic - Client Characteristic Configuration Descriptor
[LNS_IDX_NAVIGATION_NTF_CFG] = {ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE) | PERM(WR, ENABLE), sizeof(uint16_t),
0, NULL},
};
/*
* LOCAL FUNCTIONS DEFINITIONS
****************************************************************************************
*/
/**
****************************************************************************************
* @brief Packs location and speed notifications
* @param[in] param Pointer to the parameters of the message.
* @param[out] pckd_loc_speed pointer to packed message
* @return status of the operation
****************************************************************************************
*/
static uint8_t lans_pack_loc_speed_ntf(struct lans_ntf_loc_speed_cmd *param, uint8_t *pckd_loc_speed)
{
// Packed Measurement length
uint8_t pckd_loc_speed_len = LANP_LAN_LOC_SPEED_MIN_LEN;
// Check provided flags
if (LANS_IS_PRESENT(param->parameters.flags, LANP_LSPEED_INST_SPEED_PRESENT))
{
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_INSTANTANEOUS_SPEED_SUPP))
{
//Pack instantaneous speed
co_write16p(&pckd_loc_speed[pckd_loc_speed_len], param->parameters.inst_speed);
pckd_loc_speed_len += 2;
}
else //Not supported by the profile
{
//Force to not supported
param->parameters.flags &= ~LANP_LSPEED_INST_SPEED_PRESENT;
}
}
if (LANS_IS_PRESENT(param->parameters.flags, LANP_LSPEED_TOTAL_DISTANCE_PRESENT))
{
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_TOTAL_DISTANCE_SUPP))
{
//Pack total distance (24bits)
co_write24p(&pckd_loc_speed[pckd_loc_speed_len], param->parameters.total_dist);
pckd_loc_speed_len += 3;
}
else //Not supported by the profile
{
//Force to not supported
param->parameters.flags &= ~LANP_LSPEED_TOTAL_DISTANCE_PRESENT;
}
}
if (LANS_IS_PRESENT(param->parameters.flags, LANP_LSPEED_LOCATION_PRESENT))
{
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_LOCATION_SUPP))
{
//Pack Location
co_write32p(&pckd_loc_speed[pckd_loc_speed_len], param->parameters.latitude);
pckd_loc_speed_len += 4;
co_write32p(&pckd_loc_speed[pckd_loc_speed_len], param->parameters.longitude);
pckd_loc_speed_len += 4;
}
else //Not supported by the profile
{
//Force to not supported
param->parameters.flags &= ~LANP_LSPEED_LOCATION_PRESENT;
}
}
if (LANS_IS_PRESENT(param->parameters.flags, LANP_LSPEED_ELEVATION_PRESENT))
{
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_ELEVATION_SUPP))
{
//Pack elevation (24 bits)
co_write24p(&pckd_loc_speed[pckd_loc_speed_len], param->parameters.elevation);
pckd_loc_speed_len += 3;
}
else //Not supported by the profile
{
//Force to not supported
param->parameters.flags &= ~LANP_LSPEED_ELEVATION_PRESENT;
}
}
if (LANS_IS_PRESENT(param->parameters.flags, LANP_LSPEED_HEADING_PRESENT))
{
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_HEADING_SUPP))
{
//Pack Extreme Force Magnitudes (Maximum Force Magnitude & Minimum Force Magnitude)
co_write16p(&pckd_loc_speed[pckd_loc_speed_len], param->parameters.heading);
pckd_loc_speed_len += 2;
}
else //Not supported by the profile
{
//Force to not supported
param->parameters.flags &= ~LANP_LSPEED_HEADING_PRESENT;
}
}
if (LANS_IS_PRESENT(param->parameters.flags, LANP_LSPEED_ROLLING_TIME_PRESENT))
{
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_ROLLING_TIME_SUPP))
{
//Pack rolling time
pckd_loc_speed[pckd_loc_speed_len] = param->parameters.rolling_time;
pckd_loc_speed_len++;
}
else //Not supported by the profile
{
//Force to not supported
param->parameters.flags &= ~LANP_LSPEED_ROLLING_TIME_PRESENT;
}
}
if (LANS_IS_PRESENT(param->parameters.flags, LANP_LSPEED_UTC_TIME_PRESENT))
{
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_UTC_TIME_SUPP))
{
// Pack UTC time
pckd_loc_speed_len += prf_pack_date_time(&pckd_loc_speed[pckd_loc_speed_len], &(param->parameters.date_time));
}
else //Not supported by the profile
{
//Force to not supported
param->parameters.flags &= ~LANP_LSPEED_UTC_TIME_PRESENT;
}
}
// Force the unused bits of the flag value to 0
// param->parameters.flags &= LANP_LSPEED_ALL_PRESENT;
// Flags value
co_write16p(&pckd_loc_speed[0], param->parameters.flags);
return pckd_loc_speed_len;
}
/**
****************************************************************************************
* @brief Splits notifications in order to be sent with default MTU
* @param[in] pckd_locspeed packed message
* @param[out] ntf1 first packed notification
* @param[out] len1 length of the first notification
* @param[out] ntf2 second packed notification
* @param[out] len2 length of the second notification
* @return status of the operation
****************************************************************************************
*/
static uint8_t lans_split_loc_speed_ntf(uint8_t *pckd_locspeed, uint8_t *ntf1, uint8_t *len1, uint8_t *ntf2, uint8_t *len2)
{
uint16_t flags = co_read16p(&pckd_locspeed[0]), flags_cp;
uint8_t pckd_meas_idx = LANP_LAN_LOC_SPEED_MIN_LEN, len = 0;
// Initialize parameters
uint8_t *buff_copy_pt = ntf1;
uint8_t *len_copy_pt = len1;
lans_env.ntf_len = LANP_LAN_LOC_SPEED_MIN_LEN;
// Copy status flags
co_write16p(&ntf1[0], (flags & (LANP_LSPEED_POSITION_STATUS_LSB |
LANP_LSPEED_POSITION_STATUS_MSB |
LANP_LSPEED_SPEED_AND_DISTANCE_FORMAT |
LANP_LSPEED_ELEVATION_SOURCE_LSB |
LANP_LSPEED_ELEVATION_SOURCE_MSB |
LANP_LSPEED_HEADING_SOURCE)));
co_write16p(&ntf2[0], (flags & (LANP_LSPEED_POSITION_STATUS_LSB |
LANP_LSPEED_POSITION_STATUS_MSB |
LANP_LSPEED_SPEED_AND_DISTANCE_FORMAT |
LANP_LSPEED_ELEVATION_SOURCE_LSB |
LANP_LSPEED_ELEVATION_SOURCE_MSB |
LANP_LSPEED_HEADING_SOURCE)));
for (uint16_t feat = LANP_LSPEED_INST_SPEED_PRESENT;
feat <= LANP_LSPEED_POSITION_STATUS_LSB;
feat <<= 1)
{
if (LANS_IS_PRESENT(flags, feat))
{
// Field does not fit, change pointers
// ATT_DEFAULT_MTU is 23 equal to buffer size
if (!(((ATT_DEFAULT_MTU - 3) - (*len_copy_pt)) >= LANP_LAN_LSPEED_MAX_PAIR_SIZE))
{
lans_env.ntf_pending = true;
buff_copy_pt = ntf2;
len_copy_pt = len2;
}
switch (feat)
{
case LANP_LSPEED_ROLLING_TIME_PRESENT:
// Copy uint8
buff_copy_pt[(*len_copy_pt)] = pckd_locspeed[pckd_meas_idx];
len = 1;
break;
case LANP_LSPEED_INST_SPEED_PRESENT:
case LANP_LSPEED_HEADING_PRESENT:
// Copy uint16
memcpy(&buff_copy_pt[(*len_copy_pt)], &pckd_locspeed[pckd_meas_idx], 2);
len = 2;
break;
case LANP_LSPEED_TOTAL_DISTANCE_PRESENT:
case LANP_LSPEED_ELEVATION_PRESENT:
// Copy uint24
memcpy(&buff_copy_pt[(*len_copy_pt)], &pckd_locspeed[pckd_meas_idx], 3);
len = 3;
break;
case LANP_LSPEED_LOCATION_PRESENT:
// Copy latitude and longitude
memcpy(&buff_copy_pt[(*len_copy_pt)], &pckd_locspeed[pckd_meas_idx], 8);
len = 8;
break;
case LANP_LSPEED_UTC_TIME_PRESENT:
// Copy time
memcpy(&buff_copy_pt[(*len_copy_pt)], &pckd_locspeed[pckd_meas_idx], 7);
len = 7;
break;
default:
len = 0;
break;
}
if (len)
{
// Update indexes
pckd_meas_idx += len;
(*len_copy_pt) += len;
// Copy flag to current message
flags_cp = co_read16p(&buff_copy_pt[0]) | feat;
co_write16p(&buff_copy_pt[0], flags_cp);
}
}
}
return pckd_meas_idx;
}
/**
****************************************************************************************
* @brief updates the environment with the descriptor configuration and sends indication
* @param[in] prfl_config requested value
* @param[in] char_code characteristic code
* @param[in] param pointer to the message parameters
* @return status of the operation
****************************************************************************************
*/
static uint8_t lans_update_characteristic_config(uint8_t prfl_config, uint8_t char_code, struct gattc_write_cmd_ind const *param)
{
// New configuration
struct lans_ntf_ind_cfg_ind *ind = KE_MSG_ALLOC(LANS_NTF_IND_CFG_IND,
lans_env.con_info.appid, lans_env.con_info.prf_id,
lans_ntf_ind_cfg_ind);
ind->conhdl = gapc_get_conhdl(lans_env.con_info.conidx);
// Status
uint8_t status = PRF_ERR_OK;
// Get the value
uint16_t ntf_cfg = co_read16p(¶m->value[0]);
// Check if the value is correct
if (prfl_config == LANS_PRF_CFG_FLAG_LN_CTNL_PT_IND)
{
if ((ntf_cfg == PRF_CLI_STOP_NTFIND) || (ntf_cfg == PRF_CLI_START_IND))
{
// Save the new configuration in the environment
(ntf_cfg == PRF_CLI_STOP_NTFIND) ?
LANS_DISABLE_NTF_IND(prfl_config) : LANS_ENABLE_NTF_IND(prfl_config);
}
else
{
status = PRF_ERR_INVALID_PARAM;
}
}
else
{
if ((ntf_cfg == PRF_CLI_STOP_NTFIND) || (ntf_cfg == PRF_CLI_START_NTF))
{
// Save the new configuration in the environment
(ntf_cfg == PRF_CLI_STOP_NTFIND) ?
LANS_DISABLE_NTF_IND(prfl_config) : LANS_ENABLE_NTF_IND(prfl_config);
}
else
{
status = PRF_ERR_INVALID_PARAM;
}
}
if (status == PRF_ERR_OK)
{
// Set the value in the database
attmdb_att_set_value(param->handle, sizeof(uint16_t), (uint8_t *)&ntf_cfg);
ind->char_code = char_code;
ind->ntf_cfg = ntf_cfg;
ke_msg_send(ind);
}
else
{
ke_msg_free(ke_param2msg(ind));
}
return status;
}
/**
****************************************************************************************
* @brief Update database in non discovery modes
* @param[in] con_type Connection type
* @param[in] handle handle
* @param[in] ntf_cfg provided flag
* @param[in] cfg_flag requested flag
* @return status of the operation
****************************************************************************************
*/
static int lans_update_cfg_char_value (uint8_t con_type, uint8_t handle, uint16_t ntf_cfg, uint16_t cfg_flag)
{
uint8_t status = ATT_ERR_NO_ERROR;
uint16_t desc_cfg = PRF_CLI_STOP_NTFIND;
if (con_type != PRF_CON_DISCOVERY)
{
// Check the provided value
if (ntf_cfg & cfg_flag)
{
// Store the status
LANS_ENABLE_NTF_IND(cfg_flag);
// Start
desc_cfg = PRF_CLI_START_NTF;
}
}
// Set the Characteristic Configuration value in the database
status = attmdb_att_set_value(LANS_HANDLE(handle),
sizeof(uint16_t), (uint8_t *)&desc_cfg);
return status;
}
/**
****************************************************************************************
* @brief Packs navigation notifications
* @param[in] param Pointer to the parameters of the message.
* @param[out] pckd_navigation pointer to packed message
* @return length
****************************************************************************************
*/
static uint8_t lans_pack_navigation_ntf(struct lans_ntf_navigation_cmd *param, uint8_t *pckd_navigation)
{
// Packed Measurement length
uint8_t pckd_navigation_len = LANP_LAN_NAVIGATION_MIN_LEN;
// Check provided flags
if (LANS_IS_PRESENT(param->parameters.flags, LANP_NAVI_REMAINING_DIS_PRESENT))
{
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_REMAINING_DISTANCE_SUPP))
{
//Pack distance (24bits)
co_write24p(&pckd_navigation[pckd_navigation_len], param->parameters.remaining_distance);
pckd_navigation_len += 3;
}
else //Not supported by the profile
{
//Force to not supported
param->parameters.flags &= ~LANP_NAVI_REMAINING_DIS_PRESENT;
}
}
if (LANS_IS_PRESENT(param->parameters.flags, LANP_NAVI_REMAINING_VER_DIS_PRESENT))
{
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_REMAINING_VERTICAL_DISTANCE_SUPP))
{
//Pack vertical distance (24bits)
co_write24p(&pckd_navigation[pckd_navigation_len], param->parameters.remaining_ver_distance);
pckd_navigation_len += 3;
}
else //Not supported by the profile
{
//Force to not supported
param->parameters.flags &= ~LANP_NAVI_REMAINING_VER_DIS_PRESENT;
}
}
if (LANS_IS_PRESENT(param->parameters.flags, LANP_NAVI_ESTIMATED_TIME_OF_ARRIVAL_PRESENT))
{
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_ESTIMATED_TIME_OF_ARRIVAL_SUPP))
{
//Pack time
pckd_navigation_len += prf_pack_date_time(
&pckd_navigation[pckd_navigation_len], &(param->parameters.estimated_arrival_time));
}
else //Not supported by the profile
{
//Force to not supported
param->parameters.flags &= ~LANP_NAVI_ESTIMATED_TIME_OF_ARRIVAL_PRESENT;
}
}
// Force the unused bits of the flag value to 0
// param->parameters.flags &= LANP_NAVI_ALL_PRESENT;
// Flags value
co_write16p(&pckd_navigation[0], param->parameters.flags);
// Bearing value
co_write16p(&pckd_navigation[2], param->parameters.bearing);
// heading value
co_write16p(&pckd_navigation[4], param->parameters.heading);
return pckd_navigation_len;
}
/**
****************************************************************************************
* @brief Packs position quality
* @param[in] param Pointer to the parameters of the message.
* @param[out] pckd_posq pointer to packed message
* @return length
****************************************************************************************
*/
static uint8_t lans_pack_posq(struct lans_upd_pos_q_cmd *param, uint8_t *pckd_posq)
{
// Packed length
uint8_t pckd_posq_len = LANP_LAN_POSQ_MIN_LEN;
// Check provided flags
if (LANS_IS_PRESENT(param->parameters.flags, LANP_POSQ_NUMBER_OF_BEACONS_IN_SOLUTION_PRESENT))
{
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_NUMBER_OF_BEACONS_IN_SOLUTION_SUPP))
{
//Pack beacons in solution
pckd_posq[pckd_posq_len] = param->parameters.n_beacons_solution;
pckd_posq_len++;
}
else //Not supported by the profile
{
//Force to not supported
param->parameters.flags &= ~LANP_POSQ_NUMBER_OF_BEACONS_IN_SOLUTION_PRESENT;
}
}
if (LANS_IS_PRESENT(param->parameters.flags, LANP_POSQ_NUMBER_OF_BEACONS_IN_VIEW_PRESENT))
{
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_NUMBER_OF_BEACONS_IN_VIEW_SUPP))
{
//Pack beacons in view
pckd_posq[pckd_posq_len] = param->parameters.n_beacons_view;
pckd_posq_len++;
}
else //Not supported by the profile
{
//Force to not supported
param->parameters.flags &= ~LANP_POSQ_NUMBER_OF_BEACONS_IN_VIEW_PRESENT;
}
}
if (LANS_IS_PRESENT(param->parameters.flags, LANP_POSQ_TIME_TO_FIRST_FIX_PRESENT))
{
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_TIME_TO_FIRST_FIX_SUPP))
{
//Pack time to fix
co_write16p(&pckd_posq[pckd_posq_len], param->parameters.time_first_fix);
pckd_posq_len += 2;
}
else //Not supported by the profile
{
//Force to not supported
param->parameters.flags &= ~LANP_POSQ_TIME_TO_FIRST_FIX_PRESENT;
}
}
if (LANS_IS_PRESENT(param->parameters.flags, LANP_POSQ_EHPE_PRESENT))
{
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_ESTIMATED_HOR_POSITION_ERROR_SUPP))
{
//Pack ehpe
co_write32p(&pckd_posq[pckd_posq_len], param->parameters.ehpe);
pckd_posq_len += 4;
}
else //Not supported by the profile
{
//Force to not supported
param->parameters.flags &= ~LANP_POSQ_EHPE_PRESENT;
}
}
if (LANS_IS_PRESENT(param->parameters.flags, LANP_POSQ_EVPE_PRESENT))
{
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_ESTIMATED_VER_POSITION_ERROR_SUPP))
{
//Pack ehpe
co_write32p(&pckd_posq[pckd_posq_len], param->parameters.evpe);
pckd_posq_len += 4;
}
else //Not supported by the profile
{
//Force to not supported
param->parameters.flags &= ~LANP_POSQ_EVPE_PRESENT;
}
}
if (LANS_IS_PRESENT(param->parameters.flags, LANP_POSQ_HDOP_PRESENT))
{
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_HOR_DILUTION_OF_PRECISION_SUPP))
{
//Pack ehpe
pckd_posq[pckd_posq_len] = param->parameters.hdop;
pckd_posq_len++;
}
else //Not supported by the profile
{
//Force to not supported
param->parameters.flags &= ~LANP_POSQ_HDOP_PRESENT;
}
}
if (LANS_IS_PRESENT(param->parameters.flags, LANP_POSQ_VDOP_PRESENT))
{
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_VER_DILUTION_OF_PRECISION_SUPP))
{
//Pack ehpe
pckd_posq[pckd_posq_len] = param->parameters.vdop;
pckd_posq_len++;
}
else //Not supported by the profile
{
//Force to not supported
param->parameters.flags &= ~LANP_POSQ_VDOP_PRESENT;
}
}
// Force the unused bits of the flag value to 0
// param->parameters.flags &= LANP_POSQ_ALL_PRESENT;
// Flags value
co_write16p(&pckd_posq[0], param->parameters.flags);
return pckd_posq_len;
}
/**
****************************************************************************************
* @brief Packs control point
* @param[in] param Pointer to the parameters of the message.
* @param[out] rsp pointer to message
* @return status of the operation
****************************************************************************************
*/
static uint8_t lans_pack_ln_ctnl_point_cfm (struct lans_ln_ctnl_pt_cfm *param, uint8_t *rsp)
{
// Response Length (At least 3)
uint8_t rsp_len = LANP_LAN_LN_CNTL_PT_RSP_MIN_LEN;
// Set the Response Code
rsp[0] = LANP_LN_CTNL_PT_RESPONSE_CODE;
// Set the Response Value
rsp[2] = (param->status > LANP_LN_CTNL_PT_RESP_FAILED) ? LANP_LN_CTNL_PT_RESP_FAILED : param->status;
switch (lans_env.operation)
{
case (LANS_SET_CUMUL_VALUE_OP_CODE):
{
// Set the request operation code
rsp[1] = LANP_LN_CTNL_PT_SET_CUMUL_VALUE;
} break;
case (LANS_MASK_LSPEED_CHAR_CT_OP_CODE):
{
// Set the request operation code
rsp[1] = LANP_LN_CTNL_PT_MASK_LSPEED_CHAR_CT;
} break;
case (LANS_NAVIGATION_CONTROL_OP_CODE):
{
// Set the request operation code
rsp[1] = LANP_LN_CTNL_PT_NAVIGATION_CONTROL;
} break;
case (LANS_REQ_NUMBER_OF_ROUTES_OP_CODE):
{
// Set the request operation code
rsp[1] = LANP_LN_CTNL_PT_REQ_NUMBER_OF_ROUTES;
if (param->status == LANP_LN_CTNL_PT_RESP_SUCCESS)
{
co_write16p(&rsp[rsp_len], param->value.number_of_routes);
rsp_len += 2;
}
} break;
case (LANS_REQ_NAME_OF_ROUTE_OP_CODE):
{
// Set the request operation code
rsp[1] = LANP_LN_CTNL_PT_REQ_NAME_OF_ROUTE;
if (param->status == LANP_LN_CTNL_PT_RESP_SUCCESS)
{
// pack name of route
for (int i=0; i<param->value.route.length; i++)
{
rsp[i + 3] = param->value.route.name[i];
rsp_len++;
}
}
} break;
case (LANS_SELECT_ROUTE_OP_CODE):
{
// Set the request operation code
rsp[1] = LANP_LN_CTNL_PT_SELECT_ROUTE;
} break;
case (LANS_SET_FIX_RATE_OP_CODE):
{
// Set the request operation code
rsp[1] = LANP_LN_CTNL_PT_SET_FIX_RATE;
} break;
case (LANS_SET_ELEVATION_OP_CODE):
{
// Set the request operation code
rsp[1] = LANP_LN_CTNL_PT_SET_ELEVATION;
} break;
default:
{
param->status = LANP_LN_CTNL_PT_RESP_NOT_SUPP;
} break;
}
return rsp_len;
}
/**
****************************************************************************************
* @brief Unpack control point and sends indication
* @param[in] param pointer to message
* @return status of the operation
****************************************************************************************
*/
static uint8_t lans_unpack_ln_ctnl_point_ind (struct gattc_write_cmd_ind const *param)
{
// Indication Status
uint8_t ind_status = LANP_LN_CTNL_PT_RESP_NOT_SUPP;
// Allocate a request indication message for the application
struct lans_ln_ctnl_pt_req_ind *req_ind = KE_MSG_ALLOC(LANS_LN_CTNL_PT_REQ_IND,
lans_env.con_info.appid, lans_env.con_info.prf_id,
lans_ln_ctnl_pt_req_ind);
// Connection Handle
req_ind->conhdl = gapc_get_conhdl(lans_env.con_info.conidx);
// Operation Code
req_ind->op_code = param->value[0];
// Operation Code
switch(req_ind->op_code)
{
case (LANP_LN_CTNL_PT_SET_CUMUL_VALUE):
{
// Check if total distance feature is supported
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_TOTAL_DISTANCE_SUPP))
{
// Provided parameter in not within the defined range
ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM;
if (param->length == 4)
{
// The request can be handled
ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS;
// Update the environment
lans_env.operation = LANS_SET_CUMUL_VALUE_OP_CODE;
// Cumulative value
req_ind->value.cumul_val = co_read24p(¶m->value[1]);
}
}
} break;
case (LANP_LN_CTNL_PT_MASK_LSPEED_CHAR_CT):
{
// Check if the LN Masking feature is supported
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_LSPEED_CHAR_CT_MASKING_SUPP))
{
// Provided parameter in not within the defined range
ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM;
if (param->length == 3)
{
// The request can be handled
ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS;
// Update the environment
lans_env.operation = LANS_MASK_LSPEED_CHAR_CT_OP_CODE;
// Mask content
req_ind->value.mask_content = co_read16p(¶m->value[1]);
}
}
} break;
case (LANP_LN_CTNL_PT_NAVIGATION_CONTROL):
{
// Check if navigation feature is supported
if ((LANS_IS_FEATURE_SUPPORTED(lans_env.prfl_cfg, LANS_NAVI_MASK)) &&
(LANS_IS_NTF_IND_ENABLED(LANS_PRF_CFG_FLAG_NAVIGATION_NTF)))
{
// Provided parameter in not within the defined range
ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM;
if (param->length == 2)
{
// The request can be handled
ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS;
// Update the environment
lans_env.operation = LANS_NAVIGATION_CONTROL_OP_CODE;
// Control value
req_ind->value.control_value = param->value[1];
}
}
} break;
case (LANP_LN_CTNL_PT_REQ_NUMBER_OF_ROUTES):
{
// Check if navigation feature is supported
if (LANS_IS_FEATURE_SUPPORTED(lans_env.prfl_cfg, LANS_NAVI_MASK))
{
// The request can be handled
ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS;
// Update the environment
lans_env.operation = LANS_REQ_NUMBER_OF_ROUTES_OP_CODE;
}
} break;
case (LANP_LN_CTNL_PT_REQ_NAME_OF_ROUTE):
{
// Check if navigation feature is supported
if (LANS_IS_FEATURE_SUPPORTED(lans_env.prfl_cfg, LANS_NAVI_MASK))
{
// Provided parameter in not within the defined range
ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM;
if (param->length == 3)
{
// The request can be handled
ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS;
// Update the environment
lans_env.operation = LANS_REQ_NAME_OF_ROUTE_OP_CODE;
// Route number
req_ind->value.route_number = co_read16p(¶m->value[1]);
}
}
} break;
case (LANP_LN_CTNL_PT_SELECT_ROUTE):
{
// Check if navigation feature is supported
if (LANS_IS_FEATURE_SUPPORTED(lans_env.prfl_cfg, LANS_NAVI_MASK))
{
// Provided parameter in not within the defined range
ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM;
if (param->length == 3)
{
// The request can be handled
ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS;
// Update the environment
lans_env.operation = LANS_SELECT_ROUTE_OP_CODE;
// route number
req_ind->value.route_number = co_read16p(¶m->value[1]);
}
}
} break;
case (LANP_LN_CTNL_PT_SET_FIX_RATE):
{
// Check if the LN Masking feature is supported
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_FIX_RATE_SETTING_SUPP))
{
// Provided parameter in not within the defined range
ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM;
if (param->length == 2)
{
// The request can be handled
ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS;
// Update the environment
lans_env.operation = LANS_SET_FIX_RATE_OP_CODE;
// fix rate
req_ind->value.fix_rate = param->value[1];
}
}
} break;
case (LANP_LN_CTNL_PT_SET_ELEVATION):
{
// Check if the Chain Weight Adjustment feature is supported
if (LANS_IS_FEATURE_SUPPORTED(lans_env.feat_cfg, LANP_FEAT_ELEVATION_SETTING_SUPP))
{
// Provided parameter in not within the defined range
ind_status = LANP_LN_CTNL_PT_RESP_INV_PARAM;
if (param->length == 4)
{
// The request can be handled
ind_status = LANP_LN_CTNL_PT_RESP_SUCCESS;
// Update the environment
lans_env.operation = LANS_SET_ELEVATION_OP_CODE;
// elevation
req_ind->value.elevation = co_read24p(¶m->value[1]);
}
}
} break;
default:
{
// Operation Code is invalid, status is already LAN_CTNL_PT_RESP_NOT_SUPP
} break;
}
// Go to the Busy status
ke_state_set(TASK_LANS, LANS_BUSY);
// If no error raised, inform the application about the request
if (ind_status == LANP_LN_CTNL_PT_RESP_SUCCESS)
{
// Send the request indication to the application
ke_msg_send(req_ind);
}
else
{
// Free the allocated message
ke_msg_free(ke_param2msg(req_ind));
// Send an error indication
lans_send_rsp_ind(param->handle, param->value[0], ind_status);
lans_env.operation = LANS_LN_CTNL_ERR_IND_OP_CODE;
}
return ind_status;
}
/**
****************************************************************************************
* @brief Handles reception of the @ref LANS_CREATE_DB_CMD message.
* @param[in] msgid Id of the message received.
* @param[in] param Pointer to the parameters of the message.
* @param[in] dest_id ID of the receiving task instance
* @param[in] src_id ID of the sending task instance.
* @return If the message was consumed or not.
****************************************************************************************
*/
static int lans_create_db_cmd_handler(ke_msg_id_t const msgid,
struct lans_create_db_req *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
// Service Configuration Flag
uint16_t cfg_flag = LANS_MANDATORY_MASK;
// Database Creation Status
uint8_t status;
// Check if a Location and Navigation service has already been added in the database
if (ke_state_get(dest_id) == LANS_DISABLED)
{
/*
* Check if Position Quality shall be added.
*/
if((LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_NUMBER_OF_BEACONS_IN_SOLUTION_SUPP)) ||
(LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_NUMBER_OF_BEACONS_IN_VIEW_SUPP)) ||
(LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_TIME_TO_FIRST_FIX_SUPP)) ||
(LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_ESTIMATED_HOR_POSITION_ERROR_SUPP)) ||
(LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_ESTIMATED_VER_POSITION_ERROR_SUPP)) ||
(LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_HOR_DILUTION_OF_PRECISION_SUPP)) ||
(LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_VER_DILUTION_OF_PRECISION_SUPP)) ||
(LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_POSITION_STATUS_SUPP)))
{
//Add configuration to the database
cfg_flag |= LANS_POS_Q_MASK;
}
/*
* Check if the Navigation characteristic shall be added.
*/
if ((LANS_IS_FEATURE_SUPPORTED(param->prfl_config, LANS_NAVIGATION_SUPP_FLAG)) ||
(LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_NUMBER_OF_BEACONS_IN_SOLUTION_SUPP)) ||
(LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_REMAINING_DISTANCE_SUPP)) ||
(LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_REMAINING_VERTICAL_DISTANCE_SUPP)) ||
(LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_ESTIMATED_TIME_OF_ARRIVAL_SUPP)) ||
(LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_POSITION_STATUS_SUPP)))
{
cfg_flag |= LANS_NAVI_MASK;
}
/*
* Check if the LN Control Point characteristic shall be added
*/
if ((LANS_IS_FEATURE_SUPPORTED(cfg_flag, LANS_NAVI_MASK)) ||
(LANS_IS_FEATURE_SUPPORTED(param->prfl_config, LANS_CTNL_PT_CHAR_SUPP_FLAG)) ||
(LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_TOTAL_DISTANCE_SUPP)) ||
(LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_LSPEED_CHAR_CT_MASKING_SUPP)) ||
(LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_FIX_RATE_SETTING_SUPP)) ||
((LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_ELEVATION_SUPP)) &&
(LANS_IS_FEATURE_SUPPORTED(param->ln_feature, LANP_FEAT_ELEVATION_SETTING_SUPP))))
{
cfg_flag |= LANS_LN_CTNL_PT_MASK;
}
//Store Config flag
lans_env.prfl_cfg = cfg_flag;
// Add service in the database
status = attm_svc_create_db(&lans_env.shdl, (uint8_t *)&lans_env.prfl_cfg, LNS_IDX_NB,
&lans_env.hdl_offset[0], dest_id, &lans_att_db[0]);
// Check if an error has occured
if (status == ATT_ERR_NO_ERROR)
{
// Force the unused bits of the LN Feature Char value to 0
// param->ln_feature &= LANP_FEAT_ALL_SUPP;
// Store the value in the environment
lans_env.feat_cfg = param->ln_feature;
// Set the value of the LN Feature characteristic
attmdb_att_set_value(LANS_HANDLE(LNS_IDX_LN_FEAT_VAL), sizeof(uint32_t), (uint8_t *)¶m->ln_feature);
// Disable LNS
attmdb_svc_set_permission(lans_env.shdl, PERM(SVC, DISABLE));
//Database has been fulfilled with success, go to idle state
ke_state_set(TASK_LANS, LANS_IDLE);
}
}
else
{
// Request is disallowed, a LNS has already been added
status = PRF_ERR_REQ_DISALLOWED;
}
// Send complete event message to the application
lans_send_cmp_evt(TASK_LANS, src_id, GAP_INVALID_CONHDL, LANS_CREATE_DB_REQ_OP_CODE, status);
return (KE_MSG_CONSUMED);
}
/**
****************************************************************************************
* @brief Handles reception of the @ref LANS_ENABLE_CMD message.
* @param[in] msgid Id of the message received
* @param[in] param Pointer to the parameters of the message.
* @param[in] dest_id ID of the receiving task instance
* @param[in] src_id ID of the sending task instance.
* @return If the message was consumed or not.
****************************************************************************************
*/
static int lans_enable_cmd_handler(ke_msg_id_t const msgid,
struct lans_enable_req *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
// Status
uint8_t status = PRF_ERR_OK;
// Check the current state of the task and if the provided connection handle is valid
if ((ke_state_get(TASK_LANS) == LANS_IDLE) &&
(gapc_get_conidx(param->conhdl) != GAP_INVALID_CONIDX))
{
// Fill the Connection Information structure
lans_env.con_info.conidx = gapc_get_conidx(param->conhdl);
lans_env.con_info.prf_id = dest_id;
lans_env.con_info.appid = src_id;
// Reset the store Client Characteristic Configuration status
lans_env.prfl_ntf_ind_cfg = 0;
// Set the Location and speed Char. Client Characteristic Configuration value
if (lans_update_cfg_char_value(param->con_type, LNS_IDX_LOC_SPEED_NTF_CFG,
param->prfl_ntf_ind_cfg, LANS_PRF_CFG_FLAG_LOC_SPEED_NTF) != ATT_ERR_NO_ERROR)
{
status = PRF_ERR_NOT_WRITABLE;
}
// If supported, set the LN Control Point Char. Client Characteristic Configuration value
if (LANS_IS_FEATURE_SUPPORTED(lans_env.prfl_cfg, LANS_LN_CTNL_PT_MASK))
{
if (lans_update_cfg_char_value(param->con_type, LNS_IDX_LN_CTNL_PT_IND_CFG,
param->prfl_ntf_ind_cfg, LANS_PRF_CFG_FLAG_LN_CTNL_PT_IND) != ATT_ERR_NO_ERROR)
{
status = PRF_ERR_NOT_WRITABLE;
}
}
// If supported, set the Navigation Char. Client Characteristic Configuration value
if (LANS_IS_FEATURE_SUPPORTED(lans_env.prfl_cfg, LANS_NAVI_MASK))
{
if (lans_update_cfg_char_value(param->con_type, LNS_IDX_NAVIGATION_NTF_CFG,
param->prfl_ntf_ind_cfg, LANS_PRF_CFG_FLAG_NAVIGATION_NTF) != ATT_ERR_NO_ERROR)
{
status = PRF_ERR_NOT_WRITABLE;
}
}
if (status == PRF_ERR_OK)
{
//Store the Notify/Indication config
lans_env.prfl_ntf_ind_cfg = param->prfl_ntf_ind_cfg;
// Enable LNS
attmdb_svc_set_permission(lans_env.shdl, param->sec_lvl);
// Go to Connected State
ke_state_set(dest_id, LANS_CONNECTED);
}
}
else
{
// The request is disallowed (profile already enabled for this connection, or not enough memory, ...)
status = PRF_ERR_REQ_DISALLOWED;
}
// Send response to application
lans_send_cmp_evt(dest_id, src_id, param->conhdl, LANS_ENABLE_REQ_OP_CODE, status);
return (KE_MSG_CONSUMED);
}
/**
****************************************************************************************
* @brief Handles reception of the @ref LANS_NTF_LN_MEAS_CMD message.
* @param[in] msgid Id of the message received.
* @param[in] param Pointer to the parameters of the message.
* @param[in] dest_id ID of the receiving task instance.
* @param[in] src_id ID of the sending task instance.
* @return If the message was consumed or not.
****************************************************************************************
*/
static int lans_ntf_loc_speed_cmd_handler(ke_msg_id_t const msgid,
struct lans_ntf_loc_speed_cmd *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
// Message status
uint8_t msg_status = KE_MSG_CONSUMED;
// State
ke_state_t state = ke_state_get(TASK_LANS);
// State shall be Connected or Busy
if (state >= LANS_CONNECTED)
{
// Status
uint8_t status = PRF_ERR_OK;
do
{
// Check the connection handle
if (gapc_get_conidx(param->conhdl) != lans_env.con_info.conidx)
{
status = PRF_ERR_INVALID_PARAM;
break;
}
// Check if sending of notifications has been enabled
if (!LANS_IS_NTF_IND_ENABLED(LANS_PRF_CFG_FLAG_LOC_SPEED_NTF))
{
status = LAN_ERROR_IMPROPERLY_CONFIGURED;
break;
}
// Check the current state of the task
if (state == LANS_BUSY)
{
// Keep the message for later, status will be PRF_ERR_OK
msg_status = KE_MSG_SAVED;
break;
}
ASSERT_ERR(lans_env.operation == LANS_RESERVED_OP_CODE);
// Location and speed array declaration
uint8_t pckd_loc_speed[LANP_LAN_LOC_SPEED_MAX_LEN];
// Pack Location and speed
uint8_t nb = lans_pack_loc_speed_ntf(param, pckd_loc_speed);
// Split notification if necessary
// ToDo [CM] Maximize first notification with MTU value
if (nb > (gattc_get_mtu(lans_env.con_info.conidx) - 3))
{
uint8_t ntf1[ATT_DEFAULT_MTU - 3], len1 = LANP_LAN_LOC_SPEED_MIN_LEN;
lans_split_loc_speed_ntf(pckd_loc_speed, ntf1, &len1, lans_env.ntf, &lans_env.ntf_len);
// Set the value in the database
attmdb_att_set_value(LANS_HANDLE(LNS_IDX_LOC_SPEED_VAL), len1, (uint8_t *)&ntf1[0]);
// Send the notification
prf_server_send_event((prf_env_struct *)&lans_env, false, LANS_HANDLE(LNS_IDX_LOC_SPEED_VAL));
}
else
{
// Set the value in the database
attmdb_att_set_value(LANS_HANDLE(LNS_IDX_LOC_SPEED_VAL), nb, (uint8_t *)&pckd_loc_speed[0]);
// Send the notification
prf_server_send_event((prf_env_struct *)&lans_env, false, LANS_HANDLE(LNS_IDX_LOC_SPEED_VAL));
}
// Configure the environment
lans_env.operation = LANS_NTF_LOC_SPEED_OP_CODE;
// Go to busy state
ke_state_set(TASK_LANS, LANS_BUSY);
} while (0);
if (status != PRF_ERR_OK)
{
// Send response to application
lans_send_cmp_evt(lans_env.con_info.prf_id, lans_env.con_info.appid, gapc_get_conhdl(lans_env.con_info.conidx),
LANS_NTF_LOC_SPEED_OP_CODE, status);
}
}
else
{
// The profile has not been enabled for a connection or the database has not been created
lans_send_cmp_evt(dest_id, src_id, param->conhdl, LANS_NTF_LOC_SPEED_OP_CODE, PRF_ERR_REQ_DISALLOWED);
}
return (int)msg_status;
}
/**
****************************************************************************************
* @brief Handles reception of the @ref LANS_UPD_POS_Q_CMD message.
* @param[in] msgid Id of the message received.
* @param[in] param Pointer to the parameters of the message.
* @param[in] dest_id ID of the receiving task instance.
* @param[in] src_id ID of the sending task instance.
* @return If the message was consumed or not.
****************************************************************************************
*/
static int lans_upd_pos_q_cmd_handler(ke_msg_id_t const msgid,
struct lans_upd_pos_q_cmd *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
// Status
uint8_t status = PRF_ERR_INVALID_PARAM;
// Check if Position Quality Char. has been added in the database
if (LANS_IS_FEATURE_SUPPORTED(lans_env.prfl_cfg, LANS_POS_Q_MASK))
{
// position quality array declaration
uint8_t pckd_posq[LANP_LAN_POSQ_MAX_LEN];
// Pack Position quality
uint8_t nb = lans_pack_posq(param, pckd_posq);
// Set the value in the database
status = attmdb_att_set_value(LANS_HANDLE(LNS_IDX_POS_Q_VAL), nb, (uint8_t *)&pckd_posq[0]);
}
else
{
status = PRF_ERR_FEATURE_NOT_SUPPORTED;
}
// Send response to application
lans_send_cmp_evt(lans_env.con_info.prf_id, lans_env.con_info.appid, gapc_get_conhdl(lans_env.con_info.conidx),
LANS_UPD_POS_Q_OP_CODE, status);
return (KE_MSG_CONSUMED);
}
/**
****************************************************************************************
* @brief Handles reception of the @ref LANS_NTF_NAVIGATION_CMD message.
* @param[in] msgid Id of the message received.
* @param[in] param Pointer to the parameters of the message.
* @param[in] dest_id ID of the receiving task instance.
* @param[in] src_id ID of the sending task instance.
* @return If the message was consumed or not.
****************************************************************************************
*/
static int lans_ntf_navigation_cmd_handler(ke_msg_id_t const msgid,
struct lans_ntf_navigation_cmd *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
// Message status
uint8_t msg_status = KE_MSG_CONSUMED;
// State
ke_state_t state = ke_state_get(TASK_LANS);
// State shall be Connected or Busy
if (state >= LANS_CONNECTED)
{
// Status
uint8_t status = PRF_ERR_OK;
do
{
// Check the connection handle
if (gapc_get_conidx(param->conhdl) != lans_env.con_info.conidx)
{
status = PRF_ERR_INVALID_PARAM;
break;
}
// Check if sending of notifications has been enabled
if (!LANS_IS_NTF_IND_ENABLED(LANS_PRF_CFG_FLAG_NAVIGATION_NTF))
{
status = LAN_ERROR_IMPROPERLY_CONFIGURED;
break;
}
// Check the current state of the task
if (state == LANS_BUSY)
{
// Keep the message for later, status will be PRF_ERR_OK
msg_status = KE_MSG_SAVED;
break;
}
ASSERT_ERR(lans_env.operation == LANS_RESERVED_OP_CODE);
// Navigation array declaration
uint8_t pckd_navigation[LANP_LAN_NAVIGATION_MAX_LEN];
// Pack Navigation
uint8_t nb = lans_pack_navigation_ntf(param, pckd_navigation);
// Set the value in the database
attmdb_att_set_value(LANS_HANDLE(LNS_IDX_NAVIGATION_VAL), nb, (uint8_t *)&pckd_navigation[0]);
// Send the notification
prf_server_send_event((prf_env_struct *)&lans_env, false, LANS_HANDLE(LNS_IDX_NAVIGATION_VAL));
// Configure the environment
lans_env.operation = LANS_NTF_NAVIGATION_OP_CODE;
// Go to busy state
ke_state_set(TASK_LANS, LANS_BUSY);
} while (0);
if (status != PRF_ERR_OK)
{
// Send response to application
lans_send_cmp_evt(lans_env.con_info.prf_id, lans_env.con_info.appid, gapc_get_conhdl(lans_env.con_info.conidx),
LANS_NTF_NAVIGATION_OP_CODE, status);
}
}
else
{
// The profile has not been enabled for a connection or the database has not been created
lans_send_cmp_evt(dest_id, src_id, param->conhdl, LANS_NTF_NAVIGATION_OP_CODE, PRF_ERR_REQ_DISALLOWED);
}
return (int)msg_status;
}
/**
****************************************************************************************
* @brief Handles reception of the @ref LANS_LN_CTNL_PT_CFM message.
* @param[in] msgid Id of the message received.
* @param[in] param Pointer to the parameters of the message.
* @param[in] dest_id ID of the receiving task instance.
* @param[in] src_id ID of the sending task instance.
* @return If the message was consumed or not.
****************************************************************************************
*/
static int lans_ln_ctnl_pt_cfm_handler(ke_msg_id_t const msgid,
struct lans_ln_ctnl_pt_cfm *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
// Control Point Response
uint8_t rsp[LANP_LAN_LN_CNTL_PT_RSP_MAX_LEN];
do
{
// Check the current operation
if (lans_env.operation < LANS_SET_CUMUL_VALUE_OP_CODE)
{
// The confirmation has been sent without request indication, ignore
break;
}
// The SC Control Point Characteristic must be supported if we are here
ASSERT_ERR(lans_env.hdl_offset[LANP_LANS_LN_CTNL_PT_CHAR] != 0x00);
// Pack Control Point confirmation
uint8_t nb = lans_pack_ln_ctnl_point_cfm (param, rsp);
// Set the value in the database - If we are here the handle is valid
attmdb_att_set_value(LANS_HANDLE(LNS_IDX_LN_CTNL_PT_VAL),
nb, (uint8_t *)&rsp);
// Send the response indication to the peer device
prf_server_send_event((prf_env_struct *)&lans_env, true,
LANS_HANDLE(LNS_IDX_LN_CTNL_PT_VAL));
// Wait for Confirm
ke_state_set(TASK_LANS, LANS_WAIT_FOR_CFM);
} while (0);
return (KE_MSG_CONSUMED);
}
/**
****************************************************************************************
* @brief Handles reception of the @ref GATTC_WRITE_CMD_IND message.
* @param[in] msgid Id of the message received.
* @param[in] param Pointer to the parameters of the message.
* @param[in] dest_id ID of the receiving task instance.
* @param[in] src_id ID of the sending task instance.
* @return If the message was consumed or not.
****************************************************************************************
*/
static int gattc_write_cmd_ind_handler(ke_msg_id_t const msgid,
struct gattc_write_cmd_ind const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
// Message status
uint8_t msg_status = KE_MSG_CONSUMED;
// Status
uint8_t status = PRF_ERR_OK;
// check if waiting for indication confirmation
if((ke_state_get(TASK_LANS) == LANS_WAIT_FOR_CFM)
&& (KE_TYPE_GET(src_id) == TASK_GATTC))
{
// reschedule message once to ensure that indication reception is not on-going.
ke_msg_forward(param, dest_id, dest_id);
// Message forwarded do not free it
msg_status = KE_MSG_NO_FREE;
}
// Check the connection handle
else if (ke_state_get(TASK_LANS) >= LANS_CONNECTED)
{
// Location and speed Characteristic, Client Characteristic Configuration Descriptor
if (param->handle == (LANS_HANDLE(LNS_IDX_LOC_SPEED_NTF_CFG)))
{
// Update value
status = lans_update_characteristic_config(LANS_PRF_CFG_FLAG_LOC_SPEED_NTF,
LANP_LANS_LOC_SPEED_CHAR, param);
}
// Navigation Characteristic, Client Characteristic Configuration Descriptor
else if (param->handle == (LANS_HANDLE(LNS_IDX_NAVIGATION_NTF_CFG)))
{
ASSERT_ERR(lans_env.hdl_offset[LANP_LANS_NAVIG_CHAR] != 0x00);
// Update value
status = lans_update_characteristic_config(LANS_PRF_CFG_FLAG_NAVIGATION_NTF,
LANP_LANS_NAVIG_CHAR, param);
}
// LN Control Point Characteristic
else
{
ASSERT_ERR(lans_env.hdl_offset[LANP_LANS_LN_CTNL_PT_CHAR] != 0x00);
// LN Control Point, Client Characteristic Configuration Descriptor
if (param->handle == (LANS_HANDLE(LNS_IDX_LN_CTNL_PT_IND_CFG)))
{
// Update value
status = lans_update_characteristic_config(LANS_PRF_CFG_FLAG_LN_CTNL_PT_IND,
LANP_LANS_LN_CTNL_PT_CHAR, param);
}
// LN Control Point Characteristic
else if (param->handle == (LANS_HANDLE(LNS_IDX_LN_CTNL_PT_VAL)))
{
do
{
// Check if sending of indications has been enabled
if (!LANS_IS_NTF_IND_ENABLED(LANS_PRF_CFG_FLAG_LN_CTNL_PT_IND))
{
// CCC improperly configured
status = LAN_ERROR_IMPROPERLY_CONFIGURED;
break;
}
if (lans_env.operation >= LANS_SET_CUMUL_VALUE_OP_CODE)
{
// A procedure is already in progress
status = LAN_ERROR_PROC_IN_PROGRESS;
break;
}
if (lans_env.operation == LANS_NTF_LOC_SPEED_OP_CODE)
{
// Keep the message until the end of the current procedure
msg_status = KE_MSG_SAVED;
break;
}
// Unpack Control Point parameters
lans_unpack_ln_ctnl_point_ind (param);
} while (0);
}
else
{
ASSERT_ERR(0);
}
}
// Send the write response to the peer device
atts_write_rsp_send(lans_env.con_info.conidx, param->handle, status);
}
// else drop the message
return (int)msg_status;
}
/**
****************************************************************************************
* @brief Handles @ref GATT_NOTIFY_CMP_EVT message meaning that a notification or an indication
* has been correctly sent to peer device (but not confirmed by peer device).
*
* @param[in] msgid Id of the message received.
* @param[in] param Pointer to the parameters of the message.
* @param[in] dest_id ID of the receiving task instance
* @param[in] src_id ID of the sending task instance.
* @return If the message was consumed or not.
****************************************************************************************
*/
static int gattc_cmp_evt_handler(ke_msg_id_t const msgid, struct gattc_cmp_evt const *param,
ke_task_id_t const dest_id, ke_task_id_t const src_id)
{
// Check if a connection exists
if (ke_state_get(TASK_LANS) >= LANS_CONNECTED)
{
switch (param->req_type)
{
case (GATTC_NOTIFY):
{
if (lans_env.operation == LANS_NTF_LOC_SPEED_OP_CODE)
{
// Notification pending?
if (lans_env.ntf_pending)
{
lans_env.ntf_pending = false;
// Set the value in the database
attmdb_att_set_value(LANS_HANDLE(LNS_IDX_LOC_SPEED_VAL), lans_env.ntf_len, (uint8_t *)&lans_env.ntf[0]);
// Send the notification
prf_server_send_event((prf_env_struct *)&lans_env, false, LANS_HANDLE(LNS_IDX_LOC_SPEED_VAL));
}
else
{
// Inform the application that a procedure has been completed
lans_send_cmp_evt(lans_env.con_info.prf_id, lans_env.con_info.appid, gapc_get_conhdl(lans_env.con_info.conidx),
LANS_NTF_LOC_SPEED_OP_CODE, param->status);
}
}
else if (lans_env.operation == LANS_NTF_NAVIGATION_OP_CODE)
{
// Inform the application that a procedure has been completed
lans_send_cmp_evt(lans_env.con_info.prf_id, lans_env.con_info.appid, gapc_get_conhdl(lans_env.con_info.conidx),
LANS_NTF_NAVIGATION_OP_CODE, param->status);
}
else
{
ASSERT_ERR(0);
}
// else ignore the message
} break;
case (GATTC_INDICATE):
{
ASSERT_ERR(lans_env.operation >= LANS_SET_CUMUL_VALUE_OP_CODE);
// Inform the application that a procedure has been completed
lans_send_cmp_evt(lans_env.con_info.prf_id, lans_env.con_info.appid, gapc_get_conhdl(lans_env.con_info.conidx),
lans_env.operation, param->status);
// else ignore the message
} break;
default:
{
ASSERT_ERR(0);
} break;
}
}
return (KE_MSG_CONSUMED);
}
/**
****************************************************************************************
* @brief Disconnection indication to LANS.
* @param[in] msgid Id of the message received.
* @param[in] param Pointer to the parameters of the message.
* @param[in] dest_id ID of the receiving task instance
* @param[in] src_id ID of the sending task instance.
* @return If the message was consumed or not.
****************************************************************************************
*/
static int gapc_disconnect_ind_handler(ke_msg_id_t const msgid,
struct gapc_disconnect_ind const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
// Check if a connection exists
if (KE_IDX_GET(src_id) == lans_env.con_info.conidx)
{
lans_disable(param->conhdl);
}
return (KE_MSG_CONSUMED);
}
/*
* GLOBAL VARIABLE DEFINITIONS
****************************************************************************************
*/
/// Specifies the default message handlers
const struct ke_msg_handler lans_default_state[] =
{
{LANS_CREATE_DB_CMD, (ke_msg_func_t)lans_create_db_cmd_handler},
{LANS_ENABLE_CMD, (ke_msg_func_t)lans_enable_cmd_handler},
{LANS_NTF_LOC_SPEED_CMD, (ke_msg_func_t)lans_ntf_loc_speed_cmd_handler},
{LANS_UPD_POS_Q_CMD, (ke_msg_func_t)lans_upd_pos_q_cmd_handler},
{LANS_NTF_NAVIGATION_CMD, (ke_msg_func_t)lans_ntf_navigation_cmd_handler},
{LANS_LN_CTNL_PT_CFM, (ke_msg_func_t)lans_ln_ctnl_pt_cfm_handler},
{GATTC_WRITE_CMD_IND, (ke_msg_func_t) gattc_write_cmd_ind_handler},
{GATTC_CMP_EVT, (ke_msg_func_t) gattc_cmp_evt_handler},
{GAPC_DISCONNECT_IND, (ke_msg_func_t)gapc_disconnect_ind_handler},
};
/// Specifies the message handler structure for every input state.
const struct ke_state_handler lans_state_handler[LANS_STATE_MAX] =
{
[LANS_DISABLED] = KE_STATE_HANDLER_NONE,
[LANS_IDLE] = KE_STATE_HANDLER_NONE,
[LANS_CONNECTED] = KE_STATE_HANDLER_NONE,
[LANS_BUSY] = KE_STATE_HANDLER_NONE,
[LANS_WAIT_FOR_CFM] = KE_STATE_HANDLER_NONE,
};
/// Specifies the message handlers that are common to all states.
const struct ke_state_handler lans_default_handler = KE_STATE_HANDLER(lans_default_state);
/// Defines the place holder for the states of all the task instances.
ke_state_t lans_state[LANS_IDX_MAX] __attribute__((section("retention_mem_area0"),zero_init)); //@RETENTION MEMORY
#endif //(BLE_LN_SENSOR)
/// @} LANSTASK
| 39.250598 | 135 | 0.569552 |
0c436d78e7bc3a807bcc371841b3c215cb806eb3 | 7,467 | h | C | muzero-cpp/mcts.h | tuero/muzero-cpp | a679275a2c6f6a6ff7fb38ede40423aced0afe10 | [
"Apache-2.0"
] | 6 | 2022-01-13T07:41:50.000Z | 2022-02-07T22:29:01.000Z | muzero-cpp/mcts.h | tuero/muzero-cpp | a679275a2c6f6a6ff7fb38ede40423aced0afe10 | [
"Apache-2.0"
] | null | null | null | muzero-cpp/mcts.h | tuero/muzero-cpp | a679275a2c6f6a6ff7fb38ede40423aced0afe10 | [
"Apache-2.0"
] | 1 | 2022-01-19T01:29:23.000Z | 2022-01-19T01:29:23.000Z | #ifndef MUZERO_CPP_MCTS_H_
#define MUZERO_CPP_MCTS_H_
#include <cassert>
#include <limits>
#include <memory>
#include <random>
#include <vector>
#include "muzero-cpp/config.h"
#include "muzero-cpp/types.h"
#include "muzero-cpp/util.h"
#include "muzero-cpp/vprnet_evaluator.h"
namespace muzero_cpp {
namespace algorithm {
// Node used in MCTS search tree
struct MCTSNode {
int visit_count = 0; // Number of times this node has been visited
types::Player to_play = types::InvalidPlayer; // Current player to play at this node
types::Action action =
types::InvalidAction; // Action taken to get to this node from the previous state
double prior = 0; // Prior probability for choosing action which led to this node
double value_sum = 0; // Sum of values from passing through this node
double reward = 0; // Reward received by transitioning to this node
std::vector<MCTSNode> children; // Child nodes
types::Observation encoded_state; // Hidden state which the nodes represents
MCTSNode(types::Action action, double prior) : action(action), prior(prior) {}
MCTSNode() = delete; // Default constructor is probably fine, but doesn't make sense to use ...
/**
* Check whether the node has been previously expanded.
* @return True if the node has been expanded, false otherwise
*/
bool is_expanded() const;
/**
* Get the mean value of the node.
* @return The mean value of the node
*/
double value() const;
/**
* Expand the current node using the value/policy and reward prediction
* from the recurrent dynamics model.
* @param actions All possible game actions
* @param to_play The current player to play
* @param reward The predicted reward
* @param policy_probs The policy probabilities over tne entire action space
* @param encoded_state The hidden state which the current node represents
*/
void expand(const std::vector<types::Action> &actions, types::Player to_play, double reward,
const std::vector<double> &policy_probs, const types::Observation &encoded_state);
/**
* Add a weighted sum of dirichlet exploration noise over the priors
* @param dirichlet_alpha The alpha parameter for the Dirichlet distribution
* @param dirichlet_epsilon The fractional component of the weighted sum for the Dirichlet noise
* @param rng A random number generator
*/
void add_exploration_noise(double dirichlet_alpha, double dirichlet_epsilon, std::mt19937 &rng);
/**
* Get the search statistics in form of a policy.
* @param action_space Action space to gather statistics over
* @return vector of visit count over total visits for all actions
*/
// std::vector<double> get_search_statistics(const std::vector<types::Action> &action_space) const;
void get_search_statistics(const std::vector<types::Action> &action_space,
std::vector<types::Action> &child_actions,
std::vector<double> &children_relative_visit,
std::vector<double> &root_policy) const;
};
// Class to hold the min-max values seen during the tree search
// Used to normalize values (Appendix B Search)
class MinMaxStats {
public:
MinMaxStats(double minimum, double maximum)
: init_minimum_(minimum), init_maximum_(maximum), minimum_(minimum), maximum_(maximum){};
MinMaxStats()
: init_minimum_(types::INF_D),
init_maximum_(types::NINF_D),
minimum_(types::INF_D),
maximum_(types::NINF_D){};
/**
* Reset the stored min/max bounds to the init values
*/
void reset();
/**
* Update the seen min/max bounds.
* @param value The new value seen.
*/
void update(double value);
/**
* Normalize the given value using the known/seen min/max bounds.
* @param value The value to normalize
* @return The normalized value
*/
double normalize(double value) const;
private:
double init_minimum_; // Minimum starting value
double init_maximum_; // Maximum starting value
double minimum_; // Minimum observed bound on value
double maximum_; // Maximum observed bound on value
};
// Class which handles the MCTS for self-play
class MCTS {
public:
/**
* Constructor for MCTS object
* @param config A muzero configuration struct
* @param seed Initial seed to source all randomness used in the search
* @param vpr_eval Muzero network evaluator for inference
*/
MCTS(const muzero_config::MuZeroConfig &config, int seed, std::shared_ptr<Evaluator> vpr_eval);
MCTS() = delete;
/**
* Run MCTS for a set number of iterations
* @param stacked_observation The stacked observation for the current game state
* @param legal_actions The list of legal actions for the current game state
* @param to_play The player to move for the current game state
* @param add_exploration_noise flag to add Dirichlet exploration noise to the prior distribution
* @return Struct containing root value, max depth searched, child visit counts, and root child actions
*/
types::MCTSReturn run(const types::Observation &stacked_observation,
const std::vector<types::Action> &legal_actions, types::Player to_play,
bool add_exploration_noise);
/**
* Selects a child node which maximizes the modifed pUCT formulation
* @param node Pointer to node which to select for
* @return Pointer to child node selected
*/
MCTSNode *select_child(MCTSNode *node);
/**
* Calculate the UCB score for the node using the modified pUCT rule (See Appendix B Search)
* @param Parent Pointer to parent of node to consider
* @param child node to find the value of
* @return The UCB score for the given child node
*/
double ucb_score(MCTSNode *parent, MCTSNode *child);
/**
* Backpropogate the value up along the nodes for the given search path
* @param search_path The path along which to backpropogate
* @param value The value to popogate
* @param to_play The current player for the leaf node along the path
*/
void backpropogate(std::vector<MCTSNode *> &search_path, double value, types::Player to_play);
private:
int num_players_; // Number of players the game requires
int num_simulations_; // Number of MCTS simulations per move
double dirichlet_alpha_; // Dirichlet distribution alpha parameter
double dirichlet_epsilon_; // The fractional component of the weighted sum for the Dirichlet noise
double pb_c_base_; // pUCT c_base constant
double pb_c_init_; // pUCT c_base constant
double discount_; // Discount factor for reward
MinMaxStats minmax_stats_; // Normalizes values seen into [0, 1] range
std::mt19937 rng_; // Source of randomness for Dirichlet noise
std::vector<types::Action> action_space_; // List of all possible actions
std::shared_ptr<Evaluator> vpr_eval_; // Muzero network evaluator for inference
};
} // namespace algorithm
} // namespace muzero_cpp
#endif // MUZERO_CPP_MCTS_H_ | 41.949438 | 107 | 0.671354 |
0c43826139d09feb2d5f1755acf2bcd0348ad993 | 1,100 | h | C | hypre-2.16.0/src/distributed_ls/ParaSails/ConjGrad.h | sarahorsak/MFEM | 9ff3dd6ff54ce7652fc7fdb5d348073fb9321cf3 | [
"BSD-3-Clause"
] | null | null | null | hypre-2.16.0/src/distributed_ls/ParaSails/ConjGrad.h | sarahorsak/MFEM | 9ff3dd6ff54ce7652fc7fdb5d348073fb9321cf3 | [
"BSD-3-Clause"
] | null | null | null | hypre-2.16.0/src/distributed_ls/ParaSails/ConjGrad.h | sarahorsak/MFEM | 9ff3dd6ff54ce7652fc7fdb5d348073fb9321cf3 | [
"BSD-3-Clause"
] | null | null | null | /*BHEADER**********************************************************************
* Copyright (c) 2008, Lawrence Livermore National Security, LLC.
* Produced at the Lawrence Livermore National Laboratory.
* This file is part of HYPRE. See file COPYRIGHT for details.
*
* HYPRE 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) version 2.1 dated February 1999.
*
* $Revision$
***********************************************************************EHEADER*/
/******************************************************************************
*
* ConjGrad.h header file.
*
*****************************************************************************/
#ifndef _CONJGRAD_H
#define _CONJGRAD_H
void PCG_ParaSails(Matrix *mat, ParaSails *ps, HYPRE_Real *b, HYPRE_Real *x,
HYPRE_Real tol, HYPRE_Int max_iter);
void FGMRES_ParaSails(Matrix *mat, ParaSails *ps, HYPRE_Real *b, HYPRE_Real *x,
HYPRE_Int dim, HYPRE_Real tol, HYPRE_Int max_iter);
#endif /* _CONJGRAD_H */
| 35.483871 | 81 | 0.538182 |
0c4448b4784e5aad06794d93f2dba6849b68da03 | 5,454 | h | C | IPlug/VST2/IPlugReaperVST2.h | badi91/iPlug2 | e508e85060871cef4ff16c9bc80c503c375e0a14 | [
"Zlib"
] | 1,305 | 2018-07-28T08:48:47.000Z | 2022-03-31T23:06:59.000Z | IPlug/VST2/IPlugReaperVST2.h | badi91/iPlug2 | e508e85060871cef4ff16c9bc80c503c375e0a14 | [
"Zlib"
] | 582 | 2019-01-01T15:37:55.000Z | 2022-03-30T22:57:16.000Z | IPlug/VST2/IPlugReaperVST2.h | badi91/iPlug2 | e508e85060871cef4ff16c9bc80c503c375e0a14 | [
"Zlib"
] | 284 | 2018-10-17T22:16:26.000Z | 2022-03-30T15:38:19.000Z | /*
==============================================================================
This file is part of the iPlug 2 library. Copyright (C) the iPlug 2 developers.
See LICENSE.txt for more info.
==============================================================================
*/
#pragma once
#include "IPlugVST2.h"
#include "reaper_plugin.h"
#include "video_processor.h"
#define REAPERAPI_IMPLEMENT
#include "reaper_plugin_functions.h"
bool (*DoFxLastTweakParmCtxMenu2)(void* pFXDSP, void* pHWND, int xpos, int ypos, const char* headerStr);
BEGIN_IPLUG_NAMESPACE
/** Reaper specific VST2.4 API base class for an IPlug plug-in. */
class IPlugReaperVST2 : public IPlugVST2
{
public:
IPlugReaperVST2(const InstanceInfo& info, const Config& config)
: IPlugVST2(info, config)
{
int errorCount = REAPERAPI_LoadAPI([this](const char* str) {
return (void*) mHostCallback(NULL, 0xdeadbeef, 0xdeadf00d, 0, (void*) str, 0.0);
});
if (errorCount > 0)
LogToReaper("some errors when loading reaper api functions\n");
}
/** Pop up Reaper's "Last touched FX" dialog, in order to set envelopes etc for the last touched parameter
* @param pView platform view handle - in an IGraphics plug-in you can call IGraphics::GetWindow() to get this
* @param xpos x position on the screen to popup the menu. NOTE: screen coordinates! Can convert mouse position in IControls with IGraphics::ClientToScreen()
* @param ypos y position on the screen to popup the menu. NOTE: screen coordinates! Can convert mouse position in IControls with IGraphics::ClientToScreen() */
void CreateParameterPopup(void* pView, int xpos, int ypos)
{
void *pFXDSP = (void*)mHostCallback(&mAEffect, 0xdeadbeef, 0xdeadf00e, 4, NULL, 0.0f);
*(VstIntPtr *)&DoFxLastTweakParmCtxMenu2 = mHostCallback(NULL, 0xdeadbeef, 0xdeadf00d, 0, (void*) "DoFxLastTweakParmCtxMenu2", 0.0);
if(DoFxLastTweakParmCtxMenu2)
DoFxLastTweakParmCtxMenu2(pFXDSP, pView, xpos, ypos, NULL);
}
void SetTrackVolume(double gain)
{
MediaTrack* tr = GetReaperTrack();
if (tr != nullptr)
SetMediaTrackInfo_Value(tr, "D_VOL", gain);
}
void GetTakeName(WDL_String& str)
{
const char* name = ::GetTakeName(GetReaperTake());
if (name != nullptr)
str.Set(name);
}
void SetTakeName(const char* name)
{
MediaItem_Take* tk = GetReaperTake();
if (tk != nullptr)
{
GetSetMediaItemTakeInfo_String(tk, "P_NAME", const_cast<char*>(name), true);
UpdateArrange();
}
else
{
LogToReaper("Plugin is not loaded into a Reaper take\n");
}
}
void GetTrackName(WDL_String& str) override
{
char buf[2048];
if (GetSetMediaTrackInfo_String(GetReaperTrack(), "P_NAME", buf, false) == true)
{
str.Set(buf);
}
}
void SetTrackName(const char* name)
{
GetSetMediaTrackInfo_String(GetReaperTrack(), "P_NAME", const_cast<char*>(name), true);
UpdateArrange();
}
MediaTrack* GetReaperTrack()
{
return (MediaTrack*)mHostCallback(&mAEffect, 0xdeadbeef, 0xdeadf00e, 1, 0, 0.0);
}
MediaItem_Take* GetReaperTake()
{
return (MediaItem_Take*) mHostCallback(&mAEffect, 0xdeadbeef, 0xdeadf00e, 2, 0, 0.0);
}
void GetTrackColor(int& r, int& g, int& b) override
{
MediaTrack* pTrack = GetReaperTrack();
ColorFromNative(::GetTrackColor(pTrack), &r, &g, &b);
}
void LogToReaper(const char* str)
{
if(ShowConsoleMsg != nullptr)
ShowConsoleMsg(str);
}
void InformHostOfAddedParams(int index, int numAddedParams)
{
int listadj[2] = {index, numAddedParams};
mAEffect.numParams = NParams();
mHostCallback(&mAEffect, audioMasterVendorSpecific, 0xdeadbeef, audioMasterAutomate, listadj, 0.0);
}
void InformHostOfRemovedParams(int index, int numRemovedParams)
{
int listadj[2] = {index, -numRemovedParams};
mAEffect.numParams = NParams();
mHostCallback(&mAEffect, audioMasterVendorSpecific, 0xdeadbeef, audioMasterAutomate, listadj, 0.0);
}
void InitializeVideo(void* staticProcessVideoFrame, void* staticGetVideoParam)
{
void* pCtx = (void*) mHostCallback(&mAEffect, 0xdeadbeef, 0xdeadf00e, 4, NULL, 0.0f);
if (pCtx)
{
IREAPERVideoProcessor *(*video_CreateVideoProcessor)(void *fxctx, int version);
*(void**)&video_CreateVideoProcessor = (void *) mHostCallback(&mAEffect, 0xdeadbeef, 0xdeadf00d, 0, (void *) "video_CreateVideoProcessor", 0.0f);
if (video_CreateVideoProcessor)
{
mVideoProc = video_CreateVideoProcessor(pCtx, IREAPERVideoProcessor::REAPER_VIDEO_PROCESSOR_VERSION);
if (mVideoProc)
{
mVideoProc->userdata = this;
mVideoProc->process_frame = (IVideoFrame* (*)(IREAPERVideoProcessor*, const double*, int, double, double, int)) staticProcessVideoFrame;
mVideoProc->get_parameter_value = (bool (*)(IREAPERVideoProcessor*, int, double *)) staticGetVideoParam;
}
}
}
}
private:
// template<typename T>
// T (*GetFunc(VstInt32 p1, VstIntPtr p2, const char* str = NULL, float p3 = 0.f))()
// {
// T (*func)();
// *(long *)&func = mHostCallback(&mAEffect, 0xdeadbeef, p1, p2, (void*) str, p3);
// return func;
// }
IREAPERVideoProcessor* mVideoProc = nullptr;
};
IPlugReaperVST2* MakePlug(const InstanceInfo& info);
END_IPLUG_NAMESPACE
| 32.272189 | 162 | 0.656582 |
bd07435aacf019e74f96cd52b80e47592f3275a9 | 1,204 | h | C | src/Three20/TTSearchlightLabel.h | searls/three20 | f7bb856065882948005782939d5e5337dd4c3e36 | [
"Apache-2.0"
] | 1 | 2016-05-09T13:58:30.000Z | 2016-05-09T13:58:30.000Z | src/Three20/TTSearchlightLabel.h | searls/three20 | f7bb856065882948005782939d5e5337dd4c3e36 | [
"Apache-2.0"
] | null | null | null | src/Three20/TTSearchlightLabel.h | searls/three20 | f7bb856065882948005782939d5e5337dd4c3e36 | [
"Apache-2.0"
] | null | null | null | //
// Copyright 2009-2010 Facebook
//
// 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.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface TTSearchlightLabel : UIView {
NSString* _text;
UIFont* _font;
UIColor* textColor;
UIColor* _spotlightColor;
UITextAlignment _textAlignment;
NSTimer* _timer;
CGFloat _spotlightPoint;
CGContextRef _maskContext;
void* _maskData;
}
@property(nonatomic,copy) NSString* text;
@property(nonatomic,retain) UIFont* font;
@property(nonatomic,retain) UIColor* textColor;
@property(nonatomic,retain) UIColor* spotlightColor;
@property(nonatomic) UITextAlignment textAlignment;
- (void)startAnimating;
- (void)stopAnimating;
@end
| 28.666667 | 75 | 0.758306 |
bd07d4af503aeafd826d9a009280f8c4085f47ed | 15,631 | c | C | alsa-lib-1.1.3/src/control/control_shm.c | Xartos/ALSA_MIDI_Synth | b6b6585f375edee514ee7e9bc5888ed071d9ef41 | [
"MIT"
] | null | null | null | alsa-lib-1.1.3/src/control/control_shm.c | Xartos/ALSA_MIDI_Synth | b6b6585f375edee514ee7e9bc5888ed071d9ef41 | [
"MIT"
] | null | null | null | alsa-lib-1.1.3/src/control/control_shm.c | Xartos/ALSA_MIDI_Synth | b6b6585f375edee514ee7e9bc5888ed071d9ef41 | [
"MIT"
] | null | null | null | /*
* Control - SHM Client
* Copyright (c) 2000 by Abramo Bagnara <abramo@alsa-project.org>
*
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <sys/shm.h>
#include <sys/socket.h>
#include <sys/poll.h>
#include <sys/un.h>
#include <sys/uio.h>
#include <sys/mman.h>
#include <netinet/in.h>
#include <netdb.h>
#include "aserver.h"
#ifndef PIC
/* entry for static linking */
const char *_snd_module_control_shm = "";
#endif
#ifndef DOC_HIDDEN
typedef struct {
int socket;
volatile snd_ctl_shm_ctrl_t *ctrl;
} snd_ctl_shm_t;
#endif
static int snd_ctl_shm_action(snd_ctl_t *ctl)
{
snd_ctl_shm_t *shm = ctl->private_data;
int err;
char buf[1];
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
err = write(shm->socket, buf, 1);
if (err != 1)
return -EBADFD;
err = read(shm->socket, buf, 1);
if (err != 1)
return -EBADFD;
if (ctrl->cmd) {
SNDERR("Server has not done the cmd");
return -EBADFD;
}
return ctrl->result;
}
static int snd_ctl_shm_action_fd(snd_ctl_t *ctl, int *fd)
{
snd_ctl_shm_t *shm = ctl->private_data;
int err;
char buf[1];
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
err = write(shm->socket, buf, 1);
if (err != 1)
return -EBADFD;
err = snd_receive_fd(shm->socket, buf, 1, fd);
if (err != 1)
return -EBADFD;
if (ctrl->cmd) {
SNDERR("Server has not done the cmd");
return -EBADFD;
}
return ctrl->result;
}
static int snd_ctl_shm_close(snd_ctl_t *ctl)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int result;
ctrl->cmd = SND_CTL_IOCTL_CLOSE;
result = snd_ctl_shm_action(ctl);
shmdt((void *)ctrl);
close(shm->socket);
free(shm);
return result;
}
static int snd_ctl_shm_nonblock(snd_ctl_t *handle ATTRIBUTE_UNUSED, int nonblock ATTRIBUTE_UNUSED)
{
return 0;
}
static int snd_ctl_shm_async(snd_ctl_t *ctl, int sig, pid_t pid)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
ctrl->cmd = SND_CTL_IOCTL_ASYNC;
ctrl->u.async.sig = sig;
if (pid == 0)
pid = getpid();
ctrl->u.async.pid = pid;
return snd_ctl_shm_action(ctl);
}
static int snd_ctl_shm_poll_descriptor(snd_ctl_t *ctl)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int fd, err;
ctrl->cmd = SND_CTL_IOCTL_POLL_DESCRIPTOR;
err = snd_ctl_shm_action_fd(ctl, &fd);
if (err < 0)
return err;
return fd;
}
static int snd_ctl_shm_subscribe_events(snd_ctl_t *ctl, int subscribe)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
ctrl->cmd = SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS;
ctrl->u.subscribe_events = subscribe;
return snd_ctl_shm_action(ctl);
}
static int snd_ctl_shm_card_info(snd_ctl_t *ctl, snd_ctl_card_info_t *info)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
// ctrl->u.card_info = *info;
ctrl->cmd = SNDRV_CTL_IOCTL_CARD_INFO;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
*info = ctrl->u.card_info;
return err;
}
static int snd_ctl_shm_elem_list(snd_ctl_t *ctl, snd_ctl_elem_list_t *list)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
size_t maxsize = CTL_SHM_DATA_MAXLEN;
size_t bytes = list->space * sizeof(*list->pids);
int err;
snd_ctl_elem_id_t *pids = list->pids;
if (bytes > maxsize)
return -EINVAL;
ctrl->u.element_list = *list;
ctrl->cmd = SNDRV_CTL_IOCTL_ELEM_LIST;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
*list = ctrl->u.element_list;
list->pids = pids;
bytes = list->used * sizeof(*list->pids);
memcpy(pids, (void *)ctrl->data, bytes);
return err;
}
static int snd_ctl_shm_elem_info(snd_ctl_t *ctl, snd_ctl_elem_info_t *info)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.element_info = *info;
ctrl->cmd = SNDRV_CTL_IOCTL_ELEM_INFO;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
*info = ctrl->u.element_info;
return err;
}
static int snd_ctl_shm_elem_read(snd_ctl_t *ctl, snd_ctl_elem_value_t *control)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.element_read = *control;
ctrl->cmd = SNDRV_CTL_IOCTL_ELEM_READ;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
*control = ctrl->u.element_read;
return err;
}
static int snd_ctl_shm_elem_write(snd_ctl_t *ctl, snd_ctl_elem_value_t *control)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.element_write = *control;
ctrl->cmd = SNDRV_CTL_IOCTL_ELEM_WRITE;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
*control = ctrl->u.element_write;
return err;
}
static int snd_ctl_shm_elem_lock(snd_ctl_t *ctl, snd_ctl_elem_id_t *id)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.element_lock = *id;
ctrl->cmd = SNDRV_CTL_IOCTL_ELEM_LOCK;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
*id = ctrl->u.element_lock;
return err;
}
static int snd_ctl_shm_elem_unlock(snd_ctl_t *ctl, snd_ctl_elem_id_t *id)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.element_unlock = *id;
ctrl->cmd = SNDRV_CTL_IOCTL_ELEM_UNLOCK;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
*id = ctrl->u.element_unlock;
return err;
}
static int snd_ctl_shm_hwdep_next_device(snd_ctl_t *ctl, int * device)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.device = *device;
ctrl->cmd = SNDRV_CTL_IOCTL_HWDEP_NEXT_DEVICE;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
*device = ctrl->u.device;
return err;
}
static int snd_ctl_shm_hwdep_info(snd_ctl_t *ctl, snd_hwdep_info_t * info)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.hwdep_info = *info;
ctrl->cmd = SNDRV_CTL_IOCTL_HWDEP_INFO;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
*info = ctrl->u.hwdep_info;
return err;
}
static int snd_ctl_shm_pcm_next_device(snd_ctl_t *ctl, int * device)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.device = *device;
ctrl->cmd = SNDRV_CTL_IOCTL_PCM_NEXT_DEVICE;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
*device = ctrl->u.device;
return err;
}
static int snd_ctl_shm_pcm_info(snd_ctl_t *ctl, snd_pcm_info_t * info)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.pcm_info = *info;
ctrl->cmd = SNDRV_CTL_IOCTL_PCM_INFO;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
*info = ctrl->u.pcm_info;
return err;
}
static int snd_ctl_shm_pcm_prefer_subdevice(snd_ctl_t *ctl, int subdev)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.pcm_prefer_subdevice = subdev;
ctrl->cmd = SNDRV_CTL_IOCTL_PCM_PREFER_SUBDEVICE;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
return err;
}
static int snd_ctl_shm_rawmidi_next_device(snd_ctl_t *ctl, int * device)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.device = *device;
ctrl->cmd = SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
*device = ctrl->u.device;
return err;
}
static int snd_ctl_shm_rawmidi_info(snd_ctl_t *ctl, snd_rawmidi_info_t * info)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.rawmidi_info = *info;
ctrl->cmd = SNDRV_CTL_IOCTL_RAWMIDI_INFO;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
*info = ctrl->u.rawmidi_info;
return err;
}
static int snd_ctl_shm_rawmidi_prefer_subdevice(snd_ctl_t *ctl, int subdev)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.rawmidi_prefer_subdevice = subdev;
ctrl->cmd = SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
return err;
}
static int snd_ctl_shm_set_power_state(snd_ctl_t *ctl, unsigned int state)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->u.power_state = state;
ctrl->cmd = SNDRV_CTL_IOCTL_POWER;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
return err;
}
static int snd_ctl_shm_get_power_state(snd_ctl_t *ctl, unsigned int *state)
{
snd_ctl_shm_t *shm = ctl->private_data;
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
int err;
ctrl->cmd = SNDRV_CTL_IOCTL_POWER_STATE;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
*state = ctrl->u.power_state;
return err;
}
static int snd_ctl_shm_read(snd_ctl_t *ctl, snd_ctl_event_t *event)
{
snd_ctl_shm_t *shm;
volatile snd_ctl_shm_ctrl_t *ctrl;
int err;
err = snd_ctl_wait(ctl, -1);
if (err < 0)
return 0;
shm = ctl->private_data;
ctrl = shm->ctrl;
ctrl->u.read = *event;
ctrl->cmd = SND_CTL_IOCTL_READ;
err = snd_ctl_shm_action(ctl);
if (err < 0)
return err;
*event = ctrl->u.read;
return err;
}
static const snd_ctl_ops_t snd_ctl_shm_ops = {
.close = snd_ctl_shm_close,
.nonblock = snd_ctl_shm_nonblock,
.async = snd_ctl_shm_async,
.subscribe_events = snd_ctl_shm_subscribe_events,
.card_info = snd_ctl_shm_card_info,
.element_list = snd_ctl_shm_elem_list,
.element_info = snd_ctl_shm_elem_info,
.element_read = snd_ctl_shm_elem_read,
.element_write = snd_ctl_shm_elem_write,
.element_lock = snd_ctl_shm_elem_lock,
.element_unlock = snd_ctl_shm_elem_unlock,
.hwdep_next_device = snd_ctl_shm_hwdep_next_device,
.hwdep_info = snd_ctl_shm_hwdep_info,
.pcm_next_device = snd_ctl_shm_pcm_next_device,
.pcm_info = snd_ctl_shm_pcm_info,
.pcm_prefer_subdevice = snd_ctl_shm_pcm_prefer_subdevice,
.rawmidi_next_device = snd_ctl_shm_rawmidi_next_device,
.rawmidi_info = snd_ctl_shm_rawmidi_info,
.rawmidi_prefer_subdevice = snd_ctl_shm_rawmidi_prefer_subdevice,
.set_power_state = snd_ctl_shm_set_power_state,
.get_power_state = snd_ctl_shm_get_power_state,
.read = snd_ctl_shm_read,
};
static int make_local_socket(const char *filename)
{
size_t l = strlen(filename);
size_t size = offsetof(struct sockaddr_un, sun_path) + l;
struct sockaddr_un *addr = alloca(size);
int sock;
sock = socket(PF_LOCAL, SOCK_STREAM, 0);
if (sock < 0)
return -errno;
addr->sun_family = AF_LOCAL;
memcpy(addr->sun_path, filename, l);
if (connect(sock, (struct sockaddr *) addr, size) < 0)
return -errno;
return sock;
}
int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *sockname, const char *sname, int mode)
{
snd_ctl_t *ctl;
snd_ctl_shm_t *shm = NULL;
snd_client_open_request_t *req;
snd_client_open_answer_t ans;
size_t snamelen, reqlen;
int err;
int result;
int sock = -1;
snd_ctl_shm_ctrl_t *ctrl = NULL;
snamelen = strlen(sname);
if (snamelen > 255)
return -EINVAL;
result = make_local_socket(sockname);
if (result < 0) {
SNDERR("server for socket %s is not running", sockname);
goto _err;
}
sock = result;
reqlen = sizeof(*req) + snamelen;
req = alloca(reqlen);
memcpy(req->name, sname, snamelen);
req->dev_type = SND_DEV_TYPE_CONTROL;
req->transport_type = SND_TRANSPORT_TYPE_SHM;
req->stream = 0;
req->mode = mode;
req->namelen = snamelen;
err = write(sock, req, reqlen);
if (err < 0) {
SNDERR("write error");
result = -errno;
goto _err;
}
if ((size_t) err != reqlen) {
SNDERR("write size error");
result = -EINVAL;
goto _err;
}
err = read(sock, &ans, sizeof(ans));
if (err < 0) {
SNDERR("read error");
result = -errno;
goto _err;
}
if (err != sizeof(ans)) {
SNDERR("read size error");
result = -EINVAL;
goto _err;
}
result = ans.result;
if (result < 0)
goto _err;
ctrl = shmat(ans.cookie, 0, 0);
if (!ctrl) {
result = -errno;
goto _err;
}
shm = calloc(1, sizeof(snd_ctl_shm_t));
if (!shm) {
result = -ENOMEM;
goto _err;
}
shm->socket = sock;
shm->ctrl = ctrl;
err = snd_ctl_new(&ctl, SND_CTL_TYPE_SHM, name);
if (err < 0) {
result = err;
goto _err;
}
ctl->ops = &snd_ctl_shm_ops;
ctl->private_data = shm;
err = snd_ctl_shm_poll_descriptor(ctl);
if (err < 0) {
snd_ctl_close(ctl);
return err;
}
ctl->poll_fd = err;
*handlep = ctl;
return 0;
_err:
close(sock);
if (ctrl)
shmdt(ctrl);
free(shm);
return result;
}
int _snd_ctl_shm_open(snd_ctl_t **handlep, char *name, snd_config_t *root, snd_config_t *conf, int mode)
{
snd_config_iterator_t i, next;
const char *server = NULL;
const char *ctl_name = NULL;
snd_config_t *sconfig;
const char *sockname = NULL;
long port = -1;
int err;
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id;
if (snd_config_get_id(n, &id) < 0)
continue;
if (_snd_conf_generic_id(id))
if (strcmp(id, "server") == 0) {
err = snd_config_get_string(n, &server);
if (err < 0) {
SNDERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
if (strcmp(id, "ctl") == 0) {
err = snd_config_get_string(n, &ctl_name);
if (err < 0) {
SNDERR("Invalid type for %s", id);
return -EINVAL;
}
continue;
}
SNDERR("Unknown field %s", id);
return -EINVAL;
}
if (!ctl_name) {
SNDERR("ctl is not defined");
return -EINVAL;
}
if (!server) {
SNDERR("server is not defined");
return -EINVAL;
}
err = snd_config_search_definition(root, "server", server, &sconfig);
if (err < 0) {
SNDERR("Unknown server %s", server);
return -EINVAL;
}
if (snd_config_get_type(sconfig) != SND_CONFIG_TYPE_COMPOUND) {
SNDERR("Invalid type for server %s definition", server);
err = -EINVAL;
goto _err;
}
snd_config_for_each(i, next, sconfig) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id;
if (snd_config_get_id(n, &id) < 0)
continue;
if (_snd_conf_generic_id(id))
continue;
if (strcmp(id, "host") == 0)
continue;
if (strcmp(id, "socket") == 0) {
err = snd_config_get_string(n, &sockname);
if (err < 0) {
SNDERR("Invalid type for %s", id);
goto _err;
}
continue;
}
if (strcmp(id, "port") == 0) {
err = snd_config_get_integer(n, &port);
if (err < 0) {
SNDERR("Invalid type for %s", id);
goto _err;
}
continue;
}
SNDERR("Unknown field %s", id);
err = -EINVAL;
goto _err;
}
if (!sockname) {
SNDERR("socket is not defined");
goto _err;
}
err = snd_ctl_shm_open(handlep, name, sockname, ctl_name, mode);
_err:
snd_config_delete(sconfig);
return err;
}
SND_DLSYM_BUILD_VERSION(_snd_ctl_shm_open, SND_CONTROL_DLSYM_VERSION);
| 24.732595 | 110 | 0.710447 |
bd0819cc24e3a0fe1a6c5a4c4d5dac656994a5b4 | 11,173 | c | C | cfe-eds/osal/src/ut-stubs/osapi-utstub-task.c | OpenSatKit/Runtime-Env | 08d5c4146b06cb7b633d3fec2f58d782798954d4 | [
"Apache-2.0"
] | 2 | 2020-06-17T20:30:28.000Z | 2020-12-28T18:42:46.000Z | cfe-eds/osal/src/ut-stubs/osapi-utstub-task.c | OpenSatKit/Runtime-Env | 08d5c4146b06cb7b633d3fec2f58d782798954d4 | [
"Apache-2.0"
] | 7 | 2020-07-23T17:14:46.000Z | 2020-09-17T00:25:08.000Z | osal/src/ut-stubs/osapi-utstub-task.c | McMasterNEUDOSE/cFS | 9e991aa05da8df102943498ec3281d0f91d134e1 | [
"Apache-2.0"
] | 2 | 2021-01-21T16:18:16.000Z | 2021-02-10T23:05:51.000Z | /*
* NASA Docket No. GSC-18,370-1, and identified as "Operating System Abstraction Layer"
*
* Copyright (c) 2019 United States Government as represented by
* the Administrator of the National Aeronautics and Space Administration.
* All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* \file osapi_stubs.c
*
* Created on: Feb 25, 2015
* Author: joseph.p.hickey@nasa.gov
*
* Stub implementations for the functions defined in the OSAL API
*
* The stub implementation can be used for unit testing applications built
* on top of OSAL. The stubs do not do any real function, but allow
* the return code to be crafted such that error paths in the application
* can be executed.
*/
#include "utstub-helpers.h"
UT_DEFAULT_STUB(OS_TaskAPI_Init,(void))
/*****************************************************************************/
/**
** \brief OS_TaskCreate stub function
**
** \par Description
** This function is used to mimic the response of the OS API function
** OS_TaskCreate. The user can adjust the response by setting the value
** of UT_OS_Fail prior to this function being called.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \returns
** Returns either OS_SUCCESS or OS_ERROR.
**
******************************************************************************/
int32 OS_TaskCreate(uint32 *task_id, const char *task_name,
osal_task_entry function_pointer,
uint32 *stack_pointer,
uint32 stack_size, uint32 priority,
uint32 flags)
{
UT_Stub_RegisterContext(UT_KEY(OS_TaskCreate), task_id);
UT_Stub_RegisterContext(UT_KEY(OS_TaskCreate), task_name);
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TaskCreate), function_pointer);
UT_Stub_RegisterContext(UT_KEY(OS_TaskCreate), stack_pointer);
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TaskCreate), stack_size);
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TaskCreate), priority);
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TaskCreate), flags);
int32 status;
status = UT_DEFAULT_IMPL(OS_TaskCreate);
if (status == OS_SUCCESS)
{
*task_id = UT_AllocStubObjId(UT_OBJTYPE_TASK);
}
else
{
*task_id = 0xDEADBEEFU;
}
return status;
}
/*****************************************************************************/
/**
** \brief OS_TaskDelete stub function
**
** \par Description
** This function is used to mimic the response of the OS API function
** OS_TaskDelete. The user can adjust the response by
** setting the value of UT_OS_Fail prior to this function being called.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \returns
** Returns either OS_SUCCESS or OS_ERROR.
**
******************************************************************************/
int32 OS_TaskDelete(uint32 task_id)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TaskDelete), task_id);
int32 status;
status = UT_DEFAULT_IMPL(OS_TaskDelete);
if (status == OS_SUCCESS)
{
UT_DeleteStubObjId(UT_OBJTYPE_TASK, task_id);
}
return status;
}
/*****************************************************************************/
/**
** \brief OS_TaskExit stub function
**
** \par Description
** This function is used to mimic the response of the OS API function
** OS_TaskExit.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \returns
** This function does not return a value.
**
******************************************************************************/
void OS_TaskExit()
{
/* Although this has no retcode, invoke the hooks provided in the default impl.
* NOTE: historically CFE UT checks for a "1" output via its sideband methods. */
UT_DEFAULT_IMPL_RC(OS_TaskExit, 1);
}
/*****************************************************************************/
/**
** \brief OS_TaskDelay stub function
**
** \par Description
** This function is used to mimic the response of the OS API function
** OS_TaskDelay. The user can adjust the response by setting the value
** of UT_OS_Fail prior to this function being called.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \returns
** Returns either OS_SUCCESS or OS_ERROR.
**
******************************************************************************/
int32 OS_TaskDelay(uint32 millisecond)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TaskDelay), millisecond);
int32 status;
status = UT_DEFAULT_IMPL(OS_TaskDelay);
return status;
}
/*****************************************************************************
*
* Stub function for OS_TaskSetPriority()
*
*****************************************************************************/
int32 OS_TaskSetPriority (uint32 task_id, uint32 new_priority)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TaskSetPriority), task_id);
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TaskSetPriority), new_priority);
int32 status;
status = UT_DEFAULT_IMPL(OS_TaskSetPriority);
return status;
}
/*****************************************************************************/
/**
** \brief OS_TaskRegister stub function
**
** \par Description
** This function is used to mimic the response of the OS API function
** OS_TaskRegister. The user can adjust the response by setting the value
** of UT_OS_Fail prior to this function being called.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \returns
** Returns either OS_SUCCESS or OS_ERROR.
**
******************************************************************************/
int32 OS_TaskRegister(void)
{
int32 status;
status = UT_DEFAULT_IMPL(OS_TaskRegister);
return status;
}
/*****************************************************************************/
/**
** \brief OS_TaskGetId stub function
**
** \par Description
** This function is used as a placeholder for the OS API function
** OS_TaskGetId.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \returns
** Returns 1 unless an override value is configured.
**
******************************************************************************/
uint32 OS_TaskGetId(void)
{
int32 TaskId;
TaskId = 1;
UT_FIXUP_ID(TaskId, UT_OBJTYPE_TASK);
TaskId = UT_DEFAULT_IMPL_RC(OS_TaskGetId, TaskId);
return TaskId;
}
/*****************************************************************************
*
* Stub function for OS_TaskGetIdByName()
*
*****************************************************************************/
int32 OS_TaskGetIdByName (uint32 *task_id, const char *task_name)
{
UT_Stub_RegisterContext(UT_KEY(OS_TaskGetIdByName), task_id);
UT_Stub_RegisterContext(UT_KEY(OS_TaskGetIdByName), task_name);
int32 status;
status = UT_DEFAULT_IMPL(OS_TaskGetIdByName);
if (status == OS_SUCCESS &&
UT_Stub_CopyToLocal(UT_KEY(OS_TaskGetIdByName), task_id, sizeof(*task_id)) < sizeof(*task_id))
{
*task_id = 1;
UT_FIXUP_ID(*task_id, UT_OBJTYPE_TASK);
}
return status;
}
/*****************************************************************************/
/**
** \brief OS_TaskGetInfo stub function
**
** \par Description
** This function is used to mimic the response of the OS API function
** OS_TaskGetInfo. If the input structure, task_prop, is null, it
** returns OS_INVALID_POINTER. Otherwise it sets the task structure
** variables to fixed values and returns OS_SUCCESS.
**
** \par Assumptions, External Events, and Notes:
** None
**
** \returns
** Returns either OS_INVALID_POINTER or OS_SUCCESS.
**
******************************************************************************/
int32 OS_TaskGetInfo(uint32 task_id, OS_task_prop_t *task_prop)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TaskGetInfo), task_id);
UT_Stub_RegisterContext(UT_KEY(OS_TaskGetInfo), task_prop);
int32 status;
status = UT_DEFAULT_IMPL(OS_TaskGetInfo);
if (status == OS_SUCCESS &&
UT_Stub_CopyToLocal(UT_KEY(OS_TaskGetInfo), task_prop, sizeof(*task_prop)) < sizeof(*task_prop))
{
task_prop->creator = 1;
UT_FIXUP_ID(task_prop->creator, UT_OBJTYPE_TASK);
task_prop->stack_size = 100;
task_prop->priority = 150;
strncpy(task_prop->name, "UnitTest", OS_MAX_API_NAME - 1);
task_prop->name[OS_MAX_API_NAME - 1] = '\0';
}
return status;
}
/*****************************************************************************/
/**
** \brief OS_TaskGetInfo stub function
**
** \par Description
** This function is used to mimic the response of the OS API function
** OS_TaskFindIdBySystemData.
**
** \returns
** The return value instructed by the test case setup
**
******************************************************************************/
int32 OS_TaskFindIdBySystemData(uint32 *task_id, const void *sysdata, size_t sysdata_size)
{
UT_Stub_RegisterContext(UT_KEY(OS_TaskFindIdBySystemData), task_id);
UT_Stub_RegisterContext(UT_KEY(OS_TaskFindIdBySystemData), sysdata);
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TaskFindIdBySystemData), sysdata_size);
int32 status;
status = UT_DEFAULT_IMPL(OS_TaskFindIdBySystemData);
if (status == OS_SUCCESS &&
UT_Stub_CopyToLocal(UT_KEY(OS_TaskFindIdBySystemData), task_id, sizeof(*task_id)) < sizeof(*task_id))
{
*task_id = 1;
UT_FIXUP_ID(*task_id, UT_OBJTYPE_TASK);
}
return status;
}
/*****************************************************************************
*
* Stub function for OS_TaskInstallDeleteHandler()
*
*****************************************************************************/
int32 OS_TaskInstallDeleteHandler(osal_task_entry function_pointer)
{
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_TaskInstallDeleteHandler), function_pointer);
int32 status;
status = UT_DEFAULT_IMPL(OS_TaskInstallDeleteHandler);
return (status);
}
/*****************************************************************************
*
* Stub function for OS_TaskEntryPoint()
*
* This is an internal function but it needs a stub in order to test
* the low level implementation that uses the shared layer.
*
*****************************************************************************/
void OS_TaskEntryPoint(uint32 task_id)
{
UT_DEFAULT_IMPL(OS_TaskEntryPoint);
}
| 30.695055 | 113 | 0.580328 |
bd082eaec1a3b58834ab17af7cabd2aac96d31c1 | 2,606 | h | C | hyperCore/include/Basic/Logger.h | sadcatsoft/hyperui | f26242a9034ad1e0abf54bd7691fe48809262f5b | [
"MIT"
] | 2 | 2019-05-17T16:16:21.000Z | 2019-08-21T20:18:22.000Z | hyperUI/python/dist/mac/hyperui/HyperCore.framework/Versions/A/Headers/Basic/Logger.h | sadcatsoft/hyperui | f26242a9034ad1e0abf54bd7691fe48809262f5b | [
"MIT"
] | 1 | 2018-10-18T22:05:12.000Z | 2018-10-18T22:05:12.000Z | hyperUI/python/dist/mac/hyperui/HyperCore.framework/Versions/A/Headers/Basic/Logger.h | sadcatsoft/hyperui | f26242a9034ad1e0abf54bd7691fe48809262f5b | [
"MIT"
] | null | null | null | /*****************************************************************************
Disclaimer: This software is supplied to you by Sad Cat Software
("Sad Cat") in consideration of your agreement to the following terms, and
your use, installation, modification or redistribution of this Sad Cat software
constitutes acceptance of these terms. If you do not agree with these terms,
please do not use, install, modify or redistribute this Sad Cat software.
This software is provided "as is". Sad Cat Software makes no warranties,
express or implied, including without limitation the implied warranties
of non-infringement, merchantability and fitness for a particular
purpose, regarding Sad Cat's software or its use and operation alone
or in combination with other hardware or software products.
In no event shall Sad Cat Software be liable for any special, indirect,
incidental, or consequential damages (including, but not limited to,
procurement of substitute goods or services; loss of use, data, or profits;
or business interruption) arising in any way out of the use, reproduction,
modification and/or distribution of Sad Cat's software however caused and
whether under theory of contract, tort (including negligence), strict
liability or otherwise, even if Sad Cat Software has been advised of the
possibility of such damage.
Copyright (C) 2012, Sad Cat Software. All Rights Reserved.
*****************************************************************************/
#pragma once
#define DEFAULT_MAX_LINES 400
/*****************************************************************************/
enum LogLevelType
{
LogLevelSystem = 0x0001,
LogLevelUser = 0x0002,
LogLevelError = 0x0004,
};
#define LOG_LEVEL_ALL (0xFFFFFFFF)
#define LOG_LEVEL_ALL_EXCEPT_USER ((LOG_LEVEL_ALL) & (~LogLevelUser))
/*****************************************************************************/
struct SLogItem
{
SLogItem() { myLevel = LogLevelSystem; }
string myValue;
LogLevelType myLevel;
};
typedef list < SLogItem > TLogItemList;
/*****************************************************************************/
class HYPERCORE_API Logger
{
public:
static void log(const char* format, ...);
static void log(LogLevelType eLogLevel, const char* format, ...);
static void getAsString(string& strOut, int iLogLevel = LOG_LEVEL_ALL_EXCEPT_USER, int iMaxRecordsToGet = DEFAULT_MAX_LINES);
private:
static TLogItemList theLog;
static Mutex theInternalsLock;
};
/*****************************************************************************/ | 41.365079 | 127 | 0.62548 |
bd08a38dac0d710b0d30576038dae33a88e379bf | 10,173 | h | C | CallTraceForWeChat/CallTraceForWeChat/WeChat_Headers/WAMainListViewController.h | ceekay1991/CallTraceForWeChat | 5767cb6f781821b6bf9facc8c87e58e15fa88541 | [
"MIT"
] | 30 | 2020-03-22T12:30:21.000Z | 2022-02-09T08:49:13.000Z | CallTraceForWeChat/CallTraceForWeChat/WeChat_Headers/WAMainListViewController.h | ceekay1991/CallTraceForWeChat | 5767cb6f781821b6bf9facc8c87e58e15fa88541 | [
"MIT"
] | null | null | null | CallTraceForWeChat/CallTraceForWeChat/WeChat_Headers/WAMainListViewController.h | ceekay1991/CallTraceForWeChat | 5767cb6f781821b6bf9facc8c87e58e15fa88541 | [
"MIT"
] | 8 | 2020-03-22T12:30:23.000Z | 2020-09-22T04:01:47.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 "MMUIViewController.h"
#import "IWAAppEntryExtension-Protocol.h"
#import "MMUIViewControllerTransitionInfo-Protocol.h"
#import "MMWebViewDelegate-Protocol.h"
#import "UITableViewDataSource-Protocol.h"
#import "UITableViewDelegate-Protocol.h"
#import "UIViewControllerAnimatedTransitioning-Protocol.h"
#import "WAAppItemManagerExtension-Protocol.h"
#import "WAContactMgrExtension-Protocol.h"
#import "WAMainListNearByLogicDelegate-Protocol.h"
#import "WAMainListPageLogicDelegate-Protocol.h"
#import "WAMainListStarLogicDelegate-Protocol.h"
#import "WAPermissionMgrExtension-Protocol.h"
#import "WASearchControllerDelegate-Protocol.h"
#import "WCActionSheetDelegate-Protocol.h"
@class MMTableView, MMToastViewController, NSDictionary, NSMutableArray, NSMutableDictionary, NSString, UIButton, UIImageView, UIPercentDrivenInteractiveTransition, UISearchBar, UIView, UIViewController, WAAppItemData, WAMainListNearByLogic, WAMainListPageLogic, WAMainListStarLogic, WAOrderInfoLogic, WAPackageSweeperLogic, WASearchController;
@interface WAMainListViewController : MMUIViewController <UITableViewDataSource, UITableViewDelegate, WAContactMgrExtension, WCActionSheetDelegate, WAAppItemManagerExtension, WASearchControllerDelegate, IWAAppEntryExtension, WAMainListPageLogicDelegate, WAMainListNearByLogicDelegate, WAMainListStarLogicDelegate, WAPermissionMgrExtension, MMWebViewDelegate, UIViewControllerAnimatedTransitioning, MMUIViewControllerTransitionInfo>
{
NSMutableArray *m_unStarHistoryItemMenuArray;
NSMutableArray *m_staredHistoryItemMenuArray;
NSMutableDictionary *m_contactViewCache;
WAAppItemData *m_appItemToDelete;
WAAppItemData *m_starItemToDelete;
WAPackageSweeperLogic *m_sweepLogic;
NSString *m_showSessionId;
_Bool _isShowSearchBar;
NSMutableArray *m_sessionData;
_Bool _isViewHasLayout;
_Bool _hasClickHistoryItem;
_Bool _hasClickNearBySection;
_Bool _isViewAppeared;
UIView *_movingFakeCell;
_Bool _lastSearchBarStatus;
_Bool _isDuringSearch;
UIButton *_euSearchBarHitBtn;
_Bool _needLogRedDot;
_Bool _tmpUseForMainFrameSearch;
_Bool _needTargetToHistory;
unsigned int _onRedDotTime;
int _m_searchScene;
unsigned long long m_scene;
NSString *m_relatedUserName;
NSString *m_sceneNote;
UIPercentDrivenInteractiveTransition *_interactiveTransition;
UIViewController *_animatedTransitionRespondViewController;
WASearchController *_searchController;
UISearchBar *_searchBar;
MMTableView *_tableView;
MMToastViewController *_toastView;
UIView *_emptyView;
NSDictionary *_searchResult;
WAMainListPageLogic *_pageLogic;
WAMainListNearByLogic *_nearByLogic;
WAMainListStarLogic *_starLogic;
UIButton *_entryForSearchApp;
UIImageView *_entryImageViewForSearchApp;
WAOrderInfoLogic *_orderLogic;
}
@property(retain, nonatomic) WAOrderInfoLogic *orderLogic; // @synthesize orderLogic=_orderLogic;
@property(retain, nonatomic) UIImageView *entryImageViewForSearchApp; // @synthesize entryImageViewForSearchApp=_entryImageViewForSearchApp;
@property(retain, nonatomic) UIButton *entryForSearchApp; // @synthesize entryForSearchApp=_entryForSearchApp;
@property(retain, nonatomic) WAMainListStarLogic *starLogic; // @synthesize starLogic=_starLogic;
@property(retain, nonatomic) WAMainListNearByLogic *nearByLogic; // @synthesize nearByLogic=_nearByLogic;
@property(retain, nonatomic) WAMainListPageLogic *pageLogic; // @synthesize pageLogic=_pageLogic;
@property(retain, nonatomic) NSDictionary *searchResult; // @synthesize searchResult=_searchResult;
@property(retain, nonatomic) UIView *emptyView; // @synthesize emptyView=_emptyView;
@property(retain, nonatomic) MMToastViewController *toastView; // @synthesize toastView=_toastView;
@property(retain, nonatomic) MMTableView *tableView; // @synthesize tableView=_tableView;
@property(retain, nonatomic) UISearchBar *searchBar; // @synthesize searchBar=_searchBar;
@property(retain, nonatomic) WASearchController *searchController; // @synthesize searchController=_searchController;
@property(nonatomic) int m_searchScene; // @synthesize m_searchScene=_m_searchScene;
@property(nonatomic) _Bool needTargetToHistory; // @synthesize needTargetToHistory=_needTargetToHistory;
@property(nonatomic) _Bool tmpUseForMainFrameSearch; // @synthesize tmpUseForMainFrameSearch=_tmpUseForMainFrameSearch;
@property(nonatomic) __weak UIViewController *animatedTransitionRespondViewController; // @synthesize animatedTransitionRespondViewController=_animatedTransitionRespondViewController;
@property(retain, nonatomic) UIPercentDrivenInteractiveTransition *interactiveTransition; // @synthesize interactiveTransition=_interactiveTransition;
@property(nonatomic) unsigned int onRedDotTime; // @synthesize onRedDotTime=_onRedDotTime;
@property(nonatomic) _Bool needLogRedDot; // @synthesize needLogRedDot=_needLogRedDot;
@property(copy, nonatomic) NSString *m_sceneNote; // @synthesize m_sceneNote;
@property(copy, nonatomic) NSString *m_relatedUserName; // @synthesize m_relatedUserName;
@property(nonatomic) unsigned long long m_scene; // @synthesize m_scene;
- (void).cxx_destruct;
- (void)onTextFieldMarkedTextChanged:(id)arg1;
- (id)onWebViewPassParams:(id)arg1 Webview:(id)arg2;
- (void)animateTransition:(id)arg1;
- (double)transitionDuration:(id)arg1;
- (id)mmNavigationController:(id)arg1 interactionControllerForAnimationController:(id)arg2;
- (id)mmNavigationController:(id)arg1 animationControllerForOperation:(long long)arg2 fromViewController:(id)arg3 toViewController:(id)arg4;
- (void)onLaunchPermissionUpdateHistoryList:(id)arg1;
- (id)getBottomView;
- (void)fixTableViewAndSearchBarPos;
- (void)fixTableViewOffset;
- (void)waSearchBarDidEndEditting:(id)arg1;
- (void)waSearchBarDidBeginEditting:(id)arg1;
- (void)searchTextChanged:(id)arg1;
- (void)didEndSearch;
- (void)willEndSearch;
- (void)willBeginSearch;
- (_Bool)isInSearch;
- (void)reportDestopOpWithAppItem:(id)arg1 eventId:(unsigned long long)arg2;
- (void)reportDestopStateWhenViewAppear;
- (void)onWeAppItemOpened:(id)arg1;
- (void)openStarListView;
- (id)genStaredHistoryItemMenuArray;
- (id)genUnStarHistoryItemMenuArray;
- (_Bool)hasRunningAppTask;
- (id)getContactByUserName:(id)arg1;
- (void)reloadTableViewNonAnimated;
- (void)reloadTableView;
- (void)showTipsViewController:(id)arg1;
- (void)showToast:(id)arg1;
- (void)deleteHistoryItem:(id)arg1 atIndex:(unsigned long long)arg2;
- (void)deleteStarItem:(id)arg1 atIndex:(unsigned long long)arg2;
- (void)unstarAppItem:(id)arg1 atIndexPath:(id)arg2;
- (void)starAppItem:(id)arg1 atIndexPath:(id)arg2;
- (void)onDeleteStaredItem:(id)arg1 atIndexPath:(id)arg2;
- (void)onDeleteAppListItemAtIndexPath:(id)arg1 appItem:(id)arg2;
- (void)requestOrderInfo;
- (void)onSearchPlaceHolderUpdate:(id)arg1;
- (void)checkAndUpdateContactForUsernameInList:(id)arg1;
- (void)checkAndUpdateContactInList:(id)arg1;
- (void)onModifyWeAppContact:(id)arg1;
- (id)tranferDynamicViewModelFromNearByInfo:(id)arg1;
- (void)onOpenNearWeApps;
- (void)onClickNearbyCell;
- (void)onGetNearByInfoFailedWithLocationInvalid;
- (void)onGetNearByInfoFailedWithErrCode:(int)arg1;
- (void)onNearByInfoTriggerUpdated;
- (void)onFirstTimeGetNearByInfo;
- (void)onWeAppItemBatchMoved:(id)arg1;
- (void)onWeAppItemUnStared:(id)arg1;
- (void)onWeAppItemStared:(id)arg1;
- (void)starDataDidUpdated;
- (void)appItemDidUnStaredFailedWithUnknownError:(id)arg1;
- (void)appItemDidUnStaredSuccess:(id)arg1;
- (void)appItemDidStaredFailedWithUnknownError:(id)arg1;
- (void)appItemDidStaredFailedWithCountLimit:(id)arg1;
- (void)appItemDidStaredSuccess:(id)arg1;
- (void)didFinishFetchNextPageItemsErrorWithErrCode:(int)arg1;
- (void)didFinishFetchNextPageItems:(id)arg1 pageNum:(unsigned int)arg2 beginPos:(unsigned long long)arg3;
- (long long)tableView:(id)arg1 editingStyleForRowAtIndexPath:(id)arg2;
- (void)tableView:(id)arg1 commitEditingStyle:(long long)arg2 forRowAtIndexPath:(id)arg3;
- (void)tableView:(id)arg1 didSelectRowAtIndexPath:(id)arg2;
- (double)tableView:(id)arg1 heightForRowAtIndexPath:(id)arg2;
- (void)tableView:(id)arg1 willDisplayCell:(id)arg2 forRowAtIndexPath:(id)arg3;
- (double)tableView:(id)arg1 heightForFooterInSection:(long long)arg2;
- (id)tableView:(id)arg1 viewForFooterInSection:(long long)arg2;
- (unsigned int)stateFlagForAppItem:(id)arg1 withIndexPath:(id)arg2;
- (id)tableView:(id)arg1 cellForRowAtIndexPath:(id)arg2;
- (long long)tableView:(id)arg1 numberOfRowsInSection:(long long)arg2;
- (long long)numberOfSectionsInTableView:(id)arg1;
- (void)updateViewStates;
- (void)loadMoreIfNeeded;
- (void)actionSheet:(id)arg1 clickedButtonAtIndex:(long long)arg2;
- (void)onMoreOperate;
- (void)onStarBarButton;
- (void)onReturn;
- (unsigned long long)insertNearBySection;
- (void)reloadNearBySection;
- (void)reloadStarSection;
- (void)initEmptyView;
- (void)onEntryForSearchAppBtnClicked:(id)arg1;
- (void)onEuSearchBarHitBtnClick:(id)arg1;
- (void)initSearchController;
- (void)initRefreshControl;
- (void)initTableView;
- (void)updateNavigationItems;
- (void)initCustomNavigationBar;
- (void)setNavigationBarViewsHidden:(_Bool)arg1;
- (void)fixNavigationBarTitle;
- (void)tryFixPicSearchEntry;
- (void)tryFixSearchController;
- (void)viewDidBePoped:(_Bool)arg1;
- (void)viewDidLayoutSubviews;
- (void)viewDidDisappear:(_Bool)arg1;
- (void)viewWillDisappear:(_Bool)arg1;
- (void)viewDidAppear:(_Bool)arg1;
- (void)viewWillAppear:(_Bool)arg1;
- (void)viewDidLoad;
- (void)dealloc;
- (void)updateFooterNoMoreDataState;
- (void)updateRefreshFooterHiddenState;
- (void)updateEmptyViewState;
- (long long)indexOfSessionId:(id)arg1;
- (void)updateSectionData;
- (void)viewDidTransitionToNewSize;
- (void)willChangeToSplitMode;
- (id)init;
// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(readonly) Class superclass;
@end
| 49.144928 | 431 | 0.810872 |
bd0bf9f377172d492f7a8adc4644b51275f4d809 | 12,771 | h | C | hphp/runtime/base/smart_allocator.h | abhishekgahlot/hiphop-php | 5b367ac44a7a9a6e4c777ae0786d1c872d3ae0a9 | [
"PHP-3.01",
"Zend-2.0"
] | 1 | 2015-11-05T19:26:02.000Z | 2015-11-05T19:26:02.000Z | hphp/runtime/base/smart_allocator.h | abhishekgahlot/hiphop-php | 5b367ac44a7a9a6e4c777ae0786d1c872d3ae0a9 | [
"PHP-3.01",
"Zend-2.0"
] | null | null | null | hphp/runtime/base/smart_allocator.h | abhishekgahlot/hiphop-php | 5b367ac44a7a9a6e4c777ae0786d1c872d3ae0a9 | [
"PHP-3.01",
"Zend-2.0"
] | null | null | null | /*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 1998-2010 Zend Technologies Ltd. (http://www.zend.com) |
+----------------------------------------------------------------------+
| This source file is subject to version 2.00 of the Zend license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.zend.com/license/2_00.txt. |
| If you did not receive a copy of the Zend license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@zend.com so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#ifndef incl_HPHP_SMART_ALLOCATOR_H_
#define incl_HPHP_SMART_ALLOCATOR_H_
#include <boost/noncopyable.hpp>
#include <boost/type_traits/is_base_of.hpp>
#include "hphp/util/base.h"
#include "hphp/util/thread_local.h"
#include "hphp/util/stack_trace.h"
#include "hphp/util/lock.h"
#include "hphp/runtime/base/types.h"
#include "hphp/runtime/base/countable.h"
#include "hphp/runtime/base/memory_usage_stats.h"
#include "hphp/util/trace.h"
#include <typeinfo>
namespace HPHP {
#ifdef DEBUG_MEMORY_LEAK
#define DEBUGGING_SMART_ALLOCATOR 1
#endif
//#define DEBUGGING_SMART_ALLOCATOR 1
//#define SMART_ALLOCATOR_DEBUG_FREE
///////////////////////////////////////////////////////////////////////////////
/**
* If a class is using SmartAllocator, all "new" and "delete" should be done
* through these two macros in a form like this,
*
* MyClass *obj = NEW(MyClass)(...);
* DELETE(MyClass)(obj);
*
* Note that these various allocation functions should only be used
* for ObjectData-derived classes. (If you need other
* request-lifetime memory you need to do something else.)
*/
template<class T>
inline void smart_allocator_check_type() {
static_assert((boost::is_base_of<ObjectData,T>::value),
"Non-ObjectData allocated in smart heap");
}
#ifdef DEBUGGING_SMART_ALLOCATOR
#define NEW(T) new T
#define NEWOBJ(T) new T
#define NEWOBJSZ(T,SZ) new (malloc(SZ)) T
#define ALLOCOBJSZ(SZ) (malloc(SZ))
#define ALLOCOBJIDX(I) (malloc(object_alloc_index_to_size(I)))
#define DELETE(T) delete
#define DELETEOBJSZ(SZ) free
#define DELETEOBJ(NS,T,OBJ) delete OBJ
#define RELEASEOBJ(NS,T,OBJ) ::operator delete(OBJ)
#define SWEEPOBJ(T) delete this
#else
#define NEW(T) new (T::AllocatorType::getNoCheck()) T
#define NEWOBJ(T) new \
((smart_allocator_check_type<T>(), ThreadLocalSingleton \
<ObjectAllocator<ObjectSizeClass<sizeof(T)>::value>> \
::getNoCheck())) T
#define NEWOBJSZ(T,SZ) \
new ((smart_allocator_check_type<T>(), info->instanceSizeAllocator(SZ))) T
#define ALLOCOBJSZ(SZ) (ThreadInfo::s_threadInfo.getNoCheck()->\
instanceSizeAllocator(SZ)->alloc())
#define ALLOCOBJIDX(I) (ThreadInfo::s_threadInfo.getNoCheck()-> \
instanceIdxAllocator(I)->alloc())
#define DELETE(T) T::AllocatorType::getNoCheck()->release
#define DELETEOBJSZ(SZ) (ThreadInfo::s_threadInfo.getNoCheck()->\
instanceSizeAllocator(SZ)->release)
#define DELETEOBJ(NS,T,OBJ) delete OBJ
#define RELEASEOBJ(NS,T,OBJ) \
(ThreadLocalSingleton \
<ObjectAllocator<ObjectSizeClass<sizeof(T)>::value>> \
::getNoCheck())->release(OBJ)
#define SWEEPOBJ(T) this->~T()
#endif
///////////////////////////////////////////////////////////////////////////////
/**
* To use this allocator, simply add DECLARE_SMART_ALLOCATION macro to .h and
* add IMPLEMENT_SMART_ALLOCATION macro to .cpp. For example,
*
* class MyClass {
* DECLARE_SMART_ALLOCATION(MyClass);
* };
*
* IMPLEMENT_SMART_ALLOCATION(MyClass);
*/
typedef void (*AllocatorThreadLocalInit)(void);
std::set<AllocatorThreadLocalInit>& GetAllocatorInitList();
void InitAllocatorThreadLocal() ATTRIBUTE_COLD;
#define DECLARE_SMART_ALLOCATION(T) \
public: \
typedef ThreadLocalSingleton<SmartAllocator<T>> AllocatorType; \
static void *SmaAllocatorInitSetup; \
void release();
#define IMPLEMENT_SMART_ALLOCATION(T) \
void *T::SmaAllocatorInitSetup = \
SmartAllocatorInitSetup<T>(); \
void T::release() { \
DELETE(T)(this); \
}
#define IMPLEMENT_SMART_ALLOCATION_HOT(T) \
void *T::SmaAllocatorInitSetup = \
SmartAllocatorInitSetup<T>(); \
HOT_FUNC void T::release() { \
DELETE(T)(this); \
}
#define IMPLEMENT_SMART_ALLOCATION_CLS(C, T) \
void *C::T::SmaAllocatorInitSetup = \
SmartAllocatorInitSetup<C::T>(); \
void C::T::release() { \
DELETE(T)(this); \
}
///////////////////////////////////////////////////////////////////////////////
const uint SLAB_SIZE = 2 << 20;
/**
* Just a simple free-list based memory allocator.
*/
class SmartAllocatorImpl : boost::noncopyable {
public:
struct Iterator;
// Ensure we have room for freelist and _count tombstone
static const size_t MinItemSize = 16;
public:
SmartAllocatorImpl(const std::type_info* typeId, uint itemSize);
int getItemSize() const { return m_itemSize;}
static size_t itemSizeRoundup(size_t n) {
return n >= MinItemSize ? n : MinItemSize;
}
/**
* Allocation/deallocation of object memory.
*/
void* alloc() { return alloc(m_itemSize); }
void* alloc(size_t size);
void dealloc(void *obj) {
TRACE(1, "dealloc %p\n", obj);
assert(memset(obj, kSmartFreeFill, m_itemSize));
m_free.push(obj);
MemoryManager::TheMemoryManager()->getStats().usage -= m_itemSize;
}
void clear() { m_free.clear(); }
/*
* Returns whether the given pointer points into this smart
* allocator (regardless of whether it is already freed).
*/
bool isFromThisAllocator(void*) const { return false; }
const std::type_info& getAllocatorType() const {
assert(m_typeId);
return *m_typeId;
}
// keep these frequently used fields together.
private:
TRACE_SET_MOD(smartalloc);
GarbageList m_free;
const uint m_itemSize;
const std::type_info* m_typeId;
};
/*
* Object for iterating over all unfreed objects in smart allocator.
*
* It is legal to deallocate the currently pointed to element during
* iteration (and will not affect the iteration state). Other changes
* to the allocator during iteration do not have guaranteed behavior.
*
* Nop'd out but still here to keep cycle-gc compiling.
*/
struct SmartAllocatorImpl::Iterator : private boost::noncopyable {
explicit Iterator(const SmartAllocatorImpl*);
void* current() const; // returns 0 when done
void next();
};
///////////////////////////////////////////////////////////////////////////////
// This allocator is for known and fixed sized classes, like StringData or
// ArrayData.
template <typename T>
class SmartAllocator : public SmartAllocatorImpl {
public:
/**
* Specify how many items to allocate a time. The more, the less number of
* times to grow the memory, but the higher chance of increasing memory
* footprint.
*/
SmartAllocator() : SmartAllocatorImpl(&typeid(T), sizeof(T)) {
static_assert(sizeof(T) <= SLAB_SIZE, "slab too small");
}
void release(T *p) {
if (p) {
p->~T();
dealloc(p);
}
}
static void Create(void* storage) {
new (storage) SmartAllocator<T>();
}
static void Delete(SmartAllocator *p) {
p->~SmartAllocator();
}
static void OnThreadExit(SmartAllocator *p) {
p->~SmartAllocator();
}
};
template<typename T>
void *SmartAllocatorInitSetup() {
ThreadLocalSingleton<SmartAllocator<T>> tls;
GetAllocatorInitList().insert((AllocatorThreadLocalInit)(tls.getCheck));
return (void*)tls.getNoCheck;
}
///////////////////////////////////////////////////////////////////////////////
// This allocator is for unknown but fixed sized classes, like ObjectData.
#define DECLARE_OBJECT_ALLOCATION_NO_SWEEP(T) \
public: \
/* static void *ObjAllocatorInitSetup; */ \
inline ALWAYS_INLINE void operator delete(void *p) { \
if (T::IsResourceClass) { \
RELEASEOBJ(NS, T, p); \
return; \
} \
ObjectData* this_ = (ObjectData*)p; \
Class* cls = this_->getVMClass(); \
size_t nProps = cls->numDeclProperties(); \
size_t builtinPropSize = cls->builtinPropSize(); \
TypedValue* propVec = \
(TypedValue *)((uintptr_t)this_ + sizeof(ObjectData) + \
builtinPropSize); \
for (unsigned i = 0; i < nProps; ++i) { \
TypedValue* prop = &propVec[i]; \
tvRefcountedDecRef(prop); \
} \
DELETEOBJSZ(ObjectData::sizeForNProps(nProps) + \
builtinPropSize)(this_); \
}
#define DECLARE_OBJECT_ALLOCATION(T) \
DECLARE_OBJECT_ALLOCATION_NO_SWEEP(T) \
virtual void sweep();
#define IMPLEMENT_OBJECT_ALLOCATION_NO_DEFAULT_SWEEP_CLS(NS,T) \
/* void *NS::T::ObjAllocatorInitSetup = \
ObjectAllocatorInitSetup<NS::T>(); */
#define IMPLEMENT_OBJECT_ALLOCATION_NO_DEFAULT_SWEEP(T) \
IMPLEMENT_OBJECT_ALLOCATION_NO_DEFAULT_SWEEP_CLS(HPHP,T)
#define IMPLEMENT_OBJECT_ALLOCATION_CLS(NS,T) \
IMPLEMENT_OBJECT_ALLOCATION_NO_DEFAULT_SWEEP_CLS(NS,T); \
void NS::T::sweep() { \
SWEEPOBJ(T); \
}
#define IMPLEMENT_OBJECT_ALLOCATION(T) IMPLEMENT_OBJECT_ALLOCATION_CLS(HPHP,T)
class ObjectAllocatorBase : public SmartAllocatorImpl {
public:
ObjectAllocatorBase(int itemSize);
void release(void *p) {
if (p) {
dealloc(p);
}
}
};
template<int S>
class ObjectAllocator : public ObjectAllocatorBase {
public:
static void Create(void* storage) {
new (storage) ObjectAllocator<S>();
static_assert(unsigned(S) <= SLAB_SIZE, "slab too small");
}
static void Delete(ObjectAllocator *p) {
p->~ObjectAllocator();
}
static void OnThreadExit(ObjectAllocator *p) {
p->~ObjectAllocator();
}
ObjectAllocator() : ObjectAllocatorBase(S) { }
};
///////////////////////////////////////////////////////////////////////////////
}
template<typename T>
inline void *operator new(size_t sizeT, HPHP::SmartAllocator<T> *a) {
assert(sizeT == sizeof(T));
return a->alloc(HPHP::SmartAllocatorImpl::itemSizeRoundup(sizeof(T)));
}
inline void *operator new(size_t sizeT, HPHP::ObjectAllocatorBase *a) {
assert(sizeT <= size_t(a->getItemSize()));
return a->alloc();
}
template<typename T>
inline void operator delete(void *p, HPHP::SmartAllocator<T> *a) {
assert(p);
a->dealloc((T*)p);
}
inline void operator delete(void *p , HPHP::ObjectAllocatorBase *a) {
assert(p);
a->dealloc(p);
}
///////////////////////////////////////////////////////////////////////////////
#endif // incl_HPHP_SMART_ALLOCATOR_H_
| 36.384615 | 79 | 0.543419 |
bd0caeca4ba8e80b65748a11b1068907522a8e01 | 520 | h | C | usr/libexec/addressbooksyncd/NDTLog.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | 1 | 2020-11-04T15:43:01.000Z | 2020-11-04T15:43:01.000Z | usr/libexec/addressbooksyncd/NDTLog.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | usr/libexec/addressbooksyncd/NDTLog.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | //
// Generated by classdumpios 1.0.1 (64 bit) (iOS port by DreamDevLost)(Debug version compiled Sep 26 2020 13:48:20).
//
// Copyright (C) 1997-2019 Steve Nygard.
//
#import <objc/NSObject.h>
__attribute__((visibility("hidden")))
@interface NDTLog : NSObject
{
}
+ (id)facilityWithSubsystem:(id)arg1 category:(id)arg2; // IMP=0x000000010003533c
+ (_Bool)isInternalDevice; // IMP=0x0000000100035330
+ (_Bool)obfuscate; // IMP=0x0000000100035324
+ (void)setObfuscate:(_Bool)arg1; // IMP=0x0000000100035318
@end
| 24.761905 | 120 | 0.725 |
bd0d2bf96a210d7d87aed89fa8137f9c670e965e | 2,733 | h | C | opentherm-ha/config.h | aamorin/home-assistant-opentherm-thermostat | 1ead6f618bf3c7de8776fed3b221a11f5136e991 | [
"MIT"
] | 24 | 2020-12-08T10:26:47.000Z | 2022-03-25T12:28:06.000Z | opentherm-ha/config.h | aamorin/home-assistant-opentherm-thermostat | 1ead6f618bf3c7de8776fed3b221a11f5136e991 | [
"MIT"
] | 6 | 2021-03-23T11:32:35.000Z | 2022-01-07T12:46:10.000Z | opentherm-ha/config.h | aamorin/home-assistant-opentherm-thermostat | 1ead6f618bf3c7de8776fed3b221a11f5136e991 | [
"MIT"
] | 14 | 2020-12-17T09:29:23.000Z | 2022-02-18T14:48:38.000Z | /*
Topic structure is built with get/set mechanizm for
compatibility with home assistant and to allow external
device control
_GET_ topics are used to publish current thermostat state
_SET_ topics are used to control the thermostat
*/
// Your WiFi credentials.
// Set password to "" for open networks.
const char* ssid = "xxxxxx";
const char* pass = "xxxxxx";
// Your MQTT broker address and credentials
const char* mqtt_server = "xxx.xxx.xxx.xxx";
const char* mqtt_user = "xxxxxx";
const char* mqtt_password = "xxxxxx";
const int mqtt_port = 1883;
// Master OpenTherm Shield pins configuration
const int OT_IN_PIN = 4; //for Arduino, 4 for ESP8266 (D2), 21 for ESP32
const int OT_OUT_PIN = 5; //for Arduino, 5 for ESP8266 (D1), 22 for ESP32
// Temperature sensor pin
const int ROOM_TEMP_SENSOR_PIN = 14; //for Arduino, 14 for ESP8266 (D5), 18 for ESP32
/*
current temperature topics
if setter is used - thermostat works with external values, bypassing built-in sensor
if no values on setter for more than 1 minute - thermostat falls back to built-in sensor
*/
const String BASE_TOPIC = "opentherm-thermostat/";
const String CURRENT_TEMP_GET_TOPIC = BASE_TOPIC + "current-temperature/get";
const String CURRENT_TEMP_SET_TOPIC = BASE_TOPIC + "current-temperature/set";
// current temperature topics
const String TEMP_SETPOINT_GET_TOPIC = BASE_TOPIC + "setpoint-temperature/get";
const String TEMP_SETPOINT_SET_TOPIC = BASE_TOPIC + "setpoint-temperature/set";
// working mode topics
const String MODE_GET_TOPIC = BASE_TOPIC + "mode/get";
const String MODE_SET_TOPIC = BASE_TOPIC + "mode/set";
// boiler water temperature topic
const String TEMP_BOILER_GET_TOPIC = BASE_TOPIC + "boiler-temperature/get";
const String TEMP_BOILER_TARGET_GET_TOPIC = BASE_TOPIC + "boiler-target-temperature/get";
// debug data
const String INTEGRAL_ERROR_GET_TOPIC = BASE_TOPIC + "integral-error/get";
const String FLAME_STATUS_GET_TOPIC = BASE_TOPIC + "flame-status/get";
const String FLAME_LEVEL_GET_TOPIC = BASE_TOPIC + "flame-level/get";
// domestic hot water temperature topic
const String TEMP_DHW_GET_TOPIC = BASE_TOPIC + "dhw-temperature/get";
const String TEMP_DHW_SET_TOPIC = BASE_TOPIC + "dhw-temperature/set";
const String ACTUAL_TEMP_DHW_GET_TOPIC = BASE_TOPIC + "dhw-actual-temperature/get";
// domestic hot water enable/disable
const String STATE_DHW_GET_TOPIC = BASE_TOPIC + "dhw-state/get";
const String STATE_DHW_SET_TOPIC = BASE_TOPIC + "dhw-state/set";
// setpoint topic
const String SETPOINT_OVERRIDE_SET_TOPIC = BASE_TOPIC + "setpoint-override/set";
const String SETPOINT_OVERRIDE_RESET_TOPIC = BASE_TOPIC + "setpoint-override/reset";
// logs topic
const String LOG_GET_TOPIC = BASE_TOPIC + "log";
| 39.042857 | 91 | 0.774973 |
bd0decd6d7535ed1c034863df738ac4f48904512 | 13,549 | c | C | openeuler-kernel/tools/perf/util/stat.c | Ddnirvana/test-CI | dd7a0a71281075e8ab300bddbab4a9fa039958f0 | [
"MulanPSL-1.0"
] | 31 | 2021-04-27T08:50:40.000Z | 2022-03-01T02:26:21.000Z | openeuler-kernel/tools/perf/util/stat.c | Ddnirvana/test-CI | dd7a0a71281075e8ab300bddbab4a9fa039958f0 | [
"MulanPSL-1.0"
] | 13 | 2021-07-10T04:36:17.000Z | 2022-03-03T10:50:05.000Z | openeuler-kernel/tools/perf/util/stat.c | Ddnirvana/test-CI | dd7a0a71281075e8ab300bddbab4a9fa039958f0 | [
"MulanPSL-1.0"
] | 12 | 2021-04-06T02:23:10.000Z | 2022-02-28T11:43:19.000Z | // SPDX-License-Identifier: GPL-2.0
#include <errno.h>
#include <inttypes.h>
#include <math.h>
#include <string.h>
#include "counts.h"
#include "cpumap.h"
#include "debug.h"
#include "header.h"
#include "stat.h"
#include "session.h"
#include "target.h"
#include "evlist.h"
#include "evsel.h"
#include "thread_map.h"
#include <linux/zalloc.h>
void update_stats(struct stats *stats, u64 val)
{
double delta;
stats->n++;
delta = val - stats->mean;
stats->mean += delta / stats->n;
stats->M2 += delta*(val - stats->mean);
if (val > stats->max)
stats->max = val;
if (val < stats->min)
stats->min = val;
}
double avg_stats(struct stats *stats)
{
return stats->mean;
}
/*
* http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
*
* (\Sum n_i^2) - ((\Sum n_i)^2)/n
* s^2 = -------------------------------
* n - 1
*
* http://en.wikipedia.org/wiki/Stddev
*
* The std dev of the mean is related to the std dev by:
*
* s
* s_mean = -------
* sqrt(n)
*
*/
double stddev_stats(struct stats *stats)
{
double variance, variance_mean;
if (stats->n < 2)
return 0.0;
variance = stats->M2 / (stats->n - 1);
variance_mean = variance / stats->n;
return sqrt(variance_mean);
}
double rel_stddev_stats(double stddev, double avg)
{
double pct = 0.0;
if (avg)
pct = 100.0 * stddev/avg;
return pct;
}
bool __perf_evsel_stat__is(struct evsel *evsel,
enum perf_stat_evsel_id id)
{
struct perf_stat_evsel *ps = evsel->stats;
return ps->id == id;
}
#define ID(id, name) [PERF_STAT_EVSEL_ID__##id] = #name
static const char *id_str[PERF_STAT_EVSEL_ID__MAX] = {
ID(NONE, x),
ID(CYCLES_IN_TX, cpu/cycles-t/),
ID(TRANSACTION_START, cpu/tx-start/),
ID(ELISION_START, cpu/el-start/),
ID(CYCLES_IN_TX_CP, cpu/cycles-ct/),
ID(TOPDOWN_TOTAL_SLOTS, topdown-total-slots),
ID(TOPDOWN_SLOTS_ISSUED, topdown-slots-issued),
ID(TOPDOWN_SLOTS_RETIRED, topdown-slots-retired),
ID(TOPDOWN_FETCH_BUBBLES, topdown-fetch-bubbles),
ID(TOPDOWN_RECOVERY_BUBBLES, topdown-recovery-bubbles),
ID(TOPDOWN_RETIRING, topdown-retiring),
ID(TOPDOWN_BAD_SPEC, topdown-bad-spec),
ID(TOPDOWN_FE_BOUND, topdown-fe-bound),
ID(TOPDOWN_BE_BOUND, topdown-be-bound),
ID(SMI_NUM, msr/smi/),
ID(APERF, msr/aperf/),
};
#undef ID
static void perf_stat_evsel_id_init(struct evsel *evsel)
{
struct perf_stat_evsel *ps = evsel->stats;
int i;
/* ps->id is 0 hence PERF_STAT_EVSEL_ID__NONE by default */
for (i = 0; i < PERF_STAT_EVSEL_ID__MAX; i++) {
if (!strcmp(evsel__name(evsel), id_str[i])) {
ps->id = i;
break;
}
}
}
static void evsel__reset_stat_priv(struct evsel *evsel)
{
int i;
struct perf_stat_evsel *ps = evsel->stats;
for (i = 0; i < 3; i++)
init_stats(&ps->res_stats[i]);
perf_stat_evsel_id_init(evsel);
}
static int evsel__alloc_stat_priv(struct evsel *evsel)
{
evsel->stats = zalloc(sizeof(struct perf_stat_evsel));
if (evsel->stats == NULL)
return -ENOMEM;
evsel__reset_stat_priv(evsel);
return 0;
}
static void evsel__free_stat_priv(struct evsel *evsel)
{
struct perf_stat_evsel *ps = evsel->stats;
if (ps)
zfree(&ps->group_data);
zfree(&evsel->stats);
}
static int evsel__alloc_prev_raw_counts(struct evsel *evsel, int ncpus, int nthreads)
{
struct perf_counts *counts;
counts = perf_counts__new(ncpus, nthreads);
if (counts)
evsel->prev_raw_counts = counts;
return counts ? 0 : -ENOMEM;
}
static void evsel__free_prev_raw_counts(struct evsel *evsel)
{
perf_counts__delete(evsel->prev_raw_counts);
evsel->prev_raw_counts = NULL;
}
static void evsel__reset_prev_raw_counts(struct evsel *evsel)
{
if (evsel->prev_raw_counts)
perf_counts__reset(evsel->prev_raw_counts);
}
static int evsel__alloc_stats(struct evsel *evsel, bool alloc_raw)
{
int ncpus = evsel__nr_cpus(evsel);
int nthreads = perf_thread_map__nr(evsel->core.threads);
if (evsel__alloc_stat_priv(evsel) < 0 ||
evsel__alloc_counts(evsel, ncpus, nthreads) < 0 ||
(alloc_raw && evsel__alloc_prev_raw_counts(evsel, ncpus, nthreads) < 0))
return -ENOMEM;
return 0;
}
int perf_evlist__alloc_stats(struct evlist *evlist, bool alloc_raw)
{
struct evsel *evsel;
evlist__for_each_entry(evlist, evsel) {
if (evsel__alloc_stats(evsel, alloc_raw))
goto out_free;
}
return 0;
out_free:
perf_evlist__free_stats(evlist);
return -1;
}
void perf_evlist__free_stats(struct evlist *evlist)
{
struct evsel *evsel;
evlist__for_each_entry(evlist, evsel) {
evsel__free_stat_priv(evsel);
evsel__free_counts(evsel);
evsel__free_prev_raw_counts(evsel);
}
}
void perf_evlist__reset_stats(struct evlist *evlist)
{
struct evsel *evsel;
evlist__for_each_entry(evlist, evsel) {
evsel__reset_stat_priv(evsel);
evsel__reset_counts(evsel);
}
}
void perf_evlist__reset_prev_raw_counts(struct evlist *evlist)
{
struct evsel *evsel;
evlist__for_each_entry(evlist, evsel)
evsel__reset_prev_raw_counts(evsel);
}
static void perf_evsel__copy_prev_raw_counts(struct evsel *evsel)
{
int ncpus = evsel__nr_cpus(evsel);
int nthreads = perf_thread_map__nr(evsel->core.threads);
for (int thread = 0; thread < nthreads; thread++) {
for (int cpu = 0; cpu < ncpus; cpu++) {
*perf_counts(evsel->counts, cpu, thread) =
*perf_counts(evsel->prev_raw_counts, cpu,
thread);
}
}
evsel->counts->aggr = evsel->prev_raw_counts->aggr;
}
void perf_evlist__copy_prev_raw_counts(struct evlist *evlist)
{
struct evsel *evsel;
evlist__for_each_entry(evlist, evsel)
perf_evsel__copy_prev_raw_counts(evsel);
}
void perf_evlist__save_aggr_prev_raw_counts(struct evlist *evlist)
{
struct evsel *evsel;
/*
* To collect the overall statistics for interval mode,
* we copy the counts from evsel->prev_raw_counts to
* evsel->counts. The perf_stat_process_counter creates
* aggr values from per cpu values, but the per cpu values
* are 0 for AGGR_GLOBAL. So we use a trick that saves the
* previous aggr value to the first member of perf_counts,
* then aggr calculation in process_counter_values can work
* correctly.
*/
evlist__for_each_entry(evlist, evsel) {
*perf_counts(evsel->prev_raw_counts, 0, 0) =
evsel->prev_raw_counts->aggr;
}
}
static void zero_per_pkg(struct evsel *counter)
{
if (counter->per_pkg_mask)
memset(counter->per_pkg_mask, 0, cpu__max_cpu());
}
static int check_per_pkg(struct evsel *counter,
struct perf_counts_values *vals, int cpu, bool *skip)
{
unsigned long *mask = counter->per_pkg_mask;
struct perf_cpu_map *cpus = evsel__cpus(counter);
int s;
*skip = false;
if (!counter->per_pkg)
return 0;
if (perf_cpu_map__empty(cpus))
return 0;
if (!mask) {
mask = zalloc(cpu__max_cpu());
if (!mask)
return -ENOMEM;
counter->per_pkg_mask = mask;
}
/*
* we do not consider an event that has not run as a good
* instance to mark a package as used (skip=1). Otherwise
* we may run into a situation where the first CPU in a package
* is not running anything, yet the second is, and this function
* would mark the package as used after the first CPU and would
* not read the values from the second CPU.
*/
if (!(vals->run && vals->ena))
return 0;
s = cpu_map__get_socket(cpus, cpu, NULL);
if (s < 0)
return -1;
*skip = test_and_set_bit(s, mask) == 1;
return 0;
}
static int
process_counter_values(struct perf_stat_config *config, struct evsel *evsel,
int cpu, int thread,
struct perf_counts_values *count)
{
struct perf_counts_values *aggr = &evsel->counts->aggr;
static struct perf_counts_values zero;
bool skip = false;
if (check_per_pkg(evsel, count, cpu, &skip)) {
pr_err("failed to read per-pkg counter\n");
return -1;
}
if (skip)
count = &zero;
switch (config->aggr_mode) {
case AGGR_THREAD:
case AGGR_CORE:
case AGGR_DIE:
case AGGR_SOCKET:
case AGGR_NODE:
case AGGR_NONE:
if (!evsel->snapshot)
evsel__compute_deltas(evsel, cpu, thread, count);
perf_counts_values__scale(count, config->scale, NULL);
if ((config->aggr_mode == AGGR_NONE) && (!evsel->percore)) {
perf_stat__update_shadow_stats(evsel, count->val,
cpu, &rt_stat);
}
if (config->aggr_mode == AGGR_THREAD) {
if (config->stats)
perf_stat__update_shadow_stats(evsel,
count->val, 0, &config->stats[thread]);
else
perf_stat__update_shadow_stats(evsel,
count->val, 0, &rt_stat);
}
break;
case AGGR_GLOBAL:
aggr->val += count->val;
aggr->ena += count->ena;
aggr->run += count->run;
case AGGR_UNSET:
default:
break;
}
return 0;
}
static int process_counter_maps(struct perf_stat_config *config,
struct evsel *counter)
{
int nthreads = perf_thread_map__nr(counter->core.threads);
int ncpus = evsel__nr_cpus(counter);
int cpu, thread;
if (counter->core.system_wide)
nthreads = 1;
for (thread = 0; thread < nthreads; thread++) {
for (cpu = 0; cpu < ncpus; cpu++) {
if (process_counter_values(config, counter, cpu, thread,
perf_counts(counter->counts, cpu, thread)))
return -1;
}
}
return 0;
}
int perf_stat_process_counter(struct perf_stat_config *config,
struct evsel *counter)
{
struct perf_counts_values *aggr = &counter->counts->aggr;
struct perf_stat_evsel *ps = counter->stats;
u64 *count = counter->counts->aggr.values;
int i, ret;
aggr->val = aggr->ena = aggr->run = 0;
/*
* We calculate counter's data every interval,
* and the display code shows ps->res_stats
* avg value. We need to zero the stats for
* interval mode, otherwise overall avg running
* averages will be shown for each interval.
*/
if (config->interval || config->summary) {
for (i = 0; i < 3; i++)
init_stats(&ps->res_stats[i]);
}
if (counter->per_pkg)
zero_per_pkg(counter);
ret = process_counter_maps(config, counter);
if (ret)
return ret;
if (config->aggr_mode != AGGR_GLOBAL)
return 0;
if (!counter->snapshot)
evsel__compute_deltas(counter, -1, -1, aggr);
perf_counts_values__scale(aggr, config->scale, &counter->counts->scaled);
for (i = 0; i < 3; i++)
update_stats(&ps->res_stats[i], count[i]);
if (verbose > 0) {
fprintf(config->output, "%s: %" PRIu64 " %" PRIu64 " %" PRIu64 "\n",
evsel__name(counter), count[0], count[1], count[2]);
}
/*
* Save the full runtime - to allow normalization during printout:
*/
perf_stat__update_shadow_stats(counter, *count, 0, &rt_stat);
return 0;
}
int perf_event__process_stat_event(struct perf_session *session,
union perf_event *event)
{
struct perf_counts_values count;
struct perf_record_stat *st = &event->stat;
struct evsel *counter;
count.val = st->val;
count.ena = st->ena;
count.run = st->run;
counter = perf_evlist__id2evsel(session->evlist, st->id);
if (!counter) {
pr_err("Failed to resolve counter for stat event.\n");
return -EINVAL;
}
*perf_counts(counter->counts, st->cpu, st->thread) = count;
counter->supported = true;
return 0;
}
size_t perf_event__fprintf_stat(union perf_event *event, FILE *fp)
{
struct perf_record_stat *st = (struct perf_record_stat *)event;
size_t ret;
ret = fprintf(fp, "\n... id %" PRI_lu64 ", cpu %d, thread %d\n",
st->id, st->cpu, st->thread);
ret += fprintf(fp, "... value %" PRI_lu64 ", enabled %" PRI_lu64 ", running %" PRI_lu64 "\n",
st->val, st->ena, st->run);
return ret;
}
size_t perf_event__fprintf_stat_round(union perf_event *event, FILE *fp)
{
struct perf_record_stat_round *rd = (struct perf_record_stat_round *)event;
size_t ret;
ret = fprintf(fp, "\n... time %" PRI_lu64 ", type %s\n", rd->time,
rd->type == PERF_STAT_ROUND_TYPE__FINAL ? "FINAL" : "INTERVAL");
return ret;
}
size_t perf_event__fprintf_stat_config(union perf_event *event, FILE *fp)
{
struct perf_stat_config sc;
size_t ret;
perf_event__read_stat_config(&sc, &event->stat_config);
ret = fprintf(fp, "\n");
ret += fprintf(fp, "... aggr_mode %d\n", sc.aggr_mode);
ret += fprintf(fp, "... scale %d\n", sc.scale);
ret += fprintf(fp, "... interval %u\n", sc.interval);
return ret;
}
int create_perf_stat_counter(struct evsel *evsel,
struct perf_stat_config *config,
struct target *target,
int cpu)
{
struct perf_event_attr *attr = &evsel->core.attr;
struct evsel *leader = evsel->leader;
attr->read_format = PERF_FORMAT_TOTAL_TIME_ENABLED |
PERF_FORMAT_TOTAL_TIME_RUNNING;
/*
* The event is part of non trivial group, let's enable
* the group read (for leader) and ID retrieval for all
* members.
*/
if (leader->core.nr_members > 1)
attr->read_format |= PERF_FORMAT_ID|PERF_FORMAT_GROUP;
attr->inherit = !config->no_inherit;
/*
* Some events get initialized with sample_(period/type) set,
* like tracepoints. Clear it up for counting.
*/
attr->sample_period = 0;
if (config->identifier)
attr->sample_type = PERF_SAMPLE_IDENTIFIER;
if (config->all_user) {
attr->exclude_kernel = 1;
attr->exclude_user = 0;
}
if (config->all_kernel) {
attr->exclude_kernel = 0;
attr->exclude_user = 1;
}
/*
* Disabling all counters initially, they will be enabled
* either manually by us or by kernel via enable_on_exec
* set later.
*/
if (evsel__is_group_leader(evsel)) {
attr->disabled = 1;
/*
* In case of initial_delay we enable tracee
* events manually.
*/
if (target__none(target) && !config->initial_delay)
attr->enable_on_exec = 1;
}
if (target__has_cpu(target) && !target__has_per_thread(target))
return evsel__open_per_cpu(evsel, evsel__cpus(evsel), cpu);
return evsel__open_per_thread(evsel, evsel->core.threads);
}
| 23.687063 | 94 | 0.696288 |
bd0e8b69c5406bad9383b262b07588e72f766e43 | 44,616 | h | C | source/sysevent/lib/sysevent.h | junnanx/rdkb-Utopia | 88cec7b166bf0379d498c04248b9712424e2c0ad | [
"Apache-2.0"
] | 5 | 2017-08-08T08:04:18.000Z | 2020-03-11T16:19:43.000Z | source/sysevent/lib/sysevent.h | junnanx/rdkb-Utopia | 88cec7b166bf0379d498c04248b9712424e2c0ad | [
"Apache-2.0"
] | 1 | 2021-11-24T02:13:21.000Z | 2021-11-24T02:13:21.000Z | source/sysevent/lib/sysevent.h | junnanx/rdkb-Utopia | 88cec7b166bf0379d498c04248b9712424e2c0ad | [
"Apache-2.0"
] | 7 | 2018-08-16T18:59:09.000Z | 2021-11-23T05:04:33.000Z | /*
* If not stated otherwise in this file or this component's Licenses.txt file the
* following copyright and licenses apply:
*
* Copyright 2015 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**********************************************************************
Copyright [2014] [Cisco Systems, Inc.]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
**********************************************************************/
#ifndef __LIB_SYSEVENT_H_
#define __LIB_SYSEVENT_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/time.h>
/*
* Well known port of the sysevent daemon
*/
#define SE_SERVER_WELL_KNOWN_PORT 52367
/*
* Well known UDS
*/
#define UDS_PATH "/tmp/syseventd_connection"
/*
* current version of se messages
*/
#define SE_VERSION 1
/*
* Given a *se_msg_hdr calculate the address of the body
* of the message
*/
#define SE_MSG_HDR_2_BODY(a) ((char *)(a) + sizeof(se_msg_hdr))
/*
* The maximum size of a SE msg
* Note: For ARM linux this value must be a multiple of
* sizeof(int) - 1
*/
#define SE_MAX_MSG_SIZE 1023
#define SE_MAX_MSG_DATA_SIZE 40960 /* 40K Max */
#define SE_MAX_MSG_DATA_SIZE_READ_FILE "/tmp/sysevent_binsize_max"
/*
* null async_id_t
*/
#define NULL_ASYNC_ID {0,0}
/*
* For iterating through unique namespaces (in dataMgr) we use an iterator
* which users initialize to NULL_ITERATOR
*/
#define SYSEVENT_NULL_ITERATOR 0xFFFFFFFF
/*
* The ARM processor will not necessarily align
* a char * on a 4 byte boundry, but SE msg
* contain an int which needs to be properly aligned.
* This makes a problem when typecasting from char * to se_msg
* as is commonly done for reading from an fd into a buffer
* and then using that buffer as a structure
*/
typedef char se_buffer[SE_MAX_MSG_SIZE+1] __attribute__ ((aligned(4)));
/*
* Errors
*/
#define ERR_NAME_TOO_LONG -1241
#define ERR_BAD_PORT -1242
#define ERR_INCORRECT_VERSION -1243
#define ERR_BAD_DESTINATION -1244
#define ERR_MSG_PREPARE -1245
#define ERR_SOCKET_OPEN -1246
#define ERR_CANNOT_CONNECT -1247
#define ERR_REGISTRATION_REFUSED -1248
#define ERR_ALREADY_CONNECTED -1249
#define ERR_NOT_CONNECTED -1250
#define ERR_NO_PING_REPLY -1251
#define ERR_INSUFFICIENT_ROOM -1252
#define ERR_BAD_BUFFER -1253
#define ERR_SERVER_ERROR -1254
#define ERR_MSG_TOO_LONG -1255
#define ERR_VALUE_NOT_FOUND -1256
#define ERR_CANNOT_SET_STRING -1257
#define ERR_PARAM_NOT_FOUND -1258
#define ERR_OUT_OF_ORDER -1259
#define ERR_CORRUPTED -1260
#define ERR_DUPLICATE_MSG -1261
typedef enum
{
SE_MSG_NONE = 0,
/* inter-thread messages */
SE_MSG_DIE = 1,
SE_MSG_SEND_NOTIFICATION = 2,
SE_MSG_EXECUTE_SERIALLY = 3,
SE_MSG_RUN_EXTERNAL_EXECUTABLE = 4,
/* inter-process messages */
SE_MSG_OPEN_CONNECTION = 5,
SE_MSG_OPEN_CONNECTION_REPLY = 6,
SE_MSG_CLOSE_CONNECTION = 7,
SE_MSG_CLOSE_CONNECTION_REPLY = 8,
SE_MSG_PING = 9,
SE_MSG_PING_REPLY = 10,
SE_MSG_NEW_CLIENT = 11,
SE_MSG_GET = 12,
SE_MSG_GET_REPLY = 13,
SE_MSG_SET = 14,
SE_MSG_SET_REPLY = 15,
SE_MSG_SET_UNIQUE = 16,
SE_MSG_SET_UNIQUE_REPLY = 17,
SE_MSG_DEL_UNIQUE = 18,
SE_MSG_SET_OPTIONS = 19,
SE_MSG_SET_OPTIONS_REPLY = 20,
SE_MSG_ITERATE_GET = 21, /* get value of next unique element in namespace using a given iterator */
SE_MSG_ITERATE_GET_REPLY = 22,
SE_MSG_NEXT_ITERATOR_GET = 23, /* get next iterator of a namespace using current iterator as seed */
SE_MSG_NEXT_ITERATOR_GET_REPLY = 24,
SE_MSG_SET_ASYNC_ACTION = 25,
SE_MSG_SET_ASYNC_MESSAGE = 26,
SE_MSG_SET_ASYNC_REPLY = 27,
SE_MSG_REMOVE_ASYNC = 28,
SE_MSG_REMOVE_ASYNC_REPLY = 29,
SE_MSG_NOTIFICATION = 30,
SE_MSG_SHOW_DATA_ELEMENTS = 31,
SE_MSG_ERRORED = 32, /* msg corrupted */
SE_MSG_DEBUG = 33, /* change debug level */
SE_MSG_SET_DATA = 34,
SE_MSG_GET_DATA = 35,
SE_MSG_GET_DATA_REPLY = 36,
SE_MSG_SEND_NOTIFICATION_DATA = 37,
SE_MSG_SET_ASYNC_MESSAGE_DATA = 38,
SE_MSG_NOTIFICATION_DATA = 39,
SE_MSG_RUN_EXTERNAL_EXECUTABLE_DATA = 40,
SE_MSG_OPEN_CONNECTION_DATA = 41
} se_msg_type;
typedef unsigned int token_t;
#define TOKEN_NULL 0
#define TOKEN_INVALID -1
#define MSG_DELIMITER 0xFEEDFAD0
/*
* se_msg_hdr
*
* The header of every SE message below
*
* Fields :
* poison : A field that must be set to 0xfeedfad0
* mbytes : The total number of bytes in the message including the header
* mtype : The type of message
* sender : The sender of the message
* 0 is from the sysevent daemon
* a client uses the token_id from the se_open_connection_reply_msg
* (except for se_open_connection_msg when it doesn't have an token_id yet)
* Note : It is better if the se_msg_hdr is word aligned
*/
typedef struct
{
int poison;
int mbytes; /* number of bytes in message */
se_msg_type mtype; /* type of message */
token_t sender_token; /* id of sender */
} se_msg_hdr;
/*
* se_msg_footer
* The transport footer of each SE message
*
* Fields :
* poison : A field that is st to 0xfeedfad0 during transport
*
* Notes : The footer is added prior to sending a message and it is removed when received
* by the transport layer
*/
typedef struct
{
int poison;
} se_msg_footer;
/*
* note that in all of the messages, strings are represented as
* se_msg_string types
*/
/*
* se_msg_string
* The representation of a string in a SE message
* size : the number of bytes in the next field
* str : the string
* NOTE: There are places in libsystem.c that assume that the string
* is immediately after size. Do not add any variables into the structure
* without considering that implication
*/
typedef struct {
unsigned int size;
/* char str[0]; */ /* for ISO C compatibility, 0 len not allowed */
}se_msg_string;
/*
* convenience to get overhead of se_msg_string to the char string itself
* used in case we change the contents of a se_msg_string in the future
*/
#define SE_MSG_STRING_OVERHEAD (sizeof(unsigned int))
/*
* Procedure : SE_msg_get_string
* Purpose : Get a string from a SE_msg buffer. The buffer
* must be pointing at the se_msg_string containing the string
* Parameters :
* msg : A pointer to the start of the se_msg_string
* size : On return the number of bytes that the se_msg_string occupied
* Return Code :
* NULL : problem, string not gotten
* !NULL : string
*/
char *SE_msg_get_string(char *msg, int *size);
/*
==========================================================================
inter-process messages
Communication between clients and the server
==========================================================================
*/
/*
* se_open_connection_msg
*
* A request by a client to connect to the sysevent daemon
*
* Fields :
* version : The version of SE message the client understands
* data : An user readable (and hopefully unique) id that the client
* calls itself.
*/
typedef struct
{
int version;
void *data;
} se_open_connection_msg;
/*
* se_open_connection_reply_msg
*
* A response to the open connection message
*
* Fields :
* status : Status of registration
* 0 is success, !0 is failure
* token_id: The id to use in future messages to the sysevent daemon
*/
typedef struct
{
int status;
token_t token_id;
} se_open_connection_reply_msg;
/*
* se_close_connection_msg
*
* A request by a connected client to close its connection
*
* Fields :
* reserved: Not currently used
*/
typedef struct
{
void *reserved;
} se_close_connection_msg;
/*
* se_close_connection_reply_msg
*
* A response to an close connection message
*
* Fields :
* reserved: Not currently used
*/
typedef struct
{
void *reserved;
} se_close_connection_reply_msg;
/*
* se_ping_msg
*
* A request to indicate sign of life via ping reply
*
* Fields :
* reserved: Not currently used
*/
typedef struct
{
void *reserved;
} se_ping_msg;
/*
* se_ping_reply_msg
*
* A response to request for indication of sign of life
*
* Fields :
* reserved: Not currently used
*/
typedef struct
{
void *reserved;
} se_ping_reply_msg;
/*
* se_debug_msg
*
* Change the debug level of syseventd
*
* Fields :
* level: The debug level to use (see server/syseventd.h for debug flags)
*/
typedef struct
{
int level;
} se_debug_msg;
/*
* se_new_client_msg
*
* A message from the TCP accept wait thread to the general Listener
* thread to indicate that a new client has connected
*
* Fields :
* token_id: The id that the acceptor has assigned to the client
* after it has already been added to the list of clients
*/
typedef struct
{
token_t token_id;
} se_new_client_msg;
/*
* se_get_msg
*
* A request to retrieve the value of a subject known to
* the sysevent daemon.
*
* Fields :
* data : a se_msg_string which contains the name of the subject
* for which the value is requested
*/
typedef struct
{
void *data;
} se_get_msg;
/*
* se_get_reply_msg
*
* A response from the sysevent daemon to a se_get_msg
*
* Fields :
* status : the status of the response. 0 means no error
* data : 2 se_msg_strings
* The first contains the name of the subject for which the value
* had been requested
* The second contains the current value
*/
typedef struct
{
int status;
void *data;
} se_get_reply_msg;
/*
* se_set_msg
*
* A request to set the value of a subject known to
* the sysevent daemon.
*
* Fields :
* source : source of the message
* tid : transaction id for the message
* data : 2 se_msg_strings
* The first contains the name of the tuple for which the value
* is to be set
* The second contains the value it is to be set to
*/
typedef struct
{
int source;
int tid;
void *data; /* this will be 2 character strings
* the first is subject_bytes long
* the second is value_bytes long
*/
} se_set_msg;
/*
* se_set_reply_msg
*
* A response from the sysevent daemon to a se_set_msg
*
* Fields :
* status : the status of the response. 0 means no error
*/
typedef struct
{
int status;
} se_set_reply_msg;
/*
* se_set_unique_msg
*
* A request to create a new subject with a given preamble and set the value
*
* Fields :
* data : 2 se_msg_strings
* The first contains the preamble name(namespace) of the tuple to create
* The second contains the value it is to be set to
*/
typedef struct
{
void *data; /* this will be 2 character strings
* the first is subject_bytes long
* the second is value_bytes long
*/
} se_set_unique_msg;
/*
* se_set_unique_reply_msg
*
* A response from the sysevent daemon to a se_set_unique_msg
*
* Fields :
* status : the status of the response. 0 means no error
* data : 2 se_msg_strings
* The first contains the unique name of the subject that was assigned
*/
typedef struct
{
int status;
void *data;
} se_set_unique_reply_msg;
/*
* se_iterate_get_msg
*
* A request to get the value of the next data element is a namespace
*
* Fields :
* iterator : an opaque field initially set to SYSEVENT_NULL_ITERATOR
* data : a se_msg_string which contains the name of the subject
* for which the value is requested
*/
typedef struct
{
unsigned int iterator;
void *data;
} se_iterate_get_msg;
/*
* se_iterate_get_reply_msg
*
* A response from the sysevent daemon to a get_unique_iterate_msg
*
* Fields :
* status : the status of the response. 0 means no error
* iterator: the new value to set in the caller's iterator
* data : 2 se_msg_strings
* The first contains the name of the subject for which the value
* had been requested. It is the unique name of that subject.
* The second contains the current value
*/
typedef struct
{
int status;
unsigned int iterator;
void *data;
} se_iterate_get_reply_msg;
/*
* se_del_unique_msg
*
* A request to delete a new UNIQUE element
*
* Fields :
* iterator: A iterator pointing at the element to delete
* data : 1 se_msg_strings
* The first contains the preamble name(namespace) of the tuple to delete
*/
typedef struct
{
unsigned int iterator;
void *data;
}se_del_unique_msg;
/*
* se_iterate_get_iterator__msg
*
* Return an iterator to the next UNIQUE element in a namespace
*
* Fields :
* iterator: the value of the current iterator
* NULL_ITERATOR means first iterator
* data : 1 se_msg_strings
* The first contains the namespace of the subject
*/
typedef struct
{
unsigned int iterator;
void *data;
} se_iterate_get_iterator_msg;
/*
* se_iterate_get_iterator_reply_msg
*
* Fields :
* status : the status of the response. 0 means no error
* iterator: the value of the next iterator
* data : 1 se_msg_strings
* The first contains the namespace of the subject for which the value
*/
typedef struct
{
int status;
unsigned int iterator;
void *data;
} se_iterate_get_iterator_reply_msg;
/*
* tuple_flag_t
* Controls that can be put on a tuple's execution
* 0x00000000 : Use defaults
* 0x00000001 : Order of action execution must be serialized in the order of
* the action was registered
* 0x00000002 : Execute any notifications on a tuple whether there is a
* change of tuple value or not
* 0x00000004 : The tuple value can be read often, but is only writable once
*
* IMPORTANT: IF YOU CHANGE THESE VALUES YOU MUST CHANGE ..../init/init.d/event_flags AS WELL
*
*/
typedef enum {
TUPLE_FLAG_NONE = 0, /* 0x00000000 */
TUPLE_FLAG_SERIAL = 1, /* 0x00000001 */
TUPLE_FLAG_EVENT = 2, /* 0x00000002 */
TUPLE_FLAG_WORM = 4, /* 0x00000004 */
TUPLE_FLAG_RESERVED = -1 /*ULONG_MAX */ /* 0xFFFFFFFF */
} tuple_flag_t;
/*
* strings for TUPLE FLAGS
*/
#define SYSEVENT_TUPLE_FLAG_SERIAL "0x00000001"
#define SYSEVENT_TUPLE_FLAG_EVENT "0x00000002"
#define SYSEVENT_TUPLE_FLAG_WORM "0x00000003"
/*
* action_flag_t
* Controls that can be put on a action
* 0x00000000 : Use defaults
* 0x00000001 : When execle an executable (activation) then the normal behavior
* is to only allow one executable target to be active at a time.
* This behavior blocks exec of the same target while one target
* is running (targets are short lived processes). If this flag is
* set, then multiple execs of the same target are allowed.
* 0x00000002 : When waiting for an executable target to be ready for activation,
* keep the waiting queue at a depth of 1 - the currently running
* process, and the latest request
*
*
* IMPORTANT: IF YOU CHANGE THESE VALUES YOU MUST CHANGE ..../init/init.d/event_flags AS WELL
*/
typedef enum {
ACTION_FLAG_NONE = 0, /* 0x00000000 */
ACTION_FLAG_MULTIPLE_ACTIVATION = 1, /* 0x00000001 */
ACTION_FLAG_COLLAPSE_PENDING_QUEUE = 2, /* 0x00000002 */
ACTION_FLAG_RESERVED = -1 /*ULONG_MAX */ /* 0xFFFFFFFF */
} action_flag_t;
/*
* strings for ACTION FLAGS
*/
#define SYSEVENT_ACTION_FLAG_MULTIPLE_ACTIVATION "0x00000001"
#define SYSEVENT_ACTION_FLAG_COLLAPSE_PENDING_QUEUE "0x00000002"
/*
* se_set_options_msg
*
* A request to set the flag options of a subject known to
* the sysevent daemon.
*
* Fields :
*
* flags : flags to be set on the tuple
* data : se_msg_strings
* The first contains the name of the tuple for which the flag options
* is to be set
*/
typedef struct
{
tuple_flag_t flags;
void *data; /* this will be 1 character strings
* the first is subject_bytes long
*/
} se_set_options_msg;
/*
* se_set_options_reply_msg
*
* A response from the sysevent daemon to a se_set_options_msg
*
* Fields :
* status : the status of the response. 0 means no error
*/
typedef struct
{
int status;
} se_set_options_reply_msg;
/*
* se_set_async_action_msg
*
* A request to set an executable and parameters to be called whenever
* a trigger changes value
* the sysevent daemon.
*
* Fields :
* flags : flags to be applied to this activation
* num_params : The number of parameters given in data
* data : se_msg_strings
* The first contains the name of the subject/trigger to monitor
* The second contains the executable that is to be called when trigger
* changes value
* The rest are num_params parameters to provide the executable
*/
typedef struct
{
action_flag_t flags;
int num_params;
void *data;
} se_set_async_action_msg;
/*
* se_set_async_message_msg
*
* A request to set an executable and parameters to be called whenever
* a trigger changes value
* the sysevent daemon.
*
* Fields :
* flags : flags to be applied to this trigger
* data : se_msg_strings
* The first contains the name of the subject/trigger to monitor
*/
typedef struct
{
action_flag_t flags;
void *data;
} se_set_async_message_msg;
/*
* async_id_t
* Used to identify the trigger and action of an async
* in case someone wants to cancel it
*/
typedef struct
{ unsigned int trigger_id;
unsigned int action_id;
} async_id_t;
/*
* se_set_async_reply_msg
*
* A response from the sysevent daemon to a se_set_async_action_msg
* or a se_set_async_notification_msg
*
* Fields :
* status : the status of the response. 0 means no error
*
* async_id : the id of the action that the async is attached to
* This are used to cancel the async
*/
typedef struct
{
int status;
async_id_t async_id;
} se_set_async_reply_msg;
/*
* se_remove_async_msg
*
* A request to remove an async action from a trigger
*
* Fields :
* async_id : the id of the action that the async is attached to
* This came from a previous se_set_async_reply_msg
*/
typedef struct
{
async_id_t async_id;
} se_remove_async_msg;
/*
* se_remove_async_reply_msg
*
* A response from the sysevent daemon to a se_remove_async_msg
*
* Fields :
* status : the status of the response. 0 means no error
*/
typedef struct
{
int status;
} se_remove_async_reply_msg;
/*
* se_notification_msg
*
* An asynchronous notification to a client that a data value has changed
*
* Fields :
* source : source of the message
* tid : transaction id of the message
* async_id : the id of the notification
* data : 2 se_msg_strings
* The first contains the name of the subject for which the value
* had been requested
* The second contains the current value
*/
typedef struct
{
int source;
int tid;
async_id_t async_id;
void *data;
} se_notification_msg;
/*
* se_show_data_elements_msg
*
* A request to retrieve the value of a subject known to
* the sysevent daemon.
*
* Fields :
* data : a se_msg_string which contains the name of the file
* to write the data elements to
*/
typedef struct
{
void *data;
} se_show_data_elements_msg;
/*
==========================================================================
inter-thread messages
==========================================================================
*/
/*
* se_die_msg
*
* A command to stop execution and close connections
*
* Fields :
* reserved: Not currently used
*/
typedef struct
{
void *reserved;
} se_die_msg;
/*
* se_send_notification_msg
*
* A command to message a client that some data value has changed
*
* Fields :
* source : source of the message
* tid : transaction id of the message
* token_id : id of the client to send message to
* async_id : the id of the notification
* flags : flags to modify behavior of action
* data : 2 se_msg_strings
* The first contains the name of the subject for which the value
* had been requested
* The second contains the current value
*/
typedef struct
{
int source;
int tid;
token_t token_id;
async_id_t async_id;
action_flag_t flags;
void *data;
} se_send_notification_msg;
/*
* se_run_executable_msg
*
* A command to run an executable in response to a value change
*
* Fields :
* token_id : id of the client which registered the executable
* async_id : the id of the notification
* flags : flags to modify behavior of action
* data : 2 se_msg_strings
* The first contains the name of the subject for which the value
* had been requested
* The second contains the current value
*/
typedef struct
{
token_t token_id;
async_id_t async_id;
action_flag_t flags;
void *data;
} se_run_executable_msg;
/*
* se_run_serially_msg
*
* An inter-thread message describing a list of events to run serially to completion
*
* Fields :
* async_id : the id of the notification
* num_msgs : the number of messages in the serial_msg_list_t
* data : a pointer to serial_msg_list_t containing a list to run serially
*/
typedef struct
{
async_id_t async_id;
int num_msgs;
void *data;
} se_run_serially_msg;
/*
===============================================================
Functions
===============================================================
*/
/*
* Procedure : SE_strerror
* Purpose : Return a string version of an error code
* Parameters :
* error : The error
* Return Code :
* The string.
* Do NOT save this string. It has no lifespan
*/
char *SE_strerror (int error);
/*
* Procedure : SE_print_mtype
* Purpose : Return a string for a msgtype
* Parameters :
* mtype : The msg type
* Return Code :
* The string.
* Do NOT save this string. It has no lifespan
*/
char *SE_print_mtype (int mtype);
/*
* Procedure : init_libsysevent
* Purpose : initialize this library
* Parameters :
* name : name of the user of this library
* Return Code :
* Notes : This doesn't need to be called by most users
* of libsysevent since it is implicitly called during
* sysevent_open. It is used by syseventd.
*/
void init_libsysevent(const char* const name);
/*
* Procedure : sysevent_open
* Purpose : Connect to the sysevent daemon
* Parameters :
* ip : ip address to connect to.
* This may be dots and dashes or hostname
* port : port to connect to
* version : version of client
* id : name of client
* token : on return, an opaque value to be used in future calls for this session
* Return Code :
* NULL : error
* >0 : file descriptor for connection
*/
int sysevent_open(char *ip, unsigned short port, int version, char *id, token_t *token);
int sysevent_open_data (char *ip, unsigned short port, int version, char *id, token_t *token);
/*
* Procedure : sysevent_local_open
* Purpose : Connect to the sysevent daemon using Unix Domain Socket
* Parameters :
* target : the name of the uds to connect to
* version : version of client
* id : name of client
* token : opaque id for future contact
* Return Code :
* The file descriptor to use in future calls
* -1 if error
*/
int sysevent_local_open (char *target, int version, char *id, token_t *token);
int sysevent_local_open_data (char *target, int version, char *id, token_t *token);
/*
* Procedure : sysevent_close
* Purpose : Disconnect from the sysevent daemon
* Parameters :
* fd : the file descriptor to close
* token : The server provided opaque id of the client
* Return Code :
* 0 : disconnected
* !0 : some error
*/
int sysevent_close(const int fd, const token_t token);
/*
* Procedure : sysevent_ping
* Purpose : Ping a connection to the sysevent daemon
* Parameters :
* fd : the file descriptor to ping
* token : Server provided opaque value
* Return Code :
* 0 : ping msg sent
* !0 : some error
* Note : We only told sysevent daemon to ping reply. We are not handling the
* reply itself. That is up to the caller
* Note that there is no current need to ping. If the server
* breaks the connection then there will be a series of SE_MSG_NONE
* coming on the connection. Receipt of several SE_MSG_NONE can be used
* by clients to realize the connection is broken
*
* if you are looking for a blocking ping test which waits for a ping reply
* then use sysevent_ping_test
*/
int sysevent_ping (int fd, token_t token);
/*
* Procedure : sysevent_ping_test
* Purpose : Ping a connection to the sysevent daemon
* AND wait for reply
* Parameters :
* fd : the file descriptor to ping
* token : Server provided opaque value
* tv : A timeval describing how long to wait
* Return Code :
* 0 : ping reply msg received
* !0 : some error
*/
int sysevent_ping_test (int fd, token_t token, struct timeval* tv);
/*
* Procedure : sysevent_get
* Purpose : Send a get to the sysevent daemon and receive reply
* Parameters :
* fd the connection descriptor
* token : The server provided opaque id of the client
* inbuf : A null terminated string which is the thing to get
* outbuf : A buffer to hold returned value
* outbytes : The maximum number of bytes in outbuf
* Return Code :
* 0 : Reply received
* !0 : Some error
* Notes :
* If outbuf is not big enough to hold the reply value, then the value will
* be truncated to fit. An error of ERR_INSUFFICIENT_ROOM will be returned.
* The value will always be NULL terminated, so the outbuf must contain
* enough bytes for the return value as well as the NULL byte.
*/
int sysevent_get(const int fd, const token_t token, const char *inbuf, char *outbuf, int outbytes);
/*
* Procedure : sysevent_get_data
* Purpose : Send a get to the sysevent daemon and receive reply
* Parameters :
* fd : The connection id
* token : Server provided opaque value
* inbuf : A null terminated string which is the thing to get
* inbytes : The length of the string not counting terminating null
* outbuf : A buffer to hold returned value
* outbytes : The maximum number of bytes in outbuf
* bufsizecopied : The actual number of bytes copied into outbuf
* Return Code :
* 0 : Reply received
* !0 : Some error
* Notes :
* If outbuf is not big enough to hold the reply value, then the value will
* be truncated to fit. An error of ERR_INSUFFICIENT_ROOM will be returned.
* The value will always be NULL terminated, so the outbuf must contain
* enough bytes for the return value as well as the NULL byte.
*/
int sysevent_get_data(const int fd, const token_t token, const char *inbuf, char *outbuf, int outbytes,int *actualsizecopied);
/*
* Procedure : sysevent_set
* Purpose : Send a set to the sysevent daemon
* A set may change the value of a tuple
* Parameters :
* fd the connection descriptor
* token : The server provided opaque id of the client
* name : A null terminated string which is the tuple to set
* value : A null terminated string which is the value to set tuple to, or NULL
* Return Code :
* 0 : Success
* !0 : Some error
*/
int sysevent_set(const int fd, const token_t token, const char *name, const char *value, int conf_req);
/*
* Procedure : sysevent_set_data
* Purpose : Send a set to the sysevent daemon
* A set may change the value of a tuple
* Parameters :
* fd : The connection id
* token : Server provided opaque value
* name : A null terminated string which is the tuple to set
* value : buffer holds binary data which is the value to set tuple to, or NULL
* value_length : actual size of binary data buffer
* Return Code :
* 0 : Reply received
* !0 : Some error
*/
int sysevent_set_data(const int fd, const token_t token, const char *name, const char *value, int value_length);
/*
* Procedure : sysevent_unset
* Purpose : Send a set to the sysevent daemon
* A set with NULL value of a tuple to clear existing value from volatile memory.
* Parameters :
* fd : The connection id
* token : Server provided opaque value
* name : A null terminated string which is the tuple to set
* value : NULL by default
* Return Code :
* 0 : Reply received
* !0 : Some error
*/
int sysevent_unset (const int fd, const token_t token, const char *name);
/*
* Procedure : sysevent_set_with_tid
* Purpose : Send a set to the sysevent daemon
* A set may change the value of a tuple
* Parameters :
* fd : The connection id
* token : Server provided opaque value
* name : A null terminated string which is the tuple to set
* value : A null terminated string which is the value to set tuple to, or NULL
* source : source of message
* tid : transaction id
* Return Code :
* 0 : Success
* !0 : Some error
*/
int sysevent_set_with_tid (const int fd, const token_t token, const char *name, const char *value, const int source, const int tid);
/*
* Procedure : sysevent_set_unique
* Purpose : Send a set unique to the sysevent daemon and receive reply
* A set will create a new tuple with name derived from client request,
* and it will set this new tuple to the value.
* Parameters :
* fd the connection descriptor
* token : The server provided opaque id of the client
* name : A null terminated string which is the namespace of the tuple to create and set
* value : A null terminated string which is the value to set tuple to, or NULL
* outbuf : A buffer to hold returned value
* outbytes : The maximum number of bytes in outbuf
* Return Code :
* 0 : Reply received
* !0 : Some error
* Note that the position of the newly added item within its namespace is not guaranteed to be
* in a particular order when iterating through the space using sysevent_get_unique.
* If you need to guarantee that the newly added item is iterated in order of its addition to the
* namespace (and are willing to cost the system some memory for each element in the namespace) then
* you must use the ! character as the first character in your namespace
*/
int sysevent_set_unique(const int fd, const token_t token, const char *name, const char *value, char *outbuf, int outbytes);
/*
* Procedure : sysevent_get_unique
* Purpose : Send a get for a unique element to the sysevent daemon and receive reply
* This returns the next value.
* Parameters :
* fd the connection descriptor
* token : The server provided opaque id of the client
* inbuf : A null terminated string which is the namespace of the thing to get
* iterator : A iterator which is initialize to NULL
* on return it will contain the next iterator
* subjectbuf : A buffer to hold returned unique name
* subjectbytes : The maximum number of bytes in subjectbuf
* valuebuf : A buffer to hold returned value
* valuebytes : The maximum number of bytes in valuebuf
* Return Code :
* 0 : Reply received
* !0 : Some error
* Notes :
* If either is not big enough to hold the reply value, then the value will
* be truncated to fit. An error of ERR_INSUFFICIENT_ROOM will be returned.
* The value will always be NULL terminated, so the outbuf must contain
* enough bytes for the return value as well as the NULL byte.
*/
int sysevent_get_unique(const int fd, const token_t token, const char *inbuf, unsigned int *iterator, char *subjectbuf, int subjectbytes, char *valuebuf, int valuebytes);
/*
* Procedure : sysevent_del_unique
* Purpose : Send a delete of unique element from its namespace
* Parameters :
* fd the connection descriptor
* token : The server provided opaque id of the client
* inbuf : A null terminated string which is the namespace of the thing to delete
* iterator : A iterator which is describing the element to delete within the namespace
* The first iterator is SYSEVENT_NULL_ITERATOR
* Return Code :
* 0 :
*/
int sysevent_del_unique(const int fd, const token_t token, const char *inbuf, unsigned int *iterator);
/*
* Procedure : sysevent_get_next_iterator
* Purpose : Get the next iterator for a namespace
* Parameters :
* fd the connection descriptor
* token : The server provided opaque id of the client
* inbuf : A null terminated string which is the namespace
* iterator : A iterator which is describing the current iterator. Initially set to 0
* On return it contains the next iterator to the namespace
* Return Code :
* 0 :
*/
int sysevent_get_next_iterator(const int fd, const token_t token, const char *inbuf, unsigned int *iterator);
/*
* Procedure : sysevent_set_options
* Purpose : Send a set options flag to the sysevent daemon and receive reply
* A set may change the event flags of that tuple
* Parameters :
* fd the connection descriptor
* token : The server provided opaque id of the client
* name : A null terminated string which is the tuple to set
* flags : The flags to set tuple to
* Return Code :
* 0 : Success
* !0 : Some error
*/
int sysevent_set_options(const int fd, const token_t token, const char *name, unsigned int flags);
/*
* Procedure : sysevent_setcallback
* Purpose : Declare a program to run when a given tuple changes value
* Parameters :
* fd the connection descriptor
* token : The server provided opaque id of the client
* flags : action_flag_t flags to control the activation
* subject : A null terminated string which is the name of the tuple
* function : An execeutable to call when the tuple changes value
* numparams : The number of arguments in the following char**
* params : A list of 0 or more parameters to use when calling the function
* async_id : On return, and id that can be used to cancel the callback
* Return Code :
* 0 : Success
* !0 : Some error
* Notes :
* When the tuple changes value the executabl3 will be called with all parameters given
* the value of parameters will be either:
* the exact string given as a parameter, or
* if the parameter begins with $ the return will be the current value
* of the trigger by that name. If the trigger does not exist
* then "NULL" will be used.
* For example, if the subject is trigger1, the function /bin/programA, and
* the parameter list is 3 params = trigger1, $trigger3, $trigger1.
* Assuming trigger3 has not yet been set,
* Then when trigger1 changes to "new_value", a process will be forked to
* call /bin/programA "trigger1" "NULL" "new_value"
*/
int sysevent_setcallback(const int fd, const token_t token, action_flag_t flags, char *subject, char *function, int numparams, char **params, async_id_t *async_id);
/*
* Procedure : sysevent_rmcallback
* Purpose : Remove an callback/notification from a trigger
* Parameters :
* fd the connection descriptor
* token : The server provided opaque id of the client
* async_id : The async id to remove
* Return Code :
* 0 : Async action is removed
*/
int sysevent_rmcallback(const int fd, const token_t token, async_id_t async_id);
/*
* Procedure : sysevent_setnotification
* Purpose : Request a notification message to be sent when a given tuple changes value
* Parameters :
* fd : the connection descriptor
* token : The server provided opaque id of the client
* subject : A null terminated string which is the name of the tuple
* async_id : On return, and id that can be used to cancel the notification
* Return Code :
* 0 : Success
* !0 : Some error
* Note : A notification can only be sent to a client which is still connected
* Note : Notifications are asynchronous and should be sent to a client connection
* which is dedicated to asynchronous sysevent messages. In other words a
* connection which is not shared with a thread doing sets/gets etc.
*/
int sysevent_setnotification(const int fd, const token_t token, char *subject, async_id_t *async_id);
/*
* Procedure : sysevent_rmnotification
* Purpose : Remove an callback/notification from a trigger
* Parameters :
* fd the connection descriptor
* token : The server provided opaque id of the client
* async_id : The async id to remove
* Return Code :
* 0 : Async action is removed
*/
int sysevent_rmnotification(const int fd, const token_t token, async_id_t async_id);
/*
* Procedure : sysevent_getnotification
* Purpose : Wait for a notification and return the results when received
* Parameters :
* fd : The connection id
* token : The server provided opaque id of the client
* namebuf : A buffer to hold the name received
* namebytes : The length of the string not counting terminating null
* valbuf : A buffer to hold returned value
* valbytes : On input the maximum number of bytes in outbuf
* On output the actual number of bytes in outbuf not counting
* the terminating null
* async_id : The async id of the action
* Return Code :
* 0 : Reply received
* !0 : Some error
* Notes :
* If a buffer is not big enough to hold the reply value, then the value will
* be truncated to fit. An error of ERR_INSUFFICIENT_ROOM will be returned.
* The value will always be NULL terminated, so the buffer must contain
* enough bytes for the return value as well as the NULL byte.
* Notes
* This will block
*/
int sysevent_getnotification (const int fd, const token_t token, char *namebuf, int *namebytes, char *valbuf, int *valbytes, async_id_t *async_id);
/*
* Procedure : sysevent_getnotification_data
* Purpose : Wait for a notification and return the results when received
* Parameters :
* fd : The connection id
* token : A server generated opaque value
* namebuf : A buffer to hold the name received
* namebytes : The length of the string not counting terminating null
* valbuf : A buffer to hold returned value
* valbytes : On input the maximum number of bytes in outbuf
* On output the actual number of bytes in outbuf
* async_id : The async id of the action
* Return Code :
* 0 : Reply received
* !0 : Some error
* Notes :
* If a buffer is not big enough to hold the reply value, then the value will
* be truncated to fit. An error of ERR_INSUFFICIENT_ROOM will be returned.
* The value will always be NULL terminated, so the buffer must contain
* enough bytes for the return value as well as the NULL byte.
* Notes
* This will block
*/
int sysevent_getnotification_data (const int fd, const token_t token, char *namebuf, int *namebytes, char *valbuf, int *valbytes, async_id_t *async_id);
/*
* Procedure : sysevent_show
* Purpose : Tell daemon to show all data elements
* Parameters :
* fd : The connection id
* token : The server provided opaque id of the client
* file : A null terminated string which is the file to write to
* Return Code :
* 0 : Success
* !0 : Some error
*/
int sysevent_show (const int fd, const token_t token, const char *file);
/*
* Procedure : sysevent_debug
* Purpose : Set sysevent daemon debug level
* Parameters :
* ip : the name or ip address of the sysevent daemon to send msg to
* port : the port of the sysevent daemon to send to
* level : Debug level to set to
* Return Code :
* 0 : debug msg sent
* !0 : some error
*/
int sysevent_debug (char *ip, unsigned short port, int level);
unsigned int sysevent_get_binmsg_maxsize();
#ifdef __cplusplus
}
#endif
#endif /* __LIB_SYSEVENT_H_ */
| 33.122494 | 170 | 0.628497 |