hexsha stringlengths 40 40 | size int64 5 1.05M | ext stringclasses 588
values | lang stringclasses 305
values | max_stars_repo_path stringlengths 3 363 | max_stars_repo_name stringlengths 5 118 | max_stars_repo_head_hexsha stringlengths 40 40 | max_stars_repo_licenses listlengths 1 10 | max_stars_count float64 1 191k ⌀ | max_stars_repo_stars_event_min_datetime stringdate 2015-01-01 00:00:35 2022-03-31 23:43:49 ⌀ | max_stars_repo_stars_event_max_datetime stringdate 2015-01-01 12:37:38 2022-03-31 23:59:52 ⌀ | max_issues_repo_path stringlengths 3 363 | max_issues_repo_name stringlengths 5 118 | max_issues_repo_head_hexsha stringlengths 40 40 | max_issues_repo_licenses listlengths 1 10 | max_issues_count float64 1 134k ⌀ | max_issues_repo_issues_event_min_datetime stringlengths 24 24 ⌀ | max_issues_repo_issues_event_max_datetime stringlengths 24 24 ⌀ | max_forks_repo_path stringlengths 3 363 | max_forks_repo_name stringlengths 5 135 | max_forks_repo_head_hexsha stringlengths 40 40 | max_forks_repo_licenses listlengths 1 10 | max_forks_count float64 1 105k ⌀ | max_forks_repo_forks_event_min_datetime stringdate 2015-01-01 00:01:02 2022-03-31 23:27:27 ⌀ | max_forks_repo_forks_event_max_datetime stringdate 2015-01-03 08:55:07 2022-03-31 23:59:24 ⌀ | content stringlengths 5 1.05M | avg_line_length float64 1.13 1.04M | max_line_length int64 1 1.05M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b1f51794d7be40b5dd438495044dca00dd6c3b26 | 2,582 | c | C | ubmark-nosyscalls/ubmark/ubmark-masked-filter.c | kevinyuan/pydgin | 9e5dea526a17b23929b2a1d24598154b42323073 | [
"BSD-3-Clause"
] | 159 | 2015-02-12T03:28:25.000Z | 2022-02-24T22:40:35.000Z | ubmark-nosyscalls/ubmark/ubmark-masked-filter.c | kevinyuan/pydgin | 9e5dea526a17b23929b2a1d24598154b42323073 | [
"BSD-3-Clause"
] | 21 | 2015-01-31T23:47:26.000Z | 2020-12-21T12:41:08.000Z | ubmark-nosyscalls/ubmark/ubmark-masked-filter.c | kevinyuan/pydgin | 9e5dea526a17b23929b2a1d24598154b42323073 | [
"BSD-3-Clause"
] | 40 | 2015-01-28T21:31:30.000Z | 2022-01-25T12:50:23.000Z | //========================================================================
// ubmark-masked-filter
//========================================================================
#include "ubmark.h"
#include "ubmark-masked-filter.dat"
#include <stdlib.h>
//------------------------------------------------------------------------
// global coeffient values
//------------------------------------------------------------------------
uint g_coeff[] = { 8, 6 };
//------------------------------------------------------------------------
// masked_filter_scalar
//------------------------------------------------------------------------
__attribute__ ((noinline))
void masked_filter_scalar( uint dest[], uint mask[], uint src[],
int nrows, int ncols, uint coeff[] )
{
uint coeff0 = coeff[0];
uint coeff1 = coeff[1];
uint norm = coeff[0] + 4*coeff[1];
int ridx;
int cidx;
for ( ridx = 1; ridx < nrows-1; ridx++ ) {
for ( cidx = 1; cidx < ncols-1; cidx++ ) {
if ( mask[ ridx*ncols + cidx ] != 0 ) {
uint out0 = ( src[ (ridx-1)*ncols + cidx ] * coeff1 );
uint out1 = ( src[ ridx*ncols + (cidx-1) ] * coeff1 );
uint out2 = ( src[ ridx*ncols + cidx ] * coeff0 );
uint out3 = ( src[ ridx*ncols + (cidx+1) ] * coeff1 );
uint out4 = ( src[ (ridx+1)*ncols + cidx ] * coeff1 );
uint out = out0 + out1 + out2 + out3 + out4;
dest[ ridx*ncols + cidx ] = (byte)(out/norm);
}
else
dest[ ridx*ncols + cidx ] = src[ ridx*ncols + cidx ];
}
}
}
//------------------------------------------------------------------------
// verify_results
//------------------------------------------------------------------------
void verify_results( uint dest[], uint ref[], int size )
{
int temp = 0;
int i;
for ( i = 0; i < size*size; i++ ) {
if ( !( dest[i] == ref[i] ) ) {
test_fail( temp );
}
}
test_pass( temp );
}
//------------------------------------------------------------------------
// Test harness
//------------------------------------------------------------------------
int main( int argc, char* argv[] )
{
int iterations = 1;
if (argc > 1)
iterations = atoi( argv[1] );
int size = 10;
uint dest[size*size];
int i;
for ( i = 0; i < size*size; i++ )
dest[i] = 0;
int temp = 0;
for ( i = 0; i < iterations; i++ ) {
test_stats_on( temp );
masked_filter_scalar( dest, mask, src, size, size, g_coeff );
test_stats_off( temp );
}
verify_results( dest, ref, size );
return 0;
}
| 28.373626 | 74 | 0.378389 |
0e7d258e678c3197e6bf9616e741c923014622e6 | 2,500 | c | C | 2020-2021/S3T_TP_03_PROCESSUS-2-PROG/Demonstrations_a_etudier/p_fork_wait_exit.c | 2019-2020-IUT/M311-Principes-des-systemes-d-exploitation | 3ca738c779c4c65f8316fda6a1ecaa3db76e0f15 | [
"CC-BY-4.0"
] | null | null | null | 2020-2021/S3T_TP_03_PROCESSUS-2-PROG/Demonstrations_a_etudier/p_fork_wait_exit.c | 2019-2020-IUT/M311-Principes-des-systemes-d-exploitation | 3ca738c779c4c65f8316fda6a1ecaa3db76e0f15 | [
"CC-BY-4.0"
] | null | null | null | 2020-2021/S3T_TP_03_PROCESSUS-2-PROG/Demonstrations_a_etudier/p_fork_wait_exit.c | 2019-2020-IUT/M311-Principes-des-systemes-d-exploitation | 3ca738c779c4c65f8316fda6a1ecaa3db76e0f15 | [
"CC-BY-4.0"
] | null | null | null | /**
* @ Author: JunkJumper
* @ Link: https://github.com/JunkJumper
* @ Copyright: Creative Common 4.0 (CC BY 4.0)
* @ Create Time: 01-10-2020 10:24:44
* @ Modified by: JunkJumper
* @ Modified time: 01-10-2020 10:52:49
* @ Description:
*/
/*******************************************************/ /* */
/* p_fork_wait_exit : Ce programme illustre le */
/* mecanisme de duplication de processus */
/* de LINUX. */
/* Le processus pere attend le fils. */
/* Le processus fils dort quelques secondes puis ... */
/* Le processus fils affiche un message puis retourne */
/* un code de retour pris dans argv[1]. */
/* Le pere affiche "Operation reussie" si le fils */
/* s'est bien termin�, et "Echec d'operation" sinon. */
/* */
/* Convention : "bien termin�" == (code de retour == 0)*/
/* */
/* Technique : Utiliser wait (adresse) et WEXITSTATUS */
/* */
/*******************************************************/
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int main(int argc, char *argv[])
{
/**********************/
/* PARTIE A COMPLETER */
/**********************/
int infosRetour;
int res = fork();
int max = atoi(argv[1]);
if (res < 0)
{
printf("ERREUR FORK\n");
}
else
{
if (res == 0)
{ /************************** FILS ***********************/
printf("Je suis le fils :\n");
printf("pid : %d\n", getpid());
printf("ppid : %d\n", getppid());
printf("Hush now quiet now It's time to go to bed for 3 seconds...\n");
sleep(3);
printf("I know this one ! :D");
printf("\n\n");
exit(max);
}
else
{ /************************** PERE ***********************/
wait(&infosRetour);
printf("Je suis le père :\n");
printf("pid : %d\n", getpid());
printf("ppid : %d\n", getppid());
printf("%d", WEXITSTATUS(infosRetour));
printf("\n\n");
}
}
return 0;
} | 32.894737 | 116 | 0.3924 |
8a423662c3fd81d821865347939b733a21b6755d | 14,373 | h | C | thirdparty/physx/physx/include/PxArticulationJoint.h | Houkime/echo | d115ca55faf3a140bea04feffeb2efdedb0e7f82 | [
"MIT"
] | 675 | 2019-02-07T01:23:19.000Z | 2022-03-28T05:45:10.000Z | Raybyte/Submodules/PhysX/Include/PhysX/PxArticulationJoint.h | EddeDev/RaybyteEngine | bd1756246966c43c6b52ee8804aa9b5ce6a931b9 | [
"MIT"
] | 843 | 2019-01-25T01:06:46.000Z | 2022-03-16T11:15:53.000Z | Raybyte/Submodules/PhysX/Include/PhysX/PxArticulationJoint.h | EddeDev/RaybyteEngine | bd1756246966c43c6b52ee8804aa9b5ce6a931b9 | [
"MIT"
] | 83 | 2019-02-20T06:18:46.000Z | 2022-03-20T09:36:09.000Z | //
// 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 NVIDIA 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 ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_PHYSICS_NX_ARTICULATION_JOINT
#define PX_PHYSICS_NX_ARTICULATION_JOINT
/** \addtogroup physics
@{ */
#include "PxPhysXConfig.h"
#include "common/PxBase.h"
#if !PX_DOXYGEN
namespace physx
{
#endif
class PxArticulationJointImpl;
/**
\brief The type of joint drive to use for the articulation joint.
Two drive models are currently supported. in the TARGET model, the drive spring displacement will be determined
as the rotation vector from the relative quaternion beetween child and parent, and the target quaternion.
In the ERROR model, the drive spring displacement will be taken directly from the imaginary part of the relative
quaternion. This drive model requires more computation on the part of the application, but allows driving the joint
with a spring displacement that is more than a complete rotation.
@see PxArticulationJoint
*/
struct PxArticulationJointDriveType
{
enum Enum
{
eTARGET = 0, // use the quaternion as the drive target
eERROR = 1 // use the vector part of the quaternion as the drive error.
};
};
struct PxArticulationAxis
{
enum Enum
{
eTWIST = 0,
eSWING1 = 1,
eSWING2 = 2,
eX = 3,
eY = 4,
eZ = 5,
eCOUNT = 6
};
};
PX_FLAGS_OPERATORS(PxArticulationAxis::Enum, PxU8)
struct PxArticulationMotion
{
enum Enum
{
eLOCKED = 0,
eLIMITED = 1,
eFREE = 2
};
};
typedef PxFlags<PxArticulationMotion::Enum, PxU8> PxArticulationMotions;
PX_FLAGS_OPERATORS(PxArticulationMotion::Enum, PxU8)
struct PxArticulationJointType
{
enum Enum
{
ePRISMATIC = 0,
eREVOLUTE = 1,
eSPHERICAL = 2,
eFIX = 3,
eUNDEFINED = 4
};
};
class PxArticulationJointBase : public PxBase
{
public:
/**
\brief get the parent articulation link to which this articulation joint belongs
\return the articulation link to which this joint belongs
*/
virtual PxArticulationLink& getParentArticulationLink() const = 0;
/**
\brief set the joint pose in the parent frame
\param[in] pose the joint pose in the parent frame
<b>Default:</b> the identity matrix
@see getParentPose()
*/
virtual void setParentPose(const PxTransform& pose) = 0;
/**
\brief get the joint pose in the parent frame
\return the joint pose in the parent frame
@see setParentPose()
*/
virtual PxTransform getParentPose() const = 0;
/**
\brief get the child articulation link to which this articulation joint belongs
\return the articulation link to which this joint belongs
*/
virtual PxArticulationLink& getChildArticulationLink() const = 0;
/**
\brief set the joint pose in the child frame
\param[in] pose the joint pose in the child frame
<b>Default:</b> the identity matrix
@see getChildPose()
*/
virtual void setChildPose(const PxTransform& pose) = 0;
/**
\brief get the joint pose in the child frame
\return the joint pose in the child frame
@see setChildPose()
*/
virtual PxTransform getChildPose() const = 0;
virtual PxArticulationJointImpl* getImpl() = 0;
virtual const PxArticulationJointImpl* getImpl() const = 0;
virtual ~PxArticulationJointBase() {}
private:
protected:
PX_INLINE PxArticulationJointBase(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags) {}
PX_INLINE PxArticulationJointBase(PxBaseFlags baseFlags) : PxBase(baseFlags) {}
virtual bool isKindOf(const char* name) const { return !::strcmp("PxArticulationJointBase", name) || PxBase::isKindOf(name); }
};
/**
\brief a joint between two links in an articulation.
The joint model is very similar to a PxSphericalJoint with swing and twist limits,
and an implicit drive model.
@see PxArticulation PxArticulationLink
*/
class PxArticulationJoint : public PxArticulationJointBase
{
public:
/**
\brief set the target drive
This is the target position for the joint drive, measured in the parent constraint frame.
\param[in] orientation the target orientation for the joint
<b>Range:</b> a unit quaternion
<b>Default:</b> the identity quaternion
@see getTargetOrientation()
*/
virtual void setTargetOrientation(const PxQuat& orientation) = 0;
/**
\brief get the target drive position
\return the joint drive target position
@see setTargetOrientation()
*/
virtual PxQuat getTargetOrientation() const = 0;
/**
\brief set the target drive velocity
This is the target velocity for the joint drive, measured in the parent constraint frame
\param[in] velocity the target velocity for the joint
<b>Default:</b> the zero vector
@see getTargetVelocity()
*/
virtual void setTargetVelocity(const PxVec3& velocity) = 0;
/**
\brief get the target drive velocity
\return the target velocity for the joint
@see setTargetVelocity()
*/
virtual PxVec3 getTargetVelocity() const = 0;
/**
\brief set the drive type
\param[in] driveType the drive type for the joint
<b>Default:</b> PxArticulationJointDriveType::eTARGET
@see getDriveType()
*/
virtual void setDriveType(PxArticulationJointDriveType::Enum driveType) = 0;
/**
\brief get the drive type
\return the drive type
@see setDriveType()
*/
virtual PxArticulationJointDriveType::Enum
getDriveType() const = 0;
/**
\brief set the drive strength of the joint acceleration spring.
The acceleration generated by the spring drive is proportional to
this value and the angle between the drive target position and the
current position.
\param[in] spring the spring strength of the joint
<b>Range:</b> [0, PX_MAX_F32)<br>
<b>Default:</b> 0.0
@see getStiffness()
*/
virtual void setStiffness(PxReal spring) = 0;
/**
\brief get the drive strength of the joint acceleration spring
\return the spring strength of the joint
@see setStiffness()
*/
virtual PxReal getStiffness() const = 0;
/**
\brief set the damping of the joint acceleration spring
The acceleration generated by the spring drive is proportional to
this value and the difference between the angular velocity of the
joint and the target drive velocity.
\param[in] damping the damping of the joint drive
<b>Range:</b> [0, PX_MAX_F32)<br>
<b>Default:</b> 0.0
@see getDamping()
*/
virtual void setDamping(PxReal damping) = 0;
/**
\brief get the damping of the joint acceleration spring
@see setDamping()
*/
virtual PxReal getDamping() const = 0;
/**
\brief set the internal compliance
Compliance determines the extent to which the joint resists acceleration.
There are separate values for resistance to accelerations caused by external
forces such as gravity and contact forces, and internal forces generated from
other joints.
A low compliance means that forces have little effect, a compliance of 1 means
the joint does not resist such forces at all.
\param[in] compliance the compliance to internal forces
<b> Range: (0, 1]</b>
<b> Default:</b> 0.0
@see getInternalCompliance()
*/
virtual void setInternalCompliance(PxReal compliance) = 0;
/**
\brief get the internal compliance
\return the compliance to internal forces
@see setInternalCompliance()
*/
virtual PxReal getInternalCompliance() const = 0;
/**
\brief get the drive external compliance
Compliance determines the extent to which the joint resists acceleration.
There are separate values for resistance to accelerations caused by external
forces such as gravity and contact forces, and internal forces generated from
other joints.
A low compliance means that forces have little effect, a compliance of 1 means
the joint does not resist such forces at all.
\param[in] compliance the compliance to external forces
<b> Range: (0, 1]</b>
<b> Default:</b> 0.0
@see getExternalCompliance()
*/
virtual void setExternalCompliance(PxReal compliance) = 0;
/**
\brief get the drive external compliance
\return the compliance to external forces
@see setExternalCompliance()
*/
virtual PxReal getExternalCompliance() const = 0;
/**
\brief set the extents of the cone limit. The extents are measured in the frame
of the parent.
Note that very small or highly elliptical limit cones may result in jitter.
\param[in] zLimit the allowed extent of rotation around the z-axis
\param[in] yLimit the allowed extent of rotation around the y-axis
<b> Range:</b> ( (0, Pi), (0, Pi) )
<b> Default:</b> (Pi/4, Pi/4)
\note Please note the order of zLimit and yLimit.
*/
virtual void setSwingLimit(PxReal zLimit, PxReal yLimit) = 0;
/**
\brief get the extents for the swing limit cone
\param[out] zLimit the allowed extent of rotation around the z-axis
\param[out] yLimit the allowed extent of rotation around the y-axis
\note Please note the order of zLimit and yLimit.
@see setSwingLimit()
*/
virtual void getSwingLimit(PxReal& zLimit, PxReal& yLimit) const = 0;
/**
\brief set the tangential spring for the limit cone
<b> Range:</b> ([0, PX_MAX_F32), [0, PX_MAX_F32))
<b> Default:</b> (0.0, 0.0)
*/
virtual void setTangentialStiffness(PxReal spring) = 0;
/**
\brief get the tangential spring for the swing limit cone
\return the tangential spring
@see setTangentialStiffness()
*/
virtual PxReal getTangentialStiffness() const = 0;
/**
\brief set the tangential damping for the limit cone
<b> Range:</b> ([0, PX_MAX_F32), [0, PX_MAX_F32))
<b> Default:</b> (0.0, 0.0)
*/
virtual void setTangentialDamping(PxReal damping) = 0;
/**
\brief get the tangential damping for the swing limit cone
\return the tangential damping
@see setTangentialDamping()
*/
virtual PxReal getTangentialDamping() const = 0;
/**
\brief set the contact distance for the swing limit
The contact distance should be less than either limit angle.
<b> Range:</b> [0, Pi]
<b> Default:</b> 0.05 radians
@see getSwingLimitContactDistance()
*/
virtual void setSwingLimitContactDistance(PxReal contactDistance) = 0;
/**
\brief get the contact distance for the swing limit
\return the contact distance for the swing limit cone
@see setSwingLimitContactDistance()
*/
virtual PxReal getSwingLimitContactDistance() const = 0;
/**
\brief set the flag which enables the swing limit
\param[in] enabled whether the limit is enabled
<b>Default:</b> false
@see getSwingLimitEnabled()
*/
virtual void setSwingLimitEnabled(bool enabled) = 0;
/**
\brief get the flag which enables the swing limit
\return whether the swing limit is enabled
@see setSwingLimitEnabled()
*/
virtual bool getSwingLimitEnabled() const = 0;
/**
\brief set the bounds of the twistLimit
\param[in] lower the lower extent of the twist limit
\param[in] upper the upper extent of the twist limit
<b> Range: (-Pi, Pi)</b>
<b> Default:</b> (-Pi/4, Pi/4)
The lower limit value must be less than the upper limit if the limit is enabled
@see getTwistLimit()
*/
virtual void setTwistLimit(PxReal lower, PxReal upper) = 0;
/**
\brief get the bounds of the twistLimit
\param[out] lower the lower extent of the twist limit
\param[out] upper the upper extent of the twist limit
@see setTwistLimit()
*/
virtual void getTwistLimit(PxReal &lower, PxReal &upper) const = 0;
/**
\brief set the flag which enables the twist limit
\param[in] enabled whether the twist limit is enabled
<b>Default:</b> false
@see getTwistLimitEnabled()
*/
virtual void setTwistLimitEnabled(bool enabled) = 0;
/**
\brief get the twistLimitEnabled flag
\return whether the twist limit is enabled
@see setTwistLimitEnabled()
*/
virtual bool getTwistLimitEnabled() const = 0;
/**
\brief set the contact distance for the swing limit
The contact distance should be less than half the distance between the upper and lower limits.
<b> Range:</b> [0, Pi)
<b> Default:</b> 0.05 radians
@see getTwistLimitContactDistance()
*/
virtual void setTwistLimitContactDistance(PxReal contactDistance) = 0;
/**
\brief get the contact distance for the swing limit
\return the contact distance for the twist limit
@see setTwistLimitContactDistance()
*/
virtual PxReal getTwistLimitContactDistance() const = 0;
virtual const char* getConcreteTypeName() const { return "PxArticulationJoint"; }
protected:
PX_INLINE PxArticulationJoint(PxType concreteType, PxBaseFlags baseFlags) : PxArticulationJointBase(concreteType, baseFlags) {}
PX_INLINE PxArticulationJoint(PxBaseFlags baseFlags) : PxArticulationJointBase(baseFlags) {}
virtual ~PxArticulationJoint() {}
virtual bool isKindOf(const char* name) const { return !::strcmp("PxArticulationJoint", name) || PxArticulationJointBase::isKindOf(name); }
};
#if !PX_DOXYGEN
} // namespace physx
#endif
/** @} */
#endif
| 25.08377 | 144 | 0.732972 |
3df2f0f1fc5d3c0359d3bead3f475f98db9a2853 | 16,812 | c | C | src/Utility/ACE/xmgr5/regionwin.c | rustychris/schism | 3754530ef57b3a058906432b4a9fca4a670f395e | [
"Apache-2.0"
] | 42 | 2019-08-12T21:48:24.000Z | 2022-03-03T03:08:10.000Z | src/Utility/ACE/xmgr5/regionwin.c | rustychris/schism | 3754530ef57b3a058906432b4a9fca4a670f395e | [
"Apache-2.0"
] | 42 | 2019-08-19T21:57:12.000Z | 2022-03-03T17:42:01.000Z | src/Utility/ACE/xmgr5/regionwin.c | rustychris/schism | 3754530ef57b3a058906432b4a9fca4a670f395e | [
"Apache-2.0"
] | 51 | 2019-08-09T20:59:07.000Z | 2022-03-29T15:48:43.000Z | /* $Id: regionwin.c,v 1.1.1.1 2003/07/21 16:18:41 pturner Exp $
*
* define regions and operate on regions
*/
#include <stdio.h>
#include <math.h>
#include <Xm/Xm.h>
#include <Xm/BulletinB.h>
#include <Xm/DialogS.h>
#include <Xm/Frame.h>
#include <Xm/Label.h>
#include <Xm/PushB.h>
#include <Xm/RowColumn.h>
#include <Xm/Separator.h>
#include <Xm/Text.h>
#include "globals.h"
#include "motifinc.h"
static Widget but1[2];
static Widget but2[2];
static Widget but3[3];
static Widget region_frame;
static Widget region_panel;
extern int regiontype, regionlinkto; /* in xmgr.c */
static void do_eval_region(Widget w, XtPointer client_data, XtPointer call_data);
static void do_define_region(Widget w, XtPointer client_data, XtPointer call_data);
static void do_clear_region(Widget w, XtPointer client_data, XtPointer call_data);
static void do_extract_region(Widget w, XtPointer client_data, XtPointer call_data);
static void do_delete_region(Widget w, XtPointer client_data, XtPointer call_data);
static void do_extractsets_region(Widget w, XtPointer client_data, XtPointer call_data);
static void do_deletesets_region(Widget w, XtPointer client_data, XtPointer call_data);
/*
* Create the region Frame and Panel
*/
void create_region_frame(Widget w, XtPointer client_data, XtPointer call_data)
{
Widget wbut;
int x, y;
set_wait_cursor();
if (region_frame == NULL) {
XmGetPos(app_shell, 0, &x, &y);
region_frame = XmCreateDialogShell(app_shell, "Region ops", NULL, 0);
handle_close(region_frame);
XtVaSetValues(region_frame, XmNx, x, XmNy, y, NULL);
region_panel = XmCreateRowColumn(region_frame, "region_rc", NULL, 0);
wbut = XtVaCreateManagedWidget("Define region...", xmPushButtonWidgetClass, region_panel,
NULL);
XtAddCallback(wbut, XmNactivateCallback, (XtCallbackProc) create_define_frame, (XtPointer) NULL);
wbut = XtVaCreateManagedWidget("Evaluate region...", xmPushButtonWidgetClass, region_panel,
NULL);
XtAddCallback(wbut, XmNactivateCallback, (XtCallbackProc) create_evalregion_frame, (XtPointer) NULL);
wbut = XtVaCreateManagedWidget("Clear region...", xmPushButtonWidgetClass, region_panel,
NULL);
XtAddCallback(wbut, XmNactivateCallback, (XtCallbackProc) create_clear_frame, (XtPointer) NULL);
wbut = XtVaCreateManagedWidget("Extract points...", xmPushButtonWidgetClass, region_panel,
NULL);
XtAddCallback(wbut, XmNactivateCallback, (XtCallbackProc) create_extract_frame, (XtPointer) NULL);
wbut = XtVaCreateManagedWidget("Extract sets...", xmPushButtonWidgetClass, region_panel,
NULL);
XtAddCallback(wbut, XmNactivateCallback, (XtCallbackProc) create_extractsets_frame, (XtPointer) NULL);
wbut = XtVaCreateManagedWidget("Delete points...", xmPushButtonWidgetClass, region_panel,
NULL);
XtAddCallback(wbut, XmNactivateCallback, (XtCallbackProc) create_delete_frame, (XtPointer) NULL);
wbut = XtVaCreateManagedWidget("Kill sets...", xmPushButtonWidgetClass, region_panel,
NULL);
XtAddCallback(wbut, XmNactivateCallback, (XtCallbackProc) create_deletesets_frame, (XtPointer) NULL);
wbut = XtVaCreateManagedWidget("Area/perimeter...", xmPushButtonWidgetClass, region_panel,
NULL);
XtAddCallback(wbut, XmNactivateCallback, (XtCallbackProc) create_area_frame, (XtPointer) NULL);
wbut = XtVaCreateManagedWidget("Close", xmPushButtonWidgetClass, region_panel,
NULL);
XtAddCallback(wbut, XmNactivateCallback, (XtCallbackProc) destroy_dialog, region_frame);
XtManageChild(region_panel);
}
XtRaise(region_frame);
unset_wait_cursor();
} /* end create_region_panel */
static Widget *define_region_item;
static Widget *define_type_item;
static Widget *define_linkto_item;
static void do_define_region(Widget w, XtPointer client_data, XtPointer call_data)
{
int rtype = GetChoice(define_type_item);
nr = GetChoice(define_region_item);
regionlinkto = GetChoice(define_linkto_item);
define_region(nr, regionlinkto, rtype);
}
void create_define_frame(Widget w, XtPointer client_data, XtPointer call_data)
{
static Widget top, dialog;
int x, y;
Widget wbut, rc;
set_wait_cursor();
if (top == NULL) {
char *label2[2];
label2[0] = "Define";
label2[1] = "Close";
XmGetPos(app_shell, 0, &x, &y);
top = XmCreateDialogShell(app_shell, "Define region", NULL, 0);
handle_close(top);
XtVaSetValues(top, XmNx, x, XmNy, y, NULL);
dialog = XmCreateRowColumn(top, "dialog_rc", NULL, 0);
define_region_item = CreatePanelChoice(dialog,
"Define region:",
6,
"0", "1", "2", "3", "4",
NULL, 0);
define_type_item = CreatePanelChoice(dialog,
"Region type:",
7,
"Inside polygon",
"Outside polygon",
"Above line",
"Below line",
"Left of line",
"Right of line",
NULL, 0);
define_linkto_item = CreatePanelChoice(dialog,
"Link to graph(s):",
3,
"Current", "All",
NULL, 0);
XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, dialog, NULL);
CreateCommandButtons(dialog, 2, but2, label2);
XtAddCallback(but2[0], XmNactivateCallback, (XtCallbackProc) do_define_region, (XtPointer) NULL);
XtAddCallback(but2[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) top);
XtManageChild(dialog);
}
XtRaise(top);
unset_wait_cursor();
}
static Widget *clear_region_item;
static void do_clear_region(Widget w, XtPointer client_data, XtPointer call_data)
{
int i;
set_wait_cursor();
if (GetChoice(clear_region_item) == MAXREGION) {
for (i = 0; i < MAXREGION; i++) {
kill_region(i);
}
} else {
kill_region(GetChoice(clear_region_item));
}
unset_wait_cursor();
drawgraph();
}
void create_clear_frame(Widget w, XtPointer client_data, XtPointer call_data)
{
int x, y;
static Widget top, dialog;
Widget wbut, rc;
set_wait_cursor();
if (top == NULL) {
char *label1[2];
label1[0] = "Accept";
label1[1] = "Close";
XmGetPos(app_shell, 0, &x, &y);
top = XmCreateDialogShell(app_shell, "Clear region", NULL, 0);
handle_close(top);
XtVaSetValues(top, XmNx, x, XmNy, y, NULL);
dialog = XmCreateRowColumn(top, "dialog_rc", NULL, 0);
clear_region_item = CreatePanelChoice(dialog,
"Clear region:",
7,
"0", "1", "2", "3", "4", "All",
NULL, 0);
XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, dialog, NULL);
CreateCommandButtons(dialog, 2, but1, label1);
XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc) do_clear_region, (XtPointer) NULL);
XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) top);
XtManageChild(dialog);
}
XtRaise(top);
unset_wait_cursor();
}
static Widget *extract_region_item;
static Widget *extract_fromset_item;
static Widget *extract_set_item;
static Widget *extract_graph_item;
static void do_extract_region(Widget w, XtPointer client_data, XtPointer call_data)
{
int i, j, gno, fromset, setno, regno;
double *x, *y;
gno = GetChoice(extract_graph_item) - 1;
if (gno == -1) {
gno = cg;
}
fromset = (int) GetChoice(extract_fromset_item) - 1;
setno = (int) GetChoice(extract_set_item) - 1;
if (setno == -1) {
setno = nextset(gno);
if (setno == -1) {
errwin("No more sets in this graph");
return;
}
}
regno = (int) GetChoice(extract_region_item);
set_wait_cursor();
extract_region(gno, fromset, setno, regno);
unset_wait_cursor();
}
void create_extract_frame(Widget w, XtPointer client_data, XtPointer call_data)
{
int x, y;
static Widget top, dialog;
Widget wbut, rc;
set_wait_cursor();
if (top == NULL) {
char *label1[2];
label1[0] = "Accept";
label1[1] = "Close";
XmGetPos(app_shell, 0, &x, &y);
top = XmCreateDialogShell(app_shell, "Extract region", NULL, 0);
handle_close(top);
XtVaSetValues(top, XmNx, x, XmNy, y, NULL);
dialog = XmCreateRowColumn(top, "dialog_rc", NULL, 0);
extract_fromset_item = CreateSetChoice(dialog, "Extract points from set:", maxplot, 6);
extract_region_item = CreatePanelChoice(dialog,
"found in region:",
8,
"0", "1", "2", "3", "4", "Inside world", "Outside world",
NULL, 0);
extract_set_item = CreateSetChoice(dialog, "Load points in region to set:", maxplot, 4);
extract_graph_item = CreatePanelChoice(dialog,
"In graph:",
12,
"Current", "0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", NULL, 0);
XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, dialog, NULL);
CreateCommandButtons(dialog, 2, but1, label1);
XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc) do_extract_region, (XtPointer) NULL);
XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) top);
XtManageChild(dialog);
}
XtRaise(top);
unset_wait_cursor();
}
static Widget *delete_region_item;
static Widget *delete_graph_item;
static Widget *delete_set_item;
static void do_delete_region(Widget w, XtPointer client_data, XtPointer call_data)
{
int gno, regno, setno;
gno = GetChoice(delete_graph_item) - 1;
setno = GetChoice(delete_set_item) - 1;
regno = GetChoice(delete_region_item);
set_wait_cursor();
delete_region(gno, setno, regno);
unset_wait_cursor();
}
void create_delete_frame(Widget w, XtPointer client_data, XtPointer call_data)
{
int x, y;
static Widget top, dialog;
Widget wbut, rc;
set_wait_cursor();
if (top == NULL) {
char *label1[2];
label1[0] = "Accept";
label1[1] = "Close";
XmGetPos(app_shell, 0, &x, &y);
top = XmCreateDialogShell(app_shell, "Delete points in region", NULL, 0);
handle_close(top);
XtVaSetValues(top, XmNx, x, XmNy, y, NULL);
dialog = XmCreateRowColumn(top, "dialog_rc", NULL, 0);
delete_set_item = CreateSetChoice(dialog, "Delete points from set:", maxplot, 6);
delete_region_item = CreatePanelChoice(dialog,
"Found in region:",
8,
"0", "1", "2", "3", "4", "Inside world", "Outside world",
NULL, 0);
delete_graph_item = CreatePanelChoice(dialog,
"In graph:",
13,
"Current", "0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "All", NULL, 0);
XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, dialog, NULL);
CreateCommandButtons(dialog, 2, but1, label1);
XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc) do_delete_region, (XtPointer) NULL);
XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) top);
XtManageChild(dialog);
}
XtRaise(top);
unset_wait_cursor();
}
XmString astring, pstring;
Widget arealab, perimlab;
extern XmStringCharSet charset;
void create_area_frame(Widget w, XtPointer client_data, XtPointer call_data)
{
int x, y;
static Widget top, dialog;
Widget wbut, rc;
set_wait_cursor();
if (top == NULL) {
char *label3[3];
label3[0] = "Area";
label3[1] = "Perimeter";
label3[2] = "Close";
XmGetPos(app_shell, 0, &x, &y);
top = XmCreateDialogShell(app_shell, "Area/perimeter", NULL, 0);
handle_close(top);
XtVaSetValues(top, XmNx, x, XmNy, y, NULL);
dialog = XmCreateRowColumn(top, "dialog_rc", NULL, 0);
arealab = XtVaCreateManagedWidget("label Area", xmLabelWidgetClass, dialog,
XmNlabelString, astring = XmStringCreateLtoR("[ Area ]", charset),
NULL);
perimlab = XtVaCreateManagedWidget("label Perim", xmLabelWidgetClass, dialog,
XmNlabelString, pstring = XmStringCreateLtoR("[ Perim ]", charset),
NULL);
XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, dialog, NULL);
CreateCommandButtons(dialog, 3, but3, label3);
XtAddCallback(but3[0], XmNactivateCallback, (XtCallbackProc) do_select_area, (XtPointer) NULL);
XtAddCallback(but3[1], XmNactivateCallback, (XtCallbackProc) do_select_peri, (XtPointer) NULL);
XtAddCallback(but3[2], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) top);
XtManageChild(dialog);
}
XtRaise(top);
unset_wait_cursor();
}
static Widget *eval_region;
static Widget *eval_set_item;
static Widget eval_region_item;
static void do_eval_region(Widget w, XtPointer client_data, XtPointer call_data)
{
int regno, setno;
char buf[256];
regno = (int) GetChoice(eval_region);
setno = (int) GetChoice(eval_set_item);
strcpy(buf, (char *) xv_getstr(eval_region_item));
fixupstr(buf);
set_wait_cursor();
/* TODO add setno to parm list */
evaluate_region(regno, buf);
unset_wait_cursor();
}
void create_evalregion_frame(Widget w, XtPointer client_data, XtPointer call_data)
{
int x, y;
static Widget top, dialog;
Widget wbut, rc;
set_wait_cursor();
if (top == NULL) {
char *label1[2];
label1[0] = "Accept";
label1[1] = "Close";
XmGetPos(app_shell, 0, &x, &y);
top = XmCreateDialogShell(app_shell, "Evaluate region", NULL, 0);
handle_close(top);
XtVaSetValues(top, XmNx, x, XmNy, y, NULL);
dialog = XmCreateRowColumn(top, "dialog_rc", NULL, 0);
eval_set_item = CreateSetChoice(dialog, "Apply expression to all points in set:", maxplot, 6);
eval_region = CreatePanelChoice(dialog,
"found in region:",
8,
"0", "1", "2", "3", "4", "Inside world", "Outside world",
NULL, 0);
eval_region_item = CreateTextItem2(dialog, 20, "Expression:");
XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, dialog, NULL);
CreateCommandButtons(dialog, 2, but1, label1);
XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc) do_eval_region, (XtPointer) NULL);
XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) top);
XtManageChild(dialog);
}
XtRaise(top);
unset_wait_cursor();
}
static Widget *extractsets_region_item;
static Widget *extractsets_graph_item;
static void do_extractsets_region(Widget w, XtPointer client_data, XtPointer call_data)
{
int gno, setno, regno;
gno = (int) GetChoice(extractsets_graph_item);
regno = (int) GetChoice(extractsets_region_item);
set_wait_cursor();
extractsets_region(cg, gno, regno);
unset_wait_cursor();
drawgraph();
}
void create_extractsets_frame(Widget w, XtPointer client_data, XtPointer call_data)
{
int x, y;
static Widget top, dialog;
Widget wbut, rc;
set_wait_cursor();
if (top == NULL) {
char *label1[2];
label1[0] = "Accept";
label1[1] = "Close";
XmGetPos(app_shell, 0, &x, &y);
top = XmCreateDialogShell(app_shell, "Extract sets in region", NULL, 0);
handle_close(top);
XtVaSetValues(top, XmNx, x, XmNy, y, NULL);
dialog = XmCreateRowColumn(top, "dialog_rc", NULL, 0);
extractsets_region_item = CreatePanelChoice(dialog,
"Found in region:",
8,
"0", "1", "2", "3", "4", "Inside world", "Outside world",
NULL, 0);
extractsets_graph_item = CreateGraphChoice(dialog, "Load to graph:", maxgraph, 0);
XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, dialog, NULL);
CreateCommandButtons(dialog, 2, but1, label1);
XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc) do_extractsets_region, (XtPointer) NULL);
XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) top);
XtManageChild(dialog);
}
XtRaise(top);
unset_wait_cursor();
}
static Widget *deletesets_region_item;
static Widget *deletesets_graph_item;
static void do_deletesets_region(Widget w, XtPointer client_data, XtPointer call_data)
{
int regno = (int) GetChoice(deletesets_region_item);
set_wait_cursor();
deletesets_region(cg, regno);
unset_wait_cursor();
drawgraph();
}
void create_deletesets_frame(Widget w, XtPointer client_data, XtPointer call_data)
{
int x, y;
static Widget top, dialog;
Widget wbut, rc;
set_wait_cursor();
if (top == NULL) {
char *label1[2];
label1[0] = "Accept";
label1[1] = "Close";
XmGetPos(app_shell, 0, &x, &y);
top = XmCreateDialogShell(app_shell, "Delete sets in region", NULL, 0);
handle_close(top);
XtVaSetValues(top, XmNx, x, XmNy, y, NULL);
dialog = XmCreateRowColumn(top, "dialog_rc", NULL, 0);
deletesets_region_item = CreatePanelChoice(dialog,
"Delete sets in region:",
8,
"0", "1", "2", "3", "4", "Inside world", "Outside world",
NULL, 0);
XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, dialog, NULL);
CreateCommandButtons(dialog, 2, but1, label1);
XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc) do_deletesets_region, (XtPointer) NULL);
XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) top);
XtManageChild(dialog);
}
XtRaise(top);
unset_wait_cursor();
}
| 30.847706 | 103 | 0.697537 |
5c3277244f5755f55ef181a03632d93892a4fecb | 447 | h | C | emulator/src/lib/formats/vt_cas.h | rjw57/tiw-computer | 5ef1c79893165b8622d1114d81cd0cded58910f0 | [
"MIT"
] | 1 | 2022-01-15T21:38:38.000Z | 2022-01-15T21:38:38.000Z | emulator/src/lib/formats/vt_cas.h | rjw57/tiw-computer | 5ef1c79893165b8622d1114d81cd0cded58910f0 | [
"MIT"
] | null | null | null | emulator/src/lib/formats/vt_cas.h | rjw57/tiw-computer | 5ef1c79893165b8622d1114d81cd0cded58910f0 | [
"MIT"
] | null | null | null | // license:GPL-2.0+
// copyright-holders:Juergen Buchmueller
/*********************************************************************
vt_cas.h
Format code for VTech cassette files
*********************************************************************/
#ifndef VT_CAS_H
#define VT_CAS_H
#include "cassimg.h"
CASSETTE_FORMATLIST_EXTERN(vtech1_cassette_formats);
CASSETTE_FORMATLIST_EXTERN(vtech2_cassette_formats);
#endif /* VT_CAS_H */
| 22.35 | 70 | 0.532438 |
ceede9440c5e780b887836756be839d2e96af229 | 29,611 | h | C | c_include/osx/stdio.h | stuta/Luajit-Tcp-Server | d89228c170debca554c3bc71b200b1e62ccdeb9e | [
"BSD-3-Clause"
] | 24 | 2015-01-15T16:28:33.000Z | 2020-07-16T03:38:37.000Z | c_include/osx/stdio.h | stuta/Luajit-Tcp-Server | d89228c170debca554c3bc71b200b1e62ccdeb9e | [
"BSD-3-Clause"
] | null | null | null | c_include/osx/stdio.h | stuta/Luajit-Tcp-Server | d89228c170debca554c3bc71b200b1e62ccdeb9e | [
"BSD-3-Clause"
] | 9 | 2017-03-08T18:22:42.000Z | 2022-01-18T15:16:56.000Z | static const int __STDC__ = 1;
static const int __STDC_HOSTED__ = 1;
static const int __GNUC__ = 4;
static const int __GNUC_MINOR__ = 2;
static const int __GNUC_PATCHLEVEL__ = 1;
static const int __APPLE_CC__ = 5658;
static const int __llvm__ = 1;
static const int __SIZE_TYPE__ = long unsigned int;
static const int __PTRDIFF_TYPE__ = long int;
static const int __WCHAR_TYPE__ = int;
static const int __WINT_TYPE__ = int;
static const int __INTMAX_TYPE__ = long int;
static const int __UINTMAX_TYPE__ = long unsigned int;
static const int __GXX_ABI_VERSION = 1002;
static const int __SCHAR_MAX__ = 127;
static const int __SHRT_MAX__ = 32767;
static const int __INT_MAX__ = 2147483647;
static const long __LONG_MAX__ = 9223372036854775807L;
static const long long __LONG_LONG_MAX__ = 9223372036854775807LL;
static const int __WCHAR_MAX__ = 2147483647;
static const int __CHAR_BIT__ = 8;
static const long __INTMAX_MAX__ = 9223372036854775807L;
static const int __FLT_EVAL_METHOD__ = 0;
static const int __DEC_EVAL_METHOD__ = 2;
static const int __FLT_RADIX__ = 2;
static const int __FLT_MANT_DIG__ = 24;
static const int __FLT_DIG__ = 6;
static const int __FLT_MIN_EXP__ = (-125);
static const int __FLT_MIN_10_EXP__ = (-37);
static const int __FLT_MAX_EXP__ = 128;
static const int __FLT_MAX_10_EXP__ = 38;
static const double __FLT_MAX__ = 3.40282347e+38F;
static const double __FLT_MIN__ = 1.17549435e-38F;
static const double __FLT_EPSILON__ = 1.19209290e-7F;
static const double __FLT_DENORM_MIN__ = 1.40129846e-45F;
static const int __FLT_HAS_DENORM__ = 1;
static const int __FLT_HAS_INFINITY__ = 1;
static const int __FLT_HAS_QUIET_NAN__ = 1;
static const int __DBL_MANT_DIG__ = 53;
static const int __DBL_DIG__ = 15;
static const int __DBL_MIN_EXP__ = (-1021);
static const int __DBL_MIN_10_EXP__ = (-307);
static const int __DBL_MAX_EXP__ = 1024;
static const int __DBL_MAX_10_EXP__ = 308;
static const double __DBL_MAX__ = 1.7976931348623157e+308;
static const double __DBL_MIN__ = 2.2250738585072014e-308;
static const double __DBL_EPSILON__ = 2.2204460492503131e-16;
static const double __DBL_DENORM_MIN__ = 4.9406564584124654e-324;
static const int __DBL_HAS_DENORM__ = 1;
static const int __DBL_HAS_INFINITY__ = 1;
static const int __DBL_HAS_QUIET_NAN__ = 1;
static const int __LDBL_MANT_DIG__ = 64;
static const int __LDBL_DIG__ = 18;
static const int __LDBL_MIN_EXP__ = (-16381);
static const int __LDBL_MIN_10_EXP__ = (-4931);
static const int __LDBL_MAX_EXP__ = 16384;
static const int __LDBL_MAX_10_EXP__ = 4932;
static const int __DECIMAL_DIG__ = 21;
static const long __LDBL_MAX__ = 1.18973149535723176502e+4932L;
static const long __LDBL_MIN__ = 3.36210314311209350626e-4932L;
static const long __LDBL_EPSILON__ = 1.08420217248550443401e-19L;
static const long __LDBL_DENORM_MIN__ = 3.64519953188247460253e-4951L;
static const int __LDBL_HAS_DENORM__ = 1;
static const int __LDBL_HAS_INFINITY__ = 1;
static const int __LDBL_HAS_QUIET_NAN__ = 1;
static const int __DEC32_MANT_DIG__ = 7;
static const int __DEC32_MIN_EXP__ = (-95);
static const int __DEC32_MAX_EXP__ = 96;
static const double __DEC32_MIN__ = 1E-95DF;
static const double __DEC32_MAX__ = 9.999999E96DF;
static const double __DEC32_EPSILON__ = 1E-6DF;
static const double __DEC32_DEN__ = 0.000001E-95DF;
static const int __DEC64_MANT_DIG__ = 16;
static const int __DEC64_MIN_EXP__ = (-383);
static const int __DEC64_MAX_EXP__ = 384;
static const double __DEC64_MIN__ = 1E-383DD;
static const double __DEC64_MAX__ = 9.999999999999999E384DD;
static const double __DEC64_EPSILON__ = 1E-15DD;
static const double __DEC64_DEN__ = 0.000000000000001E-383DD;
static const int __DEC128_MANT_DIG__ = 34;
static const int __DEC128_MIN_EXP__ = (-6143);
static const int __DEC128_MAX_EXP__ = 6144;
static const long double __DEC128_MIN__ = 1E-6143DL;
static const long double __DEC128_MAX__ = 9.999999999999999999999999999999999E6144DL;
static const long double __DEC128_EPSILON__ = 1E-33DL;
static const long double __DEC128_DEN__ = 0.000000000000000000000000000000001E-6143DL;
static const int __USER_LABEL_PREFIX__ = _;
static const char __VERSION__ = "4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)";
static const int __GNUC_GNU_INLINE__ = 1;
static const int _LP64 = 1;
static const int __LP64__ = 1;
static const int __BLOCKS__ = 1;
static const int __NO_INLINE__ = 1;
static const int __FINITE_MATH_ONLY__ = 0;
static const int __pic__ = 2;
static const int __PIC__ = 2;
static const int __SSP__ = 1;
static const int __amd64 = 1;
static const int __amd64__ = 1;
static const int __x86_64 = 1;
static const int __x86_64__ = 1;
static const int __tune_core2__ = 1;
static const int __MMX__ = 1;
static const int __SSE__ = 1;
static const int __SSE2__ = 1;
static const int __SSE3__ = 1;
static const int __SSE_MATH__ = 1;
static const int __SSE2_MATH__ = 1;
static const int __k8 = 1;
static const int __k8__ = 1;
static const int __NO_MATH_INLINES = 1;
static const int __LITTLE_ENDIAN__ = 1;
static const int __MACH__ = 1;
static const int __APPLE__ = 1;
static const int __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ = 1083;
static const int __CONSTANT_CFSTRINGS__ = 1;
static const int __weak = __attribute__((objc_gc(weak)));
static const int __block = __attribute__((__blocks__(byref)));
static const int OBJC_NEW_PROPERTIES = 1;
static const int __DYNAMIC__ = 1;
static const int __P(protos) = protos;
static const int __CONCAT(x,y) = x ## y;
static const int __STRING(x) = #x;
static const int __const = const;
static const int __signed = signed;
static const int __volatile = volatile;
static const int __dead2 = __attribute__((noreturn));
static const int __pure2 = __attribute__((const));
static const int __unused = __attribute__((unused));
static const int __used = __attribute__((used));
static const int __deprecated = __attribute__((deprecated));
static const int __unavailable = __attribute__((unavailable));
static const int __printflike(fmtarg,firstvararg) = __attribute__((__format__ (__printf__, fmtarg, firstvararg)));
static const int __scanflike(fmtarg,firstvararg) = __attribute__((__format__ (__scanf__, fmtarg, firstvararg)));
static const int __IDSTRING(name,string) = static const char name[] __used = string;
static const int __COPYRIGHT(s) = __IDSTRING(copyright,s);
static const int __RCSID(s) = __IDSTRING(rcsid,s);
static const int __SCCSID(s) = __IDSTRING(sccsid,s);
static const int __PROJECT_VERSION(s) = __IDSTRING(project_version,s);
static const int __DARWIN_ONLY_64_BIT_INO_T = 0;
static const int __DARWIN_ONLY_VERS_1050 = 0;
static const int __DARWIN_ONLY_UNIX_CONFORMANCE = 1;
static const int __DARWIN_UNIX03 = 1;
static const int __DARWIN_64_BIT_INO_T = 1;
static const int __DARWIN_VERS_1050 = 1;
static const int __DARWIN_NON_CANCELABLE = 0;
static const char __DARWIN_SUF_64_BIT_INO_T = "$INODE64";
static const char __DARWIN_SUF_1050 = "$1050";
static const char __DARWIN_SUF_EXTSN = "$DARWIN_EXTSN";
static const int __DARWIN_ALIAS(sym) = __asm("_" __STRING(sym) __DARWIN_SUF_UNIX03);
static const int __DARWIN_ALIAS_C(sym) = __asm("_" __STRING(sym) __DARWIN_SUF_NON_CANCELABLE __DARWIN_SUF_UNIX03);
static const int __DARWIN_ALIAS_I(sym) = __asm("_" __STRING(sym) __DARWIN_SUF_64_BIT_INO_T __DARWIN_SUF_UNIX03);
static const int __DARWIN_INODE64(sym) = __asm("_" __STRING(sym) __DARWIN_SUF_64_BIT_INO_T);
static const int __DARWIN_1050(sym) = __asm("_" __STRING(sym) __DARWIN_SUF_1050);
static const int __DARWIN_1050ALIAS(sym) = __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_UNIX03);
static const int __DARWIN_1050ALIAS_C(sym) = __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_NON_CANCELABLE __DARWIN_SUF_UNIX03);
static const int __DARWIN_1050ALIAS_I(sym) = __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_64_BIT_INO_T __DARWIN_SUF_UNIX03);
static const int __DARWIN_1050INODE64(sym) = __asm("_" __STRING(sym) __DARWIN_SUF_1050 __DARWIN_SUF_64_BIT_INO_T);
static const int __DARWIN_EXTSN(sym) = __asm("_" __STRING(sym) __DARWIN_SUF_EXTSN);
static const int __DARWIN_EXTSN_C(sym) = __asm("_" __STRING(sym) __DARWIN_SUF_EXTSN __DARWIN_SUF_NON_CANCELABLE);
static const int __DARWIN_ALIAS_STARTING_MAC___MAC_10_0(x) = x;
static const int __DARWIN_ALIAS_STARTING_MAC___MAC_10_1(x) = x;
static const int __DARWIN_ALIAS_STARTING_MAC___MAC_10_2(x) = x;
static const int __DARWIN_ALIAS_STARTING_MAC___MAC_10_3(x) = x;
static const int __DARWIN_ALIAS_STARTING_MAC___MAC_10_4(x) = x;
static const int __DARWIN_ALIAS_STARTING_MAC___MAC_10_5(x) = x;
static const int __DARWIN_ALIAS_STARTING_MAC___MAC_10_6(x) = x;
static const int __DARWIN_ALIAS_STARTING_MAC___MAC_10_7(x) = x;
static const int __DARWIN_ALIAS_STARTING_MAC___MAC_10_8(x) = x;
static const int __DARWIN_ALIAS_STARTING(_mac,_iphone,x) = __DARWIN_ALIAS_STARTING_MAC_ ##_mac(x);
static const int __POSIX_C_DEPRECATED(ver) = ___POSIX_C_DEPRECATED_STARTING_ ##ver;
static const long __DARWIN_C_ANSI = 010000L;
static const long __DARWIN_C_FULL = 900000L;
static const int __DARWIN_C_LEVEL = __DARWIN_C_FULL;
static const int __DARWIN_NO_LONG_LONG = (defined(__STRICT_ANSI__) && (__STDC_VERSION__-0 < 199901L) && !defined(__GNUG__));
static const int _DARWIN_FEATURE_64_BIT_INODE = 1;
static const int _DARWIN_FEATURE_ONLY_UNIX_CONFORMANCE = 1;
static const int _DARWIN_FEATURE_UNIX_CONFORMANCE = 3;
static const int __CAST_AWAY_QUALIFIER(variable,qualifier,type) = (type) (long)(variable);
static const int __MAC_10_0 = 1000;
static const int __MAC_10_1 = 1010;
static const int __MAC_10_2 = 1020;
static const int __MAC_10_3 = 1030;
static const int __MAC_10_4 = 1040;
static const int __MAC_10_5 = 1050;
static const int __MAC_10_6 = 1060;
static const int __MAC_10_7 = 1070;
static const int __MAC_10_8 = 1080;
static const int __MAC_NA = 9999;
static const int __IPHONE_2_0 = 20000;
static const int __IPHONE_2_1 = 20100;
static const int __IPHONE_2_2 = 20200;
static const int __IPHONE_3_0 = 30000;
static const int __IPHONE_3_1 = 30100;
static const int __IPHONE_3_2 = 30200;
static const int __IPHONE_4_0 = 40000;
static const int __IPHONE_4_1 = 40100;
static const int __IPHONE_4_2 = 40200;
static const int __IPHONE_4_3 = 40300;
static const int __IPHONE_5_0 = 50000;
static const int __IPHONE_5_1 = 50100;
static const int __IPHONE_NA = 99999;
static const int __AVAILABILITY_INTERNAL_DEPRECATED = __attribute__((deprecated,visibility("default")));
static const int __AVAILABILITY_INTERNAL_UNAVAILABLE = __attribute__((unavailable,visibility("default")));
static const int __AVAILABILITY_INTERNAL_WEAK_IMPORT = __attribute__((weak_import,visibility("default")));
static const int __AVAILABILITY_INTERNAL_REGULAR = __attribute__((visibility("default")));
static const int __MAC_OS_X_VERSION_MIN_REQUIRED = __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__;
static const int __MAC_OS_X_VERSION_MAX_ALLOWED = __MAC_10_8;
static const int __AVAILABILITY_INTERNAL__MAC_10_8 = __AVAILABILITY_INTERNAL_REGULAR;
static const int __AVAILABILITY_INTERNAL__MAC_10_7 = __AVAILABILITY_INTERNAL_REGULAR;
static const int __AVAILABILITY_INTERNAL__MAC_10_6 = __AVAILABILITY_INTERNAL_REGULAR;
static const int __AVAILABILITY_INTERNAL__MAC_10_5 = __AVAILABILITY_INTERNAL_REGULAR;
static const int __AVAILABILITY_INTERNAL__MAC_10_4 = __AVAILABILITY_INTERNAL_REGULAR;
static const int __AVAILABILITY_INTERNAL__MAC_10_3 = __AVAILABILITY_INTERNAL_REGULAR;
static const int __AVAILABILITY_INTERNAL__MAC_10_2 = __AVAILABILITY_INTERNAL_REGULAR;
static const int __AVAILABILITY_INTERNAL__MAC_10_1 = __AVAILABILITY_INTERNAL_REGULAR;
static const int __AVAILABILITY_INTERNAL__MAC_10_0 = __AVAILABILITY_INTERNAL_REGULAR;
static const int __AVAILABILITY_INTERNAL__MAC_NA = __AVAILABILITY_INTERNAL_UNAVAILABLE;
static const int __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_1 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_1 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_2 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_2 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_2 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_3 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_3 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_3 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_3 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_4 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_4 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_4 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_4 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_4 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_5 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_5 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_5 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_5 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_5 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_5 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_6 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_6 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_6 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_6 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_6 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_6 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_6 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_7 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_7 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_7 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_7 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_7 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_7 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_7 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_7 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_10_8 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_10_8 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_10_8 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_10_8 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_10_8 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_10_8 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_10_8 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_10_8 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_10_8 = __AVAILABILITY_INTERNAL_DEPRECATED;
static const int __AVAILABILITY_INTERNAL__MAC_10_0_DEP__MAC_NA = __AVAILABILITY_INTERNAL__MAC_10_0;
static const int __AVAILABILITY_INTERNAL__MAC_10_1_DEP__MAC_NA = __AVAILABILITY_INTERNAL__MAC_10_1;
static const int __AVAILABILITY_INTERNAL__MAC_10_2_DEP__MAC_NA = __AVAILABILITY_INTERNAL__MAC_10_2;
static const int __AVAILABILITY_INTERNAL__MAC_10_3_DEP__MAC_NA = __AVAILABILITY_INTERNAL__MAC_10_3;
static const int __AVAILABILITY_INTERNAL__MAC_10_4_DEP__MAC_NA = __AVAILABILITY_INTERNAL__MAC_10_4;
static const int __AVAILABILITY_INTERNAL__MAC_10_5_DEP__MAC_NA = __AVAILABILITY_INTERNAL__MAC_10_5;
static const int __AVAILABILITY_INTERNAL__MAC_10_6_DEP__MAC_NA = __AVAILABILITY_INTERNAL__MAC_10_6;
static const int __AVAILABILITY_INTERNAL__MAC_10_7_DEP__MAC_NA = __AVAILABILITY_INTERNAL__MAC_10_7;
static const int __AVAILABILITY_INTERNAL__MAC_10_8_DEP__MAC_NA = __AVAILABILITY_INTERNAL__MAC_10_8;
static const int __AVAILABILITY_INTERNAL__MAC_NA_DEP__MAC_NA = __AVAILABILITY_INTERNAL_UNAVAILABLE;
static const int __OSX_AVAILABLE_STARTING(_osx,_ios) = __AVAILABILITY_INTERNAL ##_osx;
static const int __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro,_osxDep,_iosIntro,_iosDep) = __AVAILABILITY_INTERNAL ##_osxIntro ##_DEP ##_osxDep;
typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef short __int16_t;
typedef unsigned short __uint16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;
typedef long long __int64_t;
typedef unsigned long long __uint64_t;
typedef long __darwin_intptr_t;
typedef unsigned int __darwin_natural_t;
typedef int __darwin_ct_rune_t;
typedef union {
char __mbstate8[128];
long long _mbstateL;
} __mbstate_t;
typedef __mbstate_t __darwin_mbstate_t;
typedef long int __darwin_ptrdiff_t;
typedef long unsigned int __darwin_size_t;
typedef __builtin_va_list __darwin_va_list;
typedef int __darwin_wchar_t;
typedef __darwin_wchar_t __darwin_rune_t;
typedef int __darwin_wint_t;
typedef unsigned long __darwin_clock_t;
typedef __uint32_t __darwin_socklen_t;
typedef long __darwin_ssize_t;
typedef long __darwin_time_t;
static const int __PTHREAD_SIZE__ = 1168;
static const int __PTHREAD_ATTR_SIZE__ = 56;
static const int __PTHREAD_MUTEXATTR_SIZE__ = 8;
static const int __PTHREAD_MUTEX_SIZE__ = 56;
static const int __PTHREAD_CONDATTR_SIZE__ = 8;
static const int __PTHREAD_COND_SIZE__ = 40;
static const int __PTHREAD_ONCE_SIZE__ = 8;
static const int __PTHREAD_RWLOCK_SIZE__ = 192;
static const int __PTHREAD_RWLOCKATTR_SIZE__ = 16;
struct __darwin_pthread_handler_rec
{
void (*__routine)(void *);
void *__arg;
struct __darwin_pthread_handler_rec *__next;
};
struct _opaque_pthread_attr_t { long __sig; char __opaque[56]; };
struct _opaque_pthread_cond_t { long __sig; char __opaque[40]; };
struct _opaque_pthread_condattr_t { long __sig; char __opaque[8]; };
struct _opaque_pthread_mutex_t { long __sig; char __opaque[56]; };
struct _opaque_pthread_mutexattr_t { long __sig; char __opaque[8]; };
struct _opaque_pthread_once_t { long __sig; char __opaque[8]; };
struct _opaque_pthread_rwlock_t { long __sig; char __opaque[192]; };
struct _opaque_pthread_rwlockattr_t { long __sig; char __opaque[16]; };
struct _opaque_pthread_t { long __sig; struct __darwin_pthread_handler_rec *__cleanup_stack; char __opaque[1168]; };
static const int __DARWIN_NULL = ((void *)0);
typedef __int64_t __darwin_blkcnt_t;
typedef __int32_t __darwin_blksize_t;
typedef __int32_t __darwin_dev_t;
typedef unsigned int __darwin_fsblkcnt_t;
typedef unsigned int __darwin_fsfilcnt_t;
typedef __uint32_t __darwin_gid_t;
typedef __uint32_t __darwin_id_t;
typedef __uint64_t __darwin_ino64_t;
typedef __darwin_ino64_t __darwin_ino_t;
typedef __darwin_natural_t __darwin_mach_port_name_t;
typedef __darwin_mach_port_name_t __darwin_mach_port_t;
typedef __uint16_t __darwin_mode_t;
typedef __int64_t __darwin_off_t;
typedef __int32_t __darwin_pid_t;
typedef struct _opaque_pthread_attr_t
__darwin_pthread_attr_t;
typedef struct _opaque_pthread_cond_t
__darwin_pthread_cond_t;
typedef struct _opaque_pthread_condattr_t
__darwin_pthread_condattr_t;
typedef unsigned long __darwin_pthread_key_t;
typedef struct _opaque_pthread_mutex_t
__darwin_pthread_mutex_t;
typedef struct _opaque_pthread_mutexattr_t
__darwin_pthread_mutexattr_t;
typedef struct _opaque_pthread_once_t
__darwin_pthread_once_t;
typedef struct _opaque_pthread_rwlock_t
__darwin_pthread_rwlock_t;
typedef struct _opaque_pthread_rwlockattr_t
__darwin_pthread_rwlockattr_t;
typedef struct _opaque_pthread_t
*__darwin_pthread_t;
typedef __uint32_t __darwin_sigset_t;
typedef __int32_t __darwin_suseconds_t;
typedef __uint32_t __darwin_uid_t;
typedef __uint32_t __darwin_useconds_t;
typedef unsigned char __darwin_uuid_t[16];
typedef char __darwin_uuid_string_t[37];
static const int __strfmonlike(fmtarg,firstvararg) = __attribute__((__format__ (__strfmon__, fmtarg, firstvararg)));
static const int __strftimelike(fmtarg) = __attribute__((__format__ (__strftime__, fmtarg, 0)));
typedef int __darwin_nl_item;
typedef int __darwin_wctrans_t;
typedef __uint32_t __darwin_wctype_t;
static const int __DARWIN_WCHAR_MAX = __WCHAR_MAX__;
static const int __DARWIN_WCHAR_MIN = (-0x7fffffff - 1);
static const int __DARWIN_WEOF = ((__darwin_wint_t)-1);
static const int _FORTIFY_SOURCE = 2;
typedef __darwin_va_list va_list;
typedef __darwin_size_t size_t;
static const int NULL = __DARWIN_NULL;
typedef __darwin_off_t fpos_t;
struct __sbuf {
unsigned char *_base;
int _size;
};
struct __sFILEX;
typedef struct __sFILE {
unsigned char *_p;
int _r;
int _w;
short _flags;
short _file;
struct __sbuf _bf;
int _lbfsize;
void *_cookie;
int (*_close)(void *);
int (*_read) (void *, char *, int);
fpos_t (*_seek) (void *, fpos_t, int);
int (*_write)(void *, const char *, int);
struct __sbuf _ub;
struct __sFILEX *_extra;
int _ur;
unsigned char _ubuf[3];
unsigned char _nbuf[1];
struct __sbuf _lb;
int _blksize;
fpos_t _offset;
} FILE;
extern FILE *__stdinp;
extern FILE *__stdoutp;
extern FILE *__stderrp;
static const int __SLBF = 0x0001;
static const int __SNBF = 0x0002;
static const int __SRD = 0x0004;
static const int __SWR = 0x0008;
static const int __SRW = 0x0010;
static const int __SEOF = 0x0020;
static const int __SERR = 0x0040;
static const int __SMBF = 0x0080;
static const int __SAPP = 0x0100;
static const int __SSTR = 0x0200;
static const int __SOPT = 0x0400;
static const int __SNPT = 0x0800;
static const int __SOFF = 0x1000;
static const int __SMOD = 0x2000;
static const int __SALC = 0x4000;
static const int __SIGN = 0x8000;
static const int _IOFBF = 0;
static const int _IOLBF = 1;
static const int _IONBF = 2;
static const int BUFSIZ = 1024;
static const int EOF = (-1);
static const int FOPEN_MAX = 20;
static const int FILENAME_MAX = 1024;
static const char P_tmpdir = "/var/tmp/";
static const int L_tmpnam = 1024;
static const int TMP_MAX = 308915776;
static const int SEEK_SET = 0;
static const int SEEK_CUR = 1;
static const int SEEK_END = 2;
static const int stdin = __stdinp;
static const int stdout = __stdoutp;
static const int stderr = __stderrp;
void clearerr(FILE *);
int fclose(FILE *);
int feof(FILE *);
int ferror(FILE *);
int fflush(FILE *);
int fgetc(FILE *);
int fgetpos(FILE * , fpos_t *);
char *fgets(char * , int, FILE *);
FILE *fopen(const char * , const char * ) __asm("_" "fopen" );
int fprintf(FILE * , const char * , ...) __attribute__((__format__ (__printf__, 2, 3)));
int fputc(int, FILE *);
int fputs(const char * , FILE * ) __asm("_" "fputs" );
size_t fread(void * , size_t, size_t, FILE * );
FILE *freopen(const char * , const char * ,
FILE * ) __asm("_" "freopen" );
int fscanf(FILE * , const char * , ...) __attribute__((__format__ (__scanf__, 2, 3)));
int fseek(FILE *, long, int);
int fsetpos(FILE *, const fpos_t *);
long ftell(FILE *);
size_t fwrite(const void * , size_t, size_t, FILE * ) __asm("_" "fwrite" );
int getc(FILE *);
int getchar(void);
char *gets(char *);
void perror(const char *);
int printf(const char * , ...) __attribute__((__format__ (__printf__, 1, 2)));
int putc(int, FILE *);
int putchar(int);
int puts(const char *);
int remove(const char *);
int rename (const char *, const char *);
void rewind(FILE *);
int scanf(const char * , ...) __attribute__((__format__ (__scanf__, 1, 2)));
void setbuf(FILE * , char * );
int setvbuf(FILE * , char * , int, size_t);
int sprintf(char * , const char * , ...) __attribute__((__format__ (__printf__, 2, 3)));
int sscanf(const char * , const char * , ...) __attribute__((__format__ (__scanf__, 2, 3)));
FILE *tmpfile(void);
char *tmpnam(char *);
int ungetc(int, FILE *);
int vfprintf(FILE * , const char * , va_list) __attribute__((__format__ (__printf__, 2, 0)));
int vprintf(const char * , va_list) __attribute__((__format__ (__printf__, 1, 0)));
int vsprintf(char * , const char * , va_list) __attribute__((__format__ (__printf__, 2, 0)));
static const int L_ctermid = 1024;
static const int __CTERMID_DEFINED = 1;
char *ctermid(char *);
FILE *fdopen(int, const char *) __asm("_" "fdopen" );
int fileno(FILE *);
int pclose(FILE *);
FILE *popen(const char *, const char *) __asm("_" "popen" );
int __srget(FILE *);
int __svfscanf(FILE *, const char *, va_list) __attribute__((__format__ (__scanf__, 2, 0)));
int __swbuf(int, FILE *);
static const int __sgetc(p) = (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++));
static __inline int __sputc(int _c, FILE *_p) {
if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
return (*_p->_p++ = _c);
else
return (__swbuf(_c, _p));
}
static const int __sfeof(p) = (((p)->_flags & __SEOF) != 0);
static const int __sferror(p) = (((p)->_flags & __SERR) != 0);
static const int __sclearerr(p) = ((void)((p)->_flags &= ~(__SERR|__SEOF)));
static const int __sfileno(p) = ((p)->_file);
void flockfile(FILE *);
int ftrylockfile(FILE *);
void funlockfile(FILE *);
int getc_unlocked(FILE *);
int getchar_unlocked(void);
int putc_unlocked(int, FILE *);
int putchar_unlocked(int);
int getw(FILE *);
int putw(int, FILE *);
char *tempnam(const char *, const char *) __asm("_" "tempnam" );
static const int getc_unlocked(fp) = __sgetc(fp);
static const int putc_unlocked(x,fp) = __sputc(x, fp);
static const int getchar_unlocked() = getc_unlocked(stdin);
static const int putchar_unlocked(x) = putc_unlocked(x, stdout);
typedef __darwin_off_t off_t;
int fseeko(FILE *, off_t, int);
off_t ftello(FILE *);
int snprintf(char * , size_t, const char * , ...) __attribute__((__format__ (__printf__, 3, 4)));
int vfscanf(FILE * , const char * , va_list) __attribute__((__format__ (__scanf__, 2, 0)));
int vscanf(const char * , va_list) __attribute__((__format__ (__scanf__, 1, 0)));
int vsnprintf(char * , size_t, const char * , va_list) __attribute__((__format__ (__printf__, 3, 0)));
int vsscanf(const char * , const char * , va_list) __attribute__((__format__ (__scanf__, 2, 0)));
typedef __darwin_ssize_t ssize_t;
int dprintf(int, const char * , ...) __attribute__((__format__ (__printf__, 2, 3))) __attribute__((visibility("default")));
int vdprintf(int, const char * , va_list) __attribute__((__format__ (__printf__, 2, 0))) __attribute__((visibility("default")));
ssize_t getdelim(char ** , size_t * , int, FILE * ) __attribute__((visibility("default")));
ssize_t getline(char ** , size_t * , FILE * ) __attribute__((visibility("default")));
extern const int sys_nerr;
extern const char *const sys_errlist[];
int asprintf(char **, const char *, ...) __attribute__((__format__ (__printf__, 2, 3)));
char *ctermid_r(char *);
char *fgetln(FILE *, size_t *);
const char *fmtcheck(const char *, const char *);
int fpurge(FILE *);
void setbuffer(FILE *, char *, int);
int setlinebuf(FILE *);
int vasprintf(char **, const char *, va_list) __attribute__((__format__ (__printf__, 2, 0)));
FILE *zopen(const char *, const char *, int);
FILE *funopen(const void *,
int (*)(void *, char *, int),
int (*)(void *, const char *, int),
fpos_t (*)(void *, fpos_t, int),
int (*)(void *));
static const int fropen(cookie,fn) = funopen(cookie, fn, 0, 0, 0);
static const int fwopen(cookie,fn) = funopen(cookie, 0, fn, 0, 0);
static const int feof_unlocked(p) = __sfeof(p);
static const int ferror_unlocked(p) = __sferror(p);
static const int clearerr_unlocked(p) = __sclearerr(p);
static const int fileno_unlocked(p) = __sfileno(p);
static const int _USE_FORTIFY_LEVEL = 2;
static const int __darwin_obsz0(object) = __builtin_object_size (object, 0);
static const int __darwin_obsz(object) = __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1);
extern int __sprintf_chk (char * , int, size_t,
const char * , ...);
static const int sprintf(str,...) = __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__);
extern int __snprintf_chk (char * , size_t, int, size_t,
const char * , ...);
static const int snprintf(str,len,...) = __builtin___snprintf_chk (str, len, 0, __darwin_obsz(str), __VA_ARGS__);
extern int __vsprintf_chk (char * , int, size_t,
const char * , va_list);
static const int vsprintf(str,format,ap) = __builtin___vsprintf_chk (str, 0, __darwin_obsz(str), format, ap);
extern int __vsnprintf_chk (char * , size_t, int, size_t,
const char * , va_list);
static const int vsnprintf(str,len,format,ap) = __builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap);
| 52.223986 | 140 | 0.803992 |
69e2b18bf434b9262931dbeb23f97c9d69f4d624 | 19,272 | c | C | puzzles/icons/mines-icon.c | nik0kin/puzzles | 70df26c6cfc57b05549647ad3729eafb81a28cb5 | [
"MIT"
] | 13 | 2015-11-23T22:33:17.000Z | 2021-01-25T15:21:06.000Z | puzzles/icons/mines-icon.c | nik0kin/puzzles | 70df26c6cfc57b05549647ad3729eafb81a28cb5 | [
"MIT"
] | null | null | null | puzzles/icons/mines-icon.c | nik0kin/puzzles | 70df26c6cfc57b05549647ad3729eafb81a28cb5 | [
"MIT"
] | 7 | 2015-01-16T09:07:13.000Z | 2021-05-07T17:08:48.000Z | /* XPM */
static const char *const xpm_icon_0[] = {
/* columns rows colors chars-per-pixel */
"16 16 230 2",
" c #5F706E",
". c #5D7673",
"X c #7B6B6B",
"o c #737977",
"O c #BB5A58",
"+ c #827774",
"@ c #F84B4C",
"# c #E1504E",
"$ c #EC5653",
"% c #F25553",
"& c #F3605D",
"* c #CF706D",
"= c #F77875",
"- c #F07E7B",
"; c #449941",
": c #479B46",
"> c #62A45E",
", c #6EAB69",
"< c #72AE71",
"1 c #79B17A",
"2 c #80817E",
"3 c #94807D",
"4 c #83B27E",
"5 c #353591",
"6 c #45438F",
"7 c #484494",
"8 c #5A5A9E",
"9 c #7171E4",
"0 c #7A8B88",
"q c #8D9088",
"w c #999A93",
"e c #B38C89",
"r c #A09F9C",
"t c #AD9E9B",
"y c #BC9C99",
"u c #82B580",
"i c #8DB289",
"p c #97B593",
"a c #97B692",
"s c #94BB93",
"d c #A0B99C",
"f c #A3BC9E",
"g c #8380AF",
"h c #9EA6A4",
"j c #9EB5B2",
"k c #AFACAA",
"l c #B9ACA9",
"z c #AABBA5",
"x c #B5B1AE",
"c c #B1BFAC",
"v c #A4A0B4",
"b c #A6A4BC",
"n c #A6A5BD",
"m c #A8A7BF",
"M c #AEA9B9",
"N c #B8BBB7",
"B c #BCBCB5",
"V c #FD8381",
"C c #E39896",
"Z c #F29795",
"A c #C7AFAB",
"S c #D8A8A5",
"D c #DEA9A6",
"F c #C4BBB7",
"G c #C2BDBB",
"H c #C0BEBA",
"J c #CEBEBA",
"K c #D0BABA",
"L c #EAB7B3",
"P c #E8B7B7",
"I c #B3C2AD",
"U c #B7C4B3",
"Y c #B7C2B4",
"T c #B8C2B5",
"R c #BBC1BE",
"E c #C0C5BA",
"W c #C2C3BD",
"Q c #C6C3BF",
"! c #D0C2BE",
"~ c #E8C2BE",
"^ c #8D8CD7",
"/ c #9697D7",
"( c #A09FD3",
") c #B7B5C6",
"_ c #B8B8C8",
"` c #8182E3",
"' c #C5BCC8",
"] c #BAC9C2",
"[ c #C0C0C0",
"{ c #C4C3C0",
"} c #C3C4C0",
"| c #C6C4C0",
" . c #C6C4C1",
".. c #C8C6C3",
"X. c #CCC4C6",
"o. c #CBC8C1",
"O. c #CAC8C3",
"+. c #CAC8C4",
"@. c #CEC8C4",
"#. c #CCCAC5",
"$. c #CCCAC7",
"%. c #CDCAC7",
"&. c #CACEC5",
"*. c #CDCCC7",
"=. c #CDCAC9",
"-. c #CBC9CC",
";. c #D0CAC5",
":. c #DDCAC7",
">. c #D1C9CB",
",. c #D0CEC9",
"<. c #D0CFC9",
"1. c #D1CFCA",
"2. c #D2CFCA",
"3. c #D9D4C6",
"4. c #D3D1C9",
"5. c #D1D0CC",
"6. c #D0D1CC",
"7. c #D1D0CD",
"8. c #D3D0CC",
"9. c #D1D0CE",
"0. c #D3D1CE",
"q. c #D2D1CF",
"w. c #D1D3CE",
"e. c #D4D1CD",
"r. c #D5D3CD",
"t. c #D5D1CE",
"y. c #D5D3CE",
"u. c #D6D3CF",
"i. c #D7D5CF",
"p. c #DDDBC9",
"a. c #D8CCD2",
"s. c #DACDD3",
"d. c #D3D2D0",
"f. c #D6D1D0",
"g. c #D5D3D0",
"h. c #D4D3D1",
"j. c #D7D2D1",
"k. c #D0D6D2",
"l. c #D5D4D0",
"z. c #D5D6D1",
"x. c #D5D4D2",
"c. c #D6D5D2",
"v. c #D9D2D3",
"b. c #DAD3D3",
"n. c #D8D5D1",
"m. c #D8D6D1",
"M. c #D9D7D3",
"N. c #D9D7D4",
"B. c #DAD7D5",
"V. c #DDD4D6",
"C. c #DADAD2",
"Z. c #DBD9D4",
"A. c #D9D8D6",
"S. c #D8D9D6",
"D. c #D9D9D6",
"F. c #DBD8D6",
"G. c #DAD9D7",
"H. c #D9DAD7",
"J. c #DCDAD5",
"K. c #DDDAD5",
"L. c #DED8D6",
"P. c #DDDBD6",
"I. c #DCDAD7",
"U. c #DEDCD6",
"Y. c #DAD9D8",
"T. c #DBDAD8",
"R. c #DDDBD8",
"E. c #DCDBD9",
"W. c #DEDBD8",
"Q. c #DBDCDA",
"!. c #DFDDD8",
"~. c #DEDCD9",
"^. c #DDDCDA",
"/. c #DDDCDB",
"(. c #DFDCDA",
"). c #DEDDDB",
"_. c #DFDEDB",
"`. c #D8DFDC",
"'. c #ECCFCC",
"]. c #E6DDD4",
"[. c #E9DAD7",
"{. c #E0DED8",
"}. c #E2DDDA",
"|. c #E0DFDA",
" X c #E1DFDA",
".X c #E0DEDB",
"XX c #E2DFDB",
"oX c #E3DFDB",
"OX c #E4DFDA",
"+X c #E1DFDC",
"@X c #E4DFDC",
"#X c #EEDEDF",
"$X c #D2E0DD",
"%X c #D8E0DE",
"&X c #DEE2DD",
"*X c #E2E0DB",
"=X c #E1E0DC",
"-X c #E2E0DC",
";X c #E2E1DC",
":X c #E3E1DC",
">X c #E3E1DD",
",X c #E3E2DD",
"<X c #E3E1DE",
"1X c #E4E2DD",
"2X c #E4E2DE",
"3X c #E5E2DE",
"4X c #E5E2DF",
"5X c #E7E2DE",
"6X c #E7E6DF",
"7X c #EDE4D8",
"8X c #EEE5DD",
"9X c #DBECE7",
"0X c #DFF1ED",
"qX c #E3E2E1",
"wX c #E3E3E1",
"eX c #E1E5E1",
"rX c #E2E4E0",
"tX c #E3E4E3",
"yX c #E7ECE3",
"uX c #E7EFE7",
"iX c #EAE8E3",
"pX c #ECEAE1",
"aX c #EFEEE2",
"sX c #ECE8E8",
"dX c #F1E4E7",
"fX c #F0EFE0",
"gX c #F4EAEF",
"hX c #E2F2EE",
"jX c #E9F3EF",
"kX c #F2F0E7",
/* pixels */
"K.rX0XrXv.b.b.2.j.V.8.4.p.4.b.U.",
"rX[.Z :.N p p >.z i W Q ^ ) rX=X",
"rX'.# A B u > s.U : Y 3.9 ( kX{.",
"4Xk.. 2 G < s s.p , ....` / aX!.",
"z.l y x H.dX#X} @.' Q 4X7X].rX*X",
"6.! % D hX& - ] M 5 _ dX@ C $X:X",
"w.J $ S jXt X B v 7 m fX+ + !.+X",
"6.F K =. .w q k uX9X4X}.j h H.=X",
"r.U 1 c *.m g iXP = j.R.V L `.+X",
"r.R ; f >.8 6 &X~ O B +X* e `.+X",
"v.U u &.#.-.n 4XR w Y.0 o b.4X",
"}.sXgX+X!.iXpXY.!.4Xb.!.+X!.!.=X",
"=X=XZ.*.z.}.z.#.*XU.*.Y.}.r.j.=X",
"4XK.r.#.6.v.2...Z.r. .d.z.#.d.=X",
"=XQ.6.z.R.x.r.H.H.6.z.!.j.6.wX}.",
"K.}.4X4X+X4X=X4X=X4X4X=X=X4X*XH."
};
/* XPM */
static const char *const xpm_icon_1[] = {
/* columns rows colors chars-per-pixel */
"32 32 216 2",
" c #0E1110",
". c #141615",
"X c #171A1A",
"o c #232323",
"O c #2C3130",
"+ c #363534",
"@ c #007700",
"# c #007900",
"$ c #02027C",
"% c #484544",
"& c #4A4B49",
"* c #5B4D4B",
"= c #5C5755",
"- c #5C5A58",
"; c #7A4F4E",
": c #6E615F",
"> c #6B6967",
", c #6F6B68",
"< c #736E6B",
"1 c #73716F",
"2 c #767272",
"3 c #787674",
"4 c #7B7A77",
"5 c #7E7D7A",
"6 c #FD0000",
"7 c #FB0F0F",
"8 c #F91514",
"9 c #F61D1D",
"0 c #F52323",
"q c #F12E2C",
"w c #EA3B3A",
"e c #F33534",
"r c #F23938",
"t c #A55755",
"y c #8A6764",
"u c #807F7C",
"i c #F04442",
"p c #EF514F",
"a c #ED5553",
"s c #EE5F5D",
"d c #E7605E",
"f c #EB605E",
"g c #E86563",
"h c #EA6C69",
"j c #E87572",
"k c #E97875",
"l c #E47D7A",
"z c #E87B78",
"x c #0E800E",
"c c #1D861C",
"v c #1D8A1C",
"b c #238C22",
"n c #288E27",
"m c #2A8E29",
"M c #2D912C",
"N c #349132",
"B c #3A9738",
"V c #3E983C",
"C c #439941",
"Z c #489B45",
"A c #4D9D4B",
"S c #549F52",
"D c #53A151",
"F c #64A661",
"G c #69A766",
"H c #70A96D",
"J c #75AD72",
"K c #7FAF7C",
"L c #80AF7B",
"P c navy",
"I c #0E0E82",
"U c #26268D",
"Y c #3C3C95",
"T c #48479A",
"R c #4D4C9C",
"E c #54539E",
"W c #59589F",
"Q c #5F5EA2",
"! c #605FA1",
"~ c #6262A3",
"^ c #6E6DA7",
"/ c #0B0BFC",
"( c #1616FC",
") c #2424F6",
"_ c #4241EF",
"` c #6E6DE5",
"' c #7775E1",
"] c #878683",
"[ c #8A8481",
"{ c #8B8986",
"} c #8D8C89",
"| c #918F8C",
" . c #94918E",
".. c #969491",
"X. c #999692",
"o. c #9C9996",
"O. c #9E9D9A",
"+. c #A19F9C",
"@. c #8DB489",
"#. c #9DB797",
"$. c #95B891",
"%. c #9ABA95",
"&. c #A4A19E",
"*. c #A1BD9E",
"=. c #8180AE",
"-. c #8887B2",
";. c #9796B4",
":. c #9F9DB9",
">. c #A7A5A2",
",. c #A8A7A3",
"<. c #ABA9A6",
"1. c #ADACA9",
"2. c #B0AAA6",
"3. c #B1AEAB",
"4. c #ABBEA6",
"5. c #ACB1AE",
"6. c #B3B1AE",
"7. c #AAA9BB",
"8. c #ABB6B2",
"9. c #B5B5B1",
"0. c #BAB6B3",
"q. c #BBBAB5",
"w. c #B3B1BF",
"e. c #BEBCB9",
"r. c #DE9492",
"t. c #DB9C99",
"y. c #E38683",
"u. c #E28885",
"i. c #C2B1AD",
"p. c #D4B2AE",
"a. c #DBB2AD",
"s. c #C0BEB1",
"d. c #C2BDBC",
"f. c #D2BAB4",
"g. c #DDBFBA",
"h. c #E5B2AE",
"j. c #E2BAB6",
"k. c #E8BCB8",
"l. c #AEC3A9",
"z. c #B0C3AC",
"x. c #B5C5B0",
"c. c #BAC5B5",
"v. c #BCC9B7",
"b. c #C5C3BE",
"n. c #C3CBBD",
"m. c #9D9AD2",
"M. c #9695D9",
"N. c #B8B6C2",
"B. c #BDBBC3",
"V. c #BCBACC",
"C. c #A4A2D2",
"Z. c #A8A7D8",
"A. c #C5BEC2",
"S. c #C6C5C2",
"D. c #C9C6C3",
"F. c #C6CAC0",
"G. c #CCCBC5",
"H. c #C4C2CD",
"J. c #CBC4CA",
"K. c #C5CEC9",
"L. c #CECCC9",
"P. c #D4C6C3",
"I. c #D0CBC6",
"U. c #D2CDCB",
"Y. c #CCD3CE",
"T. c #DAD8C6",
"R. c #D3D1CD",
"E. c #D9D6CD",
"W. c #DCDACC",
"Q. c #CCD6D2",
"!. c #C9D9D5",
"~. c #D5D3D2",
"^. c #D9D6D2",
"/. c #D1DBD6",
"(. c #DCDAD5",
"). c #DED4D8",
"_. c #DEDDD8",
"`. c #E3CBC6",
"'. c #E0DEC5",
"]. c #E6D1CD",
"[. c #E3D5D1",
"{. c #E2DAD5",
"}. c #E3D7DC",
"|. c #E0DED9",
" X c #D7E1DC",
".X c #DEE1DC",
"XX c #EAE8C3",
"oX c #E3E2DD",
"OX c #F2ECDF",
"+X c #F1DBEA",
"@X c #DEE7E1",
"#X c #D7E9E3",
"$X c #DAE9E3",
"%X c #DDEEE8",
"&X c #DEF2ED",
"*X c #E5E5E2",
"=X c #E8E6E4",
"-X c #E6E9E5",
";X c #EBE9E6",
":X c #E3EAE9",
">X c #ECECEA",
",X c #F0E7E9",
"<X c #F2EDEB",
"1X c #E1F2ED",
"2X c #ECF2ED",
"3X c #F2F3E4",
"4X c #F1F0EF",
"5X c #E1F7F4",
"6X c #EEF4F2",
"7X c #E8F9F3",
"8X c #ECFDFB",
"9X c #F5F4F4",
"0X c #F8F7F7",
"qX c #F8F8F7",
"wX c #F0FFFD",
"eX c #FAF9F9",
/* pixels */
"(.(.E.^.^.E.^.E.(.|._._._.|.(.oX|.|.|.(.(.oX(.oX(.|.(.oX(.^.(.(.",
"(._.=X=X*X=X=X;X^.b.D.G.D.S.D.D.b.D.L.b.S.S.D.D.D.b.D.S.L.oX(.(.",
"^.=X9X2X7X>X;X*X,.b.G.q.D.D.b.6.D.b.c.D.G.b.6.D.b.B.S.b.Y.eX(.(.",
"^.=X-Xa.z q j.K...^.F B C n.^.e.L.S B D R.L.e.E.' ( Z.W.^.eX(.(.",
"^.=X>Xj 7 6 k.Y.o.L.l.).c @.).q.n.c.D.x x.U.q.U.H.) M.T.R.eX(.(.",
"E.=X-X X<Xt f.~.X.R.).F M G.U.q.R.R.C Z R.L.q.R.XX) Z.W.~.eX(.(.",
"^.=X>XL.1.O 3 G.o.).A @ V c.~.0.U.n # S G.G.e.E.' / _ V.(.eX(.(.",
"^.=X-XX.= = - ..o.L.4.4.#.c.L.q.R.l.z.*.L.R.0.L.C.C.m.B.E.eX_.(.",
"(.E.,.O.8.5.1.o.0.>X,X,X9X;X;X0.q.A.A.D.e.0.^.;XOXOX3X;X-X0X_.).",
"oXb.S.P.t.p.Y.G.=X>X5X1X].=XL.,.U.G.S.7.D.L.9X:X5X*X].-XS.9X(.^.",
"(.D.K.u.g 0 u.Q.=X|.y.e 9 [.q.O.^.E.T $ N.E.>Xg.h 8 d #X<.9XoX^.",
"oXS.S.R.u.9 r.Q.=X|.j 9 8 (.e.&.(.! ^ U N.E.6Xg.p 6 s #X6.qX(.(.",
"|.b.b.b.r.0 l !.=X=X%X4X; {.b.&.L.U R $ ~ ^.>X_.8Xi.y 9X<.9X|.^.",
"oXb.K.y.p r t.Y.=X,X0.2 . u q.&.~.L.N.U 7.^.9X(.&.& o 1.0.9X(.(.",
"|.b.D.R.g.P./.I.=XU.] > 1 1 .&.R.U.U.D.I.U.;X6.1 , < 4 ,.qX|.^.",
"|.b.6.b.J.d.0.q.0.&.<.9.s.0.&.R.9X;X>X9X>X;X:X^.oX-X:X.X^.eX(.(.",
"|.S.D.v.L %.U.R.e.L.^.G.=.H.^.>X*X&X^.h.=Xq.*X:X1X`.k.=Xq.9X(.(.",
"|.S.U.J G n L }.q.G.E.W $ ;.E.>X`.a 6 e *X3.@Xj.i 6 s #X<.9X|.(.",
"|.S.S.^.+XN H }.9.E.~ ~ Y =.E.>X[.y.e w @X3.*X`.z 0 s #X3.9X(.(.",
"|.S.D.c.n b n.R.q.R.W E $ Y U.>X|.7X/.* >X9..X.XwX9.> 4X1.9X|.(.",
"|.b.U.J v C $.).q.D.E.W.E :.E.;XoXX.% u 3.*X).] + X ..6.9X(.(.",
"{.D.S.^.).~.U.R.e.L.R.R.^.R.U.-Xq.{ ] ..{ +._.3.] } } } <.eX(.(.",
").|.9X<X2X4X9X;XoX9X2X4X<X9X:X=X=X;X;X;X>X_.:X*X>X;X;X;X_.9X|.(.",
"^.;X-X^.(.^.|.S.S.;X^.(.(.|.q.~.;X(._.(.oX0.oX|._.|._._.6.9X_.(.",
"^.=X;X^.(.(.|.b.K.;X~.(.(.|.q.~.*X^.(.(._.6.oX_.^.(.(.(.6.9X(.(.",
"^.=X;X^.(.(.|.b.S.;X^.(.^.oXq.~.oX~._.^._.6.*X_.).(.(.(.6.9X_.(.",
"E.=X-XE.(.(.|.b.S.;X^.(.(.|.q.^.=X^.(.^.|.9.oX_.(.^.(.(.6.9X_.(.",
"^.-X>X(.(.(.|.b.S.;X^.(.(.oX0.~.oX^._.^.|.6..X_.(.(.(.(.1.9X_.(.",
"^.=XL.1.6.6.6.,.G.S.1.6.6.6.,.^.e.1.6.6.6.,._.9.3.6.6.6.5.qX(.(.",
"^.=X9X9X9X9X9X9XeX9X9X9X9X9X9XqX9X9X9X9X9XeX9X9X9X9X9X9XqXqX(.(.",
"^.(.|._._._.|.(._._._._.(._.(..XoX(.(.|._.(._.(._._._.(.|.(.(.(.",
"(.(.^.(.(.(.(.(.^.(.(.(.(.(.(.^.^.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(."
};
/* XPM */
static const char *const xpm_icon_2[] = {
/* columns rows colors chars-per-pixel */
"48 48 256 2",
" c #020101",
". c #0C0C0C",
"X c #100F0F",
"o c #141212",
"O c #181817",
"+ c #262525",
"@ c #282827",
"# c #2E2D2C",
"$ c #313130",
"% c #333938",
"& c #3C3E3D",
"* c #4E2827",
"= c #007400",
"- c #007B00",
"; c #000075",
": c #01017C",
"> c #0B0B7F",
", c #424140",
"< c #4B4847",
"1 c #4F4F4D",
"2 c #565553",
"3 c #5A5957",
"4 c #5F5E5C",
"5 c #625F5C",
"6 c #62615E",
"7 c #646361",
"8 c #6D6C69",
"9 c #767A77",
"0 c #D40D0D",
"q c #D31C1B",
"w c #FE0202",
"e c #FC0C0C",
"r c #FA1C1B",
"t c #FA1615",
"y c #FA2120",
"u c #F92B2A",
"i c #F43534",
"p c #F4403F",
"a c #A94E4C",
"s c #B55250",
"d c #807F7C",
"f c #EE4C4A",
"g c #F14543",
"h c #F24F4D",
"j c #EB5856",
"k c #E25A58",
"l c #EC5C5A",
"z c #F15553",
"x c #F05E5C",
"c c #E9605F",
"v c #EB6967",
"b c #E97370",
"n c #E27E7C",
"m c #9D2120",
"M c #028002",
"N c #0B830B",
"B c #128512",
"V c #178816",
"C c #188918",
"Z c #258D24",
"A c #2A8F29",
"S c #2D902B",
"D c #3C963A",
"F c #349333",
"G c #459943",
"H c #499C47",
"J c #4D9D4B",
"K c #529F50",
"L c #56A154",
"P c #59A157",
"I c #6AA767",
"U c #69A866",
"Y c #72AB6F",
"T c #77AD74",
"R c #80B07C",
"E c navy",
"W c #121286",
"Q c #1A1987",
"! c #171788",
"~ c #23238C",
"^ c #28278E",
"/ c #2D2D90",
"( c #3E3E96",
") c #323291",
"_ c #403F97",
"` c #454497",
"' c #4E4E9C",
"] c #53529D",
"[ c #5C5CA1",
"{ c #6F6EA9",
"} c #6262A2",
"| c #7675AB",
" . c #7B7AAB",
".. c #0202FE",
"X. c #1E1EF7",
"o. c #1313FA",
"O. c #3D3CEF",
"+. c #2423F6",
"@. c #2D2CF3",
"#. c #3A39F1",
"$. c #3433F3",
"%. c #4444EE",
"&. c #4B4AED",
"*. c #807EDF",
"=. c #898784",
"-. c #8C8A87",
";. c #8E8C89",
":. c #918E8B",
">. c #94918E",
",. c #969491",
"<. c #999693",
"1. c #9B9996",
"2. c #9E9D99",
"3. c #A09E9B",
"4. c #86B382",
"5. c #8FB68B",
"6. c #8BB487",
"7. c #91B78D",
"8. c #97B993",
"9. c #9CBB97",
"0. c #A3A29E",
"q. c #A3BD9E",
"w. c #8280AD",
"e. c #8887B1",
"r. c #8A89B1",
"t. c #9594B5",
"y. c #9896B6",
"u. c #A6A4A1",
"i. c #A9A7A4",
"p. c #ABA9A6",
"a. c #AEACAA",
"s. c #B7A9A5",
"d. c #B1AEAB",
"f. c #A6BFA1",
"g. c #B2B1AE",
"h. c #AAA9BD",
"j. c #A5A3BB",
"k. c #B6B4B1",
"l. c #B9B6B3",
"z. c #BCBAB5",
"x. c #BEBCB9",
"c. c #C2928F",
"v. c #D89692",
"b. c #E38582",
"n. c #E28A87",
"m. c #E88884",
"M. c #E68D8A",
"N. c #EB8582",
"B. c #E79592",
"V. c #E59E9A",
"C. c #DFA39F",
"Z. c #E1A29E",
"A. c #D9A7A4",
"S. c #DFA8A3",
"D. c #D8ADAA",
"F. c #DDB4AF",
"G. c #C1BDB4",
"H. c #C1BDBC",
"J. c #DCB5B0",
"K. c #DEB8B3",
"L. c #DFBDB9",
"P. c #D4BBB8",
"I. c #E0AEAA",
"U. c #E1B9B5",
"Y. c #A4C09F",
"T. c #ABC2A6",
"R. c #AEC1A9",
"E. c #B0C3AB",
"W. c #B6C6B1",
"Q. c #BFC7B9",
"!. c #B8C4B2",
"~. c #C4C3BD",
"^. c #C2C9BD",
"/. c #C4C2B1",
"(. c #DBC4BF",
"). c #D3C0BC",
"_. c #8685DD",
"`. c #B9B7C3",
"'. c #BEBCC3",
"]. c #B8B6CE",
"[. c #BEBCCF",
"{. c #B6B4C1",
"}. c #ACAAD8",
"|. c #B6B5D7",
" X c #BCBAD1",
".X c #C1BFCD",
"XX c #C6C4C2",
"oX c #CAC6C2",
"OX c #C7CBC1",
"+X c #CCCAC5",
"@X c #C2C0CD",
"#X c #CECCC9",
"$X c #DEC7C3",
"%X c #DECBC6",
"&X c #D1CECB",
"*X c #DBCEC9",
"=X c #CFD1CC",
"-X c #C5D2CD",
";X c #D4D2C6",
":X c #D9D7C7",
">X c #DDDBC4",
",X c #D4D2CD",
"<X c #DAD6CD",
"1X c #DCDACE",
"2X c #C9C7D2",
"3X c #CDD5D1",
"4X c #C6DBD6",
"5X c #CFDAD6",
"6X c #C6DCD8",
"7X c #CDDDD9",
"8X c #D6D4D1",
"9X c #DAD5D3",
"0X c #D7DAD5",
"qX c #DCDAD4",
"wX c #DFD3D9",
"eX c #D4DED9",
"rX c #DFDDD9",
"tX c #E4C8C4",
"yX c #E1DEC1",
"uX c #E2DDD3",
"iX c #E2D5DB",
"pX c #E1DEDA",
"aX c #CEE0DB",
"sX c #D6E2DD",
"dX c #DAE3DD",
"fX c #E6E4C5",
"gX c #F0EEC3",
"hX c #F3F1C2",
"jX c #E8E6D3",
"kX c #E2E0DC",
"lX c #EAE5DF",
"zX c #EAE8D4",
"xX c #E6DCE1",
"cX c #E8D8E2",
"vX c #D6E6E1",
"bX c #D9E7E2",
"nX c #DDEAE4",
"mX c #DBEDE8",
"MX c #E5E4E3",
"NX c #E9E7E2",
"BX c #E2EBE6",
"VX c #EBEAE6",
"CX c #E3EDE8",
"ZX c #EDEDEB",
"AX c #F2EFED",
"SX c #EAF3EE",
"DX c #E5F2EE",
"FX c #F3F1EE",
"GX c #F1EFF0",
"HX c #EAF6F2",
"JX c #F4F4F3",
"KX c #F9F6F5",
"LX c #F1F9F7",
"PX c #F9F8F6",
"IX c #F0FEFD",
"UX c #FDFDFD",
/* pixels */
"qXqXqXrXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXrXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXrXqXqXqX",
"qXqXqXqXqXqXqXrXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqX<XqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqX",
"qXqXqXqXqXqXqX9XqXqX9XqXqXqXrXrXrXrXrXrXuXrXrXrXrXrXrXrXrXrXrXrXuXrXrXrXrXrXrXrXuXqXqXqXqXqXqXqX",
"qXqXqXqXrXkXkXkXkXpXkXkXkXrX+X+X+X+X+X+X+X+X+X&X#X+X+X+X+X+X+X+X+X#X+X#X+X+X+X+X+X+X,XkXqXqXqXqX",
"qXqXqXpXUXPXPXKXKXUXPXPXPXk.a.z.l.H.H.l.l.z.z.u.l.l.z.H.G.k.l.z.g.i.z.l.z././.l.z.k.&XUXpXqXqXqX",
"rXqX9XpXPXqX0XdXbXL.<XrXH.;.#X9X#XT.T.,XqX,X,Xg.8XqX^.T.W.9X,X8X+Xz.0X,X2X}.|.,X8X,XMXUXrXqXqXqX",
"qXqXqXdXPXqX*XV.h w I.nXx.;.+X+XZ Z N S Q.&X#Xd.9X9.B Z - P ,X,XXXk.<X].@...@.;X+X+XpXUXrXqXqXqX",
"qXqXqXrXUXtXi w w w I.BXx.;.&X^.R 9XT.= 4.wX#Xg.9Xf.7.cXI - ^.8X~.l.,X@X[.O.+.1X#X+XpXUXrXqXqXqX",
"qXrXqXpXPXqX$XB.g w D.nXz.;.+X,XwXiX4.- 8.9X#Xg.+X&XwXwXH N OX,XXXl.,X#XfX#.X.:X#X#XkXUXrXqXqXrX",
"qXqXqXkXPXqX0XsXSX* s.VXz.;.+X,X9XT - J ,X#X,Xg.+X9XOXH - 4.9X,X~.l.,X#XhX%.+.gX,X+XpXUXuXqXqXqX",
"qXqX9XkXPXqXkXkX+XO >.FXx.-.+X#XD = B I !.&X#Xg.9Xg.B = A 4.OX,XXXk.,X.X_.+.o.*. X,XrXUXrXqXqXqX",
"qXqXqXkXPXkX0., o X 7 z.;.&X+XH H J F 9.iX=Xa.9Xf.D J G D ^.8XXXk.1X[.#.%.&.$.}.;XrXUXrXqXqXqX",
"qXqX<XkXPX~.2.>.1.0.1.,.u.;.XX&XwX9XwXwX&X+X+Xg.,XqXxXiXiXcX8X8X+Xd.#X#X>X>X>X>X;XXXqXUXrXqXqXqX",
"qXqXqXrXk.-.>.,.>.>.<.<.;.u.MXNXkXMXpXpXNXNXVXg.g.l.g.g.g.g.k.l.k.8XVXMXMXMXxXMXNXMXSXUXrXqXqXqX",
"qXqXrX+Xa.#X#X6X4X-X+X+XXXkXUXSXAXAXLXIXFXJXqX0.oXXX~.XX,X:XXX~.+XPXJXSXAXJXIXJXJXNX&XUXrXqXqXqX",
"qXqXrX+Xz.0XD.v l n.,X,X#XNXAX,XbXeXJ.N.,XrX2.1.9X,X,X,X| { +X,X8XKX9XsXsX*Xm.J.dXl.d.UXrXqXqXqX",
"qXqXrX#Xk.eXl f j w l 7XXXNXJX(.N.g w y qXkXu.1.,X#X1X] : > x.,X,XPXqXZ.x y w V.mXG.g.UXrX0XqXqX",
"qX<XrX+Xz.,X#X&XP.t l 7X+XNXLXS.u w w y qXpXu.2.,X1X .) .: XX,X8XPX9Xz w w w Z.BXG.g.UXrXqXqXqX",
"rXqXrX#Xl.,X6Xf w e A.3X+XNXAX0XdXU.k q qXpX0.1.qXh.: y.| : j.,X8XPXwXbX*XM.0 v.BXz.g.UXrX9XqXqX",
"qXqXrX+Xz.,XP.5X#Xe g eXoXNXJX<XwXSX-X+ NXkX0.1.kXt.W ^ W E ~ XX9XPXqXqXkXUX& 1.KXl.k.UXrXqXrXqX",
"qXqXrX+Xl.eXl i i w b.5XXXVXFX,X,Xg.6 . >.qX0.2.,X&X&XuX .; XX,X8XKX0XqXH.;.X 2 ,Xz.d.UXrXqXqXqX",
"qXqXrX+Xl.8XP.b.n D.3X#X+XNXJXqX8 $ @ # + d p.1.,X#X&X,X{.e.#X&X8XKXNX2.& @ # @ 1 d.l.UXrXqXqXqX",
"qXqXrX+Xz.,X,X7XaX3X&X,X+XNX8X3.0.p.d.p.p.0.>.1.,X+X+X+X,X1X+X+X8XZXi.1.u.p.i.i.0.:.d.UXrXqXqXqX",
"qXqXqX#Xu.g.a.d.d.d.g.d.g.g.0.1.1.1.<.1.1.3.1.8XPXJXJXJXAXGXJXJXGXZXrXbXpXqXrXrXpXxXMXUXrXqXqXqX",
"qXqXrX+Xl.,X9XwXwXwX&X#X,Xg.XX8X,X8XuXqX9X,X#XJXZXkXMXCXDXVXMXkXg.PXZXVXVXHXHXVXZX9X~.UXrX9XqXqX",
"qXqXrX;Xl.9X6.F Z K ^.&X,Xl.~.,X#X:X] ! y.qXoXJXkXsXbXK.x b bX&X1.JX9XsXqXZ.g Z.nXl.a.UXrXqXrXqX",
"qXqXkX+Xl.iXJ Y 7.- K wX,Xl.XX,XqX} Q ; w.1X+XJXVXm.u w w x mX,X3.PXuXv t w w V.BXz.g.UXrXqXqXqX",
"qXqXqX+Xl.,X+XiXiXC G wX,Xk.~.qXe./ '.: t.jXXXFXBXI.h r w l mX*X2.KX9Xm.p e w Z.BXG.g.UXrXqXqXqX",
"qXqXuX+Xl.,X9X#XK = 5.9X,Xl.oX#X> ` { : _ `.,XJXlXdXvXuXs a CX&X2.PX0XbXsXtXm c.CXz.g.UXrX0XqXqX",
"qXqXrX#Xl.qXT.S - U ,X#X8Xl.XX+X[ ] ( : ~ h.,XJXlX9XpXUX9 1 UX,X2.PXrXrXkXUX% 1.UXz.g.UXrXqXqXqX",
"qXqXrX+Xl.iXG - B V L wX=Xk.~.,XqXjX#X: t.jXXXJXNX,X1.5 o . 9 ~.0.JXkX+X=.< @ 1.z.g.UXrX<XqXqX",
"qXqXpX+Xl.&X^.^.Q.!.^.#X,Xk.~.,X+X#X+X'.oX&X+XJXVXg.5 2 5 5 2 1.0.FXrX,.3 2 7 3 6 u.k.UXrXqXrXqX",
"qXqXrX#Xx.0X8XqX9X9X9X8XqXx.oX0X8X8X8X9X8X,X8XGXd.2.k.k.a.g.k.0.i.MX2.i.g.g.d.d.k.<.x.UXpXqXqXqX",
"qXqXqXpXUXPXPXPXPXPXPXPXJXMXUXPXPXPXPXPXPXUXZXZXPXJXJXGXJXJXJXJXMXJXLXJXJXJXJXJXJXJXMXUXpXqXqXqX",
"qXqXqXpXPXqXrXqXrXqXqXMXz.x.PX9XqXrXrXqXqXkXu.rXZX9XrXqXrXqXrX8Xu.JXpXqXqXpXqXqXpX~.k.UXrXqXqXqX",
"qXqXqXkXPXqXqXqX0XqXqXpXk.x.KX8XqXqXqXqXqXdX3.pXVX8XqXqXqXqXqX,X2.PXqXqXqXqXqX0XpXz.a.UXrXqXqXqX",
"qXqXqXkXPXqXqXqXqXqXqXkXk.x.PX8XqXqXrXqX0XpX3.dXVX8XqXqXqXqXqX:X2.PXrXqXqXqXqXqXkXx.k.UXrX9XqXqX",
"qXqX9XkXPXqXqXqXqXqXqXkXg.x.PX8XqXqXqXqX0XxX3.pXVX9XrXqXqXqXrX,X2.JXwXqXqXqXqXqXkXx.a.UXrXqXqXqX",
"qXqXqXkXPXqXqXqXqXqXqXkXk.x.PX,XqXqXwXqXqXpX3.pXVXqXqXqXqXqXqX,X2.PXrXqXqXqXqXqXkXx.d.UXrXqXrXqX",
"qXqXqXkXPXqXqXqXqXqX9XpXk.x.PX<XqX8XqXqXqXpX2.dXVX,XqXqXqXqXqX,X3.PX0XqXqXqXqX8XkXz.g.UXrXqXqXqX",
"qXqXqXkXPXpXkXkXdXpXpXNXz.x.PXrXkXkXkXkXpXkXu.rXZXuXkXkXkXkXkXqX2.PXkXpXkXkXkXkXNX~.k.UXrX9XqXqX",
"rXqXqXkXJXx.x.x.z.x.z.~.2.x.ZXl.x.z.x.x.x.~.,.rXqXl.x.x.z.x.H.l.<.JX~.z.x.z.x.x.~.0.d.UXrXqXqXqX",
"qXqX8XkXkXg.g.g.g.g.g.k.a.qX,Xa.k.g.g.g.g.g.k.NXx.a.g.g.g.g.g.a.x.MXk.g.g.d.g.d.g.d.#XUXrXqXqXrX",
"qXqXqXkXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXUXrXqXqXqX",
"qXqXqXqXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXrXpXrXrXrXrXrXrXrXpXrXrXrXrXrXrXrXrXrXrXrXqXqXqXqX",
"qXqXqXqXqXqXqX<XqX8XqXqXqXqX8XqXqXqX8XqXqXqX<XqXqXqX9XqXqXqXqX9XqXqX9XqXqXqXqXqXqXqXqXqXqXqXqXqX",
"qXqXqXqXqXqXqXrXqXqXqXqXqXqXqXqXrXqXqXqXqXqXqXrXqXqXqXqXqXqXqXrXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqXqX",
"qXqXqXrXqXqXqXqXqXqXrXqXqXqXqXrXqXqXqXqXqXqXqXqXqXrXqXqXqXqXqXqXqXrXqXqXqXqXqXqXqXqXqXrXqXqXqXqX"
};
const char *const *const xpm_icons[] = {
xpm_icon_0,
xpm_icon_1,
xpm_icon_2,
};
const int n_xpm_icons = 3;
| 23.331719 | 99 | 0.540006 |
0d7d64829a23b78950400497932684be09b0dc6e | 5,929 | h | C | src/library/blas/functor/include/functor_hawaii_dgemm_NT_MN48.h | JishinMaster/clBLAS | 3711b9788b5fd71d5e2f1cae3431753cdcd2ed76 | [
"Apache-2.0"
] | 615 | 2015-01-05T13:24:44.000Z | 2022-03-31T14:58:04.000Z | src/library/blas/functor/include/functor_hawaii_dgemm_NT_MN48.h | JishinMaster/clBLAS | 3711b9788b5fd71d5e2f1cae3431753cdcd2ed76 | [
"Apache-2.0"
] | 223 | 2015-01-12T21:07:18.000Z | 2021-11-24T17:00:44.000Z | src/library/blas/functor/include/functor_hawaii_dgemm_NT_MN48.h | JishinMaster/clBLAS | 3711b9788b5fd71d5e2f1cae3431753cdcd2ed76 | [
"Apache-2.0"
] | 250 | 2015-01-05T06:39:43.000Z | 2022-03-23T09:13:00.000Z | /* ************************************************************************
* Copyright 2014 Advanced Micro Devices, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ************************************************************************/
#include <functor.h>
#include <binary_lookup.h>
#include <iostream>
#define BUILD_KERNEL_FROM_STRING 0
#if BUILD_KERNEL_FROM_STRING
#include <dgemm_NT_MN48.clT>
#else
#include <dgemm_NT_MN48.spir.clT>
#endif
class clblasDgemmFunctorHawaii_NT_MN48 : public clblasDgemmFunctor
{
private: // Constructor & Destructor
clblasDgemmFunctorHawaii_NT_MN48(Args & args, cl_int & err);
~clblasDgemmFunctorHawaii_NT_MN48();
public: // Members inherited from clblasDgemmFunctor
virtual clblasStatus execute(Args & a);
public:
static clblasDgemmFunctorHawaii_NT_MN48 * provide(Args & args);
private:
typedef clblasFunctorCache<clblasDgemmFunctorHawaii_NT_MN48,bool> Cache ;
static Cache cache;
private:
cl_program program ;
};
clblasDgemmFunctorHawaii_NT_MN48::Cache clblasDgemmFunctorHawaii_NT_MN48::cache;
clblasDgemmFunctorHawaii_NT_MN48 *
clblasDgemmFunctorHawaii_NT_MN48::provide(clblasDgemmFunctor::Args & args)
{
//Work only if TRANSA == N, TRANSB == T, M and N multiple of 48
//Note: Are K%48 == 0 LDA LDB %2 == 0 and OFFA OFFB %2 == 0 required?
bool applicable = (args.transA == clblasNoTrans)
&& (args.transB == clblasTrans)
&& (args.M % 48 == 0)
&& (args.N % 48 == 0)
&& (args.K % 48 == 0)
&& (args.order == clblasColumnMajor) ;
if(!applicable)
{
return NULL;
}
cl_device_id dev;
cl_context ctxt;
cl_int err = getDeviceAndContext(args.queue, dev, ctxt);
if (err != CL_SUCCESS)
{
return NULL;
}
Cache::Lookup lookup(cache, ctxt, dev, true ) ;
if ( lookup.ok() ){
clblasDgemmFunctorHawaii_NT_MN48 * functor = lookup.get();
functor->retain(); // increment the reference counter to avoid deletion while it is still beeing used
return functor;
}
clblasDgemmFunctorHawaii_NT_MN48 * functor = new clblasDgemmFunctorHawaii_NT_MN48(args, err);
if (err != CL_SUCCESS)
{
return NULL;
}
lookup.set(functor) ;
return functor;
}
clblasDgemmFunctorHawaii_NT_MN48::clblasDgemmFunctorHawaii_NT_MN48(Args & args, cl_int & err) :
program(0)
{
//Hawaii kernel here only for test.
//Work only if TRANSA == N, TRANSB == T, M and N multiple of 48
//Note: Are K%48 == 0 LDA LDB %2 == 0 and OFFA OFFB %2 == 0 required?
cl_device_id device;
cl_context context;
cl_command_queue queue = args.queue;
err = getDeviceAndContext(queue, device, context);
if( err != CL_SUCCESS )
{
return;
}
BinaryLookup bl(context, device, "clblasDgemmFunctorHawaii_NT_MN48");
bl.variantInt(48);
if ( !bl.found() ) // may create empty file or may wait until file is ready
{
#if BUILD_KERNEL_FROM_STRING
// directly build from a char*
err = bl.buildFromSource(DGEMM_NT_MN48_KERNEL);
#else
// build from compiled version of the kernel (SPIR)
err = bl.buildFromBinary(DGEMM_NT_MN48_SPIR_KERNEL, sizeof(DGEMM_NT_MN48_SPIR_KERNEL));
#endif
if( err != CL_SUCCESS )
{
return;
}
}
this->program = bl.getProgram();
}
clblasDgemmFunctorHawaii_NT_MN48::~clblasDgemmFunctorHawaii_NT_MN48()
{
if (this->program) {
clReleaseProgram( this->program ) ;
}
}
clblasStatus clblasDgemmFunctorHawaii_NT_MN48::execute(Args & args)
{
cl_int err;
cl_command_queue queue = args.queue;
cl_kernel kernel = clCreateKernel( this->program, "dgemm", &err);
if (err != CL_SUCCESS) return clblasStatus(err) ;
int M = args.M, N = args.N, K = args.K;
int lda = args.lda, ldb = args.ldb, ldc = args.ldc;
int offsetA = args.offA;
int offsetB = args.offB;
int offsetC = args.offC;
setKernelArg<cl_mem>(kernel, 0, args.C);
setKernelArg<cl_mem>(kernel, 1, args.B);
setKernelArg<cl_mem>(kernel, 2, args.A);
setKernelArg<int>(kernel, 3, N);
setKernelArg<int>(kernel, 4, M);
setKernelArg<int>(kernel, 5, K);
setKernelArg<cl_double>(kernel, 6, args.alpha);
setKernelArg<cl_double>(kernel, 7, args.beta);
setKernelArg<int>(kernel, 8, ldc);
setKernelArg<int>(kernel, 9, ldb);
setKernelArg<int>(kernel, 10, lda);
setKernelArg<int>(kernel, 11, offsetC);
setKernelArg<int>(kernel, 12, offsetB);
setKernelArg<int>(kernel, 13, offsetA);
const size_t ls[2] = {8, 8};
const size_t bwi[2] = {6, 6};
size_t globalThreads[2];
unsigned int thx, thy;
thx = M/bwi[0] + ((M%bwi[0] != 0) ? 1 : 0); // Each PE updates (bwi[0] x bwi[1])=(6 x 6) values
thx = thx/ls[0] + ((thx%ls[0] != 0) ? 1 : 0); // Each work group is made of (ls[0] x ls[1])=(8 x 8) PE
thx = ls[0] * thx;
thy = N/bwi[1] + ((N%bwi[1] != 0) ? 1 : 0); // Each PE updates (bwi[0] x bwi[1])=(6 x 6) values
thy = thy/ls[1] + ((thy%ls[1] != 0) ? 1 : 0); // Each work group is made of (ls[0] x ls[1])=(8 x 8) PE
thy = ls[1] * thy;
globalThreads[0] = thx;
globalThreads[1] = thy;
err = clEnqueueNDRangeKernel(queue, kernel, 2, NULL,
globalThreads, NULL ,
args.numEventsInWaitList,
args.eventWaitList,
args.events);
clReleaseKernel(kernel) ;
return clblasStatus(err) ;
}
| 28.099526 | 106 | 0.640749 |
d4a91e03c3929a938900d47f5f8065d2faf1f68e | 523 | h | C | Alpha/Utility/General/ALPHAUtility.h | huangboju/Alpha | 278e5772c38b3e2c2464718e8f2327c455020006 | [
"MIT"
] | 797 | 2015-01-26T02:51:19.000Z | 2021-11-22T07:03:36.000Z | Alpha/Utility/General/ALPHAUtility.h | huangboju/Alpha | 278e5772c38b3e2c2464718e8f2327c455020006 | [
"MIT"
] | 61 | 2015-05-06T16:17:40.000Z | 2017-08-18T14:58:49.000Z | Alpha/Utility/General/ALPHAUtility.h | huangboju/Alpha | 278e5772c38b3e2c2464718e8f2327c455020006 | [
"MIT"
] | 64 | 2015-01-26T02:51:26.000Z | 2021-10-29T18:03:33.000Z | //
// ALPHAUtility.h
// Alpha
//
// Created by Dal Rupnik on 17/6/15.
// Copyright © 2015 Unified Sense. All rights reserved.
//
@import Foundation;
@import UIKit;
#define ALPHAFloor(x) (floor([[UIScreen mainScreen] scale] * (x)) / [[UIScreen mainScreen] scale])
#define ALPHAEncodeBool(expr) ( (expr) ? @"Yes" : @"No" )
#define ALPHAEncodeString(expr) ( (expr != nil) ? [expr description] : @"" )
@interface ALPHAUtility : NSObject
+ (UIInterfaceOrientationMask)infoPlistSupportedInterfaceOrientationsMask;
@end
| 23.772727 | 98 | 0.697897 |
3598788918f5de39622332b728a42a1705ac5cfe | 38 | h | C | contrib/libs/openssl/include/openssl/des.h | Lokutrus/catboost | 66eb1f404897411b7b05e549e151a1736d93f203 | [
"Apache-2.0"
] | 1 | 2019-07-08T09:14:39.000Z | 2019-07-08T09:14:39.000Z | contrib/libs/openssl/include/openssl/des.h | tspannhw/catboost | 8b5adff365e82794f1876649898cc491cf81ab12 | [
"Apache-2.0"
] | null | null | null | contrib/libs/openssl/include/openssl/des.h | tspannhw/catboost | 8b5adff365e82794f1876649898cc491cf81ab12 | [
"Apache-2.0"
] | null | null | null | #pragma once
#include <openssl/des.h>
| 12.666667 | 24 | 0.736842 |
775afc13d7e80ed0fba3631e5b6fa02516389931 | 877 | c | C | lib/libgfx/NewBitmapCustom.c | kgalikgh/demoscene | 62e74002bf8c0962647c6977419bea90b67fd5b7 | [
"Artistic-2.0"
] | 80 | 2015-02-10T19:33:04.000Z | 2022-02-12T10:29:43.000Z | lib/libgfx/NewBitmapCustom.c | kgalikgh/demoscene | 62e74002bf8c0962647c6977419bea90b67fd5b7 | [
"Artistic-2.0"
] | 30 | 2015-12-19T23:08:22.000Z | 2022-02-25T15:50:47.000Z | lib/libgfx/NewBitmapCustom.c | kgalikgh/demoscene | 62e74002bf8c0962647c6977419bea90b67fd5b7 | [
"Artistic-2.0"
] | 17 | 2015-02-10T19:33:31.000Z | 2022-02-24T07:10:57.000Z | #include <bitmap.h>
#include <memory.h>
BitmapT *NewBitmapCustom(u_short width, u_short height, u_short depth,
u_char flags)
{
BitmapT *bitmap = MemAlloc(sizeof(BitmapT), MEMF_PUBLIC|MEMF_CLEAR);
u_short bytesPerRow = ((width + 15) & ~15) / 8;
bitmap->width = width;
bitmap->height = height;
bitmap->bytesPerRow = bytesPerRow;
/* Let's make it aligned to short boundary. */
bitmap->bplSize = bytesPerRow * height;
bitmap->depth = depth;
bitmap->flags = flags & BM_FLAGMASK;
if (!(flags & BM_MINIMAL)) {
u_int memoryFlags = 0;
/* Recover memory flags. */
if (flags & BM_CLEAR)
memoryFlags |= MEMF_CLEAR;
if (flags & BM_DISPLAYABLE)
memoryFlags |= MEMF_CHIP;
else
memoryFlags |= MEMF_PUBLIC;
BitmapSetPointers(bitmap, MemAlloc(BitmapSize(bitmap), memoryFlags));
}
return bitmap;
}
| 25.057143 | 73 | 0.653364 |
90a229cbb094367835562db215f6a3acda506ad9 | 3,113 | c | C | modules/m_privs.c | happyhater/ircd | b24763a44e8e5cf0ed476b593e9e77ad23647ae4 | [
"Unlicense"
] | null | null | null | modules/m_privs.c | happyhater/ircd | b24763a44e8e5cf0ed476b593e9e77ad23647ae4 | [
"Unlicense"
] | null | null | null | modules/m_privs.c | happyhater/ircd | b24763a44e8e5cf0ed476b593e9e77ad23647ae4 | [
"Unlicense"
] | null | null | null | #include "stdinc.h"
#include "client.h"
#include "common.h"
#include "numeric.h"
#include "send.h"
#include "msg.h"
#include "parse.h"
#include "modules.h"
#include "s_conf.h"
#include "s_newconf.h"
static int me_privs(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
static int mo_privs(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]);
struct Message privs_msgtab = {
"PRIVS", 0, 0, 0, MFLG_SLOW,
{mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_privs, 0}, {mo_privs, 0}}
};
mapi_clist_av1 privs_clist[] = {
&privs_msgtab,
NULL
};
/* there is no such table like this anywhere else */
static struct mode_table auth_client_table[] = {
{"resv_exempt", FLAGS2_EXEMPTRESV },
{"kline_exempt", FLAGS2_EXEMPTKLINE },
{"flood_exempt", FLAGS2_EXEMPTFLOOD },
{"spambot_exempt", FLAGS2_EXEMPTSPAMBOT },
{"shide_exempt", FLAGS2_EXEMPTSHIDE },
{"jupe_exempt", FLAGS2_EXEMPTJUPE },
{"extend_chans", FLAGS2_EXTENDCHANS },
{NULL, 0}
};
DECLARE_MODULE_AV1(privs, NULL, NULL, privs_clist, NULL, NULL, "");
static void show_privs(struct Client *source_p, struct Client *target_p)
{
char buf[512];
struct mode_table *p;
buf[0] = '\0';
if (target_p->localClient->privset)
rb_strlcat(buf, target_p->localClient->privset->privs, sizeof buf);
if (IsOper(target_p))
{
if (buf[0] != '\0')
rb_strlcat(buf, " ", sizeof buf);
rb_strlcat(buf, "operator:", sizeof buf);
rb_strlcat(buf, target_p->user->opername, sizeof buf);
if (target_p->localClient->privset)
{
if (buf[0] != '\0')
rb_strlcat(buf, " ", sizeof buf);
rb_strlcat(buf, "privset:", sizeof buf);
rb_strlcat(buf, target_p->localClient->privset->name, sizeof buf);
}
}
p = &auth_client_table[0];
while (p->name != NULL)
{
if (target_p->flags2 & p->mode)
{
if (buf[0] != '\0')
rb_strlcat(buf, " ", sizeof buf);
rb_strlcat(buf, p->name, sizeof buf);
}
p++;
}
sendto_one_numeric(source_p, RPL_PRIVS, form_str(RPL_PRIVS),
target_p->name, buf);
}
static int me_privs(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Client *target_p;
if (!IsOper(source_p) || parc < 2 || EmptyString(parv[1]))
return 0;
/* we cannot show privs for remote clients */
if((target_p = find_person(parv[1])) && MyClient(target_p))
show_privs(source_p, target_p);
return 0;
}
static int mo_privs(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
struct Client *target_p;
if (parc < 2 || EmptyString(parv[1]))
target_p = source_p;
else if(!IsOperAdmin(source_p))
{
sendto_one(source_p, form_str(ERR_NOPRIVS),
me.name, source_p->name, "admin");
return 0;
}
else
{
target_p = find_named_person(parv[1]);
if (target_p == NULL)
{
sendto_one_numeric(source_p, ERR_NOSUCHNICK,
form_str(ERR_NOSUCHNICK), parv[1]);
return 0;
}
}
if (MyClient(target_p))
show_privs(source_p, target_p);
else
sendto_one(target_p, ":%s ENCAP %s PRIVS %s",
get_id(source_p, target_p),
target_p->servptr->name,
use_id(target_p));
return 0;
}
| 24.904 | 100 | 0.680694 |
fc918e1ce747bc07cbd95541d12ec33906b0e016 | 88 | h | C | App/Utils.h | Tomasito665/mtv-rhythm-generator | 6cdfbdcdd745148d477ce3b7599912dc36cd2848 | [
"MIT"
] | null | null | null | App/Utils.h | Tomasito665/mtv-rhythm-generator | 6cdfbdcdd745148d477ce3b7599912dc36cd2848 | [
"MIT"
] | null | null | null | App/Utils.h | Tomasito665/mtv-rhythm-generator | 6cdfbdcdd745148d477ce3b7599912dc36cd2848 | [
"MIT"
] | null | null | null | #pragma once
#include <cinder/Color.h>
ci::Color toGrayscale(const ci::Color& color);
| 14.666667 | 46 | 0.727273 |
69472415018b7d089d44a56da25e2dc2c51a5b67 | 2,275 | h | C | sutil/MeshScene.h | soundsilence/Tracer | 3a71b2afcbd3debc34d601962a80967d8aa1cae0 | [
"MIT"
] | null | null | null | sutil/MeshScene.h | soundsilence/Tracer | 3a71b2afcbd3debc34d601962a80967d8aa1cae0 | [
"MIT"
] | null | null | null | sutil/MeshScene.h | soundsilence/Tracer | 3a71b2afcbd3debc34d601962a80967d8aa1cae0 | [
"MIT"
] | null | null | null |
/*
* Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
*
* NVIDIA Corporation and its licensors retain all intellectual property and proprietary
* rights in and to this software, related documentation and any modifications thereto.
* Any use, reproduction, disclosure or distribution of this software and related
* documentation without an express license agreement from NVIDIA Corporation is strictly
* prohibited.
*
* TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
* INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
* SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
* LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
* BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
* INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES
*/
//-----------------------------------------------------------------------------
//
// MeshScene.h
//
//-----------------------------------------------------------------------------
#ifndef MESHSCENE_H
#define MESHSCENE_H
#include "SampleScene.h"
#include <sutil.h>
#include <optixu/optixpp_namespace.h>
#include <optixu/optixu_math_namespace.h>
#include <optixu/optixu_aabb_namespace.h>
#include <string>
//------------------------------------------------------------------------------
//
// MeshScene class
//
//------------------------------------------------------------------------------
class MeshScene : public SampleScene
{
public:
SUTILAPI MeshScene() {}
SUTILAPI virtual ~MeshScene() {}
// Setters for controlling application behavior
SUTILAPI void setMesh( const char* filename ) { m_filename = filename; }
SUTILAPI void loadAccelCache();
SUTILAPI void saveAccelCache();
protected:
std::string getCacheFileName();
std::string m_filename;
optix::GeometryGroup m_geometry_group;
SUTILAPI const static int WIDTH;
SUTILAPI const static int HEIGHT;
};
#endif // MESHSCENE_H
| 33.455882 | 89 | 0.656264 |
1140079a4c54a718e796483a7bf4af997421c279 | 217 | h | C | AerodromeUI/NSDictionary+AERIcons.h | digital-pers0n/Aerodrome | 6cef0434650b5bd2c2edb59a2cf4e5cdae1039bf | [
"MIT"
] | null | null | null | AerodromeUI/NSDictionary+AERIcons.h | digital-pers0n/Aerodrome | 6cef0434650b5bd2c2edb59a2cf4e5cdae1039bf | [
"MIT"
] | null | null | null | AerodromeUI/NSDictionary+AERIcons.h | digital-pers0n/Aerodrome | 6cef0434650b5bd2c2edb59a2cf4e5cdae1039bf | [
"MIT"
] | null | null | null | //
// NSImage+AERIcons.h
// Aerodrome
//
// Created by Terminator on 8/29/16.
//
//
#import <Cocoa/Cocoa.h>
@interface NSDictionary (AERIcons)
-(NSDictionary *)signalIcons;
-(NSDictionary *)menuBarIcons;
@end
| 12.055556 | 37 | 0.677419 |
114854cec4c207f2c376b0ab0909c622ced7f59b | 65,326 | c | C | reuse/c/rFsearch.c | cocolab8/cocktail | 6b4dfe28fcca30098c9a053f48e5a395c006009d | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | reuse/c/rFsearch.c | cocolab8/cocktail | 6b4dfe28fcca30098c9a053f48e5a395c006009d | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | reuse/c/rFsearch.c | cocolab8/cocktail | 6b4dfe28fcca30098c9a053f48e5a395c006009d | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | /* Copyright (c) 1999 Dr. Josef Grosch, CoCoLab - Datenverarbeitung
This file contains proprietary and confidential information and
remains the property of CoCoLab. Use, disclosure, or reproduction
is prohibited except as permitted by express written license agreement
with CoCoLab.
Phone: +49-7841-669144
Fax : +49-7841-669145
Email: grosch@cocolab.com
*/
/* Project: Cocktail Reuse Library
* Descr: Search a filename in a list of directories
* Author: Dr. Juergen Vollmer <vollmer@cocolab.com>
* Id: rFsearch.c,v 1.57 2009/08/03 15:25:29 vollmer Exp $
*/
/****************************************************************************/
/* If the `assert' macros below are triggered, indicate programming error :-)
* i.e. wrong initialization / finalization etc.
*/
/* # undef DEBUG_RFSEARCH */
# ifdef DEBUG_RFSEARCH
static int debug_func_nesting = 0;
# define DENTER(args) \
{if (rFsearchShowDebug) { \
printf ("%*s| ", debug_func_nesting+2, " "); \
printf args; \
} \
debug_func_nesting += 2; \
}
# define DEXIT(args) \
{if (rFsearchShowDebug) { \
printf ("%*s| ", debug_func_nesting+2, " "); \
printf args; \
} \
debug_func_nesting -= 2; \
}
# define DPRINTF(args) \
{if (rFsearchShowDebug) { \
printf ("%*s| ", debug_func_nesting+2, " "); \
printf args; \
} \
}
/* enable assert macro's in any case */
# undef NDEBUG
# else
# define DENTER(func)
# define DEXIT(args)
# define DPRINTF(args)
/* disable assert macro's */
# ifndef NDEBUG
# define NDEBUG
# endif
# endif
/****************************************************************************/
# include <assert.h>
# include <stdlib.h>
# include <stdio.h>
# include <ctype.h>
# include "rSystem.h"
# include "rMemory.h"
# include "rSystem.h"
# include "DynArray.h"
# include "rFsearch.h"
# include "rString.h"
# ifdef DEBUG_RFSEARCH
rbool rFsearchShowDebug = rtrue;
# else
rbool rFsearchShowDebug = rfalse;
# endif
/****************************************************************************
* UNIX specific stuff
****************************************************************************/
# ifdef rFsearch_UNIX
# include <sys/types.h>
# include <sys/stat.h>
# include <dirent.h>
# define STRCMP strcmp
# define STRCASECMP strcasecmp
/* handling file system directories */
struct sFileSystemDir {
# ifdef rFsearch_HAVE_DIR_ACCESS
DIR *dir;
struct dirent *entry;
# endif
rbool first; /* true iff the next call to
* rFileSystemNext is the first call
*/
};
const char rDirSeparator = '/';
# endif
/***************************************************************************
* MICROSOFT specific stuff
***************************************************************************/
# ifdef rFsearch_MICROSOFT
# include <sys/types.h>
# include <sys/stat.h>
# include <ctype.h>
# if _MSC_VER >= 1400
/* MS Visual Studio 2005 changed names (and return values) ... */
# include <io.h>
# define FindClose(D) _findclose(D)
# define FindFirstFile(N,E) _findfirst(N,E)
# define FindNextFile(N,E) (_findnext(N,E)==0)
/* NOTE: _findnext() returns 0 if a file is found
* FindNextFile() returns 1 if a file is found
*/
# define cFileName name
# define MAX_PATH _MAX_PATH
# define HANDLE intptr_t
# define WIN32_FIND_DATA struct _finddata_t
# define INVALID_HANDLE_VALUE -1L
# else
# include <windows.h>
# endif
/* Microsoft: all comparison is done case-insensitive */
# define STRCMP _stricmp
# define STRCASECMP _stricmp
struct sFileSystemDir {
# ifdef rFsearch_HAVE_DIR_ACCESS
HANDLE dir;
WIN32_FIND_DATA entry;
# endif
rbool first; /* true iff the next call to
* rFileSystemNext is the first call
*/
};
const char rDirSeparator = '\\';
# endif
/****************************************************************************
* MVS specific stuff
****************************************************************************/
# ifdef rFsearch_MVS
# define STRCMP strcmp
# define STRCASECMP strcasecmp
/* handling file system directories */
struct sFileSystemDir {
# ifdef rFsearch_HAVE_DIR_ACCESS
DIR *dir;
struct dirent *entry;
# endif
rbool first; /* true iff the next call to
* rFileSystemNext is the first call
*/
};
const char rDirSeparator = '\0';
# endif
/****************************************************************************/
static rbool case_sensitive = rtrue;
/* true, if files should be searched in a case sensitive way, false else. */
typedef int (*tcmp_StringFunc) (const char*, const char*);
static tcmp_StringFunc cmp_string_func = NULL;
/****************************************************************************/
static unsigned short current_set = 0;
/* 0: use all directory sets */
/****************************************************************************/
static char *find_file_last_search_path = NULL;
/****************************************************************************/
typedef enum {
unknown_file_state,
file_readable,
file_not_readable
} tFileState;
/* String with its length and size */
typedef struct {
char *Str;
size_t Len; /* = strlen (Str) */
size_t Size; /* = number of bytes allocated for `Str' */
tFileState file_state; /* if used to store a filename in the cache,
* the readability state of that file, otherwise
* undefined.
*/
} tStringLS;
# define INIT_STRING {NULL,0,0,unknown_file_state}
# define STRING_RESERVE 10 /* When allocating so much extra space
* is added. E.g. adding \* for Microsoft
* directory names
*/
/* linked list of directories */
# define INIT_MAX_DIR_ENTRIES 100 /* initial size of "Entries" */
typedef struct sDirEntry *tDirEntryPtr;
typedef struct sDirEntry {
tStringLS Dir; /* a trailing '/' will be added if needed */
long Mark; /* Mark >= 0 : given by the user
* Mark == NO_DIR_MARK : "no_dir", see below
* Mark == ROOT_DIR_MARK : "root_dir", see below
* Mark == AUTO_CACHE_MARK : directory added when
* in rFindFile the searched filename
* contains a "/", i.e. is a partial
* path.
* Only directories with Marks != AUTO_CACHE_MARK
* are used as search directories.
* Directories with Mark = AUTO_CACHE_MARK
* are appended at the end of the directory list.
*/
tStringLS *Entries; /* dynamic array of strings,
* If non-NULL contains the content of the directory
* alphabetically sorted.
*/
unsigned long Max; /* maximum number of elements of Entries */
long Last; /* Entries[0] .. Entries[Last] are used
* Last == -1: array contains no entries
*/
tDirEntryPtr Next; /* next entry in the list */
rbool Exists; /* true, iff the directory exists */
unsigned short Set; /* to which set it belongs, 0: all sets */
} tDirEntry;
# define DEFAULT_DIR_MARK -1
# define ROOT_DIR_MARK -2
# define AUTO_CACHE_MARK -3
/* list of directories given by the user (via rAddDir) */
static tDirEntryPtr user_dirs = NULL; /* pointer to the first list element */
static tDirEntryPtr dirs_end = NULL; /* pointer to the last list element */
static tDirEntryPtr current_user_dirs = NULL; /* start search with that dir */
/* list of auto cached directories */
static tDirEntryPtr auto_cached_dirs = NULL;
/* If the user has not provided a list of directories, use this one. It is
* the current directory
*/
static tDirEntryPtr no_dir = NULL;
/* Use this dir-entry for handling absolute path in rFindFile
* Its directory name is "/"
*/
static tDirEntryPtr root_dir = NULL;
/* linked list of extensions */
typedef struct sExtEntry *tExtEntryPtr;
typedef struct sExtEntry {
tStringLS Ext;
tExtEntryPtr Next; /* next entry in the list */
} tExtEntry;
/* list of extension given by the user (via rAddExtension) */
static tExtEntryPtr user_exts = NULL;
/* If the user has not provided any extensions, use this one. It is the
* empty extension.
*/
static tExtEntryPtr no_ext = NULL;
/* strlen of the longest extension */
static size_t ext_max_len = 0;
/* strlen of the longest directory name used so far */
static size_t dir_max_len = 0;
/* call function `conv' for each char of the string `s' */
# define STRCONV(conv,s) {char *PP; \
for (PP=(s); *PP; PP++) { \
*PP=(char)conv(*PP); \
}}
/* call function `conv' for each char of the string `s' until 'e'
* (a pointer to a char inside 's') is reached. '*e' is not converted.
*/
# define STRCONV2(conv,s,e) {char *PP; \
for (PP=(s); PP<(e); PP++) { \
*PP=(char)conv(*PP); \
}}
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
static void read_one_dir (tDirEntryPtr dir);
static rbool read_dir (tDirEntryPtr dir);
static void read_dir_no_case (tDirEntryPtr dir);
# endif
#define use_dir(set) ((current_set == 0) || (current_set == (set)))
/* return true, if the directory should be searched */
static void print_dir (FILE *file, tDirEntryPtr dir);
static void print_dirs (FILE *file, tDirEntryPtr dir);
/****************************************************************************
* Handling strings
****************************************************************************/
static tStringLS init_String_init = INIT_STRING;
static void init_String (tStringLS *s)
/* initializes `s', used at places where an assignment of INIT_STRING is
* not syntactical legal.
*/
{
memcpy (s, &init_String_init, sizeof (tStringLS));
}
/****************************************************************************/
static void free_String (tStringLS *s)
/* Deallocates a tStringLS */
{
if (s->Str != NULL) {
Free (s->Size, s->Str);
s->Str = NULL;
s->Size = 0;
}
}
/****************************************************************************/
static void alloc_String (tStringLS *s, size_t requested_size)
/* Allocates a string large enough to hold `requested_size + STRING_RESERVE'
* char's. `s' must be initialized.
* If `s.str' is already large enough nothing is done.
*/
{
requested_size += STRING_RESERVE;
if (requested_size >= s->Size) {
free_String (s);
s->Size = 2 * requested_size;
s->Str = Alloc (s->Size);
}
s->Len = 0;
}
/****************************************************************************/
static void copy_String (tStringLS *dest, const tStringLS *src)
/* allocate a tStringLS and copy src into it */
{
alloc_String (dest, src->Len);
dest->Len = src->Len;
strcpy (dest->Str, src->Str);
}
/****************************************************************************/
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
static void copy_String_char (tStringLS *dest, const char c)
/* allocate a tStringLS and copy c into it */
{
alloc_String (dest, 2);
dest->Len = 1;
dest->Str[0] = c;
dest->Str[1] = '\0';
}
# endif
/****************************************************************************/
static void copy_String_str (tStringLS *dest, const char *src)
/* allocate a tStringLS and copy src into it */
{
size_t len = strlen (src);
alloc_String (dest, len);
dest->Len = len;
strcpy (dest->Str, src);
}
/****************************************************************************/
static void empty_String (tStringLS *dest)
/* make the string empty */
{
dest->Len = 0;
}
/****************************************************************************/
static void append_String (tStringLS *dest, const tStringLS *src)
/* appends 'src' to 'dest' */
{
assert (dest->Size > dest->Len + src->Len);
strcpy (&dest->Str[dest->Len], src->Str);
dest->Len += src->Len;
assert (dest->Len == strlen (dest->Str));
}
/****************************************************************************/
static void append_String_char_ptr (tStringLS *dest,
const char *src,
int src_len)
/* appends 'src' to 'dest' */
{
assert (dest->Size > dest->Len + src_len);
strcpy (&dest->Str[dest->Len], src);
dest->Len += src_len;
assert (dest->Len == strlen (dest->Str));
}
/****************************************************************************/
static void append_String_char (tStringLS *dest, const char ch)
/* if ch != '\0' appends ch to 'dest' */
{
assert (dest->Size > dest->Len + 1);
if (ch) {
dest->Str[dest->Len++] = ch;
dest->Str[dest->Len] = '\0';
}
}
/****************************************************************************/
static int cmp_String (const void *A, const void *B)
/* compares two tStringLS, takes setting of case_sensitive into account */
{
return cmp_string_func (((tStringLS *)A)->Str, ((tStringLS *)B)->Str) ;
}
/****************************************************************************/
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
static void append_String_trailing_dirsep (tStringLS *s)
/* For Non-MVS: add a trailing / if needed */
{
/* terminating '/' required? */
if (s->Str[s->Len - 1] != rDirSeparator) {
/* our strings are large enough to store one more char,
* since we use STRING_RESERVE, c.f. alloc_String
*/
s->Str[s->Len++] = rDirSeparator;
s->Str[s->Len] = '\0';
}
}
# else
# define append_String_trailing_dirsep(s)
# endif
/****************************************************************************/
/****************************************************************************
* handling file and directory names
****************************************************************************/
static void replace_dir_separator (char *name)
/* Replaces directory separators. */
{
# ifdef rFsearch_UNIX
while (((name = strchr (name, '\\'))) != NULL) {
*name++ = '/';
}
# endif
# ifdef rFsearch_MICROSOFT
while (((name = strchr (name, '/'))) != NULL) {
*name++ = '\\';
}
# endif
# ifdef rFsearch_MVS
/* nothing */
# endif
}
/****************************************************************************/
static void copy_replace_dir_separator (tStringLS *name,
const char *str,
size_t len)
/* Copies `str' to `name' and replaces directory separators.
* `name' must be initialized but will be allocated here
*/
{
char *c;
alloc_String (name, len + 1);
name->Len = len;
for (c = name->Str; *str != '\0'; str++, c++) {
*c = *str;
# ifdef rFsearch_UNIX
if (*c == '\\') *c = '/';
# endif
# ifdef rFsearch_MICROSOFT
if (*c == '/') *c = '\\';
# endif
# ifdef rFsearch_MVS
/* nothing */
# endif
}
name->Str[len] = '\0';
}
void
rReplaceDirSeparator (char *name)
{
DENTER (("rReplaceDirSeparator: name = `%s'\n", name));
replace_dir_separator (name);
DEXIT (("res=`%s'\n", name));
}
/****************************************************************************/
static tStringLS rBaseName_buf1 = INIT_STRING;
static tStringLS rBaseName_buf2 = INIT_STRING;
char *rBaseName (char *name, char *buffer)
{
/* we use two buffers in order to avoid problems with overlapping strings */
char *res;
size_t len = strlen (name);
DENTER (("rBaseName name = `%s'\n", name));
copy_replace_dir_separator (&rBaseName_buf1, name, len);
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
{
char *slash;
slash = strrchr (rBaseName_buf1.Str, rDirSeparator);
/* skip trailing "/" */
while (slash != NULL && /* ok there is one */
*(slash+1) == '\0') { /* but it is a trailing one */
*slash = '\0';
slash = strrchr (rBaseName_buf1.Str, rDirSeparator);
}
if (buffer == NULL) {
/* return the stuff in a static variable */
if (slash == NULL) {
/* no directory part */
res = rBaseName_buf1.Str;
} else {
copy_String_str (&rBaseName_buf2, slash + 1);
res = rBaseName_buf2.Str;
}
} else if (name == buffer) {
/* inplace */
strcpy (name, (slash == NULL) ? rBaseName_buf1.Str : (slash + 1));
res = name;
} else {
/* separate buffer given by the user */
strcpy (buffer, (slash == NULL) ? rBaseName_buf1.Str : (slash + 1));
res = buffer;
}
# ifdef rFsearch_MICROSOFT
if (slash == NULL) {
/* no slash or only trailing ones */
char *colon = strchr (res, ':');
if (colon != NULL) {
res = colon + 1; /* that's ok, in worst case it's already '\0' */
}
}
# endif
}
# endif
# ifdef rFsearch_MVS
{
/* filename = dirname(member) */
char *from = strrchr (rBaseName_buf1.Str, '(');
char *to = strrchr (rBaseName_buf1.Str, ')');
if (from && to) {
from ++;
*to = '\0';
} else {
from = "";
}
if (buffer == NULL) {
/* return the stuff in a static variable */
copy_String_str (&rBaseName_buf2, from);
res = rBaseName_buf2.Str;
} else if (name == buffer) {
/* inplace */
strcpy (name, from);
res = name;
} else {
/* separate buffer given by the user */
strcpy (buffer, from);
res = buffer;
}
}
# endif
DEXIT (("res=`%s'\n", res));
return res;
}
/****************************************************************************/
static tStringLS rDirName_my_buffer = INIT_STRING;
char *rDirName (char *name, char *buffer)
{
char *res;
DENTER (("rDirName name = `%s'\n", name));
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
{
char *slash;
/* which buffer should be used */
if (buffer == NULL) {
/* static variable */
copy_replace_dir_separator (&rDirName_my_buffer, name, strlen (name));
res = rDirName_my_buffer.Str;
} else if (name == buffer) {
/* inplace */
res = name;
replace_dir_separator (res);
} else {
/* buffer given by user */
/* Note: replace_dir_separator does not use Len and Size of `s' */
res = buffer;
strcpy (res, name);
replace_dir_separator (res);
}
slash = strrchr (res, rDirSeparator);
/* remove trailing "/" */
while (slash != NULL && /* ok there is one */
*(slash+1) == '\0' && /* but is a trailing one */
slash != res) { /* but not the root directory */
*slash = '\0';
slash = strrchr (res, rDirSeparator);
}
if (slash == NULL) {
/* no directory part contained, or only trailing slashes given */
# ifdef rFsearch_MICROSOFT
/* do we have a drive letter? */
char *colon = strchr (res, ':');
if (colon != NULL) {
*(colon + 1) = '\0'; /* that's ok, in worst case it's already '\0' */
} else {
strcpy (res, ".");
}
# endif
# ifdef rFsearch_UNIX
strcpy (res, ".");
# endif
} else {
/* directory part contained */
if (slash == res) {
/* absolute path in the root directory */
res[0] = rDirSeparator;
res[1] = '\0';
} else {
*slash = '\0';
}
}
}
# endif
# ifdef rFsearch_MVS
{
/* filename = dirname(member) */
char *p = strrchr (name, '(');
if (buffer == NULL) {
/* static variable */
copy_String_str (&rDirName_my_buffer, name);
if (p) {
rDirName_my_buffer.Len -= p - name;
}
res = rDirName_my_buffer.Str;
} else if (name == buffer) {
/* inplace */
res = name;
} else {
/* buffer given by user */
strcpy (buffer, name);
res = buffer;
}
if (p) {
res[p - name] = '\0';
}
}
# endif
DEXIT (("res=`%s'\n", res));
return res;
}
/****************************************************************************/
static void dir_base_name (const char *name,
tStringLS *dir_name,
tStringLS *base_name)
{
copy_String_str (dir_name, name);
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
{
char *slash;
slash = strrchr (dir_name->Str, rDirSeparator);
/* skip trailing "/" */
while (slash != NULL && /* ok there is one */
*(slash+1) == '\0' && /* but is is a trailing one */
slash != dir_name->Str) { /* but not the root directory */
*slash = '\0';
dir_name->Len = slash - dir_name->Str;
slash = strrchr (dir_name->Str, rDirSeparator);
}
if (slash == NULL) {
/* no directory part contained, or only trailing slashes given */
# ifdef rFsearch_MICROSOFT
char *colon = strchr (dir_name->Str, ':');
/* do we have a drive letter? */
if (colon != NULL) {
copy_String_str (base_name, colon+1);
*(colon + 1) = '\0';
dir_name->Len = strlen (dir_name->Str);
} else {
copy_String (base_name, dir_name);
copy_String_char (dir_name, '.');
}
# endif
# ifdef rFsearch_UNIX
copy_String (base_name, dir_name);
copy_String_char (dir_name, '.');
# endif
} else {
*slash = '\0';
dir_name->Len = slash - dir_name->Str;
copy_String_str (base_name, slash + 1);
if (slash == dir_name->Str) {
/* root directory */
copy_String_char (dir_name, rDirSeparator);
}
}
assert (dir_name->Len == strlen (dir_name->Str));
assert (base_name->Len == strlen (base_name->Str));
}
# endif
# ifdef rFsearch_MVS
{
/* filename = dirname(member) */
char *p1 = strrchr (dir_name->Str, '(');
char *p2 = strrchr (dir_name->Str, ')');
if (p1 && p2) {
*p1 = '\0'; p1++;
*p2 = '\0';
} else {
p1 = "";
}
copy_String_str (base_name, p1);
}
# endif
}
static tStringLS rDirBaseName_Name = INIT_STRING;
static tStringLS rDirBaseName_DirName = INIT_STRING;
static tStringLS rDirBaseName_BaseName = INIT_STRING;
void rDirBaseName (const char *name, char *dir_name, char *base_name)
{
DENTER (("rDirBaseName name = `%s'\n", name));
copy_replace_dir_separator (&rDirBaseName_Name, name, strlen(name));
dir_base_name (rDirBaseName_Name.Str,
&rDirBaseName_DirName,
&rDirBaseName_BaseName);
strcpy (dir_name, rDirBaseName_DirName.Str);
strcpy (base_name, rDirBaseName_BaseName.Str);
DEXIT (("dir_name =`%s'; base_name = `%s'\n", dir_name, base_name));
}
void rDirBaseSuffixName (const char *name,
char *dir_name, char *base_name, char *suffix)
{
DENTER (("rDirBaseSuffixName name = `%s'\n", name));
rDirBaseName (name, dir_name, base_name);
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
{
char *dot;
if ((dot = strchr (base_name, '.')) != NULL) {
*dot = '\0';
strcpy (suffix, dot+1);
} else {
suffix[0] = '\0';
}
}
# endif
# ifdef rFsearch_MVS
strcpy (suffix, "");
# endif
DEXIT (("dir_name =`%s', base_name = `%s', suffix = `%s'\n",
dir_name, base_name, suffix));
}
/****************************************************************************
* handling files
****************************************************************************/
static rbool file_is_readable (const tStringLS *name)
{
tFile f;
rbool res;
f = OpenInput (name->Str);
if (f >= 0) {
res = rtrue;
rClose (f);
} else {
res = rfalse;
}
/* is a regular file? */
# ifdef rFsearch_UNIX
if (res) {
struct stat buf;
if (stat (name->Str, &buf) >= 0) {
# ifdef S_IFREG
res = (buf.st_mode & S_IFREG) != 0;
# elif defined S_ISREG
res = S_ISREG (buf.st_mode);
# else
# error "neither S_ISREG nor S_IFREG defined"
# endif
}
}
# endif
# ifdef rFsearch_MICROSOFT
if (res) {
struct _stat buf;
if (_stat (name->Str, &buf) == 0) {
res = (rbool) ((buf.st_mode & _S_IFREG) != 0);
}
}
# endif
/* for MVS we assume it is regular -> nothing more to do */
return res;
}
static tStringLS rFileIsReadable_Name = INIT_STRING;
rbool rFileIsReadable (const char *name)
{
rbool res;
DENTER (("rFileIsReadable `%s'\n", name));
copy_replace_dir_separator (&rFileIsReadable_Name, name, strlen(name));
res = file_is_readable (&rFileIsReadable_Name);
DEXIT (("res=%s\n", res? "true" : "false"));
return res;
}
/****************************************************************************/
static rbool dir_or_file_exists (const tStringLS *name)
{
rbool res;
# ifdef rFsearch_UNIX
{
struct stat buf;
DENTER (("dir_or_file_exists, name=`%s'\n", name->Str));
res = (stat (name->Str, &buf) >= 0);
}
# endif
# ifdef rFsearch_MICROSOFT
{
struct _stat buf;
DENTER (("dir_or_file_exists, name=`%s'\n", name->Str));
/* Microsoft's variant of 'stat' cares about a trailing '\', hence
* we must remove it before calling stat, but not for things like
* "C:\ "
*/
if (name->Str[1] == ':' && name->Str[2] == '\\' && name->Str[3] == '\0') {
res = (rbool) (_stat (name->Str, &buf) == 0);
} else if (name->Len > 1 && name->Str[name->Len-1] == '\\') {
name->Str[name->Len-1] = '\0';
res = (rbool) (_stat (name->Str, &buf) == 0);
name->Str[name->Len-1] = '\\';
} else {
res = (rbool) (_stat (name->Str, &buf) == 0);
}
}
# endif
# ifdef rFsearch_MVS
res = rtrue;
# endif
DEXIT (("dir_or_file_exists `%s' : %s\n",
name->Str,
res? "true" : "false"));
return res;
}
static tStringLS rDirOrFileExists_Name = INIT_STRING;
rbool rDirOrFileExists (const char *name)
{
rbool res;
DENTER (("rDirOrFileExists `%s'\n", name));
copy_replace_dir_separator (&rDirOrFileExists_Name, name, strlen (name));
res = dir_or_file_exists (&rDirOrFileExists_Name);
DEXIT (("res=%s\n", res? "true" : "false"));
return res;
}
/****************************************************************************
* handling file system directories
****************************************************************************/
# ifdef rFsearch_MICROSOFT
static tStringLS open_file_system_dir_Name = INIT_STRING;
# endif
static tFileSystemDir open_file_system_dir (const tStringLS *name)
{
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
# ifdef rFsearch_HAVE_DIR_ACCESS
tFileSystemDir dir = (tFileSystemDir) Alloc (sizeof (struct sFileSystemDir));
DPRINTF (("open_file_system_dir: `%s'\n", name->Str));
if (dir == NULL) goto error;
# ifdef rFsearch_UNIX
dir->dir = opendir (name->Str);
if (dir->dir == NULL) goto error;
# endif
# ifdef rFsearch_MICROSOFT
{
copy_String (&open_file_system_dir_Name, name);
assert (open_file_system_dir_Name.Len + 3 <=
open_file_system_dir_Name.Size); /* appending "\*" for MICROSOFT */
open_file_system_dir_Name.Str[open_file_system_dir_Name.Len++] = '\\';
open_file_system_dir_Name.Str[open_file_system_dir_Name.Len++] = '*';
open_file_system_dir_Name.Str[open_file_system_dir_Name.Len] = '\0';
if (open_file_system_dir_Name.Len >= MAX_PATH) goto error;
dir->dir = FindFirstFile (open_file_system_dir_Name.Str, &(dir->entry));
if (dir->dir == INVALID_HANDLE_VALUE) goto error;
}
# endif
/* every thing is ok */
dir->first = rtrue;
return dir;
error:
/* directory can not be opened, or not enough memory */
Free (sizeof (struct sFileSystemDir), (char*) dir);
# endif
# endif
# ifdef rFsearch_MVS
fprintf (stderr, "rFsearch::rOpenFileSystemDir not available under MVS\n");
exit (1);
# endif
return NULL;
}
static tStringLS rOpenFileSystemDir_Name = INIT_STRING;
tFileSystemDir rOpenFileSystemDir (const char *name)
{
tFileSystemDir dir;
DENTER (("rOpenFileSystemEntry: %s\n", name));
copy_replace_dir_separator (&rOpenFileSystemDir_Name, name, strlen (name));
dir = open_file_system_dir (&rOpenFileSystemDir_Name);
DEXIT (("%s\n", dir? "<ok>":"<error>"));
return dir;
}
/****************************************************************************/
const char *
rNextFileSystemEntry (tFileSystemDir dir)
{
char *str = NULL;
/* DENTER (("rNextFileSystemEntry:\n"));*/
assert (dir != NULL);
# ifdef rFsearch_HAVE_DIR_ACCESS
# ifdef rFsearch_UNIX
dir->entry = readdir(dir->dir);
if (dir->entry != NULL) {
str = dir->entry->d_name;
}
# endif
# ifdef rFsearch_MICROSOFT
if (dir->first) {
/* FindFirstFile already sets cFileName, hence use it */
str = dir->entry.cFileName;
} else {
if (FindNextFile(dir->dir, &(dir->entry))) {
str = dir->entry.cFileName;
}
}
# endif
# endif
# ifdef rFsearch_MVS
fprintf (stderr, "rFsearch::rNextFileSystemEntry not available under MVS\n");
exit (1);
# endif
/* DEXIT (("`%s'\n", str? str : ""));*/
dir->first = rfalse;
return str;
}
/****************************************************************************/
void
rCloseFileSystemDir (tFileSystemDir dir)
{
DPRINTF (("rCloseFileSystemDir\n"));
assert (dir != NULL);
# ifdef rFsearch_HAVE_DIR_ACCESS
# ifdef rFsearch_UNIX
closedir(dir->dir);
# endif
# ifdef rFsearch_MICROSOFT
FindClose (dir->dir);
# endif
# endif
# ifdef rFsearch_MVS
fprintf (stderr, "rFsearch::rNextFileSystemEntry not available under MVS\n");
exit (1);
# endif
Free (sizeof (struct sFileSystemDir), (char*)dir);
}
/****************************************************************************/
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
static rbool dir_is_readable (const tStringLS *name)
{
rbool res;
# ifdef rFsearch_HAVE_DIR_ACCESS
tFileSystemDir dir;
DENTER (("dir_is_readable: name=`%s'\n", name->Str));
dir = open_file_system_dir (name);
if (dir != NULL) {
res = rtrue;
rCloseFileSystemDir (dir);
} else {
res = rfalse;
}
# else
/* use a simplification: just check for readability */
DENTER (("dir_is_readable: name=`%s'\n", name->Str));
res = dir_or_file_exists (name);
# endif
DEXIT (("dir_is_readable: name=`%s' res=%s\n",
name->Str, res? "true" : "false"));
return res;
}
# endif
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
static tStringLS rDirIsReadable_Name = INIT_STRING;
# endif
rbool rDirIsReadable (const char *name)
{
rbool res;
DENTER (("rDirIsReadable `%s'\n", name));
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
copy_replace_dir_separator (&rDirIsReadable_Name, name, strlen (name));
res = dir_is_readable (&rDirIsReadable_Name);
# endif
# ifdef rFsearch_MVS
res = rtrue;
# endif
DEXIT (("res=%s\n", res? "true" : "false"));
return res;
}
/****************************************************************************
* handling directory cache
****************************************************************************/
static void free_dir_cache (tDirEntryPtr entry)
/* deallocate the cached entries */
{
if (entry->Entries != NULL) {
long i;
for (i = 0; i <= entry->Last; i++) {
free_String (&(entry->Entries[i]));
}
ReleaseArray ((char**)&entry->Entries, &(entry->Max), sizeof (tStringLS));
}
entry->Entries = NULL;
}
/****************************************************************************/
static void free_dir_entry (tDirEntryPtr entry)
/* deallocate the memory of `entry' */
{
free_dir_cache (entry);
free_String (&(entry->Dir));
Free (sizeof (tDirEntry), (char*) entry);
}
/****************************************************************************/
static void free_all_dir_entries (tDirEntryPtr dirs)
{
while (dirs != NULL) {
tDirEntryPtr dir = dirs;
dirs = dirs->Next;
free_dir_entry (dir);
}
}
/****************************************************************************/
static tDirEntryPtr new_dir (tDirEntryPtr dirs, const char *dir, long mark)
/* create and return a new directory entry. `dirs' is appended to the created
* entry.
* If `dir' is not terminated by a '/' add one, only non-MVS.
* The dir-separators are already fixed.
*/
{
tDirEntryPtr new_entry;
new_entry = (tDirEntryPtr) Alloc (sizeof (tDirEntry));
new_entry->Next = dirs;
new_entry->Mark = mark;
new_entry->Entries = NULL;
new_entry->Max = 0;
new_entry->Last = -1;
new_entry->Set = current_set;
init_String (&new_entry->Dir); copy_String_str (&new_entry->Dir, dir);
append_String_trailing_dirsep (&new_entry->Dir);
# ifdef rFsearch_HAVE_DIR_ACCESS
new_entry->Exists = dir_is_readable (&new_entry->Dir);
# else
new_entry->Exists = dir_or_file_exists (&new_entry->Dir);
# endif
if (dir_max_len < new_entry->Dir.Len) {
dir_max_len = new_entry->Dir.Len;
}
return new_entry;
}
/****************************************************************************/
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
static tDirEntryPtr find_dir (tDirEntryPtr dirs, tStringLS *name)
/* Searches the directory `name' in the list `dirs'.
* If no matching directory is found NULL is returned.
* NOTE: `name' __must__ be terminated by a trailing '/'.
*/
{
DENTER (("find_dir `%s' (set=%d)\n", name->Str, current_set));
assert (name->Str[name->Len-1] == rDirSeparator);
while (dirs != NULL) {
assert (dirs->Dir.Str[dirs->Dir.Len-1] == rDirSeparator);
if (use_dir (dirs->Set)) {
if (name->Len == dirs->Dir.Len) {
if (cmp_String (name, &dirs->Dir) == 0) {
DEXIT (("find_dir `%s': res=`%s'\n", name->Str, dirs->Dir.Str));
return dirs;
}
}
}
dirs = dirs->Next;
}
DEXIT (("find_dir `%s': res=`%s'\n", name->Str, ""));
return NULL;
}
# endif
/* endif UNIX/MICROSOFT */
/****************************************************************************/
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
static rbool read_dir (tDirEntryPtr dir)
/* Reads the content of one directory into the directory cache.
* Returns true, iff the directory exists and could be read and is not empty.
* The entries are sorted.
*/
{
tFileSystemDir fs_dir;
const char *fs_entry;
DENTER (("read_dir `%s' (set=%d) %p\n", dir->Dir.Str, dir->Set, (void*)dir));
if (!dir->Exists) {
/* directory does not exist in filesystem */
DEXIT (("read_dir: does not exist in filesystem\n"));
return rfalse;
}
if (dir->Entries != NULL) {
/* already cached */
DEXIT (("read_dir `%s': already cached\n", dir->Dir.Str));
return rtrue;
}
fs_dir = open_file_system_dir (&dir->Dir);
if (fs_dir == NULL) {
/* OOPS!!!! no such dir, the dir vanished.....*/
dir->Exists = rfalse;
DEXIT (("read_dir `%s': does not exist - dir vanished??\n",
dir->Dir.Str));
return rfalse;
}
dir->Exists = rtrue;
dir->Max = INIT_MAX_DIR_ENTRIES;
dir->Last = -1;
MakeArray ((char**)&dir->Entries, &dir->Max, sizeof (tStringLS));
while ((fs_entry = rNextFileSystemEntry (fs_dir)) != NULL) {
/* store the entry */
dir->Last++;
if ((unsigned long) dir->Last >= dir->Max) {
ExtendArray ((char**)&dir->Entries, &dir->Max, sizeof (tStringLS));
}
init_String (&dir->Entries[dir->Last]);
copy_String_str (&dir->Entries[dir->Last], fs_entry);
dir->Entries[dir->Last].file_state = unknown_file_state;
}
rCloseFileSystemDir (fs_dir);
qsort (dir->Entries, (size_t) dir->Last+1, sizeof (tStringLS), cmp_String);
DEXIT (("read_dir `%s': does exist\n", dir->Dir.Str));
return rtrue;
}
# endif
/****************************************************************************/
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
static void read_one_dir (tDirEntryPtr dir)
{
/* first try name as it is */
if (!read_dir (dir)) {
if (!case_sensitive) {
read_dir_no_case (dir);
}
}
}
# endif
/****************************************************************************/
static tDirEntryPtr get_search_path (void)
{
return current_user_dirs? current_user_dirs : user_dirs;
}
/****************************************************************************/
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
static void read_dir_no_case (tDirEntryPtr dir)
/* Reads a directory, tries to find it even if the name is given case
* insensitive.
* If a directory is found, the `Dir.Str' value is changed to reflect the
* name of the directory as stored in the file system.
* It is assumed, that `dir' does not exist as given (case sensitive).
* Solution: try to read the base directory of `dir' and check whether
* there is an entry which is equal (case insensitive) to
* the "subdirectory" part of `dir'. This is done recursively
* for all directory parts of `dir'.
*/
{
/* this routine is recursive, hence do not use `static' variables! */
tStringLS base_dir_name = INIT_STRING;
tStringLS sub_name = INIT_STRING;
tDirEntryPtr base_dir;
DENTER ((" read_dir_no_case: `%s'\n", dir->Dir.Str));
/* find and read the base directory of `dir' */
copy_String (&base_dir_name, &dir->Dir);
dir_base_name (dir->Dir.Str, &base_dir_name, &sub_name);
append_String_trailing_dirsep (&base_dir_name);
/* `base_dir' given as user supplied search path? */
DPRINTF (("search base-dir `%s' in search-path\n", base_dir_name.Str));
base_dir = find_dir (get_search_path(), &base_dir_name);
if (base_dir == NULL) {
/* `base_dir' already cached? */
DPRINTF (("search base-dir `%s' in auto-cached-dirs\n",
base_dir_name.Str));
base_dir = find_dir (auto_cached_dirs, &base_dir_name);
}
if (base_dir == NULL) {
/* `base_dir' not seen yet, hence create dir-object */
DPRINTF (("read base-dir `%s' from file system\n", base_dir_name.Str));
base_dir = new_dir (auto_cached_dirs, base_dir_name.Str, AUTO_CACHE_MARK);
auto_cached_dirs = base_dir;
}
if (base_dir->Entries == NULL) {
/* `base_dir' not seen yet, hence read it */
read_one_dir (base_dir);
}
if (base_dir->Entries != NULL) {
/* check whether `sub_name' exists in `base_dir' */
tStringLS *found_entry;
DPRINTF (("check if `%s' exsist in `%s'\n",
sub_name.Str, base_dir_name.Str));
found_entry = (tStringLS*) bsearch(&sub_name,
base_dir->Entries,
(size_t) base_dir->Last+1,
sizeof (tStringLS),
cmp_String);
if (found_entry != NULL) {
empty_String (&dir->Dir);
append_String (&dir->Dir, &base_dir->Dir);
append_String (&dir->Dir, found_entry);
append_String_char (&dir->Dir, rDirSeparator);
DPRINTF (("found it, read dir `%s'\n", dir->Dir.Str));
dir->Exists = rtrue;
read_dir (dir);
}
}
free_String (&base_dir_name);
free_String (&sub_name);
DEXIT (("dir `%s' exists=%s\n", dir->Dir.Str, dir->Exists? "true":"false"));
}
# endif
/****************************************************************************/
static void print_dir (FILE *file, tDirEntryPtr dir)
/* print a single directory 'dir' */
{
int i;
fprintf (file, "%s %s mark=%2ld set=%2d `%s'\n",
(dir->Entries == NULL)? "empty/no-dir/no-cache" :
"---------------------",
dir->Exists? " exists " : "not-exists",
dir->Mark,
dir->Set,
dir->Dir.Str);
for (i = 0; i <= dir->Last; i++) {
fprintf (file, "- %2d `%s'\n", i, dir->Entries[i].Str);
}
}
/****************************************************************************/
static void print_dirs (FILE *file, tDirEntryPtr dirs)
/* print all directores in the list 'dirs' */
{
tDirEntryPtr d;
for (d = dirs; d != NULL; d = d->Next) {
print_dir (file, d);
}
}
/****************************************************************************/
static void free_ext_entry (tExtEntryPtr entry)
/* deallocate the memory of `entry' */
{
free_String (&entry->Ext);
Free (sizeof (tExtEntry), (char*) entry);
}
static tExtEntryPtr new_extension (const char *ext, tExtEntryPtr exts)
/* create and return a new extension entry. `ext' is appended to the entry */
{
tExtEntryPtr new_entry;
new_entry = (tExtEntryPtr) Alloc (sizeof (tExtEntry));
new_entry->Next = exts;
init_String (&new_entry->Ext); copy_String_str (&new_entry->Ext, ext);
if (new_entry->Ext.Len > ext_max_len) {
ext_max_len = new_entry->Ext.Len;
}
return new_entry;
}
/****************************************************************************/
void
Begin_rFsearch (rbool CaseSensitive)
{
DENTER (("Begin_rFsearch, CaseSensitive = %s\n",
CaseSensitive? "true" : "false"));
if (cmp_string_func == NULL) {
current_set = 0;
user_dirs = NULL;
dirs_end = NULL;
current_user_dirs = NULL;
user_exts = NULL;
auto_cached_dirs = NULL;
ext_max_len = 0;
dir_max_len = 0;
case_sensitive = CaseSensitive;
cmp_string_func = CaseSensitive? STRCMP : STRCASECMP;
no_ext = new_extension ("", NULL);
# ifdef rFsearch_UNIX
no_dir = new_dir (NULL, "./", DEFAULT_DIR_MARK);
root_dir = new_dir (NULL, "/", ROOT_DIR_MARK);
# endif
# ifdef rFsearch_MICROSOFT
no_dir = new_dir (NULL, ".\\", DEFAULT_DIR_MARK);
root_dir = new_dir (NULL, "\\", ROOT_DIR_MARK);
# endif
# ifdef rFsearch_MVS
no_dir = new_dir (NULL, "", DEFAULT_DIR_MARK);
root_dir = new_dir (NULL, "", DEFAULT_DIR_MARK);
# endif
find_file_last_search_path = NULL;
}
DEXIT(("\n"));
}
void
rSetCaseSensitive (rbool CaseSensitive)
{
DPRINTF (("rSetCaseSensitive, CaseSensitive = %s\n",
CaseSensitive? "true" : "false"));
case_sensitive = CaseSensitive;
cmp_string_func = CaseSensitive? STRCMP : STRCASECMP;
}
rbool
rGetCaseSensitive (void)
{
assert (cmp_string_func != NULL);
return case_sensitive;
}
void
Print_rFsearch (FILE *file)
{
tExtEntryPtr e;
assert (cmp_string_func != NULL);
fprintf (file, "=============================\n");
fprintf (file, " Print_rFsearch\n");
fprintf (file, "search directories:\n");
if (dirs_end != NULL) {
fprintf (file, "last: %2ld `%s'\n",
dirs_end->Mark, dirs_end->Dir.Str);
fprintf (file, "-----\n");
}
print_dirs (file, user_dirs);
fprintf (file, "=============================\n");
fprintf (file, "auto cached directories:\n");
print_dirs (file, auto_cached_dirs);
fprintf (file, "=============================\n");
fprintf (file, "default directory:\n");
print_dirs (file, no_dir);
fprintf (file, "=============================\n");
fprintf (file, "root cached directory:\n");
print_dirs (file, root_dir);
fprintf (file, "=============================\n");
fprintf (file, "extensions:\n");
for (e = user_exts; e != NULL; e = e->Next) {
fprintf (file, " `%s'\n", e->Ext.Str);
}
fprintf (file, "=============================\n");
}
/****************************************************************************/
void rUseDirSet (unsigned short set)
{
current_set = set;
}
/****************************************************************************/
void rUseDirAllSets (void)
{
current_set = 0;
}
/****************************************************************************/
static tStringLS rAddDir_Dir = INIT_STRING;
void rAddDir (const char* dir,
unsigned int mark,
rbool at_end)
{
assert (cmp_string_func != NULL);
DPRINTF (("rAddDir dir = `%s' mark=%d set=%d at_end=%s\n",
dir, mark, current_set, at_end? "true":"false"));
copy_replace_dir_separator (&rAddDir_Dir, dir, strlen (dir));
if (user_dirs == NULL) {
user_dirs = dirs_end = new_dir (NULL, rAddDir_Dir.Str, mark);
} else {
if (at_end) {
tDirEntryPtr new_entry = new_dir (NULL, rAddDir_Dir.Str, mark);
dirs_end->Next = new_entry;
dirs_end = new_entry;
} else {
user_dirs = new_dir (user_dirs, rAddDir_Dir.Str, mark);
}
}
}
/****************************************************************************/
void rAddDirSet (const char* dir,
unsigned int mark,
rbool at_end,
unsigned short set)
{
unsigned short prev_set = current_set;
current_set = set;
rAddDir (dir, mark, at_end);
current_set = prev_set;
}
/****************************************************************************/
void
rDeleteDirs (unsigned int mark)
{
tDirEntryPtr cur = user_dirs;
tDirEntryPtr prev = NULL;
long Mark = mark;
assert (cmp_string_func != NULL);
DENTER (("rDeleteDirs mark=%d\n", mark));
while (cur != NULL) {
if (cur->Mark == Mark) {
tDirEntryPtr next = cur->Next;
DPRINTF (("delete `%s'\n", cur->Dir.Str));
if (prev == NULL) {
/* cur is the first element of the list */
user_dirs = next;
} else {
prev->Next = next;
}
free_dir_entry (cur);
cur = next;
} else {
prev = cur;
cur = cur->Next;
}
}
dirs_end = prev;
DEXIT(("\n"));
}
void
rDeleteAllDirs (void)
{
assert (cmp_string_func != NULL);
DPRINTF (("rDeleleteAllDirs\n"));
free_all_dir_entries (user_dirs);
free_all_dir_entries (auto_cached_dirs);
user_dirs = NULL;
dirs_end = NULL;
current_user_dirs = NULL;
auto_cached_dirs = NULL;
dir_max_len = 0;
}
/****************************************************************************/
void
rReadDirs (unsigned int mark)
{
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
tDirEntryPtr cur;
long Mark = mark;
DENTER (("rReadDirs mark=%d\n",mark));
assert (cmp_string_func != NULL);
# ifndef rFsearch_HAVE_DIR_ACCESS
/* since we have no functionality, no cahing is possible */
DPRINTF (("rFsearch_HAVE_DIR_ACCESS not defined\n"));
return;
# endif
for (cur = user_dirs; cur != NULL; cur = cur->Next) {
if (cur->Mark == Mark) {
read_dir (cur);
}
}
/* we do this in two steps, to avoid auto-caching of directories
* supplied as search paths
*/
if (!case_sensitive) {
for (cur = user_dirs; cur != NULL; cur = cur->Next) {
if (cur->Mark == Mark && !cur->Exists) {
read_dir_no_case (cur);
}
}
}
# endif
# ifdef rFsearch_MVS
/* nothing */
# endif
DEXIT(("\n"));
}
void
rReadAllDirs (void)
{
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
tDirEntryPtr cur;
DENTER (("rReadAllDirs\n"));
assert (cmp_string_func != NULL);
# ifndef rFsearch_HAVE_DIR_ACCESS
/* since we have no functionality, no caching is possible */
DPRINTF (("rFsearch_HAVE_DIR_ACCESS not defined\n"));
return;
# endif
for (cur = user_dirs; cur != NULL; cur = cur->Next) {
read_dir (cur);
}
/* we do this in two steps, to avoid auto-caching of directories
* supplied as search paths
*/
if (!case_sensitive) {
for (cur = user_dirs; cur != NULL; cur = cur->Next) {
if (!cur->Exists) {
read_dir_no_case (cur);
}
}
}
# endif
# ifdef rFsearch_MVS
/* nothing */
# endif
DEXIT (("\n"));
}
/****************************************************************************/
void
rAddExtension (const char *ext)
{
DPRINTF (("rAddExtension ext = `%s'\n", ext));
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
assert (cmp_string_func != NULL);
user_exts = new_extension (ext, user_exts);
# endif
# ifdef rFsearch_MVS
/* nothing */
# endif
}
/****************************************************************************/
void
rDeleteExtensions (void)
{
DPRINTF (("rDeleteExtension\n"));
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
assert (cmp_string_func != NULL);
while (user_exts != NULL) {
tExtEntryPtr next = user_exts->Next;
free_ext_entry (user_exts);
user_exts = next;
}
# endif
# ifdef rFsearch_MVS
/* nothing */
# endif
ext_max_len = 0;
}
/****************************************************************************/
static tStringLS rSetSearchPathStart_ls = INIT_STRING;
char *rSetSearchPathStart (const char *path)
{
tDirEntryPtr dir;
DENTER (("rSetSearchPathStart: path = `%s'\n", path));
if (path == NULL) {
/* reset to entire search path list */
dir = user_dirs;
} else {
/* add a trailing directory separator if needed */
copy_String_str (&rSetSearchPathStart_ls, path);
if (rSetSearchPathStart_ls.Str[rSetSearchPathStart_ls.Len-1] !=
rDirSeparator) {
append_String_char (&rSetSearchPathStart_ls, rDirSeparator);
}
/* search a matching directory */
for (dir = get_search_path(); dir != NULL; dir = dir->Next) {
if (cmp_String (&dir->Dir, &rSetSearchPathStart_ls) == 0) {
dir = dir->Next;
break;
}
}
}
current_user_dirs = dir;
DEXIT (("res=`%s'\n", (dir == NULL)? "" : dir->Dir.Str));
return dir? dir->Dir.Str : NULL;
}
/****************************************************************************/
static tStringLS find_file_in_dir_full_name = INIT_STRING;
static tStringLS find_file_in_dir_str = INIT_STRING;
static char *find_file_in_dir (tDirEntryPtr dir, const tStringLS *name)
/* Searches `name' in the directory `dir'.
* Returns the entire path or NULL.
* for MVS: the name passed here must be of the form "(member)" i.e.
* with the enclosing ()
*/
{
char *res;
DENTER (("find_file_in_dir: dir = `%s', name = `%s'\n",
dir->Dir.Str, name->Str));
if (!dir->Exists) {
DEXIT (("dir does not exists\n"));
return NULL;
}
if (!use_dir(dir->Set)) {
/* skip this directory */
DEXIT(("dir not in current set (current=%d,this=%d), it is skipped\n",
current_set, dir->Set));
return NULL;
}
alloc_String (&find_file_in_dir_full_name,
dir_max_len + ext_max_len + name->Len + 2);
res = find_file_in_dir_full_name.Str;
if (dir->Entries == NULL) {
/* no directories entries cached for this dir */
tExtEntryPtr ext;
char *n = find_file_in_dir_full_name.Str +
dir->Dir.Len; /* first char of the name */
char *e = n + name->Len; /* first char of an extension
* appended to the name
*/
empty_String (&find_file_in_dir_full_name);
append_String (&find_file_in_dir_full_name, &dir->Dir);
DPRINTF (("not cached\n"));
for (ext = (user_exts == NULL) ? no_ext : user_exts;
ext != NULL;
ext = ext->Next) {
DPRINTF (("try extension: `%s'\n", ext->Ext.Str));
strcpy (n, name->Str);
strcpy (e, ext->Ext.Str);
/* test name as given */
if (rFileIsReadable (find_file_in_dir_full_name.Str)) goto found;
if (!case_sensitive) {
/* test name in uppercase */
STRCONV2(toupper, n, e);
if (rFileIsReadable (find_file_in_dir_full_name.Str)) goto found;
/* test name in lowercase */
STRCONV2(tolower, n, e);
if (rFileIsReadable (find_file_in_dir_full_name.Str)) goto found;
/* test name, first letter in upper case, rest lowercase */
n[0] = (char) toupper (n[0]);
if (rFileIsReadable (find_file_in_dir_full_name.Str)) goto found;
}
}
} else {
/* directory entries are cached */
tExtEntryPtr ext;
char *e;
DPRINTF (("cached\n"));
alloc_String (&find_file_in_dir_str,
dir_max_len + ext_max_len + name->Len + 2);
copy_String (&find_file_in_dir_str, name);
e = find_file_in_dir_str.Str + name->Len;
/* first char of an extension appended to name */
for (ext = (user_exts == NULL) ? no_ext : user_exts;
ext != NULL;
ext = ext->Next) {
tStringLS *found_entry;
strcpy (e, ext->Ext.Str);
found_entry = (tStringLS*) bsearch(&find_file_in_dir_str, dir->Entries,
(size_t) dir->Last+1,
sizeof (tStringLS),
cmp_String);
if (found_entry != NULL) {
empty_String (&find_file_in_dir_full_name);
append_String (&find_file_in_dir_full_name, &dir->Dir);
append_String (&find_file_in_dir_full_name, found_entry);
switch (found_entry->file_state) {
case unknown_file_state:
if (rFileIsReadable (find_file_in_dir_full_name.Str)) {
found_entry->file_state = file_readable;
goto found;
} else {
found_entry->file_state = file_not_readable;
goto not_found;
}
case file_readable:
goto found;
case file_not_readable:
goto not_found;
default:
fprintf (stderr, "\nrFsearch: FATAL ERROR\n");
Reuse_Exit();
}
}
}
}
not_found:
res = NULL;
found:
DEXIT (("res=`%s'\n", (res == NULL)? "" : res));
return res;
}
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
static char *find_file_in_dirs (tDirEntryPtr dirs, const tStringLS *name)
/* Search name in all directories `dirs'.
* `name' must not contain any directory part!
* Returns the entire path or NULL.
*/
{
char *res = NULL;
tDirEntryPtr cur;
DENTER (("find_file_in_dirs: `%s'\n", name->Str));
for (cur = dirs; cur != NULL && res == NULL; cur = cur->Next) {
DPRINTF (("try search dir `%s'\n", cur->Dir.Str));
if (cur->Exists && use_dir(cur->Set)) {
find_file_last_search_path = cur->Dir.Str;
res = find_file_in_dir (cur, name);
}
}
DEXIT (("res=`%s'\n", (res == NULL)? "" : res));
return res;
}
static tStringLS get_sub_dir_name = INIT_STRING;
static tDirEntryPtr get_sub_dir (tDirEntryPtr search_dir,
const tStringLS *name)
/* Check if the `search_dir' contains a sub-directory `name'.
* Check the auto-cached-dirs and the file system,
* If `search_dir' does not contain the sub-directory, append
* 'search_dir/name' at the end of the auto_cached_dirs list,
* and mark it as non-existent.
* Return the dir-entry.
*/
{
tDirEntryPtr res;
DENTER (("get_sub_dir `%s' (set=%d)\n", name->Str, current_set));
alloc_String (&get_sub_dir_name, search_dir->Dir.Len + name->Len + 2);
copy_String (&get_sub_dir_name, &search_dir->Dir);
append_String (&get_sub_dir_name, name);
append_String_trailing_dirsep (&get_sub_dir_name);
DPRINTF (("check if dir `%s' contains `%s' in auto-cache-dirs\n",
search_dir->Dir.Str, name->Str));
res = find_dir (auto_cached_dirs, &get_sub_dir_name);
if (res) {
DEXIT (("res=`%s'\n", res->Dir.Str));
return res;
}
if (search_dir->Exists) {
/* only existing directories may have subdirectoires :-) */
DPRINTF (("check if dir `%s' contains `%s' in the file system\n",
search_dir->Dir.Str, name->Str));
res = new_dir (NULL, get_sub_dir_name.Str, AUTO_CACHE_MARK);
read_one_dir (res);
if (res->Exists) {
res->Next = auto_cached_dirs;
auto_cached_dirs = res;
DEXIT (("res=`%s'\n", res? res->Dir.Str : ""));
return res;
}
}
/* sub-directory does not exists in any case, add it at the end of
* the auto-cache-dirs.
*/
if (auto_cached_dirs) {
tDirEntryPtr d = auto_cached_dirs;
while (d->Next != NULL) {
d = d->Next;
}
res = new_dir (NULL, get_sub_dir_name.Str, AUTO_CACHE_MARK);
d->Next = res;
} else {
auto_cached_dirs =
res =
new_dir (NULL, get_sub_dir_name.Str, AUTO_CACHE_MARK);
}
DEXIT (("res=`%s' (sub dir does not exists)\n", res->Dir.Str));
return res;
}
static char *find_file_in_sub_dirs (tDirEntryPtr search_path,
tStringLS *sub_dir_name,
tStringLS *base_name)
/* For all directories "D" of the `search_path' directory list and
* check if "D/sub_dir_name/base_name" exists:
* 1. check search_dirs for "D/sub_dir_name/base_name"
* 2. check auto_cached_dirs for "D/sub_dir_name/base_name",
* 3. check if "D/sub_dir_name" exists in the file-system.
* If no directory "D/sub_dir_name" exists, add it to the
* auto_cached_dirs and mark it as non-existent.
* If it exists, but is not chached, read the directory, and check for
* the existence of `base_name'.
* Returns the entire path or NULL.
*/
{
char *res = NULL;
tDirEntryPtr cur;
DENTER (("find_file_in_sub_dirs: subdir:`%s' name:`%s' cur_set=%d\n",
sub_dir_name->Str, base_name->Str, current_set));
for (cur = search_path; cur != NULL && res == NULL; cur = cur->Next) {
if (use_dir(cur->Set)) {
/* check only sub-dir's of allowed search dirs */
tDirEntryPtr dir;
DPRINTF (("try search dir `%s'\n", cur->Dir.Str));
find_file_last_search_path = cur->Dir.Str;
dir = get_sub_dir (cur, sub_dir_name);
res = find_file_in_dir (dir, base_name);
}
}
DEXIT (("res=`%s'\n", (res == NULL)? "" : res));
return res;
}
# endif
/* endif UNIX/MICROSOFT */
static tStringLS rFindFile_Name = INIT_STRING;
static tStringLS rFindFile_base_name = INIT_STRING;
static tStringLS rFindFile_subdir_name = INIT_STRING;
static tStringLS rFindFile_dir_name = INIT_STRING;
char *rFindFile (const char *name)
{
char *res = NULL;
DENTER (("rFindFile file = `%s', current_set=%d\n", name, current_set));
assert (cmp_string_func != NULL);
find_file_last_search_path = NULL;
copy_replace_dir_separator (&rFindFile_Name, name, strlen (name));
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
{
tDirEntryPtr search_dirs;
rbool HasSubDir;
# ifdef rFsearch_MICROSOFT
if (rFindFile_Name.Str[1] == ':') {
/* an absolute path given, do not lookup in cache */
res = file_is_readable (&rFindFile_Name) ? rFindFile_Name.Str : NULL;
DEXIT (("res=`%s'\n", res));
return res;
}
# endif
if (rFindFile_Name.Str[0] == rDirSeparator) {
search_dirs = root_dir;
} else {
search_dirs = get_search_path();
if (search_dirs == NULL) search_dirs = no_dir;
}
HasSubDir = (rbool) (strchr (rFindFile_Name.Str, rDirSeparator) != NULL);
if (HasSubDir) {
/* 'name' contains a directory part: name = "d/n"
* 1. search "n" in all directories "D/d", where "D" is in the
* search path.
* 2. search "n" in all directories "D/d", where "D" is a
* auto-chached directory
* 3. check in the filesystem wether a directory "D/d" exists,
* where "D" is a directory given in the search path.
*/
alloc_String (&rFindFile_subdir_name, rFindFile_Name.Len + 2);
alloc_String (&rFindFile_base_name, rFindFile_Name.Len + 1);
dir_base_name (rFindFile_Name.Str,
&rFindFile_subdir_name,
&rFindFile_base_name);
append_String_char (&rFindFile_subdir_name, rDirSeparator);
DPRINTF (("search `%s' in list search_dirs\n",
rFindFile_subdir_name.Str));
res = find_file_in_sub_dirs (search_dirs,
&rFindFile_subdir_name,
&rFindFile_base_name);
} else {
/* 'name' contains no directory part:
* 1. search 'name' in all directories of the search path
*/
res = find_file_in_dirs (search_dirs, &rFindFile_Name);
}
if (res) {
if (res[0] == '.' && res[1] == rDirSeparator) {
/* skip leading `./' */
res += 2;
}
# ifdef rFsearch_UNIX
if (res[0] == rDirSeparator && res[1] == rDirSeparator) {
/* skip leading one '/' of two leading `//' */
res ++;
}
# endif
}
}
# endif
/* endif UNIX | Windows */
# ifdef rFsearch_MVS
{
tDirEntryPtr cur;
/* does this name exist? */
if (rFileIsReadable(name)) {
DEXIT (("res=`%s'\n", name));
return (char*) name;
}
/* add () around name */
alloc_String (&rFindFile_base_name, rFindFile_Name.Len + 2);
rFindFile_base_name.Len = sprintf (rFindFile_base_name.Str, "(%s)",
rFindFile_Name.Str);
for (cur = get_search_path(); cur != NULL; cur = cur->Next) {
DPRINTF (("try search dir `%s'\n", cur->Dir.Str));
res = find_file_in_dir (cur, &rFindFile_base_name);
if (res != NULL) break;
}
}
# endif
/* endif MVS */
DEXIT (("rFindFile(%s) with set=%d returns=`%s'\n",
name, current_set, res));
return res;
}
/****************************************************************************/
char *rFindFileSet (const char* name, unsigned short set)
{
unsigned short prev_set = current_set;
char *res;
current_set = set;
res = rFindFile (name);
current_set = prev_set;
return res;
}
/****************************************************************************/
char *rFindFileSameDir (const char* cur_file, const char* name)
{
char dir[1024];
char *res;
DENTER (("rFindFileSameDir: cur_file = `%s', name = `%s'\n", cur_file,
name));
rDirName ((char*)cur_file, dir);
res = rFindFileDir (dir, name);
if (res == NULL) {
res = rFindFile (name);
}
DEXIT (("res=`%s'\n", res));
return res;
}
/****************************************************************************/
char *rFsearchUsedSearchPath(void)
{
DENTER (("rFsearchUsedSearchPath:"));
DEXIT (("res=`%s'\n", find_file_last_search_path));
return find_file_last_search_path;
}
/****************************************************************************/
char *rFindFileSameDirSet (const char* cur_file, const char* name,
unsigned short set)
{
unsigned short prev_set = current_set;
char *res;
current_set = set;
res = rFindFileSameDir (cur_file, name);
current_set = prev_set;
return res;
}
/****************************************************************************/
# ifdef rFsearch_MVS
char *_rFindFileDir (const char *dir, const char* name);
char *rFindFileDir (const char *dir, const char* name)
/* add () around name */
{
char n[255];
assert (strlen (name) < sizeof (n));
DPRINTF (("rFindFileDir: dir = `%s', name = `%s'\n", dir, name));
sprintf (n, "(%s)", name);
return _rFindFileDir (dir, n);
}
# define rFindFileDir _rFindFileDir
# endif
static tStringLS rFindFileDir_full_name = INIT_STRING;
char *rFindFileDir (const char *dir, const char* name)
{
char *res;
int dir_len = strlen (dir);
int name_len = strlen (name);
tExtEntryPtr ext;
DENTER (("rFindFileDir: dir = `%s', name = `%s'\n", dir, name));
alloc_String (&rFindFileDir_full_name, dir_len + ext_max_len + name_len + 2);
res = rFindFileDir_full_name.Str;
empty_String (&rFindFileDir_full_name);
append_String_char_ptr (&rFindFileDir_full_name, dir, dir_len);
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
if (dir[dir_len-1] != rDirSeparator) {
append_String_char (&rFindFileDir_full_name, rDirSeparator);
dir_len++;
}
# endif
append_String_char_ptr (&rFindFileDir_full_name, name, name_len);
for (ext = (user_exts == NULL) ? no_ext : user_exts;
ext != NULL;
ext = ext->Next) {
char *n = rFindFileDir_full_name.Str + dir_len;
/* first char of the name */
char *e = n + name_len; /* first char of an extension
* appended to the name
*/
DPRINTF (("try extension `%s'\n", ext->Ext.Str));
strcpy (n, name);
strcpy (e, ext->Ext.Str);
if (rFileIsReadable (rFindFileDir_full_name.Str)) goto found;
if (!case_sensitive) {
/* test name in uppercase */
STRCONV(toupper, n);
if (rFileIsReadable (rFindFileDir_full_name.Str)) goto found;
/* test name in lowercase */
STRCONV(tolower, n);
if (rFileIsReadable (rFindFileDir_full_name.Str)) goto found;
/* test name, first letter in upper case, rest lowercase */
n[0] = (char) toupper (n[0]);
if (rFileIsReadable (rFindFileDir_full_name.Str)) goto found;
}
}
/* not found */
res = NULL;
DEXIT (("res=`'\n"));
return res;
found:
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
if (res[0] == '.' && res[1] == rDirSeparator) {
/* skip leading `./' */
res += 2;
}
# ifdef rFsearch_UNIX
if (res[0] == rDirSeparator && res[1] == rDirSeparator) {
/* skip leading one '/' of two leading `//' */
res ++;
}
# endif
# endif
DEXIT (("res=`%s'\n", res));
return res;
}
/****************************************************************************/
void
Close_rFsearch (void)
{
DPRINTF (("Close_rFsearch\n"));
# ifdef DEBUG_RFSEARCH
if (rFsearchShowDebug) Print_rFsearch (stdout);
# endif
if (cmp_string_func != NULL) {
rDeleteAllDirs ();
rDeleteExtensions ();
free_ext_entry (no_ext);
free_dir_entry (no_dir);
free_dir_entry (root_dir);
user_dirs = NULL;
dirs_end = NULL;
current_user_dirs = NULL;
auto_cached_dirs = NULL;
no_dir = NULL;
root_dir = NULL;
no_ext = NULL;
cmp_string_func = NULL;
free_String (&rFileIsReadable_Name);
free_String (&rBaseName_buf1);
free_String (&rBaseName_buf2);
free_String (&rDirName_my_buffer);
free_String (&init_String_init);
free_String (&rDirBaseName_Name);
free_String (&rDirBaseName_DirName);
free_String (&rDirBaseName_BaseName);
free_String (&rDirOrFileExists_Name);
free_String (&rOpenFileSystemDir_Name);
free_String (&rAddDir_Dir);
free_String (&rSetSearchPathStart_ls);
free_String (&rFindFile_Name);
free_String (&rFindFile_base_name);
free_String (&rFindFile_subdir_name);
free_String (&rFindFile_dir_name);
free_String (&rFindFileDir_full_name);
free_String (&find_file_in_dir_full_name);
free_String (&find_file_in_dir_str);
# ifdef rFsearch_MICROSOFT
free_String (&open_file_system_dir_Name);
# endif
# if defined (rFsearch_UNIX) || defined (rFsearch_MICROSOFT)
free_String (&get_sub_dir_name);
free_String (&rDirIsReadable_Name);
# endif
}
}
/****************************************************************************/
| 28.414963 | 79 | 0.573768 |
9beddff14ba835821717ae3069b06bfba410948a | 2,847 | h | C | cpp/framework/NodeServer/NodeRollLogger.h | yangg37/Tars | a4ed7b1706a800175dd02775c12ba3afb89a07ee | [
"Apache-2.0"
] | 137 | 2017-01-20T03:24:33.000Z | 2022-02-28T16:09:42.000Z | cpp/framework/NodeServer/NodeRollLogger.h | playbar/TAFS | bb58e48954b5725a65b8054c13ae3713c3eeb7ca | [
"Apache-2.0"
] | null | null | null | cpp/framework/NodeServer/NodeRollLogger.h | playbar/TAFS | bb58e48954b5725a65b8054c13ae3713c3eeb7ca | [
"Apache-2.0"
] | 49 | 2017-01-28T07:43:43.000Z | 2021-10-31T03:20:50.000Z | /**
* Tencent is pleased to support the open source community by making Tars available.
*
* Copyright (C) 2016THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* 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 __NODE_ROLL_LOGGER_H__
#define __NODE_ROLL_LOGGER_H__
#include "util/tc_logger.h"
#include "servant/TarsLogger.h"
/**
* node使用的日志,主要是为了支持多个滚动日志
*/
///////////////////////////////////////////////////////////////////////////////
/**
* 本地日志帮助类, 单件
* 循环日志单件是永生不死的, 保证任何地方都可以使用
* 当该对象析够以后, 则直接cout出来
*/
class RollLoggerManager : public TC_ThreadLock, public TC_Singleton<RollLoggerManager, CreateUsingNew, DefaultLifetime>
{
public:
enum
{
NONE_LOG = 1, /**所有的log都不写*/
ERROR_LOG = 2, /**写错误log*/
WARN_LOG = 3, /**写错误,警告log*/
DEBUG_LOG = 4, /**写错误,警告,调试log*/
INFO_LOG = 5 /**写错误,警告,调试,Info log*/
};
public:
typedef TC_Logger<RollWriteT, TC_RollBySize> RollLogger;
RollLoggerManager();
~RollLoggerManager();
/**
* 设置本地信息
* @param app, 业务名称
* @param server, 服务名称
* @param logpath, 日志路径
* @param iMaxSize, 文件最大大小,字节
* @param iMaxNum, 文件最大数
*/
void setLogInfo(const string &sApp, const string &sServer, const string &sLogpath, int iMaxSize = 1024*1024*50, int iMaxNum = 10, const CommunicatorPtr &comm=NULL, const string &sLogObj="");
/**
* 设置同步写日志
*
* @param bSync
*/
void sync(RollLogger *pRollLogger, bool bSync = true);
/**
* 获取循环日志
*
* @return RollLogger
*/
RollLogger *logger(const string &sFile);
private:
void initRollLogger(RollLogger *pRollLogger, const string &sFile, const string &sFormat);
protected:
/**
* 应用
*/
string _app;
/**
* 服务名称
*/
string _server;
/**
* 日志路径
*/
string _logpath;
int _maxSize;
int _maxNum;
CommunicatorPtr _comm;
string _logObj;
/**
* 本地线程组
*/
TC_LoggerThreadGroup _local;
/**
* 远程日志
*/
map<string, RollLogger*> _loggers;
};
/**
* 循环日志
*/
#define NODE_LOG(x) (RollLoggerManager::getInstance()->logger(x))
#endif
| 23.528926 | 194 | 0.58588 |
50430a61f3168c81d23a80c200a328751603d654 | 169 | h | C | src/JabbrChatCpp/util.h | moozzyk/JabbrClientCpp | 283a00f55a3b7c179c0d2a51e2cc0defbc42553e | [
"Apache-2.0"
] | null | null | null | src/JabbrChatCpp/util.h | moozzyk/JabbrClientCpp | 283a00f55a3b7c179c0d2a51e2cc0defbc42553e | [
"Apache-2.0"
] | null | null | null | src/JabbrChatCpp/util.h | moozzyk/JabbrClientCpp | 283a00f55a3b7c179c0d2a51e2cc0defbc42553e | [
"Apache-2.0"
] | null | null | null | #include <string>
namespace util
{
std::wstring <rim(std::wstring &s);
std::wstring &rtrim(std::wstring &s);
std::wstring &trim(std::wstring &s);
} | 21.125 | 42 | 0.609467 |
da2ea3b98b766b4763b06542988db4de34c864a9 | 702 | c | C | pkg/wfc3/calwf3/lib/defswitch.c | rendinam/hstcal | e08676b02e4c7cd06e3d5630b62f7b59951ac8c3 | [
"BSD-3-Clause"
] | 8 | 2016-07-28T15:14:27.000Z | 2020-04-02T16:37:23.000Z | pkg/wfc3/calwf3/lib/defswitch.c | rendinam/hstcal | e08676b02e4c7cd06e3d5630b62f7b59951ac8c3 | [
"BSD-3-Clause"
] | 484 | 2016-03-14T20:44:42.000Z | 2022-03-31T15:54:38.000Z | pkg/wfc3/calwf3/lib/defswitch.c | rendinam/hstcal | e08676b02e4c7cd06e3d5630b62f7b59951ac8c3 | [
"BSD-3-Clause"
] | 21 | 2016-03-14T14:22:35.000Z | 2022-02-07T18:41:49.000Z | # include <string.h>
# include <ctype.h>
# include "wf3.h" /* for PERFORM and OMIT */
# include "wf3omit.h" /* a list of switches that should be OMIT */
/* This routine assigns the default value for a calibration switch,
for the case that no switch was specified on the command line.
*/
int DefSwitch (char *keyword) {
int i;
char lckey[SZ_KEYWORD+1]; /* keyword converted to lower case */
for (i = 0; i < SZ_KEYWORD; i++) {
if (isupper (keyword[i]))
lckey[i] = tolower (keyword[i]);
else
lckey[i] = keyword[i];
if (keyword[i] == '\0')
break;
}
for (i = 0; i < WF3_N_OMIT; i++) {
if (strcmp (lckey, omitsw[i]) == 0)
return (OMIT);
}
return (PERFORM);
}
| 22.645161 | 67 | 0.611111 |
da547cd7378d1a3bd356d24a4da6abe45bf31ba2 | 714 | h | C | config-examples/config-example.h | Phuurl/esp32-greengrass-temperature-sensor | 073b3a7578b27bf9e8bb909e2f61db60bd1f218d | [
"Apache-2.0"
] | null | null | null | config-examples/config-example.h | Phuurl/esp32-greengrass-temperature-sensor | 073b3a7578b27bf9e8bb909e2f61db60bd1f218d | [
"Apache-2.0"
] | null | null | null | config-examples/config-example.h | Phuurl/esp32-greengrass-temperature-sensor | 073b3a7578b27bf9e8bb909e2f61db60bd1f218d | [
"Apache-2.0"
] | null | null | null | #define DHTPIN 12 // what pin we're connected to
#define DHTTYPE DHT11 // DHT 11 (AM2302)
int publish_frequency = 60000; // Time in ms to publish sensor data
char WIFI_SSID[] = "wifi"; // Your WiFi SSID
char WIFI_PASSWORD[] = "password"; // Your WiFi password
char AWSIOTURL[] = "xxxx.iot.eu-west-1.amazonaws.com"; // Your AWS IoT core endpoint (this can be found in under settings in the AWS IoT console)
char THING[] = "ESP32-temperature"; // This name must match the name of your device in AWS IoT
char TOPIC_NAME[] = "topic/subtopic"; // Topic you wish the device to publish to.
const char JSONPAYLOAD[] = "{ \"DeviceID\" : \"%s\", \"timestamp\": %lu, \"tempC\": %f, \"Humid\": %f, \"TTL\": %lu}";
| 54.923077 | 146 | 0.672269 |
fb9268cb647f39663c37258b7dc72667d40079b4 | 2,580 | c | C | ac_memory.c | adamyi/achelper | 08566a095995f42d5cc1a76a6c874291059863c2 | [
"Apache-2.0"
] | 3 | 2020-09-25T10:59:38.000Z | 2020-10-04T23:05:03.000Z | ac_memory.c | adamyi/achelper | 08566a095995f42d5cc1a76a6c874291059863c2 | [
"Apache-2.0"
] | null | null | null | ac_memory.c | adamyi/achelper | 08566a095995f42d5cc1a76a6c874291059863c2 | [
"Apache-2.0"
] | null | null | null | // This file is part of achelper, Adam's C helper written for UNSW assignments.
// Copyright 2018 Adam Yi <i@adamyi.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "ac_memory.h"
#include <memory.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "ac_config.h"
#include "ac_log.h"
#define AC_MEMORY_DEBUG(file, line, values...) \
if (memconf.logging_enabled) _ac_log(file, line, AC_LOG_DEBUG, values)
static ac_memory_config_t memconf = {.type = AC_MEMORY_LIBC_MALLOC,
.panic_on_oom = false,
.logging_enabled = true};
void ac_set_memory_config(ac_memory_config_t *config) {
memcpy(&memconf, config, sizeof(ac_memory_config_t));
}
ac_memory_config_t ac_get_memory_config() { return memconf; }
void *_ac_malloc(const char *file, int line, size_t size, const char *name) {
if (size == 0) {
AC_MEMORY_DEBUG(file, line,
"Tried to allocate memory of size 0 for %s, returned NULL",
name);
return NULL;
}
void *ptr = NULL;
switch (memconf.type) {
case AC_MEMORY_LIBC_MALLOC:
ptr = malloc(size);
break;
case AC_MEMORY_DUMMY_STACK:
if (memconf.size > size) {
memconf.size -= size;
ptr = memconf.region;
memconf.region += size;
}
break;
default:
ac_log(AC_LOG_ERROR, "ac_free: memconf->type invalid");
}
if (ptr == NULL && memconf.panic_on_oom) {
_ac_log(file, line, AC_LOG_FATAL,
"Failed to allocate memory of size %d at %p for %s", size, ptr,
name);
__builtin_unreachable();
}
AC_MEMORY_DEBUG(file, line, "Allocated memory of size %d at %p for %s", size,
ptr, name);
return ptr;
}
void ac_free(void *ptr) {
switch (memconf.type) {
case AC_MEMORY_LIBC_MALLOC:
free(ptr);
break;
case AC_MEMORY_DUMMY_STACK:
// nothing to do...
break;
default:
ac_log(AC_LOG_ERROR, "ac_free: memconf->type invalid");
}
}
| 30 | 79 | 0.647287 |
74c77f7c7b6bcdeeb67d4557d002762e66e58b11 | 4,209 | h | C | cacheTraceAnalysis/simulator/libCacheSim/libMimircache/libMimircache/include/mimircache/heatmap.h | Thesys-lab/cacheWorkloadAnalysisOSDI20 | cfc5bbb5c8d909571546c78c247561c9db449469 | [
"Apache-2.0"
] | 6 | 2020-11-12T07:51:02.000Z | 2022-03-27T20:20:01.000Z | cacheTraceAnalysis/simulator/libCacheSim/libMimircache/libMimircache/include/mimircache/heatmap.h | Thesys-lab/InMemoryCachingWorkloadAnalysis | 5f6f9f7e29a164478f3fc28eb64c170bbbafdec7 | [
"Apache-2.0"
] | null | null | null | cacheTraceAnalysis/simulator/libCacheSim/libMimircache/libMimircache/include/mimircache/heatmap.h | Thesys-lab/InMemoryCachingWorkloadAnalysis | 5f6f9f7e29a164478f3fc28eb64c170bbbafdec7 | [
"Apache-2.0"
] | 1 | 2021-12-31T01:16:09.000Z | 2021-12-31T01:16:09.000Z | //
// heatmap.h
// heatmap
//
// Created by Juncheng on 5/24/16.
// Copyright © 2016 Juncheng. All rights reserved.
//
#ifndef heatmap_h
#define heatmap_h
#include <stdio.h>
#include <stdlib.h>
#include <glib.h>
#include <unistd.h>
#include <math.h>
#include "reader.h"
#include "cache.h"
#include "profilerLRU.h"
#include "const.h"
#include "request.h"
#ifdef __cplusplus
extern "C"
{
#endif
typedef struct {
gint64 bin_size_ld;
gboolean interval_hit_ratio_b;
double ewma_coefficient_lf;
gboolean use_percent_b;
}hm_comp_params_t;
typedef struct {
/*
the data in matrix is stored in column based for performance consideration
because in each computation thread, the result is stored on one column
think it as the x, y coordinates
*/
guint64 xlength;
guint64 ylength;
double** matrix;
double log_base;
}draw_dict;
typedef struct _multithreading_params_heatmap{
int order;
reader_t* reader;
struct cache* cache;
guint64 cache_size;
gint64 bin_size;
gint64 *last_access_dist;
gint64 *stack_dist;
// gint64 *dist;
gboolean interval_hit_ratio_b;
double ewma_coefficient_lf;
gboolean use_percent;
gint64 *future_stack_dist;
GArray* break_points;
draw_dict* dd;
guint64* progress;
GMutex mtx;
// used in rd_distribution
// double log_base;
}mt_params_hm_t;
typedef enum _heatmap_type{
hr_st_et,
hr_st_size,
avg_rd_st_et,
effective_size,
rd_distribution,
future_rd_distribution,
dist_distribution, // this one is not using reuse distance, instead using distance to last access
rt_distribution, // real time distribution, use integer for time
rd_distribution_CDF,
hr_interval_size // hit ratio of current interval and cache size
}heatmap_type_e;
void free_draw_dict(draw_dict* dd);
draw_dict* heatmap(reader_t* reader,
cache_t* cache,
char time_mode,
gint64 time_interval,
gint64 num_of_pixel_for_time_dim,
heatmap_type_e plot_type,
hm_comp_params_t* hm_comp_params,
int num_of_threads);
draw_dict* differential_heatmap(reader_t* reader,
cache_t* cache1,
cache_t* cache2,
char time_mode,
gint64 time_interval,
gint64 num_of_pixels,
heatmap_type_e plot_type,
hm_comp_params_t* hm_comp_params,
int num_of_threads);
draw_dict* heatmap_dist_distribution(reader_t* reader,
const gint64 *dist,
int num_of_threads,
int CDF);
/* heatmap_thread */
void hm_LRU_hr_st_et_thread(gpointer data,
gpointer user_data);
void hm_nonLRU_hr_st_et_thread(gpointer data,
gpointer user_data);
void hm_LRU_hr_interval_size_thread(gpointer data,
gpointer user_data);
void hm_nonLRU_hr_interval_size_thread(gpointer data,
gpointer user_data);
void hm_rd_distribution_thread(gpointer data,
gpointer user_data);
void hm_rd_distribution_CDF_thread(gpointer data,
gpointer user_data);
void hm_effective_size_thread(gpointer data,
gpointer user_data);
void hm_LRU_effective_size_thread(gpointer data, gpointer user_data);
#ifdef __cplusplus
}
#endif
#endif /* heatmap_h */
| 26.471698 | 114 | 0.547398 |
31d1aa2aa05ba7be10c43cf452ecbe01482c8106 | 625 | h | C | kernel/include/arch/arm/arch/64/mode/machine/timer.h | Nexusoft/LLL-OS | 7b0ad5afb339e9bebc65142ee89bded5344cedbe | [
"BSD-2-Clause"
] | 4 | 2020-08-07T19:48:01.000Z | 2020-10-16T20:05:17.000Z | kernel/include/arch/arm/arch/64/mode/machine/timer.h | Nexusoft/LX-OS | 7b0ad5afb339e9bebc65142ee89bded5344cedbe | [
"BSD-2-Clause"
] | null | null | null | kernel/include/arch/arm/arch/64/mode/machine/timer.h | Nexusoft/LX-OS | 7b0ad5afb339e9bebc65142ee89bded5344cedbe | [
"BSD-2-Clause"
] | 2 | 2020-08-13T01:48:40.000Z | 2020-09-17T07:34:42.000Z | /*
* Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
*
* SPDX-License-Identifier: GPL-2.0-only
*/
#pragma once
#include <config.h>
#ifdef CONFIG_KERNEL_MCS
#include <stdint.h>
#include <util.h>
/* timer function definitions that work for all 64 bit arm platforms */
static inline CONST ticks_t getMaxTicksToUs(void)
{
#if USE_KHZ
return UINT64_MAX / TIMER_CLOCK_KHZ;
#else
return UINT64_MAX;
#endif
}
static inline CONST time_t ticksToUs(ticks_t ticks)
{
#if USE_KHZ
return (ticks * TIMER_CLOCK_KHZ) / TIMER_CLOCK_MHZ;
#else
return ticks / TIMER_CLOCK_MHZ;
#endif
}
#endif /* CONFIG_KERNEL_MCS */
| 18.382353 | 71 | 0.7264 |
5a6a39e207b9e510b47294c62a0c3ef021b494a0 | 1,235 | h | C | OutPutHeaders/UrlLabel.h | cocos543/WeChatTimeLineRobot | 1e93480e502e36ca9a21a506f481aa1fcb70ac4b | [
"MIT"
] | 106 | 2016-04-09T01:16:14.000Z | 2021-06-04T00:20:24.000Z | OutPutHeaders/UrlLabel.h | cocos543/WeChatTimeLineRobot | 1e93480e502e36ca9a21a506f481aa1fcb70ac4b | [
"MIT"
] | 2 | 2017-06-13T09:41:29.000Z | 2018-03-26T03:32:07.000Z | OutPutHeaders/UrlLabel.h | cocos543/WeChatTimeLineRobot | 1e93480e502e36ca9a21a506f481aa1fcb70ac4b | [
"MIT"
] | 58 | 2016-04-28T09:52:08.000Z | 2021-12-25T06:42:14.000Z | /**
* This header is generated by class-dump-z 0.2a.
* class-dump-z is Copyright (C) 2009 by KennyTM~, licensed under GPLv3.
*
* Source: (null)
*/
#import "WeChat-Structs.h"
#import "MMCPLabel.h"
@class UIColor, NSString;
@protocol ILinkEventExt;
@interface UrlLabel : MMCPLabel {
NSString* _urlString;
NSString* _backupUrlString;
id<ILinkEventExt> _linkDelegate;
BOOL _ignoreHighlight;
UIColor* _normalBackgroundColor;
UIColor* _highlightedBackgroundColor;
BOOL _bTouchEnds;
}
@property(retain, nonatomic) UIColor* highlightedBackgroundColor;
@property(retain, nonatomic) UIColor* normalBackgroundColor;
@property(assign, nonatomic) BOOL ignoreHighlight;
@property(assign, nonatomic) __weak id<ILinkEventExt> linkDelegate;
@property(retain, nonatomic) NSString* backupUrlString;
@property(retain, nonatomic) NSString* urlString;
-(void).cxx_destruct;
-(void)touchesCancelled:(id)cancelled withEvent:(id)event;
-(void)touchesEnded:(id)ended withEvent:(id)event;
-(void)touchesMoved:(id)moved withEvent:(id)event;
-(void)touchesBegan:(id)began withEvent:(id)event;
-(void)throwUrlMessage;
-(void)setHighlighted:(BOOL)highlighted;
-(void)setHighlightedColor;
-(void)setNormalColor;
-(id)initWithFrame:(CGRect)frame;
@end
| 30.121951 | 72 | 0.779757 |
4c845851bbc8ff887c1e3a66a87d22b609a25207 | 2,452 | h | C | Unix/Write.h | PLPCode/PLPv1b | 6e0f5d91c5a9f94ad478890a17cb6f33c1e5f656 | [
"BSD-2-Clause"
] | 11 | 2019-09-29T18:52:48.000Z | 2021-07-23T08:19:40.000Z | Unix/Write.h | PLPCode/PLPv1b | 6e0f5d91c5a9f94ad478890a17cb6f33c1e5f656 | [
"BSD-2-Clause"
] | 3 | 2019-09-29T18:57:20.000Z | 2021-07-15T18:35:40.000Z | Unix/Write.h | PLPCode/PLPv1b | 6e0f5d91c5a9f94ad478890a17cb6f33c1e5f656 | [
"BSD-2-Clause"
] | 3 | 2020-02-20T11:53:32.000Z | 2021-07-31T18:53:21.000Z | #include <iostream>
#include <string>
#include "Define"
space
/*Write for print*/
out Write(text STR) {
text Command;
Command += "echo ";
Command += dq;
Command += STR;
Command += dq;
Command += " ";
system Command.Cstr);
readers;
}
out Write(text STR, text STR2){
text Command;
Command += "echo ";
Command += dq;
Command += STR;
Command += STR2;
Command += dq;
system Command.Cstr);
readers;
}
/*Counter for Write*/
in Write(text STR, in INT, text STR3) {
print STR << INT << STR3;
readers;
reader
}
in write(in INT, text STR, text STR3) {
print INT << STR << STR3;
reader
}
in Write(text STR, text STR2, in INT) {
print STR << STR2 << INT;
reader
}
out write(text STR, text STR2, text STR3) {
text Command;
Command += "echo ";
Command += dq;
Command += STR;
Command += STR2;
Command += STR3;
Command += dq;
system Command.Cstr);
readers;
}
out Write(text STR, text STR2, text STR3) {
text Command;
Command += "echo ";
Command += dq;
Command += STR;
Command += STR2;
Command += STR3;
Command += dq;
system Command.Cstr);
readers;
}
out Write(text STR, text STR2, text STR3, text STR4) {
text Command;
Command += "echo ";
Command += dq;
Command += STR;
Command += STR2;
Command += STR3;
Command += STR4;
Command += dq;
system Command.Cstr);
readers;
}
out write(text STR, text STR2, text STR3, text STR4) {
text Command;
Command += "echo ";
Command += dq;
Command += STR;
Command += STR2;
Command += STR3;
Command += STR4;
Command += dq;
system Command.Cstr);
readers;
}
/*Number for int*/
in Write(in INT) {
print INT;
reader
}
in Write(text STR, in INT) {
print STR << " " << INT;
reader
}
in Write(in INT, text STR) {
print INT << " " << STR;
reader
}
/*Repeat Code for Easily*/
out write(text STR) {
text Command;
Command += "echo ";
Command += dq;
Command += STR;
Command += dq;
Command += " ";
system Command.Cstr);
}
out write(text STR, text STR2) {
text Command;
Command += "echo ";
Command += dq;
Command += STR;
Command += "\n";
Command += STR2;
Command += dq;
system Command.Cstr);
}
in write(in INT) {
print INT << " ";
reader
}
in write(text STR, in INT) {
print STR << " " << INT;
reader
}
in write(in INT, text STR) {
print INT << " " << STR;
reader
}
/*This Code for Every Number*/
in write(text STR, dec8 Double) {
print STR << " " << Double;
reader
}
in Write(dec8 Double, dec8 Double2) {
print Double << Double2;
reader
}
| 16.567568 | 54 | 0.619086 |
21bbb84f9684574ef55aae1491c059ee8c069018 | 758 | h | C | LWeiKit/Classes/LWSingleton.h | linlishu8/LWeiKit | 58f2321faa2d6d994daa8317adc772a131b70e4b | [
"MIT"
] | null | null | null | LWeiKit/Classes/LWSingleton.h | linlishu8/LWeiKit | 58f2321faa2d6d994daa8317adc772a131b70e4b | [
"MIT"
] | null | null | null | LWeiKit/Classes/LWSingleton.h | linlishu8/LWeiKit | 58f2321faa2d6d994daa8317adc772a131b70e4b | [
"MIT"
] | null | null | null | //
// LWSingleton.h
// LWKitDemo
//
// Created by 动感超人 on 2017/10/13.
// Copyright © 2017年 LiuweiChina. All rights reserved.
//
#define LWSingletonH(ClassName) +(instancetype) share##ClassName;
#define LWSingletonM(ClassName) static id _instance;\
\
+(instancetype)allocWithZone:(struct _NSZone *)zone\
{\
static dispatch_once_t onceToken;\
dispatch_once(&onceToken, ^{\
_instance = [super allocWithZone:zone];\
});\
\
return _instance;\
}\
\
\
+(instancetype)share##ClassName\
{\
static dispatch_once_t onceToken;\
dispatch_once(&onceToken, ^{\
_instance = [[self alloc] init];\
});\
\
return _instance;\
}\
\
\
-(id)copyWithZone:(NSZone *)zone\
{\
return _instance;\
}\
\
\
- (id)mutableCopyWithZone:(nullable NSZone *)zone\
{\
return _instance;\
}
| 16.478261 | 65 | 0.700528 |
90c1de80eb261d631d6d5e1807c20e5248265fc2 | 6,540 | h | C | ace/tao/tao/Pluggable.h | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | 46 | 2015-12-04T17:12:58.000Z | 2022-03-11T04:30:49.000Z | ace/tao/tao/Pluggable.h | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | null | null | null | ace/tao/tao/Pluggable.h | tharindusathis/sourcecodes-of-CodeReadingTheOpenSourcePerspective | 1b0172cdb78757fd17898503aaf6ce03d940ef28 | [
"Apache-1.1"
] | 23 | 2016-10-24T09:18:14.000Z | 2022-02-25T02:11:35.000Z | // This may look like C, but it's really -*- C++ -*-
//=============================================================================
/**
* @file Pluggable.h
*
* Pluggable.h,v 1.82 2001/09/18 00:05:44 irfan Exp
*
* Interface for the TAO pluggable protocol framework.
*
* @author Fred Kuhns <fredk@cs.wustl.edu>
*/
//=============================================================================
#ifndef TAO_PLUGGABLE_H
#define TAO_PLUGGABLE_H
#include "ace/pre.h"
#include "tao/corbafwd.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#include "tao/Sequence.h"
#include "tao/Typecode.h"
#include "tao/IOPC.h"
// Forward declarations.
class ACE_Addr;
class ACE_Reactor;
class TAO_ORB_Core;
class TAO_Stub;
class TAO_Endpoint;
class TAO_Profile;
class TAO_MProfile;
class TAO_Resource_Factory;
class TAO_Reply_Dispatcher;
class TAO_Transport_Mux_Strategy;
class TAO_Wait_Strategy;
class TAO_GIOP_Invocation;
class TAO_Pluggable_Messaging_Interface;
class TAO_Target_Specification;
class TAO_Operation_Details;
class TAO_Transport_Descriptor_Interface;
class TAO_Transport;
// ****************************************************************
/**
* @class TAO_Acceptor
*
* @brief Abstract Acceptor class used for pluggable protocols.
*
* Base class for the Acceptor bridge class.
*/
class TAO_Export TAO_Acceptor
{
public:
TAO_Acceptor (CORBA::ULong tag);
/// Destructor
virtual ~TAO_Acceptor (void);
/// The tag, each concrete class will have a specific tag value.
CORBA::ULong tag (void) const;
/// Method to initialize acceptor for address.
virtual int open (TAO_ORB_Core *orb_core,
ACE_Reactor *reactor,
int version_major,
int version_minor,
const char *address,
const char *options = 0) = 0;
/**
* Open an acceptor with the given protocol version on a default
* endpoint
* @@ This method should be pure virtual, but in order to maintain
* some form of backward compatibilty, a default implementation
* is provided. Ideally, that default implementation should be
* removed in the near future.
*/
virtual int open_default (TAO_ORB_Core *,
ACE_Reactor *reactor,
int version_major,
int version_minor,
const char *options = 0) = 0;
/// Closes the acceptor
virtual int close (void) = 0;
/** Create the corresponding profile for this endpoint.
* If share_profile is set to true, the pluggable protocol
* implementation should try to add the endpoint to a profile
* in the mprofile that is of the same type. Currently, this
* is used when RT CORBA is enabled.
*/
virtual int create_profile (const TAO_ObjectKey &object_key,
TAO_MProfile &mprofile,
CORBA::Short priority) = 0;
/// Return 1 if the <endpoint> has the same address as the acceptor.
virtual int is_collocated (const TAO_Endpoint* endpoint) = 0;
/**
* Returns the number of endpoints this acceptor is listening on. This
* is used for determining how many profiles will be generated
* for this acceptor.
*/
virtual CORBA::ULong endpoint_count (void) = 0;
/**
* This method fetches the <key> from the <profile>. Protocols that
* are pluggable can send data that are specific in the
* <profile_data> field encapsulated as a octet stream. This method
* allows those protocols to get the object key from the
* encapsulation.
*/
virtual int object_key (IOP::TaggedProfile &profile,
TAO_ObjectKey &key) = 0;
private:
/// IOP protocol tag.
CORBA::ULong tag_;
};
/**
* @class TAO_Connector
*
* @brief Generic Connector interface definitions.
*
* Base class for connector bridge object.
*/
class TAO_Export TAO_Connector
{
public:
/// default constructor.
TAO_Connector (CORBA::ULong tag);
/// the destructor.
virtual ~TAO_Connector (void);
/**
* The tag identifying the specific ORB transport layer protocol.
* For example TAO_TAG_IIOP_PROFILE = 0. The tag is used in the
* IOR to identify the type of profile included. IOR -> {{tag0,
* profile0} {tag1, profole1} ...} GIOP.h defines typedef
* CORBA::ULong TAO_IOP_Profile_ID;
*/
CORBA::ULong tag (void) const;
/// Parse a string containing a URL style IOR and return an
/// MProfile.
int make_mprofile (const char *ior,
TAO_MProfile &mprofile,
CORBA::Environment &ACE_TRY_ENV);
/// Initialize object and register with reactor.
virtual int open (TAO_ORB_Core *orb_core) = 0;
/// Shutdown Connector bridge and concrete Connector.
virtual int close (void) = 0;
/**
* To support pluggable we need to abstract away the connect()
* method so it can be called from the GIOP code independant of the
* actual transport protocol in use.
*/
virtual int connect (TAO_GIOP_Invocation *invocation,
TAO_Transport_Descriptor_Interface *desc,
CORBA::Environment &ACE_TRY_ENV) = 0;
/// Initial set of connections to be established.
virtual int preconnect (const char *preconnections) = 0;
/// Create a profile for this protocol and initialize it based on the
/// encapsulation in <cdr>
virtual TAO_Profile *create_profile (TAO_InputCDR& cdr) = 0;
/// Check that the prefix of the provided endpoint is valid for use
/// with a given pluggable protocol.
virtual int check_prefix (const char *endpoint) = 0;
/// Return the object key delimiter to use or expect.
virtual char object_key_delimiter (void) const = 0;
protected:
/// Create a profile with a given endpoint.
virtual TAO_Profile *make_profile (CORBA::Environment &ACE_TRY_ENV) = 0;
/// Set the ORB Core pointer
void orb_core (TAO_ORB_Core *orb_core);
/// Return the TAO_ORB_Core pointer
TAO_ORB_Core *orb_core (void);
private:
/// IOP protocol tag.
CORBA::ULong tag_;
/// Pointer to our ORB core
TAO_ORB_Core *orb_core_;
};
#if defined (__ACE_INLINE__)
# include "tao/Pluggable.i"
#endif /* __ACE_INLINE__ */
#include "ace/post.h"
#endif /* TAO_PLUGGABLE_H */
| 29.59276 | 80 | 0.629511 |
2941a0e0f4cb9ae17b0672be7ab0978ac30510d9 | 381 | h | C | SPARQLKit/Serializers/SPKSPARQLResultsCSVSerializer.h | kasei/SPARQLKit | 3de76ea9ff89e8e017557afc7bfa5621caa1789a | [
"BSD-Source-Code"
] | 6 | 2015-12-04T12:14:37.000Z | 2018-11-22T11:20:03.000Z | SPARQLKit/Serializers/SPKSPARQLResultsCSVSerializer.h | kasei/SPARQLKit | 3de76ea9ff89e8e017557afc7bfa5621caa1789a | [
"BSD-Source-Code"
] | null | null | null | SPARQLKit/Serializers/SPKSPARQLResultsCSVSerializer.h | kasei/SPARQLKit | 3de76ea9ff89e8e017557afc7bfa5621caa1789a | [
"BSD-Source-Code"
] | null | null | null | //
// SPKSPARQLResultsCSVSerializer.h
// SPARQLKit
//
// Created by Gregory Williams on 12/6/13.
// Copyright (c) 2013 Gregory Williams. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GTWSWBase/GTWSWBase.h>
@interface SPKSPARQLResultsCSVSerializer : NSObject<GTWSerializer, GTWSPARQLResultsSerializer>
@property id<GTWSerializerDelegate> delegate;
@end
| 22.411765 | 94 | 0.774278 |
2136ee09ccdccd69e1983b063a8bf16539bf7128 | 11,838 | h | C | FlingEngine/Graphics/inc/GraphicsHelpers.h | BenjaFriend/EngineBay | 402d49dc4378f0672fb66053effa49867b8c6726 | [
"MIT"
] | 315 | 2019-07-27T23:24:26.000Z | 2022-03-23T18:55:31.000Z | FlingEngine/Graphics/inc/GraphicsHelpers.h | flingengine/FlingEngine | 402d49dc4378f0672fb66053effa49867b8c6726 | [
"MIT"
] | 109 | 2019-07-14T19:47:03.000Z | 2022-02-23T21:34:45.000Z | FlingEngine/Graphics/inc/GraphicsHelpers.h | BenjaFriend/EngineBay | 402d49dc4378f0672fb66053effa49867b8c6726 | [
"MIT"
] | 18 | 2019-11-03T16:06:26.000Z | 2022-01-23T03:32:19.000Z | #pragma once
#include "FlingVulkan.h"
#include "FlingTypes.h"
#include "File.h"
#include "Texture.h"
#include "Buffer.h"
#define VK_CHECK_RESULT(f) \
{ \
VkResult res = (f); \
if (res != VK_SUCCESS) \
{ \
F_LOG_ERROR("VkResult is {} in {} at line {}", res, __FILE__, __LINE__); \
assert(res == VK_SUCCESS); \
} \
}
namespace Fling
{
namespace GraphicsHelpers
{
/**
* Find a suitable memory type for use on the current device
*
* @param t_Filter Type of memory types that are suitable for this application
* @param t_Props Memory properties
*
* @return The
*/
uint32 FindMemoryType(VkPhysicalDevice t_PhysicalDevice, uint32 t_Filter, VkMemoryPropertyFlags t_Props);
void CreateBuffer(VkDevice t_Device, VkPhysicalDevice t_PhysicalDevice, VkDeviceSize t_Size, VkBufferUsageFlags t_Usage, VkMemoryPropertyFlags t_Properties, VkBuffer& t_Buffer, VkDeviceMemory& t_BuffMemory);
VkCommandBuffer BeginSingleTimeCommands();
void EndSingleTimeCommands(VkCommandBuffer t_CommandBuffer);
void CreateVkImage(
VkDevice t_Dev,
uint32 t_Width,
uint32 t_Height,
VkFormat t_Format,
VkImageTiling t_Tiling,
VkImageUsageFlags t_Useage,
VkMemoryPropertyFlags t_Props,
VkImage& t_Image,
VkDeviceMemory& t_Memory,
VkSampleCountFlagBits t_NumSamples = VK_SAMPLE_COUNT_1_BIT
);
VkSemaphore CreateSemaphore(VkDevice t_Dev);
void CreateVkImage(
VkDevice t_Dev,
uint32 t_Width,
uint32 t_Height,
uint32 t_MipLevels,
uint32 t_Depth,
uint32 t_ArrayLayers,
VkFormat t_Format,
VkImageTiling t_Tiling,
VkImageUsageFlags t_Useage,
VkMemoryPropertyFlags t_Props,
VkImageCreateFlags t_flags,
VkImage& t_Image,
VkDeviceMemory& t_Memory,
VkSampleCountFlagBits t_NumSamples = VK_SAMPLE_COUNT_1_BIT
);
void CreateVkSampler(
VkFilter t_magFilter,
VkFilter t_minFilter,
VkSamplerMipmapMode t_mipmapMode,
VkSamplerAddressMode t_addressModeU,
VkSamplerAddressMode t_addressModeV,
VkSamplerAddressMode t_addressModeM,
VkBorderColor t_borderColor,
VkSampler& t_sampler
);
void SetImageLayout(
VkCommandBuffer t_cmdbuffer,
VkImage t_image,
VkImageAspectFlags t_aspectMask,
VkImageLayout t_oldImageLayout,
VkImageLayout t_newImageLayout,
VkPipelineStageFlags t_srcStageMask,
VkPipelineStageFlags t_dstStageMask
);
void SetImageLayout(
VkCommandBuffer t_cmdbuffer,
VkImage t_image,
VkImageLayout t_oldImageLayout,
VkImageLayout t_newImageLayout,
VkImageSubresourceRange t_subresourceRange,
VkPipelineStageFlags t_srcStageMask,
VkPipelineStageFlags t_dstStageMask
);
void CreateCommandPool(
VkCommandPool* t_commandPool,
VkCommandPoolCreateFlags t_flags
);
void CreateCommandBuffers(
VkCommandBuffer* t_commandBuffer,
uint32 t_commandBufferCount,
VkCommandPool& t_commandPool
);
void CreatePipelineCache(VkPipelineCache& t_PipelineCache);
VkShaderModule CreateShaderModule(std::shared_ptr<File> t_ShaderCode);
/**
* @brief Create a an image view for Vulkan with the given format
*/
VkImageView CreateVkImageView(VkImage t_Image, VkFormat t_Format, VkImageAspectFlags t_AspectFalgs, uint32 t_MipLevels = 1);
VkFormat FindSupportedFormat(const std::vector<VkFormat>& t_Candidates, VkImageTiling t_Tiling, VkFormatFeatureFlags t_Features);
void TransitionImageLayout(
VkImage t_Image,
VkFormat t_Format,
VkImageLayout t_oldLayout,
VkImageLayout t_NewLayout,
uint32 t_MipLevels = 1
);
/**
* @brief Returns true if the given format has a stencil component
*/
bool HasStencilComponent(VkFormat t_format);
} // namespace GraphicsHelpers
// Some helpers for Vulkan initialization
// Grabbed these from https://github.com/SaschaWillems/Vulkan/tree/master/examples/dynamicuniformbuffer
namespace Initializers
{
VkMappedMemoryRange MappedMemoryRange();
VkDescriptorPoolSize DescriptorPoolSize(VkDescriptorType t_type, uint32 t_descriptorCount);
VkPipelineVertexInputStateCreateInfo PiplineVertexInptStateCreateInfo();
VkDescriptorPoolCreateInfo DescriptorPoolCreateInfo(
const std::vector<VkDescriptorPoolSize>& t_poolSizes,
uint32 t_maxSets
);
VkMemoryAllocateInfo MemoryAllocateInfo();
VkDescriptorSetLayoutBinding DescriptorSetLayoutBindings(
VkDescriptorType t_type,
VkShaderStageFlags t_stageFlags,
uint32 t_binding,
uint32 t_descriptorCount = 1
);
VkDescriptorSetLayoutCreateInfo DescriptorSetLayoutCreateInfo(
const std::vector<VkDescriptorSetLayoutBinding>& t_bindings
);
inline VkRenderPassBeginInfo RenderPassBeginInfo()
{
VkRenderPassBeginInfo renderPassBeginInfo{};
renderPassBeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
return renderPassBeginInfo;
}
VkWriteDescriptorSet WriteDescriptorSetUniform(
Buffer* t_Buffer,
VkDescriptorSet t_DstSet,
uint32 t_Binding,
uint32 t_Set = 0,
VkDeviceSize t_Offset = 0);
VkWriteDescriptorSet WriteDescriptorSetImage(
Texture* t_Image,
VkDescriptorSet t_DstSet,
uint32 t_Binding,
uint32 t_Set = 0,
VkDeviceSize t_Offset = 0);
VkSamplerCreateInfo SamplerCreateInfo();
VkImageViewCreateInfo ImageViewCreateInfo();
VkDescriptorSetAllocateInfo DescriptorSetAllocateInfo(
VkDescriptorPool t_descriptorPool,
const VkDescriptorSetLayout* t_pSetLayouts,
uint32 t_descriptorSetCount
);
VkDescriptorImageInfo DescriptorImageInfo(
VkSampler t_sampler,
VkImageView t_imageView,
VkImageLayout t_imageLayout
);
VkWriteDescriptorSet WriteDescriptorSet(
VkDescriptorSet t_dstSet,
VkDescriptorType t_type,
uint32 t_binding,
VkDescriptorImageInfo* imageInfo,
uint32 descriptorCount = 1
);
VkPushConstantRange PushConstantRange(
VkShaderStageFlags t_stageFlags,
uint32 t_size,
uint32 t_offset
);
VkPipelineLayoutCreateInfo PiplineLayoutCreateInfo(
const VkDescriptorSetLayout* t_pSetLayouts,
uint32 t_setLayoutCount = 1
);
VkPipelineInputAssemblyStateCreateInfo PipelineInputAssemblyStateCreateInfo(
VkPrimitiveTopology t_topology,
VkPipelineInputAssemblyStateCreateFlags t_flags,
VkBool32 t_primitiveRestartEnable
);
VkPipelineRasterizationStateCreateInfo PipelineRasterizationStateCreateInfo(
VkPolygonMode t_polygonMode,
VkCullModeFlags t_cullMode,
VkFrontFace t_frontFace,
VkPipelineRasterizationStateCreateFlags t_flags = 0
);
VkPipelineColorBlendStateCreateInfo PipelineColorBlendStateCreateInfo(
uint32 t_attachmentCount,
const VkPipelineColorBlendAttachmentState* t_pAttachments
);
VkPipelineColorBlendAttachmentState PipelineColorBlendAttachmentState(
VkColorComponentFlags t_colorWriteMask,
VkBool32 t_blendEnable
);
inline VkPipelineDepthStencilStateCreateInfo PipelineDepthStencilStateCreateInfo(
VkBool32 depthTestEnable,
VkBool32 depthWriteEnable,
VkCompareOp depthCompareOp)
{
VkPipelineDepthStencilStateCreateInfo pipelineDepthStencilStateCreateInfo{};
pipelineDepthStencilStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
pipelineDepthStencilStateCreateInfo.depthTestEnable = depthTestEnable;
pipelineDepthStencilStateCreateInfo.depthWriteEnable = depthWriteEnable;
pipelineDepthStencilStateCreateInfo.depthCompareOp = depthCompareOp;
pipelineDepthStencilStateCreateInfo.front = pipelineDepthStencilStateCreateInfo.back;
pipelineDepthStencilStateCreateInfo.back.compareOp = VK_COMPARE_OP_ALWAYS;
return pipelineDepthStencilStateCreateInfo;
}
inline VkPipelineDynamicStateCreateInfo PipelineDynamicStateCreateInfo(
const VkDynamicState* pDynamicStates,
uint32_t dynamicStateCount,
VkPipelineDynamicStateCreateFlags flags = 0)
{
VkPipelineDynamicStateCreateInfo pipelineDynamicStateCreateInfo{};
pipelineDynamicStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
pipelineDynamicStateCreateInfo.pDynamicStates = pDynamicStates;
pipelineDynamicStateCreateInfo.dynamicStateCount = dynamicStateCount;
pipelineDynamicStateCreateInfo.flags = flags;
return pipelineDynamicStateCreateInfo;
}
VkPipelineDepthStencilStateCreateInfo DepthStencilState(
VkBool32 t_depthTestEnable,
VkBool32 t_depthWriteEnable,
VkCompareOp t_depthCompareOp
);
VkPipelineViewportStateCreateInfo PipelineViewportStateCreateInfo(
uint32 t_viewportCount,
uint32 t_scissorCount,
VkPipelineViewportStateCreateFlags t_flags = 0
);
VkPipelineMultisampleStateCreateInfo PipelineMultiSampleStateCreateInfo(
VkSampleCountFlagBits t_rasterizationSamples,
VkPipelineMultisampleStateCreateFlags t_flags = 0
);
VkPipelineDynamicStateCreateInfo PipelineDynamicStateCreateInfo(
const std::vector<VkDynamicState>& t_pDynamicStates,
VkPipelineDynamicStateCreateFlags t_flags = 0
);
VkGraphicsPipelineCreateInfo PipelineCreateInfo(
VkPipelineLayout t_layout,
VkRenderPass t_renderPass,
VkPipelineCreateFlags t_flags = 0
);
VkVertexInputBindingDescription VertexInputBindingDescription(
uint32 t_binding,
uint32 t_stride,
VkVertexInputRate t_inputRate
);
VkVertexInputAttributeDescription VertexInputAttributeDescription(
uint32 t_binding,
uint32 t_location,
VkFormat t_format,
uint32 t_offset
);
VkViewport Viewport(
float t_width,
float t_height,
float t_minDepth,
float t_maxDepth
);
VkDescriptorSetLayoutBinding DescriptorSetLayoutBinding(
VkDescriptorType type,
VkShaderStageFlags stageFlags,
uint32_t binding,
uint32_t descriptorCount = 1
);
VkWriteDescriptorSet WriteDescriptorSet(
VkDescriptorSet dstSet,
VkDescriptorType type,
uint32_t binding,
VkDescriptorBufferInfo* bufferInfo,
uint32_t descriptorCount = 1
);
VkRect2D Rect2D(
int32_t width,
int32_t height,
int32_t offsetX,
int32_t offsetY
);
}
} // namespace Fling
| 34.115274 | 215 | 0.669708 |
426b33f823aff29c60d33b5cc00cd6071c9f283f | 2,778 | h | C | third_party/codecs/xvidcore/src/utils/timer.h | Narflex/sagetv | 76cb5755e54fd3b01d2bb708a8a72af0aa1533f1 | [
"Apache-2.0"
] | 292 | 2015-08-10T18:34:55.000Z | 2022-01-26T00:38:45.000Z | third_party/codecs/xvidcore/src/utils/timer.h | Narflex/sagetv | 76cb5755e54fd3b01d2bb708a8a72af0aa1533f1 | [
"Apache-2.0"
] | 366 | 2015-08-10T18:21:02.000Z | 2022-01-22T20:03:41.000Z | third_party/codecs/xvidcore/src/utils/timer.h | Narflex/sagetv | 76cb5755e54fd3b01d2bb708a8a72af0aa1533f1 | [
"Apache-2.0"
] | 227 | 2015-08-10T22:24:29.000Z | 2022-02-25T19:16:21.000Z | /*****************************************************************************
*
* XVID MPEG-4 VIDEO CODEC
* - Timer related header (used for internal debugging) -
*
* Copyright(C) 2002 Michael Militzer <isibaar@xvid.org>
*
* This program is free software ; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id: timer.h 1985 2011-05-18 09:02:35Z Isibaar $
*
****************************************************************************/
#ifndef _ENCORE_TIMER_H
#define _ENCORE_TIMER_H
#if defined(_PROFILING_)
#include "../portab.h"
uint64_t count_frames;
extern void start_timer(void);
extern void start_global_timer(void);
extern void stop_dct_timer(void);
extern void stop_idct_timer(void);
extern void stop_motion_timer(void);
extern void stop_comp_timer(void);
extern void stop_edges_timer(void);
extern void stop_inter_timer(void);
extern void stop_quant_timer(void);
extern void stop_iquant_timer(void);
extern void stop_conv_timer(void);
extern void stop_transfer_timer(void);
extern void stop_coding_timer(void);
extern void stop_prediction_timer(void);
extern void stop_interlacing_timer(void);
extern void stop_global_timer(void);
extern void init_timer(void);
extern void write_timer(void);
#else
static __inline void
start_timer(void)
{
}
static __inline void
start_global_timer(void)
{
}
static __inline void
stop_dct_timer(void)
{
}
static __inline void
stop_idct_timer(void)
{
}
static __inline void
stop_motion_timer(void)
{
}
static __inline void
stop_comp_timer(void)
{
}
static __inline void
stop_edges_timer(void)
{
}
static __inline void
stop_inter_timer(void)
{
}
static __inline void
stop_quant_timer(void)
{
}
static __inline void
stop_iquant_timer(void)
{
}
static __inline void
stop_conv_timer(void)
{
}
static __inline void
stop_transfer_timer(void)
{
}
static __inline void
init_timer(void)
{
}
static __inline void
write_timer(void)
{
}
static __inline void
stop_coding_timer(void)
{
}
static __inline void
stop_interlacing_timer(void)
{
}
static __inline void
stop_prediction_timer(void)
{
}
static __inline void
stop_global_timer(void)
{
}
#endif
#endif /* _TIMER_H_ */
| 21.045455 | 78 | 0.726062 |
34f45cbf8e1d6abe5b6ea2ae422369f3ec869b45 | 1,130 | h | C | firmware/coreboot/src/include/adainit.h | fabiojna02/OpenCellular | 45b6a202d6b2e2485c89955b9a6da920c4d56ddb | [
"CC-BY-4.0",
"BSD-3-Clause"
] | 1 | 2019-11-04T07:11:25.000Z | 2019-11-04T07:11:25.000Z | firmware/coreboot/src/include/adainit.h | fabiojna02/OpenCellular | 45b6a202d6b2e2485c89955b9a6da920c4d56ddb | [
"CC-BY-4.0",
"BSD-3-Clause"
] | 13 | 2018-10-12T21:29:09.000Z | 2018-10-25T20:06:51.000Z | firmware/coreboot/src/include/adainit.h | fabiojna02/OpenCellular | 45b6a202d6b2e2485c89955b9a6da920c4d56ddb | [
"CC-BY-4.0",
"BSD-3-Clause"
] | null | null | null | /*
* This file is part of the coreboot project.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef _ADAINIT_H
#define _ADAINIT_H
/**
* @file adainit.h
*
* Ada supports some complex constructs that result in code for runtime
* initialization. It's also possible to have explicit procedures for
* package level initialization (e.g. you can initialize huge arrays in
* a loop instead of cluttering the binary).
*
* When an Ada main() is in charge, GNAT emmits the call to the initia-
* lizations automatically. When not, we have to call it explicitly.
*/
#if IS_ENABLED(CONFIG_RAMSTAGE_ADA)
void ramstage_adainit(void);
#else
static inline void ramstage_adainit(void) {}
#endif
#endif /* _ADAINIT_H */
| 31.388889 | 71 | 0.750442 |
550d056e56d4330c6847d6ee56af11e526fd4e92 | 12,560 | h | C | include/3dim/qtplugin/PluginInterface.h | SindenDev/3dimviewer | e23a3147edc35034ef4b75eae9ccdcbc7192b1a1 | [
"Apache-2.0"
] | 6 | 2020-04-14T16:10:55.000Z | 2021-05-21T07:13:55.000Z | include/3dim/qtplugin/PluginInterface.h | SindenDev/3dimviewer | e23a3147edc35034ef4b75eae9ccdcbc7192b1a1 | [
"Apache-2.0"
] | null | null | null | include/3dim/qtplugin/PluginInterface.h | SindenDev/3dimviewer | e23a3147edc35034ef4b75eae9ccdcbc7192b1a1 | [
"Apache-2.0"
] | 2 | 2020-07-24T16:25:38.000Z | 2021-01-19T09:23:18.000Z | ///////////////////////////////////////////////////////////////////////////////
// $Id$
//
// 3DimViewer
// Lightweight 3D DICOM viewer.
//
// Copyright 2008-2016 3Dim Laboratory s.r.o.
//
// 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 _QT_PLUGININTERFACE_H
#define _QT_PLUGININTERFACE_H
#include <QtPlugin>
#include <QTranslator>
#include <QTextCodec>
#include <QApplication>
#include <QLocale>
#include <QLibraryInfo>
#include <QFileInfo>
class QStringList;
class QRect;
class QString;
class QPainter;
class QPoint;
class QMenu;
class QToolBar;
class QWidget;
class QAction;
#include <VPL/Base/Object.h>
#include <VPL/Base/SharedPtr.h>
#include <VPL/Base/Exception.h>
#include <data/CDataStorage.h>
#include <osg/CAppMode.h>
#include <render/CVolumeRenderer.h>
#include "CPluginInfo.h"
#ifndef PLUG_APP_SIGNATURE
#define PLUG_APP_SIGNATURE "OpenSource"
#endif
class PluginInterface;
///////////////////////////////////////////////////////////////////////////////
//! Class manages application interface.
class CAppBindings : public vpl::base::CObject
{
public:
//! Smart pointer type.
VPL_SHAREDPTR(CAppBindings);
//! Exception thrown in case of an error.
VPL_DECLARE_EXCEPTION(CNullAppBindings, "Trying to access application bindings via NULL pointer")
public:
//! Default constructor.
CAppBindings()
: vpl::base::CObject()
, m_pAppMode(NULL)
, m_pStorage(NULL)
, m_pRenderer(NULL)
, m_pParent(NULL)
, m_pPlugin(NULL)
, m_vplSignals(NULL)
{
}
//! Kind of copy constructor
CAppBindings(CAppBindings* pBindings)
: vpl::base::CObject()
, m_pAppMode(NULL)
, m_pStorage(NULL)
, m_pRenderer(NULL)
, m_pParent(NULL)
, m_pPlugin(NULL)
, m_vplSignals(NULL)
{
Q_ASSERT(pBindings);
if (NULL!=pBindings)
{
m_pAppMode = pBindings->getAppMode();
m_pStorage = pBindings->getDataStorage();
m_pParent = pBindings->getParentWindow();
m_pPlugin = pBindings->getPluginInstance();
m_pRenderer = pBindings->getRenderer();
m_vplSignals = pBindings->getVPLSignals();
}
}
//! Destructor.
virtual ~CAppBindings()
{
}
//! Initializes binding of the plugin to application.
CAppBindings& setPluginInstance(PluginInterface *pPlugin)
{
m_pPlugin = pPlugin;
return *this;
}
//! Returns pointer to the plugin instance.
PluginInterface *getPluginInstance()
{
if( !m_pPlugin )
{
throw CNullAppBindings();
}
return m_pPlugin;
}
//! Initializes binding of the plugin to application.
CAppBindings& setAppMode(scene::CAppMode *pAppMode)
{
m_pAppMode = pAppMode;
return *this;
}
//! Returns pointer to the object managing mouse mode in the application.
scene::CAppMode *getAppMode()
{
if( !m_pAppMode )
{
throw CNullAppBindings();
}
return m_pAppMode;
}
//! Initializes binding of the plugin to application.
CAppBindings& setDataStorage(data::CDataStorage *pStorage)
{
m_pStorage = pStorage;
return *this;
}
//! Returns pointer to the object managing data in the application.
data::CDataStorage *getDataStorage()
{
if( !m_pStorage )
{
throw CNullAppBindings();
}
return m_pStorage;
}
//! Initializes binding of the plugin to application.
CAppBindings& setRenderer(CVolumeRenderer *pRenderer)
{
if (m_pRenderer != nullptr)
{
onRendererDelete();
}
m_pRenderer = pRenderer;
return *this;
}
//! Returns pointer to the volume renderer in the application.
CVolumeRenderer *getRenderer()
{
return m_pRenderer;
}
//! Sets pointer to application's main window
CAppBindings& setParentWindow(QWidget* pParent)
{
m_pParent = pParent;
return *this;
}
//! Returns pointer to the application's main window
QWidget *getParentWindow()
{
return m_pParent;
}
//! Sets pointer to application's main window
CAppBindings& setVPLSignals(std::map<int,vpl::base::CObject*>* pSignals)
{
m_vplSignals = pSignals;
return *this;
}
//! Returns pointer to the application's main window
std::map<int,vpl::base::CObject*> *getVPLSignals()
{
return m_vplSignals;
}
//! Sets information on the current language to plugin
// localeDir - folder where to search translations
// lngFile - app language file (same name as locale name)
// fileName - plugin file name
void setLanguage(const QString &localeDir, const QString& lngFile, const QString& fileName)
{
m_wcsLocale = lngFile;
if (!fileName.isEmpty())
{
if (lngFile.isNull() || lngFile.isEmpty())
{
// English - do nothing
}
else
{
QFileInfo file(fileName.toLower());
#ifdef QT_DEBUG // remove d suffix
QString pluginFileName(file.baseName());
if (pluginFileName.endsWith('d'))
{
pluginFileName.chop(1);
pluginFileName=pluginFileName+"."+file.completeSuffix();
file.setFile(pluginFileName);
}
#endif
#ifdef __APPLE__ // remove lib prefix
QString pluginFileNameA(file.baseName());
if (pluginFileNameA.startsWith("lib",Qt::CaseInsensitive))
{
pluginFileNameA = pluginFileNameA.right(pluginFileNameA.length()-3)+"."+file.completeSuffix();
file.setFile(pluginFileNameA);
}
#endif
if ((!localeDir.isEmpty() && m_translator.load( localeDir+"/"+file.baseName()+"-"+lngFile )) || // try to load from localeDir
m_translator.load( file.baseName()+"-"+lngFile )) // try to load from current working dir
{
QApplication::installTranslator(&m_translator);
}
else
{ // try to load from app dir
QString path=QCoreApplication::applicationDirPath();
if (m_translator.load( path+"/"+file.baseName()+"-"+lngFile ))
{
QApplication::installTranslator(&m_translator);
}
}
}
}
}
protected:
virtual void onRendererDelete()
{ }
protected:
//! Pointer to the class managing mouse mode in the application.
scene::CAppMode *m_pAppMode;
//! Pointer to the class managing data in the application.
data::CDataStorage *m_pStorage;
//! Pointer to renderer
CVolumeRenderer *m_pRenderer;
//! Pointer to parent window
QWidget* m_pParent;
//! Info about preferred language
QString m_wcsLocale;
//! Plugin translator object
QTranslator m_translator;
//! Pointer to the plugin instance
PluginInterface* m_pPlugin;
//! Mapping of vpl signals
std::map<int,vpl::base::CObject*>* m_vplSignals;
};
///////////////////////////////////////////////////////////////////////////////
//! 3Dim plugin interface
class PluginInterface : public CAppBindings
{
public:
//! Constructor with some basic initialization
PluginInterface() { setPluginInstance(this); }
public:
//! Empty virtual destructor to avoid some compiler warnings
virtual ~PluginInterface() {}
//! Create Plugin's Menu, can be NULL
//! Please note that the Menu, ToolBar and Panel are erased by the host application
virtual QMenu* getOrCreateMenu() = 0;
//! Create Plugin's Toolbar, can be NULL
virtual QToolBar* getOrCreateToolBar() = 0;
//! Create Plugin's Panel, can be NULL
//! - note that windowTitle and objectName of the Panels has to be valid
//! and in case of objectName it should be also unique
virtual QWidget* getOrCreatePanel() = 0;
//! Return pointer to action so the host application can trigger it
virtual QAction* getAction(const QString &actionName) = 0;
//! Return localized plugin name
virtual QString pluginName() = 0;
//! Return unique non localized plugin name eg "DataExpress"
virtual QString pluginID() = 0;
//! Method called by the main application when the plugin is connected
virtual void connectPlugin() = 0;
//! Method called by the main application when the plugin is disconnected
virtual void disconnectPlugin() = 0;
protected:
//! Method called on renderer delete
virtual void onRendererDelete()
{ }
};
Q_DECLARE_INTERFACE(PluginInterface, "com.3dim-laboratory.PluginInterface/1.0")
// License handling interface
#define PLUGIN_LICENSE_CHECK_OCCASIONALLY 1
#define PLUGIN_LICENSE_SHOW_DIALOG 2
class PluginLicenseInterface : public plug::CPluginInfo
{
public:
//! Default constructor with plugin info
PluginLicenseInterface(const std::string& ssHost,
const std::string& ssName,
const std::string& ssActName,
int MajorNum,
int MinorNum = 0
) :
plug::CPluginInfo(ssHost,ssName,ssActName,MajorNum,MinorNum)
{}
//! Checks if the product license is valid.
//! - Returns an error code, see the CActivationPolicy class.
//! - Implement this method according to your needs.
//! - Default version of the method does no license checking!
//! - Handle of the plugin (i.e. pointer to the parent wxWindow object must be set)!
virtual int validateLicense(int Flags = 0) = 0;
//! Checks available exports in the product license
virtual bool canExport(const QString& seriesID) = 0;
//! Notifies that a series was exported (->inc used exports count)
virtual void wasExported(const QString& seriesID) = 0;
};
Q_DECLARE_INTERFACE(PluginLicenseInterface, "com.3dim-laboratory.PluginLicenseInterface/1.1")
//
///////////////////////////////////////////////////////////////////////////////
//! Macro returns reference to the application mode.
//! - This macro may be used within any class derived from the CAppBindings class.
#define PLUGIN_APP_MODE (*getAppMode())
//! Returns reference to the application data storage.
//! - This macro may be used within any class derived from the CAppBindings class.
#define PLUGIN_APP_STORAGE (*getDataStorage())
//! Macro returns reference to volume renderer usable for rendering of custom volume data.
//! - This macro may be used within any class derived from the CAppBindings class.
#define PLUGIN_RENDERER (*getRenderer())
//! Returns reference to the plugin.
//! - This macro may be used within any class derived from the CAppBindings class.
#define PLUGIN_INSTANCE (*getPluginInstance())
#define PLUGIN_LICENSE_INSTANCE (*(dynamic_cast<PluginLicenseInterface*>(getPluginInstance())))
//! Plugin VPL signals access - beware that only a subset of all signals is available!
#define PLUGIN_VPL_SIGNAL_AVAILABLE(x) (NULL!=(dynamic_cast<decltype(&(VPL_SIGNAL(x)))>((*m_vplSignals)[VPL_SIGNAL(x).getId()])))
#define PLUGIN_VPL_SIGNAL(x) (*(dynamic_cast<decltype(&(VPL_SIGNAL(x)))>((*m_vplSignals)[VPL_SIGNAL(x).getId()])))
#endif // _QT_PLUGININTERFACE_H
| 31.243781 | 142 | 0.60008 |
519842f61f6c37bac9c57a31404945a051810a63 | 3,967 | h | C | src/engine/engine.h | 1Macho/mkpixel | cd5890b4169d0b6934ef7980ef16b7896231e4d2 | [
"BSD-2-Clause"
] | null | null | null | src/engine/engine.h | 1Macho/mkpixel | cd5890b4169d0b6934ef7980ef16b7896231e4d2 | [
"BSD-2-Clause"
] | null | null | null | src/engine/engine.h | 1Macho/mkpixel | cd5890b4169d0b6934ef7980ef16b7896231e4d2 | [
"BSD-2-Clause"
] | null | null | null | #ifndef ENGINE_ENGINE_H
#define ENGINE_ENGINE_H
#include <GLFW/glfw3.h>
#include <stdio.h>
#include <stdlib.h>
#include <AL/al.h>
#include <AL/alc.h>
#include "audio.h"
#include "palette.h"
#include "colour.h"
#include "framebuffer.h"
typedef struct {
GLFWwindow *window;
int screenWidth;
int screenHeight;
char *title;
double nowTime;
double lastTime;
double dt;
unsigned int fbID;
unsigned int fbWidth;
unsigned int fbHeight;
unsigned int upscale;
Framebuffer *fb;
Palette *palette;
ALCdevice *audio_device;
ALCcontext *audio_context;
ALuint audio_sources[256];
void (*on_update)(double dt);
void (*on_draw)();
void (*callback_window_size)(GLFWwindow *window, int width,
int height);
void (*callback_key)(GLFWwindow *window, int key,
int scancode, int action, int mods);
void (*callback_fbt_input)(GLFWwindow *window,
unsigned int codepoint);
void (*callback_cursor_position)(GLFWwindow *window,
double xpos, double ypos);
} Engine;
Engine *newEngine(unsigned int tW, unsigned int tH,
unsigned int upscale, char *title) {
// Engine *self = malloc(sizeof(*self));
Engine *self = (Engine *)calloc(1, sizeof(*self));
self->upscale = upscale;
self->screenWidth = tW * upscale;
self->screenHeight = tH * upscale;
self->fbWidth = tW;
self->fbHeight = tH;
self->palette = defaultPalette();
self->fb = newFramebuffer(self->fbWidth, self->fbHeight);
self->title = title;
// engine_init(self);
return self;
}
int engine_init(Engine *self) {
// Initalize glfw and window stuff.
if (!glfwInit())
return -1;
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
self->window = glfwCreateWindow(self->screenWidth,
self->screenHeight, self->title, NULL, NULL);
if (!self->window) {
glfwTerminate();
return -1;
}
glfwSetWindowSizeCallback(self->window,
self->callback_window_size);
glfwSetKeyCallback(self->window,
self->callback_key);
glfwSetCharCallback(self->window,
self->callback_fbt_input);
glfwSetCursorPosCallback(self->window,
self->callback_cursor_position);
glfwMakeContextCurrent(self->window);
// Initialize screen texture.
glEnable(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
glGenTextures(1, &self->fbID);
// Initialize audio stuff.
audio_check_errors("Pre init");
self->audio_device = alcOpenDevice(NULL);
audio_check_errors("Device");
if (!self->audio_device) {
return -1;
}
self->audio_context = alcCreateContext(self->audio_device,
NULL);
audio_check_errors("Context");
if (!alcMakeContextCurrent(self->audio_context)) {
return -1;
}
alGenSources(256, (ALuint*)&self->audio_sources);
audio_check_errors("Source gen");
return 0;
}
void engine_draw(Engine *self) {
glClear(GL_COLOR_BUFFER_BIT);
if(self->on_draw != NULL) {
self->on_draw(self->fb);
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, self->fbWidth,
self->fbHeight, 0, GL_RGB, GL_UNSIGNED_BYTE,
self->fb->data);
glBegin(GL_TRIANGLES);
glTexCoord2f(0.0, 1.0); // 01
glVertex2f(-1.0f, -1.0f);
glTexCoord2f(0.0, 0.0); // 00
glVertex2f(-1.0f, 1.0f);
glTexCoord2f(1.0, 1.0); // 11
glVertex2f(1.0f, -1.0f);
glTexCoord2f(1.0, 1.0); // 11
glVertex2f(1.0f, -1.0f);
glTexCoord2f(0.0, 0.0); // 00
glVertex2f(-1.0f, 1.0f);
glTexCoord2f(1.0, 0.0); // 10
glVertex2f(1.0f, 1.0f);
glEnd();
glfwSwapBuffers(self->window);
}
void engine_tick(Engine *self) {
self->nowTime = glfwGetTime();
self->dt = (self->nowTime - self->lastTime);
self->lastTime = self->nowTime;
//printf("%f\n", 1/self->dt);
if (self->on_update != NULL) {
self->on_update(self->dt);
}
engine_draw(self);
glfwPollEvents();
}
void engine_run(Engine *self) {
while (!glfwWindowShouldClose(self->window)) {
engine_tick(self);
}
glfwTerminate();
}
#endif
| 22.539773 | 62 | 0.684396 |
8e01088db9c62ba1f622dd0220588a2b2e44fedc | 790 | h | C | src/misc_functions.h | babetoduarte/EF5 | 5e469f288bce82259e85d26a3f30f7dc260547fb | [
"Unlicense"
] | 20 | 2016-09-20T15:19:54.000Z | 2021-09-04T21:53:30.000Z | src/misc_functions.h | chrimerss/EF5 | c97ed83ead8fd764f7c94731fd5bf74761a0bb3d | [
"Unlicense"
] | 10 | 2016-09-20T17:13:00.000Z | 2022-03-20T12:53:37.000Z | src/misc_functions.h | chrimerss/EF5 | c97ed83ead8fd764f7c94731fd5bf74761a0bb3d | [
"Unlicense"
] | 20 | 2016-12-01T21:41:40.000Z | 2021-08-07T06:11:43.000Z | #ifndef MISC_FUNCTIONS_H
#define MISC_FUNCTIONS_H
enum MVOPS { MVOP_MEAN, MVOP_VAR, MVOP_STD, MVOP_MAX, MVOP_MIN };
void allocate2D(float ***array, int nrows, int ncols);
void deallocate2D(float ***array, int nrows);
void nrandn(float **pArray, int nrows, int ncols);
float sumarray(float *array, int nrows, int ncols);
void randperm(int **array, int n);
void reshape(float **oldarray, int m0, int n0, float ***newarray, int m, int n);
float meanvar(float *arr, int no, MVOPS option);
void transp(float **oldarray, int m0, int n0, float ***newarray,
bool preallocated = false);
float percentile(float *array, int nelem, float pctile);
void sortarray(float *array, int n, const char *option);
void sortrows(float **array1, int nr, int nc, int sort_col, float **array2);
#endif
| 41.578947 | 80 | 0.724051 |
79b5f18f83ff280241ce3e26fe9acd2dbb089e7b | 298 | h | C | Demo Code/polymorphism_examples/otter_class_example/teal_sea_otter.h | pranavas11/CS162-Introduction-to-CS-II | c17c5c1f844de1be4a49646201d77717394dfdbc | [
"MIT"
] | null | null | null | Demo Code/polymorphism_examples/otter_class_example/teal_sea_otter.h | pranavas11/CS162-Introduction-to-CS-II | c17c5c1f844de1be4a49646201d77717394dfdbc | [
"MIT"
] | null | null | null | Demo Code/polymorphism_examples/otter_class_example/teal_sea_otter.h | pranavas11/CS162-Introduction-to-CS-II | c17c5c1f844de1be4a49646201d77717394dfdbc | [
"MIT"
] | null | null | null | /*
Teal Sea Otter Class
*/
#ifndef TEAL_SEA_OTTER_H
#define TEAL_SEA_OTTER_H
#include <iostream>
#include "sea_otter.h"
using namespace std;
class Teal_Sea_Otter : public Sea_Otter {
public:
Teal_Sea_Otter(string);
void make_noise(int) override;
void swim(int) override;
private:
};
#endif
| 14.190476 | 41 | 0.758389 |
19ede9c3afd9ca440d91bd9c77f1bbed6b09b9a1 | 739 | h | C | Frameworks/DeepWallKids.xcframework/ios-i386_x86_64-simulator/DeepWallKids.framework/Headers/PloutosValidateReceiptFailed.h | Teknasyon-Teknoloji/deepwallkids-ios-sdk | cb4271a126b2e4e9e4447dd8ffff4220b0ab50f0 | [
"MIT"
] | 6 | 2020-11-08T13:07:51.000Z | 2021-12-23T13:57:01.000Z | Frameworks/DeepWallKids.xcframework/ios-i386_x86_64-simulator/DeepWallKids.framework/Headers/PloutosValidateReceiptFailed.h | Teknasyon-Teknoloji/deepwallkids-ios-sdk | cb4271a126b2e4e9e4447dd8ffff4220b0ab50f0 | [
"MIT"
] | 3 | 2020-11-27T12:31:22.000Z | 2022-02-23T06:13:20.000Z | Frameworks/DeepWallKids.xcframework/ios-i386_x86_64-simulator/DeepWallKids.framework/Headers/PloutosValidateReceiptFailed.h | Teknasyon-Teknoloji/deepwallkids-ios-sdk | cb4271a126b2e4e9e4447dd8ffff4220b0ab50f0 | [
"MIT"
] | 2 | 2021-04-19T02:53:40.000Z | 2022-02-07T14:16:04.000Z | //
// PloutosValidateReceiptFailed.h
// Ploutos
//
// Created by Burak Yalcin on 6.10.2020.
//
#import <Foundation/Foundation.h>
#import "PloutosValidationType.h"
NS_ASSUME_NONNULL_BEGIN
/// Ploutos validate receipt result when request is failed
@interface PloutosValidateReceiptFailed : NSObject
/// Validation type
@property (nonatomic) PloutosValidationType type;
/// Error code
@property (nonatomic, strong) NSString *errorCode;
/// Failure reason message
@property (nonatomic, strong) NSString *reason;
/// UNAVAILABLE
- (instancetype)init NS_UNAVAILABLE;
/// Initialize method
- (instancetype)initWithType:(PloutosValidationType)type errorCode:(NSString *)errorCode reason:(NSString *)reason;
@end
NS_ASSUME_NONNULL_END
| 21.735294 | 115 | 0.775372 |
616595e4cfe9f6f6fdc97ff472d50bf66d819442 | 2,328 | h | C | src/include/vuh/utils/utils.h | wangqiang1588/vuh | 20450436022b5386a0da3a82062bd49813993180 | [
"MIT"
] | null | null | null | src/include/vuh/utils/utils.h | wangqiang1588/vuh | 20450436022b5386a0da3a82062bd49813993180 | [
"MIT"
] | null | null | null | src/include/vuh/utils/utils.h | wangqiang1588/vuh | 20450436022b5386a0da3a82062bd49813993180 | [
"MIT"
] | null | null | null | #pragma once
#include <cstdint>
#include <vector>
#include <vuh/device.h>
namespace vuh {
/// Typelist. That is all about it.
template<class... Ts> struct typelist{};
/// @return nearest integer bigger or equal to exact division value
inline auto div_up(uint32_t x, uint32_t y){ return (x + y - 1u)/y; }
/// Read binary shader file into array of uint32_t. little endian assumed.
/// Padded by 0s to a boundary of 4.
auto read_spirv(const char* fn)-> std::vector<char>;
namespace utils {
/// Copy data between device buffers using the device transfer command pool and queue.
/// Source and destination buffers are supposed to be allocated on the same device.
/// Fully sync, no latency hiding whatsoever.
auto copyBuf(const vuh::Device& dev ///< device where buffers are allocated
, vhn::Buffer src ///< source buffer
, vhn::Buffer dst ///< destination buffer
, size_t szBytes ///< size of memory chunk to copy in bytes
, size_t srcOff = 0 ///< source buffer offset (bytes)
, size_t dstOff = 0///< destination buffer offset (bytes)
)-> void;
auto genCopyImageToBufferCmd(const vhn::CommandBuffer& transCmdBuf
, const vhn::Image& im
, vhn::Buffer& buf
, const uint32_t imW
, const uint32_t imH
, const size_t bufOff = 0
)-> void;
auto copyImageToBuffer(const vuh::Device& dev
, const vhn::Image& im
, vhn::Buffer& buf
, const uint32_t imW
, const uint32_t imH
, const size_t bufOff = 0
)-> void;
auto genTransImageLayoutCmd(const vhn::CommandBuffer& transCmdBuf
, const vhn::Image& im
, const vhn::ImageLayout& lyOld
, const vhn::ImageLayout& lyNew
)-> bool;
auto genCopyBufferToImageCmd(const vhn::CommandBuffer& transCmdBuf
, const vhn::Buffer& buf
, vhn::Image& im
, const uint32_t imW
, const uint32_t imH
, const size_t bufOff = 0
)-> void;
auto copyBufferToImage(const vuh::Device& dev
, const vhn::Buffer& buf
, vhn::Image& im
, const vhn::DescriptorType& imDesc
, const uint32_t imW
, const uint32_t imH
, const size_t bufOff = 0
)-> void;
// image format bytes per Pixel
size_t imageFormatPerPixelBytes(vhn::Format fmt);
} // namespace utils
} // namespace vuh
| 31.890411 | 88 | 0.652062 |
e8d21f2da2879756ec1dba737c32405d62cbc8c1 | 3,620 | h | C | vmTools/src/CLogs/CLogImp.h | vincentma0001/vmTools | 4dec6c20e6305fdab3a70d7af9ee127aa129add1 | [
"BSD-3-Clause"
] | null | null | null | vmTools/src/CLogs/CLogImp.h | vincentma0001/vmTools | 4dec6c20e6305fdab3a70d7af9ee127aa129add1 | [
"BSD-3-Clause"
] | null | null | null | vmTools/src/CLogs/CLogImp.h | vincentma0001/vmTools | 4dec6c20e6305fdab3a70d7af9ee127aa129add1 | [
"BSD-3-Clause"
] | null | null | null | /////////////////////////////////////////////////////////////////////////////////////////
//
// File name : CLogImp.h
// Version : 0.0.0.0
// Brief :
// Author : v.m.
// Create time : 2020/01/05 15:33:40
// Modify time : 2020/01/05 15:33:40
// Note :
//
/////////////////////////////////////////////////////////////////////////////////////////
//
// Copyright : this file is copyright by v.m.'s tools lib
//
/////////////////////////////////////////////////////////////////////////////////////////
// compile macro definition
#if defined (_MSC_VER) && (_MSC_VER >= 1300)
#pragma once
#endif
#ifndef __CLOGIMP_H__
#define __CLOGIMP_H__
/////////////////////////////////////////////////////////////////////////////////////////
// Include libs :
/////////////////////////////////////////////////////////////////////////////////////////
// Include files :
// Standard c/c++ files included
// Config files included
// Platform files included
// Used files included
/////////////////////////////////////////////////////////////////////////////////////////
// using namespace
namespace vm{
/////////////////////////////////////////////////////////////////////////////////////////
//
// class CLogImp : ## add class brief here ##
//
/////////////////////////////////////////////////////////////////////////////////////////
class CLogImp
{
/////////////////////////////////////////////////////////////////////////////////////////
// Typedefs :
/////////////////////////////////////////////////////////////////////////////////////////
// Construct && Destruct
public:
// Construct define
explicit CLogImp():mpImpNext(nullptr){};
// Destruct define
virtual ~CLogImp()
{
if ( mpImpNext==nullptr )
delete [] mpImpNext;
};
private:
// No Copy
CLogImp(const CLogImp& obj){};
// No Assignment
CLogImp& operator = ( const CLogImp& obj ){};
public:
virtual tchar* WriteLine( const tchar* const cpFmt, va_list vList ) = 0;
virtual bool WriteNext( const tchar* const cpFmt, va_list vList )
{
CLogImp* lpLogNext = mpImpNext;
while ( lpLogNext != nullptr )
{
lpLogNext->WriteLine(cpFmt, vList);
lpLogNext = lpLogNext->mpImpNext;
}
}
void AddImp( CLogImp& oLogImp )
{
CLogImp* lpImpNow = GetLastImp();
lpImpNow->mpImpNext = &oLogImp;
}
CLogImp* GetLastImp()
{
CLogImp* lpImpNow = this;
CLogImp* lpImpNext = this->mpImpNext;
while (lpImpNext!=nullptr)
{
lpImpNow = lpImpNext;
lpImpNext = lpImpNow->mpImpNext;
}
return lpImpNow;
}
/////////////////////////////////////////////////////////////////////////////////////////
// Members :
private:
CLogImp* mpImpNext;
/////////////////////////////////////////////////////////////////////////////////////////
// Functions :
public:
}; // End of class CLogImp
/////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////
} // End of namespace vm
/////////////////////////////////////////////////////////////////////////////////////////
#endif // __CLOGIMP_H__
/////////////////////////////////////////////////////////////////////////////////////////
// usage :
/*
//*/
/////////////////////////////////////////////////////////////////////////////////////////
// End of file CLogImp.h
///////////////////////////////////////////////////////////////////////////////////////// | 29.193548 | 89 | 0.322652 |
792f45ff702fdb6293d51fe752fed90d651c0867 | 10,253 | h | C | src/tdme/tools/leveleditor/logic/Level.h | mahula/tdme2 | 0f74d35ae5d2cd33b1a410c09f0d45f250ca7a64 | [
"BSD-3-Clause"
] | null | null | null | src/tdme/tools/leveleditor/logic/Level.h | mahula/tdme2 | 0f74d35ae5d2cd33b1a410c09f0d45f250ca7a64 | [
"BSD-3-Clause"
] | null | null | null | src/tdme/tools/leveleditor/logic/Level.h | mahula/tdme2 | 0f74d35ae5d2cd33b1a410c09f0d45f250ca7a64 | [
"BSD-3-Clause"
] | null | null | null | #pragma once
#include <tdme/tdme.h>
#include <tdme/audio/fwd-tdme.h>
#include <tdme/engine/fwd-tdme.h>
#include <tdme/engine/model/fwd-tdme.h>
#include <tdme/engine/physics/fwd-tdme.h>
#include <tdme/math/fwd-tdme.h>
#include <tdme/math/Vector3.h>
#include <tdme/tools/leveleditor/logic/fwd-tdme.h>
#include <tdme/tools/shared/files/fwd-tdme.h>
#include <tdme/tools/shared/model/fwd-tdme.h>
#include <tdme/utils/fwd-tdme.h>
using tdme::audio::Audio;
using tdme::engine::Engine;
using tdme::engine::Entity;
using tdme::engine::Transformations;
using tdme::engine::model::Model;
using tdme::engine::physics::Body;
using tdme::engine::physics::World;
using tdme::math::Vector3;
using tdme::tools::shared::files::ProgressCallback;
using tdme::tools::shared::model::LevelEditorEntity;
using tdme::tools::shared::model::LevelEditorEntityParticleSystem;
using tdme::tools::shared::model::LevelEditorLevel;
using tdme::tools::shared::model::LevelEditorObject;
using tdme::utils::MutableString;
/**
* Level Editor Level Logic
* @author Andreas Drewke
* @version $Id$
*/
class tdme::tools::leveleditor::logic::Level final
{
public:
static constexpr int32_t RIGIDBODY_TYPEID_STATIC { 1 };
static constexpr int32_t RIGIDBODY_TYPEID_DYNAMIC { 2 };
static constexpr int32_t RIGIDBODY_TYPEID_COLLISION { 4 };
static constexpr int32_t RIGIDBODY_TYPEID_TRIGGER { 8 };
static float renderGroupsPartitionWidth;
static float renderGroupsPartitionHeight;
static float renderGroupsPartitionDepth;
static int renderGroupsReduceBy;
static int renderGroupsLODLevels;
static float renderGroupsLOD2MinDistance;
static float renderGroupsLOD3MinDistance;
static int renderGroupsLOD2ReduceBy;
static int renderGroupsLOD3ReduceBy;
static bool enableEarlyZRejection;
public:
/**
* @return render groups partition size / width
*/
inline static float getRenderGroupsPartitionWidth() {
return renderGroupsPartitionWidth;
}
/**
* Set render groups partition size / width
* @param renderGroupsPartitionDepth render groups partition size / width
*/
inline static void setRenderGroupsPartitionWidth(float renderGroupsPartitionWidth) {
Level::renderGroupsPartitionWidth = renderGroupsPartitionWidth;
}
/**
* @return render groups partition size / height
*/
inline static float getRenderGroupsPartitionHeight() {
return renderGroupsPartitionHeight;
}
/**
* Set render groups partition size / height
* @param renderGroupsPartitionDepth render groups partition size / height
*/
inline static void setRenderGroupsPartitionHeight(float renderGroupsPartitionHeight) {
Level::renderGroupsPartitionHeight = renderGroupsPartitionHeight;
}
/**
* @return render groups partition size / depth
*/
inline static float getRenderGroupsPartitionDepth() {
return renderGroupsPartitionDepth;
}
/**
* Set render groups partition size / depth
* @param renderGroupsPartitionDepth render groups partition size / depth
*/
inline static void setRenderGroupsPartitionDepth(float renderGroupsPartitionDepth) {
Level::renderGroupsPartitionDepth = renderGroupsPartitionDepth;
}
/**
* Set render groups reduce objects by a given factor
* @param reduceBy render groups objects reduce by factor
*/
inline static void setRenderGroupsReduceBy(int32_t reduceBy) {
Level::renderGroupsReduceBy = reduceBy;
}
/**
* @return render groups objects reduce by factor
*/
inline static int getRenderGroupsReduceBy() {
return renderGroupsReduceBy;
}
/**
* @return render groups LOD levels
*/
inline static int getRenderGroupsLodLevels() {
return renderGroupsLODLevels;
}
/**
* Set render groups LOD levels
* @param renderGroupsLodLevels render groups LOD levels
*/
inline static void setRenderGroupsLodLevels(int lodLevels) {
renderGroupsLODLevels = lodLevels;
}
/**
* @return render groups LOD2 minumum distance
*/
inline static float getRenderGroupsLod2MinDistance() {
return renderGroupsLOD2MinDistance;
}
/**
* Set render groups LOD2 minumum distance
* @param renderGroupsLod2MinDistance render groups LOD2 minumum distance
*/
inline static void setRenderGroupsLod2MinDistance(float minDistance) {
renderGroupsLOD2MinDistance = minDistance;
}
/**
* @return render groups LOD3 minumum distance
*/
inline static float getRenderGroupsLod3MinDistance() {
return renderGroupsLOD3MinDistance;
}
/**
* Set render groups LOD3 minumum distance
* @param renderGroupsLod3MinDistance render groups LOD3 minumum distance
*/
inline static void setRenderGroupsLod3MinDistance(float minDistance) {
renderGroupsLOD3MinDistance = minDistance;
}
/**
* @return render groups LOD2 reduce by factor
*/
inline static int getRenderGroupsLod2ReduceBy() {
return renderGroupsLOD2ReduceBy;
}
/**
* Set render groups LOD2 reduce by factor
* @param renderGroupsLod2ReduceBy render groups LOD2 reduce by factor
*/
inline static void setRenderGroupsLod2ReduceBy(int reduceBy) {
renderGroupsLOD2ReduceBy = reduceBy;
}
/**
* @return render groups LOD3 reduce by factor
*/
inline static int getRenderGroupsLod3ReduceBy() {
return renderGroupsLOD3ReduceBy;
}
/**
* Set render groups LOD3 reduce by factor
* @param renderGroupsLod3ReduceBy render groups LOD3 reduce by factor
*/
inline static void setRenderGroupsLod3ReduceBy(int reduceBy) {
renderGroupsLOD3ReduceBy = reduceBy;
}
/**
* @return If early z rejection is enabled, in level loading case its used for render groups and terrain
*/
inline static bool isEnableEarlyZRejection() {
return enableEarlyZRejection;
}
/**
* Enable/disable early z rejection, in level loading case its used for render groups and terrain
* @param enableEarlyZRejection enable early z rejection
*/
inline static void setEnableEarlyZRejection(bool enableEarlyZRejection) {
Level::enableEarlyZRejection = enableEarlyZRejection;
}
/**
* Set lights from level
* @param engine engine
* @param level level
* @param translation translation
*/
static void setLight(Engine* engine, LevelEditorLevel* level, const Vector3& translation = Vector3(0.0f, 0.0f, 0.0f));
/**
* Create particle system
* @param particleSystem level editor entity particle system
* @param id id
* @param enableDynamicShadows enable dynamic shadows
* @return engine particle system entity
*/
static Entity* createParticleSystem(LevelEditorEntityParticleSystem* particleSystem, const string& id, bool enableDynamicShadows = true);
/**
* Create engine entity
* @param id id
* @param transformations transformations
* @return entity
*/
static Entity* createEmpty(const string& id, const Transformations& transformations);
/**
* Create engine entity
* @param levelEditorEntity level editor entity
* @param id id
* @param transformations transformations
* @return entity
*/
static Entity* createEntity(LevelEditorEntity* levelEditorEntity, const string& id, const Transformations& transformations);
/**
* Create engine entity
* @param levelEditorObject level editor object
* @param translation translation
* @return entity
*/
static Entity* createEntity(LevelEditorObject* levelEditorObject, const Vector3& translation = Vector3(0.0f, 0.0f, 0.0f));
/**
* Add level to engine
* @param engine engine
* @param level level
* @param addEmpties add empties
* @param addTrigger add trigger
* @param pickable pickable
* @param enable enable
* @param translation translation
* @param progressCallback progress callback
*/
static void addLevel(Engine* engine, LevelEditorLevel* level, bool addEmpties, bool addTrigger, bool pickable, bool enable = true, const Vector3& translation = Vector3(0.0f, 0.0f, 0.0f), ProgressCallback* progressCallback = nullptr);
/**
* Create rigid body
* @param world world
* @param levelEditorEntity level editor entity
* @param id id
* @param transformations transformations
* @param collisionTypeId collision type id or 0 for default
* @return rigid body
*/
static Body* createBody(World* world, LevelEditorEntity* levelEditorEntity, const string& id, const Transformations& transformations, uint16_t collisionTypeId = 0);
/**
* Create rigid body
* @param world world
* @param levelEditorObject level editor object
* @param translation translation
* @param collisionTypeId collision type id or 0 for default
* @return rigid body
*/
static Body* createBody(World* world, LevelEditorObject* levelEditorObject, const Vector3& translation = Vector3(0.0f, 0.0f, 0.0f), uint16_t collisionTypeId = 0);
/**
* Add level to physics world
* @param world world
* @param level level
* @param enable enable
* @param translation translation
* @param progressCallback progress callback
*/
static void addLevel(World* world, LevelEditorLevel* level, bool enable = true, const Vector3& translation = Vector3(0.0f, 0.0f, 0.0f), ProgressCallback* progressCallback = nullptr);
/**
* Disable level in engine
* @param engine engine
* @param level level
*/
static void disableLevel(Engine* engine, LevelEditorLevel* level);
/**
* Disable level in physics world
* @param world world
* @param level level
*/
static void disableLevel(World* world, LevelEditorLevel* level);
/**
* Enable disabled level in engine
* @param engine engine
* @param level level
* @param translation translation
*/
static void enableLevel(Engine* engine, LevelEditorLevel* level, const Vector3& translation = Vector3(0.0f, 0.0f, 0.0f));
/**
* Enable disabled level in physics world
* @param world world
* @param level level
* @param translation translation
*/
static void enableLevel(World* world, LevelEditorLevel* level, const Vector3& translation = Vector3(0.0f, 0.0f, 0.0f));
/**
* Add level editor entity sounds into given audio instance associated with given id
* @param audio audio instance to load sounds into
* @param levelEditorEntity level editor entity
* @param id audio entity id
* @param poolSize pool size, which is optional if you want to use a pool for each sound
*/
static void addEntitySounds(Audio* audio, LevelEditorEntity* levelEditorEntity, const string& id, const int poolSize = 1);
private:
static Model* emptyModel;
};
| 30.60597 | 234 | 0.75295 |
959797b1d1ffe24457ab819735c7755cf75c58a0 | 558 | h | C | DiabetesCare/CFKPIGlycemiaTableCell.h | flyingfan76/DiabeteHealth | b3c86e7a5d3b088a3135fb43342013396989b7fd | [
"MIT"
] | null | null | null | DiabetesCare/CFKPIGlycemiaTableCell.h | flyingfan76/DiabeteHealth | b3c86e7a5d3b088a3135fb43342013396989b7fd | [
"MIT"
] | null | null | null | DiabetesCare/CFKPIGlycemiaTableCell.h | flyingfan76/DiabeteHealth | b3c86e7a5d3b088a3135fb43342013396989b7fd | [
"MIT"
] | null | null | null | //
// cfKPISceneBloodSugarTableCellTableViewCell.h
// DiabetesCare
//
// Created by Chen, Fan on 7/24/14.
// Copyright (c) 2014 HealthyCare. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface CFKPIGlycemiaTableCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UITextField *myDatePicker;
@property (weak, nonatomic) IBOutlet UITextField *myBloodSugar;
@property (weak, nonatomic) IBOutlet UIImageView *myTime;
@property (weak, nonatomic) IBOutlet UILabel *sampleTime;
@property (weak, nonatomic) IBOutlet UILabel *sampleValue;
@end
| 26.571429 | 63 | 0.768817 |
e5d14b266985a010a4d72e5b52f45e5d17c67d9b | 1,895 | h | C | PrivateFrameworks/SiriTasks/STGenericIntent.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/SiriTasks/STGenericIntent.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/SiriTasks/STGenericIntent.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 1 | 2018-09-28T13:54:23.000Z | 2018-09-28T13:54:23.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSObject.h"
#import "NSSecureCoding.h"
@class AFSiriTask, NSMutableDictionary, NSString, STGenericIntentRequest;
@interface STGenericIntent : NSObject <NSSecureCoding>
{
BOOL _appInForeground;
BOOL _isLaunch;
BOOL _handled;
BOOL _finishedState;
NSString *_name;
NSString *_utterance;
NSString *_attributes;
NSMutableDictionary *_parameters;
AFSiriTask *_siriTask;
STGenericIntentRequest *_intentRequest;
}
+ (BOOL)supportsSecureCoding;
@property(nonatomic) BOOL finishedState; // @synthesize finishedState=_finishedState;
@property(nonatomic) BOOL handled; // @synthesize handled=_handled;
@property(retain, nonatomic) STGenericIntentRequest *intentRequest; // @synthesize intentRequest=_intentRequest;
@property(retain, nonatomic) AFSiriTask *siriTask; // @synthesize siriTask=_siriTask;
@property(retain, nonatomic) NSMutableDictionary *parameters; // @synthesize parameters=_parameters;
@property(nonatomic) BOOL isLaunch; // @synthesize isLaunch=_isLaunch;
@property(nonatomic) BOOL appInForeground; // @synthesize appInForeground=_appInForeground;
@property(copy, nonatomic) NSString *attributes; // @synthesize attributes=_attributes;
@property(copy, nonatomic) NSString *utterance; // @synthesize utterance=_utterance;
@property(copy, nonatomic) NSString *name; // @synthesize name=_name;
- (void).cxx_destruct;
- (id)initWithCoder:(id)arg1;
- (void)encodeWithCoder:(id)arg1;
- (void)addParam:(id)arg1 withValue:(id)arg2;
- (id)getPlacesParameter:(id)arg1;
- (id)getGroupParameter:(id)arg1;
- (id)getPersonParameter:(id)arg1;
- (id)getTopicParameter:(id)arg1;
- (id)getDateRangeParameter:(id)arg1;
- (void)handleWithProgress:(long long)arg1;
- (void)finished;
- (id)initWithName:(id)arg1;
@end
| 35.754717 | 112 | 0.759894 |
b2724adfc5cc012a4e3dc5e2e7507236429224bc | 4,838 | h | C | src/YAKL_mem_transfers.h | mrnorman/KLaunch | 505fc45e9946aa501142305a164931b71f05b002 | [
"BSD-2-Clause"
] | null | null | null | src/YAKL_mem_transfers.h | mrnorman/KLaunch | 505fc45e9946aa501142305a164931b71f05b002 | [
"BSD-2-Clause"
] | null | null | null | src/YAKL_mem_transfers.h | mrnorman/KLaunch | 505fc45e9946aa501142305a164931b71f05b002 | [
"BSD-2-Clause"
] | null | null | null |
#pragma once
// Included by YAKL.h
namespace yakl {
// Your one-stop shop for memory transfers to / from host / device
template <class T1, class T2,
typename std::enable_if< std::is_same< typename std::remove_cv<T1>::type ,
typename std::remove_cv<T2>::type >::value , int >::type = 0>
inline void memcpy_host_to_host(T1 *dst , T2 *src , index_t elems) {
for (index_t i=0; i<elems; i++) { dst[i] = src[i]; }
}
inline void memcpy_host_to_host_void(void *dst , void *src , size_t bytes) {
memcpy( dst , src , bytes );
}
template <class T1, class T2,
typename std::enable_if< std::is_same< typename std::remove_cv<T1>::type ,
typename std::remove_cv<T2>::type >::value , int >::type = 0>
inline void memcpy_device_to_host(T1 *dst , T2 *src , index_t elems) {
#ifdef YAKL_AUTO_PROFILE
timer_start("YAKL_internal_memcpy_device_to_host");
#endif
#ifdef YAKL_ARCH_CUDA
cudaMemcpyAsync(dst,src,elems*sizeof(T1),cudaMemcpyDeviceToHost,0);
check_last_error();
#elif defined(YAKL_ARCH_HIP)
hipMemcpyAsync(dst,src,elems*sizeof(T1),hipMemcpyDeviceToHost,0);
check_last_error();
#elif defined (YAKL_ARCH_SYCL)
sycl_default_stream().memcpy(dst, src, elems*sizeof(T1));
check_last_error();
#elif defined(YAKL_ARCH_OPENMP)
#pragma omp parallel for
for (index_t i=0; i<elems; i++) { dst[i] = src[i]; }
#else
for (index_t i=0; i<elems; i++) { dst[i] = src[i]; }
#endif
#if defined(YAKL_AUTO_FENCE)
fence();
#endif
#ifdef YAKL_AUTO_PROFILE
timer_stop("YAKL_internal_memcpy_device_to_host");
#endif
}
template <class T1, class T2,
typename std::enable_if< std::is_same< typename std::remove_cv<T1>::type ,
typename std::remove_cv<T2>::type >::value , int >::type = 0>
inline void memcpy_host_to_device(T1 *dst , T2 *src , index_t elems) {
#ifdef YAKL_AUTO_PROFILE
timer_start("YAKL_internal_memcpy_host_to_device");
#endif
#ifdef YAKL_ARCH_CUDA
cudaMemcpyAsync(dst,src,elems*sizeof(T1),cudaMemcpyHostToDevice,0);
check_last_error();
#elif defined(YAKL_ARCH_HIP)
hipMemcpyAsync(dst,src,elems*sizeof(T1),hipMemcpyHostToDevice,0);
check_last_error();
#elif defined (YAKL_ARCH_SYCL)
sycl_default_stream().memcpy(dst, src, elems*sizeof(T1));
check_last_error();
#elif defined(YAKL_ARCH_OPENMP)
#pragma omp parallel for
for (index_t i=0; i<elems; i++) { dst[i] = src[i]; }
#else
for (index_t i=0; i<elems; i++) { dst[i] = src[i]; }
#endif
#if defined(YAKL_AUTO_FENCE)
fence();
#endif
#ifdef YAKL_AUTO_PROFILE
timer_stop("YAKL_internal_memcpy_host_to_device");
#endif
}
template <class T1, class T2,
typename std::enable_if< std::is_same< typename std::remove_cv<T1>::type ,
typename std::remove_cv<T2>::type >::value , int >::type = 0>
inline void memcpy_device_to_device(T1 *dst , T2 *src , index_t elems) {
#ifdef YAKL_AUTO_PROFILE
timer_start("YAKL_internal_memcpy_device_to_device");
#endif
#ifdef YAKL_ARCH_CUDA
cudaMemcpyAsync(dst,src,elems*sizeof(T1),cudaMemcpyDeviceToDevice,0);
check_last_error();
#elif defined(YAKL_ARCH_HIP)
hipMemcpyAsync(dst,src,elems*sizeof(T1),hipMemcpyDeviceToDevice,0);
check_last_error();
#elif defined (YAKL_ARCH_SYCL)
sycl_default_stream().memcpy(dst, src, elems*sizeof(T1));
check_last_error();
#elif defined(YAKL_ARCH_OPENMP)
#pragma omp parallel for
for (index_t i=0; i<elems; i++) { dst[i] = src[i]; }
#else
for (index_t i=0; i<elems; i++) { dst[i] = src[i]; }
#endif
#if defined(YAKL_AUTO_FENCE)
fence();
#endif
#ifdef YAKL_AUTO_PROFILE
timer_stop("YAKL_internal_memcpy_device_to_device");
#endif
}
inline void memcpy_device_to_device_void(void *dst , void *src , size_t bytes) {
#ifdef YAKL_AUTO_PROFILE
timer_start("YAKL_internal_memcpy_device_to_device");
#endif
#ifdef YAKL_ARCH_CUDA
cudaMemcpyAsync(dst,src,bytes,cudaMemcpyDeviceToDevice,0);
check_last_error();
#elif defined(YAKL_ARCH_HIP)
hipMemcpyAsync(dst,src,bytes,hipMemcpyDeviceToDevice,0);
check_last_error();
#elif defined (YAKL_ARCH_SYCL)
sycl_default_stream().memcpy(dst, src, bytes);
check_last_error();
#else
memcpy( dst , src , bytes );
#endif
#if defined(YAKL_AUTO_FENCE)
fence();
#endif
#ifdef YAKL_AUTO_PROFILE
timer_stop("YAKL_internal_memcpy_device_to_device");
#endif
}
}
| 33.832168 | 112 | 0.63766 |
d7c9f221395bc289ab8aaa74ee5d4f9d51967d24 | 1,777 | h | C | src/import/import_formblder.h | KeyWorksRW/wxUiEditor | fc58bb37284430fa5901579ae121d4482b588c75 | [
"Apache-2.0"
] | 7 | 2021-10-22T02:43:12.000Z | 2022-01-15T10:52:58.000Z | src/import/import_formblder.h | KeyWorksRW/wxUiEditor | fc58bb37284430fa5901579ae121d4482b588c75 | [
"Apache-2.0"
] | 288 | 2021-05-16T19:12:04.000Z | 2022-03-30T13:22:31.000Z | src/import/import_formblder.h | KeyWorksRW/wxUiEditor | fc58bb37284430fa5901579ae121d4482b588c75 | [
"Apache-2.0"
] | null | null | null | /////////////////////////////////////////////////////////////////////////////
// Purpose: Import a wxFormBuider project
// Author: Ralph Walden
// Copyright: Copyright (c) 2019-2021 KeyWorks Software (Ralph Walden)
// License: Apache License -- see ../../LICENSE
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include <map>
#include "ttstr.h" // ttString -- wxString with additional methods similar to ttlib::cstr
#include "node_classes.h" // Forward defintions of Node classes
#include "import_xml.h" // ImportXML -- Base class for XML importing
class wxImage;
using ImportNameMap = std::unordered_map<std::string, const char*>;
class FormBuilder : public ImportXML
{
public:
FormBuilder();
~FormBuilder() {};
bool Import(const ttString& filename, bool write_doc = true) override;
NodeSharedPtr CreateFbpNode(pugi::xml_node& xml_prop, Node* parent, Node* sizeritem = nullptr);
protected:
void ConvertNameSpaceProp(NodeProperty* prop, ttlib::cview org_names);
// Called when a property is unknown and has a value set.
void ProcessPropValue(pugi::xml_node& xml_prop, ttlib::cview prop_name, ttlib::cview class_name, Node* newobject);
void ProcessStyleProperty(pugi::xml_node& xml_prop, ttlib::cview class_name, Node* newobject);
void ConvertSizerProperties(pugi::xml_node& xml_prop, Node* object, Node* parent, NodeProperty* prop);
void BitmapProperty(pugi::xml_node& xml_obj, NodeProperty* prop);
void CreateProjectNode(pugi::xml_node& xml_obj, Node* new_node);
private:
ImportNameMap m_mapEventNames;
ttlib::cstr m_embedPath;
ttlib::cstr m_eventGeneration;
ttlib::cstr m_baseFile;
ttlib::cstr m_class_decoration;
int m_VerMinor { 0 };
};
| 34.173077 | 118 | 0.667417 |
67dac42900457c5eacb87b9751d09878ba9796a2 | 293 | h | C | ESP/ESP32/components/app_mqtt/app_mqtt.h | J-Magiera/ESP-BB | d3de1ec55f907424321f9e5edb1495aef938ca17 | [
"MIT"
] | null | null | null | ESP/ESP32/components/app_mqtt/app_mqtt.h | J-Magiera/ESP-BB | d3de1ec55f907424321f9e5edb1495aef938ca17 | [
"MIT"
] | null | null | null | ESP/ESP32/components/app_mqtt/app_mqtt.h | J-Magiera/ESP-BB | d3de1ec55f907424321f9e5edb1495aef938ca17 | [
"MIT"
] | null | null | null | /**
* @file mqtt_app.h
* @author MagieraJ
* @brief
* @version 0.1
* @date 2021-12-28
*
* @copyright Copyright (c) 2021
*
*/
#include "esp_err.h"
#ifndef APP_MQTT_H_
#define APP_MQTT_H_
void appMQTTStart(void);
esp_err_t appMQTTPublish(const char* topic, const char* data);
#endif | 16.277778 | 62 | 0.682594 |
c50d4a5048c31a43c47107aa5d7a12373a6ee0f3 | 13,592 | c | C | as/code.c | hiromi-mi/aqcc | 2861f51735e0db9e5e7f988a2e51862dca14537a | [
"MIT"
] | 188 | 2018-07-10T10:22:45.000Z | 2022-03-12T06:57:29.000Z | as/code.c | hiromi-mi/aqcc | 2861f51735e0db9e5e7f988a2e51862dca14537a | [
"MIT"
] | 14 | 2018-07-14T15:18:10.000Z | 2022-03-02T02:16:32.000Z | as/code.c | hiromi-mi/aqcc | 2861f51735e0db9e5e7f988a2e51862dca14537a | [
"MIT"
] | 17 | 2018-07-12T20:13:25.000Z | 2021-07-27T09:56:42.000Z | #include "as.h"
Code *new_code(int kind)
{
Code *code = safe_malloc(sizeof(Code));
code->kind = kind;
code->lhs = code->rhs = NULL;
code->ival = 0;
code->sval = NULL;
code->label = NULL;
code->read_dep = new_vector();
code->can_be_eliminated = 1;
return code;
}
Code *new_binop_code(int kind, Code *lhs, Code *rhs)
{
Code *code = new_code(kind);
code->lhs = lhs;
code->rhs = rhs;
vector_push_back(code->read_dep, lhs);
vector_push_back(code->read_dep, rhs);
return code;
}
Code *new_unary_code(int kind, Code *lhs)
{
Code *code = new_code(kind);
code->lhs = lhs;
code->rhs = NULL;
vector_push_back(code->read_dep, lhs);
return code;
}
Code *new_value_code(int value)
{
Code *code = new_code(CD_VALUE);
code->ival = value;
return code;
}
Code *new_addrof_label_code(Code *reg, char *label)
{
Code *code = new_code(CD_ADDR_OF_LABEL);
code->lhs = reg;
code->label = label;
return code;
}
Code *new_addrof_code(Code *reg, int offset)
{
Code *code = new_code(CD_ADDR_OF);
code->lhs = reg;
code->ival = offset;
return code;
}
Code *MOV(Code *lhs, Code *rhs)
{
Code *code = new_code(INST_MOV);
code->lhs = lhs;
code->rhs = rhs;
vector_push_back(code->read_dep, lhs);
if (!is_register_code(rhs)) vector_push_back(code->read_dep, rhs);
return code;
}
Code *MOVL(Code *lhs, Code *rhs)
{
Code *code = new_code(INST_MOVL);
code->lhs = lhs;
code->rhs = rhs;
vector_push_back(code->read_dep, lhs);
if (!is_register_code(rhs)) vector_push_back(code->read_dep, rhs);
return code;
}
Code *MOVSBL(Code *lhs, Code *rhs)
{
Code *code = new_code(INST_MOVSBL);
code->lhs = lhs;
code->rhs = rhs;
vector_push_back(code->read_dep, lhs);
if (!is_register_code(rhs)) vector_push_back(code->read_dep, rhs);
return code;
}
Code *MOVSLQ(Code *lhs, Code *rhs)
{
Code *code = new_code(INST_MOVSLQ);
code->lhs = lhs;
code->rhs = rhs;
vector_push_back(code->read_dep, lhs);
if (!is_register_code(rhs)) vector_push_back(code->read_dep, rhs);
return code;
}
Code *MOVZB(Code *lhs, Code *rhs)
{
Code *code = new_code(INST_MOVZB);
code->lhs = lhs;
code->rhs = rhs;
vector_push_back(code->read_dep, lhs);
if (!is_register_code(rhs)) vector_push_back(code->read_dep, rhs);
return code;
}
Code *LEA(Code *lhs, Code *rhs)
{
Code *code = new_code(INST_LEA);
code->lhs = lhs;
code->rhs = rhs;
vector_push_back(code->read_dep, lhs);
if (!is_register_code(rhs)) vector_push_back(code->read_dep, rhs);
return code;
}
Code *PUSH(Code *lhs) { return new_unary_code(INST_PUSH, lhs); }
Code *POP(Code *lhs) { return new_unary_code(INST_POP, lhs); }
Code *ADD(Code *lhs, Code *rhs) { return new_binop_code(INST_ADD, lhs, rhs); }
Code *ADDQ(Code *lhs, Code *rhs) { return new_binop_code(INST_ADDQ, lhs, rhs); }
Code *SUB(Code *lhs, Code *rhs) { return new_binop_code(INST_SUB, lhs, rhs); }
Code *IMUL(Code *lhs, Code *rhs) { return new_binop_code(INST_IMUL, lhs, rhs); }
Code *IDIV(Code *lhs) { return new_unary_code(INST_IDIV, lhs); }
Code *SAR(Code *lhs, Code *rhs) { return new_binop_code(INST_SAR, lhs, rhs); }
Code *SAL(Code *lhs, Code *rhs) { return new_binop_code(INST_SAL, lhs, rhs); }
Code *NEG(Code *lhs) { return new_unary_code(INST_NEG, lhs); }
Code *NOT(Code *lhs) { return new_unary_code(INST_NOT, lhs); }
Code *CMP(Code *lhs, Code *rhs) { return new_binop_code(INST_CMP, lhs, rhs); }
Code *SETL(Code *lhs) { return new_unary_code(INST_SETL, lhs); }
Code *SETLE(Code *lhs) { return new_unary_code(INST_SETLE, lhs); }
Code *SETE(Code *lhs) { return new_unary_code(INST_SETE, lhs); }
Code *AND(Code *lhs, Code *rhs) { return new_binop_code(INST_AND, lhs, rhs); }
Code *XOR(Code *lhs, Code *rhs) { return new_binop_code(INST_XOR, lhs, rhs); }
Code *OR(Code *lhs, Code *rhs) { return new_binop_code(INST_OR, lhs, rhs); }
Code *RET() { return new_code(INST_RET); }
Code *CLTD() { return new_code(INST_CLTD); }
Code *CLTQ() { return new_code(INST_CLTQ); }
Code *JMP(char *label)
{
Code *code = new_code(INST_JMP);
code->label = label;
return code;
}
Code *JE(char *label)
{
Code *code = new_code(INST_JE);
code->label = label;
return code;
}
Code *JNE(char *label)
{
Code *code = new_code(INST_JNE);
code->label = label;
return code;
}
Code *JAE(char *label)
{
Code *code = new_code(INST_JAE);
code->label = label;
return code;
}
Code *LABEL(char *label)
{
Code *code = new_code(INST_LABEL);
code->label = label;
return code;
}
Code *INCL(Code *lhs) { return new_unary_code(INST_INCL, lhs); }
Code *INCQ(Code *lhs) { return new_unary_code(INST_INCQ, lhs); }
Code *DECL(Code *lhs) { return new_unary_code(INST_DECL, lhs); }
Code *DECQ(Code *lhs) { return new_unary_code(INST_DECQ, lhs); }
Code *EAX() { return new_code(REG_EAX); }
Code *EDX() { return new_code(REG_EDX); }
Code *RAX() { return new_code(REG_RAX); }
Code *RBP() { return new_code(REG_RBP); }
Code *RSP() { return new_code(REG_RSP); }
Code *RIP() { return new_code(REG_RIP); }
Code *RDI() { return new_code(REG_RDI); }
Code *RDX() { return new_code(REG_RDX); }
Code *R10() { return new_code(REG_R10); }
Code *R11() { return new_code(REG_R11); }
Code *R12() { return new_code(REG_R12); }
Code *R13() { return new_code(REG_R13); }
Code *R14() { return new_code(REG_R14); }
Code *R15() { return new_code(REG_R15); }
Code *AL() { return new_code(REG_AL); }
Code *CL() { return new_code(REG_CL); }
Code *GLOBAL(char *label)
{
Code *code = new_code(CD_GLOBAL);
code->label = label;
return code;
}
char *code2str(Code *code)
{
if (code == NULL) return NULL;
switch (code->kind) {
case REG_AL:
return "%al";
case REG_DIL:
return "%dil";
case REG_SIL:
return "%sil";
case REG_DL:
return "%dl";
case REG_CL:
return "%cl";
case REG_R8B:
return "%r8b";
case REG_R9B:
return "%r9b";
case REG_R10B:
return "%r10b";
case REG_R11B:
return "%r11b";
case REG_R12B:
return "%r12b";
case REG_R13B:
return "%r13b";
case REG_R14B:
return "%r14b";
case REG_R15B:
return "%r15b";
case REG_AX:
return "%ax";
case REG_DI:
return "%di";
case REG_SI:
return "%si";
case REG_DX:
return "%dx";
case REG_CX:
return "%cx";
case REG_R8W:
return "%r8w";
case REG_R9W:
return "%r9w";
case REG_R10W:
return "%r10w";
case REG_R11W:
return "%r11w";
case REG_R12W:
return "%r12w";
case REG_R13W:
return "%r13w";
case REG_R14W:
return "%r14w";
case REG_R15W:
return "%r15w";
case REG_EAX:
return "%eax";
case REG_EDI:
return "%edi";
case REG_ESI:
return "%esi";
case REG_EDX:
return "%edx";
case REG_ECX:
return "%ecx";
case REG_R8D:
return "%r8d";
case REG_R9D:
return "%r9d";
case REG_R10D:
return "%r10d";
case REG_R11D:
return "%r11d";
case REG_R12D:
return "%r12d";
case REG_R13D:
return "%r13d";
case REG_R14D:
return "%r14d";
case REG_R15D:
return "%r15d";
case REG_RAX:
return "%rax";
case REG_RDI:
return "%rdi";
case REG_RSI:
return "%rsi";
case REG_RDX:
return "%rdx";
case REG_RCX:
return "%rcx";
case REG_R8:
return "%r8";
case REG_R9:
return "%r9";
case REG_R10:
return "%r10";
case REG_R11:
return "%r11";
case REG_R12:
return "%r12";
case REG_R13:
return "%r13";
case REG_R14:
return "%r14";
case REG_R15:
return "%r15";
case REG_RBP:
return "%rbp";
case REG_RSP:
return "%rsp";
case REG_RIP:
return "%rip";
case INST_MOV:
return format("mov %s, %s", code2str(code->lhs),
code2str(code->rhs));
case INST_MOVL:
return format("movl %s, %s", code2str(code->lhs),
code2str(code->rhs));
case INST_MOVSBL:
return format("movsbl %s, %s", code2str(code->lhs),
code2str(code->rhs));
case INST_MOVSLQ:
return format("movslq %s, %s", code2str(code->lhs),
code2str(code->rhs));
case INST_MOVZB:
return format("movzb %s, %s", code2str(code->lhs),
code2str(code->rhs));
case INST_LEA:
return format("lea %s, %s", code2str(code->lhs),
code2str(code->rhs));
case INST_POP:
return format("pop %s", code2str(code->lhs));
case INST_PUSH:
return format("push %s", code2str(code->lhs));
case INST_ADD:
return format("add %s, %s", code2str(code->lhs),
code2str(code->rhs));
case INST_ADDQ:
return format("addq %s, %s", code2str(code->lhs),
code2str(code->rhs));
case INST_SUB:
return format("sub %s, %s", code2str(code->lhs),
code2str(code->rhs));
case INST_IMUL:
return format("imul %s, %s", code2str(code->lhs),
code2str(code->rhs));
case INST_IDIV:
return format("idiv %s", code2str(code->lhs));
case INST_SAR:
return format("sar %s, %s", code2str(code->lhs),
code2str(code->rhs));
case INST_SAL:
return format("sal %s, %s", code2str(code->lhs),
code2str(code->rhs));
case INST_NEG:
return format("neg %s", code2str(code->lhs));
case INST_NOT:
return format("not %s", code2str(code->lhs));
case INST_CMP:
return format("cmp %s, %s", code2str(code->lhs),
code2str(code->rhs));
case INST_SETL:
return format("setl %s", code2str(code->lhs));
case INST_SETLE:
return format("setle %s", code2str(code->lhs));
case INST_SETE:
return format("sete %s", code2str(code->lhs));
case INST_AND:
return format("and %s, %s", code2str(code->lhs),
code2str(code->rhs));
case INST_XOR:
return format("xor %s, %s", code2str(code->lhs),
code2str(code->rhs));
case INST_OR:
return format("or %s, %s", code2str(code->lhs),
code2str(code->rhs));
case INST_RET:
return "ret";
case INST_CLTD:
return "cltd";
case INST_CLTQ:
return "cltq";
case INST_JMP:
return format("jmp %s", code->label);
case INST_JE:
return format("je %s", code->label);
case INST_JNE:
return format("jne %s", code->label);
case INST_JAE:
return format("jae %s", code->label);
case INST_LABEL:
return format("%s:", code->label);
case INST_INCL:
return format("incl %s", code2str(code->lhs));
case INST_INCQ:
return format("incq %s", code2str(code->lhs));
case INST_DECL:
return format("decl %s", code2str(code->lhs));
case INST_DECQ:
return format("decq %s", code2str(code->lhs));
case INST_CALL:
return format("call %s", code->label);
case INST_NOP:
return "nop";
case INST_SYSCALL:
return "syscall";
case CD_COMMENT:
return format("/* %s */", code->sval);
case CD_VALUE:
return format("$%d", code->ival);
case CD_ADDR_OF:
if (code->ival == 0) return format("(%s)", code2str(code->lhs));
return format("%d(%s)", code->ival, code2str(code->lhs));
case CD_ADDR_OF_LABEL:
return format("%s(%s)", code->label, code2str(code->lhs));
case CD_GLOBAL:
return format(".global %s", code->label);
case CD_TEXT:
return ".text";
case CD_DATA:
return ".data";
case CD_ZERO:
return format(".zero %d", code->ival);
case CD_LONG:
return format(".long %d", code->ival);
case CD_BYTE:
return format(".byte %d", code->ival);
case CD_QUAD:
return format(".quad %d", code->ival);
case CD_ASCII:
return format(".ascii \"%s\"",
escape_string(code->sval, code->ival));
}
warn(format("code.c %d", code->kind));
assert(0);
}
void dump_code(Code *code, FILE *fh)
{
char *str = code2str(code);
if (str != NULL) fprintf(fh, "%s\n", str);
}
| 25.077491 | 80 | 0.539214 |
7b1cd240ab47bf49bc234cd0aa4388e89406cd0d | 989 | c | C | src/cw/cw_ktv_add_from_str.c | 7u83/actube | 0f6cfb9eab2843cf8269187d64cc797491d55b02 | [
"BSD-2-Clause"
] | 35 | 2015-01-16T04:33:02.000Z | 2021-04-29T02:22:33.000Z | src/cw/cw_ktv_add_from_str.c | 7u83/actube | 0f6cfb9eab2843cf8269187d64cc797491d55b02 | [
"BSD-2-Clause"
] | 4 | 2015-05-28T21:59:43.000Z | 2016-03-25T18:34:13.000Z | src/cw/cw_ktv_add_from_str.c | 7u83/actube | 0f6cfb9eab2843cf8269187d64cc797491d55b02 | [
"BSD-2-Clause"
] | 26 | 2015-01-16T04:32:56.000Z | 2022-02-21T09:14:22.000Z | #include "ktv.h"
#include "cw.h"
#include "log.h"
#include "dbg.h"
const char * cw_ktv_add_from_str(mavl_t kvtstore, const char *key,
const struct cw_Type *type,
const void * valguard,
const char * str)
{
cw_KTV_t mdata, *mresult;
int exists;
/* cw_dbg(DBG_ELEM,"KVStore (%p,%d) add elem (%s): %s", kvstore, kvstore->count,
type->name, key );
*/
mdata.key=cw_strdup(key);
mdata.valguard=valguard;
if (!mdata.key){
cw_log(LOG_ERR, "Can't allocate memory for key %s: %s",
key,strerror(errno));
return NULL;
}
mresult = type->from_str(&mdata,str);
if (!mresult){
cw_log(LOG_ERR, "Can't create kvstore element for key %s of type %s: %s",
key,type->name, strerror(errno));
free(mdata.key);
return NULL;
}
mresult = mavl_add(kvtstore, &mdata, &exists);
if (exists){
cw_log(LOG_ERR, "Element already exists %s", key);
/* element already exists */
free(mdata.key);
if (type->del)
type->del(&mdata);
return key;
}
return mdata.key;
}
| 21.5 | 80 | 0.651163 |
474f24448992c0fcd93ca54462180a636a1b6519 | 11,498 | c | C | src/kernel/kernel/kernel_task.c | DrDeano/DeanOS | 845223d085a2c5efc2a77f0a491a58b8a297637d | [
"MIT"
] | 6 | 2018-10-06T02:34:55.000Z | 2022-01-06T22:22:27.000Z | src/kernel/kernel/kernel_task.c | DrDeano/DeanOS | 845223d085a2c5efc2a77f0a491a58b8a297637d | [
"MIT"
] | null | null | null | src/kernel/kernel/kernel_task.c | DrDeano/DeanOS | 845223d085a2c5efc2a77f0a491a58b8a297637d | [
"MIT"
] | 1 | 2021-06-25T17:27:55.000Z | 2021-06-25T17:27:55.000Z | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <kernel_task.h>
#include <tty.h>
#include <rtc.h>
#include <floppy.h>
#include <speaker.h>
#include <keyboard.h>
#include <pit.h>
static char prev_command_buffer[10][64] = {0}; /**< */
static int prev_command_buffer_end = 0; /**< */
static int prev_command_buffer_index = 0; /**< */
static void display_time(void) {
static char * str_day[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
rtc_date_time_t date;
tty_get_time(&date);
// DD-MM-YYYY hh:mm:ss
kprintf("%s %02d-%02d-%04d %02d:%02d:%02d\n", str_day[date.day_of_week], date.day, date.month, date.year, date.hour, date.minute, date.second);
}
static void add_command(char * cmd) {
memcpy(prev_command_buffer[prev_command_buffer_end], cmd, strlen(cmd) + 1);
prev_command_buffer_end = (prev_command_buffer_end + 1) % 10;
prev_command_buffer_index = prev_command_buffer_end;
}
static char * get_prev_cmd(void) {
int count = 10;
int save_index = prev_command_buffer_index;
if(prev_command_buffer_index == 0) {
prev_command_buffer_index = 10;
}
prev_command_buffer_index--;
//save_index = prev_command_buffer_index;
while((prev_command_buffer[prev_command_buffer_index][0] == '\0') && count > 0) {
if(prev_command_buffer_index == prev_command_buffer_end) {
prev_command_buffer_index = save_index;
return prev_command_buffer[prev_command_buffer_index];
}
prev_command_buffer_index--;
if(prev_command_buffer_index == 0) {
prev_command_buffer_index = 10;
}
count--;
}
if(prev_command_buffer_index == prev_command_buffer_end) {
prev_command_buffer_index = save_index;
return prev_command_buffer[prev_command_buffer_index];
}
return prev_command_buffer[prev_command_buffer_index];
}
static void zero_cmd_buffer(char * command_buffer, int * command_buffer_index) {
memset(command_buffer, 0, 64);
*command_buffer_index = 0;
}
static void move_left(int * command_buffer_index) {
if(*command_buffer_index) {
tty_move_cursor_left();
(*command_buffer_index)--;
}
}
static void move_right(char * command_buffer, int * command_buffer_index) {
if(command_buffer[*command_buffer_index] != '\0') {
tty_move_cursor_right();
(*command_buffer_index)++;
}
}
static void clear_line(char * command_buffer, int * command_buffer_index) {
//int temp = command_buffer_index;
// Start from the end
for(unsigned int i = *command_buffer_index; i < strlen(command_buffer); i++) {
move_right(command_buffer, command_buffer_index);
(*command_buffer_index)--;
}
// Clear the line
for(unsigned int i = 0; i < strlen(command_buffer); i++) {
kputchar('\b');
kputchar('\0');
kputchar('\b');
}
// Move back to where started
//command_buffer_index = temp;
}
static void add_char_to_cmd(char c, char * command_buffer, int * command_buffer_index) {
// CHECK OVER FLOW
clear_line(command_buffer, command_buffer_index);
if(c == '\b') {
if(*command_buffer_index) {
memmove(command_buffer + *command_buffer_index - 1, command_buffer + *command_buffer_index, strlen(command_buffer + *command_buffer_index));
(*command_buffer_index)--;
// Set last item to null
command_buffer[strlen(command_buffer) - 1] = '\0';
}
goto print;
} else if(c == '\t') {
if(*command_buffer_index + 4 > 62) {
goto print;
}
if(command_buffer[*command_buffer_index] != '\0') {
memmove(command_buffer + *command_buffer_index + 4, command_buffer + *command_buffer_index, strlen(command_buffer + *command_buffer_index));
}
command_buffer[(*command_buffer_index)++] = ' ';
command_buffer[(*command_buffer_index)++] = ' ';
command_buffer[(*command_buffer_index)++] = ' ';
command_buffer[(*command_buffer_index)++] = ' ';
goto print;
}
// if(*command_buffer_index + 1 > 62)
if(*command_buffer_index > 61) {
goto print;
}
// If half way into a word
if(command_buffer[*command_buffer_index] != '\0') {
// Move all chars to right of the index one to the right
memmove(command_buffer + *command_buffer_index + 1, command_buffer + *command_buffer_index, strlen(command_buffer + *command_buffer_index));
}
// Add the char
command_buffer[(*command_buffer_index)++] = c;
print:
kprintf("%s", command_buffer);
for(unsigned int i = *command_buffer_index; i < strlen(command_buffer); i++) {
(*command_buffer_index)++;
move_left(command_buffer_index);
}
}
static char * get_next_cmd(void) {
if(prev_command_buffer_index == prev_command_buffer_end) {
return prev_command_buffer[prev_command_buffer_index];
}
if(prev_command_buffer_index == 10) {
prev_command_buffer_index = 0;
}
prev_command_buffer_index++;
return prev_command_buffer[prev_command_buffer_index];
}
static void get_command(char * command_buffer) {
char ch;
char * prev_cmd;
bool end_of_cmd = false;
char * help = "help";
//char command_buffer[64] = {0};
int command_buffer_index = 0;
while(command_buffer_index < 62 && !end_of_cmd) {
// unsigned char key = get_key();
unsigned char key = wait_for_key_press();
switch (key) {
case KEYBOARD_KEY_ENTER:
end_of_cmd = true;
break;
case KEYBOARD_KEY_ESC:
//kprintf("ESC\n");
break;
case KEYBOARD_KEY_F1:
zero_cmd_buffer(command_buffer, &command_buffer_index);
clear_line(command_buffer, &command_buffer_index);
for(int i = 0; i < 5; i++) {
add_char_to_cmd(help[i], command_buffer, &command_buffer_index);
}
end_of_cmd = true;
break;
case KEYBOARD_KEY_F2:
//kprintf("F2\n");
break;
case KEYBOARD_KEY_F3:
//kprintf("F3\n");
break;
case KEYBOARD_KEY_F4:
//kprintf("F4\n");
break;
case KEYBOARD_KEY_F5:
//kprintf("F5\n");
break;
case KEYBOARD_KEY_F6:
//kprintf("F6\n");
break;
case KEYBOARD_KEY_F7:
//kprintf("F7\n");
break;
case KEYBOARD_KEY_F8:
//kprintf("F8\n");
break;
case KEYBOARD_KEY_F9:
//kprintf("F9\n");
break;
case KEYBOARD_KEY_F10:
//kprintf("F10\n");
break;
case KEYBOARD_KEY_F11:
//kprintf("F11\n");
break;
case KEYBOARD_KEY_F12:
//kprintf("F12\n");
break;
case KEYBOARD_KEY_NUM_LOCK:
//kprintf("NUM\n");
break;
case KEYBOARD_KEY_CAPS_LOCK:
//kprintf("CAPS\n");
break;
case KEYBOARD_KEY_SCROLL_LOCK:
//kprintf("SCROLL\n");
break;
case KEYBOARD_KEY_LEFT_CTRL:
//kprintf("LCTRL\n");
break;
case KEYBOARD_KEY_LEFT_SHIFT:
//kprintf("LSHIFT\n");
break;
case KEYBOARD_KEY_LEFT_ALT:
//kprintf("LALT\n");
break;
case KEYBOARD_KEY_RIGHT_CTRL:
//kprintf("RCTRL\n");
break;
case KEYBOARD_KEY_RIGHT_SHIFT:
//kprintf("RSHIFT\n");
break;
case KEYBOARD_KEY_RIGHT_ALT:
//kprintf("RALT\n");
break;
case KEYBOARD_KEY_SYSREQ:
//kprintf("SYSREQ\n");
break;
case KEYBOARD_KEY_INSERT:
//kprintf("INSERT\n");
break;
case KEYBOARD_KEY_HOME:
//kprintf("HOME\n");
break;
case KEYBOARD_KEY_PAGE_UP:
tty_page_up();
break;
case KEYBOARD_KEY_DELETE:
//kprintf("DELETE\n");
break;
case KEYBOARD_KEY_END:
//kprintf("END\n");
break;
case KEYBOARD_KEY_PAGE_DOWN:
tty_page_down();
break;
case KEYBOARD_KEY_ARROW_UP:
clear_line(command_buffer, &command_buffer_index);
zero_cmd_buffer(command_buffer, &command_buffer_index);
prev_cmd = get_prev_cmd();
kprintf("%s", prev_cmd);
for(unsigned int i = 0; i < strlen(prev_cmd); i++) {
command_buffer[command_buffer_index++] = prev_cmd[i];
}
break;
case KEYBOARD_KEY_ARROW_DOWN:
clear_line(command_buffer, &command_buffer_index);
zero_cmd_buffer(command_buffer, &command_buffer_index);
prev_cmd = get_next_cmd();
kprintf("%s", prev_cmd);
for(unsigned int i = 0; i < strlen(prev_cmd); i++) {
command_buffer[command_buffer_index++] = prev_cmd[i];
}
break;
case KEYBOARD_KEY_ARROW_LEFT:
move_left(&command_buffer_index);
break;
case KEYBOARD_KEY_ARROW_RIGHT:
move_right(command_buffer, &command_buffer_index);
break;
case KEYBOARD_KEY_BACKSPACE:
if (command_buffer_index > 0) {
add_char_to_cmd('\b', command_buffer, &command_buffer_index);
}
break;
case KEYBOARD_KEY_TAB:
add_char_to_cmd('\t', command_buffer, &command_buffer_index);
break;
default:
ch = key_to_ascii(key);
if(ch) {
add_char_to_cmd(ch, command_buffer, &command_buffer_index);
}
break;
}
}
//end_of_cmd = false;
kputchar('\n');
}
void kernel_task(void) {
const int num_commands = 9;
const char * list_of_commands[] = {
"help",
"hello",
"butt",
"eg",
"time",
"uptime",
"clear",
"read",
"beep"
};
char command_buffer[64] = {0};
int command_buffer_index = 0;
kprintf("kernel task started\n");
while(true) {
zero_cmd_buffer(command_buffer, &command_buffer_index);
kprintf("terminal:>");
get_command(command_buffer);
add_command(command_buffer);
if(strcmp(command_buffer, "help") == 0) {
kprintf("List of commands:\n");
for(int i = 0; i < num_commands; i++) {
kprintf("\t- %s\n", list_of_commands[i]);
}
} else if(strcmp(command_buffer, "hello") == 0) {
kprintf("Hello there\n");
} else if(strcmp(command_buffer, "uptime") == 0) {
unsigned int ticks = pit_get_ticks();
unsigned int freq = pit_get_frequency();
unsigned int sec = (ticks / freq) % 60;
unsigned int min = (ticks / (freq * 60)) % 60;
unsigned int hr = (ticks / (freq * 60 * 60)) % 24;
unsigned int day = (ticks / (freq * 60 * 60 * 24)) % 365;
kprintf("%u ticks: day:hr:min:sec %3d:%02d:%02d:%02d\n", ticks, day, hr, min, sec);
} else if(strcmp(command_buffer, "eg") == 0) {
kprintf("Soph is a butt\n");
} else if(strcmp(command_buffer, "time") == 0) {
display_time();
} else if(strcmp(command_buffer, "clear") == 0) {
tty_clear();
} else if(strcmp(command_buffer, "butt") == 0) {
kprintf(" \\ / \n");
kprintf(" \\ / \n");
kprintf(" ) ( \n");
kprintf(" .` `. \n");
kprintf(".' `. \n");
kprintf(": | :\n");
kprintf("'. .'. .'\n");
kprintf(" \\`'''`\\ /`'''`/ \n");
kprintf(" \\ | / \n");
kprintf(" | | | \n");
} else if(strcmp(command_buffer, "read") == 0) {
kprintf("Enter the logical bock address to read from: ");
char lba[64] = {0};
get_command(lba);
kprintf("string number get: %s\n", lba);
uint32_t lba_int = atoi(lba);
kprintf("lba number: %d\n", lba_int);
uint8_t * sector = floppy_read_sector(lba_int);
if(sector) {
for(int i = 1; i <= 512; i++) {
kprintf("0x%2X ", (uint32_t) sector[i - 1]);
if(i % 15 == 0 && i != 1) {
kprintf("\n");
}
}
kprintf("\n");
} else {
kprintf("Error reading\n");
}
} else if(strcmp(command_buffer, "beep") == 0) {
beep(400, 150);
// speaker_happy_birthday();
// speaker_star_wars();
} else {
if(command_buffer[0]) {
kprintf("%s: Command not found\n", command_buffer);
}
}
}
}
| 25.438053 | 144 | 0.632371 |
0bd6888cb7b35b61692ab2180b4b2ae8ed8817cf | 1,301 | h | C | src/plugins/speech-to-text/sphinx/filter-buffer.h | klihub/winthorpe | 2af63d02d833637e5c52f0af75f4f8029124c757 | [
"BSD-3-Clause"
] | null | null | null | src/plugins/speech-to-text/sphinx/filter-buffer.h | klihub/winthorpe | 2af63d02d833637e5c52f0af75f4f8029124c757 | [
"BSD-3-Clause"
] | null | null | null | src/plugins/speech-to-text/sphinx/filter-buffer.h | klihub/winthorpe | 2af63d02d833637e5c52f0af75f4f8029124c757 | [
"BSD-3-Clause"
] | 2 | 2019-11-02T05:20:50.000Z | 2021-01-26T11:48:42.000Z | #ifndef __SRS_POCKET_SPHINX_FILTER_BUFFER_H__
#define __SRS_POCKET_SPHINX_FILTER_BUFFER_H__
#include "sphinx-plugin.h"
struct filter_buf_s {
int16_t *buf;
int32_t max; /* maximum buffer size of filtered data (in samples) */
int32_t hwm; /* high-water mark (in samples) */
int32_t len; /* length of data in filter buffer (in samples) */
int32_t frlen; /* frame length in samples */
int32_t silen; /* minimum samples to declare silence */
int32_t ts; /* time stamp (in samples actually) */
int fdrec; /* fd for recording the filtered stream */
};
int filter_buffer_create(context_t *ctx);
void filter_buffer_destroy(context_t *ctx);
void filter_buffer_initialize(context_t *ctx, int32_t bufsiz,
int32_t high_water_mark, int32_t silen);
bool filter_buffer_is_empty(context_t *ctx);
void filter_buffer_purge(context_t *ctx, int32_t length);
void filter_buffer_process_data(context_t *ctx);
void filter_buffer_utter(context_t *ctx, bool full_utterance);
int16_t *filter_buffer_dup(context_t *ctx, int32_t start, int32_t end,
size_t *ret_length);
#endif /* __SRS_POCKET_SPHINX_FILTER_BUFFER_H__ */
/*
* Local Variables:
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*
*/
| 32.525 | 76 | 0.700999 |
6056e4ffe14413d1e612dcbb40f1e920ecff2610 | 502 | h | C | src/natives.h | ShapeDev/MurmurHash3 | 6149de4832225b97ad0c6532404b0c9403112b9a | [
"MIT"
] | null | null | null | src/natives.h | ShapeDev/MurmurHash3 | 6149de4832225b97ad0c6532404b0c9403112b9a | [
"MIT"
] | null | null | null | src/natives.h | ShapeDev/MurmurHash3 | 6149de4832225b97ad0c6532404b0c9403112b9a | [
"MIT"
] | null | null | null | #ifndef NATIVES_H_
#define NATIVES_H_
// native MurmurHash3(key[], len, seed)
static cell AMX_NATIVE_CALL n_MurmurHash3_x86_32(AMX* amx, cell* params)
{
static char* key;
int result;
amx_StrParam(amx, params[1], key);
MurmurHash3_x86_32(key, params[2], params[3], &result);
return result;
}
static void RegisterNatives(AMX* amx)
{
std::vector<AMX_NATIVE_INFO> MurmurNatives {
{ "MurmurHash", n_MurmurHash3_x86_32 }
};
amx_Register(amx, MurmurNatives.data(), MurmurNatives.size());
}
#endif | 22.818182 | 72 | 0.741036 |
44ba0ab12a7688844d416fb4873693add5a9c963 | 2,195 | h | C | ecc/gf13.h | eric613-chan/dhara | 1b166e41b74b4a62ee6001ba5fab7a8805e80ea2 | [
"0BSD"
] | 270 | 2016-02-20T20:44:25.000Z | 2022-03-30T02:42:41.000Z | ecc/gf13.h | eric613-chan/dhara | 1b166e41b74b4a62ee6001ba5fab7a8805e80ea2 | [
"0BSD"
] | 29 | 2016-05-15T05:43:41.000Z | 2022-03-14T08:48:21.000Z | ecc/gf13.h | eric613-chan/dhara | 1b166e41b74b4a62ee6001ba5fab7a8805e80ea2 | [
"0BSD"
] | 95 | 2015-06-03T04:59:50.000Z | 2022-03-25T18:17:02.000Z | /* Dhara - NAND flash management layer
* Copyright (C) 2013 Daniel Beer <dlbeer@gmail.com>
*
* 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.
*/
#ifndef ECC_GF13_H_
#define ECC_GF13_H_
#include <stdint.h>
/* Galois field tables of order 2^13-1 */
#define GF13_ORDER 8191
typedef uint16_t gf13_elem_t;
/* If you need to reduce the code size, you can define GF13_NO_TABLES.
*
* This results in much smaller (but also much slower) code.
*/
#ifdef GF13_NO_TABLES
gf13_elem_t gf13_mul(gf13_elem_t a, gf13_elem_t b);
gf13_elem_t gf13_div(gf13_elem_t a, gf13_elem_t b);
static inline gf13_elem_t gf13_divx(gf13_elem_t a)
{
return gf13_mul(a, 0x100d);
}
static inline gf13_elem_t gf13_mulx(gf13_elem_t a)
{
gf13_elem_t r = a << 1;
if (r & 8192)
r ^= 0x201b;
return r;
}
#else
extern const gf13_elem_t gf13_exp[8192];
extern const gf13_elem_t gf13_log[8192];
/* Wrappers for field arithmetic */
static inline gf13_elem_t gf13_wrap(gf13_elem_t s)
{
return (s >= GF13_ORDER) ? (s - GF13_ORDER) : s;
}
static inline gf13_elem_t gf13_mul(gf13_elem_t a, gf13_elem_t b)
{
return gf13_exp[gf13_wrap(gf13_log[a] + gf13_log[b])];
}
static inline gf13_elem_t gf13_div(gf13_elem_t a, gf13_elem_t b)
{
return gf13_exp[gf13_wrap(gf13_log[a] + GF13_ORDER - gf13_log[b])];
}
static inline gf13_elem_t gf13_divx(gf13_elem_t a)
{
return gf13_exp[gf13_wrap(gf13_log[a] + GF13_ORDER - 1)];
}
static inline gf13_elem_t gf13_mulx(gf13_elem_t a)
{
return gf13_exp[gf13_wrap(gf13_log[a] + 1)];
}
#endif
#endif
| 25.523256 | 75 | 0.75262 |
a220310a0eb8917fbb02ec01fb4ca41cb1bf4f37 | 12,735 | c | C | stores/filestore/tmfile.c | algermissen/tmtk | 899701f6327cf927752a7eae839dc6b6dd9342d5 | [
"MIT"
] | null | null | null | stores/filestore/tmfile.c | algermissen/tmtk | 899701f6327cf927752a7eae839dc6b6dd9342d5 | [
"MIT"
] | null | null | null | stores/filestore/tmfile.c | algermissen/tmtk | 899701f6327cf927752a7eae839dc6b6dd9342d5 | [
"MIT"
] | null | null | null | /*
* $Id$
*
* Copyright (c) 2002 Jan Algermissen
* See the file "COPYING" for copying permission.
*
*/
#include <sys/stat.h> /* for stat() */
#include "tmfile.h"
#include <tmutil.h>
#include <tmmem.h>
#include <tmtrace.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
/* we need some cache, since pages need to be kept as long as they are
* accessed (between fetch and drop).
*/
#define MIN_CACHE_SIZE (TM_PAGE_SIZE * 100)
/* the cache consists of these items */
struct page_item {
TMPage page; /* tm_file_fetch_page() returns this pointer */
int usecount; /* usecount > 0 means also 'is locked' */
/* FIXME: timestamp? */
};
struct TMFile {
int fd; /* the file handle */
int is_open; /* open status */
double cache_size; /* current cache size */
char *path; /* file name */
char errstr[1024]; /* holds error */
struct { /* the cache */
struct page_item *page_items;
int pcnt; /* number of used items */
int pmax; /* maximum number (cache_size / page size) */
} cache;
};
/* local rountines */
static const char *_set_error(TMFile self, const char *fmt,...);
static TMError _readpage(TMFile self,TMPage p, int n);
static TMError _writepage(TMFile self,TMPage p);
/* FIXME: add flag for immediate write etc. !! */
TMFile tm_file_new(const char *path, long cache_size)
{
TMFile self;
int i;
assert(path);
/* FIXME: */
assert(sizeof(int) == 4);
assert(sizeof(off_t) == 4);
TM_NEW(self);
if(!self)
return NULL;
self->is_open = 0;
self->cache_size = (cache_size >= MIN_CACHE_SIZE) ? cache_size :
MIN_CACHE_SIZE;
self->path = tm_strdup(path);
bzero(self->errstr,sizeof(self->errstr));
self->cache.pmax = self->cache_size / TM_PAGE_SIZE;
self->cache.page_items = (struct page_item*)TM_ALLOC(
self->cache.pmax * sizeof(struct page_item) );
assert(self->cache.page_items);
for(i = 0; i < self->cache.pmax; i++)
{
self->cache.page_items[i].page =
(TMPage)TM_ALLOC(TM_PAGE_SIZE);
assert(self->cache.page_items[i].page);
self->cache.page_items[i].usecount = 0;
}
self->cache.pcnt = 0;
return self;
}
void tm_file_delete(TMFile *pself)
{
TMFile self;
int i;
assert(pself && *pself);
self = *pself;
assert(!self->is_open);
for(i = 0; i < self->cache.pmax; i++)
TM_FREE(self->cache.page_items[i].page);
TM_FREE(self->cache.page_items);
TM_FREE(self->path);
TM_FREE(self);
}
TMError tm_file_open(TMFile self, int *created)
{
struct stat stat_buf;
TMTRACE(TM_STORAGE_TRACE,"tm_file_open(): enter path=%s\n" _ self->path);
assert(created);
assert(!self->is_open);
*created = 0;
if(stat(self->path,&stat_buf) < 0)
{
TMTRACE(TM_STORAGE_TRACE,
"cannot stat %s, (%s) opening with CREAT\n" _
self->path _ strerror(errno) );
if( (self->fd = open(self->path,
O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) < 0)
{
_set_error(self,"cannot create file %s, %s",
self->path, strerror(errno));
return TM_ESYS;
}
TMTRACE(TM_STORAGE_TRACE,"created %s\n" _ self->path);
*created = 1;
self->is_open = 1;
return TM_OK;
}
if( (self->fd = open(self->path,O_RDWR, S_IRUSR | S_IWUSR)) < 0)
{
_set_error(self,"cannot open file %s, %s",
self->path, strerror(errno));
return TM_ESYS;
}
TMTRACE(TM_STORAGE_TRACE,"opened %s\n" _ self->path);
self->is_open = 1;
return TM_OK;
}
TMError tm_file_close(TMFile self)
{
int i;
assert(self);
assert(self->is_open);
TMTRACE(TM_STORAGE_TRACE,"tm_file_close(): enter [%s]\n" _ self->path);
for(i = 0; i < self->cache.pcnt; i++)
{
assert(self->cache.page_items[i].usecount == 0);
/* this assertion enforces the client to flush the file
* before calling close. I think that is good, so I leave
* the assertion here.
*/
assert(! tm_page_changed(self->cache.page_items[i].page));
if(gs_page_get_changedflag(self->cache.page_items[i].page))
{
if(_writepage(self,
self->cache.page_items[i].page) != TM_OK)
return TM_ESYS;
}
}
if( close(self->fd) < 0 )
{
_set_error(self,"cannot close file %s, %s",
self->path, strerror(errno));
return TM_ESYS;
}
TMTRACE(TM_STORAGE_TRACE,"tm_file_close(): exit\n");
self->is_open = 0;
return TM_OK;
}
const char *tm_file_get_error(TMFile self)
{
assert(self);
return (self->errstr);
}
TMError tm_file_create_page(TMFile self,GS_INITFUNC_T initfunc,int *np)
{
off_t offset;
int n;
char empty[TM_PAGE_SIZE]; /* an empty page to do initialization
on */
TMPage p; /* pointer to that page */
TMTRACE(TM_STORAGE_TRACE,"tm_file_create_page(): enter\n");
p = empty;
assert(self);
assert(np);
if( (offset = lseek(self->fd,0,SEEK_END)) < 0)
{
_set_error(self,"cannot seek to end %s, %s",
self->path, strerror(errno));
return TM_ESYS;
}
TMTRACE(TM_STORAGE_TRACE,"tm_file_create_page(): end of last page: %ld\n" _ offset);
n = ( (int)offset / TM_PAGE_SIZE ) + 1;
/* initialize page either with caller's function or the standard one*/
if(initfunc)
initfunc(p,n);
else
tm_page_init(p,n);
if( write(self->fd,p,TM_PAGE_SIZE) != TM_PAGE_SIZE)
{
_set_error(self,"cannot write new page to %s, %s",
self->path, strerror(errno));
return TM_ESYS;
}
*np = n;
TMTRACE(TM_STORAGE_TRACE,"tm_file_create_page(): exit n=%d\n" _ *np);
return TM_OK;
}
TMError tm_file_fetch_page(TMFile self,int n,TMPage *bp)
{
int i;
assert(self);
assert(bp);
assert(n > 0);
*bp = NULL;
TMTRACE(TM_STORAGE_TRACE,"tm_file_fetch_page(): page %d of %s\n" _
n _ self->path);
/*
* Step 1: Look for page in our cache.
*/
for (i=0; i<self->cache.pcnt; i++)
{
if(gs_page_get_number(self->cache.page_items[i].page) == n)
{
self->cache.page_items[i].usecount++;
/* XXXX */
/*
_readpage(self->f,self->cache.page_items[i].page,n);
*/
/* set callers page pointer to the cached page */
*bp = self->cache.page_items[i].page;
return TM_OK;
}
}
/*
* Page was not found in the cache, now we need
* Step 2: get page from disk if still room in cache
*/
if(self->cache.pcnt < self->cache.pmax)
{
i = self->cache.pcnt;
/* FIXME: we might keep the old page and restore if fails */
if(_readpage(self,self->cache.page_items[i].page,n) != TM_OK)
return TM_ESYS;
self->cache.page_items[i].usecount = 1;
*bp = self->cache.page_items[i].page;
self->cache.pcnt++;
return TM_OK;
}
/*
* Since now space left in cache, we need
* Step 3: throw one page away and load requested page
* from disk.
* FIXME: use better algorithm? Does it matter?
*/
for(i = 0; i < self->cache.pmax; i++)
{
if(!self->cache.page_items[i].usecount == 0)
{
/* take the first available spot */
break;
}
}
/* FIXME: how to handle that situation */
assert(i < self->cache.pmax); /* or cache too small !! */
if(gs_page_get_changedflag(self->cache.page_items[i].page))
{
if(_writepage(self,self->cache.page_items[i].page) != TM_OK)
return TM_ESYS;
}
if(_readpage(self,self->cache.page_items[i].page,n) != TM_OK)
return TM_ESYS;
assert(gs_page_get_number(self->cache.page_items[i].page) == n);
self->cache.page_items[i].usecount = 1;
*bp = self->cache.page_items[i].page;
return TM_OK;
}
TMError tm_file_drop_page(TMFile self, TMPage page)
{
int i;
assert(self);
assert(page);
TMTRACE(TM_STORAGE_TRACE,
"tm_file_drop_page(): page %d of %s\n" _
gs_page_get_number(page) _ self->path);
for(i = 0; i < self->cache.pmax; i++)
{
if(self->cache.page_items[i].page == page)
{
assert(self->cache.page_items[i].usecount > 0);
self->cache.page_items[i].usecount--;
/* XXXX */
/*
_writepage(self,self->cache.page_items[i].page);
*/
return TM_OK;
}
}
return TM_OK;
}
TMError tm_file_flush_cache(TMFile self)
{
int i;
assert(self);
for(i = 0; i < self->cache.pcnt; i++)
{
if(tm_page_changed(self->cache.page_items[i].page))
{
if(_writepage(self,self->cache.page_items[i].page)
!= TM_OK)
return TM_ESYS;
}
}
return TM_OK;
}
#if 0
static const char *files[] = {
"topics",
"data",
"locpfxtree",
"wordpfxtree",
"wordindex",
NULL
};
TMError gs_storage_create_topicmap(const char *name)
{
char buf[256];
int i = 0;
int fd;
assert(name);
assert(name[strlen(name)-1] != '/');
TMTRACE(TM_STORAGE_TRACE,"creating topicmap _%s_\n" _ name );
if( mkdir(name,O_RDWR | O_CREAT | O_EXCL) < 0)
{
TMTRACE(TM_STORAGE_TRACE,"cannot create directory %s, %s\n" _
name _ strerror(errno));
return GS_ESYS;
}
if( chmod(name,S_IRUSR | S_IWUSR | S_IXUSR) )
{
/* FIXME: unlink directory ?? */
TMTRACE(TM_STORAGE_TRACE,"cannot chmod on %s, %s\n" _
buf _ strerror(errno));
return GS_ESYS;
}
while(files && files[i] != NULL)
{
snprintf(buf,sizeof(buf),"%s/%s",name,files[i]);
if( (fd = open(buf,O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) < 0)
{
/* FIXME: unlink directory ?? */
TMTRACE(TM_STORAGE_TRACE,"cannot open %s, %s\n" _
buf _ strerror(errno) );
return GS_ESYS;
}
i++;
}
return GS_OK;
}
TMError gs_storage_destroy_topicmap(const char *name)
{
char buf[GS_MAXPATH];
assert(name);
TMTRACE(TM_STORAGE_TRACE,"destroying topicmap _%s_\n" _ name );
/* ok, if we got here, topicmap has been removed an we can delete */
snprintf(buf,sizeof(buf),"topicmaps/%s/topics",name);
/* check if user has permissions to destroy topicmap */
if( unlink(buf) < 0)
{
TMTRACE(TM_STORAGE_TRACE,"unlink error: %s\n" _ strerror(errno));
/*
gs_thread_set_error(tp,GS_EXXX,
"cannot remove topics file, %s",strerror(errno));
*/
return GS_ESYS;
}
snprintf(buf,sizeof(buf),"topicmaps/%s/data",name);
/* check if user has permissions to destroy topicmap */
if( unlink(buf) < 0)
{
TMTRACE(TM_STORAGE_TRACE,"unlink error: %s\n" _ strerror(errno));
/*
gs_thread_set_error(tp,GS_EXXX,
"cannot remove data file, %s",strerror(errno));
*/
return GS_ESYS;
}
snprintf(buf,sizeof(buf),"topicmaps/%s/locpfxtree",name);
/* check if user has permissions to destroy topicmap */
if( unlink(buf) < 0)
{
TMTRACE(TM_STORAGE_TRACE,"unlink error: %s\n" _ strerror(errno));
/*
gs_thread_set_error(tp,GS_EXXX,
"cannot remove lpt file, %s",strerror(errno));
*/
return GS_ESYS;
}
snprintf(buf,sizeof(buf),"topicmaps/%s",name);
/* check if user has permissions to destroy topicmap */
if( rmdir(buf) < 0)
{
TMTRACE(TM_STORAGE_TRACE,"rmdir error: %s\n" _ strerror(errno));
/*
gs_thread_set_error(tp,GS_EXXX,"cannot destroy %s, %s" ,
name, strerror(errno));
*/
return GS_ESYS;
}
return GS_OK;
}
#endif /* if 0 */
#ifdef TEST
#include "test.h"
int main(int argc, char **args)
{
GS_TEST_T test;
GS_FILE_T file;
byte p[GS_PAGE_SIZE];
int created = 0;
TMError e;
test = gs_test_new(__FILE__);
e = gs_storage_open_file("/xxtmp/testfile", NULL, 20000, &file, &created);
GS_TEST(test, e == GS_ESYS);
/*
printf("errno=%s\n", strerror(errno));
*/
e = gs_storage_open_file("/tmp/testfile", NULL, 20000, &file, &created);
GS_TEST(test, e == GS_OK);
_readpage(file->f,p,1);
GS_TEST(test, gs_page_get_number(p) == 1);
/*
GS_TEST(test, gs_page_get_number(p) == 0);
*/
gs_storage_close_file(file);
gs_test_delete(&test);
return 0;
}
#endif
const char *_set_error(TMFile self, const char *fmt,...)
{
va_list args;
assert(self);
assert(fmt);
va_start(args,fmt);
vsnprintf(self->errstr,sizeof(self->errstr),fmt,args);
va_end(args);
return (self->errstr);
}
TMError _readpage(TMFile self ,TMPage p, int n)
{
off_t offset;
assert(self);
assert(p);
assert(n > 0);
TMTRACE(TM_STORAGE_TRACE," _readpage(): n=%d\n" _ n);
offset = TM_PAGE_SIZE * (n-1);
if( lseek(self->fd,offset,SEEK_SET) != offset)
{
_set_error(self,"cannot seek file %s to %ld, %s",
self->path, offset, strerror(errno));
return TM_ESYS;
}
if( read(self->fd,p,TM_PAGE_SIZE) != TM_PAGE_SIZE)
{
_set_error(self,"reading file %s failed, %s",
self->path, strerror(errno));
return TM_ESYS;
}
/* check the returned page number */
assert(gs_page_get_number(p) == n);
return TM_OK;
}
TMError _writepage(TMFile self,TMPage p)
{
off_t offset;
int n;
assert(self);
assert(p);
n = gs_page_get_number(p);
TMTRACE(TM_STORAGE_TRACE," _writepage() enter n=%d\n" _ n );
tm_page_clear_changedflag(p);
offset = TM_PAGE_SIZE * (n-1);
if(lseek(self->fd,offset,SEEK_SET) != offset)
{
_set_error(self,"cannot seek file %s to %ld, %s",
self->path, offset, strerror(errno));
return TM_ESYS;
}
if(write(self->fd,p,GS_PAGE_SIZE) != GS_PAGE_SIZE)
{
_set_error(self,"writng to file %s failed, %s",
self->path, strerror(errno));
return TM_ESYS;
}
return TM_OK;
}
| 21.189684 | 85 | 0.651904 |
9e37240a578d748fb8e78390d4884069cb27279f | 356 | h | C | Game/Source/Game/include/MY_ResourceManager.h | RyanBluth/Low-Rez-Jam | e6d82807ea57502613fa8cd7afc97bd8b409b24c | [
"MIT"
] | 1 | 2016-04-02T21:01:29.000Z | 2016-04-02T21:01:29.000Z | Game/Source/Game/include/MY_ResourceManager.h | seleb/MiniLD66 | 8871f3ad6743f2530257193a678a28288b88fd11 | [
"MIT"
] | null | null | null | Game/Source/Game/include/MY_ResourceManager.h | seleb/MiniLD66 | 8871f3ad6743f2530257193a678a28288b88fd11 | [
"MIT"
] | null | null | null | #pragma once
#include <ResourceManager.h>
#include <scenario\Scenario.h>
class MY_ResourceManager : public ResourceManager{
public:
// A container for all of the assets which are loaded at initialization and are accessible from anywhere in the application, at any time
static Scenario * globalAssets;
MY_ResourceManager();
~MY_ResourceManager();
}; | 27.384615 | 137 | 0.783708 |
9e78f931e87a8ce13e36f891b93a6fcf5deca488 | 10,102 | c | C | third-party/ffmpeg/src/ffmpeg-4.4/libavformat/hlsproto.c | wangyoucao577/m2kit | 3d42dda3e22c1e9ee5db5fd09a05c216fc2f06cc | [
"MIT"
] | 30 | 2022-03-10T16:34:13.000Z | 2022-03-29T09:32:35.000Z | third-party/ffmpeg/src/ffmpeg-4.4/libavformat/hlsproto.c | wangyoucao577/m2kit | 3d42dda3e22c1e9ee5db5fd09a05c216fc2f06cc | [
"MIT"
] | 2 | 2021-07-24T19:31:37.000Z | 2022-02-14T05:25:19.000Z | ffmpeg-gpu/libavformat/hlsproto.c | NVIDIA/FFmpeg-GPU-Demo | f41f54bb72359e024a106aa665e1484e13497ee3 | [
"RSA-MD"
] | 2 | 2021-07-13T08:06:59.000Z | 2021-07-24T19:27:44.000Z | /*
* Apple HTTP Live Streaming Protocol Handler
* Copyright (c) 2010 Martin Storsjo
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg 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 FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* Apple HTTP Live Streaming Protocol Handler
* https://www.rfc-editor.org/rfc/rfc8216.txt
*/
#include "libavutil/avstring.h"
#include "libavutil/time.h"
#include "avformat.h"
#include "avio_internal.h"
#include "internal.h"
#include "url.h"
#include "version.h"
/*
* An apple http stream consists of a playlist with media segment files,
* played sequentially. There may be several playlists with the same
* video content, in different bandwidth variants, that are played in
* parallel (preferably only one bandwidth variant at a time). In this case,
* the user supplied the url to a main playlist that only lists the variant
* playlists.
*
* If the main playlist doesn't point at any variants, we still create
* one anonymous toplevel variant for this, to maintain the structure.
*/
struct segment {
int64_t duration;
char url[MAX_URL_SIZE];
};
struct variant {
int bandwidth;
char url[MAX_URL_SIZE];
};
typedef struct HLSContext {
char playlisturl[MAX_URL_SIZE];
int64_t target_duration;
int start_seq_no;
int finished;
int n_segments;
struct segment **segments;
int n_variants;
struct variant **variants;
int cur_seq_no;
URLContext *seg_hd;
int64_t last_load_time;
} HLSContext;
static void free_segment_list(HLSContext *s)
{
int i;
for (i = 0; i < s->n_segments; i++)
av_freep(&s->segments[i]);
av_freep(&s->segments);
s->n_segments = 0;
}
static void free_variant_list(HLSContext *s)
{
int i;
for (i = 0; i < s->n_variants; i++)
av_freep(&s->variants[i]);
av_freep(&s->variants);
s->n_variants = 0;
}
struct variant_info {
char bandwidth[20];
};
static void handle_variant_args(struct variant_info *info, const char *key,
int key_len, char **dest, int *dest_len)
{
if (!strncmp(key, "BANDWIDTH=", key_len)) {
*dest = info->bandwidth;
*dest_len = sizeof(info->bandwidth);
}
}
static int parse_playlist(URLContext *h, const char *url)
{
HLSContext *s = h->priv_data;
AVIOContext *in;
int ret = 0, is_segment = 0, is_variant = 0, bandwidth = 0;
int64_t duration = 0;
char line[1024];
const char *ptr;
if ((ret = ffio_open_whitelist(&in, url, AVIO_FLAG_READ,
&h->interrupt_callback, NULL,
h->protocol_whitelist, h->protocol_blacklist)) < 0)
return ret;
ff_get_chomp_line(in, line, sizeof(line));
if (strcmp(line, "#EXTM3U")) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
free_segment_list(s);
s->finished = 0;
while (!avio_feof(in)) {
ff_get_chomp_line(in, line, sizeof(line));
if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) {
struct variant_info info = {{0}};
is_variant = 1;
ff_parse_key_value(ptr, (ff_parse_key_val_cb) handle_variant_args,
&info);
bandwidth = atoi(info.bandwidth);
} else if (av_strstart(line, "#EXT-X-TARGETDURATION:", &ptr)) {
s->target_duration = atoi(ptr) * AV_TIME_BASE;
} else if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", &ptr)) {
s->start_seq_no = atoi(ptr);
} else if (av_strstart(line, "#EXT-X-ENDLIST", &ptr)) {
s->finished = 1;
} else if (av_strstart(line, "#EXTINF:", &ptr)) {
is_segment = 1;
duration = atof(ptr) * AV_TIME_BASE;
} else if (av_strstart(line, "#", NULL)) {
continue;
} else if (line[0]) {
if (is_segment) {
struct segment *seg = av_malloc(sizeof(struct segment));
if (!seg) {
ret = AVERROR(ENOMEM);
goto fail;
}
seg->duration = duration;
ff_make_absolute_url(seg->url, sizeof(seg->url), url, line);
dynarray_add(&s->segments, &s->n_segments, seg);
is_segment = 0;
} else if (is_variant) {
struct variant *var = av_malloc(sizeof(struct variant));
if (!var) {
ret = AVERROR(ENOMEM);
goto fail;
}
var->bandwidth = bandwidth;
ff_make_absolute_url(var->url, sizeof(var->url), url, line);
dynarray_add(&s->variants, &s->n_variants, var);
is_variant = 0;
}
}
}
s->last_load_time = av_gettime_relative();
fail:
avio_close(in);
return ret;
}
static int hls_close(URLContext *h)
{
HLSContext *s = h->priv_data;
free_segment_list(s);
free_variant_list(s);
ffurl_closep(&s->seg_hd);
return 0;
}
static int hls_open(URLContext *h, const char *uri, int flags)
{
HLSContext *s = h->priv_data;
int ret, i;
const char *nested_url;
if (flags & AVIO_FLAG_WRITE)
return AVERROR(ENOSYS);
h->is_streamed = 1;
if (av_strstart(uri, "hls+", &nested_url)) {
av_strlcpy(s->playlisturl, nested_url, sizeof(s->playlisturl));
} else if (av_strstart(uri, "hls://", &nested_url)) {
av_log(h, AV_LOG_ERROR,
"No nested protocol specified. Specify e.g. hls+http://%s\n",
nested_url);
ret = AVERROR(EINVAL);
goto fail;
} else {
av_log(h, AV_LOG_ERROR, "Unsupported url %s\n", uri);
ret = AVERROR(EINVAL);
goto fail;
}
av_log(h, AV_LOG_WARNING,
"Using the hls protocol is discouraged, please try using the "
"hls demuxer instead. The hls demuxer should be more complete "
"and work as well as the protocol implementation. (If not, "
"please report it.) To use the demuxer, simply use %s as url.\n",
s->playlisturl);
if ((ret = parse_playlist(h, s->playlisturl)) < 0)
goto fail;
if (s->n_segments == 0 && s->n_variants > 0) {
int max_bandwidth = 0, maxvar = -1;
for (i = 0; i < s->n_variants; i++) {
if (s->variants[i]->bandwidth > max_bandwidth || i == 0) {
max_bandwidth = s->variants[i]->bandwidth;
maxvar = i;
}
}
av_strlcpy(s->playlisturl, s->variants[maxvar]->url,
sizeof(s->playlisturl));
if ((ret = parse_playlist(h, s->playlisturl)) < 0)
goto fail;
}
if (s->n_segments == 0) {
av_log(h, AV_LOG_WARNING, "Empty playlist\n");
ret = AVERROR(EIO);
goto fail;
}
s->cur_seq_no = s->start_seq_no;
if (!s->finished && s->n_segments >= 3)
s->cur_seq_no = s->start_seq_no + s->n_segments - 3;
return 0;
fail:
hls_close(h);
return ret;
}
static int hls_read(URLContext *h, uint8_t *buf, int size)
{
HLSContext *s = h->priv_data;
const char *url;
int ret;
int64_t reload_interval;
start:
if (s->seg_hd) {
ret = ffurl_read(s->seg_hd, buf, size);
if (ret > 0)
return ret;
}
if (s->seg_hd) {
ffurl_closep(&s->seg_hd);
s->cur_seq_no++;
}
reload_interval = s->n_segments > 0 ?
s->segments[s->n_segments - 1]->duration :
s->target_duration;
retry:
if (!s->finished) {
int64_t now = av_gettime_relative();
if (now - s->last_load_time >= reload_interval) {
if ((ret = parse_playlist(h, s->playlisturl)) < 0)
return ret;
/* If we need to reload the playlist again below (if
* there's still no more segments), switch to a reload
* interval of half the target duration. */
reload_interval = s->target_duration / 2;
}
}
if (s->cur_seq_no < s->start_seq_no) {
av_log(h, AV_LOG_WARNING,
"skipping %d segments ahead, expired from playlist\n",
s->start_seq_no - s->cur_seq_no);
s->cur_seq_no = s->start_seq_no;
}
if (s->cur_seq_no - s->start_seq_no >= s->n_segments) {
if (s->finished)
return AVERROR_EOF;
while (av_gettime_relative() - s->last_load_time < reload_interval) {
if (ff_check_interrupt(&h->interrupt_callback))
return AVERROR_EXIT;
av_usleep(100*1000);
}
goto retry;
}
url = s->segments[s->cur_seq_no - s->start_seq_no]->url;
av_log(h, AV_LOG_DEBUG, "opening %s\n", url);
ret = ffurl_open_whitelist(&s->seg_hd, url, AVIO_FLAG_READ,
&h->interrupt_callback, NULL,
h->protocol_whitelist, h->protocol_blacklist, h);
if (ret < 0) {
if (ff_check_interrupt(&h->interrupt_callback))
return AVERROR_EXIT;
av_log(h, AV_LOG_WARNING, "Unable to open %s\n", url);
s->cur_seq_no++;
goto retry;
}
goto start;
}
const URLProtocol ff_hls_protocol = {
.name = "hls",
.url_open = hls_open,
.url_read = hls_read,
.url_close = hls_close,
.flags = URL_PROTOCOL_FLAG_NESTED_SCHEME,
.priv_data_size = sizeof(HLSContext),
};
| 31.56875 | 86 | 0.580182 |
7f2e313c3825d788a056d5c26811df7f81e12690 | 2,615 | h | C | mindspore/ccsrc/minddata/dataset/kernels/image/pad_op.h | GuoSuiming/mindspore | 48afc4cfa53d970c0b20eedfb46e039db2a133d5 | [
"Apache-2.0"
] | 55 | 2020-12-17T10:26:06.000Z | 2022-03-28T07:18:26.000Z | mindspore/ccsrc/minddata/dataset/kernels/image/pad_op.h | forwhat461/mindspore | 59a277756eb4faad9ac9afcc7fd526e8277d4994 | [
"Apache-2.0"
] | 1 | 2020-12-29T06:46:38.000Z | 2020-12-29T06:46:38.000Z | mindspore/ccsrc/minddata/dataset/kernels/image/pad_op.h | forwhat461/mindspore | 59a277756eb4faad9ac9afcc7fd526e8277d4994 | [
"Apache-2.0"
] | 14 | 2021-01-29T02:39:47.000Z | 2022-03-23T05:00:26.000Z | /**
* Copyright 2019 Huawei Technologies 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.
*/
#ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_PAD_OP_H_
#define MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_PAD_OP_H_
#include <memory>
#include <vector>
#include <string>
#include "minddata/dataset/core/tensor.h"
#include "minddata/dataset/kernels/tensor_op.h"
#include "minddata/dataset/core/constants.h"
#include "minddata/dataset/util/status.h"
namespace mindspore {
namespace dataset {
class PadOp : public TensorOp {
public:
// Default values, also used by python_bindings.cc
static const BorderType kDefBorderType;
static const uint8_t kDefFillR;
static const uint8_t kDefFillG;
static const uint8_t kDefFillB;
// Constructor for PadOp.
// @param pad_top number of pixels to pad the top of image with.
// @param pad_bottom number of pixels to pad the bottom of the image with.
// @param pad_left number of pixels to pad the left of the image with.
// @param pad_right number of pixels to pad the right of the image with.
// @param border_types BorderType enum, the type of boarders that we are using.
// @param fill_r R value for the color to pad with.
// @param fill_g G value for the color to pad with.
// @param fill_b B value for the color to pad with.
PadOp(int32_t pad_top, int32_t pad_bottom, int32_t pad_left, int32_t pad_right, BorderType border_types,
uint8_t fill_r = kDefFillR, uint8_t fill_g = kDefFillG, uint8_t fill_b = kDefFillB);
~PadOp() override = default;
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
Status OutputShape(const std::vector<TensorShape> &inputs, std::vector<TensorShape> &outputs) override;
std::string Name() const override { return kPadOp; }
private:
int32_t pad_top_;
int32_t pad_bottom_;
int32_t pad_left_;
int32_t pad_right_;
BorderType boarder_type_;
uint8_t fill_r_;
uint8_t fill_g_;
uint8_t fill_b_;
};
} // namespace dataset
} // namespace mindspore
#endif // MINDSPORE_CCSRC_MINDDATA_DATASET_KERNELS_IMAGE_PAD_OP_H_
| 36.830986 | 106 | 0.759082 |
2c6a1797811dbb29b09ebe36a97d0b7aba8fd80b | 4,215 | c | C | hypre-2.11.2/src/FEI_mv/DSuperLU/SRC/dsp_blas3.c | GWU-CFD/flash-distro | 740f45047bde057365823036158893c19c6d7c72 | [
"MIT"
] | 75 | 2015-07-06T18:14:20.000Z | 2022-01-24T02:54:32.000Z | src/ilPSP/layer_0/3rd_party/Hypre2.9.0b/src/FEI_mv/DSuperLU/SRC/dsp_blas3.c | leyel/BoSSS | 39f58a1a64a55e44f51384022aada20a5b425230 | [
"Apache-2.0"
] | 15 | 2017-04-07T18:09:58.000Z | 2022-02-28T01:48:33.000Z | src/ilPSP/layer_0/3rd_party/Hypre2.9.0b/src/FEI_mv/DSuperLU/SRC/dsp_blas3.c | leyel/BoSSS | 39f58a1a64a55e44f51384022aada20a5b425230 | [
"Apache-2.0"
] | 41 | 2015-05-24T23:24:54.000Z | 2021-12-13T22:07:45.000Z | /*
* -- Distributed SuperLU routine (version 1.0) --
* Lawrence Berkeley National Lab, Univ. of California Berkeley.
* September 1, 1999
*
*/
/*
* File name: sp_blas3.c
* Purpose: Sparse BLAS3, using some dense BLAS3 operations.
*/
#include "superlu_ddefs.h"
int
sp_dgemm_dist(char *transa, char *transb, int m, int n, int k,
double alpha, SuperMatrix *A, double *b, int ldb,
double beta, double *c, int ldc)
{
/* Purpose
=======
sp_d performs one of the matrix-matrix operations
C := alpha*op( A )*op( B ) + beta*C,
where op( X ) is one of
op( X ) = X or op( X ) = X' or op( X ) = conjg( X' ),
alpha and beta are scalars, and A, B and C are matrices, with op( A )
an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
Parameters
==========
TRANSA - (input) char*
On entry, TRANSA specifies the form of op( A ) to be used in
the matrix multiplication as follows:
TRANSA = 'N' or 'n', op( A ) = A.
TRANSA = 'T' or 't', op( A ) = A'.
TRANSA = 'C' or 'c', op( A ) = conjg( A' ).
Unchanged on exit.
TRANSB - (input) char*
On entry, TRANSB specifies the form of op( B ) to be used in
the matrix multiplication as follows:
TRANSB = 'N' or 'n', op( B ) = B.
TRANSB = 'T' or 't', op( B ) = B'.
TRANSB = 'C' or 'c', op( B ) = conjg( B' ).
Unchanged on exit.
M - (input) int
On entry, M specifies the number of rows of the matrix
op( A ) and of the matrix C. M must be at least zero.
Unchanged on exit.
N - (input) int
On entry, N specifies the number of columns of the matrix
op( B ) and the number of columns of the matrix C. N must be
at least zero.
Unchanged on exit.
K - (input) int
On entry, K specifies the number of columns of the matrix
op( A ) and the number of rows of the matrix op( B ). K must
be at least zero.
Unchanged on exit.
ALPHA - (input) double
On entry, ALPHA specifies the scalar alpha.
A - (input) SuperMatrix*
Matrix A with a sparse format, of dimension (A->nrow, A->ncol).
Currently, the type of A can be:
Stype = SLU_NC or SLU_NCP; Dtype = SLU_D; Mtype = SLU_GE.
In the future, more general A can be handled.
B - DOUBLE PRECISION array of DIMENSION ( LDB, kb ), where kb is
n when TRANSB = 'N' or 'n', and is k otherwise.
Before entry with TRANSB = 'N' or 'n', the leading k by n
part of the array B must contain the matrix B, otherwise
the leading n by k part of the array B must contain the
matrix B.
Unchanged on exit.
LDB - (input) int
On entry, LDB specifies the first dimension of B as declared
in the calling (sub) program. LDB must be at least max( 1, n ).
Unchanged on exit.
BETA - (input) double
On entry, BETA specifies the scalar beta. When BETA is
supplied as zero then C need not be set on input.
C - DOUBLE PRECISION array of DIMENSION ( LDC, n ).
Before entry, the leading m by n part of the array C must
contain the matrix C, except when beta is zero, in which
case C need not be set on entry.
On exit, the array C is overwritten by the m by n matrix
( alpha*op( A )*B + beta*C ).
LDC - (input) int
On entry, LDC specifies the first dimension of C as declared
in the calling (sub)program. LDC must be at least max(1,m).
Unchanged on exit.
==== Sparse Level 3 Blas routine.
*/
int incx = 1, incy = 1;
int j;
for (j = 0; j < n; ++j) {
sp_dgemv_dist(transa, alpha, A, &b[ldb*j], incx, beta, &c[ldc*j], incy);
}
return 0;
}
| 35.420168 | 78 | 0.528351 |
2c8bb1ff87efe5e4bd06d6605eeddd120020675f | 599 | h | C | C++/OOP Game 2nd course/Stepik/Figures/Circle.h | po4yka/elementary-education-projects | f525a41eef2dee98e2a2ff8a7d063fac747d0d4b | [
"MIT"
] | 1 | 2020-09-01T20:22:30.000Z | 2020-09-01T20:22:30.000Z | C++/OOP Game 2nd course/Stepik/Figures/Circle.h | po4yka/EducationProjects | f525a41eef2dee98e2a2ff8a7d063fac747d0d4b | [
"MIT"
] | null | null | null | C++/OOP Game 2nd course/Stepik/Figures/Circle.h | po4yka/EducationProjects | f525a41eef2dee98e2a2ff8a7d063fac747d0d4b | [
"MIT"
] | null | null | null | #ifndef STEPIC_CIRCLE_H
#define STEPIC_CIRCLE_H
#include "../Subsidiary/IGeometricObject.h"
#include "Shape.h"
class Circle final : public Shape {
private:
float radius{};
public:
~Circle() override = default;
Circle(int xCenter, int yCenter, float radius_, ANSIColor::eCOLOR_CODE color_);
// Geometry object interface realization
eFIGURE getType() const override;
std::string getDescription() const override;
// Shape interface realization
void move(std::vector<BasePoint> newVertex) override;
void scale(float factor) override;
};
#endif //STEPIC_CIRCLE_H
| 24.958333 | 83 | 0.731219 |
82b361716c5df7ec1bed3eff4c36bedbdfda70b5 | 4,887 | h | C | AXVersionKit/Classes/AVKVersion.h | devedbox/AXVersionKit | 02ac1d0400851836ea4a1f319cbe833e103be6b2 | [
"MIT"
] | null | null | null | AXVersionKit/Classes/AVKVersion.h | devedbox/AXVersionKit | 02ac1d0400851836ea4a1f319cbe833e103be6b2 | [
"MIT"
] | null | null | null | AXVersionKit/Classes/AVKVersion.h | devedbox/AXVersionKit | 02ac1d0400851836ea4a1f319cbe833e103be6b2 | [
"MIT"
] | null | null | null | //
// AVKVersion.h
// AXVersionKit
//
// Created by devedbox on 2017/3/30.
// Copyright © 2017年 devedbox. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#import <Foundation/Foundation.h>
@interface AVKVersion : NSObject
/// primaryGenreName.
@property(readonly, copy, nonatomic) NSString *primaryGenreName;
/// Artist id of the app.
@property(readonly, copy, nonatomic) NSString *artistId;
/// artworkUrl100.
@property(readonly, copy, nonatomic) NSString *artworkUrl100;
/// sellerUrl.
@property(readonly, copy, nonatomic) NSString *sellerUrl;
/// currency.
@property(readonly, copy, nonatomic) NSString *currency;
/// artworkUrl512.
@property(readonly, copy, nonatomic) NSString *artworkUrl512;
/// ipadScreenshotUrls.
@property(readonly, copy, nonatomic) NSArray<NSString *> *ipadScreenshotUrls;
/// fileSizeBytes.
@property(readonly, nonatomic) NSUInteger fileSizeBytes;
/// genres.
@property(readonly, copy, nonatomic) NSArray<NSString *> *genres;
/// languageCodesISO2A.
@property(readonly, copy, nonatomic) NSArray<NSString *> *languageCodesISO2A;
/// artworkUrl60.
@property(readonly, copy, nonatomic) NSString *artworkUrl60;
/// supportedDevices.
@property(readonly, copy, nonatomic) NSArray<NSString *> *supportedDevices;
/// trackViewUrl.
@property(readonly, copy, nonatomic) NSString *trackViewUrl;
/// description.
@property(readonly, copy, nonatomic) NSString *description;
/// version.
@property(readonly, copy, nonatomic) NSString *version;
/// bundleId.
@property(readonly, copy, nonatomic) NSString *bundleId;
/// artistViewUrl.
@property(readonly, copy, nonatomic) NSString *artistViewUrl;
/// userRatingCountForCurrentVersion.
@property(readonly, nonatomic) NSUInteger userRatingCountForCurrentVersion;
/// releaseDate.
@property(readonly, copy, nonatomic) NSString *releaseDate;
/// appletvScreenshotUrls.
@property(readonly, copy, nonatomic) NSArray<NSString *> *appletvScreenshotUrls;
/// screenshotUrls.
@property(readonly, copy, nonatomic) NSArray<NSString *> *screenshotUrls;
/// isGameCenterEnabled.
@property(readonly, nonatomic) BOOL isGameCenterEnabled;
/// wrapperType.
@property(readonly, copy, nonatomic) NSString *wrapperType;
/// averageUserRatingForCurrentVersion.
@property(readonly, nonatomic) NSUInteger averageUserRatingForCurrentVersion;
/// genreIds.
@property(readonly, copy, nonatomic) NSArray<NSString *> *genreIds;
/// trackId.
@property(readonly, copy, nonatomic) NSString *trackId;
/// minimumOsVersion.
@property(readonly, copy, nonatomic) NSString *minimumOsVersion;
/// formattedPrice.
@property(readonly, copy, nonatomic) NSString *formattedPrice;
/// primaryGenreId.
@property(readonly, copy, nonatomic) NSString *primaryGenreId;
/// currentVersionReleaseDate.
@property(readonly, copy, nonatomic) NSString *currentVersionReleaseDate;
/// trackContentRating.
@property(readonly, copy, nonatomic) NSString *trackContentRating;
/// artistName.
@property(readonly, copy, nonatomic) NSString *artistName;
/// price
@property(readonly, nonatomic) NSDecimalNumber *price;
/// trackCensoredName.
@property(readonly, copy, nonatomic) NSString *trackCensoredName;
/// trackName.
@property(readonly, copy, nonatomic) NSString *trackName;
/// kind.
@property(readonly, copy, nonatomic) NSString *kind;
/// features.
@property(readonly, copy, nonatomic) NSArray<NSString *> *features;
/// releaseNotes.
@property(readonly, copy, nonatomic) NSString *releaseNotes;
/// isVppDeviceBasedLicensingEnabled.
@property(readonly, nonatomic) BOOL isVppDeviceBasedLicensingEnabled;
/// sellerName.
@property(readonly, copy, nonatomic) NSString *sellerName;
#pragma mark - Content rating.
/// Advisories items of content.
@property(readonly, copy, nonatomic) NSString *advisories;
/// Advisory rating of content.
@property(readonly, copy, nonatomic) NSString *contentAdvisoryRating;
@end
| 42.495652 | 82 | 0.772458 |
d60ecbc4e29ccb0919376e4d32d90f27b90bc6c6 | 405 | c | C | src/imop/lib/testcases/mhpTests/test5.c | amannougrahiya/imop-compiler | a0f0c9aaea00c6e5d37a17172c5db2967822ba9b | [
"MIT"
] | 10 | 2020-02-24T20:39:06.000Z | 2021-11-01T03:33:22.000Z | src/imop/lib/testcases/mhpTests/test5.c | anonymousoopsla21/homeostasis | e56c5c2f8392027ad5a49a45d7ac49a139c33674 | [
"MIT"
] | 2 | 2020-02-25T20:30:46.000Z | 2020-07-18T19:05:27.000Z | src/imop/lib/testcases/mhpTests/test5.c | anonymousoopsla21/homeostasis | e56c5c2f8392027ad5a49a45d7ac49a139c33674 | [
"MIT"
] | 2 | 2020-03-11T11:53:47.000Z | 2021-08-23T06:49:57.000Z | void bar();
void foo() {
0;
#pragma omp barrier
1;
#pragma omp barrier
2;
#pragma omp barrier
3;
}
void foobar() {
4;
#pragma omp barrier
5;
#pragma omp barrier
6;
#pragma omp barrier
7;
}
int main() {
#pragma omp parallel
{
8;
switch (9) {
case 1:
10;
bar();
11;
break;
case 2:
13;
foo();
14;
break;
default:
15;
foobar();
16;
break;
}
17;
}
}
| 9.204545 | 20 | 0.538272 |
d0d9bc5ea34d197b641d2cb1c73823f8ed0fb8aa | 1,147 | h | C | usr/libexec/gamed/ACAccount-GameCenter.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | 1 | 2020-11-04T15:43:01.000Z | 2020-11-04T15:43:01.000Z | usr/libexec/gamed/ACAccount-GameCenter.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | usr/libexec/gamed/ACAccount-GameCenter.h | zhangkn/iOS14Header | 4323e9459ed6f6f5504ecbea2710bfd6c3d7c946 | [
"MIT"
] | null | null | null | //
// Generated by classdumpios 1.0.1 (64 bit) (iOS port by DreamDevLost)(Debug version compiled Sep 26 2020 13:48:20).
//
// Copyright (C) 1997-2019 Steve Nygard.
//
#import <Accounts/ACAccount.h>
@interface ACAccount (GameCenter)
- (void)_gkSetProperty:(id)arg1 forKey:(id)arg2 environment:(long long)arg3; // IMP=0x00000001000e7cb0
- (id)_gkPropertyForKey:(id)arg1 environment:(long long)arg2; // IMP=0x00000001000e7c5c
- (id)_gkModifiedDateForProperty:(id)arg1 environment:(long long)arg2; // IMP=0x00000001000e7c08
- (id)_gkCredentialForEnvironment:(long long)arg1; // IMP=0x00000001000e7ad0
- (id)_gkCredentialsForEnvironment:(long long)arg1; // IMP=0x00000001000e74e8
- (id)_gkCredentials; // IMP=0x00000001000e74d8
- (void)_gkSetPlayerInternal:(id)arg1; // IMP=0x00000001000e7430
- (id)_gkPlayerInternal; // IMP=0x00000001000e72b0
- (id)_gkPerEnvironmentTokens; // IMP=0x00000001000e71e0
- (void)_gkSetToken:(id)arg1 forEnvironment:(long long)arg2; // IMP=0x00000001000e6fbc
- (id)_gkTokenForEnvironment:(long long)arg1; // IMP=0x00000001000e6ee8
- (_Bool)_gkIsPrimaryForEnvironment:(long long)arg1; // IMP=0x00000001000e6e80
@end
| 47.791667 | 120 | 0.77245 |
c558930a26db71ca0d9dfec3b64717db0aece070 | 2,137 | h | C | GeneratedModels/MSGraphWindowsInformationProtectionPolicy.h | kvurd/msgraph-sdk-objc-models | 5879f4deccd15092f9877e30541d6bc8351eec4f | [
"MIT"
] | null | null | null | GeneratedModels/MSGraphWindowsInformationProtectionPolicy.h | kvurd/msgraph-sdk-objc-models | 5879f4deccd15092f9877e30541d6bc8351eec4f | [
"MIT"
] | null | null | null | GeneratedModels/MSGraphWindowsInformationProtectionPolicy.h | kvurd/msgraph-sdk-objc-models | 5879f4deccd15092f9877e30541d6bc8351eec4f | [
"MIT"
] | 1 | 2020-11-25T11:05:50.000Z | 2020-11-25T11:05:50.000Z | // Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
#import "MSGraphWindowsInformationProtectionPinCharacterRequirements.h"
#import "MSGraphWindowsInformationProtection.h"
@interface MSGraphWindowsInformationProtectionPolicy : MSGraphWindowsInformationProtection
@property (nonatomic, setter=setRevokeOnMdmHandoffDisabled:, getter=revokeOnMdmHandoffDisabled) BOOL revokeOnMdmHandoffDisabled;
@property (nullable, nonatomic, setter=setMdmEnrollmentUrl:, getter=mdmEnrollmentUrl) NSString* mdmEnrollmentUrl;
@property (nonatomic, setter=setWindowsHelloForBusinessBlocked:, getter=windowsHelloForBusinessBlocked) BOOL windowsHelloForBusinessBlocked;
@property (nonatomic, setter=setPinMinimumLength:, getter=pinMinimumLength) int32_t pinMinimumLength;
@property (nonnull, nonatomic, setter=setPinUppercaseLetters:, getter=pinUppercaseLetters) MSGraphWindowsInformationProtectionPinCharacterRequirements* pinUppercaseLetters;
@property (nonnull, nonatomic, setter=setPinLowercaseLetters:, getter=pinLowercaseLetters) MSGraphWindowsInformationProtectionPinCharacterRequirements* pinLowercaseLetters;
@property (nonnull, nonatomic, setter=setPinSpecialCharacters:, getter=pinSpecialCharacters) MSGraphWindowsInformationProtectionPinCharacterRequirements* pinSpecialCharacters;
@property (nonatomic, setter=setPinExpirationDays:, getter=pinExpirationDays) int32_t pinExpirationDays;
@property (nonatomic, setter=setNumberOfPastPinsRemembered:, getter=numberOfPastPinsRemembered) int32_t numberOfPastPinsRemembered;
@property (nonatomic, setter=setPasswordMaximumAttemptCount:, getter=passwordMaximumAttemptCount) int32_t passwordMaximumAttemptCount;
@property (nonatomic, setter=setMinutesOfInactivityBeforeDeviceLock:, getter=minutesOfInactivityBeforeDeviceLock) int32_t minutesOfInactivityBeforeDeviceLock;
@property (nonatomic, setter=setDaysWithoutContactBeforeUnenroll:, getter=daysWithoutContactBeforeUnenroll) int32_t daysWithoutContactBeforeUnenroll;
@end
| 85.48 | 180 | 0.848386 |
c5c17f64ab510bbae480df6aeb9632b2cc58361f | 1,917 | h | C | components/variations/variations_layers.h | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 14,668 | 2015-01-01T01:57:10.000Z | 2022-03-31T23:33:32.000Z | components/variations/variations_layers.h | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 86 | 2015-10-21T13:02:42.000Z | 2022-03-14T07:50:50.000Z | components/variations/variations_layers.h | zealoussnow/chromium | fd8a8914ca0183f0add65ae55f04e287543c7d4a | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 5,941 | 2015-01-02T11:32:21.000Z | 2022-03-31T16:35:46.000Z | // Copyright 2020 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_VARIATIONS_VARIATIONS_LAYERS_H_
#define COMPONENTS_VARIATIONS_VARIATIONS_LAYERS_H_
#include <map>
#include "base/component_export.h"
#include "base/metrics/field_trial.h"
#include "components/variations/proto/variations_seed.pb.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
namespace variations {
// Parses out the Variations Layers data from the provided seed and
// chooses which member within each layer should be the active one.
class COMPONENT_EXPORT(VARIATIONS) VariationsLayers {
public:
VariationsLayers(
const VariationsSeed& seed,
const base::FieldTrial::EntropyProvider* low_entropy_provider);
VariationsLayers();
~VariationsLayers();
VariationsLayers(const VariationsLayers&) = delete;
VariationsLayers& operator=(const VariationsLayers&) = delete;
// Return whether the given layer has the given member active.
bool IsLayerMemberActive(uint32_t layer_id, uint32_t member_id) const;
// Return whether the layer should use the default entropy source
// (usually the high entropy source).
bool IsLayerUsingDefaultEntropy(uint32_t layer_id) const;
private:
void ConstructLayer(
const base::FieldTrial::EntropyProvider& low_entropy_provider,
const Layer& layer_proto);
struct LayerInfo {
LayerInfo(absl::optional<uint32_t> active_member_id,
Layer::EntropyMode entropy_mode);
~LayerInfo();
LayerInfo(const LayerInfo& other); // = delete;
LayerInfo& operator=(const LayerInfo&) = delete;
absl::optional<uint32_t> active_member_id;
Layer::EntropyMode entropy_mode;
};
std::map<uint32_t, LayerInfo> active_member_for_layer_;
};
} // namespace variations
#endif // COMPONENTS_VARIATIONS_VARIATIONS_LAYERS_H_
| 32.491525 | 73 | 0.76578 |
3012d655977866f79ccb99da994a3fd012ca4401 | 2,226 | c | C | examples/bme680/main/main.c | Dinidrol/esp_libs | 8eb6711b2287c1d1df143296c54e1e6406d951db | [
"MIT"
] | null | null | null | examples/bme680/main/main.c | Dinidrol/esp_libs | 8eb6711b2287c1d1df143296c54e1e6406d951db | [
"MIT"
] | null | null | null | examples/bme680/main/main.c | Dinidrol/esp_libs | 8eb6711b2287c1d1df143296c54e1e6406d951db | [
"MIT"
] | null | null | null | #include <stdio.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <esp_system.h>
#include <bme680.h>
#include <string.h>
#define SDA_GPIO 16
#define SCL_GPIO 17
#define PORT 0
#define ADDR BME680_I2C_ADDR_0
void bme680_test(void *pvParamters)
{
bme680_t sensor;
memset(&sensor, 0, sizeof(bme680_t));
ESP_ERROR_CHECK(bme680_init_desc(&sensor, ADDR, PORT, SDA_GPIO, SCL_GPIO));
// init the sensor
ESP_ERROR_CHECK(bme680_init_sensor(&sensor));
// Changes the oversampling rates to 4x oversampling for temperature
// and 2x oversampling for humidity. Pressure measurement is skipped.
bme680_set_oversampling_rates(&sensor, BME680_OSR_4X, BME680_OSR_NONE, BME680_OSR_2X);
// Change the IIR filter size for temperature and pressure to 7.
bme680_set_filter_size(&sensor, BME680_IIR_SIZE_7);
// Change the heater profile 0 to 200 degree Celcius for 100 ms.
bme680_set_heater_profile(&sensor, 0, 200, 100);
bme680_use_heater_profile(&sensor, 0);
// Set ambient temperature to 10 degree Celsius
bme680_set_ambient_temperature(&sensor, 10);
// as long as sensor configuration isn't changed, duration is constant
uint32_t duration;
bme680_get_measurement_duration(&sensor, &duration);
TickType_t last_wakeup = xTaskGetTickCount();
bme680_values_float_t values;
while (1)
{
// trigger the sensor to start one TPHG measurement cycle
if (bme680_force_measurement(&sensor) == ESP_OK)
{
// passive waiting until measurement results are available
vTaskDelay(duration);
// get the results and do something with them
if (bme680_get_results_float(&sensor, &values))
printf("BME680 Sensor: %.2f °C, %.2f %%, %.2f hPa, %.2f Ohm\n",
values.temperature, values.humidity, values.pressure, values.gas_resistance);
}
// passive waiting until 1 second is over
vTaskDelayUntil(&last_wakeup, 1000 / portTICK_PERIOD_MS);
}
}
void app_main()
{
ESP_ERROR_CHECK(i2cdev_init());
xTaskCreatePinnedToCore(bme680_test, "bme680_test", configMINIMAL_STACK_SIZE * 8, NULL, 5, NULL, APP_CPU_NUM);
}
| 32.735294 | 114 | 0.698562 |
cf236c300042c40c57e51dc14b1ef42e5ea27cc3 | 16,932 | h | C | coreboot/src/vendorcode/amd/agesa/f15tn/Include/OptionMemory.h | leetobin/firebrick | 9109e8025d949357a0320aa2903bbad876593143 | [
"Apache-2.0"
] | 9 | 2015-03-24T12:39:13.000Z | 2021-03-31T20:08:03.000Z | emuboot/src/vendorcode/amd/agesa/f15tn/Include/OptionMemory.h | leetobin/firebrickRemote | e825e194d09752b32db3c8d5a9b8d0e912030df9 | [
"Apache-2.0"
] | null | null | null | emuboot/src/vendorcode/amd/agesa/f15tn/Include/OptionMemory.h | leetobin/firebrickRemote | e825e194d09752b32db3c8d5a9b8d0e912030df9 | [
"Apache-2.0"
] | 3 | 2015-11-23T14:14:18.000Z | 2018-03-14T11:49:00.000Z | /* $NoKeywords:$ */
/**
* @file
*
* AMD Memory option API.
*
* Contains structures and values used to control the Memory option code.
*
* @xrefitem bom "File Content Label" "Release Content"
* @e project: AGESA
* @e sub-project: OPTION
* @e \$Revision: 64574 $ @e \$Date: 2012-01-25 01:01:51 -0600 (Wed, 25 Jan 2012) $
*
*/
/*****************************************************************************
*
* Copyright 2008 - 2012 ADVANCED MICRO DEVICES, INC. All Rights Reserved.
*
* AMD is granting you permission to use this software (the Materials)
* pursuant to the terms and conditions of your Software License Agreement
* with AMD. This header does *NOT* give you permission to use the Materials
* or any rights under AMD's intellectual property. Your use of any portion
* of these Materials shall constitute your acceptance of those terms and
* conditions. If you do not agree to the terms and conditions of the Software
* License Agreement, please do not use any portion of these Materials.
*
* CONFIDENTIALITY: The Materials and all other information, identified as
* confidential and provided to you by AMD shall be kept confidential in
* accordance with the terms and conditions of the Software License Agreement.
*
* LIMITATION OF LIABILITY: THE MATERIALS AND ANY OTHER RELATED INFORMATION
* PROVIDED TO YOU BY AMD ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTY OF ANY KIND, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
* MERCHANTABILITY, NONINFRINGEMENT, TITLE, FITNESS FOR ANY PARTICULAR PURPOSE,
* OR WARRANTIES ARISING FROM CONDUCT, COURSE OF DEALING, OR USAGE OF TRADE.
* IN NO EVENT SHALL AMD OR ITS LICENSORS BE LIABLE FOR ANY DAMAGES WHATSOEVER
* (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS
* INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF AMD'S NEGLIGENCE,
* GROSS NEGLIGENCE, THE USE OF OR INABILITY TO USE THE MATERIALS OR ANY OTHER
* RELATED INFORMATION PROVIDED TO YOU BY AMD, EVEN IF AMD HAS BEEN ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME JURISDICTIONS PROHIBIT THE
* EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES,
* THE ABOVE LIMITATION MAY NOT APPLY TO YOU.
*
* AMD does not assume any responsibility for any errors which may appear in
* the Materials or any other related information provided to you by AMD, or
* result from use of the Materials or any related information.
*
* You agree that you will not reverse engineer or decompile the Materials.
*
* NO SUPPORT OBLIGATION: AMD is not obligated to furnish, support, or make any
* further information, software, technical information, know-how, or show-how
* available to you. Additionally, AMD retains the right to modify the
* Materials at any time, without notice, and is not obligated to provide such
* modified Materials to you.
*
* U.S. GOVERNMENT RESTRICTED RIGHTS: The Materials are provided with
* "RESTRICTED RIGHTS." Use, duplication, or disclosure by the Government is
* subject to the restrictions as set forth in FAR 52.227-14 and
* DFAR252.227-7013, et seq., or its successor. Use of the Materials by the
* Government constitutes acknowledgement of AMD's proprietary rights in them.
*
* EXPORT ASSURANCE: You agree and certify that neither the Materials, nor any
* direct product thereof will be exported directly or indirectly, into any
* country prohibited by the United States Export Administration Act and the
* regulations thereunder, without the required authorization from the U.S.
* government nor will be used for any purpose prohibited by the same.
******************************************************************************
*/
#ifndef _OPTION_MEMORY_H_
#define _OPTION_MEMORY_H_
/* Memory Includes */
#include "mm.h"
#include "mn.h"
#include "mt.h"
#include "ma.h"
#include "mp.h"
/*----------------------------------------------------------------------------------------
* M I X E D (Definitions And Macros / Typedefs, Structures, Enums)
*----------------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------------------
* D E F I N I T I O N S A N D M A C R O S
*----------------------------------------------------------------------------------------
*/
#define MAX_FF_TYPES 6 ///< Maximum number of DDR Form factors (UDIMMs, RDIMMMs, SODIMMS) supported
/*----------------------------------------------------------------------------------------
* T Y P E D E F S, S T R U C T U R E S, E N U M S
*----------------------------------------------------------------------------------------
*/
/*
* STANDARD MEMORY FEATURE FUNCTION POINTER
*/
typedef BOOLEAN OPTION_MEM_FEATURE_NB (
IN OUT MEM_NB_BLOCK *NBPtr
);
typedef BOOLEAN MEM_TECH_FEAT (
IN OUT MEM_TECH_BLOCK *TechPtr
);
typedef UINT8 MEM_TABLE_FEAT (
IN OUT MEM_TABLE_ALIAS **MTPtr
);
#define MEM_FEAT_BLOCK_NB_STRUCT_VERSION 0x01
/**
* MEMORY FEATURE BLOCK - This structure serves as a vector table for standard
* memory feature implementation functions. It contains vectors for all of the
* features that are supported by the various Northbridge devices supported by
* AGESA.
*/
typedef struct _MEM_FEAT_BLOCK_NB {
UINT16 OptMemFeatVersion; ///< Version of memory feature block.
OPTION_MEM_FEATURE_NB *OnlineSpare; ///< Online spare support.
OPTION_MEM_FEATURE_NB *InterleaveBanks; ///< Bank (Chip select) interleaving support.
OPTION_MEM_FEATURE_NB *UndoInterleaveBanks; ///< Undo Bank (Chip Select) interleaving.
OPTION_MEM_FEATURE_NB *CheckInterleaveNodes; ///< Check for Node interleaving support.
OPTION_MEM_FEATURE_NB *InterleaveNodes; ///< Node interleaving support.
OPTION_MEM_FEATURE_NB *InterleaveChannels; ///< Channel interleaving support.
OPTION_MEM_FEATURE_NB *InterleaveRegion; ///< Interleave Region support.
OPTION_MEM_FEATURE_NB *CheckEcc; ///< Check for ECC support.
OPTION_MEM_FEATURE_NB *InitEcc; ///< ECC support.
OPTION_MEM_FEATURE_NB *Training; ///< Choose the type of training (Parallel, standard or hardcoded).
OPTION_MEM_FEATURE_NB *LvDdr3; ///< Low voltage DDR3 dimm support
OPTION_MEM_FEATURE_NB *OnDimmThermal; ///< On-Dimm thermal management
MEM_TECH_FEAT *DramInit; ///< Choose the type of Dram init (hardware based or software based).
OPTION_MEM_FEATURE_NB *ExcludeDIMM; ///< Exclude a dimm.
OPTION_MEM_FEATURE_NB *excel221;
OPTION_MEM_FEATURE_NB *InitCPG; ///< Continuous pattern generation.
OPTION_MEM_FEATURE_NB *InitHwRxEn; ///< Hardware Receiver Enable Training Initilization.
} MEM_FEAT_BLOCK_NB;
typedef AGESA_STATUS MEM_MAIN_FLOW_CONTROL (
IN OUT MEM_MAIN_DATA_BLOCK *MemMainPtr
);
typedef BOOLEAN OPTION_MEM_FEATURE_MAIN (
IN MEM_MAIN_DATA_BLOCK *MMPtr
);
typedef BOOLEAN MEM_NB_CONSTRUCTOR (
IN OUT MEM_NB_BLOCK *NBPtr,
IN OUT MEM_DATA_STRUCT *MemPtr,
IN MEM_FEAT_BLOCK_NB *FeatPtr,
IN MEM_SHARED_DATA *mmSharedPtr, ///< Pointer to Memory scratchpad
IN UINT8 NodeID
);
typedef BOOLEAN MEM_TECH_CONSTRUCTOR (
IN OUT MEM_TECH_BLOCK *TechPtr,
IN OUT MEM_NB_BLOCK *NBPtr
);
typedef VOID MEM_INITIALIZER (
IN OUT MEM_DATA_STRUCT *MemPtr
);
typedef AGESA_STATUS MEM_PLATFORM_CFG (
IN struct _MEM_DATA_STRUCT *MemData,
IN UINT8 SocketID,
IN CH_DEF_STRUCT *CurrentChannel
);
typedef BOOLEAN MEM_IDENDIMM_CONSTRUCTOR (
IN OUT MEM_NB_BLOCK *NBPtr,
IN OUT MEM_DATA_STRUCT *MemPtr,
IN UINT8 NodeID
);
typedef VOID MEM_TECH_TRAINING_FEAT (
IN OUT MEM_TECH_BLOCK *TechPtr,
IN UINT8 Pass
);
typedef BOOLEAN MEM_RESUME_CONSTRUCTOR (
IN OUT VOID *S3NBPtr,
IN OUT MEM_DATA_STRUCT *MemPtr,
IN UINT8 NodeID
);
typedef AGESA_STATUS MEM_PLAT_SPEC_CFG (
IN struct _MEM_DATA_STRUCT *MemData,
IN OUT CH_DEF_STRUCT *CurrentChannel,
IN OUT MEM_PS_BLOCK *PsPtr
);
typedef AGESA_STATUS MEM_FLOW_CFG (
IN OUT MEM_MAIN_DATA_BLOCK *MemData
);
#define MEM_FEAT_BLOCK_MAIN_STRUCT_VERSION 0x01
/**
* MAIN FEATURE BLOCK - This structure serves as vector table for memory features
* that shared between all northbridge devices.
*/
typedef struct _MEM_FEAT_BLOCK_MAIN {
UINT16 OptMemFeatVersion; ///< Version of main feature block.
OPTION_MEM_FEATURE_MAIN *Training; ///< Training features.
OPTION_MEM_FEATURE_MAIN *ExcludeDIMM; ///< Exclude a dimm.
OPTION_MEM_FEATURE_MAIN *OnlineSpare; ///< On-line spare.
OPTION_MEM_FEATURE_MAIN *InterleaveNodes; ///< Node interleave.
OPTION_MEM_FEATURE_MAIN *InitEcc; ///< Initialize ECC on all nodes if they all support it.
OPTION_MEM_FEATURE_MAIN *MemClr; ///< Memory Clear.
OPTION_MEM_FEATURE_MAIN *MemDmi; ///< Memory DMI Support.
OPTION_MEM_FEATURE_MAIN *excel222;
OPTION_MEM_FEATURE_MAIN *LvDDR3; ///< Low voltage DDR3 support.
OPTION_MEM_FEATURE_MAIN *UmaAllocation; ///< Uma Allocation.
OPTION_MEM_FEATURE_MAIN *MemSave; ///< Memory Context Save
OPTION_MEM_FEATURE_MAIN *MemRestore; ///< Memory Context Restore
} MEM_FEAT_BLOCK_MAIN;
#define MEM_NB_SUPPORT_STRUCT_VERSION 0x01
#define MEM_TECH_FEAT_BLOCK_STRUCT_VERSION 0x01
#define MEM_TECH_TRAIN_SEQUENCE_STRUCT_VERSION 0x01
#define MEM_TECH_LRDIMM_STRUCT_VERSION 0x01
/**
* MEMORY TECHNOLOGY FEATURE BLOCK - This structure serves as a vector table for standard
* memory feature implementation functions. It contains vectors for all of the
* features that are supported by the various Technology features supported by
* AGESA.
*/
typedef struct _MEM_TECH_FEAT_BLOCK {
UINT16 OptMemTechFeatVersion; ///< Version of memory Tech feature block.
MEM_TECH_FEAT *EnterHardwareTraining; ///<Enter HW WL Training
MEM_TECH_FEAT *SwWLTraining; ///<SW Write Levelization training
MEM_TECH_FEAT *HwBasedWLTrainingPart1; ///<HW based write levelization Training Part 1
MEM_TECH_FEAT *HwBasedDQSReceiverEnableTrainingPart1; ///<HW based DQS receiver Enabled Training Part 1
MEM_TECH_FEAT *HwBasedWLTrainingPart2; ///<HW based write levelization Training Part 2
MEM_TECH_FEAT *HwBasedDQSReceiverEnableTrainingPart2; ///<HW based DQS receiver Enabled Training Part 2
MEM_TECH_FEAT *TrainExitHwTrn; ///<Exit HW WL Training
MEM_TECH_FEAT *NonOptimizedSWDQSRecEnTrainingPart1; ///< Non-Optimized Software based receiver Enable Training part 1
MEM_TECH_FEAT *OptimizedSwDqsRecEnTrainingPart1; ///< Optimized Software based receiver Enable Training part 1
MEM_TECH_FEAT *NonOptimizedSRdWrPosTraining; ///< Non-Optimized Rd Wr Position training
MEM_TECH_FEAT *OptimizedSRdWrPosTraining; ///< Optimized Rd Wr Position training
MEM_TECH_FEAT *MaxRdLatencyTraining; ///< MaxReadLatency Training
MEM_TECH_FEAT *RdPosTraining; ///< HW Rx En Seed Training
} MEM_TECH_FEAT_BLOCK;
/**
* MEMORY TECHNOLOGY LRDIMM BLOCK - This structure serves as a vector table for standard
* memory feature implementation functions. It contains vectors for all of the
* features that are supported by the various LRDIMM features supported by
* AGESA.
*/
typedef struct _MEM_TECH_LRDIMM {
UINT16 OptMemTechLrdimmVersion; ///< Version of memory Tech feature block.
MEM_TECH_FEAT *MemTInitializeLrdimm; ///< LRDIMM initialization
} MEM_TECH_LRDIMM;
/**
* MEMORY NORTHBRIDGE SUPPORT STRUCT - This structure groups the Northbridge dependent
* options together in a list to provide a single access point for all code to use
* and to ensure that everything corresponding to the same NB type is grouped together.
*
* The Technology Block pointers are not included in this structure because DRAM technology
* needs to be decoupled from the northbridge type.
*
*/
typedef struct _MEM_NB_SUPPORT {
UINT16 MemNBSupportVersion; ///< Version of northbridge support.
MEM_NB_CONSTRUCTOR *MemConstructNBBlock; ///< NorthBridge block constructor.
MEM_INITIALIZER *MemNInitDefaults; ///< Default value initialization for MEM_DATA_STRUCT.
MEM_FEAT_BLOCK_NB *MemFeatBlock; ///< Memory feature block.
MEM_RESUME_CONSTRUCTOR *MemS3ResumeConstructNBBlock; ///< S3 memory initialization northbridge block constructor.
MEM_IDENDIMM_CONSTRUCTOR *MemIdentifyDimmConstruct; ///< Constructor for address to dimm identification.
} MEM_NB_SUPPORT;
/*
* MEMORY Non-Training FEATURES - This structure serves as a vector table for standard
* memory non-training feature implementation functions. It contains vectors for all of the
* features that are supported by the various Technology devices supported by
* AGESA.
*/
/**
* MAIN TRAINING SEQUENCE LIST - This structure serves as vector table for memory features
* that shared between all northbridge devices.
*/
typedef struct _MEM_FEAT_TRAIN_SEQ {
UINT16 OptMemTrainingSequenceListVersion; ///< Version of main feature block.
OPTION_MEM_FEATURE_NB *TrainingSequence; ///< Training Sequence function.
OPTION_MEM_FEATURE_NB *TrainingSequenceEnabled; ///< Enable function.
MEM_TECH_FEAT_BLOCK *MemTechFeatBlock; ///< Memory feature block.
} MEM_FEAT_TRAIN_SEQ;
/**
* PLATFORM SPECIFIC CONFIGURATION BLOCK - This structure groups various PSC table
* entries which are used by PSC engine
*/
typedef struct _MEM_PSC_TABLE_BLOCK {
PSC_TBL_ENTRY **TblEntryOfMaxFreq; ///< Table entry of MaxFreq.
PSC_TBL_ENTRY **TblEntryOfDramTerm; ///< Table entry of Dram Term.
PSC_TBL_ENTRY **TblEntryOfODTPattern; ///< Table entry of ODT Pattern.
PSC_TBL_ENTRY **TblEntryOfSAO; ///< Table entry of Slow access mode, AddrTmg and ODC..
PSC_TBL_ENTRY **TblEntryOfMR0WR; ///< Table entry of MR0[WR].
PSC_TBL_ENTRY **TblEntryOfMR0CL; ///< Table entry of MR0[CL].
PSC_TBL_ENTRY **TblEntryOfRC2IBT; ///< Table entry of RC2 IBT.
PSC_TBL_ENTRY **TblEntryOfRC10OpSpeed; ///< Table entry of RC10[operating speed].
PSC_TBL_ENTRY **TblEntryOfLRIBT;///< Table entry of LRDIMM IBT
PSC_TBL_ENTRY **TblEntryOfLRNPR; ///< Table entry of LRDIMM F0RC13[NumPhysicalRanks].
PSC_TBL_ENTRY **TblEntryOfLRNLR; ///< Table entry of LRDIMM F0RC13[NumLogicalRanks].
PSC_TBL_ENTRY **TblEntryOfGen; ///< Table entry of CLKDis map and CKE, ODT as well as ChipSel tri-state map.
PSC_TBL_ENTRY **excel224;
PSC_TBL_ENTRY **TblEntryOfWLSeed; ///< Table entry of WL seed
PSC_TBL_ENTRY **TblEntryOfHWRxENSeed; ///< Table entry of HW RxEN seed
} MEM_PSC_TABLE_BLOCK;
typedef BOOLEAN MEM_PSC_FLOW (
IN OUT MEM_NB_BLOCK *NBPtr,
IN MEM_PSC_TABLE_BLOCK *EntryOfTables
);
/**
* PLATFORM SPECIFIC CONFIGURATION FLOW BLOCK - Pointers to the sub-engines of platform
* specific configuration.
*/
typedef struct _MEM_PSC_FLOW_BLOCK {
MEM_PSC_TABLE_BLOCK *EntryOfTables; ///<Entry of NB specific MEM_PSC_TABLE_BLOCK
MEM_PSC_FLOW *MaxFrequency; ///< Sub-engine which performs "Max Frequency" value extraction.
MEM_PSC_FLOW *DramTerm; ///< Sub-engine which performs "Dram Term" value extraction.
MEM_PSC_FLOW *ODTPattern; ///< Sub-engine which performs "ODT Pattern" value extraction.
MEM_PSC_FLOW *SAO; ///< Sub-engine which performs "Slow access mode, AddrTmg and ODC" value extraction.
MEM_PSC_FLOW *MR0WrCL; ///< Sub-engine which performs "MR0[WR] and MR0[CL]" value extraction.
MEM_PSC_FLOW *RC2IBT; ///< Sub-engine "RC2 IBT" value extraction.
MEM_PSC_FLOW *RC10OpSpeed; ///< Sub-engine "RC10[operating speed]" value extraction.
MEM_PSC_FLOW *LRIBT; ///< Sub-engine "LRDIMM IBT" value extraction.
MEM_PSC_FLOW *LRNPR; ///< Sub-engine "LRDIMM F0RC13[NumPhysicalRanks]" value extraction.
MEM_PSC_FLOW *LRNLR; ///< Sub-engine "LRDIMM F0RC13[NumLogicalRanks]" value extraction.
MEM_PSC_FLOW *excel225;
MEM_PSC_FLOW *TrainingSeedVal; ///< Sub-engine for WL and HW RxEn pass1 seed value extraction
} MEM_PSC_FLOW_BLOCK;
/*----------------------------------------------------------------------------------------
* F U N C T I O N P R O T O T Y P E
*----------------------------------------------------------------------------------------
*/
/* Feature Default Return */
BOOLEAN MemFDefRet (
IN OUT MEM_NB_BLOCK *NBPtr
);
BOOLEAN MemMDefRet (
IN MEM_MAIN_DATA_BLOCK *MMPtr
);
BOOLEAN MemMDefRetFalse (
IN MEM_MAIN_DATA_BLOCK *MMPtr
);
/* Table Feature Default Return */
UINT8 MemFTableDefRet (
IN OUT MEM_TABLE_ALIAS **MTPtr
);
/* S3 Feature Default Return */
BOOLEAN MemFS3DefConstructorRet (
IN OUT VOID *S3NBPtr,
IN OUT MEM_DATA_STRUCT *MemPtr,
IN UINT8 NodeID
);
BOOLEAN MemNIdentifyDimmConstructorRetDef (
IN OUT MEM_NB_BLOCK *NBPtr,
IN OUT MEM_DATA_STRUCT *MemPtr,
IN UINT8 NodeID
);
BOOLEAN
MemProcessConditionalOverrides (
IN PSO_TABLE *PlatformMemoryConfiguration,
IN OUT MEM_NB_BLOCK *NBPtr,
IN UINT8 PsoAction,
IN UINT8 Dimm
);
#endif // _OPTION_MEMORY_H_
| 43.979221 | 119 | 0.711906 |
680e8478a1de047d402760f621179e16cfb46925 | 812 | h | C | explosivo/Emitter.h | L1quid/Explosivo | b94250ed6ee43ecfda4cfa70ddb366a8990d15d1 | [
"MIT"
] | null | null | null | explosivo/Emitter.h | L1quid/Explosivo | b94250ed6ee43ecfda4cfa70ddb366a8990d15d1 | [
"MIT"
] | null | null | null | explosivo/Emitter.h | L1quid/Explosivo | b94250ed6ee43ecfda4cfa70ddb366a8990d15d1 | [
"MIT"
] | null | null | null | #ifndef _DEMOS_EMITTER_H
#define _DEMOS_EMITTER_H
#include "Streamlet.h"
#include "../wdl/ptrlist.h"
class Emitter
{
public:
Emitter();
virtual ~Emitter();
void reset();
void init_stream();
Streamlet *create_streamlet();
void tick();
bool emit();
void set_window(int w, int h);
WDL_PtrList<Streamlet> *get_streamlets();
void sort_streamlets();
void set_offset(int x, int y) { m_x_offset = x; m_y_offset = y; }
int get_x_offset() const { return(m_x_offset); }
int get_y_offset() const { return(m_y_offset); }
double get_age() const { return(m_age); }
protected:
double m_age;
int m_cx, m_cy, m_win_width, m_win_height, m_x_offset, m_y_offset;
WDL_PtrList<Streamlet> m_streamlets, m_active_streamlets, m_inactive_streamlets, m_sorted_streamlets;
};
#endif // _DEMOS_EMITTER_H | 25.375 | 103 | 0.725369 |
654025e723412373d7e92dd46df334d9f8eb2b80 | 779 | h | C | Source/VAPlugin/Private/VASoundSourceRepresentation.h | VRGroupRWTH/UE4-VirtualAcousticsPlugin | d6db01f7b2550f36cd6515e4fac52006fcc22385 | [
"BSD-3-Clause"
] | null | null | null | Source/VAPlugin/Private/VASoundSourceRepresentation.h | VRGroupRWTH/UE4-VirtualAcousticsPlugin | d6db01f7b2550f36cd6515e4fac52006fcc22385 | [
"BSD-3-Clause"
] | null | null | null | Source/VAPlugin/Private/VASoundSourceRepresentation.h | VRGroupRWTH/UE4-VirtualAcousticsPlugin | d6db01f7b2550f36cd6515e4fac52006fcc22385 | [
"BSD-3-Clause"
] | 1 | 2020-11-27T15:39:12.000Z | 2020-11-27T15:39:12.000Z | // Class for graphical representation of every Sound Source (and Representation)
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Components/SphereComponent.h"
#include "Components/ShapeComponent.h"
#include "VASoundSourceRepresentation.generated.h"
UCLASS()
class VAPLUGIN_API AVASoundSourceRepresentation : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AVASoundSourceRepresentation();
// Setter
void SetPosition(FVector Pos);
void SetRotation(FRotator Rot);
void SetVisibility(bool bVisibility);
protected:
// Called when the game starts or when spawned
void BeginPlay() override;
// Graphical Components
USphereComponent* SphereComponent;
UStaticMeshComponent* SphereMesh;
};
| 21.638889 | 80 | 0.790757 |
247de4acfef8f12602f7bcc5248422fae5ff13ff | 23,836 | h | C | reduceby2_functions.h | chikuzen/ResizeHalf | f1eb302317b2de5f8c1768db989c167c6f785822 | [
"WTFPL"
] | 2 | 2017-03-26T15:25:47.000Z | 2019-05-25T23:05:26.000Z | reduceby2_functions.h | chikuzen/ResizeHalf | f1eb302317b2de5f8c1768db989c167c6f785822 | [
"WTFPL"
] | null | null | null | reduceby2_functions.h | chikuzen/ResizeHalf | f1eb302317b2de5f8c1768db989c167c6f785822 | [
"WTFPL"
] | null | null | null | /*
reduceby2_functions.h
This file is a part of ResizeHalf.
Copyright (c) 2017-2019 OKA Motofumi <chikuzen.mo at gmail dot com>
All Rights Reserved
This program is free software. It comes without any warranty, to
the extent permitted by applicable law. You can redistribute it
and/or modify it under the terms of the Do What the Fuck You Want
to Public License, Version 2, as published by Sam Hocevar. See
http://www.wtfpl.net/ for more details.
*/
#ifndef REDUCE_BY_2_FUNCTIONS_H
#define REDUCE_BY_2_FUNCTIONS_H
#include "rh_common.h"
#if defined(__SSE2__)
// ReduceBy2 helper
#if 1
static F_INLINE __m128i red_by_2(
const __m128i& s0, const __m128i& s1, const __m128i& s2, const __m128i& one)
{
return _mm_avg_epu8(
_mm_avg_epu8(s0, s1), _mm_subs_epu8(_mm_avg_epu8(s2, s1), one));
}
#else
static F_INLINE __m128i red_by_2( // accurate version
const __m128i& s0, const __m128i& s1, const __m128i& s2, const __m128i& one)
{
__m128i t0 = _mm_avg_epu8(s0, s1);
__m128i t1 = _mm_avg_epu8(s2, s1);
__m128i error = _mm_or_si128(_mm_xor_si128(s0, s1), _mm_xor_si128(s2, s1));
__m128i err2 = _mm_xor_si128(t0, t1);
error = _mm_and_si128(_mm_and_si128(error, err2), one);
return _mm_subs_epu8(_mm_avg_epu8(t0, t1), error);
}
#endif
// ReduceBy2 for RGBA
static F_INLINE __m128i red_by_2_h_rgba(
const __m128i& _l, const __m128i& _c, const __m128i& _r, const __m128i& one)
{
__m128i t0 = _mm_shuffle_epi32(_l, _MM_SHUFFLE(3, 1, 2, 0));
__m128i t1 = _mm_shuffle_epi32(_c, _MM_SHUFFLE(3, 1, 2, 0));
__m128i l = _mm_unpacklo_epi64(t0, t1);
__m128i c = _mm_unpackhi_epi64(t0, t1);
#if defined(__SSSE3__)
__m128i r = _mm_alignr_epi8(_r, l, 4);
#else
__m128i r = _mm_or_si128(_mm_srli_si128(l, 4), _mm_slli_si128(_r, 12));
#endif
return red_by_2(l, c, r, one);
}
template <bool ALIGNED>
static void reduceby2_hv_rgba(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
const __m128i one = _mm_set1_epi8(1);
for (size_t y = 0; y < height - 2; y += 2) {
auto sb = srcp + sstride;
auto sc = sb + sstride;
__m128i left = red_by_2(
load<ALIGNED>(srcp), load<ALIGNED>(sb), load<ALIGNED>(sc), one);
for (size_t x = 0; x < width - 2; x += 8) {
__m128i center = red_by_2(
load<ALIGNED>(srcp + 4 * x + 16), load<ALIGNED>(sb + 4 * x + 16),
load<ALIGNED>(sc + 4 * x + 16), one);
__m128i right = red_by_2(
load<ALIGNED>(srcp + 4 * x + 32), load<ALIGNED>(sb + 4 * x + 32),
load<ALIGNED>(sc + 4 * x + 32), one);
center = red_by_2_h_rgba(left, center, right, one);
stream(dstp + 2 * x, center);
left = right;
}
if ((width & 1) == 0) {
auto d = reinterpret_cast<RGBA*>(dstp) + width / 2 - 1;
auto s0 = reinterpret_cast<const RGBA*>(srcp) + width - 2;
auto s1 = reinterpret_cast<const RGBA*>(sb) + width - 2;
auto s2 = reinterpret_cast<const RGBA*>(sc) + width - 2;
*d = (
RGBAi(s0[0], 1) + RGBAi(s0[1], 3) +
RGBAi(s1[0], 2) + RGBAi(s1[1], 6) +
RGBAi(s2[0], 1) + RGBAi(s2[1], 3)).div16<RGBA>();
}
srcp += 2 * sstride;
dstp += dstride;
}
if ((height & 1) == 0) {
auto d = reinterpret_cast<RGBA*>(dstp);
auto sa = reinterpret_cast<const RGBA*>(srcp);
auto sb = reinterpret_cast<const RGBA*>(srcp + sstride);
for (size_t x = 0; x < width - 2; x += 2) {
d[x / 2] = (
RGBAi(sa[x], 1) + RGBAi(sa[x + 1], 2) + RGBAi(sa[x + 2], 1) +
RGBAi(sb[x], 3) + RGBAi(sb[x + 1], 6) + RGBAi(sb[x + 2], 3)
).div16<RGBA>();
}
if ((width & 1) == 0) {
d[width / 2 - 1] = (
RGBAi(sa[width - 2], 1) + RGBAi(sa[width - 1], 3) +
RGBAi(sb[width - 2], 3) + RGBAi(sb[width - 1], 9)).div16<RGBA>();
}
}
}
template <bool ALIGNED>
static void reduceby2_h_rgba(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
const __m128i one = _mm_set1_epi8(1);
for (size_t y = 0; y < height; ++y) {
__m128i s0 = load<ALIGNED>(srcp);
for (size_t x = 0; x < width - 2; x += 8) {
__m128i s1 = load<ALIGNED>(srcp + 4 * x + 16);
__m128i s2 = load<ALIGNED>(srcp + 4 * x + 32);
__m128i ret = red_by_2_h_rgba(s0, s1, s2, one);
stream(dstp + 2 * x, ret);
s0 = s2;
}
if ((width & 1) == 0) {
auto d = reinterpret_cast<RGBA*>(dstp) + width / 2 - 1;
auto s = reinterpret_cast<const RGBA*>(srcp) + width - 2;
*d = (RGBAi(s[0], 1) + RGBAi(s[1], 3)).div4<RGBA>();
}
srcp += sstride;
dstp += dstride;
}
}
template <bool ALIGNED>
static void reduceby2_v_rgba(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
const __m128i one = _mm_set1_epi8(1);
for (size_t y = 0; y < height - 2; y += 2) {
for (size_t x = 0; x < width; x += 4) {
__m128i ret = red_by_2(
load<ALIGNED>(srcp + 4 * x),
load<ALIGNED>(srcp + 4 * x + sstride),
load<ALIGNED>(srcp + 4 * x + sstride * 2), one);
stream(dstp + 4 * x, ret);
}
srcp += 2 * sstride;
dstp += dstride;
}
if ((height & 1) == 0) {
for (size_t x = 0; x < width; x += 4) {
__m128i s0 = load<ALIGNED>(srcp + 4 * x);
__m128i s1 = load<ALIGNED>(srcp + 4 * x + sstride);
s1 = red_by_2(s0, s1, s1, one);
stream(dstp + 4 * x, s1);
}
}
}
// ReduceBy2 for GREY8
static F_INLINE __m128i red_by_2_h_grey(
const __m128i& l0, const __m128i& l1, const __m128i& l2, const __m128i& mask,
const __m128i& one)
{
__m128i l = _mm_packus_epi16(_mm_and_si128(l0, mask), _mm_and_si128(l1, mask));
__m128i m = _mm_packus_epi16(_mm_srli_epi16(l0, 8), _mm_srli_epi16(l1, 8));
#if defined(__SSSE3__)
__m128i r = _mm_alignr_epi8(l2, l, 1);
#else
__m128i r = _mm_or_si128(_mm_srli_si128(l, 1), _mm_slli_si128(l2, 15));
#endif
return red_by_2(l, m , r, one);
}
template <bool ALIGNED>
static void reduceby2_hv_grey(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
const __m128i one = _mm_set1_epi8(1);
const __m128i mask = _mm_set1_epi16(0x00FF);
for (size_t y = 0; y < height - 2; y += 2) {
auto sb = srcp + sstride;
auto sc = sb + sstride;
__m128i left = red_by_2(
load<ALIGNED>(srcp), load<ALIGNED>(sb), load<ALIGNED>(sc), one);
for (size_t x = 0; x < width - 2; x += 32) {
__m128i center = red_by_2(
load<ALIGNED>(srcp + x + 16), load<ALIGNED>(sb + x + 16),
load<ALIGNED>(sc + x + 16), one);
__m128i right = red_by_2(
load<ALIGNED>(srcp + x + 32), load<ALIGNED>(sb + x + 32),
load<ALIGNED>(sc + x + 32), one);
center = red_by_2_h_grey(left, center, right, mask, one);
stream(dstp + x / 2, center);
left = right;
}
if ((width & 1) == 0) {
auto w2 = width - 2;
auto w1 = width - 1;
dstp[width / 2 - 1] = (
srcp[w2] + 3 * srcp[w1] +
2 * sb[w2] + 6 * sb[w1] +
sc[w2] + 3 * sc[w1] + 8) / 16;
}
srcp += 2 * sstride;
dstp += dstride;
}
if ((height & 1) == 0) {
auto sb = srcp + sstride;
__m128i s0 = load<ALIGNED>(srcp);
__m128i s1 = load<ALIGNED>(sb);
__m128i left = red_by_2(s0, s1, s1, one);
for (size_t x = 0; x < width; x += 32) {
s0 = load<ALIGNED>(srcp + x + 16);
s1 = load<ALIGNED>(sb + x + 16);
__m128i center = red_by_2(s0, s1, s1, one);
s0 = load<ALIGNED>(srcp + x + 32);
s1 = load<ALIGNED>(sb + x + 32);
__m128i right = red_by_2(s0, s1, s1, one);
center = red_by_2_h_grey(left, center, right, mask, one);
stream(dstp + x / 2, center);
left = right;
}
if ((width & 1) == 0) {
dstp[width / 2 - 1] = (
srcp[width - 2] + srcp[width - 1] * 3 +
sb[width - 2] * 3 + sb[width - 1] * 9 + 8) / 16;
}
}
}
template <bool ALIGNED>
static void reduceby2_h_grey(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
const __m128i one = _mm_set1_epi8(1);
const __m128i mask = _mm_set1_epi16(0x00FF);
for (size_t y = 0; y < height; ++y) {
__m128i left = load<ALIGNED>(srcp);
for (size_t x = 0; x < width - 2; x += 32) {
__m128i center = load<ALIGNED>(srcp + x + 16);
__m128i right = load<ALIGNED>(srcp + x + 32);
center = red_by_2_h_grey(left, center, right, mask, one);
stream(dstp + x / 2, center);
left = center;
}
if ((width & 1) == 0) {
dstp[width / 2 - 1] = (
srcp[width - 2] + srcp[width - 1] * 3 + 2) / 4;
}
srcp += sstride;
dstp += dstride;
}
}
template <bool ALIGNED>
static void reduceby2_v_grey(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
const __m128i one = _mm_set1_epi8(1);
for (size_t y = 0; y < height - 2; y += 2) {
for (size_t x = 0; x < width; x += 16) {
__m128i ret = red_by_2(
load<ALIGNED>(srcp + x),
load<ALIGNED>(srcp + x + sstride),
load<ALIGNED>(srcp + x + 2 * sstride), one);
stream(dstp + x, ret);
}
srcp += 2 * sstride;
dstp += dstride;
}
if ((height & 1) == 0) {
for (size_t x = 0; x < width; x += 16) {
__m128i s0 = load<ALIGNED>(srcp + x);
__m128i s1 = load<ALIGNED>(srcp + x + sstride);
__m128i ret = red_by_2(s0, s1, s1, one);
stream(dstp + x, ret);
}
}
}
// ReduceBy2 for RGB888
#if defined(__SSSE3__)
static void reduceby2_hv_rgb888(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
const __m128i one = _mm_set1_epi8(1);
const __m128i smask0 = _mm_setr_epi8(
0, 1, 2, -1, 3, 4, 5, -1, 6, 7, 8, -1, 9, 10, 11, -1);
const __m128i smask1 = _mm_setr_epi8(
0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, -1, -1, -1, -1);
for (size_t y = 0; y < height - 2; y += 2) {
auto sb = srcp + sstride;
auto sc = sb + sstride;
__m128i left = _mm_shuffle_epi8(
red_by_2(load<false>(srcp),
load<false>(sb),
load<false>(sc), one), smask0);
for (size_t x = 0; x < width - 2; x += 8) {
__m128i center = _mm_shuffle_epi8(
red_by_2(load<false>(srcp + 3 * x + 12),
load<false>(sb + 3 * x + 12),
load<false>(sc + 3 * x + 12), one), smask0);
__m128i right = _mm_shuffle_epi8(
red_by_2(load<false>(srcp + 3 * x + 24),
load<false>(sb + 3 * x + 24),
load<false>(sc + 3 * x + 24), one), smask0);
center = _mm_shuffle_epi8(
red_by_2_h_rgba(left, center, right, one), smask1);
storeu(dstp + 3 * x / 2, center);
left = right;
}
if ((width & 1) == 0) {
auto d = reinterpret_cast<RGB24*>(dstp) + width / 2 - 1;
auto s0 = reinterpret_cast<const RGB24*>(srcp) + width - 2;
auto s1 = reinterpret_cast<const RGB24*>(sb) + width - 2;
auto s2 = reinterpret_cast<const RGB24*>(sc) + width - 2;
*d = (
RGBAi(s0[0], 1) + RGBAi(s0[1], 3) +
RGBAi(s1[0], 2) + RGBAi(s1[1], 6) +
RGBAi(s2[0], 1) + RGBAi(s2[1], 3)).div16<RGB24>();
}
srcp += 2 * sstride;
dstp += dstride;
}
if ((height & 1) == 0) {
auto sb = srcp + sstride;
__m128i s0 = load<false>(srcp);
__m128i s1 = load<false>(sb);
__m128i left = red_by_2(s0, s1, s1, one);
for (size_t x = 0; x < width - 2; x += 8) {
s0 = load<false>(srcp + 3 * x + 12);
s1 = load<false>(sb + 3 * x + 12);
__m128i center = red_by_2(s0, s1, s1, one);
s0 = load<false>(srcp + 3 * x + 32);
s1 = load<false>(sb + 3 * x + 32);
__m128i right = red_by_2(s0, s1, s1, one);
center = _mm_shuffle_epi8(
red_by_2_h_rgba(left, center, right, one), smask1);
storeu(dstp + 3 * x / 2, center);
left = right;
}
if ((width & 1) == 0) {
auto d = reinterpret_cast<RGB24*>(dstp) + width / 2 - 1;
auto sc = reinterpret_cast<const RGB24*>(srcp) + width - 2;
auto sd = reinterpret_cast<const RGB24*>(srcp + sstride) + width - 2;
*d = (
RGBAi(sc[0], 1) + RGBAi(sc[1], 3) +
RGBAi(sd[0], 3) + RGBAi(sd[1], 9)).div16<RGB24>();
}
}
}
static void reduceby2_h_rgb888(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
const __m128i one = _mm_set1_epi8(1);
const __m128i smask0 = _mm_setr_epi8(
0, 1, 2, -1, 3, 4, 5, -1, 6, 7, 8, -1, 9, 10, 11, -1);
const __m128i smask1 = _mm_setr_epi8(
0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, -1, -1, -1, -1);
for (size_t y = 0; y < height; ++y) {
__m128i s0 = _mm_shuffle_epi8(load<false>(srcp), smask0);
for (size_t x = 0; x < width - 2; x += 8) {
__m128i s1 = _mm_shuffle_epi8(load<false>(srcp + 3 * x + 12), smask0);
__m128i s2 = _mm_shuffle_epi8(load<false>(srcp + 3 * x + 24), smask0);
__m128i ret = _mm_shuffle_epi8(red_by_2_h_rgba(s0, s1, s2, one), smask1);
storeu(dstp + 3 * x / 2, ret);
s0 = s2;
}
if ((width & 1) == 0) {
auto d = reinterpret_cast<RGB24*>(dstp) + width / 2 - 1;
auto s = reinterpret_cast<const RGB24*>(srcp) + width - 2;
*d = (RGBAi(s[0]) + RGBAi(s[1], 3)).div4<RGB24>();
}
srcp += sstride;
dstp += dstride;
}
}
#endif // __SSSE3__
static void reduceby2_v_rgb888(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
reduceby2_v_grey<false>(srcp, dstp, width * 3, height, sstride, dstride);
}
#endif // __SSE2__
// ReduceBy2 for RGBA (no SIMD)
static void reduceby2_hv_rgba_c(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
for (size_t y = 0; y < height - 2; y += 2) {
auto sa = reinterpret_cast<const RGBA*>(srcp);
auto sb = reinterpret_cast<const RGBA*>(srcp + sstride);
auto sc = reinterpret_cast<const RGBA*>(srcp + 2 * sstride);
auto d = reinterpret_cast<RGBA*>(dstp);
for (size_t x = 0; x < width - 2; x += 2) {
d[x / 2] = (
RGBAi(sa[x], 1) + RGBAi(sa[x + 1], 2) + RGBAi(sa[x + 2], 1) +
RGBAi(sb[x], 2) + RGBAi(sb[x + 1], 4) + RGBAi(sb[x + 2], 2) +
RGBAi(sc[x], 1) + RGBAi(sc[x + 1], 2) + RGBAi(sc[x + 2], 1)
).div16<RGBA>();
}
if ((width & 1) == 0) {
d[width / 2 - 1] = (
RGBAi(sa[width - 2], 1) + RGBAi(sa[width - 1], 3) +
RGBAi(sb[width - 2], 2) + RGBAi(sb[width - 1], 6) +
RGBAi(sc[width - 2], 1) + RGBAi(sc[width - 1], 3)).div16<RGBA>();
}
srcp += 2 * sstride;
dstp += dstride;
}
if ((height & 1) == 0) {
auto sa = reinterpret_cast<const RGBA*>(srcp);
auto sb = reinterpret_cast<const RGBA*>(srcp + sstride);
auto d = reinterpret_cast<RGBA*>(dstp);
for (size_t x = 0; x < width - 2; x += 2) {
d[x / 2] = (
RGBAi(sa[x], 1) + RGBAi(sa[x + 1], 2) + RGBAi(sa[x + 2], 1) +
RGBAi(sb[x], 3) + RGBAi(sb[x + 1], 6) + RGBAi(sb[x + 2], 3)
).div16<RGBA>();
}
if ((width & 1) == 0) {
d[width / 2 - 1] = (
RGBAi(sa[width - 2], 1) + RGBAi(sa[width - 1], 3) +
RGBAi(sb[width - 2], 3) + RGBAi(sb[width - 1], 9)).div16<RGBA>();
}
}
}
static void reduceby2_h_rgba_c(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
for (size_t y = 0; y < height; ++y) {
auto s = reinterpret_cast<const RGBA*>(srcp);
auto d = reinterpret_cast<RGBA*>(dstp);
for (size_t x = 0; x < width - 2; x += 2) {
d[x / 2] = (
RGBAi(s[x], 1) + RGBAi(s[x + 1], 2) + RGBAi(s[x + 2], 1)
).div4<RGBA>();
}
if ((width & 1) == 0) {
d[width / 2 - 1] = (
RGBAi(s[width - 2], 1) + RGBAi(s[width - 1], 3)).div4<RGBA>();
}
srcp += sstride;
dstp += dstride;
}
}
static void reduceby2_v_rgba_c(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
auto s = reinterpret_cast<const RGBA*>(srcp);
auto d = reinterpret_cast<RGBA*>(dstp);
auto ss = sstride / sizeof(RGBA);
auto ds = dstride / sizeof(RGBA);
for (size_t y = 0; y < height - 2; y += 2) {
auto sb = s + ss;
auto sc = sb + ss;
for (size_t x = 0; x < width; ++x) {
d[x] = (
RGBAi(s[x], 1) + RGBAi(sb[x], 2) + RGBAi(sc[x], 1)).div4<RGBA>();
}
s += 2 * ss;
d += ds;
}
if ((height & 1) == 0) {
auto sb = s + ss;
for (size_t x = 0; x < width; ++x) {
d[x] = (RGBAi(s[x], 1) + RGBAi(sb[x], 3)).div4<RGBA>();
}
}
}
// ReduceBy2 for GREY8 (no SIMD)
static void reduceby2_hv_grey_c(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
for (size_t y = 0; y < height - 2; y += 2) {
auto sb = srcp + sstride;
auto sc = sb + sstride;
for (size_t x = 0; x < width - 2; x += 2) {
dstp[x / 2] = (srcp[x] + 2 * srcp[x + 1] + srcp[x + 2]
+ 2 * sb[x] + 4 * sb[x + 1] + 2 * sb[x + 2]
+ sc[x] + 2 * sc[x + 1] + sc[x + 2] + 8) / 16;
}
if ((width & 1) == 0) {
dstp[width / 2 - 1] = (srcp[width - 2] + srcp[width - 1] * 3
+ 2 * sb[width - 2] + 6 * sb[width - 1] + sc[width - 2]
+ sc[width - 1] + 8) / 16;
}
srcp += 2 * sstride;
dstp += dstride;
}
}
static void reduceby2_h_grey_c(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
for (size_t y = 0; y < height; ++y) {
for (size_t x = 0; x < width - 2; x += 2) {
dstp[x / 2] = (srcp[x] + 2 * srcp[x + 1] + srcp[x + 2] + 2) / 4;
}
if ((width & 1) == 0) {
dstp[width / 2 - 1] = (srcp[width - 2] + srcp[width - 1] * 3 + 2) / 4;
}
srcp += sstride;
dstp += dstride;
}
}
static void reduceby2_v_grey_c(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
for (size_t y = 0; y < height - 2; y += 2) {
for (size_t x = 0; x < width; ++x) {
dstp[x] = (
srcp[x] + 2 * srcp[x + sstride] + srcp[x + 2 * sstride] + 2) / 4;
}
srcp += 2 * sstride;
dstp += dstride;
}
if ((height & 1) == 0) {
for (size_t x = 0; x < width; ++x) {
dstp[x] = (srcp[x] + 3 * srcp[x + sstride] + 2) / 4;
}
}
}
// ReduceBy2 for RGB888 (no SIMD)
static void reduceby2_hv_rgb888_c(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
for (size_t y = 0; y < height - 2; y += 2) {
auto sa = reinterpret_cast<const RGB24*>(srcp);
auto sb = reinterpret_cast<const RGB24*>(srcp + sstride);
auto sc = reinterpret_cast<const RGB24*>(srcp + 2 * sstride);
auto d = reinterpret_cast<RGB24*>(dstp);
for (size_t x = 0; x < width - 2; x += 2) {
d[x / 2] = (
RGBAi(sa[x], 1) + RGBAi(sa[x + 1], 2) + RGBAi(sa[x + 2], 1) +
RGBAi(sb[x], 2) + RGBAi(sb[x + 1], 4) + RGBAi(sb[x + 2], 2) +
RGBAi(sc[x], 1) + RGBAi(sc[x + 1], 2) + RGBAi(sc[x + 2], 1)
).div16<RGB24>();
}
if ((width & 1) == 0) {
auto w2 = width - 2;
auto w1 = width - 1;
d[width / 2 - 1] = (
RGBAi(sa[w2], 1) + RGBAi(sa[w1], 3) +
RGBAi(sb[w2], 2) + RGBAi(sb[w1], 6) +
RGBAi(sc[w2], 1) + RGBAi(sc[w1], 3)).div16<RGB24>();
}
srcp += 2 * sstride;
dstp += dstride;
}
if ((height & 1) == 0) {
auto sa = reinterpret_cast<const RGB24*>(srcp);
auto sb = reinterpret_cast<const RGB24*>(srcp + sstride);
auto d = reinterpret_cast<RGB24*>(dstp);
for (size_t x = 0; x < width - 2; x += 2) {
d[x / 2] = (
RGBAi(sa[x], 1) + RGBAi(sa[x + 1], 2) + RGBAi(sa[x + 2], 1) +
RGBAi(sb[x], 3) + RGBAi(sb[x + 1], 6) + RGBAi(sb[x + 2], 3)
).div16<RGB24>();
}
if ((width & 1) == 0) {
auto w2 = width - 2;
auto w1 = width - 1;
d[width / 2 - 1] = (
RGBAi(sa[w2], 1) + RGBAi(sa[w1], 3) +
RGBAi(sb[w2], 3) + RGBAi(sb[w1], 9)).div16<RGB24>();
}
}
}
static void reduceby2_h_rgb888_c(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
for (size_t y = 0; y < height; ++y) {
auto s = reinterpret_cast<const RGB24*>(srcp);
auto d = reinterpret_cast<RGB24*>(dstp);
for (size_t x = 0; x < width - 2; x += 2) {
d[x / 2] = (
RGBAi(s[x], 1) + RGBAi(s[x + 1], 2) + RGBAi(s[x + 2], 1)
).div4<RGB24>();
}
if ((width & 1) == 0) {
d[width / 2 - 1] = (
RGBAi(s[width - 2], 1) + RGBAi(s[width - 1], 3)).div4<RGB24>();
}
srcp += sstride;
dstp += dstride;
}
}
static void reduceby2_v_rgb888_c(
const uint8_t* srcp, uint8_t* dstp, const size_t width, const size_t height,
const size_t sstride, const size_t dstride) noexcept
{
reduceby2_v_grey_c(srcp, dstp, width * 3, height, sstride, dstride);
}
#endif // REDUCE_BY_2_FUNCTIONS_H
| 34.79708 | 85 | 0.506922 |
f2b22767b7c71081b5b46d94c2cb1c41d9a4f622 | 2,765 | c | C | src/sbmf/global_state.c | AntonJohansson/sbmf | 8856068236987081fe20814ab565456b7f92b822 | [
"MIT"
] | null | null | null | src/sbmf/global_state.c | AntonJohansson/sbmf | 8856068236987081fe20814ab565456b7f92b822 | [
"MIT"
] | null | null | null | src/sbmf/global_state.c | AntonJohansson/sbmf | 8856068236987081fe20814ab565456b7f92b822 | [
"MIT"
] | null | null | null | static u32 thread_storage_size = 96*1024*1024;
struct thread_local_storage {
struct stack_allocator* stack;
};
static struct {
bool initialized;
struct thread_local_storage* thread_storage;
u32 thread_count;
struct timespec start_time;
sbmf_log_callback_func* log_callback;
} _state;
static void interrupt_handler(int dummy) {
SBMF_UNUSED(dummy);
sbmf_shutdown();
exit(1);
}
void sbmf_set_thread_storage_size(u32 size) {
thread_storage_size = size;
}
void sbmf_init() {
if (_state.initialized) {
sbmf_log_error("sbmf_init(): Already intialized!");
return;
}
srand(time(NULL));
sbmf_log_info("Initializing");
signal(SIGINT, interrupt_handler);
signal(SIGABRT, interrupt_handler);
/* Setup thread local storage */
{
_state.thread_count = (u32)omp_get_max_threads();
sbmf_log_info("\t- OpenMP using %u threads", _state.thread_count);
_state.thread_storage = xmalloc(_state.thread_count*sizeof(struct thread_local_storage));
for (u32 i = 0; i < _state.thread_count; ++i) {
_state.thread_storage[i].stack = sa_make(thread_storage_size);
}
}
_state.initialized = true;
}
void sbmf_shutdown() {
if (!_state.initialized) {
sbmf_log_error("sbmf_shutdown(): Not initialized!");
return;
}
sbmf_log_info("Shutting down");
for (u32 i = 0; i < _state.thread_count; ++i) {
sa_destroy(_state.thread_storage[i].stack);
}
_state.initialized = false;
}
#define sbmf_stack_push(size_in_bytes) \
sbmf_stack_push_impl(size_in_bytes, __LINE__, __FILE__, __func__)
void* sbmf_stack_push_impl(u32 size_in_bytes, const u32 linenumber, const char file[], const char func[]) {
u32 threadid = (u32)omp_get_thread_num();
assert(threadid < _state.thread_count);
SBMF_UNUSED(linenumber);
SBMF_UNUSED(file);
SBMF_UNUSED(func);
/* Dump memory usage after allocating */
//if (_state.memory_sbmf_log_fd) {
// f64 elapsed = elapsed_time();
// fprintf(_state.memory_sbmf_log_fd, "%lf\t%u\t%u\t[%s:%d in %s()]\n",
// elapsed,
// _state.thread_storage[threadid].stack->top,
// _state.thread_storage[threadid].stack->size,
// file, linenumber, func);
//}
u8* ptr = sa_push(_state.thread_storage[threadid].stack, size_in_bytes);
return (void*)ptr;
}
u32 sbmf_stack_marker() {
u32 threadid = (u32)omp_get_thread_num();
return _state.thread_storage[threadid].stack->top;
}
void sbmf_stack_free_to_marker(u32 marker) {
u32 threadid = (u32)omp_get_thread_num();
_state.thread_storage[threadid].stack->top = marker;
/* Dump memory usage after freeing */
//if (_state.memory_sbmf_log_fd) {
// f64 elapsed = elapsed_time();
// fprintf(_state.memory_sbmf_log_fd, "%lf\t%u\t%u\n",
// elapsed,
// _state.thread_storage[threadid].stack->top,
// _state.thread_storage[threadid].stack->size);
//}
}
| 24.043478 | 107 | 0.726221 |
6207cd2954301b530d6e051f035c078a07a21bc8 | 485 | h | C | Engine/Event/Event.h | mariofv/LittleEngine | 38ecfdf6041a24f304c679ee3b6b589ba2040e48 | [
"MIT"
] | 9 | 2020-04-05T07:44:38.000Z | 2022-01-12T02:07:14.000Z | Engine/Event/Event.h | mariofv/LittleEngine | 38ecfdf6041a24f304c679ee3b6b589ba2040e48 | [
"MIT"
] | 105 | 2020-03-13T19:12:23.000Z | 2020-12-02T23:41:15.000Z | Engine/Event/Event.h | mariofv/LittleEngine | 38ecfdf6041a24f304c679ee3b6b589ba2040e48 | [
"MIT"
] | 1 | 2021-04-24T16:11:49.000Z | 2021-04-24T16:11:49.000Z | #ifndef _EVENT_H_
#define _EVENT_H_
#include "Component/ComponentCollider.h"
#include "Main/GameObject.h"
class Event
{
public:
Event(GameObject* emitter) : emitter(emitter) {}
virtual ~Event() {};
public:
GameObject* emitter = nullptr;
};
class CollisionEvent : public Event {
public:
CollisionEvent(GameObject* emitter, std::vector<CollisionInformation> collisions) : Event(emitter), collisions(collisions) {}
public:
std::vector<CollisionInformation> collisions;
};
#endif
| 20.208333 | 126 | 0.758763 |
00685222ae98affeb30fa241b224f1c3f81cbbaa | 6,544 | c | C | Linear Equations/MENU/matriz22.c | abrahamMS18/Solution-of-linear-equations-with-C | f2e4a4da7247b415a88df0b295217a82b548f0e7 | [
"MIT"
] | null | null | null | Linear Equations/MENU/matriz22.c | abrahamMS18/Solution-of-linear-equations-with-C | f2e4a4da7247b415a88df0b295217a82b548f0e7 | [
"MIT"
] | null | null | null | Linear Equations/MENU/matriz22.c | abrahamMS18/Solution-of-linear-equations-with-C | f2e4a4da7247b415a88df0b295217a82b548f0e7 | [
"MIT"
] | null | null | null | /*
Creado por: Carlos Abraham Mora Hernandez
Fecha: 01/08/20
Compilador: Mingw GCC (Compilado en entorno Linux y MacOS)
Lenguaje: C
Version: 1.0
Contenido: Funcion que realiza Gauss-Jordan con una matriz de 2x2 con base a esta estructura:
En forma de ecuación:
Ax + By = C
Dx + Ey = F
En forma matricial:
| A B | C |
| D E | F |
Para Gauss-Jordan hay varias vartientes:
Sistema Linealmente Dependiente
Sistema Linealmente Independiente
Sistema sin solucion
Estas vertientes las contempla el programa
La solucion directa directa para X y Y, sin que haya una restriccion de por medio, es la siguiente:
y = (C*D - F*A)/(B*D - E*A)
x = ( (B*(C*D - F*A)) - (C*(B*D - E*A)) ) / (-A*(B*D - E*A))
NOTA: El programa no contempla uso de numeros con punto flotante a la hora de ingresar los datos, de igual manera de que no hay exepciones si se inserta una letra
POR LO QUE NO INGRESE NUMEROS CON PUNTO FLOTANTE (6.66) O LETRAS (X, Y, U, ETC).
*/
int mat[2][3]; //Matriz
int i, j; //Iteradores
float A, B, C, D, E, F;
float x, y;
/* Llamado de funciones */
void mostrar_matriz();
void ingresar_datos();
int resultado();
void asignacion_letras();
int iteracion_1();
void matriz_22(){
/*
Nombre: matriz_22
Funcion: Funcion principal que mandara a llamar a todas para la resolucion de gauss-jordan 2x2
Envía: --
Recibe: --
*/
int exito;
printf("Selecciono la matriz de 2x2\n");
mostrar_matriz();
ingresar_datos();
exito = resultado();
//printf("Exito es igual a ->%d<-", exito);
switch (exito){
case 0:
if(A == 0 && E == 0){
printf("Sistema resuelto\n\nX = %.3f\nY = %.3f", F/D, C/B);
} else{
y = (C*D - F*A)/(B*D - E*A);
x = ( (B*(C*D - F*A)) - (C*(B*D - E*A)) ) / (-A*(B*D - E*A));
printf("Sistema resuelto\n\nX = %.3f\nY = %.3f", x, y);
}
break;
case 1: printf("Sistema inconsistente o No tiene solucion\n\n");
mostrar_matriz();
break;
case 2: printf("El sistema es linealmente dependiente\n\n");
if(B <= 0){
printf("X = %.3f(%.3f - %.3fw)\n", 1/A, C, B*-1);
} else{
printf("X = %.3f(%.3f - %.3fw)\n", 1/A, C, B);
}
printf("Y = w pertenece a los numeros Reales\n\n");
break;
}
}
void mostrar_matriz(){
/*
Nombre: mostrar_matriz
Funcion: Muestra la matriz inicial con valores cero
Envia: --
Recibe: --
*/
for(i=0;i<2;i++){
printf("\n");
for(j=0;j<3;j++){
printf("%3d", mat[i][j]);
}
}
printf("\n\n");
}
void ingresar_datos(){
/*
Nombre: ingresar_datos
Funcion: El usuario ingresa el valor de 'x', 'y' y valor contasnte de las dos ecuaciones
Envia: --
Recibe: --
*/
printf("El sistema de ecuaciones es de la forma: \n\n");
printf("1) Ax + By = C\n");
printf("2) Dx + Ey = F\n\n");
/* Ecuacion 1 */
printf("Valor de A (x): ");
scanf("%d", &mat[0][0]);
printf("Valor de B (y): ");
scanf("%d", &mat[0][1]);
printf("Valor de C : ");
scanf("%d", &mat[0][2]);
/* Ecuacion 2 */
printf("Valor de D (x): ");
scanf("%d", &mat[1][0]);
printf("Valor de E (y): ");
scanf("%d", &mat[1][1]);
printf("Valor de F : ");
scanf("%d", &mat[1][2]);
printf("\n\n");
printf("La matriz quedo de la siguiente manera:\n\n");
printf("Forma canonica:\n\n");
printf("1) %dx + %dy = %d\n", mat[0][0], mat[0][1], mat[0][2]);
printf("2) %dx + %dy = %d\n\n", mat[1][0], mat[1][1], mat[1][2]);
printf("Forma matricial\n");
mostrar_matriz();
printf("\n\n");
}
int resultado(){
/*
Nombre: resultado
Funcion: Realiza el procedimiento de la matriz escalonado, para la realizacion de Gauss-Jordan
Envia: 0 si fue realizado con exito la operación
1 si el sistema es inconsistente
2 si el sistema es linealmente dependiente
Recibe: --
*/
asignacion_letras();
if (A == 0 && B == 0 && D == 0 && E == 0)
{
return 1;
} else if ((A == 0 && D == 0) || (B == 0 && E == 0))
{
return 1;
} else if ( (A == 0 && B == 0) || (D == 0 && E == 0) ){
return 1;
}else{
int iter1;
iter1 = iteracion_1();
return iter1;
}
}
void asignacion_letras(){
/*
Nombre: asignacion_letras
Funcion: Asigna el numero a cada una de las letras que hay el matriz
Envia: --
Recibe: --
*/
//Ecuacion 1: Ax + By = C
A = mat[0][0];
B = mat[0][1];
C = mat[0][2];
//Ecuacion 2: Dx + Ey = F
D = mat[1][0];
E = mat[1][1];
F = mat[1][2];
}
int iteracion_1(){
/*
Nombre: iteracion_1
Funcion: Resuelve Gauss-Jordan
Envia: Dos clases de 0:
0 si la letra D es ingresada con cero, ya que el procedimiento de Gauss-Jordan no cera necesario
0 despues de pasar por todas la restricciones
1 si despues de realizar Gauss-Jordan D y E son 0 y F es diferente de cero (0x + 0y = 18), por lo el sistema no tiene solucion
2 si despues de realizar Gauss-Jordan D, E y F son cero (0x + 0y = 0), por lo que el sistema es linealmente dependiente
Recibe: --
*/
if (D == 0)
{
return 0;
}
for(i=0; i<3;i++){
mat[0][i] = mat[0][i]*D;
if(D > 0) {mat[1][i] = mat[1][i]*A;}
else {mat[1][i] = mat[1][i]*-A;}
}
mat[1][0] = mat[0][0] + mat[1][0];
mat[1][1] = mat[0][1] + mat[1][1];
mat[1][2] = mat[0][2] + mat[1][2];
if(mat[1][0] == 0 && mat[1][1] == 0 && mat[1][2] == 0){
return 2;
} else if(mat[1][0] == 0 && mat[1][1] == 0 && mat[1][2] != 0){
return 1;
} else{
return 0;
}
}
/*
| 0 B | C |
| 0 E | F |
Ó
| A 0 | C |
| D 0 | F |
| 0 0 | C |
| D E | F |
ó
| A B | C |
| 0 0 | F |
*/
| 23.288256 | 166 | 0.47448 |
fff8db998f91b50d2e363be98294963e2df5d60a | 2,263 | c | C | osx_system_idle.c | perj/movactl | 8e0b90c20920287da1ca6ca2433a5dc5c50e2f70 | [
"BSD-2-Clause"
] | 1 | 2021-01-12T21:13:57.000Z | 2021-01-12T21:13:57.000Z | osx_system_idle.c | perj/movactl | 8e0b90c20920287da1ca6ca2433a5dc5c50e2f70 | [
"BSD-2-Clause"
] | null | null | null | osx_system_idle.c | perj/movactl | 8e0b90c20920287da1ca6ca2433a5dc5c50e2f70 | [
"BSD-2-Clause"
] | null | null | null | /*
* Copyright (c) 2013 Per Johansson
* 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 <time.h>
#include <IOKit/IOKitLib.h>
#include <CoreFoundation/CoreFoundation.h>
int
osx_system_idle(struct timespec *dst)
{
kern_return_t err;
io_iterator_t it;
io_registry_entry_t service;
bool set = false;
err = IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching("IOHIDSystem"), &it);
if (err)
return -1;
while ((service = IOIteratorNext(it)))
{
CFNumberRef value = IORegistryEntryCreateCFProperty(service, CFSTR("HIDIdleTime"), kCFAllocatorDefault, 0);
long long n;
struct timespec ts;
if (!value)
goto next;
if (!CFNumberGetValue(value, kCFNumberLongLongType, &n))
goto next;
ts.tv_sec = n / 1000000000;
ts.tv_nsec = n % 1000000000;
if (!set || ts.tv_sec < dst->tv_sec || (ts.tv_sec == dst->tv_sec && ts.tv_nsec < dst->tv_nsec))
*dst = ts;
set = true;
next:
if (value)
CFRelease(value);
IOObjectRelease(service);
}
IOObjectRelease(it);
return set ? 0 : -1;
}
| 32.797101 | 109 | 0.737075 |
b11ee9e790b24b9ba2c866a0d88538d6abc96ef8 | 5,641 | h | C | src/H5Epkg.h | hyoklee/hdf5 | d128e98a69039be58deeca9b737bf4b465b9756f | [
"BSD-3-Clause-LBNL"
] | 215 | 2020-04-27T17:08:20.000Z | 2022-03-09T14:36:37.000Z | src/H5Epkg.h | hyoklee/hdf5 | d128e98a69039be58deeca9b737bf4b465b9756f | [
"BSD-3-Clause-LBNL"
] | 562 | 2020-06-21T15:38:20.000Z | 2022-03-31T15:33:59.000Z | src/H5Epkg.h | hyoklee/hdf5 | d128e98a69039be58deeca9b737bf4b465b9756f | [
"BSD-3-Clause-LBNL"
] | 180 | 2020-04-30T17:05:42.000Z | 2022-03-31T16:04:26.000Z | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Programmer: Quincey Koziol
* Wednesday, April 11, 2007
*
* Purpose: This file contains declarations which are visible only within
* the H5E package. Source files outside the H5E package should
* include H5Eprivate.h instead.
*/
#if !(defined H5E_FRIEND || defined H5E_MODULE)
#error "Do not include this file outside the H5E package!"
#endif
#ifndef H5Epkg_H
#define H5Epkg_H
/* Get package's private header */
#include "H5Eprivate.h"
/* Other private headers needed by this file */
/**************************/
/* Package Private Macros */
/**************************/
/* Amount to indent each error */
#define H5E_INDENT 2
/* Number of slots in an error stack */
#define H5E_NSLOTS 32
#ifdef H5_HAVE_THREADSAFE
/*
* The per-thread error stack. pthread_once() initializes a special
* key that will be used by all threads to create a stack specific to
* each thread individually. The association of stacks to threads will
* be handled by the pthread library.
*
* In order for this macro to work, H5E__get_my_stack() must be preceded
* by "H5E_t *estack =".
*/
#define H5E__get_my_stack() H5E__get_stack()
#else /* H5_HAVE_THREADSAFE */
/*
* The current error stack.
*/
#define H5E__get_my_stack() (H5E_stack_g + 0)
#endif /* H5_HAVE_THREADSAFE */
/****************************/
/* Package Private Typedefs */
/****************************/
/* Some syntactic sugar to make the compiler happy with two different kinds of callbacks */
#ifndef H5_NO_DEPRECATED_SYMBOLS
typedef struct {
unsigned vers; /* Which version callback to use */
hbool_t is_default; /* If the printing function is the library's own. */
H5E_auto1_t func1; /* Old-style callback, NO error stack param. */
H5E_auto2_t func2; /* New-style callback, with error stack param. */
H5E_auto1_t func1_default; /* The saved library's default function - old style. */
H5E_auto2_t func2_default; /* The saved library's default function - new style. */
} H5E_auto_op_t;
#else /* H5_NO_DEPRECATED_SYMBOLS */
typedef struct {
H5E_auto2_t func2; /* Only the new style callback function is available. */
} H5E_auto_op_t;
#endif /* H5_NO_DEPRECATED_SYMBOLS */
/* Some syntactic sugar to make the compiler happy with two different kinds of callbacks */
typedef struct {
unsigned vers; /* Which version callback to use */
union {
#ifndef H5_NO_DEPRECATED_SYMBOLS
H5E_walk1_t func1; /* Old-style callback, NO error stack param. */
#endif /* H5_NO_DEPRECATED_SYMBOLS */
H5E_walk2_t func2; /* New-style callback, with error stack param. */
} u;
} H5E_walk_op_t;
/* Error class */
typedef struct H5E_cls_t {
char *cls_name; /* Name of error class */
char *lib_name; /* Name of library within class */
char *lib_vers; /* Version of library */
} H5E_cls_t;
/* Major or minor message */
typedef struct H5E_msg_t {
char * msg; /* Message for error */
H5E_type_t type; /* Type of error (major or minor) */
H5E_cls_t *cls; /* Which error class this message belongs to */
} H5E_msg_t;
/* Error stack */
struct H5E_t {
size_t nused; /* Num slots currently used in stack */
H5E_error2_t slot[H5E_NSLOTS]; /* Array of error records */
H5E_auto_op_t auto_op; /* Operator for 'automatic' error reporting */
void * auto_data; /* Callback data for 'automatic error reporting */
};
/*****************************/
/* Package Private Variables */
/*****************************/
#ifndef H5_HAVE_THREADSAFE
/*
* The current error stack.
*/
H5_DLLVAR H5E_t H5E_stack_g[1];
#endif /* H5_HAVE_THREADSAFE */
/******************************/
/* Package Private Prototypes */
/******************************/
H5_DLL herr_t H5E__term_deprec_interface(void);
#ifdef H5_HAVE_THREADSAFE
H5_DLL H5E_t *H5E__get_stack(void);
#endif /* H5_HAVE_THREADSAFE */
H5_DLL herr_t H5E__push_stack(H5E_t *estack, const char *file, const char *func, unsigned line, hid_t cls_id,
hid_t maj_id, hid_t min_id, const char *desc);
H5_DLL ssize_t H5E__get_msg(const H5E_msg_t *msg_ptr, H5E_type_t *type, char *msg, size_t size);
H5_DLL herr_t H5E__print(const H5E_t *estack, FILE *stream, hbool_t bk_compat);
H5_DLL herr_t H5E__walk(const H5E_t *estack, H5E_direction_t direction, const H5E_walk_op_t *op,
void *client_data);
H5_DLL herr_t H5E__get_auto(const H5E_t *estack, H5E_auto_op_t *op, void **client_data);
H5_DLL herr_t H5E__set_auto(H5E_t *estack, const H5E_auto_op_t *op, void *client_data);
H5_DLL herr_t H5E__pop(H5E_t *err_stack, size_t count);
#endif /* H5Epkg_H */
| 39.173611 | 110 | 0.619216 |
7fc1068e3543298fb4dae0f0ebf4f4106e62e554 | 1,073 | h | C | src/untrusted/nacl/nacl_list_mappings.h | cohortfsllc/cohort-cocl2-sandbox | 0ac6669d1a459d65a52007b80d5cffa4ef330287 | [
"BSD-3-Clause"
] | 2,151 | 2020-04-18T07:31:17.000Z | 2022-03-31T08:39:18.000Z | src/untrusted/nacl/nacl_list_mappings.h | cohortfsllc/cohort-cocl2-sandbox | 0ac6669d1a459d65a52007b80d5cffa4ef330287 | [
"BSD-3-Clause"
] | 395 | 2020-04-18T08:22:18.000Z | 2021-12-08T13:04:49.000Z | src/untrusted/nacl/nacl_list_mappings.h | cohortfsllc/cohort-cocl2-sandbox | 0ac6669d1a459d65a52007b80d5cffa4ef330287 | [
"BSD-3-Clause"
] | 338 | 2020-04-18T08:03:10.000Z | 2022-03-29T12:33:22.000Z | /*
* Copyright (c) 2013 The Native Client 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 _NATIVE_CLIENT_SRC_UNTRUSTED_NACL_NACL_LIST_MAPPINGS_H_
#define _NATIVE_CLIENT_SRC_UNTRUSTED_NACL_NACL_LIST_MAPPINGS_H_ 1
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
struct NaClMemMappingInfo;
/**
* @nacl
* Gets a memory map of the current process.
* @param regions Destination to receive info on memory regions.
* @param count Number of regions that there are space for.
* @param result_count Pointer to location to receive number of regions
* needed.
* @return Returns zero on success, -1 on failure.
* Sets errno to EFAULT if output locations are bad.
* Sets errno to ENOMEM if insufficent memory exists to gather the map.
*/
int nacl_list_mappings(struct NaClMemMappingInfo *info, size_t count,
size_t *result_count);
#ifdef __cplusplus
}
#endif
#endif /* _NATIVE_CLIENT_SRC_UNTRUSTED_NACL_NACL_LIST_MAPPINGS_H_ */
| 29 | 73 | 0.752097 |
cfb4b1326d98b3680c51b6f07b0757e6dd48d1d9 | 2,627 | c | C | raytrace/scene/ballgen.c | lukaszgryglicki/rays | a237e319a4e116bd20aa5aaaaaf1fd2aa8f36499 | [
"Apache-2.0"
] | 3 | 2019-08-07T02:58:56.000Z | 2021-08-29T23:53:54.000Z | raytrace/scene/ballgen.c | lukaszgryglicki/rays | a237e319a4e116bd20aa5aaaaaf1fd2aa8f36499 | [
"Apache-2.0"
] | null | null | null | raytrace/scene/ballgen.c | lukaszgryglicki/rays | a237e319a4e116bd20aa5aaaaaf1fd2aa8f36499 | [
"Apache-2.0"
] | null | null | null | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
void outf(char* par)
{
char str[1024];
sprintf(str, "echo \"%s\" >> prog.dat", par);
system( str );
}
int ran(int num)
{
return rand() % num;
}
void mkball(int n, int lt)
{
char str[1024];
int nt, tid;
double tr, tg, tb;
double sr, sg, sb;
double cr, cg, cb;
double sfr, sfg, sfb;
double sx, sy, sz, sf;
double rx, ry, rz;
double tx, ty, tz;
nt = 2000 * n;
tr = (double)ran(10);
tg = (double)ran(10);
tb = (double)ran(10);
sr = (double)ran(10);
sg = (double)ran(10);
sb = (double)ran(10);
cr = (double)ran(10);
cg = (double)ran(10);
cb = (double)ran(10);
cr = 0.;
sfr = 1.2 + (double)ran(20) / 100.;
sfg = 1.2 + (double)ran(20) / 100.;
sfb = 1.2 + (double)ran(20) / 100.;
tid = ran(14) + 1;
sx = 35. + (double)ran(25);
sy = 35. + (double)ran(25);
sz = 35. + (double)ran(25);
rx = (double)ran(360);
ry = (double)ran(360);
rz = (double)ran(360);
tx = (double)ran(250) - 125.;
ty = (double)ran(250) - 125.;
tz = (double)ran(250) - 125.;
sf = 10. + (double)ran(90);
sprintf(str, "../ball %d %f %f %f %f %f %f %f %f %f %d %f %f %f %f %f %f %f %f %f %f %f %f %f 0 1 %d 25 20 >> prog.dat",
nt, tr, tr, tr, sr, sr, sr, cr, cr, cr, tid, sfr, sfg, sfb, sf, sx, sy, sz, rx, ry, rz, tx, ty, tz, lt);
system( str );
}
void cptri(int n)
{
char str[1024];
sprintf(str, "CopyTriangles: dst=%d,src=0,num=2000", n * 2000);
outf( str );
}
void go(int n)
{
char str[1024];
time_t tm;
int r, r2, r3, nt, i;
time(&tm);
srand((int)tm);
system("rm -f prog.dat");
outf("Screen: (1920,1200)");
r = ran(14) + 1;
sprintf(str, "Background: %d", r);
outf( str );
outf("MaxRecurse: 100");
outf("Backup: 500");
outf("Observer: Vertex: (0,0,-250)");
r = 25 + ran(20);
sprintf(str, "LookZ: %d%%", r);
outf( str );
r = ran(1000) - 500;
r2 = ran(1000) - 500;
r3 = ran(1000) - 500;
sprintf(str, "Light: Vertex: (%d,%d,%d)", r, r2, r3);
outf( str );
r = ran(0x100);
r2 = ran(0x100);
r3 = ran(0x100);
sprintf(str, "LightColor: %02x%02x%02x", r, r2, r3);
outf( str );
outf("TexDirectory: tex");
outf("NumTextures: 14");
nt = n * 2000;
sprintf(str, "nTriangles: %d", nt);
outf( str );
sprintf(str, "ListTransform: [0,%d]", nt-1);
outf( str );
outf("{");
outf("}");
for (i=0;i<n;i++)
{
mkball(i, 1);
}
for (i=0;i<n;i++)
{
mkball(i, 0);
}
/* mkball(0, 0);*/
/* for (i=1;i<n;i++) cptri(i);*/
}
int main(int lb, char** par)
{
if (lb < 2)
{
printf("%s num\n", par[0]);
return 1;
}
go(atoi(par[1]));
return 0;
}
| 20.523438 | 121 | 0.527217 |
36fb4882aac6161f7777edb1de8f9b9e45015387 | 8,397 | h | C | Assets/Purple.h | Press-Play-On-Tape/GalaxyFighter_Pokitto | ce135d529f3ed53a4f7ee27e0efe2dbd06a5b29b | [
"BSD-3-Clause"
] | 3 | 2020-01-10T18:06:25.000Z | 2020-11-10T01:17:54.000Z | Assets/Purple.h | Press-Play-On-Tape/GalaxyFighter_Pokitto | ce135d529f3ed53a4f7ee27e0efe2dbd06a5b29b | [
"BSD-3-Clause"
] | null | null | null | Assets/Purple.h | Press-Play-On-Tape/GalaxyFighter_Pokitto | ce135d529f3ed53a4f7ee27e0efe2dbd06a5b29b | [
"BSD-3-Clause"
] | 2 | 2020-01-14T12:27:52.000Z | 2022-02-18T14:32:08.000Z | // Automatically generated file, do not edit.
#pragma once
const uint8_t Purple[] = {
184, 18,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0c,0x00,0xcc,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x0c,0x00,0x00,0x00,
0x00,0x00,0x00,0x0c,0xcc,0xce,0xee,0xcc,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xce,0xec,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xce,0xec,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0xee,0xce,0xec,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0xee,0xce,0xec,0xc0,0x00,
0x00,0x00,0x00,0xcc,0xce,0xec,0xee,0xcc,0x00,0x00,0x00,0x00,0x00,0x0c,0xc0,0xcc,0xcc,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0xce,0xec,0x0c,0xcc,0xcc,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xce,0xe0,0x0c,0xc0,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x0e,0xce,0xc0,0x0c,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0xee,0xce,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xee,0xce,0xec,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xee,0xce,0xec,0x00,0x00,
0x00,0xc0,0x00,0xcc,0xcc,0xcc,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x0e,0xc0,0xcc,0xcc,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0xcc,0xdc,0xcc,0xee,0xec,0xc0,0x00,0x00,0x00,0x00,0x00,0x0c,0x0e,0xec,0xcc,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x0c,0xce,0xcc,0xdd,0xcc,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xce,0xcc,0xcc,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0xcc,0xc0,0x00,0x00,
0x00,0xcc,0x0c,0xcc,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xce,0xec,0xdd,0xc0,0x00,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xcd,0xdd,0xdc,0xcc,0xec,0xcc,0x00,0x00,0x00,0x00,0x00,0x0e,0xec,0xcd,0xdc,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xcd,0xdd,0xdc,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xdc,0xdd,0xcc,0xc0,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xdd,0xcd,0xdc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0xdd,0xcd,0xdc,0xc0,0x00,
0x00,0xee,0xcd,0xdd,0xd0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0xcd,0xdd,0xdd,0x00,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0xec,0xdd,0xdd,0xe0,0x00,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x0e,0xec,0xcd,0xdd,0x0c,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xdd,0xdd,0xdc,0xcc,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xcd,0xdd,0xdd,0xcc,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0xdd,0xdd,0xdc,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0xdd,0xdd,0xdc,0xcc,0x00,
0xcc,0xee,0xcd,0xdd,0xde,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xee,0xcc,0xdd,0xde,0xe0,0x0c,0xc0,0x00,0x00,0x00,0x00,0x0c,0xc0,0xdd,0xdd,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xc0,0xcd,0xdd,0xdd,0xd0,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x0c,0xcd,0xdd,0xe0,0x0c,0xce,0xc0,0x00,0x00,0x00,0x00,0x00,0x0c,0xcd,0xdd,0xdd,0xd0,0xcc,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0xcc,0xdd,0xdd,0xdc,0xcc,0xcc,0x00,0x00,0x00,0x00,0x0c,0xcc,0xcc,0xdd,0xdd,0xdc,0xcc,0xcc,
0x00,0xcc,0xcc,0xdd,0xd0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xee,0xcd,0xdd,0xd0,0x00,0x00,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0xde,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcd,0xdd,0xdd,0xe0,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0xcc,0xcd,0xe0,0xe0,0x0c,0xee,0xc0,0x00,0x00,0x00,0x00,0x00,0xcc,0xcc,0xdd,0xdd,0x00,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0xcc,0xdd,0xdd,0xdc,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0xcc,0xc0,0xdd,0xdd,0xd0,0xcc,0xc0,
0xcc,0xee,0xcd,0xdd,0xde,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xcd,0xdd,0xde,0xe0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0xdd,0xd0,0xe0,0x0c,0xc0,0x00,0x00,0x00,0x00,0x0c,0xcc,0xcc,0x00,0x00,0x00,0xcc,0xc0,0x00,0x00,0x00,0x00,0x0c,0xcc,0xc0,0xde,0x0e,0x00,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0xce,0xcc,0x0e,0x0e,0x0c,0xce,0xc0,0x00,0x00,0x00,0x00,0x00,0x0c,0xc0,0x0e,0x0e,0x00,0xcc,0x00,
0x00,0xee,0xcd,0xdd,0xd0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0xcc,0xcd,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0x0d,0xee,0x00,0x0c,0xc0,0x00,0x00,0x00,0x00,0x00,0x0c,0xec,0x00,0x00,0x00,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0xcc,0xc0,0x0e,0x0e,0x0c,0xcc,0x00,0x00,0x00,0x00,0x00,0x0c,0xce,0xc0,0x0e,0x0e,0x00,0xce,0xcc,0x00,0x00,0x00,0x00,0x00,0x0c,0xc0,0x0e,0x0e,0x00,0xcc,0x00,
0x00,0xcc,0x0c,0xcc,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0xc0,0x00,0xc0,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0xc0,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xec,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xc0,0x00,0x00,0x00,0xcc,0x00,0x00,0x00,0x00,0x00,0x0c,0xec,0xc0,0x00,0x00,0x00,0xcc,0xec,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0x00,0x00,0x0c,0xcc,0x00,
0x00,0xc0,0x00,0xcc,0xcc,0xcc,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0xcc,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0xec,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0xcc,0xc0,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xee,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0xc0,0x00,0x0c,0xc0,0x00,0x00,0x00,0x00,0x00,0x0c,0xee,0xc0,0x00,0x00,0x00,0xce,0xec,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0x00,0x00,0x0c,0xc0,0x00,
0x00,0x00,0x00,0xcc,0xce,0xec,0xee,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0xcc,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xce,0xec,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0xcc,0xcc,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xee,0xc0,0x00,0x00,0x00,0xce,0xec,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xc0,0x00,0xcc,0x00,0x00,
0x00,0x00,0x00,0x0c,0xcc,0xce,0xee,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0xc0,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0xcc,0xc0,0x00,0x00,0x00,0xcc,0xcc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0x0c,0xc0,0x00,0x00,
0x00,0x00,0x00,0x0c,0x00,0xcc,0xcc,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xcc,0x00,0x00,0x00,0x00,0x0c,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0c,0x0c,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
| 322.961538 | 460 | 0.796951 |
3248d250852eafb227c8a741f4b1d28398dee81d | 16,039 | c | C | src/3.2/src/vfc_grab.c | ronf/nv | 7d95c9d975d7a40068c969483d78438e6069e356 | [
"Xerox",
"Unlicense"
] | 37 | 2020-06-24T04:41:20.000Z | 2022-01-14T09:35:32.000Z | src/3.2/src/vfc_grab.c | ronf/nv | 7d95c9d975d7a40068c969483d78438e6069e356 | [
"Xerox",
"Unlicense"
] | null | null | null | src/3.2/src/vfc_grab.c | ronf/nv | 7d95c9d975d7a40068c969483d78438e6069e356 | [
"Xerox",
"Unlicense"
] | 3 | 2020-06-24T04:41:31.000Z | 2021-10-15T01:13:17.000Z | /*
Netvideo version 3.2
Written by Ron Frederick <frederick@parc.xerox.com>
VideoPix frame grab routines
*/
/*
* Copyright (c) Xerox Corporation 1992. All rights reserved.
*
* License is granted to copy, to use, and to make and to use derivative
* works for research and evaluation purposes, provided that Xerox is
* acknowledged in all documentation pertaining to any such copy or derivative
* work. Xerox grants no other licenses expressed or implied. The Xerox trade
* name should not be used in any advertising without its written permission.
*
* XEROX CORPORATION MAKES NO REPRESENTATIONS CONCERNING EITHER THE
* MERCHANTABILITY OF THIS SOFTWARE OR THE SUITABILITY OF THIS SOFTWARE
* FOR ANY PARTICULAR PURPOSE. The software is provided "as is" without
* express or implied warranty of any kind.
*
* These notices must be retained in any copies of any part of this software.
*/
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <vfc_lib.h>
#include "vidgrab.h"
#ifdef __GNUC__
#undef VFCSCTRL
#define VFCSCTRL _IOW('j', 1, int) /* set ctrl. attr. */
#endif /*__GNUC__*/
static VfcDev *vfcdev;
int (*GrabImage)(u_char *y_data, signed char *uv_data);
static int GrabImage_NTSC_Grey(u_char *y_data)
{
static int grab=CAPTRCMD;
register int i, j;
register unsigned long data0, data1, data2, data3, mask, y, *yptr;
register volatile unsigned long *dataptr=vfcdev->vfc_port1;
ioctl(vfcdev->vfc_fd, VFCSCTRL, &grab);
for (i=0; i<VFC_OSKIP_NTSC+3; i++) data0 = *dataptr;
data0 = *dataptr;
data1 = *dataptr;
yptr = (u_long *)y_data;
mask = 0xff000000;
for (i=0; i<NTSC_HEIGHT; i++) {
for (j=0; j<NTSC_WIDTH; j+=20) {
data2 = *dataptr;
data3 = *dataptr;
y = data1 & mask;
data0 = *dataptr;
data1 = *dataptr;
y += (data3 & mask) >> 8;
data2 = *dataptr;
data3 = *dataptr;
y += (data1 & mask) >> 16;
data0 = *dataptr;
data1 = *dataptr;
*yptr++ = y + (data3 >> 24);
data2 = *dataptr;
data3 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y = data1 & mask;
data0 = *dataptr;
data1 = *dataptr;
y += (data2 & mask) >> 8;
data2 = *dataptr;
data3 = *dataptr;
y += (data0 & mask) >> 16;
data0 = *dataptr;
data1 = *dataptr;
*yptr++ = y + (data2 >> 24);
data2 = *dataptr;
data3 = *dataptr;
y = data0 & mask;
data0 = *dataptr;
data1 = *dataptr;
y += (data2 & mask) >> 8;
data2 = *dataptr;
data3 = *dataptr;
y += (data1 & mask) >> 16;
data0 = *dataptr;
data1 = *dataptr;
*yptr++ = y + (data3 >> 24);
data2 = *dataptr;
data3 = *dataptr;
y = data1 & mask;
data0 = *dataptr;
data1 = *dataptr;
y += (data3 & mask) >> 8;
data2 = *dataptr;
data3 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y += (data1 & mask) >> 16;
data0 = *dataptr;
data1 = *dataptr;
*yptr++ = y + (data2 >> 24);
data2 = *dataptr;
data3 = *dataptr;
y = data0 & mask;
data0 = *dataptr;
data1 = *dataptr;
y += (data2 & mask) >> 8;
data2 = *dataptr;
data3 = *dataptr;
y += (data0 & mask) >> 16;
data0 = *dataptr;
data1 = *dataptr;
*yptr++ = y + (data2 >> 24);
}
for (j=0; j<16; j++) data1 = *dataptr;
}
return 1;
}
static int GrabImage_PAL_Grey(u_char *y_data)
{
static int grab=CAPTRCMD;
register int i, j;
register unsigned long data0, data1, data2, data3, mask, y, *yptr;
register volatile unsigned long *dataptr=vfcdev->vfc_port1;
ioctl(vfcdev->vfc_fd, VFCSCTRL, &grab);
for (i=0; i<VFC_ESKIP_PAL+3; i++) data0 = *dataptr;
data0 = *dataptr;
data1 = *dataptr;
yptr = (u_long *)y_data;
mask = 0xff000000;
for (i=0; i<PAL_HEIGHT; i++) {
for (j=0; j<PAL_WIDTH; j+=24) {
data2 = *dataptr;
data3 = *dataptr;
y = data0 & mask;
data0 = *dataptr;
data1 = *dataptr;
y += (data2 & mask) >> 8;
data2 = *dataptr;
data3 = *dataptr;
y += (data0 & mask) >> 16;
data0 = *dataptr;
data1 = *dataptr;
*yptr++ = y + (data2 >> 24);
data2 = *dataptr;
data3 = *dataptr;
y = data0 & mask;
data0 = *dataptr;
data1 = *dataptr;
y += (data2 & mask) >> 8;
y += (data3 & mask) >> 16;
data2 = *dataptr;
data3 = *dataptr;
*yptr++ = y + (data1 >> 24);
data0 = *dataptr;
data1 = *dataptr;
y = data3 & mask;
data2 = *dataptr;
data3 = *dataptr;
y += (data1 & mask) >> 8;
data0 = *dataptr;
data1 = *dataptr;
y += (data3 & mask) >> 16;
data2 = *dataptr;
data3 = *dataptr;
*yptr++ = y + (data1 >> 24);
data0 = *dataptr;
data1 = *dataptr;
y = data2 & mask;
data2 = *dataptr;
data3 = *dataptr;
y += (data0 & mask) >> 8;
data0 = *dataptr;
data1 = *dataptr;
y += (data2 & mask) >> 16;
data2 = *dataptr;
data3 = *dataptr;
*yptr++ = y + (data0 >> 24);
data0 = *dataptr;
data1 = *dataptr;
y = data2 & mask;
data2 = *dataptr;
data3 = *dataptr;
y += (data0 & mask) >> 8;
y += (data1 & mask) >> 16;
data0 = *dataptr;
data1 = *dataptr;
*yptr++ = y + (data3 >> 24);
data2 = *dataptr;
data3 = *dataptr;
y = data1 & mask;
data0 = *dataptr;
data1 = *dataptr;
y += (data3 & mask) >> 8;
data2 = *dataptr;
data3 = *dataptr;
y += (data1 & mask) >> 16;
data0 = *dataptr;
data1 = *dataptr;
*yptr++ = y + (data3 >> 24);
}
for (j=0; j<16; j++) data0 = *dataptr;
}
return 1;
}
static int GrabImage_NTSC_Color(u_char *y_data, signed char *uv_data)
{
static int grab=CAPTRCMD;
register int i, j;
register unsigned long data0, data1, data2, data3;
register unsigned long y1, y2, uv1, uv2, *yptr, *uvptr;
register volatile unsigned long *dataptr=vfcdev->vfc_port1;
ioctl(vfcdev->vfc_fd, VFCSCTRL, &grab);
for (i=0; i<VFC_OSKIP_NTSC+3; i++) data0 = *dataptr;
yptr = (u_long *)y_data;
uvptr = (u_long *)uv_data;
for (i=0; i<NTSC_HEIGHT; i++) {
for (j=0; j<NTSC_WIDTH; j+=20) {
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y1 = ((data1 >> 16) & 0xff00) + (data3 >> 24);
uv1 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y2 = ((data1 >> 16) & 0xff00) + (data3 >> 24);
uv2 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
*yptr++ = (y1 << 16) + y2;
*uvptr++ = (uv1 << 16) + uv2;
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y1 = ((data1 >> 16) & 0xff00) + (data3 >> 24);
uv1 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y2 = ((data1 >> 16) & 0xff00) + (data3 >> 24);
uv2 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
*yptr++ = (y1 << 16) + y2;
*uvptr++ = (uv1 << 16) + uv2;
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y1 = ((data1 >> 16) & 0xff00) + (data3 >> 24);
uv1 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y2 = ((data0 >> 16) & 0xff00) + (data2 >> 24);
uv2 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
*yptr++ = (y1 << 16) + y2;
*uvptr++ = (uv1 << 16) + uv2;
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y1 = ((data0 >> 16) & 0xff00) + (data2 >> 24);
uv1 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y2 = ((data0 >> 16) & 0xff00) + (data2 >> 24);
uv2 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
*yptr++ = (y1 << 16) + y2;
*uvptr++ = (uv1 << 16) + uv2;
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y1 = ((data0 >> 16) & 0xff00) + (data2 >> 24);
uv1 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y2 = ((data0 >> 16) & 0xff00) + (data2 >> 24);
uv2 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
*yptr++ = (y1 << 16) + y2;
*uvptr++ = (uv1 << 16) + uv2;
}
for (j=0; j<16; j++) data0 = *dataptr;
}
return 1;
}
static int GrabImage_PAL_Color(u_char *y_data, signed char *uv_data)
{
static int grab=CAPTRCMD;
register int i, j;
register unsigned long data0, data1, data2, data3;
register unsigned long y1, y2, uv1, uv2, *yptr, *uvptr;
register volatile unsigned long *dataptr=vfcdev->vfc_port1;
ioctl(vfcdev->vfc_fd, VFCSCTRL, &grab);
for (i=0; i<VFC_ESKIP_PAL+3; i++) data0 = *dataptr;
yptr = (u_long *)y_data;
uvptr = (u_long *)uv_data;
for (i=0; i<PAL_HEIGHT; i++) {
for (j=0; j<PAL_WIDTH; j+=24) {
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y1 = ((data0 >> 16) & 0xff00) + (data2 >> 24);
uv1 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y2 = ((data0 >> 16) & 0xff00) + (data2 >> 24);
uv2 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
*yptr++ = (y1 << 16) + y2;
*uvptr++ = (uv1 << 16) + uv2;
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y1 = ((data0 >> 16) & 0xff00) + (data2 >> 24);
uv1 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y2 = ((data0 >> 16) & 0xff00) + (data1 >> 24);
uv2 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
*yptr++ = (y1 << 16) + y2;
*uvptr++ = (uv1 << 16) + uv2;
y1 = ((data2 >> 16) & 0xff00) + (data3 >> 24);
uv1 = uv2;
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y2 = ((data1 >> 16) & 0xff00) + (data3 >> 24);
uv2 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
*yptr++ = (y1 << 16) + y2;
*uvptr++ = (uv1 << 16) + uv2;
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y1 = ((data1 >> 16) & 0xff00) + (data3 >> 24);
uv1 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y2 = ((data1 >> 16) & 0xff00) + (data3 >> 24);
uv2 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
*yptr++ = (y1 << 16) + y2;
*uvptr++ = (uv1 << 16) + uv2;
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y1 = ((data1 >> 16) & 0xff00) + (data3 >> 24);
uv1 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y2 = ((data0 >> 16) & 0xff00) + (data2 >> 24);
uv2 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
*yptr++ = (y1 << 16) + y2;
*uvptr++ = (uv1 << 16) + uv2;
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y1 = ((data0 >> 16) & 0xff00) + (data2 >> 24);
uv1 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
data0 = *dataptr;
data1 = *dataptr;
data2 = *dataptr;
data3 = *dataptr;
y2 = ((data0 >> 16) & 0xff00) + (data2 >> 24);
uv2 = ((data0 >> 8) & 0xc000) + ((data0 >> 14) & 0xc0) +
((data1 >> 10) & 0x3000) + ((data1 >> 16) & 0x30) +
((data2 >> 12) & 0x0c00) + ((data2 >> 18) & 0x0c);
*yptr++ = (y1 << 16) + y2;
*uvptr++ = (uv1 << 16) + uv2;
}
for (j=0; j<16; j++) data0 = *dataptr;
}
return 1;
}
static int GrabImage_NTSC(u_char *y_data, signed char *uv_data)
{
if (uv_data)
return GrabImage_NTSC_Color(y_data, uv_data);
else
return GrabImage_NTSC_Grey(y_data);
}
static int GrabImage_PAL(u_char *y_data, signed char *uv_data)
{
if (uv_data)
return GrabImage_PAL_Color(y_data, uv_data);
else
return GrabImage_PAL_Grey(y_data);
}
int GrabImage_Init(int framerate, int *widthp, int *heightp)
{
int tmpfd, format;
/* This is a horrible hack to prevent the VFC library from printing
error messages that we'd rather not print. */
tmpfd = dup(2);
close(2);
open("/dev/null", O_RDONLY);
vfcdev = vfc_open("/dev/vfc0", VFC_LOCKDEV);
dup2(tmpfd, 2);
close(tmpfd);
if (vfcdev == NULL) {
*widthp = *heightp = 0;
return 0;
}
vfc_set_port(vfcdev, VFC_PORT1);
vfc_set_format(vfcdev, VFC_AUTO, &format);
switch (format) {
default:
case NO_LOCK:
fprintf(stderr, "Warning: no video signal found!\n");
/* Fall through */
case NTSC_COLOR:
case NTSC_NOCOLOR:
*widthp = NTSC_WIDTH;
*heightp = NTSC_HEIGHT;
GrabImage = GrabImage_NTSC;
break;
case PAL_COLOR:
case PAL_NOCOLOR:
*widthp = PAL_WIDTH;
*heightp = PAL_HEIGHT;
GrabImage = GrabImage_PAL;
break;
}
return 1;
}
void GrabImage_Cleanup(void)
{
vfc_destroy(vfcdev);
}
| 25.100156 | 78 | 0.510568 |
c5dbce0b22ecd2a12dc1b0abf9f4e528473275dc | 5,737 | c | C | crypto/x509/v3_info.c | swenkeratmicrosoft/openssl | 941fc66b4beafa5b40cb94959100cb81684643d3 | [
"Apache-2.0"
] | null | null | null | crypto/x509/v3_info.c | swenkeratmicrosoft/openssl | 941fc66b4beafa5b40cb94959100cb81684643d3 | [
"Apache-2.0"
] | null | null | null | crypto/x509/v3_info.c | swenkeratmicrosoft/openssl | 941fc66b4beafa5b40cb94959100cb81684643d3 | [
"Apache-2.0"
] | null | null | null | /*
* Copyright 1999-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#include <stdio.h>
#include "internal/cryptlib.h"
#include <openssl/conf.h>
#include <openssl/asn1.h>
#include <openssl/asn1t.h>
#include <openssl/x509v3.h>
#include "ext_dat.h"
DEFINE_STACK_OF(ACCESS_DESCRIPTION)
DEFINE_STACK_OF(CONF_VALUE)
static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD
*method, AUTHORITY_INFO_ACCESS
*ainfo, STACK_OF(CONF_VALUE)
*ret);
static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD
*method,
X509V3_CTX *ctx,
STACK_OF(CONF_VALUE)
*nval);
const X509V3_EXT_METHOD v3_info = { NID_info_access, X509V3_EXT_MULTILINE,
ASN1_ITEM_ref(AUTHORITY_INFO_ACCESS),
0, 0, 0, 0,
0, 0,
(X509V3_EXT_I2V) i2v_AUTHORITY_INFO_ACCESS,
(X509V3_EXT_V2I)v2i_AUTHORITY_INFO_ACCESS,
0, 0,
NULL
};
const X509V3_EXT_METHOD v3_sinfo = { NID_sinfo_access, X509V3_EXT_MULTILINE,
ASN1_ITEM_ref(AUTHORITY_INFO_ACCESS),
0, 0, 0, 0,
0, 0,
(X509V3_EXT_I2V) i2v_AUTHORITY_INFO_ACCESS,
(X509V3_EXT_V2I)v2i_AUTHORITY_INFO_ACCESS,
0, 0,
NULL
};
ASN1_SEQUENCE(ACCESS_DESCRIPTION) = {
ASN1_SIMPLE(ACCESS_DESCRIPTION, method, ASN1_OBJECT),
ASN1_SIMPLE(ACCESS_DESCRIPTION, location, GENERAL_NAME)
} ASN1_SEQUENCE_END(ACCESS_DESCRIPTION)
IMPLEMENT_ASN1_FUNCTIONS(ACCESS_DESCRIPTION)
ASN1_ITEM_TEMPLATE(AUTHORITY_INFO_ACCESS) =
ASN1_EX_TEMPLATE_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, GeneralNames, ACCESS_DESCRIPTION)
ASN1_ITEM_TEMPLATE_END(AUTHORITY_INFO_ACCESS)
IMPLEMENT_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS)
static STACK_OF(CONF_VALUE) *i2v_AUTHORITY_INFO_ACCESS(
X509V3_EXT_METHOD *method, AUTHORITY_INFO_ACCESS *ainfo,
STACK_OF(CONF_VALUE) *ret)
{
ACCESS_DESCRIPTION *desc;
int i, nlen;
char objtmp[80], *ntmp;
CONF_VALUE *vtmp;
STACK_OF(CONF_VALUE) *tret = ret;
for (i = 0; i < sk_ACCESS_DESCRIPTION_num(ainfo); i++) {
STACK_OF(CONF_VALUE) *tmp;
desc = sk_ACCESS_DESCRIPTION_value(ainfo, i);
tmp = i2v_GENERAL_NAME(method, desc->location, tret);
if (tmp == NULL)
goto err;
tret = tmp;
vtmp = sk_CONF_VALUE_value(tret, i);
i2t_ASN1_OBJECT(objtmp, sizeof(objtmp), desc->method);
nlen = (int)(strlen(objtmp) + 3 + strlen(vtmp->name) + 1);
ntmp = (char *)OPENSSL_malloc(nlen);
if (ntmp == NULL)
goto err;
BIO_snprintf(ntmp, nlen, "%s - %s", objtmp, vtmp->name);
OPENSSL_free(vtmp->name);
vtmp->name = ntmp;
}
if (ret == NULL && tret == NULL)
return sk_CONF_VALUE_new_null();
return tret;
err:
X509V3err(X509V3_F_I2V_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE);
if (ret == NULL && tret != NULL)
sk_CONF_VALUE_pop_free(tret, X509V3_conf_free);
return NULL;
}
static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD
*method,
X509V3_CTX *ctx,
STACK_OF(CONF_VALUE)
*nval)
{
AUTHORITY_INFO_ACCESS *ainfo = NULL;
CONF_VALUE *cnf, ctmp;
ACCESS_DESCRIPTION *acc;
int i, objlen;
const int num = sk_CONF_VALUE_num(nval);
char *objtmp, *ptmp;
if ((ainfo = sk_ACCESS_DESCRIPTION_new_reserve(NULL, num)) == NULL) {
X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS, ERR_R_MALLOC_FAILURE);
return NULL;
}
for (i = 0; i < num; i++) {
cnf = sk_CONF_VALUE_value(nval, i);
if ((acc = ACCESS_DESCRIPTION_new()) == NULL) {
X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,
ERR_R_MALLOC_FAILURE);
goto err;
}
sk_ACCESS_DESCRIPTION_push(ainfo, acc); /* Cannot fail due to reserve */
ptmp = strchr(cnf->name, ';');
if (ptmp == NULL) {
X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,
X509V3_R_INVALID_SYNTAX);
goto err;
}
objlen = (int)(ptmp - cnf->name);
ctmp.name = ptmp + 1;
ctmp.value = cnf->value;
if (!v2i_GENERAL_NAME_ex(acc->location, method, ctx, &ctmp, 0))
goto err;
if ((objtmp = OPENSSL_strndup(cnf->name, objlen)) == NULL) {
X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,
ERR_R_MALLOC_FAILURE);
goto err;
}
acc->method = OBJ_txt2obj(objtmp, 0);
if (!acc->method) {
X509V3err(X509V3_F_V2I_AUTHORITY_INFO_ACCESS,
X509V3_R_BAD_OBJECT);
ERR_add_error_data(2, "value=", objtmp);
OPENSSL_free(objtmp);
goto err;
}
OPENSSL_free(objtmp);
}
return ainfo;
err:
sk_ACCESS_DESCRIPTION_pop_free(ainfo, ACCESS_DESCRIPTION_free);
return NULL;
}
int i2a_ACCESS_DESCRIPTION(BIO *bp, const ACCESS_DESCRIPTION *a)
{
i2a_ASN1_OBJECT(bp, a->method);
return 2;
}
| 34.560241 | 89 | 0.59613 |
d67861baa88d0cd181adef219d4de1872f684ff8 | 15,443 | c | C | release/src/linux/linux/drivers/char/hp_keyb.c | ghsecuritylab/tomato_egg | 50473a46347f4631eb4878a0f47955cc64c87293 | [
"FSFAP"
] | 278 | 2015-11-03T03:01:20.000Z | 2022-01-20T18:21:05.000Z | release/src/linux/linux/drivers/char/hp_keyb.c | ghsecuritylab/tomato_egg | 50473a46347f4631eb4878a0f47955cc64c87293 | [
"FSFAP"
] | 374 | 2015-11-03T12:37:22.000Z | 2021-12-17T14:18:08.000Z | release/src/linux/linux/drivers/char/hp_keyb.c | ghsecuritylab/tomato_egg | 50473a46347f4631eb4878a0f47955cc64c87293 | [
"FSFAP"
] | 96 | 2015-11-22T07:47:26.000Z | 2022-01-20T19:52:19.000Z | /*
* linux/drivers/char/hp_keyb.c
* helper-functions for the keyboard/psaux driver for HP-PARISC workstations
*
* based on pc_keyb.c by Geert Uytterhoeven & Martin Mares
*
* 2000/10/26 Debacker Xavier <debackex@esiee.fr>
* Marteau Thomas <marteaut@esiee.fr>
* Djoudi Malek <djoudim@esiee.fr>
* - fixed some keysym defines
*
* 2001/04/28 Debacker Xavier <debackex@esiee.fr>
* - scancode translation rewritten in handle_at_scancode()
*/
#include <linux/config.h>
#include <linux/sched.h>
#include <linux/interrupt.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/mm.h>
#include <linux/slab.h>
#include <linux/ptrace.h>
#include <linux/signal.h>
#include <linux/timer.h>
#include <linux/random.h>
#include <linux/ctype.h>
#include <linux/kbd_ll.h>
#include <linux/init.h>
#include <asm/bitops.h>
#include <asm/irq.h>
#include <asm/hardware.h>
#include <asm/io.h>
#include <asm/system.h>
#define KBD_REPORT_ERR
#define KBD_REPORT_UNKN
#define KBD_ESCAPEE0 0xe0 /* in */
#define KBD_ESCAPEE1 0xe1 /* in */
#define ESCE0(x) (0xe000|(x))
#define ESCE1(x) (0xe100|(x))
#define KBD_BAT 0xaa /* in */
#define KBD_SETLEDS 0xed /* out */
#define KBD_ECHO 0xee /* in/out */
#define KBD_BREAK 0xf0 /* in */
#define KBD_TYPRATEDLY 0xf3 /* out */
#define KBD_SCANENABLE 0xf4 /* out */
#define KBD_DEFDISABLE 0xf5 /* out */
#define KBD_DEFAULT 0xf6 /* out */
#define KBD_ACK 0xfa /* in */
#define KBD_DIAGFAIL 0xfd /* in */
#define KBD_RESEND 0xfe /* in/out */
#define KBD_RESET 0xff /* out */
#define CODE_BREAK 1
#define CODE_ESCAPEE0 2
#define CODE_ESCAPEE1 4
#define CODE_ESCAPE12 8
#define K_NONE 0x7f
#define K_ESC 0x01
#define K_F1 0x3b
#define K_F2 0x3c
#define K_F3 0x3d
#define K_F4 0x3e
#define K_F5 0x3f
#define K_F6 0x40
#define K_F7 0x41
#define K_F8 0x42
#define K_F9 0x43
#define K_F10 0x44
#define K_F11 0x57
#define K_F12 0x58
#define K_PRNT 0x54
#define K_SCRL 0x46
#define K_BRK 0x77
#define K_AGR 0x29
#define K_1 0x02
#define K_2 0x03
#define K_3 0x04
#define K_4 0x05
#define K_5 0x06
#define K_6 0x07
#define K_7 0x08
#define K_8 0x09
#define K_9 0x0a
#define K_0 0x0b
#define K_MINS 0x0c
#define K_EQLS 0x0d
#define K_BKSP 0x0e
#define K_INS 0x6e
#define K_HOME 0x66
#define K_PGUP 0x68
#define K_NUML 0x45
#define KP_SLH 0x62
#define KP_STR 0x37
#define KP_MNS 0x4a
#define K_TAB 0x0f
#define K_Q 0x10
#define K_W 0x11
#define K_E 0x12
#define K_R 0x13
#define K_T 0x14
#define K_Y 0x15
#define K_U 0x16
#define K_I 0x17
#define K_O 0x18
#define K_P 0x19
#define K_LSBK 0x1a
#define K_RSBK 0x1b
#define K_ENTR 0x1c
#define K_DEL 111
#define K_END 0x6b
#define K_PGDN 0x6d
#define KP_7 0x47
#define KP_8 0x48
#define KP_9 0x49
#define KP_PLS 0x4e
#define K_CAPS 0x3a
#define K_A 0x1e
#define K_S 0x1f
#define K_D 0x20
#define K_F 0x21
#define K_G 0x22
#define K_H 0x23
#define K_J 0x24
#define K_K 0x25
#define K_L 0x26
#define K_SEMI 0x27
#define K_SQOT 0x28
#define K_HASH K_NONE
#define KP_4 0x4b
#define KP_5 0x4c
#define KP_6 0x4d
#define K_LSFT 0x2a
#define K_BSLH 0x2b
#define K_Z 0x2c
#define K_X 0x2d
#define K_C 0x2e
#define K_V 0x2f
#define K_B 0x30
#define K_N 0x31
#define K_M 0x32
#define K_COMA 0x33
#define K_DOT 0x34
#define K_FSLH 0x35
#define K_RSFT 0x36
#define K_UP 0x67
#define KP_1 0x4f
#define KP_2 0x50
#define KP_3 0x51
#define KP_ENT 0x60
#define K_LCTL 0x1d
#define K_LALT 0x38
#define K_SPCE 0x39
#define K_RALT 0x64
#define K_RCTL 0x61
#define K_LEFT 0x69
#define K_DOWN 0x6c
#define K_RGHT 0x6a
#define KP_0 0x52
#define KP_DOT 0x53
static unsigned char keycode_translate[256] =
{
/* 00 */ K_NONE, K_F9 , K_NONE, K_F5 , K_F3 , K_F1 , K_F2 , K_F12 ,
/* 08 */ K_NONE, K_F10 , K_F8 , K_F6 , K_F4 , K_TAB , K_AGR , K_NONE,
/* 10 */ K_NONE, K_LALT, K_LSFT, K_NONE, K_LCTL, K_Q , K_1 , K_NONE,
/* 18 */ K_NONE, K_NONE, K_Z , K_S , K_A , K_W , K_2 , K_NONE,
/* 20 */ K_NONE, K_C , K_X , K_D , K_E , K_4 , K_3 , K_NONE,
/* 28 */ K_NONE, K_SPCE, K_V , K_F , K_T , K_R , K_5 , K_NONE,
/* 30 */ K_NONE, K_N , K_B , K_H , K_G , K_Y , K_6 , K_NONE,
/* 38 */ K_NONE, K_NONE, K_M , K_J , K_U , K_7 , K_8 , K_NONE,
/* 40 */ K_NONE, K_COMA, K_K , K_I , K_O , K_0 , K_9 , K_NONE,
/* 48 */ K_PGUP, K_DOT , K_FSLH, K_L , K_SEMI, K_P , K_MINS, K_NONE,
/* 50 */ K_NONE, K_NONE, K_SQOT, K_NONE, K_LSBK, K_EQLS, K_NONE, K_NONE,
/* 58 */ K_CAPS, K_RSFT, K_ENTR, K_RSBK, K_NONE, K_BSLH, K_NONE, K_NONE,
/* 60 */ K_NONE, K_HASH, K_NONE, K_NONE, K_NONE, K_NONE, K_BKSP, K_NONE,
/* 68 */ K_NONE, KP_1 , K_NONE, KP_4 , KP_7 , K_NONE, K_NONE, K_NONE,
/* 70 */ KP_0 , KP_DOT, KP_2 , KP_5 , KP_6 , KP_8 , K_ESC , K_NUML,
/* 78 */ K_F11 , KP_PLS, KP_3 , KP_MNS, KP_STR, KP_9 , K_SCRL, K_PRNT,
/* 80 */ K_NONE, K_NONE, K_NONE, K_F7 , K_NONE, K_NONE, K_NONE, K_NONE,
/* 88 */ K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE,
/* 90 */ K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE,
/* 98 */ K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE,
/* a0 */ K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE,
/* a8 */ K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE,
/* b0 */ K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE,
/* b8 */ K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE,
/* c0 */ K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE,
/* c8 */ K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE,
/* d0 */ K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE,
/* d8 */ K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE,
/* e0 */ K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE,
/* e8 */ K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE,
/* f0 */ K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE,
/* f8 */ K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, K_NONE, KBD_RESEND, K_NONE
};
/* ----- the following code stolen from pc_keyb.c */
#ifdef CONFIG_MAGIC_SYSRQ
unsigned char hp_ps2kbd_sysrq_xlate[128] =
"\000\0331234567890-=\177\t" /* 0x00 - 0x0f */
"qwertyuiop[]\r\000as" /* 0x10 - 0x1f */
"dfghjkl;'`\000\\zxcv" /* 0x20 - 0x2f */
"bnm,./\000*\000 \000\201\202\203\204\205" /* 0x30 - 0x3f */
"\206\207\210\211\212\000\000789-456+1" /* 0x40 - 0x4f */
"230\177\000\000\213\214\000\000\000\000\000\000\000\000\000\000" /* 0x50 - 0x5f */
"\r\000/"; /* 0x60 - 0x6f */
#endif
/*
* Translation of escaped scancodes to keycodes.
* This is now user-settable.
* The keycodes 1-88,96-111,119 are fairly standard, and
* should probably not be changed - changing might confuse X.
* X also interprets scancode 0x5d (KEY_Begin).
*
* For 1-88 keycode equals scancode.
*/
#define E0_KPENTER 96
#define E0_RCTRL 97
#define E0_KPSLASH 98
#define E0_PRSCR 99
#define E0_RALT 100
#define E0_BREAK 101 /* (control-pause) */
#define E0_HOME 102
#define E0_UP 103
#define E0_PGUP 104
#define E0_LEFT 105
#define E0_RIGHT 106
#define E0_END 107
#define E0_DOWN 108
#define E0_PGDN 109
#define E0_INS 110
#define E0_DEL 111
#define E1_PAUSE 119
/*
* The keycodes below are randomly located in 89-95,112-118,120-127.
* They could be thrown away (and all occurrences below replaced by 0),
* but that would force many users to use the `setkeycodes' utility, where
* they needed not before. It does not matter that there are duplicates, as
* long as no duplication occurs for any single keyboard.
*/
#define SC_LIM 89 /* 0x59 == 89 */
#define FOCUS_PF1 85 /* actual code! */
#define FOCUS_PF2 89
#define FOCUS_PF3 90
#define FOCUS_PF4 91
#define FOCUS_PF5 92
#define FOCUS_PF6 93
#define FOCUS_PF7 94
#define FOCUS_PF8 95
#define FOCUS_PF9 120
#define FOCUS_PF10 121
#define FOCUS_PF11 122
#define FOCUS_PF12 123
#define JAP_86 124
/* On one Compaq UK keyboard, at least, bar/backslash generates scancode
* 0x7f. 0x7f generated on some .de and .no keyboards also.
*/
#define UK_86 86
/* tfj@olivia.ping.dk:
* The four keys are located over the numeric keypad, and are
* labelled A1-A4. It's an rc930 keyboard, from
* Regnecentralen/RC International, Now ICL.
* Scancodes: 59, 5a, 5b, 5c.
*/
#define RGN1 124
#define RGN2 125
#define RGN3 126
#define RGN4 127
static unsigned char high_keys[128 - SC_LIM] = {
RGN1, RGN2, RGN3, RGN4, 0, 0, 0, /* 0x59-0x5f */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */
0, 0, 0, 0, 0, FOCUS_PF11, 0, FOCUS_PF12, /* 0x68-0x6f */
0, 0, 0, FOCUS_PF2, FOCUS_PF9, 0, 0, FOCUS_PF3, /* 0x70-0x77 */
FOCUS_PF4, FOCUS_PF5, FOCUS_PF6, FOCUS_PF7, /* 0x78-0x7b */
FOCUS_PF8, JAP_86, FOCUS_PF10, UK_86 /* 0x7c-0x7f */
};
/* BTC */
#define E0_MACRO 112
/* LK450 */
#define E0_F13 113
#define E0_F14 114
#define E0_HELP 115
#define E0_DO 116
#define E0_F17 117
#define E0_KPMINPLUS 118
/*
* My OmniKey generates e0 4c for the "OMNI" key and the
* right alt key does nada. [kkoller@nyx10.cs.du.edu]
*/
#define E0_OK 124
/*
* New microsoft keyboard is rumoured to have
* e0 5b (left window button), e0 5c (right window button),
* e0 5d (menu button). [or: LBANNER, RBANNER, RMENU]
* [or: Windows_L, Windows_R, TaskMan]
*/
#define E0_MSLW 125
#define E0_MSRW 126
#define E0_MSTM 127
static unsigned char e0_keys[128] = {
0, 0, 0, 0, 0, 0, 0, 0, /* 0x00-0x07 */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x08-0x0f */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x10-0x17 */
0, 0, 0, 0, E0_KPENTER, E0_RCTRL, 0, 0, /* 0x18-0x1f */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x20-0x27 */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x28-0x2f */
0, 0, 0, 0, 0, E0_KPSLASH, 0, E0_PRSCR, /* 0x30-0x37 */
E0_RALT, 0, 0, 0, 0, E0_F13, E0_F14, E0_HELP, /* 0x38-0x3f */
E0_DO, E0_F17, 0, 0, 0, 0, E0_BREAK, E0_HOME, /* 0x40-0x47 */
E0_UP, E0_PGUP, 0, E0_LEFT, E0_OK, E0_RIGHT, E0_KPMINPLUS, E0_END,/* 0x48-0x4f */
E0_DOWN, E0_PGDN, E0_INS, E0_DEL, 0, 0, 0, 0, /* 0x50-0x57 */
0, 0, 0, E0_MSLW, E0_MSRW, E0_MSTM, 0, 0, /* 0x58-0x5f */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x60-0x67 */
0, 0, 0, 0, 0, 0, 0, E0_MACRO, /* 0x68-0x6f */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x70-0x77 */
0, 0, 0, 0, 0, 0, 0, E0_MSLW /* 0x78-0x7f */
};
int pckbd_setkeycode(unsigned int scancode, unsigned int keycode)
{
if (scancode < SC_LIM || scancode > 255 || keycode > 127)
return -EINVAL;
if (scancode < 128)
high_keys[scancode - SC_LIM] = keycode;
else
e0_keys[scancode - 128] = keycode;
return 0;
}
int pckbd_getkeycode(unsigned int scancode)
{
return
(scancode < SC_LIM || scancode > 255) ? -EINVAL :
(scancode < 128) ? high_keys[scancode - SC_LIM] :
e0_keys[scancode - 128];
}
int pckbd_translate(unsigned char scancode, unsigned char *keycode,
char raw_mode)
{
static int prev_scancode;
/* special prefix scancodes.. */
if (scancode == 0xe0 || scancode == 0xe1) {
prev_scancode = scancode;
return 0;
}
/* 0xFF is sent by a few keyboards, ignore it. 0x00 is error */
if (scancode == 0x00 || scancode == 0xff) {
prev_scancode = 0;
return 0;
}
scancode &= 0x7f;
if (prev_scancode) {
/*
* usually it will be 0xe0, but a Pause key generates
* e1 1d 45 e1 9d c5 when pressed, and nothing when released
*/
if (prev_scancode != 0xe0) {
if (prev_scancode == 0xe1 && scancode == 0x1d) {
prev_scancode = 0x100;
return 0;
} else if (prev_scancode == 0x100 && scancode == 0x45) {
*keycode = E1_PAUSE;
prev_scancode = 0;
} else {
#ifdef KBD_REPORT_UNKN
if (!raw_mode)
printk(KERN_INFO "keyboard: unknown e1 escape sequence\n");
#endif
prev_scancode = 0;
return 0;
}
} else {
prev_scancode = 0;
/*
* The keyboard maintains its own internal caps lock and
* num lock statuses. In caps lock mode E0 AA precedes make
* code and E0 2A follows break code. In num lock mode,
* E0 2A precedes make code and E0 AA follows break code.
* We do our own book-keeping, so we will just ignore these.
*/
/*
* For my keyboard there is no caps lock mode, but there are
* both Shift-L and Shift-R modes. The former mode generates
* E0 2A / E0 AA pairs, the latter E0 B6 / E0 36 pairs.
* So, we should also ignore the latter. - aeb@cwi.nl
*/
if (scancode == 0x2a || scancode == 0x36)
return 0;
if (e0_keys[scancode])
*keycode = e0_keys[scancode];
else {
#ifdef KBD_REPORT_UNKN
if (!raw_mode)
printk(KERN_INFO "keyboard: unknown scancode e0 %02x\n",
scancode);
#endif
return 0;
}
}
} else if (scancode >= SC_LIM) {
/* This happens with the FOCUS 9000 keyboard
Its keys PF1..PF12 are reported to generate
55 73 77 78 79 7a 7b 7c 74 7e 6d 6f
Moreover, unless repeated, they do not generate
key-down events, so we have to zero up_flag below */
/* Also, Japanese 86/106 keyboards are reported to
generate 0x73 and 0x7d for \ - and \ | respectively. */
/* Also, some Brazilian keyboard is reported to produce
0x73 and 0x7e for \ ? and KP-dot, respectively. */
*keycode = high_keys[scancode - SC_LIM];
if (!*keycode) {
if (!raw_mode) {
#ifdef KBD_REPORT_UNKN
printk(KERN_INFO "keyboard: unrecognized scancode (%02x)"
" - ignored\n", scancode);
#endif
}
return 0;
}
} else
*keycode = scancode;
return 1;
}
/* ----- end of stolen part ------ */
void kbd_reset_setup(void)
{
}
void handle_at_scancode(int keyval)
{
static int brk;
static int esc0;
static int esc1;
int scancode = 0;
switch (keyval) {
case KBD_BREAK :
/* sets the "release_key" bit when a key is
released. HP keyboard send f0 followed by
the keycode while AT keyboard send the keycode
with this bit set. */
brk = 0x80;
return;
case KBD_ESCAPEE0 :
/* 2chars sequence, commonly used to differenciate
the two ALT keys and the two ENTER keys and so
on... */
esc0 = 2; /* e0-xx are 2 chars */
scancode = keyval;
break;
case KBD_ESCAPEE1 :
/* 3chars sequence, only used by the Pause key. */
esc1 = 3; /* e1-xx-xx are 3 chars */
scancode = keyval;
break;
#if 0
case KBD_RESEND :
/* dunno what to do when it happens. RFC */
printk(KERN_INFO "keyboard: KBD_RESEND received.\n");
return;
#endif
case 0x14 :
/* translate e1-14-77-e1-f0-14-f0-77 to
e1-1d-45-e1-9d-c5 (the Pause key) */
if (esc1==2) scancode = brk | 0x1d;
break;
case 0x77 :
if (esc1==1) scancode = brk | 0x45;
break;
case 0x12 :
/* an extended key is e0-12-e0-xx e0-f0-xx-e0-f0-12
on HP, while it is e0-2a-e0-xx e0-(xx|80)-f0-aa
on AT. */
if (esc0==1) scancode = brk | 0x2a;
break;
}
/* translates HP scancodes to AT scancodes */
if (!scancode) scancode = brk | keycode_translate[keyval];
if (!scancode) printk(KERN_INFO "keyboard: unexpected key code %02x\n",keyval);
/* now behave like an AT keyboard */
handle_scancode(scancode,!(scancode&0x80));
if (esc0) esc0--;
if (esc1) esc1--;
/* release key bit must be unset for the next key */
brk = 0;
}
| 29.359316 | 84 | 0.644823 |
d03a4fd8391ff06ffcbb1b687a1b38d4150888c3 | 124 | h | C | src/orbits/constants.h | Tuqz/Helion | 9ef6ec1f5483eb3ab3883d81e04122d36e2aa703 | [
"BSD-3-Clause"
] | 2 | 2015-06-03T19:08:15.000Z | 2019-02-25T16:52:54.000Z | src/orbits/constants.h | Tuqz/helion | 9ef6ec1f5483eb3ab3883d81e04122d36e2aa703 | [
"BSD-3-Clause"
] | 1 | 2015-06-12T00:21:00.000Z | 2015-06-13T16:54:51.000Z | src/orbits/constants.h | Tuqz/helion | 9ef6ec1f5483eb3ab3883d81e04122d36e2aa703 | [
"BSD-3-Clause"
] | 1 | 2015-06-08T19:13:19.000Z | 2015-06-08T19:13:19.000Z | #pragma once
#include <cmath>
namespace helion {
static const double G = 6.67e-11;
static const double pi = atan(1)*4;
}
| 15.5 | 36 | 0.693548 |
30f310a9c6444595354a1514bcdba16bf172c4ee | 310 | h | C | include/list.h | VanirLab/vanir-gui-daemon | 234786ae758c2c9c0cd1857bc6886930b3cb4fee | [
"MIT"
] | null | null | null | include/list.h | VanirLab/vanir-gui-daemon | 234786ae758c2c9c0cd1857bc6886930b3cb4fee | [
"MIT"
] | null | null | null | include/list.h | VanirLab/vanir-gui-daemon | 234786ae758c2c9c0cd1857bc6886930b3cb4fee | [
"MIT"
] | null | null | null | struct genlist {
long key;
void *data;
struct genlist *next;
struct genlist *prev;
};
struct genlist *list_new(void);
struct genlist *list_lookup(struct genlist *l, long key);
struct genlist *list_insert(struct genlist *l, long key, void *data);
void list_remove(struct genlist *);
| 25.833333 | 70 | 0.687097 |
317f6903fff39acd8a41e1ad4d73f3d1dd480f07 | 6,885 | h | C | aprinter/meta/ListForEach.h | ambrop72/aprinter | b97c3111dad96aedf653c40b976317d73ac91715 | [
"BSD-2-Clause"
] | 133 | 2015-02-02T04:20:19.000Z | 2021-02-28T22:21:49.000Z | aprinter/meta/ListForEach.h | ambrop72/aprinter | b97c3111dad96aedf653c40b976317d73ac91715 | [
"BSD-2-Clause"
] | 20 | 2015-01-06T08:41:26.000Z | 2019-07-25T07:10:26.000Z | aprinter/meta/ListForEach.h | ambrop72/aprinter | b97c3111dad96aedf653c40b976317d73ac91715 | [
"BSD-2-Clause"
] | 46 | 2015-01-05T11:26:21.000Z | 2020-06-22T04:58:23.000Z | /*
* Copyright (c) 2013 Ambroz Bizjak
* 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 AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef AMBROLIB_LIST_FOR_EACH_H
#define AMBROLIB_LIST_FOR_EACH_H
#include <aprinter/meta/TypeList.h>
#include <aprinter/meta/BasicMetaUtils.h>
#include <aprinter/base/Hints.h>
#include <aprinter/base/Preprocessor.h>
namespace APrinter {
template <typename TheList>
struct ListForEach;
template <typename Head, typename Tail>
struct ListForEach<ConsTypeList<Head, Tail>> {
template <typename Func, typename... Args>
AMBRO_ALWAYS_INLINE static void call_forward (Func func, Args... args)
{
func(WrapType<Head>(), args...);
ListForEach<Tail>::call_forward(func, args...);
}
template <typename Func, typename... Args>
AMBRO_ALWAYS_INLINE static void call_reverse (Func func, Args... args)
{
ListForEach<Tail>::call_reverse(func, args...);
func(WrapType<Head>(), args...);
}
template <typename Func, typename... Args>
AMBRO_ALWAYS_INLINE static bool call_forward_interruptible (Func func, Args... args)
{
if (!func(WrapType<Head>(), args...)) {
return false;
}
return ListForEach<Tail>::call_forward_interruptible(func, args...);
}
template <typename AccRes, typename Func, typename... Args>
AMBRO_ALWAYS_INLINE static auto call_forward_accres (AccRes acc_res, Func func, Args... args) -> decltype(ListForEach<Tail>::call_forward_accres(func(WrapType<Head>(), acc_res, args...), func, args...))
{
return ListForEach<Tail>::call_forward_accres(func(WrapType<Head>(), acc_res, args...), func, args...);
}
};
template <>
struct ListForEach<EmptyTypeList> {
template <typename Func, typename... Args>
AMBRO_ALWAYS_INLINE static void call_forward (Func func, Args... args)
{
}
template <typename Func, typename... Args>
AMBRO_ALWAYS_INLINE static void call_reverse (Func func, Args... args)
{
}
template <typename Func, typename... Args>
AMBRO_ALWAYS_INLINE static bool call_forward_interruptible (Func func, Args... args)
{
return true;
}
template <typename AccRes, typename Func, typename... Args>
AMBRO_ALWAYS_INLINE static auto call_forward_accres (AccRes acc_res, Func func, Args... args) -> decltype(acc_res)
{
return acc_res;
}
};
template <typename List, int Offset, typename Ret, typename IndexType>
struct ListForOneHelper;
template <typename Head, typename Tail, int Offset, typename Ret, typename IndexType>
struct ListForOneHelper<ConsTypeList<Head, Tail>, Offset, Ret, IndexType> {
template <typename Func, typename... Args>
AMBRO_ALWAYS_INLINE static Ret call (IndexType index, Func func, Args... args)
{
if (index == Offset) {
return func(WrapType<Head>(), args...);
}
return ListForOneHelper<Tail, Offset + 1, Ret, IndexType>::call(index, func, args...);
}
template <typename Func, typename... Args>
AMBRO_ALWAYS_INLINE static bool call_bool (IndexType index, Func func, Args... args)
{
if (index == Offset) {
func(WrapType<Head>(), args...);
return true;
}
return ListForOneHelper<Tail, Offset + 1, Ret, IndexType>::call_bool(index, func, args...);
}
};
template <int Offset, typename Ret, typename IndexType>
struct ListForOneHelper<EmptyTypeList, Offset, Ret, IndexType> {
template <typename Func, typename... Args>
AMBRO_ALWAYS_INLINE static Ret call (IndexType index, Func func, Args... args)
{
__builtin_unreachable();
}
template <typename Func, typename... Args>
AMBRO_ALWAYS_INLINE static bool call_bool (IndexType index, Func func, Args... args)
{
return false;
}
};
template <typename List, typename Func, typename... Args>
AMBRO_ALWAYS_INLINE void ListFor (Func func, Args... args)
{
return ListForEach<List>::call_forward(func, args...);
}
template <typename List, typename Func, typename... Args>
AMBRO_ALWAYS_INLINE void ListForReverse (Func func, Args... args)
{
return ListForEach<List>::call_reverse(func, args...);
}
template <typename List, typename Func, typename... Args>
AMBRO_ALWAYS_INLINE bool ListForBreak (Func func, Args... args)
{
return ListForEach<List>::call_forward_interruptible(func, args...);
}
template <typename List, typename InitialAccRes, typename Func, typename... Args>
AMBRO_ALWAYS_INLINE auto ListForFold (InitialAccRes initial_acc_res, Func func, Args... args) -> decltype(ListForEach<List>::call_forward_accres(initial_acc_res, func, args...))
{
return ListForEach<List>::call_forward_accres(initial_acc_res, func, args...);
}
template <typename List, int Offset = 0, typename Ret = void, typename IndexType, typename Func, typename... Args>
AMBRO_ALWAYS_INLINE Ret ListForOne (IndexType index, Func func, Args... args)
{
return ListForOneHelper<List, Offset, Ret, IndexType>::call(index, func, args...);
}
template <typename List, int Offset = 0, typename IndexType, typename Func, typename... Args>
AMBRO_ALWAYS_INLINE bool ListForOneBool (IndexType index, Func func, Args... args)
{
return ListForOneHelper<List, Offset, void, IndexType>::call_bool(index, func, args...);
}
#define APRINTER_TL(TypeAlias, code) (auto aprinter__type_lambda_arg) { using TypeAlias = typename decltype(aprinter__type_lambda_arg)::Type; code; }
#define APRINTER_TLA(TypeAlias, args, code) (auto aprinter__type_lambda_arg, APRINTER_REMOVE_PARENS args) { using TypeAlias = typename decltype(aprinter__type_lambda_arg)::Type; code; }
}
#endif
| 38.679775 | 206 | 0.71053 |
c805ca86687cc307c1068142d653ffb36a6b5bd1 | 6,294 | h | C | windows/core/ntgdi/client/metarec.h | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | windows/core/ntgdi/client/metarec.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | windows/core/ntgdi/client/metarec.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | /******************************Module*Header*******************************\
* Module Name: metarec.h
*
* Metafile recording functions.
*
* Copyright (c) 1991-1999 Microsoft Corporation
\**************************************************************************/
BOOL MF_GdiComment(HDC hdc, UINT nSize, CONST BYTE *lpData);
BOOL MF_GdiCommentWindowsMetaFile(HDC hdc, UINT nSize, CONST BYTE *lpData);
BOOL MF_GdiCommentBeginGroupEMF(HDC hdc, PENHMETAHEADER pemfHeader);
BOOL MF_GdiCommentEndGroupEMF(HDC hdc);
// SaveDC
// BeginPath
// EndPath
// CloseFigure
// FlattenPath
// WidenPath
// AbortPath
BOOL MF_Record(HDC hdc,DWORD mrType);
// FillPath
// StrokeAndFillPath
// StrokePath
BOOL MF_BoundRecord(HDC hdc,DWORD mrType);
// PolyBezier
// Polygon
// Polyline
// PolyBezierTo
// PolylineTo
BOOL MF_Poly(HDC hdc, CONST POINT *pptl, DWORD cptl, DWORD mrType);
// PolyPolygon
// PolyPolyline
BOOL MF_PolyPoly(HDC hdc, CONST POINT *pptl, CONST DWORD *pc, DWORD cPoly, DWORD mrType);
BOOL MF_PolyDraw(HDC hdc, CONST POINT *pptl, CONST BYTE *pb, DWORD cptl);
// SetMapperFlags
// SetMapMode
// SetBkMode
// SetPolyFillMode
// SetROP2
// SetStretchBltMode
// SetTextAlign
// SetTextColor
// SetBkColor
// RestoreDC
// SetArcDirection
// SetMiterLimit
BOOL MF_SetD(HDC hdc,DWORD d1,DWORD mrType);
// OffsetWindowOrgEx
// OffsetViewportOrgEx
// SetWindowExtEx
// SetWindowOrgEx
// SetViewportExtEx
// SetViewportOrgEx
// SetBrushOrgEx
// MoveToEx
// LineTo
BOOL MF_SetDD(HDC hdc,DWORD d1,DWORD d2,DWORD mrType);
// ScaleViewportExtEx
// ScaleWindowExtEx
BOOL MF_SetDDDD(HDC hdc,DWORD d1,DWORD d2,DWORD d3,DWORD d4,DWORD mrType);
BOOL MF_RestoreDC(HDC hdc,int iLevel);
BOOL MF_SetViewportExtEx(HDC hdc,int x,int y);
BOOL MF_SetViewportOrgEx(HDC hdc,int x,int y);
BOOL MF_SetWindowExtEx(HDC hdc,int x,int y);
BOOL MF_SetWindowOrgEx(HDC hdc,int x,int y);
BOOL MF_OffsetViewportOrgEx(HDC hdc,int x,int y);
BOOL MF_OffsetWindowOrgEx(HDC hdc,int x,int y);
BOOL MF_SetBrushOrgEx(HDC hdc,int x,int y);
// ExcludeClipRect
// IntersectClipRect
BOOL MF_AnyClipRect(HDC hdc,int x1,int y1,int x2,int y2,DWORD mrType);
// SetMetaRgn
BOOL MF_SetMetaRgn(HDC hdc);
// SelectClipPath
BOOL MF_SelectClipPath(HDC hdc,int iMode);
// OffsetClipRgn
BOOL MF_OffsetClipRgn(HDC hdc,int x1,int y1);
// SetPixel
// SetPixelV
BOOL MF_SetPixelV(HDC hdc,int x,int y,COLORREF color);
// CloseEnhMetaFile
BOOL MF_EOF(HDC hdc, ULONG cEntries, PPALETTEENTRY pPalEntries);
BOOL MF_SetWorldTransform(HDC hdc, CONST XFORM *pxform);
BOOL MF_ModifyWorldTransform(HDC hdc, CONST XFORM *pxform, DWORD iMode);
// SelectObject
// SelectPalette
BOOL MF_SelectAnyObject(HDC hdc,HANDLE h,DWORD mrType);
BOOL MF_DeleteObject(HANDLE h);
DWORD MF_InternalCreateObject(HDC hdc,HANDLE h);
BOOL MF_AngleArc(HDC hdc,int x,int y,DWORD r,FLOAT eA,FLOAT eB);
// SetArcDirection
BOOL MF_ValidateArcDirection(HDC hdc);
// Ellipse
// Rectangle
BOOL MF_EllipseRect(HDC hdc,int x1,int y1,int x2,int y2,DWORD mrType);
BOOL MF_RoundRect(HDC hdc,int x1,int y1,int x2,int y2,int x3,int y3);
// Arc
// ArcTo
// Chord
// Pie
BOOL MF_ArcChordPie(HDC hdc,int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4,DWORD mrType);
BOOL MF_ResizePalette(HPALETTE hpal,UINT c);
BOOL MF_RealizePalette(HPALETTE hpal);
BOOL MF_SetPaletteEntries(HPALETTE hpal, UINT iStart, UINT cEntries, CONST PALETTEENTRY *pPalEntries);
BOOL MF_ColorCorrectPalette(HDC hdc,HPALETTE hpal,ULONG FirstEntry,ULONG NumberOfEntries);
// InvertRgn
// PaintRgn
BOOL MF_InvertPaintRgn(HDC hdc,HRGN hrgn,DWORD mrType);
BOOL MF_FillRgn(HDC hdc,HRGN hrgn,HBRUSH hbrush);
BOOL MF_FrameRgn(HDC hdc,HRGN hrgn,HBRUSH hbrush,int cx,int cy);
// SelectClipRgn
// ExtSelectClipRgn
// SelectObject(hdc,hrgn)
BOOL MF_ExtSelectClipRgn(HDC hdc,HRGN hrgn,int iMode);
// BitBlt
// PatBlt
// StretchBlt
// MaskBlt
// PlgBlt
BOOL MF_AnyBitBlt(HDC hdcDst,int xDst,int yDst,int cxDst,int cyDst,
CONST POINT *pptDst, HDC hdcSrc,int xSrc,int ySrc,int cxSrc,int cySrc,
HBITMAP hbmMask,int xMask,int yMask,DWORD rop,DWORD mrType);
// SetDIBitsToDevice
// StretchDIBits
BOOL MF_AnyDIBits(HDC hdcDst,int xDst,int yDst,int cxDst,int cyDst,
int xDib,int yDib,int cxDib,int cyDib,DWORD iStartScan,DWORD cScans,
CONST VOID * pBitsDib, CONST BITMAPINFO *pBitsInfoDib,DWORD iUsageDib,DWORD rop,DWORD mrType);
// TextOutA
// TextOutW
// ExtTextOutA
// ExtTextOutW
BOOL MF_ExtTextOut(HDC hdc,int x,int y,UINT fl,CONST RECT *prcl,LPCSTR psz,int c, CONST INT *pdx,DWORD mrType);
// PolyTextOutA
// PolyTextOutW
BOOL MF_PolyTextOut(HDC hdc,CONST POLYTEXTA *ppta,int c,DWORD mrType);
// ExtFloodFill
// FloodFill
BOOL MF_ExtFloodFill(HDC hdc,int x,int y,COLORREF color,DWORD iMode);
// SetColorAdjustment
BOOL MF_SetColorAdjustment(HDC hdc, CONST COLORADJUSTMENT *pca);
// SetFontXform
BOOL MF_SetFontXform(HDC hdc,FLOAT exScale,FLOAT eyScale);
// EMF Spooling Stuff
BOOL MF_StartDoc(HDC hdc, CONST DOCINFOW *pDocInfo );
BOOL MF_EndPage(HDC hdc);
BOOL MF_StartPage(HDC hdc);
BOOL MF_WriteEscape(HDC hdc, int nEscape, int nCount, LPCSTR lpInData, int type );
BOOL MF_ForceUFIMapping(HDC hdc, PUNIVERSAL_FONT_ID pufi );
BOOL MF_SetLinkedUFIs(HDC hdc, PUNIVERSAL_FONT_ID pufi, UINT uNumLinkedUFIs );
// SetPixelFormat
BOOL MF_SetPixelFormat(HDC hdc,
int iPixelFormat,
CONST PIXELFORMATDESCRIPTOR *ppfd);
BOOL MF_WriteNamedEscape(HDC hdc, LPWSTR pwszDriver, int nEscape, int nCount,
LPCSTR lpInData);
// SetICMProfile
BOOL MF_SetICMProfile(HDC hdc,LPBYTE lpData,PVOID pColorSpace,DWORD dwRecord);
// ColorMatchToTarget
BOOL MF_ColorMatchToTarget(HDC hdc, DWORD uiAction, PVOID pColorSpace, DWORD dwRecord);
// CreateColorSpace
BOOL MF_InternalCreateColorSpace(HDC hdc,HGDIOBJ h,DWORD imhe);
// Image APIs
BOOL MF_AlphaBlend(HDC,LONG,LONG,LONG,LONG,HDC,LONG,LONG,LONG,LONG,BLENDFUNCTION);
BOOL MF_GradientFill(HDC,CONST PTRIVERTEX,ULONG, CONST PVOID,ULONG,ULONG);
BOOL MF_TransparentImage(HDC,LONG,LONG,LONG,LONG,HDC,LONG,LONG,LONG,LONG,ULONG,ULONG);
| 26.556962 | 112 | 0.719892 |
0835417adaad75286aa64a7da550054e65c4ce57 | 542 | h | C | XOChatModule/Classes/Chat/Box/View/ZXChatBoxFaceView.h | Hjt830/XOChatModule | d5dcf1f9e28acc162d45688687e888e11cd75fb9 | [
"MIT"
] | null | null | null | XOChatModule/Classes/Chat/Box/View/ZXChatBoxFaceView.h | Hjt830/XOChatModule | d5dcf1f9e28acc162d45688687e888e11cd75fb9 | [
"MIT"
] | null | null | null | XOChatModule/Classes/Chat/Box/View/ZXChatBoxFaceView.h | Hjt830/XOChatModule | d5dcf1f9e28acc162d45688687e888e11cd75fb9 | [
"MIT"
] | null | null | null | //
// ZXChatBoxFaceView.h
// ZXDNLLTest
//
// Created by mxsm on 16/5/19.
// Copyright © 2016年 mxsm. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "ChatFace.h"
@protocol ZXChatBoxFaceViewDelegate <NSObject>
- (void) chatBoxFaceViewDidSelectedFace:(int)faceIndex faceGroup:(ChatFaceGroup *)faceGroup type:(TLFaceType)type;
- (void) chatBoxFaceViewDeleteButtonDown;
- (void) chatBoxFaceViewSendButtonDown;
@end
@interface ZXChatBoxFaceView : UIView
@property (nonatomic, weak) id <ZXChatBoxFaceViewDelegate> delegate;
@end
| 21.68 | 114 | 0.761993 |
0889a4e84e8a22a711930767ba225b0aebad045b | 374 | h | C | iOSOpenDev/frameworks/PhotoLibrary.framework/Headers/AirPlayRemoteSlideshowDelegate.h | bzxy/cydia | f8c838cdbd86e49dddf15792e7aa56e2af80548d | [
"MIT"
] | 678 | 2017-11-17T08:33:19.000Z | 2022-03-26T10:40:20.000Z | iOSOpenDev/frameworks/PhotoLibrary.framework/Headers/AirPlayRemoteSlideshowDelegate.h | chenfanfang/Cydia | 5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0 | [
"MIT"
] | 22 | 2019-04-16T05:51:53.000Z | 2021-11-08T06:18:45.000Z | iOSOpenDev/frameworks/PhotoLibrary.framework/Headers/AirPlayRemoteSlideshowDelegate.h | chenfanfang/Cydia | 5efce785bfd5f1064b9c0f0e29a9cc05aa24cad0 | [
"MIT"
] | 170 | 2018-06-10T07:59:20.000Z | 2022-03-22T16:19:33.000Z | /**
* This header is generated by class-dump-z 0.2b.
*
* Source: /System/Library/PrivateFrameworks/PhotoLibrary.framework/PhotoLibrary
*/
@protocol AirPlayRemoteSlideshowDelegate <NSObject>
- (BOOL)airplayRemoteSlideshow:(id)slideshow handleEvent:(id)event;
- (BOOL)airplayRemoteSlideshow:(id)slideshow requestAssetWithInfo:(id)info completion:(id)completion;
@end
| 24.933333 | 101 | 0.786096 |
03b8a8f3d303ffdcafdef1008be084878c2e05fd | 310 | h | C | src/icl/tests/tst_tcp_socket.h | manolab-project/pier-o-bois | 7c562d4cdf2eead50ec1f9e946ef96e9606e4e23 | [
"MIT"
] | 1 | 2020-12-30T16:03:29.000Z | 2020-12-30T16:03:29.000Z | src/icl/tests/tst_tcp_socket.h | manolab-project/pier-o-bois | 7c562d4cdf2eead50ec1f9e946ef96e9606e4e23 | [
"MIT"
] | null | null | null | src/icl/tests/tst_tcp_socket.h | manolab-project/pier-o-bois | 7c562d4cdf2eead50ec1f9e946ef96e9606e4e23 | [
"MIT"
] | null | null | null | #ifndef TST_TCP_SOCKET_H
#define TST_TCP_SOCKET_H
#include <QString>
#include <QtTest>
#include <QCoreApplication>
#include <cstdint>
class TcpSocketTest : public QObject
{
Q_OBJECT
public:
TcpSocketTest();
private Q_SLOTS:
void SimpleTcpEchoServer();
private:
};
#endif // TST_TCP_SOCKET_H
| 12.916667 | 36 | 0.745161 |
83e73e13951d11a546fb5907e26f63e5261a8761 | 4,631 | c | C | drop_cache.c | confluentinc/kibosh | af24173bc74bae24c17a66c6a4df240c865b9d16 | [
"Apache-2.0"
] | 7 | 2018-05-25T19:01:06.000Z | 2022-01-27T03:56:24.000Z | drop_cache.c | confluentinc/kibosh | af24173bc74bae24c17a66c6a4df240c865b9d16 | [
"Apache-2.0"
] | 2 | 2020-06-30T00:01:02.000Z | 2020-08-13T22:31:18.000Z | drop_cache.c | confluentinc/kibosh | af24173bc74bae24c17a66c6a4df240c865b9d16 | [
"Apache-2.0"
] | 6 | 2017-09-06T04:21:22.000Z | 2021-01-03T19:07:36.000Z | /**
* Copyright 2020 Confluent Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
#include "drop_cache.h"
#include "io.h"
#include "log.h"
#include "util.h"
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
struct drop_cache_thread {
pthread_t pthread;
pthread_mutex_t lock;
pthread_cond_t cond;
char *path;
int should_run;
int period;
};
int drop_cache(const char *path)
{
int ret, fd;
char buf[] = { '1' };
fd = open(path, O_WRONLY | O_CREAT, 0666);
if (fd < 0) {
return -errno;
}
ret = safe_write(fd, buf, sizeof(buf));
close(fd);
return ret;
}
static void *drop_cache_thread_run(void *arg)
{
struct drop_cache_thread *thread = (struct drop_cache_thread *)arg;
struct timespec deadline;
int ret;
INFO("drop_cache_thread: starting with period %d.\n", thread->period);
while (1) {
pthread_mutex_lock(&thread->lock);
if (!thread->should_run) {
pthread_mutex_unlock(&thread->lock);
break;
}
ret = clock_gettime(CLOCK_MONOTONIC, &deadline);
if (ret) {
abort();
}
deadline.tv_sec += thread->period;
ret = pthread_cond_timedwait(&thread->cond, &thread->lock, &deadline);
INFO("ret = %d\n", ret);
pthread_mutex_unlock(&thread->lock);
ret = drop_cache(thread->path);
if (ret) {
INFO("drop_cache_thread: failed to drop cache: %s (%d)\n",
safe_strerror(ret), ret);
} else {
DEBUG("drop_cache_thread: dropped cache.\n");
}
}
INFO("drop_cache_thread: exiting.\n");
return NULL;
}
struct drop_cache_thread *drop_cache_thread_start(const char *path, int period)
{
struct drop_cache_thread *thread = NULL;
pthread_condattr_t attr;
int ret;
thread = calloc(sizeof(struct drop_cache_thread), 1);
if (!thread) {
INFO("drop_cache_thread_start: OOM\n");
goto error;
}
thread->should_run = 1;
thread->period = period;
thread->path = strdup(path);
if (!thread->path) {
INFO("drop_cache_thread_start: OOM\n");
goto error;
}
ret = pthread_mutex_init(&thread->lock, NULL);
if (ret) {
INFO("drop_cache_thread_start: failed to create lock: %s (%d)\n",
safe_strerror(ret), ret);
goto error_free_path;
}
ret = pthread_condattr_init(&attr);
if (ret) {
INFO("drop_cache_thread_start: failed to create condattr: %s (%d)\n",
safe_strerror(ret), ret);
goto error_mutex_destroy;
}
ret = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
if (ret) {
INFO("drop_cache_thread_start: failed to set cond clock: %s (%d)\n",
safe_strerror(ret), ret);
goto error_condattr_destroy;
}
ret = pthread_cond_init(&thread->cond, &attr);
if (ret) {
INFO("drop_cache_thread_start: failed to create cond: %s (%d)\n",
safe_strerror(ret), ret);
goto error_condattr_destroy;
}
ret = pthread_create(&thread->pthread, NULL, drop_cache_thread_run, thread);
if (ret) {
INFO("drop_cache_thread_start: failed to create thread: %s (%d)\n",
safe_strerror(ret), ret);
goto error_cond_destroy;
}
pthread_condattr_destroy(&attr);
return thread;
error_cond_destroy:
pthread_cond_destroy(&thread->cond);
error_condattr_destroy:
pthread_condattr_destroy(&attr);
error_mutex_destroy:
pthread_mutex_destroy(&thread->lock);
error_free_path:
free(thread->path);
error:
free(thread);
return NULL;
}
void drop_cache_thread_join(struct drop_cache_thread *thread)
{
pthread_mutex_lock(&thread->lock);
thread->should_run = 0;
pthread_cond_signal(&thread->cond);
pthread_mutex_unlock(&thread->lock);
pthread_join(thread->pthread, NULL);
pthread_cond_destroy(&thread->cond);
pthread_mutex_destroy(&thread->lock);
free(thread->path);
free(thread);
}
// vim: ts=4:sw=4:tw=99:et
| 28.411043 | 80 | 0.638307 |
23b80f0f62d43a4d9da4d7d5d0b4ccfc57e1b684 | 3,516 | h | C | src/message.h | shangjiaxuan/Kagami | 6e6013b1ad2ebdf4b67162929fd2cd19c61635e3 | [
"BSD-2-Clause"
] | null | null | null | src/message.h | shangjiaxuan/Kagami | 6e6013b1ad2ebdf4b67162929fd2cd19c61635e3 | [
"BSD-2-Clause"
] | null | null | null | src/message.h | shangjiaxuan/Kagami | 6e6013b1ad2ebdf4b67162929fd2cd19c61635e3 | [
"BSD-2-Clause"
] | null | null | null | #pragma once
#include "util.h"
#include "object.h"
namespace kagami {
/* Message state level for Message class */
enum StateLevel {
kStateNormal,
kStateError,
kStateWarning
};
enum ParameterPattern {
kParamAutoSize,
kParamAutoFill,
kParamNormal
};
enum StateCode {
kCodeInterface = 5,
kCodeObject = 1,
kCodeSuccess = 0,
kCodeIllegalParam = -1,
kCodeIllegalCall = -2,
kCodeIllegalSymbol = -3,
kCodeBadStream = -4,
kCodeBadExpression = -5
};
class Message {
private:
StateLevel level_;
string detail_;
StateCode code_;
shared_ptr<void> object_;
size_t idx_;
public:
Message() :
level_(kStateNormal),
detail_(""),
code_(kCodeSuccess),
idx_(0) {}
Message(const Message &msg) :
level_(msg.level_),
detail_(msg.detail_),
code_(msg.code_),
object_(msg.object_),
idx_(msg.idx_) {}
Message(const Message &&msg) :
Message(msg) {}
Message(StateCode code, string detail, StateLevel level = kStateNormal) :
level_(level),
detail_(detail),
code_(code),
idx_(0) {}
Message(string detail) :
level_(kStateNormal),
code_(kCodeObject),
detail_(""),
object_(make_shared<Object>(detail)),
idx_(0) {}
Message &operator=(Message &msg) {
level_ = msg.level_;
detail_ = msg.detail_;
code_ = msg.code_;
object_ = msg.object_;
idx_ = msg.idx_;
return *this;
}
Message &operator=(Message &&msg) {
return this->operator=(msg);
}
StateLevel GetLevel() const {
return level_;
}
StateCode GetCode() const {
return code_;
}
string GetDetail() const {
return detail_;
}
size_t GetIndex() const {
return idx_;
}
Object GetObj() const {
if (code_ != kCodeObject) return Object();
return *static_pointer_cast<Object>(object_);
}
Message &SetObject(Object &object) {
object_ = make_shared<Object>(object);
code_ = kCodeObject;
return *this;
}
Message &SetObject(bool value) {
object_ = make_shared<Object>(
make_shared<bool>(value), kTypeIdBool
);
code_ = kCodeObject;
return *this;
}
Message &SetObject(int64_t value) {
object_ = make_shared<Object>(
make_shared<int64_t>(value), kTypeIdInt
);
code_ = kCodeObject;
return *this;
}
Message &SetObject(double value) {
object_ = make_shared<Object>(
make_shared<double>(value), kTypeIdFloat
);
code_ = kCodeObject;
return *this;
}
Message &SetObject(string value) {
object_ = make_shared<Object>(
make_shared<string>(value), kTypeIdString
);
code_ = kCodeObject;
return *this;
}
Message &SetObject(Object &&object) {
return this->SetObject(object);
}
Message &SetLevel(StateLevel level) {
level_ = level;
return *this;
}
Message &SetCode(StateCode code) {
code_ = code;
return *this;
}
Message &SetDetail(const string &detail) {
detail_ = detail;
return *this;
}
Message &SetIndex(const size_t index) {
idx_ = index;
return *this;
}
void Clear() {
level_ = kStateNormal;
detail_.clear();
detail_.shrink_to_fit();
code_ = kCodeSuccess;
object_.reset();
idx_ = 0;
}
};
} | 20.323699 | 77 | 0.582196 |
d9a7ad0e16480621ce9fb31d4afb3f6d2221c835 | 1,197 | h | C | PrivateFrameworks/Notes/NSData-ICNFMCMailCoreAdditions.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 17 | 2018-11-13T04:02:58.000Z | 2022-01-20T09:27:13.000Z | PrivateFrameworks/Notes/NSData-ICNFMCMailCoreAdditions.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 3 | 2018-04-06T02:02:27.000Z | 2018-10-02T01:12:10.000Z | PrivateFrameworks/Notes/NSData-ICNFMCMailCoreAdditions.h | phatblat/macOSPrivateFrameworks | 9047371eb80f925642c8a7c4f1e00095aec66044 | [
"MIT"
] | 1 | 2018-09-28T13:54:23.000Z | 2018-09-28T13:54:23.000Z | //
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#import "NSData.h"
@interface NSData (ICNFMCMailCoreAdditions)
+ (id)ic_dataByConvertingLineEndingsFromNetworkToUnix:(id)arg1;
+ (id)ic_dataByConvertingLineEndingsFromUnixToNetwork:(id)arg1;
+ (unsigned long long)ic_quotedPrintableLengthOfHeaderBytes:(const char *)arg1 length:(unsigned long long)arg2;
@property(readonly, copy, nonatomic) NSData *ic_MD5Digest;
- (struct _NSRange)ic_rangeOfCString:(const char *)arg1 options:(unsigned long long)arg2 range:(struct _NSRange)arg3;
- (struct _NSRange)ic_rangeOfCString:(const char *)arg1 options:(unsigned long long)arg2;
- (struct _NSRange)ic_rangeOfCString:(const char *)arg1;
@property(readonly, nonatomic) struct _NSRange ic_rangeOfRFC822HeaderData;
- (id)ic_wrapperForBinHex40DataWithFileEncodingHint:(unsigned long long)arg1;
- (id)ic_wrapperForAppleFileDataWithFileEncodingHint:(unsigned long long)arg1;
- (id)ic_uudecodedDataIntoFile:(id *)arg1 mode:(unsigned int *)arg2;
- (id)ic_encodeQuotedPrintableForText:(BOOL)arg1 allowCancel:(BOOL)arg2;
- (id)ic_decodeQuotedPrintableForText:(BOOL)arg1;
@end
| 47.88 | 117 | 0.792815 |
9ce58b17ea148ce6196848b30191b9ababa537da | 6,619 | h | C | scann/scann/tree_x_hybrid/tree_ah_hybrid_residual.h | dumpmemory/google-research | bc87d010ab9086b6e92c3f075410fa6e1f27251b | [
"Apache-2.0"
] | null | null | null | scann/scann/tree_x_hybrid/tree_ah_hybrid_residual.h | dumpmemory/google-research | bc87d010ab9086b6e92c3f075410fa6e1f27251b | [
"Apache-2.0"
] | null | null | null | scann/scann/tree_x_hybrid/tree_ah_hybrid_residual.h | dumpmemory/google-research | bc87d010ab9086b6e92c3f075410fa6e1f27251b | [
"Apache-2.0"
] | null | null | null | // Copyright 2022 The Google Research Authors.
//
// 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 SCANN_TREE_X_HYBRID_TREE_AH_HYBRID_RESIDUAL_H_
#define SCANN_TREE_X_HYBRID_TREE_AH_HYBRID_RESIDUAL_H_
#include <cstdint>
#include <functional>
#include <utility>
#include "scann/base/search_parameters.h"
#include "scann/base/single_machine_base.h"
#include "scann/data_format/datapoint.h"
#include "scann/data_format/dataset.h"
#include "scann/hashes/asymmetric_hashing2/querying.h"
#include "scann/hashes/asymmetric_hashing2/searcher.h"
#include "scann/partitioning/kmeans_tree_like_partitioner.h"
#include "scann/partitioning/kmeans_tree_partitioner.h"
#include "scann/proto/hash.pb.h"
#include "scann/trees/kmeans_tree/kmeans_tree.h"
#include "scann/utils/types.h"
namespace research_scann {
class TreeAHHybridResidual final : public SingleMachineSearcherBase<float> {
public:
TreeAHHybridResidual(shared_ptr<const DenseDataset<float>> dataset,
int32_t default_pre_reordering_num_neighbors,
float default_pre_reordering_epsilon)
: SingleMachineSearcherBase<float>(std::move(dataset),
default_pre_reordering_num_neighbors,
default_pre_reordering_epsilon) {}
Status BuildLeafSearchers(
const AsymmetricHasherConfig& config,
unique_ptr<KMeansTreeLikePartitioner<float>> partitioner,
shared_ptr<const asymmetric_hashing2::Model<float>> ah_model,
vector<std::vector<DatapointIndex>> datapoints_by_token,
const DenseDataset<uint8_t>* hashed_dataset, ThreadPool* pool = nullptr);
void set_database_tokenizer(
shared_ptr<const KMeansTreeLikePartitioner<float>> database_tokenizer) {
database_tokenizer_ = database_tokenizer;
}
bool supports_crowding() const final { return true; }
static StatusOr<DenseDataset<float>> ComputeResiduals(
const DenseDataset<float>& dataset,
const KMeansTreeLikePartitioner<float>* partitioner,
ConstSpan<std::vector<DatapointIndex>> datapoints_by_token,
bool normalize_residual_by_cluster_stdev = false);
static StatusOr<DenseDataset<float>> ComputeResiduals(
const DenseDataset<float>& dataset,
const DenseDataset<float>& kmeans_centers,
ConstSpan<std::vector<DatapointIndex>> datapoints_by_token);
static StatusOr<uint8_t> ComputeGlobalTopNShift(
ConstSpan<std::vector<DatapointIndex>> datapoints_by_token);
Status PreprocessQueryIntoParamsUnlocked(
const DatapointPtr<float>& query,
SearchParameters& search_params) const final;
StatusOr<SingleMachineFactoryOptions> ExtractSingleMachineFactoryOptions()
override;
void AttemptEnableGlobalTopN();
protected:
bool impl_needs_dataset() const final { return leaf_searchers_.empty(); }
bool impl_needs_hashed_dataset() const final {
return leaf_searchers_.empty();
}
Status FindNeighborsImpl(const DatapointPtr<float>& query,
const SearchParameters& params,
NNResultsVector* result) const final;
Status FindNeighborsBatchedImpl(
const TypedDataset<float>& queries, ConstSpan<SearchParameters> params,
MutableSpan<NNResultsVector> results) const final;
Status EnableCrowdingImpl(
ConstSpan<int64_t> datapoint_index_to_crowding_attribute) final;
void DisableCrowdingImpl() final;
private:
class UnlockedTreeAHHybridResidualPreprocessingResults
: public SearchParameters::UnlockedQueryPreprocessingResults {
public:
UnlockedTreeAHHybridResidualPreprocessingResults(
vector<KMeansTreeSearchResult> centers_to_search,
asymmetric_hashing2::LookupTable lookup_table)
: centers_to_search_(std::move(centers_to_search)),
lookup_table_(
make_unique<
asymmetric_hashing2::AsymmetricHashingOptionalParameters>(
std::move(lookup_table))) {}
ConstSpan<KMeansTreeSearchResult> centers_to_search() const {
return centers_to_search_;
}
shared_ptr<asymmetric_hashing2::AsymmetricHashingOptionalParameters>
lookup_table() const {
return lookup_table_;
}
private:
vector<KMeansTreeSearchResult> centers_to_search_;
shared_ptr<asymmetric_hashing2::AsymmetricHashingOptionalParameters>
lookup_table_;
};
Status FindNeighborsInternal1(
const DatapointPtr<float>& query, const SearchParameters& params,
ConstSpan<KMeansTreeSearchResult> centers_to_search,
NNResultsVector* result) const;
template <typename TopN>
Status FindNeighborsInternal2(
const DatapointPtr<float>& query, const SearchParameters& params,
ConstSpan<KMeansTreeSearchResult> centers_to_search, TopN top_n,
NNResultsVector* result) const;
Status CheckBuildLeafSearchersPreconditions(
const AsymmetricHasherConfig& config,
const KMeansTreeLikePartitioner<float>& partitioner) const;
StatusOr<pair<int32_t, DatapointPtr<float>>> TokenizeAndMaybeResidualize(
const DatapointPtr<float>& dptr, Datapoint<float>* residual_storage);
StatusOr<vector<pair<int32_t, DatapointPtr<float>>>>
TokenizeAndMaybeResidualize(const TypedDataset<float>& dps,
MutableSpan<Datapoint<float>*> residual_storage);
vector<unique_ptr<asymmetric_hashing2::Searcher<float>>> leaf_searchers_;
shared_ptr<const asymmetric_hashing2::AsymmetricQueryer<float>>
asymmetric_queryer_;
unique_ptr<KMeansTreeLikePartitioner<float>> query_tokenizer_;
shared_ptr<const KMeansTreeLikePartitioner<float>> database_tokenizer_;
vector<std::vector<DatapointIndex>> datapoints_by_token_;
DatapointIndex num_datapoints_ = 0;
vector<uint32_t> leaf_tokens_by_norm_;
AsymmetricHasherConfig::LookupType lookup_type_tag_ =
AsymmetricHasherConfig::FLOAT;
bool disjoint_leaf_partitions_ = true;
bool enable_global_topn_ = false;
uint8_t global_topn_shift_ = 0;
FRIEND_TEST(TreeAHHybridResidualTest, CrowdingMutation);
};
} // namespace research_scann
#endif
| 36.368132 | 79 | 0.754344 |
1409f18c71dceb06589f9fb4daecf6a59530d498 | 3,725 | h | C | include/usb_audio.h | wastevensv/homemmade-track-node | b4ae85837d629858024c4ed941b2ffdfe8c439f9 | [
"MIT"
] | 17 | 2019-09-22T11:58:29.000Z | 2022-03-16T03:13:14.000Z | include/usb_audio.h | wastevensv/homemmade-track-node | b4ae85837d629858024c4ed941b2ffdfe8c439f9 | [
"MIT"
] | 11 | 2019-09-01T06:56:02.000Z | 2020-04-29T11:46:25.000Z | software/controller/core/usb_audio.h | s-bear/UVTV | eea18af656a2f7e803badf3a7d4457464221d19a | [
"MIT"
] | 3 | 2017-10-06T06:01:44.000Z | 2018-05-25T06:37:19.000Z | /* Teensyduino Core Library
* http://www.pjrc.com/teensy/
* Copyright (c) 2017 PJRC.COM, LLC.
*
* 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:
*
* 1. The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* 2. If the Software is incorporated into a build system that allows
* selection among a list of target devices, then similar target
* devices manufactured by PJRC.COM must be included in the list of
* target devices and selectable in the same manner.
*
* 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 USBaudio_h_
#define USBaudio_h_
#include "usb_desc.h"
#ifdef AUDIO_INTERFACE
#define FEATURE_MAX_VOLUME 0xFFF // volume accepted from 0 to 0xFFF
#ifdef __cplusplus
extern "C" {
#endif
extern uint16_t usb_audio_receive_buffer[];
extern uint16_t usb_audio_transmit_buffer[];
extern void usb_audio_receive_callback(unsigned int len);
extern unsigned int usb_audio_transmit_callback(void);
int usb_audio_set_feature(void *stp, uint8_t *buf);
int usb_audio_get_feature(void *stp, uint8_t *data, uint32_t *datalen);
extern uint32_t usb_audio_sync_feedback;
extern uint8_t usb_audio_receive_setting;
extern uint8_t usb_audio_transmit_setting;
#ifdef __cplusplus
}
// audio features supported
struct usb_audio_features_struct {
int change; // set to 1 when any value is changed
int mute; // 1=mute, 0=unmute
int volume; // volume from 0 to FEATURE_MAX_VOLUME, maybe should be float from 0.0 to 1.0
};
#include "AudioStream.h"
class AudioInputUSB : public AudioStream
{
public:
AudioInputUSB(void) : AudioStream(0, NULL) { begin(); }
virtual void update(void);
void begin(void);
friend void usb_audio_receive_callback(unsigned int len);
friend int usb_audio_set_feature(void *stp, uint8_t *buf);
friend int usb_audio_get_feature(void *stp, uint8_t *data, uint32_t *datalen);
static struct usb_audio_features_struct features;
float volume(void) {
if (features.mute) return 0.0;
return (float)(features.volume) * (1.0 / (float)FEATURE_MAX_VOLUME);
}
private:
static bool update_responsibility;
static audio_block_t *incoming_left;
static audio_block_t *incoming_right;
static audio_block_t *ready_left;
static audio_block_t *ready_right;
static uint16_t incoming_count;
static uint8_t receive_flag;
};
class AudioOutputUSB : public AudioStream
{
public:
AudioOutputUSB(void) : AudioStream(2, inputQueueArray) { begin(); }
virtual void update(void);
void begin(void);
friend unsigned int usb_audio_transmit_callback(void);
private:
static bool update_responsibility;
static audio_block_t *left_1st;
static audio_block_t *left_2nd;
static audio_block_t *right_1st;
static audio_block_t *right_2nd;
static uint16_t offset_1st;
audio_block_t *inputQueueArray[2];
};
#endif // __cplusplus
#endif // AUDIO_INTERFACE
#endif // USBaudio_h_
| 34.490741 | 92 | 0.775839 |
14224517e6210d3010789ad45e7716116d8c015a | 3,696 | c | C | linsched-linsched-alpha/arch/arm/mach-s3c2443/dma.c | usenixatc2021/SoftRefresh_Scheduling | 589ba06c8ae59538973c22edf28f74a59d63aa14 | [
"MIT"
] | null | null | null | linsched-linsched-alpha/arch/arm/mach-s3c2443/dma.c | usenixatc2021/SoftRefresh_Scheduling | 589ba06c8ae59538973c22edf28f74a59d63aa14 | [
"MIT"
] | null | null | null | linsched-linsched-alpha/arch/arm/mach-s3c2443/dma.c | usenixatc2021/SoftRefresh_Scheduling | 589ba06c8ae59538973c22edf28f74a59d63aa14 | [
"MIT"
] | null | null | null | /* linux/arch/arm/mach-s3c2443/dma.c
*
* Copyright (c) 2007 Simtec Electronics
* Ben Dooks <ben@simtec.co.uk>
*
* S3C2443 DMA selection
*
* http://armlinux.simtec.co.uk/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/serial_core.h>
#include <linux/io.h>
#include <mach/dma.h>
#include <plat/dma-s3c24xx.h>
#include <plat/cpu.h>
#include <plat/regs-serial.h>
#include <mach/regs-gpio.h>
#include <plat/regs-ac97.h>
#include <plat/regs-dma.h>
#include <mach/regs-mem.h>
#include <mach/regs-lcd.h>
#include <mach/regs-sdi.h>
#include <plat/regs-iis.h>
#include <plat/regs-spi.h>
#define MAP(x) { \
[0] = (x) | DMA_CH_VALID, \
[1] = (x) | DMA_CH_VALID, \
[2] = (x) | DMA_CH_VALID, \
[3] = (x) | DMA_CH_VALID, \
[4] = (x) | DMA_CH_VALID, \
[5] = (x) | DMA_CH_VALID, \
}
static struct s3c24xx_dma_map __initdata s3c2443_dma_mappings[] = {
[DMACH_XD0] = {
.name = "xdreq0",
.channels = MAP(S3C2443_DMAREQSEL_XDREQ0),
},
[DMACH_XD1] = {
.name = "xdreq1",
.channels = MAP(S3C2443_DMAREQSEL_XDREQ1),
},
[DMACH_SDI] = {
.name = "sdi",
.channels = MAP(S3C2443_DMAREQSEL_SDI),
},
[DMACH_SPI0] = {
.name = "spi0",
.channels = MAP(S3C2443_DMAREQSEL_SPI0TX),
},
[DMACH_SPI1] = {
.name = "spi1",
.channels = MAP(S3C2443_DMAREQSEL_SPI1TX),
},
[DMACH_UART0] = {
.name = "uart0",
.channels = MAP(S3C2443_DMAREQSEL_UART0_0),
},
[DMACH_UART1] = {
.name = "uart1",
.channels = MAP(S3C2443_DMAREQSEL_UART1_0),
},
[DMACH_UART2] = {
.name = "uart2",
.channels = MAP(S3C2443_DMAREQSEL_UART2_0),
},
[DMACH_UART3] = {
.name = "uart3",
.channels = MAP(S3C2443_DMAREQSEL_UART3_0),
},
[DMACH_UART0_SRC2] = {
.name = "uart0",
.channels = MAP(S3C2443_DMAREQSEL_UART0_1),
},
[DMACH_UART1_SRC2] = {
.name = "uart1",
.channels = MAP(S3C2443_DMAREQSEL_UART1_1),
},
[DMACH_UART2_SRC2] = {
.name = "uart2",
.channels = MAP(S3C2443_DMAREQSEL_UART2_1),
},
[DMACH_UART3_SRC2] = {
.name = "uart3",
.channels = MAP(S3C2443_DMAREQSEL_UART3_1),
},
[DMACH_TIMER] = {
.name = "timer",
.channels = MAP(S3C2443_DMAREQSEL_TIMER),
},
[DMACH_I2S_IN] = {
.name = "i2s-sdi",
.channels = MAP(S3C2443_DMAREQSEL_I2SRX),
},
[DMACH_I2S_OUT] = {
.name = "i2s-sdo",
.channels = MAP(S3C2443_DMAREQSEL_I2STX),
},
[DMACH_PCM_IN] = {
.name = "pcm-in",
.channels = MAP(S3C2443_DMAREQSEL_PCMIN),
},
[DMACH_PCM_OUT] = {
.name = "pcm-out",
.channels = MAP(S3C2443_DMAREQSEL_PCMOUT),
},
[DMACH_MIC_IN] = {
.name = "mic-in",
.channels = MAP(S3C2443_DMAREQSEL_MICIN),
},
};
static void s3c2443_dma_select(struct s3c2410_dma_chan *chan,
struct s3c24xx_dma_map *map)
{
writel(map->channels[0] | S3C2443_DMAREQSEL_HW,
chan->regs + S3C2443_DMA_DMAREQSEL);
}
static struct s3c24xx_dma_selection __initdata s3c2443_dma_sel = {
.select = s3c2443_dma_select,
.dcon_mask = 0,
.map = s3c2443_dma_mappings,
.map_size = ARRAY_SIZE(s3c2443_dma_mappings),
};
static int __init s3c2443_dma_add(struct device *dev,
struct subsys_interface *sif)
{
s3c24xx_dma_init(6, IRQ_S3C2443_DMA0, 0x100);
return s3c24xx_dma_init_map(&s3c2443_dma_sel);
}
static struct subsys_interface s3c2443_dma_interface = {
.name = "s3c2443_dma",
.subsys = &s3c2443_subsys,
.add_dev = s3c2443_dma_add,
};
static int __init s3c2443_dma_init(void)
{
return subsys_interface_register(&s3c2443_dma_interface);
}
arch_initcall(s3c2443_dma_init);
| 23.541401 | 71 | 0.668831 |
96b7a775ce47ba4cf47da4101b0a3da59feee6f6 | 947 | h | C | modules/grove/include/grove/relocalisation/cpu/ScoreGTRelocaliser_CPU.h | torrvision/spaint | 9cac8100323ea42fe439f66407b832b88f72d2fd | [
"Unlicense"
] | 197 | 2015-10-01T07:23:01.000Z | 2022-03-23T03:02:31.000Z | modules/grove/include/grove/relocalisation/cpu/ScoreGTRelocaliser_CPU.h | torrvision/spaint | 9cac8100323ea42fe439f66407b832b88f72d2fd | [
"Unlicense"
] | 16 | 2016-03-26T13:01:08.000Z | 2020-09-02T09:13:49.000Z | modules/grove/include/grove/relocalisation/cpu/ScoreGTRelocaliser_CPU.h | torrvision/spaint | 9cac8100323ea42fe439f66407b832b88f72d2fd | [
"Unlicense"
] | 62 | 2015-10-03T07:14:59.000Z | 2021-08-31T08:58:18.000Z | /**
* grove: ScoreGTRelocaliser_CPU.h
* Copyright (c) Torr Vision Group, University of Oxford, 2018. All rights reserved.
*/
#ifndef H_GROVE_SCOREGTRELOCALISER_CPU
#define H_GROVE_SCOREGTRELOCALISER_CPU
#include "../interface/ScoreGTRelocaliser.h"
namespace grove {
/**
* \brief An instance of this class can be used to relocalise a camera in a 3D scene on the CPU, using known ground truth correspondences.
*/
class ScoreGTRelocaliser_CPU : public ScoreGTRelocaliser
{
//#################### CONSTRUCTORS ####################
public:
/**
* \brief Constructs a ground truth SCoRe relocaliser on the CPU.
*
* \param settings The settings used to configure the relocaliser.
* \param settingsNamespace The namespace associated with the settings that are specific to the relocaliser.
*/
ScoreGTRelocaliser_CPU(const tvgutil::SettingsContainer_CPtr& settings, const std::string& settingsNamespace);
};
}
#endif
| 29.59375 | 138 | 0.722281 |
9f2a332ef6caa691c8fb3f6305acbdafacce9609 | 8,106 | h | C | src/mongo/db/s/resharding/resharding_data_copy_util.h | benety/mongo | 203430ac9559f82ca01e3cbb3b0e09149fec0835 | [
"Apache-2.0"
] | null | null | null | src/mongo/db/s/resharding/resharding_data_copy_util.h | benety/mongo | 203430ac9559f82ca01e3cbb3b0e09149fec0835 | [
"Apache-2.0"
] | null | null | null | src/mongo/db/s/resharding/resharding_data_copy_util.h | benety/mongo | 203430ac9559f82ca01e3cbb3b0e09149fec0835 | [
"Apache-2.0"
] | null | null | null | /**
* Copyright (C) 2021-present MongoDB, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* 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
* Server Side Public License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>.
*
* As a special exception, the copyright holders give permission to link the
* code of portions of this program with the OpenSSL library under certain
* conditions as described in each individual source file and distribute
* linked combinations including the program with the OpenSSL library. You
* must comply with the Server Side Public License in all respects for
* all of the code used other than as permitted herein. If you modify file(s)
* with this exception, you may extend this exception to your version of the
* file(s), but you are not obligated to do so. If you do not wish to do so,
* delete this exception statement from your version. If you delete this
* exception statement from all source files in the program, then also delete
* it in the license file.
*/
#pragma once
#include <boost/optional.hpp>
#include <vector>
#include "mongo/bson/bsonobj.h"
#include "mongo/db/catalog/collection_catalog.h"
#include "mongo/db/exec/document_value/document.h"
#include "mongo/db/exec/document_value/value.h"
#include "mongo/db/logical_session_id.h"
#include "mongo/db/repl/oplog.h"
#include "mongo/db/s/shard_filtering_metadata_refresh.h"
#include "mongo/s/resharding/common_types_gen.h"
#include "mongo/util/functional.h"
namespace mongo {
class NamespaceString;
class OperationContext;
class Pipeline;
namespace resharding::data_copy {
/**
* Creates the specified collection with the given options if the collection does not already exist.
* If the collection already exists, we do not compare the options because the resharding process
* will always use the same options for the same namespace.
*/
void ensureCollectionExists(OperationContext* opCtx,
const NamespaceString& nss,
const CollectionOptions& options);
/**
* Drops the specified collection or returns without error if the collection has already been
* dropped. A particular incarnation of the collection can be dropped by specifying its UUID.
*
* This functions assumes the collection being dropped doesn't have any two-phase index builds
* active on it.
*/
void ensureCollectionDropped(OperationContext* opCtx,
const NamespaceString& nss,
const boost::optional<UUID>& uuid = boost::none);
/**
* Removes documents from the oplog applier progress and transaction applier progress collections
* that are associated with an in-progress resharding operation. Also drops all oplog buffer
* collections and conflict stash collections that are associated with the in-progress resharding
* operation.
*/
void ensureOplogCollectionsDropped(OperationContext* opCtx,
const UUID& reshardingUUID,
const UUID& sourceUUID,
const std::vector<DonorShardFetchTimestamp>& donorShards);
/**
* Renames the temporary resharding collection to the source namespace string, or is a no-op if the
* collection has already been renamed to it.
*
* This function throws an exception if the collection doesn't exist as the temporary resharding
* namespace string or the source namespace string.
*/
void ensureTemporaryReshardingCollectionRenamed(OperationContext* opCtx,
const CommonReshardingMetadata& metadata);
/**
* Returns the largest _id value in the collection.
*/
Value findHighestInsertedId(OperationContext* opCtx, const CollectionPtr& collection);
/**
* Returns the full document of the largest _id value in the collection.
*/
boost::optional<Document> findDocWithHighestInsertedId(OperationContext* opCtx,
const CollectionPtr& collection);
/**
* Returns a batch of documents suitable for being inserted with insertBatch().
*
* The batch of documents is returned once its size exceeds batchSizeLimitBytes or the pipeline has
* been exhausted.
*/
std::vector<InsertStatement> fillBatchForInsert(Pipeline& pipeline, int batchSizeLimitBytes);
/**
* Atomically inserts a batch of documents in a single storage transaction. Returns the number of
* bytes inserted.
*
* Throws NamespaceNotFound if the collection doesn't already exist.
*/
int insertBatch(OperationContext* opCtx,
const NamespaceString& nss,
std::vector<InsertStatement>& batch);
/**
* Checks out the logical session and acts in one of the following ways depending on the state of
* this shard's config.transactions table:
*
* (a) When this shard already knows about a higher transaction than txnNumber,
* withSessionCheckedOut() skips calling the supplied lambda function and returns boost::none.
*
* (b) When this shard already knows about the retryable write statement (txnNumber, *stmtId),
* withSessionCheckedOut() skips calling the supplied lambda function and returns boost::none.
*
* (c) When this shard has an earlier prepared transaction still active, withSessionCheckedOut()
* skips calling the supplied lambda function and returns a future that becomes ready once the
* active prepared transaction on this shard commits or aborts. After waiting for the returned
* future to become ready, the caller should then invoke withSessionCheckedOut() with the same
* arguments a second time.
*
* (d) Otherwise, withSessionCheckedOut() calls the lambda function and returns boost::none.
*/
boost::optional<SharedSemiFuture<void>> withSessionCheckedOut(OperationContext* opCtx,
LogicalSessionId lsid,
TxnNumber txnNumber,
boost::optional<StmtId> stmtId,
unique_function<void()> callable);
/**
* Updates this shard's config.transactions table based on a retryable write or multi-statement
* transaction that already executed on some donor shard.
*
* This function assumes it is being called while the corresponding logical session is checked out
* by the supplied OperationContext.
*/
void updateSessionRecord(OperationContext* opCtx,
BSONObj o2Field,
std::vector<StmtId> stmtIds,
boost::optional<repl::OpTime> preImageOpTime,
boost::optional<repl::OpTime> postImageOpTime);
/**
* Calls and returns the value from the supplied lambda function.
*
* If a StaleConfig exception is thrown during its execution, then this function will attempt to
* refresh the collection and invoke the supplied lambda function a second time.
*/
template <typename Callable>
auto withOneStaleConfigRetry(OperationContext* opCtx, Callable&& callable) {
try {
return callable();
} catch (const ExceptionForCat<ErrorCategory::StaleShardVersionError>& ex) {
if (auto sce = ex.extraInfo<StaleConfigInfo>()) {
const auto refreshed =
onShardVersionMismatchNoExcept(opCtx, sce->getNss(), sce->getVersionReceived())
.isOK();
if (refreshed) {
return callable();
}
}
throw;
}
}
} // namespace resharding::data_copy
} // namespace mongo
| 43.816216 | 100 | 0.688256 |
23df4353bdabcbee78067f790a6d270b3b13ec29 | 12,271 | h | C | libs/sge_core/src/sge_core/model/Model.h | sgeByOngamex/sge_source | a172dbf0f1d363f242b7e9cba99dc167867134a9 | [
"MIT"
] | 28 | 2021-03-03T15:27:30.000Z | 2021-05-23T11:46:30.000Z | libs/sge_core/src/sge_core/model/Model.h | sgeByOngamex/sge_source | a172dbf0f1d363f242b7e9cba99dc167867134a9 | [
"MIT"
] | 9 | 2021-03-04T21:34:03.000Z | 2021-05-04T18:33:47.000Z | libs/sge_core/src/sge_core/model/Model.h | sgeByOngamex/sge_source | a172dbf0f1d363f242b7e9cba99dc167867134a9 | [
"MIT"
] | 1 | 2021-04-26T07:16:12.000Z | 2021-04-26T07:16:12.000Z | #pragma once
#include <memory>
#include <string>
#include "sge_core/sgecore_api.h"
#include "sge_renderer/renderer/renderer.h"
#include "sge_utils/math/Box.h"
#include "sge_utils/math/mat4.h"
#include "sge_utils/math/primitives.h"
#include "sge_utils/math/transform.h"
#include "sge_utils/utils/ChunkContainer.h"
#include "CollisionMesh.h"
namespace sge {
struct AssetLibrary;
struct AssetIface_Material;
struct IMaterial;
struct Model_CollisionShapeBox {
Model_CollisionShapeBox() = default;
Model_CollisionShapeBox(std::string name, transf3d transform, vec3f halfDiagonal)
: name(std::move(name))
, transform(transform)
, halfDiagonal(halfDiagonal) {
}
std::string name;
transf3d transform = transf3d::getIdentity();
vec3f halfDiagonal = vec3f(0.f);
};
/// Represents a capsule. The capsule is defined by all points that are at distace "radius" from
/// the line defined by ({0.f, -halfHeight, 0.f}, {0.f, halfHeight, 0.f}}
struct Model_CollisionShapeCapsule {
Model_CollisionShapeCapsule() = default;
Model_CollisionShapeCapsule(std::string name, transf3d transform, float halfHeight, float radius)
: name(std::move(name))
, transform(transform)
, halfHeight(halfHeight)
, radius(radius) {
}
std::string name;
transf3d transform = transf3d::getIdentity();
float halfHeight = 0.f;
float radius = 0.f;
};
struct Model_CollisionShapeCylinder {
Model_CollisionShapeCylinder() = default;
Model_CollisionShapeCylinder(std::string name, transf3d transform, vec3f halfDiagonal)
: name(std::move(name))
, transform(transform)
, halfDiagonal(halfDiagonal) {
}
std::string name;
transf3d transform = transf3d::getIdentity();
vec3f halfDiagonal = vec3f(0.f);
};
struct Model_CollisionShapeSphere {
Model_CollisionShapeSphere() = default;
Model_CollisionShapeSphere(std::string name, transf3d transform, float radius)
: name(std::move(name))
, transform(transform)
, radius(radius) {
}
std::string name;
transf3d transform = transf3d::getIdentity();
float radius = 0.f;
};
/// Loading settings describing how the model should be loaded.
struct ModelLoadSettings {
/// The directory of the file, used for dependacy(materials or textures)loading assets.
/// Needed when the model references other assets like textures.
std::string assetDir;
};
struct ModelMaterial {
struct OldInplaceMaterial {
// Legacy settings for loading old models.
float alphaMultiplier = 1.f;
bool needsAlphaSorting = false;
vec4f diffuseColor = vec4f(1.f);
vec4f emissionColor = vec4f(0.f);
float metallic = 0.f;
float roughness = 1.f;
std::string diffuseTextureName;
std::string emissionTextureName;
std::string normalTextureName;
std::string metallicTextureName;
std::string roughnessTextureName;
};
std::string name;
std::string assetForThisMaterial;
/// Before materials were made assets each 3D model described its assets
/// by itself. This is kept to support these old 3D models.
OldInplaceMaterial oldInplaceMtl;
};
// Skinning bone.
struct ModelMeshBone {
ModelMeshBone() = default;
ModelMeshBone(const mat4f& offsetMatrix, int nodeIdx)
: offsetMatrix(offsetMatrix)
, nodeIdx(nodeIdx) {
}
mat4f offsetMatrix = mat4f::getIdentity(); ///< The transformation matrix used for binding a bone to a mesh.
int nodeIdx = -1; ///< The index of the node representing this bone transformation.
};
struct SGE_CORE_API ModelMesh {
std::string name; ///< The name of the mesh.
PrimitiveTopology::Enum primitiveTopology = PrimitiveTopology::Unknown;
int vbByteOffset = 0; ///< 1st vertex byte offset into the vertex buffer
int ibByteOffset = 0; ///< 1st index byte offse int the index buffer
UniformType::Enum ibFmt = UniformType::Unknown; ///< The format the index buffer, if unknown this mesh doesn't use index buffers.
int numElements = 0; ///< The number of vertices/indices used by this mesh.
int numVertices = 0; ///< The number of vertices in the mesh.
std::vector<VertexDecl> vertexDecl; ///< The vertex declaration
int stride = 0; ///< The byte size stride of a single vertex.
int vbVertexColorOffsetBytes = -1; ///, The byte offset of the vertex color.
int vbPositionOffsetBytes = -1; ///< The byte offset in the stride of vertex position.
int vbNormalOffsetBytes = -1; ///< The byte offset in the stride of the vertex normal.
int vbTangetOffsetBytes = -1;
int vbBinormalOffsetBytes = -1;
int vbUVOffsetBytes = -1; ///< The byte offset in the stride of the 1st vertex UV channel.
int vbBonesIdsBytesOffset = -1;
int vbBonesWeightsByteOffset = -1;
std::vector<char> vertexBufferRaw; ///< The raw data containing all vertices in the vertex buffer,
std::vector<char> indexBufferRaw; ///< The raw data containing all indices in the vertex buffer,
AABox3f aabox; ///< The bounding box around the vertices of the mesh, without any deformation by skinning or anything else.
///< A list of bones affecting the mesh.
std::vector<ModelMeshBone> bones;
// The member below are available only if @Model::createRenderingResources gets called:
GpuHandle<Buffer> vertexBuffer; ///< The vertex buffer to be used for rendering of that mesh.
GpuHandle<Buffer> indexBuffer; ///< The index buffer to be used for rendering of that mesh.
bool hasUsableTangetSpace = false; ///< True if uv and all 3 tangent space vectors are available in the vertex declaration.
VertexDeclIndex vertexDeclIndex = VertexDeclIndex_Null;
};
struct MeshAttachment {
MeshAttachment() = default;
MeshAttachment(int attachedMeshIndex, int attachedMaterialIndex)
: attachedMeshIndex(attachedMeshIndex)
, attachedMaterialIndex(attachedMaterialIndex) {
}
int attachedMeshIndex = -1;
int attachedMaterialIndex = -1;
};
struct KeyFrames {
std::map<float, vec3f> positionKeyFrames;
std::map<float, quatf> rotationKeyFrames;
std::map<float, vec3f> scalingKeyFrames;
void evaluate(transf3d& result, const float t) const;
};
struct ModelAnimation {
ModelAnimation() = default;
ModelAnimation(std::string animationName, float durationSec, std::map<int, KeyFrames> perNodeKeyFrames)
: animationName(std::move(animationName))
, durationSec(durationSec)
, perNodeKeyFrames(std::move(perNodeKeyFrames)) {
}
/// Modifies the specified transform and amends the keyframed data. Non-keyframed data is not changed.
/// Usually you want to initialize this to the node static local transform before calling this function
/// to properly get the transform of the node at that moment in animation.
/// @param [in,out] outTransform the transform to get modified.
/// @param [in] the keyframes for the targeted node.
/// @param [in] time is the time in the animation used to interpolate between keyframes.
/// @return true if there were keyframes for the node.
bool modifyTransformWithKeyFrames(transf3d& outTransform, const int nodeIndex, const float time) const {
auto itr = perNodeKeyFrames.find(nodeIndex);
if (itr != perNodeKeyFrames.end()) {
itr->second.evaluate(outTransform, time);
return true;
}
return false;
}
public:
/// The name of the animation.
std::string animationName;
/// The lenght of the animation in seconds.. Keep in mind that there might be key frames beyond that value,
/// The artist might need them for interpolation purposes.
float durationSec = 0;
/// The keyframes of all affected nodes in their local space (relative to their parents).
std::map<int, KeyFrames> perNodeKeyFrames;
};
struct ModelNode {
transf3d staticLocalTransform; ///< The local transformation of the node when not animated.
std::vector<MeshAttachment> meshAttachments;
std::vector<int> childNodes; ///< The indices of all child nodes.
float limbLength = 0.f; ///< If the node seemed to be used for skinning, this is the length of the bone in the interface. 0 otherwise.
std::string name; ///< The name of the node.
};
/// @brief Model hold a serialized/deserialized state of our internal 3D model file format,
/// usually imported from obj/fbx/others.
/// In addition as some of the data may not change during runtime the structure hold that immutable data
/// like the GPUHandles to the vertex buffers needed.
/// To render and/or play animations on that model use @EvaluatedModel.
struct SGE_CORE_API Model {
/// @brief If the model is going to be used for rendering,
/// you need to call this function after the model is fully loaded.
/// It will initialize vertex/index buffer or other needed data.
void prepareForRendering(SGEDevice& sgedev, AssetLibrary& assetlib);
int makeNewNode();
int makeNewMaterial();
int makeNewMesh();
int makeNewAnim();
void setRootNodeIndex(const int newRootNodeIndex);
int getRootNodeIndex() const {
return m_rootNodeIndex;
}
ModelNode* getRootNode() {
return nodeAt(getRootNodeIndex());
}
const ModelNode* getRootNode() const {
return nodeAt(getRootNodeIndex());
}
int numNodes() const {
return int(m_nodes.size());
}
int numMaterials() const {
return int(m_materials.size());
}
int numMeshes() const {
return int(m_meshes.size());
}
int numAnimations() const {
return int(m_animations.size());
}
ModelNode* nodeAt(int nodeIndex);
const ModelNode* nodeAt(int nodeIndex) const;
int findFistNodeIndexWithName(const std::string& name) const;
ModelMaterial* materialAt(int materialIndex);
const ModelMaterial* materialAt(int materialIndex) const;
IMaterial* loadedMaterialAt(int mtlIndex);
IMaterial* loadedMaterialAt(int mtlIndex) const;
ModelMesh* meshAt(int meshIndex);
const ModelMesh* meshAt(int meshIndex) const;
const ModelAnimation* animationAt(int iAnim) const;
ModelAnimation* animationAt(int iAnim);
const ModelAnimation* getAnimationByName(const std::string& name) const;
int getAnimationIndexByName(const std::string& name) const;
const std::vector<ModelNode*>& getNodes() {
return m_nodes;
}
const std::vector<ModelMesh*>& getMeshes() {
return m_meshes;
}
const std::vector<ModelMaterial*>& getMatrials() {
return m_materials;
}
void setModelLoadSettings(const ModelLoadSettings& loadSets) {
m_loadSets = loadSets;
}
const ModelLoadSettings& getModelLoadSetting() const {
return m_loadSets;
}
private:
void loadMaterials(AssetLibrary& assetLib);
private:
/// The index of the root node in the model.
/// All other nodes or somehow childred of this one.
int m_rootNodeIndex = -1;
/// An ordered list of all animations described by this model.
std::vector<ModelAnimation> m_animations;
/// An ordered list of all nodes. Others refer to this by its index here.
std::vector<ModelNode*> m_nodes;
/// An ordered list of all meshes. Others refer to this by its index here.
std::vector<ModelMesh*> m_meshes;
/// An ordered list of all raw materials data. Others refer to this by its index here.
std::vector<ModelMaterial*> m_materials;
/// A list of loaded materials ready to be used for rendering. Each elements corresponds
/// to an element with the same index in @m_materials.
std::vector<std::shared_ptr<AssetIface_Material>> m_loadedMaterial;
/// The actual storage for the model data.
/// The pointers of @m_nodes, @m_meshes, @m_materials
/// point to these.
ChunkContainer<ModelMesh> m_containerMesh;
ChunkContainer<ModelMaterial> m_containerMaterial;
ChunkContainer<ModelNode> m_containerNode;
/// Cached loading settings.
ModelLoadSettings m_loadSets;
public:
// TODO: make these private.
// TODO: Make these use the same strcture we have for the physics RigidBody creation.
/// Stores the various collision shapes defineded in the model.
/// They are useful for having one place for the rendering geometry and the
/// geometry that is going to be used for game physics.
std::vector<ModelCollisionMesh> m_convexHulls;
std::vector<ModelCollisionMesh> m_concaveHulls;
std::vector<Model_CollisionShapeBox> m_collisionBoxes;
std::vector<Model_CollisionShapeCapsule> m_collisionCapsules;
std::vector<Model_CollisionShapeCylinder> m_collisionCylinders;
std::vector<Model_CollisionShapeSphere> m_collisionSpheres;
};
} // namespace sge
| 34.76204 | 135 | 0.736941 |
182dd252ac476bfcf9c28ba459653abb2b08ce29 | 377 | h | C | fanbrd/domain/src/nidec/nidec_fan_drv_adapter.h | horance-liu/fan-speed | 62c9e79279d02c5aabaef9714cc17945cdf194ca | [
"Apache-2.0"
] | null | null | null | fanbrd/domain/src/nidec/nidec_fan_drv_adapter.h | horance-liu/fan-speed | 62c9e79279d02c5aabaef9714cc17945cdf194ca | [
"Apache-2.0"
] | null | null | null | fanbrd/domain/src/nidec/nidec_fan_drv_adapter.h | horance-liu/fan-speed | 62c9e79279d02c5aabaef9714cc17945cdf194ca | [
"Apache-2.0"
] | null | null | null | #ifndef EA20235E_1E9D_49B4_B767_182FBD951C20
#define EA20235E_1E9D_49B4_B767_182FBD951C20
#include "fan_drv.h"
#include "nidec_fan_drv.h"
namespace fanbrd {
struct NidecFanDrvAdapter : private NidecFanDrv, FanDrv {
private:
Status Adjust(FanSpeed) override;
bool IsError() const override;
};
} // namespace fanbrd
#endif /* EA20235E_1E9D_49B4_B767_182FBD951C20 */
| 20.944444 | 57 | 0.790451 |
76606d814b8c140c9a19293e19b42c30e03bae03 | 1,132 | c | C | cmds/spells/g/_gentle_repose.c | facadepapergirl/shadowgate | 2b811671c5c85952ed93767753d72fc0d12819d8 | [
"MIT"
] | null | null | null | cmds/spells/g/_gentle_repose.c | facadepapergirl/shadowgate | 2b811671c5c85952ed93767753d72fc0d12819d8 | [
"MIT"
] | null | null | null | cmds/spells/g/_gentle_repose.c | facadepapergirl/shadowgate | 2b811671c5c85952ed93767753d72fc0d12819d8 | [
"MIT"
] | null | null | null | #include <spell.h>
inherit SPELL;
void create()
{
::create();
set_spell_name("gentle repose");
set_spell_level(([ "cleric" : 2, "mage" : 3 ]));
set_syntax("cast CLASS gentle repose");
set_spell_sphere("necromancy");
set_description("This spell preserves remains of the dead in the area, extending their decay time. Doing so effectively extends the time limit on raising that creature from the dead.");
set_helpful_spell(1);
}
void spell_effect()
{
object *corpses=({}), corpse;
corpses=all_inventory(ENV(caster));
corpses=filter_array(corpses,(:(int)$1->is_corpse()==1:));
if(!sizeof(corpses))
{
tell_object(caster,"%^BOLD%^%^BLUE%^There are no corpses.%^RESET%^");
TO->remove();
return;
}
tell_object(caster,"%^BOLD%^%^CYAN%^You gently touch corpses in the room, freezing them.%^RESET%^");
tell_room(ENV(caster),"%^BOLD%^%^CYAN%^"+caster->QCN+" gently touches corpses in the room, freezing them.%^RESET%^",caster);
spell_successful();
map_array(corpses,(:$1->remove_decay():));
dest_effect();
return;
}
| 29.025641 | 189 | 0.636042 |
0ad5c0e6ab52dab9a44398d00d2b125c0ecc1acc | 314 | h | C | src/library/tactic/whnf_tactic.h | javra/lean | cc70845332e63a1f1be21dc1f96d17269fc85909 | [
"Apache-2.0"
] | 130 | 2016-12-02T22:46:10.000Z | 2022-03-22T01:09:48.000Z | src/library/tactic/whnf_tactic.h | soonhokong/lean | 38607e3eb57f57f77c0ac114ad169e9e4262e24f | [
"Apache-2.0"
] | 8 | 2017-05-03T01:21:08.000Z | 2020-02-25T11:38:05.000Z | src/library/tactic/whnf_tactic.h | soonhokong/lean | 38607e3eb57f57f77c0ac114ad169e9e4262e24f | [
"Apache-2.0"
] | 28 | 2016-12-02T22:46:20.000Z | 2022-03-18T21:28:20.000Z | /*
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#pragma once
#include "library/tactic/tactic.h"
namespace lean {
tactic whnf_tactic();
void initialize_whnf_tactic();
void finalize_whnf_tactic();
}
| 20.933333 | 67 | 0.77707 |
17f2f1cbe1d30a2d97a34711210e72004b818269 | 16,333 | c | C | drivers/gpu/arm/t83x/r15p0/platform/exynos/gpu_exynos8890.c | CaelestisZ/HeraQ | 2804afc99bf59c43740038833077ef7b14993592 | [
"MIT"
] | null | null | null | drivers/gpu/arm/t83x/r15p0/platform/exynos/gpu_exynos8890.c | CaelestisZ/HeraQ | 2804afc99bf59c43740038833077ef7b14993592 | [
"MIT"
] | null | null | null | drivers/gpu/arm/t83x/r15p0/platform/exynos/gpu_exynos8890.c | CaelestisZ/HeraQ | 2804afc99bf59c43740038833077ef7b14993592 | [
"MIT"
] | null | null | null | /* drivers/gpu/t6xx/kbase/src/platform/gpu_exynos8890.c
*
* Copyright 2011 by S.LSI. Samsung Electronics Inc.
* San#24, Nongseo-Dong, Giheung-Gu, Yongin, Korea
*
* Samsung SoC Mali-T604 DVFS driver
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software FoundatIon.
*/
/**
* @file gpu_exynos8890.c
* DVFS
*/
#include <mali_kbase.h>
#include <linux/regulator/driver.h>
#include <linux/pm_qos.h>
#include <linux/delay.h>
#include <linux/smc.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
#include <mach/asv-exynos.h>
#ifdef CONFIG_MALI_RT_PM
#include <../pwrcal/S5E8890/S5E8890-vclk.h>
#include <../pwrcal/pwrcal.h>
#include <mach/pm_domains-cal.h>
#endif
#else
#include <soc/samsung/asv-exynos.h>
#include <../drivers/soc/samsung/pwrcal/S5E8890/S5E8890-vclk.h>
#include <../drivers/soc/samsung/pwrcal/pwrcal.h>
#include <soc/samsung/pm_domains-cal.h>
#include <soc/samsung/exynos-pmu.h>
#endif
#include <linux/apm-exynos.h>
#ifdef CONFIG_EXYNOS8890_BTS_OPTIMIZATION
#include <soc/samsung/bts.h>
#endif
#include <linux/clk.h>
#include "mali_kbase_platform.h"
#include "gpu_dvfs_handler.h"
#include "gpu_dvfs_governor.h"
#include "gpu_control.h"
#include "../mali_midg_regmap.h"
extern struct kbase_device *pkbdev;
#ifdef CONFIG_REGULATOR
#if defined(CONFIG_REGULATOR_S2MPS16)
#if LINUX_VERSION_CODE > KERNEL_VERSION(3, 17, 0)
#define EXYNOS_PMU_G3D_STATUS 0x4064
#define LOCAL_PWR_CFG (0xF << 0)
#endif
extern int s2m_get_dvs_is_on(void);
#endif
#endif
#ifdef CONFIG_MALI_DVFS
#define CPU_MAX PM_QOS_CLUSTER1_FREQ_MAX_DEFAULT_VALUE
#else
#define CPU_MAX -1
#endif
#ifndef KHZ
#define KHZ (1000)
#endif
#ifdef CONFIG_EXYNOS_BUSMONITOR
void __iomem *g3d0_outstanding_regs;
void __iomem *g3d1_outstanding_regs;
#endif /* CONFIG_EXYNOS_BUSMONITOR */
/* clk,vol,abb,min,max,down stay, pm_qos mem, pm_qos int, pm_qos cpu_kfc_min, pm_qos cpu_egl_max */
static gpu_dvfs_info gpu_dvfs_table_default[] = {
{806, 850000, 0, 98, 100, 1, 0, 1794000, 413000, 1586000, CPU_MAX},
{754, 850000, 0, 98, 100, 1, 0, 1794000, 413000, 1586000, CPU_MAX},
{728, 850000, 0, 98, 100, 1, 0, 1794000, 413000, 1586000, CPU_MAX},
{702, 850000, 0, 98, 100, 1, 0, 1794000, 413000, 1586000, CPU_MAX},
{650, 800000, 0, 98, 100, 5, 0, 1794000, 413000, 1586000, 1560000},
{600, 800000, 0, 78, 99, 9, 0, 1539000, 413000, 1378000, CPU_MAX},
{546, 800000, 0, 78, 99, 1, 0, 1144000, 413000, 1170000, CPU_MAX},
{419, 800000, 0, 78, 85, 1, 0, 1144000, 267000, 858000, CPU_MAX},
{338, 800000, 0, 78, 85, 1, 0, 546000, 200000, 0, CPU_MAX},
{260, 800000, 0, 78, 85, 1, 0, 421000, 160000, 0, CPU_MAX},
};
static int mif_min_table[] = {
100000, 133000, 167000,
276000, 348000, 416000,
543000, 632000, 828000,
1026000, 1264000, 1456000,
1552000,
};
static gpu_attribute gpu_config_attributes[GPU_CONFIG_LIST_END] = {
{GPU_MAX_CLOCK, 650},
{GPU_MAX_CLOCK_LIMIT, 650},
{GPU_MIN_CLOCK, 260},
{GPU_DVFS_START_CLOCK, 260},
{GPU_DVFS_BL_CONFIG_CLOCK, 260},
{GPU_GOVERNOR_TYPE, G3D_DVFS_GOVERNOR_INTERACTIVE},
{GPU_GOVERNOR_START_CLOCK_DEFAULT, 260},
{GPU_GOVERNOR_START_CLOCK_INTERACTIVE, 260},
{GPU_GOVERNOR_START_CLOCK_STATIC, 260},
{GPU_GOVERNOR_START_CLOCK_BOOSTER, 260},
{GPU_GOVERNOR_TABLE_DEFAULT, (uintptr_t)&gpu_dvfs_table_default},
{GPU_GOVERNOR_TABLE_INTERACTIVE, (uintptr_t)&gpu_dvfs_table_default},
{GPU_GOVERNOR_TABLE_STATIC, (uintptr_t)&gpu_dvfs_table_default},
{GPU_GOVERNOR_TABLE_BOOSTER, (uintptr_t)&gpu_dvfs_table_default},
{GPU_GOVERNOR_TABLE_SIZE_DEFAULT, GPU_DVFS_TABLE_LIST_SIZE(gpu_dvfs_table_default)},
{GPU_GOVERNOR_TABLE_SIZE_INTERACTIVE, GPU_DVFS_TABLE_LIST_SIZE(gpu_dvfs_table_default)},
{GPU_GOVERNOR_TABLE_SIZE_STATIC, GPU_DVFS_TABLE_LIST_SIZE(gpu_dvfs_table_default)},
{GPU_GOVERNOR_TABLE_SIZE_BOOSTER, GPU_DVFS_TABLE_LIST_SIZE(gpu_dvfs_table_default)},
{GPU_GOVERNOR_INTERACTIVE_HIGHSPEED_CLOCK, 419},
{GPU_GOVERNOR_INTERACTIVE_HIGHSPEED_LOAD, 95},
{GPU_GOVERNOR_INTERACTIVE_HIGHSPEED_DELAY, 0},
{GPU_DEFAULT_VOLTAGE, 800000},
{GPU_COLD_MINIMUM_VOL, 0},
{GPU_VOLTAGE_OFFSET_MARGIN, 25000},
{GPU_TMU_CONTROL, 1},
{GPU_TEMP_THROTTLING1, 650},
{GPU_TEMP_THROTTLING2, 600},
{GPU_TEMP_THROTTLING3, 546},
{GPU_TEMP_THROTTLING4, 419},
{GPU_TEMP_THROTTLING5, 338},
{GPU_TEMP_TRIPPING, 260},
{GPU_POWER_COEFF, 625}, /* all core on param */
{GPU_DVFS_TIME_INTERVAL, 5},
{GPU_DEFAULT_WAKEUP_LOCK, 1},
{GPU_BUS_DEVFREQ, 0},
{GPU_DYNAMIC_ABB, 0},
{GPU_EARLY_CLK_GATING, 0},
{GPU_DVS, 1},
{GPU_PERF_GATHERING, 0},
#ifdef CONFIG_MALI_SEC_HWCNT
{GPU_HWCNT_PROFILE, 0},
{GPU_HWCNT_GATHERING, 1},
{GPU_HWCNT_POLLING_TIME, 90},
{GPU_HWCNT_UP_STEP, 3},
{GPU_HWCNT_DOWN_STEP, 2},
{GPU_HWCNT_GPR, 1},
{GPU_HWCNT_DUMP_PERIOD, 50}, /* ms */
{GPU_HWCNT_CHOOSE_JM , 0x56},
{GPU_HWCNT_CHOOSE_SHADER , 0x560},
{GPU_HWCNT_CHOOSE_TILER , 0x800},
{GPU_HWCNT_CHOOSE_L3_CACHE , 0},
{GPU_HWCNT_CHOOSE_MMU_L2 , 0x80},
#endif
{GPU_RUNTIME_PM_DELAY_TIME, 50},
{GPU_DVFS_POLLING_TIME, 30},
{GPU_PMQOS_INT_DISABLE, 1},
{GPU_PMQOS_MIF_MAX_CLOCK, 1539000},
{GPU_PMQOS_MIF_MAX_CLOCK_BASE, 650},
{GPU_CL_DVFS_START_BASE, 419},
{GPU_DEBUG_LEVEL, DVFS_WARNING},
{GPU_TRACE_LEVEL, TRACE_ALL},
#ifdef CONFIG_MALI_DVFS_USER
{GPU_UDVFS_ENABLE, 1},
#endif
{GPU_MO_MIN_CLOCK, 419},
{GPU_BOOST_EGL_MIN_LOCK, 1872000},
};
#ifdef CONFIG_MALI_DVFS_USER
unsigned int gpu_get_config_attr_size(void)
{
return sizeof(gpu_config_attributes);
}
#endif
int gpu_dvfs_decide_max_clock(struct exynos_context *platform)
{
if (!platform)
return -1;
return 0;
}
void *gpu_get_config_attributes(void)
{
return &gpu_config_attributes;
}
uintptr_t gpu_get_max_freq(void)
{
return gpu_get_attrib_data(gpu_config_attributes, GPU_MAX_CLOCK) * 1000;
}
uintptr_t gpu_get_min_freq(void)
{
return gpu_get_attrib_data(gpu_config_attributes, GPU_MIN_CLOCK) * 1000;
}
struct clk *vclk_g3d;
#ifdef CONFIG_REGULATOR
struct regulator *g3d_regulator;
struct regulator *g3d_m_regulator;
#endif /* CONFIG_REGULATOR */
int gpu_is_power_on(void)
{
unsigned int val;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
val = __raw_readl(EXYNOS_PMU_G3D_STATUS);
#else
exynos_pmu_read(EXYNOS_PMU_G3D_STATUS, &val);
#endif
return ((val & LOCAL_PWR_CFG) == LOCAL_PWR_CFG) ? 1 : 0;
}
int gpu_power_init(struct kbase_device *kbdev)
{
struct exynos_context *platform = (struct exynos_context *) kbdev->platform_context;
if (!platform)
return -ENODEV;
GPU_LOG(DVFS_INFO, DUMMY, 0u, 0u, "power initialized\n");
return 0;
}
int gpu_get_cur_clock(struct exynos_context *platform)
{
if (!platform)
return -ENODEV;
if (!vclk_g3d) {
GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: clock is not initialized\n", __func__);
return -1;
}
return cal_dfs_get_rate(dvfs_g3d)/KHZ;
}
int gpu_register_dump(void)
{
#ifdef CONFIG_MALI_RT_PM
#ifdef CONFIG_REGULATOR
#if defined(CONFIG_REGULATOR_S2MPS16)
if (gpu_is_power_on() && !s2m_get_dvs_is_on()) {
#endif
#else
if (gpu_is_power_on()) {
#endif
#endif
#ifdef MALI_SEC_INTEGRATION
/* MCS Value check */
GPU_LOG(DVFS_WARNING, LSI_REGISTER_DUMP, 0x10051224 , __raw_readl(EXYNOS7420_VA_SYSREG + 0x1224),
"REG_DUMP: G3D_EMA_RF2_UHD_CON %x\n", __raw_readl(EXYNOS7420_VA_SYSREG + 0x1224));
/* G3D PMU */
GPU_LOG(DVFS_WARNING, LSI_REGISTER_DUMP, 0x105C4100, __raw_readl(EXYNOS_PMU_G3D_CONFIGURATION),
"REG_DUMP: EXYNOS_PMU_G3D_CONFIGURATION %x\n", __raw_readl(EXYNOS_PMU_G3D_CONFIGURATION));
GPU_LOG(DVFS_WARNING, LSI_REGISTER_DUMP, 0x105C4104, __raw_readl(EXYNOS_PMU_G3D_STATUS),
"REG_DUMP: EXYNOS_PMU_G3D_STATUS %x\n", __raw_readl(EXYNOS_PMU_G3D_STATUS));
/* G3D PLL */
GPU_LOG(DVFS_WARNING, LSI_REGISTER_DUMP, 0x105C6100, __raw_readl(EXYNOS_PMU_GPU_DVS_CTRL),
"REG_DUMP: EXYNOS_PMU_GPU_DVS_CTRL %x\n", __raw_readl(EXYNOS_PMU_GPU_DVS_CTRL));
GPU_LOG(DVFS_WARNING, LSI_REGISTER_DUMP, 0x10576104, __raw_readl(EXYNOS_PMU_GPU_DVS_STATUS),
"REG_DUMP: GPU_DVS_STATUS %x\n", __raw_readl(EXYNOS_PMU_GPU_DVS_STATUS));
GPU_LOG(DVFS_WARNING, LSI_REGISTER_DUMP, 0x10051234, __raw_readl(EXYNOS7420_VA_SYSREG + 0x1234),
"REG_DUMP: G3D_G3DCFG_REG0 %x\n", __raw_readl(EXYNOS7420_VA_SYSREG + 0x1234));
#ifdef CONFIG_EXYNOS_BUSMONITOR
GPU_LOG(DVFS_WARNING, LSI_REGISTER_DUMP, 0x14A002F0, __raw_readl(g3d0_outstanding_regs + 0x2F0),
"REG_DUMP: read outstanding %x\n", __raw_readl(g3d0_outstanding_regs + 0x2F0));
GPU_LOG(DVFS_WARNING, LSI_REGISTER_DUMP, 0x14A003F0, __raw_readl(g3d0_outstanding_regs + 0x3F0),
"REG_DUMP: write outstanding %x\n", __raw_readl(g3d0_outstanding_regs + 0x3F0));
GPU_LOG(DVFS_WARNING, LSI_REGISTER_DUMP, 0x14A202F0, __raw_readl(g3d1_outstanding_regs + 0x2F0),
"REG_DUMP: read outstanding %x\n", __raw_readl(g3d1_outstanding_regs + 0x2F0));
GPU_LOG(DVFS_WARNING, LSI_REGISTER_DUMP, 0x14A203F0, __raw_readl(g3d1_outstanding_regs + 0x3F0),
"REG_DUMP: write outstanding %x\n", __raw_readl(g3d1_outstanding_regs + 0x3F0));
#endif /* CONFIG_EXYNOS_BUSMONITOR */
#endif
#ifdef CONFIG_MALI_RT_PM
} else {
#ifdef CONFIG_REGULATOR
#if defined(CONFIG_REGULATOR_S2MPS16)
GPU_LOG(DVFS_WARNING, DUMMY, 0u, 0u, "%s: Power Status %d, DVS Status %d\n", __func__, gpu_is_power_on(), s2m_get_dvs_is_on());
#endif
#else
GPU_LOG(DVFS_WARNING, DUMMY, 0u, 0u, "%s: Power Status %d\n", __func__, gpu_is_power_on());
#endif
}
#endif
return 0;
}
#ifdef CONFIG_MALI_DVFS
static int gpu_set_clock(struct exynos_context *platform, int clk)
{
unsigned long g3d_rate = clk * KHZ;
int ret = 0;
#ifdef CONFIG_MALI_RT_PM
if (platform->exynos_pm_domain)
mutex_lock(&platform->exynos_pm_domain->access_lock);
if (!gpu_is_power_on()) {
ret = -1;
GPU_LOG(DVFS_INFO, DUMMY, 0u, 0u, "%s: can't set clock in the power-off state!\n", __func__);
goto err;
}
#endif /* CONFIG_MALI_RT_PM */
cal_dfs_set_rate(dvfs_g3d, g3d_rate);
platform->cur_clock = cal_dfs_get_rate(dvfs_g3d)/KHZ;
GPU_LOG(DVFS_INFO, LSI_CLOCK_VALUE, g3d_rate/KHZ, platform->cur_clock,
"[id: %x] clock set: %ld, clock get: %d\n", dvfs_g3d, g3d_rate/KHZ, platform->cur_clock);
#ifdef CONFIG_MALI_RT_PM
err:
if (platform->exynos_pm_domain)
mutex_unlock(&platform->exynos_pm_domain->access_lock);
#endif /* CONFIG_MALI_RT_PM */
return ret;
}
static int gpu_get_clock(struct kbase_device *kbdev)
{
struct exynos_context *platform = (struct exynos_context *) kbdev->platform_context;
if (!platform)
return -ENODEV;
KBASE_DEBUG_ASSERT(kbdev != NULL);
vclk_g3d = clk_get(kbdev->dev, "vclk_g3d");
if (IS_ERR(vclk_g3d)) {
GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: failed to clk_get [vclk_g3d]\n", __func__);
return -1;
}
clk_prepare_enable(vclk_g3d);
return 0;
}
static int gpu_enable_clock(struct exynos_context *platform)
{
GPU_LOG(DVFS_DEBUG, DUMMY, 0u, 0u, "%s: [vclk_g3d]\n", __func__);
clk_prepare_enable(vclk_g3d);
return 0;
}
static int gpu_disable_clock(struct exynos_context *platform)
{
GPU_LOG(DVFS_DEBUG, DUMMY, 0u, 0u, "%s: [vclk_g3d]\n", __func__);
#ifdef CONFIG_EXYNOS8890_BTS_OPTIMIZATION
bts_ext_scenario_set(TYPE_G3D, TYPE_G3D_FREQ, 0);
#endif
clk_disable_unprepare(vclk_g3d);
return 0;
}
#endif
int gpu_clock_init(struct kbase_device *kbdev)
{
#ifdef CONFIG_MALI_DVFS
int ret;
KBASE_DEBUG_ASSERT(kbdev != NULL);
ret = gpu_get_clock(kbdev);
if (ret < 0)
return -1;
#ifdef CONFIG_EXYNOS_BUSMONITOR
g3d0_outstanding_regs = ioremap(0x14A00000, SZ_1K);
g3d1_outstanding_regs = ioremap(0x14A20000, SZ_1K);
#endif /* CONFIG_EXYNOS_BUSMONITOR */
GPU_LOG(DVFS_INFO, DUMMY, 0u, 0u, "clock initialized\n");
#else
vclk_g3d = clk_get(kbdev->dev, "vclk_g3d");
clk_prepare_enable(vclk_g3d);
#endif
return 0;
}
int gpu_get_cur_voltage(struct exynos_context *platform)
{
int ret = 0;
#ifdef CONFIG_REGULATOR
if (!g3d_regulator) {
GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: regulator is not initialized\n", __func__);
return -1;
}
ret = regulator_get_voltage(g3d_regulator);
#endif /* CONFIG_REGULATOR */
return ret;
}
static int gpu_set_voltage(struct exynos_context *platform, int vol)
{
if (gpu_get_cur_voltage(platform) == vol)
return 0;
if (!gpu_is_power_on()) {
GPU_LOG(DVFS_INFO, DUMMY, 0u, 0u, "%s: can't set voltage in the power-off state!\n", __func__);
return -1;
}
#ifdef CONFIG_REGULATOR
if (!g3d_regulator) {
GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: regulator is not initialized\n", __func__);
return -1;
}
#ifdef CONFIG_EXYNOS_CL_DVFS_G3D
regulator_sync_voltage(g3d_regulator);
#endif /* CONFIG_EXYNOS_CL_DVFS_G3D */
if (regulator_set_voltage(g3d_regulator, vol, vol) != 0) {
GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: failed to set voltage, voltage: %d\n", __func__, vol);
return -1;
}
#endif /* CONFIG_REGULATOR */
platform->cur_voltage = gpu_get_cur_voltage(platform);
GPU_LOG(DVFS_DEBUG, LSI_VOL_VALUE, vol, platform->cur_voltage, "voltage set: %d, voltage get:%d\n", vol, platform->cur_voltage);
return 0;
}
static int gpu_set_voltage_pre(struct exynos_context *platform, bool is_up)
{
if (!platform)
return -ENODEV;
if (!is_up && platform->dynamic_abb_status)
set_match_abb(ID_G3D, gpu_dvfs_get_cur_asv_abb());
return 0;
}
static int gpu_set_voltage_post(struct exynos_context *platform, bool is_up)
{
if (!platform)
return -ENODEV;
if (is_up && platform->dynamic_abb_status)
set_match_abb(ID_G3D, gpu_dvfs_get_cur_asv_abb());
return 0;
}
static struct gpu_control_ops ctr_ops = {
.is_power_on = gpu_is_power_on,
#ifdef CONFIG_MALI_DVFS
.set_voltage = gpu_set_voltage,
.set_voltage_pre = gpu_set_voltage_pre,
.set_voltage_post = gpu_set_voltage_post,
.set_clock_to_osc = NULL,
.set_clock = gpu_set_clock,
.set_clock_pre = NULL,
.set_clock_post = NULL,
.enable_clock = gpu_enable_clock,
.disable_clock = gpu_disable_clock,
#endif
};
struct gpu_control_ops *gpu_get_control_ops(void)
{
return &ctr_ops;
}
#ifdef CONFIG_REGULATOR
extern int s2m_set_dvs_pin(bool gpio_val);
int gpu_enable_dvs(struct exynos_context *platform)
{
#ifdef CONFIG_MALI_RT_PM
#ifdef CONFIG_EXYNOS_CL_DVFS_G3D
int level = 0;
#endif /* CONFIG_EXYNOS_CL_DVFS_G3D */
if (!platform->dvs_status)
return 0;
if (!gpu_is_power_on()) {
GPU_LOG(DVFS_INFO, DUMMY, 0u, 0u, "%s: can't set dvs in the power-off state!\n", __func__);
return -1;
}
#if defined(CONFIG_REGULATOR_S2MPS16)
#ifdef CONFIG_EXYNOS_CL_DVFS_G3D
if (!platform->dvs_is_enabled)
{
level = gpu_dvfs_get_level(gpu_get_cur_clock(platform));
exynos_cl_dvfs_stop(ID_G3D, level);
}
#endif /* CONFIG_EXYNOS_CL_DVFS_G3D */
/* Do not need to enable dvs during suspending */
if (!pkbdev->pm.suspending) {
// if (s2m_set_dvs_pin(true) != 0) {
if (cal_dfs_ext_ctrl(dvfs_g3d, cal_dfs_dvs, 1) != 0) {
GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: failed to enable dvs\n", __func__);
return -1;
}
}
#endif /* CONFIG_REGULATOR_S2MPS16 */
GPU_LOG(DVFS_INFO, DUMMY, 0u, 0u, "dvs is enabled (vol: %d)\n", gpu_get_cur_voltage(platform));
#endif
return 0;
}
int gpu_disable_dvs(struct exynos_context *platform)
{
if (!platform->dvs_status)
return 0;
#ifdef CONFIG_MALI_RT_PM
#if defined(CONFIG_REGULATOR_S2MPS16)
// if (s2m_set_dvs_pin(false) != 0) {
if (cal_dfs_ext_ctrl(dvfs_g3d, cal_dfs_dvs, 0) != 0) {
GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: failed to disable dvs\n", __func__);
return -1;
}
#endif /* CONFIG_REGULATOR_S2MPS16 */
GPU_LOG(DVFS_INFO, DUMMY, 0u, 0u, "dvs is disabled (vol: %d)\n", gpu_get_cur_voltage(platform));
#endif
return 0;
}
int gpu_regulator_init(struct exynos_context *platform)
{
#ifdef CONFIG_MALI_DVFS
g3d_regulator = regulator_get(NULL, "vdd_g3d");
if (IS_ERR(g3d_regulator)) {
GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: failed to get vdd_g3d regulator, 0x%p\n", __func__, g3d_regulator);
g3d_regulator = NULL;
return -1;
}
g3d_m_regulator = regulator_get(NULL, "vdd_extra");
if (IS_ERR(g3d_m_regulator)) {
GPU_LOG(DVFS_ERROR, DUMMY, 0u, 0u, "%s: failed to get vdd_g3d_m regulator, 0x%p\n", __func__, g3d_m_regulator);
g3d_m_regulator = NULL;
return -1;
}
if (platform->dvs_status)
GPU_LOG(DVFS_INFO, DUMMY, 0u, 0u, "dvs GPIO PMU status enable\n");
GPU_LOG(DVFS_INFO, DUMMY, 0u, 0u, "regulator initialized\n");
#endif
return 0;
}
#endif /* CONFIG_REGULATOR */
int *get_mif_table(int *size)
{
*size = ARRAY_SIZE(mif_min_table);
return mif_min_table;
}
| 28.654386 | 129 | 0.752281 |
eba8477070b7530c6a1d669418a9cff83eae0fa2 | 304 | h | C | Classes/MouseRect.h | KHAKhazeus/BattleField_RTS | f290492faa34e6dff9f8496dc592395a4eb47756 | [
"MIT"
] | 6 | 2018-05-15T05:10:53.000Z | 2019-09-07T08:21:36.000Z | Classes/MouseRect.h | KHAKhazeus/BattleField_RTS | f290492faa34e6dff9f8496dc592395a4eb47756 | [
"MIT"
] | null | null | null | Classes/MouseRect.h | KHAKhazeus/BattleField_RTS | f290492faa34e6dff9f8496dc592395a4eb47756 | [
"MIT"
] | null | null | null | #ifndef _MOUSERECT
#define _MOUSERECT
#include "cocos2d.h"
USING_NS_CC;
//Class of mouse rect selection
class MouseRect : public cocos2d::DrawNode
{
public:
CREATE_FUNC(MouseRect);
//Start point and end point
Vec2 start, end;
virtual void update(float delta);
void reset();
};
#endif _MOUSERECT | 15.2 | 42 | 0.75 |
6f7236c1483e046a42895e94ce5bf8bc8611461f | 1,062 | h | C | include/reflection/visitor.h | StefanoLanza/Reflection | 2749f8f86c65680787162199093a0c35bd08a8ae | [
"MIT"
] | null | null | null | include/reflection/visitor.h | StefanoLanza/Reflection | 2749f8f86c65680787162199093a0c35bd08a8ae | [
"MIT"
] | 5 | 2020-09-01T14:06:03.000Z | 2020-09-26T09:25:46.000Z | include/reflection/visitor.h | StefanoLanza/Reflection | 2749f8f86c65680787162199093a0c35bd08a8ae | [
"MIT"
] | null | null | null | #pragma once
#include "config.h"
#include <core/typeId.h>
#include <functional>
namespace Typhoon::Reflection {
class Type;
class Namespace;
class StructType;
class TypeVisitor {
public:
~TypeVisitor() = default;
virtual void beginNamespace(const Namespace& nameSpace) = 0;
virtual void endNamespace(const refl::Namespace& nameSpace) = 0;
virtual void beginClass(const StructType& type) = 0;
virtual void endClass() = 0;
virtual void visitType(const Type& type) = 0;
virtual void visitField(const char* fieldName, const Type& type) = 0;
};
struct VisitOptions {
bool recursive = true;
};
void visitType(TypeId typeId, TypeVisitor& visitor, const VisitOptions& options);
void visitType(const Type& type, TypeVisitor& visitor, const VisitOptions& options);
// Helper
template <class T>
inline void visitType(TypeVisitor& visitor, const VisitOptions& options) {
visitType(getTypeId<T>(), visitor, options);
}
void visitNamespace(const Namespace& nameSpace, TypeVisitor& visitor, const VisitOptions& options);
} // namespace Typhoon::Reflection
| 24.697674 | 99 | 0.757062 |
6ffaccf10e252c21e110b74466d9901de63c84d0 | 9,061 | c | C | tools/ccc_validate.c | wdj/CoMet | 3e3c099c6eadafc24a1b69d81f07b3a4ed3e16ef | [
"BSD-2-Clause"
] | 1 | 2021-04-14T23:16:32.000Z | 2021-04-14T23:16:32.000Z | tools/ccc_validate.c | wdj/comet | 3e3c099c6eadafc24a1b69d81f07b3a4ed3e16ef | [
"BSD-2-Clause"
] | null | null | null | tools/ccc_validate.c | wdj/comet | 3e3c099c6eadafc24a1b69d81f07b3a4ed3e16ef | [
"BSD-2-Clause"
] | null | null | null | //-----------------------------------------------------------------------------
// "Manually" calculate a CCC metric value directly from the original
// SNP file.
//-----------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
enum{MAX_LABEL_LEN = 11};
//-----------------------------------------------------------------------------
int process_line(int argc, char** argv, FILE* snptxtfile, FILE* lifile) {
if (argc != 1+4 && argc != 1+6) {
// Input format expectd from each line of stdin:
printf("Line format: lineno0 bitno0 lineno1 bitno1 [lineno2 bitno2]\n");
printf("Line and bit numbers are 0-based\n");
return 1;
}
const int num_way = argc == 1+4 ? 2 : 3;
enum {NUM_WAY_MAX = 3};
int lineno[NUM_WAY_MAX];
lineno[0] = atoi(argv[1]);
lineno[1] = atoi(argv[3]);
lineno[2] = num_way == 3 ? atoi(argv[5]) : 0;
int bitno[NUM_WAY_MAX];
bitno[0] = atoi(argv[2]);
bitno[1] = atoi(argv[4]);
bitno[2] = num_way == 3 ? atoi(argv[6]) : 0;
const int no_al = 'X';
const int label_len = MAX_LABEL_LEN;
unsigned char label[NUM_WAY_MAX][label_len+1];
for (int i=0; i<num_way; ++i) {
for (int j=0; j<label_len+1; ++j) {
label[i][j] = 0;
}
}
int num_read = 0;
int fseek_success = 0;
// Initial loop to get upper bound on fields per line.
fseek_success = fseek(snptxtfile, 0, SEEK_SET);
if (0 != fseek_success) {
printf("Error: error reading SNP data file (0).\n");
return 1;
}
int c = 0;
while ((c = fgetc(snptxtfile)) != '\n') {
if (c == EOF) {
printf("Error snp file has no newlines.");
return 1;
}
num_read++;
}
const int num_field_max = num_read / 2 + 1;
// Storage for allelel labels and alleles for each needed SNP.
int al[NUM_WAY_MAX][2];
int* elts[NUM_WAY_MAX];
for (int i=0; i<num_way; ++i) {
al[i][0] = no_al;
al[i][1] = no_al;
elts[i] = malloc(num_field_max * 2 * sizeof(int));
}
int num_field = 0;
// Loop over num_way to input the required vectors.
for (int i=0; i<num_way; ++i) {
fseek_success = fseek(lifile, lineno[i]*sizeof(size_t), SEEK_SET);
if (0 != fseek_success) {
printf("Error: error reading label_indices file (1).\n");
return 1;
}
// Get the index to this line in the file
size_t line_index = 0;
num_read = fread(&line_index, sizeof(size_t), 1, lifile);
if (1 != num_read) {
printf("Error: error reading label_indices file (2).\n");
return 1;
}
fseek_success = fseek(snptxtfile, line_index, SEEK_SET);
if (0 != fseek_success) {
printf("Error: error reading SNP data file (1).\n");
return 1;
}
int num_tabs = 0;
int j = 0;
// Loop to read in line
while ((c = fgetc(snptxtfile)) != '\n') {
if (c == '\t') {
num_tabs++;
continue;
}
// Get line label
if (num_tabs == 1) {
label[i][j++] = c; //check
continue;
}
if (num_tabs == 3) {
j = 0;
}
if (num_tabs < 4) {
continue;
}
// Store allele
elts[i][j++] = c;
if (i == 0) {
num_field++;
}
// Record allele label
if (c != '0') {
if (al[i][0] == no_al) {
al[i][0] = c;
} else if (al[i][1] == no_al) {
if (al[i][0] < c) {
al[i][1] = c;
} else if (al[i][0] > c) {
al[i][1] = al[i][0];
al[i][0] = c;
}
}
} // if
} // while
} // for i
num_field /= 2;
// We account for sparsity of the data
// First get sum_i's
int count1[NUM_WAY_MAX];
int sum1[NUM_WAY_MAX];
for (int i=0; i<num_way; ++i) {
count1[i] = 0;
sum1[i] = 0;
for (int f=0; f<num_field; ++f) {
const int e0 = elts[i][2*f];
const int e1 = elts[i][2*f+1];
if (e0 == '0') {
// assert(e1 == '0');
continue;
}
count1[i] += 1;
// Calculate row and add to sum - see paper
const int rho = (e0 == al[i][bitno[i]]) + (e1 == al[i][bitno[i]]);
sum1[i] += rho;
} // for f
} // for i
// Now get sum_{ij}'s (or sum_{ijk}'s if 3-way)
int countijk = 0;
int sumijk = 0;
for (int f=0; f<num_field; ++f) {
const int e00 = elts[0][2*f];
const int e01 = elts[0][2*f+1];
if (e00 == '0') {
continue;
}
const int e10 = elts[1][2*f];
const int e11 = elts[1][2*f+1];
if (e10 == '0') {
continue;
}
const int e20 = num_way == 2 ? 1 : elts[2][2*f];
const int e21 = num_way == 2 ? 1 : elts[2][2*f+1];
if (num_way == 3 && e20 == '0') {
continue;
}
countijk += 1;
const int rho0 = (e00 == al[0][bitno[0]]) + (e01 == al[0][bitno[0]]);
const int rho1 = (e10 == al[1][bitno[1]]) + (e11 == al[1][bitno[1]]);
const int rho2 = num_way == 2 ? 1 :
(e20 == al[2][bitno[2]]) + (e21 == al[2][bitno[2]]);
sumijk += rho0 * rho1 * rho2;
} // for f
// substitute into formula
double f1[NUM_WAY_MAX];
for (int i=0; i<num_way; ++i) {
f1[i] = 0 == count1[i] ? 0 : sum1[i] * 1. / (double)( 2 * count1[i] );
}
const double fijk = 0 == countijk ? 0 :
sumijk * 1. / (double)( (1 << num_way) * countijk );
// NOTE hard-wired constant here
const double ccc_multiplier = 9. / (double)2.;
const double ccc_param = 2. / (double)3.;
const double value = 2 == num_way ?
ccc_multiplier * fijk * (1 - ccc_param*f1[0]) * (1 - ccc_param*f1[1]) :
ccc_multiplier * fijk * (1 - ccc_param*f1[0]) * (1 - ccc_param*f1[1])
* (1 - ccc_param*f1[2]);
// Permute labels to output each result in a uniform order
int perm[3];
if (num_way == 2) {
if (lineno[0] > lineno[1]) {
perm[0] = 0;
perm[1] = 1;
} else {
perm[0] = 1;
perm[1] = 0;
}
} else {
if (lineno[0] > lineno[1] && lineno[1] > lineno[2]) {
perm[0] = 0;
perm[1] = 1;
perm[2] = 2;
} else if (lineno[0] > lineno[2] && lineno[2] > lineno[1]) {
perm[0] = 0;
perm[1] = 2;
perm[2] = 1;
} else if (lineno[1] > lineno[0] && lineno[0] > lineno[2]) {
perm[0] = 1;
perm[1] = 0;
perm[2] = 2;
} else if (lineno[1] > lineno[2] && lineno[2] > lineno[0]) {
perm[0] = 1;
perm[1] = 2;
perm[2] = 0;
} else if (lineno[2] > lineno[0] && lineno[0] > lineno[1]) {
perm[0] = 2;
perm[1] = 0;
perm[2] = 1;
} else if (lineno[2] > lineno[1] && lineno[1] > lineno[0]) {
perm[0] = 2;
perm[1] = 1;
perm[2] = 0;
}
} // if num_way
// Do output to stdout
for (int i=0; i<num_way; ++i) {
int iperm = perm[i];
printf(0 != i ? " " : "");
printf("%i %i", lineno[iperm], bitno[iperm]);
} // for i
for (int i=0; i<num_way; ++i) {
int iperm = perm[i];
printf(" %s_%c", label[iperm], al[iperm][bitno[iperm]]);
} // for i
printf(" %f\n", value);
for (int i=0; i<num_way; ++i) {
free(elts[i]);
}
return 0;
}
//-----------------------------------------------------------------------------
int main(int argc, char** argv) {
if (argc < 4) {
printf("ccc_validate: create validation data for CCC calculations\n");
printf("Usage: ccc_validate <num_way> <snptxtfile> <line_index_file>\n");
return 0;
}
if (!( ('2' == argv[1][0] || '3' == argv[1][0]) && 0 == argv[1][1] )) {
printf("Error: invalid num_way\n");
return 1;
}
const int num_way = atoi(argv[1]);
FILE* snptxtfile = fopen(argv[2], "r");
if (!snptxtfile) {
printf("Error: unable to open file. %s\n", argv[2]);
return 1;
}
FILE* lifile = fopen(argv[3], "rb");
if (!lifile) {
printf("Error: unable to open file. %s\n", argv[2]);
return 1;
}
enum{LINE_LEN_MAX = 4096};
unsigned char line[LINE_LEN_MAX];
int lineptr = 0;
int argc_ = 1;
char* argv_[LINE_LEN_MAX];
int c = 0;
// Loop over chars from stdin
while ((c = fgetc(stdin)) != EOF) {
if (c != '\n') {
line[lineptr++] = c;
if (lineptr >= LINE_LEN_MAX) {
printf("Error: line too long");
return 1;
}
continue;
}
// Process full line
// Create an arg list consisting of the tokens
line[lineptr] = 0;
argv_[0] = (char*)&line[lineptr];
for (int i=0; i<lineptr; ++i) {
if (line[i] == ' ') {
line[i] = 0;
}
}
for (int i=0; i<lineptr; ++i) {
if (line[i] != 0 && (i == 0 || line[i-1] == 0)) {
argv_[argc_++] = (char*)&line[i];
}
}
// Only use the first several tokens, specifying line and bit numbers
argc_ = argc_ < 2*num_way+1 ? argc_ : 2*num_way+1;
int result = process_line(argc_, argv_, snptxtfile, lifile);
if (result != 0) {
return 1;
}
// Prepare for next line
lineptr = 0;
argc_ = 1;
}
fclose(snptxtfile);
fclose(lifile);
return 0;
}
//-----------------------------------------------------------------------------
| 23.353093 | 79 | 0.487363 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.