hexsha stringlengths 40 40 | size int64 5 1.05M | ext stringclasses 588
values | lang stringclasses 305
values | max_stars_repo_path stringlengths 3 363 | max_stars_repo_name stringlengths 5 118 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 10 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringdate 2015-01-01 00:00:35 2022-03-31 23:43:49 ⌀ | max_stars_repo_stars_event_max_datetime stringdate 2015-01-01 12:37:38 2022-03-31 23:59:52 ⌀ | max_issues_repo_path stringlengths 3 363 | max_issues_repo_name stringlengths 5 118 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 10 | max_issues_count float64 1 134k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 363 | max_forks_repo_name stringlengths 5 135 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 10 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringdate 2015-01-01 00:01:02 2022-03-31 23:27:27 ⌀ | max_forks_repo_forks_event_max_datetime stringdate 2015-01-03 08:55:07 2022-03-31 23:59:24 ⌀ | content stringlengths 5 1.05M | avg_line_length float64 1.13 1.04M | max_line_length int64 1 1.05M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8e3b9d6965a7c975f7d4cceea03a54c464ed1550 | 373 | c | C | HW-10/hello.c | gyf1214/ICS | d7a5e80d157853434a79e1fa0f83dd30dc7cb90a | [
"MIT"
] | 1 | 2016-12-22T09:59:44.000Z | 2016-12-22T09:59:44.000Z | HW-10/hello.c | gyf1214/ICS | d7a5e80d157853434a79e1fa0f83dd30dc7cb90a | [
"MIT"
] | null | null | null | HW-10/hello.c | gyf1214/ICS | d7a5e80d157853434a79e1fa0f83dd30dc7cb90a | [
"MIT"
] | null | null | null | #include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/mman.h>
int main() {
int fd = open("hello.txt", O_RDWR);
size_t size = lseek(fd, 0, SEEK_END);
lseek(fd, 0, SEEK_SET);
char *buf = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
buf[0] += 2;
munmap(buf, size);
close(fd);
return 0;
}
| 20.722222 | 76 | 0.600536 |
32d7f7d6308a00f6b1785a64c6786107fb464b10 | 2,115 | h | C | include/star/3rdparty/UltraLib/Include/bcg/BCGPSDPlaceMarkerWnd.h | hara-y/StarROS | 03008d8acb46f606bf750cdbb4a9703fae427694 | [
"Apache-2.0"
] | 2 | 2020-05-16T03:14:54.000Z | 2020-05-16T08:27:24.000Z | include/star/3rdparty/UltraLib/Include/bcg/BCGPSDPlaceMarkerWnd.h | hara-y/StarROS | 03008d8acb46f606bf750cdbb4a9703fae427694 | [
"Apache-2.0"
] | null | null | null | include/star/3rdparty/UltraLib/Include/bcg/BCGPSDPlaceMarkerWnd.h | hara-y/StarROS | 03008d8acb46f606bf750cdbb4a9703fae427694 | [
"Apache-2.0"
] | 3 | 2020-05-15T09:50:06.000Z | 2020-08-26T12:47:05.000Z | #if !defined(AFX_BCGPSDPLACEMARKERWND_H__FA84F558_73E5_40AA_9C70_4D69E9FF496C__INCLUDED_)
#define AFX_BCGPSDPLACEMARKERWND_H__FA84F558_73E5_40AA_9C70_4D69E9FF496C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// This is a part of BCGControlBar Library Professional Edition
// Copyright (C) 1998-2010 BCGSoft Ltd.
// All rights reserved.
//
// This source code can be used, distributed or modified
// only under terms and conditions
// of the accompanying license agreement.
//*******************************************************************************
//
// BCGPSDPlaceMarkerWnd.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CBCGPSDPlaceMarkerWnd window
class CBCGPSDPlaceMarkerWnd : public CWnd
{
friend class CBCGPSmartDockingManager;
// Construction
public:
CBCGPSDPlaceMarkerWnd ();
void Create (CWnd* pwndOwner);
void SetDockingWnd (CWnd* pDockingWnd)
{
m_pDockingWnd = pDockingWnd;
}
void ShowAt (CRect rect);
void ShowTabbedAt (CRect rect, CRect rectTab);
void Hide ();
// Attributes
protected:
CWnd* m_pWndOwner;
CWnd* m_pDockingWnd;
CRect m_rectLast;
CRect m_rectTab;
BOOL m_bTabbed;
BOOL m_bShown;
BOOL m_bUseThemeColorInShading;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBCGPSDPlaceMarkerWnd)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CBCGPSDPlaceMarkerWnd();
// Generated message map functions
protected:
//{{AFX_MSG(CBCGPSDPlaceMarkerWnd)
afx_msg void OnPaint();
afx_msg void OnClose();
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BCGPSDPLACEMARKERWND_H__FA84F558_73E5_40AA_9C70_4D69E9FF496C__INCLUDED_)
| 25.481928 | 97 | 0.646809 |
0a5b4406b3d12c827f49e20b11fc9c6d6da86b91 | 1,500 | h | C | Intercom.xcframework/ios-arm64_armv7/Intercom.framework/PrivateHeaders/ICMDataManager.h | intercom/intercom-ios | c9135d7293b8e7d0ea47db5eb86a7ebee29132ab | [
"Apache-2.0",
"BSD-3-Clause"
] | 326 | 2015-01-06T01:11:52.000Z | 2022-03-29T22:43:59.000Z | Intercom.xcframework/ios-arm64_i386_x86_64-simulator/Intercom.framework/PrivateHeaders/ICMDataManager.h | intercom/intercom-ios | c9135d7293b8e7d0ea47db5eb86a7ebee29132ab | [
"Apache-2.0",
"BSD-3-Clause"
] | 277 | 2015-01-05T03:11:57.000Z | 2021-11-18T12:23:34.000Z | Intercom.xcframework/ios-arm64_armv7/Intercom.framework/PrivateHeaders/ICMDataManager.h | intercom/intercom-ios | c9135d7293b8e7d0ea47db5eb86a7ebee29132ab | [
"Apache-2.0",
"BSD-3-Clause"
] | 152 | 2015-03-03T00:46:40.000Z | 2021-12-15T18:56:53.000Z | //
// ICMDataManager.h
// IntercomSDK
//
// Created by Dale Cantwell on 28/04/2014.
// Copyright (c) 2014 Intercom. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "ICMUnreadManager.h"
#import "ICMDataManagerProtocol.h"
@class ICMConversation;
@interface ICMDataManager : NSObject <ICMDataManagerProtocol>
@property (nonatomic, readonly) NSMutableArray<ICMConversation *> *conversations;
@property (nonatomic, strong) NSString *conversationToMark;
@property (nonatomic, strong) ICMUnreadManager *unreadManager;
@property (nonatomic, strong) ICMConversation *lastViewedConversation;
@property (nonatomic, assign) BOOL morePagesAvailable;
@property (nonatomic, assign) BOOL hasReceivedConversationsResponse;
+ (instancetype)sharedManager;
- (void)updateConversationsBefore:(NSDate *)before success:(void (^)(NSArray <ICMConversation *> *conversations, BOOL newElementsAdded))success failure:(void (^)(NSError *error))failure;
- (void)updateConversationsWithSuccess:(void (^)(NSArray <ICMConversation *> *conversations))success failure:(void (^)(NSError *error))failure;
- (void)updateWithConversation:(ICMConversation *)conversation;
- (void)getUnreadConversationsIfNeeded;
- (NSArray<ICMConversation *> *)getRecentConversations;
- (NSArray<ICMConversation *> *)getPreviousConversations;
- (void)clearConversations;
- (BOOL)hasRecentConversations;
- (BOOL)hasPreviousConversations;
- (NSInteger)recentConversationCount;
- (BOOL)hasConversations;
@end
| 39.473684 | 186 | 0.789333 |
1140bd5b416300ae0619bf8f269069d509848dc3 | 1,619 | h | C | Scribble/stdafx.h | calgaryscientific/pureweb-cpp-samples | 71ba4e501a05f40dc6447a8e8888848c596c4ef5 | [
"Apache-2.0"
] | null | null | null | Scribble/stdafx.h | calgaryscientific/pureweb-cpp-samples | 71ba4e501a05f40dc6447a8e8888848c596c4ef5 | [
"Apache-2.0"
] | null | null | null | Scribble/stdafx.h | calgaryscientific/pureweb-cpp-samples | 71ba4e501a05f40dc6447a8e8888848c596c4ef5 | [
"Apache-2.0"
] | null | null | null | // Copyright 2013-2019 Calgary Scientific Inc. (operating under the brand name of PureWeb)
//
// 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.
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef _SECURE_ATL
#define _SECURE_ATL 1
#endif
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include "targetver.h"
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include "pureweb.h"
| 26.983333 | 93 | 0.741816 |
76dd9e296f702d0d535039f2faf4a12d83582e64 | 211 | h | C | kandy-cpaas2-sample-ios-oc/Handlers/Chat_Controller.h | hclsampleapps/kandy-cpaas2-sample-ios-oc | d2ea32c3a6fee049769853f91cb47a07a43dc3b1 | [
"MIT"
] | null | null | null | kandy-cpaas2-sample-ios-oc/Handlers/Chat_Controller.h | hclsampleapps/kandy-cpaas2-sample-ios-oc | d2ea32c3a6fee049769853f91cb47a07a43dc3b1 | [
"MIT"
] | null | null | null | kandy-cpaas2-sample-ios-oc/Handlers/Chat_Controller.h | hclsampleapps/kandy-cpaas2-sample-ios-oc | d2ea32c3a6fee049769853f91cb47a07a43dc3b1 | [
"MIT"
] | null | null | null |
#import <UIKit/UIKit.h>
@import CPaaSSDK;
NS_ASSUME_NONNULL_BEGIN
@interface Chat_Controller : UIViewController <CPChatDelegate>
@property(strong, nonatomic) CPaaS* cpaasObject;
@end
NS_ASSUME_NONNULL_END
| 15.071429 | 62 | 0.810427 |
133bd54e8fda03efcb379b53e4ca60de76e5e250 | 2,301 | h | C | 2.4/include/java/sql/SQLPermission.h | yaohb/J2ObjCAuto | 8b5252896999f367066e3f68226620f78c020923 | [
"MIT"
] | null | null | null | 2.4/include/java/sql/SQLPermission.h | yaohb/J2ObjCAuto | 8b5252896999f367066e3f68226620f78c020923 | [
"MIT"
] | null | null | null | 2.4/include/java/sql/SQLPermission.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/sql/SQLPermission.java
//
#include "J2ObjC_header.h"
#pragma push_macro("INCLUDE_ALL_JavaSqlSQLPermission")
#ifdef RESTRICT_JavaSqlSQLPermission
#define INCLUDE_ALL_JavaSqlSQLPermission 0
#else
#define INCLUDE_ALL_JavaSqlSQLPermission 1
#endif
#undef RESTRICT_JavaSqlSQLPermission
#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 (JavaSqlSQLPermission_) && (INCLUDE_ALL_JavaSqlSQLPermission || defined(INCLUDE_JavaSqlSQLPermission))
#define JavaSqlSQLPermission_
#define RESTRICT_JavaSecurityBasicPermission 1
#define INCLUDE_JavaSecurityBasicPermission 1
#include "java/security/BasicPermission.h"
/*!
@brief Legacy security code; do not use.
*/
@interface JavaSqlSQLPermission : JavaSecurityBasicPermission
#pragma mark Public
- (instancetype __nonnull)initWithNSString:(NSString *)name;
- (instancetype __nonnull)initWithNSString:(NSString *)name
withNSString:(NSString *)actions;
@end
J2OBJC_EMPTY_STATIC_INIT(JavaSqlSQLPermission)
FOUNDATION_EXPORT void JavaSqlSQLPermission_initWithNSString_(JavaSqlSQLPermission *self, NSString *name);
FOUNDATION_EXPORT JavaSqlSQLPermission *new_JavaSqlSQLPermission_initWithNSString_(NSString *name) NS_RETURNS_RETAINED;
FOUNDATION_EXPORT JavaSqlSQLPermission *create_JavaSqlSQLPermission_initWithNSString_(NSString *name);
FOUNDATION_EXPORT void JavaSqlSQLPermission_initWithNSString_withNSString_(JavaSqlSQLPermission *self, NSString *name, NSString *actions);
FOUNDATION_EXPORT JavaSqlSQLPermission *new_JavaSqlSQLPermission_initWithNSString_withNSString_(NSString *name, NSString *actions) NS_RETURNS_RETAINED;
FOUNDATION_EXPORT JavaSqlSQLPermission *create_JavaSqlSQLPermission_initWithNSString_withNSString_(NSString *name, NSString *actions);
J2OBJC_TYPE_LITERAL_HEADER(JavaSqlSQLPermission)
#endif
#if __has_feature(nullability)
#pragma clang diagnostic pop
#endif
#pragma clang diagnostic pop
#pragma pop_macro("INCLUDE_ALL_JavaSqlSQLPermission")
| 32.408451 | 151 | 0.837897 |
92bac5fa9f58b508d6ac0bf06692f25dd3818088 | 400 | h | C | be/src/storage/lake/tablet_metadata.h | stephen-shelby/starrocks | 67932670efddbc8c56e2aaf5d3758724dcb44b0a | [
"Zlib",
"PSF-2.0",
"BSD-2-Clause",
"Apache-2.0",
"ECL-2.0",
"BSD-3-Clause-Clear"
] | 1 | 2022-03-08T09:13:32.000Z | 2022-03-08T09:13:32.000Z | be/src/storage/lake/tablet_metadata.h | stephen-shelby/starrocks | 67932670efddbc8c56e2aaf5d3758724dcb44b0a | [
"Zlib",
"PSF-2.0",
"BSD-2-Clause",
"Apache-2.0",
"ECL-2.0",
"BSD-3-Clause-Clear"
] | null | null | null | be/src/storage/lake/tablet_metadata.h | stephen-shelby/starrocks | 67932670efddbc8c56e2aaf5d3758724dcb44b0a | [
"Zlib",
"PSF-2.0",
"BSD-2-Clause",
"Apache-2.0",
"ECL-2.0",
"BSD-3-Clause-Clear"
] | null | null | null | // This file is licensed under the Elastic License 2.0. Copyright 2021-present, StarRocks Limited.
#pragma once
#include <memory>
#include "gen_cpp/starlake.pb.h"
namespace starrocks::lake {
using TabletMetadata = TabletMetadataPB;
using TabletMetadataPtr = std::shared_ptr<const TabletMetadata>;
using MutableTabletMetadataPtr = std::shared_ptr<TabletMetadata>;
} // namespace starrocks::lake
| 25 | 98 | 0.7875 |
dd4f344c8fbdc1cc8022d6839b455fd8a57d2c52 | 2,062 | c | C | screen.c | Goloman/crescent | 212ed93e9235e62bbe321f23c67b97cd1899db0e | [
"MIT"
] | 1 | 2016-07-27T10:15:08.000Z | 2016-07-27T10:15:08.000Z | screen.c | Goloman/crescent | 212ed93e9235e62bbe321f23c67b97cd1899db0e | [
"MIT"
] | null | null | null | screen.c | Goloman/crescent | 212ed93e9235e62bbe321f23c67b97cd1899db0e | [
"MIT"
] | null | null | null | #include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#define TICK_INTERNAL 100
#define SDL_ERR() (fprintf(stderr, "%s:%d %s\n", __FILE__, __LINE__, SDL_GetError()), exit(EXIT_FAILURE))
int main() {
if (SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO) != 0)
SDL_ERR();
SDL_Window *win = SDL_CreateWindow("Test",
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
SCREEN_WIDTH,
SCREEN_HEIGHT,
SDL_WINDOW_SHOWN);
if(win == NULL) SDL_ERR();
SDL_Renderer *ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if(ren == NULL) SDL_ERR();
SDL_SetRenderDrawColor(ren, 0,0,0,255);
SDL_Texture *txt = IMG_LoadTexture(ren, "img/png/TestBox.png");
if(txt == NULL) SDL_ERR();
SDL_Event e;
SDL_bool quit = SDL_FALSE;
Uint32 next = SDL_GetTicks() + TICK_INTERNAL;
unsigned short pillars = 0;
while (!quit) {
while (SDL_PollEvent(&e))
if(e.type == SDL_QUIT)
quit = SDL_TRUE;
SDL_RenderClear(ren);
// floor
for(int i=0; i<8; i++)
for(int j=0; j<8; j++) {
SDL_Rect r;
r.x = SCREEN_WIDTH/2 + ((i - j - 1) * 32);
r.y = 100 + (i + j) * 16;;
r.w = 64;
r.h = 96;
SDL_RenderCopy(ren, txt, NULL, &r);
}
// walls
for(int i=0; i<8; i++) {
for(int j=0; j<8; j++) {
if((pillars & 0xff) & (1 << i)) continue;
if((pillars >> 8) & (1 << j)) continue;
SDL_Rect r;
r.x = SCREEN_WIDTH/2 + ((i - j - 1) * 32);
r.y = 34 + (i + j) * 16;;
r.w = 64;
r.h = 96;
SDL_RenderCopy(ren, txt, NULL, &r);
}
}
pillars++;
SDL_RenderPresent(ren);
// make sure the framerate is more
// or less fine and don't fty the cpu
Uint32 current = SDL_GetTicks();
if(next > current)
SDL_Delay(next - current);
next += TICK_INTERNAL;
}
SDL_DestroyRenderer(ren);
SDL_DestroyWindow(win);
SDL_Quit();
return EXIT_SUCCESS;
}
| 22.172043 | 105 | 0.571775 |
46b48d22affe719f8e4d0d048a8ef9ec255e5f9d | 26,164 | h | C | DREAM3DReviewFilters/InsertTransformationPhases.h | JDuffeyBQ/DREAM3DReview | 098ddc60d1c53764e09e21e08d4636233071be31 | [
"BSD-3-Clause"
] | null | null | null | DREAM3DReviewFilters/InsertTransformationPhases.h | JDuffeyBQ/DREAM3DReview | 098ddc60d1c53764e09e21e08d4636233071be31 | [
"BSD-3-Clause"
] | 18 | 2017-09-01T23:13:02.000Z | 2021-09-02T12:58:57.000Z | DREAM3DReviewFilters/InsertTransformationPhases.h | JDuffeyBQ/DREAM3DReview | 098ddc60d1c53764e09e21e08d4636233071be31 | [
"BSD-3-Clause"
] | 9 | 2017-09-01T23:15:17.000Z | 2021-09-21T13:24:19.000Z | /* ============================================================================
* Copyright (c) 2011 Michael A. Jackson (BlueQuartz Software)
* Copyright (c) 2011 Dr. Michael A. Groeber (US Air Force Research Laboratories)
* Copyright (c) 2015 Dr. Joseph C. Tucker (UES, Inc.)
* Copyright (c) 2014 Sudipto Mandal & Prof. Anthony D. Rollett (Carnegie Mellon
* University)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice, this
* list of conditions and the following disclaimer in the documentation and/or
* other materials provided with the distribution.
*
* Neither the name of Joseph C. Tucker, Michael A. Groeber, Michael A. Jackson,
* Sudipto Mandal, Anthony D. Rollett, UES, Inc., the US Air Force, BlueQuartz
* Software, Carnegie Mellon University nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This code was written under United States Air Force Contract number
* FA8650-07-D-5800 and FA8650-10-D-5226 and The Boeing Company
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
#pragma once
#include <memory>
#include <vector>
#include <QtCore/QString>
#include "SIMPLib/SIMPLib.h"
#include "SIMPLib/Common/PhaseType.h"
#include "SIMPLib/Common/ShapeType.h"
#include "SIMPLib/DataArrays/DataArray.hpp"
#include "SIMPLib/DataArrays/IDataArray.h"
#include "SIMPLib/DataContainers/DataContainer.h"
#include "SIMPLib/FilterParameters/FloatVec3FilterParameter.h"
#include "SIMPLib/Filtering/AbstractFilter.h"
#include "EbsdLib/Core/EbsdLibConstants.h"
#include "EbsdLib/Core/Quaternion.hpp"
#include "DREAM3DReview/DREAM3DReviewConstants.h"
#include "DREAM3DReview/DREAM3DReviewDLLExport.h"
class LaueOps;
using LaueOpsShPtrType = std::shared_ptr<LaueOps>;
using LaueOpsContainer = std::vector<LaueOpsShPtrType>;
/**
* @class InsertTransformationPhases InsertTransformationPhases.h DREAM3DLib/SyntheticBuildingFilters/InsertTransformationPhases.h
* @brief
* @author Joseph C. Tucker (UES, Inc.)
* @author Sudipto Mandal (CMU)
* @date Feb 6, 2015
* @version 5.1
*/
class DREAM3DReview_EXPORT InsertTransformationPhases : public AbstractFilter
{
Q_OBJECT
// Start Python bindings declarations
PYB11_BEGIN_BINDINGS(InsertTransformationPhases SUPERCLASS AbstractFilter)
PYB11_FILTER()
PYB11_SHARED_POINTERS(InsertTransformationPhases)
PYB11_FILTER_NEW_MACRO(InsertTransformationPhases)
PYB11_PROPERTY(int ParentPhase READ getParentPhase WRITE setParentPhase)
PYB11_PROPERTY(int TransCrystalStruct READ getTransCrystalStruct WRITE setTransCrystalStruct)
PYB11_PROPERTY(float TransformationPhaseMisorientation READ getTransformationPhaseMisorientation WRITE setTransformationPhaseMisorientation)
PYB11_PROPERTY(FloatVec3Type TransformationPhaseHabitPlane READ getTransformationPhaseHabitPlane WRITE setTransformationPhaseHabitPlane)
PYB11_PROPERTY(bool DefineHabitPlane READ getDefineHabitPlane WRITE setDefineHabitPlane)
PYB11_PROPERTY(bool UseAllVariants READ getUseAllVariants WRITE setUseAllVariants)
PYB11_PROPERTY(float CoherentFrac READ getCoherentFrac WRITE setCoherentFrac)
PYB11_PROPERTY(float TransformationPhaseThickness READ getTransformationPhaseThickness WRITE setTransformationPhaseThickness)
PYB11_PROPERTY(int NumTransformationPhasesPerFeature READ getNumTransformationPhasesPerFeature WRITE setNumTransformationPhasesPerFeature)
PYB11_PROPERTY(float PeninsulaFrac READ getPeninsulaFrac WRITE setPeninsulaFrac)
PYB11_PROPERTY(DataArrayPath StatsGenCellEnsembleAttributeMatrixPath READ getStatsGenCellEnsembleAttributeMatrixPath WRITE setStatsGenCellEnsembleAttributeMatrixPath)
PYB11_PROPERTY(DataArrayPath CellFeatureAttributeMatrixName READ getCellFeatureAttributeMatrixName WRITE setCellFeatureAttributeMatrixName)
PYB11_PROPERTY(DataArrayPath FeatureIdsArrayPath READ getFeatureIdsArrayPath WRITE setFeatureIdsArrayPath)
PYB11_PROPERTY(DataArrayPath CellEulerAnglesArrayPath READ getCellEulerAnglesArrayPath WRITE setCellEulerAnglesArrayPath)
PYB11_PROPERTY(DataArrayPath CellPhasesArrayPath READ getCellPhasesArrayPath WRITE setCellPhasesArrayPath)
PYB11_PROPERTY(DataArrayPath AvgQuatsArrayPath READ getAvgQuatsArrayPath WRITE setAvgQuatsArrayPath)
PYB11_PROPERTY(DataArrayPath CentroidsArrayPath READ getCentroidsArrayPath WRITE setCentroidsArrayPath)
PYB11_PROPERTY(DataArrayPath EquivalentDiametersArrayPath READ getEquivalentDiametersArrayPath WRITE setEquivalentDiametersArrayPath)
PYB11_PROPERTY(DataArrayPath FeatureEulerAnglesArrayPath READ getFeatureEulerAnglesArrayPath WRITE setFeatureEulerAnglesArrayPath)
PYB11_PROPERTY(DataArrayPath FeaturePhasesArrayPath READ getFeaturePhasesArrayPath WRITE setFeaturePhasesArrayPath)
PYB11_PROPERTY(QString FeatureParentIdsArrayName READ getFeatureParentIdsArrayName WRITE setFeatureParentIdsArrayName)
PYB11_PROPERTY(DataArrayPath NumFeaturesPerParentArrayPath READ getNumFeaturesPerParentArrayPath WRITE setNumFeaturesPerParentArrayPath)
PYB11_PROPERTY(DataArrayPath CrystalStructuresArrayPath READ getCrystalStructuresArrayPath WRITE setCrystalStructuresArrayPath)
PYB11_PROPERTY(DataArrayPath PhaseTypesArrayPath READ getPhaseTypesArrayPath WRITE setPhaseTypesArrayPath)
PYB11_PROPERTY(DataArrayPath ShapeTypesArrayPath READ getShapeTypesArrayPath WRITE setShapeTypesArrayPath)
PYB11_PROPERTY(DataArrayPath NumFeaturesArrayPath READ getNumFeaturesArrayPath WRITE setNumFeaturesArrayPath)
PYB11_END_BINDINGS()
// End Python bindings declarations
public:
using Self = InsertTransformationPhases;
using Pointer = std::shared_ptr<Self>;
using ConstPointer = std::shared_ptr<const Self>;
using WeakPointer = std::weak_ptr<Self>;
using ConstWeakPointer = std::weak_ptr<const Self>;
static Pointer NullPointer();
static std::shared_ptr<InsertTransformationPhases> New();
/**
* @brief Returns the name of the class for InsertTransformationPhases
*/
QString getNameOfClass() const override;
/**
* @brief Returns the name of the class for InsertTransformationPhases
*/
static QString ClassName();
~InsertTransformationPhases() override;
/**
* @brief Setter property for ParentPhase
*/
void setParentPhase(int value);
/**
* @brief Getter property for ParentPhase
* @return Value of ParentPhase
*/
int getParentPhase() const;
Q_PROPERTY(int ParentPhase READ getParentPhase WRITE setParentPhase)
/**
* @brief Setter property for TransCrystalStruct
*/
void setTransCrystalStruct(int value);
/**
* @brief Getter property for TransCrystalStruct
* @return Value of TransCrystalStruct
*/
int getTransCrystalStruct() const;
Q_PROPERTY(int TransCrystalStruct READ getTransCrystalStruct WRITE setTransCrystalStruct)
/**
* @brief Setter property for TransformationPhaseMisorientation
*/
void setTransformationPhaseMisorientation(float value);
/**
* @brief Getter property for TransformationPhaseMisorientation
* @return Value of TransformationPhaseMisorientation
*/
float getTransformationPhaseMisorientation() const;
Q_PROPERTY(float TransformationPhaseMisorientation READ getTransformationPhaseMisorientation WRITE setTransformationPhaseMisorientation)
/**
* @brief Setter property for TransformationPhaseHabitPlane
*/
void setTransformationPhaseHabitPlane(const FloatVec3Type& value);
/**
* @brief Getter property for TransformationPhaseHabitPlane
* @return Value of TransformationPhaseHabitPlane
*/
FloatVec3Type getTransformationPhaseHabitPlane() const;
Q_PROPERTY(FloatVec3Type TransformationPhaseHabitPlane READ getTransformationPhaseHabitPlane WRITE setTransformationPhaseHabitPlane)
/**
* @brief Setter property for DefineHabitPlane
*/
void setDefineHabitPlane(bool value);
/**
* @brief Getter property for DefineHabitPlane
* @return Value of DefineHabitPlane
*/
bool getDefineHabitPlane() const;
Q_PROPERTY(bool DefineHabitPlane READ getDefineHabitPlane WRITE setDefineHabitPlane)
/**
* @brief Setter property for UseAllVariants
*/
void setUseAllVariants(bool value);
/**
* @brief Getter property for UseAllVariants
* @return Value of UseAllVariants
*/
bool getUseAllVariants() const;
Q_PROPERTY(bool UseAllVariants READ getUseAllVariants WRITE setUseAllVariants)
/**
* @brief Setter property for CoherentFrac
*/
void setCoherentFrac(float value);
/**
* @brief Getter property for CoherentFrac
* @return Value of CoherentFrac
*/
float getCoherentFrac() const;
Q_PROPERTY(float CoherentFrac READ getCoherentFrac WRITE setCoherentFrac)
/**
* @brief Setter property for TransformationPhaseThickness
*/
void setTransformationPhaseThickness(float value);
/**
* @brief Getter property for TransformationPhaseThickness
* @return Value of TransformationPhaseThickness
*/
float getTransformationPhaseThickness() const;
Q_PROPERTY(float TransformationPhaseThickness READ getTransformationPhaseThickness WRITE setTransformationPhaseThickness)
/**
* @brief Setter property for NumTransformationPhasesPerFeature
*/
void setNumTransformationPhasesPerFeature(int value);
/**
* @brief Getter property for NumTransformationPhasesPerFeature
* @return Value of NumTransformationPhasesPerFeature
*/
int getNumTransformationPhasesPerFeature() const;
Q_PROPERTY(int NumTransformationPhasesPerFeature READ getNumTransformationPhasesPerFeature WRITE setNumTransformationPhasesPerFeature)
/**
* @brief Setter property for PeninsulaFrac
*/
void setPeninsulaFrac(float value);
/**
* @brief Getter property for PeninsulaFrac
* @return Value of PeninsulaFrac
*/
float getPeninsulaFrac() const;
Q_PROPERTY(float PeninsulaFrac READ getPeninsulaFrac WRITE setPeninsulaFrac)
/**
* @brief Setter property for StatsGenCellEnsembleAttributeMatrixPath
*/
void setStatsGenCellEnsembleAttributeMatrixPath(const DataArrayPath& value);
/**
* @brief Getter property for StatsGenCellEnsembleAttributeMatrixPath
* @return Value of StatsGenCellEnsembleAttributeMatrixPath
*/
DataArrayPath getStatsGenCellEnsembleAttributeMatrixPath() const;
Q_PROPERTY(DataArrayPath StatsGenCellEnsembleAttributeMatrixPath READ getStatsGenCellEnsembleAttributeMatrixPath WRITE setStatsGenCellEnsembleAttributeMatrixPath)
/**
* @brief Setter property for CellFeatureAttributeMatrixName
*/
void setCellFeatureAttributeMatrixName(const DataArrayPath& value);
/**
* @brief Getter property for CellFeatureAttributeMatrixName
* @return Value of CellFeatureAttributeMatrixName
*/
DataArrayPath getCellFeatureAttributeMatrixName() const;
Q_PROPERTY(DataArrayPath CellFeatureAttributeMatrixName READ getCellFeatureAttributeMatrixName WRITE setCellFeatureAttributeMatrixName)
/**
* @brief Setter property for FeatureIdsArrayPath
*/
void setFeatureIdsArrayPath(const DataArrayPath& value);
/**
* @brief Getter property for FeatureIdsArrayPath
* @return Value of FeatureIdsArrayPath
*/
DataArrayPath getFeatureIdsArrayPath() const;
Q_PROPERTY(DataArrayPath FeatureIdsArrayPath READ getFeatureIdsArrayPath WRITE setFeatureIdsArrayPath)
/**
* @brief Setter property for CellEulerAnglesArrayPath
*/
void setCellEulerAnglesArrayPath(const DataArrayPath& value);
/**
* @brief Getter property for CellEulerAnglesArrayPath
* @return Value of CellEulerAnglesArrayPath
*/
DataArrayPath getCellEulerAnglesArrayPath() const;
Q_PROPERTY(DataArrayPath CellEulerAnglesArrayPath READ getCellEulerAnglesArrayPath WRITE setCellEulerAnglesArrayPath)
/**
* @brief Setter property for CellPhasesArrayPath
*/
void setCellPhasesArrayPath(const DataArrayPath& value);
/**
* @brief Getter property for CellPhasesArrayPath
* @return Value of CellPhasesArrayPath
*/
DataArrayPath getCellPhasesArrayPath() const;
Q_PROPERTY(DataArrayPath CellPhasesArrayPath READ getCellPhasesArrayPath WRITE setCellPhasesArrayPath)
/**
* @brief Setter property for AvgQuatsArrayPath
*/
void setAvgQuatsArrayPath(const DataArrayPath& value);
/**
* @brief Getter property for AvgQuatsArrayPath
* @return Value of AvgQuatsArrayPath
*/
DataArrayPath getAvgQuatsArrayPath() const;
Q_PROPERTY(DataArrayPath AvgQuatsArrayPath READ getAvgQuatsArrayPath WRITE setAvgQuatsArrayPath)
/**
* @brief Setter property for CentroidsArrayPath
*/
void setCentroidsArrayPath(const DataArrayPath& value);
/**
* @brief Getter property for CentroidsArrayPath
* @return Value of CentroidsArrayPath
*/
DataArrayPath getCentroidsArrayPath() const;
Q_PROPERTY(DataArrayPath CentroidsArrayPath READ getCentroidsArrayPath WRITE setCentroidsArrayPath)
/**
* @brief Setter property for EquivalentDiametersArrayPath
*/
void setEquivalentDiametersArrayPath(const DataArrayPath& value);
/**
* @brief Getter property for EquivalentDiametersArrayPath
* @return Value of EquivalentDiametersArrayPath
*/
DataArrayPath getEquivalentDiametersArrayPath() const;
Q_PROPERTY(DataArrayPath EquivalentDiametersArrayPath READ getEquivalentDiametersArrayPath WRITE setEquivalentDiametersArrayPath)
/**
* @brief Setter property for FeatureEulerAnglesArrayPath
*/
void setFeatureEulerAnglesArrayPath(const DataArrayPath& value);
/**
* @brief Getter property for FeatureEulerAnglesArrayPath
* @return Value of FeatureEulerAnglesArrayPath
*/
DataArrayPath getFeatureEulerAnglesArrayPath() const;
Q_PROPERTY(DataArrayPath FeatureEulerAnglesArrayPath READ getFeatureEulerAnglesArrayPath WRITE setFeatureEulerAnglesArrayPath)
/**
* @brief Setter property for FeaturePhasesArrayPath
*/
void setFeaturePhasesArrayPath(const DataArrayPath& value);
/**
* @brief Getter property for FeaturePhasesArrayPath
* @return Value of FeaturePhasesArrayPath
*/
DataArrayPath getFeaturePhasesArrayPath() const;
Q_PROPERTY(DataArrayPath FeaturePhasesArrayPath READ getFeaturePhasesArrayPath WRITE setFeaturePhasesArrayPath)
/**
* @brief Setter property for FeatureParentIdsArrayName
*/
void setFeatureParentIdsArrayName(const QString& value);
/**
* @brief Getter property for FeatureParentIdsArrayName
* @return Value of FeatureParentIdsArrayName
*/
QString getFeatureParentIdsArrayName() const;
Q_PROPERTY(QString FeatureParentIdsArrayName READ getFeatureParentIdsArrayName WRITE setFeatureParentIdsArrayName)
/**
* @brief Setter property for NumFeaturesPerParentArrayPath
*/
void setNumFeaturesPerParentArrayPath(const DataArrayPath& value);
/**
* @brief Getter property for NumFeaturesPerParentArrayPath
* @return Value of NumFeaturesPerParentArrayPath
*/
DataArrayPath getNumFeaturesPerParentArrayPath() const;
Q_PROPERTY(DataArrayPath NumFeaturesPerParentArrayPath READ getNumFeaturesPerParentArrayPath WRITE setNumFeaturesPerParentArrayPath)
/**
* @brief Setter property for CrystalStructuresArrayPath
*/
void setCrystalStructuresArrayPath(const DataArrayPath& value);
/**
* @brief Getter property for CrystalStructuresArrayPath
* @return Value of CrystalStructuresArrayPath
*/
DataArrayPath getCrystalStructuresArrayPath() const;
Q_PROPERTY(DataArrayPath CrystalStructuresArrayPath READ getCrystalStructuresArrayPath WRITE setCrystalStructuresArrayPath)
/**
* @brief Setter property for PhaseTypesArrayPath
*/
void setPhaseTypesArrayPath(const DataArrayPath& value);
/**
* @brief Getter property for PhaseTypesArrayPath
* @return Value of PhaseTypesArrayPath
*/
DataArrayPath getPhaseTypesArrayPath() const;
Q_PROPERTY(DataArrayPath PhaseTypesArrayPath READ getPhaseTypesArrayPath WRITE setPhaseTypesArrayPath)
/**
* @brief Setter property for ShapeTypesArrayPath
*/
void setShapeTypesArrayPath(const DataArrayPath& value);
/**
* @brief Getter property for ShapeTypesArrayPath
* @return Value of ShapeTypesArrayPath
*/
DataArrayPath getShapeTypesArrayPath() const;
Q_PROPERTY(DataArrayPath ShapeTypesArrayPath READ getShapeTypesArrayPath WRITE setShapeTypesArrayPath)
/**
* @brief Setter property for NumFeaturesArrayPath
*/
void setNumFeaturesArrayPath(const DataArrayPath& value);
/**
* @brief Getter property for NumFeaturesArrayPath
* @return Value of NumFeaturesArrayPath
*/
DataArrayPath getNumFeaturesArrayPath() const;
Q_PROPERTY(DataArrayPath NumFeaturesArrayPath READ getNumFeaturesArrayPath WRITE setNumFeaturesArrayPath)
/**
* @brief getCompiledLibraryName Reimplemented from @see AbstractFilter class
*/
QString getCompiledLibraryName() const override;
/**
* @brief getBrandingString Returns the branding string for the filter, which is a tag
* used to denote the filter's association with specific plugins
* @return Branding string
*/
QString getBrandingString() const override;
/**
* @brief getFilterVersion Returns a version string for this filter. Default
* value is an empty string.
* @return
*/
QString getFilterVersion() const override;
/**
* @brief newFilterInstance Reimplemented from @see AbstractFilter class
*/
AbstractFilter::Pointer newFilterInstance(bool copyFilterParameters) const override;
/**
* @brief getGroupName Reimplemented from @see AbstractFilter class
*/
QString getGroupName() const override;
/**
* @brief getSubGroupName Reimplemented from @see AbstractFilter class
*/
QString getSubGroupName() const override;
/**
* @brief getUuid Return the unique identifier for this filter.
* @return A QUuid object.
*/
QUuid getUuid() const override;
/**
* @brief getHumanLabel Reimplemented from @see AbstractFilter class
*/
QString getHumanLabel() const override;
/**
* @brief setupFilterParameters Reimplemented from @see AbstractFilter class
*/
void setupFilterParameters() override;
/**
* @brief readFilterParameters Reimplemented from @see AbstractFilter class
*/
void readFilterParameters(AbstractFilterParametersReader* reader, int index) override;
/**
* @brief execute Reimplemented from @see AbstractFilter class
*/
void execute() override;
protected:
InsertTransformationPhases();
/**
* @brief dataCheck Checks for the appropriate parameter values and availability of arrays
*/
void dataCheck() override;
/**
* @brief Initializes all the private instance variables.
*/
void initialize();
/**
* @brief insertTransformationPhases
*/
void insertTransformationPhases();
/**
* @brief placeTransformationPhase
* @param curFeature
* @param sample111
* @param totalFeatures
* @param plateThickness
* @param d
* @param numFeatures
* @param euler
* @return
*/
bool placeTransformationPhase(int32_t curFeature, float sample111[], int32_t totalFeatures, float plateThickness, float d, float* euler);
/**
* @brief peninsulaTransformationPhase
* @param curFeature
* @param totalFeatures
*/
void peninsulaTransformationPhase(int32_t curFeature, int32_t totalFeatures);
/**
* @brief transferAttributes
* @param totalFeatures
* @param q
* @param e
* @param curFeature
* @return
*/
size_t transferAttributes(size_t totalFeatures, QuatF q, float e[], int32_t curFeature);
private:
std::weak_ptr<DataArray<bool>> m_ActivePtr;
std::weak_ptr<DataArray<int32_t>> m_FeatureIdsPtr;
int32_t* m_FeatureIds = nullptr;
std::weak_ptr<DataArray<float>> m_CellEulerAnglesPtr;
float* m_CellEulerAngles = nullptr;
std::weak_ptr<DataArray<int32_t>> m_CellPhasesPtr;
int32_t* m_CellPhases = nullptr;
std::weak_ptr<DataArray<float>> m_AvgQuatsPtr;
float* m_AvgQuats = nullptr;
std::weak_ptr<DataArray<float>> m_CentroidsPtr;
float* m_Centroids = nullptr;
std::weak_ptr<DataArray<float>> m_EquivalentDiametersPtr;
float* m_EquivalentDiameters = nullptr;
std::weak_ptr<DataArray<float>> m_FeatureEulerAnglesPtr;
float* m_FeatureEulerAngles = nullptr;
std::weak_ptr<DataArray<int32_t>> m_FeaturePhasesPtr;
int32_t* m_FeaturePhases = nullptr;
std::weak_ptr<DataArray<int32_t>> m_FeatureParentIdsPtr;
int32_t* m_FeatureParentIds = nullptr;
std::weak_ptr<DataArray<int32_t>> m_NumFeaturesPerParentPtr;
int32_t* m_NumFeaturesPerParent = nullptr;
std::weak_ptr<DataArray<uint32_t>> m_CrystalStructuresPtr;
uint32_t* m_CrystalStructures = nullptr;
std::weak_ptr<DataArray<PhaseType::EnumType>> m_PhaseTypesPtr;
PhaseType::EnumType* m_PhaseTypes = nullptr;
std::weak_ptr<DataArray<ShapeType::EnumType>> m_ShapeTypesPtr;
ShapeType::EnumType* m_ShapeTypes = nullptr;
std::weak_ptr<DataArray<int32_t>> m_NumFeaturesPtr;
int32_t* m_NumFeatures = nullptr;
int m_ParentPhase = {1};
int m_TransCrystalStruct = {EbsdLib::CrystalStructure::UnknownCrystalStructure};
float m_TransformationPhaseMisorientation = {60.0f};
FloatVec3Type m_TransformationPhaseHabitPlane = {};
bool m_DefineHabitPlane = {true};
bool m_UseAllVariants = {true};
float m_CoherentFrac = {1.0f};
float m_TransformationPhaseThickness = {0.2f};
int m_NumTransformationPhasesPerFeature = {1};
float m_PeninsulaFrac = {0.0f};
DataArrayPath m_StatsGenCellEnsembleAttributeMatrixPath = {SIMPL::Defaults::StatsGenerator, SIMPL::Defaults::CellEnsembleAttributeMatrixName, ""};
DataArrayPath m_CellFeatureAttributeMatrixName = {SIMPL::Defaults::SyntheticVolumeDataContainerName, SIMPL::Defaults::CellFeatureAttributeMatrixName, ""};
DataArrayPath m_FeatureIdsArrayPath = {SIMPL::Defaults::SyntheticVolumeDataContainerName, SIMPL::Defaults::CellAttributeMatrixName, SIMPL::CellData::FeatureIds};
DataArrayPath m_CellEulerAnglesArrayPath = {SIMPL::Defaults::SyntheticVolumeDataContainerName, SIMPL::Defaults::CellAttributeMatrixName, SIMPL::CellData::EulerAngles};
DataArrayPath m_CellPhasesArrayPath = {SIMPL::Defaults::SyntheticVolumeDataContainerName, SIMPL::Defaults::CellAttributeMatrixName, SIMPL::CellData::Phases};
DataArrayPath m_AvgQuatsArrayPath = {SIMPL::Defaults::SyntheticVolumeDataContainerName, SIMPL::Defaults::CellFeatureAttributeMatrixName, SIMPL::FeatureData::AvgQuats};
DataArrayPath m_CentroidsArrayPath = {SIMPL::Defaults::SyntheticVolumeDataContainerName, SIMPL::Defaults::CellFeatureAttributeMatrixName, SIMPL::FeatureData::Centroids};
DataArrayPath m_EquivalentDiametersArrayPath = {SIMPL::Defaults::SyntheticVolumeDataContainerName, SIMPL::Defaults::CellFeatureAttributeMatrixName, SIMPL::FeatureData::EquivalentDiameters};
DataArrayPath m_FeatureEulerAnglesArrayPath = {SIMPL::Defaults::SyntheticVolumeDataContainerName, SIMPL::Defaults::CellFeatureAttributeMatrixName, SIMPL::FeatureData::EulerAngles};
DataArrayPath m_FeaturePhasesArrayPath = {SIMPL::Defaults::SyntheticVolumeDataContainerName, SIMPL::Defaults::CellFeatureAttributeMatrixName, SIMPL::FeatureData::Phases};
QString m_FeatureParentIdsArrayName = {SIMPL::FeatureData::ParentIds};
DataArrayPath m_NumFeaturesPerParentArrayPath = {SIMPL::Defaults::SyntheticVolumeDataContainerName, SIMPL::Defaults::CellEnsembleAttributeMatrixName, SIMPL::FeatureData::NumFeaturesPerParent};
DataArrayPath m_CrystalStructuresArrayPath = {SIMPL::Defaults::StatsGenerator, SIMPL::Defaults::CellEnsembleAttributeMatrixName, SIMPL::EnsembleData::CrystalStructures};
DataArrayPath m_PhaseTypesArrayPath = {SIMPL::Defaults::StatsGenerator, SIMPL::Defaults::CellEnsembleAttributeMatrixName, SIMPL::EnsembleData::PhaseTypes};
DataArrayPath m_ShapeTypesArrayPath = {SIMPL::Defaults::StatsGenerator, SIMPL::Defaults::CellEnsembleAttributeMatrixName, SIMPL::EnsembleData::ShapeTypes};
DataArrayPath m_NumFeaturesArrayPath = {SIMPL::Defaults::SyntheticVolumeDataContainerName, SIMPL::Defaults::CellEnsembleAttributeMatrixName, SIMPL::EnsembleData::NumFeatures};
LaueOpsContainer m_OrientationOps;
// Cell Data - make sure these are all initialized to nullptr in the constructor
// Feature Data - make sure these are all initialized to nullptr in the constructor
// Ensemble Data - make sure these are all initialized to nullptr in the constructor
FloatVec3Type m_NormalizedTransformationPhaseHabitPlane;
/**
* @brief updateFeatureInstancePointers
*/
void updateFeatureInstancePointers();
/**
* @brief updateStatsGenEnsembleInstancePointers
*/
void updateStatsGenEnsembleInstancePointers();
/**
* @brief updateVolEnsembleInstancePointers
*/
void updateVolEnsembleInstancePointers();
public:
InsertTransformationPhases(const InsertTransformationPhases&) = delete; // Copy Constructor Not Implemented
InsertTransformationPhases(InsertTransformationPhases&&) = delete; // Move Constructor Not Implemented
InsertTransformationPhases& operator=(const InsertTransformationPhases&) = delete; // Copy Assignment Not Implemented
InsertTransformationPhases& operator=(InsertTransformationPhases&&) = delete; // Move Assignment Not Implemented
};
| 42.405186 | 194 | 0.792195 |
de07e6a0e3e535b029ba6f7d131677459c3e9d7a | 304 | h | C | MMSegObjC/MMSegObjC/MMSToken.h | younthu/mmsegObjc | f23606b93ff0750af7ae7288845fd3eb921c31a5 | [
"MIT"
] | 2 | 2016-03-28T05:38:46.000Z | 2016-12-05T09:59:04.000Z | MMSegObjC/MMSegObjC/MMSToken.h | younthu/mmsegObjc | f23606b93ff0750af7ae7288845fd3eb921c31a5 | [
"MIT"
] | null | null | null | MMSegObjC/MMSegObjC/MMSToken.h | younthu/mmsegObjc | f23606b93ff0750af7ae7288845fd3eb921c31a5 | [
"MIT"
] | null | null | null | //
// MMSToken.h
// MMSegObjC
//
// Created by Andrew(Zhiyong) Yang on 1/15/16.
// Copyright © 2016 FoolDragon. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface MMSToken : NSObject
@property (nonatomic, copy) NSString *text;
@property (nonatomic, assign) NSRange range;
@end
| 20.266667 | 53 | 0.703947 |
940891ea2e6a28da00ad30ea6d9c38a922aa622d | 958 | h | C | packages/mccomposite/lib/geometry/primitives/Sphere.h | mcvine/mcvine | 42232534b0c6af729628009bed165cd7d833789d | [
"BSD-3-Clause"
] | 5 | 2017-01-16T03:59:47.000Z | 2020-06-23T02:54:19.000Z | packages/mccomposite/lib/geometry/primitives/Sphere.h | mcvine/mcvine | 42232534b0c6af729628009bed165cd7d833789d | [
"BSD-3-Clause"
] | 293 | 2015-10-29T17:45:52.000Z | 2022-01-07T16:31:09.000Z | packages/mccomposite/lib/geometry/primitives/Sphere.h | mcvine/mcvine | 42232534b0c6af729628009bed165cd7d833789d | [
"BSD-3-Clause"
] | 1 | 2019-05-25T00:53:31.000Z | 2019-05-25T00:53:31.000Z | // -*- C++ -*-
//
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Jiao Lin
// California Institute of Technology
// (C) 2005 All Rights Reserved
//
// {LicenseText}
//
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
#ifndef MCCOMPOSITE_GEOMETRY_PRIMITIVES_SPHERE_H
#define MCCOMPOSITE_GEOMETRY_PRIMITIVES_SPHERE_H
#include "AbstractShape.h"
namespace mccomposite{
namespace geometry {
//! sphere: a Shape
/// a sphere.
struct Sphere : public AbstractShape {
//meta methods
Sphere( double radius );
~Sphere() ;
//methods
virtual void identify( AbstractShapeVisitor & visitor ) const;
//data
double radius;
};
}
}
#endif //MCCOMPOSITE_GEOMETRY_PRIMITIVES_SPHERE_H
// version
// $Id$
// End of file
| 18.784314 | 81 | 0.463466 |
7cbf0830aebbb61eafc36e692504700dcb0c1d7d | 1,418 | h | C | assembler/asmif.h | paulscottrobson/RCA-Cosmac-VIP-III | 5d3fcea325aacb7c99269f266bc14e30439cdc2b | [
"MIT"
] | null | null | null | assembler/asmif.h | paulscottrobson/RCA-Cosmac-VIP-III | 5d3fcea325aacb7c99269f266bc14e30439cdc2b | [
"MIT"
] | null | null | null | assembler/asmif.h | paulscottrobson/RCA-Cosmac-VIP-III | 5d3fcea325aacb7c99269f266bc14e30439cdc2b | [
"MIT"
] | null | null | null | #ifndef _ASMIF_H
#define _ASMIF_H
/* asmif.h */
/*****************************************************************************/
/* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only */
/* */
/* AS-Portierung */
/* */
/* Befehle zur bedingten Assemblierung */
/* */
/* Historie: 15. 5.1996 Grundsteinlegung */
/* */
/*****************************************************************************/
typedef struct _TIfSave
{
struct _TIfSave *Next;
Integer NestLevel;
Boolean SaveIfAsm;
TempResult SaveExpr;
enum
{
IfState_IFIF, IfState_IFELSE,
IfState_CASESWITCH, IfState_CASECASE, IfState_CASEELSE
} State;
Boolean CaseFound;
LongInt StartLine;
} TIfSave,*PIfSave;
extern Boolean IfAsm;
extern PIfSave FirstIfSave;
extern Boolean CodeIFs(void);
extern void AsmIFInit(void);
extern Integer SaveIFs(void);
extern void RestoreIFs(Integer Level);
extern Boolean IFListMask(void);
extern void asmif_init(void);
#endif /* _ASMIF_H */
| 30.826087 | 79 | 0.408322 |
f5d25e1d370344a74e4bf3d4573f677a3cc5b32f | 324 | h | C | server/src/Include.h | PolyProgrammist/UTBotCpp | 4886622f21c92e3b73daa553008e541be9d82f21 | [
"Apache-2.0"
] | null | null | null | server/src/Include.h | PolyProgrammist/UTBotCpp | 4886622f21c92e3b73daa553008e541be9d82f21 | [
"Apache-2.0"
] | null | null | null | server/src/Include.h | PolyProgrammist/UTBotCpp | 4886622f21c92e3b73daa553008e541be9d82f21 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright (c) Huawei Technologies Co., Ltd. 2012-2021. All rights reserved.
*/
#ifndef UNITTESTBOT_INCLUDE_H
#define UNITTESTBOT_INCLUDE_H
#include "utils/path/FileSystemPath.h"
struct Include {
bool is_angled;
fs::path path;
Include(bool isAngled, fs::path path);
};
#endif //UNITTESTBOT_INCLUDE_H
| 17.052632 | 78 | 0.722222 |
ea0e753a23665f6cbf5aee71b45cfdad8a734f66 | 21,832 | h | C | analogEtherNet/gr_sakura_ethernet/tkdnip.h | SaneyukiM/Arudino-Xamarine-UdpListener | 68249ecc8d5fee646a414c6aa9a7ed67d424f24f | [
"MIT"
] | null | null | null | analogEtherNet/gr_sakura_ethernet/tkdnip.h | SaneyukiM/Arudino-Xamarine-UdpListener | 68249ecc8d5fee646a414c6aa9a7ed67d424f24f | [
"MIT"
] | null | null | null | analogEtherNet/gr_sakura_ethernet/tkdnip.h | SaneyukiM/Arudino-Xamarine-UdpListener | 68249ecc8d5fee646a414c6aa9a7ed67d424f24f | [
"MIT"
] | 2 | 2022-01-24T21:58:51.000Z | 2022-01-24T21:59:42.000Z | /*******************************************************************************
* GR-SAKURA LIBRARY LICENSE. LIMITATION and DISCLAIMER of WARRANTY
*
* This software is supplied by Tokushu Denshi Kairo Inc. and is only intended
* for use with Gadget Renesas projects. No other uses are authorized.
* This software is owned by Tokuden and is protected under all applicable laws,
* including copyright laws. Disclosure or redistribution to others this headder
* file and related library file alone is not allowed.
* You can redistribute the executable object file (only SREC or BIN file) which
* is generated as a result of compilation and link your program.
* Of cource the limitation of this library license does not effect to your code.
* THIS SOFTWARE IS PROVIDED "AS IS" AND TOKUDEN MAKES NO WARRANTIES REGARDING
* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
* Tokuden reserves the right, without notice, to make changes to this software
* and to discontinue the availability of this software. By using this software,
* you agree to the additional terms and conditions found by accessing the
* http://rx.tokudenkairo.co.jp/
* (C) Copyright 2011-2012 Tokushu Denshi Kairo Inc.
*******************************************************************************/
#ifndef H_TKDNIP
#define H_TKDNIP
/**************************************************************************//**
* @file tkdnip.h
* @brief RX62N/RX63N用のTCP/IPプロトコルスタック。
* @details このライブラリはTCP/IPレベルでの送受信を行う。Arduino互換ではなく独自実装。<BR>
* この関数群をArduino風にC++でラッパしたものが Ethernet.h で定義される TEthernet クラスと、 EthernetClient クラスと、 EthernetServer クラスである。ライブラリを使うにはリンカで -ltkdnip を指定すること。
******************************************************************************/
// 特電HAL
#include "tkdn_hal.h"
#ifndef BOOL
#define BOOL int
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*********************************************************************//**
* @brief リンクの状態
**********************************************************************/
typedef enum {
LINK_DOWN = 0, //!< @brief リンクダウン
LINK_UP = 1, //!< @brief リンクアップ
LINK_DOWN_CHANGED = 2, //!< @brief リンクが切断された
LINK_UP_CHANGED = 3 //!< @brief リンクが接続された
} LINK_STATE;
/*********************************************************************//**
* @brief DNSの応答のタイプ
**********************************************************************/
typedef enum {
DNS_NONAUTH, //!< @brief ノンオーソリティ
DNS_AUTH, //!< @brief オーソリティ
DNS_APPENDIX, //!< @brief 追加情報
DNS_UNDEF //!< @brief 不明
} DNS_REPLY_TYPE;
/*********************************************************************//**
* @brief DNSのレコードのタイプ
**********************************************************************/
typedef enum {
DNS_A = 1, //!< @brief IPv4 アドレス
DNS_NS = 2, //!< @brief ネームサーバ
DNS_CNAME = 5, //!< @brief 別名
DNS_PTR = 12, //!< @brief 逆引き
DNS_MX = 15, //!< @brief メールサーバ
DNS_AAAA = 28, //!< @brief IPv6アドレス
DNS_ANY = 255, //!< @brief 全部
} DNS_TYPE;
/*********************************************************************//**
* @brief DNSのアドレスのタイプ
**********************************************************************/
typedef enum {
DNS_UNKN = 0, //!< @brief 不明
DNS_IN = 1, //!< @brief インターネットアドレス
} DNS_CLASS;
/****************************************************************
* @brief DNSの結果レコードが格納される構造体。
* @details dns_records_t 型に含まれるフィールドで用いられる
* ユーザアプリで詳細なDNS情報を使う場合に使用する。
****************************************************************/
typedef struct dns_record_t
{
DNS_REPLY_TYPE rtype; //!< @brief DNS応答タイプ
DNS_TYPE type; //!< @brief DNSのタイプ
DNS_CLASS aclass; //!< @brief アドレスクラス
int ttl; //!< @brief 有効時間(秒)
char *name; //!< @brief 名前
unsigned char *data; //!< @brief データ
} dns_record_t;
/****************************************************************
* @brief DNSの結果が格納される構造体 dns_record_t の配列を格納するための構造体
* @details tketh_nslookup_ex() の戻り値で使われる
* @note この構造体が不要になったときには、 tketh_free_dns_records() で開放すること。
****************************************************************/
typedef struct dns_records_t
{
int num_of_records; //!< @brief DNSレコードの数
dns_record_t **record; //!< @brief DNSレコード
} dns_records_t;
/****************************************************************
* @def UDP_HANDLE_FUNC
* @brief UDPを受信したときに呼び出されるユーザ関数
* @details この関数がTRUEを返すとユーザで処理したものと解釈され、システムでは処理されない。<BR>
* この関数がFALSEを返すとシステムでは処理される。<BR>
* @note この関数が呼び出されるとき、ポート番号とデータ長はリトルエンディアンになっている<BR>
****************************************************************/
typedef BOOL (*UDP_HANDLE_FUNC)(
unsigned char dest_ip[4],
unsigned char src_ip[4],
unsigned short dest_port,
unsigned short src_port,
unsigned char *data, // UDPパケットのデータ部
short datalen // UDPパケットのデータの長さ(ヘッダは含まない)
);
//! @brief TCPの接続情報を示す構造体 内部構造は知る必要はないため隠蔽されている
typedef struct tcp_str tcp_t;
typedef struct tcp_server_str tcp_server_t;
//! @brief TCPの接続状態を表す定数
typedef enum {
TCP_CLOSED, //!< @brief CLOSED 接続は閉じている
TCP_LISTEN, //!< @brief LISTEN サーバが接続を待っている
TCP_SYNRCVD, //!< @brief SYN_RCVD SYNを受信した
TCP_ESTAB, //!< @brief ESTABLISHED 通信が確立している
TCP_FIN_WAIT1, //!< @brief FIN_WAIT1 相手からのFINを待っている
TCP_FIN_WAIT2, //!< @brief FIN_WAIT2 相手からのFINを待っている
TCP_CLOSING, //!< @brief CLOSING FINを送ったらFINを送り返された
TCP_TIME_WAIT, //!< @brief TIME_WAIT クライアントからCLOSEされた後の待ち
TCP_SYN_SENT, //!< @brief SYN_SENT SYNを送った。サーバからのACK待ち
TCP_CLOSEWAIT, //!< @brief CLOSE_WAIT
TCP_LAST_ACK //!< @brief LAST_ACK
} TCP_STATE;
// クライアントの接続状態を示す構造体。 clients_stat_t のメンバとして使われる
typedef struct client_stat_t
{
unsigned char ipaddr[4]; // @brief クライアントIPアドレス
unsigned short local_port; // @brief ローカルポート番号
unsigned short foreign_port; // @brief 相手先ポート番号
BOOL server; // @brief 自分がサーバかどうか
TCP_STATE state; // @brief TCPの状態
} client_stat_t;
// クライアントの接続状態を示す構造体のリスト。 tketh_get_client_stats() の結果として返される。
typedef struct clients_stat_t
{
int num_of_clients; // 接続しているクライアントの数
client_stat_t *clients; // 接続クライアント情報
} clients_stat_t;
//! @brief TCPのイベントが起きた時にコールバックされる関数の型
typedef void (*FUNCTYPE_TCPEVENT)(tcp_t *client);
////////////////////////////////////////////////////////////////////////
// ユーザ公開関数
////////////////////////////////////////////////////////////////////////
//------------------------------------------------------------------------
// 基本的な操作
//------------------------------------------------------------------------
/*********************************************************************//**
* @brief 自分のMACアドレスを設定し、ライブラリを開始する
* @param[in] macaddr MACアドレス
* @return なし
**********************************************************************/
void tketh_open(unsigned char *macaddr);
/*********************************************************************//**
* @brief イーサネットのリンクアップをチェックする。
* @note リンクが切断→接続に変わったら自動的にオートネゴーシエーションが実行される。
* @return LINK_STATE 型の値。下記のとおり
* - LINK_DOWN (0) : リンクはダウンしている
* - LINK_UP (1) : リンクはアップしている
* - LINK_DOWN_CHANGED (2) : リンクは変化し、切断された
* - LINK_UP_CHANGED (3) : リンクは変化し、接続された
**********************************************************************/
LINK_STATE tketh_check_link();
/*********************************************************************//**
* @brief イーサネットの受信処理を進める
* @details この関数が呼び出されると、受信パケットの有無を調べ、
* パケットの内容に応じて受信処理を進める。<BR>
* 受信エラーの解除も行われる。
* @warning この関数はメインのループの中で繰り返し呼び出さなければならない。
* @return なし
**********************************************************************/
void tketh_process();
/*********************************************************************//**
* @brief デバッグレベルを設定する
* @param level
* - 0:なし
* - 1:パケットの概要を表示する
* - 2:パケットをダンプする
* @return なし
**********************************************************************/
void tketh_debug(int level);
/*********************************************************************//**
* @brief 自分の名前を設定する
* @details ここで設定したホスト名はDHCPで使われるので重要
* @param hostname ホスト名
* @return なし
**********************************************************************/
void tketh_set_hostname(const char *hostname);
/*********************************************************************//**
* @brief 自分の名前を調べる
* @details tketh_set_hostname() で設定した名前を返す
* @return 自分のホスト名が格納された文字列バッファへのポインタ
* @note 返された文字列はライブラリ内部でmallocして複製したもの
* @warning 返された文字列をfreeしてはならない
**********************************************************************/
char *tketh_get_hostname(void);
/*********************************************************************//**
* @brief MACアドレスを変更する
* @param macaddr 新しいMACアドレス
* @return なし
**********************************************************************/
void tketh_change_macaddr(const unsigned char macaddr[6]);
/*********************************************************************//**
* @brief 自分のMACアドレスを調べる
* @param[out] macaddr MACアドレスを格納するバッファへのポインタ
* @return なし
* @note バッファを確保するのはユーザルーチンで行うこと
* @warning 戻り値用に6バイト以上の配列を確保しておくこと
**********************************************************************/
void tketh_get_macaddr(unsigned char macaddr[6]);
//------------------------------------------------------------------------
// IPアドレス等の設定や取得
//------------------------------------------------------------------------
/*********************************************************************//**
* @brief DHCPを実行して、IPアドレス、GW、DNSサーバを設定する
* @return 成功するとTRUEを返す。失敗するとFALSEを返す。
**********************************************************************/
BOOL tketh_dhcpc(void);
/*********************************************************************//**
* @brief 自分のIPアドレスを設定する
* @details IPアドレスとサブネットマスクを指定する。
* @param[in] ipaddr IPアドレスが格納された4バイトの配列
* @param[in] mask サブネットマスクが格納された4バイトの配列
**********************************************************************/
void tketh_set_myipaddr(unsigned char ipaddr[4],unsigned char mask[4]);
/*********************************************************************//**
* @brief 自分のIPアドレスを取得する
* @details DHCP等で設定されたIPアドレスを調べるときに使う
* @param[out] ipaddr IPアドレスを格納する4バイトの配列
* @param[out] mask サブネットマスクを格納する4バイトの配列
* @note この関数はメモリの確保は行わない。配列の実体を確保するのはユーザルーチンで行うこと
* @return なし
**********************************************************************/
void tketh_get_myipaddr(unsigned char ipaddr[4],unsigned char mask[4]);
/*********************************************************************//**
* @brief デフォルトゲートウェイを設定する
* @param[in] ipaddr デフォルトゲートウェイのIPアドレス
* @return なし
**********************************************************************/
void tketh_set_gateway(unsigned char ipaddr[4]);
/*********************************************************************//**
* @brief 設定されているデフォルトゲートウェイのアドレスを取得する
* @details DHCP等で設定されたデフォルトゲートウェイアドレスを調べるときに使う
* @param[out] ipaddr デフォルトゲートウェイのIPアドレスを格納する4バイトの配列
* @note この関数はメモリの確保は行わない。配列の実体を確保するのはユーザルーチンで行うこと
* @return なし
**********************************************************************/
void tketh_get_gateway(unsigned char ipaddr[4]);
/*********************************************************************//**
* @brief DNSサーバのアドレスを設定する
* @param[in] ipaddr DNSサーバのIPアドレス
* @return なし
**********************************************************************/
void tketh_set_nameserver(unsigned char ipaddr[4]);
/*********************************************************************//**
* @brief 設定されているDNSサーバのアドレスを取得する
* @details DHCP等で設定されたDNSサーバのアドレスを調べるときに使う
* @param[out] ipaddr DNSサーバのIPアドレスを格納する4バイトの配列
* @note この関数はメモリの確保は行わない。配列の実体を確保するのはユーザルーチンで行うこと
* @return なし
**********************************************************************/
void tketh_get_nameserver(unsigned char ipaddr[4]);
/*********************************************************************//**
* @brief ARPのテーブルを表示する
* @return なし
* @note デフォルトのシリアルポートに表示する
**********************************************************************/
void tketh_arp_table_show();
//------------------------------------------------------------------------
// 低レベルなパケットの送受信
//------------------------------------------------------------------------
/*********************************************************************//**
* @brief UDPを送信する
* @param[in] tgtaddr 相手先のIPアドレス
* @param[in] dest_port 送信先ポート番号
* @param[in] src_port 送信元ポート番号
* @param[in] buf 送信したいデータが格納されたバッファ
* @param[in] len 送信したいデータ長
* @return 成功したらTRUE、失敗したらFALSEを返す
* @note V1.07から、送信元ポート番号を指定できるようにしたため、パラメータ書式が変更になった
**********************************************************************/
BOOL tketh_send_udp(unsigned char tgtaddr[4],unsigned short dest_port,unsigned short src_port,unsigned char *buf,int len);
/*********************************************************************//**
* @brief UDPを受信したときにコールバックされる関数を登録する
* @param[in] func UDPを受信したときにコールバックされる関数
* @note 登録される関数は processPackets() の中から呼び出される。したがって、processPackets()を繰り返し呼び出していないと受信処理は行われない。
**********************************************************************/
void tketh_regist_udp_handler(UDP_HANDLE_FUNC func);
//------------------------------------------------------------------------
// PING関係のプロトコル
//------------------------------------------------------------------------
/*********************************************************************//**
* @brief PINGを送信する
* @param[in] ipaddr Pingを送りたいホストのIPアドレス
* @param[in] buf Pingのデータ部に乗せるデータ。必要なければNULLでよい。
* @param len データ部の長さ。必要なければ0を指定してよい。
* @return 成功したらTRUE、失敗したらFALSEを返す。
**********************************************************************/
BOOL tketh_send_ping(unsigned char ipaddr[4],unsigned char *buf,int len);
/*********************************************************************//**
* @brief PINGが実行中かどうか調べる
* @details tketh_send_ping() で送信したPingが実行中かどうか調べる
* @return 実行中ならTRUE、実行中でなければFALSEを返す。
**********************************************************************/
BOOL tketh_is_ping_running();
/*********************************************************************//**
* @brief PINGの実行をキャンセルする
* @details tketh_send_ping() で開始したPingを中断する。
* @return なし
**********************************************************************/
void tketh_cancel_ping();
/*********************************************************************//**
* @brief 最後にPINGを送った時刻をus単位で返す
* @return Pingを最後に送った時間。システム起動時からの時間がms単位で返される。
**********************************************************************/
unsigned long tketh_ping_starttime();
//------------------------------------------------------------------------
// 名前解決
//------------------------------------------------------------------------
/*********************************************************************//**
* @brief DNSサーバにアクセスして名前解決を行う
* @param[in] hostname 調べたいホスト名
* @param[out] ipaddr IPアドレス
* @return 成功したらTRUE、失敗したらFALSEを返す
**********************************************************************/
BOOL tketh_nslookup(char *hostname,unsigned char ipaddr[4]);
/*********************************************************************//**
* @brief DNSサーバにアクセスして名前解決を行い、すべてのレコードを得る
* @details dns_records_t *型のオブジェクトを返し、すべてのレコードを知ることができるようになっている。
* @param[in] hostname 調べたいホスト名
* @return 結果が格納された dns_records_t *型の構造体へのポインタ
* @note ユーザルーチンはこの関数の戻り値は tketh_free_dns_records() 関数で開放しなければならない。
* @warning 1500バイト以上の結果が返されたときには最後まで受信できない
**********************************************************************/
dns_records_t *tketh_nslookup_ex(char *hostname);
/*********************************************************************//**
* @brief DNS結果構造体を開放する
* @details tketh_nslookup_ex()で得られた結果のオブジェクトを開放する。
* @param[in] dnsrec tketh_nslookup_ex() で得られたオブジェクト。
* @return なし
**********************************************************************/
void tketh_free_dns_records(dns_records_t *dnsrec);
/*********************************************************************//**
* @brief DNSサーバにアクセスしてIPアドレスから名前を調べる
* @param[in] ipaddr 調べたいIPアドレス
* @param[out] hostname 変換されたホスト名が入るバッファ
* @param[in] hostname_maxlen バッファのサイズ
* @return 成功したらTRUE、失敗したらFALSEを返す
* @note この関数は実装されていない
**********************************************************************/
BOOL tketh_ip_to_hostname(unsigned char ipaddr[4],char *hostname,int hostname_maxlen);
//------------------------------------------------------------------------
// TCPクライアント
//------------------------------------------------------------------------
/*********************************************************************//**
* @brief TCPでサーバに接続する
* @param[in] ipaddr 接続したいサーバのIPアドレス
* @param[in] dest_port 接続したいポート番号
* @return 成功したら tcp_t 型のオブジェクトを返す。失敗したらNULLを返す。
**********************************************************************/
tcp_t *tketh_tcp_connect(unsigned char ipaddr[4],unsigned short dest_port);
/*********************************************************************//**
* @brief コネクションが接続中かどうかを調べる
* @param[in] info tketh_tcp_connect() で返されたオブジェクト
* @return 接続中ならばTRUEを返す。切断されていればFALSEを返す。
**********************************************************************/
BOOL tketh_tcp_is_connected(tcp_t *info);
/*********************************************************************//**
* @brief コネクションの穏やかな終了
* @details 接続先のサーバにFINを送ることでコネクションを終了する
* @param[in] info tketh_tcp_connect() で返されたオブジェクト
* @note この関数はFINを送った後、相手からFINやACKが返るのを待たずに即座に戻る
* @todo FINタイマなどを実装するべき
**********************************************************************/
void tketh_tcp_fin(tcp_t *info);
/*********************************************************************//**
* @brief コネクションの状態を文字列で返す
* @param[in] info tketh_tcp_connect() で返されたオブジェクト
* @return コネクションの状態を表す文字列
* @note この関数の戻り値はライブラリ内でstaticに確保された領域を指している。ユーザがfreeしてはならない。
* @warning この関数は実装されていない
**********************************************************************/
char *tketh_tcp_state(tcp_t *info);
/*********************************************************************//**
* @brief TCPの接続先にデータを送信する
* @param[in] info tketh_tcp_connect() で返されたオブジェクト
* @param[in] data 送信したいデータが格納されたバッファ
* @param[in] len 送信したいデータ長
**********************************************************************/
void tketh_tcp_senddata(tcp_t *info,unsigned char *data,int len);
/*********************************************************************//**
* @brief 受信バッファに溜まっているデータの量を調べる
* @details TCPのパケットを受信すると受信バッファに格納される。その受信バッファ内のデータ数を返す。
* @param info tketh_tcp_connect() で返されたオブジェクト
* @return 受信バッファ内のデータ数 (バイト単位)
**********************************************************************/
int tketh_tcp_recvcount(tcp_t *info);
/*********************************************************************//**
* @brief 受信バッファからデータを取り出す
* @param[in] info tketh_tcp_connect() で返されたオブジェクト
* @param[out] data 読み出したデータが格納されるバッファ。バッファは十分なサイズのメモリを確保しておくこと。
* @param[in] len 読み出したい長さ。
* @return 受信したデータ数。データがなければ0を返す。
**********************************************************************/
int tketh_tcp_recvdata(tcp_t *info,unsigned char *data,int len);
//------------------------------------------------------------------------
// TCPサーバ ※現在はセッションを1つしか張れない
//------------------------------------------------------------------------
/*********************************************************************//**
* @brief TCP接続を待ちうけたいポート番号をセットする
* @details この関数はあくまでも準備をするだけ。実際にLISTENステートには入れない。
* @param[in] port 接続を待ちうけるポート番号
* @param[in] func TCPのイベントが発生したときにコールバックされる関数 (この機能は未実装)
* @return TCPの接続情報を示すオブジェクトが返される
* @note この関数はあくまでもポート番号を指示するだけで、実際にはLISTEN状態にはならない
**********************************************************************/
tcp_t *tketh_tcp_open_server(unsigned short port,FUNCTYPE_TCPEVENT func);
/*********************************************************************//**
* @brief サーバの受信開始
* @details サーバのTCPステートをLISTEN状態になる
* @param[in] info tketh_tcp_open_server() 関数で返されたオブジェクト
* @return 成功したらTRUEを返す。失敗したらFALSEを返す。
**********************************************************************/
BOOL tketh_tcp_listen(tcp_t *info);
/*********************************************************************//**
* @brief 接続先のIPアドレスを調べる
* @param[in] info tketh_tcp_open_server() 関数で返されたオブジェクト
* @return 接続先のIPアドレスが入った配列
* @note この関数の戻り値はライブラリ内でstaticに確保された領域なので、ユーザアプリでfreeをしてはいけない。
**********************************************************************/
unsigned char *tketh_tcp_target_addr(tcp_t *info);
/*********************************************************************//**
* @brief サーバの待ち受け状態を終了する
* @details サーバのLISTEN状態を解除して、IDLE状態に戻す。この引数で指定した構造体へのオブジェクト info はもう使えない。
* @param[in] info tketh_tcp_open_server() 関数で返されたオブジェクト
* @return なし
**********************************************************************/
void tketh_tcp_server_terminate(tcp_t *info);
//------------------------------------------------------------------------
// コネクション管理
//------------------------------------------------------------------------
/*********************************************************************//**
* @brief クライアントの状態を調べる
* @details 本ライブラリは、サーバ・クライアント合わせて最大16個のセッションを張ることができる。その1つ1つのセッションに関する情報を返す。
* @return clients_stat_t *型オブジェクトへのハンドル
**********************************************************************/
clients_stat_t *tketh_get_client_stats();
#ifdef __cplusplus
}
#endif
#endif
| 41.505703 | 149 | 0.457127 |
73f060b079817c47a6aec1ccee46f9ec81654694 | 196 | h | C | sources/drivers/gpu/drm/nouveau/core/include/subdev/bios/bit.h | fuldaros/paperplane_kernel_wileyfox-spark | bea244880d2de50f4ad14bb6fa5777652232c033 | [
"Apache-2.0"
] | 55 | 2019-12-20T03:25:14.000Z | 2022-01-16T07:19:47.000Z | sources/drivers/gpu/drm/nouveau/core/include/subdev/bios/bit.h | fuldaros/paperplane_kernel_wileyfox-spark | bea244880d2de50f4ad14bb6fa5777652232c033 | [
"Apache-2.0"
] | 2 | 2020-11-02T08:01:00.000Z | 2022-03-27T02:59:18.000Z | sources/drivers/gpu/drm/nouveau/core/include/subdev/bios/bit.h | fuldaros/paperplane_kernel_wileyfox-spark | bea244880d2de50f4ad14bb6fa5777652232c033 | [
"Apache-2.0"
] | 11 | 2020-08-06T03:59:45.000Z | 2022-02-25T02:31:59.000Z | #ifndef __NVBIOS_BIT_H__
#define __NVBIOS_BIT_H__
struct bit_entry {
u8 id;
u8 version;
u16 length;
u16 offset;
};
int bit_entry(struct nouveau_bios *, u8 id, struct bit_entry *);
#endif
| 14 | 64 | 0.734694 |
90fd5b63ec2d1a1786001aa2d2f10c51dc276988 | 248 | c | C | src/action/actions/move/east_action.c | danielmunro/csaw | 83b9bd668ce47b20c0acc958177f134400d7263f | [
"MIT"
] | null | null | null | src/action/actions/move/east_action.c | danielmunro/csaw | 83b9bd668ce47b20c0acc958177f134400d7263f | [
"MIT"
] | null | null | null | src/action/actions/move/east_action.c | danielmunro/csaw | 83b9bd668ce47b20c0acc958177f134400d7263f | [
"MIT"
] | null | null | null | void do_east_action(GameServiceT *game_service, RequestT *request) {
do_move_action(game_service, request, EastDirection);
}
ActionT *create_east_action() {
return create_action(EastAction, "east", create_single_word(), do_east_action);
}
| 31 | 83 | 0.778226 |
4276b0ce1b931e2dff69497fee92db7d93cee70a | 860 | c | C | sys/taika/locore/x86/smbios.c | vendu/vaaja | 24066d15df39b8c4326707c004e0cc16495987a5 | [
"BSD-3-Clause"
] | 4 | 2020-05-11T15:19:54.000Z | 2020-08-29T00:19:09.000Z | kern/unit/x86/smbios.c | JamesLinus/OS-Zero | effa0bd7c35ac21ba6132120549b4e882001b0e6 | [
"BSD-3-Clause"
] | 1 | 2021-06-01T22:14:37.000Z | 2021-06-01T22:14:37.000Z | sys/taika/locore/x86/smbios.c | vendu/vaaja | 24066d15df39b8c4326707c004e0cc16495987a5 | [
"BSD-3-Clause"
] | null | null | null | #include <kern/conf.h>
#if (SMBIOS)
#include <stddef.h>
#include <stdint.h>
#include <kern/util.h>
#include <kern/unit/x86/smbios.h>
struct smbiosdrv smbiosdrv;
static struct smbioshdr *
smbiosfind(void)
{
struct smbioshdr *hdr = NULL;
uint32_t *ptr = (uint32_t *)0xf0000;
uint32_t *lim = (uint32_t *)0xfffff;
while (ptr < lim) {
if (*ptr == SMBIOSSIG) {
hdr = (struct smbioshdr *)ptr;
return hdr;
}
ptr += 4;
}
return hdr;
}
void
smbiosinit(void)
{
struct smbioshdr *hdr;
hdr = smbiosfind();
if (!hdr) {
kprintf("SMBIOS: header not found!\n");
return;
}
kprintf("SMBIOS: header found at %p\n", hdr);
smbiosdrv.ninfo = hdr->ninfo;
smbiosdrv.infophys = (void *)(hdr->tabphysadr);
return;
}
#endif /* SMBIOS */
| 16.862745 | 51 | 0.565116 |
5d013bdbaa5fba3143f769e2bc0eebdaf9cdf5e5 | 251 | h | C | src/mods/WorldGenMod/WorldGenMod.h | thetrueoneshots/CubeMegaMod | b5efbd559cbd2b7399f42b4ffab3453a1dd544bf | [
"MIT"
] | 39 | 2021-02-28T04:17:16.000Z | 2022-02-23T14:25:41.000Z | src/mods/WorldGenMod/WorldGenMod.h | thetrueoneshots/CubeMegaMod | b5efbd559cbd2b7399f42b4ffab3453a1dd544bf | [
"MIT"
] | 16 | 2021-03-12T04:44:33.000Z | 2022-03-31T14:16:16.000Z | src/mods/WorldGenMod/WorldGenMod.h | thetrueoneshots/CubeMegaMod | b5efbd559cbd2b7399f42b4ffab3453a1dd544bf | [
"MIT"
] | 3 | 2021-09-10T14:19:08.000Z | 2021-12-19T20:45:04.000Z | #pragma once
#include "../../CubeMod.h"
#include "../../hooks.h"
class WorldGenMod : public CubeMod
{
public:
WorldGenMod() {
m_Name = "World Gen Mod";
m_FileName = "WorldGenMod";
m_ID = 6;
m_Version = { 1, 1, 0 };
}
void Initialize();
}; | 15.6875 | 34 | 0.609562 |
513a5f3b164949bda31615d556a7e08f12651959 | 2,002 | h | C | source/main.h | Husamdababneh/Commandos-strike-force-extractor | 1205bed2c325e0351b714cd767dfd5661340ab0e | [
"Apache-2.0"
] | null | null | null | source/main.h | Husamdababneh/Commandos-strike-force-extractor | 1205bed2c325e0351b714cd767dfd5661340ab0e | [
"Apache-2.0"
] | null | null | null | source/main.h | Husamdababneh/Commandos-strike-force-extractor | 1205bed2c325e0351b714cd767dfd5661340ab0e | [
"Apache-2.0"
] | null | null | null | /* ========================================================================
$File: main.h
$Date: 2020-03-20
$Revision: : @Incomplete
$Creator: Husam Dababneh
========================================================================*/
#pragma once
#include <stdint.h>
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
typedef float f32;
typedef double f64;
typedef float float32;
typedef double float64;
#include <iostream>
#include <cstddef>
enum : short
{
CSF_HEADER = 0,
CSF_COLLECTION = 1,
CSF_LIST = 2,
CSF_INT = 3,
CSF_FLOAT = 4,
CSF_STRING = 5
};
enum : long
{
GFX = 0x1c633a1,
MENUS = 0x1c633a6,
MAPS = 0x1c633ac,
MODELS = 0x1c633a7,
BDD = 0x1c633af
};
struct PakHeader
{
char Tag[4];
long IDK;
long Version;
long ResNum;
};
enum : short
{
UNKNOWN_TYPE = 0
};
struct FilesMetaData
{
u8* filename;
// resouce offset in file -> first you have to get the first offset by looping over the resources header, save the offset , addit to roff to get to the location of the resources
u32 roff;
u32 size;
union {
u32 v1;
struct { u16 v1_1; u16 v1_2; };
};
union {
u32 v2;
struct { u16 v2_1; u16 v2_2; };
};
};
struct CSFFBSHeader
{
char Tag[6];
// there is a 2 byte padding here ?
long Version; // ?? maybe
long NumberOfItems; // * 12) + 24= Offset Of Where Data Begins -v
long StringEntryCount;
long StringValueCount;
};
struct CSFFBSData
{
long Indicator;
union {
// Data
long IntegerValue;
float FloatValue;
// String
long StringIndex;
// List
long InnerItemCount;
};
short ItemStringIndex;
short Type;
};
struct CSFFBSBrackets
{
std::stack<int> col;
std::stack<int> arr;
std::stack<int> turn2;
bool turn = false; // true -> arr , false -> col
};
#pragma warning(disable: 4200)
struct SString {
u32 size;
u8 str[];
};
| 16.276423 | 178 | 0.604895 |
b63901f6525033176a01cda69540f4fab6547228 | 301 | h | C | src/led_controller/led_controller.h | ojousima/ruuvi.node_nrf91.c | a157c5fa6bd8f6f8a411a7796fe84367fc32ed4f | [
"BSD-3-Clause"
] | null | null | null | src/led_controller/led_controller.h | ojousima/ruuvi.node_nrf91.c | a157c5fa6bd8f6f8a411a7796fe84367fc32ed4f | [
"BSD-3-Clause"
] | null | null | null | src/led_controller/led_controller.h | ojousima/ruuvi.node_nrf91.c | a157c5fa6bd8f6f8a411a7796fe84367fc32ed4f | [
"BSD-3-Clause"
] | null | null | null | #include <zephyr.h>
void led_init(void);
void toggle_led_one(u8_t on);
void flash_led_one(void);
void toggle_led_two(u8_t on);
void flash_led_two(void);
void toggle_led_three(u8_t on);
void flash_led_three(void);
void toggle_led_four(u8_t on);
void flash_led_four(void);
| 14.333333 | 32 | 0.717608 |
99b96cc37cddc2f49b61e223033c6078303f10a5 | 4,545 | h | C | src/util/gui/unhoverdeletemixin.h | MellonQ/leechcraft | 71cbb238d2dade56b3865278a6a8e6a58c217fc5 | [
"BSL-1.0"
] | 1 | 2017-01-12T07:05:45.000Z | 2017-01-12T07:05:45.000Z | src/util/gui/unhoverdeletemixin.h | MellonQ/leechcraft | 71cbb238d2dade56b3865278a6a8e6a58c217fc5 | [
"BSL-1.0"
] | null | null | null | src/util/gui/unhoverdeletemixin.h | MellonQ/leechcraft | 71cbb238d2dade56b3865278a6a8e6a58c217fc5 | [
"BSL-1.0"
] | null | null | null | /**********************************************************************
* LeechCraft - modular cross-platform feature rich internet client.
* Copyright (C) 2006-2014 Georg Rudoy
*
* Boost Software License - Version 1.0 - August 17th, 2003
*
* Permission is hereby granted, free of charge, to any person or organization
* obtaining a copy of the software and accompanying documentation covered by
* this license (the "Software") to use, reproduce, display, distribute,
* execute, and transmit the Software, and to prepare derivative works of the
* Software, and to permit third-parties to whom the Software is furnished to
* do so, all subject to the following:
*
* The copyright notices in the Software and this entire statement, including
* the above license grant, this restriction and the following disclaimer,
* must be included in all copies of the Software, in whole or in part, and
* all derivative works of the Software, unless such copies or derivative
* works are solely in the form of machine-executable object code generated by
* a source language processor.
*
* 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
**********************************************************************/
#pragma once
#include <QObject>
#include "guiconfig.h"
class QTimer;
namespace LeechCraft
{
namespace Util
{
/** @brief Allows to hide a widget or popup after mouse leave.
*
* This class is used to automatically hide a top-level widget like a
* tooltip or popup after mouse has left the widget and some time has
* passed.
*
* This class supports performing arbitrary operations in addition to
* destructing the widget, just pass the corresponding slot to call
* in the constructor. Despite this functionality, we will say
* "deletion" each time we speak of the operation without noticing
* that any other operation is possible on the widget.
*
* It is also possible to directly start the destruction timer using
* the Start() function, and to stop is with its counterpart Stop().
*
* The widget on which this mixin is constructed takes ownership of
* this class, so there is no need to keep it around or delete it
* explicitly.
*
* @ingroup GuiUtil
*/
class UnhoverDeleteMixin : public QObject
{
Q_OBJECT
QTimer *LeaveTimer_;
bool ContainsMouse_;
bool IgnoreNext_;
public:
/** @brief Creates the mixin for the given parent widget.
*
* @param[in] parent The widget for which should be watched for
* mouse leave events.
* @param[in] slot The slot to call when enough time has passed
* since mouse leave. By default it is <code>deleteLater()</code>.
*/
UTIL_GUI_API UnhoverDeleteMixin (QObject *parent, const char *slot = SLOT (deleteLater ()));
/** @brief Manually starts the timer.
*
* This function can be used to start the timer after a Stop().
*
* If the widget currently contains the mouse, this function does
* nothing.
*
* @param[in] timeout The number of milliseconds to wait before
* the widget is deleted..
*
* @sa Stop()
*/
void UTIL_GUI_API Start (int timeout = 1200);
/** @brief Stops the previously started timer.
*
* This function stops the started destruction timer, both if it
* is started as the result of mouse leave or due to Start().
*
* After a Stop() the widget will never be deleted without mouse
* entering the widget and then leaving it again, or calling
* Start().
*
* This function is useful if a user is currently interacting
* with a logical child of the watched widget, and though the
* watched widget doesn't contain mouse at the moment, it still
* makes sense to keep it around.
*
* @sa Start()
*/
void UTIL_GUI_API Stop ();
/** @brief Ignores the next leave event.
*
* This function is useful if one knows that the watched widget
* is going to be resized, for example, and needs to cancel the
* deletion of the widget upon receiving the corresponding
* leave event.
*/
void UTIL_GUI_API IgnoreNext ();
protected:
bool eventFilter (QObject*, QEvent*);
};
}
}
| 36.653226 | 94 | 0.69945 |
797e2ce3ec7720a558cc335b917e82bcccacc3a5 | 679 | h | C | include/NoiseTools.h | fmidev/smartmet-qdcontour | 8cf0ea3f03f8784249ea4f69d9b2bcdf83accc4a | [
"MIT"
] | null | null | null | include/NoiseTools.h | fmidev/smartmet-qdcontour | 8cf0ea3f03f8784249ea4f69d9b2bcdf83accc4a | [
"MIT"
] | null | null | null | include/NoiseTools.h | fmidev/smartmet-qdcontour | 8cf0ea3f03f8784249ea4f69d9b2bcdf83accc4a | [
"MIT"
] | 1 | 2017-05-04T08:02:41.000Z | 2017-05-04T08:02:41.000Z | // ======================================================================
/*!
* \file
* \brief Interface of namespace NoiseTools
*/
// ======================================================================
#ifndef NOISETOOLS_H
#define NOISETOOLS_H
#include <newbase/NFmiDataMatrix.h>
namespace NoiseTools
{
// weighted median filter
void despeckle(NFmiDataMatrix<float> &theValues,
float theLoLimit,
float theHiLimit,
int theRadius,
float theWeight,
int theIterations);
} // namespace NoiseTools
#endif // NOISETOOLS_H
// ======================================================================
| 24.25 | 73 | 0.430044 |
c3d22eae69eda502629659f09d2e85f02c3d873e | 203 | h | C | extras/common/timing.h | simondlevy/CrossPlatformI2C | 548522ab86100b98cf8dd2022ef55f2925abe0b0 | [
"MIT"
] | 9 | 2019-04-02T12:19:58.000Z | 2022-01-09T19:08:13.000Z | extras/common/timing.h | simondlevy/CrossPlatformI2C | 548522ab86100b98cf8dd2022ef55f2925abe0b0 | [
"MIT"
] | 3 | 2020-02-20T23:16:26.000Z | 2020-09-12T06:55:04.000Z | extras/common/timing.h | simondlevy/CrossPlatformDataBus | 548522ab86100b98cf8dd2022ef55f2925abe0b0 | [
"MIT"
] | 4 | 2019-06-13T19:27:32.000Z | 2020-03-14T03:28:13.000Z | /*
timing.h: Arduino-style delay(), micros() for Linux
Copyright (c) 2021 Simon D. Levy
MIT LIcense
*/
void delay(unsigned int msec);
unsigned int millis(void);
unsigned int micros(void);
| 14.5 | 54 | 0.679803 |
d7a9cfd8f7546d7efeec72731c9d8770715efb20 | 3,341 | c | C | ext/hal/nordic/nrfx/drivers/src/nrfx_spim.c | dmgerman/zephyrd3 | b6a23cc9c5d534c352e33fd18fff7799ac3c2886 | [
"Apache-2.0"
] | null | null | null | ext/hal/nordic/nrfx/drivers/src/nrfx_spim.c | dmgerman/zephyrd3 | b6a23cc9c5d534c352e33fd18fff7799ac3c2886 | [
"Apache-2.0"
] | null | null | null | ext/hal/nordic/nrfx/drivers/src/nrfx_spim.c | dmgerman/zephyrd3 | b6a23cc9c5d534c352e33fd18fff7799ac3c2886 | [
"Apache-2.0"
] | null | null | null | DECL|NRFX_LOG_MODULE|macro|NRFX_LOG_MODULE
DECL|SPIM0_LENGTH_VALIDATE|macro|SPIM0_LENGTH_VALIDATE
DECL|SPIM0_LENGTH_VALIDATE|macro|SPIM0_LENGTH_VALIDATE
DECL|SPIM1_LENGTH_VALIDATE|macro|SPIM1_LENGTH_VALIDATE
DECL|SPIM1_LENGTH_VALIDATE|macro|SPIM1_LENGTH_VALIDATE
DECL|SPIM2_LENGTH_VALIDATE|macro|SPIM2_LENGTH_VALIDATE
DECL|SPIM2_LENGTH_VALIDATE|macro|SPIM2_LENGTH_VALIDATE
DECL|SPIM3_LENGTH_VALIDATE|macro|SPIM3_LENGTH_VALIDATE
DECL|SPIM3_LENGTH_VALIDATE|macro|SPIM3_LENGTH_VALIDATE
DECL|SPIMX_LENGTH_VALIDATE|macro|SPIMX_LENGTH_VALIDATE
DECL|SPIM_LENGTH_VALIDATE|macro|SPIM_LENGTH_VALIDATE
DECL|USE_WORKAROUND_FOR_ANOMALY_195|macro|USE_WORKAROUND_FOR_ANOMALY_195
DECL|anomaly_198_disable|function|static void anomaly_198_disable(void)
DECL|anomaly_198_enable|function|static void anomaly_198_enable(uint8_t const * p_buffer, size_t buf_len)
DECL|evt|member|nrfx_spim_evt_t evt; // Keep the struct that is ready for event handler. Less memcpy.
DECL|finish_transfer|function|static void finish_transfer(spim_control_block_t * p_cb)
DECL|handler|member|nrfx_spim_evt_handler_t handler;
DECL|irq_handler|function|static void irq_handler(NRF_SPIM_Type * p_spim, spim_control_block_t * p_cb)
DECL|m_anomaly_198_preserved_value|variable|m_anomaly_198_preserved_value
DECL|m_cb|variable|m_cb
DECL|miso_pin|member|uint8_t miso_pin;
DECL|nrfx_spim_0_irq_handler|function|void nrfx_spim_0_irq_handler(void)
DECL|nrfx_spim_1_irq_handler|function|void nrfx_spim_1_irq_handler(void)
DECL|nrfx_spim_2_irq_handler|function|void nrfx_spim_2_irq_handler(void)
DECL|nrfx_spim_3_irq_handler|function|void nrfx_spim_3_irq_handler(void)
DECL|nrfx_spim_abort|function|void nrfx_spim_abort(nrfx_spim_t const * p_instance)
DECL|nrfx_spim_end_event_get|function|uint32_t nrfx_spim_end_event_get(nrfx_spim_t const * p_instance)
DECL|nrfx_spim_init|function|nrfx_err_t nrfx_spim_init(nrfx_spim_t const * const p_instance, nrfx_spim_config_t const * p_config, nrfx_spim_evt_handler_t handler, void * p_context)
DECL|nrfx_spim_start_task_get|function|uint32_t nrfx_spim_start_task_get(nrfx_spim_t const * p_instance)
DECL|nrfx_spim_uninit|function|void nrfx_spim_uninit(nrfx_spim_t const * const p_instance)
DECL|nrfx_spim_xfer_dcx|function|nrfx_err_t nrfx_spim_xfer_dcx(nrfx_spim_t const * const p_instance, nrfx_spim_xfer_desc_t const * p_xfer_desc, uint32_t flags, uint8_t cmd_length)
DECL|nrfx_spim_xfer|function|nrfx_err_t nrfx_spim_xfer(nrfx_spim_t const * const p_instance, nrfx_spim_xfer_desc_t const * p_xfer_desc, uint32_t flags)
DECL|orc|member|uint8_t orc;
DECL|p_context|member|void * p_context;
DECL|rx_length|member|size_t rx_length;
DECL|spim_control_block_t|typedef|} spim_control_block_t;
DECL|spim_int_enable|function|__STATIC_INLINE void spim_int_enable(NRF_SPIM_Type * p_spim, bool enable)
DECL|spim_list_enable_handle|function|__STATIC_INLINE void spim_list_enable_handle(NRF_SPIM_Type * p_spim, uint32_t flags)
DECL|spim_xfer|function|static nrfx_err_t spim_xfer(NRF_SPIM_Type * p_spim, spim_control_block_t * p_cb, nrfx_spim_xfer_desc_t const * p_xfer_desc, uint32_t flags)
DECL|ss_active_high|member|bool ss_active_high;
DECL|ss_pin|member|uint8_t ss_pin;
DECL|state|member|nrfx_drv_state_t state;
DECL|transfer_in_progress|member|volatile bool transfer_in_progress;
DECL|tx_length|member|size_t tx_length;
DECL|use_hw_ss|member|bool use_hw_ss;
| 72.630435 | 180 | 0.879976 |
be59210a1860aa9b0f9bcdfcc4b18dab49a201a9 | 327 | c | C | src/compat/vsyslog.c | awujek/lldpd | e25f1966e0d0b810ab88813b519e52efe4c62923 | [
"0BSD"
] | 312 | 2015-01-18T15:36:55.000Z | 2020-11-10T02:58:53.000Z | src/compat/vsyslog.c | awujek/lldpd | e25f1966e0d0b810ab88813b519e52efe4c62923 | [
"0BSD"
] | 308 | 2015-01-12T13:57:09.000Z | 2020-11-12T01:22:42.000Z | src/compat/vsyslog.c | awujek/lldpd | e25f1966e0d0b810ab88813b519e52efe4c62923 | [
"0BSD"
] | 129 | 2015-01-20T03:42:22.000Z | 2020-09-26T01:46:27.000Z | /* -*- mode: c; c-file-style: "openbsd" -*- */
#include <stdlib.h>
#include <syslog.h>
#include "compat.h"
/* vsyslog() doesn't exist on HP-UX */
void
vsyslog(int facility, const char *format, va_list ap) {
char *msg = NULL;
if (vasprintf(&msg, format, ap) == -1) {
return;
}
syslog(facility, "%s", msg);
free(msg);
}
| 19.235294 | 55 | 0.608563 |
71e64662557c10952cac35c9984ab30654393dec | 252 | h | C | DemoPageView/PageView/UIColor/UIColor+YGW.h | yangjw/iOS-Demo | dcf85a0a9cc521cf0fd3786e0908caf46f936fa9 | [
"MIT"
] | null | null | null | DemoPageView/PageView/UIColor/UIColor+YGW.h | yangjw/iOS-Demo | dcf85a0a9cc521cf0fd3786e0908caf46f936fa9 | [
"MIT"
] | null | null | null | DemoPageView/PageView/UIColor/UIColor+YGW.h | yangjw/iOS-Demo | dcf85a0a9cc521cf0fd3786e0908caf46f936fa9 | [
"MIT"
] | null | null | null | //
// UIColor+YGW.h
// PageView
//
// Created by yangjw on 2018/3/13.
// Copyright © 2018年 yangjw. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIColor (YGW)
+ (UIColor *)randomColor;
+ (UIColor *)colorWithHex:(NSString *)hex;
@end
| 16.8 | 50 | 0.662698 |
a7fe2655bab81785c554fa77ff19c7241b67d104 | 3,001 | h | C | KSOColorPicker/KSOColorPickerButton.h | Kosoku/KSOColorPicker | 7558e5ecd94649d5d9baead6f90f67f476f9bd13 | [
"Apache-2.0"
] | 2 | 2020-04-01T19:45:38.000Z | 2020-05-15T16:03:53.000Z | KSOColorPicker/KSOColorPickerButton.h | Kosoku/KSOColorPicker | 7558e5ecd94649d5d9baead6f90f67f476f9bd13 | [
"Apache-2.0"
] | 1 | 2018-09-10T19:42:26.000Z | 2018-09-10T19:42:26.000Z | KSOColorPicker/KSOColorPickerButton.h | Kosoku/KSOColorPicker | 7558e5ecd94649d5d9baead6f90f67f476f9bd13 | [
"Apache-2.0"
] | null | null | null | //
// KSOColorPickerButton.h
// KSOColorPicker-iOS
//
// Created by William Towe on 9/10/18.
// Copyright © 2018 Kosoku Interactive, LLC. 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.
#import <Ditko/KDIButton.h>
#import <Ditko/KDIUIResponder.h>
NS_ASSUME_NONNULL_BEGIN
@class KSOColorPickerButton;
/**
Block that is invoked to determine the image to display for the provided *color*. Returning nil will use the default image.
@param colorPickerButton The color picker button whose color changed
@param color The new color
@param defaultImageSize The size at which the default image will be drawn
@return The custom image or nil
*/
typedef UIImage* _Nullable (^KSOColorPickerButtonImageForColorBlock)(__kindof KSOColorPickerButton *colorPickerButton, UIColor * _Nullable color, CGSize defaultImageSize);
/**
Block that is invoked to determine the title to display for the provided *color*. Returning nil will leave the title as is.
@param colorPickerButton The color picker button whose color changed
@param color The new color
@return The custom title or nil
*/
typedef NSString* _Nullable (^KSOColorPickerButtonTitleForColorBlock)(__kindof KSOColorPickerButton *colorPickerButton, UIColor * _Nullable color);
@class KSOColorPickerView;
/**
KSOColorPickerButton is a KDIButton subclass that manages a KDIColorPickerView as its inputView.
*/
@interface KSOColorPickerButton : KDIButton <KDIUIResponder>
/**
Set and get the color displayed by the receiver. Whenever the color property of the backing KSOColorPickerView changes, this property will also update.
The default is nil.
*/
@property (strong,nonatomic,nullable) UIColor *color;
/**
Set and get the KSOColorPickerView that is used as the receiver's inputView.
*/
@property (strong,nonatomic,null_resettable) KSOColorPickerView *colorPickerView;
/**
Set and get the block that is used to determine the image the receiver should display whenever it's color property changes.
The default is nil.
@see KSOColorPickerButtonImageForColorBlock
*/
@property (copy,nonatomic,nullable) KSOColorPickerButtonImageForColorBlock imageForColorBlock;
/**
Set and get the block that is used to determine the title the receiver should display whenever it's color property changes.
The default is nil.
@see KSOColorPickerButtonTitleForColorBlock
*/
@property (copy,nonatomic,nullable) KSOColorPickerButtonTitleForColorBlock titleForColorBlock;
@end
NS_ASSUME_NONNULL_END
| 35.72619 | 171 | 0.785072 |
413ef1a8a44b66c029217edfca74e66b61c5d136 | 2,396 | c | C | nm/src/fill_elf.c | rectoria/PSU_2017_nmobjdump | 83ba06e832cfdb8243221eb33f91c4d8da78d35b | [
"MIT"
] | null | null | null | nm/src/fill_elf.c | rectoria/PSU_2017_nmobjdump | 83ba06e832cfdb8243221eb33f91c4d8da78d35b | [
"MIT"
] | null | null | null | nm/src/fill_elf.c | rectoria/PSU_2017_nmobjdump | 83ba06e832cfdb8243221eb33f91c4d8da78d35b | [
"MIT"
] | null | null | null | /*
** EPITECH PROJECT, 2021
** PSU_2017_nmobjdump
** File description:
** Created by rectoria
*/
#include <string.h>
#include <stdio.h>
#include "my_nm.h"
bool isElf(Elf64_Ehdr *elf)
{
return (elf->e_ident[EI_MAG0] == ELFMAG0
&& elf->e_ident[EI_MAG1] == ELFMAG1
&& elf->e_ident[EI_MAG2] == ELFMAG2
&& elf->e_ident[EI_MAG3] == ELFMAG3);
}
bool check_file_type(elf_t *elf)
{
bool ret = true;
if (!((Elf64_Ehdr *)elf->mmap)->e_ident[EI_CLASS])
ret = print_err(elf->filename, "Invalid class", false);
elf->type = (char)(((Elf64_Ehdr *)elf->mmap)->e_ident[EI_CLASS] - 1);
return (ret);
}
bool fill_shstr(const char *filename, elf_t *elf)
{
bool ret = true;
if (elf->type && ((E64)elf->ehdr)->e_shstrndx != SHN_UNDEF)
elf->shstr = &((S64)elf->shdr)[((E64)elf->ehdr)->e_shstrndx];
else if (!elf->type && ((E32)elf->ehdr)->e_shstrndx != SHN_UNDEF)
elf->shstr = &((S32)elf->shdr)[((E32)elf->ehdr)->e_shstrndx];
else
ret = print_err(filename,
"Invalid section header string table index", false);
return (ret);
}
bool get_strtab(const char *filename, elf_t *elf)
{
int iter = elf->type ? ((E64)elf->ehdr)->e_shnum :
((E32)elf->ehdr)->e_shnum;
for (int i = 0; i < iter; ++i) {
if (elf->type &&
!strcmp(elf->mmap + ((S64)elf->shstr)->sh_offset +
((S64)elf->shdr)[i].sh_name, ".strtab")) {
elf->strtab = elf->mmap + ((S64)elf->shdr)[i].sh_offset;
return (true);
} else if (!elf->type &&
!strcmp(elf->mmap + ((S32)elf->shstr)->sh_offset +
((S32)elf->shdr)[i].sh_name, ".strtab")) {
elf->strtab = elf->mmap + ((S32)elf->shdr)[i].sh_offset;
return (true);
}
}
return (print_err(filename, "Unable to locate .strtab section", false));
}
bool get_symtab(const char *filename, elf_t *elf, size_t *size)
{
int iter = elf->type ? ((E64)elf->ehdr)->e_shnum :
((E32)elf->ehdr)->e_shnum;
for (int i = 0; i < iter; ++i)
if (elf->type && ((S64)elf->shdr)[i].sh_type == SHT_SYMTAB) {
elf->symstr = elf->mmap + ((S64)elf->shdr)[i].sh_offset;
*size = ((S64)elf->shdr)[i].sh_size /
((S64)elf->shdr)[i].sh_entsize;
return (true);
} else if (!elf->type &&
((S32)elf->shdr)[i].sh_type == SHT_SYMTAB) {
elf->symstr = elf->mmap + ((S32)elf->shdr)[i].sh_offset;
*size = ((S32)elf->shdr)[i].sh_size /
((S32)elf->shdr)[i].sh_entsize;
return (true);
}
dprintf(2, "nm: %s: %s\n", filename, "no symbols");
return (false);
} | 28.188235 | 73 | 0.613105 |
b381d41312074f24a72a15703332fdd959d3ea6f | 1,284 | h | C | PrivateFrameworks/CloudPhotoLibrary/CPLBaseSyncManager.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/CloudPhotoLibrary/CPLBaseSyncManager.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/CloudPhotoLibrary/CPLBaseSyncManager.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 <CloudPhotoLibrary/CPLPlatformObject.h>
#import "CPLEngineSyncManagerImplementation.h"
@class NSString, _CPLProgress;
@interface CPLBaseSyncManager : CPLPlatformObject <CPLEngineSyncManagerImplementation>
{
BOOL _foreground;
_CPLProgress *_progress;
unsigned long long _currentState;
BOOL _closed;
BOOL _overridingForeground;
}
- (void).cxx_destruct;
- (void)prepareForClose;
- (void)didProgress:(float)arg1 userInfo:(id)arg2 forState:(unsigned long long)arg3;
- (void)didMoveToState:(unsigned long long)arg1;
- (long long)_baseProgressForState:(unsigned long long)arg1 totalUnits:(long long *)arg2;
- (void)syncSessionDidSucceed;
- (void)syncSessionDidFailWithError:(id)arg1;
- (void)didFinishSyncSession;
- (void)willStartSyncSession;
- (void)setSyncSessionShouldBeForeground:(BOOL)arg1;
- (void)endClientWork:(id)arg1;
- (void)beginClientWork:(id)arg1;
- (id)initWithAbstractObject:(id)arg1;
// Remaining properties
@property(readonly, copy) NSString *debugDescription;
@property(readonly, copy) NSString *description;
@property(readonly) unsigned long long hash;
@property(readonly) Class superclass;
@end
| 29.181818 | 89 | 0.767134 |
7da8ea7e085fcd0ca8b07b2289b1adf739e9c746 | 385 | h | C | 29--Oscar/MovieMania/MovieMania/DetailTableViewController.h | PedroTrujilloV/TIY-Assignments | 774c927ad984d61d68ff66bc2b280a85bcfae513 | [
"CC0-1.0"
] | null | null | null | 29--Oscar/MovieMania/MovieMania/DetailTableViewController.h | PedroTrujilloV/TIY-Assignments | 774c927ad984d61d68ff66bc2b280a85bcfae513 | [
"CC0-1.0"
] | null | null | null | 29--Oscar/MovieMania/MovieMania/DetailTableViewController.h | PedroTrujilloV/TIY-Assignments | 774c927ad984d61d68ff66bc2b280a85bcfae513 | [
"CC0-1.0"
] | null | null | null | //
// DetailTableViewController.h
// MovieMania
//
// Created by Pedro Trujillo on 11/13/15.
// Copyright © 2015 The Iron Yard. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "Movie.h"
#import "MoviesCell.h"
@interface DetailTableViewController : UITableViewController
@property (nonatomic) Movie *movie;
@property (nonatomic) NSMutableArray * allKeysInMovieDic;
@end
| 20.263158 | 60 | 0.742857 |
f26a4905781921c00089aae08c4426ab588b805a | 1,918 | c | C | 8-0-kruskal/search_tree.c | Dimonchik0036/FIT-16211-All-labs | c380f1be0824dc8ad5844f355521c9b183852a0b | [
"MIT"
] | 4 | 2017-06-08T18:01:31.000Z | 2017-12-07T08:36:29.000Z | 8-0-kruskal/search_tree.c | Dimonchik0036/FIT-16211-All-labs | c380f1be0824dc8ad5844f355521c9b183852a0b | [
"MIT"
] | null | null | null | 8-0-kruskal/search_tree.c | Dimonchik0036/FIT-16211-All-labs | c380f1be0824dc8ad5844f355521c9b183852a0b | [
"MIT"
] | null | null | null | // Labs: 8-0-kruskal
// Author: Dimonchik0036
#include <stdio.h>
#include <stdlib.h>
#include "kruskal.h"
struct Stack
{
int indexFrom;
int indexTo;
struct Stack *next;
};
static void push(struct Stack **st, int from, int to)
{
if (!st)
{
fprintf(stderr, "ERROR: NULL pointer(Stack)\n");
exit(0);
}
struct Stack *tmp = malloc(sizeof(struct Stack));
if (!tmp)
{
fprintf(stderr, "ERROR: Out of memory!\n");
exit(0);
}
tmp->indexTo = to;
tmp->indexFrom = from;
tmp->next = *st;
(*st) = tmp;
}
static int pop(struct Stack **st, FILE *out)
{
struct Stack *tmp = *st;
if (!st)
{
fprintf(stderr, "ERROR: NULL pointer(Stack)\n");
exit(0);
}
if (!*st) return (0);
fprintf(out, "%d %d\n", (*st)->indexFrom, (*st)->indexTo);
(*st) = (*st)->next;
free(tmp);
return (1);
}
static int compare(const struct Edge *first, const struct Edge *second) { return (first->weight - second->weight); }
static int master(int *set, int index)
{
int last = index;
while (index != set[index]) index = set[index];
set[last] = index;
return (index);
}
static void colored(int *set, int N, int prev, int next) { for (int i = 0; i < N; ++i) if (set[i] == prev) set[i] = next; }
int search_tree(struct Edge *edges, int M, int N, FILE *fOut)
{
int i;
struct Stack *st = NULL;
int *set = malloc(sizeof(int) * N);
if (!set)
{
fprintf(stderr, ERROR_MEM);
exit(0);
}
for (i = 0; i < N; ++i) set[i] = i;
qsort(edges, M, sizeof(struct Edge), compare);
for (i = 0; i < M; ++i)
{
if (master(set, edges[i].indexFrom - 1) != master(set, edges[i].indexTo - 1))
{
colored(set, N, set[edges[i].indexFrom - 1], master(set, edges[i].indexTo - 1));
push(&st, edges[i].indexFrom, edges[i].indexTo);
}
}
int tmp = set[0];
for (i = 0; i < N; ++i)
{
master(set, i);
if (tmp != set[i]) return (-1);
}
for (i = 0; i < M && pop(&st, fOut); ++i);
free(set);
return (0);
}
| 17.436364 | 123 | 0.583942 |
93d6ff696fbac5cc6c2c96a512f17dae7082baa9 | 64 | h | C | src/configFile.h | rexdex/lua_build | 3da086ab8ed9d120539c27e13f71026629f009ac | [
"MIT"
] | null | null | null | src/configFile.h | rexdex/lua_build | 3da086ab8ed9d120539c27e13f71026629f009ac | [
"MIT"
] | null | null | null | src/configFile.h | rexdex/lua_build | 3da086ab8ed9d120539c27e13f71026629f009ac | [
"MIT"
] | null | null | null | #pragma once
#include "common.h"
#include "utils.h"
//--
//-- | 8 | 19 | 0.578125 |
7a417f1927f84510ef41d3ddfa7db99d1d08880f | 477 | h | C | src/render/scene.h | ugozapad/pbr-sandbox | 07417cc68b9422ff01b4c293a42d8ce65f9297ca | [
"BSD-2-Clause"
] | null | null | null | src/render/scene.h | ugozapad/pbr-sandbox | 07417cc68b9422ff01b4c293a42d8ce65f9297ca | [
"BSD-2-Clause"
] | null | null | null | src/render/scene.h | ugozapad/pbr-sandbox | 07417cc68b9422ff01b4c293a42d8ce65f9297ca | [
"BSD-2-Clause"
] | null | null | null | #pragma once
#include "render/mesh.h"
#include "render/light.h"
class ConstantBuffer;
class Scene
{
public:
static int ms_lightsCount;
public:
static Scene* createFromFile(const char* filename);
private:
Scene(aiNode *node, const aiScene *scene);
void processNode(aiNode *node, const aiScene *scene);
void initSceneLights();
public:
~Scene();
void draw();
private:
std::vector<Mesh*> m_meshes;
std::vector<PointLight> m_pointLights;
ConstantBuffer* m_lightCb;
}; | 17.666667 | 54 | 0.744235 |
4d61c93f6fcf5284f641a17e34ee044ad452973b | 172 | h | C | src/ai/robot/GreenTargetRobot.h | elikos/elikos_decisionmaking | d48379643e69ad5fa5dfb2fc79034ca259cf0012 | [
"MIT"
] | 1 | 2019-02-24T08:29:06.000Z | 2019-02-24T08:29:06.000Z | src/ai/robot/GreenTargetRobot.h | elikos/elikos_decisionmaking | d48379643e69ad5fa5dfb2fc79034ca259cf0012 | [
"MIT"
] | null | null | null | src/ai/robot/GreenTargetRobot.h | elikos/elikos_decisionmaking | d48379643e69ad5fa5dfb2fc79034ca259cf0012 | [
"MIT"
] | 1 | 2019-02-12T23:06:13.000Z | 2019-02-12T23:06:13.000Z | //
// Created by olivier on 9/22/16.
//
#ifndef AI_GREEN_TARGET_ROBOT_H
#define AI_GREEN_TARGET_ROBOT_H
class GreenTargetRobot
{
};
#endif // AI_GREEN_TARGET_ROBOT_H
| 10.75 | 33 | 0.755814 |
7fab2832c243c62ee9536d52f8acc3403fcc45c9 | 5,895 | h | C | src/runtime/ext/profile/extprofile_function.h | zhangjiayin/hiphop-php | 7d2f56f342938ba8dc6c54d44e39aa0ba5390679 | [
"PHP-3.01",
"Zend-2.0"
] | 10 | 2019-01-20T18:09:28.000Z | 2021-06-17T01:29:31.000Z | src/runtime/ext/profile/extprofile_function.h | lorenzo/hiphop-php | 31a9c9039f309dcfa213f0db5d29e63bfa4643a9 | [
"PHP-3.01",
"Zend-2.0"
] | null | null | null | src/runtime/ext/profile/extprofile_function.h | lorenzo/hiphop-php | 31a9c9039f309dcfa213f0db5d29e63bfa4643a9 | [
"PHP-3.01",
"Zend-2.0"
] | 4 | 2015-01-15T00:04:16.000Z | 2020-07-26T09:03:34.000Z | /*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 1997-2010 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP 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.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#ifndef __EXTPROFILE_FUNCTION_H__
#define __EXTPROFILE_FUNCTION_H__
// >>>>>> Generated by idl.php. Do NOT modify. <<<<<<
#include <runtime/ext/ext_function.h>
namespace HPHP {
///////////////////////////////////////////////////////////////////////////////
inline Array x_get_defined_functions() {
FUNCTION_INJECTION_BUILTIN(get_defined_functions);
return f_get_defined_functions();
}
inline bool x_function_exists(CStrRef function_name) {
FUNCTION_INJECTION_BUILTIN(function_exists);
return f_function_exists(function_name);
}
inline bool x_is_callable(CVarRef v, bool syntax = false, VRefParam name = null) {
FUNCTION_INJECTION_BUILTIN(is_callable);
return f_is_callable(v, syntax, name);
}
inline Variant x_call_user_func_array(CVarRef function, CArrRef params) {
FUNCTION_NOPROFILE_BUILTIN(call_user_func_array);
return f_call_user_func_array(function, params);
}
inline Variant x_call_user_func(int _argc, CVarRef function, CArrRef _argv = null_array) {
FUNCTION_NOPROFILE_BUILTIN(call_user_func);
return f_call_user_func(_argc, function, _argv);
}
inline Object x_call_user_func_array_async(CVarRef function, CArrRef params) {
FUNCTION_INJECTION_BUILTIN(call_user_func_array_async);
return f_call_user_func_array_async(function, params);
}
inline Object x_call_user_func_async(int _argc, CVarRef function, CArrRef _argv = null_array) {
FUNCTION_INJECTION_BUILTIN(call_user_func_async);
return f_call_user_func_async(_argc, function, _argv);
}
inline Variant x_check_user_func_async(CVarRef handles, int timeout = -1) {
FUNCTION_INJECTION_BUILTIN(check_user_func_async);
return f_check_user_func_async(handles, timeout);
}
inline Variant x_end_user_func_async(CObjRef handle, int default_strategy = k_GLOBAL_STATE_IGNORE, CVarRef additional_strategies = null) {
FUNCTION_INJECTION_BUILTIN(end_user_func_async);
return f_end_user_func_async(handle, default_strategy, additional_strategies);
}
inline String x_call_user_func_serialized(CStrRef input) {
FUNCTION_INJECTION_BUILTIN(call_user_func_serialized);
return f_call_user_func_serialized(input);
}
inline Variant x_call_user_func_array_rpc(CStrRef host, int port, CStrRef auth, int timeout, CVarRef function, CArrRef params) {
FUNCTION_INJECTION_BUILTIN(call_user_func_array_rpc);
return f_call_user_func_array_rpc(host, port, auth, timeout, function, params);
}
inline Variant x_call_user_func_rpc(int _argc, CStrRef host, int port, CStrRef auth, int timeout, CVarRef function, CArrRef _argv = null_array) {
FUNCTION_INJECTION_BUILTIN(call_user_func_rpc);
return f_call_user_func_rpc(_argc, host, port, auth, timeout, function, _argv);
}
inline Variant x_forward_static_call_array(CVarRef function, CArrRef params) {
FUNCTION_INJECTION_BUILTIN(forward_static_call_array);
return f_forward_static_call_array(function, params);
}
inline Variant x_forward_static_call(int _argc, CVarRef function, CArrRef _argv = null_array) {
FUNCTION_INJECTION_BUILTIN(forward_static_call);
return f_forward_static_call(_argc, function, _argv);
}
inline Variant x_get_called_class() {
FUNCTION_INJECTION_BUILTIN(get_called_class);
return f_get_called_class();
}
inline String x_create_function(CStrRef args, CStrRef code) {
FUNCTION_INJECTION_BUILTIN(create_function);
return f_create_function(args, code);
}
inline Variant x_func_get_arg(int arg_num) {
FUNCTION_INJECTION_BUILTIN(func_get_arg);
return f_func_get_arg(arg_num);
}
inline Array x_func_get_args() {
FUNCTION_INJECTION_BUILTIN(func_get_args);
return f_func_get_args();
}
inline int x_func_num_args() {
FUNCTION_INJECTION_BUILTIN(func_num_args);
return f_func_num_args();
}
inline void x_register_postsend_function(int _argc, CVarRef function, CArrRef _argv = null_array) {
FUNCTION_INJECTION_BUILTIN(register_postsend_function);
f_register_postsend_function(_argc, function, _argv);
}
inline void x_register_shutdown_function(int _argc, CVarRef function, CArrRef _argv = null_array) {
FUNCTION_INJECTION_BUILTIN(register_shutdown_function);
f_register_shutdown_function(_argc, function, _argv);
}
inline void x_register_cleanup_function(int _argc, CVarRef function, CArrRef _argv = null_array) {
FUNCTION_INJECTION_BUILTIN(register_cleanup_function);
f_register_cleanup_function(_argc, function, _argv);
}
inline bool x_register_tick_function(int _argc, CVarRef function, CArrRef _argv = null_array) {
FUNCTION_INJECTION_BUILTIN(register_tick_function);
return f_register_tick_function(_argc, function, _argv);
}
inline void x_unregister_tick_function(CVarRef function_name) {
FUNCTION_INJECTION_BUILTIN(unregister_tick_function);
f_unregister_tick_function(function_name);
}
///////////////////////////////////////////////////////////////////////////////
}
#endif // __EXTPROFILE_FUNCTION_H__
| 38.529412 | 145 | 0.717218 |
36998899b4836f54ca50a140f6e5dd373b729532 | 5,020 | h | C | Marlin/src/lcd/extui/mks_ui/wifi_module.h | tom-2273/Tronxy_SKR_mini_E3_V20 | bc4a8dc2c6c627e4bd7aa423794246f5b051448d | [
"CC0-1.0"
] | null | null | null | Marlin/src/lcd/extui/mks_ui/wifi_module.h | tom-2273/Tronxy_SKR_mini_E3_V20 | bc4a8dc2c6c627e4bd7aa423794246f5b051448d | [
"CC0-1.0"
] | null | null | null | Marlin/src/lcd/extui/mks_ui/wifi_module.h | tom-2273/Tronxy_SKR_mini_E3_V20 | bc4a8dc2c6c627e4bd7aa423794246f5b051448d | [
"CC0-1.0"
] | null | null | null | /**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* 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 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "../../../inc/MarlinConfigPre.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define UART_RX_BUFFER_SIZE 1024
#define UART_FIFO_BUFFER_SIZE 1024
#define WIFI_DECODE_TYPE 1
#define IP_DHCP_FLAG 1
#define WIFI_AP_NAME "TP-LINK_MKS"
#define WIFI_KEY_CODE "makerbase"
#define IP_ADDR "192.168.3.100"
#define IP_MASK "255.255.255.0"
#define IP_GATE "192.168.3.1"
#define IP_DNS "192.168.3.1"
#define AP_IP_DHCP_FLAG 1
#define AP_IP_ADDR "192.168.3.100"
#define AP_IP_MASK "255.255.255.0"
#define AP_IP_GATE "192.168.3.1"
#define AP_IP_DNS "192.168.3.1"
#define IP_START_IP "192.168.3.1"
#define IP_END_IP "192.168.3.255"
#define UDISKBUFLEN 1024
typedef enum {
udisk_buf_empty = 0,
udisk_buf_full,
} UDISK_DATA_BUFFER_STATE;
#define TRANS_RCV_FIFO_BLOCK_NUM 14
typedef struct {
bool receiveEspData;
unsigned char *bufferAddr[TRANS_RCV_FIFO_BLOCK_NUM];
unsigned char *p;
UDISK_DATA_BUFFER_STATE state[TRANS_RCV_FIFO_BLOCK_NUM];
unsigned char read_cur;
unsigned char write_cur;
} WIFI_DMA_RCV_FIFO;
typedef struct {
uint8_t flag; // 0x0: no error; 0x01: error
uint32_t start_tick; // error start time
uint32_t now_tick;
} WIFI_TRANS_ERROR;
extern volatile WIFI_TRANS_ERROR wifiTransError;
typedef struct {
char ap_name[32]; // wifi-name
char keyCode[64]; // wifi password
int decodeType;
int baud;
int mode;
} WIFI_PARA;
typedef struct {
char state;
char hostUrl[96];
int port;
char id[21];
} CLOUD_PARA;
typedef struct {
char dhcp_flag;
char ip_addr[16];
char mask[16];
char gate[16];
char dns[16];
char dhcpd_flag;
char dhcpd_ip[16];
char dhcpd_mask[16];
char dhcpd_gate[16];
char dhcpd_dns[16];
char start_ip_addr[16];
char end_ip_addr[16];
} IP_PARA;
typedef enum {
WIFI_NOT_CONFIG,
WIFI_CONFIG_MODE,
WIFI_CONFIG_DHCP,
WIFI_CONFIG_AP,
WIFI_CONFIG_IP_INF,
WIFI_CONFIG_DNS,
WIFI_CONFIG_TCP,
WIFI_CONFIG_SERVER,
WIFI_CONFIG_REMOTE_PORT,
WIFI_CONFIG_BAUD,
WIFI_CONFIG_COMMINT,
WIFI_CONFIG_OK,
WIFI_GET_IP_OK,
WIFI_RECONN,
WIFI_CONNECTED,
WIFI_WAIT_TRANS_START,
WIFI_TRANS_FILE,
WIFI_CONFIG_DHCPD,
WIFI_COFIG_DHCPD_IP,
WIFI_COFIG_DHCPD_DNS,
WIFI_EXCEPTION,
} WIFI_STATE;
typedef enum {
TRANSFER_IDLE,
TRANSFERRING,
TRANSFER_STORE,
} TRANSFER_STATE;
extern volatile TRANSFER_STATE esp_state;
typedef struct {
char buf[20][80];
int rd_index;
int wt_index;
} QUEUE;
typedef enum {
WIFI_PARA_SET, // 0x0:net parameter
WIFI_PRINT_INF, // 0x1:print message
WIFI_TRANS_INF, // 0x2:Pass through information
WIFI_EXCEP_INF, // 0x3:Exception information
WIFI_CLOUD_CFG, // 0x4:cloud config
WIFI_CLOUD_UNBIND, // 0x5:Unbind ID
} WIFI_RET_TYPE;
typedef struct {
uint32_t uart_read_point;
uint32_t uart_write_point;
//uint8_t uartTxBuffer[UART_FIFO_BUFFER_SIZE];
} SZ_USART_FIFO;
#define WIFI_GCODE_BUFFER_LEAST_SIZE 96
#define WIFI_GCODE_BUFFER_SIZE (WIFI_GCODE_BUFFER_LEAST_SIZE * 3)
typedef struct {
uint8_t wait_tick;
uint8_t Buffer[WIFI_GCODE_BUFFER_SIZE];
uint32_t r;
uint32_t w;
} WIFI_GCODE_BUFFER;
extern volatile WIFI_STATE wifi_link_state;
extern WIFI_PARA wifiPara;
extern IP_PARA ipPara;
extern CLOUD_PARA cloud_para;
extern WIFI_GCODE_BUFFER espGcodeFifo;
uint32_t getWifiTick();
uint32_t getWifiTickDiff(int32_t lastTick, int32_t curTick);
void mks_esp_wifi_init();
extern int cfg_cloud_flag;
int send_to_wifi(uint8_t *buf, int len);
void wifi_looping();
int raw_send_to_wifi(uint8_t *buf, int len);
int package_to_wifi(WIFI_RET_TYPE type, uint8_t *buf, int len);
void get_wifi_list_command_send();
void get_wifi_commands();
int readWifiBuf(int8_t *buf, int32_t len);
void mks_wifi_firmware_update();
int usartFifoAvailable(SZ_USART_FIFO *fifo);
int readUsartFifo(SZ_USART_FIFO *fifo, int8_t *buf, int32_t len);
void esp_port_begin(uint8_t interrupt);
#ifdef __cplusplus
} /* C-declarations for C++ */
#endif
| 24.851485 | 79 | 0.729482 |
36e4086b555c4d95001a1ea4fa7362379967c064 | 8,961 | h | C | os/board/rtl8721csm/src/component/soc/realtek/amebad/fwlib/include/rtl8721d_gpio.h | ziyik/TizenRT-1 | d510c03303fcfa605bc12c60f826fa5642bbe406 | [
"Apache-2.0"
] | 511 | 2017-03-29T09:14:09.000Z | 2022-03-30T23:10:29.000Z | os/board/rtl8721csm/src/component/soc/realtek/amebad/fwlib/include/rtl8721d_gpio.h | ziyik/TizenRT-1 | d510c03303fcfa605bc12c60f826fa5642bbe406 | [
"Apache-2.0"
] | 4,673 | 2017-03-29T10:43:43.000Z | 2022-03-31T08:33:44.000Z | os/board/rtl8721csm/src/component/soc/realtek/amebad/fwlib/include/rtl8721d_gpio.h | ziyik/TizenRT-1 | d510c03303fcfa605bc12c60f826fa5642bbe406 | [
"Apache-2.0"
] | 642 | 2017-03-30T20:45:33.000Z | 2022-03-24T17:07:33.000Z | /**
******************************************************************************
* @file rtl8721d_gpio.h
* @author
* @version V1.0.0
* @date 2016-05-17
* @brief This file contains all the functions prototypes for the GPIO firmware
* library.
******************************************************************************
* @attention
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*
* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
******************************************************************************
*/
#ifndef _RTL8721D_GPIO_H_
#define _RTL8721D_GPIO_H_
/** @addtogroup AmebaD_Periph_Driver
* @{
*/
/** @defgroup GPIO
* @brief GPIO driver modules
* @{
*/
/** @addtogroup GPIO
* @verbatim
*****************************************************************************************
* Introduction
*****************************************************************************************
* GPIO:
* - Base Address: GPIO
* - Port number: support A/B two ports
* - Pin number: 0 ~ 31(portA), 0 ~ 31(portB)
* - IRQ: GPIO_IRQ
* - portA/B can be configured to interrupt mode
*
*****************************************************************************************
* How to use GPIO in normal mode
*****************************************************************************************
* To use GPIO peripheral in normal mode, the following steps are mandatory:
*
* 1. Enable the GPIO interface clock using
* RCC_PeriphClockCmd(APBPeriph_GPIO, APBPeriph_GPIO_CLOCK, ENABLE);
*
* 2. Fill the GPIO_InitStruct with the desired parameters.
*
* 3. configure GPIO with the configuration(GPIO mode, pull up/down) of step2:
* GPIO_Init(&GPIO_InitStruct)
*
* 4. Read or write GPIO pin according to GPIO out/in mode using
* GPIO_ReadDataBit() or GPIO_WriteBit()
*
*****************************************************************************************
* How to use GPIO in interrupt mode
*****************************************************************************************
* To use GPIO in interrupt mode, the following steps are mandatory:
*
* 1. Enable the GPIO interface clock using
* RCC_PeriphClockCmd(APBPeriph_GPIO, APBPeriph_GPIO_CLOCK, ENABLE);
*
* 2. Fill the GPIO_InitStruct with the desired parameters.
*
* 3. configure GPIO with the configuration(GPIO mode, pull up/down) of step2:
* GPIO_Init(&GPIO_InitStruct)
*
* 4. Register a user interrupt handler:
* GPIO_UserRegIrq
*
* 5. Configure interrupt mode(trigger, polarity, debounce):
* GPIO_INTMode()
*
* 6. Enable the interrupt of a specified pin:
* GPIO_INTConfig()
*
* @note PortA/B can configure interrupt mode.
*
*****************************************************************************************
* How to use GPIO port (multiple GPIO pins)
*****************************************************************************************
* To use GPIO port, the following steps are mandatory:
*
* 1. Enable the GPIO interface clock using
* RCC_PeriphClockCmd(APBPeriph_GPIO, APBPeriph_GPIO_CLOCK, ENABLE);
*
* 2. Configure GPIO data direction(IN/OUT)
* GPIO_PortDirection()
*
* 3. Read or write GPIO pin according to GPIO out/in mode using
* GPIO_PortRead()
* GPIO_PortWrite()
*
*****************************************************************************************
* @endverbatim
*/
/* Exported types ------------------------------------------------------------*/
/** @defgroup GPIO_Exported_Types GPIO Exported Types
* @{
*/
/**
* @brief GPIO Init structure definition
*/
typedef struct {
u32 GPIO_Mode; /*!< Specifies the operating mode for the selected pins.
This parameter can be a value of @ref GPIO_Mode_parameter_definitions */
u32 GPIO_PuPd; /*!< Specifies the operating Pull-up/Pull down for the selected pins.
This parameter can be a value of @ref GPIO_Pull_parameter_definitions */
u32 GPIO_ITTrigger; /*!< Specifies interrupt mode is level or edge trigger
This parameter can be a value of @ref GPIO_INT_Trigger_parameter_definitions */
u32 GPIO_ITPolarity; /*!< Specifies interrupt mode is high or low active trigger
This parameter can be a value of @ref GPIO_INT_Polarity_parameter_definitions */
u32 GPIO_ITDebounce; /*!< Specifies enable or disable de-bounce for interrupt
This parameter can be a value of @ref GPIO_INT_Debounce_parameter_definitions*/
u32 GPIO_Pin; /*!< Specifies the selected pins.
This parameter contains two parts: Pin: [7:5]: port number; [4:0]: pin number */
} GPIO_InitTypeDef;
/**
* @}
*/
/* Exported constants --------------------------------------------------------*/
/** @defgroup GPIO_Exported_Constants GPIO Exported Constants
* @{
*/
/** @defgroup GPIO_Mode_parameter_definitions
* @{
*/
#define GPIO_Mode_IN 0x00 /*!< GPIO Input Mode */
#define GPIO_Mode_OUT 0x01 /*!< GPIO Output Mode */
#define GPIO_Mode_INT 0x02 /*!< GPIO Interrupt Mode */
/**
* @}
*/
/** @defgroup GPIO_Pull_parameter_definitions
* @{
*/
#define GPIO_PuPd_NOPULL 0x00 /*!< GPIO Interrnal HIGHZ */
#define GPIO_PuPd_DOWN 0x01 /*!< GPIO Interrnal Pull DOWN */
#define GPIO_PuPd_UP 0x02 /*!< GPIO Interrnal Pull UP */
#define GPIO_PuPd_SHUTDOWN 0x03 /*!< GPIO Interrnal PAD shutdown */
/**
* @}
*/
/** @defgroup GPIO_INT_Trigger_parameter_definitions
* @{
*/
#define GPIO_INT_Trigger_LEVEL 0x0 /*!< This interrupt is level trigger */
#define GPIO_INT_Trigger_EDGE 0x1 /*!< This interrupt is edge trigger */
#define GPIO_INT_Trigger_BOTHEDGE 0x2 /*!< This interrupt is both-edge trigger */
#define IS_GPIOIT_LEVEL_TYPE(TYPE) (((TYPE) == GPIO_INT_Trigger_LEVEL)\
|| ((TYPE) == GPIO_INT_Trigger_EDGE)\
|| ((TYPE) == GPIO_INT_Trigger_BOTHEDGE))
/**
* @}
*/
/** @defgroup GPIO_INT_Polarity_parameter_definitions
* @{
*/
#define GPIO_INT_POLARITY_ACTIVE_LOW 0x0 /*!< Setting interrupt to low active: falling edge or low level */
#define GPIO_INT_POLARITY_ACTIVE_HIGH 0x1 /*!< Setting interrupt to high active: rising edge or high level */
#define IS_GPIOIT_POLARITY_TYPE(TYPE) (((TYPE) == GPIO_INT_POLARITY_ACTIVE_LOW)\
|| ((TYPE) == GPIO_INT_POLARITY_ACTIVE_HIGH))
/**
* @}
*/
/** @defgroup GPIO_INT_Debounce_parameter_definitions
* @{
*/
#define GPIO_INT_DEBOUNCE_DISABLE 0x0 /*!< Disable interrupt debounce */
#define GPIO_INT_DEBOUNCE_ENABLE 0x1 /*!< Enable interrupt debounce */
#define IS_GPIOIT_DEBOUNCE_TYPE(TYPE) (((TYPE) == GPIO_INT_DEBOUNCE_DISABLE)\
|| ((TYPE) == GPIO_INT_DEBOUNCE_ENABLE))
/**
* @}
*/
/** @defgroup GPIO_Pin_State_definitions
* @{
*/
#define GPIO_PIN_LOW 0 /*!< Pin state is low */
#define GPIO_PIN_HIGH 1 /*!< Pin state is high */
/**
* @}
*/
/** @defgroup GPIO_Port_definitions
* @{
*/
#define GPIO_PORT_A 0 /*!< Port number A */
#define GPIO_PORT_B 1 /*!< Port number B */
/**
* @}
*/
/** @defgroup GPIO_IRQ_Event_definitions
* @{
*/
#define HAL_IRQ_NONE 0 /*!< No interrupt event */
#define HAL_IRQ_RISE 1 /*!< Rising edge or high level interrupt event */
#define HAL_IRQ_FALL 2 /*!< Falling edge or low level interrupt event */
/**
* @}
*/
/**
* @}
*/
/** @defgroup GPIO_Exported_Functions GPIO Exported Functions
* @{
*/
_LONG_CALL_ void GPIO_WriteBit(u32 GPIO_Pin, u32 BitVal);
_LONG_CALL_ u32 GPIO_ReadDataBit(u32 GPIO_Pin);
_LONG_CALL_ void GPIO_DeInit(u32 GPIO_Pin);
_LONG_CALL_ void GPIO_UserRegIrq(u32 GPIO_Pin, VOID *IrqHandler, VOID *IrqData);
_LONG_CALL_ void GPIO_INTMode(u32 GPIO_Pin, u32 NewState, u32 GPIO_ITTrigger, u32 GPIO_ITPolarity, u32 GPIO_ITDebounce);
_LONG_CALL_ void GPIO_INTConfig(u32 GPIO_Pin, u32 NewState);
_LONG_CALL_ void GPIO_Init(GPIO_InitTypeDef *GPIO_InitStruct);
_LONG_CALL_ u32 GPIO_INTHandler(IN VOID *pData);
_LONG_CALL_ void GPIO_Direction(u32 GPIO_Pin, u32 data_direction);
_LONG_CALL_ u32 GPIO_PortRead(u32 GPIO_Port, u32 GPIO_Mask);
_LONG_CALL_ void GPIO_PortWrite(u32 GPIO_Port, u32 GPIO_Mask, u32 Port_State);
_LONG_CALL_ void GPIO_PortDirection(u32 GPIO_Port, u32 GPIO_Mask, u32 data_direction);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
typedef void (*GPIO_IRQ_FUN)(VOID *Data, u32 Id);
typedef void (*GPIO_USER_IRQ_FUN)(u32 Id);
#endif // end of "#define _RTL8721D_GPIO_H_"
/******************* (C) COPYRIGHT 2016 Realtek Semiconductor *****END OF FILE****/
| 33.815094 | 120 | 0.577056 |
9a8adaa6916516d16f4be52c5148544ac969ad28 | 32,778 | c | C | examples/fonts/fontcmss46b.c | aehparta/libeui | bf73d8dd7b13c4fdcf2524f4e5baa0187bb5fe6c | [
"MIT"
] | 1 | 2020-08-14T22:32:53.000Z | 2020-08-14T22:32:53.000Z | software/rfPacketRx_CC1352P1_LAUNCHXL_tirtos_gcc/fonts/fontcmss46b.c | nlbutts/cc1352_mini_board | ce18b36773f8626cc8bd09935166d7b5476379de | [
"MIT"
] | null | null | null | software/rfPacketRx_CC1352P1_LAUNCHXL_tirtos_gcc/fonts/fontcmss46b.c | nlbutts/cc1352_mini_board | ce18b36773f8626cc8bd09935166d7b5476379de | [
"MIT"
] | null | null | null | /* --COPYRIGHT--,BSD
* Copyright (c) 2014, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --/COPYRIGHT--*/
//*****************************************************************************
//
// This file is generated by ftrasterize; DO NOT EDIT BY HAND!
//
//*****************************************************************************
#include "grlib.h"
//*****************************************************************************
//
// Details of this font:
// Style: cmss
// Size: 46 point
// Bold: yes
// Italic: no
// Memory usage: 5636 bytes
//
//*****************************************************************************
//*****************************************************************************
//
// The compressed data for the 46 point Cmss bold font.
//
//*****************************************************************************
static const uint8_t g_pucCmss46bData[5434] =
{
5, 18, 0, 101, 32, 37, 10, 240, 86, 70, 70, 70,
70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
70, 70, 70, 70, 70, 70, 70, 240, 240, 70, 70, 70,
70, 70, 70, 0, 14, 32, 29, 20, 240, 240, 166, 70,
70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 84, 100,
100, 100, 99, 115, 100, 100, 99, 115, 0, 80, 112, 129,
40, 0, 12, 18, 131, 240, 180, 115, 240, 180, 100, 240,
180, 100, 240, 164, 116, 240, 164, 116, 240, 164, 100, 240,
164, 116, 240, 164, 116, 240, 164, 100, 240, 180, 100, 240,
164, 116, 240, 164, 116, 223, 15, 4, 95, 15, 6, 79,
15, 6, 95, 15, 4, 240, 36, 100, 240, 164, 116, 240,
164, 116, 240, 164, 100, 240, 164, 116, 240, 164, 116, 240,
164, 100, 240, 47, 15, 4, 95, 15, 6, 79, 15, 6,
95, 15, 4, 228, 100, 240, 164, 116, 240, 164, 115, 240,
180, 100, 240, 164, 116, 240, 164, 116, 240, 164, 100, 240,
179, 116, 240, 164, 116, 240, 164, 115, 240, 180, 100, 240,
179, 116, 240, 179, 130, 0, 12, 80, 70, 23, 131, 240,
83, 240, 56, 206, 143, 1, 111, 2, 102, 19, 37, 86,
35, 67, 85, 51, 197, 51, 197, 51, 198, 35, 198, 35,
203, 219, 205, 190, 174, 173, 189, 218, 219, 195, 38, 195,
38, 195, 53, 195, 53, 195, 53, 66, 99, 53, 68, 67,
38, 70, 35, 22, 95, 3, 95, 2, 127, 172, 230, 240,
67, 240, 83, 0, 24, 64, 124, 44, 86, 240, 82, 234,
240, 36, 204, 245, 181, 54, 213, 196, 85, 212, 197, 101,
181, 197, 101, 165, 213, 101, 164, 229, 101, 149, 229, 101,
133, 245, 101, 117, 240, 21, 101, 116, 240, 53, 70, 101,
240, 53, 54, 101, 240, 78, 85, 240, 108, 100, 240, 152,
117, 240, 240, 133, 240, 240, 148, 104, 240, 165, 91, 240,
117, 92, 240, 101, 85, 54, 240, 84, 101, 69, 240, 69,
85, 101, 240, 37, 101, 101, 240, 36, 117, 101, 240, 20,
133, 101, 245, 133, 101, 229, 149, 101, 228, 165, 101, 213,
165, 101, 197, 181, 101, 181, 213, 69, 196, 229, 54, 181,
252, 196, 240, 42, 226, 240, 86, 0, 45, 16, 93, 37,
0, 6, 5, 240, 249, 240, 203, 240, 165, 53, 240, 133,
69, 240, 132, 101, 240, 101, 101, 240, 101, 101, 240, 101,
101, 240, 101, 101, 240, 101, 85, 240, 117, 69, 240, 134,
53, 240, 149, 22, 132, 219, 149, 201, 181, 200, 196, 230,
197, 215, 197, 201, 165, 188, 149, 165, 39, 117, 166, 39,
102, 165, 71, 85, 166, 87, 54, 166, 103, 22, 182, 109,
198, 123, 215, 121, 247, 91, 114, 95, 15, 2, 111, 15,
1, 126, 61, 167, 168, 0, 47, 17, 10, 240, 86, 70,
70, 70, 70, 70, 84, 100, 99, 100, 99, 0, 40, 112,
48, 16, 147, 196, 180, 180, 181, 180, 181, 165, 181, 181,
165, 181, 166, 166, 166, 165, 181, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 181, 182, 166, 166, 181,
181, 182, 181, 181, 197, 196, 197, 196, 212, 212, 211, 64,
48, 16, 3, 212, 212, 212, 197, 196, 197, 197, 181, 182,
181, 181, 182, 166, 166, 181, 182, 166, 166, 166, 166, 166,
166, 166, 166, 166, 166, 166, 166, 165, 181, 166, 166, 165,
181, 166, 165, 181, 165, 180, 181, 180, 180, 180, 195, 208,
52, 23, 131, 240, 69, 240, 53, 240, 53, 195, 67, 67,
85, 51, 53, 70, 35, 38, 71, 19, 23, 95, 2, 155,
240, 19, 240, 27, 159, 2, 87, 19, 23, 70, 35, 38,
69, 51, 53, 83, 67, 67, 197, 240, 53, 240, 53, 240,
67, 0, 70, 64, 103, 38, 0, 30, 66, 240, 240, 84,
240, 240, 68, 240, 240, 68, 240, 240, 68, 240, 240, 68,
240, 240, 68, 240, 240, 68, 240, 240, 68, 240, 240, 68,
240, 240, 68, 240, 240, 68, 240, 240, 68, 240, 240, 68,
240, 95, 15, 2, 95, 15, 4, 79, 15, 4, 95, 15,
2, 240, 84, 240, 240, 68, 240, 240, 68, 240, 240, 68,
240, 240, 68, 240, 240, 68, 240, 240, 68, 240, 240, 68,
240, 240, 68, 240, 240, 68, 240, 240, 68, 240, 240, 68,
240, 240, 68, 240, 240, 68, 240, 240, 82, 0, 31, 18,
10, 0, 35, 6, 70, 70, 70, 70, 70, 84, 100, 99,
100, 99, 0, 8, 48, 9, 17, 0, 46, 109, 77, 77,
0, 43, 13, 10, 0, 35, 6, 70, 70, 70, 70, 70,
0, 14, 32, 94, 23, 240, 18, 240, 84, 240, 68, 240,
68, 240, 52, 240, 68, 240, 52, 240, 68, 240, 68, 240,
52, 240, 68, 240, 68, 240, 52, 240, 68, 240, 52, 240,
68, 240, 68, 240, 52, 240, 68, 240, 68, 240, 52, 240,
68, 240, 67, 240, 68, 240, 68, 240, 52, 240, 68, 240,
68, 240, 52, 240, 68, 240, 68, 240, 52, 240, 68, 240,
52, 240, 68, 240, 68, 240, 52, 240, 68, 240, 68, 240,
52, 240, 68, 240, 52, 240, 68, 240, 68, 240, 82, 240,
80, 71, 24, 240, 240, 22, 240, 26, 221, 165, 69, 149,
101, 133, 102, 102, 102, 101, 133, 101, 133, 86, 134, 70,
134, 70, 134, 70, 134, 70, 134, 70, 134, 70, 134, 70,
134, 70, 134, 70, 134, 70, 134, 70, 134, 70, 134, 70,
134, 70, 134, 70, 134, 85, 133, 101, 133, 102, 102, 102,
102, 118, 85, 149, 69, 174, 202, 240, 22, 0, 31, 48,
44, 21, 240, 243, 240, 21, 231, 156, 156, 156, 162, 54,
246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 175,
1, 79, 2, 95, 1, 0, 29, 48, 69, 24, 0, 6,
103, 252, 190, 159, 1, 118, 72, 85, 119, 85, 135, 83,
166, 98, 166, 98, 166, 240, 54, 240, 54, 240, 54, 240,
38, 240, 54, 240, 38, 240, 53, 240, 53, 240, 53, 240,
53, 240, 53, 240, 53, 240, 53, 240, 53, 240, 53, 240,
53, 240, 53, 240, 63, 4, 95, 4, 95, 4, 95, 4,
95, 4, 0, 33, 64, 66, 24, 240, 240, 23, 236, 190,
159, 1, 118, 86, 116, 134, 114, 150, 114, 150, 240, 54,
240, 54, 240, 53, 240, 54, 240, 53, 240, 54, 218, 233,
251, 240, 70, 240, 70, 240, 69, 240, 70, 240, 54, 240,
54, 240, 54, 240, 54, 240, 54, 81, 198, 67, 182, 68,
150, 87, 87, 95, 3, 143, 173, 232, 0, 31, 32, 70,
25, 0, 7, 86, 240, 55, 240, 40, 240, 40, 240, 25,
240, 25, 244, 21, 244, 21, 229, 21, 228, 37, 213, 37,
212, 53, 197, 53, 196, 69, 181, 69, 180, 85, 165, 85,
149, 101, 149, 101, 133, 117, 133, 117, 143, 6, 79, 6,
79, 6, 79, 6, 240, 21, 240, 85, 240, 85, 240, 85,
240, 85, 240, 85, 240, 85, 0, 35, 48, 68, 24, 0,
6, 47, 1, 143, 1, 143, 1, 143, 1, 143, 1, 134,
240, 54, 240, 54, 240, 54, 240, 54, 240, 54, 240, 54,
240, 61, 191, 159, 1, 135, 70, 117, 102, 117, 117, 131,
134, 240, 54, 240, 54, 240, 54, 240, 54, 240, 54, 240,
54, 82, 182, 83, 165, 85, 134, 87, 87, 111, 2, 143,
188, 231, 0, 31, 48, 67, 24, 240, 240, 55, 235, 204,
189, 167, 82, 150, 240, 54, 240, 38, 240, 54, 240, 53,
240, 69, 240, 54, 54, 150, 41, 118, 27, 104, 70, 103,
102, 87, 117, 87, 118, 70, 134, 70, 134, 70, 134, 70,
134, 70, 134, 70, 134, 85, 134, 85, 134, 85, 134, 86,
117, 117, 102, 118, 71, 143, 173, 203, 247, 0, 31, 32,
73, 24, 0, 6, 15, 4, 95, 5, 79, 5, 79, 5,
79, 4, 240, 53, 240, 54, 240, 53, 240, 53, 240, 54,
240, 53, 240, 54, 240, 53, 240, 54, 240, 53, 240, 54,
240, 53, 240, 54, 240, 54, 240, 54, 240, 38, 240, 54,
240, 54, 240, 54, 240, 53, 240, 54, 240, 54, 240, 54,
240, 54, 240, 54, 240, 54, 240, 54, 240, 54, 0, 31,
96, 65, 24, 240, 248, 236, 190, 159, 1, 118, 87, 101,
133, 101, 133, 101, 133, 101, 133, 101, 133, 101, 133, 101,
133, 102, 102, 118, 70, 158, 202, 206, 150, 70, 118, 102,
101, 133, 86, 134, 70, 134, 70, 134, 70, 134, 70, 134,
70, 134, 70, 134, 70, 134, 86, 102, 103, 71, 127, 1,
158, 188, 232, 0, 31, 32, 67, 24, 240, 240, 22, 251,
206, 159, 150, 70, 118, 101, 117, 118, 86, 133, 86, 133,
86, 134, 70, 134, 70, 134, 70, 134, 70, 134, 70, 134,
70, 134, 70, 119, 85, 119, 86, 103, 102, 57, 107, 22,
121, 38, 150, 54, 240, 53, 240, 69, 240, 69, 240, 54,
240, 53, 145, 134, 132, 86, 158, 158, 188, 247, 0, 31,
64, 21, 10, 0, 16, 38, 70, 70, 70, 70, 70, 0,
11, 102, 70, 70, 70, 70, 70, 0, 14, 32, 26, 10,
0, 16, 38, 70, 70, 70, 70, 70, 0, 11, 102, 70,
70, 70, 70, 70, 84, 100, 99, 100, 99, 0, 8, 48,
37, 10, 0, 13, 102, 70, 70, 70, 70, 70, 240, 240,
70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 240,
144, 32, 37, 0, 69, 79, 15, 1, 95, 15, 3, 79,
15, 3, 95, 15, 1, 0, 33, 31, 15, 1, 95, 15,
3, 79, 15, 3, 95, 15, 1, 0, 70, 57, 22, 0,
31, 5, 240, 23, 247, 247, 247, 240, 21, 0, 10, 53,
240, 37, 240, 37, 240, 37, 240, 37, 240, 37, 240, 21,
240, 37, 240, 22, 240, 21, 240, 22, 246, 247, 246, 246,
240, 22, 240, 22, 240, 22, 146, 86, 132, 86, 86, 95,
2, 111, 153, 0, 6, 80, 49, 21, 0, 5, 104, 174,
111, 1, 85, 86, 84, 118, 81, 150, 246, 246, 246, 231,
215, 230, 230, 230, 245, 240, 21, 245, 240, 21, 240, 21,
240, 20, 240, 36, 240, 36, 240, 36, 0, 9, 118, 246,
246, 246, 246, 246, 0, 30, 16, 84, 31, 0, 9, 25,
240, 78, 255, 3, 199, 102, 182, 165, 149, 198, 117, 124,
117, 94, 101, 95, 1, 85, 69, 72, 85, 53, 118, 84,
69, 118, 69, 53, 149, 69, 53, 149, 69, 53, 149, 69,
53, 149, 69, 53, 149, 69, 53, 149, 69, 53, 149, 69,
53, 149, 69, 53, 149, 85, 53, 117, 101, 53, 117, 101,
70, 69, 133, 77, 149, 91, 181, 103, 215, 240, 168, 150,
175, 4, 239, 240, 73, 0, 44, 80, 33, 0, 9, 87,
240, 169, 240, 139, 240, 123, 240, 123, 240, 109, 240, 93,
240, 86, 22, 240, 70, 39, 240, 54, 39, 240, 54, 39,
240, 38, 71, 240, 22, 71, 240, 22, 71, 246, 103, 230,
103, 230, 103, 214, 135, 198, 135, 198, 135, 182, 167, 175,
8, 175, 8, 159, 10, 143, 10, 134, 214, 118, 231, 102,
231, 102, 246, 86, 240, 23, 70, 240, 23, 69, 240, 54,
0, 45, 112, 71, 30, 0, 7, 79, 3, 207, 6, 159,
7, 143, 8, 118, 153, 102, 183, 102, 199, 86, 214, 86,
214, 86, 214, 86, 198, 102, 198, 102, 182, 118, 151, 143,
6, 159, 4, 191, 7, 134, 168, 102, 199, 86, 214, 86,
215, 70, 230, 70, 230, 70, 230, 70, 230, 70, 215, 70,
214, 86, 184, 95, 9, 111, 8, 127, 7, 143, 4, 0,
42, 80, 71, 30, 0, 8, 122, 240, 47, 2, 191, 4,
175, 5, 152, 118, 135, 195, 119, 225, 134, 240, 134, 240,
150, 240, 150, 240, 134, 240, 150, 240, 150, 240, 150, 240,
150, 240, 150, 240, 150, 240, 150, 240, 150, 240, 150, 240,
166, 240, 150, 240, 150, 240, 166, 240, 151, 241, 135, 211,
137, 118, 143, 7, 175, 5, 207, 1, 240, 42, 0, 42,
48, 87, 33, 0, 8, 47, 4, 239, 7, 191, 9, 159,
10, 134, 170, 118, 215, 118, 231, 102, 246, 102, 240, 22,
86, 240, 22, 86, 240, 37, 86, 240, 38, 70, 240, 38,
70, 240, 38, 70, 240, 38, 70, 240, 38, 70, 240, 38,
70, 240, 38, 70, 240, 38, 70, 240, 38, 70, 240, 38,
70, 240, 38, 70, 240, 22, 86, 240, 22, 86, 247, 86,
231, 102, 215, 118, 185, 127, 10, 143, 9, 159, 7, 191,
4, 0, 47, 16, 71, 26, 0, 6, 79, 6, 95, 6,
95, 6, 95, 6, 95, 6, 86, 240, 86, 240, 86, 240,
86, 240, 86, 240, 86, 240, 86, 240, 86, 240, 86, 240,
95, 5, 111, 5, 111, 5, 111, 5, 102, 240, 86, 240,
86, 240, 86, 240, 86, 240, 86, 240, 86, 240, 86, 240,
86, 240, 95, 7, 79, 7, 79, 7, 79, 7, 79, 7,
0, 36, 32, 70, 25, 0, 6, 47, 5, 95, 6, 79,
6, 79, 6, 79, 5, 86, 240, 70, 240, 70, 240, 70,
240, 70, 240, 70, 240, 70, 240, 70, 240, 70, 240, 79,
3, 127, 4, 111, 4, 111, 3, 118, 240, 70, 240, 70,
240, 70, 240, 70, 240, 70, 240, 70, 240, 70, 240, 70,
240, 70, 240, 70, 240, 70, 240, 70, 240, 70, 0, 36,
96, 72, 30, 0, 8, 122, 240, 47, 1, 207, 5, 159,
6, 136, 134, 119, 195, 119, 226, 118, 240, 17, 102, 240,
150, 240, 150, 240, 134, 240, 150, 240, 150, 240, 150, 240,
150, 240, 150, 240, 150, 170, 70, 170, 70, 170, 70, 170,
86, 214, 86, 214, 87, 198, 102, 198, 103, 182, 119, 166,
136, 134, 159, 6, 175, 5, 207, 1, 240, 42, 0, 42,
48, 71, 31, 0, 7, 102, 246, 70, 246, 70, 246, 70,
246, 70, 246, 70, 246, 70, 246, 70, 246, 70, 246, 70,
246, 70, 246, 70, 246, 70, 246, 70, 246, 79, 12, 79,
12, 79, 12, 79, 12, 70, 246, 70, 246, 70, 246, 70,
246, 70, 246, 70, 246, 70, 246, 70, 246, 70, 246, 70,
246, 70, 246, 70, 246, 70, 246, 70, 246, 0, 43, 16,
38, 10, 240, 86, 70, 70, 70, 70, 70, 70, 70, 70,
70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 0,
14, 32, 43, 21, 0, 6, 86, 246, 246, 246, 246, 246,
246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246, 246,
246, 246, 246, 246, 246, 246, 246, 246, 81, 150, 82, 134,
84, 71, 111, 95, 125, 184, 0, 27, 48, 75, 32, 0,
8, 6, 246, 86, 231, 86, 215, 102, 199, 118, 183, 134,
167, 150, 151, 166, 135, 182, 119, 198, 103, 214, 87, 230,
71, 246, 55, 240, 22, 24, 240, 47, 1, 240, 31, 2,
255, 2, 255, 3, 234, 39, 217, 71, 200, 87, 199, 119,
182, 151, 166, 166, 166, 167, 150, 183, 134, 199, 118, 199,
118, 215, 102, 231, 86, 247, 70, 240, 21, 0, 44, 80,
71, 23, 0, 5, 102, 240, 38, 240, 38, 240, 38, 240,
38, 240, 38, 240, 38, 240, 38, 240, 38, 240, 38, 240,
38, 240, 38, 240, 38, 240, 38, 240, 38, 240, 38, 240,
38, 240, 38, 240, 38, 240, 38, 240, 38, 240, 38, 240,
38, 240, 38, 240, 38, 240, 38, 240, 38, 240, 47, 4,
79, 4, 79, 4, 79, 4, 79, 4, 0, 32, 16, 117,
40, 0, 10, 8, 240, 88, 73, 240, 57, 74, 240, 26,
74, 240, 26, 74, 240, 26, 75, 235, 75, 235, 70, 20,
228, 22, 70, 21, 197, 22, 70, 21, 197, 22, 70, 37,
165, 38, 70, 37, 165, 38, 70, 37, 165, 38, 70, 53,
133, 54, 70, 53, 133, 54, 70, 54, 101, 70, 70, 69,
101, 70, 70, 69, 101, 70, 70, 85, 69, 86, 70, 85,
69, 86, 70, 85, 69, 86, 70, 101, 37, 102, 70, 101,
37, 102, 70, 107, 118, 70, 122, 118, 70, 122, 118, 70,
136, 134, 70, 136, 134, 70, 135, 150, 70, 150, 150, 70,
164, 166, 70, 240, 150, 0, 55, 64, 89, 32, 0, 8,
24, 229, 74, 198, 74, 198, 75, 182, 75, 182, 76, 166,
76, 166, 70, 22, 150, 70, 22, 150, 70, 38, 134, 70,
38, 134, 70, 54, 118, 70, 54, 118, 70, 70, 102, 70,
70, 102, 70, 86, 86, 70, 86, 86, 70, 102, 70, 70,
102, 70, 70, 118, 54, 70, 118, 54, 70, 134, 38, 70,
134, 38, 70, 150, 22, 70, 150, 22, 70, 172, 70, 172,
70, 187, 70, 187, 70, 202, 70, 202, 70, 217, 0, 44,
64, 86, 33, 240, 240, 217, 240, 111, 240, 47, 3, 223,
6, 199, 120, 166, 182, 150, 214, 134, 214, 118, 246, 102,
246, 102, 246, 101, 240, 38, 70, 240, 38, 70, 240, 38,
70, 240, 38, 70, 240, 38, 70, 240, 38, 70, 240, 38,
70, 240, 38, 70, 240, 38, 70, 240, 38, 70, 240, 38,
70, 240, 38, 86, 246, 102, 246, 102, 246, 118, 214, 135,
183, 151, 151, 169, 104, 191, 6, 223, 4, 240, 31, 240,
105, 0, 43, 70, 29, 0, 7, 47, 3, 191, 6, 143,
7, 127, 8, 102, 168, 86, 198, 86, 199, 70, 214, 70,
214, 70, 214, 70, 214, 70, 214, 70, 214, 70, 199, 70,
198, 86, 168, 95, 8, 111, 7, 127, 6, 143, 3, 182,
240, 134, 240, 134, 240, 134, 240, 134, 240, 134, 240, 134,
240, 134, 240, 134, 240, 134, 240, 134, 240, 134, 0, 42,
96, 104, 34, 240, 240, 234, 240, 127, 240, 47, 3, 255,
6, 200, 104, 183, 167, 151, 199, 134, 230, 118, 240, 22,
102, 240, 22, 102, 240, 22, 101, 240, 54, 70, 240, 54,
70, 240, 54, 70, 240, 54, 70, 240, 54, 70, 240, 54,
70, 240, 54, 70, 240, 54, 70, 240, 54, 70, 240, 54,
70, 240, 54, 70, 240, 54, 86, 240, 23, 86, 102, 70,
102, 103, 54, 118, 103, 23, 119, 94, 151, 93, 153, 75,
191, 7, 239, 3, 240, 47, 3, 240, 79, 1, 240, 200,
240, 184, 240, 200, 240, 199, 0, 26, 32, 71, 29, 0,
7, 47, 3, 191, 6, 143, 7, 127, 8, 102, 168, 86,
198, 86, 199, 70, 214, 70, 214, 70, 214, 70, 214, 70,
214, 70, 199, 70, 198, 86, 167, 111, 7, 127, 6, 143,
4, 166, 103, 166, 103, 166, 119, 150, 134, 150, 135, 134,
150, 134, 151, 118, 167, 102, 182, 102, 183, 86, 198, 86,
199, 70, 214, 70, 229, 0, 40, 48, 65, 26, 0, 7,
57, 239, 159, 3, 143, 3, 119, 102, 118, 148, 102, 193,
118, 240, 86, 240, 86, 240, 87, 240, 73, 240, 59, 255,
207, 1, 191, 1, 191, 1, 207, 236, 240, 56, 240, 87,
240, 71, 240, 86, 240, 86, 66, 230, 67, 214, 69, 167,
71, 119, 95, 6, 95, 5, 127, 3, 175, 233, 0, 33,
112, 70, 32, 0, 8, 15, 13, 79, 13, 79, 13, 79,
13, 79, 13, 246, 240, 182, 240, 182, 240, 182, 240, 182,
240, 182, 240, 182, 240, 182, 240, 182, 240, 182, 240, 182,
240, 182, 240, 182, 240, 182, 240, 182, 240, 182, 240, 182,
240, 182, 240, 182, 240, 182, 240, 182, 240, 182, 240, 182,
240, 182, 240, 182, 240, 182, 240, 182, 0, 45, 112, 72,
30, 0, 7, 70, 230, 70, 230, 70, 230, 70, 230, 70,
230, 70, 230, 70, 230, 70, 230, 70, 230, 70, 230, 70,
230, 70, 230, 70, 230, 70, 230, 70, 230, 70, 230, 70,
230, 70, 230, 70, 230, 70, 230, 70, 230, 70, 230, 70,
230, 70, 230, 70, 230, 86, 199, 86, 198, 103, 167, 120,
104, 159, 5, 191, 3, 223, 240, 57, 0, 39, 16, 82,
35, 0, 8, 102, 240, 70, 71, 240, 54, 87, 240, 22,
103, 240, 22, 103, 247, 119, 230, 135, 230, 135, 215, 151,
198, 167, 198, 167, 183, 183, 166, 199, 166, 214, 150, 231,
134, 231, 119, 247, 102, 240, 23, 102, 240, 23, 87, 240,
39, 70, 240, 55, 70, 240, 55, 55, 240, 71, 38, 240,
87, 38, 240, 102, 22, 240, 125, 240, 125, 240, 139, 240,
155, 240, 155, 240, 169, 240, 185, 0, 50, 122, 49, 0,
12, 37, 231, 228, 86, 216, 198, 70, 201, 197, 102, 185,
197, 102, 185, 197, 102, 171, 166, 102, 171, 165, 134, 149,
21, 165, 134, 149, 21, 165, 134, 133, 38, 134, 134, 133,
38, 133, 166, 117, 53, 133, 166, 117, 54, 102, 166, 101,
70, 102, 166, 101, 70, 101, 198, 85, 85, 101, 198, 85,
86, 70, 198, 69, 102, 69, 230, 53, 102, 69, 230, 53,
117, 69, 230, 53, 118, 38, 230, 37, 134, 37, 240, 22,
21, 134, 37, 240, 22, 21, 149, 37, 240, 22, 20, 172,
240, 27, 171, 240, 58, 186, 240, 58, 186, 240, 57, 202,
240, 57, 201, 240, 88, 216, 240, 87, 231, 0, 69, 77,
34, 0, 8, 87, 215, 120, 184, 136, 167, 152, 151, 184,
120, 200, 103, 232, 71, 240, 23, 56, 240, 24, 39, 240,
63, 240, 93, 240, 124, 240, 123, 240, 153, 240, 184, 240,
184, 240, 169, 240, 170, 240, 140, 240, 110, 240, 71, 23,
240, 71, 39, 240, 39, 56, 247, 88, 216, 103, 215, 135,
183, 152, 152, 168, 135, 199, 119, 216, 88, 232, 71, 240,
23, 0, 47, 32, 74, 34, 0, 8, 71, 240, 38, 72,
247, 87, 231, 104, 215, 120, 183, 151, 167, 168, 151, 184,
119, 215, 103, 232, 87, 248, 55, 240, 39, 39, 240, 56,
23, 240, 78, 240, 108, 240, 124, 240, 138, 240, 168, 240,
199, 240, 198, 240, 214, 240, 214, 240, 214, 240, 214, 240,
214, 240, 214, 240, 214, 240, 214, 240, 214, 240, 214, 240,
214, 240, 214, 0, 48, 96, 72, 29, 0, 7, 63, 9,
95, 9, 95, 9, 95, 9, 95, 9, 240, 88, 240, 103,
240, 103, 240, 104, 240, 103, 240, 103, 240, 103, 240, 104,
240, 103, 240, 103, 240, 103, 240, 104, 240, 103, 240, 103,
240, 104, 240, 103, 240, 103, 240, 103, 240, 104, 240, 103,
240, 103, 240, 103, 240, 127, 9, 79, 10, 79, 10, 79,
10, 79, 10, 0, 40, 48, 48, 15, 10, 91, 74, 86,
150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
150, 150, 154, 91, 74, 80, 29, 21, 240, 240, 243, 131,
100, 116, 99, 131, 100, 116, 100, 116, 86, 86, 70, 86,
70, 86, 70, 86, 70, 86, 70, 86, 0, 84, 64, 48,
15, 26, 75, 90, 150, 150, 150, 150, 150, 150, 150, 150,
150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150,
150, 150, 150, 150, 150, 150, 150, 90, 75, 90, 64, 17,
19, 240, 240, 213, 215, 185, 149, 21, 117, 52, 100, 100,
83, 132, 0, 86, 10, 10, 240, 86, 70, 70, 70, 70,
0, 48, 17, 10, 240, 131, 100, 99, 100, 100, 86, 70,
70, 70, 70, 70, 0, 40, 64, 48, 24, 0, 36, 105,
206, 159, 2, 117, 102, 115, 150, 98, 166, 240, 54, 240,
54, 240, 54, 204, 143, 1, 103, 86, 87, 102, 86, 118,
70, 134, 70, 134, 70, 134, 71, 103, 87, 72, 92, 22,
106, 38, 134, 84, 0, 33, 80, 71, 24, 0, 6, 6,
240, 54, 240, 54, 240, 54, 240, 54, 240, 54, 240, 54,
240, 54, 240, 54, 240, 54, 240, 54, 240, 54, 54, 150,
26, 127, 3, 104, 71, 86, 118, 86, 118, 86, 134, 70,
134, 70, 134, 70, 134, 70, 134, 70, 134, 70, 134, 70,
134, 70, 134, 70, 118, 86, 118, 87, 86, 111, 3, 102,
25, 149, 38, 0, 34, 32, 45, 23, 0, 35, 56, 205,
159, 127, 1, 103, 100, 102, 146, 101, 240, 38, 240, 38,
240, 38, 240, 38, 240, 38, 240, 38, 240, 38, 240, 38,
240, 54, 161, 102, 146, 103, 101, 111, 2, 127, 157, 200,
0, 32, 96, 69, 25, 0, 8, 37, 240, 70, 240, 70,
240, 70, 240, 70, 240, 70, 240, 70, 240, 70, 240, 70,
240, 70, 240, 70, 166, 54, 138, 22, 127, 3, 103, 87,
86, 134, 86, 134, 70, 150, 70, 150, 70, 150, 70, 150,
70, 150, 70, 150, 70, 150, 70, 150, 70, 150, 86, 134,
86, 134, 102, 88, 111, 4, 138, 22, 166, 68, 0, 35,
45, 25, 0, 41, 72, 253, 175, 1, 135, 86, 102, 133,
102, 148, 101, 165, 70, 165, 70, 165, 79, 6, 79, 6,
70, 240, 70, 240, 70, 240, 86, 240, 70, 194, 102, 163,
103, 102, 127, 3, 158, 232, 0, 35, 64, 41, 20, 0,
6, 8, 170, 155, 134, 66, 118, 97, 118, 230, 230, 230,
230, 230, 204, 125, 140, 166, 230, 230, 230, 230, 230, 230,
230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 0,
28, 112, 63, 27, 0, 44, 89, 68, 143, 4, 127, 5,
102, 70, 181, 102, 150, 102, 150, 102, 150, 102, 150, 102,
150, 102, 150, 102, 166, 70, 206, 221, 225, 40, 243, 240,
147, 240, 159, 1, 191, 3, 175, 4, 143, 4, 111, 7,
85, 182, 69, 213, 69, 213, 70, 197, 86, 150, 127, 4,
159, 2, 219, 0, 8, 71, 23, 0, 5, 102, 240, 38,
240, 38, 240, 38, 240, 38, 240, 38, 240, 38, 240, 38,
240, 38, 240, 38, 240, 38, 240, 38, 70, 118, 42, 86,
27, 89, 55, 71, 102, 71, 102, 70, 118, 70, 118, 70,
118, 70, 118, 70, 118, 70, 118, 70, 118, 70, 118, 70,
118, 70, 118, 70, 118, 70, 118, 70, 118, 70, 118, 70,
118, 0, 32, 16, 35, 10, 240, 86, 70, 70, 70, 70,
70, 0, 6, 102, 70, 70, 70, 70, 70, 70, 70, 70,
70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
0, 14, 32, 46, 17, 240, 240, 182, 167, 167, 167, 167,
182, 0, 12, 6, 182, 182, 182, 182, 182, 182, 182, 182,
182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182,
182, 182, 182, 182, 66, 71, 76, 92, 91, 150, 240, 240,
192, 65, 23, 0, 5, 101, 240, 53, 240, 53, 240, 53,
240, 53, 240, 53, 240, 53, 240, 53, 240, 53, 240, 53,
240, 53, 240, 53, 118, 85, 103, 85, 87, 101, 71, 117,
55, 133, 39, 149, 23, 172, 187, 203, 204, 189, 174, 150,
38, 149, 70, 133, 86, 117, 87, 101, 102, 101, 118, 85,
134, 69, 134, 0, 32, 16, 38, 10, 240, 86, 70, 70,
70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
70, 70, 70, 70, 70, 0, 14, 32, 71, 37, 0, 60,
22, 70, 134, 118, 42, 58, 102, 27, 44, 86, 18, 58,
71, 71, 104, 102, 71, 103, 118, 70, 118, 134, 70, 118,
134, 70, 118, 134, 70, 118, 134, 70, 118, 134, 70, 118,
134, 70, 118, 134, 70, 118, 134, 70, 118, 134, 70, 118,
134, 70, 118, 134, 70, 118, 134, 70, 118, 134, 70, 118,
134, 70, 118, 134, 0, 51, 48, 50, 23, 0, 37, 54,
70, 118, 42, 86, 27, 86, 18, 55, 71, 102, 71, 102,
70, 118, 70, 118, 70, 118, 70, 118, 70, 118, 70, 118,
70, 118, 70, 118, 70, 118, 70, 118, 70, 118, 70, 118,
70, 118, 70, 118, 70, 118, 0, 32, 16, 45, 26, 0,
43, 24, 254, 191, 1, 150, 102, 118, 134, 102, 134, 101,
165, 86, 166, 70, 166, 70, 166, 70, 166, 70, 166, 70,
166, 70, 166, 86, 135, 86, 134, 104, 87, 127, 3, 159,
1, 190, 248, 0, 37, 16, 67, 24, 0, 37, 37, 150,
41, 118, 27, 111, 4, 88, 71, 86, 118, 86, 119, 70,
134, 70, 134, 70, 134, 70, 134, 70, 134, 70, 134, 70,
134, 70, 134, 70, 134, 70, 118, 86, 118, 87, 71, 111,
2, 118, 25, 134, 38, 166, 240, 54, 240, 54, 240, 54,
240, 54, 240, 54, 240, 54, 240, 54, 240, 54, 0, 8,
32, 69, 24, 0, 36, 101, 69, 137, 22, 127, 2, 111,
3, 88, 56, 86, 103, 86, 118, 70, 134, 70, 134, 70,
134, 70, 134, 70, 134, 70, 134, 70, 134, 70, 134, 70,
134, 86, 118, 86, 103, 102, 72, 111, 3, 122, 22, 150,
54, 240, 54, 240, 54, 240, 54, 240, 54, 240, 54, 240,
54, 240, 54, 240, 54, 240, 54, 0, 6, 64, 32, 17,
0, 27, 86, 67, 70, 37, 70, 22, 70, 22, 74, 120,
151, 167, 166, 182, 182, 182, 182, 182, 182, 182, 182, 182,
182, 182, 182, 0, 24, 96, 34, 19, 0, 29, 8, 156,
109, 101, 68, 85, 114, 85, 229, 231, 203, 156, 140, 139,
170, 214, 244, 81, 148, 67, 132, 69, 85, 78, 94, 123,
167, 0, 27, 16, 35, 20, 0, 17, 118, 230, 230, 230,
230, 230, 191, 95, 95, 134, 230, 230, 230, 230, 230, 230,
230, 230, 230, 230, 230, 230, 231, 51, 125, 140, 138, 197,
0, 28, 80, 50, 23, 0, 37, 54, 118, 70, 118, 70,
118, 70, 118, 70, 118, 70, 118, 70, 118, 70, 118, 70,
118, 70, 118, 70, 118, 70, 118, 70, 118, 70, 118, 70,
118, 70, 118, 70, 103, 70, 103, 71, 72, 91, 22, 105,
37, 135, 0, 30, 48, 43, 24, 0, 39, 5, 165, 70,
149, 70, 134, 85, 133, 101, 133, 102, 102, 117, 101, 133,
101, 134, 70, 149, 69, 165, 69, 166, 38, 166, 38, 181,
37, 204, 204, 218, 234, 234, 248, 240, 24, 0, 34, 32,
71, 35, 0, 56, 117, 147, 149, 69, 133, 133, 70, 117,
118, 85, 102, 117, 101, 103, 101, 102, 87, 101, 102, 87,
86, 117, 67, 21, 69, 133, 67, 21, 69, 134, 51, 21,
69, 134, 36, 21, 53, 165, 36, 37, 37, 165, 35, 53,
37, 166, 19, 53, 22, 185, 53, 21, 201, 74, 200, 90,
200, 90, 215, 89, 230, 120, 245, 119, 0, 49, 48, 45,
24, 0, 39, 6, 133, 86, 118, 102, 86, 134, 70, 150,
38, 188, 203, 233, 240, 24, 240, 38, 240, 54, 240, 39,
240, 40, 250, 213, 37, 182, 38, 150, 69, 149, 101, 118,
102, 86, 134, 69, 165, 0, 33, 64, 61, 24, 0, 39,
5, 165, 70, 149, 70, 134, 86, 117, 102, 117, 118, 86,
118, 85, 149, 70, 150, 54, 165, 53, 182, 37, 182, 21,
213, 21, 219, 233, 249, 240, 24, 240, 23, 240, 54, 240,
54, 240, 53, 240, 69, 240, 69, 240, 68, 240, 69, 194,
69, 219, 218, 233, 240, 22, 0, 8, 16, 34, 22, 0,
35, 127, 2, 95, 2, 95, 2, 246, 247, 231, 246, 246,
247, 231, 246, 246, 247, 246, 246, 246, 247, 246, 255, 3,
79, 3, 79, 3, 0, 30, 96, 13, 29, 0, 72, 79,
10, 79, 10, 79, 10, 0, 80, 32, 22, 54, 0, 127,
0, 8, 15, 15, 15, 5, 79, 15, 15, 5, 79, 15,
15, 5, 0, 127, 0, 22, 21, 19, 240, 240, 150, 38,
85, 53, 101, 53, 85, 68, 100, 69, 100, 68, 115, 83,
0, 86, 64, 19, 20, 240, 240, 212, 99, 103, 67, 90,
20, 68, 26, 83, 72, 83, 100, 0, 93, 48,
};
//*****************************************************************************
//
// The font definition for the 46 point Cmss bold font.
//
//*****************************************************************************
const Graphics_Font g_sFontCmss46b =
{
//
// The format of the font.
//
FONT_FMT_PIXEL_RLE,
//
// The maximum width of the font.
//
49,
//
// The height of the font.
//
45,
//
// The baseline of the font.
//
34,
//
// The offset to each character in the font.
//
{
0, 5, 42, 71, 200, 270, 394, 487,
504, 552, 600, 652, 755, 773, 782, 795,
889, 960, 1004, 1073, 1139, 1209, 1277, 1344,
1417, 1482, 1549, 1570, 1596, 1633, 1665, 1722,
1771, 1855, 1935, 2006, 2077, 2164, 2235, 2305,
2377, 2448, 2486, 2529, 2604, 2675, 2792, 2881,
2967, 3037, 3141, 3212, 3277, 3347, 3419, 3501,
3623, 3700, 3774, 3846, 3894, 3923, 3971, 3988,
3998, 4015, 4063, 4134, 4179, 4248, 4293, 4334,
4397, 4468, 4503, 4549, 4614, 4652, 4723, 4773,
4818, 4885, 4954, 4986, 5020, 5055, 5105, 5148,
5219, 5264, 5325, 5359, 5372, 5394, 5415,
},
//
// A pointer to the actual font data
//
g_pucCmss46bData
};
| 58.220249 | 79 | 0.468027 |
9a922752ca9592b0aa3df29889a1b2ba7311abbf | 3,257 | h | C | Code/Tools/Animation/GraphEditor/EditorGraph/Animation_EditorGraph_Variations.h | JuanluMorales/KRG | f3a11de469586a4ef0db835af4bc4589e6b70779 | [
"MIT"
] | 419 | 2022-01-27T19:37:43.000Z | 2022-03-31T06:14:22.000Z | Code/Tools/Animation/GraphEditor/EditorGraph/Animation_EditorGraph_Variations.h | jagt/KRG | ba20cd8798997b0450491b0cc04dc817c4a4bc76 | [
"MIT"
] | 2 | 2022-01-28T20:35:33.000Z | 2022-03-13T17:42:52.000Z | Code/Tools/Animation/GraphEditor/EditorGraph/Animation_EditorGraph_Variations.h | jagt/KRG | ba20cd8798997b0450491b0cc04dc817c4a4bc76 | [
"MIT"
] | 20 | 2022-01-27T20:41:02.000Z | 2022-03-26T16:16:57.000Z | #pragma once
#include "System/Animation/AnimationSkeleton.h"
#include "System/Resource/ResourcePtr.h"
#include "System/TypeSystem/TypeRegistrationMacros.h"
#include "System/Core/Types/StringID.h"
#include "System/Core/ThirdParty/KRG_RapidJson.h"
//-------------------------------------------------------------------------
namespace KRG::TypeSystem { class TypeRegistry;}
//-------------------------------------------------------------------------
namespace KRG::Animation
{
struct Variation : public IRegisteredType
{
KRG_REGISTER_TYPE( Variation );
inline bool IsValid() const { return m_ID.IsValid(); }
inline bool operator==( StringID const& variationID ) const { return m_ID == variationID; }
inline bool operator!=( StringID const& variationID ) const { return m_ID != variationID; }
KRG_EXPOSE StringID m_ID;
KRG_REGISTER StringID m_parentID;
KRG_EXPOSE TResourcePtr<Skeleton> m_pSkeleton;
};
//-------------------------------------------------------------------------
class VariationHierarchy
{
public:
VariationHierarchy();
void Reset();
// Does the specified variation exist?
inline bool IsValidVariation( StringID variationID ) const { return eastl::find( m_variations.begin(), m_variations.end(), variationID ) != m_variations.end(); }
// Get a specified variation
Variation* GetVariation( StringID variationID );
// Get a specified variation
Variation const* GetVariation( StringID variationID ) const { return const_cast<VariationHierarchy*>( this )->GetVariation( variationID ); }
// Returns the ID of the parent variation (invalid ID if called for the default variation)
StringID GetParentVariationID( StringID variationID ) const;
// Get all children for a specified variation
TInlineVector<StringID, 5> GetChildVariations( StringID variationID ) const;
// Get a flat list of all variations
TVector<Variation> const& GetAllVariations() const { return m_variations; }
// This will create a new variation under the specified parent variation
void CreateVariation( StringID variationID, StringID parentVariationID );
// This will rename the specified variation
void RenameVariation( StringID oldVariationID, StringID newVariationID );
// This will destroy the specified variation and all children
void DestroyVariation( StringID variationID );
// Serialization
bool Serialize( TypeSystem::TypeRegistry const& typeRegistry, RapidJsonValue const& objectValue );
void Serialize( TypeSystem::TypeRegistry const& typeRegistry, RapidJsonWriter& writer ) const;
private:
inline int32 GetVariationIndex( StringID variationID ) const
{
auto iter = eastl::find( m_variations.begin(), m_variations.end(), variationID );
if ( iter != m_variations.end() )
{
return int32( iter - m_variations.begin() );
}
return InvalidIndex;
}
private:
TVector<Variation> m_variations;
};
} | 37.011364 | 169 | 0.617746 |
966510323912032545ab870a6c9051106bfdd447 | 1,318 | h | C | include/threadPoolBook.h | kiyoMatsui/concurrencyTests | eefe67ff8f7bf3d39d45977ddeba99861f1167da | [
"BSL-1.0"
] | null | null | null | include/threadPoolBook.h | kiyoMatsui/concurrencyTests | eefe67ff8f7bf3d39d45977ddeba99861f1167da | [
"BSL-1.0"
] | null | null | null | include/threadPoolBook.h | kiyoMatsui/concurrencyTests | eefe67ff8f7bf3d39d45977ddeba99861f1167da | [
"BSL-1.0"
] | null | null | null | #ifndef THREADPOOL_BOOK
#define THREADPOOL_BOOK
#include <vector>
#include <thread>
#include <functional>
#include <atomic>
#include "tsQueueBook.h"
class join_threads {
std::vector<std::thread> &threads;
public:
explicit join_threads(std::vector<std::thread> &threads_)
: threads(threads_) {}
~join_threads() {
for (unsigned long i = 0; i < threads.size(); ++i) {
if (threads[i].joinable())
threads[i].join();
}
}
};
class thread_pool {
std::atomic_bool done;
threadsafe_queue<std::function<void()>> work_queue;
std::vector<std::thread> threads;
join_threads joiner;
void worker_thread() {
while (!done) {
std::function<void()> task;
if (work_queue.try_pop(task)) {
task();
} else {
std::this_thread::yield();
}
}
}
public:
thread_pool() : done(false), joiner(threads) {
unsigned const thread_count = std::thread::hardware_concurrency();
try {
for (unsigned i = 0; i < thread_count; ++i) {
threads.push_back(std::thread(&thread_pool::worker_thread, this));
}
} catch (...) {
done = true;
throw;
}
}
~thread_pool() { done = true; }
template <typename FunctionType> void submit(FunctionType f) {
work_queue.push(std::function<void()>(f));
}
};
#endif
| 20.920635 | 74 | 0.614568 |
3277b900498328e415b9eb049854138c3f2110d7 | 58,855 | c | C | ext/kameleon/ext/hdf5/hdf5-1.8.12/src/H5V.c | alexanderbock/Kameleon-Converter | 6c2e66bfea60b17a369a3615bc1a623bba100a6f | [
"BSD-3-Clause"
] | 6 | 2015-07-16T14:09:58.000Z | 2017-09-02T02:51:08.000Z | ext/kameleon/ext/hdf5/hdf5-1.8.12/src/H5V.c | alexanderbock/Kameleon-Converter | 6c2e66bfea60b17a369a3615bc1a623bba100a6f | [
"BSD-3-Clause"
] | null | null | null | ext/kameleon/ext/hdf5/hdf5-1.8.12/src/H5V.c | alexanderbock/Kameleon-Converter | 6c2e66bfea60b17a369a3615bc1a623bba100a6f | [
"BSD-3-Clause"
] | null | null | null | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the files COPYING and Copyright.html. COPYING can be found at the root *
* of the source code distribution tree; Copyright.html can be found at the *
* root level of an installed copy of the electronic HDF5 document set and *
* is linked from the top-level documents page. It can also be found at *
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
* access to either file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Programmer: Robb Matzke <matzke@llnl.gov>
* Friday, October 10, 1997
*/
#include "H5private.h"
#include "H5Eprivate.h"
#include "H5Oprivate.h"
#include "H5Vprivate.h"
/* Local typedefs */
typedef struct H5V_memcpy_ud_t {
unsigned char *dst; /* Pointer to destination buffer */
const unsigned char *src; /* Pointer to source buffer */
} H5V_memcpy_ud_t;
/* Local macros */
#define H5V_HYPER_NDIMS H5O_LAYOUT_NDIMS
/* Local prototypes */
static void
H5V_stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/,
const hsize_t *size, hsize_t *stride1);
static void
H5V_stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/,
const hsize_t *size, hsize_t *stride1, hsize_t *stride2);
#ifdef LATER
static void
H5V_stride_copy2(hsize_t nelmts, hsize_t elmt_size,
unsigned dst_n, const hsize_t *dst_size, const ssize_t *dst_stride, void *_dst,
unsigned src_n, const hsize_t *src_size, const ssize_t *src_stride, const void *_src);
#endif /* LATER */
/*-------------------------------------------------------------------------
* Function: H5V_stride_optimize1
*
* Purpose: Given a stride vector which references elements of the
* specified size, optimize the dimensionality, the stride
* vector, and the element size to minimize the dimensionality
* and the number of memory accesses.
*
* All arguments are passed by reference and their values may be
* modified by this function.
*
* Return: None
*
* Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
H5V_stride_optimize1(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/,
const hsize_t *size, hsize_t *stride1)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
/*
* This has to be true because if we optimize the dimensionality down to
* zero we still must make one reference.
*/
HDassert(1 == H5V_vector_reduce_product(0, NULL));
/*
* Combine adjacent memory accesses
*/
while (*np && stride1[*np-1]>0 &&
(hsize_t)(stride1[*np-1])==*elmt_size) {
*elmt_size *= size[*np-1];
if (--*np)
stride1[*np-1] += size[*np] * stride1[*np];
}
FUNC_LEAVE_NOAPI_VOID
}
/*-------------------------------------------------------------------------
* Function: H5V_stride_optimize2
*
* Purpose: Given two stride vectors which reference elements of the
* specified size, optimize the dimensionality, the stride
* vectors, and the element size to minimize the dimensionality
* and the number of memory accesses.
*
* All arguments are passed by reference and their values may be
* modified by this function.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
* Unrolled loops for common cases
* Quincey Koziol
* ?, ? ?, 2001?
*
*-------------------------------------------------------------------------
*/
static void
H5V_stride_optimize2(unsigned *np/*in,out*/, hsize_t *elmt_size/*in,out*/,
const hsize_t *size, hsize_t *stride1, hsize_t *stride2)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
/*
* This has to be true because if we optimize the dimensionality down to
* zero we still must make one reference.
*/
HDassert(1 == H5V_vector_reduce_product(0, NULL));
HDassert(*elmt_size>0);
/*
* Combine adjacent memory accesses
*/
/* Unroll loop for common cases */
switch(*np) {
case 1: /* For 0-D datasets (dunno if this ever gets used...) */
if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) {
*elmt_size *= size[0];
--*np; /* *np decrements to a value of 0 now */
} /* end if */
break;
case 2: /* For 1-D datasets */
if(stride1[1] == *elmt_size && stride2[1] == *elmt_size) {
*elmt_size *= size[1];
--*np; /* *np decrements to a value of 1 now */
stride1[0] += size[1] * stride1[1];
stride2[0] += size[1] * stride2[1];
if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) {
*elmt_size *= size[0];
--*np; /* *np decrements to a value of 0 now */
} /* end if */
} /* end if */
break;
case 3: /* For 2-D datasets */
if(stride1[2] == *elmt_size && stride2[2] == *elmt_size) {
*elmt_size *= size[2];
--*np; /* *np decrements to a value of 2 now */
stride1[1] += size[2] * stride1[2];
stride2[1] += size[2] * stride2[2];
if(stride1[1] == *elmt_size && stride2[1] == *elmt_size) {
*elmt_size *= size[1];
--*np; /* *np decrements to a value of 1 now */
stride1[0] += size[1] * stride1[1];
stride2[0] += size[1] * stride2[1];
if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) {
*elmt_size *= size[0];
--*np; /* *np decrements to a value of 0 now */
} /* end if */
} /* end if */
} /* end if */
break;
case 4: /* For 3-D datasets */
if(stride1[3] == *elmt_size && stride2[3] == *elmt_size) {
*elmt_size *= size[3];
--*np; /* *np decrements to a value of 3 now */
stride1[2] += size[3] * stride1[3];
stride2[2] += size[3] * stride2[3];
if(stride1[2] == *elmt_size && stride2[2] == *elmt_size) {
*elmt_size *= size[2];
--*np; /* *np decrements to a value of 2 now */
stride1[1] += size[2] * stride1[2];
stride2[1] += size[2] * stride2[2];
if(stride1[1] == *elmt_size && stride2[1] == *elmt_size) {
*elmt_size *= size[1];
--*np; /* *np decrements to a value of 1 now */
stride1[0] += size[1] * stride1[1];
stride2[0] += size[1] * stride2[1];
if(stride1[0] == *elmt_size && stride2[0] == *elmt_size) {
*elmt_size *= size[0];
--*np; /* *np decrements to a value of 0 now */
} /* end if */
} /* end if */
} /* end if */
} /* end if */
break;
default:
while (*np &&
stride1[*np-1] == *elmt_size &&
stride2[*np-1] == *elmt_size) {
*elmt_size *= size[*np-1];
if (--*np) {
stride1[*np-1] += size[*np] * stride1[*np];
stride2[*np-1] += size[*np] * stride2[*np];
}
}
break;
} /* end switch */
FUNC_LEAVE_NOAPI_VOID
}
/*-------------------------------------------------------------------------
* Function: H5V_hyper_stride
*
* Purpose: Given a description of a hyperslab, this function returns
* (through STRIDE[]) the byte strides appropriate for accessing
* all bytes of the hyperslab and the byte offset where the
* striding will begin. The SIZE can be passed to the various
* stride functions.
*
* The dimensionality of the whole array, the hyperslab, and the
* returned stride array is N. The whole array dimensions are
* TOTAL_SIZE and the hyperslab is at offset OFFSET and has
* dimensions SIZE.
*
* The stride and starting point returned will cause the
* hyperslab elements to be referenced in C order.
*
* Return: Success: Byte offset from beginning of array to start
* of striding.
*
* Failure: abort() -- should never fail
*
* Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
* Unrolled loops for common cases
* Quincey Koziol
* ?, ? ?, 2001?
*
*-------------------------------------------------------------------------
*/
hsize_t
H5V_hyper_stride(unsigned n, const hsize_t *size,
const hsize_t *total_size, const hsize_t *offset,
hsize_t *stride/*out*/)
{
hsize_t skip; /*starting point byte offset */
hsize_t acc; /*accumulator */
int i; /*counter */
hsize_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT_NOERR
HDassert(n <= H5V_HYPER_NDIMS);
HDassert(size);
HDassert(total_size);
HDassert(stride);
/* init */
HDassert(n>0);
stride[n-1] = 1;
skip = offset ? offset[n-1] : 0;
switch(n) {
case 2: /* 1-D dataset */
HDassert(total_size[1]>=size[1]);
stride[0] = total_size[1]-size[1]; /*overflow checked*/
acc = total_size[1];
skip += acc * (offset ? offset[0] : 0);
break;
case 3: /* 2-D dataset */
HDassert(total_size[2]>=size[2]);
stride[1] = total_size[2]-size[2]; /*overflow checked*/
acc = total_size[2];
skip += acc * (offset ? (hsize_t)offset[1] : 0);
HDassert(total_size[1]>=size[1]);
stride[0] = acc * (total_size[1] - size[1]); /*overflow checked*/
acc *= total_size[1];
skip += acc * (offset ? (hsize_t)offset[0] : 0);
break;
case 4: /* 3-D dataset */
HDassert(total_size[3]>=size[3]);
stride[2] = total_size[3]-size[3]; /*overflow checked*/
acc = total_size[3];
skip += acc * (offset ? (hsize_t)offset[2] : 0);
HDassert(total_size[2]>=size[2]);
stride[1] = acc * (total_size[2] - size[2]); /*overflow checked*/
acc *= total_size[2];
skip += acc * (offset ? (hsize_t)offset[1] : 0);
HDassert(total_size[1]>=size[1]);
stride[0] = acc * (total_size[1] - size[1]); /*overflow checked*/
acc *= total_size[1];
skip += acc * (offset ? (hsize_t)offset[0] : 0);
break;
default:
/* others */
for (i=(int)(n-2), acc=1; i>=0; --i) {
HDassert(total_size[i+1]>=size[i+1]);
stride[i] = acc * (total_size[i+1] - size[i+1]); /*overflow checked*/
acc *= total_size[i+1];
skip += acc * (offset ? (hsize_t)offset[i] : 0);
}
break;
} /* end switch */
/* Set return value */
ret_value=skip;
FUNC_LEAVE_NOAPI(ret_value)
}
/*-------------------------------------------------------------------------
* Function: H5V_hyper_eq
*
* Purpose: Determines whether two hyperslabs are equal. This function
* assumes that both hyperslabs are relative to the same array,
* for if not, they could not possibly be equal.
*
* Return: Success: TRUE if the hyperslabs are equal (that is,
* both refer to exactly the same elements of an
* array)
*
* FALSE otherwise.
*
* Failure: TRUE the rank is zero or if both hyperslabs
* are of zero size.
*
* Programmer: Robb Matzke
* Friday, October 17, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
htri_t
H5V_hyper_eq(unsigned n,
const hsize_t *offset1, const hsize_t *size1,
const hsize_t *offset2, const hsize_t *size2)
{
hsize_t nelmts1 = 1, nelmts2 = 1;
unsigned i;
htri_t ret_value=TRUE; /* Return value */
/* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
FUNC_ENTER_NOAPI_NOINIT_NOERR
if (n == 0) HGOTO_DONE(TRUE)
for (i=0; i<n; i++) {
if ((offset1 ? offset1[i] : 0) != (offset2 ? offset2[i] : 0))
HGOTO_DONE(FALSE)
if ((size1 ? size1[i] : 0) != (size2 ? size2[i] : 0))
HGOTO_DONE(FALSE)
if (0 == (nelmts1 *= (size1 ? size1[i] : 0)))
HGOTO_DONE(FALSE)
if (0 == (nelmts2 *= (size2 ? size2[i] : 0)))
HGOTO_DONE(FALSE)
}
done:
FUNC_LEAVE_NOAPI(ret_value)
}
/*-------------------------------------------------------------------------
* Function: H5V_hyper_disjointp
*
* Purpose: Determines if two hyperslabs are disjoint.
*
* Return: Success: FALSE if they are not disjoint.
* TRUE if they are disjoint.
*
* Failure: A hyperslab of zero size is disjoint from all
* other hyperslabs.
*
* Programmer: Robb Matzke
* Thursday, October 16, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
htri_t
H5V_hyper_disjointp(unsigned n,
const hsize_t *offset1, const uint32_t *size1,
const hsize_t *offset2, const uint32_t *size2)
{
unsigned u;
htri_t ret_value = FALSE; /* Return value */
/* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */
FUNC_ENTER_NOAPI_NOINIT_NOERR
if(!n || !size1 || !size2)
HGOTO_DONE(TRUE)
for(u = 0; u < n; u++) {
HDassert(size1[u] < HSIZET_MAX);
HDassert(size2[u] < HSIZET_MAX);
if(0 == size1[u] || 0 == size2[u])
HGOTO_DONE(TRUE)
if(((offset1 ? offset1[u] : 0) < (offset2 ? offset2[u] : 0) &&
((offset1 ? offset1[u] : 0) + size1[u] <= (offset2 ? offset2[u] : 0))) ||
((offset2 ? offset2[u] : 0) < (offset1 ? offset1[u] : 0) &&
((offset2 ? offset2[u] : 0) + size2[u] <= (offset1 ? offset1[u] : 0))))
HGOTO_DONE(TRUE)
} /* end for */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5V_hyper_disjointp() */
/*-------------------------------------------------------------------------
* Function: H5V_hyper_fill
*
* Purpose: Similar to memset() except it operates on hyperslabs...
*
* Fills a hyperslab of array BUF with some value VAL. BUF
* is treated like a C-order array with N dimensions where the
* size of each dimension is TOTAL_SIZE[]. The hyperslab which
* will be filled with VAL begins at byte offset OFFSET[] from
* the minimum corner of BUF and continues for SIZE[] bytes in
* each dimension.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5V_hyper_fill(unsigned n, const hsize_t *_size,
const hsize_t *total_size, const hsize_t *offset, void *_dst,
unsigned fill_value)
{
uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic */
hsize_t size[H5V_HYPER_NDIMS]; /*a modifiable copy of _size */
hsize_t dst_stride[H5V_HYPER_NDIMS]; /*destination stride info */
hsize_t dst_start; /*byte offset to start of stride*/
hsize_t elmt_size = 1; /*bytes per element */
herr_t ret_value; /*function return status */
#ifndef NDEBUG
unsigned u;
#endif
FUNC_ENTER_NOAPI_NOINIT_NOERR
/* check args */
HDassert(n > 0 && n <= H5V_HYPER_NDIMS);
HDassert(_size);
HDassert(total_size);
HDassert(dst);
#ifndef NDEBUG
for (u = 0; u < n; u++) {
HDassert(_size[u] > 0);
HDassert(total_size[u] > 0);
}
#endif
/* Copy the size vector so we can modify it */
H5V_vector_cpy(n, size, _size);
/* Compute an optimal destination stride vector */
dst_start = H5V_hyper_stride(n, size, total_size, offset, dst_stride);
H5V_stride_optimize1(&n, &elmt_size, size, dst_stride);
/* Copy */
ret_value = H5V_stride_fill(n, elmt_size, size, dst_stride, dst+dst_start,
fill_value);
FUNC_LEAVE_NOAPI(ret_value)
}
/*-------------------------------------------------------------------------
* Function: H5V_hyper_copy
*
* Purpose: Copies a hyperslab from the source to the destination.
*
* A hyperslab is a logically contiguous region of
* multi-dimensional size SIZE of an array whose dimensionality
* is N and whose total size is DST_TOTAL_SIZE or SRC_TOTAL_SIZE.
* The minimum corner of the hyperslab begins at a
* multi-dimensional offset from the minimum corner of the DST
* (destination) or SRC (source) array. The sizes and offsets
* are assumed to be in C order, that is, the first size/offset
* varies the slowest while the last varies the fastest in the
* mapping from N-dimensional space to linear space. This
* function assumes that the array elements are single bytes (if
* your array has multi-byte elements then add an additional
* dimension whose size is that of your element).
*
* The SRC and DST array may be the same array, but the results
* are undefined if the source hyperslab overlaps the
* destination hyperslab.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
* Unrolled loops for common cases
* Quincey Koziol
* ?, ? ?, 2001?
*
*-------------------------------------------------------------------------
*/
herr_t
H5V_hyper_copy(unsigned n, const hsize_t *_size,
/*destination*/
const hsize_t *dst_size, const hsize_t *dst_offset,
void *_dst,
/*source*/
const hsize_t *src_size, const hsize_t *src_offset,
const void *_src)
{
const uint8_t *src = (const uint8_t*)_src; /*cast for ptr arithmtc */
uint8_t *dst = (uint8_t*) _dst; /*cast for ptr arithmtc */
hsize_t size[H5V_HYPER_NDIMS]; /*a modifiable _size */
hsize_t src_stride[H5V_HYPER_NDIMS]; /*source stride info */
hsize_t dst_stride[H5V_HYPER_NDIMS]; /*dest stride info */
hsize_t dst_start, src_start; /*offset to start at */
hsize_t elmt_size = 1; /*element size in bytes */
herr_t ret_value; /*return status */
#ifndef NDEBUG
unsigned u;
#endif
FUNC_ENTER_NOAPI_NOINIT_NOERR
/* check args */
HDassert(n > 0 && n <= H5V_HYPER_NDIMS);
HDassert(_size);
HDassert(dst_size);
HDassert(src_size);
HDassert(dst);
HDassert(src);
#ifndef NDEBUG
for (u = 0; u < n; u++) {
HDassert(_size[u] > 0);
HDassert(dst_size[u] > 0);
HDassert(src_size[u] > 0);
}
#endif
/* Copy the size vector so we can modify it */
H5V_vector_cpy(n, size, _size);
/* Compute stride vectors for source and destination */
#ifdef NO_INLINED_CODE
dst_start = H5V_hyper_stride(n, size, dst_size, dst_offset, dst_stride);
src_start = H5V_hyper_stride(n, size, src_size, src_offset, src_stride);
#else /* NO_INLINED_CODE */
/* in-line version of two calls to H5V_hyper_stride() */
{
hsize_t dst_acc; /*accumulator */
hsize_t src_acc; /*accumulator */
int ii; /*counter */
/* init */
HDassert(n>0);
dst_stride[n-1] = 1;
src_stride[n-1] = 1;
dst_start = dst_offset ? dst_offset[n-1] : 0;
src_start = src_offset ? src_offset[n-1] : 0;
/* Unroll loop for common cases */
switch(n) {
case 2:
HDassert(dst_size[1]>=size[1]);
HDassert(src_size[1]>=size[1]);
dst_stride[0] = dst_size[1] - size[1]; /*overflow checked*/
src_stride[0] = src_size[1] - size[1]; /*overflow checked*/
dst_acc = dst_size[1];
src_acc = src_size[1];
dst_start += dst_acc * (dst_offset ? dst_offset[0] : 0);
src_start += src_acc * (src_offset ? src_offset[0] : 0);
break;
case 3:
HDassert(dst_size[2]>=size[2]);
HDassert(src_size[2]>=size[2]);
dst_stride[1] = dst_size[2] - size[2]; /*overflow checked*/
src_stride[1] = src_size[2] - size[2]; /*overflow checked*/
dst_acc = dst_size[2];
src_acc = src_size[2];
dst_start += dst_acc * (dst_offset ? dst_offset[1] : 0);
src_start += src_acc * (src_offset ? src_offset[1] : 0);
HDassert(dst_size[1]>=size[1]);
HDassert(src_size[1]>=size[1]);
dst_stride[0] = dst_acc * (dst_size[1] - size[1]); /*overflow checked*/
src_stride[0] = src_acc * (src_size[1] - size[1]); /*overflow checked*/
dst_acc *= dst_size[1];
src_acc *= src_size[1];
dst_start += dst_acc * (dst_offset ? dst_offset[0] : 0);
src_start += src_acc * (src_offset ? src_offset[0] : 0);
break;
case 4:
HDassert(dst_size[3]>=size[3]);
HDassert(src_size[3]>=size[3]);
dst_stride[2] = dst_size[3] - size[3]; /*overflow checked*/
src_stride[2] = src_size[3] - size[3]; /*overflow checked*/
dst_acc = dst_size[3];
src_acc = src_size[3];
dst_start += dst_acc * (dst_offset ? dst_offset[2] : 0);
src_start += src_acc * (src_offset ? src_offset[2] : 0);
HDassert(dst_size[2]>=size[2]);
HDassert(src_size[2]>=size[2]);
dst_stride[1] = dst_acc * (dst_size[2] - size[2]); /*overflow checked*/
src_stride[1] = src_acc * (src_size[2] - size[2]); /*overflow checked*/
dst_acc *= dst_size[2];
src_acc *= src_size[2];
dst_start += dst_acc * (dst_offset ? dst_offset[1] : 0);
src_start += src_acc * (src_offset ? src_offset[1] : 0);
HDassert(dst_size[1]>=size[1]);
HDassert(src_size[1]>=size[1]);
dst_stride[0] = dst_acc * (dst_size[1] - size[1]); /*overflow checked*/
src_stride[0] = src_acc * (src_size[1] - size[1]); /*overflow checked*/
dst_acc *= dst_size[1];
src_acc *= src_size[1];
dst_start += dst_acc * (dst_offset ? dst_offset[0] : 0);
src_start += src_acc * (src_offset ? src_offset[0] : 0);
break;
default:
/* others */
for (ii=(int)(n-2), dst_acc=1, src_acc=1; ii>=0; --ii) {
HDassert(dst_size[ii+1]>=size[ii+1]);
HDassert(src_size[ii+1]>=size[ii+1]);
dst_stride[ii] = dst_acc * (dst_size[ii+1] - size[ii+1]); /*overflow checked*/
src_stride[ii] = src_acc * (src_size[ii+1] - size[ii+1]); /*overflow checked*/
dst_acc *= dst_size[ii+1];
src_acc *= src_size[ii+1];
dst_start += dst_acc * (dst_offset ? dst_offset[ii] : 0);
src_start += src_acc * (src_offset ? src_offset[ii] : 0);
}
break;
} /* end switch */
}
#endif /* NO_INLINED_CODE */
/* Optimize the strides as a pair */
H5V_stride_optimize2(&n, &elmt_size, size, dst_stride, src_stride);
/* Perform the copy in terms of stride */
ret_value = H5V_stride_copy(n, elmt_size, size,
dst_stride, dst+dst_start, src_stride, src+src_start);
FUNC_LEAVE_NOAPI(ret_value)
}
/*-------------------------------------------------------------------------
* Function: H5V_stride_fill
*
* Purpose: Fills all bytes of a hyperslab with the same value using
* memset().
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5V_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size,
const hsize_t *stride, void *_dst, unsigned fill_value)
{
uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic */
hsize_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */
hsize_t nelmts; /*number of elements to fill */
hsize_t i; /*counter */
int j; /*counter */
hbool_t carry; /*subtraction carray value */
FUNC_ENTER_NOAPI_NOINIT_NOERR
HDassert(elmt_size < SIZET_MAX);
H5V_vector_cpy(n, idx, size);
nelmts = H5V_vector_reduce_product(n, size);
for (i=0; i<nelmts; i++) {
/* Copy an element */
H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
HDmemset(dst, (int)fill_value, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
/* Decrement indices and advance pointer */
for (j=(int)(n-1), carry=TRUE; j>=0 && carry; --j) {
dst += stride[j];
if (--idx[j])
carry = FALSE;
else {
HDassert(size);
idx[j] = size[j];
} /* end else */
}
}
FUNC_LEAVE_NOAPI(SUCCEED)
}
/*-------------------------------------------------------------------------
* Function: H5V_stride_copy
*
* Purpose: Uses DST_STRIDE and SRC_STRIDE to advance through the arrays
* DST and SRC while copying bytes from SRC to DST. This
* function minimizes the number of calls to memcpy() by
* combining various strides, but it will never touch memory
* outside the hyperslab defined by the strides.
*
* Note: If the src_stride is all zero and elmt_size is one, then it's
* probably more efficient to use H5V_stride_fill() instead.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5V_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size,
const hsize_t *dst_stride, void *_dst,
const hsize_t *src_stride, const void *_src)
{
uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic*/
const uint8_t *src = (const uint8_t*) _src; /*cast for ptr arithmetic*/
hsize_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */
hsize_t nelmts; /*num elements to copy */
hsize_t i; /*counter */
int j; /*counters */
hbool_t carry; /*carray for subtraction*/
FUNC_ENTER_NOAPI_NOINIT_NOERR
HDassert(elmt_size<SIZET_MAX);
if (n) {
H5V_vector_cpy(n, idx, size);
nelmts = H5V_vector_reduce_product(n, size);
for (i=0; i<nelmts; i++) {
/* Copy an element */
H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
HDmemcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
/* Decrement indices and advance pointers */
for (j=(int)(n-1), carry=TRUE; j>=0 && carry; --j) {
src += src_stride[j];
dst += dst_stride[j];
if (--idx[j])
carry = FALSE;
else {
HDassert(size);
idx[j] = size[j];
}
}
}
} else {
H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
HDmemcpy (dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
}
FUNC_LEAVE_NOAPI(SUCCEED)
}
/*-------------------------------------------------------------------------
* Function: H5V_stride_copy_s
*
* Purpose: Uses DST_STRIDE and SRC_STRIDE to advance through the arrays
* DST and SRC while copying bytes from SRC to DST. This
* function minimizes the number of calls to memcpy() by
* combining various strides, but it will never touch memory
* outside the hyperslab defined by the strides.
*
* Note: If the src_stride is all zero and elmt_size is one, then it's
* probably more efficient to use H5V_stride_fill() instead.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5V_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *size,
const hssize_t *dst_stride, void *_dst,
const hssize_t *src_stride, const void *_src)
{
uint8_t *dst = (uint8_t*)_dst; /*cast for ptr arithmetic*/
const uint8_t *src = (const uint8_t*) _src; /*cast for ptr arithmetic*/
hsize_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */
hsize_t nelmts; /*num elements to copy */
hsize_t i; /*counter */
int j; /*counters */
hbool_t carry; /*carray for subtraction*/
FUNC_ENTER_NOAPI_NOINIT_NOERR
HDassert(elmt_size<SIZET_MAX);
if (n) {
H5V_vector_cpy(n, idx, size);
nelmts = H5V_vector_reduce_product(n, size);
for (i=0; i<nelmts; i++) {
/* Copy an element */
H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
HDmemcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
/* Decrement indices and advance pointers */
for (j=(int)(n-1), carry=TRUE; j>=0 && carry; --j) {
src += src_stride[j];
dst += dst_stride[j];
if (--idx[j])
carry = FALSE;
else {
HDassert(size);
idx[j] = size[j];
}
}
}
} else {
H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
HDmemcpy (dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
}
FUNC_LEAVE_NOAPI(SUCCEED)
}
#ifdef LATER
/*-------------------------------------------------------------------------
* Function: H5V_stride_copy2
*
* Purpose: Similar to H5V_stride_copy() except the source and
* destination each have their own dimensionality and size and
* we copy exactly NELMTS elements each of size ELMT_SIZE. The
* size counters wrap if NELMTS is more than a size counter.
*
* Return: None
*
* Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
H5V_stride_copy2(hsize_t nelmts, hsize_t elmt_size,
/* destination */
unsigned dst_n, const hsize_t *dst_size,
const hsize_t *dst_stride,
void *_dst,
/* source */
unsigned src_n, const hsize_t *src_size,
const hsize_t *src_stride,
const void *_src)
{
uint8_t *dst = (uint8_t *) _dst;
const uint8_t *src = (const uint8_t *) _src;
hsize_t dst_idx[H5V_HYPER_NDIMS];
hsize_t src_idx[H5V_HYPER_NDIMS];
hsize_t i; /* Local index variable */
int j; /* Local index variable */
hbool_t carry;
FUNC_ENTER_NOAPI_NOINIT_NOERR
HDassert(elmt_size < SIZET_MAX);
HDassert(dst_n>0);
HDassert(src_n>0);
H5V_vector_cpy(dst_n, dst_idx, dst_size);
H5V_vector_cpy(src_n, src_idx, src_size);
for (i=0; i<nelmts; i++) {
/* Copy an element */
H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
HDmemcpy(dst, src, (size_t)elmt_size); /*lint !e671 The elmt_size will be OK */
/* Decrement indices and advance pointers */
for (j=(int)(dst_n-1), carry=TRUE; j>=0 && carry; --j) {
dst += dst_stride[j];
if (--dst_idx[j])
carry = FALSE;
else {
HDassert(dst_size);
dst_idx[j] = dst_size[j];
} /* end else */
}
for (j=(int)(src_n-1), carry=TRUE; j>=0 && carry; --j) {
src += src_stride[j];
if (--src_idx[j])
carry = FALSE;
else {
HDassert(src_size);
src_idx[j] = src_size[j];
} /* end else */
}
}
FUNC_LEAVE_NOAPI_VOID
}
#endif /* LATER */
/*-------------------------------------------------------------------------
* Function: H5V_array_fill
*
* Purpose: Fills all bytes of an array with the same value using
* memset(). Increases amount copied by power of two until the
* halfway point is crossed, then copies the rest in one swoop.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Thursday, June 18, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5V_array_fill(void *_dst, const void *src, size_t size, size_t count)
{
size_t copy_size; /* size of the buffer to copy */
size_t copy_items; /* number of items currently copying*/
size_t items_left; /* number of items left to copy */
uint8_t *dst=(uint8_t*)_dst;/* alias for pointer arithmetic */
FUNC_ENTER_NOAPI_NOINIT_NOERR
HDassert(dst);
HDassert(src);
HDassert(size < SIZET_MAX && size > 0);
HDassert(count < SIZET_MAX && count > 0);
HDmemcpy(dst, src, size); /* copy first item */
/* Initialize counters, etc. while compensating for first element copied */
copy_size = size;
copy_items = 1;
items_left = count - 1;
dst += size;
/* copy until we've copied at least half of the items */
while (items_left >= copy_items)
{
HDmemcpy(dst, _dst, copy_size); /* copy the current chunk */
dst += copy_size; /* move the offset for the next chunk */
items_left -= copy_items; /* decrement the number of items left */
copy_size *= 2; /* increase the size of the chunk to copy */
copy_items *= 2; /* increase the count of items we are copying */
} /* end while */
if (items_left > 0) /* if there are any items left to copy */
HDmemcpy(dst, _dst, items_left * size);
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5V_array_fill() */
/*-------------------------------------------------------------------------
* Function: H5V_array_down
*
* Purpose: Given a set of dimension sizes, calculate the size of each
* "down" slice. This is the size of the dimensions for all the
* dimensions below the current one, which is used for indexing
* offsets in this dimension.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Monday, April 28, 2003
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5V_array_down(unsigned n, const hsize_t *total_size, hsize_t *down)
{
hsize_t acc; /*accumulator */
int i; /*counter */
FUNC_ENTER_NOAPI_NOINIT_NOERR
HDassert(n <= H5V_HYPER_NDIMS);
HDassert(total_size);
HDassert(down);
/* Build the sizes of each dimension in the array */
/* (From fastest to slowest) */
for(i=(int)(n-1),acc=1; i>=0; i--) {
down[i]=acc;
acc *= total_size[i];
} /* end for */
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5V_array_down() */
/*-------------------------------------------------------------------------
* Function: H5V_array_offset_pre
*
* Purpose: Given a coordinate description of a location in an array, this
* function returns the byte offset of the coordinate.
*
* The dimensionality of the whole array, and the offset is N.
* The whole array dimensions are TOTAL_SIZE and the coordinate
* is at offset OFFSET.
*
* Return: Success: Byte offset from beginning of array to element offset
* Failure: abort() -- should never fail
*
* Programmer: Quincey Koziol
* Tuesday, June 22, 1999
*
* Modifications:
* Use precomputed accumulator array
* Quincey Koziol
* Saturday, April 26, 2003
*
*-------------------------------------------------------------------------
*/
hsize_t
H5V_array_offset_pre(unsigned n, const hsize_t *acc, const hsize_t *offset)
{
int i; /*counter */
hsize_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT_NOERR
HDassert(n <= H5V_HYPER_NDIMS);
HDassert(acc);
HDassert(offset);
/* Compute offset in array */
for (i=(int)(n-1), ret_value=0; i>=0; --i)
ret_value += acc[i] * offset[i];
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5V_array_offset_pre() */
/*-------------------------------------------------------------------------
* Function: H5V_array_offset
*
* Purpose: Given a coordinate description of a location in an array, this
* function returns the byte offset of the coordinate.
*
* The dimensionality of the whole array, and the offset is N.
* The whole array dimensions are TOTAL_SIZE and the coordinate
* is at offset OFFSET.
*
* Return: Success: Byte offset from beginning of array to element offset
* Failure: abort() -- should never fail
*
* Programmer: Quincey Koziol
* Tuesday, June 22, 1999
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
hsize_t
H5V_array_offset(unsigned n, const hsize_t *total_size, const hsize_t *offset)
{
hsize_t acc_arr[H5V_HYPER_NDIMS]; /* Accumulated size of down dimensions */
hsize_t ret_value; /* Return value */
FUNC_ENTER_NOAPI((HDabort(), 0)) /*lint !e527 Don't worry about unreachable statement */
HDassert(n <= H5V_HYPER_NDIMS);
HDassert(total_size);
HDassert(offset);
/* Build the sizes of each dimension in the array */
if(H5V_array_down(n,total_size,acc_arr)<0)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, UFAIL, "can't compute down sizes")
/* Set return value */
ret_value=H5V_array_offset_pre(n,acc_arr,offset);
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5V_array_offset() */
/*-------------------------------------------------------------------------
* Function: H5V_array_calc_pre
*
* Purpose: Given a linear offset in an array, the dimensions of that
* array and the pre-computed 'down' (accumulator) sizes, this
* function computes the coordinates of that offset in the array.
*
* The dimensionality of the whole array, and the coordinates is N.
* The array dimensions are TOTAL_SIZE and the coordinates
* are returned in COORD. The linear offset is in OFFSET.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Thursday, July 16, 2009
*
*-------------------------------------------------------------------------
*/
static herr_t
H5V_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *down,
hsize_t *coords)
{
unsigned u; /* Local index variable */
FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Sanity check */
HDassert(n <= H5V_HYPER_NDIMS);
HDassert(coords);
/* Compute the coordinates from the offset */
for(u = 0; u < n; u++) {
coords[u] = offset / down[u];
offset %= down[u];
} /* end for */
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5V_array_calc_pre() */
/*-------------------------------------------------------------------------
* Function: H5V_array_calc
*
* Purpose: Given a linear offset in an array and the dimensions of that
* array, this function computes the coordinates of that offset
* in the array.
*
* The dimensionality of the whole array, and the coordinates is N.
* The array dimensions are TOTAL_SIZE and the coordinates
* are returned in COORD. The linear offset is in OFFSET.
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Wednesday, April 16, 2003
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5V_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hsize_t *coords)
{
hsize_t idx[H5V_HYPER_NDIMS]; /* Size of each dimension in bytes */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Sanity check */
HDassert(n <= H5V_HYPER_NDIMS);
HDassert(total_size);
HDassert(coords);
/* Build the sizes of each dimension in the array */
if(H5V_array_down(n, total_size, idx) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute down sizes")
/* Compute the coordinates from the offset */
if(H5V_array_calc_pre(offset, n, idx, coords) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute coordinates")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5V_array_calc() */
/*-------------------------------------------------------------------------
* Function: H5V_chunk_index
*
* Purpose: Given a coordinate offset (COORD), the size of each chunk
* (CHUNK), the number of chunks in each dimension (NCHUNKS)
* and the number of dimensions of all of these (NDIMS), calculate
* a "chunk index" for the chunk that the coordinate offset is
* located in.
*
* The chunk index starts at 0 and increases according to the
* fastest changing dimension, then the next fastest, etc.
*
* For example, with a 3x5 chunk size and 6 chunks in the fastest
* changing dimension and 3 chunks in the slowest changing
* dimension, the chunk indices are as follows:
*
* +-----+-----+-----+-----+-----+-----+
* | | | | | | |
* | 0 | 1 | 2 | 3 | 4 | 5 |
* | | | | | | |
* +-----+-----+-----+-----+-----+-----+
* | | | | | | |
* | 6 | 7 | 8 | 9 | 10 | 11 |
* | | | | | | |
* +-----+-----+-----+-----+-----+-----+
* | | | | | | |
* | 12 | 13 | 14 | 15 | 16 | 17 |
* | | | | | | |
* +-----+-----+-----+-----+-----+-----+
*
* The chunk index is placed in the CHUNK_IDX location for return
* from this function
*
* Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Monday, April 21, 2003
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
H5V_chunk_index(unsigned ndims, const hsize_t *coord, const uint32_t *chunk,
const hsize_t *down_nchunks, hsize_t *chunk_idx)
{
hsize_t scaled_coord[H5V_HYPER_NDIMS]; /* Scaled, coordinates, in terms of chunks */
unsigned u; /* Local index variable */
FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Sanity check */
HDassert(ndims <= H5V_HYPER_NDIMS);
HDassert(coord);
HDassert(chunk);
HDassert(chunk_idx);
/* Compute the scaled coordinates for actual coordinates */
for(u=0; u<ndims; u++)
scaled_coord[u]=coord[u]/chunk[u];
/* Compute the chunk index */
*chunk_idx=H5V_array_offset_pre(ndims,down_nchunks,scaled_coord); /*lint !e772 scaled_coord will always be initialized */
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5V_chunk_index() */
/*-------------------------------------------------------------------------
* Function: H5V_opvv
*
* Purpose: Perform an operation on a source & destination sequences
* of offset/length pairs. Each set of sequnces has an array
* of lengths, an array of offsets, the maximum number of
* sequences and the current sequence to start at in the sequence.
*
* There may be different numbers of bytes in the source and
* destination sequences, the operation stops when either the
* source or destination sequence runs out of information.
*
* Note: The algorithm in this routine is [basically] the same as for
* H5V_memcpyvv(). Changes should be made to both!
*
* Return: Non-negative # of bytes operated on, on success/Negative on failure
*
* Programmer: Quincey Koziol
* Thursday, September 30, 2010
*
*-------------------------------------------------------------------------
*/
ssize_t
H5V_opvv(size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[],
hsize_t dst_off_arr[],
size_t src_max_nseq, size_t *src_curr_seq, size_t src_len_arr[],
hsize_t src_off_arr[],
H5V_opvv_func_t op, void *op_data)
{
hsize_t *max_dst_off_ptr, *max_src_off_ptr; /* Pointers to max. source and destination offset locations */
hsize_t *dst_off_ptr, *src_off_ptr; /* Pointers to source and destination offset arrays */
size_t *dst_len_ptr, *src_len_ptr; /* Pointers to source and destination length arrays */
hsize_t tmp_dst_off, tmp_src_off; /* Temporary source and destination offset values */
size_t tmp_dst_len, tmp_src_len; /* Temporary source and destination length values */
size_t acc_len; /* Accumulated length of sequences */
ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */
FUNC_ENTER_NOAPI(FAIL)
/* Sanity check */
HDassert(dst_curr_seq);
HDassert(*dst_curr_seq < dst_max_nseq);
HDassert(dst_len_arr);
HDassert(dst_off_arr);
HDassert(src_curr_seq);
HDassert(*src_curr_seq < src_max_nseq);
HDassert(src_len_arr);
HDassert(src_off_arr);
HDassert(op);
/* Set initial offset & length pointers */
dst_len_ptr = dst_len_arr + *dst_curr_seq;
dst_off_ptr = dst_off_arr + *dst_curr_seq;
src_len_ptr = src_len_arr + *src_curr_seq;
src_off_ptr = src_off_arr + *src_curr_seq;
/* Get temporary source & destination sequence offsets & lengths */
tmp_dst_len = *dst_len_ptr;
tmp_dst_off = *dst_off_ptr;
tmp_src_len = *src_len_ptr;
tmp_src_off = *src_off_ptr;
/* Compute maximum offset pointer values */
max_dst_off_ptr = dst_off_arr + dst_max_nseq;
max_src_off_ptr = src_off_arr + src_max_nseq;
/* Work through the sequences */
/* (Choose smallest sequence available initially) */
/* Source sequence is less than destination sequence */
if(tmp_src_len < tmp_dst_len) {
src_smaller:
acc_len = 0;
do {
/* Make operator callback */
if((*op)(tmp_dst_off, tmp_src_off, tmp_src_len, op_data) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTOPERATE, FAIL, "can't perform operation")
/* Accumulate number of bytes copied */
acc_len += tmp_src_len;
/* Update destination length */
tmp_dst_off += tmp_src_len;
tmp_dst_len -= tmp_src_len;
/* Advance source offset & check for being finished */
src_off_ptr++;
if(src_off_ptr >= max_src_off_ptr) {
/* Roll accumulated changes into appropriate counters */
*dst_off_ptr = tmp_dst_off;
*dst_len_ptr = tmp_dst_len;
/* Done with sequences */
goto finished;
} /* end if */
tmp_src_off = *src_off_ptr;
/* Update source information */
src_len_ptr++;
tmp_src_len = *src_len_ptr;
} while(tmp_src_len < tmp_dst_len);
/* Roll accumulated sequence lengths into return value */
ret_value += (ssize_t)acc_len;
/* Transition to next state */
if(tmp_dst_len < tmp_src_len)
goto dst_smaller;
else
goto equal;
} /* end if */
/* Destination sequence is less than source sequence */
else if(tmp_dst_len < tmp_src_len) {
dst_smaller:
acc_len = 0;
do {
/* Make operator callback */
if((*op)(tmp_dst_off, tmp_src_off, tmp_dst_len, op_data) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTOPERATE, FAIL, "can't perform operation")
/* Accumulate number of bytes copied */
acc_len += tmp_dst_len;
/* Update source length */
tmp_src_off += tmp_dst_len;
tmp_src_len -= tmp_dst_len;
/* Advance destination offset & check for being finished */
dst_off_ptr++;
if(dst_off_ptr >= max_dst_off_ptr) {
/* Roll accumulated changes into appropriate counters */
*src_off_ptr = tmp_src_off;
*src_len_ptr = tmp_src_len;
/* Done with sequences */
goto finished;
} /* end if */
tmp_dst_off = *dst_off_ptr;
/* Update destination information */
dst_len_ptr++;
tmp_dst_len = *dst_len_ptr;
} while(tmp_dst_len < tmp_src_len);
/* Roll accumulated sequence lengths into return value */
ret_value += (ssize_t)acc_len;
/* Transition to next state */
if(tmp_src_len < tmp_dst_len)
goto src_smaller;
else
goto equal;
} /* end else-if */
/* Destination sequence and source sequence are same length */
else {
equal:
acc_len = 0;
do {
/* Make operator callback */
if((*op)(tmp_dst_off, tmp_src_off, tmp_dst_len, op_data) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTOPERATE, FAIL, "can't perform operation")
/* Accumulate number of bytes copied */
acc_len += tmp_dst_len;
/* Advance source & destination offset & check for being finished */
src_off_ptr++;
dst_off_ptr++;
if(src_off_ptr >= max_src_off_ptr || dst_off_ptr >= max_dst_off_ptr)
/* Done with sequences */
goto finished;
tmp_src_off = *src_off_ptr;
tmp_dst_off = *dst_off_ptr;
/* Update source information */
src_len_ptr++;
tmp_src_len = *src_len_ptr;
/* Update destination information */
dst_len_ptr++;
tmp_dst_len = *dst_len_ptr;
} while(tmp_dst_len == tmp_src_len);
/* Roll accumulated sequence lengths into return value */
ret_value += (ssize_t)acc_len;
/* Transition to next state */
if(tmp_dst_len < tmp_src_len)
goto dst_smaller;
else
goto src_smaller;
} /* end else */
finished:
/* Roll accumulated sequence lengths into return value */
ret_value += (ssize_t)acc_len;
/* Update current sequence vectors */
*dst_curr_seq = (size_t)(dst_off_ptr - dst_off_arr);
*src_curr_seq = (size_t)(src_off_ptr - src_off_arr);
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5V_opvv() */
/*-------------------------------------------------------------------------
* Function: H5V_memcpyvv
*
* Purpose: Given source and destination buffers in memory (SRC & DST)
* copy sequences of from the source buffer into the destination
* buffer. Each set of sequnces has an array of lengths, an
* array of offsets, the maximum number of sequences and the
* current sequence to start at in the sequence.
*
* There may be different numbers of bytes in the source and
* destination sequences, data copying stops when either the
* source or destination buffer runs out of sequence information.
*
* Note: The algorithm in this routine is [basically] the same as for
* H5V_opvv(). Changes should be made to both!
*
* Return: Non-negative # of bytes copied on success/Negative on failure
*
* Programmer: Quincey Koziol
* Friday, May 2, 2003
*
*-------------------------------------------------------------------------
*/
ssize_t
H5V_memcpyvv(void *_dst,
size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], hsize_t dst_off_arr[],
const void *_src,
size_t src_max_nseq, size_t *src_curr_seq, size_t src_len_arr[], hsize_t src_off_arr[])
{
unsigned char *dst; /* Destination buffer pointer */
const unsigned char *src; /* Source buffer pointer */
hsize_t *max_dst_off_ptr, *max_src_off_ptr; /* Pointers to max. source and destination offset locations */
hsize_t *dst_off_ptr, *src_off_ptr; /* Pointers to source and destination offset arrays */
size_t *dst_len_ptr, *src_len_ptr; /* Pointers to source and destination length arrays */
size_t tmp_dst_len; /* Temporary dest. length value */
size_t tmp_src_len; /* Temporary source length value */
size_t acc_len; /* Accumulated length of sequences */
ssize_t ret_value = 0; /* Return value (Total size of sequence in bytes) */
FUNC_ENTER_NOAPI_NOINIT_NOERR
/* Sanity check */
HDassert(_dst);
HDassert(dst_curr_seq);
HDassert(*dst_curr_seq < dst_max_nseq);
HDassert(dst_len_arr);
HDassert(dst_off_arr);
HDassert(_src);
HDassert(src_curr_seq);
HDassert(*src_curr_seq < src_max_nseq);
HDassert(src_len_arr);
HDassert(src_off_arr);
/* Set initial offset & length pointers */
dst_len_ptr = dst_len_arr + *dst_curr_seq;
dst_off_ptr = dst_off_arr + *dst_curr_seq;
src_len_ptr = src_len_arr + *src_curr_seq;
src_off_ptr = src_off_arr + *src_curr_seq;
/* Get temporary source & destination sequence lengths */
tmp_dst_len = *dst_len_ptr;
tmp_src_len = *src_len_ptr;
/* Compute maximum offset pointer values */
max_dst_off_ptr = dst_off_arr + dst_max_nseq;
max_src_off_ptr = src_off_arr + src_max_nseq;
/* Compute buffer offsets */
dst = (unsigned char *)_dst + *dst_off_ptr;
src = (const unsigned char *)_src + *src_off_ptr;
/* Work through the sequences */
/* (Choose smallest sequence available initially) */
/* Source sequence is less than destination sequence */
if(tmp_src_len < tmp_dst_len) {
src_smaller:
acc_len = 0;
do {
/* Copy data */
HDmemcpy(dst, src, tmp_src_len);
/* Accumulate number of bytes copied */
acc_len += tmp_src_len;
/* Update destination length */
tmp_dst_len -= tmp_src_len;
/* Advance source offset & check for being finished */
src_off_ptr++;
if(src_off_ptr >= max_src_off_ptr) {
/* Roll accumulated changes into appropriate counters */
*dst_off_ptr += acc_len;
*dst_len_ptr = tmp_dst_len;
/* Done with sequences */
goto finished;
} /* end if */
/* Update destination pointer */
dst += tmp_src_len;
/* Update source information */
src_len_ptr++;
tmp_src_len = *src_len_ptr;
src = (const unsigned char *)_src + *src_off_ptr;
} while(tmp_src_len < tmp_dst_len);
/* Roll accumulated sequence lengths into return value */
ret_value += (ssize_t)acc_len;
/* Transition to next state */
if(tmp_dst_len < tmp_src_len)
goto dst_smaller;
else
goto equal;
} /* end if */
/* Destination sequence is less than source sequence */
else if(tmp_dst_len < tmp_src_len) {
dst_smaller:
acc_len = 0;
do {
/* Copy data */
HDmemcpy(dst, src, tmp_dst_len);
/* Accumulate number of bytes copied */
acc_len += tmp_dst_len;
/* Update source length */
tmp_src_len -= tmp_dst_len;
/* Advance destination offset & check for being finished */
dst_off_ptr++;
if(dst_off_ptr >= max_dst_off_ptr) {
/* Roll accumulated changes into appropriate counters */
*src_off_ptr += acc_len;
*src_len_ptr = tmp_src_len;
/* Done with sequences */
goto finished;
} /* end if */
/* Update source pointer */
src += tmp_dst_len;
/* Update destination information */
dst_len_ptr++;
tmp_dst_len = *dst_len_ptr;
dst = (unsigned char *)_dst + *dst_off_ptr;
} while(tmp_dst_len < tmp_src_len);
/* Roll accumulated sequence lengths into return value */
ret_value += (ssize_t)acc_len;
/* Transition to next state */
if(tmp_src_len < tmp_dst_len)
goto src_smaller;
else
goto equal;
} /* end else-if */
/* Destination sequence and source sequence are same length */
else {
equal:
acc_len = 0;
do {
/* Copy data */
HDmemcpy(dst, src, tmp_dst_len);
/* Accumulate number of bytes copied */
acc_len += tmp_dst_len;
/* Advance source & destination offset & check for being finished */
src_off_ptr++;
dst_off_ptr++;
if(src_off_ptr >= max_src_off_ptr || dst_off_ptr >= max_dst_off_ptr)
/* Done with sequences */
goto finished;
/* Update source information */
src_len_ptr++;
tmp_src_len = *src_len_ptr;
src = (const unsigned char *)_src + *src_off_ptr;
/* Update destination information */
dst_len_ptr++;
tmp_dst_len = *dst_len_ptr;
dst = (unsigned char *)_dst + *dst_off_ptr;
} while(tmp_dst_len == tmp_src_len);
/* Roll accumulated sequence lengths into return value */
ret_value += (ssize_t)acc_len;
/* Transition to next state */
if(tmp_dst_len < tmp_src_len)
goto dst_smaller;
else
goto src_smaller;
} /* end else */
finished:
/* Roll accumulated sequence lengths into return value */
ret_value += (ssize_t)acc_len;
/* Update current sequence vectors */
*dst_curr_seq = (size_t)(dst_off_ptr - dst_off_arr);
*src_curr_seq = (size_t)(src_off_ptr - src_off_arr);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5V_memcpyvv() */
| 34.357852 | 125 | 0.55528 |
d03f98c336be7452f6ae4e94b3e9eb0d58e4b106 | 36,093 | c | C | sys/platform/pc32/apic/ioapic_abi.c | cooljeanius/DragonFlyBSD | 4c4e823ecc4019d4536be9493e38fef118f9a8cf | [
"BSD-3-Clause"
] | 1 | 2015-02-18T22:03:27.000Z | 2015-02-18T22:03:27.000Z | sys/platform/pc32/apic/ioapic_abi.c | cooljeanius/DragonFlyBSD | 4c4e823ecc4019d4536be9493e38fef118f9a8cf | [
"BSD-3-Clause"
] | null | null | null | sys/platform/pc32/apic/ioapic_abi.c | cooljeanius/DragonFlyBSD | 4c4e823ecc4019d4536be9493e38fef118f9a8cf | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright (c) 2005 The DragonFly Project. All rights reserved.
* Copyright (c) 1996, by Steve Passe. All rights reserved.
* Copyright (c) 1991 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to The DragonFly Project
* by Matthew Dillon <dillon@backplane.com>
*
* This code is derived from software contributed to Berkeley by
* William Jolitz.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of The DragonFly Project nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific, prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/machintr.h>
#include <sys/interrupt.h>
#include <sys/bus.h>
#include <sys/rman.h>
#include <sys/thread2.h>
#include <machine/smp.h>
#include <machine/segments.h>
#include <machine/md_var.h>
#include <machine/intr_machdep.h>
#include <machine/globaldata.h>
#include <machine/msi_var.h>
#include <machine_base/isa/isa_intr.h>
#include <machine_base/icu/icu.h>
#include <machine_base/icu/icu_var.h>
#include <machine_base/apic/ioapic.h>
#include <machine_base/apic/ioapic_abi.h>
#include <machine_base/apic/ioapic_ipl.h>
#include <machine_base/apic/apicreg.h>
#include <dev/acpica/acpi_sci_var.h>
#define IOAPIC_HWI_VECTORS IDT_HWI_VECTORS
extern inthand_t
IDTVEC(ioapic_intr0),
IDTVEC(ioapic_intr1),
IDTVEC(ioapic_intr2),
IDTVEC(ioapic_intr3),
IDTVEC(ioapic_intr4),
IDTVEC(ioapic_intr5),
IDTVEC(ioapic_intr6),
IDTVEC(ioapic_intr7),
IDTVEC(ioapic_intr8),
IDTVEC(ioapic_intr9),
IDTVEC(ioapic_intr10),
IDTVEC(ioapic_intr11),
IDTVEC(ioapic_intr12),
IDTVEC(ioapic_intr13),
IDTVEC(ioapic_intr14),
IDTVEC(ioapic_intr15),
IDTVEC(ioapic_intr16),
IDTVEC(ioapic_intr17),
IDTVEC(ioapic_intr18),
IDTVEC(ioapic_intr19),
IDTVEC(ioapic_intr20),
IDTVEC(ioapic_intr21),
IDTVEC(ioapic_intr22),
IDTVEC(ioapic_intr23),
IDTVEC(ioapic_intr24),
IDTVEC(ioapic_intr25),
IDTVEC(ioapic_intr26),
IDTVEC(ioapic_intr27),
IDTVEC(ioapic_intr28),
IDTVEC(ioapic_intr29),
IDTVEC(ioapic_intr30),
IDTVEC(ioapic_intr31),
IDTVEC(ioapic_intr32),
IDTVEC(ioapic_intr33),
IDTVEC(ioapic_intr34),
IDTVEC(ioapic_intr35),
IDTVEC(ioapic_intr36),
IDTVEC(ioapic_intr37),
IDTVEC(ioapic_intr38),
IDTVEC(ioapic_intr39),
IDTVEC(ioapic_intr40),
IDTVEC(ioapic_intr41),
IDTVEC(ioapic_intr42),
IDTVEC(ioapic_intr43),
IDTVEC(ioapic_intr44),
IDTVEC(ioapic_intr45),
IDTVEC(ioapic_intr46),
IDTVEC(ioapic_intr47),
IDTVEC(ioapic_intr48),
IDTVEC(ioapic_intr49),
IDTVEC(ioapic_intr50),
IDTVEC(ioapic_intr51),
IDTVEC(ioapic_intr52),
IDTVEC(ioapic_intr53),
IDTVEC(ioapic_intr54),
IDTVEC(ioapic_intr55),
IDTVEC(ioapic_intr56),
IDTVEC(ioapic_intr57),
IDTVEC(ioapic_intr58),
IDTVEC(ioapic_intr59),
IDTVEC(ioapic_intr60),
IDTVEC(ioapic_intr61),
IDTVEC(ioapic_intr62),
IDTVEC(ioapic_intr63),
IDTVEC(ioapic_intr64),
IDTVEC(ioapic_intr65),
IDTVEC(ioapic_intr66),
IDTVEC(ioapic_intr67),
IDTVEC(ioapic_intr68),
IDTVEC(ioapic_intr69),
IDTVEC(ioapic_intr70),
IDTVEC(ioapic_intr71),
IDTVEC(ioapic_intr72),
IDTVEC(ioapic_intr73),
IDTVEC(ioapic_intr74),
IDTVEC(ioapic_intr75),
IDTVEC(ioapic_intr76),
IDTVEC(ioapic_intr77),
IDTVEC(ioapic_intr78),
IDTVEC(ioapic_intr79),
IDTVEC(ioapic_intr80),
IDTVEC(ioapic_intr81),
IDTVEC(ioapic_intr82),
IDTVEC(ioapic_intr83),
IDTVEC(ioapic_intr84),
IDTVEC(ioapic_intr85),
IDTVEC(ioapic_intr86),
IDTVEC(ioapic_intr87),
IDTVEC(ioapic_intr88),
IDTVEC(ioapic_intr89),
IDTVEC(ioapic_intr90),
IDTVEC(ioapic_intr91),
IDTVEC(ioapic_intr92),
IDTVEC(ioapic_intr93),
IDTVEC(ioapic_intr94),
IDTVEC(ioapic_intr95),
IDTVEC(ioapic_intr96),
IDTVEC(ioapic_intr97),
IDTVEC(ioapic_intr98),
IDTVEC(ioapic_intr99),
IDTVEC(ioapic_intr100),
IDTVEC(ioapic_intr101),
IDTVEC(ioapic_intr102),
IDTVEC(ioapic_intr103),
IDTVEC(ioapic_intr104),
IDTVEC(ioapic_intr105),
IDTVEC(ioapic_intr106),
IDTVEC(ioapic_intr107),
IDTVEC(ioapic_intr108),
IDTVEC(ioapic_intr109),
IDTVEC(ioapic_intr110),
IDTVEC(ioapic_intr111),
IDTVEC(ioapic_intr112),
IDTVEC(ioapic_intr113),
IDTVEC(ioapic_intr114),
IDTVEC(ioapic_intr115),
IDTVEC(ioapic_intr116),
IDTVEC(ioapic_intr117),
IDTVEC(ioapic_intr118),
IDTVEC(ioapic_intr119),
IDTVEC(ioapic_intr120),
IDTVEC(ioapic_intr121),
IDTVEC(ioapic_intr122),
IDTVEC(ioapic_intr123),
IDTVEC(ioapic_intr124),
IDTVEC(ioapic_intr125),
IDTVEC(ioapic_intr126),
IDTVEC(ioapic_intr127),
IDTVEC(ioapic_intr128),
IDTVEC(ioapic_intr129),
IDTVEC(ioapic_intr130),
IDTVEC(ioapic_intr131),
IDTVEC(ioapic_intr132),
IDTVEC(ioapic_intr133),
IDTVEC(ioapic_intr134),
IDTVEC(ioapic_intr135),
IDTVEC(ioapic_intr136),
IDTVEC(ioapic_intr137),
IDTVEC(ioapic_intr138),
IDTVEC(ioapic_intr139),
IDTVEC(ioapic_intr140),
IDTVEC(ioapic_intr141),
IDTVEC(ioapic_intr142),
IDTVEC(ioapic_intr143),
IDTVEC(ioapic_intr144),
IDTVEC(ioapic_intr145),
IDTVEC(ioapic_intr146),
IDTVEC(ioapic_intr147),
IDTVEC(ioapic_intr148),
IDTVEC(ioapic_intr149),
IDTVEC(ioapic_intr150),
IDTVEC(ioapic_intr151),
IDTVEC(ioapic_intr152),
IDTVEC(ioapic_intr153),
IDTVEC(ioapic_intr154),
IDTVEC(ioapic_intr155),
IDTVEC(ioapic_intr156),
IDTVEC(ioapic_intr157),
IDTVEC(ioapic_intr158),
IDTVEC(ioapic_intr159),
IDTVEC(ioapic_intr160),
IDTVEC(ioapic_intr161),
IDTVEC(ioapic_intr162),
IDTVEC(ioapic_intr163),
IDTVEC(ioapic_intr164),
IDTVEC(ioapic_intr165),
IDTVEC(ioapic_intr166),
IDTVEC(ioapic_intr167),
IDTVEC(ioapic_intr168),
IDTVEC(ioapic_intr169),
IDTVEC(ioapic_intr170),
IDTVEC(ioapic_intr171),
IDTVEC(ioapic_intr172),
IDTVEC(ioapic_intr173),
IDTVEC(ioapic_intr174),
IDTVEC(ioapic_intr175),
IDTVEC(ioapic_intr176),
IDTVEC(ioapic_intr177),
IDTVEC(ioapic_intr178),
IDTVEC(ioapic_intr179),
IDTVEC(ioapic_intr180),
IDTVEC(ioapic_intr181),
IDTVEC(ioapic_intr182),
IDTVEC(ioapic_intr183),
IDTVEC(ioapic_intr184),
IDTVEC(ioapic_intr185),
IDTVEC(ioapic_intr186),
IDTVEC(ioapic_intr187),
IDTVEC(ioapic_intr188),
IDTVEC(ioapic_intr189),
IDTVEC(ioapic_intr190),
IDTVEC(ioapic_intr191);
static inthand_t *ioapic_intr[IOAPIC_HWI_VECTORS] = {
&IDTVEC(ioapic_intr0),
&IDTVEC(ioapic_intr1),
&IDTVEC(ioapic_intr2),
&IDTVEC(ioapic_intr3),
&IDTVEC(ioapic_intr4),
&IDTVEC(ioapic_intr5),
&IDTVEC(ioapic_intr6),
&IDTVEC(ioapic_intr7),
&IDTVEC(ioapic_intr8),
&IDTVEC(ioapic_intr9),
&IDTVEC(ioapic_intr10),
&IDTVEC(ioapic_intr11),
&IDTVEC(ioapic_intr12),
&IDTVEC(ioapic_intr13),
&IDTVEC(ioapic_intr14),
&IDTVEC(ioapic_intr15),
&IDTVEC(ioapic_intr16),
&IDTVEC(ioapic_intr17),
&IDTVEC(ioapic_intr18),
&IDTVEC(ioapic_intr19),
&IDTVEC(ioapic_intr20),
&IDTVEC(ioapic_intr21),
&IDTVEC(ioapic_intr22),
&IDTVEC(ioapic_intr23),
&IDTVEC(ioapic_intr24),
&IDTVEC(ioapic_intr25),
&IDTVEC(ioapic_intr26),
&IDTVEC(ioapic_intr27),
&IDTVEC(ioapic_intr28),
&IDTVEC(ioapic_intr29),
&IDTVEC(ioapic_intr30),
&IDTVEC(ioapic_intr31),
&IDTVEC(ioapic_intr32),
&IDTVEC(ioapic_intr33),
&IDTVEC(ioapic_intr34),
&IDTVEC(ioapic_intr35),
&IDTVEC(ioapic_intr36),
&IDTVEC(ioapic_intr37),
&IDTVEC(ioapic_intr38),
&IDTVEC(ioapic_intr39),
&IDTVEC(ioapic_intr40),
&IDTVEC(ioapic_intr41),
&IDTVEC(ioapic_intr42),
&IDTVEC(ioapic_intr43),
&IDTVEC(ioapic_intr44),
&IDTVEC(ioapic_intr45),
&IDTVEC(ioapic_intr46),
&IDTVEC(ioapic_intr47),
&IDTVEC(ioapic_intr48),
&IDTVEC(ioapic_intr49),
&IDTVEC(ioapic_intr50),
&IDTVEC(ioapic_intr51),
&IDTVEC(ioapic_intr52),
&IDTVEC(ioapic_intr53),
&IDTVEC(ioapic_intr54),
&IDTVEC(ioapic_intr55),
&IDTVEC(ioapic_intr56),
&IDTVEC(ioapic_intr57),
&IDTVEC(ioapic_intr58),
&IDTVEC(ioapic_intr59),
&IDTVEC(ioapic_intr60),
&IDTVEC(ioapic_intr61),
&IDTVEC(ioapic_intr62),
&IDTVEC(ioapic_intr63),
&IDTVEC(ioapic_intr64),
&IDTVEC(ioapic_intr65),
&IDTVEC(ioapic_intr66),
&IDTVEC(ioapic_intr67),
&IDTVEC(ioapic_intr68),
&IDTVEC(ioapic_intr69),
&IDTVEC(ioapic_intr70),
&IDTVEC(ioapic_intr71),
&IDTVEC(ioapic_intr72),
&IDTVEC(ioapic_intr73),
&IDTVEC(ioapic_intr74),
&IDTVEC(ioapic_intr75),
&IDTVEC(ioapic_intr76),
&IDTVEC(ioapic_intr77),
&IDTVEC(ioapic_intr78),
&IDTVEC(ioapic_intr79),
&IDTVEC(ioapic_intr80),
&IDTVEC(ioapic_intr81),
&IDTVEC(ioapic_intr82),
&IDTVEC(ioapic_intr83),
&IDTVEC(ioapic_intr84),
&IDTVEC(ioapic_intr85),
&IDTVEC(ioapic_intr86),
&IDTVEC(ioapic_intr87),
&IDTVEC(ioapic_intr88),
&IDTVEC(ioapic_intr89),
&IDTVEC(ioapic_intr90),
&IDTVEC(ioapic_intr91),
&IDTVEC(ioapic_intr92),
&IDTVEC(ioapic_intr93),
&IDTVEC(ioapic_intr94),
&IDTVEC(ioapic_intr95),
&IDTVEC(ioapic_intr96),
&IDTVEC(ioapic_intr97),
&IDTVEC(ioapic_intr98),
&IDTVEC(ioapic_intr99),
&IDTVEC(ioapic_intr100),
&IDTVEC(ioapic_intr101),
&IDTVEC(ioapic_intr102),
&IDTVEC(ioapic_intr103),
&IDTVEC(ioapic_intr104),
&IDTVEC(ioapic_intr105),
&IDTVEC(ioapic_intr106),
&IDTVEC(ioapic_intr107),
&IDTVEC(ioapic_intr108),
&IDTVEC(ioapic_intr109),
&IDTVEC(ioapic_intr110),
&IDTVEC(ioapic_intr111),
&IDTVEC(ioapic_intr112),
&IDTVEC(ioapic_intr113),
&IDTVEC(ioapic_intr114),
&IDTVEC(ioapic_intr115),
&IDTVEC(ioapic_intr116),
&IDTVEC(ioapic_intr117),
&IDTVEC(ioapic_intr118),
&IDTVEC(ioapic_intr119),
&IDTVEC(ioapic_intr120),
&IDTVEC(ioapic_intr121),
&IDTVEC(ioapic_intr122),
&IDTVEC(ioapic_intr123),
&IDTVEC(ioapic_intr124),
&IDTVEC(ioapic_intr125),
&IDTVEC(ioapic_intr126),
&IDTVEC(ioapic_intr127),
&IDTVEC(ioapic_intr128),
&IDTVEC(ioapic_intr129),
&IDTVEC(ioapic_intr130),
&IDTVEC(ioapic_intr131),
&IDTVEC(ioapic_intr132),
&IDTVEC(ioapic_intr133),
&IDTVEC(ioapic_intr134),
&IDTVEC(ioapic_intr135),
&IDTVEC(ioapic_intr136),
&IDTVEC(ioapic_intr137),
&IDTVEC(ioapic_intr138),
&IDTVEC(ioapic_intr139),
&IDTVEC(ioapic_intr140),
&IDTVEC(ioapic_intr141),
&IDTVEC(ioapic_intr142),
&IDTVEC(ioapic_intr143),
&IDTVEC(ioapic_intr144),
&IDTVEC(ioapic_intr145),
&IDTVEC(ioapic_intr146),
&IDTVEC(ioapic_intr147),
&IDTVEC(ioapic_intr148),
&IDTVEC(ioapic_intr149),
&IDTVEC(ioapic_intr150),
&IDTVEC(ioapic_intr151),
&IDTVEC(ioapic_intr152),
&IDTVEC(ioapic_intr153),
&IDTVEC(ioapic_intr154),
&IDTVEC(ioapic_intr155),
&IDTVEC(ioapic_intr156),
&IDTVEC(ioapic_intr157),
&IDTVEC(ioapic_intr158),
&IDTVEC(ioapic_intr159),
&IDTVEC(ioapic_intr160),
&IDTVEC(ioapic_intr161),
&IDTVEC(ioapic_intr162),
&IDTVEC(ioapic_intr163),
&IDTVEC(ioapic_intr164),
&IDTVEC(ioapic_intr165),
&IDTVEC(ioapic_intr166),
&IDTVEC(ioapic_intr167),
&IDTVEC(ioapic_intr168),
&IDTVEC(ioapic_intr169),
&IDTVEC(ioapic_intr170),
&IDTVEC(ioapic_intr171),
&IDTVEC(ioapic_intr172),
&IDTVEC(ioapic_intr173),
&IDTVEC(ioapic_intr174),
&IDTVEC(ioapic_intr175),
&IDTVEC(ioapic_intr176),
&IDTVEC(ioapic_intr177),
&IDTVEC(ioapic_intr178),
&IDTVEC(ioapic_intr179),
&IDTVEC(ioapic_intr180),
&IDTVEC(ioapic_intr181),
&IDTVEC(ioapic_intr182),
&IDTVEC(ioapic_intr183),
&IDTVEC(ioapic_intr184),
&IDTVEC(ioapic_intr185),
&IDTVEC(ioapic_intr186),
&IDTVEC(ioapic_intr187),
&IDTVEC(ioapic_intr188),
&IDTVEC(ioapic_intr189),
&IDTVEC(ioapic_intr190),
&IDTVEC(ioapic_intr191)
};
#define IOAPIC_HWI_SYSCALL (IDT_OFFSET_SYSCALL - IDT_OFFSET)
static struct ioapic_irqmap {
int im_type; /* IOAPIC_IMT_ */
enum intr_trigger im_trig;
enum intr_polarity im_pola;
int im_gsi;
int im_msi_base;
uint32_t im_flags; /* IOAPIC_IMF_ */
} ioapic_irqmaps[MAXCPU][IOAPIC_HWI_VECTORS];
static struct lwkt_token ioapic_irqmap_tok =
LWKT_TOKEN_INITIALIZER(ioapic_irqmap_token);
#define IOAPIC_IMT_UNUSED 0
#define IOAPIC_IMT_RESERVED 1
#define IOAPIC_IMT_LEGACY 2
#define IOAPIC_IMT_SYSCALL 3
#define IOAPIC_IMT_SHADOW 4
#define IOAPIC_IMT_MSI 5
#define IOAPIC_IMT_MSIX 6
#define IOAPIC_IMT_ISHWI(map) ((map)->im_type != IOAPIC_IMT_RESERVED && \
(map)->im_type != IOAPIC_IMT_SYSCALL && \
(map)->im_type != IOAPIC_IMT_SHADOW)
#define IOAPIC_IMF_CONF 0x1
extern void IOAPIC_INTREN(int);
extern void IOAPIC_INTRDIS(int);
extern int imcr_present;
static void ioapic_abi_intr_enable(int);
static void ioapic_abi_intr_disable(int);
static void ioapic_abi_intr_setup(int, int);
static void ioapic_abi_intr_teardown(int);
static void ioapic_abi_legacy_intr_config(int,
enum intr_trigger, enum intr_polarity);
static int ioapic_abi_legacy_intr_cpuid(int);
static int ioapic_abi_legacy_intr_find(int,
enum intr_trigger, enum intr_polarity);
static int ioapic_abi_legacy_intr_find_bygsi(int,
enum intr_trigger, enum intr_polarity);
static int ioapic_abi_msi_alloc(int [], int, int);
static void ioapic_abi_msi_release(const int [], int, int);
static void ioapic_abi_msi_map(int, uint64_t *, uint32_t *, int);
static int ioapic_abi_msix_alloc(int *, int);
static void ioapic_abi_msix_release(int, int);
static int ioapic_abi_msi_alloc_intern(int, const char *,
int [], int, int);
static void ioapic_abi_msi_release_intern(int, const char *,
const int [], int, int);
static void ioapic_abi_finalize(void);
static void ioapic_abi_cleanup(void);
static void ioapic_abi_setdefault(void);
static void ioapic_abi_stabilize(void);
static void ioapic_abi_initmap(void);
static void ioapic_abi_rman_setup(struct rman *);
static int ioapic_abi_gsi_cpuid(int, int);
static int ioapic_find_unused_irqmap(int);
struct machintr_abi MachIntrABI_IOAPIC = {
MACHINTR_IOAPIC,
.intr_disable = ioapic_abi_intr_disable,
.intr_enable = ioapic_abi_intr_enable,
.intr_setup = ioapic_abi_intr_setup,
.intr_teardown = ioapic_abi_intr_teardown,
.legacy_intr_config = ioapic_abi_legacy_intr_config,
.legacy_intr_cpuid = ioapic_abi_legacy_intr_cpuid,
.legacy_intr_find = ioapic_abi_legacy_intr_find,
.legacy_intr_find_bygsi = ioapic_abi_legacy_intr_find_bygsi,
.msi_alloc = ioapic_abi_msi_alloc,
.msi_release = ioapic_abi_msi_release,
.msi_map = ioapic_abi_msi_map,
.msix_alloc = ioapic_abi_msix_alloc,
.msix_release = ioapic_abi_msix_release,
.finalize = ioapic_abi_finalize,
.cleanup = ioapic_abi_cleanup,
.setdefault = ioapic_abi_setdefault,
.stabilize = ioapic_abi_stabilize,
.initmap = ioapic_abi_initmap,
.rman_setup = ioapic_abi_rman_setup
};
static int ioapic_abi_extint_irq = -1;
static int ioapic_abi_legacy_irq_max;
static int ioapic_abi_gsi_balance;
static int ioapic_abi_msi_start; /* NOTE: for testing only */
struct ioapic_irqinfo ioapic_irqs[IOAPIC_HWI_VECTORS];
static void
ioapic_abi_intr_enable(int irq)
{
const struct ioapic_irqmap *map;
KASSERT(irq >= 0 && irq < IOAPIC_HWI_VECTORS,
("ioapic enable, invalid irq %d", irq));
map = &ioapic_irqmaps[mycpuid][irq];
KASSERT(IOAPIC_IMT_ISHWI(map),
("ioapic enable, not hwi irq %d, type %d, cpu%d",
irq, map->im_type, mycpuid));
if (map->im_type != IOAPIC_IMT_LEGACY)
return;
IOAPIC_INTREN(irq);
}
static void
ioapic_abi_intr_disable(int irq)
{
const struct ioapic_irqmap *map;
KASSERT(irq >= 0 && irq < IOAPIC_HWI_VECTORS,
("ioapic disable, invalid irq %d", irq));
map = &ioapic_irqmaps[mycpuid][irq];
KASSERT(IOAPIC_IMT_ISHWI(map),
("ioapic disable, not hwi irq %d, type %d, cpu%d",
irq, map->im_type, mycpuid));
if (map->im_type != IOAPIC_IMT_LEGACY)
return;
IOAPIC_INTRDIS(irq);
}
static void
ioapic_abi_finalize(void)
{
KKASSERT(MachIntrABI.type == MACHINTR_IOAPIC);
KKASSERT(ioapic_enable);
/*
* If an IMCR is present, program bit 0 to disconnect the 8259
* from the BSP.
*/
if (imcr_present) {
outb(0x22, 0x70); /* select IMCR */
outb(0x23, 0x01); /* disconnect 8259 */
}
}
/*
* This routine is called after physical interrupts are enabled but before
* the critical section is released. We need to clean out any interrupts
* that had already been posted to the cpu.
*/
static void
ioapic_abi_cleanup(void)
{
bzero(mdcpu->gd_ipending, sizeof(mdcpu->gd_ipending));
}
/* Must never be called */
static void
ioapic_abi_stabilize(void)
{
panic("ioapic_stabilize() is called");
}
static void
ioapic_abi_intr_setup(int intr, int flags)
{
const struct ioapic_irqmap *map;
int vector, select;
uint32_t value;
u_long ef;
KASSERT(intr >= 0 && intr < IOAPIC_HWI_VECTORS,
("ioapic setup, invalid irq %d", intr));
map = &ioapic_irqmaps[mycpuid][intr];
KASSERT(IOAPIC_IMT_ISHWI(map),
("ioapic setup, not hwi irq %d, type %d, cpu%d",
intr, map->im_type, mycpuid));
if (map->im_type != IOAPIC_IMT_LEGACY)
return;
KASSERT(ioapic_irqs[intr].io_addr != NULL,
("ioapic setup, no GSI information, irq %d", intr));
ef = read_eflags();
cpu_disable_intr();
vector = IDT_OFFSET + intr;
/*
* Now reprogram the vector in the IO APIC. In order to avoid
* losing an EOI for a level interrupt, which is vector based,
* make sure that the IO APIC is programmed for edge-triggering
* first, then reprogrammed with the new vector. This should
* clear the IRR bit.
*/
imen_lock();
select = ioapic_irqs[intr].io_idx;
value = ioapic_read(ioapic_irqs[intr].io_addr, select);
value |= IOART_INTMSET;
ioapic_write(ioapic_irqs[intr].io_addr, select,
(value & ~APIC_TRIGMOD_MASK));
ioapic_write(ioapic_irqs[intr].io_addr, select,
(value & ~IOART_INTVEC) | vector);
imen_unlock();
IOAPIC_INTREN(intr);
write_eflags(ef);
}
static void
ioapic_abi_intr_teardown(int intr)
{
const struct ioapic_irqmap *map;
int vector, select;
uint32_t value;
u_long ef;
KASSERT(intr >= 0 && intr < IOAPIC_HWI_VECTORS,
("ioapic teardown, invalid irq %d", intr));
map = &ioapic_irqmaps[mycpuid][intr];
KASSERT(IOAPIC_IMT_ISHWI(map),
("ioapic teardown, not hwi irq %d, type %d, cpu%d",
intr, map->im_type, mycpuid));
if (map->im_type != IOAPIC_IMT_LEGACY)
return;
KASSERT(ioapic_irqs[intr].io_addr != NULL,
("ioapic teardown, no GSI information, irq %d", intr));
ef = read_eflags();
cpu_disable_intr();
/*
* Teardown an interrupt vector. The vector should already be
* installed in the cpu's IDT, but make sure.
*/
IOAPIC_INTRDIS(intr);
vector = IDT_OFFSET + intr;
/*
* In order to avoid losing an EOI for a level interrupt, which
* is vector based, make sure that the IO APIC is programmed for
* edge-triggering first, then reprogrammed with the new vector.
* This should clear the IRR bit.
*/
imen_lock();
select = ioapic_irqs[intr].io_idx;
value = ioapic_read(ioapic_irqs[intr].io_addr, select);
ioapic_write(ioapic_irqs[intr].io_addr, select,
(value & ~APIC_TRIGMOD_MASK));
ioapic_write(ioapic_irqs[intr].io_addr, select,
(value & ~IOART_INTVEC) | vector);
imen_unlock();
write_eflags(ef);
}
static void
ioapic_abi_setdefault(void)
{
int intr;
for (intr = 0; intr < IOAPIC_HWI_VECTORS; ++intr) {
if (intr == IOAPIC_HWI_SYSCALL)
continue;
setidt(IDT_OFFSET + intr, ioapic_intr[intr], SDT_SYS386IGT,
SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
}
}
static void
ioapic_abi_initmap(void)
{
int cpu;
kgetenv_int("hw.ioapic.gsi.balance", &ioapic_abi_gsi_balance);
kgetenv_int("hw.ioapic.msi_start", &ioapic_abi_msi_start);
ioapic_abi_msi_start &= ~0x1f; /* MUST be 32 aligned */
/*
* NOTE: ncpus is not ready yet
*/
for (cpu = 0; cpu < MAXCPU; ++cpu) {
int i;
for (i = 0; i < IOAPIC_HWI_VECTORS; ++i) {
ioapic_irqmaps[cpu][i].im_gsi = -1;
ioapic_irqmaps[cpu][i].im_msi_base = -1;
}
ioapic_irqmaps[cpu][IOAPIC_HWI_SYSCALL].im_type =
IOAPIC_IMT_SYSCALL;
}
}
static int
ioapic_find_unused_irqmap(int gsi)
{
int cpuid, i;
cpuid = ioapic_abi_gsi_cpuid(-1, gsi);
for (i = ISA_IRQ_CNT; i < IOAPIC_HWI_VECTORS; ++i) {
if (i == acpi_sci_irqno())
continue;
if (ioapic_irqmaps[cpuid][i].im_type == IOAPIC_IMT_UNUSED)
return i;
}
return -1;
}
void
ioapic_set_legacy_irqmap(int irq, int gsi, enum intr_trigger trig,
enum intr_polarity pola)
{
struct ioapic_irqinfo *info;
struct ioapic_irqmap *map;
void *ioaddr;
int pin, cpuid;
KKASSERT(trig == INTR_TRIGGER_EDGE || trig == INTR_TRIGGER_LEVEL);
KKASSERT(pola == INTR_POLARITY_HIGH || pola == INTR_POLARITY_LOW);
KKASSERT(irq >= 0);
if (irq >= IOAPIC_HWI_VECTORS) {
/*
* Some BIOSes seem to assume that all 256 IDT vectors
* could be used, while we limit the available IDT
* vectors to 192; find an unused IRQ for this GSI.
*/
irq = ioapic_find_unused_irqmap(gsi);
if (irq < 0) {
kprintf("failed to find unused irq for gsi %d\n", gsi);
return;
}
}
KKASSERT(irq < IOAPIC_HWI_VECTORS);
if (irq > ioapic_abi_legacy_irq_max)
ioapic_abi_legacy_irq_max = irq;
cpuid = ioapic_abi_gsi_cpuid(irq, gsi);
map = &ioapic_irqmaps[cpuid][irq];
KKASSERT(map->im_type == IOAPIC_IMT_UNUSED);
map->im_type = IOAPIC_IMT_LEGACY;
map->im_gsi = gsi;
map->im_trig = trig;
map->im_pola = pola;
if (bootverbose) {
kprintf("IOAPIC: irq %d -> gsi %d %s/%s\n",
irq, map->im_gsi,
intr_str_trigger(map->im_trig),
intr_str_polarity(map->im_pola));
}
pin = ioapic_gsi_pin(map->im_gsi);
ioaddr = ioapic_gsi_ioaddr(map->im_gsi);
info = &ioapic_irqs[irq];
imen_lock();
info->io_addr = ioaddr;
info->io_idx = IOAPIC_REDTBL + (2 * pin);
info->io_flags = IOAPIC_IRQI_FLAG_MASKED;
if (map->im_trig == INTR_TRIGGER_LEVEL)
info->io_flags |= IOAPIC_IRQI_FLAG_LEVEL;
ioapic_pin_setup(ioaddr, pin, IDT_OFFSET + irq,
map->im_trig, map->im_pola, cpuid);
imen_unlock();
}
void
ioapic_fixup_legacy_irqmaps(void)
{
int cpu;
ioapic_abi_legacy_irq_max += 1;
if (bootverbose) {
kprintf("IOAPIC: legacy irq max %d\n",
ioapic_abi_legacy_irq_max);
}
for (cpu = 0; cpu < ncpus; ++cpu) {
int i;
for (i = 0; i < ioapic_abi_legacy_irq_max; ++i) {
struct ioapic_irqmap *map = &ioapic_irqmaps[cpu][i];
if (map->im_type == IOAPIC_IMT_UNUSED) {
map->im_type = IOAPIC_IMT_RESERVED;
if (bootverbose) {
kprintf("IOAPIC: "
"cpu%d irq %d reserved\n", cpu, i);
}
}
}
}
}
static int
ioapic_abi_legacy_intr_find_bygsi(int gsi, enum intr_trigger trig,
enum intr_polarity pola)
{
int cpu;
#ifdef INVARIANTS
if (trig == INTR_TRIGGER_CONFORM) {
KKASSERT(pola == INTR_POLARITY_CONFORM);
} else {
KKASSERT(trig == INTR_TRIGGER_EDGE ||
trig == INTR_TRIGGER_LEVEL);
KKASSERT(pola == INTR_POLARITY_HIGH ||
pola == INTR_POLARITY_LOW);
}
#endif
for (cpu = 0; cpu < ncpus; ++cpu) {
int irq;
for (irq = 0; irq < ioapic_abi_legacy_irq_max; ++irq) {
const struct ioapic_irqmap *map =
&ioapic_irqmaps[cpu][irq];
if (map->im_gsi == gsi) {
KKASSERT(map->im_type == IOAPIC_IMT_LEGACY);
if ((map->im_flags & IOAPIC_IMF_CONF) &&
trig != INTR_TRIGGER_CONFORM &&
pola != INTR_POLARITY_CONFORM) {
if (map->im_trig != trig ||
map->im_pola != pola)
return -1;
}
return irq;
}
}
}
return -1;
}
static int
ioapic_abi_legacy_intr_find(int irq, enum intr_trigger trig,
enum intr_polarity pola)
{
int cpu;
#ifdef INVARIANTS
if (trig == INTR_TRIGGER_CONFORM) {
KKASSERT(pola == INTR_POLARITY_CONFORM);
} else {
KKASSERT(trig == INTR_TRIGGER_EDGE ||
trig == INTR_TRIGGER_LEVEL);
KKASSERT(pola == INTR_POLARITY_HIGH ||
pola == INTR_POLARITY_LOW);
}
#endif
if (irq < 0 || irq >= ioapic_abi_legacy_irq_max)
return -1;
for (cpu = 0; cpu < ncpus; ++cpu) {
const struct ioapic_irqmap *map = &ioapic_irqmaps[cpu][irq];
if (map->im_type == IOAPIC_IMT_LEGACY) {
if ((map->im_flags & IOAPIC_IMF_CONF) &&
trig != INTR_TRIGGER_CONFORM &&
pola != INTR_POLARITY_CONFORM) {
if (map->im_trig != trig ||
map->im_pola != pola)
return -1;
}
return irq;
}
}
return -1;
}
static void
ioapic_abi_legacy_intr_config(int irq, enum intr_trigger trig,
enum intr_polarity pola)
{
struct ioapic_irqinfo *info;
struct ioapic_irqmap *map = NULL;
void *ioaddr;
int pin, cpuid;
KKASSERT(trig == INTR_TRIGGER_EDGE || trig == INTR_TRIGGER_LEVEL);
KKASSERT(pola == INTR_POLARITY_HIGH || pola == INTR_POLARITY_LOW);
KKASSERT(irq >= 0 && irq < ioapic_abi_legacy_irq_max);
for (cpuid = 0; cpuid < ncpus; ++cpuid) {
map = &ioapic_irqmaps[cpuid][irq];
if (map->im_type == IOAPIC_IMT_LEGACY)
break;
}
KKASSERT(cpuid < ncpus);
#ifdef notyet
if (map->im_flags & IOAPIC_IMF_CONF) {
if (trig != map->im_trig) {
panic("ioapic_intr_config: trig %s -> %s",
intr_str_trigger(map->im_trig),
intr_str_trigger(trig));
}
if (pola != map->im_pola) {
panic("ioapic_intr_config: pola %s -> %s",
intr_str_polarity(map->im_pola),
intr_str_polarity(pola));
}
return;
}
#endif
map->im_flags |= IOAPIC_IMF_CONF;
if (trig == map->im_trig && pola == map->im_pola)
return;
if (bootverbose) {
kprintf("IOAPIC: irq %d, gsi %d %s/%s -> %s/%s\n",
irq, map->im_gsi,
intr_str_trigger(map->im_trig),
intr_str_polarity(map->im_pola),
intr_str_trigger(trig),
intr_str_polarity(pola));
}
map->im_trig = trig;
map->im_pola = pola;
pin = ioapic_gsi_pin(map->im_gsi);
ioaddr = ioapic_gsi_ioaddr(map->im_gsi);
info = &ioapic_irqs[irq];
imen_lock();
info->io_flags &= ~IOAPIC_IRQI_FLAG_LEVEL;
if (map->im_trig == INTR_TRIGGER_LEVEL)
info->io_flags |= IOAPIC_IRQI_FLAG_LEVEL;
ioapic_pin_setup(ioaddr, pin, IDT_OFFSET + irq,
map->im_trig, map->im_pola, cpuid);
imen_unlock();
}
int
ioapic_conf_legacy_extint(int irq)
{
struct ioapic_irqinfo *info;
struct ioapic_irqmap *map;
void *ioaddr;
int pin, error, vec;
/* XXX only irq0 is allowed */
KKASSERT(irq == 0);
vec = IDT_OFFSET + irq;
if (ioapic_abi_extint_irq == irq)
return 0;
else if (ioapic_abi_extint_irq >= 0)
return EEXIST;
error = icu_ioapic_extint(irq, vec);
if (error)
return error;
/* ExtINT is always targeted to cpu0 */
map = &ioapic_irqmaps[0][irq];
KKASSERT(map->im_type == IOAPIC_IMT_RESERVED ||
map->im_type == IOAPIC_IMT_LEGACY);
if (map->im_type == IOAPIC_IMT_LEGACY) {
if (map->im_flags & IOAPIC_IMF_CONF)
return EEXIST;
}
ioapic_abi_extint_irq = irq;
map->im_type = IOAPIC_IMT_LEGACY;
map->im_trig = INTR_TRIGGER_EDGE;
map->im_pola = INTR_POLARITY_HIGH;
map->im_flags = IOAPIC_IMF_CONF;
map->im_gsi = ioapic_extpin_gsi();
KKASSERT(map->im_gsi >= 0);
if (bootverbose) {
kprintf("IOAPIC: irq %d -> extint gsi %d %s/%s\n",
irq, map->im_gsi,
intr_str_trigger(map->im_trig),
intr_str_polarity(map->im_pola));
}
pin = ioapic_gsi_pin(map->im_gsi);
ioaddr = ioapic_gsi_ioaddr(map->im_gsi);
info = &ioapic_irqs[irq];
imen_lock();
info->io_addr = ioaddr;
info->io_idx = IOAPIC_REDTBL + (2 * pin);
info->io_flags = IOAPIC_IRQI_FLAG_MASKED;
ioapic_extpin_setup(ioaddr, pin, vec);
imen_unlock();
return 0;
}
static int
ioapic_abi_legacy_intr_cpuid(int irq)
{
const struct ioapic_irqmap *map = NULL;
int cpuid;
KKASSERT(irq >= 0 && irq < ioapic_abi_legacy_irq_max);
for (cpuid = 0; cpuid < ncpus; ++cpuid) {
map = &ioapic_irqmaps[cpuid][irq];
if (map->im_type == IOAPIC_IMT_LEGACY)
return cpuid;
}
/* XXX some drivers tries to peek at reserved IRQs */
for (cpuid = 0; cpuid < ncpus; ++cpuid) {
map = &ioapic_irqmaps[cpuid][irq];
KKASSERT(map->im_type == IOAPIC_IMT_RESERVED);
}
return 0;
}
static int
ioapic_abi_gsi_cpuid(int irq, int gsi)
{
char envpath[32];
int cpuid = -1;
KKASSERT(gsi >= 0);
if (irq == 0 || gsi == 0) {
KKASSERT(irq >= 0);
if (bootverbose) {
kprintf("IOAPIC: irq %d, gsi %d -> cpu0 (0)\n",
irq, gsi);
}
return 0;
}
if (irq >= 0 && irq == acpi_sci_irqno()) {
if (bootverbose) {
kprintf("IOAPIC: irq %d, gsi %d -> cpu0 (sci)\n",
irq, gsi);
}
return 0;
}
ksnprintf(envpath, sizeof(envpath), "hw.ioapic.gsi.%d.cpu", gsi);
kgetenv_int(envpath, &cpuid);
if (cpuid < 0) {
if (!ioapic_abi_gsi_balance) {
if (irq >= 0 && bootverbose) {
kprintf("IOAPIC: irq %d, gsi %d -> cpu0 "
"(fixed)\n", irq, gsi);
}
return 0;
}
cpuid = gsi % ncpus;
if (irq >= 0 && bootverbose) {
kprintf("IOAPIC: irq %d, gsi %d -> cpu%d (auto)\n",
irq, gsi, cpuid);
}
} else if (cpuid >= ncpus) {
cpuid = ncpus - 1;
if (irq >= 0 && bootverbose) {
kprintf("IOAPIC: irq %d, gsi %d -> cpu%d (fixup)\n",
irq, gsi, cpuid);
}
} else {
if (irq >= 0 && bootverbose) {
kprintf("IOAPIC: irq %d, gsi %d -> cpu%d (user)\n",
irq, gsi, cpuid);
}
}
return cpuid;
}
static void
ioapic_abi_rman_setup(struct rman *rm)
{
int start, end, i;
KASSERT(rm->rm_cpuid >= 0 && rm->rm_cpuid < MAXCPU,
("invalid rman cpuid %d", rm->rm_cpuid));
start = end = -1;
for (i = 0; i < IOAPIC_HWI_VECTORS; ++i) {
const struct ioapic_irqmap *map =
&ioapic_irqmaps[rm->rm_cpuid][i];
if (start < 0) {
if (IOAPIC_IMT_ISHWI(map))
start = end = i;
} else {
if (IOAPIC_IMT_ISHWI(map)) {
end = i;
} else {
KKASSERT(end >= 0);
if (bootverbose) {
kprintf("IOAPIC: rman cpu%d %d - %d\n",
rm->rm_cpuid, start, end);
}
if (rman_manage_region(rm, start, end)) {
panic("rman_manage_region"
"(cpu%d %d - %d)", rm->rm_cpuid,
start, end);
}
start = end = -1;
}
}
}
if (start >= 0) {
KKASSERT(end >= 0);
if (bootverbose) {
kprintf("IOAPIC: rman cpu%d %d - %d\n",
rm->rm_cpuid, start, end);
}
if (rman_manage_region(rm, start, end)) {
panic("rman_manage_region(cpu%d %d - %d)",
rm->rm_cpuid, start, end);
}
}
}
static int
ioapic_abi_msi_alloc_intern(int type, const char *desc,
int intrs[], int count, int cpuid)
{
int i, error;
KASSERT(cpuid >= 0 && cpuid < ncpus,
("invalid cpuid %d", cpuid));
KASSERT(count > 0 && count <= 32, ("invalid count %d", count));
KASSERT((count & (count - 1)) == 0,
("count %d is not power of 2", count));
lwkt_gettoken(&ioapic_irqmap_tok);
/*
* NOTE:
* Since IDT_OFFSET is 32, which is the maximum valid 'count',
* we do not need to find out the first properly aligned
* interrupt vector.
*/
error = EMSGSIZE;
for (i = ioapic_abi_msi_start; i < IOAPIC_HWI_VECTORS; i += count) {
int j;
if (ioapic_irqmaps[cpuid][i].im_type != IOAPIC_IMT_UNUSED)
continue;
for (j = 1; j < count; ++j) {
if (ioapic_irqmaps[cpuid][i + j].im_type !=
IOAPIC_IMT_UNUSED)
break;
}
if (j != count)
continue;
for (j = 0; j < count; ++j) {
int intr = i + j, cpu;
for (cpu = 0; cpu < ncpus; ++cpu) {
struct ioapic_irqmap *map;
map = &ioapic_irqmaps[cpu][intr];
KASSERT(map->im_msi_base < 0,
("intr %d cpu%d, stale %s-base %d",
intr, cpu, desc, map->im_msi_base));
KASSERT(map->im_type == IOAPIC_IMT_UNUSED,
("intr %d cpu%d, already allocated",
intr, cpu));
if (cpu == cpuid) {
map->im_type = type;
map->im_msi_base = i;
} else {
map->im_type = IOAPIC_IMT_SHADOW;
}
}
intrs[j] = intr;
msi_setup(intr);
if (bootverbose) {
kprintf("alloc %s intr %d on cpu%d\n",
desc, intr, cpuid);
}
}
error = 0;
break;
}
lwkt_reltoken(&ioapic_irqmap_tok);
return error;
}
static void
ioapic_abi_msi_release_intern(int type, const char *desc,
const int intrs[], int count, int cpuid)
{
int i, msi_base = -1, intr_next = -1, mask;
KASSERT(cpuid >= 0 && cpuid < ncpus,
("invalid cpuid %d", cpuid));
KASSERT(count > 0 && count <= 32, ("invalid count %d", count));
mask = count - 1;
KASSERT((count & mask) == 0, ("count %d is not power of 2", count));
lwkt_gettoken(&ioapic_irqmap_tok);
for (i = 0; i < count; ++i) {
int intr = intrs[i], cpu;
KASSERT(intr >= 0 && intr < IOAPIC_HWI_VECTORS,
("invalid intr %d", intr));
for (cpu = 0; cpu < ncpus; ++cpu) {
struct ioapic_irqmap *map;
map = &ioapic_irqmaps[cpu][intr];
if (cpu == cpuid) {
KASSERT(map->im_type == type,
("trying to release non-%s intr %d cpu%d, "
"type %d", desc, intr, cpu,
map->im_type));
KASSERT(map->im_msi_base >= 0 &&
map->im_msi_base <= intr,
("intr %d cpu%d, invalid %s-base %d",
intr, cpu, desc, map->im_msi_base));
KASSERT((map->im_msi_base & mask) == 0,
("intr %d cpu%d, %s-base %d is "
"not properly aligned %d",
intr, cpu, desc, map->im_msi_base, count));
if (msi_base < 0) {
msi_base = map->im_msi_base;
} else {
KASSERT(map->im_msi_base == msi_base,
("intr %d cpu%d, "
"inconsistent %s-base, "
"was %d, now %d",
intr, cpu, desc,
msi_base, map->im_msi_base));
}
map->im_msi_base = -1;
} else {
KASSERT(map->im_type == IOAPIC_IMT_SHADOW,
("trying to release non-%ssh intr %d cpu%d, "
"type %d", desc, intr, cpu,
map->im_type));
KASSERT(map->im_msi_base < 0,
("intr %d cpu%d, invalid %ssh-base %d",
intr, cpu, desc, map->im_msi_base));
}
map->im_type = IOAPIC_IMT_UNUSED;
}
if (intr_next < intr)
intr_next = intr;
if (bootverbose) {
kprintf("release %s intr %d on cpu%d\n",
desc, intr, cpuid);
}
}
KKASSERT(intr_next > 0);
KKASSERT(msi_base >= 0);
++intr_next;
if (intr_next < IOAPIC_HWI_VECTORS) {
int cpu;
for (cpu = 0; cpu < ncpus; ++cpu) {
const struct ioapic_irqmap *map =
&ioapic_irqmaps[cpu][intr_next];
if (map->im_type == type) {
KASSERT(map->im_msi_base != msi_base,
("more than %d %s was allocated",
count, desc));
}
}
}
lwkt_reltoken(&ioapic_irqmap_tok);
}
static int
ioapic_abi_msi_alloc(int intrs[], int count, int cpuid)
{
return ioapic_abi_msi_alloc_intern(IOAPIC_IMT_MSI, "MSI",
intrs, count, cpuid);
}
static void
ioapic_abi_msi_release(const int intrs[], int count, int cpuid)
{
ioapic_abi_msi_release_intern(IOAPIC_IMT_MSI, "MSI",
intrs, count, cpuid);
}
static int
ioapic_abi_msix_alloc(int *intr, int cpuid)
{
return ioapic_abi_msi_alloc_intern(IOAPIC_IMT_MSIX, "MSI-X",
intr, 1, cpuid);
}
static void
ioapic_abi_msix_release(int intr, int cpuid)
{
ioapic_abi_msi_release_intern(IOAPIC_IMT_MSIX, "MSI-X",
&intr, 1, cpuid);
}
static void
ioapic_abi_msi_map(int intr, uint64_t *addr, uint32_t *data, int cpuid)
{
const struct ioapic_irqmap *map;
KASSERT(cpuid >= 0 && cpuid < ncpus,
("invalid cpuid %d", cpuid));
KASSERT(intr >= 0 && intr < IOAPIC_HWI_VECTORS,
("invalid intr %d", intr));
lwkt_gettoken(&ioapic_irqmap_tok);
map = &ioapic_irqmaps[cpuid][intr];
KASSERT(map->im_type == IOAPIC_IMT_MSI ||
map->im_type == IOAPIC_IMT_MSIX,
("trying to map non-MSI/MSI-X intr %d, type %d", intr, map->im_type));
KASSERT(map->im_msi_base >= 0 && map->im_msi_base <= intr,
("intr %d, invalid %s-base %d", intr,
map->im_type == IOAPIC_IMT_MSI ? "MSI" : "MSI-X",
map->im_msi_base));
msi_map(map->im_msi_base, addr, data, cpuid);
if (bootverbose) {
kprintf("map %s intr %d on cpu%d\n",
map->im_type == IOAPIC_IMT_MSI ? "MSI" : "MSI-X",
intr, cpuid);
}
lwkt_reltoken(&ioapic_irqmap_tok);
}
| 24.874569 | 75 | 0.702657 |
65345ab7912a917d28d4a63629db1bf9d0c9abb6 | 2,035 | h | C | flang/lib/Semantics/assignment.h | mkinsner/llvm | 589d48844edb12cd357b3024248b93d64b6760bf | [
"Apache-2.0"
] | 2,338 | 2018-06-19T17:34:51.000Z | 2022-03-31T11:00:37.000Z | flang/lib/Semantics/assignment.h | mkinsner/llvm | 589d48844edb12cd357b3024248b93d64b6760bf | [
"Apache-2.0"
] | 3,740 | 2019-01-23T15:36:48.000Z | 2022-03-31T22:01:13.000Z | flang/lib/Semantics/assignment.h | mkinsner/llvm | 589d48844edb12cd357b3024248b93d64b6760bf | [
"Apache-2.0"
] | 500 | 2019-01-23T07:49:22.000Z | 2022-03-30T02:59:37.000Z | //===-- lib/Semantics/assignment.h ------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef FORTRAN_SEMANTICS_ASSIGNMENT_H_
#define FORTRAN_SEMANTICS_ASSIGNMENT_H_
#include "flang/Common/indirection.h"
#include "flang/Evaluate/expression.h"
#include "flang/Semantics/semantics.h"
namespace Fortran::parser {
class ContextualMessages;
struct AssignmentStmt;
struct EndWhereStmt;
struct MaskedElsewhereStmt;
struct PointerAssignmentStmt;
struct WhereConstructStmt;
struct WhereStmt;
} // namespace Fortran::parser
namespace Fortran::semantics {
class AssignmentContext;
class Scope;
class Symbol;
// Applies checks from C1594(1-2) on definitions in pure subprograms
bool CheckDefinabilityInPureScope(parser::ContextualMessages &, const Symbol &,
const Scope &context, const Scope &pure);
// Applies checks from C1594(5-6) on copying pointers in pure subprograms
bool CheckCopyabilityInPureScope(parser::ContextualMessages &,
const evaluate::Expr<evaluate::SomeType> &, const Scope &);
class AssignmentChecker : public virtual BaseChecker {
public:
explicit AssignmentChecker(SemanticsContext &);
~AssignmentChecker();
void Enter(const parser::AssignmentStmt &);
void Enter(const parser::PointerAssignmentStmt &);
void Enter(const parser::WhereStmt &);
void Leave(const parser::WhereStmt &);
void Enter(const parser::WhereConstructStmt &);
void Leave(const parser::EndWhereStmt &);
void Enter(const parser::MaskedElsewhereStmt &);
void Leave(const parser::MaskedElsewhereStmt &);
private:
common::Indirection<AssignmentContext> context_;
};
} // namespace Fortran::semantics
extern template class Fortran::common::Indirection<
Fortran::semantics::AssignmentContext>;
#endif // FORTRAN_SEMANTICS_ASSIGNMENT_H_
| 33.360656 | 80 | 0.733661 |
04ef00c8851e95194ba716439d1acf4fd907adcc | 1,590 | c | C | src/image/jpegload.c | ElArtista/AssetLoader | 1f2e102db40a7ffc379e7a442a23503424bd3350 | [
"MIT"
] | 4 | 2016-10-07T15:52:56.000Z | 2020-04-11T00:53:32.000Z | src/image/jpegload.c | ElArtista/AssetLoader | 1f2e102db40a7ffc379e7a442a23503424bd3350 | [
"MIT"
] | null | null | null | src/image/jpegload.c | ElArtista/AssetLoader | 1f2e102db40a7ffc379e7a442a23503424bd3350 | [
"MIT"
] | null | null | null | #include "assets/image/imageload.h"
#include "assets/error.h"
#include <stdio.h>
#include "jpeglib.h"
struct image* image_from_jpeg(const unsigned char* data, size_t sz) {
/* Create decompress struct */
struct jpeg_decompress_struct cinfo;
/* Set the error handling mechanism */
struct jpeg_error_mgr err_mgr;
cinfo.err = jpeg_std_error(&err_mgr);
/* Initialize decompression object */
jpeg_create_decompress(&cinfo);
/* Set memory buffer as source */
jpeg_mem_src(&cinfo, (unsigned char*) data, sz);
if (!jpeg_read_header(&cinfo, TRUE)) {
jpeg_destroy_decompress(&cinfo);
set_last_asset_load_error("Incorrect jpeg header");
return 0;
}
/* Start the decompression procedure */
jpeg_start_decompress(&cinfo);
/* Gather image data info */
int width = cinfo.output_width;
int height = cinfo.output_height;
int pixel_size = cinfo.output_components;
/* Allocate and fill the image object */
struct image* im = image_blank(width, height, pixel_size);
/* Read by lines */
unsigned char* bufp = im->data;
int stride = cinfo.image_width * cinfo.num_components;
while (cinfo.output_scanline < cinfo.output_height) {
unsigned char* row = bufp + (cinfo.output_height - cinfo.output_scanline - 1) * stride;
jpeg_read_scanlines(&cinfo, (JSAMPARRAY)&row, 1);
}
/* Finish decompression procedure */
jpeg_finish_decompress(&cinfo);
/* Destroy decompress struct */
jpeg_destroy_decompress(&cinfo);
/* Return loaded image */
return im;
}
| 30 | 95 | 0.677987 |
ca2853146cc25a1d234f68571867ab8758f60069 | 5,819 | c | C | openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/glibc/2.29-r0/git/sunrpc/xdr_intXX_t.c | sotaoverride/backup | ca53a10b72295387ef4948a9289cb78ab70bc449 | [
"Apache-2.0"
] | null | null | null | openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/glibc/2.29-r0/git/sunrpc/xdr_intXX_t.c | sotaoverride/backup | ca53a10b72295387ef4948a9289cb78ab70bc449 | [
"Apache-2.0"
] | null | null | null | openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/glibc/2.29-r0/git/sunrpc/xdr_intXX_t.c | sotaoverride/backup | ca53a10b72295387ef4948a9289cb78ab70bc449 | [
"Apache-2.0"
] | null | null | null | /* Copyright (c) 1998-2019 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1998.
The GNU C 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.
The GNU C 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 the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#include <rpc/types.h>
/* We play dirty tricks with aliases. */
#include <rpc/xdr.h>
#include <shlib-compat.h>
#include <stdint.h>
/* XDR 64bit integers */
bool_t xdr_int64_t(XDR* xdrs, int64_t* ip)
{
int32_t t1, t2;
switch (xdrs->x_op)
{
case XDR_ENCODE:
t1 = (int32_t)((*ip) >> 32);
t2 = (int32_t)(*ip);
return (XDR_PUTINT32(xdrs, &t1) && XDR_PUTINT32(xdrs, &t2));
case XDR_DECODE:
if (!XDR_GETINT32(xdrs, &t1) || !XDR_GETINT32(xdrs, &t2))
return FALSE;
*ip = ((int64_t)t1) << 32;
*ip |= (uint32_t)t2; /* Avoid sign extension. */
return TRUE;
case XDR_FREE:
return TRUE;
default:
return FALSE;
}
}
libc_hidden_nolink_sunrpc(xdr_int64_t, GLIBC_2_1_1)
bool_t xdr_quad_t(XDR* xdrs, quad_t* ip)
{
return xdr_int64_t(xdrs, (int64_t*)ip);
}
libc_hidden_nolink_sunrpc(xdr_quad_t, GLIBC_2_3_4)
/* XDR 64bit unsigned integers */
bool_t xdr_uint64_t(XDR* xdrs, uint64_t* uip)
{
uint32_t t1;
uint32_t t2;
switch (xdrs->x_op)
{
case XDR_ENCODE:
t1 = (uint32_t)((*uip) >> 32);
t2 = (uint32_t)(*uip);
return (XDR_PUTINT32(xdrs, (int32_t*)&t1) &&
XDR_PUTINT32(xdrs, (int32_t*)&t2));
case XDR_DECODE:
if (!XDR_GETINT32(xdrs, (int32_t*)&t1) ||
!XDR_GETINT32(xdrs, (int32_t*)&t2))
return FALSE;
*uip = ((uint64_t)t1) << 32;
*uip |= t2;
return TRUE;
case XDR_FREE:
return TRUE;
default:
return FALSE;
}
}
libc_hidden_nolink_sunrpc(xdr_uint64_t, GLIBC_2_1_1)
bool_t xdr_u_quad_t(XDR* xdrs, u_quad_t* ip)
{
return xdr_uint64_t(xdrs, (uint64_t*)ip);
}
libc_hidden_nolink_sunrpc(xdr_u_quad_t, GLIBC_2_3_4)
/* XDR 32bit integers */
bool_t xdr_int32_t(XDR* xdrs, int32_t* lp)
{
switch (xdrs->x_op)
{
case XDR_ENCODE:
return XDR_PUTINT32(xdrs, lp);
case XDR_DECODE:
return XDR_GETINT32(xdrs, lp);
case XDR_FREE:
return TRUE;
default:
return FALSE;
}
}
libc_hidden_nolink_sunrpc(xdr_int32_t, GLIBC_2_1)
/* XDR 32bit unsigned integers */
bool_t xdr_uint32_t(XDR* xdrs, uint32_t* ulp)
{
switch (xdrs->x_op)
{
case XDR_ENCODE:
return XDR_PUTINT32(xdrs, (int32_t*)ulp);
case XDR_DECODE:
return XDR_GETINT32(xdrs, (int32_t*)ulp);
case XDR_FREE:
return TRUE;
default:
return FALSE;
}
}
#ifdef EXPORT_RPC_SYMBOLS
libc_hidden_def(xdr_uint32_t)
#else
libc_hidden_nolink_sunrpc(xdr_uint32_t, GLIBC_2_1)
#endif
/* XDR 16bit integers */
bool_t xdr_int16_t(XDR* xdrs, int16_t* ip)
{
int32_t t;
switch (xdrs->x_op)
{
case XDR_ENCODE:
t = (int32_t)*ip;
return XDR_PUTINT32(xdrs, &t);
case XDR_DECODE:
if (!XDR_GETINT32(xdrs, &t))
return FALSE;
*ip = (int16_t)t;
return TRUE;
case XDR_FREE:
return TRUE;
default:
return FALSE;
}
}
libc_hidden_nolink_sunrpc(xdr_int16_t, GLIBC_2_1)
/* XDR 16bit unsigned integers */
bool_t xdr_uint16_t(XDR* xdrs, uint16_t* uip)
{
uint32_t ut;
switch (xdrs->x_op)
{
case XDR_ENCODE:
ut = (uint32_t)*uip;
return XDR_PUTINT32(xdrs, (int32_t*)&ut);
case XDR_DECODE:
if (!XDR_GETINT32(xdrs, (int32_t*)&ut))
return FALSE;
*uip = (uint16_t)ut;
return TRUE;
case XDR_FREE:
return TRUE;
default:
return FALSE;
}
}
libc_hidden_nolink_sunrpc(xdr_uint16_t, GLIBC_2_1)
/* XDR 8bit integers */
bool_t xdr_int8_t(XDR* xdrs, int8_t* ip)
{
int32_t t;
switch (xdrs->x_op)
{
case XDR_ENCODE:
t = (int32_t)*ip;
return XDR_PUTINT32(xdrs, &t);
case XDR_DECODE:
if (!XDR_GETINT32(xdrs, &t))
return FALSE;
*ip = (int8_t)t;
return TRUE;
case XDR_FREE:
return TRUE;
default:
return FALSE;
}
}
libc_hidden_nolink_sunrpc(xdr_int8_t, GLIBC_2_1)
/* XDR 8bit unsigned integers */
bool_t xdr_uint8_t(XDR* xdrs, uint8_t* uip)
{
uint32_t ut;
switch (xdrs->x_op)
{
case XDR_ENCODE:
ut = (uint32_t)*uip;
return XDR_PUTINT32(xdrs, (int32_t*)&ut);
case XDR_DECODE:
if (!XDR_GETINT32(xdrs, (int32_t*)&ut))
return FALSE;
*uip = (uint8_t)ut;
return TRUE;
case XDR_FREE:
return TRUE;
default:
return FALSE;
}
}
libc_hidden_nolink_sunrpc(xdr_uint8_t, GLIBC_2_1)
| 26.45 | 72 | 0.577419 |
c83ca377b40886571f16d589438064d8e3a8c5e7 | 971 | h | C | u-boot/arch/arm/include/asm/arch-sunxi/pwm.h | xregist/v3s-linux-sdk | a2b013e3959662d65650a13fc23ec1cd503865eb | [
"Apache-2.0"
] | 31 | 2018-01-16T17:11:44.000Z | 2022-03-16T13:51:24.000Z | uboot/u-boot-3s-spi-experimental/arch/arm/include/asm/arch-sunxi/pwm.h | linlyv/SUDA_V3S | 1809657dfdbd07c15304e941775441c478de2efb | [
"Apache-2.0"
] | 1 | 2021-04-29T09:08:08.000Z | 2021-05-08T07:57:06.000Z | uboot/u-boot-3s-spi-experimental/arch/arm/include/asm/arch-sunxi/pwm.h | linlyv/SUDA_V3S | 1809657dfdbd07c15304e941775441c478de2efb | [
"Apache-2.0"
] | 30 | 2018-05-02T08:43:27.000Z | 2022-01-23T03:25:54.000Z | /*
* (C) Copyright 2016 Hans de Goede <hdegoede@redhat.com>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#ifndef _SUNXI_PWM_H
#define _SUNXI_PWM_H
#define SUNXI_PWM_CTRL_REG (SUNXI_PWM_BASE + 0)
#define SUNXI_PWM_CH0_PERIOD (SUNXI_PWM_BASE + 4)
#define SUNXI_PWM_CTRL_PRESCALE0(x) ((x) & 0xf)
#define SUNXI_PWM_CTRL_ENABLE0 (0x5 << 4)
#define SUNXI_PWM_CTRL_POLARITY0(x) ((x) << 5)
#define SUNXI_PWM_PERIOD_80PCT 0x04af03c0
#if defined CONFIG_MACH_SUN4I || defined CONFIG_MACH_SUN5I
#define SUNXI_PWM_PIN0 SUNXI_GPB(2)
#define SUNXI_PWM_MUX SUN4I_GPB_PWM
#endif
#if defined CONFIG_MACH_SUN6I
#define SUNXI_PWM_PIN0 SUNXI_GPH(13)
#define SUNXI_PWM_MUX SUN6I_GPH_PWM
#endif
#if defined CONFIG_MACH_SUN8I_A23 || defined CONFIG_MACH_SUN8I_A33
#define SUNXI_PWM_PIN0 SUNXI_GPH(0)
#define SUNXI_PWM_MUX SUN8I_GPH_PWM
#endif
#if defined CONFIG_MACH_SUN8I_V3S
#define SUNXI_PWM_PIN0 SUNXI_GPB(4)
#define SUNXI_PWM_MUX SUN8I_V3S_GPB_PWM
#endif
#endif
| 24.275 | 66 | 0.786818 |
bdc491ce313c07cd24051c6ebe6cc8d2c9fcacd8 | 8,526 | c | C | Smit/Sem VI/HPC/Lab1/q1e.c | Vishu26/Academics_Projects | d390a90b2740b6bd85381ca3a5292c42c29196a1 | [
"MIT"
] | null | null | null | Smit/Sem VI/HPC/Lab1/q1e.c | Vishu26/Academics_Projects | d390a90b2740b6bd85381ca3a5292c42c29196a1 | [
"MIT"
] | null | null | null | Smit/Sem VI/HPC/Lab1/q1e.c | Vishu26/Academics_Projects | d390a90b2740b6bd85381ca3a5292c42c29196a1 | [
"MIT"
] | null | null | null | /*#include <stdio.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <omp.h>
long minSize,maxSize,total,size,i,j,k,bi,bj,bk,temp,blockSize,sum;
double throughput,runs,**a,**b,**c;
int main(){
minSize = pow(2,4);
maxSize = pow(2,10);
total = maxSize;
for(size=minSize;size<maxSize;size*=2){
runs = (double)total/size;
a=(double**)calloc(size,sizeof(double*));
b=(double**)calloc(size,sizeof(double*));
c=(double**)calloc(size,sizeof(double*));
for(i=0;i<size;i++){
a[i]=(double*)calloc(size,sizeof(double));
b[i]=(double*)calloc(size,sizeof(double));
c[i]=(double*)calloc(size,sizeof(double));
}
double start_time = omp_get_wtime();
for(temp=0;temp<(long)runs;temp++){
for(i=0;i<size;i++)
for(j=0;j<size;j++){
sum=0;
for(k=0;k<size;k++) sum+=a[i][k]*b[k][j];
c[i][j]=temp;
}
if(temp==maxSize) temp++;
}
double end_time = omp_get_wtime() - start_time;
throughput = (sizeof(double)*2*total)/(double)end_time;
printf("%lf,",throughput);
free(a);free(b);free(c);
a=(double**)calloc(size,sizeof(double*));
b=(double**)calloc(size,sizeof(double*));
c=(double**)calloc(size,sizeof(double*));
for(i=0;i<size;i++){
a[i]=(double*)calloc(size,sizeof(double));
b[i]=(double*)calloc(size,sizeof(double));
c[i]=(double*)calloc(size,sizeof(double));
}
if(size<100) blockSize = size;
else blockSize = 128;
start_time = omp_get_wtime();
for(temp=0;temp<(long)runs;temp++){
for(bi=0;bi<size;bi+=blockSize)
for(bj=0;bj<size;bj+=blockSize)
for(bk=0;bk<size;bk+=blockSize)
for(i=0;i<blockSize;i++)
for(j=0;j<blockSize;j++){
sum=0;
for(k=0;k<blockSize;k++) sum+=a[bi+i][bk+k]*b[bk+k][bj+j];
c[bi+i][bj+j]=temp;
}
if(temp==maxSize) temp++;
}
end_time = omp_get_wtime() - start_time;
throughput = (sizeof(double)*2*total)/(double)end_time;
printf("%lf,",throughput);
free(a);free(b);free(c);
}
}*/
#include<stdio.h>
#include<omp.h>
#include<math.h>
#include<stdlib.h>
#define LL long long
#define max(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a > _b ? _a : _b; })
#define min(a,b) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
_a < _b ? _a : _b; })
int main(void) {
LL int min_size = pow(2,3);
LL int max_size = pow(2,10);
LL int total = max_size;
LL int i,j,k,l,kk,jj,size,cache_size,runs;
LL int RUNS = 5;
double start_time_c, end_time_c, start_time, end_time, d;
printf("Problem Size\tCompute Time\t\tCMA\n");
int size_array[8];
float compute_time_array[8], CMA_array[8];
// Standard Algorithm
for(size = min_size; size <= max_size; size *= 2) {
double** A = (double**) malloc(size * sizeof(double*));
for(i = 0; i < size; i++) {
A[i] = (double*)malloc(size * sizeof(double));
for(j = 0; j < size; j++) {
A[i][j] = 2.5;
}
}
double** B = (double**) malloc(size * sizeof(double*));
for(i = 0; i < size; i++) {
B[i] = (double*)malloc(size * sizeof(double));
for(j = 0; j < size; j++) {
B[i][j] = 3.75;
}
}
double** C = (double**) malloc(size * sizeof(double*));
for(i = 0; i < size; i++) {
C[i] = (double*)malloc(size * sizeof(double));
for(j = 0; j < size; j++) {
C[i][j] = 0;
}
}
// Calculate Compute Time
start_time_c = omp_get_wtime();
for(i = 0; i < size; i++) {
for(j = 0; j < size; j++) {
for(k = 0; k < size; k++) {
d = 1 + 2 * 3;
}
}
}
end_time_c = omp_get_wtime() - start_time_c;
start_time = omp_get_wtime();
for(runs = 0; runs < RUNS; runs++) {
for(i = 0; i < size; i++) {
for(j = 0; j < size; j++) {
for(k = 0; k < size; k++) {
C[i][j] = C[i][j] + A[i][k] * B[k][j];
}
}
}
}
end_time = omp_get_wtime() - start_time;
end_time /= RUNS;
size_array[size/min_size -1] = size;
compute_time_array[size/min_size -1] = end_time;
CMA_array[size/min_size -1] = (end_time_c)/(end_time - end_time_c);
// printf("%lld\t\t%f\t\t%f\n", size, end_time, (end_time_c)/(end_time - end_time_c));
}
int kg=0;
for(kg=0; kg<8; kg++) {
printf("%d ", size_array[i]);
}
printf("\n");
for(kg=0; kg<8; kg++) {
printf("%f ", compute_time_array[i]);
}
printf("\n");
for(kg=0; kg<8; kg++) {
printf("%f ", CMA_array[i]);
}
printf("\n");
printf("================================================================");
printf("\n");
/*
// 2D Blocled MM
LL int min_cache_line = pow(2,2);
LL int max_cache_line = pow(2,7);
for(cache_size = min_cache_line; cache_size <= max_cache_line; cache_size *= 2) {
printf("\n\n\nCache Size: %lld", cache_size);
// printf("\n\nProblem Size\tCompute Time\t\tCMA\n");
for(size = min_size; size <= max_size; size *= 2) {
double** A = (double**) malloc(size * sizeof(double*));
for(i = 0; i < size; i++) {
A[i] = (double*)malloc(size * sizeof(double));
for(j = 0; j < size; j++) {
A[i][j] = 2.5;
}
}
double** B = (double**) malloc(size * sizeof(double*));
for(i = 0; i < size; i++) {
B[i] = (double*)malloc(size * sizeof(double));
for(j = 0; j < size; j++) {
B[i][j] = 3.75;
}
}
double** C = (double**) malloc(size * sizeof(double*));
for(i = 0; i < size; i++) {
C[i] = (double*)malloc(size * sizeof(double));
for(j = 0; j < size; j++) {
C[i][j] = 0;
}
}
// Calculate Compute Time
start_time_c = omp_get_wtime();
for(i = 0; i < size; i++) {
for(j = 0; j < size; j++) {
for(k = 0; k < size; k++) {
d = 1 + 2 * 3;
}
}
}
end_time_c = omp_get_wtime() - start_time_c;
LL int MATRIX_SIZE = size;
LL int block_size = cache_size;
start_time = omp_get_wtime();
for(runs = 0; runs < RUNS; runs++) {
for (k = 0; k < MATRIX_SIZE; k += block_size)
for (j = 0; j < MATRIX_SIZE; j += block_size)
for (i = 0; i < MATRIX_SIZE; ++i)
for (jj = j; jj < min(j + block_size, MATRIX_SIZE); ++jj)
for (kk = k; kk < min(k + block_size, MATRIX_SIZE); ++kk)
C[i][jj] += A[i][kk] * B[kk][jj];
}
end_time = omp_get_wtime() - start_time;
end_time /= RUNS;
// printf("%lld\t\t%f\t\t%f\n", size, end_time, (end_time_c)/(end_time - end_time_c));
size_array[size/min_cache_line -1] = size;
compute_time_array[size/min_cache_line -1] = end_time;
CMA_array[size/min_cache_line -1] = (end_time_c)/(end_time - end_time_c);
int i=0;
for(i=0; i<8; i++) {
printf("%lld ", size_array[i]);
}
printf("\n");
for(i=0; i<8; i++) {
printf("%f ", compute_time_array[i]);
}
printf("\n");
for(i=0; i<8; i++) {
printf("%f ", CMA_array[i]);
}
printf("\n");
printf("================================================================");
printf("\n");
}
}
*/
}
| 31.230769 | 98 | 0.433028 |
2605682c5a8eaa54474180fadb30c104b498799e | 7,416 | h | C | analysis/projection3D/point_quantities.h | jfbucas/PION | e0a66aa301e4d94d581ba4df078f1a3b82faab99 | [
"BSD-3-Clause"
] | null | null | null | analysis/projection3D/point_quantities.h | jfbucas/PION | e0a66aa301e4d94d581ba4df078f1a3b82faab99 | [
"BSD-3-Clause"
] | null | null | null | analysis/projection3D/point_quantities.h | jfbucas/PION | e0a66aa301e4d94d581ba4df078f1a3b82faab99 | [
"BSD-3-Clause"
] | null | null | null | ///
/// \file point_quantities.h
/// \author Jonathan Mackey
/// \date 2015.08.06
///
/// This file defines a number or functions to calculate physical
/// properties of a point in space, by bilinear interpolation from
/// four other coplanar points.
///
/// Modifications:
/// - 2015.08.06 JM: Trying to avoid code duplication in
/// point_velocity and image classes, so both can derive from this
/// class.
/// - 2015.08.19 JM: Added get_point_RotationMeasure()
/// - 2015.10.13 JM: added 20cm Bremsstrahlung and Emission measure
/// - 2018.01.25 JM: added functions to request n(H+),n(H0),n(e-)
#ifndef POINT_QUANTITIES_H
#define POINT_QUANTITIES_H
#include "../xray/xray_emission.h"
///
/// integration point along line of sight of a pixel. This point
/// is to be placed along a plane of cells, so the state vector at the
/// point can be obtained by linear interpolation between two cells to the
/// left and right of the point (in that plane).
///
struct point_4cellavg {
cell *ngb[4]; ///< pointers to four surrounding cells.
pion_flt wt[4]; ///< weight of right cell value (wt of left=1-wt).
//pion_flt pos[3]; ///< position of point, in image coords.
};
///
/// Class for evaluating quantities at integration points.
///
class point_quantities : public Xray_emission {
public:
///
/// constructor does nothing
///
point_quantities() {}
///
/// destructor does nothing
///
virtual ~point_quantities() {}
protected:
///
/// Get the density at the point, based on 4 cell bilinear interpolation.
///
double get_point_density(
const struct point_4cellavg * ///< point
);
///
/// Get the e^- number density, using Microphysics function to get
/// the electron number density at each simulation point and then
/// interpolating.
///
double get_point_electron_numberdensity(
const struct point_4cellavg *
);
///
/// Get the H^+ number density, using Microphysics function to get
/// the ionized H number density at each simulation point and then
/// interpolating.
///
double get_point_ionizedH_numberdensity(
const struct point_4cellavg *
);
///
/// Get the H^0 number density, using Microphysics function to get
/// the neutral H number density at each simulation point and then
/// interpolating.
///
double get_point_neutralH_numberdensity(
const struct point_4cellavg *
);
///
/// Get the temperature at a point, based on 4-cell bilinear
/// interpolation. This uses a microphysics class to get T.
///
double get_point_temperature(
const struct point_4cellavg *, ///< point
const double gamma ///< EOS gamma
);
///
/// Get the Stokes Q component for the perpendicular magnetic field
///
double get_point_StokesQ(
struct point_4cellavg *, ///< pt
const int, ///< ifrac
const int, ///< bx index (image coords)
const int, ///< by index (image coords)
const int, ///< bz index (image coords)
const int, ///< sign(xx)
const int, ///< sign(yy)
const int, ///< sign(zz)
const double, ///< sin(theta)
const double ///< cos(theta)
);
///
/// Get the Stokes U component for the perpendicular magnetic field
///
double get_point_StokesU(
struct point_4cellavg *, ///< pt
const int, ///< ifrac
const int, ///< bx index (image coords)
const int, ///< by index (image coords)
const int, ///< bz index (image coords)
const int, ///< sign(xx)
const int, ///< sign(yy)
const int, ///< sign(zz)
const double, ///< sin(theta)
const double ///< cos(theta)
);
///
/// Get the |BX| component for the perpendicular magnetic field.
/// This returns sqrt(n_H)*Bx^2/|B|, so it's a density weighted
/// value and also diluted by the proportion of B on the los
/// direction
///
double get_point_BXabs(
struct point_4cellavg *, ///< pt
const int, ///< ifrac
const int, ///< bx index (image coords)
const int, ///< by index (image coords)
const int, ///< bz index (image coords)
const int, ///< sign(xx)
const int, ///< sign(yy)
const int, ///< sign(zz)
const double, ///< sin(theta)
const double ///< cos(theta)
);
///
/// Get the |BY| component for the perpendicular magnetic field.
/// This returns sqrt(n_H)*By^2/|B|, so it's a density weighted
/// value and also diluted by the proportion of B on the los
/// direction
///
double get_point_BYabs(
struct point_4cellavg *, ///< pt
const int, ///< ifrac
const int, ///< bx index (image coords)
const int, ///< by index (image coords)
const int, ///< bz index (image coords)
const int, ///< sign(xx)
const int, ///< sign(yy)
const int, ///< sign(zz)
const double, ///< sin(theta)
const double ///< cos(theta)
);
///
/// Get the Rotation measure along the line of sight. When
/// multiplied by the path length along each line segment (in pc)
/// and by sqrt(4pi) this gives the RM in units of rad/m^2.
/// It assumes n_e = n_H*y(H+), i.e. all electrons are from H-->H^+
///
double get_point_RotationMeasure(
struct point_4cellavg *, ///< pt
const int, ///< bx index (image coords)
const int, ///< bz index (image coords)
const int, ///< sign(xx)
const int, ///< sign(zz)
const double, ///< sin(theta)
const double ///< cos(theta)
);
///
/// Get the absorption and emission coefficients for H-alpha
/// radiation, according to a fit to Osterbrock's data table for
/// photoionised nebulae.
///
void get_point_Halpha_params(
const struct point_4cellavg *, ///< point in question.
const int, ///< ifrac index in prim.vec.
const double, ///< EOS gamma
double *, ///< absorption coefficient (/cm)
double * ///< emission coeff (erg/cm^3/s/sq.arcsec)
);
///
/// Get the absorption and emission coefficients for [N II] 6584AA
/// radiation, according to a fit from Dopita (1973,A&A,29,387).
///
void get_point_NII6584_params(
const struct point_4cellavg *, ///< point in question.
const int, ///< ifrac index in prim.vec.
const double, ///< EOS gamma
double *, ///< absorption coefficient (/cm)
double * ///< emission coeff (erg/cm^3/s/sq.arcsec)
);
///
/// Get the Emission Measure at a point, based on 4-cell bilinear
/// interpolation. Returns value in cm^{-6}
///
double get_point_EmissionMeasure(
const struct point_4cellavg *
);
///
/// Get the 20cm Bremsstrahlung at a point, based on 4-cell bilinear
/// interpolation. Returns value in MJy/sr/cm.
///
double get_point_Bremsstrahlung20cm(
const struct point_4cellavg *, ///< point
const double ///< EOS gamma
);
///
/// function to get the X-ray emissivity at a point, by reading
/// from an interpolation table.
///
void get_point_Xray_params(
const struct point_4cellavg *, ///< point in question.
const int, ///< ifrac index in prim.vec.
const int, ///< which X-ray emissivity to use (index in array).
const double, ///< EOS gamma
double *, ///< absorption coefficient (/cm)
double * ///< emission coeff (erg/cm^3/s/sq.arcsec)
);
};
#endif // POINT_QUANTITIES_H
| 30.771784 | 75 | 0.621899 |
d3f3dee089f88aa08c4bc070b6bd34c71082e30e | 435 | h | C | handlers/serverlog/include/transaction.h | Nadrin/mcproxy | 1a4d881d666ade5796f7577d72ffff1a8837f269 | [
"MIT"
] | 2 | 2019-11-22T06:13:25.000Z | 2022-01-17T17:19:33.000Z | handlers/serverlog/include/transaction.h | Nadrin/mcproxy | 1a4d881d666ade5796f7577d72ffff1a8837f269 | [
"MIT"
] | null | null | null | handlers/serverlog/include/transaction.h | Nadrin/mcproxy | 1a4d881d666ade5796f7577d72ffff1a8837f269 | [
"MIT"
] | null | null | null | /* Minecraft Protocol Proxy (mcproxy)
* Copyright (c) 2011 Michał Siejak
* ServerLog handler library.
*
* Licensed under MIT open-source license.
* See COPYING file for details.
*/
#ifndef __MCPROXY_HANDLERS_TRANSACTION_H
#define __MCPROXY_HANDLERS_TRANSACTION_H
int transact_handler_main(cid_t client_id, char direction, unsigned char msg_id,
nethost_t* hfrom, nethost_t* hto, objlist_t* data,
void* extra);
#endif
| 25.588235 | 80 | 0.765517 |
2ffa8d8dadeec0ca4281e26f8889c89be1653774 | 53,041 | h | C | Include/10.0.17763.0/cppwinrt/winrt/impl/Windows.Management.Deployment.0.h | sezero/windows-sdk-headers | e8e9d4d50769ded01a2df905c6bf4355eb3fa8b5 | [
"MIT"
] | 5 | 2020-05-29T06:22:17.000Z | 2021-11-28T08:21:38.000Z | Include/10.0.17763.0/cppwinrt/winrt/impl/Windows.Management.Deployment.0.h | sezero/windows-sdk-headers | e8e9d4d50769ded01a2df905c6bf4355eb3fa8b5 | [
"MIT"
] | null | null | null | Include/10.0.17763.0/cppwinrt/winrt/impl/Windows.Management.Deployment.0.h | sezero/windows-sdk-headers | e8e9d4d50769ded01a2df905c6bf4355eb3fa8b5 | [
"MIT"
] | 5 | 2020-05-30T04:15:11.000Z | 2021-11-28T08:48:56.000Z | // C++/WinRT v1.0.180821.2
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
WINRT_EXPORT namespace winrt::Windows::ApplicationModel {
enum class PackageContentGroupState;
struct Package;
}
WINRT_EXPORT namespace winrt::Windows::Foundation {
struct Uri;
}
WINRT_EXPORT namespace winrt::Windows::Management::Deployment {
enum class AddPackageByAppInstallerOptions : uint32_t
{
None = 0x0,
InstallAllResources = 0x20,
ForceTargetAppShutdown = 0x40,
RequiredContentGroupOnly = 0x100,
};
enum class DeploymentOptions : uint32_t
{
None = 0x0,
ForceApplicationShutdown = 0x1,
DevelopmentMode = 0x2,
InstallAllResources = 0x20,
ForceTargetApplicationShutdown = 0x40,
RequiredContentGroupOnly = 0x100,
ForceUpdateFromAnyVersion = 0x40000,
};
enum class DeploymentProgressState : int32_t
{
Queued = 0,
Processing = 1,
};
enum class PackageInstallState : int32_t
{
NotInstalled = 0,
Staged = 1,
Installed = 2,
Paused = 6,
};
enum class PackageState : int32_t
{
Normal = 0,
LicenseInvalid = 1,
Modified = 2,
Tampered = 3,
};
enum class PackageStatus : uint32_t
{
OK = 0x0,
LicenseIssue = 0x1,
Modified = 0x2,
Tampered = 0x4,
Disabled = 0x8,
};
enum class PackageTypes : uint32_t
{
None = 0x0,
Main = 0x1,
Framework = 0x2,
Resource = 0x4,
Bundle = 0x8,
Xap = 0x10,
Optional = 0x20,
};
enum class RemovalOptions : uint32_t
{
None = 0x0,
PreserveApplicationData = 0x1000,
RemoveForAllUsers = 0x80000,
};
struct IDeploymentResult;
struct IDeploymentResult2;
struct IPackageManager;
struct IPackageManager2;
struct IPackageManager3;
struct IPackageManager4;
struct IPackageManager5;
struct IPackageManager6;
struct IPackageManager7;
struct IPackageManager8;
struct IPackageManagerDebugSettings;
struct IPackageUserInformation;
struct IPackageVolume;
struct IPackageVolume2;
struct DeploymentResult;
struct PackageManager;
struct PackageManagerDebugSettings;
struct PackageUserInformation;
struct PackageVolume;
struct DeploymentProgress;
}
namespace winrt::impl {
template<> struct is_enum_flag<Windows::Management::Deployment::AddPackageByAppInstallerOptions> : std::true_type {};
template<> struct is_enum_flag<Windows::Management::Deployment::DeploymentOptions> : std::true_type {};
template<> struct is_enum_flag<Windows::Management::Deployment::PackageStatus> : std::true_type {};
template<> struct is_enum_flag<Windows::Management::Deployment::PackageTypes> : std::true_type {};
template<> struct is_enum_flag<Windows::Management::Deployment::RemovalOptions> : std::true_type {};
template <> struct category<Windows::Management::Deployment::IDeploymentResult>{ using type = interface_category; };
template <> struct category<Windows::Management::Deployment::IDeploymentResult2>{ using type = interface_category; };
template <> struct category<Windows::Management::Deployment::IPackageManager>{ using type = interface_category; };
template <> struct category<Windows::Management::Deployment::IPackageManager2>{ using type = interface_category; };
template <> struct category<Windows::Management::Deployment::IPackageManager3>{ using type = interface_category; };
template <> struct category<Windows::Management::Deployment::IPackageManager4>{ using type = interface_category; };
template <> struct category<Windows::Management::Deployment::IPackageManager5>{ using type = interface_category; };
template <> struct category<Windows::Management::Deployment::IPackageManager6>{ using type = interface_category; };
template <> struct category<Windows::Management::Deployment::IPackageManager7>{ using type = interface_category; };
template <> struct category<Windows::Management::Deployment::IPackageManager8>{ using type = interface_category; };
template <> struct category<Windows::Management::Deployment::IPackageManagerDebugSettings>{ using type = interface_category; };
template <> struct category<Windows::Management::Deployment::IPackageUserInformation>{ using type = interface_category; };
template <> struct category<Windows::Management::Deployment::IPackageVolume>{ using type = interface_category; };
template <> struct category<Windows::Management::Deployment::IPackageVolume2>{ using type = interface_category; };
template <> struct category<Windows::Management::Deployment::DeploymentResult>{ using type = class_category; };
template <> struct category<Windows::Management::Deployment::PackageManager>{ using type = class_category; };
template <> struct category<Windows::Management::Deployment::PackageManagerDebugSettings>{ using type = class_category; };
template <> struct category<Windows::Management::Deployment::PackageUserInformation>{ using type = class_category; };
template <> struct category<Windows::Management::Deployment::PackageVolume>{ using type = class_category; };
template <> struct category<Windows::Management::Deployment::AddPackageByAppInstallerOptions>{ using type = enum_category; };
template <> struct category<Windows::Management::Deployment::DeploymentOptions>{ using type = enum_category; };
template <> struct category<Windows::Management::Deployment::DeploymentProgressState>{ using type = enum_category; };
template <> struct category<Windows::Management::Deployment::PackageInstallState>{ using type = enum_category; };
template <> struct category<Windows::Management::Deployment::PackageState>{ using type = enum_category; };
template <> struct category<Windows::Management::Deployment::PackageStatus>{ using type = enum_category; };
template <> struct category<Windows::Management::Deployment::PackageTypes>{ using type = enum_category; };
template <> struct category<Windows::Management::Deployment::RemovalOptions>{ using type = enum_category; };
template <> struct category<Windows::Management::Deployment::DeploymentProgress>{ using type = struct_category<Windows::Management::Deployment::DeploymentProgressState,uint32_t>; };
template <> struct name<Windows::Management::Deployment::IDeploymentResult>{ static constexpr auto & value{ L"Windows.Management.Deployment.IDeploymentResult" }; };
template <> struct name<Windows::Management::Deployment::IDeploymentResult2>{ static constexpr auto & value{ L"Windows.Management.Deployment.IDeploymentResult2" }; };
template <> struct name<Windows::Management::Deployment::IPackageManager>{ static constexpr auto & value{ L"Windows.Management.Deployment.IPackageManager" }; };
template <> struct name<Windows::Management::Deployment::IPackageManager2>{ static constexpr auto & value{ L"Windows.Management.Deployment.IPackageManager2" }; };
template <> struct name<Windows::Management::Deployment::IPackageManager3>{ static constexpr auto & value{ L"Windows.Management.Deployment.IPackageManager3" }; };
template <> struct name<Windows::Management::Deployment::IPackageManager4>{ static constexpr auto & value{ L"Windows.Management.Deployment.IPackageManager4" }; };
template <> struct name<Windows::Management::Deployment::IPackageManager5>{ static constexpr auto & value{ L"Windows.Management.Deployment.IPackageManager5" }; };
template <> struct name<Windows::Management::Deployment::IPackageManager6>{ static constexpr auto & value{ L"Windows.Management.Deployment.IPackageManager6" }; };
template <> struct name<Windows::Management::Deployment::IPackageManager7>{ static constexpr auto & value{ L"Windows.Management.Deployment.IPackageManager7" }; };
template <> struct name<Windows::Management::Deployment::IPackageManager8>{ static constexpr auto & value{ L"Windows.Management.Deployment.IPackageManager8" }; };
template <> struct name<Windows::Management::Deployment::IPackageManagerDebugSettings>{ static constexpr auto & value{ L"Windows.Management.Deployment.IPackageManagerDebugSettings" }; };
template <> struct name<Windows::Management::Deployment::IPackageUserInformation>{ static constexpr auto & value{ L"Windows.Management.Deployment.IPackageUserInformation" }; };
template <> struct name<Windows::Management::Deployment::IPackageVolume>{ static constexpr auto & value{ L"Windows.Management.Deployment.IPackageVolume" }; };
template <> struct name<Windows::Management::Deployment::IPackageVolume2>{ static constexpr auto & value{ L"Windows.Management.Deployment.IPackageVolume2" }; };
template <> struct name<Windows::Management::Deployment::DeploymentResult>{ static constexpr auto & value{ L"Windows.Management.Deployment.DeploymentResult" }; };
template <> struct name<Windows::Management::Deployment::PackageManager>{ static constexpr auto & value{ L"Windows.Management.Deployment.PackageManager" }; };
template <> struct name<Windows::Management::Deployment::PackageManagerDebugSettings>{ static constexpr auto & value{ L"Windows.Management.Deployment.PackageManagerDebugSettings" }; };
template <> struct name<Windows::Management::Deployment::PackageUserInformation>{ static constexpr auto & value{ L"Windows.Management.Deployment.PackageUserInformation" }; };
template <> struct name<Windows::Management::Deployment::PackageVolume>{ static constexpr auto & value{ L"Windows.Management.Deployment.PackageVolume" }; };
template <> struct name<Windows::Management::Deployment::AddPackageByAppInstallerOptions>{ static constexpr auto & value{ L"Windows.Management.Deployment.AddPackageByAppInstallerOptions" }; };
template <> struct name<Windows::Management::Deployment::DeploymentOptions>{ static constexpr auto & value{ L"Windows.Management.Deployment.DeploymentOptions" }; };
template <> struct name<Windows::Management::Deployment::DeploymentProgressState>{ static constexpr auto & value{ L"Windows.Management.Deployment.DeploymentProgressState" }; };
template <> struct name<Windows::Management::Deployment::PackageInstallState>{ static constexpr auto & value{ L"Windows.Management.Deployment.PackageInstallState" }; };
template <> struct name<Windows::Management::Deployment::PackageState>{ static constexpr auto & value{ L"Windows.Management.Deployment.PackageState" }; };
template <> struct name<Windows::Management::Deployment::PackageStatus>{ static constexpr auto & value{ L"Windows.Management.Deployment.PackageStatus" }; };
template <> struct name<Windows::Management::Deployment::PackageTypes>{ static constexpr auto & value{ L"Windows.Management.Deployment.PackageTypes" }; };
template <> struct name<Windows::Management::Deployment::RemovalOptions>{ static constexpr auto & value{ L"Windows.Management.Deployment.RemovalOptions" }; };
template <> struct name<Windows::Management::Deployment::DeploymentProgress>{ static constexpr auto & value{ L"Windows.Management.Deployment.DeploymentProgress" }; };
template <> struct guid_storage<Windows::Management::Deployment::IDeploymentResult>{ static constexpr guid value{ 0x2563B9AE,0xB77D,0x4C1F,{ 0x8A,0x7B,0x20,0xE6,0xAD,0x51,0x5E,0xF3 } }; };
template <> struct guid_storage<Windows::Management::Deployment::IDeploymentResult2>{ static constexpr guid value{ 0xFC0E715C,0x5A01,0x4BD7,{ 0xBC,0xF1,0x38,0x1C,0x8C,0x82,0xE0,0x4A } }; };
template <> struct guid_storage<Windows::Management::Deployment::IPackageManager>{ static constexpr guid value{ 0x9A7D4B65,0x5E8F,0x4FC7,{ 0xA2,0xE5,0x7F,0x69,0x25,0xCB,0x8B,0x53 } }; };
template <> struct guid_storage<Windows::Management::Deployment::IPackageManager2>{ static constexpr guid value{ 0xF7AAD08D,0x0840,0x46F2,{ 0xB5,0xD8,0xCA,0xD4,0x76,0x93,0xA0,0x95 } }; };
template <> struct guid_storage<Windows::Management::Deployment::IPackageManager3>{ static constexpr guid value{ 0xDAAD9948,0x36F1,0x41A7,{ 0x91,0x88,0xBC,0x26,0x3E,0x0D,0xCB,0x72 } }; };
template <> struct guid_storage<Windows::Management::Deployment::IPackageManager4>{ static constexpr guid value{ 0x3C719963,0xBAB6,0x46BF,{ 0x8F,0xF7,0xDA,0x47,0x19,0x23,0x0A,0xE6 } }; };
template <> struct guid_storage<Windows::Management::Deployment::IPackageManager5>{ static constexpr guid value{ 0x711F3117,0x1AFD,0x4313,{ 0x97,0x8C,0x9B,0xB6,0xE1,0xB8,0x64,0xA7 } }; };
template <> struct guid_storage<Windows::Management::Deployment::IPackageManager6>{ static constexpr guid value{ 0x0847E909,0x53CD,0x4E4F,{ 0x83,0x2E,0x57,0xD1,0x80,0xF6,0xE4,0x47 } }; };
template <> struct guid_storage<Windows::Management::Deployment::IPackageManager7>{ static constexpr guid value{ 0xF28654F4,0x2BA7,0x4B80,{ 0x88,0xD6,0xBE,0x15,0xF9,0xA2,0x3F,0xBA } }; };
template <> struct guid_storage<Windows::Management::Deployment::IPackageManager8>{ static constexpr guid value{ 0xB8575330,0x1298,0x4EE2,{ 0x80,0xEE,0x7F,0x65,0x9C,0x5D,0x27,0x82 } }; };
template <> struct guid_storage<Windows::Management::Deployment::IPackageManagerDebugSettings>{ static constexpr guid value{ 0x1A611683,0xA988,0x4FCF,{ 0x8F,0x0F,0xCE,0x17,0x58,0x98,0xE8,0xEB } }; };
template <> struct guid_storage<Windows::Management::Deployment::IPackageUserInformation>{ static constexpr guid value{ 0xF6383423,0xFA09,0x4CBC,{ 0x90,0x55,0x15,0xCA,0x27,0x5E,0x2E,0x7E } }; };
template <> struct guid_storage<Windows::Management::Deployment::IPackageVolume>{ static constexpr guid value{ 0xCF2672C3,0x1A40,0x4450,{ 0x97,0x39,0x2A,0xCE,0x2E,0x89,0x88,0x53 } }; };
template <> struct guid_storage<Windows::Management::Deployment::IPackageVolume2>{ static constexpr guid value{ 0x46ABCF2E,0x9DD4,0x47A2,{ 0xAB,0x8C,0xC6,0x40,0x83,0x49,0xBC,0xD8 } }; };
template <> struct default_interface<Windows::Management::Deployment::DeploymentResult>{ using type = Windows::Management::Deployment::IDeploymentResult; };
template <> struct default_interface<Windows::Management::Deployment::PackageManager>{ using type = Windows::Management::Deployment::IPackageManager; };
template <> struct default_interface<Windows::Management::Deployment::PackageManagerDebugSettings>{ using type = Windows::Management::Deployment::IPackageManagerDebugSettings; };
template <> struct default_interface<Windows::Management::Deployment::PackageUserInformation>{ using type = Windows::Management::Deployment::IPackageUserInformation; };
template <> struct default_interface<Windows::Management::Deployment::PackageVolume>{ using type = Windows::Management::Deployment::IPackageVolume; };
template <> struct abi<Windows::Management::Deployment::IDeploymentResult>{ struct type : IInspectable
{
virtual int32_t WINRT_CALL get_ErrorText(void** value) noexcept = 0;
virtual int32_t WINRT_CALL get_ActivityId(winrt::guid* value) noexcept = 0;
virtual int32_t WINRT_CALL get_ExtendedErrorCode(winrt::hresult* value) noexcept = 0;
};};
template <> struct abi<Windows::Management::Deployment::IDeploymentResult2>{ struct type : IInspectable
{
virtual int32_t WINRT_CALL get_IsRegistered(bool* value) noexcept = 0;
};};
template <> struct abi<Windows::Management::Deployment::IPackageManager>{ struct type : IInspectable
{
virtual int32_t WINRT_CALL AddPackageAsync(void* packageUri, void* dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions deploymentOptions, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL UpdatePackageAsync(void* packageUri, void* dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions deploymentOptions, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL RemovePackageAsync(void* packageFullName, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL StagePackageAsync(void* packageUri, void* dependencyPackageUris, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL RegisterPackageAsync(void* manifestUri, void* dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions deploymentOptions, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL FindPackages(void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByUserSecurityId(void* userSecurityId, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByNamePublisher(void* packageName, void* packagePublisher, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByUserSecurityIdNamePublisher(void* userSecurityId, void* packageName, void* packagePublisher, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindUsers(void* packageFullName, void** users) noexcept = 0;
virtual int32_t WINRT_CALL SetPackageState(void* packageFullName, Windows::Management::Deployment::PackageState packageState) noexcept = 0;
virtual int32_t WINRT_CALL FindPackageByPackageFullName(void* packageFullName, void** packageInformation) noexcept = 0;
virtual int32_t WINRT_CALL CleanupPackageForUserAsync(void* packageName, void* userSecurityId, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByPackageFamilyName(void* packageFamilyName, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByUserSecurityIdPackageFamilyName(void* userSecurityId, void* packageFamilyName, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackageByUserSecurityIdPackageFullName(void* userSecurityId, void* packageFullName, void** packageInformation) noexcept = 0;
};};
template <> struct abi<Windows::Management::Deployment::IPackageManager2>{ struct type : IInspectable
{
virtual int32_t WINRT_CALL RemovePackageWithOptionsAsync(void* packageFullName, Windows::Management::Deployment::RemovalOptions removalOptions, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL StagePackageWithOptionsAsync(void* packageUri, void* dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions deploymentOptions, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL RegisterPackageByFullNameAsync(void* mainPackageFullName, void* dependencyPackageFullNames, Windows::Management::Deployment::DeploymentOptions deploymentOptions, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesWithPackageTypes(Windows::Management::Deployment::PackageTypes packageTypes, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByUserSecurityIdWithPackageTypes(void* userSecurityId, Windows::Management::Deployment::PackageTypes packageTypes, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByNamePublisherWithPackageTypes(void* packageName, void* packagePublisher, Windows::Management::Deployment::PackageTypes packageTypes, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByUserSecurityIdNamePublisherWithPackageTypes(void* userSecurityId, void* packageName, void* packagePublisher, Windows::Management::Deployment::PackageTypes packageTypes, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByPackageFamilyNameWithPackageTypes(void* packageFamilyName, Windows::Management::Deployment::PackageTypes packageTypes, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByUserSecurityIdPackageFamilyNameWithPackageTypes(void* userSecurityId, void* packageFamilyName, Windows::Management::Deployment::PackageTypes packageTypes, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL StageUserDataAsync(void* packageFullName, void** deploymentOperation) noexcept = 0;
};};
template <> struct abi<Windows::Management::Deployment::IPackageManager3>{ struct type : IInspectable
{
virtual int32_t WINRT_CALL AddPackageVolumeAsync(void* packageStorePath, void** packageVolume) noexcept = 0;
virtual int32_t WINRT_CALL AddPackageToVolumeAsync(void* packageUri, void* dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions deploymentOptions, void* targetVolume, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL ClearPackageStatus(void* packageFullName, Windows::Management::Deployment::PackageStatus status) noexcept = 0;
virtual int32_t WINRT_CALL RegisterPackageWithAppDataVolumeAsync(void* manifestUri, void* dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions deploymentOptions, void* appDataVolume, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL FindPackageVolumeByName(void* volumeName, void** volume) noexcept = 0;
virtual int32_t WINRT_CALL FindPackageVolumes(void** volumeCollection) noexcept = 0;
virtual int32_t WINRT_CALL GetDefaultPackageVolume(void** volume) noexcept = 0;
virtual int32_t WINRT_CALL MovePackageToVolumeAsync(void* packageFullName, Windows::Management::Deployment::DeploymentOptions deploymentOptions, void* targetVolume, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL RemovePackageVolumeAsync(void* volume, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL SetDefaultPackageVolume(void* volume) noexcept = 0;
virtual int32_t WINRT_CALL SetPackageStatus(void* packageFullName, Windows::Management::Deployment::PackageStatus status) noexcept = 0;
virtual int32_t WINRT_CALL SetPackageVolumeOfflineAsync(void* packageVolume, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL SetPackageVolumeOnlineAsync(void* packageVolume, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL StagePackageToVolumeAsync(void* packageUri, void* dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions deploymentOptions, void* targetVolume, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL StageUserDataWithOptionsAsync(void* packageFullName, Windows::Management::Deployment::DeploymentOptions deploymentOptions, void** deploymentOperation) noexcept = 0;
};};
template <> struct abi<Windows::Management::Deployment::IPackageManager4>{ struct type : IInspectable
{
virtual int32_t WINRT_CALL GetPackageVolumesAsync(void** operation) noexcept = 0;
};};
template <> struct abi<Windows::Management::Deployment::IPackageManager5>{ struct type : IInspectable
{
virtual int32_t WINRT_CALL AddPackageToVolumeAndOptionalPackagesAsync(void* packageUri, void* dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions deploymentOptions, void* targetVolume, void* optionalPackageFamilyNames, void* externalPackageUris, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL StagePackageToVolumeAndOptionalPackagesAsync(void* packageUri, void* dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions deploymentOptions, void* targetVolume, void* optionalPackageFamilyNames, void* externalPackageUris, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL RegisterPackageByFamilyNameAndOptionalPackagesAsync(void* mainPackageFamilyName, void* dependencyPackageFamilyNames, Windows::Management::Deployment::DeploymentOptions deploymentOptions, void* appDataVolume, void* optionalPackageFamilyNames, void** deploymentOperation) noexcept = 0;
virtual int32_t WINRT_CALL get_DebugSettings(void** value) noexcept = 0;
};};
template <> struct abi<Windows::Management::Deployment::IPackageManager6>{ struct type : IInspectable
{
virtual int32_t WINRT_CALL ProvisionPackageForAllUsersAsync(void* packageFamilyName, void** operation) noexcept = 0;
virtual int32_t WINRT_CALL AddPackageByAppInstallerFileAsync(void* appInstallerFileUri, Windows::Management::Deployment::AddPackageByAppInstallerOptions options, void* targetVolume, void** operation) noexcept = 0;
virtual int32_t WINRT_CALL RequestAddPackageByAppInstallerFileAsync(void* appInstallerFileUri, Windows::Management::Deployment::AddPackageByAppInstallerOptions options, void* targetVolume, void** operation) noexcept = 0;
virtual int32_t WINRT_CALL AddPackageToVolumeAndRelatedSetAsync(void* packageUri, void* dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions options, void* targetVolume, void* optionalPackageFamilyNames, void* packageUrisToInstall, void* relatedPackageUris, void** operation) noexcept = 0;
virtual int32_t WINRT_CALL StagePackageToVolumeAndRelatedSetAsync(void* packageUri, void* dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions options, void* targetVolume, void* optionalPackageFamilyNames, void* packageUrisToInstall, void* relatedPackageUris, void** operation) noexcept = 0;
virtual int32_t WINRT_CALL RequestAddPackageAsync(void* packageUri, void* dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions deploymentOptions, void* targetVolume, void* optionalPackageFamilyNames, void* relatedPackageUris, void** operation) noexcept = 0;
};};
template <> struct abi<Windows::Management::Deployment::IPackageManager7>{ struct type : IInspectable
{
virtual int32_t WINRT_CALL RequestAddPackageAndRelatedSetAsync(void* packageUri, void* dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions deploymentOptions, void* targetVolume, void* optionalPackageFamilyNames, void* relatedPackageUris, void* packageUrisToInstall, void** operation) noexcept = 0;
};};
template <> struct abi<Windows::Management::Deployment::IPackageManager8>{ struct type : IInspectable
{
virtual int32_t WINRT_CALL DeprovisionPackageForAllUsersAsync(void* packageFamilyName, void** operation) noexcept = 0;
};};
template <> struct abi<Windows::Management::Deployment::IPackageManagerDebugSettings>{ struct type : IInspectable
{
virtual int32_t WINRT_CALL SetContentGroupStateAsync(void* package, void* contentGroupName, Windows::ApplicationModel::PackageContentGroupState state, void** action) noexcept = 0;
virtual int32_t WINRT_CALL SetContentGroupStateWithPercentageAsync(void* package, void* contentGroupName, Windows::ApplicationModel::PackageContentGroupState state, double completionPercentage, void** action) noexcept = 0;
};};
template <> struct abi<Windows::Management::Deployment::IPackageUserInformation>{ struct type : IInspectable
{
virtual int32_t WINRT_CALL get_UserSecurityId(void** value) noexcept = 0;
virtual int32_t WINRT_CALL get_InstallState(Windows::Management::Deployment::PackageInstallState* value) noexcept = 0;
};};
template <> struct abi<Windows::Management::Deployment::IPackageVolume>{ struct type : IInspectable
{
virtual int32_t WINRT_CALL get_IsOffline(bool* value) noexcept = 0;
virtual int32_t WINRT_CALL get_IsSystemVolume(bool* value) noexcept = 0;
virtual int32_t WINRT_CALL get_MountPoint(void** value) noexcept = 0;
virtual int32_t WINRT_CALL get_Name(void** value) noexcept = 0;
virtual int32_t WINRT_CALL get_PackageStorePath(void** value) noexcept = 0;
virtual int32_t WINRT_CALL get_SupportsHardLinks(bool* value) noexcept = 0;
virtual int32_t WINRT_CALL FindPackages(void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByNamePublisher(void* packageName, void* packagePublisher, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByPackageFamilyName(void* packageFamilyName, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesWithPackageTypes(Windows::Management::Deployment::PackageTypes packageTypes, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByNamePublisherWithPackagesTypes(Windows::Management::Deployment::PackageTypes packageTypes, void* packageName, void* packagePublisher, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByPackageFamilyNameWithPackageTypes(Windows::Management::Deployment::PackageTypes packageTypes, void* packageFamilyName, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackageByPackageFullName(void* packageFullName, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByUserSecurityId(void* userSecurityId, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByUserSecurityIdNamePublisher(void* userSecurityId, void* packageName, void* packagePublisher, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByUserSecurityIdPackageFamilyName(void* userSecurityId, void* packageFamilyName, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByUserSecurityIdWithPackageTypes(void* userSecurityId, Windows::Management::Deployment::PackageTypes packageTypes, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByUserSecurityIdNamePublisherWithPackageTypes(void* userSecurityId, Windows::Management::Deployment::PackageTypes packageTypes, void* packageName, void* packagePublisher, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackagesByUserSecurityIdPackageFamilyNameWithPackagesTypes(void* userSecurityId, Windows::Management::Deployment::PackageTypes packageTypes, void* packageFamilyName, void** packageCollection) noexcept = 0;
virtual int32_t WINRT_CALL FindPackageByUserSecurityIdPackageFullName(void* userSecurityId, void* packageFullName, void** packageCollection) noexcept = 0;
};};
template <> struct abi<Windows::Management::Deployment::IPackageVolume2>{ struct type : IInspectable
{
virtual int32_t WINRT_CALL get_IsFullTrustPackageSupported(bool* value) noexcept = 0;
virtual int32_t WINRT_CALL get_IsAppxInstallSupported(bool* value) noexcept = 0;
virtual int32_t WINRT_CALL GetAvailableSpaceAsync(void** operation) noexcept = 0;
};};
template <typename D>
struct consume_Windows_Management_Deployment_IDeploymentResult
{
hstring ErrorText() const;
winrt::guid ActivityId() const;
winrt::hresult ExtendedErrorCode() const;
};
template <> struct consume<Windows::Management::Deployment::IDeploymentResult> { template <typename D> using type = consume_Windows_Management_Deployment_IDeploymentResult<D>; };
template <typename D>
struct consume_Windows_Management_Deployment_IDeploymentResult2
{
bool IsRegistered() const;
};
template <> struct consume<Windows::Management::Deployment::IDeploymentResult2> { template <typename D> using type = consume_Windows_Management_Deployment_IDeploymentResult2<D>; };
template <typename D>
struct consume_Windows_Management_Deployment_IPackageManager
{
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> AddPackageAsync(Windows::Foundation::Uri const& packageUri, param::async_iterable<Windows::Foundation::Uri> const& dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions const& deploymentOptions) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> UpdatePackageAsync(Windows::Foundation::Uri const& packageUri, param::async_iterable<Windows::Foundation::Uri> const& dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions const& deploymentOptions) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> RemovePackageAsync(param::hstring const& packageFullName) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> StagePackageAsync(Windows::Foundation::Uri const& packageUri, param::async_iterable<Windows::Foundation::Uri> const& dependencyPackageUris) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> RegisterPackageAsync(Windows::Foundation::Uri const& manifestUri, param::async_iterable<Windows::Foundation::Uri> const& dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions const& deploymentOptions) const;
Windows::Foundation::Collections::IIterable<Windows::ApplicationModel::Package> FindPackages() const;
Windows::Foundation::Collections::IIterable<Windows::ApplicationModel::Package> FindPackagesForUser(param::hstring const& userSecurityId) const;
Windows::Foundation::Collections::IIterable<Windows::ApplicationModel::Package> FindPackages(param::hstring const& packageName, param::hstring const& packagePublisher) const;
Windows::Foundation::Collections::IIterable<Windows::ApplicationModel::Package> FindPackagesForUser(param::hstring const& userSecurityId, param::hstring const& packageName, param::hstring const& packagePublisher) const;
Windows::Foundation::Collections::IIterable<Windows::Management::Deployment::PackageUserInformation> FindUsers(param::hstring const& packageFullName) const;
void SetPackageState(param::hstring const& packageFullName, Windows::Management::Deployment::PackageState const& packageState) const;
Windows::ApplicationModel::Package FindPackage(param::hstring const& packageFullName) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> CleanupPackageForUserAsync(param::hstring const& packageName, param::hstring const& userSecurityId) const;
Windows::Foundation::Collections::IIterable<Windows::ApplicationModel::Package> FindPackages(param::hstring const& packageFamilyName) const;
Windows::Foundation::Collections::IIterable<Windows::ApplicationModel::Package> FindPackagesForUser(param::hstring const& userSecurityId, param::hstring const& packageFamilyName) const;
Windows::ApplicationModel::Package FindPackageForUser(param::hstring const& userSecurityId, param::hstring const& packageFullName) const;
};
template <> struct consume<Windows::Management::Deployment::IPackageManager> { template <typename D> using type = consume_Windows_Management_Deployment_IPackageManager<D>; };
template <typename D>
struct consume_Windows_Management_Deployment_IPackageManager2
{
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> RemovePackageAsync(param::hstring const& packageFullName, Windows::Management::Deployment::RemovalOptions const& removalOptions) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> StagePackageAsync(Windows::Foundation::Uri const& packageUri, param::async_iterable<Windows::Foundation::Uri> const& dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions const& deploymentOptions) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> RegisterPackageByFullNameAsync(param::hstring const& mainPackageFullName, param::async_iterable<hstring> const& dependencyPackageFullNames, Windows::Management::Deployment::DeploymentOptions const& deploymentOptions) const;
Windows::Foundation::Collections::IIterable<Windows::ApplicationModel::Package> FindPackagesWithPackageTypes(Windows::Management::Deployment::PackageTypes const& packageTypes) const;
Windows::Foundation::Collections::IIterable<Windows::ApplicationModel::Package> FindPackagesForUserWithPackageTypes(param::hstring const& userSecurityId, Windows::Management::Deployment::PackageTypes const& packageTypes) const;
Windows::Foundation::Collections::IIterable<Windows::ApplicationModel::Package> FindPackagesWithPackageTypes(param::hstring const& packageName, param::hstring const& packagePublisher, Windows::Management::Deployment::PackageTypes const& packageTypes) const;
Windows::Foundation::Collections::IIterable<Windows::ApplicationModel::Package> FindPackagesForUserWithPackageTypes(param::hstring const& userSecurityId, param::hstring const& packageName, param::hstring const& packagePublisher, Windows::Management::Deployment::PackageTypes const& packageTypes) const;
Windows::Foundation::Collections::IIterable<Windows::ApplicationModel::Package> FindPackagesWithPackageTypes(param::hstring const& packageFamilyName, Windows::Management::Deployment::PackageTypes const& packageTypes) const;
Windows::Foundation::Collections::IIterable<Windows::ApplicationModel::Package> FindPackagesForUserWithPackageTypes(param::hstring const& userSecurityId, param::hstring const& packageFamilyName, Windows::Management::Deployment::PackageTypes const& packageTypes) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> StageUserDataAsync(param::hstring const& packageFullName) const;
};
template <> struct consume<Windows::Management::Deployment::IPackageManager2> { template <typename D> using type = consume_Windows_Management_Deployment_IPackageManager2<D>; };
template <typename D>
struct consume_Windows_Management_Deployment_IPackageManager3
{
Windows::Foundation::IAsyncOperation<Windows::Management::Deployment::PackageVolume> AddPackageVolumeAsync(param::hstring const& packageStorePath) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> AddPackageAsync(Windows::Foundation::Uri const& packageUri, param::async_iterable<Windows::Foundation::Uri> const& dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions const& deploymentOptions, Windows::Management::Deployment::PackageVolume const& targetVolume) const;
void ClearPackageStatus(param::hstring const& packageFullName, Windows::Management::Deployment::PackageStatus const& status) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> RegisterPackageAsync(Windows::Foundation::Uri const& manifestUri, param::async_iterable<Windows::Foundation::Uri> const& dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions const& deploymentOptions, Windows::Management::Deployment::PackageVolume const& appDataVolume) const;
Windows::Management::Deployment::PackageVolume FindPackageVolume(param::hstring const& volumeName) const;
Windows::Foundation::Collections::IIterable<Windows::Management::Deployment::PackageVolume> FindPackageVolumes() const;
Windows::Management::Deployment::PackageVolume GetDefaultPackageVolume() const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> MovePackageToVolumeAsync(param::hstring const& packageFullName, Windows::Management::Deployment::DeploymentOptions const& deploymentOptions, Windows::Management::Deployment::PackageVolume const& targetVolume) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> RemovePackageVolumeAsync(Windows::Management::Deployment::PackageVolume const& volume) const;
void SetDefaultPackageVolume(Windows::Management::Deployment::PackageVolume const& volume) const;
void SetPackageStatus(param::hstring const& packageFullName, Windows::Management::Deployment::PackageStatus const& status) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> SetPackageVolumeOfflineAsync(Windows::Management::Deployment::PackageVolume const& packageVolume) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> SetPackageVolumeOnlineAsync(Windows::Management::Deployment::PackageVolume const& packageVolume) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> StagePackageAsync(Windows::Foundation::Uri const& packageUri, param::async_iterable<Windows::Foundation::Uri> const& dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions const& deploymentOptions, Windows::Management::Deployment::PackageVolume const& targetVolume) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> StageUserDataAsync(param::hstring const& packageFullName, Windows::Management::Deployment::DeploymentOptions const& deploymentOptions) const;
};
template <> struct consume<Windows::Management::Deployment::IPackageManager3> { template <typename D> using type = consume_Windows_Management_Deployment_IPackageManager3<D>; };
template <typename D>
struct consume_Windows_Management_Deployment_IPackageManager4
{
Windows::Foundation::IAsyncOperation<Windows::Foundation::Collections::IVectorView<Windows::Management::Deployment::PackageVolume>> GetPackageVolumesAsync() const;
};
template <> struct consume<Windows::Management::Deployment::IPackageManager4> { template <typename D> using type = consume_Windows_Management_Deployment_IPackageManager4<D>; };
template <typename D>
struct consume_Windows_Management_Deployment_IPackageManager5
{
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> AddPackageAsync(Windows::Foundation::Uri const& packageUri, param::async_iterable<Windows::Foundation::Uri> const& dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions const& deploymentOptions, Windows::Management::Deployment::PackageVolume const& targetVolume, param::async_iterable<hstring> const& optionalPackageFamilyNames, param::async_iterable<Windows::Foundation::Uri> const& externalPackageUris) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> StagePackageAsync(Windows::Foundation::Uri const& packageUri, param::async_iterable<Windows::Foundation::Uri> const& dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions const& deploymentOptions, Windows::Management::Deployment::PackageVolume const& targetVolume, param::async_iterable<hstring> const& optionalPackageFamilyNames, param::async_iterable<Windows::Foundation::Uri> const& externalPackageUris) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> RegisterPackageByFamilyNameAsync(param::hstring const& mainPackageFamilyName, param::async_iterable<hstring> const& dependencyPackageFamilyNames, Windows::Management::Deployment::DeploymentOptions const& deploymentOptions, Windows::Management::Deployment::PackageVolume const& appDataVolume, param::async_iterable<hstring> const& optionalPackageFamilyNames) const;
Windows::Management::Deployment::PackageManagerDebugSettings DebugSettings() const;
};
template <> struct consume<Windows::Management::Deployment::IPackageManager5> { template <typename D> using type = consume_Windows_Management_Deployment_IPackageManager5<D>; };
template <typename D>
struct consume_Windows_Management_Deployment_IPackageManager6
{
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> ProvisionPackageForAllUsersAsync(param::hstring const& packageFamilyName) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> AddPackageByAppInstallerFileAsync(Windows::Foundation::Uri const& appInstallerFileUri, Windows::Management::Deployment::AddPackageByAppInstallerOptions const& options, Windows::Management::Deployment::PackageVolume const& targetVolume) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> RequestAddPackageByAppInstallerFileAsync(Windows::Foundation::Uri const& appInstallerFileUri, Windows::Management::Deployment::AddPackageByAppInstallerOptions const& options, Windows::Management::Deployment::PackageVolume const& targetVolume) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> AddPackageAsync(Windows::Foundation::Uri const& packageUri, param::async_iterable<Windows::Foundation::Uri> const& dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions const& options, Windows::Management::Deployment::PackageVolume const& targetVolume, param::async_iterable<hstring> const& optionalPackageFamilyNames, param::async_iterable<Windows::Foundation::Uri> const& packageUrisToInstall, param::async_iterable<Windows::Foundation::Uri> const& relatedPackageUris) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> StagePackageAsync(Windows::Foundation::Uri const& packageUri, param::async_iterable<Windows::Foundation::Uri> const& dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions const& options, Windows::Management::Deployment::PackageVolume const& targetVolume, param::async_iterable<hstring> const& optionalPackageFamilyNames, param::async_iterable<Windows::Foundation::Uri> const& packageUrisToInstall, param::async_iterable<Windows::Foundation::Uri> const& relatedPackageUris) const;
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> RequestAddPackageAsync(Windows::Foundation::Uri const& packageUri, param::async_iterable<Windows::Foundation::Uri> const& dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions const& deploymentOptions, Windows::Management::Deployment::PackageVolume const& targetVolume, param::async_iterable<hstring> const& optionalPackageFamilyNames, param::async_iterable<Windows::Foundation::Uri> const& relatedPackageUris) const;
};
template <> struct consume<Windows::Management::Deployment::IPackageManager6> { template <typename D> using type = consume_Windows_Management_Deployment_IPackageManager6<D>; };
template <typename D>
struct consume_Windows_Management_Deployment_IPackageManager7
{
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> RequestAddPackageAsync(Windows::Foundation::Uri const& packageUri, param::async_iterable<Windows::Foundation::Uri> const& dependencyPackageUris, Windows::Management::Deployment::DeploymentOptions const& deploymentOptions, Windows::Management::Deployment::PackageVolume const& targetVolume, param::async_iterable<hstring> const& optionalPackageFamilyNames, param::async_iterable<Windows::Foundation::Uri> const& relatedPackageUris, param::async_iterable<Windows::Foundation::Uri> const& packageUrisToInstall) const;
};
template <> struct consume<Windows::Management::Deployment::IPackageManager7> { template <typename D> using type = consume_Windows_Management_Deployment_IPackageManager7<D>; };
template <typename D>
struct consume_Windows_Management_Deployment_IPackageManager8
{
Windows::Foundation::IAsyncOperationWithProgress<Windows::Management::Deployment::DeploymentResult, Windows::Management::Deployment::DeploymentProgress> DeprovisionPackageForAllUsersAsync(param::hstring const& packageFamilyName) const;
};
template <> struct consume<Windows::Management::Deployment::IPackageManager8> { template <typename D> using type = consume_Windows_Management_Deployment_IPackageManager8<D>; };
template <typename D>
struct consume_Windows_Management_Deployment_IPackageManagerDebugSettings
{
Windows::Foundation::IAsyncAction SetContentGroupStateAsync(Windows::ApplicationModel::Package const& package, param::hstring const& contentGroupName, Windows::ApplicationModel::PackageContentGroupState const& state) const;
Windows::Foundation::IAsyncAction SetContentGroupStateAsync(Windows::ApplicationModel::Package const& package, param::hstring const& contentGroupName, Windows::ApplicationModel::PackageContentGroupState const& state, double completionPercentage) const;
};
template <> struct consume<Windows::Management::Deployment::IPackageManagerDebugSettings> { template <typename D> using type = consume_Windows_Management_Deployment_IPackageManagerDebugSettings<D>; };
template <typename D>
struct consume_Windows_Management_Deployment_IPackageUserInformation
{
hstring UserSecurityId() const;
Windows::Management::Deployment::PackageInstallState InstallState() const;
};
template <> struct consume<Windows::Management::Deployment::IPackageUserInformation> { template <typename D> using type = consume_Windows_Management_Deployment_IPackageUserInformation<D>; };
template <typename D>
struct consume_Windows_Management_Deployment_IPackageVolume
{
bool IsOffline() const;
bool IsSystemVolume() const;
hstring MountPoint() const;
hstring Name() const;
hstring PackageStorePath() const;
bool SupportsHardLinks() const;
Windows::Foundation::Collections::IVector<Windows::ApplicationModel::Package> FindPackages() const;
Windows::Foundation::Collections::IVector<Windows::ApplicationModel::Package> FindPackages(param::hstring const& packageName, param::hstring const& packagePublisher) const;
Windows::Foundation::Collections::IVector<Windows::ApplicationModel::Package> FindPackages(param::hstring const& packageFamilyName) const;
Windows::Foundation::Collections::IVector<Windows::ApplicationModel::Package> FindPackagesWithPackageTypes(Windows::Management::Deployment::PackageTypes const& packageTypes) const;
Windows::Foundation::Collections::IVector<Windows::ApplicationModel::Package> FindPackagesWithPackageTypes(Windows::Management::Deployment::PackageTypes const& packageTypes, param::hstring const& packageName, param::hstring const& packagePublisher) const;
Windows::Foundation::Collections::IVector<Windows::ApplicationModel::Package> FindPackagesWithPackageTypes(Windows::Management::Deployment::PackageTypes const& packageTypes, param::hstring const& packageFamilyName) const;
Windows::Foundation::Collections::IVector<Windows::ApplicationModel::Package> FindPackage(param::hstring const& packageFullName) const;
Windows::Foundation::Collections::IVector<Windows::ApplicationModel::Package> FindPackagesForUser(param::hstring const& userSecurityId) const;
Windows::Foundation::Collections::IVector<Windows::ApplicationModel::Package> FindPackagesForUser(param::hstring const& userSecurityId, param::hstring const& packageName, param::hstring const& packagePublisher) const;
Windows::Foundation::Collections::IVector<Windows::ApplicationModel::Package> FindPackagesForUser(param::hstring const& userSecurityId, param::hstring const& packageFamilyName) const;
Windows::Foundation::Collections::IVector<Windows::ApplicationModel::Package> FindPackagesForUserWithPackageTypes(param::hstring const& userSecurityId, Windows::Management::Deployment::PackageTypes const& packageTypes) const;
Windows::Foundation::Collections::IVector<Windows::ApplicationModel::Package> FindPackagesForUserWithPackageTypes(param::hstring const& userSecurityId, Windows::Management::Deployment::PackageTypes const& packageTypes, param::hstring const& packageName, param::hstring const& packagePublisher) const;
Windows::Foundation::Collections::IVector<Windows::ApplicationModel::Package> FindPackagesForUserWithPackageTypes(param::hstring const& userSecurityId, Windows::Management::Deployment::PackageTypes const& packageTypes, param::hstring const& packageFamilyName) const;
Windows::Foundation::Collections::IVector<Windows::ApplicationModel::Package> FindPackageForUser(param::hstring const& userSecurityId, param::hstring const& packageFullName) const;
};
template <> struct consume<Windows::Management::Deployment::IPackageVolume> { template <typename D> using type = consume_Windows_Management_Deployment_IPackageVolume<D>; };
template <typename D>
struct consume_Windows_Management_Deployment_IPackageVolume2
{
bool IsFullTrustPackageSupported() const;
bool IsAppxInstallSupported() const;
Windows::Foundation::IAsyncOperation<uint64_t> GetAvailableSpaceAsync() const;
};
template <> struct consume<Windows::Management::Deployment::IPackageVolume2> { template <typename D> using type = consume_Windows_Management_Deployment_IPackageVolume2<D>; };
struct struct_Windows_Management_Deployment_DeploymentProgress
{
Windows::Management::Deployment::DeploymentProgressState state;
uint32_t percentage;
};
template <> struct abi<Windows::Management::Deployment::DeploymentProgress>{ using type = struct_Windows_Management_Deployment_DeploymentProgress; };
}
| 102.792636 | 671 | 0.815841 |
eacbdcd82d0b49ca3ab0d5d9875bb98576c6434d | 2,022 | c | C | openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/e2fsprogs/1.44.5-r0/git/misc/mklost+found.c | sotaoverride/backup | ca53a10b72295387ef4948a9289cb78ab70bc449 | [
"Apache-2.0"
] | null | null | null | openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/e2fsprogs/1.44.5-r0/git/misc/mklost+found.c | sotaoverride/backup | ca53a10b72295387ef4948a9289cb78ab70bc449 | [
"Apache-2.0"
] | null | null | null | openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/e2fsprogs/1.44.5-r0/git/misc/mklost+found.c | sotaoverride/backup | ca53a10b72295387ef4948a9289cb78ab70bc449 | [
"Apache-2.0"
] | null | null | null | /*
* mklost+found.c - Creates a directory lost+found on a mounted second
* extended file system
*
* Copyright (C) 1992, 1993 Remy Card <card@masi.ibp.fr>
*
* This file can be redistributed under the terms of the GNU General
* Public License
*/
/*
* History:
* 93/04/22 - Creation
*/
#include "config.h"
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <unistd.h>
#include "../version.h"
#include "ext2fs/ext2_fs.h"
#include "support/nls-enable.h"
#define LPF "lost+found"
int main(int argc, char** argv)
{
char name[EXT2_NAME_LEN + 2];
char path[sizeof(LPF) + 1 + 256];
struct stat st;
int i, j;
int d;
#ifdef ENABLE_NLS
setlocale(LC_MESSAGES, "");
setlocale(LC_CTYPE, "");
bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
textdomain(NLS_CAT_NAME);
#endif
fprintf(stderr, "mklost+found %s (%s)\n", E2FSPROGS_VERSION,
E2FSPROGS_DATE);
if (argc != 1)
{
(void)argv; /* avoid unused argument warning */
fprintf(stderr, "%s", _("Usage: mklost+found\n"));
exit(1);
}
if (mkdir(LPF, 0700) == -1)
{
perror("mkdir");
exit(1);
}
i = 0;
memset(name, 'x', 246);
do
{
sprintf(name + 246, "%08d", i);
strcpy(path, LPF);
strcat(path, "/");
strcat(path, name);
if ((d = creat(path, 0644)) == -1)
{
perror("creat");
exit(1);
}
i++;
close(d);
if (stat(LPF, &st) == -1)
{
perror("stat");
exit(1);
}
} while (st.st_size <= (EXT2_NDIR_BLOCKS - 1) * st.st_blksize);
for (j = 0; j < i; j++)
{
sprintf(name + 246, "%08d", j);
strcpy(path, LPF);
strcat(path, "/");
strcat(path, name);
if (unlink(path) == -1)
{
perror("unlink");
exit(1);
}
}
exit(0);
}
| 21.0625 | 70 | 0.519782 |
238eaecfe35c7d083c2220397b03496262883b2e | 574 | c | C | testnet/tests/scripts/test_modules/wasm-generator/libs-src.c | 3cL1p5e7/ic | 2b6011291d900454cedcf86ec41c8c1994fdf7d9 | [
"Apache-2.0"
] | 941 | 2021-05-10T08:14:14.000Z | 2022-03-31T11:40:24.000Z | testnet/tests/scripts/test_modules/wasm-generator/libs-src.c | 3cL1p5e7/ic | 2b6011291d900454cedcf86ec41c8c1994fdf7d9 | [
"Apache-2.0"
] | 4 | 2021-12-22T22:34:51.000Z | 2022-03-31T07:34:19.000Z | testnet/tests/scripts/test_modules/wasm-generator/libs-src.c | 3cL1p5e7/ic | 2b6011291d900454cedcf86ec41c8c1994fdf7d9 | [
"Apache-2.0"
] | 122 | 2021-05-10T08:21:23.000Z | 2022-03-25T20:34:12.000Z | /*
C implementation of some standard libraries that Csmith might include in a randomly generated C code
*/
void * memcpy(void* dst, const void* src, unsigned int cnt)
{
char *pszDest = (char *)dst;
const char *pszSource =( const char*)src;
while(cnt) //till cnt
{
//Copy byte by byte
*(pszDest++)= *(pszSource++);
--cnt;
}
return dst;
}
void * memset(void *s, int c, unsigned int len)
{
unsigned char* p=s;
while(len--)
{
*p++ = (unsigned char)c;
}
return s;
}
int printf (const char *buff, ...) {
}
| 15.944444 | 100 | 0.576655 |
1e50797710f3c6d570f322001428fe486cb937fc | 19,179 | c | C | src/coregister_fine/coregister_fine.c | glshort/MapReady | c9065400a64c87be46418ab32e3a251ca2f55fd5 | [
"BSD-3-Clause"
] | 3 | 2017-12-31T05:33:28.000Z | 2021-07-28T01:51:22.000Z | src/coregister_fine/coregister_fine.c | glshort/MapReady | c9065400a64c87be46418ab32e3a251ca2f55fd5 | [
"BSD-3-Clause"
] | null | null | null | src/coregister_fine/coregister_fine.c | glshort/MapReady | c9065400a64c87be46418ab32e3a251ca2f55fd5 | [
"BSD-3-Clause"
] | 7 | 2017-04-26T18:18:33.000Z | 2020-05-15T08:01:09.000Z | /******************************************************************************
* *
* Copyright (c) 2004, Geophysical Institute, University of Alaska Fairbanks *
* All rights reserved. *
* *
* You should have received an ASF SOFTWARE License Agreement with this source *
* code. Please consult this agreement for license grant information. *
* *
* *
* For more information contact us at: *
* *
* Alaska Satellite Facility *
* Geophysical Institute http://www.asf.alaska.edu *
* University of Alaska Fairbanks uso@asf.alaska.edu *
* P.O. Box 757320 *
* Fairbanks, AK 99775-7320 *
* *
******************************************************************************/
/*******************************************************************************
NAME: coregister_fine
SYNOPSIS:
coregister_fine [<grid resolution>] [-f] [-log <file>] [-quiet]
<file1> <file2> <control> <out>
DESCRIPTION:
Coregister_fine is a program used to perform sub-pixel correlation
during the process of interferometry. It only works with complex images.
The way coregister_fine works is it correlates (that is, match up) two
images at various points in the image. The points it matches up are
arranged in a grid. The number of points in this grid can be set by the
command line.
Coregister_fine needs an gross estimate (to a single pixel) of the
offset between the two images; it gets this offset from its control
file. For each grid point, coregister_fine computes the phase coherence
of several offsets near the gross offset, and searches for the highest
coherence offset. It then refines this offset by performing a parabolic
interpolation on the nearby coherence values.
Coregister_fine now double-checks its result by running the same
calculation with the images reversed. If the two results agree, the
point is "good" and is output. If the results disagree, the correlation
is "bad" and is not output.
In addition to the offset, coregister_fine also calculates the SNR
(Signal-to-Noise Ratio) at each point. This can be used as a measure of
the quality of the correlation. Correlation points with a low SNR are
bad.
If coregister_fine does not find many good points, you may not get an
interferogram when you interfere the two images. This can be the result
of several things: your interferometric baseline might be too big, and
there will never be an interferogram between the images; the initial
offset in the coregister_fine control file is incorrect, and
coregister_fine cannot find anything that looks like interferometric
phase.
Increasing the number of grid points slows the program down, but
generates more output for fit_line or fit_plane, which then improves the
coherence.
EXTERNAL ASSOCIATES:
NAME: USAGE:
---------------------------------------------------------------
FILE REFERENCES:
NAME: USAGE:
---------------------------------------------------------------
PROGRAM HISTORY:
VERS: DATE: PURPOSE:
---------------------------------------------------------------
1.0 10/95 R. Fatland - Original Development
1.1 10/95 M. Shindle - Revised & cleaned
T. Logan - Port to Solaris, modified form
1.2 4/96 M. Shindle - Apply ASF standards
2.0 8/96 M. Shindle - Implement modifications from Rob Fatland.
3.0 2/97 T. Logan - Modified to work on float complex output
patches from ASP code
4.0 5/97 O. Lawlor - Modified to allow reverse correlation
(to check the first correlation) and
grid resolution, and do a trilinear peak
interpolation.
5.0 9/97 O. Lawlor - Optimization-- replaced FFT with
much faster phase coherence method.
5.1 5/98 O. Lawlor - Perform forward and reverse correlation,
delete suspect points.
5.2 6/00 M. Ayers - Add Complex FFT matching option to offset
estimation
5.21 7/01 R. Gens - Added logfile and quiet switch
5.5 10/03 P. Denny - Standardize commandline parsing & order
Use meta v1.1 instead of DDR
5.6 2/04 P. Denny - Change license from GPL to ASF. Change
name from fico to coregister_fine.
5.7 7/05 R. Gens - Took care of endianess issue.
HARDWARE/SOFTWARE LIMITATIONS:
ALGORITHM DESCRIPTION:
ALGORITHM REFERENCES:
BUGS:
*******************************************************************************/
#include "asf.h"
#include "asf_meta.h"
#include "ifm.h"
#include "asf_endian.h"
#define borderX 80 /*Distances from edge of image to start correlating.*/
#define borderY 80
#define minSNR 0.30 /*SNR's below this will be deleted.*/
#define maxDisp 1.8 /*Forward and reverse correlations which differ by more
than this will be deleted.*/
#define VERSION 5.7
/*Read-only, informational globals:*/
int wid, len; /*Width and length of source images.*/
int intOffsetX, intOffsetY; /*Image offset estimates from coregister_coarse.*/
int srcSize=32, trgSize;
float xMEP=4.1,yMEP=6.1; /*Maximum Error Pixel values.*/
complexFloat cZero;
/*Function declarations */
void usage(char *name);
void readControlFile(char *filename);
void initSourcePts(char *gridRes);
bool getNextPoint(int *x1,int *y1,int *x2,int *y2);
bool outOfBounds(int x1, int y1, int x2, int y2, int srcSize, int trgSize);
void getPeak(int x1,int y1,char *szImg1,int x2,int y2,char *szImg2,float *dx,float *dy, float *snr,int fft_flag);
void topOffPeak(float *peaks,int i, int j, int maxI, int maxJ,float *dx,float *dy);
float getPhaseCoherence(complexFloat *igram,int sizeX,int sizeY);
float getFFTCorrelation(complexFloat *igram,int sizeX,int sizeY);
/* Start of main progam */
int main(int argc, char *argv[])
{
char szOut[MAXNAME], szCtrl[MAXNAME], szImg1[MAXNAME], szImg2[MAXNAME];
int fft_flag=0;
int x1, x2, y1, y2;
int goodPoints,attemptedPoints;
FILE *fp_output;
char gridRes[256];
meta_parameters *meta;
/* parse command line */
logflag=quietflag=FALSE;
while (currArg < (argc-4)) {
char *key = argv[currArg++];
if (strmatch(key,"-log")) {
CHECK_ARG(1);
strcpy(logFile,GET_ARG(1));
fLog = FOPEN(logFile, "a");
logflag=TRUE;
}
else if (strmatch(key,"-quiet")) {
quietflag=TRUE;
}
else if (strmatch(key,"-f")) {
fft_flag=1;
}
else if (strmatch(key,"-g")) {
CHECK_ARG(1);
strcpy(gridRes,GET_ARG(1));
}
else {printf( "\n**Invalid option: %s\n",argv[currArg-1]); usage(argv[0]);}
}
if ((argc-currArg) < 4) {printf("Insufficient arguments.\n"); usage(argv[0]);}
create_name(szImg1, argv[currArg++], ".img");
create_name(szImg2, argv[currArg++], ".img");
strcpy(szCtrl,argv[currArg++]);
strcpy(szOut,argv[currArg]);
printf("%s\n",date_time_stamp());
printf("Program: coregister_fine\n\n");
if (fft_flag)
printf(" Using Complex FFT instead of coherence for matching\n");
if (!quietflag)
printf(" coregister_fine is correlating '%s' to '%s'.\n",szImg2,szImg1);
if (logflag) {
StartWatchLog(fLog);
printLog("Program: coregister_fine\n\n");
if (fft_flag)
printLog(" Using Complex FFT instead of coherence for matching\n");
}
readControlFile(szCtrl);
/* calculate parameters */
trgSize = 2*srcSize;
/* determine size of input files */
meta = meta_read(szImg1);
wid = meta->general->sample_count;
len = meta->general->line_count;
meta_free(meta);
/* initialize params before looping */
cZero = Czero();
/* create output file */
fp_output=FOPEN(szOut,"w");
initSourcePts(gridRes);
/* Loop over grid, performing forward and backward correlations */
goodPoints=attemptedPoints=0;
while (getNextPoint(&x1,&y1,&x2,&y2))
{
float dx,dy,snr,dxFW,dyFW,snrFW,dxBW,dyBW,snrBW;
attemptedPoints++;
/*Check bounds...*/
if (!(outOfBounds(x1, y1, x2, y2, srcSize, trgSize) ||
outOfBounds(x2, y2, x1, y1, srcSize, trgSize)))
{
/*...check forward correlation...*/
getPeak(x1,y1,szImg1,x2,y2,szImg2,&dxFW,&dyFW,&snrFW,fft_flag);
if (snrFW>minSNR)
{
/*...check backward correlation...*/
getPeak(x2,y2,szImg2,x1,y1,szImg1,&dxBW,&dyBW,&snrBW,fft_flag);
dxBW*=-1.0;dyBW*=-1.0;
if ((snrBW>minSNR)&&
(fabs(dxFW-dxBW)<maxDisp)&&
(fabs(dyFW-dyBW)<maxDisp))
{
goodPoints++;
dx=(dxFW+dxBW)/2;
dy=(dyFW+dyBW)/2;
snr=snrFW*snrBW;
fprintf(fp_output,"%6d %6d %8.5f %8.5f %4.2f\n",
x1,y1,x2+dx,y2+dy,snr);
fflush(fp_output);
if (!quietflag && (goodPoints <= 10 || !(goodPoints%100)))
printf("\t%6d %6d %8.5f %8.5f %4.2f/%4.2f\n",
x1,y1,dx,dy,snrFW,snrBW);
}
}
}
} /* end while(getNextPoint) */
if (goodPoints<20)
{
sprintf(errbuf," *************** ERROR! ************\n"
" ** coregister_fine was only able to find %i points which\n"
" ** correlated the same backwards and forwards. This\n"
" ** is not enough for a planar map!\n"
" ** Problems with coregister_fine can usually be traced back "
"to coregister_fine's\n"
" ** control file, which MUST have a good estimate of the \n"
" ** single-pixel offset between the two images.\n"
" ** Exiting with error!\n",goodPoints);
printErr(errbuf);
}
else
printf(" coregister_fine attempted %d correlations, %d succeeded.\n\n",
attemptedPoints,goodPoints);
if (logflag) {
sprintf(logbuf," coregister_fine attempted %d correlations, %d succeeded.\n\n",
attemptedPoints,goodPoints);
printLog(logbuf);
}
exit(EXIT_SUCCESS);
}
bool outOfBounds(int x1, int y1, int x2, int y2, int srcSize, int trgSize)
{
if (x1 - srcSize/2 + 1 < 0) return TRUE;
if (y1 - srcSize/2 + 1 < 0) return TRUE;
if (x2 - trgSize/2 + 1 < 0) return TRUE;
if (y2 - trgSize/2 + 1 < 0) return TRUE;
if (x1 + srcSize/2 >= wid) return TRUE;
if (y1 + srcSize/2 >= len) return TRUE;
if (x2 + trgSize/2 >= wid) return TRUE;
if (y2 + trgSize/2 >= len) return TRUE;
return FALSE;
}
void readControlFile(char *filename)
{
float ignored;
/* read control file parameters
-----------------------------*/
FILE *fp = FOPEN(filename,"r"); /* control file: */
/* range offset (loc in img 2 = loc in img 1 - x offset) */
fscanf(fp, "%d", &intOffsetX);
/* azimuth offset (loc in img 2 = loc in img 1 - y offset) */
fscanf(fp, "%d", &intOffsetY);
fscanf(fp, "%d", &srcSize);
if (srcSize<8) srcSize=32;
fscanf(fp, "%f", &ignored);/*IGNORED oversample. This is now always 1.*/
fscanf(fp, "%f", &xMEP);
fscanf(fp, "%f", &yMEP);
FCLOSE(fp);
}
int pointNo=0;
int gridResolution=20;
void initSourcePts(char *gridRes)
{
/*Check to see if the last parameter contains a number, the grid resolution*/
if (gridRes)
gridResolution=atoi(gridRes);
if (gridResolution<2)
gridResolution=20;
if (!quietflag)
printf(" Sampling rectangular grid, %ix%i resolution.\n",
gridResolution,gridResolution);
}
bool getNextPoint(int *x1,int *y1,int *x2,int *y2)
{
int unscaledX, unscaledY;
unscaledX=pointNo%gridResolution;
unscaledY=pointNo/gridResolution;
*x1=unscaledX*(wid-2*borderX)/(gridResolution-1)+borderX;
*y1=unscaledY*(len-2*borderY)/(gridResolution-1)+borderY;
*x2=*x1-intOffsetX;
*y2=*y1-intOffsetY;
if (pointNo>=(gridResolution*gridResolution))
return FALSE;
pointNo++;
return TRUE;
}
/*getPeak:
This function computes a correlation peak, with SNR, between
the two given images at the given points.
*/
void getPeak(int x1,int y1,char *szImg1,int x2,int y2,char *szImg2,
float *peakX,float *peakY, float *snr,int fft_flag)
{
FILE *fpSource, *fpTarget;
meta_parameters *metaSource, *metaTarget;
static float *peaks;
static complexFloat *bufSource, *bufTarget;
static complexFloat *s=NULL, *t, *product; /*Keep working arrays around */
static float *bufAmpSource, *bufAmpTarget;
int srcSamples, trgSamples;
int peakMaxX, peakMaxY, x,y,xOffset,yOffset,count;
int xOffsetStart, yOffsetStart, xOffsetEnd, yOffsetEnd;
float dx,dy,accel1 = (float)(trgSize/2 - srcSize/2);
float peakMax, thisMax, peakSum;
/*
* Calculate the limits of the time domain correlations...
* A coordinate in the target may be set to:
* ( (trgSize/2 - srcSize/2), (trgSize/2 - srcSize/2) ).
* If this is the ulh element of the source chip, then
* the src chip coincides with the trg precisely, with no offset.
*/
xOffsetStart = (trgSize/2 - srcSize/2) - (int)(xMEP);
xOffsetEnd = (trgSize/2 - srcSize/2) + (int)(xMEP);
yOffsetStart = (trgSize/2 - srcSize/2) - (int)(yMEP);
yOffsetEnd = (trgSize/2 - srcSize/2) + (int)(yMEP);
/* Read metadata */
metaSource = meta_read(szImg1);
metaTarget = meta_read(szImg2);
srcSamples = metaSource->general->sample_count;
trgSamples = metaTarget->general->sample_count;
int ii, ampFlag = FALSE;
if (metaSource->general->data_type == REAL32)
ampFlag = TRUE;
/*Allocate working arrays if we haven't already done so.*/
if (ampFlag && s==NULL) {
bufAmpSource = (float *) MALLOC(sizeof(float)*srcSize*srcSamples);
bufAmpTarget = (float *) MALLOC(sizeof(float)*trgSize*trgSamples);
}
if (s==NULL)
{
bufSource = (complexFloat *) MALLOC(sizeof(complexFloat)*srcSize*srcSamples);
bufTarget = (complexFloat *) MALLOC(sizeof(complexFloat)*trgSize*trgSamples);
s = (complexFloat *)(MALLOC(srcSize*srcSize*sizeof(complexFloat)));
t = (complexFloat *)(MALLOC(trgSize*trgSize*sizeof(complexFloat)));
product = (complexFloat *)(MALLOC(srcSize*srcSize*sizeof(complexFloat)));
peaks=(float *)MALLOC(sizeof(float)*trgSize*trgSize);
}
/* Open files, read lines and create subset */
fpSource = FOPEN(szImg1, "rb");
fpTarget = FOPEN(szImg2, "rb");
if (ampFlag) {
get_float_lines(fpSource, metaSource, y1-srcSize/2+1, srcSize,
bufAmpSource);
for (ii=0; ii<srcSize*srcSamples; ii++) {
bufSource[ii].real = bufAmpSource[ii];
bufSource[ii].imag = 0.0;
}
get_float_lines(fpTarget, metaTarget, y2-trgSize/2+1, trgSize,
bufAmpTarget);
for (ii=0; ii<trgSize*trgSamples; ii++) {
bufTarget[ii].real = bufAmpTarget[ii];
bufTarget[ii].imag = 0.0;
}
}
else {
get_complexFloat_lines(fpSource, metaSource, y1-srcSize/2+1, srcSize,
bufSource);
get_complexFloat_lines(fpTarget, metaTarget, y2-trgSize/2+1, trgSize,
bufTarget);
}
FCLOSE(fpSource);
FCLOSE(fpTarget);
for (y=0; y<srcSize; y++) {
int srcIndex = y*srcSize;
for (x=0; x<srcSize; x++)
s[srcIndex++] = bufSource[x1-srcSize/2+1+x+y*srcSamples];
}
for (y=0; y<trgSize; y++) {
int trgIndex = y*trgSize;
for (x=0; x<trgSize; x++)
t[trgIndex++] = bufTarget[x2-trgSize/2+1+x+y*trgSamples];
}
/*Take the complex conjugate of the source chunk (so we only have to do so once).*/
for(y=0;y<srcSize;y++)
{
int srcIndex=y*srcSize;
for(x=0;x<srcSize;x++)
s[srcIndex++].imag*=-1;
}
/*Now compute the best possible offset between these two images,
by checking the phase coherence at each possible offset.*/
peakMax = peakSum = 0.0;
peakMaxX=peakMaxY=count=0;
for(yOffset=yOffsetStart;yOffset<=yOffsetEnd;yOffset++)
{
for(xOffset=xOffsetStart;xOffset<=xOffsetEnd;xOffset++)
{
/* Form an interferogram \
(multiply by complex conjugate at this offset between the images: */
for(y=0;y<srcSize;y++)
{
int srcIndex=y*srcSize;
int trgIndex=xOffset+(yOffset+y)*trgSize;
for(x=0;x<srcSize;x++)
{
product[srcIndex] = Cmul(s[srcIndex], t[trgIndex]);
srcIndex++,trgIndex++;
}
}
/*Find the phase coherence for this interferogram*/
if(fft_flag)
thisMax=getFFTCorrelation(product,srcSize,srcSize);
else
thisMax=getPhaseCoherence(product,srcSize,srcSize);
/*Possibly save this coherence value.*/
if (thisMax>peakMax)
{
peakMax=thisMax;
peakMaxX=xOffset;
peakMaxY=yOffset;
}
peaks[yOffset*trgSize+xOffset]=thisMax;
peakSum += thisMax;
count++;
}
}
/* Calculate the SNR, with a much faster (but weaker) SNR calculation */
*snr = peakMax / ((peakSum - peakMax) / (float)(count-1))-1.0;
//printf("peakMaxX: %i, peakMaxY: %i\n", peakMaxX, peakMaxY);
if ((peakMaxX>xOffsetStart)&&(peakMaxY>yOffsetStart)&&
(peakMaxX<xOffsetEnd)&&(peakMaxY<yOffsetEnd))
topOffPeak(peaks,peakMaxX,peakMaxY,trgSize,trgSize,&dx,&dy);
else
dx=dy=0.0;
*peakX=((float)(peakMaxX) + dx - accel1 );
*peakY=((float)(peakMaxY) + dy - accel1 );
}
/*TopOffPeak:
Given an array of peak values, use trilinear interpolation to determine the exact (i.e. float) top.
This works by finding the peak of a parabola which goes though the highest point, and the three points
surrounding it.
*/
void topOffPeak(float *peaks,int i, int j, int maxI, int maxJ,float *dx,float *dy)
{
int offset=j*maxI+i;
float a,b,c,d;
a=peaks[offset-1];
b=peaks[offset];
c=peaks[offset+1];
d=4*((a+c)/2-b);
if (d!=0)
*dx=(a-c)/d;
else *dx=0;
a=peaks[offset-maxI];
b=peaks[offset];
c=peaks[offset+maxI];
d=4*((a+c)/2-b);
if (d!=0)
*dy=(a-c)/d;
else *dy=0;
}
void usage(char *name)
{
printf("\n"
"USAGE:\n"
" %s [-g <grid res>] [<-f>] [-log <file>] [-quiet]\n"
" <file1> <file2> <control> <out>\n", name);
printf("\n"
"REQUIRED ARGUMENTS:\n"
" file1 First raw float complex base file name (.cpx & .meta)\n"
" file2 Second raw float complex base file name (.cpx & .meta)\n"
" control Parameter file. This file is created by coregister_coarse.\n"
" out Ouput ASCII file of offset points.\n");
printf("\n"
"OPTIONAL ARGUMETNS:\n"
" -g <grid_res> Number of grid points per axis\n"
" -f Use of complex FFT instead of coherence\n"
" -log <file> Allows the output to be written to a log file\n"
" -quiet Suppress the output to the essential\n");
printf("\n"
"DESCRIPTION:\n"
" Used to perform sub-pixel co-registration on two images, to form\n"
" an interferogram\n");
printf("\n"
"Version: %.2f, ASF InSAR Tools\n"
"\n",VERSION);
exit(EXIT_FAILURE);
}
| 35.385609 | 113 | 0.611189 |
632bff067fe377c52a1232ff33262b8239828000 | 5,591 | h | C | paddle/fluid/inference/experimental/javaapi/native/com_baidu_paddle_inference_Tensor.h | ZibinGuo/Paddle | 6e0892312de5e4ba76d980ff0e4322ac55ca0d07 | [
"Apache-2.0"
] | 11 | 2016-08-29T07:43:26.000Z | 2016-08-29T07:51:24.000Z | paddle/fluid/inference/experimental/javaapi/native/com_baidu_paddle_inference_Tensor.h | ZibinGuo/Paddle | 6e0892312de5e4ba76d980ff0e4322ac55ca0d07 | [
"Apache-2.0"
] | 1 | 2022-01-28T07:23:22.000Z | 2022-01-28T07:23:22.000Z | paddle/fluid/inference/experimental/javaapi/native/com_baidu_paddle_inference_Tensor.h | ZibinGuo/Paddle | 6e0892312de5e4ba76d980ff0e4322ac55ca0d07 | [
"Apache-2.0"
] | 1 | 2021-09-24T11:23:36.000Z | 2021-09-24T11:23:36.000Z | // Copyright (c) 2021 PaddlePaddle Authors. 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.
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class com_baidu_paddle_inference_Tensor */
#ifndef PADDLE_FLUID_INFERENCE_JAVAAPI_NATIVE_COM_BAIDU_PADDLE_INFERENCE_TENSOR_H_
#define PADDLE_FLUID_INFERENCE_JAVAAPI_NATIVE_COM_BAIDU_PADDLE_INFERENCE_TENSOR_H_
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: com_baidu_paddle_inference_Tensor
* Method: cppTensorDestroy
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_com_baidu_paddle_inference_Tensor_cppTensorDestroy(
JNIEnv *, jobject, jlong);
/*
* Class: com_baidu_paddle_inference_Tensor
* Method: cppTensorReshape
* Signature: (JI[I)V
*/
JNIEXPORT void JNICALL Java_com_baidu_paddle_inference_Tensor_cppTensorReshape(
JNIEnv *, jobject, jlong, jint, jintArray);
/*
* Class: com_baidu_paddle_inference_Tensor
* Method: cppTensorGetShape
* Signature: (J)[I
*/
JNIEXPORT jintArray JNICALL
Java_com_baidu_paddle_inference_Tensor_cppTensorGetShape(JNIEnv *, jobject,
jlong);
/*
* Class: com_baidu_paddle_inference_Tensor
* Method: cppTensorGetName
* Signature: (J)Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
Java_com_baidu_paddle_inference_Tensor_cppTensorGetName(JNIEnv *, jobject,
jlong);
/*
* Class: com_baidu_paddle_inference_Tensor
* Method: cppTensorCopyFromCpuFloat
* Signature: (J[F)V
*/
JNIEXPORT void JNICALL
Java_com_baidu_paddle_inference_Tensor_cppTensorCopyFromCpuFloat(JNIEnv *,
jobject, jlong,
jfloatArray);
/*
* Class: com_baidu_paddle_inference_Tensor
* Method: cppTensorCopyFromCpuInt
* Signature: (J[I)V
*/
JNIEXPORT void JNICALL
Java_com_baidu_paddle_inference_Tensor_cppTensorCopyFromCpuInt(JNIEnv *,
jobject, jlong,
jintArray);
/*
* Class: com_baidu_paddle_inference_Tensor
* Method: cppTensorCopyFromCpuLong
* Signature: (J[J)V
*/
JNIEXPORT void JNICALL
Java_com_baidu_paddle_inference_Tensor_cppTensorCopyFromCpuLong(JNIEnv *,
jobject, jlong,
jlongArray);
/*
* Class: com_baidu_paddle_inference_Tensor
* Method: cppTensorCopyFromCpuByte
* Signature: (J[B)V
*/
JNIEXPORT void JNICALL
Java_com_baidu_paddle_inference_Tensor_cppTensorCopyFromCpuByte(JNIEnv *,
jobject, jlong,
jbyteArray);
/*
* Class: com_baidu_paddle_inference_Tensor
* Method: cppTensorCopyFromCpuBoolean
* Signature: (J[Z)V
*/
JNIEXPORT void JNICALL
Java_com_baidu_paddle_inference_Tensor_cppTensorCopyFromCpuBoolean(
JNIEnv *, jobject, jlong, jbooleanArray);
/*
* Class: com_baidu_paddle_inference_Tensor
* Method: cppTensorCopyToCpuFloat
* Signature: (J[F)V
*/
JNIEXPORT void JNICALL
Java_com_baidu_paddle_inference_Tensor_cppTensorCopyToCpuFloat(JNIEnv *,
jobject, jlong,
jfloatArray);
/*
* Class: com_baidu_paddle_inference_Tensor
* Method: cppTensorCopyToCpuInt
* Signature: (J[I)V
*/
JNIEXPORT void JNICALL
Java_com_baidu_paddle_inference_Tensor_cppTensorCopyToCpuInt(JNIEnv *, jobject,
jlong, jintArray);
/*
* Class: com_baidu_paddle_inference_Tensor
* Method: cppTensorCopyToCpuLong
* Signature: (J[J)V
*/
JNIEXPORT void JNICALL
Java_com_baidu_paddle_inference_Tensor_cppTensorCopyToCpuLong(JNIEnv *, jobject,
jlong,
jlongArray);
/*
* Class: com_baidu_paddle_inference_Tensor
* Method: cppTensorCopyToCpuByte
* Signature: (J[B)V
*/
JNIEXPORT void JNICALL
Java_com_baidu_paddle_inference_Tensor_cppTensorCopyToCpuByte(JNIEnv *, jobject,
jlong,
jbyteArray);
/*
* Class: com_baidu_paddle_inference_Tensor
* Method: cppTensorCopyToCpuBoolean
* Signature: (J[Z)V
*/
JNIEXPORT void JNICALL
Java_com_baidu_paddle_inference_Tensor_cppTensorCopyToCpuBoolean(JNIEnv *,
jobject, jlong,
jbooleanArray);
#ifdef __cplusplus
}
#endif
#endif // PADDLE_FLUID_INFERENCE_JAVAAPI_NATIVE_COM_BAIDU_PADDLE_INFERENCE_TENSOR_H_
| 34.94375 | 85 | 0.617421 |
e4294a0d3fb8b064bf4f56ddcc4caf94ccbb1cc4 | 41 | h | C | test/nanafy-memory/src/test-copy-nanafy-memory.h | Tikubonn/nanafy | adc9476bd110b15d4ff92175a48c384bcfe8f0f3 | [
"MIT"
] | null | null | null | test/nanafy-memory/src/test-copy-nanafy-memory.h | Tikubonn/nanafy | adc9476bd110b15d4ff92175a48c384bcfe8f0f3 | [
"MIT"
] | null | null | null | test/nanafy-memory/src/test-copy-nanafy-memory.h | Tikubonn/nanafy | adc9476bd110b15d4ff92175a48c384bcfe8f0f3 | [
"MIT"
] | null | null | null |
extern void test_copy_nanafy_memory ();
| 13.666667 | 39 | 0.804878 |
17e996084257fe5f853fc64e5c517e9ab11bead2 | 1,752 | h | C | example/ads1115/main/main.h | bzgec/ADS1115_esp32_espIdf | 7a2e73c87742f39db4e8b2d8d23da3f6199970d3 | [
"MIT"
] | 1 | 2020-06-22T01:16:33.000Z | 2020-06-22T01:16:33.000Z | example/ads1115/main/main.h | bzgec/ADS1115_esp32_espIdf | 7a2e73c87742f39db4e8b2d8d23da3f6199970d3 | [
"MIT"
] | null | null | null | example/ads1115/main/main.h | bzgec/ADS1115_esp32_espIdf | 7a2e73c87742f39db4e8b2d8d23da3f6199970d3 | [
"MIT"
] | null | null | null | #ifndef __main_h
#define __main_h
#include "Types.h"
//#include "bitInRegOperations.h"
#define PIN_SDA GPIO_NUM_21
#define PIN_SCL GPIO_NUM_22
#define LED_BUILTIN GPIO_NUM_2
#define PIN_ADS1115_ALRT GPIO_NUM_23
// enable what you use
#define ENABLE_ADS1115
// intervals at which task is run (in milli seconds)
#define TASK_INTERVAL_ADS1115_SINGLE_READ 20 // depends on ADS1115_DATA_RATE of ADS1115!!!!
#define TASK_INTERVAL_ADS1115 100 // depends on ADS1115_DATA_RATE of ADS1115!!!!
#define TASK_INTERVAL_ADS1115_PRINTF 100
// Each task is assigned a priority from 0 to ( configMAX_PRIORITIES - 1 )
// Low priority numbers denote low priority tasks. The idle task has priority zero (tskIDLE_PRIORITY).
#define TASK_PRIORITY_ADS1115 8
#define TASK_STACK_SIZE_ADS1115 configMINIMAL_STACK_SIZE*10
#define ADS1115_MODE ADS1115_MODE_SINGLESHOT
#define ADS1115_DATA_RATE ADS1115_DATA_RATE_64 // carefully because of task interval
#define ADS1115_PGA ADS1115_PGA_6P144
void app_main();
void init_gpio_LEDBUILTIN();
void init_gpio_ADS1115_alertPin();
void init_ADS1115();
void task_read_ads1115(void* pvParameter);
void task_printf_voltages(void *pvParameters);
void printf_clearLine();
void printf_cursorUpOneLine();
void printf_cursorUpLines(BYTE byN);
#define GPIO_REG_ADDR 0x3FF44000
#define GPIO_REG_IN_ADDR_OFFSET 0x003c
#define GPIO_REG_IN_ADDR (GPIO_REG_ADDR + GPIO_REG_IN_ADDR_OFFSET)
#define GPIO_REG_IN (*((DWORD*)GPIO_REG_IN_ADDR))
#ifndef INTERRUPTS_DISABLE
#define INTERRUPTS_DISABLE() portDISABLE_INTERRUPTS()
#endif // INTERRUPTS_DISABLE
#ifndef INTERRUPTS_ENABLE
#define INTERRUPTS_ENABLE() portENABLE_INTERRUPTS()
#endif // INTERRUPTS_ENABLE
#endif // __main_h
| 30.736842 | 103 | 0.791096 |
5b6fa7d8243b4f7d4c3e6ecb6242e55f7fe4ea1e | 4,910 | h | C | include/cnl/_impl/scaled_integer/tagged_convert_operator.h | NotifAi/cnl | 17e8c241b99d5c808b5de6b919ad82f4d0502074 | [
"BSL-1.0"
] | null | null | null | include/cnl/_impl/scaled_integer/tagged_convert_operator.h | NotifAi/cnl | 17e8c241b99d5c808b5de6b919ad82f4d0502074 | [
"BSL-1.0"
] | null | null | null | include/cnl/_impl/scaled_integer/tagged_convert_operator.h | NotifAi/cnl | 17e8c241b99d5c808b5de6b919ad82f4d0502074 | [
"BSL-1.0"
] | null | null | null |
// Copyright John McFarlane 2018.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file ../LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#if !defined(CNL_IMPL_SCALED_INTEGER_TAGGED_CONVERT_OPERATOR_H)
#define CNL_IMPL_SCALED_INTEGER_TAGGED_CONVERT_OPERATOR_H
#include "../power_value.h"
#include "../overflow/overflow_operator.h"
#include "../rounding/nearest_rounding_tag.h"
#include "../rounding/native_rounding_tag.h"
#include "../type_traits/enable_if.h"
#include "declaration.h"
#include "from_rep.h"
/// compositional numeric library
namespace cnl {
namespace _impl {
// conversion between two scaled_integer types where rounding *isn't* an issue
template<
typename ResultRep, int ResultExponent,
typename InputRep, int InputExponent,
int Radix>
struct tagged_convert_operator<
nearest_rounding_tag,
scaled_integer<ResultRep, power<ResultExponent, Radix>>,
scaled_integer<InputRep, power<InputExponent, Radix>>,
_impl::enable_if_t<(ResultExponent <= InputExponent)>>
: tagged_convert_operator<
native_rounding_tag,
scaled_integer<ResultRep, power<ResultExponent, Radix>>,
scaled_integer<InputRep, power<InputExponent, Radix>>> {
};
// conversion between two scaled_integer types where rounding *is* an issue
template<
typename ResultRep, int ResultExponent,
typename InputRep, int InputExponent,
int Radix>
struct tagged_convert_operator<
nearest_rounding_tag,
scaled_integer<ResultRep, power<ResultExponent, Radix>>,
scaled_integer<InputRep, power<InputExponent, Radix>>,
_impl::enable_if_t<!(ResultExponent<=InputExponent)>> {
private:
using _result = scaled_integer<ResultRep, power<ResultExponent, Radix>>;
using _input = scaled_integer<InputRep, power<InputExponent, Radix>>;
CNL_NODISCARD static constexpr _input half()
{
return static_cast<_input>(_impl::from_rep<_result>(1))/2;
}
public:
CNL_NODISCARD constexpr _result operator()(_input const& from) const
{
// TODO: unsigned specialization
return static_cast<_result>(from+((from >= 0) ? half() : -half()));
}
};
// conversion from float to scaled_integer
template<
typename ResultRep, int ResultExponent, int ResultRadix,
typename Input>
struct tagged_convert_operator<
nearest_rounding_tag,
scaled_integer<ResultRep, power<ResultExponent, ResultRadix>>,
Input,
_impl::enable_if_t<std::is_floating_point<Input>::value>> {
private:
using _result = scaled_integer<ResultRep, power<ResultExponent, ResultRadix>>;
CNL_NODISCARD static constexpr Input half()
{
return power_value<Input, ResultExponent-1, ResultRadix>();
}
public:
CNL_NODISCARD constexpr _result operator()(Input const& from) const
{
// TODO: unsigned specialization
return static_cast<_result>(from+((from >= 0) ? half() : -half()));
}
};
template<
typename ResultRep, class ResultScale,
typename Input>
struct tagged_convert_operator<
nearest_rounding_tag,
scaled_integer<ResultRep, ResultScale>,
Input,
_impl::enable_if_t<cnl::numeric_limits<Input>::is_integer>>
: tagged_convert_operator<
nearest_rounding_tag,
scaled_integer<ResultRep, ResultScale>,
scaled_integer<Input>> {
};
template<
typename Result,
typename InputRep, class InputScale>
struct tagged_convert_operator<
nearest_rounding_tag,
Result,
scaled_integer<InputRep, InputScale>,
_impl::enable_if_t<cnl::numeric_limits<Result>::is_integer>> {
using _input = scaled_integer<InputRep, InputScale>;
CNL_NODISCARD constexpr Result operator()(_input const& from) const
{
return _impl::to_rep(
_impl::tagged_convert_operator<nearest_rounding_tag, scaled_integer<Result>, _input>{}(
from));
}
};
}
}
#endif // CNL_IMPL_SCALED_INTEGER_TAGGED_CONVERT_OPERATOR_H
| 39.596774 | 111 | 0.587984 |
c0a25d544f6ec0be76640f3b864547856eb80f74 | 823 | c | C | c/command-injection.c | 0xdea/semgrep-rules | 1297667a6780af4060ef7bc0616a214087f1f88c | [
"MIT"
] | 1 | 2022-03-19T06:08:31.000Z | 2022-03-19T06:08:31.000Z | c/command-injection.c | 0xdea/semgrep-rules | 1297667a6780af4060ef7bc0616a214087f1f88c | [
"MIT"
] | null | null | null | c/command-injection.c | 0xdea/semgrep-rules | 1297667a6780af4060ef7bc0616a214087f1f88c | [
"MIT"
] | 1 | 2022-03-16T19:14:13.000Z | 2022-03-16T19:14:13.000Z | // Marco Ivaldi <raptor@0xdeadbeef.info>
#include <stdio.h>
#include <stdlib.h>
int invoke1(char *string)
{
char buf[] = "uname -a; id";
// ok: raptor-command-injection
system(buf);
// ok: raptor-command-injection
system("whoami");
// ruleid: raptor-command-injection
system(string);
}
int invoke2(char *string)
{
char buf[] = "uname -a; id";
// ok: raptor-command-injection
popen(buf, "r");
// ok: raptor-command-injection
popen("whoami", "r");
// ruleid: raptor-command-injection
popen(string, "r");
}
int send_mail(char *user)
{
char buf[1024];
FILE *fp;
snprintf(buf, sizeof(buf), "/usr/bin/sendmail -s \"hi\" %s", user);
// ruleid: raptor-command-injection
fp = popen(buf, "w");
if (fp == NULL)
return 1;
// ...
}
int main()
{
printf("Hello, World!");
return 0;
}
| 15.240741 | 68 | 0.618469 |
cba3804f4a21b79b170aa9978566f428838c84b6 | 9,368 | c | C | mibench/office/rsynth/say.c | hyu-iot/gem5 | aeccc8bd8e9a86f96fc7a6f40d978f8494337fc5 | [
"BSD-3-Clause"
] | 165 | 2020-07-23T00:34:24.000Z | 2022-03-18T16:30:59.000Z | mibench/office/rsynth/say.c | hyu-iot/gem5 | aeccc8bd8e9a86f96fc7a6f40d978f8494337fc5 | [
"BSD-3-Clause"
] | 80 | 2019-08-27T14:43:46.000Z | 2020-12-16T11:56:19.000Z | mibench/office/rsynth/say.c | hyu-iot/gem5 | aeccc8bd8e9a86f96fc7a6f40d978f8494337fc5 | [
"BSD-3-Clause"
] | 98 | 2019-08-30T14:29:16.000Z | 2020-11-21T18:22:13.000Z | #include <config.h>
/* $Id: say.c,v 1.13 1994/11/08 13:30:50 a904209 Exp a904209 $
$Log: say.c,v $
* Revision 1.13 1994/11/08 13:30:50 a904209
* 2.0 release
*
* Revision 1.12 1994/11/04 13:32:31 a904209
* 1.99.1 - Change configure stuff
*
* Revision 1.11 1994/11/02 10:55:31 a904209
* Add autoconf. Tested on SunOS/Solaris
*
* Revision 1.10 1994/10/04 17:12:50 a904209
* 3rd pre-release
*
* Revision 1.9 1994/10/04 09:08:27 a904209
* Next Patch merge
*
* Revision 1.8 1994/10/03 08:41:47 a904209
* 2nd pre-release
*
* Revision 1.7 1994/09/19 15:48:29 a904209
* Split hplay.c, gdbm dictionary, start of f0 contour, netaudio and HP ports
*
* Revision 1.6 1994/04/15 16:47:37 a904209
* Edits for Solaris2.3 (aka SunOs 5.3)
*
* Revision 1.5 1994/02/24 15:03:05 a904209
* Added contributed linux, NeXT and SGI ports.
*
* Revision 1.4 93/11/18 16:29:06 a904209
* Migrated nsyth.c towards Jon's scheme - merge still incomplete
*
* Revision 1.3 93/11/16 14:32:44 a904209
* Added RCS Ids, partial merge of Jon's new klatt/parwave
*
* Revision 1.3 93/11/16 14:00:58 a904209
* Add IDs and merge Jon's klatt sources - incomplete
*
*/
char *say_id = "$Id: say.c,v 1.13 1994/11/08 13:30:50 a904209 Exp a904209 $";
extern char *Revision;
#include <stdio.h>
#include <ctype.h>
#include <useconfig.h>
#include <math.h>
#include "proto.h"
#include "nsynth.h"
#include "hplay.h"
#include "dict.h"
#include "ASCII.h"
#include "darray.h"
#include "holmes.h"
#include "phtoelm.h"
#include "text.h"
#include "getargs.h"
#include "phones.h"
#include "file.h"
#include "say.h"
char *program = "say";
static int verbose = 0;
unsigned
spell_out(word, n, phone)
char *word;
int n;
darray_ptr phone;
{
unsigned nph = 0;
fprintf(stderr, "Spelling '%.*s'\n", n, word);
while (n-- > 0)
{
nph += xlate_string(ASCII[*word++ & 0x7F], phone);
}
return nph;
}
int
suspect_word(s, n)
char *s;
int n;
{
int i = 0;
int seen_lower = 0;
int seen_upper = 0;
int seen_vowel = 0;
int last = 0;
for (i = 0; i < n; i++)
{
char ch = *s++;
if (i && last != '-' && isupper(ch))
seen_upper = 1;
if (islower(ch))
{
seen_lower = 1;
ch = toupper(ch);
}
if (ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U' || ch == 'Y')
seen_vowel = 1;
last = ch;
}
return !seen_vowel || (seen_upper && seen_lower) || !seen_lower;
}
static unsigned xlate_word PROTO((char *word, int n, darray_ptr phone));
static unsigned
xlate_word(word, n, phone)
char *word;
int n;
darray_ptr phone;
{
unsigned nph = 0;
if (*word != '[')
{
if (dict)
{
unsigned char *p = dict_find(word, n);
if (p)
{
unsigned char *s = p;
while (*s)
{
char *x = dialect[(unsigned) (*s++)];
while (*x)
{
phone_append(phone, *x++);
nph++;
}
}
phone_append(phone, ' ');
free(p);
return nph + 1;
}
else
{
/* If supposed word contains '.' or '-' try breaking it up... */
char *h = word;
while (h < word + n)
{
if (*h == '.' || *h == '-')
{
nph += xlate_word(word, h++ - word, phone);
nph += xlate_word(h, word + n - h, phone);
return nph;
}
else
h++;
}
}
}
if (suspect_word(word, n))
return spell_out(word, n, phone);
else
{
if (dict || verbose)
fprintf(stderr, "Guess %p '%.*s'\n", dict, n, word);
nph += NRL(word, n, phone);
}
}
else
{
if ((++word)[(--n) - 1] == ']')
n--;
while (n-- > 0)
{
phone_append(phone, *word++);
nph++;
}
}
phone_append(phone, ' ');
return nph + 1;
}
void
say_phones(phone, len, verbose)
char *phone;
int len;
int verbose;
{
darray_t elm;
unsigned frames;
darray_init(&elm, sizeof(char), len);
if ((frames = phone_to_elm(phone, len, &elm)))
{
unsigned max_samples = frames * klatt_global.nspfr;
short *samp = (short *) malloc(sizeof(short) * max_samples);
if (verbose)
fprintf(stderr,"%.*s\n", len, phone);
if (samp)
{
unsigned nsamp = holmes(elm.items, (unsigned char *) darray_find(&elm, 0),
max_samples, samp);
audio_play(nsamp, samp);
if (file_write)
(*file_write)(nsamp, samp);
free(samp);
}
}
darray_free(&elm);
}
unsigned
xlate_string(string, phone)
char *string;
darray_ptr phone;
{
unsigned nph = 0;
char *s = string;
char ch;
while (isspace(ch = *s))
s++;
while ((ch = *s))
{
char *word = s;
if (isalpha(ch))
{
while (isalpha(ch = *s) || ((ch == '\'' || ch == '-' || ch == '.') && isalpha(s[1])))
s++;
if (!ch || isspace(ch) || ispunct(ch) || (isdigit(ch) && !suspect_word(word, s - word)))
nph += xlate_word(word, s - word, phone);
else
{
while ((ch = *s) && !isspace(ch) && !ispunct(ch))
s++;
nph += spell_out(word, s - word, phone);
}
}
else if (isdigit(ch) || (ch == '-' && isdigit(s[1])))
{
int sign = (ch == '-') ? -1 : 1;
long value = 0;
if (sign < 0)
ch = *++s;
while (isdigit(ch = *s))
{
value = value * 10 + ch - '0';
s++;
}
if (ch == '.' && isdigit(s[1]))
{
word = ++s;
nph += xlate_cardinal(value * sign, phone);
nph += xlate_string("point", phone);
while (isdigit(ch = *s))
s++;
nph += spell_out(word, s - word, phone);
}
else
{
/* check for ordinals, date, time etc. can go in here */
nph += xlate_cardinal(value * sign, phone);
}
}
else if (ch == '[' && strchr(s, ']'))
{
char *word = s;
while (*s && *s++ != ']')
/* nothing */ ;
nph += xlate_word(word, s - word, phone);
}
else if (ispunct(ch))
{
switch (ch)
{
/* On end of sentence flush the buffer ... */
case '!':
case '?':
case '.':
if ((!s[1] || isspace(s[1])) && phone->items)
{
say_phones((char *) darray_find(phone, 0), phone->items, verbose);
phone->items = 0;
}
s++;
phone_append(phone, ' ');
break;
case '"': /* change pitch ? */
case ':':
case '-':
case ';':
case ',':
case '(':
case ')':
s++;
phone_append(phone, ' ');
break;
case '[':
{
char *e = strchr(s, ']');
if (e)
{
s++;
while (s < e)
phone_append(phone, *s++);
s = e + 1;
break;
}
}
default:
nph += spell_out(word, 1, phone);
s++;
break;
}
}
else
{
while ((ch = *s) && !isspace(ch))
s++;
nph += spell_out(word, s - word, phone);
}
while (isspace(ch = *s))
s++;
}
return nph;
}
char *
concat_args(argc, argv)
int argc;
char *argv[];
{
int len = 0;
int i;
char *buf;
for (i = 1; i < argc; i++)
len += strlen(argv[i]) + 1;
buf = (char *) malloc(len);
if (buf)
{
char *d = buf;
for (i = 1; i < argc;)
{
char *s = argv[i++];
while (*s)
*d++ = *s++;
if (i < argc)
*d++ = ' ';
else
*d = '\0';
}
}
return buf;
}
void
say_string(s)
char *s;
{
darray_t phone;
darray_init(&phone, sizeof(char), 128);
xlate_string(s, &phone);
if (phone.items)
say_phones((char *) darray_find(&phone, 0), phone.items, verbose);
darray_free(&phone);
}
extern int darray_fget PROTO((FILE * f, darray_ptr p));
int
darray_fget(f, p)
FILE *f;
darray_ptr p;
{
int ch;
while ((ch = fgetc(f)) != EOF)
{
phone_append(p, ch);
if (ch == '\n')
break;
}
phone_append(p, '\0');
return p->items - 1;
}
extern void say_file PROTO((FILE * f));
void
say_file(f)
FILE *f;
{
darray_t line;
darray_t phone;
darray_init(&line, sizeof(char), 128);
darray_init(&phone, sizeof(char), 128);
while (darray_fget(f, &line))
{
xlate_string((char *) darray_find(&line, 0), &phone);
line.items = 0;
}
if (phone.items)
say_phones((char *) darray_find(&phone, 0), phone.items, verbose);
darray_free(&phone);
darray_free(&line);
}
int main PROTO((int argc, char *argv[], char *env[]));
int
main(argc, argv, env)
int argc;
char *argv[];
char *env[];
{
program = argv[0];
argc = audio_init(argc, argv);
argc = init_synth(argc, argv);
argc = init_holmes(argc, argv);
argc = dict_init(argc, argv);
argc = file_init(argc, argv);
argc = getargs("Misc",argc, argv, "v", NULL, &verbose, "Verbose, show phonetic form",NULL);
if (help_only)
{
fprintf(stderr,"Usage: %s [options as above] words to say\n",program);
fprintf(stderr,"or %s [options as above] < file-to-say\n",program);
fprintf(stderr,"(%s)\n",Revision);
}
else
{
if (argc > 1)
{
char *s = concat_args(argc, argv);
if (s)
{
say_string(s);
free(s);
}
}
else
say_file(stdin);
}
if (file_term)
(*file_term)();
audio_term();
term_holmes();
if (dict)
dict_term();
return (0);
}
| 21.051685 | 93 | 0.511208 |
3fdd6221a0a1d92e639aff03d0c38b004b779cdc | 253 | h | C | anim/anim.h | ibarisic05/anim | e8c5504d5bb0b1af808d5fb16fd240c35903245f | [
"MIT"
] | 527 | 2016-01-20T16:46:02.000Z | 2022-03-01T05:27:19.000Z | anim/anim.h | ibarisic05/anim | e8c5504d5bb0b1af808d5fb16fd240c35903245f | [
"MIT"
] | 4 | 2016-09-19T01:38:52.000Z | 2018-09-28T09:48:41.000Z | anim/anim.h | ibarisic05/anim | e8c5504d5bb0b1af808d5fb16fd240c35903245f | [
"MIT"
] | 43 | 2016-02-10T23:06:38.000Z | 2022-01-29T15:58:07.000Z | //
// anim.h
// anim
//
// Created by Onur Ersel on 2017-02-17.
// Copyright © 2017 Onur Ersel. All rights reserved.
//
#import <UIKit/UIKit.h>
FOUNDATION_EXPORT double animVersionNumber;
FOUNDATION_EXPORT const unsigned char animVersionString[];
| 19.461538 | 58 | 0.727273 |
3f272b81ccdf79b9e4b999f4c9b625c056be045b | 2,045 | h | C | nhelper/args_check.h | xhcoding/node-addon-helper | 5d7f2e69e388eb22ed5a271bbdce35f0aa724e5d | [
"MIT"
] | 2 | 2020-07-25T20:43:12.000Z | 2020-11-18T06:29:57.000Z | nhelper/args_check.h | xhcoding/node-addon-helper | 5d7f2e69e388eb22ed5a271bbdce35f0aa724e5d | [
"MIT"
] | 1 | 2021-09-02T11:13:50.000Z | 2021-09-02T11:13:50.000Z | nhelper/args_check.h | xhcoding/node-addon-helper | 5d7f2e69e388eb22ed5a271bbdce35f0aa724e5d | [
"MIT"
] | null | null | null | #pragma once
#include <napi.h>
#include <sstream>
#include <string>
#include <type_traits>
#include "type_converter.h"
namespace Nhelper {
inline void CheckInfoLength(const Napi::CallbackInfo& info, size_t expect_length) {
if (info.Length() != expect_length) {
std::stringstream ss;
ss << "Wrong number of arguments! expect: " << expect_length
<< ", actual: " << info.Length();
throw Napi::TypeError::New(info.Env(), ss.str());
}
}
template <typename T>
inline void CheckInfoType(const Napi::CallbackInfo& info, size_t idx) {
if (!TypeConverter<std::decay_t<T>>::IsConvertible(info[idx])) {
std::stringstream ss;
ss << "Type of arg " << idx << " is not matched! expect: "
<< TypeConverter<std::decay_t<T>>::TypeName()
<< ", actual: " << TypeName(info[idx]);
throw Napi::TypeError::New(info.Env(), ss.str());
}
}
inline void CheckInfoTypeIsFunction(const Napi::CallbackInfo& info, size_t idx) {
if (!info[idx].IsFunction()) {
std::stringstream ss;
ss << "Type of arg " << idx << " is not matched! expect: Function"
<< ", actual: " << TypeName(info[idx]);
throw Napi::TypeError::New(info.Env(), ss.str());
}
}
namespace details {
template <typename... Args>
struct CheckInfoTypeImpl {
static void Check(const Napi::CallbackInfo& /* info */, size_t /* start_idx */, size_t /* end_idx */) {
}
};
template <typename T, typename... Rest>
struct CheckInfoTypeImpl<T, Rest...> {
static void Check(const Napi::CallbackInfo& info, size_t start_idx, size_t end_idx) {
if (start_idx == end_idx) {
return;
}
CheckInfoType<T>(info, start_idx);
CheckInfoTypeImpl<Rest...>::Check(info, start_idx + 1, end_idx);
}
};
}
template <typename... Args>
inline void CheckInfoType(const Napi::CallbackInfo& info, size_t start_idx, size_t end_idx) {
details::CheckInfoTypeImpl<Args...>::Check(info, start_idx, end_idx);
}
} // namespace Nhelper
| 26.558442 | 107 | 0.623472 |
8b99e3783fb72321096bbaf37387154bea200f3f | 460 | h | C | Resources/Chat.h | stanwood/Stanwood_Chat_iOS | 134a18eaeed03a8ba444d59badd43bc626653f47 | [
"MIT"
] | 1 | 2018-08-22T07:04:38.000Z | 2018-08-22T07:04:38.000Z | Resources/Chat.h | stanwood/Stanwood_Chat_iOS | 134a18eaeed03a8ba444d59badd43bc626653f47 | [
"MIT"
] | null | null | null | Resources/Chat.h | stanwood/Stanwood_Chat_iOS | 134a18eaeed03a8ba444d59badd43bc626653f47 | [
"MIT"
] | 2 | 2018-08-19T19:55:40.000Z | 2018-11-30T10:39:17.000Z | //
// Chat.h
// Chat
//
// Created by Maciek on 17.01.2018.
// Copyright © 2018 Stanwood GmbH. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for Chat.
FOUNDATION_EXPORT double ChatVersionNumber;
//! Project version string for Chat.
FOUNDATION_EXPORT const unsigned char ChatVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <Chat/PublicHeader.h>
| 23 | 129 | 0.741304 |
8bca734fe0977b507b944ffc4b13f588b31a6fce | 1,712 | h | C | Wml/Source/Graphics/WmlSkinController.h | 1iyiwei/deform2d | 1a350dd20f153e72de1ea9cffb873eb67bf3d668 | [
"MIT"
] | 26 | 2018-07-04T15:31:11.000Z | 2021-09-23T02:43:46.000Z | Wml/Source/Graphics/WmlSkinController.h | 1iyiwei/deform2d | 1a350dd20f153e72de1ea9cffb873eb67bf3d668 | [
"MIT"
] | null | null | null | Wml/Source/Graphics/WmlSkinController.h | 1iyiwei/deform2d | 1a350dd20f153e72de1ea9cffb873eb67bf3d668 | [
"MIT"
] | 1 | 2019-06-11T03:20:28.000Z | 2019-06-11T03:20:28.000Z | // Magic Software, Inc.
// http://www.magic-software.com
// http://www.wild-magic.com
// Copyright (c) 2004. All Rights Reserved
//
// The Wild Magic Library (WML) source code is supplied under the terms of
// the license agreement http://www.magic-software.com/License/WildMagic.pdf
// and may not be copied or disclosed except in accordance with the terms of
// that agreement.
#ifndef WMLSKINCONTROLLER_H
#define WMLSKINCONTROLLER_H
#include "WmlController.h"
#include "WmlGeometry.h"
#include "WmlNode.h"
namespace Wml
{
class WML_ITEM SkinController : public Controller
{
WmlDeclareRTTI;
WmlDeclareStream;
public:
SkinController ();
virtual ~SkinController ();
// Bone nodes. The first bone in the array must be the root bone. The
// skin controller needs access to its parent (if any) for setting the
// trimesh object's local transforms.
int& BoneQuantity ();
Node**& Bones ();
// Skin vertices. The relationship between vertices and bones is
// contained in this information.
class WML_ITEM SkinVertex
{
public:
int m_iIndex;
float m_fWeight;
Vector3f m_kOffset;
};
int*& SkinVertexQuantities ();
SkinVertex**& SkinVertices ();
virtual bool Update (float fAppTime);
protected:
int m_iBoneQuantity;
Node** m_apkBone; // Node*[bone_quantity]
int* m_aiSkinVertexQuantity; // int[bone_quantity]
// skinvert[bone_quantity][skinvertquan[i]], 0 <= i < bone_quantity
SkinVertex** m_aakSkinVertex;
};
WmlSmartPointer(SkinController);
WmlRegisterStream(SkinController);
#include "WmlSkinController.inl"
}
#endif
| 25.552239 | 77 | 0.675818 |
8f9325d53033442597012097ac1c3513bd729160 | 97 | c | C | example/lang/future/anonymous.c | DaemonSnake/postfix | e26030e40985b664dbd329948c8a3077686783cd | [
"MIT"
] | 1 | 2019-12-12T04:27:06.000Z | 2019-12-12T04:27:06.000Z | example/lang/future/anonymous.c | DaemonSnake/macropp | e26030e40985b664dbd329948c8a3077686783cd | [
"MIT"
] | 3 | 2016-12-11T18:39:06.000Z | 2016-12-11T18:49:49.000Z | example/lang/future/anonymous.c | DaemonSnake/macropp | e26030e40985b664dbd329948c8a3077686783cd | [
"MIT"
] | null | null | null | int main()
{
int i;
Object tmp = new_class(Object, IStream)(i) {
}.as(Object)
}
| 12.125 | 48 | 0.525773 |
8f4e2da42bd47e02cac6d6057d711213da11da0b | 1,975 | h | C | src/include/mpichconfconst.h | OpenCMISS-Dependencies/mpich2 | cc5f4d3fd0f8c9f2774d10deaebdced77985d839 | [
"Unlicense"
] | 1 | 2015-09-11T07:55:48.000Z | 2015-09-11T07:55:48.000Z | src/include/mpichconfconst.h | grondo/mvapich2-cce | ec084d8e07db1cf2ac1352ee4c604ae7dbae55cb | [
"Intel",
"mpich2",
"Unlicense"
] | null | null | null | src/include/mpichconfconst.h | grondo/mvapich2-cce | ec084d8e07db1cf2ac1352ee4c604ae7dbae55cb | [
"Intel",
"mpich2",
"Unlicense"
] | 2 | 2015-11-27T23:24:14.000Z | 2021-03-29T07:06:34.000Z | /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
* (C) 2009 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
/* This header file contains constants that might end up on the right hand side
* of a #define in mpichconf.h.
*
* In particular, this file must provide any constants that might be used for
* conditional compilation in mpidpre.h, before most of the other headers have
* been included in mpiimpl.h. */
#ifndef MPICHCONFCONST_H_INCLUDED
#define MPICHCONFCONST_H_INCLUDED
#define MPICH_ERROR_MSG_NONE 0
#define MPICH_ERROR_MSG_CLASS 1
#define MPICH_ERROR_MSG_GENERIC 2
#define MPICH_ERROR_MSG_ALL 8
/* -------------------------------------------------------------------- */
/* thread-related constants */
/* -------------------------------------------------------------------- */
/* Define the four ways that we achieve proper thread-safe updates of
* shared structures and services
*
* A configure choice will set MPIU_THREAD_GRANULARITY to one of these values */
/* _INVALID exists to avoid accidental macro evaluations to 0 */
#define MPIU_THREAD_GRANULARITY_INVALID 0
#define MPIU_THREAD_GRANULARITY_GLOBAL 1
#define MPIU_THREAD_GRANULARITY_BRIEF_GLOBAL 2
#define MPIU_THREAD_GRANULARITY_PER_OBJECT 3
#define MPIU_THREAD_GRANULARITY_LOCK_FREE 4
/* _SINGLE is the "null" granularity, where all processes are single-threaded */
#define MPIU_THREAD_GRANULARITY_SINGLE 5
/* controls the allocation mechanism for MPID_Request handles, which can greatly
* affect concurrency on the critical path */
#define MPIU_HANDLE_ALLOCATION_MUTEX 0
#define MPIU_HANDLE_ALLOCATION_THREAD_LOCAL 1
/* _INVALID exists to avoid accidental macro evaluations to 0 */
#define MPIU_REFCOUNT_INVALID 0
/* _NONE means no concurrency control, such as when using MPI_THREAD_SINGLE */
#define MPIU_REFCOUNT_NONE 1
#define MPIU_REFCOUNT_LOCK 2
#define MPIU_REFCOUNT_LOCKFREE 3
#endif /* MPICHCONFCONST_H_INCLUDED */
| 37.264151 | 80 | 0.730633 |
6aa8bb8a55d27037eb03c053d42610e0062d0ffb | 26,732 | c | C | ext/calendar/jewish.c | aria4c/brew71 | 44205bfccff32d55d93469617e7d74b527f46e84 | [
"PHP-3.01"
] | 45 | 2019-07-05T09:05:07.000Z | 2020-08-28T09:31:39.000Z | ext/calendar/jewish.c | aria4c/brew71 | 44205bfccff32d55d93469617e7d74b527f46e84 | [
"PHP-3.01"
] | null | null | null | ext/calendar/jewish.c | aria4c/brew71 | 44205bfccff32d55d93469617e7d74b527f46e84 | [
"PHP-3.01"
] | 6 | 2019-07-05T09:13:58.000Z | 2020-07-22T07:35:55.000Z | /* $selId: jewish.c,v 2.0 1995/10/24 01:13:06 lees Exp $
* Copyright 1993-1995, Scott E. Lee, all rights reserved.
* Permission granted to use, copy, modify, distribute and sell so long as
* the above copyright and this permission statement are retained in all
* copies. THERE IS NO WARRANTY - USE AT YOUR OWN RISK.
*/
/**************************************************************************
*
* These are the externally visible components of this file:
*
* void
* SdnToJewish(
* long int sdn,
* int *pYear,
* int *pMonth,
* int *pDay);
*
* Convert a SDN to a Jewish calendar date. If the input SDN is before the
* first day of year 1, the three output values will all be set to zero,
* otherwise *pYear will be > 0; *pMonth will be in the range 1 to 13
* inclusive; *pDay will be in the range 1 to 30 inclusive. Note that Adar
* II is assigned the month number 7 and Elul is always 13.
*
* long int
* JewishToSdn(
* int year,
* int month,
* int day);
*
* Convert a Jewish calendar date to a SDN. Zero is returned when the
* input date is detected as invalid or out of the supported range. The
* return value will be > 0 for all valid, supported dates, but there are
* some invalid dates that will return a positive value. To verify that a
* date is valid, convert it to SDN and then back and compare with the
* original.
*
* char *JewishMonthName[14];
*
* Convert a Jewish month number (1 to 13) to the name of the Jewish month
* (null terminated). An index of zero will return a zero length string.
*
* VALID RANGE
*
* Although this software can handle dates all the way back to the year
* 1 (3761 B.C.), such use may not be meaningful.
*
* The Jewish calendar has been in use for several thousand years, but
* in the early days there was no formula to determine the start of a
* month. A new month was started when the new moon was first
* observed.
*
* It is not clear when the current rule based calendar replaced the
* observation based calendar. According to the book "Jewish Calendar
* Mystery Dispelled" by George Zinberg, the patriarch Hillel II
* published these rules in 358 A.D. But, according to The
* Encyclopedia Judaica, Hillel II may have only published the 19 year
* rule for determining the occurrence of leap years.
*
* I have yet to find a specific date when the current set of rules
* were known to be in use.
*
* CALENDAR OVERVIEW
*
* The Jewish calendar is based on lunar as well as solar cycles. A
* month always starts on or near a new moon and has either 29 or 30
* days (a lunar cycle is about 29 1/2 days). Twelve of these
* alternating 29-30 day months gives a year of 354 days, which is
* about 11 1/4 days short of a solar year.
*
* Since a month is defined to be a lunar cycle (new moon to new moon),
* this 11 1/4 day difference cannot be overcome by adding days to a
* month as with the Gregorian calendar, so an entire month is
* periodically added to the year, making some years 13 months long.
*
* For astronomical as well as ceremonial reasons, the start of a new
* year may be delayed until a day or two after the new moon causing
* years to vary in length. Leap years can be from 383 to 385 days and
* common years can be from 353 to 355 days. These are the months of
* the year and their possible lengths:
*
* COMMON YEAR LEAP YEAR
* 1 Tishri 30 30 30 30 30 30
* 2 Heshvan 29 29 30 29 29 30 (variable)
* 3 Kislev 29 30 30 29 30 30 (variable)
* 4 Tevet 29 29 29 29 29 29
* 5 Shevat 30 30 30 30 30 30
* 6 Adar I -- -- -- 30 30 30 (optional)
* 7 Adar (II) 29 29 29 29 29 29
* 8 Nisan 30 30 30 30 30 30
* 9 Iyyar 29 29 29 29 29 29
* 10 Sivan 30 30 30 30 30 30
* 11 Tammuz 29 29 29 29 29 29
* 12 Av 30 30 30 30 30 30
* 13 Elul 29 29 29 29 29 29
* --- --- --- --- --- ---
* 353 354 355 383 384 385
*
* Note that the month names and other words that appear in this file
* have multiple possible spellings in the Roman character set. I have
* chosen to use the spellings found in the Encyclopedia Judaica.
*
* Adar I, the month added for leap years, is sometimes referred to as
* the 13th month, but I have chosen to assign it the number 6 to keep
* the months in chronological order. This may not be consistent with
* other numbering schemes.
*
* Leap years occur in a fixed pattern of 19 years called the metonic
* cycle. The 3rd, 6th, 8th, 11th, 14th, 17th and 19th years of this
* cycle are leap years. The first metonic cycle starts with Jewish
* year 1, or 3761/60 B.C. This is believed to be the year of
* creation.
*
* To construct the calendar for a year, you must first find the length
* of the year by determining the first day of the year (Tishri 1, or
* Rosh Ha-Shanah) and the first day of the following year. This
* selects one of the six possible month length configurations listed
* above.
*
* Finding the first day of the year is the most difficult part.
* Finding the date and time of the new moon (or molad) is the first
* step. For this purpose, the lunar cycle is assumed to be 29 days 12
* hours and 793 halakim. A halakim is 1/1080th of an hour or 3 1/3
* seconds. (This assumed value is only about 1/2 second less than the
* value used by modern astronomers -- not bad for a number that was
* determined so long ago.) The first molad of year 1 occurred on
* Sunday at 11:20:11 P.M. This would actually be Monday, because the
* Jewish day is considered to begin at sunset.
*
* Since sunset varies, the day is assumed to begin at 6:00 P.M. for
* calendar calculation purposes. So, the first molad was 5 hours 793
* halakim after the start of Tishri 1, 0001 (which was Monday
* September 7, 4761 B.C. by the Gregorian calendar). All subsequent
* molads can be calculated from this starting point by adding the
* length of a lunar cycle.
*
* Once the molad that starts a year is determined the actual start of
* the year (Tishri 1) can be determined. Tishri 1 will be the day of
* the molad unless it is delayed by one of the following four rules
* (called dehiyyot). Each rule can delay the start of the year by one
* day, and since rule #1 can combine with one of the other rules, it
* can be delayed as much as two days.
*
* 1. Tishri 1 must never be Sunday, Wednesday or Friday. (This
* is largely to prevent certain holidays from occurring on the
* day before or after the Sabbath.)
*
* 2. If the molad occurs on or after noon, Tishri 1 must be
* delayed.
*
* 3. If it is a common (not leap) year and the molad occurs on
* Tuesday at or after 3:11:20 A.M., Tishri 1 must be delayed.
*
* 4. If it is the year following a leap year and the molad occurs
* on Monday at or after 9:32:43 and 1/3 sec, Tishri 1 must be
* delayed.
*
* GLOSSARY
*
* dehiyyot The set of 4 rules that determine when the new year
* starts relative to the molad.
*
* halakim 1/1080th of an hour or 3 1/3 seconds.
*
* lunar cycle The period of time between mean conjunctions of the
* sun and moon (new moon to new moon). This is
* assumed to be 29 days 12 hours and 793 halakim for
* calendar purposes.
*
* metonic cycle A 19 year cycle which determines which years are
* leap years and which are common years. The 3rd,
* 6th, 8th, 11th, 14th, 17th and 19th years of this
* cycle are leap years.
*
* molad The date and time of the mean conjunction of the
* sun and moon (new moon). This is the approximate
* beginning of a month.
*
* Rosh Ha-Shanah The first day of the Jewish year (Tishri 1).
*
* Tishri The first month of the Jewish year.
*
* ALGORITHMS
*
* SERIAL DAY NUMBER TO JEWISH DATE
*
* The simplest approach would be to use the rules stated above to find
* the molad of Tishri before and after the given day number. Then use
* the molads to find Tishri 1 of the current and following years.
* From this the length of the year can be determined and thus the
* length of each month. But this method is used as a last resort.
*
* The first 59 days of the year are the same regardless of the length
* of the year. As a result, only the day number of the start of the
* year is required.
*
* Similarly, the last 6 months do not change from year to year. And
* since it can be determined whether the year is a leap year by simple
* division, the lengths of Adar I and II can be easily calculated. In
* fact, all dates after the 3rd month are consistent from year to year
* (once it is known whether it is a leap year).
*
* This means that if the given day number falls in the 3rd month or on
* the 30th day of the 2nd month the length of the year must be found,
* but in no other case.
*
* So, the approach used is to take the given day number and round it
* to the closest molad of Tishri (first new moon of the year). The
* rounding is not really to the *closest* molad, but is such that if
* the day number is before the middle of the 3rd month the molad at
* the start of the year is found, otherwise the molad at the end of
* the year is found.
*
* Only if the day number is actually found to be in the ambiguous
* period of 29 to 31 days is the other molad calculated.
*
* JEWISH DATE TO SERIAL DAY NUMBER
*
* The year number is used to find which 19 year metonic cycle contains
* the date and which year within the cycle (this is a division and
* modulus). This also determines whether it is a leap year.
*
* If the month is 1 or 2, the calculation is simple addition to the
* first of the year.
*
* If the month is 8 (Nisan) or greater, the calculation is simple
* subtraction from beginning of the following year.
*
* If the month is 4 to 7, it is considered whether it is a leap year
* and then simple subtraction from the beginning of the following year
* is used.
*
* Only if it is the 3rd month is both the start and end of the year
* required.
*
* TESTING
*
* This algorithm has been tested in two ways. First, 510 dates from a
* table in "Jewish Calendar Mystery Dispelled" were calculated and
* compared to the table. Second, the calculation algorithm described
* in "Jewish Calendar Mystery Dispelled" was coded and used to verify
* all dates from the year 1 (3761 B.C.) to the year 13760 (10000
* A.D.).
*
* The source code of the verification program is included in this
* package.
*
* REFERENCES
*
* The Encyclopedia Judaica, the entry for "Calendar"
*
* The Jewish Encyclopedia
*
* Jewish Calendar Mystery Dispelled by George Zinberg, Vantage Press,
* 1963
*
* The Comprehensive Hebrew Calendar by Arthur Spier, Behrman House
*
* The Book of Calendars [note that this work contains many typos]
*
**************************************************************************/
#if defined(PHP_WIN32)
#pragma setlocale("english")
#endif
#include "sdncal.h"
#define HALAKIM_PER_HOUR 1080
#define HALAKIM_PER_DAY 25920
#define HALAKIM_PER_LUNAR_CYCLE ((29 * HALAKIM_PER_DAY) + 13753)
#define HALAKIM_PER_METONIC_CYCLE (HALAKIM_PER_LUNAR_CYCLE * (12 * 19 + 7))
#define JEWISH_SDN_OFFSET 347997
#define JEWISH_SDN_MAX 324542846L /* 12/13/887605, greater value raises interger overflow */
#define NEW_MOON_OF_CREATION 31524
#define SUNDAY 0
#define MONDAY 1
#define TUESDAY 2
#define WEDNESDAY 3
#define THURSDAY 4
#define FRIDAY 5
#define SATURDAY 6
#define NOON (18 * HALAKIM_PER_HOUR)
#define AM3_11_20 ((9 * HALAKIM_PER_HOUR) + 204)
#define AM9_32_43 ((15 * HALAKIM_PER_HOUR) + 589)
int monthsPerYear[19] =
{
12, 12, 13, 12, 12, 13, 12, 13, 12, 12, 13, 12, 12, 13, 12, 12, 13, 12, 13
};
static int yearOffset[19] =
{
0, 12, 24, 37, 49, 61, 74, 86, 99, 111, 123,
136, 148, 160, 173, 185, 197, 210, 222
};
/* names for leap (13-month) year */
char *JewishMonthNameLeap[14] =
{
"",
"Tishri",
"Heshvan",
"Kislev",
"Tevet",
"Shevat",
"Adar I",
"Adar II",
"Nisan",
"Iyyar",
"Sivan",
"Tammuz",
"Av",
"Elul"
};
/* names for regular year */
char *JewishMonthName[14] =
{
"",
"Tishri",
"Heshvan",
"Kislev",
"Tevet",
"Shevat",
"",
"Adar",
"Nisan",
"Iyyar",
"Sivan",
"Tammuz",
"Av",
"Elul"
};
/* names for leap (13-month) year */
char *JewishMonthHebNameLeap[14] =
{
"",
"\xFA\xF9\xF8\xE9",
"\xE7\xF9\xE5\xEF",
"\xEB\xF1\xEC\xE5",
"\xE8\xE1\xFA",
"\xF9\xE1\xE8",
"\xE0\xE3\xF8 \xE0'",
"\xE0\xE3\xF8 \xE1'",
"\xF0\xE9\xF1\xEF",
"\xE0\xE9\xE9\xF8",
"\xF1\xE9\xe5\xEF",
"\xFA\xEE\xE5\xE6",
"\xE0\xE1",
"\xE0\xEC\xE5\xEC"
};
/* names for regular year */
char *JewishMonthHebName[14] =
{
"",
"\xFA\xF9\xF8\xE9",
"\xE7\xF9\xE5\xEF",
"\xEB\xF1\xEC\xE5",
"\xE8\xE1\xFA",
"\xF9\xE1\xE8",
"",
"\xE0\xE3\xF8",
"\xF0\xE9\xF1\xEF",
"\xE0\xE9\xE9\xF8",
"\xF1\xE9\xE5\xEF",
"\xFA\xEE\xE5\xE6",
"\xE0\xE1",
"\xE0\xEC\xE5\xEC"
};
/************************************************************************
* Given the year within the 19 year metonic cycle and the time of a molad
* (new moon) which starts that year, this routine will calculate what day
* will be the actual start of the year (Tishri 1 or Rosh Ha-Shanah). This
* first day of the year will be the day of the molad unless one of 4 rules
* (called dehiyyot) delays it. These 4 rules can delay the start of the
* year by as much as 2 days.
*/
static zend_long Tishri1(
int metonicYear,
zend_long moladDay,
zend_long moladHalakim)
{
zend_long tishri1;
int dow;
int leapYear;
int lastWasLeapYear;
tishri1 = moladDay;
dow = tishri1 % 7;
leapYear = metonicYear == 2 || metonicYear == 5 || metonicYear == 7
|| metonicYear == 10 || metonicYear == 13 || metonicYear == 16
|| metonicYear == 18;
lastWasLeapYear = metonicYear == 3 || metonicYear == 6
|| metonicYear == 8 || metonicYear == 11 || metonicYear == 14
|| metonicYear == 17 || metonicYear == 0;
/* Apply rules 2, 3 and 4. */
if ((moladHalakim >= NOON) ||
((!leapYear) && dow == TUESDAY && moladHalakim >= AM3_11_20) ||
(lastWasLeapYear && dow == MONDAY && moladHalakim >= AM9_32_43)) {
tishri1++;
dow++;
if (dow == 7) {
dow = 0;
}
}
/* Apply rule 1 after the others because it can cause an additional
* delay of one day. */
if (dow == WEDNESDAY || dow == FRIDAY || dow == SUNDAY) {
tishri1++;
}
return (tishri1);
}
/************************************************************************
* Given a metonic cycle number, calculate the date and time of the molad
* (new moon) that starts that cycle. Since the length of a metonic cycle
* is a constant, this is a simple calculation, except that it requires an
* intermediate value which is bigger that 32 bits. Because this
* intermediate value only needs 36 to 37 bits and the other numbers are
* constants, the process has been reduced to just a few steps.
*/
static void MoladOfMetonicCycle(
int metonicCycle,
zend_long *pMoladDay,
zend_long *pMoladHalakim)
{
register zend_ulong r1, r2, d1, d2;
/* Start with the time of the first molad after creation. */
r1 = NEW_MOON_OF_CREATION;
/* Calculate metonicCycle * HALAKIM_PER_METONIC_CYCLE. The upper 32
* bits of the result will be in r2 and the lower 16 bits will be
* in r1. */
r1 += metonicCycle * (HALAKIM_PER_METONIC_CYCLE & 0xFFFF);
r2 = r1 >> 16;
r2 += metonicCycle * ((HALAKIM_PER_METONIC_CYCLE >> 16) & 0xFFFF);
/* Calculate r2r1 / HALAKIM_PER_DAY. The remainder will be in r1, the
* upper 16 bits of the quotient will be in d2 and the lower 16 bits
* will be in d1. */
d2 = r2 / HALAKIM_PER_DAY;
r2 -= d2 * HALAKIM_PER_DAY;
r1 = (r2 << 16) | (r1 & 0xFFFF);
d1 = r1 / HALAKIM_PER_DAY;
r1 -= d1 * HALAKIM_PER_DAY;
*pMoladDay = (d2 << 16) | d1;
*pMoladHalakim = r1;
}
/************************************************************************
* Given a day number, find the molad of Tishri (the new moon at the start
* of a year) which is closest to that day number. It's not really the
* *closest* molad that we want here. If the input day is in the first two
* months, we want the molad at the start of the year. If the input day is
* in the fourth to last months, we want the molad at the end of the year.
* If the input day is in the third month, it doesn't matter which molad is
* returned, because both will be required. This type of "rounding" allows
* us to avoid calculating the length of the year in most cases.
*/
static void FindTishriMolad(
zend_long inputDay,
int *pMetonicCycle,
int *pMetonicYear,
zend_long *pMoladDay,
zend_long *pMoladHalakim)
{
zend_long moladDay;
zend_long moladHalakim;
int metonicCycle;
int metonicYear;
/* Estimate the metonic cycle number. Note that this may be an under
* estimate because there are 6939.6896 days in a metonic cycle not
* 6940, but it will never be an over estimate. The loop below will
* correct for any error in this estimate. */
metonicCycle = (inputDay + 310) / 6940;
/* Calculate the time of the starting molad for this metonic cycle. */
MoladOfMetonicCycle(metonicCycle, &moladDay, &moladHalakim);
/* If the above was an under estimate, increment the cycle number until
* the correct one is found. For modern dates this loop is about 98.6%
* likely to not execute, even once, because the above estimate is
* really quite close. */
while (moladDay < inputDay - 6940 + 310) {
metonicCycle++;
moladHalakim += HALAKIM_PER_METONIC_CYCLE;
moladDay += moladHalakim / HALAKIM_PER_DAY;
moladHalakim = moladHalakim % HALAKIM_PER_DAY;
}
/* Find the molad of Tishri closest to this date. */
for (metonicYear = 0; metonicYear < 18; metonicYear++) {
if (moladDay > inputDay - 74) {
break;
}
moladHalakim += HALAKIM_PER_LUNAR_CYCLE * monthsPerYear[metonicYear];
moladDay += moladHalakim / HALAKIM_PER_DAY;
moladHalakim = moladHalakim % HALAKIM_PER_DAY;
}
*pMetonicCycle = metonicCycle;
*pMetonicYear = metonicYear;
*pMoladDay = moladDay;
*pMoladHalakim = moladHalakim;
}
/************************************************************************
* Given a year, find the number of the first day of that year and the date
* and time of the starting molad.
*/
static void FindStartOfYear(
int year,
int *pMetonicCycle,
int *pMetonicYear,
zend_long *pMoladDay,
zend_long *pMoladHalakim,
int *pTishri1)
{
*pMetonicCycle = (year - 1) / 19;
*pMetonicYear = (year - 1) % 19;
MoladOfMetonicCycle(*pMetonicCycle, pMoladDay, pMoladHalakim);
*pMoladHalakim += HALAKIM_PER_LUNAR_CYCLE * yearOffset[*pMetonicYear];
*pMoladDay += *pMoladHalakim / HALAKIM_PER_DAY;
*pMoladHalakim = *pMoladHalakim % HALAKIM_PER_DAY;
*pTishri1 = Tishri1(*pMetonicYear, *pMoladDay, *pMoladHalakim);
}
/************************************************************************
* Given a serial day number (SDN), find the corresponding year, month and
* day in the Jewish calendar. The three output values will always be
* modified. If the input SDN is before the first day of year 1, they will
* all be set to zero, otherwise *pYear will be > 0; *pMonth will be in the
* range 1 to 13 inclusive; *pDay will be in the range 1 to 30 inclusive.
*/
void SdnToJewish(
zend_long sdn,
int *pYear,
int *pMonth,
int *pDay)
{
zend_long inputDay;
zend_long day;
zend_long halakim;
int metonicCycle;
int metonicYear;
int tishri1;
int tishri1After;
int yearLength;
if (sdn <= JEWISH_SDN_OFFSET || sdn > JEWISH_SDN_MAX) {
*pYear = 0;
*pMonth = 0;
*pDay = 0;
return;
}
inputDay = sdn - JEWISH_SDN_OFFSET;
FindTishriMolad(inputDay, &metonicCycle, &metonicYear, &day, &halakim);
tishri1 = Tishri1(metonicYear, day, halakim);
if (inputDay >= tishri1) {
/* It found Tishri 1 at the start of the year. */
*pYear = metonicCycle * 19 + metonicYear + 1;
if (inputDay < tishri1 + 59) {
if (inputDay < tishri1 + 30) {
*pMonth = 1;
*pDay = inputDay - tishri1 + 1;
} else {
*pMonth = 2;
*pDay = inputDay - tishri1 - 29;
}
return;
}
/* We need the length of the year to figure this out, so find
* Tishri 1 of the next year. */
halakim += HALAKIM_PER_LUNAR_CYCLE * monthsPerYear[metonicYear];
day += halakim / HALAKIM_PER_DAY;
halakim = halakim % HALAKIM_PER_DAY;
tishri1After = Tishri1((metonicYear + 1) % 19, day, halakim);
} else {
/* It found Tishri 1 at the end of the year. */
*pYear = metonicCycle * 19 + metonicYear;
if (inputDay >= tishri1 - 177) {
/* It is one of the last 6 months of the year. */
if (inputDay > tishri1 - 30) {
*pMonth = 13;
*pDay = inputDay - tishri1 + 30;
} else if (inputDay > tishri1 - 60) {
*pMonth = 12;
*pDay = inputDay - tishri1 + 60;
} else if (inputDay > tishri1 - 89) {
*pMonth = 11;
*pDay = inputDay - tishri1 + 89;
} else if (inputDay > tishri1 - 119) {
*pMonth = 10;
*pDay = inputDay - tishri1 + 119;
} else if (inputDay > tishri1 - 148) {
*pMonth = 9;
*pDay = inputDay - tishri1 + 148;
} else {
*pMonth = 8;
*pDay = inputDay - tishri1 + 178;
}
return;
} else {
if (monthsPerYear[(*pYear - 1) % 19] == 13) {
*pMonth = 7;
*pDay = inputDay - tishri1 + 207;
if (*pDay > 0)
return;
(*pMonth)--;
(*pDay) += 30;
if (*pDay > 0)
return;
(*pMonth)--;
(*pDay) += 30;
} else {
*pMonth = 7;
*pDay = inputDay - tishri1 + 207;
if (*pDay > 0)
return;
(*pMonth) -= 2;
(*pDay) += 30;
}
if (*pDay > 0)
return;
(*pMonth)--;
(*pDay) += 29;
if (*pDay > 0)
return;
/* We need the length of the year to figure this out, so find
* Tishri 1 of this year. */
tishri1After = tishri1;
FindTishriMolad(day - 365,
&metonicCycle, &metonicYear, &day, &halakim);
tishri1 = Tishri1(metonicYear, day, halakim);
}
}
yearLength = tishri1After - tishri1;
day = inputDay - tishri1 - 29;
if (yearLength == 355 || yearLength == 385) {
/* Heshvan has 30 days */
if (day <= 30) {
*pMonth = 2;
*pDay = day;
return;
}
day -= 30;
} else {
/* Heshvan has 29 days */
if (day <= 29) {
*pMonth = 2;
*pDay = day;
return;
}
day -= 29;
}
/* It has to be Kislev. */
*pMonth = 3;
*pDay = day;
}
/************************************************************************
* Given a year, month and day in the Jewish calendar, find the
* corresponding serial day number (SDN). Zero is returned when the input
* date is detected as invalid. The return value will be > 0 for all valid
* dates, but there are some invalid dates that will return a positive
* value. To verify that a date is valid, convert it to SDN and then back
* and compare with the original.
*/
zend_long JewishToSdn(
int year,
int month,
int day)
{
zend_long sdn;
int metonicCycle;
int metonicYear;
int tishri1;
int tishri1After;
zend_long moladDay;
zend_long moladHalakim;
int yearLength;
int lengthOfAdarIAndII;
if (year <= 0 || day <= 0 || day > 30) {
return (0);
}
switch (month) {
case 1:
case 2:
/* It is Tishri or Heshvan - don't need the year length. */
FindStartOfYear(year, &metonicCycle, &metonicYear,
&moladDay, &moladHalakim, &tishri1);
if (month == 1) {
sdn = tishri1 + day - 1;
} else {
sdn = tishri1 + day + 29;
}
break;
case 3:
/* It is Kislev - must find the year length. */
/* Find the start of the year. */
FindStartOfYear(year, &metonicCycle, &metonicYear,
&moladDay, &moladHalakim, &tishri1);
/* Find the end of the year. */
moladHalakim += HALAKIM_PER_LUNAR_CYCLE * monthsPerYear[metonicYear];
moladDay += moladHalakim / HALAKIM_PER_DAY;
moladHalakim = moladHalakim % HALAKIM_PER_DAY;
tishri1After = Tishri1((metonicYear + 1) % 19, moladDay, moladHalakim);
yearLength = tishri1After - tishri1;
if (yearLength == 355 || yearLength == 385) {
sdn = tishri1 + day + 59;
} else {
sdn = tishri1 + day + 58;
}
break;
case 4:
case 5:
case 6:
/* It is Tevet, Shevat or Adar I - don't need the year length. */
FindStartOfYear(year + 1, &metonicCycle, &metonicYear,
&moladDay, &moladHalakim, &tishri1After);
if (monthsPerYear[(year - 1) % 19] == 12) {
lengthOfAdarIAndII = 29;
} else {
lengthOfAdarIAndII = 59;
}
if (month == 4) {
sdn = tishri1After + day - lengthOfAdarIAndII - 237;
} else if (month == 5) {
sdn = tishri1After + day - lengthOfAdarIAndII - 208;
} else {
sdn = tishri1After + day - lengthOfAdarIAndII - 178;
}
break;
default:
/* It is Adar II or later - don't need the year length. */
FindStartOfYear(year + 1, &metonicCycle, &metonicYear,
&moladDay, &moladHalakim, &tishri1After);
switch (month) {
case 7:
sdn = tishri1After + day - 207;
break;
case 8:
sdn = tishri1After + day - 178;
break;
case 9:
sdn = tishri1After + day - 148;
break;
case 10:
sdn = tishri1After + day - 119;
break;
case 11:
sdn = tishri1After + day - 89;
break;
case 12:
sdn = tishri1After + day - 60;
break;
case 13:
sdn = tishri1After + day - 30;
break;
default:
return (0);
}
}
return (sdn + JEWISH_SDN_OFFSET);
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: sw=4 ts=4 fdm=marker
* vim<600: sw=4 ts=4
*/
| 33.207453 | 92 | 0.622475 |
383584dae488bbebd7e2a808b0dbca4d959e7698 | 823 | h | C | CleverTapSDK/CTLoginInfoProvider.h | aakarsh-sasi/clevertap-ios-sdk | a2f9cffa6e2d0c6f763b7bfd4391f6e64ffa2fa1 | [
"MIT"
] | null | null | null | CleverTapSDK/CTLoginInfoProvider.h | aakarsh-sasi/clevertap-ios-sdk | a2f9cffa6e2d0c6f763b7bfd4391f6e64ffa2fa1 | [
"MIT"
] | null | null | null | CleverTapSDK/CTLoginInfoProvider.h | aakarsh-sasi/clevertap-ios-sdk | a2f9cffa6e2d0c6f763b7bfd4391f6e64ffa2fa1 | [
"MIT"
] | null | null | null | //
// CTLoginInfoProvider.h
// CleverTapSDK
//
// Created by Akash Malhotra on 05/12/21.
// Copyright © 2021 CleverTap. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "CTDeviceInfo.h"
#import "CleverTapInstanceConfig.h"
@interface CTLoginInfoProvider : NSObject
- (void)cacheGUID:(NSString *)guid forKey:(NSString *)key andIdentifier:(NSString *)identifier;
- (BOOL)deviceIsMultiUser;
- (NSDictionary *)getCachedGUIDs;
- (void)setCachedGUIDs:(NSDictionary *)cache;
- (NSString *)getCachedIdentities;
- (NSString *)getGUIDforKey:(NSString *)key andIdentifier:(NSString *)identifier;
- (BOOL)isAnonymousDevice;
- (BOOL)isLegacyProfileLoggedIn;
- (void)setCachedIdentities:(NSString *)cache;
- (instancetype)initWithDeviceInfo:(CTDeviceInfo*)deviceInfo config:(CleverTapInstanceConfig*)config;
@end
| 30.481481 | 101 | 0.767922 |
a85b6adb9c07be21b45759f68fa1bfd3ec83bd11 | 2,918 | h | C | Source/cryptography/implementation/SecApi/Hash.h | FitzerIRL/Thunder | bee4e8b0ca66c0feb8eed22587934f0c3e74c0c8 | [
"Apache-2.0"
] | null | null | null | Source/cryptography/implementation/SecApi/Hash.h | FitzerIRL/Thunder | bee4e8b0ca66c0feb8eed22587934f0c3e74c0c8 | [
"Apache-2.0"
] | null | null | null | Source/cryptography/implementation/SecApi/Hash.h | FitzerIRL/Thunder | bee4e8b0ca66c0feb8eed22587934f0c3e74c0c8 | [
"Apache-2.0"
] | 1 | 2021-06-11T10:58:46.000Z | 2021-06-11T10:58:46.000Z | /*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2020 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.
*/
#include <sec_security.h>
#include <sec_security_datatype.h>
#include <sec_security_common.h>
#include<string>
#include "../../Module.h"
#include <hash_implementation.h>
#include <core/core.h>
#include "Vault.h"
struct HashImplementation {
virtual uint32_t Ingest(const uint32_t length, const uint8_t data[]) = 0;
virtual uint8_t Calculate(const uint8_t maxLength, uint8_t data[]) = 0;
virtual ~HashImplementation() { }
};
struct HashAlg {
Sec_DigestAlgorithm digest_alg;
Sec_MacAlgorithm mac_alg;
uint16_t size;
};
struct Handle {
Sec_DigestHandle* digest_handle;
Sec_MacHandle* mac_handle;
};
namespace Implementation {
template<typename OPERATION>
class HashType : public HashImplementation {
public:
HashType(const HashType<OPERATION>&) = delete;
HashType<OPERATION>& operator=(const HashType) = delete;
HashType();
HashType(const Sec_DigestAlgorithm digestAlg, const uint16_t digestSize);
HashType(const Implementation::Vault* vault, const Sec_MacAlgorithm macAlg, const uint16_t macSize, const uint32_t secretId, const uint16_t secretLength);
~HashType() override;
private:
const Implementation::Vault* _vault;
const Implementation::Vault* _vault_digest = nullptr;
uint16_t _size;
bool _failure;
Handle* handle = new Handle;
Sec_KeyHandle* sec_key = nullptr;
SEC_OBJECTID _id_sec;
public:
uint32_t Ingest(const uint32_t length, const uint8_t* data) override;
uint8_t Calculate(const uint8_t maxLength, uint8_t* data) override;
};
class HashTypeNetflix : public HashImplementation {
private:
const Implementation::VaultNetflix* _vaultNetflix;
bool _failure;
Sec_NetflixHandle* _netflixHandle;
Sec_SocKeyHandle* _secretKey = NULL;
std::string _buffer = "";
public:
HashTypeNetflix(const Implementation::VaultNetflix* vault, const uint32_t secretId);
uint32_t Ingest(const uint32_t length, const uint8_t* data) override;
uint8_t Calculate(const uint8_t maxLength, uint8_t* data) override;
};
} // namespace Implementation
| 30.715789 | 163 | 0.711789 |
ef95148553d3aacf138139006d6267df2bd3b3a9 | 231 | h | C | CPP/TuringSimulator.CPP.Core/Stdafx.h | sascha-schwegelbauer/turing-simulator | 3e84b4aa63174b4cfa46d8f0e569a6c9c7e42b19 | [
"MIT"
] | null | null | null | CPP/TuringSimulator.CPP.Core/Stdafx.h | sascha-schwegelbauer/turing-simulator | 3e84b4aa63174b4cfa46d8f0e569a6c9c7e42b19 | [
"MIT"
] | null | null | null | CPP/TuringSimulator.CPP.Core/Stdafx.h | sascha-schwegelbauer/turing-simulator | 3e84b4aa63174b4cfa46d8f0e569a6c9c7e42b19 | [
"MIT"
] | null | null | null | // <copyright file="Stdafx.h" company="Privat">
// Copyright (c) Sascha Schwegelbauer. All rights reserved.
// </copyright>
#pragma once
#include "TuringCommand.h"
#include "TuringCommandList.h"
#include "TuringLogic.h" | 25.666667 | 62 | 0.705628 |
81fa3564cd18f0c8de4bae942f4ad1f7817c7c8d | 15,489 | c | C | MetroMiniABS2/MetroMiniABS2/libraries/CAN/utility/mcp2517.c | RobertPHeller/RPi-RRCircuits | 19aff23e20eebdbd028c0407d68eef77cc6ee0ec | [
"CC-BY-4.0"
] | 10 | 2018-09-04T02:12:39.000Z | 2022-03-17T20:29:32.000Z | MetroMiniABS2/MetroMiniABS2/libraries/CAN/utility/mcp2517.c | RobertPHeller/RPi-RRCircuits | 19aff23e20eebdbd028c0407d68eef77cc6ee0ec | [
"CC-BY-4.0"
] | null | null | null | MetroMiniABS2/MetroMiniABS2/libraries/CAN/utility/mcp2517.c | RobertPHeller/RPi-RRCircuits | 19aff23e20eebdbd028c0407d68eef77cc6ee0ec | [
"CC-BY-4.0"
] | 1 | 2018-12-26T00:32:27.000Z | 2018-12-26T00:32:27.000Z | /* -*- C -*- ****************************************************************
*
* System :
* Module :
* Object Name : $RCSfile$
* Revision : $Revision$
* Date : $Date$
* Author : $Author$
* Created By : Robert Heller
* Created : Sun Jun 3 10:11:20 2018
* Last Modified : <180612.0847>
*
* Description
*
* Notes
*
* History
*
****************************************************************************
*
* Copyright (C) 2018 Robert Heller D/B/A Deepwoods Software
* 51 Locke Hill Road
* Wendell, MA 01379-9728
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*
*
****************************************************************************/
static const char rcsid[] = "@(#) : $Id$";
/* Bit timings
*
* Fosc = 20Mhz
* BRP = 20 = 0x13 (+1)
* TQ = 1us
* TSEG1 = 4 = 0x03 (+1)
* TSEG2 = 3 = 0x02 (+1)
* SJW = 1 = 0x00 (+1)
* SynSeg = 1
* Prop Seg+Phase1 Seg = 4
* Phase2 Seg = 3
* -----
* 8
* Bus speed = 1 / ((Total # of TQ) * TQ)
* 1 / (8 * TQ) = 125 Khz
*/
#include "mcp2517_private.h"
#ifdef SUPPORT_FOR_MCP2517__
#include <assert.h>
#ifndef MCP2517_CLKOUT_PRESCALER
#error MCP2517_CLKOUT_PRESCALER not defined! #error MCP2517_CLKOUT_PRESCALER not defined!
#elif MCP2517_CLKOUT_PRESCALER == 0
#define CLKOUT_PRESCALER_ 0x0
#elif MCP2517_CLKOUT_PRESCALER == 1
#define CLKOUT_PRESCALER_ 0x4
#elif MCP2517_CLKOUT_PRESCALER == 2
#define CLKOUT_PRESCALER_ 0x5
#elif MCP2517_CLKOUT_PRESCALER == 4
#define CLKOUT_PRESCALER_ 0x6
#elif MCP2517_CLKOUT_PRESCALER == 8
#define CLKOUT_PRESCALER_ 0x7
#else
#error invaild value of MCP2517_CLKOUT_PRESCALER
#endif
// -------------------------------------------------------------------------
void mcp2517_write_register( uint16_t adress, uint32_t data )
{
RESET(MCP2517_CS);
spi_putc(SPI_WRITE| ((adress >> 8) & 0x0F));
spi_putc(adress & 0x0ff);
spi_putc(data & 0x0ff);
spi_putc((data >> 8) & 0x0ff);
spi_putc((data >> 16) & 0x0ff);
spi_putc((data >> 24) & 0x0ff);
SET(MCP2515_CS);
}
// -------------------------------------
uint32_t mcp2517_read_register(uint16_t adress)
{
uint32_t data;
uint8_t buffer[4];
RESET(MCP2517_CS);
spi_putc(SPI_READ| ((adress >> 8) & 0x0F));
spi_putc(adress & 0x0ff);
buffer[0] = spi_putc(0xff);
buffer[1] = spi_putc(0xff);
buffer[2] = spi_putc(0xff);
buffer[3] = spi_putc(0xff);
SET(MCP2517_CS);
data = buffer[0] | (buffer[1] << 8) | (buffer[2] << 16) | (buffer[3] << 24);
return data;
}
int mcp2517_read_data(uint16_t adress,uint8_t *buffer,uint8_t len)
{
uint8_t i, byte;
if ((len & 0x3) != 0) {return -2;}
RESET(MCP2517_CS);
byte = SPI_READ| ((adress >> 8) & 0x0F);
spi_putc(byte);
byte = adress & 0x0ff;
spi_putc(byte);
for (i = 0; i < len; i++) {
buffer[i] = spi_putc(0xff);
}
SET(MCP2517_CS);
return len;
}
/** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */
static uint16_t const crc16_table[256] = {
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
};
static inline uint16_t crc16_byte(uint16_t crc, const uint8_t data)
{
return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff];
}
/**
* crc16 - compute the CRC-16 for the data buffer
* @crc: previous CRC value
* @buffer: data pointer
* @len: number of bytes in the buffer
*
* Returns the updated CRC value.
*/
static uint16_t crc16(uint16_t crc, uint8_t const *buffer, uint8_t len)
{
while (len--)
crc = crc16_byte(crc, *buffer++);
return crc;
}
int mcp2517_read_crc(uint16_t adress,uint8_t *buffer,uint8_t len)
{
uint8_t i, byte;
if ((len & 0x3) != 0) {return -2;}
uint16_t crc = 0xffff, read_crc;
RESET(MCP2517_CS);
byte = SPI_READ_CRC| ((adress >> 8) & 0x0F);
crc = crc16_byte(crc,byte);
spi_putc(byte);
byte = adress & 0x0ff;
crc = crc16_byte(crc,byte);
spi_putc(byte);
spi_putc(len);
crc = crc16_byte(crc,len);
for (i = 0; i < len; i++) {
buffer[i] = spi_putc(0xff);
}
crc = crc16(crc,buffer,len);
read_crc |= (spi_putc(0xff) << 8);
read_crc = spi_putc(0xff);
SET(MCP2517_CS);
if (crc != read_crc) return -1;
else return len;
}
void mcp2517_write_crc(uint16_t adress,uint8_t *buffer,uint8_t len)
{
uint8_t i, byte;
if ((len & 0x3) != 0) {return -2;}
uint16_t crc = 0xffff;
RESET(MCP2517_CS);
byte = SPI_WRITE_CRC| ((adress >> 8) & 0x0F);
crc = crc16_byte(crc,byte);
spi_putc(byte);
byte = adress & 0x0ff;
crc = crc16_byte(crc,byte);
spi_putc(byte);
crc = crc16_byte(crc,len);
spi_putc(len);
for (i = 0; i < len; i++) {
spi_putc(buffer[i]);
}
crc = crc16(crc,buffer,len);
spi_putc((crc>>8)&0x0ff);
spi_putc(crc&0x0ff);
SET(MCP2517_CS);
}
void mcp2517_write_safe(uint16_t adress,uint32_t word)
{
uint8_t i, byte, buffer[4];
uint16_t crc = 0xffff;
buffer[0] = word & 0x0ff;
buffer[1] = (word >> 8) & 0x0ff;
buffer[2] = (word >> 16) & 0x0ff;
buffer[3] = (word >> 24) & 0x0ff;
RESET(MCP2517_CS);
byte = SPI_WRITE_SAFE| ((adress >> 8) & 0x0F);
crc = crc16_byte(crc,byte);
byte = adress & 0x0ff;
crc = crc16_byte(crc,byte);
spi_putc(byte);
for (i = 0; i < 4; i++) {
spi_putc(buffer[i]);
}
crc = crc16(crc,buffer,4);
spi_putc((crc>>8)&0x0ff);
spi_putc(crc&0x0ff);
SET(MCP2517_CS);
}
// -------------------------------------------------------------------------
#if 0
// I don't know how all of these numbers were derived and don't know the mcp2517 equiv.
// I am only going to support 125 Kbps for now.
const uint8_t _mcp2515_cnf[8][3] PROGMEM = {
// 10 kbps
{ 0x04,
0xb6,
0xe7
},
// 20 kbps
{ 0x04,
0xb6,
0xd3
},
// 50 kbps
{ 0x04,
0xb6,
0xc7
},
// 100 kbps
{ 0x04,
0xb6,
0xc3
},
// 125 kbps
{ (1<<PHSEG21), // CNF3
(1<<BTLMODE)|(1<<PHSEG11), // CNF2
(1<<BRP2)|(1<<BRP1)|(1<<BRP0) // CNF1
},
// 250 kbps
{ 0x03,
0xac,
0x81
},
// 500 kbps
{ 0x03,
0xac,
0x80
},
// 1 Mbps
{ (1<<PHSEG21),
(1<<BTLMODE)|(1<<PHSEG11),
0
}
};
#endif
const uint32_t _mcp2517_cnf[8] PROGMEM = {
// 10 kbps
// ((50-1)<<CiDBTCFG_BRP) | ((14-1)<<CiDBTCFG_TSEG1) | ((5-1)<<CiDBTCFG_TSEG2) | ((4-1)<<CiDBTCFG_SJW)
0x310d0403,
// 20 kbps
// ((25-1)<<CiDBTCFG_BRP) | ((14-1)<<CiDBTCFG_TSEG1) | ((5-1)<<CiDBTCFG_TSEG2) | ((4-1)<<CiDBTCFG_SJW)
0x180d0403,
// 50 kbps
// ((10-1)<<CiDBTCFG_BRP) | ((14-1)<<CiDBTCFG_TSEG1) | ((5-1)<<CiDBTCFG_TSEG2) | ((4-1)<<CiDBTCFG_SJW)
0x090d0403,
// 100 kbps
// ((5-1)<<CiDBTCFG_BRP) | ((14-1)<<CiDBTCFG_TSEG1) | ((5-1)<<CiDBTCFG_TSEG2) | ((4-1)<<CiDBTCFG_SJW)
0x040d0403,
// 125 kbps
// ((10-1)<<CiDBTCFG_BRP) | ((4-1)<<CiDBTCFG_TSEG1) | ((4-1)<<CiDBTCFG_TSEG2) | ((1-1)<<CiDBTCFG_SJW)
0x09030300,
// 250 kbps
// ((2-1)<<CiDBTCFG_BRP) | ((8-1)<<CiDBTCFG_TSEG1) | ((4-1)<<CiDBTCFG_TSEG2) | ((3-1)<<CiDBTCFG_SJW)
0x01070302,
// 500 kbps
// ((1-1)<<CiDBTCFG_BRP) | ((8-1)<<CiDBTCFG_TSEG1) | ((4-1)<<CiDBTCFG_TSEG2) | ((3-1)<<CiDBTCFG_SJW)
0x00070302,
// 1 Mbps1 Mbps
// ((1-1)<<CiDBTCFG_BRP) | ((4-1)<<CiDBTCFG_TSEG1) | ((2-1)<<CiDBTCFG_TSEG2) | ((1-1)<<CiDBTCFG_SJW)
0x00030100
};
bool mcp2517_init(uint8_t bitrate)
{
uint32_t dataword;
if (bitrate >= 8) return false; //
SET(MCP2517_CS);
SET_OUTPUT(MCP2517_CS);
// Activate pins for the SPI Interface
RESET(P_SCK);
RESET(P_MOSI);
RESET(P_MISO);
SET_OUTPUT(P_SCK);
SET_OUTPUT(P_MOSI);
SET_INPUT(P_MISO);
// SPI Initialization
mcp251x_spi_init();
// MCP2517 software reset
RESET(MCP2517_CS);
spi_putc(SPI_RESET);
SET(MCP2517_CS);
// Wait for MCP2517 to start up.
_delay_ms(0.1);
// OSC init.
dataword = 0;
mcp2517_write_register(OSC,dataword); // Wake up and enter config mode
dataword |= CLKOUT_PRESCALER_ << OSC_CLKODIV;
mcp2517_write_register(OSC,dataword);
// GPIO Pins
mcp2517_write_register(IOCON,(1<<IOCON_PM1)|(1<<IOCON_PM0));
// C1CON register
dataword = 0;
dataword |= 1 << CiCON_ISOCRCEN; // Not sure about this..
dataword |= 0 << CiCON_STEF; // Disable Store in Transmit Event FIFO
dataword |= 1 << CiCON_TXQEN; // Enable Transmit Queue
dataword |= CiCON_OPMOD_CONFIG << CiCON_REQOP;
mcp2517_write_register(C1CON,dataword);
// Bit timing configuration
dataword = _mcp2517_cnf[bitrate];
mcp2517_write_register(C1NBTCFG,dataword);
mcp2517_write_register(C1DBTCFG,dataword);
// TEF Not used.
// TEF Configuration - 12 messages, time stamping enabled
//dataword = (12-1) << CiTEFCON_FSIZE; // Guess
#if SUPPORT_TIMESTAMPS
//dataword |= 1 << CiTEFCON_TEFTSEN; // ???
#endif
//mcp2517_write_register(C1TEFCON,dataword);
// TXQ Configuration -- 32 messages, 8 byte payload, high priority
dataword = 1 << CiTXQCON_TXPRI;
dataword |= (32-1) << CiTXQCON_FSIZE;
dataword |= CiTXQCON_PLSIZE_8;
mcp2517_write_register(C1TXQCON,dataword);
// FIFO 1: Transmit FIFO: 10 messages, 8 byte maximum payload, low priority
//dataword = 1 << CiFIFOCONm_TXEN; // Transmit FIFO
//dataword |= (10-1) << CiFIFOCONm_FSIZE;
//dataword |= CiTXQCON_PLSIZE_8 << CiFIFOCONm_PLSIZE;
//dataword |= 0 << CiFIFOCONm_TXPRI;
//mcp2517_write_register(C1FIFOCON1,dataword);
// FIFO 1: Receive FIFO: 64 messages, 8 byte maximum payload, time stamping enabled, FIFO not empty Interrupt Enable.
dataword = 0 << CiFIFOCONm_TXEN; // Receive FIFO
dataword |= (64-1) << CiFIFOCONm_FSIZE;
dataword |= CiTXQCON_PLSIZE_8 << CiFIFOCONm_PLSIZE;
#if SUPPORT_TIMESTAMPS
dataword |= 1 << CiFIFOCONm_RXTSEN;
#endif
dataword |= 1 << CiFIFOCONm_TFNRFNIE;
mcp2517_write_register(C1FIFOCON1,dataword);
// Enable ECC
dataword = 1 << ECCCON_ECCEN;
mcp2517_write_register(ECCCON,dataword);
// RAM Usage: TEF TXQ TXFIFO RXFIFO
uint16_t rsizeB = /*(12*12) +*/ (32*(8+8)) /*+ (10*(8+8))*/ + (64*(12+8));
uint16_t rsizeL = (rsizeB+3)/4;
uint16_t iw, ramaddress;
// Check for over allocation...
assert(rsizeB > 2048);
// Initialize RAM to all 1's.
ramaddress = RAMSTART;
dataword = 0xffffffff;
for (iw = 0; iw < rsizeL; iw++) {
mcp2517_write_register(ramaddress,dataword);
ramaddress += 4;
}
// Time Stamp Control
mcp2517_write_register(C1TSCON,0); // Stop and clear counter
#if SUPPORT_TIMESTAMPS
dataword = 0 << CiTSCON_TSRES; // TS at SOF for FD frames
dataword |= 0 << CiTSCON_TSEOF; // TS at SOF for clasical frames
dataword |= 1 << CiTSCON_TBCEN; // Enable TS
dataword |= ((80-1)<<CiTSCON_TBCPRE); // Counter at 4us (20Mhz / 80).
mcp2517_write_register(C1TSCON,dataword);
#endif
// Disable all filters
mcp2517_write_register(C1FLTCON0,0);
mcp2517_write_register(C1FLTCON1,0);
mcp2517_write_register(C1FLTCON2,0);
mcp2517_write_register(C1FLTCON3,0);
mcp2517_write_register(C1FLTCON4,0);
mcp2517_write_register(C1FLTCON5,0);
mcp2517_write_register(C1FLTCON7,0);
// Now enable filter 0, with a "wild card" mask (should match all
// messages). Feed the messages (all of them) to FIFO 2.
mcp2517_write_register(C1MASK0,0);
mcp2517_write_register(C1FLTOBJ0,0);
dataword = (1<<CiFLTCONm_FLTEN0)|(CiFLTCONm_BP2<<CiFLTCONm_F0BP);
mcp2517_write_register(C1FLTCON0,dataword);
// Enable interrupts.
mcp2517_write_register(C1INT,MCP2517_INTERRUPTS);
#if defined(MCP2517_INT)
SET_INPUT(MCP2517_INT);
SET(MCP2517_INT);
// Set up interrupt handler?
#endif
bool error = false;
// Check bit timing registers...
if (mcp2517_read_register(C1NBTCFG) != dataword) error = true;
if (mcp2517_read_register(C1DBTCFG) != dataword) error = true;
if (error) {
return false;
} else {
// Enter normal operating mode
dataword = mcp2517_read_register(C1CON);
dataword &= ~(CiCON_REQOP_M<<CiCON_REQOP);
dataword |= CiCON_OPMOD_NORMALCANFD<<CiCON_REQOP;
mcp2517_write_register(C1CON,dataword);
// Wait for the mcp2517 to come up.
while (((mcp2517_read_register(C1CON) >> CiCON_OPMOD) & CiCON_OPMOD_M) != CiCON_OPMOD_NORMALCANFD) ;
return true;
}
}
#endif
| 30.430255 | 121 | 0.615598 |
a661081207c0bec424bac2519d0b0b29d4c85760 | 2,216 | c | C | gempak/source/contrib/awc/gprcm/radar_stats.c | oxelson/gempak | e7c477814d7084c87d3313c94e192d13d8341fa1 | [
"BSD-3-Clause"
] | 42 | 2015-06-03T15:26:21.000Z | 2022-02-28T22:36:03.000Z | gempak/source/contrib/awc/gprcm/radar_stats.c | oxelson/gempak | e7c477814d7084c87d3313c94e192d13d8341fa1 | [
"BSD-3-Clause"
] | 60 | 2015-05-11T21:36:08.000Z | 2022-03-29T16:22:42.000Z | gempak/source/contrib/awc/gprcm/radar_stats.c | oxelson/gempak | e7c477814d7084c87d3313c94e192d13d8341fa1 | [
"BSD-3-Clause"
] | 27 | 2016-06-06T21:55:14.000Z | 2022-03-18T18:23:28.000Z | #include "geminc.h"
#include "gemprm.h"
#include "rcm.h"
char *radar_mode_tostring(int mode)
{
static char NEstr[] = "NE";
static char OMstr[] = "OM";
static char NAstr[] = "NA";
static char CLRstr[] = "CLEAR AIR";
static char PCPstr[] = "PRECIP";
static char UNKstr[] = "UNKNOWN";
switch (mode)
{
case MDNE:
return(NEstr);
case MDOM:
return(OMstr);
case MDNA:
return(NAstr);
case MDCLAR:
return(CLRstr);
case MDPCPN:
return(PCPstr);
}
return(UNKstr);
}
void radar_stats(rad_struct RADARS[], int NEXSTNS, int *nlun, int *luns)
{
int i,j,ilen,iret;
char timestr[30],outstr[132];
float nx[1],ny[1],lat[1],lon[1];
struct tm *tstruct;
static int np=1;
static char ncord[]="N";
static char mcord[]="M";
sprintf(outstr,"Station Observation Time Mode\0");
text_output(nlun,luns,outstr,strlen(outstr));
sprintf(outstr,"____________________________________\0");
text_output(nlun,luns,outstr,strlen(outstr));
for(i=0;i<NEXSTNS;i++)
{
if(RADARS[i].obs_time > -1)
{
/*ilen = cftime (timestr,"%Y %m %d: %H%M\0", &(RADARS[i].obs_time)); not supported by compaq */
tstruct = gmtime (&(RADARS[i].obs_time));
strftime(timestr, 30, "%Y %m %d: %H%MZ\0", tstruct);
}
else
sprintf(timestr,"Station not found\0");
sprintf(outstr,"%-8s %-17s %9s\0",RADARS[i].idlst,timestr,radar_mode_tostring(RADARS[i].mode));
text_output(nlun,luns,outstr,strlen(outstr));
for(j=0;j<RADARS[i].nmeso;j++)
{
nx[0] = RADARS[i].meso[j].nx;
ny[0] = RADARS[i].meso[j].ny;
gtrans ( ncord, mcord, &np, nx, ny, lat, lon, &iret,
strlen(ncord),strlen(mcord));
sprintf(outstr,"\t\t\t\t\t%s Meso%02d %8.4f %9.4f\0",RADARS[i].idlst,j+1,lat[0],lon[0]);
text_output(nlun,luns,outstr,strlen(outstr));
}
for(j=0;j<RADARS[i].ntvs;j++)
{
nx[0] = RADARS[i].tvs[j].nx;
ny[0] = RADARS[i].tvs[j].ny;
gtrans ( ncord, mcord, &np, nx, ny, lat, lon, &iret,
strlen(ncord),strlen(mcord));
sprintf(outstr,"\t\t\t\t\t%s TVS%02d %8.4f %9.4f\0",RADARS[i].idlst,j+1,lat[0],lon[0]);
text_output(nlun,luns,outstr,strlen(outstr));
}
}
}
| 26.698795 | 102 | 0.599278 |
07378cfc793a1728f18cadb5f072f2b2bc0464f6 | 1,017 | h | C | twitter/View Controllers/ProfileViewController.h | nmachado26/twitter | ab8d60a07f1971aede2c704bcf7d3219b36cabd1 | [
"Apache-2.0"
] | null | null | null | twitter/View Controllers/ProfileViewController.h | nmachado26/twitter | ab8d60a07f1971aede2c704bcf7d3219b36cabd1 | [
"Apache-2.0"
] | 1 | 2018-07-08T10:51:53.000Z | 2018-07-08T10:51:53.000Z | twitter/View Controllers/ProfileViewController.h | nmachado26/twitter | ab8d60a07f1971aede2c704bcf7d3219b36cabd1 | [
"Apache-2.0"
] | null | null | null | //
// ProfileViewController.h
// twitter
//
// Created by Nicolas Machado on 7/5/18.
// Copyright © 2018 Emerson Malca. All rights reserved.
//
//#import <UIKit/UIKit.h>
//#import "TimelineViewController.h"
//#import "User.h"
//#import "Tweet.h"
#import <UIKit/UIKit.h>
#import "User.h"
#import "TimelineViewController.h"
#import "Tweet.h"
@interface ProfileViewController : UIViewController
@property (nonatomic, strong) User *user;
@property (weak, nonatomic) IBOutlet UILabel *tweetCountLabel;
@property (weak, nonatomic) IBOutlet UILabel *settingLabel;
@property (weak, nonatomic) IBOutlet UIImageView *backgroundImage;
@property (weak, nonatomic) IBOutlet UIImageView *profileImage;
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *screenNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *biographyLabel;
@property (weak, nonatomic) IBOutlet UILabel *followingCountLabel;
@property (weak, nonatomic) IBOutlet UILabel *followersCountLabel;
@end
| 31.78125 | 66 | 0.766962 |
60f3c633d5fec16d264f4d1ae8f30749864cae64 | 319 | c | C | test/val/bug250.c | C-Chads/cc65 | 52e43879298c2fb30c7bc6fd95fae3b3f1458793 | [
"Zlib"
] | 1,673 | 2015-01-01T23:03:31.000Z | 2022-03-30T21:49:03.000Z | test/val/bug250.c | Fabrizio-Caruso/cc65 | 84dba7f6ae43e8e93ed1601e1d565e97503cd0b2 | [
"Zlib"
] | 1,307 | 2015-01-06T09:32:26.000Z | 2022-03-31T19:57:16.000Z | test/val/bug250.c | Fabrizio-Caruso/cc65 | 84dba7f6ae43e8e93ed1601e1d565e97503cd0b2 | [
"Zlib"
] | 423 | 2015-01-01T19:11:31.000Z | 2022-03-30T14:36:00.000Z | /* bug #250 - Array size compile-time optimization stops halfway */
#include <stdlib.h>
#define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
unsigned char c[2*4];
unsigned char b[2*LZO_MAX(8,sizeof(int))]; // this will not compile
int main(void)
{
/* FIXME: add some runtime check */
return EXIT_SUCCESS;
}
| 22.785714 | 68 | 0.626959 |
90420c1786081e05445fb20c1e64dee5d19f60f6 | 4,251 | c | C | processors/ARM/skyeye/arch/coldfire/common/handlers.c | zecke/pharo-vm-1 | c06ab62eab741547dc4e0ed2e107928bd8885eb7 | [
"MIT"
] | 2 | 2018-07-09T14:14:48.000Z | 2018-11-01T20:54:57.000Z | processors/ARM/skyeye/arch/coldfire/common/handlers.c | zecke/pharo-vm-1 | c06ab62eab741547dc4e0ed2e107928bd8885eb7 | [
"MIT"
] | 1 | 2016-09-30T10:16:44.000Z | 2016-09-30T10:16:44.000Z | processors/ARM/skyeye/arch/coldfire/common/handlers.c | zecke/pharo-vm-1 | c06ab62eab741547dc4e0ed2e107928bd8885eb7 | [
"MIT"
] | 1 | 2018-10-25T23:31:42.000Z | 2018-10-25T23:31:42.000Z | /**********************************/
/* */
/* Copyright 2000, David Grant */
/* */
/* see LICENSE for more details */
/* */
/**********************************/
#include <stdio.h>
#include <stdarg.h>
#include "coldfire.h"
SKYEYE_DBGR_DEFAULT_CHANNEL(handlers);
void SR_Set(short Instr, int Source, int Destination, int Result)
{
char Sm = (Source >= 0) ? 0 : 1;
char Dm = (Destination >= 0) ? 0 : 1;
char Rm = (Result >= 0) ? 0 : 1;
short BackupSR = memory_core.sr;
SKYEYE_DBG("Setting Source=0x%08lx, Destination=0x%08lx, Result=0x%08lx\n", Source, Destination, Result);
SKYEYE_DBG("Sm=%d, Dm=%d, Rm=%d\n", Sm,Dm,Rm);
/* Clear out the XNZVC */
memory_core.sr &= 0xFFE0;
switch(Instr) {
case I_ADDX:
/* Z - cleared if result is non-zero, unchanged otherwise */
case I_ADD: case I_ADDI: case I_ADDQ:
/* Set the status register */
/* X - Set to value of carry bit
N - Set if result is -ve, cleared otherwise
Z - Set if result is zero, cleared otherwise
V - Set if an overflow occurs, cleared otherwise
C - Set if a carry is generated, cleared otherwise
*/
if(Rm) memory_core.sr |= SR_N;
if(Instr==I_ADDX) {
if(Result) /* SR_Z will already be cleared */;
else /* Restore the old one */
memory_core.sr |= (BackupSR & SR_Z);
} else {
if(Result==0) memory_core.sr |= SR_Z;
}
if((Sm && Dm && !Rm) || (!Sm && !Dm && Rm) )
memory_core.sr |= SR_V;
if((Sm && Dm) || (!Rm && Dm) || (Sm && !Rm) ) {
memory_core.sr |= SR_C;
memory_core.sr |= SR_X;
}
break;
case I_SUBX:
/* Z - cleared if result is non-zero, unchanged otherwise */
case I_SUB: case I_SUBI: case I_SUBQ:
/* Set the status register */
/* X - Set to value of carry bit
N - Set if result is -ve, cleared otherwise
Z - Set if result is zero, cleared otherwise
V - Set if an overflow occurs, cleared otherwise
C - Set if a borrow occurs, cleared otherwise
*/
if(Rm) memory_core.sr |= SR_N;
if(Instr==I_SUBX) {
if(Result) /* SR_Z will already be cleared */;
else /* Restore the old one */
memory_core.sr |= (BackupSR & SR_Z);
} else {
if(Result==0) memory_core.sr |= SR_Z;
}
if((!Sm && Dm && !Rm) || (Sm && !Dm && Rm) )
memory_core.sr |= SR_V;
if((Sm && !Dm) || (Rm && !Dm) || (Sm && Rm) ) {
memory_core.sr |= SR_C;
memory_core.sr |= SR_X;
}
break;
case I_CMP: case I_CMPA: case I_CMPI:
/* Set the status register
* X - Not affected
* N - Set if result is -ve, cleared otherwise
* Z - Set if result is zero, cleared otherwise
* V - Set if an overflow occurs, cleared otherwise
* C - Set if a borrow occurs, cleared otherwise
*/
if(Rm) memory_core.sr |= SR_N;
if(Result==0) memory_core.sr |= SR_Z;
if((!Sm && Dm && !Rm) || (Sm && !Dm && Rm) )
memory_core.sr |= SR_V;
if((Sm && !Dm) || (Rm && !Dm) || (Sm && Rm) )
memory_core.sr |= SR_C;
/* Restore X */
memory_core.sr |= (BackupSR & SR_X);
break;
case I_NEG:
/* X - Set to value of carry bit
N - Set if result is -ve, cleared otherwise
Z - Set if result is zero, cleared otherwise
V - Set if an overflow occurs, cleared otherwise
C - Cleared if the result is zero, set otherwise
*/
if(Rm) memory_core.sr |= SR_N;
if(Result==0) memory_core.sr |= SR_Z;
if(Dm && Rm) memory_core.sr |= SR_V;
if(Dm || Rm) memory_core.sr |= (SR_C | SR_X);
break;
case I_NEGX:
/* X - Set to value of carry bit
N - Set if result is -ve, cleared otherwise
Z - Cleared if the result is non-zero, unchanged otherwise
V - Set if an overflow occurs, cleared otherwise
C - Cleared if the result is zero, set otherwise
*/
if(Rm) memory_core.sr |= SR_N;
if(Result==0) memory_core.sr |= (BackupSR & SR_Z);
if(Dm && Rm) memory_core.sr |= SR_V;
if(Dm || Rm) memory_core.sr |= (SR_C | SR_X);
break;
default:
SKYEYE_ERR("Called with unknown instruction %d\n", Instr);
break;
}
SKYEYE_DBG("X:%d, Neg:%d, Zero:%d, Overflow:%d, Carry:%d\n", (memory_core.sr&SR_X) >> 4,(memory_core.sr&SR_N) >> 3,(memory_core.sr&SR_Z) >> 2,(memory_core.sr&SR_V) >> 1, (memory_core.sr&SR_C));
return;
}
| 29.520833 | 194 | 0.585274 |
b80f13ff09418ef294e3e837f66215f39649644c | 1,163 | c | C | libft/libft/ft_btree_apply_prefix.c | fbertoia/42sh | 5dc12587c58b26814c55a50b8c83b198796ca91a | [
"MIT"
] | 1 | 2018-05-05T13:58:26.000Z | 2018-05-05T13:58:26.000Z | libft/libft/ft_btree_apply_prefix.c | fbertoia/42sh | 5dc12587c58b26814c55a50b8c83b198796ca91a | [
"MIT"
] | null | null | null | libft/libft/ft_btree_apply_prefix.c | fbertoia/42sh | 5dc12587c58b26814c55a50b8c83b198796ca91a | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_btree_apply_prefix.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fle-roy <fle-roy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/09/19 13:44:20 by fle-roy #+# #+# */
/* Updated: 2017/12/03 11:54:47 by fle-roy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_btree_apply_prefix(t_btree *root, void (*applyf)(void *))
{
if (!root || !applyf)
return ;
applyf(root->item);
if (root->left)
ft_btree_apply_prefix(root->left, applyf);
if (root->right)
ft_btree_apply_prefix(root->right, applyf);
}
| 46.52 | 80 | 0.252794 |
e6d102cfc3ead2f1a636103f13e765b59c6278cc | 923 | h | C | Nathan Music Player/songPlayView.h | biubiublue/NathanMusic | 240c588ebfd9bdcb7c84c9a16ff2ebbb6018c880 | [
"MIT"
] | 1 | 2018-03-30T09:48:14.000Z | 2018-03-30T09:48:14.000Z | Nathan Music Player/songPlayView.h | bestnathan/NathanMusic | 240c588ebfd9bdcb7c84c9a16ff2ebbb6018c880 | [
"MIT"
] | null | null | null | Nathan Music Player/songPlayView.h | bestnathan/NathanMusic | 240c588ebfd9bdcb7c84c9a16ff2ebbb6018c880 | [
"MIT"
] | null | null | null | //
// songPlayView.h
// Nathan Music Player
//
// Created by 李宁 on 15/12/23.
// Copyright © 2015年 Nthan. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface songPlayView : UIView<UIScrollViewDelegate>
//左边是图片旋转,右边是歌词tableview
@property(nonatomic,strong)UIScrollView *myScrollView;
//显示北京
@property (strong, nonatomic) UIImageView *myImageViewblur;
//显示旋转图片
@property (strong, nonatomic) UIImageView *myImageView;
//显示歌词
@property (strong, nonatomic) UITableView *tableview;
//播放模式控制按钮
@property (strong, nonatomic) UIButton *playMod;
@property (strong, nonatomic) UIButton *lastSong;
@property (strong, nonatomic) UIButton *playSong;
@property (strong, nonatomic) UIButton *nextSong;
@property (strong, nonatomic) UIButton *backButton;
@property (strong, nonatomic) UILabel *SongName;
@property (strong, nonatomic) UILabel *SingerName;
@property (strong, nonatomic) UISlider *mySlider;
@end
| 24.289474 | 60 | 0.749729 |
696e0d3f24e09f0cc13388cb9a45e54df3c7dd70 | 682 | h | C | Mesa-7.11.2_GPGPU-Sim/src/gallium/drivers/nouveau/nouveau_context.h | ayoubg/gem5-graphics_v1 | d74a968d5854dc02797139558430ccda1f71108e | [
"BSD-3-Clause"
] | 1 | 2019-01-26T10:34:02.000Z | 2019-01-26T10:34:02.000Z | Mesa-7.11.2_GPGPU-Sim/src/gallium/drivers/nouveau/nouveau_context.h | ayoubg/gem5-graphics_v1 | d74a968d5854dc02797139558430ccda1f71108e | [
"BSD-3-Clause"
] | null | null | null | Mesa-7.11.2_GPGPU-Sim/src/gallium/drivers/nouveau/nouveau_context.h | ayoubg/gem5-graphics_v1 | d74a968d5854dc02797139558430ccda1f71108e | [
"BSD-3-Clause"
] | 1 | 2021-07-06T10:40:34.000Z | 2021-07-06T10:40:34.000Z | #ifndef __NOUVEAU_CONTEXT_H__
#define __NOUVEAU_CONTEXT_H__
#include "pipe/p_context.h"
struct nouveau_context {
struct pipe_context pipe;
struct nouveau_screen *screen;
boolean vbo_dirty;
void (*copy_data)(struct nouveau_context *,
struct nouveau_bo *dst, unsigned, unsigned,
struct nouveau_bo *src, unsigned, unsigned, unsigned);
void (*push_data)(struct nouveau_context *,
struct nouveau_bo *dst, unsigned, unsigned,
unsigned, void *);
};
static INLINE struct nouveau_context *
nouveau_context(struct pipe_context *pipe)
{
return (struct nouveau_context *)pipe;
}
#endif
| 25.259259 | 75 | 0.673021 |
5075db22243010ac6b97757de1a5ffce8c9a9eff | 1,516 | c | C | usr.bin/make/lst.lib/lstFake.c | weiss/original-bsd | b44636d7febc9dcf553118bd320571864188351d | [
"Unlicense"
] | 114 | 2015-01-18T22:55:52.000Z | 2022-02-17T10:45:02.000Z | usr.bin/make/lst.lib/lstFake.c | JamesLinus/original-bsd | b44636d7febc9dcf553118bd320571864188351d | [
"Unlicense"
] | null | null | null | usr.bin/make/lst.lib/lstFake.c | JamesLinus/original-bsd | b44636d7febc9dcf553118bd320571864188351d | [
"Unlicense"
] | 29 | 2015-11-03T22:05:22.000Z | 2022-02-08T15:36:37.000Z | /*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Adam de Boor.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef lint
static char sccsid[] = "@(#)lstFake.c 5.2 (Berkeley) 03/11/90";
#endif /* not lint */
/*-
* lstFake.c --
* This is a file whose sole purpose is to force ranlib to
* place enough entries in the library's table of contents to
* prevent it (the table of contents) from looking like an object
* file. As of this writing, the table had 0410 (shared text) entries
* in it, so we define five junk variables to up the number beyond
* the range of the magic numbers.
*/
int _junk_one__ = 1;
int _junk_two__ = 2;
int _junk_three__ = 3;
int _junk_four__ = 4;
int _junk_five__ = 5;
| 37.9 | 78 | 0.745383 |
136162a8cc9c07ee5c5148d96c7e3bdd9f520313 | 7,079 | c | C | src/ocilib-4.2.1/src/agent.c | ysmgigi/dbss | c6c00c4990a00514e158d1b10bc5cf38743fd2cc | [
"Apache-2.0"
] | null | null | null | src/ocilib-4.2.1/src/agent.c | ysmgigi/dbss | c6c00c4990a00514e158d1b10bc5cf38743fd2cc | [
"Apache-2.0"
] | null | null | null | src/ocilib-4.2.1/src/agent.c | ysmgigi/dbss | c6c00c4990a00514e158d1b10bc5cf38743fd2cc | [
"Apache-2.0"
] | null | null | null | /*
* OCILIB - C Driver for Oracle (C Wrapper for Oracle OCI)
*
* Website: http://www.ocilib.net
*
* Copyright (c) 2007-2016 Vincent ROGIER <vince.rogier@ocilib.net>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ocilib_internal.h"
/* ********************************************************************************************* *
* PRIVATE FUNCTIONS
* ********************************************************************************************* */
/* --------------------------------------------------------------------------------------------- *
* OCI_AgentInit
* --------------------------------------------------------------------------------------------- */
OCI_Agent * OCI_AgentInit
(
OCI_Connection *con,
OCI_Agent **pagent,
OCIAQAgent *handle,
const otext *name,
const otext *address
)
{
OCI_Agent *agent = NULL;
boolean res = FALSE;
OCI_CHECK(NULL == pagent, NULL)
/* allocate agent structure */
if (!*pagent)
{
*pagent = (OCI_Agent *) OCI_MemAlloc(OCI_IPC_AGENT, sizeof(*agent), (size_t) 1, TRUE);
}
if (*pagent)
{
res = TRUE;
agent = *pagent;
OCI_FREE(agent->name)
OCI_FREE(agent->address)
agent->con = con;
agent->handle = handle;
if (!handle)
{
agent->hstate = OCI_OBJECT_ALLOCATED;
res = OCI_SUCCESSFUL(OCI_DescriptorAlloc((dvoid * ) agent->con->env,
(dvoid **) &agent->handle,
OCI_DTYPE_AQAGENT,
(size_t) 0, (dvoid **) NULL));
}
else
{
agent->hstate = OCI_OBJECT_FETCHED_CLEAN;
}
/* set name attribute if provided */
if (res && name && name[0])
{
res = OCI_AgentSetName(agent, name);
}
/* set address attribute if provided */
if (res && address && address[0])
{
res = OCI_AgentSetAddress(agent, address);
}
}
/* check for failure */
if (!res && agent)
{
OCI_AgentFree(agent);
agent = NULL;
}
return agent;
}
/* ********************************************************************************************* *
* PUBLIC FUNCTIONS
* ********************************************************************************************* */
/* --------------------------------------------------------------------------------------------- *
* OCI_AgentCreate
* --------------------------------------------------------------------------------------------- */
OCI_Agent * OCI_API OCI_AgentCreate
(
OCI_Connection *con,
const otext *name,
const otext *address
)
{
OCI_LIB_CALL_ENTER(OCI_Agent *, NULL)
OCI_CHECK_PTR(OCI_IPC_CONNECTION, con)
call_retval = OCI_AgentInit(con, &call_retval, NULL, name, address);
call_status = (NULL != call_retval);
OCI_LIB_CALL_EXIT()
}
/* --------------------------------------------------------------------------------------------- *
* OCI_AgentFree
* --------------------------------------------------------------------------------------------- */
boolean OCI_API OCI_AgentFree
(
OCI_Agent *agent
)
{
OCI_LIB_CALL_ENTER(boolean, FALSE)
OCI_CHECK_PTR(OCI_IPC_AGENT, agent)
call_status = TRUE;
if (OCI_OBJECT_ALLOCATED == agent->hstate)
{
OCI_DescriptorFree((dvoid *) agent->handle, OCI_DTYPE_AQAGENT);
}
OCI_FREE(agent->address)
OCI_FREE(agent->name)
OCI_FREE(agent)
OCI_LIB_CALL_EXIT()
}
/* --------------------------------------------------------------------------------------------- *
* OCI_AgentGetName
* --------------------------------------------------------------------------------------------- */
const otext * OCI_API OCI_AgentGetName
(
OCI_Agent *agent
)
{
OCI_LIB_CALL_ENTER(otext *, NULL)
OCI_CHECK_PTR(OCI_IPC_AGENT, agent)
call_status = TRUE;
if (!agent->name)
{
call_status = OCI_GetStringAttribute(agent->con, agent->handle, OCI_DTYPE_AQAGENT,
OCI_ATTR_AGENT_NAME, &agent->name);
}
call_retval = agent->name;
OCI_LIB_CALL_EXIT()
}
/* --------------------------------------------------------------------------------------------- *
* OCI_AgentSetName
* --------------------------------------------------------------------------------------------- */
boolean OCI_API OCI_AgentSetName
(
OCI_Agent *agent,
const otext *name
)
{
OCI_LIB_CALL_ENTER(boolean , FALSE)
OCI_CHECK_PTR(OCI_IPC_AGENT, agent)
call_retval = call_status = OCI_SetStringAttribute(agent->con, agent->handle, OCI_DTYPE_AQAGENT,
OCI_ATTR_AGENT_NAME, &agent->name, name);
OCI_LIB_CALL_EXIT()
}
/* --------------------------------------------------------------------------------------------- *
* OCI_AgentGetAddress
* --------------------------------------------------------------------------------------------- */
const otext * OCI_API OCI_AgentGetAddress
(
OCI_Agent *agent
)
{
OCI_LIB_CALL_ENTER(otext *, NULL)
OCI_CHECK_PTR(OCI_IPC_AGENT, agent)
call_status = TRUE;
if (!agent->address)
{
call_status = OCI_GetStringAttribute(agent->con, agent->handle, OCI_DTYPE_AQAGENT,
OCI_ATTR_AGENT_ADDRESS, &agent->address);
}
call_retval = agent->address;
OCI_LIB_CALL_EXIT()
}
/* --------------------------------------------------------------------------------------------- *
* OCI_AgentSetAddress
* --------------------------------------------------------------------------------------------- */
boolean OCI_API OCI_AgentSetAddress
(
OCI_Agent *agent,
const otext *address
)
{
OCI_LIB_CALL_ENTER(boolean, FALSE)
OCI_CHECK_PTR(OCI_IPC_AGENT, agent)
call_retval = call_status = OCI_SetStringAttribute(agent->con, agent->handle, OCI_DTYPE_AQAGENT,
OCI_ATTR_AGENT_ADDRESS, &agent->address, address);
OCI_LIB_CALL_EXIT()
}
| 28.659919 | 106 | 0.422941 |
92e5b1d9d18e100a3abc52125cf5f44e45759abf | 1,071 | h | C | PoseFlow/deepmatching/main.h | jeongjuns/yolactpose | 6faea1707731e4a4bfb019856d3667e70238cfc6 | [
"MIT"
] | null | null | null | PoseFlow/deepmatching/main.h | jeongjuns/yolactpose | 6faea1707731e4a4bfb019856d3667e70238cfc6 | [
"MIT"
] | null | null | null | PoseFlow/deepmatching/main.h | jeongjuns/yolactpose | 6faea1707731e4a4bfb019856d3667e70238cfc6 | [
"MIT"
] | null | null | null | /*
Copyright (C) 2014 Jerome Revaud
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 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef ___MAIN_H___
#define ___MAIN_H___
#define EXE_OPTIONS 0
#define MATLAB_OPTIONS 1
#define PYTHON_OPTIONS 2
#include "deep_matching.h"
void usage(const int language);
const char* parse_options(dm_params_t *params, scalerot_params_t *sr_params, bool *use_scalerot, float *fx, float *fy, const int argc, const char **argv, const int language, image_t **im1, image_t **im2);
#endif
| 34.548387 | 205 | 0.760971 |
1c8c9430a9f087cbb5c62ff41e9c426d4669ac06 | 378 | c | C | clang/test/CodeGen/2009-06-01-addrofknr.c | ornata/llvm-project | 494913b8b4e4bce0b3525e5569d8e486e82b9a52 | [
"Apache-2.0"
] | null | null | null | clang/test/CodeGen/2009-06-01-addrofknr.c | ornata/llvm-project | 494913b8b4e4bce0b3525e5569d8e486e82b9a52 | [
"Apache-2.0"
] | null | null | null | clang/test/CodeGen/2009-06-01-addrofknr.c | ornata/llvm-project | 494913b8b4e4bce0b3525e5569d8e486e82b9a52 | [
"Apache-2.0"
] | null | null | null | // RUN: %clang_cc1 %s -o %t -emit-llvm -verify -std=c89
// PR4289
struct funcptr {
int (*func)();
};
static int func(f) // expected-warning {{a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x}}
void *f;
{
return 0;
}
int
main(int argc, char *argv[])
{
struct funcptr fp;
fp.func = &func;
fp.func = func;
}
| 17.181818 | 148 | 0.650794 |
59e33a5058a3647285db447d6f690dde2b960790 | 2,424 | h | C | Scripts/Template/Headers/org/mockito/internal/matchers/ArrayEquals.h | zhouxl/J2ObjC-Framework | ff83a41f44aaab295dbd4f4b4b02d5e894cdc2e1 | [
"MIT"
] | null | null | null | Scripts/Template/Headers/org/mockito/internal/matchers/ArrayEquals.h | zhouxl/J2ObjC-Framework | ff83a41f44aaab295dbd4f4b4b02d5e894cdc2e1 | [
"MIT"
] | null | null | null | Scripts/Template/Headers/org/mockito/internal/matchers/ArrayEquals.h | zhouxl/J2ObjC-Framework | ff83a41f44aaab295dbd4f4b4b02d5e894cdc2e1 | [
"MIT"
] | null | null | null | //
// Generated by the J2ObjC translator. DO NOT EDIT!
// source: /Users/antoniocortes/j2objcprj/relases/j2objc/testing/mockito/build_result/java/org/mockito/internal/matchers/ArrayEquals.java
//
#include "../../../../J2ObjC_header.h"
#pragma push_macro("INCLUDE_ALL_OrgMockitoInternalMatchersArrayEquals")
#ifdef RESTRICT_OrgMockitoInternalMatchersArrayEquals
#define INCLUDE_ALL_OrgMockitoInternalMatchersArrayEquals 0
#else
#define INCLUDE_ALL_OrgMockitoInternalMatchersArrayEquals 1
#endif
#undef RESTRICT_OrgMockitoInternalMatchersArrayEquals
#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 (OrgMockitoInternalMatchersArrayEquals_) && (INCLUDE_ALL_OrgMockitoInternalMatchersArrayEquals || defined(INCLUDE_OrgMockitoInternalMatchersArrayEquals))
#define OrgMockitoInternalMatchersArrayEquals_
#define RESTRICT_OrgMockitoInternalMatchersEquals 1
#define INCLUDE_OrgMockitoInternalMatchersEquals 1
#include "../../../../org/mockito/internal/matchers/Equals.h"
@class IOSObjectArray;
@protocol OrgHamcrestDescription;
@interface OrgMockitoInternalMatchersArrayEquals : OrgMockitoInternalMatchersEquals
#pragma mark Public
- (instancetype __nonnull)initWithId:(id)wanted;
+ (IOSObjectArray *)createObjectArrayWithId:(id)array;
- (void)describeToWithOrgHamcrestDescription:(id<OrgHamcrestDescription>)description_;
- (jboolean)matchesWithId:(id)actual;
@end
J2OBJC_EMPTY_STATIC_INIT(OrgMockitoInternalMatchersArrayEquals)
FOUNDATION_EXPORT void OrgMockitoInternalMatchersArrayEquals_initWithId_(OrgMockitoInternalMatchersArrayEquals *self, id wanted);
FOUNDATION_EXPORT OrgMockitoInternalMatchersArrayEquals *new_OrgMockitoInternalMatchersArrayEquals_initWithId_(id wanted) NS_RETURNS_RETAINED;
FOUNDATION_EXPORT OrgMockitoInternalMatchersArrayEquals *create_OrgMockitoInternalMatchersArrayEquals_initWithId_(id wanted);
FOUNDATION_EXPORT IOSObjectArray *OrgMockitoInternalMatchersArrayEquals_createObjectArrayWithId_(id array);
J2OBJC_TYPE_LITERAL_HEADER(OrgMockitoInternalMatchersArrayEquals)
#endif
#if __has_feature(nullability)
#pragma clang diagnostic pop
#endif
#pragma clang diagnostic pop
#pragma pop_macro("INCLUDE_ALL_OrgMockitoInternalMatchersArrayEquals")
| 34.628571 | 166 | 0.860974 |
0ccb9dd4600067a9c69525f2081fdcbe3400589f | 27,101 | c | C | minixbuilder/xc_minix_build.c | ivankelly/minix | 30caa3ccef22a9e9cfeefd4d3e5682ceb48e86d8 | [
"BSD-3-Clause"
] | 1 | 2020-04-01T01:05:25.000Z | 2020-04-01T01:05:25.000Z | minixbuilder/xc_minix_build.c | ivankelly/minix | 30caa3ccef22a9e9cfeefd4d3e5682ceb48e86d8 | [
"BSD-3-Clause"
] | null | null | null | minixbuilder/xc_minix_build.c | ivankelly/minix | 30caa3ccef22a9e9cfeefd4d3e5682ceb48e86d8 | [
"BSD-3-Clause"
] | 2 | 2020-04-19T18:22:06.000Z | 2020-09-08T00:51:49.000Z | /******************************************************************************
* xc_minix_build.c
* derived from xc_plan9_build.c
*/
#include "xc_private.h"
#define DEBUG 1
#ifdef DEBUG
#define DPRINTF(x) printf x; fflush(stdout);
#else
#define DPRINTF(x)
#endif
/** use this instead of free. prevents double frees happening */
#define dfree(ptr) do { free(ptr) ; ptr = NULL; } while (0)
#include <unistd.h>
#include "minixa.out.h"
#include "minix.h"
/* for some reason this isn't being found in unistd */
extern ssize_t pread (int __fd, void *__buf, size_t __nbytes,
__off_t __offset);
void setup_codeseg(struct segdesc_s *gdt_ptr, unsigned long cs);
void setup_dataseg(struct segdesc_s *gdt_ptr, unsigned long ds);
void setup_seg(struct segdesc_s *gdt_ptr, int index, unsigned long base, unsigned long size);
/** Protection levels for pages */
#define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED)
#define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
/** Constant defines where the virtual address space should start */
#define VIRT_ADDR_START 0x00000000
#define INITIAL_CODE_SEGMENT 1
#define INITIAL_DATA_SEGMENT 2
/**
* Get the total number of pages allocated to a domain
*/
static long
get_tot_pages(int xc_handle, u32 domid)
{
dom0_op_t op;
op.cmd = DOM0_GETDOMAININFO;
op.u.getdomaininfo.domain = (domid_t) domid;
op.u.getdomaininfo.ctxt = NULL;
return (do_dom0_op(xc_handle, &op) < 0) ?
-1 : op.u.getdomaininfo.tot_pages;
}
/**
* Get the frame number that should contain the shared_info structure
*/
static unsigned long
get_shared_info_frame(int xc_handle, u32 domid)
{
dom0_op_t op;
op.cmd = DOM0_GETDOMAININFO;
op.u.getdomaininfo.domain = (domid_t) domid;
op.u.getdomaininfo.ctxt = NULL;
return (do_dom0_op(xc_handle, &op) < 0) ?
-1 : op.u.getdomaininfo.shared_info_frame;
}
/**
do this function properly later maybe
if may not have any funtion within xen. from what i see it's used to
load the harddrive task. maybe needed, for virtual block device,
but until then, always return 1
*/
int
selected(char *name)
{
return 1;
}
/**
This function will need a bit of testing to get right
@return the size of the process on disk
*/
u32
proc_size(image_header_t *hdr)
{
/**
Size occupied on disk by each process consists of image_header,
text size and data size. this probably wont work. will need debugging
*/
return align(hdr->process.a_text, SECTOR_SIZE)
+ align(hdr->process.a_data, SECTOR_SIZE);
}
/**
Read the clicksize from the kernel image
*/
u16
get_clicksize(const int fd, off_t offset)
{
u16 click_shift = 0;
if (!pread(fd, &click_shift, sizeof(click_shift), offset + CLICK_OFF)) {
PERROR("Error reading click shift");
return 0;
}
if (click_shift < HCLICK_SHIFT || click_shift > 16) {
PERROR("Bad clickshift");
return 0;
}
printf("click_shift: %x\n", click_shift);
return 1 << click_shift;
}
/**
Read the boot flags from the kernel image
*/
u16
get_flags(const int fd, off_t offset)
{
u16 flags = 0;
if (!pread(fd, &flags, sizeof(flags), offset + FLAGS_OFF)) {
PERROR("Error reading flags");
return -1;
}
return flags;
}
/**
Read the magic number from the kernel image
*/
u16
get_magic_number(const int fd, off_t offset)
{
u16 magic = 0;
if (!pread(fd, &magic, sizeof(magic), offset + FLAGS_OFF)) {
PERROR("Error reading kernel magic number");
return 0;
}
return magic;
}
/**
Converts a page frame number to a virtual address.
@see setup_page_tables()
*/
unsigned long
pfn_to_vaddr(int pfn)
{
return VIRT_ADDR_START | (pfn << PAGE_SHIFT);
}
/**
Converts a virtual address to a page frame number
*/
unsigned long
vaddr_to_pfn(int vaddr)
{
return (vaddr & ~VIRT_ADDR_START) >> PAGE_SHIFT;
}
/**
Process size in memory
@return the amount of memory a process will occupy in memory
*/
static unsigned long
proc_size_in_memory(const image_header_t hdr, u16 click_size, u16 flags)
{
unsigned long stack_size = 0;
if (flags & K_CHMEM) {
stack_size = hdr.process.a_total - (hdr.process.a_data
+ hdr.process.a_bss);
if (!(hdr.process.a_flags & A_SEP)) {
stack_size -= hdr.process.a_text;
}
}
return align(hdr.process.a_text, click_size)
+ align(hdr.process.a_data, click_size)
+ align(hdr.process.a_bss, click_size)
+ align(stack_size, click_size);
}
/**
Copied data to the domain memory. Will always start to copy on
a new page.
@return return the virtual address of the first page used or -1 on error.
*/
static unsigned long
copy_to_domain_memory(int xc_handle, const u32 domid,
void *data, long size,
unsigned long *pages, const unsigned long nr_pages,
unsigned long *pg_alloc) {
unsigned long virt_addr = 0, addr = 0;
virt_addr = pfn_to_vaddr(*pg_alloc);
while (size > 0) {
addr = (unsigned long)xc_map_foreign_range(xc_handle, domid,
PAGE_SIZE, PROT_READ|PROT_WRITE,
pages[(*pg_alloc)++]);
if (addr == 0) {
PERROR("Error mapping process memory");
virt_addr = -1;
goto copy_error;
}
memcpy((void*)addr, data, (size > PAGE_SIZE) ? PAGE_SIZE : size);
munmap((void*)addr, PAGE_SIZE);
size -= PAGE_SIZE;
data += PAGE_SIZE;
}
copy_error:
return virt_addr;
}
/**
Read minix kernel image specified by image_name into memory of new domain
@return array of processes contained in kernel image
*/
static int
load_minix_image(int xc_handle, const u32 domid, const char *image_name,
unsigned long *pages, unsigned long *pg_alloc,
minix_start_info_t *msi)
{
image_header_t hdr;
int fd = 0, i = 0, banner = 0, ret = -1;
off_t fileoffset = 0, image_size = 0;
u16 click_size = 0, flags = 0, magic = 0;
char *buf = NULL, *bufptr = NULL;
unsigned long base = 0, size_in_mem = 0;
unsigned long text_offset = 0, data_offset = 0, bss_offset = 0, stack_size = 0;
image_header_t *headers = msi->setup_info.procheaders;
process_t *process_list = msi->setup_info.processes;
if (!(fd = open(image_name, 0))) { /* no flags on creation */
PERROR("Error opening image file");
goto load_error;
}
/* get size of image file */
image_size = lseek(fd, 0, SEEK_END);
lseek(fd, 0, SEEK_SET);
/**
Loop through all processes in image file
and load them into memory
*/
for (i = 0; fileoffset < image_size; i++) {
DPRINTF(("Loading image %i\n", i));
if (i == PROCESS_MAX) {
PERROR("Too many processes in image file");
goto load_error;
}
/**
read in headers. dont stop until a good one is found
then proceed
*/
while (1) {
if (!pread(fd, (void*)&hdr, sizeof(hdr), fileoffset)) {
PERROR("Error reading header");
goto load_error;
}
/** header has been read, so advance offset */
fileoffset += align(sizeof(image_header_t), SECTOR_SIZE);
/* check the magic number of the process, and dont use a bad one */
if (CHECKMAGIC(hdr.process)) {
PERROR("Bad Magic number on executable");
goto load_error;
}
/* check if we are to use this process. if not skip */
if (selected(hdr.name)) {
break;
}
/* bad process, skip it */
fileoffset += proc_size(&hdr);
}
/* make sure we're trying to run on the correct arch.
Xen only runs on 386 machines so we can only use a
386 minix image
*/
DPRINTF(("Checking image to make sure it is of the correct type\n"));
if (hdr.process.a_cpu != A_I80386) {
PERROR("Bad kernel image. Not for 386 architecture");
goto load_error;
}
/** get clickshift, flags and magic number */
if (i == KERNEL) {
if ((click_size = get_clicksize(fd, fileoffset)) == 0)
goto load_error;
if ((flags = get_flags(fd, fileoffset)) == (u16)-1)
goto load_error;
if ((magic = get_magic_number(fd, fileoffset)) == 0)
goto load_error;
}
DPRINTF(("Allocating memory for image buffer\n"));
size_in_mem = proc_size_in_memory(hdr, click_size, flags);
buf = (char*)malloc(size_in_mem);
if (buf == NULL) {
PERROR("Error allocating memory for process\n");
goto load_error;
}
bufptr = buf;
DPRINTF(("Reading image into buffer"));
/** copy text into buf */
text_offset = 0;
if (!pread(fd, bufptr, hdr.process.a_text, fileoffset)) {
PERROR("Error reading in text section\n");
goto load_error;
}
fileoffset += align(hdr.process.a_text, SECTOR_SIZE);
bufptr += align(hdr.process.a_text, click_size);
/** copy data into buf */
data_offset = bufptr - buf;
if (!pread(fd, bufptr, hdr.process.a_data, fileoffset)) {
PERROR("Error reading in data section\n");
goto load_error;
}
fileoffset += align(hdr.process.a_data, SECTOR_SIZE);
bufptr += align(hdr.process.a_data, click_size);
/** zero out the bss */
bss_offset = bufptr - buf;
memset(bufptr, 0, hdr.process.a_bss);
bufptr += align(hdr.process.a_bss, click_size);
DPRINTF(("Copying the buffer to the domain memory\n"));
base = copy_to_domain_memory(xc_handle, domid, buf,
size_in_mem,
pages, msi->start_info.nr_pages,
pg_alloc);
dfree(buf);
if (base == -1) {
PERROR("Error copying buf to domain memory\n");
goto load_error;
}
process_list[i].entry = hdr.process.a_entry;
process_list[i].cs = base + text_offset;
process_list[i].ds = base + data_offset;
process_list[i].data = base + data_offset;
process_list[i].end = base + hdr.process.a_total;
/** copy header into memory */
DPRINTF(("Updating header object with correct values\n"))
hdr.process.a_syms = base;
memcpy(&headers[i], &hdr, sizeof(image_header_t));
/** print process info for the user's benefit */
if (!banner) {
printf(" cs ds text data bss");
if (flags & K_CHMEM) printf(" stack");
putchar('\n');
banner = 1;
}
if (flags & K_CHMEM) {
stack_size = hdr.process.a_total - hdr.process.a_data
- hdr.process.a_bss;
if (!(hdr.process.a_flags & A_SEP)) stack_size -= hdr.process.a_text;
} else {
stack_size = 0;
}
printf("%07lx %07lx %8ld %8ld %8ld",
(unsigned long)process_list[i].cs,
(unsigned long)process_list[i].ds,
hdr.process.a_text, hdr.process.a_data,
hdr.process.a_bss
);
if (flags & K_CHMEM) printf(" %8ld", stack_size);
printf(" %s\n", hdr.name);
}
/* success! ret is set as such */
ret = 0;
load_error:
/**
something has gone wrong. cleanup
*/
if (fd) {
close(fd);
}
dfree(buf);
return ret;
}
/**
* Load the list of page frames that have been allocated to this VM
*/
static int get_pfn_list(int xc_handle,
u32 domid,
unsigned long *pfn_buf,
unsigned long max_pfns)
{
dom0_op_t op;
int ret;
op.cmd = DOM0_GETMEMLIST;
op.u.getmemlist.domain = (domid_t)domid;
op.u.getmemlist.max_pfns = max_pfns;
op.u.getmemlist.buffer = pfn_buf;
if ( mlock(pfn_buf, max_pfns * sizeof(unsigned long)) != 0 )
return -1;
ret = do_dom0_op(xc_handle, &op);
(void)munlock(pfn_buf, max_pfns * sizeof(unsigned long));
return (ret < 0) ? -1 : op.u.getmemlist.num_pfns;
}
/**
Setup page tables for minix. Page table for minix must be a
1-1 mapping of page table entries(pte) to page frames. This is
so the hardware will never fire a page fault, because minix hasnt
a clue in hell how to handle that.
The virtual address space must start from 64M onwards as the first
64M is reserved by xen.
This function also sets up the GDT frames for minix as it can't do it
itself (no notion of page tables)
**/
static int
setup_page_table(int xc_handle, u32 domid,
unsigned long *pages, unsigned long *pg_alloc,
unsigned long *pt_frame,
minix_start_info_t *msi)
{
int i = 0;
unsigned long va_start = VIRT_ADDR_START;
unsigned long first_non_kernel = 0;
/* variables needed for pagetable setup */
l1_pgentry_t *pg_tab=NULL, *pg_tab_entry=NULL;
l2_pgentry_t *pg_dir=NULL, *pg_dir_entry=NULL;
unsigned long pg_dir_frame = 0, pg_tab_frame = 0;
unsigned long first_pg_alloc = 0;
unsigned long *ptm_map, *ptm_map_e = NULL;
unsigned long first_gdt_pfn = 0;
unsigned long shared_info_frame = get_shared_info_frame(xc_handle, domid);
unsigned long *gdt_ptr = NULL;
mmu_t *mmu = NULL;
image_header_t *first_non_kernel_header = &msi->setup_info.procheaders[KERNEL+1];
first_non_kernel = vaddr_to_pfn(first_non_kernel_header->process.a_syms);
DPRINTF(("First non kernel page: %lx\n", first_non_kernel));
/*
work out how many page frames will be needed to hold
page tables
1 is for page required for page dir. Theres only ever one page dir.
*/
msi->start_info.nr_pt_frames = 1 +
(sizeof(l1_pgentry_t)*msi->start_info.nr_pages + PAGE_SIZE - 1)/PAGE_SIZE + 1;
if ( (mmu = init_mmu_updates(xc_handle, domid)) == NULL ) {
PERROR("Could not initialise mmu");
goto error_out;
}
/** initialise the gdt frames */
msi->setup_info.gdt_vaddr = pfn_to_vaddr(*pg_alloc);
first_gdt_pfn = *pg_alloc;
for (i = 0; i < NR_GDT_MF; i++) {
msi->setup_info.gdt_mfns[i] = pages[(*pg_alloc)++];
if ((gdt_ptr = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
PROT_READ|PROT_WRITE,
msi->setup_info.gdt_mfns[i])) == NULL) {
PERROR("Error mapping GDT frame");
goto error_out;
}
memset(gdt_ptr, 0x00000000, PAGE_SIZE);
munmap(gdt_ptr, PAGE_SIZE);
}
/* Allocate page to act as page dir */
first_pg_alloc = *pg_alloc;
msi->start_info.pt_base = pfn_to_vaddr(*pg_alloc);
pg_dir_frame = pages[(*pg_alloc)++] << PAGE_SHIFT;
*pt_frame = pg_dir_frame;
/* initialise page dir */
if ( (pg_dir = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE, PROT_READ|PROT_WRITE,
pg_dir_frame >> PAGE_SHIFT)) == NULL) {
PERROR("Error mapping directory frame");
goto error_out;
}
memset(pg_dir, 0, PAGE_SIZE);
pg_dir_entry = &pg_dir[l2_table_offset(va_start)];
/**
Loop through all the pages that have been allocated to me.
put them all in a 2 level page table structure.
*/
for (i = 0; i < msi->start_info.nr_pages; i++) {
/**
If the current page table entry needs a new entry in the
page dir, initialise that page dir */
if ( ((unsigned long)pg_tab_entry & (PAGE_SIZE-1)) == 0 ) {
pg_tab_frame = pages[(*pg_alloc)++] << PAGE_SHIFT;
if (pg_tab != NULL) {
munmap(pg_tab, PAGE_SIZE);
}
if ( (pg_tab = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
PROT_READ|PROT_WRITE,
pg_tab_frame >> PAGE_SHIFT)) == NULL) {
munmap(pg_dir, PAGE_SIZE);
PERROR("Error mapping page table frame");
goto error_out;
}
memset(pg_tab, 0, PAGE_SIZE);
pg_tab_entry = &pg_tab[l1_table_offset(va_start + (i << PAGE_SHIFT))];
*pg_dir_entry++ = pg_tab_frame | L2_PROT;
}
*pg_tab_entry = (pages[i] << PAGE_SHIFT) | L1_PROT;
if (i >= first_non_kernel) {
*pg_tab_entry |= _PAGE_USER;
}
/* sets the frames containing page table as read only
also contains page_dir and gdt as i slipped them in there */
if ((i >= first_pg_alloc && i < (first_pg_alloc + msi->start_info.nr_pt_frames))
|| ((i >= first_gdt_pfn && i <= first_gdt_pfn + NR_GDT_MF))) {
*pg_tab_entry &= ~_PAGE_RW;
}
pg_tab_entry++;
}
printf("Last usable page: %lx\n", pfn_to_vaddr(i));
/**
* place the shared info in accessible memory
*/
msi->shared_info = (shared_info_t *)FIXED_SHARED_INFO;
pg_dir_entry = &pg_dir[l2_table_offset(FIXED_SHARED_INFO)];
pg_tab_frame = pages[(*pg_alloc)++] << PAGE_SHIFT;
if (pg_tab != NULL) {
munmap(pg_tab, PAGE_SIZE);
}
if ( (pg_tab = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
PROT_READ|PROT_WRITE,
pg_tab_frame >> PAGE_SHIFT)) == NULL) {
munmap(pg_dir, PAGE_SIZE);
PERROR("Error mapping page table frame");
goto error_out;
}
memset(pg_tab, 0, PAGE_SIZE);
pg_tab_entry = &pg_tab[l1_table_offset(FIXED_SHARED_INFO)];
*pg_dir_entry = pg_tab_frame | L2_PROT | _PAGE_USER;
*pg_tab_entry = (shared_info_frame << PAGE_SHIFT) | L1_PROT;
munmap(pg_tab, PAGE_SIZE);
munmap(pg_dir, PAGE_SIZE);
/**
pin down page dir as page dir, so hypervisor protects it correctly
*/
if (add_mmu_update(xc_handle, mmu,
pg_dir_frame | MMU_EXTENDED_COMMAND, MMUEXT_PIN_L2_TABLE)) {
PERROR("Error pinning down page dir frame");
goto error_out;
}
/** build phys->machine and machine->map maps */
msi->start_info.mfn_list = pfn_to_vaddr(*pg_alloc);
ptm_map = ptm_map_e = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
PROT_READ|PROT_WRITE, pages[(*pg_alloc)++]);
for (i = 0; i < (XEN_DESC_LIMIT >> PAGE_SHIFT); i++) {
if (i < msi->start_info.nr_pages) {
if (add_mmu_update(xc_handle, mmu,
(pages[i] << PAGE_SHIFT) |
MMU_MACHPHYS_UPDATE, i)) {
PERROR("Error updating phy-mach mapping, fail on page %d", i);
munmap(ptm_map, PAGE_SIZE);
goto error_out;
}
*ptm_map_e++ = pages[i];
} else if (i <= (FIXED_SHARED_INFO >> PAGE_SHIFT) + 40) {
if (add_mmu_update(xc_handle, mmu,
(shared_info_frame << PAGE_SHIFT) |
MMU_MACHPHYS_UPDATE, FIXED_SHARED_INFO >> PAGE_SHIFT)) {
PERROR("Error updating phy-mach mapping, fail on page %d", i);
munmap(ptm_map, PAGE_SIZE);
goto error_out;
}
*ptm_map_e++ = shared_info_frame;
} else {
*ptm_map_e++ = 0x0;
}
if (((unsigned long)ptm_map_e & (PAGE_SIZE-1)) == 0) {
munmap(ptm_map, PAGE_SIZE);
ptm_map = ptm_map_e = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
PROT_READ|PROT_WRITE,
pages[(*pg_alloc)++]);
}
}
munmap(ptm_map, PAGE_SIZE);
/**
Cleanup up mmu and finish updates
*/
if (finish_mmu_updates(xc_handle, mmu)) {
PERROR("Couldn't finish mmu updates");
goto error_out;
}
dfree(mmu);
return 0;
error_out:
dfree(mmu);
return -1;
}
/**
Setup start info structure
This must be after all other pages are allocated, because the start of freemem
is calculated here.
*/
static int
setup_start_info(int xc_handle, u32 domid, unsigned long *pages,
unsigned long *pg_alloc, minix_start_info_t *msi)
{
int i = 0;
shared_info_t *shared_info;
unsigned long shared_info_frame = get_shared_info_frame(xc_handle, domid);
unsigned long msi_vaddr;
msi->start_info.shared_info = shared_info_frame << PAGE_SHIFT; /* machine addr */
/* shared_info page starts its life empty. */
shared_info = xc_map_foreign_range(
xc_handle, domid, PAGE_SIZE, PROT_READ|PROT_WRITE, shared_info_frame);
if (shared_info == NULL) {
PERROR("Error mapping shared info struct");
return -1;
}
memset(shared_info, 0, sizeof(shared_info_t));
/* Mask all upcalls... */
for ( i = 0; i < MAX_VIRT_CPUS; i++ )
shared_info->vcpu_data[i].evtchn_upcall_mask = 1;
munmap(shared_info, PAGE_SIZE);
msi->setup_info.msi_vaddr = pfn_to_vaddr(*pg_alloc);
msi->setup_info.fmem_vaddr = pfn_to_vaddr(*pg_alloc+KERNEL_STACK_PAGES);
msi_vaddr = copy_to_domain_memory(xc_handle, domid, msi, sizeof(minix_start_info_t),
pages, msi->start_info.nr_pages, pg_alloc);
if (msi->setup_info.msi_vaddr != msi_vaddr) {
PERROR("minix_start_info is not where it was expected. Aborting.");
return -1;
}
return 0;
}
/**
* Sets up the default code and data segments of the kernel.
* A lot of the descriptor code is nicked from protect.c in minix.
*/
void
build_seg(struct segdesc_s *gdt_ptr, int index, unsigned long base, unsigned long size)
{
gdt_ptr[index].base_low = base;
gdt_ptr[index].base_middle = base >> BASE_MIDDLE_SHIFT;
gdt_ptr[index].base_high = base >> BASE_HIGH_SHIFT;
--size; /* convert to a limit, 0 size means 4G */
if (size > BYTE_GRAN_MAX) {
gdt_ptr[index].limit_low = size >> PAGE_GRAN_SHIFT;
gdt_ptr[index].granularity = GRANULAR | (size >>
(PAGE_GRAN_SHIFT + GRANULARITY_SHIFT));
} else {
gdt_ptr[index].limit_low = size;
gdt_ptr[index].granularity = size >> GRANULARITY_SHIFT;
}
gdt_ptr[index].granularity |= DEFAULT; /* means BIG for data seg */
}
static int
setup_gdt(int xc_handle, u32 domid, minix_start_info_t *msi)
{
struct segdesc_s *gdt_ptr;
if ((gdt_ptr = xc_map_foreign_range(xc_handle, domid, PAGE_SIZE,
PROT_READ|PROT_WRITE,
msi->setup_info.gdt_mfns[0])) == NULL) {
PERROR("Error mapping GDT frame");
goto error_out;
}
build_seg(gdt_ptr, CS_INDEX,
msi->setup_info.processes[KERNEL].cs,
msi->setup_info.fmem_vaddr - (msi->setup_info.processes[KERNEL].cs) - 1);
gdt_ptr[CS_INDEX].access = (INTR_PRIVILEGE << DPL_SHIFT)
| (PRESENT | SEGMENT | EXECUTABLE | READABLE);
build_seg(gdt_ptr, DS_INDEX,
msi->setup_info.processes[KERNEL].ds, 0);
//msi->setup_info.fmem_vaddr - (msi->setup_info.processes[KERNEL].ds) - 1);
gdt_ptr[DS_INDEX].access = (INTR_PRIVILEGE << DPL_SHIFT) | (PRESENT | SEGMENT | WRITEABLE);
munmap(gdt_ptr, PAGE_SIZE);
return 0;
error_out:
return -1;
}
/**
* Builds a minix domain
* - Loads image into memory
* - Sets up page tables
* - Sets up start_info structure
* - Sets up GDT
* - Executes domain
*/
int
xc_minix_build(int xc_handle,
u32 domid,
const char *image_name,
const char *cmdline,
unsigned int control_evtchn, unsigned long flags)
{
dom0_op_t launch_op, op;
int rc, i;
full_execution_context_t st_ctxt, *ctxt = &st_ctxt;
unsigned long *pages = NULL;
unsigned long pt_frame = 0, pg_alloc = 0;
minix_start_info_t msi;
memset(&msi, 0, sizeof(msi));
/* get the number of page frames allocated to this domain */
if ( (msi.start_info.nr_pages = get_tot_pages(xc_handle, domid)) < 0 ) {
PERROR("Could not find total pages for domain");
goto error_out;
}
/**
page array needs its space allocated before it can be filled
*/
if ( (pages = malloc(msi.start_info.nr_pages * sizeof(unsigned long))) == NULL) {
PERROR("Could not allocate memory");
goto error_out;
}
/**
read in array of page frames
*/
if (get_pfn_list(xc_handle, domid, pages, msi.start_info.nr_pages)
!= msi.start_info.nr_pages) {
PERROR("Could not get the page frame list");
goto error_out;
}
/**
Load array of processes into domain memory
*/
if ( (load_minix_image(xc_handle, domid, image_name,
pages, &pg_alloc, &msi)) != 0) {
PERROR("Invalid kernel image");
goto error_out;
}
/**
Setup page table
*/
if (setup_page_table(xc_handle, domid, pages, &pg_alloc, &pt_frame, &msi) != 0) {
PERROR("Error setting up page tables");
goto error_out;
}
/**
Setup the start info and shared info structures.
pg_alloc is incremented as pages are used again.
*/
msi.start_info.flags = flags;
msi.start_info.domain_controller_evtchn = control_evtchn;
strncpy((char*)msi.start_info.cmd_line, cmdline, MAX_CMDLINE);
msi.start_info.cmd_line[MAX_CMDLINE-1] = '\0';
if (setup_start_info(xc_handle, domid, pages, &pg_alloc, &msi) != 0) {
PERROR("Error setting up start info structure");
goto error_out;
}
/**
Setup gdt
*/
if (setup_gdt(xc_handle, domid, &msi) != 0) {
PERROR("Error setting up the default GDT");
goto error_out;
}
if ( mlock(&st_ctxt, sizeof(st_ctxt) ) ) {
PERROR("Unable to mlock ctxt");
goto error_out;
}
op.cmd = DOM0_GETDOMAININFO;
op.u.getdomaininfo.domain = (domid_t)domid;
op.u.getdomaininfo.ctxt = ctxt;
if ( (do_dom0_op(xc_handle, &op) < 0) ||
((u16)op.u.getdomaininfo.domain != domid) ) {
PERROR("Could not get info on domain");
goto error_out;
}
if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) ||
(ctxt->pt_base != 0) ) {
ERROR("Domain is already constructed");
goto error_out;
}
ctxt->flags = 0;
ctxt->pt_base = pt_frame;
/*
* Initial register values:
* DS,ES,FS,GS = FLAT_GUESTOS_DS
* CS:EIP = FLAT_GUESTOS_CS:start_pc
* SS:ESP = FLAT_GUESTOS_DS:start_stack
* ESI = start_info
* [EAX, EBX, ECX,EDX,EDI,EBP are zero]
* EFLAGS = IF | 2 (bit 1 is reserved and should always be 1)
*/
ctxt->cpu_ctxt.ds = FLAT_GUESTOS_DS;
ctxt->cpu_ctxt.es = FLAT_GUESTOS_DS;
ctxt->cpu_ctxt.fs = FLAT_GUESTOS_DS;
ctxt->cpu_ctxt.gs = FLAT_GUESTOS_DS;
ctxt->cpu_ctxt.ss = FLAT_GUESTOS_DS;
ctxt->cpu_ctxt.cs = FLAT_GUESTOS_CS;
ctxt->cpu_ctxt.eip = msi.setup_info.processes[KERNEL].cs
+ msi.setup_info.processes[KERNEL].entry;
ctxt->cpu_ctxt.esp = msi.setup_info.msi_vaddr + KERNEL_STACK_SIZE;
ctxt->cpu_ctxt.esi = msi.setup_info.msi_vaddr;
ctxt->cpu_ctxt.eflags = (1<<9) | (1<<2);
/* FPU is set up to default initial state. */
memset(ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
/* Virtual IDT is empty at start-of-day. */
for ( i = 0; i < 256; i++ )
{
ctxt->trap_ctxt[i].vector = i;
ctxt->trap_ctxt[i].cs = FLAT_GUESTOS_CS;
}
ctxt->fast_trap_idx = 0;
/* No LDT. */
ctxt->ldt_ents = 0;
/* Use the default Xen-provided GDT. */
ctxt->gdt_ents = 0;
/* Ring 1 stack is the initial stack. */
ctxt->guestos_ss = FLAT_GUESTOS_DS;
ctxt->guestos_esp = msi.setup_info.msi_vaddr + KERNEL_STACK_SIZE;
/* No debugging. */
memset(ctxt->debugreg, 0, sizeof(ctxt->debugreg));
/* No callback handlers. */
ctxt->event_callback_cs = FLAT_GUESTOS_CS;
ctxt->event_callback_eip = 0;
ctxt->failsafe_callback_cs = FLAT_GUESTOS_CS;
ctxt->failsafe_callback_eip = 0;
memset( &launch_op, 0, sizeof(launch_op) );
launch_op.u.builddomain.domain = (domid_t)domid;
launch_op.u.builddomain.ctxt = ctxt;
launch_op.cmd = DOM0_BUILDDOMAIN;
DPRINTF(("***CPU Context***\n"));
DPRINTF(("CmdLine: %s\n", cmdline));
DPRINTF(("EAX: %lx\t", ctxt->cpu_ctxt.eax));
DPRINTF(("EBX: %lx\t", ctxt->cpu_ctxt.ebx));
DPRINTF(("ECX: %lx\t", ctxt->cpu_ctxt.ecx));
DPRINTF(("EDX: %lx\n", ctxt->cpu_ctxt.edx));
DPRINTF(("EBP: %lx\t", ctxt->cpu_ctxt.ebp));
DPRINTF(("ESI: %lx\t", ctxt->cpu_ctxt.esi));
DPRINTF(("ESP: %lx\t", ctxt->cpu_ctxt.esp));
DPRINTF(("EDI: %lx\n", ctxt->cpu_ctxt.edi));
DPRINTF(("EFLAGS: %lx\t", ctxt->cpu_ctxt.eflags));
DPRINTF(("_UNUSED: %lx\n", ctxt->cpu_ctxt._unused));
DPRINTF(("EIP: %lx\t", ctxt->cpu_ctxt.eip));
DPRINTF(("CS: %lx\n", ctxt->cpu_ctxt.cs));
DPRINTF(("SS: %lx\t", ctxt->cpu_ctxt.ss));
DPRINTF(("ES: %lx\t", ctxt->cpu_ctxt.es));
DPRINTF(("DS: %lx\t", ctxt->cpu_ctxt.ds));
DPRINTF(("FS: %lx\t", ctxt->cpu_ctxt.fs));
DPRINTF(("GS: %lx\n", ctxt->cpu_ctxt.gs));
DPRINTF(("***End CPU Context***\n"));
rc = do_dom0_op(xc_handle, &launch_op);
dfree(pages);
return rc;
error_out:
dfree(pages);
return -1;
}
| 28.769639 | 93 | 0.656987 |
f53ffc82bfe471c8b18295e56100fc67f5a6df3d | 31,276 | c | C | arch/amd64/code.c | matijaskala/pcc | 24419558147b85ddaeafad1c1a90ba7623316c88 | [
"BSD-3-Clause"
] | null | null | null | arch/amd64/code.c | matijaskala/pcc | 24419558147b85ddaeafad1c1a90ba7623316c88 | [
"BSD-3-Clause"
] | null | null | null | arch/amd64/code.c | matijaskala/pcc | 24419558147b85ddaeafad1c1a90ba7623316c88 | [
"BSD-3-Clause"
] | 1 | 2021-09-02T10:37:24.000Z | 2021-09-02T10:37:24.000Z | /* $Id: code.c,v 1.94 2020/04/10 20:00:08 plunky Exp $ */
/*
* Copyright (c) 2008 Michael Shalayeff
* Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. 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.
*/
# include "pass1.h"
#ifndef LANG_CXX
#undef NIL
#define NIL NULL
#define NODE P1ND
#define nfree p1nfree
#define ccopy p1tcopy
#define tfree p1tfree
#endif
static int nsse, ngpr, nrsp, rsaoff;
static int thissse, thisgpr, thisrsp;
enum { NO_CLASS, INTEGER, INTMEM, SSE, SSEMEM, X87,
STRREG, STRMEM, STRSSE, STRIF, STRFI, STRX87 };
static const int argregsi[] = { RDI, RSI, RDX, RCX, R08, R09 };
/*
* The Register Save Area looks something like this.
* It is put first on stack with fixed offsets.
* struct {
* long regs[6];
* double xmm[8][2]; // 16 byte in width
* };
*/
#define RSASZ (6*SZLONG+8*2*SZDOUBLE)
#define RSALONGOFF(x) (RSASZ-(x)*SZLONG)
#define RSADBLOFF(x) ((8*2*SZDOUBLE)-(x)*SZDOUBLE*2)
/* va_list */
#define VAARGSZ (SZINT*2+SZPOINT(CHAR)*2)
#define VAGPOFF(x) (x)
#define VAFPOFF(x) (x-SZINT)
#define VAOFA(x) (x-SZINT-SZINT)
#define VARSA(x) (x-SZINT-SZINT-SZPOINT(0))
static int stroffset;
static int varneeds;
#define NEED_1FPREF 001
#define NEED_2FPREF 002
#define NEED_1REGREF 004
#define NEED_2REGREF 010
#define NEED_MEMREF 020
#define NEED_STRFI 040
#define NEED_STRIF 0100
static int argtyp(TWORD t, union dimfun *df, struct attr *ap);
static NODE *movtomem(NODE *p, int off, int reg);
static NODE *movtoreg(NODE *p, int rno);
void varattrib(char *name, struct attr *sap);
/*
* Print out assembler segment name.
*/
#ifdef MACHOABI
void
setseg(int seg, char *name)
{
switch (seg) {
case PROG: name = ".text"; break;
case DATA:
case LDATA: name = ".data"; break;
case RDATA: name = ".const"; break;
case STRNG: name = ".cstring"; break;
case UDATA: break;
case CTORS: name = ".mod_init_func"; break;
case DTORS: name = ".mod_term_func"; break;
default:
cerror("unknown seg %d", seg);
}
printf("\t%s\n", name);
}
#else
void
setseg(int seg, char *name)
{
switch (seg) {
case PROG: name = ".text"; break;
case DATA:
case LDATA: name = ".data"; break;
case STRNG:
case RDATA: name = ".section .rodata"; break;
case UDATA: break;
case PICLDATA:
case PICDATA: name = ".section .data.rel.rw,\"aw\",@progbits"; break;
case PICRDATA: name = ".section .data.rel.ro,\"aw\",@progbits"; break;
case TLSDATA: name = ".section .tdata,\"awT\",@progbits"; break;
case TLSUDATA: name = ".section .tbss,\"awT\",@nobits"; break;
case CTORS: name = ".section\t.ctors,\"aw\",@progbits"; break;
case DTORS: name = ".section\t.dtors,\"aw\",@progbits"; break;
case NMSEG:
printf("\t.section %s,\"a%c\",@progbits\n", name,
cftnsp ? 'x' : 'w');
return;
}
printf("\t%s\n", name);
}
#endif
/*
* Define everything needed to print out some data (or text).
* This means segment, alignment, visibility, etc.
*/
void
defloc(struct symtab *sp)
{
char *name;
name = getexname(sp);
if (sp->sclass == EXTDEF) {
printf("\t.globl %s\n", name);
#ifndef MACHOABI
if (ISFTN(sp->stype)) {
printf("\t.type %s,@function\n", name);
} else {
printf("\t.type %s,@object\n", name);
printf("\t.size %s,%d\n", name,
(int)tsize(sp->stype, sp->sdf, sp->sap)/SZCHAR);
}
#endif
}
if (sp->slevel == 0)
printf("%s:\n", name);
else
printf(LABFMT ":\n", sp->soffset);
}
/*
* code for the end of a function
* deals with struct return here
* The return value is in (or pointed to by) RETREG.
*/
void
efcode(void)
{
struct symtab *sp;
extern int gotnr;
TWORD t;
NODE *p, *r, *l;
int typ;
gotnr = 0; /* new number for next fun */
sp = cftnsp;
t = DECREF(sp->stype);
if (t != STRTY && t != UNIONTY)
return;
/* XXX should have one routine for this */
ngpr = nsse = 0;
typ = argtyp(t, sp->sdf, sp->sap);
if (typ == STRMEM) {
r = block(REG, NIL, NIL, INCREF(t), sp->sdf, sp->sap);
regno(r) = RAX;
r = buildtree(UMUL, r, NIL);
l = tempnode(stroffset, INCREF(t), sp->sdf, sp->sap);
l = buildtree(UMUL, l, NIL);
ecomp(buildtree(ASSIGN, l, r));
l = block(REG, NIL, NIL, LONG, 0, 0);
regno(l) = RAX;
r = tempnode(stroffset, LONG, 0, 0);
ecomp(buildtree(ASSIGN, l, r));
} else if (typ == STRX87) {
p = block(REG, NIL, NIL, INCREF(LDOUBLE), 0, 0);
regno(p) = RAX;
p = buildtree(UMUL, buildtree(PLUS, p, bcon(1)), NIL);
ecomp(movtoreg(p, 041));
p = block(REG, NIL, NIL, INCREF(LDOUBLE), 0, 0);
regno(p) = RAX;
p = buildtree(UMUL, p, NIL);
ecomp(movtoreg(p, 040));
} else {
TWORD t1, t2;
int r1, r2;
if (typ == STRSSE || typ == STRFI)
r1 = XMM0, t1 = DOUBLE;
else
r1 = RAX, t1 = LONG;
if (typ == STRSSE)
r2 = XMM1, t2 = DOUBLE;
else if (typ == STRFI)
r2 = RAX, t2 = LONG;
else if (typ == STRIF)
r2 = XMM0, t2 = DOUBLE;
else /* if (typ == STRREG) */
r2 = RDX, t2 = LONG;
if (tsize(t, sp->sdf, sp->sap) > SZLONG) {
p = block(REG, NIL, NIL, INCREF(t2), 0, 0);
regno(p) = RAX;
p = buildtree(UMUL, buildtree(PLUS, p, bcon(1)), NIL);
ecomp(movtoreg(p, r2));
}
p = block(REG, NIL, NIL, INCREF(t1), 0, 0);
regno(p) = RAX;
p = buildtree(UMUL, p, NIL);
ecomp(movtoreg(p, r1));
}
}
/*
* code for the beginning of a function; a is an array of
* indices in symtab for the arguments; n is the number
*/
void
bfcode(struct symtab **s, int cnt)
{
union arglist *al;
struct symtab *sp;
NODE *p, *r;
TWORD t;
int i, rno, typ, ssz;
/* recalculate the arg offset and create TEMP moves */
/* Always do this for reg, even if not optimizing, to free arg regs */
nsse = ngpr = 0;
nrsp = ARGINIT;
if (cftnsp->stype == STRTY+FTN || cftnsp->stype == UNIONTY+FTN) {
sp = cftnsp;
if (argtyp(DECREF(sp->stype), sp->sdf, sp->sap) == STRMEM) {
r = block(REG, NIL, NIL, LONG, 0, 0);
regno(r) = argregsi[ngpr++];
p = tempnode(0, r->n_type, r->n_df, r->n_ap);
stroffset = regno(p);
ecomp(buildtree(ASSIGN, p, r));
}
}
for (i = 0; i < cnt; i++) {
sp = s[i];
if (sp == NULL)
continue; /* XXX when happens this? */
ssz = (int)tsize(sp->stype, sp->sdf, sp->sap);
switch (typ = argtyp(sp->stype, sp->sdf, sp->sap)) {
case INTEGER:
case SSE:
if (typ == SSE)
rno = XMM0 + nsse++;
else
rno = argregsi[ngpr++];
r = block(REG, NIL, NIL, sp->stype, sp->sdf, sp->sap);
regno(r) = rno;
p = tempnode(0, sp->stype, sp->sdf, sp->sap);
sp->soffset = regno(p);
sp->sflags |= STNODE;
ecomp(buildtree(ASSIGN, p, r));
break;
case SSEMEM:
sp->soffset = nrsp;
nrsp += SZDOUBLE;
if (xtemps) {
p = tempnode(0, sp->stype, sp->sdf, sp->sap);
p = buildtree(ASSIGN, p, nametree(sp));
sp->soffset = regno(p->n_left);
sp->sflags |= STNODE;
ecomp(p);
}
break;
case INTMEM:
sp->soffset = nrsp;
nrsp += SZLONG;
if (xtemps) {
p = tempnode(0, sp->stype, sp->sdf, sp->sap);
p = buildtree(ASSIGN, p, nametree(sp));
sp->soffset = regno(p->n_left);
sp->sflags |= STNODE;
ecomp(p);
}
break;
case STRX87:
case STRMEM: /* Struct in memory */
sp->soffset = nrsp;
nrsp += ssz;
break;
case X87: /* long double args */
sp->soffset = nrsp;
nrsp += SZLDOUBLE;
break;
case STRFI:
case STRIF:
case STRSSE:
case STRREG: /* Struct in register */
autooff += (2*SZLONG);
if (typ == STRSSE || typ == STRFI) {
rno = XMM0 + nsse++;
t = DOUBLE;
} else {
rno = argregsi[ngpr++];
t = LONG;
}
r = block(REG, NIL, NIL, t, 0, 0);
regno(r) = rno;
ecomp(movtomem(r, -autooff, FPREG));
if (ssz > SZLONG) {
if (typ == STRSSE || typ == STRIF) {
rno = XMM0 + nsse++;
t = DOUBLE;
} else {
rno = argregsi[ngpr++];
t = LONG;
}
r = block(REG, NIL, NIL, t, 0, 0);
regno(r) = rno;
ecomp(movtomem(r, -autooff+SZLONG, FPREG));
}
sp->soffset = -autooff;
break;
default:
cerror("bfcode: %d", typ);
}
}
/* Check if there are varargs */
if (cftnsp->sdf == NULL || cftnsp->sdf->dfun == NULL)
return; /* no prototype */
al = cftnsp->sdf->dfun;
for (; al->type != TELLIPSIS; al++) {
t = al->type;
if (t == TNULL)
return;
if (ISSOU(BTYPE(t)))
al++;
for (i = 0; t > BTMASK; t = DECREF(t))
if (ISARY(t) || ISFTN(t))
i++;
if (i)
al++;
}
/* fix stack offset */
SETOFF(autooff, ALMAX);
/* Save reg arguments in the reg save area */
p = NIL;
for (i = ngpr; i < 6; i++) {
r = block(REG, NIL, NIL, LONG, 0, 0);
regno(r) = argregsi[i];
r = movtomem(r, -RSALONGOFF(i)-autooff, FPREG);
p = (p == NIL ? r : block(COMOP, p, r, INT, 0, 0));
}
for (i = nsse; i < 8; i++) {
r = block(REG, NIL, NIL, DOUBLE, 0, 0);
regno(r) = i + XMM0;
r = movtomem(r, -RSADBLOFF(i)-autooff, FPREG);
p = (p == NIL ? r : block(COMOP, p, r, INT, 0, 0));
}
autooff += RSASZ;
rsaoff = autooff;
thissse = nsse;
thisgpr = ngpr;
thisrsp = nrsp;
ecomp(p);
}
/* called just before final exit */
/* flag is 1 if errors, 0 if none */
void
ejobcode(int flag)
{
if (flag)
return;
#ifdef MACHOABI
#define PT(x)
#else
#define PT(x) printf(".type __pcc_" x ",@function\n")
#endif
#define P(x) printf(x "\n")
/* printout varargs routines if used */
if (varneeds & NEED_STRFI) { /* struct with one float and then int */
P(".text\n.align 4");
PT("strif");
P("__pcc_strif:");
P("cmpl $176,4(%%rdi)\njae .Ladd16");
P("cmpl $48,(%%rdi)\njae .Ladd16\n");
P("movl 4(%%rdi),%%eax\naddq 16(%%rdi),%%rax");
P("movq (%%rax),%%rdx\nmovq %%rdx,24(%%rdi)");
P("movl (%%rdi),%%eax\naddq 16(%%rdi),%%rax");
P("movq 16(%%rax),%%rdx\nmovq %%rdx,32(%%rdi)");
P("leaq 24(%%rdi),%%rax\nret");
}
if (varneeds & NEED_STRIF) { /* struct with one int and one float */
P(".text\n.align 4");
PT("strif");
P("__pcc_strif:");
P("cmpl $176,4(%%rdi)\njae .Ladd16");
P("cmpl $48,(%%rdi)\njae .Ladd16\n");
P("movl (%%rdi),%%eax\naddq 16(%%rdi),%%rax");
P("movq (%%rax),%%rdx\nmovq %%rdx,24(%%rdi)");
P("movl 4(%%rdi),%%eax\naddq 16(%%rdi),%%rax");
P("movq 16(%%rax),%%rdx\nmovq %%rdx,32(%%rdi)");
P("leaq 24(%%rdi),%%rax\nret");
}
if (varneeds & NEED_2FPREF) { /* struct with two float regs */
P(".text\n.align 4");
PT("2fpref");
P("__pcc_2fpref:");
P("cmpl $160,4(%%rdi)\njae .Ladd16");
P("movl 4(%%rdi),%%eax\naddq 16(%%rdi),%%rax");
P("addl $32,4(%%rdi)");
P("movq (%%rax),%%rdx\nmovq %%rdx,24(%%rdi)");
P("movq 16(%%rax),%%rdx\nmovq %%rdx,32(%%rdi)");
P("leaq 24(%%rdi),%%rax\nret");
}
if (varneeds & NEED_1FPREF) {
printf(".text\n.align 4\n");
PT("1fpref");
printf("__pcc_1fpref:\n");
printf("cmpl $176,4(%%rdi)\njae .Ladd8\n");
printf("movl 4(%%rdi),%%eax\naddq 16(%%rdi),%%rax\n");
printf("addl $16,4(%%rdi)\nret\n");
}
if (varneeds & NEED_1REGREF) {
printf(".text\n.align 4\n");
PT("1regref");
printf("__pcc_1regref:\n");
printf("cmpl $48,(%%rdi)\njae .Ladd8\n");
printf("movl (%%rdi),%%eax\naddq 16(%%rdi),%%rax\n");
printf("addl $8,(%%rdi)\nret\n");
}
if (varneeds & NEED_2REGREF) {
printf(".text\n.align 4\n");
PT("2regref");
printf("__pcc_2regref:\n");
printf("cmpl $40,(%%rdi)\njae .Ladd16\n");
printf("movl (%%rdi),%%eax\naddq 16(%%rdi),%%rax\n");
printf("addl $16,(%%rdi)\nret\n");
}
if (varneeds & NEED_MEMREF) {
printf(".text\n.align 4\n");
PT("memref");
printf("__pcc_memref:\n");
printf("movq 8(%%rdi),%%rax\n");
printf("addq %%rsi,8(%%rdi)\nret\n");
}
if (varneeds & (NEED_1FPREF|NEED_1REGREF)) {
P(".Ladd8:");
P("movq 8(%%rdi),%%rax");
P("addq $8,8(%%rdi)");
P("ret");
}
if (varneeds & (NEED_2FPREF|NEED_2REGREF|NEED_STRFI|NEED_STRIF)) {
P(".Ladd16:");
P("movq 8(%%rdi),%%rax");
P("addq $16,8(%%rdi)");
P("ret");
}
#ifdef MACHOABI
printf("\t.ident \"PCC: %s\"\n", VERSSTR);
#else
printf("\t.ident \"PCC: %s\"\n\t.end\n", VERSSTR);
#endif
}
/*
* Varargs stuff:
* The ABI says that va_list should be declared as this typedef.
* We handcraft it here and then just reference it.
*
* typedef struct {
* unsigned int gp_offset;
* unsigned int fp_offset;
* void *overflow_arg_area;
* void *reg_save_area;
* } __builtin_va_list[1];
*
* ...actually, we allocate two of them and use the second one as
* bounce buffers for floating point structs...
*
* There are a number of asm routines printed out if varargs are used:
* long __pcc_gpnext(va) - get a gpreg value
* long __pcc_fpnext(va) - get a fpreg value
* void *__pcc_1regref(va) - get reference to a onereg struct
* void *__pcc_2regref(va) - get reference to a tworeg struct
* void *__pcc_memref(va,sz) - get reference to a large struct
*/
static char *gp_offset, *fp_offset, *overflow_arg_area, *reg_save_area;
static char *_1fpref, *_2fpref, *_1regref, *_2regref, *memref;
static char *strif, *strfi;
void
bjobcode(void)
{
struct symtab *sp;
struct rstack *rp;
NODE *p, *q;
char *c;
#if defined(__GNUC__) || defined(__PCC__)
/* Be sure that the compiler uses full x87 */
/* XXX cross-compiling will fail here */
volatile int fcw = 0;
__asm("fstcw (%0)" : : "r"(&fcw));
fcw |= 0x33f;
__asm("fldcw (%0)" : : "r"(&fcw));
#endif
/* amd64 names for some asm constant printouts */
astypnames[INT] = astypnames[UNSIGNED] = "\t.long";
astypnames[LONG] = astypnames[ULONG] = "\t.quad";
gp_offset = addname("gp_offset");
fp_offset = addname("fp_offset");
overflow_arg_area = addname("overflow_arg_area");
reg_save_area = addname("reg_save_area");
rp = bstruct(NULL, STNAME, NULL);
p = block(NAME, NIL, NIL, UNSIGNED, 0, 0);
soumemb(p, gp_offset, 0);
soumemb(p, fp_offset, 0);
p->n_type = VOID+PTR;
p->n_ap = NULL;
soumemb(p, overflow_arg_area, 0);
soumemb(p, reg_save_area, 0);
nfree(p);
q = dclstruct(rp);
c = addname("__builtin_va_list");
p = block(LB, bdty(NAME, c), bcon(2), INT, 0, 0);
p = tymerge(q, p);
p->n_sp = lookup(c, 0);
defid(p, TYPEDEF);
nfree(q);
nfree(p);
#ifdef GCC_COMPAT
/*
* gcc defines __float128 on amd64. We handcraft a typedef
* of long double here to make glibc happy. (size is same).
*/
p = bdty(NAME, c = addname("__float128"));
p = tymerge(q = mkty(LDOUBLE, 0, 0), p);
p->n_sp = lookup(c, 0);
defid(p, TYPEDEF);
nfree(q);
nfree(p);
#endif
/* for the static varargs functions */
#define MKN(vn, rn) \
{ vn = addname(rn); sp = lookup(vn, SNORMAL); \
sp->sclass = USTATIC; sp->stype = FTN|VOID|(PTR<<TSHIFT); }
MKN(strfi, "__pcc_strfi");
MKN(strif, "__pcc_strif");
MKN(_1fpref, "__pcc_1fpref");
MKN(_2fpref, "__pcc_2fpref");
MKN(_1regref, "__pcc_1regref");
MKN(_2regref, "__pcc_2regref");
MKN(memref, "__pcc_memref");
}
static NODE *
mkstkref(int off, TWORD typ)
{
NODE *p;
p = block(REG, NIL, NIL, PTR|typ, 0, 0);
regno(p) = FPREG;
return buildtree(PLUS, p, bcon(off/SZCHAR));
}
NODE *
amd64_builtin_stdarg_start(const struct bitable *bt, NODE *a)
{
NODE *p, *r;
/* use the values from the function header */
p = a->n_left;
r = buildtree(ASSIGN, structref(ccopy(p), STREF, reg_save_area),
mkstkref(-rsaoff, VOID));
r = buildtree(COMOP, r,
buildtree(ASSIGN, structref(ccopy(p), STREF, overflow_arg_area),
mkstkref(thisrsp, VOID)));
r = buildtree(COMOP, r,
buildtree(ASSIGN, structref(ccopy(p), STREF, gp_offset),
bcon(thisgpr*(SZLONG/SZCHAR))));
r = buildtree(COMOP, r,
buildtree(ASSIGN, structref(ccopy(p), STREF, fp_offset),
bcon(thissse*(SZDOUBLE*2/SZCHAR)+48)));
tfree(a);
return r;
}
static NODE *
mkvacall(char *fun, NODE *a, int typ)
{
NODE *r, *f = block(NAME, NIL, NIL, INT, 0, 0);
NODE *ap = a->n_left;
NODE *dp = a->n_right;
OFFSZ sz = tsize(dp->n_type, dp->n_df, dp->n_ap);
f->n_sp = lookup(fun, SNORMAL);
varneeds |= typ;
f->n_type = f->n_sp->stype;
f = clocal(f);
SETOFF(sz, ALLONG);
r = buildtree(CALL, f,
buildtree(CM, ccopy(ap), bcon(sz/SZCHAR)));
r = ccast(r, INCREF(dp->n_type), 0, dp->n_df, dp->n_ap);
r = buildtree(UMUL, r, NIL);
return r;
}
NODE *
amd64_builtin_va_arg(const struct bitable *bt, NODE *a)
{
NODE *r, *dp;
int typ;
OFFSZ sz;
dp = a->n_right;
nsse = ngpr = 0;
sz = tsize(dp->n_type, dp->n_df, dp->n_ap);
switch (typ = argtyp(dp->n_type, dp->n_df, dp->n_ap)) {
case INTEGER:
r = mkvacall(_1regref, a, NEED_1REGREF);
break;
case SSE:
r = mkvacall(_1fpref, a, NEED_1FPREF);
break;
default:
cerror("va_arg: bad type %d", typ);
case X87:
case STRX87:
case STRMEM: /* stored in memory */
r = mkvacall(memref, a, NEED_MEMREF);
break;
case STRREG: /* struct in general regs */
if (sz <= SZLONG)
r = mkvacall(_1regref, a, NEED_1REGREF);
else
r = mkvacall(_2regref, a, NEED_2REGREF);
break;
case STRSSE:
if (sz <= SZLONG)
r = mkvacall(_1fpref, a, NEED_1FPREF);
else
r = mkvacall(_2fpref, a, NEED_2FPREF);
break;
case STRIF:
r = mkvacall(strif, a, NEED_STRIF);
break;
case STRFI:
r = mkvacall(strfi, a, NEED_STRFI);
break;
}
tfree(a);
return r;
}
NODE *
amd64_builtin_va_end(const struct bitable *bt, NODE *a)
{
tfree(a);
return bcon(0); /* nothing */
}
NODE *
amd64_builtin_va_copy(const struct bitable *bt, NODE *a)
{
NODE *f;
f = buildtree(ASSIGN, buildtree(UMUL, a->n_left, NIL),
buildtree(UMUL, a->n_right, NIL));
nfree(a);
return f;
}
static NODE *
movtoreg(NODE *p, int rno)
{
NODE *r;
r = block(REG, NIL, NIL, p->n_type, p->n_df, p->n_ap);
regno(r) = rno;
return clocal(buildtree(ASSIGN, r, p));
}
static NODE *
movtomem(NODE *p, int off, int reg)
{
struct symtab s;
NODE *r, *l;
s.stype = p->n_type;
s.squal = 0;
s.sdf = p->n_df;
s.sap = p->n_ap;
s.soffset = off;
s.sclass = AUTO;
l = block(REG, NIL, NIL, PTR+STRTY, 0, 0);
slval(l, 0);
regno(l) = reg;
r = block(NAME, NIL, NIL, p->n_type, p->n_df, p->n_ap);
r->n_sp = &s;
r = stref(block(STREF, l, r, 0, 0, 0));
return clocal(buildtree(ASSIGN, r, p));
}
/*
* Check what to do with a struct/union. We traverse down in the struct to
* find which types it is and where the struct really should be.
* The return vals we may end up with are:
* STRREG - The whole struct is saved in general registers.
* STRMEM - the struct is saved in memory.
* STRSSE - the whole struct is saved in SSE registers.
* STRIF - First word of struct is saved in general reg, other SSE.
* STRFI - First word of struct is saved in SSE, next in general reg.
*
* INTEGER, MEMORY, X87, X87UP, X87COMPLEX, SSE, NO_CLASS.
*
* - If size > 16 bytes or there are packed fields, use memory.
* - If any part of an eight-byte should be in a general register,
* the eight-byte is stored in a general register
* - If the eight-byte only contains float or double, use a SSE register
* - Otherwise use memory.
*
* Arrays must be broken up as separate elements, since the elements
* are classified separately. For example;
* struct s { short s; float f[3]; } S;
* will have the first 64 bits passed in general reg and the second in SSE.
*
* sp below is a pointer to a member list.
* off tells how many bits in that the classification should start.
*/
/*
* fill in an array of what elements are classified as.
* May return:
* - NO_CLASS (if more checks needed)
* - STRMEM (if known to end up in memory)
*/
#define MAXCLELEM 128
static struct {
int off;
int cl;
} cla[MAXCLELEM];
static int clp;
static int fillstr(struct symtab *sp);
static int fillun(struct symtab *sp);
static int
flatten(TWORD t, struct symtab *sp)
{
int cl;
clp = 0;
cl = (t == STRTY ? fillstr(sp) : fillun(sp));
return cl;
}
static int
fillstr(struct symtab *sp)
{
int cl = NO_CLASS;
TWORD t;
for (; sp; sp = sp->snext) {
t = sp->stype;
while (ISARY(t))
t = DECREF(t);
if (t <= ULONGLONG || ISPTR(t)) {
cla[clp].cl = STRREG;
cla[clp++].off = (int)sp->soffset;
} else if (t <= DOUBLE) {
cla[clp].cl = STRSSE;
cla[clp++].off = (int)sp->soffset;
} else if (t == LDOUBLE) {
cl = STRMEM;
break;
} else { /* struct or union */
#ifdef GCC_COMPAT
if (attr_find(sp->sap, GCC_ATYP_PACKED)) {
cl = STRMEM;
break;
}
#endif
if (t == STRTY)
cl = fillstr(strmemb(sp->sap));
else if (t == UNIONTY)
cl = fillun(strmemb(sp->sap));
else
cerror("fillstr: %d", t);
if (cl == STRMEM)
break;
}
}
return cl;
}
/* NO_CLASS, STRMEM, STRREG, STRSSE, X87 */
static int
unmerge(int old, int new)
{
int cl = old;
if (new == STRMEM)
cl = new;
else switch (old) {
case NO_CLASS:
cl = new;
break;
case STRREG:
case STRMEM:
break;
case X87:
if (new == STRREG)
cl = new;
else if (new == STRSSE)
cl = STRMEM;
else
cl = X87;
break;
case STRSSE:
if (new == X87)
cl = STRMEM;
else
cl = new;
break;
}
return cl;
}
static int
fillun(struct symtab *sp)
{
int cl = NO_CLASS;
TWORD t;
cla[clp].off = (int)sp->soffset;
for (; sp; sp = sp->snext) {
t = sp->stype;
while (ISARY(t))
t = DECREF(t);
if (t <= ULONGLONG || ISPTR(t)) {
cl = unmerge(cl, STRREG);
} else if (t <= DOUBLE) {
cl = unmerge(cl, STRSSE);
} else if (t == LDOUBLE) {
cl = unmerge(cl, X87);
} else { /* struct or union */
#ifdef GCC_COMPAT
if (attr_find(sp->sap, GCC_ATYP_PACKED)) {
cl = STRMEM;
} else
#endif
{ int cl2 = NO_CLASS;
if (t == STRTY)
cl2 = fillstr(strmemb(sp->sap));
else if (t == UNIONTY)
cl2 = fillun(strmemb(sp->sap));
else
cerror("fillstr: %d", t);
cl = unmerge(cl, cl2);
}
}
if (cl == STRMEM)
break;
}
if (cl == X87)
cl = STRMEM;
cla[clp].cl = cl;
clp++;
return cl;
}
/*
* Check for long double complex structs.
*/
static int
iscplx87(struct symtab *sp)
{
if (sp->stype == LDOUBLE && sp->snext->stype == LDOUBLE &&
sp->snext->snext == NULL)
return STRX87;
return 0;
}
/*
* AMD64 parameter classification.
*/
static int
argtyp(TWORD t, union dimfun *df, struct attr *ap)
{
int i, cl2, cl = 0;
if (t <= ULONG || ISPTR(t) || t == BOOL) {
cl = ngpr < 6 ? INTEGER : INTMEM;
} else if (t == FLOAT || t == DOUBLE || t == FIMAG || t == IMAG) {
cl = nsse < 8 ? SSE : SSEMEM;
} else if (t == LDOUBLE || t == LIMAG) {
cl = X87; /* XXX */
} else if (t == STRTY || t == UNIONTY) {
int sz = (int)tsize(t, df, ap);
#ifdef GCC_COMPAT
if (attr_find(ap, GCC_ATYP_PACKED)) {
cl = STRMEM;
} else
#endif
if (iscplx87(strmemb(ap)) == STRX87) {
cl = STRX87;
} else if (sz > 2*SZLONG) {
cl = STRMEM;
} else {
if ((cl = flatten(t, strmemb(ap))) == STRMEM)
return STRMEM;
cl = cl2 = NO_CLASS;
for (i = 0; i < clp; i++) {
if (cla[i].off < SZLONG) {
if (cl == NO_CLASS || cl == STRSSE)
cl = cla[i].cl;
} else {
if (cl2 == NO_CLASS || cl2 == STRSSE)
cl2 = cla[i].cl;
}
}
if (cl == STRMEM || cl2 == STRMEM)
cl = STRMEM;
else if (cl == STRREG && cl2 == STRSSE)
cl = STRIF;
else if (cl2 == STRREG && cl == STRSSE)
cl = STRFI;
if (cl == STRREG && ngpr > 4)
cl = STRMEM;
else if (cl == STRSSE && nsse > 6)
cl = STRMEM;
else if ((cl == STRIF || cl == STRFI) &&
(ngpr > 5 || nsse > 7))
cl = STRMEM;
}
} else
cerror("FIXME: classify");
return cl;
}
/*
* Do the "hard work" in assigning correct destination for arguments.
* Also convert arguments < INT to inte (default argument promotions).
* XXX - should be dome elsewhere.
*/
static NODE *
argput(NODE *p)
{
NODE *q, *ql;
TWORD ty;
int typ, r, ssz, rn;
if (p->n_op == CM) {
p->n_left = argput(p->n_left);
p->n_right = argput(p->n_right);
return p;
}
/* first arg may be struct return pointer */
/* XXX - check if varargs; setup al */
switch (typ = argtyp(p->n_type, p->n_df, p->n_ap)) {
case INTEGER:
case SSE:
if (typ == SSE)
r = XMM0 + nsse++;
else
r = argregsi[ngpr++];
if (p->n_type < INT || p->n_type == BOOL)
p = cast(p, INT, 0);
p = movtoreg(p, r);
break;
case X87:
r = nrsp;
nrsp += SZLDOUBLE;
p = movtomem(p, r, STKREG);
break;
case SSEMEM:
r = nrsp;
nrsp += SZDOUBLE;
p = movtomem(p, r, STKREG);
break;
case INTMEM:
r = nrsp;
nrsp += SZLONG;
if (p->n_type < INT || p->n_type == BOOL)
p = cast(p, INT, 0);
p = movtomem(p, r, STKREG);
break;
case STRFI:
case STRIF:
case STRSSE:
case STRREG: /* Struct in registers */
/* Cast to long/sse pointer and move to the registers */
/* XXX can overrun struct size */
ssz = (int)tsize(p->n_type, p->n_df, p->n_ap);
if (typ == STRSSE || typ == STRFI) {
r = XMM0 + nsse++;
ty = DOUBLE;
} else {
r = argregsi[ngpr++];
ty = LONG;
}
p = nfree(p); /* remove STARG */
p = makety(p, PTR|ty, 0, 0, 0);
ql = tempnode(0, PTR|ty, 0, 0);
rn = regno(ql);
p = buildtree(ASSIGN, ql, p);
ql = tempnode(rn, PTR|ty, 0, 0);
ql = movtoreg(buildtree(UMUL, ql, NIL), r);
p = buildtree(COMOP, p, ql);
if (ssz > SZLONG) {
if (typ == STRSSE || typ == STRIF) {
r = XMM0 + nsse++;
ty = DOUBLE;
} else {
r = argregsi[ngpr++];
ty = LONG;
}
ql = tempnode(rn, PTR|ty, 0, 0);
ql = buildtree(UMUL, buildtree(PLUS, ql, bcon(1)), NIL);
ql = movtoreg(ql, r);
p = buildtree(CM, p, ql);
}
break;
case STRX87:
case STRMEM: {
struct symtab s;
NODE *l, *t;
q = buildtree(UMUL, p->n_left, NIL);
s.stype = p->n_type;
s.squal = 0;
s.sdf = p->n_df;
s.sap = p->n_ap;
s.soffset = nrsp;
s.sclass = AUTO;
nrsp += (int)tsize(p->n_type, p->n_df, p->n_ap);
l = block(REG, NIL, NIL, PTR+STRTY, 0, 0);
slval(l, 0);
regno(l) = STKREG;
t = block(NAME, NIL, NIL, p->n_type, p->n_df, p->n_ap);
t->n_sp = &s;
t = stref(block(STREF, l, t, 0, 0, 0));
t = (buildtree(ASSIGN, t, q));
nfree(p);
p = t->n_left;
nfree(t);
break;
}
default:
cerror("argument %d", typ);
}
return p;
}
/*
* Sort arglist so that register assignments ends up last.
*/
static int
argsort(NODE *p)
{
NODE *q, *r;
int rv = 0;
if (p->n_op != CM) {
if (p->n_op == ASSIGN && p->n_left->n_op == REG &&
coptype(p->n_right->n_op) != LTYPE) {
q = tempnode(0, p->n_type, p->n_df, p->n_ap);
r = ccopy(q);
p->n_right = buildtree(COMOP,
buildtree(ASSIGN, q, p->n_right), r);
}
return rv;
}
if (p->n_right->n_op == CM) {
/* fixup for small structs in regs */
q = p->n_right->n_left;
p->n_right->n_left = p->n_left;
p->n_left = p->n_right;
p->n_right = p->n_left->n_right;
p->n_left->n_right = q;
}
if (p->n_right->n_op == ASSIGN && p->n_right->n_left->n_op == REG &&
coptype(p->n_right->n_right->n_op) != LTYPE) {
/* move before everything to avoid reg trashing */
q = tempnode(0, p->n_right->n_type,
p->n_right->n_df, p->n_right->n_ap);
r = ccopy(q);
p->n_right->n_right = buildtree(COMOP,
buildtree(ASSIGN, q, p->n_right->n_right), r);
}
if (p->n_right->n_op == ASSIGN && p->n_right->n_left->n_op == REG) {
if (p->n_left->n_op == CM &&
p->n_left->n_right->n_op == STASG) {
q = p->n_left->n_right;
p->n_left->n_right = p->n_right;
p->n_right = q;
rv = 1;
} else if (p->n_left->n_op == STASG) {
q = p->n_left;
p->n_left = p->n_right;
p->n_right = q;
rv = 1;
}
}
return rv | argsort(p->n_left);
}
/*
* Called with a function call with arguments as argument.
* This is done early in buildtree() and only done once.
* Returns p.
*/
NODE *
funcode(NODE *p)
{
NODE *l, *r;
TWORD t;
int i;
nsse = ngpr = nrsp = 0;
/* Check if hidden arg needed */
/* If so, add it in pass2 */
if ((l = p->n_left)->n_type == INCREF(FTN)+STRTY ||
l->n_type == INCREF(FTN)+UNIONTY) {
OFFSZ ssz = tsize(BTYPE(l->n_type), l->n_df, l->n_ap);
struct symtab *sp = strmemb(l->n_ap);
if (ssz == 2*SZLDOUBLE && sp->stype == LDOUBLE &&
sp->snext->stype == LDOUBLE)
; /* long complex struct */
else if (ssz > 2*SZLONG)
ngpr++;
}
/* Convert just regs to assign insn's */
p->n_right = argput(p->n_right);
/* Must sort arglist so that STASG ends up first */
/* This avoids registers being clobbered */
while (argsort(p->n_right))
;
/* Check if there are varargs */
if (nsse || l->n_df == NULL || l->n_df->dfun == NULL) {
; /* Need RAX */
} else {
union arglist *al = l->n_df->dfun;
for (; al->type != TELLIPSIS; al++) {
if ((t = al->type) == TNULL)
return p; /* No need */
if (ISSOU(BTYPE(t)))
al++;
for (i = 0; t > BTMASK; t = DECREF(t))
if (ISARY(t) || ISFTN(t))
i++;
if (i)
al++;
}
}
/* Always emit number of SSE regs used */
l = movtoreg(bcon(nsse), RAX);
if (p->n_right->n_op != CM) {
p->n_right = block(CM, l, p->n_right, INT, 0, 0);
} else {
for (r = p->n_right; r->n_left->n_op == CM; r = r->n_left)
;
r->n_left = block(CM, l, r->n_left, INT, 0, 0);
}
return p;
}
/* fix up type of field p */
void
fldty(struct symtab *p)
{
}
/*
* XXX - fix genswitch.
*/
int
mygenswitch(int num, TWORD type, struct swents **p, int n)
{
return 0;
}
/*
* Return return as given by a.
*/
NODE *
builtin_return_address(const struct bitable *bt, NODE *a)
{
int nframes;
NODE *f;
nframes = (int)glval(a);
tfree(a);
f = block(REG, NIL, NIL, PTR+VOID, 0, 0);
regno(f) = FPREG;
while (nframes--)
f = block(UMUL, f, NIL, PTR+VOID, 0, 0);
f = block(PLUS, f, bcon(8), INCREF(PTR+VOID), 0, 0);
f = buildtree(UMUL, f, NIL);
return f;
}
/*
* Return frame as given by a.
*/
NODE *
builtin_frame_address(const struct bitable *bt, NODE *a)
{
int nframes;
NODE *f;
nframes = (int)glval(a);
tfree(a);
f = block(REG, NIL, NIL, PTR+VOID, 0, 0);
regno(f) = FPREG;
while (nframes--)
f = block(UMUL, f, NIL, PTR+VOID, 0, 0);
return f;
}
/*
* Return "canonical frame address".
*/
NODE *
builtin_cfa(const struct bitable *bt, NODE *a)
{
NODE *f;
f = block(REG, NIL, NIL, PTR+VOID, 0, 0);
regno(f) = FPREG;
return block(PLUS, f, bcon(16), INCREF(PTR+VOID), 0, 0);
}
int codeatyp(NODE *);
int
codeatyp(NODE *p)
{
TWORD t;
int typ;
ngpr = nsse = 0;
t = DECREF(p->n_type);
if (ISSOU(t) == 0) {
p = p->n_left;
t = DECREF(DECREF(p->n_type));
}
if (ISSOU(t) == 0)
cerror("codeatyp");
typ = argtyp(t, p->n_df, p->n_ap);
return typ;
}
| 23.35773 | 76 | 0.601707 |
7b3d9e0579daee7563641eeeef02c5bc6d8868ff | 5,500 | c | C | src/STE/ECS/Components/RenderableFunctions.c | silenttowergames/stonetowerenginw | f47977d864f177cb06e681c50c6120c5a630115d | [
"0BSD"
] | 7 | 2020-08-20T17:02:01.000Z | 2022-03-25T13:50:40.000Z | src/STE/ECS/Components/RenderableFunctions.c | silenttowergames/stonetowerenginw | f47977d864f177cb06e681c50c6120c5a630115d | [
"0BSD"
] | 23 | 2020-09-17T22:15:38.000Z | 2021-04-17T16:31:01.000Z | src/STE/ECS/Components/RenderableFunctions.c | silenttowergames/stonetowerengine | f47977d864f177cb06e681c50c6120c5a630115d | [
"0BSD"
] | null | null | null | #include <math.h>
#include "RenderableFunctions.h"
#include "../../Application/ApplicationState.h"
#include "../../Assets/FontStashFNA3D.h"
#include "../../Assets/TiledJSONFunctions.h"
#include "../../Rendering/SpriteBatchFunctions.h"
#include "../../Utilities/quadFunctions.h"
quad Renderable_Sprite_GetPosQuad(Renderable* renderable, float2d position)
{
return quad_Easy(
position.X,
position.Y,
renderable->texture->tilesize.X * renderable->scale.X,
renderable->texture->tilesize.Y * renderable->scale.Y,
renderable->offset.X * renderable->scale.X,
renderable->offset.Y * renderable->scale.Y,
renderable->rotation
);
}
void Renderable_Sprite_Render(ApplicationState* app, SpriteBatch* spriteBatch, Camera* camera, void* _renderable, float2d position)
{
Renderable* renderable = (Renderable*)_renderable;
float2d _position = position;
_position.X += (camera->position.X * (1 - renderable->parallax));
_position.Y += (camera->position.Y * (1 - renderable->parallax));
quad pos = Renderable_Sprite_GetPosQuad(renderable, _position);
quad src = quad_Frame(renderable->texture, renderable->frame.X, renderable->frame.Y);
if(renderable->flipX || renderable->flipY)
{
float swap;
if(renderable->flipX)
{
swap = src.topLeft.X;
src.topLeft.X = src.topRight.X;
src.bottomLeft.X = src.bottomRight.X;
src.topRight.X = swap;
src.bottomRight.X = swap;
}
if(renderable->flipY)
{
swap = src.topLeft.Y;
src.topLeft.Y = src.bottomLeft.Y;
src.topRight.Y = src.bottomRight.Y;
src.bottomLeft.Y = swap;
src.bottomRight.Y = swap;
}
}
SpriteBatch_AddQuad(app, spriteBatch, camera, renderable->texture->asset, pos, src, renderable->color);
}
void Renderable_TextBox_Render(ApplicationState* app, SpriteBatch* spriteBatch, Camera* camera, void* _renderable, float2d position)
{
Renderable* renderable = (Renderable*)_renderable;
float2d _position = position;
_position.X += (camera->position.X * (1 - renderable->parallax));
_position.Y += (camera->position.Y * (1 - renderable->parallax));
const char* message = (const char*)renderable->data;
if(message == NULL || strlen(message) == 0)
{
renderable->duration = 0;
}
renderable->duration++;
FontStashFNA3D* fna = (FontStashFNA3D*)app->fons->params.userPtr;
fna->renderable = renderable;
fonsSetFont(app->fons, renderable->scale.X);
fonsSetSize(app->fons, renderable->scale.Y);
fonsSetColor(app->fons, renderable->color);
fonsDrawText(app->fons, _position.X, _position.Y, message, NULL);
}
void Renderable_Tilemap_Render(ApplicationState* app, SpriteBatch* spriteBatch, Camera* camera, void* _renderable, float2d position)
{
Renderable* renderable = (Renderable*)_renderable;
if(renderable == NULL)
{
return;
}
TiledJSONLayer* tilemap = (TiledJSONLayer*)renderable->data;
if(
tilemap == NULL
||
strcmp(tilemap->type, "tilelayer") != 0
)
{
return;
}
quad pos;
quad src;
int index;
int tile;
int2d frame;
int Left = ((camera->position.X - position.X - (camera->resolution.X / 2)) / renderable->texture->tilesize.X) + 1;
int Top = ((camera->position.Y - position.Y - (camera->resolution.Y / 2)) / renderable->texture->tilesize.Y) + 1;
int Right = ((camera->position.X - position.X + (camera->resolution.X / 2)) / renderable->texture->tilesize.X) + 2;
int Bottom = ((camera->position.Y - position.Y + (camera->resolution.Y / 2)) / renderable->texture->tilesize.Y) + 2;
for(int Y = fmax(0, Top); Y < Bottom; Y++)
{
if(Y >= tilemap->size.Y)
{
break;
}
for(int X = fmax(0, Left); X < Right; X++)
{
if(X >= tilemap->size.X)
{
break;
}
index = (Y * tilemap->size.X) + X;
if(tilemap->tiles[index] == 0)
{
continue;
}
tile = tilemap->tiles[index] - 1;
frame.X = tile % (renderable->texture->size.X / renderable->texture->tilesize.X);
frame.Y = floor(tile / (renderable->texture->size.X / renderable->texture->tilesize.X));
pos = quad_Easy(
position.X + (X * renderable->texture->tilesize.X * renderable->scale.X),
position.Y + (Y * renderable->texture->tilesize.Y * renderable->scale.Y),
renderable->texture->tilesize.X * renderable->scale.X,
renderable->texture->tilesize.Y * renderable->scale.Y,
renderable->offset.X,
renderable->offset.Y,
0
);
src = quad_Frame(renderable->texture, frame.X, frame.Y);
SpriteBatch_AddQuad(app, spriteBatch, camera, renderable->texture->asset, pos, src, renderable->color);
}
}
}
void Renderable_Box_Render(ApplicationState* app, SpriteBatch* spriteBatch, Camera* camera, void* _renderable, float2d position)
{
Renderable* renderable = (Renderable*)_renderable;
float2d _position = position;
_position.X += (camera->position.X * (1 - renderable->parallax));
_position.Y += (camera->position.Y * (1 - renderable->parallax));
quad pos = {
{ _position.X - (renderable->scale.X / 2), _position.Y - (renderable->scale.Y / 2), },
{ _position.X + (renderable->scale.X / 2), _position.Y - (renderable->scale.Y / 2), },
{ _position.X - (renderable->scale.X / 2), _position.Y + (renderable->scale.Y / 2), },
{ _position.X + (renderable->scale.X / 2), _position.Y + (renderable->scale.Y / 2), },
};
quad src = {
{ 0, 0, },
{ 1, 0, },
{ 0, 1, },
{ 1, 1, },
};
SpriteBatch_AddQuad(app, spriteBatch, camera, app->renderState.blankTexture.asset, pos, src, renderable->color);
}
| 29.569892 | 132 | 0.663636 |
72c18e84d5ceb1d29bf80f4c2ad7d04759a8c69e | 1,285 | h | C | common/event_log.h | eLong-INF/pyxis | 304820eb72bd62d3c211c3423f62dc87b535bb3c | [
"BSD-3-Clause"
] | 9 | 2016-07-21T01:45:17.000Z | 2016-08-26T03:20:25.000Z | common/event_log.h | eLong-opensource/pyxis | 304820eb72bd62d3c211c3423f62dc87b535bb3c | [
"BSD-3-Clause"
] | null | null | null | common/event_log.h | eLong-opensource/pyxis | 304820eb72bd62d3c211c3423f62dc87b535bb3c | [
"BSD-3-Clause"
] | null | null | null | #ifndef PYXIS_SERVER_EVENT_LOG_H
#define PYXIS_SERVER_EVENT_LOG_H
#include <string>
#include <toft/base/string/string_piece.h>
#include <stdio.h>
#include <time.h>
#include <muduo/base/Mutex.h>
#include <pyxis/server/proc_db.h>
#include <pyxis/common/types.h>
namespace pyxis {
namespace watch {
class Event;
}
}
namespace pyxis {
namespace rpc {
class Request;
class Response;
}
}
namespace pyxis {
class EventLog
{
public:
EventLog(time_t flushInterval = 3);
~EventLog();
void SetLogFile(const std::string& p);
void Reload();
// 用于切割日志文件
Status OnProcWrite(const store::ProcDB::ArgList& args,
const std::string& value);
void LogWatch(sid_t sid, const watch::Event& e);
void LogRpc(const std::string& addr, rpc::Request* req, rpc::Response* rep, double used);
void LogSession(sid_t sid, toft::StringPiece what);
void Log(toft::StringPiece addr, toft::StringPiece event,
sid_t sid, uint64_t xid, toft::StringPiece param,
toft::StringPiece err, double used);
private:
void getActionAndNode(const rpc::Request* e, std::string* action,
std::string* node);
std::string logFilePath_;
FILE* fp_;
time_t flushInterval_;
time_t lastflush_;
muduo::MutexLock mutex_;
};
}
#endif
| 19.769231 | 91 | 0.690272 |
a73a6f53756daf8df8b5f3f87a38d32d0ebde1af | 39,778 | c | C | src/parser.c | jaredtking/cs4013-4 | 487384036392f2627f0334962e4ec1fdbef0f1c0 | [
"MIT"
] | 1 | 2015-03-22T17:18:49.000Z | 2015-03-22T17:18:49.000Z | src/parser.c | jaredtking/cs4013-4 | 487384036392f2627f0334962e4ec1fdbef0f1c0 | [
"MIT"
] | null | null | null | src/parser.c | jaredtking/cs4013-4 | 487384036392f2627f0334962e4ec1fdbef0f1c0 | [
"MIT"
] | null | null | null | #include "parser.h"
void parse(ParserData *parser_data)
{
parse_program(parser_data);
match(TOKEN_EOF, parser_data);
// output symbol table
fprint_symbol_table(parser_data->symbols, parser_data->symbol_table);
}
struct MachineResult *match(TokenType t, ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NONE);
if (tok->token->type == t) {
if (t == TOKEN_EOF) {
// END
} else {
// NOP
}
return tok;
} else {
synerr((TokenType[]){t}, 1, tok, parser_data);
return NULL;
}
}
void parse_program(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
MachineResult *idptr;
int doSynch = 0;
switch (tok->token->type) {
case TOKEN_PROGRAM:
if (match(TOKEN_PROGRAM, parser_data) == NULL) { doSynch = 1; break; }
idptr = match(TOKEN_ID, parser_data);
if (idptr == NULL) { doSynch = 1; break; }
check_enter_method(idptr->lexeme, parser_data);
if (match(TOKEN_LPAREN, parser_data) == NULL) { doSynch = 1; break; }
parse_id_list(parser_data);
if (match(TOKEN_RPAREN, parser_data) == NULL) { doSynch = 1; break; }
if (match(TOKEN_SEMICOLON, parser_data) == NULL) { doSynch = 1; break; }
parse_program_(parser_data);
check_exit_method(parser_data);
break;
default:
synerr((TokenType[]){TOKEN_PROGRAM}, 1, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_PROGRAM, tok, parser_data);
}
void parse_program_(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
int doSynch = 0;
switch (tok->token->type) {
case TOKEN_VAR:
parse_declarations(parser_data);
parse_program__(parser_data);
break;
case TOKEN_FUNCTION:
parse_subprogram_declarations(parser_data);
parse_compound_statement(parser_data);
if (match(TOKEN_PERIOD, parser_data) == NULL) { doSynch = 1; break; }
break;
case TOKEN_BEGIN:
parse_compound_statement(parser_data);
if (match(TOKEN_PERIOD, parser_data) == NULL) { doSynch = 1; break; }
break;
default:
synerr((TokenType[]){TOKEN_VAR,TOKEN_FUNCTION,TOKEN_BEGIN}, 3, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_PROGRAM_, tok, parser_data);
}
void parse_program__(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
int doSynch = 0;
switch (tok->token->type) {
case TOKEN_FUNCTION:
parse_subprogram_declarations(parser_data);
parse_compound_statement(parser_data);
if (match(TOKEN_PERIOD, parser_data) == NULL) { doSynch = 1; break; }
break;
case TOKEN_BEGIN:
parse_compound_statement(parser_data);
if (match(TOKEN_PERIOD, parser_data) == NULL) { doSynch = 1; break; }
break;
default:
synerr((TokenType[]){TOKEN_FUNCTION,TOKEN_BEGIN}, 2, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_PROGRAM__, tok, parser_data);
}
void parse_id_list(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
MachineResult *idptr;
int doSynch = 0;
switch (tok->token->type) {
case TOKEN_ID:
idptr = match(TOKEN_ID, parser_data);
if (idptr == NULL) { doSynch = 1; break; }
check_add_prog_param(idptr->lexeme, parser_data);
parse_id_list_(parser_data);
break;
default:
synerr((TokenType[]){TOKEN_ID}, 1, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_ID_LIST, tok, parser_data);
}
void parse_id_list_(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
MachineResult *idptr;
int doSynch = 0;
switch (tok->token->type) {
case TOKEN_COMMA:
if (match(TOKEN_COMMA, parser_data) == NULL) { doSynch = 1; break; }
idptr = match(TOKEN_ID, parser_data);
if (idptr == NULL) { doSynch = 1; break; }
check_add_prog_param(idptr->lexeme, parser_data);
parse_id_list_(parser_data);
break;
case TOKEN_RPAREN:
// NOP
break;
default:
synerr((TokenType[]){TOKEN_COMMA,TOKEN_RPAREN}, 2, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_ID_LIST_, tok, parser_data);
}
void parse_declarations(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
MachineResult *idptr;
int doSynch = 0;
switch (tok->token->type) {
case TOKEN_VAR:
if (match(TOKEN_VAR, parser_data) == NULL) { doSynch = 1; break; }
idptr = match(TOKEN_ID, parser_data);
if (idptr == NULL) { doSynch = 1; break; }
if (match(TOKEN_COLON, parser_data) == NULL) { doSynch = 1; break; }
Attributes t = parse_type(parser_data);
check_add_var(idptr->lexeme, t, parser_data);
if (match(TOKEN_SEMICOLON, parser_data) == NULL) { doSynch = 1; break; }
parse_declarations_(parser_data);
break;
default:
synerr((TokenType[]){TOKEN_VAR}, 1, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_DECLARATIONS, tok, parser_data);
}
void parse_declarations_(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
MachineResult *idptr;
int doSynch = 0;
switch (tok->token->type) {
case TOKEN_VAR:
if (match(TOKEN_VAR, parser_data) == NULL) { doSynch = 1; break; }
idptr = match(TOKEN_ID, parser_data);
if (idptr == NULL) { doSynch = 1; break; }
if (match(TOKEN_COLON, parser_data) == NULL) { doSynch = 1; break; }
Attributes t = parse_type(parser_data);
check_add_var(idptr->lexeme, t, parser_data);
if (match(TOKEN_SEMICOLON, parser_data) == NULL) { doSynch = 1; break; }
parse_declarations_(parser_data);
break;
case TOKEN_FUNCTION:
case TOKEN_BEGIN:
// NOP
break;
default:
synerr((TokenType[]){TOKEN_VAR, TOKEN_FUNCTION, TOKEN_BEGIN}, 3, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_DECLARATIONS_, tok, parser_data);
}
struct Attributes parse_type(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
Attributes t = ATTRIBUTES_DEFAULT, st = ATTRIBUTES_DEFAULT;
int doSynch = 0;
switch (tok->token->type) {
case TOKEN_ARRAY:
if (match(TOKEN_ARRAY, parser_data) == NULL) { doSynch = 1; break; }
if (match(TOKEN_LBRACKET, parser_data) == NULL) { doSynch = 1; break; }
MachineResult *num1 = match(TOKEN_NUM, parser_data);
if (num1 == NULL) { doSynch = 1; break; }
if (match(TOKEN_PERIOD, parser_data) == NULL) { doSynch = 1; break; }
if (match(TOKEN_PERIOD, parser_data) == NULL) { doSynch = 1; break; }
MachineResult *num2 = match(TOKEN_NUM, parser_data);
if (num2 == NULL) { doSynch = 1; break; }
if (match(TOKEN_RBRACKET, parser_data) == NULL) { doSynch = 1; break; }
if (match(TOKEN_OF, parser_data) == NULL) { doSynch = 1; break; }
st = parse_std_type(parser_data);
if (num1->token->attribute != ATTRIBUTE_INT || num2->token->attribute != ATTRIBUTE_INT) {
semerr("Array bounds must be ints", tok->line_no, parser_data);
t.t.std_type = ERR;
} else {
if(st.t.std_type == INT) t.t.std_type = AINT;
if(st.t.std_type == REAL) t.t.std_type = AREAL;
t.t.start = num1->intval;
t.t.end = num2->intval;
if (t.t.start > t.t.end) {
semerr("Array bounds not valid", tok->line_no, parser_data);
t.t.std_type = ERR;
}
}
break;
case TOKEN_INTEGER:
case TOKEN_REAL:
st = parse_std_type(parser_data);
t.t = st.t;
break;
default:
synerr((TokenType[]){TOKEN_INTEGER, TOKEN_REAL, TOKEN_ARRAY}, 3, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_TYPE, tok, parser_data);
return t;
}
struct Attributes parse_std_type(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
Attributes st = ATTRIBUTES_DEFAULT;
int doSynch = 0;
switch (tok->token->type) {
case TOKEN_INTEGER:
if (match(TOKEN_INTEGER, parser_data) == NULL) { doSynch = 1; break; }
st.t.std_type = INT;
break;
case TOKEN_REAL:
if (match(TOKEN_REAL, parser_data) == NULL) { doSynch = 1; break; }
st.t.std_type = REAL;
break;
default:
synerr((TokenType[]){TOKEN_INTEGER, TOKEN_REAL}, 2, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_STD_TYPE, tok, parser_data);
return st;
}
void parse_subprogram_declarations(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
int doSynch = 0;
switch (tok->token->type) {
case TOKEN_FUNCTION:
parse_subprogram_declaration(parser_data);
if (match(TOKEN_SEMICOLON, parser_data) == NULL) { doSynch = 1; break; }
parse_subprogram_declarations_(parser_data);
break;
default:
synerr((TokenType[]){TOKEN_FUNCTION}, 1, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_SUBPROGRAM_DECLARATIONS, tok, parser_data);
}
void parse_subprogram_declarations_(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
int doSynch = 0;
switch (tok->token->type) {
case TOKEN_FUNCTION:
parse_subprogram_declaration(parser_data);
if (match(TOKEN_SEMICOLON, parser_data) == NULL) { doSynch = 1; break; }
parse_subprogram_declarations_(parser_data);
break;
case TOKEN_BEGIN:
// NOP
break;
default:
synerr((TokenType[]){TOKEN_FUNCTION,TOKEN_BEGIN}, 2, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_SUBPROGRAM_DECLARATIONS_, tok, parser_data);
}
void parse_subprogram_declaration(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
switch (tok->token->type) {
case TOKEN_FUNCTION:
parse_subprogram_head(parser_data);
parse_subprogram_declaration_(parser_data);
check_exit_method(parser_data);
break;
default:
synerr((TokenType[]){TOKEN_FUNCTION}, 1, tok, parser_data);
synch(PRODUCTION_SUBPROGRAM_DECLARATION, tok, parser_data);
break;
}
}
void parse_subprogram_declaration_(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
switch (tok->token->type) {
case TOKEN_VAR:
parse_declarations(parser_data);
parse_subprogram_declaration__(parser_data);
break;
case TOKEN_FUNCTION:
parse_subprogram_declarations(parser_data);
parse_compound_statement(parser_data);
break;
case TOKEN_BEGIN:
parse_compound_statement(parser_data);
break;
default:
synerr((TokenType[]){TOKEN_VAR,TOKEN_FUNCTION,TOKEN_BEGIN}, 3, tok, parser_data);
synch(PRODUCTION_SUBPROGRAM_DECLARATION_, tok, parser_data);
break;
}
}
void parse_subprogram_declaration__(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
switch (tok->token->type) {
case TOKEN_FUNCTION:
parse_subprogram_declarations(parser_data);
parse_compound_statement(parser_data);
break;
case TOKEN_BEGIN:
parse_compound_statement(parser_data);
break;
default:
synerr((TokenType[]){TOKEN_FUNCTION,TOKEN_BEGIN}, 2, tok, parser_data);
synch(PRODUCTION_SUBPROGRAM_DECLARATION__, tok, parser_data);
break;
}
}
void parse_subprogram_head(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
MachineResult *idptr;
int doSynch = 0;
Attributes sh_ = ATTRIBUTES_DEFAULT;
switch (tok->token->type) {
case TOKEN_FUNCTION:
if (match(TOKEN_FUNCTION, parser_data) == NULL) { doSynch = 1; break; }
idptr = match(TOKEN_ID, parser_data);
if (idptr == NULL) { doSynch = 1; break; }
check_enter_method(idptr->lexeme, parser_data);
sh_ = parse_subprogram_head_(parser_data);
set_method_type(sh_.t, parser_data);
set_method_param_count(sh_.c, parser_data);
break;
default:
synerr((TokenType[]){TOKEN_FUNCTION}, 1, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_SUBPROGRAM_HEAD, tok, parser_data);
}
struct Attributes parse_subprogram_head_(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
int doSynch = 0;
Attributes sh_ = ATTRIBUTES_DEFAULT, a = ATTRIBUTES_DEFAULT, st = ATTRIBUTES_DEFAULT;
switch (tok->token->type) {
case TOKEN_LPAREN:
a = parse_arguments(parser_data);
sh_.c = a.c;
if (match(TOKEN_COLON, parser_data) == NULL) { doSynch = 1; break; }
st = parse_std_type(parser_data);
sh_.t = st.t;
if (match(TOKEN_SEMICOLON, parser_data) == NULL) { doSynch = 1; break; }
break;
case TOKEN_COLON:
sh_.c = 0;
if (match(TOKEN_COLON, parser_data) == NULL) { doSynch = 1; break; }
st = parse_std_type(parser_data);
sh_.t = st.t;
if (match(TOKEN_SEMICOLON, parser_data) == NULL) { doSynch = 1; break; }
break;
default:
synerr((TokenType[]){TOKEN_LPAREN,TOKEN_COLON}, 2, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_SUBPROGRAM_HEAD_, tok, parser_data);
return sh_;
}
struct Attributes parse_arguments(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
Attributes a = ATTRIBUTES_DEFAULT, pl = ATTRIBUTES_DEFAULT;
int doSynch = 0;
switch (tok->token->type) {
case TOKEN_LPAREN:
if (match(TOKEN_LPAREN, parser_data) == NULL) { doSynch = 1; break; }
pl = parse_param_list(parser_data);
a.c = pl.c;
if (match(TOKEN_RPAREN, parser_data) == NULL) { doSynch = 1; break; }
break;
default:
synerr((TokenType[]){TOKEN_LPAREN}, 1, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_ARGUMENTS, tok, parser_data);
return a;
}
struct Attributes parse_param_list(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
MachineResult *idptr;
int doSynch = 0;
Attributes pl = ATTRIBUTES_DEFAULT, t = ATTRIBUTES_DEFAULT, pl_ = ATTRIBUTES_DEFAULT;
switch (tok->token->type) {
case TOKEN_ID:
idptr = match(TOKEN_ID, parser_data);
if (idptr == NULL) { doSynch = 1; break; }
if (match(TOKEN_COLON, parser_data) == NULL) { doSynch = 1; break; }
t = parse_type(parser_data);
check_add_fun_param(idptr->lexeme, t, parser_data);
pl_.c = 1;
parse_param_list_(parser_data, &pl_);
pl.c = pl_.c;
break;
default:
synerr((TokenType[]){TOKEN_ID}, 1, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_PARAM_LIST, tok, parser_data);
return pl;
}
void parse_param_list_(ParserData *parser_data, struct Attributes *pl_)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
MachineResult *idptr;
int doSynch = 0;
Attributes t = ATTRIBUTES_DEFAULT, pl1_ = ATTRIBUTES_DEFAULT;
switch (tok->token->type) {
case TOKEN_SEMICOLON:
if (match(TOKEN_SEMICOLON, parser_data) == NULL) { doSynch = 1; break; }
idptr = match(TOKEN_ID, parser_data);
if (idptr == NULL) { doSynch = 1; break; }
if (match(TOKEN_COLON, parser_data) == NULL) { doSynch = 1; break; }
t = parse_type(parser_data);
check_add_fun_param(idptr->lexeme, t, parser_data);
pl1_.c = pl_->c + 1;
parse_param_list_(parser_data, &pl1_);
pl_->c = pl1_.c;
break;
case TOKEN_RPAREN:
// NOP
break;
default:
synerr((TokenType[]){TOKEN_COLON,TOKEN_RPAREN}, 2, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_PARAM_LIST_, tok, parser_data);
}
void parse_compound_statement(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
int doSynch = 0;
switch (tok->token->type) {
case TOKEN_BEGIN:
if (match(TOKEN_BEGIN, parser_data) == NULL) { doSynch = 1; break; }
parse_compound_statement_(parser_data);
break;
default:
synerr((TokenType[]){TOKEN_BEGIN}, 1, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_COMPOUND_STATEMENT, tok, parser_data);
}
void parse_compound_statement_(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
int doSynch = 0;
switch (tok->token->type) {
case TOKEN_ID:
case TOKEN_BEGIN:
case TOKEN_IF:
case TOKEN_WHILE:
parse_optional_statements(parser_data);
case TOKEN_END:
if (match(TOKEN_END, parser_data) == NULL) { doSynch = 1; break; }
break;
default:
synerr((TokenType[]){TOKEN_ID,TOKEN_BEGIN,TOKEN_IF,TOKEN_WHILE,TOKEN_END}, 5, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_COMPOUND_STATEMENT_, tok, parser_data);
}
void parse_optional_statements(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
switch (tok->token->type) {
case TOKEN_ID:
case TOKEN_BEGIN:
case TOKEN_IF:
case TOKEN_WHILE:
parse_statement_list(parser_data);
break;
default:
synerr((TokenType[]){TOKEN_ID,TOKEN_BEGIN,TOKEN_IF,TOKEN_WHILE}, 4, tok, parser_data);
synch(PRODUCTION_OPTIONAL_STATEMENTS, tok, parser_data);
break;
}
}
void parse_statement_list(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
switch (tok->token->type) {
case TOKEN_ID:
case TOKEN_BEGIN:
case TOKEN_IF:
case TOKEN_WHILE:
parse_statement(parser_data);
parse_statement_list_(parser_data);
break;
default:
synerr((TokenType[]){TOKEN_ID,TOKEN_BEGIN,TOKEN_IF,TOKEN_WHILE}, 4, tok, parser_data);
synch(PRODUCTION_STATEMENT_LIST, tok, parser_data);
break;
}
}
void parse_statement_list_(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
int doSynch = 0;
switch (tok->token->type) {
case TOKEN_SEMICOLON:
if (match(TOKEN_SEMICOLON, parser_data) == NULL) { doSynch = 1; break; }
parse_statement(parser_data);
parse_statement_list_(parser_data);
break;
case TOKEN_END:
// NOP
break;
default:
synerr((TokenType[]){TOKEN_SEMICOLON,TOKEN_END}, 2, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_STATEMENT_LIST_, tok, parser_data);
}
struct Attributes parse_statement(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
int doSynch = 0;
Attributes s = ATTRIBUTES_DEFAULT, v = ATTRIBUTES_DEFAULT, e = ATTRIBUTES_DEFAULT;
switch (tok->token->type) {
case TOKEN_ID:
v = parse_var(parser_data);
if (match(TOKEN_ASSIGNOP, parser_data) == NULL) { doSynch = 1; break; }
e = parse_expr(parser_data);
if (types_equal(v.t, e.t, 0) && (v.t.std_type == INT || v.t.std_type == REAL) && e.t.fun == 0)
s.t = v.t;
else {
char *err_str = (char *)malloc(200);
sprintf(err_str, "Mismatched type for assignment. Tried to assign %s to %s for symbol \"%s\"", type_to_str(e.t), type_to_str(v.t), v.idptr);
semerr(err_str, tok->line_no, parser_data);
s.t.std_type = ERR;
}
break;
case TOKEN_BEGIN:
parse_compound_statement(parser_data);
break;
case TOKEN_IF:
if (match(TOKEN_IF, parser_data) == NULL) { doSynch = 1; break; }
e = parse_expr(parser_data);
if (e.t.std_type != BOOL) {
semerr("If condition must be a bool", tok->line_no, parser_data);
s.t.std_type = ERR;
}
if (match(TOKEN_THEN, parser_data) == NULL) { doSynch = 1; break; }
parse_statement(parser_data);
parse_statement_(parser_data);
break;
case TOKEN_WHILE:
if (match(TOKEN_WHILE, parser_data) == NULL) { doSynch = 1; break; }
e = parse_expr(parser_data);
if (e.t.std_type != BOOL) {
semerr("While condition must be a bool", tok->line_no, parser_data);
s.t.std_type = ERR;
}
if (match(TOKEN_DO, parser_data) == NULL) { doSynch = 1; break; }
parse_statement(parser_data);
break;
default:
synerr((TokenType[]){TOKEN_ID,TOKEN_BEGIN,TOKEN_IF,TOKEN_WHILE}, 4, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_STATEMENT, tok, parser_data);
return s;
}
void parse_statement_(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
switch (tok->token->type) {
case TOKEN_ELSE:
tok = get_next_token(parser_data, TOKEN_OPTION_NONE);
if (tok->token->type == TOKEN_ELSE) {
parse_statement(parser_data);
} else {
// NOP
}
break;
case TOKEN_SEMICOLON:
case TOKEN_END:
// NOP
break;
default:
synerr((TokenType[]){TOKEN_ELSE,TOKEN_SEMICOLON,TOKEN_END}, 4, tok, parser_data);
synch(PRODUCTION_STATEMENT_, tok, parser_data);
break;
}
}
struct Attributes parse_var(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
MachineResult *idptr;
int doSynch = 0;
Attributes v = ATTRIBUTES_DEFAULT, v_ = ATTRIBUTES_DEFAULT;
switch (tok->token->type) {
case TOKEN_ID:
idptr = match(TOKEN_ID, parser_data);
if (idptr == NULL) { doSynch = 1; break; }
Type idtype = get_type(idptr->lexeme, parser_data);
if (idtype.std_type == NONE) {
char *err_str = (char *)malloc(250);
sprintf(err_str, "Undefined symbol \"%s\"", idptr->lexeme);
semerr(err_str, tok->line_no, parser_data);
v_.in.std_type = ERR;
} else
v_.in = idtype;
v.idptr = idptr->lexeme;
parse_var_(parser_data, &v_);
v.t = v_.t;
break;
default:
synerr((TokenType[]){TOKEN_ID}, 1, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_VAR, tok, parser_data);
return v;
}
void parse_var_(ParserData *parser_data, struct Attributes *v_)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
int doSynch = 0;
Attributes e = ATTRIBUTES_DEFAULT;
switch (tok->token->type) {
case TOKEN_LBRACKET:
if (match(TOKEN_LBRACKET, parser_data) == NULL) { doSynch = 1; break; }
e = parse_expr(parser_data);
if (v_->in.std_type == AINT || v_->in.std_type == AREAL) {
if (e.t.std_type == INT) {
if (v_->in.std_type == AINT) v_->t.std_type = INT;
if (v_->in.std_type == AREAL) v_->t.std_type = REAL;
} else {
semerr("Array index must be integer", tok->line_no, parser_data);
v_->t.std_type = ERR;
}
} else {
semerr("Symbol must be an array", tok->line_no, parser_data);
v_->t.std_type = ERR;
}
if (match(TOKEN_RBRACKET, parser_data) == NULL) { doSynch = 1; break; }
break;
case TOKEN_ASSIGNOP:
// NOP
v_->t = v_->in;
break;
default:
synerr((TokenType[]){TOKEN_LBRACKET,TOKEN_ASSIGNOP}, 2, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_VAR_, tok, parser_data);
}
void parse_expr_list(ParserData *parser_data, struct Attributes *el)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
Attributes e = ATTRIBUTES_DEFAULT, el_ = ATTRIBUTES_DEFAULT;
char *idptr = el->idptr;
int expected_count = get_num_params(idptr, parser_data);
Type expected_type = get_param_type(idptr, 0, parser_data);
switch (tok->token->type) {
case TOKEN_ID:
case TOKEN_NUM:
case TOKEN_LPAREN:
case TOKEN_NOT:
case TOKEN_ADDOP:
e = parse_expr(parser_data);
if (el->in.std_type == ERR)
el_.in.std_type = ERR;
else if (expected_count < 1) {
char *err_str = (char *)malloc(250);
sprintf(err_str, "Number of arguments do not match for function \"%s\": expecting %d, given %d", idptr, expected_count, 1);
semerr(err_str, tok->line_no, parser_data);
el_.in.std_type = ERR;
} else if (types_equal(expected_type, e.t, 1) == 0) {
char *err_str = (char *)malloc(250);
sprintf(err_str, "Argument type mismatch for function \"%s\" on arg 1: expecting %s, given %s", idptr, type_to_str(expected_type), type_to_str(e.t));
semerr(err_str, tok->line_no, parser_data);
el_.in.std_type = ERR;
} else
el_.c = 1;
el_.idptr = idptr;
parse_expr_list_(parser_data, &el_);
break;
default:
synerr((TokenType[]){TOKEN_ID,TOKEN_NUM,TOKEN_LPAREN,TOKEN_NOT,TOKEN_ADDOP}, 5, tok, parser_data);
synch(PRODUCTION_EXPR_LIST, tok, parser_data);
break;
}
}
void parse_expr_list_(ParserData *parser_data, struct Attributes *el_)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
int doSynch = 0;
Attributes el1_ = ATTRIBUTES_DEFAULT, e = ATTRIBUTES_DEFAULT;
char *idptr = el_->idptr;
int expected_count = get_num_params(idptr, parser_data);
Type expected_type = get_param_type(idptr, el_->c, parser_data);
switch (tok->token->type) {
case TOKEN_COMMA:
if (match(TOKEN_COMMA, parser_data) == NULL) { doSynch = 1; break; }
e = parse_expr(parser_data);
if (el_->in.std_type == ERR)
el1_.in.std_type = ERR;
else if (expected_count < el_->c + 1) {
char *err_str = (char *)malloc(250);
sprintf(err_str, "Number of arguments do not match for function \"%s\": expecting %d, given too many", idptr, expected_count);
semerr(err_str, tok->line_no, parser_data);
el1_.in.std_type = ERR;
} else if (types_equal(expected_type, e.t, 1) == 0) {
char *err_str = (char *)malloc(250);
sprintf(err_str, "Argument type mismatch for function \"%s\" on arg %d: expecting %s, given %s", idptr, el_->c + 1, type_to_str(expected_type), type_to_str(e.t));
semerr(err_str, tok->line_no, parser_data);
el1_.in.std_type = ERR;
} else
el1_.c = el_->c + 1;
el1_.idptr = idptr;
parse_expr_list_(parser_data, &el1_);
break;
case TOKEN_RPAREN:
// NOP
if (el_->in.std_type != ERR && expected_count > el_->c) {
char *err_str = (char *)malloc(250);
sprintf(err_str, "Number of arguments do not match for symbol \"%s\": expecting %d, given %d", idptr, expected_count, el_->c);
semerr(err_str, tok->line_no, parser_data);
el_->t.std_type = ERR;
}
break;
default:
synerr((TokenType[]){TOKEN_COMMA,TOKEN_RPAREN}, 2, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_EXPR_LIST_, tok, parser_data);
}
struct Attributes parse_expr(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
Attributes e = ATTRIBUTES_DEFAULT, se = ATTRIBUTES_DEFAULT, e_ = ATTRIBUTES_DEFAULT;
switch (tok->token->type) {
case TOKEN_ID:
case TOKEN_NUM:
case TOKEN_LPAREN:
case TOKEN_NOT:
case TOKEN_ADDOP:
se = parse_simple_expr(parser_data);
e_.in = se.t;
parse_expr_(parser_data, &e_);
e.t = e_.t;
break;
default:
synerr((TokenType[]){TOKEN_ID,TOKEN_NUM,TOKEN_LPAREN,TOKEN_NOT,TOKEN_ADDOP}, 5, tok, parser_data);
synch(PRODUCTION_EXPR, tok, parser_data);
break;
}
return e;
}
void parse_expr_(ParserData *parser_data, Attributes *e_)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
int doSynch = 0;
Attributes se = ATTRIBUTES_DEFAULT;
switch (tok->token->type) {
case TOKEN_RELOP:
if (match(TOKEN_RELOP, parser_data) == NULL) { doSynch = 1; break; }
se = parse_simple_expr(parser_data);
if (e_->in.std_type == ERR || se.t.std_type == ERR)
e_->t.std_type = ERR;
else if (types_equal(e_->in, se.t, 1) == 0) {
semerr("Mixed mode relop not allowed", tok->line_no, parser_data);
e_->t.std_type = ERR;
} else if (e_->in.std_type == INT || e_->in.std_type == REAL)
e_->t.std_type = BOOL;
else {
semerr("Relop operands must be INT or REAL", tok->line_no, parser_data);
e_->t.std_type = ERR;
}
break;
case TOKEN_SEMICOLON:
case TOKEN_END:
case TOKEN_ELSE:
case TOKEN_THEN:
case TOKEN_DO:
case TOKEN_RBRACKET:
case TOKEN_COMMA:
case TOKEN_RPAREN:
// NOP
e_->t = e_->in;
break;
default:
synerr((TokenType[]){TOKEN_RELOP,TOKEN_SEMICOLON,TOKEN_END,TOKEN_ELSE,TOKEN_THEN,TOKEN_DO,TOKEN_RBRACKET,TOKEN_COMMA,TOKEN_RPAREN}, 9, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_EXPR_, tok, parser_data);
}
struct Attributes parse_simple_expr(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
Attributes se = ATTRIBUTES_DEFAULT, t = ATTRIBUTES_DEFAULT, se_ = ATTRIBUTES_DEFAULT;
switch (tok->token->type) {
case TOKEN_ID:
case TOKEN_NUM:
case TOKEN_LPAREN:
case TOKEN_NOT:
t = parse_term(parser_data);
se_.in = t.t;
parse_simple_expr_(parser_data, &se_);
se.t = se_.t;
break;
case TOKEN_ADDOP:
parse_sign(parser_data);
t = parse_term(parser_data);
if (t.t.std_type == INT || t.t.std_type == REAL || t.t.std_type == ERR)
se_.in = t.t;
else {
semerr("Only int and real numbers can be prefixed with a +/-", tok->line_no, parser_data);
se_.in.std_type = ERR;
}
se_.in = t.t;
parse_simple_expr_(parser_data, &se_);
se.t = se_.t;
break;
default:
synerr((TokenType[]){TOKEN_ID,TOKEN_NUM,TOKEN_LPAREN,TOKEN_NOT,TOKEN_ADDOP}, 5, tok, parser_data);
synch(PRODUCTION_SIMPLE_EXPR, tok, parser_data);
break;
}
return se;
}
void parse_simple_expr_(ParserData *parser_data, struct Attributes *se_)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
int doSynch = 0;
Attributes t = ATTRIBUTES_DEFAULT, se1_ = ATTRIBUTES_DEFAULT;
switch (tok->token->type) {
case TOKEN_ADDOP:
if (match(TOKEN_ADDOP, parser_data) == NULL) { doSynch = 1; break; }
t = parse_term(parser_data);
if (se_->in.std_type == ERR || t.t.std_type == ERR)
se1_.in.std_type = ERR;
else if (types_equal(se_->in, t.t, 1) == 0) {
semerr("Mixed mode addop not allowed", tok->line_no, parser_data);
se1_.in.std_type = ERR;
} else if (tok->token->attribute == '+' || tok->token->attribute == '-') {
if (se_->in.std_type == INT || se_->in.std_type == REAL)
se1_.in = se_->in;
else {
semerr("Addop operands must be int or real", tok->line_no, parser_data);
se1_.in.std_type = ERR;
}
} else if (tok->token->attribute == ATTRIBUTE_OR) {
if (se_->in.std_type == BOOL)
se1_.in = se_->in;
else {
semerr("OR operands must be must be bool", tok->line_no, parser_data);
}
}
parse_simple_expr_(parser_data, &se1_);
se_->t = se1_.t;
break;
case TOKEN_RELOP:
case TOKEN_SEMICOLON:
case TOKEN_END:
case TOKEN_ELSE:
case TOKEN_THEN:
case TOKEN_DO:
case TOKEN_RBRACKET:
case TOKEN_COMMA:
case TOKEN_RPAREN:
// NOP
se_->t = se_->in;
break;
default:
synerr((TokenType[]){TOKEN_RELOP,TOKEN_SEMICOLON,TOKEN_END,TOKEN_ELSE,TOKEN_THEN,TOKEN_DO,TOKEN_RBRACKET,TOKEN_COMMA,TOKEN_RPAREN}, 10, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_SIMPLE_EXPR_, tok, parser_data);
}
struct Attributes parse_term(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
Attributes t = ATTRIBUTES_DEFAULT, f = ATTRIBUTES_DEFAULT, t_ = ATTRIBUTES_DEFAULT;
switch (tok->token->type) {
case TOKEN_ID:
case TOKEN_NUM:
case TOKEN_LPAREN:
case TOKEN_NOT:
f = parse_factor(parser_data);
t_.in = f.t;
parse_term_(parser_data, &t_);
t.t = t_.t;
break;
default:
synerr((TokenType[]){TOKEN_ID,TOKEN_NUM,TOKEN_LPAREN,TOKEN_NOT}, 4, tok, parser_data);
synch(PRODUCTION_TERM, tok, parser_data);
break;
}
return t;
}
void parse_term_(ParserData *parser_data, struct Attributes *t_)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
int doSynch = 0;
Attributes f = ATTRIBUTES_DEFAULT, t1_ = ATTRIBUTES_DEFAULT;
switch (tok->token->type) {
case TOKEN_MULOP:
if (match(TOKEN_MULOP, parser_data) == NULL) { doSynch = 1; break; }
f = parse_factor(parser_data);
if (t_->in.std_type == ERR || f.t.std_type == ERR)
t1_.in.std_type = ERR;
else if (types_equal(t_->in, f.t, 1) == 0) {
semerr("Mixed mode mulop not allowed", tok->line_no, parser_data);
t1_.in.std_type = ERR;
} else if (tok->token->attribute == '*' || tok->token->attribute == '/' ||
tok->token->attribute == ATTRIBUTE_DIV || tok->token->attribute == ATTRIBUTE_MOD) {
if (t_->in.std_type == INT)
t1_.in.std_type = INT;
else {
semerr("Operands must be int", tok->line_no, parser_data);
t1_.in.std_type = ERR;
}
} else if (tok->token->attribute == ATTRIBUTE_AND) {
if (t_->in.std_type == BOOL)
t1_.in.std_type = BOOL;
else {
semerr("Operands must be bool", tok->line_no, parser_data);
t1_.in.std_type = ERR;
}
}
parse_term_(parser_data, &t1_);
t_->t = t1_.t;
break;
case TOKEN_ADDOP:
case TOKEN_RELOP:
case TOKEN_SEMICOLON:
case TOKEN_END:
case TOKEN_ELSE:
case TOKEN_THEN:
case TOKEN_DO:
case TOKEN_RBRACKET:
case TOKEN_COMMA:
case TOKEN_RPAREN:
// NOP
t_->t = t_->in;
break;
default:
synerr((TokenType[]){TOKEN_MULOP,TOKEN_ADDOP,TOKEN_RELOP,TOKEN_SEMICOLON,TOKEN_END,TOKEN_ELSE,TOKEN_THEN,TOKEN_DO,TOKEN_RBRACKET,TOKEN_COMMA,TOKEN_RPAREN}, 11, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_TERM_, tok, parser_data);
}
struct Attributes parse_factor(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
MachineResult *idptr;
int doSynch = 0;
Attributes f = ATTRIBUTES_DEFAULT, e = ATTRIBUTES_DEFAULT, f1 = ATTRIBUTES_DEFAULT, f_ = ATTRIBUTES_DEFAULT;
switch (tok->token->type) {
case TOKEN_ID:
idptr = match(TOKEN_ID, parser_data);
if (idptr == NULL) { doSynch = 1; break; }
Type idtype = get_type(idptr->lexeme, parser_data);
if (idtype.std_type == NONE) {
char *err_str = (char *)malloc(250);
sprintf(err_str, "Undefined symbol \"%s\"", idptr->lexeme);
semerr(err_str, tok->line_no, parser_data);
f_.in.std_type = ERR;
} else
f_.in = idtype;
f_.idptr = idptr->lexeme;
parse_factor_(parser_data, &f_);
f.t = f_.t;
break;
case TOKEN_NUM:
if (match(TOKEN_NUM, parser_data) == NULL) { doSynch = 1; break; }
if (tok->token->attribute == ATTRIBUTE_INT)
f.t.std_type = INT;
else if (tok->token->attribute == ATTRIBUTE_REAL || tok->token->attribute == ATTRIBUTE_LONGREAL)
f.t.std_type = REAL;
break;
case TOKEN_LPAREN:
if (match(TOKEN_LPAREN, parser_data) == NULL) { doSynch = 1; break; }
e = parse_expr(parser_data);
if (match(TOKEN_RPAREN, parser_data) == NULL) { doSynch = 1; break; }
f.t = e.t;
break;
case TOKEN_NOT:
if (match(TOKEN_NOT, parser_data) == NULL) { doSynch = 1; break; }
f1 = parse_factor(parser_data);
if (f1.t.std_type == BOOL || f1.t.std_type == ERR)
f.t = f1.t;
else {
semerr("Not must be followed by a bool type", tok->line_no, parser_data);
f.t.std_type = ERR;
}
break;
default:
synerr((TokenType[]){TOKEN_ID,TOKEN_NUM,TOKEN_LPAREN,TOKEN_NOT}, 4, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_FACTOR, tok, parser_data);
return f;
}
void parse_factor_(ParserData *parser_data, struct Attributes *f_)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
int doSynch = 0;
Attributes el = ATTRIBUTES_DEFAULT, e = ATTRIBUTES_DEFAULT;
switch (tok->token->type) {
case TOKEN_LPAREN:
if (match(TOKEN_LPAREN, parser_data) == NULL) { doSynch = 1; break; }
el.in = f_->in;
el.idptr = f_->idptr;
parse_expr_list(parser_data, &el);
if (match(TOKEN_RPAREN, parser_data) == NULL) { doSynch = 1; break; }
if (el.t.std_type == ERR)
f_->t.std_type = ERR;
else {
f_->t = f_->in;
f_->t.fun = 0;
}
break;
case TOKEN_LBRACKET:
if (match(TOKEN_LBRACKET, parser_data) == NULL) { doSynch = 1; break; }
e = parse_expr(parser_data);
if (match(TOKEN_RBRACKET, parser_data) == NULL) { doSynch = 1; break; }
if (f_->in.std_type == ERR || e.t.std_type == ERR)
f_->t.std_type = ERR;
else if (e.t.std_type != INT) {
semerr("Index must be an integer", tok->line_no, parser_data);
f_->t.std_type = ERR;
} else if (f_->in.std_type == AINT || f_->in.std_type == AREAL) {
if (f_->in.std_type == AINT) f_->t.std_type = INT;
if (f_->in.std_type == AREAL) f_->t.std_type = REAL;
} else {
semerr("Symbol is not an array", tok->line_no, parser_data);
f_->t.std_type = ERR;
}
break;
case TOKEN_MULOP:
case TOKEN_ADDOP:
case TOKEN_RELOP:
case TOKEN_SEMICOLON:
case TOKEN_END:
case TOKEN_ELSE:
case TOKEN_THEN:
case TOKEN_DO:
case TOKEN_RBRACKET:
case TOKEN_COMMA:
case TOKEN_RPAREN:
// NOP
f_->t = f_->in;
break;
default:
synerr((TokenType[]){TOKEN_LPAREN,TOKEN_LBRACKET,TOKEN_MULOP,TOKEN_ADDOP,TOKEN_RELOP,TOKEN_SEMICOLON,TOKEN_END,TOKEN_ELSE,TOKEN_THEN,TOKEN_DO,TOKEN_RBRACKET,TOKEN_COMMA,TOKEN_RPAREN}, 13, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_FACTOR_, tok, parser_data);
}
void parse_sign(ParserData *parser_data)
{
MachineResult *tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
int doSynch = 0;
switch (tok->token->type) {
case TOKEN_ADDOP:
if (match(TOKEN_ADDOP, parser_data) == NULL) { doSynch = 1; break; }
break;
default:
synerr((TokenType[]){TOKEN_ADDOP}, 1, tok, parser_data);
doSynch = 1;
break;
}
if (doSynch == 1)
synch(PRODUCTION_SIGN, tok, parser_data);
}
void synch(Production prod, MachineResult *tok, ParserData *parser_data)
{
TokenType *synchSet;
int len;
switch(prod) {
case PRODUCTION_PROGRAM:
case PRODUCTION_PROGRAM_:
case PRODUCTION_PROGRAM__:
synchSet = (TokenType[]){TOKEN_EOF}; len = 1;
break;
case PRODUCTION_ID_LIST:
case PRODUCTION_ID_LIST_:
case PRODUCTION_PARAM_LIST:
case PRODUCTION_PARAM_LIST_:
case PRODUCTION_EXPR_LIST:
case PRODUCTION_EXPR_LIST_:
synchSet = (TokenType[]){TOKEN_EOF, TOKEN_RPAREN}; len = 2;
break;
case PRODUCTION_DECLARATIONS:
case PRODUCTION_DECLARATIONS_:
synchSet = (TokenType[]){TOKEN_EOF, TOKEN_BEGIN, TOKEN_SEMICOLON, TOKEN_PROCEDURE}; len = 4;
break;
case PRODUCTION_TYPE:
case PRODUCTION_STD_TYPE:
synchSet = (TokenType[]){TOKEN_EOF, TOKEN_SEMICOLON, TOKEN_RPAREN}; len = 3;
break;
case PRODUCTION_SUBPROGRAM_DECLARATIONS:
case PRODUCTION_SUBPROGRAM_DECLARATIONS_:
synchSet = (TokenType[]){TOKEN_EOF, TOKEN_BEGIN, TOKEN_SEMICOLON}; len = 3;
break;
case PRODUCTION_SUBPROGRAM_DECLARATION:
case PRODUCTION_SUBPROGRAM_DECLARATION_:
case PRODUCTION_SUBPROGRAM_DECLARATION__:
case PRODUCTION_ARGUMENTS:
synchSet = (TokenType[]){TOKEN_EOF, TOKEN_SEMICOLON}; len = 2;
break;
case PRODUCTION_COMPOUND_STATEMENT:
case PRODUCTION_COMPOUND_STATEMENT_:
synchSet = (TokenType[]){TOKEN_EOF, TOKEN_PERIOD, TOKEN_END, TOKEN_ELSE, TOKEN_SEMICOLON}; len = 5;
break;
case PRODUCTION_SUBPROGRAM_HEAD:
case PRODUCTION_SUBPROGRAM_HEAD_:
synchSet = (TokenType[]){TOKEN_EOF, TOKEN_BEGIN, TOKEN_VAR, TOKEN_SEMICOLON, TOKEN_PROCEDURE}; len = 5;
break;
case PRODUCTION_OPTIONAL_STATEMENTS:
case PRODUCTION_STATEMENT_LIST:
case PRODUCTION_STATEMENT_LIST_:
synchSet = (TokenType[]){TOKEN_EOF, TOKEN_END}; len = 2;
break;
case PRODUCTION_STATEMENT:
case PRODUCTION_STATEMENT_:
synchSet = (TokenType[]){TOKEN_EOF, TOKEN_END, TOKEN_ELSE, TOKEN_SEMICOLON}; len = 4;
break;
case PRODUCTION_VAR:
case PRODUCTION_VAR_:
synchSet = (TokenType[]){TOKEN_EOF, TOKEN_ASSIGNOP}; len = 2;
break;
case PRODUCTION_EXPR:
case PRODUCTION_EXPR_:
synchSet = (TokenType[]){TOKEN_EOF, TOKEN_THEN, TOKEN_COMMA, TOKEN_SEMICOLON, TOKEN_RBRACKET, TOKEN_DO, TOKEN_ELSE, TOKEN_RPAREN, TOKEN_END}; len = 9;
break;
case PRODUCTION_SIMPLE_EXPR:
case PRODUCTION_SIMPLE_EXPR_:
synchSet = (TokenType[]){TOKEN_EOF, TOKEN_THEN, TOKEN_COMMA, TOKEN_SEMICOLON, TOKEN_RBRACKET, TOKEN_DO, TOKEN_ELSE, TOKEN_RPAREN, TOKEN_END, TOKEN_RELOP}; len = 10;
break;
case PRODUCTION_TERM:
case PRODUCTION_TERM_:
synchSet = (TokenType[]){TOKEN_EOF, TOKEN_THEN, TOKEN_COMMA, TOKEN_SEMICOLON, TOKEN_RBRACKET, TOKEN_DO, TOKEN_ELSE, TOKEN_RPAREN, TOKEN_END, TOKEN_RELOP, TOKEN_ADDOP}; len = 11;
break;
case PRODUCTION_FACTOR:
case PRODUCTION_FACTOR_:
synchSet = (TokenType[]){TOKEN_EOF, TOKEN_THEN, TOKEN_COMMA, TOKEN_SEMICOLON, TOKEN_RBRACKET, TOKEN_DO, TOKEN_ELSE, TOKEN_RPAREN, TOKEN_END, TOKEN_RELOP, TOKEN_ADDOP, TOKEN_MULOP}; len = 12;
break;
case PRODUCTION_SIGN:
synchSet = (TokenType[]){TOKEN_EOF, TOKEN_ID, TOKEN_NUM, TOKEN_LPAREN, TOKEN_NOT}; len = 5;
break;
}
while(1) {
// advance to next token but hang onto it
tok = get_next_token(parser_data, TOKEN_OPTION_NOP);
for(int i = 0; i < len; i++) {
if(tok->token->type == synchSet[i]) {
if(tok->token->type == TOKEN_EOF) {
fprintf(stderr, "Reached EOF...quitting now\n");
exit(PARSER_RESULT_SYNERR);
} else {
fprintf(stderr, "Synchronized on term \"%s\" (%s)\n", tok->lexeme, token_type_to_str(tok->token->type));
return;
}
}
}
// advance to next token
tok = get_next_token(parser_data, TOKEN_OPTION_NONE);
}
} | 27.662031 | 208 | 0.709437 |
567d504c4271c38ea0fd6cb0a4afd23e822a5b33 | 6,699 | h | C | include/frontend/frontend.h | ViewFaceCore/TenniS | c1d21a71c1cd025ddbbe29924c8b3296b3520fc0 | [
"BSD-2-Clause"
] | null | null | null | include/frontend/frontend.h | ViewFaceCore/TenniS | c1d21a71c1cd025ddbbe29924c8b3296b3520fc0 | [
"BSD-2-Clause"
] | null | null | null | include/frontend/frontend.h | ViewFaceCore/TenniS | c1d21a71c1cd025ddbbe29924c8b3296b3520fc0 | [
"BSD-2-Clause"
] | null | null | null | //
// Created by kier on 2019/3/27.
//
#ifndef TENSORSTACK_FRONTEND_FRONTEND_H
#define TENSORSTACK_FRONTEND_FRONTEND_H
#include "module/menu.h"
#include "symbol.h"
#include <module/graph.h>
#include "frontend/desc.h"
#include <array>
namespace ts {
namespace frontend {
using namespace bubble;
struct DimPadding {
DimPadding() = default;
DimPadding(int32_t first, int32_t second)
: first(first), second(second) {}
int32_t first = 0;
int32_t second = 0;
};
class TS_DEBUG_API NodeOrTensor {
public:
using self = NodeOrTensor;
NodeOrTensor(const Node &node);
NodeOrTensor(const Tensor &tensor);
NodeOrTensor(const Tensor &tensor, const char *device);
NodeOrTensor(const Tensor &tensor, const DeviceType &device);
NodeOrTensor(const Tensor &tensor, const MemoryDevice &device);
operator Node() const;
private:
Node m_node;
};
TS_DEBUG_API Node
pad(const std::string &name, const NodeOrTensor &x, const NodeOrTensor &padding, float padding_value = 0);
TS_DEBUG_API Node pad(const std::string &name, const NodeOrTensor &x, const std::vector<DimPadding> &padding,
float padding_value = 0);
TS_DEBUG_API Node resize2d(const std::string &name, const NodeOrTensor &x, const NodeOrTensor &size,
desc::ResizeType type = desc::ResizeType::LINEAR);
TS_DEBUG_API Node resize2d(const std::string &name, const NodeOrTensor &x, const std::vector<int32_t> &size,
desc::ResizeType type = desc::ResizeType::LINEAR);
TS_DEBUG_API Node add(const std::string &name, const NodeOrTensor &lhs, const NodeOrTensor &rhs);
TS_DEBUG_API Node sub(const std::string &name, const NodeOrTensor &lhs, const NodeOrTensor &rhs);
TS_DEBUG_API Node mul(const std::string &name, const NodeOrTensor &lhs, const NodeOrTensor &rhs);
TS_DEBUG_API Node div(const std::string &name, const NodeOrTensor &lhs, const NodeOrTensor &rhs);
TS_DEBUG_API Node
transpose(const std::string &name, const NodeOrTensor &x, const std::vector<int32_t> &permute);
TS_DEBUG_API Node sigmoid(const std::string &name, const NodeOrTensor &x);
TS_DEBUG_API Node
gather(const std::string &name, const NodeOrTensor &x, const NodeOrTensor &indices, int32_t axis);
TS_DEBUG_API Node concat(const std::string &name, const std::vector<NodeOrTensor> &x, int32_t dim);
TS_DEBUG_API Node softmax(const std::string &name, const NodeOrTensor &x, int32_t dim, bool smooth = true);
TS_DEBUG_API Node cast(const std::string &name, const NodeOrTensor &x, DTYPE dtype);
TS_DEBUG_API Node affine_sample2d(const std::string &name,
const NodeOrTensor &x, const NodeOrTensor &size, const NodeOrTensor &affine,
int32_t dim = -1,
float outer_value = 0,
desc::ResizeType type = desc::ResizeType::LINEAR);
TS_DEBUG_API Node affine_sample2d(const std::string &name,
const NodeOrTensor &x,
const std::array<int32_t, 2> &size, const NodeOrTensor &affine,
int32_t dim = -1,
float outer_value = 0,
desc::ResizeType type = desc::ResizeType::LINEAR);
TS_DEBUG_API Node affine_sample2d(const std::string &name,
const NodeOrTensor &x,
const NodeOrTensor &size, const std::array<float, 9> &affine,
int32_t dim = -1,
float outer_value = 0,
desc::ResizeType type = desc::ResizeType::LINEAR);
TS_DEBUG_API Node affine_sample2d(const std::string &name,
const NodeOrTensor &x,
const std::array<int32_t, 2> &size, const std::array<float, 9> &affine,
int32_t dim = -1,
float outer_value = 0,
desc::ResizeType type = desc::ResizeType::LINEAR);
TS_DEBUG_API Node affine_on_sample2d(const std::string &name,
const NodeOrTensor &x, const NodeOrTensor &size,
const NodeOrTensor &affine,
int32_t dim = -1,
desc::ResizeType type = desc::ResizeType::LINEAR);
TS_DEBUG_API Node affine_on_sample2d(const std::string &name,
const NodeOrTensor &x,
const std::array<int32_t, 2> &size, const NodeOrTensor &affine,
int32_t dim = -1,
desc::ResizeType type = desc::ResizeType::LINEAR);
TS_DEBUG_API Node affine_on_sample2d(const std::string &name,
const NodeOrTensor &x,
const NodeOrTensor &size, const std::array<float, 9> &affine,
int32_t dim = -1,
desc::ResizeType type = desc::ResizeType::LINEAR);
TS_DEBUG_API Node affine_on_sample2d(const std::string &name,
const NodeOrTensor &x,
const std::array<int32_t, 2> &size, const std::array<float, 9> &affine,
int32_t dim = -1,
desc::ResizeType type = desc::ResizeType::LINEAR);
TS_DEBUG_API Node matmul(const std::string &name, const NodeOrTensor &A, const NodeOrTensor &B, bool transpose = false);
TS_DEBUG_API Node broadcast(const std::string &name, const NodeOrTensor &x, const NodeOrTensor &shape);
TS_DEBUG_API Node broadcast(const std::string &name, const NodeOrTensor &x, const std::vector<int32_t> &shape);
}
}
#endif //TENSORSTACK_FRONTEND_FRONTEND_H
| 45.883562 | 128 | 0.528139 |
bc352212d01a5e79139dc4a893459668262caaf5 | 1,151 | h | C | include/process.h | raulpac/CPPND-System-Monitor | 2f4fa8008eed299c1a717a526ec31811f0dc04e8 | [
"MIT"
] | 2 | 2020-06-19T16:08:12.000Z | 2021-04-08T14:27:28.000Z | include/process.h | raulpac/CPPND-System-Monitor | 2f4fa8008eed299c1a717a526ec31811f0dc04e8 | [
"MIT"
] | null | null | null | include/process.h | raulpac/CPPND-System-Monitor | 2f4fa8008eed299c1a717a526ec31811f0dc04e8 | [
"MIT"
] | null | null | null | #ifndef PROCESS_H
#define PROCESS_H
#include "linux_parser.h"
#include <string>
/*
Basic class for Process representation
It contains relevant attributes as shown below
*/
class Process {
public:
int Pid(); // TODO: See src/process.cpp
std::string User(); // TODO: See src/process.cpp
std::string Command(); // TODO: See src/process.cpp
float CpuUtilization(); // TODO: See src/process.cpp
std::string Ram(); // TODO: See src/process.cpp
long int UpTime(); // TODO: See src/process.cpp
bool operator<(Process const& a) const; // TODO: See src/process.cpp
Process(int Pid){
pid_ = Pid;
user_ = User();
command_ = Command();
cpuutilization_ = CpuUtilization();
ram_ = Ram();
uptime = UpTime();
}
// TODO: Declare any necessary private members
private:
int pid_;
std::string user_;
std::string command_;
float cpuutilization_;
std::string ram_;
long int uptime;
float CpuProc_;
float TUsageTime_; //prev
float TTime_; //prev
};
#endif | 26.159091 | 71 | 0.588184 |
14f602e8603cd7d8b68a7f76b9f81a4159384dc5 | 1,562 | c | C | tests/for.c | tsubo164/acc | ea01169e21392d865af71744515db3ac43ce0a5f | [
"MIT"
] | null | null | null | tests/for.c | tsubo164/acc | ea01169e21392d865af71744515db3ac43ce0a5f | [
"MIT"
] | null | null | null | tests/for.c | tsubo164/acc | ea01169e21392d865af71744515db3ac43ce0a5f | [
"MIT"
] | null | null | null | #include "test.h"
int main()
{
{
int sum = 0;
int i;
for (i = 1; i <= 10; i++) {
sum = sum + i;
}
assert(55, sum);
}
{
int i;
for (i = 0; i < 10; ) {
i = 2 * i + 1;
}
assert(15, i);
}
{
int sum = 0;
int i = 11;
for (; i <= 20; ) {
sum = sum + i;
i++;
}
assert(155, sum);
}
{
int i;
for (i = 0; i < 10; i++)
if (i == 6)
break;
assert(6, i);
}
{
int i = 0;
for (;;) {
if (i / 3 == 4)
if (i / 6 == 2)
break;
i++;
}
assert(12, i);
}
{
int sum = 0;
int i = 0;
for (i = 0; i < 20; i++) {
if (i / 3 == 3) {
sum += i;
continue;
}
}
assert(30, sum);
}
{
/* infinite loop style */
int i = 0;
for (;;) {
if (i == 10)
break;
i++;
}
assert(10, i);
}
{
/* test for null statement */
int a = 19;
if (0)
;
a = 22;
assert(22, a);
}
{
/* controlling expression with char type */
char *s = "abc";
char *c = s;
int a = 0;
while (*c) {
a += *c;
c++;
}
assert(294, a);
}
return 0;
}
| 15.62 | 51 | 0.254161 |
423f0564da18df7f3c56acd205deb1ec2eef023d | 1,185 | h | C | DXMUI/D3D11_Interface/DXMRenderer.h | Ulvmane/DXMUI | 999d30c1d21777f382cbf37d7aa2c701d5951ac3 | [
"MIT"
] | null | null | null | DXMUI/D3D11_Interface/DXMRenderer.h | Ulvmane/DXMUI | 999d30c1d21777f382cbf37d7aa2c701d5951ac3 | [
"MIT"
] | null | null | null | DXMUI/D3D11_Interface/DXMRenderer.h | Ulvmane/DXMUI | 999d30c1d21777f382cbf37d7aa2c701d5951ac3 | [
"MIT"
] | null | null | null | #pragma once
#include <vector>
#include "DXMDrawSurface.h"
#include "DXMTextRenderer.h"
struct ID3D11DeviceContext;
struct ID3D11Buffer;
struct ID3D11Device;
struct ID3D11SamplerState;
struct ID3D11BlendState;
namespace DXMUI
{
class DXMRenderer
{
public:
DXMRenderer();
~DXMRenderer();
void Render(ID3D11DeviceContext* aContext);
bool Init(ID3D11Device* aDevice);
static void AddDrawSurface(DXMDrawSurface& aSurface);
private:
static std::vector<DXMDrawSurface> ourDrawSurfaces;
void SetShaders(ID3D11DeviceContext* aContext);
void SetBuffer(ID3D11DeviceContext* aContext, DXMDrawSurface& aSurface);
void SetSamplers(ID3D11DeviceContext* aContext);
void SetBlendState(ID3D11DeviceContext* aContext);
//void SetBuffer(ID3D11DeviceContext* aContext, DXMDrawSurface& aSurface);
void ReSetSamplers(ID3D11DeviceContext* aContext);
void ReSetBlendState(ID3D11DeviceContext* aContext);
void ReSetShaders(ID3D11DeviceContext* aContext);
DXMTextRenderer myTextRenderer;
ID3D11Buffer* myElementBuffer = nullptr;
ID3D11Buffer* myVertexBuffer = nullptr;
ID3D11SamplerState* mySamplerState = nullptr;
ID3D11BlendState* myBlendState = nullptr;
};
}
| 29.625 | 76 | 0.8 |
f61c0138ec9cf056e85e264d725b124958cedef4 | 1,165 | c | C | rascull/src/c/vector.c | Shfty/rascull | 7a403d3622339c8f2ce131604f94e2e396388336 | [
"MIT"
] | 3 | 2020-06-25T08:40:44.000Z | 2021-02-14T04:30:02.000Z | rascull/src/c/vector.c | Shfty/rascull | 7a403d3622339c8f2ce131604f94e2e396388336 | [
"MIT"
] | null | null | null | rascull/src/c/vector.c | Shfty/rascull | 7a403d3622339c8f2ce131604f94e2e396388336 | [
"MIT"
] | 1 | 2020-08-12T08:55:48.000Z | 2020-08-12T08:55:48.000Z | #include "vector.h"
#include "math.h"
float fvec3_sqlen(fvec3 v)
{
return fvec3_dot(v, v);
}
float fvec3_length(fvec3 v)
{
float sqlen = fvec3_sqlen(v);
return (float)sqrt(fvec3_sqlen(v));
}
fvec3 fvec3_normalize(fvec3 v)
{
float len = fvec3_length(v);
return fvec3_div_float(v, len);
}
float fvec3_dot(fvec3 lhs, fvec3 rhs)
{
return lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z;
}
fvec3 fvec3_cross(fvec3 lhs, fvec3 rhs)
{
return (fvec3){
lhs.y * rhs.z - lhs.z * rhs.y,
lhs.z * rhs.x - lhs.x * rhs.z,
lhs.x * rhs.y - lhs.y * rhs.x,
};
}
fvec3 fvec3_add_float(const fvec3 lhs, const float rhs)
{
fvec3 result = {lhs.x + rhs, lhs.y + rhs, lhs.z + rhs};
return result;
};
fvec3 fvec3_sub_float(const fvec3 lhs, const float rhs)
{
fvec3 result = {lhs.x - rhs, lhs.y - rhs, lhs.z - rhs};
return result;
};
fvec3 fvec3_mul_float(const fvec3 lhs, const float rhs)
{
fvec3 result = {lhs.x * rhs, lhs.y * rhs, lhs.z * rhs};
return result;
};
fvec3 fvec3_div_float(const fvec3 lhs, const float rhs)
{
fvec3 result = {lhs.x / rhs, lhs.y / rhs, lhs.z / rhs};
return result;
};
| 19.745763 | 59 | 0.618026 |
393389f270119329bf03e02f8b892c03d930257e | 12,576 | h | C | Sail/src/Sail/netcode/NetworkedStructs.h | BTH-StoraSpel-DXR/SPLASH | 1bf4c9b96cbcce570ed3a97f30a556a992e1ad08 | [
"MIT"
] | 12 | 2019-09-11T15:52:31.000Z | 2021-11-14T20:33:35.000Z | Sail/src/Sail/netcode/NetworkedStructs.h | BTH-StoraSpel-DXR/Game | 1bf4c9b96cbcce570ed3a97f30a556a992e1ad08 | [
"MIT"
] | 227 | 2019-09-11T08:40:24.000Z | 2020-06-26T14:12:07.000Z | Sail/src/Sail/netcode/NetworkedStructs.h | BTH-StoraSpel-DXR/Game | 1bf4c9b96cbcce570ed3a97f30a556a992e1ad08 | [
"MIT"
] | 2 | 2020-10-26T02:35:18.000Z | 2020-10-26T02:36:01.000Z | #pragma once
#include "ArchiveHelperFunctions.h"
#include "NetcodeTypes.h"
#include <atomic>
namespace Netcode {
// Global counter
extern std::atomic<ComponentID> gNetworkIDCounter;
extern ComponentID gNetworkBotIDCounter;
static constexpr ComponentID UNINITIALIZED = 0;
static constexpr ComponentID PLAYER_VALUE = 1;
static constexpr ComponentID GUN_VALUE = 2;
static constexpr ComponentID TORCH_VALUE = 3;
static constexpr ComponentID RESET_VALUE = 4;
static void resetIDCounter() {
gNetworkIDCounter = RESET_VALUE;
gNetworkBotIDCounter = 0;
}
static ComponentID createNetworkID() { return ++gNetworkIDCounter; }
static ComponentID nrOfNetworkObjects() { return gNetworkIDCounter; }
// ComponentID has 32 bits and the first 8 are the PlayerID of the owner which
// can be extracted by shifting the ComponentID 18 bits to the right.
static constexpr ComponentID SHIFT_AMOUNT = 18;
#pragma region SPECIAL_ID_VALUES
// All non-player and non-player-owned entities will have PlayerIDs above 200
static constexpr PlayerID NONE_PLAYER_ID_START = 200;
static constexpr PlayerID MESSAGE_BOT_ID = 252;
static constexpr PlayerID MESSAGE_INSANITY_ID = 253;
static constexpr PlayerID NEUTRAL_OWNER_ID = 251; //NEUTRAL OWNER, NOT A PLAYER
static constexpr ComponentID INSANITY_COMP_ID = static_cast<ComponentID>(MESSAGE_INSANITY_ID) << SHIFT_AMOUNT;
static constexpr PlayerID MESSAGE_SPRINKLER_ID = 254;
static constexpr ComponentID SPRINKLER_COMP_ID = static_cast<ComponentID>(MESSAGE_SPRINKLER_ID) << SHIFT_AMOUNT;
// Used to signify NetworkMessages sent Internally
static constexpr PlayerID MESSAGE_FROM_SELF_ID = 255;
static constexpr PlayerID UNINITIALIZED_PLAYER = 255;
#pragma endregion
static constexpr ComponentID generateID(PlayerID playerID, ComponentID counter) {
return (counter | (static_cast<ComponentID>(playerID) << SHIFT_AMOUNT));
}
// Generates a unique ID for a NetworkSenderComponent based on the player's PlayerID
static ComponentID generateUniqueComponentID(PlayerID ownerID) {
return generateID(ownerID, createNetworkID());
}
static ComponentID generateUniqueBotID() {
return generateID(MESSAGE_BOT_ID, gNetworkBotIDCounter++);
}
// Extract the PlayerID of the owner of a NetworkComponent from the component's ID
static constexpr PlayerID getComponentOwner(ComponentID componentID) {
return static_cast<PlayerID>(componentID >> SHIFT_AMOUNT);
}
static ComponentID getPlayerCompID(PlayerID playerID) {
return generateID(playerID, PLAYER_VALUE);
}
static ComponentID getGunCompID(PlayerID playerID) {
return generateID(playerID, GUN_VALUE);
}
static ComponentID getTorchCompID(PlayerID playerID) {
return generateID(playerID, TORCH_VALUE);
}
/*
Enums for the kind of entities/data that will be sent over the network,
will just be used to read to/write from in the NetworkSystems
*/
// Pre-defined entity types so that other players know which entity to create
enum class EntityType : __int8 {
PLAYER_ENTITY = 1,
CANDLE_ENTITY,
GUN_ENTITY,
PROJECTILE_ENTITY,
POWER_UP,
MECHA_ENTITY, // RIP Mecha-Jörgen (2019-2019)
INVALID_ENTITY,
};
// TODO: should be one message type for tracked entities and one for events
// The message type decides how the subsequent data will be parsed and used
enum class MessageType : __int8 {
DESTROY_ENTITY = 1,
CHANGE_LOCAL_POSITION,
CHANGE_LOCAL_ROTATION,
CHANGE_ABSOLUTE_POS_AND_ROT,
UPDATE_PROJECTILE_ONCE,
SPAWN_PROJECTILE,
SUBMIT_WATER_POINTS,
ANIMATION,
SHOOT_START,
SHOOT_LOOP,
SHOOT_END,
PLAYER_JUMPED,
PLAYER_LANDED,
WATER_HIT_PLAYER,
SET_CANDLE_HEALTH,
EXTINGUISH_CANDLE,
PLAYER_DIED,
MATCH_ENDED,
PREPARE_ENDSCREEN, // Clients send relevant data for the endgame screen
ENDGAME_STATS,
CANDLE_HELD_STATE,
RUNNING_METAL_START,
RUNNING_TILE_START,
RUNNING_WATER_METAL_START,
RUNNING_WATER_TILE_START,
RUNNING_STOP_SOUND,
IGNITE_CANDLE,
UPDATE_SANITY,
HIT_BY_SPRINKLER,
ENABLE_SPRINKLERS,
START_THROWING,
STOP_THROWING,
SPAWN_POWER_UP,
DESTROY_POWER_UP,
SET_CENTER,
EMPTY,
COUNT
};
static const std::string MessageNames[] = {
"DESTROY_ENTITY",
"CHANGE_LOCAL_POSITION",
"CHANGE_LOCAL_ROTATION",
"CHANGE_ABSOLUTE_POS_AND_ROT",
"UPDATE_PROJECTILE_ONCE",
"SPAWN_PROJECTILE",
"SUBMIT_WATER_POINTS",
"ANIMATION",
"SHOOT_START",
"SHOOT_LOOP",
"SHOOT_END",
"PLAYER_JUMPED",
"PLAYER_LANDED",
"WATER_HIT_PLAYER",
"SET_CANDLE_HEALTH",
"EXTINGUISH_CANDLE",
"PLAYER_DIED",
"MATCH_ENDED",
"PREPARE_ENDSCREEN",
"ENDGAME_STATS",
"CANDLE_HELD_STATE",
"RUNNING_METAL_START",
"RUNNING_TILE_START",
"RUNNING_WATER_METAL_START",
"RUNNING_WATER_TILE_START",
"RUNNING_STOP_SOUND",
"IGNITE_CANDLE",
"UPDATE_SANITY",
"HIT_BY_SPRINKLER",
"ENABLE_SPRINKLERS",
"START_THROWING",
"STOP_THROWING",
"SET_CENTER",
"EMPTY",
"COUNT"
};
/*
Structs for the kind of data that will be sent/
They map to the message types as if the message consists of a tagged union
Logical structure of a message:
struct NetworkMessage {
NetworkObjectID objectID;
MessageType type;
union {
ModifyTransform transform;
SpawnProjectile spawnProjectile;
...
}
}
*/
// MODIFY_TRANSFORM
struct ModifyTransform {
glm::vec3 transform;
template <class Archive>
void save(Archive& ar) const {
ArchiveHelpers::serializeVec3(ar, position);
}
template <class Archive>
void load(Archive& ar) {
ArchiveHelpers::serializeVec3(ar, position);
}
};
// ROTATION_TRANSFORM
struct RotationTransform {
glm::vec3 rotation;
template <class Archive>
void save(Archive& ar) const {
ArchiveHelpers::serializeVec3(ar, position);
}
template <class Archive>
void load(Archive& ar) {
ArchiveHelpers::serializeVec3(ar, position);
}
};
class MessageData {
public:
MessageData() {}
virtual ~MessageData() {}
};
class MessageSpawnPowerUp : public MessageData {
public:
MessageSpawnPowerUp(int powerUpType, glm::vec3 translation_, Netcode::ComponentID powerUpComponentID, Netcode::ComponentID parentComponentID)
: translation(translation_), powerUpComponentID(powerUpComponentID), powerUpType(powerUpType), parentComponentID(parentComponentID)
{
}
virtual ~MessageSpawnPowerUp() {}
int powerUpType;
glm::vec3 translation;
Netcode::ComponentID powerUpComponentID;
Netcode::ComponentID parentComponentID;
};
class MessageDestroyPowerUp : public MessageData {
public:
MessageDestroyPowerUp(Netcode::ComponentID powerUpComponentID, Netcode::ComponentID pickedByPlayer) : powerUpComponentID(powerUpComponentID), pickedByPlayer(pickedByPlayer) {
}
virtual ~MessageDestroyPowerUp() {}
Netcode::ComponentID powerUpComponentID;
Netcode::ComponentID pickedByPlayer;
};
class MessageSpawnProjectile : public MessageData {
public:
MessageSpawnProjectile(glm::vec3 translation_, glm::vec3 velocity_,
Netcode::ComponentID projectileCompID, Netcode::ComponentID ownerComponentID, float frequency)
: translation(translation_), velocity(velocity_),
projectileComponentID(projectileCompID), ownerPlayerComponentID(ownerComponentID),
lowPassFrequency(frequency)
{}
virtual ~MessageSpawnProjectile() {}
glm::vec3 translation;
glm::vec3 velocity;
float lowPassFrequency;
Netcode::ComponentID projectileComponentID;
Netcode::ComponentID ownerPlayerComponentID;
};
class MessageSubmitWaterPoints : public MessageData {
public:
MessageSubmitWaterPoints(std::vector<glm::vec3> _points) : points(_points) {}
virtual ~MessageSubmitWaterPoints() {}
std::vector<glm::vec3> points;
};
class MessageWaterHitPlayer : public MessageData {
public:
MessageWaterHitPlayer(Netcode::ComponentID whoWasHit, Netcode::ComponentID projectileID)
: playerWhoWasHitID(whoWasHit), projectileThatHitID(projectileID)
{}
~MessageWaterHitPlayer() {}
Netcode::ComponentID playerWhoWasHitID;
Netcode::ComponentID projectileThatHitID;
};
class MessageSetCandleHealth : public MessageData {
public:
MessageSetCandleHealth(Netcode::ComponentID candleID, float candleHealth)
: candleThatWasHit(candleID), health(candleHealth) {
}
~MessageSetCandleHealth() {}
Netcode::ComponentID candleThatWasHit;
float health;
};
class MessageExtinguishCandle : public MessageData {
public:
MessageExtinguishCandle(Netcode::ComponentID candleID, Netcode::PlayerID extinguishedBy)
: candleThatWasHit(candleID), playerWhoExtinguishedCandle(extinguishedBy) {
}
~MessageExtinguishCandle() {}
Netcode::ComponentID candleThatWasHit;
Netcode::PlayerID playerWhoExtinguishedCandle;
};
class MessagePlayerJumped : public MessageData {
public:
MessagePlayerJumped(Netcode::ComponentID id) : playerWhoJumped(id) {}
~MessagePlayerJumped() {}
Netcode::ComponentID playerWhoJumped;
};
class MessagePlayerLanded : public MessageData {
public:
MessagePlayerLanded(Netcode::ComponentID id) : playerWhoLanded(id) {}
~MessagePlayerLanded() {}
Netcode::ComponentID playerWhoLanded;
};
class MessagePlayerDied : public MessageData {
public:
MessagePlayerDied(Netcode::ComponentID id, Netcode::ComponentID killer, bool finalKill)
: playerWhoDied(id), killingEntity(killer), isFinalKill(finalKill) {}
~MessagePlayerDied() {}
Netcode::ComponentID playerWhoDied;
Netcode::ComponentID killingEntity;
bool isFinalKill;
};
class MessageCandleHeldState : public MessageData {
public:
MessageCandleHeldState(Netcode::ComponentID id, bool held, glm::vec3 pos) : candleOwnerID(id), isHeld(held), candlePos(pos) {}
~MessageCandleHeldState() {}
Netcode::ComponentID candleOwnerID;
bool isHeld;
glm::vec3 candlePos;
};
class MessageEndGameStats : public MessageData {
public:
MessageEndGameStats() {}
~MessageEndGameStats() {}
};
class MessagePrepareEndScreen : public MessageData {
public:
MessagePrepareEndScreen() {}
~MessagePrepareEndScreen() {}
private:
};
class MessageRunningMetalStart : public MessageData {
public:
MessageRunningMetalStart(Netcode::ComponentID id) : runningPlayer(id) {}
~MessageRunningMetalStart() {}
Netcode::ComponentID runningPlayer;
};
class MessageRunningTileStart : public MessageData {
public:
MessageRunningTileStart(Netcode::ComponentID id) : runningPlayer(id) {}
~MessageRunningTileStart() {}
Netcode::ComponentID runningPlayer;
};
class MessageRunningWaterMetalStart : public MessageData {
public:
MessageRunningWaterMetalStart(Netcode::ComponentID id) : runningPlayer(id) {}
~MessageRunningWaterMetalStart() {}
Netcode::ComponentID runningPlayer;
};
class MessageRunningWaterTileStart : public MessageData {
public:
MessageRunningWaterTileStart(Netcode::ComponentID id) : runningPlayer(id) {}
~MessageRunningWaterTileStart() {}
Netcode::ComponentID runningPlayer;
};
class MessageRunningStopSound : public MessageData {
public:
MessageRunningStopSound(Netcode::ComponentID id) : runningPlayer(id) {}
~MessageRunningStopSound() {}
Netcode::ComponentID runningPlayer;
};
class MessageIgniteCandle : public MessageData {
public:
MessageIgniteCandle(Netcode::ComponentID candleId) : candleCompId(candleId) {}
~MessageIgniteCandle() {}
Netcode::ComponentID candleCompId;
};
class MessageInsanityScream : public MessageData {
public:
MessageInsanityScream(Netcode::ComponentID id) : screamingPlayer(id) {}
~MessageInsanityScream() {}
Netcode::ComponentID screamingPlayer;
};
class MessageHitBySprinkler : public MessageData {
public:
MessageHitBySprinkler(Netcode::ComponentID id) : candleOwnerID(id) {}
~MessageHitBySprinkler() {}
Netcode::ComponentID candleOwnerID;
};
class MessageEnableSprinklers : public MessageData {
public:
MessageEnableSprinklers() {}
~MessageEnableSprinklers() {}
};
class MessageStartThrowing : public MessageData {
public:
MessageStartThrowing(Netcode::ComponentID id) : playerCompID(id) {}
~MessageStartThrowing() {}
Netcode::ComponentID playerCompID;
};
class MessageStopThrowing : public MessageData {
public:
MessageStopThrowing(Netcode::ComponentID id) : playerCompID(id) {}
~MessageStopThrowing() {}
Netcode::ComponentID playerCompID;
};
class MessageSetCenter : public MessageData {
public:
MessageSetCenter(Netcode::ComponentID id, glm::vec3 offset) : compID(id), centerOffset(offset) {}
~MessageSetCenter() {}
Netcode::ComponentID compID;
glm::vec3 centerOffset;
};
}
| 28.910345 | 176 | 0.760973 |
05abf4cfb0e6938c6c74d530aaa9e19d2dad5188 | 197 | h | C | Example/Pods/Target Support Files/Pods-CPConfettiViewExample/Pods-CPConfettiViewExample-umbrella.h | phuongvnc/CPConfettiViewAnimation | 00ab6beb29cb724443a65b922caf3da457c97c92 | [
"MIT"
] | 19 | 2017-03-12T04:25:23.000Z | 2022-03-22T02:48:20.000Z | Example/Pods/Target Support Files/Pods-CPConfettiViewExample/Pods-CPConfettiViewExample-umbrella.h | phuongvnc/CPConfettiViewAnimation | 00ab6beb29cb724443a65b922caf3da457c97c92 | [
"MIT"
] | null | null | null | Example/Pods/Target Support Files/Pods-CPConfettiViewExample/Pods-CPConfettiViewExample-umbrella.h | phuongvnc/CPConfettiViewAnimation | 00ab6beb29cb724443a65b922caf3da457c97c92 | [
"MIT"
] | 2 | 2018-08-13T14:08:52.000Z | 2019-03-04T13:31:06.000Z | #ifdef __OBJC__
#import <UIKit/UIKit.h>
#endif
FOUNDATION_EXPORT double Pods_CPConfettiViewExampleVersionNumber;
FOUNDATION_EXPORT const unsigned char Pods_CPConfettiViewExampleVersionString[];
| 21.888889 | 80 | 0.862944 |
9f30138b7b11820d094db9dac56b9aa698793a44 | 36,846 | c | C | sdk-6.5.20/src/bcm/dnx/oam/oam_punt_and_protection.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/src/bcm/dnx/oam/oam_punt_and_protection.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null | sdk-6.5.20/src/bcm/dnx/oam/oam_punt_and_protection.c | copslock/broadcom_cpri | 8e2767676e26faae270cf485591902a4c50cf0c5 | [
"Spencer-94"
] | null | null | null |
/** \file oam_punt_and_protection.c
*
*
* OAM punt and protection configurationprocedures for DNX.
*/
/*
* This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
*
* Copyright 2007-2020 Broadcom Inc. All rights reserved.
*/
#ifdef BSL_LOG_MODULE
#error "BSL_LOG_MODULE redefined"
#endif
#define BSL_LOG_MODULE BSL_LS_BCMDNX_OAM
/*
* Include files.
* {
*/
#include <bcm/oam.h>
#include <soc/dnx/dbal/dbal.h>
#include <soc/dnx/dnx_data/auto_generated/dnx_data_headers.h>
#include <soc/dnx/dnx_data/auto_generated/dnx_data_oam.h>
#include <soc/dnx/dnx_err_recovery_manager.h>
#include <include/bcm_int/dnx/oam/oam_punt_and_protection.h>
#include <bcm_int/common/multicast.h>
#include <bcm_int/dnx/algo/port/algo_port_mgmt.h>
#include <include/bcm_int/dnx/algo/algo_gpm.h>
#include <include/bcm_int/dnx/rx/rx_trap.h>
#include <include/bcm/types.h>
#include <src/bcm/dnx/oam/oam_oamp.h>
/*
* }
*/
/*
* Macros and defines for OAM punt and protection
* {
*/
#define DNX_OAM_TRAP_ID_MSB_MASK 0xFF00
#define DNX_OAMP_PUNT_MSB 0x400
#define NOF_PTCH_HEADER_BYTES 2
#define NOF_ITMH_HEADER_BYTES 5
#define NOF_ITMH_HEADER_BYTES_JR1 4
#define NOF_PROP_HEADER_BYTES 12
#define NOF_PROP_JR1_HEADER_BYTES 7
#define NOF_FHEI_HEADER_BYTES 5
#define NOF_3B_FHEI_HEADER_BYTES 3
#define JR2_PPC_DEFAULT 0
#define DEFAULT_PROP_TYPE 1
#define NOF_PROP_FIELDS 15
#define PROP_FIELD_VALUE_BYTE_0 0x3
#define PROP_FIELD_VALUE_BYTE_1 0x0
#define PROP_FIELD_VALUE_BYTE_2 0xfa
#define PROP_FIELD_VALUE_BYTE_3 0x7
#define PROP_FIELD_BYTE_6 6
#define PROP_FIELD_BYTE_5 5
#define PROP_JR1_FIELD_VALUE_BYTE_6 0x17
#define PROP_JR1_FIELD_VALUE 2
#define PROP_JR1_FIELD_BIT_OFFSET 4
#define PROP_JR1_FIELD_BYTE_OFFSET 6
#define OAMP_PROTECTION_PACKET_LEN 0x40
#define OAMP_PROTECTION_MAX_HEADERS_SIZE 0x50
#define OAMP_PROTECTION_HEADERS_FIRST_PART_SIZE 0x10
#define OAMP_PROTECTION_HEADERS_SECOND_PART_SIZE 0x40
#define DNX_ALGO_GPM_DESTINATION_JR1_INVALID 0x7FFFF
/*
* }
*/
/*
* Globals
* {
*/
/*
* } Globals
*/
/*
* Functions
* {
*/
/**
* \brief
* Given a gport, returns forward destination encoded by this gport.
*
* \param [in] unit -
* Relevant unit.
* \param [in] flags - one of ALGO_GPM_ENCODE_DESTINATION_XXX
* \param [in] header_mode - Can be JR1 mode or JR2 mode
* \param [in] port -
* GPORT given by user, might be port or gport.
* Supported gports - physical gports and FEC gports.
* \param [out] destination -
* DBAL encoding for destination field.
* Can be FEC/PORT/LAG/TRAP/FLOW-ID
* \return
* shr_error_e -
* Error return value
* \remark
* * None
* \see
* * None
*/
static shr_error_e
oam_algo_gpm_encode_destination_field_from_gport_with_header_mode(
int unit,
uint32 flags,
int header_mode,
bcm_gport_t port,
uint32 *destination)
{
bcm_gport_t gport;
dnx_algo_gpm_gport_phy_info_t gport_info;
SHR_FUNC_INIT_VARS(unit);
SHR_NULL_CHECK(destination, _SHR_E_PARAM, "destination");
if (header_mode == DBAL_ENUM_FVAL_SYSTEM_HEADERS_MODE_JERICHO2_MODE)
{
SHR_IF_ERR_EXIT(algo_gpm_encode_destination_field_from_gport(unit, flags, port, destination));
}
else
{
/*
* Check if gport is actually local port that is not encoded as GPORT
*/
if (BCM_GPORT_IS_SET(port))
{
gport = port;
}
else
{
SHR_IF_ERR_EXIT(dnx_algo_port_valid_verify(unit, port));
BCM_GPORT_LOCAL_SET(gport, port);
}
/*
* Set DESTINATION according to GPORT TYPE
*/
if (BCM_GPORT_IS_BLACK_HOLE(gport))
{
/*
* GPORT type is BLACK HOLE and should be dropped
*/
*destination = DNX_ALGO_GPM_DESTINATION_JR1_INVALID;
}
else if (BCM_GPORT_IS_SYSTEM_PORT(gport))
{
/*
* GPORT type is PORT
*/
/*
* Get system port from gport
*/
uint32 sys_port = BCM_GPORT_SYSTEM_PORT_ID_GET(gport);
/*
* Encode destination as system port
*/
SHR_IF_ERR_EXIT(dbal_fields_parent_field32_value_set
(unit, DBAL_FIELD_DESTINATION_JR1, DBAL_FIELD_PORT_ID, &sys_port, destination));
}
else if (BCM_GPORT_IS_LOCAL(gport) || BCM_GPORT_IS_LOCAL_CPU(gport) || BCM_GPORT_IS_MODPORT(gport))
{
/*
* GPORT type is PORT
*/
/*
* Get system port from gport
*/
SHR_IF_ERR_EXIT(dnx_algo_gpm_gport_phy_info_get
(unit, gport, DNX_ALGO_GPM_GPORT_TO_PHY_OP_RETRIVE_SYS_PORT, &gport_info));
/*
* Encode destination as system port
*/
SHR_IF_ERR_EXIT(dbal_fields_parent_field32_value_set
(unit, DBAL_FIELD_DESTINATION_JR1, DBAL_FIELD_PORT_ID, &gport_info.sys_port, destination));
}
else if (BCM_GPORT_IS_MCAST(gport))
{
/*
* GPORT is MULTICAST, Encode destination as multicast
*/
uint32 mc_id = _BCM_MULTICAST_ID_GET(BCM_GPORT_MCAST_GET(gport));
SHR_IF_ERR_EXIT(dbal_fields_parent_field32_value_set(unit, DBAL_FIELD_DESTINATION_JR1, DBAL_FIELD_MC_ID_JR1,
&mc_id, destination));
}
else
{
/*
* Unsupported GPORT type
*/
SHR_ERR_EXIT(_SHR_E_PARAM, "port is not a valid destination gport.\r\n");
}
}
exit:
SHR_FUNC_EXIT;
}
/**
* \brief
* Match an OAMP error type to a give trap type
* \param [in] unit - Unit ID
* \param [in] type - error trap type to map
* \param [in] error_type - OAMP error type
*
* \return
* shr_error - Error indication
* \remark
* * None
* \see
* * None
*/
static shr_error_e
dnx_rx_trap_type_to_oam_error_type(
int unit,
bcm_rx_trap_t type,
dbal_enum_value_field_oamp_error_type_e * error_type)
{
SHR_FUNC_INIT_VARS(unit);
SHR_NULL_CHECK(error_type, _SHR_E_PARAM, "error_type");
switch (type)
{
case bcmRxTrapOampChanTypeMissErr:
*error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_CHAN_TYPE_MISS;
break;
case bcmRxTrapOampTypeErr:
*error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_TYPE_MISS;
break;
case bcmRxTrapOampRmepErr:
*error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_EMC_MISS;
break;
case bcmRxTrapOampMaidErr:
*error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_MAID_MISS;
break;
case bcmRxTrapOampFlexCrcMissErr:
*error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_FLEX_CRC_MISS;
break;
case bcmRxTrapOampMplsLmDmErr:
*error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_RFC_PUNT;
break;
case bcmRxTrapOampMdlErr:
*error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_MDL_MISS;
break;
case bcmRxTrapOampCcmIntrvErr:
*error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_CCM_INTRVL_MISS;
break;
case bcmRxTrapOampMyDiscErr:
*error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_ERR_MY_DISC_MISS;
break;
case bcmRxTrapOampSrcIpErr:
*error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_ERR_SRC_IP_MISS;
break;
case bcmRxTrapOampYourDiscErr:
*error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_ERR_YOUR_DISC_MISS;
break;
case bcmRxTrapOampSrcPortErr:
*error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_SRC_PORT_MISS;
break;
case bcmRxTrapOampRmepStateChange:
*error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_RMEP_STATE_CHANGE;
break;
case bcmRxTrapOampParityErr:
*error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_PARITY_ERROR;
break;
case bcmRxTrapOampTimestampErr:
*error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_TIMESTAMP_MISS;
break;
case bcmRxTrapOampTrapErr:
*error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_TRAP_CODE_MISS;
break;
case bcmRxTrapOampPuntNextGoodPacket:
*error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_DEBUG;
break;
default:
/**
* Not an OAM punt/protection trap
*/
SHR_ERR_EXIT(_SHR_E_PARAM, "Not supported\n");
break;
}
exit:
SHR_FUNC_EXIT;
}
/**
* See oam_punt_and_protection.h for info
*/
shr_error_e
dnx_oam_error_trap_type_set(
int unit,
bcm_rx_trap_t type,
int trap_id_p)
{
uint32 entry_handle_id;
dbal_enum_value_field_oamp_error_type_e error_type = DBAL_ENUM_FVAL_OAMP_ERROR_TYPE_ERR_PACKET;
SHR_FUNC_INIT_VARS(unit);
DBAL_FUNC_INIT_VARS(unit);
/** Write trap to lookup table */
SHR_IF_ERR_EXIT(DBAL_HANDLE_ALLOC(unit, DBAL_TABLE_OAM_PUNT_TRAP_ID_FROM_TRAP_TYPE_SW, &entry_handle_id));
dbal_entry_key_field32_set(unit, entry_handle_id, DBAL_FIELD_TRAP_TYPE, type);
dbal_entry_value_field32_set(unit, entry_handle_id, DBAL_FIELD_PUNT_PROTECTION_TRAP_ID, INST_SINGLE, trap_id_p);
SHR_IF_ERR_EXIT(dbal_entry_commit(unit, entry_handle_id, DBAL_COMMIT));
SHR_IF_ERR_EXIT(DBAL_HANDLE_ALLOC(unit, DBAL_TABLE_OAM_ERROR_CODE_FROM_TRAP_ID_SW, &entry_handle_id));
dbal_entry_key_field32_set(unit, entry_handle_id, DBAL_FIELD_TRAP_ID, DNX_RX_TRAP_ID_TYPE_GET(trap_id_p));
if (type == bcmRxTrapOampProtection)
{
dbal_entry_value_field32_set(unit, entry_handle_id, DBAL_FIELD_IS_PROTECTION, INST_SINGLE, TRUE);
}
else
{
/** Configure OAMP_PORT */
SHR_IF_ERR_EXIT(dnx_oam_oamp_init_cpu_port_configuration(unit));
SHR_IF_ERR_EXIT(dnx_rx_trap_type_to_oam_error_type(unit, type, &error_type));
dbal_entry_value_field32_set(unit, entry_handle_id, DBAL_FIELD_OAMP_ERROR_TYPE, INST_SINGLE, error_type);
dbal_entry_value_field32_set(unit, entry_handle_id, DBAL_FIELD_IS_PROTECTION, INST_SINGLE, FALSE);
}
SHR_IF_ERR_EXIT(dbal_entry_commit(unit, entry_handle_id, DBAL_COMMIT));
exit:
DBAL_FUNC_FREE_VARS;
SHR_FUNC_EXIT;
}
/**
* See oam_punt_and_protection.h for info
*/
shr_error_e
dnx_oam_punt_and_protection_trap_create_verify(
int unit,
int flags,
bcm_rx_trap_t type,
int trap_id,
uint8 *is_oam_punt_or_protection)
{
int trap_id_msb, rv;
uint32 entry_handle_id, trap_code;
SHR_FUNC_INIT_VARS(unit);
DBAL_FUNC_INIT_VARS(unit);
*is_oam_punt_or_protection = (((type >= bcmRxTrapOampTrapErr) && (type <= bcmRxTrapOampProtection)) ||
(type == bcmRxTrapOampChanTypeMissErr) || (type == bcmRxTrapOampFlexCrcMissErr) ||
(type == bcmRxTrapOampPuntNextGoodPacket) || (type == bcmRxTrapOampMplsLmDmErr));
if (*is_oam_punt_or_protection == TRUE)
{
if (flags & BCM_RX_TRAP_WITH_ID)
{
trap_id_msb = trap_id & DNX_OAM_TRAP_ID_MSB_MASK;
if (trap_id_msb != DNX_OAMP_PUNT_MSB)
{
SHR_ERR_EXIT(_SHR_E_CONFIG, "OAMP Error traps must be in range 0x400-0x4FF");
}
}
/** Make sure this type doesn't have a trap */
SHR_IF_ERR_EXIT(DBAL_HANDLE_ALLOC(unit, DBAL_TABLE_OAM_PUNT_TRAP_ID_FROM_TRAP_TYPE_SW, &entry_handle_id));
dbal_entry_key_field32_set(unit, entry_handle_id, DBAL_FIELD_TRAP_TYPE, type);
dbal_value_field32_request(unit, entry_handle_id, DBAL_FIELD_PUNT_PROTECTION_TRAP_ID, INST_SINGLE, &trap_code);
rv = dbal_entry_get(unit, entry_handle_id, DBAL_COMMIT);
if (rv != BCM_E_NOT_FOUND)
{
SHR_IF_ERR_EXIT(rv);
if (trap_code != 0)
{
SHR_ERR_EXIT(BCM_E_PARAM, "Type already created, with trap code 0x%x", trap_code);
}
}
}
exit:
DBAL_FUNC_FREE_VARS;
SHR_FUNC_EXIT;
}
/**
* \brief
* This function builds a PTCH header according to
* global configuration, which is done on
* initialization
* \param [in] unit - Device ID
* \param [out] ptch_header - pointer to which the
* header is written
* \param [out] total_header_len - pointer to the
* cumulative header length; PTCH length is
* added to it.
* \return
* shr_error_e - Error Type
* \remark
* * None
* \see
* * None
*/
static shr_error_e
dnx_rx_trap_fill_ptch_header(
int unit,
uint8 *ptch_header,
uint32 *total_header_len)
{
uint32 pp_ssp, reserved = 0, prt_qual, ppc = JR2_PPC_DEFAULT;
uint32 ptch_header_tmp = 0;
uint32 entry_handle_id;
SHR_FUNC_INIT_VARS(unit);
DBAL_FUNC_INIT_VARS(unit);
/** Taking a handle */
SHR_IF_ERR_EXIT(DBAL_HANDLE_ALLOC(unit, DBAL_TABLE_OAMP_INIT_CPU_PORT_CFG, &entry_handle_id));
dbal_value_field32_request(unit, entry_handle_id, DBAL_FIELD_PTCH_PP_SSP, INST_SINGLE, &pp_ssp);
dbal_value_field32_request(unit, entry_handle_id, DBAL_FIELD_PRT_QUALIFIER, INST_SINGLE, &prt_qual);
/** Read the values */
SHR_IF_ERR_EXIT(dbal_entry_get(unit, entry_handle_id, DBAL_COMMIT));
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode
(unit, DBAL_FIELD_PTCH_HEADER, DBAL_FIELD_PTCH_PP_SSP, &pp_ssp, &ptch_header_tmp));
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode
(unit, DBAL_FIELD_PTCH_HEADER, DBAL_FIELD_RESERVED, &reserved, &ptch_header_tmp));
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode
(unit, DBAL_FIELD_PTCH_HEADER, DBAL_FIELD_PRT_QUALIFIER, &prt_qual, &ptch_header_tmp));
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode
(unit, DBAL_FIELD_PTCH_HEADER, DBAL_FIELD_PTCH_PARSER_PROGRAM_CONTROL, &ppc, &ptch_header_tmp));
SHR_IF_ERR_EXIT(utilex_U32_to_U8(&ptch_header_tmp, NOF_PTCH_HEADER_BYTES, ptch_header));
*total_header_len += NOF_PTCH_HEADER_BYTES;
exit:
DBAL_FUNC_FREE_VARS;
SHR_FUNC_EXIT;
}
/**
* \brief
* This function builds an ITMH header from global
* configuration, which is done on initialization
* \param [in] unit - Device ID
* \param [in] config_p - Pointer to configuration
* structure that contains the destination port
* \param [in] is_jr1_format - TRUE for Jericho1 mode,
* FALSE for Jericho 2 mode
* \param [out] itmh_header - pointer to which the
* header is written
* \param [out] total_header_len - pointer to the
* cumulative header length; ITMH length is
* added to it.
* \return
* shr_error_e - Error Type
* \remark
* * None
* \see
* * None
*/
static shr_error_e
dnx_rx_trap_fill_itmh_header(
int unit,
bcm_rx_trap_config_t * config_p,
uint8 is_jr1_format,
uint8 *itmh_header,
uint32 *total_header_len)
{
int system_headers_mode;
uint32 entry_handle_id, itmh_ext_present = 0, tc, dp, snoop_cmd = 0, in_mirr_dis = 0;
uint32 prop_type = DEFAULT_PROP_TYPE, inj_ext_present = 0, reserved = 0, num_bytes, itmh_header_tmp_len;
uint32 *itmh_header_tmp = NULL;
dbal_fields_e itmh, sub_field1, sub_field2;
uint32 destination = 0;
SHR_FUNC_INIT_VARS(unit);
DBAL_FUNC_INIT_VARS(unit);
system_headers_mode = dnx_data_headers.system_headers.system_headers_mode_get(unit);
/** Taking a handle */
SHR_IF_ERR_EXIT(DBAL_HANDLE_ALLOC(unit, DBAL_TABLE_OAMP_INIT_CPU_PORT_CFG, &entry_handle_id));
dbal_value_field32_request(unit, entry_handle_id, DBAL_FIELD_CPU_PORT_TC, INST_SINGLE, &tc);
dbal_value_field32_request(unit, entry_handle_id, DBAL_FIELD_CPU_PORT_DP, INST_SINGLE, &dp);
/** Read the values */
SHR_IF_ERR_EXIT(dbal_entry_get(unit, entry_handle_id, DBAL_COMMIT));
if (is_jr1_format)
{
num_bytes = NOF_ITMH_HEADER_BYTES_JR1;
itmh = DBAL_FIELD_ITMH_BASE_JR1;
sub_field1 = DBAL_FIELD_ITMH_DEST_INFO_EXTENSION_EXISTS;
sub_field2 = DBAL_FIELD_SNOOP_CMD;
}
else
{
num_bytes = NOF_ITMH_HEADER_BYTES;
itmh = DBAL_FIELD_ITMH_BASE;
sub_field1 = DBAL_FIELD_ITMH_EXTENSION_PRESENT;
sub_field2 = DBAL_FIELD_SNIF_COMMAND_ID;
}
itmh_header_tmp_len = ((num_bytes - 1) / sizeof(uint32) + 1) * sizeof(uint32);
SHR_ALLOC_SET_ZERO(itmh_header_tmp, itmh_header_tmp_len, "ITMH header for OAM protection",
"%s%s%s\r\n", EMPTY, EMPTY, EMPTY);
if (!is_jr1_format)
{
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode
(unit, itmh, DBAL_FIELD_INJECTED_AS_EXTENSION_PRESENT, &inj_ext_present, itmh_header_tmp));
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode(unit, itmh, DBAL_FIELD_RESERVED, &reserved, itmh_header_tmp));
}
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode(unit, itmh, sub_field1, &itmh_ext_present, itmh_header_tmp));
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode(unit, itmh, DBAL_FIELD_TC, &tc, itmh_header_tmp));
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode(unit, itmh, sub_field2, &snoop_cmd, itmh_header_tmp));
SHR_IF_ERR_EXIT(oam_algo_gpm_encode_destination_field_from_gport_with_header_mode
(unit, ALGO_GPM_ENCODE_DESTINATION_FLAGS_NONE, system_headers_mode, config_p->dest_port,
&destination));
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode(unit, itmh, DBAL_FIELD_DESTINATION, &destination, itmh_header_tmp));
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode(unit, itmh, DBAL_FIELD_DP, &dp, itmh_header_tmp));
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode
(unit, itmh, DBAL_FIELD_INBOUND_MIRROR_DISABLE, &in_mirr_dis, itmh_header_tmp));
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode(unit, itmh, DBAL_FIELD_PPH_TYPE, &prop_type, itmh_header_tmp));
SHR_IF_ERR_EXIT(utilex_U32_to_U8(itmh_header_tmp, num_bytes, itmh_header));
*total_header_len += num_bytes;
SHR_FREE(itmh_header_tmp);
exit:
DBAL_FUNC_FREE_VARS;
SHR_FUNC_EXIT;
}
/**
* \brief
* This function builds a JR2 format proprietary header
* from global configuration, which is done on
* initialization
* \param [in] unit - Device ID
* \param [out] prop_header - pointer to which the
* header is written
* \param [out] total_header_len - pointer to the
* cumulative header length; proprietary header
* length is added to it.
* \return
* None
* \remark
* * None
* \see
* * None
*/
static void
dnx_rx_trap_fill_prop_header(
int unit,
uint8 *prop_header,
uint32 *total_header_len)
{
sal_memset(prop_header, 0, NOF_PROP_HEADER_BYTES);
prop_header[0] = PROP_FIELD_VALUE_BYTE_0;
prop_header[1] = PROP_FIELD_VALUE_BYTE_1;
prop_header[2] = PROP_FIELD_VALUE_BYTE_2;
prop_header[3] = PROP_FIELD_VALUE_BYTE_3;
*total_header_len += NOF_PROP_HEADER_BYTES;
}
/**
* \brief
* This function builds a JR1 format proprietary header
* from global configuration, which is done on
* initialization
* \param [in] unit - Device ID
* \param [out] prop_header - pointer to which the
* header is written
* \param [in] udh_size - User defined header length
* \param [out] total_header_len - pointer to the
* cumulative header length; proprietary header
* length is added to it.
* \return
* None
* \remark
* * None
* \see
* * None
*/
static void
dnx_rx_trap_fill_jr1_prop_header(
int unit,
uint8 *prop_header,
uint32 udh_size,
uint32 *total_header_len)
{
sal_memset(prop_header, 0, NOF_PROP_JR1_HEADER_BYTES);
prop_header[PROP_FIELD_BYTE_6] = PROP_JR1_FIELD_VALUE_BYTE_6;
prop_header[PROP_FIELD_BYTE_5] = udh_size << 1;
*total_header_len += NOF_PROP_JR1_HEADER_BYTES;
}
/**
* \brief
* This function builds a 5-byte trap/snoop JR2
* format FHEI header from global configuration,
* which is done on initialization
* \param [in] unit - Device ID
* \param [in] trap_type - ID of trap to put in header
* \param [out] fhei_header - pointer to which the
* header is written
* \param [out] total_header_len - pointer to the
* cumulative header length; ITMH length is
* added to it.
* \return
* shr_error_e - Error Type
* \remark
* * None
* \see
* * None
*/
static shr_error_e
dnx_rx_trap_fill_fhei_header(
int unit,
int trap_type,
uint8 *fhei_header,
uint32 *total_header_len)
{
uint32 trap_code = trap_type, qualifier = 0, fhei_type = DBAL_ENUM_FVAL_FHEI_TYPE_TRAP_SNOOP;
uint32 fhei_header_tmp[(NOF_FHEI_HEADER_BYTES - 1) / sizeof(uint32) + 1] = { 0 };
SHR_FUNC_INIT_VARS(unit);
sal_memset(fhei_header_tmp, 0, sizeof(fhei_header_tmp));
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode
(unit, DBAL_FIELD_FHEI_5B_TRAP_SNIFF, DBAL_FIELD_FHEI_TYPE, &fhei_type, fhei_header_tmp));
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode
(unit, DBAL_FIELD_FHEI_5B_TRAP_SNIFF, DBAL_FIELD_CODE, &trap_code, fhei_header_tmp));
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode
(unit, DBAL_FIELD_FHEI_5B_TRAP_SNIFF, DBAL_FIELD_QUALIFIER, &qualifier, fhei_header_tmp));
SHR_IF_ERR_EXIT(utilex_U32_to_U8(fhei_header_tmp, NOF_FHEI_HEADER_BYTES, fhei_header));
*total_header_len += NOF_FHEI_HEADER_BYTES;
exit:
SHR_FUNC_EXIT;
}
/**
* \brief
* This function builds a 3-byte trap/snoop JR1
* format FHEI header from global configuration,
* which is done on initialization
* \param [in] unit - Device ID
* \param [in] trap_type - ID of trap to put in header
* \param [out] fhei_header - pointer to which the
* header is written
* \param [out] total_header_len - pointer to the
* cumulative header length; ITMH length is
* added to it.
* \return
* shr_error_e - Error Type
* \remark
* * None
* \see
* * None
*/
static shr_error_e
dnx_rx_trap_fill_jr1_fhei_header(
int unit,
int trap_type,
uint8 *fhei_header,
uint32 *total_header_len)
{
uint32 trap_code = trap_type, qualifier = 0;
uint32 fhei_header_dword[NOF_3B_FHEI_HEADER_BYTES / sizeof(uint32) + 1] = { 0 };
SHR_FUNC_INIT_VARS(unit);
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode
(unit, DBAL_FIELD_FHEI_3B_TRAP_JR1, DBAL_FIELD_CPU_TRAP_CODE_JR1, &trap_code, fhei_header_dword));
SHR_IF_ERR_EXIT(dbal_fields_struct_field_encode
(unit, DBAL_FIELD_FHEI_3B_TRAP_JR1, DBAL_FIELD_CPU_TRAP_CODE_QUALIFIER, &qualifier,
fhei_header_dword));
SHR_IF_ERR_EXIT(utilex_U32_to_U8(fhei_header_dword, NOF_3B_FHEI_HEADER_BYTES, fhei_header));
*total_header_len += NOF_3B_FHEI_HEADER_BYTES;
exit:
SHR_FUNC_EXIT;
}
/**
* See oam_punt_and_protection.h for info
*/
shr_error_e
dnx_oam_error_trap_set(
int unit,
int trap_type,
bcm_rx_trap_config_t * config_p)
{
int system_headers_mode;
uint32 entry_handle_id, total_header_len = 0, destination;
uint8 ptch_header[NOF_PTCH_HEADER_BYTES], itmh_header[NOF_ITMH_HEADER_BYTES] =
{ 0 }, prop_header[NOF_PROP_HEADER_BYTES] =
{
0}, fhei_header[NOF_FHEI_HEADER_BYTES] =
{
0};
uint32 ptch_header_size, itmh_header_size, prop_header_size, fhei_header_size, back_offset;
uint8 headers[OAMP_PROTECTION_HEADERS_SECOND_PART_SIZE] = { 0 };
uint8 zeros[OAMP_PROTECTION_HEADERS_FIRST_PART_SIZE] = { 0 };
uint8 oamp_tx_format, jr1_format, is_format_jr1;
dbal_enum_value_field_oamp_error_type_e error_type;
uint32 is_protection;
uint32 udh_size = 0;
SHR_FUNC_INIT_VARS(unit);
DBAL_FUNC_INIT_VARS(unit);
system_headers_mode = dnx_data_headers.system_headers.system_headers_mode_get(unit);
if (system_headers_mode == dnx_data_headers.system_headers.system_headers_mode_jericho_get(unit))
{
udh_size = BITS2BYTES(dnx_data_field.udh.field_class_id_size_0_get(unit));
udh_size += BITS2BYTES(dnx_data_field.udh.field_class_id_size_1_get(unit));
udh_size += BITS2BYTES(dnx_data_field.udh.field_class_id_size_2_get(unit));
udh_size += BITS2BYTES(dnx_data_field.udh.field_class_id_size_3_get(unit));
}
SHR_IF_ERR_EXIT(DBAL_HANDLE_ALLOC(unit, DBAL_TABLE_OAM_ERROR_CODE_FROM_TRAP_ID_SW, &entry_handle_id));
dbal_entry_key_field32_set(unit, entry_handle_id, DBAL_FIELD_TRAP_ID, trap_type);
dbal_value_field32_request(unit, entry_handle_id, DBAL_FIELD_OAMP_ERROR_TYPE, INST_SINGLE, &error_type);
dbal_value_field32_request(unit, entry_handle_id, DBAL_FIELD_IS_PROTECTION, INST_SINGLE, &is_protection);
SHR_IF_ERR_EXIT(dbal_entry_get(unit, entry_handle_id, DBAL_COMMIT));
if (is_protection == TRUE)
{
/** Protection trap */
oamp_tx_format = dnx_data_headers.system_headers.system_headers_mode_get(unit);
jr1_format = dnx_data_headers.system_headers.system_headers_mode_jericho_get(unit);
/** PTCH header is the same for JR1 and JR2 */
SHR_IF_ERR_EXIT(dnx_rx_trap_fill_ptch_header(unit, ptch_header, &total_header_len));
is_format_jr1 = (oamp_tx_format == jr1_format);
SHR_IF_ERR_EXIT(dnx_rx_trap_fill_itmh_header(unit, config_p, is_format_jr1, itmh_header, &total_header_len));
if (oamp_tx_format == jr1_format)
{
/** Jericho 1 headers */
dnx_rx_trap_fill_jr1_prop_header(unit, prop_header, udh_size, &total_header_len);
SHR_IF_ERR_EXIT(dnx_rx_trap_fill_jr1_fhei_header(unit, trap_type, fhei_header, &total_header_len));
total_header_len += udh_size;
}
else
{
/** Jericho 2 headers */
dnx_rx_trap_fill_prop_header(unit, prop_header, &total_header_len);
SHR_IF_ERR_EXIT(dnx_rx_trap_fill_fhei_header(unit, trap_type, fhei_header, &total_header_len));
}
ptch_header_size = NOF_PTCH_HEADER_BYTES;
itmh_header_size = is_format_jr1 ? NOF_ITMH_HEADER_BYTES_JR1 : NOF_ITMH_HEADER_BYTES;
prop_header_size = is_format_jr1 ? NOF_PROP_JR1_HEADER_BYTES : NOF_PROP_HEADER_BYTES;
fhei_header_size = is_format_jr1 ? NOF_3B_FHEI_HEADER_BYTES : NOF_FHEI_HEADER_BYTES;
back_offset = ptch_header_size;
sal_memcpy(headers + sizeof(headers) - back_offset, ptch_header, ptch_header_size);
back_offset += itmh_header_size;
sal_memcpy(headers + sizeof(headers) - back_offset, itmh_header, itmh_header_size);
back_offset += prop_header_size;
sal_memcpy(headers + sizeof(headers) - back_offset, prop_header, prop_header_size);
back_offset += fhei_header_size;
sal_memcpy(headers + sizeof(headers) - back_offset, fhei_header, fhei_header_size);
if (total_header_len > OAMP_PROTECTION_PACKET_LEN)
{
SHR_ERR_EXIT(_SHR_E_CONFIG, "OAMP total header length is greater than OAMP_PROTECTION_PACKET_LEN(64)");
}
SHR_IF_ERR_EXIT(DBAL_HANDLE_ALLOC(unit, DBAL_TABLE_OAMP_PROTECTION_PACKET_HEADER, &entry_handle_id));
dbal_entry_value_field_arr8_set(unit, entry_handle_id, DBAL_FIELD_PROTECTION_PACKET_HEADER_PART_2, INST_SINGLE,
headers);
dbal_entry_value_field_arr8_set(unit, entry_handle_id, DBAL_FIELD_PROTECTION_PACKET_HEADER_PART_1, INST_SINGLE,
zeros);
dbal_entry_value_field32_set(unit, entry_handle_id, DBAL_FIELD_PROTECTION_PACKET_LEN, INST_SINGLE,
OAMP_PROTECTION_PACKET_LEN);
SHR_IF_ERR_EXIT(dbal_entry_commit(unit, entry_handle_id, DBAL_COMMIT));
}
else
{
if (!dnx_data_oam.oamp.punt_packet_itmh_destination_full_encoding_supported_get(unit)
&& (BCM_GPORT_IS_UCAST_QUEUE_GROUP(config_p->dest_port)
|| BCM_GPORT_IS_MCAST_QUEUE_GROUP(config_p->dest_port) || BCM_GPORT_IS_MCAST(config_p->dest_port)))
{
SHR_ERR_EXIT(_SHR_E_CONFIG, "Destination port could not be FLOW-ID or MC-ID in JR2_A0/B0");
}
/** Punt trap */
SHR_IF_ERR_EXIT(DBAL_HANDLE_ALLOC
(unit, DBAL_TABLE_OAMP_PUNT_PACKET_TRAP_CODES_AND_DESTINATIONS, &entry_handle_id));
dbal_entry_key_field32_set(unit, entry_handle_id, DBAL_FIELD_OAMP_ERROR_TYPE, error_type);
SHR_IF_ERR_EXIT(oam_algo_gpm_encode_destination_field_from_gport_with_header_mode
(unit, ALGO_GPM_ENCODE_DESTINATION_FLAGS_NONE, system_headers_mode, config_p->dest_port,
&destination));
dbal_entry_value_field32_set(unit, entry_handle_id, DBAL_FIELD_OAMP_DESTINATION, INST_SINGLE, destination);
dbal_entry_value_field32_set(unit, entry_handle_id, DBAL_FIELD_OAMP_TRAP_CODE, INST_SINGLE, trap_type);
SHR_IF_ERR_EXIT(dbal_entry_commit(unit, entry_handle_id, DBAL_COMMIT));
}
exit:
DBAL_FUNC_FREE_VARS;
SHR_FUNC_EXIT;
}
/**
* See oam_punt_and_protection.h for info
*/
shr_error_e
dnx_oam_error_trap_get(
int unit,
int trap_type,
bcm_rx_trap_config_t * config_p)
{
uint32 entry_handle_id, error_type, is_protection, dest_encoded;
SHR_FUNC_INIT_VARS(unit);
DBAL_FUNC_INIT_VARS(unit);
SHR_IF_ERR_EXIT(DBAL_HANDLE_ALLOC(unit, DBAL_TABLE_OAM_ERROR_CODE_FROM_TRAP_ID_SW, &entry_handle_id));
dbal_entry_key_field32_set(unit, entry_handle_id, DBAL_FIELD_TRAP_ID, trap_type);
dbal_value_field32_request(unit, entry_handle_id, DBAL_FIELD_OAMP_ERROR_TYPE, INST_SINGLE, &error_type);
dbal_value_field32_request(unit, entry_handle_id, DBAL_FIELD_IS_PROTECTION, INST_SINGLE, &is_protection);
SHR_IF_ERR_EXIT(dbal_entry_get(unit, entry_handle_id, DBAL_COMMIT));
if (is_protection == FALSE)
{
/** Punt trap */
SHR_IF_ERR_EXIT(DBAL_HANDLE_ALLOC
(unit, DBAL_TABLE_OAMP_PUNT_PACKET_TRAP_CODES_AND_DESTINATIONS, &entry_handle_id));
dbal_entry_key_field32_set(unit, entry_handle_id, DBAL_FIELD_OAMP_ERROR_TYPE, error_type);
dbal_value_field32_request(unit, entry_handle_id, DBAL_FIELD_OAMP_DESTINATION, INST_SINGLE, &dest_encoded);
SHR_IF_ERR_EXIT(dbal_entry_get(unit, entry_handle_id, DBAL_COMMIT));
SHR_IF_ERR_EXIT(algo_gpm_gport_from_encoded_destination_field(unit, ALGO_GPM_ENCODE_DESTINATION_FLAGS_NONE,
dest_encoded, &config_p->dest_port));
}
exit:
DBAL_FUNC_FREE_VARS;
SHR_FUNC_EXIT;
}
/**
* See oam_punt_and_protection.h for info
*/
shr_error_e
dnx_oam_error_trap_destroy(
int unit,
int trap_type)
{
uint32 entry_handle_id, trap_code;
int rv, index, num_seq_traps, num_non_seq_traps, total_traps;
bcm_rx_trap_t trap_types[] = { bcmRxTrapOampChanTypeMissErr, bcmRxTrapOampFlexCrcMissErr,
bcmRxTrapOampPuntNextGoodPacket, bcmRxTrapOampMplsLmDmErr
};
bcm_rx_trap_t type;
SHR_FUNC_INIT_VARS(unit);
DBAL_FUNC_INIT_VARS(unit);
SHR_IF_ERR_EXIT(DBAL_HANDLE_ALLOC(unit, DBAL_TABLE_OAM_ERROR_CODE_FROM_TRAP_ID_SW, &entry_handle_id));
dbal_entry_key_field32_set(unit, entry_handle_id, DBAL_FIELD_TRAP_ID, trap_type);
SHR_IF_ERR_EXIT(dbal_entry_clear(unit, entry_handle_id, DBAL_COMMIT));
SHR_IF_ERR_EXIT(DBAL_HANDLE_FREE(unit, entry_handle_id));
/** Same trap may be used for multiple punt reasons, so check all of them */
/** How many traps have sequential numbers? */
num_seq_traps = bcmRxTrapOampProtection - bcmRxTrapOampTrapErr + 1;
/** How many traps have numbers not in sequence? */
num_non_seq_traps = sizeof(trap_types) / sizeof(bcm_rx_trap_t);
/** How many total traps? */
total_traps = num_seq_traps + num_non_seq_traps;
for (index = 0; index < total_traps; index++)
{
/** Which trap are we looking up? */
if (index < num_seq_traps)
{
/** Sequential trap */
type = bcmRxTrapOampTrapErr + index;
}
else
{
/** Non sequential trap */
type = trap_types[index - num_seq_traps];
}
SHR_IF_ERR_EXIT(DBAL_HANDLE_ALLOC(unit, DBAL_TABLE_OAM_PUNT_TRAP_ID_FROM_TRAP_TYPE_SW, &entry_handle_id));
dbal_entry_key_field32_set(unit, entry_handle_id, DBAL_FIELD_TRAP_TYPE, type);
dbal_value_field32_request(unit, entry_handle_id, DBAL_FIELD_PUNT_PROTECTION_TRAP_ID, INST_SINGLE, &trap_code);
rv = dbal_entry_get(unit, entry_handle_id, DBAL_COMMIT);
if (rv != BCM_E_NOT_FOUND)
{
SHR_IF_ERR_EXIT(rv);
if (trap_code == trap_type)
{
SHR_IF_ERR_EXIT(dbal_entry_clear(unit, entry_handle_id, DBAL_COMMIT));
}
}
SHR_IF_ERR_EXIT(DBAL_HANDLE_FREE(unit, entry_handle_id));
}
exit:
DBAL_FUNC_FREE_VARS;
SHR_FUNC_EXIT;
}
/**
* \brief
* Configure the parameters for protection packets generated
* by the OAMP.
* \param [in] unit - Relevant unit.
* \param [in] packet_header - Pointer to the structure,
* containing information about the protection packet header.
*
* \retval
* shr_error - Error indication
* \remark
* * None
* \see
* * None
*/
shr_error_e
bcm_dnx_oam_protection_packet_header_set(
int unit,
bcm_pkt_blk_t * packet_header)
{
int index;
uint8 *first_part = NULL, *second_part = NULL;
uint32 entry_handle_id;
SHR_FUNC_INIT_VARS(unit);
DNX_ERR_RECOVERY_NOT_NEEDED(unit);
DBAL_FUNC_INIT_VARS(unit);
SHR_ALLOC_SET_ZERO(first_part, OAMP_PROTECTION_HEADERS_FIRST_PART_SIZE, "Array for over 32-bit dbal fields",
"%s%s%s\r\n", EMPTY, EMPTY, EMPTY);
SHR_ALLOC_SET_ZERO(second_part, OAMP_PROTECTION_HEADERS_SECOND_PART_SIZE, "Array for over 32-bit dbal fields",
"%s%s%s\r\n", EMPTY, EMPTY, EMPTY);
if (packet_header->len > OAMP_PROTECTION_MAX_HEADERS_SIZE)
{
SHR_ERR_EXIT(_SHR_E_PARAM,
"Illegal OAMP protection packet header length. Value provided is %d, maximum is %d\n",
packet_header->len, OAMP_PROTECTION_MAX_HEADERS_SIZE);
}
/** Taking a handle */
SHR_IF_ERR_EXIT(DBAL_HANDLE_ALLOC(unit, DBAL_TABLE_OAMP_PROTECTION_PACKET_HEADER, &entry_handle_id));
/*
* Configure protection packet headers by starting
* from the LSB of PROTECTION_PACKET_HEADER_PART_2
*/
for (index = 0; index < packet_header->len; ++index)
{
if (index < OAMP_PROTECTION_HEADERS_SECOND_PART_SIZE)
{
/** Beginning of header goes in part 2 */
second_part[OAMP_PROTECTION_HEADERS_SECOND_PART_SIZE - index - 1] = packet_header->data[index];
}
else
{
/** If length is more than 64 bytes, remainder goes in part 1 */
first_part[OAMP_PROTECTION_MAX_HEADERS_SIZE - index - 1] = packet_header->data[index];
}
}
dbal_entry_value_field_arr8_set(unit, entry_handle_id, DBAL_FIELD_PROTECTION_PACKET_HEADER_PART_2, INST_SINGLE,
second_part);
dbal_entry_value_field_arr8_set(unit, entry_handle_id, DBAL_FIELD_PROTECTION_PACKET_HEADER_PART_1, INST_SINGLE,
first_part);
/** Length of header */
dbal_entry_value_field32_set(unit, entry_handle_id, DBAL_FIELD_PROTECTION_PACKET_LEN, INST_SINGLE,
packet_header->len);
/** Commit table values */
SHR_IF_ERR_EXIT(dbal_entry_commit(unit, entry_handle_id, DBAL_COMMIT));
exit:
SHR_FREE(first_part);
SHR_FREE(second_part);
DBAL_FUNC_FREE_VARS;
SHR_FUNC_EXIT;
}
/**
* See oam_punt_and_protection.h for info
*/
shr_error_e
dnx_oam_get_punt_protection_trap_from_type(
int unit,
bcm_rx_trap_t type,
int *trap_id_p)
{
uint32 entry_handle_id, trap_id;
dbal_enum_value_field_oamp_error_type_e error_type;
SHR_FUNC_INIT_VARS(unit);
DBAL_FUNC_INIT_VARS(unit);
SHR_IF_ERR_EXIT(dnx_rx_trap_type_to_oam_error_type(unit, type, &error_type));
SHR_IF_ERR_EXIT(DBAL_HANDLE_ALLOC(unit, DBAL_TABLE_OAMP_PUNT_PACKET_TRAP_CODES_AND_DESTINATIONS, &entry_handle_id));
dbal_entry_key_field32_set(unit, entry_handle_id, DBAL_FIELD_OAMP_ERROR_TYPE, error_type);
dbal_value_field32_request(unit, entry_handle_id, DBAL_FIELD_OAMP_TRAP_CODE, INST_SINGLE, &trap_id);
SHR_IF_ERR_EXIT(dbal_entry_get(unit, entry_handle_id, DBAL_COMMIT));
*trap_id_p = trap_id | DNX_OAMP_PUNT_MSB;
exit:
DBAL_FUNC_FREE_VARS;
SHR_FUNC_EXIT;
}
/*
* }
*/
| 33.772686 | 134 | 0.69823 |
bf3c4827dee9bfcae7dcc3bb39062e7fed130aae | 214 | c | C | chapter6/ex3.c | basstal/CPrimerPlus | a90c1c78748d9ae8eb788222bfde9d51aa2ae702 | [
"MIT"
] | null | null | null | chapter6/ex3.c | basstal/CPrimerPlus | a90c1c78748d9ae8eb788222bfde9d51aa2ae702 | [
"MIT"
] | null | null | null | chapter6/ex3.c | basstal/CPrimerPlus | a90c1c78748d9ae8eb788222bfde9d51aa2ae702 | [
"MIT"
] | null | null | null | /**
使用嵌套循环产生下列图案:
F
FE
FED
FEDC
FEDCB
FEDCBA
*/
#include <stdio.h>
int main(void)
{
for(char ed = 'F' ; ed >= 'A' ; --ed)
{
for(char c = 'F' ; c >= ed ; --c)
printf("%c",c);
printf("\n");
}
return 0;
} | 9.727273 | 38 | 0.5 |
c9d538190b71898d7dcf7d4c66a46590c76b307b | 1,983 | h | C | components/drivers/peripheral/adc/include/aos/adc_core.h | wstong999/AliOS-Things | 6554769cb5b797e28a30a4aa89b3f4cb2ef2f5d9 | [
"Apache-2.0"
] | 4,538 | 2017-10-20T05:19:03.000Z | 2022-03-30T02:29:30.000Z | components/drivers/peripheral/adc/include/aos/adc_core.h | wstong999/AliOS-Things | 6554769cb5b797e28a30a4aa89b3f4cb2ef2f5d9 | [
"Apache-2.0"
] | 1,088 | 2017-10-21T07:57:22.000Z | 2022-03-31T08:15:49.000Z | components/drivers/peripheral/adc/include/aos/adc_core.h | wstong999/AliOS-Things | 6554769cb5b797e28a30a4aa89b3f4cb2ef2f5d9 | [
"Apache-2.0"
] | 1,860 | 2017-10-20T05:22:35.000Z | 2022-03-27T10:54:14.000Z | /*
* Copyright (C) 2021 Alibaba Group Holding Limited
*/
#ifndef _AOS_ADC_CORE_H
#define _AOS_ADC_CORE_H
#include <stdint.h>
#include <aos/kernel.h>
#include <aos/device_core.h>
#include <aos/adc.h>
/** @defgroup driver_api driver
* @ingroup aos_components
* @{
*/
/** @} */
/**
* @defgroup aos_adc_driver ADC驱动操作
* @ingroup driver_api
* 给ADC驱动提供ADC设备注册/注销操作.
*
* @{
*/
struct aos_adc_ops;
typedef struct aos_adc {
aos_dev_t dev;
const struct aos_adc_ops *ops; /**< ADC设备的底层操作, 设备注册前必须赋值 */
uint32_t resolution; /**< ADC设备分辨率(单位:bits), 设备注册前必须赋值 */
uint32_t freq; /**< ADC设备时钟频率(单位:HZ), 设备注册前必须赋值 */
void *priv; /**< 私有数据 */
} aos_adc_t;
typedef struct aos_adc_ops {
/**< ADC设备的注销操作(可选) */
void (*unregister)(aos_adc_t *adc);
/**< ADC设备的开始采样 */
aos_status_t (*startup)(aos_adc_t *adc);
/**< ADC设备的停止采样 */
void (*shutdown)(aos_adc_t *adc);
/**< 读取ADC设备的原始数据 */
aos_status_t (*read)(aos_adc_t *adc, int32_t channel, int32_t *data);
/**< 读取ADC设备的转换后的电压值(单位: mV)*/
aos_status_t (*read_voltage)(aos_adc_t *adc, int32_t channel, int32_t *data);
/**< 设置ADC设备的通道(开启与关闭)(可选)*/
aos_status_t (*set_channel)(aos_adc_t *adc, int32_t channel, bool enable);
/**< 设置ADC设备的采样时间(单位: 时钟周期的倍数)(可选)*/
aos_status_t (*set_sample_time)(aos_adc_t *adc, int32_t channel, uint32_t clock);
/**< 设置ADC设备的工作模式(可选)*/
aos_status_t (*set_mode)(aos_adc_t *adc, aos_adc_mode_t clock);
/**< 获取ADC设备的电压量程 */
aos_status_t (*get_range)(aos_adc_t *adc, int32_t channel, int32_t *range);
} aos_adc_ops_t;
#ifdef __cplusplus
extern "C" {
#endif
/**
* 注册一个ADC设备
*
* @param[in] adc 要注册的ADC设备,调用者应该分配内存并初始化设置它的ID
*
* @return 0: 成功; <0: 失败
*/
aos_status_t aos_adc_register(aos_adc_t *adc);
/**
* 注销一个ADC设备
*
* @param[in] id ADC设备的ID
*
* @return 0: 成功; <0: 失败
*/
aos_status_t aos_adc_unregister(uint32_t id);
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* _AOS_ADC_CORE_H */
| 22.534091 | 85 | 0.65053 |
a7e78ef49f461f10a1a9fd2ffbb4986c9698a36f | 6,712 | c | C | sys/src/cmd/gs/zimage2.c | Plan9-Archive/plan9-2e | ce6d0434246216e848babe4f56919dc28981ad04 | [
"MIT"
] | 1 | 2021-03-23T22:40:43.000Z | 2021-03-23T22:40:43.000Z | sys/src/cmd/gs/zimage2.c | Plan9-Archive/plan9-2e | ce6d0434246216e848babe4f56919dc28981ad04 | [
"MIT"
] | null | null | null | sys/src/cmd/gs/zimage2.c | Plan9-Archive/plan9-2e | ce6d0434246216e848babe4f56919dc28981ad04 | [
"MIT"
] | 1 | 2021-12-21T06:19:58.000Z | 2021-12-21T06:19:58.000Z | /* Copyright (C) 1992, 1994 Aladdin Enterprises. All rights reserved.
This file is part of Aladdin Ghostscript.
Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author
or distributor accepts any responsibility for the consequences of using it,
or for whether it serves any particular purpose or works at all, unless he
or she says so in writing. Refer to the Aladdin Ghostscript Free Public
License (the "License") for full details.
Every copy of Aladdin Ghostscript must include a copy of the License,
normally in a plain ASCII text file named PUBLIC. The License grants you
the right to copy, modify and redistribute Aladdin Ghostscript, but only
under certain conditions described in the License. Among other things, the
License requires that the copyright notice and this notice be preserved on
all copies.
*/
/* zimage2.c */
/* image operator extensions for Level 2 PostScript */
#include "math_.h"
#include "memory_.h"
#include "ghost.h"
#include "errors.h"
#include "oper.h"
#include "gscolor.h"
#include "gscspace.h"
#include "gscolor2.h"
#include "gsmatrix.h"
#include "idict.h"
#include "idparam.h"
#include "ilevel.h"
#include "igstate.h" /* for igs */
/* Imported from zpaint.c */
extern int zimage_setup(P11(int width, int height, gs_matrix *pmat,
ref *sources, int bits_per_component,
bool multi, const gs_color_space *pcs, int masked,
const float *decode, bool interpolate, int npop));
extern int zimage(P1(os_ptr));
extern int zimagemask(P1(os_ptr));
/* Define a structure for acquiring image parameters. */
typedef struct image_params_s {
int Width;
int Height;
gs_matrix ImageMatrix;
bool MultipleDataSources;
ref DataSource[4];
int BitsPerComponent;
float Decode[2*4];
const float *pDecode;
bool Interpolate;
} image_params;
/* Common code for unpacking an image dictionary. */
/* Assume *op is a dictionary. */
private int
image_dict_unpack(os_ptr op, image_params *pip, int max_bits_per_component)
{ int code;
int num_components;
int decode_size;
ref *pds;
check_dict_read(*op);
num_components = gs_currentcolorspace(igs)->type->num_components;
if ( num_components < 1 )
return_error(e_rangecheck);
if ( max_bits_per_component == 1 ) /* imagemask */
num_components = 1; /* for Decode */
if ( (code = dict_int_param(op, "ImageType", 1, 1, 1,
&code)) < 0 ||
(code = dict_int_param(op, "Width", 0, 0x7fff, -1,
&pip->Width)) < 0 ||
(code = dict_int_param(op, "Height", 0, 0x7fff, -1,
&pip->Height)) < 0 ||
(code = dict_matrix_param(op, "ImageMatrix",
&pip->ImageMatrix)) < 0 ||
(code = dict_bool_param(op, "MultipleDataSources", false,
&pip->MultipleDataSources)) < 0 ||
(code = dict_int_param(op, "BitsPerComponent", 0,
max_bits_per_component, -1,
&pip->BitsPerComponent)) < 0 ||
(code = decode_size = dict_float_array_param(op, "Decode",
num_components * 2,
&pip->Decode[0], NULL)) < 0 ||
(code = dict_bool_param(op, "Interpolate", false,
&pip->Interpolate)) < 0
)
return code;
if ( decode_size == 0 )
pip->pDecode = 0;
else if ( decode_size != num_components * 2 )
return_error(e_rangecheck);
else
pip->pDecode = &pip->Decode[0];
/* Extract and check the data sources. */
if ( (code = dict_find_string(op, "DataSource", &pds)) < 0 )
return code;
if ( pip->MultipleDataSources )
{ check_type_only(*pds, t_array);
if ( r_size(pds) != num_components )
return_error(e_rangecheck);
memcpy(&pip->DataSource[0], pds->value.refs, sizeof(ref) * num_components);
}
else
pip->DataSource[0] = *pds;
return 0;
}
/* (<width> <height> <bits/sample> <matrix> <datasrc> image -) */
/* <dict> image - */
int
z2image(register os_ptr op)
{ if ( level2_enabled )
{ check_op(1);
if ( r_has_type(op, t_dictionary) )
{ image_params ip;
int code = image_dict_unpack(op, &ip, 12);
if ( code < 0 )
return code;
return zimage_setup(ip.Width, ip.Height,
&ip.ImageMatrix,
&ip.DataSource[0],
ip.BitsPerComponent,
ip.MultipleDataSources,
gs_currentcolorspace(igs),
0, ip.pDecode, ip.Interpolate, 1);
}
}
/* Level 1 image operator */
check_op(5);
return zimage(op);
}
/* (<width> <height> <paint_1s> <matrix> <datasrc> imagemask -) */
/* <dict> imagemask - */
int
z2imagemask(register os_ptr op)
{ if ( level2_enabled )
{ check_op(1);
if ( r_has_type(op, t_dictionary) )
{ image_params ip;
gs_color_space cs;
int code = image_dict_unpack(op, &ip, 1);
if ( code < 0 )
return code;
if ( ip.MultipleDataSources )
return_error(e_rangecheck);
cs.type = &gs_color_space_type_DeviceGray;
return zimage_setup(ip.Width, ip.Height,
&ip.ImageMatrix,
&ip.DataSource[0], 1, false, &cs,
1, ip.pDecode, ip.Interpolate, 1);
}
}
/* Level 1 imagemask operator */
check_op(5);
return zimagemask(op);
}
/* ------ Experimental code ------ */
#include "gsiscale.h"
#include "ialloc.h"
/* <indata> <w> <h> <mat> <outdata> .scaleimage - */
/* Rescale an image represented as an array of bytes (representing values */
/* in the range [0..1]) using filtering. */
private int
zscaleimage(os_ptr op)
{ const_os_ptr rin = op - 4;
const_os_ptr rout = op;
gs_matrix mat;
int code;
gs_image_scale_state iss;
check_write_type(*rout, t_string);
if ( (code = read_matrix(op - 1, &mat)) < 0 )
return code;
if ( mat.xx < 1 || mat.xy != 0 || mat.yx != 0 || mat.yy < 1 )
return_error(e_rangecheck);
check_type(op[-2], t_integer);
check_type(op[-3], t_integer);
check_read_type(*rin, t_string);
if ( op[-3].value.intval <= 0 || op[-2].value.intval <= 0 ||
r_size(rin) != op[-3].value.intval * op[-2].value.intval
)
return_error(e_rangecheck);
iss.sizeofPixelIn = 1;
iss.maxPixelIn = 0xff;
iss.sizeofPixelOut = 1;
iss.maxPixelOut = 0xff;
iss.src_width = op[-3].value.intval;
iss.src_height = op[-2].value.intval;
iss.dst_width = (int)ceil(iss.src_width * mat.xx);
iss.dst_height = (int)ceil(iss.src_height * mat.yy);
if ( r_size(rout) != iss.dst_width * iss.dst_height )
return_error(e_rangecheck);
iss.values_per_pixel = 1;
iss.memory = imemory;
code = gs_image_scale_init(&iss, false, false);
if ( code < 0 )
return code;
code = gs_image_scale(rout->value.bytes, rin->value.bytes, &iss);
gs_image_scale_cleanup(&iss);
pop(5);
return 0;
}
/* ------ Initialization procedure ------ */
/* Note that these override the definitions in zpaint.c. */
BEGIN_OP_DEFS(zimage2_l2_op_defs) {
op_def_begin_level2(),
{"1image", z2image},
{"1imagemask", z2imagemask},
{"5.scaleimage", zscaleimage},
END_OP_DEFS(0) }
| 30.648402 | 77 | 0.671037 |
9c1f8c28578d6d39fc2452dda67c9033692306ca | 744 | h | C | System/Library/PrivateFrameworks/FontServices.framework/FontServicesFontPickerSupportProtocol.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | 2 | 2021-11-02T09:23:27.000Z | 2022-03-28T08:21:57.000Z | System/Library/PrivateFrameworks/FontServices.framework/FontServicesFontPickerSupportProtocol.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | null | null | null | System/Library/PrivateFrameworks/FontServices.framework/FontServicesFontPickerSupportProtocol.h | lechium/iOS1351Headers | 6bed3dada5ffc20366b27f7f2300a24a48a6284e | [
"MIT"
] | 1 | 2022-03-28T08:21:59.000Z | 2022-03-28T08:21:59.000Z | /*
* This header is generated by classdump-dyld 1.5
* on Friday, April 30, 2021 at 11:35:54 AM Mountain Standard Time
* Operating System: Version 13.5.1 (Build 17F80)
* Image Source: /System/Library/PrivateFrameworks/FontServices.framework/FontServices
* classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. Updated by Kevin Bradley.
*/
@protocol FontServicesFontPickerSupportProtocol
@required
-(void)ping:(id)arg1 reply:(/*^block*/id)arg2;
-(void)activateFontsForFontPickerClient:(id)arg1 reply:(/*^block*/id)arg2;
-(void)locallyActivatedFontFiles:(/*^block*/id)arg1;
@end
| 41.333333 | 130 | 0.626344 |
febe051caaed0070a11f65f928ce286322036bce | 321 | c | C | 0x02-functions_nested_loops/8-24_hours.c | Athesto/holbertonschool-low_level_programming | 91014500ccfae135ef2ab36846879d360609273b | [
"MIT"
] | null | null | null | 0x02-functions_nested_loops/8-24_hours.c | Athesto/holbertonschool-low_level_programming | 91014500ccfae135ef2ab36846879d360609273b | [
"MIT"
] | null | null | null | 0x02-functions_nested_loops/8-24_hours.c | Athesto/holbertonschool-low_level_programming | 91014500ccfae135ef2ab36846879d360609273b | [
"MIT"
] | null | null | null | #include "holberton.h"
/**
*jack_bauer - print time 0-24
*Return: no return
*/
void jack_bauer(void)
{
int s;
for (s = 0; s < 24 * 60; s++)
{
_putchar('0' + (s / 60) / 10);
_putchar('0' + (s / 60) % 10);
_putchar(':');
_putchar('0' + (s % 60) / 10);
_putchar('0' + (s % 60) % 10);
_putchar('\n');
}
}
| 16.05 | 32 | 0.495327 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.