text stringlengths 4 6.14k |
|---|
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of the Qt Build Suite.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef QBS_RULECOMMAND_H
#define QBS_RULECOMMAND_H
#include <tools/qbs_export.h>
#include <QExplicitlySharedDataPointer>
#include <QStringList>
QT_BEGIN_NAMESPACE
class QProcessEnvironment;
QT_END_NAMESPACE
namespace qbs {
namespace Internal {
class ProjectPrivate;
class RuleCommandPrivate;
}
class QBS_EXPORT RuleCommand
{
friend class Internal::ProjectPrivate;
public:
RuleCommand();
RuleCommand(const RuleCommand &other);
~RuleCommand();
RuleCommand &operator=(const RuleCommand &other);
enum Type { ProcessCommandType, JavaScriptCommandType, InvalidType };
Type type() const;
QString description() const;
QString sourceCode() const;
QString executable() const;
QStringList arguments() const;
QString workingDirectory() const;
QProcessEnvironment environment() const;
private:
QExplicitlySharedDataPointer<Internal::RuleCommandPrivate> d;
};
typedef QList<RuleCommand> RuleCommandList;
} // namespace qbs
#endif // Include guard.
|
/*
* Hqp_IpRedPardiso.h --
* - manage the Jacobian matrix of Interior Point algorithms
* - eliminate inequality constraints
* - use Pardiso sparse matrix solver
*
* hl, 2006/11/22
*
* derived from Hqp_IpRedSpBKP.h (developed by Ruediger Franke)
*
*/
/*
Copyright (C) 2006 Hartmut Linke
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;
version 2 of the License.
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 (file COPYING.LIB);
if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef Hqp_IpRedPardiso_H
#define Hqp_IpRedPardiso_H
#include "Hqp_IpMatrix.h"
class Hqp_IpRedPardiso: public Hqp_IpMatrix {
protected:
int _n, _me, _m, _nnz; // dimensions
int _sbw;
Real _tol; // tolerance for fill-in vs. stability
SPMAT *_CT;
SPMAT *_QCTC;
PERM *_pivot;
PERM *_blocks;
VEC *_zw;
VEC *_scale;
VEC *_r12;
VEC *_xy;
IVEC *_CTC_degree;
IVEC *_CTC_neigh_start;
IVEC *_CTC_neighs;
// parameters of PARDISO solver
void *_pardiso_pt[64];
int _pardiso_parm[64];
int _reinit;
int _pivot_strategy;
IVEC *_iv;
IVEC *_jv;
IVEC *_ipivot;
VEC *_v;
VEC *_v_raw;
int _maxfct; // Maximum number of numerical factorizations
int _mnum; // Which factorization to use
int _msglvl; // Print statistical information in file
int _error; // Initialize error flag
int _mtype; // Real symmetric matrix
int _nrhs; // Number of right hand sides
int _phase; // solution phase of the PARDISO solver
int _dim; // dimension of equation system
void sub_CTC();
void free_pardiso();
void reinit_pardiso();
public:
Hqp_IpRedPardiso();
~Hqp_IpRedPardiso();
void init(const Hqp_Program *);
void update(const Hqp_Program *);
void factor(const Hqp_Program *, const VEC *z, const VEC *w);
void step(const Hqp_Program *, const VEC *z, const VEC *w,
const VEC *r1, const VEC *r2, const VEC *r3, const VEC *r4,
VEC *dx, VEC *dy, VEC *dz, VEC *dw);
const char *name() {return "RedPardiso";}
};
#endif
|
/********************************************************************************
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
/*
* FairTestDetectorDigi.h
*
* Created on: 20.07.2012
* Author: stockman
*/
#ifndef FAIRTESTDETECTORDIGI_H_
#define FAIRTESTDETECTORDIGI_H_
#include "FairTimeStamp.h" // for FairTimeStamp
#include "Riosfwd.h" // for ostream
#include "Rtypes.h" // for Int_t, etc
#include <iostream> // for operator<<, basic_ostream, etc
#include <string>
#include <sstream>
#ifndef __CINT__
#include <boost/serialization/access.hpp>
#include <boost/serialization/base_object.hpp>
#endif //__CINT__
class FairTestDetectorDigi : public FairTimeStamp
{
public:
FairTestDetectorDigi();
FairTestDetectorDigi(Int_t x, Int_t y, Int_t z, Double_t timeStamp);
virtual ~FairTestDetectorDigi();
void SetXYZ(Int_t x, Int_t y, Int_t z)
{
SetX(x);
SetY(y);
SetZ(z);
}
void SetX(Int_t x)
{
fX = x;
}
void SetY(Int_t y)
{
fY = y;
}
void SetZ(Int_t z)
{
fZ = z;
}
Int_t GetX() const
{
return fX;
}
Int_t GetY() const
{
return fY;
}
Int_t GetZ() const
{
return fZ;
}
// temporary to avoid serialisation of the parent class
virtual bool equal(FairTimeStamp* data)
{
FairTestDetectorDigi* myDigi = dynamic_cast<FairTestDetectorDigi*>(data);
if (myDigi != 0)
{
if (fX == myDigi->GetX())
if (fY == myDigi->GetY())
if (fZ == myDigi->GetZ())
{
return true;
}
}
return false;
}
virtual bool operator<(const FairTestDetectorDigi& myDigi) const
{
if (fX < myDigi.GetX())
{
return true;
}
else if (fX > myDigi.GetX())
{
return false;
}
if (fY < myDigi.GetY())
{
return true;
}
else if (fY > myDigi.GetY())
{
return false;
}
if (fZ < myDigi.GetZ())
{
return true;
}
else if (fZ > myDigi.GetZ())
{
return false;
}
return false;
}
friend std::ostream& operator<<(std::ostream& out, FairTestDetectorDigi& digi)
{
out << "FairTestDetectorDigi at:"
<< " (" << digi.GetX() << "/" << digi.GetY() << "/" << digi.GetZ() << ") "
<< " with TimeStamp: " << digi.GetTimeStamp() << std::endl;
return out;
}
template <class T>
std::string ToString (const T& value)
{
std::stringstream ss;
ss.precision(5);
ss << value;
return ss.str();
}
std::string ToString()
{
std::string out = "FairTestDetectorDigi at: (" + ToString(GetX())
+ "/" + ToString(GetY()) + "/" + ToString(GetZ())
+ ") " + " with TimeStamp: " + ToString(GetTimeStamp());
return out;
}
template <class Archive>
void serialize(Archive& ar, const unsigned int /*version*/)
{
ar& boost::serialization::base_object<FairTimeStamp>(*this);
ar& fX;
ar& fY;
ar& fZ;
}
private:
#ifndef __CINT__ // for BOOST serialization
friend class boost::serialization::access;
#endif // for BOOST serialization
Int_t fX;
Int_t fY;
Int_t fZ;
ClassDef(FairTestDetectorDigi, 1);
};
#endif /* FAIRTESTDETECTORDIGI_H_ */
|
// -*- C++ -*-
//
// Copyright (C) 2009-2014 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library 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, 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 General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
/** @file profile/impl/profiler_hash_func.h
* @brief Data structures to represent profiling traces.
*/
// Written by Lixia Liu and Silvius Rus.
#ifndef _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H
#define _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H 1
#include "profile/impl/profiler.h"
#include "profile/impl/profiler_node.h"
#include "profile/impl/profiler_trace.h"
namespace __gnu_profile
{
/** @brief A hash performance instrumentation line in the object table. */
class __hashfunc_info
: public __object_info_base
{
public:
__hashfunc_info(__stack_t __stack)
: __object_info_base(__stack), _M_longest_chain(0),
_M_accesses(0), _M_hops(0) { }
void
__merge(const __hashfunc_info& __o)
{
__object_info_base::__merge(__o);
_M_longest_chain = std::max(_M_longest_chain, __o._M_longest_chain);
_M_accesses += __o._M_accesses;
_M_hops += __o._M_hops;
}
void
__destruct(std::size_t __chain, std::size_t __accesses,
std::size_t __hops)
{
_M_longest_chain = std::max(_M_longest_chain, __chain);
_M_accesses += __accesses;
_M_hops += __hops;
}
void
__write(FILE* __f) const
{ std::fprintf(__f, "%Zu %Zu %Zu\n", _M_hops,
_M_accesses, _M_longest_chain); }
float
__magnitude() const
{ return static_cast<float>(_M_hops); }
std::string
__advice() const
{ return "change hash function"; }
private:
std::size_t _M_longest_chain;
std::size_t _M_accesses;
std::size_t _M_hops;
};
/** @brief A hash performance instrumentation line in the stack table. */
class __hashfunc_stack_info
: public __hashfunc_info
{
public:
__hashfunc_stack_info(const __hashfunc_info& __o)
: __hashfunc_info(__o) { }
};
/** @brief Hash performance instrumentation producer. */
class __trace_hash_func
: public __trace_base<__hashfunc_info, __hashfunc_stack_info>
{
public:
__trace_hash_func()
: __trace_base<__hashfunc_info, __hashfunc_stack_info>()
{ __id = "hash-distr"; }
~__trace_hash_func() {}
// Call at destruction/clean to set container final size.
void
__destruct(__hashfunc_info* __obj_info,
std::size_t __chain, std::size_t __accesses, std::size_t __hops)
{
if (!__obj_info)
return;
__obj_info->__destruct(__chain, __accesses, __hops);
__retire_object(__obj_info);
}
};
inline void
__trace_hash_func_init()
{ _GLIBCXX_PROFILE_DATA(_S_hash_func) = new __trace_hash_func(); }
inline void
__trace_hash_func_free()
{ delete _GLIBCXX_PROFILE_DATA(_S_hash_func); }
inline void
__trace_hash_func_report(FILE* __f, __warning_vector_t& __warnings)
{ __trace_report(_GLIBCXX_PROFILE_DATA(_S_hash_func), __f, __warnings); }
inline __hashfunc_info*
__trace_hash_func_construct()
{
if (!__profcxx_init())
return 0;
if (!__reentrance_guard::__get_in())
return 0;
__reentrance_guard __get_out;
return _GLIBCXX_PROFILE_DATA(_S_hash_func)->__add_object(__get_stack());
}
inline void
__trace_hash_func_destruct(__hashfunc_info* __obj_info,
std::size_t __chain, std::size_t __accesses,
std::size_t __hops)
{
_GLIBCXX_PROFILE_DATA(_S_hash_func)->__destruct(__obj_info, __chain,
__accesses, __hops);
}
} // namespace __gnu_profile
#endif /* _GLIBCXX_PROFILE_PROFILER_HASH_FUNC_H */
|
/* GEGL - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* 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 3 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 GEGL; if not, see <http://www.gnu.org/licenses/>.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GEGL_REGION_H__
#define __GEGL_REGION_H__
#include <gegl/gegl-types-internal.h>
#include "gegl-buffer-types.h"
G_BEGIN_DECLS
struct _GeglSegment
{
gint x1;
gint y1;
gint x2;
gint y2;
};
struct _GeglSpan
{
gint x;
gint y;
gint width;
};
/* Type definitions for the basic structures.
*/
typedef struct _GeglSegment GeglSegment;
typedef struct _GeglSpan GeglSpan;
/* GC fill rule for polygons
* EvenOddRule
* WindingRule
*/
typedef enum
{
GEGL_EVEN_ODD_RULE,
GEGL_WINDING_RULE
} GeglFillRule;
/* Types of overlapping between a rectangle and a region
* GEGL_OVERLAP_RECTANGLE_IN: rectangle is in region
* GEGL_OVERLAP_RECTANGLE_OUT: rectangle in not in region
* GEGL_OVERLAP_RECTANGLE_PART: rectangle in partially in region
*/
typedef enum
{
GEGL_OVERLAP_RECTANGLE_IN,
GEGL_OVERLAP_RECTANGLE_OUT,
GEGL_OVERLAP_RECTANGLE_PART
} GeglOverlapType;
typedef void (* GeglSpanFunc) (GeglSpan *span,
gpointer data);
GeglRegion * gegl_region_new (void);
GeglRegion * gegl_region_polygon (GeglPoint *points,
gint n_points,
GeglFillRule fill_rule);
GeglRegion * gegl_region_copy (const GeglRegion *region);
GeglRegion * gegl_region_rectangle (const GeglRectangle *rectangle);
void gegl_region_destroy (GeglRegion *region);
void gegl_region_get_clipbox (GeglRegion *region,
GeglRectangle *rectangle);
void gegl_region_get_rectangles (GeglRegion *region,
GeglRectangle **rectangles,
gint *n_rectangles);
gboolean gegl_region_empty (const GeglRegion *region);
gboolean gegl_region_equal (const GeglRegion *region1,
const GeglRegion *region2);
gboolean gegl_region_point_in (const GeglRegion *region,
gint x,
gint y);
GeglOverlapType gegl_region_rect_in (const GeglRegion *region,
const GeglRectangle *rectangle);
void gegl_region_offset (GeglRegion *region,
gint dx,
gint dy);
void gegl_region_shrink (GeglRegion *region,
gint dx,
gint dy);
void gegl_region_union_with_rect (GeglRegion *region,
const GeglRectangle *rect);
void gegl_region_intersect (GeglRegion *source1,
const GeglRegion *source2);
void gegl_region_union (GeglRegion *source1,
const GeglRegion *source2);
void gegl_region_subtract (GeglRegion *source1,
const GeglRegion *source2);
void gegl_region_xor (GeglRegion *source1,
const GeglRegion *source2);
void gegl_region_dump (GeglRegion *region);
void gegl_region_spans_intersect_foreach (GeglRegion *region,
GeglSpan *spans,
int n_spans,
gboolean sorted,
GeglSpanFunc function,
gpointer data);
G_END_DECLS
#endif /* __GEGL_REGION_H__ */
|
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QBEARERENGINE_IMPL_H
#define QBEARERENGINE_IMPL_H
#include <QtNetwork/private/qbearerengine_p.h>
#ifndef QT_NO_BEARERMANAGEMENT
QT_BEGIN_NAMESPACE
class QBearerEngineImpl : public QBearerEngine
{
Q_OBJECT
public:
enum ConnectionError {
InterfaceLookupError = 0,
ConnectError,
OperationNotSupported,
DisconnectionError,
};
QBearerEngineImpl(QObject *parent = 0) : QBearerEngine(parent) { }
~QBearerEngineImpl() { }
virtual void connectToId(const QString &id) = 0;
virtual void disconnectFromId(const QString &id) = 0;
virtual QString getInterfaceFromId(const QString &id) = 0;
virtual QNetworkSession::State sessionStateForId(const QString &id) = 0;
virtual quint64 bytesWritten(const QString &) { return Q_UINT64_C(0); }
virtual quint64 bytesReceived(const QString &) { return Q_UINT64_C(0); }
virtual quint64 startTime(const QString &) { return Q_UINT64_C(0); }
Q_SIGNALS:
void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error);
};
QT_END_NAMESPACE
#endif // QT_NO_BEARERMANAGEMENT
#endif
|
#pragma once
#include <wx/thread.h>
#include <wx/textctrl.h>
#include <wx/gauge.h>
#include <wx/button.h>
class Generator : public wxThread{
public:
// Thread built
Generator(wxString lua_file, wxString ass_file, wxString output_file, wxString command, wxString sound, wxTextCtrl *log, wxGauge *progressbar, wxButton *gencanc);
// Thread run end
~Generator();
private:
// Object references
wxString lua_file, ass_file, output_file, command, sound;
wxTextCtrl *log;
wxGauge *progressbar;
wxButton *gencanc;
protected:
// Thread run
ExitCode Entry();
};
|
/*--------------------------------------------------------------------
(C) Copyright 2006-2013 Barcelona Supercomputing Center
Centro Nacional de Supercomputacion
This file is part of Mercurium C/C++ source-to-source compiler.
See AUTHORS file in the top level directory for information
regarding developers and contributors.
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 3 of the License, or (at your option) any later version.
Mercurium C/C++ source-to-source compiler 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 Mercurium C/C++ source-to-source compiler; if
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
Cambridge, MA 02139, USA.
--------------------------------------------------------------------*/
/*
<testinfo>
test_generator=config/mercurium-ompss
</testinfo>
*/
#include<assert.h>
#pragma omp task in(x)
int foo(int x, char wait)
{
if (wait)
{
for(int i = 0; i < 10000; ++i)
{
for(int j = 0; j < 100; ++j)
{}
}
}
return x + 1;
}
int main()
{
int valor = 0;
int x = 0;
x = foo(foo(valor, 1), 0);
#pragma omp taskwait
assert(x == 2);
}
|
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
#include <gsl/gsl_math.h>
#include <math.h>
#include <options/options.h>
#include "../csm/csm_all.h"
struct {
double interval;
int seed;
}p ;
LDP ld_resample(LDP ld);
gsl_rng * rng;
int main(int argc, const char ** argv) {
sm_set_program_name(argv[0]);
struct option* ops = options_allocate(3);
options_double(ops, "interval", &p.interval, sqrt(2.0), " 1 = no resampling");
if(!options_parse_args(ops, argc, argv)) {
options_print_help(ops, stderr);
return -1;
}
int count = -1;
LDP ld;
while( (ld = ld_read_smart(stdin))) {
count++;
if(!ld_valid_fields(ld)) {
sm_error("Invalid laser data (#%d in file)\n", count);
continue;
}
/* if(count & 1) {*/
LDP ld2 = ld_resample(ld);
ld_write_as_json(ld2, stdout);
ld_free(ld2);
ld_free(ld);
/* } else {
ld_write_as_json(ld, stdout);
ld_free(ld);
}*/
count++;
}
return 0;
}
LDP ld_resample(LDP ld) {
/* FIXME magic number */
int n = (int) (floor(ld->nrays / p.interval));
LDP ld2 = ld_alloc_new(n);
int k;
for(k=0;k<n;k++) {
double index = k * p.interval;
int i = (int) floor(index);
int j = i + 1;
double a = 1 - (index - i);
if( (j>= ld->nrays) || !ld->valid[i] || !ld->valid[j]) {
ld2->valid[k] = 0;
ld2->readings[k] = NAN;
ld2->alpha_valid[k] = 0;
ld2->alpha[k] = NAN;
ld2->theta[k] = ld->theta[i];
} else {
ld2->theta[k] = a * ld->theta[i] + (1-a) * ld->theta[j];
if(is_nan(ld2->theta[k])) {
sm_debug("Hey, k=%d theta[%d]=%f theta[%d]=%f\n",
k,i,ld->theta[i],j,ld->theta[j]);
}
ld2->readings[k] = a * ld->readings[i] + (1-a) * ld->readings[j];
ld2->valid[k] = 1;
}
/* sm_debug("k=%d index=%f i=%d a=%f valid %d reading %f\n", k,index,i,a,ld2->valid[k],ld2->readings[k]);*/
}
ld2->min_theta = ld2->theta[0];
ld2->max_theta = ld2->theta[n-1];
ld2->tv = ld->tv;
copy_d(ld->odometry, 3, ld2->odometry);
copy_d(ld->estimate, 3, ld2->estimate);
return ld2;
}
|
/// @author Alexander Rykovanov 2013
/// @email rykovanov.as@gmail.com
/// @brief View services interface.
/// @license GNU LGPL
///
/// Distributed under the GNU LGPL License
/// (See accompanying file LICENSE or copy at
/// http://www.gnu.org/licenses/lgpl.html)
///
#ifndef OPC_UA_Client_VIEW_H
#define OPC_UA_Client_VIEW_H
#include <opc/common/interface.h>
#include <opc/common/class_pointers.h>
#include <opc/ua/protocol/types.h>
#include <opc/ua/protocol/view.h>
#include <vector>
namespace OpcUa
{
class ViewServices : private Common::Interface
{
public:
DEFINE_CLASS_POINTERS(ViewServices);
public:
virtual std::vector<BrowseResult> Browse(const OpcUa::NodesQuery& query) const = 0;
virtual std::vector<BrowseResult> BrowseNext() const = 0;
virtual std::vector<BrowsePathResult> TranslateBrowsePathsToNodeIds(const TranslateBrowsePathsParameters& params) const = 0;
virtual std::vector<NodeId> RegisterNodes(const std::vector<NodeId>& params) const = 0;
virtual void UnregisterNodes(const std::vector<NodeId>& params) const = 0;
};
} // namespace OpcUa
#endif // OPC_UA_Client_VIEW_H
|
// Copyright 2017-present the Material Components for iOS authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#import <UIKit/UIKit.h>
#import "MDCFontTextStyle.h"
@interface UIFont (MaterialTypography)
/**
Returns an instance of the font associated with the Material text style and scaled based on the
content size category.
@param style The Material font text style for which to return a font.
@return The font associated with the specified style.
*/
+ (nonnull UIFont *)mdc_preferredFontForMaterialTextStyle:(MDCFontTextStyle)style
API_DEPRECATED("Follow go/material-ios-dynamic-type#custom-fonts instead.",
ios(11, API_TO_BE_DEPRECATED));
/**
Returns an instance of the font associated with the Material text style
This font is *not* scaled based on the content size category (Dynamic Type).
@param style The Material font text style for which to return a font.
@return The font associated with the specified style.
*/
+ (nonnull UIFont *)mdc_standardFontForMaterialTextStyle:(MDCFontTextStyle)style
API_DEPRECATED("Follow go/material-ios-dynamic-type#custom-fonts instead.",
ios(11, API_TO_BE_DEPRECATED));
/**
Returns an new instance of the font sized according to the text-style and whether the content
size category (Dynamic Type) should be taken into account.
@param style The Material font text style that will determine the fontSize of the new font
@param scaled Should the new font be scaled according to the content size category (Dynamic Type)
*/
- (nonnull UIFont *)mdc_fontSizedForMaterialTextStyle:(MDCFontTextStyle)style
scaledForDynamicType:(BOOL)scaled
API_DEPRECATED("Follow go/material-ios-dynamic-type#custom-fonts instead.",
ios(11, API_TO_BE_DEPRECATED));
@end
|
/* This file was converted by gperf_fold_key_conv.py
from gperf output file. */
/* ANSI-C code produced by gperf version 3.1 */
/* Command-line: /usr/bin/gperf -n -C -T -c -t -j1 -L ANSI-C -F,-1 -N onigenc_unicode_fold2_key unicode_fold2_key.gperf */
/* Computed positions: -k'3,6' */
/* This gperf source file was generated by make_unicode_fold_data.py */
/*-
* Copyright (c) 2017-2018 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
* 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 AUTHOR 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 AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
//#include <string.h>
#include "regenc.h"
#define TOTAL_KEYWORDS 59
#define MIN_WORD_LENGTH 6
#define MAX_WORD_LENGTH 6
#define MIN_HASH_VALUE 0
#define MAX_HASH_VALUE 58
/* maximum key range = 59, duplicates = 0 */
#ifdef __GNUC__
__inline
#else
#ifdef __cplusplus
inline
#endif
#endif
/*ARGSUSED*/
static unsigned int
hash(OnigCodePoint codes[])
{
static const unsigned char asso_values[] =
{
58, 57, 56, 55, 54, 53, 52, 16, 50, 59,
15, 59, 25, 59, 59, 59, 59, 59, 59, 3,
59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 59, 49, 48, 47, 46, 45, 44, 43, 42,
59, 59, 59, 59, 59, 59, 59, 59, 59, 21,
59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 59, 59, 59, 59, 59, 2, 59, 59, 59,
59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 59, 59, 59, 59, 59, 40, 20, 39, 38,
37, 14, 5, 36, 20, 7, 25, 34, 29, 32,
16, 59, 31, 59, 59, 2, 1, 59, 25, 15,
59, 14, 59, 59, 28, 59, 2, 59, 59, 59,
11, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 59, 24, 59, 22, 59, 59, 11, 59, 59,
59, 59, 59, 7, 59, 0, 59, 59, 16, 59,
1, 59, 59, 16, 59, 59, 59, 15, 59, 59,
59, 6, 59, 59, 59, 59, 0, 59, 59, 59,
59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 59, 59, 59, 59, 59
};
return asso_values[(unsigned char)onig_codes_byte_at(codes, 5)] + asso_values[(unsigned char)onig_codes_byte_at(codes, 2)];
}
int
onigenc_unicode_fold2_key(OnigCodePoint codes[])
{
static const short int wordlist[] =
{
101,
253,
76,
29,
24,
239,
96,
71,
92,
67,
4,
62,
8,
58,
234,
109,
164,
88,
84,
80,
214,
0,
54,
261,
50,
105,
121,
125,
257,
42,
38,
249,
46,
117,
12,
113,
244,
229,
224,
219,
209,
16,
204,
199,
194,
189,
184,
179,
174,
169,
20,
34,
159,
154,
149,
144,
139,
134,
129
};
if (0 == 0)
{
int key = hash(codes);
if (key <= MAX_HASH_VALUE)
{
int index = wordlist[key];
if (index >= 0 && onig_codes_cmp(codes, OnigUnicodeFolds2 + index, 2) == 0)
return index;
}
}
return -1;
}
|
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2017, STMicroelectronics
* 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 STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************
*/
#ifndef MBED_OBJECTS_H
#define MBED_OBJECTS_H
#include "cmsis.h"
#include "PortNames.h"
#include "PeripheralNames.h"
#include "PinNames.h"
#ifdef __cplusplus
extern "C" {
#endif
struct gpio_irq_s {
IRQn_Type irq_n;
uint32_t irq_index;
uint32_t event;
PinName pin;
};
struct port_s {
PortName port;
uint32_t mask;
PinDirection direction;
__IO uint32_t *reg_in;
__IO uint32_t *reg_out;
};
struct can_s {
CANName can;
int index;
};
struct trng_s {
RNG_HandleTypeDef handle;
};
#include "common_objects.h"
#ifdef __cplusplus
}
#endif
#endif
|
/* mbed Microcontroller Library
* A generic CMSIS include header
*******************************************************************************
* Copyright (c) 2014, STMicroelectronics
* 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 STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************
*/
#ifndef MBED_CMSIS_H
#define MBED_CMSIS_H
#include "stm32f4xx.h"
#include "cmsis-core/cmsis_nvic.h"
#endif
|
/* $OpenBSD: auth2-passwd.c,v 1.19 2020/10/18 11:32:01 djm Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. 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 AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "includes.h"
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include "packet.h"
#include "ssherr.h"
#include "log.h"
#include "sshkey.h"
#include "hostfile.h"
#include "auth.h"
#ifdef GSSAPI
#include "ssh-gss.h"
#endif
#include "monitor_wrap.h"
#include "misc.h"
#include "servconf.h"
/* import */
extern ServerOptions options;
static int
userauth_passwd(struct ssh *ssh)
{
char *password;
int authenticated = 0, r;
u_char change;
size_t len;
if ((r = sshpkt_get_u8(ssh, &change)) != 0 ||
(r = sshpkt_get_cstring(ssh, &password, &len)) != 0 ||
(change && (r = sshpkt_get_cstring(ssh, NULL, NULL)) != 0) ||
(r = sshpkt_get_end(ssh)) != 0)
fatal_fr(r, "parse packet");
if (change)
logit("password change not supported");
else if (PRIVSEP(auth_password(ssh, password)) == 1)
authenticated = 1;
freezero(password, len);
return authenticated;
}
Authmethod method_passwd = {
"password",
userauth_passwd,
&options.password_authentication
};
|
/**
r_errors.c
Copyright (C) 2002-2003, Network Resonance, Inc.
Copyright (C) 2006, Network Resonance, 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.
3. Neither the name of Network Resonance, Inc. nor the name of any
contributors to this software may be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
/**
r_errors.c
Copyright (C) 1999-2000 RTFM, Inc.
All Rights Reserved
This package is a SSLv3/TLS protocol analyzer written by Eric Rescorla
<ekr@rtfm.com> and licensed by RTFM, Inc.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by Eric Rescorla for
RTFM, Inc.
4. Neither the name of RTFM, Inc. nor the name of Eric Rescorla may be
used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY ERIC RESCORLA AND RTFM, INC. ``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 SUCH DAMAGE.
$Id: r_errors.c,v 1.5 2008/11/26 03:22:02 adamcain Exp $
ekr@rtfm.com Tue Feb 16 16:37:05 1999
*/
static char *RCSSTRING __UNUSED__ ="$Id: r_errors.c,v 1.5 2008/11/26 03:22:02 adamcain Exp $";
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include "r_common.h"
#include "r_errors.h"
static struct {
int errnum;
char *str;
} errors[] = NR_ERROR_MAPPING;
int nr_verr_exit(char *fmt,...)
{
va_list ap;
va_start(ap,fmt);
vfprintf(stderr,fmt,ap);
if (fmt[0] != '\0' && fmt[strlen(fmt)-1] != '\n')
fprintf(stderr,"\n");
exit(1);
}
char *
nr_strerror(int errnum)
{
static char unknown_error[256];
int i;
char *error = 0;
for (i = 0; i < sizeof(errors)/sizeof(*errors); ++i) {
if (errnum == errors[i].errnum) {
error = errors[i].str;
break;
}
}
if (! error) {
snprintf(unknown_error, sizeof(unknown_error), "Unknown error: %d", errnum);
error = unknown_error;
}
return error;
}
int
nr_strerror_r(int errnum, char *strerrbuf, size_t buflen)
{
char *error = nr_strerror(errnum);
snprintf(strerrbuf, buflen, "%s", error);
return 0;
}
|
/* test random number generator APIs */
/*
* Copyright (c) 2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* This tests the following random number routines:
* u32_t sys_rand32_get(void);
*/
#include <ztest.h>
#include <logging/sys_log.h>
#define N_VALUES 10
/**
*
* @brief Regression test's entry point
*
*
* @return N/A
*/
void test_rand32(void)
{
u32_t gen, last_gen;
int rnd_cnt;
int equal_count = 0;
/*
* Test subsequently calls sys_rand32_get(), checking
* that two values are not equal.
*/
SYS_LOG_DBG("Generating random numbers");
last_gen = sys_rand32_get();
/*
* Get several subsequent numbers as fast as possible.
* Based on review comments in
* https://github.com/zephyrproject-rtos/zephyr/pull/5066
* If minimum half of the numbers generated were the same
* as the previously generated one, then test fails, this
* should catch a buggy sys_rand32_get() function.
*/
for (rnd_cnt = 0; rnd_cnt < (N_VALUES - 1); rnd_cnt++) {
gen = sys_rand32_get();
if (gen == last_gen) {
equal_count++;
}
last_gen = gen;
}
if (equal_count > N_VALUES / 2) {
zassert_false((equal_count > N_VALUES / 2),
"random numbers returned same value with high probability");
}
}
void test_main(void)
{
ztest_test_suite(common_test,
ztest_unit_test(test_rand32)
);
ztest_run_test_suite(common_test);
}
|
/*!
* @file ezs_dac.c
* @brief A very simple DA converter, based on Fail*
* @author Martin Hoffmann
* \ingroup dac
*/
#include <stdint.h>
#include "ezs_dac.h"
static volatile uint8_t ezs_dac_out_register;
/*!
* \brief Write a value to the DAC
*/
void ezs_dac_write(uint8_t value){
ezs_dac_out_register = value;
}
|
/****************************************************************************
* *
* PrimeSense Sensor 5.x Alpha *
* Copyright (C) 2011 PrimeSense Ltd. *
* *
* This file is part of PrimeSense Sensor. *
* *
* PrimeSense Sensor is free software: you can redistribute it and/or modify*
* it under the terms of the GNU Lesser General Public License as published *
* by the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* PrimeSense Sensor 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 PrimeSense Sensor. If not, see <http://www.gnu.org/licenses/>.*
* *
****************************************************************************/
#ifndef __XN_STRING_PROPERTY_H__
#define __XN_STRING_PROPERTY_H__
//---------------------------------------------------------------------------
// Includes
//---------------------------------------------------------------------------
#include <XnDDK/XnProperty.h>
//---------------------------------------------------------------------------
// Class
//---------------------------------------------------------------------------
/**
* A property of type general.
*/
class XN_DDK_CPP_API XnStringProperty : public XnProperty
{
public:
XnStringProperty(const XnChar* strName, XnChar* pValueHolder, const XnChar* strModule = "");
typedef XnStatus (XN_CALLBACK_TYPE* SetFuncPtr)(XnStringProperty* pSender, const XnChar* strValue, void* pCookie);
typedef XnStatus (XN_CALLBACK_TYPE* GetFuncPtr)(const XnStringProperty* pSender, XnChar* csValue, void* pCookie);
inline XnStatus SetValue(const XnChar* strValue)
{
XN_VALIDATE_INPUT_PTR(strValue);
return XnProperty::SetValue(strValue);
}
inline XnStatus GetValue(XnChar* csValue) const
{
XN_VALIDATE_INPUT_PTR(csValue);
return XnProperty::GetValue(csValue);
}
inline XnStatus UnsafeUpdateValue(const XnChar* strValue)
{
XN_VALIDATE_INPUT_PTR(strValue);
return XnProperty::UnsafeUpdateValue(strValue);
}
inline void UpdateSetCallback(SetFuncPtr pFunc, void* pCookie)
{
XnProperty::UpdateSetCallback((XnProperty::SetFuncPtr)pFunc, pCookie);
}
inline void UpdateGetCallback(GetFuncPtr pFunc, void* pCookie)
{
XnProperty::UpdateGetCallback((XnProperty::GetFuncPtr)pFunc, pCookie);
}
XnStatus ReadValueFromFile(const XnChar* csINIFile, const XnChar* csSection);
XnStatus AddToPropertySet(XnPropertySet* pSet);
protected:
//---------------------------------------------------------------------------
// Overridden Methods
//---------------------------------------------------------------------------
virtual XnStatus CopyValueImpl(void* pDest, const void* pSource) const;
virtual XnBool IsEqual(const void* pValue1, const void* pValue2) const;
virtual XnStatus CallSetCallback(XnProperty::SetFuncPtr pFunc, const void* pValue, void* pCookie);
virtual XnStatus CallGetCallback(XnProperty::GetFuncPtr pFunc, void* pValue, void* pCookie) const;
virtual XnBool ConvertValueToString(XnChar* csValue, const void* pValue) const;
};
#endif //__XN_STRING_PROPERTY_H__ |
//
// Integrated+Extensions.h
// LastHistory
//
// Created by Frederik Seiffert on 28.11.08.
// Copyright 2008 Frederik Seiffert. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <CommonCrypto/CommonDigest.h>
#import <CommonCrypto/CommonHMAC.h>
#import <CommonCrypto/CommonCryptor.h>
@interface NSString (Extensions)
//中文编码转换
/**
* URL encodes a string
*/
- (NSString*)stringByURLEncodingStringParameter;
+ (NSString *)getDate;
+ (NSString *)createUUID;
+ (NSString *)decodeUTF8ToChinese:(NSString *)encodeStr;
+ (NSString *)encodeChineseToUTF8:(NSString *)encodeStr;
+ (NSString *)encodeURL:(NSString *)string;
+ (NSString *)encodeURL:(NSString *)string endcode:(NSStringEncoding)stringEncoding;
+ (NSString *)encodeURL:(NSString *)originalString stringEncoding:(NSStringEncoding)stringEncoding;
+ (NSString*)encodeXML:(NSString *)originalString;
+ (NSString*)decodeXML:(NSString *)originalString;
+ (NSString *)unEscapedString:(NSString *)oldString;
- (NSString *)stringByEscapingMetacharacters;
//加密解密
- (NSString *)md5;
+ (NSData *)desData:(NSData *)data key:(NSString *)keyString CCOperation:(CCOperation)op;
//3des+base64
+ (NSString *)tripleDES:(NSString*)dataString encryptOrDecrypt:(CCOperation)encryptOrDecrypt key:(NSString*)key;
+ (NSString *)getEscapeMetacharacters:(NSString *)formatString;
@end
@interface UIColor (Color)
+ (UIColor *) colorWithHexString: (NSString *) stringToConvert;
@end
@interface UIColor (Document)
+ (NSString *)documentsDirectory;
@end |
//
// GradientStop.h
// Beautify
//
// Created by Chris Grant on 28/02/2013.
// Copyright (c) Beautify. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "JSONModel.h"
@protocol BYGradientStop
@end
@interface NSArray (Stop) <BYGradientStop>
@end
/**
A style property representing a stop for a background gradient for a UIView.
*/
@interface BYGradientStop : JSONModel <NSCopying>
/**
The color to use for this stop.
*/
@property UIColor *color;
/**
The location of the stop, in the range 0-1.
*/
@property float position;
/**
Create with the specified color at the specified location.
*/
+(BYGradientStop*)stopWithColor:(UIColor*)color at:(float)stop;
@end |
/*
* Copyright 1999 SuSE, Inc.
*
* 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, and that the name of SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Keith Packard, SuSE, Inc.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <X11/fonts/fntfilst.h>
#include <X11/fonts/fontutil.h>
#include <X11/fonts/pcf.h>
#include "builtin.h"
static int
BuiltinOpenBitmap (FontPathElementPtr fpe, FontPtr *ppFont, int flags,
FontEntryPtr entry, char *fileName, fsBitmapFormat format,
fsBitmapFormatMask fmask, FontPtr unused)
{
FontFilePtr file;
FontPtr pFont;
int ret;
int bit,
byte,
glyph,
scan,
image;
file = BuiltinFileOpen (fileName);
if (!file)
return BadFontName;
pFont = malloc(sizeof(FontRec));
if (!pFont) {
BuiltinFileClose (file, 0);
return AllocError;
}
/* set up default values */
FontDefaultFormat(&bit, &byte, &glyph, &scan);
/* get any changes made from above */
ret = CheckFSFormat(format, fmask, &bit, &byte, &scan, &glyph, &image);
/* Fill in font record. Data format filled in by reader. */
pFont->refcnt = 0;
pFont->maxPrivate = -1;
pFont->devPrivates = (pointer *) 0;
ret = pcfReadFont (pFont, file, bit, byte, glyph, scan);
BuiltinFileClose (file, 0);
if (ret != Successful)
free(pFont);
else
*ppFont = pFont;
return ret;
}
static int
BuiltinGetInfoBitmap (FontPathElementPtr fpe, FontInfoPtr pFontInfo,
FontEntryPtr entry, char *fileName)
{
FontFilePtr file;
int ret;
file = BuiltinFileOpen (fileName);
if (!file)
return BadFontName;
ret = pcfReadFontInfo (pFontInfo, file);
BuiltinFileClose (file, 0);
return ret;
}
static int
BuiltinOpenScalable (FontPathElementPtr fpe,
FontPtr *pFont,
int flags,
FontEntryPtr entry,
char *fileName,
FontScalablePtr vals,
fsBitmapFormat format,
fsBitmapFormatMask fmask,
FontPtr non_cachable_font) /* We don't do licensing */
{
return BadFontName;
}
static int
BuiltinGetInfoScalable (FontPathElementPtr fpe,
FontInfoPtr pFontInfo,
FontEntryPtr entry,
FontNamePtr fontName,
char *fileName,
FontScalablePtr vals)
{
return BadFontName;
}
static FontRendererRec renderers[] = {
{ ".builtin", 8,
BuiltinOpenBitmap,
BuiltinOpenScalable,
BuiltinGetInfoBitmap,
BuiltinGetInfoScalable,
0 }
};
#define numRenderers (sizeof renderers / sizeof renderers[0])
void
BuiltinRegisterFontFileFunctions(void)
{
int i;
for (i = 0; i < numRenderers; i++)
FontFileRegisterRenderer ((FontRendererRec *) &renderers[i]);
}
|
/*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#pragma once
#include <aws/mediaconvert/MediaConvert_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
namespace Aws
{
namespace MediaConvert
{
namespace Model
{
enum class OutputSdt
{
NOT_SET,
SDT_FOLLOW,
SDT_FOLLOW_IF_PRESENT,
SDT_MANUAL,
SDT_NONE
};
namespace OutputSdtMapper
{
AWS_MEDIACONVERT_API OutputSdt GetOutputSdtForName(const Aws::String& name);
AWS_MEDIACONVERT_API Aws::String GetNameForOutputSdt(OutputSdt value);
} // namespace OutputSdtMapper
} // namespace Model
} // namespace MediaConvert
} // namespace Aws
|
/*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#pragma once
#include <aws/sts/STS_EXPORTS.h>
#include <aws/sts/STSRequest.h>
namespace Aws
{
namespace STS
{
namespace Model
{
/**
*/
class AWS_STS_API GetCallerIdentityRequest : public STSRequest
{
public:
GetCallerIdentityRequest();
Aws::String SerializePayload() const override;
protected:
void DumpBodyToUrl(Aws::Http::URI& uri ) const override;
public:
};
} // namespace Model
} // namespace STS
} // namespace Aws
|
/* Copyright 2015 CyberTech Labs Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. */
#pragma once
#include <QtCore/QByteArray>
#include <trikHal/trikHalDeclSpec.h>
namespace trikHal {
/// Communicates with MSP processor over USB bus.
class TRIKHAL_EXPORT MspUsbInterface
{
Q_DISABLE_COPY(MspUsbInterface)
public:
MspUsbInterface() = default;
virtual ~MspUsbInterface() = default;
/// Send data to MSP.
virtual void send(const QByteArray &data) = 0;
/// Reads data by given MSP command number and returns the result.
virtual int read(const QByteArray &data) = 0;
/// Establish connection with MSP over USB bus.
virtual bool connect() = 0;
/// Disconnect from MSP.
virtual void disconnect() = 0;
};
}
|
/*
* _coder_rpy2quat_mex.c
*
* Code generation for function 'rpy2quat'
*
*/
/* Include files */
#include "mex.h"
#include "_coder_rpy2quat_api.h"
/* Function Declarations */
static void rpy2quat_mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
/* Variable Definitions */
emlrtContext emlrtContextGlobal = { true, false, EMLRT_VERSION_INFO, NULL, "rpy2quat", NULL, false, {2045744189U,2170104910U,2743257031U,4284093946U}, NULL };
void *emlrtRootTLSGlobal = NULL;
/* Function Definitions */
static void rpy2quat_mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
const mxArray *outputs[1];
const mxArray *inputs[3];
int n = 0;
int nOutputs = (nlhs < 1 ? 1 : nlhs);
int nInputs = nrhs;
emlrtStack st = { NULL, NULL, NULL };
/* Module initialization. */
rpy2quat_initialize(&emlrtContextGlobal);
st.tls = emlrtRootTLSGlobal;
/* Check for proper number of arguments. */
if (nrhs != 3) {
emlrtErrMsgIdAndTxt(&st, "EMLRT:runTime:WrongNumberOfInputs", 5, mxINT32_CLASS, 3, mxCHAR_CLASS, 8, "rpy2quat");
} else if (nlhs > 1) {
emlrtErrMsgIdAndTxt(&st, "EMLRT:runTime:TooManyOutputArguments", 3, mxCHAR_CLASS, 8, "rpy2quat");
}
/* Temporary copy for mex inputs. */
for (n = 0; n < nInputs; ++n) {
inputs[n] = prhs[n];
}
/* Call the function. */
rpy2quat_api(inputs, outputs);
/* Copy over outputs to the caller. */
for (n = 0; n < nOutputs; ++n) {
plhs[n] = emlrtReturnArrayR2009a(outputs[n]);
}
/* Module finalization. */
rpy2quat_terminate();
}
void rpy2quat_atexit_wrapper(void)
{
rpy2quat_atexit();
}
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
/* Initialize the memory manager. */
mexAtExit(rpy2quat_atexit_wrapper);
/* Dispatch the entry-point. */
rpy2quat_mexFunction(nlhs, plhs, nrhs, prhs);
}
/* End of code generation (_coder_rpy2quat_mex.c) */
|
#pragma once
#include <boost/serialization/export.hpp>
#include <boost/serialization/access.hpp>
#include <boost/serialization/base_object.hpp>
#include "dynet/dynet.h"
#include "dynet/rnn.h"
#include "dynet/expr.h"
#include "dynet/lstm.h"
using namespace dynet::expr;
namespace dynet {
struct TreeLSTMBuilder : public RNNBuilder {
public:
virtual Expression back() const override;
virtual std::vector<Expression> final_h() const override;
virtual std::vector<Expression> final_s() const override;
virtual unsigned num_h0_components() const override;
virtual void copy(const RNNBuilder & params) override;
virtual Expression add_input(int id, std::vector<int> children, const Expression& x) = 0;
std::vector<Expression> get_h(RNNPointer i) const override { throw std::runtime_error("get_h() not a valid function for TreeLSTMBuilder"); }
std::vector<Expression> get_s(RNNPointer i) const override { throw std::runtime_error("get_s() not a valid function for TreeLSTMBuilder"); }
Expression set_s_impl(int prev, const std::vector<Expression>& s_new) override { throw std::runtime_error("set_s_impl() not a valid function for TreeLSTMBuilder"); }
protected:
virtual void new_graph_impl(ComputationGraph& cg) override = 0;
virtual void start_new_sequence_impl(const std::vector<Expression>& h0) override = 0;
virtual Expression add_input_impl(int prev, const Expression& x) override;
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int) {
ar & boost::serialization::base_object<RNNBuilder>(*this);
}
};
struct NaryTreeLSTMBuilder : public TreeLSTMBuilder {
NaryTreeLSTMBuilder() = default;
explicit NaryTreeLSTMBuilder(unsigned N, //Max branching factor
unsigned layers,
unsigned input_dim,
unsigned hidden_dim,
Model& model);
Expression add_input(int id, std::vector<int> children, const Expression& x) override;
void copy(const RNNBuilder & params) override;
protected:
void new_graph_impl(ComputationGraph& cg) override;
void start_new_sequence_impl(const std::vector<Expression>& h0) override;
Expression Lookup(unsigned layer, unsigned p_type, unsigned value);
public:
// first index is layer, then ...
std::vector<std::vector<Parameter>> params;
std::vector<std::vector<LookupParameter>> lparams;
// first index is layer, then ...
std::vector<std::vector<Expression>> param_vars;
std::vector<std::vector<std::vector<Expression>>> lparam_vars;
// first index is time, second is layer
std::vector<std::vector<Expression>> h, c;
// initial values of h and c at each layer
// - both default to zero matrix input
bool has_initial_state; // if this is false, treat h0 and c0 as 0
std::vector<Expression> h0;
std::vector<Expression> c0;
unsigned layers;
unsigned N; // Max branching factor
private:
ComputationGraph* cg;
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int) {
ar & boost::serialization::base_object<TreeLSTMBuilder>(*this);
ar & params;
ar & lparams;
ar & layers;
ar & N;
}
};
struct UnidirectionalTreeLSTMBuilder : public TreeLSTMBuilder {
UnidirectionalTreeLSTMBuilder() = default;
explicit UnidirectionalTreeLSTMBuilder(unsigned layers,
unsigned input_dim,
unsigned hidden_dim,
Model& model);
Expression add_input(int id, std::vector<int> children, const Expression& x) override;
protected:
void new_graph_impl(ComputationGraph& cg) override;
void start_new_sequence_impl(const std::vector<Expression>& h0) override;
public:
LSTMBuilder node_builder;
std::vector<Expression> h;
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int) {
ar & boost::serialization::base_object<TreeLSTMBuilder>(*this);
ar & node_builder;
}
};
struct BidirectionalTreeLSTMBuilder : public TreeLSTMBuilder {
BidirectionalTreeLSTMBuilder() = default;
explicit BidirectionalTreeLSTMBuilder(unsigned layers,
unsigned input_dim,
unsigned hidden_dim,
Model& model);
Expression add_input(int id, std::vector<int> children, const Expression& x) override;
protected:
void new_graph_impl(ComputationGraph& cg) override;
void start_new_sequence_impl(const std::vector<Expression>& h0) override;
Expression set_h_impl(int prev, const std::vector<Expression>& h_new) override;
public:
LSTMBuilder fwd_node_builder;
LSTMBuilder rev_node_builder;
std::vector<Expression> h;
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar, const unsigned int) {
ar & boost::serialization::base_object<TreeLSTMBuilder>(*this);
ar & fwd_node_builder;
ar & rev_node_builder;
}
};
} // namespace dynet
BOOST_CLASS_EXPORT_KEY(dynet::TreeLSTMBuilder)
BOOST_CLASS_EXPORT_KEY(dynet::NaryTreeLSTMBuilder)
BOOST_CLASS_EXPORT_KEY(dynet::UnidirectionalTreeLSTMBuilder)
BOOST_CLASS_EXPORT_KEY(dynet::BidirectionalTreeLSTMBuilder)
|
// Copyright 2016 Markus Tzoe
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef Argument_h
#define Argument_h
#include <atomic>
#include <cstddef>
#include <string>
namespace async {
struct Argument {
enum Type {
UNDEFINED,
BOOLEAN,
NUMBER,
INTEGER,
STRING,
};
Type type;
uintptr_t payload;
virtual ~Argument();
Argument() = delete;
Argument(std::nullptr_t);
Argument(const char* rhs);
Argument(const std::string& rhs);
Argument(bool rhs);
Argument(double rhs);
Argument(int64_t rhs);
Argument(uint64_t rhs);
Argument(int32_t rhs);
Argument(uint32_t rhs);
Argument(const Argument& rhs);
Argument& operator=(const Argument& rhs);
const Argument* next() const;
void next(Argument* p) { nextptr = p; }
size_t size() const;
template <typename T>
T value() const;
private:
std::atomic<uint32_t>* refcnt;
Argument* nextptr;
};
} // namespace async
#endif // Argument_h
|
#ifndef _CAMERA_H_
#define _CAMERA_H_
#include <DirectXMath.h>
#include <AntTweakBar.h>
#include "SimpleMath.h"
using namespace DirectX;
class Camera
{
static float quat[4];
public:
Camera( TwBar *p_bar);
Camera(const Camera&);
~Camera(void);
void setPos(float x, float y, float z);
void setRot(float, float, float);
XMFLOAT3 GetPos() const;
XMFLOAT3 GetRot() const;
void Render();
void GetViewMatrix(XMMATRIX& _out) const;
void RotX(float);
void MovX(float);
void MovY(float);
void MovZ(float);
void GetPosZ(float* get);
private:
float m_positionX, m_positionY, m_positionZ;
float m_rotationX, m_rotationY, m_rotationZ;
XMFLOAT3 lookAt;
XMVECTOR q;
XMMATRIX m_viewMatrix;
TwBar *m_bar;
};
#endif |
/*
* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#pragma once
#include <aws/rds/RDS_EXPORTS.h>
#include <aws/rds/model/DBClusterParameterGroup.h>
#include <aws/rds/model/ResponseMetadata.h>
#include <utility>
namespace Aws
{
template<typename RESULT_TYPE>
class AmazonWebServiceResult;
namespace Utils
{
namespace Xml
{
class XmlDocument;
} // namespace Xml
} // namespace Utils
namespace RDS
{
namespace Model
{
class AWS_RDS_API CopyDBClusterParameterGroupResult
{
public:
CopyDBClusterParameterGroupResult();
CopyDBClusterParameterGroupResult(const Aws::AmazonWebServiceResult<Aws::Utils::Xml::XmlDocument>& result);
CopyDBClusterParameterGroupResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Xml::XmlDocument>& result);
inline const DBClusterParameterGroup& GetDBClusterParameterGroup() const{ return m_dBClusterParameterGroup; }
inline void SetDBClusterParameterGroup(const DBClusterParameterGroup& value) { m_dBClusterParameterGroup = value; }
inline void SetDBClusterParameterGroup(DBClusterParameterGroup&& value) { m_dBClusterParameterGroup = std::move(value); }
inline CopyDBClusterParameterGroupResult& WithDBClusterParameterGroup(const DBClusterParameterGroup& value) { SetDBClusterParameterGroup(value); return *this;}
inline CopyDBClusterParameterGroupResult& WithDBClusterParameterGroup(DBClusterParameterGroup&& value) { SetDBClusterParameterGroup(std::move(value)); return *this;}
inline const ResponseMetadata& GetResponseMetadata() const{ return m_responseMetadata; }
inline void SetResponseMetadata(const ResponseMetadata& value) { m_responseMetadata = value; }
inline void SetResponseMetadata(ResponseMetadata&& value) { m_responseMetadata = std::move(value); }
inline CopyDBClusterParameterGroupResult& WithResponseMetadata(const ResponseMetadata& value) { SetResponseMetadata(value); return *this;}
inline CopyDBClusterParameterGroupResult& WithResponseMetadata(ResponseMetadata&& value) { SetResponseMetadata(std::move(value)); return *this;}
private:
DBClusterParameterGroup m_dBClusterParameterGroup;
ResponseMetadata m_responseMetadata;
};
} // namespace Model
} // namespace RDS
} // namespace Aws
|
/*
*
* Copyright 2012 Samsung Electronics S.LSI Co. LTD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* @file Exynos_OSAL_Library.c
* @brief
* @author SeungBeom Kim (sbcrux.kim@samsung.com)
* @version 2.0.0
* @history
* 2012.02.20 : Create
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>
#include "Exynos_OSAL_Library.h"
void *Exynos_OSAL_dlopen(const char *filename, int flag)
{
return dlopen(filename, flag);
}
void *Exynos_OSAL_dlsym(void *handle, const char *symbol)
{
return dlsym(handle, symbol);
}
int Exynos_OSAL_dlclose(void *handle)
{
return dlclose(handle);
}
const char *Exynos_OSAL_dlerror(void)
{
return dlerror();
}
|
#pragma once
#include <memory>
namespace Envoy {
/**
* This is a helper that wraps C style API objects that need to be deleted with a smart pointer.
*/
template <class T, void (*deleter)(T*)> class CSmartPtr : public std::unique_ptr<T, void (*)(T*)> {
public:
CSmartPtr() : std::unique_ptr<T, void (*)(T*)>(nullptr, deleter) {}
CSmartPtr(T* object) : std::unique_ptr<T, void (*)(T*)>(object, deleter) {}
};
} // Envoy
|
/*****************************************************************************/
/* huffman.h Copyright (c) Ladislav Zezula 2003 */
/*---------------------------------------------------------------------------*/
/* Description : */
/*---------------------------------------------------------------------------*/
/* Date Ver Who Comment */
/* -------- ---- --- ------- */
/* xx.xx.xx 1.00 Lad The first version of huffman.h */
/* 03.05.03 2.00 Lad Added compression */
/* 08.12.03 2.01 Dan High-memory handling (> 0x80000000) */
/*****************************************************************************/
#ifndef __HUFFMAN_H__
#define __HUFFMAN_H__
//-----------------------------------------------------------------------------
// Defines
#define INSERT_ITEM 1
#define SWITCH_ITEMS 2 // Switch the item1 and item2
#define PTR_NOT(ptr) (THTreeItem *)(~(uint64_t)(ptr))
#define PTR_PTR(ptr) ((THTreeItem *)(ptr))
#define PTR_INT(ptr) (int64_t)(ptr)
#ifndef NULL
#define NULL 0
#endif
//-----------------------------------------------------------------------------
// Structures and classes
// Input stream for Huffmann decompression
class TInputStream
{
public:
unsigned long GetBit();
unsigned long Get7Bits();
unsigned long Get8Bits();
unsigned char * pbInBuffer; // 00 - Input data
unsigned long dwBitBuff; // 04 - Input bit buffer
unsigned int nBits; // 08 - Number of bits remaining in 'dwValue'
};
// Output stream for Huffmann compression
class TOutputStream
{
public:
void PutBits(unsigned long dwBuff, unsigned int nPutBits);
unsigned char * pbOutBuffer; // 00 : Output buffer
unsigned long dwOutSize; // 04 : Size of output buffer
unsigned char * pbOutPos; // 08 : Current output position
unsigned long dwBitBuff; // 0C : Bit buffer
unsigned long nBits; // 10 : Number of bits in the bit buffer
};
// Huffmann tree item (?)
struct THTreeItem
{
public:
THTreeItem * Call1501DB70(THTreeItem * pLast);
THTreeItem * GetPrevItem(long value);
void ClearItemLinks();
void RemoveItem();
THTreeItem * next; // 00 - Pointer to next THTreeItem
THTreeItem * prev; // 04 - Pointer to prev THTreeItem (< 0 if none)
unsigned long dcmpByte; // 08 - Index of this item in item pointer array, decompressed byte value
unsigned long byteValue; // 0C - Some byte value
THTreeItem * parent; // 10 - Pointer to parent THTreeItem (NULL if none)
THTreeItem * child; // 14 - Pointer to child THTreeItem
int addressMultiplier; // -1 if object on negative address (>0x80000000), +1 if positive
};
// Structure used for quick decompress. The 'bitCount' contains number of bits
// and byte value contains result decompressed byte value.
// After each walk through Huffman tree are filled all entries which are
// multiplies of number of bits loaded from input stream. These entries
// contain number of bits and result value. At the next 7 bits is tested this
// structure first. If corresponding entry found, decompression routine will
// not walk through Huffman tree and directly stores output byte to output stream.
struct TQDecompress
{
unsigned long offs00; // 00 - 1 if resolved
unsigned long nBits; // 04 - Bit count
union
{
unsigned long dcmpByte; // 08 - Byte value for decompress (if bitCount <= 7)
THTreeItem * pItem; // 08 - THTreeItem (if number of bits is greater than 7
};
};
// Structure for Huffman tree (Size 0x3674 bytes). Because I'm not expert
// for the decompression, I do not know actually if the class is really a Hufmann
// tree. If someone knows the decompression details, please let me know
class THuffmannTree
{
public:
THuffmannTree();
void InitTree(bool bCompression);
void BuildTree(unsigned int nCmpType);
// void ModifyTree(unsigned long dwIndex);
// void UninitTree();
// void Call15007010(Bit32 dwInLength, THTreeItem * item);
THTreeItem * Call1500E740(unsigned int nValue);
void Call1500E820(THTreeItem * pItem);
unsigned int DoCompression(TOutputStream * os, unsigned char * pbInBuffer, int nInLength, int nCmpType);
unsigned int DoDecompression(unsigned char * pbOutBuffer, unsigned int dwOutLength, TInputStream * is);
unsigned long bIsCmp0; // 0000 - 1 if compression type 0
unsigned long offs0004; // 0004 - Some flag
THTreeItem items0008[0x203]; // 0008 - HTree items
//- Sometimes used as HTree item -----------
THTreeItem * pItem3050; // 3050 - Always NULL (?)
THTreeItem * pItem3054; // 3054 - Pointer to Huffman tree item
THTreeItem * pItem3058; // 3058 - Pointer to Huffman tree item (< 0 if invalid)
//- Sometimes used as HTree item -----------
THTreeItem * pItem305C; // 305C - Usually NULL
THTreeItem * pFirst; // 3060 - Pointer to top (first) Huffman tree item
THTreeItem * pLast; // 3064 - Pointer to bottom (last) Huffman tree item (< 0 if invalid)
unsigned long nItems; // 3068 - Number of used HTree items
//-------------------------------------------
THTreeItem * items306C[0x102]; // 306C - THTreeItem pointer array
TQDecompress qd3474[0x80]; // 3474 - Array for quick decompression
int addressMultiplier; // -1 if object on negative address (>0x80000000), +1 if positive
static unsigned char Table1502A630[];// Some table
};
#endif // __HUFFMAN_H__
|
/*
* Copyright (c) 2002-2008 Sam Leffler, Errno Consulting
* Copyright (c) 2002-2008 Atheros Communications, Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* $FreeBSD: soc2013/dpl/head/sys/dev/ath/ath_hal/ar5416/ar5416_power.c 234552 2012-04-14 04:40:11Z adrian $
*/
#include "opt_ah.h"
#include "ah.h"
#include "ah_internal.h"
#include "ar5416/ar5416.h"
#include "ar5416/ar5416reg.h"
/*
* Notify Power Mgt is enabled in self-generated frames.
* If requested, force chip awake.
*
* Returns A_OK if chip is awake or successfully forced awake.
*
* WARNING WARNING WARNING
* There is a problem with the chip where sometimes it will not wake up.
*/
static HAL_BOOL
ar5416SetPowerModeAwake(struct ath_hal *ah, int setChip)
{
#define POWER_UP_TIME 200000
uint32_t val;
int i = 0;
if (setChip) {
/*
* Do a Power-On-Reset if OWL is shutdown
* the NetBSD driver power-cycles the Cardbus slot
* as part of the reset procedure.
*/
if ((OS_REG_READ(ah, AR_RTC_STATUS)
& AR_RTC_PM_STATUS_M) == AR_RTC_STATUS_SHUTDOWN) {
if (!ar5416SetResetReg(ah, HAL_RESET_POWER_ON))
goto bad;
AH5416(ah)->ah_initPLL(ah, AH_NULL);
}
if (AR_SREV_HOWL(ah))
OS_REG_SET_BIT(ah, AR_RTC_RESET, AR_RTC_RESET_EN);
OS_REG_SET_BIT(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN);
if (AR_SREV_HOWL(ah))
OS_DELAY(10000);
else
OS_DELAY(50); /* Give chip the chance to awake */
for (i = POWER_UP_TIME / 50; i != 0; i--) {
val = OS_REG_READ(ah, AR_RTC_STATUS) & AR_RTC_STATUS_M;
if (val == AR_RTC_STATUS_ON)
break;
OS_DELAY(50);
OS_REG_SET_BIT(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN);
}
bad:
if (i == 0) {
#ifdef AH_DEBUG
ath_hal_printf(ah, "%s: Failed to wakeup in %ums\n",
__func__, POWER_UP_TIME/1000);
#endif
return AH_FALSE;
}
}
OS_REG_CLR_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV);
return AH_TRUE;
#undef POWER_UP_TIME
}
/*
* Notify Power Mgt is disabled in self-generated frames.
* If requested, force chip to sleep.
*/
static void
ar5416SetPowerModeSleep(struct ath_hal *ah, int setChip)
{
OS_REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV);
if (setChip) {
/* Clear the RTC force wake bit to allow the mac to sleep */
OS_REG_CLR_BIT(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN);
if (! AR_SREV_HOWL(ah))
OS_REG_WRITE(ah, AR_RC, AR_RC_AHB|AR_RC_HOSTIF);
/* Shutdown chip. Active low */
if (! AR_SREV_OWL(ah))
OS_REG_CLR_BIT(ah, AR_RTC_RESET, AR_RTC_RESET_EN);
}
}
/*
* Notify Power Management is enabled in self-generating
* fames. If request, set power mode of chip to
* auto/normal. Duration in units of 128us (1/8 TU).
*/
static void
ar5416SetPowerModeNetworkSleep(struct ath_hal *ah, int setChip)
{
OS_REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV);
if (setChip)
OS_REG_CLR_BIT(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN);
}
/*
* Set power mgt to the requested mode, and conditionally set
* the chip as well
*/
HAL_BOOL
ar5416SetPowerMode(struct ath_hal *ah, HAL_POWER_MODE mode, int setChip)
{
struct ath_hal_5212 *ahp = AH5212(ah);
#ifdef AH_DEBUG
static const char* modes[] = {
"AWAKE",
"FULL-SLEEP",
"NETWORK SLEEP",
"UNDEFINED"
};
#endif
int status = AH_TRUE;
if (!setChip)
return AH_TRUE;
HALDEBUG(ah, HAL_DEBUG_POWER, "%s: %s -> %s (%s)\n", __func__,
modes[ahp->ah_powerMode], modes[mode], setChip ? "set chip " : "");
switch (mode) {
case HAL_PM_AWAKE:
status = ar5416SetPowerModeAwake(ah, setChip);
break;
case HAL_PM_FULL_SLEEP:
ar5416SetPowerModeSleep(ah, setChip);
break;
case HAL_PM_NETWORK_SLEEP:
ar5416SetPowerModeNetworkSleep(ah, setChip);
break;
default:
HALDEBUG(ah, HAL_DEBUG_ANY, "%s: unknown power mode 0x%x\n",
__func__, mode);
return AH_FALSE;
}
ahp->ah_powerMode = mode;
return status;
}
/*
* Return the current sleep mode of the chip
*/
HAL_POWER_MODE
ar5416GetPowerMode(struct ath_hal *ah)
{
int mode = OS_REG_READ(ah, AR_RTC_STATUS);
switch (mode & AR_RTC_PM_STATUS_M) {
case AR_RTC_STATUS_ON:
case AR_RTC_STATUS_WAKEUP:
return HAL_PM_AWAKE;
case AR_RTC_STATUS_SLEEP:
return HAL_PM_NETWORK_SLEEP;
case AR_RTC_STATUS_SHUTDOWN:
return HAL_PM_FULL_SLEEP;
default:
HALDEBUG(ah, HAL_DEBUG_ANY,
"%s: unknown power mode, RTC_STATUS 0x%x\n",
__func__, mode);
return HAL_PM_UNDEFINED;
}
}
|
/*-
* Copyright (c) 2004 Tim J. Robbins.
* 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 AUTHOR 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 AUTHOR 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.
*/
/*
* "Character map" ADT. Stores mappings between pairs of characters in a
* splay tree, with a lookup table cache to simplify looking up the first
* bunch of characters (which are presumably more common than others).
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD: soc2013/dpl/head/usr.bin/tr/cmap.c 200505 2009-12-13 03:14:06Z delphij $");
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
#include <stdlib.h>
#include <wchar.h>
#include "cmap.h"
static struct cmapnode *cmap_splay(struct cmapnode *, wint_t);
/*
* cmap_alloc --
* Allocate a character map.
*/
struct cmap *
cmap_alloc(void)
{
struct cmap *cm;
cm = malloc(sizeof(*cm));
if (cm == NULL)
return (NULL);
cm->cm_root = NULL;
cm->cm_def = CM_DEF_SELF;
cm->cm_havecache = false;
cm->cm_min = cm->cm_max = 0;
return (cm);
}
/*
* cmap_add --
* Add a mapping from "from" to "to" to the map.
*/
bool
cmap_add(struct cmap *cm, wint_t from, wint_t to)
{
struct cmapnode *cmn, *ncmn;
cm->cm_havecache = false;
if (cm->cm_root == NULL) {
cmn = malloc(sizeof(*cmn));
if (cmn == NULL)
return (false);
cmn->cmn_from = from;
cmn->cmn_to = to;
cmn->cmn_left = cmn->cmn_right = NULL;
cm->cm_root = cmn;
cm->cm_min = cm->cm_max = from;
return (true);
}
cmn = cm->cm_root = cmap_splay(cm->cm_root, from);
if (cmn->cmn_from == from) {
cmn->cmn_to = to;
return (true);
}
ncmn = malloc(sizeof(*ncmn));
if (ncmn == NULL)
return (false);
ncmn->cmn_from = from;
ncmn->cmn_to = to;
if (from < cmn->cmn_from) {
ncmn->cmn_left = cmn->cmn_left;
ncmn->cmn_right = cmn;
cmn->cmn_left = NULL;
} else {
ncmn->cmn_right = cmn->cmn_right;
ncmn->cmn_left = cmn;
cmn->cmn_right = NULL;
}
if (from < cm->cm_min)
cm->cm_min = from;
if (from > cm->cm_max)
cm->cm_max = from;
cm->cm_root = ncmn;
return (true);
}
/*
* cmap_lookup_hard --
* Look up the mapping for a character without using the cache.
*/
wint_t
cmap_lookup_hard(struct cmap *cm, wint_t ch)
{
if (cm->cm_root != NULL) {
cm->cm_root = cmap_splay(cm->cm_root, ch);
if (cm->cm_root->cmn_from == ch)
return (cm->cm_root->cmn_to);
}
return (cm->cm_def == CM_DEF_SELF ? ch : cm->cm_def);
}
/*
* cmap_cache --
* Update the cache.
*/
void
cmap_cache(struct cmap *cm)
{
wint_t ch;
for (ch = 0; ch < CM_CACHE_SIZE; ch++)
cm->cm_cache[ch] = cmap_lookup_hard(cm, ch);
cm->cm_havecache = true;
}
/*
* cmap_default --
* Change the value that characters without mappings map to, and
* return the old value. The special character value CM_MAP_SELF
* means characters map to themselves.
*/
wint_t
cmap_default(struct cmap *cm, wint_t def)
{
wint_t old;
old = cm->cm_def;
cm->cm_def = def;
cm->cm_havecache = false;
return (old);
}
static struct cmapnode *
cmap_splay(struct cmapnode *t, wint_t ch)
{
struct cmapnode N, *l, *r, *y;
/*
* Based on public domain code from Sleator.
*/
assert(t != NULL);
N.cmn_left = N.cmn_right = NULL;
l = r = &N;
for (;;) {
if (ch < t->cmn_from) {
if (t->cmn_left != NULL &&
ch < t->cmn_left->cmn_from) {
y = t->cmn_left;
t->cmn_left = y->cmn_right;
y->cmn_right = t;
t = y;
}
if (t->cmn_left == NULL)
break;
r->cmn_left = t;
r = t;
t = t->cmn_left;
} else if (ch > t->cmn_from) {
if (t->cmn_right != NULL &&
ch > t->cmn_right->cmn_from) {
y = t->cmn_right;
t->cmn_right = y->cmn_left;
y->cmn_left = t;
t = y;
}
if (t->cmn_right == NULL)
break;
l->cmn_right = t;
l = t;
t = t->cmn_right;
} else
break;
}
l->cmn_right = t->cmn_left;
r->cmn_left = t->cmn_right;
t->cmn_left = N.cmn_right;
t->cmn_right = N.cmn_left;
return (t);
}
|
/////////////////////////////////////////////////////////////////////////////
//
// File : qtc_hs_QPaintEvent.h
// Copyright : (c) David Harley 2010
// Project : qtHaskell
// Version : 1.1.4
// Modified : 2010-09-02 17:02:41
//
// Warning : this file is machine generated - do not modify.
//
/////////////////////////////////////////////////////////////////////////////
void* qtc_QPaintEvent(void*);
void* qtc_QPaintEvent1(void*);
void* qtc_QPaintEvent2(int, int, int, int);
void* qtc_QPaintEvent3(void*);
void* qtc_QPaintEvent_rect(void*);
void* qtc_QPaintEvent_rect_qth(void*,int*,int*,int*,int*);
void* qtc_QPaintEvent_region(void*);
void qtc_QPaintEvent_finalizer(void*);
void* qtc_QPaintEvent_getFinalizer();
void qtc_QPaintEvent_delete(void*);
|
/* Copyright (c) 2013, Regents of the Columbia University
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 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 COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Authors: Heming Cui (heming@cs.columbia.edu), Junfeng Yang (junfeng@cs.columbia.edu) -*- Mode: C++ -*- */
#ifndef TERN_COMMON_SYNCFUNCS_H
#define TERN_COMMON_SYNCFUNCS_H
#include <cassert>
#include <limits.h>
#include <boost/static_assert.hpp>
namespace tern {
namespace syncfunc {
#undef DEF
#undef DEFTERNAUTO
#undef DEFTERNUSER
enum {
not_sync = 0, // not a sync operation
# define DEF(func,kind,...) func,
# define DEFTERNAUTO(func) func,
# define DEFTERNUSER(func) func,
# include "syncfuncs.def.h"
# undef DEF
# undef DEFTERNAUTO
# undef DEFTERNUSER
num_syncs,
first_sync = 1,
pthread_cond_wait_1 = 0x1000,
pthread_cond_wait_2
};
BOOST_STATIC_ASSERT(num_syncs<USHRT_MAX);
extern const int kind[];
extern const char* name[];
extern const char* nameInTern[];
enum {Synchronization, BlockingSyscall, TernUser, TernAuto};
static inline bool isSync(unsigned nr) {
assert(first_sync <= nr && nr < num_syncs);
return kind[nr] == Synchronization;
}
static inline bool isBlockingSyscall(unsigned nr) {
assert(first_sync <= nr && nr < num_syncs);
return kind[nr] == BlockingSyscall;
}
static inline bool isTern(unsigned nr) {
assert(first_sync <= nr && nr < num_syncs);
return kind[nr] == TernUser || kind[nr] == TernAuto;
}
static inline bool isTernUser(unsigned nr) {
assert(first_sync <= nr && nr < num_syncs);
return kind[nr] == TernUser;
}
static inline bool isTernAuto(unsigned nr) {
assert(first_sync <= nr && nr < num_syncs);
return kind[nr] == TernAuto;
}
static inline const char* getName(unsigned nr) {
assert(first_sync <= nr && nr < num_syncs);
return name[nr];
}
static inline const char* getTernName(unsigned nr) {
assert(first_sync <= nr && nr < num_syncs);
return nameInTern[nr];
}
unsigned getNameID(const char* name);
unsigned getTernNameID(const char* nameInTern);
} // namespace syncfuncs
} // namespace tern
#endif
|
/*
File: AVBase.h
Framework: AVFoundation
Copyright 2010-2013 Apple Inc. All rights reserved.
*/
#import <Availability.h>
#import <Foundation/NSObjCRuntime.h>
#if defined(__cplusplus)
#define AVF_EXPORT extern "C"
#else
#define AVF_EXPORT extern
#endif
// Pre-10.10
#ifndef __NSi_10_10
#define __NSi_10_10 introduced=10.10
#endif
// Pre-10.9, weak import
#ifndef __AVAILABILITY_INTERNAL__MAC_10_9
#define __AVAILABILITY_INTERNAL__MAC_10_9 __AVAILABILITY_INTERNAL_WEAK_IMPORT
#endif
// Pre-10.8, weak import
#ifndef __AVAILABILITY_INTERNAL__MAC_10_8
#define __AVAILABILITY_INTERNAL__MAC_10_8 __AVAILABILITY_INTERNAL_WEAK_IMPORT
#endif
#ifndef AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
#define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER WEAK_IMPORT_ATTRIBUTE
#endif
#ifndef AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
#define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER WEAK_IMPORT_ATTRIBUTE
#endif
// Pre-10.7, weak import
#ifndef __AVAILABILITY_INTERNAL__MAC_10_7
#define __AVAILABILITY_INTERNAL__MAC_10_7 __AVAILABILITY_INTERNAL_WEAK_IMPORT
#endif
// Pre-5.1, weak import
#ifndef __AVAILABILITY_INTERNAL__IPHONE_5_1
#define __AVAILABILITY_INTERNAL__IPHONE_5_1 __AVAILABILITY_INTERNAL_WEAK_IMPORT
#endif
// Pre-5.0, weak import
#ifndef __AVAILABILITY_INTERNAL__IPHONE_5_0
#define __AVAILABILITY_INTERNAL__IPHONE_5_0 __AVAILABILITY_INTERNAL_WEAK_IMPORT
#endif
// Pre-6.0, weak import
#ifndef __AVAILABILITY_INTERNAL__IPHONE_6_0
#define __AVAILABILITY_INTERNAL__IPHONE_6_0 __AVAILABILITY_INTERNAL_WEAK_IMPORT
#endif
// Pre-6.1, weak import
#ifndef __AVAILABILITY_INTERNAL__IPHONE_6_1
#define __AVAILABILITY_INTERNAL__IPHONE_6_1 __AVAILABILITY_INTERNAL_WEAK_IMPORT
#endif
// Pre-7.0, weak import
#ifndef __AVAILABILITY_INTERNAL__IPHONE_7_0
#define __AVAILABILITY_INTERNAL__IPHONE_7_0 __AVAILABILITY_INTERNAL_WEAK_IMPORT
#endif
// Pre-7.1, weak import
#ifndef __AVAILABILITY_INTERNAL__IPHONE_7_1
#define __AVAILABILITY_INTERNAL__IPHONE_7_1 __AVAILABILITY_INTERNAL_WEAK_IMPORT
#endif
// Deprecations
#ifndef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8
#define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_8 WEAK_IMPORT_ATTRIBUTE
#endif
#ifndef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9
#define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_X_VERSION_10_9 WEAK_IMPORT_ATTRIBUTE
#endif
#ifndef __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_6_0
#define __AVAILABILITY_INTERNAL__IPHONE_4_0_DEP__IPHONE_6_0 WEAK_IMPORT_ATTRIBUTE
#endif
#ifndef __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_6_0
#define __AVAILABILITY_INTERNAL__IPHONE_5_0_DEP__IPHONE_6_0 WEAK_IMPORT_ATTRIBUTE
#endif
#ifndef __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_7_0
#define __AVAILABILITY_INTERNAL__IPHONE_4_3_DEP__IPHONE_7_0 WEAK_IMPORT_ATTRIBUTE
#endif
#ifndef __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_7_0
#define __AVAILABILITY_INTERNAL__IPHONE_6_0_DEP__IPHONE_7_0 WEAK_IMPORT_ATTRIBUTE
#endif
// To be determined, weak import
#ifndef __AVAILABILITY_INTERNAL__IPHONE_TBD
#define __AVAILABILITY_INTERNAL__IPHONE_TBD __AVAILABILITY_INTERNAL_WEAK_IMPORT
#endif
#ifndef __AVAILABILITY_INTERNAL__MAC_TBD
#define __AVAILABILITY_INTERNAL__MAC_TBD __AVAILABILITY_INTERNAL_WEAK_IMPORT
#endif
#ifndef AVAILABLE_MAC_OS_X_VERSION_TBD_AND_LATER
#define AVAILABLE_MAC_OS_X_VERSION_TBD_AND_LATER WEAK_IMPORT_ATTRIBUTE
#endif
#ifndef NS_AVAILABLE
#define NS_AVAILABLE(a, b)
#endif
#ifndef NS_AVAILABLE_IOS
#define NS_AVAILABLE_IOS(a)
#endif
#ifndef NS_CLASS_AVAILABLE
#define NS_CLASS_AVAILABLE(a, b)
#endif
#ifndef NS_DEPRECATED
#define NS_DEPRECATED(a, b, c, d)
#endif
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef AppBannerCallbacks_h
#define AppBannerCallbacks_h
#include "modules/app_banner/BeforeInstallPromptEvent.h"
#include "public/platform/modules/app_banner/WebAppBannerClient.h"
namespace blink {
class AppBannerCallbacks : public WebAppBannerCallbacks {
// FIXME(tasak): when making public/platform classes to use PartitionAlloc,
// the following macro should be moved to WebCallbacks defined in
// public/platformWebCallbacks.h.
USING_FAST_MALLOC(AppBannerCallbacks);
public:
explicit AppBannerCallbacks(UserChoiceProperty*);
~AppBannerCallbacks() override = default;
// WebAppBannerCallbacks overrides.
void onSuccess(const WebAppBannerPromptResult&) override;
private:
Persistent<UserChoiceProperty> m_userChoice;
};
} // namespace blink
#endif // AppBannerCallbacks_h
|
/*
* Copyright (c) 2009-2011 Juli Mallett. 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 AUTHOR 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 AUTHOR 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 PROGRAMS_WANPROXY_PROXY_SOCKS_CONNECTION_H
#define PROGRAMS_WANPROXY_PROXY_SOCKS_CONNECTION_H
class ProxySocksConnection {
enum State {
GetSOCKSVersion,
GetSOCKS4Command,
GetSOCKS4Port,
GetSOCKS4Address,
GetSOCKS4User,
GetSOCKS5AuthLength,
GetSOCKS5Auth,
GetSOCKS5Command,
GetSOCKS5Reserved,
GetSOCKS5AddressType,
GetSOCKS5Address,
GetSOCKS5NameLength,
GetSOCKS5Name,
GetSOCKS5Port,
};
LogHandle log_;
std::string name_;
Socket *client_;
Action *action_;
State state_;
uint16_t network_port_;
uint32_t network_address_;
bool socks5_authenticated_;
std::string socks5_remote_name_;
public:
ProxySocksConnection(const std::string&, Socket *);
private:
~ProxySocksConnection();
private:
void read_complete(Event);
void write_complete(Event);
void close_complete(void);
void schedule_read(size_t);
void schedule_write(void);
void schedule_close(void);
};
#endif /* !PROGRAMS_WANPROXY_PROXY_SOCKS_CONNECTION_H */
|
/* $NetBSD: darwin_machdep.h,v 1.1 2002/12/08 21:53:13 manu Exp $ */
#include <powerpc/darwin_machdep.h>
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE400_Resource_Exhaustion__fscanf_for_loop_06.c
Label Definition File: CWE400_Resource_Exhaustion.label.xml
Template File: sources-sinks-06.tmpl.c
*/
/*
* @description
* CWE: 400 Resource Exhaustion
* BadSource: fscanf Read data from the console using fscanf()
* GoodSource: Assign count to be a relatively small number
* Sinks: for_loop
* GoodSink: Validate count before using it as the loop variant in a for loop
* BadSink : Use count as the loop variant in a for loop
* Flow Variant: 06 Control flow: if(STATIC_CONST_FIVE==5) and if(STATIC_CONST_FIVE!=5)
*
* */
#include "std_testcase.h"
/* The variable below is declared "const", so a tool should be able
to identify that reads of this will always give its initialized
value. */
static const int STATIC_CONST_FIVE = 5;
#ifndef OMITBAD
void CWE400_Resource_Exhaustion__fscanf_for_loop_06_bad()
{
int count;
/* Initialize count */
count = -1;
if(STATIC_CONST_FIVE==5)
{
/* POTENTIAL FLAW: Read count from the console using fscanf() */
fscanf(stdin, "%d", &count);
}
if(STATIC_CONST_FIVE==5)
{
{
size_t i = 0;
/* POTENTIAL FLAW: For loop using count as the loop variant and no validation */
for (i = 0; i < (size_t)count; i++)
{
printLine("Hello");
}
}
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodB2G1() - use badsource and goodsink by changing the second STATIC_CONST_FIVE==5 to STATIC_CONST_FIVE!=5 */
static void goodB2G1()
{
int count;
/* Initialize count */
count = -1;
if(STATIC_CONST_FIVE==5)
{
/* POTENTIAL FLAW: Read count from the console using fscanf() */
fscanf(stdin, "%d", &count);
}
if(STATIC_CONST_FIVE!=5)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
{
size_t i = 0;
/* FIX: Validate count before using it as the for loop variant */
if (count > 0 && count <= 20)
{
for (i = 0; i < (size_t)count; i++)
{
printLine("Hello");
}
}
}
}
}
/* goodB2G2() - use badsource and goodsink by reversing the blocks in the second if */
static void goodB2G2()
{
int count;
/* Initialize count */
count = -1;
if(STATIC_CONST_FIVE==5)
{
/* POTENTIAL FLAW: Read count from the console using fscanf() */
fscanf(stdin, "%d", &count);
}
if(STATIC_CONST_FIVE==5)
{
{
size_t i = 0;
/* FIX: Validate count before using it as the for loop variant */
if (count > 0 && count <= 20)
{
for (i = 0; i < (size_t)count; i++)
{
printLine("Hello");
}
}
}
}
}
/* goodG2B1() - use goodsource and badsink by changing the first STATIC_CONST_FIVE==5 to STATIC_CONST_FIVE!=5 */
static void goodG2B1()
{
int count;
/* Initialize count */
count = -1;
if(STATIC_CONST_FIVE!=5)
{
/* INCIDENTAL: CWE 561 Dead Code, the code below will never run */
printLine("Benign, fixed string");
}
else
{
/* FIX: Use a relatively small number */
count = 20;
}
if(STATIC_CONST_FIVE==5)
{
{
size_t i = 0;
/* POTENTIAL FLAW: For loop using count as the loop variant and no validation */
for (i = 0; i < (size_t)count; i++)
{
printLine("Hello");
}
}
}
}
/* goodG2B2() - use goodsource and badsink by reversing the blocks in the first if */
static void goodG2B2()
{
int count;
/* Initialize count */
count = -1;
if(STATIC_CONST_FIVE==5)
{
/* FIX: Use a relatively small number */
count = 20;
}
if(STATIC_CONST_FIVE==5)
{
{
size_t i = 0;
/* POTENTIAL FLAW: For loop using count as the loop variant and no validation */
for (i = 0; i < (size_t)count; i++)
{
printLine("Hello");
}
}
}
}
void CWE400_Resource_Exhaustion__fscanf_for_loop_06_good()
{
goodB2G1();
goodB2G2();
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()...");
CWE400_Resource_Exhaustion__fscanf_for_loop_06_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE400_Resource_Exhaustion__fscanf_for_loop_06_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
/**
* Copyright (c) 2013, Willem-Hendrik Thiart
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*
* @file
* @author Willem Thiart himself@willemthiart.com
* @version 0.1
*/
class RaftLogger;
/**
* Apply entry at lastApplied + 1. Entry becomes 'committed'.
* @return 1 if entry committed, 0 otherwise */
//int raft_apply_entry(raft_server_t* me_);
/**
* Appends entry using the current term.
* Note: we make the assumption that current term is up-to-date
* @return 0 if unsuccessful */
//int raft_append_entry(raft_server_t* me_, raft_entry_t* c);
|
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#include "src/core/lib/slice/slice_string_helpers.h"
#include <string.h>
#include <grpc/support/log.h>
#include "src/core/lib/support/string.h"
char *grpc_dump_slice(grpc_slice s, uint32_t flags) {
return gpr_dump((const char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s),
flags);
}
/** Finds the initial (\a begin) and final (\a end) offsets of the next
* substring from \a str + \a read_offset until the next \a sep or the end of \a
* str.
*
* Returns 1 and updates \a begin and \a end. Returns 0 otherwise. */
static int slice_find_separator_offset(const grpc_slice str, const char *sep,
const size_t read_offset, size_t *begin,
size_t *end) {
size_t i;
const uint8_t *str_ptr = GRPC_SLICE_START_PTR(str) + read_offset;
const size_t str_len = GRPC_SLICE_LENGTH(str) - read_offset;
const size_t sep_len = strlen(sep);
if (str_len < sep_len) {
return 0;
}
for (i = 0; i <= str_len - sep_len; i++) {
if (memcmp(str_ptr + i, sep, sep_len) == 0) {
*begin = read_offset;
*end = read_offset + i;
return 1;
}
}
return 0;
}
void grpc_slice_split(grpc_slice str, const char *sep, grpc_slice_buffer *dst) {
const size_t sep_len = strlen(sep);
size_t begin, end;
GPR_ASSERT(sep_len > 0);
if (slice_find_separator_offset(str, sep, 0, &begin, &end) != 0) {
do {
grpc_slice_buffer_add_indexed(dst, grpc_slice_sub(str, begin, end));
} while (slice_find_separator_offset(str, sep, end + sep_len, &begin,
&end) != 0);
grpc_slice_buffer_add_indexed(
dst, grpc_slice_sub(str, end + sep_len, GRPC_SLICE_LENGTH(str)));
} else { /* no sep found, add whole input */
grpc_slice_buffer_add_indexed(dst, grpc_slice_ref(str));
}
}
|
#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/fcall.h"
#include "kernel/operators.h"
#include "kernel/memory.h"
#include "kernel/object.h"
/**
* Plural rules for Polish language:
*
* Locales: pl
*
* Rules:
* one → n is 1;
* few → n mod 10 in 2..4 and n mod 100 not in 12..14 and n mod 100 not in 22..24;
* other → everything else (fractions)
*
* Reference CLDR Version 21 (2012-03-01 03:27:30 GMT)
* @see http://unicode.org/repos/cldr-tmp/trunk/diff/supplemental/language_plural_rules.html
* @see http://unicode.org/repos/cldr/trunk/common/supplemental/plurals.xml
*
* @package Ice/I18n
* @category Plural rules
* @author Ice Team
* @copyright (c) 2014-2020 Ice Team
* @license http://iceframework.org/license
*/
ZEPHIR_INIT_CLASS(Ice_I18n_Plural_Polish) {
ZEPHIR_REGISTER_CLASS(Ice\\I18n\\Plural, Polish, ice, i18n_plural_polish, ice_i18n_plural_polish_method_entry, 0);
zend_class_implements(ice_i18n_plural_polish_ce, 1, ice_i18n_plural_pluralinterface_ce);
return SUCCESS;
}
PHP_METHOD(Ice_I18n_Plural_Polish, getCategory) {
zend_bool _1, _2, _3, _4, _5, _6;
zephir_method_globals *ZEPHIR_METHOD_GLOBALS_PTR = NULL;
zval *count_param = NULL, isInt, _0;
zend_long count, ZEPHIR_LAST_CALL_STATUS, i10 = 0, i100 = 0;
zval *this_ptr = getThis();
ZVAL_UNDEF(&isInt);
ZVAL_UNDEF(&_0);
ZEPHIR_MM_GROW();
zephir_fetch_params(1, 1, 0, &count_param);
count = zephir_get_intval(count_param);
ZVAL_LONG(&_0, count);
ZEPHIR_CALL_METHOD(&isInt, this_ptr, "isint", NULL, 0, &_0);
zephir_check_call_status();
i10 = (long) (zephir_safe_mod_long_long(count, 10));
i100 = (long) (zephir_safe_mod_long_long(count, 100));
_1 = zephir_is_true(&isInt);
if (_1) {
_1 = i10 >= 2;
}
_2 = _1;
if (_2) {
_2 = i10 <= 4;
}
_3 = _2;
if (_3) {
_4 = i100 >= 12;
if (_4) {
_4 = i100 <= 14;
}
_3 = !(_4);
}
_5 = _3;
if (_5) {
_6 = i100 >= 22;
if (_6) {
_6 = i100 <= 24;
}
_5 = !(_6);
}
if (count == 1) {
RETURN_MM_STRING("one");
} else if (_5) {
RETURN_MM_STRING("few");
} else {
RETURN_MM_STRING("other");
}
}
PHP_METHOD(Ice_I18n_Plural_Polish, isInt) {
zend_bool _0;
zval *value, value_sub;
zval *this_ptr = getThis();
ZVAL_UNDEF(&value_sub);
zephir_fetch_params_without_memory_grow(1, 0, &value);
_0 = zephir_is_numeric(value);
if (_0) {
_0 = (zephir_get_numberval(value) - zephir_get_intval(value)) == 0;
}
RETURN_BOOL(_0);
}
|
/* $NetBSD: endian_machdep.h,v 1.1 2000/03/17 00:09:21 mycroft Exp $ */
#include <powerpc/endian_machdep.h>
|
/*
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VP9_COMMON_VP9_ENUMS_H_
#define VP9_COMMON_VP9_ENUMS_H_
#include "./vpx_config.h"
#define LOG2_MI_SIZE 3
#define MI_SIZE (1 << LOG2_MI_SIZE)
#define MI_MASK ((64 >> LOG2_MI_SIZE) - 1)
typedef enum BLOCK_SIZE_TYPE {
BLOCK_SIZE_AB4X4,
BLOCK_SIZE_SB4X8,
BLOCK_SIZE_SB8X4,
BLOCK_SIZE_SB8X8,
BLOCK_SIZE_SB8X16,
BLOCK_SIZE_SB16X8,
BLOCK_SIZE_MB16X16,
BLOCK_SIZE_SB16X32,
BLOCK_SIZE_SB32X16,
BLOCK_SIZE_SB32X32,
BLOCK_SIZE_SB32X64,
BLOCK_SIZE_SB64X32,
BLOCK_SIZE_SB64X64,
BLOCK_SIZE_TYPES
} BLOCK_SIZE_TYPE;
typedef enum PARTITION_TYPE {
PARTITION_NONE,
PARTITION_HORZ,
PARTITION_VERT,
PARTITION_SPLIT,
PARTITION_TYPES
} PARTITION_TYPE;
#define PARTITION_PLOFFSET 4 // number of probability models per block size
#define NUM_PARTITION_CONTEXTS (4 * PARTITION_PLOFFSET)
#endif // VP9_COMMON_VP9_ENUMS_H_
|
/* ----------------------------------------------------------------- */
/* The Toolkit for Building Voice Interaction Systems */
/* "MMDAgent" developed by MMDAgent Project Team */
/* http://www.mmdagent.jp/ */
/* ----------------------------------------------------------------- */
/* */
/* Copyright (c) 2009-2012 Nagoya Institute of Technology */
/* Department of Computer Science */
/* */
/* 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 MMDAgent project team nor the names of */
/* its contributors may be used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND */
/* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS */
/* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, */
/* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, */
/* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
/* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, */
/* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY */
/* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
/* POSSIBILITY OF SUCH DAMAGE. */
/* ----------------------------------------------------------------- */
#define BULLETPHYSICS_PI 3.1415926535897932384626433832795
#define BULLETPHYSICS_RIGIDBODYFLAGB 0x10
#define BULLETPHYSICS_RIGIDBODYFLAGP 0x20
#define BULLETPHYSICS_RIGIDBODYFLAGA 0x40
/* BulletPhysics: Bullet Physics engine */
class BulletPhysics
{
private:
btDefaultCollisionConfiguration *m_collisionConfig; /* collision configuration */
btCollisionDispatcher *m_dispatcher; /* collision dispatcher */
btAxisSweep3 *m_overlappingPairCache;
btConstraintSolver *m_solver; /* constraint solver */
btDiscreteDynamicsWorld *m_world; /* the simulation world */
int m_fps; /* simulation frame rate (Hz) */
btScalar m_subStep; /* sub step to process simulation */
GLuint m_boxList; /* display list (box) */
bool m_boxListEnabled;
GLuint m_sphereList; /* display list (sphere) */
bool m_sphereListEnabled;
/* initialize: initialize BulletPhysics */
void initialize();
/* clear: free BulletPhysics */
void clear();
public:
/* BulletPhysics: constructor */
BulletPhysics();
/* ~BulletPhysics: destructor */
~BulletPhysics();
/* setup: initialize and setup BulletPhysics */
void setup(int simulationFps, float gravityFactor);
/* update: step the simulation world forward */
void update(float deltaFrame);
/* getWorld: get simulation world */
btDiscreteDynamicsWorld *getWorld();
/* debugDisplay: render rigid bodies */
void debugDisplay();
};
|
// Copyright (c) 2004
// Utrecht University (The Netherlands),
// ETH Zurich (Switzerland),
// INRIA Sophia-Antipolis (France),
// Max-Planck-Institute Saarbruecken (Germany),
// and Tel-Aviv University (Israel). All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 3 of the License,
// or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : Sylvain Pion
#ifndef CGAL_INTERNAL_EXACT_TYPE_SELECTOR_H
#define CGAL_INTERNAL_EXACT_TYPE_SELECTOR_H
// This is an undocumented private helper for Filtered_kernel.
#include <CGAL/number_type_basic.h>
#include <CGAL/MP_Float.h>
#include <CGAL/Quotient.h>
#include <CGAL/Lazy_exact_nt.h>
#ifdef CGAL_USE_GMP
# include <CGAL/Gmpz.h>
# include <CGAL/Gmpq.h>
# include <CGAL/Gmpzf.h>
# include <CGAL/Mpzf.h>
#endif
#ifdef CGAL_USE_GMPXX
# include <CGAL/gmpxx.h>
#endif
#ifdef CGAL_USE_LEDA
# include <CGAL/leda_integer.h>
# include <CGAL/leda_rational.h>
# include <CGAL/leda_real.h>
#endif
#ifdef CGAL_USE_CORE
// # include <CGAL/CORE_Expr.h>
namespace CORE {
class Expr;
}
#endif
namespace CGAL { namespace internal {
// Two classes which tell the prefered "exact number types" corresponding to a type.
// The default template chooses Gmpq, or leda_rational, or Quotient<MP_Float>.
// It should support the built-in types.
template < typename >
struct Exact_field_selector
#ifdef CGAL_USE_GMP
{ typedef Gmpq Type; };
#elif defined(CGAL_USE_LEDA)
{ typedef leda_rational Type; };
#else
{ typedef Quotient<MP_Float> Type; };
#endif
// By default, a field is a safe choice of ring.
template < typename T >
struct Exact_ring_selector : Exact_field_selector < T > { };
template <>
struct Exact_ring_selector<double>
#ifdef CGAL_HAS_MPZF
{ typedef Mpzf Type; };
#elif defined(CGAL_HAS_THREADS) || !defined(CGAL_USE_GMP)
{ typedef MP_Float Type; };
#else
{ typedef Gmpzf Type; };
#endif
template <>
struct Exact_ring_selector<float> : Exact_ring_selector<double> { };
template <>
struct Exact_field_selector<MP_Float>
{ typedef Quotient<MP_Float> Type; };
template <>
struct Exact_ring_selector<MP_Float>
{ typedef MP_Float Type; };
template <>
struct Exact_field_selector<Quotient<MP_Float> >
{ typedef Quotient<MP_Float> Type; };
// And we specialize for the following types :
#ifdef CGAL_USE_GMP
template <>
struct Exact_field_selector<Gmpz>
{ typedef Gmpq Type; };
template <>
struct Exact_ring_selector<Gmpz>
{ typedef Gmpz Type; };
template <>
struct Exact_ring_selector<Gmpzf>
{ typedef Gmpzf Type; };
template <>
struct Exact_field_selector<Gmpq>
{ typedef Gmpq Type; };
#endif
#ifdef CGAL_USE_GMPXX
template <>
struct Exact_field_selector< ::mpz_class>
{ typedef ::mpq_class Type; };
template <>
struct Exact_ring_selector< ::mpz_class>
{ typedef ::mpz_class Type; };
template <>
struct Exact_field_selector< ::mpq_class>
{ typedef ::mpq_class Type; };
#endif
#ifdef CGAL_USE_LEDA
template <>
struct Exact_field_selector<leda_integer>
{ typedef leda_rational Type; };
template <>
struct Exact_ring_selector<leda_integer>
{ typedef leda_integer Type; };
template <>
struct Exact_field_selector<leda_rational>
{ typedef leda_rational Type; };
template <>
struct Exact_field_selector<leda_real>
{ typedef leda_real Type; };
#endif
#ifdef CGAL_USE_CORE
template <>
struct Exact_field_selector<CORE::Expr>
{ typedef CORE::Expr Type; };
#endif
template < typename ET >
struct Exact_field_selector<Lazy_exact_nt<ET> >
: Exact_field_selector<ET>
{
// We have a choice here :
// - using ET gets rid of the DAG computation as well as redoing the interval
// - using Lazy_exact_nt<ET> might use sharper intervals.
// typedef ET Type;
// typedef Lazy_exact_nt<ET> Type;
};
template < typename ET >
struct Exact_ring_selector<Lazy_exact_nt<ET> >
: Exact_ring_selector<ET>
{};
#ifndef CGAL_NO_DEPRECATED_CODE
// Added for backward compatibility
template < typename ET >
struct Exact_type_selector : Exact_field_selector< ET > {};
#endif
} } // namespace CGAL::internal
#endif // CGAL_INTERNAL_EXACT_TYPE_SELECTOR_H
|
// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef V8_OBJECTS_CELL_H_
#define V8_OBJECTS_CELL_H_
#include "src/objects/heap-object.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
namespace v8 {
namespace internal {
#include "torque-generated/src/objects/cell-tq.inc"
class Cell : public TorqueGeneratedCell<Cell, HeapObject> {
public:
static inline Cell FromValueAddress(Address value);
inline Address ValueAddress() { return address() + kValueOffset; }
using BodyDescriptor = FixedBodyDescriptor<kValueOffset, kSize, kSize>;
TQ_OBJECT_CONSTRUCTORS(Cell)
};
} // namespace internal
} // namespace v8
#include "src/objects/object-macros-undef.h"
#endif // V8_OBJECTS_CELL_H_
|
/*
* $Id: hdrcmp.c,v 1.2 2004/01/16 07:12:53 syoyo Exp $
*
* Compare two Radiance .hdr image.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "rgbe.h"
double compare(float *img1, float *img2, int len, int l2)
{
int i;
double diff = 0.0;
double x;
for (i = 0; i < len; i++) {
if (isnan(img1[i]) || isnan(img2[i])) continue;
if (l2) {
x = (double)img1[i] - (double)img2[i];
diff += x * x;
} else {
diff += fabs((double)img1[i] - (double)img2[i]);
}
}
if (l2) {
diff /= (double)len;
}
return diff;
}
int
main(int argc, char **argv)
{
int w1, w2;
int h1, h2;
int ret;
int l2;
double diff;
rgbe_header_info info;
float *img1, *img2;
FILE *fp1, *fp2;
if (argc < 3) {
printf("usage: hdrcmp image1.hdr image2.hdr\n");
exit(-1);
}
l2 = 0;
if (argc > 3) {
if (strcmp(argv[3], "-l2") == 0) {
/* compute L2 norm. */
l2 = 1;
}
}
fp1 = fopen(argv[1], "rb");
if (!fp1) {
printf("-1\n");
exit(-1);
}
fp2 = fopen(argv[2], "rb");
if (!fp2) {
printf("-1\n");
exit(-1);
}
ret = RGBE_ReadHeader(fp1, &w1, &h1, &info);
if (ret != RGBE_RETURN_SUCCESS) {
printf("-1\n");
exit(-1);
}
ret = RGBE_ReadHeader(fp2, &w2, &h2, &info);
if (ret != RGBE_RETURN_SUCCESS) {
printf("-1\n");
exit(-1);
}
if ((w1 != w2) || (h1 != h2)) {
printf("-1\n");
exit(-1);
}
img1 = (float *)malloc(sizeof(float) * w1 * h1 * 3);
img2 = (float *)malloc(sizeof(float) * w2 * h2 * 3);
ret = RGBE_ReadPixels_RLE(fp1, img1, w1, h1);
if (ret != RGBE_RETURN_SUCCESS) {
printf("-1\n");
exit(-1);
}
ret = RGBE_ReadPixels_RLE(fp2, img2, w2, h2);
if (ret != RGBE_RETURN_SUCCESS) {
printf("-1\n");
exit(-1);
}
diff = compare(img1, img2, w1 * h1, l2);
printf("%16.16lf\n", diff);
exit(0);
}
|
// Copyright (c) 2006-2008 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 PRINTING_PRINT_SETTINGS_H_
#define PRINTING_PRINT_SETTINGS_H_
#include "base/gfx/rect.h"
#include "printing/page_overlays.h"
#include "printing/page_range.h"
#include "printing/page_setup.h"
typedef struct HDC__* HDC;
typedef struct _devicemodeW DEVMODE;
namespace printing {
// OS-independent print settings.
class PrintSettings {
public:
PrintSettings();
// Reinitialize the settings to the default values.
void Clear();
#ifdef WIN32
// Reads the settings from the selected device context. Calculates derived
// values like printable_area_.
void Init(HDC hdc,
const DEVMODE& dev_mode,
const PageRanges& new_ranges,
const std::wstring& new_device_name,
bool selection_only);
#endif
// Set printer printable area in in pixels.
void SetPrinterPrintableArea(gfx::Size const& physical_size_pixels,
gfx::Rect const& printable_area_pixels);
// Equality operator.
// NOTE: printer_name is NOT tested for equality since it doesn't affect the
// output.
bool Equals(const PrintSettings& rhs) const;
const std::wstring& printer_name() const { return printer_name_; }
void set_device_name(const std::wstring& device_name) {
device_name_ = device_name;
}
const std::wstring& device_name() const { return device_name_; }
int dpi() const { return dpi_; }
const PageSetup& page_setup_pixels() const { return page_setup_pixels_; }
// Multi-page printing. Each PageRange describes a from-to page combination.
// This permits printing selected pages only.
PageRanges ranges;
// By imaging to a width a little wider than the available pixels, thin pages
// will be scaled down a little, matching the way they print in IE and Camino.
// This lets them use fewer sheets than they would otherwise, which is
// presumably why other browsers do this. Wide pages will be scaled down more
// than this.
double min_shrink;
// This number determines how small we are willing to reduce the page content
// in order to accommodate the widest line. If the page would have to be
// reduced smaller to make the widest line fit, we just clip instead (this
// behavior matches MacIE and Mozilla, at least)
double max_shrink;
// Desired visible dots per inch rendering for output. Printing should be
// scaled to ScreenDpi/dpix*desired_dpi.
int desired_dpi;
// The various overlays (headers and footers).
PageOverlays overlays;
// Indicates if the user only wants to print the current selection.
bool selection_only;
// Cookie generator. It is used to initialize PrintedDocument with its
// associated PrintSettings, to be sure that each generated PrintedPage is
// correctly associated with its corresponding PrintedDocument.
static int NewCookie();
private:
//////////////////////////////////////////////////////////////////////////////
// Settings that can't be changed without side-effects.
// Printer name as shown to the user.
std::wstring printer_name_;
// Printer device name as opened by the OS.
std::wstring device_name_;
// Page setup in pixel units, dpi adjusted.
PageSetup page_setup_pixels_;
// Printer's device effective dots per inch in both axis.
int dpi_;
// Is the orientation landscape or portrait.
bool landscape_;
};
} // namespace printing
#endif // PRINTING_PRINT_SETTINGS_H_
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HUNSPELL_DICTIONARY_H_
#define CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HUNSPELL_DICTIONARY_H_
#include "chrome/browser/spellchecker/spellcheck_dictionary.h"
#include "base/files/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/platform_file.h"
#include "net/url_request/url_fetcher_delegate.h"
class Profile;
class SpellcheckService;
struct DictionaryFile;
namespace net {
class URLFetcher;
class URLRequestContextGetter;
} // namespace net
// Defines the browser-side hunspell dictionary and provides access to it.
class SpellcheckHunspellDictionary
: public SpellcheckDictionary,
public net::URLFetcherDelegate,
public base::SupportsWeakPtr<SpellcheckHunspellDictionary> {
public:
// Interface to implement for observers of the Hunspell dictionary.
class Observer {
public:
// The dictionary has been initialized.
virtual void OnHunspellDictionaryInitialized() = 0;
// Dictionary download began.
virtual void OnHunspellDictionaryDownloadBegin() = 0;
// Dictionary download succeeded.
virtual void OnHunspellDictionaryDownloadSuccess() = 0;
// Dictionary download failed.
virtual void OnHunspellDictionaryDownloadFailure() = 0;
};
// TODO(rlp): Passing in the host is very temporary. In the next CL this
// will be removed.
SpellcheckHunspellDictionary(
const std::string& language,
net::URLRequestContextGetter* request_context_getter,
SpellcheckService* spellcheck_service);
virtual ~SpellcheckHunspellDictionary();
// SpellcheckDictionary implementation:
virtual void Load() OVERRIDE;
// Retry downloading |dictionary_file_|.
void RetryDownloadDictionary(
net::URLRequestContextGetter* request_context_getter);
// Returns true if the dictionary is ready to use.
virtual bool IsReady() const;
// TODO(rlp): Return by value.
const base::PlatformFile& GetDictionaryFile() const;
const std::string& GetLanguage() const;
bool IsUsingPlatformChecker() const;
// Add an observer for Hunspell dictionary events.
void AddObserver(Observer* observer);
// Remove an observer for Hunspell dictionary events.
void RemoveObserver(Observer* observer);
// Whether dictionary is being downloaded.
bool IsDownloadInProgress();
// Whether dictionary download failed.
bool IsDownloadFailure();
private:
// Dictionary download status.
enum DownloadStatus {
DOWNLOAD_NONE,
DOWNLOAD_IN_PROGRESS,
DOWNLOAD_FAILED,
};
// net::URLFetcherDelegate implementation. Called when dictionary download
// finishes.
virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
// Attempt to download the dictionary.
void DownloadDictionary();
// The reply point for PostTaskAndReplyWithResult, called after the dictionary
// file has been initialized.
void InitializeDictionaryLocationComplete(scoped_ptr<DictionaryFile> file);
// The reply point for PostTaskAndReplyWithResult, called after the dictionary
// file has been saved.
void SaveDictionaryDataComplete(bool dictionary_saved);
// Notify listeners that the dictionary has been initialized.
void InformListenersOfInitialization();
// Notify listeners that the dictionary download failed.
void InformListenersOfDownloadFailure();
// The language of the dictionary file.
std::string language_;
// Whether to use the platform spellchecker instead of Hunspell.
bool use_platform_spellchecker_;
// Used for downloading the dictionary file. SpellcheckHunspellDictionary does
// not hold a reference, and it is only valid to use it on the UI thread.
net::URLRequestContextGetter* request_context_getter_;
// Used for downloading the dictionary file.
scoped_ptr<net::URLFetcher> fetcher_;
base::WeakPtrFactory<SpellcheckHunspellDictionary> weak_ptr_factory_;
SpellcheckService* spellcheck_service_;
// Observers of Hunspell dictionary events.
ObserverList<Observer> observers_;
// Status of the dictionary download.
DownloadStatus download_status_;
// Dictionary file path and descriptor.
scoped_ptr<DictionaryFile> dictionary_file_;
DISALLOW_COPY_AND_ASSIGN(SpellcheckHunspellDictionary);
};
#endif // CHROME_BROWSER_SPELLCHECKER_SPELLCHECK_HUNSPELL_DICTIONARY_H_
|
//////////////////////////////////////////////////////////////////
// (c) Copyright 2009- by Jeongnim Kim
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
// National Center for Supercomputing Applications &
// Materials Computation Center
// University of Illinois, Urbana-Champaign
// Urbana, IL 61801
// e-mail: jnkim@ncsa.uiuc.edu
//
// Supported by
// National Center for Supercomputing Applications, UIUC
// Materials Computation Center, UIUC
//////////////////////////////////////////////////////////////////
// -*- C++ -*-
/** @file SPOSetProxy.h
* @brief declare a proxy class to a SPOSetBase for multi determinants
*/
#ifndef QMCPLUSPLUS_SPOSETPROXY_H
#define QMCPLUSPLUS_SPOSETPROXY_H
#include "QMCWaveFunctions/SPOSetBase.h"
namespace qmcplusplus
{
/** proxy SPOSetBase
*
* This class owns a SPOSetBase for all the states to be evaluated
* and will be owned by a DiracDeterminantBase object.
*/
struct SPOSetProxy: public SPOSetBase
{
///pointer to the SPOSet which evaluate the single-particle states
SPOSetBasePtr refPhi;
///container for the values
ValueMatrix_t psiM;
///container for the gradients
GradMatrix_t dpsiM;
///container for the laplacians
ValueMatrix_t d2psiM;
///contatiner for the values for a particle
ValueVector_t psiV;
///contatiner for the gradients for a particle
GradVector_t dpsiV;
///contatiner for the laplacians for a particle
ValueVector_t d2psiV;
/** constructor
* @param spos a SPOSet
* @param first the first particle index
* @param last the last particle index
*/
SPOSetProxy(SPOSetBasePtr const& spos, int first, int last);
void resetParameters(const opt_variables_type& optVariables);
void resetTargetParticleSet(ParticleSet& P);
void setOrbitalSetSize(int norbs);
void evaluate(const ParticleSet& P, int iat, ValueVector_t& psi);
void evaluate(const ParticleSet& P, int iat
, ValueVector_t& psi, GradVector_t& dpsi, ValueVector_t& d2psi);
inline void
evaluate(const ParticleSet& P, int iat,
ValueVector_t& psi, GradVector_t& dpsi, HessVector_t& d2psi)
{
APP_ABORT("Need specialization of evaluate(HessVector_t&) for grad_grad_grad_logdet. \n");
}
void evaluate(const ParticleSet& P, int first, int last
, ValueMatrix_t& logdet, GradMatrix_t& dlogdet, ValueMatrix_t& d2logdet);
void evaluate_notranspose(const ParticleSet& P, int first, int last
, ValueMatrix_t& logdet, GradMatrix_t& dlogdet, ValueMatrix_t& d2logdet);
void evaluate(const ParticleSet& P, int first, int last
, ValueMatrix_t& logdet, GradMatrix_t& dlogdet, HessMatrix_t& grad_grad_logdet);
void evaluate(const ParticleSet& P, int first, int last
, ValueMatrix_t& logdet, GradMatrix_t& dlogdet, HessMatrix_t& grad_grad_logdet, GGGMatrix_t& grad_grad_grad_logdet);
void evaluate_notranspose(const ParticleSet& P, int first, int last
, ValueMatrix_t& logdet, GradMatrix_t& dlogdet, HessMatrix_t& grad_grad_logdet);
void evaluate_notranspose(const ParticleSet& P, int first, int last
, ValueMatrix_t& logdet, GradMatrix_t& dlogdet, HessMatrix_t& grad_grad_logdet, GGGMatrix_t& grad_grad_grad_logdet);
};
}
#endif
/***************************************************************************
* $RCSfile$ $Author: kesler $
* $Revision: 3535 $ $Date: 2009-02-10 13:04:12 -0600 (Tue, 10 Feb 2009) $
* $Id: SPOSetProxy.h 3535 2009-02-10 19:04:12Z kesler $
***************************************************************************/
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_QUIC_CRYPTO_AEAD_BASE_DECRYPTER_H_
#define NET_QUIC_CRYPTO_AEAD_BASE_DECRYPTER_H_
#include "base/compiler_specific.h"
#include "net/quic/crypto/quic_decrypter.h"
#if defined(USE_OPENSSL)
#include "net/quic/crypto/scoped_evp_aead_ctx.h"
#else
#include <pkcs11t.h>
#include <seccomon.h>
typedef struct PK11SymKeyStr PK11SymKey;
typedef SECStatus (*PK11_DecryptFunction)(
PK11SymKey* symKey, CK_MECHANISM_TYPE mechanism, SECItem* param,
unsigned char* out, unsigned int* outLen, unsigned int maxLen,
const unsigned char* enc, unsigned encLen);
#endif
namespace net {
// AeadBaseDecrypter is the base class of AEAD QuicDecrypter subclasses.
class NET_EXPORT_PRIVATE AeadBaseDecrypter : public QuicDecrypter {
public:
#if defined(USE_OPENSSL)
AeadBaseDecrypter(const EVP_AEAD* aead_alg,
size_t key_size,
size_t auth_tag_size,
size_t nonce_prefix_size);
#else
AeadBaseDecrypter(CK_MECHANISM_TYPE aead_mechanism,
PK11_DecryptFunction pk11_decrypt,
size_t key_size,
size_t auth_tag_size,
size_t nonce_prefix_size);
#endif
virtual ~AeadBaseDecrypter();
// QuicDecrypter implementation
virtual bool SetKey(base::StringPiece key) OVERRIDE;
virtual bool SetNoncePrefix(base::StringPiece nonce_prefix) OVERRIDE;
virtual bool Decrypt(base::StringPiece nonce,
base::StringPiece associated_data,
base::StringPiece ciphertext,
unsigned char* output,
size_t* output_length) OVERRIDE;
virtual QuicData* DecryptPacket(QuicPacketSequenceNumber sequence_number,
base::StringPiece associated_data,
base::StringPiece ciphertext) OVERRIDE;
virtual base::StringPiece GetKey() const OVERRIDE;
virtual base::StringPiece GetNoncePrefix() const OVERRIDE;
protected:
// Make these constants available to the subclasses so that the subclasses
// can assert at compile time their key_size_ and nonce_prefix_size_ do not
// exceed the maximum.
static const size_t kMaxKeySize = 32;
static const size_t kMaxNoncePrefixSize = 4;
#if !defined(USE_OPENSSL)
struct AeadParams {
unsigned int len;
union {
CK_GCM_PARAMS gcm_params;
#if !defined(USE_NSS)
// USE_NSS means we are using system NSS rather than our copy of NSS.
// The system NSS <pkcs11n.h> header doesn't define this type yet.
CK_NSS_AEAD_PARAMS nss_aead_params;
#endif
} data;
};
virtual void FillAeadParams(base::StringPiece nonce,
base::StringPiece associated_data,
size_t auth_tag_size,
AeadParams* aead_params) const = 0;
#endif // !defined(USE_OPENSSL)
private:
#if defined(USE_OPENSSL)
const EVP_AEAD* const aead_alg_;
#else
const CK_MECHANISM_TYPE aead_mechanism_;
const PK11_DecryptFunction pk11_decrypt_;
#endif
const size_t key_size_;
const size_t auth_tag_size_;
const size_t nonce_prefix_size_;
// The key.
unsigned char key_[kMaxKeySize];
// The nonce prefix.
unsigned char nonce_prefix_[kMaxNoncePrefixSize];
#if defined(USE_OPENSSL)
ScopedEVPAEADCtx ctx_;
#endif
};
} // namespace net
#endif // NET_QUIC_CRYPTO_AEAD_BASE_DECRYPTER_H_
|
#include <stdint.h>
/*===-- clang-c/Platform.h - C Index platform decls -------------*- C -*-===*\
|* *|
|* The LLVM Compiler Infrastructure *|
|* *|
|* This file is distributed under the University of Illinois Open Source *|
|* License. See LICENSE.TXT for details. *|
|* *|
|*===----------------------------------------------------------------------===*|
|* *|
|* This header provides platform specific macros (dllimport, deprecated, ...) *|
|* *|
\*===----------------------------------------------------------------------===*/
#ifndef LLVM_CLANG_C_PLATFORM_H
#define LLVM_CLANG_C_PLATFORM_H
#ifdef __cplusplus
extern "C" {
#endif
/* MSVC DLL import/export. */
#ifdef _MSC_VER
#ifdef _CINDEX_LIB_
#define CINDEX_LINKAGE __declspec(dllexport)
#else
#define CINDEX_LINKAGE __declspec(dllimport)
#endif
#else
#define CINDEX_LINKAGE
#endif
#ifdef __GNUC__
#define CINDEX_DEPRECATED __attribute__((deprecated))
#else
#ifdef _MSC_VER
#define CINDEX_DEPRECATED __declspec(deprecated)
#else
#define CINDEX_DEPRECATED
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE114_Process_Control__w32_char_file_18.c
Label Definition File: CWE114_Process_Control__w32.label.xml
Template File: sources-sink-18.tmpl.c
*/
/*
* @description
* CWE: 114 Process Control
* BadSource: file Read input from a file
* GoodSource: Hard code the full pathname to the library
* Sink:
* BadSink : Load a dynamic link library
* Flow Variant: 18 Control flow: goto statements
*
* */
#include "std_testcase.h"
#include <wchar.h>
#ifdef _WIN32
#define FILENAME "C:\\temp\\file.txt"
#else
#define FILENAME "/tmp/file.txt"
#endif
#include <windows.h>
#ifndef OMITBAD
void CWE114_Process_Control__w32_char_file_18_bad()
{
char * data;
char dataBuffer[100] = "";
data = dataBuffer;
goto source;
source:
{
/* Read input from a file */
size_t dataLen = strlen(data);
FILE * pFile;
/* if there is room in data, attempt to read the input from a file */
if (100-dataLen > 1)
{
pFile = fopen(FILENAME, "r");
if (pFile != NULL)
{
/* POTENTIAL FLAW: Read data from a file */
if (fgets(data+dataLen, (int)(100-dataLen), pFile) == NULL)
{
printLine("fgets() failed");
/* Restore NUL terminator if fgets fails */
data[dataLen] = '\0';
}
fclose(pFile);
}
}
}
{
HMODULE hModule;
/* POTENTIAL FLAW: If the path to the library is not specified, an attacker may be able to
* replace his own file with the intended library */
hModule = LoadLibraryA(data);
if (hModule != NULL)
{
FreeLibrary(hModule);
printLine("Library loaded and freed successfully");
}
else
{
printLine("Unable to load library");
}
}
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B() - use goodsource and badsink by reversing the blocks on the goto statement */
static void goodG2B()
{
char * data;
char dataBuffer[100] = "";
data = dataBuffer;
goto source;
source:
/* FIX: Specify the full pathname for the library */
strcpy(data, "C:\\Windows\\System32\\winsrv.dll");
{
HMODULE hModule;
/* POTENTIAL FLAW: If the path to the library is not specified, an attacker may be able to
* replace his own file with the intended library */
hModule = LoadLibraryA(data);
if (hModule != NULL)
{
FreeLibrary(hModule);
printLine("Library loaded and freed successfully");
}
else
{
printLine("Unable to load library");
}
}
}
void CWE114_Process_Control__w32_char_file_18_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()...");
CWE114_Process_Control__w32_char_file_18_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE114_Process_Control__w32_char_file_18_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
#include "KMotionDef.h"
// Home and set the commutation for a 3 phase brushless motor
//
// Assume index mark
void main()
{
float k=0,A=30.0f; // set coil current amplitude to 30 PWM units
// rotate until we find the index mark
ch0->Enable=FALSE;
SetBitDirection(8,0); // define bit 8 (index) as input
for (;;)
{
Delay_sec(0.001); // wait a millisecond
Write3PH(ch0,A, ++k/1000.0); // move the pole
if (!ReadBit(8)) // check for index mark
{
ch0->Position=0; // set current position to Zero
// set commutation offset to 1/6th of a cycle
// encoder has 4000 counts/rev
// motor has 3 cycles per rev
ch0->CommutationOffset = 4000/3.0/6.0;
break;
}
}
Write3PH(ch0,0,0); // turn off the coil
// define the axis as 3 phase BRUSHLESS_3PH_MODE
// and set low PID gains
ch0->InputMode=ENCODER_MODE;
ch0->OutputMode=BRUSHLESS_3PH_MODE;
ch0->Vel=100000.000000;
ch0->Accel=10000000.000000;
ch0->Jerk=100000000.000000;
ch0->P=0.100000;
ch0->I=0.000000;
ch0->D=0.000000;
ch0->FFAccel=0.000000;
ch0->FFVel=0.000000;
ch0->MaxI=200.000000;
ch0->MaxErr=1000000.000000;
ch0->MaxOutput=60.000000;
ch0->DeadBandGain=1.000000;
ch0->DeadBandRange=0.000000;
ch0->InputChan0=0;
ch0->InputChan1=1;
ch0->OutputChan0=0;
ch0->OutputChan1=1;
ch0->LimitSwitchOptions=0x0;
ch0->InputGain0=1.000000;
ch0->InputGain1=1.000000;
ch0->InputOffset0=0.000000;
ch0->InputOffset1=0.000000;
ch0->invDistPerCycle=-0.000750; // CW (3 cycles/rev) / (4000 encoder cnts/rev)
ch0->Lead=0.000000;
ch0->MaxFollowingError=1000000000.000000;
ch0->StepperAmplitude=20.000000;
ch0->iir[0].B0=1.000000;
ch0->iir[0].B1=0.000000;
ch0->iir[0].B2=0.000000;
ch0->iir[0].A1=0.000000;
ch0->iir[0].A2=0.000000;
ch0->iir[1].B0=1.000000;
ch0->iir[1].B1=0.000000;
ch0->iir[1].B2=0.000000;
ch0->iir[1].A1=0.000000;
ch0->iir[1].A2=0.000000;
ch0->iir[2].B0=1.000000;
ch0->iir[2].B1=0.000000;
ch0->iir[2].B2=0.000000;
ch0->iir[2].A1=0.000000;
ch0->iir[2].A2=0.000000;
EnableAxisDest(0,0.0f); // Enable servo at destination of 0
}
|
#ifndef ZSWCRANGEANALYZER_H
#define ZSWCRANGEANALYZER_H
#include <vector>
#include "zswctree.h"
#include "zellipsoid.h"
class ZSwcRangeAnalyzer
{
public:
ZSwcRangeAnalyzer();
std::vector<ZEllipsoid> computeLayerRange(const ZSwcTree &tree);
std::vector<ZPoint> computerLayerCentroid(const ZSwcTree &tree);
std::vector<Swc_Tree_Node*> getOutsideNode(const ZSwcTree &host,
const ZSwcTree &targetTree);
inline void setZStep(double step) { m_zStep = step; }
inline void setZMargin(double margin) { m_zMargin = margin; }
private:
double m_zStep;
double m_zMargin;
};
#endif // ZSWCRANGEANALYZER_H
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_
#define MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_
#include "mojo/public/c/environment/async_waiter.h"
#include "mojo/public/cpp/bindings/lib/message_queue.h"
#include "mojo/public/cpp/bindings/message.h"
#include "mojo/public/cpp/environment/environment.h"
#include "mojo/public/cpp/system/core.h"
namespace mojo {
class ErrorHandler;
namespace internal {
// The Connector class is responsible for performing read/write operations on a
// MessagePipe. It writes messages it receives through the MessageReceiver
// interface that it subclasses, and it forwards messages it reads through the
// MessageReceiver interface assigned as its incoming receiver.
//
// NOTE: MessagePipe I/O is non-blocking.
//
class Connector : public MessageReceiver {
public:
// The Connector takes ownership of |message_pipe|.
explicit Connector(
ScopedMessagePipeHandle message_pipe,
const MojoAsyncWaiter* waiter = Environment::GetDefaultAsyncWaiter());
virtual ~Connector();
// Sets the receiver to handle messages read from the message pipe. The
// Connector will read messages from the pipe regardless of whether or not an
// incoming receiver has been set.
void set_incoming_receiver(MessageReceiver* receiver) {
incoming_receiver_ = receiver;
}
// Errors from incoming receivers will force the connector into an error
// state, where no more messages will be processed. This method is used
// during testing to prevent that from happening.
void set_enforce_errors_from_incoming_receiver(bool enforce) {
enforce_errors_from_incoming_receiver_ = enforce;
}
// Sets the error handler to receive notifications when an error is
// encountered while reading from the pipe or waiting to read from the pipe.
void set_error_handler(ErrorHandler* error_handler) {
error_handler_ = error_handler;
}
// Returns true if an error was encountered while reading from the pipe or
// waiting to read from the pipe.
bool encountered_error() const { return error_; }
// Closes the pipe, triggering the error state. Connector is put into a
// quiescent state.
void CloseMessagePipe();
// Releases the pipe, not triggering the error state. Connector is put into
// a quiescent state.
ScopedMessagePipeHandle PassMessagePipe();
// Waits for the next message on the pipe, blocking until one arrives or an
// error happens. Returns |true| if a message has been delivered, |false|
// otherwise.
bool WaitForIncomingMessage();
// MessageReceiver implementation:
virtual bool Accept(Message* message) MOJO_OVERRIDE;
private:
static void CallOnHandleReady(void* closure, MojoResult result);
void OnHandleReady(MojoResult result);
void WaitToReadMore();
// Returns false if |this| was destroyed during message dispatch.
MOJO_WARN_UNUSED_RESULT bool ReadSingleMessage(MojoResult* read_result);
// |this| can be destroyed during message dispatch.
void ReadAllAvailableMessages();
void NotifyError();
ErrorHandler* error_handler_;
const MojoAsyncWaiter* waiter_;
ScopedMessagePipeHandle message_pipe_;
MessageReceiver* incoming_receiver_;
MojoAsyncWaitID async_wait_id_;
bool error_;
bool drop_writes_;
bool enforce_errors_from_incoming_receiver_;
// If non-null, this will be set to true when the Connector is destroyed. We
// use this flag to allow for the Connector to be destroyed as a side-effect
// of dispatching an incoming message.
bool* destroyed_flag_;
MOJO_DISALLOW_COPY_AND_ASSIGN(Connector);
};
} // namespace internal
} // namespace mojo
#endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_CONNECTOR_H_
|
/*
* Copyright (C) 2011 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 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 APPLE AND ITS 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 APPLE OR ITS 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 ScrollbarThemeOverlay_h
#define ScrollbarThemeOverlay_h
#include "platform/graphics/Color.h"
#include "platform/scroll/ScrollbarTheme.h"
namespace blink {
// This scrollbar theme is used to get overlay scrollbar for platforms other
// than Mac. Mac's overlay scrollbars are in ScrollbarThemeMac*.
class PLATFORM_EXPORT ScrollbarThemeOverlay : public ScrollbarTheme {
public:
enum HitTestBehavior { AllowHitTest, DisallowHitTest };
ScrollbarThemeOverlay(int thumbThickness, int scrollbarMargin, HitTestBehavior);
ScrollbarThemeOverlay(int thumbThickness, int scrollbarMargin, HitTestBehavior, Color);
~ScrollbarThemeOverlay() override {}
int scrollbarThickness(ScrollbarControlSize) override;
int scrollbarMargin() const override;
bool usesOverlayScrollbars() const override;
int thumbPosition(const ScrollbarThemeClient&, float scrollPosition) override;
int thumbLength(const ScrollbarThemeClient&) override;
bool hasButtons(const ScrollbarThemeClient&) override { return false; }
bool hasThumb(const ScrollbarThemeClient&) override;
IntRect backButtonRect(const ScrollbarThemeClient&, ScrollbarPart, bool painting = false) override;
IntRect forwardButtonRect(const ScrollbarThemeClient&, ScrollbarPart, bool painting = false) override;
IntRect trackRect(const ScrollbarThemeClient&, bool painting = false) override;
int thumbThickness(const ScrollbarThemeClient&) override;
int thumbThickness() { return m_thumbThickness; }
void paintThumb(GraphicsContext&, const Scrollbar&, const IntRect&) override;
ScrollbarPart hitTest(const ScrollbarThemeClient&, const IntPoint&) override;
static ScrollbarThemeOverlay& mobileTheme();
private:
int m_thumbThickness;
int m_scrollbarMargin;
HitTestBehavior m_allowHitTest;
Color m_color;
const bool m_useSolidColor;
};
} // namespace blink
#endif
|
#ifndef ZMOVIESTAGE_H
#define ZMOVIESTAGE_H
#include <string>
class Z3DWindow;
class ZMovieStage
{
public:
explicit ZMovieStage(Z3DWindow *window = 0x0);
inline Z3DWindow *getWindow() {
return m_window;
}
inline void setWindow(Z3DWindow *window) {
m_window = window;
}
inline bool isSwcChanged() {
return m_isSwcChanged;
}
inline bool isVolumeChanged() {
return m_isVolumeChanged;
}
inline bool isPunctaChanged() {
return m_isPunctaChanged;
}
inline void setSwcChanged(bool changed) {
m_isSwcChanged = changed;
}
inline void setVolumeChanged(bool changed) {
m_isVolumeChanged = changed;
}
inline void setPunctaChanged(bool changed) {
m_isPunctaChanged = changed;
}
void updateWindow();
void hideVolume();
void showVolume();
void saveScreenShot(const std::string &filePath, int width, int height);
bool hasAnyChange();
private:
Z3DWindow *m_window;
bool m_isSwcChanged;
bool m_isVolumeChanged;
bool m_isPunctaChanged;
};
#endif // ZMOVIESTAGE_H
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_BITMAP_IMAGE_METRICS_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_BITMAP_IMAGE_METRICS_H_
#include "base/time/time.h"
#include "third_party/blink/renderer/platform/graphics/image_orientation.h"
#include "third_party/blink/renderer/platform/platform_export.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
namespace blink {
class IntSize;
class UseCounter;
class PLATFORM_EXPORT BitmapImageMetrics {
STATIC_ONLY(BitmapImageMetrics);
public:
// Values synced with 'DecodedImageType' in
// src/tools/metrics/histograms/enums.xml. These values are persisted to logs.
// Entries should not be renumbered and numeric values should never be reused.
enum class DecodedImageType {
kUnknown = 0,
kJPEG = 1,
kPNG = 2,
kGIF = 3,
kWebP = 4,
kICO = 5,
kBMP = 6,
kAVIF = 7,
kJXL = 8,
kMaxValue = kJXL,
};
// Categories for the JPEG color space histogram. Synced with 'JpegColorSpace'
// in src/tools/metrics/histograms/enums.xml. These values are persisted to
// logs. Entries should not be renumbered and numeric values should never be
// reused.
enum class JpegColorSpace {
kUnknown = 0,
kGrayscale = 1,
kRGB = 2,
kCMYK = 3,
kYCCK = 4,
kYCbCr410 = 5,
kYCbCr411 = 6,
kYCbCr420 = 7,
kYCbCr422 = 8,
kYCbCr440 = 9,
kYCbCr444 = 10,
kYCbCrOther = 11,
kMaxValue = kYCbCrOther,
};
// |type| is the return value of ImageDecoder::FilenameExtension().
static DecodedImageType StringToDecodedImageType(const String& type);
// |type| is the return value of ImageDecoder::FilenameExtension(). |elapsed|
// is how long it took to completely decode the frame.
// |original_frame_rect_area| is the number of decoded pixels. |first| is
// whether this is the first time this image was decoded.
static void CountDecodedImageFrameTime(const String& type,
base::TimeDelta elapsed,
uint64_t original_frame_rect_area,
bool first);
// |type| is the return value of ImageDecoder::FilenameExtension().
static void CountDecodedImageType(const String& type);
// |type| is the return value of ImageDecoder::FilenameExtension().
// |use_counter| may be a null pointer.
static void CountDecodedImageType(const String& type,
UseCounter* use_counter);
// Report the image compression density in 0.01 bits per pixel for an image
// with a smallest side (width or length) of |image_min_side| and total size
// in bytes |image_size_bytes|. Only certain image types and minimum image
// size are reported.
static void CountDecodedImageDensity(const String& type,
int image_min_side,
uint64_t density_centi_bpp,
size_t image_size_bytes);
static void CountJpegArea(const IntSize& size);
static void CountJpegColorSpace(JpegColorSpace color_space);
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_GRAPHICS_BITMAP_IMAGE_METRICS_H_
|
#ifndef _BONITO_PCI_H_
#define _BONITO_PCI_H_
#define BONITO_PCI_CFG_ADDR(idsel, func, reg) ( (1 << (11 + (idsel))) + ((func) << 8) + (reg) )
#define PCI_READ32(idsel, func, reg) \
li a0, BONITO_PCI_CFG_ADDR(idsel, func, reg); \
jal PciRead32; \
nop;
#define PCI_WRITE32(idsel, func, reg, data) \
li a0, BONITO_PCI_CFG_ADDR(idsel, func, reg); \
li a1, data; \
jal PciWrite32; \
nop;
#endif /* _BONITO_PCI_H_ */
|
// =============================================================================
// PROJECT CHRONO - http://projectchrono.org
//
// Copyright (c) 2014 projectchrono.org
// All right reserved.
//
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file at the top level of the distribution and at
// http://projectchrono.org/license-chrono.txt.
//
// =============================================================================
// Authors: Alessandro Tasora, Radu Serban
// =============================================================================
//
// HMMWV Reissner-shell tire subsystem
//
// =============================================================================
#ifndef HMMWV_REISSNER_TIRE_H
#define HMMWV_REISSNER_TIRE_H
#include "chrono_vehicle/wheeled_vehicle/tire/ChReissnerTire.h"
#include "chrono_fea/ChElementShellReissner4.h"
#include "chrono_models/ChApiModels.h"
namespace chrono {
namespace vehicle {
namespace hmmwv {
class CH_MODELS_API HMMWV_ReissnerTire : public ChReissnerTire {
public:
HMMWV_ReissnerTire(const std::string& name);
~HMMWV_ReissnerTire() {}
/// Get the tire radius.
virtual double GetRadius() const override { return m_tire_radius; }
/// Get the rim radius (inner tire radius).
virtual double GetRimRadius() const override { return m_rim_radius; }
/// Get the tire width.
virtual double GetWidth() const override { return m_rim_width; }
/// Get the default tire pressure.
virtual double GetDefaultPressure() const override { return m_default_pressure; }
/// Return list of nodes connected to the rim.
virtual std::vector<std::shared_ptr<fea::ChNodeFEAbase>> GetConnectedNodes() const override;
/// Create the FEA nodes and elements.
/// The wheel rotational axis is assumed to be the Y axis.
virtual void CreateMesh(const ChFrameMoving<>& wheel_frame, ///< frame of associated wheel
VehicleSide side ///< left/right vehicle side
) override;
private:
static const double m_tire_radius;
static const double m_rim_radius;
static const double m_rim_width;
static const int m_div_circumference;
int m_div_width;
static const double m_alpha;
static const double m_default_pressure;
static const double m_rho_0;
static const ChVector<> m_E_0; // Ex Ey (Ez not used)
static const double m_nu_0; // nu for xy shear
static const ChVector<> m_G_0; // Gxy Gxz Gyz
static const double m_rho_1;
static const ChVector<> m_E_1; // Ex Ey (Ez not used)
static const double m_nu_1; // nu for xy shear
static const ChVector<> m_G_1; // Gxy Gxz Gyz
static const double m_rho_2;
static const ChVector<> m_E_2; // Ex Ey (Ez not used)
static const double m_nu_2; // nu for xy shear
static const ChVector<> m_G_2; // Gxy Gxz Gyz
std::vector<std::shared_ptr<fea::ChMaterialShellReissnerOrthotropic>> m_materials;
static const unsigned int m_num_elements_bead;
static const unsigned int m_num_layers_bead;
static const std::vector<double> m_layer_thickness_bead;
static const std::vector<double> m_ply_angle_bead;
static const std::vector<int> m_material_id_bead;
static const unsigned int m_num_elements_sidewall;
static const unsigned int m_num_layers_sidewall;
static const std::vector<double> m_layer_thickness_sidewall;
static const std::vector<double> m_ply_angle_sidewall;
static const std::vector<int> m_material_id_sidewall;
static const unsigned int m_num_elements_tread;
static const unsigned int m_num_layers_tread;
static const std::vector<double> m_layer_thickness_tread;
static const std::vector<double> m_ply_angle_tread;
static const std::vector<int> m_material_id_tread;
static const float m_friction;
static const float m_restiturion;
static const float m_Young;
static const float m_Poisson;
static const float m_kn;
static const float m_gn;
static const float m_kt;
static const float m_gt;
static const unsigned int m_num_points;
static const double m_profile[71][3];
std::vector<double> m_profile_t;
std::vector<double> m_profile_x;
std::vector<double> m_profile_y;
};
} // end namespace hmmwv
} // end namespace vehicle
} // end namespace chrono
#endif
|
/* Copyright 2016 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.
*/
/* Clocks and power management settings */
#include "clock.h"
#include "common.h"
#include "util.h"
#include "power_mgt.h"
/* Console output macros */
#define CPUTS(outstr) cputs(CC_CLOCK, outstr)
#define CPRINTS(format, args...) cprints(CC_CLOCK, format, ## args)
void clock_init(void)
{
/* No initialization for clock on ISH */
}
void clock_refresh_console_in_use(void)
{
/**
* on ISH, uart interrupt can only wakeup ISH from low power state via
* CTS pin, but most ISH platforms only have Rx and Tx pins, no CTS pin
* exposed, so, we need block ISH enter low power state for a while
* when console is in use
*/
ish_pm_refresh_console_in_use();
}
|
/*
* Copyright (c) 2009, Piotr Korzuszek
* 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 <organization> 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.
*/
#pragma once
#include <list>
#include "gfx/Drawable.h"
namespace Race {
class Sandpit;
}
namespace Gfx {
class Sandpit : public Gfx::Drawable {
public:
Sandpit(const Race::Sandpit *p_logicSandpit);
virtual ~Sandpit();
virtual void draw(CL_GraphicContext &p_gc);
virtual void load(CL_GraphicContext &p_gc);
void setPosition(const CL_Pointf &p_position);
private:
/** Sandpit from logic */
const Race::Sandpit *m_logicSandpit;
/** Draw position */
CL_Pointf m_position;
/** Build state */
bool m_built;
/** Pixel data */
CL_SharedPtr<CL_PixelBuffer> m_pixelData;
/** The texture */
CL_SharedPtr<CL_Texture> m_texture;
// build routines
void build();
CL_Rect calculateCircleBounds();
void fillCircles(int p_width, int p_height, const CL_Rect& p_totalBounds);
};
}
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_45.c
Label Definition File: CWE121_Stack_Based_Buffer_Overflow__CWE805.string.label.xml
Template File: sources-sink-45.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
* Sinks: ncat
* BadSink : Copy string to data using wcsncat
* Flow Variant: 45 Data flow: data passed as a static global variable from one function to another in the same source file
*
* */
#include "std_testcase.h"
#include <wchar.h>
static wchar_t * CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_45_badData;
static wchar_t * CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_45_goodG2BData;
#ifndef OMITBAD
static void badSink()
{
wchar_t * data = CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_45_badData;
{
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_45_bad()
{
wchar_t * data;
wchar_t dataBadBuffer[50];
wchar_t dataGoodBuffer[100];
/* 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 */
CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_45_badData = data;
badSink();
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* goodG2B() uses the GoodSource with the BadSink */
static void goodG2BSink()
{
wchar_t * data = CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_45_goodG2BData;
{
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);
}
}
static void goodG2B()
{
wchar_t * data;
wchar_t dataBadBuffer[50];
wchar_t dataGoodBuffer[100];
/* FIX: Set a pointer to a "large" buffer, thus avoiding buffer overflows in the sinks. */
data = dataGoodBuffer;
data[0] = L'\0'; /* null terminate */
CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_45_goodG2BData = data;
goodG2BSink();
}
void CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_45_good()
{
goodG2B();
}
#endif /* OMITGOOD */
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
#ifdef INCLUDEMAIN
int main(int argc, char * argv[])
{
/* seed randomness */
srand( (unsigned)time(NULL) );
#ifndef OMITGOOD
printLine("Calling good()...");
CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_45_good();
printLine("Finished good()");
#endif /* OMITGOOD */
#ifndef OMITBAD
printLine("Calling bad()...");
CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_45_bad();
printLine("Finished bad()");
#endif /* OMITBAD */
return 0;
}
#endif
|
/*
* Copyright 2021 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef skgpu_Buffer_DEFINED
#define skgpu_Buffer_DEFINED
#include "experimental/graphite/src/Resource.h"
#include "experimental/graphite/src/ResourceTypes.h"
namespace skgpu {
class Buffer : public Resource {
public:
size_t size() const { return fSize; }
void* map();
void unmap();
bool isMapped() const { return fMapPtr; }
protected:
Buffer(const Gpu* gpu, size_t size, BufferType type, PrioritizeGpuReads prioritizeGpuReads)
: Resource(gpu, Ownership::kOwned)
, fSize(size)
, fType(type)
, fPrioritizeGpuReads(prioritizeGpuReads) {}
void* fMapPtr = nullptr;
private:
virtual void onMap() = 0;
virtual void onUnmap() = 0;
// TODO: Remove these getters once we start using fType and fPrioritizeGpuReads in key
// generation. For now this silences compiler unused member warnings.
BufferType bufferType() const { return fType; }
PrioritizeGpuReads prioritizeGpuReads() const { return fPrioritizeGpuReads; }
size_t fSize;
BufferType fType;
PrioritizeGpuReads fPrioritizeGpuReads;
};
} // namespace skgpu
#endif // skgpu_Buffer_DEFINED
|
/*****************************************************************************
Copyright (c) 2014, Intel Corp.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
******************************************************************************
* Contents: Native high-level C interface to LAPACK function stprfb
* Author: Intel Corporation
* Generated June 2016
*****************************************************************************/
#include "lapacke_utils.h"
lapack_int LAPACKE_stprfb( int matrix_layout, char side, char trans, char direct,
char storev, lapack_int m, lapack_int n,
lapack_int k, lapack_int l, const float* v,
lapack_int ldv, const float* t, lapack_int ldt,
float* a, lapack_int lda, float* b, lapack_int ldb)
{
lapack_int ncols_v, nrows_v, ncols_a, nrows_a;
lapack_int info = 0;
lapack_int ldwork;
lapack_int work_size;
float* work = NULL;
if( matrix_layout != LAPACK_COL_MAJOR && matrix_layout != LAPACK_ROW_MAJOR ) {
LAPACKE_xerbla( "LAPACKE_stprfb", -1 );
return -1;
}
#ifndef LAPACK_DISABLE_NAN_CHECK
if( LAPACKE_get_nancheck() ) {
/* Optionally check input matrices for NaNs
* V is m-by-k (left, columnwise)
* or n-by-k (right, columnwise)
* or k-by-m (left, rowwise)
* or k-by-n (right, rowwise)
* T is k-by-k
* A is k-by-n (left)
* or m-by-k (right)
* B is m-by-n
*/
if( LAPACKE_lsame( storev, 'C' ) ) {
ncols_v = k;
nrows_v = LAPACKE_lsame( side, 'L' ) ? m :
LAPACKE_lsame( side, 'R' ) ? n : 0;
} else if( LAPACKE_lsame( storev, 'R' ) ) {
ncols_v = LAPACKE_lsame( side, 'L' ) ? m :
LAPACKE_lsame( side, 'R' ) ? n : 0;
nrows_v = k;
} else {
ncols_v = 0;
nrows_v = 0;
}
nrows_a = LAPACKE_lsame( side, 'L' ) ? k :
LAPACKE_lsame( side, 'R' ) ? m : 0;
ncols_a = LAPACKE_lsame( side, 'L' ) ? n :
LAPACKE_lsame( side, 'R' ) ? k : 0;
if( LAPACKE_sge_nancheck( matrix_layout, ncols_a, nrows_a, a, lda ) ) {
return -14;
}
if( LAPACKE_sge_nancheck( matrix_layout, m, n, b, ldb ) ) {
return -16;
}
if( LAPACKE_sge_nancheck( matrix_layout, k, k, t, ldt ) ) {
return -12;
}
if( LAPACKE_sge_nancheck( matrix_layout, nrows_v, ncols_v, v, ldv ) ) {
return -10;
}
}
#endif
if (side=='l' || side=='L') {
ldwork = k;
work_size = MAX(1,ldwork) * MAX(1,n);
}
else {
ldwork = m;
work_size = MAX(1,ldwork) * MAX(1,k);
}
/* Allocate memory for working array(s) */
work = (float*)
LAPACKE_malloc( sizeof(float) * work_size );
if( work == NULL ) {
info = LAPACK_WORK_MEMORY_ERROR;
goto exit_level_0;
}
/* Call middle-level interface */
info = LAPACKE_stprfb_work( matrix_layout, side, trans, direct, storev, m, n,
k, l, v, ldv, t, ldt, a, lda, b, ldb, work,
ldwork );
/* Release memory and exit */
LAPACKE_free( work );
exit_level_0:
if( info == LAPACK_WORK_MEMORY_ERROR ) {
LAPACKE_xerbla( "LAPACKE_stprfb", info );
}
return info;
}
|
#include <alloca.h>
#include <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>
#include "wr_bluetooth.h"
#include "wr_sdp_lib.h"
int wr_sdp_set_browse_groups(sdp_record_t* rec, sdp_list_t* seq) {
return sdp_set_browse_groups(rec, seq);
}
sdp_session_t *wr_sdp_connect(const wr_bdaddr_t *src, const wr_bdaddr_t *dst, const uint32_t flags) {
bdaddr_t *newSrc = alloca(sizeof(bdaddr_t));
bdaddr_t *newDst = alloca(sizeof(bdaddr_t));
from_wr_bdaddr(newSrc, src);
from_wr_bdaddr(newDst, dst);
return sdp_connect(newSrc, newDst, flags);
}
int wr_sdp_set_service_classes(sdp_record_t* rec, sdp_list_t* seq) {
return sdp_set_service_classes(rec, seq);
}
void wr_sdp_set_service_id(sdp_record_t *rec, const uuid_t *uuid) {
sdp_set_service_id(rec, *uuid);
} |
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_RENDERER_WEB_APPS_H_
#define CHROME_RENDERER_WEB_APPS_H_
#include <string>
#include <vector>
#include "base/strings/string16.h"
#include "ui/gfx/geometry/size.h"
namespace blink {
class WebLocalFrame;
}
struct WebApplicationInfo;
namespace web_apps {
// Parses the icon's size attribute as defined in the HTML 5 spec. Returns true
// on success, false on errors. On success either all the sizes specified in
// the attribute are added to sizes, or is_any is set to true.
//
// You shouldn't have a need to invoke this directly, it's public for testing.
bool ParseIconSizes(const base::string16& text, std::vector<gfx::Size>* sizes,
bool* is_any);
// Parses |app_info| information out of the document in WebFrame. Note that the
// document may contain no web application information, in which case |app_info|
// is unchanged.
void ParseWebAppFromWebDocument(blink::WebLocalFrame* frame,
WebApplicationInfo* app_info);
} // namespace web_apps
#endif // CHROME_RENDERER_WEB_APPS_H_
|
/*
* Copyright (c) 2015, Stefan Lankes, RWTH Aachen University
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of 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 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 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.
*/
#include <hermit/stdlib.h>
struct itimerval;
int getitimer(int which, struct itimerval *value)
{
return 0;
}
int setitimer(int which, const struct itimerval *restrict value, struct itimerval * ovalue)
{
return 0;
}
|
// Copyright 2018-present 650 Industries. All rights reserved.
#import <Foundation/Foundation.h>
#import <UMAppLoader/UMAppLoaderInterface.h>
#define UM_REGISTER_APP_LOADER_WITH_CUSTOM_LOAD(loader_name, _custom_load_code) \
extern void UMRegisterAppLoader(NSString *, Class); \
+ (void)load { \
UMRegisterAppLoader(@#loader_name, self); \
_custom_load_code \
}
#define UM_REGISTER_APP_LOADER(loader_name) \
UM_REGISTER_APP_LOADER_WITH_CUSTOM_LOAD(loader_name,)
@interface UMAppLoaderProvider : NSObject
- (nullable id<UMAppLoaderInterface>)createAppLoader:(nonnull NSString *)loaderName;
+ (nonnull instancetype)sharedInstance;
@end
|
/* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE590_Free_Memory_Not_on_Heap__free_struct_static_54c.c
Label Definition File: CWE590_Free_Memory_Not_on_Heap__free.label.xml
Template File: sources-sink-54c.tmpl.c
*/
/*
* @description
* CWE: 590 Free Memory Not on Heap
* BadSource: static Data buffer is declared static on the stack
* GoodSource: Allocate memory on the heap
* Sink:
* BadSink : Print then free data
* 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 CWE590_Free_Memory_Not_on_Heap__free_struct_static_54d_badSink(twoIntsStruct * data);
void CWE590_Free_Memory_Not_on_Heap__free_struct_static_54c_badSink(twoIntsStruct * data)
{
CWE590_Free_Memory_Not_on_Heap__free_struct_static_54d_badSink(data);
}
#endif /* OMITBAD */
#ifndef OMITGOOD
/* good function declaration */
void CWE590_Free_Memory_Not_on_Heap__free_struct_static_54d_goodG2BSink(twoIntsStruct * data);
/* goodG2B uses the GoodSource with the BadSink */
void CWE590_Free_Memory_Not_on_Heap__free_struct_static_54c_goodG2BSink(twoIntsStruct * data)
{
CWE590_Free_Memory_Not_on_Heap__free_struct_static_54d_goodG2BSink(data);
}
#endif /* OMITGOOD */
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_USAGE_STORE_H_
#define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_USAGE_STORE_H_
#include <map>
#include <string>
#include <vector>
#include "base/macros.h"
#include "base/sequence_checker.h"
#include "components/data_reduction_proxy/core/browser/data_store.h"
namespace base {
class Time;
}
namespace data_reduction_proxy {
class DataStore;
class DataUsageBucket;
// Time interval for each DataUsageBucket.
constexpr int kDataUsageBucketLengthInMinutes = 15;
// Number of days for which to maintain data usage history.
constexpr int kDataUsageHistoryNumDays = 60;
// Store for detailed data usage stats. Data usage from every
// |kDataUsageBucketLengthMins| interval is stored in a DataUsageBucket.
class DataUsageStore {
public:
explicit DataUsageStore(DataStore* db);
~DataUsageStore();
// Loads the historic data usage into |data_usage|.
void LoadDataUsage(std::vector<DataUsageBucket>* data_usage);
// Loads the data usage bucket for the current interval into |current_bucket|.
// This method must be called at least once before any calls to
// |StoreCurrentDataUsageBucket|.
void LoadCurrentDataUsageBucket(DataUsageBucket* bucket);
// Stores the data usage bucket for the current interval. This will overwrite
// the current data usage bucket in the |db_| if they are for the same
// interval. It will also backfill any missed intervals with empty data.
// Intervals might be missed because Chrome was not running, or there was no
// network activity during an interval.
void StoreCurrentDataUsageBucket(const DataUsageBucket& current_bucket);
// Deletes all historical data usage from storage.
void DeleteHistoricalDataUsage();
// Deletes historical data usage from storage.
void DeleteBrowsingHistory(const base::Time& start, const base::Time& end);
// Returns whether |time1| and |time2| are in the same interval. Each hour is
// divided into |kDataUsageBucketLengthMins| minute long intervals. Returns
// true if either |time1| or |time2| has NULL time since an uninitialized
// bucket can be assigned to any interval.
static bool AreInSameInterval(const base::Time& time1,
const base::Time& time2);
// Returns whether the bucket that was last updated at |bucket_last_updated|
// overlaps in time with the interval [|start_interval|, |end_interval|].
static bool BucketOverlapsInterval(const base::Time& bucket_last_updated,
const base::Time& start_interval,
const base::Time& end_interval);
private:
friend class DataUsageStoreTest;
// Converts the given |bucket| into a string format for persistance to
// |DataReductionProxyStore| and adds it to the map. The key is generated
// based on |current_bucket_index_|.
// |current_bucket_index_| will be incremented before generating the key if
// |increment_current_index| is true.
void GenerateKeyAndAddToMap(const DataUsageBucket& bucket,
std::map<std::string, std::string>* map,
bool increment_current_index);
// Returns the offset between the bucket for |current| time and the last
// bucket that was persisted to the store. Eg: Returns 0 if |current| is in
// the last persisted bucket. Returns 1 if |current| belongs to the bucket
// immediately after the last persisted bucket.
int BucketOffsetFromLastSaved(const base::Time& current) const;
// Computes the index of the bucket for the given |time| relative to
// |current_bucket_index_| and |current_bucket_last_updated_|.
// |current_bucket_last_updated_| belongs at |current_bucket_index_| and
// bucket index is computed by going backwards or forwards from current index
// by one position for every |kDataUsageBucketLengthInMinutes| minutes.
int ComputeBucketIndex(const base::Time& time) const;
// Loads the data usage bucket at the given index.
DataStore::Status LoadBucketAtIndex(int index, DataUsageBucket* current);
// The store to persist data usage information.
DataStore* db_;
// The index of the last bucket persisted in the |db_|. |DataUsageBucket| is
// stored in the |db_| as a circular array. This index points to the array
// position corresponding to the current bucket.
int current_bucket_index_;
// The time when the current bucket was last written to |db_|. This field is
// used to determine if a DataUsageBucket to be saved belongs to the same
// interval, or a more recent interval.
base::Time current_bucket_last_updated_;
base::SequenceChecker sequence_checker_;
DISALLOW_COPY_AND_ASSIGN(DataUsageStore);
};
} // namespace data_reduction_proxy
#endif // COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_USAGE_STORE_H_
|
// Copyright (c) 2009 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_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_GTK_H_
#define CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_GTK_H_
#include <map>
#include <string>
#include <vector>
#include "base/scoped_ptr.h"
#include "chrome/browser/gtk/menu_gtk.h"
#include "chrome/browser/gtk/standard_menus.h"
#include "chrome/browser/tab_contents/render_view_context_menu.h"
class ContextMenuParams;
class RenderWidgetHostView;
// TODO(port): we need accelerator support for this class.
class RenderViewContextMenuGtk : public RenderViewContextMenu,
public MenuGtk::Delegate {
public:
RenderViewContextMenuGtk(TabContents* web_contents,
const ContextMenuParams& params,
uint32_t triggering_event_time);
~RenderViewContextMenuGtk();
// Show the menu at the current cursor location.
void Popup();
// Menu::Delegate implementation ---------------------------------------------
virtual bool IsCommandEnabled(int id) const;
virtual bool IsItemChecked(int id) const;
virtual void ExecuteCommand(int id);
virtual std::string GetLabel(int id) const;
virtual void StoppedShowing();
protected:
// RenderViewContextMenu implementation --------------------------------------
virtual void DoInit();
virtual void AppendMenuItem(int id);
virtual void AppendMenuItem(int id, const string16& label);
virtual void AppendRadioMenuItem(int id, const string16& label);
virtual void AppendCheckboxMenuItem(int id, const string16& label);
virtual void AppendSeparator();
virtual void StartSubMenu(int id, const string16& label);
virtual void FinishSubMenu();
virtual void DidWriteURLToClipboard(const std::string& url);
private:
void AppendItem(int id, const string16& label, MenuItemType type);
static void DoneMakingMenu(std::vector<MenuCreateMaterial>* menu);
scoped_ptr<MenuGtk> gtk_menu_;
std::map<int, std::string> label_map_;
std::vector<MenuCreateMaterial> menu_;
std::vector<MenuCreateMaterial> submenu_;
bool making_submenu_;
uint32_t triggering_event_time_;
};
#endif // CHROME_BROWSER_TAB_CONTENTS_RENDER_VIEW_CONTEXT_MENU_GTK_H_
|
#include <mpi.h>
#include <unistd.h>
int main( int argc, char **argv ){
MPI_Init(&argc, &argv);
sleep(5);
MPI_Finalize();
return 0;
}
|
/*""FILE COMMENT""*******************************************************
* System Name : PDL driver API
* File Name : r_pdl_definitions.h
* Version : 0.10
* Contents : API headers for RX62N (100-pin package)
* Customer :
* Model :
* Order :
* CPU : RX600
* Compiler : RXC
* OS :
* Programmer :
* Note :
************************************************************************
* Copyright,2010 RENESAS ELECTRONICS CORPORATION
* AND RENESAS SOLUTIONS CORPORATION
************************************************************************
* History : 2010.06.22
* : Ver 0.10
* : First draft
*""FILE COMMENT END""**************************************************/
#ifndef R_PDL_DEFS_H
#define R_PDL_DEFS_H
#define PDL_VERSION 0x0010u /* v00.10 in BCD format */
#define DEVICE_PACKAGE_LQFP_100
#include "r_pdl_user_definitions.h"
/* Peripiherals that are common to all device packages */
#include "r_pdl_adc_10_RX62Nxx.h"
#include "r_pdl_adc_12_RX62Nxx.h"
#include "r_pdl_bsc_RX62Nxx.h"
#include "r_pdl_cgc_RX62Nxx.h"
#include "r_pdl_cmt_RX62Nxx.h"
#include "r_pdl_crc_RX62Nxx.h"
#include "r_pdl_dac_10_RX62Nxx.h"
#include "r_pdl_dmac_RX62Nxx.h"
#include "r_pdl_dtc_RX62Nxx.h"
#include "r_pdl_intc_RX62Nxx.h"
#include "r_pdl_lpc_RX62Nxx.h"
#include "r_pdl_mcu_RX62Nxx.h"
#include "r_pdl_mtu_RX62Nxx.h"
#include "r_pdl_pfc_RX62Nxx.h"
#include "r_pdl_poe_RX62Nxx.h"
#include "r_pdl_ppg_RX62Nxx.h"
#include "r_pdl_sci_RX62Nxx.h"
#include "r_pdl_spi_RX62Nxx.h"
#include "r_pdl_tmr_RX62Nxx.h"
#include "r_pdl_wdt_RX62Nxx.h"
/* Peripiherals that are device package-dependent */
#include "r_pdl_iic_RX62NxFP.h"
#include "r_pdl_io_port_RX62NxFP.h"
#endif
/* End of file */
|
#pragma once
#include <Eigen/Dense>
#include <chrono>
#include <iostream>
#include <stdexcept>
#include <thread>
#include "drake/systems/simulation_options.h"
#include "drake/systems/vector.h"
namespace drake {
/** @defgroup simulation Simulation
*@{
*@brief Algorithms for simulating dynamical systems
*@}
*/
typedef std::chrono::system_clock TimeClock; // would love to use steady_clock,
// but it seems to not compile on
// all platforms (e.g. MSVC 2013
// Win64)
typedef std::chrono::duration<double> TimeDuration;
typedef std::chrono::time_point<TimeClock, TimeDuration> TimePoint;
/*!
* Determines whether the simulation time has lagged behind the real time beyond
* the specified <pre>timeout_seconds</pre>, after accounting for the real-time
* factor. If it has, throw a <pre>std::runtime_error</pre> exception.
*
* @param wall_clock_start_time The the simulation's start time.
* @param sim_time The current simulation time.
* @param realtime_factor The simulation's desired real-time factor. This
* is the speed at which the simulation should run relative to real-time.
* For example, 0 means the simulation should run as fast as possible,
* 1.0 means the simulation should run at real-time, and 2.0 means the
* simulation should run at 2X real-time speed.
* @param timeout_seconds The maximum difference between the current time and
* the desired time (as determined based on the current simulation time
* and real-time factor) before which an exception is thrown.
* return True if the realtime factor was successfully handled. False otherwise.
*/
inline bool handle_realtime_factor(const TimePoint& wall_clock_start_time,
double sim_time, double realtime_factor,
double timeout_seconds) {
bool result = true;
if (realtime_factor > 0.0) {
TimePoint wall_time = TimeClock::now();
TimePoint desired_time =
wall_clock_start_time + TimeDuration(sim_time / realtime_factor);
if (desired_time > wall_time) {
// could probably just call sleep_until, but just in case
std::this_thread::sleep_until(desired_time);
} else if (wall_time >
desired_time + TimeDuration(timeout_seconds / realtime_factor)) {
result = false;
}
}
return result;
}
/** simulate
* @brief Runs a simulation given a model, its initial conditions, and a number
*of simulation parameters
* @ingroup simulation
*
* Currently runs with a fixed step integrator using the initial step size in
* \p options and stepping from initial time \p ti to final time \p tf.
* There is no error control; if you have accuracy or stability problems try
* a smaller step size.
*
* @param sys The system being simulated.
* @param ti The initial time of the simulation.
* @param tf The final time of the simulation.
* @param xi The state vector of the system being simulated.
* @param options The simulation options.
* @return The final simulation time.
*/
template <typename System>
double simulate(const System& sys, double ti, double tf,
const typename System::template StateVector<double>& xi,
const SimulationOptions& options) {
TimePoint start = TimeClock::now();
typename System::template StateVector<double> x(xi), x1est, xdot0, xdot1;
typename System::template InputVector<double> u(
Eigen::VectorXd::Zero(getNumInputs(sys)));
typename System::template OutputVector<double> y;
bool rt_warning_printed = false;
// Take steps from ti to tf.
double t = ti;
while (t < tf && !options.should_stop(t)) {
double realtime_factor = options.realtime_factor;
if (realtime_factor < 0.0) {
realtime_factor = 0.0;
}
if (!handle_realtime_factor(start, t, realtime_factor,
options.timeout_seconds)) {
std::stringstream error_msg;
error_msg
<< "The simulation is not keeping up with desired real-time factor. "
<< "It is behind by more than " << options.timeout_seconds
<< " (scaled) second at simulation time " << t;
if (options.warn_real_time_violation) {
if (!rt_warning_printed) {
std::cerr << "WARNING: " << error_msg.str() << std::endl;
rt_warning_printed = true; // Suppress future warnings.
}
} else {
throw std::runtime_error(error_msg.str());
}
}
const double dt = (std::min)(options.initial_step_size, tf - t);
// Output is at t0, x0, u0.
y = sys.output(t, x, u);
// This is an RK2 integrator (explicit trapezoid rule).
// First stage: xd0 = dynamics(t0,x0,u0).
xdot0 = sys.dynamics(t, x, u);
x1est = toEigen(x) + dt * toEigen(xdot0); // explicit Euler step
t += dt;
// Second stage: xd1 = dynamics(t1,x1est,u0).
xdot1 = sys.dynamics(t, x1est, u);
// 2nd order result: x = x0 + dt (xd0+xd1)/2.
x = toEigen(x) + (dt / 2) * (toEigen(xdot0) + toEigen(xdot1));
}
return t;
}
/** simulate
* @brief Runs a simulation using the default simulation options
* @ingroup simulation
*
*/
template <typename System>
void simulate(const System& sys, double t0, double tf,
const typename System::template StateVector<double>& x0) {
simulate(sys, t0, tf, x0, SimulationOptions());
}
/** simulate
* @brief Runs a simulation using the default simulation options
* @ingroup simulation
*
*/
template <typename System>
void simulate(const System& sys, double t0, double tf) {
auto x0 = getInitialState(sys);
simulate(sys, t0, tf, x0);
}
} // end namespace drake
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROMEOS_DBUS_SHILL_IPCONFIG_CLIENT_H_
#define CHROMEOS_DBUS_SHILL_IPCONFIG_CLIENT_H_
#include <string>
#include "base/basictypes.h"
#include "base/callback.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/dbus_client.h"
#include "chromeos/dbus/dbus_client_implementation_type.h"
#include "chromeos/dbus/shill_client_helper.h"
namespace base {
class Value;
class DictionaryValue;
} // namespace base
namespace dbus {
class ObjectPath;
} // namespace dbus
namespace chromeos {
class ShillPropertyChangedObserver;
// ShillIPConfigClient is used to communicate with the Shill IPConfig
// service. All methods should be called from the origin thread which
// initializes the DBusThreadManager instance.
class CHROMEOS_EXPORT ShillIPConfigClient : public DBusClient {
public:
typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler;
typedef ShillClientHelper::DictionaryValueCallback DictionaryValueCallback;
virtual ~ShillIPConfigClient();
// Factory function, creates a new instance which is owned by the caller.
// For normal usage, access the singleton via DBusThreadManager::Get().
static ShillIPConfigClient* Create(DBusClientImplementationType type);
// Adds a property changed |observer| for the ipconfig at |ipconfig_path|.
virtual void AddPropertyChangedObserver(
const dbus::ObjectPath& ipconfig_path,
ShillPropertyChangedObserver* observer) = 0;
// Removes a property changed |observer| for the ipconfig at |ipconfig_path|.
virtual void RemovePropertyChangedObserver(
const dbus::ObjectPath& ipconfig_path,
ShillPropertyChangedObserver* observer) = 0;
// Refreshes the active IP configuration after service property changes and
// renews the DHCP lease, if any.
virtual void Refresh(const dbus::ObjectPath& ipconfig_path,
const VoidDBusMethodCallback& callback) = 0;
// Calls GetProperties method.
// |callback| is called after the method call succeeds.
virtual void GetProperties(const dbus::ObjectPath& ipconfig_path,
const DictionaryValueCallback& callback) = 0;
// Calls SetProperty method.
// |callback| is called after the method call succeeds.
virtual void SetProperty(const dbus::ObjectPath& ipconfig_path,
const std::string& name,
const base::Value& value,
const VoidDBusMethodCallback& callback) = 0;
// Calls ClearProperty method.
// |callback| is called after the method call succeeds.
virtual void ClearProperty(const dbus::ObjectPath& ipconfig_path,
const std::string& name,
const VoidDBusMethodCallback& callback) = 0;
// Calls Remove method.
// |callback| is called after the method call succeeds.
virtual void Remove(const dbus::ObjectPath& ipconfig_path,
const VoidDBusMethodCallback& callback) = 0;
protected:
friend class ShillIPConfigClientTest;
// Create() should be used instead.
ShillIPConfigClient();
private:
DISALLOW_COPY_AND_ASSIGN(ShillIPConfigClient);
};
} // namespace chromeos
#endif // CHROMEOS_DBUS_SHILL_IPCONFIG_CLIENT_H_
|
/* Copyright 2016 Bloq, Inc.
* Distributed under the MIT/X11 software license, see the accompanying
* file COPYING or http://www.opensource.org/licenses/mit-license.php.
*/
#include <ccoin/crypto/hmac.h> // for hmac_sha256, hmac_sha512
#include <ccoin/crypto/rijndael.h> // for aes_cbc_encrypt, etc
#include <ccoin/crypto/ripemd160.h> // for RIPEMD160_DIGEST_LENGTH, etc
#include <ccoin/crypto/sha1.h> // for SHA1_DIGEST_LENGTH, etc
#include <ccoin/crypto/sha2.h> // for SHA256_DIGEST_LENGTH, etc
#include <ccoin/cstr.h> // for cstr_free, cstring
#include <ccoin/hexcode.h> // for str2hex
#include <assert.h> // for assert
#include <stdint.h> // for uint8_t
#include <string.h> // for strlen, strcmp, memcpy, etc
#include <stdbool.h> // for true
static const char *test_data = "Harold of the Rocks";
static void test_sha1(void)
{
SHA1_CTX ctx;
unsigned char md1[SHA1_DIGEST_LENGTH];
unsigned char md2[SHA1_DIGEST_LENGTH];
static const char *test_hashstr = "455741020672c0e50a41efde48a0b727d441440e";
sha1_Init(&ctx);
sha1_Update(&ctx, test_data, strlen(test_data));
sha1_Final(md1, &ctx);
sha1_Raw(test_data, strlen(test_data), md2);
cstring *s1 = str2hex(md1, sizeof(md1));
cstring *s2 = str2hex(md2, sizeof(md2));
assert(strcmp(test_hashstr, s1->str) == 0);
assert(strcmp(test_hashstr, s2->str) == 0);
cstr_free(s1, true);
cstr_free(s2, true);
}
static void test_sha256(void)
{
SHA256_CTX ctx;
unsigned char md1[SHA256_DIGEST_LENGTH];
unsigned char md2[SHA256_DIGEST_LENGTH];
static const char *test_hashstr = "e500c59624947f43d7849943651e41f503fe4a7e1570b90e7b71562ad2293441";
sha256_Init(&ctx);
sha256_Update(&ctx, test_data, strlen(test_data));
sha256_Final(md1, &ctx);
sha256_Raw(test_data, strlen(test_data), md2);
cstring *s1 = str2hex(md1, sizeof(md1));
cstring *s2 = str2hex(md2, sizeof(md2));
assert(strcmp(test_hashstr, s1->str) == 0);
assert(strcmp(test_hashstr, s2->str) == 0);
cstr_free(s1, true);
cstr_free(s2, true);
}
static void test_sha512(void)
{
SHA512_CTX ctx;
unsigned char md1[SHA512_DIGEST_LENGTH];
unsigned char md2[SHA512_DIGEST_LENGTH];
static const char *test_hashstr = "ad4630aa2150bd6d6c6ebae4ab9ecfa54b5162dc5aec7b3d426ec2f31992772ec96df66ba720bd6cdc5e62592c02bfcd72a48b161bda00cc92e9da53bf08d2c8";
sha512_Init(&ctx);
sha512_Update(&ctx, test_data, strlen(test_data));
sha512_Final(md1, &ctx);
sha512_Raw(test_data, strlen(test_data), md2);
cstring *s1 = str2hex(md1, sizeof(md1));
cstring *s2 = str2hex(md2, sizeof(md2));
assert(strcmp(test_hashstr, s1->str) == 0);
assert(strcmp(test_hashstr, s2->str) == 0);
cstr_free(s1, true);
cstr_free(s2, true);
}
static void test_ripemd160(void)
{
RIPEMD160_CTX ctx;
unsigned char md1[RIPEMD160_DIGEST_LENGTH];
unsigned char md2[RIPEMD160_DIGEST_LENGTH];
static const char *test_hashstr = "62678ae26728a6b9f33b2e13a8d8fb53860d8d27";
ripemd160_Init(&ctx);
ripemd160_Update(&ctx, test_data, strlen(test_data));
ripemd160_Final(md1, &ctx);
ripemd160(test_data, strlen(test_data), md2);
cstring *s1 = str2hex(md1, sizeof(md1));
cstring *s2 = str2hex(md2, sizeof(md2));
assert(strcmp(test_hashstr, s1->str) == 0);
assert(strcmp(test_hashstr, s2->str) == 0);
cstr_free(s1, true);
cstr_free(s2, true);
}
static void test_hmac(void)
{
static const char *key = "blockchain blockchain blockchain";
static const char *res256 = "3b5d1e25fbad8111af6d691bd15210cac2fc7b58039809188294f33250168b6a";
static const char *res512 = "436a835a8cb769a708903b59ce804e20a770639df7769688c533aafb6f4a1d42d7f88f7b7bdfb6cb47dc5340edbe4342bcc8b76ba9f733fa1bfef24695461922";
unsigned char md256[SHA256_DIGEST_LENGTH];
unsigned char md512[SHA512_DIGEST_LENGTH];
hmac_sha256(key, strlen(key), test_data, strlen(test_data), md256);
hmac_sha512(key, strlen(key), test_data, strlen(test_data), md512);
cstring *s256 = str2hex(md256, sizeof(md256));
cstring *s512 = str2hex(md512, sizeof(md512));
assert(strcmp(res256, s256->str) == 0);
assert(strcmp(res512, s512->str) == 0);
cstr_free(s256, true);
cstr_free(s512, true);
}
static void test_rijndael(void)
{
rijndael_ctx ctx;
static const char *key = "blockchain blockchain blockchain";
static uint8_t iv[] = { 222U, 173U, 190U, 239U, 222U, 173U, 190U, 239U,
222U, 173U, 190U, 239U, 222U, 173U, 190U, 239U };
static const char *res256ebc = "b1171a6e12500d4c07b56a43968cba1938c822358db242115a3c5eb5cf5ebc8d";
static const char *res256cbc = "403a8e3c31ebd2808ff83391fab1514ebf01928daa93039afeeed628db9d4903";
unsigned char md256[SHA256_DIGEST_LENGTH];
memset(md256, 0, sizeof(md256));
memcpy(md256, test_data, strlen(test_data));
aes_set_key(&ctx, (const uint8_t *)key, strlen(key) * 8, 1);
aes_ecb_encrypt(&ctx, md256, 32);
cstring *s256 = str2hex(md256, sizeof(md256));
assert(strcmp(res256ebc, s256->str) == 0);
cstr_free(s256, true);
memset(md256, 0, sizeof(md256));
memcpy(md256, test_data, strlen(test_data));
aes_cbc_encrypt(&ctx, iv, md256, 32);
s256 = str2hex(md256, sizeof(md256));
assert(strcmp(res256cbc, s256->str) == 0);
cstr_free(s256, true);
}
int main (int argc, char *argv[])
{
test_sha1();
test_sha256();
test_sha512();
test_ripemd160();
test_hmac();
test_rijndael();
return 0;
}
|
/*
* fgetpos.c - get the position in the file
*/
/* $Header$ */
#include <stdio.h>
int
fgetpos(FILE *stream, fpos_t *pos)
{
*pos = ftell(stream);
if (*pos == -1) return -1;
return 0;
}
|
#ifndef _MDrawProcedureBase
#define _MDrawProcedureBase
//
//-
// ==========================================================================
// Copyright (C) 1995 - 2006 Autodesk, Inc., and/or its licensors. All
// rights reserved.
//
// The coded instructions, statements, computer programs, and/or related
// material (collectively the "Data") in these files contain unpublished
// information proprietary to Autodesk, Inc. ("Autodesk") and/or its
// licensors, which is protected by U.S. and Canadian federal copyright law
// and by international treaties.
//
// The Data may not be disclosed or distributed to third parties or be
// copied or duplicated, in whole or in part, without the prior written
// consent of Autodesk.
//
// The copyright notices in the Software and this entire statement,
// including the above license grant, this restriction and the following
// disclaimer, must be included in all copies of the Software, in whole
// or in part, and all derivative works of the Software, unless such copies
// or derivative works are solely in the form of machine-executable object
// code generated by a source language processor.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
// AUTODESK DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED
// WARRANTIES INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF
// NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
// OR ARISING FROM A COURSE OF DEALING, USAGE, OR TRADE PRACTICE. IN NO
// EVENT WILL AUTODESK AND/OR ITS LICENSORS BE LIABLE FOR ANY LOST
// REVENUES, DATA, OR PROFITS, OR SPECIAL, DIRECT, INDIRECT, OR
// CONSEQUENTIAL DAMAGES, EVEN IF AUTODESK AND/OR ITS LICENSORS HAS
// BEEN ADVISED OF THE POSSIBILITY OR PROBABILITY OF SUCH DAMAGES.
// ==========================================================================
//+
//
// CLASS: MDrawProcedureBase
//
// *****************************************************************************
//
// CLASS DESCRIPTION (MDrawProcedureBase)
//
// This class provides an interface through which a plugin can implement a class to provide
// custom hardware drawing effects.
//
// The derived class needs to be registered with using <to be completed>
// Please refer to documentation of <> for more details.
//
// Each procedure has a user defined string name and can be enabled or disabled.
// There is also a logical "call location" which defines when within a rendering loop that
// the draw procedure will be called. Name, enabling and call location must be defined.
//
// Additionally, the procedure can define a desired sequence number. All draw procedures
// are sorted by sequence number. Procedures with lower sequence number will be
// invoked first. The number 0 is the lowest supported sequence number and is the default.
// When more than one procedure has a sequence number, the order of registration
// will determine the invocation order.
//
// All derived classes must over the execute() method. This is the method that
// will be called by the hardware renderer to which the procedure is attached.
// The call will only be made if the procedure is enabled.
//
// *****************************************************************************
#if defined __cplusplus
#ifdef _WIN32
#pragma warning(disable: 4522)
#endif // _WIN32
// INCLUDED HEADER FILES
// INCLUDES
#include <maya/MString.h>
// CLASS DECLARATION (MDrawProcedureBase)
/// Base user draw procedure class
class OPENMAYARENDER_EXPORT MDrawProcedureBase
{
public:
// constructor
///
MDrawProcedureBase(const MString &name);
// destructor
///
virtual ~MDrawProcedureBase();
// Method called to perform drawing effect. Derived classes must implement this.
///
virtual bool execute() = 0;
// Set the procedure to be enabled or not.
///
void setEnabled(bool value);
// Returns if the procedure is enabled.
///
bool enabled() const ;
// Set the name of the procedure
///
void setName( const MString &name );
// Get the name of the procedure
///
const MString &name() const;
protected :
// Protected default constructor
MDrawProcedureBase();
// Name of the procedure
MString fName;
// Enable / disable toggle
bool fEnabled;
private:
// No private members
};
#ifdef _WIN32
#pragma warning(default: 4522)
#endif // _WIN32
// *****************************************************************************
#endif /* __cplusplus */
#endif /* _MDrawProcedureBase */
|
/* rawfs.h - Raw Minix file system support. Author: Kees J. Bot
*
* off_t r_super(int *block_size);
* Initialize variables, returns the size of a valid Minix
* file system blocks, but zero on error.
*
* void r_stat(ino_t file, struct stat *stp);
* Return information about a file like stat(2) and
* remembers file for the next two calls.
*
* off_t r_vir2abs(off_t virblockno);
* Translate virtual block number in file to absolute
* disk block number. Returns 0 if the file contains
* a hole, or -1 if the block lies past the end of file.
*
* ino_t r_readdir(char *name);
* Return next directory entry or 0 if there are no more.
* Returns -1 and sets errno on error.
*
* ino_t r_lookup(ino_t cwd, const char *path);
* A utility function that translates a pathname to an
* inode number. It starts from directory "cwd" unless
* path starts with a '/', then from ROOT_INO.
* Returns 0 and sets errno on error.
*
* One function needs to be provided by the outside world:
*
* void readblock(off_t blockno, char *buf, int block_size);
* Read a block into the buffer. Outside world handles
* errors.
*/
#ifndef INC_RAWFS_H
#define INC_RAWFS_H
#define ROOT_INO ((ino_t) 1) /* Inode nr of root dir. */
extern off_t r_super(int *);
extern void r_stat(Ino_t file, struct stat *stp);
extern off_t r_vir2abs(off_t virblockno);
extern ino_t r_readdir(char *name);
extern ino_t r_lookup(Ino_t cwd, const char *path);
/*
* $PchId: rawfs.h,v 1.4 1996/04/19 08:16:36 philip Exp $
*/
#endif
|
#include<stdio.h>
void main()
{
printf("Hello World\n");
}
|
/***********************************************************************************
* This software is under the MIT License quoted below:
***********************************************************************************
*
* Copyright (c) 2010 Olivier Halligon
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
***********************************************************************************/
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreText/CoreText.h>
/////////////////////////////////////////////////////////////////////////////////////
#pragma mark - Text Alignment Convertion
/////////////////////////////////////////////////////////////////////////////////////
CTTextAlignment CTTextAlignmentFromUITextAlignment(UITextAlignment alignment);
CTLineBreakMode CTLineBreakModeFromUILineBreakMode(UILineBreakMode lineBreakMode);
/////////////////////////////////////////////////////////////////////////////////////
#pragma mark - Flipping Coordinates
/////////////////////////////////////////////////////////////////////////////////////
CGPoint CGPointFlipped(CGPoint point, CGRect bounds);
CGRect CGRectFlipped(CGRect rect, CGRect bounds);
/////////////////////////////////////////////////////////////////////////////////////
#pragma mark - NSRange / CFRange
/////////////////////////////////////////////////////////////////////////////////////
NSRange NSRangeFromCFRange(CFRange range);
/////////////////////////////////////////////////////////////////////////////////////
#pragma mark - CoreText CTLine/CTRun utils
/////////////////////////////////////////////////////////////////////////////////////
CGRect CTLineGetTypographicBoundsAsRect(CTLineRef line, CGPoint lineOrigin);
CGRect CTRunGetTypographicBoundsAsRect(CTRunRef run, CTLineRef line, CGPoint lineOrigin);
BOOL CTLineContainsCharactersFromStringRange(CTLineRef line, NSRange range);
BOOL CTRunContainsCharactersFromStringRange(CTRunRef run, NSRange range);
|
#ifndef SD_DISKIO_H_
#define SD_DISKIO_H_
#define SD_SECTOR_SIZE 512
//*****************************************************************************
// Disk Info Structure definition
//*****************************************************************************
typedef struct
{
unsigned char ucCardType;
unsigned int ulVersion;
unsigned int ulCapClass;
unsigned int ulNofBlock;
unsigned int ulBlockSize;
DSTATUS bStatus;
unsigned short usRCA;
}DiskInfo_t;
extern DiskInfo_t sd_disk_info;
DSTATUS sd_disk_init (void);
DSTATUS sd_disk_status (void);
bool sd_disk_ready (void);
DRESULT sd_disk_read (BYTE* pBuffer, DWORD ulSectorNumber, UINT bSectorCount);
DRESULT sd_disk_write (const BYTE* pBuffer, DWORD ulSectorNumber, UINT bSectorCount);
#endif /* SD_DISKIO_H_ */
|
//
// HelloWorldLayer.h
// Cocos2dTest
//
// Created by Student on 1/31/14.
// Copyright Xin ZHANG 2014. All rights reserved.
//
#import <GameKit/GameKit.h>
// When you import this file, you import all the cocos2d classes
#import "cocos2d.h"
// MenuLayer
//@interface MenuLayer : CCLayer <GKAchievementViewControllerDelegate, GKLeaderboardViewControllerDelegate>
@interface QXMenuLayer : CCLayer
{
CCSprite *layerBack;
CCLayer *layer1;
CCLayer *layer2;
CCSprite *airplane;
CCSprite *airplane2;
CCSprite *airplane3;
double rotateAngel;
double specialAngle;
}
// returns a CCScene that contains the HelloWorldLayer as the only child
+(CCScene *) scene;
@end
|
#include <stdio.h>
int main()
{
int cc;
int n1=0, n2=0, aux;
do
{
for(cc=0;cc<=n2;cc++)
{
printf("*");
}
printf("\n");
aux=n2+n1;
n1=n2;
n2=aux;
}while(n2<=10);
return 0;
} |
#include <stdlib.h>
#include <stdio.h>
#include "stack.h"
typedef struct {
node_t node;
int data;
} data_node_t;
data_node_t * alloc_node(int data) {
data_node_t * node = calloc(1, sizeof(data_node_t));
node->data = data;
return node;
}
int main() {
const int elements = 5;
int index, errors = 0;
volatile node_t * empty_stack;
ipa_stack_t * stack = new_stack();
for (index = 0; index < elements; index++) {
push(stack, (node_t *) alloc_node(index));
}
for (index = elements - 1; index >= 0; index--) {
data_node_t * popped = (data_node_t *) pop(stack);
if (popped == NULL) {
errors++;
fprintf(stderr, "Stack returned null for index %d\n", index);
} else if (popped->data != index) {
errors++;
fprintf(stderr, "Invalid item found in stack. Expected %d got %d", index, popped->data);
}
}
if ((empty_stack = pop(stack)) != NULL) {
errors++;
fprintf(stderr, "Non-null return from empty stack (%p)\n", empty_stack);
}
if (errors == 0) {
printf("Stack test past successfully\n");
}
exit(errors == 0 ? 0 : -1);
}
|
#pragma once
#include <pebble.h>
typedef struct {
uint8_t index;
char title[24];
char subtitle[32];
} PlexClient;
void plex_init(void);
void plex_deinit(void);
void plex_in_received_handler(DictionaryIterator *iter);
void plex_reload_data_and_mark_dirty();
void plex_request(uint8_t request);
char* plex_get_error();
uint8_t plex_clients_count();
PlexClient* plex_client_get(uint8_t index);
PlexClient* plex_client_get_current();
uint8_t plex_client_get_current_index();
void plex_client_set_current(uint8_t index);
|
/*
For more information, please see: http://software.sci.utah.edu
The MIT License
Copyright (c) 2015 Scientific Computing and Imaging Institute,
University of Utah.
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 CORE_DATABASEMANAGER_DATABASEMANAGER_H
#define CORE_DATABASEMANAGER_DATABASEMANAGER_H
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
# pragma once
#endif
#include <map>
#include <boost/filesystem.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/any.hpp>
#include <boost/noncopyable.hpp>
#include <Core/DatabaseManager/share.h>
namespace SCIRun
{
namespace Core
{
namespace Database
{
typedef std::vector< std::map< std::string, boost::any > > ResultSet;
typedef boost::shared_ptr<ResultSet> ResultSetHandle;
typedef boost::shared_ptr< class DatabaseManager > DatabaseManagerHandle;
class SCISHARE DatabaseManager : boost::noncopyable
{
public:
DatabaseManager();
~DatabaseManager();
public:
/// RUN_SQL_STATEMENT:
/// Execute the given SQL statement on the database. If the statement generates
/// any results, they will be put in the result set.
/// Returns true on success, otherwise false.
bool run_sql_statement( const std::string& sql_str, ResultSet& results, std::string& error );
/// RUN_SQL_STATEMENT:
/// Execute the given SQL statement on the database.
/// Returns true on success, otherwise false.
bool run_sql_statement( const std::string& sql_str, std::string& error );
/// RUN_SQL_SCRIPT:
/// Execute multiple SQL statements sequentially.
bool run_sql_script( const std::string& sql_str, std::string& error );
/// SAVE_DATABASE:
/// Save the database to disk
bool save_database( const boost::filesystem::path& database_file, std::string& error );
/// LOAD_DATABASE:
/// Load the database from disk
bool load_database( const boost::filesystem::path& database_file, std::string& error );
/// GET_LAST_INSERT_ROWID:
/// Return the row ID of last successful insert statement.
long long get_last_insert_rowid();
/// GET_COLUMN_METADATA:
/// Get metadata about a specific column of a specific database table.
/// Returns true if the table and column exist, otherwise false.
bool get_column_metadata( const std::string& table_name, const std::string& column_name,
char const** data_type = 0, char const** coll_seq = 0,
int* not_null = 0, int* primary_key = 0, int* auto_inc = 0 );
private:
boost::shared_ptr< class DatabaseManagerPrivate > private_;
public:
/// ESCAPEQUOTES:
/// Escape the quotes(') in the string so it can be used as text in a SQL statement.
static std::string EscapeQuotes( const std::string& str );
};
}
}
}
#endif
|
// This file was generated based on 'C:\ProgramData\Uno\Packages\Android\0.19.1\Android\android\content\$.uno'.
// WARNING: Changes might be lost if you edit this file directly.
#pragma once
#include <Android.android.os.Parcelable.h>
#include <Android.Base.Wrappers.IJWrapper.h>
#include <Android.java.lang.Object.h>
#include <jni.h>
#include <Uno.IDisposable.h>
namespace g{namespace Android{namespace android{namespace content{struct ComponentName;}}}}
namespace g{namespace Android{namespace android{namespace os{struct Parcel;}}}}
namespace g{namespace Android{namespace java{namespace lang{struct String;}}}}
namespace g{
namespace Android{
namespace android{
namespace content{
// public sealed extern class ComponentName :10538
// {
struct ComponentName_type : ::g::Android::java::lang::Object_type
{
::g::Android::android::os::Parcelable interface2;
};
ComponentName_type* ComponentName_typeof();
void ComponentName___Init2_fn();
void ComponentName__describeContents_fn(ComponentName* __this, int* __retval);
void ComponentName__describeContents_IMPL_3884_fn(bool* arg0_, jobject* arg1_, int* __retval);
void ComponentName__equals1_fn(ComponentName* __this, ::g::Android::java::lang::Object* arg0, bool* __retval);
void ComponentName__equals_IMPL_3881_fn(bool* arg0_, jobject* arg1_, uObject* arg2_, bool* __retval);
void ComponentName__hashCode1_fn(ComponentName* __this, int* __retval);
void ComponentName__hashCode_IMPL_3882_fn(bool* arg0_, jobject* arg1_, int* __retval);
void ComponentName__toString_fn(ComponentName* __this, ::g::Android::java::lang::String** __retval);
void ComponentName__toString_IMPL_3880_fn(bool* arg0_, jobject* arg1_, uObject** __retval);
void ComponentName__writeToParcel1_fn(ComponentName* __this, ::g::Android::android::os::Parcel* arg0, int* arg1);
void ComponentName__writeToParcel_IMPL_3885_fn(bool* arg0_, jobject* arg1_, uObject* arg2_, int* arg3_);
struct ComponentName : ::g::Android::java::lang::Object
{
static jclass _javaClass2_;
static jclass& _javaClass2() { return _javaClass2_; }
static jmethodID describeContents_3884_ID_;
static jmethodID& describeContents_3884_ID() { return describeContents_3884_ID_; }
static jmethodID equals_3881_ID_;
static jmethodID& equals_3881_ID() { return equals_3881_ID_; }
static jmethodID hashCode_3882_ID_;
static jmethodID& hashCode_3882_ID() { return hashCode_3882_ID_; }
static jmethodID toString_3880_ID_;
static jmethodID& toString_3880_ID() { return toString_3880_ID_; }
static jmethodID writeToParcel_3885_ID_;
static jmethodID& writeToParcel_3885_ID() { return writeToParcel_3885_ID_; }
int describeContents();
void writeToParcel1(::g::Android::android::os::Parcel* arg0, int arg1);
static void _Init2();
static int describeContents_IMPL_3884(bool arg0_, jobject arg1_);
static bool equals_IMPL_3881(bool arg0_, jobject arg1_, uObject* arg2_);
static int hashCode_IMPL_3882(bool arg0_, jobject arg1_);
static uObject* toString_IMPL_3880(bool arg0_, jobject arg1_);
static void writeToParcel_IMPL_3885(bool arg0_, jobject arg1_, uObject* arg2_, int arg3_);
};
// }
}}}} // ::g::Android::android::content
|
/*
* Copyright (C) 2008-2019 TrinityCore <https://www.trinitycore.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, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TRANSACTION_H
#define _TRANSACTION_H
#include "Define.h"
#include "DatabaseEnvFwd.h"
#include "SQLOperation.h"
#include "StringFormat.h"
#include <mutex>
#include <vector>
/*! Transactions, high level class. */
class TC_DATABASE_API Transaction
{
friend class TransactionTask;
friend class MySQLConnection;
template <typename T>
friend class DatabaseWorkerPool;
public:
Transaction() : _cleanedUp(false) { }
~Transaction() { Cleanup(); }
void Append(PreparedStatement* statement);
void Append(const char* sql);
template<typename Format, typename... Args>
void PAppend(Format&& sql, Args&&... args)
{
Append(Trinity::StringFormat(std::forward<Format>(sql), std::forward<Args>(args)...).c_str());
}
std::size_t GetSize() const { return m_queries.size(); }
protected:
void Cleanup();
std::vector<SQLElementData> m_queries;
private:
bool _cleanedUp;
};
/*! Low level class*/
class TC_DATABASE_API TransactionTask : public SQLOperation
{
template <class T> friend class DatabaseWorkerPool;
friend class DatabaseWorker;
public:
TransactionTask(SQLTransaction trans) : m_trans(trans) { }
~TransactionTask() { }
protected:
bool Execute() override;
SQLTransaction m_trans;
static std::mutex _deadlockLock;
};
#endif
|
/***************************************************************************
file : OsgDome.h
created : Mon Aug 21 18:24:02 CEST 2012
copyright : (C) 2012 by Xavier Bertaux
email : bertauxx@yahoo.fr
version : $Id$
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef _OSGSKYDOME_H
#define _OSGSKYDOME_H
#include <osg/ref_ptr>
#include <osg/Array>
#include <osg/MatrixTransform>
#include "OsgUtil/OsgReferenced.h"
#include "OsgUtil/OsgMath.h"
namespace osg
{
class DrawElementsUShort;
}
class SDSkyDome
{
osg::ref_ptr<osg::MatrixTransform> dome_transform;
double asl;
osg::ref_ptr<osg::Vec3Array> dome_vl;
osg::ref_ptr<osg::Vec3Array> dome_cl;
public:
// Constructor
SDSkyDome( void );
// Destructor
~SDSkyDome( void );
osg::Node *build( double hscale = 80000.0, double vscale = 80000.0 );
bool repaint( const osg::Vec3f &sky_color, const osg::Vec3f &fog_color,
double sun_angle, double vis );
bool reposition( const osg::Vec3f& p, double spin );
private:
void makeDome(int rings, int bands, osg::DrawElementsUShort& elements);
};
#endif // OSGSKYDOME_H
|
#include <RealConv.d>
#include <__oo2c.h>
#include <setjmp.h>
void RealConv__ScanReal(OOC_CHAR8 inputCh, OOC_INT8 *chClass, ConvTypes__ScanState *nextState) {
register OOC_INT32 i0;
i0 = inputCh;
Real0__ScanReal(i0, (void*)(OOC_INT32)chClass, (void*)(OOC_INT32)nextState);
return;
;
}
OOC_INT8 RealConv__FormatReal(const OOC_CHAR8 str__ref[], OOC_LEN str_0d) {
register OOC_INT32 i0;
OOC_ALLOCATE_VPAR(str,OOC_CHAR8 ,str_0d)
OOC_INITIALIZE_VPAR(str__ref,str,OOC_CHAR8 ,str_0d)
i0 = Real0__FormatReal((void*)(OOC_INT32)str, str_0d, 38, (OOC_CHAR8*)"340282347", 10);
return i0;
;
}
OOC_REAL32 RealConv__ValueReal(const OOC_CHAR8 str__ref[], OOC_LEN str_0d) {
register OOC_INT32 i0,i1;
register OOC_REAL32 f0;
OOC_ALLOCATE_VPAR(str,OOC_CHAR8 ,str_0d)
OOC_REAL32 value;
OOC_INITIALIZE_VPAR(str__ref,str,OOC_CHAR8 ,str_0d)
i0 = *(OOC_UINT8*)((OOC_INT32)str+(_check_index(0, str_0d, OOC_UINT32, 2407)));
i0 = CharClass__IsWhiteSpace(i0);
if (i0) goto l3;
i0=0;
goto l9;
l3:
i0=0;
l4_loop:
i0 = i0+1;
i1 = *(OOC_UINT8*)((OOC_INT32)str+(_check_index(i0, str_0d, OOC_UINT32, 2407)));
i1 = CharClass__IsWhiteSpace(i1);
if (i1) goto l4_loop;
l9:
i0 = sscanf(((OOC_INT32)str+(_check_index(i0, str_0d, OOC_UINT32, 2518))), (OOC_CHAR8*)"%f", (OOC_INT32)&value);
i0 = i0==1;
if (i0) goto l12;
return 0.0000000000000000f;
goto l13;
l12:
f0 = value;
return f0;
l13:
_failed_function(2215); return 0;
;
}
OOC_INT16 RealConv__LengthFloatReal(OOC_REAL32 real, OOC_INT16 sigFigs) {
_assert(0u, 127, 2859);
_failed_function(2763);
;
}
OOC_INT16 RealConv__LengthEngReal(OOC_REAL32 real, OOC_INT16 sigFigs) {
_assert(0u, 127, 3012);
_failed_function(2918);
;
}
OOC_INT16 RealConv__LengthFixedReal(OOC_REAL32 real, OOC_INT16 place) {
_assert(0u, 127, 3163);
_failed_function(3069);
;
}
void OOC_RealConv_init(void) {
return;
;
}
void OOC_RealConv_destroy(void) {
}
/* --- */
|
/* Single-precision log function.
Copyright (c) 2017 ARM Ltd. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the company may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY ARM LTD ``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 ARM LTD 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 "fdlibm.h"
#if !__OBSOLETE_MATH
#include <math.h>
#include <stdint.h>
#include "math_config.h"
/*
LOGF_TABLE_BITS = 4
LOGF_POLY_ORDER = 4
ULP error: 0.818 (nearest rounding.)
Relative error: 1.957 * 2^-26 (before rounding.)
*/
#define T __logf_data.tab
#define A __logf_data.poly
#define Ln2 __logf_data.ln2
#define N (1 << LOGF_TABLE_BITS)
#define OFF 0x3f330000
float
logf (float x)
{
/* double_t for better performance on targets with FLT_EVAL_METHOD==2. */
double_t z, r, r2, y, y0, invc, logc;
uint32_t ix, iz, tmp;
int k, i;
ix = asuint (x);
#if WANT_ROUNDING
/* Fix sign of zero with downward rounding when x==1. */
if (__builtin_expect (ix == 0x3f800000, 0))
return 0;
#endif
if (__builtin_expect (ix - 0x00800000 >= 0x7f800000 - 0x00800000, 0))
{
/* x < 0x1p-126 or inf or nan. */
if (ix * 2 == 0)
return __math_divzerof (1);
if (ix == 0x7f800000) /* log(inf) == inf. */
return x;
if ((ix & 0x80000000) || ix * 2 >= 0xff000000)
return __math_invalidf (x);
/* x is subnormal, normalize it. */
ix = asuint (x * 0x1p23f);
ix -= 23 << 23;
}
/* x = 2^k z; where z is in range [OFF,2*OFF] and exact.
The range is split into N subintervals.
The ith subinterval contains z and c is near its center. */
tmp = ix - OFF;
i = (tmp >> (23 - LOGF_TABLE_BITS)) % N;
k = (int32_t) tmp >> 23; /* arithmetic shift */
iz = ix - (tmp & 0x1ff << 23);
invc = T[i].invc;
logc = T[i].logc;
z = (double_t) asfloat (iz);
/* log(x) = log1p(z/c-1) + log(c) + k*Ln2 */
r = z * invc - 1;
y0 = logc + (double_t) k * Ln2;
/* Pipelined polynomial evaluation to approximate log1p(r). */
r2 = r * r;
y = A[1] * r + A[2];
y = A[0] * r2 + y;
y = y * r2 + (y0 + r);
return (float) y;
}
#endif /* !__OBSOLETE_MATH */
|
#ifndef STDDEF_H
#define STDDEF_H
#include <commonlib/helpers.h>
typedef long ptrdiff_t;
#ifndef __SIZE_TYPE__
#define __SIZE_TYPE__ unsigned long
#endif
typedef __SIZE_TYPE__ size_t;
/* There is a GCC macro for a size_t type, but not
* for a ssize_t type. Below construct tricks GCC
* into making __SIZE_TYPE__ signed.
*/
#define unsigned signed
typedef __SIZE_TYPE__ ssize_t;
#undef unsigned
typedef int wchar_t;
typedef unsigned int wint_t;
#define NULL ((void *)0)
#ifdef __PRE_RAM__
#define ROMSTAGE_CONST const
#else
#define ROMSTAGE_CONST
#endif
/* Work around non-writable data segment in execute-in-place romstage on x86. */
#if defined(__PRE_RAM__) && CONFIG_ARCH_X86
#define MAYBE_STATIC
#else
#define MAYBE_STATIC static
#endif
#endif /* STDDEF_H */
|
/* $Header: /cvsroot/lesstif/lesstif/test/Xm-2.0/container/test4.c,v 1.2 2001/12/19 20:38:41 dannybackx Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <X11/Intrinsic.h>
#include <Xm/Xm.h>
#include <Xm/Container.h>
#include <Xm/IconG.h>
#include "../../common/Test.h"
#ifndef LESSTIF_VERSION
#include <X11/Xmu/Editres.h>
#endif
void
check_geometry(Widget w)
{
static int result_index = 0;
static XtWidgetGeometry Expected[] = {
/* result test 0 */
{ CWWidth | CWHeight , 10, 10, 386, 94, 0,0,0 }, /* widget */
{ CWWidth | CWHeight | CWX | CWY, 6, 6, 374, 50, 0,0,0 }, /* Text */
{ CWWidth | CWHeight | CWX | CWY, 6, 56, 374, 32, 0,0,0 }, /* ListSW */
{ CWWidth | CWHeight | CWX | CWY, 359, 0, 15, 32, 0,0,0 }, /* VertScrollBar */
{ CWWidth | CWHeight | CWX | CWY, 0, 0, 359, 32, 0,0,0 }, /* List */
};
#if 0
PrintDetails2(w, NULL);
#else
if (result_index <= 0)
{
PrintDetails2(w, Expected);
fflush(stdout);
result_index ++;
}
#endif
}
static void doit(Widget w, XtPointer client, XtPointer call)
{
XmContainerSelectCallbackStruct *cbp = (XmContainerSelectCallbackStruct *)call;
char *txt = (char *)client;
int i;
if (cbp->selected_item_count == 0) {
fprintf(stderr, "Callback(%s) - no selection\n", txt);
} else {
fprintf(stderr, "Callback(%s) - %d items selected :\n", txt, cbp->selected_item_count);
for (i=0; i<cbp->selected_item_count; i++) {
fprintf(stderr, "\t%s\n", XtName(cbp->selected_items[i]));
}
}
}
int
main(int argc, char **argv)
{
Display *dpy;
Widget toplevel, c, widget, parent;
XtAppContext app;
Pixmap p;
Pixel fg, bg;
Arg al[5];
int ac;
XtSetLanguageProc(NULL, NULL, NULL);
toplevel = XtVaAppInitialize(&app, "Container", NULL, 0,
&argc, argv, NULL, NULL);
#ifndef LESSTIF_VERSION
XtAddEventHandler(toplevel, (EventMask)0, True,
(XtEventHandler)_XEditResCheckMessages, NULL);
#endif
ac = 0;
XtSetArg(al[ac], XmNlayoutType, XmOUTLINE); ac++;
c = XmCreateContainer(toplevel, "container", al, ac);
XtManageChild(c);
XtAddCallback(c, XmNconvertCallback, doit, XmNconvertCallback);
XtAddCallback(c, XmNdefaultActionCallback, doit, XmNdefaultActionCallback);
XtAddCallback(c, XmNdestinationCallback, doit, XmNdestinationCallback);
XtAddCallback(c, XmNoutlineChangedCallback, doit, XmNoutlineChangedCallback);
XtAddCallback(c, XmNselectionCallback, doit, XmNselectionCallback);
dpy = XtDisplay(toplevel);
fg = XBlackPixelOfScreen(DefaultScreenOfDisplay(dpy));
bg = XWhitePixelOfScreen(DefaultScreenOfDisplay(dpy));
p = XmGetPixmap(DefaultScreenOfDisplay(dpy),
"woman",
fg, bg);
ac = 0;
XtSetArg(al[ac], XmNsmallIconPixmap, p); ac++;
XtSetArg(al[ac], XmNoutlineState, XmEXPANDED); ac++;
parent = XmCreateIconGadget(c, "tree-1", al, ac);
XtManageChild(parent);
ac = 0;
XtSetArg(al[ac], XmNentryParent, parent); ac++;
widget = XmCreateIconGadget(c, "child-1", al, ac);
XtManageChild(widget);
ac = 0;
XtSetArg(al[ac], XmNentryParent, parent); ac++;
XtSetArg(al[ac], XmNoutlineState, XmEXPANDED); ac++;
widget = XmCreateIconGadget(c, "child-2", al, ac);
XtManageChild(widget);
/* An additional level */
parent = widget;
ac = 0;
XtSetArg(al[ac], XmNentryParent, parent); ac++;
widget = XmCreateIconGadget(c, "child-3", al, ac);
XtManageChild(widget);
ac = 0;
XtSetArg(al[ac], XmNentryParent, parent); ac++;
widget = XmCreateIconGadget(c, "child-4", al, ac);
XtManageChild(widget);
/* Second tree */
ac = 0;
XtSetArg(al[ac], XmNsmallIconPixmap, p); ac++;
XtSetArg(al[ac], XmNoutlineState, XmEXPANDED); ac++;
parent = XmCreateIconGadget(c, "tree-2", al, ac);
XtManageChild(parent);
ac = 0;
XtSetArg(al[ac], XmNentryParent, parent); ac++;
widget = XmCreateIconGadget(c, "child-5", al, ac);
XtManageChild(widget);
XtRealizeWidget(toplevel);
#if 0
check_geometry(toplevel);
#endif
LessTifTestMainLoop(toplevel);
exit(0);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.