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
697c6519134907b48bedf96cffe5eb2325ff72a4
163
h
C
cpp/bmt.h
gsioteam/native_main_thread
df9b4c08776c89e3fb1f81cf5994ff2b47f8926a
[ "MIT" ]
null
null
null
cpp/bmt.h
gsioteam/native_main_thread
df9b4c08776c89e3fb1f81cf5994ff2b47f8926a
[ "MIT" ]
null
null
null
cpp/bmt.h
gsioteam/native_main_thread
df9b4c08776c89e3fb1f81cf5994ff2b47f8926a
[ "MIT" ]
null
null
null
// // Created by gen on 11/21/21. // #ifndef ANDROID_BMT_H #define ANDROID_BMT_H void bmt_sendEvent(const char *name, const char *data); #endif //ANDROID_BMT_H
14.818182
55
0.730061
52df9972facd4727de0c99f38ffdada3df7f70a7
658
h
C
SmartLight/firmware/lib/i2c.h
TeamScheire/bicycleLight
604fe0ca518052c466c15d44a1d961a16489436b
[ "Apache-2.0" ]
7
2018-11-20T09:42:30.000Z
2019-06-18T13:58:40.000Z
firmware/lib/i2c.h
TeamScheire/theBenZ
b486a96421d4a9b6ffb7c0df660de31c5c6aeb8a
[ "Apache-2.0" ]
8
2020-05-19T05:11:11.000Z
2020-10-12T13:14:25.000Z
firmware/lib/i2c.h
maartenweyn/teamscheire_tatjana
35e8b6b57a0d7acfbf2c45c4800659d94ee6bd7c
[ "Apache-2.0" ]
null
null
null
#ifndef I2C_H__ #define I2C_H__ #include <stdint.h> #include <stdbool.h> #include <nrf_twi_mngr.h> #define TWI_INSTANCE_ID 0 #define MAX_PENDING_TRANSACTIONS 5 #define TWI_TIMEOUT 30000 extern const nrf_twi_mngr_t* twi_mngr; void i2c_init (void); void i2c_deinit(void); #define MAX_MULTI_DEVICE_NUM 5 uint8_t i2c_write(uint8_t data[], uint8_t length, uint8_t device_address, bool no_stop); uint8_t i2c_read(uint8_t buf[], uint8_t reg, uint8_t length, uint8_t device_address); uint8_t i2c_read_register (uint8_t reg, uint8_t* val, uint8_t device_address); uint8_t i2c_write_register(uint8_t reg, uint8_t val, uint8_t device_address); #endif
23.5
88
0.791793
fb54a58962ec24e3abba03ef8356a24111f9e335
3,690
c
C
ompi/mpi/fortran/mpif-h/file_write_at_all_begin_f.c
urids/XSCALAMPI
38624f682211d55c047183637fed8dbcc09f6d74
[ "BSD-3-Clause-Open-MPI" ]
1
2015-12-16T08:16:23.000Z
2015-12-16T08:16:23.000Z
ompi/mpi/fortran/mpif-h/file_write_at_all_begin_f.c
urids/XSCALAMPI
38624f682211d55c047183637fed8dbcc09f6d74
[ "BSD-3-Clause-Open-MPI" ]
null
null
null
ompi/mpi/fortran/mpif-h/file_write_at_all_begin_f.c
urids/XSCALAMPI
38624f682211d55c047183637fed8dbcc09f6d74
[ "BSD-3-Clause-Open-MPI" ]
3
2015-11-29T06:00:56.000Z
2021-03-29T07:03:29.000Z
/* * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana * University Research and Technology * Corporation. All rights reserved. * Copyright (c) 2004-2005 The University of Tennessee and The University * of Tennessee Research Foundation. All rights * reserved. * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow * * $HEADER$ */ #include "ompi_config.h" #include "ompi/mpi/fortran/mpif-h/bindings.h" #include "ompi/mpi/fortran/base/constants.h" #if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILE_LAYER #pragma weak PMPI_FILE_WRITE_AT_ALL_BEGIN = ompi_file_write_at_all_begin_f #pragma weak pmpi_file_write_at_all_begin = ompi_file_write_at_all_begin_f #pragma weak pmpi_file_write_at_all_begin_ = ompi_file_write_at_all_begin_f #pragma weak pmpi_file_write_at_all_begin__ = ompi_file_write_at_all_begin_f #pragma weak PMPI_File_write_at_all_begin_f = ompi_file_write_at_all_begin_f #pragma weak PMPI_File_write_at_all_begin_f08 = ompi_file_write_at_all_begin_f #elif OMPI_PROFILE_LAYER OMPI_GENERATE_F77_BINDINGS (PMPI_FILE_WRITE_AT_ALL_BEGIN, pmpi_file_write_at_all_begin, pmpi_file_write_at_all_begin_, pmpi_file_write_at_all_begin__, pompi_file_write_at_all_begin_f, (MPI_Fint *fh, MPI_Offset *offset, char *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *ierr), (fh, offset, buf, count, datatype, ierr) ) #endif #if OPAL_HAVE_WEAK_SYMBOLS #pragma weak MPI_FILE_WRITE_AT_ALL_BEGIN = ompi_file_write_at_all_begin_f #pragma weak mpi_file_write_at_all_begin = ompi_file_write_at_all_begin_f #pragma weak mpi_file_write_at_all_begin_ = ompi_file_write_at_all_begin_f #pragma weak mpi_file_write_at_all_begin__ = ompi_file_write_at_all_begin_f #pragma weak MPI_File_write_at_all_begin_f = ompi_file_write_at_all_begin_f #pragma weak MPI_File_write_at_all_begin_f08 = ompi_file_write_at_all_begin_f #endif #if ! OPAL_HAVE_WEAK_SYMBOLS && ! OMPI_PROFILE_LAYER OMPI_GENERATE_F77_BINDINGS (MPI_FILE_WRITE_AT_ALL_BEGIN, mpi_file_write_at_all_begin, mpi_file_write_at_all_begin_, mpi_file_write_at_all_begin__, ompi_file_write_at_all_begin_f, (MPI_Fint *fh, MPI_Offset *offset, char *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *ierr), (fh, offset, buf, count, datatype, ierr) ) #endif #if OMPI_PROFILE_LAYER && ! OPAL_HAVE_WEAK_SYMBOLS #include "ompi/mpi/fortran/mpif-h/profile/defines.h" #endif void ompi_file_write_at_all_begin_f(MPI_Fint *fh, MPI_Offset *offset, char *buf, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *ierr) { int c_ierr; MPI_File c_fh = MPI_File_f2c(*fh); MPI_Datatype c_type = MPI_Type_f2c(*datatype); c_ierr = MPI_File_write_at_all_begin(c_fh, (MPI_Offset) *offset, OMPI_F2C_BOTTOM(buf), OMPI_FINT_2_INT(*count), c_type); if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); }
44.457831
126
0.674255
dd5392b954ef8e931dbdffbe1e464026abffbee2
264
h
C
src/camera.h
BrendanParmer/RayTracing
4a0753f87de0a2748eefc57c1b9712dec9f915b5
[ "MIT" ]
null
null
null
src/camera.h
BrendanParmer/RayTracing
4a0753f87de0a2748eefc57c1b9712dec9f915b5
[ "MIT" ]
null
null
null
src/camera.h
BrendanParmer/RayTracing
4a0753f87de0a2748eefc57c1b9712dec9f915b5
[ "MIT" ]
null
null
null
#pragma once #include "vec3.h" #include "ray.h" class camera { public: camera(); ray get_ray(double u, double v) const; private: point3 origin; point3 lower_left_corner; vec3 horizontal; vec3 vertical; };
15.529412
46
0.579545
5427656c4872c0abc3b88a359c2418476b15645d
1,620
h
C
includes/CrossNetSystem/System/Reflection/Missing.h
KonajuGames/CrossNetSystem
23c516d79b16224745b05ba1044fd9786f3a5a14
[ "MS-PL" ]
2
2019-10-23T09:14:29.000Z
2021-02-02T15:01:35.000Z
includes/CrossNetSystem/System/Reflection/Missing.h
KonajuGames/CrossNetSystem
23c516d79b16224745b05ba1044fd9786f3a5a14
[ "MS-PL" ]
null
null
null
includes/CrossNetSystem/System/Reflection/Missing.h
KonajuGames/CrossNetSystem
23c516d79b16224745b05ba1044fd9786f3a5a14
[ "MS-PL" ]
null
null
null
/* * CrossNetSystem * .NET API Copyrighted by Microsoft */ #ifndef __SYSTEM_REFLECTION_MISSING_H__ #define __SYSTEM_REFLECTION_MISSING_H__ #ifndef CN_NO_SYSTEM_REFLECTION_MISSING #include "CrossNetRuntime/System/Object.h" #include "CrossNetSystem/System/Runtime/Serialization/ISerializable.h" namespace System { namespace Runtime { namespace Serialization { class SerializationInfo; struct StreamingContext; } } namespace Reflection { class Missing : public ::System::Object { CN_DYNAMIC_ID() public: static ::System::Reflection::Missing * Value; public: void __ctor__(); static ::System::Reflection::Missing * __Create__(); public: virtual ::System::Void System_Runtime_Serialization_ISerializable_GetObjectData(::System::Runtime::Serialization::SerializationInfo * info, ::System::Runtime::Serialization::StreamingContext context); public: static void Static__ctor__(); class Wrapper__ISerializable : public ::System::Runtime::Serialization::ISerializable { public: public: virtual ::System::Void GetObjectData(void * __passed_instance__, ::System::Runtime::Serialization::SerializationInfo * info, ::System::Runtime::Serialization::StreamingContext context); CN__NEW_DELETE_OPERATORS_FOR_WRAPPER }; public: static void __CreateInterfaceMap__(); }; } } #endif #endif
28.928571
212
0.633951
5a250a789f369ff3c0f18c92ca8933852a403632
1,768
h
C
iOSOpenDev/frameworks/HomeSharing.framework/Headers/HSResponse.h
bzxy/cydia
f8c838cdbd86e49dddf15792e7aa56e2af80548d
[ "MIT" ]
678
2017-11-17T08:33:19.000Z
2022-03-26T10:40:20.000Z
iOSOpenDev/frameworks/HomeSharing.framework/Headers/HSResponse.h
chenfanfang/Cydia
5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0
[ "MIT" ]
22
2019-04-16T05:51:53.000Z
2021-11-08T06:18:45.000Z
iOSOpenDev/frameworks/HomeSharing.framework/Headers/HSResponse.h
chenfanfang/Cydia
5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0
[ "MIT" ]
170
2018-06-10T07:59:20.000Z
2022-03-22T16:19:33.000Z
/** * This header is generated by class-dump-z 0.2b. * * Source: /System/Library/PrivateFrameworks/HomeSharing.framework/HomeSharing */ #import <HomeSharing/XXUnknownSuperclass.h> #import <HomeSharing/HomeSharing-Structs.h> @class NSData, NSError, NSDictionary; @interface HSResponse : XXUnknownSuperclass { @private CFHTTPMessageRef _CFHTTPMessage; // 4 = 0x4 NSData *_responseData; // 8 = 0x8 unsigned _responseCode; // 12 = 0xc NSDictionary *_responseHeaderFields; // 16 = 0x10 NSError *_error; // 20 = 0x14 } @property(assign, nonatomic) CFHTTPMessageRef CFHTTPMessage; // G=0x4539; S=0x4501; @synthesize=_CFHTTPMessage @property(readonly, assign, nonatomic) NSError *error; // G=0x4579; @synthesize=_error @property(readonly, assign, nonatomic) NSData *responseData; // G=0x4549; @synthesize=_responseData @property(readonly, assign, nonatomic) NSDictionary *responseHeaderFields; // G=0x4569; @synthesize=_responseHeaderFields @property(readonly, assign, nonatomic) unsigned responseCode; // G=0x4559; @synthesize=_responseCode + (id)responseWithResponse:(id)response; // 0x43c5 + (id)responseWithCode:(unsigned)code headerFields:(id)fields data:(id)data error:(id)error; // 0x4369 // declared property getter: - (id)error; // 0x4579 // declared property getter: - (id)responseHeaderFields; // 0x4569 // declared property getter: - (unsigned)responseCode; // 0x4559 // declared property getter: - (id)responseData; // 0x4549 // declared property getter: - (CFHTTPMessageRef)CFHTTPMessage; // 0x4539 // declared property setter: - (void)setCFHTTPMessage:(CFHTTPMessageRef)message; // 0x4501 - (id)description; // 0x4475 - (void)dealloc; // 0x42dd - (id)initWithCode:(unsigned)code headerFields:(id)fields data:(id)data error:(id)error; // 0x4235 @end
47.783784
121
0.758484
7c3307fe77ec0d999e6ec30ec12629dbf8965203
3,246
h
C
src/dpdk/drivers/raw/ifpga/base/ifpga_hw.h
ajitkhaparde/trex-core
1834ebd49112af0731a819056612dde832f7a94e
[ "Apache-2.0" ]
956
2015-06-24T15:04:55.000Z
2022-03-30T06:25:04.000Z
src/dpdk/drivers/raw/ifpga/base/ifpga_hw.h
hjat2005/trex-core
400f03c86c844a0096dff3f6b13e58a808aaefff
[ "Apache-2.0" ]
782
2015-09-20T15:19:00.000Z
2022-03-31T23:52:05.000Z
src/dpdk/drivers/raw/ifpga/base/ifpga_hw.h
hjat2005/trex-core
400f03c86c844a0096dff3f6b13e58a808aaefff
[ "Apache-2.0" ]
429
2015-06-27T19:34:21.000Z
2022-03-23T11:02:51.000Z
/* SPDX-License-Identifier: BSD-3-Clause * Copyright(c) 2010-2018 Intel Corporation */ #ifndef _IFPGA_HW_H_ #define _IFPGA_HW_H_ #include "ifpga_defines.h" #include "opae_ifpga_hw_api.h" #include "opae_eth_group.h" /** List of private feateues */ TAILQ_HEAD(ifpga_feature_list, ifpga_feature); enum ifpga_feature_state { IFPGA_FEATURE_UNUSED = 0, IFPGA_FEATURE_ATTACHED, }; enum feature_type { FEATURE_FME_TYPE = 0, FEATURE_PORT_TYPE, }; struct feature_irq_ctx { int eventfd; int idx; }; struct ifpga_feature { TAILQ_ENTRY(ifpga_feature)next; enum ifpga_feature_state state; enum feature_type type; const char *name; u64 id; u8 *addr; uint64_t phys_addr; u32 size; int revision; u64 cap; int vfio_dev_fd; struct feature_irq_ctx *ctx; unsigned int ctx_num; void *parent; /* to parent hw data structure */ struct ifpga_feature_ops *ops;/* callback to this private feature */ unsigned int vec_start; unsigned int vec_cnt; }; struct ifpga_feature_ops { int (*init)(struct ifpga_feature *feature); void (*uinit)(struct ifpga_feature *feature); int (*get_prop)(struct ifpga_feature *feature, struct feature_prop *prop); int (*set_prop)(struct ifpga_feature *feature, struct feature_prop *prop); int (*set_irq)(struct ifpga_feature *feature, void *irq_set); }; enum ifpga_fme_state { IFPGA_FME_UNUSED = 0, IFPGA_FME_IMPLEMENTED, }; struct ifpga_fme_hw { enum ifpga_fme_state state; struct ifpga_feature_list feature_list; spinlock_t lock; /* protect hardware access */ void *parent; /* pointer to ifpga_hw */ /* provied by HEADER feature */ u32 port_num; struct uuid bitstream_id; u64 bitstream_md; size_t pr_bandwidth; u32 socket_id; u32 fabric_version_id; u32 cache_size; u32 capability; void *max10_dev; /* MAX10 device */ void *i2c_master; /* I2C Master device */ void *eth_dev[MAX_ETH_GROUP_DEVICES]; struct opae_reg_region eth_group_region[MAX_ETH_GROUP_DEVICES]; struct opae_board_info board_info; int nums_eth_dev; unsigned int nums_acc_region; }; enum ifpga_port_state { IFPGA_PORT_UNUSED = 0, IFPGA_PORT_ATTACHED, IFPGA_PORT_DETACHED, }; struct ifpga_port_hw { enum ifpga_port_state state; struct ifpga_feature_list feature_list; spinlock_t lock; /* protect access to hw */ void *parent; /* pointer to ifpga_hw */ int port_id; /* provied by HEADER feature */ struct uuid afu_id; /* provied by User AFU feature */ unsigned int disable_count; u32 capability; u32 num_umsgs; /* The number of allocated umsgs */ u32 num_uafu_irqs; /* The number of uafu interrupts */ u8 *stp_addr; u32 stp_size; }; #define AFU_MAX_REGION 1 struct ifpga_afu_info { struct opae_reg_region region[AFU_MAX_REGION]; unsigned int num_regions; unsigned int num_irqs; }; struct ifpga_hw { struct opae_adapter *adapter; struct opae_adapter_data_pci *pci_data; struct ifpga_fme_hw fme; struct ifpga_port_hw port[MAX_FPGA_PORT_NUM]; }; static inline bool is_ifpga_hw_pf(struct ifpga_hw *hw) { return hw->fme.state != IFPGA_FME_UNUSED; } static inline bool is_valid_port_id(struct ifpga_hw *hw, u32 port_id) { if (port_id >= MAX_FPGA_PORT_NUM || hw->port[port_id].state != IFPGA_PORT_ATTACHED) return false; return true; } #endif /* _IFPGA_HW_H_ */
21.355263
69
0.756315
4056db92a52523a25e2c87946498cd753e6ecbdc
711
h
C
WPObserver/Classes/WPObserver.h
wuyanghu/WPObserver
c85d858db0f0f0b375ea69912ffec98ab77da5a1
[ "MIT" ]
6
2021-02-18T10:57:39.000Z
2021-06-10T13:45:43.000Z
WPObserver/Classes/WPObserver.h
wuyanghu/WPObserver
c85d858db0f0f0b375ea69912ffec98ab77da5a1
[ "MIT" ]
null
null
null
WPObserver/Classes/WPObserver.h
wuyanghu/WPObserver
c85d858db0f0f0b375ea69912ffec98ab77da5a1
[ "MIT" ]
null
null
null
// // WPObserver.h // WPObserver // // Created by wupeng on 2021/11/12. // #import <Foundation/Foundation.h> #import "WPProxy.h" NS_ASSUME_NONNULL_BEGIN typedef void(^WPObserverBlock)(id target); @interface WPObserver : NSObject //默认主队列 - (void)addObserver:(id)observer; - (void)addObserver:(id)observer delegateQueue:(dispatch_queue_t)queue; //移除:观察者对象释放,默认不用移除;不想监听时可调用此方法移除;监听单例需要移除。 //考虑到观察者数量不会太大,直接使用数组方法移除 - (void)removeObserver:(id)observer; //selector:校验target是否响应selector方法 - (void)notifyObserver:(WPObserverBlock)observerBlock selector:(SEL)aSelector; @end @interface NSObject (WPProxyObserver) @property (nonatomic,strong,readonly) WPObserver * proxyObserver; @end NS_ASSUME_NONNULL_END
20.911765
78
0.780591
c6d25689dd0530560b82ab8b47299e738ec7ed09
1,232
c
C
libutil/proc.c
cemkeylan/sm
02d6cfce82d5491da7933ec1e752c559093af7c4
[ "MIT" ]
2
2020-10-22T14:04:52.000Z
2020-10-25T12:43:07.000Z
libutil/proc.c
cemkeylan/sm
02d6cfce82d5491da7933ec1e752c559093af7c4
[ "MIT" ]
null
null
null
libutil/proc.c
cemkeylan/sm
02d6cfce82d5491da7933ec1e752c559093af7c4
[ "MIT" ]
null
null
null
#include <unistd.h> #include <stdio.h> #include <signal.h> #include <errno.h> #include "../util.h" pid_t getsvpid(service *sv) { pid_t pid; if (access(sv->pidfile, R_OK) == -1) return -1; FILE *pidfile; pidfile = fopen(sv->pidfile, "r"); if (pidfile == NULL) return -1; fscanf(pidfile, "%d", &pid); fclose(pidfile); return pid; } pid_t getsyspid(service *sv) { pid_t pid; if (access(sv->syspidfile, R_OK) == -1) { return -1; } FILE *pidfile; pidfile = fopen(sv->syspidfile, "r"); if (pidfile == NULL) return -1; fscanf(pidfile, "%d", &pid); fclose(pidfile); return pid; } int writesvpid(char *file, pid_t pid) { FILE *pidfile; pidfile = fopen(file, "w"); if (pidfile == NULL) { perror(file); return -1; } fprintf(pidfile, "%d\n", pid); fclose(pidfile); return 0; } int checkprocess(int pid) { if (kill(pid, 0) == 0) return 0; else { switch (errno) { case 1: /* EPERM is only produced if the process exists, but the * user running the program doesn't have the permissions * to kill the process. We can safely assume that the * process exists in this case and return 0. */ return 0; break; default: perror("kill"); break; } return 1; } }
14.494118
59
0.618506
3cae4b0d34ea1220b8e00c401e8b116032963151
299
h
C
CoreUI.framework/CUINamedMultisizeImageSet.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
4
2021-10-06T12:15:26.000Z
2022-02-21T02:26:00.000Z
CoreUI.framework/CUINamedMultisizeImageSet.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
null
null
null
CoreUI.framework/CUINamedMultisizeImageSet.h
reels-research/iOS-Private-Frameworks
9a4f4534939310a51fdbf5a439dd22487efb0f01
[ "MIT" ]
1
2021-10-08T07:40:53.000Z
2021-10-08T07:40:53.000Z
/* Generated by RuntimeBrowser Image: /System/Library/PrivateFrameworks/CoreUI.framework/CoreUI */ @interface CUINamedMultisizeImageSet : CUINamedLookup - (id)debugDescription; - (id)initWithName:(id)arg1 usingRenditionKey:(id)arg2 fromTheme:(unsigned long long)arg3; - (id)sizeIndexes; @end
24.916667
90
0.785953
14d15ed462603b3a05d3697db1e0411bcd278bdb
5,376
h
C
released_plugins/v3d_plugins/neurontracing_neutube/src_neutube/neurolabi/gui/zgraph.h
zzhmark/vaa3d_tools
3ca418add85a59ac7e805d55a600b78330d7e53d
[ "MIT" ]
1
2021-12-27T19:14:03.000Z
2021-12-27T19:14:03.000Z
released_plugins/v3d_plugins/neurontracing_neutube/src_neutube/neurolabi/gui/zgraph.h
zzhmark/vaa3d_tools
3ca418add85a59ac7e805d55a600b78330d7e53d
[ "MIT" ]
1
2016-12-03T05:33:13.000Z
2016-12-03T05:33:13.000Z
released_plugins/v3d_plugins/neurontracing_neutube/src_neutube/neurolabi/gui/zgraph.h
zzhmark/vaa3d_tools
3ca418add85a59ac7e805d55a600b78330d7e53d
[ "MIT" ]
null
null
null
#ifndef ZGRAPH_H #define ZGRAPH_H #include "tz_graph.h" #include <set> #include <vector> #include <string> #include <map> #include "zprogressreporter.h" //! ZGraph class /*! *This is a class of hosting a graph which is defined as (V, E), where V is the *set of vertices and E is the set of edges. There are four types of graphs *supported by this class: * DIRECTED_WITH_WEIGHT: Directed with weighted edges (default) * UNDIRECTED_WITH_WEIGHT: Undirected with weighted edges * DIRECTED_WITHOUT_WEIGHT: Directed without weights * UNDIRECTED_WITHOUT_WEIGHT: Undirected without weights */ class ZGraph { public: enum EGraphType { DIRECTED_WITH_WEIGHT, UNDIRECTED_WITH_WEIGHT, DIRECTED_WITHOUT_WEIGHT, UNDIRECTED_WITHOUT_WEIGHT }; ZGraph(EGraphType type = UNDIRECTED_WITHOUT_WEIGHT); ZGraph(Graph *graph); ~ZGraph(); ZGraph* clone() const; enum EComponent { PARENT_LIST, CHILD_LIST, WEIGHT_MATRIX, DEGREE, IN_DEGREE, OUT_DEGREE, EDGE_TABLE, EDGE_MAP, BFS_TREE, NEIGHBOR_LIST, CONNECTED_SUBGRAPH, ALL_COMPONENT }; /*! * \brief Set the graph as a directed/undirected graph. * * \param isDirected true for directed graph; false for undirected graph */ void setDirected(bool isDirected); void deprecateDependent(EComponent component); void deprecate(EComponent component); bool isDeprecated(EComponent component) const; inline bool isDirected() const { return Graph_Is_Directed(m_graph); } inline bool isWeighted() const { return Graph_Is_Weighted(m_graph); } inline int getVertexNumber() const { return m_graph->nvertex; } inline int getEdgeNumber() const { return m_graph->nedge; } inline bool hasVertex(int v) const { return ((v >= 0) && (v < getVertexNumber())); } inline double edgeWeight(size_t index) const { return m_graph->weights[index]; } void addEdge(int v1, int v2, double weight = 1.0); //Do not check if the edge exists void addEdgeFast(int v1, int v2, double weight = 1.0); inline int edgeStart(size_t edgeIndex) const { return m_graph->edges[edgeIndex][0]; } inline int edgeEnd(size_t edgeIndex) const { return m_graph->edges[edgeIndex][1]; } int getEdgeIndex(int v1, int v2) const; void setEdge(int index, int v1, int v2); //void setEdge(int index, int v1, int v2, double weight); inline size_t size() const { return m_graph->nedge; } inline int order() const { return m_graph->nvertex; } std::set<int> getNeighborSet(int vertex) const; std::set<int> getNeighborSet(const std::vector<int> &vertexArray) const; void print() const; void exportDotFile(const std::string &filePath) const; void exportDotFile(const std::string &filePath, const std::vector<bool> &labeled) const; void exportTxtFile(const std::string &filePath) const; void importTxtFile(const std::string &filePath); void clear(); double getEdgeWeight(int edgeIndex) const; double getEdgeWeight(int v1, int v2); void setEdgeWeight(int v1, int v2, double weight); void toMst(); int* getDegree() const; int getDegree(int v) const; //Remove all termini (any node with degree <= 1) void removeTerminal(); //Extract the path (with smallest number of nodes) between two vertices. //It extracts a cycle if <v1> is the same as <v2> and the cycle exists. std::vector<int> getPath(int v1, int v2); std::vector<std::vector<int> > getCycle(int root) const; std::vector<std::vector<int> > getCycle() const; //Merge a set of vertex. the new vertex index is the minumum of vertexArray void mergeVertex(const std::vector<int> &vertexArray); void setVertexNumber(int n); inline int getEdgeBegin(int edgeIndex) const { return m_graph->edges[edgeIndex][0]; } inline int getEdgeEnd(int edgeIndex) const { return m_graph->edges[edgeIndex][1]; } void removeEdge(int index); void removeEdge(const std::vector<int> &edgeList); void removeSelfEdge(); void removeDuplicatedEdge(); int **getNeighborList() const; int getNeighborNumber(int v) const; int getNeighbor(int v, int index) const; const std::vector<ZGraph*>& getConnectedSubgraph() const; inline void setProgressReporter(ZProgressReporter *reporter) { m_progressReporter = reporter; } inline Graph* getRawGraph() { return m_graph; } inline const Graph* getRawGraph() const { return m_graph; } /*! * \brief Compute shortest path * * It computes the shortest path from \a start to \a end. The current version * treated a directed graph as undirected. It returns empty if there is no * path from start to end. * * \param start vertex * \param end vertex * \return the array of vertices on the path */ std::vector<int> computeShortestPath(int start, int end); void expandEdgeTable(int v1, int v2); /*! * \brief Find matches among vertices * * This function does not garuantee a global optimization. The weight of each * edge must be small (< 100) to get good results. * * \return Map of the matches */ std::map<int, int> runMinWeightSumMatch(); private: void initWorkspace(); const Hash_Table* getEdgeTable() const; private: Graph *m_graph; Graph_Workspace *m_workspace; mutable std::vector<ZGraph*> m_connectedSubgraph; ZProgressReporter *m_progressReporter; ZProgressReporter m_nullProgressReporter; }; #endif // ZGRAPH_H
28.294737
82
0.714844
42f2271762f1e8bdc5ebd6d859f155846f627819
1,464
h
C
projects/client/audio/aura_processing/source/aura/processing/utility.h
silentorb/mythic-cpp
97319d158800d77e1a944c47c13523662bc07e08
[ "MIT" ]
null
null
null
projects/client/audio/aura_processing/source/aura/processing/utility.h
silentorb/mythic-cpp
97319d158800d77e1a944c47c13523662bc07e08
[ "MIT" ]
null
null
null
projects/client/audio/aura_processing/source/aura/processing/utility.h
silentorb/mythic-cpp
97319d158800d77e1a944c47c13523662bc07e08
[ "MIT" ]
null
null
null
#pragma once #include <cmath> namespace aura { namespace processing { // float to_dB(float value); // float to_dB(float value) { //// return std::pow(value, 2); //// const auto base = 10; // return (std::pow(10, value) - 1) / (10 - 1); //// return 20 * log10(value);' //// return std::pow(10.0f, value / 20.0f); // } float inverse_dB(float value); template<typename Signal_Type> Signal_Type clip(const Signal_Type &signal, Signal_Type limit = 1) { if (signal > limit) return limit; if (signal < -limit) return -limit; return signal; } template<typename Signal_Type> Signal_Type transition(float progress, const Signal_Type &start, const Signal_Type &end) { auto range = end - start; return range * progress + start; } template<typename Signal_Type> class Transition { const Signal_Type start; float range; public: Transition(const Signal_Type start, const Signal_Type end) : start(start) { range = end - start; } Signal_Type operator()(float progress) { return range * progress + start; } }; template<typename Signal_Type> Signal_Type signal_range(const Signal_Type &signal, const Signal_Type &bottom, const Signal_Type &top) { return transition(signal * 0.5 + 0.5, bottom, top); } } }
26.618182
109
0.585383
a415de4aa28701c4fb3614aa8ac6b253b42a1f31
3,012
h
C
workspace/unionfind/unionfind/unionfind.h
nvdungx/algo1
87e2916bf9e8649ce56a3766843ff44e05faf557
[ "MIT" ]
null
null
null
workspace/unionfind/unionfind/unionfind.h
nvdungx/algo1
87e2916bf9e8649ce56a3766843ff44e05faf557
[ "MIT" ]
null
null
null
workspace/unionfind/unionfind/unionfind.h
nvdungx/algo1
87e2916bf9e8649ce56a3766843ff44e05faf557
[ "MIT" ]
null
null
null
// unionfind.h : Include file for standard system include files, // or project specific include files. #pragma once #include <vector> #include <iostream> // TODO: Reference additional headers your program requires here. class QuickFindUF { public: QuickFindUF(int N) { count = N; id.reserve(N); for (size_t i = 0; i < N; i++) { id.push_back(i); } } ~QuickFindUF() { } bool connected(int p, int q) { (id[p] == id[q]) ? std::cout << p << "," << q << " connected" << std::endl : std::cout << p << "," << q << " not connected" << std::endl; return id[p] == id[q]; } // this take n^2 to perform n union operation void munion(int p, int q) { // change all element with id = p to q; int pid = id[p]; int qid = id[q]; if (pid == qid) return; for (size_t i = 0; i < id.size(); i++) { if (id[i] == pid) id[i] = qid; } count--; std::cout << "QF "<< count <<"- connect: " << p << "," << q << std::endl; } private: std::vector<int> id; int count; }; class QuickUnion { public: QuickUnion(int N) { id.reserve(N); count = N; for (size_t i = 0; i < N; i++) { id.push_back(i); } } ~QuickUnion() { } bool connected(int p, int q) { (find(p) == find(q)) ? std::cout << p << "," << q << " connected" << std::endl : std::cout << p << "," << q << " not connected" << std::endl; return find(p) == find(q); } void munion(int p, int q) { if (find(p) == find(q)) return; id[find(p)] = find(q); count--; std::cout << "QU "<< count <<"- connect: " << p << "," << q << " - " << "root p:"<< find(p) <<" to root q:" << find(q) << std::endl; } private: int find(int element) { while (element != id[element]) { element = id[element]; } return element; } std::vector<int> id; int count; }; class WeightedQU { public: WeightedQU(int N) { count = N; size.resize(N, 1); id.reserve(N); for (size_t i = 0; i < N; i++) { id.push_back(i); } } ~WeightedQU() { } void muinion(int p, int q) { int i = find(p); int j = find(q); if (i == j) return; if (size[i] > size[j]) { // root j connect to i size[i] += size[j]; id[j] = i; } else { // root i connect to j size[j] += size[i]; id[i] = j; } } int root_size(int element) { return size[find(element)]; } bool connected(int p, int q) { (find(p) == find(q)) ? std::cout << p << "," << q << " connected" << std::endl : std::cout << p << "," << q << " not connected" << std::endl; return find(p) == find(q); } private: int find(int element) { while (element != id[element]) { // make all node in path point to its grandparent id[element] = id[id[element]]; element = id[element]; } return element; } std::vector<int> id; // size of rooted tree(component) for current item std::vector<int> size; // count number of component int count; };
19.063291
144
0.51162
f8feb5ca70939f4d35cbad468a763b4007de394e
3,437
h
C
bsp/Atmel/system/system.h
Hotboards/CodeBank8
ddadc3249ec03fd0859326ef89577f97288c5694
[ "Beerware" ]
2
2018-11-09T23:09:13.000Z
2021-05-13T19:58:15.000Z
bsp/Atmel/system/system.h
Hotboards/CodeBank8
ddadc3249ec03fd0859326ef89577f97288c5694
[ "Beerware" ]
null
null
null
bsp/Atmel/system/system.h
Hotboards/CodeBank8
ddadc3249ec03fd0859326ef89577f97288c5694
[ "Beerware" ]
1
2021-05-13T19:59:11.000Z
2021-05-13T19:59:11.000Z
/*-------------------------------------------------------------------------------------------------- "THE BEER-WARE LICENSE" (Revision 42): <phk@FreeBSD.ORG> wrote this file. As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return to Hotboards crew (Beer-ware license created by Poul-Henning Kamp) \file system.h \author Diego \email diego.perez@hotboards.org \ver 2.0 \date June 14, 2014 \target ATmega series \brief Este driver maneja operaciones internas realizadas por el CPU tales como activacion/ desactivacion de interrupciones, reset del contador de watchdog, reset por software, y la activacion interna del PLL para que aumente la frecuencia de operacion a 48MHz -------------------------------------------------------------------------------------------------*/ #ifndef __SYSTEM_H__ #define __SYSTEM_H__ /*-- Includes --*/ #include <avr/interrupt.h> #include <avr/cpufunc.h> #include "types.h" /*-- Defines --*/ /**--------------------------------------------------------------------------------------------- \def _ePPS \brief perifericos que pueden ser reubicados en los diferentes pines "RPn" ----------------------------------------------------------------------------------------------*/ /*-- Macros --*/ /**--------------------------------------------------------------------------------------------- \def ENABLE_INTERRUPTS/DISABLE_INTERRUPTS \brief Habilita o desabilita las interrupciones globales del uC ----------------------------------------------------------------------------------------------*/ #define __ENABLE_INTERRUPTS() sei() #define __DISABLE_INTERRUPTS() cli() /**--------------------------------------------------------------------------------------------- \def __KICK_THE_DOG() \brief Resetea el contador del Watchdog timer ----------------------------------------------------------------------------------------------*/ #define __KICK_THE_DOG() /**--------------------------------------------------------------------------------------------- \def __RESET() \brief Provoca un reset del uC ----------------------------------------------------------------------------------------------*/ #define __RESET() /**--------------------------------------------------------------------------------------------- \def __NOP() \brief Ejecuta una instruccion que consume un ciclo en el procesador ----------------------------------------------------------------------------------------------*/ #define __NOP() __NOP() /*-- Functions --*/ /**--------------------------------------------------------------------------------------------- \brief Activa el PLL interno para que la frecuecia interne aumente a 48MHz \param None \return None \warning Esta funcion ciclara al uC por espacio de 2ms ----------------------------------------------------------------------------------------------*/ #endif
46.445946
101
0.35176
56f8da2de1b630d94a5baa26c7824cb09da4b688
3,824
c
C
experiment_log/permutant_index_v1/indexing/indexing.c
KukyNekoi/fpga_index_accelerator
0026e0deb31c556cc3770ed2be64eae93257949f
[ "MIT" ]
1
2018-07-12T09:43:05.000Z
2018-07-12T09:43:05.000Z
experiment_log/permutant_index_v1/indexing/indexing.c
honorpeter/fpga_index_accelerator
c09d222d3ad55d6bb354dee8aff97a4f519df89d
[ "MIT" ]
null
null
null
experiment_log/permutant_index_v1/indexing/indexing.c
honorpeter/fpga_index_accelerator
c09d222d3ad55d6bb354dee8aff97a4f519df89d
[ "MIT" ]
1
2019-04-09T02:38:27.000Z
2019-04-09T02:38:27.000Z
#ifndef INDEXING_C_ #define INDEXING_C_ #include <math.h> #include <stdlib.h> #include <string.h> #include "../constants.h" #include "indexing.h" #include "../dataset/dataset.h" #include "../permutant/permutant.h" #include "../vector/vector.h" size_t comp (const void * elem1, const void * elem2) { size_t f = *((size_t*)elem1); size_t s = *((size_t*)elem2); if (f > s) return 1; if (f < s) return -1; return 0; } vector_t get_sss_pivots(dataset_t *dataset, double factor, double alpha){ // Random sampling to determine max distance. Otherwise, this could take an eternity TwT //Random seed generation for random pivot selection size_t random_number = 0; FILE *random_source; random_source = fopen("/dev/urandom", "r"); fread(&random_number, 1, sizeof(size_t), random_source); size_t current_index_size = DATASET_SIZE; size_t sss_sample_size; if(factor == 0.0) sss_sample_size = cbrt(current_index_size); else sss_sample_size = factor * (current_index_size); size_t *sample = (size_t *) malloc(sizeof(size_t) * sss_sample_size); bool uniform = true; // Assuming that random values are distributed evenly for (int i=0; i < sss_sample_size; i++){ fread(&random_number, 1, sizeof(size_t), random_source); sample[i] = random_number % DATASET_SIZE; // printf("Random sample[%d]: %zu\n", i ,sample[i]); } fclose(random_source); // return NULL; // Now selecting pivots // calculate max distance between the samples (exhaustive for now) double max_distance = 0; for(int i = 0; i < sss_sample_size; i++){ for(int j = i+1; j < sss_sample_size - 1; j++){ double dist = dataset_distance(dataset, i, j); if(dist > max_distance) max_distance = dist; } } // printf("Max distance: %f\n", max_distance); // Believe it or not, we only did that to get the max distance. wwwww free(sample); vector_t pivots; vector_init(&pivots); vector_append(&pivots, 0); // for each new element if distance to all pivots exceeds (max*alpha) add as pivots #ifndef SKIP_SSS_INTERVAL for(size_t i = 0; i < current_index_size; i++){ #else for(size_t i = 0; i < current_index_size; i+= SKIP_SSS_INTERVAL){ #endif bool accepted = true; for(size_t j = 0; j < pivots.size; j++){ // vector_print(&pivots); double dist = dataset_distance(dataset, vector_get(&pivots, j), i); size_t next = vector_get(&pivots, j); dataset_t *a = dataset_get(dataset, next); dataset_t *b = dataset_get(dataset, i); if(dist < alpha * max_distance){ accepted = false; break; } } if(accepted == true){ vector_append(&pivots, i); } } vector_print(&pivots); return pivots; } vector_t force_sss_pivots(dataset_t *dataset, double factor, double precision, size_t amount){ size_t lower_bound = amount * (1.0-precision); size_t upper_bound = amount * (1.0+precision); double upper_alpha_bound = 1; double lower_alpha_bound = 0; while(1){ double curr_alpha = ((2*upper_alpha_bound)+lower_alpha_bound)/3.0; vector_t pivots = get_sss_pivots(dataset, factor, curr_alpha); if(pivots.size > upper_bound){ lower_alpha_bound = curr_alpha; } else if(pivots.size < lower_bound){ upper_alpha_bound = curr_alpha; } else{ return pivots; } } } permutant_t* get_permutation_mapping(dataset_t *dataset, vector_t pivots, size_t offset){ permutant_t *permutation = NULL; permutation_create(permutation, DATASET_SIZE); } #endif
31.866667
94
0.623169
51ac446aeef63266850273280db4d4ab86a09787
985
h
C
Project 2 - Collision Detection/screensaver/cilktool.h
simonaertssen/MIT-6.172-Performance-Engineering-of-Software-Systems
4e17186f9ecb8e40440565da8a619e33494bba22
[ "MIT" ]
null
null
null
Project 2 - Collision Detection/screensaver/cilktool.h
simonaertssen/MIT-6.172-Performance-Engineering-of-Software-Systems
4e17186f9ecb8e40440565da8a619e33494bba22
[ "MIT" ]
null
null
null
Project 2 - Collision Detection/screensaver/cilktool.h
simonaertssen/MIT-6.172-Performance-Engineering-of-Software-Systems
4e17186f9ecb8e40440565da8a619e33494bba22
[ "MIT" ]
1
2021-12-06T07:28:39.000Z
2021-12-06T07:28:39.000Z
#ifndef INCLUDED_CILKTOOL_DOT_H #define INCLUDED_CILKTOOL_DOT_H #include <inttypes.h> typedef struct __cilkrts_stack_frame __cilkrts_stack_frame; #ifdef __cplusplus #define EXTERN_C extern "C" { #define EXTERN_C_END } #else #define EXTERN_C #define EXTERN_C_END #endif EXTERN_C void cv_start(); void cv_stop(); void print_total(); void cilk_enter_begin (uint32_t prop, __cilkrts_stack_frame* sf, void* this_fn, void* rip); void cilk_enter_helper_begin(__cilkrts_stack_frame* sf, void* this_fn, void* rip); void cilk_enter_end (__cilkrts_stack_frame* sf, void* rsp); void cilk_spawn_prepare (__cilkrts_stack_frame* sf); void cilk_spawn_or_continue (int in_continuation); void cilk_detach_begin (__cilkrts_stack_frame* parent); void cilk_detach_end (void); void cilk_sync_begin (__cilkrts_stack_frame* sf); void cilk_sync_end (__cilkrts_stack_frame* sf); void cilk_leave_begin (__cilkrts_stack_frame *sf); void cilk_leave_end (void); EXTERN_C_END #endif // INCLUDED_CILKTOOL_DOT_H
28.970588
91
0.819289
863889c7fc3b7e18f5db33299ba2ff962c9b3a78
2,694
h
C
SpeechproSpeechKit/SpeechproSpeechKit/Common/VoiceCapture/OPCSAudioQueueRecorder.h
elegion/stc-speechkit-ios
a90cc89efd81b82cdbdaedfffad726db3e584ef8
[ "BSD-2-Clause-FreeBSD" ]
1
2022-03-16T19:40:55.000Z
2022-03-16T19:40:55.000Z
SpeechproSpeechKit/SpeechproSpeechKit/Common/VoiceCapture/OPCSAudioQueueRecorder.h
elegion/stc-speechkit-ios
a90cc89efd81b82cdbdaedfffad726db3e584ef8
[ "BSD-2-Clause-FreeBSD" ]
null
null
null
SpeechproSpeechKit/SpeechproSpeechKit/Common/VoiceCapture/OPCSAudioQueueRecorder.h
elegion/stc-speechkit-ios
a90cc89efd81b82cdbdaedfffad726db3e584ef8
[ "BSD-2-Clause-FreeBSD" ]
null
null
null
// // OPCSAudioQueueRecorder.h // OnePassCaptureStandard // // Created by Soloshcheva Aleksandra on 06.09.16. // Copyright © 2016 Speech Technology Center. All rights reserved. // #ifndef OPCSAudioQueueRecorder_h #define OPCSAudioQueueRecorder_h #include <AudioToolbox/AudioToolbox.h> #include <stdio.h> /** * The type definition of the pointer to OPCSAudioQueueRecorderRef */ typedef struct OPCSAudioQueueRecorder* OPCSAudioQueueRecorderRef; /** * Is type for the callback function which is invoked when the buffer is full */ typedef void(*OPCSAudioQueueRecorderCallbackPointer)(OPCSAudioQueueRecorderRef, AudioQueueRef, AudioQueueBufferRef) ; /** * The constant of the number of buffers */ static const int kNumberBuffers = 3; /** * The struct of the audio queue recorder */ struct OPCSAudioQueueRecorder{ ///This structure encapsulates all the information for describing the format of an audio stream. AudioStreamBasicDescription dataFormat; ///Defines an opaque data type that represents an audio queue. AudioQueueRef queue; //An array of pointers to an AudioQueueBuffer. AudioQueueBufferRef buffers[kNumberBuffers]; ///The size of buffers in bytes UInt32 bufferByteSize; ///Shows that recording is in progress bool isRunning; /// The pointer to the additional data void *userInfo; ///The pointer to the callback function which is invoked when the buffer is full OPCSAudioQueueRecorderCallbackPointer callback; }; /** * Creates the audio queue source and return reference to it * @param callback The pointer to the callback function * @param userInfo The additional data passed to the callback function * @return The reference to the audio queue recorder */ OPCSAudioQueueRecorderRef OPCRAudioQueueSourceCreate(OPCSAudioQueueRecorderCallbackPointer callback, void *userInfo, Float64 sampleRate); /** * Destroys the audio queue recorder * @param ref The reference to the audio queue recorder */ void OPCSAudioQueueSourceDestroy(OPCSAudioQueueRecorderRef ref); /** * Starts recording * @param ref The audio queue recorder references * @return The recorder status */ OSStatus OPCSAudioQueueSourceStartRecord(OPCSAudioQueueRecorderRef ref); /** * Stops recording * @param ref The audio queue recorder references */ void OPCSAudioQueueSourceStopRecord(OPCSAudioQueueRecorderRef ref); /** * Returns the current time * @param ref The audio queue recorder references * @return The timestamp */ Float64 OPCSSourceGetCurrentTime(OPCSAudioQueueRecorderRef ref); #endif /* OPCSAudioQueueRecorder_h */
29.604396
137
0.745731
798c79dbdca637f9b891f096ef6407d63275025d
251
h
C
DVAVKit/DVAVKit/Utils/GLKit/Application/DVGLColorLayer.h
HEROhuqinchao/DVAVKit_forOC
5d7a2d80b6561c3949938a0b86d87558ec010abc
[ "Apache-2.0" ]
18
2020-04-10T10:20:55.000Z
2021-09-09T08:17:40.000Z
DVAVKit/DVAVKit/Utils/GLKit/Application/DVGLColorLayer.h
willbetheone/DVAVKit
1a49398bdb9d6d32b4e7e85232edfa54ba523d76
[ "MIT" ]
2
2020-04-11T07:39:17.000Z
2020-11-20T01:02:47.000Z
DVAVKit/DVAVKit/Utils/GLKit/Application/DVGLColorLayer.h
willbetheone/DVAVKit
1a49398bdb9d6d32b4e7e85232edfa54ba523d76
[ "MIT" ]
8
2020-04-17T09:41:49.000Z
2021-08-03T02:49:15.000Z
// // DVGLColorLayer.h // DVGLKit // // Created by DV on 2019/1/15. // Copyright © 2019 DVKit. All rights reserved. // #import "DVGLRenderLayer.h" NS_ASSUME_NONNULL_BEGIN @interface DVGLColorLayer : DVGLRenderLayer @end NS_ASSUME_NONNULL_END
13.944444
48
0.733068
b2a12e747398f80b7eff6fce99adae435e5f8986
1,495
c
C
simulation/others/gen_randqc.c
yeehui1988/QCM
95ae18b7737ae325916c95926192fae2f01e16b8
[ "BSD-3-Clause" ]
4
2019-05-27T06:37:36.000Z
2021-11-17T11:17:57.000Z
simulation/others/gen_randqc.c
yeehui1988/QCM
95ae18b7737ae325916c95926192fae2f01e16b8
[ "BSD-3-Clause" ]
null
null
null
simulation/others/gen_randqc.c
yeehui1988/QCM
95ae18b7737ae325916c95926192fae2f01e16b8
[ "BSD-3-Clause" ]
3
2019-05-27T06:37:23.000Z
2022-02-18T17:11:14.000Z
#include <stdio.h> #include <stdlib.h> #include <time.h> unsigned int getrandom(unsigned int n) { unsigned int r = (RAND_MAX*rand() + rand()) % n; r = (r + n) % n; return r; } int main ()//(int argc, char **argv) { unsigned int n = 4; // number of qubits unsigned int T = 10; // number of gates double m = 0.0f; // measurement double c = 1.0f; // portion of gates that are CNOT double h = 1.0f; // Hadamard double p = 1.0f; // phase // double m = 1.0f; // measurement double sum; double r; unsigned int a; unsigned int b; unsigned int i; srand(time(0)); sum = c+h+p+m; c /= sum; h /= sum; p /= sum; m /= sum; printf("Randomly-generated Clifford group quantum circuit"); printf("\nn=%u qubits, T=%u gates", n, T); printf("\nInstruction mix: %.2lf%% CNOT, %.2lf%% Hadamard, %.2lf%% Phase, %.2lf%% Measurement\n", 100.0f*c, 100.0f*h, 100.0f*p, 100.0f*m); FILE *output; output=fopen("randqc.txt","w"); fprintf(output,"%u\t%u\n", n, T); for (i = 0; i < T; i++) { r = (double)rand()/RAND_MAX; a = getrandom(n); b = a; while (b==a) b = getrandom(n); if (r < c) { printf("\nc %u %u", a, b); fprintf(output,"c\t%u\t%u\n", a, b); } else if (r < c+h) { printf("\nh %u", a); fprintf(output,"h\t%u\n", a); } else if (r < c+h+p) { printf("\np %u", a); fprintf(output,"p\t%u\n", a); } else { printf("\nm %u", a); fprintf(output,"m\t%u\n", a); } } printf("\n"); fclose(output); return 0; }
18.924051
98
0.548495
2542b0dff56cf096675d40dc58e9141894785d7e
2,072
h
C
Classes/MacTrek/Gui/SettingsController.h
netrek/netrek-client-mactrek
28c343588bba6dc220d8da967b9c271d33c6cbfd
[ "ClArtistic" ]
null
null
null
Classes/MacTrek/Gui/SettingsController.h
netrek/netrek-client-mactrek
28c343588bba6dc220d8da967b9c271d33c6cbfd
[ "ClArtistic" ]
null
null
null
Classes/MacTrek/Gui/SettingsController.h
netrek/netrek-client-mactrek
28c343588bba6dc220d8da967b9c271d33c6cbfd
[ "ClArtistic" ]
null
null
null
// // SettingsController.h // MacTrek // // Created by Aqua on 26/05/2006. // Copyright 2006 Luky Soft. See Licence.txt for licence details. // #import <Cocoa/Cocoa.h> #import "KeyMapTableDataSource.h" #import "MTMouseMap.h" #import "Luky.h" #import "BaseClass.h" #import "MTDistressKeyMap.h" #import "MenuController.h" #define GRAPHICS_MODEL_NETREK 0 #define GRAPHICS_MODEL_MACTREK 1 #define GRAPHICS_MODEL_TAC 2 @interface SettingsController : BaseClass { IBOutlet NSSlider *musicLevel; IBOutlet NSSlider *fxLevel; IBOutlet NSSegmentedControl *graphicsModel; IBOutlet NSButton *voiceOver; IBOutlet NSButton *voiceCmds; IBOutlet NSButton *accelerateButton; IBOutlet NSButton *trackingEnabledButton; IBOutlet NSButton *logToConsole; IBOutlet NSButton *useRCD; IBOutlet NSButton *tipsButton; IBOutlet NSPopUpButton *leftMouse; IBOutlet NSPopUpButton *rightMouse; IBOutlet NSPopUpButton *middleMouse; IBOutlet NSPopUpButton *wheelMouse; IBOutlet NSPopUpButton *resolution; IBOutlet NSTextField *playerName; IBOutlet NSTextField *playerPassword; IBOutlet KeyMapTableDataSource *actionKeyMapDataSource; IBOutlet KeyMapTableDataSource *distressKeyMapDataSource; IBOutlet NSWindow *mainWindow; LLScreenResolution *displaySetter; } - (MTKeyMap*) distressKeyMap; - (MTKeyMap*) actionKeyMap; - (void) setResolutionByString:(NSString*) resolutionString; - (void) resolutionChanged:(NSNotification *)notification; - (bool) trackingEnabled; - (bool) soundEnabled; - (bool) voiceEnabled; - (bool) tipsEnabled; - (bool) voiceCommands; - (bool) accelerate; - (bool) useRCD; - (float) musicLevel; - (float) fxLevel; - (int) graphicsModel; - (void) setPreviousValues; - (void) saveSettingsToFile:(bool)useFile; - (int) actionForButton:(NSPopUpButton *) button; - (NSString *) stringForAction:(int) action; - (MTMouseMap *)mouseMap; @end
29.183099
66
0.696911
668c83ef6ec361243ddb90838598c4368ab9d7dd
546
h
C
arithmetic_fault.h
rbur004/MacVAX
4edc3b84939895c8b6811811a7403ce556a5b0ce
[ "BSD-4-Clause-UC" ]
3
2015-03-10T06:19:49.000Z
2020-07-24T23:23:36.000Z
arithmetic_fault.h
rbur004/MacVAX
4edc3b84939895c8b6811811a7403ce556a5b0ce
[ "BSD-4-Clause-UC" ]
null
null
null
arithmetic_fault.h
rbur004/MacVAX
4edc3b84939895c8b6811811a7403ce556a5b0ce
[ "BSD-4-Clause-UC" ]
null
null
null
#ifndef ARITHMETIC_H #define ARITHMETIC_H /*TRAPS*/ #define INTEGER_OVERFLOW_TRAP 1 /*and IV in PSW must be set*/ #define INTEGER_DIVIDE_BY_ZERO_TRAP 2 #define FLOATING_OVERFLOW_TRAP 3 #define DECIMAL_DIVIDE_BY_ZERO_TRAP 4 #define FLOATING_UNDERFLOW_TRAP 5 /*and FU in PSW set*/ #define DECIMAL_OVERFLOW_TRAP 6 /*and DV in PSW set*/ #define SUBSCRIPT_RANGE_TRAP 7 /*FAULTS*/ #define FLOATING_OVERFLOW_FAULT 8 #define FLOATING_DIVIDE_BY_ZERO_FAULT 9 #define FLOATING_UNDERFLOW_FAULT 10 extern long floating_underflow; #endif ARITHMETIC_H
546
546
0.815018
585c764cc8d8579e0536aa4f5c4759618f0e95ed
1,071
c
C
openearthsdk/src/main/cpp/util/image.c
Darlun1024/OpenEarth
f30f5fd2d4bb91e00d323f8c8a1d17169a3e8fbb
[ "Unlicense" ]
5
2017-12-05T01:32:19.000Z
2019-12-15T17:42:47.000Z
openearthsdk/src/main/cpp/util/image.c
Darlun1024/OpenEarth
f30f5fd2d4bb91e00d323f8c8a1d17169a3e8fbb
[ "Unlicense" ]
1
2017-12-08T06:48:41.000Z
2017-12-08T06:48:41.000Z
openearthsdk/src/main/cpp/util/image.c
Darlun1024/OpenEarth
f30f5fd2d4bb91e00d323f8c8a1d17169a3e8fbb
[ "Unlicense" ]
4
2017-12-05T01:34:09.000Z
2019-12-15T17:42:53.000Z
#include <assert.h> #include <malloc.h> #include "png_reader.h" #include "jpeg_reader.h" #ifndef INCLUDE_IMAGE #include "image.h" #define INCLUDE_IMAGE #endif void release_raw_image_data(const RawImageData *data){ assert(data != NULL); free((void*)data->data); } RawImageData get_raw_image_data(const void* img_data, const int img_data_size){ uint8_t* data = (uint8_t*)img_data; //判断文件是png还是jpeg //png 文件 以 89 50 4E 47 开头 //C 语言中 U标志无符号整形 L 表示Long F 表示浮点型 if (img_data_size >= 4) { uint32_t magic = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3]; if (magic == 0x89504E47U) { return get_raw_image_data_from_png(img_data,img_data_size); } } //jpeg 文件以 ff d8 开头 if (img_data_size >= 2) { uint16_t magic = ((data[0] << 8) | data[1]) & 0xffff; if (magic == 0xFFD8) { return get_raw_image_data_from_jpeg(data,img_data_size); } } return (RawImageData){ 0, 0, 0, 0, NULL }; }
25.5
86
0.580766
c9916cf391b2830f22cc094e8771af57505489b0
321
h
C
communication/usb_communication.h
josebly/motor-tmp
20432ddf5ad0b21c328c1548ab261935150facd4
[ "BSD-3-Clause" ]
null
null
null
communication/usb_communication.h
josebly/motor-tmp
20432ddf5ad0b21c328c1548ab261935150facd4
[ "BSD-3-Clause" ]
null
null
null
communication/usb_communication.h
josebly/motor-tmp
20432ddf5ad0b21c328c1548ab261935150facd4
[ "BSD-3-Clause" ]
1
2020-02-27T16:24:44.000Z
2020-02-27T16:24:44.000Z
#ifndef USB_COMMUNICATION_H #define USB_COMMUNICATION_H #include "communication.h" class USB; class USBCommunication : public Communication { public: virtual void init(); virtual int receive_data(ReceiveData * const data); virtual void send_data(const SendData &data); private: USB * usb_; }; #endif
18.882353
55
0.741433
ba1c887c5bce98b11c1ccec97c052e7a70fda0eb
170
h
C
MotorSpecTest/app.h
CountrySideEngineer/Ev3MotorSpecCheck
6fdba0d7236c8b7ef03f9ebe2b82cf6d0d7f44a3
[ "MIT" ]
null
null
null
MotorSpecTest/app.h
CountrySideEngineer/Ev3MotorSpecCheck
6fdba0d7236c8b7ef03f9ebe2b82cf6d0d7f44a3
[ "MIT" ]
null
null
null
MotorSpecTest/app.h
CountrySideEngineer/Ev3MotorSpecCheck
6fdba0d7236c8b7ef03f9ebe2b82cf6d0d7f44a3
[ "MIT" ]
null
null
null
#pragma once #include "ev3api.h" extern void main_task(intptr_t exinf); extern void cyc_task_100msec(intptr_t unused); extern void cyc_task_1sec(intptr_t unused);
24.285714
47
0.782353
c9e56e4737677a2e9ed75bbe1cef24e7c8244f15
9,497
h
C
world/terrain_2d_world.h
Relintai/terraman_2d
60a7e84a5dc2fc252b0c582dd8f877685d28d74a
[ "MIT" ]
null
null
null
world/terrain_2d_world.h
Relintai/terraman_2d
60a7e84a5dc2fc252b0c582dd8f877685d28d74a
[ "MIT" ]
null
null
null
world/terrain_2d_world.h
Relintai/terraman_2d
60a7e84a5dc2fc252b0c582dd8f877685d28d74a
[ "MIT" ]
null
null
null
/* Copyright (c) 2019-2022 Péter Magyar Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef TERRAIN_2D_WORLD_H #define TERRAIN_2D_WORLD_H #include "core/version.h" #if VERSION_MAJOR > 3 #include "core/config/engine.h" #include "core/templates/hash_map.h" #else #include "core/engine.h" #include "core/hash_map.h" #endif #include "../defines.h" #include "scene/2d/navigation_2d.h" #include "../areas/terrain_2d_world_area.h" #include "../level_generator/terrain_2d_level_generator.h" #include "../library/terrain_2d_library.h" #include "core/os/os.h" #if PROPS_2D_PRESENT #include "../../props_2d/props/prop_2d_data.h" #endif class Terrain2DStructure; class Terrain2DChunk; class Prop2DData; class Terrain2DWorld : public Navigation2D { GDCLASS(Terrain2DWorld, Navigation2D); public: enum ChannelTypeInfo { CHANNEL_TYPE_INFO_TYPE = 0, CHANNEL_TYPE_INFO_ISOLEVEL, CHANNEL_TYPE_INFO_LIQUID_FLOW, }; enum { NOTIFICATION_ACTIVE_STATE_CHANGED = 9000, }; static const String BINDING_STRING_CHANNEL_TYPE_INFO; public: bool get_active() const; void set_active(const bool value); bool get_editable() const; void set_editable(const bool value); int get_chunk_size_x() const; void set_chunk_size_x(const int value); int get_chunk_size_y() const; void set_chunk_size_y(const int value); int get_data_margin_start() const; void set_data_margin_start(const int value); int get_data_margin_end() const; void set_data_margin_end(const int value); int get_current_seed() const; void set_current_seed(const int value); int get_max_concurrent_generations(); void set_max_concurrent_generations(const int value); Ref<Terrain2DLibrary> get_library(); void set_library(const Ref<Terrain2DLibrary> &library); Ref<Terrain2DLevelGenerator> get_level_generator() const; void set_level_generator(const Ref<Terrain2DLevelGenerator> &level_generator); int get_cell_size_x() const; void set_cell_size_x(const int value); int get_cell_size_y() const; void set_cell_size_y(const int value); int get_chunk_spawn_range() const; void set_chunk_spawn_range(const int value); NodePath get_player_path() const; void set_player_path(const NodePath &player_path); Node2D *get_player() const; void set_player(Node2D *player); void set_player_bind(Node *player); Transform2D mesh_transform_terrain_get(); void mesh_transform_terrain_set(const Transform2D &value); Transform2D mesh_transform_wall_north_get(); void mesh_transform_wall_north_set(const Transform2D &value); Transform2D mesh_transform_wall_south_get(); void mesh_transform_wall_south_set(const Transform2D &value); Transform2D mesh_transform_wall_east_get(); void mesh_transform_wall_east_set(const Transform2D &value); Transform2D mesh_transform_wall_west_get(); void mesh_transform_wall_west_set(const Transform2D &value); //World Areas Ref<Terrain2DWorldArea> world_area_get(const int index) const; void world_area_add(const Ref<Terrain2DWorldArea> &area); void world_area_remove(const int index); void world_areas_clear(); int world_area_get_count() const; //Terra Structures Ref<Terrain2DStructure> voxel_structure_get(const int index) const; void voxel_structure_add(const Ref<Terrain2DStructure> &structure); void voxel_structure_remove(const Ref<Terrain2DStructure> &structure); void voxel_structure_remove_index(const int index); void voxel_structures_clear(); int voxel_structure_get_count() const; void voxel_structure_add_at_position(Ref<Terrain2DStructure> structure, const Vector3 &world_position); Vector<Variant> voxel_structures_get(); void voxel_structures_set(const Vector<Variant> &structures); //Chunks void chunk_add(Ref<Terrain2DChunk> chunk, const int x, const int y); bool chunk_has(const int x, const int y) const; Ref<Terrain2DChunk> chunk_get(const int x, const int y); Ref<Terrain2DChunk> chunk_remove(const int x, const int y); Ref<Terrain2DChunk> chunk_remove_index(const int index); Ref<Terrain2DChunk> chunk_get_index(const int index); int chunk_get_count() const; void chunks_clear(); Ref<Terrain2DChunk> chunk_get_or_create(const int x, const int y); Ref<Terrain2DChunk> chunk_create(const int x, const int y); void chunk_setup(Ref<Terrain2DChunk> chunk); void chunk_generate(Ref<Terrain2DChunk> chunk); Vector<Variant> chunks_get(); void chunks_set(const Vector<Variant> &chunks); bool can_chunk_do_build_step(); bool is_position_walkable(const Vector2 &p_pos); void on_chunk_mesh_generation_finished(Ref<Terrain2DChunk> p_chunk); void generation_queue_add_to(const Ref<Terrain2DChunk> &chunk); Ref<Terrain2DChunk> generation_queue_get_index(const int index); void generation_queue_remove_index(const int index); int generation_queue_get_size() const; void generation_add_to(const Ref<Terrain2DChunk> &chunk); Ref<Terrain2DChunk> generation_get_index(const int index); void generation_remove_index(const int index); int generation_get_size() const; #if PROPS_2D_PRESENT void prop_add(Transform transform, const Ref<Prop2DData> &prop, const bool apply_scale = true); #endif //Lights void light_add(const Ref<Terrain2DLight> &light); Ref<Terrain2DLight> light_get(const int index); void light_remove(const int index); int light_get_count() const; void lights_clear(); Vector<Variant> lights_get(); void lights_set(const Vector<Variant> &chunks); //Helpers uint8_t get_voxel_at_world_position(const Vector2 &world_position, const int channel_index); void set_voxel_at_world_position(const Vector2 &world_position, const uint8_t data, const int channel_index, const bool rebuild = true); Ref<Terrain2DChunk> get_chunk_at_world_position(const Vector2 &world_position); Ref<Terrain2DChunk> get_or_create_chunk_at_world_position(const Vector2 &world_position); void set_voxel_with_tool(const bool mode_add, const Vector2 hit_position, const int selected_voxel, const int isolevel); int get_channel_index_info(const ChannelTypeInfo channel_type); #if VERSION_MAJOR >= 4 GDVIRTUAL1(_chunk_added, Ref<Terrain2DChunk>); GDVIRTUAL0(_generation_finished); GDVIRTUAL3R(Ref<Terrain2DChunk>, _create_chunk, int, int, Ref<Terrain2DChunk>); GDVIRTUAL1(_prepare_chunk_for_generation, Ref<Terrain2DChunk>); GDVIRTUAL1(_generate_chunk, Ref<Terrain2DChunk>); GDVIRTUAL1R(int, _get_channel_index_info, int); GDVIRTUAL5(_set_voxel_with_tool, bool, Vector3, Vector3, int, int); #endif Terrain2DWorld(); ~Terrain2DWorld(); protected: virtual void _draw(); virtual void _generate_chunk(Ref<Terrain2DChunk> chunk); virtual Ref<Terrain2DChunk> _create_chunk(int x, int y, Ref<Terrain2DChunk> p_chunk); virtual int _get_channel_index_info(const ChannelTypeInfo channel_type); virtual void _set_voxel_with_tool(const bool mode_add, const Vector2 hit_position, const int selected_voxel, const int isolevel); virtual void _notification(int p_what); static void _bind_methods(); public: struct IntPos { int x; int y; IntPos() { x = 0; y = 0; } IntPos(int p_x, int p_y) { x = p_x; y = p_y; } IntPos(const Vector2 &p) { x = p.x; y = p.y; } }; struct IntPosHasher { static _FORCE_INLINE_ uint32_t hash(const IntPos &v) { uint32_t hash = hash_djb2_one_32(v.x); hash = hash_djb2_one_32(v.x, hash); return hash_djb2_one_32(v.y, hash); } }; private: bool _active; bool _editable; bool _is_priority_generation; int _chunk_size_x; int _chunk_size_y; int _current_seed; int _data_margin_start; int _data_margin_end; Ref<Terrain2DLibrary> _library; Ref<Terrain2DLevelGenerator> _level_generator; int _cell_size_x; int _cell_size_y; int _chunk_spawn_range; HashMap<IntPos, Ref<Terrain2DChunk>, IntPosHasher> _chunks; Vector<Ref<Terrain2DChunk>> _chunks_vector; Vector<Ref<Terrain2DWorldArea>> _world_areas; Vector<Ref<Terrain2DStructure>> _voxel_structures; NodePath _player_path; Node2D *_player; int _max_concurrent_generations; Vector<Ref<Terrain2DChunk>> _generation_queue; Vector<Ref<Terrain2DChunk>> _generating; int _max_frame_chunk_build_steps; int _num_frame_chunk_build_steps; Vector<Ref<Terrain2DLight>> _lights; Transform2D _mesh_transform_terrain; Transform2D _mesh_transform_wall_north; Transform2D _mesh_transform_wall_south; Transform2D _mesh_transform_wall_east; Transform2D _mesh_transform_wall_west; }; _FORCE_INLINE_ bool operator==(const Terrain2DWorld::IntPos &a, const Terrain2DWorld::IntPos &b) { return a.x == b.x && a.y == b.y; } VARIANT_ENUM_CAST(Terrain2DWorld::ChannelTypeInfo); #endif
30.053797
137
0.794988
b90f72c74f2a831807fd34e59653b51c9e9e7df5
516
h
C
src/common/common/macros.h
caseymcc/open-builder
644356e2704ad9f3b9cb3d197504cae9a0cfadc5
[ "MIT" ]
null
null
null
src/common/common/macros.h
caseymcc/open-builder
644356e2704ad9f3b9cb3d197504cae9a0cfadc5
[ "MIT" ]
null
null
null
src/common/common/macros.h
caseymcc/open-builder
644356e2704ad9f3b9cb3d197504cae9a0cfadc5
[ "MIT" ]
null
null
null
#pragma once #define NON_COPYABLE(Class) \ Class& operator=(const Class& obj) = delete; \ Class(const Class& obj) = delete; #define NON_MOVEABLE(Class) \ Class& operator=(Class&& obj) = delete; \ Class(Class&& obj) = delete; // Just some macros to assist with making classes noncopyable etc
46.909091
90
0.408915
7ecd1895cd6c0071302afee4e80f7fa236986048
1,531
c
C
sort_merge.c
blackyau/Learn_C
60996bb2243ae489c7f9e90da0ea0a77d3c819d5
[ "Unlicense" ]
null
null
null
sort_merge.c
blackyau/Learn_C
60996bb2243ae489c7f9e90da0ea0a77d3c819d5
[ "Unlicense" ]
null
null
null
sort_merge.c
blackyau/Learn_C
60996bb2243ae489c7f9e90da0ea0a77d3c819d5
[ "Unlicense" ]
null
null
null
// 归并排序 #include<stdio.h> #include<stdlib.h> #include<string.h> void sort_merge(int list[], int n); // 初始化入口 void sort_merge_c(int a[], int p, int r); // 递归调用函数 void merge(int arr[], int p, int q, int r); // 合并函数 void main() { int list[6] = { 1, 5, 6, 2, 3, 4 }; for (int i = 0; i < 6; i++) printf("%d ", list[i]); sort_merge(list, 6); printf("\n"); for (int i = 0; i < 6; i++) printf("%d ", list[i]); } // 把数组分为两半,然后再继续分两半,一直分到只有2个元素,再对比其大小,小的在前大的在后 // 归并排序,传入数组和长度 void sort_merge(int list[], int n) { sort_merge_c(list, 0, n-1); } // 归并排序递归调用函数,传入数组、首元素下标、尾元素下标 void sort_merge_c(int a[], int p, int r) { if (p >= r)return; // 递归出口 int q = (p + r) / 2; // 取 p 和 r 的中间值 sort_merge_c(a, p, q); // 左边部分的数组 sort_merge_c(a, q + 1, r); // 右边部分的数组 merge(a, p, q, r); // 合并数组 } // 合并数组 // 数组、首元素、中间元素、尾元素 void merge(int arr[], int p, int q, int r) { int* temp; int i, j, k; temp = (int*)malloc((r - p + 1) * sizeof(int)); // 创建一个长度和原数组一样的数组 if (!temp) abort(); // exit(1) 程序异常终止 // i为前一半元素的首地址,j为后一半元素首地址,k为临时数组的当前下标 // 将i或j里面小的那一个放进临时数组 for (i = p, j = q + 1, k = 0; i <= q && j <= r;) { if (arr[i] <= arr[j]) temp[k++] = arr[i++]; else temp[k++] = arr[j++]; } // 下面就是用来连接,数组中没有参加上面计算的元素,把arr中的其他元素也搬进temp,用于下一次递归 // 哪一个数组有剩余元素 int start = i, end = q; // 默认是左边 if (j <= r) { // 如果右边的有剩余元素 start = j; // 交换一下,把下标都换成右边的 end = r; } // 把剩余元素拷贝进临时数组 while (start <= end) { temp[k++] = arr[start++]; } // 把整理好的数字返回给原始数组 memcpy(arr + p, temp, (r - p + 1) * sizeof(int)); free(temp); }
22.514706
67
0.570216
7e64b031da185104f84d7ef9a3a726d92a48f30e
3,367
c
C
2_Simple Kernel Module/HW2_2.c
an36/Linux-Char-Dev-Driver
3aadc75d8d9ff67f277a82f1b9d8b26617cd200a
[ "MIT" ]
null
null
null
2_Simple Kernel Module/HW2_2.c
an36/Linux-Char-Dev-Driver
3aadc75d8d9ff67f277a82f1b9d8b26617cd200a
[ "MIT" ]
null
null
null
2_Simple Kernel Module/HW2_2.c
an36/Linux-Char-Dev-Driver
3aadc75d8d9ff67f277a82f1b9d8b26617cd200a
[ "MIT" ]
null
null
null
/* * Abdullah Almarzouq (an36@pdx.edu) * 4/22/2020 * * HW2_2: kernel module with 1 parameter called exam */ #include <linux/module.h> #include <linux/types.h> #include <linux/kdev_t.h> #include <linux/fs.h> #include <linux/cdev.h> #include <linux/slab.h> #include <linux/uaccess.h> #define DEVCNT 5 #define DEVNAME "HW2_2" static struct mydev_dev { struct cdev my_cdev; dev_t mydev_node; int syscall_val; } mydev; /* this shows up under /sys/modules/HW2_2/parameters */ static int exam; module_param(exam, int, S_IRUSR | S_IWUSR); static int HW2_2_open(struct inode *inode, struct file *file) { printk(KERN_INFO "successfully opened!\n"); mydev.syscall_val = exam; return 0; } static ssize_t HW2_2_read(struct file *file, char __user *buf, size_t len, loff_t *offset) { /* Get a local kernel buffer set aside */ int ret; if (*offset >= sizeof(int)){ return 0; } /* Make sure our user wasn't bad... */ if (!buf) { ret = -EINVAL; goto out; } if (copy_to_user(buf, &mydev.syscall_val, sizeof(int))) { ret = -EFAULT; goto out; } ret = sizeof(int); *offset += sizeof(int); /* Good to go, so printk the thingy */ printk(KERN_INFO "syscall_val= %d\n", mydev.syscall_val); out: return ret; } static ssize_t HW2_2_write(struct file *file, const char __user *buf, size_t len, loff_t *offset) { /* Have local kernel memory ready */ char *kern_buf; int ret, res; /* Make sure our user isn't bad... */ if (!buf) { ret = -EINVAL; goto out; } /* Get some memory to copy into... */ kern_buf = kmalloc(len, GFP_KERNEL); /* ...and make sure it's good to go */ if (!kern_buf) { ret = -ENOMEM; goto out; } /* Copy from the user-provided buffer */ if (copy_from_user(kern_buf, buf, len)) { /* uh-oh... */ ret = -EFAULT; goto mem_out; } ret = len; /* print what userspace gave us */ printk(KERN_INFO "Userspace wrote \"%s\" to syscall_val\n", kern_buf); /*converting ascii/string to int*/ res= kstrtoint(kern_buf,10,&mydev.syscall_val); if(res){ ret= -EINVAL; goto out; } mem_out: kfree(kern_buf); out: return ret; } /* File operations for our device */ static struct file_operations mydev_fops = { .owner = THIS_MODULE, .open = HW2_2_open, .read = HW2_2_read, .write = HW2_2_write, }; static int __init HW2_2_init(void) { printk("HW2_2 module loading... exam=%d\n",exam); if (alloc_chrdev_region(&mydev.mydev_node, 0, DEVCNT, DEVNAME)) { printk(KERN_ERR "alloc_chrdev_region() failed!\n"); return -1; } printk(KERN_INFO "Allocated %d devices at major: %d\n", DEVCNT, MAJOR(mydev.mydev_node)); /* Initialize the character device and add it to the kernel */ cdev_init(&mydev.my_cdev, &mydev_fops); mydev.my_cdev.owner = THIS_MODULE; if (cdev_add(&mydev.my_cdev, mydev.mydev_node, DEVCNT)) { printk(KERN_ERR "cdev_add() failed!\n"); /* clean up chrdev allocation */ unregister_chrdev_region(mydev.mydev_node, DEVCNT); return -1; } return 0; } static void __exit HW2_2_exit(void) { /* destroy the cdev */ cdev_del(&mydev.my_cdev); /* clean up the devices */ unregister_chrdev_region(mydev.mydev_node, DEVCNT); printk(KERN_INFO "HW2_2 module unloaded!\n"); } MODULE_AUTHOR("HW2_2"); MODULE_LICENSE("GPL"); MODULE_VERSION("0.1"); module_init(HW2_2_init); module_exit(HW2_2_exit);
19.923077
71
0.668845
0bdbd292760ebae96f8e922e079e540d3b7a03af
656
h
C
PrivateFrameworks/AddressBookCore/ABCNChainedPhotoFuture.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
17
2018-11-13T04:02:58.000Z
2022-01-20T09:27:13.000Z
PrivateFrameworks/AddressBookCore/ABCNChainedPhotoFuture.h
phatblat/macOSPrivateFrameworks
9047371eb80f925642c8a7c4f1e00095aec66044
[ "MIT" ]
3
2018-04-06T02:02:27.000Z
2018-10-02T01:12:10.000Z
PrivateFrameworks/AddressBookCore/ABCNChainedPhotoFuture.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 "CNFuture.h" @class ABCNChainedFutureQueue; @interface ABCNChainedPhotoFuture : CNFuture { ABCNChainedFutureQueue *_futureQueue; } + (id)chainedFutureWithFutures:(id)arg1; - (void).cxx_destruct; - (id)description; - (void)cancelCurrentAndRemainingFutures; - (void)didCancel; - (BOOL)resultDataIsEmpty:(id)arg1; - (void)nextWithResult:(id)arg1; - (void)addCompletionBlocksToFuture:(id)arg1; - (void)runNextFuture; - (void)addCompletionBlocksToSelf; - (void)start; - (id)initWithFutures:(id)arg1; @end
21.16129
83
0.730183
6d26472ef7c589e4b56924b25726557090e047be
3,529
c
C
CS50x 2021/Week 4/2- PSet 4 Filter (Less)/helpers.c
moqdm/CS50x
7d9a4b4cbe96516383727dc70a1a274f2beb2d28
[ "MIT" ]
7
2021-10-05T16:06:09.000Z
2022-03-14T07:02:33.000Z
CS50x 2021/Week 4/2- PSet 4 Filter (Less)/helpers.c
moqdm/CS50x
7d9a4b4cbe96516383727dc70a1a274f2beb2d28
[ "MIT" ]
null
null
null
CS50x 2021/Week 4/2- PSet 4 Filter (Less)/helpers.c
moqdm/CS50x
7d9a4b4cbe96516383727dc70a1a274f2beb2d28
[ "MIT" ]
7
2021-10-10T12:35:32.000Z
2021-12-30T16:03:51.000Z
#include "helpers.h" #include <math.h> // Convert image to grayscale void grayscale(int height, int width, RGBTRIPLE image[height][width]) { for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { //Get RGBTriple values float blue = image[i][j].rgbtBlue; float green = image[i][j].rgbtGreen; float red = image[i][j].rgbtRed; //Calculate average int average = round((red + blue + green) / 3); //Set all values = average image[i][j].rgbtBlue = image[i][j].rgbtGreen = image[i][j].rgbtRed = average; } } return; } // Convert image to sepia void sepia(int height, int width, RGBTRIPLE image[height][width]) { for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { //Get RGB values int red = image[i][j].rgbtRed; int green = image[i][j].rgbtGreen; int blue = image[i][j].rgbtBlue; // Get sepia values based on sepia formula and round it int sepiaRed = round(0.393 * red + 0.769 * green + 0.189 * blue); int sepiaGreen = round(0.349 * red + 0.686 * green + 0.168 * blue); int sepiaBlue = round(0.272 * red + 0.534 * green + 0.131 * blue); //Limit values at 255 and RGB values = sepia values image[i][j].rgbtRed = fmin(255, sepiaRed); image[i][j].rgbtGreen = fmin(255, sepiaGreen); image[i][j].rgbtBlue = fmin(255, sepiaBlue); } } return; } // Reflect image horizontally void reflect(int height, int width, RGBTRIPLE image[height][width]) { for (int i = 0; i < height; i++) { for (int j = 0; j < width / 2; j++) { //Reflect pixels RGBTRIPLE temp = image[i][j]; image[i][j] = image[i][width - (j + 1)]; image[i][width - (j + 1)] = temp; } } return; } // Blur image void blur(int height, int width, RGBTRIPLE image[height][width]) { RGBTRIPLE temp[height][width]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { temp[i][j] = image[i][j]; } } for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { //Initialise values float sum_red; float sum_blue; float sum_green; int counter; sum_red = sum_blue = sum_green = counter = 0; for (int k = -1; k < 2; k++) { for (int l = -1; l < 2; l++) { //Check if pixel is outside rows if (i + k < 0 || i + k >= height) { continue; } //Check if pixel is outside columns if (j + l < 0 || j + l >= width) { continue; } sum_red += temp[i + k][j + l].rgbtRed; sum_blue += temp[i + k][j + l].rgbtBlue; sum_green += temp[i + k][j + l].rgbtGreen; counter++; } } //Get average and blur image image[i][j].rgbtRed = round(sum_red / counter); image[i][j].rgbtGreen = round(sum_green / counter); image[i][j].rgbtBlue = round(sum_blue / counter); } } return; }
31.508929
89
0.452819
75c2096c3f4c4cf51fd5bff7329dff446fdc3d73
449
h
C
opt/opt.h
qixiuai/BCGHeart
b1127fa4420b658308acd883bc11945b7fcac4df
[ "MIT" ]
null
null
null
opt/opt.h
qixiuai/BCGHeart
b1127fa4420b658308acd883bc11945b7fcac4df
[ "MIT" ]
null
null
null
opt/opt.h
qixiuai/BCGHeart
b1127fa4420b658308acd883bc11945b7fcac4df
[ "MIT" ]
null
null
null
#ifndef OPT_OPT_H_ #define OPT_OPT_H_ /** max f(w, n) with n fixed w; * max g(W) with to w fixed n; * g(W) = linear(W) ||W|| = 1; */ class Optimizer { Optimizer(Function func, Function grad_func, Constraint constraint); void Run(); }; class Variable { }; class Function { }; class Problem { Problem(Function func, Function grad_func, Constraint constraint); }; class Constraint { }; class Graident { }; #endif
9.977778
70
0.632517
924e2673e73d95bf2e4e0169b70ef909297af0a6
1,504
h
C
Stealth/src/WorldRenderer.h
Pharap/StealthGame
ccc68d2e96bb1769bcceefdff7cb0f551ad143de
[ "Apache-2.0" ]
null
null
null
Stealth/src/WorldRenderer.h
Pharap/StealthGame
ccc68d2e96bb1769bcceefdff7cb0f551ad143de
[ "Apache-2.0" ]
null
null
null
Stealth/src/WorldRenderer.h
Pharap/StealthGame
ccc68d2e96bb1769bcceefdff7cb0f551ad143de
[ "Apache-2.0" ]
1
2019-10-07T23:37:08.000Z
2019-10-07T23:37:08.000Z
#pragma once // // Copyright (C) 2019 Pharap (@Pharap) // // 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 <stdint.h> #include <stddef.h> #include <Arduboy2.h> #include "World.h" struct WorldRenderer { template<uint8_t tileWidth = 8, uint8_t tileHeight = tileWidth> static void render(Arduboy2 & arduboy, const World & world) { const uint8_t screenWidth = (arduboy.width() / tileWidth); const uint8_t screenHeight = (arduboy.height() / tileHeight); const uint8_t worldWidth = world.getWidth(); const uint8_t worldHeight = world.getHeight(); const uint8_t maxX = min(screenWidth, worldWidth); const uint8_t maxY = min(screenHeight, worldHeight); for(uint8_t y = 0; y < maxY; ++y) { const int16_t drawY = (y * tileHeight); for(uint8_t x = 0; x < maxX; ++x) { const int16_t drawX = (x * tileWidth); if(world.isSolid(x, y)) arduboy.drawRect(drawX, drawY, tileWidth, tileHeight); } } } };
28.923077
76
0.678856
ffa9b6b49e23863becefae06bea8146fe7463404
2,529
h
C
src/cuckoofilter.h
shuiying1037/E2CF
426c1af6cc4fa415a71ef998c2a42b7d2d512883
[ "Apache-2.0" ]
3
2020-11-26T01:53:18.000Z
2021-11-24T10:02:37.000Z
src/cuckoofilter.h
shuiying1037/E2CF
426c1af6cc4fa415a71ef998c2a42b7d2d512883
[ "Apache-2.0" ]
null
null
null
src/cuckoofilter.h
shuiying1037/E2CF
426c1af6cc4fa415a71ef998c2a42b7d2d512883
[ "Apache-2.0" ]
2
2020-11-26T01:53:21.000Z
2020-12-29T09:03:22.000Z
#ifndef CUCKOOFILTER_H_ #define CUCKOOFILTER_H_ #include<string.h> #include<stdlib.h> #include"hashfunction.h" #include"bithack.h" #include"stdint.h" #define MaxNumKicks 40 using namespace std; typedef struct { size_t index; uint32_t fingerprint; } Victim; typedef struct{ char* bit_array; } Bucket; class CuckooFilter{ private: int capacity; size_t single_table_length; size_t fingerprint_size; size_t bits_per_bucket; size_t bytes_per_bucket; Bucket* bucket; uint32_t mask; //myself size_t tags_per_bucket; public: bool is_full; bool is_empty; int counter; CuckooFilter* next; CuckooFilter* front; //construction and distruction function CuckooFilter(const size_t single_table_length, const size_t fingerprint_size, const int capacity); ~CuckooFilter(); //insert & query & delete function int insertItem(const char* item, Victim &victim); bool insertItem(const size_t index, const uint32_t fingerprint, bool kickout, Victim &victim); bool queryItem(const char* item); // bool deleteItem(const char* item); bool insertImpl(const size_t index, const uint32_t fingerprint, const bool kickout, Victim &victim); bool queryImpl(const size_t index, const uint32_t fingerprint,size_t PowLevel); bool deleteImpl(const size_t index, const uint32_t fingerprint,size_t nPowlevel); //generate two candidate bucket addresses // void generateIF(const char* item, size_t &index, uint32_t &fingerprint, int fingerprint_size, int single_table_length); void generateA(size_t index, uint32_t fingerprint, size_t &alt_index, int single_table_length); //read from bucket & write into bucket uint32_t read(const size_t index, const size_t pos, size_t Pow_level); void write(const size_t index, const size_t pos, const uint32_t fingerprint, size_t Pow_level); //move corresponding fingerprints to sparser CF bool transfer(CuckooFilter* tarCF); bool insertImpl(const size_t index, const uint32_t fingerprint, size_t Pow_level, const bool kickout, Victim &victim); // uint64_t* moveodd_self_naive(int versionID,int iBucket,uint64_t* aBucket); uint64_t* moveodd_addItem(int versionID,int iBucket, uint64_t* aBucket,uint32_t fingerprint); void addBNewCF(size_t verID,size_t ibucket,uint64_t aBucket); void addBNewCF_naive(int iBucket,uint64_t aBucket); void addBNewCF_addItem(int versionID,size_t iBucket,uint32_t fingerprint); char* getBucket(uint32_t index); int Level; }; #endif //CUCKOOFILTER_H_
29.068966
124
0.761566
4dcd82f5e4fc12f03739f807e115cd4b5ffe82c6
782
c
C
libevent/two.c
AoEiuV020/linux
644c25e39e6d647b70114c49434d8e01ef031328
[ "MIT" ]
null
null
null
libevent/two.c
AoEiuV020/linux
644c25e39e6d647b70114c49434d8e01ef031328
[ "MIT" ]
null
null
null
libevent/two.c
AoEiuV020/linux
644c25e39e6d647b70114c49434d8e01ef031328
[ "MIT" ]
null
null
null
/***************************************************** ^> File Name: two.c ^> Author: AoEiuV020 ^> Mail: 490674483@qq.com ^> Created Time: 2015/12/02 - 16:00:06 ****************************************************/ #include <stdio.h> #include <event.h> #include <unistd.h> void foo(int sock,short event,void *arg) { while(1) { printf("foo...\n"); sleep(1); } } void bar(int sock,short event,void *arg) { while(1) { printf("bar...\n"); sleep(1); } } int main(int argc, char **argv) { struct timeval tv; tv.tv_sec=0; tv.tv_usec=500000; event_init(); struct event evt; evtimer_set(&evt,foo,NULL); event_add(&evt,&tv); struct event evtb; evtimer_set(&evtb,bar,NULL); tv.tv_usec=0; event_add(&evtb,&tv); event_dispatch(); printf("end...\n"); return 0; }
17.772727
54
0.548593
321b513b0526138e9ce89cdc552e07a12e57a773
2,795
h
C
Engine/Source/Runtime/Core/YumeTimer.h
rodrigobmg/YumeEngine
67c525c84616a5167b5bae45f36641e90227c281
[ "MIT" ]
129
2016-05-05T23:34:44.000Z
2022-03-07T20:17:18.000Z
Engine/Source/Runtime/Core/YumeTimer.h
rodrigobmg/YumeEngine
67c525c84616a5167b5bae45f36641e90227c281
[ "MIT" ]
1
2017-05-07T16:09:41.000Z
2017-05-08T15:35:50.000Z
Engine/Source/Runtime/Core/YumeTimer.h
rodrigobmg/YumeEngine
67c525c84616a5167b5bae45f36641e90227c281
[ "MIT" ]
20
2016-02-24T20:40:08.000Z
2022-02-04T23:48:18.000Z
//---------------------------------------------------------------------------- //Yume Engine //Copyright (C) 2015 arkenthera //This program is free software; you can redistribute it and/or modify //it under the terms of the GNU General Public License as published by //the Free Software Foundation; either version 2 of the License, or //(at your option) any later version. //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. //You should have received a copy of the GNU General Public License along //with this program; if not, write to the Free Software Foundation, Inc., //51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.*/ //---------------------------------------------------------------------------- // // File : <Filename> YumeGraphics.h // Date : 2.19.2016 // Comments : // //---------------------------------------------------------------------------- #ifndef __YumeTimer_h__ #define __YumeTimer_h__ //---------------------------------------------------------------------------- #include "YumeRequired.h" #include "YumeEventHub.h" #include <boost/timer.hpp> //---------------------------------------------------------------------------- namespace YumeEngine { class YumeAPIExport YumeLowresTimer { public: YumeLowresTimer(); unsigned GetMSec(bool reset); void Reset(); private: unsigned startTime_; }; class YumeAPIExport YumeHiresTimer { friend class YumeTime; public: YumeHiresTimer(); long long GetUSec(bool reset); void Reset(); static bool IsSupported() { return supported; } static long long GetFrequency() { return frequency; } private: long long startTime_; static bool supported; static long long frequency; }; class YumeAPIExport YumeTime : public RefCounted { public: YumeTime(); ~YumeTime(); void BeginFrame(float dt); void EndFrame(); static void Sleep(unsigned mSce); int GetFrameNumber() const { return frameNumber_; } float GetTimeStep() const { return timeStep_; } YumeString GetTimeStamp(); double GetElapsedTime(); void fireFrameBegin(int frameNumber); void fireFrameEnd(int frameNumber); protected: typedef YumeVector<YumeTimerEventListener*>::type TimeEventListeners; TimeEventListeners listenerList_; public: void AddTimeEventListener(YumeTimerEventListener* listener); void RemoveTimeEventListener(YumeTimerEventListener* listener); void RemoveAllListeners(); protected: int frameNumber_; double timeStep_; boost::timer totalTime_; }; } //---------------------------------------------------------------------------- #endif
24.517544
78
0.611807
9a819f4700869cd3b71ba4afef0c4283b00a056c
9,642
h
C
src/v8binder/CTypeJS.h
log245/XScript
28edca1454ad5c601164227766177957ddc6edff
[ "MIT" ]
1
2020-03-09T01:58:04.000Z
2020-03-09T01:58:04.000Z
src/v8binder/CTypeJS.h
log245/XScript
28edca1454ad5c601164227766177957ddc6edff
[ "MIT" ]
null
null
null
src/v8binder/CTypeJS.h
log245/XScript
28edca1454ad5c601164227766177957ddc6edff
[ "MIT" ]
null
null
null
/**@file CTypeJS.h * @brief Data interface between V8&c++ * @author Daphnis Kau * @date 2019-06-24 * @version V1.0 */ #ifndef __TYPE_JS_H__ #define __TYPE_JS_H__ #include "common/Memory.h" #include "core/CTypeBase.h" #include "V8Context.h" #include "CScriptJS.h" namespace XS { #define MAX_UNKNOW_ARRAYBUFFER_SIZE (100*1024*1024) class CJSTypeBase; //===================================================================== /// aux function //===================================================================== CJSTypeBase* GetJSTypeBase( DataType eType ); //===================================================================== /// Base class of data type //===================================================================== class CJSTypeBase : public CTypeBase { public: CJSTypeBase() {} virtual void FromVMValue(DataType eType, CScriptJS& Script, char* pDataBuf, v8::Local<v8::Value> obj) = 0; virtual LocalValue ToVMValue(DataType eType, CScriptJS& Script, char* pDataBuf) = 0; }; //===================================================================== /// Common class of data type //===================================================================== template<typename T> class TJSValue : public CJSTypeBase { public: void FromVMValue(DataType eType, CScriptJS& Script, char* pDataBuf, LocalValue obj) { v8::Isolate* isolate = Script.GetV8Context().m_pIsolate; v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::MaybeLocal<v8::Int32> v = obj->ToInt32(context); *(T*)(pDataBuf) = (T)( v.IsEmpty() ? 0 : v.ToLocalChecked()->Value() ); } LocalValue ToVMValue(DataType eType, CScriptJS& Script, char* pDataBuf) { return v8::Int32::New(Script.GetV8Context().m_pIsolate, (int32)*(T*)(pDataBuf)); } static TJSValue<T>& GetInst() { static TJSValue<T> s_Instance; return s_Instance; } }; // POD type class specialization template<> inline void TJSValue<double>::FromVMValue( DataType eType, CScriptJS& Script, char* pDataBuf, LocalValue obj) { v8::Isolate* isolate = Script.GetV8Context().m_pIsolate; v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::MaybeLocal<v8::Number> v = obj->ToNumber(context); *(double*)(pDataBuf) = v.IsEmpty() ? 0 : v.ToLocalChecked()->Value(); } template<> inline LocalValue TJSValue<double>::ToVMValue( DataType eType, CScriptJS& Script, char* pDataBuf) { return v8::Number::New(Script.GetV8Context().m_pIsolate, *(double*)(pDataBuf)); } template<> inline void TJSValue<float>::FromVMValue( DataType eType, CScriptJS& Script, char* pDataBuf, LocalValue obj) { v8::Isolate* isolate = Script.GetV8Context().m_pIsolate; v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::MaybeLocal<v8::Number> v = obj->ToNumber(context); *(float*)(pDataBuf) = (float)( v.IsEmpty() ? 0 : v.ToLocalChecked()->Value() ); } template<> inline LocalValue TJSValue<float>::ToVMValue( DataType eType, CScriptJS& Script, char* pDataBuf) { return v8::Number::New(Script.GetV8Context().m_pIsolate, *(float*)(pDataBuf)); } template<> inline void TJSValue<uint64>::FromVMValue( DataType eType, CScriptJS& Script, char* pDataBuf, LocalValue obj) { v8::Isolate* isolate = Script.GetV8Context().m_pIsolate; v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::MaybeLocal<v8::Number> v = obj->ToNumber(context); *(uint64*)(pDataBuf) = (uint64)( v.IsEmpty() ? 0 : v.ToLocalChecked()->Value() ); } template<> inline LocalValue TJSValue<uint64>::ToVMValue( DataType eType, CScriptJS& Script, char* pDataBuf) { v8::Isolate* isolate = Script.GetV8Context().m_pIsolate; return v8::Number::New(isolate, (double)*(uint64*)(pDataBuf)); } template<> inline void TJSValue<ulong>::FromVMValue( DataType eType, CScriptJS& Script, char* pDataBuf, LocalValue obj) { v8::Isolate* isolate = Script.GetV8Context().m_pIsolate; v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::MaybeLocal<v8::Number> v = obj->ToNumber(context); *(ulong*)(pDataBuf) = (ulong)( v.IsEmpty() ? 0 : v.ToLocalChecked()->Value() ); } template<> inline LocalValue TJSValue<ulong>::ToVMValue( DataType eType, CScriptJS& Script, char* pDataBuf) { v8::Isolate* isolate = Script.GetV8Context().m_pIsolate; return v8::Number::New(isolate, (double)*(ulong*)(pDataBuf)); } template<> inline void TJSValue<int64>::FromVMValue( DataType eType, CScriptJS& Script, char* pDataBuf, LocalValue obj) { v8::Isolate* isolate = Script.GetV8Context().m_pIsolate; v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::MaybeLocal<v8::Number> v = obj->ToNumber(context); *(int64*)(pDataBuf) = (int64)( v.IsEmpty() ? 0 : v.ToLocalChecked()->Value() ); } template<> inline LocalValue TJSValue<int64>::ToVMValue( DataType eType, CScriptJS& Script, char* pDataBuf) { v8::Isolate* isolate = Script.GetV8Context().m_pIsolate; return v8::Number::New(isolate, (double)*(int64*)(pDataBuf)); } template<> inline void TJSValue<long>::FromVMValue( DataType eType, CScriptJS& Script, char* pDataBuf, LocalValue obj) { v8::Isolate* isolate = Script.GetV8Context().m_pIsolate; v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::MaybeLocal<v8::Number> v = obj->ToNumber(context); *(long*)(pDataBuf) = (long)( v.IsEmpty() ? 0 : v.ToLocalChecked()->Value()); } template<> inline LocalValue TJSValue<long>::ToVMValue( DataType eType, CScriptJS& Script, char* pDataBuf) { v8::Isolate* isolate = Script.GetV8Context().m_pIsolate; return v8::Number::New(isolate, *(long*)(pDataBuf)); } template<> inline void TJSValue<uint32>::FromVMValue( DataType eType, CScriptJS& Script, char* pDataBuf, LocalValue obj) { v8::Isolate* isolate = Script.GetV8Context().m_pIsolate; v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::MaybeLocal<v8::Uint32> v = obj->ToUint32(context); *(uint32*)(pDataBuf) = v.IsEmpty() ? 0 : v.ToLocalChecked()->Value(); } template<> inline LocalValue TJSValue<uint32>::ToVMValue( DataType eType, CScriptJS& Script, char* pDataBuf) { v8::Isolate* isolate = Script.GetV8Context().m_pIsolate; return v8::Uint32::New(isolate, *(uint32*)(pDataBuf)); } template<> inline void TJSValue<bool>::FromVMValue( DataType eType, CScriptJS& Script, char* pDataBuf, LocalValue obj) { v8::Isolate* isolate = Script.GetV8Context().m_pIsolate; v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::MaybeLocal<v8::Boolean> v = obj->ToBoolean(context); *(bool*)(pDataBuf) = v.IsEmpty() ? 0 : v.ToLocalChecked()->Value(); } template<> inline LocalValue TJSValue<bool>::ToVMValue( DataType eType, CScriptJS& Script, char* pDataBuf) { v8::Isolate* isolate = Script.GetV8Context().m_pIsolate; return v8::Boolean::New(isolate, *(bool*)(pDataBuf)); } template<> inline void TJSValue<void*>::FromVMValue( DataType eType, CScriptJS& Script, char* pDataBuf, LocalValue obj) { if (obj->IsArrayBufferView()) { v8::ArrayBufferView* view = v8::ArrayBufferView::Cast(*obj); char* data = (char*)view->Buffer()->GetContents().Data(); *(void**)(pDataBuf) = data + view->ByteOffset(); } else if (obj->IsArrayBuffer()) *(void**)(pDataBuf) = v8::ArrayBuffer::Cast(*obj)->GetContents().Data(); else *(void**)(pDataBuf) = NULL; } template<> inline LocalValue TJSValue<void*>::ToVMValue( DataType eType, CScriptJS& Script, char* pDataBuf) { return v8::ArrayBuffer::New(Script.GetV8Context().m_pIsolate, *(void**)(pDataBuf), MAX_UNKNOW_ARRAYBUFFER_SIZE); } template<> inline void TJSValue<const char*>::FromVMValue( DataType eType, CScriptJS& Script, char* pDataBuf, LocalValue obj) { *(const char**)(pDataBuf) = Script.GetV8Context().StringToUtf8( obj ); } template<> inline LocalValue TJSValue<const char*>::ToVMValue( DataType eType, CScriptJS& Script, char* pDataBuf) { return Script.GetV8Context().StringFromUtf8( *(const char**)(pDataBuf) ); } template<> inline void TJSValue<const wchar_t*>::FromVMValue( DataType eType, CScriptJS& Script, char* pDataBuf, LocalValue obj) { *(const wchar_t**)(pDataBuf) = Script.GetV8Context().StringToUcs( obj ); } template<> inline LocalValue TJSValue<const wchar_t*>::ToVMValue( DataType eType, CScriptJS& Script, char* pDataBuf) { return Script.GetV8Context().StringFromUcs(*(const wchar_t**)(pDataBuf)); } //===================================================================== /// Interface of class pointer //===================================================================== class CJSObject : public TJSValue<void*> { protected: const CClassInfo* _FromVMValue(DataType eType, CScriptJS& Script, char* pDataBuf, v8::Local<v8::Value> obj); LocalValue _ToVMValue(DataType eType, CScriptJS& Script, void* pObj, bool bCopy); public: CJSObject(); static CJSObject& GetInst(); virtual void FromVMValue(DataType eType, CScriptJS& Script, char* pDataBuf, v8::Local<v8::Value> obj); virtual LocalValue ToVMValue(DataType eType, CScriptJS& Script, char* pDataBuf); }; //===================================================================== /// Interface of class value //===================================================================== class CJSValueObject : public CJSObject { public: CJSValueObject(); static CJSValueObject& GetInst(); virtual void FromVMValue(DataType eType, CScriptJS& Script, char* pDataBuf, v8::Local<v8::Value> obj); virtual LocalValue ToVMValue(DataType eType, CScriptJS& Script, char* pDataBuf); }; } #endif
34.934783
83
0.648309
9ad3fa9d31202dd4d3fd9101a4543dce23041b81
8,253
c
C
dependencies/otp/r15b03-1/erts/emulator/hipe/hipe_x86_stack.c
mosaic-cloud/mosaic-distribution-dependencies
87b9fa3dcf24751abcc52c00849b85f4d7e77b16
[ "Apache-2.0" ]
null
null
null
dependencies/otp/r15b03-1/erts/emulator/hipe/hipe_x86_stack.c
mosaic-cloud/mosaic-distribution-dependencies
87b9fa3dcf24751abcc52c00849b85f4d7e77b16
[ "Apache-2.0" ]
null
null
null
dependencies/otp/r15b03-1/erts/emulator/hipe/hipe_x86_stack.c
mosaic-cloud/mosaic-distribution-dependencies
87b9fa3dcf24751abcc52c00849b85f4d7e77b16
[ "Apache-2.0" ]
null
null
null
/* * %CopyrightBegin% * * Copyright Ericsson AB 2001-2011. All Rights Reserved. * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. * * %CopyrightEnd% */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "global.h" #include "bif.h" #include "hipe_stack.h" #ifdef __x86_64__ #include "hipe_amd64_asm.h" /* for NR_ARG_REGS */ #else #include "hipe_x86_asm.h" /* for NR_ARG_REGS */ #endif extern void nbif_fail(void); extern void nbif_stack_trap_ra(void); /* * hipe_print_nstack() is called from hipe_bifs:show_nstack/1. */ static void print_slot(Eterm *sp, unsigned int live) { Eterm val = *sp; printf(" | 0x%0*lx | 0x%0*lx | ", 2*(int)sizeof(long), (unsigned long)sp, 2*(int)sizeof(long), val); if (live) erts_printf("%.30T", val); printf("\r\n"); } void hipe_print_nstack(Process *p) { Eterm *nsp; Eterm *nsp_end; struct sdesc sdesc0; const struct sdesc *sdesc1; const struct sdesc *sdesc; unsigned long ra; unsigned long exnra; unsigned int mask; unsigned int sdesc_size; unsigned int i; unsigned int nstkarity; static const char dashes[2*sizeof(long)+5] = { [0 ... 2*sizeof(long)+3] = '-' }; nsp = p->hipe.nsp; nsp_end = p->hipe.nstend; nstkarity = p->hipe.narity - NR_ARG_REGS; if ((int)nstkarity < 0) nstkarity = 0; sdesc0.summary = nstkarity; sdesc0.livebits[0] = ~1; sdesc = &sdesc0; printf(" | NATIVE STACK |\r\n"); printf(" |%s|%s|\r\n", dashes, dashes); printf(" | %*s | 0x%0*lx |\r\n", 2+2*(int)sizeof(long), "heap", 2*(int)sizeof(long), (unsigned long)p->heap); printf(" | %*s | 0x%0*lx |\r\n", 2+2*(int)sizeof(long), "high_water", 2*(int)sizeof(long), (unsigned long)p->high_water); printf(" | %*s | 0x%0*lx |\r\n", 2+2*(int)sizeof(long), "hend", 2*(int)sizeof(long), (unsigned long)p->htop); printf(" | %*s | 0x%0*lx |\r\n", 2+2*(int)sizeof(long), "old_heap", 2*(int)sizeof(long), (unsigned long)p->old_heap); printf(" | %*s | 0x%0*lx |\r\n", 2+2*(int)sizeof(long), "old_hend", 2*(int)sizeof(long), (unsigned long)p->old_hend); printf(" | %*s | 0x%0*lx |\r\n", 2+2*(int)sizeof(long), "nsp", 2*(int)sizeof(long), (unsigned long)p->hipe.nsp); printf(" | %*s | 0x%0*lx |\r\n", 2+2*(int)sizeof(long), "nstend", 2*(int)sizeof(long), (unsigned long)p->hipe.nstend); printf(" | %*s| 0x%0*lx |\r\n", 2+2*(int)sizeof(long)+1, "nstblacklim", 2*(int)sizeof(long), (unsigned long)p->hipe.nstblacklim); printf(" | %*s | 0x%0*lx |\r\n", 2+2*(int)sizeof(long), "nstgraylim", 2*(int)sizeof(long), (unsigned long)p->hipe.nstgraylim); printf(" | %*s | 0x%0*x |\r\n", 2+2*(int)sizeof(long), "narity", 2*(int)sizeof(long), p->hipe.narity); printf(" |%s|%s|\r\n", dashes, dashes); printf(" | %*s | %*s |\r\n", 2+2*(int)sizeof(long), "Address", 2+2*(int)sizeof(long), "Contents"); for (;;) { printf(" |%s|%s|\r\n", dashes, dashes); if (nsp >= nsp_end) { if (nsp == nsp_end) return; fprintf(stderr, "%s: passed end of stack\r\n", __FUNCTION__); break; } ra = nsp[sdesc_fsize(sdesc)]; if (ra == (unsigned long)nbif_stack_trap_ra) sdesc1 = hipe_find_sdesc((unsigned long)p->hipe.ngra); else sdesc1 = hipe_find_sdesc(ra); sdesc_size = sdesc_fsize(sdesc) + 1 + sdesc_arity(sdesc); i = 0; mask = sdesc->livebits[0]; for (;;) { if (i == sdesc_fsize(sdesc)) { printf(" | 0x%0*lx | 0x%0*lx | ", 2*(int)sizeof(long), (unsigned long)&nsp[i], 2*(int)sizeof(long), ra); if (ra == (unsigned long)nbif_stack_trap_ra) printf("STACK TRAP, ORIG RA 0x%lx", (unsigned long)p->hipe.ngra); else printf("NATIVE RA"); if ((exnra = sdesc_exnra(sdesc1)) != 0) printf(", EXNRA 0x%lx", exnra); printf("\r\n"); } else print_slot(&nsp[i], (mask & 1)); if (++i >= sdesc_size) break; if (i & 31) mask >>= 1; else mask = sdesc->livebits[i >> 5]; } nsp += sdesc_size; sdesc = sdesc1; } abort(); } #define MINSTACK 128 #define NSKIPFRAMES 4 void hipe_update_stack_trap(Process *p, const struct sdesc *sdesc) { Eterm *nsp; Eterm *nsp_end; unsigned long ra; int n; nsp = p->hipe.nsp; nsp_end = p->hipe.nstend; if ((unsigned long)((char*)nsp_end - (char*)nsp) < MINSTACK*sizeof(Eterm*)) { p->hipe.nstgraylim = NULL; return; } n = NSKIPFRAMES; for (;;) { nsp += sdesc_fsize(sdesc); if (nsp >= nsp_end) { p->hipe.nstgraylim = NULL; return; } ra = nsp[0]; if (--n <= 0) break; nsp += 1 + sdesc_arity(sdesc); sdesc = hipe_find_sdesc(ra); } p->hipe.nstgraylim = nsp + 1 + sdesc_arity(sdesc); p->hipe.ngra = (void(*)(void))ra; nsp[0] = (unsigned long)nbif_stack_trap_ra; } /* * hipe_handle_stack_trap() is called when the mutator returns to * nbif_stack_trap_ra, which marks the gray/white stack boundary frame. * The gray/white boundary is moved back one or more frames. * * The function head below is "interesting". */ void (*hipe_handle_stack_trap(Process *p))(void) { void (*ngra)(void) = p->hipe.ngra; const struct sdesc *sdesc = hipe_find_sdesc((unsigned long)ngra); hipe_update_stack_trap(p, sdesc); return ngra; } /* * hipe_find_handler() is called from hipe_handle_exception() to locate * the current exception handler's PC and SP. * The native stack MUST contain a stack frame as it appears on * entry to a function (return address, actuals, caller's frame). * p->hipe.narity MUST contain the arity (number of actuals). * On exit, p->hipe.ncallee is set to the handler's PC and p->hipe.nsp * is set to its SP (low address of its stack frame). */ void hipe_find_handler(Process *p) { Eterm *nsp; Eterm *nsp_end; unsigned long ra; unsigned long exnra; unsigned int arity; const struct sdesc *sdesc; unsigned int nstkarity; nsp = p->hipe.nsp; nsp_end = p->hipe.nstend; nstkarity = p->hipe.narity - NR_ARG_REGS; if ((int)nstkarity < 0) nstkarity = 0; arity = nstkarity; while (nsp < nsp_end) { ra = nsp[0]; if (ra == (unsigned long)nbif_stack_trap_ra) ra = (unsigned long)p->hipe.ngra; sdesc = hipe_find_sdesc(ra); /* nsp = nsp + 1 + arity + sdesc_fsize(sdesc); */ nsp += 1; /* skip ra */ nsp += arity; /* skip actuals */ if ((exnra = sdesc_exnra(sdesc)) != 0 && (p->catches >= 0 || exnra == (unsigned long)nbif_fail)) { p->hipe.ncallee = (void(*)(void)) exnra; p->hipe.nsp = nsp; p->hipe.narity = 0; /* update the gray/white boundary if we threw past it */ if (p->hipe.nstgraylim && nsp >= p->hipe.nstgraylim) hipe_update_stack_trap(p, sdesc); return; } nsp += sdesc_fsize(sdesc); arity = sdesc_arity(sdesc); } fprintf(stderr, "%s: no native CATCH found!\r\n", __FUNCTION__); abort(); } int hipe_fill_stacktrace(Process *p, int depth, Eterm **trace) { Eterm *nsp; Eterm *nsp_end; unsigned long ra, prev_ra; unsigned int arity; const struct sdesc *sdesc; unsigned int nstkarity; int i; if (depth < 1) return 0; nsp = p->hipe.nsp; nsp_end = p->hipe.nstend; nstkarity = p->hipe.narity - NR_ARG_REGS; if ((int)nstkarity < 0) nstkarity = 0; arity = nstkarity; prev_ra = 0; i = 0; while (nsp < nsp_end) { /* INV: i < depth */ ra = nsp[0]; if (ra == (unsigned long)nbif_stack_trap_ra) ra = (unsigned long)p->hipe.ngra; if (ra != prev_ra) { trace[i] = (Eterm*)ra; ++i; if (i == depth) break; prev_ra = ra; } sdesc = hipe_find_sdesc(ra); nsp += 1 + arity + sdesc_fsize(sdesc); arity = sdesc_arity(sdesc); } return i; }
27.787879
81
0.612626
82a2ecbeed0f52ef27154ee18c00b339ba8f01de
1,195
h
C
build/lib/DateTimeTools/__data/libdatetime/DayNo.h
pshustov/DateTimeTools
e542fd3f0e3c5290faad09b7cf8a2751132d4dd3
[ "MIT" ]
null
null
null
build/lib/DateTimeTools/__data/libdatetime/DayNo.h
pshustov/DateTimeTools
e542fd3f0e3c5290faad09b7cf8a2751132d4dd3
[ "MIT" ]
null
null
null
build/lib/DateTimeTools/__data/libdatetime/DayNo.h
pshustov/DateTimeTools
e542fd3f0e3c5290faad09b7cf8a2751132d4dd3
[ "MIT" ]
null
null
null
#ifndef __DAYNO_H__ #define __DAYNO_H__ #include <stdio.h> #include <stdlib.h> #include "LeapYear.h" #include "DateSplit.h" #endif using namespace std; /*********************************************************************** * NAME : void DayNo(n,Date,Year,DayNo) * * DESCRIPTION : Work out the day numbers for an array of dates. * * INPUTS : * int n Number of dates * int *Date Integer dates in format yyyymmdd * * OUTPUTS : * int *Year output years * int *DayNo output day numbers * * ********************************************************************/ extern "C" { void DayNo(int n, int *Date, int *Year, int *DayNo); } /*********************************************************************** * NAME : void DayNotoDate(n,Year,DayNo,Date) * * DESCRIPTION : Converts year and day number to dates in the format * yyyymmdd * * INPUTS : * int n Number of dates * int *Year years * int *DayNo day numbers * * OUTPUTS : * int *Date Integer dates in format yyyymmdd * * ********************************************************************/ extern "C" { void DayNotoDate(int n, int *Year, int *Doy, int *Date); }
25.978261
72
0.481172
d621135008158e064b908d9cb12c98c396cd7db3
1,524
c
C
glibc/sysdeps/mips/fpu/fraiseexcpt.c
chyidl/mirror-glibc
3b17633afc85a9fb8cba0edc365d19403158c5a0
[ "BSD-3-Clause" ]
null
null
null
glibc/sysdeps/mips/fpu/fraiseexcpt.c
chyidl/mirror-glibc
3b17633afc85a9fb8cba0edc365d19403158c5a0
[ "BSD-3-Clause" ]
null
null
null
glibc/sysdeps/mips/fpu/fraiseexcpt.c
chyidl/mirror-glibc
3b17633afc85a9fb8cba0edc365d19403158c5a0
[ "BSD-3-Clause" ]
null
null
null
/* Raise given exceptions. Copyright (C) 2000-2020 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger <aj@suse.de>, 2000. 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 <https://www.gnu.org/licenses/>. */ #include <fenv.h> #include <fenv_libc.h> #include <fpu_control.h> int __feraiseexcept (int excepts) { fpu_control_t cw; /* Get current state. */ _FPU_GETCW (cw); /* Set flag bits (which are accumulative), and *also* set the cause bits. The setting of the cause bits is what actually causes the hardware to generate the exception, if the corresponding enable bit is set as well. */ excepts &= FE_ALL_EXCEPT; cw |= excepts | (excepts << CAUSE_SHIFT); /* Set new state. */ _FPU_SETCW (cw); return 0; } libm_hidden_def (__feraiseexcept) weak_alias (__feraiseexcept, feraiseexcept) libm_hidden_weak (feraiseexcept)
31.102041
72
0.725722
d2a9d24412435e7451f16a3a32f3b09eca693588
1,051
c
C
d/islands/tonerra/monastary/backup/m3.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
13
2019-07-19T05:24:44.000Z
2021-11-18T04:08:19.000Z
d/islands/tonerra/monastary/backup/m3.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
4
2021-03-15T18:56:39.000Z
2021-08-17T17:08:22.000Z
d/islands/tonerra/monastary/backup/m3.c
Dbevan/SunderingShadows
6c15ec56cef43c36361899bae6dc08d0ee907304
[ "MIT" ]
13
2019-09-12T06:22:38.000Z
2022-01-31T01:15:12.000Z
#include <std.h> #include "/d/islands/tonerra/monastary/short.h" inherit ROOM; void create(){ object ob; :: create(); set_light(2); set_indoors(1); set_short(" %^BOLD%^%^WHITE%^An old oriental monastary. "); set_long( @SEETH %^BOLD%^%^CYAN%^This appears to be the main chamber of the monastary. The room is lighted by the few torches along two opposite walls to the east and west, and what light that comes through the entrance. Lines of meditating monks sit on the ground on circular mats parallel to the torches. Directly infront of you is an old monk upon a platform also in meditation. Behind the old monk is a large statue of Buddha. You feel at peace in here. SEETH ); set_items(([ "statue" : "This is a large golden statue of Buddha.", "floor" : "The floors are made of large grey tiles. It appears clean.", "torches" : "normal torches along the walls.", ])); set_exits(([ "south" : RPATH "monastary.c", ])); set_smell("default", "The air is clean and comfortable."); set_listen("default", "You hear the breathing of the monks."); }
26.948718
440
0.721218
cf8c9c57fb39e12fe6765b970cb2b4eca8b0ed57
22,423
c
C
q3osc/ccrmamod/liblo/src/testlo.c
martinez-zea/localconflict
9b47c92b93315efe6a0a485a645d080f3ecf7e9a
[ "MIT" ]
1
2015-05-02T11:29:58.000Z
2015-05-02T11:29:58.000Z
q3osc/ccrmamod/liblo/src/testlo.c
martinez-zea/localconflict
9b47c92b93315efe6a0a485a645d080f3ecf7e9a
[ "MIT" ]
null
null
null
q3osc/ccrmamod/liblo/src/testlo.c
martinez-zea/localconflict
9b47c92b93315efe6a0a485a645d080f3ecf7e9a
[ "MIT" ]
null
null
null
/* * Copyright (C) 2004 Steve Harris * * 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. * * $Id: testlo.c 83 2007-03-13 16:15:18Z nhumfrey $ */ /* * This is some testcase code - it exercises the internals of liblo, so its not * a good example to learn from, see examples/ for example code */ #include <math.h> #include <float.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include "lo_types_internal.h" #include "lo/lo.h" #include "config.h" #ifdef WIN32 #define PATHDELIM "\\" #else #define PATHDELIM "/" #endif #define TEST(cond) if (!(cond)) { fprintf(stderr, "FAILED " #cond \ " at %s:%d\n", __FILE__, __LINE__); \ exit(1); } \ else { printf("passed " #cond "\n"); } union end_test32 { uint32_t i; char c[4]; }; union end_test64 { uint64_t i; char c[8]; }; static int done = 0; static int bundle_count = 0; static int pattern_count = 0; static int reply_count = 0; static int subtest_count = 0; static int subtest_reply_count = 0; char testdata[5] = "ABCDE"; static int jitter_count = 0; static float jitter_total = 0.0f; static float jitter_max = 0.0f; static float jitter_min = 1000.0f; void exitcheck(void); void error(int num, const char *m, const char *path); void rep_error(int num, const char *m, const char *path); int generic_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data); int foo_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data); int reply_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data); int lots_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data); int coerce_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data); int bundle_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data); int jitter_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data); int pattern_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data); int subtest_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data); int subtest_reply_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data); int quit_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data); int main() { lo_blob btest = lo_blob_new(sizeof(testdata), testdata); lo_server_thread st, sta, stb; lo_server s = lo_server_new(NULL, error); lo_bundle b; lo_message m1, m2; char *server_url, *path, *protocol, *host, *port; const char *host2, *port2; lo_address a; uint8_t midi_data[4] = {0xff, 0xf7, 0xAA, 0x00}; union end_test32 et32; union end_test64 et64; lo_timetag tt = {0x1, 0x80000000}, sched; int count; int proto; char cmd[256]; sta = lo_server_thread_new("7591", error); stb = lo_server_thread_new("7591", rep_error); if (stb) { fprintf(stderr, "FAILED: create bad server thread object!\n"); exit(1); } lo_server_thread_free(sta); /* leak check */ st = lo_server_thread_new(NULL, error); lo_server_thread_start(st); #ifdef WIN32 Sleep(4); #else usleep(4000); #endif lo_server_thread_stop(st); lo_server_thread_free(st); st = lo_server_thread_new(NULL, error); lo_server_thread_start(st); lo_server_thread_stop(st); lo_server_thread_free(st); st = lo_server_thread_new(NULL, error); lo_server_thread_free(st); st = lo_server_thread_new(NULL, error); lo_server_thread_free(st); st = lo_server_thread_new(NULL, error); a = lo_address_new_from_url("osc://localhost/"); TEST(a != NULL); lo_address_free(a); atexit(exitcheck); printf("type tests\n"); TEST(sizeof(float) == sizeof(int32_t)); TEST(sizeof(double) == sizeof(int64_t)); et32.i = 0x23242526U; et32.i = lo_htoo32(et32.i); if (et32.c[0] != 0x23 || et32.c[1] != 0x24 || et32.c[2] != 0x25 || et32.c[3] != 0x26) { fprintf(stderr, "failed 32bit endian conversion test\n"); fprintf(stderr, "0x23242526 -> %X\n", et32.i); exit(1); } else { printf("passed 32bit endian conversion test\n"); } et64.i = 0x232425262728292AULL; et64.i = lo_htoo64(et64.i); if (et64.c[0] != 0x23 || et64.c[1] != 0x24 || et64.c[2] != 0x25 || et64.c[3] != 0x26 || et64.c[4] != 0x27 || et64.c[5] != 0x28 || et64.c[6] != 0x29 || et64.c[7] != 0x2A) { fprintf(stderr, "failed 64bit endian conversion\n"); fprintf(stderr, "0x232425262728292A -> %llX\n", (long long unsigned int)et64.i); exit(1); } else { printf("passed 64bit endian conversion\n"); } printf("\n"); /* OSC URL tests */ path = lo_url_get_path("osc.udp://localhost:9999/a/path/is/here"); if (strcmp(path, "/a/path/is/here")) { printf("failed lo_url_get_path() test1\n"); printf("'%s' != '/a/path/is/here'\n", path); exit(1); } else { printf("passed lo_url_get_path() test1\n"); } free(path); protocol = lo_url_get_protocol("osc.udp://localhost:9999/a/path/is/here"); if (strcmp(protocol, "udp")) { printf("failed lo_url_get_protocol() test1\n"); printf("'%s' != 'udp'\n", protocol); exit(1); } else { printf("passed lo_url_get_protocol() test1\n"); } free(protocol); protocol = lo_url_get_protocol("osc.tcp://localhost:9999/a/path/is/here"); if (strcmp(protocol, "tcp")) { printf("failed lo_url_get_protocol() test2\n"); printf("'%s' != 'udp'\n", protocol); exit(1); } else { printf("passed lo_url_get_protocol() test2\n"); } free(protocol); protocol = lo_url_get_protocol("osc.udp://[::ffff:localhost]:9999/a/path/is/here"); if (strcmp(protocol, "udp")) { printf("failed lo_url_get_protocol() test1 (IPv6)\n"); printf("'%s' != 'udp'\n", protocol); exit(1); } else { printf("passed lo_url_get_protocol() test1 (IPv6)\n"); } free(protocol); host = lo_url_get_hostname("osc.udp://foo.example.com:9999/a/path/is/here"); if (strcmp(host, "foo.example.com")) { printf("failed lo_url_get_hostname() test1\n"); printf("'%s' != 'foo.example.com'\n", host); exit(1); } else { printf("passed lo_url_get_hostname() test1\n"); } free(host); host = lo_url_get_hostname("osc.udp://[0000::::0001]:9999/a/path/is/here"); if (strcmp(host, "0000::::0001")) { printf("failed lo_url_get_hostname() test2 (IPv6)\n"); printf("'%s' != '0000::::0001'\n", host); exit(1); } else { printf("passed lo_url_get_hostname() test2 (IPv6)\n"); } free(host); port = lo_url_get_port("osc.udp://localhost:9999/a/path/is/here"); if (strcmp(port, "9999")) { printf("failed lo_url_get_port() test1\n"); printf("'%s' != '9999'\n", port); exit(1); } else { printf("passed lo_url_get_port() test1\n"); } free(port); port = lo_url_get_port("osc.udp://[::ffff:127.0.0.1]:9999/a/path/is/here"); if (strcmp(port, "9999")) { printf("failed lo_url_get_port() test1 (IPv6)\n"); printf("'%s' != '9999'\n", port); exit(1); } else { printf("passed lo_url_get_port() test1 (IPv6)\n"); } free(port); printf("\n"); a = lo_address_new_from_url("osc.tcp://foo.example.com:9999/"); host2 = lo_address_get_hostname(a); if (strcmp(host2, "foo.example.com")) { printf("failed lo_address_get_hostname() test\n"); printf("'%s' != 'foo.example.com'\n", host2); exit(1); } else { printf("passed lo_address_get_hostname() test\n"); } port2 = lo_address_get_port(a); if (strcmp(port2, "9999")) { printf("failed lo_address_get_port() test\n"); printf("'%s' != '9999'\n", port2); exit(1); } else { printf("passed lo_address_get_port() test\n"); } proto = lo_address_get_protocol(a); if (proto != LO_TCP) { printf("failed lo_address_get_protocol() test\n"); printf("'%d' != '%d'\n", proto, LO_TCP); exit(1); } else { printf("passed lo_address_get_protocol() test\n"); } server_url = lo_address_get_url(a); if (strcmp(server_url, "osc.tcp://foo.example.com:9999/")) { printf("failed lo_address_get_url() test\n"); printf("'%s' != '%s'\n", server_url, "osc.tcp://foo.example.com:9999/"); exit(1); } else { printf("passed lo_address_get_url() test\n"); } free(server_url); lo_address_free( a ); printf("\n"); /* Test blod sizes */ if (lo_blob_datasize(btest) != 5 || lo_blobsize(btest) != 12) { printf("blob is %d (%d) bytes long, should be 5 (12)\n", lo_blob_datasize(btest), lo_blobsize(btest)); lo_arg_pp(LO_BLOB, btest); printf(" <- blob\n"); exit(1); } /* Server method handler tests */ server_url = lo_server_thread_get_url(st); a = lo_address_new_from_url(server_url); printf("Server URL: %s\n", server_url); free(server_url); /* add method that will match the path /foo/bar, with two numbers, coerced * to float and int */ lo_server_thread_add_method(st, "/foo/bar", "fi", foo_handler, lo_server_thread_get_server(st)); lo_server_thread_add_method(st, "/reply", "s", reply_handler, NULL); lo_server_thread_add_method(st, "/lotsofformats", "fisbmhtdSccTFNI", lots_handler, NULL); lo_server_thread_add_method(st, "/coerce", "dfhiSs", coerce_handler, NULL); lo_server_thread_add_method(st, "/bundle", NULL, bundle_handler, NULL); lo_server_thread_add_method(st, "/jitter", "ti", jitter_handler, NULL); lo_server_thread_add_method(st, "/pattern/foo", NULL, pattern_handler, "foo"); lo_server_thread_add_method(st, "/pattern/bar", NULL, pattern_handler, "bar"); lo_server_thread_add_method(st, "/pattern/baz", NULL, pattern_handler, "baz"); lo_server_thread_add_method(st, "/subtest", "i", subtest_handler, NULL); lo_server_thread_add_method(st, "/subtest-reply", "i", subtest_reply_handler, NULL); /* add method that will match any path and args */ lo_server_thread_add_method(st, NULL, NULL, generic_handler, NULL); /* add method that will match the path /quit with no args */ lo_server_thread_add_method(st, "/quit", "", quit_handler, NULL); /* check that the thread restarts */ lo_server_thread_start(st); lo_server_thread_stop(st); lo_server_thread_start(st); if (lo_send(a, "/foo/bar", "ff", 0.12345678f, 23.0f) == -1) { printf("OSC error A %d: %s\n", lo_address_errno(a), lo_address_errstr(a)); exit(1); } if (lo_send(a, "/foo/bar", "ff", 0.12345678f, 23.0f) == -1) { printf("OSC error B %d: %s\n", lo_address_errno(a), lo_address_errstr(a)); exit(1); } lo_send(a, "/", "i", 242); lo_send(a, "/pattern/", "i", 243); lo_send(a, "/bar", "ff", 0.12345678f, 1.0/0.0); lo_send(a, "/lotsofformats", "fisbmhtdSccTFNI", 0.12345678f, 123, "123", btest, midi_data, 0x0123456789abcdefULL, tt, 0.9999, "sym", 'X', 'Y'); lo_send(a, "/coerce", "fdihsS", 0.1f, 0.2, 123, 124LL, "aaa", "bbb"); lo_send(a, "/coerce", "ffffss", 0.1f, 0.2f, 123.0, 124.0, "aaa", "bbb"); lo_send(a, "/coerce", "ddddSS", 0.1, 0.2, 123.0, 124.0, "aaa", "bbb"); lo_send(a, "/a/b/c/d", "sfsff", "one", 0.12345678f, "three", -0.00000023001f, 1.0); lo_send(a, "/a/b/c/d", "b", btest); lo_blob_free(btest); lo_send(a, "/pattern/*", "s", "a"); lo_send(a, "/pattern/ba[rz]", "s", "b"); server_url = lo_server_thread_get_url(st); sprintf(cmd, "." PATHDELIM "subtest %s &", server_url); if (system(cmd) != 0) { fprintf(stderr, "Cannot execute subtest command\n"); exit(1); } system(cmd); #ifdef WIN32 Sleep(2000); #else sleep(2); #endif TEST(reply_count == 2); TEST(pattern_count == 5); TEST(subtest_count == 2); TEST(subtest_reply_count == 22); printf("\n"); b = lo_bundle_new((lo_timetag){10,0xFFFFFFFC}); m1 = lo_message_new(); lo_message_add_string(m1, "abcdefghijklmnopqrstuvwxyz"); lo_message_add_string(m1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); lo_bundle_add_message(b, "/bundle", m1); lo_send_bundle(a, b); lo_message_free(m1); lo_bundle_free(b); b = lo_bundle_new((lo_timetag){1,2}); m1 = lo_message_new(); lo_message_add_int32(m1, 23); lo_message_add_string(m1, "23"); lo_bundle_add_message(b, "/bundle", m1); m2 = lo_message_new(); lo_message_add_string(m2, "24"); lo_message_add_int32(m2, 24); lo_bundle_add_message(b, "/bundle", m2); /* lo_send_bundle(a, b); if (a->errnum) { printf("error %d: %s\n", a->errnum, a->errstr); exit(1); } */ TEST(lo_send_bundle(a, b) == 64); lo_message_free(m1); lo_message_free(m2); lo_bundle_free(b); b = lo_bundle_new((lo_timetag){10,0xFFFFFFFE}); m1 = lo_message_new(); lo_message_add_string(m1, "abcdefghijklmnopqrstuvwxyz"); lo_message_add_string(m1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); lo_bundle_add_message(b, "/bundle", m1); lo_send_bundle(a, b); lo_message_free(m1); lo_bundle_free(b); lo_timetag_now(&sched); sched.sec += 5; b = lo_bundle_new(sched); m1 = lo_message_new(); lo_message_add_string(m1, "future"); lo_message_add_string(m1, "time"); lo_message_add_string(m1, "test"); lo_bundle_add_message(b, "/bundle", m1); lo_send_bundle(a, b); lo_message_free(m1); lo_bundle_free(b); lo_send_timestamped(a, sched, "/bundle", "s", "lo_send_timestamped() test"); #define JITTER_ITS 25 /* jitter tests */ { lo_timetag stamps[JITTER_ITS]; lo_timetag now; int i; for (i=0; i<JITTER_ITS; i++) { lo_timetag_now(&now); stamps[i] = now; stamps[i].sec += 1; stamps[i].frac = rand(); lo_send_timestamped(a, stamps[i], "/jitter", "ti", stamps[i], i); } } #ifdef WIN32 Sleep(2000); #else sleep(2); #endif lo_address_free(a); TEST(lo_server_thread_events_pending(st)); while (lo_server_thread_events_pending(st)) { printf("pending events, wait...\n"); #ifdef WIN32 fflush(stdout); Sleep(1000); #else sleep(1); #endif } TEST(bundle_count == 6); printf("\n"); printf("bundle timing jitter results:\n" "max jitter = %fs\n" "avg jitter = %fs\n" "min jitter = %fs\n\n", jitter_max, jitter_total/(float)jitter_count, jitter_min); server_url = lo_server_get_url(s); lo_server_add_method(s, NULL, NULL, generic_handler, NULL); a = lo_address_new_from_url(server_url); TEST(lo_server_recv_noblock(s, 0) == 0); printf("Testing noblock API on %s\n", server_url); lo_send(a, "/non-block-test", "f", 23.0); count = 0; while (!lo_server_recv_noblock(s, 10) && count++ < 1000) { } if (count >= 1000) { printf("lo_server_recv_noblock() test failed\n"); exit(1); } /* Delete methods */ lo_server_thread_del_method(st, "/coerce", "dfhiSs"); lo_server_del_method(s, NULL, NULL); lo_address_free(a); lo_server_free(s); free(server_url); #ifndef WIN32 { /* UNIX domain tests */ lo_address ua; lo_server us; char *addr; unlink("/tmp/testlo.osc"); us = lo_server_new_with_proto("/tmp/testlo.osc", LO_UNIX, error); ua = lo_address_new_from_url("osc.unix:///tmp/testlo.osc"); TEST(lo_server_get_protocol(us) == LO_UNIX); TEST(lo_send(ua, "/unix", "f", 23.0) == 16); TEST(lo_server_recv(us) == 16); addr = lo_server_get_url(us); TEST(!strcmp("osc.unix:////tmp/testlo.osc", addr)); free(addr); lo_server_free(us); lo_address_free(ua); } #endif { /* TCP tests */ lo_address ta; lo_server ts; char *addr; ts = lo_server_new_with_proto(NULL, LO_TCP, error); addr = lo_server_get_url(ts); ta = lo_address_new_from_url(addr); if (lo_address_errno(ta)) { printf("err: %s\n", lo_address_errstr(ta)); exit(1); } TEST(lo_server_get_protocol(ts) == LO_TCP); TEST(lo_send(ta, "/tcp", "f", 23.0) == 16); TEST(lo_send(ta, "/tcp", "f", 23.0) == 16); TEST(lo_server_recv(ts) == 16); TEST(lo_server_recv(ts) == 16); free(addr); lo_server_free(ts); lo_address_free(ta); } server_url = lo_server_thread_get_url(st); a = lo_address_new_from_url(server_url); /* exit */ lo_send(a, "/quit", NULL); lo_address_free(a); while (!done) { #ifdef WIN32 Sleep(1); #else usleep(1000); #endif } lo_server_thread_free(st); free(server_url); return 0; } void exitcheck(void) { if (!done) { fprintf(stderr, "\ntest run not completed\n" PACKAGE_NAME " test FAILED\n"); } else { printf(PACKAGE_NAME " test PASSED\n"); } } void error(int num, const char *msg, const char *path) { printf("liblo server error %d in %s: %s\n", num, path, msg); exit(1); } void rep_error(int num, const char *msg, const char *path) { if (num != 9904) { error(num, msg, path); } } int generic_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data) { int i; printf("path: <%s>\n", path); for (i=0; i<argc; i++) { printf("arg %d '%c' ", i, types[i]); lo_arg_pp(types[i], argv[i]); printf("\n"); } printf("\n"); return 1; } int foo_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data) { lo_server serv = (lo_server)user_data; lo_address src = lo_message_get_source(data); char *url = lo_address_get_url(src); printf("Address of us: %s\n", lo_server_get_url(serv)); printf("%s <- f:%f, i:%d\n", path, argv[0]->f, argv[1]->i); if (lo_send_from(src, serv, LO_TT_IMMEDIATE, "/reply", "s", "a reply") == -1) { printf("OSC reply error %d: %s\nSending to %s\n", lo_address_errno(src), lo_address_errstr(src), url); exit(1); } else { printf("Reply sent to %s\n\n", url); } free(url); return 0; } int reply_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data) { lo_address src = lo_message_get_source(data); char *url = lo_address_get_url(src); printf("Reply received from %s\n", url); reply_count++; return 0; } int lots_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data) { lo_blob b; unsigned char *d; if (strcmp(path, "/lotsofformats")) { fprintf(stderr, "path != /lotsofformats\n"); exit(1); } printf("path = %s\n", path); TEST(types[0] == 'f' && argv[0]->f == 0.12345678f); TEST(types[1] == 'i' && argv[1]->i == 123); TEST(types[2] == 's' && !strcmp(&argv[2]->s, "123")); b = (lo_blob)argv[3]; d = lo_blob_dataptr(b); TEST(types[3] == 'b' && lo_blob_datasize(b) == 5); TEST(d[0] == 'A' && d[1] == 'B' && d[2] == 'C' && d[3] == 'D' && d[4] == 'E'); d = argv[4]->m; TEST(d[0] == 0xff && d[1] == 0xf7 && d[2] == 0xaa && d[3] == 0x00); TEST(types[5] == 'h' && argv[5]->h == 0x0123456789ABCDEFULL); TEST(types[6] == 't' && argv[6]->t.sec == 1 && \ argv[6]->t.frac == 0x80000000); TEST(types[7] == 'd' && argv[7]->d == 0.9999); TEST(types[8] == 'S' && !strcmp(&argv[8]->S, "sym")); printf("char: %d\n", argv[9]->c); TEST(types[9] == 'c' && argv[9]->c == 'X'); TEST(types[10] == 'c' && argv[10]->c == 'Y'); TEST(types[11] == 'T'); TEST(types[12] == 'F'); TEST(types[13] == 'N'); TEST(types[14] == 'I'); printf("\n"); return 0; } int coerce_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data) { printf("path = %s\n", path); TEST(types[0] == 'd' && fabs(argv[0]->d - 0.1) < FLT_EPSILON); TEST(types[1] == 'f' && fabs(argv[1]->f - 0.2) < FLT_EPSILON); TEST(types[2] == 'h' && argv[2]->h == 123); TEST(types[3] == 'i' && argv[3]->i == 124); TEST(types[4] == 'S' && !strcmp(&argv[4]->S, "aaa")); TEST(types[5] == 's' && !strcmp(&argv[5]->s, "bbb")); printf("\n"); return 0; } int bundle_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data) { bundle_count++; printf("received bundle\n"); return 0; } int jitter_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data) { lo_timetag now; float jitter; lo_timetag_now(&now); jitter = fabs(lo_timetag_diff(now, argv[0]->t)); jitter_count++; //printf("jitter: %f\n", jitter); printf("%d expected: %x:%x received %x:%x\n", argv[1]->i, argv[0]->t.sec, argv[0]->t.frac, now.sec, now.frac); jitter_total += jitter; if (jitter > jitter_max) jitter_max = jitter; if (jitter < jitter_min) jitter_min = jitter; return 0; } int pattern_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data) { pattern_count++; printf("pattern matched %s\n", (char *)user_data); return 0; } int subtest_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data) { lo_address a = lo_message_get_source(data); subtest_count++; printf("got subtest message %d\n", subtest_count); lo_send(a, "/subtest", "i", subtest_count); return 0; } int subtest_reply_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data) { subtest_reply_count++; //printf("got subtest reply message %d\n", subtest_reply_count); return 0; } int quit_handler(const char *path, const char *types, lo_arg **argv, int argc, lo_message data, void *user_data) { done = 1; return 0; } /* vi:set ts=8 sts=4 sw=4: */
28.098997
103
0.628105
6830cf963a8c5b426994ccb5a1b90af0fbac2c90
2,430
h
C
third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
110
2020-10-27T02:15:35.000Z
2022-03-30T10:24:52.000Z
third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
45
2020-09-02T03:21:37.000Z
2022-03-31T22:19:45.000Z
third_party/blink/renderer/bindings/core/v8/active_script_wrappable.h
zealoussnow/chromium
fd8a8914ca0183f0add65ae55f04e287543c7d4a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
37
2020-11-13T15:44:23.000Z
2022-03-25T09:08:22.000Z
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_ACTIVE_SCRIPT_WRAPPABLE_H_ #define THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_ACTIVE_SCRIPT_WRAPPABLE_H_ #include "base/macros.h" #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/platform/bindings/active_script_wrappable_base.h" namespace blink { class ExecutionContext; // Derived by wrappable objects which need to remain alive due to ongoing // asynchronous activity, even if they are not referenced in the JavaScript or // Blink heap. // // This is useful for ScriptWrappable objects that are not held alive by regular // references from the object graph. E.g., XMLHttpRequest may have a pending // activity that may be visible (e.g. firing event listeners or resolving // promises) and should thus not be collected. // // Such objects should derive from ActiveScriptWrappable<T>, and override // ScriptWrappable::HasPendingActivity: // bool HasPendingActivity() const final; // which returns true if there may be pending activity which requires the // wrappable remain alive. // // To avoid leaking objects after the context is destroyed, users of // ActiveScriptWrappable<T> also have to provide a GetExecutionContext() method // that returns the ExecutionContext or nullptr. A nullptr or already destroyed // context results in ignoring HasPendingActivity(). template <typename T> class ActiveScriptWrappable : public ActiveScriptWrappableBase { public: ActiveScriptWrappable(const ActiveScriptWrappable&) = delete; ActiveScriptWrappable& operator=(const ActiveScriptWrappable&) = delete; ~ActiveScriptWrappable() override = default; protected: ActiveScriptWrappable() = default; bool IsContextDestroyed() const final { return IsContextDestroyedForActiveScriptWrappable( static_cast<const T*>(this)->GetExecutionContext()); } bool DispatchHasPendingActivity() const final { return static_cast<const T*>(this)->HasPendingActivity(); } }; // Helper for ActiveScriptWrappable<T>::IsContextDestroyed(); CORE_EXPORT bool IsContextDestroyedForActiveScriptWrappable( const ExecutionContext* execution_context); } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_BINDINGS_CORE_V8_ACTIVE_SCRIPT_WRAPPABLE_H_
38.571429
86
0.796296
d0a5a7c2eafe6104b47771737bf3b6e2639124d5
426
h
C
LvLEngine/LvLEngine/LvLAudio/LvL2DSound.h
Aura003/DontOpen
5a85a60f9b3b854dc16a4b22c7aebb0055a56944
[ "MIT" ]
null
null
null
LvLEngine/LvLEngine/LvLAudio/LvL2DSound.h
Aura003/DontOpen
5a85a60f9b3b854dc16a4b22c7aebb0055a56944
[ "MIT" ]
null
null
null
LvLEngine/LvLEngine/LvLAudio/LvL2DSound.h
Aura003/DontOpen
5a85a60f9b3b854dc16a4b22c7aebb0055a56944
[ "MIT" ]
null
null
null
#pragma once #include"iLvLSound.h" class LvL2DSound : public iLvLSound { LvL_DECLARE_REFCOUNTTED(); public: // Inherited via iLvLSound LvL2DSound(Mix_Music* music, const char* name); virtual const char* GetName() override; virtual eLvLResourceType GetType() override; virtual void* GetHandle() override; virtual void Play() override; private: virtual ~LvL2DSound(); std::string _pName; Mix_Music* _BGM = NULL; };
20.285714
48
0.751174
a98b4ce86f0b417b217a88e49bba151d96932820
6,799
h
C
third_party/WebKit/Source/core/html/HTMLImageElement.h
Wzzzx/chromium-crosswalk
768dde8efa71169f1c1113ca6ef322f1e8c9e7de
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
2
2019-01-28T08:09:58.000Z
2021-11-15T15:32:10.000Z
third_party/WebKit/Source/core/html/HTMLImageElement.h
Wzzzx/chromium-crosswalk
768dde8efa71169f1c1113ca6ef322f1e8c9e7de
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
third_party/WebKit/Source/core/html/HTMLImageElement.h
Wzzzx/chromium-crosswalk
768dde8efa71169f1c1113ca6ef322f1e8c9e7de
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
6
2020-09-23T08:56:12.000Z
2021-11-18T03:40:49.000Z
/* * Copyright (C) 1999 Lars Knoll (knoll@kde.org) * (C) 1999 Antti Koivisto (koivisto@kde.org) * Copyright (C) 2004, 2008, 2010 Apple Inc. All rights reserved. * Copyright (C) 2010 Google Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * */ #ifndef HTMLImageElement_h #define HTMLImageElement_h #include "bindings/core/v8/ActiveScriptWrappable.h" #include "core/CoreExport.h" #include "core/fetch/FetchRequest.h" #include "core/html/HTMLElement.h" #include "core/html/HTMLImageLoader.h" #include "core/html/canvas/CanvasImageSource.h" #include "core/imagebitmap/ImageBitmapSource.h" #include "platform/graphics/GraphicsTypes.h" #include "platform/network/ResourceResponse.h" namespace blink { class HTMLFormElement; class ImageCandidate; class ShadowRoot; class ImageBitmapOptions; class CORE_EXPORT HTMLImageElement final : public HTMLElement, public CanvasImageSource, public ImageBitmapSource, public ActiveScriptWrappable { DEFINE_WRAPPERTYPEINFO(); USING_GARBAGE_COLLECTED_MIXIN(HTMLImageElement); public: class ViewportChangeListener; static HTMLImageElement* create(Document&); static HTMLImageElement* create(Document&, HTMLFormElement*, bool createdByParser); static HTMLImageElement* createForJSConstructor(Document&); static HTMLImageElement* createForJSConstructor(Document&, int width); static HTMLImageElement* createForJSConstructor(Document&, int width, int height); ~HTMLImageElement() override; DECLARE_VIRTUAL_TRACE(); int width(); int height(); int naturalWidth() const; int naturalHeight() const; const String& currentSrc() const; bool isServerMap() const; String altText() const final; ImageResource* cachedImage() const { return imageLoader().image(); } void setImageResource(ImageResource* i) { imageLoader().setImage(i); } void setLoadingImageDocument() { imageLoader().setLoadingImageDocument(); } void setHeight(int); KURL src() const; void setSrc(const String&); void setWidth(int); int x() const; int y() const; bool complete() const; bool hasPendingActivity() const final { return imageLoader().hasPendingActivity(); } bool canContainRangeEndPoint() const override { return false; } const AtomicString imageSourceURL() const override; HTMLFormElement* formOwner() const override; void formRemovedFromTree(const Node& formRoot); virtual void ensureFallbackContent(); virtual void ensureFallbackForGeneratedContent(); virtual void ensurePrimaryContent(); // CanvasImageSource implementation PassRefPtr<Image> getSourceImageForCanvas(SourceImageStatus*, AccelerationHint, SnapshotReason, const FloatSize&) const override; bool isSVGSource() const override; bool wouldTaintOrigin(SecurityOrigin*) const override; FloatSize elementSize(const FloatSize&) const override; FloatSize defaultDestinationSize(const FloatSize&) const override; const KURL& sourceURL() const override; bool isOpaque() const override; int sourceWidth() override; int sourceHeight() override; // public so that HTMLPictureElement can call this as well. void selectSourceURL(ImageLoader::UpdateFromElementBehavior); void reattachFallbackContent(); void setUseFallbackContent(); void setIsFallbackImage() { m_isFallbackImage = true; } FetchRequest::ResourceWidth getResourceWidth(); float sourceSize(Element&); void forceReload() const; // ImageBitmapSource implementation IntSize bitmapSourceSize() const override; ScriptPromise createImageBitmap(ScriptState*, EventTarget&, int sx, int sy, int sw, int sh, const ImageBitmapOptions&, ExceptionState&) override; protected: explicit HTMLImageElement(Document&, HTMLFormElement* = 0, bool createdByParser = false); void didMoveToNewDocument(Document& oldDocument) override; virtual bool useFallbackContent() const { return m_useFallbackContent; } void didAddUserAgentShadowRoot(ShadowRoot&) override; PassRefPtr<ComputedStyle> customStyleForLayoutObject() override; private: bool areAuthorShadowsAllowed() const override { return false; } void parseAttribute(const QualifiedName&, const AtomicString&, const AtomicString&) override; bool isPresentationAttribute(const QualifiedName&) const override; void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStylePropertySet*) override; void attach(const AttachContext& = AttachContext()) override; LayoutObject* createLayoutObject(const ComputedStyle&) override; bool canStartSelection() const override { return false; } bool isURLAttribute(const Attribute&) const override; bool hasLegalLinkAttribute(const QualifiedName&) const override; const QualifiedName& subResourceAttributeName() const override; bool draggable() const override; InsertionNotificationRequest insertedInto(ContainerNode*) override; void removedFrom(ContainerNode*) override; bool shouldRegisterAsNamedItem() const override { return true; } bool shouldRegisterAsExtraNamedItem() const override { return true; } bool isInteractiveContent() const override; Image* imageContents() override; void resetFormOwner(); ImageCandidate findBestFitImageFromPictureParent(); void setBestFitURLAndDPRFromImageCandidate(const ImageCandidate&); HTMLImageLoader& imageLoader() const { return *m_imageLoader; } void notifyViewportChanged(); void createMediaQueryListIfDoesNotExist(); Member<HTMLImageLoader> m_imageLoader; Member<ViewportChangeListener> m_listener; Member<HTMLFormElement> m_form; AtomicString m_bestFitImageURL; float m_imageDevicePixelRatio; Member<HTMLSourceElement> m_source; unsigned m_formWasSetByParser : 1; unsigned m_elementCreatedByParser : 1; unsigned m_useFallbackContent : 1; unsigned m_isFallbackImage : 1; ReferrerPolicy m_referrerPolicy; }; } // namespace blink #endif // HTMLImageElement_h
37.357143
149
0.760994
ca1843e9a85e33acabad4a669ba4b3d26eb9a003
3,586
h
C
aws-cpp-sdk-mediaconvert/include/aws/mediaconvert/model/ListQueuesResult.h
curiousjgeorge/aws-sdk-cpp
09b65deba03cfbef9a1e5d5986aa4de71bc03cd8
[ "Apache-2.0" ]
2
2019-03-11T15:50:55.000Z
2020-02-27T11:40:27.000Z
aws-cpp-sdk-mediaconvert/include/aws/mediaconvert/model/ListQueuesResult.h
curiousjgeorge/aws-sdk-cpp
09b65deba03cfbef9a1e5d5986aa4de71bc03cd8
[ "Apache-2.0" ]
null
null
null
aws-cpp-sdk-mediaconvert/include/aws/mediaconvert/model/ListQueuesResult.h
curiousjgeorge/aws-sdk-cpp
09b65deba03cfbef9a1e5d5986aa4de71bc03cd8
[ "Apache-2.0" ]
1
2019-01-18T13:03:55.000Z
2019-01-18T13:03:55.000Z
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. 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. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #pragma once #include <aws/mediaconvert/MediaConvert_EXPORTS.h> #include <aws/core/utils/memory/stl/AWSString.h> #include <aws/core/utils/memory/stl/AWSVector.h> #include <aws/mediaconvert/model/Queue.h> #include <utility> namespace Aws { template<typename RESULT_TYPE> class AmazonWebServiceResult; namespace Utils { namespace Json { class JsonValue; } // namespace Json } // namespace Utils namespace MediaConvert { namespace Model { class AWS_MEDIACONVERT_API ListQueuesResult { public: ListQueuesResult(); ListQueuesResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); ListQueuesResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result); /** * Use this string to request the next batch of queues. */ inline const Aws::String& GetNextToken() const{ return m_nextToken; } /** * Use this string to request the next batch of queues. */ inline void SetNextToken(const Aws::String& value) { m_nextToken = value; } /** * Use this string to request the next batch of queues. */ inline void SetNextToken(Aws::String&& value) { m_nextToken = std::move(value); } /** * Use this string to request the next batch of queues. */ inline void SetNextToken(const char* value) { m_nextToken.assign(value); } /** * Use this string to request the next batch of queues. */ inline ListQueuesResult& WithNextToken(const Aws::String& value) { SetNextToken(value); return *this;} /** * Use this string to request the next batch of queues. */ inline ListQueuesResult& WithNextToken(Aws::String&& value) { SetNextToken(std::move(value)); return *this;} /** * Use this string to request the next batch of queues. */ inline ListQueuesResult& WithNextToken(const char* value) { SetNextToken(value); return *this;} /** * List of queues. */ inline const Aws::Vector<Queue>& GetQueues() const{ return m_queues; } /** * List of queues. */ inline void SetQueues(const Aws::Vector<Queue>& value) { m_queues = value; } /** * List of queues. */ inline void SetQueues(Aws::Vector<Queue>&& value) { m_queues = std::move(value); } /** * List of queues. */ inline ListQueuesResult& WithQueues(const Aws::Vector<Queue>& value) { SetQueues(value); return *this;} /** * List of queues. */ inline ListQueuesResult& WithQueues(Aws::Vector<Queue>&& value) { SetQueues(std::move(value)); return *this;} /** * List of queues. */ inline ListQueuesResult& AddQueues(const Queue& value) { m_queues.push_back(value); return *this; } /** * List of queues. */ inline ListQueuesResult& AddQueues(Queue&& value) { m_queues.push_back(std::move(value)); return *this; } private: Aws::String m_nextToken; Aws::Vector<Queue> m_queues; }; } // namespace Model } // namespace MediaConvert } // namespace Aws
28.015625
113
0.674847
a9cf2bcf5defcd5dff66e9d360f2f99c113edd22
30,200
c
C
src/ptree.c
tulip-control/gr1c
4c73161e7857410b86536f4be9d2a55c581e2e9c
[ "BSD-3-Clause" ]
11
2016-10-11T22:39:27.000Z
2022-03-26T15:28:20.000Z
src/ptree.c
tulip-control/gr1c
4c73161e7857410b86536f4be9d2a55c581e2e9c
[ "BSD-3-Clause" ]
13
2016-07-29T04:39:22.000Z
2021-09-21T08:03:50.000Z
src/ptree.c
tulip-control/gr1c
4c73161e7857410b86536f4be9d2a55c581e2e9c
[ "BSD-3-Clause" ]
2
2017-03-22T08:12:11.000Z
2017-08-12T03:27:14.000Z
/* ptree.c -- Definitions for signatures appearing in ptree.h. * * * SCL; 2012-2015 */ #define _POSIX_C_SOURCE 200809L #define _ISOC99_SOURCE #include <math.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> #include "common.h" #include "ptree.h" ptree_t *init_ptree( int type, char *name, int value ) { ptree_t *head = malloc( sizeof(ptree_t) ); if (head == NULL) { perror( __FILE__ ", malloc" ); exit(-1); } head->left = head->right = NULL; head->name = NULL; head->type = type; if (type == PT_VARIABLE || type == PT_NEXT_VARIABLE) { if (name == NULL) { head->name = NULL; } else { head->name = strdup( name ); if (head->name == NULL) { perror( __FILE__ ", strdup" ); exit(-1); } } /* The "value" field is used to specify the domain of an integer variable, if it is nonzero. Else (if value=0), the variable is boolean. */ head->value = value; } else if (type == PT_CONSTANT) { head->value = value; } return head; } ptree_t *copy_ptree( ptree_t *head ) { ptree_t *new_head; if (head == NULL) return NULL; new_head = init_ptree( head->type, head->name, head->value ); if (new_head == NULL) return NULL; new_head->left = copy_ptree( head->left ); if (new_head->left == NULL && head->left != NULL) return NULL; new_head->right = copy_ptree( head->right ); if (new_head->right == NULL && head->right != NULL) return NULL; return new_head; } void delete_tree( ptree_t *head ) { if (head == NULL) return; if (head->left != NULL) { delete_tree( head->left ); head->left = NULL; } if (head->right != NULL) { delete_tree( head->right ); head->right = NULL; } if (head->name != NULL) { free( head->name ); } free( head ); } int min_tree_value( ptree_t *head ) { int childval, minval; if (head == NULL) return -9999; if (head->type == PT_CONSTANT) { minval = head->value; } else { minval = -9999; } childval = min_tree_value( head->left ); if (childval != -9999 && minval != -9999) { minval = (childval < minval) ? childval : minval; } else if (childval != -9999) { minval = childval; } childval = min_tree_value( head->right ); if (childval != -9999 && minval != -9999) { minval = (childval < minval) ? childval : minval; } else if (childval != -9999) { minval = childval; } return minval; } int max_tree_value( ptree_t *head ) { int childval, maxval; if (head == NULL) return -9999; if (head->type == PT_CONSTANT) { maxval = head->value; } else { maxval = -9999; } childval = max_tree_value( head->left ); if (childval != -9999 && maxval != -9999) { maxval = (childval > maxval) ? childval : maxval; } else if (childval != -9999) { maxval = childval; } childval = max_tree_value( head->right ); if (childval != -9999 && maxval != -9999) { maxval = (childval > maxval) ? childval : maxval; } else if (childval != -9999) { maxval = childval; } return maxval; } int rmin_tree_value( ptree_t *head, char *name ) { int childval, minval; if (head == NULL) return -9999; if (head->type == PT_EQUALS) { if ((head->left->type == PT_VARIABLE || head->left->type == PT_NEXT_VARIABLE) && head->right->type == PT_CONSTANT && !strncmp(head->left->name, name, strlen(name))) { minval = head->right->value; } else if ((head->right->type == PT_VARIABLE || head->right->type == PT_NEXT_VARIABLE) && head->left->type == PT_CONSTANT && !strncmp(head->right->name, name, strlen(name))) { minval = head->left->value; } else { minval = -9999; } } else { minval = -9999; } childval = rmin_tree_value( head->left, name ); if (childval != -9999 && minval != -9999) { minval = (childval < minval) ? childval : minval; } else if (childval != -9999) { minval = childval; } childval = rmin_tree_value( head->right, name ); if (childval != -9999 && minval != -9999) { minval = (childval < minval) ? childval : minval; } else if (childval != -9999) { minval = childval; } return minval; } int rmax_tree_value( ptree_t *head, char *name ) { int childval, maxval; if (head == NULL) return -9999; if (head->type == PT_EQUALS) { if ((head->left->type == PT_VARIABLE || head->left->type == PT_NEXT_VARIABLE) && head->right->type == PT_CONSTANT && !strncmp(head->left->name, name, strlen(name))) { maxval = head->right->value; } else if ((head->right->type == PT_VARIABLE || head->right->type == PT_NEXT_VARIABLE) && head->left->type == PT_CONSTANT && !strncmp(head->right->name, name, strlen(name))) { maxval = head->left->value; } else { maxval = -9999; } } else { maxval = -9999; } childval = rmax_tree_value( head->left, name ); if (childval != -9999 && maxval != -9999) { maxval = (childval > maxval) ? childval : maxval; } else if (childval != -9999) { maxval = childval; } childval = rmax_tree_value( head->right, name ); if (childval != -9999 && maxval != -9999) { maxval = (childval > maxval) ? childval : maxval; } else if (childval != -9999) { maxval = childval; } return maxval; } char *check_vars( ptree_t *head, ptree_t *var_list, ptree_t *nextvar_list ) { char *name; ptree_t *node; if (head == NULL) return NULL; if (head->type == PT_VARIABLE || head->type == PT_NEXT_VARIABLE) { if (head->type == PT_VARIABLE) { node = var_list; } else { node = nextvar_list; } while (node) { if (!strcmp( head->name, node->name )) break; node = node->left; } if (node == NULL) { name = malloc( (strlen( head->name )+2)*sizeof(char) ); if (name == NULL) { perror( __FILE__ ", malloc" ); exit(-1); } strcpy( name, head->name ); if (head->type == PT_NEXT_VARIABLE) { *(name+strlen( head->name )) = '\''; *(name+strlen( head->name )+1) = '\0'; } return name; } } if ((name = check_vars( head->left, var_list, nextvar_list )) != NULL || (name = check_vars( head->right, var_list, nextvar_list )) != NULL) return name; return NULL; } #define VARNAME_STRING_LEN 1024 ptree_t *var_to_bool( char *name, int maxval ) { ptree_t *head; char varname[VARNAME_STRING_LEN]; int i; if (name == NULL || maxval < 0) return NULL; maxval = (int)(ceil(log2( maxval+1 ))); snprintf( varname, VARNAME_STRING_LEN, "%s0", name ); head = init_ptree( PT_VARIABLE, varname, 0 ); for (i = 1; i < maxval; i++) { snprintf( varname, VARNAME_STRING_LEN, "%s%d", name, i ); append_list_item( head, PT_VARIABLE, varname, 0 ); } return head; } /* Expand a subformula like x < 3 to ((x = 0) | (x = 1) | (x = 2)), assuming x has a domain of an interval of integers from 0 to some value at least 2. */ ptree_t *expand_nonbool_varnum( ptree_t *head, char *name, int maxval ) { ptree_t **heads; int var_tense, op_type, this_val; int max, min; int i; /* Handle pointless calls */ if (head == NULL || !((head->type == PT_LT) || (head->type == PT_GT) || (head->type == PT_LE) || (head->type == PT_GE) || (head->type == PT_NOTEQ)) || !(((head->left->type == PT_VARIABLE || head->left->type == PT_NEXT_VARIABLE) && head->right->type == PT_CONSTANT && !strcmp( head->left->name, name )) || ((head->right->type == PT_VARIABLE || head->right->type == PT_NEXT_VARIABLE) && head->left->type == PT_CONSTANT && !strcmp( head->right->name, name )))) return head; op_type = head->type; if (head->left->type == PT_CONSTANT) { this_val = head->left->value; var_tense = head->right->type; } else { this_val = head->right->value; var_tense = head->left->type; } delete_tree( head ); /* Special cases */ if ((op_type == PT_LT && this_val <= 0) || (op_type == PT_GT && this_val >= maxval) || (op_type == PT_LE && this_val < 0) || (op_type == PT_GE && this_val > maxval)) return init_ptree( PT_CONSTANT, NULL, 0 ); /* constant False */ if (op_type == PT_NOTEQ && (this_val < 0 || this_val > maxval)) return init_ptree( PT_CONSTANT, NULL, 1 ); /* constant True */ if (op_type == PT_NOTEQ) { heads = malloc( maxval*sizeof(ptree_t *) ); if (heads == NULL) { perror( __FILE__ ", malloc" ); exit(-1); } min = 0; for (i = 0; i <= maxval; i++) { if (i == this_val) { min = 1; continue; } *(heads+i-min) = init_ptree( PT_EQUALS, NULL, 0 ); (*(heads+i-min))->left = init_ptree( var_tense, name, 0 ); (*(heads+i-min))->right = init_ptree( PT_CONSTANT, NULL, i ); } head = merge_ptrees( heads, maxval, PT_OR ); } else { if (op_type == PT_LT) { min = 0; max = this_val-1; } else if (op_type == PT_GT) { max = maxval; min = this_val+1; } else if (op_type == PT_LE) { min = 0; max = this_val; } else { /* op_type == PT_GE */ max = maxval; min = this_val; } heads = malloc( (max-min+1)*sizeof(ptree_t *) ); if (heads == NULL) { perror( __FILE__ ", malloc" ); exit(-1); } for (i = min; i <= max; i++) { *(heads+i-min) = init_ptree( PT_EQUALS, NULL, 0 ); (*(heads+i-min))->left = init_ptree( var_tense, name, 0 ); (*(heads+i-min))->right = init_ptree( PT_CONSTANT, NULL, i ); } head = merge_ptrees( heads, max-min+1, PT_OR ); } free( heads ); return head; } ptree_t *expand_to_bool( ptree_t *head, char *name, int maxval ) { ptree_t **heads; int this_val, i; bool is_next; int num_bits; ptree_t *expanded_varlist; if (head == NULL) return NULL; if (maxval > 0) { num_bits = (int)(ceil(log2( maxval+1 ))); } else { num_bits = 1; } if (head->type == PT_LT || head->type == PT_GT || head->type == PT_LE || head->type == PT_GE || head->type == PT_NOTEQ) head = expand_nonbool_varnum( head, name, maxval ); if (head->type == PT_EQUALS && ((head->left->type != PT_CONSTANT && !strcmp( head->left->name, name )) || (head->right->type != PT_CONSTANT && !strcmp( head->right->name, name )))) { expanded_varlist = var_to_bool( name, maxval ); if (expanded_varlist == NULL) return NULL; /* We assume that nonboolean comparison is only between a variable and a number; will be generalized soon. */ if (head->left->type == PT_CONSTANT) { this_val = head->left->value; if (head->right->type == PT_VARIABLE) { is_next = False; } else { /* head->right->type == PT_NEXT_VARIABLE */ is_next = True; } } else { this_val = head->right->value; if (head->left->type == PT_VARIABLE) { is_next = False; } else { /* head->right->type == PT_NEXT_VARIABLE */ is_next = True; } } delete_tree( head ); heads = malloc( num_bits*sizeof(ptree_t *) ); if (heads == NULL) { perror( __FILE__ ", malloc" ); exit(-1); } /* Enforce inability to reach values outside the expanded domain */ if (this_val > (int)(pow( 2, num_bits ) )-1 || this_val < 0) { free( heads ); return init_ptree( PT_CONSTANT, NULL, 0 ); } for (i = num_bits-1; i >= 0; i--) { if ((this_val >> i)&1) { *(heads+i) = get_list_item( expanded_varlist, i ); (*(heads+i))->left = (*(heads+i))->right = NULL; if (is_next) (*(heads+i))->type = PT_NEXT_VARIABLE; } else { *(heads+i) = init_ptree( PT_NEG, NULL, 0 ); (*(heads+i))->right = get_list_item( expanded_varlist, i ); (*(heads+i))->right->left = (*(heads+i))->right->right = NULL; if (is_next) (*(heads+i))->right->type = PT_NEXT_VARIABLE; } } head = merge_ptrees( heads, num_bits, PT_AND ); free( heads ); } else { head->left = expand_to_bool( head->left, name, maxval ); head->right = expand_to_bool( head->right, name, maxval ); } return head; } ptree_t *unreach_expanded_bool( char *name, int lower, int upper, int type ) { ptree_t *head, *node; int i; if (lower > upper) return NULL; if (!(type == PT_VARIABLE || type == PT_NEXT_VARIABLE)) { fprintf( stderr, "unreach_expanded_bool: Invoked with unsupported type, %d\n", type ); return NULL; } head = init_ptree( PT_NEG, NULL, 0 ); head->right = init_ptree( PT_EQUALS, NULL, 0 ); head->right->left = init_ptree( type, name, 0 ); head->right->right = init_ptree( PT_CONSTANT, NULL, lower ); for (i = lower+1; i <= upper; i++) { node = head; head = init_ptree( PT_AND, NULL, 0 ); head->right = node; head->left = init_ptree( PT_NEG, NULL, 0 ); head->left->right = init_ptree( PT_EQUALS, NULL, 0 ); head->left->right->left = init_ptree( type, name, 0 ); head->left->right->right = init_ptree( PT_CONSTANT, NULL, i ); } return head; } int tree_size( ptree_t *head ) { if (head == NULL) return 0; return 1 + tree_size( head->left ) + tree_size( head->right ); } void print_node( ptree_t *node, FILE *fp ) { if (fp == NULL) fp = stdout; switch (node->type) { case PT_EMPTY: fprintf( fp, "(empty)" ); break; case PT_VARIABLE: fprintf( fp, "%s", node->name ); break; case PT_NEXT_VARIABLE: fprintf( fp, "%s'", node->name ); break; case PT_CONSTANT: fprintf( fp, "%d", node->value ); break; case PT_NEG: fprintf( fp, "!" ); break; case PT_AND: fprintf( fp, "&" ); break; case PT_OR: fprintf( fp, "|" ); break; case PT_IMPLIES: fprintf( fp, "->" ); break; case PT_EQUIV: fprintf( fp, "<->" ); break; case PT_EQUALS: fprintf( fp, "=" ); break; case PT_NOTEQ: fprintf( fp, "!=" ); break; case PT_LT: fprintf( fp, "<" ); break; case PT_GT: fprintf( fp, ">" ); break; case PT_LE: fprintf( fp, "<=" ); break; case PT_GE: fprintf( fp, ">=" ); break; default: fprintf( stderr, "inorder_print: Unrecognized type, %d\n", node->type ); break; } } void inorder_trav( ptree_t *head, void (* node_fn)(ptree_t *, void *), void *arg ) { if (head == NULL) return; inorder_trav( head->left, node_fn, arg ); (*node_fn)( head, arg ); inorder_trav( head->right, node_fn, arg ); } ptree_t *merge_ptrees( ptree_t **heads, int len, int type ) { ptree_t *head, *node; int i; if (len <= 0 || heads == NULL) /* Vacuous call. */ return NULL; if (len == 1) /* Special case */ return *heads; /* Check whether valid merging operator requested. */ switch (type) { case PT_AND: case PT_OR: case PT_IMPLIES: break; default: return NULL; } head = init_ptree( type, NULL, -1 ); if (head == NULL) return NULL; head->right = *(heads+len-1); node = head; for (i = len-1; i > 1; i--) { node->left = init_ptree( type, NULL, -1 ); if (node->left == NULL) { fprintf( stderr, "Error: merge_ptrees failed to create enough new" " nodes.\n" ); return NULL; } node = node->left; node->right = *(heads+i-1); } node->left = *heads; return head; } ptree_t *append_list_item( ptree_t *head, int type, char *name, int value ) { if (head == NULL) { return init_ptree( type, name, value ); } if (head->left == NULL) { head->left = init_ptree( type, name, value ); return head->left; } else { return append_list_item( head->left, type, name, value ); } } ptree_t *remove_list_item( ptree_t *head, int index ) { ptree_t *child; int length = tree_size( head ); int current_index = 1; /* Error-checking */ if (head == NULL) { fprintf( stderr, "WARNING: remove_list_item called with empty tree.\n" ); return NULL; } if (index < -1 || index >= length) { fprintf( stderr, "Error: remove_list_item given invalid index, %d." " Max possible is %d.\n", index, length-1 ); return NULL; } if (index == 0 || (length == 1 && index == -1)) { /* Special case; remove root, return pointer to next item. */ child = head->left; if (head->name != NULL) { free( head->name ); } free( head ); return child; } if (index == -1) /* Special case; remove last item. */ index = length-1; while (current_index != index) { head = head->left; current_index++; } child = head->left; head->left = child->left; if (child->name != NULL) { free( child->name ); } free( child ); return head; } ptree_t *pusht_terminal( ptree_t *head, int type, char *name, int value ) { ptree_t *new_head; new_head = init_ptree( type, name, value ); new_head->left = head; return new_head; } ptree_t *pusht_operator( ptree_t *head, int type ) { ptree_t *new_head, *prev; /* Make sure doing this is possible. */ if (head == NULL) return NULL; new_head = init_ptree( type, NULL, 0 ); prev = head; while (prev->left) { if (prev->type == PT_EMPTY || prev->type == PT_VARIABLE || prev->type == PT_NEXT_VARIABLE || prev->type == PT_CONSTANT || prev->type == PT_NEG) break; prev = prev->left; } new_head->left = prev->left; prev->left = NULL; new_head->right = head; return new_head; } void tree_dot_dump_node( ptree_t *node, FILE *fp ) { fprintf( fp, "\"%ld;\\n", (size_t)node ); print_node( node, fp ); fprintf( fp, "\"\n" ); if (node->left != NULL) { fprintf( fp, "\"%ld;\\n", (size_t)node ); print_node( node, fp ); fprintf( fp, "\" -> \"%ld;\\n", (size_t)(node->left) ); print_node( node->left, fp ); fprintf( fp, "\"\n" ); } if (node->right != NULL) { fprintf( fp, "\"%ld;\\n", (size_t)node ); print_node( node, fp ); fprintf( fp, "\" -> \"%ld;\\n", (size_t)(node->right) ); print_node( node->right, fp ); fprintf( fp, "\"\n" ); } } int tree_dot_dump( ptree_t *head, char *filename ) { FILE *fp = fopen( filename, "w" ); if (fp == NULL) { perror( __FILE__ ", fopen" ); exit(-1); } if (fprintf( fp, "digraph PT {\n" ) < -1) { fclose( fp ); return -1; } inorder_trav( head, tree_dot_dump_node, fp ); fprintf( fp, "}\n" ); if (fclose( fp )) { perror( __FILE__ ", fclose" ); exit(-1); } return 0; } void print_formula( ptree_t *head, FILE *fp, unsigned char format_flags ) { if (head == NULL) { fprintf( stderr, "WARNING: print_formula called with NULL node." ); return; } if (fp == NULL) fp = stdout; /* Special cases */ if (format_flags == FORMULA_SYNTAX_SPIN) { switch (head->type) { case PT_IMPLIES: fprintf( fp, "(!" ); print_formula( head->left, fp, format_flags ); fprintf( fp, "||" ); print_formula( head->right, fp, format_flags ); fprintf( fp, ")" ); return; case PT_EQUIV: /* Naively compute subtrees twice, to avoid space requirements of caching. */ fprintf( fp, "((" ); print_formula( head->left, fp, format_flags ); fprintf( fp, "&&" ); print_formula( head->right, fp, format_flags ); fprintf( fp, ")||(!" ); print_formula( head->left, fp, format_flags ); fprintf( fp, "&&!" ); print_formula( head->right, fp, format_flags ); fprintf( fp, "))" ); return; } } switch (head->type) { case PT_AND: case PT_OR: case PT_IMPLIES: case PT_EQUIV: case PT_EQUALS: case PT_NOTEQ: case PT_LT: /* less than */ case PT_GT: /* greater than */ case PT_GE: /* ...or equal to*/ case PT_LE: fprintf( fp, "(" ); if (head->left != NULL && head->right != NULL && ((head->right->type == PT_VARIABLE || head->right->type == PT_NEXT_VARIABLE) && head->left->type == PT_CONSTANT && head->right->value >= 0)) { fprintf( fp, "%d", head->left->value ); } else { print_formula( head->left, fp, format_flags ); } break; case PT_NEG: fprintf( fp, "(!" ); print_formula( head->right, fp, format_flags ); fprintf( fp, ")" ); return; case PT_VARIABLE: fprintf( fp, "%s", head->name ); return; case PT_NEXT_VARIABLE: if (format_flags == FORMULA_SYNTAX_SPIN) { fprintf( fp, "%s_next", head->name ); } else { fprintf( fp, "%s'", head->name ); } return; case PT_CONSTANT: if (head->value == 0) { if (format_flags == FORMULA_SYNTAX_SPIN) { fprintf( fp, "false" ); } else { fprintf( fp, "False" ); } } else if (head->value == 1) { if (format_flags == FORMULA_SYNTAX_SPIN) { fprintf( fp, "true" ); } else { fprintf( fp, "True" ); } } else { fprintf( fp, "%d", head->value ); } return; default: fprintf( stderr, "WARNING: print_formula called with node of unknown type" ); return; } switch (head->type) { case PT_AND: if (format_flags == FORMULA_SYNTAX_SPIN) { fprintf( fp, "&&" ); } else { fprintf( fp, "&" ); } break; case PT_OR: if (format_flags == FORMULA_SYNTAX_SPIN) { fprintf( fp, "||" ); } else { fprintf( fp, "|" ); } break; case PT_IMPLIES: fprintf( fp, "->" ); break; case PT_EQUIV: fprintf( fp, "<->" ); break; case PT_EQUALS: if (format_flags == FORMULA_SYNTAX_SPIN) { fprintf( fp, "==" ); } else { fprintf( fp, "=" ); } break; case PT_NOTEQ: fprintf( fp, "!=" ); break; case PT_LT: fprintf( fp, "<" ); break; case PT_GT: fprintf( fp, ">" ); break; case PT_GE: fprintf( fp, ">=" ); break; case PT_LE: fprintf( fp, "<=" ); break; } if (head->left != NULL && head->right != NULL && ((head->left->type == PT_VARIABLE || head->left->type == PT_NEXT_VARIABLE) && head->right->type == PT_CONSTANT && head->left->value >= 0)) { fprintf( fp, "%d", head->right->value ); } else { print_formula( head->right, fp, format_flags ); } fprintf( fp, ")" ); return; } DdNode *ptree_BDD( ptree_t *head, ptree_t *var_list, DdManager *manager ) { DdNode *lsub, *rsub,*fn2, *tmp; int index; /* Initialize with NULL to ensure meaningful return value in case default branches taken. */ DdNode *fn = NULL; switch (head->type) { case PT_AND: case PT_OR: case PT_IMPLIES: case PT_EQUIV: lsub = ptree_BDD( head->left, var_list, manager ); rsub = ptree_BDD( head->right, var_list, manager ); break; case PT_NEG: rsub = ptree_BDD( head->right, var_list, manager ); break; case PT_VARIABLE: index = find_list_item( var_list, head->type, head->name, 0 ); if (index < 0) { fprintf( stderr, "Error: ptree_BDD requested variable \"%s\"," " but it is not in given list.\n", head->name ); exit(-1); } lsub = Cudd_ReadOne( manager ); Cudd_Ref( lsub ); fn = Cudd_bddAnd( manager, lsub, Cudd_bddIthVar( manager, index ) ); Cudd_Ref( fn ); Cudd_RecursiveDeref( manager, lsub ); break; case PT_NEXT_VARIABLE: index = find_list_item( var_list, PT_VARIABLE, head->name, 0 ); if (index < 0) { fprintf( stderr, "Error: ptree_BDD requested primed variable \"%s\"," " but it is not in given list.\n", head->name ); exit(-1); } lsub = Cudd_ReadOne( manager ); Cudd_Ref( lsub ); fn = Cudd_bddAnd( manager, lsub, Cudd_bddIthVar( manager, tree_size(var_list)+index ) ); Cudd_Ref( fn ); Cudd_RecursiveDeref( manager, lsub ); break; case PT_CONSTANT: if (head->value == 0) { fn = Cudd_Not( Cudd_ReadOne( manager ) ); } else { fn = Cudd_ReadOne( manager ); } Cudd_Ref( fn ); break; } switch (head->type) { case PT_AND: fn = Cudd_bddAnd( manager, lsub, rsub ); Cudd_Ref( fn ); Cudd_RecursiveDeref( manager, lsub ); Cudd_RecursiveDeref( manager, rsub ); break; case PT_OR: fn = Cudd_bddOr( manager, lsub, rsub ); Cudd_Ref( fn ); Cudd_RecursiveDeref( manager, lsub ); Cudd_RecursiveDeref( manager, rsub ); break; case PT_IMPLIES: tmp = Cudd_Not( lsub ); Cudd_Ref( tmp ); Cudd_RecursiveDeref( manager, lsub ); fn = Cudd_bddOr( manager, tmp, rsub ); Cudd_Ref( fn ); Cudd_RecursiveDeref( manager, tmp ); Cudd_RecursiveDeref( manager, rsub ); break; case PT_EQUIV: /* -> */ tmp = Cudd_Not( lsub ); Cudd_Ref( tmp ); fn = Cudd_bddOr( manager, tmp, rsub ); Cudd_Ref( fn ); Cudd_RecursiveDeref( manager, tmp ); /* <- */ tmp = Cudd_Not( rsub ); Cudd_Ref( tmp ); Cudd_RecursiveDeref( manager, rsub ); fn2 = Cudd_bddOr( manager, tmp, lsub ); Cudd_Ref( fn2 ); Cudd_RecursiveDeref( manager, tmp ); Cudd_RecursiveDeref( manager, lsub ); /* & */ tmp = fn; fn = Cudd_bddAnd( manager, fn, fn2 ); Cudd_Ref( fn ); Cudd_RecursiveDeref( manager, tmp ); Cudd_RecursiveDeref( manager, fn2 ); break; case PT_NEG: fn = Cudd_Not( rsub ); Cudd_Ref( fn ); Cudd_RecursiveDeref( manager, rsub ); break; } return fn; } int find_list_item( ptree_t *head, int type, char *name, int value ) { int index = 0; while (head != NULL) { if (head->type == type) { if (head->type == PT_VARIABLE || head->type == PT_NEXT_VARIABLE) { /* If node is variable type, then names must match. */ if (name != NULL && head->name != NULL && !strcmp( head->name, name )) break; } else if (head->type == PT_CONSTANT) { /* If node is constant (e.g., True), then values must match. */ if (head->value == value) break; } else { /* Otherwise, it suffices to have the same type. */ break; } } index += 1; head = head->left; } if (head == NULL) { return -1; /* No matches found. */ } else { return index; } } ptree_t *get_list_item( ptree_t *head, int index ) { if (head == NULL || index < -1) return NULL; if (index == -1) { /* Special case of end item request. */ while (head->left != NULL) head = head->left; return head; } while (index >= 1) { if (head->left == NULL) return NULL; head = head->left; index--; } return head; }
26.514486
81
0.497351
a9ee64c2414981812fb6a185b88fac25fe384065
1,513
c
C
ext/rb_rdma/pd.c
hiroyuki-sato/rb_rdma
09705906e58620e79db0c5e4a1962c2eb201863d
[ "MIT" ]
null
null
null
ext/rb_rdma/pd.c
hiroyuki-sato/rb_rdma
09705906e58620e79db0c5e4a1962c2eb201863d
[ "MIT" ]
8
2016-05-13T00:07:00.000Z
2016-07-12T13:07:08.000Z
ext/rb_rdma/pd.c
hiroyuki-sato/rb_rdma
09705906e58620e79db0c5e4a1962c2eb201863d
[ "MIT" ]
null
null
null
#include "rb_rdma.h" #include "context.h" #include "pd.h" VALUE cPD; static size_t memsize_rdma_pd(const void *p){ return sizeof(struct rb_rdma_data_pd *); }; static void free_rdma_pd(void *ptr){ struct rb_rdma_data_pd *data_pd = ptr; if( data_pd->pd ) ibv_dealloc_pd(data_pd->pd); xfree(data_pd); }; static void mark_rdma_pd(void *ptr){ struct rb_rdma_data_pd *data_pd = ptr; rb_gc_mark(data_pd->context); } const rb_data_type_t rdma_pd_type = { "rdma_pd", { mark_rdma_pd, free_rdma_pd, memsize_rdma_pd }, 0,0, 0 }; static VALUE pd_s_alloc(VALUE klass){ VALUE self; struct rb_rdma_data_pd *data_pd; self = TypedData_Make_Struct(klass,struct rb_rdma_data_pd, &rdma_pd_type,data_pd); data_pd->pd = NULL; return self; } static VALUE rdma_pd_initialize(VALUE self, VALUE rb_ctx){ struct rdma_context *ctx; struct rb_rdma_data_pd *data_pd; Check_OBJ_Type(rb_ctx,cContext,"not RDMA::Context object"); GET_Context_DATA(rb_ctx,ctx); GET_PD_DATA(self,data_pd); data_pd->context = rb_ctx; printf("ibv_ctx in pd %p\n",ctx->context); data_pd->pd = ibv_alloc_pd(ctx->context); if(!data_pd->pd){ rb_exc_raise(rb_syserr_new(errno, "pd alloc fail")); // TODO ERROR } printf("alloc_pd %p\n",data_pd->pd); return self; } void Init_pd(){ cPD = rb_define_class_under(mRbRDMA, "PD", rb_cData); rb_define_alloc_func(cPD, pd_s_alloc); rb_define_method(cPD,"initialize", rdma_pd_initialize,1); }
18.228916
61
0.694646
aa8a1c4e83ed1247630268c8fe1c9e407bef8c0f
509
c
C
1051.c
thiagozanini/URI
c32afe25390ce0a3fea9a060e8fbdc4b3ec4e631
[ "MIT" ]
null
null
null
1051.c
thiagozanini/URI
c32afe25390ce0a3fea9a060e8fbdc4b3ec4e631
[ "MIT" ]
null
null
null
1051.c
thiagozanini/URI
c32afe25390ce0a3fea9a060e8fbdc4b3ec4e631
[ "MIT" ]
null
null
null
#include <stdio.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <stdio.h> #include <stdlib.h> int main(){ double A; float X; scanf("%lf", &A); if (A<=2000) { printf("Isento\n"); }else{ if (A>2000 && A<=3000) { X=((A-2000)*0.08);} else if(A>3000 && A<=4500) { X=(((A-3000)*0.18)+80);} else if (A>4500){ X=(((A-4500)*0.28)+80+270); } printf("R$ %.2f\n", X); } return 0; }
19.576923
39
0.438114
a64069c4b15ee370bbf87a243d4b9184fa8b6166
1,598
h
C
usr/lib/libcoreroutine.dylib/RTStoredLocationOfInterestEnumerationOptions.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
1
2020-11-04T15:43:01.000Z
2020-11-04T15:43:01.000Z
usr/lib/libcoreroutine.dylib/RTStoredLocationOfInterestEnumerationOptions.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
usr/lib/libcoreroutine.dylib/RTStoredLocationOfInterestEnumerationOptions.h
zhangkn/iOS14Header
4323e9459ed6f6f5504ecbea2710bfd6c3d7c946
[ "MIT" ]
null
null
null
/* * This header is generated by classdump-dyld 1.0 * on Sunday, September 27, 2020 at 11:52:36 AM Mountain Standard Time * Operating System: Version 14.0 (Build 18A373) * Image Source: /usr/lib/libcoreroutine.dylib * classdump-dyld is licensed under GPLv3, Copyright © 2013-2016 by Elias Limneos. */ #import <libcoreroutine.dylib/libcoreroutine.dylib-Structs.h> #import <libobjc.A.dylib/NSCopying.h> @class NSDateInterval; @interface RTStoredLocationOfInterestEnumerationOptions : NSObject <NSCopying> { BOOL _ascendingVisitEntryDate; BOOL _singleVisit; unsigned long long _batchSize; NSDateInterval* _dateInterval; } @property (nonatomic,readonly) BOOL ascendingVisitEntryDate; //@synthesize ascendingVisitEntryDate=_ascendingVisitEntryDate - In the implementation block @property (nonatomic,readonly) unsigned long long batchSize; //@synthesize batchSize=_batchSize - In the implementation block @property (nonatomic,copy,readonly) NSDateInterval * dateInterval; //@synthesize dateInterval=_dateInterval - In the implementation block @property (nonatomic,readonly) BOOL singleVisit; //@synthesize singleVisit=_singleVisit - In the implementation block -(id)copyWithZone:(NSZone*)arg1 ; -(NSDateInterval *)dateInterval; -(id)init; -(BOOL)isEqual:(id)arg1 ; -(unsigned long long)batchSize; -(unsigned long long)hash; -(id)initWithAscendingVisitEntryDate:(BOOL)arg1 batchSize:(unsigned long long)arg2 dateInterval:(id)arg3 singleVisit:(BOOL)arg4 ; -(BOOL)singleVisit; -(BOOL)ascendingVisitEntryDate; @end
42.052632
172
0.757822
2eccd851cec9a5fa377d975506a4c88e8edebe0d
2,824
c
C
lib/src/profile_curves.c
EwoutH/colorist
8e8b586aceac9f54fecb648e94f6e4ad19593c76
[ "BSL-1.0" ]
null
null
null
lib/src/profile_curves.c
EwoutH/colorist
8e8b586aceac9f54fecb648e94f6e4ad19593c76
[ "BSL-1.0" ]
null
null
null
lib/src/profile_curves.c
EwoutH/colorist
8e8b586aceac9f54fecb648e94f6e4ad19593c76
[ "BSL-1.0" ]
null
null
null
// --------------------------------------------------------------------------- // Copyright Joe Drago 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) // --------------------------------------------------------------------------- #include "colorist/profile.h" #include "colorist/context.h" #include "colorist/embedded.h" #include "lcms2.h" #include "md5.h" #include <string.h> struct CurveSignature { uint8_t signature[16]; }; static struct CurveSignature pqProfiles_[] = { { { 0x59, 0x53, 0xac, 0x21, 0x04, 0x41, 0x70, 0xc4, 0x7c, 0x98, 0x9e, 0xa6, 0x27, 0x11, 0x42, 0xd9 } }, // HDR_HD_ST2084.icc { { 0x57, 0x15, 0xa6, 0x9d, 0xc0, 0xc9, 0x89, 0x16, 0x1e, 0x3f, 0x71, 0x6a, 0xe3, 0x72, 0xa0, 0x1d } }, // HDR_P3_D65_ST2084.icc { { 0xbf, 0x0c, 0x50, 0x8c, 0x59, 0xaa, 0xfc, 0xa1, 0x17, 0xc3, 0xcf, 0xce, 0xd6, 0xf3, 0xe3, 0x07 } } // HDR_UHD_ST2084.icc }; static const int pqProfileCount = sizeof(pqProfiles_) / sizeof(pqProfiles_[0]); static struct CurveSignature sentinelHLGCurve_ = { { 0x68, 0x88, 0x4e, 0xc0, 0xd3, 0x82, 0xe4, 0x43, 0xcd, 0x03, 0x91, 0xfd, 0xb9, 0x17, 0x8e, 0x94 } }; // hlgCurve.bin static struct CurveSignature sentinelPQCurve_ = { { 0x40, 0xb8, 0xbe, 0x41, 0x32, 0xd9, 0x58, 0x33, 0x1c, 0xaa, 0xc1, 0x20, 0x4c, 0x72, 0xdc, 0xae } }; // pqCurve.bin clBool clProfileHasPQSignature(struct clContext * C, clProfile * profile, clProfilePrimaries * primaries) { for (int i = 0; i < pqProfileCount; ++i) { struct CurveSignature * pqProfile = &pqProfiles_[i]; if (!memcmp(pqProfile->signature, profile->signature, sizeof(struct CurveSignature))) { if (primaries) { clProfileQuery(C, profile, primaries, NULL, NULL); } return clTrue; } } return clFalse; } clProfileCurveType clProfileCurveSignature(struct clContext * C, clProfile * profile) { if (cmsReadRawTag(profile->handle, cmsSigRedTRCTag, NULL, 0) == (int)pqCurveBinarySize) { struct CurveSignature curveSignature; uint8_t * rawCurve = clAllocate(pqCurveBinarySize); cmsReadRawTag(profile->handle, cmsSigRedTRCTag, rawCurve, pqCurveBinarySize); MD5_CTX ctx; MD5_Init(&ctx); MD5_Update(&ctx, rawCurve, (unsigned long)pqCurveBinarySize); MD5_Final(curveSignature.signature, &ctx); clFree(rawCurve); if (!memcmp(&sentinelHLGCurve_, &curveSignature, sizeof(struct CurveSignature))) { return CL_PCT_HLG; } if (!memcmp(&sentinelPQCurve_, &curveSignature, sizeof(struct CurveSignature))) { return CL_PCT_PQ; } } return CL_PCT_UNKNOWN; }
40.342857
168
0.61721
03efaae9a8b43372d2c01fec4a5b3748e1ee9e3c
4,117
h
C
src/viewer/scriptcontrol.h
Romop5/noob-engine
346376b6243a270b31fe704fb532f92908ccc12f
[ "MIT" ]
2
2018-02-19T21:46:16.000Z
2019-05-26T17:30:12.000Z
src/viewer/scriptcontrol.h
Romop5/noob-engine
346376b6243a270b31fe704fb532f92908ccc12f
[ "MIT" ]
null
null
null
src/viewer/scriptcontrol.h
Romop5/noob-engine
346376b6243a270b31fe704fb532f92908ccc12f
[ "MIT" ]
null
null
null
/** * @file ./viewer/scriptcontrol.h * @brief Multithreaded script loading * @copyright The MIT license */ #include <engine/engine.h> #include <thread> #include <mutex> #include <vector> class ScriptControl { std::thread slave; std::mutex jobMutex; std::vector<std::string> inputScripts; std::vector<std::shared_ptr<Generator>> outputResults; size_t iterationCount; float stochasticity; bool shouldTerminate; bool _hasJob; // path to last script used std::string lastScriptName; public: ScriptControl() { this->shouldTerminate = false; this->_hasJob = false; } ~ScriptControl() { jobMutex.lock(); this->shouldTerminate = true; jobMutex.unlock(); this->slave.join(); } /** * @brief Add script which will be generated with parameters * * @param name * @param iterationCount * @param stochasticity */ void addScript(std::string name, size_t iterationCount = 1, float stochasticity = 0.5) { this->jobMutex.lock(); this->inputScripts.push_back(name); this->lastScriptName = name; this->iterationCount = iterationCount; this->stochasticity = stochasticity; this->jobMutex.unlock(); } /** * @brief Get last script that was generated * * @return */ const std::string& getLastScriptName() const { return this->lastScriptName; } void init() { slave = std::thread([this]() { while(1==1) { std::string scriptName = ""; jobMutex.lock(); if(this->shouldTerminate) { this->jobMutex.unlock(); return; } this->_hasJob = false; if(this->inputScripts.size() > 0) { scriptName = this->inputScripts.back(); this->inputScripts.pop_back(); this->_hasJob = true; } jobMutex.unlock(); if(scriptName == "") { std::this_thread::sleep_for(std::chrono::milliseconds(10)); continue; } else { LOG_INFO("Doing something with %s\n",scriptName.c_str()); auto gen = std::make_shared<Generator>(); if(gen->compile(scriptName.c_str())) { // set iteration uniform gen->getLibrary().setUniform("iterations", (int) this->iterationCount); gen->getLibrary().setUniform("stochasticity", (float) this->stochasticity); bool generationResult = gen->generate(); if(generationResult != false) { if(scriptName.find("cube") != std::string::npos) { this->jobMutex.lock(); this->outputResults.push_back(gen); this->jobMutex.unlock(); } } if(generationResult == false) LOG_ERROR("Generation failed\n"); } else { LOG_ERROR("Procedural compilation failed\n"); } } } }); } void tick(std::shared_ptr<SceneNode> scene) { std::lock_guard<std::mutex> lock(jobMutex); if(outputResults.size() == 0) { return; } else { auto newNode = std::make_shared<SceneNode>(); auto result = this->outputResults.back()->produceOutput(newNode); if(result != 0) { scene->clearChildren(); scene->addChild(newNode); } this->outputResults.pop_back(); } } bool hasJob() { return this->_hasJob; } };
29.618705
99
0.477046
644d67df1d13141a451e7cb2d42af628644311bf
9,643
h
C
Inc/NamedInlineComponent.h
Remag/ReversedLibrary
c2e929586b1fccdf0f090bc68df2ec62389ceada
[ "MIT" ]
null
null
null
Inc/NamedInlineComponent.h
Remag/ReversedLibrary
c2e929586b1fccdf0f090bc68df2ec62389ceada
[ "MIT" ]
null
null
null
Inc/NamedInlineComponent.h
Remag/ReversedLibrary
c2e929586b1fccdf0f090bc68df2ec62389ceada
[ "MIT" ]
null
null
null
#pragma once #include <Redefs.h> #include <BaseString.h> #include <ComponentUtils.h> #include <Pair.h> #include <Map.h> namespace Relib { ////////////////////////////////////////////////////////////////////////// // A weakly typed component. class CNamedInlineComponent { public: // Constructors have to be public to be accessible from CMap. CNamedInlineComponent() = default; template <class ComponentClass> CNamedInlineComponent( TNamedComponentType compType, int typeSize, int typeAlignment, const ComponentClass& compClass ) : type( compType ), id( RelibInternal::CComponentClassInstance<ComponentClass>::RetrieveNextFreeId() ), size( typeSize ), alignment( typeAlignment ), componentClass( &compClass ) {} CNamedInlineComponent( TNamedComponentType compType, int typeSize, int typeAlignment, const IComponentClass& compClass, int componentId ) : type( compType ), id( componentId ), size( typeSize ), alignment( typeAlignment ), componentClass( &compClass ) {} // Named component creation and retrieval. // Get method returns null if no component with the given name exists. static CNamedInlineComponent* Get( CStringPart name ); template <class ComponentClass> static const CNamedInlineComponent* GetById( int componentId ); template <class ComponentClass> static CNamedInlineComponent GetOrCreate( CStringPart name, TNamedComponentType type ); template <class ComponentClass> static CNamedInlineComponent GetOrCreate( CStringPart name, int componentSize, int componentAlignment ); template <class ComponentClass> static CNamedInlineComponent Create( CStringPart name, TNamedComponentType type ); template <class ComponentClass> static CNamedInlineComponent Create( CStringPart name, int componentSize, int componentAlignment ); template <class T, class ComponentClass> static CNamedInlineComponent Create( CStringPart name ); // Associate a name with an existing component. template <class T, class ComponentClass> static CNamedInlineComponent AddExisting( CStringPart name, const CInlineComponent<T, ComponentClass>& component ); template <class ComponentClass> static CNamedInlineComponent AddExisting( CStringPart name, TNamedComponentType type, const ComponentClass& classInstance, int componentId ); CStringView Name() const { return name; } // Identifier and size of the component. int GetClassId() const { return componentClass->GetClassId(); } int GetId() const { return id; } int GetSize() const { return size; } int GetAlignment() const { return alignment; } TNamedComponentType GetType() const { return type; } private: const IComponentClass* componentClass = nullptr; CStringView name; TNamedComponentType type; int id; int size; int alignment; void setComponentName( CStringView newValue ) { name = newValue; } template <class ComponentClass> static CNamedInlineComponent getOrCreate( CStringPart name, TNamedComponentType type, int componentSize, int componentAlignment ); template <class ComponentClass> static CNamedInlineComponent create( CStringPart name, TNamedComponentType type, int componentSize, int componentAlignment ); template <class ComponentClass> static CNamedInlineComponent setNamedComponent( CStringPart name, TNamedComponentType type, int componentSize, int componentAlignment, const ComponentClass& classInstance ); template <class ComponentClass> static void setComponentIdValue( CNamedInlineComponent component ); }; ////////////////////////////////////////////////////////////////////////// namespace RelibInternal { // Named component database. extern REAPI CMap<CString, CNamedInlineComponent, CDefaultHash<CString>, CProcessHeap> NamedInlineComponents; // Named component database keyed by a class id and component id pair. extern REAPI CMap<CPair<int>, CNamedInlineComponent, CDefaultHash<CPair<int>>, CProcessHeap> NamedInlineComponentIds; // Component size and alignment dictionary. extern REAPI CEnumDictionary<TNamedComponentType, NCT_EnumCount, CPair<unsigned>> NamedComponentSizeDict; } ////////////////////////////////////////////////////////////////////////// inline CNamedInlineComponent* CNamedInlineComponent::Get( CStringPart name ) { return RelibInternal::NamedInlineComponents.Get( name ); } template <class ComponentClass> const CNamedInlineComponent* CNamedInlineComponent::GetById( int componentId ) { const auto classId = GetComponentClassInstance<ComponentClass>().GetUniqueId(); const auto idPair = CreatePair( classId, componentId ); return RelibInternal::NamedInlineComponentIds.Get( idPair ); } template <class ComponentClass> CNamedInlineComponent CNamedInlineComponent::GetOrCreate( CStringPart name, int componentSize, int componentAlignment ) { return getOrCreate<ComponentClass>( name, NCT_CustomComplex, componentSize, componentAlignment ); } template <class ComponentClass> CNamedInlineComponent CNamedInlineComponent::GetOrCreate( CStringPart name, TNamedComponentType type ) { staticAssert( NCT_EnumCount == 12 ); assert( type != NCT_CustomComplex && type != NCT_CustomPrimitive ); const auto sizeAlign = RelibInternal::NamedComponentSizeDict[type]; return getOrCreate<ComponentClass>( name, type, numeric_cast<int>( sizeAlign.First ), numeric_cast<int>( sizeAlign.Second ) ); } template <class ComponentClass> CNamedInlineComponent CNamedInlineComponent::getOrCreate( CStringPart name, TNamedComponentType type, int componentSize, int componentAlignment ) { assert( !name.IsEmpty() ); const auto& classInstance = GetComponentClassInstance<ComponentClass>(); auto& componentData = RelibInternal::NamedInlineComponents.GetOrCreate( name, type, componentSize, componentAlignment, classInstance ); auto& resultValue = componentData.Value(); if( resultValue.Name().IsEmpty() ) { resultValue.setComponentName( componentData.Key() ); setComponentIdValue<ComponentClass>( resultValue ); } return resultValue; } template <class ComponentClass> CNamedInlineComponent CNamedInlineComponent::Create( CStringPart name, int componentSize, int componentAlignment ) { return create<ComponentClass>( name, NCT_CustomComplex, componentSize, componentAlignment ); } template <class ComponentClass> CNamedInlineComponent CNamedInlineComponent::Create( CStringPart name, TNamedComponentType type ) { staticAssert( NCT_EnumCount == 12 ); assert( type != NCT_CustomComplex && type != NCT_CustomPrimitive ); const auto sizeAlign = RelibInternal::NamedComponentSizeDict[type]; return create<ComponentClass>( name, type, numeric_cast<int>( sizeAlign.First ), numeric_cast<int>( sizeAlign.Second ) ); } template <class T, class ComponentClass> CNamedInlineComponent CNamedInlineComponent::Create( CStringPart name ) { const auto type = Types::NamedComponentType<T>::Result; return create<ComponentClass>( name, type, sizeof( T ), alignof( T ) ); } template <class ComponentClass> CNamedInlineComponent CNamedInlineComponent::create( CStringPart name, TNamedComponentType type, int componentSize, int componentAlignment ) { assert( !RelibInternal::NamedInlineComponents.Has( name ) ); const auto& classInstance = GetComponentClassInstance<ComponentClass>(); const auto newData = setNamedComponent( name, type, componentSize, componentAlignment, classInstance ); setComponentIdValue<ComponentClass>( newData ); return newData; } template <class ComponentClass> CNamedInlineComponent CNamedInlineComponent::setNamedComponent( CStringPart name, TNamedComponentType type, int componentSize, int componentAlignment, const ComponentClass& classInstance ) { auto& newData = RelibInternal::NamedInlineComponents.Set( name, type, componentSize, componentAlignment, classInstance ); newData.Value().setComponentName( newData.Key() ); return newData.Value(); } template <class ComponentClass> void CNamedInlineComponent::setComponentIdValue( CNamedInlineComponent component ) { const auto classId = GetComponentClassInstance<ComponentClass>().GetUniqueId(); const auto idPair = CreatePair( classId, component.GetId() ); RelibInternal::NamedInlineComponentIds.Set( idPair, component ); } template <class T, class ComponentClass> CNamedInlineComponent CNamedInlineComponent::AddExisting( CStringPart name, const CInlineComponent<T, ComponentClass>& component ) { const auto type = component.GetType(); const auto& classInstance = GetComponentClassInstance<ComponentClass>(); auto& newData = RelibInternal::NamedInlineComponents.Set( name, type, sizeof( T ), alignof( T ), classInstance, component.GetId() ); newData.Value().setComponentName( newData.Key() ); setComponentIdValue<ComponentClass>( newData.Value() ); return newData.Value(); } template <class ComponentClass> CNamedInlineComponent CNamedInlineComponent::AddExisting( CStringPart name, TNamedComponentType type, const ComponentClass& classInstance, int componentId ) { const auto sizeAlign = RelibInternal::NamedComponentSizeDict[type]; auto& newData = RelibInternal::NamedInlineComponents.Set( name, type, numeric_cast<int>( sizeAlign.First ), numeric_cast<int>( sizeAlign.Second ), classInstance, componentId ); newData.Value().setComponentName( newData.Key() ); const auto classId = classInstance.GetClassId(); const auto idPair = CreatePair( classId, componentId ); RelibInternal::NamedInlineComponentIds.Set( idPair, newData.Value() ); return newData.Value(); } ////////////////////////////////////////////////////////////////////////// } // namespace Relib.
45.2723
189
0.755263
8c4a5bed00852d959afa181b21d190908a4f82e7
1,830
c
C
toolbox/gsw_specvol.c
efiring/GSW-C
092f1e32e7c4f2efd861fc0ca6a5c2c2150b6caf
[ "BSD-3-Clause" ]
null
null
null
toolbox/gsw_specvol.c
efiring/GSW-C
092f1e32e7c4f2efd861fc0ca6a5c2c2150b6caf
[ "BSD-3-Clause" ]
null
null
null
toolbox/gsw_specvol.c
efiring/GSW-C
092f1e32e7c4f2efd861fc0ca6a5c2c2150b6caf
[ "BSD-3-Clause" ]
1
2017-07-23T12:53:08.000Z
2017-07-23T12:53:08.000Z
/* !========================================================================== function gsw_specvol(sa,ct,p) !========================================================================== ! ! Calculates specific volume from Absolute Salinity, Conservative ! Temperature and pressure, using the computationally-efficient ! polynomial expression for specific volume (Roquet et al., 2014). ! ! sa : Absolute Salinity [g/kg] ! ct : Conservative Temperature (ITS-90) [deg C] ! p : sea pressure [dbar] ! ( i.e. absolute pressure - 10.1325 dbar ) ! ! specvol: specific volume [m^3/kg] */ double gsw_specvol(double sa, double ct, double p) { GSW_TEOS10_CONSTANTS; GSW_SPECVOL_COEFFICIENTS; double xs, ys, z, value; xs = sqrt(gsw_sfac*sa + offset); ys = ct*0.025; z = p*1e-4; value = v000 + xs*(v010 + xs*(v020 + xs*(v030 + xs*(v040 + xs*(v050 + v060*xs))))) + ys*(v100 + xs*(v110 + xs*(v120 + xs*(v130 + xs*(v140 + v150*xs)))) + ys*(v200 + xs*(v210 + xs*(v220 + xs*(v230 + v240*xs))) + ys*(v300 + xs*(v310 + xs*(v320 + v330*xs)) + ys*(v400 + xs*(v410 + v420*xs) + ys*(v500 + v510*xs + v600*ys))))) + z*(v001 + xs*(v011 + xs*(v021 + xs*(v031 + xs*(v041 + v051*xs)))) + ys*(v101 + xs*(v111 + xs*(v121 + xs*(v131 + v141*xs))) + ys*(v201 + xs*(v211 + xs*(v221 + v231*xs)) + ys*(v301 + xs*(v311 + v321*xs) + ys*(v401 + v411*xs + v501*ys)))) + z*(v002 + xs*(v012 + xs*(v022 + xs*(v032 + v042*xs))) + ys*(v102 + xs*(v112 + xs*(v122 + v132*xs)) + ys*(v202 + xs*(v212 + v222*xs) + ys*(v302 + v312*xs + v402*ys))) + z*(v003 + xs*(v013 + v023*xs) + ys*(v103 + v113*xs + v203*ys) + z*(v004 + v014*xs + v104*ys + z*(v005 + v006*z))))); return (value); }
40.666667
76
0.492896
147fcd3a36c6bbf0723095306f58e487136439cb
246
h
C
include/x86/idt.h
m-rinaldi/emuk86
c5224ad212ec73ddc6d5b9bfb845fb487b2de085
[ "MIT" ]
null
null
null
include/x86/idt.h
m-rinaldi/emuk86
c5224ad212ec73ddc6d5b9bfb845fb487b2de085
[ "MIT" ]
null
null
null
include/x86/idt.h
m-rinaldi/emuk86
c5224ad212ec73ddc6d5b9bfb845fb487b2de085
[ "MIT" ]
null
null
null
#pragma once int idt_init(void); int idt_set_trap_gate(unsigned int index, void (*isr)(void)); int idt_set_intr_gate(unsigned int index, void (*isr)(void)); int idt_set_task_gate(unsigned int index, void (*isr)(void)); void idt_display(void);
24.6
61
0.752033
f0318a9e156e1811272a5c2286041928178e5b64
6,084
h
C
parser/parser_sha_mct_helper.h
banvikas/acvpparser
802bf0c63ee6e380cef9f9c43c586e9cdab84e7c
[ "BSD-3-Clause" ]
18
2018-12-03T19:08:47.000Z
2022-01-30T16:20:53.000Z
parser/parser_sha_mct_helper.h
banvikas/acvpparser
802bf0c63ee6e380cef9f9c43c586e9cdab84e7c
[ "BSD-3-Clause" ]
47
2018-12-14T21:00:04.000Z
2022-03-17T21:42:07.000Z
parser/parser_sha_mct_helper.h
banvikas/acvpparser
802bf0c63ee6e380cef9f9c43c586e9cdab84e7c
[ "BSD-3-Clause" ]
15
2020-04-28T12:21:45.000Z
2022-03-17T21:42:20.000Z
/* * Copyright (C) 2020 - 2021, Stephan Mueller <smueller@chronox.de> * * License: see LICENSE file in root directory * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF * WHICH ARE HEREBY 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 NOT ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. */ /* * The following functions are helper functions to implement * the SHA1/2, SHA3 and SHAKE MCT inner loop. */ #ifndef PARSER_SHA_MCT_HELPER_H #define PARSER_SHA_MCT_HELPER_H #include "logger.h" #include "parser_sha.h" #include "stringhelper.h" #ifdef __cplusplus extern "C" { #endif /** * @brief SHA-1 and SHA-2 Monte-Carlo Testing inner loop implementation. * * This is a service function that may be used when implementing the MCT * inner loop. To utilize the function, the data provided by the parser * needs to be provided and a function call back implementing one hash * operation. * * An example of how to use it is given with * backend_openssl.c:openssl_hash_inner_loop */ static inline int parser_sha2_inner_loop(struct sha_data *data, flags_t parsed_flags, int (*hash_generate)(struct sha_data *data, flags_t parsed_flags)) { unsigned int j; int ret; if (!hash_generate) return -EOPNOTSUPP; for (j = 0; j < 1000; j++) { unsigned int k = 0; free_buf(&data->mac); CKINT_LOG(hash_generate(data, parsed_flags), "SHA operation failed\n"); /* move the two last blocks to the front */ for (k = 0; k < data->mac.len * 2; k++) data->msg.buf[k] = data->msg.buf[(k + data->mac.len)]; /* place newly calculated message to the end */ memcpy(data->msg.buf + data->mac.len * 2, data->mac.buf, data->mac.len); } out: return ret; } /** * @brief SHA-3 Monte-Carlo Testing inner loop implementation. * * This is a service function that may be used when implementing the MCT * inner loop. To utilize the function, the data provided by the parser * needs to be provided and a function call back implementing one hash * operation. * * An example of how to use it is given with * backend_openssl.c:openssl_hash_inner_loop */ static inline int parser_sha3_inner_loop(struct sha_data *data, flags_t parsed_flags, int (*hash_generate)(struct sha_data *data, flags_t parsed_flags)) { unsigned int j; int ret; if (!hash_generate) return -EOPNOTSUPP; for (j = 0; j < 1000; j++) { free_buf(&data->mac); CKINT_LOG(hash_generate(data, parsed_flags), "SHA operation failed\n"); /* hash becomes new message */ memcpy(data->msg.buf, data->mac.buf, data->mac.len); } out: return ret; } #define min(x, y) (((size_t)x < (size_t)y) ? x : y) #define GCC_VERSION (__GNUC__ * 10000 \ + __GNUC_MINOR__ * 100 \ + __GNUC_PATCHLEVEL__) #if !defined(TEST) && (GCC_VERSION >= 40400 || defined(__clang__)) # define __HAVE_BUILTIN_BSWAP16__ #endif /**************** * Rotate the 32 bit unsigned integer X by N bits left/right */ /* Byte swap for 16-bit, 32-bit and 64-bit integers. */ #ifndef __HAVE_BUILTIN_BSWAP16__ static inline uint16_t rol16(uint16_t x, int n) { return ( (x << (n&(16-1))) | (x >> ((16-n)&(16-1))) ); } static inline uint16_t ror16(uint16_t x, int n) { return ( (x >> (n&(16-1))) | (x << ((16-n)&(16-1))) ); } static inline uint16_t _bswap16(uint16_t x) { return ((rol16(x, 8) & 0x00ff) | (ror16(x, 8) & 0xff00)); } # define _swap16(x) _bswap16(x) #else # define _swap16(x) (uint16_t)__builtin_bswap16((uint16_t)(x)) #endif /* Endian dependent byte swap operations. */ /* Endian dependent byte swap operations. */ #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ # define be_bswap16(x) ((uint16_t)(x)) #elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ # define be_bswap16(x) _swap16(x) #else # error "Endianess not defined" #endif /** * @brief SHAKE Monte-Carlo Testing inner loop implementation. * * This is a service function that may be used when implementing the MCT * inner loop. To utilize the function, the data provided by the parser * needs to be provided and a function call back implementing one hash * operation. * * An example of how to use it is given with * backend_openssl.c:openssl_hash_inner_loop */ static inline int parser_shake_inner_loop(struct sha_data *data, flags_t parsed_flags, int (*hash_generate)(struct sha_data *data, flags_t parsed_flags)) { uint32_t minoutbytes = (data->minoutlen + 7) / 8, maxoutbytes = data->maxoutlen / 8; size_t read_outbits; uint32_t range; uint16_t outbits = 0; unsigned int j; int ret; if (!hash_generate) return -EOPNOTSUPP; CKNULL(minoutbytes, -EOPNOTSUPP); CKNULL(maxoutbytes, -EOPNOTSUPP); for (j = 0; j < 1000; j++) { free_buf(&data->mac); CKINT_LOG(hash_generate(data, parsed_flags), "SHAKE operation failed\n"); /* hash becomes new message */ memset(data->msg.buf, 0, data->msg.len); memcpy(data->msg.buf, data->mac.buf, min(data->msg.len, data->mac.len)); read_outbits = min(data->mac.len, sizeof(outbits)); /* * Rightmost_Output_bits = rightmost 16 bits of * Output_i. */ memcpy(&outbits + sizeof(outbits) - read_outbits, data->mac.buf + data->mac.len - read_outbits, read_outbits); /* Convert read value into an integer */ outbits = be_bswap16(outbits); range = maxoutbytes - minoutbytes + 1; data->outlen = minoutbytes + (outbits % range); data->outlen *= 8; } out: return ret; } #undef min #undef GCC_VERSION #undef be_bswap16 #ifdef __cplusplus } #endif #endif /* PARSER_SHA_MCT_HELPER_H */
26.684211
72
0.696252
004c503c7dd2b56edff5397095d2dd1a9a8fd6a5
1,629
h
C
src/binaryServer/HaSubscription.h
peramic/OPC-UA.Server
ebfafb0f9a1943fc1f2d44f20a0497a59e5bfd97
[ "Apache-2.0" ]
null
null
null
src/binaryServer/HaSubscription.h
peramic/OPC-UA.Server
ebfafb0f9a1943fc1f2d44f20a0497a59e5bfd97
[ "Apache-2.0" ]
null
null
null
src/binaryServer/HaSubscription.h
peramic/OPC-UA.Server
ebfafb0f9a1943fc1f2d44f20a0497a59e5bfd97
[ "Apache-2.0" ]
null
null
null
#ifndef BINARYSERVER_HASUBSCRIPTION_H #define BINARYSERVER_HASUBSCRIPTION_H #include "Event.h" #include "EventField.h" #include "HaSession.h" #include <uasession.h> // UaSession #include <uanodeid.h> // UaNodeId #include <vector> class HaSubscriptionPrivate; class HaSubscription { public: class HaSubscriptionCallback { public: HaSubscriptionCallback(); virtual ~HaSubscriptionCallback(); virtual void dataChanged(std::vector<NodeAttributes*>& nodeAttributes) /* throws Exception */ = 0; virtual void newEvents(std::vector<const BinaryServerNamespace::Event*>& events) /* throws Exception */ = 0; private: }; // sendReceiveTimeout: in sec. // publishingInterval: in ms HaSubscription(UaClientSdk::UaSession& session, int sendReceiveTimeout, int publishingInterval, HaSubscriptionCallback& callback) /* throws MutexException */; virtual ~HaSubscription() /* throws HaSubscriptionException */; void add(std::vector<NodeAttributes*>& nodeAttributes, std::map<UaNodeId, std::vector<BinaryServerNamespace::EventField*>*>& eventFields) /* throws HaSubscriptionException */; void remove(const std::vector<const UaNodeId*>& nodeIds) /* throws HaSubscriptionException */; void removeAll() /* throws HaSubscriptionException */; std::vector<const UaNodeId*>* getMonitoredItems() /* throws HaSubscriptionException */; private: HaSubscription(const HaSubscription& orig); HaSubscription& operator=(const HaSubscription&); HaSubscriptionPrivate* d; }; #endif /* BINARYSERVER_HASUBSCRIPTION_H */
32.58
99
0.718232
534af40bf8b917c444fdc2cb8939f594446faf54
3,882
h
C
morpho5/builtin/builtin.h
ConduitDan/morpho
9df2d652d9bc269ce0f8cdeb4d55cec51d95c2f9
[ "MIT" ]
10
2021-09-18T14:44:14.000Z
2022-03-26T11:41:50.000Z
morpho5/builtin/builtin.h
ConduitDan/morpho
9df2d652d9bc269ce0f8cdeb4d55cec51d95c2f9
[ "MIT" ]
79
2021-10-05T17:33:19.000Z
2022-03-31T16:06:10.000Z
morpho5/builtin/builtin.h
ConduitDan/morpho
9df2d652d9bc269ce0f8cdeb4d55cec51d95c2f9
[ "MIT" ]
2
2021-10-05T16:56:16.000Z
2021-10-31T19:55:27.000Z
/** @file builtin.h * @author T J Atherton * * @brief Morpho built in functions and classes */ #ifndef builtin_h #define builtin_h #include "object.h" #ifndef MORPHO_CORE #include "morpho.h" #endif /* --------------------------- * Built in functions * --------------------------- */ /** Flags that describe properties of the built in function */ typedef unsigned int builtinfunctionflags; #define BUILTIN_FLAGSEMPTY 0 /** Type of C function that implements a built in Morpho function */ typedef value (*builtinfunction) (vm *v, int nargs, value *args); /** A built in function object */ typedef struct { object obj; value name; builtinfunctionflags flags; builtinfunction function; } objectbuiltinfunction; /** Gets an objectfunction from a value */ #define MORPHO_GETBUILTINFUNCTION(val) ((objectbuiltinfunction *) MORPHO_GETOBJECT(val)) /** Tests whether an object is a function */ #define MORPHO_ISBUILTINFUNCTION(val) object_istype(val, OBJECT_BUILTINFUNCTION) /* --------------------------- * Built in classes * --------------------------- */ /** A type used to store the entries of a built in class */ typedef struct { enum { BUILTIN_METHOD, BUILTIN_PROPERTY } type; char *name; builtinfunctionflags flags; builtinfunction function; } builtinclassentry; /** The following macros help to define a built in class. They should be used outside of any function declaration. * To use: * MORPHO_BEGINCLASS(Object) - Starts the declaration * MORPHO_PROPERTY("test") - Adds a property called "test" to the definition * MORPHO_METHOD("init", object_init, BUILTIN_FLAGSEMPTY) - Adds a method called "init" to the definition * MORPHO_ENDCLASS - Ends the declaration */ #define MORPHO_BEGINCLASS(name) builtinclassentry builtinclass_##name[] = { #define MORPHO_PROPERTY(label) ((builtinclassentry) { .type=(BUILTIN_PROPERTY), .name=(label), .flags=BUILTIN_FLAGSEMPTY, .function=NULL}) #define MORPHO_METHOD(label, func, flg) ((builtinclassentry) { .type=(BUILTIN_METHOD), .name=(label), .flags=flg, .function=func}) #define MORPHO_ENDCLASS , MORPHO_PROPERTY(NULL) \ }; #define MORPHO_GETCLASSDEFINITION(name) (builtinclass_##name) /** Macros and functions for built in classes */ #define MORPHO_GETARG(args, n) (args[n+1]) /** This macro gets self */ #define MORPHO_SELF(args) (args[0]) /** Raise an error and return nil */ #define MORPHO_RAISE(v, err) { morpho_runtimeerror(v, err ); return MORPHO_NIL; } #define MORPHO_RAISEVARGS(v, err, ...) \ { morpho_runtimeerror(v, err, __VA_ARGS__); \ return MORPHO_NIL; } /* --------------------------- * Loop functions * --------------------------- */ /** Type of C function that implements a built in Morpho function */ typedef bool (*builtin_loopfunction) (vm *v, indx i, value item, void *ref); /* --------------------------- * Prototypes * --------------------------- */ value builtin_addfunction(char *name, builtinfunction func, builtinfunctionflags flags); value builtin_findfunction(value name); void builtin_printfunction(objectbuiltinfunction *f); value builtin_addclass(char *name, builtinclassentry desc[], value superclass); value builtin_findclass(value name); void builtin_copysymboltable(dictionary *out); value builtin_internsymbol(value symbol); value builtin_internsymbolascstring(char *symbol); void builtin_setveneerclass(objecttype type, value class); objectclass *builtin_getveneerclass(objecttype type); bool builtin_options(vm *v, int nargs, value *args, int *nfixed, int noptions, ...); bool builtin_iscallable(value val); bool builtin_enumerateloop(vm *v, value obj, builtin_loopfunction fn, void *ref); void builtin_initialize(void); void builtin_finalize(void); #endif /* builtin_h */
32.621849
139
0.676971
18007269a0d0a66206e345d5a855370323921f31
695
c
C
Src/count_larger.c
OferMon/Recursion-and-Backtracking
8afeedc70804f07c27402fecf1c5b42447dce684
[ "Apache-2.0" ]
null
null
null
Src/count_larger.c
OferMon/Recursion-and-Backtracking
8afeedc70804f07c27402fecf1c5b42447dce684
[ "Apache-2.0" ]
null
null
null
Src/count_larger.c
OferMon/Recursion-and-Backtracking
8afeedc70804f07c27402fecf1c5b42447dce684
[ "Apache-2.0" ]
null
null
null
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> /* The function gets a digit and a number, and checks several digits in a large mixer from the received number */ unsigned count_larger(unsigned n, unsigned x); // check functions void main() { unsigned int num, digit; printf("Enter an integer number\n"); scanf("%u", &num); printf("Enter digit "); scanf("%u", &digit); printf("There are %u digits in the number bigger than %u\n", count_larger(num, digit), digit); system("pause"); } unsigned count_larger(unsigned n, unsigned x) { if (n > 0) { if (n % 10 > x) return 1 + count_larger(n / 10, x); return count_larger(n / 10, x); } return 0; }
23.166667
114
0.648921
4b5150553c6aab0aa42d6b52bd7f833f93ef536b
20,229
h
C
Source/Core/Numeric/Quaternion.h
X1aoyueyue/KVS
ad47d62bef4fdd9ddd3412a26ee6557b63f0543b
[ "BSD-3-Clause" ]
42
2015-07-24T23:05:07.000Z
2022-03-16T01:31:04.000Z
Source/Core/Numeric/Quaternion.h
X1aoyueyue/KVS
ad47d62bef4fdd9ddd3412a26ee6557b63f0543b
[ "BSD-3-Clause" ]
4
2015-03-17T05:42:49.000Z
2020-08-09T15:21:45.000Z
Source/Core/Numeric/Quaternion.h
X1aoyueyue/KVS
ad47d62bef4fdd9ddd3412a26ee6557b63f0543b
[ "BSD-3-Clause" ]
29
2015-01-03T05:56:32.000Z
2021-10-05T15:28:33.000Z
/****************************************************************************/ /** * @file Quaternion.h * @author Naohisa Sakamoto */ /****************************************************************************/ #ifndef KVS__QUATERNION_H_INCLUDE #define KVS__QUATERNION_H_INCLUDE #include <iostream> #include <iomanip> #include <kvs/Math> #include <kvs/Assert> #include <kvs/Vector4> #include <kvs/Matrix33> #include <kvs/Matrix44> #include <kvs/Deprecated> namespace kvs { /*===========================================================================*/ /** * @brief Quaternion class. */ /*===========================================================================*/ class Quaternion { private: // Quaternion: Q = w + xi + yj + zk // x = m_elements[0], // y = m_elements[1], // z = m_elements[2], // w = m_elements[3] kvs::Vec4 m_elements; ///< elements of quaternion public: static const Quaternion Zero(); static const Quaternion Identity(); static const kvs::Vec3 Rotate( const kvs::Vec3& pos, const kvs::Vec3& axis, float rad ); static const kvs::Vec3 Rotate( const kvs::Vec3& pos, const Quaternion& q ); static const Quaternion RotationQuaternion( kvs::Vec3 v0, kvs::Vec3 v1 ); static const Quaternion LinearInterpolation( const Quaternion& q1, const Quaternion& q2, double t, bool for_rotation ); static const Quaternion SphericalLinearInterpolation( const Quaternion& q1, const Quaternion& q2, double t, bool invert, bool for_rotation ); static const Quaternion SphericalCubicInterpolation( const Quaternion& q1, const Quaternion& q2, const Quaternion& a, const Quaternion& b, double t, bool for_rotation ); static const Quaternion SplineInterpolation( const Quaternion& q1, const Quaternion& q2, const Quaternion& q3, const Quaternion& q4, double t, bool for_rotation ); static const Quaternion Spline( const Quaternion& qnm1, const Quaternion& qn, const Quaternion& qnp1 ); public: Quaternion(); Quaternion( float x, float y, float z, float w ); Quaternion( const kvs::Vec3& axis, float angle ); explicit Quaternion( const kvs::Mat3& mat ); explicit Quaternion( const float elements[4] ); public: void set( float x, float y, float z, float w ) { m_elements.set( x, y, z, w ); } float& x() { return m_elements[0]; } float& y() { return m_elements[1]; } float& z() { return m_elements[2]; } float& w() { return m_elements[3]; } float x() const { return m_elements[0]; } float y() const { return m_elements[1]; } float z() const { return m_elements[2]; } float w() const { return m_elements[3]; } void zero() { *this = Zero(); } void identity() { *this = Identity(); } void conjugate(); void normalize(); void invert(); Quaternion conjugated() const; Quaternion normalized() const; Quaternion inverted() const; Quaternion log() const; Quaternion exp() const; double dot( const Quaternion& q ) const { return m_elements.dot( q.m_elements ); } double length() const { return m_elements.length(); } double squaredLength() const { return m_elements.squaredLength(); } void toMatrix( kvs::Mat3& m ) const; void toMatrix( kvs::Mat4& m ) const; void toMatrix( float m[16] ) const; kvs::Mat3 toMatrix() const; kvs::Vec3 axis() const; float angle() const; public: float& operator [] ( size_t index ) { return m_elements[ index ]; } const float& operator [] ( size_t index ) const { return m_elements[ index ]; } Quaternion& operator += ( const Quaternion& q ) { m_elements += q.m_elements; return *this; } Quaternion& operator -= ( const Quaternion& q ) { m_elements -= q.m_elements; return *this; } Quaternion& operator *= ( float a ) { m_elements *= a; return *this; } Quaternion& operator /= ( float a ) { m_elements /= a; return *this; } Quaternion& operator *= ( const Quaternion& q ) { float x = this->x(); float y = this->y(); float z = this->z(); float w = this->w(); this->set( w * q.x() + x * q.w() + y * q.z() - z * q.y(), w * q.y() - x * q.z() + y * q.w() + z * q.x(), w * q.z() + x * q.y() - y * q.x() + z * q.w(), w * q.w() - x * q.x() - y * q.y() - z * q.z() ); return *this; } friend bool operator == ( const Quaternion& a, const Quaternion& b ) { return a.m_elements == b.m_elements; } friend bool operator != ( const Quaternion& a, const Quaternion& b ) { return !( a == b ); } friend Quaternion operator - ( const Quaternion& a ) { return Quaternion( -a[0], -a[1], -a[2], -a[3] ); } friend Quaternion operator + ( const Quaternion& a, const Quaternion& b ) { return Quaternion( a ) += b; } friend Quaternion operator - ( const Quaternion& a, const Quaternion& b ) { return Quaternion( a ) -= b; } friend Quaternion operator * ( const Quaternion& q, float s ) { return Quaternion( q ) *= s; } friend Quaternion operator * ( float s, const Quaternion& q ) { return Quaternion( q ) *= s; } friend Quaternion operator / ( const Quaternion& q, float s ) { return Quaternion( q ) /= s; } friend Quaternion operator * ( const Quaternion& a, const Quaternion& b ) { return Quaternion( a ) *= b; } friend std::ostream& operator << ( std::ostream& os, const Quaternion& q ) { const size_t width = 8; const size_t precision = 3; const std::ios_base::fmtflags original_flags( os.flags() ); os.setf( std::ios::fixed ); os.setf( std::ios::showpoint ); os << std::setw(width) << std::setprecision(precision) << q.w() << " + "; os << std::setw(width) << std::setprecision(precision) << q.x() << " i + "; os << std::setw(width) << std::setprecision(precision) << q.y() << " j + "; os << std::setw(width) << std::setprecision(precision) << q.z() << " k"; os.flags( original_flags ); return os; } public: KVS_DEPRECATED( static Vector3<float> rotate( const kvs::Vec3& pos, const kvs::Vec3& axis, float rad ) ) { return Quaternion::Rotate( pos, axis, rad ); } KVS_DEPRECATED( static Vector3<float> rotate( const kvs::Vec3& pos, const Quaternion& q ) ) { return Quaternion::Rotate( pos, q ); } KVS_DEPRECATED( static Quaternion rotationQuaternion( kvs::Vec3 v0, kvs::Vec3 v1 ) ) { return Quaternion::RotationQuaternion( v0, v1 ); } KVS_DEPRECATED( static Quaternion linearInterpolation( const Quaternion& q1, const Quaternion& q2, double t, bool for_rotation ) ) { return Quaternion::LinearInterpolation( q1, q2, t, for_rotation ); } KVS_DEPRECATED( static Quaternion sphericalLinearInterpolation( const Quaternion& q1, const Quaternion& q2, double t, bool invert, bool for_rotation ) ) { return Quaternion::SphericalLinearInterpolation( q1, q2, t, invert, for_rotation ); } KVS_DEPRECATED( static Quaternion sphericalCubicInterpolation( const Quaternion& q1, const Quaternion& q2, const Quaternion& a, const Quaternion& b, double t, bool for_rotation ) ) { return Quaternion::SphericalCubicInterpolation( q1, q2, a, b, t, for_rotation ); } KVS_DEPRECATED( static Quaternion splineInterpolation( const Quaternion& q1, const Quaternion& q2, const Quaternion& q3, const Quaternion& q4, double t, bool for_rotation ) ) { return Quaternion::SplineInterpolation( q1, q2, q3, q4, t, for_rotation ); } KVS_DEPRECATED( static Quaternion spline( const Quaternion& qnm1, const Quaternion& qn, const Quaternion& qnp1 ) ) { return Quaternion::Spline( qnm1, qn, qnp1 ); } KVS_DEPRECATED( double length2() const ) { return this->squaredLength(); } }; /*===========================================================================*/ /** * @brief Constructs a new Quaternion class. */ /*===========================================================================*/ inline Quaternion::Quaternion(): m_elements( 0, 0, 0, 0 ) { } /*===========================================================================*/ /** * @brief Constructs a new Quaternion class. * @param x [in] element of i-term * @param y [in] element of j-term * @param z [in] element of k-term * @param w [in] real number */ /*===========================================================================*/ inline Quaternion::Quaternion( float x, float y, float z, float w ): m_elements( x, y, z, w ) { } /*===========================================================================*/ /** * @brief Constructs a new Quaternion class. * @param axis [in] rotation axis * @param angle [in] rotation angle */ /*===========================================================================*/ inline Quaternion::Quaternion( const kvs::Vector3<float>& axis, float angle ) { float s = static_cast<float>( std::sin( angle * 0.5 ) ); float w = static_cast<float>( std::cos( angle * 0.5 ) ); kvs::Vec3 n = axis.normalized(); kvs::Vec3 v = s * n; m_elements.set( v, w ); } /*===========================================================================*/ /** * @brief Constructs a new Quaternion class. * @param m [in] rotation matrix */ /*===========================================================================*/ inline Quaternion::Quaternion( const kvs::Matrix33<float>& m ) { double trace = double( m.trace() + 1.0 ); float x, y, z, w; if ( trace >= 1.0 ) { double sqrt_trace = std::sqrt( trace ); x = float( ( m[1][2] - m[2][1] ) * 0.5 / sqrt_trace ); y = float( ( m[2][0] - m[0][2] ) * 0.5 / sqrt_trace ); z = float( ( m[0][1] - m[1][0] ) * 0.5 / sqrt_trace ); w = float( sqrt_trace * 0.5 ); } else { if ( m[0][0] > m[1][1] && m[0][0] > m[2][2] ) { x = float( std::sqrt( double( m[0][0] - m[1][1] - m[2][2] ) + 1.0 ) * 0.5 ); y = float( ( m[0][1] + m[1][0] ) * 0.25 / x ); z = float( ( m[0][2] + m[2][0] ) * 0.25 / x ); w = float( ( m[1][2] + m[2][1] ) * 0.25 / x ); } else if ( m[1][1] > m[2][2] ) { y = float( std::sqrt( double( m[1][1] - m[2][2] - m[0][0] ) + 1.0 ) * 0.5 ); z = float( ( m[1][2] + m[2][1] ) * 0.25 / y ); x = float( ( m[1][0] + m[0][1] ) * 0.25 / y ); w = float( ( m[2][0] + m[0][2] ) * 0.25 / y ); } else { z = float( std::sqrt( double( m[2][2] - m[0][0] - m[1][1] ) + 1.0 ) * 0.5 ); x = float( ( m[2][0] + m[0][2] ) * 0.25 / z ); y = float( ( m[2][1] + m[1][2] ) * 0.25 / z ); w = float( ( m[0][1] + m[1][0] ) * 0.25 / z ); } } m_elements.set( x, y, z, w ); } /*===========================================================================*/ /** * @brief Constructs a new Quaternion class. * @param elements [in] elements of rotation matrix */ /*===========================================================================*/ inline Quaternion::Quaternion( const float elements[4] ) : m_elements( elements ) { } /*===========================================================================*/ /** * @brief Conjugates the quaternion. */ /*===========================================================================*/ inline void Quaternion::conjugate() { m_elements[0] *= -1.0f; m_elements[1] *= -1.0f; m_elements[2] *= -1.0f; } /*===========================================================================*/ /** * @brief Normalizes the quaternion. */ /*===========================================================================*/ inline void Quaternion::normalize() { float n = static_cast<float>( this->length() ); if ( n > 0 ) { m_elements /= n; } } /*===========================================================================*/ /** * @brief Inverts the quaternion. */ /*===========================================================================*/ inline void Quaternion::invert() { float n = static_cast<float>( this->squaredLength() ); if ( n > 0 ) { this->conjugate(); m_elements /= n; } } /*===========================================================================*/ /** * @brief Returns conjugated quaternion. * @return conjugated quaternion */ /*===========================================================================*/ inline Quaternion Quaternion::conjugated() const { Quaternion result( *this ); result.conjugate(); return result; } /*===========================================================================*/ /** * @brief Returns normalized quaternion. * @return normalized quaternion */ /*===========================================================================*/ inline Quaternion Quaternion::normalized() const { Quaternion result( *this ); result.normalize(); return result; } /*===========================================================================*/ /** * @brief Returns inverted quaternion. * @return inverted quaternion */ /*===========================================================================*/ inline Quaternion Quaternion::inverted() const { Quaternion result( *this ); result.invert(); return result; } /*===========================================================================*/ /** * @brief Returns logarithm of quaternion. * @return logarithm of quaternion */ /*===========================================================================*/ inline Quaternion Quaternion::log() const { Quaternion result( *this ); double theta = std::acos( double( result.w() ) ); double sin_theta = std::sin( theta ); if ( sin_theta > 0 ) { result.x() = float( theta * result.x() / sin_theta ); result.y() = float( theta * result.y() / sin_theta ); result.z() = float( theta * result.z() / sin_theta ); result.w() = 0; } else { result.x() = 0; result.y() = 0; result.z() = 0; result.w() = 0; } return result; } /*===========================================================================*/ /** * @brief Returns exponential of quaternion. * @return exponential of quaternion */ /*===========================================================================*/ inline Quaternion Quaternion::exp() const { Quaternion result( *this ); double theta2 = m_elements.xyz().squaredLength(); double theta = std::sqrt( theta2 ); double cos_theta = std::cos( theta ); if ( theta > 0 ) { double sin_theta = std::sin( theta ); result.x() = float( sin_theta * result.x() / theta ); result.y() = float( sin_theta * result.y() / theta ); result.z() = float( sin_theta * result.z() / theta ); result.w() = float( cos_theta ); } else { result.x() = 0; result.y() = 0; result.z() = 0; result.w() = float( cos_theta ); } return *this; } /*===========================================================================*/ /** * @brief Calculates 3x3 matrix of the quaternion. * @param m [in/out] 3x3 matrix */ /*===========================================================================*/ inline void Quaternion::toMatrix( kvs::Mat3& m ) const { float length_2 = static_cast<float>( this->squaredLength() ); float s = ( length_2 > 0 ) ? float(2) / length_2 : 0; float xx = this->x() * this->x() * s; float yy = this->y() * this->y() * s; float zz = this->z() * this->z() * s; float xy = this->x() * this->y() * s; float xz = this->x() * this->z() * s; float yz = this->y() * this->z() * s; float wx = this->w() * this->x() * s; float wy = this->w() * this->y() * s; float wz = this->w() * this->z() * s; m[0][0] = 1.0f - ( yy + zz ); m[1][0] = xy + wz; m[2][0] = xz - wy; m[0][1] = xy - wz; m[1][1] = 1.0f - ( xx + zz ); m[2][1] = yz + wx; m[0][2] = xz + wy; m[1][2] = yz - wx; m[2][2] = 1.0f - ( xx + yy ); } /*===========================================================================*/ /** * @brief Calculates 4x4 matrix of the quaternion. * @param m [in/out] 4x4 matrix */ /*===========================================================================*/ inline void Quaternion::toMatrix( kvs::Mat4& m ) const { float length_2 = static_cast<float>( this->squaredLength() ); float s = ( length_2 > float(0) ) ? float(2) / length_2 : float(0); float xx = this->x() * this->x() * s; float yy = this->y() * this->y() * s; float zz = this->z() * this->z() * s; float xy = this->x() * this->y() * s; float xz = this->x() * this->z() * s; float yz = this->y() * this->z() * s; float wx = this->w() * this->x() * s; float wy = this->w() * this->y() * s; float wz = this->w() * this->z() * s; m[0][0] = 1.0f - ( yy + zz ); m[1][0] = xy + wz; m[2][0] = xz - wy; m[3][0] = 0.0f; m[0][1] = xy - wz; m[1][1] = 1.0f - ( xx + zz ); m[2][1] = yz + wx; m[3][1] = 0.0f; m[0][2] = xz + wy; m[1][2] = yz - wx; m[2][2] = 1.0f - ( xx + yy ); m[3][2] = 0.0f; m[0][3] = 0.0f; m[1][3] = 0.0f; m[2][3] = 0.0f; m[3][3] = 1.0f; } /*===========================================================================*/ /** * @brief Calculates 4x4 matrix of the quaternion. * @param m [in/out] 4x4 matrix */ /*===========================================================================*/ inline void Quaternion::toMatrix( float m[16] ) const { float length_2 = static_cast<float>( this->squaredLength() ); float s = ( length_2 > 0 ) ? float(2) / length_2 : float(0); float xx = this->x() * this->x() * s; float yy = this->y() * this->y() * s; float zz = this->z() * this->z() * s; float xy = this->x() * this->y() * s; float xz = this->x() * this->z() * s; float yz = this->y() * this->z() * s; float wx = this->w() * this->x() * s; float wy = this->w() * this->y() * s; float wz = this->w() * this->z() * s; m[0] = 1.0f - ( yy + zz ); m[1] = xy + wz; m[2] = xz - wy; m[3] = 0.0f; m[4] = xy - wz; m[5] = 1.0f - ( xx + zz ); m[6] = yz + wx; m[7] = 0.0f; m[8] = xz + wy; m[9] = yz - wx; m[10] = 1.0f - ( xx + yy ); m[11] = 0.0f; m[12] = 0.0f; m[13] = 0.0f; m[14] = 0.0f; m[15] = 1.0f; } /*===========================================================================*/ /** * @brief Returns 3x3 matrix of the quaternion. * @return 3x3 matrix */ /*===========================================================================*/ inline kvs::Mat3 Quaternion::toMatrix() const { kvs::Mat3 result; this->toMatrix( result ); return result; } /*===========================================================================*/ /** * @brief Returns rotation axis. * @return rotation axis */ /*===========================================================================*/ inline kvs::Vec3 Quaternion::axis() const { float s = float( std::sin( double( this->angle() ) * 0.5 ) ); return m_elements.xyz() / s; } /*===========================================================================*/ /** * @brief Returns rotation angle. * @return rotation angle */ /*===========================================================================*/ inline float Quaternion::angle() const { return float( std::acos( double( this->w() ) ) * 2.0 ); } } // end of namespace kvs #endif // KVS__QUATERNION_H_INCLUDE
29.924556
173
0.454793
189f6afa0b0ddb7e049ca7f4444c6521cba13442
1,471
h
C
user.h
Subangkar/xv6-Socket-API-Local-Loopback-Implementation
496f273d68cac3f9b8dcf69d114c961843a3c305
[ "MIT-0" ]
1
2020-04-09T05:30:30.000Z
2020-04-09T05:30:30.000Z
user.h
Subangkar/xv6-Socket-API-Local-Loopback-Implementation
496f273d68cac3f9b8dcf69d114c961843a3c305
[ "MIT-0" ]
null
null
null
user.h
Subangkar/xv6-Socket-API-Local-Loopback-Implementation
496f273d68cac3f9b8dcf69d114c961843a3c305
[ "MIT-0" ]
null
null
null
struct stat; struct rtcdate; // system calls int fork(void); int exit(void) __attribute__((noreturn)); int wait(void); int pipe(int*); int write(int, const void*, int); int read(int, void*, int); int close(int); int kill(int); int exec(char*, char**); int open(const char*, int); int mknod(const char*, short, short); int unlink(const char*); int fstat(int fd, struct stat*); int link(const char*, const char*); int mkdir(const char*); int chdir(const char*); int dup(int); int getpid(void); char* sbrk(int); int sleep(int); int uptime(void); /// opens socket @ local-port and enables a local port to be connected from any remote socket /// local-port int listen(int); /// connects to the remote port @ host is listening /// 1:remote-port, 2:host int connect(int, const char* host); /// 1:local-port, 2:buffer, 3:size-of-buffer int send(int, const char*, int); /// 1:local-port, 2:buffer, 3:size-of-buffer int recv(int, char*, int); /// disconnects from the remote port and closes the socket @ local-port /// local-port int disconnect(int); // ulib.c int stat(const char*, struct stat*); char* strcpy(char*, const char*); void *memmove(void*, const void*, int); char* strchr(const char*, char c); int strcmp(const char*, const char*); void printf(int, const char*, ...); char* gets(char*, int max); uint strlen(const char*); void* memset(void*, int, uint); void* malloc(uint); void free(void*); int atoi(const char*); // console macro #define stdin 0 #define stdout 1
25.807018
93
0.693406
bbbe54abdd627775c15dd74dba9947d49d58d3f3
3,788
h
C
libsqlite3-sys/sqlite3/wasm32-unknown-unknown-libc-stub/libc_stub.h
jnetterf/rusqlite
79e4dfeed4e820c9fc0623dc746505ce8d431146
[ "MIT" ]
null
null
null
libsqlite3-sys/sqlite3/wasm32-unknown-unknown-libc-stub/libc_stub.h
jnetterf/rusqlite
79e4dfeed4e820c9fc0623dc746505ce8d431146
[ "MIT" ]
null
null
null
libsqlite3-sys/sqlite3/wasm32-unknown-unknown-libc-stub/libc_stub.h
jnetterf/rusqlite
79e4dfeed4e820c9fc0623dc746505ce8d431146
[ "MIT" ]
null
null
null
/** * This is a subset of libc required to build sqlite. * All implementations taken from musl. * * Copyright © 2005-2020 Rich Felker, et al. * Modifications copyright © 2020 Joshua Netterfield. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #pragma once typedef __UINT32_TYPE__ uint32_t; typedef __UINT64_TYPE__ uint64_t; typedef __UINTPTR_TYPE__ uintptr_t; typedef unsigned long size_t; /* ---- stdlib ---- */ // We're going to use Rust's allocator. void *rusqlite_wasm32_unknown_unknown_malloc (unsigned long size); void rusqlite_wasm32_unknown_unknown_free(void *mem); void *rusqlite_wasm32_unknown_unknown_realloc(void *, unsigned long); #define malloc(x) rusqlite_wasm32_unknown_unknown_malloc(x) #define free(x) rusqlite_wasm32_unknown_unknown_free(x) #define realloc(x,y) rusqlite_wasm32_unknown_unknown_realloc(x,y) /* ---- assert ---- */ #define assert(expr) ((void) (0)) /* ---- string ---- */ #define memcpy(x, y, z) rusqlite_wasm32_unknown_unknown_memcpy(x, y, z); void *rusqlite_wasm32_unknown_unknown_memcpy(void *restrict dest, const void *restrict src, size_t n); #define memset(x, y, z) rusqlite_wasm32_unknown_unknown_memset(x, y, z) void *rusqlite_wasm32_unknown_unknown_memset(void *dest, int c, size_t n); #define memmove(x, y, z) rusqlite_wasm32_unknown_unknown_memmove(x, y, z) void *rusqlite_wasm32_unknown_unknown_memmove(void *dest, const void *src, size_t n); #define strcmp(x, y) rusqlite_wasm32_unknown_unknown_strcmp(x, y) int rusqlite_wasm32_unknown_unknown_strcmp(const char *l, const char *r); #define strncmp(x, y, z) rusqlite_wasm32_unknown_unknown_strncmp(x, y, z) int rusqlite_wasm32_unknown_unknown_strncmp(const char *_l, const char *_r, size_t n); #define memcmp(x, y, z) rusqlite_wasm32_unknown_unknown_memcmp(x, y, z) int rusqlite_wasm32_unknown_unknown_memcmp(const void *vl, const void *vr, size_t n); #define strlen(x) rusqlite_wasm32_unknown_unknown_strlen(x) size_t rusqlite_wasm32_unknown_unknown_strlen(const char *s); #define strrchr(x, y) rusqlite_wasm32_unknown_unknown_strrchr(x, y) char *rusqlite_wasm32_unknown_unknown_strrchr(const char *s, int c); #define strcspn(x, y) rusqlite_wasm32_unknown_unknown_strcspn(x, y) size_t rusqlite_wasm32_unknown_unknown_strcspn(const char *s, const char *c); /* ---- math ---- */ // We'll use rust's version. #define log(x) rusqlite_wasm32_unknown_unknown_log(x) double rusqlite_wasm32_unknown_unknown_log(double x); /* ---- qsort ---- */ #define qsort(w, x, y, z) rusqlite_wasm32_unknown_unknown_qsort(w, x, y, z) typedef int (*rusqlite_wasm32_unknown_unknown_cmpfun)(const void *, const void *); void rusqlite_wasm32_unknown_unknown_qsort(void *base, size_t nel, size_t width, rusqlite_wasm32_unknown_unknown_cmpfun cmp);
37.88
125
0.774815
f4fc4dba13d75c4844c8753456127710f4ec3b23
1,557
h
C
chromeos/network/network_cert_migrator.h
kjthegod/chromium
cf940f7f418436b77e15b1ea23e6fa100ca1c91a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
1
2019-11-28T10:46:52.000Z
2019-11-28T10:46:52.000Z
chromeos/network/network_cert_migrator.h
kjthegod/chromium
cf940f7f418436b77e15b1ea23e6fa100ca1c91a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
null
null
null
chromeos/network/network_cert_migrator.h
kjthegod/chromium
cf940f7f418436b77e15b1ea23e6fa100ca1c91a
[ "BSD-3-Clause-No-Nuclear-License-2014", "BSD-3-Clause" ]
2
2015-03-27T11:15:39.000Z
2016-08-17T14:19:56.000Z
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROMEOS_NETWORK_NETWORK_CERT_MIGRATOR_H_ #define CHROMEOS_NETWORK_NETWORK_CERT_MIGRATOR_H_ #include "base/basictypes.h" #include "base/memory/weak_ptr.h" #include "chromeos/cert_loader.h" #include "chromeos/chromeos_export.h" #include "chromeos/network/network_state_handler_observer.h" namespace chromeos { class NetworkStateHandler; // Migrates network configurations with incorrect or missing slot IDs of client // certificates. class CHROMEOS_EXPORT NetworkCertMigrator : public NetworkStateHandlerObserver, public CertLoader::Observer { public: ~NetworkCertMigrator() override; private: friend class NetworkHandler; friend class NetworkCertMigratorTest; class MigrationTask; NetworkCertMigrator(); void Init(NetworkStateHandler* network_state_handler); // NetworkStateHandlerObserver overrides void NetworkListChanged() override; // CertLoader::Observer overrides void OnCertificatesLoaded(const net::CertificateList& cert_list, bool initial_load) override; // Unowned associated NetworkStateHandler* (global or test instance). NetworkStateHandler* network_state_handler_; base::WeakPtrFactory<NetworkCertMigrator> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(NetworkCertMigrator); }; } // namespace chromeos #endif // CHROMEOS_NETWORK_NETWORK_CERT_MIGRATOR_H_
30.529412
79
0.775209
6364917bb6c311d9cd7b1a2608fdeab0cebc266b
3,668
h
C
CodeaTemplate/Codify/PhysicsManager.h
tesch1/Codea-Runtime
35d1905fd229cf86a7779d617f446437e2e468ae
[ "Apache-2.0" ]
57
2015-01-08T10:11:18.000Z
2022-02-26T19:16:46.000Z
CodeaTemplate/Codify/PhysicsManager.h
tesch1/Codea-Runtime
35d1905fd229cf86a7779d617f446437e2e468ae
[ "Apache-2.0" ]
null
null
null
CodeaTemplate/Codify/PhysicsManager.h
tesch1/Codea-Runtime
35d1905fd229cf86a7779d617f446437e2e468ae
[ "Apache-2.0" ]
10
2015-01-08T06:29:38.000Z
2021-08-07T08:41:01.000Z
// // PhysicsManager.h // Codea // // Created by JtM on 30/10/11. // // Copyright 2012 Two Lives Left Pty. Ltd. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #import <Foundation/Foundation.h> #include <Box2d.h> #include <vector> #include <algorithm> #define INV_PTM_RATIO 1.0f/PTM_RATIO #define DEFAULT_WORLD_GRAVITY_X 0 #define DEFAULT_WORLD_GRAVITY_Y -9.8f struct lua_State; typedef enum BodyType { BODY_STATIC = 0, BODY_KINEMATIC, BODY_DYNAMIC } BodyType; const int kMaxContactPoints = 2048; typedef enum ContactState { CONTACT_BEGAN=0, CONTACT_PERSIST, CONTACT_ENDED } ContactState; struct ContactPoint { int ref; int ID; bool touching; b2Fixture* fixtureA; b2Fixture* fixtureB; int childIndexA; int childIndexB; b2Vec2 normal; b2Vec2 position; float normalImpulse; float tangentImpulse; b2Vec2 points[b2_maxManifoldPoints]; float normalImpulses[b2_maxManifoldPoints]; float tangentImpulses[b2_maxManifoldPoints]; int pointCount; ContactState state; bool operator==(const ContactPoint& other) const { return (fixtureA == other.fixtureA) && (fixtureB == other.fixtureB) && (childIndexA == other.childIndexA) && (childIndexB == other.childIndexB); } }; class ContactListener : public b2ContactListener { public: virtual void BeginContact(b2Contact* contact); virtual void EndContact(b2Contact* contact); virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold); virtual void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse); std::vector<ContactPoint> contacts; int currentID; }; class DestructionListener : public b2DestructionListener { virtual void SayGoodbye(b2Joint* joint); virtual void SayGoodbye(b2Fixture* fixture) {} }; @interface PhysicsManager : NSObject { b2World* world; ContactListener* contactListener; DestructionListener* destructionListener; int velocityIterations; int positionIterations; BOOL paused; float timeStep; float invTimeStep; float accum; float alpha; } @property(nonatomic, readonly) b2World* world; @property(nonatomic, readonly) float alpha; @property(nonatomic, readonly) float timeStep; @property(nonatomic, readonly) float invTimeStep; @property(nonatomic, assign) float pixelToMeterRatio; -(void) step:(float)dt; -(BOOL) processContacts:(lua_State*)L; -(void) reset; -(void) setVelocityIterations:(int)velIter positionIterations:(int)posIter; -(void) setPaused:(BOOL)p; -(b2Body*) createCircle:(float)x y:(float)y radius:(float)radius; -(b2Body*) createPolygon:(CGPoint)position x:(float*)x y:(float*)y numPoints:(int)numPoints; -(b2Body*) createChain:(CGPoint)position x:(float*)x y:(float*)y numPoints:(int)numPoints loop:(BOOL)loop; -(b2Body*) createEdge:(CGPoint)position pointA:(CGPoint)pointA pointB:(CGPoint)pointB; -(void) destroyBody:(b2Body*)body; -(b2Joint*) createJoint:(b2JointType)type bodyA:(b2Body*)bodyA bodyB:(b2Body*)bodyB anchorA:(b2Vec2)anchorA anchorB:(b2Vec2)anchorB maxLength:(float)maxLength; -(void) destroyJoint:(b2Joint*)joint; @end
27.17037
159
0.732279
4982c388dd06cccbdd15f6f131fdcfc1367dd5a8
1,046
h
C
Engine/Src/SFEngine/Graphics/Vulkan/SFVulkanTexture.h
blue3k/StormForge
1557e699a673ae9adcc8f987868139f601ec0887
[ "Apache-2.0" ]
1
2020-06-20T07:35:25.000Z
2020-06-20T07:35:25.000Z
Engine/Src/SFEngine/Graphics/Vulkan/SFVulkanTexture.h
blue3k/StormForge
1557e699a673ae9adcc8f987868139f601ec0887
[ "Apache-2.0" ]
null
null
null
Engine/Src/SFEngine/Graphics/Vulkan/SFVulkanTexture.h
blue3k/StormForge
1557e699a673ae9adcc8f987868139f601ec0887
[ "Apache-2.0" ]
null
null
null
//////////////////////////////////////////////////////////////////////////////// // // CopyRight (c) 2016 Kyungkun Ko // // Author : KyungKun Ko // // Description : Vulkan texture // //////////////////////////////////////////////////////////////////////////////// #pragma once #if HAVE_VULKAN #include "Resource/SFDeviceTexture.h" #include "Graphics/Vulkan/SFVulkanSystem.h" namespace SF { //////////////////////////////////////////////////////////////////// // // Resource // class VulkanTexture : public DeviceTexture { public: private: //VkImage m_VKImage; //VkDeviceMemory m_VKMemory; VkImageView m_VKView; public: VulkanTexture(IHeap& heap, GraphicDevice* pDevice, Texture* sourceResource); virtual ~VulkanTexture(); VkImageView GetDeviceImage() { return m_VKView; } virtual void Dispose() override; }; typedef SharedPointerT<VulkanTexture> VulkanTexturePtr; extern template class SharedPointerT<VulkanTexture>; } #endif //#if HAVE_VULKAN
18.678571
81
0.525813
6f3e138094ba9eecf3c3d49b56527a4117ba014f
80
h
C
shared/ios/Pods/Headers/Private/yoga/instrumentation.h
yan0908/client
2debd54aa01e01f91cb5ef81104b1932a5cd681f
[ "BSD-3-Clause" ]
401
2019-09-05T04:20:57.000Z
2022-01-18T02:52:40.000Z
shared/ios/Pods/Headers/Private/yoga/instrumentation.h
joergpanke/client
e310b28b4e58987ffb1228650d35e07b9a379669
[ "BSD-3-Clause" ]
94
2019-10-04T19:34:42.000Z
2021-08-03T13:23:17.000Z
shared/ios/Pods/Headers/Private/yoga/instrumentation.h
joergpanke/client
e310b28b4e58987ffb1228650d35e07b9a379669
[ "BSD-3-Clause" ]
71
2016-10-19T09:57:21.000Z
2022-01-24T21:37:40.000Z
../../../../../node_modules/react-native/ReactCommon/yoga/yoga/instrumentation.h
80
80
0.725
6f93ece947b59bc9d9c7a78395b7fa18abba1664
612
h
C
Source/FSD/Public/UsableAggregator.h
Dr-Turtle/DRG_ModPresetManager
abd7ff98a820969504491a1fe68cf2f9302410dc
[ "MIT" ]
8
2021-07-10T20:06:05.000Z
2022-03-04T19:03:50.000Z
Source/FSD/Public/UsableAggregator.h
Dr-Turtle/DRG_ModPresetManager
abd7ff98a820969504491a1fe68cf2f9302410dc
[ "MIT" ]
9
2022-01-13T20:49:44.000Z
2022-03-27T22:56:48.000Z
Source/FSD/Public/UsableAggregator.h
Dr-Turtle/DRG_ModPresetManager
abd7ff98a820969504491a1fe68cf2f9302410dc
[ "MIT" ]
2
2021-07-10T20:05:42.000Z
2022-03-14T17:05:35.000Z
#pragma once #include "CoreMinimal.h" #include "ItemAggregator.h" #include "UsableAggregator.generated.h" UDELEGATE(BlueprintCallable) DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FUsableAggregatorOnVisibilityChanged, bool, IsVisible); UCLASS() class UUsableAggregator : public UItemAggregator { GENERATED_BODY() public: UPROPERTY(BlueprintAssignable) FUsableAggregatorOnVisibilityChanged OnVisibilityChanged; protected: UPROPERTY(BlueprintReadOnly, EditAnywhere) FText UsingText; public: UFUNCTION(BlueprintCallable) float GetProgress(); UUsableAggregator(); };
23.538462
128
0.784314
6fdc7ea86ce657b65126c93787791e13fd8acae4
6,760
h
C
src/IOREG.h
benghaem/avremu
0741984c40c6918141e844018992e1eeb5945a34
[ "MIT" ]
1
2017-08-15T18:13:15.000Z
2017-08-15T18:13:15.000Z
src/IOREG.h
benghaem/avremu
0741984c40c6918141e844018992e1eeb5945a34
[ "MIT" ]
5
2016-07-14T07:02:05.000Z
2016-08-25T05:21:05.000Z
src/IOREG.h
benghaem/avremu
0741984c40c6918141e844018992e1eeb5945a34
[ "MIT" ]
null
null
null
/* ATtiny 25 / 45 / 85 IO Register Names * generated from: http://www.atmel.com/Images/Atmel-2586-AVR-8-bit-Microcontroller-ATtiny25-ATtiny45-ATtiny85_Datasheet.pdf * * Named registers also have named values for their bits * Named bits are shown below as REGISTERNAME_BITNAME */ #ifndef IOREG_H #define IOREG_H #define SREG 0x3F #define SREG_I 7 #define SREG_T 6 #define SREG_H 5 #define SREG_S 4 #define SREG_V 3 #define SREG_N 2 #define SREG_Z 1 #define SREG_C 0 #define SPH 0x3E #define SPH_SP9 1 #define SPH_SP8 0 #define SPL 0x3D #define SPL_SP7 7 #define SPL_SP6 6 #define SPL_SP5 5 #define SPL_SP4 4 #define SPL_SP3 3 #define SPL_SP2 2 #define SPL_SP1 1 #define SPL_SP0 0 #define GIMSK 0x3B #define GIMSK_INT0 6 #define GIMSK_PCIE 5 #define GIFR 0x3A #define GIFR_INTF0 6 #define GIFR_PCIF 5 #define TIMSK 0x39 #define TIMSK_OCIE1A 6 #define TIMSK_OCIE1B 5 #define TIMSK_OCIE0A 4 #define TIMSK_OCIE0B 3 #define TIMSK_TOIE1 2 #define TIMSK_TOIE0 1 #define TIFR 0x38 #define TIFR_OCF1A 6 #define TIFR_OCF1B 5 #define TIFR_OCF0A 4 #define TIFR_OCF0B 3 #define TIFR_TOV1 2 #define TIFR_TOV0 1 #define SPMCSR 0x37 #define SPMCSR_RSIG 5 #define SPMCSR_CTPB 4 #define SPMCSR_RFLB 3 #define SPMCSR_PGWRT 2 #define SPMCSR_PGERS 1 #define SPMCSR_SPMEN 0 #define MCUCR 0x35 #define MCUCR_BODS 7 #define MCUCR_PUD 6 #define MCUCR_SE 5 #define MCUCR_SM1 4 #define MCUCR_SM0 3 #define MCUCR_BODSE 2 #define MCUCR_ISC01 1 #define MCUCR_ISC00 0 #define MCUSR 0x34 #define MCUSR_WDRF 3 #define MCUSR_BORF 2 #define MCUSR_EXTRF 1 #define MCUSR_PORF 0 #define TCCR0B 0x33 #define TCCR0B_FOC0A 7 #define TCCR0B_FOC0B 6 #define TCCR0B_WGM02 3 #define TCCR0B_CS02 2 #define TCCR0B_CS01 1 #define TCCR0B_CS00 0 #define TCNT0 0x32 #define OSCCAL 0x31 #define TCCR1 0x30 #define TCCR1_CTC1 7 #define TCCR1_PWM1A 6 #define TCCR1_COM1A1 5 #define TCCR1_COM1A0 4 #define TCCR1_CS13 3 #define TCCR1_CS12 2 #define TCCR1_CS11 1 #define TCCR1_CS10 0 #define TCNT1 0x2F #define OCR1A 0x2E #define OCR1C 0x2D #define GTCCR 0x2C #define GTCCR_TSM 7 #define GTCCR_PWM1B 6 #define GTCCR_COM1B1 5 #define GTCCR_COM1B0 4 #define GTCCR_FOC1B 3 #define GTCCR_FOC1A 2 #define GTCCR_PSR1 1 #define GTCCR_PSR0 0 #define OCR1B 0x2B #define TCCR0A 0x2A #define TCCR0A_COM0A1 7 #define TCCR0A_COM0A0 6 #define TCCR0A_COM0B1 5 #define TCCR0A_COM0B0 4 #define TCCR0A_WGM01 1 #define TCCR0A_WGM00 0 #define OCR0A 0x29 #define OCR0B 0x28 #define PLLCSR 0x27 #define PLLCSR_LSM 7 #define PLLCSR_PCKE 2 #define PLLCSR_PLLE 1 #define PLLCSR_PLOCK 0 #define CLKPR 0x26 #define CLKPR_CLKPCE 7 #define CLKPR_CLKPS3 3 #define CLKPR_CLKPS2 2 #define CLKPR_CLKPS1 1 #define CLKPR_CLKPS0 0 #define DT1A 0x25 #define DT1A_DT1AH3 7 #define DT1A_DT1AH2 6 #define DT1A_DT1AH1 5 #define DT1A_DT 4 #define DT1A_1AH0 3 #define DT1A_DT1AL3 2 #define DT1A_DT1AL2 1 #define DT1A_DT1AL1 0 #define DT1B 0x24 #define DT1B_DT1BH3 7 #define DT1B_DT1BH2 6 #define DT1B_DT1BH1 5 #define DT1B_DT 4 #define DT1B_1BH0 3 #define DT1B_DT1BL3 2 #define DT1B_DT1BL2 1 #define DT1B_DT1BL1 0 #define DTPS1 0x23 #define DTPS1_DTPS11 1 #define DTPS1_DTPS10 0 #define DWDR 0x22 #define WDTCR 0x21 #define WDTCR_WDIF 7 #define WDTCR_WDIE 6 #define WDTCR_WDP3 5 #define WDTCR_WDCE 4 #define WDTCR_WDE 3 #define WDTCR_WDP2 2 #define WDTCR_WDP1 1 #define WDTCR_WDP0 0 #define PRR 0x20 #define PRR_PRTIM1 3 #define PRR_PRTIM0 2 #define PRR_PRUSI 1 #define PRR_PRADC 0 #define EEARH 0x1F #define EEARH_EEAR8 0 #define EEARL 0x1E #define EEARL_EEAR7 7 #define EEARL_EEAR6 6 #define EEARL_EEAR5 5 #define EEARL_EEAR4 4 #define EEARL_EEAR3 3 #define EEARL_EEAR2 2 #define EEARL_EEAR1 1 #define EEARL_EEAR0 0 #define EEDR 0x1D #define EECR 0x1C #define EECR_EEPM1 5 #define EECR_EEPM0 4 #define EECR_EERIE 3 #define EECR_EEMPE 2 #define EECR_EEPE 1 #define EECR_EERE 0 #define PORTB 0x18 #define PORTB_PORTB5 5 #define PORTB_PORTB4 4 #define PORTB_PORTB3 3 #define PORTB_PORTB2 2 #define PORTB_PORTB1 1 #define PORTB_PORTB0 0 #define DDRB 0x17 #define DDRB_DDB5 5 #define DDRB_DDB4 4 #define DDRB_DDB3 3 #define DDRB_DDB2 2 #define DDRB_DDB1 1 #define DDRB_DDB0 0 #define PINB 0x16 #define PINB_PINB5 5 #define PINB_PINB4 4 #define PINB_PINB3 3 #define PINB_PINB2 2 #define PINB_PINB1 1 #define PINB_PINB0 0 #define PCMSK 0x15 #define PCMSK_PCINT5 5 #define PCMSK_PCINT4 4 #define PCMSK_PCINT3 3 #define PCMSK_PCINT2 2 #define PCMSK_PCINT1 1 #define PCMSK_PCINT0 0 #define DIDR0 0x14 #define DIDR0_ADC0D 5 #define DIDR0_ADC2D 4 #define DIDR0_ADC3D 3 #define DIDR0_ADC1D 2 #define DIDR0_AIN1D 1 #define DIDR0_AIN0D 0 #define GPIOR2 0x13 #define GPIOR1 0x12 #define GPIOR0 0x11 #define USIBR 0x10 #define USIDR 0x0F #define USISR 0x0E #define USISR_USISIF 7 #define USISR_USIOIF 6 #define USISR_USIPF 5 #define USISR_USIDC 4 #define USISR_USICNT3 3 #define USISR_USICNT2 2 #define USISR_USICNT1 1 #define USISR_USICNT0 0 #define USICR 0x0D #define USICR_USISIE 7 #define USICR_USIOIE 6 #define USICR_USIWM1 5 #define USICR_USIWM0 4 #define USICR_USICS1 3 #define USICR_USICS0 2 #define USICR_USICLK 1 #define USICR_USITC 0 #define ACSR 0x08 #define ACSR_ACD 7 #define ACSR_ACBG 6 #define ACSR_ACO 5 #define ACSR_ACI 4 #define ACSR_ACIE 3 #define ACSR_ACIS1 1 #define ACSR_ACIS0 0 #define ADMUX 0x07 #define ADMUX_REFS1 7 #define ADMUX_REFS0 6 #define ADMUX_ADLAR 5 #define ADMUX_REFS2 4 #define ADMUX_MUX3 3 #define ADMUX_MUX2 2 #define ADMUX_MUX1 1 #define ADMUX_MUX0 0 #define ADCSRA 0x06 #define ADCSRA_ADEN 7 #define ADCSRA_ADSC 6 #define ADCSRA_ADATE 5 #define ADCSRA_ADIF 4 #define ADCSRA_ADIE 3 #define ADCSRA_ADPS2 2 #define ADCSRA_ADPS1 1 #define ADCSRA_ADPS0 0 #define ADCH 0x05 #define ADCL 0x04 #define ADCSRB 0x03 #define ADCSRB_BIN 7 #define ADCSRB_ACME 6 #define ADCSRB_IPR 5 #define ADCSRB_ADTS2 2 #define ADCSRB_ADTS1 1 #define ADCSRB_ADTS0 0 #endif /* IOREG.h */
24.671533
124
0.690237
a585219f2f58e62610b77fa5bfd19dddb2aade22
4,706
h
C
util/third_party/emwin/inc/GUI_FontIntern.h
lenloe1/v2.7
9ac9c4a7bb37987af382c80647f42d84db5f2e1d
[ "Zlib" ]
null
null
null
util/third_party/emwin/inc/GUI_FontIntern.h
lenloe1/v2.7
9ac9c4a7bb37987af382c80647f42d84db5f2e1d
[ "Zlib" ]
1
2020-08-25T02:36:22.000Z
2020-08-25T02:36:22.000Z
util/third_party/emwin/inc/GUI_FontIntern.h
lenloe1/v2.7
9ac9c4a7bb37987af382c80647f42d84db5f2e1d
[ "Zlib" ]
1
2020-08-25T01:56:04.000Z
2020-08-25T01:56:04.000Z
/***************************************************************************//** * # License * * The licensor of this software is Silicon Laboratories Inc. Your use of this * software is governed by the terms of Silicon Labs Master Software License * Agreement (MSLA) available at * www.silabs.com/about-us/legal/master-software-license-agreement. This * software is Third Party Software licensed by Silicon Labs from a third party * and is governed by the sections of the MSLA applicable to Third Party * Software and the additional terms set forth below. * ******************************************************************************/ /********************************************************************* * SEGGER Microcontroller GmbH & Co. KG * * Solutions for real time microcontroller applications * ********************************************************************** * * * (c) 1996 - 2016 SEGGER Microcontroller GmbH & Co. KG * * * * Internet: www.segger.com Support: support@segger.com * * * ********************************************************************** ** emWin V5.34 - Graphical user interface for embedded applications ** All Intellectual Property rights in the Software belongs to SEGGER. emWin is protected by international copyright laws. Knowledge of the source code may not be used to write a similar product. This file may only be used in accordance with the following terms: The software has been licensed to Silicon Labs Norway, a subsidiary of Silicon Labs Inc. whose registered office is 400 West Cesar Chavez, Austin, TX 78701, USA solely for the purposes of creating libraries for its ARM Cortex-M3, M4F processor-based devices, sublicensed and distributed under the terms and conditions of the End User License Agreement supplied by Silicon Labs. Full source code is available at: www.segger.com We appreciate your understanding and fairness. ---------------------------------------------------------------------- Licensing information Licensor: SEGGER Software GmbH Licensed to: Silicon Laboratories Norway Licensed SEGGER software: emWin License number: GUI-00140 License model: See Agreement, dated 20th April 2012 Licensed product: - Licensed platform: Cortex M3, Cortex M4F Licensed number of seats: - ---------------------------------------------------------------------- File : GUI_FontIntern.h Purpose : Internal decalrations used in font files ---------------------------END-OF-HEADER------------------------------ Attention : Do not modify this file ! If you do, you will not be able do update to a later GUI version ! */ #ifndef GUI_FONTINTERN_H /* Guard against multiple inclusion */ #define GUI_FONTINTERN_H #include "GUI.h" #if defined(__cplusplus) extern "C" { /* Make sure we have C-declarations in C++ programs */ #endif extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_Font8ASCII_Prop; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_FontF8x13_ASCII_Prop1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_FontF8x15B_ASCII_Prop1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_Font10S_ASCII_FontProp1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_Font10ASCIIProp1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_Font13ASCII_Prop1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_Font13B_ASCII_Prop1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_Font13H_ASCII_Prop1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_Font13HB_ASCII_Prop1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_Font16_1_FontProp1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_Font16ASCIIProp1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_Font16B_ASCII_Prop1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_Font20_ASCII_Prop1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_Font20B_ASCII_Prop1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_Font24_ASCII_Prop1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_Font24B_ASCII_Prop1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_Font32_ASCII_Prop1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_Font32B_ASCII_Prop1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_FontComic18B_ASCII_Prop1; extern GUI_CONST_STORAGE GUI_FONT_PROP GUI_FontComic24B_ASCII_Prop1; extern GUI_CONST_STORAGE GUI_CHARINFO GUI_Font16_HK_CharInfo[169]; #if defined(__cplusplus) } #endif #endif /* Guard against multiple inclusion */ /*************************** End of file ****************************/
46.137255
80
0.646621
a5a7401ee35c22ab372791fffbc47c01a72681a7
717
h
C
include/pin.h
felixonmars/canokey-core
5ed06b835452743356321fba21d07c9a352e5c53
[ "Apache-2.0" ]
135
2019-10-24T06:58:33.000Z
2022-03-25T16:54:01.000Z
include/pin.h
felixonmars/canokey-core
5ed06b835452743356321fba21d07c9a352e5c53
[ "Apache-2.0" ]
10
2020-05-21T10:29:49.000Z
2022-01-22T02:40:14.000Z
include/pin.h
felixonmars/canokey-core
5ed06b835452743356321fba21d07c9a352e5c53
[ "Apache-2.0" ]
22
2019-12-09T10:39:46.000Z
2022-03-19T08:25:52.000Z
/* SPDX-License-Identifier: Apache-2.0 */ #ifndef CANOKEY_CORE_SRC_PIN_H #define CANOKEY_CORE_SRC_PIN_H #include <stdint.h> typedef struct { uint8_t min_length; uint8_t max_length; uint8_t is_validated; char path[]; } pin_t; #define PIN_IO_FAIL -1 #define PIN_AUTH_FAIL -2 #define PIN_LENGTH_INVALID -3 #define PIN_MAX_LENGTH 64 int pin_create(const pin_t *pin, const void *buf, uint8_t len, uint8_t max_retries); int pin_verify(pin_t *pin, const void *buf, uint8_t len, uint8_t *retries); int pin_update(pin_t *pin, const void *buf, uint8_t len); int pin_get_size(const pin_t *pin); int pin_get_retries(const pin_t *pin); int pin_clear(const pin_t *pin); #endif // CANOKEY_CORE_SRC_PIN_H
25.607143
75
0.753138
9d55c5e485530599a1d88d2b2728fb9f984d9f6c
2,184
h
C
Testing-Libraries/GHUnitIOS.framework/Versions/A/Headers/GHTestUtils.h
ubahnverleih/apps-ios-commons
8573fbae5afd4dfd879968879ab5485f3b34b68a
[ "BSD-2-Clause" ]
366
2015-01-01T19:07:57.000Z
2022-03-15T06:13:12.000Z
Testing-Libraries/GHUnitIOS.framework/Versions/A/Headers/GHTestUtils.h
ubahnverleih/apps-ios-commons
8573fbae5afd4dfd879968879ab5485f3b34b68a
[ "BSD-2-Clause" ]
33
2015-03-17T22:35:21.000Z
2020-06-17T20:56:51.000Z
FPPopoverTests/GHUnitIOS.framework/Versions/A/Headers/GHTestUtils.h
isabella232/FPPopover
f6185b9c51d7df6400100c7b02a72dc0107ae440
[ "MIT" ]
65
2015-01-08T05:43:56.000Z
2021-01-26T07:10:50.000Z
// // GHTestUtils.h // GHUnitIOS // // Created by John Boiles on 10/22/12. // Copyright 2012. All rights reserved. // // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation // files (the "Software"), to deal in the Software without // restriction, including without limitation the rights to use, // copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following // conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // OTHER DEALINGS IN THE SOFTWARE. // #import <Foundation/Foundation.h> #define GHRunWhile(__CONDITION__) GHRunUntilTimeoutWhileBlock(10.0, ^BOOL{ return (__CONDITION__); }) /*! Run the main run loop for a period of time. This is useful to give views time to render any asynchronously rendered views. However when possible, GHRunUntilTimeoutWhileBlock should be used instead since it will provide more determinate output. @param interval Interval for the main loop to run */ void GHRunForInterval(CFTimeInterval interval); /*! Keep running the main runloop until whileBlock returns NO or timeout is reached. This is useful for waiting until certain parts of views render. This method should be used instead of putting GHRunForInterval in a while loop. @param timeout Maximum time to run the main loop before giving up @param whileBlock Block that returns YES if the main runloop should keep running */ void GHRunUntilTimeoutWhileBlock(CFTimeInterval timeout, BOOL(^whileBlock)());
42
101
0.763736
8b3e61d35a7d3dda5476e0582c1baeea0228eceb
402
h
C
src/DataStreams/NullBlockOutputStream.h
lizhichao/ClickHouse
3f5dc37095ccca18de490fab162d6e3cb99756aa
[ "Apache-2.0" ]
18
2021-05-29T01:12:33.000Z
2021-11-18T12:34:48.000Z
src/DataStreams/NullBlockOutputStream.h
lizhichao/ClickHouse
3f5dc37095ccca18de490fab162d6e3cb99756aa
[ "Apache-2.0" ]
16
2021-06-07T21:32:30.000Z
2022-03-31T21:08:29.000Z
src/DataStreams/NullBlockOutputStream.h
lizhichao/ClickHouse
3f5dc37095ccca18de490fab162d6e3cb99756aa
[ "Apache-2.0" ]
22
2019-06-14T10:31:51.000Z
2020-10-12T14:57:44.000Z
#pragma once #include <DataStreams/IBlockOutputStream.h> namespace DB { /** Does nothing. Used for debugging and benchmarks. */ class NullBlockOutputStream : public IBlockOutputStream { public: NullBlockOutputStream(const Block & header_) : header(header_) {} Block getHeader() const override { return header; } void write(const Block &) override {} private: Block header; }; }
17.478261
69
0.718905
5b0e1c4cda5719f97d47af301eebd6f9a12424d8
1,597
c
C
src/ringbuf.c
brenns10/libstephen
8c5caa27998fdfdb8591b1999b5d1ce1119a6c40
[ "BSD-3-Clause" ]
24
2015-11-07T09:34:38.000Z
2021-11-04T17:58:25.000Z
src/ringbuf.c
brenns10/libstephen
8c5caa27998fdfdb8591b1999b5d1ce1119a6c40
[ "BSD-3-Clause" ]
20
2015-07-30T20:41:04.000Z
2016-06-13T03:27:57.000Z
src/ringbuf.c
brenns10/libstephen
8c5caa27998fdfdb8591b1999b5d1ce1119a6c40
[ "BSD-3-Clause" ]
3
2018-04-02T11:07:57.000Z
2020-12-06T03:28:28.000Z
#include "libstephen/rb.h" #include <stdlib.h> #include <string.h> void rb_init(smb_rb *rb, int dsize, int init) { rb->dsize = dsize; rb->nalloc = init; rb->start = 0; rb->count = 0; rb->data = calloc(dsize, init); } void rb_destroy(smb_rb *rb) { free(rb->data); } void rb_grow(smb_rb *rb) { int oldalloc = rb->nalloc; rb->nalloc *= 2; rb->data = realloc(rb->data, rb->nalloc * rb->dsize); for (int i = 0; i < rb->count; i++) { int oldindex = (rb->start + i) % oldalloc; int newindex = (rb->start + i) % rb->nalloc; if (oldindex != newindex) { memcpy(rb->data + newindex * rb->dsize, rb->data + oldindex * rb->dsize, rb->nalloc); } } } void rb_push_front(smb_rb *rb, void *src) { if (rb->count >= rb->nalloc) { rb_grow(rb); } // ensure the new start index is still positive int newstart = (rb->start + rb->nalloc - 1) % rb->nalloc; rb->start = newstart; memcpy(rb->data + rb->start * rb->dsize, src, rb->dsize); rb->count++; } void rb_pop_front(smb_rb *rb, void *dst) { int newstart = (rb->start + 1) % rb->nalloc; memcpy(dst, rb->data + rb->start * rb->dsize, rb->dsize); rb->start = newstart; rb->count--; } void rb_push_back(smb_rb *rb, void *src) { if (rb->count >= rb->nalloc) { rb_grow(rb); } int index = (rb->start + rb->count) % rb->nalloc; memcpy(rb->data + index * rb->dsize, src, rb->dsize); rb->count++; } void rb_pop_back(smb_rb *rb, void *dst) { int index = (rb->start + rb->count - 1) % rb->nalloc; memcpy(dst, rb->data + index * rb->dsize, rb->dsize); rb->count--; }
21.581081
59
0.585473
3f8cde78679d93a06bc3698502952280b80dbbea
99
h
C
Core Data Editor/Core Data Editor/CDENSNullToNilTransformer.h
pkh/Core-Data-Editor
9aca149089bad67fbaf5547ce299e968abddc400
[ "BSD-3-Clause" ]
1,025
2015-01-01T11:53:49.000Z
2022-03-17T12:41:10.000Z
Core Data Editor/Core Data Editor/CDENSNullToNilTransformer.h
altimac/Core-Data-Editor
a713160b9e40709baf5717211b0778e390790ea3
[ "BSD-3-Clause" ]
24
2015-02-14T11:51:30.000Z
2021-06-18T10:14:05.000Z
Core Data Editor/Core Data Editor/CDENSNullToNilTransformer.h
altimac/Core-Data-Editor
a713160b9e40709baf5717211b0778e390790ea3
[ "BSD-3-Clause" ]
141
2015-01-06T06:43:58.000Z
2022-01-19T07:31:48.000Z
#import <Foundation/Foundation.h> @interface CDENSNullToNilTransformer : NSValueTransformer @end
16.5
57
0.828283
8b883caeb6c01a8ac2888b3f761c127d33cb2ba0
86,629
h
C
base/ntos/mm/amd64/miamd.h
987432340/wrk-v1.2
423d4c22b892bcc97778385bc0a646ed7a3cfbde
[ "Intel" ]
1
2022-03-12T13:57:18.000Z
2022-03-12T13:57:18.000Z
base/ntos/mm/amd64/miamd.h
987432340/wrk-v1.2
423d4c22b892bcc97778385bc0a646ed7a3cfbde
[ "Intel" ]
null
null
null
base/ntos/mm/amd64/miamd.h
987432340/wrk-v1.2
423d4c22b892bcc97778385bc0a646ed7a3cfbde
[ "Intel" ]
1
2021-11-25T08:18:04.000Z
2021-11-25T08:18:04.000Z
/*++ Copyright (c) Microsoft Corporation. All rights reserved. You may only use this code if you agree to the terms of the Windows Research Kernel Source Code License agreement (see License.txt). If you do not agree to the terms, do not use the code. Module Name: miamd.h Abstract: This module contains the private data structures and procedure prototypes for the hardware dependent portion of the memory management system. This module is specifically tailored for the AMD 64-bit processor. --*/ /*++ Virtual Memory Layout on the AMD64 is: +------------------------------------+ 0000000000000000 | User mode addresses - 8tb minus 64k| | | | | 000007FFFFFEFFFF | | MM_HIGHEST_USER_ADDRESS +------------------------------------+ 000007FFFFFF0000 | 64k No Access Region | MM_USER_PROBE_ADDRESS 000007FFFFFFFFFF | | +------------------------------------+ . +------------------------------------+ FFFF080000000000 | Start of System space | MM_SYSTEM_RANGE_START +------------------------------------+ FFFFF68000000000 | 512gb four level page table map. | PTE_BASE +------------------------------------+ FFFFF70000000000 | HyperSpace - working set lists | HYPER_SPACE | and per process memory management | | structures mapped in this 512gb | | region. | HYPER_SPACE_END +------------------------------------+ MM_WORKING_SET_END FFFFF78000000000 | Shared system page | KI_USER_SHARED_DATA +------------------------------------+ FFFFF78000001000 | The system cache working set | MM_SYSTEM_CACHE_WORKING_SET | information resides in this | | 512gb-4k region. | | | +------------------------------------+ . . Note the ranges below are sign extended for > 43 bits and therefore can be used with interlocked slists. The system address space above is NOT. . . +------------------------------------+ FFFFF80000000000 | | MM_KSEG0_BASE | Mappings initialized by the loader.| MM_KSEG2_BASE +------------------------------------+ FFFFF90000000000 | win32k.sys | | | | Hydra configurations have session | | data structures here. | | | | This is a 512gb region. | +------------------------------------+ | | MM_SYSTEM_SPACE_START FFFFF98000000000 | System cache resides here. | MM_SYSTEM_CACHE_START | Kernel mode access only. | | 1tb. | | | MM_SYSTEM_CACHE_END +------------------------------------+ FFFFFA8000000000 | Start of paged system area. | MM_PAGED_POOL_START | Kernel mode access only. | | 128gb. | +------------------------------------+ | System mapped views start just | | after paged pool. Default is | | 104MB, can be registry-overridden. | | 8GB maximum. | | | +------------------------------------+ FFFFFAA000000000 | System PTE pool. | MM_LOWEST_NONPAGED_SYSTEM_START | Kernel mode access only. | | 128gb. | +------------------------------------+ FFFFFAC000000000 | NonPaged pool. | MM_NON_PAGED_POOL_START | Kernel mode access only. | | 128gb. | | | FFFFFADFFFFFFFFF | NonPaged System area | MM_NONPAGED_POOL_END +------------------------------------+ . . . . +------------------------------------+ FFFFFFFF80000000 | | | Reserved for the HAL. 2gb. | FFFFFFFFFFFFFFFF | | MM_SYSTEM_SPACE_END +------------------------------------+ --*/ #define _MI_PAGING_LEVELS 4 #define _MI_MORE_THAN_4GB_ 1 #define _MI_USE_BIT_INTRINSICS 1 // // Top level PXE mapping allocations: // // 0x0->0xF: 0x10 user entries // 0x1ed: 0x1 for selfmaps // 0x1ee: 0x1 hyperspace entry // 0x1ef: 0x1 entry for syscache WSL & shared user data // 0x1f0->0x1ff: 0x10 kernel entries // // // Define empty list markers. // #define MM_EMPTY_LIST ((ULONG_PTR)-1) // #define MM_EMPTY_PTE_LIST 0xFFFFFFFFUI64 // N.B. tied to MMPTE definition #define MI_PTE_BASE_FOR_LOWEST_KERNEL_ADDRESS (MiGetPteAddress (MM_KSEG0_BASE)) #define MI_PTE_BASE_FOR_LOWEST_SESSION_ADDRESS (MiGetPteAddress (MM_SESSION_SPACE_DEFAULT)) // // This is the size of the region used by the loader. // extern ULONG_PTR MmBootImageSize; // // PAGE_SIZE for AMD64 is 4k, virtual page is 36 bits with a PAGE_SHIFT // byte offset. // #define MM_VIRTUAL_PAGE_FILLER 0 #define MM_VIRTUAL_PAGE_SIZE (64 - 12) // // Address space layout definitions. // #define MM_KSEG2_BASE 0xFFFFF90000000000UI64 #define MM_PAGES_IN_KSEG0 ((MM_KSEG2_BASE - MM_KSEG0_BASE) >> PAGE_SHIFT) #define MM_SYSTEM_SPACE_START 0xFFFFF98000000000UI64 #define MM_USER_ADDRESS_RANGE_LIMIT 0xFFFFFFFFFFFFFFFF // user address range limit #define MM_MAXIMUM_ZERO_BITS 53 // maximum number of zero bits // // Define the start and maximum size for the system cache. // #define MM_SYSTEM_CACHE_START 0xFFFFF98000000000UI64 #define MM_SYSTEM_CACHE_END 0xFFFFFA8000000000UI64 #define MM_MAXIMUM_SYSTEM_CACHE_SIZE \ ((MM_SYSTEM_CACHE_END - MM_SYSTEM_CACHE_START) >> PAGE_SHIFT) #define MM_SYSTEM_CACHE_WORKING_SET 0xFFFFF78000001000UI64 // // Define area for mapping views into system space. // #define MM_SESSION_SPACE_DEFAULT_END 0xFFFFF98000000000UI64 #define MM_SESSION_SPACE_DEFAULT (MM_SESSION_SPACE_DEFAULT_END - MI_SESSION_SPACE_MAXIMUM_TOTAL_SIZE) #define MM_SYSTEM_VIEW_SIZE (104 * 1024 * 1024) // // Various system resource locations. // #define MM_PAGED_POOL_START ((PVOID)0xFFFFFA8000000000) #define MM_LOWEST_NONPAGED_SYSTEM_START ((PVOID)0xFFFFFAA000000000) #define MM_NONPAGED_POOL_END ((PVOID)(0xFFFFFAE000000000)) extern PVOID MmDebugVa; #define MM_DEBUG_VA MmDebugVa extern PVOID MmCrashDumpVa; #define MM_CRASH_DUMP_VA MmCrashDumpVa #define NON_PAGED_SYSTEM_END ((PVOID)0xFFFFFFFFFFFFFFF0) extern BOOLEAN MiWriteCombiningPtes; // // Define absolute minimum and maximum count for system PTEs. // #define MM_MINIMUM_SYSTEM_PTES 7000 #define MM_MAXIMUM_SYSTEM_PTES (16*1024*1024) #define MM_DEFAULT_SYSTEM_PTES 11000 // // Pool limits. // // The maximum amount of nonpaged pool that can be initially created. // #define MM_MAX_INITIAL_NONPAGED_POOL (128 * 1024 * 1024) // // The total amount of nonpaged pool (initial pool + expansion). // #define MM_MAX_ADDITIONAL_NONPAGED_POOL (((SIZE_T)128 * 1024 * 1024 * 1024)) // // The maximum amount of paged pool that can be created. // #define MM_MAX_PAGED_POOL ((SIZE_T)128 * 1024 * 1024 * 1024) #define MM_MAX_DEFAULT_NONPAGED_POOL ((SIZE_T)8 * 1024 * 1024 * 1024) // // Structure layout definitions. // #define MM_PROTO_PTE_ALIGNMENT ((ULONG)MM_MAXIMUM_NUMBER_OF_COLORS * (ULONG)PAGE_SIZE) // // Define the address bits mapped by one PXE/PPE/PDE/PTE entry. // #define MM_VA_MAPPED_BY_PTE ((ULONG_PTR)PAGE_SIZE) #define MM_VA_MAPPED_BY_PDE (PTE_PER_PAGE * MM_VA_MAPPED_BY_PTE) #define MM_VA_MAPPED_BY_PPE (PDE_PER_PAGE * MM_VA_MAPPED_BY_PDE) #define MM_VA_MAPPED_BY_PXE (PPE_PER_PAGE * MM_VA_MAPPED_BY_PPE) // // Define the address bits mapped by PPE and PDE entries. // // A PXE entry maps 9+9+9+12 = 39 bits of address space. // A PPE entry maps 9+9+12 = 30 bits of address space. // A PDE entry maps 9+12 = 21 bits of address space. // #define PAGE_DIRECTORY0_MASK (MM_VA_MAPPED_BY_PXE - 1) #define PAGE_DIRECTORY1_MASK (MM_VA_MAPPED_BY_PPE - 1) #define PAGE_DIRECTORY2_MASK (MM_VA_MAPPED_BY_PDE - 1) #define PTE_SHIFT 3 #define MM_MINIMUM_VA_FOR_LARGE_PAGE MM_VA_MAPPED_BY_PDE // // The number of bits in a virtual address. // #define VIRTUAL_ADDRESS_BITS 48 #define VIRTUAL_ADDRESS_MASK ((((ULONG_PTR)1) << VIRTUAL_ADDRESS_BITS) - 1) // // The number of bits in a physical address. // #define PHYSICAL_ADDRESS_BITS 40 #define MM_MAXIMUM_NUMBER_OF_COLORS (1) // // AMD64 does not require support for colored pages. // #define MM_NUMBER_OF_COLORS (1) // // Mask for obtaining color from a physical page number. // #define MM_COLOR_MASK (0) // // Boundary for aligned pages of like color upon. // #define MM_COLOR_ALIGNMENT (0) // // Mask for isolating color from virtual address. // #define MM_COLOR_MASK_VIRTUAL (0) // // Define 256k worth of secondary colors. // #define MM_SECONDARY_COLORS_DEFAULT (64) #define MM_SECONDARY_COLORS_MIN (8) #define MM_SECONDARY_COLORS_MAX (1024) // // Maximum number of paging files. // #define MAX_PAGE_FILES 16 // // Hyper space definitions. // #define HYPER_SPACE ((PVOID)0xFFFFF70000000000) #define HYPER_SPACE_END 0xFFFFF77FFFFFFFFFUI64 #define FIRST_MAPPING_PTE 0xFFFFF70000000000 #define NUMBER_OF_MAPPING_PTES 126 #define LAST_MAPPING_PTE \ (FIRST_MAPPING_PTE + (NUMBER_OF_MAPPING_PTES * PAGE_SIZE)) #define COMPRESSION_MAPPING_PTE ((PMMPTE)((ULONG_PTR)LAST_MAPPING_PTE + PAGE_SIZE)) #define NUMBER_OF_ZEROING_PTES 256 #define VAD_BITMAP_SPACE ((PVOID)((ULONG_PTR)COMPRESSION_MAPPING_PTE + PAGE_SIZE)) #define WORKING_SET_LIST ((PVOID)((ULONG_PTR)VAD_BITMAP_SPACE + PAGE_SIZE)) #define MM_MAXIMUM_WORKING_SET \ ((((ULONG_PTR)8 * 1024 * 1024 * 1024 * 1024) - (64 * 1024 * 1024)) >> PAGE_SHIFT) //8Tb-64Mb #define MmWorkingSetList ((PMMWSL)WORKING_SET_LIST) #define MmWsle ((PMMWSLE)((PUCHAR)WORKING_SET_LIST + sizeof(MMWSL))) #define MM_WORKING_SET_END (HYPER_SPACE_END + 1) // // Define masks for fields within the PTE. // #define MM_PTE_VALID_MASK 0x1 #if defined(NT_UP) #define MM_PTE_WRITE_MASK 0x2 #else #define MM_PTE_WRITE_MASK 0x800 #endif #define MM_PTE_OWNER_MASK 0x4 #define MM_PTE_WRITE_THROUGH_MASK 0x8 #define MM_PTE_CACHE_DISABLE_MASK 0x10 #define MM_PTE_ACCESS_MASK 0x20 #if defined(NT_UP) #define MM_PTE_DIRTY_MASK 0x40 #else #define MM_PTE_DIRTY_MASK 0x42 #endif #define MM_PTE_LARGE_PAGE_MASK 0x80 #define MM_PTE_GLOBAL_MASK 0x100 #define MM_PTE_COPY_ON_WRITE_MASK 0x200 #define MM_PTE_PROTOTYPE_MASK 0x400 #define MM_PTE_TRANSITION_MASK 0x800 // // Bit fields to or into PTE to make a PTE valid based on the // protection field of the invalid PTE. // #define MM_PTE_NOACCESS 0x0 // not expressible on AMD64 #define MM_PTE_READONLY 0x0 #define MM_PTE_READWRITE MM_PTE_WRITE_MASK #define MM_PTE_WRITECOPY 0x200 // read-only copy on write bit set. #define MM_PTE_EXECUTE 0x0 // read-only on AMD64 #define MM_PTE_EXECUTE_READ 0x0 #define MM_PTE_EXECUTE_READWRITE MM_PTE_WRITE_MASK #define MM_PTE_EXECUTE_WRITECOPY 0x200 // read-only copy on write bit set. #define MM_PTE_NOCACHE 0x010 #define MM_PTE_WRITECOMBINE 0x010 // overridden in MmEnablePAT #define MM_PTE_GUARD 0x0 // not expressible on AMD64 #define MM_PTE_CACHE 0x0 #define MM_PROTECT_FIELD_SHIFT 5 // // Bits available for the software working set index within the hardware PTE. // #define MI_MAXIMUM_PTE_WORKING_SET_INDEX (1 << _HARDWARE_PTE_WORKING_SET_BITS) // // Zero PTE // #define MM_ZERO_PTE 0 // // Zero Kernel PTE // #define MM_ZERO_KERNEL_PTE 0 // // A demand zero PTE with a protection or PAGE_READWRITE. // #define MM_DEMAND_ZERO_WRITE_PTE (MM_READWRITE << MM_PROTECT_FIELD_SHIFT) // // A demand zero PTE with a protection or PAGE_READWRITE for system space. // #define MM_KERNEL_DEMAND_ZERO_PTE (MM_READWRITE << MM_PROTECT_FIELD_SHIFT) // // A no access PTE for system space. // #define MM_KERNEL_NOACCESS_PTE (MM_NOACCESS << MM_PROTECT_FIELD_SHIFT) // // Kernel stack alignment requirements. // #define MM_STACK_ALIGNMENT 0x0 #define MM_STACK_OFFSET 0x0 // // System process definitions // #define PXE_PER_PAGE 512 #define PPE_PER_PAGE 512 #define PDE_PER_PAGE 512 #define PTE_PER_PAGE 512 #define PTE_PER_PAGE_BITS 10 // This handles the case where the page is full #if PTE_PER_PAGE_BITS > 32 error - too many bits to fit into MMPTE_SOFTWARE or MMPFN.u1 #endif // // Number of page table pages for user addresses. // #define MM_USER_PXES (0x10) #define MM_USER_PAGE_TABLE_PAGES ((ULONG_PTR)PDE_PER_PAGE * PPE_PER_PAGE * MM_USER_PXES) #define MM_USER_PAGE_DIRECTORY_PAGES (PPE_PER_PAGE * MM_USER_PXES) #define MM_USER_PAGE_DIRECTORY_PARENT_PAGES (MM_USER_PXES) //++ // VOID // MI_MAKE_VALID_USER_PTE ( // OUT OUTPTE, // IN FRAME, // IN PMASK, // IN PPTE // ); // // Routine Description: // // This macro makes a valid *USER* PTE from a page frame number, // protection mask, and owner. // // THIS MUST ONLY BE USED FOR PAGE TABLE ENTRIES (NOT PAGE DIRECTORY // ENTRIES), MAPPING USER (NOT KERNEL OR SESSION) VIRTUAL ADDRESSES. // // Arguments // // OUTPTE - Supplies the PTE in which to build the valid PTE. // // FRAME - Supplies the page frame number for the PTE. // // PMASK - Supplies the protection to set in the valid PTE. // // Return Value: // // None. // //-- #define MI_MAKE_VALID_USER_PTE(OUTPTE, FRAME, PMASK, PPTE) { \ (OUTPTE).u.Long = MmProtectToPteMask[PMASK] | MM_PTE_VALID_MASK; \ (OUTPTE).u.Long |= ((FRAME) << PAGE_SHIFT); \ (OUTPTE).u.Hard.Accessed = 1; \ ASSERT (((PPTE) < (PMMPTE)PDE_BASE) || ((PPTE) > (PMMPTE)PDE_TOP)); \ (OUTPTE).u.Long |= MM_PTE_OWNER_MASK; \ ASSERT ((OUTPTE).u.Hard.Global == 0); \ } //++ // VOID // MI_MAKE_VALID_KERNEL_PTE ( // OUT OUTPTE, // IN FRAME, // IN PMASK, // IN PPTE // ); // // Routine Description: // // This macro makes a valid *KERNEL* PTE from a page frame number, // protection mask, and owner. // // THIS MUST ONLY BE USED FOR PAGE TABLE ENTRIES (NOT PAGE DIRECTORY // ENTRIES), MAPPING GLOBAL (NOT SESSION) VIRTUAL ADDRESSES. // // Arguments // // OUTPTE - Supplies the PTE in which to build the valid PTE. // // FRAME - Supplies the page frame number for the PTE. // // PMASK - Supplies the protection to set in the valid PTE. // // Return Value: // // None. // //-- #define MI_MAKE_VALID_KERNEL_PTE(OUTPTE, FRAME, PMASK, PPTE) { \ ASSERT (((PPTE) < (PMMPTE)PDE_BASE) || ((PPTE) > (PMMPTE)PDE_TOP)); \ (OUTPTE).u.Long = MmProtectToPteMask[PMASK] | MM_PTE_VALID_MASK; \ (OUTPTE).u.Long |= ((FRAME) << PAGE_SHIFT); \ (OUTPTE).u.Hard.Accessed = 1; \ (OUTPTE).u.Hard.Global = 1; \ } //++ // VOID // MI_MAKE_VALID_PTE ( // OUT OUTPTE, // IN FRAME, // IN PMASK, // IN PPTE // ); // // Routine Description: // // This macro makes a valid PTE from a page frame number, protection mask, // and owner. // // Arguments // // OUTPTE - Supplies the PTE in which to build the transition PTE. // // FRAME - Supplies the page frame number for the PTE. // // PMASK - Supplies the protection to set in the transition PTE. // // PPTE - Supplies a pointer to the PTE which is being made valid. // For prototype PTEs NULL should be specified. // // Return Value: // // None. // //-- #define MI_MAKE_VALID_PTE(OUTPTE, FRAME, PMASK, PPTE) { \ (OUTPTE).u.Long = MmProtectToPteMask[PMASK] | MM_PTE_VALID_MASK;\ (OUTPTE).u.Long |= ((FRAME) << PAGE_SHIFT); \ (OUTPTE).u.Hard.Accessed = 1; \ if (((PPTE) >= (PMMPTE)PDE_BASE) && ((PPTE) <= (PMMPTE)PDE_TOP)) { \ (OUTPTE).u.Hard.NoExecute = 0; \ } \ if (MI_DETERMINE_OWNER(PPTE)) { \ (OUTPTE).u.Long |= MM_PTE_OWNER_MASK; \ } \ if ((((PMMPTE)PPTE) >= MiGetPteAddress(MM_KSEG0_BASE)) && \ ((((PMMPTE)PPTE) >= MiGetPteAddress(MM_SYSTEM_SPACE_START)) || \ (((PMMPTE)PPTE) < MiGetPteAddress(MM_KSEG2_BASE)))) { \ (OUTPTE).u.Hard.Global = 1; \ } \ } //++ // VOID // MI_MAKE_VALID_PTE_TRANSITION ( // IN OUT OUTPTE // IN PROTECT // ); // // Routine Description: // // This macro takes a valid pte and turns it into a transition PTE. // // Arguments // // OUTPTE - Supplies the current valid PTE. This PTE is then // modified to become a transition PTE. // // PROTECT - Supplies the protection to set in the transition PTE. // // Return Value: // // None. // //-- #define MI_MAKE_VALID_PTE_TRANSITION(OUTPTE,PROTECT) \ (OUTPTE).u.Soft.Transition = 1; \ (OUTPTE).u.Soft.Valid = 0; \ (OUTPTE).u.Soft.Prototype = 0; \ (OUTPTE).u.Soft.Protection = PROTECT; //++ // VOID // MI_MAKE_TRANSITION_PTE ( // OUT OUTPTE, // IN PAGE, // IN PROTECT, // IN PPTE // ); // // Routine Description: // // This macro takes a valid pte and turns it into a transition PTE. // // Arguments // // OUTPTE - Supplies the PTE in which to build the transition PTE. // // PAGE - Supplies the page frame number for the PTE. // // PROTECT - Supplies the protection to set in the transition PTE. // // PPTE - Supplies a pointer to the PTE, this is used to determine // the owner of the PTE. // // Return Value: // // None. // //-- #define MI_MAKE_TRANSITION_PTE(OUTPTE,PAGE,PROTECT,PPTE) \ (OUTPTE).u.Long = 0; \ (OUTPTE).u.Trans.PageFrameNumber = PAGE; \ (OUTPTE).u.Trans.Transition = 1; \ (OUTPTE).u.Trans.Protection = PROTECT; \ (OUTPTE).u.Trans.Owner = MI_DETERMINE_OWNER(PPTE); //++ // VOID // MI_MAKE_TRANSITION_PTE_VALID ( // OUT OUTPTE, // IN PPTE // ); // // Routine Description: // // This macro takes a transition pte and makes it a valid PTE. // // Arguments // // OUTPTE - Supplies the PTE in which to build the valid PTE. // // PPTE - Supplies a pointer to the transition PTE. // // Return Value: // // None. // //-- #define MI_MAKE_TRANSITION_PTE_VALID(OUTPTE,PPTE) \ ASSERT (((PPTE)->u.Hard.Valid == 0) && \ ((PPTE)->u.Trans.Prototype == 0) && \ ((PPTE)->u.Trans.Transition == 1)); \ (OUTPTE).u.Long = MmProtectToPteMask[(PPTE)->u.Trans.Protection] | MM_PTE_VALID_MASK; \ if (((PPTE) >= (PMMPTE)PDE_BASE) && ((PPTE) <= (PMMPTE)PDE_TOP)) { \ (OUTPTE).u.Hard.NoExecute = 0; \ } \ (OUTPTE).u.Long |= ((PPTE->u.Hard.PageFrameNumber) << PAGE_SHIFT); \ if (MI_DETERMINE_OWNER(PPTE)) { \ (OUTPTE).u.Long |= MM_PTE_OWNER_MASK; \ } \ if ((((PMMPTE)PPTE) >= MiGetPteAddress(MM_KSEG0_BASE)) && \ ((((PMMPTE)PPTE) >= MiGetPteAddress(MM_SYSTEM_SPACE_START)) || \ (((PMMPTE)PPTE) < MiGetPteAddress(MM_KSEG2_BASE)))) { \ (OUTPTE).u.Hard.Global = 1; \ } \ (OUTPTE).u.Hard.Accessed = 1; //++ // VOID // MI_MAKE_TRANSITION_KERNELPTE_VALID ( // OUT OUTPTE, // IN PPTE // ); // // Routine Description: // // This macro takes a transition kernel PTE and makes it a valid PTE. // // THIS MUST ONLY BE USED FOR PAGE TABLE ENTRIES (NOT PAGE DIRECTORY // ENTRIES), MAPPING GLOBAL (NOT SESSION) VIRTUAL ADDRESSES. // // Arguments // // OUTPTE - Supplies the PTE in which to build the valid PTE. // // PPTE - Supplies a pointer to the transition PTE. // // Return Value: // // None. // //-- #define MI_MAKE_TRANSITION_KERNELPTE_VALID(OUTPTE,PPTE) \ ASSERT (((PPTE)->u.Hard.Valid == 0) && \ ((PPTE)->u.Trans.Prototype == 0) && \ ((PPTE)->u.Trans.Transition == 1)); \ (OUTPTE).u.Long = MmProtectToPteMask[(PPTE)->u.Trans.Protection] | MM_PTE_VALID_MASK; \ ASSERT (((PPTE) < (PMMPTE)PDE_BASE) || ((PPTE) > (PMMPTE)PDE_TOP)); \ (OUTPTE).u.Long |= ((PPTE->u.Hard.PageFrameNumber) << PAGE_SHIFT); \ (OUTPTE).u.Long |= MI_PTE_OWNER_KERNEL; \ ASSERT ((((PMMPTE)PPTE) >= MiGetPteAddress(MM_KSEG0_BASE)) && \ ((((PMMPTE)PPTE) >= MiGetPteAddress(MM_SYSTEM_SPACE_START)) || \ (((PMMPTE)PPTE) < MiGetPteAddress(MM_KSEG2_BASE)))); \ (OUTPTE).u.Hard.Global = 1; \ (OUTPTE).u.Hard.Accessed = 1; //++ // VOID // MI_MAKE_TRANSITION_PROTOPTE_VALID ( // OUT OUTPTE, // IN PPTE // ); // // Routine Description: // // This macro takes a transition prototype PTE (in paged pool) and // makes it a valid PTE. Because we know this is a prototype PTE and // not a pagetable PTE, this can directly or in the global bit. This // makes a measurable performance gain since every instruction counts // when holding the PFN lock. // // Arguments // // OUTPTE - Supplies the PTE in which to build the valid PTE. // // PPTE - Supplies a pointer to the transition PTE. // // Return Value: // // None. // //-- #define MI_MAKE_TRANSITION_PROTOPTE_VALID(OUTPTE,PPTE) \ ASSERT (((PPTE)->u.Hard.Valid == 0) && \ ((PPTE)->u.Trans.Prototype == 0) && \ ((PPTE)->u.Trans.Transition == 1)); \ (OUTPTE).u.Long = MmProtectToPteMask[(PPTE)->u.Trans.Protection] | MM_PTE_VALID_MASK; \ (OUTPTE).u.Long |= ((PPTE->u.Hard.PageFrameNumber) << PAGE_SHIFT); \ (OUTPTE).u.Hard.Global = 1; \ (OUTPTE).u.Hard.Accessed = 1; #define MI_FAULT_STATUS_INDICATES_EXECUTION(_FaultStatus) (_FaultStatus & 0x8) #define MI_FAULT_STATUS_INDICATES_WRITE(_FaultStatus) (_FaultStatus & 0x1) #define MI_CLEAR_FAULT_STATUS(_FaultStatus) (_FaultStatus = 0) #define MI_IS_PTE_EXECUTABLE(_TempPte) ((_TempPte)->u.Hard.NoExecute == 0) //++ // VOID // MI_SET_PTE_IN_WORKING_SET ( // OUT PMMPTE PTE, // IN ULONG WSINDEX // ); // // Routine Description: // // This macro inserts the specified working set index into the argument PTE. // // No TB invalidation is needed for other processors (or this one) even // though the entry may already be in a TB - it's just a software field // update and doesn't affect miss resolution. // // Arguments // // PTE - Supplies the PTE in which to insert the working set index. // // WSINDEX - Supplies the working set index for the PTE. // // Return Value: // // None. // //-- #define MI_SET_PTE_IN_WORKING_SET(PTE, WSINDEX) { \ MMPTE _TempPte; \ _TempPte = *(PTE); \ _TempPte.u.Hard.SoftwareWsIndex = (WSINDEX); \ ASSERT (_TempPte.u.Long != 0); \ *(PTE) = _TempPte; \ } //++ // ULONG WsIndex // MI_GET_WORKING_SET_FROM_PTE( // IN PMMPTE PTE // ); // // Routine Description: // // This macro returns the working set index from the argument PTE. // Since the AMD64 PTE has no free bits nothing needs to be done on this // architecture. // // Arguments // // PTE - Supplies the PTE to extract the working set index from. // // Return Value: // // This macro returns the working set index for the argument PTE. // //-- #define MI_GET_WORKING_SET_FROM_PTE(PTE) (ULONG)(PTE)->u.Hard.SoftwareWsIndex //++ // VOID // MI_SET_PTE_WRITE_COMBINE ( // IN MMPTE PTE // ); // // Routine Description: // // This macro takes a valid PTE and enables WriteCombining as the // caching state. Note that the PTE bits may only be set this way // if the Page Attribute Table is present and the PAT has been // initialized to provide Write Combining. // // If either of the above conditions is not satisfied, then // the macro enables WEAK UC (PCD = 1, PWT = 0) in the PTE. // // Arguments // // PTE - Supplies a valid PTE. // // Return Value: // // None. // //-- // #define MI_SET_PTE_WRITE_COMBINE(PTE) \ { \ if (MiWriteCombiningPtes == TRUE) { \ ((PTE).u.Hard.CacheDisable = 0); \ ((PTE).u.Hard.WriteThrough = 1); \ } else { \ ((PTE).u.Hard.CacheDisable = 1); \ ((PTE).u.Hard.WriteThrough = 0); \ } \ } #define MI_SET_LARGE_PTE_WRITE_COMBINE(PTE) MI_SET_PTE_WRITE_COMBINE(PTE) //++ // VOID // MI_PREPARE_FOR_NONCACHED ( // IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute // ); // // Routine Description: // // This macro prepares the system prior to noncached PTEs being created. // // Arguments // // CacheAttribute - Supplies the cache attribute the PTEs will be filled // with. // // Return Value: // // None. // //-- #define MI_PREPARE_FOR_NONCACHED(_CacheAttribute) \ if (_CacheAttribute != MiCached) { \ MI_FLUSH_ENTIRE_TB (0x20); \ KeInvalidateAllCaches (); \ } //++ // VOID // MI_FLUSH_TB_FOR_INDIVIDUAL_ATTRIBUTE_CHANGE ( // IN PFN_NUMBER PageFrameIndex, // IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute // ); // // Routine Description: // // The entire TB must be flushed if we are changing cache attributes. // // KeFlushSingleTb cannot be used because we don't know // what virtual address(es) this physical frame was last mapped at. // // Additionally, the cache must be flushed if we are switching from // write back to write combined (or noncached) because otherwise the // current data may live in the cache while the uc/wc mapping is used // and then when the uc/wc mapping is freed, the cache will hold stale // data that will be found when a normal write back mapping is reapplied. // // Arguments // // PageFrameIndex - Supplies the page frame number that is going to be // used with the new attribute. // // CacheAttribute - Supplies the cache attribute the new PTEs will be filled // with. // // Return Value: // // None. // //-- #define MI_FLUSH_TB_FOR_INDIVIDUAL_ATTRIBUTE_CHANGE(_PageFrameIndex,_CacheAttribute) \ MiFlushTbForAttributeChange += 1; \ MI_FLUSH_ENTIRE_TB (0x21); \ if (_CacheAttribute != MiCached) { \ MiFlushCacheForAttributeChange += 1; \ KeInvalidateAllCaches (); \ } //++ // VOID // MI_FLUSH_ENTIRE_TB_FOR_ATTRIBUTE_CHANGE ( // IN MI_PFN_CACHE_ATTRIBUTE CacheAttribute // ); // // Routine Description: // // The entire TB must be flushed if we are changing cache attributes. // // KeFlushSingleTb cannot be used because we don't know // what virtual address(es) this physical frame was last mapped at. // // Additionally, the cache must be flushed if we are switching from // write back to write combined (or noncached) because otherwise the // current data may live in the cache while the uc/wc mapping is used // and then when the uc/wc mapping is freed, the cache will hold stale // data that will be found when a normal write back mapping is reapplied. // // Arguments // // CacheAttribute - Supplies the cache attribute the new PTEs will be filled // with. // // Return Value: // // None. // //-- #define MI_FLUSH_ENTIRE_TB_FOR_ATTRIBUTE_CHANGE(_CacheAttribute) \ MiFlushTbForAttributeChange += 1; \ MI_FLUSH_ENTIRE_TB (0x22); \ if (_CacheAttribute != MiCached) { \ MiFlushCacheForAttributeChange += 1; \ KeInvalidateAllCaches (); \ } //++ // VOID // MI_FLUSH_TB_FOR_CACHED_ATTRIBUTE ( // VOID // ); // // Routine Description: // // The entire TB must be flushed if we are changing cache attributes. // // KeFlushSingleTb cannot be used because we don't know // what virtual address(es) a physical frame was last mapped at. // // Note no cache flush is needed because the attribute-changing-pages // are going to be mapped fully cached. // // Arguments // // None. // // Return Value: // // None. // //-- #define MI_FLUSH_TB_FOR_CACHED_ATTRIBUTE() \ MiFlushTbForAttributeChange += 1; \ MI_FLUSH_ENTIRE_TB (0x23); //++ // VOID // MI_SET_PTE_DIRTY ( // IN MMPTE PTE // ); // // Routine Description: // // This macro sets the dirty bit(s) in the specified PTE. // // Arguments // // PTE - Supplies the PTE to set dirty. // // Return Value: // // None. // //-- #define MI_SET_PTE_DIRTY(PTE) (PTE).u.Long |= HARDWARE_PTE_DIRTY_MASK //++ // VOID // MI_SET_PTE_CLEAN ( // IN MMPTE PTE // ); // // Routine Description: // // This macro clears the dirty bit(s) in the specified PTE. // // Arguments // // PTE - Supplies the PTE to set clear. // // Return Value: // // None. // //-- #define MI_SET_PTE_CLEAN(PTE) (PTE).u.Long &= ~HARDWARE_PTE_DIRTY_MASK //++ // VOID // MI_IS_PTE_DIRTY ( // IN MMPTE PTE // ); // // Routine Description: // // This macro checks the dirty bit(s) in the specified PTE. // // Arguments // // PTE - Supplies the PTE to check. // // Return Value: // // TRUE if the page is dirty (modified), FALSE otherwise. // //-- #define MI_IS_PTE_DIRTY(PTE) ((PTE).u.Hard.Dirty != 0) //++ // VOID // MI_SET_GLOBAL_STATE ( // IN MMPTE PTE, // IN ULONG STATE // ); // // Routine Description: // // This macro sets the global bit in the PTE. if the pointer PTE is within // // Arguments // // PTE - Supplies the PTE to set global state into. // // STATE - Supplies 1 if global, 0 if not. // // Return Value: // // None. // //-- #define MI_SET_GLOBAL_STATE(PTE, STATE) (PTE).u.Hard.Global = STATE; //++ // VOID // MI_ENABLE_CACHING ( // IN MMPTE PTE // ); // // Routine Description: // // This macro takes a valid PTE and sets the caching state to be // enabled. This is performed by clearing the PCD and PWT bits in the PTE. // // Semantics of the overlap between PCD, PWT, and the // USWC memory type in the MTRR are: // // PCD PWT Mtrr Mem Type Effective Memory Type // 1 0 USWC USWC // 1 1 USWC UC // // Arguments // // PTE - Supplies a valid PTE. // // Return Value: // // None. // //-- #define MI_ENABLE_CACHING(PTE) \ { \ ((PTE).u.Hard.CacheDisable = 0); \ ((PTE).u.Hard.WriteThrough = 0); \ } //++ // VOID // MI_DISABLE_CACHING ( // IN MMPTE PTE // ); // // Routine Description: // // This macro takes a valid PTE and sets the caching state to be // disabled. This is performed by setting the PCD and PWT bits in the PTE. // // Semantics of the overlap between PCD, PWT, and the // USWC memory type in the MTRR are: // // PCD PWT Mtrr Mem Type Effective Memory Type // 1 0 USWC USWC // 1 1 USWC UC // // Since an effective memory type of UC is desired here, // the WT bit is set. // // Arguments // // PTE - Supplies a pointer to the valid PTE. // // Return Value: // // None. // //-- #define MI_DISABLE_CACHING(PTE) \ { \ ((PTE).u.Hard.CacheDisable = 1); \ ((PTE).u.Hard.WriteThrough = 1); \ } #define MI_DISABLE_LARGE_PTE_CACHING(PTE) MI_DISABLE_CACHING(PTE) //++ // BOOLEAN // MI_IS_CACHING_DISABLED ( // IN PMMPTE PPTE // ); // // Routine Description: // // This macro takes a valid PTE and returns TRUE if caching is // disabled. // // Arguments // // PPTE - Supplies a pointer to the valid PTE. // // Return Value: // // TRUE if caching is disabled, FALSE if it is enabled. // //-- #define MI_IS_CACHING_DISABLED(PPTE) \ ((PPTE)->u.Hard.CacheDisable == 1) //++ // VOID // MI_SET_PFN_DELETED ( // IN PMMPFN PPFN // ); // // Routine Description: // // This macro takes a pointer to a PFN element and indicates that // the PFN is no longer in use. // // Arguments // // PPTE - Supplies a pointer to the PFN element. // // Return Value: // // none. // //-- #define MI_SET_PFN_DELETED(PPFN) \ (PPFN)->PteAddress = (PMMPTE)((ULONG_PTR)PPFN->PteAddress | 0x1); //++ // VOID // MI_MARK_PFN_UNDELETED ( // IN PMMPFN PPFN // ); // // Routine Description: // // This macro takes a pointer to a deleted PFN element and mark that // the PFN is not deleted. // // Arguments // // PPTE - Supplies a pointer to the PFN element. // // Return Value: // // none. // //-- #define MI_MARK_PFN_UNDELETED(PPFN) \ PPFN->PteAddress = (PMMPTE)((ULONG_PTR)PPFN->PteAddress & ~0x1); //++ // BOOLEAN // MI_IS_PFN_DELETED ( // IN PMMPFN PPFN // ); // // Routine Description: // // This macro takes a pointer to a PFN element and determines if // the PFN is no longer in use. // // Arguments // // PPTE - Supplies a pointer to the PFN element. // // Return Value: // // TRUE if PFN is no longer used, FALSE if it is still being used. // //-- #define MI_IS_PFN_DELETED(PPFN) \ ((ULONG_PTR)(PPFN)->PteAddress & 0x1) //++ // VOID // MI_CHECK_PAGE_ALIGNMENT ( // IN ULONG PAGE, // IN PMMPTE PPTE // ); // // Routine Description: // // This macro takes a PFN element number (Page) and checks to see // if the virtual alignment for the previous address of the page // is compatible with the new address of the page. If they are // not compatible, the D cache is flushed. // // Arguments // // PAGE - Supplies the PFN element. // PPTE - Supplies a pointer to the new PTE which will contain the page. // // Return Value: // // none. // //-- // does nothing on AMD64. #define MI_CHECK_PAGE_ALIGNMENT(PAGE,PPTE) //++ // VOID // MI_INITIALIZE_HYPERSPACE_MAP ( // VOID // ); // // Routine Description: // // This macro initializes the PTEs reserved for double mapping within // hyperspace. // // Arguments // // None. // // Return Value: // // None. // //-- // does nothing on AMD64. #define MI_INITIALIZE_HYPERSPACE_MAP(INDEX) //++ // ULONG // MI_GET_NEXT_COLOR ( // IN ULONG COLOR // ); // // Routine Description: // // This macro returns the next color in the sequence. // // Arguments // // COLOR - Supplies the color to return the next of. // // Return Value: // // Next color in sequence. // //-- #define MI_GET_NEXT_COLOR(COLOR) ((COLOR + 1) & MM_COLOR_MASK) //++ // ULONG // MI_GET_PREVIOUS_COLOR ( // IN ULONG COLOR // ); // // Routine Description: // // This macro returns the previous color in the sequence. // // Arguments // // COLOR - Supplies the color to return the previous of. // // Return Value: // // Previous color in sequence. // //-- #define MI_GET_PREVIOUS_COLOR(COLOR) (0) #define MI_GET_SECONDARY_COLOR(PAGE,PFN) ((ULONG)(PAGE & MmSecondaryColorMask)) #define MI_GET_COLOR_FROM_SECONDARY(SECONDARY_COLOR) (0) //++ // VOID // MI_GET_MODIFIED_PAGE_BY_COLOR ( // OUT ULONG PAGE, // IN ULONG COLOR // ); // // Routine Description: // // This macro returns the first page destined for a paging // file with the desired color. It does NOT remove the page // from its list. // // Arguments // // PAGE - Returns the page located, the value MM_EMPTY_LIST is // returned if there is no page of the specified color. // // COLOR - Supplies the color of page to locate. // // Return Value: // // none. // //-- #define MI_GET_MODIFIED_PAGE_BY_COLOR(PAGE,COLOR) \ PAGE = MmModifiedPageListByColor[COLOR].Flink //++ // VOID // MI_GET_MODIFIED_PAGE_ANY_COLOR ( // OUT ULONG PAGE, // IN OUT ULONG COLOR // ); // // Routine Description: // // This macro returns the first page destined for a paging // file with the desired color. If not page of the desired // color exists, all colored lists are searched for a page. // It does NOT remove the page from its list. // // Arguments // // PAGE - Returns the page located, the value MM_EMPTY_LIST is // returned if there is no page of the specified color. // // COLOR - Supplies the color of page to locate and returns the // color of the page located. // // Return Value: // // none. // //-- #define MI_GET_MODIFIED_PAGE_ANY_COLOR(PAGE,COLOR) \ { \ if (MmTotalPagesForPagingFile == 0) { \ PAGE = MM_EMPTY_LIST; \ } else { \ PAGE = MmModifiedPageListByColor[COLOR].Flink; \ } \ } //++ // VOID // MI_MAKE_VALID_PTE_WRITE_COPY ( // IN OUT PMMPTE PTE // ); // // Routine Description: // // This macro checks to see if the PTE indicates that the // page is writable and if so it clears the write bit and // sets the copy-on-write bit. // // Arguments // // PTE - Supplies the PTE to operate upon. // // Return Value: // // None. // //-- #if defined(NT_UP) #define MI_MAKE_VALID_PTE_WRITE_COPY(PPTE) \ if ((PPTE)->u.Hard.Write == 1) { \ (PPTE)->u.Hard.CopyOnWrite = 1; \ (PPTE)->u.Hard.Write = 0; \ } #else #define MI_MAKE_VALID_PTE_WRITE_COPY(PPTE) \ if ((PPTE)->u.Hard.Write == 1) { \ (PPTE)->u.Hard.CopyOnWrite = 1; \ (PPTE)->u.Hard.Write = 0; \ (PPTE)->u.Hard.Writable = 0; \ } #endif #define MI_PTE_OWNER_USER 1 #define MI_PTE_OWNER_KERNEL 0 //++ // ULONG // MI_DETERMINE_OWNER ( // IN MMPTE PPTE // ); // // Routine Description: // // This macro examines the virtual address of the PTE and determines // if the PTE resides in system space or user space. // // Arguments // // PTE - Supplies the PTE to operate upon. // // Return Value: // // 1 if the owner is USER_MODE, 0 if the owner is KERNEL_MODE. // //-- #define MI_DETERMINE_OWNER(PPTE) \ ((((PPTE) <= MiHighestUserPte) || \ ((PPTE) >= MiGetPdeAddress(NULL) && ((PPTE) <= MiHighestUserPde)) || \ ((PPTE) >= MiGetPpeAddress(NULL) && ((PPTE) <= MiHighestUserPpe)) || \ ((PPTE) >= MiGetPxeAddress(NULL) && ((PPTE) <= MiHighestUserPxe))) \ ? MI_PTE_OWNER_USER : MI_PTE_OWNER_KERNEL) //++ // VOID // MI_SET_ACCESSED_IN_PTE ( // IN OUT MMPTE PPTE, // IN ULONG ACCESSED // ); // // Routine Description: // // This macro sets the ACCESSED field in the PTE. // // Arguments // // PTE - Supplies the PTE to operate upon. // // Return Value: // // None // //-- #define MI_SET_ACCESSED_IN_PTE(PPTE,ACCESSED) \ ((PPTE)->u.Hard.Accessed = ACCESSED) //++ // ULONG // MI_GET_ACCESSED_IN_PTE ( // IN OUT MMPTE PPTE // ); // // Routine Description: // // This macro returns the state of the ACCESSED field in the PTE. // // Arguments // // PTE - Supplies the PTE to operate upon. // // Return Value: // // The state of the ACCESSED field. // //-- #define MI_GET_ACCESSED_IN_PTE(PPTE) ((PPTE)->u.Hard.Accessed) //++ // VOID // MI_SET_OWNER_IN_PTE ( // IN PMMPTE PPTE // IN ULONG OWNER // ); // // Routine Description: // // This macro sets the owner field in the PTE. // // Arguments // // PTE - Supplies the PTE to operate upon. // // Return Value: // // None. // //-- #define MI_SET_OWNER_IN_PTE(PPTE,OWNER) ((PPTE)->u.Hard.Owner = OWNER) // // Mask to clear all fields but protection in a PTE to or in paging file // location. // #define CLEAR_FOR_PAGE_FILE 0x000003E0 //++ // VOID // MI_SET_PAGING_FILE_INFO ( // OUT MMPTE OUTPTE, // IN MMPTE PPTE, // IN ULONG FILEINFO, // IN ULONG OFFSET // ); // // Routine Description: // // This macro sets into the specified PTE the supplied information // to indicate where the backing store for the page is located. // // Arguments // // OUTPTE - Supplies the PTE in which to store the result. // // PTE - Supplies the PTE to operate upon. // // FILEINFO - Supplies the number of the paging file. // // OFFSET - Supplies the offset into the paging file. // // Return Value: // // None. // //-- #define MI_SET_PAGING_FILE_INFO(OUTPTE,PPTE,FILEINFO,OFFSET) \ (OUTPTE).u.Long = (PPTE).u.Long; \ (OUTPTE).u.Long &= CLEAR_FOR_PAGE_FILE; \ (OUTPTE).u.Long |= (FILEINFO << 1); \ (OUTPTE).u.Soft.PageFileHigh = (OFFSET); //++ // PMMPTE // MiPteToProto ( // IN OUT MMPTE PPTE, // IN ULONG FILEINFO, // IN ULONG OFFSET // ); // // Routine Description: // // This macro returns the address of the corresponding prototype which // was encoded earlier into the supplied PTE. // // Arguments // // lpte - Supplies the PTE to operate upon. // // Return Value: // // Pointer to the prototype PTE that backs this PTE. // //-- #define MiPteToProto(lpte) \ ((PMMPTE)((lpte)->u.Proto.ProtoAddress)) //++ // ULONG // MiProtoAddressForPte ( // IN PMMPTE proto_va // ); // // Routine Description: // // This macro sets into the specified PTE the supplied information // to indicate where the backing store for the page is located. // MiProtoAddressForPte returns the bit field to OR into the PTE to // reference a prototype PTE. And set the protoPTE bit, // MM_PTE_PROTOTYPE_MASK. // // Arguments // // proto_va - Supplies the address of the prototype PTE. // // Return Value: // // Mask to set into the PTE. // //-- #define MiProtoAddressForPte(proto_va) \ (((ULONG_PTR)proto_va << 16) | MM_PTE_PROTOTYPE_MASK) //++ // ULONG // MiProtoAddressForKernelPte ( // IN PMMPTE proto_va // ); // // Routine Description: // // This macro sets into the specified PTE the supplied information // to indicate where the backing store for the page is located. // MiProtoAddressForPte returns the bit field to OR into the PTE to // reference a prototype PTE. And set the protoPTE bit, // MM_PTE_PROTOTYPE_MASK. // // This macro also sets any other information (such as global bits) // required for kernel mode PTEs. // // Arguments // // proto_va - Supplies the address of the prototype PTE. // // Return Value: // // Mask to set into the PTE. // //-- // not different on AMD64. #define MiProtoAddressForKernelPte(proto_va) MiProtoAddressForPte(proto_va) //++ // PSUBSECTION // MiGetSubsectionAddress ( // IN PMMPTE lpte // ); // // Routine Description: // // This macro takes a PTE and returns the address of the subsection that // the PTE refers to. Subsections are quadword structures allocated // from nonpaged pool. // // Arguments // // lpte - Supplies the PTE to operate upon. // // Return Value: // // A pointer to the subsection referred to by the supplied PTE. // //-- #define MiGetSubsectionAddress(lpte) \ ((PSUBSECTION)((lpte)->u.Subsect.SubsectionAddress)) //++ // ULONG // MiGetSubsectionAddressForPte ( // IN PSUBSECTION VA // ); // // Routine Description: // // This macro takes the address of a subsection and encodes it for use // in a PTE. // // Arguments // // VA - Supplies a pointer to the subsection to encode. // // Return Value: // // The mask to set into the PTE to make it reference the supplied // subsection. // //-- #define MiGetSubsectionAddressForPte(VA) ((ULONGLONG)VA << 16) //++ // PMMPTE // MiGetPxeAddress ( // IN PVOID va // ); // // Routine Description: // // MiGetPxeAddress returns the address of the extended page directory parent // entry which maps the given virtual address. This is one level above the // page parent directory. // // Arguments // // Va - Supplies the virtual address to locate the PXE for. // // Return Value: // // The address of the PXE. // //-- #define MiGetPxeAddress(va) ((PMMPTE)PXE_BASE + MiGetPxeOffset(va)) //++ // PMMPTE // MiGetPpeAddress ( // IN PVOID va // ); // // Routine Description: // // MiGetPpeAddress returns the address of the page directory parent entry // which maps the given virtual address. This is one level above the // page directory. // // Arguments // // Va - Supplies the virtual address to locate the PPE for. // // Return Value: // // The address of the PPE. // //-- #define MiGetPpeAddress(va) \ ((PMMPTE)(((((ULONG_PTR)(va) & VIRTUAL_ADDRESS_MASK) >> PPI_SHIFT) << PTE_SHIFT) + PPE_BASE)) //++ // PMMPTE // MiGetPdeAddress ( // IN PVOID va // ); // // Routine Description: // // MiGetPdeAddress returns the address of the PDE which maps the // given virtual address. // // Arguments // // Va - Supplies the virtual address to locate the PDE for. // // Return Value: // // The address of the PDE. // //-- #define MiGetPdeAddress(va) \ ((PMMPTE)(((((ULONG_PTR)(va) & VIRTUAL_ADDRESS_MASK) >> PDI_SHIFT) << PTE_SHIFT) + PDE_BASE)) //++ // PMMPTE // MiGetPteAddress ( // IN PVOID va // ); // // Routine Description: // // MiGetPteAddress returns the address of the PTE which maps the // given virtual address. // // Arguments // // Va - Supplies the virtual address to locate the PTE for. // // Return Value: // // The address of the PTE. // //-- #define MiGetPteAddress(va) \ ((PMMPTE)(((((ULONG_PTR)(va) & VIRTUAL_ADDRESS_MASK) >> PTI_SHIFT) << PTE_SHIFT) + PTE_BASE)) //++ // ULONG // MiGetPxeOffset ( // IN PVOID va // ); // // Routine Description: // // MiGetPxeOffset returns the offset into an extended page directory parent // for a given virtual address. // // Arguments // // Va - Supplies the virtual address to locate the offset for. // // Return Value: // // The offset into the extended parent page directory table the corresponding // PXE is at. // //-- #define MiGetPxeOffset(va) ((ULONG)(((ULONG_PTR)(va) >> PXI_SHIFT) & PXI_MASK)) //++ // ULONG // MiGetPxeIndex ( // IN PVOID va // ); // // Routine Description: // // MiGetPxeIndex returns the extended page directory parent index // for a given virtual address. // // N.B. This does not mask off PXE bits. // // Arguments // // Va - Supplies the virtual address to locate the index for. // // Return Value: // // The index into the extended page directory parent - ie: the virtual page // directory parent number. This is different from the extended page // directory parent offset because this spans extended page directory // parents on supported platforms. // //-- #define MiGetPxeIndex(va) ((ULONG)((ULONG_PTR)(va) >> PXI_SHIFT)) //++ // ULONG // MiGetPpeOffset ( // IN PVOID va // ); // // Routine Description: // // MiGetPpeOffset returns the offset into a page directory parent for a // given virtual address. // // Arguments // // Va - Supplies the virtual address to locate the offset for. // // Return Value: // // The offset into the parent page directory table the corresponding // PPE is at. // //-- #define MiGetPpeOffset(va) ((ULONG)(((ULONG_PTR)(va) >> PPI_SHIFT) & PPI_MASK)) //++ // ULONG // MiGetPpeIndex ( // IN PVOID va // ); // // Routine Description: // // MiGetPpeIndex returns the page directory parent index // for a given virtual address. // // N.B. This does not mask off PXE bits. // // Arguments // // Va - Supplies the virtual address to locate the index for. // // Return Value: // // The index into the page directory parent - ie: the virtual page directory // number. This is different from the page directory parent offset because // this spans page directory parents on supported platforms. // //-- #define MiGetPpeIndex(va) ((ULONG)((ULONG_PTR)(va) >> PPI_SHIFT)) //++ // ULONG // MiGetPdeOffset ( // IN PVOID va // ); // // Routine Description: // // MiGetPdeOffset returns the offset into a page directory // for a given virtual address. // // Arguments // // Va - Supplies the virtual address to locate the offset for. // // Return Value: // // The offset into the page directory table the corresponding PDE is at. // //-- #define MiGetPdeOffset(va) ((ULONG)(((ULONG_PTR)(va) >> PDI_SHIFT) & (PDE_PER_PAGE - 1))) //++ // ULONG // MiGetPdeIndex ( // IN PVOID va // ); // // Routine Description: // // MiGetPdeIndex returns the page directory index // for a given virtual address. // // N.B. This does not mask off PPE or PXE bits. // // Arguments // // Va - Supplies the virtual address to locate the index for. // // Return Value: // // The index into the page directory - ie: the virtual page table number. // This is different from the page directory offset because this spans // page directories on supported platforms. // //-- #define MiGetPdeIndex(va) ((ULONG)((ULONG_PTR)(va) >> PDI_SHIFT)) //++ // ULONG // MiGetPteOffset ( // IN PVOID va // ); // // Routine Description: // // MiGetPteOffset returns the offset into a page table page // for a given virtual address. // // Arguments // // Va - Supplies the virtual address to locate the offset for. // // Return Value: // // The offset into the page table page table the corresponding PTE is at. // //-- #define MiGetPteOffset(va) ((ULONG)(((ULONG_PTR)(va) >> PTI_SHIFT) & (PTE_PER_PAGE - 1))) //++ // PVOID // MiGetVirtualAddressMappedByPxe ( // IN PMMPTE PTE // ); // // Routine Description: // // MiGetVirtualAddressMappedByPxe returns the virtual address // which is mapped by a given PXE address. // // Arguments // // PXE - Supplies the PXE to get the virtual address for. // // Return Value: // // Virtual address mapped by the PXE. // //-- #define MiGetVirtualAddressMappedByPxe(PXE) \ MiGetVirtualAddressMappedByPde(MiGetVirtualAddressMappedByPde(PXE)) //++ // PVOID // MiGetVirtualAddressMappedByPpe ( // IN PMMPTE PTE // ); // // Routine Description: // // MiGetVirtualAddressMappedByPpe returns the virtual address // which is mapped by a given PPE address. // // Arguments // // PPE - Supplies the PPE to get the virtual address for. // // Return Value: // // Virtual address mapped by the PPE. // //-- #define MiGetVirtualAddressMappedByPpe(PPE) \ MiGetVirtualAddressMappedByPte(MiGetVirtualAddressMappedByPde(PPE)) //++ // PVOID // MiGetVirtualAddressMappedByPde ( // IN PMMPTE PTE // ); // // Routine Description: // // MiGetVirtualAddressMappedByPde returns the virtual address // which is mapped by a given PDE address. // // Arguments // // PDE - Supplies the PDE to get the virtual address for. // // Return Value: // // Virtual address mapped by the PDE. // //-- #define MiGetVirtualAddressMappedByPde(PDE) \ MiGetVirtualAddressMappedByPte(MiGetVirtualAddressMappedByPte(PDE)) //++ // PVOID // MiGetVirtualAddressMappedByPte ( // IN PMMPTE PTE // ); // // Routine Description: // // MiGetVirtualAddressMappedByPte returns the virtual address // which is mapped by a given PTE address. // // Arguments // // PTE - Supplies the PTE to get the virtual address for. // // Return Value: // // Virtual address mapped by the PTE. // //-- #define VA_SHIFT (63 - 47) // address sign extend shift count #define MiGetVirtualAddressMappedByPte(PTE) \ ((PVOID)((LONG_PTR)(((LONG_PTR)(PTE) - PTE_BASE) << (PAGE_SHIFT + VA_SHIFT - PTE_SHIFT)) >> VA_SHIFT)) //++ // LOGICAL // MiIsVirtualAddressOnPxeBoundary ( // IN PVOID VA // ); // // Routine Description: // // MiIsVirtualAddressOnPxeBoundary returns TRUE if the virtual address is // on an extended page directory parent entry boundary. // // Arguments // // VA - Supplies the virtual address to check. // // Return Value: // // TRUE if on a boundary, FALSE if not. // //-- #define MiIsVirtualAddressOnPxeBoundary(VA) (((ULONG_PTR)(VA) & PAGE_DIRECTORY0_MASK) == 0) //++ // LOGICAL // MiIsVirtualAddressOnPpeBoundary ( // IN PVOID VA // ); // // Routine Description: // // MiIsVirtualAddressOnPpeBoundary returns TRUE if the virtual address is // on a page directory entry boundary. // // Arguments // // VA - Supplies the virtual address to check. // // Return Value: // // TRUE if on a boundary, FALSE if not. // //-- #define MiIsVirtualAddressOnPpeBoundary(VA) (((ULONG_PTR)(VA) & PAGE_DIRECTORY1_MASK) == 0) //++ // LOGICAL // MiIsVirtualAddressOnPdeBoundary ( // IN PVOID VA // ); // // Routine Description: // // MiIsVirtualAddressOnPdeBoundary returns TRUE if the virtual address is // on a page directory entry boundary. // // Arguments // // VA - Supplies the virtual address to check. // // Return Value: // // TRUE if on a 2MB PDE boundary, FALSE if not. // //-- #define MiIsVirtualAddressOnPdeBoundary(VA) (((ULONG_PTR)(VA) & PAGE_DIRECTORY2_MASK) == 0) //++ // LOGICAL // MiIsPteOnPxeBoundary ( // IN PVOID PTE // ); // // Routine Description: // // MiIsPteOnPxeBoundary returns TRUE if the PTE is // on an extended page directory parent entry boundary. // // Arguments // // PTE - Supplies the PTE to check. // // Return Value: // // TRUE if on a boundary, FALSE if not. // //-- #define MiIsPteOnPxeBoundary(PTE) (((ULONG_PTR)(PTE) & (PAGE_DIRECTORY1_MASK)) == 0) //++ // LOGICAL // MiIsPteOnPpeBoundary ( // IN PVOID PTE // ); // // Routine Description: // // MiIsPteOnPpeBoundary returns TRUE if the PTE is // on a page directory parent entry boundary. // // Arguments // // PTE - Supplies the PTE to check. // // Return Value: // // TRUE if on a boundary, FALSE if not. // //-- #define MiIsPteOnPpeBoundary(PTE) (((ULONG_PTR)(PTE) & (PAGE_DIRECTORY2_MASK)) == 0) //++ // LOGICAL // MiIsPteOnPdeBoundary ( // IN PVOID PTE // ); // // Routine Description: // // MiIsPteOnPdeBoundary returns TRUE if the PTE is // on a page directory entry boundary. // // Arguments // // PTE - Supplies the PTE to check. // // Return Value: // // TRUE if on a 2MB PDE boundary, FALSE if not. // //-- #define MiIsPteOnPdeBoundary(PTE) (((ULONG_PTR)(PTE) & (PAGE_SIZE - 1)) == 0) //++ //ULONG //GET_PAGING_FILE_NUMBER ( // IN MMPTE PTE // ); // // Routine Description: // // This macro extracts the paging file number from a PTE. // // Arguments // // PTE - Supplies the PTE to operate upon. // // Return Value: // // The paging file number. // //-- #define GET_PAGING_FILE_NUMBER(PTE) ((ULONG)(((PTE).u.Soft.PageFileLow))) //++ //ULONG //GET_PAGING_FILE_OFFSET ( // IN MMPTE PTE // ); // // Routine Description: // // This macro extracts the offset into the paging file from a PTE. // // Arguments // // PTE - Supplies the PTE to operate upon. // // Return Value: // // The paging file offset. // //-- #define GET_PAGING_FILE_OFFSET(PTE) ((ULONG)((PTE).u.Soft.PageFileHigh)) //++ //ULONG //IS_PTE_NOT_DEMAND_ZERO ( // IN PMMPTE PTE // ); // // Routine Description: // // This macro checks to see if a given PTE is NOT a demand zero PTE. // // Arguments // // PTE - Supplies the PTE to operate upon. // // Return Value: // // Returns 0 if the PTE is demand zero, non-zero otherwise. // //-- #define IS_PTE_NOT_DEMAND_ZERO(PTE) \ ((PTE).u.Long & ((ULONG_PTR)0xFFFFFFFFFFFFF000 | \ MM_PTE_VALID_MASK | \ MM_PTE_PROTOTYPE_MASK | \ MM_PTE_TRANSITION_MASK)) //++ // VOID // MI_MAKE_PROTECT_WRITE_COPY ( // IN OUT MMPTE PPTE // ); // // Routine Description: // // This macro makes a writable PTE a writable-copy PTE. // // Arguments // // PTE - Supplies the PTE to operate upon. // // Return Value: // // NONE // //-- #define MI_MAKE_PROTECT_WRITE_COPY(PTE) \ if ((PTE).u.Soft.Protection & MM_PROTECTION_WRITE_MASK) { \ (PTE).u.Long |= MM_PROTECTION_COPY_MASK << MM_PROTECT_FIELD_SHIFT; \ } //++ // VOID // MI_SET_PAGE_DIRTY( // IN PMMPTE PPTE, // IN PVOID VA, // IN PVOID PFNHELD // ); // // Routine Description: // // This macro sets the dirty bit (and release page file space). // // Arguments // // TEMP - Supplies a temporary for usage. // // PPTE - Supplies a pointer to the PTE that corresponds to VA. // // VA - Supplies a the virtual address of the page fault. // // PFNHELD - Supplies TRUE if the PFN lock is held. // // Return Value: // // None. // //-- #if defined(NT_UP) #define MI_SET_PAGE_DIRTY(PPTE,VA,PFNHELD) #else #define MI_SET_PAGE_DIRTY(PPTE,VA,PFNHELD) \ if ((PPTE)->u.Hard.Dirty == 1) { \ MiSetDirtyBit ((VA),(PPTE),(PFNHELD)); \ } #endif //++ // VOID // MI_NO_FAULT_FOUND( // IN FAULTSTATUS, // IN PMMPTE PPTE, // IN PVOID VA, // IN PVOID PFNHELD // ); // // Routine Description: // // This macro handles the case when a page fault is taken and no // PTE with the valid bit clear is found. // // Arguments // // FAULTSTATUS - Supplies the fault status. // // PPTE - Supplies a pointer to the PTE that corresponds to VA. // // VA - Supplies a the virtual address of the page fault. // // PFNHELD - Supplies TRUE if the PFN lock is held. // // Return Value: // // None. // //-- #if defined(NT_UP) #define MI_NO_FAULT_FOUND(FAULTSTATUS,PPTE,VA,PFNHELD) #else #define MI_NO_FAULT_FOUND(FAULTSTATUS,PPTE,VA,PFNHELD) \ if ((MI_FAULT_STATUS_INDICATES_WRITE(FAULTSTATUS)) && ((PPTE)->u.Hard.Dirty == 0)) { \ MiSetDirtyBit ((VA),(PPTE),(PFNHELD)); \ } #endif //++ // ULONG // MI_CAPTURE_DIRTY_BIT_TO_PFN ( // IN PMMPTE PPTE, // IN PMMPFN PPFN // ); // // Routine Description: // // This macro gets captures the state of the dirty bit to the PFN // and frees any associated page file space if the PTE has been // modified element. // // NOTE - THE PFN LOCK MUST BE HELD! // // Arguments // // PPTE - Supplies the PTE to operate upon. // // PPFN - Supplies a pointer to the PFN database element that corresponds // to the page mapped by the PTE. // // Return Value: // // None. // //-- #define MI_CAPTURE_DIRTY_BIT_TO_PFN(PPTE,PPFN) \ ASSERT (KeGetCurrentIrql() > APC_LEVEL); \ if (((PPFN)->u3.e1.Modified == 0) && \ ((PPTE)->u.Hard.Dirty != 0)) { \ MI_SET_MODIFIED (PPFN, 1, 0x18); \ if (((PPFN)->OriginalPte.u.Soft.Prototype == 0) && \ ((PPFN)->u3.e1.WriteInProgress == 0)) { \ MiReleasePageFileSpace ((PPFN)->OriginalPte); \ (PPFN)->OriginalPte.u.Soft.PageFileHigh = 0; \ } \ } //++ // BOOLEAN // MI_IS_PHYSICAL_ADDRESS ( // IN PVOID VA // ); // // Routine Description: // // This macro determines if a given virtual address is really a // physical address. // // Arguments // // VA - Supplies the virtual address. // // Return Value: // // FALSE if it is not a physical address, TRUE if it is. // //-- #define MI_IS_PHYSICAL_ADDRESS(Va) \ ((MiGetPxeAddress(Va)->u.Hard.Valid == 1) && \ (MiGetPpeAddress(Va)->u.Hard.Valid == 1) && \ ((MiGetPdeAddress(Va)->u.Long & 0x81) == 0x81)) //++ // ULONG // MI_CONVERT_PHYSICAL_TO_PFN ( // IN PVOID VA // ); // // Routine Description: // // This macro converts a physical address (see MI_IS_PHYSICAL_ADDRESS) // to its corresponding physical frame number. // // Arguments // // VA - Supplies a pointer to the physical address. // // Return Value: // // Returns the PFN for the page. // //-- #define MI_CONVERT_PHYSICAL_TO_PFN(Va) \ ((PFN_NUMBER)(MiGetPdeAddress(Va)->u.Hard.PageFrameNumber) + (MiGetPteOffset((ULONG_PTR)Va))) typedef struct _MMCOLOR_TABLES { PFN_NUMBER Flink; PVOID Blink; PFN_NUMBER Count; } MMCOLOR_TABLES, *PMMCOLOR_TABLES; extern PMMCOLOR_TABLES MmFreePagesByColor[2]; extern PFN_NUMBER MmTotalPagesForPagingFile; // // A VALID Page Table Entry on an AMD64 has the following definition. // #define MI_MAXIMUM_PAGEFILE_SIZE (((UINT64)4 * 1024 * 1024 * 1024 - 1) * PAGE_SIZE) #define MI_PTE_LOOKUP_NEEDED ((ULONG64)0xffffffff) typedef struct _MMPTE_SOFTWARE { ULONGLONG Valid : 1; ULONGLONG PageFileLow : 4; ULONGLONG Protection : 5; ULONGLONG Prototype : 1; ULONGLONG Transition : 1; ULONGLONG UsedPageTableEntries : PTE_PER_PAGE_BITS; ULONGLONG Reserved : 20 - PTE_PER_PAGE_BITS; ULONGLONG PageFileHigh : 32; } MMPTE_SOFTWARE; typedef struct _MMPTE_TRANSITION { ULONGLONG Valid : 1; ULONGLONG Write : 1; ULONGLONG Owner : 1; ULONGLONG WriteThrough : 1; ULONGLONG CacheDisable : 1; ULONGLONG Protection : 5; ULONGLONG Prototype : 1; ULONGLONG Transition : 1; ULONGLONG PageFrameNumber : 28; ULONGLONG Unused : 24; } MMPTE_TRANSITION; typedef struct _MMPTE_PROTOTYPE { ULONGLONG Valid : 1; ULONGLONG Unused0: 7; ULONGLONG ReadOnly : 1; ULONGLONG Unused1: 1; ULONGLONG Prototype : 1; ULONGLONG Protection : 5; LONGLONG ProtoAddress: 48; } MMPTE_PROTOTYPE; typedef struct _MMPTE_SUBSECTION { ULONGLONG Valid : 1; ULONGLONG Unused0 : 4; ULONGLONG Protection : 5; ULONGLONG Prototype : 1; ULONGLONG Unused1 : 5; LONGLONG SubsectionAddress : 48; } MMPTE_SUBSECTION; typedef struct _MMPTE_LIST { ULONGLONG Valid : 1; ULONGLONG OneEntry : 1; ULONGLONG filler0 : 3; // // Note the Prototype bit must not be used for lists like freed nonpaged // pool because lookaside pops can legitimately reference bogus addresses // (since the pop is unsynchronized) and the fault handler must be able to // distinguish lists from protos so a retry status can be returned (vs a // fatal bugcheck). // // The same caveat applies to both the Transition and the Protection // fields as they are similarly examined in the fault handler and would // be misinterpreted if ever nonzero in the freed nonpaged pool chains. // ULONGLONG Protection : 5; ULONGLONG Prototype : 1; // MUST BE ZERO as per above comment. ULONGLONG Transition : 1; ULONGLONG filler1 : 20; ULONGLONG NextEntry : 32; } MMPTE_LIST; typedef struct _MMPTE_HIGHLOW { ULONG LowPart; ULONG HighPart; } MMPTE_HIGHLOW; typedef struct _MMPTE_HARDWARE_LARGEPAGE { ULONGLONG Valid : 1; ULONGLONG Write : 1; ULONGLONG Owner : 1; ULONGLONG WriteThrough : 1; ULONGLONG CacheDisable : 1; ULONGLONG Accessed : 1; ULONGLONG Dirty : 1; ULONGLONG LargePage : 1; ULONGLONG Global : 1; ULONGLONG CopyOnWrite : 1; // software field ULONGLONG Prototype : 1; // software field ULONGLONG reserved0 : 1; // software field ULONGLONG PAT : 1; ULONGLONG reserved1 : 8; // software field ULONGLONG PageFrameNumber : 19; ULONGLONG reserved2 : 24; // software field } MMPTE_HARDWARE_LARGEPAGE, *PMMPTE_HARDWARE_LARGEPAGE; // // A Page Table Entry on AMD64 has the following definition. // Note the MP version is to avoid stalls when flushing TBs across processors. // // // Uniprocessor version. // typedef struct _MMPTE_HARDWARE { ULONGLONG Valid : 1; #if defined(NT_UP) ULONGLONG Write : 1; // UP version #else ULONGLONG Writable : 1; // changed for MP version #endif ULONGLONG Owner : 1; ULONGLONG WriteThrough : 1; ULONGLONG CacheDisable : 1; ULONGLONG Accessed : 1; ULONGLONG Dirty : 1; ULONGLONG LargePage : 1; ULONGLONG Global : 1; ULONGLONG CopyOnWrite : 1; // software field ULONGLONG Prototype : 1; // software field #if defined(NT_UP) ULONGLONG reserved0 : 1; // software field #else ULONGLONG Write : 1; // software field - MP change #endif ULONGLONG PageFrameNumber : 28; ULONG64 reserved1 : 24 - (_HARDWARE_PTE_WORKING_SET_BITS+1); ULONGLONG SoftwareWsIndex : _HARDWARE_PTE_WORKING_SET_BITS; ULONG64 NoExecute : 1; } MMPTE_HARDWARE, *PMMPTE_HARDWARE; #if defined(NT_UP) #define HARDWARE_PTE_DIRTY_MASK 0x40 #else #define HARDWARE_PTE_DIRTY_MASK 0x42 #endif #define MI_PDE_MAPS_LARGE_PAGE(PDE) ((PDE)->u.Hard.LargePage == 1) #define MI_MAKE_PDE_MAP_LARGE_PAGE(PDE) ((PDE)->u.Hard.LargePage = 1) #define MI_GET_PAGE_FRAME_FROM_PTE(PTE) ((PTE)->u.Hard.PageFrameNumber) #define MI_GET_PAGE_FRAME_FROM_TRANSITION_PTE(PTE) ((PTE)->u.Trans.PageFrameNumber) #define MI_GET_PROTECTION_FROM_SOFT_PTE(PTE) ((ULONG)(PTE)->u.Soft.Protection) #define MI_GET_PROTECTION_FROM_TRANSITION_PTE(PTE) ((ULONG)(PTE)->u.Trans.Protection) typedef struct _MMPTE { union { ULONG_PTR Long; MMPTE_HARDWARE Hard; MMPTE_HARDWARE_LARGEPAGE HardLarge; HARDWARE_PTE Flush; MMPTE_PROTOTYPE Proto; MMPTE_SOFTWARE Soft; MMPTE_TRANSITION Trans; MMPTE_SUBSECTION Subsect; MMPTE_LIST List; } u; } MMPTE; typedef MMPTE *PMMPTE; extern PMMPTE MiFirstReservedZeroingPte; #define InterlockedCompareExchangePte(_PointerPte, _NewContents, _OldContents) \ InterlockedCompareExchange64 ((PLONGLONG)(_PointerPte), (LONGLONG)(_NewContents), (LONGLONG)(_OldContents)) #define InterlockedExchangePte(_PointerPte, _NewContents) InterlockedExchange64((PLONG64)(_PointerPte), _NewContents) //++ // VOID // MI_WRITE_VALID_PTE ( // IN PMMPTE PointerPte, // IN MMPTE PteContents // ); // // Routine Description: // // MI_WRITE_VALID_PTE fills in the specified PTE making it valid with the // specified contents. // // Arguments // // PointerPte - Supplies a PTE to fill. // // PteContents - Supplies the contents to put in the PTE. // // Return Value: // // None. // //-- #define MI_WRITE_VALID_PTE(_PointerPte, _PteContents) \ ASSERT ((_PointerPte)->u.Hard.Valid == 0); \ ASSERT ((_PteContents).u.Hard.Valid == 1); \ MI_INSERT_VALID_PTE(_PointerPte); \ MI_LOG_PTE_CHANGE (_PointerPte, _PteContents); \ (*(_PointerPte) = (_PteContents)) //++ // VOID // MI_WRITE_INVALID_PTE ( // IN PMMPTE PointerPte, // IN MMPTE PteContents // ); // // Routine Description: // // MI_WRITE_INVALID_PTE fills in the specified PTE making it invalid with the // specified contents. // // Arguments // // PointerPte - Supplies a PTE to fill. // // PteContents - Supplies the contents to put in the PTE. // // Return Value: // // None. // //-- #define MI_WRITE_INVALID_PTE(_PointerPte, _PteContents) \ ASSERT ((_PteContents).u.Hard.Valid == 0); \ MI_REMOVE_PTE(_PointerPte); \ MI_LOG_PTE_CHANGE (_PointerPte, _PteContents); \ (*(_PointerPte) = (_PteContents)) #define MI_WRITE_INVALID_PTE_WITHOUT_WS MI_WRITE_INVALID_PTE //++ // VOID // MI_WRITE_ZERO_PTE ( // IN PMMPTE PointerPte // ); // // Routine Description: // // MI_WRITE_ZERO_PTE fills the specified PTE with zero, making it invalid. // // Arguments // // PointerPte - Supplies a PTE to fill. // // Return Value: // // None. // //-- #define MI_WRITE_ZERO_PTE(_PointerPte) \ MI_REMOVE_PTE(_PointerPte); \ MI_LOG_PTE_CHANGE (_PointerPte, ZeroPte); \ (_PointerPte)->u.Long = 0; //++ // VOID // MI_WRITE_VALID_PTE_NEW_PROTECTION ( // IN PMMPTE PointerPte, // IN MMPTE PteContents // ); // // Routine Description: // // MI_WRITE_VALID_PTE_NEW_PROTECTION fills in the specified PTE (which was // already valid) changing only the protection or the dirty bit. // // Arguments // // PointerPte - Supplies a PTE to fill. // // PteContents - Supplies the contents to put in the PTE. // // Return Value: // // None. // //-- #define MI_WRITE_VALID_PTE_NEW_PROTECTION(_PointerPte, _PteContents) \ ASSERT ((_PointerPte)->u.Hard.Valid == 1); \ ASSERT ((_PteContents).u.Hard.Valid == 1); \ ASSERT ((_PointerPte)->u.Hard.PageFrameNumber == (_PteContents).u.Hard.PageFrameNumber); \ MI_LOG_PTE_CHANGE (_PointerPte, _PteContents); \ (*(_PointerPte) = (_PteContents)) //++ // VOID // MI_WRITE_VALID_PTE_NEW_PAGE ( // IN PMMPTE PointerPte, // IN MMPTE PteContents // ); // // Routine Description: // // MI_WRITE_VALID_PTE_NEW_PAGE fills in the specified PTE (which was // already valid) changing the page and the protection. // Note that the contents are very carefully written. // // Arguments // // PointerPte - Supplies a PTE to fill. // // PteContents - Supplies the contents to put in the PTE. // // Return Value: // // None. // //-- #define MI_WRITE_VALID_PTE_NEW_PAGE(_PointerPte, _PteContents) \ ASSERT ((_PointerPte)->u.Hard.Valid == 1); \ ASSERT ((_PteContents).u.Hard.Valid == 1); \ ASSERT ((_PointerPte)->u.Hard.PageFrameNumber != (_PteContents).u.Hard.PageFrameNumber); \ MI_LOG_PTE_CHANGE (_PointerPte, _PteContents); \ (*(_PointerPte) = (_PteContents)) //++ // VOID // MiFillMemoryPte ( // IN PMMPTE Destination, // IN ULONG NumberOfPtes, // IN MMPTE Pattern // }; // // Routine Description: // // This function fills memory with the specified PTE pattern. // // Arguments // // Destination - Supplies a pointer to the memory to fill. // // NumberOfPtes - Supplies the number of PTEs (not bytes!) to be filled. // // Pattern - Supplies the PTE fill pattern. // // Return Value: // // None. // //-- #define MiFillMemoryPte(Destination, Length, Pattern) \ __stosq((PULONG64)(Destination), Pattern, Length) #define MiZeroMemoryPte(Destination, Length) \ __stosq((PULONG64)(Destination), 0, Length) //++ // BOOLEAN // MI_IS_WRITE_COMBINE_ENABLED ( // IN PMMPTE PPTE // ); // // Routine Description: // // This macro takes a valid PTE and returns TRUE if write combine is // enabled. // // Arguments // // PPTE - Supplies a pointer to the valid PTE. // // Return Value: // // TRUE if write combine is enabled, FALSE if it is disabled. // //-- __forceinline LOGICAL MI_IS_WRITE_COMBINE_ENABLED ( IN PMMPTE PointerPte ) { if (MiWriteCombiningPtes == TRUE) { if ((PointerPte->u.Hard.CacheDisable == 0) && (PointerPte->u.Hard.WriteThrough == 1)) { return TRUE; } } else { if ((PointerPte->u.Hard.CacheDisable == 1) && (PointerPte->u.Hard.WriteThrough == 0)) { return TRUE; } } return FALSE; } ULONG FASTCALL MiDetermineUserGlobalPteMask ( IN PMMPTE Pte ); //++ // BOOLEAN // MI_IS_PAGE_TABLE_ADDRESS ( // IN PVOID VA // ); // // Routine Description: // // This macro takes a virtual address and determines if // it is a page table address. // // Arguments // // VA - Supplies a virtual address. // // Return Value: // // TRUE if the address is a page table address, FALSE if not. // //-- #define MI_IS_PAGE_TABLE_ADDRESS(VA) \ ((PVOID)(VA) >= (PVOID)PTE_BASE && (PVOID)(VA) <= (PVOID)PTE_TOP) //++ // BOOLEAN // MI_IS_PAGE_TABLE_OR_HYPER_ADDRESS ( // IN PVOID VA // ); // // Routine Description: // // This macro takes a virtual address and determines if // it is a page table or hyperspace address. // // Arguments // // VA - Supplies a virtual address. // // Return Value: // // TRUE if the address is a page table or hyperspace address, FALSE if not. // //-- #define MI_IS_PAGE_TABLE_OR_HYPER_ADDRESS(VA) \ ((PVOID)(VA) >= (PVOID)PTE_BASE && (PVOID)(VA) <= (PVOID)HYPER_SPACE_END) //++ // BOOLEAN // MI_IS_KERNEL_PAGE_TABLE_ADDRESS ( // IN PVOID VA // ); // // Routine Description: // // This macro takes a virtual address and determines if // it is a page table address for a kernel address. // // Arguments // // VA - Supplies a virtual address. // // Return Value: // // TRUE if the address is a kernel page table address, FALSE if not. // //-- #define MI_IS_KERNEL_PAGE_TABLE_ADDRESS(VA) \ ((PVOID)(VA) >= (PVOID)MiGetPteAddress(MM_SYSTEM_RANGE_START) && (PVOID)(VA) <= (PVOID)PTE_TOP) //++ // BOOLEAN // MI_IS_PAGE_DIRECTORY_ADDRESS ( // IN PVOID VA // ); // // Routine Description: // // This macro takes a virtual address and determines if // it is a page directory address. // // Arguments // // VA - Supplies a virtual address. // // Return Value: // // TRUE if the address is a page directory address, FALSE if not. // //-- #define MI_IS_PAGE_DIRECTORY_ADDRESS(VA) \ ((PVOID)(VA) >= (PVOID)PDE_BASE && (PVOID)(VA) <= (PVOID)PDE_TOP) //++ // BOOLEAN // MI_IS_HYPER_SPACE_ADDRESS ( // IN PVOID VA // ); // // Routine Description: // // This macro takes a virtual address and determines if // it is a hyper space address. // // Arguments // // VA - Supplies a virtual address. // // Return Value: // // TRUE if the address is a hyper space address, FALSE if not. // //-- #define MI_IS_HYPER_SPACE_ADDRESS(VA) \ ((PVOID)(VA) >= (PVOID)HYPER_SPACE && (PVOID)(VA) <= (PVOID)HYPER_SPACE_END) //++ // BOOLEAN // MI_IS_PROCESS_SPACE_ADDRESS ( // IN PVOID VA // ); // // Routine Description: // // This macro takes a virtual address and determines if // it is a process-specific address. This is an address in user space // or page table pages or hyper space. // // Arguments // // VA - Supplies a virtual address. // // Return Value: // // TRUE if the address is a process-specific address, FALSE if not. // //-- #define MI_IS_PROCESS_SPACE_ADDRESS(VA) \ (((PVOID)(VA) <= (PVOID)MM_HIGHEST_USER_ADDRESS) || \ ((PVOID)(VA) >= (PVOID)PTE_BASE && (PVOID)(VA) <= (PVOID)HYPER_SPACE_END)) //++ // BOOLEAN // MI_IS_PTE_PROTOTYPE ( // IN PMMPTE PTE // ); // // Routine Description: // // This macro takes a PTE address and determines if it is a prototype PTE. // // Arguments // // PTE - Supplies the virtual address of the PTE to check. // // Return Value: // // TRUE if the PTE is in a segment (ie, a prototype PTE), FALSE if not. // //-- #define MI_IS_PTE_PROTOTYPE(PTE) \ ((PTE) > (PMMPTE)PTE_TOP) //++ // BOOLEAN // MI_IS_SYSTEM_CACHE_ADDRESS ( // IN PVOID VA // ); // // Routine Description: // // This macro takes a virtual address and determines if // it is a system cache address. // // Arguments // // VA - Supplies a virtual address. // // Return Value: // // TRUE if the address is in the system cache, FALSE if not. // //-- #define MI_IS_SYSTEM_CACHE_ADDRESS(VA) \ ((PVOID)(VA) >= (PVOID)MmSystemCacheStart && \ (PVOID)(VA) <= (PVOID)MmSystemCacheEnd) //++ // VOID // MI_BARRIER_SYNCHRONIZE ( // IN ULONG TimeStamp // ); // // Routine Description: // // MI_BARRIER_SYNCHRONIZE compares the argument timestamp against the // current IPI barrier sequence stamp. When equal, all processors will // issue memory barriers to ensure that newly created pages remain coherent. // // When a page is put in the zeroed or free page list the current // barrier sequence stamp is read (interlocked - this is necessary // to get the correct value - memory barriers won't do the trick) // and stored in the pfn entry for the page. The current barrier // sequence stamp is maintained by the IPI send logic and is // incremented (interlocked) when the target set of an IPI send // includes all processors, but the one doing the send. When a page // is needed its sequence number is compared against the current // barrier sequence number. If it is equal, then the contents of // the page may not be coherent on all processors, and an IPI must // be sent to all processors to ensure a memory barrier is // executed (generic call can be used for this). Sending the IPI // automatically updates the barrier sequence number. The compare // is for equality as this is the only value that requires the IPI // (i.e., the sequence number wraps, values in both directions are // older). When a page is removed in this fashion and either found // to be coherent or made coherent, it cannot be modified between // that time and writing the PTE. If the page is modified between // these times, then an IPI must be sent. // // Arguments // // TimeStamp - Supplies the timestamp at the time when the page was zeroed. // // Return Value: // // None. // //-- // does nothing on AMD64. #define MI_BARRIER_SYNCHRONIZE(TimeStamp) //++ // VOID // MI_BARRIER_STAMP_ZEROED_PAGE ( // IN PULONG PointerTimeStamp // ); // // Routine Description: // // MI_BARRIER_STAMP_ZEROED_PAGE issues an interlocked read to get the // current IPI barrier sequence stamp. This is called AFTER a page is // zeroed. // // Arguments // // PointerTimeStamp - Supplies a timestamp pointer to fill with the // current IPI barrier sequence stamp. // // Return Value: // // None. // //-- // does nothing on AMD64. #define MI_BARRIER_STAMP_ZEROED_PAGE(PointerTimeStamp) // //++ // LOGICAL // MI_RESERVED_BITS_CANONICAL ( // IN PVOID VirtualAddress // ); // // Routine Description: // // This routine checks whether all of the reserved bits are correct. // // The processor implements at 48 bits of VA and memory management // uses them all so the VA is checked against 48 bits to prevent // reserved bit faults as our caller is not going to be expecting them. // // Arguments // // VirtualAddress - Supplies the virtual address to check. // // Return Value: // // TRUE if the address is ok, FALSE if not. // LOGICAL __inline MI_RESERVED_BITS_CANONICAL ( IN PVOID VirtualAddress ) { // // Bits 48-63 of the address must match, i.e., they must be all zeros // or all ones. // return ((ULONG64)(((LONG64)VirtualAddress >> 48) + 1) <= 1); } //++ // VOID // MI_DISPLAY_TRAP_INFORMATION ( // IN PVOID TrapInformation // ); // // Routine Description: // // Display any relevant trap information to aid debugging. // // Arguments // // TrapInformation - Supplies a pointer to a trap frame. // // Return Value: // // None. // #define MI_DISPLAY_TRAP_INFORMATION(TrapInformation) \ KdPrint(("MM:***RIP %p, EFL %p\n", \ ((PKTRAP_FRAME) (TrapInformation))->Rip, \ ((PKTRAP_FRAME) (TrapInformation))->EFlags)); \ KdPrint(("MM:***RAX %p, RCX %p RDX %p\n", \ ((PKTRAP_FRAME) (TrapInformation))->Rax, \ ((PKTRAP_FRAME) (TrapInformation))->Rcx, \ ((PKTRAP_FRAME) (TrapInformation))->Rdx)); \ KdPrint(("MM:***RBX %p, RSI %p RDI %p\n", \ ((PKTRAP_FRAME) (TrapInformation))->Rbx, \ ((PKTRAP_FRAME) (TrapInformation))->Rsi, \ ((PKTRAP_FRAME) (TrapInformation))->Rdi)); VOID MiGetStackPointer ( OUT PULONG_PTR StackPointer );
25.790116
133
0.57393
8bd1362963371eb5343de3d3ddf50111e05c9fac
489
h
C
Asteroids/pax16/gfx/cga/mode_6/mode_6.h
ifknot/Asteroids
26ec3b72997a3077218d320b580460447c5575e2
[ "MIT" ]
null
null
null
Asteroids/pax16/gfx/cga/mode_6/mode_6.h
ifknot/Asteroids
26ec3b72997a3077218d320b580460447c5575e2
[ "MIT" ]
null
null
null
Asteroids/pax16/gfx/cga/mode_6/mode_6.h
ifknot/Asteroids
26ec3b72997a3077218d320b580460447c5575e2
[ "MIT" ]
null
null
null
/*****************************************************************//** * \file mode_6.h * \brief * * \author ifkno * \date September 2021 *********************************************************************/ //#pragma once #ifndef MODE_6_H #define MODE_6_H #include "mode_6_line_asm.h" #include "mode_6_line.h" #include "mode_6_pixel_asm.h" #include "mode_6_pixel.h" #include "mode_6_bitmap.h" #include "mode_6_display_buffer.h" #include "mode_6_screen_buffer.h" #endif
20.375
71
0.513292
e9ae5068b149448efb9136e76ca0ee16e0ce07cf
3,169
h
C
MatrixSDK/Crypto/KeySharing/Data/MXOutgoingRoomKeyRequest.h
VenkatAdk7/Matrix_iOS_SDK_Test
6310852d806ead3ceb07ef6378d17ea77c478bb5
[ "Apache-2.0" ]
7
2020-05-13T15:50:11.000Z
2021-03-13T04:59:56.000Z
MatrixSDK/Crypto/KeySharing/Data/MXOutgoingRoomKeyRequest.h
VenkatAdk7/Matrix_iOS_SDK_Test
6310852d806ead3ceb07ef6378d17ea77c478bb5
[ "Apache-2.0" ]
null
null
null
MatrixSDK/Crypto/KeySharing/Data/MXOutgoingRoomKeyRequest.h
VenkatAdk7/Matrix_iOS_SDK_Test
6310852d806ead3ceb07ef6378d17ea77c478bb5
[ "Apache-2.0" ]
1
2020-07-05T23:06:35.000Z
2020-07-05T23:06:35.000Z
/* Copyright 2017 OpenMarket Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #import <Foundation/Foundation.h> /** Possible states for a room key request The state machine looks like: | V (cancellation requested) UNSENT -----------------------------+ | | | (send successful) | V | SENT | |-------------------------------- | --------------+ | | | | | (cancellation requested with intent | | to resend a new request) | (cancellation requested) | | V | V CANCELLATION_PENDING | CANCELLATION_PENDING_AND_WILL_RESEND | | | | (cancellation sent) | (cancellation sent. Create new request | | in the UNSENT state) V | | (deleted) <---------------------------+----------------+ */ typedef enum : NSUInteger { // request not yet sent MXRoomKeyRequestStateUnsent = 0, // request sent, awaiting reply MXRoomKeyRequestStateSent, // reply received, cancellation not yet sent MXRoomKeyRequestStateCancellationPending, // Cancellation not yet sent and will send a new request MXRoomKeyRequestStateCancellationPendingAndWillResend } MXRoomKeyRequestState; /** `MXOutgoingRoomKeyRequest` represents an outgoing room key request. */ @interface MXOutgoingRoomKeyRequest : NSObject /** The requestId unique id for this request. Used for both an id within the request for later pairing with a cancellation, and for the transaction id when sending the to_device messages to our local server. */ @property (nonatomic) NSString *requestId; /** The transaction id for the cancellation, if any. */ @property (nonatomic) NSString *cancellationTxnId; /** The list of recipients for the request. Array of userId -> deviceId dictionary. */ @property (nonatomic) NSArray<NSDictionary<NSString*, NSString*>*> *recipients; /** The parameters of a room key request. The details of the request may vary with the crypto algorithm, but the management and storage layers for outgoing requests expect it to have 'room_id' and 'session_id' properties */ @property (nonatomic) NSDictionary *requestBody; /** The current state of this request. */ @property (nonatomic) MXRoomKeyRequestState state; @end
33.357895
80
0.591985
eb564d2605f683b82b94e6bbd1a0352e72a4750a
1,277
h
C
Arkanoid/DLL/GameStructs.h
rmcsilva/ArkanoidSO2
e296cb4297922278a87c5421fa9b0f7c1b340683
[ "Apache-2.0" ]
3
2019-11-19T10:03:55.000Z
2022-01-12T22:17:59.000Z
Arkanoid/DLL/GameStructs.h
rmcsilva/ArkanoidSO2
e296cb4297922278a87c5421fa9b0f7c1b340683
[ "Apache-2.0" ]
null
null
null
Arkanoid/DLL/GameStructs.h
rmcsilva/ArkanoidSO2
e296cb4297922278a87c5421fa9b0f7c1b340683
[ "Apache-2.0" ]
null
null
null
#pragma once #include "stdafx.h" #include "resourceConstants.h" #include "gameConstants.h" //Game Status #define GAME_LOBBY 0 #define GAME_ACTIVE 1 #define GAME_OVER 2 //Bonus status #define BONUS_INACTIVE 0 #define BONUS_IN_PLAY 1 #define BONUS_CAUGHT 2 typedef struct Position { int x; int y; }Position; typedef struct Ball { int directionX; int directionY; int velocityRatio; Position position; int playerIndex; BOOL inPlay; }Ball; typedef struct Barrier { Position position; int sizeRatio; int playerID; }Barrier; typedef struct Brick { Position position; int resistance; BOOL hasBonus; int bonusType; }Brick; typedef struct Bonus { Position position; int type; int status; }Bonus; typedef struct Player { TCHAR username[TAM]; int id; int score; BOOL inGame; }Player; typedef struct GameData { int gameStatus; int level; int lives; int barrierDimensions; int numPlayers; Player player[MAX_PLAYERS]; Barrier barrier[MAX_PLAYERS]; int bricksDirectionX; int numBricks; Brick brick[MAX_BRICKS]; int numBonus; Bonus bonus[MAX_BONUS]; int numBalls; Ball ball[MAX_BALLS]; }GameData; typedef struct TopPlayer { TCHAR username[TAM]; int topScore; }TopPlayer;
16.802632
31
0.711825
6a519d685d89766cb7b9e7757c3da0badf4a760e
6,369
h
C
gporca/libgpopt/include/gpopt/base/COptCtxt.h
Tanmoy248/gpdb
67fa1568b3ef2dc1c7757e3e94705de2f92e124b
[ "PostgreSQL", "Apache-2.0" ]
null
null
null
gporca/libgpopt/include/gpopt/base/COptCtxt.h
Tanmoy248/gpdb
67fa1568b3ef2dc1c7757e3e94705de2f92e124b
[ "PostgreSQL", "Apache-2.0" ]
null
null
null
gporca/libgpopt/include/gpopt/base/COptCtxt.h
Tanmoy248/gpdb
67fa1568b3ef2dc1c7757e3e94705de2f92e124b
[ "PostgreSQL", "Apache-2.0" ]
1
2022-03-22T18:45:41.000Z
2022-03-22T18:45:41.000Z
//--------------------------------------------------------------------------- // Greenplum Database // Copyright (C) 2009 Greenplum, Inc. // // @filename: // COptCtxt.h // // @doc: // Optimizer context object; contains all global objects pertaining to // one optimization //--------------------------------------------------------------------------- #ifndef GPOPT_COptCtxt_H #define GPOPT_COptCtxt_H #include "gpos/base.h" #include "gpos/task/CTaskLocalStorageObject.h" #include "gpopt/base/CColumnFactory.h" #include "gpopt/base/CCTEInfo.h" #include "gpopt/base/IComparator.h" #include "gpopt/mdcache/CMDAccessor.h" #include "naucrates/traceflags/traceflags.h" namespace gpopt { using namespace gpos; // forward declarations class CColRefSet; class COptimizerConfig; class ICostModel; class IConstExprEvaluator; //--------------------------------------------------------------------------- // @class: // COptCtxt // // @doc: // "Optimizer Context" is a container of global objects (mostly // singletons) that are needed by the optimizer. // // A COptCtxt object is instantiated in COptimizer::PdxlnOptimize() via // COptCtxt::PoctxtCreate() and stored as a task local object. The global // information contained in it can be accessed by calling // COptCtxt::PoctxtFromTLS(), instead of passing a pointer to it all // around. For example to get the global CMDAccessor: // CMDAccessor *md_accessor = COptCtxt::PoctxtFromTLS()->Pmda(); // //--------------------------------------------------------------------------- class COptCtxt : public CTaskLocalStorageObject { private: // private copy ctor COptCtxt(COptCtxt &); // shared memory pool IMemoryPool *m_mp; // column factory CColumnFactory *m_pcf; // metadata accessor; CMDAccessor *m_pmda; // cost model ICostModel *m_cost_model; // constant expression evaluator IConstExprEvaluator *m_pceeval; // comparator between IDatum instances IComparator *m_pcomp; // atomic counter for generating part index ids CAtomicULONG m_auPartId; // global CTE information CCTEInfo *m_pcteinfo; // system columns required in query output CColRefArray *m_pdrgpcrSystemCols; // optimizer configurations COptimizerConfig *m_optimizer_config; // whether or not we are optimizing a DML query BOOL m_fDMLQuery; // value for the first valid part id static ULONG m_ulFirstValidPartId; // if there are master only tables in the query BOOL m_has_master_only_tables; // does the query contain any volatile functions or // functions that read/modify SQL data BOOL m_has_volatile_or_SQL_func; // does the query have replicated tables BOOL m_has_replicated_tables; public: // ctor COptCtxt ( IMemoryPool *mp, CColumnFactory *col_factory, CMDAccessor *md_accessor, IConstExprEvaluator *pceeval, COptimizerConfig *optimizer_config ); // dtor virtual ~COptCtxt(); // memory pool accessor IMemoryPool *Pmp() const { return m_mp; } // optimizer configurations COptimizerConfig *GetOptimizerConfig() const { return m_optimizer_config; } // are we optimizing a DML query BOOL FDMLQuery() const { return m_fDMLQuery; } // set the DML flag void MarkDMLQuery ( BOOL fDMLQuery ) { m_fDMLQuery = fDMLQuery; } void SetHasMasterOnlyTables() { m_has_master_only_tables = true; } void SetHasVolatileOrSQLFunc() { m_has_volatile_or_SQL_func = true; } void SetHasReplicatedTables() { m_has_replicated_tables = true; } BOOL HasMasterOnlyTables() const { return m_has_master_only_tables; } BOOL HasVolatileOrSQLFunc() const { return m_has_volatile_or_SQL_func; } BOOL HasReplicatedTables() const { return m_has_replicated_tables; } BOOL OptimizeDMLQueryWithSingletonSegment() const { // A DML statement can be optimized by enforcing a gather motion on segment instead of master, // whenever a singleton execution is needed. // This optmization can not be applied if the query contains any of the following: // (1). master-only tables // (2). a volatile function // (3). a function SQL dataaccess: EfdaContainsSQL or EfdaReadsSQLData or EfdaModifiesSQLData // In such cases, it is safe to *always* enforce gather motion on master as there is no way to determine // if the SQL contains any master-only tables. return !GPOS_FTRACE(EopttraceDisableNonMasterGatherForDML) && FDMLQuery() && !HasMasterOnlyTables() && !HasVolatileOrSQLFunc(); } // column factory accessor CColumnFactory *Pcf() const { return m_pcf; } // metadata accessor CMDAccessor *Pmda() const { return m_pmda; } // cost model accessor ICostModel *GetCostModel() const { return m_cost_model; } // constant expression evaluator IConstExprEvaluator *Pceeval() { return m_pceeval; } // comparator const IComparator *Pcomp() { return m_pcomp; } // cte info CCTEInfo *Pcteinfo() { return m_pcteinfo; } // return a new part index id ULONG UlPartIndexNextVal() { return m_auPartId.Incr(); } // required system columns CColRefArray *PdrgpcrSystemCols() const { return m_pdrgpcrSystemCols; } // set required system columns void SetReqdSystemCols ( CColRefArray *pdrgpcrSystemCols ) { GPOS_ASSERT(NULL != pdrgpcrSystemCols); CRefCount::SafeRelease(m_pdrgpcrSystemCols); m_pdrgpcrSystemCols = pdrgpcrSystemCols; } // factory method static COptCtxt *PoctxtCreate ( IMemoryPool *mp, CMDAccessor *md_accessor, IConstExprEvaluator *pceeval, COptimizerConfig *optimizer_config ); // shorthand to retrieve opt context from TLS inline static COptCtxt *PoctxtFromTLS() { return reinterpret_cast<COptCtxt*>(ITask::Self()->GetTls().Get(CTaskLocalStorage::EtlsidxOptCtxt)); } // return true if all enforcers are enabled static BOOL FAllEnforcersEnabled(); #ifdef GPOS_DEBUG virtual IOstream &OsPrint(IOstream &) const; #endif // GPOS_DEBUG }; // class COptCtxt } #endif // !GPOPT_COptCtxt_H // EOF
22.114583
113
0.653478
5595a22921b882fabaad71924148814882455655
233
h
C
Example/HyperWindowSwitch/HomeFirstViewController.h
phpremedy/HyperWindowSwitch
a852b06fd5384f6d7e5ed07ddeb1281d90ab1fc1
[ "MIT" ]
4
2016-12-08T15:19:56.000Z
2022-01-15T00:41:39.000Z
Example/HyperWindowSwitch/HomeFirstViewController.h
phpremedy/HyperWindowSwitch
a852b06fd5384f6d7e5ed07ddeb1281d90ab1fc1
[ "MIT" ]
null
null
null
Example/HyperWindowSwitch/HomeFirstViewController.h
phpremedy/HyperWindowSwitch
a852b06fd5384f6d7e5ed07ddeb1281d90ab1fc1
[ "MIT" ]
3
2016-12-08T15:19:57.000Z
2022-01-15T00:41:41.000Z
// // ExampleViewController.h // HyperWindowSwitch // // Created by H.Vakilian on 11/03/2016. // Copyright (c) 2016 H.Vakilian. All rights reserved. // @import UIKit; @interface HomeFirstViewController : UIViewController @end
16.642857
55
0.725322
ce75bb913cf9c3519167f672b7caeb1786bed0ae
2,345
h
C
core/sql/parser/HvTypes.h
CoderSong2015/Apache-Trafodion
889631aae9cdcd38fca92418d633f2dedc0be619
[ "Apache-2.0" ]
148
2015-06-18T21:26:04.000Z
2017-12-25T01:47:01.000Z
core/sql/parser/HvTypes.h
CoderSong2015/Apache-Trafodion
889631aae9cdcd38fca92418d633f2dedc0be619
[ "Apache-2.0" ]
1,352
2015-06-20T03:05:01.000Z
2017-12-25T14:13:18.000Z
core/sql/parser/HvTypes.h
CoderSong2015/Apache-Trafodion
889631aae9cdcd38fca92418d633f2dedc0be619
[ "Apache-2.0" ]
166
2015-06-19T18:52:10.000Z
2017-12-27T06:19:32.000Z
/* -*-C++-*- ****************************************************************************** * * File: HvTypes.h * Description: HostVar argument types for Parser * Language: C++ * // @@@ START COPYRIGHT @@@ // // Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you 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. // // @@@ END COPYRIGHT @@@ * ****************************************************************************** */ #ifndef HVTYPES_H #define HVTYPES_H #include "Collections.h" #include "NAString.h" #include "NAType.h" class HVArgType : public NABasicObject { public: HVArgType(NAString *name, NAType *type) : name_(name), type_(type), useCount_(0), intoCount_(0) {} const NAString *getName() const { return name_; } const NAType *getType() const { return type_; } NAType *getType() { return type_; } Int32 &useCount() { return useCount_; } Int32 &intoCount() { return intoCount_; } // Methods needed for NAKeyLookup collections template const NAString *getKey() const { return name_; } NABoolean operator==(const HVArgType &other) { return *getName() == *other.getName() && *getType() == *other.getType(); } private: NAString *name_; NAType *type_; Int32 useCount_; Int32 intoCount_; }; class HVArgTypeLookup : public NAKeyLookup<NAString,HVArgType> { public: #define HVARGTYPELKP_INIT_SIZE 29 HVArgTypeLookup(CollHeap *h) : NAKeyLookup<NAString,HVArgType> (HVARGTYPELKP_INIT_SIZE, NAKeyLookupEnums::KEY_INSIDE_VALUE, h) {} ~HVArgTypeLookup() { clearAndDestroy(); } private: }; #endif // HVTYPES_H
27.916667
78
0.641365
077a3df23e88bcf9c925ddebc86d5a05e1105be4
4,332
c
C
stm32/i2c.c
VilocNV/basicmac
981b73abf2dfc6b9570a0ec4075cac736191cdd6
[ "BSD-3-Clause" ]
80
2019-04-30T23:21:12.000Z
2021-08-30T11:01:34.000Z
stm32/i2c.c
VilocNV/basicmac
981b73abf2dfc6b9570a0ec4075cac736191cdd6
[ "BSD-3-Clause" ]
19
2019-05-09T13:24:13.000Z
2021-07-21T21:50:30.000Z
stm32/i2c.c
mkuyper/basicmac
2d2f247a2853a5eeb31b4044978eb5bf198947e3
[ "BSD-3-Clause" ]
42
2019-04-30T17:45:30.000Z
2021-09-23T01:08:28.000Z
// Copyright (C) 2016-2019 Semtech (International) AG. All rights reserved. // // This file is subject to the terms and conditions defined in file 'LICENSE', // which is part of this source code package. #include "peripherals.h" #ifdef BRD_I2C #if BRD_I2C == 1 #define I2Cx I2C1 #define I2Cx_enable() do { RCC->APB1ENR |= RCC_APB1ENR_I2C1EN; } while (0) #define I2Cx_disable() do { RCC->APB1ENR &= ~RCC_APB1ENR_I2C1EN; } while (0) #define I2Cx_IRQn I2C1_IRQn #else #error "Unsupported I2C peripheral" #endif static struct { unsigned int wlen; unsigned char* wptr; unsigned int rlen; unsigned char* rptr; osjob_t* job; osjobcb_t cb; int* pstatus; } xfr; static struct { int status; osjob_t job; i2c_cb cb; } xfr2; static void i2c_stop (int status) { // generate stop condition I2Cx->CR2 |= I2C_CR2_STOP; // disable interrupts in NVIC NVIC_DisableIRQ(I2Cx_IRQn); // disable interrupts/peripheral I2Cx->CR1 = 0; // reconfigure GPIOs CFG_PIN_DEFAULT(GPIO_I2C_SCL); CFG_PIN_DEFAULT(GPIO_I2C_SDA); // disable peripheral clock I2Cx_disable(); // schedule callback *(xfr.pstatus) = status; if (xfr.job != NULL) { os_setCallback(xfr.job, xfr.cb); } else { xfr.cb(NULL); } // re-enable sleep hal_clearMaxSleep(HAL_SLEEP_S0); } static void i2c_start (int addr) { // enable peripheral clock I2Cx_enable(); // set timing I2Cx->TIMINGR = 0x40101A22; // from CubeMX tool; t_rise=t_fall=50ns, 100kHz // start I2C I2Cx->CR1 |= I2C_CR1_PE; // setup slave address I2Cx->CR2 = (I2Cx->CR2 & ~I2C_CR2_SADD) | (addr & I2C_CR2_SADD); // setup GPIOs CFG_PIN_AF(GPIO_I2C_SCL, GPIOCFG_OSPEED_40MHz | GPIOCFG_OTYPE_OPEN | GPIOCFG_PUPD_NONE); CFG_PIN_AF(GPIO_I2C_SDA, GPIOCFG_OSPEED_40MHz | GPIOCFG_OTYPE_OPEN | GPIOCFG_PUPD_NONE); // disable sleep (keep clock at full speed during transfer hal_setMaxSleep(HAL_SLEEP_S0); // enable interrupts in NVIC NVIC_EnableIRQ(I2Cx_IRQn); } static void i2c_cont (void) { if (xfr.wlen) { // calculate length; TODO: handle >255 int n = xfr.wlen & 0xff; xfr.wlen -= n; // set direction & number of bytes I2Cx->CR2 = (I2Cx->CR2 & ~(I2C_CR2_RD_WRN | I2C_CR2_NBYTES)) | (n << 16); // enable interrupts I2Cx->CR1 = (I2Cx->CR1 & ~0xfe) | I2C_CR1_TXIE | I2C_CR1_TCIE | I2C_CR1_NACKIE | I2C_CR1_ERRIE; // start TX I2Cx->CR2 |= I2C_CR2_START; } else if (xfr.rlen) { // calculate length; TODO: handle >255 int n = xfr.rlen & 0xff; xfr.rlen -= n; // set direction & number of bytes I2Cx->CR2 = (I2Cx->CR2 & ~(I2C_CR2_RD_WRN | I2C_CR2_NBYTES)) | I2C_CR2_RD_WRN | (n << 16); // enable interrupts I2Cx->CR1 = (I2Cx->CR1 & ~0xfe) | I2C_CR1_RXIE | I2C_CR1_TCIE | I2C_CR1_NACKIE | I2C_CR1_ERRIE; // start RX I2Cx->CR2 |= I2C_CR2_START; } else { // done i2c_stop(I2C_OK); } } void i2c_irq (void) { unsigned int isr = I2Cx->ISR; if (isr & I2C_ISR_NACKF) { // NACK detected, transfer failed! i2c_stop(I2C_NAK); } else if (isr & I2C_ISR_TC) { // transfer complete, move on i2c_cont(); } else if (isr & I2C_ISR_TXIS) { // write next byte I2Cx->TXDR = *xfr.wptr++; } else if (isr & I2C_ISR_RXNE) { // next byte received *xfr.rptr++ = I2Cx->RXDR; } else { hal_failed(); // XXX } } static void i2c_timeout (osjob_t* job) { i2c_abort(); } void i2c_xfer_ex (unsigned int addr, unsigned char* buf, unsigned int wlen, unsigned int rlen, ostime_t timeout, osjob_t* job, osjobcb_t cb, int* pstatus) { // setup xfr structure xfr.wlen = wlen; xfr.rlen = rlen; xfr.wptr = xfr.rptr = buf; xfr.job = job; xfr.cb = cb; xfr.pstatus = pstatus; *xfr.pstatus = I2C_BUSY; // set timeout if (timeout) { os_setTimedCallback(job, os_getTime() + timeout, i2c_timeout); } // prepare peripheral i2c_start(addr); // start actual transfer i2c_cont(); } static void i2cfunc (osjob_t* j) { xfr2.cb(xfr2.status); } void i2c_xfer (unsigned int addr, unsigned char* buf, unsigned int wlen, unsigned int rlen, i2c_cb cb, ostime_t timeout) { xfr2.cb = cb; i2c_xfer_ex(addr, buf, wlen, rlen, timeout, &xfr2.job, i2cfunc, &xfr2.status); } void i2c_abort (void) { hal_disableIRQs(); i2c_stop(I2C_ABORT); hal_enableIRQs(); } #endif
26.740741
122
0.661127
35bed63a2e124a37125de796f07a991e7735a185
1,426
c
C
usaco/milk2.c
KuleshVandan/IOI-PRAC
9f35e8f738bd8dd1e8116173e67ab27902e26756
[ "MIT" ]
1
2021-06-19T18:49:44.000Z
2021-06-19T18:49:44.000Z
usaco/milk2.c
KuleshVandan/IOI-PRAC
9f35e8f738bd8dd1e8116173e67ab27902e26756
[ "MIT" ]
null
null
null
usaco/milk2.c
KuleshVandan/IOI-PRAC
9f35e8f738bd8dd1e8116173e67ab27902e26756
[ "MIT" ]
1
2017-03-27T14:08:34.000Z
2017-03-27T14:08:34.000Z
/* ID: argh PROG: milk2 LANG: C */ #include <stdio.h> #include <stdlib.h> #define MAXLEN 5000 void quick_sort(int A[][2], int N); int main(void) { FILE *fin = fopen("milk2.in", "r"); FILE *fout = fopen("milk2.out", "w"); int N; fscanf(fin, "%d", &N); int timings[MAXLEN][2]; // [k][0] is start, [k][1] is end for(int i = 0; i < N; i++) { fscanf(fin, "%d %d", &timings[i][0], &timings[i][1]); } quick_sort(timings, N); int maxMilk = 0; int minMilk = 0; int prevMax = 0; int startMilk = timings[0][0]; for(int i = 0; i < N - 1; i++) { if(timings[i][1] - startMilk > maxMilk) maxMilk = timings[i][1] - startMilk; if(timings[i][1] > prevMax) prevMax = timings[i][1]; if(timings[i + 1][0] > prevMax) { startMilk = timings[i + 1][0]; } if(timings[i + 1][0] - prevMax > minMilk) minMilk = timings[i + 1][0] - prevMax; } if(timings[N - 1][1] - startMilk > maxMilk) maxMilk = timings[N - 1][1] - startMilk; fprintf(fout, "%d %d\n", maxMilk, minMilk); return 0; } void quick_sort(int A[][2], int N) { if(N < 2) return; int i, j; int pivot = A[N / 2][0]; for (i = 0, j = N - 1; ; i++, j--) { while (A[i][0] < pivot) i++; while (A[j][0] > pivot) j--; if (i >= j) break; int swapTemp0 = A[i][0]; int swapTemp1 = A[i][1]; A[i][0] = A[j][0]; A[i][1] = A[j][1]; A[j][0] = swapTemp0; A[j][1] = swapTemp1; } quick_sort(A, i); quick_sort(A + i, N - i); }
16.97619
85
0.535063
ef6c687afd470c9b1a256ad790f697810d2082ea
262
h
C
PanoDemo/Models/Cropping.h
DJI-Mobile-SDK/iOS-PanoDemo
8bb2bc1d7ef40318944c474791f889a7d7192e0e
[ "MIT" ]
25
2016-08-11T02:21:49.000Z
2020-12-13T19:38:27.000Z
PanoDemo/Models/Cropping.h
DJI-Mobile-SDK/iOS-PanoDemo
8bb2bc1d7ef40318944c474791f889a7d7192e0e
[ "MIT" ]
4
2017-06-15T10:04:48.000Z
2021-05-25T07:54:16.000Z
PanoDemo/Models/Cropping.h
DJI-Mobile-SDK/iOS-PanoDemo
8bb2bc1d7ef40318944c474791f889a7d7192e0e
[ "MIT" ]
5
2016-09-05T17:29:02.000Z
2019-04-26T16:57:35.000Z
// // Cropping.h // PanoDemo // // Created by DJI on 15/7/31. // Copyright (c) 2015年 DJI. All rights reserved. // #import <Foundation/Foundation.h> @interface Cropping : NSObject + (bool) cropWithMat: (const cv::Mat &)src andResult:(cv::Mat &)dest; @end
16.375
69
0.656489
35a1face317f9640a5c930e18c29c3d8323b21eb
703
c
C
solutions/c/2.c
pwaring/project-euler
b03091e0dbc29f40a6380e9f281fd9ec3a9dacc6
[ "MIT" ]
null
null
null
solutions/c/2.c
pwaring/project-euler
b03091e0dbc29f40a6380e9f281fd9ec3a9dacc6
[ "MIT" ]
null
null
null
solutions/c/2.c
pwaring/project-euler
b03091e0dbc29f40a6380e9f281fd9ec3a9dacc6
[ "MIT" ]
null
null
null
#include <stdio.h> #include <stdlib.h> #include <inttypes.h> #define MAX_SEQUENCE 4000000 int main(void) { // Fibonnaci sequence actually starts 1, 2 but pretending it is 1, 1, 2 allows // us to use the same logic for every step instead of treating the first one // as a special case uint32_t sequence[] = {1, 1, 2}; uint64_t sum = 0; while (sequence[2] <= MAX_SEQUENCE) { if (sequence[2] % 2 == 0) { sum += sequence[2]; } // Move all elements back one space, then recalculate current element sequence[0] = sequence[1]; sequence[1] = sequence[2]; sequence[2] = sequence[0] + sequence[1]; } printf("%" PRIu64 "\n", sum); return EXIT_SUCCESS; }
21.96875
80
0.634424
72497e3d844ad314b3619c1c42fc5d4f4156113a
1,320
c
C
sdk-6.5.20/libs/sdklt/bcmbd/chip/bcm56990_a0/bcm56990_a0_bd_otp.c
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
sdk-6.5.20/libs/sdklt/bcmbd/chip/bcm56990_a0/bcm56990_a0_bd_otp.c
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
sdk-6.5.20/libs/sdklt/bcmbd/chip/bcm56990_a0/bcm56990_a0_bd_otp.c
copslock/broadcom_cpri
8e2767676e26faae270cf485591902a4c50cf0c5
[ "Spencer-94" ]
null
null
null
/*! \file bcm56990_a0_bd_otp.c * * Device-specific functions for accessing OTP parameters */ /* * 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. */ #include <bcmdrd/bcmdrd_symbols.h> #include <bcmbd/bcmbd_otp.h> #include <bcmdrd/chip/bcm56990_a0_cmic_defs.h> #include <bcmbd/chip/bcm56990_a0_cmic_acc.h> #include "bcm56990_a0_drv.h" /* Local defines */ /* Offset in to OTP register array where AVS value is stored */ #define OTP_REG_OFFSET 4 /* Macros to extract AVS voltage value. Value is contained in a single word */ #define AVS_VAL_HIGH_BIT_POS 15 #define AVS_VAL_LOW_BIT_POS 8 /* AVS value is always less than 32 bits */ #define AVS_VAL_NUM_BITS ((AVS_VAL_HIGH_BIT_POS) - (AVS_VAL_LOW_BIT_POS) + 1) #define AVS_VAL_MASK ((AVS_VAL_NUM_BITS < 32) ? \ ((1 << (AVS_VAL_NUM_BITS)) - 1) : ~0) int bcm56990_a0_bd_avs_voltage_get(int unit, uint32_t *val) { DMU_PCU_OTP_CONFIGr_t otp_config; uint32_t reg_val; READ_DMU_PCU_OTP_CONFIGr(unit, OTP_REG_OFFSET, &otp_config); reg_val = DMU_PCU_OTP_CONFIGr_OTP_CONFIGf_GET(otp_config); reg_val >>= AVS_VAL_LOW_BIT_POS; *val = reg_val & AVS_VAL_MASK; return SHR_E_NONE; }
33
134
0.742424
471fcac6ff55dffba2724c5ec3a9c8de68536043
701
h
C
fs/btrfs/xattr.h
fergy/aplit_linux-5
a6ef4cb0e17e1eec9743c064e65f730c49765711
[ "MIT" ]
11
2022-02-05T12:12:43.000Z
2022-03-08T08:09:08.000Z
fs/btrfs/xattr.h
fergy/aplit_linux-5
a6ef4cb0e17e1eec9743c064e65f730c49765711
[ "MIT" ]
3
2021-03-09T04:02:52.000Z
2021-05-15T14:08:02.000Z
fs/btrfs/xattr.h
fergy/aplit_linux-5
a6ef4cb0e17e1eec9743c064e65f730c49765711
[ "MIT" ]
1
2020-11-06T07:32:55.000Z
2020-11-06T07:32:55.000Z
/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2007 Red Hat. All rights reserved. */ #ifndef BTRFS_XATTR_H #define BTRFS_XATTR_H #include <linux/xattr.h> extern const struct xattr_handler *btrfs_xattr_handlers[]; int btrfs_getxattr(struct inode *inode, const char *name, void *buffer, size_t size); int btrfs_setxattr(struct btrfs_trans_handle *trans, struct inode *inode, const char *name, const void *value, size_t size, int flags); ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size); int btrfs_xattr_security_init(struct btrfs_trans_handle *trans, struct inode *inode, struct inode *dir, const struct qstr *qstr); #endif
28.04
74
0.731812
54bfd89009a64a3237d276c8c4af72ab26d5f72c
4,137
h
C
LIB_GO_UTILS/GoGameTree.h
gabrielmsantos/go_tools
514c852b49c75f206b4a940f7d46ee0162e146ab
[ "MIT" ]
null
null
null
LIB_GO_UTILS/GoGameTree.h
gabrielmsantos/go_tools
514c852b49c75f206b4a940f7d46ee0162e146ab
[ "MIT" ]
null
null
null
LIB_GO_UTILS/GoGameTree.h
gabrielmsantos/go_tools
514c852b49c75f206b4a940f7d46ee0162e146ab
[ "MIT" ]
null
null
null
#ifndef GOGAMETREE_H #define GOGAMETREE_H #include <boost/multi_index_container.hpp> #include <boost/multi_index/random_access_index.hpp> #include <boost/multi_index/identity.hpp> #include <boost/multi_index/hashed_index.hpp> #include <boost/multi_index/member.hpp> using boost::multi_index_container; using namespace boost::multi_index; struct CompactBoard; class GoGameNode; //=============== Node Entry struct ====================== typedef struct node_entry_t { short m_move; // boost::shared_ptr<GoGameNode > m_node_ptr; GoGameNode * m_node_ptr; node_entry_t(short move, GoGameNode* node):m_move(move), m_node_ptr(node){} } node_entry; //====================================================== /** * Declaring the multi_index_container regarding to the node structure */ /** Tag for accessing by move*/ struct move_code_t{}; typedef multi_index_container< node_entry, indexed_by< random_access<>, hashed_unique<tag <move_code_t>, member <node_entry, short, &node_entry::m_move > > > > node_container_t; /** Creating an index to access through random_access (like Queue) */ typedef node_container_t::nth_index<0>::type random_access_index; /** Creating an index to access by hashed move_code*/ typedef node_container_t::index<move_code_t>::type hashed_code_index; //====================================================== /** Class GoGameNode @description: The class contains : m_move (represents the code of the action took) m_parent (representing its parent node) m_children_container (representing the container for my children) m_compact_board (representing the board state for this node) */ class GoGameNode { public: explicit GoGameNode(short move, CompactBoard* compact_board) :m_move(move), m_parent(NULL), m_compact_board(compact_board) { } void ClearNode(); GoGameNode(const GoGameNode& node_copy); ~GoGameNode(); bool HasChildren() const; GoGameNode* GetChild(short move) const; inline GoGameNode* FirstChild() const { const random_access_index& l_queue_container = m_children_container.get<0>(); const node_entry& l_node = l_queue_container.front(); return l_node.m_node_ptr; } inline void SetParent(GoGameNode* parent) { m_parent = parent; } inline void InsertChild(GoGameNode* child) { child->SetParent(this); random_access_index& l_queue_container = m_children_container.get<0>(); l_queue_container.push_back(node_entry(child->GetMove(),child)); } inline CompactBoard* GetCompactBoard() const { return m_compact_board; } inline short GetMove() const { return m_move; } inline GoGameNode* GetParent() const { return m_parent; } GoGameNode& operator=(GoGameNode& node_copy); GoGameNode* GetNodeInSubTree(short move, CompactBoard* l_compact_board) const; const node_container_t& GetChildrenContainer() const; void PrintSubTree() const; private: void RemoveChildFromContainer(short move); /** The move that created the state represented by compact board If the move is negative then it was made by the white player, otherwise it the black player */ short m_move; GoGameNode* m_parent; node_container_t m_children_container; CompactBoard* m_compact_board; }; //====================================================== class GoGameTree { public: GoGameTree(); GoGameTree(const GoGameTree& tree_copy); ~GoGameTree() { delete m_root; m_root = NULL; m_current_node = NULL; } GoGameTree& operator=(const GoGameTree& tree_copy); inline GoGameNode* GetCurrentNode() const { return m_current_node; } void InsertNewNode(GoGameNode* child); bool TakeBack(GoGameNode **node); bool TakeBack(GoGameNode **node, unsigned short number); void BackToNode(GoGameNode *node); GoGameNode* GetRoot(); private: GoGameNode* m_root; GoGameNode* m_current_node; }; //===================================== #endif // GOGAMETREE_H
23.64
97
0.66715
b0f0b3e0956acec3f3cad0f84487138d98470fdc
9,504
c
C
MyApps/ThinkPwn/ThinkPwn.c
fpmurphy/ThinkPwn
89bddd918745b198e4ff967f43fbcb4a88bd25cb
[ "BSD-2-Clause" ]
5
2017-04-26T16:14:19.000Z
2018-04-23T15:53:48.000Z
MyApps/ThinkPwn/ThinkPwn.c
fpmurphy/ThinkPwn
89bddd918745b198e4ff967f43fbcb4a88bd25cb
[ "BSD-2-Clause" ]
null
null
null
MyApps/ThinkPwn/ThinkPwn.c
fpmurphy/ThinkPwn
89bddd918745b198e4ff967f43fbcb4a88bd25cb
[ "BSD-2-Clause" ]
null
null
null
// // Copyright (c) 2016 Finnbarr P. Murphy. All rights reserved. // // Check SMM Write Access (Based on ThinkPwn code from Dmytro Oleksiuk) // // License: BSD License // #include <Uefi.h> #include <FrameworkSmm.h> #include <Uefi/UefiSpec.h> #include <Guid/GlobalVariable.h> #include <Guid/SmmCommunicate.h> #include <Library/UefiLib.h> #include <Library/ShellCEntryLib.h> #include <Library/ShellLib.h> #include <Library/BaseMemoryLib.h> #include <Library/UefiBootServicesTableLib.h> #include <Library/MemoryAllocationLib.h> #include <Library/IoLib.h> #include <Library/DevicePathLib.h> #include <Protocol/EfiShell.h> #include <Protocol/LoadedImage.h> #include <Protocol/SmmBase.h> #include <Protocol/SmmAccess.h> #define UTILITY_VERSION L"0.1" #undef DEBUG // image name for SystemSmmRuntimeRt UEFI driver #define IMAGE_NAME L"FvFile(7C79AC8C-5E6C-4E3D-BA6F-C260EE7C172E)" // SMM communication data size #define SMM_DATA_SIZE 0x1000 #define MAX_SMRAM_REGIONS 4 #define MAX_HANDLES 0x10 #define MAX_PATH 0x200 #define COMMUNICATE_GUID \ { 0x1279E288, 0x24CD, 0x47E9, {0x96, 0xBA, 0xD7, 0xA3, 0x8C, 0x17, 0xBD, 0x64 }} typedef VOID (* EXPLOIT_HANDLER)(VOID *Context, VOID *Unknown, VOID *Data); typedef struct { VOID *Context; EXPLOIT_HANDLER Handler; } EXPLOIT_STRUCT; // struct addr is EFI_SMM_BASE_PROTOCOL + 0x58 typedef struct { EFI_HANDLE CallbackHandle; VOID *Data; UINTN *DataSize; } COMMUNICATE_STRUCT; UINTN gSmmHandlerExecuted = 0; VOID FireSynchronousSmi( UINT8 Handler, UINT8 Data) { // fire SMI using APMC I/O port IoWrite8((UINTN)0xb3, Data); IoWrite8((UINTN)0xb2, Handler); } VOID SmmHandler( VOID *Context, VOID *Unknown, VOID *Data) { // SMM code executed tellatil gSmmHandlerExecuted += 1; } EFI_STATUS GetImageHandle( CHAR16 *TargetPath, EFI_HANDLE *HandlesList, UINTN *HandlesListCount) { EFI_STATUS Status = EFI_SUCCESS; EFI_GUID gEfiLoadedImageProtocolGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID; EFI_HANDLE *Buffer = NULL; UINTN BufferSize = 0; UINTN HandlesFound = 0; EFI_LOADED_IMAGE *LoadedImage = NULL; CHAR16 *Path = NULL; // determinate handles buffer size Status = gBS->LocateHandle( ByProtocol, &gEfiLoadedImageProtocolGuid, NULL, &BufferSize, NULL); if (Status != EFI_BUFFER_TOO_SMALL) { Print(L"ERROR: LocateHandle [%d]\n", Status); return Status; } Buffer = AllocateZeroPool(BufferSize); if (!Buffer) { Print(L"ERROR: AllocatePool\n"); return Status; } // get image handles list Status = gBS->LocateHandle( ByProtocol, &gEfiLoadedImageProtocolGuid, NULL, &BufferSize, Buffer); if (EFI_ERROR(Status)) { Print(L"ERROR: LocateHandle [%d]\n", Status); FreePool(Buffer); return Status; } for (int i = 0; i < BufferSize / sizeof(EFI_HANDLE); i++) { LoadedImage = NULL; // get loaded image protocol instance for given image handle Status = gBS->HandleProtocol( Buffer[i], &gEfiLoadedImageProtocolGuid, (VOID *)&LoadedImage); if (Status == EFI_SUCCESS) { // get and check image path if ((Path = ConvertDevicePathToText(LoadedImage->FilePath, TRUE, TRUE))) { if (!StrCmp(Path, TargetPath)) { if (HandlesFound + 1 < *HandlesListCount) { HandlesList[HandlesFound] = Buffer[i]; HandlesFound++; } else { // handle list is full Status = EFI_BUFFER_TOO_SMALL; } } FreePool(Path); if (Status != EFI_SUCCESS) { break; } } } } FreePool(Buffer); if (Status == EFI_SUCCESS) { *HandlesListCount = HandlesFound; } return Status; } EFI_STATUS TrySmmExploit(EXPLOIT_HANDLER Handler) { EFI_STATUS Status = EFI_SUCCESS; EFI_GUID gEfiSmmBaseProtocolGuid = EFI_SMM_BASE_PROTOCOL_GUID; EFI_GUID gSmmCommunicateHeaderGuid = SMM_COMMUNICATE_HEADER_GUID; EFI_SMM_BASE_PROTOCOL *SmmBase = NULL; EXPLOIT_STRUCT Struct; UINTN DataSize = SMM_DATA_SIZE; EFI_SMM_COMMUNICATE_HEADER *Data = NULL; EFI_HANDLE HandlesList[MAX_HANDLES]; UINTN HandlesListCount = MAX_HANDLES; EFI_HANDLE ImageHandle; ZeroMem(HandlesList, sizeof(HandlesList)); gSmmHandlerExecuted = 0; // locate SMM base protocol Status = gBS->LocateProtocol( &gEfiSmmBaseProtocolGuid, NULL, (VOID *) &SmmBase); if (EFI_ERROR(Status)) { Print(L"ERROR: Unable to locate SMM base protocol [%d]\n", Status); return Status; } #ifdef DEBUG Print(L"SMM base protocol is at 0x%llx\n", SmmBase); #endif // allocate memory for SMM communication data Data = AllocateZeroPool( DataSize); if (!Data) { Print(L"ERROR: AllocateZeroPool\n"); return Status; } #ifdef DEBUG Print(L"Buffer for SMM communicate call is allocated at 0x%llx\n", Data); #endif Print(L"Image handles for %S\n", IMAGE_NAME); Status = GetImageHandle(IMAGE_NAME, HandlesList, &HandlesListCount); if (EFI_ERROR(Status)) { Print(L"ERROR: GetImageHandle [%d]`\n", Status); goto _END; } if (HandlesListCount == 0) { Print(L"ERROR: No image handles found\n"); goto _END; } // try all image handles found. Break on success. for (int i = 0; i < HandlesListCount && gSmmHandlerExecuted == 0; i++) { ImageHandle = HandlesList[i]; // set up data header DataSize = SMM_DATA_SIZE; ZeroMem(Data, DataSize); CopyMem(&Data->HeaderGuid, &gSmmCommunicateHeaderGuid, (UINTN)sizeof(EFI_GUID)); Data->MessageLength = DataSize - sizeof(EFI_SMM_COMMUNICATE_HEADER); // set up data body Struct.Context = NULL; Struct.Handler = Handler; *(VOID **)((UINT8 *)Data + 0x20) = (VOID *)&Struct; // queue SMM communication call Status = SmmBase->Communicate( SmmBase, ImageHandle, Data, &DataSize); // process pending SMM communication calls FireSynchronousSmi(0, 0); Print(L" * Handle: 0x%llx SmmBase->Communicate returned status: %d data size: 0x%x\n", ImageHandle, Status, DataSize); } if (gSmmHandlerExecuted > 0) { Status = EFI_SUCCESS; } else { Status = EFI_UNSUPPORTED; } _END: if (Data) { FreePool(Data); } return Status; } VOID Usage(CHAR16 *Str) { Print(L"Usage: %s [-V|--version]\n", Str); } INTN EFIAPI ShellAppMain(UINTN Argc, CHAR16 **Argv) { EFI_STATUS Status = EFI_SUCCESS; EFI_GUID gEfiSmmAccessProtocolGuid = EFI_SMM_ACCESS_PROTOCOL_GUID; EFI_SMM_ACCESS_PROTOCOL *SmmAccess = NULL; EFI_SMRAM_DESCRIPTOR SmramMap[MAX_SMRAM_REGIONS]; UINTN SmramMapSize = sizeof(SmramMap); if (Argc == 2) { if (!StrCmp(Argv[1], L"--version") || !StrCmp(Argv[1], L"-V")) { Print(L"Version: %s\n", UTILITY_VERSION); return Status; } if (!StrCmp(Argv[1], L"--help") || !StrCmp(Argv[1], L"-h") || !StrCmp(Argv[1], L"-?")) { Usage(Argv[0]); return Status; } } // catchall for all other cases if (Argc > 1) { Usage(Argv[0]); return Status; } // locate SMM access protocol Status = gBS->LocateProtocol( &gEfiSmmAccessProtocolGuid, NULL, (VOID*) &SmmAccess); if (EFI_ERROR (Status)) { Print(L"ERROR: Unable to locate SMM access protocol [%d]\n", Status); return Status; } #ifdef DEBUG Print(L"SMM access protocol is at 0x%llx\n", SmmAccess); #endif // get SMRAM regions information Status = SmmAccess->GetCapabilities( SmmAccess, &SmramMapSize, SmramMap); if (EFI_ERROR (Status)) { Print(L"ERROR: GetCapabilities [%d]\n", Status); return Status; } Print(L"Available SMRAM regions:\n"); for (int i = 0; i < SmramMapSize / sizeof(EFI_SMRAM_DESCRIPTOR); i++) { Print(L" * 0x%.8llx:0x%.8llx\n", SmramMap[i].PhysicalStart, SmramMap[i].PhysicalStart + SmramMap[i].PhysicalSize - 1); } // Try the exploit if (TrySmmExploit(SmmHandler) == EFI_SUCCESS) { Print(L"\nEXPLOIT SUCCEEDED\n"); } else { Print(L"\nEXPLOIT FAILED\n"); } return EFI_SUCCESS; }
28.035398
108
0.565867
b04f79fbb4f3abd6260e8cc35a745cdf44543aff
657
h
C
Bin/GLFunctions/Misc/OES_draw_buffers_indexed_Include.h
vinjn/glintercept
f82166d3a774bfb02459f6b3ae2a03d4c9eaf64f
[ "MIT" ]
468
2015-04-13T19:03:57.000Z
2022-03-23T00:11:24.000Z
Bin/GLFunctions/Misc/OES_draw_buffers_indexed_Include.h
vinjn/glintercept
f82166d3a774bfb02459f6b3ae2a03d4c9eaf64f
[ "MIT" ]
12
2015-05-25T11:15:21.000Z
2020-10-26T02:46:50.000Z
Bin/GLFunctions/Misc/OES_draw_buffers_indexed_Include.h
vinjn/glintercept
f82166d3a774bfb02459f6b3ae2a03d4c9eaf64f
[ "MIT" ]
67
2015-04-22T13:22:48.000Z
2022-03-05T01:11:02.000Z
#define GLI_INCLUDE_GL_OES_DRAW_BUFFERS_INDEXED void glEnableiOES(GLenum[Main] target, GLuint index); void glDisableiOES(GLenum[Main] target, GLuint index); void glBlendEquationiOES(GLuint buf, GLenum[Main] mode); void glBlendEquationSeparateiOES(GLuint buf, GLenum[Main] modeRGB, GLenum[Main] modeAlpha); void glBlendFunciOES(GLuint buf, GLenum[Main] src, GLenum[Main] dst); void glBlendFuncSeparateiOES(GLuint buf, GLenum[Main] srcRGB, GLenum[Main] dstRGB, GLenum[Main] srcAlpha, GLenum[Main] dstAlpha); void glColorMaskiOES(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); GLboolean glIsEnablediOES(GLenum[Main] target, GLuint index);
59.727273
129
0.811263
b8471e06f5e8f274840b6eab2f6f800b3454f5d5
252
h
C
src/I2C.h
coryking/MotionController
56445b4faea2f044e256cf2414021cadb62b5d67
[ "BSD-2-Clause" ]
2
2018-07-22T12:07:09.000Z
2021-07-15T15:46:06.000Z
src/I2C.h
coryking/MotionController
56445b4faea2f044e256cf2414021cadb62b5d67
[ "BSD-2-Clause" ]
null
null
null
src/I2C.h
coryking/MotionController
56445b4faea2f044e256cf2414021cadb62b5d67
[ "BSD-2-Clause" ]
null
null
null
// // Created by Cory King on 5/26/17. // #ifndef MOTIONCONTROLLER_I2C_H #define MOTIONCONTROLLER_I2C_H #include <Arduino.h> #include <Wire.h> #include "Pins.h" void setupI2C() { Wire.begin(SDA_PIN, SCL_PIN); } #endif //MOTIONCONTROLLER_I2C_H
14
35
0.718254
e6fb70bbeee3422dddf8b3786550888973575d32
462
h
C
FlameCrowdfunding/FlameCrowdfunding/Classes/UI/Public/View/FCPublicCell.h
JimmyOu/CrowFunding
eab7c7dfe02e93c709258d943b1a2bb53f6e23cf
[ "Apache-2.0" ]
null
null
null
FlameCrowdfunding/FlameCrowdfunding/Classes/UI/Public/View/FCPublicCell.h
JimmyOu/CrowFunding
eab7c7dfe02e93c709258d943b1a2bb53f6e23cf
[ "Apache-2.0" ]
null
null
null
FlameCrowdfunding/FlameCrowdfunding/Classes/UI/Public/View/FCPublicCell.h
JimmyOu/CrowFunding
eab7c7dfe02e93c709258d943b1a2bb53f6e23cf
[ "Apache-2.0" ]
null
null
null
// // FCPublicCell.h // FlameCrowdfunding // // Created by JimmyOu on 16/5/22. // Copyright © 2016年 JimmyOu. All rights reserved. // #import <UIKit/UIKit.h> @class FCFundingItem; //@class FCPublicCellLayout; @interface FCPublicCell : UITableViewCell @property (nonatomic, strong) FCFundingItem *fundingItem; @property (nonatomic, copy) void(^tapFundingDetailBlock)(); //点击众筹详情 @property (nonatomic, copy) void(^tapCommentsDetailBlock)(); //点击评论详情 @end
27.176471
71
0.735931
e63c39c94f88e86ac53179fa4d8d6790b5617ad0
297
h
C
LookNovel/classes/base/controller/LNNavigationViewController.h
wangyingbo/readNovel
37fbbc557123c7dffdddc683cb6f7bc20be7d696
[ "MIT" ]
178
2019-05-28T03:21:58.000Z
2022-03-28T02:39:14.000Z
LookNovel/classes/base/controller/LNNavigationViewController.h
Subery/readNovel
0afda0f4ce24c80248b96d2013f4d337af403342
[ "MIT" ]
7
2019-05-30T05:54:23.000Z
2021-07-30T09:29:51.000Z
LookNovel/classes/base/controller/LNNavigationViewController.h
Subery/readNovel
0afda0f4ce24c80248b96d2013f4d337af403342
[ "MIT" ]
61
2019-05-28T03:24:24.000Z
2022-03-18T03:33:30.000Z
// // LNNavigationViewController.h // LookNovel // // Created by wangchengshan on 2019/5/10. // Copyright © 2019 wcs Co.,ltd. All rights reserved. // #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN @interface LNNavigationViewController : UINavigationController @end NS_ASSUME_NONNULL_END
16.5
62
0.760943
525f3f19d0f066fb05eb11b0adf17cd98c343091
464
h
C
onlineC/Classes/Model/UserChat/OCSUserChatModel.h
Zydhjx/onlineC
2d8cbcabbaba7ee60b046fab84efac2c7fa002a1
[ "MIT" ]
null
null
null
onlineC/Classes/Model/UserChat/OCSUserChatModel.h
Zydhjx/onlineC
2d8cbcabbaba7ee60b046fab84efac2c7fa002a1
[ "MIT" ]
null
null
null
onlineC/Classes/Model/UserChat/OCSUserChatModel.h
Zydhjx/onlineC
2d8cbcabbaba7ee60b046fab84efac2c7fa002a1
[ "MIT" ]
null
null
null
// // OCSUserChatModel.h // onlineC // // Created by zyd on 2018/7/16. // #import "OCSModel.h" @interface OCSUserChatModel : OCSModel @property (copy, nonatomic) NSString *chatDetailId; // 用户输入类型 @property (copy, nonatomic) NSString *contentType; // 用于关联类和contentType的方法 + (void)setValue:(id)value forKey:(NSString *)key; - (instancetype)initWithDictionary:(NSDictionary *)dictionary; + (instancetype)modelWithDictionary:(NSDictionary *)dictionary; @end
19.333333
63
0.741379
509dd688663c1e693451b20793f7aac1b516929b
740
c
C
c-lib/tests/basic-types.c
archshift/C-Tycat
d91471642cabee153617602e492eaf68d78c08a3
[ "MIT" ]
3
2020-03-03T08:23:37.000Z
2021-01-25T23:05:14.000Z
c-lib/tests/basic-types.c
archshift/C-Tycat
d91471642cabee153617602e492eaf68d78c08a3
[ "MIT" ]
null
null
null
c-lib/tests/basic-types.c
archshift/C-Tycat
d91471642cabee153617602e492eaf68d78c08a3
[ "MIT" ]
1
2020-03-07T02:34:22.000Z
2020-03-07T02:34:22.000Z
/* Tycat a basic types. Copyright (C) 2018, Guillaume Gonnet This project is under the MIT License */ #include <stdio.h> #include <string.h> #include <ctycat.h> struct Container { const char *string; char c; _Bool boolean; int integer; char **array; char fixed_str[20]; }; int main() { double val = 42.1337; ctycat(val); char strz[] = "This is a string!"; // ctycat(strz); struct Container c = { .string = "Hello, my name is Guillaume.", .integer = 42, .boolean = 47, .fixed_str = "A short text" }; struct Container *ptr = &c; printf("Size of structure : %lu\n", sizeof(struct Container)); ctycat(ptr); // ctycat(ptr->integer); }
15.416667
66
0.581081
f732a520cd2742615fe5cd08257d9950cb3f79d8
5,620
h
C
rpmio/argv.h
devzero2000/RPM5
e74e9f9f745047f5dde783820367ec9c018baee9
[ "Apache-2.0" ]
2
2015-10-27T10:14:57.000Z
2019-01-14T07:48:54.000Z
rpmio/argv.h
avokhmin/RPM5
c0048ec5c5804e819c406b9d4912d55338cc3566
[ "Apache-2.0" ]
null
null
null
rpmio/argv.h
avokhmin/RPM5
c0048ec5c5804e819c406b9d4912d55338cc3566
[ "Apache-2.0" ]
4
2017-05-12T05:33:17.000Z
2019-03-17T22:29:33.000Z
#ifndef _H_ARGV_ #define _H_ARGV_ /** \ingroup rpmio * \file rpmio/argv.h */ typedef const char * ARGstr_t; typedef ARGstr_t * ARGV_t; typedef unsigned int * ARGint_t; struct ARGI_s { unsigned nvals; ARGint_t vals; }; typedef struct ARGI_s * ARGI_t; #ifdef __cplusplus extern "C" { #endif /** * Print argv array elements. * @param msg output message prefix (or NULL) * @param argv argv array * @param fp output file handle (NULL uses stderr) */ void argvPrint(/*@null@*/ const char * msg, /*@null@*/ ARGV_t argv, /*@null@*/ FILE * fp) /*@globals fileSystem @*/ /*@modifies *fp, fileSystem @*/; /** * Destroy an argi array. * @param argi argi array * @return NULL always */ /*@null@*/ ARGI_t argiFree(/*@only@*/ /*@null@*/ ARGI_t argi) /*@modifies argi @*/; /** * Destroy an argv array. * @param argv argv array * @return NULL always */ /*@null@*/ ARGV_t argvFree(/*@only@*/ /*@null@*/ ARGV_t argv) /*@modifies argv @*/; /** * Return no. of elements in argi array. * @param argi argi array * @return no. of elements */ int argiCount(/*@null@*/ const ARGI_t argi) /*@*/; /** * Return data from argi array. * @param argi argi array * @return argi array data address */ /*@null@*/ ARGint_t argiData(/*@null@*/ ARGI_t argi) /*@*/; /** * Return no. of elements in argv array. * @param argv argv array * @return no. of elements */ int argvCount(/*@null@*/ ARGV_t argv) /*@*/; /** * Return data from argv array. * @param argv argv array * @return argv array data address */ /*@null@*/ ARGV_t argvData(/*@null@*/ ARGV_t argv) /*@*/; /** * Compare argi elements (qsort/bsearch). * @param a 1st instance address * @param b 2nd instance address * @return result of comparison */ /*@-exportlocal@*/ int argiCmp(ARGint_t * a, ARGint_t * b) /*@*/; /*@=exportlocal@*/ /** * Compare argv elements using strcmp (qsort/bsearch). * @param a 1st instance address * @param b 2nd instance address * @return result of comparison */ /*@-exportlocal@*/ int argvCmp(ARGstr_t * a, ARGstr_t * b) /*@*/; /*@=exportlocal@*/ /** * Compare argv elements using strcasecmp (qsort/bsearch). * @param a 1st instance address * @param b 2nd instance address * @return result of comparison */ int argvStrcasecmp(ARGstr_t * a, ARGstr_t * b) /*@*/; #if defined(RPM_VENDOR_OPENPKG) /* wildcard-matching-arbitrary-tagnames */ /** * Wildcard-match argv arrays using fnmatch. * @param a 1st instance address * @param b 2nd instance address * @return result of comparison */ int argvFnmatch(ARGstr_t * a, ARGstr_t * b) /*@*/; /** * Wildcard-match argv arrays using fnmatch (case-insensitive). * @param a 1st instance address * @param b 2nd instance address * @return result of comparison */ int argvFnmatchCasefold(ARGstr_t * a, ARGstr_t * b) /*@*/; #endif /** * Sort an argi array. * @param argi argi array * @param compar strcmp-like comparison function, or NULL for argiCmp() * @return 0 always */ int argiSort(ARGI_t argi, int (*compar)(ARGint_t *, ARGint_t *)) /*@*/; /** * Sort an argv array. * @param argv argv array * @param compar strcmp-like comparison function, or NULL for argvCmp() * @return 0 always */ int argvSort(ARGV_t argv, int (*compar)(ARGstr_t *, ARGstr_t *)) /*@modifies *argv @*/; /** * Find an element in an argv array. * @param argv argv array * @param val string to find * @param compar strcmp-like comparison function, or NULL for argvCmp() * @return found string (NULL on failure) */ /*@dependent@*/ /*@null@*/ ARGV_t argvSearch(ARGV_t argv, ARGstr_t val, int (*compar)(ARGstr_t *, ARGstr_t *)) /*@*/; #if defined(RPM_VENDOR_OPENPKG) /* wildcard-matching-arbitrary-tagnames */ /** * Find an element in an argv array (via linear searching and just match/no-match comparison). * @param argv argv array * @param val string to find * @param compar strcmp-like comparison function, or NULL for argvCmp() * @return found string (NULL on failure) */ /*@dependent@*/ /*@null@*/ ARGV_t argvSearchLinear(ARGV_t argv, ARGstr_t val, int (*compar)(ARGstr_t *, ARGstr_t *)) /*@*/; #endif /** * Add an int to an argi array. * @retval *argip argi array * @param ix argi array index (or -1 to append) * @param val int arg to add * @return 0 always */ int argiAdd(/*@out@*/ ARGI_t * argip, int ix, int val) /*@modifies *argip @*/; /** * Add a string to an argv array. * @retval *argvp argv array * @param val string arg to append * @return 0 always */ int argvAdd(/*@out@*/ ARGV_t * argvp, ARGstr_t val) /*@modifies *argvp @*/; /** * Append one argv array to another. * @retval *argvp argv array * @param av argv array to append (NULL does nothing) * @return 0 always */ int argvAppend(/*@out@*/ ARGV_t * argvp, /*@null@*/ ARGV_t av) /*@modifies *argvp @*/; /** * Split a string into an argv array. * @retval *argvp argv array * @param str string arg to split * @param seps separator characters (NULL is C isspace() chars) * @return 0 always */ int argvSplit(ARGV_t * argvp, const char * str, /*@null@*/ const char * seps) /*@modifies *argvp @*/; /** * Concatenate an argv array into a string. * @param argv argv array * @param sep arg separator * @return concatenated string */ /*@only@*/ char * argvJoin(ARGV_t argv, char sep) /*@*/; /** * Read lines into an argv array. * @retval *argvp argv array * @param fd rpmio FD_t (NULL uses stdin) * @return 0 on success */ int argvFgets(ARGV_t * argvp, void * fd) /*@globals fileSystem@*/ /*@modifies *argvp, fd, fileSystem @*/; #ifdef __cplusplus } #endif #endif /* _H_ARGV_ */
23.032787
94
0.651423
5428af3a351ea02ddba620b41ce3876fa11ed352
1,324
c
C
src_corewar/op_aff.c
ZackChOfficial/corewar
f1f3c5a9cea873d84a69d3d1da09e50c649a7e24
[ "MIT" ]
null
null
null
src_corewar/op_aff.c
ZackChOfficial/corewar
f1f3c5a9cea873d84a69d3d1da09e50c649a7e24
[ "MIT" ]
null
null
null
src_corewar/op_aff.c
ZackChOfficial/corewar
f1f3c5a9cea873d84a69d3d1da09e50c649a7e24
[ "MIT" ]
null
null
null
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* aff.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: zchatoua <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/07/11 19:38:05 by zchatoua #+# #+# */ /* Updated: 2019/07/29 15:47:45 by zchatoua ### ########.fr */ /* */ /* ************************************************************************** */ #include "./includes/corewar.h" void ft_aff(t_vm *vm, t_process *process) { int8_t arg; int8_t reg; arg = get_one(vm->arena + ((process->current_position + 1) % MEM_SIZE)); if (arg == 64) { reg = get_one(vm->arena + ((process->current_position + 2) % MEM_SIZE)); if (reg > 0 && reg <= 16) ft_putchar((char)process->registers[reg - 1]); process->step_over = 3; } else process->step_over = skip_args(arg, 1, 4); }
42.709677
80
0.273414
2d8f4a49a7d87d1dd3a09262631525547843ca1c
12,591
h
C
impl/src/tooling/icpp/interpreter/op_eval.h
brakmic/BosqueLanguage
649c7698cebe82366c957847144515909e68aa1a
[ "MIT" ]
null
null
null
impl/src/tooling/icpp/interpreter/op_eval.h
brakmic/BosqueLanguage
649c7698cebe82366c957847144515909e68aa1a
[ "MIT" ]
null
null
null
impl/src/tooling/icpp/interpreter/op_eval.h
brakmic/BosqueLanguage
649c7698cebe82366c957847144515909e68aa1a
[ "MIT" ]
1
2021-03-15T16:07:51.000Z
2021-03-15T16:07:51.000Z
//------------------------------------------------------------------------------------------------------- // Copyright (C) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. //------------------------------------------------------------------------------------------------------- #pragma once #include "common.h" #include "runtime/environment.h" class EvaluatorFrame { public: #ifdef BSQ_DEBUG_BUILD const std::string* dbg_file; const std::string* dbg_function; int64_t dbg_prevline; int64_t dbg_line; #endif StorageLocationPtr* argsbase; uint8_t* scalarbase; uint8_t* mixedbase; BSQBool* argmask; BSQBool* masksbase; const std::vector<InterpOp*>* ops; std::vector<InterpOp*>::const_iterator cpos; std::vector<InterpOp*>::const_iterator epos; }; class Evaluator { private: EvaluatorFrame* cframe; int32_t cpos; static EvaluatorFrame g_callstack[BSQ_MAX_STACK]; #ifdef BSQ_DEBUG_BUILD inline void pushFrame(const std::string* dbg_file, const std::string* dbg_function, StorageLocationPtr* argsbase, uint8_t* scalarbase, uint8_t* mixedbase, BSQBool* argmask, BSQBool* masksbase, const std::vector<InterpOp*>* ops) { auto cf = Evaluator::g_callstack + this->cpos++; cf->dbg_file = dbg_file; cf->dbg_function = dbg_function; cf->dbg_prevline = 0; cf->argsbase = argsbase; cf->scalarbase = scalarbase; cf->mixedbase = mixedbase; cf->argmask = argmask; cf->masksbase = masksbase; cf->ops = ops; cf->cpos = cf->ops->cbegin(); cf->epos = cf->ops->cend(); cf->dbg_line = (*cf->cpos)->sinfo.line; } #else inline void pushFrame(StorageLocationPtr* argsbase, uint8_t* scalarbase, uint8_t* mixedbase, BSQBool* argmask, BSQBool* masksbase, const std::vector<InterpOp*>* ops) { auto cf = Evaluator::g_callstack + cpos++; cf->argsbase = argsbase; cf->scalarbase = scalarbase; cf->mixedbase = mixedbase; cf->argmask = argmask; cf->masksbase = masksbase; cf->ops = ops; cf->cpos = cf->ops->cbegin(); cf->epos = cf->ops->cend(); } #endif inline void popFrame() { this->cpos--; } #ifdef BSQ_DEBUG_BUILD const std::string* getCurrentFile() { return cframe->dbg_file; } const std::string* getCurrentFunction() { return cframe->dbg_function; } int64_t getPrevLine() { return cframe->dbg_prevline; } int64_t getCurrentLine() { return cframe->dbg_line; } #else const std::string* getCurrentFile() { return nullptr; } const std::string* getCurrentfunction() { return nullptr; } int64_t getPrevLine() { return -1; } int64_t getCurrentLine() { return 0; } #endif inline InterpOp* getCurrentOp() { return *this->cframe->cpos; } inline bool hasMoreOps() const { return this->cframe->cpos != this->cframe->epos; } inline InterpOp* advanceCurrentOp(uint32_t offset) { this->cframe->cpos += offset; #ifdef BSQ_DEBUG_BUILD this->cframe->dbg_prevline = this->cframe->dbg_line; this->cframe->dbg_line = (*this->cframe->cpos)->sinfo.line; #endif return *this->cframe->cpos; } inline InterpOp* advanceCurrentOp() { this->cframe->cpos++; #ifdef BSQ_DEBUG_BUILD this->cframe->dbg_prevline = this->cframe->dbg_line; this->cframe->dbg_line = (*this->cframe->cpos)->sinfo.line; #endif return *this->cframe->cpos; } inline StorageLocationPtr evalConstArgument(Argument arg) { return (StorageLocationPtr)(Environment::g_constantbuffer + arg.location); } inline StorageLocationPtr evalArgument(Argument arg) { if(arg.kind == ArgumentTag::LocalScalar) { return this->cframe->scalarbase + arg.location; } else if(arg.kind == ArgumentTag::LocalMixed) { return this->cframe->mixedbase + arg.location; } else if(arg.kind == ArgumentTag::Argument) { return this->cframe->argsbase[arg.location]; } else { return evalConstArgument(arg); } } inline StorageLocationPtr evalTargetVar(TargetVar trgt) { if(trgt.kind == ArgumentTag::LocalScalar) { return this->cframe->scalarbase + trgt.offset; } else { return this->cframe->mixedbase + trgt.offset; } } inline BSQBool* evalMaskLocation(int32_t gmaskoffset) { if(gmaskoffset < 0) { return this->cframe->argmask + (-gmaskoffset); } else { return this->cframe->masksbase + gmaskoffset; } } inline StorageLocationPtr evalGuardVar(int32_t gvaroffset) { assert(gvaroffset >= 0); return this->cframe->scalarbase + gvaroffset; } inline BSQBool evalGuardStmt(const BSQGuard& guard) { if(guard.gindex != -1) { auto maskptr = this->evalMaskLocation(guard.gmaskoffset); return maskptr[guard.gindex]; } else { return SLPTR_LOAD_CONTENTS_AS(BSQBool, this->evalGuardVar(guard.gvaroffset)); } } inline void evalStoreAltValueForGuardStmt(TargetVar trgt, Argument arg, const BSQType* oftype) { //If this is a clear then the arg should evaluate to the empty constant location oftype->storeValue(this->evalTargetVar(trgt), this->evalArgument(arg)); } inline bool tryProcessGuardStmt(TargetVar trgt, const BSQType* trgttype, const BSQStatementGuard& sguard) { auto gval = this->evalGuardStmt(sguard.guard); auto dodefault = !!(sguard.usedefaulton ? gval : !gval); if(dodefault) { this->evalStoreAltValueForGuardStmt(trgt, sguard.defaultvar, trgttype); } return dodefault; } void evalDeadFlowOp(); void evalAbortOp(const AbortOp* op); void evalAssertCheckOp(const AssertOp* op); void evalDebugOp(const DebugOp* op); void evalLoadUnintVariableValueOp(const LoadUnintVariableValueOp* op); void evalNoneInitUnionOp(const NoneInitUnionOp* op); void evalStoreConstantMaskValueOp(const StoreConstantMaskValueOp* op); template <bool isGuarded> void evalDirectAssignOp(const DirectAssignOp* op); template <bool isGuarded> void evalBoxOp(const BoxOp* op); template <bool isGuarded> void evalExtractOp(const ExtractOp* op); void evalLoadConstOp(const LoadConstOp* op); void processTupleDirectLoadAndStore(StorageLocationPtr src, const BSQType* srctype, size_t slotoffset, TargetVar dst, const BSQType* dsttype); void processTupleVirtualLoadAndStore(StorageLocationPtr src, const BSQUnionType* srctype, BSQTupleIndex idx, TargetVar dst, const BSQType* dsttype); void processRecordDirectLoadAndStore(StorageLocationPtr src, const BSQType* srctype, size_t slotoffset, TargetVar dst, const BSQType* dsttype); void processRecordVirtualLoadAndStore(StorageLocationPtr src, const BSQUnionType* srctype, BSQRecordPropertyID propId, TargetVar dst, const BSQType* dsttype); void processEntityDirectLoadAndStore(StorageLocationPtr src, const BSQType* srctype, size_t slotoffset, TargetVar dst, const BSQType* dsttype); void processEntityVirtualLoadAndStore(StorageLocationPtr src, const BSQUnionType* srctype, BSQFieldID fldId, TargetVar dst, const BSQType* dsttype); void processGuardVarStore(const BSQGuard& gv, BSQBool f); void evalTupleHasIndexOp(const TupleHasIndexOp* op); void evalRecordHasPropertyOp(const RecordHasPropertyOp* op); void evalLoadTupleIndexDirectOp(const LoadTupleIndexDirectOp* op); void evalLoadTupleIndexVirtualOp(const LoadTupleIndexVirtualOp* op); void evalLoadTupleIndexSetGuardDirectOp(const LoadTupleIndexSetGuardDirectOp* op); void evalLoadTupleIndexSetGuardVirtualOp(const LoadTupleIndexSetGuardVirtualOp* op); void evalLoadRecordPropertyDirectOp(const LoadRecordPropertyDirectOp* op); void evalLoadRecordPropertyVirtualOp(const LoadRecordPropertyVirtualOp* op); void evalLoadRecordPropertySetGuardDirectOp(const LoadRecordPropertySetGuardDirectOp* op); void evalLoadRecordPropertySetGuardVirtualOp(const LoadRecordPropertySetGuardVirtualOp* op); void evalLoadDirectFieldOp(const LoadEntityFieldDirectOp* op); void evalLoadVirtualFieldOp(const LoadEntityFieldVirtualOp* op); void evalProjectTupleOp(const ProjectTupleOp* op); void evalProjectRecordOp(const ProjectRecordOp* op); void evalProjectEntityOp(const ProjectEntityOp* op); void evalUpdateTupleOp(const UpdateTupleOp* op); void evalUpdateRecordOp(const UpdateRecordOp* op); void evalUpdateEntityOp(const UpdateEntityOp* op); void evalLoadFromEpehmeralListOp(const LoadFromEpehmeralListOp* op); void evalMultiLoadFromEpehmeralListOp(const MultiLoadFromEpehmeralListOp* op); void evalSliceEphemeralListOp(const SliceEphemeralListOp* op); template <bool isGuarded> void evalInvokeFixedFunctionOp(const InvokeFixedFunctionOp* op); void evalInvokeVirtualFunctionOp(const InvokeVirtualFunctionOp* op); void evalInvokeVirtualOperatorOp(const InvokeVirtualOperatorOp* op); void evalConstructorTupleOp(const ConstructorTupleOp* op); void evalConstructorTupleFromEphemeralListOp(const ConstructorTupleFromEphemeralListOp* op); void evalConstructorRecordOp(const ConstructorRecordOp* op); void evalConstructorRecordFromEphemeralListOp(const ConstructorRecordFromEphemeralListOp* op); void evalEphemeralListExtendOp(const EphemeralListExtendOp* op); void evalConstructorEphemeralListOp(const ConstructorEphemeralListOp* op); void evalConstructorPrimaryCollectionEmptyOp(const ConstructorPrimaryCollectionEmptyOp* op); void evalConstructorPrimaryCollectionSingletonsOp(const ConstructorPrimaryCollectionSingletonsOp* op); void evalConstructorPrimaryCollectionCopiesOp(const ConstructorPrimaryCollectionCopiesOp* op); void evalConstructorPrimaryCollectionMixedOp(const ConstructorPrimaryCollectionMixedOp* op); void evalPrefixNotOp(const PrefixNotOp* op); void evalAllTrueOp(const AllTrueOp* op); void evalSomeTrueOp(const SomeTrueOp* op); void evalBinKeyEqFastOp(const BinKeyEqFastOp* op); void evalBinKeyEqStaticOp(const BinKeyEqStaticOp* op); void evalBinKeyEqVirtualOp(const BinKeyEqVirtualOp* op); void evalBinKeyLessFastOp(const BinKeyLessFastOp* op); void evalBinKeyLessStaticOp(const BinKeyLessStaticOp* op); void evalBinKeyLessVirtualOp(const BinKeyLessVirtualOp* op); template <bool isGuarded> void evalIsNoneOp(const TypeIsNoneOp* op); template <bool isGuarded> void evalIsSomeOp(const TypeIsSomeOp* op); template <bool isGuarded> void evalTypeTagIsOp(const TypeTagIsOp* op); template <bool isGuarded> void evalTypeTagSubtypeOfOp(const TypeTagSubtypeOfOp* op); InterpOp* evalJumpOp(const JumpOp* op); InterpOp* evalJumpCondOp(const JumpCondOp* op); InterpOp* evalJumpNoneOp(const JumpNoneOp* op); template <bool isGuarded> void evalRegisterAssignOp(const RegisterAssignOp* op); void evalReturnAssignOp(const ReturnAssignOp* op); void evalReturnAssignOfConsOp(const ReturnAssignOfConsOp* op); void evalVarLifetimeStartOp(const VarLifetimeStartOp* op); void evalVarLifetimeEndOp(const VarLifetimeEndOp* op); void evaluateOpCode(const InterpOp* op); void evaluateOpCodeBlocks(); void evaluateBody(StorageLocationPtr resultsl, const BSQType* restype, Argument resarg); void invoke(const BSQInvokeDecl* call, const std::vector<Argument>& args, StorageLocationPtr resultsl, BSQBool* optmask); void invokePrelude(const BSQInvokeBodyDecl* invk, const std::vector<Argument>& args, BSQBool* optmask); void invokePrimitivePrelude(const BSQInvokePrimitiveDecl* invk, const std::vector<Argument>& args); void invokePostlude(); void evaluatePrimitiveBody(const BSQInvokePrimitiveDecl* invk, StorageLocationPtr resultsl, const BSQType* restype); public: void invokeGlobalCons(const BSQInvokeBodyDecl* invk, StorageLocationPtr resultsl, const BSQType* restype, Argument resarg); void invokeMain(const BSQInvokeBodyDecl* invk, const std::vector<void*>& argslocs, StorageLocationPtr resultsl, const BSQType* restype, Argument resarg); };
37.251479
231
0.704471
6701a88d2ac26039a7cc68acc8821231d9d4a174
2,026
h
C
skein.h
electrorys/genpwd
2bc8883b871fa412f0a947fbb29cefde8f2849c3
[ "MIT" ]
null
null
null
skein.h
electrorys/genpwd
2bc8883b871fa412f0a947fbb29cefde8f2849c3
[ "MIT" ]
null
null
null
skein.h
electrorys/genpwd
2bc8883b871fa412f0a947fbb29cefde8f2849c3
[ "MIT" ]
null
null
null
/* * MIT License * * Copyright (c) 2021 Andrey Rys * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef _THREEFISH_SKEIN_DEFINITIONS_HEADER #define _THREEFISH_SKEIN_DEFINITIONS_HEADER #include "tfdef.h" #define SKEIN_VERSION 1 #define SKEIN_ID 0x33414853 #define SKEIN_BLOCK_CFG ((TF_UNIT_TYPE)4 << 56) #define SKEIN_BLOCK_MSG ((TF_UNIT_TYPE)48 << 56) #define SKEIN_BLOCK_OUT ((TF_UNIT_TYPE)63 << 56) #define SKEIN_FLAG_FIRST ((TF_UNIT_TYPE)1 << 62) #define SKEIN_FLAG_LAST ((TF_UNIT_TYPE)1 << 63) #define SKEIN_DIGEST_SIZE TF_BLOCK_SIZE struct skein { TF_UNIT_TYPE key[TF_NR_KEY_UNITS]; TF_BYTE_TYPE carry_block[TF_BLOCK_SIZE]; size_t carry_bytes; size_t bits; }; void skein_init_key(struct skein *sk, const void *ukey, size_t bits); void skein_init(struct skein *sk, size_t bits); void skein_update(struct skein *sk, const void *msg, size_t msgsz); void skein_final(void *result, struct skein *sk); void skein(void *hash, size_t bits, const void *data, size_t szdata); #endif
36.836364
81
0.769497
91352317f229bb9cfc5984069787862a3097674b
1,813
c
C
tests/adaptor-demo/main.c
raghaven447/gaeguli
fad00b9e4377c28620fc1a62e9aa16f24d3ee8bd
[ "Apache-2.0" ]
26
2019-09-24T09:06:11.000Z
2022-01-11T00:18:42.000Z
tests/adaptor-demo/main.c
raghaven447/gaeguli
fad00b9e4377c28620fc1a62e9aa16f24d3ee8bd
[ "Apache-2.0" ]
23
2019-09-19T13:22:26.000Z
2021-11-29T09:59:27.000Z
tests/adaptor-demo/main.c
raghaven447/gaeguli
fad00b9e4377c28620fc1a62e9aa16f24d3ee8bd
[ "Apache-2.0" ]
9
2019-09-16T12:27:40.000Z
2021-05-19T19:19:50.000Z
/** * Copyright 2020 SK Telecom Co., Ltd. * Author: Jakub Adam <jakub.adam@collabora.com> * * 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 <glib-unix.h> #include "config.h" #include "adaptor-demo.h" static gboolean sigint_handler (gpointer user_data) { g_main_loop_quit (user_data); return G_SOURCE_REMOVE; } int main (int argc, char *argv[]) { g_autoptr (GMainLoop) loop = g_main_loop_new (NULL, FALSE); g_autoptr (GaeguliAdaptorDemo) app = NULL; g_autoptr (GError) error = NULL; struct { const gchar *device; } options; g_autoptr (GOptionContext) context = NULL; GOptionEntry entries[] = { {"device", 'd', 0, G_OPTION_ARG_FILENAME, &options.device, NULL, NULL}, {NULL} }; options.device = DEFAULT_VIDEO_SOURCE_DEVICE; context = g_option_context_new (NULL); g_option_context_add_main_entries (context, entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("%s\n", error->message); return -1; } g_unix_signal_add (SIGINT, sigint_handler, loop); app = gaeguli_adaptor_demo_new (options.device); { g_autofree gchar *http_uri = gaeguli_adaptor_demo_get_control_uri (app); g_print ("Control panel URI: %s\n", http_uri); } g_main_loop_run (loop); return 0; }
25.9
76
0.705461
918b5135e9e35727422ffc042ebd6a836738adf8
235
h
C
blinky/blinky/asf-3.21.0/thirdparty/lwip/lwip-port-1.4.1/hd/if/include/arch/perf.h
femtoio/femtousb-blink-example
5e166bdee500f67142d0ee83a1a169bab57fe142
[ "MIT" ]
null
null
null
blinky/blinky/asf-3.21.0/thirdparty/lwip/lwip-port-1.4.1/hd/if/include/arch/perf.h
femtoio/femtousb-blink-example
5e166bdee500f67142d0ee83a1a169bab57fe142
[ "MIT" ]
null
null
null
blinky/blinky/asf-3.21.0/thirdparty/lwip/lwip-port-1.4.1/hd/if/include/arch/perf.h
femtoio/femtousb-blink-example
5e166bdee500f67142d0ee83a1a169bab57fe142
[ "MIT" ]
null
null
null
#ifndef __PERF_H__ /** * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a> */ #define __PERF_H__ #define PERF_START /* null definition */ #define PERF_STOP(x) /* null definition */ #endif
21.363636
90
0.685106