text
stringlengths
4
6.14k
// Copyright (c) 2011, Ryan M. Lefever // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _XERCESCPPHELP_H_ #define _XERCESCPPHELP_H_ #include <xercesc/util/XMLString.hpp> #include <string> using namespace xercesc; namespace silt{ std::string xmlCh2str(const XMLCh* const c){ char* cptr = XMLString::transcode(c); std::string s(cptr); XMLString::release(&cptr); return s; } } #endif // _XERCESCPPHELP_H_
#include <immintrin.h> #include <stdint.h> #define MAX_INT 2147483647 int decimal_digits_avx512(uint32_t val) { const __m512i powers = _mm512_setr_epi32( /* 0 */ 9, /* 1 */ 99, /* 2 */ 999, /* 3 */ 9999, /* 4 */ 99999, /* 5 */ 999999, /* 6 */ 9999999, /* 7 */ 99999999, /* 8 */ 999999999, /* 9 */ MAX_INT, /* 10 */ MAX_INT, /* 11 */ MAX_INT, /* 12 */ MAX_INT, /* 13 */ MAX_INT, /* 14 */ MAX_INT, /* 15 */ MAX_INT ); const __m512i value = _mm512_set1_epi32(val); const uint16_t m = _mm512_cmple_epu32_mask(value, powers); return 1 + __builtin_ctz(m); }
/************************************************************************************ PublicHeader: OVR.h Filename : OVR_DeviceMessages.h Content : Definition of messages generated by devices Created : February 5, 2013 Authors : Lee Cooper Copyright : Copyright 2014 Oculus VR, LLC. All Rights reserved. *************************************************************************************/ #ifndef OVR_DeviceMessages_h #define OVR_DeviceMessages_h #include "OVR_DeviceConstants.h" #include "OVR_DeviceHandle.h" #include "Kernel/OVR_Math.h" #include "Kernel/OVR_Array.h" #include "Kernel/OVR_Color.h" namespace OVR { class DeviceBase; class DeviceHandle; #define OVR_MESSAGETYPE(devName, msgIndex) ((Device_##devName << 8) | msgIndex) // MessageType identifies the structure of the Message class; based on the message, // casting can be used to obtain the exact value. enum MessageType { // Used for unassigned message types. Message_None = 0, // Device Manager Messages Message_DeviceAdded = OVR_MESSAGETYPE(Manager, 0), // A new device is detected by manager. Message_DeviceRemoved = OVR_MESSAGETYPE(Manager, 1), // Existing device has been plugged/unplugged. // Sensor Messages Message_BodyFrame = OVR_MESSAGETYPE(Sensor, 0), // Emitted by sensor at regular intervals. // Latency Tester Messages Message_LatencyTestSamples = OVR_MESSAGETYPE(LatencyTester, 0), Message_LatencyTestColorDetected = OVR_MESSAGETYPE(LatencyTester, 1), Message_LatencyTestStarted = OVR_MESSAGETYPE(LatencyTester, 2), Message_LatencyTestButton = OVR_MESSAGETYPE(LatencyTester, 3), }; //------------------------------------------------------------------------------------- // Base class for all messages. class Message { public: Message(MessageType type = Message_None, DeviceBase* pdev = 0) : Type(type), pDevice(pdev) { } MessageType Type; // What kind of message this is. DeviceBase* pDevice; // Device that emitted the message. }; // Sensor BodyFrame notification. // Sensor uses Right-Handed coordinate system to return results, with the following // axis definitions: // - Y Up positive // - X Right Positive // - Z Back Positive // Rotations a counter-clockwise (CCW) while looking in the negative direction // of the axis. This means they are interpreted as follows: // - Roll is rotation around Z, counter-clockwise (tilting left) in XY plane. // - Yaw is rotation around Y, positive for turning left. // - Pitch is rotation around X, positive for pitching up. class MessageBodyFrame : public Message { public: MessageBodyFrame(DeviceBase* dev) : Message(Message_BodyFrame, dev), Temperature(0.0f), TimeDelta(0.0f) { } // JDC: added this so I can have an array of them MessageBodyFrame() : Message(Message_BodyFrame,NULL), Temperature(0.0f), TimeDelta(0.0f) { } Vector3f Acceleration; // Acceleration in m/s^2. Vector3f RotationRate; // Angular velocity in rad/s. Vector3f MagneticField; // Magnetic field strength in Gauss. Vector3f MagneticBias; // Magnetic field calibration bias in Gauss. float Temperature; // Temperature reading on sensor surface, in degrees Celsius. float TimeDelta; // Time passed since last Body Frame, in seconds. // The absolute time from the host computers perspective that the message should be // interpreted as. This is derived from the rolling 16 bit timestamp on the incoming // messages and a continuously correcting delta value maintained by SensorDeviceImpl. // // Integration should use TimeDelta, but prediction into the future should derive // the delta time from PredictToSeconds - AbsoluteTimeSeconds. // // This value will always be <= the return from a call to Timer::GetSeconds(). // // This value will not usually be an integral number of milliseconds, and it will // drift by fractions of a millisecond as the time delta between the sensor and // host is continuously adjusted. double AbsoluteTimeSeconds; }; // Sent when we receive a device status changes (e.g.: // Message_DeviceAdded, Message_DeviceRemoved). class MessageDeviceStatus : public Message { public: MessageDeviceStatus(MessageType type, DeviceBase* dev, const DeviceHandle &hdev) : Message(type, dev), Handle(hdev) { } DeviceHandle Handle; }; //------------------------------------------------------------------------------------- // ***** Latency Tester // Sent when we receive Latency Tester samples. class MessageLatencyTestSamples : public Message { public: MessageLatencyTestSamples(DeviceBase* dev) : Message(Message_LatencyTestSamples, dev) { } Array<Color> Samples; }; // Sent when a Latency Tester 'color detected' event occurs. class MessageLatencyTestColorDetected : public Message { public: MessageLatencyTestColorDetected(DeviceBase* dev) : Message(Message_LatencyTestColorDetected, dev) { } UInt16 Elapsed; Color DetectedValue; Color TargetValue; }; // Sent when a Latency Tester 'change color' event occurs. class MessageLatencyTestStarted : public Message { public: MessageLatencyTestStarted(DeviceBase* dev) : Message(Message_LatencyTestStarted, dev) { } Color TargetValue; }; // Sent when a Latency Tester 'button' event occurs. class MessageLatencyTestButton : public Message { public: MessageLatencyTestButton(DeviceBase* dev) : Message(Message_LatencyTestButton, dev) { } }; } // namespace OVR #endif
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. /*============================================================================= ParticleBeamTrailVertexFactory.h: Shared Particle Beam and Trail vertex factory definitions. =============================================================================*/ #pragma once #include "UniformBuffer.h" /** * Uniform buffer for particle beam/trail vertex factories. */ BEGIN_UNIFORM_BUFFER_STRUCT( FParticleBeamTrailUniformParameters, ) DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER( FVector4, CameraRight ) DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER( FVector4, CameraUp ) DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER( FVector4, ScreenAlignment ) END_UNIFORM_BUFFER_STRUCT( FParticleBeamTrailUniformParameters ) typedef TUniformBufferRef<FParticleBeamTrailUniformParameters> FParticleBeamTrailUniformBufferRef; /** * Beam/Trail particle vertex factory. */ class ENGINE_API FParticleBeamTrailVertexFactory : public FParticleVertexFactoryBase { DECLARE_VERTEX_FACTORY_TYPE(FParticleBeamTrailVertexFactory); public: /** Default constructor. */ FParticleBeamTrailVertexFactory( EParticleVertexFactoryType InType, ERHIFeatureLevel::Type InFeatureLevel ) : FParticleVertexFactoryBase(InType, InFeatureLevel) {} FParticleBeamTrailVertexFactory() : FParticleVertexFactoryBase(PVFT_MAX, ERHIFeatureLevel::Num) {} /** * Should we cache the material's shadertype on this platform with this vertex factory? */ static bool ShouldCache(EShaderPlatform Platform, const class FMaterial* Material, const class FShaderType* ShaderType); /** * Can be overridden by FVertexFactory subclasses to modify their compile environment just before compilation occurs. */ static void ModifyCompilationEnvironment(EShaderPlatform Platform, const FMaterial* Material, FShaderCompilerEnvironment& OutEnvironment); // FRenderResource interface. virtual void InitRHI() override; /** * Set the uniform buffer for this vertex factory. */ FORCEINLINE void SetBeamTrailUniformBuffer( FParticleBeamTrailUniformBufferRef InSpriteUniformBuffer ) { BeamTrailUniformBuffer = InSpriteUniformBuffer; } /** * Retrieve the uniform buffer for this vertex factory. */ FORCEINLINE FParticleBeamTrailUniformBufferRef GetBeamTrailUniformBuffer() { return BeamTrailUniformBuffer; } /** * Set the source vertex buffer. */ void SetVertexBuffer(const FVertexBuffer* InBuffer, uint32 StreamOffset, uint32 Stride); /** * Set the source vertex buffer that contains particle dynamic parameter data. */ void SetDynamicParameterBuffer(const FVertexBuffer* InDynamicParameterBuffer, uint32 StreamOffset, uint32 Stride); /** * Construct shader parameters for this type of vertex factory. */ static FVertexFactoryShaderParameters* ConstructShaderParameters(EShaderFrequency ShaderFrequency); private: /** Uniform buffer with beam/trail parameters. */ FParticleBeamTrailUniformBufferRef BeamTrailUniformBuffer; };
// This code contains NVIDIA Confidential Information and is disclosed to you // under a form of NVIDIA software license agreement provided separately to you. // // Notice // NVIDIA Corporation and its licensors retain all intellectual property and // proprietary rights in and to this software and related documentation and // any modifications thereto. Any use, reproduction, disclosure, or // distribution of this software and related documentation without an express // license agreement from NVIDIA Corporation is strictly prohibited. // // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. // // Information and code furnished is believed to be accurate and reliable. // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such // information or for any infringement of patents or other rights of third parties that may // result from its use. No license is granted by implication or otherwise under any patent // or patent rights of NVIDIA Corporation. Details are subject to change without notice. // This code supersedes and replaces all information previously supplied. // NVIDIA Corporation products are not authorized for use as critical // components in life support devices or systems without express written approval of // NVIDIA Corporation. // // Copyright (c) 2008-2012 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_PHYSICS_COMMON_ID_POOL #define PX_PHYSICS_COMMON_ID_POOL #include "Px.h" #include "CmPhysXCommon.h" #include "PsArray.h" // PX_SERIALIZATION /* #include "CmSerialFramework.h" #include "CmSerialAlignment.h" */ //~PX_SERIALIZATION namespace physx { namespace Cm { class IDPool { PxU32 currentID; Ps::Array<PxU32> freeIDs; public: // PX_SERIALIZATION /* IDPool(PxRefResolver& v) {} void exportExtraData(PxSerialStream& stream) { Cm::alignStream(stream, PX_SERIAL_DEFAULT_ALIGN_EXTRA_DATA); freeIDs.exportArray(stream, false); } char* importExtraData(char* address, PxU32& totalPadding) { address = Cm::alignStream(address, totalPadding, PX_SERIAL_DEFAULT_ALIGN_EXTRA_DATA); address = freeIDs.importArray(address); return address; }*/ //~PX_SERIALIZATION IDPool() : currentID(0), freeIDs(PX_DEBUG_EXP("IDPoolFreeIDs")) {} void freeID(PxU32 id) { // Allocate on first call // Add released ID to the array of free IDs freeIDs.pushBack(id); } void freeAll() { currentID = 0; freeIDs.clear(); } PxU32 getNewID() { // If recycled IDs are available, use them const PxU32 size = freeIDs.size(); if(size) { const PxU32 id = freeIDs[size-1]; // Recycle last ID freeIDs.popBack(); return id; } // Else create a new ID return currentID++; } }; } // namespace Cm } #endif
/* * Copyright (c) 2009-2011, Salvatore Sanfilippo <antirez at gmail dot com> * Copyright (c) 2010-2011, Pieter Noordhuis <pcnoordhuis at gmail dot com> * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of Redis nor the names of its contributors may be used * to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef __HIREDIS_READ_H #define __HIREDIS_READ_H #include <stdio.h> /* for size_t */ #define REDIS_ERR -1 #define REDIS_OK 0 /* When an error occurs, the err flag in a context is set to hold the type of * error that occurred. REDIS_ERR_IO means there was an I/O error and you * should use the "errno" variable to find out what is wrong. * For other values, the "errstr" field will hold a description. */ #define REDIS_ERR_IO 1 /* Error in read or write */ #define REDIS_ERR_EOF 3 /* End of file */ #define REDIS_ERR_PROTOCOL 4 /* Protocol error */ #define REDIS_ERR_OOM 5 /* Out of memory */ #define REDIS_ERR_OTHER 2 /* Everything else... */ #define REDIS_REPLY_STRING 1 #define REDIS_REPLY_ARRAY 2 #define REDIS_REPLY_INTEGER 3 #define REDIS_REPLY_NIL 4 #define REDIS_REPLY_STATUS 5 #define REDIS_REPLY_ERROR 6 #define REDIS_READER_MAX_BUF (1024*16) /* Default max unused reader buffer. */ #ifdef __cplusplus extern "C" { #endif typedef struct redisReadTask { int type; int elements; /* number of elements in multibulk container */ int idx; /* index in parent (array) object */ void *obj; /* holds user-generated value for a read task */ struct redisReadTask *parent; /* parent task */ void *privdata; /* user-settable arbitrary field */ } redisReadTask; typedef struct redisReplyObjectFunctions { void *(*createString)(const redisReadTask*, char*, size_t); void *(*createArray)(const redisReadTask*, int); void *(*createInteger)(const redisReadTask*, long long); void *(*createNil)(const redisReadTask*); void (*freeObject)(void*); } redisReplyObjectFunctions; typedef struct redisReader { int err; /* Error flags, 0 when there is no error */ char errstr[128]; /* String representation of error when applicable */ char *buf; /* Read buffer */ size_t pos; /* Buffer cursor */ size_t len; /* Buffer length */ size_t maxbuf; /* Max length of unused buffer */ redisReadTask rstack[9]; int ridx; /* Index of current read task */ void *reply; /* Temporary reply pointer */ redisReplyObjectFunctions *fn; void *privdata; } redisReader; /* Public API for the protocol parser. */ redisReader *redisReaderCreateWithFunctions(redisReplyObjectFunctions *fn); void redisReaderFree(redisReader *r); int redisReaderFeed(redisReader *r, const char *buf, size_t len); int redisReaderGetReply(redisReader *r, void **reply, int* reply_len, int is_ssdb); #define redisReaderSetPrivdata(_r, _p) (int)(((redisReader*)(_r))->privdata = (_p)) #define redisReaderGetObject(_r) (((redisReader*)(_r))->reply) #define redisReaderGetError(_r) (((redisReader*)(_r))->errstr) #ifdef __cplusplus } #endif #endif
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. #pragma once #include "Editor/Sequencer/Public/MovieSceneTrackEditor.h" class IPropertyHandle; class F2DTransformTrackEditor : public FMovieSceneTrackEditor { public: /** * Constructor * * @param InSequencer The sequencer instance to be used by this tool */ F2DTransformTrackEditor( TSharedRef<ISequencer> InSequencer ); ~F2DTransformTrackEditor(); /** * Creates an instance of this class. Called by a sequencer * * @param OwningSequencer The sequencer instance to be used by this tool * @return The new instance of this class */ static TSharedRef<FMovieSceneTrackEditor> CreateTrackEditor( TSharedRef<ISequencer> OwningSequencer ); /** FMovieSceneTrackEditor Interface */ virtual bool SupportsType( TSubclassOf<UMovieSceneTrack> Type ) const override; virtual TSharedRef<ISequencerSection> MakeSectionInterface( UMovieSceneSection& SectionObject, UMovieSceneTrack* Track ) override; private: /** * Called by the details panel when an animatable property changes * * @param InObjectsThatChanged List of objects that changed * @param PropertyValue Handle to the property value which changed */ void OnTransformChanged( const class FPropertyChangedParams& PropertyChangedParams ); /** Called After OnMarginChanged if we actually can key the margin */ void OnKeyTransform( float KeyTime, const class FPropertyChangedParams* PropertyChangedParams ); };
#include <math.h> #include <stdint.h> #include <Python.h> uint8_t isprime(uint64_t n) { uint64_t i; uint64_t maximum; if (n < 2) { return 0; } if (n == 2) { return 1; } if (n % 2 == 0) { return 0; } maximum = (uint64_t) sqrt((double) n); i = 3; while (i <= maximum) { if (n % i == 0) { return 0; } i += 2; } return 1; } uint64_t sum_primes(uint64_t n) { uint64_t i; uint64_t sum; sum = 0; for (i = 2; i < n; i++) { if (isprime(i)) { sum += i; } } return sum; } static PyObject * py_sum_primes(PyObject *self, PyObject *args) { uint64_t n; uint64_t sum; if (!PyArg_ParseTuple(args, "K", &n)) { return NULL; } Py_BEGIN_ALLOW_THREADS sum = sum_primes(n); Py_END_ALLOW_THREADS return Py_BuildValue("K", sum); } static PyMethodDef CPrimesMethods[] = { {"sum_primes", py_sum_primes, METH_VARARGS, "Sum all primes less than n"}, {NULL, NULL, 0, NULL} }; PyMODINIT_FUNC initcprimes(void) { (void) Py_InitModule("cprimes", CPrimesMethods); }
/* Flirt, an SWF rendering library Copyright (c) 2004-2006 Dave Hayden <dave@opaque.net> All rights reserved. http://www.opaque.net/flirt/ This code is distributed under the two-clause BSD license. Read the LICENSE file or visit the URL above for details */ #ifndef BLOCKTYPES_H_INCLUDED #define BLOCKTYPES_H_INCLUDED typedef enum { DEFINESHAPE = 2, DEFINESHAPE2 = 22, DEFINESHAPE3 = 32, DEFINEMORPHSHAPE = 46, DEFINEBITS = 6, DEFINEBITSJPEG2 = 21, DEFINEBITSJPEG3 = 35, DEFINELOSSLESS = 20, DEFINELOSSLESS2 = 36, JPEGTABLES = 8, DEFINEBUTTON = 7, DEFINEBUTTON2 = 34, DEFINEBUTTONCXFORM = 23, DEFINEBUTTONSOUND = 17, DEFINEFONT = 10, DEFINEFONT2 = 48, DEFINEFONTINFO = 13, DEFINEFONTINFO2 = 62, DEFINETEXT = 11, DEFINETEXT2 = 33, DEFINESOUND = 14, SOUNDSTREAMBLOCK = 19, SOUNDSTREAMHEAD = 18, SOUNDSTREAMHEAD2 = 45, DEFINESPRITE = 39, PLACEOBJECT = 4, PLACEOBJECT2 = 26, REMOVEOBJECT = 5, REMOVEOBJECT2 = 28, SHOWFRAME = 1, SETBACKGROUNDCOLOR = 9, FRAMELABEL = 43, PROTECT = 24, STARTSOUND = 15, END = 0, DOACTION = 12, TEXTFIELD = 37, LIBRARYSYMBOL = 56, PASSWORD = 58, INITCLIPACTION = 59 } Blocktype; #endif /* BLOCKTYPES_H_INCLUDED */
/* * Copyright 2014, General Dynamics C4 Systems * * This software may be distributed and modified according to the terms of * the GNU General Public License version 2. Note that NO WARRANTY is provided. * See "LICENSE_GPLv2.txt" for details. * * @TAG(GD_GPL) */ #ifndef __PLAT_IO_H #define __PLAT_IO_H #include <config.h> #include <arch/linker.h> #include <types.h> void out8(uint16_t port, uint8_t value); void out16(uint16_t port, uint16_t value); void out32(uint16_t port, uint32_t value); uint8_t in8(uint16_t port); uint16_t in16(uint16_t port); uint32_t in32(uint16_t port); #if defined(CONFIG_DEBUG_BUILD) || defined(CONFIG_PRINTING) void serial_init(uint16_t port); #endif #ifdef CONFIG_PRINTING void console_putchar(char c); #define kernel_putchar(c) console_putchar(c) #else /* !CONFIG_PRINTING */ #define kernel_putchar(c) ((void)(0)) #endif #endif
/****************************************************************************** ** ** Copyright (C) 2009-2011 Kyle Lutz <kyle.r.lutz@gmail.com> ** All rights reserved. ** ** This file is a part of the chemkit project. For more information ** see <http://www.chemkit.org>. ** ** Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions ** are met: ** ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in the ** documentation and/or other materials provided with the distribution. ** * Neither the name of the chemkit project nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ** ******************************************************************************/ #ifndef MCDLLINEFORMAT_H #define MCDLLINEFORMAT_H #include <chemkit/lineformat.h> class McdlLineFormat : public chemkit::LineFormat { public: // construction and destruction McdlLineFormat(); ~McdlLineFormat(); // input and output chemkit::Molecule* read(const std::string &formula) CHEMKIT_OVERRIDE; }; #endif // MCDLLINEFORMAT_H
/* * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ // This sub-API supports the following functionalities: // - Specify render destinations for incoming video streams, capture devices // and files. // - Configuring render streams. #ifndef WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_RENDER_H_ #define WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_RENDER_H_ #include "webrtc/common_types.h" namespace webrtc { class I420VideoFrame; class VideoEngine; class VideoRender; class VideoRenderCallback; // This class declares an abstract interface to be used for external renderers. // The user implemented derived class is registered using AddRenderer(). class ExternalRenderer { public: // This method will be called when the stream to be rendered changes in // resolution or number of streams mixed in the image. virtual int FrameSizeChange(unsigned int width, unsigned int height, unsigned int number_of_streams) = 0; // This method is called when a new frame should be rendered. virtual int DeliverFrame(unsigned char* buffer, size_t buffer_size, // RTP timestamp in 90kHz. uint32_t timestamp, // NTP time of the capture time in local timebase // in milliseconds. int64_t ntp_time_ms, // Wallclock render time in milliseconds. int64_t render_time_ms, // Handle of the underlying video frame. void* handle) = 0; // Alternative interface for I420 frames. virtual int DeliverI420Frame(const I420VideoFrame& webrtc_frame) = 0; // Returns true if the renderer supports textures. DeliverFrame can be called // with NULL |buffer| and non-NULL |handle|. virtual bool IsTextureSupported() = 0; protected: virtual ~ExternalRenderer() {} }; class ViERender { public: // Factory for the ViERender sub‐API and increases an internal reference // counter if successful. Returns NULL if the API is not supported or if // construction fails. static ViERender* GetInterface(VideoEngine* video_engine); // Releases the ViERender sub-API and decreases an internal reference // counter. Returns the new reference count. This value should be zero // for all sub-API:s before the VideoEngine object can be safely deleted. virtual int Release() = 0; // Registers render module. virtual int RegisterVideoRenderModule(VideoRender& render_module) = 0; // Deregisters render module. virtual int DeRegisterVideoRenderModule(VideoRender& render_module) = 0; // Sets the render destination for a given render ID. virtual int AddRenderer(const int render_id, void* window, const unsigned int z_order, const float left, const float top, const float right, const float bottom) = 0; // Removes the renderer for a stream. virtual int RemoveRenderer(const int render_id) = 0; // Starts rendering a render stream. virtual int StartRender(const int render_id) = 0; // Stops rendering a render stream. virtual int StopRender(const int render_id) = 0; // Set expected render time needed by graphics card or external renderer, i.e. // the number of ms a frame will be sent to rendering before the actual render // time. virtual int SetExpectedRenderDelay(int render_id, int render_delay) = 0; // Configures an already added render stream. virtual int ConfigureRender(int render_id, const unsigned int z_order, const float left, const float top, const float right, const float bottom) = 0; // This function mirrors the rendered stream left and right or up and down. virtual int MirrorRenderStream(const int render_id, const bool enable, const bool mirror_xaxis, const bool mirror_yaxis) = 0; // External render. virtual int AddRenderer(const int render_id, RawVideoType video_input_format, ExternalRenderer* renderer) = 0; protected: ViERender() {} virtual ~ViERender() {} }; } // namespace webrtc #endif // WEBRTC_VIDEO_ENGINE_INCLUDE_VIE_RENDER_H_
/*============================================================================== * FILE: minmax.c * OVERVIEW: Test program to exercise the matching of definitions and uses * of CCs involving the carry flag. Also tests some RTL * simplification code for the Sparc subx instruction (especially * where arguments are all registers). * (C) 2001 The University of Queensland, BT group *============================================================================*/ /* Compile with: % cc -xO4 -o test/sparc/minmax test/source/minmax.c The resultant code is highly compiler specific (even compiler version specific). The intention is to produce code like the following (for Sparc): 10800: 9d e3 bf a0 save %sp, -96, %sp 10804: 84 10 3f fe mov -2, %g2 10808: 88 10 3f ff mov -1, %g4 1080c: 87 3e 20 1f sra %i0, 31, %g3 10810: 90 a0 80 18 subcc %g2, %i0, %o0 10814: 86 61 00 03 subx %g4, %g3, %g3 10818: 86 0a 00 03 and %o0, %g3, %g3 1081c: 13 00 00 42 sethi %hi(0x10800), %o1 10820: 84 20 80 03 sub %g2, %g3, %g2 10824: 90 02 60 f0 add %o1, 240, %o0 10828: 87 38 a0 1f sra %g2, 31, %g3 1082c: 84 a0 a0 03 subcc %g2, 3, %g2 10830: 86 60 e0 00 subx %g3, 0, %g3 10834: 84 08 80 03 and %g2, %g3, %g2 10838: 40 00 40 4f call printf 1083c: 92 00 a0 03 add %g2, 3, %o1 10840: 81 c7 e0 08 ret 10844: 91 e8 20 00 restore %g0, 0, %o0 For pentum, the Sun compiler doesn't (at present) generate terribly interesting code, but the test is retained for completeness. */ #include <stdio.h> int main(int argc) { if (argc < -2) argc = -2; if (argc > 3) argc = 3; printf("MinMax adjusted number of arguments is %d\n", argc); return 0; }
#ifndef INTERACTIVE_NODE_H #define INTERACTIVE_NODE_H /// PROJECT #include <csapex/model/node.h> #include <csapex_core_plugins/csapex_core_lib_export.h> /// SYSTEM #include <mutex> namespace csapex { class CSAPEX_CORE_LIB_EXPORT InteractiveNode : public Node { friend class InteractiveNodeAdapter; public: InteractiveNode(); void process() final override; void process(csapex::NodeModifier& node_modifier, Parameterizable& parameters) final override; void process(csapex::NodeModifier& node_modifier, Parameterizable& parameters, Continuation continuation) final override; void reset() override; bool isAsynchronous() const override; void done(); protected: virtual void beginProcess(csapex::NodeModifier& node_modifier, Parameterizable& parameters); virtual void beginProcess(); virtual void finishProcess(csapex::NodeModifier& node_modifier, Parameterizable& parameters); virtual void finishProcess(); protected: bool stopped_; bool done_; Continuation continuation_; }; } // namespace csapex #endif // INTERACTIVE_NODE_H
#ifndef EXO_H_ #define EXO_H_ /* * Implement ramput/ramget, hashput/hashget, in native c outside * zaatar framework. Useful when writing exogenous checks. * */ #include <stdio.h> #include <stdlib.h> #include <include/db.h> #include <storage/merkle_ram.h> #include <storage/hasher.h> #include <storage/hash_block_store.h> #define ramput(addr, p_data) __ramput(addr, p_data, sizeof(*p_data)) #define ramget(p_data, addr) __ramget(p_data, addr, sizeof(*p_data)) #define hashput(hash, p_data) __hashput(hash, p_data, sizeof(*p_data)) #define hashget(p_data, hash) __hashget(p_data, hash, sizeof(*p_data)) #define commitmentput(hash, p_data) __commitmentput(hash, p_data, sizeof(*p_data)) #define commitmentget(p_data, hash) __commitmentget(p_data, hash, sizeof(*p_data)) #define ramput2(ram, addr, p_data) __ramput(ram, addr, p_data, sizeof(*p_data)) #define ramget2(ram, p_data, addr) __ramget(ram, p_data, addr, sizeof(*p_data)) #define hashput2(bs, hash, p_data) __hashput(bs, hash, p_data, sizeof(*p_data)) #define hashget2(bs, p_data, hash) __hashget(bs, p_data, hash, sizeof(*p_data)) #define commitmentput2(bs, hash, p_data) __commitmentput(bs, hash, p_data, sizeof(*p_data)) #define commitmentget2(bs, p_data, hash) __commitmentget(bs, p_data, hash, sizeof(*p_data)) /*#define _strcpy(dst, src) \ { \ int tempI; \ char tempCharArr[] = src; \ for (tempI = 0; tempI < sizeof(src); tempI++) { \ dst[tempI] = src[tempI]; \ } \ } */ //int hasheq(hash_t* a, hash_t* b); void initBlockStore(); HashType* getRootHash(); void setBlockStoreAndRAM(HashBlockStore* bs, MerkleRAM* ram); void deleteBlockStoreAndRAM(); void __ramput(uint32_t addr, void* data, uint32_t size); void __ramget(void* var, uint32_t addr, uint32_t size); void __hashput(hash_t* hash, void* data, uint32_t size); void __hashget(void* var, hash_t* hash, uint32_t size); void __commitmentput(commitment_t* hash, void* data, uint32_t size); void __commitmentget(void* var, commitment_t* hash, uint32_t size); void hashfree(hash_t* hash); // TODO: reconcile the two methods below with the two above, later void __hashbits(hash_t *hash, void *data, uint32_t size); void __ramput(MerkleRAM* ram, uint32_t addr, void* data, uint32_t size); void __ramget(MerkleRAM* ram, void* var, uint32_t addr, uint32_t size); void __hashput(HashBlockStore *bs, hash_t* hash, void* data, uint32_t size); void __hashget(HashBlockStore *bs, void* var, hash_t* hash, uint32_t size); void __commitmentput(HashBlockStore *bs, commitment_t* hash, void* data, uint32_t size); void __commitmentget(HashBlockStore *bs, void* var, commitment_t* hash, uint32_t size); void hashfree(HashBlockStore *bs, hash_t* hash); #endif // EXO_H_
/***************************************************************************************** * 8051 CPUÏà¹ØCÎļþ * * Copyright (C) 2010 Ô·³¼Ã¢ * * 2010-07-09 RaysRTOS *****************************************************************************************/ #include "RaySRTOS.h" /******************È«¾Ö±äÁ¿¶¨Òå***************/ INT8U StackIdle[StackSizeIdle]; // ½¨Á¢¿ÕÏÐÈÎÎñÕ» INT8U OSRdyTbl; // ¾ÍÐ÷ÈÎÎñÁбí INT8U OSPrioCur; // µ±Ç°ÈÎÎñµÄÓÅÏȼ¶ INT8U OSPrioHighRdy ; // ¼´½«ÒªÔËÐÐÈÎÎñµÄÓÅÏȼ¶ INT8U IdleCount; // ¿ÕÏÐÈÎÎñ×Ô¼ÓÊý struct TaskCtrBlock TCB[OS_TASKS + 1]; // ¶¨ÒåÈÎÎñ¿ØÖÆ¿éTCBÊý×é void CPU_TaskCreate(void (*p_Task)(void),INT8U *p_Stack,INT8U t_Prio) { *( p_Stack) = (unsigned int)p_Task & 0xff; // º¯ÊýÈë¿Ú *(++p_Stack) = (unsigned int)p_Task>>8; // º¯ÊýÈë¿Ú *(++p_Stack) = 0;//ACC *(++p_Stack) = 0;//B *(++p_Stack) = 0;//DPH *(++p_Stack) = 0;//DPL *(++p_Stack) = 0;//PSW *(++p_Stack) = 0;//R0 *(++p_Stack) = 1;//R1 *(++p_Stack) = 2;//R2 *(++p_Stack) = 3;//R3 *(++p_Stack) = 4;//R4 *(++p_Stack) = 5;//R5 *(++p_Stack) = 6;//R6 *(++p_Stack) = 7;//R7 // ³ýpcÍâ±£´æ13¸ö¼Ä´æÆ÷ TCB[t_Prio].OSTCBStkPtr = (INT8U)p_Stack; // ½«È˹¤¶ÑÕ»µÄÕ»¶¥£¬±£´æµ½¶ÑÕ»µÄÊý×éÖÐ TCB[t_Prio].OSTCBDly = 0; // ³õʼ»¯ÈÎÎñÑÓʱ } void CPU_OSStart(void) { CPU_TaskCreate(Idle_Task,StackIdle,OS_TASKS); SP=TCB[OSPrioHighRdy].OSTCBStkPtr-13; // ½«Õ»¶¥ÒƵ½pcλÖÃ,×¼±¸µ¯³ö TR0=1; }
/* * Copyright (c) 2007, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of the Intel Corporation nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * Authors: Adrian Burns * September, 2007 */ #ifndef ANEX_H #define ANEX_H enum { NUM_ACCEL_CHANS = 3 }; enum { NUM_GYRO_CHANS = 3 }; enum { SHIMMER_REV1 = 0 }; enum { PROPRIETARY_DATA_TYPE = 0xFF, STRING_DATA_TYPE = 0xFE }; enum { SAMPLING_1000HZ = 1, SAMPLING_500HZ = 2, SAMPLING_250HZ = 4, SAMPLING_200HZ = 5, SAMPLING_166HZ = 6, SAMPLING_100HZ = 10, SAMPLING_50HZ = 20, SAMPLING_0HZ_OFF = 255 }; enum { FRAMING_SIZE = 0x4, FRAMING_CE_COMP = 0x20, FRAMING_CE_CE = 0x5D, FRAMING_CE = 0x7D, FRAMING_BOF = 0xC0, FRAMING_EOF = 0xC1, FRAMING_BOF_CE = 0xE0, FRAMING_EOF_CE = 0xE1, }; #endif // ANEX_H
// Copyright (c) 2014 Intel Corporation. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef XWALK_RUNTIME_BROWSER_XWALK_RUNNER_TIZEN_H_ #define XWALK_RUNTIME_BROWSER_XWALK_RUNNER_TIZEN_H_ #include <string> #include "xwalk/runtime/browser/xwalk_runner.h" namespace xwalk { // Main object customizations for the Tizen port of Crosswalk. Any objects // specific to Tizen should be created here. class XWalkRunnerTizen : public XWalkRunner { public: // See documentation in xwalk_runner.h about when it is valid to access // XWalkRunner directly. Relying too much on this accessor makes code harder // to change and harder to reason about. static XWalkRunnerTizen* GetInstance(); ~XWalkRunnerTizen() override; void PreMainMessageLoopRun() override; private: friend class XWalkRunner; XWalkRunnerTizen(); }; } // namespace xwalk #endif // XWALK_RUNTIME_BROWSER_XWALK_RUNNER_TIZEN_H_
/*============================================================================= This file is part of FLINT. FLINT 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. FLINT 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 FLINT; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =============================================================================*/ /****************************************************************************** Copyright (C) 2009, 2010, 2011 Sebastian Pancratz ******************************************************************************/ #ifndef FMPZ_POLY_Q_H #define FMPZ_POLY_Q_H #undef ulong /* interferes with system includes */ #include <stdlib.h> #define ulong unsigned long #include "flint.h" #include "fmpz.h" #include "fmpz_poly.h" #ifdef __cplusplus extern "C" { #endif typedef struct { fmpz_poly_struct *num; fmpz_poly_struct *den; } fmpz_poly_q_struct; typedef fmpz_poly_q_struct fmpz_poly_q_t[1]; /* Accessing numerator and denominator ***************************************/ #define fmpz_poly_q_numref(op) ((op)->num) #define fmpz_poly_q_denref(op) ((op)->den) void fmpz_poly_q_canonicalise(fmpz_poly_q_t rop); int fmpz_poly_q_is_canonical(const fmpz_poly_q_t op); /* Memory management *********************************************************/ void fmpz_poly_q_init(fmpz_poly_q_t rop); void fmpz_poly_q_clear(fmpz_poly_q_t rop); /* Randomisation *************************************************************/ void fmpz_poly_q_randtest(fmpz_poly_q_t poly, flint_rand_t state, long len1, mp_bitcnt_t bits1, long len2, mp_bitcnt_t bits2); void fmpz_poly_q_randtest_not_zero(fmpz_poly_q_t poly, flint_rand_t state, long len1, mp_bitcnt_t bits1, long len2, mp_bitcnt_t bits2); /* Assignment ****************************************************************/ void fmpz_poly_q_set(fmpz_poly_q_t rop, const fmpz_poly_q_t op); void fmpz_poly_q_set_si(fmpz_poly_q_t rop, long op); void fmpz_poly_q_swap(fmpz_poly_q_t op1, fmpz_poly_q_t op2); static __inline__ void fmpz_poly_q_zero(fmpz_poly_q_t rop) { fmpz_poly_zero(rop->num); fmpz_poly_set_si(rop->den, 1); } static __inline__ void fmpz_poly_q_one(fmpz_poly_q_t rop) { fmpz_poly_set_si(rop->num, 1); fmpz_poly_set_si(rop->den, 1); } static __inline__ void fmpz_poly_q_neg(fmpz_poly_q_t rop, const fmpz_poly_q_t op) { fmpz_poly_neg(rop->num, op->num); fmpz_poly_set(rop->den, op->den); } void fmpz_poly_q_inv(fmpz_poly_q_t rop, const fmpz_poly_q_t op); /* Comparison ****************************************************************/ static __inline__ int fmpz_poly_q_is_zero(const fmpz_poly_q_t op) { return fmpz_poly_is_zero(op->num); } static __inline__ int fmpz_poly_q_is_one(const fmpz_poly_q_t op) { return fmpz_poly_is_one(op->num) && fmpz_poly_is_one(op->den); } static __inline__ int fmpz_poly_q_equal(const fmpz_poly_q_t op1, const fmpz_poly_q_t op2) { return fmpz_poly_equal(op1->num, op2->num) && fmpz_poly_equal(op1->den, op2->den); } /* Addition and subtraction **************************************************/ void fmpz_poly_q_add_in_place(fmpz_poly_q_t rop, const fmpz_poly_q_t op); void fmpz_poly_q_sub_in_place(fmpz_poly_q_t rop, const fmpz_poly_q_t op); void fmpz_poly_q_add(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2); void fmpz_poly_q_sub(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2); void fmpz_poly_q_addmul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2); void fmpz_poly_q_submul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2); /* Scalar multiplication and division ****************************************/ void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x); void fmpz_poly_q_scalar_mul_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x); void fmpz_poly_q_scalar_mul_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x); void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x); void fmpz_poly_q_scalar_div_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x); void fmpz_poly_q_scalar_div_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x); /* Multiplication and division ***********************************************/ void fmpz_poly_q_mul(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2); void fmpz_poly_q_div(fmpz_poly_q_t rop, const fmpz_poly_q_t op1, const fmpz_poly_q_t op2); /* Powering ******************************************************************/ void fmpz_poly_q_pow(fmpz_poly_q_t rop, const fmpz_poly_q_t op, ulong exp); /* Derivative ****************************************************************/ void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op); /* Evaluation ****************************************************************/ int fmpz_poly_q_evaluate(mpq_t rop, const fmpz_poly_q_t f, const mpq_t a); /* Input and output **********************************************************/ int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s); char * fmpz_poly_q_get_str(const fmpz_poly_q_t op); char * fmpz_poly_q_get_str_pretty(const fmpz_poly_q_t op, const char *x); int fmpz_poly_q_print(const fmpz_poly_q_t op); int fmpz_poly_q_print_pretty(const fmpz_poly_q_t op, const char *x); #ifdef __cplusplus } #endif #endif
/*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef mitkGantryTiltInformation_h #define mitkGantryTiltInformation_h #include "mitkPoint.h" #include "mitkVector.h" #include "mitkPoint.h" namespace mitk { /** \ingroup DICOMModule \brief Gantry tilt analysis result. Takes geometry information for two slices of a DICOM series and calculates whether these fit into an orthogonal block or not. If NOT, they can either be the result of an acquisition with gantry tilt OR completly broken by some shearing transformation. Most calculations are done in the constructor, results can then be read via the remaining methods. This class is a helper to DICOMITKSeriesGDCMReader and can not be used outside of \ref DICOMModule */ class GantryTiltInformation { public: // two types to avoid any rounding errors typedef itk::Point<double,3> Point3Dd; typedef itk::Vector<double,3> Vector3Dd; /** \brief Just so we can create empty instances for assigning results later. */ GantryTiltInformation(); void Print(std::ostream& os) const; /** \brief THE constructor, which does all the calculations. Determining the amount of tilt is done by checking the distances of origin1 from planes through origin2. Two planes are considered: - normal vector along normal of slices (right x up): gives the slice distance - normal vector along orientation vector "up": gives the shift parallel to the plane orientation The tilt angle can then be calculated from these distances \param origin1 origin of the first slice \param origin2 origin of the second slice \param right right/up describe the orientatation of borth slices \param up right/up describe the orientatation of borth slices \param numberOfSlicesApart how many slices are the given origins apart (1 for neighboring slices) */ GantryTiltInformation( const Point3D& origin1, const Point3D& origin2, const Vector3D& right, const Vector3D& up, unsigned int numberOfSlicesApart); /** \brief Factory method to create GantryTiltInformation from tag values (strings). Parameters as the regular c'tor. */ static GantryTiltInformation MakeFromTagValues( const std::string& origin1String, const std::string& origin2String, const std::string& orientationString, unsigned int numberOfSlicesApart); /** \brief Whether the slices were sheared. True if any of the shifts along right or up vector are non-zero. */ bool IsSheared() const; /** \brief Whether the shearing is a gantry tilt or more complicated. Gantry tilt will only produce shifts in ONE orientation, not in both. Since the correction code currently only coveres one tilt direction AND we don't know of medical images with two tilt directions, the loading code wants to check if our assumptions are true. */ bool IsRegularGantryTilt() const; /** \brief The offset distance in Y direction for each slice in mm (describes the tilt result). */ double GetMatrixCoefficientForCorrectionInWorldCoordinates() const; /** \brief The z / inter-slice spacing. Needed to correct ImageSeriesReader's result. */ double GetRealZSpacing() const; /** \brief The shift between first and last slice in mm. Needed to resize an orthogonal image volume. */ double GetTiltCorrectedAdditionalSize(unsigned int imageSizeZ) const; /** \brief Calculated tilt angle in degrees. */ double GetTiltAngleInDegrees() const; private: /** \brief Projection of point p onto line through lineOrigin in direction of lineDirection. */ Point3D projectPointOnLine( Point3Dd p, Point3Dd lineOrigin, Vector3Dd lineDirection ); double m_ShiftUp; double m_ShiftRight; double m_ShiftNormal; double m_ITKAssumedSliceSpacing; unsigned int m_NumberOfSlicesApart; }; } // namespace #endif
/*---------------------------------------------------------------------------*/ #include <bl/nonblock/libexport.h> #include <bl/base/platform.h> #include <bl/nonblock/mpmc_bt.h> #include <string.h> #ifdef __cplusplus extern "C" { #endif /*----------------------------------------------------------------------------*/ BL_NONBLOCK_EXPORT bl_err bl_mpmc_bt_produce_sig_fallback( bl_mpmc_bt* q, bl_mpmc_b_ticket* ticket, void const* data, bool replace_sig, bl_mpmc_b_sig sig, bl_mpmc_b_sig sig_fmask, bl_mpmc_b_sig sig_fmatch ) { bl_u8* slot; bl_err err = bl_mpmc_b_produce_prepare_sig_fallback( &q->q, ticket, &slot, replace_sig, sig, sig_fmask, sig_fmatch ); if (bl_likely (!err.own)) { memcpy (slot, data, q->sizeof_type); bl_mpmc_b_produce_commit (&q->q, *ticket); } return err; } /*----------------------------------------------------------------------------*/ BL_NONBLOCK_EXPORT bl_err bl_mpmc_bt_produce_sp( bl_mpmc_bt* q, bl_mpmc_b_ticket* ticket, void const* data ) { bl_u8* slot; bl_err err = bl_mpmc_b_produce_prepare_sp (&q->q, ticket, &slot); if (bl_likely (!err.own)) { memcpy (slot, data, q->sizeof_type); bl_mpmc_b_produce_commit (&q->q, *ticket); } return err; } /*----------------------------------------------------------------------------*/ BL_NONBLOCK_EXPORT bl_err bl_mpmc_bt_consume_sig_fallback( bl_mpmc_bt* q, bl_mpmc_b_ticket* ticket, void* data, bool replace_sig, bl_mpmc_b_sig sig, bl_mpmc_b_sig sig_fmask, bl_mpmc_b_sig sig_fmatch ) { bl_u8* slot; bl_err err = bl_mpmc_b_consume_prepare_sig_fallback( &q->q, ticket, &slot, replace_sig, sig, sig_fmask, sig_fmatch ); if (bl_likely (!err.own)) { memcpy (data, slot, q->sizeof_type); bl_mpmc_b_consume_commit (&q->q, *ticket); } return err; } /*----------------------------------------------------------------------------*/ BL_NONBLOCK_EXPORT bl_err bl_mpmc_bt_consume_sc( bl_mpmc_bt* q, bl_mpmc_b_ticket* ticket, void* data ) { bl_u8* slot; bl_err err = bl_mpmc_b_consume_prepare_sc (&q->q, ticket, &slot); if (bl_likely (!err.own)) { memcpy (data, slot, q->sizeof_type); bl_mpmc_b_consume_commit (&q->q, *ticket); } return err; } /*----------------------------------------------------------------------------*/ #ifdef __cplusplus } /*extern "C" {*/ #endif
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include <folly/Exception.h> #ifndef ABI44_0_0RN_EXPORT #ifdef _MSC_VER #define ABI44_0_0RN_EXPORT #else #define ABI44_0_0RN_EXPORT __attribute__((visibility("default"))) #endif #endif namespace ABI44_0_0facebook { namespace ABI44_0_0React { // JSExecutor functions sometimes take large strings, on the order of // megabytes. Copying these can be expensive. Introducing a // move-only, non-CopyConstructible type will let the compiler ensure // that no copies occur. folly::MoveWrapper should be used when a // large string needs to be curried into a std::function<>, which must // by CopyConstructible. class JSBigString { public: JSBigString() = default; // Not copyable JSBigString(const JSBigString &) = delete; JSBigString &operator=(const JSBigString &) = delete; virtual ~JSBigString() {} virtual bool isAscii() const = 0; // This needs to be a \0 terminated string virtual const char *c_str() const = 0; // Length of the c_str without the NULL byte. virtual size_t size() const = 0; }; // Concrete JSBigString implementation which holds a std::string // instance. class JSBigStdString : public JSBigString { public: JSBigStdString(std::string str, bool isAscii = false) : m_isAscii(isAscii), m_str(std::move(str)) {} bool isAscii() const override { return m_isAscii; } const char *c_str() const override { return m_str.c_str(); } size_t size() const override { return m_str.size(); } private: bool m_isAscii; std::string m_str; }; // Concrete JSBigString implementation which holds a heap-allocated // buffer, and provides an accessor for writing to it. This can be // used to construct a JSBigString in place, such as by reading from a // file. class ABI44_0_0RN_EXPORT JSBigBufferString : public JSBigString { public: JSBigBufferString(size_t size) : m_data(new char[size + 1]), m_size(size) { // Guarantee nul-termination. The caller is responsible for // filling in the rest of m_data. m_data[m_size] = '\0'; } ~JSBigBufferString() { delete[] m_data; } bool isAscii() const override { return true; } const char *c_str() const override { return m_data; } size_t size() const override { return m_size; } char *data() { return m_data; } private: char *m_data; size_t m_size; }; // JSBigString interface implemented by a file-backed mmap region. class ABI44_0_0RN_EXPORT JSBigFileString : public JSBigString { public: JSBigFileString(int fd, size_t size, off_t offset = 0); ~JSBigFileString(); bool isAscii() const override { return true; } const char *c_str() const override; size_t size() const override; int fd() const; static std::unique_ptr<const JSBigFileString> fromPath( const std::string &sourceURL); private: int m_fd; // The file descriptor being mmaped size_t m_size; // The size of the mmaped region mutable off_t m_pageOff; // The offset in the mmaped region to the data. off_t m_mapOff; // The offset in the file to the mmaped region. mutable const char *m_data; // Pointer to the mmaped region. }; } // namespace ABI44_0_0React } // namespace ABI44_0_0facebook
////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2012, John Haddon. All rights reserved. // Copyright (c) 2013, Image Engine Design Inc. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above // copyright notice, this list of conditions and the following // disclaimer. // // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided with // the distribution. // // * Neither the name of John Haddon nor the names of // any other contributors to this software may be used to endorse or // promote products derived from this software without specific prior // written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////// #ifndef GAFFER_PATHMATCHER_H #define GAFFER_PATHMATCHER_H #include "boost/shared_ptr.hpp" #include "IECore/TypedData.h" #include "GafferScene/Filter.h" namespace GafferScene { /// The PathMatcher class provides an acceleration structure for matching /// paths against a sequence of reference paths. It provides the internal /// implementation for the PathFilter. class PathMatcher { public : PathMatcher(); /// Constructs a deep copy of other. PathMatcher( const PathMatcher &other ); template<typename Iterator> PathMatcher( Iterator pathsBegin, Iterator pathsEnd ); /// \todo Should this keep the existing tree in place, /// but just remove the terminator flags on any items /// not present in the new paths? This might give /// better performance for selections and expansions /// which will tend to be adding and removing the same /// paths repeatedly. template<typename Iterator> void init( Iterator pathsBegin, Iterator pathsEnd ); /// Returns true if the path was added, false if /// it was already there. bool addPath( const std::string &path ); bool addPath( const std::vector<IECore::InternedString> &path ); /// Returns true if the path was removed, false if /// it was not there. bool removePath( const std::string &path ); bool removePath( const std::vector<IECore::InternedString> &path ); /// Removes the specified path and all descendant paths. /// Returns true if something was removed, false otherwise. bool prune( const std::string &path ); bool prune( const std::vector<IECore::InternedString> &path ); void clear(); bool isEmpty() const; /// Fills the paths container with all the paths held /// within this matcher. void paths( std::vector<std::string> &paths ) const; /// Result is a bitwise or of the relevant values /// from Filter::Result. unsigned match( const std::string &path ) const; unsigned match( const std::vector<IECore::InternedString> &path ) const; bool operator == ( const PathMatcher &other ) const; bool operator != ( const PathMatcher &other ) const; private : struct Node; template<typename NameIterator> bool addPath( const NameIterator &start, const NameIterator &end ); template<typename NameIterator> void removeWalk( Node *node, const NameIterator &start, const NameIterator &end, const bool prune, bool &removed ); void pathsWalk( Node *node, const std::string &path, std::vector<std::string> &paths ) const; template<typename NameIterator> void matchWalk( Node *node, const NameIterator &start, const NameIterator &end, unsigned &result ) const; boost::shared_ptr<Node> m_root; }; } // namespace GafferScene #include "GafferScene/PathMatcher.inl" #endif // GAFFER_PATHMATCHER_H
/*============================================================================ The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center (DKFZ) All rights reserved. Use of this source code is governed by a 3-clause BSD license that can be found in the LICENSE file. ============================================================================*/ #ifndef mitkPURFClassifier_h #define mitkPURFClassifier_h #include <MitkCLVigraRandomForestExports.h> #include <mitkAbstractClassifier.h> //#include <vigra/multi_array.hxx> #include <vigra/random_forest.hxx> #include <mitkBaseData.h> namespace mitk { class MITKCLVIGRARANDOMFOREST_EXPORT PURFClassifier : public AbstractClassifier { public: mitkClassMacro(PURFClassifier, AbstractClassifier) itkFactorylessNewMacro(Self) itkCloneMacro(Self) PURFClassifier(); ~PURFClassifier() override; void Train(const Eigen::MatrixXd &X, const Eigen::MatrixXi &Y) override; Eigen::MatrixXi Predict(const Eigen::MatrixXd &X) override; Eigen::MatrixXi PredictWeighted(const Eigen::MatrixXd &X); bool SupportsPointWiseWeight() override; bool SupportsPointWiseProbability() override; void ConvertParameter(); vigra::ArrayVector<double> CalculateKappa(const Eigen::MatrixXd & X_in, const Eigen::MatrixXi &Y_in); void SetRandomForest(const vigra::RandomForest<int> & rf); const vigra::RandomForest<int> & GetRandomForest() const; void UsePointWiseWeight(bool) override; void SetMaximumTreeDepth(int); void SetMinimumSplitNodeSize(int); void SetPrecision(double); void SetSamplesPerTree(double); void UseSampleWithReplacement(bool); void SetTreeCount(int); void SetWeightLambda(double); void PrintParameter(std::ostream &str = std::cout); void SetClassProbabilities(Eigen::VectorXd probabilities); Eigen::VectorXd GetClassProbabilites(); private: // *------------------- // * THREADING // *------------------- struct TrainingData; struct PredictionData; struct EigenToVigraTransform; struct Parameter; vigra::MultiArrayView<2, double> m_Probabilities; Eigen::MatrixXd m_TreeWeights; Eigen::VectorXd m_ClassProbabilities; Parameter * m_Parameter; vigra::RandomForest<int> m_RandomForest; static ITK_THREAD_RETURN_TYPE TrainTreesCallback(void *); static ITK_THREAD_RETURN_TYPE PredictCallback(void *); static ITK_THREAD_RETURN_TYPE PredictWeightedCallback(void *); static void VigraPredictWeighted(PredictionData *data, vigra::MultiArrayView<2, double> & X, vigra::MultiArrayView<2, int> & Y, vigra::MultiArrayView<2, double> & P); }; } #endif //mitkPURFClassifier_h
// Copyright 2010-2016, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef MOZC_BASE_UPDATE_UTIL_H_ #define MOZC_BASE_UPDATE_UTIL_H_ #include "base/port.h" namespace mozc { class UpdateUtil { public: // Writes a registry value for usage tracking by Omaha. // Returns true if the value is successfully written. static bool WriteActiveUsageInfo(); private: DISALLOW_IMPLICIT_CONSTRUCTORS(UpdateUtil); }; } // namespace mozc #endif // MOZC_BASE_UPDATE_UTIL_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_PUBLIC_BROWSER_UTILITY_PROCESS_HOST_H_ #define CONTENT_PUBLIC_BROWSER_UTILITY_PROCESS_HOST_H_ #include "base/environment.h" #include "base/process/launch.h" #include "base/threading/thread.h" #include "content/common/content_export.h" #include "ipc/ipc_sender.h" namespace base { class FilePath; class SequencedTaskRunner; } namespace content { class UtilityProcessHostClient; struct ChildProcessData; typedef base::Thread* (*UtilityMainThreadFactoryFunction)( const std::string& id); // This class acts as the browser-side host to a utility child process. A // utility process is a short-lived process that is created to run a specific // task. This class lives solely on the IO thread. // If you need a single method call in the process, use StartFooBar(p). // If you need multiple batches of work to be done in the process, use // StartBatchMode(), then multiple calls to StartFooBar(p), then finish with // EndBatchMode(). // // Note: If your class keeps a ptr to an object of this type, grab a weak ptr to // avoid a use after free since this object is deleted synchronously but the // client notification is asynchronous. See http://crbug.com/108871. class UtilityProcessHost : public IPC::Sender, public base::SupportsWeakPtr<UtilityProcessHost> { public: // Used to create a utility process. CONTENT_EXPORT static UtilityProcessHost* Create( UtilityProcessHostClient* client, base::SequencedTaskRunner* client_task_runner); virtual ~UtilityProcessHost() {} // Starts utility process in batch mode. Caller must call EndBatchMode() // to finish the utility process. virtual bool StartBatchMode() = 0; // Ends the utility process. Must be called after StartBatchMode(). virtual void EndBatchMode() = 0; // Allows a directory to be opened through the sandbox, in case it's needed by // the operation. virtual void SetExposedDir(const base::FilePath& dir) = 0; // Allows a mdns to use network in sandbox. virtual void EnableMDns() = 0; // Make the process run without a sandbox. virtual void DisableSandbox() = 0; // If the sandbox is being used and we are on Linux, launch the process from // the zygote. Can only be used for tasks that do not require FS access. virtual void EnableZygote() = 0; // Returns information about the utility child process. virtual const ChildProcessData& GetData() = 0; #if defined(OS_POSIX) virtual void SetEnv(const base::EnvironmentMap& env) = 0; #endif CONTENT_EXPORT static void RegisterUtilityMainThreadFactory( UtilityMainThreadFactoryFunction create); }; }; // namespace content #endif // CONTENT_PUBLIC_BROWSER_UTILITY_PROCESS_HOST_H_
/* * Copyright (c) 2014, Quarkslab * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * - Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - Neither the name of Quarkslab nor the names of its contributors may be used * to endorse or promote products derived from this software without specific * prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef LEELOO_LIST_INTERVALS_WITH_PROPERTIES_H #define LEELOO_LIST_INTERVALS_WITH_PROPERTIES_H #include <leeloo/uni.h> #include <leeloo/list_intervals.h> #include <leeloo/list_intervals_properties.h> namespace leeloo { template <class ListInterval, class Property, class PropertiesStorage = PropertiesHorizontal> class list_intervals_with_properties: public ListInterval { public: typedef ListInterval list_intervals_type; typedef typename list_intervals_type::interval_type interval_type; typedef typename list_intervals_type::size_type size_type; typedef typename interval_type::base_type base_type; typedef Property property_type; typedef list_intervals_properties<interval_type, property_type, size_type, PropertiesStorage> list_intervals_properties_type; public: template <template <class T_, bool atomic_> class UPRNG, class Fset, class RandEngine> void random_sets_with_properties(size_type size_div, Fset const& fset, RandEngine const& rand_eng) const { // There might be a more efficient way to do this if (size_div <= 0) { size_div = 1; } std::vector<property_type const*> properties; properties.resize(size_div); // AG: 'this' is necessary because the compiler can't know (before // instantiation) that random_sets will be part of ListIntervals this->template random_sets<UPRNG>(size_div, [this, &properties, &fset](base_type* set, size_type size) { for (size_type i = 0; i < size; i++) { properties[i] = property_of(set[i]); } fset(set, &properties[0], size); }, rand_eng); } template <template <class T_, bool atomic_> class UPRNG, class Fsize_div, class Fset, class RandEngine> void random_sets_with_properties(Fsize_div const& fsize_div, size_t const size_max, Fset const& fset, RandEngine const& rand_eng) const { // There might be a more efficient way to do this if (size_max <= 0) { return; } std::vector<property_type const*> properties; properties.resize(size_max); // AG: 'this' is necessary because the compiler can't know (before // instantiation) that random_sets will be part of ListIntervals this->template random_sets<UPRNG>(fsize_div, size_max, [this, &properties, &fset](base_type* set, size_type const size) { for (size_type i = 0; i < size; i++) { properties[i] = property_of(set[i]); } fset(set, &properties[0], size); }, rand_eng); } template <class Fset, class RandEngine> inline void random_sets_with_properties(size_type size_div, Fset const& fset, RandEngine const& rand_eng) const { random_sets_with_properties<uni>(size_div, fset, rand_eng); } template <class Fsize_div, class Fset, class RandEngine> inline void random_sets_with_properties(Fsize_div const& fsize_div, size_t const size_max, Fset const& fset, RandEngine const& rand_eng) const { random_sets_with_properties<uni>(fsize_div, size_max, fset, rand_eng); } public: // From list_intervals_properties inline void add_property(interval_type const& i, property_type const& p) { properties().add_property(i, p); } inline void add_property(interval_type const& i, property_type&& p) { properties().add_property(i, std::move(p)); } inline void add_property(base_type const a, base_type const b, property_type const& p) { properties().add_property(a, b, p); } inline void add_property(base_type const a, base_type const b, property_type&& p) { properties().add_property(a, b, std::move(p)); } template <class FAdd, class FRemove> inline void aggregate_properties(FAdd const& fadd, FRemove const& fremove) { properties().aggregate_properties(fadd, fremove); } template <class FAdd, class FRemove, class FDuplicate> inline void aggregate_properties(FAdd const& fadd, FRemove const& fremove, FDuplicate const& fdup) { properties().aggregate_properties(fadd, fremove, fdup); } template <class FAdd> inline void aggregate_properties_no_rem(FAdd const& fadd) { properties().aggregate_properties_no_rem(fadd); } template <class FAdd, class FDuplicate> inline void aggregate_properties_no_rem(FAdd const& fadd, FDuplicate const& fdup) { properties().aggregate_properties_no_rem(fadd, fdup); } inline property_type const* property_of(base_type const& v) const { return properties().property_of(v); } public: inline list_intervals_properties_type& properties() { return _props; } inline list_intervals_properties_type const& properties() const { return _props; } private: list_intervals_properties_type _props; }; } #endif
/* * mod_delay.c * * Copyright (c) 2001 Dug Song <dugsong@monkey.org> * * $Id: mod_delay.c,v 1.4 2002/04/07 22:55:20 dugsong Exp $ */ #include "config.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include "pkt.h" #include "mod.h" #define DELAY_FIRST 1 #define DELAY_LAST 2 #define DELAY_RANDOM 3 struct delay_data { rand_t *rnd; int which; struct timeval tv; }; void * delay_close(void *d) { struct delay_data *data = (struct delay_data *)d; if (data != NULL) { rand_close(data->rnd); free(data); } return (NULL); } void * delay_open(int argc, char *argv[]) { struct delay_data *data; uint64_t usec; if (argc != 3) return (NULL); if ((data = malloc(sizeof(*data))) == NULL) return (NULL); data->rnd = rand_open(); if (strcasecmp(argv[1], "first") == 0) data->which = DELAY_FIRST; else if (strcasecmp(argv[1], "last") == 0) data->which = DELAY_LAST; else if (strcasecmp(argv[1], "random") == 0) data->which = DELAY_RANDOM; else return (delay_close(data)); if ((usec = atoi(argv[2])) <= 0) return (delay_close(data)); usec *= 1000; data->tv.tv_sec = usec / 1000000; data->tv.tv_usec = usec % 1000000; return (data); } int delay_apply(void *d, struct pktq *pktq) { struct delay_data *data = (struct delay_data *)d; struct pkt *pkt; if (data->which == DELAY_FIRST) pkt = TAILQ_FIRST(pktq); else if (data->which == DELAY_LAST) pkt = TAILQ_LAST(pktq, pktq); else pkt = pktq_random(data->rnd, pktq); memcpy(&pkt->pkt_ts, &data->tv, sizeof(pkt->pkt_ts)); return (0); } struct mod mod_delay = { "delay", /* name */ "delay first|last|random <ms>", /* usage */ delay_open, /* open */ delay_apply, /* apply */ delay_close /* close */ };
/** @copyright Copyright (C) 2011 Oleg Kertanov <okertanov@gmail.com> @license BSD */ #pragma once #include "types.h" typedef struct gdt_entry_struct { uint16_t limit_low; uint16_t base_low; uint8_t base_middle; uint8_t access; uint8_t granularity; uint8_t base_high; } __attribute__((packed)) gdt_entry_t; typedef struct gdt_ptr_struct { uint16_t limit; uint32_t base; } __attribute__((packed)) gdt_ptr_t; void sys_init_gtd(void); extern void gdt_flush(uint32_t); void gdt_set_gate(int32_t, uint32_t, uint32_t, uint8_t, uint8_t);
/* This file is part of AstC2C. Copyright (c) STMicroelectronics, 2013. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Authors: Thierry Lepley */ #ifndef VECTOR_BUILTINS_COMMON_H #define VECTOR_BUILTINS_COMMON_H /* 'min', 'max' and 'clamp' implemented in the 'integer' library */ /* Degrees */ #define DEGREES_SCALAR_N \ static inline float __ocl_degrees_float (float radians) { \ return (180.0f / 0x1.921fb6p+1f ) * radians; \ } #define DEGREES_VECTOR_N(nb_elem) \ static inline float##nb_elem __ocl_degrees_float##nb_elem (float##nb_elem radians) { \ float##nb_elem s; \ int i; \ for (i=0;i<nb_elem;i++) { \ s.element[i]= ( 180.0f / 0x1.921fb6p+1f ) * radians.element[i] ; \ } \ return s; \ } DEGREES_SCALAR_N DEGREES_VECTOR_N(2) DEGREES_VECTOR_N(3) DEGREES_VECTOR_N(4) DEGREES_VECTOR_N(8) DEGREES_VECTOR_N(16) /* MIX : x+(y-x)*a */ #define MIX_SCALAR_N \ static inline float __ocl_mix_float (float x, float y, float a) { \ return x+(y-x)*a; \ } #define MIX_VECTOR_N(nb_elem) \ static inline float##nb_elem __ocl_mix_float##nb_elem (float##nb_elem x, float##nb_elem y, float a) { \ float##nb_elem s; \ int i; \ for (i=0;i<nb_elem;i++) { \ s.element[i]=x.element[i]+(y.element[i]-x.element[i])*a; \ } \ return s; \ } MIX_SCALAR_N MIX_VECTOR_N(2) MIX_VECTOR_N(3) MIX_VECTOR_N(4) MIX_VECTOR_N(8) MIX_VECTOR_N(16) /* Radians */ #define RADIANS_SCALAR_N \ static inline float __ocl_radians_float (float degrees) { \ return ( 0x1.921fb6p+1f / 180.0f ) * degrees; \ } #define RADIANS_VECTOR_N(nb_elem) \ static inline float##nb_elem __ocl_radians_float##nb_elem (float##nb_elem degrees) { \ float##nb_elem s; \ int i; \ for (i=0;i<nb_elem;i++) { \ s.element[i]= ( 0x1.921fb6p+1f / 180.0f ) * degrees.element[i] ; \ } \ return s; \ } RADIANS_SCALAR_N RADIANS_VECTOR_N(2) RADIANS_VECTOR_N(3) RADIANS_VECTOR_N(4) RADIANS_VECTOR_N(8) RADIANS_VECTOR_N(16) /* STEP */ #define STEP_SCALAR_N \ static inline float __ocl_step_float_float (float edge, float x) { \ return (x < edge) ? 0.0f : 1.0; \ } #define STEP_VECTOR_N(nb_elem) \ static inline float##nb_elem __ocl_step_float##nb_elem##_float##nb_elem (float##nb_elem edge, float##nb_elem x) { \ float##nb_elem s; \ int i; \ for (i=0;i<nb_elem;i++) { \ s.element[i]=(x.element[i] < edge.element[i]) ? 0.0f : 1.0; \ } \ return s; \ } \ static inline float##nb_elem __ocl_step_float_float##nb_elem (float edge, float##nb_elem x) { \ float##nb_elem s; \ int i; \ for (i=0;i<nb_elem;i++) { \ s.element[i]=(x.element[i] < edge) ? 0.0f : 1.0; \ } \ return s; \ } STEP_SCALAR_N STEP_VECTOR_N(2) STEP_VECTOR_N(3) STEP_VECTOR_N(4) STEP_VECTOR_N(8) STEP_VECTOR_N(16) /* SMOOTHSTEP */ #define SMOOTHSTEP_SCALAR_N \ static inline float __ocl_smoothstep_float_float (float edge0, float edge1, float x) { \ float t= (x <= edge0) ? 0.0f : ((x >= edge1) ? 1.0f : (x-edge0)/(edge1-edge0)) ; \ return t*t*(3.0f - 2.0f * t); \ } #define SMOOTHSTEP_VECTOR_N(nb_elem) \ static inline float##nb_elem __ocl_smoothstep_float##nb_elem##_float##nb_elem (float##nb_elem edge0, float##nb_elem edge1, float##nb_elem x) { \ float##nb_elem s; \ int i; \ for (i=0;i<nb_elem;i++) { \ float t= (x.element[i] <= edge0.element[i]) ? 0.0f : \ ((x.element[i] >= edge1.element[i]) ? 1.0f : (x.element[i]-edge0.element[i])/(edge1.element[i]-edge0.element[i])) ; \ s.element[i]= t*t*(3.0f - 2.0f * t); \ } \ return s; \ } \ static inline float##nb_elem __ocl_smoothstep_float_float##nb_elem (float edge0, float edge1, float##nb_elem x) { \ float##nb_elem s; \ int i; \ for (i=0;i<nb_elem;i++) { \ float t= (x.element[i] <= edge0) ? 0.0f : ((x.element[i] >= edge1) ? 1.0f : (x.element[i]-edge0)/(edge1-edge0)) ; \ s.element[i]= t*t*(3.0f - 2.0f * t); \ } \ return s; \ } SMOOTHSTEP_SCALAR_N SMOOTHSTEP_VECTOR_N(2) SMOOTHSTEP_VECTOR_N(3) SMOOTHSTEP_VECTOR_N(4) SMOOTHSTEP_VECTOR_N(8) SMOOTHSTEP_VECTOR_N(16) /* Sign */ /* [TBW] Note: NaN should be managed */ #define SIGN_SCALAR_N \ static inline float __ocl_sign_float (float x) { \ return (x>0.0f)? 1.0f : (x<0.0f) ? -1.0f : x ; \ } #define SIGN_VECTOR_N(nb_elem) \ static inline float##nb_elem __ocl_sign_float##nb_elem (float##nb_elem x) { \ float##nb_elem s; \ int i; \ for (i=0;i<nb_elem;i++) { \ s.element[i]= (x.element[i]>0.0f)? 1.0f : (x.element[i]<0.0f) ? -1.0f : x.element[i] ; \ } \ return s; \ } SIGN_SCALAR_N SIGN_VECTOR_N(2) SIGN_VECTOR_N(3) SIGN_VECTOR_N(4) SIGN_VECTOR_N(8) SIGN_VECTOR_N(16) #endif
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_USB_WEB_USB_PERMISSION_PROVIDER_H_ #define CHROME_BROWSER_USB_WEB_USB_PERMISSION_PROVIDER_H_ #include "device/devices_app/usb/public/interfaces/permission_provider.mojom.h" #include "third_party/mojo/src/mojo/public/cpp/bindings/array.h" #include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h" #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" namespace content { class RenderFrameHost; } class WebUSBPermissionProvider : public device::usb::PermissionProvider { public: static void Create( content::RenderFrameHost* render_frame_host, mojo::InterfaceRequest<device::usb::PermissionProvider> request); ~WebUSBPermissionProvider() override; private: WebUSBPermissionProvider(content::RenderFrameHost* render_frame_host, mojo::InterfaceRequest<PermissionProvider> request); // device::usb::PermissionProvider implementation. void HasDevicePermission( mojo::Array<mojo::String> requested_guids, const HasDevicePermissionCallback& callback) override; mojo::StrongBinding<PermissionProvider> binding_; content::RenderFrameHost* const render_frame_host_; }; #endif // CHROME_BROWSER_USB_WEB_USB_PERMISSION_PROVIDER_H_
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_ANDROID_DEVICE_UTILS_H_ #define CHROME_BROWSER_ANDROID_DEVICE_UTILS_H_ #include <string> namespace base { namespace android { // Return the unique identifier of this device. std::string GetAndroidId(); // Return the end-user-visible name for this device. std::string GetModel(); // Return if the device is a tablet. Should only be called when host is chrome. bool IsTabletUi(); } // namespace android } // namespace base #endif // CHROME_BROWSER_ANDROID_DEVICE_UTILS_H_
/** * * Author: Paul McCarthy <pauld.mccarthy@gmail.com> */ #include <argp.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> #include "util/startup.h" #include "graph/graph.h" #include "io/ngdb_graph.h" #include "io/dot.h" static char doc[] = "cdot - convert a ngdb file to a dot file"; typedef struct args { char *input; char *output; char *cmap; uint16_t dotopts; } args_t; static struct argp_option options[] = { {"colormap", 'c', "FILE", 0, "file specifying label <-> color mappings"}, {"randcolor", 'r', NULL, 0, "randomise per-label colours"}, {"edgelabels", 'e', NULL, 0, "set edge weights as labels"}, {"edgewidth", 'w', NULL, 0, "set edge width proportional to edge weight"}, {"nodelval", 'n', NULL, 0, "include node labels in dot labels"}, {"nodeid", 'i', NULL, 0, "include node IDs in dot labels"}, {"nodepos", 'p', NULL, 0, "include node positions"}, {"cmpcolor", 'm', NULL, 0, "randomise per-component colours"}, {"omitedges", 'o', NULL, 0, "do not output edges"}, {"undir", 'u', NULL, 0, "only output edges one way " \ "(e.g. output u -- v, but not v -- u)"}, {0} }; static error_t _parse_opt(int key, char *arg, struct argp_state *state) { args_t *a = state->input; switch(key) { case 'c': a->cmap = arg; break; case 'r': a->dotopts |= (1 << DOT_RAND_COLOUR); break; case 'e': a->dotopts |= (1 << DOT_EDGE_LABELS); break; case 'w': a->dotopts |= (1 << DOT_EDGE_WEIGHT); break; case 'n': a->dotopts |= (1 << DOT_NODE_LABELVAL); break; case 'i': a->dotopts |= (1 << DOT_NODE_NODEID); break; case 'p': a->dotopts |= (1 << DOT_NODE_POS); break; case 'm': a->dotopts |= (1 << DOT_CMP_COLOUR); break; case 'o': a->dotopts |= (1 << DOT_OMIT_EDGES); break; case 'u': a->dotopts |= (1 << DOT_UNDIR); break; case ARGP_KEY_ARG: if (state->arg_num == 0) a->input = arg; else if (state->arg_num == 1) a->output = arg; else argp_usage(state); break; case ARGP_KEY_END: if (state->arg_num < 2) argp_usage(state); break; default: return ARGP_ERR_UNKNOWN; } return 0; } int main (int argc, char *argv[]) { FILE *hd; graph_t g; args_t args; struct argp argp = {options, _parse_opt, "INPUT OUTPUT", doc}; memset(&args, 0, sizeof(args_t)); startup("cdot", argc, argv, &argp, &args); if (ngdb_read(args.input, &g)) { printf("error loading ngdb file %s\n", args.input); goto fail; } hd = fopen(args.output, "wt"); if (hd == NULL) goto fail; dot_write(hd, &g, args.cmap, args.dotopts); fclose(hd); return 0; fail: return 1; }
/* * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef WEBRTC_VIDEO_RAMPUP_TESTS_H_ #define WEBRTC_VIDEO_RAMPUP_TESTS_H_ #include <map> #include <string> #include <vector> #include "webrtc/base/scoped_ptr.h" #include "webrtc/call.h" #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h" #include "webrtc/system_wrappers/interface/event_wrapper.h" #include "webrtc/test/call_test.h" #include "webrtc/video/transport_adapter.h" namespace webrtc { static const int kTransmissionTimeOffsetExtensionId = 6; static const int kAbsSendTimeExtensionId = 7; static const unsigned int kSingleStreamTargetBps = 1000000; class Clock; class CriticalSectionWrapper; class ReceiveStatistics; class RtpHeaderParser; class RTPPayloadRegistry; class RtpRtcp; class StreamObserver : public newapi::Transport, public RemoteBitrateObserver { public: typedef std::map<uint32_t, int> BytesSentMap; typedef std::map<uint32_t, uint32_t> SsrcMap; StreamObserver(const SsrcMap& rtx_media_ssrcs, newapi::Transport* feedback_transport, Clock* clock, RemoteBitrateEstimatorFactory* rbe_factory, RateControlType control_type); void set_expected_bitrate_bps(unsigned int expected_bitrate_bps); void set_start_bitrate_bps(unsigned int start_bitrate_bps); virtual void OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs, unsigned int bitrate) OVERRIDE; virtual bool SendRtp(const uint8_t* packet, size_t length) OVERRIDE; virtual bool SendRtcp(const uint8_t* packet, size_t length) OVERRIDE; EventTypeWrapper Wait(); private: void ReportResult(const std::string& measurement, size_t value, const std::string& units); void TriggerTestDone() EXCLUSIVE_LOCKS_REQUIRED(crit_); Clock* const clock_; const rtc::scoped_ptr<EventWrapper> test_done_; const rtc::scoped_ptr<RtpHeaderParser> rtp_parser_; rtc::scoped_ptr<RtpRtcp> rtp_rtcp_; internal::TransportAdapter feedback_transport_; const rtc::scoped_ptr<ReceiveStatistics> receive_stats_; const rtc::scoped_ptr<RTPPayloadRegistry> payload_registry_; rtc::scoped_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_; const rtc::scoped_ptr<CriticalSectionWrapper> crit_; unsigned int expected_bitrate_bps_ GUARDED_BY(crit_); unsigned int start_bitrate_bps_ GUARDED_BY(crit_); SsrcMap rtx_media_ssrcs_ GUARDED_BY(crit_); size_t total_sent_ GUARDED_BY(crit_); size_t padding_sent_ GUARDED_BY(crit_); size_t rtx_media_sent_ GUARDED_BY(crit_); int total_packets_sent_ GUARDED_BY(crit_); int padding_packets_sent_ GUARDED_BY(crit_); int rtx_media_packets_sent_ GUARDED_BY(crit_); int64_t test_start_ms_ GUARDED_BY(crit_); int64_t ramp_up_finished_ms_ GUARDED_BY(crit_); }; class LowRateStreamObserver : public test::DirectTransport, public RemoteBitrateObserver, public PacketReceiver { public: LowRateStreamObserver(newapi::Transport* feedback_transport, Clock* clock, size_t number_of_streams, bool rtx_used); virtual void SetSendStream(VideoSendStream* send_stream); virtual void OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs, unsigned int bitrate); virtual bool SendRtp(const uint8_t* data, size_t length) OVERRIDE; virtual DeliveryStatus DeliverPacket(const uint8_t* packet, size_t length) OVERRIDE; virtual bool SendRtcp(const uint8_t* packet, size_t length) OVERRIDE; // Produces a string similar to "1stream_nortx", depending on the values of // number_of_streams_ and rtx_used_; std::string GetModifierString(); // This method defines the state machine for the ramp up-down-up test. void EvolveTestState(unsigned int bitrate_bps); EventTypeWrapper Wait(); private: static const unsigned int kHighBandwidthLimitBps = 80000; static const unsigned int kExpectedHighBitrateBps = 60000; static const unsigned int kLowBandwidthLimitBps = 20000; static const unsigned int kExpectedLowBitrateBps = 20000; enum TestStates { kFirstRampup, kLowRate, kSecondRampup }; Clock* const clock_; const size_t number_of_streams_; const bool rtx_used_; const rtc::scoped_ptr<EventWrapper> test_done_; const rtc::scoped_ptr<RtpHeaderParser> rtp_parser_; rtc::scoped_ptr<RtpRtcp> rtp_rtcp_; internal::TransportAdapter feedback_transport_; const rtc::scoped_ptr<ReceiveStatistics> receive_stats_; rtc::scoped_ptr<RemoteBitrateEstimator> remote_bitrate_estimator_; rtc::scoped_ptr<CriticalSectionWrapper> crit_; VideoSendStream* send_stream_ GUARDED_BY(crit_); FakeNetworkPipe::Config forward_transport_config_ GUARDED_BY(crit_); TestStates test_state_ GUARDED_BY(crit_); int64_t state_start_ms_ GUARDED_BY(crit_); int64_t interval_start_ms_ GUARDED_BY(crit_); unsigned int last_remb_bps_ GUARDED_BY(crit_); size_t sent_bytes_ GUARDED_BY(crit_); size_t total_overuse_bytes_ GUARDED_BY(crit_); bool suspended_in_stats_ GUARDED_BY(crit_); }; class RampUpTest : public test::CallTest { protected: void RunRampUpTest(bool rtx, size_t num_streams, unsigned int start_bitrate_bps, const std::string& extension_type); void RunRampUpDownUpTest(size_t number_of_streams, bool rtx); }; } // namespace webrtc #endif // WEBRTC_VIDEO_RAMPUP_TESTS_H_
/* GDOME Document Object Model C API for openjs * $Id: gdome_extra.h 10131 2009-11-17 11:48:19Z jheusala $ */ #ifndef OPENJS_EXTENSIONS_CGDOME_EXTRA_H #define OPENJS_EXTENSIONS_CGDOME_EXTRA_H 1 #include <gdome.h> #include "pointer.h" #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /** Create GdomeException pointer */ extern inline GdomeException* gdome_extra_exc_new(); /** Delete GdomeException pointer */ extern inline void gdome_extra_exc_del(GdomeException* exc); /** Get exception value */ extern inline GdomeException gdome_extra_exc_getvalue(GdomeException* exc); /** Set exception value */ extern inline void gdome_extra_exc_setvalue(GdomeException* exc, const GdomeException x); extern inline GdomeText* gdome_extra_cast_node_to_text(GdomeNode*); extern inline GdomeNode* gdome_extra_cast_text_to_node(GdomeText*); extern inline GdomeNode* gdome_extra_cast_element_to_node(GdomeElement*); /** gdome_extra_el_appendChild */ extern inline GdomeNode* gdome_extra_el_appendChild(GdomeElement*, GdomeNode*, GdomeException*); /** Integer gateway to C gdome_el_appendChild */ extern inline int_pointer_type gdome_int_el_appendChild(int_pointer_type, int_pointer_type, int_pointer_type); #ifdef __cplusplus } #endif /* __cplusplus */ #endif
/* _loader.c */ #include <stdint.h> extern char bss; extern char endOfBinary; int main(); void * memset(void * destiny, int32_t c, uint64_t length); int _start() { memset(&bss, 0, &endOfBinary - &bss); return main(); } void * memset(void * destiation, int32_t c, uint64_t length) { uint8_t chr = (uint8_t)c; char * dst = (char*)destiation; while(length--) dst[length] = chr; return destiation; }
#ifndef _SYSLOG_H_ #define _SYSLOG_H_ #include "util.h" uint64_t get_total_lines(char *filename); void get_line(char *filename, uint64_t line); #endif
/*========================================================================= Program: Visualization Toolkit Module: vtkXMLDataReader.h Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen All rights reserved. See Copyright.txt or http://www.kitware.com/Copyright.htm for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notice for more information. =========================================================================*/ // .NAME vtkXMLDataReader - Superclass for VTK XML file readers. // .SECTION Description // vtkXMLDataReader provides functionality common to all VTK XML file // readers. Concrete subclasses call upon this functionality when // needed. // .SECTION See Also // vtkXMLPDataReader #ifndef __vtkXMLDataReader_h #define __vtkXMLDataReader_h #include "vtkIOXMLExport.h" // For export macro #include "vtkXMLReader.h" class VTKIOXML_EXPORT vtkXMLDataReader : public vtkXMLReader { public: vtkTypeMacro(vtkXMLDataReader,vtkXMLReader); void PrintSelf(ostream& os, vtkIndent indent); // Description: // Get the number of points in the output. virtual vtkIdType GetNumberOfPoints()=0; // Description: // Get the number of cells in the output. virtual vtkIdType GetNumberOfCells()=0; // For the specified port, copy the information this reader sets up in // SetupOutputInformation to outInfo virtual void CopyOutputInformation(vtkInformation *outInfo, int port); protected: vtkXMLDataReader(); ~vtkXMLDataReader(); int SetUpdateExtentInfo(vtkXMLDataElement *eDSA, vtkInformationVector *infoVector, int piece, int numPieces); // Add functionality to methods from superclass. virtual void CreateXMLParser(); virtual void DestroyXMLParser(); virtual void SetupOutputInformation(vtkInformation *outInfo); virtual void SetupUpdateExtentInformation(vtkInformation *outInfo); int ReadPrimaryElement(vtkXMLDataElement* ePrimary); void SetupOutputData(); // Setup the reader for a given number of pieces. virtual void SetupPieces(int numPieces); virtual void DestroyPieces(); // Read information from the file for the given piece. int ReadPiece(vtkXMLDataElement* ePiece, int piece); virtual int ReadPiece(vtkXMLDataElement* ePiece); // Read data from the file for the given piece. int ReadPieceData(int piece); virtual int ReadPieceData(); virtual void ReadXMLData(); // Read a data array whose tuples coorrespond to points or cells. virtual int ReadArrayForPoints(vtkXMLDataElement* da, vtkAbstractArray* outArray); virtual int ReadArrayForCells(vtkXMLDataElement* da, vtkAbstractArray* outArray); // Read an Array values starting at the given index and up to numValues. // This method assumes that the array is of correct size to // accomodate all numValues values. arrayIndex is the value index at which the read // values will be put in the array. int ReadArrayValues(vtkXMLDataElement* da, vtkIdType arrayIndex, vtkAbstractArray* array, vtkIdType startIndex, vtkIdType numValues); // Callback registered with the DataProgressObserver. static void DataProgressCallbackFunction(vtkObject*, unsigned long, void*, void*); // Progress callback from XMLParser. virtual void DataProgressCallback(); // The number of Pieces of data found in the file. int NumberOfPieces; // The PointData and CellData element representations for each piece. vtkXMLDataElement** PointDataElements; vtkXMLDataElement** CellDataElements; // The piece currently being read. int Piece; // The number of point/cell data arrays in the output. Valid after // SetupOutputData has been called. int NumberOfPointArrays; int NumberOfCellArrays; // Flag for whether DataProgressCallback should actually update // progress. int InReadData; // The observer to report progress from reading data from XMLParser. vtkCallbackCommand* DataProgressObserver; // Specify the last time step read, useful to know if we need to rearead data // //PointData int *PointDataTimeStep; unsigned long *PointDataOffset; int PointDataNeedToReadTimeStep(vtkXMLDataElement *eNested); //CellData int *CellDataTimeStep; unsigned long *CellDataOffset; int CellDataNeedToReadTimeStep(vtkXMLDataElement *eNested); private: vtkXMLDataReader(const vtkXMLDataReader&); // Not implemented. void operator=(const vtkXMLDataReader&); // Not implemented. }; #endif
/* * readdir.c * $Id$ * * Copyright (c) 2009 The MacPorts Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of The MacPorts Project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #if HAVE_CONFIG_H #include <config.h> #endif #include <dirent.h> #include <tcl.h> #include "readdir.h" /** * * Return the list of elements in a directory. * Since 1.60.4.2, the list doesn't include . and .. * * Synopsis: readdir directory */ int ReaddirCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { DIR *dirp; struct dirent *mp; Tcl_Obj *tcl_result; char *path; if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "directory"); return TCL_ERROR; } path = Tcl_GetString(objv[1]); dirp = opendir(path); if (!dirp) { Tcl_SetResult(interp, "Cannot read directory", TCL_STATIC); return TCL_ERROR; } tcl_result = Tcl_NewListObj(0, NULL); while ((mp = readdir(dirp))) { /* Skip . and .. */ if ((mp->d_name[0] != '.') || ((mp->d_name[1] != 0) /* "." */ && ((mp->d_name[1] != '.') || (mp->d_name[2] != 0)))) /* ".." */ { Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewStringObj(mp->d_name, -1)); } } closedir(dirp); Tcl_SetObjResult(interp, tcl_result); return TCL_OK; }
// ============================================================================= // PROJECT CHRONO - http://projectchrono.org // // Copyright (c) 2014 projectchrono.org // All right reserved. // // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file at the top level of the distribution and at // http://projectchrono.org/license-chrono.txt. // // ============================================================================= // Authors: Radu Serban, Asher Elmquist, Rainer Gericke // ============================================================================= // // Wrapper classes for modeling an entire Sedan vehicle assembly // (including the vehicle itself, the powertrain, and the tires). // // ============================================================================= #ifndef FEDA_H #define FEDA_H #include <array> #include <string> #include "chrono_vehicle/wheeled_vehicle/tire/ChPacejkaTire.h" #include "chrono_models/ChApiModels.h" #include "chrono_models/vehicle/feda/FEDA_Vehicle.h" #include "chrono_models/vehicle/feda/FEDA_Powertrain.h" #include "chrono_models/vehicle/feda/FEDA_SimpleMapPowertrain.h" #include "chrono_models/vehicle/feda/FEDA_RigidTire.h" #include "chrono_models/vehicle/feda/FEDA_Pac02Tire.h" namespace chrono { namespace vehicle { namespace feda { /// @addtogroup vehicle_models_feda /// @{ /// Definition of the FED-alpha assembly. /// This class encapsulates a concrete wheeled vehicle model with parameters corresponding to /// a FED-alpha, the powertrain model, and the 4 tires. It provides wrappers to access the different /// systems and subsystems, functions for specifying the driveline, powertrain, and tire types, /// as well as functions for controlling the visualization mode of each component. class CH_MODELS_API FEDA { public: enum class DamperMode { FSD, PASSIVE_LOW, PASSIVE_HIGH }; FEDA(); FEDA(ChSystem* system); ~FEDA(); void SetContactMethod(ChContactMethod val) { m_contactMethod = val; } void SetChassisFixed(bool val) { m_fixed = val; } void SetChassisCollisionType(CollisionType val) { m_chassisCollisionType = val; } void SetBrakeType(BrakeType brake_type) { m_brake_type = brake_type; } void SetPowertrainType(PowertrainModelType val) { m_powertrain_type = val; } void SetTireType(TireModelType val) { m_tireType = val; } void SetTireCollisionType(ChTire::CollisionType collType) { m_tire_collision_type = collType; } void SetTirePressureLevel(unsigned int pressure_level = 2) { m_tire_pressure_level = pressure_level; } void SetInitPosition(const ChCoordsys<>& pos) { m_initPos = pos; } void SetInitFwdVel(double fwdVel) { m_initFwdVel = fwdVel; } void SetInitWheelAngVel(const std::vector<double>& omega) { m_initOmega = omega; } void SetTireStepSize(double step_size) { m_tire_step_size = step_size; } void SetRideHeight_Low() { m_ride_height_config = 0; } void SetRideHeight_OnRoad() { m_ride_height_config = 1; } void SetRideHeight_ObstacleCrossing() { m_ride_height_config = 2; } void SetDamperMode(DamperMode theDamperMode = DamperMode::FSD); ChSystem* GetSystem() const { return m_vehicle->GetSystem(); } ChWheeledVehicle& GetVehicle() const { return *m_vehicle; } std::shared_ptr<ChChassis> GetChassis() const { return m_vehicle->GetChassis(); } std::shared_ptr<ChBodyAuxRef> GetChassisBody() const { return m_vehicle->GetChassisBody(); } std::shared_ptr<ChPowertrain> GetPowertrain() const { return m_vehicle->GetPowertrain(); } double GetTotalMass() const; void Initialize(); void LockAxleDifferential(int axle, bool lock) { m_vehicle->LockAxleDifferential(axle, lock); } void SetAerodynamicDrag(double Cd, double area, double air_density); void SetChassisVisualizationType(VisualizationType vis) { m_vehicle->SetChassisVisualizationType(vis); } void SetSuspensionVisualizationType(VisualizationType vis) { m_vehicle->SetSuspensionVisualizationType(vis); } void SetSteeringVisualizationType(VisualizationType vis) { m_vehicle->SetSteeringVisualizationType(vis); } void SetWheelVisualizationType(VisualizationType vis) { m_vehicle->SetWheelVisualizationType(vis); } void SetTireVisualizationType(VisualizationType vis) { m_vehicle->SetTireVisualizationType(vis); } void Synchronize(double time, const ChDriver::Inputs& driver_inputs, const ChTerrain& terrain); void Advance(double step); void LogHardpointLocations() { m_vehicle->LogHardpointLocations(); } void DebugLog(int what) { m_vehicle->DebugLog(what); } protected: ChContactMethod m_contactMethod; CollisionType m_chassisCollisionType; bool m_fixed; TireModelType m_tireType; BrakeType m_brake_type; PowertrainModelType m_powertrain_type; double m_tire_step_size; ChCoordsys<> m_initPos; double m_initFwdVel; std::vector<double> m_initOmega; bool m_apply_drag; double m_Cd; double m_area; double m_air_density; ChSystem* m_system; FEDA_Vehicle* m_vehicle; double m_tire_mass; unsigned int m_tire_pressure_level; int m_ride_height_config; int m_damper_mode; ChTire::CollisionType m_tire_collision_type; }; /// @} vehicle_models_feda } // namespace feda } // end namespace vehicle } // end namespace chrono #endif
// Cyclone Maya Plugin // #ifndef _CYCLONE_H #define _CYCLONE_H #include <math.h> #include <maya/MPxNode.h> #include <maya/MFnPlugin.h> #include <maya/MTypeId.h> #include <maya/MDataBlock.h> #include <maya/MPlug.h> // -------------------------------------------------------------------------- // Cyclone node class cyclone : public MPxNode { public: enum Distribution {kParameter = 0, kLength = 1}; cyclone(); virtual ~cyclone(); virtual void postConstructor(); virtual MStatus compute( const MPlug& plug, MDataBlock& data ); static void* creator(); static MStatus initialize(); public: static MObject aCurve; static MObject aRandomSeed; static MObject aStart; static MObject aEnd; static MObject aUp; static MObject aDensity; static MObject aDistribution; static MObject aDensityCurve; static MObject aRadius; static MObject aRadiusCurve; static MObject aRedistributeUsingRadius; static MObject aEnableSpin; static MObject aSpin; static MObject aSpinCurve; static MObject aRadialSpinCurve; static MObject aPosition; static MObject aRotation; static MTypeId id; }; #endif
/** \file MemoryChart.h \brief Declares the memory chart class. **/ #pragma once namespace AnimatSim { namespace Charting { /** \brief Saves the data in memory. \details This chart is primarily used by the GUI It keeps the data buffer filled up. If the buffer starts to run over it zeros out the data and starts back at the beginning. This allows the AnimatGUI::Tools::DataChart to poll the MemoryChart on a regular bases so it can suck the data up. When it does this it transfers the stored data from the MemoryChart to the GUI chart and erases it from the MemoryChart and starts collecting all over again. If for some reason the GUI chart does not retrieve the data before the buffer is about to fill up, then we start the collection over so we do not get a buffer overrun, and that data would be lost to the GUI chart. \author dcofer \date 3/18/2011 **/ class ANIMAT_PORT MemoryChart : public DataChart { protected: /// Critical section to lock access to the data buffer for writing. CStdCriticalSection *m_oRowCountLock; public: MemoryChart(); virtual ~MemoryChart(); static MemoryChart *CastToDerived(AnimatBase *lpBase) {return static_cast<MemoryChart*>(lpBase);} virtual std::string Type(); virtual bool Lock(); virtual void Unlock(); virtual void Initialize(); virtual void StepSimulation(); virtual void Load(CStdXml &oXml); }; } //Charting } //AnimatSim
#define _RESEARCH_SOURCE #define _LOCK_EXTENSION #define _QLOCK_EXTENSION #define _BSD_EXTENSION #define _POSIX_EXTENSION #define _POSIX_SOURCE #define _PLAN9_SOURCE #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <fcntl.h> #include <u.h> #include <fmt.h> #include <lock.h> #include <qlock.h> #include <draw.h> /* PROTO */ int getwidth(void) { int linewidth, charwidth, fd, num; char buf[128], *fn; Font *font; if ((fn = getenv("font")) == NULL) return -1; if ((font = openfont(NULL, fn)) == NULL) return -1; if ((fd = open("/dev/window", O_RDONLY)) < 0) { font = NULL; return -1; } num = read(fd, buf, 60); close(fd); if (num < 60) { font = NULL; return -1; } buf[num] = 0; linewidth = atoi(buf + 36) - atoi(buf + 12) - 25; charwidth = stringwidth(font, "0"); return linewidth / charwidth; }
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #import <UIKit/UIKit.h> #import <ABI41_0_0React/ABI41_0_0RCTComponentViewProtocol.h> NS_ASSUME_NONNULL_BEGIN /* * Holds a native view instance and a set of attributes associated with it. * Mounting infrastructure uses these objects to bookkeep views and cache their * attributes for efficient access. */ class ABI41_0_0RCTComponentViewDescriptor final { public: /* * Associated (and owned) native view instance. */ __strong UIView<ABI41_0_0RCTComponentViewProtocol> *view = nil; /* * Indicates a requirement to call on the view methods from * `ABI41_0_0RCTMountingTransactionObserving` protocol. */ bool observesMountingTransactionWillMount{false}; bool observesMountingTransactionDidMount{false}; }; inline bool operator==(ABI41_0_0RCTComponentViewDescriptor const &lhs, ABI41_0_0RCTComponentViewDescriptor const &rhs) { return lhs.view == rhs.view; } inline bool operator!=(ABI41_0_0RCTComponentViewDescriptor const &lhs, ABI41_0_0RCTComponentViewDescriptor const &rhs) { return lhs.view != rhs.view; } template <> struct std::hash<ABI41_0_0RCTComponentViewDescriptor> { size_t operator()(ABI41_0_0RCTComponentViewDescriptor const &componentViewDescriptor) const { return std::hash<void *>()((__bridge void *)componentViewDescriptor.view); } }; NS_ASSUME_NONNULL_END
// Copyright 2015 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 StyleRuleNamespace_h #define StyleRuleNamespace_h #include "core/css/StyleRule.h" namespace blink { // This class is never actually stored anywhere currently, but only used for // the parser to pass to a stylesheet class StyleRuleNamespace final : public StyleRuleBase { WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; public: static PassRefPtrWillBeRawPtr<StyleRuleNamespace> create(AtomicString prefix, AtomicString uri) { return adoptRefWillBeNoop(new StyleRuleNamespace(prefix, uri)); } AtomicString prefix() const { return m_prefix; } AtomicString uri() const { return m_uri; } DEFINE_INLINE_TRACE_AFTER_DISPATCH() { StyleRuleBase::traceAfterDispatch(visitor); } private: StyleRuleNamespace(AtomicString prefix, AtomicString uri) : StyleRuleBase(Namespace) , m_prefix(prefix) , m_uri(uri) { } AtomicString m_prefix; AtomicString m_uri; }; DEFINE_STYLE_RULE_TYPE_CASTS(Namespace); } // namespace blink #endif // StyleRuleNamespace_h
/** Copyright (c) Audi Autonomous Driving Cup. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: “This product includes software developed by the Audi AG and its contributors for Audi Autonomous Driving Cup.” 4. Neither the name of Audi nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY AUDI AG AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUDI AG OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ********************************************************************** * $Author:: spiesra $ $Date:: 2014-09-16 09:23:21#$ $Rev:: 26076 $ **********************************************************************/ #ifndef _ROADSIGN_DETECTION_INTERFACE_H_ #define _ROADSIGN_DETECTION_INTERFACE_H_ #if defined _WIN32 #define LIB_PRE __declspec(dllexport) #elif defined __unix__ #define LIB_PRE __attribute__ ((visibility ("default"))) #else #define LIB_PRE #endif namespace roadsignDetection { //! interface class for the road sign detection lib /*! This is the interface class for the library for the road sign detection lib */ class IRoadsignDetection { public: /*! initializes the library and sets the resolution @param imgWidthIn width of the input images @param imgHeightIn height of the input images @param imgBytesPerLineIn bytes per line of the input images */ virtual tBool init(tInt imgWidthIn, tInt imgHeightIn, tInt imgBytesPerLineIn) = 0; /*! sets the parameter with the given name to the new value @param paramName name of the parameter @param paramValue new value of the parameter */ virtual tVoid setParam(cString paramName, tFloat64 paramValue)=0; /*! sets the width of the input images @param inWidth value width of the images */ virtual tVoid setWidth(tInt inWidth) =0; /*! sets the height of the input images @param inHeight value for height of the images */ virtual tVoid setHeight(tInt inHeight) =0; /*! sets the bytes per line of the input images @param inBytesPerLine value for the bytes per line of the images */ virtual tVoid setBytesPerLine(tInt inBytesPerLine) =0; /*! gives a new image to the libary. The image is processed and the detected sign is given back by the result integer. The image data, of which the pointer is given must be according to the predefined width, height and bytes per line @param imgRawData pointer to the image data. */ virtual tInt update(tUInt8 *imgRawData) = 0; /*! returns a pointer to the processd data. The processed data contains an image with the plotted contours */ virtual tVoid* getProcessedData()=0; /*! returns the bytes per line of the processed image data */ virtual tInt getProcImgBytesPerLine()=0; /*! returns the size of the processed image data */ virtual tInt getProcImgSize() =0; /*! returns the bits per pixel of the processed image data */ virtual tInt getProcImgBitsPerPixel() =0; /*! shuts the library down */ virtual tBool shutdown() = 0; /*! destructor */ virtual ~IRoadsignDetection(){}; }; /*! creates a new class @param srcFolderPath the path where the images of the roadsigns are located */ LIB_PRE IRoadsignDetection* CreateMyClass(cString srcFolderPath); /*! deletes the class @param ptrToClass pointer to the class which has to be deleted */ LIB_PRE tVoid DestroyMyClass(IRoadsignDetection* ptrToClass); } #endif // _ROADSIGN_DETECTION_INTERFACE_H_
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Feb 20 2016 22:04:40). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import <CoreSimulator/NSObject-Protocol.h> @class NSObject, NSString, SimPasteboardItem; @protocol NSSecureCoding; @protocol SimPasteboardItemDataProvider <NSObject> - (NSObject<NSSecureCoding> *)retrieveValueForSimPasteboardItem:(SimPasteboardItem *)arg1 type:(NSString *)arg2; @end
/* * Copyright (c) 2012 Gerard Green * All rights reserved * * Please see the file 'LICENSE' for further information */ #include "_Malloc.h" void *calloc(size_t nelem, size_t elsize) { void *pmem; size_t size; /* TODO: Check for overflow */ size = nelem * elsize; if ((pmem = malloc(size)) == NULL) { /* Must be OOM or perhaps too big */ return NULL; } memset(pmem, 0, size); return pmem; }
/** * The texture manager holds all the textures that the system supports. * Additionally to the textures in the ./textures directory, it also * holds some special textures. Here is a list of textures: * TODO: Shall the texture manager handle the render target stuff or not???? * - 'noise2D': Core 2D noise texture. In the future there might be more * - 'noise3D': Core 3D noise texture. * - 'renderTarget': Core render target at render target resolution * - 'smallTarget': Smaller render target for hypnoglow and the like */ #pragma once #define TM_DIRECTORY "textures/" #define TM_SHADER_WILDCARD "*.tga" #define TM_MAX_NUM_TEXTURES 64 #define TM_MAX_FILENAME_LENGTH 1024 #define TM_OFFSCREEN_NAME "renderTarget" #define TM_HIGHLIGHT_NAME "smallTarget" #define TM_NOISE_NAME "noise2D" #define TM_NOISE3D_NAME "noise3D" // The noise texture dimension #define TM_NOISE_TEXTURE_SIZE 256 #define TM_FILTER_KERNEL_SIZE 32 // Name of the 32x32x32 noise texture #define TM_3DNOISE_TEXTURE_SIZE 16 // try smaller? struct TGAHeader { unsigned char identSize; unsigned char colourmapType; unsigned char imageType; // This is a stupid hack to fool the compiler. // I do not know what happens if I compile it // under release conditions. unsigned char colourmapStart1; unsigned char colourmapStart2; unsigned char colourmapLength1; unsigned char colourmapLength2; unsigned char colourmapBits; short xStart; short yStart; short width; short height; unsigned char bits; unsigned char descriptor; }; class TextureManager { public: TextureManager(void); ~TextureManager(void); public: // functions // Load all textures from the ./textures directory. // Returns 0 if successful, -1 otherwise // The error string must hold space for at least SM_MAX_ERROR_LENGTH // characters. It contains errors from compilation/loading int init(char *errorString); // Get the texture ID from a named texture // That might either be a .tga or any of the special textures int getTextureID(const char *name, GLuint *id, char *errorString); private: // functions void releaseAll(void); int createRenderTargetTexture(char *errorString, int width, int height, const char *name); int loadTGA(const char *filename, char *errorString); float frand(void); void normalizeKernel(float *kernel, int kernelLength); void normalizeTexture(float *texture, int textureSize); void makeIntTexture(void); void generateNoiseTexture(void); int createNoiseTexture(char *errorString, const char *name); int createNoiseTexture3D(char *errorString, const char *name); private: // data int numTextures; char textureName[TM_MAX_NUM_TEXTURES][TM_MAX_FILENAME_LENGTH+1]; GLuint textureID[TM_MAX_NUM_TEXTURES]; int textureWidth[TM_MAX_NUM_TEXTURES]; int textureHeight[TM_MAX_NUM_TEXTURES]; };
// Copyright (c) 2003-2019 Xsens Technologies B.V. or subsidiaries worldwide. // All rights reserved. // // Redistribution and use in source and binary forms, with or without modification, // are permitted provided that the following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, // this list of conditions, and the following disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, // this list of conditions, and the following disclaimer in the documentation // and/or other materials provided with the distribution. // // 3. Neither the names of the copyright holders nor the names of their contributors // may be used to endorse or promote products derived from this software without // specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES. // #include "xsportinfoarray.h" /*! \struct XsPortInfoArray \brief A list of XsPortInfo values \sa XsArray */ void copyPortInfo(XsPortInfo* dest, XsPortInfo const* src) { memcpy(dest, src, sizeof(XsPortInfo)); } int comparePortInfo(XsPortInfo const* a, XsPortInfo const* b) { return memcmp(a, b, sizeof(XsPortInfo)); } //! \brief Descriptor for XsPortInfoArray XsArrayDescriptor const g_xsPortInfoArrayDescriptor = { sizeof(XsPortInfo), XSEXPCASTITEMSWAP XsPortInfo_swap, // swap XSEXPCASTITEMMAKE XsPortInfo_clear, // construct XSEXPCASTITEMCOPY copyPortInfo, // copy construct 0, // destruct XSEXPCASTITEMCOPY copyPortInfo, // copy XSEXPCASTITEMCOMP comparePortInfo, // compare XSEXPCASTRAWCOPY XsArray_rawCopy // raw copy }; /*! \copydoc XsArray_constructDerived \note Specialization for XsPortInfoArray */ void XsPortInfoArray_construct(XsPortInfoArray* thisPtr, XsSize count, XsPortInfo const* src) { XsArray_construct(thisPtr, &g_xsPortInfoArrayDescriptor, count, src); }
/** @file @brief Implementation of a very simple single linked list. Part of Georgios Portokalidis' Aho Corasick algorithm. ---- Fairly Fast Packet Filter http://ffpf.sourceforge.net/ Copyright (c), 2003 - 2004 Georgios Portokalidis, Herbert Bos & Willem de Bruijn contact info : wdebruij_AT_users.sourceforge.net ---- This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "xalloc.h" #ifdef __KERNEL__ #include <linux/string.h> #else #include <string.h> #endif #include "slist.h" /** \brief Append data to list \param list a pointer to a list \param data the data to place in the list \return 0 on success, or -1 on failure */ int slist_append(slist_t *list,void *data) { slist_node_t *node; if ( (node = (slist_node_t*)xalloc(sizeof(slist_node_t))) == NULL ) return -1; node->data = data; node->next = NULL; if ( slist_head(list) == NULL ) slist_head(list) = node; else slist_next(slist_tail(list)) = node; slist_tail(list) = node; ++slist_size(list); return 0; } /** \brief Prepend data to list \param list a pointer to list \param data the data to place in the list \return 0 on success, or -1 on failure */ int slist_prepend(slist_t *list,void *data) { slist_node_t *node; if ( (node = (slist_node_t*)xalloc(sizeof(slist_node_t))) == NULL ) return -1; slist_data(node) = data; slist_next(node) = slist_head(list); slist_head(list) = node; if ( slist_tail(list) == NULL ) slist_tail(list) = node; ++slist_size(list); return 0; } /** \brief Pop the first element in the list \param list a pointer to a list \return a pointer to the element, or NULL if the list is empty */ void * slist_pop_first(slist_t *list) { void *d; slist_node_t *node; if ( slist_head(list) == NULL ) return NULL; d = slist_data((node = slist_head(list))); slist_head(list) = slist_next(node); xfree(node); if ( --slist_size(list) == 0 ) slist_tail(list) = NULL; return d; } /** \ brief Initialize a single linked list \param list the list to initialize */ void slist_init(slist_t *list) { slist_head(list) = slist_tail(list) = NULL; slist_size(list) = 0; } /** \brief Destroy and de-allocate the memory hold by a list \param list a pointer to an existing list \param dealloc flag that indicates whether stored data should also be de-allocated */ void slist_destroy(slist_t *list,slist_destroy_t dealloc) { slist_node_t *node; while( ((node = slist_head(list)) != NULL) ) { slist_head(list) = slist_next(node); if ( dealloc == SLIST_FREE_DATA ) xfree(slist_data(node)); xfree(node); } slist_tail(list) = NULL; slist_size(list) = 0; }
#import "HYDBase.h" #import "HYDMapper.h" #import "HYDConstants.h" /*! Returns a mapper that converts numbers to NSDates. * The number should be seconds relative to 1970. */ HYD_EXTERN_OVERLOADED id<HYDMapper> HYDMapNumberToDateSince1970(void); /*! Returns a mapper that converts numbers to NSDates. * The number should be a value relative to 1970. * * @param unit The time unit the source number is in. */ HYD_EXTERN_OVERLOADED id<HYDMapper> HYDMapNumberToDateSince1970(HYDDateTimeUnit unit); /*! Returns a mapper that converts numbers to NSDates. * The number should be seconds relative to a given date. * * @param sinceDate The date the numeric value is relative to. */ HYD_EXTERN_OVERLOADED id<HYDMapper> HYDMapNumberToDateSince(NSDate *sinceDate) HYD_REQUIRE_NON_NIL(1); /*! Returns a mapper that converts numbers to NSDates. * The number should be a value relative to a given date. * * @param unit The time unit the source number is in. * @param sinceDate The date the numeric value is relative to. */ HYD_EXTERN_OVERLOADED id<HYDMapper> HYDMapNumberToDateSince(HYDDateTimeUnit unit, NSDate *sinceDate) HYD_REQUIRE_NON_NIL(2); /*! Returns a mapper that converts numbers to NSDates. * The number should be seconds relative to 1970. * * @param innerMapper The mapper that processes the source value before this mapper. */ HYD_EXTERN_OVERLOADED id<HYDMapper> HYDMapNumberToDateSince1970(id<HYDMapper> innerMapper) HYD_REQUIRE_NON_NIL(1); /*! Returns a mapper that converts numbers to NSDates. * The number should be a value relative to 1970. * * @param innerMapper The mapper that processes the source value before this mapper. * @param unit The time unit the source number is in. */ HYD_EXTERN_OVERLOADED id<HYDMapper> HYDMapNumberToDateSince1970(id<HYDMapper> innerMapper, HYDDateTimeUnit unit) HYD_REQUIRE_NON_NIL(1); /*! Returns a mapper that converts numbers to NSDates. * The number should be seconds relative to a given date. * * @param innerMapper The mapper that processes the source value before this mapper. * @param sinceDate The date the numeric value is relative to. */ HYD_EXTERN_OVERLOADED id<HYDMapper> HYDMapNumberToDateSince(id<HYDMapper> innerMapper, NSDate *sinceDate) HYD_REQUIRE_NON_NIL(1,2); /*! Returns a mapper that converts numbers to NSDates. * The number should be a value relative to a given date. * * @param innerMapper The mapper that processes the source value before this mapper. * @param unit The time unit the source number is in. * @param sinceDate The date the numeric value is relative to. */ HYD_EXTERN_OVERLOADED id<HYDMapper> HYDMapNumberToDateSince(id<HYDMapper> innerMapper, HYDDateTimeUnit unit, NSDate *sinceDate) HYD_REQUIRE_NON_NIL(1,3);
#define OINK_VERSION "22 Nov 2013"
// // PROJECT CHRONO - http://projectchrono.org // // Copyright (c) 2010-2012 Alessandro Tasora // All rights reserved. // // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file at the top level of the distribution // and at http://projectchrono.org/license-chrono.txt. // #ifndef CHMATERIALCOUPLE_H #define CHMATERIALCOUPLE_H /////////////////////////////////////////////////// // // ChMaterialCouple.h // // HEADER file for CHRONO, // Multibody dynamics engine // // ------------------------------------------------ // www.deltaknowledge.com // ------------------------------------------------ /////////////////////////////////////////////////// namespace chrono { /// Class to pass data about material properties of a contact pair. /// Used by ChAddContactCallback for generating cutom combinations /// of material properties (by default, friction & c. are average /// of values of the two parts in contact) class ChApi ChMaterialCouple { public: float static_friction; float sliding_friction; float rolling_friction; float spinning_friction; float restitution; float cohesion; float dampingf; float compliance; float complianceT; float complianceRoll; float complianceSpin; ChMaterialCouple() :static_friction(0), sliding_friction(0), rolling_friction(0), spinning_friction(0), restitution(0), cohesion(0), dampingf(0), compliance(0), complianceT(0), complianceRoll(0), complianceSpin(0) {}; }; } // END_OF_NAMESPACE____ #endif
/********************************************************************** * Copyright (c) 2014 BFFT Gesellschaft fuer Fahrzeugtechnik mbH. * All rights reserved. ********************************************************************** * $Author:: exthanl#$ $Date:: 2014-09-04 11:39:27#$ $Rev:: 25772 $ **********************************************************************/ #ifndef __STD_INCLUDES_HEADER #define __STD_INCLUDES_HEADER // ADTF headers #include <adtf_platform_inc.h> #include <adtf_plugin_sdk.h> using namespace adtf; // zbar headers #include <zbar.h> using namespace zbar; #endif // __STD_INCLUDES_HEADER
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22a.c Label Definition File: CWE401_Memory_Leak.c.label.xml Template File: sources-sinks-22a.tmpl.c */ /* * @description * CWE: 401 Memory Leak * BadSource: realloc Allocate data using realloc() * GoodSource: Allocate data on the stack * Sinks: * GoodSink: call free() on data * BadSink : no deallocation of data * Flow Variant: 22 Control flow: Flow controlled by value of a global variable. Sink functions are in a separate file from sources. * * */ #include "std_testcase.h" #include <wchar.h> #ifndef OMITBAD /* The global variable below is used to drive control flow in the sink function */ int CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_badGlobal = 0; void CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_badSink(struct _twoIntsStruct * data); void CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_bad() { struct _twoIntsStruct * data; data = NULL; /* POTENTIAL FLAW: Allocate memory on the heap */ data = (struct _twoIntsStruct *)realloc(data, 100*sizeof(struct _twoIntsStruct)); if (data == NULL) {exit(-1);} /* Initialize and make use of data */ data[0].intOne = 0; data[0].intTwo = 0; printStructLine((twoIntsStruct *)&data[0]); CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_badGlobal = 1; /* true */ CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_badSink(data); } #endif /* OMITBAD */ #ifndef OMITGOOD /* The global variables below are used to drive control flow in the sink functions. */ int CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_goodB2G1Global = 0; int CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_goodB2G2Global = 0; int CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_goodG2BGlobal = 0; /* goodB2G1() - use badsource and goodsink by setting the static variable to false instead of true */ void CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_goodB2G1Sink(struct _twoIntsStruct * data); static void goodB2G1() { struct _twoIntsStruct * data; data = NULL; /* POTENTIAL FLAW: Allocate memory on the heap */ data = (struct _twoIntsStruct *)realloc(data, 100*sizeof(struct _twoIntsStruct)); if (data == NULL) {exit(-1);} /* Initialize and make use of data */ data[0].intOne = 0; data[0].intTwo = 0; printStructLine((twoIntsStruct *)&data[0]); CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_goodB2G1Global = 0; /* false */ CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_goodB2G1Sink(data); } /* goodB2G2() - use badsource and goodsink by reversing the blocks in the if in the sink function */ void CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_goodB2G2Sink(struct _twoIntsStruct * data); static void goodB2G2() { struct _twoIntsStruct * data; data = NULL; /* POTENTIAL FLAW: Allocate memory on the heap */ data = (struct _twoIntsStruct *)realloc(data, 100*sizeof(struct _twoIntsStruct)); if (data == NULL) {exit(-1);} /* Initialize and make use of data */ data[0].intOne = 0; data[0].intTwo = 0; printStructLine((twoIntsStruct *)&data[0]); CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_goodB2G2Global = 1; /* true */ CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_goodB2G2Sink(data); } /* goodG2B() - use goodsource and badsink */ void CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_goodG2BSink(struct _twoIntsStruct * data); static void goodG2B() { struct _twoIntsStruct * data; data = NULL; /* FIX: Use memory allocated on the stack with ALLOCA */ data = (struct _twoIntsStruct *)ALLOCA(100*sizeof(struct _twoIntsStruct)); /* Initialize and make use of data */ data[0].intOne = 0; data[0].intTwo = 0; printStructLine((twoIntsStruct *)&data[0]); CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_goodG2BGlobal = 1; /* true */ CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_goodG2BSink(data); } void CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_good() { goodB2G1(); goodB2G2(); goodG2B(); } #endif /* OMITGOOD */ /* Below is the main(). It is only used when building this testcase on its own for testing or for building a binary to use in testing binary analysis tools. It is not used when compiling all the testcases as one application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE401_Memory_Leak__struct_twoIntsStruct_realloc_22_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
#pragma once #include <Reflection/Reflection.h> namespace DAVA { class StructureWrapperClass; class ComponentStructureWrapper : public StructureWrapper { public: ComponentStructureWrapper(const Type* type); ~ComponentStructureWrapper(); bool HasFields(const ReflectedObject& object, const ValueWrapper* vw) const override; Reflection GetField(const ReflectedObject& obj, const ValueWrapper* vw, const Any& key) const override; size_t GetFieldsCount(const ReflectedObject& object, const ValueWrapper* vw) const override; Vector<Reflection::Field> GetFields(const ReflectedObject& obj, const ValueWrapper* vw) const override; Vector<Reflection::Field> GetFields(const ReflectedObject& obj, const ValueWrapper* vw, size_t, size_t) const override; bool HasMethods(const ReflectedObject& object, const ValueWrapper* vw) const override; AnyFn GetMethod(const ReflectedObject& object, const ValueWrapper* vw, const Any& key) const override; Vector<Reflection::Method> GetMethods(const ReflectedObject& object, const ValueWrapper* vw) const override; const Reflection::FieldCaps& GetFieldsCaps(const ReflectedObject& object, const ValueWrapper* vw) const override; AnyFn GetFieldCreator(const ReflectedObject& object, const ValueWrapper* vw) const override; bool AddField(const ReflectedObject& object, const ValueWrapper* vw, const Any& key, const Any& value) const override; bool InsertField(const ReflectedObject& object, const ValueWrapper* vw, const Any& beforeKey, const Any& key, const Any& value) const override; bool RemoveField(const ReflectedObject& object, const ValueWrapper* vw, const Any& key) const override; void Update() override; private: std::unique_ptr<StructureWrapperClass> classWrapper; }; template <typename T> std::unique_ptr<StructureWrapper> CreateComponentStructureWrapper() { return std::make_unique<ComponentStructureWrapper>(Type::Instance<T>()); } } // namespace DAVA
/*------------------------------------------------------------------------- Copyright (C) 2008, Charles Wang Author: Charles Wang <charlesw123456@gmail.com> License: LGPLv2 (see LICENSE-LGPL) -------------------------------------------------------------------------*/ #ifndef COCO_BUFFER_H #define COCO_BUFFER_H #ifndef COCO_CDEFS_H #include "CDefs.h" #endif EXTC_BEGIN typedef struct CcsBuffer_s CcsBuffer_t; struct CcsBuffer_s { FILE * fp; long start; char * buf; char * busyFirst; /* The first char used by Token_t. */ char * lockCur; /* The value of of cur when locked. */ char * lockNext; /* The value of next when locked. */ char * cur; /* The first char of the current char in ScanInput_t. */ char * next; /* The first char of the next char in ScanInput_t. */ char * loaded; char * last; }; /* CcsBuffer_t members for Scanner_t. */ /* fp should be opened with 'r' mode to deal with CR/LF. */ CcsBuffer_t * CcsBuffer(CcsBuffer_t * self, FILE * fp); void CcsBuffer_Destruct(CcsBuffer_t * self); long CcsBuffer_GetPos(CcsBuffer_t * self); int CcsBuffer_Read(CcsBuffer_t * self, int * retBytes); long CcsBuffer_StringTo(CcsBuffer_t * self, size_t * len, const char * needle); const char * CcsBuffer_GetString(CcsBuffer_t * self, long start, size_t size); void CcsBuffer_Consume(CcsBuffer_t * self, long start, size_t size); void CcsBuffer_SetBusy(CcsBuffer_t * self, long startBusy); void CcsBuffer_ClearBusy(CcsBuffer_t * self); void CcsBuffer_Lock(CcsBuffer_t * self); void CcsBuffer_LockReset(CcsBuffer_t * self); void CcsBuffer_Unlock(CcsBuffer_t * self); EXTC_END #endif /* COCO_BUFFER_H */
/* $NetBSD: latchvar.h,v 1.1 2002/03/24 15:47:21 bjh21 Exp $ */ /*- * Copyright (c) 2001 Ben Harris * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _LATCHVAR_H_ #define _LATCHVAR_H_ extern struct device *the_latches; extern void latcha_update(u_int8_t mask, u_int8_t value); extern void latchb_update(u_int8_t mask, u_int8_t value); #endif
/**ARGS: symbols --active */ /**SYSCODE: = 0 */ #ifdef UNDEF1 #define FOO #endif #ifndef UNDEF2 #define BAR #endif
/* * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* M I S C E L L A N E O U S U T I L I T I E S */ /* $Id$ */ /* Code for the allocation and de-allocation of temporary variables, allowing re-use. */ #include "lint.h" #ifndef LINT #include <em.h> #else #include "l_em.h" #endif /* LINT */ #include <em_arith.h> #include <em_reg.h> #include <alloc.h> #include <em_mes.h> #include "debug.h" #include "util.h" #include "util_loc.h" #include "use_tmp.h" #include "regcount.h" #include "sizes.h" #include "align.h" #include "stack.h" #include "Lpars.h" #include "def.h" static struct localvar *FreeTmps; #ifdef USE_TMP static int loc_id; #endif /* USE_TMP */ #ifdef PEEPHOLE #undef REGCOUNT #define REGCOUNT 1 #endif extern char options[]; void LocalInit() { #ifdef USE_TMP C_insertpart(loc_id = C_getid()); #endif /* USE_TMP */ } arith LocalSpace(arith sz, int al) { struct stack_level *stl = local_level; stl->sl_max_block = - align(sz - stl->sl_max_block, al); return stl->sl_max_block; } #define TABSIZ 32 static struct localvar *regs[TABSIZ]; arith NewLocal(arith sz, int al, int regtype, int sc) { struct localvar *tmp = FreeTmps; struct localvar *prev = 0; int index; while (tmp) { if (tmp->t_align >= al && tmp->t_size >= sz && tmp->t_sc == sc && tmp->t_regtype == regtype) { if (prev) { prev->next = tmp->next; } else FreeTmps = tmp->next; break; } prev = tmp; tmp = tmp->next; } if (! tmp) { tmp = new_localvar(); tmp->t_offset = LocalSpace(sz, al); tmp->t_align = al; tmp->t_size = sz; tmp->t_sc = sc; tmp->t_regtype = regtype; tmp->t_count = REG_DEFAULT; } index = (int) (tmp->t_offset >> 2) & (TABSIZ - 1); tmp->next = regs[index]; regs[index] = tmp; return tmp->t_offset; } void FreeLocal(arith off) { int index = (int) (off >> 2) & (TABSIZ - 1); struct localvar *tmp = regs[index]; struct localvar *prev = 0; while (tmp && tmp->t_offset != off) { prev = tmp; tmp = tmp->next; } if (tmp) { if (prev) prev->next = tmp->next; else regs[index] = tmp->next; tmp->next = FreeTmps; FreeTmps = tmp; } } void LocalFinish() { struct localvar *tmp, *tmp1; int i; #ifdef USE_TMP C_beginpart(loc_id); #endif tmp = FreeTmps; while (tmp) { tmp1 = tmp; if (tmp->t_sc == REGISTER) tmp->t_count += REG_BONUS; if (! options['n'] && tmp->t_regtype >= 0) { C_ms_reg(tmp->t_offset, tmp->t_size, tmp->t_regtype, tmp->t_count); } tmp = tmp->next; free_localvar(tmp1); } FreeTmps = 0; for (i = 0; i < TABSIZ; i++) { tmp = regs[i]; while (tmp) { if (tmp->t_sc == REGISTER) tmp->t_count += REG_BONUS; tmp1 = tmp; if (! options['n'] && tmp->t_regtype >= 0) { C_ms_reg(tmp->t_offset, tmp->t_size, tmp->t_regtype, tmp->t_count); } tmp = tmp->next; free_localvar(tmp1); } regs[i] = 0; } #ifdef PEEPHOLE if (! options['n']) { C_mes_begin(ms_reg); C_mes_end(); } #endif #ifdef USE_TMP C_endpart(loc_id); #endif } void RegisterAccount(arith offset, arith size, int regtype, int sc) { struct localvar *p; int index; if (regtype < 0) return; p = new_localvar(); index = (int) (offset >> 2) & (TABSIZ - 1); p->t_offset = offset; p->t_regtype = regtype; p->t_count = REG_DEFAULT; p->t_sc = sc; p->t_size = size; p->next = regs[index]; regs[index] = p; } static struct localvar *find_reg(arith off) { struct localvar *p = regs[(int)(off >> 2) & (TABSIZ - 1)]; while (p && p->t_offset != off) p = p->next; return p; } void LoadLocal(arith off, arith sz) { struct localvar *p = find_reg(off); #ifdef USE_TMP #ifdef REGCOUNT if (p) p->t_count++; #endif #endif if (p && p->t_size != sz) p->t_regtype = -1; if (sz == word_size) C_lol(off); else if (sz == dword_size) C_ldl(off); else { if (p) p->t_regtype = -1; C_lal(off); C_loi(sz); } } void StoreLocal(arith off, arith sz) { struct localvar *p = find_reg(off); #ifdef USE_TMP #ifdef REGCOUNT if (p) p->t_count++; #endif #endif if (p && p->t_size != sz) p->t_regtype = -1; if (sz == word_size) C_stl(off); else if (sz == dword_size) C_sdl(off); else { if (p) p->t_regtype = -1; C_lal(off); C_sti(sz); } } #ifndef LINT void AddrLocal(arith off) { struct localvar *p = find_reg(off); if (p) p->t_regtype = -1; C_lal(off); } #endif /* LINT */
/* Copyright (c) 2018, Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the Ford Motor Company nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_BUTTON_RESPONSE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_BUTTON_RESPONSE_H_ #include "application_manager/commands/command_response_impl.h" #include "utils/macro.h" namespace sdl_rpc_plugin { namespace app_mngr = application_manager; namespace commands { /** * @brief UnsubscribeButtonResponse command class **/ class UnsubscribeButtonResponse : public app_mngr::commands::CommandResponseImpl { public: /** * @brief UnsubscribeButtonResponse class constructor * * @param message Incoming SmartObject message **/ UnsubscribeButtonResponse(const app_mngr::commands::MessageSharedPtr& message, app_mngr::ApplicationManager& application_manager, app_mngr::rpc_service::RPCService& rpc_service, app_mngr::HMICapabilities& hmi_capabilities, policy::PolicyHandlerInterface& policy_handler); /** * @brief UnsubscribeButtonResponse class destructor **/ virtual ~UnsubscribeButtonResponse(); /** * @brief Execute command **/ virtual void Run(); private: DISALLOW_COPY_AND_ASSIGN(UnsubscribeButtonResponse); }; } // namespace commands } // namespace sdl_rpc_plugin #endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_UNSUBSCRIBE_BUTTON_RESPONSE_H_
enum { AM_CC1000INTERFACEDRIPMSG = 8, }; typedef struct CC1000InterfaceDripMsg { uint8_t rfPowerChanged:1; uint8_t lplPowerChanged:1; uint8_t pad:6; // Valid values: 1-15. uint8_t rfPower; // Valid values: 0(full duty cycle) to 3(lowest duty cycle). uint8_t lplPower; } CC1000InterfaceDripMsg;
#import <Foundation/Foundation.h> #import "iOmniataAPI.h" @interface Logger : NSObject +(void)log:(SMT_LOG)log_Type :(NSString *) str :(NSString *)format, ...; @end #define LOG(log_type, format, ...) \ [Logger log: log_type: [NSString stringWithFormat:@"%s:%d",__PRETTY_FUNCTION__,__LINE__ ]: format, ## __VA_ARGS__ ];
// Copyright 2015 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. // IPC messages for extensions GuestViews. #ifndef EXTENSIONS_COMMON_GUEST_VIEW_EXTENSIONS_GUEST_VIEW_MESSAGES_H_ #define EXTENSIONS_COMMON_GUEST_VIEW_EXTENSIONS_GUEST_VIEW_MESSAGES_H_ #include <string> #include "ipc/ipc_message_macros.h" #include "ui/gfx/geometry/size.h" #include "ui/gfx/ipc/gfx_param_traits.h" #define IPC_MESSAGE_START ExtensionsGuestViewMsgStart // Messages sent from the renderer to the browser. // Queries whether the RenderView of the provided |routing_id| is allowed to // inject the script with the provided |script_id|. IPC_SYNC_MESSAGE_CONTROL2_1( ExtensionsGuestViewHostMsg_CanExecuteContentScriptSync, int /* routing_id */, int /* script_id */, bool /* allowed */) // A renderer sends this message when it wants to resize a guest. IPC_MESSAGE_CONTROL3(ExtensionsGuestViewHostMsg_ResizeGuest, int /* routing_id */, int /* element_instance_id*/, gfx::Size /* new_size */) #endif // EXTENSIONS_COMMON_GUEST_VIEW_EXTENSIONS_GUEST_VIEW_MESSAGES_H_
#ifndef __NESIS_EVENT_FILTER_H #define __NESIS_EVENT_FILTER_H /*************************************************************************** * * * Copyright (C) 2007 by Kanardia d.o.o. [see www.kanardia.eu] * * Writen by: * * Ales Krajnc [ales.krajnc@kanardia.eu] * * * * Status: Open Source * * * * License: GPL - GNU General Public License * * See 'COPYING.html' for more details about the license. * * * ***************************************************************************/ #include <QObject> #include <QEvent> #include "AbstractNesisInput.h" // ------------------------------------------------------------------------- #define KEYCODE_BTN_1 Qt::Key_F1 #define KEYCODE_BTN_2 Qt::Key_F2 #define KEYCODE_BTN_3 Qt::Key_F3 #define KEYCODE_BTN_4 Qt::Key_F4 #define KEYCODE_BTN_5 Qt::Key_F5 #define KEYCODE_BTN_OK Qt::Key_F6 #define KEYCODE_BTN_CANCEL Qt::Key_F7 #define KEYCODE_BTN_POWER Qt::Key_F12 #define KEYCODE_KNOB_CW Qt::Key_F9 #define KEYCODE_KNOB_CCW Qt::Key_F10 // ------------------------------------------------------------------------- /** \brief Nesis event filter inserted into QApplication. This class catches events as soon as possible (in QApplication's event loop) and detects Qt events that are used to control the Nesis. These events are translated into more specific form and and transmited to the active control using virtual functions. The controls must be derived from the \a AbstractNesisInput class. */ class NesisEventFilter : public QObject { Q_OBJECT public: //! Constructor NesisEventFilter(QObject *pParent=0); //! Destructor virtual ~NesisEventFilter(); //! The event filter function. We need to catch panel actions here. virtual bool eventFilter(QObject *pObj, QEvent *pEvent); signals: //! Shutdown signal. void Shutdown(); }; // ------------------------------------------------------------------------- #endif
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE127_Buffer_Underread__malloc_char_memmove_45.c Label Definition File: CWE127_Buffer_Underread__malloc.label.xml Template File: sources-sink-45.tmpl.c */ /* * @description * CWE: 127 Buffer Under-read * BadSource: Set data pointer to before the allocated memory buffer * GoodSource: Set data pointer to the allocated memory buffer * Sinks: memmove * BadSink : Copy data to string using memmove * Flow Variant: 45 Data flow: data passed as a static global variable from one function to another in the same source file * * */ #include "std_testcase.h" #include <wchar.h> static char * CWE127_Buffer_Underread__malloc_char_memmove_45_badData; static char * CWE127_Buffer_Underread__malloc_char_memmove_45_goodG2BData; #ifndef OMITBAD static void badSink() { char * data = CWE127_Buffer_Underread__malloc_char_memmove_45_badData; { char dest[100]; memset(dest, 'C', 100-1); /* fill with 'C's */ dest[100-1] = '\0'; /* null terminate */ /* POTENTIAL FLAW: Possibly copy from a memory location located before the source buffer */ memmove(dest, data, 100*sizeof(char)); /* Ensure null termination */ dest[100-1] = '\0'; printLine(dest); /* INCIDENTAL CWE-401: Memory Leak - data may not point to location * returned by malloc() so can't safely call free() on it */ } } void CWE127_Buffer_Underread__malloc_char_memmove_45_bad() { char * data; data = NULL; { char * dataBuffer = (char *)malloc(100*sizeof(char)); if (dataBuffer == NULL) {exit(-1);} memset(dataBuffer, 'A', 100-1); dataBuffer[100-1] = '\0'; /* FLAW: Set data pointer to before the allocated memory buffer */ data = dataBuffer - 8; } CWE127_Buffer_Underread__malloc_char_memmove_45_badData = data; badSink(); } #endif /* OMITBAD */ #ifndef OMITGOOD /* goodG2B() uses the GoodSource with the BadSink */ static void goodG2BSink() { char * data = CWE127_Buffer_Underread__malloc_char_memmove_45_goodG2BData; { char dest[100]; memset(dest, 'C', 100-1); /* fill with 'C's */ dest[100-1] = '\0'; /* null terminate */ /* POTENTIAL FLAW: Possibly copy from a memory location located before the source buffer */ memmove(dest, data, 100*sizeof(char)); /* Ensure null termination */ dest[100-1] = '\0'; printLine(dest); /* INCIDENTAL CWE-401: Memory Leak - data may not point to location * returned by malloc() so can't safely call free() on it */ } } static void goodG2B() { char * data; data = NULL; { char * dataBuffer = (char *)malloc(100*sizeof(char)); if (dataBuffer == NULL) {exit(-1);} memset(dataBuffer, 'A', 100-1); dataBuffer[100-1] = '\0'; /* FIX: Set data pointer to the allocated memory buffer */ data = dataBuffer; } CWE127_Buffer_Underread__malloc_char_memmove_45_goodG2BData = data; goodG2BSink(); } void CWE127_Buffer_Underread__malloc_char_memmove_45_good() { goodG2B(); } #endif /* OMITGOOD */ /* Below is the main(). It is only used when building this testcase on * its own for testing or for building a binary to use in testing binary * analysis tools. It is not used when compiling all the testcases as one * application, which is how source code analysis tools are tested. */ #ifdef INCLUDEMAIN int main(int argc, char * argv[]) { /* seed randomness */ srand( (unsigned)time(NULL) ); #ifndef OMITGOOD printLine("Calling good()..."); CWE127_Buffer_Underread__malloc_char_memmove_45_good(); printLine("Finished good()"); #endif /* OMITGOOD */ #ifndef OMITBAD printLine("Calling bad()..."); CWE127_Buffer_Underread__malloc_char_memmove_45_bad(); printLine("Finished bad()"); #endif /* OMITBAD */ return 0; } #endif
/* Copyright (c) 2015, Linaro Limited * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #include "config.h" #include <odp_api.h> #include <odp_packet_io_internal.h> #include <errno.h> #include <string.h> #include <inttypes.h> static int sysfs_get_val(const char *fname, uint64_t *val) { FILE *file; char str[128]; int ret = -1; file = fopen(fname, "rt"); if (file == NULL) { __odp_errno = errno; /* do not print debug err if sysfs is not supported by * kernel driver. */ if (errno != ENOENT) ODP_ERR("fopen %s: %s\n", fname, strerror(errno)); return 0; } if (fgets(str, sizeof(str), file) != NULL) ret = sscanf(str, "%" SCNx64, val); (void)fclose(file); if (ret != 1) { ODP_ERR("read %s\n", fname); return -1; } return 0; } int sysfs_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) { char fname[256]; const char *dev = pktio_entry->s.name; int ret = 0; sprintf(fname, "/sys/class/net/%s/statistics/rx_bytes", dev); ret -= sysfs_get_val(fname, &stats->in_octets); sprintf(fname, "/sys/class/net/%s/statistics/rx_packets", dev); ret -= sysfs_get_val(fname, &stats->in_ucast_pkts); sprintf(fname, "/sys/class/net/%s/statistics/rx_droppped", dev); ret -= sysfs_get_val(fname, &stats->in_discards); sprintf(fname, "/sys/class/net/%s/statistics/rx_errors", dev); ret -= sysfs_get_val(fname, &stats->in_errors); /* stats->in_unknown_protos is not supported in sysfs */ sprintf(fname, "/sys/class/net/%s/statistics/tx_bytes", dev); ret -= sysfs_get_val(fname, &stats->out_octets); sprintf(fname, "/sys/class/net/%s/statistics/tx_packets", dev); ret -= sysfs_get_val(fname, &stats->out_ucast_pkts); sprintf(fname, "/sys/class/net/%s/statistics/tx_dropped", dev); ret -= sysfs_get_val(fname, &stats->out_discards); sprintf(fname, "/sys/class/net/%s/statistics/tx_errors", dev); ret -= sysfs_get_val(fname, &stats->out_errors); return ret; }
/* $FreeBSD: releng/9.3/sys/contrib/ipfilter/netinet/ip_rcmd_pxy.c 170268 2007-06-04 02:54:36Z darrenr $ */ /* * Copyright (C) 1998-2003 by Darren Reed * * See the IPFILTER.LICENCE file for details on licencing. * * $Id: ip_rcmd_pxy.c,v 1.41.2.7 2006/07/14 06:12:18 darrenr Exp $ * * Simple RCMD transparent proxy for in-kernel use. For use with the NAT * code. * $FreeBSD: releng/9.3/sys/contrib/ipfilter/netinet/ip_rcmd_pxy.c 170268 2007-06-04 02:54:36Z darrenr $ */ #define IPF_RCMD_PROXY int ippr_rcmd_init __P((void)); void ippr_rcmd_fini __P((void)); int ippr_rcmd_new __P((fr_info_t *, ap_session_t *, nat_t *)); int ippr_rcmd_out __P((fr_info_t *, ap_session_t *, nat_t *)); int ippr_rcmd_in __P((fr_info_t *, ap_session_t *, nat_t *)); u_short ipf_rcmd_atoi __P((char *)); int ippr_rcmd_portmsg __P((fr_info_t *, ap_session_t *, nat_t *)); static frentry_t rcmdfr; int rcmd_proxy_init = 0; /* * RCMD application proxy initialization. */ int ippr_rcmd_init() { bzero((char *)&rcmdfr, sizeof(rcmdfr)); rcmdfr.fr_ref = 1; rcmdfr.fr_flags = FR_INQUE|FR_PASS|FR_QUICK|FR_KEEPSTATE; MUTEX_INIT(&rcmdfr.fr_lock, "RCMD proxy rule lock"); rcmd_proxy_init = 1; return 0; } void ippr_rcmd_fini() { if (rcmd_proxy_init == 1) { MUTEX_DESTROY(&rcmdfr.fr_lock); rcmd_proxy_init = 0; } } /* * Setup for a new RCMD proxy. */ int ippr_rcmd_new(fin, aps, nat) fr_info_t *fin; ap_session_t *aps; nat_t *nat; { tcphdr_t *tcp = (tcphdr_t *)fin->fin_dp; fin = fin; /* LINT */ nat = nat; /* LINT */ aps->aps_psiz = sizeof(u_32_t); KMALLOCS(aps->aps_data, u_32_t *, sizeof(u_32_t)); if (aps->aps_data == NULL) { #ifdef IP_RCMD_PROXY_DEBUG printf("ippr_rcmd_new:KMALLOCS(%d) failed\n", sizeof(u_32_t)); #endif return -1; } *(u_32_t *)aps->aps_data = 0; aps->aps_sport = tcp->th_sport; aps->aps_dport = tcp->th_dport; return 0; } /* * ipf_rcmd_atoi - implement a simple version of atoi */ u_short ipf_rcmd_atoi(ptr) char *ptr; { register char *s = ptr, c; register u_short i = 0; while (((c = *s++) != '\0') && ISDIGIT(c)) { i *= 10; i += c - '0'; } return i; } int ippr_rcmd_portmsg(fin, aps, nat) fr_info_t *fin; ap_session_t *aps; nat_t *nat; { tcphdr_t *tcp, tcph, *tcp2 = &tcph; struct in_addr swip, swip2; int off, dlen, nflags; char portbuf[8], *s; fr_info_t fi; u_short sp; nat_t *nat2; ip_t *ip; mb_t *m; tcp = (tcphdr_t *)fin->fin_dp; if (tcp->th_flags & TH_SYN) { *(u_32_t *)aps->aps_data = htonl(ntohl(tcp->th_seq) + 1); return 0; } if ((*(u_32_t *)aps->aps_data != 0) && (tcp->th_seq != *(u_32_t *)aps->aps_data)) return 0; m = fin->fin_m; ip = fin->fin_ip; off = (char *)tcp - (char *)ip + (TCP_OFF(tcp) << 2) + fin->fin_ipoff; #ifdef __sgi dlen = fin->fin_plen - off; #else dlen = MSGDSIZE(m) - off; #endif if (dlen <= 0) return 0; bzero(portbuf, sizeof(portbuf)); COPYDATA(m, off, MIN(sizeof(portbuf), dlen), portbuf); portbuf[sizeof(portbuf) - 1] = '\0'; s = portbuf; sp = ipf_rcmd_atoi(s); if (sp == 0) { #ifdef IP_RCMD_PROXY_DEBUG printf("ippr_rcmd_portmsg:sp == 0 dlen %d [%s]\n", dlen, portbuf); #endif return 0; } /* * Add skeleton NAT entry for connection which will come back the * other way. */ bcopy((char *)fin, (char *)&fi, sizeof(fi)); fi.fin_state = NULL; fi.fin_nat = NULL; fi.fin_flx |= FI_IGNORE; fi.fin_data[0] = sp; fi.fin_data[1] = 0; if (nat->nat_dir == NAT_OUTBOUND) nat2 = nat_outlookup(&fi, NAT_SEARCH|IPN_TCP, nat->nat_p, nat->nat_inip, nat->nat_oip); else nat2 = nat_inlookup(&fi, NAT_SEARCH|IPN_TCP, nat->nat_p, nat->nat_inip, nat->nat_oip); if (nat2 == NULL) { int slen; slen = ip->ip_len; ip->ip_len = fin->fin_hlen + sizeof(*tcp); bzero((char *)tcp2, sizeof(*tcp2)); tcp2->th_win = htons(8192); tcp2->th_sport = htons(sp); tcp2->th_dport = 0; /* XXX - don't specify remote port */ TCP_OFF_A(tcp2, 5); tcp2->th_flags = TH_SYN; fi.fin_dp = (char *)tcp2; fi.fin_fr = &rcmdfr; fi.fin_dlen = sizeof(*tcp2); fi.fin_plen = fi.fin_hlen + sizeof(*tcp2); fi.fin_flx &= FI_LOWTTL|FI_FRAG|FI_TCPUDP|FI_OPTIONS|FI_IGNORE; nflags = NAT_SLAVE|IPN_TCP|SI_W_DPORT; swip = ip->ip_src; swip2 = ip->ip_dst; if (nat->nat_dir == NAT_OUTBOUND) { fi.fin_fi.fi_saddr = nat->nat_inip.s_addr; ip->ip_src = nat->nat_inip; } else { fi.fin_fi.fi_saddr = nat->nat_oip.s_addr; ip->ip_src = nat->nat_oip; nflags |= NAT_NOTRULEPORT; } nat2 = nat_new(&fi, nat->nat_ptr, NULL, nflags, nat->nat_dir); if (nat2 != NULL) { (void) nat_proto(&fi, nat2, IPN_TCP); nat_update(&fi, nat2, nat2->nat_ptr); fi.fin_ifp = NULL; if (nat->nat_dir == NAT_INBOUND) { fi.fin_fi.fi_daddr = nat->nat_inip.s_addr; ip->ip_dst = nat->nat_inip; } (void) fr_addstate(&fi, NULL, SI_W_DPORT); if (fi.fin_state != NULL) fr_statederef((ipstate_t **)&fi.fin_state); } ip->ip_len = slen; ip->ip_src = swip; ip->ip_dst = swip2; } return 0; } int ippr_rcmd_out(fin, aps, nat) fr_info_t *fin; ap_session_t *aps; nat_t *nat; { if (nat->nat_dir == NAT_OUTBOUND) return ippr_rcmd_portmsg(fin, aps, nat); return 0; } int ippr_rcmd_in(fin, aps, nat) fr_info_t *fin; ap_session_t *aps; nat_t *nat; { if (nat->nat_dir == NAT_INBOUND) return ippr_rcmd_portmsg(fin, aps, nat); return 0; }
/* * Copyright (C) 2014 Samsung Electronics. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef XMLDocument_h #define XMLDocument_h #include "core/dom/Document.h" #include "wtf/PassRefPtr.h" namespace blink { class XMLDocument final : public Document { DEFINE_WRAPPERTYPEINFO(); public: static RawPtr<XMLDocument> create(const DocumentInit& initializer = DocumentInit()) { return new XMLDocument(initializer, XMLDocumentClass); } static RawPtr<XMLDocument> createXHTML(const DocumentInit& initializer = DocumentInit()) { return new XMLDocument(initializer, XMLDocumentClass | XHTMLDocumentClass); } static RawPtr<XMLDocument> createSVG(const DocumentInit& initializer = DocumentInit()) { return new XMLDocument(initializer, XMLDocumentClass | SVGDocumentClass); } protected: XMLDocument(const DocumentInit&, DocumentClassFlags documentClasses); }; DEFINE_DOCUMENT_TYPE_CASTS(XMLDocument); } // namespace blink #endif // XMLDocument_h
/** Copyright 2009-2017 National Technology and Engineering Solutions of Sandia, LLC (NTESS). Under the terms of Contract DE-NA-0003525, the U.S. Government retains certain rights in this software. Sandia National Laboratories is a multimission laboratory managed and operated by National Technology and Engineering Solutions of Sandia, LLC., a wholly owned subsidiary of Honeywell International, Inc., for the U.S. Department of Energy's National Nuclear Security Administration under contract DE-NA0003525. Copyright (c) 2009-2017, NTESS All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Sandia Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Questions? Contact sst-macro-help@sandia.gov */ #ifndef NETWORK_ID_H #define NETWORK_ID_H #include <sstream> #include <stdint.h> #include <sstmac/hardware/common/unique_id.h> namespace sstmac { namespace hw { typedef unique_event_id network_id; } } #endif // NETWORK_ID_H
// Copyright 2019 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 UI_GL_DC_LAYER_TREE_H_ #define UI_GL_DC_LAYER_TREE_H_ #include <windows.h> #include <d3d11.h> #include <dcomp.h> #include <wrl/client.h> #include <memory> #include "ui/gfx/geometry/size.h" #include "ui/gl/dc_renderer_layer_params.h" namespace gl { class DirectCompositionChildSurfaceWin; class SwapChainPresenter; // DCLayerTree manages a tree of direct composition visuals, and associated // swap chains for given overlay layers. It maintains a list of pending layers // submitted using ScheduleDCLayer() that are presented and committed in // CommitAndClearPendingOverlays(). class DCLayerTree { public: DCLayerTree(bool disable_nv12_dynamic_textures, bool disable_larger_than_screen_overlays, bool disable_vp_scaling); ~DCLayerTree(); // Returns true on success. bool Initialize(HWND window, Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device, Microsoft::WRL::ComPtr<IDCompositionDevice2> dcomp_device); // Present pending overlay layers, and perform a direct composition commit if // necessary. Returns true if presentation and commit succeeded. bool CommitAndClearPendingOverlays( DirectCompositionChildSurfaceWin* root_surface); // Schedule an overlay layer for the next CommitAndClearPendingOverlays call. bool ScheduleDCLayer(const ui::DCRendererLayerParams& params); // Called by SwapChainPresenter to initialize video processor that can handle // at least given input and output size. The video processor is shared across // layers so the same one can be reused if it's large enough. Returns true on // success. bool InitializeVideoProcessor(const gfx::Size& input_size, const gfx::Size& output_size); void SetNeedsRebuildVisualTree() { needs_rebuild_visual_tree_ = true; } bool disable_nv12_dynamic_textures() const { return disable_nv12_dynamic_textures_; } bool disable_larger_than_screen_overlays() const { return disable_larger_than_screen_overlays_; } bool disable_vp_scaling() const { return disable_vp_scaling_; } const Microsoft::WRL::ComPtr<ID3D11VideoDevice>& video_device() const { return video_device_; } const Microsoft::WRL::ComPtr<ID3D11VideoContext>& video_context() const { return video_context_; } const Microsoft::WRL::ComPtr<ID3D11VideoProcessor>& video_processor() const { return video_processor_; } const Microsoft::WRL::ComPtr<ID3D11VideoProcessorEnumerator>& video_processor_enumerator() const { return video_processor_enumerator_; } Microsoft::WRL::ComPtr<IDXGISwapChain1> GetLayerSwapChainForTesting( size_t index) const; private: const bool disable_nv12_dynamic_textures_; const bool disable_larger_than_screen_overlays_; const bool disable_vp_scaling_; Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device_; Microsoft::WRL::ComPtr<IDCompositionDevice2> dcomp_device_; Microsoft::WRL::ComPtr<IDCompositionTarget> dcomp_target_; // The video processor is cached so SwapChains don't have to recreate it // whenever they're created. Microsoft::WRL::ComPtr<ID3D11VideoDevice> video_device_; Microsoft::WRL::ComPtr<ID3D11VideoContext> video_context_; Microsoft::WRL::ComPtr<ID3D11VideoProcessor> video_processor_; Microsoft::WRL::ComPtr<ID3D11VideoProcessorEnumerator> video_processor_enumerator_; // Current video processor input and output size. gfx::Size video_input_size_; gfx::Size video_output_size_; // Set to true if a direct composition visual tree needs rebuild. bool needs_rebuild_visual_tree_ = false; // Set if root surface is using a swap chain currently. Microsoft::WRL::ComPtr<IDXGISwapChain1> root_swap_chain_; // Set if root surface is using a direct composition surface currently. Microsoft::WRL::ComPtr<IDCompositionSurface> root_dcomp_surface_; uint64_t root_dcomp_surface_serial_; // Direct composition visual for root surface. Microsoft::WRL::ComPtr<IDCompositionVisual2> root_surface_visual_; // Root direct composition visual for window dcomp target. Microsoft::WRL::ComPtr<IDCompositionVisual2> dcomp_root_visual_; // List of pending overlay layers from ScheduleDCLayer(). std::vector<std::unique_ptr<ui::DCRendererLayerParams>> pending_overlays_; // List of swap chain presenters for previous frame. std::vector<std::unique_ptr<SwapChainPresenter>> video_swap_chains_; DISALLOW_COPY_AND_ASSIGN(DCLayerTree); }; } // namespace gl #endif // UI_GL_DC_LAYER_TREE_H_
/***************************************************************************** Copyright (c) 2011, Intel Corp. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Intel Corporation nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ***************************************************************************** * Contents: Native high-level C interface to LAPACK function dtpttr * Author: Intel Corporation * Generated November, 2011 *****************************************************************************/ #include "lapacke.h" #include "lapacke_utils.h" lapack_int LAPACKE_dtpttr( int matrix_order, char uplo, lapack_int n, const double* ap, double* a, lapack_int lda ) { if( matrix_order != LAPACK_COL_MAJOR && matrix_order != LAPACK_ROW_MAJOR ) { LAPACKE_xerbla( "LAPACKE_dtpttr", -1 ); return -1; } #ifndef LAPACK_DISABLE_NAN_CHECK /* Optionally check input matrices for NaNs */ if( LAPACKE_dpp_nancheck( n, ap ) ) { return -4; } #endif return LAPACKE_dtpttr_work( matrix_order, uplo, n, ap, a, lda ); }
/* * * Copyright 2015, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following disclaimer * in the documentation and/or other materials provided with the * distribution. * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #include <grpc/support/port_platform.h> #include <src/core/support/time_precise.h> #ifdef GPR_POSIX_TIME #include <stdlib.h> #include <time.h> #include <unistd.h> #include <grpc/support/log.h> #include <grpc/support/time.h> #include "src/core/support/block_annotate.h" static struct timespec timespec_from_gpr(gpr_timespec gts) { struct timespec rv; if (sizeof(time_t) < sizeof(int64_t)) { /* fine to assert, as this is only used in gpr_sleep_until */ GPR_ASSERT(gts.tv_sec <= INT32_MAX && gts.tv_sec >= INT32_MIN); } rv.tv_sec = (time_t)gts.tv_sec; rv.tv_nsec = gts.tv_nsec; return rv; } #if _POSIX_TIMERS > 0 static gpr_timespec gpr_from_timespec(struct timespec ts, gpr_clock_type clock_type) { /* * timespec.tv_sec can have smaller size than gpr_timespec.tv_sec, * but we are only using this function to implement gpr_now * so there's no need to handle "infinity" values. */ gpr_timespec rv; rv.tv_sec = ts.tv_sec; rv.tv_nsec = (int32_t)ts.tv_nsec; rv.clock_type = clock_type; return rv; } /** maps gpr_clock_type --> clockid_t for clock_gettime */ static clockid_t clockid_for_gpr_clock[] = {CLOCK_MONOTONIC, CLOCK_REALTIME}; void gpr_time_init(void) { gpr_precise_clock_init(); } gpr_timespec gpr_now(gpr_clock_type clock_type) { struct timespec now; GPR_ASSERT(clock_type != GPR_TIMESPAN); if (clock_type == GPR_CLOCK_PRECISE) { gpr_timespec ret; gpr_precise_clock_now(&ret); return ret; } else { clock_gettime(clockid_for_gpr_clock[clock_type], &now); return gpr_from_timespec(now, clock_type); } } #else /* For some reason Apple's OSes haven't implemented clock_gettime. */ #include <sys/time.h> #include <mach/mach.h> #include <mach/mach_time.h> static double g_time_scale; static uint64_t g_time_start; void gpr_time_init(void) { mach_timebase_info_data_t tb = {0, 1}; gpr_precise_clock_init(); mach_timebase_info(&tb); g_time_scale = tb.numer; g_time_scale /= tb.denom; g_time_start = mach_absolute_time(); } gpr_timespec gpr_now(gpr_clock_type clock) { gpr_timespec now; struct timeval now_tv; double now_dbl; now.clock_type = clock; switch (clock) { case GPR_CLOCK_REALTIME: gettimeofday(&now_tv, NULL); now.tv_sec = now_tv.tv_sec; now.tv_nsec = now_tv.tv_usec * 1000; break; case GPR_CLOCK_MONOTONIC: now_dbl = (mach_absolute_time() - g_time_start) * g_time_scale; now.tv_sec = (int64_t)(now_dbl * 1e-9); now.tv_nsec = (int32_t)(now_dbl - ((double)now.tv_sec) * 1e9); break; case GPR_CLOCK_PRECISE: gpr_precise_clock_now(&now); break; case GPR_TIMESPAN: abort(); } return now; } #endif void gpr_sleep_until(gpr_timespec until) { gpr_timespec now; gpr_timespec delta; struct timespec delta_ts; int ns_result; for (;;) { /* We could simplify by using clock_nanosleep instead, but it might be * slightly less portable. */ now = gpr_now(until.clock_type); if (gpr_time_cmp(until, now) <= 0) { return; } delta = gpr_time_sub(until, now); delta_ts = timespec_from_gpr(delta); GRPC_SCHEDULING_START_BLOCKING_REGION; ns_result = nanosleep(&delta_ts, NULL); GRPC_SCHEDULING_END_BLOCKING_REGION; if (ns_result == 0) { break; } } } #endif /* GPR_POSIX_TIME */
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_FACTORY_H_ #define CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_FACTORY_H_ #include "base/compiler_specific.h" #include "base/memory/singleton.h" #include "components/keyed_service/content/browser_context_keyed_service_factory.h" class PushMessagingServiceImpl; class PushMessagingServiceFactory : public BrowserContextKeyedServiceFactory { public: static PushMessagingServiceImpl* GetForProfile( content::BrowserContext* profile); static PushMessagingServiceFactory* GetInstance(); PushMessagingServiceFactory(const PushMessagingServiceFactory&) = delete; PushMessagingServiceFactory& operator=(const PushMessagingServiceFactory&) = delete; // Undo a previous call to SetTestingFactory, such that subsequent calls to // GetForProfile get a real push service. void RestoreFactoryForTests(content::BrowserContext* context); private: friend struct base::DefaultSingletonTraits<PushMessagingServiceFactory>; PushMessagingServiceFactory(); ~PushMessagingServiceFactory() override; // BrowserContextKeyedServiceFactory: KeyedService* BuildServiceInstanceFor( content::BrowserContext* profile) const override; content::BrowserContext* GetBrowserContextToUse( content::BrowserContext* context) const override; }; #endif // CHROME_BROWSER_PUSH_MESSAGING_PUSH_MESSAGING_SERVICE_FACTORY_H_
// // Latin1Encoding.h // // $Id$ // // Library: Foundation // Package: Text // Module: Latin1Encoding // // Definition of the Latin1Encoding class. // // Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH. // and Contributors. // // Permission is hereby granted, free of charge, to any person or organization // obtaining a copy of the software and accompanying documentation covered by // this license (the "Software") to use, reproduce, display, distribute, // execute, and transmit the Software, and to prepare derivative works of the // Software, and to permit third-parties to whom the Software is furnished to // do so, all subject to the following: // // The copyright notices in the Software and this entire statement, including // the above license grant, this restriction and the following disclaimer, // must be included in all copies of the Software, in whole or in part, and // all derivative works of the Software, unless such copies or derivative // works are solely in the form of machine-executable object code generated by // a source language processor. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // #ifndef Foundation_Latin1Encoding_INCLUDED #define Foundation_Latin1Encoding_INCLUDED #include "Poco/Foundation.h" #include "Poco/TextEncoding.h" namespace Poco { class Foundation_API Latin1Encoding: public TextEncoding /// ISO Latin-1 (8859-1) text encoding. { public: Latin1Encoding(); ~Latin1Encoding(); const char* canonicalName() const; bool isA(const std::string& encodingName) const; const CharacterMap& characterMap() const; int convert(const unsigned char* bytes) const; int convert(int ch, unsigned char* bytes, int length) const; private: static const char* _names[]; static const CharacterMap _charMap; }; } // namespace Poco #endif // Foundation_Latin1Encoding_INCLUDED
// // Generated by class-dump 3.5 (64 bit) (Debug version compiled Feb 20 2016 22:04:40). // // class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2015 by Steve Nygard. // #import <objc/NSObject.h> @interface __SimKitPlaceholderClass : NSObject { } @end
// Copyright (c) 2014 Intel Corporation. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef XWALK_APPLICATION_COMMON_MANIFEST_HANDLERS_WIDGET_HANDLER_H_ #define XWALK_APPLICATION_COMMON_MANIFEST_HANDLERS_WIDGET_HANDLER_H_ #include <map> #include <string> #include <vector> #include "base/values.h" #include "xwalk/application/common/application_data.h" #include "xwalk/application/common/manifest_handler.h" namespace xwalk { namespace application { class WidgetInfo : public ApplicationData::ManifestData { public: WidgetInfo(); virtual ~WidgetInfo(); void SetString(const std::string& key, const std::string& value); void Set(const std::string& key, base::Value* value); // Name, shrot name and description are i18n items, they will be set // if their value were changed after loacle was changed. void SetName(const std::string& name); void SetShortName(const std::string& short_name); void SetDescription(const std::string& description); base::DictionaryValue* GetWidgetInfo() { return value_.get(); } private: scoped_ptr<base::DictionaryValue> value_; }; class WidgetHandler : public ManifestHandler { public: WidgetHandler(); virtual ~WidgetHandler(); virtual bool Parse(scoped_refptr<ApplicationData> application, base::string16* error) OVERRIDE; virtual bool AlwaysParseForType(Manifest::Type type) const OVERRIDE; virtual std::vector<std::string> Keys() const OVERRIDE; virtual bool Validate(scoped_refptr<const ApplicationData> application, std::string* error) const OVERRIDE; private: DISALLOW_COPY_AND_ASSIGN(WidgetHandler); }; } // namespace application } // namespace xwalk #endif // XWALK_APPLICATION_COMMON_MANIFEST_HANDLERS_WIDGET_HANDLER_H_
/* * Copyright 2008, The Android Open Source Project * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef TouchList_h #define TouchList_h #include "bindings/core/v8/ScriptWrappable.h" #include "core/CoreExport.h" #include "core/dom/Touch.h" #include "platform/heap/Handle.h" #include "wtf/Vector.h" namespace blink { class CORE_EXPORT TouchList final : public GarbageCollected<TouchList>, public ScriptWrappable { DEFINE_WRAPPERTYPEINFO(); public: static RawPtr<TouchList> create() { return new TouchList; } static RawPtr<TouchList> create(const HeapVector<Member<Touch>>& touches) { RawPtr<TouchList> list = new TouchList; list->m_values.appendVector(touches); return list.release(); } static RawPtr<TouchList> adopt(HeapVector<Member<Touch>>& touches) { return new TouchList(touches); } unsigned length() const { return m_values.size(); } Touch* item(unsigned); const Touch* item(unsigned) const; void append(const RawPtr<Touch> touch) { m_values.append(touch); } DECLARE_TRACE(); private: TouchList() { } TouchList(HeapVector<Member<Touch>>& touches) { m_values.swap(touches); } HeapVector<Member<Touch>> m_values; }; } // namespace blink #endif // TouchList_h
// Copyright 2019 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 SERVICES_NETWORK_DHCP_PAC_FILE_FETCHER_MOJO_H_ #define SERVICES_NETWORK_DHCP_PAC_FILE_FETCHER_MOJO_H_ #include <memory> #include "base/component_export.h" #include "base/macros.h" #include "base/memory/ref_counted.h" #include "base/memory/weak_ptr.h" #include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/remote.h" #include "net/base/completion_once_callback.h" #include "net/proxy_resolution/dhcp_pac_file_fetcher.h" #include "net/traffic_annotation/network_traffic_annotation.h" #include "services/network/public/mojom/dhcp_wpad_url_client.mojom.h" #include "url/gurl.h" namespace net { class URLRequestContext; class NetLogWithSource; class PacFileFetcher; } // namespace net namespace network { // Implementation of DhcpPacFileFetcher that gets the URL of the PAC file from // the default network over a mojo pipe. The default network points to a single // PAC file URL, provided by Shill, as reported over DHCP. // Currently only used on ChromeOS. class COMPONENT_EXPORT(NETWORK_SERVICE) DhcpPacFileFetcherMojo : public net::DhcpPacFileFetcher { public: DhcpPacFileFetcherMojo(net::URLRequestContext* url_request_context, mojo::PendingRemote<network::mojom::DhcpWpadUrlClient> dhcp_wpad_url_client); ~DhcpPacFileFetcherMojo() override; // DhcpPacFileFetcher implementation int Fetch(base::string16* utf16_text, net::CompletionOnceCallback callback, const net::NetLogWithSource& net_log, const net::NetworkTrafficAnnotationTag traffic_annotation) override; void Cancel() override; void OnShutdown() override; const GURL& GetPacURL() const override; std::string GetFetcherName() const override; void SetPacFileFetcherForTesting( std::unique_ptr<net::PacFileFetcher> pac_file_fetcher); private: void ContinueFetch(base::string16* utf16_text, const net::NetworkTrafficAnnotationTag traffic_annotation, std::string pac_url); void OnFetchCompleted(int result); void OnPacUrlReceived(const std::string& url); net::CompletionOnceCallback callback_; base::string16* utf16_text_; GURL pac_url_; net::MutableNetworkTrafficAnnotationTag traffic_annotation_; std::unique_ptr<net::PacFileFetcher> pac_file_fetcher_; mojo::Remote<network::mojom::DhcpWpadUrlClient> dhcp_wpad_url_client_; base::WeakPtrFactory<DhcpPacFileFetcherMojo> weak_ptr_factory_{this}; DISALLOW_COPY_AND_ASSIGN(DhcpPacFileFetcherMojo); }; } // namespace network #endif // SERVICES_NETWORK_DHCP_PAC_FILE_FETCHER_MOJO_H_
/* * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ #ifndef TEST_PC_E2E_ANALYZER_VIDEO_DEFAULT_ENCODED_IMAGE_DATA_INJECTOR_H_ #define TEST_PC_E2E_ANALYZER_VIDEO_DEFAULT_ENCODED_IMAGE_DATA_INJECTOR_H_ #include <cstdint> #include <deque> #include <memory> #include <set> #include <utility> #include <vector> #include "api/video/encoded_image.h" #include "rtc_base/critical_section.h" #include "test/pc/e2e/analyzer/video/encoded_image_data_injector.h" namespace webrtc { namespace webrtc_pc_e2e { // Injects frame id and discard flag into EncodedImage payload buffer. The // payload buffer will be appended in the injector with 2 bytes frame id and 4 // bytes original buffer length. Discarded flag will be put into the highest bit // of the length. It is assumed, that frame's data can't be more then 2^31 // bytes. In the decoder, frame id and discard flag will be extracted and the // length will be used to restore original buffer. We can't put this data in the // beginning of the payload, because first bytes are used in different parts of // WebRTC pipeline. // // The data in the EncodedImage on encoder side after injection will look like // this: // 4 bytes frame length + discard flag // _________________ _ _ _↓_ _ _ // | original buffer | | | // ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ ¯↑¯ ¯ ¯ ¯ ¯ // 2 bytes frame id // // But on decoder side multiple payloads can be concatenated into single // EncodedImage in jitter buffer and its payload will look like this: // _________ _ _ _ _ _ _ _________ _ _ _ _ _ _ _________ _ _ _ _ _ _ // buf: | payload | | | payload | | | payload | | | // ¯¯¯¯¯¯¯¯¯ ¯ ¯ ¯ ¯ ¯ ¯ ¯¯¯¯¯¯¯¯¯ ¯ ¯ ¯ ¯ ¯ ¯ ¯¯¯¯¯¯¯¯¯ ¯ ¯ ¯ ¯ ¯ ¯ // To correctly restore such images we will extract id by this algorithm: // 1. Make a pass from end to begin of the buffer to restore origin lengths, // frame ids and discard flags from length high bit. // 2. If all discard flags are true - discard this encoded image // 3. Make a pass from begin to end copying data to the output basing on // previously extracted length // Also it will check, that all extracted ids are equals. class DefaultEncodedImageDataInjector : public EncodedImageDataInjector, public EncodedImageDataExtractor { public: DefaultEncodedImageDataInjector(); ~DefaultEncodedImageDataInjector() override; EncodedImage InjectData(uint16_t id, bool discard, const EncodedImage& source, int /*coding_entity_id*/) override; EncodedImageExtractionResult ExtractData(const EncodedImage& source, int coding_entity_id) override; }; } // namespace webrtc_pc_e2e } // namespace webrtc #endif // TEST_PC_E2E_ANALYZER_VIDEO_DEFAULT_ENCODED_IMAGE_DATA_INJECTOR_H_
/** Copyright (c) Audi Autonomous Driving Cup. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display the following acknowledgement: “This product includes software developed by the Audi AG and its contributors for Audi Autonomous Driving Cup.” 4. Neither the name of Audi nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY AUDI AG AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUDI AG OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ********************************************************************** * $Author:: spiesra $ $Date:: 2014-09-16 13:33:02#$ $Rev:: 26105 $ **********************************************************************/ #ifndef _QRPLAYER_HEADER #define _QRPLAYER_HEADER #define OID_ADTF_SAVEIMGFILTER "adtf.aadc.saveImgFilter" /*! * This is filter gives an example of an QrPlayer */ class cSaveImg : public cFilter { ADTF_DECLARE_FILTER_VERSION(OID_ADTF_SAVEIMGFILTER, "AADC IMG SAVE", adtf::OBJCAT_Tool, "AADC IMG SAVE", 1, 0, 0, "Beta Version"); public: cSaveImg(const tChar* __info); ~cSaveImg(); tResult Init(tInitStage eStage, __exception); public: tResult OnPinEvent(adtf::IPin* pSource, tInt nEventCode, tInt nParam1, tInt nParam2, adtf::IMediaSample* pMediaSample); protected: cVideoPin m_oPinInputVideo; /**< input Pin for video */ cVideoPin m_oPinInputDepth; /**< input Pin for depth */ tResult Start(__exception); tResult Stop(__exception); tResult Shutdown(tInitStage eStage, __exception = NULL); private: /*! function which does the processing of the data @param pSample the incoming media sample */ tResult ProcessVideo(adtf::IMediaSample* pSample); tResult ProcessDepth(adtf::IMediaSample* pISample); /*! function to set the m_sProcessFormat and the m_sInputFormat variables @param pFormat */ tBitmapFormat m_sInputFormat; /**< holds the imageformat of the input data/pin */ tBitmapFormat m_sBitmapFormatDepth; /**< bitmap format for the depth video */ }; #endif //_QRREADER_HEADER
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CONTENT_WEB_TEST_RENDERER_GAMEPAD_CONTROLLER_H_ #define CONTENT_WEB_TEST_RENDERER_GAMEPAD_CONTROLLER_H_ #include <bitset> #include <memory> #include <set> #include "base/containers/unique_ptr_adapters.h" #include "base/macros.h" #include "base/memory/read_only_shared_memory_region.h" #include "base/memory/weak_ptr.h" #include "device/gamepad/public/cpp/gamepads.h" #include "device/gamepad/public/mojom/gamepad.mojom.h" #include "device/gamepad/public/mojom/gamepad_hardware_buffer.h" #include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/remote.h" #include "mojo/public/cpp/system/buffer.h" namespace content { class RenderFrame; class GamepadController : public base::SupportsWeakPtr<GamepadController> { public: GamepadController(); GamepadController(const GamepadController&) = delete; GamepadController& operator=(const GamepadController&) = delete; ~GamepadController(); void Reset(); void Install(RenderFrame* frame); private: class MonitorImpl : public device::mojom::GamepadMonitor { public: MonitorImpl(GamepadController* controller, mojo::PendingReceiver<device::mojom::GamepadMonitor> receiver); ~MonitorImpl() override; // Returns true if this monitor has a pending connection event for the // gamepad at |index|. The event will be dispatched once an observer is set. bool HasPendingConnect(int index); void Reset(); void DispatchConnected(int index, const device::Gamepad& pad); void DispatchDisconnected(int index, const device::Gamepad& pad); // GamepadMonitor implementation. void GamepadStartPolling(GamepadStartPollingCallback callback) override; void GamepadStopPolling(GamepadStopPollingCallback callback) override; void SetObserver( mojo::PendingRemote<device::mojom::GamepadObserver> observer) override; private: GamepadController* controller_; mojo::Receiver<device::mojom::GamepadMonitor> receiver_{this}; mojo::Remote<device::mojom::GamepadObserver> observer_remote_; std::bitset<device::Gamepads::kItemsLengthCap> missed_dispatches_; }; friend class GamepadControllerBindings; // TODO(b.kelemen): for historical reasons Connect just initializes the // object. The 'gamepadconnected' event will be dispatched via // DispatchConnected. Tests for connected events need to first connect(), // then set the gamepad data and finally call dispatchConnected(). // We should consider renaming Connect to Init and DispatchConnected to // Connect and at the same time updating all the gamepad tests. void Connect(int index); void DispatchConnected(int index); void Disconnect(int index); void SetId(int index, const std::string& src); void SetButtonCount(int index, int buttons); void SetButtonData(int index, int button, double data); void SetAxisCount(int index, int axes); void SetAxisData(int index, int axis, double data); void SetDualRumbleVibrationActuator(int index, bool enabled); void OnInterfaceRequest(mojo::ScopedMessagePipeHandle handle); base::ReadOnlySharedMemoryRegion GetSharedMemoryRegion() const; void OnConnectionError(MonitorImpl* monitor); // Notifies |monitor| for any gamepad connections that occurred before // SetObserver was called. void NotifyForMissedDispatches(MonitorImpl* monitor); std::set<std::unique_ptr<MonitorImpl>, base::UniquePtrComparator> monitors_; base::ReadOnlySharedMemoryRegion shared_memory_region_; base::WritableSharedMemoryMapping shared_memory_mapping_; device::GamepadHardwareBuffer* gamepads_ = nullptr; base::WeakPtrFactory<GamepadController> weak_factory_{this}; }; } // namespace content #endif // CONTENT_WEB_TEST_RENDERER_GAMEPAD_CONTROLLER_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_ANDROID_PROVIDER_BOOKMARK_MODEL_TASK_H_ #define CHROME_BROWSER_ANDROID_PROVIDER_BOOKMARK_MODEL_TASK_H_ #include "base/macros.h" #include "base/memory/scoped_refptr.h" #include "base/memory/weak_ptr.h" namespace bookmarks { class BookmarkModel; class ModelLoader; } // namespace bookmarks // Base class for synchronous tasks that involve the bookmark model. // Ensures the model has been loaded before accessing it. // Must not be created from the UI thread. class BookmarkModelTask { public: BookmarkModelTask(base::WeakPtr<bookmarks::BookmarkModel> model, scoped_refptr<bookmarks::ModelLoader> model_loader); ~BookmarkModelTask(); base::WeakPtr<bookmarks::BookmarkModel> model() const; private: base::WeakPtr<bookmarks::BookmarkModel> model_; DISALLOW_COPY_AND_ASSIGN(BookmarkModelTask); }; #endif // CHROME_BROWSER_ANDROID_PROVIDER_BOOKMARK_MODEL_TASK_H_
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Per-P malloc cache for small objects. // // See malloc.h for an overview. #include "runtime.h" #include "arch_GOARCH.h" #include "malloc.h" extern volatile intgo runtime·MemProfileRate; // dummy MSpan that contains no free objects. static MSpan emptymspan; MCache* runtime·allocmcache(void) { intgo rate; MCache *c; int32 i; runtime·lock(&runtime·mheap); c = runtime·FixAlloc_Alloc(&runtime·mheap.cachealloc); runtime·unlock(&runtime·mheap); runtime·memclr((byte*)c, sizeof(*c)); for(i = 0; i < NumSizeClasses; i++) c->alloc[i] = &emptymspan; // Set first allocation sample size. rate = runtime·MemProfileRate; if(rate > 0x3fffffff) // make 2*rate not overflow rate = 0x3fffffff; if(rate != 0) c->next_sample = runtime·fastrand1() % (2*rate); return c; } void runtime·freemcache(MCache *c) { runtime·MCache_ReleaseAll(c); runtime·lock(&runtime·mheap); runtime·purgecachedstats(c); runtime·FixAlloc_Free(&runtime·mheap.cachealloc, c); runtime·unlock(&runtime·mheap); } // Gets a span that has a free object in it and assigns it // to be the cached span for the given sizeclass. Returns this span. MSpan* runtime·MCache_Refill(MCache *c, int32 sizeclass) { MCacheList *l; MSpan *s; m->locks++; // Return the current cached span to the central lists. s = c->alloc[sizeclass]; if(s->freelist != nil) runtime·throw("refill on a nonempty span"); if(s != &emptymspan) runtime·MCentral_UncacheSpan(&runtime·mheap.central[sizeclass], s); // Push any explicitly freed objects to the central lists. // Not required, but it seems like a good time to do it. l = &c->free[sizeclass]; if(l->nlist > 0) { runtime·MCentral_FreeList(&runtime·mheap.central[sizeclass], l->list); l->list = nil; l->nlist = 0; } // Get a new cached span from the central lists. s = runtime·MCentral_CacheSpan(&runtime·mheap.central[sizeclass]); if(s == nil) runtime·throw("out of memory"); if(s->freelist == nil) { runtime·printf("%d %d\n", s->ref, (int32)((s->npages << PageShift) / s->elemsize)); runtime·throw("empty span"); } c->alloc[sizeclass] = s; m->locks--; return s; } void runtime·MCache_Free(MCache *c, MLink *p, int32 sizeclass, uintptr size) { MCacheList *l; // Put on free list. l = &c->free[sizeclass]; p->next = l->list; l->list = p; l->nlist++; c->local_cachealloc -= size; // We transfer a span at a time from MCentral to MCache, // so we'll do the same in the other direction. if(l->nlist >= (runtime·class_to_allocnpages[sizeclass]<<PageShift)/size) { runtime·MCentral_FreeList(&runtime·mheap.central[sizeclass], l->list); l->list = nil; l->nlist = 0; } } void runtime·MCache_ReleaseAll(MCache *c) { int32 i; MSpan *s; MCacheList *l; for(i=0; i<NumSizeClasses; i++) { s = c->alloc[i]; if(s != &emptymspan) { runtime·MCentral_UncacheSpan(&runtime·mheap.central[i], s); c->alloc[i] = &emptymspan; } l = &c->free[i]; if(l->nlist > 0) { runtime·MCentral_FreeList(&runtime·mheap.central[i], l->list); l->list = nil; l->nlist = 0; } } }
/* $FreeBSD: src/sys/ia64/include/_limits.h,v 1.11 2003/05/19 20:29:07 kan Exp $ */ /* From: NetBSD: limits.h,v 1.3 1997/04/06 08:47:31 cgd Exp */ /* * Copyright (c) 1988, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @(#)limits.h 8.3 (Berkeley) 1/4/94 */ #ifndef _MACHINE__LIMITS_H_ #define _MACHINE__LIMITS_H_ /* * According to ANSI (section 2.2.4.2), the values below must be usable by * #if preprocessing directives. Additionally, the expression must have the * same type as would an expression that is an object of the corresponding * type converted according to the integral promotions. The subtraction for * INT_MIN, etc., is so the value is not unsigned; e.g., 0x80000000 is an * unsigned int for 32-bit two's complement ANSI compilers (section 3.1.3.2). * These numbers are for the default configuration of gcc. They work for * some other compilers as well, but this should not be depended on. */ #define __CHAR_BIT 8 /* number of bits in a char */ #define __SCHAR_MAX 0x7f /* max value for a signed char */ #define __SCHAR_MIN (-0x7f-1) /* min value for a signed char */ #define __UCHAR_MAX 0xffU /* max value for an unsigned char */ #define __USHRT_MAX 0xffffU /* max value for an unsigned short */ #define __SHRT_MAX 0x7fff /* max value for a short */ #define __SHRT_MIN (-0x7fff-1) /* min value for a short */ #define __UINT_MAX 0xffffffffU /* max value for an unsigned int */ #define __INT_MAX 0x7fffffff /* max value for an int */ #define __INT_MIN (-0x7fffffff-1) /* min value for an int */ #define __ULONG_MAX 0xffffffffffffffffUL /* max for an unsigned long */ #define __LONG_MAX 0x7fffffffffffffffL /* max for a long */ #define __LONG_MIN (-0x7fffffffffffffffL-1) /* min for a long */ /* Long longs and longs are the same size on the IA-64. */ /* max for an unsigned long long */ #define __ULLONG_MAX 0xffffffffffffffffULL #define __LLONG_MAX 0x7fffffffffffffffLL /* max for a long long */ #define __LLONG_MIN (-0x7fffffffffffffffLL-1) /* min for a long long */ #define __SSIZE_MAX __LONG_MAX /* max value for a ssize_t */ #define __SIZE_T_MAX __ULONG_MAX /* max value for a size_t */ #define __OFF_MAX __LONG_MAX /* max value for an off_t */ #define __OFF_MIN __LONG_MIN /* min value for an off_t */ /* Quads and longs are the same. Ensure they stay in sync. */ #define __UQUAD_MAX (__ULONG_MAX) /* max value for a uquad_t */ #define __QUAD_MAX (__LONG_MAX) /* max value for a quad_t */ #define __QUAD_MIN (__LONG_MIN) /* min value for a quad_t */ #define __LONG_BIT 64 #define __WORD_BIT 32 #endif /* !_MACHINE__LIMITS_H_ */
#ifndef IPROTOCOLHANDLER_H #define IPROTOCOLHANDLER_H #include "messagelocation.h" #include <xsens/xsmessage.h> #include <xsens/xsbytearray.h> //-------------------------------------------------------------------------------- /*! \brief Interface class for protocol handlers \details Describes the interfaces of the protocol handling classes. The protocol handlers are used to convert a binary data stream into XsMessage objects. */ class IProtocolHandler { public: //! \brief Destructor virtual ~IProtocolHandler() {} /*! \brief Find the first message in the \a raw byte stream \details This function scans \a raw for a sequence of bytes that it can convert into an %XsMessage object. It returns the location and total byte size of the message so that the caller can remove those bytes from the stream. The return value can also describe that a partial message has been found. Return values: \li \a startpos >= 0 and \a size > 0: A full message with \a size has been found at \a startpos. \li \a startpos >= 0 and \a size == 0: The start of a message has been found at \a startpos, but the size could not yet be determined. \li \a startpos >= 0 and \a size < 0: The start of a message has been found at \a startpos, and the size of the full message is at least \a -size. \li \a startpos < 0: No messages have been found. \param rcv If a message is read, it will be put in this object. \param raw The raw byte stream to analyze. \returns A %MessageLocation object that describes what was found. */ virtual MessageLocation findMessage(XsMessage& rcv, const XsByteArray& raw) const = 0; /*! \brief Returns the minimum size of a valid message \details This value may differ for different protocols, but is always at least 1. \returns The minimum size of a valid message for the protocol. */ virtual int minimumMessageSize() const = 0; /*! \brief Returns the maximum size of a valid message \details This value may differ for different protocols. \returns The maximum size of a valid message for the protocol. */ virtual int maximumMessageSize() const = 0; /*! \brief Returns the type of the protocol handler \details Each protocol handler has a locally unique id that can be used for instantiation of the correct protocol handler. \returns The type id of the protocol handler. */ virtual int type() const = 0; }; //-------------------------------------------------------------------------------- #endif // file guard
#include <lib.h> /* telldir -- report directory stream position Author: D.A. Gwyn */ /* last edit: 25-Apr-1987 D A Gwyn */ #include <errno.h> #include <sys/types.h> #include <limits.h> #include <dirent.h> #include <unistd.h> #define DULL (DIR *) 0 #ifndef SEEK_CUR #define SEEK_CUR 1 #endif off_t telldir(dirp) /* return offset of next entry */ DIR *dirp; /* stream from opendir() */ { if (dirp == DULL || dirp->dd_buf == (char *)NULL || dirp->dd_magic != _DIR_MAGIC) if (dirp == DULL || dirp->dd_buf == (char *) NULL) { errno = EBADF; return(-1); /* invalid pointer */ } if (dirp->dd_loc < dirp->dd_size) /* valid index */ return(((struct dirent *) & dirp->dd_buf[dirp->dd_loc])->d_off); else /* beginning of next directory block */ return(lseek(dirp->dd_fd, (off_t) 0, SEEK_CUR)); }
// Generated by xsd compiler for ios/objective-c // DO NOT CHANGE! #import <Foundation/Foundation.h> #import "PicoClassSchema.h" #import "PicoPropertySchema.h" #import "PicoConstants.h" #import "PicoBindable.h" /** (public class) @ingroup AWSECommerceServicePortType */ @interface ItemMetaData : NSObject <PicoBindable> { @private NSString *_key; NSString *_value; } /** (public property) type : NSString, wrapper for primitive string */ @property (nonatomic, strong) NSString *key; /** (public property) type : NSString, wrapper for primitive string */ @property (nonatomic, strong) NSString *value; @end
#include <stdlib.h> #include <stdio.h> #include <smlsharp.h> #include <intinf.h> #include <object.h> static void obj_dump__(int indent, void *obj) { unsigned int i; unsigned int *bitmap; void **field = obj; char *buf; if (obj == NULL) { printf("%*sNULL\n", indent, ""); return; } switch (OBJ_TYPE(obj)) { case OBJTYPE_UNBOXED_ARRAY: case OBJTYPE_UNBOXED_VECTOR: printf("%*s%p:%u:%s\n", indent, "", obj, OBJ_SIZE(obj), (OBJ_TYPE(obj) == OBJTYPE_UNBOXED_ARRAY) ? "UNBOXED_ARRAY" : "UNBOXED_VECTOR"); for (i = 0; i < OBJ_SIZE(obj) / sizeof(unsigned int); i++) printf("%*s0x%08x\n", indent + 2, "", ((unsigned int *)field)[i]); for (i = i * sizeof(unsigned int); i < OBJ_SIZE(obj); i++) printf("%*s0x%02x\n", indent + 2, "", ((unsigned char*)field)[i]); break; case OBJTYPE_BOXED_ARRAY: case OBJTYPE_BOXED_VECTOR: printf("%*s%p:%u:%s\n", indent, "", obj, OBJ_SIZE(obj), (OBJ_TYPE(obj) == OBJTYPE_BOXED_ARRAY) ? "BOXED_ARRAY" : "BOXED_VECTOR"); for (i = 0; i < OBJ_SIZE(obj) / sizeof(void*); i++) obj_dump__(indent + 2, field[i]); for (i = i * sizeof(void*); i < OBJ_SIZE(obj); i++) printf("%*s0x%02x\n", indent + 2, "", ((char*)field)[i]); break; case OBJTYPE_RECORD: printf("%*s%p:%u:RECORD\n", indent, "", obj, OBJ_SIZE(obj)); bitmap = OBJ_BITMAP(obj); for (i = 0; i < OBJ_SIZE(obj) / sizeof(void*); i++) { if (BITMAP_BIT(bitmap, i) != TAG_UNBOXED) obj_dump__(indent + 2, field[i]); else printf("%*s%p\n", indent + 2, "", field[i]); } break; case OBJTYPE_INTINF: buf = sml_intinf_fmt((sml_intinf_t*)obj, 10); printf("%*s%p:%u:INTINF: %s\n", indent, "", obj, OBJ_SIZE(obj), buf); free(buf); break; default: printf("%*s%p:%u:unknown type %u", indent, "", obj, OBJ_SIZE(obj), OBJ_TYPE(obj)); break; } } static void first_array_dump(void *obj) { unsigned int i; void **field = obj; switch (OBJ_TYPE(obj)) { case OBJTYPE_UNBOXED_ARRAY: case OBJTYPE_UNBOXED_VECTOR: for (i = 0; i < OBJ_SIZE(obj) / sizeof(unsigned int); i++) printf("%*s0x%08x\n", 0, "", ((unsigned int *)field)[i]); for (i = i * sizeof(unsigned int); i < OBJ_SIZE(obj); i++) printf("%*s0x%02x\n", 0, "", ((unsigned char*)field)[i]); break; case OBJTYPE_BOXED_ARRAY: case OBJTYPE_BOXED_VECTOR: for (i = 0; i < OBJ_SIZE(obj) / sizeof(void*); i++) obj_dump__(0, field[i]); for (i = i * sizeof(void*); i < OBJ_SIZE(obj); i++) printf("%*s0x%02x\n", 0, "", ((char*)field)[i]); break; default: printf("%*s%p:%u:unknown type %u", 0, "", obj, OBJ_SIZE(obj), OBJ_TYPE(obj)); break; } } void c_dump(void* p, size_t size) { first_array_dump(p); }
// RUN: %clang_cc1 %s -triple i386-unknown-unknown -fvisibility default -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-DEFAULT // RUN: %clang_cc1 %s -triple i386-unknown-unknown -fvisibility protected -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-PROTECTED // RUN: %clang_cc1 %s -triple i386-unknown-unknown -fvisibility hidden -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN // CHECK-DEFAULT: @g_def = global i32 0 // CHECK-DEFAULT: @g_com = common global i32 0 // CHECK-DEFAULT: @g_ext = external global i32 // CHECK-DEFAULT: @g_deferred = internal global // CHECK-PROTECTED: @g_def = protected global i32 0 // CHECK-PROTECTED: @g_com = common protected global i32 0 // CHECK-PROTECTED: @g_ext = external global i32 // CHECK-PROTECTED: @g_deferred = internal global // CHECK-HIDDEN: @g_def = hidden global i32 0 // CHECK-HIDDEN: @g_com = common hidden global i32 0 // CHECK-HIDDEN: @g_ext = external global i32 // CHECK-HIDDEN: @g_deferred = internal global int g_com; int g_def = 0; extern int g_ext; static char g_deferred[] = "hello"; // CHECK-DEFAULT: @test4 = hidden global i32 10 // CHECK-PROTECTED: @test4 = hidden global i32 10 // CHECK-HIDDEN: @test4 = hidden global i32 10 // CHECK-DEFAULT: define i32 @f_def() // CHECK-DEFAULT: declare void @f_ext() // CHECK-DEFAULT: define internal void @f_deferred() // CHECK-PROTECTED: define protected i32 @f_def() // CHECK-PROTECTED: declare void @f_ext() // CHECK-PROTECTED: define internal void @f_deferred() // CHECK-HIDDEN: define hidden i32 @f_def() // CHECK-HIDDEN: declare void @f_ext() // CHECK-HIDDEN: define internal void @f_deferred() extern void f_ext(void); static void f_deferred(void) { } int f_def(void) { f_ext(); f_deferred(); return g_com + g_def + g_ext + g_deferred[0]; } // PR8457 // CHECK-DEFAULT: define void @test1( // CHECK-PROTECTED: define void @test1( // CHECK-HIDDEN: define void @test1( struct Test1 { int field; }; void __attribute__((visibility("default"))) test1(struct Test1 *v) { } // rdar://problem/8595231 // CHECK-DEFAULT: define void @test2() // CHECK-PROTECTED: define void @test2() // CHECK-HIDDEN: define void @test2() void test2(void); void __attribute__((visibility("default"))) test2(void) {} // CHECK-DEFAULT: define hidden void @test3() // CHECK-PROTECTED: define hidden void @test3() // CHECK-HIDDEN: define hidden void @test3() extern void test3(void); __private_extern__ void test3(void) {} // Top of file. extern int test4; __private_extern__ int test4 = 10; // rdar://12399248 // CHECK-DEFAULT: define hidden void @test5() // CHECK-PROTECTED: define hidden void @test5() // CHECK-HIDDEN: define hidden void @test5() __attribute__((availability(macosx,introduced=10.5,deprecated=10.6))) __private_extern__ void test5(void) {}
//****************************************************************************** // // Copyright (c) 2015 Microsoft Corporation. All rights reserved. // // This code is licensed under the MIT License (MIT). // // 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 __CGPATHINTERNAL_H #define __CGPATHINTERNAL_H #include "CoreGraphics/CGPath.h" enum pathComponentType { pathComponentRectangle, pathComponentMove, pathComponentLineTo, pathComponentArcToPoint, pathComponentQuadCurve, pathComponentBezierCurve, pathComponentCurve, pathComponentEllipseInRect, pathComponentClose, pathComponentArcAngle, }; typedef struct { float x1, y1, x2, y2; float radius; } arcToPoint; typedef struct { float x, y, startAngle, endAngle; float radius; BOOL clockwise; } arcAngle; struct curveToPoint { float x1, y1; // tangent from start float x2, y2; // tangent to end float x, y; // end pos }; struct quadCurveToPoint { float cpx, cpy; float x, y; }; struct ellipseInRect { CGRect rect; }; typedef struct { pathComponentType type; union { CGRect rect; CGPoint point; arcToPoint atp; curveToPoint ctp; ellipseInRect eir; quadCurveToPoint qtp; arcAngle aa; }; } pathComponent; @interface CGPath : NSObject { @public pathComponent* _components; NSUInteger _count; NSUInteger _max; } - (void)_getBoundingBox:(CGRect*)rectOut; @end COREGRAPHICS_EXPORT CGRect _CGPathFitRect(CGPathRef pathref, CGRect rect, CGSize maxSize, float padding); #endif
// // NSMutableSet+HelpMe.h // PPHelpMe // // Created by Marian Paul on 18/07/13. // // #import <Foundation/Foundation.h> @interface NSMutableSet (HelpMe) - (void)removeObjectIfNotNil:(id)object; @end
// // EMDropdownBox.h // Demo // // Created by Elliott Minns on 28/02/2014. // Copyright (c) 2014 Elliott Minns. All rights reserved. // #import <UIKit/UIKit.h> @class EMDropdownBox; @protocol EMDropdownBoxDelegate <NSObject> - (void)dropdownBox:(EMDropdownBox *)dropdown didSelectIndex:(NSUInteger)index; @end @interface EMDropdownBox : UIView @property (nonatomic, strong) UIFont *titleFont; @property (nonatomic, strong) NSString *title; @property (nonatomic, strong) UIColor *dropdownColor; @property (nonatomic, strong) UIColor *arrowColor; @property (nonatomic, strong) UIColor *titleColor; @property (nonatomic, strong) NSArray *tableData; @property (nonatomic, strong) UIColor *boxColor; @property (nonatomic, assign) NSInteger selectedIndex; @property (nonatomic, weak) id<EMDropdownBoxDelegate> delegate; @end
#pragma once #include <Tokenizer.h> namespace Lspl { namespace Parser { /////////////////////////////////////////////////////////////////////////////// class CPatternsFileProcessor { CPatternsFileProcessor( const CPatternsFileProcessor& ) = delete; CPatternsFileProcessor& operator=( const CPatternsFileProcessor& ) = delete; public: explicit CPatternsFileProcessor( CErrorProcessor& errorProcessor ); CPatternsFileProcessor( CErrorProcessor& errorProcessor, const string& filename ); ~CPatternsFileProcessor(); // Opens the file filename void Open( const string& filename ); // Check if a file is open bool IsOpen() const; // Closes opened file void Close(); // Reads all tokens of the pattern which // starts from the current line of the file. // Allowed only if file is opened. void ReadPattern( CTokens& patternTokens ); private: CErrorProcessor& errorProcessor; ifstream file; CTokenizer tokenizer; size_t lineNumber; string line; void reset(); void readLine(); bool tokenizeLine(); bool skipEmptyLines(); bool lineStartsWithSpace() const; }; /////////////////////////////////////////////////////////////////////////////// } // end of Parser namespace } // end of Lspl namespace
/* ** mruby/irep.h - mrb_irep structure ** ** See Copyright Notice in mruby.h */ #ifndef MRUBY_IREP_H #define MRUBY_IREP_H #if defined(__cplusplus) extern "C" { #endif /* Program data array struct */ typedef struct mrb_irep { uint32_t idx; uint16_t nlocals; /* Number of local variables */ uint16_t nregs; /* Number of register variables */ uint8_t flags; mrb_code *iseq; mrb_value *pool; mrb_sym *syms; /* debug info */ const char *filename; uint16_t *lines; struct mrb_irep_debug_info* debug_info; size_t ilen, plen, slen; } mrb_irep; #define MRB_ISEQ_NO_FREE 1 mrb_irep *mrb_add_irep(mrb_state *mrb); mrb_value mrb_load_irep(mrb_state*, const uint8_t*); #if defined(__cplusplus) } /* extern "C" { */ #endif #endif /* MRUBY_IREP_H */
// Copyright (c) 2011-2013 The Bitcredit Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCREDIT_QT_WALLETVIEW_H #define BITCREDIT_QT_WALLETVIEW_H #include "amount.h" #include <QStackedWidget> class BitcreditGUI; class ClientModel; class OverviewPage; class ReceiveCoinsDialog; class SendCoinsDialog; class SendCoinsRecipient; class TransactionView; class WalletModel; class ExchangeBrowser; class ChatWindow; class BlockBrowser; class BankStatisticsPage; class MessagePage; class InvoicePage; class ReceiptPage; class MessageModel; class SendMessagesDialog; class BanknodeManager; class AddEditAdrenalineNode; class TestPage; QT_BEGIN_NAMESPACE class QModelIndex; class QProgressDialog; QT_END_NAMESPACE /* WalletView class. This class represents the view to a single wallet. It was added to support multiple wallet functionality. Each wallet gets its own WalletView instance. It communicates with both the client and the wallet models to give the user an up-to-date view of the current core state. */ class WalletView : public QStackedWidget { Q_OBJECT public: explicit WalletView(QWidget *parent); ~WalletView(); void setBitcreditGUI(BitcreditGUI *gui); /** Set the client model. The client model represents the part of the core that communicates with the P2P network, and is wallet-agnostic. */ void setClientModel(ClientModel *clientModel); /** Set the wallet model. The wallet model represents a bitcredit wallet, and offers access to the list of transactions, address book and sending functionality. */ void setWalletModel(WalletModel *walletModel); void setMessageModel(MessageModel *messageModel); bool handlePaymentRequest(const SendCoinsRecipient& recipient); void showOutOfSyncWarning(bool fShow); private: ClientModel *clientModel; MessageModel *messageModel; WalletModel *walletModel; ChatWindow *chatWindow; ExchangeBrowser *exchangeBrowser; BanknodeManager *banknodeManagerPage; OverviewPage *overviewPage; QWidget *transactionsPage; ReceiveCoinsDialog *receiveCoinsPage; SendCoinsDialog *sendCoinsPage; BlockBrowser *blockBrowser; BankStatisticsPage *bankstatisticsPage; TransactionView *transactionView; SendMessagesDialog *sendMessagesPage; MessagePage *messagePage; InvoicePage *invoicePage; ReceiptPage *receiptPage; TestPage *testPage; QProgressDialog *progressDialog; public slots: /** Switch to overview (home) page */ void gotoOverviewPage(); /** Switch to history (transactions) page */ void gotoHistoryPage(); /** Switch to chat page */ void gotoChatPage(); /** Switch to exchange browser page */ void gotoExchangeBrowserPage(); /** Switch to receive coins page */ void gotoReceiveCoinsPage(); /** Switch to send coins page */ void gotoSendCoinsPage(QString addr = ""); void gotoBlockBrowser(); void gotoBankStatisticsPage(); void gotoSendMessagesPage(); /** Switch to send anonymous messages page */ /** Switch to view messages page */ void gotoMessagesPage(); /** Switch to invoices page */ void gotoInvoicesPage(); /** Switch to receipt page */ void gotoReceiptPage(); /** Switch to send coins page */ void gotoTestPage(); void gotoBanknodeManagerPage(); /** Show Sign/Verify Message dialog and switch to sign message tab */ void gotoSignMessageTab(QString addr = ""); /** Show Sign/Verify Message dialog and switch to verify message tab */ void gotoVerifyMessageTab(QString addr = ""); /** Show incoming transaction notification for new transactions. The new items are those between start and end inclusive, under the given parent item. */ void processNewTransaction(const QModelIndex& parent, int start, int /*end*/); void processNewMessage(const QModelIndex& parent, int start, int /*end*/); /** Encrypt the wallet */ void encryptWallet(bool status); /** Backup the wallet */ void backupWallet(); /** Change encrypted wallet passphrase */ void changePassphrase(); /** Ask for passphrase to unlock wallet temporarily */ void unlockWallet(); /** Open the print paper wallets dialog **/ void printPaperWallets(); /** Show used sending addresses */ void usedSendingAddresses(); /** Show used receiving addresses */ void usedReceivingAddresses(); /** Re-emit encryption status signal */ void updateEncryptionStatus(); /** Show progress dialog e.g. for rescan */ void showProgress(const QString &title, int nProgress); signals: /** Signal that we want to show the main window */ void showNormalIfMinimized(); /** Fired when a message should be reported to the user */ void message(const QString &title, const QString &message, unsigned int style); /** Encryption status of wallet changed */ void encryptionStatusChanged(int status); /** Notify that a new transaction appeared */ void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address); void incomingMessage(const QString& sent_datetime, QString from_address, QString to_address, QString message, int type); }; #endif // BITCREDIT_QT_WALLETVIEW_H
/* * SerialComm.h * * Author: Robert Katzschmann */ #ifndef SERIALCONTROL_SerialComm_H_ #define SERIALCONTROL_SerialComm_H_ #include "mbed.h" #include "MODSERIAL.h" #define SERIAL_DEFAULT_BAUD 9600 #define SERIAL_DEFAULT_TX USBTX #define SERIAL_DEFAULT_RX USBRX #define BUFFERSIZE 100 #define NUMBER_COUNT_DEF 5 #define NUMBER_COUNT_MAX 20 class SerialComm { public: // Initialization SerialComm(MODSERIAL* serialObject = NULL); // if objects are null, ones will be created void init(MODSERIAL* serialObject = NULL); // if serial objects are null, ones will be created // Execution control float getFloat(); //returns the first float void getFloats(float* floats, int howMany = NUMBER_COUNT_DEF); int getInt(); //returns the first int void getString(); void run(); bool checkIfNewMessage(); protected: void rxCallback(MODSERIAL_IRQ_INFO *q); private: bool messageProcessed; int byte_idx; int val_idx; int valueInts[NUMBER_COUNT_MAX]; float valueFloats[NUMBER_COUNT_MAX]; char input; char value[NUMBER_COUNT_MAX][BUFFERSIZE]; MODSERIAL* serial; }; #endif /* SERIALCONTROL_SerialComm_H_ */
/* This file is part of the Pangolin Project. * http://github.com/stevenlovegrove/Pangolin * * Copyright (c) 2011 Steven Lovegrove * * 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 PANGOLIN_UVC_H #define PANGOLIN_UVC_H #include <pangolin/pangolin.h> #include <pangolin/video/video.h> #ifdef _MSC_VER // Define missing timeval struct typedef struct timeval { long tv_sec; long tv_usec; } timeval; #endif // _MSC_VER #include <libuvc/libuvc.h> namespace pangolin { class PANGOLIN_EXPORT UvcVideo : public VideoInterface, public VideoUvcInterface { public: UvcVideo(int vendor_id, int product_id, const char* sn, int deviceid, int width, int height, int fps); ~UvcVideo(); void InitDevice(int vid, int pid, const char* sn, int deviceid, int width, int height, int fps); void DeinitDevice(); //! Implement VideoInput::Start() void Start(); //! Implement VideoInput::Stop() void Stop(); //! Implement VideoInput::SizeBytes() size_t SizeBytes() const; //! Implement VideoInput::Streams() const std::vector<StreamInfo>& Streams() const; //! Implement VideoInput::GrabNext() bool GrabNext( unsigned char* image, bool wait = true ); //! Implement VideoInput::GrabNewest() bool GrabNewest( unsigned char* image, bool wait = true ); //! Implement VideoUvcInterface::GetCtrl() int IoCtrl(uint8_t unit, uint8_t ctrl, unsigned char* data, int len, UvcRequestCode req_code); protected: static uvc_error_t FindDevice( uvc_context_t *ctx, uvc_device_t **dev, int vid, int pid, const char *sn, int device_id); std::vector<StreamInfo> streams; size_t size_bytes; uvc_context* ctx_; uvc_device* dev_; uvc_device_handle* devh_; uvc_stream_handle* strm_; uvc_stream_ctrl_t ctrl_; uvc_frame_t* frame_; }; } #endif // PANGOLIN_UVC_H
// // EKMacro.h // Copyright (c) 2014-2016 Moch Xiao (http://mochxiao.com). // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // #ifndef EKMacro_h #define EKMacro_h #ifndef NSLog # if DEBUG # define NSLog(FORMAT, ...) \ do { \ fprintf(stderr,"<%s> %s %s [%d] %s\n", \ (NSThread.isMainThread ? "UI" : "BG"), \ (sel_getName(_cmd)),\ [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], \ __LINE__, \ [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]); \ } while(0) # else # define NSLog(FORMAT, ...) # endif #endif #define EKString(FORMAT, ...) [NSString stringWithFormat:FORMAT, ##__VA_ARGS__] #define EKLocalizedString(key) NSLocalizedString(key, nil) #ifndef weakify # if DEBUG # if __has_feature(objc_arc) # define weakify(object) autoreleasepool{} __weak __typeof__(object) weak##_##object = object; # else # define weakify(object) autoreleasepool{} __block __typeof__(object) block##_##object = object; # endif # else # if __has_feature(objc_arc) # define weakify(object) try{} @finally{} {} __weak __typeof__(object) weak##_##object = object; # else # define weakify(object) try{} @finally{} {} __block __typeof__(object) block##_##object = object; # endif # endif #endif #ifndef strongify # if DEBUG # if __has_feature(objc_arc) # define strongify(object) autoreleasepool{} __typeof__(object) object = weak##_##object; # else # define strongify(object) autoreleasepool{} __typeof__(object) object = block##_##object; # endif # else # if __has_feature(objc_arc) # define strongify(object) try{} @finally{} __typeof__(object) object = weak##_##object; # else # define strongify(object) try{} @finally{} __typeof__(object) object = block##_##object; # endif # endif #endif #define EKRelease(object) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ [object class]; }) #ifndef todo # ifndef stringify # define stringify(str) #str # endif # ifndef defer_stringify # define defer_stringify(str) stringify(str) # endif # ifndef pragma_message # define pragma_message(msg) _Pragma(stringify(message(msg))) # endif # ifndef formatted_message # define formatted_message(msg) "[TODO-" defer_stringify(__COUNTER__) "] " msg " \n" defer_stringify(__FILE__) " line " defer_stringify(__LINE__) # endif # ifndef keyword # define keyword try {} @catch (...) {} # endif # define todo(msg) keyword pragma_message(formatted_message(msg)) #endif #endif /* EKMacro_h */