text
stringlengths 4
6.14k
|
|---|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_32.c
Label Definition File: CWE121_Stack_Based_Buffer_Overflow__CWE805.string.label.xml
Template File: sources-sink-32.tmpl.c
*/
/*
* @description
* CWE: 121 Stack Based Buffer Overflow
* BadSource: Set data pointer to the bad buffer
* GoodSource: Set data pointer to the good buffer
* Sink: ncat
* BadSink : Copy string to data using wcsncat
* Flow Variant: 32 Data flow using two pointers to the same value within the same function
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifndef OMITBAD
void CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_32_bad()
{
wchar_t * data;
wchar_t * *dataPtr1 = &data;
wchar_t * *dataPtr2 = &data;
wchar_t dataBadBuffer[50];
wchar_t dataGoodBuffer[100];
{
wchar_t * data = *dataPtr1;
/* FLAW: Set a pointer to a "small" buffer. This buffer will be used in the sinks as a destination
* buffer in various memory copying functions using a "large" source buffer. */
data = dataBadBuffer;
data[0] = L'\0'; /* null terminate */
*dataPtr1 = data;
}
{
wchar_t * data = *dataPtr2;
{
wchar_t source[100];
wmemset(source, L'C', 100-1); /* fill with L'C's */
source[100-1] = L'\0'; /* null terminate */
/* POTENTIAL FLAW: Possible buffer overflow if the sizeof(data)-strlen(data) is less than the length of source */
wcsncat(data, source, 100);
printWLine(data);
}
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B() uses the GoodSource with the BadSink */
static void goodG2B()
{
wchar_t * data;
wchar_t * *dataPtr1 = &data;
wchar_t * *dataPtr2 = &data;
wchar_t dataBadBuffer[50];
wchar_t dataGoodBuffer[100];
{
wchar_t * data = *dataPtr1;
/* FIX: Set a pointer to a "large" buffer, thus avoiding buffer overflows in the sinks. */
data = dataGoodBuffer;
data[0] = L'\0'; /* null terminate */
*dataPtr1 = data;
}
{
wchar_t * data = *dataPtr2;
{
wchar_t source[100];
wmemset(source, L'C', 100-1); /* fill with L'C's */
source[100-1] = L'\0'; /* null terminate */
/* POTENTIAL FLAW: Possible buffer overflow if the sizeof(data)-strlen(data) is less than the length of source */
wcsncat(data, source, 100);
printWLine(data);
}
}
}
void CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_32_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()...");
CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_32_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_32_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
/*++
Copyright (c) 2004 - 2007, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
DebugImageInfoTable.h
Abstract:
GUID and related data structures used with the Debug Image Info Table.
--*/
#ifndef _DEBUG_IMAGE_INFO_GUID_H_
#define _DEBUG_IMAGE_INFO_GUID_H_
#include "EfiSpec.h"
#include EFI_PROTOCOL_DEFINITION (LoadedImage)
#define EFI_DEBUG_IMAGE_INFO_TABLE_GUID \
{ \
0x49152e77, 0x1ada, 0x4764, {0xb7, 0xa2, 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b} \
}
extern EFI_GUID gEfiDebugImageInfoTableGuid;
#define EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS 0x01
#define EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED 0x02
#define EFI_DEBUG_IMAGE_INFO_INITIAL_SIZE (EFI_PAGE_SIZE / sizeof (UINTN))
#define EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL 0x01
typedef struct {
UINT64 Signature;
EFI_PHYSICAL_ADDRESS EfiSystemTableBase;
UINT32 Crc32;
} EFI_SYSTEM_TABLE_POINTER;
typedef struct {
UINT32 ImageInfoType;
EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProtocolInstance;
EFI_HANDLE *ImageHandle;
} EFI_DEBUG_IMAGE_INFO_NORMAL;
typedef union {
UINT32 *ImageInfoType;
EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage;
} EFI_DEBUG_IMAGE_INFO;
typedef struct {
volatile UINT32 UpdateStatus;
UINT32 TableSize;
EFI_DEBUG_IMAGE_INFO *EfiDebugImageInfoTable;
} EFI_DEBUG_IMAGE_INFO_TABLE_HEADER;
#endif
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkPCosmoReader.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.
=========================================================================*/
/*=========================================================================
Program: VTK/ParaView Los Alamos National Laboratory Modules (PVLANL)
Module: vtkPCosmoReader.h
Copyright (c) 2009 Los Alamos National Security, LLC
All rights reserved.
Copyright 2009. Los Alamos National Security, LLC.
This software was produced under U.S. Government contract DE-AC52-06NA25396
for Los Alamos National Laboratory (LANL), which is operated by
Los Alamos National Security, LLC for the U.S. Department of Energy.
The U.S. Government has rights to use, reproduce, and distribute this software.
NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY, LLC MAKES ANY WARRANTY,
EXPRESS OR IMPLIED, OR ASSUMES ANY LIABILITY FOR THE USE OF THIS SOFTWARE.
If software is modified to produce derivative works, such modified software
should be clearly marked, so as not to confuse it with the version available
from LANL.
Additionally, 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 Los Alamos National Security, LLC, Los Alamos National
Laboratory, LANL, the U.S. Government, 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 LOS ALAMOS NATIONAL SECURITY, LLC 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 LOS ALAMOS NATIONAL SECURITY, LLC 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.
=========================================================================*/
// .NAME vtkPCosmoReader - Read a binary cosmology data file
//
// .SECTION Description
// vtkPCosmoReader creates a vtkUnstructuredGrid from a binary cosmology file.
//
// A cosmo file is a record format file with no header.
// One record per particle.
//
// Each record is 32 bytes, with fields (in order) for:
// x_position (float),
// x_velocity (float),
// y_position (float),
// y_velocity (float),
// z-position (float),
// z_velocity (float)
// mass (float)
// identification tag (integer)
//
// Total particle data can be split into per processor files, with each file
// name ending in the processor number.
//
#ifndef __vtkPCosmoReader_h
#define __vtkPCosmoReader_h
#include "vtkFiltersCosmoModule.h" // For export macro
#include "vtkUnstructuredGridAlgorithm.h"
class vtkMultiProcessController;
class vtkStdString;
class VTKFILTERSCOSMO_EXPORT vtkPCosmoReader : public vtkUnstructuredGridAlgorithm
{
public:
static vtkPCosmoReader *New();
vtkTypeMacro(vtkPCosmoReader, vtkUnstructuredGridAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Specify the name of the cosmology particle binary file to read
vtkSetStringMacro(FileName);
vtkGetStringMacro(FileName);
// Description:
// Specify the physical box dimensions size (rL)
// (default 100.0)
vtkSetMacro(RL, float);
vtkGetMacro(RL, float);
// Description:
// Specify the ghost cell spacing in Mpc (in rL units)
// (edge boundary of processor box)
// (default 5)
vtkSetMacro(Overlap, float);
vtkGetMacro(Overlap, float);
// Description:
// Set the read mode (0 = one-to-one, 1 = default, round-robin)
vtkSetMacro(ReadMode, int);
vtkGetMacro(ReadMode, int);
// Description:
// Set the filetype to Gadget or Cosmo read mode
// (0 = Gadget, 1 = default, Cosmo)
vtkSetMacro(CosmoFormat, int);
vtkGetMacro(CosmoFormat, int);
// Description:
// Set the communicator object for interprocess communication
virtual vtkMultiProcessController* GetController();
virtual void SetController(vtkMultiProcessController*);
protected:
vtkPCosmoReader();
~vtkPCosmoReader();
virtual int RequestInformation
(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
virtual int RequestData
(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
vtkMultiProcessController* Controller;
char* FileName; // Name of binary particle file
float RL; // The physical box dimensions (rL)
float Overlap; // The ghost cell boundary space
int ReadMode; // The reading mode
int CosmoFormat; // Enable cosmo format or gadget format
private:
vtkPCosmoReader(const vtkPCosmoReader&); // Not implemented.
void operator=(const vtkPCosmoReader&); // Not implemented.
};
#endif
|
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef BASECONTROLLER_H_HEADER_INCLUDED_C1E745A3
#define BASECONTROLLER_H_HEADER_INCLUDED_C1E745A3
#include <MitkExports.h>
#include "mitkStepper.h"
#include "mitkStateMachine.h"
#include <itkObjectFactory.h>
namespace mitk {
class BaseRenderer;
//##Documentation
//## @brief Baseclass for renderer slice-/camera-control
//##
//## Tells the render (subclass of BaseRenderer) which slice (subclass
//## SliceNavigationController) or from which direction (subclass
//## CameraController) it has to render. Contains two Stepper for stepping
//## through the slices or through different camera views (e.g., for the
//## creation of a movie around the data), respectively, and through time, if
//## there is 3D+t data.
//## @note not yet implemented
//## @ingroup NavigationControl
class MITK_CORE_EXPORT BaseController : public StateMachine
{
public:
/** Standard class typedefs. */
mitkClassMacro(BaseController, StateMachine);
itkNewMacro(Self);
/** Method for creation through ::New */
mitkNewMacro1Param(Self, const char *);
//##Documentation
//## @brief Get the Stepper through the slices
mitk::Stepper* GetSlice();
//##Documentation
//## @brief Get the Stepper through the time
mitk::Stepper* GetTime();
protected:
/**
* @brief Default Constructor
**/
BaseController(const char * type = NULL);
/**
* @brief Default Destructor
**/
virtual ~BaseController();
//## @brief Stepper through the time
Stepper::Pointer m_Time;
//## @brief Stepper through the slices
Stepper::Pointer m_Slice;
unsigned long m_LastUpdateTime;
};
} // namespace mitk
#endif /* BASECONTROLLER_H_HEADER_INCLUDED_C1E745A3 */
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE195_Signed_to_Unsigned_Conversion_Error__rand_strncpy_14.c
Label Definition File: CWE195_Signed_to_Unsigned_Conversion_Error.label.xml
Template File: sources-sink-14.tmpl.c
*/
/*
* @description
* CWE: 195 Signed to Unsigned Conversion Error
* BadSource: rand Set data to result of rand(), which may be zero
* GoodSource: Positive integer
* Sink: strncpy
* BadSink : Copy strings using strncpy() with the length of data
* Flow Variant: 14 Control flow: if(globalFive==5) and if(globalFive!=5)
*
* */
#include "std_testcase.h"
#ifndef OMITBAD
void CWE195_Signed_to_Unsigned_Conversion_Error__rand_strncpy_14_bad()
{
int data;
/* Initialize data */
data = -1;
if(globalFive==5)
{
/* POTENTIAL FLAW: Set data to a random value */
data = RAND32();
}
{
char source[100];
char dest[100] = "";
memset(source, 'A', 100-1);
source[100-1] = '\0';
if (data < 100)
{
/* POTENTIAL FLAW: data is interpreted as an unsigned int - if its value is negative,
* the sign conversion could result in a very large number */
strncpy(dest, source, data);
dest[data] = '\0'; /* strncpy() does not always NULL terminate */
}
printLine(dest);
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B1() - use goodsource and badsink by changing the globalFive==5 to globalFive!=5 */
static void goodG2B1()
{
int data;
/* Initialize data */
data = -1;
if(globalFive!=5)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
/* FIX: Use a positive integer less than &InitialDataSize&*/
data = 100-1;
}
{
char source[100];
char dest[100] = "";
memset(source, 'A', 100-1);
source[100-1] = '\0';
if (data < 100)
{
/* POTENTIAL FLAW: data is interpreted as an unsigned int - if its value is negative,
* the sign conversion could result in a very large number */
strncpy(dest, source, data);
dest[data] = '\0'; /* strncpy() does not always NULL terminate */
}
printLine(dest);
}
}
/* goodG2B2() - use goodsource and badsink by reversing the blocks in the if statement */
static void goodG2B2()
{
int data;
/* Initialize data */
data = -1;
if(globalFive==5)
{
/* FIX: Use a positive integer less than &InitialDataSize&*/
data = 100-1;
}
{
char source[100];
char dest[100] = "";
memset(source, 'A', 100-1);
source[100-1] = '\0';
if (data < 100)
{
/* POTENTIAL FLAW: data is interpreted as an unsigned int - if its value is negative,
* the sign conversion could result in a very large number */
strncpy(dest, source, data);
dest[data] = '\0'; /* strncpy() does not always NULL terminate */
}
printLine(dest);
}
}
void CWE195_Signed_to_Unsigned_Conversion_Error__rand_strncpy_14_good()
{
goodG2B1();
goodG2B2();
}
#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()...");
CWE195_Signed_to_Unsigned_Conversion_Error__rand_strncpy_14_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE195_Signed_to_Unsigned_Conversion_Error__rand_strncpy_14_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <Foundation/Foundation.h>
#import <React/RCTDefines.h>
#if RCT_DEV
@class RCTBridge;
/**
* Encapsulates connection to React Native packager
*/
@interface RCTPackagerConnection : NSObject
- (instancetype)initWithBridge:(RCTBridge *)bridge;
- (void)connect;
@end
#endif
|
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef _QMITKSIMPLEEXAMPLEVIEW_H_INCLUDED
#define _QMITKSIMPLEEXAMPLEVIEW_H_INCLUDED
#include <QmitkFunctionality.h>
#include <string>
#include "ui_QmitkSimpleExampleViewControls.h"
#include <QmitkRenderWindow.h>
/*!
* \ingroup org_mitk_gui_qt_simpleexample_internal
*
* \brief QmitkSimpleExampleView
*
* Document your class here.
*
* \sa QmitkFunctionality
*/
class QmitkSimpleExampleView : public QmitkFunctionality
{
// this is needed for all Qt objects that should have a MOC object (everything that derives from QObject)
Q_OBJECT
public:
static const std::string VIEW_ID;
QmitkSimpleExampleView();
QmitkSimpleExampleView(const QmitkSimpleExampleView& other);
virtual ~QmitkSimpleExampleView();
virtual void CreateQtPartControl(QWidget *parent);
/// \brief Creation of the connections of main and control widget
virtual void CreateConnections();
/// \brief Called when the functionality is activated
virtual void Activated();
virtual void Deactivated();
virtual void StdMultiWidgetAvailable (QmitkStdMultiWidget &stdMultiWidget);
virtual void StdMultiWidgetNotAvailable();
protected slots:
/*!
qt slot for event processing from a qt widget defining the stereo mode of widget 4
*/
void stereoSelectionChanged(int id);
/*!
initialize the axial, sagittal, coronal and temporal slider according to the image dimensions
*/
void initNavigators();
/*!
generate a movie as *.avi from the active render window
*/
void generateMovie();
/*!
return the renderwindow of which the movie shall be created, what depends on the toggled button
*/
QmitkRenderWindow* GetMovieRenderWindow();
void OnRenderWindow1Clicked();
void OnRenderWindow2Clicked();
void OnRenderWindow3Clicked();
void OnRenderWindow4Clicked();
void OnTakeHighResolutionScreenshot(); ///< takes screenshot of the 3D window in 4x resolution of the render window
void OnTakeScreenshot(); ///< takes screenshot of the selected render window
protected:
Ui::QmitkSimpleExampleViewControls* m_Controls;
QmitkStdMultiWidget* m_MultiWidget;
void TakeScreenshot(vtkRenderer* renderer, unsigned int magnificationFactor, QString fileName); ///< writes a screenshot in JPEG or PNG format to the file fileName
bool m_NavigatorsInitialized;
};
#endif // _QMITKSIMPLEEXAMPLEVIEW_H_INCLUDED
|
#include <stdio.h>
#include <contiki.h>
#include <contiki-net.h>
#include "letmecreate/core/debug.h"
#include "letmecreate/core/i2c.h"
#include "letmecreate/click/weather.h"
PROCESS(main_process, "Main process");
AUTOSTART_PROCESSES(&main_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(main_process, ev, data)
{
PROCESS_BEGIN();
INIT_NETWORK_DEBUG();
{
// Due to the way Contiki protothreads work this needs to be static,
// otherwise the data will be lost when switching to a different thread
static struct etimer et;
static double temperature = 0.0;
static double pressure = 0.0;
static double humidity = 0.0;
PRINTF("===START===\n");
i2c_init();
weather_click_enable();
while (1)
{
weather_click_read_measurements(&temperature, &pressure, &humidity);
PRINTF("Temperature: %i Pressure: %i Humidity: %i\n",
(int)temperature, (int)pressure, (int)humidity);
etimer_set(&et, CLOCK_SECOND);
PROCESS_WAIT_EVENT();
}
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/
|
// 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 UI_GFX_GEOMETRY_CUBIC_BEZIER_H_
#define UI_GFX_GEOMETRY_CUBIC_BEZIER_H_
#include "base/macros.h"
#include "ui/gfx/geometry/geometry_export.h"
namespace gfx {
#define CUBIC_BEZIER_SPLINE_SAMPLES 11
class GEOMETRY_EXPORT CubicBezier {
public:
CubicBezier(double p1x, double p1y, double p2x, double p2y);
CubicBezier(const CubicBezier& other);
CubicBezier& operator=(const CubicBezier&) = delete;
double SampleCurveX(double t) const {
// `ax t^3 + bx t^2 + cx t' expanded using Horner's rule.
return ((ax_ * t + bx_) * t + cx_) * t;
}
double SampleCurveY(double t) const {
return ((ay_ * t + by_) * t + cy_) * t;
}
double SampleCurveDerivativeX(double t) const {
return (3.0 * ax_ * t + 2.0 * bx_) * t + cx_;
}
double SampleCurveDerivativeY(double t) const {
return (3.0 * ay_ * t + 2.0 * by_) * t + cy_;
}
static double GetDefaultEpsilon();
// Given an x value, find a parametric value it came from.
// x must be in [0, 1] range. Doesn't use gradients.
double SolveCurveX(double x, double epsilon) const;
// Evaluates y at the given x with default epsilon.
double Solve(double x) const;
// Evaluates y at the given x. The epsilon parameter provides a hint as to the
// required accuracy and is not guaranteed. Uses gradients if x is
// out of [0, 1] range.
double SolveWithEpsilon(double x, double epsilon) const {
if (x < 0.0)
return 0.0 + start_gradient_ * x;
if (x > 1.0)
return 1.0 + end_gradient_ * (x - 1.0);
return SampleCurveY(SolveCurveX(x, epsilon));
}
// Returns an approximation of dy/dx at the given x with default epsilon.
double Slope(double x) const;
// Returns an approximation of dy/dx at the given x.
// Clamps x to range [0, 1].
double SlopeWithEpsilon(double x, double epsilon) const;
// These getters are used rarely. We reverse compute them from coefficients.
// See CubicBezier::InitCoefficients. The speed has been traded for memory.
double GetX1() const;
double GetY1() const;
double GetX2() const;
double GetY2() const;
// Gets the bezier's minimum y value in the interval [0, 1].
double range_min() const { return range_min_; }
// Gets the bezier's maximum y value in the interval [0, 1].
double range_max() const { return range_max_; }
private:
void InitCoefficients(double p1x, double p1y, double p2x, double p2y);
void InitGradients(double p1x, double p1y, double p2x, double p2y);
void InitRange(double p1y, double p2y);
void InitSpline();
double ax_;
double bx_;
double cx_;
double ay_;
double by_;
double cy_;
double start_gradient_;
double end_gradient_;
double range_min_;
double range_max_;
double spline_samples_[CUBIC_BEZIER_SPLINE_SAMPLES];
#ifndef NDEBUG
// Guard against attempted to solve for t given x in the event that the curve
// may have multiple values for t for some values of x in [0, 1].
bool monotonically_increasing_;
#endif
};
} // namespace gfx
#endif // UI_GFX_GEOMETRY_CUBIC_BEZIER_H_
|
/**
* @file scan_cv.h
* @brief load 3D Scans in opencv format for featuer based registration.
* This class is an 3D scan container for scans that have different scan
* file formats and add them to a OpenCV Mat data type also normalize the
* reflectance.
* @author HamidReza Houshiar. Jacobs University Bremen gGmbH, Germany.
* @date Date: 2012/05/9 2:00
*/
#ifndef SCAN_CV_H_
#define SCAN_CV_H_
#include "fbr_global.h"
#include "slam6d/scan.h"
#include "slam6d/managedScan.h"
#undef max
#undef min
#include <limits>
#include "show/scancolormanager.h"
#include "show/show_Boctree.h"
#include "slam6d/point_type.h"
#include "show/show.h"
#include "slam6d/data_types.h"
#include "slam6d/Boctree.h"
#include "slam6d/basicScan.h"
namespace fbr{
/**
* @class scan_cv
* @brief class for 3D scans in open CV Mat data type
* @param sDir name and dir of the input scan file
* @param scan Mat data type which contains the 3D Scan
* @param scanColor Mat data type which contains the color of the 3D Scan
* @param sNumber input scan number
* @param nPoints Number of points
* @param zmax max value in z direction
* @param zmin min value in z direction
* @param sFormat input scan file format in IOType
* @param scanserver
* @param loadOct
* @param saveOct
*/
class scan_cv{
string sDir;
cv::Mat scan;
cv::Mat scanColor;
unsigned int sNumber;
unsigned int nPoints;
double zMax;
double zMin;
IOType sFormat;
bool scanserver;
bool loadOct;
bool saveOct;
bool reflectance, color;
unsigned int types;
double voxelSize, red, scale;
scanner_type sType;
int maxDist, minDist;
public:
/**
* constructor of class scan_cv
* @param dir directory of the input scan file
* @param number input scan number
* @param format input scan file format
* @param scanServer
* @param loadOct
* @param saveOct
*/
scan_cv (string dir, unsigned int number, IOType format, bool scanServer, scanner_type type, bool lOct, bool sOct, bool Reflectance, bool Color, int MaxDist, int MinDist);
scan_cv (string dir, unsigned int number, IOType format, bool scanServer, scanner_type type, bool lOct, bool sOct, bool Reflectance, bool Color);
scan_cv (string dir, unsigned int number, IOType format, bool scanServer);
scan_cv (string dir, unsigned int number, IOType format);
/**
* @brief read scan file and convert it to open cv Mat
*/
void convertScanToMat();
string getScanDir();
unsigned int getScanNumber();
unsigned int getNumberOfPoints();
double getZMin();
double getZMax();
IOType getScanFormat();
cv::Mat getMatScan();
cv::Mat getMatScanColor();
void getDescription();
};
}
#endif /* SCAN_CV_H_ */
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memcpy_41.c
Label Definition File: CWE195_Signed_to_Unsigned_Conversion_Error.label.xml
Template File: sources-sink-41.tmpl.c
*/
/*
* @description
* CWE: 195 Signed to Unsigned Conversion Error
* BadSource: listen_socket Read data using a listen socket (server side)
* GoodSource: Positive integer
* Sink: memcpy
* BadSink : Copy strings using memcpy() with the length of data
* Flow Variant: 41 Data flow: data passed as an argument from one function to another in the same source file
*
* */
#include "std_testcase.h"
#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
#include <direct.h>
#pragma comment(lib, "ws2_32") /* include ws2_32.lib when linking */
#define CLOSE_SOCKET closesocket
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define CLOSE_SOCKET close
#define SOCKET int
#endif
#define TCP_PORT 27015
#define LISTEN_BACKLOG 5
#define CHAR_ARRAY_SIZE (3 * sizeof(data) + 2)
#ifndef OMITBAD
void CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memcpy_41_badSink(int data)
{
{
char source[100];
char dest[100] = "";
memset(source, 'A', 100-1);
source[100-1] = '\0';
if (data < 100)
{
/* POTENTIAL FLAW: data is interpreted as an unsigned int - if its value is negative,
* the sign conversion could result in a very large number */
memcpy(dest, source, data);
dest[data] = '\0'; /* NULL terminate */
}
printLine(dest);
}
}
void CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memcpy_41_bad()
{
int data;
/* Initialize data */
data = -1;
{
#ifdef _WIN32
WSADATA wsaData;
int wsaDataInit = 0;
#endif
int recvResult;
struct sockaddr_in service;
SOCKET listenSocket = INVALID_SOCKET;
SOCKET acceptSocket = INVALID_SOCKET;
char inputBuffer[CHAR_ARRAY_SIZE];
do
{
#ifdef _WIN32
if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR)
{
break;
}
wsaDataInit = 1;
#endif
/* POTENTIAL FLAW: Read data using a listen socket */
listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (listenSocket == INVALID_SOCKET)
{
break;
}
memset(&service, 0, sizeof(service));
service.sin_family = AF_INET;
service.sin_addr.s_addr = INADDR_ANY;
service.sin_port = htons(TCP_PORT);
if (bind(listenSocket, (struct sockaddr*)&service, sizeof(service)) == SOCKET_ERROR)
{
break;
}
if (listen(listenSocket, LISTEN_BACKLOG) == SOCKET_ERROR)
{
break;
}
acceptSocket = accept(listenSocket, NULL, NULL);
if (acceptSocket == SOCKET_ERROR)
{
break;
}
/* Abort on error or the connection was closed */
recvResult = recv(acceptSocket, inputBuffer, CHAR_ARRAY_SIZE - 1, 0);
if (recvResult == SOCKET_ERROR || recvResult == 0)
{
break;
}
/* NUL-terminate the string */
inputBuffer[recvResult] = '\0';
/* Convert to int */
data = atoi(inputBuffer);
}
while (0);
if (listenSocket != INVALID_SOCKET)
{
CLOSE_SOCKET(listenSocket);
}
if (acceptSocket != INVALID_SOCKET)
{
CLOSE_SOCKET(acceptSocket);
}
#ifdef _WIN32
if (wsaDataInit)
{
WSACleanup();
}
#endif
}
CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memcpy_41_badSink(data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
void CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memcpy_41_goodG2BSink(int data)
{
{
char source[100];
char dest[100] = "";
memset(source, 'A', 100-1);
source[100-1] = '\0';
if (data < 100)
{
/* POTENTIAL FLAW: data is interpreted as an unsigned int - if its value is negative,
* the sign conversion could result in a very large number */
memcpy(dest, source, data);
dest[data] = '\0'; /* NULL terminate */
}
printLine(dest);
}
}
/* goodG2B uses the GoodSource with the BadSink */
static void goodG2B()
{
int data;
/* Initialize data */
data = -1;
/* FIX: Use a positive integer less than &InitialDataSize&*/
data = 100-1;
CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memcpy_41_goodG2BSink(data);
}
void CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memcpy_41_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()...");
CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memcpy_41_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memcpy_41_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
#ifndef MOTORCALIBRATE_H
#define MOTORCALIBRATE_H
#include "motorcalibrate.h"
#include "Modeling/Resources.h"
#include "Modeling/Robot.h"
#include "Modeling/Interpolate.h"
#include <robotics/ConstrainedDynamics.h>
#include <math/differentiation.h>
#include <math/LDL.h>
#include <optimization/Minimization.h>
#include <utils/AnyCollection.h>
#include <fstream>
#include <Timer.h>
//set this to something small if you want this to be faster
//const static size_t gMaxMilestones = 100;
static int gMaxMilestones = 100000;
static Vector3 gGravity(0,0,-9.8);
static Real gDefaultTimestep = 1e-3;
static Real gDefaultVelocityWeight = Sqr(0.005);
static int gVerbose = 0;
static int gErrorGetchar = 1;
static int gStepGetchar = 0;
class MotorCalibrateSettings : public AnyCollection
{
public:
MotorCalibrateSettings() {
}
bool read(const char* fn) {
ifstream in(fn,ios::in);
if(!in) return false;
AnyCollection newEntries;
if(!newEntries.read(in)) return false;
merge(newEntries);
return true;
}
bool write(const char* fn) {
ofstream out(fn,ios::out);
if(!out) return false;
AnyCollection::write(out);
out.close();
return true;
}
};
int main_shell(int argc,char **argv);
string motorcalibrate(AnyCollection settings);
#endif
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE121_Stack_Based_Buffer_Overflow__CWE129_rand_51b.c
Label Definition File: CWE121_Stack_Based_Buffer_Overflow__CWE129.label.xml
Template File: sources-sinks-51b.tmpl.c
*/
/*
* @description
* CWE: 121 Stack Based Buffer Overflow
* BadSource: rand Set data to result of rand(), which may be zero
* GoodSource: Larger than zero but less than 10
* Sinks:
* GoodSink: Ensure the array index is valid
* BadSink : Improperly check the array index by not checking the upper bound
* Flow Variant: 51 Data flow: data passed as an argument from one function to another in different source files
*
* */
#include "std_testcase.h"
#ifndef OMITBAD
void CWE121_Stack_Based_Buffer_Overflow__CWE129_rand_51b_badSink(int data)
{
{
int i;
int buffer[10] = { 0 };
/* POTENTIAL FLAW: Attempt to write to an index of the array that is above the upper bound
* This code does check to see if the array index is negative */
if (data >= 0)
{
buffer[data] = 1;
/* Print the array values */
for(i = 0; i < 10; i++)
{
printIntLine(buffer[i]);
}
}
else
{
printLine("ERROR: Array index is negative.");
}
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B uses the GoodSource with the BadSink */
void CWE121_Stack_Based_Buffer_Overflow__CWE129_rand_51b_goodG2BSink(int data)
{
{
int i;
int buffer[10] = { 0 };
/* POTENTIAL FLAW: Attempt to write to an index of the array that is above the upper bound
* This code does check to see if the array index is negative */
if (data >= 0)
{
buffer[data] = 1;
/* Print the array values */
for(i = 0; i < 10; i++)
{
printIntLine(buffer[i]);
}
}
else
{
printLine("ERROR: Array index is negative.");
}
}
}
/* goodB2G uses the BadSource with the GoodSink */
void CWE121_Stack_Based_Buffer_Overflow__CWE129_rand_51b_goodB2GSink(int data)
{
{
int i;
int buffer[10] = { 0 };
/* FIX: Properly validate the array index and prevent a buffer overflow */
if (data >= 0 && data < (10))
{
buffer[data] = 1;
/* Print the array values */
for(i = 0; i < 10; i++)
{
printIntLine(buffer[i]);
}
}
else
{
printLine("ERROR: Array index is out-of-bounds");
}
}
}
#endif /* OMITGOOD */
|
// 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_PLUGIN_PREFS_FACTORY_H_
#define CHROME_BROWSER_PLUGIN_PREFS_FACTORY_H_
#pragma once
#include "base/compiler_specific.h"
#include "base/memory/singleton.h"
#include "chrome/browser/profiles/profile_keyed_service.h"
#include "chrome/browser/profiles/profile_keyed_service_factory.h"
class PluginPrefs;
class PrefService;
class Profile;
class ProfileKeyedService;
// A wrapper around PluginPrefs to own the reference to thre real object.
//
// This should totally go away; we need a generic bridge between PKSF and
// scope_refptrs.
class PluginPrefsWrapper : public ProfileKeyedService {
public:
explicit PluginPrefsWrapper(scoped_refptr<PluginPrefs> plugin_prefs);
virtual ~PluginPrefsWrapper();
PluginPrefs* plugin_prefs() { return plugin_prefs_.get(); }
private:
// ProfileKeyedService methods:
virtual void Shutdown() OVERRIDE;
scoped_refptr<PluginPrefs> plugin_prefs_;
};
class PluginPrefsFactory : public ProfileKeyedServiceFactory {
public:
static PluginPrefsFactory* GetInstance();
PluginPrefsWrapper* GetWrapperForProfile(Profile* profile);
// Factory function for use with
// ProfileKeyedServiceFactory::SetTestingFactory.
static ProfileKeyedService* CreateWrapperForProfile(Profile* profile);
// Some unit tests that deal with PluginPrefs don't run with a Profile. Let
// them still register their preferences.
void ForceRegisterPrefsForTest(PrefService* prefs);
private:
friend struct DefaultSingletonTraits<PluginPrefsFactory>;
PluginPrefsFactory();
virtual ~PluginPrefsFactory();
// ProfileKeyedServiceFactory methods:
virtual ProfileKeyedService* BuildServiceInstanceFor(
Profile* profile) const OVERRIDE;
virtual void RegisterUserPrefs(PrefService* prefs) OVERRIDE;
virtual bool ServiceRedirectedInIncognito() OVERRIDE;
virtual bool ServiceIsNULLWhileTesting() OVERRIDE;
virtual bool ServiceIsCreatedWithProfile() OVERRIDE;
};
#endif // CHROME_BROWSER_PLUGIN_PREFS_FACTORY_H_
|
//
// TGAppDelegate.h
// TGJSBridge
//
// Created by Chao Shen on 12-3-1.
// Copyright (c) 2012年 Hangzhou Jiuyan Technology Co., Ltd. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "TGJSBridge.h"
@class TGViewController;
@interface TGAppDelegate : UIResponder <UIApplicationDelegate, TGJSBridgeDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (retain, nonatomic) UIWebView *webView;
@property (retain, nonatomic) UIButton *btn;
@property (retain, nonatomic) TGJSBridge *jsBridge;
@end
|
/* Copyright (c) 2010 The Chromium OS 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 VBOOT_REFERENCE_SIGNATURE_DIGEST_H_
#define VBOOT_REFERENCE_SIGNATURE_DIGEST_H_
#include <stdint.h>
/* Returns a buffer with DigestInfo (which depends on [algorithm])
* prepended to [digest].
*/
uint8_t* PrependDigestInfo(enum vb2_hash_algorithm hash_alg, uint8_t* digest);
/* Function that outputs the message digest of the contents of a buffer in a
* format that can be used as input to OpenSSL for an RSA signature.
* Needed until the stable OpenSSL release supports SHA-256/512 digests for
* RSA signatures.
*
* Returns DigestInfo || Digest where DigestInfo is the OID depending on the
* choice of the hash algorithm (see padding.c). Caller owns the returned
* pointer and must Free() it.
*/
uint8_t* SignatureDigest(const uint8_t* buf, uint64_t len,
unsigned int algorithm);
/* Calculates the signature on a buffer [buf] of length [len] using
* the private RSA key file from [key_file] and signature algorithm
* [algorithm].
*
* Returns the signature. Caller owns the buffer and must Free() it.
*/
uint8_t* SignatureBuf(const uint8_t* buf, uint64_t len, const char* key_file,
unsigned int algorithm);
#endif /* VBOOT_REFERENCE_SIGNATURE_DIGEST_H_ */
|
// 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 SKY_ENGINE_BINDINGS_SCHEDULED_ACTION_H_
#define SKY_ENGINE_BINDINGS_SCHEDULED_ACTION_H_
#include "dart/runtime/include/dart_api.h"
#include "sky/engine/tonic/dart_persistent_value.h"
#include "sky/engine/tonic/dart_state.h"
#include "sky/engine/wtf/RefPtr.h"
#include "sky/engine/wtf/PassOwnPtr.h"
namespace blink {
class ExecutionContext;
class ScheduledAction {
public:
static PassOwnPtr<ScheduledAction> Create(DartState* dart_state,
Dart_Handle closure) {
return adoptPtr(new ScheduledAction(dart_state, closure));
}
~ScheduledAction();
void Execute(ExecutionContext*);
private:
ScheduledAction(DartState* dart_state, Dart_Handle closure);
DartPersistentValue closure_;
};
} // namespace blink
#endif // SKY_ENGINE_BINDINGS_SCHEDULED_ACTION_H_
|
/*===================================================================
The Medical Imaging Interaction Toolkit (MITK)
Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.
This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.
See LICENSE.txt or http://www.mitk.org for details.
===================================================================*/
#ifndef PARRECFILEREADER_H_HEADER_INCLUDED_C1F48A22
#define PARRECFILEREADER_H_HEADER_INCLUDED_C1F48A22
#include "mitkCommon.h"
#include "mitkFileReader.h"
#include "mitkImageSource.h"
namespace mitk
{
//##Documentation
//## @brief Reader to read files in Philips PAR/REC file format
class ParRecFileReader : public ImageSource, public FileReader
{
public:
mitkClassMacro(ParRecFileReader, FileReader);
/** Method for creation through the object factory. */
itkFactorylessNewMacro(Self) itkCloneMacro(Self)
itkSetStringMacro(FileName);
itkGetStringMacro(FileName);
itkSetStringMacro(FilePrefix);
itkGetStringMacro(FilePrefix);
itkSetStringMacro(FilePattern);
itkGetStringMacro(FilePattern);
static bool CanReadFile(const std::string filename, const std::string filePrefix, const std::string filePattern);
protected:
virtual void GenerateData() override;
virtual void GenerateOutputInformation() override;
ParRecFileReader();
~ParRecFileReader();
//##Description
//## @brief Time when Header was last read
itk::TimeStamp m_ReadHeaderTime;
int m_StartFileIndex;
protected:
std::string m_FileName;
std::string m_RecFileName;
std::string m_FilePrefix;
std::string m_FilePattern;
};
} // namespace mitk
#endif /* PARRECFILEREADER_H_HEADER_INCLUDED_C1F48A22 */
|
/* Copyright 2015~2016, Ian Olivieri <ianolivieri93@gmail.com>
* All rights reserved.
*
* This file is part of the Firmata4CIAA program.
*
* 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 copyright holder 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 PWM_DRIVER_H_
#define PWM_DRIVER_H_
/*==================[inclusions]=============================================*/
/*==================[cplusplus]==============================================*/
#ifdef __cplusplus
extern "C" {
#endif
/*==================[macros and definitions]=================================*/
/*==================[typedef]================================================*/
/* PWM names are defined in sAPI_PeripheralMap.h:
typedef enum{
PWM0, PWM1, PWM2, PWM3, PWM4, PWM5, PWM6, PWM7, PWM8, PWM9, PWM10
} PwmMap_t;
*/
/*==================[external data declaration]==============================*/
/*==================[external functions declaration]=========================*/
/*
* @Brief: Initializes the pwm peripheral.
* @param none
* @return nothing
*/
void pwmConfig(void);
/*
* @brief: adds pwm to the the list of working pwms
* @param: pwmNumber: ID of the pwm, from 0 to 10
* @return: True if pwm was successfully attached, False if not.
*/
bool_t pwmAttach( uint8_t pwmNumber);
/*
* @brief: removes pwm (attached to pwmNumber) from the list
* @param: pwmNumber: ID of the pwm, from 0 to 10
* @return: True if pwm was successfully detached, False if not.
*/
bool_t pwmDetach( uint8_t pwmNumber );
/*
* @brief: change the value of the pwm at the selected pin
* @param: pwmNumber: ID of the pwm, from 0 to 10
* @param: value: 8bit value, from 0 to 255
* @return: True if the value was successfully changed, False if not.
*/
bool_t pwmWrite( uint8_t pwmNumber, uint8_t percent );
/*
* @brief: read the value of the pwm in the pin
* @param: pwmNumber: ID of the pwm, from 0 to 10
* @return: value of the pwm in the pin (0 ~ 255).
* If an error ocurred, return = EMPTY_POSITION = 255
*/
uint8_t pwmRead( uint8_t pwmNumber );
/*
* @brief: Tells if the pwm is currently active, and its position
* @param: pwmNumber: ID of the pwm, from 0 to 10
* @return: position (1 ~ PWM_TOTALNUMBER), 0 if the element was not found.
*/
uint8_t pwmIsAttached( uint8_t pwmNumber );
/*==================[cplusplus]==============================================*/
#ifdef __cplusplus
}
#endif
/*==================[end of file]============================================*/
#endif /* PWM_DRIVER_H_ */
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE121_Stack_Based_Buffer_Overflow__CWE193_char_declare_loop_02.c
Label Definition File: CWE121_Stack_Based_Buffer_Overflow__CWE193.label.xml
Template File: sources-sink-02.tmpl.c
*/
/*
* @description
* CWE: 121 Stack Based Buffer Overflow
* BadSource: Point data to a buffer that does not have space for a NULL terminator
* GoodSource: Point data to a buffer that includes space for a NULL terminator
* Sink: loop
* BadSink : Copy array to data using a loop
* Flow Variant: 02 Control flow: if(1) and if(0)
*
* */
#include "std_testcase.h"
#ifndef _WIN32
#include <wchar.h>
#endif
/* MAINTENANCE NOTE: The length of this string should equal the 10 */
#define SRC_STRING "AAAAAAAAAA"
#ifndef OMITBAD
void CWE121_Stack_Based_Buffer_Overflow__CWE193_char_declare_loop_02_bad()
{
char * data;
char dataBadBuffer[10];
char dataGoodBuffer[10+1];
if(1)
{
/* FLAW: Set a pointer to a buffer that does not leave room for a NULL terminator when performing
* string copies in the sinks */
data = dataBadBuffer;
data[0] = '\0'; /* null terminate */
}
{
char source[10+1] = SRC_STRING;
size_t i, sourceLen;
sourceLen = strlen(source);
/* Copy length + 1 to include NUL terminator from source */
/* POTENTIAL FLAW: data may not have enough space to hold source */
for (i = 0; i < sourceLen + 1; i++)
{
data[i] = source[i];
}
printLine(data);
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B1() - use goodsource and badsink by changing the 1 to 0 */
static void goodG2B1()
{
char * data;
char dataBadBuffer[10];
char dataGoodBuffer[10+1];
if(0)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
/* FIX: Set a pointer to a buffer that leaves room for a NULL terminator when performing
* string copies in the sinks */
data = dataGoodBuffer;
data[0] = '\0'; /* null terminate */
}
{
char source[10+1] = SRC_STRING;
size_t i, sourceLen;
sourceLen = strlen(source);
/* Copy length + 1 to include NUL terminator from source */
/* POTENTIAL FLAW: data may not have enough space to hold source */
for (i = 0; i < sourceLen + 1; i++)
{
data[i] = source[i];
}
printLine(data);
}
}
/* goodG2B2() - use goodsource and badsink by reversing the blocks in the if statement */
static void goodG2B2()
{
char * data;
char dataBadBuffer[10];
char dataGoodBuffer[10+1];
if(1)
{
/* FIX: Set a pointer to a buffer that leaves room for a NULL terminator when performing
* string copies in the sinks */
data = dataGoodBuffer;
data[0] = '\0'; /* null terminate */
}
{
char source[10+1] = SRC_STRING;
size_t i, sourceLen;
sourceLen = strlen(source);
/* Copy length + 1 to include NUL terminator from source */
/* POTENTIAL FLAW: data may not have enough space to hold source */
for (i = 0; i < sourceLen + 1; i++)
{
data[i] = source[i];
}
printLine(data);
}
}
void CWE121_Stack_Based_Buffer_Overflow__CWE193_char_declare_loop_02_good()
{
goodG2B1();
goodG2B2();
}
#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()...");
CWE121_Stack_Based_Buffer_Overflow__CWE193_char_declare_loop_02_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE121_Stack_Based_Buffer_Overflow__CWE193_char_declare_loop_02_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE511_Logic_Time_Bomb__time_02.c
Label Definition File: CWE511_Logic_Time_Bomb.label.xml
Template File: point-flaw-02.tmpl.c
*/
/*
* @description
* CWE: 511 Logic Time Bomb
* Sinks: time
* GoodSink: After a certain date, do something harmless
* BadSink : After a certain date, do something bad
* Flow Variant: 02 Control flow: if(1) and if(0)
*
* */
#include "std_testcase.h"
#ifdef _WIN32
#define UNLINK _unlink
#else
#include <unistd.h>
#define UNLINK unlink
#endif
#include <time.h>
#define TIME_CHECK ((time_t)1199163600) /* Jan 1, 2008 12:00:00 AM */
#ifndef OMITBAD
void CWE511_Logic_Time_Bomb__time_02_bad()
{
if(1)
{
{
time_t currentTime;
/* FLAW: After a certain date, delete a file */
time(¤tTime);
if (currentTime > TIME_CHECK)
{
UNLINK("important_file.txt");
}
}
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* good1() uses if(0) instead of if(1) */
static void good1()
{
if(0)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
{
time_t currentTime;
/* FIX: After a certain date, print to the console */
time(¤tTime);
if (currentTime > TIME_CHECK)
{
printLine("Happy New Year!");
}
}
}
}
/* good2() reverses the bodies in the if statement */
static void good2()
{
if(1)
{
{
time_t currentTime;
/* FIX: After a certain date, print to the console */
time(¤tTime);
if (currentTime > TIME_CHECK)
{
printLine("Happy New Year!");
}
}
}
}
void CWE511_Logic_Time_Bomb__time_02_good()
{
good1();
good2();
}
#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()...");
CWE511_Logic_Time_Bomb__time_02_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE511_Logic_Time_Bomb__time_02_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
#include <stdio.h>
#include <ctype.h>
#include "cmump.h"
#undef DEBUG
m_in(MINT *a, int b, FILE *f)
{
return m_in_b(a,b,f,1);
}
m_in_b(MINT *a, int b, FILE *f, int blanks)
{
MINT y, base;
int sign, c, dectop, alphatop;
short qy;
int flag;
mset(0,a);
sign = 1;
MSET(b,&base);
y.len = 1;
y.val = &qy;
flag = 0;
dectop = (b <= 10) ? '0' + b - 1 : '9';
if (b > 10) alphatop = 'a' + b - 10;
while ((c=getc(f)) != EOF) switch(c) {
case '\\':
if (getc(f) == EOF) goto end;
continue;
case ' ':
case '\t':
if (blanks) continue;
/* else fall through */
case '\n':
if (flag) {
a->len *= sign;
return 0;
}
continue;
case '-':
sign = -sign;
continue;
default:
if (isupper(c)) c = c - 'A' + 'a';
if (c >= '0' && c <= dectop) {
qy = c - '0';
mmult(a,&base,a);
if (qy != 0) madd(a,&y,a);
flag = 1;
continue;
} if (b > 10 && (c >= 'a' && c <= alphatop)) {
qy = c - 'a' + 10;
mmult(a,&base,a);
madd(a,&y,a);
flag = 1;
continue;
} else {
(void) ungetc(c,stdin);
a->len *= sign;
return 0;
}
}
end:
return EOF;
}
/* pre: n > 0; out: integer part of base 2 log of n */
static int slog(int n)
{
int i = 0;
while (n >>= 1) ++i;
return i;
}
m_out(MINT *a, int b, FILE *f)
{
m_out_b(a,b,f,0);
}
void m_out_b(MINT *a, int b, FILE *f, int blanks)
{
int sign, i;
short r;
MINT x;
char *obuf;
register char *bp;
int regionsize;
if (b < 2) return;
MINIT (&x);
mcopy(a,&x);
if (mtest(&x) == 0) { fprintf(f,"0"); return; }
else if (mtest(&x) > 0) sign = 1;
else {mnegate(&x); sign = -1;}
regionsize = slog(b);
regionsize = ((8 * sizeof(short) - 1) * x.len + (regionsize - 1)) / regionsize;
/* round up */
if (blanks) regionsize += regionsize/10;
/* a blank every 10 digits */
regionsize += 2;
/* null and opt sign */
#ifdef DEBUG
fprintf(stderr,"ALLOCATING: regionsize = %d\n",regionsize);
#endif
if ((obuf = (char*)galloc((unsigned) (regionsize))) == 0) valerr();
bp = obuf + regionsize - 1;
*bp--=0; /* sentinel */
while (mtest(&x) > 0) {
for (i = 0; i<10 && mtest(&x) > 0; i++) {
sdiv(&x,b,&x,&r);
if (r < 10) *bp-- = r + '0';
else *bp-- = r - 10+'A';
}
if (blanks && mtest(&x) > 0) *bp--=' ';
}
if (sign == -1) *bp--='-';
#ifdef DEBUG
fprintf(stderr,"OUTPUTSTRINGSIZE: %d\n",strlen(bp+1));
#endif
fprintf(f,"%s",bp+1);
gfree(obuf);
MFREE(&x);
}
// pmr: added return type
void sdiv (MINT *a, int n, MINT *q, short int *r)
{
register qlen,i,x,y;
register short *aval, *qval;
int neg;
qlen = a->len;
if (qlen == 0) {mset(0,q); *r = 0; return;}
if (qlen > 0) neg = 0;
else { qlen = -qlen; neg = 1;}
if (n < 0) {n = -n; neg = 1 - neg;}
aval = a->val;
valloc(qval,qlen);
x = 0;
for (i=qlen; (--i)>=0;) {
x <<= 15;
x += aval[i];
qval[i] = y = x/n;
x -= y*n;
}
if (qval[qlen-1] == 0) qlen--;
MFREE (q);
if (qlen==0) vfree(qval);
else q->val = qval;
if (neg) {qlen = -qlen; x = -x;}
q->len = qlen;
*r = x;
}
/* simple routines */
int min(MINT *a) {
return m_in(a,10,stdin);
}
omin(MINT *a) {
return m_in(a,8,stdin);
}
void mout(MINT *a) {
m_out(a,10,stdout);
}
omout(MINT *a) {
m_out(a,8,stdout);
}
hexmout(MINT *a) {
m_out(a,16,stdout);
}
fmout(MINT *a, FILE *f) {
m_out(a,10,f);
}
hexmin(MINT *a) {
return m_in(a,16,stdin);
}
fmin(MINT *a, FILE *f) {
return m_in(a,10,f);
}
/*
* HISTORY
*
* 22-Jan-87 Bennet Yee (byee) at Carnegie-Mellon University
* Modified m_in and m_out to handle arbitrary bases.
* Added hexmin, m_in_b, and m_out_b.
*
* 18-May-84 Lyle McGeoch (magoo) at Carnegie-Mellon University
* Created from code in existing mp package. *
* Debugged, cleaned up, and sped up. *
*/
void Sm_out_b(char *s, MINT *a, int b, int blanks)
{
int sign, i;
short r;
MINT x;
char *obuf;
register char *bp;
int regionsize;
if (b < 2) return;
MINIT (&x);
mcopy(a,&x);
if (mtest(&x) == 0) { sprintf(s+strlen(s),"0"); return; }
else if (mtest(&x) > 0) sign = 1;
else {mnegate(&x); sign = -1;}
regionsize = slog(b);
regionsize = ((8 * sizeof(short) - 1) * x.len + (regionsize - 1)) / regionsize;
/* round up */
if (blanks) regionsize += regionsize/10;
/* a blank every 10 digits */
regionsize += 2;
/* null and opt sign */
#ifdef DEBUG
fprintf(stderr,"ALLOCATING: regionsize = %d\n",regionsize);
#endif
if ((obuf = (char*)galloc((unsigned) (regionsize))) == 0) valerr();
bp = obuf + regionsize - 1;
*bp--=0; /* sentinel */
while (mtest(&x) > 0) {
for (i = 0; i<10 && mtest(&x) > 0; i++) {
sdiv(&x,b,&x,&r);
if (r < 10) *bp-- = r + '0';
else *bp-- = r - 10+'A';
}
if (blanks && mtest(&x) > 0) *bp--=' ';
}
if (sign == -1) *bp--='-';
#ifdef DEBUG
fprintf(stderr,"OUTPUTSTRINGSIZE: %d\n",strlen(bp+1));
#endif
sprintf(s+strlen(s),"%s",bp+1);
gfree(obuf);
MFREE(&x);
}
Sm_out(char *s, MINT *a, int b)
{
Sm_out_b(s,a,b,0);
}
void Smout(char *s, MINT *a) {
Sm_out(s,a,10);
}
|
//$Id: GroupManager.h,v 1.1.1.1 2007/11/05 19:09:10 jpolastre Exp $
#ifndef __GROUPMANAGER_H__
#define __GROUPMANAGER_H__
/* tab:4
* "Copyright (c) 2000-2005 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*/
/**
* @author Gilman Tolle <get@cs.berkeley.edu>
*/
enum {
GROUPMANAGER_MAX_GROUPS = 4,
GROUPMANAGER_INVALID_GROUP = 0,
};
#endif
|
// Copyright 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 CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_
#define CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_
#include <memory>
#include "base/cancelable_callback.h"
#include "base/memory/weak_ptr.h"
#include "base/time/time.h"
#include "cc/cc_export.h"
#include "cc/input/single_scrollbar_animation_controller_thinning.h"
#include "cc/layers/layer_impl.h"
#include "cc/layers/scrollbar_layer_impl_base.h"
#include "ui/gfx/geometry/vector2d_f.h"
namespace cc {
class CC_EXPORT ScrollbarAnimationControllerClient {
public:
virtual void PostDelayedScrollbarAnimationTask(base::OnceClosure task,
base::TimeDelta delay) = 0;
virtual void SetNeedsRedrawForScrollbarAnimation() = 0;
virtual void SetNeedsAnimateForScrollbarAnimation() = 0;
virtual void DidChangeScrollbarVisibility() = 0;
virtual ScrollbarSet ScrollbarsFor(ElementId scroll_element_id) const = 0;
protected:
virtual ~ScrollbarAnimationControllerClient() {}
};
// This class show scrollbars when scroll and fade out after an idle delay.
// The fade animations works on both scrollbars and is controlled in this class
// This class also passes the mouse state to each
// SingleScrollbarAnimationControllerThinning. The thinning animations are
// independent between vertical/horizontal and are managed by the
// SingleScrollbarAnimationControllerThinnings.
class CC_EXPORT ScrollbarAnimationController {
public:
// ScrollbarAnimationController for Android. It only has show & fade out
// animation.
static std::unique_ptr<ScrollbarAnimationController>
CreateScrollbarAnimationControllerAndroid(
ElementId scroll_element_id,
ScrollbarAnimationControllerClient* client,
base::TimeDelta fade_delay,
base::TimeDelta fade_duration,
float initial_opacity);
// ScrollbarAnimationController for Desktop Overlay Scrollbar. It has show &
// fade out animation and thinning animation.
static std::unique_ptr<ScrollbarAnimationController>
CreateScrollbarAnimationControllerAuraOverlay(
ElementId scroll_element_id,
ScrollbarAnimationControllerClient* client,
base::TimeDelta fade_delay,
base::TimeDelta fade_duration,
base::TimeDelta thinning_duration,
float initial_opacity);
~ScrollbarAnimationController();
bool ScrollbarsHidden() const;
bool Animate(base::TimeTicks now);
// WillUpdateScroll expects to be called even if the scroll position won't
// change as a result of the scroll. Only effect Aura Overlay Scrollbar.
void WillUpdateScroll();
// DidScrollUpdate expects to be called only if the scroll position change.
// Effect both Android and Aura Overlay Scrollbar.
void DidScrollUpdate();
void DidMouseDown();
void DidMouseUp();
void DidMouseLeave();
void DidMouseMove(const gfx::PointF& device_viewport_point);
// Called when we want to show the scrollbars.
void DidRequestShow();
void UpdateTickmarksVisibility(bool show);
// These methods are public for testing.
bool MouseIsOverScrollbarThumb(ScrollbarOrientation orientation) const;
bool MouseIsNearScrollbarThumb(ScrollbarOrientation orientation) const;
bool MouseIsNearScrollbar(ScrollbarOrientation orientation) const;
bool MouseIsNearAnyScrollbar() const;
ScrollbarSet Scrollbars() const;
static constexpr float kMouseMoveDistanceToTriggerFadeIn = 30.0f;
private:
// Describes whether the current animation should FadeIn or FadeOut.
enum class AnimationChange { NONE, FADE_IN, FADE_OUT };
ScrollbarAnimationController(ElementId scroll_element_id,
ScrollbarAnimationControllerClient* client,
base::TimeDelta fade_delay,
base::TimeDelta fade_duration,
float initial_opacity);
ScrollbarAnimationController(ElementId scroll_element_id,
ScrollbarAnimationControllerClient* client,
base::TimeDelta fade_delay,
base::TimeDelta fade_duration,
base::TimeDelta thinning_duration,
float initial_opacity);
SingleScrollbarAnimationControllerThinning& GetScrollbarAnimationController(
ScrollbarOrientation) const;
// Any scrollbar state update would show scrollbar hen post the delay fade out
// if needed.
void UpdateScrollbarState();
// Returns how far through the animation we are as a progress value from
// 0 to 1.
float AnimationProgressAtTime(base::TimeTicks now);
void RunAnimationFrame(float progress);
void StartAnimation();
void StopAnimation();
void Show();
void PostDelayedAnimation(AnimationChange animation_change);
bool Captured() const;
void ApplyOpacityToScrollbars(float opacity);
ScrollbarAnimationControllerClient* client_;
base::TimeTicks last_awaken_time_;
base::TimeDelta fade_delay_;
base::TimeDelta fade_duration_;
bool need_trigger_scrollbar_fade_in_;
bool is_animating_;
AnimationChange animation_change_;
const ElementId scroll_element_id_;
base::CancelableOnceClosure delayed_scrollbar_animation_;
float opacity_;
const bool show_scrollbars_on_scroll_gesture_;
const bool need_thinning_animation_;
bool is_mouse_down_;
bool tickmarks_showing_;
std::unique_ptr<SingleScrollbarAnimationControllerThinning>
vertical_controller_;
std::unique_ptr<SingleScrollbarAnimationControllerThinning>
horizontal_controller_;
base::WeakPtrFactory<ScrollbarAnimationController> weak_factory_{this};
};
} // namespace cc
#endif // CC_INPUT_SCROLLBAR_ANIMATION_CONTROLLER_H_
|
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_METRICS_PUBLIC_CPP_UKM_SOURCE_H_
#define SERVICES_METRICS_PUBLIC_CPP_UKM_SOURCE_H_
#include <map>
#include <vector>
#include "base/macros.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "services/metrics/public/cpp/metrics_export.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "url/gurl.h"
namespace ukm {
class Source;
// Contains UKM URL data for a single source id.
class METRICS_EXPORT UkmSource {
public:
enum CustomTabState {
kCustomTabUnset,
kCustomTabTrue,
kCustomTabFalse,
};
// Extra navigation data associated with a particular Source. Currently, all
// of these members except |url| are only set for navigation id sources.
//
// Note: If adding more members to this class, make sure you update
// CopyWithSanitizedUrls.
struct METRICS_EXPORT NavigationData {
NavigationData();
~NavigationData();
NavigationData(const NavigationData& other);
// Creates a copy of this struct, replacing the URL members with sanitized
// versions. Currently, |sanitized_urls| expects a one or two element
// vector. The last element in the vector will always be the final URL in
// the redirect chain. For two-element vectors, the first URL is assumed to
// be the first URL in the redirect chain. The URLs in |sanitized_urls| are
// expected to be non-empty.
NavigationData CopyWithSanitizedUrls(
std::vector<GURL> sanitized_urls) const;
// The URLs associated with this sources navigation. Some notes:
// - This will always contain at least one element.
// - For non navigation sources, this will contain exactly one element.
// - For navigation sources, this will only contain at most two elements,
// one for the first URL in the redirect chain and one for the final URL
// that committed.
// TODO(crbug.com/869123): This may end up containing all the URLs in the
// redirect chain for navigation sources.
std::vector<GURL> urls;
// The previous source id for this tab.
SourceId previous_source_id = kInvalidSourceId;
// The source id for the previous same document navigation, if the
// previously committed source was a same document navigation. If
// the previously committed source was not a same document
// navigation, this field will be set to kInvalidSourceId.
SourceId previous_same_document_source_id = kInvalidSourceId;
// The source id for the source which opened this tab. This should be set to
// kInvalidSourceId for all but the first navigation in the tab.
SourceId opener_source_id = kInvalidSourceId;
// A unique identifier for the tab the source navigated in. Tab ids should
// be increasing over time within a session.
int64_t tab_id = 0;
// Whether this source is for a same document navigation. Examples of same
// document navigations are fragment navigations, pushState/replaceState,
// and same page history navigation.
bool is_same_document_navigation = false;
// Represents the same origin status of the navigation compared to the
// previous document.
enum SameOriginStatus {
UNSET = 0,
SAME_ORIGIN,
CROSS_ORIGIN,
};
// Whether this is the same origin as the previous document.
//
// This is set to the NavigationHandle's same origin state when the
// navigation is committed, is not a same document navigation and is not
// committed as an error page. Otherwise, this remains unset.
SameOriginStatus same_origin_status = SameOriginStatus::UNSET;
// Whether this navigation is initiated by the renderer.
bool is_renderer_initiated = false;
// Whether the navigation committed an error page.
bool is_error_page = false;
// The navigation start time relative to session start. The navigation
// time within session should be monotonically increasing.
absl::optional<base::TimeTicks> navigation_time;
};
UkmSource(SourceId id, const GURL& url);
UkmSource(SourceId id, const NavigationData& data);
UkmSource(const UkmSource&) = delete;
UkmSource& operator=(const UkmSource&) = delete;
~UkmSource();
ukm::SourceId id() const { return id_; }
const GURL& url() const { return navigation_data_.urls.back(); }
const std::vector<GURL>& urls() const { return navigation_data_.urls; }
const NavigationData& navigation_data() const { return navigation_data_; }
// The object creation time. This is for internal purposes only and is not
// intended to be anything useful for UKM clients.
const base::TimeTicks creation_time() const { return creation_time_; }
// Records a new URL for this source.
void UpdateUrl(const GURL& url);
// Serializes the members of the class into the supplied proto.
void PopulateProto(Source* proto_source) const;
// Sets the current "custom tab" state. This can be called from any thread.
static void SetCustomTabVisible(bool visible);
// Sets the current "android_activity_type" state, this will replace the
// "custom tab" state.
static void SetAndroidActivityTypeState(int32_t android_activity_type);
private:
const ukm::SourceId id_;
const ukm::SourceIdType type_;
NavigationData navigation_data_;
// A flag indicating if metric was collected in a custom tab. This is set
// automatically when the object is created and so represents the state when
// the metric was created.
// TODO(crbug/1228735): To be replaced by |android_activity_type_state_|.
const CustomTabState custom_tab_state_;
const int32_t android_activity_type_state_ = -1;
// When this object was created.
const base::TimeTicks creation_time_;
};
} // namespace ukm
#endif // SERVICES_METRICS_PUBLIC_CPP_UKM_SOURCE_H_
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE124_Buffer_Underwrite__char_alloca_memcpy_68a.c
Label Definition File: CWE124_Buffer_Underwrite.stack.label.xml
Template File: sources-sink-68a.tmpl.c
*/
/*
* @description
* CWE: 124 Buffer Underwrite
* BadSource: Set data pointer to before the allocated memory buffer
* GoodSource: Set data pointer to the allocated memory buffer
* Sink: memcpy
* BadSink : Copy string to data using memcpy
* Flow Variant: 68 Data flow: data passed as a global variable from one function to another in different source files
*
* */
#include "std_testcase.h"
#include <wchar.h>
char * CWE124_Buffer_Underwrite__char_alloca_memcpy_68_badData;
char * CWE124_Buffer_Underwrite__char_alloca_memcpy_68_goodG2BData;
#ifndef OMITBAD
/* bad function declaration */
void CWE124_Buffer_Underwrite__char_alloca_memcpy_68b_badSink();
void CWE124_Buffer_Underwrite__char_alloca_memcpy_68_bad()
{
char * data;
char * dataBuffer = (char *)ALLOCA(100*sizeof(char));
memset(dataBuffer, 'A', 100-1);
dataBuffer[100-1] = '\0';
/* FLAW: Set data pointer to before the allocated memory buffer */
data = dataBuffer - 8;
CWE124_Buffer_Underwrite__char_alloca_memcpy_68_badData = data;
CWE124_Buffer_Underwrite__char_alloca_memcpy_68b_badSink();
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* good function declarations */
void CWE124_Buffer_Underwrite__char_alloca_memcpy_68b_goodG2BSink();
/* goodG2B uses the GoodSource with the BadSink */
static void goodG2B()
{
char * data;
char * dataBuffer = (char *)ALLOCA(100*sizeof(char));
memset(dataBuffer, 'A', 100-1);
dataBuffer[100-1] = '\0';
/* FIX: Set data pointer to the allocated memory buffer */
data = dataBuffer;
CWE124_Buffer_Underwrite__char_alloca_memcpy_68_goodG2BData = data;
CWE124_Buffer_Underwrite__char_alloca_memcpy_68b_goodG2BSink();
}
void CWE124_Buffer_Underwrite__char_alloca_memcpy_68_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()...");
CWE124_Buffer_Underwrite__char_alloca_memcpy_68_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE124_Buffer_Underwrite__char_alloca_memcpy_68_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
/****************************************************************************
** Copyright (c) 2006 - 2011, the LibQxt project.
** See the Qxt AUTHORS file for a list of authors and copyright holders.
** 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 LibQxt 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 <COPYRIGHT HOLDER> 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.
**
** <http://libqxt.org> <foundation@libqxt.org>
*****************************************************************************/
#ifndef QXTPAIRLIST_H
#define QXTPAIRLIST_H
/*!
\class QxtPairList QxtPairList
\ingroup kit
\brief Searchable List of Pairs
Pair list provides a list with two values, a bit like QHash, but with the possibility to operate on both values.
in contrast to QHash, every entry has a unique id, you can work with. like a QList.
\code
QxtPairList<int,int> list;
list.append(1,2);
list.append(1,5);
list.append(5,6);
qDebug()<< list.find(1); // "0,1"
qDebug()<< list.find(SKIP,5); // "2"
qDebug()<< list.find(5); // "2"
\endcode
you may allso play around with the list itself
\code
list.list.append(qMakePair(1,2));
\endcode
*/
#include <QList>
#include <QPair>
#include <QxtNullable>
#include <qxtglobal.h>
template <typename T, typename K>
class QXT_CORE_EXPORT QxtPairList
{
public:
QxtPairList()
{}
QxtPairList(const QxtPairList<T, K> & other)
{
list = other.list;
}
QxtPairList operator= (const QxtPairList<T, K> & other)
{
list = other.list;
}
void append(T v1, K v2)
{
list.append(qMakePair(v1, v2));
}
/*! \brief search entries by match
both arguments are optional, due to the use of QxtNullable
\code
find(SKIP,v2);
find(v1,SKIP);
find(v1);
\endcode
are all valid
*/
QList<int> find(qxtNull(T, v1) , qxtNull(K, v2))
{
QList<int> found;
if ((!v1.isNull()) and(!v2.isNull()))
{
for (int i = 0;i < list.count();i++)
if ((list[i].first() == v1)and(list[i].second() == v2))
found.append(i);
return found;
}
if ((!v1.isNull()) and(v2.isNull()))
{
for (int i = 0;i < list.count();i++)
if (list[i].first() == v1)
found.append(i);
return found;
}
if ((v1.isNull()) and(!v2.isNull()))
{
for (int i = 0;i < list.count();i++)
if (list[i].second() == v2)
found.append(i);
return found;
}
}
///remove an entries position by position
void remove(int nr)
{
list.removeAt(nr);
}
///remove a list of entries by position
void remove(QList<int> nrs)
{
int i;
Q_FOREACH(i, nrs)
list.removeAt(i);
}
/*! \brief operate on the list directly
you may use the internal list directly, but be carefull
don't expect to work the QxPairList to work normal if you mess around with it.
*/
QList<QPair<T, K> > list;
};
#endif // QXTPAIRLIST_H
|
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef EXTENSIONS_BROWSER_UPDATER_EXTENSION_INSTALLER_H_
#define EXTENSIONS_BROWSER_UPDATER_EXTENSION_INSTALLER_H_
#include <memory>
#include <string>
#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/macros.h"
#include "components/update_client/update_client.h"
namespace extensions {
// This class is used as a shim between the components::update_client and
// extensions code, to help the generic update_client code prepare and then
// install an updated version of an extension. Because the update_client code
// doesn't have the notion of extension ids, we use instances of this class to
// map an install request back to the original update check for a given
// extension.
class ExtensionInstaller : public update_client::CrxInstaller {
public:
using UpdateClientCallback = update_client::CrxInstaller::Callback;
// A callback to implement the install of a new version of the extension.
// Takes ownership of the directory at |unpacked_dir|.
using ExtensionInstallerCallback = base::RepeatingCallback<void(
const std::string& extension_id,
const std::string& public_key,
const base::FilePath& unpacked_dir,
bool install_immediately,
UpdateClientCallback update_client_callback)>;
// This method takes the id and root directory for an extension we're doing
// an update check for, as well as a callback to call if we get a new version
// of it to install.
ExtensionInstaller(std::string extension_id,
const base::FilePath& extension_root,
bool install_immediately,
ExtensionInstallerCallback extension_installer_callback);
ExtensionInstaller(const ExtensionInstaller&) = delete;
ExtensionInstaller& operator=(const ExtensionInstaller&) = delete;
// update_client::CrxInstaller::
void OnUpdateError(int error) override;
// This function is executed by the component update client, which runs on a
// blocking thread with background priority.
// |update_client_callback| is expected to be called on a UI thread.
void Install(const base::FilePath& unpack_path,
const std::string& public_key,
std::unique_ptr<InstallParams> install_params,
ProgressCallback progress_callback,
UpdateClientCallback update_client_callback) override;
bool GetInstalledFile(const std::string& file,
base::FilePath* installed_file) override;
bool Uninstall() override;
// For unit tests.
bool install_immediately() const { return install_immediately_; }
private:
friend class base::RefCountedThreadSafe<ExtensionInstaller>;
~ExtensionInstaller() override;
std::string extension_id_;
base::FilePath extension_root_;
bool install_immediately_;
ExtensionInstallerCallback extension_installer_callback_;
};
} // namespace extensions
#endif // EXTENSIONS_BROWSER_UPDATER_EXTENSION_INSTALLER_H_
|
/*++
Copyright (c) 2007, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
AcpiCommon.h
Abstract:
This file contains some basic ACPI definitions that are consumed by drivers
that do not care about ACPI versions.
--*/
#ifndef _ACPI_COMMON_H_
#define _ACPI_COMMON_H_
#include "Tiano.h"
//
// Common table header, this prefaces all ACPI tables, including FACS, but
// excluding the RSD PTR structure
//
typedef struct {
UINT32 Signature;
UINT32 Length;
} EFI_ACPI_COMMON_HEADER;
//
// Common ACPI description table header. This structure prefaces most ACPI tables.
//
#pragma pack(1)
typedef struct {
UINT32 Signature;
UINT32 Length;
UINT8 Revision;
UINT8 Checksum;
UINT8 OemId[6];
UINT64 OemTableId;
UINT32 OemRevision;
UINT32 CreatorId;
UINT32 CreatorRevision;
} EFI_ACPI_DESCRIPTION_HEADER;
#pragma pack()
//
// Define for Pci Host Bridge Resource Allocation
//
#define ACPI_ADDRESS_SPACE_DESCRIPTOR 0x8A
#define ACPI_END_TAG_DESCRIPTOR 0x79
#define ACPI_ADDRESS_SPACE_TYPE_MEM 0x00
#define ACPI_ADDRESS_SPACE_TYPE_IO 0x01
#define ACPI_ADDRESS_SPACE_TYPE_BUS 0x02
//
// Make sure structures match spec
//
#pragma pack(1)
typedef struct {
UINT8 Desc;
UINT16 Len;
UINT8 ResType;
UINT8 GenFlag;
UINT8 SpecificFlag;
UINT64 AddrSpaceGranularity;
UINT64 AddrRangeMin;
UINT64 AddrRangeMax;
UINT64 AddrTranslationOffset;
UINT64 AddrLen;
} EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR;
typedef struct {
UINT8 Desc;
UINT8 Checksum;
} EFI_ACPI_END_TAG_DESCRIPTOR;
//
// General use definitions
//
#define EFI_ACPI_RESERVED_BYTE 0x00
#define EFI_ACPI_RESERVED_WORD 0x0000
#define EFI_ACPI_RESERVED_DWORD 0x00000000
#define EFI_ACPI_RESERVED_QWORD 0x0000000000000000
#pragma pack()
#endif
|
/*
* Copyright 2001-2010 Georges Menie (www.menie.org)
* 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 University of California, Berkeley 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 AND 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 "crc16.h"
/* CRC16 implementation acording to CCITT standards */
static const unsigned short crc16tab[256]= {
0x0000,0x1021,0x2042,0x3063,0x4084,0x50a5,0x60c6,0x70e7,
0x8108,0x9129,0xa14a,0xb16b,0xc18c,0xd1ad,0xe1ce,0xf1ef,
0x1231,0x0210,0x3273,0x2252,0x52b5,0x4294,0x72f7,0x62d6,
0x9339,0x8318,0xb37b,0xa35a,0xd3bd,0xc39c,0xf3ff,0xe3de,
0x2462,0x3443,0x0420,0x1401,0x64e6,0x74c7,0x44a4,0x5485,
0xa56a,0xb54b,0x8528,0x9509,0xe5ee,0xf5cf,0xc5ac,0xd58d,
0x3653,0x2672,0x1611,0x0630,0x76d7,0x66f6,0x5695,0x46b4,
0xb75b,0xa77a,0x9719,0x8738,0xf7df,0xe7fe,0xd79d,0xc7bc,
0x48c4,0x58e5,0x6886,0x78a7,0x0840,0x1861,0x2802,0x3823,
0xc9cc,0xd9ed,0xe98e,0xf9af,0x8948,0x9969,0xa90a,0xb92b,
0x5af5,0x4ad4,0x7ab7,0x6a96,0x1a71,0x0a50,0x3a33,0x2a12,
0xdbfd,0xcbdc,0xfbbf,0xeb9e,0x9b79,0x8b58,0xbb3b,0xab1a,
0x6ca6,0x7c87,0x4ce4,0x5cc5,0x2c22,0x3c03,0x0c60,0x1c41,
0xedae,0xfd8f,0xcdec,0xddcd,0xad2a,0xbd0b,0x8d68,0x9d49,
0x7e97,0x6eb6,0x5ed5,0x4ef4,0x3e13,0x2e32,0x1e51,0x0e70,
0xff9f,0xefbe,0xdfdd,0xcffc,0xbf1b,0xaf3a,0x9f59,0x8f78,
0x9188,0x81a9,0xb1ca,0xa1eb,0xd10c,0xc12d,0xf14e,0xe16f,
0x1080,0x00a1,0x30c2,0x20e3,0x5004,0x4025,0x7046,0x6067,
0x83b9,0x9398,0xa3fb,0xb3da,0xc33d,0xd31c,0xe37f,0xf35e,
0x02b1,0x1290,0x22f3,0x32d2,0x4235,0x5214,0x6277,0x7256,
0xb5ea,0xa5cb,0x95a8,0x8589,0xf56e,0xe54f,0xd52c,0xc50d,
0x34e2,0x24c3,0x14a0,0x0481,0x7466,0x6447,0x5424,0x4405,
0xa7db,0xb7fa,0x8799,0x97b8,0xe75f,0xf77e,0xc71d,0xd73c,
0x26d3,0x36f2,0x0691,0x16b0,0x6657,0x7676,0x4615,0x5634,
0xd94c,0xc96d,0xf90e,0xe92f,0x99c8,0x89e9,0xb98a,0xa9ab,
0x5844,0x4865,0x7806,0x6827,0x18c0,0x08e1,0x3882,0x28a3,
0xcb7d,0xdb5c,0xeb3f,0xfb1e,0x8bf9,0x9bd8,0xabbb,0xbb9a,
0x4a75,0x5a54,0x6a37,0x7a16,0x0af1,0x1ad0,0x2ab3,0x3a92,
0xfd2e,0xed0f,0xdd6c,0xcd4d,0xbdaa,0xad8b,0x9de8,0x8dc9,
0x7c26,0x6c07,0x5c64,0x4c45,0x3ca2,0x2c83,0x1ce0,0x0cc1,
0xef1f,0xff3e,0xcf5d,0xdf7c,0xaf9b,0xbfba,0x8fd9,0x9ff8,
0x6e17,0x7e36,0x4e55,0x5e74,0x2e93,0x3eb2,0x0ed1,0x1ef0
};
unsigned short crc16_ccitt(const void *buf, int len)
{
int counter;
unsigned short crc = 0;
for( counter = 0; counter < len; counter++)
{
crc = (crc<<8) ^ crc16tab[((crc>>8) ^ *(char *)buf)&0x00FF];
buf = ((char *)buf) +1;
}
return crc;
}
|
/*
* Order-1, 3D 7 point stencil
* Adapted from PLUTO and Pochoir test bench
*
* Tareq Malas
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#ifdef LIKWID_PERFMON
#include <likwid.h>
#endif
#include "print_utils.h"
#define TESTS 2
#define MAX(a,b) ((a) > (b) ? a : b)
#define MIN(a,b) ((a) < (b) ? a : b)
/* Subtract the `struct timeval' values X and Y,
* storing the result in RESULT.
*
* Return 1 if the difference is negative, otherwise 0.
*/
int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y)
{
/* Perform the carry for the later subtraction by updating y. */
if (x->tv_usec < y->tv_usec)
{
int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
y->tv_usec -= 1000000 * nsec;
y->tv_sec += nsec;
}
if (x->tv_usec - y->tv_usec > 1000000)
{
int nsec = (x->tv_usec - y->tv_usec) / 1000000;
y->tv_usec += 1000000 * nsec;
y->tv_sec -= nsec;
}
/* Compute the time remaining to wait.
* tv_usec is certainly positive.
*/
result->tv_sec = x->tv_sec - y->tv_sec;
result->tv_usec = x->tv_usec - y->tv_usec;
/* Return 1 if result is negative. */
return x->tv_sec < y->tv_sec;
}
int main(int argc, char *argv[])
{
int t, i, j, k, test;
int Nx, Ny, Nz, Nt;
if (argc > 3) {
Nx = atoi(argv[1])+2;
Ny = atoi(argv[2])+2;
Nz = atoi(argv[3])+2;
}
if (argc > 4)
Nt = atoi(argv[4]);
double ****A = (double ****) malloc(sizeof(double***)*2);
A[0] = (double ***) malloc(sizeof(double**)*Nz);
A[1] = (double ***) malloc(sizeof(double**)*Nz);
for(i=0; i<Nz; i++){
A[0][i] = (double**) malloc(sizeof(double*)*Ny);
A[1][i] = (double**) malloc(sizeof(double*)*Ny);
for(j=0;j<Ny;j++){
A[0][i][j] = (double*) malloc(sizeof(double)*Nx);
A[1][i][j] = (double*) malloc(sizeof(double)*Nx);
}
}
// tile size information, including extra element to decide the list length
int *tile_size = (int*) malloc(sizeof(int));
tile_size[0] = -1;
// The list is modified here before source-to-source transformations
tile_size = (int*) realloc((void *)tile_size, sizeof(int)*5);
tile_size[0] = 16;
tile_size[1] = 16;
tile_size[2] = 16;
tile_size[3] = 32;
tile_size[4] = -1;
// for timekeeping
int ts_return = -1;
struct timeval start, end, result;
double tdiff = 0.0, min_tdiff=1.e100;
const int BASE = 1024;
const double alpha = 0.0876;
const double beta = 0.0765;
// initialize variables
//
srand(42);
for (i = 1; i < Nz; i++) {
for (j = 1; j < Ny; j++) {
for (k = 1; k < Nx; k++) {
A[0][i][j][k] = 1.0 * (rand() % BASE);
}
}
}
#ifdef LIKWID_PERFMON
LIKWID_MARKER_INIT;
#pragma omp parallel
{
LIKWID_MARKER_THREADINIT;
#pragma omp barrier
LIKWID_MARKER_START("calc");
}
#endif
int num_threads = 1;
#if defined(_OPENMP)
num_threads = omp_get_max_threads();
#endif
for(test=0; test<TESTS; test++){
gettimeofday(&start, 0);
// serial execution - Addition: 6 && Multiplication: 2
#pragma scop
for (t = 0; t < Nt-1; t++) {
for (i = 1; i < Nz-1; i++) {
for (j = 1; j < Ny-1; j++) {
for (k = 1; k < Nx-1; k++) {
A[(t+1)%2][i][j][k] = alpha * (A[t%2][i][j][k])
+ beta * (A[t%2][i - 1][j][k] + A[t%2][i][j - 1][k] + A[t%2][i][j][k - 1] +
A[t%2][i + 1][j][k] + A[t%2][i][j + 1][k] + A[t%2][i][j][k + 1]);
}
}
}
}
#pragma endscop
gettimeofday(&end, 0);
ts_return = timeval_subtract(&result, &end, &start);
tdiff = (double) (result.tv_sec + result.tv_usec * 1.0e-6);
min_tdiff = min(min_tdiff, tdiff);
printf("Rank 0 TEST# %d time: %f\n", test, tdiff);
}
PRINT_RESULTS(1, "constant")
#ifdef LIKWID_PERFMON
#pragma omp parallel
{
LIKWID_MARKER_STOP("calc");
}
LIKWID_MARKER_CLOSE;
#endif
// Free allocated arrays (Causing performance degradation
/* for(i=0; i<Nz; i++){
for(j=0;j<Ny;j++){
free(A[0][i][j]);
free(A[1][i][j]);
}
free(A[0][i]);
free(A[1][i]);
}
free(A[0]);
free(A[1]);
*/
return 0;
}
|
/* -*- buffer-read-only: t -*- vi: set ro: */
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Test of <signal.h> substitute.
Copyright (C) 2009-2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Written by Eric Blake <ebb9@byu.net>, 2009. */
#include <config.h>
#include <signal.h>
/* Check for required types. */
struct
{
size_t a;
uid_t b;
volatile sig_atomic_t c;
sigset_t d;
pid_t e;
#if 0
/* Not guaranteed by gnulib. */
pthread_t f;
struct timespec g;
#endif
} s;
/* Check that NSIG is defined. */
int nsig = NSIG;
int
main (void)
{
switch (0)
{
/* The following are guaranteed by C. */
case 0:
case SIGABRT:
case SIGFPE:
case SIGILL:
case SIGINT:
case SIGSEGV:
case SIGTERM:
/* The following is guaranteed by gnulib. */
#if GNULIB_SIGPIPE || defined SIGPIPE
case SIGPIPE:
#endif
/* Ensure no conflict with other standardized names. */
#ifdef SIGALRM
case SIGALRM:
#endif
#ifdef SIGBUS
case SIGBUS:
#endif
#ifdef SIGCHLD
case SIGCHLD:
#endif
#ifdef SIGCONT
case SIGCONT:
#endif
#ifdef SIGHUP
case SIGHUP:
#endif
#ifdef SIGKILL
case SIGKILL:
#endif
#ifdef SIGQUIT
case SIGQUIT:
#endif
#ifdef SIGSTOP
case SIGSTOP:
#endif
#ifdef SIGTSTP
case SIGTSTP:
#endif
#ifdef SIGTTIN
case SIGTTIN:
#endif
#ifdef SIGTTOU
case SIGTTOU:
#endif
#ifdef SIGUSR1
case SIGUSR1:
#endif
#ifdef SIGUSR2
case SIGUSR2:
#endif
#ifdef SIGSYS
case SIGSYS:
#endif
#ifdef SIGTRAP
case SIGTRAP:
#endif
#ifdef SIGURG
case SIGURG:
#endif
#ifdef SIGVTALRM
case SIGVTALRM:
#endif
#ifdef SIGXCPU
case SIGXCPU:
#endif
#ifdef SIGXFSZ
case SIGXFSZ:
#endif
/* SIGRTMIN and SIGRTMAX need not be compile-time constants. */
#if 0
# ifdef SIGRTMIN
case SIGRTMIN:
# endif
# ifdef SIGRTMAX
case SIGRTMAX:
# endif
#endif
;
}
return s.a + s.b + s.c + s.e;
}
|
// Copyright 2018 The Flutter 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 FLUTTER_FLUTTEROBSERVATORYPUBLISHER_H_
#define FLUTTER_FLUTTEROBSERVATORYPUBLISHER_H_
#import <Foundation/Foundation.h>
@interface FlutterObservatoryPublisher : NSObject
@end
#endif // FLUTTER_FLUTTEROBSERVATORYPUBLISHER_H_
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE127_Buffer_Underread__malloc_char_memcpy_54c.c
Label Definition File: CWE127_Buffer_Underread__malloc.label.xml
Template File: sources-sink-54c.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
* Sink: memcpy
* BadSink : Copy data to string using memcpy
* Flow Variant: 54 Data flow: data passed as an argument from one function through three others to a fifth; all five functions are in different source files
*
* */
#include "std_testcase.h"
#include <wchar.h>
/* all the sinks are the same, we just want to know where the hit originated if a tool flags one */
#ifndef OMITBAD
/* bad function declaration */
void CWE127_Buffer_Underread__malloc_char_memcpy_54d_badSink(char * data);
void CWE127_Buffer_Underread__malloc_char_memcpy_54c_badSink(char * data)
{
CWE127_Buffer_Underread__malloc_char_memcpy_54d_badSink(data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* good function declaration */
void CWE127_Buffer_Underread__malloc_char_memcpy_54d_goodG2BSink(char * data);
/* goodG2B uses the GoodSource with the BadSink */
void CWE127_Buffer_Underread__malloc_char_memcpy_54c_goodG2BSink(char * data)
{
CWE127_Buffer_Underread__malloc_char_memcpy_54d_goodG2BSink(data);
}
#endif /* OMITGOOD */
|
#ifndef __PHYSICS_H__
#define __PHYSICS_H__
#include <allegro5/allegro.h>
#include "platform_data.h"
#include "vaisseau_data.h"
class physics_constants {
public:
physics_constants(float g, float xfrott, float yfrott, float coeffax,
float coeffvx, float coeffay, float coeffvy,
float coeffimpact);
public:
double iG; // cte gravi
double iXfrott; // frottement en x
double iYfrott; // frottement en y
double iCoeffax; // pour dV = coeffa A
double iCoeffvx; // pour dX = coeffv V
double iCoeffay; // pour dV = coeffa A
double iCoeffvy; // pour dX = coeffv V
double iCoeffimpact; // when shooted on
};
void calcul_pos(const physics_constants &physics, int nbvaisseau,
struct vaisseau_data *vaisseau,
struct platform_data platforms[], int nbplatforms, double dt);
bool test_landed(struct vaisseau_data *vaisseau, struct platform_data *plt);
#endif
|
static PROGMEM prog_uchar Wood32_pic[] = {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
};
static PROGMEM prog_uchar Wood32_chr[] = {
0x55, 0xa5, 0xc0, 0xcc, 0x8a, 0xae, 0x55, 0x02, 0xfe, 0xfb, 0xbe, 0xaf, 0x12, 0x0a, 0x6b, 0xff,
0x55, 0x55, 0xfa, 0xee, 0xbc, 0x2f, 0x66, 0x5e, 0x00, 0x0f, 0xeb, 0xba, 0xea, 0xbe, 0x00, 0x03,
0x00, 0x03, 0xfd, 0xd7, 0xff, 0xf7, 0x0a, 0x6e, 0xf7, 0x55, 0xdf, 0xff, 0xa5, 0xe5, 0xd5, 0xf7,
0x03, 0x00, 0x57, 0xaf, 0xff, 0xdf, 0x5a, 0x3b, 0xaa, 0xaa, 0xe9, 0xf7, 0x9d, 0x10, 0x5a, 0xaa,
0x01, 0x5d, 0x7f, 0xaa, 0x46, 0xfd, 0x4c, 0xe9, 0xeb, 0xba, 0x7a, 0xaa, 0x00, 0x5a, 0xf5, 0xaa,
0x7c, 0x82, 0xff, 0xff, 0x58, 0x59, 0x06, 0x28, 0xfa, 0xff, 0xb0, 0x85, 0xff, 0x12, 0xec, 0xec,
0x80, 0x56, 0x0c, 0xec, 0x56, 0x81, 0x41, 0x55, 0x22, 0x98, 0x56, 0xa2, 0x4a, 0x56, 0xed, 0x80,
0xca, 0x3a, 0x0c, 0xf3, 0xea, 0x9a, 0x9a, 0xa5, 0x0f, 0xdf, 0x65, 0xe6, 0x97, 0xfa, 0x07, 0x7d,
0xde, 0x65, 0x00, 0x3c, 0x2e, 0x95, 0xa1, 0x99, 0x03, 0xc0, 0x0e, 0xfc, 0xac, 0xc3, 0x20, 0xfa,
0x99, 0x24, 0xfd, 0xff, 0xaa, 0xaa, 0x08, 0x98, 0xff, 0xc7, 0x7f, 0xff, 0x58, 0x72, 0xd6, 0xa4,
0x00, 0x4f, 0x86, 0x6a, 0xd1, 0x00, 0x00, 0xff, 0x95, 0x15, 0xa4, 0x15, 0x0d, 0xff, 0x30, 0x01,
0x56, 0xaa, 0xcf, 0x3b, 0x66, 0xa9, 0x65, 0x6a, 0x8f, 0x3c, 0x0e, 0x02, 0x62, 0x94, 0x40, 0xa6,
0x08, 0x2d, 0x55, 0x54, 0x8e, 0xfe, 0xfe, 0xef, 0x2f, 0xff, 0x55, 0x0f, 0xa0, 0xff, 0xa2, 0x28,
0x5f, 0xd7, 0xd5, 0xd1, 0x9f, 0x0c, 0xa5, 0x00, 0x6f, 0x7f, 0x02, 0xfd, 0x13, 0x9b, 0xf5, 0xa8,
0x59, 0x56, 0x03, 0x34, 0xcf, 0xfc, 0x22, 0x98, 0x56, 0xa2, 0x4a, 0xd7, 0x21, 0x80, 0x45, 0xa1,
0x57, 0xd5, 0x25, 0x7f, 0xc8, 0x92, 0x00, 0x20, 0xdf, 0xdd, 0x6c, 0x05, 0x0c, 0x83, 0xfd, 0x7f,
0x55, 0x55, 0xba, 0xaa, 0xf0, 0x00, 0xff, 0xf3, 0x69, 0xaa, 0x55, 0x5a, 0xf0, 0x00, 0xba, 0xaa,
0x55, 0x55, 0xaa, 0x3a, 0xc3, 0xc3, 0xa8, 0xfa, 0x3a, 0x5a, 0xd5, 0x66, 0xc3, 0xc3, 0x80, 0x30,
0xff, 0xff, 0x5d, 0xf5, 0x20, 0x8a, 0x04, 0x03, 0x05, 0x7f, 0x76, 0x0f, 0x20, 0x8a, 0x1d, 0xf5,
0x00, 0x00, 0xcf, 0x0c, 0xaa, 0x66, 0xc9, 0xaa, 0x2a, 0xfc, 0xff, 0xea, 0xaa, 0x66, 0xcb, 0x0c,
0x00, 0x30, 0x0c, 0xff, 0xc0, 0x03, 0x00, 0x33, 0xaa, 0xba, 0x55, 0x55, 0xaa, 0xa5, 0xef, 0xba,
0x6a, 0xaa, 0x6a, 0x55, 0xa9, 0x55, 0x95, 0x55, 0xff, 0x0f, 0x30, 0x30, 0xff, 0x0e, 0x0f, 0x6a,
0x5d, 0xff, 0x55, 0x55, 0x5f, 0xf6, 0x5d, 0xff, 0xa6, 0x5a, 0x00, 0x00, 0x08, 0xa1, 0xaa, 0x95,
0x05, 0x00, 0x50, 0x15, 0x85, 0x00, 0x05, 0x00, 0x9a, 0x59, 0xff, 0xff, 0x9f, 0xaa, 0x6a, 0xa9,
0x0a, 0xa9, 0x4f, 0xc9, 0xff, 0xff, 0x00, 0xaa, 0xfc, 0xa8, 0xff, 0xf0, 0xf2, 0x95, 0xf2, 0x2a,
0xd5, 0x77, 0xff, 0x7f, 0xaa, 0x87, 0xf0, 0x2a, 0x0a, 0x80, 0x00, 0x80, 0xff, 0xff, 0x55, 0x57,
0x67, 0xfa, 0x94, 0x29, 0xd7, 0xfd, 0x09, 0xa0, 0xa9, 0xd6, 0xaa, 0x80, 0x80, 0x80, 0x4a, 0x99,
0xaa, 0xbf, 0x65, 0xd1, 0xaa, 0xbb, 0x04, 0x59, 0x15, 0x5a, 0x05, 0x54, 0x14, 0x08, 0xa9, 0x56,
0xdf, 0xff, 0xf0, 0x30, 0x7f, 0xf3, 0xff, 0xff, 0x55, 0x65, 0x55, 0x95, 0x55, 0x55, 0x57, 0x55,
0x7b, 0xeb, 0x05, 0x45, 0xf5, 0xfa, 0x54, 0x45, 0xbb, 0xdd, 0xaa, 0x53, 0xba, 0xf7, 0xaa, 0x44,
0x08, 0x00, 0xaa, 0x5e, 0x9f, 0x5f, 0xbf, 0xfe, 0xeb, 0x55, 0x9b, 0xef, 0x1c, 0x0a, 0xd5, 0xa7,
0x00, 0xf0, 0x0e, 0xbe, 0xda, 0x9a, 0x39, 0x95, 0xa7, 0xea, 0x9f, 0x57, 0x63, 0xb0, 0x55, 0xa7,
};
static PROGMEM prog_uchar Wood32_pal[] = {
0x32, 0x6f, 0xf0, 0x6e, 0x11, 0x73, 0x32, 0x77, 0x32, 0x77, 0xf0, 0x6a, 0x11, 0x73, 0x32, 0x73,
0x10, 0x6f, 0x32, 0x77, 0x32, 0x73, 0x32, 0x77, 0xf0, 0x6e, 0x32, 0x73, 0x53, 0x77, 0x11, 0x73,
0xef, 0x6a, 0x11, 0x73, 0x32, 0x77, 0x32, 0x73, 0x11, 0x6f, 0xf0, 0x6e, 0x32, 0x73, 0x32, 0x77,
0x52, 0x77, 0x11, 0x73, 0x32, 0x77, 0x33, 0x77, 0x53, 0x77, 0x32, 0x77, 0x11, 0x73, 0x32, 0x77,
0xf0, 0x6e, 0x52, 0x77, 0x32, 0x73, 0x11, 0x73, 0x53, 0x77, 0x32, 0x77, 0x32, 0x77, 0x10, 0x73,
0x32, 0x77, 0x11, 0x73, 0xef, 0x6a, 0x52, 0x77, 0x11, 0x73, 0x52, 0x77, 0x32, 0x77, 0xf0, 0x6e,
0x11, 0x73, 0xef, 0x6a, 0x32, 0x73, 0x32, 0x77, 0x32, 0x77, 0x32, 0x73, 0x33, 0x77, 0x11, 0x73,
0x32, 0x77, 0x11, 0x73, 0x32, 0x77, 0x32, 0x73, 0x53, 0x77, 0x11, 0x73, 0x32, 0x73, 0x32, 0x77,
0xc2, 0x44, 0x44, 0x55, 0x03, 0x4d, 0xe3, 0x48, 0xe2, 0x48, 0x23, 0x51, 0x03, 0x4d, 0xc2, 0x44,
0xe2, 0x48, 0x03, 0x4d, 0xc2, 0x44, 0x24, 0x55, 0x23, 0x55, 0xc2, 0x44, 0xe3, 0x48, 0x03, 0x4d,
0x65, 0x59, 0xc2, 0x44, 0x03, 0x4d, 0x23, 0x51, 0xc2, 0x44, 0x24, 0x55, 0x23, 0x51, 0x03, 0x4d,
0xc2, 0x44, 0x23, 0x55, 0x03, 0x4d, 0x64, 0x59, 0x44, 0x59, 0x23, 0x55, 0x03, 0x4d, 0xc2, 0x44,
0x44, 0x55, 0x03, 0x4d, 0x23, 0x51, 0x65, 0x5d, 0x44, 0x55, 0x23, 0x51, 0x65, 0x59, 0x03, 0x4d,
0x44, 0x55, 0x03, 0x4d, 0x23, 0x51, 0xe3, 0x48, 0x44, 0x55, 0x23, 0x51, 0x03, 0x4d, 0xe3, 0x48,
0xc2, 0x40, 0x23, 0x51, 0x03, 0x4d, 0xe3, 0x48, 0xc2, 0x40, 0xe2, 0x48, 0x03, 0x4d, 0x03, 0x49,
0x23, 0x51, 0xe2, 0x44, 0x03, 0x49, 0xc2, 0x40, 0x23, 0x51, 0xc2, 0x40, 0xe2, 0x48, 0x03, 0x49,
};
|
typedef union
#ifdef __cplusplus
YYSTYPE
#endif
{
TYPE type;
VALUE number;
char string[32];
} YYSTYPE;
extern YYSTYPE yylval;
# define CCONST 257
# define DCONST 258
# define LCONST 259
# define ULCONST 260
# define ABS 261
# define ACOS 262
# define ACOSH 263
# define AND 264
# define ARG 265
# define ASIN 266
# define ASINH 267
# define ATAN 268
# define ATANH 269
# define BITAND 270
# define BITOR 271
# define BITXOR 272
# define COMB 273
# define COMMA 274
# define COS 275
# define COSH 276
# define COT 277
# define CSC 278
# define EQUAL 279
# define EXP 280
# define FACT 281
# define GE 282
# define GRAPH 283
# define GT 284
# define HELP 285
# define IMAG 286
# define LE 287
# define LOG 288
# define LOG10 289
# define LPAREN 290
# define LBRACKET 291
# define LSHIFT 292
# define LT 293
# define MINUS 294
# define NEWLINE 295
# define NORM 296
# define NOT 297
# define NOTEQUAL 298
# define OR 299
# define OUTBASE 300
# define PERCENT 301
# define PERM 302
# define PLUS 303
# define POW 304
# define QUIT 305
# define REAL 306
# define RPAREN 307
# define RBRACKET 308
# define RSHIFT 309
# define SEMICOLON 310
# define SIN 311
# define SINH 312
# define SLASH 313
# define SQRT 314
# define SSEC 315
# define STAR 316
# define STRING 317
# define TAN 318
# define TANH 319
# define TILDE 320
# define USURY 321
# define CCAST 322
# define DCAST 323
# define LCAST 324
# define ULCAST 325
|
/*
* Copyright (C) 2016, STMicroelectronics - All Rights Reserved
* Author(s): Vikas Manocha, <vikas.manocha@st.com> for STMicroelectronics.
*
* SPDX-License-Identifier: GPL-2.0+
*/
#ifndef _SERIAL_STM32_X7_
#define _SERIAL_STM32_X7_
#define CR1_OFFSET(x) (x ? 0x0c : 0x00)
#define CR3_OFFSET(x) (x ? 0x14 : 0x08)
#define BRR_OFFSET(x) (x ? 0x08 : 0x0c)
#define ISR_OFFSET(x) (x ? 0x00 : 0x1c)
/*
* STM32F4 has one Data Register (DR) for received or transmitted
* data, so map Receive Data Register (RDR) and Transmit Data
* Register (TDR) at the same offset
*/
#define RDR_OFFSET(x) (x ? 0x04 : 0x24)
#define TDR_OFFSET(x) (x ? 0x04 : 0x28)
struct stm32_uart_info {
u8 uart_enable_bit; /* UART_CR1_UE */
bool stm32f4; /* true for STM32F4, false otherwise */
bool has_overrun_disable;
bool has_fifo;
};
struct stm32_uart_info stm32f4_info = {
.stm32f4 = true,
.uart_enable_bit = 13,
.has_overrun_disable = false,
.has_fifo = false,
};
struct stm32_uart_info stm32f7_info = {
.uart_enable_bit = 0,
.stm32f4 = false,
.has_overrun_disable = true,
.has_fifo = false,
};
struct stm32_uart_info stm32h7_info = {
.uart_enable_bit = 0,
.stm32f4 = false,
.has_overrun_disable = true,
.has_fifo = true,
};
/* Information about a serial port */
struct stm32x7_serial_platdata {
fdt_addr_t base; /* address of registers in physical memory */
struct stm32_uart_info *uart_info;
unsigned long int clock_rate;
};
#define USART_CR1_FIFOEN BIT(29)
#define USART_CR1_OVER8 BIT(15)
#define USART_CR1_TE BIT(3)
#define USART_CR1_RE BIT(2)
#define USART_CR3_OVRDIS BIT(12)
#define USART_SR_FLAG_RXNE BIT(5)
#define USART_SR_FLAG_TXE BIT(7)
#define USART_BRR_F_MASK GENMASK(7, 0)
#define USART_BRR_M_SHIFT 4
#define USART_BRR_M_MASK GENMASK(15, 4)
#endif
|
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Paul Borman at Krystal Technologies.
*
* 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)rune.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: src/lib/libc/locale/rune.c,v 1.10 2002/08/09 08:22:29 ache Exp $");
#include "namespace.h"
#include <arpa/inet.h>
#include <errno.h>
#include <rune.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "un-namespace.h"
_RuneLocale *
_Read_RuneMagi(fp)
FILE *fp;
{
char *data;
void *lastp;
_RuneLocale *rl;
_RuneEntry *rr;
struct stat sb;
int x, saverr;
if (_fstat(fileno(fp), &sb) < 0)
return (NULL);
if (sb.st_size < sizeof(_RuneLocale)) {
errno = EFTYPE;
return (NULL);
}
if ((data = malloc(sb.st_size)) == NULL)
return (NULL);
errno = 0;
rewind(fp); /* Someone might have read the magic number once already */
if (errno) {
saverr = errno;
free(data);
errno = saverr;
return (NULL);
}
if (fread(data, sb.st_size, 1, fp) != 1) {
saverr = errno;
free(data);
errno = saverr;
return (NULL);
}
rl = (_RuneLocale *)data;
lastp = data + sb.st_size;
rl->variable = rl + 1;
if (memcmp(rl->magic, _RUNE_MAGIC_1, sizeof(rl->magic))) {
free(data);
errno = EFTYPE;
return (NULL);
}
rl->invalid_rune = ntohl(rl->invalid_rune);
rl->variable_len = ntohl(rl->variable_len);
rl->runetype_ext.nranges = ntohl(rl->runetype_ext.nranges);
rl->maplower_ext.nranges = ntohl(rl->maplower_ext.nranges);
rl->mapupper_ext.nranges = ntohl(rl->mapupper_ext.nranges);
for (x = 0; x < _CACHED_RUNES; ++x) {
rl->runetype[x] = ntohl(rl->runetype[x]);
rl->maplower[x] = ntohl(rl->maplower[x]);
rl->mapupper[x] = ntohl(rl->mapupper[x]);
}
rl->runetype_ext.ranges = (_RuneEntry *)rl->variable;
rl->variable = rl->runetype_ext.ranges + rl->runetype_ext.nranges;
if (rl->variable > lastp) {
free(data);
errno = EFTYPE;
return (NULL);
}
rl->maplower_ext.ranges = (_RuneEntry *)rl->variable;
rl->variable = rl->maplower_ext.ranges + rl->maplower_ext.nranges;
if (rl->variable > lastp) {
free(data);
errno = EFTYPE;
return (NULL);
}
rl->mapupper_ext.ranges = (_RuneEntry *)rl->variable;
rl->variable = rl->mapupper_ext.ranges + rl->mapupper_ext.nranges;
if (rl->variable > lastp) {
free(data);
errno = EFTYPE;
return (NULL);
}
for (x = 0; x < rl->runetype_ext.nranges; ++x) {
rr = rl->runetype_ext.ranges;
rr[x].min = ntohl(rr[x].min);
rr[x].max = ntohl(rr[x].max);
if ((rr[x].map = ntohl(rr[x].map)) == 0) {
int len = rr[x].max - rr[x].min + 1;
rr[x].types = rl->variable;
rl->variable = rr[x].types + len;
if (rl->variable > lastp) {
free(data);
errno = EFTYPE;
return (NULL);
}
while (len-- > 0)
rr[x].types[len] = ntohl(rr[x].types[len]);
} else
rr[x].types = 0;
}
for (x = 0; x < rl->maplower_ext.nranges; ++x) {
rr = rl->maplower_ext.ranges;
rr[x].min = ntohl(rr[x].min);
rr[x].max = ntohl(rr[x].max);
rr[x].map = ntohl(rr[x].map);
}
for (x = 0; x < rl->mapupper_ext.nranges; ++x) {
rr = rl->mapupper_ext.ranges;
rr[x].min = ntohl(rr[x].min);
rr[x].max = ntohl(rr[x].max);
rr[x].map = ntohl(rr[x].map);
}
if (((char *)rl->variable) + rl->variable_len > (char *)lastp) {
free(data);
errno = EFTYPE;
return (NULL);
}
/*
* Go out and zero pointers that should be zero.
*/
if (!rl->variable_len)
rl->variable = 0;
if (!rl->runetype_ext.nranges)
rl->runetype_ext.ranges = 0;
if (!rl->maplower_ext.nranges)
rl->maplower_ext.ranges = 0;
if (!rl->mapupper_ext.nranges)
rl->mapupper_ext.ranges = 0;
return (rl);
}
|
// Copyright (c) 2014 The Bitcoin developers
// Copyright (c) 2015 The Hivemind Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef HIVEMIND_QT_SCICON_H
#define HIVEMIND_QT_SCICON_H
#include <QtCore>
QT_BEGIN_NAMESPACE
class QColor;
class QIcon;
class QString;
QT_END_NAMESPACE
QImage SingleColorImage(const QString& filename, const QColor&);
QIcon SingleColorIcon(const QIcon&, const QColor&);
QIcon SingleColorIcon(const QString& filename, const QColor&);
QColor SingleColor();
QIcon SingleColorIcon(const QString& filename);
QIcon TextColorIcon(const QIcon&);
QIcon TextColorIcon(const QString& filename);
#endif // HIVEMIND_QT_SCICON_H
|
#ifndef GINGER_TEST_GSEARCH_GCOMPUTEMATCH_H_
#define GINGER_TEST_GSEARCH_GCOMPUTEMATCH_H_
#include <seqan/basic.h>
#include <seqan/sequence.h>
#include <seqan/GSearch.h>
#include <seqan/GSearch/GComputeMatch.h>
using namespace seqan;
using namespace std;
SEQAN_DEFINE_TEST(test_GComputeMatch_dummy)
{
String<GMatch<int> > matches;
GFastaRecord<DnaString> queryRecord;
queryRecord.id="testQueryId";
queryRecord.seq="TTTATTGCTAAGCCAAA";
GFastaRecord<DnaString> clusterRecord;
clusterRecord.id="testClusterId";
clusterRecord.seq="CCCCATTGCTAAGCCTT";
Score<int> scoringScheme(1, -2, -1);
int threshold= 1;
string scoreMode="COMMON_QGRAM_MODE";
int res=GComputeMatch(matches, queryRecord, clusterRecord, scoringScheme, threshold, scoreMode);
SEQAN_ASSERT_EQ(res,0);
SEQAN_ASSERT_EQ(length(matches),1);
SEQAN_ASSERT_EQ(matches[0].id,"testClusterId");
SEQAN_ASSERT_EQ(matches[0].queryId,"testQueryId");
SEQAN_ASSERT_EQ(matches[0].score,400);
}
#endif // GINGER_TEST_GCOMPUTEMATCH_H_
|
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by Trainer.rc
//
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
|
#ifdef HAVE_CONFIG_H
#include "../ext_config.h"
#endif
#include <php.h>
#include "../php_ext.h"
#include "../ext.h"
#include <Zend/zend_operators.h>
#include <Zend/zend_exceptions.h>
#include <Zend/zend_interfaces.h>
#include "kernel/main.h"
#include "kernel/operators.h"
#include "kernel/memory.h"
#include "kernel/object.h"
ZEPHIR_INIT_CLASS(stub_11__closure)
{
ZEPHIR_REGISTER_CLASS(stub, 11__closure, stub, 11__closure, stub_11__closure_method_entry, ZEND_ACC_FINAL_CLASS);
return SUCCESS;
}
PHP_METHOD(stub_11__closure, __invoke)
{
zval *x, x_sub;
zval *this_ptr = getThis();
ZVAL_UNDEF(&x_sub);
#if PHP_VERSION_ID >= 80000
bool is_null_true = 1;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_ZVAL(x)
ZEND_PARSE_PARAMETERS_END();
#endif
zephir_fetch_params_without_memory_grow(1, 0, &x);
mul_function(return_value, x, x);
return;
}
|
// This file was generated based on 'C:\ProgramData\Uno\Packages\FuseCore\0.18.8\Input\$.uno'.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Fuse.Input.PointerLeftArgs.h>
#include <Fuse.Input.PointerLeftHandler.h>
#include <Fuse.NodeEvent-2.h>
namespace g{namespace Fuse{namespace Input{struct PointerLeft;}}}
namespace g{
namespace Fuse{
namespace Input{
// internal sealed class PointerLeft :849
// {
::g::Fuse::NodeEvent_type* PointerLeft_typeof();
void PointerLeft__ctor_1_fn(PointerLeft* __this);
void PointerLeft__Invoke_fn(PointerLeft* __this, uDelegate* handler, uObject* sender, ::g::Fuse::Input::PointerLeftArgs* args);
void PointerLeft__New1_fn(PointerLeft** __retval);
struct PointerLeft : ::g::Fuse::NodeEvent
{
void ctor_1();
static PointerLeft* New1();
};
// }
}}} // ::g::Fuse::Input
|
//
// BaseView.h
// BetterBaseClasses
//
// Created by Joshua Greene on 2/25/15.
// Copyright (c) 2015 Joshua Greene. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "UIView+BetterBaseClasses.h"
NS_ASSUME_NONNULL_BEGIN
/**
* @brief `BaseView` is an abstract, base class meant to be subclassed instead of `UIView`.
*
* @dicussion This class is designed to be used with the `UIView+BetterBaseClasses` category, which adds convenience class instantiation methods.
*/
@interface BaseView : UIView
@end
NS_ASSUME_NONNULL_END
|
//
// SXPhotoSetPage.h
// 81 - 网易新闻
//
// Created by 董 尚先 on 15/2/3.
// Copyright (c) 2015年 ShangxianDante. All rights reserved.
//
#import <UIKit/UIKit.h>
@class SXNewsEntity;
@interface SXPhotoSetPage : UIViewController
@property(nonatomic,strong) SXNewsEntity *newsModel;
@end
|
/****************************************************************************
Copyright (C) 2013 Henry van Merode. All rights reserved.
Copyright (c) 2015-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.org
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 __CC_PU_PARTICLE_3D_JET_AFFECTOR_TRANSLATOR_H__
#define __CC_PU_PARTICLE_3D_JET_AFFECTOR_TRANSLATOR_H__
#include "extensions/Particle3D/PU/CCPUScriptTranslator.h"
#include "extensions/Particle3D/PU/CCPUScriptCompiler.h"
#include "extensions/Particle3D/PU/CCPUJetAffector.h"
NS_CC_BEGIN
class PUJetAffectorTranslator : public PUScriptTranslator
{
public:
PUJetAffectorTranslator();
virtual ~PUJetAffectorTranslator(){};
virtual bool translateChildProperty(PUScriptCompiler* compiler, PUAbstractNode *node);
virtual bool translateChildObject(PUScriptCompiler* compiler, PUAbstractNode *node);
};
NS_CC_END
#endif
|
//
// CitiesViewController.h
// WeatherApp
//
// Created by Renzo Crisóstomo on 1/15/14.
// Copyright (c) 2014 Ruenzuo. All rights reserved.
//
#import <UIKit/UIKit.h>
@class Country;
@interface CitiesViewController : UITableViewController
@property (nonatomic, strong) Country *country;
- (IBAction)onRefreshControlValueChanged:(id)sender;
@end
|
//
// MojoModel.h
// MojoDB
//
// Created by Craig Jolicoeur on 10/8/10.
// Copyright 2010 Mojo Tech, LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
@class MojoDatabase;
@interface MojoModel : NSObject {
NSUInteger primaryKey;
BOOL savedInDatabase;
}
@property (nonatomic) NSUInteger primaryKey;
@property (nonatomic) BOOL savedInDatabase;
+(void)setDatabase:(MojoDatabase *)newDatabase;
+(MojoDatabase *)database;
-(void)save;
-(void)beforeSave;
-(void)afterSave;
-(void)delete;
-(void)beforeDelete;
+(NSArray *)findWithSql:(NSString *)sql withParameters:(NSArray *)parameters;
+(NSArray *)findWithSqlWithParameters:(NSString *)sql, ...;
+(NSArray *)findWithSql:(NSString *)sql;
+(NSArray *)findByColumn:(NSString *)column value:(id)value;
+(NSArray *)findByColumn:(NSString *)column unsignedIntegerValue:(NSUInteger)value;
+(NSArray *)findByColumn:(NSString *)column integerValue:(NSInteger)value;
+(NSArray *)findByColumn:(NSString *)column doubleValue:(double)value;
+(id)find:(NSUInteger)primaryKey;
+(NSArray *)findAll;
+(void)deleteAll;
@end
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <ugens.h>
#define DEBUG
/* ------------------------------------------------------------- somefunk --- */
double
somefunk(float p[], int n_args, double pp[])
{
int an_int_arg;
float val, a_float_arg;
char *a_str_arg;
if (n_args < 1)
die("somefunk", "Wrong number of args.");
an_int_arg = (int) p[0];
a_float_arg = p[0];
/* This is the method of getting a string pointer
from Minc. Minc allocates space for the string that persists
for the life of the program, so we just need a pointer to it.
*/
a_str_arg = DOUBLE_TO_STRING(pp[0]);
/* We'll just interpret the arg as a float here. */
val = a_float_arg * 2;
return val;
}
/* -------------------------------------------------------------- profile --- */
int
profile()
{
UG_INTRO("somefunk", somefunk);
return 0;
}
|
/****************************************************************************
** libebml : parse EBML files, see http://embl.sourceforge.net/
**
** <file/class description>
**
** Copyright (C) 2002-2004 Steve Lhomme. All rights reserved.
**
** This file is part of libebml.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
**
** See http://www.matroska.org/license/lgpl/ for LGPL licensing information.
**
** Contact license@matroska.org if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
/*!
\file
\version \$Id$
\author Steve Lhomme <robux4 @ users.sf.net>
*/
#ifndef LIBEBML_HEAD_H
#define LIBEBML_HEAD_H
#include "EbmlTypes.h"
#include "EbmlMaster.h"
START_LIBEBML_NAMESPACE
DECLARE_EBML_MASTER(EbmlHead)
public:
EbmlHead(const EbmlHead & ElementToClone) : EbmlMaster(ElementToClone) {}
EBML_CONCRETE_CLASS(EbmlHead)
};
END_LIBEBML_NAMESPACE
#endif // LIBEBML_HEAD_H
|
/*==========================================================================
NinjaSCSI-3 message handler
By: YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>
This software may be used and distributed according to the terms of
the GNU General Public License.
*/
/* $Id: nsp_message.c,v 1.1 2011/07/05 16:52:23 ian Exp $ */
static void nsp_message_in(struct scsi_cmnd *SCpnt)
{
unsigned int base = SCpnt->device->host->io_port;
nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
unsigned char data_reg, control_reg;
int ret, len;
/*
* XXX: NSP QUIRK
* NSP invoke interrupts only in the case of scsi phase changes,
* therefore we should poll the scsi phase here to catch
* the next "msg in" if exists (no scsi phase changes).
*/
ret = 16;
len = 0;
nsp_dbg(NSP_DEBUG_MSGINOCCUR, "msgin loop");
do {
/* read data */
data_reg = nsp_index_read(base, SCSIDATAIN);
/* assert ACK */
control_reg = nsp_index_read(base, SCSIBUSCTRL);
control_reg |= SCSI_ACK;
nsp_index_write(base, SCSIBUSCTRL, control_reg);
nsp_negate_signal(SCpnt, BUSMON_REQ, "msgin<REQ>");
data->MsgBuffer[len] = data_reg; len++;
/* deassert ACK */
control_reg = nsp_index_read(base, SCSIBUSCTRL);
control_reg &= ~SCSI_ACK;
nsp_index_write(base, SCSIBUSCTRL, control_reg);
/* catch a next signal */
ret = nsp_expect_signal(SCpnt, BUSPHASE_MESSAGE_IN, BUSMON_REQ);
} while (ret > 0 && MSGBUF_SIZE > len);
data->MsgLen = len;
}
static void nsp_message_out(struct scsi_cmnd *SCpnt)
{
nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
int ret = 1;
int len = data->MsgLen;
/*
* XXX: NSP QUIRK
* NSP invoke interrupts only in the case of scsi phase changes,
* therefore we should poll the scsi phase here to catch
* the next "msg out" if exists (no scsi phase changes).
*/
nsp_dbg(NSP_DEBUG_MSGOUTOCCUR, "msgout loop");
do {
if (nsp_xfer(SCpnt, BUSPHASE_MESSAGE_OUT)) {
nsp_msg(KERN_DEBUG, "msgout: xfer short");
}
/* catch a next signal */
ret = nsp_expect_signal(SCpnt, BUSPHASE_MESSAGE_OUT, BUSMON_REQ);
} while (ret > 0 && len-- > 0);
}
/* end */
|
/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
*/
#include "msm_fb.h"
#include "mipi_dsi.h"
#include "mipi_renesas.h"
static struct msm_panel_info pinfo;
static struct mipi_dsi_phy_ctrl dsi_cmd_mode_phy_db = {
/* DSI_BIT_CLK at 482MHz, 2 lane, RGB888 */
{0x03, 0x01, 0x01, 0x00}, /* regulator */
/* timing */
//{0x96, 0x26, 0x23, 0x0, 0x50, 0x4B, 0x1e,
//0x28, 0x28, 0x03, 0x04},
{0x96, 0x1E, 0x1E, 0x00, 0x3C, 0x3C, 0x1E, 0x28,
0x0b, 0x13, 0x04},
{0x7f, 0x00, 0x00, 0x00}, /* phy ctrl */
{0xee, 0x02, 0x86, 0x00}, /* strength */
/* pll control */
{0x41, 0x8f, 0xb1, 0xda, 0x00, 0x50, 0x48, 0x63,
0x31, 0x0f, 0x07,
0x05, 0x14, 0x03, 0x03, 0x03, 0x54, 0x06, 0x10, 0x04, 0x03 },
};
static int __init mipi_cmd_renesas_blue_qhd_pt_init(void)
{
int ret;
#ifdef CONFIG_FB_MSM_MIPI_PANEL_DETECT
if (msm_fb_detect_client("mipi_cmd_renesas_wvga"))
return 0;
pr_info("panel: mipi_cmd_renesas_wvga\n");
#endif
pinfo.xres = 480;
pinfo.yres = 800;
pinfo.type = MIPI_CMD_PANEL;
pinfo.pdest = DISPLAY_1;
pinfo.wait_cycle = 0;
pinfo.bpp = 24;
pinfo.lcdc.h_back_porch = 64;
pinfo.lcdc.h_front_porch = 96;
pinfo.lcdc.h_pulse_width = 32;
pinfo.lcdc.v_back_porch = 16;
pinfo.lcdc.v_front_porch = 16;
pinfo.lcdc.v_pulse_width = 4;
pinfo.lcdc.border_clr = 0; /* blk */
pinfo.lcdc.underflow_clr = 0xff; /* blue */
pinfo.lcdc.hsync_skew = 0;
pinfo.bl_max = 255;
pinfo.bl_min = 1;
pinfo.fb_num = 2;
pinfo.clk_rate = 400000000;
pinfo.lcd.vsync_enable = TRUE;
pinfo.lcd.hw_vsync_mode = TRUE;
pinfo.lcd.refx100 = 6096; /* adjust refx100 to prevent tearing */
pinfo.mipi.mode = DSI_CMD_MODE;
pinfo.mipi.dst_format = DSI_CMD_DST_FORMAT_RGB888;
pinfo.mipi.vc = 0;
pinfo.mipi.rgb_swap = DSI_RGB_SWAP_BGR;
pinfo.mipi.data_lane0 = TRUE;
pinfo.mipi.data_lane1 = TRUE;
pinfo.mipi.t_clk_post = 0x0a;
pinfo.mipi.t_clk_pre = 0x1e;
pinfo.mipi.stream = 0; /* dma_p */
pinfo.mipi.mdp_trigger = DSI_CMD_TRIGGER_SW;
pinfo.mipi.dma_trigger = DSI_CMD_TRIGGER_SW;
pinfo.mipi.te_sel = 1; /* TE from vsycn gpio */
pinfo.mipi.interleave_max = 1;
pinfo.mipi.insert_dcs_cmd = TRUE;
pinfo.mipi.wr_mem_continue = 0x3c;
pinfo.mipi.wr_mem_start = 0x2c;
pinfo.mipi.dsi_phy_db = &dsi_cmd_mode_phy_db;
ret = mipi_renesas_device_register(&pinfo, MIPI_DSI_PRIM,
MIPI_DSI_PANEL_WVGA_PT);
if (ret)
pr_err("%s: failed to register device!\n", __func__);
return ret;
}
module_init(mipi_cmd_renesas_blue_qhd_pt_init);
|
/*
* system copy/paste routines
*
* Copyright (C) 2014-2016 LastPass.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations
* including the two.
*
* You must obey the GNU General Public License in all respects
* for all of the code used other than OpenSSL. If you modify
* file(s) with this exception, you may extend this exception to your
* version of the file(s), but you are not obligated to do so. If you
* do not wish to do so, delete this exception statement from your
* version. If you delete this exception statement from all source
* files in the program, then also delete it here.
*
* See LICENSE.OpenSSL for more details regarding this exception.
*/
#include "clipboard.h"
#include "util.h"
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
static pid_t clipboard_process = 0;
static int saved_stdout = -1;
static bool registered_closer = false;
void clipboard_close(void)
{
if (!clipboard_process || saved_stdout < 0)
return;
fflush(stdout);
dup2(saved_stdout, STDOUT_FILENO);
close(saved_stdout);
waitpid(clipboard_process, NULL, 0);
clipboard_process = 0;
saved_stdout = -1;
}
void exec_command(char *command) {
char *shell = getenv("SHELL");
if (!shell) {
shell = "/bin/sh";
}
execlp(shell, shell, "-c", command, NULL);
}
void clipboard_open(void)
{
int pipefd[2];
if (clipboard_process > 0)
return;
if (pipe(pipefd) < 0)
die_errno("pipe");
saved_stdout = dup(STDOUT_FILENO);
if (saved_stdout < 0)
die_errno("dup");
clipboard_process = fork();
if (clipboard_process == -1)
die_errno("fork");
if (!clipboard_process) {
close(pipefd[1]);
dup2(pipefd[0], STDIN_FILENO);
close(pipefd[0]);
char *clipboard_command = getenv("LPASS_CLIPBOARD_COMMAND");
if (clipboard_command) {
exec_command(clipboard_command);
die("Unable to copy contents to clipboard. Please make sure you have `xclip`, `xsel`, `pbcopy`, or `putclip` installed.");
} else {
execlp("xclip", "xclip", "-selection", "clipboard", "-in", NULL);
execlp("xsel", "xsel", "--clipboard", "--input", NULL);
execlp("pbcopy", "pbcopy", NULL);
execlp("putclip", "putclip", "--dos", NULL);
die("Unable to copy contents to clipboard. Please make sure you have `xclip`, `xsel`, `pbcopy`, or `putclip` installed.");
}
}
close(pipefd[0]);
dup2(pipefd[1], STDOUT_FILENO);
close(pipefd[1]);
if (!registered_closer) {
atexit(clipboard_close);
registered_closer = true;
}
}
|
/*
* splitter.h
*
* Global definitions from the splitter main program.
*
* $Id: splitter.h,v 1.1.2.1 2006/01/13 00:25:01 jeffc Exp $
*
*/
#ifndef SPLITTER_H
#define SPLITTER_H
#include "splitparms.h"
#include "splittypes.h"
#define MAX(x,y) ( ((x)<(y)) ? (y) : (x) )
#define MIN(x,y) ( ((y)<(x)) ? (y) : (x) )
/* wulog: File for logging names of completed wu files */
/* errorlog: File for logging errors */
#include "boinc_db.h"
#include "crypt.h"
#include "backend_lib.h"
#include "sched_config.h"
extern SCHED_CONFIG boinc_config;
extern DB_APP app;
extern R_RSA_PRIVATE_KEY key;
extern FILE *wulog,*errorlog;
extern workunit wuheaders[NSTRIPS];
extern tapeheader_t tapeheaders[TAPE_FRAMES_IN_BUFFER];
extern int noencode;
extern int dataclass;
extern int nodb;
extern int resumetape;
extern int startblock;
extern int norewind;
extern int output_xml;
extern int polyphase;
extern int wu_database_id[NSTRIPS];
extern int gregorian;
extern char * projectdir;
/* Buffer that holds tape data */
extern unsigned char *tapebuffer;
/* Number of records remaining in the buffer after WU creations is complete */
extern int records_in_buffer;
extern const char *wu_template;
extern const char *result_template;
// jeffc
//extern const char *result_template_filename;
extern char result_template_filename[];
extern char result_template_filepath[];
extern char wu_template_filename[];
/* Persistant sequence number of wu file */
extern int seqno;
#endif
/*
* $Log: splitter.h,v $
* Revision 1.1.2.1 2006/01/13 00:25:01 jeffc
* *** empty log message ***
*
* Revision 1.6 2004/07/09 22:35:39 jeffc
* *** empty log message ***
*
* Revision 1.5 2004/06/16 20:57:19 jeffc
* *** empty log message ***
*
* Revision 1.4 2003/09/26 20:48:52 jeffc
* jeffc - merge in branch setiathome-4_all_platforms_beta.
*
* Revision 1.2.2.1 2003/09/22 17:39:35 korpela
* *** empty log message ***
*
* Revision 1.3 2003/09/22 17:05:38 korpela
* *** empty log message ***
*
* Revision 1.2 2003/08/05 17:23:42 korpela
* More work on database stuff.
* Further tweaks.
*
* Revision 1.1 2003/06/03 00:23:40 korpela
*
* Again
*
* Revision 3.2 2003/05/19 17:40:59 eheien
* *** empty log message ***
*
* Revision 3.1 2001/08/16 23:42:08 korpela
* Mods for splitter to make binary workunits.
*
* Revision 3.0 2001/08/01 19:04:57 korpela
* Check this in before Paul screws it up.
*
* Revision 2.5 1999/10/20 19:20:26 korpela
* *** empty log message ***
*
* Revision 2.4 1999/03/05 01:47:18 korpela
* Added data_class field.
*
* Revision 2.3 1999/02/22 22:21:09 korpela
* Added nodb option
*
* Revision 2.2 1999/02/11 16:46:28 korpela
* Added startblock and norewind support, and wu_database_id.
*
* Revision 2.1 1998/11/02 16:41:21 korpela
* Minor Change.
*
* Revision 2.0 1998/10/30 22:00:04 korpela
* Conversion to C++ and merger with client source tree.
*
* Revision 1.1 1998/10/27 01:10:32 korpela
* Initial revision
*
*
*/
|
#ifndef _ASM_X86_LOCAL_H
#define _ASM_X86_LOCAL_H
#include <linux/percpu.h>
#include <asm/system.h>
#include <asm/atomic.h>
#include <asm/asm.h>
typedef struct {
atomic_long_t a;
} local_t;
#define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
#define local_read(l) atomic_long_read(&(l)->a)
#define local_set(l, i) atomic_long_set(&(l)->a, (i))
static inline void local_inc(local_t *l)
{
asm volatile(_ASM_INC "%0\n"
#ifdef CONFIG_PAX_REFCOUNT
"jno 0f\n"
_ASM_DEC "%0\n"
"int $4\n0:\n"
_ASM_EXTABLE(0b, 0b)
#endif
: "+m" (l->a.counter));
}
static inline void local_dec(local_t *l)
{
asm volatile(_ASM_DEC "%0\n"
#ifdef CONFIG_PAX_REFCOUNT
"jno 0f\n"
_ASM_INC "%0\n"
"int $4\n0:\n"
_ASM_EXTABLE(0b, 0b)
#endif
: "+m" (l->a.counter));
}
static inline void local_add(long i, local_t *l)
{
asm volatile(_ASM_ADD "%1,%0\n"
#ifdef CONFIG_PAX_REFCOUNT
"jno 0f\n"
_ASM_SUB "%1,%0\n"
"int $4\n0:\n"
_ASM_EXTABLE(0b, 0b)
#endif
: "+m" (l->a.counter)
: "ir" (i));
}
static inline void local_sub(long i, local_t *l)
{
asm volatile(_ASM_SUB "%1,%0\n"
#ifdef CONFIG_PAX_REFCOUNT
"jno 0f\n"
_ASM_ADD "%1,%0\n"
"int $4\n0:\n"
_ASM_EXTABLE(0b, 0b)
#endif
: "+m" (l->a.counter)
: "ir" (i));
}
/**
* local_sub_and_test - subtract value from variable and test result
* @i: integer value to subtract
* @l: pointer to type local_t
*
* Atomically subtracts @i from @l and returns
* true if the result is zero, or false for all
* other cases.
*/
static inline int local_sub_and_test(long i, local_t *l)
{
unsigned char c;
asm volatile(_ASM_SUB "%2,%0\n"
#ifdef CONFIG_PAX_REFCOUNT
"jno 0f\n"
_ASM_ADD "%2,%0\n"
"int $4\n0:\n"
_ASM_EXTABLE(0b, 0b)
#endif
"sete %1\n"
: "+m" (l->a.counter), "=qm" (c)
: "ir" (i) : "memory");
return c;
}
/**
* local_dec_and_test - decrement and test
* @l: pointer to type local_t
*
* Atomically decrements @l by 1 and
* returns true if the result is 0, or false for all other
* cases.
*/
static inline int local_dec_and_test(local_t *l)
{
unsigned char c;
asm volatile(_ASM_DEC "%0\n"
#ifdef CONFIG_PAX_REFCOUNT
"jno 0f\n"
_ASM_INC "%0\n"
"int $4\n0:\n"
_ASM_EXTABLE(0b, 0b)
#endif
"sete %1\n"
: "+m" (l->a.counter), "=qm" (c)
: : "memory");
return c != 0;
}
/**
* local_inc_and_test - increment and test
* @l: pointer to type local_t
*
* Atomically increments @l by 1
* and returns true if the result is zero, or false for all
* other cases.
*/
static inline int local_inc_and_test(local_t *l)
{
unsigned char c;
asm volatile(_ASM_INC "%0\n"
#ifdef CONFIG_PAX_REFCOUNT
"jno 0f\n"
_ASM_DEC "%0\n"
"int $4\n0:\n"
_ASM_EXTABLE(0b, 0b)
#endif
"sete %1\n"
: "+m" (l->a.counter), "=qm" (c)
: : "memory");
return c != 0;
}
/**
* local_add_negative - add and test if negative
* @i: integer value to add
* @l: pointer to type local_t
*
* Atomically adds @i to @l and returns true
* if the result is negative, or false when
* result is greater than or equal to zero.
*/
static inline int local_add_negative(long i, local_t *l)
{
unsigned char c;
asm volatile(_ASM_ADD "%2,%0\n"
#ifdef CONFIG_PAX_REFCOUNT
"jno 0f\n"
_ASM_SUB "%2,%0\n"
"int $4\n0:\n"
_ASM_EXTABLE(0b, 0b)
#endif
"sets %1\n"
: "+m" (l->a.counter), "=qm" (c)
: "ir" (i) : "memory");
return c;
}
/**
* local_add_return - add and return
* @i: integer value to add
* @l: pointer to type local_t
*
* Atomically adds @i to @l and returns @i + @l
*/
static inline long local_add_return(long i, local_t *l)
{
long __i;
#ifdef CONFIG_M386
unsigned long flags;
if (unlikely(boot_cpu_data.x86 <= 3))
goto no_xadd;
#endif
/* Modern 486+ processor */
__i = i;
asm volatile(_ASM_XADD "%0, %1\n"
#ifdef CONFIG_PAX_REFCOUNT
"jno 0f\n"
_ASM_MOV "%0,%1\n"
"int $4\n0:\n"
_ASM_EXTABLE(0b, 0b)
#endif
: "+r" (i), "+m" (l->a.counter)
: : "memory");
return i + __i;
#ifdef CONFIG_M386
no_xadd: /* Legacy 386 processor */
local_irq_save(flags);
__i = local_read(l);
local_set(l, i + __i);
local_irq_restore(flags);
return i + __i;
#endif
}
static inline long local_sub_return(long i, local_t *l)
{
return local_add_return(-i, l);
}
#define local_inc_return(l) (local_add_return(1, l))
#define local_dec_return(l) (local_sub_return(1, l))
#define local_cmpxchg(l, o, n) \
(cmpxchg_local(&((l)->a.counter), (o), (n)))
/* Always has a lock prefix */
#define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
/**
* local_add_unless - add unless the number is a given value
* @l: pointer of type local_t
* @a: the amount to add to l...
* @u: ...unless l is equal to u.
*
* Atomically adds @a to @l, so long as it was not @u.
* Returns non-zero if @l was not @u, and zero otherwise.
*/
#define local_add_unless(l, a, u) \
({ \
long c, old; \
c = local_read((l)); \
for (;;) { \
if (unlikely(c == (u))) \
break; \
old = local_cmpxchg((l), c, c + (a)); \
if (likely(old == c)) \
break; \
c = old; \
} \
c != (u); \
})
#define local_inc_not_zero(l) local_add_unless((l), 1, 0)
/* On x86_32, these are no better than the atomic variants.
* On x86-64 these are better than the atomic variants on SMP kernels
* because they dont use a lock prefix.
*/
#define __local_inc(l) local_inc(l)
#define __local_dec(l) local_dec(l)
#define __local_add(i, l) local_add((i), (l))
#define __local_sub(i, l) local_sub((i), (l))
#endif /* _ASM_X86_LOCAL_H */
|
/* TI C6X control register information.
Copyright 2010
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
/* Define the CTRL macro before including this file; it takes as
arguments the fields from tic6x_ctrl (defined in tic6x.h). The
control register name is given as an identifier; the isa_variants
field without the leading TIC6X_INSN_; the rw field without the
leading tic6x_rw_. */
CTRL(amr, C62X, read_write, 0x0, 0x10)
CTRL(csr, C62X, read_write, 0x1, 0x10)
CTRL(dnum, C64XP, read, 0x11, 0x1f)
CTRL(ecr, C64XP, write, 0x1d, 0x1f)
CTRL(efr, C64XP, read, 0x1d, 0x1f)
CTRL(fadcr, C67X, read_write, 0x12, 0x1f)
CTRL(faucr, C67X, read_write, 0x13, 0x1f)
CTRL(fmcr, C67X, read_write, 0x14, 0x1f)
CTRL(gfpgfr, C64X, read_write, 0x18, 0x1f)
CTRL(gplya, C64XP, read_write, 0x16, 0x1f)
CTRL(gplyb, C64XP, read_write, 0x17, 0x1f)
CTRL(icr, C62X, write, 0x3, 0x10)
CTRL(ier, C62X, read_write, 0x4, 0x10)
CTRL(ierr, C64XP, read_write, 0x1f, 0x1f)
CTRL(ifr, C62X, read, 0x2, 0x1d)
CTRL(ilc, C64XP, read_write, 0xd, 0x1f)
CTRL(irp, C62X, read_write, 0x6, 0x10)
CTRL(isr, C62X, write, 0x2, 0x10)
CTRL(istp, C62X, read_write, 0x5, 0x10)
CTRL(itsr, C64XP, read_write, 0x1b, 0x1f)
CTRL(nrp, C62X, read_write, 0x7, 0x10)
CTRL(ntsr, C64XP, read_write, 0x1c, 0x1f)
CTRL(pce1, C62X, read, 0x10, 0xf)
CTRL(rep, C64XP, read_write, 0xf, 0x1f)
CTRL(rilc, C64XP, read_write, 0xe, 0x1f)
CTRL(ssr, C64XP, read_write, 0x15, 0x1f)
CTRL(tsch, C64XP, read, 0xb, 0x1f)
CTRL(tscl, C64XP, read, 0xa, 0x1f)
CTRL(tsr, C64XP, read_write, 0x1a, 0x1f)
|
/*
* @BEGIN LICENSE
*
* Psi4: an open-source quantum chemistry software package
*
* Copyright (c) 2007-2017 The Psi4 Developers.
*
* The copyrights for code used from other parties are included in
* the corresponding files.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* @END LICENSE
*/
/*
** Declarations for functions found in libciomr.a
**
** C. David Sherrill and T. Daniel Crawford
**
**
*/
#ifndef _psi_src_lib_libciomr_libciomr_h_
#define _psi_src_lib_libciomr_libciomr_h_
#include <cstdio>
#include <string>
namespace psi {
int psi_start(FILE** infile, FILE** outfile, char** psi_file_prefix, int argc, char *argv[], int overwrite_output);
int psi_stop(FILE* infile, FILE* outfile, char* psi_file_prefix);
char* psi_ifname();
char* psi_ofname();
char* psi_fprefix();
void ffile(FILE **fptr, const char *suffix, int code);
void ffile_noexit(FILE **fptr, char *suffix, int code);
void ffileb(FILE **fptr, char *suffix, int code);
void ffileb_noexit(FILE **fptr, char *suffix, int code);
void add_arr(double *a, double *b, double *c, int n);
void add_mat(double **a,double **b,double **c,int n,int m);
void balance(double **a, int n);
/* Functions under dot.cc */
void dot_arr(double *a, double *b, int size, double *value) ;
double dot_mat(double **a,double **b,int n);
void eigout(double **a,double *b,double *c,int m,int n,FILE *out);
void eigsort(double *d,double **v,int n);
void eivout(double **a, double *b, int m, int n, std::string out) ;
void mosort(double *d, double **v, int *sym, int nso, int nmo);
void flin(double **a,double *b,int in,int im,double *det);
void free_matrix(double **array, unsigned long int size) ;
double * init_array(unsigned long int size) ;
double ** init_matrix(unsigned long int rows, unsigned long int cols) ;
void lubksb(double **a,int n,int *indx,double *b);
void ludcmp(double **a,int n,int *indx,double *d);
/* Functions under mat_to_arr.c */
void mat_to_arr(double **a,double *b, int m, int n);
void arr_to_mat(double **a,double *b,int m,int n);
void mmult(double **AF, int ta, double **BF, int tb, double **CF, int tc,
int nr, int nl, int nc, int add) ;
void mxmb(double **a,int ia,int ja,double **b,int ib,int jb,double **c,
int ic,int jc, int nrow, int nlnk, int ncol);
void print_array(double *a, int m, std::string out) ;
void print_mat(double **a, int rows, int cols, std::string out) ;
void rsp(int nm, int n, int nv, double *array, double *evals, int matz,
double **evecs, double toler) ;
void sq_rsp(int nm, int n, double **array, double *evals, int matz,
double **evecs, double toler) ;
void sq_to_tri(double **bmat,double *amat,int size);
/* Functions under tri_to_block.c */
void tri_to_block(double *a,double **b,int num_ir,int *num_so,int *ioff);
void block_to_tri(double *a,double **b,int num_ir,int *num_so,int *ioff);
void tri_to_sq(double *amat,double **bmat,int size);
/* Functions under tstart.c */
void tstart() ;
void tstop() ;
/* Functions in zero.c */
void zero_arr(double *a, int size) ;
void zero_mat(double **a, int rows, int cols) ;
/* Functions in int_array.c */
int * init_int_array(int size) ;
void zero_int_array(int *a, int size);
int **init_int_matrix(int rows, int cols);
void free_int_matrix(int **array);
void zero_int_matrix(int **array, int rows, int cols);
void print_int_mat(int **a, int m, int n, std::string out);
/* Functions in long_int_array.c */
long int * init_long_int_array(int size) ;
void zero_long_int_array(long int *a, int size);
long int **init_long_int_matrix(int rows, int cols);
void free_long_int_matrix(long int **array);
void zero_long_int_matrix(long int **array, int rows, int cols);
void print_long_int_mat(long int **a, int m, int n, std::string out);
/* Functions in block_matrix.c */
double ** block_matrix(unsigned long int n, unsigned long int m, bool mlock = false);
void free_block(double **array);
/* Functions in fndcor */
void fndcor(long int *maxcrb, std::string OutFileRMR);
}
#endif /* header guard */
|
#include <NoLengthInfo1.d>
#include <__oo2c.h>
#include <setjmp.h>
void OOC_NoLengthInfo1_init(void) {
register OOC_INT32 i0;
i0 = (OOC_INT32)NoLengthInfo1__a;
*(OOC_UINT8*)i0 = 0u;
return;
;
}
void OOC_NoLengthInfo1_destroy(void) {
}
/* --- */
|
/*
* Copyright (C) 2007 HTC Incorporated
* Author: Jay Tu (jay_tu@htc.com)
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* 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.
*/
#ifndef _HTC_BATTERY_H_
#define _HTC_BATTERY_H_
#include "htc_battery_common.h"
#include "htc_gauge.h"
#include "htc_charger.h"
#define ADC_REPLY_ARRAY_SIZE 5
/* ioctl define */
#define HTC_BATT_IOCTL_MAGIC 0xba
#define DEBUG_LOG_LENGTH 1024
#define HTC_BATT_IOCTL_READ_SOURCE \
_IOR(HTC_BATT_IOCTL_MAGIC, 1, unsigned int)
#define HTC_BATT_IOCTL_SET_BATT_ALARM \
_IOW(HTC_BATT_IOCTL_MAGIC, 2, unsigned int)
#define HTC_BATT_IOCTL_GET_ADC_VREF \
_IOR(HTC_BATT_IOCTL_MAGIC, 3, unsigned int[ADC_REPLY_ARRAY_SIZE])
#define HTC_BATT_IOCTL_GET_ADC_ALL \
_IOR(HTC_BATT_IOCTL_MAGIC, 4, struct battery_adc_reply)
#define HTC_BATT_IOCTL_CHARGER_CONTROL \
_IOW(HTC_BATT_IOCTL_MAGIC, 5, unsigned int)
#define HTC_BATT_IOCTL_UPDATE_BATT_INFO \
_IOW(HTC_BATT_IOCTL_MAGIC, 6, struct battery_info_reply)
#define HTC_BATT_IOCTL_BATT_DEBUG_LOG \
_IOW(HTC_BATT_IOCTL_MAGIC, 7, char[DEBUG_LOG_LENGTH])
#define HTC_BATT_IOCTL_SET_VOLTAGE_ALARM \
_IOW(HTC_BATT_IOCTL_MAGIC, 8, struct battery_vol_alarm)
#define HTC_BATT_IOCTL_SET_ALARM_TIMER_FLAG \
_IOW(HTC_BATT_IOCTL_MAGIC, 9, unsigned int)
#define REGULAR_BATTERRY_TIMER "regular_timer"
#define CABLE_DETECTION "cable"
#define CHARGER_IC_INTERRUPT "charger_int"
#define XOADC_MPP 0
#define PM_MPP_AIN_AMUX 1
#define MBAT_IN_LOW_TRIGGER 0
#define MBAT_IN_HIGH_TRIGGER 1
extern int radio_set_cable_status(int charger_type);
struct battery_adc_reply {
u32 adc_voltage[ADC_REPLY_ARRAY_SIZE];
u32 adc_current[ADC_REPLY_ARRAY_SIZE];
u32 adc_temperature[ADC_REPLY_ARRAY_SIZE];
u32 adc_battid[ADC_REPLY_ARRAY_SIZE];
};
struct mpp_config_data {
u32 vol[2];
u32 curr[2];
u32 temp[2];
u32 battid[2];
};
struct battery_vol_alarm {
int lower_threshold;
int upper_threshold;
int enable;
};
/* information about the system we're running on */
extern unsigned int system_rev;
enum {
GUAGE_NONE,
GUAGE_MODEM,
GUAGE_DS2784,
GUAGE_DS2746,
GUAGE_BQ27510,
};
enum {
LINEAR_CHARGER,
SWITCH_CHARGER_TPS65200,
};
enum {
BATT_TIMER_WAKE_LOCK = 0,
BATT_IOCTL_WAKE_LOCK,
};
enum {
HTC_BATT_DEBUG_UEVT = 1U << 1,
HTC_BATT_DEBUG_USER_QUERY = 1U << 2,
HTC_BATT_DEBUG_USB_NOTIFY = 1U << 3,
HTC_BATT_DEBUG_FULL_LOG = 1U << 4,
};
struct htc_battery_platform_data {
int gpio_mbat_in;
int gpio_mbat_in_trigger_level;
int gpio_mchg_en_n;
int gpio_iset;
int gpio_adp_9v;
int guage_driver;
int charger;
struct mpp_config_data mpp_data;
int chg_limit_active_mask;
int critical_low_voltage_mv;
int critical_alarm_voltage_mv;
struct htc_gauge igauge;
struct htc_charger icharger;
};
enum {
BATT_ALARM_DISABLE_MODE,
BATT_ALARM_NORMAL_MODE,
BATT_ALARM_CRITICAL_MODE,
};
#endif
|
//=============================================================================
// File : Tdmb_modeldef.h
//
// Description:
//
// Revision History:
//
// Version Date Author Description of Changes
//-----------------------------------------------------------------------------
// 1.0.0 2010/12/06 yschoi Create
// (tdmb_dev.h, tdmb_comdef.h ¿¡¼ ºÐ¸®)
//=============================================================================
#ifndef _TDMB_MODELDEF_INCLUDES_H_
#define _TDMB_MODELDEF_INCLUDES_H_
/*================================================================== */
/*================ MODEL FEATURE ================= */
/*================================================================== */
/////////////////////////////////////////////////////////////////////////
// TDMB GPIO (depend on model H/W)
// Áߺ¹µÇ¾î define µÈ ¸ðµ¨ÀÌ ÀÖÀ¸¹Ç·Î »ç¿ëÇÏ´Â ¸ðµ¨À» ¸Ç¾ÕÀ¸·Î °¡Á®¿Â´Ù.
/////////////////////////////////////////////////////////////////////////
#if defined(CONFIG_EF10_BOARD)
#define DMB_RESET 155
#define DMB_INT 98
//#define DMB_PWR_EN 57 // not used
#define DMB_ANT_SEL 58
#define DMB_ANT_EAR_ACT 1 // Earjack active (1 : High, 0 : low)
#define FEATURE_TDMB_SET_ANT_PATH
#define FEATURE_TDMB_PMIC_POWER
#elif defined(CONFIG_SP33_BOARD)
#define DMB_RESET 23
#define DMB_INT 18
#define DMB_PWR_EN 26
#define DMB_ANT_SEL 72
#define DMB_ANT_EAR_ACT 1 // Earjack High active
#define FEATURE_TDMB_SET_ANT_PATH
#elif defined(CONFIG_EF12_BOARD)
#define DMB_RESET 155
#define DMB_INT 98
//#define DMB_PWR_EN 57 // not used
//#define DMB_ANT_SEL 58 // not used
//#define DMB_ANT_EAR_ACT 1 // not used
//#define FEATURE_TDMB_SET_ANT_PATH
#define FEATURE_TDMB_PMIC_POWER
#elif defined(CONFIG_EF13_BOARD)
#define DMB_RESET 87
#define DMB_INT 84
#define DMB_PWR_EN 85
#define DMB_ANT_SEL 79
#define DMB_ANT_EAR_ACT 0 // Earjack Low active
#define FEATURE_TDMB_SET_ANT_PATH
#elif defined(CONFIG_EF14_BOARD)
#define DMB_RESET 155
#define DMB_INT 152
#define DMB_PWR_EN 151
#define DMB_ANT_SEL 21
#define DMB_ANT_EAR_ACT 1
#define FEATURE_TDMB_SET_ANT_PATH
#elif defined(CONFIG_EF18_BOARD)
#define DMB_RESET 163
#define DMB_INT 40
#define DMB_PWR_EN 164
#define DMB_ANT_SEL 172
#define DMB_ANT_EAR_ACT 0
#define FEATURE_TDMB_SET_ANT_PATH
#elif defined(CONFIG_EF31S_32K_BOARD)
#define DMB_RESET 26
#define DMB_INT 30
#define DMB_PWR_EN 106
#define DMB_I2C_SDA 28
#define DMB_I2C_SCL 29
#define FEATURE_TDMB_PMIC_POWER
#define FEATURE_TDMB_TSIF_CLK_CTL
#define FEATURE_TDMB_GPIO_INIT
#elif (defined(CONFIG_EF33_BOARD) || defined(CONFIG_EF34_BOARD)) || defined(IS_AT1) /*jjw*/
#define DMB_RESET 129
#define DMB_INT 127
#define DMB_PWR_EN 136
#define DMB_I2C_SCL 73
#define DMB_I2C_SDA 72
#if 0 // AT1 need not, jjw
#if (EF33S_BDVER_L(WS20) || EF34K_BDVER_L(WS20)) // Since WS20 use only retractable Antenna
#define FEATURE_TDMB_SET_ANT_PATH
#define DMB_ANT_SEL 42
#define DMB_ANT_EAR_ACT 1
#endif
#endif
//#define FEATURE_TDMB_PMIC_POWER
#define FEATURE_TDMB_GPIO_INIT
#elif defined(CONFIG_EF35_BOARD)
#define DMB_RESET 129
#define DMB_INT 127
#define DMB_PWR_EN 136
#define DMB_I2C_SCL 73
#define DMB_I2C_SDA 72
#if EF35L_BDVER_GE(TP10) //PMIC TCXO 19.2M
#define FEATURE_TDMB_PMIC_TCXO_192M
#define DMB_XO_SEL 42
#else
#define FEATURE_TDMB_SET_ANT_PATH
#define DMB_ANT_SEL 42
#define DMB_ANT_EAR_ACT 1
#endif
//#define FEATURE_TDMB_PMIC_POWER
#define FEATURE_TDMB_GPIO_INIT
#elif defined(CONFIG_EF40_BOARD)
#define DMB_RESET 129
#define DMB_INT 127
#define DMB_PWR_EN 136
#define DMB_I2C_SCL 73
#define DMB_I2C_SDA 72
#define FEATURE_TDMB_SET_ANT_PATH
#define DMB_ANT_SEL 42
#define DMB_ANT_EAR_ACT 1
//#define FEATURE_TDMB_PMIC_POWER
#define FEATURE_TDMB_GPIO_INIT
#else
#error
#endif
/*================================================================== */
/*================ TEST FEATURE ================= */
/*================================================================== */
//#define FEATURE_TS_PKT_MSG // Single CH : ¸ðµç ÆÐŶÀ» º¸¿©ÁÜ, Mulch CH : ÀÐÀº µ¥ÀÌÅÍÀÇ Ã¹ ÆÐŶ¸¸ º¸¿©ÁÜ.
//#define FEATURE_TEST_ON_BOOT
//#define FEATURE_NETBER_TEST_ON_BOOT
//#define FEATURE_NETBER_TEST_ON_AIR
//#define FEATURE_APP_CALL_TEST_FUNC
//#define FEAUTRE_USE_FIXED_FIC_DATA
//#define FEATURE_GPIO_DEBUG
//#define FEATURE_COMMAND_TEST_ON_BOOT
//#define FEATURE_I2C_WRITE_CHECK
//#define FEATURE_I2C_DBG_MSG
//#define FEATURE_EBI_WRITE_CHECK
//#define FEATURE_HW_INPUT_MATCHING_TEST
#ifdef CONFIG_SKY_TDMB_INC_BB
#if (defined(FEATURE_TEST_ON_BOOT) || defined(FEATURE_NETBER_TEST_ON_BOOT) || defined(FEATURE_APP_CALL_TEST_FUNC))
#define INC_FICDEC_USE // Å×½ºÆ®½Ã ä³ÎÁ¤º¸µéÀÌ Á¤È®ÇÏÁö ¾ÊÀ»¶§ ÇÊ¿ä
#define FEATURE_INC_FIC_UPDATE_MSG
#endif
#endif /* CONFIG_SKY_TDMB_INC_BB */
#endif /* _TDMB_MODELDEF_INCLUDES_H_ */
|
/* search_frame.h
*
* $Id: search_frame.h 46591 2012-12-18 17:21:20Z gerald $
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef SEARCH_FRAME_H
#define SEARCH_FRAME_H
#include <config.h>
#include "accordion_frame.h"
#include "cfile.h"
namespace Ui {
class SearchFrame;
}
class SearchFrame : public AccordionFrame
{
Q_OBJECT
public:
explicit SearchFrame(QWidget *parent = 0);
~SearchFrame();
void animatedShow();
void findNext();
void findPrevious();
public slots:
void setCaptureFile(capture_file *cf);
void findFrameWithFilter(QString &filter);
signals:
void pushFilterSyntaxStatus(QString&);
protected:
void keyPressEvent(QKeyEvent *event);
private:
void enableWidgets();
Ui::SearchFrame *sf_ui_;
capture_file *cap_file_;
private slots:
void on_searchTypeComboBox_currentIndexChanged(int index);
void on_searchLineEdit_textChanged(const QString &search_string);
void on_findButton_clicked();
void on_cancelButton_clicked();
};
#endif // SEARCH_FRAME_H
|
#ifndef gsm0480_h
#define gsm0480_h
#include <osmocom/core/msgb.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <osmocom/gsm/protocol/gsm_04_80.h>
#define MAX_LEN_USSD_STRING 31
struct ussd_request {
uint8_t text[MAX_LEN_USSD_STRING + 1];
uint8_t transaction_id;
uint8_t invoke_id;
};
int gsm0480_decode_ussd_request(const struct gsm48_hdr *hdr, uint16_t len,
struct ussd_request *request);
struct msgb *gsm0480_create_ussd_resp(uint8_t invoke_id, uint8_t trans_id, const char *text);
struct msgb *gsm0480_create_unstructuredSS_Notify(int alertPattern, const char *text);
struct msgb *gsm0480_create_notifySS(const char *text);
int gsm0480_wrap_invoke(struct msgb *msg, int op, int link_id);
int gsm0480_wrap_facility(struct msgb *msg);
#endif
|
// **********************************************************************
//
// Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
#ifndef CALLBACK_I_H
#define CALLBACK_I_H
#include <IceUtil/Mutex.h>
#include <IceUtil/Monitor.h>
#include <Callback.h>
#include <vector>
class CallbackReceiverI : public ::Test::CallbackReceiver, public IceUtil::Monitor<IceUtil::Mutex>
{
public:
CallbackReceiverI();
virtual void callback(int token, const Ice::Current&);
virtual void callbackWithPayload(const Ice::ByteSeq&, const ::Ice::Current&);
int callbackOK(int, int);
int callbackWithPayloadOK(int);
void hold();
void activate();
private:
void checkForHold();
bool _holding;
int _lastToken;
int _callback;
int _callbackWithPayload;
};
typedef IceUtil::Handle<CallbackReceiverI> CallbackReceiverIPtr;
class CallbackI : public ::Test::Callback
{
public:
CallbackI();
virtual void initiateCallback_async(const ::Test::AMD_Callback_initiateCallbackPtr&,
const ::Test::CallbackReceiverPrx&, int, const Ice::Current&);
virtual void initiateCallbackWithPayload_async(const ::Test::AMD_Callback_initiateCallbackWithPayloadPtr&,
const ::Test::CallbackReceiverPrx&,
const ::Ice::Current&);
virtual void shutdown(const Ice::Current&);
};
#endif
|
/*
Copyright 1989, 1994, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
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
OPEN GROUP 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.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/*
* This is a List widget. It allows the user to select an item in a list and
* notifies the application through a callback function.
*
* Created: 8/13/88
* By: Chris D. Peterson
* MIT - Project Athena
*/
#ifndef _XawListP_h
#define _XawListP_h
/*
* List Widget Private Data
*/
#include <X11/Xaw/SimpleP.h>
#include <X11/Xaw/List.h>
#define NO_HIGHLIGHT XAW_LIST_NONE
#define OUT_OF_RANGE -1
#define OKAY 0
/* New fields for the List widget class */
typedef struct {
XtPointer extension;
} ListClassPart;
/* Full class record */
typedef struct _ListClassRec {
CoreClassPart core_class;
SimpleClassPart simple_class;
ListClassPart list_class;
} ListClassRec;
extern ListClassRec listClassRec;
/* New fields for the List widget */
typedef struct {
/* resources */
Pixel foreground;
Dimension internal_width; /* if not 3d, user sets directly */
Dimension internal_height;
Dimension column_space; /* half of *_space is add on
top/bot/left of */
Dimension row_space; /* each item's text bounding box
half added to longest for right */
int default_cols;
Boolean force_cols;
Boolean paste;
Boolean vertical_cols;
int longest; /* in pixels */
int nitems;
XFontStruct *font;
XFontSet fontset; /* Sheeran, Omron KK, 93/03/05 */
String *list; /* for i18n, always in multibyte
format */
XtCallbackList callback;
/* private */
int is_highlighted; /* set to the item currently
highlighted */
int highlight; /* set to the item that should be
highlighted */
int col_width; /* width of each column */
int row_height; /* height of each row */
int nrows; /* number of rows in the list */
int ncols; /* number of columns in the list */
GC normgc;
GC revgc;
GC graygc;
int freedoms; /* flags for resizing height
and width */
#ifndef OLDXAW
int selected;
Boolean show_current;
char pad1[(sizeof(XtPointer) - sizeof(Boolean)) +
(sizeof(XtPointer) - sizeof(int))];
XtPointer pad2[2]; /* for future use and keep binary compatability */
#endif
} ListPart;
/* Full instance record */
typedef struct _ListRec {
CorePart core;
SimplePart simple;
ListPart list;
} ListRec;
#endif /* _XawListP_h */
|
/*
This file is part of KOrganizer.
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef URIHANDLER_H
#define URIHANDLER_H
#include "korganizer_export.h"
#include <QString>
class KORGANIZER_EVENTVIEWER_EXPORT UriHandler
{
public:
/**
Process URI (e.g. open mailer, open browser, open incidence viewer etc.).
@return true if handler handled the URI, otherwise false.
@param uri The URI of the link that should be handled.
*/
static bool process( const QString &uri );
};
#endif
|
/*
* This file is part of the coreboot project.
*
* Copyright (C) 2004 Tyan Computer
* Written by Yinghai Lu <yhlu@tyan.com> for Tyan Computer.
*
* 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; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef SOUTHBRIDGE_NVIDIA_CK804_CHIP_H
#define SOUTHBRIDGE_NVIDIA_CK804_CHIP_H
struct southbridge_nvidia_ck804_config {
unsigned int usb1_hc_reset : 1;
unsigned int ide0_enable : 1;
unsigned int ide1_enable : 1;
unsigned int sata0_enable : 1;
unsigned int sata1_enable : 1;
unsigned int mac_eeprom_smbus;
unsigned int mac_eeprom_addr;
};
struct chip_operations;
extern struct chip_operations southbridge_nvidia_ck804_ops;
#endif
|
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
Contributing author: Hasan Metin Aktulga, Purdue University
(now at Lawrence Berkeley National Laboratory, hmaktulga@lbl.gov)
Please cite the related publication:
H. M. Aktulga, J. C. Fogarty, S. A. Pandit, A. Y. Grama,
"Parallel Reactive Molecular Dynamics: Numerical Methods and
Algorithmic Techniques", Parallel Computing, in press.
------------------------------------------------------------------------- */
#ifdef PAIR_CLASS
PairStyle(reax/c,PairReaxC)
#else
#ifndef LMP_PAIR_REAXC_H
#define LMP_PAIR_REAXC_H
#include "pair.h"
#include "reaxc_types.h"
namespace LAMMPS_NS {
class PairReaxC : public Pair {
public:
int fixbond_flag, fixspecies_flag;
int **tmpid;
double **tmpbo,**tmpr;
double *chi,*eta,*gamma;
int *map;
control_params *control;
reax_system *system;
output_controls *out_control;
simulation_data *data;
storage *workspace;
reax_list *lists;
mpi_datatypes *mpi_data;
PairReaxC(class LAMMPS *);
~PairReaxC();
void compute(int, int);
void settings(int, char **);
void coeff(int, char **);
void init_style();
double init_one(int, int);
void *extract(const char *, int &);
protected:
double cutmax;
int nelements; // # of unique elements
char **elements; // names of unique elements
class FixReaxC *fix_reax;
int qeqflag;
int setup_flag;
int firstwarn;
void allocate();
void setup();
void create_compute();
void create_fix();
void write_reax_atoms();
void get_distance(rvec, rvec, double *, rvec *);
void set_far_nbr(far_neighbor_data *, int, double, rvec);
int estimate_reax_lists();
int write_reax_lists();
void read_reax_forces(int);
int nmax;
void FindBond();
double memory_usage();
};
}
#endif
#endif
/* ERROR/WARNING messages:
E: Too many ghost atoms
Number of ghost atoms has increased too much during simulation and has exceeded
the size of reax/c arrays. Increase safe_zone and min_cap in pair_style reax/c
command
*/
|
/*
* Copyright (C) 2010-2011 Freescale Semiconductor, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
extern struct platform_device mxc_fec_device;
extern struct platform_device mxc_ptp_device;
extern struct platform_device mxc_dma_device;
extern struct platform_device mxc_w1_master_device;
extern struct platform_device mxc_keypad_device;
extern struct platform_device mxc_powerkey_device;
extern struct platform_device mxc_rtc_device;
extern struct platform_device mxc_nandv2_mtd_device;
extern struct platform_device imx_nfc_device;
extern struct platform_device mxc_wdt_device;
extern struct platform_device mxc_pwm1_device;
extern struct platform_device mxc_pwm2_device;
extern struct platform_device mxc_pwm1_backlight_device;
extern struct platform_device mxc_pwm2_backlight_device;
extern struct platform_device mxc_flexcan0_device;
extern struct platform_device mxc_flexcan1_device;
extern struct platform_device mxc_ipu_device;
extern struct platform_device mxc_fb_devices[];
extern struct platform_device mxc_ldb_device;
extern struct platform_device mxcvpu_device;
extern struct platform_device mxcscc_device;
extern struct platform_device mxcspi1_device;
extern struct platform_device mxcspi2_device;
extern struct platform_device mxcspi3_device;
extern struct platform_device mxci2c_devices[];
extern struct platform_device mxci2c_hs_device;
extern struct platform_device mxc_tve_device;
extern struct platform_device mxc_dvfs_core_device;
extern struct platform_device mxc_dvfs_per_device;
extern struct platform_device mxc_ssi1_device;
extern struct platform_device mxc_ssi2_device;
extern struct platform_device mxc_ssi3_device;
extern struct platform_device mxc_esai_device;
extern struct platform_device mxc_alsa_spdif_device;
extern struct platform_device mx51_lpmode_device;
extern struct platform_device mx53_lpmode_device;
extern struct platform_device busfreq_device;
extern struct platform_device sdram_autogating_device;
extern struct platform_device mxc_iim_device;
extern struct platform_device mxc_sim_device;
extern struct platform_device mxcsdhc1_device;
extern struct platform_device mxcsdhc2_device;
extern struct platform_device mxcsdhc3_device;
extern struct platform_device ahci_fsl_device;
extern struct ahci_platform_data sata_data;
extern struct platform_device pata_fsl_device;
extern struct platform_device fsl_otp_device;
extern struct platform_device gpu_device;
extern struct platform_device mxc_android_pmem_device;
extern struct platform_device mxc_android_pmem_gpu_device;
extern struct platform_device android_usb_device;
extern struct platform_device usb_mass_storage_device;
extern struct platform_device usb_rndis_device;
extern struct platform_device mxc_usbdr_udc_device;
extern struct platform_device mxc_usbdr_otg_device;
extern struct platform_device mxc_usbdr_host_device;
extern struct platform_device mxc_usbdr_wakeup_device;
extern struct platform_device mxc_usbh1_device;
extern struct platform_device mxc_usbh1_wakeup_device;
extern struct platform_device mxc_usbh2_device;
extern struct platform_device mxc_usbh2_wakeup_device;
extern struct platform_device mxc_mlb_device;
extern struct platform_device mxc_nandv2_mtd_device;
extern struct platform_device mxc_pxp_device;
extern struct platform_device mxc_pxp_client_device;
extern struct platform_device mxc_pxp_v4l2;
extern struct platform_device epdc_device;
extern struct platform_device elcdif_device;
extern struct platform_device mxc_v4l2_device;
extern struct platform_device mxc_v4l2out_device;
extern struct platform_device mxs_viim;
extern struct platform_device mxs_dma_apbh_device;
extern struct platform_device gpmi_nfc_device;
extern struct platform_device mxc_rngb_device;
extern struct platform_device dcp_device;
extern struct platform_device pm_device;
extern struct platform_device fixed_volt_reg_device;
extern struct platform_device mxc_zq_calib_device;
extern struct platform_device mxc_asrc_device;
extern struct platform_device mxc_perfmon;
extern struct mxs_platform_perfmon_data mxc_perfmon_data;
extern struct mxc_gpu_platform_data gpu_data;
|
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* 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.
*
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/msm_tsens.h>
#include <linux/workqueue.h>
#include <linux/cpu.h>
#include <linux/cpufreq.h>
#include <linux/msm_tsens.h>
#include <linux/msm_thermal.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <mach/cpufreq.h>
static unsigned int temp_threshold = 65;
module_param(temp_threshold, int, 0755);
static unsigned int temp_scan_interval = 500;
module_param(temp_scan_interval, int, 0755);
extern uint32_t ex_max_freq;
static struct thermal_info {
uint32_t cpuinfo_max_freq;
uint32_t limited_max_freq;
unsigned int safe_diff;
bool throttling;
bool pending_change;
} info = {
.cpuinfo_max_freq = LONG_MAX,
.limited_max_freq = LONG_MAX,
.safe_diff = 5,
.pending_change = false,
.throttling = false,
};
enum thermal_freqs {
FREQ_HELL = 702000,
FREQ_VERY_HOT = 918000,
FREQ_HOT = 1026000,
FREQ_WARM = 1242000,
};
enum threshold_levels {
LEVEL_HELL = 12,
LEVEL_VERY_HOT = 9,
LEVEL_HOT = 5,
};
static struct msm_thermal_data msm_thermal_info;
static struct delayed_work check_temp_work;
unsigned short get_threshold(void)
{
return temp_threshold;
}
static int msm_thermal_cpufreq_callback(struct notifier_block *nfb,
unsigned long event, void *data)
{
struct cpufreq_policy *policy = data;
if (event != CPUFREQ_ADJUST && !info.pending_change)
return 0;
cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq,
info.limited_max_freq);
return 0;
}
static struct notifier_block msm_thermal_cpufreq_notifier = {
.notifier_call = msm_thermal_cpufreq_callback,
};
static void limit_cpu_freqs(uint32_t max_freq)
{
unsigned int cpu;
if (info.limited_max_freq == max_freq)
return;
info.limited_max_freq = max_freq;
info.pending_change = true;
get_online_cpus();
for_each_online_cpu(cpu)
{
cpufreq_update_policy(cpu);
pr_info("%s: Setting cpu%d max frequency to %d\n",
KBUILD_MODNAME, cpu, info.limited_max_freq);
}
put_online_cpus();
info.pending_change = false;
}
static void check_temp(struct work_struct *work)
{
struct tsens_device tsens_dev;
uint32_t freq = 0;
long temp = 0;
tsens_dev.sensor_num = 0;
tsens_get_temp(&tsens_dev, &temp);
if (info.throttling)
{
if (temp < (temp_threshold - info.safe_diff))
{
restore_ex_max_freq();
info.cpuinfo_max_freq = ex_max_freq;
limit_cpu_freqs(info.cpuinfo_max_freq);
info.throttling = false;
goto reschedule;
}
}
if (temp >= temp_threshold + LEVEL_HELL)
freq = FREQ_HELL;
else if (temp >= temp_threshold + LEVEL_VERY_HOT)
freq = FREQ_VERY_HOT;
else if (temp >= temp_threshold + LEVEL_HOT)
freq = FREQ_HOT;
else if (temp > temp_threshold)
freq = FREQ_WARM;
if (freq)
{
limit_cpu_freqs(freq);
if (!info.throttling)
info.throttling = true;
}
reschedule:
schedule_delayed_work_on(0, &check_temp_work, msecs_to_jiffies(temp_scan_interval));
}
int __devinit msm_thermal_init(struct msm_thermal_data *pdata)
{
int ret = 0;
BUG_ON(!pdata);
BUG_ON(pdata->sensor_id >= TSENS_MAX_SENSORS);
memcpy(&msm_thermal_info, pdata, sizeof(struct msm_thermal_data));
cpufreq_register_notifier(&msm_thermal_cpufreq_notifier,
CPUFREQ_POLICY_NOTIFIER);
INIT_DELAYED_WORK(&check_temp_work, check_temp);
schedule_delayed_work_on(0, &check_temp_work, 0);
return ret;
}
static int __devinit msm_thermal_dev_probe(struct platform_device *pdev)
{
int ret = 0;
char *key = NULL;
struct device_node *node = pdev->dev.of_node;
struct msm_thermal_data data;
memset(&data, 0, sizeof(struct msm_thermal_data));
key = "qcom,sensor-id";
ret = of_property_read_u32(node, key, &data.sensor_id);
if (ret)
goto fail;
WARN_ON(data.sensor_id >= TSENS_MAX_SENSORS);
fail:
if (ret)
pr_err("%s: Failed reading node=%s, key=%s\n",
__func__, node->full_name, key);
else
ret = msm_thermal_init(&data);
return ret;
}
static struct of_device_id msm_thermal_match_table[] = {
{.compatible = "qcom,msm-thermal"},
{},
};
static struct platform_driver msm_thermal_device_driver = {
.probe = msm_thermal_dev_probe,
.driver = {
.name = "msm-thermal",
.owner = THIS_MODULE,
.of_match_table = msm_thermal_match_table,
},
};
int __init msm_thermal_device_init(void)
{
return platform_driver_register(&msm_thermal_device_driver);
}
|
/*
* This file is part of the UCB release of Plan 9. It is subject to the license
* terms in the LICENSE file found in the top-level directory of this
* distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
* part of the UCB release of Plan 9, including this file, may be copied,
* modified, propagated, or distributed except according to the terms contained
* in the LICENSE file.
*/
#ifndef __SIGNAL_H
#define __SIGNAL_H
#pragma lib "/$M/lib/ape/libap.a"
typedef int sig_atomic_t;
/*
* We don't give arg types for signal handlers, in spite of ANSI requirement
* that it be 'int' (the signal number), because some programs need an
* additional context argument. So the real type of signal handlers is
* void handler(int sig, char *, struct Ureg *)
* where the char * is the Plan 9 message and Ureg is defined in <ureg.h>
*/
#define SIG_DFL ((void (*)())0)
#define SIG_ERR ((void (*)())-1)
#define SIG_IGN ((void (*)())1)
#define SIGHUP 1 /* hangup */
#define SIGINT 2 /* interrupt */
#define SIGQUIT 3 /* quit */
#define SIGILL 4 /* illegal instruction (not reset when caught)*/
#define SIGABRT 5 /* used by abort */
#define SIGFPE 6 /* floating point exception */
#define SIGKILL 7 /* kill (cannot be caught or ignored) */
#define SIGSEGV 8 /* segmentation violation */
#define SIGPIPE 9 /* write on a pipe with no one to read it */
#define SIGALRM 10 /* alarm clock */
#define SIGTERM 11 /* software termination signal from kill */
#define SIGUSR1 12 /* user defined signal 1 */
#define SIGUSR2 13 /* user defined signal 2 */
#define SIGBUS 14 /* bus error */
/* The following symbols must be defined, but the signals needn't be supported */
#define SIGCHLD 15 /* child process terminated or stopped */
#define SIGCONT 16 /* continue if stopped */
#define SIGSTOP 17 /* stop */
#define SIGTSTP 18 /* interactive stop */
#define SIGTTIN 19 /* read from ctl tty by member of background */
#define SIGTTOU 20 /* write to ctl tty by member of background */
#ifdef _BSD_EXTENSION
#define NSIG 21
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern void (*signal(int, void (*)()))();
extern int raise(int);
#ifdef __cplusplus
}
#endif
#ifdef _POSIX_SOURCE
typedef long sigset_t;
struct sigaction {
void (*sa_handler)();
sigset_t sa_mask;
int sa_flags;
};
/* values for sa_flags */
#define SA_NOCLDSTOP 1
/* first argument to sigprocmask */
#define SIG_BLOCK 1
#define SIG_UNBLOCK 2
#define SIG_SETMASK 3
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __TYPES_H
extern int kill(pid_t, int);
#endif
extern int sigemptyset(sigset_t *);
extern int sigfillset(sigset_t *);
extern int sigaddset(sigset_t *, int);
extern int sigdelset(sigset_t *, int);
extern int sigismember(const sigset_t *, int);
extern int sigaction(int, const struct sigaction *, struct sigaction *);
extern int sigprocmask(int, sigset_t *, sigset_t *);
extern int sigpending(sigset_t *);
extern int sigsuspend(const sigset_t *);
#ifdef __cplusplus
}
#endif
#endif /* _POSIX_SOURCE */
#endif /* __SIGNAL_H */
|
#define BAD_MAGIC(q,m) 0
int __queue_add(Queue_t *queue, Scsi_Cmnd *SCpnt, int head)
{
if (BAD_MAGIC(1,12))
BUG();
}
|
/*
MobileRobots Advanced Robotics Interface for Applications (ARIA)
Copyright (C) 2004, 2005 ActivMedia Robotics LLC
Copyright (C) 2006, 2007, 2008, 2009 MobileRobots Inc.
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
If you wish to redistribute ARIA under different terms, contact
MobileRobots for information about a commercial version of ARIA at
robots@mobilerobots.com or
MobileRobots Inc, 10 Columbia Drive, Amherst, NH 03031; 800-639-9481
*/
#ifndef ARROBOTPACKETRECEIVER_H
#define ARROBOTPACKETRECEIVER_H
#include "ariaTypedefs.h"
#include "ArRobotPacket.h"
class ArDeviceConnection;
/// Given a device connection it receives packets from the robot through it
class ArRobotPacketReceiver
{
public:
/// Constructor without an already assigned device connection
AREXPORT ArRobotPacketReceiver(bool allocatePackets = false,
unsigned char sync1 = 0xfa,
unsigned char sync2 = 0xfb);
/// Constructor with assignment of a device connection
AREXPORT ArRobotPacketReceiver(ArDeviceConnection *deviceConnection,
bool allocatePackets = false,
unsigned char sync1 = 0xfa,
unsigned char sync2 = 0xfb);
/// Destructor
AREXPORT virtual ~ArRobotPacketReceiver();
/// Receives a packet from the robot if there is one available
AREXPORT ArRobotPacket *receivePacket(unsigned int msWait = 0);
/// Sets the device this instance receives packets from
AREXPORT void setDeviceConnection(ArDeviceConnection *deviceConnection);
/// Gets the device this instance receives packets from
AREXPORT ArDeviceConnection *getDeviceConnection(void);
/// Gets whether or not the receiver is allocating packets
AREXPORT bool isAllocatingPackets(void) { return myAllocatePackets; }
protected:
ArDeviceConnection *myDeviceConn;
bool myAllocatePackets;
ArRobotPacket myPacket;
enum { STATE_SYNC1, STATE_SYNC2, STATE_ACQUIRE_DATA };
unsigned char mySync1;
unsigned char mySync2;
};
#endif // ARROBOTPACKETRECEIVER_H
|
/*
Unix SMB/CIFS implementation.
POSIX NTVFS backend - NT ACLs in xattrs
Copyright (C) Andrew Tridgell 2006
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "includes.h"
#include "vfs_posix.h"
#include "lib/util/unix_privs.h"
#include "librpc/gen_ndr/ndr_xattr.h"
/*
load the current ACL from extended attributes
*/
static NTSTATUS pvfs_acl_load_xattr(struct pvfs_state *pvfs, struct pvfs_filename *name, int fd,
TALLOC_CTX *mem_ctx,
struct security_descriptor **sd)
{
NTSTATUS status;
struct xattr_NTACL *acl;
if (!(pvfs->flags & PVFS_FLAG_XATTR_ENABLE)) {
return NT_STATUS_NOT_FOUND;
}
acl = talloc_zero(mem_ctx, struct xattr_NTACL);
NT_STATUS_HAVE_NO_MEMORY(acl);
status = pvfs_xattr_ndr_load(pvfs, mem_ctx, name->full_name, fd,
XATTR_NTACL_NAME,
acl,
(ndr_pull_flags_fn_t)ndr_pull_xattr_NTACL);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(acl);
return status;
}
if (acl->version != 1) {
talloc_free(acl);
return NT_STATUS_INVALID_ACL;
}
*sd = talloc_steal(mem_ctx, acl->info.sd);
return NT_STATUS_OK;
}
/*
save the acl for a file into filesystem xattr
*/
static NTSTATUS pvfs_acl_save_xattr(struct pvfs_state *pvfs, struct pvfs_filename *name, int fd,
struct security_descriptor *sd)
{
NTSTATUS status;
void *privs;
struct xattr_NTACL acl;
if (!(pvfs->flags & PVFS_FLAG_XATTR_ENABLE)) {
return NT_STATUS_OK;
}
acl.version = 1;
acl.info.sd = sd;
/* this xattr is in the "system" namespace, so we need
admin privileges to set it */
privs = root_privileges();
status = pvfs_xattr_ndr_save(pvfs, name->full_name, fd,
XATTR_NTACL_NAME,
&acl,
(ndr_push_flags_fn_t)ndr_push_xattr_NTACL);
talloc_free(privs);
return status;
}
/*
initialise pvfs acl xattr backend
*/
NTSTATUS pvfs_acl_xattr_init(void)
{
struct pvfs_acl_ops ops = {
.name = "xattr",
.acl_load = pvfs_acl_load_xattr,
.acl_save = pvfs_acl_save_xattr
};
return pvfs_acl_register(&ops);
}
|
/*
*
* Copyright (c) Crackerjack Project., 2007
* Copyright (c) 2011 Cyril Hrubis <chrubis@suse.cz>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Porting from Crackerjack to LTP is done
by Masatake YAMATO <yamato@redhat.com> */
#include "config.h"
#include "test.h"
#include "usctest.h"
char *TCID = "io_destroy01";
int TST_TOTAL = 1;
#ifdef HAVE_LIBAIO_H
#include <libaio.h>
#include <errno.h>
#include <string.h>
static void cleanup(void)
{
TEST_CLEANUP;
}
static void setup(void)
{
tst_sig(NOFORK, DEF_HANDLER, cleanup);
TEST_PAUSE;
}
/*
DESCRIPTION
io_destroy removes the asynchronous I/O context from the list of I/O
contexts and then destroys it. io_destroy can also cancel any out-
standing asynchronous I/O actions on ctx and block on completion.
RETURN VALUE
io_destroy returns 0 on success.
ERRORS
EINVAL The AIO context specified by ctx is invalid.
*/
#define EXP_RET (-EINVAL)
int main(int argc, char *argv[])
{
int lc;
char *msg;
io_context_t ctx;
memset(&ctx, 0xff, sizeof(ctx));
if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
setup();
for (lc = 0; TEST_LOOPING(lc); lc++) {
tst_count = 0;
TEST(io_destroy(ctx));
switch (TEST_RETURN) {
case 0:
tst_resm(TFAIL, "call succeeded unexpectedly");
break;
case EXP_RET:
tst_resm(TPASS, "expected failure - "
"returned value = %ld : %s", TEST_RETURN,
strerror(-TEST_RETURN));
break;
case -ENOSYS:
tst_resm(TCONF, "io_cancel returned ENOSYS");
break;
default:
tst_resm(TFAIL, "unexpected returned value - %s (%i) - "
"expected %s (%i)", strerror(-TEST_RETURN),
(int)TEST_RETURN, strerror(-EXP_RET), EXP_RET);
break;
}
}
cleanup();
tst_exit();
}
#else
int main(int argc, char *argv[])
{
tst_brkm(TCONF, NULL, "System doesn't support execution of the test");
tst_exit();
}
#endif
|
/* $NetBSD: cprojf.c,v 1.3 2010/09/20 17:51:38 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, 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:
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*
* imported and modified include for newlib 2010/10/03
* Marco Atzeri <marco_atzeri@yahoo.it>
*/
/*__RCSID("$NetBSD: cprojf.c,v 1.3 2010/09/20 17:51:38 christos Exp $"); */
#include <complex.h>
#include <math.h>
#include "../mathincl/fdlibm.h"
/*
* cprojf(float complex z)
*
* These functions return the value of the projection (not stereographic!)
* onto the Riemann sphere.
*
* z projects to z, except that all complex infinities (even those with one
* infinite part and one NaN part) project to positive infinity on the real axis.
* If z has an infinite part, then cproj(z) shall be equivalent to:
*
* INFINITY + I * copysign(0.0, cimag(z))
*/
float complex
cprojf(float complex z)
{
float_complex w = { .z = z };
if (isinff(crealf(z)) || isinff(cimagf(z))) {
#ifdef __INFINITY
REAL_PART(w) = __INFINITY;
#else
REAL_PART(w) = HUGE_VALF;
#endif
IMAG_PART(w) = copysignf(0.0, cimagf(z));
}
return (w.z);
}
|
/*****************************************************************************
* Copyright (c) 2014-2020 OpenRCT2 developers
*
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
#pragma once
#include "GameAction.h"
DEFINE_GAME_ACTION(LandSetHeightAction, GameCommand::SetLandHeight, GameActions::Result)
{
private:
CoordsXY _coords;
uint8_t _height{};
uint8_t _style{};
public:
LandSetHeightAction() = default;
LandSetHeightAction(const CoordsXY& coords, uint8_t height, uint8_t style);
uint16_t GetActionFlags() const override;
void Serialise(DataSerialiser & stream) override;
GameActions::Result::Ptr Query() const override;
GameActions::Result::Ptr Execute() const override;
private:
rct_string_id CheckParameters() const;
TileElement* CheckTreeObstructions() const;
money32 GetSmallSceneryRemovalCost() const;
void SmallSceneryRemoval() const;
rct_string_id CheckRideSupports() const;
TileElement* CheckFloatingStructures(TileElement * surfaceElement, uint8_t zCorner) const;
TileElement* CheckUnremovableObstructions(TileElement * surfaceElement, uint8_t zCorner) const;
money32 GetSurfaceHeightChangeCost(SurfaceElement * surfaceElement) const;
void SetSurfaceHeight(TileElement * surfaceElement) const;
/**
*
* rct2: 0x00663CB9
*/
static int32_t map_set_land_height_clear_func(
TileElement * *tile_element, [[maybe_unused]] const CoordsXY& coords, [[maybe_unused]] uint8_t flags,
[[maybe_unused]] money32* price);
};
|
#pragma once
#include "AP_RangeFinder.h"
#include "AP_RangeFinder_Backend_Serial.h"
// WASP 200 LRF
// http://www.attolloengineering.com/wasp-200-lrf.html
class AP_RangeFinder_Wasp : public AP_RangeFinder_Backend_Serial {
public:
AP_RangeFinder_Wasp(RangeFinder::RangeFinder_State &_state,
AP_RangeFinder_Params &_params);
void update(void) override;
static const struct AP_Param::GroupInfo var_info[];
protected:
// Wasp is always 115200
uint32_t initial_baudrate(uint8_t serial_instance) const override {
return 115200;
}
MAV_DISTANCE_SENSOR _get_mav_distance_sensor_type() const override {
return MAV_DISTANCE_SENSOR_LASER;
}
private:
enum wasp_configuration_stage {
WASP_CFG_RATE, // set the baudrate
WASP_CFG_ENCODING, // set the encoding to LBE
WASP_CFG_PROTOCOL, // set the protocol type used
WASP_CFG_FRQ, // set the update frequency
WASP_CFG_GO, // start/resume readings
WASP_CFG_AUT, // set the auto sensitivity threshold
WASP_CFG_THR, // set the sensitivity threshold
WASP_CFG_MAVG, // set the moving average filter
WASP_CFG_MEDF, // set the median filter windows size
WASP_CFG_AVG, // set the multi-pulse averages
WASP_CFG_AUV, // enforce auto voltage
WASP_CFG_DONE // done configuring
};
wasp_configuration_stage configuration_state = WASP_CFG_PROTOCOL;
bool get_reading(uint16_t &reading_cm) override;
void parse_response(void);
char linebuf[10];
uint8_t linebuf_len;
AP_Int16 mavg;
AP_Int16 medf;
AP_Int16 frq;
AP_Int16 avg;
AP_Int16 thr;
AP_Int8 baud;
};
|
/*
* Generated by asn1c-0.9.24 (http://lionet.info/asn1c)
* From ASN.1 module "InformationElements"
* found in "../asn/InformationElements.asn"
* `asn1c -fcompound-names -fnative-types`
*/
#ifndef _UL_CCTrCH_H_
#define _UL_CCTrCH_H_
#include <asn_application.h>
/* Including external dependencies */
#include "TFCS-IdentityPlain.h"
#include "UL-TargetSIR.h"
#include "TimeInfo.h"
#include <constr_SEQUENCE.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Forward declarations */
struct CommonTimeslotInfo;
struct UplinkTimeslotsCodes;
/* UL-CCTrCH */
typedef struct UL_CCTrCH {
TFCS_IdentityPlain_t *tfcs_ID /* DEFAULT 1 */;
UL_TargetSIR_t ul_TargetSIR;
TimeInfo_t timeInfo;
struct CommonTimeslotInfo *commonTimeslotInfo /* OPTIONAL */;
struct UplinkTimeslotsCodes *ul_CCTrCH_TimeslotsCodes /* OPTIONAL */;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} UL_CCTrCH_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_UL_CCTrCH;
#ifdef __cplusplus
}
#endif
/* Referred external types */
#include "CommonTimeslotInfo.h"
#include "UplinkTimeslotsCodes.h"
#endif /* _UL_CCTrCH_H_ */
#include <asn_internal.h>
|
/*
* Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2008, 2011
* Tama Communications Corporation
* #ifdef __DJGPP__
* Contributed by Jason Hood <jadoxa@yahoo.com.au>, 2001.
# #endif
*
* This file is part of GNU GLOBAL.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#else
#include <strings.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#ifdef __DJGPP__
#include <fcntl.h> /* for _USE_LFN */
#endif
#include "gparam.h"
#include "path.h"
#include "strbuf.h"
#include "strlimcpy.h"
#include "test.h"
/**
* isabspath: whether absolute path or not
*
* @param[in] p path
* @return 1: absolute, 0: not absolute
*/
int
isabspath(const char *p)
{
if (p[0] == '/')
return 1;
#if defined(_WIN32) || defined(__DJGPP__)
if (p[0] == '\\')
return 1;
if (isdrivechar(p[0]) && p[1] == ':' && (p[2] == '\\' || p[2] == '/'))
return 1;
#endif
return 0;
}
/**
* canonpath: make canonical path name.
*
* @param[in,out] path path
* @return path
*
* @attention canonpath() rewrite argument buffer.
*/
char *
canonpath(char *path)
{
#ifdef __DJGPP__
char *p;
if (_USE_LFN) {
char name[260], sfn[13];
char *base;
/*
* Ensure we're using a complete long name, not a mixture
* of long and short.
*/
_truename(path, path);
/*
* _truename will successfully convert the path of a non-
* existant file, but it's probably still a mixture of long and
* short components - convert the path separately.
*/
if (access(path, F_OK) != 0) {
base = basename(path);
strcpy(name, base);
*base = '\0';
_truename(path, path);
strcat(path, name);
}
/*
* Convert the case of 8.3 names, as other djgpp functions do.
*/
if (!_preserve_fncase()) {
for (p = path+3, base = p-1; *base; p++) {
if (*p == '\\' || *p == '\0') {
memcpy(name, base+1, p-base-1);
name[p-base-1] = '\0';
if (!strcmp(_lfn_gen_short_fname(name, sfn), name)) {
while (++base < p)
if (*base >= 'A' && *base <= 'Z')
*base += 'a' - 'A';
} else
base = p;
}
}
}
}
/*
* Lowercase the drive letter and convert to slashes.
*/
path[0] = tolower(path[0]);
for (p = path+2; *p; ++p)
if (*p == '\\')
*p = '/';
#else
#ifdef _WIN32
char *p, *s;
p = path;
/*
* Change \ to / in a path (for DOS/Windows paths)
*/
while ((p = strchr(p, '\\')) != NULL)
*p = '/';
#ifdef __CYGWIN__
/*
* On NT with CYGWIN, getcwd can return something like
* "//c/tmp", which isn't usable. We change that to "c:/tmp".
*/
p = path;
if (p[0] == '/' && p[1] == '/' && isdrivechar(p[2]) && p[3] == '/') {
s = &p[2]; /* point drive char */
*p++ = *s++;
*p++ = ':';
while (*p++ = *s++)
;
}
#endif /* __CYGWIN__ */
#endif /* _WIN32 */
#endif /* __DJGPP__ */
return path;
}
#if (defined(_WIN32) && !defined(__CYGWIN__)) || defined(__DJGPP__)
/**
* realpath: get the complete path
*/
char *
realpath(const char *in_path, char *out_path)
{
#ifdef __DJGPP__
/*
* I don't use _fixpath or _truename in LFN because neither guarantee
* a complete long name. This is mainly DOS's fault, since the cwd can
* be a mixture of long and short components.
*/
if (_USE_LFN) {
strlimcpy(out_path, in_path, MAXPATHLEN);
canonpath(out_path);
} else
_fixpath(in_path, out_path);
#else
_fullpath(out_path, in_path, MAXPATHLEN);
canonpath(out_path);
#endif
return out_path;
}
#endif
#define SEP '/'
/**
* makedirectories: make directories on the path like @XREF{mkdir,1} with the @OPTION{-p} option.
*
* @param[in] base base directory
* @param[in] rest path from the base
* @param[in] verbose 1: verbose mode, 0: not verbose mode
* @return 0: success <br>
* -1: base directory not found <br>
* -2: permission error <br>
* -3: cannot make directory
*/
int
makedirectories(const char *base, const char *rest, int verbose)
{
STRBUF *sb;
const char *p, *q;
if (!test("d", base))
return -1;
if (!test("drw", base))
return -2;
sb = strbuf_open(0);
strbuf_puts(sb, base);
if (*rest == SEP)
rest++;
for (q = rest; *q;) {
p = q;
while (*q && *q != SEP)
q++;
strbuf_putc(sb, SEP);
strbuf_nputs(sb, p, q - p);
p = strbuf_value(sb);
if (!test("d", p)) {
if (verbose)
fprintf(stderr, " Making directory '%s'.\n", p);
#if defined(_WIN32) && !defined(__CYGWIN__)
if (mkdir(p) < 0) {
#else
if (mkdir(p, 0775) < 0) {
#endif /* WIN32 */
strbuf_close(sb);
return -3;
}
}
if (*q == SEP)
q++;
}
strbuf_close(sb);
return 0;
}
/**
* trimpath: trim path name
*/
const char *
trimpath(const char *path)
{
if (*path == '.' && *(path + 1) == '/')
path += 2;
return path;
}
|
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include <Python.h>
#include "HeadSpin.h"
#include <string>
class plFileName;
namespace PythonInterface
{
void initPython(const plFileName& rootDir);
void finiPython();
// So the Python packer can add extra paths
void addPythonPath(const plFileName& dir);
PyObject* CompileString(const char *command, const plFileName& filename);
bool DumpObject(PyObject* pyobj, char** pickle, int32_t* size);
int getOutputAndReset(char** line=nil);
PyObject* CreateModule(const char* module);
bool RunPYC(PyObject* code, PyObject* module);
PyObject* GetModuleItem(const char* item, PyObject* module);
}
|
/*
* Generated by asn1c-0.9.24 (http://lionet.info/asn1c)
* From ASN.1 module "InformationElements"
* found in "../asn/InformationElements.asn"
* `asn1c -fcompound-names -fnative-types`
*/
#include "HCS-CellReselectInformation-RSCP.h"
static asn_TYPE_member_t asn_MBR_HCS_CellReselectInformation_RSCP_1[] = {
{ ATF_NOFLAGS, 0, offsetof(struct HCS_CellReselectInformation_RSCP, penaltyTime),
(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
+1, /* EXPLICIT tag at current level */
&asn_DEF_PenaltyTime_RSCP,
0, /* Defer constraints checking to the member type */
0, /* No PER visible constraints */
0,
"penaltyTime"
},
};
static ber_tlv_tag_t asn_DEF_HCS_CellReselectInformation_RSCP_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn_TYPE_tag2member_t asn_MAP_HCS_CellReselectInformation_RSCP_tag2el_1[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 } /* penaltyTime at 14935 */
};
static asn_SEQUENCE_specifics_t asn_SPC_HCS_CellReselectInformation_RSCP_specs_1 = {
sizeof(struct HCS_CellReselectInformation_RSCP),
offsetof(struct HCS_CellReselectInformation_RSCP, _asn_ctx),
asn_MAP_HCS_CellReselectInformation_RSCP_tag2el_1,
1, /* Count of tags in the map */
0, 0, 0, /* Optional elements (not needed) */
-1, /* Start extensions */
-1 /* Stop extensions */
};
asn_TYPE_descriptor_t asn_DEF_HCS_CellReselectInformation_RSCP = {
"HCS-CellReselectInformation-RSCP",
"HCS-CellReselectInformation-RSCP",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
SEQUENCE_decode_xer,
SEQUENCE_encode_xer,
SEQUENCE_decode_uper,
SEQUENCE_encode_uper,
0, /* Use generic outmost tag fetcher */
asn_DEF_HCS_CellReselectInformation_RSCP_tags_1,
sizeof(asn_DEF_HCS_CellReselectInformation_RSCP_tags_1)
/sizeof(asn_DEF_HCS_CellReselectInformation_RSCP_tags_1[0]), /* 1 */
asn_DEF_HCS_CellReselectInformation_RSCP_tags_1, /* Same as above */
sizeof(asn_DEF_HCS_CellReselectInformation_RSCP_tags_1)
/sizeof(asn_DEF_HCS_CellReselectInformation_RSCP_tags_1[0]), /* 1 */
0, /* No PER visible constraints */
asn_MBR_HCS_CellReselectInformation_RSCP_1,
1, /* Elements count */
&asn_SPC_HCS_CellReselectInformation_RSCP_specs_1 /* Additional specs */
};
|
/*
* Copyright 2005-2008 NVIDIA Corporation. All rights reserved.
*/
/*
Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it
under the terms of version 2 of the GNU General Public License as
published by the Free Software Foundation.
This program is distributed in the hope that it would be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Further, this software is distributed without any warranty that it is
free of the rightful claim of any third person regarding infringement
or the like. Any license provided herein, whether implied or
otherwise, applies only to this software file. Patent licenses, if
any, provided herein do not apply to combinations of this program with
other software, or any other product whatsoever.
You should have received a copy of the GNU General Public License along
with this program; if not, write the Free Software Foundation, Inc., 59
Temple Place - Suite 330, Boston MA 02111-1307, USA.
Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky,
Mountain View, CA 94043, or:
http://www.sgi.com
For further information regarding this notice, see:
http://oss.sgi.com/projects/GenInfo/NoticeExplan
*/
#ifndef targ_em_elf_INCLUDED
#define targ_em_elf_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
struct section_info {
Elf_Scn *scnptr; /* ptr to the elf section. */
char *buffer; /* data buffer for section. */
Elf64_Xword limit; /* maximum size of data buffer. */
Elf64_Xword size; /* current size of data buffer. */
Elf64_Xword offset; /* current offset in data buffer. */
Elf64_Word align; /* alignment of the section. */
Elf64_Word scnidx; /* symbol index of the section symbol. */
pSCNINFO relinfo; /* associated REL section. */
pSCNINFO relainfo; /* associated RELA section. */
pSCNINFO events; /* associated EVENTS section. */
Elf64_Word ev_offset; /* offset of last entry in events scn. */
pSCNINFO contents; /* associated CONTENTS section. */
Elf64_Word con_offset; /* offset of last entry in contents scn. */
};
#define SCNINFO_scnptr(t) ((t)->scnptr)
#define SCNINFO_buffer(t) ((t)->buffer)
#define SCNINFO_limit(t) ((t)->limit)
#define SCNINFO_size(t) ((t)->size)
#define SCNINFO_offset(t) ((t)->offset)
#define SCNINFO_align(t) ((t)->align)
#define SCNINFO_scnidx(t) ((t)->scnidx)
#define SCNINFO_relinfo(t) ((t)->relinfo)
#define SCNINFO_relainfo(t) ((t)->relainfo)
#define SCNINFO_events(t) ((t)->events)
#define SCNINFO_ev_offset(t) ((t)->ev_offset)
#define SCNINFO_contents(t) ((t)->contents)
#define SCNINFO_con_offset(t) ((t)->con_offset)
#define SCNINFO_index(t) (elf_ndxscn(SCNINFO_scnptr(t)))
extern char *Get_Section_Name (pSCNINFO scninfo);
extern void Generate_Addr_Reset (pSCNINFO scn, BOOL is_events, Elf64_Xword ev_ofst);
extern void Set_Current_Location (pSCNINFO scn, BOOL is_events, Elf64_Word ev_ofst);
extern pSCNINFO Interface_Scn;
/* this defines the common, other than name and enum value,
* parts of code for both IA-64 and Mips
*/
/*
* relocations that are the same other than the enum
*/
#define R_WORD32 (Big_Endian ? R_IA_64_DIR32MSB : R_IA_64_DIR32LSB)
#define R_WORD64 (Big_Endian ? R_IA_64_DIR64MSB : R_IA_64_DIR64LSB)
#define R_SCN_DISP (Big_Endian ? R_IA_64_SECREL64MSB : R_IA_64_SECREL64LSB)
#define R_PLT_OFFSET R_IA_64_PLTOFF22
#define R_NONE R_IA_64_NONE
/*
* section flags that are the same other than the enum
*/
#define SHF_NOSTRIP SHF_MIPS_NOSTRIP
/*
* section types that are the same other than the enum
*/
#define SHT_EVENTS SHT_IA64_EVENTS
#define SHT_CONTENT SHT_IA64_CONTENT
#define SHT_IFACE SHT_IA64_IFACE
/*
* section names
*/
#define SECT_OPTIONS_NAME IA64_OPTIONS
#define SECT_EVENTS_NAME IA64_EVENTS
#define SECT_IFACE_NAME IA64_INTERFACES
#define SECT_CONTENT_NAME MIPS_CONTENT
inline void
Set_Elf_Version (unsigned char *e_ident)
{
/* temporary version until final objects */
e_ident[EI_TVERSION] = EV_T_CURRENT;
}
#ifdef __cplusplus
}
#endif
#endif /* targ_em_elf_INCLUDED */
|
#include <stdint.h>
#include <math.h>
// Rotation matrix
volatile float R[3][3] =
{{1,0,0},{0,1,0},{0,0,1}};
float accOffset[3] = {337, 337, 337}; // ~1.5 V
float accScale[3] = {1/6.8, 1/6.8, 1/6.8}; // m/s^2
float gyrOffset[3] = {252, 252, 252}; // 1.23 V
float gyrScale[3] = {1/39.1, -1/39.1, 1/39.1}; // rad/s
//float gyrScale[3] = {1/(4*39.1), -1/(4*39.1), 1/(4*39.1)}; // rad/s swapped the pitch direction
//float gyrScale[3] = {4/(39.1), 4/(39.1), 4/(39.1)}; // rad/s
float accMagnitudeMin = 8.0;
float accMagnitudeMax = 12.0;
float accFilterTime = 1.0;
float acc[3], gyr[3];
float angle[3];
#define NGYR 2
float* imu_get_angle() {
return angle;
}
int imu_filter_gyr(uint16_t *gyrRaw, float dt) {
int i;
for (i = 0; i < NGYR; i++) {
gyr[i] = gyrScale[i]*(gyrRaw[i]-gyrOffset[i]);
}
// Quick and Dirty small angle calculations:
angle[0] += cos(angle[1])*gyr[0]*dt;
angle[1] += cos(angle[0])*gyr[1]*dt;
return 0;
}
int imu_filter_acc(uint16_t *accRaw, float dt) {
int i;
float accMagnitude=0;
float aX, aY;
for (i = 0; i < 3; i++) {
acc[i] = accScale[i]*(accRaw[i]-accOffset[i]);
accMagnitude += acc[i]*acc[i];
}
accMagnitude = sqrt(accMagnitude);
if ((accMagnitude < accMagnitudeMin) ||
(accMagnitude > accMagnitudeMax))
return -1;
aX = asin(acc[0]/accMagnitude);
aY = asin(acc[1]/accMagnitude);
// Filter angles:
angle[0] += (dt/accFilterTime)*(aX-angle[0]);
angle[1] += (dt/accFilterTime)*(aY-angle[1]);
return 0;
}
|
#if SH_HLSL == 1 || SH_CG == 1
#define shTexture2D sampler2D
#define shSample(tex, coord) tex2D(tex, coord)
#define shCubicSample(tex, coord) texCUBE(tex, coord)
#define shLerp(a, b, t) lerp(a, b, t)
#define shSaturate(a) saturate(a)
#define shSampler2D(name) , uniform sampler2D name : register(s@shCounter(0)) @shUseSampler(name)
#define shSamplerCube(name) , uniform samplerCUBE name : register(s@shCounter(0)) @shUseSampler(name)
#define shMatrixMult(m, v) mul(m, v)
#define shUniform(type, name) , uniform type name
#define shTangentInput(type) , in type tangent : TANGENT
#define shVertexInput(type, name) , in type name : TEXCOORD@shCounter(1)
#define shInput(type, name) , in type name : TEXCOORD@shCounter(1)
#define shOutput(type, name) , out type name : TEXCOORD@shCounter(2)
#define shNormalInput(type) , in type normal : NORMAL
#define shColourInput(type) , in type colour : COLOR
#define shFract(val) frac(val)
#ifdef SH_VERTEX_SHADER
#define shOutputPosition oPosition
#define shInputPosition iPosition
#define SH_BEGIN_PROGRAM \
void main( \
float4 iPosition : POSITION \
, out float4 oPosition : POSITION
#define SH_START_PROGRAM \
) \
#endif
#ifdef SH_FRAGMENT_SHADER
#define shOutputColour(num) oColor##num
#define shDeclareMrtOutput(num) , out float4 oColor##num : COLOR##num
#define SH_BEGIN_PROGRAM \
void main( \
out float4 oColor0 : COLOR
#define SH_START_PROGRAM \
) \
#endif
#endif
#if SH_GLSL == 1 || SH_GLSLES == 1
#define shFract(val) fract(val)
#if SH_GLSLES == 1
@version 100
#else
@version 120
#endif
#if SH_GLSLES == 1 && SH_FRAGMENT_SHADER
precision mediump int;
precision mediump float;
#endif
#define float2 vec2
#define float3 vec3
#define float4 vec4
#define int2 ivec2
#define int3 ivec3
#define int4 ivec4
#define shTexture2D sampler2D
#define shSample(tex, coord) texture2D(tex, coord)
#define shCubicSample(tex, coord) textureCube(tex, coord)
#define shLerp(a, b, t) mix(a, b, t)
#define shSaturate(a) clamp(a, 0.0, 1.0)
#define shUniform(type, name) uniform type name;
#define shSampler2D(name) uniform sampler2D name; @shUseSampler(name)
#define shSamplerCube(name) uniform samplerCube name; @shUseSampler(name)
#define shMatrixMult(m, v) ((m) * (v))
#define shOutputPosition gl_Position
#define float4x4 mat4
#define float3x3 mat3
// GLSL 1.3
#if 0
// automatically recognized by ogre when the input name equals this
#define shInputPosition vertex
#define shOutputColour(num) oColor##num
#define shTangentInput(type) in type tangent;
#define shVertexInput(type, name) in type name;
#define shInput(type, name) in type name;
#define shOutput(type, name) out type name;
// automatically recognized by ogre when the input name equals this
#define shNormalInput(type) in type normal;
#define shColourInput(type) in type colour;
#ifdef SH_VERTEX_SHADER
#define SH_BEGIN_PROGRAM \
in float4 vertex;
#define SH_START_PROGRAM \
void main(void)
#endif
#ifdef SH_FRAGMENT_SHADER
#define shDeclareMrtOutput(num) out vec4 oColor##num;
#define SH_BEGIN_PROGRAM \
out float4 oColor0;
#define SH_START_PROGRAM \
void main(void)
#endif
#endif
// GLSL 1.2
#if 1
// automatically recognized by ogre when the input name equals this
#define shInputPosition vertex
#define shOutputColour(num) gl_FragData[num]
#define shTangentInput(type) attribute type tangent;
#define shVertexInput(type, name) attribute type name;
#define shInput(type, name) varying type name;
#define shOutput(type, name) varying type name;
// automatically recognized by ogre when the input name equals this
#define shNormalInput(type) attribute type normal;
#define shColourInput(type) attribute type colour;
#ifdef SH_VERTEX_SHADER
#define SH_BEGIN_PROGRAM \
attribute vec4 vertex;
#define SH_START_PROGRAM \
void main(void)
#endif
#ifdef SH_FRAGMENT_SHADER
#define shDeclareMrtOutput(num)
#define SH_BEGIN_PROGRAM
#define SH_START_PROGRAM \
void main(void)
#endif
#endif
#endif
|
#ifndef _KERNEL_TESTS_H
#define _KERNEL_TESTS_H
/*
* Filename: tests.h
*
* Description:
* These are the test functions for kernel feature implementations;
*
* Date: 01-Mar-2017 01:11
*
* Copyleft 2017 Marko Trickovic
*
* TODO: Split this file into tests.h and tests.c
*/
void stack_smash_test(void)
{
char buffer[15];
memcpy(buffer, "Stack smash fucntion.\n", 22);
printf("%s\n", buffer);
}
#endif // _KERNEL_TESTS_H
|
/*
* Generated by asn1c-0.9.24 (http://lionet.info/asn1c)
* From ASN.1 module "Internode-definitions"
* found in "../asn/Internode-definitions.asn"
* `asn1c -fcompound-names -fnative-types`
*/
#include "InterRATHandoverInfoWithInterRATCapabilities-r3-IEs.h"
static int
memb_interRATHandoverInfo_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
asn_app_constraint_failed_f *ctfailcb, void *app_key) {
const OCTET_STRING_t *st = (const OCTET_STRING_t *)sptr;
size_t size;
if(!sptr) {
_ASN_CTFAIL(app_key, td, sptr,
"%s: value not given (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
size = st->size;
if((size <= 255)) {
/* Constraint check succeeded */
return 0;
} else {
_ASN_CTFAIL(app_key, td, sptr,
"%s: constraint failed (%s:%d)",
td->name, __FILE__, __LINE__);
return -1;
}
}
static asn_per_constraints_t asn_PER_memb_interRATHandoverInfo_constr_3 = {
{ APC_UNCONSTRAINED, -1, -1, 0, 0 },
{ APC_CONSTRAINED, 8, 8, 0, 255 } /* (SIZE(0..255)) */,
0, 0 /* No PER value map */
};
static asn_TYPE_member_t asn_MBR_InterRATHandoverInfoWithInterRATCapabilities_r3_IEs_1[] = {
{ ATF_POINTER, 1, offsetof(struct InterRATHandoverInfoWithInterRATCapabilities_r3_IEs, ue_RATSpecificCapability),
(ASN_TAG_CLASS_CONTEXT | (0 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_InterRAT_UE_RadioAccessCapabilityList,
0, /* Defer constraints checking to the member type */
0, /* No PER visible constraints */
0,
"ue-RATSpecificCapability"
},
{ ATF_NOFLAGS, 0, offsetof(struct InterRATHandoverInfoWithInterRATCapabilities_r3_IEs, interRATHandoverInfo),
(ASN_TAG_CLASS_CONTEXT | (1 << 2)),
-1, /* IMPLICIT tag at current level */
&asn_DEF_OCTET_STRING,
memb_interRATHandoverInfo_constraint_1,
&asn_PER_memb_interRATHandoverInfo_constr_3,
0,
"interRATHandoverInfo"
},
};
static int asn_MAP_InterRATHandoverInfoWithInterRATCapabilities_r3_IEs_oms_1[] = { 0 };
static ber_tlv_tag_t asn_DEF_InterRATHandoverInfoWithInterRATCapabilities_r3_IEs_tags_1[] = {
(ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
};
static asn_TYPE_tag2member_t asn_MAP_InterRATHandoverInfoWithInterRATCapabilities_r3_IEs_tag2el_1[] = {
{ (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* ue-RATSpecificCapability at 269 */
{ (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* interRATHandoverInfo at 275 */
};
static asn_SEQUENCE_specifics_t asn_SPC_InterRATHandoverInfoWithInterRATCapabilities_r3_IEs_specs_1 = {
sizeof(struct InterRATHandoverInfoWithInterRATCapabilities_r3_IEs),
offsetof(struct InterRATHandoverInfoWithInterRATCapabilities_r3_IEs, _asn_ctx),
asn_MAP_InterRATHandoverInfoWithInterRATCapabilities_r3_IEs_tag2el_1,
2, /* Count of tags in the map */
asn_MAP_InterRATHandoverInfoWithInterRATCapabilities_r3_IEs_oms_1, /* Optional members */
1, 0, /* Root/Additions */
-1, /* Start extensions */
-1 /* Stop extensions */
};
asn_TYPE_descriptor_t asn_DEF_InterRATHandoverInfoWithInterRATCapabilities_r3_IEs = {
"InterRATHandoverInfoWithInterRATCapabilities-r3-IEs",
"InterRATHandoverInfoWithInterRATCapabilities-r3-IEs",
SEQUENCE_free,
SEQUENCE_print,
SEQUENCE_constraint,
SEQUENCE_decode_ber,
SEQUENCE_encode_der,
SEQUENCE_decode_xer,
SEQUENCE_encode_xer,
SEQUENCE_decode_uper,
SEQUENCE_encode_uper,
0, /* Use generic outmost tag fetcher */
asn_DEF_InterRATHandoverInfoWithInterRATCapabilities_r3_IEs_tags_1,
sizeof(asn_DEF_InterRATHandoverInfoWithInterRATCapabilities_r3_IEs_tags_1)
/sizeof(asn_DEF_InterRATHandoverInfoWithInterRATCapabilities_r3_IEs_tags_1[0]), /* 1 */
asn_DEF_InterRATHandoverInfoWithInterRATCapabilities_r3_IEs_tags_1, /* Same as above */
sizeof(asn_DEF_InterRATHandoverInfoWithInterRATCapabilities_r3_IEs_tags_1)
/sizeof(asn_DEF_InterRATHandoverInfoWithInterRATCapabilities_r3_IEs_tags_1[0]), /* 1 */
0, /* No PER visible constraints */
asn_MBR_InterRATHandoverInfoWithInterRATCapabilities_r3_IEs_1,
2, /* Elements count */
&asn_SPC_InterRATHandoverInfoWithInterRATCapabilities_r3_IEs_specs_1 /* Additional specs */
};
|
/* This file is part of the KDE project
Copyright (C) 2007 David Faure <faure@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KUNITTEST_EXPORT_H
#define KUNITTEST_EXPORT_H
/* needed for KDE_EXPORT and KDE_IMPORT macros */
#include <kdemacros.h>
#ifndef KUNITTEST_EXPORT
# if defined(MAKE_KUNITTEST_LIB)
/* We are building this library */
# define KUNITTEST_EXPORT KDE_EXPORT
# else
/* We are using this library */
# define KUNITTEST_EXPORT KDE_IMPORT
# endif
#endif
# ifndef KUNITTEST_EXPORT_DEPRECATED
# define KUNITTEST_EXPORT_DEPRECATED KDE_DEPRECATED KUNITTEST_EXPORT
# endif
#endif
|
/*
* scalblnf.c
*
* by Ian Ollmann
*
* Copyright (c) 2007, Apple Inc. All Rights Reserved.
*
* C99 impelemtnation of scalblnf().
*/
#include <math.h>
#include <stdint.h>
float scalblnf( float x, long i )
{
if( i > 300 )
i = 300;
if( i < -300 )
i = -300;
return scalbnf( x, (int) i );
}
|
/*
* Copyright(C) 2011-2015 Pedro H. Penna <pedrohenriquepenna@gmail.com>
*
* This file is part of Nanvix.
*
* Nanvix is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Nanvix 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 Nanvix. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Copyright (c) 1992 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. 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.
*/
/**
* @file
*
* @brief strtoll() implementation.
*/
#include <sys/types.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
/**
* @brief Converts a string to a long long integer.
*
* @param nptr Start of string
* @param endptr End of string.
* @param base Base
*
* @returns The converted value
*/
long long strtoll(const char *nptr, char **endptr, int base)
{
const char *s;
long long acc, cutoff;
int c;
int neg, any, cutlim;
/*
* Skip white space and pick up leading +/- sign if any.
* If base is 0, allow 0x for hex and 0 for octal, else
* assume decimal; if base is already 16, allow 0x.
*/
s = nptr;
do
{
c = (unsigned char) *s++;
} while (isspace(c));
if (c == '-')
{
neg = 1;
c = *s++;
}
else
{
neg = 0;
if (c == '+')
c = *s++;
}
if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X'))
{
c = s[1];
s += 2;
base = 16;
}
if (base == 0)
base = c == '0' ? 8 : 10;
/*
* Compute the cutoff value between legal numbers and illegal
* numbers. That is the largest legal value, divided by the
* base. An input number that is greater than this value, if
* followed by a legal input character, is too big. One that
* is equal to this value may be valid or not; the limit
* between valid and invalid numbers is then based on the last
* digit. For instance, if the range for long longs is
* [-9223372036854775808..9223372036854775807] and the input base
* is 10, cutoff will be set to 922337203685477580 and cutlim to
* either 7 (neg==0) or 8 (neg==1), meaning that if we have
* accumulated a value > 922337203685477580, or equal but the
* next digit is > 7 (or 8), the number is too big, and we will
* return a range error.
*
* Set any if any `digits' consumed; make it negative to indicate
* overflow.
*/
cutoff = neg ? LLONG_MIN : LLONG_MAX;
cutlim = cutoff % base;
cutoff /= base;
if (neg)
{
if (cutlim > 0)
{
cutlim -= base;
cutoff += 1;
}
cutlim = -cutlim;
}
for (acc = 0, any = 0;; c = (unsigned char) *s++)
{
if (isdigit(c))
c -= '0';
else if (isalpha(c))
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
else
break;
if (c >= base)
break;
if (any < 0)
continue;
if (neg)
{
if (acc < cutoff || (acc == cutoff && c > cutlim))
{
any = -1;
acc = LLONG_MIN;
errno = ERANGE;
}
else
{
any = 1;
acc *= base;
acc -= c;
}
}
else
{
if (acc > cutoff || (acc == cutoff && c > cutlim))
{
any = -1;
acc = LLONG_MAX;
errno = ERANGE;
}
else
{
any = 1;
acc *= base;
acc += c;
}
}
}
if (endptr != 0)
*endptr = (char *) (any ? s - 1 : nptr);
return (acc);
}
|
/*
* Generated by asn1c-0.9.24 (http://lionet.info/asn1c)
* From ASN.1 module "InformationElements"
* found in "../asn/InformationElements.asn"
* `asn1c -fcompound-names -fnative-types`
*/
#ifndef _SysInfoType13_4_H_
#define _SysInfoType13_4_H_
#include <asn_application.h>
/* Including external dependencies */
#include "ANSI-41-GlobalServiceRedirectInfo.h"
#include <constr_SEQUENCE.h>
#ifdef __cplusplus
extern "C" {
#endif
/* SysInfoType13-4 */
typedef struct SysInfoType13_4 {
ANSI_41_GlobalServiceRedirectInfo_t ansi_41_GlobalServiceRedirectInfo;
struct SysInfoType13_4__nonCriticalExtensions {
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} *nonCriticalExtensions;
/* Context for parsing across buffer boundaries */
asn_struct_ctx_t _asn_ctx;
} SysInfoType13_4_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_SysInfoType13_4;
#ifdef __cplusplus
}
#endif
#endif /* _SysInfoType13_4_H_ */
#include <asn_internal.h>
|
// This file is part of libigl, a simple c++ geometry processing library.
//
// Copyright (C) 2014 Wenzel Jacob <wenzel@inf.ethz.ch>
//
// This Source Code Form is subject to the terms of the Mozilla Public License
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
// obtain one at http://mozilla.org/MPL/2.0/.
#ifndef IGL_VIEWER_OPENGL_SHADER_H
#define IGL_VIEWER_OPENGL_SHADER_H
#include <igl/igl_inline.h>
#include <string>
#include <Eigen/Core>
#ifdef _WIN32
# include <windows.h>
# undef max
# undef min
# undef DrawText
#endif
#ifndef __APPLE__
# define GLEW_STATIC
# include <GL/glew.h>
#endif
#ifdef __APPLE__
# include <OpenGL/gl3.h>
# define __gl_h_ /* Prevent inclusion of the old gl.h */
#else
# include <GL/gl.h>
#endif
namespace igl
{
namespace viewer
{
// This class wraps an OpenGL program composed of three shaders
// TODO: write documentation
class OpenGL_shader
{
public:
typedef unsigned int GLuint;
typedef int GLint;
GLuint vertex_shader;
GLuint fragment_shader;
GLuint geometry_shader;
GLuint program_shader;
IGL_INLINE OpenGL_shader() : vertex_shader(0), fragment_shader(0),
geometry_shader(0), program_shader(0) { }
// Create a new shader from the specified source strings
IGL_INLINE bool init(const std::string &vertex_shader_string,
const std::string &fragment_shader_string,
const std::string &fragment_data_name,
const std::string &geometry_shader_string = "",
int geometry_shader_max_vertices = 3);
// Create a new shader from the specified files on disk
IGL_INLINE bool init_from_files(const std::string &vertex_shader_filename,
const std::string &fragment_shader_filename,
const std::string &fragment_data_name,
const std::string &geometry_shader_filename = "",
int geometry_shader_max_vertices = 3);
// Select this shader for subsequent draw calls
IGL_INLINE void bind();
// Release all OpenGL objects
IGL_INLINE void free();
// Return the OpenGL handle of a named shader attribute (-1 if it does not exist)
IGL_INLINE GLint attrib(const std::string &name) const;
// Return the OpenGL handle of a uniform attribute (-1 if it does not exist)
IGL_INLINE GLint uniform(const std::string &name) const;
// Bind a per-vertex array attribute and refresh its contents from an Eigen amtrix
IGL_INLINE GLint bindVertexAttribArray(const std::string &name, GLuint bufferID,
const Eigen::MatrixXf &M, bool refresh) const;
IGL_INLINE GLuint create_shader_helper(GLint type, const std::string &shader_string);
};
}
}
#ifndef IGL_STATIC_LIBRARY
# include "OpenGL_shader.cpp"
#endif
#endif
|
/*
Copyright <SWGEmu>
See file COPYING for copying conditions.*/
/**
* \file RequestCoreSampleCommand.h
* \author Kyle Burkhardt
* \date 5-27-10
*/
#ifndef REQUESTCORESAMPLECOMMAND_H_
#define REQUESTCORESAMPLECOMMAND_H_
#include "server/zone/objects/scene/SceneObject.h"
#include "server/zone/objects/tangible/tool/SurveyTool.h"
#include "server/zone/packets/chat/ChatSystemMessage.h"
#include "server/zone/objects/player/sessions/survey/SurveySession.h"
class RequestCoreSampleCommand : public QueueCommand {
public:
RequestCoreSampleCommand(const String& name, ZoneProcessServer* server)
: QueueCommand(name, server) {
}
int doQueueCommand(CreatureObject* creature, const uint64& target, const UnicodeString& arguments) const {
if (!checkStateMask(creature))
return INVALIDSTATE;
if (!checkInvalidLocomotions(creature)) {
creature->sendSystemMessage("@error_message:survey_standing");
return INVALIDLOCOMOTION;
}
// We don't do anything if for some reason it isn't a player
if (creature->isPlayerCreature()) {
Reference<Task*> sampletask = creature->getPendingTask("sample");
Reference<Task*> surveytask = creature->getPendingTask("survey");
// If the sample task exists, we can't sample again
if (sampletask != NULL) {
Time nextExecutionTime;
Core::getTaskManager()->getNextExecutionTime(sampletask, nextExecutionTime);
int seconds = (int) ((nextExecutionTime.getMiliTime() - Time().getMiliTime()) / 1000.0f);
if(seconds < 1)
seconds = 1;
StringIdChatParameter message("survey","tool_recharge_time");
message.setDI(seconds);
ChatSystemMessage* sysMessage = new ChatSystemMessage(message);
creature->sendMessage(sysMessage);
return SUCCESS;
}
// If the survey task exists, we can't sample
if (surveytask != NULL) {
creature->sendSystemMessage("@survey:sample_survey");
return SUCCESS;
}
ManagedReference<SurveySession*> session = creature->getActiveSession(SessionFacadeType::SURVEY).castTo<SurveySession*>();
if(session == NULL) {
creature->sendSystemMessage("@ui:survey_notool");
return GENERALERROR;
}
session->setActiveSurveyTool(session->getOpenSurveyTool().get());
session->startSample(arguments.toString());
}
return SUCCESS;
}
};
#endif //REQUESTCORESAMPLECOMMAND_H_
|
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RY_ENCHANT_WEAPON_EFFECT_H
#define RY_ENCHANT_WEAPON_EFFECT_H
// game share
#include "game_share/scores.h"
#include "game_share/persistent_data.h"
//
#include "phrase_manager/s_effect.h"
#include "entity_manager/entity_base.h"
/** Class for weapon enchants
* \author Jerome Vuarand
* \author Nevrax France
* \date 2005
*
* This class is inspired from CNoLinkDOTEffect and thus may have residual
* side effects from the copy'n'paste.
*/
class CEnchantWeaponEffect
: public CSTimedEffect
{
public:
NLMISC_DECLARE_CLASS(CEnchantWeaponEffect)
DECLARE_PERSISTENCE_METHODS
// default ctor
CEnchantWeaponEffect() : CSTimedEffect() {}
CEnchantWeaponEffect(
const TDataSetRow & creatorRowId,
const TDataSetRow & targetRowId, // should be replaced with weapon id (CGameItemPtr)
EFFECT_FAMILIES::TEffectFamily family,
sint32 effectValue,
NLMISC::TGameCycle endDate,
DMGTYPE::EDamageType damageType,
SCORES::TScores affectedScore,
float dpsBonus,
DMGTYPE::EDamageType oldDamageType)
: CSTimedEffect(creatorRowId, targetRowId, family, false, effectValue, abs((sint32)dpsBonus), endDate)
, _DamageType(damageType)
, _DpsBonus(dpsBonus)
, _AffectedScore(affectedScore)
, _CycleDamage(0.f)
{
_RemainingDamage = 0;
_EndsAtCasterDeath = false;
_Stackable = false;
}
/// apply the effect
virtual bool update(CTimerEvent * event, bool applyEffect);
/// callback called when the effect is actually removed
virtual void removed();
/// if true effect ends at caster death
void endsAtCasterDeath(bool flag) { _EndsAtCasterDeath = flag; }
/// set the stackable flag
void stackable(bool flag) { _Stackable = flag; }
float getDpsBonus() const { return _DpsBonus; }
/// This method should return a direct damage value computed according to weapon speed
float getDmgBonus() const { return _DpsBonus; }
DMGTYPE::EDamageType getDmgType() const { return _DamageType; }
virtual NLMISC::CSheetId getAssociatedSheetId() const;
virtual bool automaticallyReplaceFamily() const { return true; }
virtual bool canBeInactive() const { return false; }
// re-activate a magic protection modifier loaded with character
void activate();
private:
/// DPS bonus
float _DpsBonus;
/// number of score points lost by target each cycle
float _CycleDamage;
/// fraction of lost points when not integer (0-1)
float _RemainingDamage;
/// affected score
SCORES::TScores _AffectedScore;
/// damage type
DMGTYPE::EDamageType _DamageType;
/// if true effect ends at caster death
bool _EndsAtCasterDeath;
/// if true DoT can stacks, otherwise they don't stack
bool _Stackable;
NLMISC::CEntityId _CreatorEntityId;
};
#endif
|
/*
* opencog/atomspace/FixedIntegerIndex.h
*
* Copyright (C) 2008 Linas Vepstas <linasvepstas@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License v3 as
* published by the Free Software Foundation and including the exceptions
* at http://opencog.org/wiki/Licenses
*
* 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 Affero General Public License
* along with this program; if not, write to:
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _OPENCOG_FIXEDINTEGERINDEX_H
#define _OPENCOG_FIXEDINTEGERINDEX_H
#include <cstddef>
#include <vector>
#include <opencog/atomspace/AtomIndex.h>
#include <opencog/atomspace/Handle.h>
namespace opencog
{
/** \addtogroup grp_atomspace
* @{
*/
/**
* Implements an integer index as an RB-tree (C++ map)
*/
class FixedIntegerIndex
: public AtomIndex<int, Handle>
{
protected:
std::vector<UnorderedUUIDSet> idx;
void resize(size_t);
public:
virtual ~FixedIntegerIndex() {}
virtual void insert(int, Handle);
virtual Handle get(int) const;
virtual void remove(int, Handle);
virtual size_t size(void) const;
virtual void remove(bool (*)(Handle));
};
/** @}*/
} //namespace opencog
#endif // _OPENCOG_FIXEDINTEGERINDEX_H
|
/*
* kmail: KDE mail client
* Copyright (c) 1996-1998 Stefan Taferner <taferner@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef kmmsginfo_h
#define kmmsginfo_h
#include <sys/types.h>
#include "kmmsgbase.h"
#include <QByteArray>
class KMMessage;
class KMMsgInfo: public KMMsgBase
{
public:
#ifdef KMAIL_SQLITE_INDEX
explicit KMMsgInfo(KMFolder* p, char* data=0, short len=0, sqlite_int64 dbId=0);
#else
explicit KMMsgInfo(KMFolder* parent, off_t off=0, short len=0);
#endif
virtual ~KMMsgInfo();
/** left for old style index files */
void compat_fromOldIndexString(const QByteArray& str, bool toUtf8);
/** Initialize with given values and set dirty flag to false. */
virtual void init(const QByteArray& subject, const QByteArray& from,
const QByteArray& to, time_t date,
const MessageStatus& status, const QByteArray& xmark,
const QByteArray& replyToId,
const QByteArray& replyToAuxId,
const QByteArray& msgId,
KMMsgEncryptionState encryptionState,
KMMsgSignatureState signatureState,
KMMsgMDNSentState mdnSentState,
const QByteArray &prefCharset,
off_t folderOffset=0, size_t msgSize=0,
size_t msgSizeServer = 0, ulong UID = 0);
/** Initialize with given values and set dirty flag to false. */
virtual void init(const QByteArray& subject, const QByteArray& from,
const QByteArray& to, time_t date,
const MessageStatus& status, const QByteArray& xmark,
const QByteArray& replyToId,
const QByteArray& replyToAuxId,
const QByteArray& msgId,
const QByteArray& fileName,
KMMsgEncryptionState encryptionState,
KMMsgSignatureState signatureState,
KMMsgMDNSentState mdnSentState,
const QByteArray &prefCharset,
size_t msgSize=0,
size_t msgSizeServer = 0, ulong UID = 0);
/** Inherited methods (see KMMsgBase for description): */
virtual QString subject(void) const;
virtual QString fromStrip(void) const;
virtual QString toStrip(void) const;
virtual QString xmark(void) const;
virtual QString replyToIdMD5(void) const;
virtual QString replyToAuxIdMD5() const;
virtual QString strippedSubjectMD5() const;
virtual bool subjectIsPrefixed() const;
virtual QString msgIdMD5(void) const;
virtual QString fileName(void) const;
virtual QString tagString( void ) const;
virtual KMMessageTagList *tagList( void ) const;
virtual MessageStatus& status() const;
virtual KMMsgEncryptionState encryptionState() const;
virtual KMMsgSignatureState signatureState() const;
virtual KMMsgMDNSentState mdnSentState() const;
virtual off_t folderOffset(void) const;
virtual size_t msgSize(void) const;
virtual size_t msgSizeServer(void) const;
virtual time_t date(void) const;
virtual ulong UID(void) const;
void setMsgSize(size_t sz);
void setMsgSizeServer(size_t sz);
void setFolderOffset(off_t offs);
void setFileName(const QString& file);
virtual void setStatus(const MessageStatus& status, int idx = -1);
virtual void setDate(time_t aUnixTime);
virtual void setSubject(const QString&);
virtual void setXMark(const QString&);
virtual void setReplyToIdMD5(const QString&);
virtual void setReplyToAuxIdMD5( const QString& );
virtual void initStrippedSubjectMD5();
virtual void setMsgIdMD5(const QString&);
virtual void setEncryptionState( const KMMsgEncryptionState, int idx = -1 );
virtual void setSignatureState( const KMMsgSignatureState, int idx = -1 );
virtual void setMDNSentState( KMMsgMDNSentState, int idx = -1 );
virtual void setUID(ulong);
/** Grr.. c++! */
using KMMsgBase::setDate;
virtual void setStatus(const char* s1, const char* s2=0) { KMMsgBase::setStatus(s1, s2); }
virtual void setDate(const char* s1) { KMMsgBase::setDate(s1); }
virtual bool dirty(void) const;
/** Copy operators. */
KMMsgInfo& operator=(const KMMessage&);
private:
// Currently unused
KMMsgInfo& operator=(const KMMsgInfo&);
KMMsgInfo(const KMMsgInfo&);
// WARNING: Do not add new member variables to the class. Add them to kd
class KMMsgInfoPrivate;
KMMsgInfoPrivate *kd;
};
typedef KMMsgInfo* KMMsgInfoPtr;
#endif /*kmmsginfo_h*/
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2014 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU Lesser General Public License Version 2.1
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __APPSTREAM_GLIB_H
#define __APPSTREAM_GLIB_H
#define __APPSTREAM_GLIB_H_INSIDE__
#include <as-app.h>
#include <as-bundle.h>
#include <as-checksum.h>
#include <as-enums.h>
#include <as-icon.h>
#include <as-image.h>
#include <as-inf.h>
#include <as-node.h>
#include <as-problem.h>
#include <as-provide.h>
#include <as-release.h>
#include <as-screenshot.h>
#include <as-store.h>
#include <as-tag.h>
#include <as-version.h>
#include <as-utils.h>
#undef __APPSTREAM_GLIB_H_INSIDE__
#endif /* __APPSTREAM_GLIB_H */
|
/*************************************************************************/
/* Copyright (c) 2004 */
/* Daniel Sleator, David Temperley, and John Lafferty */
/* Copyright (c) 2014 Linas Vepstas */
/* All rights reserved */
/* */
/* Use of the link grammar parsing system is subject to the terms of the */
/* license set forth in the LICENSE file included with this software. */
/* This license allows free redistribution and use in source and binary */
/* forms, with or without modification, subject to certain conditions. */
/* */
/*************************************************************************/
/**********************************************************************
Calling paradigm:
. call post_process_new() with the handle of a knowledge set. This
returns a handle, used for all subsequent calls to post-process.
. Do for each sentence:
- Do for each generated linkage of a sentence:
+ call post_process_scan_linkage()
- Do for each generated linkage of a sentence:
+ call do_post_process()
- Call post_process_free()
***********************************************************************/
#ifndef _POSTPROCESS_H_
#define _POSTPROCESS_H_
#include "api-types.h"
#include "link-includes.h"
typedef struct PP_data_s PP_data;
Postprocessor * post_process_new(pp_knowledge *);
void post_process_free(Postprocessor *);
void post_process_lkgs(Sentence, Parse_Options);
void do_post_process(Postprocessor *, Linkage, bool);
void post_process_free_data(PP_data * ppd);
bool post_process_match(const char *, const char *); /* utility function */
void compute_domain_names(Linkage);
void linkage_free_pp_domains(Linkage);
#endif
|
struct __DIR_s
{
int lock;
int fd;
off_t tell;
int buf_pos;
int buf_end;
char buf[2048];
};
|
/****************************************************************/
/* MOOSE - Multiphysics Object Oriented Simulation Environment */
/* */
/* All contents are licensed under LGPL V2.1 */
/* See LICENSE for full restrictions */
/****************************************************************/
#ifndef CAVITYPRESSUREPPACTION_H
#define CAVITYPRESSUREPPACTION_H
#include "Action.h"
#include "MooseTypes.h"
class CavityPressurePPAction: public Action
{
public:
CavityPressurePPAction(const InputParameters & params);
CavityPressurePPAction(const std::string & deprecated_name, InputParameters parameters); // DEPRECATED CONSTRUCTOR
virtual void act();
};
template<>
InputParameters validParams<CavityPressurePPAction>();
#endif // CAVITYPRESSUREPPACTION_H
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.