hexsha stringlengths 40 40 | size int64 5 2.72M | ext stringclasses 5
values | lang stringclasses 1
value | max_stars_repo_path stringlengths 3 976 | max_stars_repo_name stringlengths 5 113 | max_stars_repo_head_hexsha stringlengths 40 78 | 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:01:43 2022-03-31 23:59:48 ⌀ | max_stars_repo_stars_event_max_datetime stringdate 2015-01-01 00:06:24 2022-03-31 23:59:53 ⌀ | max_issues_repo_path stringlengths 3 976 | max_issues_repo_name stringlengths 5 116 | max_issues_repo_head_hexsha stringlengths 40 78 | 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 976 | max_forks_repo_name stringlengths 5 116 | max_forks_repo_head_hexsha stringlengths 40 78 | 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:19 2022-03-31 23:59:49 ⌀ | max_forks_repo_forks_event_max_datetime stringdate 2015-01-03 12:00:57 2022-03-31 23:59:49 ⌀ | content stringlengths 5 2.72M | avg_line_length float64 1.38 573k | max_line_length int64 2 1.01M | alphanum_fraction float64 0 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
239fcbc12422d02b59f5c214c5d9be6a8cb3ea73 | 2,387 | h | C | shell/browser/ui/file_dialog.h | lingxiao-Zhu/electron | 2d85b1f8f527d55f884904dbfdde50ee66a49830 | [
"MIT"
] | 88,283 | 2016-04-04T19:29:13.000Z | 2022-03-31T23:33:33.000Z | shell/browser/ui/file_dialog.h | lingxiao-Zhu/electron | 2d85b1f8f527d55f884904dbfdde50ee66a49830 | [
"MIT"
] | 27,327 | 2016-04-04T19:38:58.000Z | 2022-03-31T22:34:10.000Z | shell/browser/ui/file_dialog.h | ColleenKeegan/electron | f3dc3997b10fd79439ad22ff5973b3d3541d8e9d | [
"MIT"
] | 15,972 | 2016-04-04T19:32:06.000Z | 2022-03-31T08:54:00.000Z | // Copyright (c) 2013 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_BROWSER_UI_FILE_DIALOG_H_
#define SHELL_BROWSER_UI_FILE_DIALOG_H_
#include <string>
#include <utility>
#include <vector>
#include "base/files/file_path.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/promise.h"
namespace electron {
class NativeWindow;
}
namespace file_dialog {
// <description, extensions>
typedef std::pair<std::string, std::vector<std::string>> Filter;
typedef std::vector<Filter> Filters;
enum OpenFileDialogProperty {
OPEN_DIALOG_OPEN_FILE = 1 << 0,
OPEN_DIALOG_OPEN_DIRECTORY = 1 << 1,
OPEN_DIALOG_MULTI_SELECTIONS = 1 << 2,
OPEN_DIALOG_CREATE_DIRECTORY = 1 << 3, // macOS
OPEN_DIALOG_SHOW_HIDDEN_FILES = 1 << 4,
OPEN_DIALOG_PROMPT_TO_CREATE = 1 << 5, // Windows
OPEN_DIALOG_NO_RESOLVE_ALIASES = 1 << 6, // macOS
OPEN_DIALOG_TREAT_PACKAGE_APP_AS_DIRECTORY = 1 << 7, // macOS
FILE_DIALOG_DONT_ADD_TO_RECENT = 1 << 8, // Windows
};
enum SaveFileDialogProperty {
SAVE_DIALOG_CREATE_DIRECTORY = 1 << 0,
SAVE_DIALOG_SHOW_HIDDEN_FILES = 1 << 1,
SAVE_DIALOG_TREAT_PACKAGE_APP_AS_DIRECTORY = 1 << 2, // macOS
SAVE_DIALOG_SHOW_OVERWRITE_CONFIRMATION = 1 << 3, // Linux
SAVE_DIALOG_DONT_ADD_TO_RECENT = 1 << 4, // Windows
};
struct DialogSettings {
electron::NativeWindow* parent_window = nullptr;
std::string title;
std::string message;
std::string button_label;
std::string name_field_label;
base::FilePath default_path;
Filters filters;
int properties = 0;
bool shows_tag_field = true;
bool force_detached = false;
bool security_scoped_bookmarks = false;
DialogSettings();
DialogSettings(const DialogSettings&);
~DialogSettings();
};
bool ShowOpenDialogSync(const DialogSettings& settings,
std::vector<base::FilePath>* paths);
void ShowOpenDialog(const DialogSettings& settings,
gin_helper::Promise<gin_helper::Dictionary> promise);
bool ShowSaveDialogSync(const DialogSettings& settings, base::FilePath* path);
void ShowSaveDialog(const DialogSettings& settings,
gin_helper::Promise<gin_helper::Dictionary> promise);
} // namespace file_dialog
#endif // SHELL_BROWSER_UI_FILE_DIALOG_H_
| 30.602564 | 78 | 0.721408 |
23a0ea2c26c565a554301bf087705ff2d7b54e7a | 630 | h | C | Engine/ZenCore/Export/Graphic/Buffer/zcExpGfxBuffer.h | ZenEngine3D/ZenEngine | 42bcd06f743eb1381a587c9671de67e24cf72316 | [
"MIT"
] | 1 | 2018-10-12T19:10:59.000Z | 2018-10-12T19:10:59.000Z | Engine/ZenCore/Export/Graphic/Buffer/zcExpGfxBuffer.h | ZenEngine3D/ZenEngine | 42bcd06f743eb1381a587c9671de67e24cf72316 | [
"MIT"
] | null | null | null | Engine/ZenCore/Export/Graphic/Buffer/zcExpGfxBuffer.h | ZenEngine3D/ZenEngine | 42bcd06f743eb1381a587c9671de67e24cf72316 | [
"MIT"
] | 1 | 2019-03-09T02:12:31.000Z | 2019-03-09T02:12:31.000Z | #pragma once
namespace zcExp
{
struct ExportInfoGfxBuffer : public ExportInfoBase
{
zArrayDyn<zU8> maData;
zU32 muElementSize;
zU32 muElementCount;
zFlagResTexUse mUseFlags;
};
class ExportGfxBuffer : public zenRes::zExportData
{
zenClassDeclare(ExportGfxBuffer, zenRes::zExportData)
public:
zArrayDyn<zU8> maData;
zU32 muElementSize;
zU32 muElementCount;
zU32 muElementStride;
zFlagResTexUse mUseFlags;
};
zResID CreateGfxBuffer(const zU8* _pData, size_t _uDataSize, size_t _uElemSize, zU32 _uElemCount/*, zFlagResTexUse _UseFlags*/); //! @brief Create a new StructBuffer Resource
}
| 24.230769 | 175 | 0.755556 |
23a253f2524ed778163227b17638db7ae6082c96 | 705 | h | C | src/p2p/net_peerlist_boost_serialization.h | UScrypto/boolberry-opencl | 1369c7a2cb012983a2fac7e78438bd9a7185e867 | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | src/p2p/net_peerlist_boost_serialization.h | UScrypto/boolberry-opencl | 1369c7a2cb012983a2fac7e78438bd9a7185e867 | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | src/p2p/net_peerlist_boost_serialization.h | UScrypto/boolberry-opencl | 1369c7a2cb012983a2fac7e78438bd9a7185e867 | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | // Copyright (c) 2012-2013 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#pragma once
namespace boost
{
namespace serialization
{
//BOOST_CLASS_VERSION(odetool::net_adress, 1)
template <class Archive, class ver_type>
inline void serialize(Archive &a, nodetool::net_address& na, const ver_type ver)
{
a & na.ip;
a & na.port;
}
template <class Archive, class ver_type>
inline void serialize(Archive &a, nodetool::peerlist_entry& pl, const ver_type ver)
{
a & pl.adr;
a & pl.id;
a & pl.last_seen;
}
}
}
| 24.310345 | 88 | 0.66383 |
23a2c8ccbeadc2e33605e37e0993846bacf61583 | 1,297 | h | C | images/core/context/free5gc/lib/nextepc/s1ap/asn1c/S1AP_Masked-IMEISV.h | my5G/OPlaceRAN | cc6fe5223b9b2a32d7963b2304762fe2a0265298 | [
"Apache-2.0"
] | 1 | 2022-02-22T07:19:59.000Z | 2022-02-22T07:19:59.000Z | images/core/context/free5gc/lib/nextepc/s1ap/asn1c/S1AP_Masked-IMEISV.h | my5G/OPlaceRAN | cc6fe5223b9b2a32d7963b2304762fe2a0265298 | [
"Apache-2.0"
] | 1 | 2022-01-15T20:26:01.000Z | 2022-01-15T20:26:01.000Z | images/core/context/free5gc/lib/nextepc/s1ap/asn1c/S1AP_Masked-IMEISV.h | my5G/OPlaceRAN | cc6fe5223b9b2a32d7963b2304762fe2a0265298 | [
"Apache-2.0"
] | 1 | 2022-01-07T18:49:10.000Z | 2022-01-07T18:49:10.000Z | /*
* Generated by asn1c-0.9.29 (http://lionet.info/asn1c)
* From ASN.1 module "S1AP-IEs"
* found in "../support/r14.4.0/36413-e40.asn"
* `asn1c -pdu=all -fcompound-names -findirect-choice -fno-include-deps`
*/
#ifndef _S1AP_Masked_IMEISV_H_
#define _S1AP_Masked_IMEISV_H_
#include <asn_application.h>
/* Including external dependencies */
#include <BIT_STRING.h>
#ifdef __cplusplus
extern "C" {
#endif
/* S1AP_Masked-IMEISV */
typedef BIT_STRING_t S1AP_Masked_IMEISV_t;
/* Implementation */
extern asn_TYPE_descriptor_t asn_DEF_S1AP_Masked_IMEISV;
asn_struct_free_f S1AP_Masked_IMEISV_free;
asn_struct_print_f S1AP_Masked_IMEISV_print;
asn_constr_check_f S1AP_Masked_IMEISV_constraint;
ber_type_decoder_f S1AP_Masked_IMEISV_decode_ber;
der_type_encoder_f S1AP_Masked_IMEISV_encode_der;
xer_type_decoder_f S1AP_Masked_IMEISV_decode_xer;
xer_type_encoder_f S1AP_Masked_IMEISV_encode_xer;
oer_type_decoder_f S1AP_Masked_IMEISV_decode_oer;
oer_type_encoder_f S1AP_Masked_IMEISV_encode_oer;
per_type_decoder_f S1AP_Masked_IMEISV_decode_uper;
per_type_encoder_f S1AP_Masked_IMEISV_encode_uper;
per_type_decoder_f S1AP_Masked_IMEISV_decode_aper;
per_type_encoder_f S1AP_Masked_IMEISV_encode_aper;
#ifdef __cplusplus
}
#endif
#endif /* _S1AP_Masked_IMEISV_H_ */
#include <asn_internal.h>
| 28.195652 | 73 | 0.841943 |
23a4bf801c27da4dffc4faad0245503c98c067fe | 10,777 | h | C | include/genepi/binding_type.h | m59peacemaker/genepi | ab55fc212283d53442b697ba693c832b166ba12d | [
"MIT"
] | 55 | 2019-10-02T08:40:26.000Z | 2021-11-08T11:52:34.000Z | include/genepi/binding_type.h | m59peacemaker/genepi | ab55fc212283d53442b697ba693c832b166ba12d | [
"MIT"
] | 19 | 2019-10-01T14:33:31.000Z | 2021-08-20T16:18:03.000Z | include/genepi/binding_type.h | m59peacemaker/genepi | ab55fc212283d53442b697ba693c832b166ba12d | [
"MIT"
] | 6 | 2019-10-29T04:25:59.000Z | 2021-08-10T18:02:56.000Z | /*
* Copyright (c) 2019 - 2021 Geode-solutions
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#pragma once
#include <algorithm>
#include <memory>
#include <genepi/bind_class.h>
#include <genepi/class_wrapper.h>
#include <genepi/genepi_registry.h>
#include <genepi/types.h>
namespace genepi
{
// Generic C++ object.
template < typename ArgType >
struct BindingType
{
using Type = ArgType;
static bool checkType( Napi::Value arg )
{
return BindingType< Type * >::checkType( arg );
}
static Type fromNapiValue( Napi::Value arg )
{
return *BindingType< Type * >::fromNapiValue( arg );
}
static Napi::Value toNapiValue( Napi::Env env, Type &&arg )
{
return BindingType< std::unique_ptr< Type > >::toNapiValue( env,
// Move construct from stack to heap.
std::unique_ptr< Type >{ new Type{ std::move( arg ) } } );
}
};
// Object pointer.
template < typename ArgType >
struct BindingType< ArgType * >
{
using Type = ArgType *;
using BaseType = typename std::remove_const< ArgType >::type;
static bool checkType( Napi::Value arg )
{
return arg.IsObject();
}
static Type fromNapiValue( Napi::Value arg )
{
return ClassWrapperBase< BaseType >::get_bound( arg );
}
template < typename T = ArgType >
static typename std::enable_if< std::is_move_constructible< T >::value,
Napi::Value >::type
toNapiValue( Napi::Env env, Type arg )
{
if( std::find_if( class_list().begin(), class_list().end(),
[]( BindClassBase *bind_class ) {
return bind_class->type()
== BindClass< ArgType >::instance().type();
} )
!= class_list().end() )
{
return ClassWrapperBase< BaseType >::instance().create(
env, { Napi::Boolean::New( env, false ),
Napi::External< BaseType >::New(
env, const_cast< BaseType * >( arg ) ) } );
}
else
{
return BindingType< BaseType >::toNapiValue(
env, std::move( *const_cast< BaseType * >( arg ) ) );
}
}
template < typename T = ArgType >
static typename std::enable_if< !std::is_move_constructible< T >::value,
Napi::Value >::type
toNapiValue( Napi::Env env, Type arg )
{
return ClassWrapperBase< BaseType >::instance().create(
env, { Napi::Boolean::New( env, false ),
Napi::External< BaseType >::New(
env, const_cast< BaseType * >( arg ) ) } );
}
};
// Object reference.
template < typename ArgType >
struct BindingType< ArgType & >
{
using Type = ArgType &;
static bool checkType( Napi::Value arg )
{
return arg.IsObject();
}
static Type fromNapiValue( Napi::Value arg )
{
return *BindingType< ArgType * >::fromNapiValue( arg );
}
static Napi::Value toNapiValue( Napi::Env env, Type arg )
{
return BindingType< ArgType * >::toNapiValue( env, &arg );
}
};
template < typename ArgType >
struct BindingType< std::unique_ptr< ArgType > >
{
using Type = std::unique_ptr< ArgType >;
using BaseType = typename std::remove_const< ArgType >::type;
// checkType and fromNapiValue not supported! C++ objects are wrapped in
// shared_ptr which would become invalid if passed back as unique_ptr.
static Napi::Value toNapiValue( Napi::Env env, Type &&arg )
{
return BindingType< ArgType * >::toNapiValue( env, arg.release() );
}
};
template < typename ArgType >
struct BindingType< std::shared_ptr< ArgType > >
{
using Type = std::shared_ptr< ArgType >;
using BaseType = typename std::remove_const< ArgType >::type;
static bool checkType( Napi::Value arg )
{
return arg.IsObject();
}
static Type fromNapiValue( Napi::Value arg )
{
return ClassWrapperBase< ArgType >::get_smartpointer( arg );
}
static Napi::Value toNapiValue( Napi::Env env, Type &&arg )
{
return ClassWrapperBase< BaseType >::instance().create(
env, { Napi::Boolean::New( env, true ),
Napi::External< std::shared_ptr< ArgType > >::New(
env, new std::shared_ptr< ArgType >{
std::move( arg ) } ) } );
}
};
// Numeric and boolean types.
// The static cast silences a compiler warning in Visual Studio.
#define DEFINE_NATIVE_BINDING_TYPE( ArgType, checker, cast, decode, jsClass ) \
template <> \
struct BindingType< ArgType > \
{ \
using Type = ArgType; \
\
static bool checkType( Napi::Value arg ) \
{ \
return arg.checker(); \
} \
\
static Type fromNapiValue( Napi::Value arg ) \
{ \
return static_cast< Type >( arg.cast().decode() ); \
} \
\
static Napi::Value toNapiValue( Napi::Env env, Type arg ) \
{ \
return jsClass::New( env, arg ); \
} \
}
DEFINE_NATIVE_BINDING_TYPE(
bool, IsBoolean, ToBoolean, Value, Napi::Boolean );
DEFINE_NATIVE_BINDING_TYPE(
double, IsNumber, ToNumber, DoubleValue, Napi::Number );
DEFINE_NATIVE_BINDING_TYPE(
float, IsNumber, ToNumber, FloatValue, Napi::Number );
DEFINE_NATIVE_BINDING_TYPE(
unsigned int, IsNumber, ToNumber, Uint32Value, Napi::Number );
DEFINE_NATIVE_BINDING_TYPE(
unsigned short, IsNumber, ToNumber, Uint32Value, Napi::Number );
DEFINE_NATIVE_BINDING_TYPE(
unsigned char, IsNumber, ToNumber, Uint32Value, Napi::Number );
DEFINE_NATIVE_BINDING_TYPE(
signed int, IsNumber, ToNumber, Int32Value, Napi::Number );
DEFINE_NATIVE_BINDING_TYPE(
signed short, IsNumber, ToNumber, Int32Value, Napi::Number );
DEFINE_NATIVE_BINDING_TYPE(
signed char, IsNumber, ToNumber, Int32Value, Napi::Number );
DEFINE_NATIVE_BINDING_TYPE(
char, IsNumber, ToNumber, Int32Value, Napi::Number );
#define DEFINE_STRING_BINDING_TYPE( ArgType ) \
template <> \
struct BindingType< ArgType > \
{ \
using Type = ArgType; \
\
static bool checkType( Napi::Value arg ) \
{ \
return arg.IsString(); \
} \
\
static Napi::Value toNapiValue( Napi::Env env, Type arg ) \
{ \
const char *buf = ( arg == nullptr ) \
? "" \
: reinterpret_cast< const char * >( arg ); \
return Napi::String::New( env, buf, strlen( buf ) ); \
} \
}
DEFINE_STRING_BINDING_TYPE( unsigned char * );
DEFINE_STRING_BINDING_TYPE( char * );
DEFINE_STRING_BINDING_TYPE( const unsigned char * );
DEFINE_STRING_BINDING_TYPE( const char * );
// void return values are passed to toNapiValue as null pointers.
template <>
struct BindingType< void >
{
using Type = std::nullptr_t;
static Type fromNapiValue( Napi::Value arg )
{
return nullptr;
}
static Napi::Value toNapiValue( Napi::Env env, Type arg )
{
return env.Undefined();
}
};
} // namespace genepi
| 40.212687 | 80 | 0.470261 |
23a4f0d1289597c1bc702d8f36810af1ba309a7a | 215 | c | C | fun2.c | bhavesh01shukla/Modified-XV-6 | 07949fd2275684cc57d29865e002099dd24f2dcc | [
"MIT-0"
] | null | null | null | fun2.c | bhavesh01shukla/Modified-XV-6 | 07949fd2275684cc57d29865e002099dd24f2dcc | [
"MIT-0"
] | null | null | null | fun2.c | bhavesh01shukla/Modified-XV-6 | 07949fd2275684cc57d29865e002099dd24f2dcc | [
"MIT-0"
] | null | null | null |
#include "types.h"
#include "stat.h"
#include "user.h"
#include "fs.h"
int main (int argc,char *argv[])
{
for(long long int i=1;i<100;i++)
{
float x=0;
x=x+3.14*89.64;
printf(1,"2\n");
}
exit();
} | 13.4375 | 34 | 0.553488 |
23a5f5b0b35c38cb87c2345e4dfcf3335a16a8f3 | 4,948 | h | C | src/include/clocksource/clocksource.h | GNUtoo/xboot | 666251f1f6797e58bdff53b918cf207b56128266 | [
"MIT"
] | null | null | null | src/include/clocksource/clocksource.h | GNUtoo/xboot | 666251f1f6797e58bdff53b918cf207b56128266 | [
"MIT"
] | null | null | null | src/include/clocksource/clocksource.h | GNUtoo/xboot | 666251f1f6797e58bdff53b918cf207b56128266 | [
"MIT"
] | null | null | null | #ifndef __CLOCKSOURCE_H__
#define __CLOCKSOURCE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <types.h>
#include <stddef.h>
#include <time/timer.h>
#include <xboot/seqlock.h>
#include <xboot/ktime.h>
#include <xboot/dtree.h>
#include <xboot/device.h>
#include <xboot/driver.h>
#include <xboot/initcall.h>
/*
* Simplify initialization of mask field
*/
#define CLOCKSOURCE_MASK(bits) (u64_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1)
struct clocksource_t
{
struct {
u64_t interval;
u64_t last;
u64_t nsec;
seqlock_t lock;
struct timer_t timer;
} keeper;
char * name;
u64_t mask;
u32_t mult;
u32_t shift;
u64_t (*read)(struct clocksource_t * cs);
void * priv;
};
/*
* clocksource_hz2mult - calculates mult from hz and shift
* @hz: Clocksource frequency in Hz
* @shift_constant: Clocksource shift factor
*
* Helper functions that converts a hz counter
* frequency to a timsource multiplier, given the
* clocksource shift value
*/
static inline u32_t clocksource_hz2mult(u32_t hz, u32_t shift)
{
/*
* hz = cyc/(Billion ns)
* mult/2^shift = ns/cyc
* mult = ns/cyc * 2^shift
* mult = 1Billion/hz * 2^shift
* mult = 1000000000 * 2^shift / hz
* mult = (1000000000<<shift) / hz
*/
u64_t tmp = ((u64_t)1000000000ULL) << shift;
tmp += hz/2;
tmp = tmp / hz;
return (u32_t)tmp;
}
/*
* clocksource_khz2mult - calculates mult from khz and shift
* @khz: Clocksource frequency in KHz
* @shift_constant: Clocksource shift factor
*
* Helper functions that converts a khz counter frequency to a timsource
* multiplier, given the clocksource shift value
*/
static inline u32_t clocksource_khz2mult(u32_t khz, u32_t shift)
{
/*
* khz = cyc/(Million ns)
* mult/2^shift = ns/cyc
* mult = ns/cyc * 2^shift
* mult = 1Million/khz * 2^shift
* mult = 1000000 * 2^shift / khz
* mult = (1000000<<shift) / khz
*/
u64_t tmp = ((u64_t)1000000ULL) << shift;
tmp += khz / 2;
tmp = tmp / khz;
return (u32_t)tmp;
}
/*
* clocksource_calc_mult_shift - calculate mult/shift factors for scaled math of clocksource
* @mult: pointer to mult variable
* @shift: pointer to shift variable
* @from: frequency to convert from
* @to: frequency to convert to
* @maxsec: guaranteed runtime conversion range in seconds
*
* The function evaluates the shift/mult pair for the scaled math
* operations of clocksources and clockevents.
*
* @to and @from are frequency values in HZ. For clock sources @to is
* NSEC_PER_SEC == 1GHz and @from is the counter frequency. For clock
* event @to is the counter frequency and @from is NSEC_PER_SEC.
*
* The @maxsec conversion range argument controls the time frame in
* seconds which must be covered by the runtime conversion with the
* calculated mult and shift factors. This guarantees that no 64bit
* overflow happens when the input value of the conversion is
* multiplied with the calculated mult factor. Larger ranges may
* reduce the conversion accuracy by chosing smaller mult and shift
* factors.
*/
static inline void clocksource_calc_mult_shift(u32_t * mult, u32_t * shift, u32_t from, u32_t to, u32_t maxsec)
{
u64_t tmp;
u32_t sft, sftacc= 32;
/*
* Calculate the shift factor which is limiting the conversion range
*/
tmp = ((u64_t)maxsec * from) >> 32;
while(tmp)
{
tmp >>=1;
sftacc--;
}
/*
* Find the conversion shift/mult pair which has the best
* accuracy and fits the maxsec conversion range:
*/
for(sft = 32; sft > 0; sft--)
{
tmp = (u64_t) to << sft;
tmp += from / 2;
tmp = tmp / from;
if((tmp >> sftacc) == 0)
break;
}
*mult = tmp;
*shift = sft;
}
static inline u64_t clocksource_deferment(struct clocksource_t * cs)
{
return ((u64_t)cs->mask * cs->mult) >> cs->shift;
}
static inline u64_t clocksource_cycle(struct clocksource_t * cs)
{
return cs->read(cs) & cs->mask;
}
static inline u64_t clocksource_delta(struct clocksource_t * cs, u64_t last, u64_t now)
{
if(last < now)
return (now - last) & cs->mask;
return (cs->mask + 1 - last + now) & cs->mask;
}
static inline u64_t clocksource_delta2ns(struct clocksource_t * cs, u64_t delta)
{
return (delta * cs->mult) >> cs->shift;
}
static inline ktime_t clocksource_keeper_read(struct clocksource_t * cs)
{
u64_t now, delta, offset;
unsigned int seq;
do {
seq = read_seqbegin(&cs->keeper.lock);
now = clocksource_cycle(cs);
delta = clocksource_delta(cs, cs->keeper.last, now);
offset = clocksource_delta2ns(cs, delta);
} while(read_seqretry(&cs->keeper.lock, seq));
return ns_to_ktime(cs->keeper.nsec + offset);
}
struct clocksource_t * search_clocksource(const char * name);
struct clocksource_t * search_first_clocksource(void);
bool_t register_clocksource(struct device_t ** device, struct clocksource_t * cs);
bool_t unregister_clocksource(struct clocksource_t * cs);
ktime_t clocksource_ktime_get(struct clocksource_t * cs);
ktime_t ktime_get(void);
#ifdef __cplusplus
}
#endif
#endif /* __CLOCKSOURCE_H__ */
| 25.505155 | 111 | 0.705133 |
23a7e279034de3b21f4886a0950cf9611a8545a6 | 50 | h | C | lzo/lzo1.h | GeekerClub/thirdparty | aa3057801b89accee71e0dd697fbec2c216c6b32 | [
"MIT"
] | null | null | null | lzo/lzo1.h | GeekerClub/thirdparty | aa3057801b89accee71e0dd697fbec2c216c6b32 | [
"MIT"
] | null | null | null | lzo/lzo1.h | GeekerClub/thirdparty | aa3057801b89accee71e0dd697fbec2c216c6b32 | [
"MIT"
] | null | null | null | #include "thirdparty/lzo-2.07/include/lzo/lzo1.h"
| 25 | 49 | 0.76 |
23aa5b5521d0c4ca8061c9ffa340b1e3c4f0f84f | 4,180 | h | C | dependencies/panda/Panda3D-1.10.0-x64/include/pandaFileStream.h | CrankySupertoon01/Toontown-2 | 60893d104528a8e7eb4aced5d0015f22e203466d | [
"MIT"
] | 3 | 2018-03-09T12:07:29.000Z | 2021-02-25T06:50:25.000Z | dtool/src/dtoolutil/pandaFileStream.h | Sinkay/panda3d | 16bfd3750f726a8831771b81649d18d087917fd5 | [
"PHP-3.01",
"PHP-3.0"
] | 1 | 2018-07-28T20:07:04.000Z | 2018-07-30T18:28:34.000Z | dtool/src/dtoolutil/pandaFileStream.h | Sinkay/panda3d | 16bfd3750f726a8831771b81649d18d087917fd5 | [
"PHP-3.01",
"PHP-3.0"
] | 2 | 2019-12-02T01:39:10.000Z | 2021-02-13T22:41:00.000Z | // Filename: pandaFileStream.h
// Created by: drose (08Sep08)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef PANDAFILESTREAM_H
#define PANDAFILESTREAM_H
#include "dtoolbase.h"
#ifdef USE_PANDAFILESTREAM
#include "pandaFileStreamBuf.h"
////////////////////////////////////////////////////////////////////
// Class : IFileStream
// Description : Implements a C++ stream object suitable for reading
// from files on disk. This is similar to ifstream, but
// it provides low-level support for Panda's
// simple-threading implementation (using this interface
// will block only the current thread, rather than the
// entire process, on I/O waits).
////////////////////////////////////////////////////////////////////
class EXPCL_DTOOL IFileStream : public istream {
PUBLISHED:
INLINE IFileStream();
INLINE IFileStream(const char *filename, ios::openmode mode = ios::in);
INLINE ~IFileStream();
INLINE void open(const char *filename, ios::openmode mode = ios::in);
public:
#ifdef _WIN32
INLINE void attach(const char *filename, HANDLE handle, ios::openmode mode = ios::in);
#else
INLINE void attach(const char *filename, int fd, ios::openmode mode = ios::in);
#endif
PUBLISHED:
INLINE void close();
private:
PandaFileStreamBuf _buf;
};
////////////////////////////////////////////////////////////////////
// Class : OFileStream
// Description : Implements a C++ stream object suitable for writing
// to files on disk. This is similar to ofstream, but
// it provides low-level support for Panda's
// simple-threading implementation (using this interface
// will block only the current thread, rather than the
// entire process, on I/O waits).
////////////////////////////////////////////////////////////////////
class EXPCL_DTOOL OFileStream : public ostream {
PUBLISHED:
INLINE OFileStream();
INLINE OFileStream(const char *filename, ios::openmode mode = ios::out);
INLINE ~OFileStream();
INLINE void open(const char *filename, ios::openmode mode = ios::out);
public:
#ifdef _WIN32
INLINE void attach(const char *filename, HANDLE handle, ios::openmode mode = ios::out);
#else
INLINE void attach(const char *filename, int fd, ios::openmode mode = ios::out);
#endif
PUBLISHED:
INLINE void close();
private:
PandaFileStreamBuf _buf;
};
////////////////////////////////////////////////////////////////////
// Class : FileStream
// Description : Implements a C++ stream object suitable for reading
// from and/or writing to files on disk. This is
// similar to fstream, but it provides low-level support
// for Panda's simple-threading implementation (using
// this interface will block only the current thread,
// rather than the entire process, on I/O waits).
////////////////////////////////////////////////////////////////////
class EXPCL_DTOOL FileStream : public iostream {
PUBLISHED:
INLINE FileStream();
INLINE FileStream(const char *filename, ios::openmode mode = ios::in);
INLINE ~FileStream();
INLINE void open(const char *filename, ios::openmode mode = ios::in);
public:
#ifdef _WIN32
INLINE void attach(const char *filename, HANDLE handle, ios::openmode mode);
#else
INLINE void attach(const char *filename, int fd, ios::openmode mode);
#endif
PUBLISHED:
INLINE void close();
private:
PandaFileStreamBuf _buf;
};
#include "pandaFileStream.I"
typedef IFileStream pifstream;
typedef OFileStream pofstream;
typedef FileStream pfstream;
#else // USE_PANDAFILESTREAM
typedef ifstream pifstream;
typedef ofstream pofstream;
typedef fstream pfstream;
#endif // USE_PANDAFILESTREAM
#endif
| 31.666667 | 89 | 0.604306 |
23ad9f20b0846e057c7754d10327062886146430 | 410 | h | C | raytracer/main/cube.h | tobiasmarciszko/qt_raytracer_challenge | 188bf38211e30cb0655577a101c82f6ee8ae2ab8 | [
"MIT"
] | 24 | 2019-06-29T07:44:24.000Z | 2021-05-27T11:11:49.000Z | raytracer/main/cube.h | tobiasmarciszko/qt_raytracer_challenge | 188bf38211e30cb0655577a101c82f6ee8ae2ab8 | [
"MIT"
] | 1 | 2020-12-02T22:54:02.000Z | 2021-01-29T08:47:32.000Z | raytracer/main/cube.h | tobiasmarciszko/qt_raytracer_challenge | 188bf38211e30cb0655577a101c82f6ee8ae2ab8 | [
"MIT"
] | 7 | 2020-01-29T15:01:19.000Z | 2021-05-28T02:34:34.000Z | #ifndef CUBE_H
#define CUBE_H
#include "shape.h"
#include <vector>
class Vector;
struct Cube : public Shape
{
[[nodiscard]] Vector local_normal_at(const Point& local_point) const override;
[[nodiscard]] std::vector<Intersection> local_intersect(const Ray& ray) const override;
private:
[[nodiscard]] std::tuple<float,float> check_axis(float origin, float direction) const;
};
#endif // CUBE_H
| 21.578947 | 91 | 0.731707 |
23ae9e2c6f900df8042a326c17de37a0baa393b8 | 5,846 | h | C | Viewer/CommonEntities/global.h | andr1312e/Russia-Tiles-Server | c1d596b84e22c170ba0f795ed6e2bfb80167eeb6 | [
"Unlicense"
] | null | null | null | Viewer/CommonEntities/global.h | andr1312e/Russia-Tiles-Server | c1d596b84e22c170ba0f795ed6e2bfb80167eeb6 | [
"Unlicense"
] | null | null | null | Viewer/CommonEntities/global.h | andr1312e/Russia-Tiles-Server | c1d596b84e22c170ba0f795ed6e2bfb80167eeb6 | [
"Unlicense"
] | 1 | 2022-01-11T16:07:23.000Z | 2022-01-11T16:07:23.000Z | #ifndef GLOBAL_H
#define GLOBAL_H
#include <QDebug>
#include <QColor>
static constexpr quint8 maxNumberOfSectors = 10;
static constexpr quint8 currentScreenIndex = 0;
struct OpenGLRectF {
public:
Q_DECL_CONSTEXPR OpenGLRectF() noexcept : xp(0.), yp(0.), w(0.), h(0.) {}
Q_DECL_CONSTEXPR OpenGLRectF(qreal left, qreal bottom, qreal width, qreal height) noexcept :
xp(left), yp(bottom), w(width), h(height) {}
Q_DECL_CONSTEXPR inline bool isNull() const noexcept {
return w == 0. && h == 0.;
}
Q_DECL_CONSTEXPR inline qreal left() const noexcept { return xp; }
Q_DECL_CONSTEXPR inline qreal top() const noexcept { return yp + h; }
Q_DECL_CONSTEXPR inline qreal right() const noexcept { return xp + w; }
Q_DECL_CONSTEXPR inline qreal bottom() const noexcept { return yp; }
Q_DECL_RELAXED_CONSTEXPR inline void setWidth(qreal aw) noexcept { w = aw; }
Q_DECL_RELAXED_CONSTEXPR inline void setHeight(qreal ah) noexcept { h = ah; }
Q_DECL_RELAXED_CONSTEXPR inline void setX(qreal pos) noexcept { xp = pos; }
Q_DECL_RELAXED_CONSTEXPR inline void setY(qreal pos) noexcept { yp = pos; }
Q_DECL_CONSTEXPR inline qreal x() const noexcept { return xp; }
Q_DECL_CONSTEXPR inline qreal y() const noexcept { return yp; }
Q_DECL_CONSTEXPR inline qreal width() const noexcept { return w; }
Q_DECL_CONSTEXPR inline qreal height() const noexcept { return h; }
Q_DECL_RELAXED_CONSTEXPR inline void moveLeft(qreal pos) noexcept { xp -= pos; }
Q_DECL_RELAXED_CONSTEXPR inline void moveTop(qreal pos) noexcept { yp += pos; }
Q_DECL_RELAXED_CONSTEXPR inline void moveRight(qreal pos) noexcept { xp += pos; }
Q_DECL_RELAXED_CONSTEXPR inline void moveBottom(qreal pos) noexcept { yp -= pos; }
/*Q_DECL_RELAXED_CONSTEXPR inline void moveTopLeft(const QPointF &p) noexcept { moveLeft(p.x()); moveTop(p.y()); }
Q_DECL_RELAXED_CONSTEXPR inline void moveBottomRight(const QPointF &p) noexcept { moveRight(p.x()); moveBottom(p.y()); }
Q_DECL_RELAXED_CONSTEXPR inline void moveTopRight(const QPointF &p) noexcept { moveRight(p.x()); moveTop(p.y()); }
Q_DECL_RELAXED_CONSTEXPR inline void moveBottomLeft(const QPointF &p) noexcept { moveLeft(p.x()); moveBottom(p.y()); }*/
private:
qreal xp;
qreal yp;
qreal w;
qreal h;
};
enum WidgetTypes {
//VisualControl,
FunctionalControl,
Targeting,
KTAInfo,
Customizing,
Replay,
Plotter,
PlotterColorScheme,
DSPControl,
IT,
Track,
SignalNoiseRatio,
MapDebug,
StateMachine,
BioDefense,
Training
};
enum ItemState {
Active,
Excluded,
Empty
};
struct RayInfo {
RayInfo() : az(0), ugm(0)/*, id(0), mode(0)*/ {}
RayInfo(float _az, float _ugm/*, int _id, quint8 _mode*/) :
az(_az), ugm(_ugm)/*, id(_id), mode(_mode)*/ {}
float az;
float ugm;
/*int id;
quint8 mode;*/
};
using RaySet = QMap< int, QVector<RayInfo> >;
struct SceneCustomDataInit {
SceneCustomDataInit() {}
QColor backgroundColor;
QColor grideColor;
QColor grideTextColor;
float grideTextSize;
bool grideDistMark;
bool grideAzMark;
QColor ktaPOIColor;
float ktaPOISize;
QColor ktaVOIColor;
float ktaVOISize;
QColor sectorsColor;
QColor rayColor;
float rayDistMax;
QColor traceColor;
QColor traceLBColor;
QColor traceLBTextColor;
float traceLBTextSize;
};
enum TextSizeAction {
Increas,
Decreas,
Reset
};
enum ThemeEnum {
Light,
Dark,
Custom
};
struct Vertex {
Vertex() : x(0), y(0) {}
Vertex(float tx, float ty) : x(tx), y(ty) {}
friend bool operator<(const Vertex &l, const Vertex &r)
{
if (l.x < r.x)
return true;
else if (qFuzzyCompare(l.x, r.x)) {
if (l.y < r.y)
return true;
else
return false;
}
else
return false;
}
friend bool operator==(const Vertex &l, const Vertex &r)
{
if (qFuzzyCompare(l.x, r.x) && qFuzzyCompare(l.y, r.y))
return true;
else
return false;
}
friend bool operator!=(const Vertex &l, const Vertex &r)
{
if (!qFuzzyCompare(l.x, r.x) || !qFuzzyCompare(l.y, r.y))
return true;
else
return false;
}
float x;
float y;
};
/*float deg360TransitionCheck(float ang) {
if (ang > 360) {
ang -= 360;
}
else if (ang < 0) {
ang += 360;
}
return ang;
}*/
enum DSPType {
None,
DSP2,
DSP20
};
namespace TableAttributes {
const QString offStr("Откл"), onStr("Вкл"),
normalPriorityStr("Нормальная"),
hightPriorityStr("Высокая"),
dsp2Str("2 мс"), dsp20Str("20 мс"),
reflSignal("По Отраженному сигн."),
respSignal("По Ответному сигн."),
dsp("ДСП"),
reflDSP("Отр + ДСП"),respDSP("Отв + ДСП"),
reflRespSignal("По Отр. и Отв. сигн."),
threeSets("3 основ."),
fourSets("4 основ."),
threeSetsPlusExtra("3 основ. + 1 доп."),
autoSets("Авторежим"),
setOfLFM("Для ЛЧМ"), setOfRI("Для РИ"),
respSignalLFM("По Ответному(ЛЧМ)"),
respSignalRI("По Ответному(РИ)");
enum ColumnName {
TrackID = 0,
Priority = 1,
WorkMode = 2,
Letter = 3,
DSP = 4,
CT = 5,
Plotting = 6,
Trace = 7
};
}
namespace ProgramWorkMode {
enum Mode {
RegularWork,
Training,
ReplayRegistration
};
}
const QString dspDataPath("./DSP/Data/");
#endif // GLOBAL_H
| 26.816514 | 124 | 0.59716 |
23b0b5158ba6e09e8494835be101a4a4ecb0370d | 20,109 | h | C | oshmem/include/pshmem.h | raspbian-packages/openmpi | 38e7e633028faf35b2dd948a789fea95e543e567 | [
"BSD-3-Clause-Open-MPI"
] | null | null | null | oshmem/include/pshmem.h | raspbian-packages/openmpi | 38e7e633028faf35b2dd948a789fea95e543e567 | [
"BSD-3-Clause-Open-MPI"
] | null | null | null | oshmem/include/pshmem.h | raspbian-packages/openmpi | 38e7e633028faf35b2dd948a789fea95e543e567 | [
"BSD-3-Clause-Open-MPI"
] | null | null | null | /*
* Copyright (c) 2014-2016 Mellanox Technologies, Inc.
* All rights reserved.
* Copyright (c) 2014 Intel, Inc. All rights reserved
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef PSHMEM_SHMEM_H
#define PSHMEM_SHMEM_H
#include <stddef.h> /* include for ptrdiff_t */
#include <stdint.h> /* include for fixed width types */
#if defined(c_plusplus) || defined(__cplusplus)
# include <complex>
# define OSHMEM_COMPLEX_TYPE(type) std::complex<type>
#else
# include <complex.h>
# define OSHMEM_COMPLEX_TYPE(type) type complex
#endif
#ifndef OSHMEM_DECLSPEC
# if defined(OPAL_C_HAVE_VISIBILITY) && (OPAL_C_HAVE_VISIBILITY == 1)
# define OSHMEM_DECLSPEC __attribute__((visibility("default")))
# else
# define OSHMEM_DECLSPEC
# endif
#endif
#include <pshmemx.h>
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
/*
* Profiling API
*/
/*
* Initialization routines
*/
OSHMEM_DECLSPEC void pshmem_init(void);
OSHMEM_DECLSPEC void pshmem_global_exit(int status);
/*
* Finalization routines
*/
OSHMEM_DECLSPEC void pshmem_finalize(void);
/*
* Query routines
*/
OSHMEM_DECLSPEC int pshmem_n_pes(void);
OSHMEM_DECLSPEC int pshmem_my_pe(void);
/*
* Accessability routines
*/
OSHMEM_DECLSPEC int pshmem_pe_accessible(int pe);
OSHMEM_DECLSPEC int pshmem_addr_accessible(const void *addr, int pe);
/*
* Symmetric heap routines
*/
OSHMEM_DECLSPEC void* pshmem_malloc(size_t size);
OSHMEM_DECLSPEC void* pshmem_align(size_t align, size_t size);
OSHMEM_DECLSPEC void* pshmem_realloc(void *ptr, size_t size);
OSHMEM_DECLSPEC void pshmem_free(void* ptr);
/*
* Remote pointer operations
*/
OSHMEM_DECLSPEC void *pshmem_ptr(const void *ptr, int pe);
/*
* Elemental put routines
*/
OSHMEM_DECLSPEC void pshmem_char_p(char* addr, char value, int pe);
OSHMEM_DECLSPEC void pshmem_short_p(short* addr, short value, int pe);
OSHMEM_DECLSPEC void pshmem_int_p(int* addr, int value, int pe);
OSHMEM_DECLSPEC void pshmem_long_p(long* addr, long value, int pe);
OSHMEM_DECLSPEC void pshmem_float_p(float* addr, float value, int pe);
OSHMEM_DECLSPEC void pshmem_double_p(double* addr, double value, int pe);
OSHMEM_DECLSPEC void pshmem_longlong_p(long long* addr, long long value, int pe);
OSHMEM_DECLSPEC void pshmem_longdouble_p(long double* addr, long double value, int pe);
/*
* Block data put routines
*/
OSHMEM_DECLSPEC void pshmem_short_put(short *target, const short *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_int_put(int* target, const int* source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_long_put(long *target, const long *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_float_put(float *target, const float *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_double_put(double *target, const double *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_longlong_put(long long *target, const long long *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_longdouble_put(long double *target, const long double *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_put32(void *target, const void *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_put64(void *target, const void *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_put128(void *target, const void *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_putmem(void *target, const void *source, size_t len, int pe);
/*
* Strided put routines
*/
OSHMEM_DECLSPEC void pshmem_short_iput(short* target, const short* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_int_iput(int* target, const int* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_float_iput(float* target, const float* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_double_iput(double* target, const double* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_longlong_iput(long long* target, const long long* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_longdouble_iput(long double* target, const long double* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_long_iput(long* target, const long* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_iput32(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_iput64(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_iput128(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
/*
* Elemental get routines
*/
OSHMEM_DECLSPEC char pshmem_char_g(const char* addr, int pe);
OSHMEM_DECLSPEC short pshmem_short_g(const short* addr, int pe);
OSHMEM_DECLSPEC int pshmem_int_g(const int* addr, int pe);
OSHMEM_DECLSPEC long pshmem_long_g(const long* addr, int pe);
OSHMEM_DECLSPEC float pshmem_float_g(const float* addr, int pe);
OSHMEM_DECLSPEC double pshmem_double_g(const double* addr, int pe);
OSHMEM_DECLSPEC long long pshmem_longlong_g(const long long* addr, int pe);
OSHMEM_DECLSPEC long double pshmem_longdouble_g(const long double* addr, int pe);
/*
* Block data get routines
*/
OSHMEM_DECLSPEC void pshmem_short_get(short *target, const short *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_int_get(int *target, const int *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_long_get(long *target, const long *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_float_get(float *target, const float *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_double_get(double *target, const double *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_longlong_get(long long *target, const long long *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_longdouble_get(long double *target, const long double *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_get32(void *target, const void *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_get64(void *target, const void *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_get128(void *target, const void *source, size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_getmem(void *target, const void *source, size_t len, int pe);
/*
* Strided get routines
*/
OSHMEM_DECLSPEC void pshmem_int_iget(int* target, const int* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_short_iget(short* target, const short* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_float_iget(float* target, const float* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_double_iget(double* target, const double* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_longlong_iget(long long* target, const long long* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_longdouble_iget(long double* target, const long double* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_long_iget(long* target, const long* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_iget32(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_iget64(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
OSHMEM_DECLSPEC void pshmem_iget128(void* target, const void* source, ptrdiff_t tst, ptrdiff_t sst,size_t len, int pe);
/*
* Atomic operations
*/
/* Atomic swap */
OSHMEM_DECLSPEC long pshmem_swap(long *target, long value, int pe);
OSHMEM_DECLSPEC double pshmem_double_swap(double *target, double value, int pe);
OSHMEM_DECLSPEC float pshmem_float_swap(float *target, float value, int pe);
OSHMEM_DECLSPEC int pshmem_int_swap(int *target, int value, int pe);
OSHMEM_DECLSPEC long pshmem_long_swap(long *target, long value, int pe);
OSHMEM_DECLSPEC long long pshmem_longlong_swap(long long*target, long long value, int pe);
/* Atomic conditional swap */
OSHMEM_DECLSPEC int pshmem_int_cswap(int *target, int cond, int value, int pe);
OSHMEM_DECLSPEC long pshmem_long_cswap(long *target, long cond, long value, int pe);
OSHMEM_DECLSPEC long long pshmem_longlong_cswap(long long *target, long long cond, long long value, int pe);
/* Atomic Fetch&Add */
OSHMEM_DECLSPEC int pshmem_int_fadd(int *target, int value, int pe);
OSHMEM_DECLSPEC long pshmem_long_fadd(long *target, long value, int pe);
OSHMEM_DECLSPEC long long pshmem_longlong_fadd(long long *target, long long value, int pe);
/* Atomic Fetch&Inc */
OSHMEM_DECLSPEC int pshmem_int_finc(int *target, int pe);
OSHMEM_DECLSPEC long pshmem_long_finc(long *target, int pe);
OSHMEM_DECLSPEC long long pshmem_longlong_finc(long long *target, int pe);
/* Atomic Add*/
OSHMEM_DECLSPEC void pshmem_int_add(int *target, int value, int pe);
OSHMEM_DECLSPEC void pshmem_long_add(long *target, long value, int pe);
OSHMEM_DECLSPEC void pshmem_longlong_add(long long *target, long long value, int pe);
/* Atomic Inc */
OSHMEM_DECLSPEC void pshmem_int_inc(int *target, int pe);
OSHMEM_DECLSPEC void pshmem_long_inc(long *target, int pe);
OSHMEM_DECLSPEC void pshmem_longlong_inc(long long *target, int pe);
/*
* Lock functions
*/
OSHMEM_DECLSPEC void pshmem_set_lock(volatile long *lock);
OSHMEM_DECLSPEC void pshmem_clear_lock(volatile long *lock);
OSHMEM_DECLSPEC int pshmem_test_lock(volatile long *lock);
/*
* P2P sync routines
*/
OSHMEM_DECLSPEC void pshmem_short_wait(volatile short *addr, short value);
OSHMEM_DECLSPEC void pshmem_int_wait(volatile int *addr, int value);
OSHMEM_DECLSPEC void pshmem_long_wait(volatile long *addr, long value);
OSHMEM_DECLSPEC void pshmem_longlong_wait(volatile long long *addr, long long value);
OSHMEM_DECLSPEC void pshmem_wait(volatile long *addr, long value);
OSHMEM_DECLSPEC void pshmem_short_wait_until(volatile short *addr, int cmp, short value);
OSHMEM_DECLSPEC void pshmem_int_wait_until(volatile int *addr, int cmp, int value);
OSHMEM_DECLSPEC void pshmem_long_wait_until(volatile long *addr, int cmp, long value);
OSHMEM_DECLSPEC void pshmem_longlong_wait_until(volatile long long *addr, int cmp, long long value);
OSHMEM_DECLSPEC void pshmem_wait_until(volatile long *addr, int cmp, long value);
/*
* Barrier sync routines
*/
OSHMEM_DECLSPEC void pshmem_barrier(int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void pshmem_barrier_all(void);
OSHMEM_DECLSPEC void pshmem_fence(void);
OSHMEM_DECLSPEC void pshmem_quiet(void);
/*
* Collective routines
*/
OSHMEM_DECLSPEC void pshmem_broadcast32(void *target, const void *source, size_t nlong, int PE_root, int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void pshmem_broadcast64(void *target, const void *source, size_t nlong, int PE_root, int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void pshmem_broadcast(void *target, const void *source, size_t nlong, int PE_root, int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void pshmem_collect32(void *target, const void *source, size_t nlong, int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void pshmem_collect64(void *target, const void *source, size_t nlong, int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void pshmem_fcollect32(void *target, const void *source, size_t nlong, int PE_start, int logPE_stride, int PE_size, long *pSync);
OSHMEM_DECLSPEC void pshmem_fcollect64(void *target, const void *source, size_t nlong, int PE_start, int logPE_stride, int PE_size, long *pSync);
/*
* Reduction routines
*/
OSHMEM_DECLSPEC void pshmem_short_and_to_all(short *target, const short *source, int nreduce, int PE_start, int logPE_stride, int PE_size, short *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_int_and_to_all(int *target, const int *source, int nreduce, int PE_start, int logPE_stride, int PE_size, int *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_long_and_to_all(long *target, const long *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_longlong_and_to_all(long long *target, const long long *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long long *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_short_or_to_all(short *target, const short *source, int nreduce, int PE_start, int logPE_stride, int PE_size, short *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_int_or_to_all(int *target, const int *source, int nreduce, int PE_start, int logPE_stride, int PE_size, int *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_long_or_to_all(long *target, const long *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_longlong_or_to_all(long long *target, const long long *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long long *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_short_xor_to_all(short *target, const short *source, int nreduce, int PE_start, int logPE_stride, int PE_size, short *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_int_xor_to_all(int *target, const int *source, int nreduce, int PE_start, int logPE_stride, int PE_size, int *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_long_xor_to_all(long *target, const long *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_longlong_xor_to_all(long long *target, const long long *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long long *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_short_max_to_all(short *target, const short *source, int nreduce, int PE_start, int logPE_stride, int PE_size, short *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_int_max_to_all(int *target, const int *source, int nreduce, int PE_start, int logPE_stride, int PE_size, int *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_long_max_to_all(long *target, const long *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_longlong_max_to_all(long long *target, const long long *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long long *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_float_max_to_all(float *target, const float *source, int nreduce, int PE_start, int logPE_stride, int PE_size, float *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_double_max_to_all(double *target, const double *source, int nreduce, int PE_start, int logPE_stride, int PE_size, double *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_longdouble_max_to_all(long double *target, const long double *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long double *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_short_min_to_all(short *target, const short *source, int nreduce, int PE_start, int logPE_stride, int PE_size, short *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_int_min_to_all(int *target, const int *source, int nreduce, int PE_start, int logPE_stride, int PE_size, int *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_long_min_to_all(long *target, const long *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_longlong_min_to_all(long long *target, const long long *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long long *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_float_min_to_all(float *target, const float *source, int nreduce, int PE_start, int logPE_stride, int PE_size, float *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_double_min_to_all(double *target, const double *source, int nreduce, int PE_start, int logPE_stride, int PE_size, double *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_longdouble_min_to_all(long double *target, const long double *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long double *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_short_sum_to_all(short *target, const short *source, int nreduce, int PE_start, int logPE_stride, int PE_size, short *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_int_sum_to_all(int *target, const int *source, int nreduce, int PE_start, int logPE_stride, int PE_size, int *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_long_sum_to_all(long *target, const long *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_longlong_sum_to_all(long long *target, const long long *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long long *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_float_sum_to_all(float *target, const float *source, int nreduce, int PE_start, int logPE_stride, int PE_size, float *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_double_sum_to_all(double *target, const double *source, int nreduce, int PE_start, int logPE_stride, int PE_size, double *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_longdouble_sum_to_all(long double *target, const long double *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long double *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_complexf_sum_to_all(OSHMEM_COMPLEX_TYPE(float) *target, const OSHMEM_COMPLEX_TYPE(float) *source, int nreduce, int PE_start, int logPE_stride, int PE_size, OSHMEM_COMPLEX_TYPE(float) *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_complexd_sum_to_all(OSHMEM_COMPLEX_TYPE(double) *target, const OSHMEM_COMPLEX_TYPE(double) *source, int nreduce, int PE_start, int logPE_stride, int PE_size, OSHMEM_COMPLEX_TYPE(double) *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_short_prod_to_all(short *target, const short *source, int nreduce, int PE_start, int logPE_stride, int PE_size, short *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_int_prod_to_all(int *target, const int *source, int nreduce, int PE_start, int logPE_stride, int PE_size, int *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_long_prod_to_all(long *target, const long *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_longlong_prod_to_all(long long *target, const long long *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long long *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_float_prod_to_all(float *target, const float *source, int nreduce, int PE_start, int logPE_stride, int PE_size, float *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_double_prod_to_all(double *target, const double *source, int nreduce, int PE_start, int logPE_stride, int PE_size, double *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_longdouble_prod_to_all(long double *target, const long double *source, int nreduce, int PE_start, int logPE_stride, int PE_size, long double *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_complexf_prod_to_all(OSHMEM_COMPLEX_TYPE(float) *target, const OSHMEM_COMPLEX_TYPE(float) *source, int nreduce, int PE_start, int logPE_stride, int PE_size, OSHMEM_COMPLEX_TYPE(float) *pWrk, long *pSync);
OSHMEM_DECLSPEC void pshmem_complexd_prod_to_all(OSHMEM_COMPLEX_TYPE(double) *target, const OSHMEM_COMPLEX_TYPE(double) *source, int nreduce, int PE_start, int logPE_stride, int PE_size, OSHMEM_COMPLEX_TYPE(double) *pWrk, long *pSync);
/*
* Platform specific cache management routines
*/
OSHMEM_DECLSPEC void pshmem_udcflush(void);
OSHMEM_DECLSPEC void pshmem_udcflush_line(void* target);
OSHMEM_DECLSPEC void pshmem_set_cache_inv(void);
OSHMEM_DECLSPEC void pshmem_set_cache_line_inv(void* target);
OSHMEM_DECLSPEC void pshmem_clear_cache_inv(void);
OSHMEM_DECLSPEC void pshmem_clear_cache_line_inv(void* target);
#if defined(c_plusplus) || defined(__cplusplus)
}
#endif
#endif /* PSHMEM_SHMEM_H */
| 64.659164 | 235 | 0.790293 |
23b540d0433430334a91580b98f4561412da122b | 723 | h | C | src/device/output/OutputDevices.h | xpj/wemos-weather-simple | c5cbd831354fb4318677a281e4108926686bb9fe | [
"MIT"
] | null | null | null | src/device/output/OutputDevices.h | xpj/wemos-weather-simple | c5cbd831354fb4318677a281e4108926686bb9fe | [
"MIT"
] | null | null | null | src/device/output/OutputDevices.h | xpj/wemos-weather-simple | c5cbd831354fb4318677a281e4108926686bb9fe | [
"MIT"
] | null | null | null |
#ifndef OUTPUTDEVICES_H
#define OUTPUTDEVICES_H
#include "WeatherOutputDevice.h"
#include <stdlib.h>
#include <list>
class OutputDevices {
public:
void add(WeatherOutputDevice *dev) {
devices.push_back(dev);
}
void hello() {
for (devices_it = devices.begin(); devices_it!=devices.end(); devices_it++) {
(*devices_it)->hello();
}
}
void process(Weather weatherEvent) {
for (devices_it = devices.begin(); devices_it!=devices.end(); devices_it++) {
(*devices_it)->process(weatherEvent);
}
}
private:
std::list<WeatherOutputDevice*> devices;
std::list<WeatherOutputDevice*>::iterator devices_it;
};
#endif //OUTPUTDEVICES_H
| 21.909091 | 85 | 0.640387 |
23ba198000c0723d716cc5d19798f9b89a391585 | 1,965 | h | C | Doutzen/Defines.h | nielsmouthaan/Doutzen | 1b495d20469cb25bfbe05152dc6a227300adac66 | [
"Unlicense"
] | 6 | 2015-05-20T07:29:02.000Z | 2021-01-28T02:35:58.000Z | Doutzen/Defines.h | nielsmouthaan/Doutzen | 1b495d20469cb25bfbe05152dc6a227300adac66 | [
"Unlicense"
] | null | null | null | Doutzen/Defines.h | nielsmouthaan/Doutzen | 1b495d20469cb25bfbe05152dc6a227300adac66 | [
"Unlicense"
] | 3 | 2015-07-03T05:55:21.000Z | 2015-12-21T06:32:01.000Z | //
// Defines.h
// Doutzen
//
// Created by Niels Mouthaan on 27-10-12.
// Copyright (c) 2012. All rights reserved.
//
#define kFileInitialConfiguration @"initialConfiguration"
#define kDefaultsKeyLastSynced @"lastSynced"
#define kDefaultsQuincyKitHost @"quincyKitHost"
#define kDefaultsQuincyKitUsername @"quincyKitUsername"
#define kDefaultsQuincyKitPassword @"quincyKitPassword"
#define kDefaultsCheckEvery @"checkEvery"
#define kDefaultsPlaySounds @"playSounds"
#define kValueFormatterMustUseHttpOrHttps @"mustUseHttpOrHttps"
#define kKeychainService @"Doutzen"
#define kIconRotateInterval 0.03
#define kIconRotateSteps 30
#define kNetworkTimeOut 30
#define kMenuIconNormal @"menuIconNormal"
#define kMenuIconError @"menuIconError"
#define kMenuIconHighlighted @"menuIconHighlighted"
#define kMenuIconCrash @"menuIconCrash"
#define kPreferencesCheckEveryApplyAfter 3
#define kQuincyKitAdminURLSuffix @"/admin"
#define kQuincyKitTodoURLSuffix @"/admin/symbolicate_todo.php"
#define kQuincyKitCrashURLSuffix @"/admin/crash_get.php?id="
#define kQuincyKitUpdateURLSuffix @"/admin/crash_update.php"
#define kQuincyKitCrashSuffix @""
#define kQuincyKitTodoSeperator @","
#define kQuincyKitSuccessMessage @"success"
#define kResourceSymbolicator @"/symbolicatecrash.pl"
#define kVoiceOverVoice @"com.apple.speech.synthesis.voice.Vicki"
#define kAppNameMaxLength 50
#define kVersionNameMaxLength 20
#define kAppNameRegex @"\nProcess:( *)([a-zA-Z0-9\\.-_]+)"
#define kVersionNumberRegex @"\nVersion:( *)([a-zA-Z0-9\\.-_]+)"
| 37.788462 | 85 | 0.624936 |
23bc8a516ce1c2294abeb54376bb97819ca5ac70 | 247 | h | C | RayTracing/Middleware/Qt/include/QtQuickParticles/qtquickparticlesversion.h | DarriusWrightGD/realtimeraytracing | 1b1117858dcd8880ed88b59ce0388cfb39fc1d96 | [
"MIT"
] | 1 | 2020-03-27T18:59:57.000Z | 2020-03-27T18:59:57.000Z | RayTracing/Middleware/Qt/include/QtQuickParticles/qtquickparticlesversion.h | DarriusWrightGD/RealtimeRaytracing | 1b1117858dcd8880ed88b59ce0388cfb39fc1d96 | [
"MIT"
] | null | null | null | RayTracing/Middleware/Qt/include/QtQuickParticles/qtquickparticlesversion.h | DarriusWrightGD/RealtimeRaytracing | 1b1117858dcd8880ed88b59ce0388cfb39fc1d96 | [
"MIT"
] | null | null | null | /* This file was generated by syncqt. */
#ifndef QT_QTQUICKPARTICLES_VERSION_H
#define QT_QTQUICKPARTICLES_VERSION_H
#define QTQUICKPARTICLES_VERSION_STR "5.3.1"
#define QTQUICKPARTICLES_VERSION 0x050301
#endif // QT_QTQUICKPARTICLES_VERSION_H
| 24.7 | 44 | 0.838057 |
23bcfeb15c0b5b0aaa0d4d16f82aaa875579ae46 | 32,426 | c | C | transforms.c | ahmedgenina/pyxmlsec-0.3.1 | c21f5b8c9e6543eedf0364565e0298657174d9aa | [
"MIT"
] | null | null | null | transforms.c | ahmedgenina/pyxmlsec-0.3.1 | c21f5b8c9e6543eedf0364565e0298657174d9aa | [
"MIT"
] | null | null | null | transforms.c | ahmedgenina/pyxmlsec-0.3.1 | c21f5b8c9e6543eedf0364565e0298657174d9aa | [
"MIT"
] | null | null | null | /* $Id: transforms.c 366 2013-07-29 22:20:24Z valos $
*
* PyXMLSec - Python bindings for XML Security library (XMLSec)
*
* Copyright (C) 2003-2013 Easter-eggs, Valery Febvre
* http://pyxmlsec.labs.libre-entreprise.org
*
* Author: Valery Febvre <vfebvre@easter-eggs.com>
*
* This is free software; see COPYING file in the source
* distribution for preciese wording.
*/
#include "xmlsecmod.h"
#include "transforms.h"
#include "buffer.h"
#include "keys.h"
#include "list.h"
#include "nodeset.h"
PyObject *wrap_xmlSecTransformCtxPtr(xmlSecTransformCtxPtr ctx) {
PyObject *ret;
if (ctx == NULL) {
Py_INCREF(Py_None);
return (Py_None);
}
ret = PyCObject_FromVoidPtrAndDesc((void *) ctx,
(char *) "xmlSecTransformCtxPtr", NULL);
return (ret);
}
PyObject *wrap_xmlSecTransformPtr(xmlSecTransformPtr transform) {
PyObject *ret;
if (transform == NULL) {
Py_INCREF(Py_None);
return (Py_None);
}
ret = PyCObject_FromVoidPtrAndDesc((void *) transform,
(char *) "xmlSecTransformPtr", NULL);
return (ret);
}
PyObject *wrap_xmlSecTransformId(xmlSecTransformId transformId) {
PyObject *ret;
if (transformId == NULL) {
Py_INCREF(Py_None);
return (Py_None);
}
ret = PyCObject_FromVoidPtrAndDesc((void *) transformId,
(char *) "xmlSecTransformId", NULL);
return (ret);
}
/******************************************************************************/
PyObject *xmlsec_TransformUriTypeCheck(PyObject *self, PyObject *args) {
xmlSecTransformUriType type;
const xmlChar *uri;
int ret;
if (CheckArgs(args, "IS:transformUriTypeCheck")) {
if(!PyArg_ParseTuple(args, (char *) "is:transformUriTypeCheck", &type, &uri))
return NULL;
}
else return NULL;
ret = xmlSecTransformUriTypeCheck(type, uri);
return (wrap_int(ret));
}
/******************************************************************************/
/* TransformCtx */
/******************************************************************************/
static xmlHashTablePtr TransformCtxPreExecuteCallbacks = NULL;
static int xmlsec_TransformCtxPreExecuteCallback(xmlSecTransformCtxPtr transformCtx) {
PyObject *args, *result;
PyObject *func = NULL;
func = xmlHashLookup2(TransformCtxPreExecuteCallbacks,
transformCtx->uri, transformCtx->xptrExpr);
args = Py_BuildValue((char *) "O", wrap_xmlSecTransformCtxPtr(transformCtx));
Py_INCREF(func);
result = PyEval_CallObject(func, args);
Py_DECREF(func);
Py_DECREF(args);
return (PyInt_AsLong(result));
}
PyObject *xmlSecTransformCtx_getattr(PyObject *self, PyObject *args) {
PyObject *transformCtx_obj;
xmlSecTransformCtxPtr transformCtx;
const char *attr;
if (CheckArgs(args, "OS:transformCtxGetAttr")) {
if (!PyArg_ParseTuple(args, "Os:transformCtxGetAttr",
&transformCtx_obj, &attr))
return NULL;
}
else return NULL;
transformCtx = xmlSecTransformCtxPtr_get(transformCtx_obj);
if (!strcmp(attr, "__members__"))
return Py_BuildValue("[sssssssssss]", "flags",
"flags2", "enabledUris", "enabledTransforms",
"preExecCallback", "result", "status", "uri",
"xptrExpr", "first", "last");
if (!strcmp(attr, "flags"))
return (wrap_int(transformCtx->flags));
if (!strcmp(attr, "flags2"))
return (wrap_int(transformCtx->flags2));
if (!strcmp(attr, "enabledUris"))
return (wrap_int(transformCtx->enabledUris));
if (!strcmp(attr, "enabledTransforms"))
return (wrap_xmlSecPtrListPtr(&(transformCtx->enabledTransforms)));
if (!strcmp(attr, "preExecCallback"))
return PyCObject_FromVoidPtr((void *) transformCtx->preExecCallback, NULL);
if (!strcmp(attr, "result"))
return (wrap_xmlSecBufferPtr(transformCtx->result));
if (!strcmp(attr, "status"))
return (wrap_int(transformCtx->status));
if (!strcmp(attr, "uri"))
return (wrap_xmlCharPtr(transformCtx->uri));
if (!strcmp(attr, "xptrExpr"))
return (wrap_xmlCharPtr(transformCtx->xptrExpr));
if (!strcmp(attr, "first"))
return (wrap_xmlSecTransformPtr(transformCtx->first));
if (!strcmp(attr, "last"))
return (wrap_xmlSecTransformPtr(transformCtx->last));
Py_INCREF(Py_None);
return (Py_None);
}
PyObject *xmlSecTransformCtx_setattr(PyObject *self, PyObject *args) {
PyObject *transformCtx_obj, *value_obj;
xmlSecTransformCtxPtr transformCtx;
const char *name;
if (CheckArgs(args, "OS?:transformCtxSetAttr")) {
if (!PyArg_ParseTuple(args, "OsO:transformCtxSetAttr",
&transformCtx_obj, &name, &value_obj))
return NULL;
}
else return NULL;
transformCtx = xmlSecTransformCtxPtr_get(transformCtx_obj);
if (!strcmp(name, "flags"))
transformCtx->flags = PyInt_AsLong(value_obj);
else if (!strcmp(name, "flags2"))
transformCtx->flags2 = PyInt_AsLong(value_obj);
else if (!strcmp(name, "enabledUris"))
transformCtx->enabledUris = PyInt_AsLong(value_obj);
else if (!strcmp(name, "enabledTransforms"))
transformCtx->enabledTransforms = *(xmlSecPtrListPtr_get(value_obj));
else if (!strcmp(name, "preExecCallback"))
if (value_obj != Py_None) {
if (TransformCtxPreExecuteCallbacks == NULL)
TransformCtxPreExecuteCallbacks = xmlHashCreate(HASH_TABLE_SIZE);
xmlHashAddEntry2(TransformCtxPreExecuteCallbacks,
transformCtx->uri, transformCtx->xptrExpr, value_obj);
Py_XINCREF(value_obj);
transformCtx->preExecCallback = xmlsec_TransformCtxPreExecuteCallback;
}
else
transformCtx->preExecCallback = NULL;
else if (!strcmp(name, "result"))
transformCtx->result = xmlSecBufferPtr_get(value_obj);
else if (!strcmp(name, "status"))
transformCtx->status = PyInt_AsLong(value_obj);
else if (!strcmp(name, "uri"))
transformCtx->uri = (xmlChar *)PyString_AsString(value_obj);
else if (!strcmp(name, "xptrExpr"))
transformCtx->xptrExpr = (xmlChar *)PyString_AsString(value_obj);
else if (!strcmp(name, "first"))
transformCtx->first = xmlSecTransformPtr_get(value_obj);
else if (!strcmp(name, "last"))
transformCtx->last = xmlSecTransformPtr_get(value_obj);
Py_INCREF(Py_None);
return (Py_None);
}
/******************************************************************************/
PyObject *xmlsec_TransformCtxCreate(PyObject *self, PyObject *args) {
xmlSecTransformCtxPtr ctx;
ctx = xmlSecTransformCtxCreate();
return (wrap_xmlSecTransformCtxPtr(ctx));
}
PyObject *xmlsec_TransformCtxDestroy(PyObject *self, PyObject *args) {
PyObject *ctx_obj;
xmlSecTransformCtxPtr ctx;
if (CheckArgs(args, "O:transformCtxDestroy")) {
if(!PyArg_ParseTuple(args, (char *) "O:transformCtxDestroy", &ctx_obj))
return NULL;
}
else return NULL;
ctx = xmlSecTransformCtxPtr_get(ctx_obj);
xmlSecTransformCtxDestroy(ctx);
Py_INCREF(Py_None);
return (Py_None);
}
PyObject *xmlsec_TransformCtxInitialize(PyObject *self, PyObject *args) {
PyObject *ctx_obj;
xmlSecTransformCtxPtr ctx;
if (CheckArgs(args, "O:transformCtxInitialize")) {
if(!PyArg_ParseTuple(args, (char *) "O:transformCtxInitialize", &ctx_obj))
return NULL;
}
else return NULL;
ctx = xmlSecTransformCtxPtr_get(ctx_obj);
xmlSecTransformCtxInitialize(ctx);
Py_INCREF(Py_None);
return (Py_None);
}
PyObject *xmlsec_TransformCtxFinalize(PyObject *self, PyObject *args) {
PyObject *ctx_obj;
xmlSecTransformCtxPtr ctx;
if (CheckArgs(args, "O:transformCtxFinalize")) {
if(!PyArg_ParseTuple(args, (char *) "O:transformCtxFinalize", &ctx_obj))
return NULL;
}
else return NULL;
ctx = xmlSecTransformCtxPtr_get(ctx_obj);
xmlSecTransformCtxFinalize(ctx);
Py_INCREF(Py_None);
return (Py_None);
}
PyObject *xmlsec_TransformCtxReset(PyObject *self, PyObject *args) {
PyObject *ctx_obj;
xmlSecTransformCtxPtr ctx;
if (CheckArgs(args, "O:transformCtxReset")) {
if(!PyArg_ParseTuple(args, (char *) "O:transformCtxReset", &ctx_obj))
return NULL;
}
else return NULL;
ctx = xmlSecTransformCtxPtr_get(ctx_obj);
xmlSecTransformCtxReset(ctx);
Py_INCREF(Py_None);
return (Py_None);
}
/******************************************************************************/
/* Transform */
/******************************************************************************/
PyObject *xmlSecTransform_getattr(PyObject *self, PyObject *args) {
PyObject *transform_obj;
xmlSecTransformPtr transform;
const char *attr;
if (CheckArgs(args, "OS:transformGetAttr")) {
if (!PyArg_ParseTuple(args, "Os:transformGetAttr",
&transform_obj, &attr))
return NULL;
}
else return NULL;
transform = xmlSecTransformPtr_get(transform_obj);
if (!strcmp(attr, "__members__"))
return Py_BuildValue("[ssssssssss]", "id", "operation", "status",
"hereNode", "next", "prev", "inBuf", "outBuf",
"inNodes", "outNodes");
if (!strcmp(attr, "id"))
return (wrap_xmlSecTransformId(transform->id));
if (!strcmp(attr, "operation"))
return (wrap_int(transform->operation));
if (!strcmp(attr, "status"))
return (wrap_int(transform->status));
if (!strcmp(attr, "hereNode"))
return (wrap_xmlNodePtr(transform->hereNode));
if (!strcmp(attr, "next"))
return (wrap_xmlSecTransformPtr(transform->next));
if (!strcmp(attr, "prev"))
return (wrap_xmlSecTransformPtr(transform->prev));
if (!strcmp(attr, "inBuf"))
return (wrap_xmlSecBufferPtr(&(transform->inBuf)));
if (!strcmp(attr, "outBuf"))
return (wrap_xmlSecBufferPtr(&(transform->outBuf)));
if (!strcmp(attr, "inNodes"))
return (wrap_xmlSecNodeSetPtr(transform->inNodes));
if (!strcmp(attr, "outNodes"))
return (wrap_xmlSecNodeSetPtr(transform->outNodes));
Py_INCREF(Py_None);
return (Py_None);
}
PyObject *xmlSecTransform_setattr(PyObject *self, PyObject *args) {
PyObject *transform_obj, *value_obj;
xmlSecTransformPtr transform;
const char *name;
if (CheckArgs(args, "OS?:transformSetAttr")) {
if (!PyArg_ParseTuple(args, "OsO:transformSetAttr",
&transform_obj, &name, &value_obj))
return NULL;
}
else return NULL;
transform = xmlSecTransformPtr_get(transform_obj);
if (!strcmp(name, "id"))
transform->id = xmlSecTransformId_get(value_obj);
else if (!strcmp(name, "operation"))
transform->operation = PyInt_AsLong(value_obj);
else if (!strcmp(name, "status"))
transform->status = PyInt_AsLong(value_obj);
else if (!strcmp(name, "hereNode"))
transform->hereNode = xmlNodePtr_get(value_obj);
else if (!strcmp(name, "next"))
transform->next = xmlSecTransformPtr_get(value_obj);
else if (!strcmp(name, "prev"))
transform->prev = xmlSecTransformPtr_get(value_obj);
else if (!strcmp(name, "inBuf"))
transform->inBuf = *(xmlSecBufferPtr_get(value_obj));
else if (!strcmp(name, "outBuf"))
transform->outBuf = *(xmlSecBufferPtr_get(value_obj));
else if (!strcmp(name, "inNodes"))
transform->inNodes = xmlSecNodeSetPtr_get(value_obj);
else if (!strcmp(name, "outNodes"))
transform->outNodes = xmlSecNodeSetPtr_get(value_obj);
Py_INCREF(Py_None);
return (Py_None);
}
/******************************************************************************/
PyObject *xmlsec_TransformCreate(PyObject *self, PyObject *args) {
PyObject *id_obj;
xmlSecTransformId id;
xmlSecTransformPtr transform;
if (CheckArgs(args, "O:transformCreate")) {
if(!PyArg_ParseTuple(args, (char *) "O:transformCreate", &id_obj))
return NULL;
}
else return NULL;
id = xmlSecTransformId_get(id_obj);
transform = xmlSecTransformCreate(id);
return (wrap_xmlSecTransformPtr(transform));
}
PyObject *xmlsec_TransformDestroy(PyObject *self, PyObject *args) {
PyObject *transform_obj;
xmlSecTransformPtr transform;
if (CheckArgs(args, "O:transformDestroy")) {
if(!PyArg_ParseTuple(args, (char *) "O:transformDestroy", &transform_obj))
return NULL;
}
else return NULL;
transform = xmlSecTransformPtr_get(transform_obj);
xmlSecTransformDestroy(transform);
Py_INCREF(Py_None);
return (Py_None);
}
PyObject *xmlsec_TransformNodeRead(PyObject *self, PyObject *args) {
PyObject *node_obj, *transformCtx_obj;
xmlNodePtr node;
xmlSecTransformUsage usage;
xmlSecTransformCtxPtr transformCtx;
xmlSecTransformPtr transform;
if (CheckArgs(args, "OIO:transformNodeRead")) {
if(!PyArg_ParseTuple(args, (char *) "OiO:transformNodeRead", &node_obj,
&usage, &transformCtx_obj))
return NULL;
}
else return NULL;
node = xmlNodePtr_get(node_obj);
transformCtx = xmlSecTransformCtxPtr_get(transformCtx_obj);
transform = xmlSecTransformNodeRead(node, usage, transformCtx);
return (wrap_xmlSecTransformPtr(transform));
}
PyObject *xmlsec_TransformSetKey(PyObject *self, PyObject *args) {
PyObject *transform_obj, *key_obj;
xmlSecTransformPtr transform;
xmlSecKeyPtr key;
int ret;
if (CheckArgs(args, "OO:transformSetKey")) {
if(!PyArg_ParseTuple(args, (char *) "OO:transformSetKey", &transform_obj,
&key_obj))
return NULL;
}
else return NULL;
transform = xmlSecTransformPtr_get(transform_obj);
key = xmlSecKeyPtr_get(key_obj);
ret = xmlSecTransformSetKey(transform, key);
return (wrap_int(ret));
}
PyObject *xmlsec_TransformSetKeyReq(PyObject *self, PyObject *args) {
PyObject *transform_obj, *keyReq_obj;
xmlSecTransformPtr transform;
xmlSecKeyReqPtr keyReq;
int ret;
if (CheckArgs(args, "OO:transformSetKeyReq")) {
if(!PyArg_ParseTuple(args, (char *) "OO:transformSetKeyReq",
&transform_obj, &keyReq_obj))
return NULL;
}
else return NULL;
transform = xmlSecTransformPtr_get(transform_obj);
keyReq = xmlSecKeyReqPtr_get(keyReq_obj);
ret = xmlSecTransformSetKeyReq(transform, keyReq);
return (wrap_int(ret));
}
PyObject *xmlsec_TransformBase64SetLineSize(PyObject *self, PyObject *args) {
PyObject *transform_obj;
xmlSecTransformPtr transform;
xmlSecSize lineSize;
if (CheckArgs(args, "OI:transformBase64SetLineSize")) {
if(!PyArg_ParseTuple(args, (char *) "Oi:transformBase64SetLineSize",
&transform_obj, &lineSize))
return NULL;
}
else return NULL;
transform = xmlSecTransformPtr_get(transform_obj);
xmlSecTransformBase64SetLineSize(transform, lineSize);
Py_INCREF(Py_None);
return (Py_None);
}
PyObject *xmlsec_TransformXPointerSetExpr(PyObject *self, PyObject *args) {
PyObject *transform_obj, *hereNode_obj;
xmlSecTransformPtr transform;
const xmlChar *expr;
xmlSecNodeSetType nodeSetType;
xmlNodePtr hereNode;
int ret;
if (CheckArgs(args, "OSIO:transformXPointerSetExpr")) {
if(!PyArg_ParseTuple(args, (char *) "OsiO:transformXPointerSetExpr",
&transform_obj, &expr, &nodeSetType, &hereNode_obj))
return NULL;
}
else return NULL;
transform = xmlSecTransformPtr_get(transform_obj);
hereNode = xmlNodePtr_get(hereNode_obj);
ret = xmlSecTransformXPointerSetExpr(transform, expr, nodeSetType, hereNode);
return (wrap_int(ret));
}
PyObject *xmlsec_TransformVisa3DHackSetID(PyObject *self, PyObject *args) {
PyObject *transform_obj;
xmlSecTransformPtr transform;
const xmlChar *id;
int ret;
if (CheckArgs(args, "OS:transformVisa3DHackSetID")) {
if(!PyArg_ParseTuple(args, (char *) "Os:transformVisa3DHackSetID",
&transform_obj, &id))
return NULL;
}
else return NULL;
transform = xmlSecTransformPtr_get(transform_obj);
ret = xmlSecTransformVisa3DHackSetID(transform, id);
return (wrap_int(ret));
}
/*****************************************************************************/
PyObject *xmlsec_TransformBase64Id(PyObject *self, PyObject *args) {
return PyCObject_FromVoidPtr((void *) xmlSecTransformBase64Id, NULL);
}
PyObject *xmlsec_TransformInclC14NId(PyObject *self, PyObject *args) {
return PyCObject_FromVoidPtr((void *) xmlSecTransformInclC14NId, NULL);
}
PyObject *xmlsec_TransformInclC14NWithCommentsId(PyObject *self, PyObject *args) {
return PyCObject_FromVoidPtr((void *) xmlSecTransformInclC14NWithCommentsId, NULL);
}
PyObject *xmlsec_TransformExclC14NId(PyObject *self, PyObject *args) {
return PyCObject_FromVoidPtr((void *) xmlSecTransformExclC14NId, NULL);
}
PyObject *xmlsec_TransformExclC14NWithCommentsId(PyObject *self, PyObject *args) {
return PyCObject_FromVoidPtr((void *) xmlSecTransformExclC14NWithCommentsId, NULL);
}
PyObject *xmlsec_TransformEnvelopedId(PyObject *self, PyObject *args) {
return PyCObject_FromVoidPtr((void *) xmlSecTransformEnvelopedId, NULL);
}
PyObject *xmlsec_TransformXPathId(PyObject *self, PyObject *args) {
return PyCObject_FromVoidPtr((void *) xmlSecTransformXPathId, NULL);
}
PyObject *xmlsec_TransformXPath2Id(PyObject *self, PyObject *args) {
return PyCObject_FromVoidPtr((void *) xmlSecTransformXPath2Id, NULL);
}
PyObject *xmlsec_TransformXPointerId(PyObject *self, PyObject *args) {
return PyCObject_FromVoidPtr((void *) xmlSecTransformXPointerId, NULL);
}
PyObject *xmlsec_TransformXsltId(PyObject *self, PyObject *args) {
return PyCObject_FromVoidPtr((void *) xmlSecTransformXsltId, NULL);
}
PyObject *xmlsec_TransformRemoveXmlTagsC14NId(PyObject *self, PyObject *args) {
return PyCObject_FromVoidPtr((void *) xmlSecTransformRemoveXmlTagsC14NId, NULL);
}
PyObject *xmlsec_TransformVisa3DHackId(PyObject *self, PyObject *args) {
return PyCObject_FromVoidPtr((void *) xmlSecTransformVisa3DHackId, NULL);
}
/******************************************************************************/
/* TransformId */
/******************************************************************************/
static xmlHashTablePtr TransformInitializeMethods = NULL;
static xmlHashTablePtr TransformFinalizeMethods = NULL;
static xmlHashTablePtr TransformNodeReadMethods = NULL;
static xmlHashTablePtr TransformNodeWriteMethods = NULL;
static xmlHashTablePtr TransformSetKeyRequirementsMethods = NULL;
static xmlHashTablePtr TransformSetKeyMethods = NULL;
static xmlHashTablePtr TransformVerifyMethods = NULL;
static xmlHashTablePtr TransformGetDataTypeMethods = NULL;
static xmlHashTablePtr TransformPushBinMethods = NULL;
static xmlHashTablePtr TransformPopBinMethods = NULL;
static xmlHashTablePtr TransformPushXmlMethods = NULL;
static xmlHashTablePtr TransformPopXmlMethods = NULL;
static xmlHashTablePtr TransformExecuteMethods = NULL;
static int xmlsec_TransformInitializeMethod(xmlSecTransformPtr transform) {
PyObject *args, *result;
PyObject *func = NULL;
func = xmlHashLookup2(TransformInitializeMethods, transform->id->name,
transform->id->href);
args = Py_BuildValue((char *) "O", wrap_xmlSecTransformPtr(transform));
/* Protect refcount against reentrant manipulation of callback hash */
Py_INCREF(func);
result = PyEval_CallObject(func, args);
Py_DECREF(func);
Py_DECREF(args);
return (PyInt_AsLong(result));
}
static void xmlsec_TransformFinalizeMethod(xmlSecTransformPtr transform) {
PyObject *args, *result;
PyObject *func = NULL;
func = xmlHashLookup2(TransformFinalizeMethods, transform->id->name,
transform->id->href);
args = Py_BuildValue((char *) "O", wrap_xmlSecTransformPtr(transform));
Py_INCREF(func);
result = PyEval_CallObject(func, args);
Py_DECREF(func);
Py_DECREF(args);
Py_XDECREF(result);
}
static xmlSecTransformDataType xmlsec_TransformGetDataTypeMethod(xmlSecTransformPtr transform,
xmlSecTransformMode mode,
xmlSecTransformCtxPtr transformCtx) {
PyObject *args, *result;
PyObject *func = NULL;
func = xmlHashLookup2(TransformGetDataTypeMethods, transform->id->name,
transform->id->href);
args = Py_BuildValue((char *) "OiO", wrap_xmlSecTransformPtr(transform),
mode, wrap_xmlSecTransformCtxPtr(transformCtx));
Py_INCREF(func);
result = PyEval_CallObject(func, args);
Py_DECREF(func);
Py_DECREF(args);
return (PyInt_AsLong(result));
}
static int xmlsec_TransformNodeReadMethod(xmlSecTransformPtr transform,
xmlNodePtr node,
xmlSecTransformCtxPtr transformCtx) {
PyObject *args, *result;
PyObject *func = NULL;
func = xmlHashLookup2(TransformNodeReadMethods, transform->id->name,
transform->id->href);
args = Py_BuildValue((char *) "OOO", wrap_xmlSecTransformPtr(transform),
wrap_xmlNodePtr(node),
wrap_xmlSecTransformCtxPtr(transformCtx));
Py_INCREF(func);
result = PyEval_CallObject(func, args);
Py_DECREF(func);
Py_DECREF(args);
return (PyInt_AsLong(result));
}
static int xmlsec_TransformNodeWriteMethod(xmlSecTransformPtr transform,
xmlNodePtr node,
xmlSecTransformCtxPtr transformCtx) {
PyObject *args, *result;
PyObject *func = NULL;
func = xmlHashLookup2(TransformNodeWriteMethods, transform->id->name,
transform->id->href);
args = Py_BuildValue((char *) "OOO", wrap_xmlSecTransformPtr(transform),
wrap_xmlNodePtr(node),
wrap_xmlSecTransformCtxPtr(transformCtx));
Py_INCREF(func);
result = PyEval_CallObject(func, args);
Py_DECREF(func);
Py_DECREF(args);
return (PyInt_AsLong(result));
}
static int xmlsec_TransformSetKeyRequirementsMethod(xmlSecTransformPtr transform,
xmlSecKeyReqPtr keyReq) {
PyObject *args, *result;
PyObject *func = NULL;
func = xmlHashLookup2(TransformSetKeyRequirementsMethods, transform->id->name,
transform->id->href);
args = Py_BuildValue((char *) "OO", wrap_xmlSecTransformPtr(transform),
wrap_xmlSecKeyReqPtr(keyReq));
Py_INCREF(func);
result = PyEval_CallObject(func, args);
Py_DECREF(func);
Py_DECREF(args);
return (PyInt_AsLong(result));
}
static int xmlsec_TransformSetKeyMethod(xmlSecTransformPtr transform,
xmlSecKeyPtr key) {
PyObject *args, *result;
PyObject *func = NULL;
func = xmlHashLookup2(TransformSetKeyMethods, transform->id->name,
transform->id->href);
args = Py_BuildValue((char *) "OO", wrap_xmlSecTransformPtr(transform),
wrap_xmlSecKeyPtr(key));
Py_INCREF(func);
result = PyEval_CallObject(func, args);
Py_DECREF(func);
Py_DECREF(args);
return (PyInt_AsLong(result));
}
static int xmlsec_TransformVerifyMethod(xmlSecTransformPtr transform,
const xmlSecByte *data,
xmlSecSize dataSize,
xmlSecTransformCtxPtr transformCtx) {
PyObject *args, *result;
PyObject *func = NULL;
func = xmlHashLookup2(TransformVerifyMethods, transform->id->name,
transform->id->href);
args = Py_BuildValue((char *) "OsiO", wrap_xmlSecTransformPtr(transform),
data, dataSize,
wrap_xmlSecTransformCtxPtr(transformCtx));
Py_INCREF(func);
result = PyEval_CallObject(func, args);
Py_DECREF(func);
Py_DECREF(args);
return (PyInt_AsLong(result));
}
static int xmlsec_TransformPushBinMethod(xmlSecTransformPtr transform,
const xmlSecByte *data,
xmlSecSize dataSize,
int final,
xmlSecTransformCtxPtr transformCtx) {
PyObject *args, *result;
PyObject *func = NULL;
func = xmlHashLookup2(TransformPushBinMethods, transform->id->name,
transform->id->href);
args = Py_BuildValue((char *) "OsiiO", wrap_xmlSecTransformPtr(transform),
data, dataSize, final,
wrap_xmlSecTransformCtxPtr(transformCtx));
Py_INCREF(func);
result = PyEval_CallObject(func, args);
Py_DECREF(func);
Py_DECREF(args);
return (PyInt_AsLong(result));
}
static int xmlsec_TransformPopBinMethod(xmlSecTransformPtr transform,
xmlSecByte *data,
xmlSecSize maxDataSize,
xmlSecSize *dataSize,
xmlSecTransformCtxPtr transformCtx) {
PyObject *args, *result;
PyObject *func = NULL;
func = xmlHashLookup2(TransformPopBinMethods, transform->id->name,
transform->id->href);
// FIXME -> dataSize
args = Py_BuildValue((char *) "OsiOO", wrap_xmlSecTransformPtr(transform),
data, maxDataSize, PyCObject_FromVoidPtr(dataSize, NULL),
wrap_xmlSecTransformCtxPtr(transformCtx));
Py_INCREF(func);
result = PyEval_CallObject(func, args);
Py_DECREF(func);
Py_DECREF(args);
return (PyInt_AsLong(result));
}
static int xmlsec_TransformPushXmlMethod(xmlSecTransformPtr transform,
xmlSecNodeSetPtr nodes,
xmlSecTransformCtxPtr transformCtx) {
PyObject *args, *result;
PyObject *func = NULL;
func = xmlHashLookup2(TransformPushXmlMethods, transform->id->name,
transform->id->href);
args = Py_BuildValue((char *) "OOO", wrap_xmlSecTransformPtr(transform),
wrap_xmlSecNodeSetPtr(nodes),
wrap_xmlSecTransformCtxPtr(transformCtx));
Py_INCREF(func);
result = PyEval_CallObject(func, args);
Py_DECREF(func);
Py_DECREF(args);
return (PyInt_AsLong(result));
}
static int xmlsec_TransformPopXmlMethod(xmlSecTransformPtr transform,
xmlSecNodeSetPtr *nodes,
xmlSecTransformCtxPtr transformCtx) {
PyObject *args, *result;
PyObject *func = NULL;
func = xmlHashLookup2(TransformPopXmlMethods, transform->id->name,
transform->id->href);
// FIXME -> nodes
args = Py_BuildValue((char *) "OOO", wrap_xmlSecTransformPtr(transform),
PyCObject_FromVoidPtr(nodes, NULL),
wrap_xmlSecTransformCtxPtr(transformCtx));
Py_INCREF(func);
result = PyEval_CallObject(func, args);
Py_DECREF(func);
Py_DECREF(args);
return (PyInt_AsLong(result));
}
static int xmlsec_TransformExecuteMethod(xmlSecTransformPtr transform,
int last,
xmlSecTransformCtxPtr transformCtx) {
PyObject *args, *result;
PyObject *func = NULL;
func = xmlHashLookup2(TransformExecuteMethods, transform->id->name,
transform->id->href);
args = Py_BuildValue((char *) "OiO", wrap_xmlSecTransformPtr(transform),
last,
wrap_xmlSecTransformCtxPtr(transformCtx));
Py_INCREF(func);
result = PyEval_CallObject(func, args);
Py_DECREF(func);
Py_DECREF(args);
return (PyInt_AsLong(result));
}
/******************************************************************************/
PyObject *transforms_TransformIdCreate(PyObject *self, PyObject *args) {
PyObject *initialize_obj, *finalize_obj, *readNode_obj, *writeNode_obj;
PyObject *setKeyReq_obj, *setKey_obj, *verify_obj, *getDataType_obj;
PyObject *pushBin_obj, *popBin_obj, *pushXml_obj, *popXml_obj, *execute_obj;
xmlSecSize klassSize;
xmlSecSize objSize;
const xmlChar *name;
const xmlChar *href;
xmlSecTransformUsage usage;
struct _xmlSecTransformKlass *transformId;
if (CheckArgs(args, "IISSIccccccccccccc:keyTransformIdCreate")) {
if (!PyArg_ParseTuple(args, (char *) "iissiOOOOOOOOOOOOO:keyTransformIdCreate",
&klassSize, &objSize, &name, &href, &usage,
&initialize_obj, &finalize_obj, &readNode_obj,
&writeNode_obj, &setKeyReq_obj, &setKey_obj,
&verify_obj, &getDataType_obj, &pushBin_obj,
&popBin_obj, &pushXml_obj, &popXml_obj,
&execute_obj))
return NULL;
}
else return NULL;
if (TransformInitializeMethods == NULL && initialize_obj != Py_None)
TransformInitializeMethods = xmlHashCreate(HASH_TABLE_SIZE);
if (TransformFinalizeMethods == NULL && finalize_obj != Py_None)
TransformFinalizeMethods = xmlHashCreate(HASH_TABLE_SIZE);
if (TransformNodeReadMethods == NULL && readNode_obj != Py_None)
TransformNodeReadMethods = xmlHashCreate(HASH_TABLE_SIZE);
if (TransformNodeWriteMethods == NULL && writeNode_obj != Py_None)
TransformNodeWriteMethods = xmlHashCreate(HASH_TABLE_SIZE);
if (TransformSetKeyRequirementsMethods == NULL && setKeyReq_obj != Py_None)
TransformSetKeyRequirementsMethods = xmlHashCreate(HASH_TABLE_SIZE);
if (TransformSetKeyMethods == NULL && setKey_obj != Py_None)
TransformSetKeyMethods = xmlHashCreate(HASH_TABLE_SIZE);
if (TransformVerifyMethods == NULL && verify_obj != Py_None)
TransformVerifyMethods = xmlHashCreate(HASH_TABLE_SIZE);
if (TransformGetDataTypeMethods == NULL && getDataType_obj != Py_None)
TransformGetDataTypeMethods = xmlHashCreate(HASH_TABLE_SIZE);
if (TransformPushBinMethods == NULL && pushBin_obj != Py_None)
TransformPushBinMethods = xmlHashCreate(HASH_TABLE_SIZE);
if (TransformPopBinMethods == NULL && popBin_obj != Py_None)
TransformPopBinMethods = xmlHashCreate(HASH_TABLE_SIZE);
if (TransformPushXmlMethods == NULL && pushXml_obj != Py_None)
TransformPushXmlMethods = xmlHashCreate(HASH_TABLE_SIZE);
if (TransformPopXmlMethods == NULL && popXml_obj != Py_None)
TransformPopXmlMethods = xmlHashCreate(HASH_TABLE_SIZE);
if (TransformExecuteMethods == NULL && execute_obj != Py_None)
TransformExecuteMethods = xmlHashCreate(HASH_TABLE_SIZE);
if (initialize_obj != Py_None)
xmlHashAddEntry2(TransformInitializeMethods, name, href, initialize_obj);
if (finalize_obj != Py_None)
xmlHashAddEntry2(TransformFinalizeMethods, name, href, finalize_obj);
if (readNode_obj != Py_None)
xmlHashAddEntry2(TransformNodeReadMethods, name, href, readNode_obj);
if (writeNode_obj != Py_None)
xmlHashAddEntry2(TransformNodeWriteMethods, name, href, writeNode_obj);
if (setKeyReq_obj != Py_None)
xmlHashAddEntry2(TransformSetKeyRequirementsMethods, name, href, setKeyReq_obj);
if (setKey_obj != Py_None)
xmlHashAddEntry2(TransformSetKeyMethods, name, href, setKey_obj);
if (verify_obj != Py_None)
xmlHashAddEntry2(TransformVerifyMethods, name, href, verify_obj);
if (getDataType_obj != Py_None)
xmlHashAddEntry2(TransformGetDataTypeMethods, name, href, getDataType_obj);
if (pushBin_obj != Py_None)
xmlHashAddEntry2(TransformPushBinMethods, name, href, pushBin_obj);
if (popBin_obj != Py_None)
xmlHashAddEntry2(TransformPopBinMethods, name, href, popBin_obj);
if (pushXml_obj != Py_None)
xmlHashAddEntry2(TransformPushXmlMethods, name, href, pushXml_obj);
if (popXml_obj != Py_None)
xmlHashAddEntry2(TransformPopXmlMethods, name, href, popXml_obj);
if (execute_obj != Py_None)
xmlHashAddEntry2(TransformExecuteMethods, name, href, execute_obj);
transformId = xmlMalloc(sizeof(xmlSecTransformKlass));
/* FIXME
transformId->klassSize = klassSize;
transformId->objSize = objSize;
*/
transformId->klassSize = sizeof(xmlSecTransformKlass);
transformId->objSize = sizeof(xmlSecTransform);
transformId->name = name;
transformId->href = href;
transformId->usage = usage;
if (initialize_obj != Py_None)
transformId->initialize = xmlsec_TransformInitializeMethod;
else
transformId->initialize = NULL;
if (finalize_obj != Py_None)
transformId->finalize = xmlsec_TransformFinalizeMethod;
else
transformId->finalize = NULL;
if (readNode_obj != Py_None)
transformId->readNode = xmlsec_TransformNodeReadMethod;
else
transformId->readNode = NULL;
if (writeNode_obj != Py_None)
transformId->writeNode = xmlsec_TransformNodeWriteMethod;
else
transformId->writeNode = NULL;
if (setKeyReq_obj != Py_None)
transformId->setKeyReq = xmlsec_TransformSetKeyRequirementsMethod;
else
transformId->setKeyReq = NULL;
if (setKey_obj != Py_None)
transformId->setKey = xmlsec_TransformSetKeyMethod;
else
transformId->setKey = NULL;
if (verify_obj != Py_None)
transformId->verify = xmlsec_TransformVerifyMethod;
else
transformId->verify = NULL;
if (getDataType_obj != Py_None)
transformId->getDataType = xmlsec_TransformGetDataTypeMethod;
else
transformId->getDataType = NULL;
if (pushBin_obj != Py_None)
transformId->pushBin = xmlsec_TransformPushBinMethod;
else
transformId->pushBin = NULL;
if (popBin_obj != Py_None)
transformId->popBin = xmlsec_TransformPopBinMethod;
else
transformId->popBin = NULL;
if (pushXml_obj != Py_None)
transformId->pushXml = xmlsec_TransformPushXmlMethod;
else
transformId->pushXml = NULL;
if (popXml_obj != Py_None)
transformId->popXml = xmlsec_TransformPopXmlMethod;
else
transformId->popXml = NULL;
if (execute_obj != Py_None)
transformId->execute = xmlsec_TransformExecuteMethod;
else
transformId->execute = NULL;
Py_XINCREF(initialize_obj);
Py_XINCREF(finalize_obj);
Py_XINCREF(readNode_obj);
Py_XINCREF(writeNode_obj);
Py_XINCREF(setKeyReq_obj);
Py_XINCREF(setKey_obj);
Py_XINCREF(verify_obj);
Py_XINCREF(getDataType_obj);
Py_XINCREF(pushBin_obj);
Py_XINCREF(popBin_obj);
Py_XINCREF(pushXml_obj);
Py_XINCREF(popXml_obj);
Py_XINCREF(execute_obj);
return (wrap_xmlSecTransformId(transformId));
}
| 32.073195 | 94 | 0.711775 |
23be7a2232692df72833440227f7ffc2401e407a | 935 | h | C | libffi-sys-rs/libffi/src/x86/internal.h | littledivy/libffi-rs | 9b5db858a337b96a013a98b5fc7be5351aae0bd8 | [
"Apache-2.0",
"MIT"
] | 51 | 2016-07-31T09:33:23.000Z | 2022-03-27T18:01:42.000Z | libffi-sys-rs/libffi/src/x86/internal.h | littledivy/libffi-rs | 9b5db858a337b96a013a98b5fc7be5351aae0bd8 | [
"Apache-2.0",
"MIT"
] | 41 | 2016-12-09T00:10:26.000Z | 2022-03-07T20:14:18.000Z | libffi-sys-rs/libffi/src/x86/internal.h | littledivy/libffi-rs | 9b5db858a337b96a013a98b5fc7be5351aae0bd8 | [
"Apache-2.0",
"MIT"
] | 31 | 2016-08-29T17:54:07.000Z | 2022-03-04T14:39:46.000Z | #define X86_RET_FLOAT 0
#define X86_RET_DOUBLE 1
#define X86_RET_LDOUBLE 2
#define X86_RET_SINT8 3
#define X86_RET_SINT16 4
#define X86_RET_UINT8 5
#define X86_RET_UINT16 6
#define X86_RET_INT64 7
#define X86_RET_INT32 8
#define X86_RET_VOID 9
#define X86_RET_STRUCTPOP 10
#define X86_RET_STRUCTARG 11
#define X86_RET_STRUCT_1B 12
#define X86_RET_STRUCT_2B 13
#define X86_RET_UNUSED14 14
#define X86_RET_UNUSED15 15
#define X86_RET_TYPE_MASK 15
#define X86_RET_POP_SHIFT 4
#define R_EAX 0
#define R_EDX 1
#define R_ECX 2
#ifdef __PCC__
# define HAVE_FASTCALL 0
#else
# define HAVE_FASTCALL 1
#endif
#if defined(FFI_EXEC_STATIC_TRAMP)
/*
* For the trampoline code table mapping, a mapping size of 4K (base page size)
* is chosen.
*/
#define X86_TRAMP_MAP_SHIFT 12
#define X86_TRAMP_MAP_SIZE (1 << X86_TRAMP_MAP_SHIFT)
#ifdef ENDBR_PRESENT
#define X86_TRAMP_SIZE 44
#else
#define X86_TRAMP_SIZE 40
#endif
#endif
| 21.25 | 79 | 0.794652 |
23c0346084cab99c3d8139cd12c4e85d8d03875d | 307 | h | C | atom_table.h | luksamuk/some-sorta-lisp | aed2207aad002b362a603c9bdd8f7f64aea688b4 | [
"BSD-2-Clause"
] | 4 | 2022-02-11T10:38:49.000Z | 2022-02-12T02:00:35.000Z | atom_table.h | luksamuk/some-sorta-lisp | aed2207aad002b362a603c9bdd8f7f64aea688b4 | [
"BSD-2-Clause"
] | null | null | null | atom_table.h | luksamuk/some-sorta-lisp | aed2207aad002b362a603c9bdd8f7f64aea688b4 | [
"BSD-2-Clause"
] | null | null | null | #ifndef LISP_ATOM_TABLE_H
#define LISP_ATOM_TABLE_H
#include "types.h"
void init_atom_table(atom_table_t *table_ptr);
void clear_atom_table(atom_table_t *table);
void print_atom_table(atom_table_t *table);
lisp_untptr_t find_atom(atom_table_t *table, const char *name);
#endif
| 25.583333 | 63 | 0.749186 |
23c3ff8d37d84aa503a1e8e136604c6ca33bf582 | 2,067 | c | C | c/19_remove_nth_node_from_end_of_list.c | lolosssss/leetcode | f857682ee519e2eefc0f409801497148e04f846e | [
"MIT"
] | 8 | 2015-11-06T07:47:27.000Z | 2021-04-25T07:48:06.000Z | c/19_remove_nth_node_from_end_of_list.c | lolosssss/leetcode | f857682ee519e2eefc0f409801497148e04f846e | [
"MIT"
] | null | null | null | c/19_remove_nth_node_from_end_of_list.c | lolosssss/leetcode | f857682ee519e2eefc0f409801497148e04f846e | [
"MIT"
] | 1 | 2017-11-11T04:11:18.000Z | 2017-11-11T04:11:18.000Z | /**
* Description : Remove Nth Node From End of List
* Given a linked list, remove the nth node from the end of list
* and return its head.
* Note : 1) Given n will always be valid.
* 2) Try to do this in one pass.
* Author : Evan Lau
* Date : 2016/03/02
*/
#include <stdio.h>
#include <stdlib.h>
struct ListNode {
int val;
struct ListNode *next;
};
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
struct ListNode* removeNthFromEnd(struct ListNode* head, int n)
{
struct ListNode *left = head;
struct ListNode *right = head;
struct ListNode *tmp = NULL;
for (int i = 0; i < n; i++)
{
right = right->next;
}
if (right == NULL)
{
tmp = head;
head = head->next;
free(tmp);
tmp = NULL;
return head;
}
while (right->next != NULL)
{
right = right->next;
left = left->next;
}
tmp = left->next;
left->next = tmp->next;
free(tmp);
tmp = NULL;
return head;
}
struct ListNode* createList(int *nums, int numsSize)
{
int cnt = 0;
struct ListNode *head = NULL;
struct ListNode *tmp = NULL;
struct ListNode *cur = NULL;
cur = (struct ListNode *)malloc(sizeof(struct ListNode));
cur->val = nums[cnt++];
head = cur;
tmp =cur;
numsSize--;
while (numsSize--)
{
cur = (struct ListNode *)malloc(sizeof(struct ListNode));
cur->val = nums[cnt++];
tmp->next = cur;
tmp = cur;
}
tmp->next = NULL;
return head;
}
void printList(struct ListNode *head)
{
struct ListNode *tmp = head;
while (tmp != NULL)
{
printf("%d->", tmp->val);
tmp = tmp->next;
}
printf("NULL\n");
}
int main(void)
{
struct ListNode *head = NULL;
int arr[1] = {1};
head = createList(arr, 1);
printList(head);
head = removeNthFromEnd(head, 1);
printList(head);
return 0;
}
| 18.455357 | 78 | 0.536526 |
23c42176d92a373cad118710abf7d683742ad676 | 2,503 | h | C | clients/cpp-restbed-server/generated/model/GithubOrganization.h | cliffano/jenkins-api-clients-generator | 522d02b3a130a29471df5ec1d3d22c822b3d0813 | [
"MIT"
] | null | null | null | clients/cpp-restbed-server/generated/model/GithubOrganization.h | cliffano/jenkins-api-clients-generator | 522d02b3a130a29471df5ec1d3d22c822b3d0813 | [
"MIT"
] | null | null | null | clients/cpp-restbed-server/generated/model/GithubOrganization.h | cliffano/jenkins-api-clients-generator | 522d02b3a130a29471df5ec1d3d22c822b3d0813 | [
"MIT"
] | null | null | null | /**
* Swaggy Jenkins
* Jenkins API clients generated from Swagger / Open API specification
*
* The version of the OpenAPI document: 1.1.2-pre.0
* Contact: blah@cliffano.com
*
* NOTE: This class is auto generated by OpenAPI-Generator 5.4.0.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/*
* GithubOrganization.h
*
*
*/
#ifndef GithubOrganization_H_
#define GithubOrganization_H_
#include <string>
#include "GithubOrganizationlinks.h"
#include <memory>
#include <vector>
#include <boost/property_tree/ptree.hpp>
namespace org {
namespace openapitools {
namespace server {
namespace model {
/// <summary>
///
/// </summary>
class GithubOrganization
{
public:
GithubOrganization() = default;
explicit GithubOrganization(boost::property_tree::ptree const& pt);
virtual ~GithubOrganization() = default;
std::string toJsonString(bool prettyJson = false);
void fromJsonString(std::string const& jsonString);
boost::property_tree::ptree toPropertyTree();
void fromPropertyTree(boost::property_tree::ptree const& pt);
/////////////////////////////////////////////
/// GithubOrganization members
/// <summary>
///
/// </summary>
std::string get_Class() const;
void set_Class(std::string value);
/// <summary>
///
/// </summary>
std::shared_ptr<GithubOrganizationlinks> get_Links() const;
void set_Links(std::shared_ptr<GithubOrganizationlinks> value);
/// <summary>
///
/// </summary>
bool isJenkinsOrganizationPipeline() const;
void setJenkinsOrganizationPipeline(bool value);
/// <summary>
///
/// </summary>
std::string getName() const;
void setName(std::string value);
protected:
//////////////////////////////////////
// Override these for customization //
//////////////////////////////////////
virtual std::string toJsonString_internal(bool prettyJson = false);
virtual void fromJsonString_internal(std::string const& jsonString);
virtual boost::property_tree::ptree toPropertyTree_internal();
virtual void fromPropertyTree_internal(boost::property_tree::ptree const& pt);
protected:
std::string m__class = "";
std::shared_ptr<GithubOrganizationlinks> m__links;
bool m_JenkinsOrganizationPipeline = false;
std::string m_Name = "";
};
std::vector<GithubOrganization> createGithubOrganizationVectorFromJsonString(const std::string& json);
}
}
}
}
#endif /* GithubOrganization_H_ */
| 24.300971 | 102 | 0.664003 |
23c657d723e532089455e683b32ffbc023a0e8c1 | 3,223 | h | C | old_revere/source/mainwindow.h | TroyDL/revere | 541bdc2bed9db212c1b74414b24733cf39675d08 | [
"BSD-3-Clause"
] | null | null | null | old_revere/source/mainwindow.h | TroyDL/revere | 541bdc2bed9db212c1b74414b24733cf39675d08 | [
"BSD-3-Clause"
] | null | null | null | old_revere/source/mainwindow.h | TroyDL/revere | 541bdc2bed9db212c1b74414b24733cf39675d08 | [
"BSD-3-Clause"
] | null | null | null | #ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "r_disco/r_agent.h"
#include "r_disco/r_devices.h"
#include "r_vss/r_stream_keeper.h"
#include "r_utils/r_nullable.h"
#include "r_pipeline/r_stream_info.h"
#include "rtspcredentials.h"
#include "friendlyname.h"
#include "retention.h"
#include "neworexisting.h"
#include "pleasewait.h"
#include "newfilename.h"
#include "motiondetection.h"
#include "ws.h"
#include <QMainWindow>
#include <QSystemTrayIcon>
#include <QListWidget>
#include <QTimer>
#include <QTabWidget>
#include <memory>
#include <string>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
struct assignment_state
{
std::string camera_id;
std::string ipv4;
r_utils::r_nullable<std::string> rtsp_username;
r_utils::r_nullable<std::string> rtsp_password;
std::string camera_friendly_name;
int64_t byte_rate {64000};
int continuous_retention_days {3};
int motion_retention_days {10};
int motion_percentage_estimate {5};
std::string file_name;
r_utils::r_nullable<int64_t> num_storage_file_blocks {0};
r_utils::r_nullable<int64_t> storage_file_block_size {0};
r_utils::r_nullable<r_disco::r_camera> camera;
std::map<std::string, r_pipeline::r_sdp_media> sdp_medias;
std::vector<uint8_t> key_frame;
bool do_motion_detection;
std::string motion_detection_file_path;
};
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void setVisible(bool visible) override;
void save_window_state();
void restore_window_state();
protected:
void closeEvent(QCloseEvent *event) override;
signals:
void fetch_camera_params_done();
private slots:
void on_camera_ui_update_timer();
void on_record_list_item_clicked(QListWidgetItem *item);
void on_record_button_clicked();
void on_remove_button_clicked();
void on_rtsp_credentials_ok_clicked();
void on_fetch_camera_params_done();
void on_friendly_name_ok_clicked();
void on_motion_detection_ok_clicked();
void on_new_storage_clicked();
void on_existing_storage_clicked();
void on_retention_ok_clicked();
void on_continuous_retention_days_changed(QString value);
void on_motion_retention_days_changed(QString value);
void on_percentage_estimate_changed(QString value);
void on_new_filename_ok_clicked();
private:
void _update_list_ui();
void _update_retention_ui();
void _assign_camera(const assignment_state& as);
Ui::MainWindow* _ui;
QAction* _restoreAction;
QAction* _quitAction;
QSystemTrayIcon* _trayIcon;
QMenu* _trayIconMenu;
std::string _topDir;
r_disco::r_agent _agent;
r_disco::r_devices _devices;
r_vss::r_stream_keeper _streamKeeper;
QTimer* _cameraUIUpdateTimer;
QListWidget* _discoveredListWidget;
QListWidget* _recordingListWidget;
RTSPCredentials* _rtspCredentials;
FriendlyName* _friendlyName;
Retention* _retention;
NewOrExisting* _newOrExisting;
PleaseWait* _pleaseWait;
NewFileName* _newFileName;
MotionDetection* _motionDetection;
r_utils::r_nullable<assignment_state> _assignmentState;
ws _ws;
};
#endif
| 26.203252 | 62 | 0.752715 |
23c701293f7a63c8b2cfafbfedef79087eccf46a | 2,630 | c | C | Firmware/Inverter_firmware/mqx/source/io/timer/timer_mcf5225.c | gingazov2010/Indemsys-Frequency_Inverter | 58ecce428a9cda0c2694979b16f98862bd3b0c65 | [
"MIT"
] | 30 | 2022-01-04T12:10:33.000Z | 2022-03-30T09:03:48.000Z | Firmware/Inverter_firmware/mqx/source/io/timer/timer_mcf5225.c | nelveroi/Frequency_Inverter | db9ab280ef096efce4c367bf71676b2da668031d | [
"MIT"
] | 1 | 2022-01-05T08:44:01.000Z | 2022-01-05T08:44:01.000Z | Firmware/Inverter_firmware/mqx/source/io/timer/timer_mcf5225.c | nelveroi/Frequency_Inverter | db9ab280ef096efce4c367bf71676b2da668031d | [
"MIT"
] | 9 | 2022-01-04T11:44:25.000Z | 2022-03-15T04:03:05.000Z | /**HEADER********************************************************************
*
* Copyright (c) 2011 Freescale Semiconductor;
* All Rights Reserved
*
***************************************************************************
*
* THIS SOFTWARE IS PROVIDED BY FREESCALE "AS IS" AND ANY EXPRESSED 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 FREESCALE OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************
*
* $FileName: timer_mcf5225.c$
* $Version : 3.8.1.0$
* $Date : May-11-2011$
*
* Comments:
*
* This file contains timer functions for use with a MCF5208.
*
*END************************************************************************/
#include <mqx.h>
#include <bsp.h>
#include "timer_pit.h"
const PIT_TIMER_INIT_STRUCT _bsp_timers[MCF5225_NUM_TIMERS] = {
{MCF5225_INT_PIT0, BSP_PIT0_INT_LEVEL, BSP_PIT0_INT_SUBLEVEL},
{MCF5225_INT_PIT1, BSP_PIT1_INT_LEVEL, BSP_PIT1_INT_SUBLEVEL}
};
/*FUNCTION*-------------------------------------------------------------------
*
* Function Name : _bsp_get_pit_base_address
* Returned Value : Address upon success, NULL upon failure
* Comments :
* This function returns the base register address of the corresponding PIT
*
*END*----------------------------------------------------------------------*/
pointer _bsp_get_pit_base_address (uint_8 timer)
{
volatile MCF5225_STRUCT _PTR_ reg_ptr = _PSP_GET_IPSBAR();
if (timer >= MCF5225_NUM_TIMERS) return NULL;
return (pointer)®_ptr->PIT[timer];
}
/*FUNCTION*-------------------------------------------------------------------
*
* Function Name : _bsp_get_pit_vector
* Returned Value : Vector number upon success, 0 upon failure
* Comments :
* This function returns desired interrupt vector number for specified PIT
*
*END*----------------------------------------------------------------------*/
uint_32 _bsp_get_pit_vector (uint_8 timer)
{
if (timer >= MCF5225_NUM_TIMERS) return 0;
return _bsp_timers[timer].INTERRUPT;
}
| 35.540541 | 78 | 0.58251 |
23c76742f0a53328b91288e7edb8415160b8d85a | 5,777 | h | C | 2018/07/07input.h | mark-inderhees/aoc | ac40055faef4875c8446b27f54977105b65e41ad | [
"MIT"
] | null | null | null | 2018/07/07input.h | mark-inderhees/aoc | ac40055faef4875c8446b27f54977105b65e41ad | [
"MIT"
] | null | null | null | 2018/07/07input.h | mark-inderhees/aoc | ac40055faef4875c8446b27f54977105b65e41ad | [
"MIT"
] | null | null | null | char* input[] = {
"Step S must be finished before step G can begin.",
"Step E must be finished before step T can begin.",
"Step G must be finished before step A can begin.",
"Step P must be finished before step Z can begin.",
"Step L must be finished before step Z can begin.",
"Step F must be finished before step H can begin.",
"Step D must be finished before step Y can begin.",
"Step J must be finished before step Y can begin.",
"Step N must be finished before step O can begin.",
"Step R must be finished before step Y can begin.",
"Step Y must be finished before step W can begin.",
"Step U must be finished before step T can begin.",
"Step H must be finished before step W can begin.",
"Step T must be finished before step Z can begin.",
"Step Q must be finished before step B can begin.",
"Step O must be finished before step Z can begin.",
"Step K must be finished before step W can begin.",
"Step M must be finished before step C can begin.",
"Step A must be finished before step Z can begin.",
"Step C must be finished before step X can begin.",
"Step I must be finished before step V can begin.",
"Step V must be finished before step W can begin.",
"Step W must be finished before step X can begin.",
"Step Z must be finished before step B can begin.",
"Step X must be finished before step B can begin.",
"Step D must be finished before step M can begin.",
"Step S must be finished before step Z can begin.",
"Step A must be finished before step B can begin.",
"Step V must be finished before step Z can begin.",
"Step Q must be finished before step Z can begin.",
"Step O must be finished before step W can begin.",
"Step S must be finished before step E can begin.",
"Step L must be finished before step B can begin.",
"Step P must be finished before step Y can begin.",
"Step K must be finished before step M can begin.",
"Step W must be finished before step Z can begin.",
"Step Y must be finished before step Q can begin.",
"Step J must be finished before step M can begin.",
"Step U must be finished before step H can begin.",
"Step Y must be finished before step U can begin.",
"Step D must be finished before step A can begin.",
"Step C must be finished before step V can begin.",
"Step G must be finished before step J can begin.",
"Step O must be finished before step C can begin.",
"Step P must be finished before step H can begin.",
"Step M must be finished before step B can begin.",
"Step T must be finished before step C can begin.",
"Step A must be finished before step W can begin.",
"Step C must be finished before step B can begin.",
"Step Q must be finished before step I can begin.",
"Step O must be finished before step A can begin.",
"Step N must be finished before step H can begin.",
"Step Q must be finished before step C can begin.",
"Step G must be finished before step W can begin.",
"Step V must be finished before step X can begin.",
"Step A must be finished before step V can begin.",
"Step S must be finished before step C can begin.",
"Step O must be finished before step M can begin.",
"Step E must be finished before step L can begin.",
"Step D must be finished before step V can begin.",
"Step P must be finished before step N can begin.",
"Step O must be finished before step I can begin.",
"Step P must be finished before step K can begin.",
"Step N must be finished before step A can begin.",
"Step A must be finished before step X can begin.",
"Step L must be finished before step A can begin.",
"Step L must be finished before step T can begin.",
"Step I must be finished before step X can begin.",
"Step N must be finished before step C can begin.",
"Step N must be finished before step W can begin.",
"Step Y must be finished before step M can begin.",
"Step R must be finished before step A can begin.",
"Step O must be finished before step X can begin.",
"Step G must be finished before step T can begin.",
"Step S must be finished before step P can begin.",
"Step E must be finished before step M can begin.",
"Step E must be finished before step A can begin.",
"Step E must be finished before step W can begin.",
"Step F must be finished before step D can begin.",
"Step U must be finished before step C can begin.",
"Step R must be finished before step Z can begin.",
"Step A must be finished before step C can begin.",
"Step F must be finished before step K can begin.",
"Step L must be finished before step V can begin.",
"Step F must be finished before step T can begin.",
"Step W must be finished before step B can begin.",
"Step Y must be finished before step A can begin.",
"Step D must be finished before step T can begin.",
"Step S must be finished before step V can begin.",
"Step Y must be finished before step O can begin.",
"Step K must be finished before step B can begin.",
"Step N must be finished before step V can begin.",
"Step Y must be finished before step I can begin.",
"Step Z must be finished before step X can begin.",
"Step E must be finished before step B can begin.",
"Step P must be finished before step O can begin.",
"Step D must be finished before step R can begin.",
"Step Q must be finished before step X can begin.",
"Step E must be finished before step K can begin.",
"Step J must be finished before step R can begin.",
"Step L must be finished before step N can begin."
}; | 56.087379 | 56 | 0.665917 |
23c811ab0ef542dc596456dff198f582064229ce | 4,916 | h | C | libraries/data/include/StlIndexValueIterator.h | Dream-maerD/ELL-master | 9554afa876cc9e8e87529df3f3d99220abc711d6 | [
"MIT"
] | 1 | 2018-11-08T06:19:31.000Z | 2018-11-08T06:19:31.000Z | libraries/data/include/StlIndexValueIterator.h | vishnoitanuj/ELL | 993d5370f0f7a274e8dfd8f43220c792be46f314 | [
"MIT"
] | null | null | null | libraries/data/include/StlIndexValueIterator.h | vishnoitanuj/ELL | 993d5370f0f7a274e8dfd8f43220c792be46f314 | [
"MIT"
] | 1 | 2020-12-10T17:49:07.000Z | 2020-12-10T17:49:07.000Z | ////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Project: Embedded Learning Library (ELL)
// File: StlIndexValueIterator.h (data)
// Authors: Chuck Jacobs, Ofer Dekel
//
////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "IndexValue.h"
// stl
#include <cstddef>
#include <type_traits>
#include <utility>
#include <vector>
namespace ell
{
namespace data
{
/// <summary> A read-only forward index-value iterator for an STL container </summary>
template <IterationPolicy policy, typename IteratorType>
class StlIndexValueIterator;
template <typename IteratorType>
class StlIndexValueIterator<IterationPolicy::skipZeros, IteratorType> : public IIndexValueIterator
{
public:
/// <summary> Constructs an instance of StlIndexValueIterator. </summary>
///
/// <param name="begin"> STL iterator pointing at beginning of range to iterate over. </param>
/// <param name="end"> STL iterator pointing at end of range to iterate over. </param>
/// <param name="size"> The number of iterates. </param>
StlIndexValueIterator(const IteratorType& begin, const IteratorType& end, size_t size);
/// <summary> Returns True if the iterator is currently pointing to a valid iterate. </summary>
///
/// <returns> True if the iterator is currently pointing to a valid iterate. </returns>
bool IsValid() const { return _current != _end && _index < _size; }
/// <summary> Proceeds to the Next iterate </summary>
void Next();
/// <summary> Returns The current index-value pair </summary>
///
/// <returns> The current index-value pair </returns>
IndexValue Get() const { return IndexValue{ _index, (double)*_current }; }
protected:
IteratorType _current;
IteratorType _end;
size_t _size;
size_t _index = 0;
void SkipZeros();
};
/// <summary> A read-only forward index-value iterator for an STL container </summary>
template <typename IteratorType>
class StlIndexValueIterator<IterationPolicy::all, IteratorType> : public IIndexValueIterator
{
public:
/// <summary> Constructs an instance of StlIndexValueIterator. </summary>
///
/// <param name="begin"> STL iterator pointing at beginning of range to iterate over. </param>
/// <param name="end"> STL iterator pointing at end of range to iterate over. </param>
/// <param name="size"> The number of iterates. </param>
StlIndexValueIterator(const IteratorType& begin, const IteratorType& end, size_t size);
/// <summary> Returns True if the iterator is currently pointing to a valid iterate. </summary>
///
/// <returns> True if the iterator is currently pointing to a valid iterate. </returns>
bool IsValid() const { return _index < _size; }
/// <summary> Proceeds to the Next iterate </summary>
void Next();
/// <summary> Returns The current index-value pair </summary>
///
/// <returns> The current index-value pair </returns>
IndexValue Get() const;
protected:
IteratorType _current;
IteratorType _end;
size_t _size;
size_t _index = 0;
};
/// <summary> Handy type alias for a StlDenseIterator over a std::vector </summary>
template <IterationPolicy policy, typename ElementType>
using VectorIndexValueIterator = StlIndexValueIterator<policy, typename std::vector<ElementType>::const_iterator>;
/// <summary> Helper function that creates a VectorIndexValueIterator. </summary>
///
/// <typeparam name="policy"> Whether the iterator should skip zeros or not. </typeparam>
/// <typeparam name="ElementType"> The element type. </typeparam>
/// <param name="container"> The vector. </param>
///
/// <returns> An IndexValue iterator. </returns>
template <IterationPolicy policy, typename ElementType>
VectorIndexValueIterator<policy, ElementType> MakeVectorIndexValueIterator(const std::vector<ElementType>& container);
/// <summary> Helper function that creates a VectorIndexValueIterator. </summary>
///
/// <typeparam name="policy"> Whether the iterator should skip zeros or not. </typeparam>
/// <typeparam name="ElementType"> The element type. </typeparam>
/// <param name="container"> The vector. </param>
/// <param name="size"> The number of iterates. </param>
///
/// <returns> An IndexValue iterator. </returns>
template <IterationPolicy policy, typename ElementType>
VectorIndexValueIterator<policy, ElementType> MakeVectorIndexValueIterator(const std::vector<ElementType>& container, size_t size);
}
}
#include "../tcc/StlIndexValueIterator.tcc"
| 40.628099 | 135 | 0.640765 |
23c8ad30b4ac16c4fe8eb58c08dccf96c83c77dd | 2,618 | h | C | examples/pxScene2d/external/WinSparkle/3rdparty/wxWidgets/samples/xrc/myframe.h | madanagopaltcomcast/pxCore | c4a3a40a190521c8b6383d126c87612eca5b3c42 | [
"Apache-2.0"
] | 471 | 2019-06-26T09:59:09.000Z | 2022-03-30T04:59:42.000Z | examples/pxScene2d/external/WinSparkle/3rdparty/wxWidgets/samples/xrc/myframe.h | madanagopaltcomcast/pxCore | c4a3a40a190521c8b6383d126c87612eca5b3c42 | [
"Apache-2.0"
] | 1,432 | 2017-06-21T04:08:48.000Z | 2020-08-25T16:21:15.000Z | examples/pxScene2d/external/WinSparkle/3rdparty/wxWidgets/samples/xrc/myframe.h | madanagopaltcomcast/pxCore | c4a3a40a190521c8b6383d126c87612eca5b3c42 | [
"Apache-2.0"
] | 317 | 2017-06-20T19:57:17.000Z | 2020-09-16T10:28:30.000Z | //-----------------------------------------------------------------------------
// Name: myframe.h
// Purpose: XML resources sample: A derived frame, called MyFrame
// Author: Robert O'Connor (rob@medicalmnemonics.com), Vaclav Slavik
// Copyright: (c) Robert O'Connor and Vaclav Slavik
// Licence: wxWindows licence
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Begin single inclusion of this .h file condition
//-----------------------------------------------------------------------------
#ifndef _MYFRAME_H_
#define _MYFRAME_H_
//-----------------------------------------------------------------------------
// Headers
//-----------------------------------------------------------------------------
#include "wx/frame.h"
//-----------------------------------------------------------------------------
// Class definition: MyFrame
//-----------------------------------------------------------------------------
// Define a new frame type: this is going to be our main frame
class MyFrame : public wxFrame
{
public:
// Constructor.
MyFrame( wxWindow* parent=(wxWindow *)NULL);
private:
// Event handlers (these functions should _not_ be virtual)
void OnUnloadResourceMenuCommand(wxCommandEvent& event);
void OnReloadResourceMenuCommand(wxCommandEvent& event);
void OnExitToolOrMenuCommand(wxCommandEvent& event);
void OnAboutToolOrMenuCommand(wxCommandEvent& event);
void OnNonDerivedDialogToolOrMenuCommand(wxCommandEvent& event);
void OnDerivedDialogToolOrMenuCommand(wxCommandEvent& event);
void OnControlsToolOrMenuCommand(wxCommandEvent& event);
void OnUncenteredToolOrMenuCommand(wxCommandEvent& event);
void OnObjRefToolOrMenuCommand(wxCommandEvent& event);
void OnCustomClassToolOrMenuCommand(wxCommandEvent& event);
void OnPlatformPropertyToolOrMenuCommand(wxCommandEvent& event);
void OnArtProviderToolOrMenuCommand(wxCommandEvent& event);
void OnVariableExpansionToolOrMenuCommand(wxCommandEvent& event);
void OnVariants(wxCommandEvent& event);
void OnRecursiveLoad(wxCommandEvent& event);
void OnAnimationCtrlPlay(wxCommandEvent& event);
// Any class wishing to process wxWidgets events must use this macro
wxDECLARE_EVENT_TABLE();
};
//-----------------------------------------------------------------------------
// End single inclusion of this .h file condition
//-----------------------------------------------------------------------------
#endif // _MYFRAME_H_
| 40.276923 | 79 | 0.531704 |
23ca07991732ed9221a5addc569576be1d8f93f2 | 6,166 | c | C | bsp/stm32/stm32l051-zingto-timekeeper/applications/main.c | sunchenxiao/rt-thread | 69d901ee80778980b8bd212d4619767f811bb961 | [
"Apache-2.0"
] | 2 | 2021-04-10T16:44:12.000Z | 2021-07-27T15:33:38.000Z | bsp/stm32/stm32l051-zingto-timekeeper/applications/main.c | sunchenxiao/rt-thread | 69d901ee80778980b8bd212d4619767f811bb961 | [
"Apache-2.0"
] | 1 | 2020-11-08T00:08:37.000Z | 2020-11-08T00:08:37.000Z | bsp/stm32/stm32l051-zingto-timekeeper/applications/main.c | sunchenxiao/rt-thread | 69d901ee80778980b8bd212d4619767f811bb961 | [
"Apache-2.0"
] | 2 | 2020-04-08T08:05:32.000Z | 2020-07-21T07:24:32.000Z | /*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018-11-06 SummerGift change to new framework
*/
#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>
#define LOG_TAG "main"
#include <drv_log.h>
/* defined the LED pin: PA5 */
#define LED0_PIN GET_PIN(B, 4)
#define LED1_PIN GET_PIN(B, 5)
#define PWRSEL_PIN GET_PIN(B, 6)
#define TIMESET_TIMEOUT (15)
static rt_sem_t semPVD = RT_NULL;
void prepare_enter_LPM4(void)
{
}
/**
* @brief Configures system clock after wake-up from STOP: enable HSI, PLL
* and select PLL as system clock source.
* @param None
* @retval None
*/
static void SystemClockConfig_STOP(void)
{
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_OscInitTypeDef RCC_OscInitStruct;
/* Enable Power Control clock */
__HAL_RCC_PWR_CLK_ENABLE();
/* The voltage scaling allows optimizing the power consumption when the device is
clocked below the maximum system frequency, to update the voltage scaling value
regarding system frequency refer to product datasheet. */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/* Get the Oscillators configuration according to the internal RCC registers */
HAL_RCC_GetOscConfig(&RCC_OscInitStruct);
/* After wake-up from STOP reconfigure the system clock: Enable HSI and PLL */
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSEState = RCC_HSE_OFF;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB busses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if(HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
{
Error_Handler();
}
}
void PVD_IRQHandler(void)
{
rt_interrupt_enter();
HAL_PWR_PVD_IRQHandler();
rt_interrupt_leave();
}
static rt_bool_t PVDOflag = RT_FALSE;
void HAL_PWR_PVDCallback(void)
{
if (__HAL_PWR_GET_FLAG(PWR_FLAG_PVDO)) {
PVDOflag = RT_TRUE;
if (semPVD) rt_sem_release(semPVD);
}
else {
PVDOflag = RT_FALSE;
}
}
void time_keeper(void *param)
{
rt_tick_t reftick;
char dbuf[32];
rt_device_t port = RT_NULL;
port = rt_device_find("uart2");
RT_ASSERT(port != RT_NULL);
rt_device_open(port, RT_DEVICE_OFLAG_OPEN | RT_DEVICE_OFLAG_RDWR);
while (RT_TRUE) {
reftick = rt_tick_get();
do {
rt_pin_write(LED0_PIN, PIN_HIGH);
rt_thread_mdelay(2);
rt_pin_write(LED0_PIN, PIN_LOW);
rt_thread_mdelay(200);
}while (rt_tick_get() - reftick < RT_TICK_PER_SECOND * TIMESET_TIMEOUT);
rt_pin_write(LED1_PIN, PIN_HIGH);
time_t now;
/* output current time */
now = time(RT_NULL);
struct tm *date = localtime(&now);
int year = date->tm_year + 1900;
int month = date->tm_mon + 1;
rt_memset(dbuf, 0x00, sizeof(dbuf));
rt_sprintf(dbuf, "date -s \"%d-%02d-%02d %02d:%02d:%02d\"\n", year, month, date->tm_mday,
date->tm_hour, date->tm_min, date->tm_sec);
rt_kprintf("%s", dbuf);
/* send command to Hi3521D */
rt_device_write(port, 0, dbuf, rt_strlen(dbuf));
rt_thread_mdelay(200);
rt_pin_write(LED1_PIN, PIN_LOW);
}
/* never run here */
}
int main(void)
{
rt_thread_t tp = RT_NULL;
/* set LED0 pin mode to output */
rt_pin_mode(LED0_PIN, PIN_MODE_OUTPUT);
rt_pin_mode(LED1_PIN, PIN_MODE_OUTPUT);
rt_pin_mode(PWRSEL_PIN, PIN_MODE_OUTPUT);
/* disable PMOS to avoid backup bat power the entire system */
rt_pin_write(PWRSEL_PIN, PIN_HIGH);
/* show the system reset */
rt_pin_write(LED0_PIN, PIN_HIGH);
rt_pin_write(LED1_PIN, PIN_HIGH);
rt_thread_delay(RT_TICK_PER_SECOND/10);
/* show the system reset */
rt_pin_write(LED0_PIN, PIN_LOW);
rt_pin_write(LED1_PIN, PIN_LOW);
semPVD = rt_sem_create("semPVD", 0, RT_IPC_FLAG_FIFO);
RT_ASSERT(semPVD != RT_NULL);
tp = rt_thread_create("tidKPR", time_keeper, RT_NULL, 512, 10, 10);
RT_ASSERT(tp != RT_NULL);
rt_thread_startup(tp);
if (__HAL_PWR_GET_FLAG(PWR_FLAG_PVDO)) {
LOG_I("Power up, in Battery mode");
rt_sem_release(semPVD);
}
else {
LOG_I("Power up, in Normal mode");
}
rt_kprintf("RCC->CSR:\t0x%08x\n", RCC->CSR);
rt_kprintf("FLASH->OPTR:\t0x%08x\n", FLASH->OPTR);
rt_sem_take(semPVD, RT_WAITING_FOREVER);
LOG_I("Detect Power Off, System enter STOP mode in moment");
/* config the uart GPIO to prevent leak current */
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9 | GPIO_PIN_10);
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_2 | GPIO_PIN_3);
/* deinit the GPIO for LEDs */
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_4 | GPIO_PIN_5);
/* Enter Stop Mode */
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
/* Configures system clock after wake-up from STOP: enable HSI, PLL and select
PLL as system clock source (HSI and PLL are disabled automatically in STOP mode) */
SystemClockConfig_STOP();
if (PVDOflag)
LOG_I("Detect Power On, System reset, PVDOflag = TRUE");
else
LOG_I("Detect Power On, System reset, PVDOflag = FALSE");
rt_hw_cpu_reset();
return RT_EOK;
}
| 28.67907 | 103 | 0.651151 |
23caa91633b08c261283e7345052a41ec5c4d667 | 6,933 | h | C | LTSDK/sdk/ltbasetypes.h | crskycode/msLTBImporter | be8a04c5365746c46a1d7804909e04a741d86b44 | [
"MIT"
] | 3 | 2021-03-02T15:55:01.000Z | 2021-10-21T07:11:17.000Z | LTSDK/sdk/ltbasetypes.h | crskycode/msLTBImporter | be8a04c5365746c46a1d7804909e04a741d86b44 | [
"MIT"
] | 1 | 2021-09-27T02:38:49.000Z | 2021-11-06T16:09:21.000Z | LTSDK/sdk/ltbasetypes.h | crskycode/msLTBImporter | be8a04c5365746c46a1d7804909e04a741d86b44 | [
"MIT"
] | 1 | 2021-04-26T13:22:51.000Z | 2021-04-26T13:22:51.000Z | #ifndef __LTBASETYPES_H__
#define __LTBASETYPES_H__
#ifndef __MATH_H__
#include <math.h>
#define __MATH_H__
#endif
#ifndef __LTINTEGER_H__
#include "ltinteger.h"
#endif
// Use the new sound system in 3.1
#ifndef USE_ABSTRACT_SOUND_INTERFACES
#define USE_ABSTRACT_SOUND_INTERFACES 1
#endif
/*!
Base types.
*/
typedef unsigned int LTBOOL;
typedef float LTFLOAT;
typedef uint32 LTRESULT;
typedef int BOOL;
typedef unsigned long DWORD;
/*!
Base type values (enumeration emulation).
LTBOOL.
*/
#define LTFALSE 0
#define LTTRUE 1
/*!
LTRESULT (defined in ltcodes.h).
*/
/*!
Forward declaration of LTObject.
*/
class LTObject;
/*!
Handles.
Object handle definition.
*/
typedef LTObject* HOBJECT;
typedef LTObject* HLOCALOBJ;
#define INVALID_HOBJECT ((LTObject *)0)
/*!
Model handles.
*/
typedef uint32 HMODELPIECE;
#define INVALID_MODEL_PIECE ((HMODELPIECE)-1)
typedef uint32 HMODELSOCKET;
#define INVALID_MODEL_SOCKET ((HMODELSOCKET)-1)
typedef uint32 HMODELNODE;
#define INVALID_MODEL_NODE ((HMODELNODE)-1)
typedef uint32 HMODELWEIGHTSET;
#define INVALID_MODEL_WEIGHTSET ((HMODELWEIGHTSET)-1)
typedef uint32 HMODELANIM;
#define INVALID_MODEL_ANIM ((HMODELANIM)-1)
/*!
Effect Shader handles.
*/
typedef uint32 HEFFECTPOOL;
#define INVALID_EFFECT_POOL ((HEFFECTPOOL)-1)
#define NO_EFFECT_POOL INVALID_EFFECT_POOL
/*!
Render Target handles
*/
typedef uint32 HRENDERTARGET;
#define INVALID_RENDER_TARGET ((HRENDERTARGET)-1)
#define DEFAULT_RENDER_TARGET 0
/*!
Poly reference.
*/
struct HPOLY
{
HPOLY(uint32 nWorldIndex, uint32 nPolyIndex) : m_nWorldIndex(nWorldIndex), m_nPolyIndex(nPolyIndex) {}
HPOLY() : m_nWorldIndex(0xFFFFFFFF), m_nPolyIndex(0xFFFFFFFF) {}
HPOLY &operator=(const HPOLY &hOther)
{
m_nWorldIndex = hOther.m_nWorldIndex;
m_nPolyIndex = hOther.m_nPolyIndex;
return *this;
}
bool operator==(const HPOLY &hOther)
{
return (m_nWorldIndex == hOther.m_nWorldIndex) && (m_nPolyIndex == hOther.m_nPolyIndex);
}
bool operator!=(const HPOLY &hOther)
{
return (m_nWorldIndex != hOther.m_nWorldIndex) || (m_nPolyIndex != hOther.m_nPolyIndex);
}
uint32 m_nPolyIndex, m_nWorldIndex;
};
#define INVALID_HPOLY HPOLY(0xFFFFFFFF, 0xFFFFFFFF)
/*!
Color types (different byte ordering for cross platform development).
*/
struct LTRGB { uint8 b, g, r, a; };
/*!
Globally unique identifier.
*/
struct _LTGUID // the windows-ish version
{
uint32 a;
uint16 b;
uint16 c;
uint8 d[8];
};
struct _LTGUID_64
{
uint64 a;
uint64 b;
};
union LTGUID
{
_LTGUID guid;
_LTGUID_64 guid_64; // use this for fast & easy compares
inline
bool operator<(const LTGUID& _X) const
{ return (guid_64.a == _X.guid_64.a) ? (guid_64.b < _X.guid_64.b) : (guid_64.a < _X.guid_64.a); }
inline
bool operator==(const LTGUID& _X) const
{ return (guid_64.a == _X.guid_64.a) && (guid_64.b == _X.guid_64.b); }
};
// macros for defining LTGUIDs a la windows...
// Define INITLTGUID where the LTGUIDs are defined;
// Undefine INITLTGUID where LTGUIDs are declared but not defined.
#ifndef INITLTGUID
#define DEFINE_LTGUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
extern "C" const LTGUID name
#else
#define DEFINE_LTGUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
extern "C" const LTGUID name \
= { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
#endif // INITLTGUID
/*!
More complicated types.
*/
#ifndef __LTVECTOR_H__
#include "ltvector.h"
#endif
#ifndef __LTROTATION_H__
#include "ltrotation.h"
#endif
#ifndef __LTPLANE_H__
#include "ltplane.h"
#endif
#ifndef __LTRECT_H__
#include "ltrect.h"
#endif
#ifndef __LTMATRIX_H__
#include "ltmatrix.h"
#endif
#ifndef __LTLINK_H__
#include "ltlink.h"
#endif
#ifndef __LTRENDERERSTATS_H__
#include "ltrendererstats.h"
#endif
/*!
Structures.
*/
struct PGColor
{
//! RGB 0-255.
float x, y, z;
//! Alpha 0-255.
float a;
};
struct LTFloatPt
{
float x, y;
};
struct LTIntPt
{
LTIntPt(int a = 0, int b = 0) : x(a), y(b) {}
int x, y;
};
struct LTWarpPt
{
float source_x, source_y;
float dest_x, dest_y;
};
struct ArgList
{
char **argv;
int argc;
};
/*!
This class use a position and quaternion to represent a coordinate frame.
The ILTTransform interface can be used to work with these objects.
*/
class LTransform
{
public:
LTVector m_Pos;
LTRotation m_Rot;
LTVector m_Scale;
};
/*!
This is oriented bounding box used for models.
*/
// For backward compatability
struct ModelOBB_Depricated {
LTVector m_Pos; // local pos or offset.
LTVector m_Size; // box size
LTVector m_Basis[3]; // orientation. XYZ
uint32 m_iNode; // which model node do I belong to?
};
struct ModelOBB {
LTVector m_Pos; // local pos or offset.
LTVector m_Size; // box size
LTVector m_Basis[3]; // orientation. XYZ
uint32 m_iNode; // which model node do I belong to?
float m_Radius; // "Best fit" sphere radius of the OBB.
// Used to speed up "early out" OBB checks
};
/*!
Sky definition.
*/
struct SkyDef
{
LTVector m_Min, m_Max;
LTVector m_ViewMin, m_ViewMax;
};
/*!
Node Control Data
This structure holds all the data that is passed into the node contol callback
*/
struct NodeControlData
{
//this matrix is the transform of the parent of this node
const LTMatrix* m_pParentTransform;
//this matrix specifies the transform from the parent to the child in binding
//position space
const LTMatrix* m_pFromParentTransform;
//this matrix holds the current transform of the child. This includes
//the animation, other previous node controllers, and this is the matrix
//that should be modified and placed in global space
LTMatrix* m_pNodeTransform;
//the handle of the model
HOBJECT m_hModel;
//the node that is being modified
HMODELNODE m_hNode;
};
typedef void (*NodeControlFn)(const NodeControlData&, void* pUserData);
typedef void (*ConsoleProgramFn)(int argc, char **argv);
/*!
This is used to distinguish between flag types.
*/
enum ObjFlagType
{
//! FLAG_ #defines
OFT_Flags = 0,
//! FLAG2_ #defines
OFT_Flags2,
//! User flags
OFT_User,
//! Client flags (Not available on server objects)
OFT_Client
};
/*!
This is used to distinguish between different object resources
*/
enum EObjectResource
{
//! The main file for the object for sprites this is the sprite, for models the model
eObjectResource_ObjectFile,
//! The texture for this object, valid indices are 0...MAX_TEXTURES
eObjectResource_Texture,
//! The render styles associated with the object 0...MAX_RENDERSTYLES
eObjectResource_RenderStyle,
//! The extra childmodels associated with the object 0...MAX_CHILDMODELS
eObjectResource_ChildModel,
};
#endif //! __LTBASETYPES_H__
| 19.365922 | 104 | 0.695226 |
23cad8045a75bf1645d6912b5132a3d41bd46b50 | 27,673 | c | C | src/save.c | Bam4d/BrowserHack | 1a7de3a7db8ff88aaeb4a8277739586251db04e5 | [
"CC-BY-3.0"
] | 318 | 2015-04-08T17:21:29.000Z | 2022-03-24T21:16:43.000Z | src/save.c | schwabse/BrowserHack | 1a7de3a7db8ff88aaeb4a8277739586251db04e5 | [
"CC-BY-3.0"
] | 21 | 2015-04-12T18:27:16.000Z | 2021-11-15T07:02:27.000Z | src/save.c | schwabse/BrowserHack | 1a7de3a7db8ff88aaeb4a8277739586251db04e5 | [
"CC-BY-3.0"
] | 51 | 2015-04-08T17:59:07.000Z | 2022-02-24T10:10:30.000Z | /* SCCS Id: @(#)save.c 3.4 2003/11/14 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "lev.h"
#include "quest.h"
#ifdef WEB_GRAPHICS
#include <emscripten.h>
#endif
#ifndef NO_SIGNAL
#include <signal.h>
#endif
#if !defined(LSC) && !defined(O_WRONLY) && !defined(AZTEC_C)
#include <fcntl.h>
#endif
#ifdef MFLOPPY
long bytes_counted;
static int count_only;
#endif
#ifdef MICRO
int dotcnt, dotrow; /* also used in restore */
#endif
#ifdef ZEROCOMP
STATIC_DCL void FDECL(bputc, (int));
#endif
STATIC_DCL void FDECL(savelevchn, (int,int));
STATIC_DCL void FDECL(savedamage, (int,int));
STATIC_DCL void FDECL(saveobjchn, (int,struct obj *,int));
STATIC_DCL void FDECL(savemonchn, (int,struct monst *,int));
STATIC_DCL void FDECL(savetrapchn, (int,struct trap *,int));
STATIC_DCL void FDECL(savegamestate, (int,int));
#ifdef MFLOPPY
STATIC_DCL void FDECL(savelev0, (int,XCHAR_P,int));
STATIC_DCL boolean NDECL(swapout_oldest);
STATIC_DCL void FDECL(copyfile, (char *,char *));
#endif /* MFLOPPY */
#ifdef GCC_WARN
static long nulls[10];
#else
#define nulls nul
#endif
#if defined(UNIX) || defined(VMS) || defined(__EMX__) || defined(WIN32)
#define HUP if (!program_state.done_hup)
#else
#define HUP
#endif
/* need to preserve these during save to avoid accessing freed memory */
static unsigned ustuck_id = 0, usteed_id = 0;
int
dosave()
{
clear_nhwindow(WIN_MESSAGE);
if(yn("Really save?") == 'n') {
clear_nhwindow(WIN_MESSAGE);
if(multi > 0) nomul(0);
} else {
clear_nhwindow(WIN_MESSAGE);
pline("Saving...");
#if defined(UNIX) || defined(VMS) || defined(__EMX__)
program_state.done_hup = 0;
#endif
if(dosave0()) {
program_state.something_worth_saving = 0;
u.uhp = -1; /* universal game's over indicator */
/* make sure they see the Saving message */
display_nhwindow(WIN_MESSAGE, TRUE);
exit_nhwindows("Be seeing you...");
terminate(EXIT_SUCCESS);
} else (void)doredraw();
}
return 0;
}
#if defined(UNIX) || defined(VMS) || defined (__EMX__) || defined(WIN32)
/*ARGSUSED*/
void
hangup(sig_unused) /* called as signal() handler, so sent at least one arg */
int sig_unused;
{
# ifdef NOSAVEONHANGUP
(void) signal(SIGINT, SIG_IGN);
clearlocks();
# ifndef VMS
terminate(EXIT_FAILURE);
# endif
# else /* SAVEONHANGUP */
if (!program_state.done_hup++) {
if (program_state.something_worth_saving)
(void) dosave0();
# ifdef VMS
/* don't call exit when already within an exit handler;
that would cancel any other pending user-mode handlers */
if (!program_state.exiting)
# endif
{
clearlocks();
terminate(EXIT_FAILURE);
}
}
# endif
return;
}
#endif
/* returns 1 if save successful */
int
dosave0()
{
const char *fq_save;
register int fd, ofd;
xchar ltmp;
d_level uz_save;
char whynot[BUFSZ];
if (!SAVEF[0])
return 0;
fq_save = fqname(SAVEF, SAVEPREFIX, 1); /* level files take 0 */
#if defined(UNIX) || defined(VMS)
(void) signal(SIGHUP, SIG_IGN);
#endif
#ifndef NO_SIGNAL
(void) signal(SIGINT, SIG_IGN);
#endif
#if defined(MICRO) && defined(MFLOPPY)
if (!saveDiskPrompt(0)) return 0;
#endif
HUP if (iflags.window_inited) {
uncompress(fq_save);
fd = open_savefile();
if (fd > 0) {
(void) close(fd);
clear_nhwindow(WIN_MESSAGE);
There("seems to be an old save file.");
if (yn("Overwrite the old file?") == 'n') {
compress(fq_save);
return 0;
}
}
}
HUP mark_synch(); /* flush any buffered screen output */
fd = create_savefile();
if(fd < 0) {
HUP pline("Cannot open save file.");
(void) delete_savefile(); /* ab@unido */
return(0);
}
vision_recalc(2); /* shut down vision to prevent problems
in the event of an impossible() call */
/* undo date-dependent luck adjustments made at startup time */
if(flags.moonphase == FULL_MOON) /* ut-sally!fletcher */
change_luck(-1); /* and unido!ab */
if(flags.friday13)
change_luck(1);
if(iflags.window_inited)
HUP clear_nhwindow(WIN_MESSAGE);
#ifdef MICRO
dotcnt = 0;
dotrow = 2;
curs(WIN_MAP, 1, 1);
if (strncmpi("X11", windowprocs.name, 3))
putstr(WIN_MAP, 0, "Saving:");
#endif
#ifdef MFLOPPY
/* make sure there is enough disk space */
if (iflags.checkspace) {
long fds, needed;
savelev(fd, ledger_no(&u.uz), COUNT_SAVE);
savegamestate(fd, COUNT_SAVE);
needed = bytes_counted;
for (ltmp = 1; ltmp <= maxledgerno(); ltmp++)
if (ltmp != ledger_no(&u.uz) && level_info[ltmp].where)
needed += level_info[ltmp].size + (sizeof ltmp);
fds = freediskspace(fq_save);
if (needed > fds) {
HUP {
There("is insufficient space on SAVE disk.");
pline("Require %ld bytes but only have %ld.", needed, fds);
}
flushout();
(void) close(fd);
(void) delete_savefile();
return 0;
}
co_false();
}
#endif /* MFLOPPY */
store_version(fd);
#ifdef STORE_PLNAME_IN_FILE
bwrite(fd, (genericptr_t) plname, PL_NSIZ);
#endif
ustuck_id = (u.ustuck ? u.ustuck->m_id : 0);
#ifdef STEED
usteed_id = (u.usteed ? u.usteed->m_id : 0);
#endif
savelev(fd, ledger_no(&u.uz), WRITE_SAVE | FREE_SAVE);
savegamestate(fd, WRITE_SAVE | FREE_SAVE);
/* While copying level files around, zero out u.uz to keep
* parts of the restore code from completely initializing all
* in-core data structures, since all we're doing is copying.
* This also avoids at least one nasty core dump.
*/
uz_save = u.uz;
u.uz.dnum = u.uz.dlevel = 0;
/* these pointers are no longer valid, and at least u.usteed
* may mislead place_monster() on other levels
*/
u.ustuck = (struct monst *)0;
#ifdef STEED
u.usteed = (struct monst *)0;
#endif
for(ltmp = (xchar)1; ltmp <= maxledgerno(); ltmp++) {
if (ltmp == ledger_no(&uz_save)) continue;
if (!(level_info[ltmp].flags & LFILE_EXISTS)) continue;
#ifdef MICRO
curs(WIN_MAP, 1 + dotcnt++, dotrow);
if (dotcnt >= (COLNO - 1)) {
dotrow++;
dotcnt = 0;
}
if (strncmpi("X11", windowprocs.name, 3)){
putstr(WIN_MAP, 0, ".");
}
mark_synch();
#endif
ofd = open_levelfile(ltmp, whynot);
if (ofd < 0) {
HUP pline("%s", whynot);
(void) close(fd);
(void) delete_savefile();
HUP killer = whynot;
HUP done(TRICKED);
return(0);
}
minit(); /* ZEROCOMP */
getlev(ofd, hackpid, ltmp, FALSE);
(void) close(ofd);
bwrite(fd, (genericptr_t) <mp, sizeof ltmp); /* level number*/
savelev(fd, ltmp, WRITE_SAVE | FREE_SAVE); /* actual level*/
delete_levelfile(ltmp);
}
bclose(fd);
u.uz = uz_save;
/* get rid of current level --jgm */
delete_levelfile(ledger_no(&u.uz));
delete_levelfile(0);
compress(fq_save);
#ifdef WEB_GRAPHICS
/* need manual sync for emscripten */
EM_ASM( FS.syncfs(function (err) { if(err) console.log('Cannot sync FS, savegame may not work!'); }););
#endif
return(1);
}
STATIC_OVL void
savegamestate(fd, mode)
register int fd, mode;
{
int uid;
#ifdef MFLOPPY
count_only = (mode & COUNT_SAVE);
#endif
uid = getuid();
bwrite(fd, (genericptr_t) &uid, sizeof uid);
bwrite(fd, (genericptr_t) &flags, sizeof(struct flag));
bwrite(fd, (genericptr_t) &u, sizeof(struct you));
/* must come before migrating_objs and migrating_mons are freed */
save_timers(fd, mode, RANGE_GLOBAL);
save_light_sources(fd, mode, RANGE_GLOBAL);
saveobjchn(fd, invent, mode);
saveobjchn(fd, migrating_objs, mode);
savemonchn(fd, migrating_mons, mode);
if (release_data(mode)) {
invent = 0;
migrating_objs = 0;
migrating_mons = 0;
}
bwrite(fd, (genericptr_t) mvitals, sizeof(mvitals));
save_dungeon(fd, (boolean)!!perform_bwrite(mode),
(boolean)!!release_data(mode));
savelevchn(fd, mode);
bwrite(fd, (genericptr_t) &moves, sizeof moves);
bwrite(fd, (genericptr_t) &monstermoves, sizeof monstermoves);
bwrite(fd, (genericptr_t) &quest_status, sizeof(struct q_score));
bwrite(fd, (genericptr_t) spl_book,
sizeof(struct spell) * (MAXSPELL + 1));
save_artifacts(fd);
save_oracles(fd, mode);
if(ustuck_id)
bwrite(fd, (genericptr_t) &ustuck_id, sizeof ustuck_id);
#ifdef STEED
if(usteed_id)
bwrite(fd, (genericptr_t) &usteed_id, sizeof usteed_id);
#endif
bwrite(fd, (genericptr_t) pl_character, sizeof pl_character);
bwrite(fd, (genericptr_t) pl_fruit, sizeof pl_fruit);
bwrite(fd, (genericptr_t) ¤t_fruit, sizeof current_fruit);
savefruitchn(fd, mode);
savenames(fd, mode);
save_waterlevel(fd, mode);
bflush(fd);
}
#ifdef INSURANCE
void
savestateinlock()
{
int fd, hpid;
static boolean havestate = TRUE;
char whynot[BUFSZ];
/* When checkpointing is on, the full state needs to be written
* on each checkpoint. When checkpointing is off, only the pid
* needs to be in the level.0 file, so it does not need to be
* constantly rewritten. When checkpointing is turned off during
* a game, however, the file has to be rewritten once to truncate
* it and avoid restoring from outdated information.
*
* Restricting havestate to this routine means that an additional
* noop pid rewriting will take place on the first "checkpoint" after
* the game is started or restored, if checkpointing is off.
*/
if (flags.ins_chkpt || havestate) {
/* save the rest of the current game state in the lock file,
* following the original int pid, the current level number,
* and the current savefile name, which should not be subject
* to any internal compression schemes since they must be
* readable by an external utility
*/
fd = open_levelfile(0, whynot);
if (fd < 0) {
pline("%s", whynot);
pline("Probably someone removed it.");
killer = whynot;
done(TRICKED);
return;
}
(void) read(fd, (genericptr_t) &hpid, sizeof(hpid));
if (hackpid != hpid) {
Sprintf(whynot,
"Level #0 pid (%d) doesn't match ours (%d)!",
hpid, hackpid);
pline("%s", whynot);
killer = whynot;
done(TRICKED);
}
(void) close(fd);
fd = create_levelfile(0, whynot);
if (fd < 0) {
pline("%s", whynot);
killer = whynot;
done(TRICKED);
return;
}
(void) write(fd, (genericptr_t) &hackpid, sizeof(hackpid));
if (flags.ins_chkpt) {
int currlev = ledger_no(&u.uz);
(void) write(fd, (genericptr_t) &currlev, sizeof(currlev));
save_savefile_name(fd);
store_version(fd);
#ifdef STORE_PLNAME_IN_FILE
bwrite(fd, (genericptr_t) plname, PL_NSIZ);
#endif
ustuck_id = (u.ustuck ? u.ustuck->m_id : 0);
#ifdef STEED
usteed_id = (u.usteed ? u.usteed->m_id : 0);
#endif
savegamestate(fd, WRITE_SAVE);
}
bclose(fd);
}
havestate = flags.ins_chkpt;
}
#endif
#ifdef MFLOPPY
boolean
savelev(fd, lev, mode)
int fd;
xchar lev;
int mode;
{
if (mode & COUNT_SAVE) {
bytes_counted = 0;
savelev0(fd, lev, COUNT_SAVE);
/* probably bytes_counted will be filled in again by an
* immediately following WRITE_SAVE anyway, but we'll
* leave it out of checkspace just in case */
if (iflags.checkspace) {
while (bytes_counted > freediskspace(levels))
if (!swapout_oldest())
return FALSE;
}
}
if (mode & (WRITE_SAVE | FREE_SAVE)) {
bytes_counted = 0;
savelev0(fd, lev, mode);
}
if (mode != FREE_SAVE) {
level_info[lev].where = ACTIVE;
level_info[lev].time = moves;
level_info[lev].size = bytes_counted;
}
return TRUE;
}
STATIC_OVL void
savelev0(fd,lev,mode)
#else
void
savelev(fd,lev,mode)
#endif
int fd;
xchar lev;
int mode;
{
#ifdef TOS
short tlev;
#endif
/* if we're tearing down the current level without saving anything
(which happens upon entrance to the endgame or after an aborted
restore attempt) then we don't want to do any actual I/O */
if (mode == FREE_SAVE) goto skip_lots;
if (iflags.purge_monsters) {
/* purge any dead monsters (necessary if we're starting
* a panic save rather than a normal one, or sometimes
* when changing levels without taking time -- e.g.
* create statue trap then immediately level teleport) */
dmonsfree();
}
if(fd < 0) panic("Save on bad file!"); /* impossible */
#ifdef MFLOPPY
count_only = (mode & COUNT_SAVE);
#endif
if (lev >= 0 && lev <= maxledgerno())
level_info[lev].flags |= VISITED;
bwrite(fd,(genericptr_t) &hackpid,sizeof(hackpid));
#ifdef TOS
tlev=lev; tlev &= 0x00ff;
bwrite(fd,(genericptr_t) &tlev,sizeof(tlev));
#else
bwrite(fd,(genericptr_t) &lev,sizeof(lev));
#endif
#ifdef RLECOMP
{
/* perform run-length encoding of rm structs */
struct rm *prm, *rgrm;
int x, y;
uchar match;
rgrm = &levl[0][0]; /* start matching at first rm */
match = 0;
for (y = 0; y < ROWNO; y++) {
for (x = 0; x < COLNO; x++) {
prm = &levl[x][y];
if (prm->glyph == rgrm->glyph
&& prm->typ == rgrm->typ
&& prm->seenv == rgrm->seenv
&& prm->horizontal == rgrm->horizontal
&& prm->flags == rgrm->flags
&& prm->lit == rgrm->lit
&& prm->waslit == rgrm->waslit
&& prm->roomno == rgrm->roomno
&& prm->edge == rgrm->edge) {
match++;
if (match > 254) {
match = 254; /* undo this match */
goto writeout;
}
} else {
/* the run has been broken,
* write out run-length encoding */
writeout:
bwrite(fd, (genericptr_t)&match, sizeof(uchar));
bwrite(fd, (genericptr_t)rgrm, sizeof(struct rm));
/* start encoding again. we have at least 1 rm
* in the next run, viz. this one. */
match = 1;
rgrm = prm;
}
}
}
if (match > 0) {
bwrite(fd, (genericptr_t)&match, sizeof(uchar));
bwrite(fd, (genericptr_t)rgrm, sizeof(struct rm));
}
}
#else
bwrite(fd,(genericptr_t) levl,sizeof(levl));
#endif /* RLECOMP */
bwrite(fd,(genericptr_t) &monstermoves,sizeof(monstermoves));
bwrite(fd,(genericptr_t) &upstair,sizeof(stairway));
bwrite(fd,(genericptr_t) &dnstair,sizeof(stairway));
bwrite(fd,(genericptr_t) &upladder,sizeof(stairway));
bwrite(fd,(genericptr_t) &dnladder,sizeof(stairway));
bwrite(fd,(genericptr_t) &sstairs,sizeof(stairway));
bwrite(fd,(genericptr_t) &updest,sizeof(dest_area));
bwrite(fd,(genericptr_t) &dndest,sizeof(dest_area));
bwrite(fd,(genericptr_t) &level.flags,sizeof(level.flags));
bwrite(fd, (genericptr_t) doors, sizeof(doors));
save_rooms(fd); /* no dynamic memory to reclaim */
/* from here on out, saving also involves allocated memory cleanup */
skip_lots:
/* must be saved before mons, objs, and buried objs */
save_timers(fd, mode, RANGE_LEVEL);
save_light_sources(fd, mode, RANGE_LEVEL);
savemonchn(fd, fmon, mode);
save_worm(fd, mode); /* save worm information */
savetrapchn(fd, ftrap, mode);
saveobjchn(fd, fobj, mode);
saveobjchn(fd, level.buriedobjlist, mode);
saveobjchn(fd, billobjs, mode);
if (release_data(mode)) {
fmon = 0;
ftrap = 0;
fobj = 0;
level.buriedobjlist = 0;
billobjs = 0;
}
save_engravings(fd, mode);
savedamage(fd, mode);
save_regions(fd, mode);
if (mode != FREE_SAVE) bflush(fd);
}
#ifdef ZEROCOMP
/* The runs of zero-run compression are flushed after the game state or a
* level is written out. This adds a couple bytes to a save file, where
* the runs could be mashed together, but it allows gluing together game
* state and level files to form a save file, and it means the flushing
* does not need to be specifically called for every other time a level
* file is written out.
*/
#define RLESC '\0' /* Leading character for run of LRESC's */
#define flushoutrun(ln) (bputc(RLESC), bputc(ln), ln = -1)
#ifndef ZEROCOMP_BUFSIZ
# define ZEROCOMP_BUFSIZ BUFSZ
#endif
static NEARDATA unsigned char outbuf[ZEROCOMP_BUFSIZ];
static NEARDATA unsigned short outbufp = 0;
static NEARDATA short outrunlength = -1;
static NEARDATA int bwritefd;
static NEARDATA boolean compressing = FALSE;
/*dbg()
{
HUP printf("outbufp %d outrunlength %d\n", outbufp,outrunlength);
}*/
STATIC_OVL void
bputc(c)
int c;
{
#ifdef MFLOPPY
bytes_counted++;
if (count_only)
return;
#endif
if (outbufp >= sizeof outbuf) {
(void) write(bwritefd, outbuf, sizeof outbuf);
outbufp = 0;
}
outbuf[outbufp++] = (unsigned char)c;
}
/*ARGSUSED*/
void
bufon(fd)
int fd;
{
compressing = TRUE;
return;
}
/*ARGSUSED*/
void
bufoff(fd)
int fd;
{
if (outbufp) {
outbufp = 0;
panic("closing file with buffered data still unwritten");
}
outrunlength = -1;
compressing = FALSE;
return;
}
void
bflush(fd) /* flush run and buffer */
register int fd;
{
bwritefd = fd;
if (outrunlength >= 0) { /* flush run */
flushoutrun(outrunlength);
}
#ifdef MFLOPPY
if (count_only) outbufp = 0;
#endif
if (outbufp) {
if (write(fd, outbuf, outbufp) != outbufp) {
#if defined(UNIX) || defined(VMS) || defined(__EMX__)
if (program_state.done_hup)
terminate(EXIT_FAILURE);
else
#endif
bclose(fd); /* panic (outbufp != 0) */
}
outbufp = 0;
}
}
void
bwrite(fd, loc, num)
int fd;
genericptr_t loc;
register unsigned num;
{
register unsigned char *bp = (unsigned char *)loc;
if (!compressing) {
#ifdef MFLOPPY
bytes_counted += num;
if (count_only) return;
#endif
if ((unsigned) write(fd, loc, num) != num) {
#if defined(UNIX) || defined(VMS) || defined(__EMX__)
if (program_state.done_hup)
terminate(EXIT_FAILURE);
else
#endif
panic("cannot write %u bytes to file #%d", num, fd);
}
} else {
bwritefd = fd;
for (; num; num--, bp++) {
if (*bp == RLESC) { /* One more char in run */
if (++outrunlength == 0xFF) {
flushoutrun(outrunlength);
}
} else { /* end of run */
if (outrunlength >= 0) { /* flush run */
flushoutrun(outrunlength);
}
bputc(*bp);
}
}
}
}
void
bclose(fd)
int fd;
{
bufoff(fd);
(void) close(fd);
return;
}
#else /* ZEROCOMP */
static int bw_fd = -1;
static FILE *bw_FILE = 0;
static boolean buffering = FALSE;
void
bufon(fd)
int fd;
{
#ifdef UNIX
if(bw_fd >= 0)
panic("double buffering unexpected");
bw_fd = fd;
if((bw_FILE = fdopen(fd, "w")) == 0)
panic("buffering of file %d failed", fd);
#endif
buffering = TRUE;
}
void
bufoff(fd)
int fd;
{
bflush(fd);
buffering = FALSE;
}
void
bflush(fd)
int fd;
{
#ifdef UNIX
if(fd == bw_fd) {
if(fflush(bw_FILE) == EOF)
panic("flush of savefile failed!");
}
#endif
return;
}
void
bwrite(fd,loc,num)
register int fd;
register genericptr_t loc;
register unsigned num;
{
boolean failed;
#ifdef MFLOPPY
bytes_counted += num;
if (count_only) return;
#endif
#ifdef UNIX
if (buffering) {
if(fd != bw_fd)
panic("unbuffered write to fd %d (!= %d)", fd, bw_fd);
failed = (fwrite(loc, (int)num, 1, bw_FILE) != 1);
} else
#endif /* UNIX */
{
/* lint wants the 3rd arg of write to be an int; lint -p an unsigned */
#if defined(BSD) || defined(ULTRIX)
failed = (write(fd, loc, (int)num) != (int)num);
#else /* e.g. SYSV, __TURBOC__ */
failed = (write(fd, loc, num) != num);
#endif
}
if (failed) {
#if defined(UNIX) || defined(VMS) || defined(__EMX__)
if (program_state.done_hup)
terminate(EXIT_FAILURE);
else
#endif
panic("cannot write %u bytes to file #%d", num, fd);
}
}
void
bclose(fd)
int fd;
{
bufoff(fd);
#ifdef UNIX
if (fd == bw_fd) {
(void) fclose(bw_FILE);
bw_fd = -1;
bw_FILE = 0;
} else
#endif
(void) close(fd);
return;
}
#endif /* ZEROCOMP */
STATIC_OVL void
savelevchn(fd, mode)
register int fd, mode;
{
s_level *tmplev, *tmplev2;
int cnt = 0;
for (tmplev = sp_levchn; tmplev; tmplev = tmplev->next) cnt++;
if (perform_bwrite(mode))
bwrite(fd, (genericptr_t) &cnt, sizeof(int));
for (tmplev = sp_levchn; tmplev; tmplev = tmplev2) {
tmplev2 = tmplev->next;
if (perform_bwrite(mode))
bwrite(fd, (genericptr_t) tmplev, sizeof(s_level));
if (release_data(mode))
free((genericptr_t) tmplev);
}
if (release_data(mode))
sp_levchn = 0;
}
STATIC_OVL void
savedamage(fd, mode)
register int fd, mode;
{
register struct damage *damageptr, *tmp_dam;
unsigned int xl = 0;
damageptr = level.damagelist;
for (tmp_dam = damageptr; tmp_dam; tmp_dam = tmp_dam->next)
xl++;
if (perform_bwrite(mode))
bwrite(fd, (genericptr_t) &xl, sizeof(xl));
while (xl--) {
if (perform_bwrite(mode))
bwrite(fd, (genericptr_t) damageptr, sizeof(*damageptr));
tmp_dam = damageptr;
damageptr = damageptr->next;
if (release_data(mode))
free((genericptr_t)tmp_dam);
}
if (release_data(mode))
level.damagelist = 0;
}
STATIC_OVL void
saveobjchn(fd, otmp, mode)
register int fd, mode;
register struct obj *otmp;
{
register struct obj *otmp2;
unsigned int xl;
int minusone = -1;
while(otmp) {
otmp2 = otmp->nobj;
if (perform_bwrite(mode)) {
xl = otmp->oxlth + otmp->onamelth;
bwrite(fd, (genericptr_t) &xl, sizeof(int));
bwrite(fd, (genericptr_t) otmp, xl + sizeof(struct obj));
}
if (Has_contents(otmp))
saveobjchn(fd,otmp->cobj,mode);
if (release_data(mode)) {
if (otmp->oclass == FOOD_CLASS) food_disappears(otmp);
if (otmp->oclass == SPBOOK_CLASS) book_disappears(otmp);
otmp->where = OBJ_FREE; /* set to free so dealloc will work */
otmp->timed = 0; /* not timed any more */
otmp->lamplit = 0; /* caller handled lights */
dealloc_obj(otmp);
}
otmp = otmp2;
}
if (perform_bwrite(mode))
bwrite(fd, (genericptr_t) &minusone, sizeof(int));
}
STATIC_OVL void
savemonchn(fd, mtmp, mode)
register int fd, mode;
register struct monst *mtmp;
{
register struct monst *mtmp2;
unsigned int xl;
int minusone = -1;
struct permonst *monbegin = &mons[0];
if (perform_bwrite(mode))
bwrite(fd, (genericptr_t) &monbegin, sizeof(monbegin));
while (mtmp) {
mtmp2 = mtmp->nmon;
if (perform_bwrite(mode)) {
xl = mtmp->mxlth + mtmp->mnamelth;
bwrite(fd, (genericptr_t) &xl, sizeof(int));
bwrite(fd, (genericptr_t) mtmp, xl + sizeof(struct monst));
}
if (mtmp->minvent)
saveobjchn(fd,mtmp->minvent,mode);
if (release_data(mode))
dealloc_monst(mtmp);
mtmp = mtmp2;
}
if (perform_bwrite(mode))
bwrite(fd, (genericptr_t) &minusone, sizeof(int));
}
STATIC_OVL void
savetrapchn(fd, trap, mode)
register int fd, mode;
register struct trap *trap;
{
register struct trap *trap2;
while (trap) {
trap2 = trap->ntrap;
if (perform_bwrite(mode))
bwrite(fd, (genericptr_t) trap, sizeof(struct trap));
if (release_data(mode))
dealloc_trap(trap);
trap = trap2;
}
if (perform_bwrite(mode))
bwrite(fd, (genericptr_t)nulls, sizeof(struct trap));
}
/* save all the fruit names and ID's; this is used only in saving whole games
* (not levels) and in saving bones levels. When saving a bones level,
* we only want to save the fruits which exist on the bones level; the bones
* level routine marks nonexistent fruits by making the fid negative.
*/
void
savefruitchn(fd, mode)
register int fd, mode;
{
register struct fruit *f2, *f1;
f1 = ffruit;
while (f1) {
f2 = f1->nextf;
if (f1->fid >= 0 && perform_bwrite(mode))
bwrite(fd, (genericptr_t) f1, sizeof(struct fruit));
if (release_data(mode))
dealloc_fruit(f1);
f1 = f2;
}
if (perform_bwrite(mode))
bwrite(fd, (genericptr_t)nulls, sizeof(struct fruit));
if (release_data(mode))
ffruit = 0;
}
/* also called by prscore(); this probably belongs in dungeon.c... */
void
free_dungeons()
{
#ifdef FREE_ALL_MEMORY
savelevchn(0, FREE_SAVE);
save_dungeon(0, FALSE, TRUE);
#endif
return;
}
void
freedynamicdata()
{
unload_qtlist();
free_invbuf(); /* let_to_name (invent.c) */
free_youbuf(); /* You_buf,&c (pline.c) */
tmp_at(DISP_FREEMEM, 0); /* temporary display effects */
#ifdef FREE_ALL_MEMORY
# define freeobjchn(X) (saveobjchn(0, X, FREE_SAVE), X = 0)
# define freemonchn(X) (savemonchn(0, X, FREE_SAVE), X = 0)
# define freetrapchn(X) (savetrapchn(0, X, FREE_SAVE), X = 0)
# define freefruitchn() savefruitchn(0, FREE_SAVE)
# define freenames() savenames(0, FREE_SAVE)
# define free_oracles() save_oracles(0, FREE_SAVE)
# define free_waterlevel() save_waterlevel(0, FREE_SAVE)
# define free_worm() save_worm(0, FREE_SAVE)
# define free_timers(R) save_timers(0, FREE_SAVE, R)
# define free_light_sources(R) save_light_sources(0, FREE_SAVE, R);
# define free_engravings() save_engravings(0, FREE_SAVE)
# define freedamage() savedamage(0, FREE_SAVE)
# define free_animals() mon_animal_list(FALSE)
/* move-specific data */
dmonsfree(); /* release dead monsters */
/* level-specific data */
free_timers(RANGE_LEVEL);
free_light_sources(RANGE_LEVEL);
freemonchn(fmon);
free_worm(); /* release worm segment information */
freetrapchn(ftrap);
freeobjchn(fobj);
freeobjchn(level.buriedobjlist);
freeobjchn(billobjs);
free_engravings();
freedamage();
/* game-state data */
free_timers(RANGE_GLOBAL);
free_light_sources(RANGE_GLOBAL);
freeobjchn(invent);
freeobjchn(migrating_objs);
freemonchn(migrating_mons);
freemonchn(mydogs); /* ascension or dungeon escape */
/* freelevchn(); [folded into free_dungeons()] */
free_animals();
free_oracles();
freefruitchn();
freenames();
free_waterlevel();
free_dungeons();
/* some pointers in iflags */
if (iflags.wc_font_map) free(iflags.wc_font_map);
if (iflags.wc_font_message) free(iflags.wc_font_message);
if (iflags.wc_font_text) free(iflags.wc_font_text);
if (iflags.wc_font_menu) free(iflags.wc_font_menu);
if (iflags.wc_font_status) free(iflags.wc_font_status);
if (iflags.wc_tile_file) free(iflags.wc_tile_file);
#ifdef AUTOPICKUP_EXCEPTIONS
free_autopickup_exceptions();
#endif
#endif /* FREE_ALL_MEMORY */
return;
}
#ifdef MFLOPPY
boolean
swapin_file(lev)
int lev;
{
char to[PATHLEN], from[PATHLEN];
Sprintf(from, "%s%s", permbones, alllevels);
Sprintf(to, "%s%s", levels, alllevels);
set_levelfile_name(from, lev);
set_levelfile_name(to, lev);
if (iflags.checkspace) {
while (level_info[lev].size > freediskspace(to))
if (!swapout_oldest())
return FALSE;
}
# ifdef WIZARD
if (wizard) {
pline("Swapping in `%s'.", from);
wait_synch();
}
# endif
copyfile(from, to);
(void) unlink(from);
level_info[lev].where = ACTIVE;
return TRUE;
}
STATIC_OVL boolean
swapout_oldest() {
char to[PATHLEN], from[PATHLEN];
int i, oldest;
long oldtime;
if (!ramdisk)
return FALSE;
for (i = 1, oldtime = 0, oldest = 0; i <= maxledgerno(); i++)
if (level_info[i].where == ACTIVE
&& (!oldtime || level_info[i].time < oldtime)) {
oldest = i;
oldtime = level_info[i].time;
}
if (!oldest)
return FALSE;
Sprintf(from, "%s%s", levels, alllevels);
Sprintf(to, "%s%s", permbones, alllevels);
set_levelfile_name(from, oldest);
set_levelfile_name(to, oldest);
# ifdef WIZARD
if (wizard) {
pline("Swapping out `%s'.", from);
wait_synch();
}
# endif
copyfile(from, to);
(void) unlink(from);
level_info[oldest].where = SWAPPED;
return TRUE;
}
STATIC_OVL void
copyfile(from, to)
char *from, *to;
{
# ifdef TOS
if (_copyfile(from, to))
panic("Can't copy %s to %s", from, to);
# else
char buf[BUFSIZ]; /* this is system interaction, therefore
* BUFSIZ instead of NetHack's BUFSZ */
int nfrom, nto, fdfrom, fdto;
if ((fdfrom = open(from, O_RDONLY | O_BINARY, FCMASK)) < 0)
panic("Can't copy from %s !?", from);
if ((fdto = open(to, O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, FCMASK)) < 0)
panic("Can't copy to %s", to);
do {
nfrom = read(fdfrom, buf, BUFSIZ);
nto = write(fdto, buf, nfrom);
if (nto != nfrom)
panic("Copyfile failed!");
} while (nfrom == BUFSIZ);
(void) close(fdfrom);
(void) close(fdto);
# endif /* TOS */
}
void
co_false() /* see comment in bones.c */
{
count_only = FALSE;
return;
}
#endif /* MFLOPPY */
/*save.c*/
| 24.511072 | 107 | 0.664727 |
23cc82682cc5e44387c4eb175822027e475fa468 | 1,344 | h | C | macOS/10.13/CoreData.framework/PFUbiquityMigrationAssistant.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | 30 | 2016-10-09T20:13:00.000Z | 2022-01-24T04:14:57.000Z | macOS/10.13/CoreData.framework/PFUbiquityMigrationAssistant.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | null | null | null | macOS/10.13/CoreData.framework/PFUbiquityMigrationAssistant.h | onmyway133/Runtime-Headers | e9b80e7ab9103f37ad421ad6b8b58ee06369d21f | [
"MIT"
] | 7 | 2017-08-29T14:41:25.000Z | 2022-01-19T17:14:54.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
*/
@interface PFUbiquityMigrationAssistant : NSObject {
NSMutableDictionary * _baselineLocationsByVersionHash;
NSString * _currentModelVersionHash;
NSString * _localPeerID;
NSMutableDictionary * _logLocationsByVersionHash;
NSMutableArray * _orderedReceipts;
NSString * _previousModelVersionHash;
NSMutableArray * _receiptLocations;
NSString * _ubiquityName;
PFUbiquityLocation * _ubiquityRootLocation;
}
@property (nonatomic, readonly) NSString *currentModelVersionHash;
@property (nonatomic, readonly) NSString *previousModelVersionHash;
- (void)_populateBaselineAndTransactionLogLocations;
- (id)baselineLocationsByModelVersionHash;
- (BOOL)canUseReceipts;
- (id)currentModelVersionHash;
- (void)dealloc;
- (BOOL)electPreviousModelVersionHashFromTransactionLogsError:(id*)arg1;
- (id)initWithUbiquityRootLocation:(id)arg1 peerID:(id)arg2 ubiquityName:(id)arg3 modelVersionHash:(id)arg4;
- (id)latestBaselineLocationSkipModelVersionHash:(id)arg1;
- (id)latestTransactionLogForModelVersionHash:(id)arg1;
- (id)orderedReceipts;
- (id)previousModelVersionHash;
- (id)receiptLocations;
- (id)transactionLogLocationsByModelVersionHash;
- (id)transactionLogLocationsForModelVersionHash:(id)arg1;
@end
| 37.333333 | 108 | 0.810268 |
23ccb4aa3253d6c578031f1e185aaa9c7ff915cd | 1,543 | h | C | AiaCore/include/aiacore/aia_encryption_algorithm.h | isabella232/AIAClientSDK | 686cf5781adb4c24e78081d25ddea0faafe2c612 | [
"Apache-2.0"
] | 19 | 2020-09-11T23:40:31.000Z | 2021-10-30T14:43:23.000Z | AiaCore/include/aiacore/aia_encryption_algorithm.h | alexa/AIAClientSDK | 686cf5781adb4c24e78081d25ddea0faafe2c612 | [
"Apache-2.0"
] | 5 | 2020-10-27T21:57:18.000Z | 2021-01-11T21:17:02.000Z | AiaCore/include/aiacore/aia_encryption_algorithm.h | isabella232/AIAClientSDK | 686cf5781adb4c24e78081d25ddea0faafe2c612 | [
"Apache-2.0"
] | 3 | 2020-12-01T07:16:15.000Z | 2022-02-08T17:35:06.000Z | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file aia_encryption_algorithm.h
* @brief User-facing functions and variables for encryption/decryption.
*/
#ifndef AIA_ENCRYPTION_ALGORITHM_H_
#define AIA_ENCRYPTION_ALGORITHM_H_
/* The config header is always included first. */
#include <aia_config.h>
#include <stddef.h>
/** Encryption algorithms supported by Aia */
typedef enum AiaEncryptionAlgorithm
{
/* AES-GCM encryption. */
AIA_AES_GCM
} AiaEncryptionAlgorithm_t;
/**
* @param algorithm The encryption algorithm to get the key size of.
* @return The key size (in bits) of @c algorithm.
*/
size_t AiaEncryptionAlgorithm_GetKeySize();
/**
* @param algorithm The encryption algorithm to get the string representation
* of.
* @return The string representation for @c algorithm.
*/
const char* AiaEncryptionAlgorithm_ToString(
AiaEncryptionAlgorithm_t algorithm );
#endif /* ifndef AIA_ENCRYPTION_ALGORITHM_H_ */
| 29.673077 | 77 | 0.747894 |
23cd0daeed465496a42d8318187b68dbadf53f35 | 709 | c | C | d/changan/npc/zhifu.c | zhangyifei/mud | b2090bbd2a8d3d82b86148d794a7ca59cd2429f3 | [
"MIT"
] | null | null | null | d/changan/npc/zhifu.c | zhangyifei/mud | b2090bbd2a8d3d82b86148d794a7ca59cd2429f3 | [
"MIT"
] | null | null | null | d/changan/npc/zhifu.c | zhangyifei/mud | b2090bbd2a8d3d82b86148d794a7ca59cd2429f3 | [
"MIT"
] | null | null | null | //zhifu.c
inherit NPC;
void create()
{
set_name("梁兴禄", ({ "liang xinglu", "liang" }));
set("title", "长安知府");
set("gender", "男性");
set("age", 43);
set("str", 20);
set("dex", 20);
set("long", "长安城现任知府。\n");
set("combat_exp", 50000);
set("shen_type", 0);
set("attitude", "heroism");
set_skill("unarmed", 60);
set_skill("force", 60);
set_skill("sword", 60);
set_skill("dodge", 60);
set_skill("parry", 60);
set_temp("apply/attack", 50);
set_temp("apply/defense", 50);
set_temp("apply/armor", 50);
set_temp("apply/damage", 15);
set("neili", 500);
set("max_neili", 500);
set("jiali", 20);
setup();
carry_object(__DIR__"obj/sword")->wield();
carry_object(__DIR__"obj/choupao")->wear();
}
| 20.852941 | 48 | 0.614951 |
23cd23b4b8d7ba3e28e4a3ae8e2eb1177609e67c | 4,846 | c | C | source/blender/nodes/texture/nodes/node_texture_output.c | juangea/B28_boneMaster | 6be9d19951ed460829d379aa90953b14a9f281f2 | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | 2 | 2019-06-03T02:47:42.000Z | 2020-04-03T10:23:33.000Z | source/blender/nodes/texture/nodes/node_texture_output.c | juangea/B28_boneMaster | 6be9d19951ed460829d379aa90953b14a9f281f2 | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | source/blender/nodes/texture/nodes/node_texture_output.c | juangea/B28_boneMaster | 6be9d19951ed460829d379aa90953b14a9f281f2 | [
"Naumen",
"Condor-1.1",
"MS-PL"
] | null | null | null | /*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* The Original Code is Copyright (C) 2006 Blender Foundation.
* All rights reserved.
*/
/** \file
* \ingroup texnodes
*/
#include "node_texture_util.h"
#include "NOD_texture.h"
/* **************** COMPOSITE ******************** */
static bNodeSocketTemplate inputs[] = {
{SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
{SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, PROP_DIRECTION},
{-1, 0, ""},
};
/* applies to render pipeline */
static void exec(void *data,
int UNUSED(thread),
bNode *node,
bNodeExecData *execdata,
bNodeStack **in,
bNodeStack **UNUSED(out))
{
TexCallData *cdata = (TexCallData *)data;
TexResult *target = cdata->target;
if (cdata->do_preview) {
TexParams params;
params_from_cdata(¶ms, cdata);
if (in[1] && in[1]->hasinput && !in[0]->hasinput) {
tex_input_rgba(&target->tr, in[1], ¶ms, cdata->thread);
}
else {
tex_input_rgba(&target->tr, in[0], ¶ms, cdata->thread);
}
tex_do_preview(execdata->preview, params.co, &target->tr, cdata->do_manage);
}
else {
/* 0 means don't care, so just use first */
if (cdata->which_output == node->custom1 || (cdata->which_output == 0 && node->custom1 == 1)) {
TexParams params;
params_from_cdata(¶ms, cdata);
tex_input_rgba(&target->tr, in[0], ¶ms, cdata->thread);
target->tin = (target->tr + target->tg + target->tb) / 3.0f;
target->talpha = true;
if (target->nor) {
if (in[1] && in[1]->hasinput) {
tex_input_vec(target->nor, in[1], ¶ms, cdata->thread);
}
else {
target->nor = NULL;
}
}
}
}
}
static void unique_name(bNode *node)
{
TexNodeOutput *tno = (TexNodeOutput *)node->storage;
char new_name[sizeof(tno->name)];
int new_len = 0;
int suffix;
bNode *i;
const char *name = tno->name;
new_name[0] = '\0';
i = node;
while (i->prev) {
i = i->prev;
}
for (; i; i = i->next) {
if (i == node || i->type != TEX_NODE_OUTPUT ||
!STREQ(name, ((TexNodeOutput *)(i->storage))->name)) {
continue;
}
if (new_name[0] == '\0') {
int len = strlen(name);
if (len >= 4 && sscanf(name + len - 4, ".%03d", &suffix) == 1) {
new_len = len;
}
else {
suffix = 0;
new_len = len + 4;
if (new_len > (sizeof(tno->name) - 1)) {
new_len = (sizeof(tno->name) - 1);
}
}
BLI_strncpy(new_name, name, sizeof(tno->name));
name = new_name;
}
sprintf(new_name + new_len - 4, ".%03d", ++suffix);
}
if (new_name[0] != '\0') {
BLI_strncpy(tno->name, new_name, sizeof(tno->name));
}
}
static void assign_index(struct bNode *node)
{
bNode *tnode;
int index = 1;
tnode = node;
while (tnode->prev) {
tnode = tnode->prev;
}
check_index:
for (; tnode; tnode = tnode->next)
if (tnode->type == TEX_NODE_OUTPUT && tnode != node)
if (tnode->custom1 == index) {
index++;
goto check_index;
}
node->custom1 = index;
}
static void init(bNodeTree *UNUSED(ntree), bNode *node)
{
TexNodeOutput *tno = MEM_callocN(sizeof(TexNodeOutput), "TEX_output");
node->storage = tno;
strcpy(tno->name, "Default");
unique_name(node);
assign_index(node);
}
static void copy(bNodeTree *dest_ntree, bNode *dest_node, bNode *src_node)
{
node_copy_standard_storage(dest_ntree, dest_node, src_node);
unique_name(dest_node);
assign_index(dest_node);
}
void register_node_type_tex_output(void)
{
static bNodeType ntype;
tex_node_type_base(&ntype, TEX_NODE_OUTPUT, "Output", NODE_CLASS_OUTPUT, NODE_PREVIEW);
node_type_socket_templates(&ntype, inputs, NULL);
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
node_type_init(&ntype, init);
node_type_storage(&ntype, "TexNodeOutput", node_free_standard_storage, copy);
node_type_exec(&ntype, NULL, NULL, exec);
/* Do not allow muting output. */
node_type_internal_links(&ntype, NULL);
nodeRegisterType(&ntype);
}
| 27.224719 | 99 | 0.614734 |
23d1808fe027a45db7094bf5dd5477d776194fd1 | 4,146 | c | C | linux-4.14.90-dev/linux-4.14.90/drivers/xen/xen-acpi-pad.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | 55 | 2019-12-20T03:25:14.000Z | 2022-01-16T07:19:47.000Z | linux-4.14.90-dev/linux-4.14.90/drivers/xen/xen-acpi-pad.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | 5 | 2020-04-04T09:24:09.000Z | 2020-04-19T12:33:55.000Z | linux-4.14.90-dev/linux-4.14.90/drivers/xen/xen-acpi-pad.c | bingchunjin/1806_SDK | d5ed0258fc22f60e00ec025b802d175f33da6e41 | [
"MIT"
] | 30 | 2018-05-02T08:43:27.000Z | 2022-01-23T03:25:54.000Z | /*
* xen-acpi-pad.c - Xen pad interface
*
* Copyright (c) 2012, Intel Corporation.
* Author: Liu, Jinsong <jinsong.liu@intel.com>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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.
*/
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/acpi.h>
#include <xen/interface/version.h>
#include <xen/xen-ops.h>
#include <asm/xen/hypercall.h>
#define ACPI_PROCESSOR_AGGREGATOR_CLASS "acpi_pad"
#define ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME "Processor Aggregator"
#define ACPI_PROCESSOR_AGGREGATOR_NOTIFY 0x80
static DEFINE_MUTEX(xen_cpu_lock);
static int xen_acpi_pad_idle_cpus(unsigned int idle_nums)
{
struct xen_platform_op op;
op.cmd = XENPF_core_parking;
op.u.core_parking.type = XEN_CORE_PARKING_SET;
op.u.core_parking.idle_nums = idle_nums;
return HYPERVISOR_platform_op(&op);
}
static int xen_acpi_pad_idle_cpus_num(void)
{
struct xen_platform_op op;
op.cmd = XENPF_core_parking;
op.u.core_parking.type = XEN_CORE_PARKING_GET;
return HYPERVISOR_platform_op(&op)
?: op.u.core_parking.idle_nums;
}
/*
* Query firmware how many CPUs should be idle
* return -1 on failure
*/
static int acpi_pad_pur(acpi_handle handle)
{
struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL};
union acpi_object *package;
int num = -1;
if (ACPI_FAILURE(acpi_evaluate_object(handle, "_PUR", NULL, &buffer)))
return num;
if (!buffer.length || !buffer.pointer)
return num;
package = buffer.pointer;
if (package->type == ACPI_TYPE_PACKAGE &&
package->package.count == 2 &&
package->package.elements[0].integer.value == 1) /* rev 1 */
num = package->package.elements[1].integer.value;
kfree(buffer.pointer);
return num;
}
static void acpi_pad_handle_notify(acpi_handle handle)
{
int idle_nums;
struct acpi_buffer param = {
.length = 4,
.pointer = (void *)&idle_nums,
};
mutex_lock(&xen_cpu_lock);
idle_nums = acpi_pad_pur(handle);
if (idle_nums < 0) {
mutex_unlock(&xen_cpu_lock);
return;
}
idle_nums = xen_acpi_pad_idle_cpus(idle_nums)
?: xen_acpi_pad_idle_cpus_num();
if (idle_nums >= 0)
acpi_evaluate_ost(handle, ACPI_PROCESSOR_AGGREGATOR_NOTIFY,
0, ¶m);
mutex_unlock(&xen_cpu_lock);
}
static void acpi_pad_notify(acpi_handle handle, u32 event,
void *data)
{
switch (event) {
case ACPI_PROCESSOR_AGGREGATOR_NOTIFY:
acpi_pad_handle_notify(handle);
break;
default:
pr_warn("Unsupported event [0x%x]\n", event);
break;
}
}
static int acpi_pad_add(struct acpi_device *device)
{
acpi_status status;
strcpy(acpi_device_name(device), ACPI_PROCESSOR_AGGREGATOR_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_PROCESSOR_AGGREGATOR_CLASS);
status = acpi_install_notify_handler(device->handle,
ACPI_DEVICE_NOTIFY, acpi_pad_notify, device);
if (ACPI_FAILURE(status))
return -ENODEV;
return 0;
}
static int acpi_pad_remove(struct acpi_device *device)
{
mutex_lock(&xen_cpu_lock);
xen_acpi_pad_idle_cpus(0);
mutex_unlock(&xen_cpu_lock);
acpi_remove_notify_handler(device->handle,
ACPI_DEVICE_NOTIFY, acpi_pad_notify);
return 0;
}
static const struct acpi_device_id pad_device_ids[] = {
{"ACPI000C", 0},
{"", 0},
};
static struct acpi_driver acpi_pad_driver = {
.name = "processor_aggregator",
.class = ACPI_PROCESSOR_AGGREGATOR_CLASS,
.ids = pad_device_ids,
.ops = {
.add = acpi_pad_add,
.remove = acpi_pad_remove,
},
};
static int __init xen_acpi_pad_init(void)
{
/* Only DOM0 is responsible for Xen acpi pad */
if (!xen_initial_domain())
return -ENODEV;
/* Only Xen4.2 or later support Xen acpi pad */
if (!xen_running_on_version_or_later(4, 2))
return -ENODEV;
return acpi_bus_register_driver(&acpi_pad_driver);
}
subsys_initcall(xen_acpi_pad_init);
| 24.245614 | 76 | 0.748191 |
d95cd5479acc86cd101db8c12eb23564b400df84 | 148 | h | C | osprey/libiberty/acconfig.h | sharugupta/OpenUH | daddd76858a53035f5d713f648d13373c22506e8 | [
"BSD-2-Clause"
] | null | null | null | osprey/libiberty/acconfig.h | sharugupta/OpenUH | daddd76858a53035f5d713f648d13373c22506e8 | [
"BSD-2-Clause"
] | null | null | null | osprey/libiberty/acconfig.h | sharugupta/OpenUH | daddd76858a53035f5d713f648d13373c22506e8 | [
"BSD-2-Clause"
] | null | null | null | /*
* Copyright 2005 PathScale, Inc. All Rights Reserved.
*/
/* Define to `unsigned long' if <sys/types.h> doesn't define. */
#undef uintptr_t
| 18.5 | 65 | 0.668919 |
d95d6a22c7fcacb499bfd0b9cbd5f37a8f0676b9 | 1,401 | h | C | third_party/virtualbox/src/VBox/Devices/Network/slirp/if.h | Fimbure/icebox-1 | 0b81992a53e1b410955ca89bdb6f8169d6f2da86 | [
"MIT"
] | 521 | 2019-03-29T15:44:08.000Z | 2022-03-22T09:46:19.000Z | third_party/virtualbox/src/VBox/Devices/Network/slirp/if.h | Fimbure/icebox-1 | 0b81992a53e1b410955ca89bdb6f8169d6f2da86 | [
"MIT"
] | 30 | 2019-06-04T17:00:49.000Z | 2021-09-08T20:44:19.000Z | third_party/virtualbox/src/VBox/Devices/Network/slirp/if.h | Fimbure/icebox-1 | 0b81992a53e1b410955ca89bdb6f8169d6f2da86 | [
"MIT"
] | 99 | 2019-03-29T16:04:13.000Z | 2022-03-28T16:59:34.000Z | /* $Id: if.h $ */
/** @file
* NAT - if_*.
*/
/*
* Copyright (C) 2006-2017 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* you can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*
* This code is based on:
*
* Copyright (c) 1995 Danny Gasparovski.
*
* Please read the file COPYRIGHT for the
* terms and conditions of the copyright.
*/
#ifndef _IF_H_
#define _IF_H_
#define IF_COMPRESS 0x01 /* We want compression */
#define IF_NOCOMPRESS 0x02 /* Do not do compression */
#define IF_AUTOCOMP 0x04 /* Autodetect (default) */
#define IF_NOCIDCOMP 0x08 /* CID compression */
#ifdef ETH_P_ARP
# undef ETH_P_ARP
#endif /* ETH_P_ARP*/
#define ETH_P_ARP 0x0806 /* Address Resolution packet */
#ifdef ETH_P_IP
# undef ETH_P_IP
#endif /* ETH_P_IP */
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
#ifdef ETH_P_IPV6
# undef ETH_P_IPV6
#endif /* ETH_P_IPV6 */
#define ETH_P_IPV6 0x86DD /* IPv6 */
#endif
| 26.942308 | 74 | 0.675946 |
d95edf35722bcb4eaaab057bdb122d886122f93d | 11,387 | c | C | firmware/coreboot/src/vendorcode/amd/agesa/f15tn/Proc/CPU/Family/0x15/TN/F15TnInitEarlyTable.c | 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/vendorcode/amd/agesa/f15tn/Proc/CPU/Family/0x15/TN/F15TnInitEarlyTable.c | 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/vendorcode/amd/agesa/f15tn/Proc/CPU/Family/0x15/TN/F15TnInitEarlyTable.c | fabiojna02/OpenCellular | 45b6a202d6b2e2485c89955b9a6da920c4d56ddb | [
"CC-BY-4.0",
"BSD-3-Clause"
] | null | null | null | /* $NoKeywords:$ */
/**
* @file
*
* Initialize the Family 15h Trinity specific way of running early initialization.
*
* Returns the table of initialization steps to perform at
* AmdInitEarly.
*
* @xrefitem bom "File Content Label" "Release Content"
* @e project: AGESA
* @e sub-project: CPU/FAMILY/0x15/TN
* @e \$Revision: 64491 $ @e \$Date: 2012-01-23 12:37:30 -0600 (Mon, 23 Jan 2012) $
*
*/
/*
******************************************************************************
*
* Copyright (c) 2008 - 2012, Advanced Micro Devices, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Advanced Micro Devices, Inc. nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. 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.
******************************************************************************
*/
/*----------------------------------------------------------------------------------------
* M O D U L E S U S E D
*----------------------------------------------------------------------------------------
*/
#include "AGESA.h"
#include "amdlib.h"
#include "cpuFamilyTranslation.h"
#include "Filecode.h"
#include "GeneralServices.h"
#include "heapManager.h"
#include "Fch.h"
#include "Gnb.h"
#include "GnbLib.h"
#include "cpuEarlyInit.h"
#include "cpuF15TnPowerMgmt.h"
CODE_GROUP (G2_PEI)
RDATA_GROUP (G2_PEI)
#define FILECODE PROC_CPU_FAMILY_0X15_TN_F15TNINITEARLYTABLE_FILECODE
/*----------------------------------------------------------------------------------------
* D E F I N I T I O N S A N D M A C R O S
*----------------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------------------
* T Y P E D E F S A N D S T R U C T U R E S
*----------------------------------------------------------------------------------------
*/
/*----------------------------------------------------------------------------------------
* P R O T O T Y P E S O F L O C A L F U N C T I O N S
*----------------------------------------------------------------------------------------
*/
VOID
F15TnLoadMicrocodePatchAtEarly (
IN CPU_SPECIFIC_SERVICES *FamilyServices,
IN AMD_CPU_EARLY_PARAMS *EarlyParams,
IN AMD_CONFIG_PARAMS *StdHeader
);
VOID
GetF15TnEarlyInitOnCoreTable (
IN CPU_SPECIFIC_SERVICES *FamilyServices,
OUT CONST S_PERFORM_EARLY_INIT_ON_CORE **Table,
IN AMD_CPU_EARLY_PARAMS *EarlyParams,
IN AMD_CONFIG_PARAMS *StdHeader
);
VOID
ApplyWorkaroundForFchErratum39 (
IN AMD_CONFIG_PARAMS *StdHeader
);
VOID
F15TnNbPstateForceBeforeApLaunchAtEarly (
IN CPU_SPECIFIC_SERVICES *FamilyServices,
IN AMD_CPU_EARLY_PARAMS *EarlyParams,
IN AMD_CONFIG_PARAMS *StdHeader
);
/*----------------------------------------------------------------------------------------
* E X P O R T E D F U N C T I O N S
*----------------------------------------------------------------------------------------
*/
extern F_PERFORM_EARLY_INIT_ON_CORE SetRegistersFromTablesAtEarly;
extern F_PERFORM_EARLY_INIT_ON_CORE F15SetBrandIdRegistersAtEarly;
extern F_PERFORM_EARLY_INIT_ON_CORE LocalApicInitializationAtEarly;
CONST S_PERFORM_EARLY_INIT_ON_CORE ROMDATA F15TnEarlyInitOnCoreTable[] =
{
{SetRegistersFromTablesAtEarly, PERFORM_EARLY_ANY_CONDITION},
{F15SetBrandIdRegistersAtEarly, PERFORM_EARLY_ANY_CONDITION},
{LocalApicInitializationAtEarly, PERFORM_EARLY_ANY_CONDITION},
{F15TnLoadMicrocodePatchAtEarly, PERFORM_EARLY_ANY_CONDITION},
{F15TnNbPstateForceBeforeApLaunchAtEarly, PERFORM_EARLY_WARM_RESET},
{NULL, 0}
};
/*------------------------------------------------------------------------------------*/
/**
* Initializer routine that may be invoked at AmdCpuEarly to return the steps that a
* processor that uses the standard initialization steps should take.
*
* @CpuServiceMethod{::F_GET_EARLY_INIT_TABLE}.
*
* @param[in] FamilyServices The current Family Specific Services.
* @param[out] Table Table of appropriate init steps for the executing core.
* @param[in] EarlyParams Service Interface structure to initialize.
* @param[in] StdHeader Opaque handle to standard config header.
*
*/
VOID
GetF15TnEarlyInitOnCoreTable (
IN CPU_SPECIFIC_SERVICES *FamilyServices,
OUT CONST S_PERFORM_EARLY_INIT_ON_CORE **Table,
IN AMD_CPU_EARLY_PARAMS *EarlyParams,
IN AMD_CONFIG_PARAMS *StdHeader
)
{
*Table = F15TnEarlyInitOnCoreTable;
}
/*---------------------------------------------------------------------------------------*/
/**
* Update microcode patch in current processor for Family15h TN.
*
* This function acts as a wrapper for calling the LoadMicrocodePatch
* routine at AmdInitEarly.
*
* @param[in] FamilyServices The current Family Specific Services.
* @param[in] EarlyParams Service parameters.
* @param[in] StdHeader Config handle for library and services.
*
*/
VOID
F15TnLoadMicrocodePatchAtEarly (
IN CPU_SPECIFIC_SERVICES *FamilyServices,
IN AMD_CPU_EARLY_PARAMS *EarlyParams,
IN AMD_CONFIG_PARAMS *StdHeader
)
{
BOOLEAN IsPatchLoaded;
AGESA_TESTPOINT (TpProcCpuLoadUcode, StdHeader);
if (IsCorePairPrimary (FirstCoreIsComputeUnitPrimary, StdHeader)) {
IsPatchLoaded = LoadMicrocodePatch (StdHeader);
}
// After microcode patch has been loaded, apply the workaround for FCH erratum 39
ApplyWorkaroundForFchErratum39 (StdHeader);
}
/*---------------------------------------------------------------------------------------*/
/**
* Apply the workaround for FCH H2/H3 erratum #39.
*
* This function detects the FCH version and applies the appropriate workaround, if
* required.
*
* @param[in] StdHeader Config handle for library and services.
*
*/
VOID
ApplyWorkaroundForFchErratum39 (
IN AMD_CONFIG_PARAMS *StdHeader
)
{
UINT8 MiscReg51;
UINT8 RevisionId;
UINT16 AcpiPmTmrBlk;
UINT32 VendorIdDeviceId;
UINT64 MsrValue;
PCI_ADDR PciAddress;
AGESA_STATUS IgnoredSts;
CPU_LOGICAL_ID LogicalId;
// Read Vendor ID / Device ID
PciAddress.AddressValue = MAKE_SBDFO (0, 0, 0x14, 0, 0);
LibAmdPciRead (AccessWidth32, PciAddress, &VendorIdDeviceId, StdHeader);
// For Hudson based system, perform workaround
if (VendorIdDeviceId == 0x780B1022) {
PciAddress.Address.Register = 0x8;
LibAmdPciRead (AccessWidth8, PciAddress, &RevisionId, StdHeader);
if ((RevisionId == 0x14) && IsBsp (StdHeader, &IgnoredSts)) {
// Enable hardware workaround by setting Misc_reg x51[0]
LibAmdMemRead (AccessWidth8, (UINT64) (ACPI_MMIO_BASE + MISC_BASE + 0x51), &MiscReg51, StdHeader);
MiscReg51 |= BIT0;
LibAmdMemWrite (AccessWidth8, (UINT64) (ACPI_MMIO_BASE + MISC_BASE + 0x51), &MiscReg51, StdHeader);
} else if (RevisionId == 0x13) {
GetLogicalIdOfCurrentCore (&LogicalId, StdHeader);
if ((LogicalId.Revision & AMD_F15_TN_GT_A0) != 0) {
// For revs A1+, set up the C0010055 MSR
GnbLibIndirectIoBlockRead (0xCD6, 0xCD7, AccessWidth8, 0x64, 2, &AcpiPmTmrBlk, StdHeader);
LibAmdMsrRead (0xC0010055, &MsrValue, StdHeader);
MsrValue |= BIT30;
MsrValue |= AcpiPmTmrBlk;
LibAmdMsrWrite (0xC0010055, &MsrValue, StdHeader);
}
}
}
}
/*---------------------------------------------------------------------------------------*/
/**
* Prevent NB P-state transitions prior to AP launch on Family 15h TN.
*
* This function determines the current NB P-state and forces the NB to remain
* in that P-state.
*
* @param[in] FamilyServices The current Family Specific Services.
* @param[in] EarlyParams Service parameters.
* @param[in] StdHeader Config handle for library and services.
*
*/
VOID
F15TnNbPstateForceBeforeApLaunchAtEarly (
IN CPU_SPECIFIC_SERVICES *FamilyServices,
IN AMD_CPU_EARLY_PARAMS *EarlyParams,
IN AMD_CONFIG_PARAMS *StdHeader
)
{
UINT64 MsrValue;
UINT64 PerfCtrlSave;
UINT64 PerfStsSave;
PCI_ADDR PciAddress;
AGESA_STATUS IgnoredSts;
ALLOCATE_HEAP_PARAMS Alloc;
NB_PSTATE_CTRL_REGISTER NbPsCtrl;
if (IsBsp (StdHeader, &IgnoredSts) && FamilyServices->IsNbPstateEnabled (FamilyServices, &EarlyParams->PlatformConfig, StdHeader)) {
LibAmdMsrRead (MSR_NB_PERF_CTL3, &PerfCtrlSave, StdHeader);
MsrValue = 0x00000006004004E9;
LibAmdMsrRead (MSR_NB_PERF_CTR3, &PerfStsSave, StdHeader);
LibAmdMsrWrite (MSR_NB_PERF_CTL3, &MsrValue, StdHeader);
MsrValue = 0;
LibAmdMsrWrite (MSR_NB_PERF_CTR3, &MsrValue, StdHeader);
PciAddress.AddressValue = NB_PSTATE_CTRL_PCI_ADDR;
LibAmdPciRead (AccessWidth32, PciAddress, &NbPsCtrl, StdHeader);
Alloc.RequestedBufferSize = sizeof (NB_PSTATE_CTRL_REGISTER);
Alloc.BufferHandle = AMD_CPU_NB_PSTATE_FIXUP_HANDLE;
Alloc.Persist = 0;
if (HeapAllocateBuffer (&Alloc, StdHeader) == AGESA_SUCCESS) {
*((NB_PSTATE_CTRL_REGISTER *) Alloc.BufferPtr) = NbPsCtrl;
} else {
ASSERT (FALSE);
}
LibAmdMsrRead (MSR_NB_PERF_CTR3, &MsrValue, StdHeader);
if (MsrValue == 0) {
NbPsCtrl.SwNbPstateLoDis = 1;
} else {
NbPsCtrl.SwNbPstateLoDis = 0;
NbPsCtrl.NbPstateDisOnP0 = 0;
NbPsCtrl.NbPstateThreshold = 0;
}
LibAmdPciWrite (AccessWidth32, PciAddress, &NbPsCtrl, StdHeader);
LibAmdMsrWrite (MSR_NB_PERF_CTL3, &PerfCtrlSave, StdHeader);
LibAmdMsrWrite (MSR_NB_PERF_CTR3, &PerfStsSave, StdHeader);
}
}
| 39.401384 | 134 | 0.605603 |
d9606a2ca6474ee240ceadccea251735d3030528 | 1,575 | h | C | dependencies/include/cgal/CGAL/Arr_spherical_gaussian_map_3/Arr_polyhedral_sgm_transformation.h | rosecodym/space-boundary-tool | 300db4084cd19b092bdf2e8432da065daeaa7c55 | [
"FSFAP"
] | 6 | 2016-11-01T11:09:00.000Z | 2022-02-15T06:31:58.000Z | dependencies/include/cgal/CGAL/Arr_spherical_gaussian_map_3/Arr_polyhedral_sgm_transformation.h | rosecodym/space-boundary-tool | 300db4084cd19b092bdf2e8432da065daeaa7c55 | [
"FSFAP"
] | null | null | null | dependencies/include/cgal/CGAL/Arr_spherical_gaussian_map_3/Arr_polyhedral_sgm_transformation.h | rosecodym/space-boundary-tool | 300db4084cd19b092bdf2e8432da065daeaa7c55 | [
"FSFAP"
] | null | null | null | // Copyright (c) 2009,2010,2011 Tel-Aviv University (Israel).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org).
// You can redistribute it and/or modify it under the terms of the GNU
// General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/releases/CGAL-4.1-branch/Arrangement_on_surface_2/include/CGAL/Arr_spherical_gaussian_map_3/Arr_polyhedral_sgm_transformation.h $
// $Id: Arr_polyhedral_sgm_transformation.h 70967 2012-08-02 12:48:04Z lrineau $
//
// Author(s) : Naama mayer <naamamay@post.tau.ac.il>
#ifndef CGAL_ARR_POLYHEDRAL_SGM_TRANSFORMATION_H
#define CGAL_ARR_POLYHEDRAL_SGM_TRANSFORMATION_H
namespace CGAL {
/* This function rotates the face when the arrangement is Arr_polyhedral_sgm */
template <class Arrangement, class Transformation_3>
class Arr_polyhedral_sgm_transformation
{
public:
typedef typename Arrangement::Face_handle Face_handle;
void rotate_face(Face_handle f, const Transformation_3 & aff)
{
//Transform all the vertices of the original polyhedron.
f->set_point(aff.transform(f->point()));
}
};
} //namespace CGAL
#endif
| 35 | 186 | 0.764444 |
d96085eaad3278fc443ffbac7b2bda3bc98c6038 | 2,194 | c | C | u-boot-2019.01+gitAUTOINC+333c3e72d3-g333c3e72d3/tools/fit_common.c | rlourette/TI_SDK_u-boot-2019.01 | 3000a07c021e84d717e6792a74efcf895a7d7188 | [
"MIT"
] | 1,144 | 2018-12-18T09:46:47.000Z | 2022-03-07T14:51:46.000Z | u-boot-2019.01+gitAUTOINC+333c3e72d3-g333c3e72d3/tools/fit_common.c | rlourette/TI_SDK_u-boot-2019.01 | 3000a07c021e84d717e6792a74efcf895a7d7188 | [
"MIT"
] | 16 | 2019-01-28T06:08:40.000Z | 2019-12-04T10:26:41.000Z | u-boot-2019.01+gitAUTOINC+333c3e72d3-g333c3e72d3/tools/fit_common.c | rlourette/TI_SDK_u-boot-2019.01 | 3000a07c021e84d717e6792a74efcf895a7d7188 | [
"MIT"
] | 129 | 2018-12-18T09:46:50.000Z | 2022-03-30T07:30:13.000Z | // SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2014
* DENX Software Engineering
* Heiko Schocher <hs@denx.de>
*
* (C) Copyright 2008 Semihalf
*
* (C) Copyright 2000-2004
* DENX Software Engineering
* Wolfgang Denk, wd@denx.de
*
* Updated-by: Prafulla Wadaskar <prafulla@marvell.com>
* FIT image specific code abstracted from mkimage.c
* some functions added to address abstraction
*
* All rights reserved.
*/
#include "imagetool.h"
#include "mkimage.h"
#include "fit_common.h"
#include <image.h>
#include <u-boot/crc.h>
int fit_verify_header(unsigned char *ptr, int image_size,
struct image_tool_params *params)
{
return fdt_check_header(ptr);
}
int fit_check_image_types(uint8_t type)
{
if (type == IH_TYPE_FLATDT)
return EXIT_SUCCESS;
else
return EXIT_FAILURE;
}
int mmap_fdt(const char *cmdname, const char *fname, size_t size_inc,
void **blobp, struct stat *sbuf, bool delete_on_error)
{
void *ptr;
int fd;
/* Load FIT blob into memory (we need to write hashes/signatures) */
fd = open(fname, O_RDWR | O_BINARY);
if (fd < 0) {
fprintf(stderr, "%s: Can't open %s: %s\n",
cmdname, fname, strerror(errno));
goto err;
}
if (fstat(fd, sbuf) < 0) {
fprintf(stderr, "%s: Can't stat %s: %s\n",
cmdname, fname, strerror(errno));
goto err;
}
if (size_inc) {
sbuf->st_size += size_inc;
if (ftruncate(fd, sbuf->st_size)) {
fprintf(stderr, "%s: Can't expand %s: %s\n",
cmdname, fname, strerror(errno));
goto err;
}
}
errno = 0;
ptr = mmap(0, sbuf->st_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
if ((ptr == MAP_FAILED) || (errno != 0)) {
fprintf(stderr, "%s: Can't read %s: %s\n",
cmdname, fname, strerror(errno));
goto err;
}
/* check if ptr has a valid blob */
if (fdt_check_header(ptr)) {
fprintf(stderr, "%s: Invalid FIT blob\n", cmdname);
goto err;
}
/* expand if needed */
if (size_inc) {
int ret;
ret = fdt_open_into(ptr, ptr, sbuf->st_size);
if (ret) {
fprintf(stderr, "%s: Cannot expand FDT: %s\n",
cmdname, fdt_strerror(ret));
goto err;
}
}
*blobp = ptr;
return fd;
err:
if (fd >= 0)
close(fd);
if (delete_on_error)
unlink(fname);
return -1;
}
| 20.504673 | 71 | 0.650866 |
d9633eef50a4a78fecded564fbb36784f2e1e7e6 | 4,730 | h | C | src/visualizer/visualizer.h | ICRA-2018/fast_change_detection | 502b7e1831ef8de42de07442a847a31f44c8c296 | [
"BSD-2-Clause"
] | null | null | null | src/visualizer/visualizer.h | ICRA-2018/fast_change_detection | 502b7e1831ef8de42de07442a847a31f44c8c296 | [
"BSD-2-Clause"
] | null | null | null | src/visualizer/visualizer.h | ICRA-2018/fast_change_detection | 502b7e1831ef8de42de07442a847a31f44c8c296 | [
"BSD-2-Clause"
] | null | null | null | // Copyright 2017 Jens Behley (jens.behley@igg.uni-bonn.de)
// Emanuele Palazzolo (emanuele.palazzolo@uni-bonn.de)
#pragma once
#include <vector>
#include <glow/glbase.h>
#include <QtCore/QTimer>
#include <QtOpenGL/QGLWidget>
#include <glow/GlUniform.h>
#include <glow/util/FpsCamera.h>
#include <glow/GlTexture.h>
#include <glow/GlSampler.h>
#include "fastcd/mesh.h"
#include "fastcd/camera.h"
namespace fastcd {
/**
* @brief Class for an OpenGL visualization.
*/
class Visualizer : public QGLWidget {
Q_OBJECT
public:
/**
* @brief Constructor.
*/
Visualizer(QWidget* parent = 0, const QGLWidget* shareWidget = 0,
Qt::WindowFlags f = 0);
/**
* @brief Adds a mesh to the 3D world.
*
* @param mesh The mesh
*/
void addMesh(Mesh& mesh);
/**
* @brief Sets the background color.
*
* @param[in] r The red value
* @param[in] g The green value
* @param[in] b The blue value
* @param[in] a The alpha value
*/
void setBackgroundColor(float r, float g, float b, float a);
/**
* @brief Sets the texture to be painted on the 3D model. (for debug
* purpose)
*
* @param texture The texture
*/
void setOutput(glow::GlTexture& texture);
/**
* @brief Adds a camera do be drawn in the 3D world. Its position is also
* a teleport point of the user camera.
*
* @param[in] camera The camera
* @param[in] color The color of the visualized frustum
* @param[in] length The length of the visualized frustum
*/
void addCamera(Camera camera, float color, float length);
/**
* @brief Adds a point to be drawn in the 3D world (as a cross).
*
* @param[in] position The position of the point
* @param[in] size The size of the point
* @param[in] color The color of the point
*/
void addPoint(const Eigen::Vector3f& position, float size, float color);
/**
* @brief Adds a line to be drawn in the 3D world.
*
* @param[in] start The starting point of the line
* @param[in] end The ending point of the line
* @param[in] color The color of the line
*/
void addLine(const Eigen::Vector3f& start, const Eigen::Vector3f& end,
float color);
/**
* @brief Helper fuction that packs the red, green and blue values of a
* color in a single float.
*
* @param[in] r The red value
* @param[in] g The green value
* @param[in] b The blue value
*
* @return The color packed in a single float.
*/
static float rgb2float(float r, float g, float b);
void ShowAxis(bool option);
protected:
bool initContext();
void initializeGL();
void resizeGL(int w, int h);
void paintGL();
void mousePressEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
void keyPressEvent(QKeyEvent* event);
void keyReleaseEvent(QKeyEvent* event);
glow::GlCamera::KeyboardModifier resolveKeyboardModifier(
Qt::KeyboardModifiers modifiers);
glow::GlCamera::MouseButton resolveMouseButton(Qt::MouseButtons button);
glow::GlCamera::KeyboardKey resolveKeyboardKey(Qt::Key key);
// hack to have GLEW initalized before anything else.
bool contextInitialized_;
glow::GlUniform<Eigen::Matrix4f> mvp_{"mvp", Eigen::Matrix4f::Identity()};
glow::GlUniform<Eigen::Matrix4f> mvp_inv_t_{"mvp_inv_t",
Eigen::Matrix4f::Identity()};
QTimer timer_;
glow::FpsCamera camera_;
Eigen::Matrix4f model_{Eigen::Matrix4f::Identity()};
Eigen::Matrix4f view_{Eigen::Matrix4f::Identity()};
Eigen::Matrix4f projection_{Eigen::Matrix4f::Identity()};
std::vector<Mesh> meshes_;
glow::GlProgram prgDrawMesh_;
glow::GlProgram coloredPointProgram_;
glow::GlBuffer<float> coordAxisVBO_{glow::BufferTarget::ARRAY_BUFFER,
glow::BufferUsage::STATIC_DRAW}; // x, y, z, color(float)
glow::GlVertexArray coordAxisVAO_;
std::vector<glow::GlBuffer<float>> linesVBOs_;
std::vector<glow::GlVertexArray> linesVAOs_;
// visualization of the image points.
bool show_output_{false};
glow::GlTexture output_{10, 10, glow::TextureFormat::RGBA_FLOAT};
glow::GlVertexArray vao_img_coords_;
glow::GlBuffer<glow::vec2> vbo_img_coords_{glow::BufferTarget::ARRAY_BUFFER,
glow::BufferUsage::STATIC_DRAW};
glow::GlSampler sampler_;
glow::GlProgram renderPoints_;
std::vector<float> bg_color_{0.0f, 0.0f, 0.0f, 1.0f};
std::vector<Camera> cameras_;
bool show_axis_{true};
};
} // namespace fastcd
| 29.5625 | 94 | 0.647992 |
d96402c4c54056a4af089712ff1aee1639cdd1b4 | 1,103 | h | C | forth/include/stack_machine/entry.h | rm-hull/byok | 8c24ec865f9f8534bf7f9edcb41dc459186ae958 | [
"MIT"
] | 41 | 2015-01-06T08:22:27.000Z | 2022-02-27T18:55:32.000Z | forth/include/stack_machine/entry.h | rm-hull/byok | 8c24ec865f9f8534bf7f9edcb41dc459186ae958 | [
"MIT"
] | 18 | 2015-01-01T18:01:01.000Z | 2019-03-03T19:01:13.000Z | forth/include/stack_machine/entry.h | rm-hull/byok | 8c24ec865f9f8534bf7f9edcb41dc459186ae958 | [
"MIT"
] | 10 | 2015-07-26T22:10:46.000Z | 2022-03-01T09:52:59.000Z | #ifndef _ENTRY_H
#define _ENTRY_H 1
#include <collections/stack.h>
#include <collections/hashtable.h>
#ifdef __cplusplus
extern "C" {
#endif
// Flags
#define FLAG_IMMEDIATE (1<<0)
#define FLAG_USER_DEFINED (1<<1)
#define FLAG_PRIMITIVE (1<<2)
#define FLAG_HIDDEN (1<<3)
#define FLAG_CONSTANT (1<<4)
#define FLAG_VARIABLE (1<<5)
#define is_set(entry, f) ((entry->flags & f) == f)
extern void indent(context_t *ctx);
extern int set_flags(hashtable_t *htbl, char *name, int flags);
extern int add_primitive(hashtable_t *htbl, char *name, state_t (*code_ptr)(context_t *ctx), char *stack_effect, char *docstring);
extern int add_variable(context_t *ctx, char *name, word_t *addr);
extern int add_constant(context_t *ctx, char *name, const int value);
extern int add_word(context_t *ctx, char *name, word_t *addr);
extern int find_entry(hashtable_t *htbl, char *name, entry_t **entry);
extern int entry_hash(const void *data);
extern int entry_match(const void *data1, const void *data2);
extern char **get_words(hashtable_t *htbl);
#ifdef __cplusplus
}
#endif
#endif | 29.026316 | 130 | 0.723481 |
d9648765580f3d83042aeed83cb50d4a0d837e86 | 26 | h | C | base/mvdm/softpc.new/host/inc/hstsystm.h | npocmaka/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 17 | 2020-11-13T13:42:52.000Z | 2021-09-16T09:13:13.000Z | base/mvdm/softpc.new/host/inc/hstsystm.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 2 | 2020-10-19T08:02:06.000Z | 2020-10-19T08:23:18.000Z | base/mvdm/softpc.new/host/inc/hstsystm.h | sancho1952007/Windows-Server-2003 | 5c6fe3db626b63a384230a1aa6b92ac416b0765f | [
"Unlicense"
] | 14 | 2020-11-14T09:43:20.000Z | 2021-08-28T08:59:57.000Z | /* Required for herc.c */
| 13 | 25 | 0.615385 |
d966a6a0f39cc928caeb0e791eeed9387ece625e | 15,235 | h | C | ui/views/metadata/view_factory.h | Yannic/chromium | ab32e8aacb08c9fce0dc4bf09eec456ba46e3710 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | ui/views/metadata/view_factory.h | Yannic/chromium | ab32e8aacb08c9fce0dc4bf09eec456ba46e3710 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | 1 | 2019-03-13T10:32:53.000Z | 2019-03-13T11:05:30.000Z | ui/views/metadata/view_factory.h | Yannic/chromium | ab32e8aacb08c9fce0dc4bf09eec456ba46e3710 | [
"BSD-3-Clause-No-Nuclear-License-2014",
"BSD-3-Clause"
] | null | null | null | // 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 UI_VIEWS_METADATA_VIEW_FACTORY_H_
#define UI_VIEWS_METADATA_VIEW_FACTORY_H_
#include <functional>
#include <map>
#include <memory>
#include <utility>
#include <vector>
#include "base/compiler_specific.h"
#include "ui/base/class_property.h"
#include "ui/base/metadata/base_type_conversion.h"
#include "ui/views/metadata/view_factory_internal.h"
#include "ui/views/views_export.h"
namespace views {
template <typename Builder>
class BaseViewBuilderT : public internal::ViewBuilderCore {
public:
using ViewClass_ = typename internal::ViewClassTrait<Builder>::ViewClass_;
BaseViewBuilderT() { view_ = std::make_unique<ViewClass_>(); }
explicit BaseViewBuilderT(ViewClass_* root_view) : root_view_(root_view) {}
BaseViewBuilderT(BaseViewBuilderT&&) = default;
BaseViewBuilderT& operator=(BaseViewBuilderT&&) = default;
~BaseViewBuilderT() override = default;
template <typename View>
Builder& CopyAddressTo(View** view_address) & {
*view_address = view_ ? view_.get() : root_view_;
return *static_cast<Builder*>(this);
}
template <typename View>
Builder&& CopyAddressTo(View** view_address) && {
return std::move(this->CopyAddressTo(view_address));
}
template <typename Child>
Builder& AddChild(Child&& child) & {
children_.emplace_back(child.Release());
return *static_cast<Builder*>(this);
}
template <typename Child>
Builder&& AddChild(Child&& child) && {
return std::move(this->AddChild(std::move(child)));
}
template <typename Child, typename... Types>
Builder& AddChildren(Child&& child, Types&&... args) & {
return AddChildrenImpl(&child, &args...);
}
template <typename Child, typename... Types>
Builder&& AddChildren(Child&& child, Types&&... args) && {
return std::move(this->AddChildrenImpl(&child, &args...));
}
std::unique_ptr<ViewClass_> Build() && WARN_UNUSED_RESULT {
DCHECK(!root_view_) << "Root view specified. Use BuildChildren() instead.";
DCHECK(view_);
SetProperties(view_.get());
CreateChildren(view_.get());
return std::move(view_);
}
void BuildChildren() && {
DCHECK(!view_) << "Default constructor called. Use Build() instead.";
DCHECK(root_view_);
SetProperties(root_view_);
CreateChildren(root_view_);
}
template <typename T>
Builder& SetProperty(const ui::ClassProperty<T>* property,
ui::metadata::ArgType<T> value) & {
auto setter =
std::make_unique<internal::ClassPropertyValueSetter<ViewClass_, T>>(
property, value);
internal::ViewBuilderCore::AddPropertySetter(std::move(setter));
return *static_cast<Builder*>(this);
}
template <typename T>
Builder&& SetProperty(const ui::ClassProperty<T>* property,
ui::metadata::ArgType<T> value) && {
return std::move(this->SetProperty(property, value));
}
template <typename T>
Builder& SetProperty(const ui::ClassProperty<T*>* property,
ui::metadata::ArgType<T> value) & {
auto setter =
std::make_unique<internal::ClassPropertyMoveSetter<ViewClass_, T>>(
property, value);
internal::ViewBuilderCore::AddPropertySetter(std::move(setter));
return *static_cast<Builder*>(this);
}
template <typename T>
Builder&& SetProperty(const ui::ClassProperty<T*>* property,
ui::metadata::ArgType<T> value) && {
return std::move(this->SetProperty(property, value));
}
template <typename T>
Builder& SetProperty(const ui::ClassProperty<T*>* property, T&& value) & {
auto setter =
std::make_unique<internal::ClassPropertyMoveSetter<ViewClass_, T>>(
property, std::move(value));
internal::ViewBuilderCore::AddPropertySetter(std::move(setter));
return *static_cast<Builder*>(this);
}
template <typename T>
Builder&& SetProperty(const ui::ClassProperty<T*>* property, T&& value) && {
return std::move(this->SetProperty(property, value));
}
template <typename T>
Builder& SetProperty(const ui::ClassProperty<T*>* property,
std::unique_ptr<T> value) & {
auto setter =
std::make_unique<internal::ClassPropertyUniquePtrSetter<ViewClass_, T>>(
property, std::move(value));
internal::ViewBuilderCore::AddPropertySetter(std::move(setter));
return *static_cast<Builder*>(this);
}
template <typename T>
Builder&& SetProperty(const ui::ClassProperty<T*>* property,
std::unique_ptr<T> value) && {
return std::move(this->SetProperty(property, std::move(value)));
}
protected:
// Internal implementation which iterates over all the parameters without
// resorting to recursion which can lead to more code generation.
template <typename... Args>
Builder& AddChildrenImpl(Args*... args) & {
std::vector<internal::ViewBuilderCore*> children = {args...};
for (auto* child : children)
children_.emplace_back(child->Release());
return *static_cast<Builder*>(this);
}
std::unique_ptr<View> DoBuild() override { return std::move(*this).Build(); }
// Owned and meaningful during the Builder building process. Its
// ownership will be transferred out upon Build() call.
std::unique_ptr<ViewClass_> view_;
// Unowned root view. Used for creating a builder with an existing root
// instance.
ViewClass_* root_view_ = nullptr;
};
} // namespace views
// Example of builder class generated by the following macros.
//
// template <typename Builder, typename ViewClass>
// class ViewBuilderT : public BaseViewBuilderT<Builder, ViewClass> {
// public:
// ViewBuilderT() = default;
// ViewBuilderT(const ViewBuilderT&&) = default;
// ViewBuilderT& operator=(const ViewBuilderT&&) = default;
// ~ViewBuilderT() override = default;
//
// Builder& SetEnabled(bool value) {
// auto setter = std::make_unique<
// PropertySetter<ViewClass, bool, decltype(&ViewClass::SetEnabled),
// &ViewClass::SetEnabled>>(value);
// ViewBuilderCore::AddPropertySetter(std::move(setter));
// return *static_cast<Builder*>(this);
// }
//
// Builder& SetVisible(bool value) {
// auto setter = std::make_unique<
// PropertySetter<ViewClass, bool, &ViewClass::SetVisible>>(value);
// ViewBuilderCore::AddPropertySetter(std::move(setter));
// return *static_cast<Builder*>(this);
// }
// };
//
// class VIEWS_EXPORT ViewBuilderTest
// : public ViewBuilderT<ViewBuilderTest, View> {};
//
// template <typename Builder, typename ViewClass>
// class LabelButtonBuilderT : public ViewBuilderT<Builder, ViewClass> {
// public:
// LabelButtonBuilderT() = default;
// LabelButtonBuilderT(LabelButtonBuilderT&&) = default;
// LabelButtonBuilderT& operator=(LabelButtonBuilderT&&) = default;
// ~LabelButtonBuilderT() override = default;
//
// Builder& SetIsDefault(bool value) {
// auto setter = std::make_unique<
// PropertySetter<ViewClass, bool, decltype(&ViewClass::SetIsDefault),
// &ViewClass::SetIsDefault>>(value);
// ViewBuilderCore::AddPropertySetter(std::move(setter));
// return *static_cast<Builder*>(this);
// }
// };
//
// class VIEWS_EXPORT LabelButtonBuilder
// : public LabelButtonBuilderT<LabelButtonBuilder, LabelButton> {};
// BEGIN_VIEW_BUILDER, END_VIEW_BUILDER and VIEW_BUILDER_XXXX macros should
// be placed into the same namespace as the 'view_class' parameter.
#define BEGIN_VIEW_BUILDER(export, view_class, ancestor) \
template <typename BuilderT> \
class export view_class##BuilderT : public ancestor##BuilderT<BuilderT> { \
private: \
using ViewClass_ = view_class; \
\
public: \
view_class##BuilderT() = default; \
explicit view_class##BuilderT( \
typename ::views::internal::ViewClassTrait<BuilderT>::ViewClass_* \
root_view) \
: ancestor##BuilderT<BuilderT>(root_view) {} \
view_class##BuilderT(view_class##BuilderT&&) = default; \
view_class##BuilderT& operator=(view_class##BuilderT&&) = default; \
~view_class##BuilderT() override = default;
#define VIEW_BUILDER_PROPERTY(property_type, property_name) \
BuilderT& Set##property_name( \
::ui::metadata::ArgType<property_type> value)& { \
auto setter = std::make_unique<::views::internal::PropertySetter< \
ViewClass_, property_type, decltype(&ViewClass_::Set##property_name), \
&ViewClass_::Set##property_name>>(std::move(value)); \
::views::internal::ViewBuilderCore::AddPropertySetter(std::move(setter)); \
return *static_cast<BuilderT*>(this); \
} \
BuilderT&& Set##property_name( \
::ui::metadata::ArgType<property_type> value)&& { \
return std::move(this->Set##property_name(std::move(value))); \
}
#define VIEW_BUILDER_METHOD(method_name) \
BuilderT& method_name()& { \
auto caller = std::make_unique<::views::internal::ClassMethodCaller< \
ViewClass_, decltype(&ViewClass_::method_name), \
&ViewClass_::method_name>>(); \
::views::internal::ViewBuilderCore::AddPropertySetter(std::move(caller)); \
return *static_cast<BuilderT*>(this); \
} \
BuilderT&& method_name()&& { return std::move(this->method_name()); }
#define VIEW_BUILDER_VIEW_TYPE_PROPERTY(property_type, property_name) \
template <typename _View> \
BuilderT& Set##property_name(_View&& view)& { \
auto setter = std::make_unique<::views::internal::ViewBuilderSetter< \
ViewClass_, property_type, \
decltype(&ViewClass_::Set##property_name<property_type>), \
&ViewClass_::Set##property_name<property_type>>>(view.Release()); \
::views::internal::ViewBuilderCore::AddPropertySetter(std::move(setter)); \
return *static_cast<BuilderT*>(this); \
} \
template <typename _View> \
BuilderT&& Set##property_name(_View&& view)&& { \
return std::move(this->Set##property_name(std::move(view))); \
}
#define VIEW_BUILDER_VIEW_PROPERTY(property_type, property_name) \
template <typename _View> \
BuilderT& Set##property_name(_View&& view)& { \
auto setter = std::make_unique<::views::internal::ViewBuilderSetter< \
ViewClass_, property_type, decltype(&ViewClass_::Set##property_name), \
&ViewClass_::Set##property_name>>(view.Release()); \
::views::internal::ViewBuilderCore::AddPropertySetter(std::move(setter)); \
return *static_cast<BuilderT*>(this); \
} \
template <typename _View> \
BuilderT&& Set##property_name(_View&& view)&& { \
return std::move(this->Set##property_name(std::move(view))); \
}
#define VIEW_BUILDER_PROPERTY_DEFAULT(property_type, property_name, default) \
BuilderT& Set##property_name(::ui::metadata::ArgType<property_type> value = \
default)& { \
auto setter = std::make_unique<::views::internal::PropertySetter< \
ViewClass_, property_type, decltype(&ViewClass_::Set##property_name), \
&ViewClass_::Set##property_name>>(std::move(value)); \
::views::internal::ViewBuilderCore::AddPropertySetter(std::move(setter)); \
return *static_cast<BuilderT*>(this); \
} \
BuilderT&& Set##property_name(::ui::metadata::ArgType<property_type> value = \
default)&& { \
return std::move(this->Set##property_name(value)); \
}
// Turn off clang-format due to it messing up the following macro. Places the
// semi-colon on a separate line.
// clang-format off
#define END_VIEW_BUILDER };
// Unlike the above macros, DEFINE_VIEW_BUILDER must be placed in the global
// namespace. Unless 'view_class' is already in the 'views' namespace, it should
// be fully qualified with the namespace in which it lives.
#define DEFINE_VIEW_BUILDER(export, view_class) \
namespace views { \
template <> \
class export Builder<view_class> \
: public view_class##BuilderT<Builder<view_class>> { \
private: \
using ViewClass_ = view_class; \
public: \
Builder<ViewClass_>() = default; \
explicit Builder<ViewClass_>(ViewClass_* root_view) \
: view_class##BuilderT<Builder<ViewClass_>>(root_view) {} \
Builder<ViewClass_>(Builder&&) = default; \
Builder<ViewClass_>& operator=(Builder<ViewClass_>&&) = default; \
~Builder<ViewClass_>() = default; \
std::unique_ptr<internal::ViewBuilderCore> Release() override \
WARN_UNUSED_RESULT { \
return std::make_unique<Builder<view_class>>(std::move(*this)); \
} \
}; \
} // namespace views
// clang-format on
#endif // UI_VIEWS_METADATA_VIEW_FACTORY_H_
| 45.613772 | 80 | 0.567575 |
d9670fb3f8f010ae82b97b3102cb9f496070dedf | 9,774 | c | C | FreeBSD/sys/dev/qlxgb/qla_isr.c | TigerBSD/FreeBSD-Custom-ThinkPad | 3d092f261b362f73170871403397fc5d6b89d1dc | [
"0BSD"
] | 4 | 2016-08-22T22:02:55.000Z | 2017-03-04T22:56:44.000Z | FreeBSD/sys/dev/qlxgb/qla_isr.c | TigerBSD/FreeBSD-Custom-ThinkPad | 3d092f261b362f73170871403397fc5d6b89d1dc | [
"0BSD"
] | 21 | 2016-08-11T09:43:43.000Z | 2017-01-29T12:52:56.000Z | FreeBSD/sys/dev/qlxgb/qla_isr.c | TigerBSD/TigerBSD | 3d092f261b362f73170871403397fc5d6b89d1dc | [
"0BSD"
] | null | null | null | /*
* Copyright (c) 2011-2013 Qlogic Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 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.
*/
/*
* File: qla_isr.c
* Author : David C Somayajulu, Qlogic Corporation, Aliso Viejo, CA 92656.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "qla_os.h"
#include "qla_reg.h"
#include "qla_hw.h"
#include "qla_def.h"
#include "qla_inline.h"
#include "qla_ver.h"
#include "qla_glbl.h"
#include "qla_dbg.h"
static void qla_replenish_normal_rx(qla_host_t *ha, qla_sds_t *sdsp);
static void qla_replenish_jumbo_rx(qla_host_t *ha, qla_sds_t *sdsp);
/*
* Name: qla_rx_intr
* Function: Handles normal ethernet frames received
*/
static void
qla_rx_intr(qla_host_t *ha, uint64_t data, uint32_t sds_idx,
struct lro_ctrl *lro)
{
uint32_t idx, length, status, ring;
qla_rx_buf_t *rxb;
struct mbuf *mp;
struct ifnet *ifp = ha->ifp;
qla_sds_t *sdsp;
struct ether_vlan_header *eh;
sdsp = &ha->hw.sds[sds_idx];
ring = (uint32_t)Q8_STAT_DESC_TYPE(data);
idx = (uint32_t)Q8_STAT_DESC_HANDLE(data);
length = (uint32_t)Q8_STAT_DESC_TOTAL_LENGTH(data);
status = (uint32_t)Q8_STAT_DESC_STATUS(data);
if (ring == 0) {
if ((idx >= NUM_RX_DESCRIPTORS) || (length > MCLBYTES)) {
device_printf(ha->pci_dev, "%s: ring[%d] index[0x%08x]"
" len[0x%08x] invalid\n",
__func__, ring, idx, length);
return;
}
} else {
if ((idx >= NUM_RX_JUMBO_DESCRIPTORS)||(length > MJUM9BYTES)) {
device_printf(ha->pci_dev, "%s: ring[%d] index[0x%08x]"
" len[0x%08x] invalid\n",
__func__, ring, idx, length);
return;
}
}
if (ring == 0)
rxb = &ha->rx_buf[idx];
else
rxb = &ha->rx_jbuf[idx];
QL_ASSERT((rxb != NULL),\
("%s: [r, i, sds_idx]=[%d, 0x%x, %d] rxb != NULL\n",\
__func__, ring, idx, sds_idx));
mp = rxb->m_head;
QL_ASSERT((mp != NULL),\
("%s: [r,i,rxb, sds_idx]=[%d, 0x%x, %p, %d] mp != NULL\n",\
__func__, ring, idx, rxb, sds_idx));
bus_dmamap_sync(ha->rx_tag, rxb->map, BUS_DMASYNC_POSTREAD);
if (ring == 0) {
rxb->m_head = NULL;
rxb->next = sdsp->rxb_free;
sdsp->rxb_free = rxb;
sdsp->rx_free++;
} else {
rxb->m_head = NULL;
rxb->next = sdsp->rxjb_free;
sdsp->rxjb_free = rxb;
sdsp->rxj_free++;
}
mp->m_len = length;
mp->m_pkthdr.len = length;
mp->m_pkthdr.rcvif = ifp;
eh = mtod(mp, struct ether_vlan_header *);
if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) {
uint32_t *data = (uint32_t *)eh;
mp->m_pkthdr.ether_vtag = ntohs(eh->evl_tag);
mp->m_flags |= M_VLANTAG;
*(data + 3) = *(data + 2);
*(data + 2) = *(data + 1);
*(data + 1) = *data;
m_adj(mp, ETHER_VLAN_ENCAP_LEN);
}
if (status == Q8_STAT_DESC_STATUS_CHKSUM_OK) {
mp->m_pkthdr.csum_flags = (CSUM_IP_CHECKED | CSUM_IP_VALID);
} else {
mp->m_pkthdr.csum_flags = 0;
}
if (lro->lro_cnt && (tcp_lro_rx(lro, mp, 0) == 0)) {
/* LRO packet has been successfully queued */
} else {
(*ifp->if_input)(ifp, mp);
}
if (sdsp->rx_free > std_replenish)
qla_replenish_normal_rx(ha, sdsp);
if (sdsp->rxj_free > jumbo_replenish)
qla_replenish_jumbo_rx(ha, sdsp);
return;
}
static void
qla_replenish_jumbo_rx(qla_host_t *ha, qla_sds_t *sdsp)
{
qla_rx_buf_t *rxb;
int count = jumbo_replenish;
uint32_t rxj_next;
if (!mtx_trylock(&ha->rxj_lock))
return;
rxj_next = ha->hw.rxj_next;
while (count--) {
rxb = sdsp->rxjb_free;
if (rxb == NULL)
break;
sdsp->rxjb_free = rxb->next;
sdsp->rxj_free--;
if (qla_get_mbuf(ha, rxb, NULL, RDS_RING_INDEX_JUMBO) == 0) {
qla_set_hw_rcv_desc(ha, RDS_RING_INDEX_JUMBO,
ha->hw.rxj_in, rxb->handle, rxb->paddr,
(rxb->m_head)->m_pkthdr.len);
ha->hw.rxj_in++;
if (ha->hw.rxj_in == NUM_RX_JUMBO_DESCRIPTORS)
ha->hw.rxj_in = 0;
ha->hw.rxj_next++;
if (ha->hw.rxj_next == NUM_RX_JUMBO_DESCRIPTORS)
ha->hw.rxj_next = 0;
} else {
device_printf(ha->pci_dev,
"%s: qla_get_mbuf [1,(%d),(%d)] failed\n",
__func__, ha->hw.rxj_in, rxb->handle);
rxb->m_head = NULL;
rxb->next = sdsp->rxjb_free;
sdsp->rxjb_free = rxb;
sdsp->rxj_free++;
break;
}
}
if (rxj_next != ha->hw.rxj_next) {
QL_UPDATE_RDS_PRODUCER_INDEX(ha, 1, ha->hw.rxj_next);
}
mtx_unlock(&ha->rxj_lock);
}
static void
qla_replenish_normal_rx(qla_host_t *ha, qla_sds_t *sdsp)
{
qla_rx_buf_t *rxb;
int count = std_replenish;
uint32_t rx_next;
if (!mtx_trylock(&ha->rx_lock))
return;
rx_next = ha->hw.rx_next;
while (count--) {
rxb = sdsp->rxb_free;
if (rxb == NULL)
break;
sdsp->rxb_free = rxb->next;
sdsp->rx_free--;
if (qla_get_mbuf(ha, rxb, NULL, RDS_RING_INDEX_NORMAL) == 0) {
qla_set_hw_rcv_desc(ha, RDS_RING_INDEX_NORMAL,
ha->hw.rx_in, rxb->handle, rxb->paddr,
(rxb->m_head)->m_pkthdr.len);
ha->hw.rx_in++;
if (ha->hw.rx_in == NUM_RX_DESCRIPTORS)
ha->hw.rx_in = 0;
ha->hw.rx_next++;
if (ha->hw.rx_next == NUM_RX_DESCRIPTORS)
ha->hw.rx_next = 0;
} else {
device_printf(ha->pci_dev,
"%s: qla_get_mbuf [0,(%d),(%d)] failed\n",
__func__, ha->hw.rx_in, rxb->handle);
rxb->m_head = NULL;
rxb->next = sdsp->rxb_free;
sdsp->rxb_free = rxb;
sdsp->rx_free++;
break;
}
}
if (rx_next != ha->hw.rx_next) {
QL_UPDATE_RDS_PRODUCER_INDEX(ha, 0, ha->hw.rx_next);
}
mtx_unlock(&ha->rx_lock);
}
/*
* Name: qla_isr
* Function: Main Interrupt Service Routine
*/
static uint32_t
qla_rcv_isr(qla_host_t *ha, uint32_t sds_idx, uint32_t count)
{
device_t dev;
qla_hw_t *hw;
uint32_t comp_idx, desc_count;
q80_stat_desc_t *sdesc;
struct lro_ctrl *lro;
uint32_t ret = 0;
dev = ha->pci_dev;
hw = &ha->hw;
hw->sds[sds_idx].rcv_active = 1;
if (ha->flags.stop_rcv) {
hw->sds[sds_idx].rcv_active = 0;
return 0;
}
QL_DPRINT2((dev, "%s: [%d]enter\n", __func__, sds_idx));
/*
* receive interrupts
*/
comp_idx = hw->sds[sds_idx].sdsr_next;
lro = &hw->sds[sds_idx].lro;
while (count--) {
sdesc = (q80_stat_desc_t *)
&hw->sds[sds_idx].sds_ring_base[comp_idx];
if (Q8_STAT_DESC_OWNER((sdesc->data[0])) !=
Q8_STAT_DESC_OWNER_HOST) {
QL_DPRINT2((dev, "%s: data %p sdsr_next 0x%08x\n",
__func__, (void *)sdesc->data[0], comp_idx));
break;
}
desc_count = Q8_STAT_DESC_COUNT((sdesc->data[0]));
switch (Q8_STAT_DESC_OPCODE((sdesc->data[0]))) {
case Q8_STAT_DESC_OPCODE_RCV_PKT:
case Q8_STAT_DESC_OPCODE_SYN_OFFLOAD:
qla_rx_intr(ha, (sdesc->data[0]), sds_idx, lro);
break;
default:
device_printf(dev, "%s: default 0x%llx!\n", __func__,
(long long unsigned int)sdesc->data[0]);
break;
}
while (desc_count--) {
sdesc->data[0] =
Q8_STAT_DESC_SET_OWNER(Q8_STAT_DESC_OWNER_FW);
comp_idx = (comp_idx + 1) & (NUM_STATUS_DESCRIPTORS-1);
sdesc = (q80_stat_desc_t *)
&hw->sds[sds_idx].sds_ring_base[comp_idx];
}
}
tcp_lro_flush_all(lro);
if (hw->sds[sds_idx].sdsr_next != comp_idx) {
QL_UPDATE_SDS_CONSUMER_INDEX(ha, sds_idx, comp_idx);
}
hw->sds[sds_idx].sdsr_next = comp_idx;
sdesc = (q80_stat_desc_t *)&hw->sds[sds_idx].sds_ring_base[comp_idx];
if ((sds_idx == 0) && (Q8_STAT_DESC_OWNER((sdesc->data[0])) ==
Q8_STAT_DESC_OWNER_HOST)) {
ret = -1;
}
hw->sds[sds_idx].rcv_active = 0;
return (ret);
}
void
qla_isr(void *arg)
{
qla_ivec_t *ivec = arg;
qla_host_t *ha;
uint32_t sds_idx;
uint32_t ret;
ha = ivec->ha;
sds_idx = ivec->irq_rid - 1;
if (sds_idx >= ha->hw.num_sds_rings) {
device_printf(ha->pci_dev, "%s: bogus sds_idx 0x%x\n", __func__,
sds_idx);
return;
}
if (sds_idx == 0)
taskqueue_enqueue(ha->tx_tq, &ha->tx_task);
ret = qla_rcv_isr(ha, sds_idx, rcv_pkt_thres);
if (sds_idx == 0)
taskqueue_enqueue(ha->tx_tq, &ha->tx_task);
if (ret) {
taskqueue_enqueue(ha->irq_vec[sds_idx].rcv_tq,
&ha->irq_vec[sds_idx].rcv_task);
} else {
QL_ENABLE_INTERRUPTS(ha, sds_idx);
}
}
void
qla_rcv(void *context, int pending)
{
qla_ivec_t *ivec = context;
qla_host_t *ha;
device_t dev;
qla_hw_t *hw;
uint32_t sds_idx;
uint32_t ret;
struct ifnet *ifp;
ha = ivec->ha;
dev = ha->pci_dev;
hw = &ha->hw;
sds_idx = ivec->irq_rid - 1;
ifp = ha->ifp;
do {
if (sds_idx == 0) {
if (qla_le32_to_host(*(hw->tx_cons)) != hw->txr_comp) {
taskqueue_enqueue(ha->tx_tq, &ha->tx_task);
} else if ((ifp->if_snd.ifq_head != NULL) &&
QL_RUNNING(ifp)) {
taskqueue_enqueue(ha->tx_tq, &ha->tx_task);
}
}
ret = qla_rcv_isr(ha, sds_idx, rcv_pkt_thres_d);
} while (ret);
if (sds_idx == 0)
taskqueue_enqueue(ha->tx_tq, &ha->tx_task);
QL_ENABLE_INTERRUPTS(ha, sds_idx);
}
| 23.723301 | 79 | 0.665439 |
d967354842c2ef083543061612e5143ed7701c8a | 445 | c | C | ccan/ccan/tal/str/test/run-strndup.c | AYCH-Inc/aych.bitlight.network | 3bd90a49509cb7da7bcc6f174930923770ec00f0 | [
"MIT"
] | null | null | null | ccan/ccan/tal/str/test/run-strndup.c | AYCH-Inc/aych.bitlight.network | 3bd90a49509cb7da7bcc6f174930923770ec00f0 | [
"MIT"
] | null | null | null | ccan/ccan/tal/str/test/run-strndup.c | AYCH-Inc/aych.bitlight.network | 3bd90a49509cb7da7bcc6f174930923770ec00f0 | [
"MIT"
] | null | null | null | #include <ccan/tal/str/str.h>
#include <stdlib.h>
#include <stdio.h>
#include <ccan/tal/str/str.c>
#include <ccan/tap/tap.h>
#include "helper.h"
int main(int argc, char *argv[])
{
char *str, *copy;
plan_tests(1);
str = malloc(5);
memcpy(str, "hello", 5);
/* We should be fine to strndup src without nul terminator. */
copy = tal_strndup(NULL, str, 5);
ok1(!strcmp(copy, "hello"));
tal_free(copy);
free(str);
return exit_status();
}
| 19.347826 | 63 | 0.658427 |
d9678fa914b9ba642fab2b466bf05a2cd62a16b8 | 2,628 | h | C | Zend/zend_language_parser.h | ferrolad/php4 | 9b990badc1fe9de2fc9a9a4794e341e4eb9f886c | [
"PHP-3.0"
] | null | null | null | Zend/zend_language_parser.h | ferrolad/php4 | 9b990badc1fe9de2fc9a9a4794e341e4eb9f886c | [
"PHP-3.0"
] | null | null | null | Zend/zend_language_parser.h | ferrolad/php4 | 9b990badc1fe9de2fc9a9a4794e341e4eb9f886c | [
"PHP-3.0"
] | null | null | null | #ifndef YYSTYPE
#define YYSTYPE int
#endif
#define T_INCLUDE 257
#define T_INCLUDE_ONCE 258
#define T_EVAL 259
#define T_REQUIRE 260
#define T_REQUIRE_ONCE 261
#define T_LOGICAL_OR 262
#define T_LOGICAL_XOR 263
#define T_LOGICAL_AND 264
#define T_PRINT 265
#define T_PLUS_EQUAL 266
#define T_MINUS_EQUAL 267
#define T_MUL_EQUAL 268
#define T_DIV_EQUAL 269
#define T_CONCAT_EQUAL 270
#define T_MOD_EQUAL 271
#define T_AND_EQUAL 272
#define T_OR_EQUAL 273
#define T_XOR_EQUAL 274
#define T_SL_EQUAL 275
#define T_SR_EQUAL 276
#define T_BOOLEAN_OR 277
#define T_BOOLEAN_AND 278
#define T_IS_EQUAL 279
#define T_IS_NOT_EQUAL 280
#define T_IS_IDENTICAL 281
#define T_IS_NOT_IDENTICAL 282
#define T_IS_SMALLER_OR_EQUAL 283
#define T_IS_GREATER_OR_EQUAL 284
#define T_SL 285
#define T_SR 286
#define T_INC 287
#define T_DEC 288
#define T_INT_CAST 289
#define T_DOUBLE_CAST 290
#define T_STRING_CAST 291
#define T_ARRAY_CAST 292
#define T_OBJECT_CAST 293
#define T_BOOL_CAST 294
#define T_UNSET_CAST 295
#define T_NEW 296
#define T_EXIT 297
#define T_IF 298
#define T_ELSEIF 299
#define T_ELSE 300
#define T_ENDIF 301
#define T_LNUMBER 302
#define T_DNUMBER 303
#define T_STRING 304
#define T_STRING_VARNAME 305
#define T_VARIABLE 306
#define T_NUM_STRING 307
#define T_INLINE_HTML 308
#define T_CHARACTER 309
#define T_BAD_CHARACTER 310
#define T_ENCAPSED_AND_WHITESPACE 311
#define T_CONSTANT_ENCAPSED_STRING 312
#define T_ECHO 313
#define T_DO 314
#define T_WHILE 315
#define T_ENDWHILE 316
#define T_FOR 317
#define T_ENDFOR 318
#define T_FOREACH 319
#define T_ENDFOREACH 320
#define T_DECLARE 321
#define T_ENDDECLARE 322
#define T_AS 323
#define T_SWITCH 324
#define T_ENDSWITCH 325
#define T_CASE 326
#define T_DEFAULT 327
#define T_BREAK 328
#define T_CONTINUE 329
#define T_OLD_FUNCTION 330
#define T_FUNCTION 331
#define T_CONST 332
#define T_RETURN 333
#define T_USE 334
#define T_GLOBAL 335
#define T_STATIC 336
#define T_VAR 337
#define T_UNSET 338
#define T_ISSET 339
#define T_EMPTY 340
#define T_CLASS 341
#define T_EXTENDS 342
#define T_OBJECT_OPERATOR 343
#define T_DOUBLE_ARROW 344
#define T_LIST 345
#define T_ARRAY 346
#define T_CLASS_C 347
#define T_FUNC_C 348
#define T_LINE 349
#define T_FILE 350
#define T_COMMENT 351
#define T_ML_COMMENT 352
#define T_OPEN_TAG 353
#define T_OPEN_TAG_WITH_ECHO 354
#define T_CLOSE_TAG 355
#define T_WHITESPACE 356
#define T_START_HEREDOC 357
#define T_END_HEREDOC 358
#define T_DOLLAR_OPEN_CURLY_BRACES 359
#define T_CURLY_OPEN 360
#define T_PAAMAYIM_NEKUDOTAYIM 361
| 23.890909 | 39 | 0.794901 |
d968254d02c5e41dbd453dacb72c3d7cedd655e8 | 5,363 | h | C | src/ja3.h | jgru/libja3 | 988b10e4be114d779fe1a23cd00150f93fc394a5 | [
"BSD-3-Clause"
] | 1 | 2021-07-06T20:02:21.000Z | 2021-07-06T20:02:21.000Z | src/ja3.h | jgru/libja3 | 988b10e4be114d779fe1a23cd00150f93fc394a5 | [
"BSD-3-Clause"
] | null | null | null | src/ja3.h | jgru/libja3 | 988b10e4be114d779fe1a23cd00150f93fc394a5 | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright (c) 2021 Jan Gru
* All rights reserved.
* BSD 3-Clause License
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef JA3_H
#define JA3_H
#include <stdlib.h>
//#include <stdint.h>
/* Network specific headers */
#include <arpa/inet.h>
#include <pcap.h>
/* 16 bytes length of hashes ja3 string equals 32 characters hex representation */
#define JA3HASH_LEN 0x10
#define JA3HEXSTR_LEN 0x21
/* Define type of JA3*/
typedef enum ja3_type{SERVER, CLIENT, NIL} ja3_type;
/* TLS record */
struct tls_handshake_record {
/* Pointer to TCP payload data of type TLS record */
u_char* payload;
/* Total length of the record*/
u_int32_t payload_len;
};
/* Information on connection */
struct tls_connection{
/* Source IP address */
char ip_src[INET6_ADDRSTRLEN];
/* Destination IP address */
char ip_dst[INET6_ADDRSTRLEN];
/* Timestamp of packet */
struct timeval tv;
/* Source port */
u_int16_t port_src;
/* Destination port */
u_int16_t port_dst;
/* TLS record */
struct tls_handshake_record* record;
};
struct ja3_struct {
/* Server (ja3s) or client (ja3) */
enum ja3_type t;
/* JA3 string */
char *ja3str;
/* Length of ja3str */
u_int16_t ja3str_len;
/* JA3(S) hash, MD5 ja3-string as bytes */
u_int8_t ja3hash[JA3HASH_LEN];
/* JA3 hash as hex string (32 chars + \0*/
char ja3hexstr[JA3HEXSTR_LEN];
};
struct ja3_context {
/* Information on connection information */
struct tls_connection *conn;
/* JA3 hash */
struct ja3_struct *ja3;
};
/* Takes a packet and returns a JA3 hex-string, if it is a TLS handshake msg
*
* Convenience method for cases, where only JA3 hexadecimal string is of interest
* and connection info and the like is not needed.
*/
ja3_type get_ja3_hexstr_from_pkt(const struct pcap_pkthdr *pkthdr, const u_char *packet, char **result);
/* Takes a packet and returns a human-readable JA3-string, if it is a TLS handshake msg
*
* Convenience method for cases, where only the human-readable JA3 string is of interest
* and connection info and the like is not needed.
*/
ja3_type get_ja3_str_from_pkt(const struct pcap_pkthdr *pkthdr, const u_char *packet, char **result);
/* Checks, a given TCP segment for the presence of TLS handshake data and calculates
* JA3 hex-string, if it is a TLS handshake msg
*
* Convenience method for cases, where only JA3 hexadecimal string is of interest
* and connection info and the like is not needed.
*/
ja3_type get_ja3_hexstr_from_segment(const u_char *payload, uint payload_len, char **result);
/* Checks, a given TCP segment for the presence of TLS handshake data and calculates
* human-readable JA3string, if it is a TLS handshake msg
*
* Convenience method for cases, where only the human-readable JA3 string is of interest
* and connection info and the like is not needed.
*/
ja3_type get_ja3_str_from_segment(const u_char *payload, uint payload_len, char **result);
/* Takes a packet and populates a ja3_context, if it is a TLS handshake msg */
int get_ja3_context_from_pkt(const struct pcap_pkthdr *pkthdr, const u_char *packet, struct ja3_context **result);
/* Checks, a given TLS record and populates a ja3_context, if it is a TLS handshake msg*/
int get_ja3_struct_from_segment(const u_char *payload, uint payload_len, struct ja3_struct **result);
/* Takes a packet and populates a pointer to the TLS part of the packet */
int get_tls_handshake_from_pkt(const struct pcap_pkthdr *pkthdr, const u_char *packet, struct tls_connection **result);
/* Cleans up ja3ctx */
void free_ja3_context(struct ja3_context *ja3ctx);
/* Cleans up ja3struct */
void free_ja3_struct(struct ja3_struct *ja3);
/* Cleans up tls_connection struct */
void free_tls_connection(struct tls_connection *tc);
/* Cleans up tls_handshake_record struct */
void free_tls_handshake_record(struct tls_handshake_record *thr);
#endif /* !JA3_H */
| 36.482993 | 119 | 0.749394 |
d96985c2a3b3856d888d7c26853d4221b0e50385 | 1,526 | h | C | lib/include/usart/Uart4.h | AIHZP/andysworkshop-stm32plus | 8f7868bf30e9df7df38004597a0430d1fe5d0370 | [
"BSD-3-Clause"
] | 607 | 2015-01-06T18:38:17.000Z | 2022-03-19T18:37:09.000Z | lib/include/usart/Uart4.h | AIHZP/andysworkshop-stm32plus | 8f7868bf30e9df7df38004597a0430d1fe5d0370 | [
"BSD-3-Clause"
] | 148 | 2015-01-02T11:34:15.000Z | 2021-05-10T05:15:30.000Z | lib/include/usart/Uart4.h | AIHZP/andysworkshop-stm32plus | 8f7868bf30e9df7df38004597a0430d1fe5d0370 | [
"BSD-3-Clause"
] | 203 | 2015-01-10T14:24:58.000Z | 2022-03-25T16:08:57.000Z | /*
* This file is a part of the open source stm32plus library.
* Copyright (c) 2011,2012,2013,2014 Andy Brown <www.andybrown.me.uk>
* Please see website for licensing terms.
*/
#pragma once
namespace stm32plus {
/**
* Generic class for any pin package
*/
template<class TPinPackage,class... Features>
struct Uart4_Custom : UsartPeripheral<TPinPackage,PERIPHERAL_UART4>,
Features... {
/**
* Constructor
* @param params Initialisation parameters
*/
Uart4_Custom(const typename UsartPeripheral<TPinPackage,PERIPHERAL_UART4>::Parameters& params)
: UsartPeripheral<TPinPackage,PERIPHERAL_UART4>(params),
Features(static_cast<Usart&>(*this))... {
}
};
/**
* Default pin package:
* (TX,RX) = (PC10,PC11)
*/
struct Uart4DefaultPinPackage {
enum {
Port_CK=0,
Port_TX=GPIOC_BASE,
Port_RX=GPIOC_BASE,
Port_CTS=0,
Port_RTS=0,
Pin_CK=0,
Pin_TX=GPIO_Pin_10,
Pin_RX=GPIO_Pin_11,
Pin_CTS=0,
Pin_RTS=0
};
};
/**
* Convenience class to match the F1 pin for pin.
*/
template<class... Features>
struct Uart4 : UsartPeripheral<Uart4DefaultPinPackage,PERIPHERAL_UART4>,
Features... {
/**
* Constructor
* @param params Initialisation parameters
*/
Uart4(const Parameters& params)
: UsartPeripheral<Uart4DefaultPinPackage,PERIPHERAL_UART4>(params),
Features(static_cast<Usart&>(*this))... {
}
};
}
| 20.90411 | 98 | 0.631062 |
d96b565d99cf02654f233a3945c5b1d617979a4d | 9,596 | h | C | src/dlib/optimization/optimization_oca.h | cpearce/HARM | 1e629099bbaa0203b19fe9007a71d9ab9c938be0 | [
"Apache-2.0"
] | 1 | 2016-10-11T18:37:52.000Z | 2016-10-11T18:37:52.000Z | src/dlib/optimization/optimization_oca.h | wsgan001/HARM | 1e629099bbaa0203b19fe9007a71d9ab9c938be0 | [
"Apache-2.0"
] | 2 | 2017-03-27T22:58:45.000Z | 2017-03-28T04:46:52.000Z | src/dlib/optimization/optimization_oca.h | wsgan001/HARM | 1e629099bbaa0203b19fe9007a71d9ab9c938be0 | [
"Apache-2.0"
] | 4 | 2016-04-19T06:15:01.000Z | 2020-01-02T11:11:57.000Z | // Copyright (C) 2010 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_OPTIMIZATIoN_OCA_H__
#define DLIB_OPTIMIZATIoN_OCA_H__
#include "optimization_oca_abstract.h"
#include "../matrix.h"
#include "optimization_solve_qp_using_smo.h"
#include <list>
// ----------------------------------------------------------------------------------------
namespace dlib
{
template <typename matrix_type>
class oca_problem
{
public:
typedef typename matrix_type::type scalar_type;
virtual ~oca_problem() {}
virtual bool risk_has_lower_bound (
scalar_type&
) const { return false; }
virtual bool optimization_status (
scalar_type ,
scalar_type ,
scalar_type ,
scalar_type ,
unsigned long,
unsigned long
) const = 0;
virtual scalar_type get_c (
) const = 0;
virtual long get_num_dimensions (
) const = 0;
virtual void get_risk (
matrix_type& current_solution,
scalar_type& risk_value,
matrix_type& risk_subgradient
) const = 0;
};
// ----------------------------------------------------------------------------------------
class oca
{
public:
oca ()
{
sub_eps = 1e-2;
sub_max_iter = 50000;
inactive_thresh = 20;
}
void set_subproblem_epsilon (
double eps_
) { sub_eps = eps_; }
double get_subproblem_epsilon (
) const { return sub_eps; }
void set_subproblem_max_iterations (
unsigned long sub_max_iter_
)
{
// make sure requires clause is not broken
DLIB_ASSERT(sub_max_iter_ > 0,
"\t void oca::set_subproblem_max_iterations"
<< "\n\t max iterations must be greater than 0"
<< "\n\t sub_max_iter_: " << sub_max_iter_
<< "\n\t this: " << this
);
sub_max_iter = sub_max_iter_;
}
unsigned long get_subproblem_max_iterations (
) const { return sub_max_iter; }
void set_inactive_plane_threshold (
unsigned long inactive_thresh_
)
{
// make sure requires clause is not broken
DLIB_ASSERT(inactive_thresh_ > 0,
"\t void oca::set_inactive_plane_threshold"
<< "\n\t inactive threshold must be greater than 0"
<< "\n\t inactive_thresh_: " << inactive_thresh_
<< "\n\t this: " << this
);
inactive_thresh = inactive_thresh_;
}
unsigned long get_inactive_plane_threshold (
) const { return inactive_thresh; }
template <
typename matrix_type
>
typename matrix_type::type operator() (
const oca_problem<matrix_type>& problem,
matrix_type& w
) const
{
// make sure requires clause is not broken
DLIB_ASSERT(problem.get_c() > 0 &&
problem.get_num_dimensions() > 0,
"\t void oca::operator()"
<< "\n\t The oca_problem is invalid"
<< "\n\t problem.get_c(): " << problem.get_c()
<< "\n\t problem.get_num_dimensions(): " << problem.get_num_dimensions()
<< "\n\t this: " << this
);
typedef typename matrix_type::type scalar_type;
typedef typename matrix_type::layout_type layout_type;
typedef typename matrix_type::mem_manager_type mem_manager_type;
typedef matrix_type vect_type;
const scalar_type C = problem.get_c();
std::list<vect_type> planes;
std::vector<scalar_type> bs, miss_count;
vect_type temp, alpha;
w.set_size(problem.get_num_dimensions(), 1);
w = 0;
// The current objective value. Note also that w always contains
// the current solution.
scalar_type cur_obj = std::numeric_limits<scalar_type>::max();
// This will hold the cutting plane objective value. This value is
// a lower bound on the true optimal objective value.
scalar_type cp_obj = 0;
matrix<scalar_type,0,0,mem_manager_type, layout_type> K, Ktmp;
scalar_type R_lower_bound;
if (problem.risk_has_lower_bound(R_lower_bound))
{
// The flat lower bounding plane is always good to have if we know
// what it is.
bs.push_back(R_lower_bound);
planes.push_back(zeros_matrix<scalar_type>(w.size(),1));
alpha = uniform_matrix<scalar_type>(1,1, C);
miss_count.push_back(0);
K.set_size(1,1);
K(0,0) = 0;
}
unsigned long counter = 0;
while (true)
{
// add the next cutting plane
scalar_type cur_risk;
planes.resize(planes.size()+1);
problem.get_risk(w, cur_risk, planes.back());
bs.push_back(cur_risk - dot(w,planes.back()));
miss_count.push_back(0);
// If alpha is empty then initialize it (we must always have sum(alpha) == C).
// But otherwise, just append a zero.
if (alpha.size() == 0)
alpha = uniform_matrix<scalar_type>(1,1, C);
else
alpha = join_cols(alpha,zeros_matrix<scalar_type>(1,1));
const scalar_type wnorm = 0.5*trans(w)*w;
cur_obj = wnorm + C*cur_risk;
// report current status
const scalar_type risk_gap = cur_risk - (cp_obj-wnorm)/C;
if (counter > 0 && problem.optimization_status(cur_obj, cur_obj - cp_obj,
cur_risk, risk_gap, planes.size(), counter))
{
break;
}
// compute kernel matrix for all the planes
K.swap(Ktmp);
K.set_size(planes.size(), planes.size());
// copy over the old K matrix
set_subm(K, 0,0, Ktmp.nr(), Ktmp.nc()) = Ktmp;
// now add the new row and column to K
long rr = 0;
for (typename std::list<vect_type>::iterator r = planes.begin(); r != planes.end(); ++r)
{
K(rr, Ktmp.nc()) = dot(*r, planes.back());
K(Ktmp.nc(), rr) = K(rr,Ktmp.nc());
++rr;
}
// solve the cutting plane subproblem for the next w. We solve it to an
// accuracy that is related to how big the error gap is
scalar_type eps = std::min<scalar_type>(sub_eps, 0.1*(cur_obj-cp_obj)) ;
// just a sanity check
if (eps < 1e-16)
eps = 1e-16;
// Note that we warm start this optimization by using the alpha from the last
// iteration as the starting point.
solve_qp_using_smo(K, vector_to_matrix(bs), alpha, eps, sub_max_iter);
// construct the w that minimized the subproblem.
w = 0;
rr = 0;
for (typename std::list<vect_type>::iterator i = planes.begin(); i != planes.end(); ++i)
{
if (alpha(rr) != 0)
{
w -= alpha(rr)*(*i);
miss_count[rr] = 0;
}
else
{
miss_count[rr] += 1;
}
++rr;
}
// Compute the lower bound on the true objective given to us by the cutting
// plane subproblem.
cp_obj = -0.5*trans(w)*w + trans(alpha)*vector_to_matrix(bs);
// If it has been a while since a cutting plane was an active constraint then
// we should throw it away.
while (max(vector_to_matrix(miss_count)) >= inactive_thresh)
{
const long idx = index_of_max(vector_to_matrix(miss_count));
typename std::list<vect_type>::iterator i0 = planes.begin();
advance(i0, idx);
planes.erase(i0);
bs.erase(bs.begin()+idx);
miss_count.erase(miss_count.begin()+idx);
K = removerc(K, idx, idx);
alpha = remove_row(alpha,idx);
}
++counter;
}
return cur_obj;
}
private:
double sub_eps;
unsigned long sub_max_iter;
unsigned long inactive_thresh;
};
}
// ----------------------------------------------------------------------------------------
#endif // DLIB_OPTIMIZATIoN_OCA_H__
| 34.642599 | 108 | 0.473843 |
d96dc24e3d31f74071e3935039a1fbee0bb8dc77 | 2,916 | h | C | wit/src/AvSorter.h | IBM/CMMPPT | 16dd1b709af992c09a1fda110b0602998f46d0d7 | [
"Apache-2.0"
] | 1 | 2019-10-25T05:25:23.000Z | 2019-10-25T05:25:23.000Z | wit/src/AvSorter.h | IBM/CMMPPT | 16dd1b709af992c09a1fda110b0602998f46d0d7 | [
"Apache-2.0"
] | 2 | 2019-09-04T17:34:59.000Z | 2020-09-16T08:10:57.000Z | wit/src/AvSorter.h | IBM/CMMPPT | 16dd1b709af992c09a1fda110b0602998f46d0d7 | [
"Apache-2.0"
] | 18 | 2019-07-22T19:01:25.000Z | 2022-03-03T15:36:11.000Z | //==============================================================================
// Constrained Materials Management and Production Planning Tool
//
// (C) Copyright IBM Corp. 1993, 2020 All Rights Reserved
//==============================================================================
#ifndef AvSorterH
#define AvSorterH
//------------------------------------------------------------------------------
// Header file: "AvSorter.h"
//
// Contains the declaration of class template AvSorter.
//------------------------------------------------------------------------------
#include <PtrVec.h>
//------------------------------------------------------------------------------
// Class template AvSorter <SortEntry>
//
// Responsible for sorting instances of the SortEntry class (either BopEntry or
// SubEntry) by their aversion.
//
// Implemented in PreHelp.C.
//------------------------------------------------------------------------------
template <typename SortEntry>
class WitAvSorter
{
public:
//-----------------------------------------------------------------------
// Public member functions.
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// Constructor functions.
//-----------------------------------------------------------------------
WitAvSorter (int nEntries);
//-----------------------------------------------------------------------
// Destructor function.
//-----------------------------------------------------------------------
~WitAvSorter ();
//-----------------------------------------------------------------------
// Other public member functions.
//-----------------------------------------------------------------------
void sort (WitList <SortEntry> & theList);
//
// Sorts the elements of theList according to the aversion function.
private:
//-----------------------------------------------------------------------
// Private member functions.
//-----------------------------------------------------------------------
bool inOrder (const WitList <SortEntry> & theList);
//
// Returns true, iff the elements of theList are ordered consistently
// with the aversion function.
static bool compareAversions (SortEntry *, SortEntry *);
//
// Sort compare function based on aversion.
static double aversion (SortEntry *);
//
// Returns the appropriate aversion.
//-----------------------------------------------------------------------
// Private member data.
//-----------------------------------------------------------------------
WitPtrVec <SortEntry> workingVec_;
//
// Working PtrVec.
};
#endif
| 34.305882 | 80 | 0.323045 |
d96df0d8cade649eecafa0d98063c1a13d93df8d | 1,123 | c | C | projects/util_libs/libutils/src/arch/riscv/stack.c | Nexusoft/LLL-OS | 7b0ad5afb339e9bebc65142ee89bded5344cedbe | [
"BSD-2-Clause"
] | 4 | 2020-08-07T19:48:01.000Z | 2020-10-16T20:05:17.000Z | projects/util_libs/libutils/src/arch/riscv/stack.c | Nexusoft/LX-OS | 7b0ad5afb339e9bebc65142ee89bded5344cedbe | [
"BSD-2-Clause"
] | null | null | null | projects/util_libs/libutils/src/arch/riscv/stack.c | Nexusoft/LX-OS | 7b0ad5afb339e9bebc65142ee89bded5344cedbe | [
"BSD-2-Clause"
] | 2 | 2020-08-13T01:48:40.000Z | 2020-09-17T07:34:42.000Z | /*
* Copyright 2018, Data61
* Commonwealth Scientific and Industrial Research Organisation (CSIRO)
* ABN 41 687 119 230.
*
* This software may be distributed and modified according to the terms of
* the BSD 2-Clause license. Note that NO WARRANTY is provided.
* See "LICENSE_BSD2.txt" for details.
*
* @TAG(DATA61_BSD)
*/
#include <autoconf.h>
#include <utils/gen_config.h>
#include <utils/stack.h>
void *
utils_run_on_stack(void *stack_top, void * (*func)(void *arg), void *arg)
{
void *ret;
asm volatile (
"mv s0, sp\n\t" /* Save sp - s0 is callee saved so we don't need to save it. */
"mv sp, %[new_stack]\n\t" /* Switch to new stack. */
"mv a0, %[arg]\n\t" /* Setup argument to func. */
"jalr %[func]\n\t"
"mv sp, s0\n\t"
"mv %[ret], a0\n\t"
: [ret] "=r" (ret)
: [new_stack] "r" (stack_top),
[func] "r" (func),
[arg] "r" (arg)
/* caller saved registers */
: "t0", "t1", "t2", "t3", "t4", "t5", "t6", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "ra");
return ret;
}
| 32.085714 | 106 | 0.544969 |
d96e0623330cd7044d4b1ac766c2fc9c09a6a8f3 | 9,460 | c | C | Mediabench/rasta/src/lpccep.c | srokicki/HybridDBT-benchmarks | 3557dbcc34887131a819143a76e429f2abdf7314 | [
"MIT"
] | 28 | 2017-01-20T15:25:54.000Z | 2020-03-17T00:28:31.000Z | benchmarks/mediabench/rasta/src/lpccep.c | wuiw/HybridDBT-For-RISCV | ddfbe8b2a9a98fe9a8f4bab876614c7af5c002e1 | [
"MIT"
] | 2 | 2017-10-24T09:34:12.000Z | 2017-11-09T12:55:48.000Z | benchmarks/mediabench/rasta/src/lpccep.c | wuiw/HybridDBT-For-RISCV | ddfbe8b2a9a98fe9a8f4bab876614c7af5c002e1 | [
"MIT"
] | 7 | 2017-05-22T13:15:39.000Z | 2022-01-20T09:36:00.000Z | /*************************************************************************
* *
* ROUTINES IN THIS FILE: *
* *
* lpccep(): computes autoregressive cepstrum *
* from the auditory spectrum *
* *
* auto_to_lpc(): computes autoregressive coeffs *
* from the autocorrrelation *
* *
* lpc_to_cep(): computes cepstral coeffs *
* from the prediction vector *
* *
* band_to_auto(): computes autocorrelations from *
* auditory spectrum *
* *
************************************************************************/
/***********************************************************************
(C) 1995 US West and International Computer Science Institute,
All rights reserved
U.S. Patent Numbers 5,450,522 and 5,537,647
Embodiments of this technology are covered by U.S. Patent
Nos. 5,450,522 and 5,537,647. A limited license for internal
research and development use only is hereby granted. All other
rights, including all commercial exploitation, are retained unless a
license has been granted by either US West or International Computer
Science Institute.
***********************************************************************/
#include <stdio.h>
#include <math.h>
#include "rasta.h"
#include "functions.h"
/*
* This routine computes the lpc cepstrum from the
* cleaned up auditory spectrum.
*
* The first time that this program is called, we do
* the usual allocation.
*/
/* local function prototype */
void band_to_auto( const struct param *, struct fvec *, struct fvec *);
struct fvec *lpccep( const struct param *pptr, struct fvec *in)
{
static struct fvec *autoptr = NULL; /* array for autocor */
static struct fvec *lpcptr; /* array for predictors */
static struct fvec *outptr; /* array for cepstra */
static struct fvec *outptrOLD; /* last array of cepstra */
float lpcgain;
int i;
char *funcname;
funcname = "lpccep";
if(autoptr == (struct fvec *)NULL) /* Check for 1st time */
{
/* Allocate space */
autoptr = alloc_fvec( pptr->order + 1 );
lpcptr = alloc_fvec( pptr->order + 1 );
outptr = alloc_fvec( pptr->nout );
outptrOLD = alloc_fvec( pptr->nout );
for(i=0; i<outptr->length; i++)
outptrOLD->values[i] = TINY;
}
band_to_auto(pptr, in, autoptr);
/* Do IDFT by multiplying cosine matrix times power values,
getting autocorrelations */
auto_to_lpc( pptr, autoptr, lpcptr, &lpcgain );
/* do Durbin recursion to get predictor coefficients */
if(lpcgain<=0) /* in case of calculation inaccuracy */
{
for(i=0; i<outptr->length; i++)
outptr->values[i] = outptrOLD->values[i];
fprintf(stderr,"Warning: inaccuracy of calculation -> using last frame\n");
}
else
{
if( pptr->gainflag == TRUE)
{
norm_fvec( lpcptr, lpcgain );
}
/* Put in model gain */
lpc_to_cep( pptr, lpcptr, outptr );
/* Recursion to get cepstral coefficients */
}
for(i=0; i<outptr->length; i++)
outptrOLD->values[i] = outptr->values[i];
return( outptr );
}
/* This routine computes the solution for an autoregressive
model given the autocorrelation vector.
This routine uses essentially the
same variables as were used in the original Fortran,
as I don't want to mess with the magic therein. */
void auto_to_lpc( const struct param *pptr, struct fvec * autoptr,
struct fvec * lpcptr, float *lpcgain )
{
float s;
static float *alp = NULL;
static float *rc;
float alpmin, rcmct, aib, aip;
float *a, *r;
char *funcname;
int idx, mct, mct2, ib, ip, i_1, i_2, mh;
funcname = "auto_to_lpc";
if(alp == (float *)NULL) /* If first time */
{
alp = (float *)malloc((pptr->order + 1) * sizeof(float));
if(alp == (float *)NULL)
{
fprintf(stderr,"cant allocate alp\n");
exit(-1);
}
rc = (float *)malloc((pptr->order ) * sizeof(float));
if(rc == (float *)NULL)
{
fprintf(stderr,"cant allocate rc\n");
exit(-1);
}
}
fvec_check( funcname, lpcptr, pptr->order );
fvec_check( funcname, autoptr, pptr->order );
/* Move values and pointers over from nice calling
names to Fortran names */
a = lpcptr->values;
r = autoptr->values;
/* solution for autoregressive model */
a[0] = 1.;
alp[0] = r[0];
rc[0] = -(double)r[1] / r[0];
a[1] = rc[0];
alp[1] = r[0] + r[1] * rc[0];
i_2 = pptr->order;
for (mct = 2; mct <= i_2; ++mct)
{
s = 0.;
mct2 = mct + 2;
alpmin = alp[mct - 1];
i_1 = mct;
for (ip = 1; ip <= i_1; ++ip)
{
idx = mct2 - ip;
s += r[idx - 1] * a[ip-1];
}
rcmct = -(double)s / alpmin;
mh = mct / 2 + 1;
i_1 = mh;
for (ip = 2; ip <= i_1; ++ip)
{
ib = mct2 - ip;
aip = a[ip-1];
aib = a[ib-1];
a[ip-1] = aip + rcmct * aib;
a[ib-1] = aib + rcmct * aip;
}
a[mct] = rcmct;
alp[mct] = alpmin - alpmin * rcmct * rcmct;
rc[mct-1] = rcmct;
}
*lpcgain = alp[pptr->order];
}
/* This routine computes the cepstral coefficients
for an autoregressive model
given the prediction vector.
This routine uses essentially the
same variables as were used in the original Fortran,
as I don't want to mess with the magic therein. */
void lpc_to_cep( const struct param *pptr, struct fvec * lpcptr,
struct fvec * cepptr )
{
int ii, j, l, jb;
float sum;
static float *c = NULL;
float *a, *gexp;
char *funcname;
double d_1, d_2;
funcname = "lpc_to_cep";
if(c == (float *)NULL)
{
c = (float *)malloc((pptr->nout) * sizeof(float));
if(c == (float *)NULL)
{
fprintf(stderr,"cant allocate c\n");
exit(-1);
}
}
fvec_check( funcname, lpcptr, pptr->order );
/* bounds-checking for array reference */
fvec_check( funcname, cepptr, pptr->nout - 1 );
/* bounds-checking for array reference */
/* Move values and pointers over from calling
names to local array names */
a = lpcptr->values;
gexp = cepptr->values;
/* Function Body */
c[0] = -log(a[0]);
c[1] = -(double)a[1] / a[0];
for (l = 2; l < pptr->nout; ++l)
{
if (l <= pptr->order )
{
sum = l * a[l] / a[0];
}
else
{
sum = 0.;
}
for (j = 2; j <= l; ++j)
{
jb = l - j + 2;
if (j <= (pptr->order + 1) )
{
sum += a[j-1] * c[jb - 1] * (jb - 1) / a[0];
}
}
c[l] = -(double)sum / l;
}
gexp[0] = c[0];
for (ii = 2; ii <= pptr->nout; ++ii)
{
if (pptr->lift != 0.)
{
d_1 = (double) ((ii - 1));
d_2 = (double) (pptr->lift);
gexp[ii-1] = pow(d_1, d_2) * c[ii - 1];
}
else
{
gexp[ii-1] = c[ii - 1];
}
}
}
/* Do IDFT by multiplying cosine matrix times power values,
getting autocorrelations */
void band_to_auto(const struct param *pptr, struct fvec *bandptr,
struct fvec *autoptr)
{
static double **wcosptr = (double **)NULL;
double base_angle,tmp;
int n_auto, n_freq;
int i, j;
char *funcname;
funcname = "band_to_auto";
n_auto = pptr->order+1;
n_freq = pptr->nfilts;
/* check dimension */
if(bandptr->length != n_freq)
{
fprintf(stderr,"input veclength neq number of critical bands\n");
exit(-1);
}
if(autoptr->length != n_auto)
{
fprintf(stderr,"output veclength neq autocorrelation length\n");
exit(-1);
}
/* Builds up a matrix of cosines for IDFT, 1st time */
if(wcosptr == (double **)NULL)
{
/* Allocate double matrix */
wcosptr = (double **)malloc(n_auto * sizeof(double *));
if(wcosptr == (double **)NULL)
{
fprintf(stderr,"Cannot malloc double ptr array (matrix of cosines)\n");
exit(-1);
}
for(i=0; i<n_auto; i++)
{
wcosptr[i] = (double *)malloc(n_freq * sizeof(double));
if(wcosptr[i] == (double *)NULL)
{
fprintf(stderr,"Cannot malloc double array (matrix of cosines)\n");
exit(-1);
}
}
/* Builds up a matrix of cosines for IDFT */
base_angle = M_PI / (double)(n_freq - 1); /* M_PI is PI, defined in math.h */
for(i=0; i<n_auto; i++)
{
wcosptr[i][0] = 1.0;
for(j=1; j<(n_freq-1); j++)
{
wcosptr[i][j]
= 2.0 * cos(base_angle * (double)i * (double)j);
}
/* No folding over from neg values for Nyquist freq */
wcosptr[i][n_freq-1]
= cos(base_angle * (double)i * (double)(n_freq-1));
}
}
/* multiplying cosine matrix times power values */
for(i=0; i<n_auto; i++)
{
tmp = wcosptr[i][0] * (double)bandptr->values[0];
for(j=1; j<n_freq; j++)
tmp += wcosptr[i][j] * (double)bandptr->values[j];
autoptr->values[i] = (float)(tmp / (double)(2. * (n_freq-1))); /* normalize */
}
}
| 27.42029 | 81 | 0.521353 |
d96e59515f172de32cd73187cc9bc874ac730ab9 | 3,295 | h | C | inference-engine/src/legacy_api/include/net_pass.h | cwzrad/openvino | ae4bd370eac7c695bd797a31e62317d328dbe742 | [
"Apache-2.0"
] | 1 | 2020-10-13T22:49:18.000Z | 2020-10-13T22:49:18.000Z | inference-engine/src/legacy_api/include/net_pass.h | cwzrad/openvino | ae4bd370eac7c695bd797a31e62317d328dbe742 | [
"Apache-2.0"
] | null | null | null | inference-engine/src/legacy_api/include/net_pass.h | cwzrad/openvino | ae4bd370eac7c695bd797a31e62317d328dbe742 | [
"Apache-2.0"
] | null | null | null | // Copyright (C) 2018-2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <map>
#include <string>
#include <vector>
#include "ie_icnn_network.hpp"
#include "graph_tools.hpp"
namespace InferenceEngine {
namespace NetPass {
IE_SUPPRESS_DEPRECATED_START
/**
* Try to detect LSTM Sequence pattern inside TI and convert it
*
* @param net network to modify
* @return true if all Tensor iterator was converted
*/
INFERENCE_ENGINE_API_CPP(bool) CombineRNNSeq(ICNNNetwork& net);
INFERENCE_ENGINE_API_CPP(bool) CombineRNNSeq(TensorIterator::Body& net);
/**
* Returns a vector of the topologically sorted layers from
* the passed TI layer body.
*
* @param body TI body
* @return vector of layer objects
*/
INFERENCE_ENGINE_API_CPP(std::vector<CNNLayerPtr>) TIBodySortTopologically(const TensorIterator::Body& body);
/**
* Check if provided layer contains internal attribute like subnet/subgraph
*
* @param layer to check
* @return true if layer has subnet
*/
bool HasInternalSubnet(const CNNLayerPtr &layer);
/**
* Extract internal subnet from layer
*
* All internal layers are returned by reference. Any modification further subnet modification will
* has affect on original layer state.
*
* @param layer to proceed
* @return internal subnet
*/
details::CNNSubnet GetInternalSubnet(const CNNLayerPtr &layer);
/**
* Unroll all present Tensor Iterators
*
* @param net network to modify
* @return true if all Tensor iterator was unrolled successfully
*/
INFERENCE_ENGINE_API_CPP(bool) UnrollTI(ICNNNetwork& net);
/**
* Unroll all RNN specific layers by predicate
*
* Will be applied to all RNNSeq and RNNCell layers
*
* @param net network to modify
* @param pred predicate to mark layer to unroll
* @return true if all RNN layers was unrolled successfully
*/
INFERENCE_ENGINE_API_CPP(bool) UnrollRNN_if(ICNNNetwork& net, std::function<bool(const RNNCellBase&)> pred);
/**
* Construct a copy of provided subnet. Will change names by adding suffix if it was provided.
*
* @param subnet to copy from
* @param suffix is optional attribute. Will be added into name of each layer/data object if provided
* @return subnet copy. Each layer/data object is newly created. Const blob objects is inherited from
* original subnet.
*/
INFERENCE_ENGINE_API_CPP(TensorIterator::Body) CopyTIBody(const TensorIterator::Body& body, std::string suffix = std::string());
INFERENCE_ENGINE_API_CPP(bool) UnrollRNN_if(TensorIterator::Body& net, std::function<bool(const RNNCellBase&)> pred);
IE_SUPPRESS_DEPRECATED_END
/**
* Precision conversion pass
*
* Will perform conversion of all presented tensors with specified precision including
* const blobs and intermediate tensors. It doesn't check layer semantic. It may break
* correctness of topology.
*
* It also remove redundant convert layers if they will appear.
*
* @param net is network to apply conversion
* @param from precision of tensors required conversion
* @param to resulting precision of tensors
*/
INFERENCE_ENGINE_API_CPP(void) ConvertPrecision(ICNNNetwork& net, Precision from, Precision to);
INFERENCE_ENGINE_API_CPP(void) ConvertIOPrecision(ICNNNetwork& net, Precision from, Precision to);
} // namespace NetPass
} // namespace InferenceEngine
| 30.509259 | 128 | 0.763885 |
d96ea1bbdd20653ef93c22dbc385d86a347a76d0 | 2,351 | h | C | src/media/audio/lib/test/comparators.h | dahlia-os/fuchsia-pine64-pinephone | 57aace6f0b0bd75306426c98ab9eb3ff4524a61d | [
"BSD-3-Clause"
] | 10 | 2020-12-28T17:04:44.000Z | 2022-03-12T03:20:43.000Z | src/media/audio/lib/test/comparators.h | oshunter/fuchsia | 2196fc8c176d01969466b97bba3f31ec55f7767b | [
"BSD-3-Clause"
] | 1 | 2022-01-14T23:38:40.000Z | 2022-01-14T23:38:40.000Z | src/media/audio/lib/test/comparators.h | oshunter/fuchsia | 2196fc8c176d01969466b97bba3f31ec55f7767b | [
"BSD-3-Clause"
] | 4 | 2020-12-28T17:04:45.000Z | 2022-03-12T03:20:44.000Z | // Copyright 2020 The Fuchsia 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 SRC_MEDIA_AUDIO_LIB_TEST_COMPARATORS_H_
#define SRC_MEDIA_AUDIO_LIB_TEST_COMPARATORS_H_
#include <fuchsia/media/cpp/fidl.h>
#include <fuchsia/virtualaudio/cpp/fidl.h>
#include <lib/fzl/vmo-mapper.h>
#include <lib/zx/vmo.h>
#include <cmath>
#include <memory>
#include "src/lib/fxl/strings/string_printf.h"
#include "src/media/audio/lib/format/audio_buffer.h"
namespace media::audio::test {
struct CompareAudioBufferOptions {
// See CompareAudioBuffers for a description.
bool partial = false;
// If positive, allow the samples to differ from the expected samples by a relative error.
// If want_slice is empty or RMS(want_slice) == 0, this has no effect.
// Relative error is defined to be:
//
// abs(RMS(got_slice - want_slice) - RMS(want_slice)) / RMS(want_slice)
//
// The term RMS(got_slice - want_slice) is known as RMS error, or RMSE. See:
// https://en.wikipedia.org/wiki/Root-mean-square_deviation.
double max_relative_error = 0;
// These options control additional debugging output of CompareAudioBuffer in failure cases.
std::string test_label;
size_t num_frames_per_packet = 100;
};
// Compares got_slice to want_slice, reporting any differences. If got_slice is larger than
// want_slice, the extra suffix should contain silence. If options.partial is true, then got_slice
// should contain a prefix of want_slice, followed by silence.
//
// For example, CompareAudioBuffer succeeds on these inputs
// got_slice = {0,1,2,3,4,0,0,0,0,0}
// want_slice = {0,1,2,3,4}
// partial = false
//
// And these inputs:
// got_slice = {0,1,2,3,0,0,0,0,0,0}
// want_slice = {0,1,2,3,4}
// partial = true
//
// But not these inputs:
// got_slice = {0,1,2,3,0,0,0,0,0,0}
// want_slice = {0,1,2,3,4}
// partial = false
//
// Differences are reported to gtest EXPECT macros.
template <fuchsia::media::AudioSampleFormat SampleFormat>
void CompareAudioBuffers(AudioBufferSlice<SampleFormat> got_slice,
AudioBufferSlice<SampleFormat> want_slice,
CompareAudioBufferOptions options);
} // namespace media::audio::test
#endif // SRC_MEDIA_AUDIO_LIB_TEST_COMPARATORS_H_
| 34.573529 | 98 | 0.716291 |
d96eac535eae39087ed6830806079c72d576dd05 | 37,790 | c | C | libdisk/format/ibm.c | davide125/Disk-Utilities | 1b2ad04f8260dd1acc83eb2334a522cb83cd95c6 | [
"Unlicense"
] | 1 | 2021-10-30T07:59:00.000Z | 2021-10-30T07:59:00.000Z | libdisk/format/ibm.c | bsdimp/Disk-Utilities | ce19c7b6ba690bc76f25b6597eed81adf8ff4a02 | [
"Unlicense"
] | null | null | null | libdisk/format/ibm.c | bsdimp/Disk-Utilities | ce19c7b6ba690bc76f25b6597eed81adf8ff4a02 | [
"Unlicense"
] | null | null | null | /*
* disk/ibm.c
*
* Supported by uPD765A, Intel 8272, and many other FDC chips, as used in
* pretty much every home computer (except Amiga and C64!).
*
* One of the more useful references:
* "uPD765A/7265 Single/Double Density Floppy Disk Controllers",
* NEC Electronics Inc.
*
* Written in 2012 by Keir Fraser
*/
#include <libdisk/util.h>
#include <private/disk.h>
struct ibm_sector {
struct ibm_idam idam;
uint8_t mark;
uint16_t crc; /* 0 = good crc */
uint8_t dat[0];
};
struct ibm_track {
uint8_t has_iam;
uint8_t post_data_gap;
struct ibm_sector secs[0];
};
struct ibm_psector {
struct ibm_psector *next;
int offset;
struct ibm_sector s;
};
#define type_is_fm(type) \
(((type) == TRKTYP_ibm_fm_sd) \
|| ((type) == TRKTYP_ibm_fm_dd) \
|| ((type) == TRKTYP_ibm_fm_sd_recovery) )
/* Defined all TRS80 track types that attemt data recovery */
static bool_t is_recovery_type(int type)
{
return (type == TRKTYP_ibm_fm_sd_recovery
|| type == TRKTYP_ibm_mfm_dd_recovery);
}
/***********************************
* In-order sector retrieval
*/
static int ibm_secno_compare(const void *_a, const void *_b)
{
const struct ibm_sector *a = *(const struct ibm_sector **)_a;
const struct ibm_sector *b = *(const struct ibm_sector **)_b;
return ((a->idam.sec < b->idam.sec) ? -1
: (a->idam.sec > b->idam.sec) ? 1 : 0);
}
void ibm_read_sectors(
struct disk *d, unsigned int tracknr, struct track_sectors *sectors)
{
struct track_info *ti = &d->di->track[tracknr];
struct ibm_track *ibm_track = (struct ibm_track *)ti->dat;
struct ibm_sector *sec, **secs = memalloc(ti->nr_sectors * sizeof(*secs));
unsigned int i, sec_sz;
char *p;
sectors->nr_bytes = (ti->len
- sizeof(struct ibm_track)
- ti->nr_sectors * sizeof(struct ibm_sector));
sectors->data = memalloc(sectors->nr_bytes);
sec = ibm_track->secs;
for (i = 0; i < ti->nr_sectors; i++) {
secs[i] = sec;
sec_sz = 128 << sec->idam.no;
sec = (struct ibm_sector *)
((char *)sec + sizeof(struct ibm_sector) + sec_sz);
}
qsort(secs, ti->nr_sectors, sizeof(*secs), ibm_secno_compare);
p = (char *)sectors->data;
for (i = 0; i < ti->nr_sectors; i++) {
sec = secs[i];
sec_sz = 128 << sec->idam.no;
memcpy(p, sec->dat, sec_sz);
p += sec_sz;
}
memfree(secs);
}
/***********************************
* Double-density (IBM-MFM) handlers
*
* Index Address Mark (IAM):
* 0xc2c2c2fc
* ID Address Mark (IDAM):
* 0xa1a1a1fe, <cyl>, <hd> <sec>, <sz>, <crc16_ccitt>
* Data Address Mark (DAM):
* 0xa1a1a1fb, <N bytes data>, <crc16_ccitt> [N = 128 << sz]
* Deleted Data Address Mark (DDAM):
* As DAM, but identifier 0xfb -> 0xf8
*
* NB. In above, 0xc2 and 0xa1 are sync marks which have one of their clock
* bits forced to zero. Hence 0xc2 -> 0x5224; 0xa1 -> 0x4489.
*/
int ibm_scan_mark(struct stream *s, unsigned int max_scan, uint8_t *pmark)
{
int idx_off = -1;
*pmark = 0;
do {
if (s->word != 0x44894489)
continue;
stream_start_crc(s);
if (stream_next_bits(s, 16) == -1)
break;
if ((uint16_t)s->word != 0x4489)
continue;
if (stream_next_bits(s, 16) == -1)
break;
idx_off = s->index_offset_bc - 63;
if (idx_off < 0)
idx_off += s->track_len_bc;
*pmark = (uint8_t)mfm_decode_word(s->word);
break;
} while ((stream_next_bit(s) != -1) && --max_scan);
return idx_off;
}
int ibm_scan_idam(struct stream *s, struct ibm_idam *idam)
{
uint8_t mark;
int idx_off;
idx_off = ibm_scan_mark(s, ~0u, &mark);
if ((idx_off < 0) || (mark != IBM_MARK_IDAM))
goto fail;
/* cyl,head */
if (stream_next_bits(s, 32) == -1)
goto fail;
idam->cyl = mfm_decode_word(s->word >> 16);
idam->head = mfm_decode_word(s->word);
/* sec,no */
if (stream_next_bits(s, 32) == -1)
goto fail;
idam->sec = mfm_decode_word(s->word >> 16);
idam->no = mfm_decode_word(s->word);
/* crc */
if (stream_next_bits(s, 32) == -1)
goto fail;
idam->crc = s->crc16_ccitt;
return idx_off;
fail:
return -1;
}
int ibm_scan_dam(struct stream *s)
{
uint8_t mark;
int idx_off = ibm_scan_mark(s, 1000, &mark);
return (mark == IBM_MARK_DAM) ? idx_off : -1;
}
static int choose_post_data_gap(
struct track_info *ti, struct ibm_track *ibm_track,
int gap_bits, unsigned int nr_secs)
{
int post_data_gap, iam_bits = (type_is_fm(ti->type) ? 7 : 16) * 16;
int pre_index_gap = 40, post_index_gap = type_is_fm(ti->type) ? 40 : 80;
for (;;) {
/* Don't include pre/post-index gaps (aka "track gap"). */
post_data_gap = gap_bits - (post_index_gap + pre_index_gap) * 16;
/* Account for IAM and distribute gap evenly across sectors and IAM. */
post_data_gap = (ibm_track->has_iam
? (post_data_gap - iam_bits) / ((nr_secs+1) * 16)
: post_data_gap / (nr_secs * 16));
if (post_data_gap >= 10) /* some very small paranoia value */
break;
/* Inter-sector gap is too small: lengthen the track to make space. */
gap_bits += 1000;
ti->total_bits += 1000;
}
return post_data_gap;
}
static void *ibm_mfm_write_raw(
struct disk *d, unsigned int tracknr, struct stream *s)
{
struct track_info *ti = &d->di->track[tracknr];
struct ibm_psector *ibm_secs, *new_sec, *cur_sec, *next_sec, **pprev_sec;
struct ibm_track *ibm_track = NULL;
unsigned int dat_bytes = 0, gap_bits, nr_blocks = 0;
unsigned int sec_sz;
bool_t iam = 0;
/* IAM */
while (!iam && (stream_next_bit(s) != -1)) {
if (s->word != 0x52245224)
continue;
if (stream_next_bits(s, 32) == -1)
break;
iam = (s->word == 0x52245552);
}
stream_reset(s);
ibm_secs = NULL;
while (stream_next_bit(s) != -1) {
int idx_off;
uint8_t mark, dat[2*16384];
uint16_t crc;
struct ibm_idam idam;
/* IDAM */
if ((idx_off = ibm_scan_idam(s, &idam)) < 0)
continue;
/* If the IDAM CRC is bad we cannot trust the sector data: we always
* skip the sector data in this case. CRC errors can also happen from
* cross-talk (40-track disk read as 80-track). */
if (idam.crc) {
#if CRC_DEBUG
/* Warn if we are recovering */
if (is_recovery_type(ti->type)) {
trk_warn(ti, tracknr, "IDAM CRC cyl:%2d, head:%2d, sec:%2d, "
"no:%2d, crc:%04x, offset:%5d",
idam.cyl, idam.head, idam.sec,
idam.no, idam.crc, idx_off);
}
#endif
/* TODO: try to reconstruct the correct idam ... */
continue;
}
if (idam.no > 7) {
trk_warn(ti, tracknr, "Unexpected IDAM no=%02x", idam.no);
continue;
}
sec_sz = 128 << idam.no;
/* DAM/DDAM */
if ((ibm_scan_mark(s, 1000, &mark) < 0) ||
(stream_next_bytes(s, dat, 2*sec_sz) == -1) ||
(stream_next_bits(s, 32) == -1))
continue;
/* Skip bad data CRC unless we are doing data recovery. */
crc = s->crc16_ccitt;
if (crc && !is_recovery_type(ti->type))
continue;
/* Find correct place for this sector in our linked list of sectors
* that we have decoded so far. */
pprev_sec = &ibm_secs;
cur_sec = *pprev_sec;
while (cur_sec && ((idx_off - cur_sec->offset) >= 1000)) {
pprev_sec = &cur_sec->next;
cur_sec = *pprev_sec;
}
/* If this sector's start is within 1000 bits of one we already decoded
* then it is the same sector: we decoded it already on an earlier
* revolution and can skip it this time round. */
if (cur_sec && (abs(idx_off - cur_sec->offset) < 1000)) {
/* Is this really the same sector? Check IDAM contents. */
if ((idam.cyl == cur_sec->s.idam.cyl) &&
(idam.head == cur_sec->s.idam.head) &&
(idam.sec == cur_sec->s.idam.sec) &&
(idam.no == cur_sec->s.idam.no)) {
/* If we now have a good CRC and the saved sector has a bad CRC
* we should try converting it again.
*
* TODO:
* 1 if we only have bad crcs on all reads we might try to
* median combine all of the bits into a new one
* 2 reconstruct missing idam values if we have a data
* sector */
if (!crc && cur_sec->s.crc) {
#ifdef CRC_DEBUG
trk_warn(ti, tracknr, "FIXED CRC cyl:%2d, head:%2d, "
"sec:%2d, no:%2d, size:%4x, offset:%5d",
idam.cyl, idam.head, idam.sec, idam.no,
sec_sz, idx_off);
#endif
/* Replace the previous bad sector header/data. */
cur_sec->offset = idx_off;
cur_sec->s.crc = crc;
cur_sec->s.mark = mark;
mfm_decode_bytes(bc_mfm, sec_sz, dat, dat);
memcpy(&cur_sec->s.dat[0], dat, sec_sz);
memcpy(&cur_sec->s.idam, &idam, sizeof(idam));
}
} else {
/* This code should NEVER trigger */
trk_warn(ti, tracknr, "IDAM WARN"
" [cyl:%2d, head:%2d, sec:%2d, no:%2d, "
"crc:%04x, offset:%5d] != [cyl:%2d, head:%2d, "
"sec:%2d, no:%2d, crc:%04x, offset:%5d]",
idam.cyl, idam.head, idam.sec, idam.no,
crc, idx_off,
cur_sec->s.idam.cyl, cur_sec->s.idam.head,
cur_sec->s.idam.sec, cur_sec->s.idam.no,
cur_sec->s.idam.crc, cur_sec->offset);
}
continue;
}
#ifdef CRC_DEBUG
if (crc) {
trk_warn(ti, tracknr, "DATA CRC cyl:%2d, head:%2d, sec:%2d, "
"no:%2d, crc:%04x, offset:%5d",
idam.cyl, idam.head, idam.sec, idam.no, crc, idx_off);
}
#endif
/* Add a new sector. */
mfm_decode_bytes(bc_mfm, sec_sz, dat, dat);
new_sec = memalloc(sizeof(*new_sec) + sec_sz);
new_sec->offset = idx_off;
new_sec->s.crc = crc;
new_sec->s.mark = mark;
memcpy(&new_sec->s.dat[0], dat, sec_sz);
memcpy(&new_sec->s.idam, &idam, sizeof(idam));
/* Add the new sector to linked list */
new_sec->next = *pprev_sec;
*pprev_sec = new_sec;
}
gap_bits = ti->total_bits - s->track_len_bc;
for (cur_sec = ibm_secs; cur_sec; cur_sec = cur_sec->next) {
int distance, cur_size;
next_sec = cur_sec->next ?: ibm_secs;
distance = next_sec->offset - cur_sec->offset;
if (distance <= 0)
distance += s->track_len_bc;
sec_sz = 128 << cur_sec->s.idam.no;
cur_size = 62 + sec_sz;
if ((distance -= cur_size * 16) < 0) {
trk_warn(ti, tracknr, "Overlapping sectors");
goto out;
}
gap_bits += distance;
nr_blocks++;
dat_bytes += sec_sz;
}
if (nr_blocks == 0)
goto out;
ti->data_bitoff = 80 * 16;
ti->nr_sectors = nr_blocks;
set_all_sectors_valid(ti);
ibm_track = memalloc(sizeof(struct ibm_track)
+ nr_blocks * sizeof(struct ibm_sector)
+ dat_bytes);
ibm_track->has_iam = iam ? 1 : 0;
ibm_track->post_data_gap = choose_post_data_gap(
ti, ibm_track, gap_bits, nr_blocks);
ti->len = sizeof(struct ibm_track);
for (cur_sec = ibm_secs; cur_sec; cur_sec = cur_sec->next) {
sec_sz = 128 << cur_sec->s.idam.no;
memcpy((char *)ibm_track + ti->len,
&cur_sec->s, sizeof(struct ibm_sector) + sec_sz);
ti->len += sizeof(struct ibm_sector) + sec_sz;
}
out:
return ibm_track;
}
static void ibm_mfm_read_raw(
struct disk *d, unsigned int tracknr, struct tbuf *tbuf)
{
struct track_info *ti = &d->di->track[tracknr];
struct ibm_track *ibm_track = (struct ibm_track *)ti->dat;
struct ibm_sector *cur_sec;
unsigned int sec, i, sec_sz;
tbuf_set_gap_fill_byte(tbuf, 0x4e);
/* IAM */
if (ibm_track->has_iam) {
for (i = 0; i < 12; i++)
tbuf_bits(tbuf, SPEED_AVG, bc_mfm, 8, 0x00);
tbuf_bits(tbuf, SPEED_AVG, bc_raw, 32, 0x52245224);
tbuf_bits(tbuf, SPEED_AVG, bc_raw, 32, 0x52245552);
for (i = 0; i < ibm_track->post_data_gap; i++)
tbuf_bits(tbuf, SPEED_AVG, bc_mfm, 8, 0x4e);
}
cur_sec = ibm_track->secs;
for (sec = 0; sec < ti->nr_sectors; sec++) {
sec_sz = 128 << cur_sec->idam.no;
/* IDAM */
for (i = 0; i < 12; i++)
tbuf_bits(tbuf, SPEED_AVG, bc_mfm, 8, 0x00);
tbuf_start_crc(tbuf);
tbuf_bits(tbuf, SPEED_AVG, bc_raw, 32, 0x44894489);
tbuf_bits(tbuf, SPEED_AVG, bc_raw, 16, 0x4489);
tbuf_bits(tbuf, SPEED_AVG, bc_mfm, 8, IBM_MARK_IDAM);
tbuf_bits(tbuf, SPEED_AVG, bc_mfm, 8, cur_sec->idam.cyl);
tbuf_bits(tbuf, SPEED_AVG, bc_mfm, 8, cur_sec->idam.head);
tbuf_bits(tbuf, SPEED_AVG, bc_mfm, 8, cur_sec->idam.sec);
tbuf_bits(tbuf, SPEED_AVG, bc_mfm, 8, cur_sec->idam.no);
tbuf_emit_crc16_ccitt(tbuf, SPEED_AVG);
for (i = 0; i < 22; i++)
tbuf_bits(tbuf, SPEED_AVG, bc_mfm, 8, 0x4e);
/* DAM */
for (i = 0; i < 12; i++)
tbuf_bits(tbuf, SPEED_AVG, bc_mfm, 8, 0x00);
tbuf_start_crc(tbuf);
tbuf_bits(tbuf, SPEED_AVG, bc_raw, 32, 0x44894489);
tbuf_bits(tbuf, SPEED_AVG, bc_raw, 16, 0x4489);
tbuf_bits(tbuf, SPEED_AVG, bc_mfm, 8, cur_sec->mark);
tbuf_bytes(tbuf, SPEED_AVG, bc_mfm, sec_sz, cur_sec->dat);
tbuf_emit_crc16_ccitt(tbuf, SPEED_AVG);
for (i = 0; i < ibm_track->post_data_gap; i++)
tbuf_bits(tbuf, SPEED_AVG, bc_mfm, 8, 0x4e);
cur_sec = (struct ibm_sector *)
((char *)cur_sec + sizeof(struct ibm_sector) + sec_sz);
}
}
static void ibm_get_name(
struct disk *d, unsigned int tracknr, char *str, size_t size)
{
struct track_info *ti = &d->di->track[tracknr];
struct ibm_track *ibm_track = (struct ibm_track *)ti->dat;
struct ibm_sector *cur_sec;
int trk_sz, sec_sz, no, sec;
cur_sec = ibm_track->secs;
no = cur_sec->idam.no;
trk_sz = sec_sz = 128 << no;
for (sec = 1; sec < ti->nr_sectors; sec++) {
cur_sec = (struct ibm_sector *)
((char *)cur_sec + sizeof(struct ibm_sector) + sec_sz);
trk_sz += sec_sz = 128 << cur_sec->idam.no;
if (no != cur_sec->idam.no)
no = -1;
}
if (no < 0)
snprintf(str, size, "%s (%u sectors, %u bytes)",
ti->typename, ti->nr_sectors, trk_sz);
else
snprintf(str, size, "%s (%u %u-byte sectors, %u bytes)",
ti->typename, ti->nr_sectors, 128 << no, trk_sz);
}
void setup_ibm_mfm_track(
struct disk *d, unsigned int tracknr,
enum track_type type, unsigned int nr_secs, unsigned int no,
uint8_t *sec_map, uint8_t *cyl_map, uint8_t *head_map,
uint8_t *mark_map, uint8_t *dat)
{
struct track_info *ti = &d->di->track[tracknr];
struct ibm_track *ibm_track;
struct ibm_sector *cur_sec;
bool_t is_fm = type_is_fm(type);
unsigned int sec_sz = 128u << no, sec;
int gap_bits;
init_track_info(ti, type);
ti->len = (sizeof(struct ibm_track)
+ nr_secs * (sizeof(struct ibm_sector) + sec_sz));
ti->dat = memalloc(ti->len);
ibm_track = (struct ibm_track *)ti->dat;
cur_sec = ibm_track->secs;
for (sec = 0; sec < nr_secs; sec++) {
cur_sec->idam.cyl = cyl_map[sec];
cur_sec->idam.head = head_map[sec];
cur_sec->idam.sec = sec_map[sec];
cur_sec->idam.no = no;
cur_sec->mark = mark_map[sec];
memcpy(cur_sec->dat, &dat[sec*sec_sz], sec_sz);
cur_sec = (struct ibm_sector *)
((char *)cur_sec + sizeof(struct ibm_sector) + sec_sz);
}
ti->total_bits = DEFAULT_BITS_PER_TRACK(d);
if (handlers[type]->density == trkden_high)
ti->total_bits *= 2;
gap_bits = ti->total_bits - nr_secs * ((is_fm ? 33 : 62) + sec_sz) * 16;
if (gap_bits < 0)
errx(1, "Too much data for track!");
ibm_track->has_iam = 1;
ibm_track->post_data_gap = choose_post_data_gap(
ti, ibm_track, gap_bits, nr_secs);
ti->data_bitoff = (is_fm ? 40 : 80) * 16;
ti->nr_sectors = nr_secs;
set_all_sectors_valid(ti);
}
void retrieve_ibm_mfm_track(
struct disk *d, unsigned int tracknr,
uint8_t **psec_map, uint8_t **pcyl_map,
uint8_t **phead_map, uint8_t **pno_map,
uint8_t **pmark_map, uint16_t **pcrc_map,
uint8_t **pdat)
{
struct track_info *ti = &d->di->track[tracknr];
struct ibm_track *ibm_track = (struct ibm_track *)ti->dat;
struct ibm_sector *cur_sec;
uint8_t *sec_map, *cyl_map, *head_map, *no_map, *mark_map, *dat;
uint16_t *crc_map;
unsigned int sec, sec_sz, dat_sz = 0;
cur_sec = ibm_track->secs;
for (sec = 0; sec < ti->nr_sectors; sec++) {
sec_sz = 128u << cur_sec->idam.no;
dat_sz += sec_sz;
cur_sec = (struct ibm_sector *)
((char *)cur_sec + sizeof(struct ibm_sector) + sec_sz);
}
*psec_map = sec_map = memalloc(ti->nr_sectors);
*pcyl_map = cyl_map = memalloc(ti->nr_sectors);
*phead_map = head_map = memalloc(ti->nr_sectors);
*pno_map = no_map = memalloc(ti->nr_sectors);
*pmark_map = mark_map = memalloc(ti->nr_sectors);
*pcrc_map = crc_map = memalloc(ti->nr_sectors * sizeof(uint16_t));
*pdat = dat = memalloc(dat_sz);
cur_sec = ibm_track->secs;
for (sec = 0; sec < ti->nr_sectors; sec++) {
sec_sz = 128u << cur_sec->idam.no;
cyl_map[sec] = cur_sec->idam.cyl;
head_map[sec] = cur_sec->idam.head;
sec_map[sec] = cur_sec->idam.sec;
no_map[sec] = cur_sec->idam.no;
mark_map[sec] = cur_sec->mark;
crc_map[sec] = cur_sec->crc;
memcpy(dat, cur_sec->dat, sec_sz);
dat += sec_sz;
cur_sec = (struct ibm_sector *)
((char *)cur_sec + sizeof(struct ibm_sector) + sec_sz);
}
}
struct track_handler ibm_mfm_dd_handler = {
.density = trkden_double,
.get_name = ibm_get_name,
.write_raw = ibm_mfm_write_raw,
.read_raw = ibm_mfm_read_raw,
.read_sectors = ibm_read_sectors
};
struct track_handler ibm_mfm_hd_handler = {
.density = trkden_high,
.get_name = ibm_get_name,
.write_raw = ibm_mfm_write_raw,
.read_raw = ibm_mfm_read_raw,
.read_sectors = ibm_read_sectors
};
struct track_handler ibm_mfm_ed_handler = {
.density = trkden_extra,
.get_name = ibm_get_name,
.write_raw = ibm_mfm_write_raw,
.read_raw = ibm_mfm_read_raw,
.read_sectors = ibm_read_sectors
};
struct track_handler ibm_mfm_dd_recovery_handler = {
.density = trkden_double,
.get_name = ibm_get_name,
.write_raw = ibm_mfm_write_raw,
.read_raw = ibm_mfm_read_raw,
.read_sectors = ibm_read_sectors
};
/**********************************
* Single-density (IBM-FM) handlers
*/
#define IBM_FM_IAM_CLK 0xd7
#define IBM_FM_IAM_RAW 0xf77a
#define IBM_FM_SYNC_CLK 0xc7
#define DEC_RX02_MMFM_DAM_DAT 0xfd
#define DEC_RX02_MMFM_DDAM_DAT 0xf9
static int ibm_fm_scan_mark(
struct stream *s, unsigned int max_scan, uint8_t *pmark)
{
int idx_off = -1;
do {
if (((s->word>>16) != 0xaaaa) ||
((uint8_t)mfm_decode_word(s->word>>1) != IBM_FM_SYNC_CLK))
continue;
idx_off = s->index_offset_bc - 111;
if (idx_off < 0)
idx_off += s->track_len_bc;
*pmark = (uint8_t)mfm_decode_word(s->word);
stream_start_crc(s);
s->crc16_ccitt = crc16_ccitt(pmark, 1, 0xffff);
break;
} while ((stream_next_bit(s) != -1) && --max_scan);
return idx_off;
}
static int ibm_fm_scan_idam(struct stream *s, struct ibm_idam *idam)
{
uint8_t mark;
int idx_off;
idx_off = ibm_fm_scan_mark(s, ~0u, &mark);
if ((idx_off < 0) || (mark != IBM_MARK_IDAM))
goto fail;
/* cyl,head */
if (stream_next_bits(s, 32) == -1)
goto fail;
idam->cyl = mfm_decode_word(s->word >> 16);
idam->head = mfm_decode_word(s->word);
/* sec,no */
if (stream_next_bits(s, 32) == -1)
goto fail;
idam->sec = mfm_decode_word(s->word >> 16);
idam->no = mfm_decode_word(s->word);
/* crc */
if (stream_next_bits(s, 32) == -1)
goto fail;
idam->crc = s->crc16_ccitt;
return idx_off;
fail:
return -1;
}
static void *ibm_fm_write_raw(
struct disk *d, unsigned int tracknr, struct stream *s)
{
struct track_info *ti = &d->di->track[tracknr];
struct ibm_psector *ibm_secs, *new_sec, *cur_sec, *next_sec, **pprev_sec;
struct ibm_track *ibm_track = NULL;
unsigned int dat_bytes = 0, gap_bits, nr_blocks = 0;
unsigned int sec_sz;
bool_t iam = 0, is_dec = 0;
switch (ti->type) {
case TRKTYP_dec_rx01:
case TRKTYP_dec_rx02:
case TRKTYP_dec_rx01_525:
case TRKTYP_dec_rx02_525:
is_dec = 1;
stream_set_density(s, stream_get_density(s)*2);
break;
}
/* IAM */
while (!iam && (stream_next_bit(s) != -1))
iam = (s->word == (0xaaaa0000|IBM_FM_IAM_RAW));
stream_reset(s);
ibm_secs = NULL;
while (stream_next_bit(s) != -1) {
int idx_off;
uint8_t mark, dat[2*16384];
uint16_t crc;
struct ibm_idam idam;
/* IDAM */
if ((idx_off = ibm_fm_scan_idam(s, &idam)) < 0)
continue;
/* If the IDAM CRC is bad we cannot trust the sector data: we always
* skip the sector data in this case. CRC errors can also happen from
* cross-talk (40-track disk read as 80-track). */
if (idam.crc) {
#if CRC_DEBUG
/* Warn if we are recovering */
if (is_recovery_type(ti->type)) {
trk_warn(ti, tracknr, "IDAM CRC cyl:%2d, head:%2d, sec:%2d, "
"no:%2d, crc:%04x, offset:%5d",
idam.cyl, idam.head, idam.sec,
idam.no, idam.crc, idx_off);
}
#endif
/* TODO: try to reconstruct the correct idam ... */
continue;
}
if (idam.no > 7) {
trk_warn(ti, tracknr, "Unexpected IDAM no=%02x", idam.no);
continue;
}
sec_sz = 128 << idam.no;
/* DAM/DDAM */
if (ibm_fm_scan_mark(s, 1000, &mark) < 0)
continue;
if (((ti->type == TRKTYP_dec_rx02)
|| (ti->type == TRKTYP_dec_rx02_525))
&& ((mark == DEC_RX02_MMFM_DAM_DAT)
|| (mark == DEC_RX02_MMFM_DDAM_DAT))) {
int i, rc;
uint16_t x = 1;
crc = s->crc16_ccitt;
idam.no = 1;
sec_sz = 256;
stream_set_density(s, stream_get_density(s)/2);
stream_next_bit(s); /* Skip second half of last 2us bitcell? */
rc = stream_next_bytes(s, dat, 2*(sec_sz+2));
stream_set_density(s, stream_get_density(s)*2);
if (rc == -1)
continue;
/* Undo RX02 modified MFM rule... */
for (i = 0; i < 2*(sec_sz+2); i++) {
x = (x << 8) | dat[i];
if (!(x & 0x1c0)) { dat[i-1] |= 1; x |= 0x40; }
if (!(x & 0x070)) x |= 0x50;
if (!(x & 0x01c)) x |= 0x14;
if (!(x & 0x007)) x |= 0x05;
dat[i] = x;
}
/* ...then extract data bits as usual. */
mfm_decode_bytes(bc_mfm, sec_sz+2, dat, dat);
crc = crc16_ccitt(dat, sec_sz+2, crc);
} else {
if (stream_next_bytes(s, dat, 2*sec_sz) == -1)
continue;
if (stream_next_bits(s, 32) == -1)
continue;
crc = s->crc16_ccitt;
mfm_decode_bytes(bc_mfm, sec_sz, dat, dat);
}
/* Skip bad data CRC unless we are doing data recovery. */
if (crc && !is_recovery_type(ti->type))
continue;
/* Find correct place for this sector in our linked list of sectors
* that we have decoded so far. */
pprev_sec = &ibm_secs;
cur_sec = *pprev_sec;
while (cur_sec && ((idx_off - cur_sec->offset) >= 1000)) {
pprev_sec = &cur_sec->next;
cur_sec = *pprev_sec;
}
/* If this sector's start is within 1000 bits of one we already decoded
* then it is the same sector: we decoded it already on an earlier
* revolution and can skip it this time round. */
if (cur_sec && (abs(idx_off - cur_sec->offset) < 1000)) {
/* Is this really the same sector? Check IDAM contents. */
if ((idam.cyl == cur_sec->s.idam.cyl) &&
(idam.head == cur_sec->s.idam.head) &&
(idam.sec == cur_sec->s.idam.sec) &&
(idam.no == cur_sec->s.idam.no)) {
/* If we now have a good CRC and the saved sector has a bad CRC
* we should try converting it again. */
if (!crc && cur_sec->s.crc) {
#ifdef CRC_DEBUG
trk_warn(ti, tracknr, "FIXED CRC cyl:%2d, head:%2d, "
"sec:%2d, no:%2d, size:%4x, offset:%5d",
idam.cyl, idam.head, idam.sec, idam.no,
sec_sz, idx_off);
#endif
/* Replace the previous bad sector header/data. */
cur_sec->offset = idx_off;
cur_sec->s.crc = crc;
cur_sec->s.mark = mark;
memcpy(&cur_sec->s.dat[0], dat, sec_sz);
memcpy(&cur_sec->s.idam, &idam, sizeof(idam));
}
} else {
/* This code should NEVER trigger */
trk_warn(ti, tracknr, "IDAM WARN"
" [cyl:%2d, head:%2d, sec:%2d, no:%2d, "
"crc:%04x, offset:%5d] != [cyl:%2d, head:%2d, "
"sec:%2d, no:%2d, crc:%04x, offset:%5d]",
idam.cyl, idam.head, idam.sec, idam.no,
crc, idx_off,
cur_sec->s.idam.cyl, cur_sec->s.idam.head,
cur_sec->s.idam.sec, cur_sec->s.idam.no,
cur_sec->s.idam.crc, cur_sec->offset);
}
continue;
}
#ifdef CRC_DEBUG
if (crc) {
trk_warn(ti, tracknr, "DATA CRC cyl:%2d, head:%2d, sec:%2d, "
"no:%2d, crc:%04x, offset:%5d",
idam.cyl, idam.head, idam.sec, idam.no, crc, idx_off);
}
#endif
/* Add a new sector. */
new_sec = memalloc(sizeof(*new_sec) + sec_sz);
new_sec->offset = idx_off;
new_sec->s.crc = crc;
new_sec->s.mark = mark;
memcpy(&new_sec->s.dat[0], dat, sec_sz);
memcpy(&new_sec->s.idam, &idam, sizeof(idam));
/* Add the new sector to linked list */
new_sec->next = *pprev_sec;
*pprev_sec = new_sec;
}
gap_bits = ti->total_bits - s->track_len_bc;
for (cur_sec = ibm_secs; cur_sec; cur_sec = cur_sec->next) {
int distance, cur_size;
next_sec = cur_sec->next ?: ibm_secs;
distance = next_sec->offset - cur_sec->offset;
if (distance <= 0)
distance += s->track_len_bc;
sec_sz = 128 << cur_sec->s.idam.no;
cur_size = 33 + sec_sz;
if ((distance -= cur_size * 16) < 0) {
trk_warn(ti, tracknr, "Overlapping sectors");
goto out;
}
gap_bits += distance;
nr_blocks++;
dat_bytes += sec_sz;
}
if (nr_blocks == 0)
goto out;
ti->data_bitoff = 40 * 16;
ti->nr_sectors = nr_blocks;
set_all_sectors_valid(ti);
ibm_track = memalloc(sizeof(struct ibm_track)
+ nr_blocks * sizeof(struct ibm_sector)
+ dat_bytes);
ibm_track->has_iam = iam ? 1 : 0;
ibm_track->post_data_gap = is_dec ? 27
: choose_post_data_gap(ti, ibm_track, gap_bits, nr_blocks);
ti->len = sizeof(struct ibm_track);
for (cur_sec = ibm_secs; cur_sec; cur_sec = cur_sec->next) {
sec_sz = 128 << cur_sec->s.idam.no;
memcpy((char *)ibm_track + ti->len,
&cur_sec->s, sizeof(struct ibm_sector) + sec_sz);
ti->len += sizeof(struct ibm_sector) + sec_sz;
}
out:
if (is_dec)
stream_set_density(s, stream_get_density(s)/2);
return ibm_track;
}
#define ENC_RAW (1u<<0)
#define ENC_HALFRATE (1u<<1)
static void fm_bits(struct tbuf *tbuf, unsigned int flags,
unsigned int bits, uint32_t x)
{
int i;
for (i = bits-1; i >= 0; i--) {
uint8_t b = (x >> i) & 1;
if (!(flags & ENC_RAW) || !(i & 1))
tbuf->crc16_ccitt = crc16_ccitt_bit(b, tbuf->crc16_ccitt);
if (!(flags & ENC_RAW)) {
if (flags & ENC_HALFRATE)
tbuf->bit(tbuf, SPEED_AVG, bc_raw, 0);
tbuf->bit(tbuf, SPEED_AVG, bc_raw, 1);
}
if (flags & ENC_HALFRATE)
tbuf->bit(tbuf, SPEED_AVG, bc_raw, 0);
tbuf->bit(tbuf, SPEED_AVG, bc_raw, b);
}
}
static uint16_t fm_sync(uint8_t dat, uint8_t clk)
{
unsigned int i;
uint16_t sync = 0;
for (i = 0; i < 8; i++) {
sync <<= 2;
sync |= ((clk & 0x80) ? 2 : 0) | ((dat & 0x80) ? 1 : 0);
clk <<= 1; dat <<= 1;
}
return sync;
}
static void ibm_fm_read_raw(
struct disk *d, unsigned int tracknr, struct tbuf *tbuf)
{
struct track_info *ti = &d->di->track[tracknr];
struct ibm_track *ibm_track = (struct ibm_track *)ti->dat;
struct ibm_sector *cur_sec;
unsigned int sec, i, j, sec_sz, flags = 0;
bool_t is_dec = 0;
tbuf_set_gap_fill_byte(tbuf, 0xff);
switch (ti->type) {
case TRKTYP_dec_rx01:
case TRKTYP_dec_rx02:
case TRKTYP_dec_rx01_525:
case TRKTYP_dec_rx02_525:
flags |= ENC_HALFRATE;
is_dec = 1;
break;
}
/* IAM */
if (ibm_track->has_iam) {
for (i = 0; i < 6; i++)
fm_bits(tbuf, flags, 8, 0x00);
fm_bits(tbuf, flags|ENC_RAW, 16, IBM_FM_IAM_RAW);
for (i = 0; i < ibm_track->post_data_gap; i++)
fm_bits(tbuf, flags, 8, 0xff);
}
cur_sec = ibm_track->secs;
for (sec = 0; sec < ti->nr_sectors; sec++) {
sec_sz = 128 << cur_sec->idam.no;
/* IDAM */
for (i = 0; i < 6; i++)
fm_bits(tbuf, flags, 8, 0x00);
tbuf_start_crc(tbuf);
fm_bits(tbuf, flags|ENC_RAW, 16,
fm_sync(IBM_MARK_IDAM, IBM_FM_SYNC_CLK));
fm_bits(tbuf, flags, 8, cur_sec->idam.cyl);
fm_bits(tbuf, flags, 8, cur_sec->idam.head);
fm_bits(tbuf, flags, 8, cur_sec->idam.sec);
fm_bits(tbuf, flags, 8, is_dec ? 0 : cur_sec->idam.no);
fm_bits(tbuf, flags, 16, tbuf->crc16_ccitt);
for (i = 0; i < 11; i++)
fm_bits(tbuf, flags, 8, 0xff);
/* DAM */
for (i = 0; i < 6; i++)
fm_bits(tbuf, flags, 8, 0x00);
tbuf_start_crc(tbuf);
fm_bits(tbuf, flags|ENC_RAW, 16,
fm_sync(cur_sec->mark, IBM_FM_SYNC_CLK));
if ((cur_sec->mark == DEC_RX02_MMFM_DAM_DAT)
|| (cur_sec->mark == DEC_RX02_MMFM_DDAM_DAT)) {
uint8_t w8, dat[256+2+2];
uint16_t w16, mmfm[256+2+2], crc;
uint32_t w32;
crc = crc16_ccitt(cur_sec->dat, 256, tbuf->crc16_ccitt);
flags &= ~ENC_HALFRATE;
fm_bits(tbuf, flags|ENC_RAW, 1, 0); /* 1us of delay to next flux */
/* MMFM area: Data, CRC, lead-out. */
memcpy(dat, cur_sec->dat, 256);
dat[256+0] = crc >> 8; dat[256+1] = crc;
dat[256+2+0] = dat[256+2+1] = 0xff;
/* Normal MFM encoding. */
for (i = w16 = 0; i < sizeof(dat); i++) {
w8 = dat[i];
for (j = 0; j < 8; j++) {
w16 <<= 2;
w16 |= (w8 >> (7-j)) & 1;
if (!(w16 & 5))
w16 |= 2;
}
mmfm[i] = w16;
}
/* Apply the extra DEC-RX02 rule: 011110 -> 01000100010. */
for (i = w32 = 0; i < sizeof(dat); i++) {
w32 = (w32 << 16) | mmfm[i];
for (j = 0; j < 16; j += 2) {
if ((w32 & (0x555u << (14-j))) == (0x154u << (14-j))) {
w32 &= ~(0x7ffu << (14-j));
w32 |= 0x222u << (14-j);
}
}
if (i)
mmfm[i-1] = w32 >> 16;
}
for (i = 0; i < sizeof(dat); i++)
fm_bits(tbuf, flags|ENC_RAW, 16, mmfm[i]);
flags |= ENC_HALFRATE;
} else {
for (i = 0; i < sec_sz; i++)
fm_bits(tbuf, flags, 8, cur_sec->dat[i]);
fm_bits(tbuf, flags, 16, tbuf->crc16_ccitt);
}
for (i = 0; i < ibm_track->post_data_gap; i++)
fm_bits(tbuf, flags, 8, 0xff);
cur_sec = (struct ibm_sector *)
((char *)cur_sec + sizeof(struct ibm_sector) + sec_sz);
}
}
static void *dec_write_sectors(
struct disk *d, unsigned int tracknr, struct track_sectors *sectors)
{
struct track_info *ti = &d->di->track[tracknr];
struct ibm_track *trk;
struct ibm_sector *sec;
unsigned int i;
char *block;
if (sectors->nr_bytes < ti->len)
return NULL;
ti->len += sizeof(*trk);
ti->len += ti->nr_sectors * (sizeof(*sec) + ti->bytes_per_sector);
block = memalloc(ti->len);
trk = (struct ibm_track *)block;
trk->has_iam = 1;
trk->post_data_gap = 27;
sec = trk->secs;
for (i = 0; i < ti->nr_sectors; i++) {
sec->idam.cyl = tracknr/2;
sec->idam.head = 0;
sec->idam.sec = i + ((tracknr&1) ? 14 : 1);
sec->idam.crc = 0;
sec->crc = 0;
if (ti->bytes_per_sector == 256) {
sec->idam.no = 1;
sec->mark = DEC_RX02_MMFM_DAM_DAT;
} else { /* TRKTYP_dec_rx01 */
sec->idam.no = 0;
sec->mark = IBM_MARK_DAM;
}
memcpy(sec->dat, sectors->data, ti->bytes_per_sector);
sectors->data += ti->bytes_per_sector;
sectors->nr_bytes -= ti->bytes_per_sector;
sec = (struct ibm_sector *)
((char *)sec + sizeof(struct ibm_sector) + ti->bytes_per_sector);
}
ti->data_bitoff = 40*16;
return block;
}
struct track_handler ibm_fm_sd_handler = {
.density = trkden_single,
.get_name = ibm_get_name,
.write_raw = ibm_fm_write_raw,
.read_raw = ibm_fm_read_raw,
.read_sectors = ibm_read_sectors
};
struct track_handler ibm_fm_dd_handler = {
.density = trkden_double,
.get_name = ibm_get_name,
.write_raw = ibm_fm_write_raw,
.read_raw = ibm_fm_read_raw,
.read_sectors = ibm_read_sectors
};
struct track_handler dec_rx01_handler = {
.density = trkden_high,
.get_name = ibm_get_name,
.write_raw = ibm_fm_write_raw,
.read_raw = ibm_fm_read_raw,
.read_sectors = ibm_read_sectors,
.write_sectors = dec_write_sectors,
.bytes_per_sector = 128,
.nr_sectors = 26
};
struct track_handler dec_rx02_handler = {
.density = trkden_high,
.get_name = ibm_get_name,
.write_raw = ibm_fm_write_raw,
.read_raw = ibm_fm_read_raw,
.read_sectors = ibm_read_sectors,
.write_sectors = dec_write_sectors,
.bytes_per_sector = 256,
.nr_sectors = 26
};
/* Micro Technology manufactured dual-density third-party interfaces (MXV22M,
* MXV42C) for the DEC RX02 subsystem. They write to 300RPM 5.25" DSDD disks.
* Sectors 1-13 on side 0, Sectors 14-26 on side 1. */
struct track_handler dec_rx01_525_handler = {
.density = trkden_double,
.get_name = ibm_get_name,
.write_raw = ibm_fm_write_raw,
.read_raw = ibm_fm_read_raw,
.read_sectors = ibm_read_sectors,
.write_sectors = dec_write_sectors,
.bytes_per_sector = 128,
.nr_sectors = 13
};
struct track_handler dec_rx02_525_handler = {
.density = trkden_double,
.get_name = ibm_get_name,
.write_raw = ibm_fm_write_raw,
.read_raw = ibm_fm_read_raw,
.read_sectors = ibm_read_sectors,
.write_sectors = dec_write_sectors,
.bytes_per_sector = 256,
.nr_sectors = 13
};
struct track_handler ibm_fm_sd_recovery_handler = {
.density = trkden_single,
.get_name = ibm_get_name,
.write_raw = ibm_fm_write_raw,
.read_raw = ibm_fm_read_raw,
.read_sectors = ibm_read_sectors
};
/*
* Local variables:
* mode: C
* c-file-style: "Linux"
* c-basic-offset: 4
* tab-width: 4
* indent-tabs-mode: nil
* End:
*/
| 32.354452 | 79 | 0.548029 |
d96f07dcc8d15f7f802ca83eed1ae9f88370749a | 11,867 | c | C | src/efi_main.c | tenpoku1000/UEFI_SecureBoot | 6a58d4e2c3b7daffb113450b36840bc3aaefeb40 | [
"MIT"
] | 15 | 2015-09-22T06:23:18.000Z | 2022-01-06T17:20:00.000Z | src/efi_main.c | tenpoku1000/UEFI_SecureBoot | 6a58d4e2c3b7daffb113450b36840bc3aaefeb40 | [
"MIT"
] | null | null | null | src/efi_main.c | tenpoku1000/UEFI_SecureBoot | 6a58d4e2c3b7daffb113450b36840bc3aaefeb40 | [
"MIT"
] | 1 | 2020-10-23T17:06:45.000Z | 2020-10-23T17:06:45.000Z |
// Copyright 2015 Shin'ichi Ichikawa. Released under the MIT license.
#include "secure_boot_mode.h"
#include "setup_screen.h"
#include "tp_UDKenv.h"
#include "tp_draw_logo.h"
#define EFI_RUNTIME_NOT_USE_AFTER_EXITBOOTSERVICES 1
#define SCREEN_WIDTH 1024
static EFI_HANDLE IH = NULL;
static EFI_GRAPHICS_OUTPUT_PROTOCOL* gop = NULL;
static EFI_LOADED_IMAGE* loaded_image = NULL;
typedef struct mem_map_ {
UINTN memory_map_size;
EFI_MEMORY_DESCRIPTOR* memory_map;
UINTN map_key;
UINTN descriptor_size;
UINT32 descriptor_version;
}mem_map;
static mem_map MM = { 0 };
typedef enum UEFI_KEYS_{
UEFI_KEYS_EXISTS,
UEFI_KEYS_OPEN,
}UEFI_KEYS_METHOD;
static void init(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE* system_table);
static void boot_exec(void);
static bool file_name_match(CHAR16* path, CHAR16* file_name);
static void boot_self_signed(void);
static bool uefi_keys(
UEFI_KEYS_METHOD method,
EFI_FILE_HANDLE* pk_file, EFI_FILE_HANDLE* kek_file, EFI_FILE_HANDLE* db_file
);
static void regist_uefi_keys(void);
static void boot_common(void);
static void exit_boot_services(void);
static void get_memory_map(void);
EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE* system_table)
{
init(image_handle, system_table);
tp_draw_logo(gop);
boot_exec();
return EFI_SUCCESS;
}
static void init(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE* system_table)
{
InitializeLib(image_handle, system_table);
IH = image_handle;
tp_set_uefi_pointers(image_handle, system_table);
EFI_STATUS status = EFI_SUCCESS;
if ((NULL == ST->ConIn) || (EFI_SUCCESS != (status = ST->ConIn->Reset(ST->ConIn, 0)))){
error_print(L"Input device unavailable.\n", ST->ConIn ? &status : NULL);
}
status = BS->OpenProtocol(
image_handle, &LoadedImageProtocol, &loaded_image,
image_handle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR(status)){
error_print(L"OpenProtocol() LoadedImageProtocol failed.\n", &status);
}
UINTN number_gop_handles = 0;
EFI_HANDLE* gop_handles = NULL;
status = BS->LocateHandleBuffer(
ByProtocol,
&GraphicsOutputProtocol,
NULL,
&number_gop_handles,
&gop_handles
);
if (EFI_ERROR(status)){
error_print(L"LocateHandleBuffer() GraphicsOutputProtocol failed.\n", &status);
}
status = BS->OpenProtocol(
gop_handles[0], &GraphicsOutputProtocol, &gop,
image_handle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR(status)){
error_print(L"OpenProtocol() GraphicsOutputProtocol failed.\n", &status);
}
FreePool(gop_handles);
gop_handles = NULL;
int mode_num = 0;
int set_mode_num = 0;
bool valid_query_mode = false;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION* mode_info;
UINTN size = 0;
UINT32 HorizontalResolution = 0;
for (; (status = gop->QueryMode(gop, mode_num, &size, &mode_info)) == EFI_SUCCESS; ++mode_num){
if (PixelBlueGreenRedReserved8BitPerColor != mode_info->PixelFormat) {
continue;
}
if (HorizontalResolution < mode_info->HorizontalResolution){
HorizontalResolution = mode_info->HorizontalResolution;
set_mode_num = mode_num;
valid_query_mode = true;
if (HorizontalResolution == SCREEN_WIDTH) {
break;
}
}
}
if (false == valid_query_mode){
error_print(L"QueryMode() GOP failed.\n", NULL);
}
status = gop->SetMode(gop, set_mode_num);
if (EFI_ERROR(status)){
error_print(L"SetMode() GOP failed.\n", &status);
}
}
static void boot_exec()
{
CHAR16* path = DevicePathToStr(loaded_image->FilePath);
if (path){
if (file_name_match(path, L"GRUBX64.EFI")){
boot_common();
}else if (file_name_match(path, L"BOOTX64.EFI")){
boot_self_signed();
}else{
Print(L"Bad file name(%s).\n", path);
}
FreePool(path);
path = NULL;
}else{
error_print(L"DevicePathToStr() failed.\n", NULL);
}
}
static bool file_name_match(CHAR16* path, CHAR16* file_name)
{
UINTN file_name_length = StrLen(file_name);
for (UINTN i = 0; L'\0' != path[i]; ++i){
if (L'\\' == path[i]){
++i;
if (L'\0' == path[i]){
break;
}
CHAR16* str = path + i;
UINTN length = StrLen(str);
if (length > file_name_length){
length = file_name_length;
}
if (0 == StrnCmp(str, file_name, length)){
return true;
}
}
}
return false;
}
static void boot_self_signed(void)
{
bool is_exists_keys = uefi_keys(UEFI_KEYS_EXISTS, NULL, NULL, NULL);
if (is_exists_keys){
bool is_unknown_mode = false;
if (is_secure_boot_setup_mode(&is_unknown_mode)){
regist_uefi_keys();
}else{
if (is_unknown_mode){
boot_common();
}else{
transition_setup_screen(false);
}
}
}else{
boot_common();
}
}
static bool uefi_keys(
UEFI_KEYS_METHOD method,
EFI_FILE_HANDLE* pk_file, EFI_FILE_HANDLE* kek_file, EFI_FILE_HANDLE* db_file)
{
EFI_FILE_IO_INTERFACE* efi_simple_file_system = NULL;
EFI_FILE* efi_file_root = NULL;
EFI_FILE* efi_file = NULL;
EFI_STATUS status = BS->OpenProtocol(
loaded_image->DeviceHandle,
&FileSystemProtocol,
&efi_simple_file_system,
IH,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR(status)){
error_print(L"OpenProtocol() FileSystemProtocol failed.\n", &status);
}
status = efi_simple_file_system->OpenVolume(
efi_simple_file_system, &efi_file_root
);
if (EFI_ERROR(status)){
error_print(L"OpenVolume() failed.\n", &status);
}
CHAR16* path[] = {
L"\\EFI\\BOOT\\PKSELF.CER",
L"\\EFI\\BOOT\\KEKSELF.CER",
L"\\EFI\\BOOT\\DBSELF.CER",
NULL
};
enum PK_KEK_INDEX_{
PK_INDEX = 0,
KEK_INDEX,
DB_INDEX,
};
for (int i = 0; NULL != path[i]; ++i){
status = efi_file_root->Open(
efi_file_root, &efi_file, path[i],
EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0
);
if ((UEFI_KEYS_EXISTS == method) && (EFI_NOT_FOUND == status)){
return false;
}
if (EFI_ERROR(status)){
error_print(L"Open() failed.\n", &status);
}
if (UEFI_KEYS_OPEN == method){
switch (i) {
case PK_INDEX:
*pk_file = efi_file;
break;
case KEK_INDEX:
*kek_file = efi_file;
break;
case DB_INDEX:
*db_file = efi_file;
break;
default:
error_print(L"Bad index value.\n", NULL);
}
}
}
return true;
}
static void regist_uefi_keys(void)
{
EFI_STATUS status = tp_begin_enroll_keys();
if (EFI_ERROR(status)){
error_print(L"tp_begin_enroll_keys() failed.\n", &status);
}
EFI_FILE_HANDLE pk_file = NULL;
EFI_FILE_HANDLE kek_file = NULL;
EFI_FILE_HANDLE db_file = NULL;
if (false == uefi_keys(UEFI_KEYS_OPEN, &pk_file, &kek_file, &db_file)){
error_print(L"uefi_keys(UEFI_KEYS_OPEN) failed.\n", NULL);
}
CHAR16* db_file_name = L"dbself.cer";
status = tp_enroll_uefi_key(
ENROLL_UEFI_KEY_DB, db_file, db_file_name
);
if (EFI_ERROR(status)){
(void)pk_file->Close(pk_file);
(void)kek_file->Close(kek_file);
(void)db_file->Close(db_file);
error_print(L"tp_enroll_uefi_key(ENROLL_UEFI_KEY_DB) failed.\n", &status);
}
CHAR16* kek_file_name = L"kekself.cer";
status = tp_enroll_uefi_key(
ENROLL_UEFI_KEY_KEK, kek_file, kek_file_name
);
if (EFI_ERROR(status)){
(void)pk_file->Close(pk_file);
(void)kek_file->Close(kek_file);
(void)db_file->Close(db_file);
error_print(L"tp_enroll_uefi_key(ENROLL_UEFI_KEY_KEK) failed.\n", &status);
}
CHAR16* pk_file_name = L"pkself.cer";
status = tp_enroll_uefi_key(
ENROLL_UEFI_KEY_PK, pk_file, pk_file_name
);
if (EFI_ERROR(status)){
(void)pk_file->Close(pk_file);
(void)kek_file->Close(kek_file);
(void)db_file->Close(db_file);
error_print(L"tp_enroll_uefi_key(ENROLL_UEFI_KEY_PK) failed.\n", &status);
}
tp_end_enroll_keys();
status = pk_file->Delete(db_file);
if (EFI_ERROR(status)){
error_print(L"Delete(DB) failed.\n", &status);
}
status = pk_file->Delete(pk_file);
if (EFI_ERROR(status)){
error_print(L"Delete(PK) failed.\n", &status);
}
pk_file = NULL;
status = kek_file->Delete(kek_file);
if (EFI_ERROR(status)){
error_print(L"Delete(KEK) failed.\n", &status);
}
kek_file = NULL;
Print(L"Successful registration of PK, KEK and DB.\n");
transition_setup_screen(true);
}
static void boot_common(void)
{
Print(L"After pressing any key, the system is reset in the case of a successful execution of ExitBootServices().\n");
read_key();
exit_boot_services();
#if EFI_RUNTIME_NOT_USE_AFTER_EXITBOOTSERVICES
tp_reset_cold();
#else
EFI_STATUS status = RT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL);
if (EFI_ERROR(status)){
return;
}
#endif
}
static void exit_boot_services(void)
{
BS->SetMem(&MM, sizeof(MM), 0);
bool retry = false;
retry:
;
get_memory_map();
UINTN num = MM.memory_map_size / MM.descriptor_size;
EFI_MEMORY_DESCRIPTOR* memory_map = MM.memory_map;
for (UINTN i = 0; num > i; ++i){
// UEFI 2.6 Specification
//
// 2.3.4 x64 Platforms
//
// Any UEFI memory descriptor that requests a virtual mapping via the
// EFI_MEMORY_DESCRIPTOR having the EFI_MEMORY_RUNTIME bit set must be aligned
// on a 4 KiB boundary and must be a multiple of 4 KiB in size.
//
if (memory_map->Attribute & EFI_MEMORY_RUNTIME){
memory_map->VirtualStart = memory_map->PhysicalStart;
}
memory_map = (EFI_MEMORY_DESCRIPTOR*)(((UINT8*)memory_map) + MM.descriptor_size);
}
EFI_STATUS status = BS->ExitBootServices(IH, MM.map_key);
if (EFI_ERROR(status)){
if (retry){
error_print(L"ExitBootServices() faild.\n", &status);
}
retry = true;
goto retry;
}
BS = NULL;
set_exit_boot_services();
status = RT->SetVirtualAddressMap(
MM.memory_map_size,
MM.descriptor_size,
MM.descriptor_version,
MM.memory_map
);
if (EFI_ERROR(status)){
tp_reset_cold();
return;
}
}
static void get_memory_map(void)
{
MM.memory_map_size = 0;
for (;;){
if (MM.memory_map){
FreePool(MM.memory_map);
MM.memory_map = NULL;
}
EFI_STATUS status = BS->AllocatePool(EfiLoaderData, MM.memory_map_size, &MM.memory_map);
if (EFI_ERROR(status)){
error_print(L"AllocatePool() failed.\n", &status);
}
status = BS->GetMemoryMap(
&MM.memory_map_size, MM.memory_map,
&MM.map_key, &MM.descriptor_size, &MM.descriptor_version
);
if (EFI_BUFFER_TOO_SMALL == status){
continue;
}
if (EFI_SUCCESS != status){
error_print(L"GetMemoryMap() failed.\n", &status);
}
break;
}
}
| 21.894834 | 121 | 0.608326 |
d971bafa8e89d09181745808a9bb3d76351f3ca6 | 2,625 | h | C | aws-cpp-sdk-resiliencehub/include/aws/resiliencehub/model/TerraformSource.h | Nexuscompute/aws-sdk-cpp | e7ef485e46e6962c9e084b8c9b104c1bfcceaf26 | [
"Apache-2.0"
] | 1 | 2022-01-05T18:20:03.000Z | 2022-01-05T18:20:03.000Z | aws-cpp-sdk-resiliencehub/include/aws/resiliencehub/model/TerraformSource.h | Nexuscompute/aws-sdk-cpp | e7ef485e46e6962c9e084b8c9b104c1bfcceaf26 | [
"Apache-2.0"
] | null | null | null | aws-cpp-sdk-resiliencehub/include/aws/resiliencehub/model/TerraformSource.h | Nexuscompute/aws-sdk-cpp | e7ef485e46e6962c9e084b8c9b104c1bfcceaf26 | [
"Apache-2.0"
] | 1 | 2021-11-09T12:02:58.000Z | 2021-11-09T12:02:58.000Z | /**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#pragma once
#include <aws/resiliencehub/ResilienceHub_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <utility>
namespace Aws
{
namespace Utils
{
namespace Json
{
class JsonValue;
class JsonView;
} // namespace Json
} // namespace Utils
namespace ResilienceHub
{
namespace Model
{
/**
* <p> The Terraform s3 state file you need to import. </p><p><h3>See Also:</h3>
* <a
* href="http://docs.aws.amazon.com/goto/WebAPI/resiliencehub-2020-04-30/TerraformSource">AWS
* API Reference</a></p>
*/
class AWS_RESILIENCEHUB_API TerraformSource
{
public:
TerraformSource();
TerraformSource(Aws::Utils::Json::JsonView jsonValue);
TerraformSource& operator=(Aws::Utils::Json::JsonView jsonValue);
Aws::Utils::Json::JsonValue Jsonize() const;
/**
* <p> The Terraform s3 state file you need to import. </p>
*/
inline const Aws::String& GetS3StateFileUrl() const{ return m_s3StateFileUrl; }
/**
* <p> The Terraform s3 state file you need to import. </p>
*/
inline bool S3StateFileUrlHasBeenSet() const { return m_s3StateFileUrlHasBeenSet; }
/**
* <p> The Terraform s3 state file you need to import. </p>
*/
inline void SetS3StateFileUrl(const Aws::String& value) { m_s3StateFileUrlHasBeenSet = true; m_s3StateFileUrl = value; }
/**
* <p> The Terraform s3 state file you need to import. </p>
*/
inline void SetS3StateFileUrl(Aws::String&& value) { m_s3StateFileUrlHasBeenSet = true; m_s3StateFileUrl = std::move(value); }
/**
* <p> The Terraform s3 state file you need to import. </p>
*/
inline void SetS3StateFileUrl(const char* value) { m_s3StateFileUrlHasBeenSet = true; m_s3StateFileUrl.assign(value); }
/**
* <p> The Terraform s3 state file you need to import. </p>
*/
inline TerraformSource& WithS3StateFileUrl(const Aws::String& value) { SetS3StateFileUrl(value); return *this;}
/**
* <p> The Terraform s3 state file you need to import. </p>
*/
inline TerraformSource& WithS3StateFileUrl(Aws::String&& value) { SetS3StateFileUrl(std::move(value)); return *this;}
/**
* <p> The Terraform s3 state file you need to import. </p>
*/
inline TerraformSource& WithS3StateFileUrl(const char* value) { SetS3StateFileUrl(value); return *this;}
private:
Aws::String m_s3StateFileUrl;
bool m_s3StateFileUrlHasBeenSet;
};
} // namespace Model
} // namespace ResilienceHub
} // namespace Aws
| 29.166667 | 130 | 0.67619 |
d971d803b12c5664e3a327a5ecd0825e2bdee2c1 | 832 | h | C | DropboxSDK/MPOAuthURLRequest.h | agilebits/Dropbox-SDK | a2a0879ab65db000ef8d4c342cd5d5f1948835df | [
"MIT"
] | 1 | 2020-03-26T20:52:32.000Z | 2020-03-26T20:52:32.000Z | DropboxSDK/MPOAuthURLRequest.h | agilebits/Dropbox-SDK | a2a0879ab65db000ef8d4c342cd5d5f1948835df | [
"MIT"
] | null | null | null | DropboxSDK/MPOAuthURLRequest.h | agilebits/Dropbox-SDK | a2a0879ab65db000ef8d4c342cd5d5f1948835df | [
"MIT"
] | null | null | null | //
// MPOAuthURLRequest.h
// MPOAuthConnection
//
// Created by Karl Adam on 08.12.05.
// Copyright 2008 matrixPointer. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface MPOAuthURLRequest : NSObject {
@private
NSURL *_url;
NSString *_httpMethod;
NSURLRequest *_urlRequest;
NSMutableArray *_parameters;
}
@property (nonatomic, strong) NSURL *url;
@property (nonatomic, strong) NSString *HTTPMethod;
@property (nonatomic, readonly) NSURLRequest *urlRequest;
@property (nonatomic, strong) NSMutableArray *parameters;
- (id)initWithURL:(NSURL *)inURL andParameters:(NSArray *)parameters;
- (id)initWithURLRequest:(NSURLRequest *)inRequest;
- (void)addParameters:(NSArray *)inParameters;
- (NSMutableURLRequest*)urlRequestSignedWithSecret:(NSString *)inSecret usingMethod:(NSString *)inScheme;
@end
| 25.212121 | 105 | 0.762019 |
d9726e66edbf97a1339b2ee507731205c94dae17 | 764 | h | C | drivers/crypto/caam/error.h | xqdzn/linux-bpi-p2z-dev | fc302d86fb16fff3a25894efd3d5dd9e8e379a82 | [
"MIT"
] | null | null | null | drivers/crypto/caam/error.h | xqdzn/linux-bpi-p2z-dev | fc302d86fb16fff3a25894efd3d5dd9e8e379a82 | [
"MIT"
] | null | null | null | drivers/crypto/caam/error.h | xqdzn/linux-bpi-p2z-dev | fc302d86fb16fff3a25894efd3d5dd9e8e379a82 | [
"MIT"
] | null | null | null | /* SPDX-License-Identifier: GPL-2.0 */
/*
* CAAM Error Reporting code header
*
* Copyright 2009-2011 Freescale Semiconductor, Inc.
*/
#ifndef CAAM_ERROR_H
#define CAAM_ERROR_H
#include "desc.h"
#define CAAM_ERROR_STR_MAX 302
void caam_strstatus(struct device *dev, u32 status, bool qi_v2);
#define caam_jr_strstatus(jrdev, status) caam_strstatus(jrdev, status, false)
#define caam_qi2_strstatus(qidev, status) caam_strstatus(qidev, status, true)
void caam_dump_sg(const char *prefix_str, int prefix_type,
int rowsize, int groupsize, struct scatterlist *sg,
size_t tlen, bool ascii);
static inline bool is_mdha(u32 algtype)
{
return (algtype & OP_ALG_ALGSEL_MASK & ~OP_ALG_ALGSEL_SUBMASK) ==
OP_ALG_CHA_MDHA;
}
#endif /* CAAM_ERROR_H */
| 25.466667 | 77 | 0.753927 |
d973429ade5a1f5972ca53a33993c3851d76f538 | 2,133 | h | C | Pods/Headers/Public/OneDriveSDK/ODLogger.h | spanfish/3dview | f3ccfcbd35208b4e8528f3f3a3a3ef58cff0ecb4 | [
"BSD-3-Clause"
] | null | null | null | Pods/Headers/Public/OneDriveSDK/ODLogger.h | spanfish/3dview | f3ccfcbd35208b4e8528f3f3a3a3ef58cff0ecb4 | [
"BSD-3-Clause"
] | null | null | null | Pods/Headers/Public/OneDriveSDK/ODLogger.h | spanfish/3dview | f3ccfcbd35208b4e8528f3f3a3a3ef58cff0ecb4 | [
"BSD-3-Clause"
] | null | null | null | // Copyright 2015 Microsoft Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import <Foundation/Foundation.h>
#import "ODLoggerProtocol.h"
/**
Simple Logger for the OneDriveSDK will log everything to the console using NSLog
## Writing to a File
If you wish to log to a file instead of the console, it is easiest to subclass the ODLogger and overload writeMessage:
This method will have the constructed string passed into the [ODLogger logWithLevel:message:] method and passed it along
to the writeMessage: method
@see writeMessage:
*/
@interface ODLogger : NSObject <ODLogger>
/**
Creates the logger with the given level
@param level the level to create the logger with
@see ODLogLevel
*/
- (instancetype)initWithLogLevel:(ODLogLevel)level;
/**
The current log level
Use setLogLevel to set the logLevel
@see setLogLevel:
*/
@property (readonly) ODLogLevel logLevel;
/**
Actually writes the full log message. This will just call NSLog with the message.
@param message the message to log
*/
- (void)writeMessage:(NSString *)message;
@end
| 34.967213 | 121 | 0.753868 |
d97541b42c8fc9a472c88e7c70be532cffadad7b | 1,022 | c | C | native/jni/external/dtc/tests/addr_size_cells2.c | Joyoe/Magisk-nosbin_magisk-nohide | 449441921740bf85926c14f41b3532822ca0eb65 | [
"MIT"
] | 44 | 2022-03-16T08:32:31.000Z | 2022-03-31T16:02:35.000Z | native/jni/external/dtc/tests/addr_size_cells2.c | Joyoe/Magisk-nosbin_magisk-nohide | 449441921740bf85926c14f41b3532822ca0eb65 | [
"MIT"
] | 1 | 2022-03-29T02:30:28.000Z | 2022-03-30T03:40:46.000Z | native/jni/external/dtc/tests/addr_size_cells2.c | Joyoe/Magisk-nosbin_magisk-nohide | 449441921740bf85926c14f41b3532822ca0eb65 | [
"MIT"
] | 18 | 2022-03-19T04:41:04.000Z | 2022-03-31T03:32:12.000Z | // SPDX-License-Identifier: LGPL-2.1-or-later
/*
* libfdt - Flat Device Tree manipulation
* Testcase for #address-cells and #size-cells handling
* Copyright (C) 2014 David Gibson, <david@gibson.dropbear.id.au>
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <libfdt.h>
#include "tests.h"
#include "testdata.h"
static void check_node(const void *fdt, const char *path, int ac, int sc)
{
int offset;
int xac, xsc;
offset = fdt_path_offset(fdt, path);
if (offset < 0)
FAIL("Couldn't find path %s", path);
xac = fdt_address_cells(fdt, offset);
xsc = fdt_size_cells(fdt, offset);
if (xac != ac)
FAIL("Address cells for %s is %d instead of %d\n",
path, xac, ac);
if (xsc != sc)
FAIL("Size cells for %s is %d instead of %d\n",
path, xsc, sc);
}
int main(int argc, char *argv[])
{
void *fdt;
if (argc != 2)
CONFIG("Usage: %s <dtb file>\n", argv[0]);
test_init(argc, argv);
fdt = load_blob(argv[1]);
check_node(fdt, "/", 2, 1);
PASS();
}
| 20.44 | 73 | 0.6409 |
d975e8afc773ae5e68de279541c436e4f5ab68e9 | 624 | c | C | CompetitiveProgramming/HackerEarth/basicInput/ex/Playwithnumbers.c | send2manoo/Data-Structure-C | c9763ec9709421a558a8dee5e3d811dd8e343960 | [
"Apache-2.0"
] | 1 | 2020-01-20T09:15:13.000Z | 2020-01-20T09:15:13.000Z | CompetitiveProgramming/HackerEarth/basicInput/ex/Playwithnumbers.c | send2manoo/Data-Structure-C | c9763ec9709421a558a8dee5e3d811dd8e343960 | [
"Apache-2.0"
] | null | null | null | CompetitiveProgramming/HackerEarth/basicInput/ex/Playwithnumbers.c | send2manoo/Data-Structure-C | c9763ec9709421a558a8dee5e3d811dd8e343960 | [
"Apache-2.0"
] | 1 | 2020-10-01T06:33:39.000Z | 2020-10-01T06:33:39.000Z | #include <stdio.h>
int main()
{
unsigned int N = 0, Q = 0, L = 0, R = 0, i, j, mean = 0, count = 0;
scanf("%d %d", &N, &Q);
int Arr[N];
for (i = 0; i < N; i++) scanf("%d ", &Arr[i]);
for (i = 0; i < Q; i++)
{
scanf("%d %d", &L, &R);
for (j = 0; j < N; j++)
{
if (Arr[j] == L)
{
count = 0; // reset count for next sub array count added by manohar
mean = 0; // reset mean for next sub array mean
while(Arr[j] != R)
{
count++;
mean = mean + Arr[j];
j++;
}
count++;
mean = mean + Arr[j];
break;
}
}
printf("%d\n", (int)(mean/count));
}
return 0;
} | 20.129032 | 74 | 0.445513 |
d9777e75144b926f887a6238561d215815dde6b5 | 756 | h | C | libraries/networking/src/ResourceScriptingInterface.h | mnafees/hifi | d8f0cfa89a1fdf7339bac6af984e940df6265006 | [
"Apache-2.0"
] | 7 | 2015-08-24T17:01:00.000Z | 2021-03-30T09:30:40.000Z | libraries/networking/src/ResourceScriptingInterface.h | mnafees/hifi | d8f0cfa89a1fdf7339bac6af984e940df6265006 | [
"Apache-2.0"
] | 1 | 2016-01-17T17:49:05.000Z | 2016-01-17T17:49:05.000Z | libraries/networking/src/ResourceScriptingInterface.h | mnafees/hifi | d8f0cfa89a1fdf7339bac6af984e940df6265006 | [
"Apache-2.0"
] | 1 | 2019-07-05T08:39:35.000Z | 2019-07-05T08:39:35.000Z | //
// AssetClient.h
// libraries/networking/src
//
// Created by Ryan Huffman on 2015/07/21
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_networking_ResourceScriptingInterface_h
#define hifi_networking_ResourceScriptingInterface_h
#include <QtCore/QObject>
#include <DependencyManager.h>
class ResourceScriptingInterface : public QObject, public Dependency {
Q_OBJECT
public:
Q_INVOKABLE void overrideUrlPrefix(const QString& prefix, const QString& replacement);
Q_INVOKABLE void restoreUrlPrefix(const QString& prefix) {
overrideUrlPrefix(prefix, "");
}
};
#endif
| 23.625 | 90 | 0.753968 |
d9780fb1ab4ca0eb9157defeca2437f1a7280031 | 474 | h | C | Message.framework/MFAttachmentLibraryManager.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | 4 | 2021-10-06T12:15:26.000Z | 2022-02-21T02:26:00.000Z | Message.framework/MFAttachmentLibraryManager.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | null | null | null | Message.framework/MFAttachmentLibraryManager.h | reels-research/iOS-Private-Frameworks | 9a4f4534939310a51fdbf5a439dd22487efb0f01 | [
"MIT"
] | 1 | 2021-10-08T07:40:53.000Z | 2021-10-08T07:40:53.000Z | /* Generated by RuntimeBrowser
Image: /System/Library/PrivateFrameworks/Message.framework/Message
*/
@interface MFAttachmentLibraryManager : MFAttachmentComposeManager
- (id)_dataProviderForAttachmentURL:(id)arg1 error:(id*)arg2;
- (void)_messageAttachmentStorageLocationsDidChangeNotification:(id)arg1;
- (id)attachmentsForMessage:(id)arg1 withSchemes:(id)arg2;
- (void)dealloc;
- (id)initWithPrimaryLibrary:(id)arg1;
- (void)removeProviderForBaseURL:(id)arg1;
@end
| 31.6 | 73 | 0.803797 |
d978c84f67abbf1bba9111f6113d5a716e5c87da | 3,685 | h | C | onnxruntime/core/providers/cuda/cuda_common.h | luyaor/onnxruntime | 8cce473f7c9c741b6faae24ef6e6a6a22ccdbc6e | [
"MIT"
] | 1 | 2021-03-07T21:33:04.000Z | 2021-03-07T21:33:04.000Z | onnxruntime/core/providers/cuda/cuda_common.h | luyaor/onnxruntime | 8cce473f7c9c741b6faae24ef6e6a6a22ccdbc6e | [
"MIT"
] | 1 | 2021-02-24T01:31:43.000Z | 2021-05-02T03:29:52.000Z | onnxruntime/core/providers/cuda/cuda_common.h | luyaor/onnxruntime | 8cce473f7c9c741b6faae24ef6e6a6a22ccdbc6e | [
"MIT"
] | null | null | null | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include "core/common/status.h"
#include "core/providers/cuda/cuda_pch.h"
#include "core/providers/cuda/shared_inc/cuda_call.h"
#include "core/providers/cuda/shared_inc/fast_divmod.h"
#include "core/util/math.h"
namespace onnxruntime {
namespace cuda {
#define CUDA_RETURN_IF_ERROR(expr) \
ORT_RETURN_IF_ERROR(CUDA_CALL(expr) \
? common::Status::OK() \
: ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "CUDA error executing ", #expr))
#define CUBLAS_RETURN_IF_ERROR(expr) \
ORT_RETURN_IF_ERROR(CUBLAS_CALL(expr) \
? common::Status::OK() \
: ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "CUBLAS error executing ", #expr))
#define CUSPARSE_RETURN_IF_ERROR(expr) \
ORT_RETURN_IF_ERROR(CUSPARSE_CALL(expr) \
? common::Status::OK() \
: ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "CUSPARSE error executing ", #expr))
#define CURAND_RETURN_IF_ERROR(expr) \
ORT_RETURN_IF_ERROR(CURAND_CALL(expr) \
? common::Status::OK() \
: ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "CURAND error executing ", #expr))
#define CUDNN_RETURN_IF_ERROR(expr) \
ORT_RETURN_IF_ERROR(CUDNN_CALL(expr) \
? common::Status::OK() \
: ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "CUDNN error executing ", #expr))
#define CUDNN2_RETURN_IF_ERROR(expr, m) \
ORT_RETURN_IF_ERROR(CUDNN_CALL2(expr, m) \
? common::Status::OK() \
: ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "CUDNN2 error executing ", #expr))
#define CUFFT_RETURN_IF_ERROR(expr) \
ORT_RETURN_IF_ERROR(CUFFT_CALL(expr) \
? common::Status::OK() \
: ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "CUFFT error executing ", #expr))
// Type mapping for MLFloat16 to half
template <typename T>
class ToCudaType {
public:
typedef T MappedType;
static MappedType FromFloat(float f) {
return static_cast<T>(f);
}
};
template <>
class ToCudaType<MLFloat16> {
public:
typedef half MappedType;
static MappedType FromFloat(float f) {
uint16_t h = math::floatToHalf(f);
return *reinterpret_cast<MappedType*>(&h);
}
};
inline bool CalculateFdmStrides(gsl::span<fast_divmod> p, const std::vector<int64_t>& dims) {
int stride = 1;
if (dims.empty() || p.size() < dims.size())
return false;
auto rank = p.size();
for (size_t i = 0; i < rank; i++) {
p[rank - 1 - i] = fast_divmod(stride);
if (i < dims.size() - 1) {
stride *= static_cast<int>(dims[dims.size() - 1 - i]);
}
}
return true;
}
class CublasMathModeSetter {
public:
CublasMathModeSetter(const cudaDeviceProp& prop, cublasHandle_t handle, cublasMath_t mode) : prop_(prop), handle_(handle) {
cublasGetMathMode(handle, &mode_);
#if defined(CUDA_VERSION) && CUDA_VERSION < 11000
if (prop.major >= 7 && mode == CUBLAS_TENSOR_OP_MATH) {
cublasSetMathMode(handle, mode);
}
#endif
#if defined(CUDA_VERSION) && CUDA_VERSION >= 11000
if (prop.major >= 8 && mode == CUBLAS_TF32_TENSOR_OP_MATH) {
cublasSetMathMode(handle, mode);
}
#endif
}
~CublasMathModeSetter() {
cublasSetMathMode(handle_, mode_);
}
private:
const cudaDeviceProp& prop_;
cublasHandle_t handle_;
cublasMath_t mode_;
};
} // namespace cuda
} // namespace onnxruntime
| 32.901786 | 125 | 0.612754 |
d97a7de302e3733e5a887785ee393366401e3afc | 899 | h | C | realsense2_framos_camera/include/t265_realsense_node.h | nikostsagk/realsense | 3dbdba2c6d49bc6286adc763fc666c758dc0c3d0 | [
"Apache-2.0"
] | 1 | 2020-06-14T22:06:23.000Z | 2020-06-14T22:06:23.000Z | realsense2_framos_camera/include/t265_realsense_node.h | nikostsagk/realsense | 3dbdba2c6d49bc6286adc763fc666c758dc0c3d0 | [
"Apache-2.0"
] | 3 | 2020-06-05T18:38:07.000Z | 2020-07-20T10:07:52.000Z | realsense2_framos_camera/include/t265_realsense_node.h | nikostsagk/realsense | 3dbdba2c6d49bc6286adc763fc666c758dc0c3d0 | [
"Apache-2.0"
] | 4 | 2019-04-09T12:21:22.000Z | 2021-01-04T11:48:37.000Z | #pragma once
#include <base_realsense_node.h>
namespace realsense2_framos_camera
{
class T265RealsenseNode : public BaseRealSenseNode
{
public:
T265RealsenseNode(ros::NodeHandle& nodeHandle,
ros::NodeHandle& privateNodeHandle,
rs2::device dev,
const std::string& serial_no);
void publishTopics();
protected:
void calcAndPublishStaticTransform(const stream_index_pair& stream, const rs2::stream_profile& base_profile) override;
private:
void initializeOdometryInput();
void setupSubscribers();
void odom_in_callback(const nav_msgs::Odometry::ConstPtr& msg);
ros::Subscriber _odom_subscriber;
rs2::wheel_odometer _wo_snr;
bool _use_odom_in;
};
}
| 31 | 131 | 0.589544 |
d97b6d40be660b5128298ba9ca071ce6b22ec70c | 75,678 | h | C | KOST-Val/src/main/resources_notJar/resources/ExifTool-10.15/Perl/lib/CORE/proto.h | rebplu/KOST-VAL | 1537125425068d5faec3bc4f5263df715956ae76 | [
"BSD-3-Clause-No-Nuclear-Warranty"
] | null | null | null | KOST-Val/src/main/resources_notJar/resources/ExifTool-10.15/Perl/lib/CORE/proto.h | rebplu/KOST-VAL | 1537125425068d5faec3bc4f5263df715956ae76 | [
"BSD-3-Clause-No-Nuclear-Warranty"
] | null | null | null | KOST-Val/src/main/resources_notJar/resources/ExifTool-10.15/Perl/lib/CORE/proto.h | rebplu/KOST-VAL | 1537125425068d5faec3bc4f5263df715956ae76 | [
"BSD-3-Clause-No-Nuclear-Warranty"
] | null | null | null | /*
* proto.h
*
* Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999,
* 2000, 2001, 2002, 2003, 2004, by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
*
* !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
* This file is built by embed.pl from data in embed.fnc, embed.pl,
* pp.sym, intrpvar.h, perlvars.h and thrdvar.h.
* Any changes made here will be lost!
*
* Edit those files and run 'make regen_headers' to effect changes.
*/
START_EXTERN_C
#if defined(PERL_IMPLICIT_SYS)
PERL_CALLCONV PerlInterpreter* perl_alloc_using(struct IPerlMem* m, struct IPerlMem* ms, struct IPerlMem* mp, struct IPerlEnv* e, struct IPerlStdIO* io, struct IPerlLIO* lio, struct IPerlDir* d, struct IPerlSock* s, struct IPerlProc* p);
#endif
PERL_CALLCONV PerlInterpreter* perl_alloc(void);
PERL_CALLCONV void perl_construct(PerlInterpreter* interp);
PERL_CALLCONV int perl_destruct(PerlInterpreter* interp);
PERL_CALLCONV void perl_free(PerlInterpreter* interp);
PERL_CALLCONV int perl_run(PerlInterpreter* interp);
PERL_CALLCONV int perl_parse(PerlInterpreter* interp, XSINIT_t xsinit, int argc, char** argv, char** env);
PERL_CALLCONV bool Perl_doing_taint(int argc, char** argv, char** env);
#if defined(USE_ITHREADS)
PERL_CALLCONV PerlInterpreter* perl_clone(PerlInterpreter* interp, UV flags);
# if defined(PERL_IMPLICIT_SYS)
PERL_CALLCONV PerlInterpreter* perl_clone_using(PerlInterpreter *interp, UV flags, struct IPerlMem* m, struct IPerlMem* ms, struct IPerlMem* mp, struct IPerlEnv* e, struct IPerlStdIO* io, struct IPerlLIO* lio, struct IPerlDir* d, struct IPerlSock* s, struct IPerlProc* p);
# endif
#endif
PERL_CALLCONV Malloc_t Perl_malloc(MEM_SIZE nbytes);
PERL_CALLCONV Malloc_t Perl_calloc(MEM_SIZE elements, MEM_SIZE size);
PERL_CALLCONV Malloc_t Perl_realloc(Malloc_t where, MEM_SIZE nbytes);
PERL_CALLCONV Free_t Perl_mfree(Malloc_t where);
#if defined(MYMALLOC)
PERL_CALLCONV MEM_SIZE Perl_malloced_size(void *p);
#endif
PERL_CALLCONV void* Perl_get_context(void);
PERL_CALLCONV void Perl_set_context(void *thx);
END_EXTERN_C
/* functions with flag 'n' should come before here */
START_EXTERN_C
# include "pp_proto.h"
PERL_CALLCONV SV* Perl_amagic_call(pTHX_ SV* left, SV* right, int method, int dir);
PERL_CALLCONV bool Perl_Gv_AMupdate(pTHX_ HV* stash);
PERL_CALLCONV CV* Perl_gv_handler(pTHX_ HV* stash, I32 id);
PERL_CALLCONV OP* Perl_append_elem(pTHX_ I32 optype, OP* head, OP* tail);
PERL_CALLCONV OP* Perl_append_list(pTHX_ I32 optype, LISTOP* first, LISTOP* last);
PERL_CALLCONV I32 Perl_apply(pTHX_ I32 type, SV** mark, SV** sp);
PERL_CALLCONV void Perl_apply_attrs_string(pTHX_ char *stashpv, CV *cv, char *attrstr, STRLEN len);
PERL_CALLCONV SV* Perl_avhv_delete_ent(pTHX_ AV *ar, SV* keysv, I32 flags, U32 hash);
PERL_CALLCONV bool Perl_avhv_exists_ent(pTHX_ AV *ar, SV* keysv, U32 hash);
PERL_CALLCONV SV** Perl_avhv_fetch_ent(pTHX_ AV *ar, SV* keysv, I32 lval, U32 hash);
PERL_CALLCONV SV** Perl_avhv_store_ent(pTHX_ AV *ar, SV* keysv, SV* val, U32 hash);
PERL_CALLCONV HE* Perl_avhv_iternext(pTHX_ AV *ar);
PERL_CALLCONV SV* Perl_avhv_iterval(pTHX_ AV *ar, HE* entry);
PERL_CALLCONV HV* Perl_avhv_keys(pTHX_ AV *ar);
PERL_CALLCONV void Perl_av_clear(pTHX_ AV* ar);
PERL_CALLCONV SV* Perl_av_delete(pTHX_ AV* ar, I32 key, I32 flags);
PERL_CALLCONV bool Perl_av_exists(pTHX_ AV* ar, I32 key);
PERL_CALLCONV void Perl_av_extend(pTHX_ AV* ar, I32 key);
PERL_CALLCONV AV* Perl_av_fake(pTHX_ I32 size, SV** svp);
PERL_CALLCONV SV** Perl_av_fetch(pTHX_ AV* ar, I32 key, I32 lval);
PERL_CALLCONV void Perl_av_fill(pTHX_ AV* ar, I32 fill);
PERL_CALLCONV I32 Perl_av_len(pTHX_ AV* ar);
PERL_CALLCONV AV* Perl_av_make(pTHX_ I32 size, SV** svp);
PERL_CALLCONV SV* Perl_av_pop(pTHX_ AV* ar);
PERL_CALLCONV void Perl_av_push(pTHX_ AV* ar, SV* val);
PERL_CALLCONV void Perl_av_reify(pTHX_ AV* ar);
PERL_CALLCONV SV* Perl_av_shift(pTHX_ AV* ar);
PERL_CALLCONV SV** Perl_av_store(pTHX_ AV* ar, I32 key, SV* val);
PERL_CALLCONV void Perl_av_undef(pTHX_ AV* ar);
PERL_CALLCONV void Perl_av_unshift(pTHX_ AV* ar, I32 num);
PERL_CALLCONV OP* Perl_bind_match(pTHX_ I32 type, OP* left, OP* pat);
PERL_CALLCONV OP* Perl_block_end(pTHX_ I32 floor, OP* seq);
PERL_CALLCONV I32 Perl_block_gimme(pTHX);
PERL_CALLCONV int Perl_block_start(pTHX_ int full);
PERL_CALLCONV void Perl_boot_core_UNIVERSAL(pTHX);
PERL_CALLCONV void Perl_boot_core_PerlIO(pTHX);
PERL_CALLCONV void Perl_call_list(pTHX_ I32 oldscope, AV* av_list);
PERL_CALLCONV bool Perl_cando(pTHX_ Mode_t mode, Uid_t effective, Stat_t* statbufp);
PERL_CALLCONV U32 Perl_cast_ulong(pTHX_ NV f);
PERL_CALLCONV I32 Perl_cast_i32(pTHX_ NV f);
PERL_CALLCONV IV Perl_cast_iv(pTHX_ NV f);
PERL_CALLCONV UV Perl_cast_uv(pTHX_ NV f);
#if !defined(HAS_TRUNCATE) && !defined(HAS_CHSIZE) && defined(F_FREESP)
PERL_CALLCONV I32 Perl_my_chsize(pTHX_ int fd, Off_t length);
#endif
#if defined(USE_5005THREADS)
PERL_CALLCONV MAGIC* Perl_condpair_magic(pTHX_ SV *sv);
#endif
PERL_CALLCONV OP* Perl_convert(pTHX_ I32 optype, I32 flags, OP* o);
PERL_CALLCONV void Perl_croak(pTHX_ const char* pat, ...) __attribute__((noreturn))
__attribute__format__(__printf__,pTHX_1,pTHX_2);
PERL_CALLCONV void Perl_vcroak(pTHX_ const char* pat, va_list* args) __attribute__((noreturn));
#if defined(PERL_IMPLICIT_CONTEXT)
PERL_CALLCONV void Perl_croak_nocontext(const char* pat, ...) __attribute__((noreturn))
__attribute__format__(__printf__,1,2);
PERL_CALLCONV OP* Perl_die_nocontext(const char* pat, ...)
__attribute__format__(__printf__,1,2);
PERL_CALLCONV void Perl_deb_nocontext(const char* pat, ...)
__attribute__format__(__printf__,1,2);
PERL_CALLCONV char* Perl_form_nocontext(const char* pat, ...)
__attribute__format__(__printf__,1,2);
PERL_CALLCONV void Perl_load_module_nocontext(U32 flags, SV* name, SV* ver, ...);
PERL_CALLCONV SV* Perl_mess_nocontext(const char* pat, ...)
__attribute__format__(__printf__,1,2);
PERL_CALLCONV void Perl_warn_nocontext(const char* pat, ...)
__attribute__format__(__printf__,1,2);
PERL_CALLCONV void Perl_warner_nocontext(U32 err, const char* pat, ...)
__attribute__format__(__printf__,2,3);
PERL_CALLCONV SV* Perl_newSVpvf_nocontext(const char* pat, ...)
__attribute__format__(__printf__,1,2);
PERL_CALLCONV void Perl_sv_catpvf_nocontext(SV* sv, const char* pat, ...)
__attribute__format__(__printf__,2,3);
PERL_CALLCONV void Perl_sv_setpvf_nocontext(SV* sv, const char* pat, ...)
__attribute__format__(__printf__,2,3);
PERL_CALLCONV void Perl_sv_catpvf_mg_nocontext(SV* sv, const char* pat, ...)
__attribute__format__(__printf__,2,3);
PERL_CALLCONV void Perl_sv_setpvf_mg_nocontext(SV* sv, const char* pat, ...)
__attribute__format__(__printf__,2,3);
PERL_CALLCONV int Perl_fprintf_nocontext(PerlIO* stream, const char* fmt, ...)
__attribute__format__(__printf__,2,3);
PERL_CALLCONV int Perl_printf_nocontext(const char* fmt, ...)
__attribute__format__(__printf__,1,2);
#endif
PERL_CALLCONV void Perl_cv_ckproto(pTHX_ CV* cv, GV* gv, char* p);
PERL_CALLCONV CV* Perl_cv_clone(pTHX_ CV* proto);
PERL_CALLCONV SV* Perl_cv_const_sv(pTHX_ CV* cv);
PERL_CALLCONV SV* Perl_op_const_sv(pTHX_ OP* o, CV* cv);
PERL_CALLCONV void Perl_cv_undef(pTHX_ CV* cv);
PERL_CALLCONV void Perl_cx_dump(pTHX_ PERL_CONTEXT* cs);
PERL_CALLCONV SV* Perl_filter_add(pTHX_ filter_t funcp, SV* datasv);
PERL_CALLCONV void Perl_filter_del(pTHX_ filter_t funcp);
PERL_CALLCONV I32 Perl_filter_read(pTHX_ int idx, SV* buffer, int maxlen);
PERL_CALLCONV char** Perl_get_op_descs(pTHX);
PERL_CALLCONV char** Perl_get_op_names(pTHX);
PERL_CALLCONV char* Perl_get_no_modify(pTHX);
PERL_CALLCONV U32* Perl_get_opargs(pTHX);
PERL_CALLCONV PPADDR_t* Perl_get_ppaddr(pTHX);
PERL_CALLCONV I32 Perl_cxinc(pTHX);
PERL_CALLCONV void Perl_deb(pTHX_ const char* pat, ...)
__attribute__format__(__printf__,pTHX_1,pTHX_2);
PERL_CALLCONV void Perl_vdeb(pTHX_ const char* pat, va_list* args);
PERL_CALLCONV void Perl_debprofdump(pTHX);
PERL_CALLCONV I32 Perl_debop(pTHX_ OP* o);
PERL_CALLCONV I32 Perl_debstack(pTHX);
PERL_CALLCONV I32 Perl_debstackptrs(pTHX);
PERL_CALLCONV char* Perl_delimcpy(pTHX_ char* to, char* toend, char* from, char* fromend, int delim, I32* retlen);
PERL_CALLCONV void Perl_deprecate(pTHX_ char* s);
PERL_CALLCONV void Perl_deprecate_old(pTHX_ char* s);
PERL_CALLCONV OP* Perl_die(pTHX_ const char* pat, ...)
__attribute__format__(__printf__,pTHX_1,pTHX_2);
PERL_CALLCONV OP* Perl_vdie(pTHX_ const char* pat, va_list* args);
PERL_CALLCONV OP* Perl_die_where(pTHX_ char* message, STRLEN msglen);
PERL_CALLCONV void Perl_dounwind(pTHX_ I32 cxix);
PERL_CALLCONV bool Perl_do_aexec(pTHX_ SV* really, SV** mark, SV** sp);
PERL_CALLCONV bool Perl_do_aexec5(pTHX_ SV* really, SV** mark, SV** sp, int fd, int flag);
PERL_CALLCONV int Perl_do_binmode(pTHX_ PerlIO *fp, int iotype, int mode);
PERL_CALLCONV void Perl_do_chop(pTHX_ SV* asv, SV* sv);
PERL_CALLCONV bool Perl_do_close(pTHX_ GV* gv, bool not_implicit);
PERL_CALLCONV bool Perl_do_eof(pTHX_ GV* gv);
PERL_CALLCONV bool Perl_do_exec(pTHX_ char* cmd);
#if defined(WIN32)
PERL_CALLCONV int Perl_do_aspawn(pTHX_ SV* really, SV** mark, SV** sp);
PERL_CALLCONV int Perl_do_spawn(pTHX_ char* cmd);
PERL_CALLCONV int Perl_do_spawn_nowait(pTHX_ char* cmd);
#endif
#if !defined(WIN32)
PERL_CALLCONV bool Perl_do_exec3(pTHX_ char* cmd, int fd, int flag);
#endif
PERL_CALLCONV void Perl_do_execfree(pTHX);
#if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
PERL_CALLCONV I32 Perl_do_ipcctl(pTHX_ I32 optype, SV** mark, SV** sp);
PERL_CALLCONV I32 Perl_do_ipcget(pTHX_ I32 optype, SV** mark, SV** sp);
PERL_CALLCONV I32 Perl_do_msgrcv(pTHX_ SV** mark, SV** sp);
PERL_CALLCONV I32 Perl_do_msgsnd(pTHX_ SV** mark, SV** sp);
PERL_CALLCONV I32 Perl_do_semop(pTHX_ SV** mark, SV** sp);
PERL_CALLCONV I32 Perl_do_shmio(pTHX_ I32 optype, SV** mark, SV** sp);
#endif
PERL_CALLCONV void Perl_do_join(pTHX_ SV* sv, SV* del, SV** mark, SV** sp);
PERL_CALLCONV OP* Perl_do_kv(pTHX);
PERL_CALLCONV bool Perl_do_open(pTHX_ GV* gv, char* name, I32 len, int as_raw, int rawmode, int rawperm, PerlIO* supplied_fp);
PERL_CALLCONV bool Perl_do_open9(pTHX_ GV *gv, char *name, I32 len, int as_raw, int rawmode, int rawperm, PerlIO *supplied_fp, SV *svs, I32 num);
PERL_CALLCONV bool Perl_do_openn(pTHX_ GV *gv, char *name, I32 len, int as_raw, int rawmode, int rawperm, PerlIO *supplied_fp, SV **svp, I32 num);
PERL_CALLCONV void Perl_do_pipe(pTHX_ SV* sv, GV* rgv, GV* wgv);
PERL_CALLCONV bool Perl_do_print(pTHX_ SV* sv, PerlIO* fp);
PERL_CALLCONV OP* Perl_do_readline(pTHX);
PERL_CALLCONV I32 Perl_do_chomp(pTHX_ SV* sv);
PERL_CALLCONV bool Perl_do_seek(pTHX_ GV* gv, Off_t pos, int whence);
PERL_CALLCONV void Perl_do_sprintf(pTHX_ SV* sv, I32 len, SV** sarg);
PERL_CALLCONV Off_t Perl_do_sysseek(pTHX_ GV* gv, Off_t pos, int whence);
PERL_CALLCONV Off_t Perl_do_tell(pTHX_ GV* gv);
PERL_CALLCONV I32 Perl_do_trans(pTHX_ SV* sv);
PERL_CALLCONV UV Perl_do_vecget(pTHX_ SV* sv, I32 offset, I32 size);
PERL_CALLCONV void Perl_do_vecset(pTHX_ SV* sv);
PERL_CALLCONV void Perl_do_vop(pTHX_ I32 optype, SV* sv, SV* left, SV* right);
PERL_CALLCONV OP* Perl_dofile(pTHX_ OP* term);
PERL_CALLCONV I32 Perl_dowantarray(pTHX);
PERL_CALLCONV void Perl_dump_all(pTHX);
PERL_CALLCONV void Perl_dump_eval(pTHX);
#if defined(DUMP_FDS)
PERL_CALLCONV void Perl_dump_fds(pTHX_ char* s);
#endif
PERL_CALLCONV void Perl_dump_form(pTHX_ GV* gv);
PERL_CALLCONV void Perl_gv_dump(pTHX_ GV* gv);
PERL_CALLCONV void Perl_op_dump(pTHX_ OP* arg);
PERL_CALLCONV void Perl_pmop_dump(pTHX_ PMOP* pm);
PERL_CALLCONV void Perl_dump_packsubs(pTHX_ HV* stash);
PERL_CALLCONV void Perl_dump_sub(pTHX_ GV* gv);
PERL_CALLCONV void Perl_fbm_compile(pTHX_ SV* sv, U32 flags);
PERL_CALLCONV char* Perl_fbm_instr(pTHX_ unsigned char* big, unsigned char* bigend, SV* littlesv, U32 flags);
PERL_CALLCONV char* Perl_find_script(pTHX_ char *scriptname, bool dosearch, char **search_ext, I32 flags);
#if defined(USE_5005THREADS)
PERL_CALLCONV PADOFFSET Perl_find_threadsv(pTHX_ const char *name);
#endif
PERL_CALLCONV OP* Perl_force_list(pTHX_ OP* arg);
PERL_CALLCONV OP* Perl_fold_constants(pTHX_ OP* arg);
PERL_CALLCONV char* Perl_form(pTHX_ const char* pat, ...)
__attribute__format__(__printf__,pTHX_1,pTHX_2);
PERL_CALLCONV char* Perl_vform(pTHX_ const char* pat, va_list* args);
PERL_CALLCONV void Perl_free_tmps(pTHX);
PERL_CALLCONV OP* Perl_gen_constant_list(pTHX_ OP* o);
#if !defined(HAS_GETENV_LEN)
PERL_CALLCONV char* Perl_getenv_len(pTHX_ const char* key, unsigned long *len);
#endif
PERL_CALLCONV void Perl_gp_free(pTHX_ GV* gv);
PERL_CALLCONV GP* Perl_gp_ref(pTHX_ GP* gp);
PERL_CALLCONV GV* Perl_gv_AVadd(pTHX_ GV* gv);
PERL_CALLCONV GV* Perl_gv_HVadd(pTHX_ GV* gv);
PERL_CALLCONV GV* Perl_gv_IOadd(pTHX_ GV* gv);
PERL_CALLCONV GV* Perl_gv_autoload4(pTHX_ HV* stash, const char* name, STRLEN len, I32 method);
PERL_CALLCONV void Perl_gv_check(pTHX_ HV* stash);
PERL_CALLCONV void Perl_gv_efullname(pTHX_ SV* sv, GV* gv);
PERL_CALLCONV void Perl_gv_efullname3(pTHX_ SV* sv, GV* gv, const char* prefix);
PERL_CALLCONV void Perl_gv_efullname4(pTHX_ SV* sv, GV* gv, const char* prefix, bool keepmain);
PERL_CALLCONV GV* Perl_gv_fetchfile(pTHX_ const char* name);
PERL_CALLCONV GV* Perl_gv_fetchmeth(pTHX_ HV* stash, const char* name, STRLEN len, I32 level);
PERL_CALLCONV GV* Perl_gv_fetchmeth_autoload(pTHX_ HV* stash, const char* name, STRLEN len, I32 level);
PERL_CALLCONV GV* Perl_gv_fetchmethod(pTHX_ HV* stash, const char* name);
PERL_CALLCONV GV* Perl_gv_fetchmethod_autoload(pTHX_ HV* stash, const char* name, I32 autoload);
PERL_CALLCONV GV* Perl_gv_fetchpv(pTHX_ const char* name, I32 add, I32 sv_type);
PERL_CALLCONV void Perl_gv_fullname(pTHX_ SV* sv, GV* gv);
PERL_CALLCONV void Perl_gv_fullname3(pTHX_ SV* sv, GV* gv, const char* prefix);
PERL_CALLCONV void Perl_gv_fullname4(pTHX_ SV* sv, GV* gv, const char* prefix, bool keepmain);
PERL_CALLCONV void Perl_gv_init(pTHX_ GV* gv, HV* stash, const char* name, STRLEN len, int multi);
PERL_CALLCONV HV* Perl_gv_stashpv(pTHX_ const char* name, I32 create);
PERL_CALLCONV HV* Perl_gv_stashpvn(pTHX_ const char* name, U32 namelen, I32 create);
PERL_CALLCONV HV* Perl_gv_stashsv(pTHX_ SV* sv, I32 create);
PERL_CALLCONV void Perl_hv_clear(pTHX_ HV* tb);
PERL_CALLCONV void Perl_hv_delayfree_ent(pTHX_ HV* hv, HE* entry);
PERL_CALLCONV SV* Perl_hv_delete(pTHX_ HV* tb, const char* key, I32 klen, I32 flags);
PERL_CALLCONV SV* Perl_hv_delete_ent(pTHX_ HV* tb, SV* key, I32 flags, U32 hash);
PERL_CALLCONV bool Perl_hv_exists(pTHX_ HV* tb, const char* key, I32 klen);
PERL_CALLCONV bool Perl_hv_exists_ent(pTHX_ HV* tb, SV* key, U32 hash);
PERL_CALLCONV SV** Perl_hv_fetch(pTHX_ HV* tb, const char* key, I32 klen, I32 lval);
PERL_CALLCONV HE* Perl_hv_fetch_ent(pTHX_ HV* tb, SV* key, I32 lval, U32 hash);
PERL_CALLCONV void Perl_hv_free_ent(pTHX_ HV* hv, HE* entry);
PERL_CALLCONV I32 Perl_hv_iterinit(pTHX_ HV* tb);
PERL_CALLCONV char* Perl_hv_iterkey(pTHX_ HE* entry, I32* retlen);
PERL_CALLCONV SV* Perl_hv_iterkeysv(pTHX_ HE* entry);
PERL_CALLCONV HE* Perl_hv_iternext(pTHX_ HV* tb);
PERL_CALLCONV SV* Perl_hv_iternextsv(pTHX_ HV* hv, char** key, I32* retlen);
PERL_CALLCONV HE* Perl_hv_iternext_flags(pTHX_ HV* tb, I32 flags);
PERL_CALLCONV SV* Perl_hv_iterval(pTHX_ HV* tb, HE* entry);
PERL_CALLCONV void Perl_hv_ksplit(pTHX_ HV* hv, IV newmax);
PERL_CALLCONV void Perl_hv_magic(pTHX_ HV* hv, GV* gv, int how);
PERL_CALLCONV SV** Perl_hv_store(pTHX_ HV* tb, const char* key, I32 klen, SV* val, U32 hash);
PERL_CALLCONV HE* Perl_hv_store_ent(pTHX_ HV* tb, SV* key, SV* val, U32 hash);
PERL_CALLCONV SV** Perl_hv_store_flags(pTHX_ HV* tb, const char* key, I32 klen, SV* val, U32 hash, int flags);
PERL_CALLCONV void Perl_hv_undef(pTHX_ HV* tb);
PERL_CALLCONV I32 Perl_ibcmp(pTHX_ const char* a, const char* b, I32 len);
PERL_CALLCONV I32 Perl_ibcmp_locale(pTHX_ const char* a, const char* b, I32 len);
PERL_CALLCONV I32 Perl_ibcmp_utf8(pTHX_ const char* a, char **pe1, UV l1, bool u1, const char* b, char **pe2, UV l2, bool u2);
PERL_CALLCONV bool Perl_ingroup(pTHX_ Gid_t testgid, Uid_t effective);
PERL_CALLCONV void Perl_init_argv_symbols(pTHX_ int, char **);
PERL_CALLCONV void Perl_init_debugger(pTHX);
PERL_CALLCONV void Perl_init_stacks(pTHX);
PERL_CALLCONV void Perl_init_tm(pTHX_ struct tm *ptm);
PERL_CALLCONV U32 Perl_intro_my(pTHX);
PERL_CALLCONV char* Perl_instr(pTHX_ const char* big, const char* little);
PERL_CALLCONV bool Perl_io_close(pTHX_ IO* io, bool not_implicit);
PERL_CALLCONV OP* Perl_invert(pTHX_ OP* cmd);
PERL_CALLCONV bool Perl_is_gv_magical(pTHX_ char *name, STRLEN len, U32 flags);
PERL_CALLCONV I32 Perl_is_lvalue_sub(pTHX);
PERL_CALLCONV U32 Perl_to_uni_upper_lc(pTHX_ U32 c);
PERL_CALLCONV U32 Perl_to_uni_title_lc(pTHX_ U32 c);
PERL_CALLCONV U32 Perl_to_uni_lower_lc(pTHX_ U32 c);
PERL_CALLCONV bool Perl_is_uni_alnum(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_alnumc(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_idfirst(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_alpha(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_ascii(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_space(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_cntrl(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_graph(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_digit(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_upper(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_lower(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_print(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_punct(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_xdigit(pTHX_ UV c);
PERL_CALLCONV UV Perl_to_uni_upper(pTHX_ UV c, U8 *p, STRLEN *lenp);
PERL_CALLCONV UV Perl_to_uni_title(pTHX_ UV c, U8 *p, STRLEN *lenp);
PERL_CALLCONV UV Perl_to_uni_lower(pTHX_ UV c, U8 *p, STRLEN *lenp);
PERL_CALLCONV UV Perl_to_uni_fold(pTHX_ UV c, U8 *p, STRLEN *lenp);
PERL_CALLCONV bool Perl_is_uni_alnum_lc(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_alnumc_lc(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_idfirst_lc(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_alpha_lc(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_ascii_lc(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_space_lc(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_cntrl_lc(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_graph_lc(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_digit_lc(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_upper_lc(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_lower_lc(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_print_lc(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_punct_lc(pTHX_ UV c);
PERL_CALLCONV bool Perl_is_uni_xdigit_lc(pTHX_ UV c);
PERL_CALLCONV STRLEN Perl_is_utf8_char(pTHX_ U8 *p);
PERL_CALLCONV bool Perl_is_utf8_string(pTHX_ U8 *s, STRLEN len);
PERL_CALLCONV bool Perl_is_utf8_string_loc(pTHX_ U8 *s, STRLEN len, U8 **p);
PERL_CALLCONV bool Perl_is_utf8_alnum(pTHX_ U8 *p);
PERL_CALLCONV bool Perl_is_utf8_alnumc(pTHX_ U8 *p);
PERL_CALLCONV bool Perl_is_utf8_idfirst(pTHX_ U8 *p);
PERL_CALLCONV bool Perl_is_utf8_idcont(pTHX_ U8 *p);
PERL_CALLCONV bool Perl_is_utf8_alpha(pTHX_ U8 *p);
PERL_CALLCONV bool Perl_is_utf8_ascii(pTHX_ U8 *p);
PERL_CALLCONV bool Perl_is_utf8_space(pTHX_ U8 *p);
PERL_CALLCONV bool Perl_is_utf8_cntrl(pTHX_ U8 *p);
PERL_CALLCONV bool Perl_is_utf8_digit(pTHX_ U8 *p);
PERL_CALLCONV bool Perl_is_utf8_graph(pTHX_ U8 *p);
PERL_CALLCONV bool Perl_is_utf8_upper(pTHX_ U8 *p);
PERL_CALLCONV bool Perl_is_utf8_lower(pTHX_ U8 *p);
PERL_CALLCONV bool Perl_is_utf8_print(pTHX_ U8 *p);
PERL_CALLCONV bool Perl_is_utf8_punct(pTHX_ U8 *p);
PERL_CALLCONV bool Perl_is_utf8_xdigit(pTHX_ U8 *p);
PERL_CALLCONV bool Perl_is_utf8_mark(pTHX_ U8 *p);
PERL_CALLCONV OP* Perl_jmaybe(pTHX_ OP* arg);
PERL_CALLCONV I32 Perl_keyword(pTHX_ char* d, I32 len);
PERL_CALLCONV void Perl_leave_scope(pTHX_ I32 base);
PERL_CALLCONV void Perl_lex_end(pTHX);
PERL_CALLCONV void Perl_lex_start(pTHX_ SV* line);
PERL_CALLCONV void Perl_op_null(pTHX_ OP* o);
PERL_CALLCONV void Perl_op_clear(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_linklist(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_list(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_listkids(pTHX_ OP* o);
PERL_CALLCONV void Perl_load_module(pTHX_ U32 flags, SV* name, SV* ver, ...);
PERL_CALLCONV void Perl_vload_module(pTHX_ U32 flags, SV* name, SV* ver, va_list* args);
PERL_CALLCONV OP* Perl_localize(pTHX_ OP* arg, I32 lexical);
PERL_CALLCONV I32 Perl_looks_like_number(pTHX_ SV* sv);
PERL_CALLCONV UV Perl_grok_bin(pTHX_ char* start, STRLEN* len, I32* flags, NV *result);
PERL_CALLCONV UV Perl_grok_hex(pTHX_ char* start, STRLEN* len, I32* flags, NV *result);
PERL_CALLCONV int Perl_grok_number(pTHX_ const char *pv, STRLEN len, UV *valuep);
PERL_CALLCONV bool Perl_grok_numeric_radix(pTHX_ const char **sp, const char *send);
PERL_CALLCONV UV Perl_grok_oct(pTHX_ char* start, STRLEN* len, I32* flags, NV *result);
PERL_CALLCONV int Perl_magic_clearenv(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_clear_all_env(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_clearpack(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_clearsig(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_existspack(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_freeregexp(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_freeovrld(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_get(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_getarylen(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_getdefelem(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_getglob(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_getnkeys(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_getpack(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_getpos(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_getsig(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_getsubstr(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_gettaint(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_getuvar(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_getvec(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV U32 Perl_magic_len(pTHX_ SV* sv, MAGIC* mg);
#if defined(USE_5005THREADS)
PERL_CALLCONV int Perl_magic_mutexfree(pTHX_ SV* sv, MAGIC* mg);
#endif
PERL_CALLCONV int Perl_magic_nextpack(pTHX_ SV* sv, MAGIC* mg, SV* key);
PERL_CALLCONV U32 Perl_magic_regdata_cnt(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_regdatum_get(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_regdatum_set(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_set(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setamagic(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setarylen(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setbm(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setdbline(pTHX_ SV* sv, MAGIC* mg);
#if defined(USE_LOCALE_COLLATE)
PERL_CALLCONV int Perl_magic_setcollxfrm(pTHX_ SV* sv, MAGIC* mg);
#endif
PERL_CALLCONV int Perl_magic_setdefelem(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setenv(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setfm(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setisa(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setglob(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setmglob(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setnkeys(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setpack(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setpos(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setregexp(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setsig(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setsubstr(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_settaint(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setuvar(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setvec(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_setutf8(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_set_all_env(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV U32 Perl_magic_sizepack(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV int Perl_magic_wipepack(pTHX_ SV* sv, MAGIC* mg);
PERL_CALLCONV void Perl_magicname(pTHX_ char* sym, char* name, I32 namlen);
PERL_CALLCONV void Perl_markstack_grow(pTHX);
#if defined(USE_LOCALE_COLLATE)
PERL_CALLCONV char* Perl_mem_collxfrm(pTHX_ const char* s, STRLEN len, STRLEN* xlen);
#endif
PERL_CALLCONV SV* Perl_mess(pTHX_ const char* pat, ...)
__attribute__format__(__printf__,pTHX_1,pTHX_2);
PERL_CALLCONV SV* Perl_vmess(pTHX_ const char* pat, va_list* args);
PERL_CALLCONV void Perl_qerror(pTHX_ SV* err);
PERL_CALLCONV void Perl_sortsv(pTHX_ SV ** array, size_t num_elts, SVCOMPARE_t cmp);
PERL_CALLCONV int Perl_mg_clear(pTHX_ SV* sv);
PERL_CALLCONV int Perl_mg_copy(pTHX_ SV* sv, SV* nsv, const char* key, I32 klen);
PERL_CALLCONV MAGIC* Perl_mg_find(pTHX_ SV* sv, int type);
PERL_CALLCONV int Perl_mg_free(pTHX_ SV* sv);
PERL_CALLCONV int Perl_mg_get(pTHX_ SV* sv);
PERL_CALLCONV U32 Perl_mg_length(pTHX_ SV* sv);
PERL_CALLCONV void Perl_mg_magical(pTHX_ SV* sv);
PERL_CALLCONV int Perl_mg_set(pTHX_ SV* sv);
PERL_CALLCONV I32 Perl_mg_size(pTHX_ SV* sv);
PERL_CALLCONV void Perl_mini_mktime(pTHX_ struct tm *pm);
PERL_CALLCONV OP* Perl_mod(pTHX_ OP* o, I32 type);
PERL_CALLCONV int Perl_mode_from_discipline(pTHX_ SV* discp);
PERL_CALLCONV char* Perl_moreswitches(pTHX_ char* s);
PERL_CALLCONV OP* Perl_my(pTHX_ OP* o);
PERL_CALLCONV NV Perl_my_atof(pTHX_ const char *s);
#if (!defined(HAS_MEMCPY) && !defined(HAS_BCOPY)) || (!defined(HAS_MEMMOVE) && !defined(HAS_SAFE_MEMCPY) && !defined(HAS_SAFE_BCOPY))
PERL_CALLCONV char* Perl_my_bcopy(const char* from, char* to, I32 len);
#endif
#if !defined(HAS_BZERO) && !defined(HAS_MEMSET)
PERL_CALLCONV char* Perl_my_bzero(char* loc, I32 len);
#endif
PERL_CALLCONV void Perl_my_exit(pTHX_ U32 status) __attribute__((noreturn));
PERL_CALLCONV void Perl_my_failure_exit(pTHX) __attribute__((noreturn));
PERL_CALLCONV I32 Perl_my_fflush_all(pTHX);
PERL_CALLCONV Pid_t Perl_my_fork(void);
PERL_CALLCONV void Perl_atfork_lock(void);
PERL_CALLCONV void Perl_atfork_unlock(void);
PERL_CALLCONV I32 Perl_my_lstat(pTHX);
#if !defined(HAS_MEMCMP) || !defined(HAS_SANE_MEMCMP)
PERL_CALLCONV I32 Perl_my_memcmp(const char* s1, const char* s2, I32 len);
#endif
#if !defined(HAS_MEMSET)
PERL_CALLCONV void* Perl_my_memset(char* loc, I32 ch, I32 len);
#endif
PERL_CALLCONV I32 Perl_my_pclose(pTHX_ PerlIO* ptr);
PERL_CALLCONV PerlIO* Perl_my_popen(pTHX_ char* cmd, char* mode);
PERL_CALLCONV PerlIO* Perl_my_popen_list(pTHX_ char* mode, int n, SV ** args);
PERL_CALLCONV void Perl_my_setenv(pTHX_ char* nam, char* val);
PERL_CALLCONV I32 Perl_my_stat(pTHX);
PERL_CALLCONV char * Perl_my_strftime(pTHX_ char *fmt, int sec, int min, int hour, int mday, int mon, int year, int wday, int yday, int isdst);
#if defined(MYSWAP)
PERL_CALLCONV short Perl_my_swap(pTHX_ short s);
PERL_CALLCONV long Perl_my_htonl(pTHX_ long l);
PERL_CALLCONV long Perl_my_ntohl(pTHX_ long l);
#endif
PERL_CALLCONV void Perl_my_unexec(pTHX);
PERL_CALLCONV OP* Perl_newANONLIST(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_newANONHASH(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_newANONSUB(pTHX_ I32 floor, OP* proto, OP* block);
PERL_CALLCONV OP* Perl_newASSIGNOP(pTHX_ I32 flags, OP* left, I32 optype, OP* right);
PERL_CALLCONV OP* Perl_newCONDOP(pTHX_ I32 flags, OP* expr, OP* trueop, OP* falseop);
PERL_CALLCONV CV* Perl_newCONSTSUB(pTHX_ HV* stash, char* name, SV* sv);
PERL_CALLCONV void Perl_newFORM(pTHX_ I32 floor, OP* o, OP* block);
PERL_CALLCONV OP* Perl_newFOROP(pTHX_ I32 flags, char* label, line_t forline, OP* sclr, OP* expr, OP*block, OP*cont);
PERL_CALLCONV OP* Perl_newLOGOP(pTHX_ I32 optype, I32 flags, OP* left, OP* right);
PERL_CALLCONV OP* Perl_newLOOPEX(pTHX_ I32 type, OP* label);
PERL_CALLCONV OP* Perl_newLOOPOP(pTHX_ I32 flags, I32 debuggable, OP* expr, OP* block);
PERL_CALLCONV OP* Perl_newNULLLIST(pTHX);
PERL_CALLCONV OP* Perl_newOP(pTHX_ I32 optype, I32 flags);
PERL_CALLCONV void Perl_newPROG(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_newRANGE(pTHX_ I32 flags, OP* left, OP* right);
PERL_CALLCONV OP* Perl_newSLICEOP(pTHX_ I32 flags, OP* subscript, OP* listop);
PERL_CALLCONV OP* Perl_newSTATEOP(pTHX_ I32 flags, char* label, OP* o);
PERL_CALLCONV CV* Perl_newSUB(pTHX_ I32 floor, OP* o, OP* proto, OP* block);
PERL_CALLCONV CV* Perl_newXS(pTHX_ char* name, XSUBADDR_t f, char* filename);
PERL_CALLCONV AV* Perl_newAV(pTHX);
PERL_CALLCONV OP* Perl_newAVREF(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_newBINOP(pTHX_ I32 type, I32 flags, OP* first, OP* last);
PERL_CALLCONV OP* Perl_newCVREF(pTHX_ I32 flags, OP* o);
PERL_CALLCONV OP* Perl_newGVOP(pTHX_ I32 type, I32 flags, GV* gv);
PERL_CALLCONV GV* Perl_newGVgen(pTHX_ char* pack);
PERL_CALLCONV OP* Perl_newGVREF(pTHX_ I32 type, OP* o);
PERL_CALLCONV OP* Perl_newHVREF(pTHX_ OP* o);
PERL_CALLCONV HV* Perl_newHV(pTHX);
PERL_CALLCONV HV* Perl_newHVhv(pTHX_ HV* hv);
PERL_CALLCONV IO* Perl_newIO(pTHX);
PERL_CALLCONV OP* Perl_newLISTOP(pTHX_ I32 type, I32 flags, OP* first, OP* last);
PERL_CALLCONV OP* Perl_newPADOP(pTHX_ I32 type, I32 flags, SV* sv);
PERL_CALLCONV OP* Perl_newPMOP(pTHX_ I32 type, I32 flags);
PERL_CALLCONV OP* Perl_newPVOP(pTHX_ I32 type, I32 flags, char* pv);
PERL_CALLCONV SV* Perl_newRV(pTHX_ SV* pref);
PERL_CALLCONV SV* Perl_newRV_noinc(pTHX_ SV *sv);
PERL_CALLCONV SV* Perl_newSV(pTHX_ STRLEN len);
PERL_CALLCONV OP* Perl_newSVREF(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_newSVOP(pTHX_ I32 type, I32 flags, SV* sv);
PERL_CALLCONV SV* Perl_newSViv(pTHX_ IV i);
PERL_CALLCONV SV* Perl_newSVuv(pTHX_ UV u);
PERL_CALLCONV SV* Perl_newSVnv(pTHX_ NV n);
PERL_CALLCONV SV* Perl_newSVpv(pTHX_ const char* s, STRLEN len);
PERL_CALLCONV SV* Perl_newSVpvn(pTHX_ const char* s, STRLEN len);
PERL_CALLCONV SV* Perl_newSVpvn_share(pTHX_ const char* s, I32 len, U32 hash);
PERL_CALLCONV SV* Perl_newSVpvf(pTHX_ const char* pat, ...)
__attribute__format__(__printf__,pTHX_1,pTHX_2);
PERL_CALLCONV SV* Perl_vnewSVpvf(pTHX_ const char* pat, va_list* args);
PERL_CALLCONV SV* Perl_newSVrv(pTHX_ SV* rv, const char* classname);
PERL_CALLCONV SV* Perl_newSVsv(pTHX_ SV* old);
PERL_CALLCONV OP* Perl_newUNOP(pTHX_ I32 type, I32 flags, OP* first);
PERL_CALLCONV OP* Perl_newWHILEOP(pTHX_ I32 flags, I32 debuggable, LOOP* loop, I32 whileline, OP* expr, OP* block, OP* cont);
PERL_CALLCONV PERL_SI* Perl_new_stackinfo(pTHX_ I32 stitems, I32 cxitems);
PERL_CALLCONV char* Perl_scan_vstring(pTHX_ char *vstr, SV *sv);
PERL_CALLCONV PerlIO* Perl_nextargv(pTHX_ GV* gv);
PERL_CALLCONV char* Perl_ninstr(pTHX_ const char* big, const char* bigend, const char* little, const char* lend);
PERL_CALLCONV OP* Perl_oopsCV(pTHX_ OP* o);
PERL_CALLCONV void Perl_op_free(pTHX_ OP* arg);
PERL_CALLCONV void Perl_package(pTHX_ OP* o);
PERL_CALLCONV PADOFFSET Perl_pad_alloc(pTHX_ I32 optype, U32 tmptype);
PERL_CALLCONV PADOFFSET Perl_allocmy(pTHX_ char* name);
PERL_CALLCONV PADOFFSET Perl_pad_findmy(pTHX_ char* name);
PERL_CALLCONV OP* Perl_oopsAV(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_oopsHV(pTHX_ OP* o);
PERL_CALLCONV void Perl_pad_leavemy(pTHX);
PERL_CALLCONV SV* Perl_pad_sv(pTHX_ PADOFFSET po);
PERL_CALLCONV void Perl_pad_free(pTHX_ PADOFFSET po);
PERL_CALLCONV void Perl_pad_reset(pTHX);
PERL_CALLCONV void Perl_pad_swipe(pTHX_ PADOFFSET po, bool refadjust);
PERL_CALLCONV void Perl_peep(pTHX_ OP* o);
PERL_CALLCONV PerlIO* Perl_start_glob(pTHX_ SV* pattern, IO *io);
#if defined(USE_5005THREADS)
PERL_CALLCONV struct perl_thread* Perl_new_struct_thread(pTHX_ struct perl_thread *t);
#endif
#if defined(USE_REENTRANT_API)
PERL_CALLCONV void Perl_reentrant_size(pTHX);
PERL_CALLCONV void Perl_reentrant_init(pTHX);
PERL_CALLCONV void Perl_reentrant_free(pTHX);
PERL_CALLCONV void* Perl_reentrant_retry(const char*, ...);
#endif
PERL_CALLCONV void Perl_call_atexit(pTHX_ ATEXIT_t fn, void *ptr);
PERL_CALLCONV I32 Perl_call_argv(pTHX_ const char* sub_name, I32 flags, char** argv);
PERL_CALLCONV I32 Perl_call_method(pTHX_ const char* methname, I32 flags);
PERL_CALLCONV I32 Perl_call_pv(pTHX_ const char* sub_name, I32 flags);
PERL_CALLCONV I32 Perl_call_sv(pTHX_ SV* sv, I32 flags);
PERL_CALLCONV void Perl_despatch_signals(pTHX);
PERL_CALLCONV SV* Perl_eval_pv(pTHX_ const char* p, I32 croak_on_error);
PERL_CALLCONV I32 Perl_eval_sv(pTHX_ SV* sv, I32 flags);
PERL_CALLCONV SV* Perl_get_sv(pTHX_ const char* name, I32 create);
PERL_CALLCONV AV* Perl_get_av(pTHX_ const char* name, I32 create);
PERL_CALLCONV HV* Perl_get_hv(pTHX_ const char* name, I32 create);
PERL_CALLCONV CV* Perl_get_cv(pTHX_ const char* name, I32 create);
PERL_CALLCONV int Perl_init_i18nl10n(pTHX_ int printwarn);
PERL_CALLCONV int Perl_init_i18nl14n(pTHX_ int printwarn);
PERL_CALLCONV void Perl_new_collate(pTHX_ char* newcoll);
PERL_CALLCONV void Perl_new_ctype(pTHX_ char* newctype);
PERL_CALLCONV void Perl_new_numeric(pTHX_ char* newcoll);
PERL_CALLCONV void Perl_set_numeric_local(pTHX);
PERL_CALLCONV void Perl_set_numeric_radix(pTHX);
PERL_CALLCONV void Perl_set_numeric_standard(pTHX);
PERL_CALLCONV void Perl_require_pv(pTHX_ const char* pv);
PERL_CALLCONV void Perl_pack_cat(pTHX_ SV *cat, char *pat, char *patend, SV **beglist, SV **endlist, SV ***next_in_list, U32 flags);
PERL_CALLCONV void Perl_packlist(pTHX_ SV *cat, char *pat, char *patend, SV **beglist, SV **endlist);
PERL_CALLCONV void Perl_pidgone(pTHX_ Pid_t pid, int status);
PERL_CALLCONV void Perl_pmflag(pTHX_ U32* pmfl, int ch);
PERL_CALLCONV OP* Perl_pmruntime(pTHX_ OP* pm, OP* expr, OP* repl);
PERL_CALLCONV OP* Perl_pmtrans(pTHX_ OP* o, OP* expr, OP* repl);
PERL_CALLCONV OP* Perl_pop_return(pTHX);
PERL_CALLCONV void Perl_pop_scope(pTHX);
PERL_CALLCONV OP* Perl_prepend_elem(pTHX_ I32 optype, OP* head, OP* tail);
PERL_CALLCONV void Perl_push_return(pTHX_ OP* o);
PERL_CALLCONV void Perl_push_scope(pTHX);
PERL_CALLCONV OP* Perl_ref(pTHX_ OP* o, I32 type);
PERL_CALLCONV OP* Perl_refkids(pTHX_ OP* o, I32 type);
PERL_CALLCONV void Perl_regdump(pTHX_ regexp* r);
PERL_CALLCONV SV* Perl_regclass_swash(pTHX_ struct regnode *n, bool doinit, SV **listsvp, SV **altsvp);
PERL_CALLCONV I32 Perl_pregexec(pTHX_ regexp* prog, char* stringarg, char* strend, char* strbeg, I32 minend, SV* screamer, U32 nosave);
PERL_CALLCONV void Perl_pregfree(pTHX_ struct regexp* r);
PERL_CALLCONV regexp* Perl_pregcomp(pTHX_ char* exp, char* xend, PMOP* pm);
PERL_CALLCONV char* Perl_re_intuit_start(pTHX_ regexp* prog, SV* sv, char* strpos, char* strend, U32 flags, struct re_scream_pos_data_s *data);
PERL_CALLCONV SV* Perl_re_intuit_string(pTHX_ regexp* prog);
PERL_CALLCONV I32 Perl_regexec_flags(pTHX_ regexp* prog, char* stringarg, char* strend, char* strbeg, I32 minend, SV* screamer, void* data, U32 flags);
PERL_CALLCONV regnode* Perl_regnext(pTHX_ regnode* p);
PERL_CALLCONV void Perl_regprop(pTHX_ SV* sv, regnode* o);
PERL_CALLCONV void Perl_repeatcpy(pTHX_ char* to, const char* from, I32 len, I32 count);
PERL_CALLCONV char* Perl_rninstr(pTHX_ const char* big, const char* bigend, const char* little, const char* lend);
PERL_CALLCONV Sighandler_t Perl_rsignal(pTHX_ int i, Sighandler_t t);
PERL_CALLCONV int Perl_rsignal_restore(pTHX_ int i, Sigsave_t* t);
PERL_CALLCONV int Perl_rsignal_save(pTHX_ int i, Sighandler_t t1, Sigsave_t* t2);
PERL_CALLCONV Sighandler_t Perl_rsignal_state(pTHX_ int i);
PERL_CALLCONV void Perl_rxres_free(pTHX_ void** rsp);
PERL_CALLCONV void Perl_rxres_restore(pTHX_ void** rsp, REGEXP* prx);
PERL_CALLCONV void Perl_rxres_save(pTHX_ void** rsp, REGEXP* prx);
#if !defined(HAS_RENAME)
PERL_CALLCONV I32 Perl_same_dirent(pTHX_ char* a, char* b);
#endif
PERL_CALLCONV char* Perl_savepv(pTHX_ const char* pv);
PERL_CALLCONV char* Perl_savesharedpv(pTHX_ const char* pv);
PERL_CALLCONV char* Perl_savepvn(pTHX_ const char* pv, I32 len);
PERL_CALLCONV void Perl_savestack_grow(pTHX);
PERL_CALLCONV void Perl_savestack_grow_cnt(pTHX_ I32 need);
PERL_CALLCONV void Perl_save_aelem(pTHX_ AV* av, I32 idx, SV **sptr);
PERL_CALLCONV I32 Perl_save_alloc(pTHX_ I32 size, I32 pad);
PERL_CALLCONV void Perl_save_aptr(pTHX_ AV** aptr);
PERL_CALLCONV AV* Perl_save_ary(pTHX_ GV* gv);
PERL_CALLCONV void Perl_save_bool(pTHX_ bool* boolp);
PERL_CALLCONV void Perl_save_clearsv(pTHX_ SV** svp);
PERL_CALLCONV void Perl_save_delete(pTHX_ HV* hv, char* key, I32 klen);
PERL_CALLCONV void Perl_save_destructor(pTHX_ DESTRUCTORFUNC_NOCONTEXT_t f, void* p);
PERL_CALLCONV void Perl_save_destructor_x(pTHX_ DESTRUCTORFUNC_t f, void* p);
PERL_CALLCONV void Perl_save_freesv(pTHX_ SV* sv);
PERL_CALLCONV void Perl_save_freeop(pTHX_ OP* o);
PERL_CALLCONV void Perl_save_freepv(pTHX_ char* pv);
PERL_CALLCONV void Perl_save_generic_svref(pTHX_ SV** sptr);
PERL_CALLCONV void Perl_save_generic_pvref(pTHX_ char** str);
PERL_CALLCONV void Perl_save_shared_pvref(pTHX_ char** str);
PERL_CALLCONV void Perl_save_gp(pTHX_ GV* gv, I32 empty);
PERL_CALLCONV HV* Perl_save_hash(pTHX_ GV* gv);
PERL_CALLCONV void Perl_save_helem(pTHX_ HV* hv, SV *key, SV **sptr);
PERL_CALLCONV void Perl_save_hints(pTHX);
PERL_CALLCONV void Perl_save_hptr(pTHX_ HV** hptr);
PERL_CALLCONV void Perl_save_I16(pTHX_ I16* intp);
PERL_CALLCONV void Perl_save_I32(pTHX_ I32* intp);
PERL_CALLCONV void Perl_save_I8(pTHX_ I8* bytep);
PERL_CALLCONV void Perl_save_int(pTHX_ int* intp);
PERL_CALLCONV void Perl_save_item(pTHX_ SV* item);
PERL_CALLCONV void Perl_save_iv(pTHX_ IV* iv);
PERL_CALLCONV void Perl_save_list(pTHX_ SV** sarg, I32 maxsarg);
PERL_CALLCONV void Perl_save_long(pTHX_ long* longp);
PERL_CALLCONV void Perl_save_mortalizesv(pTHX_ SV* sv);
PERL_CALLCONV void Perl_save_nogv(pTHX_ GV* gv);
PERL_CALLCONV void Perl_save_op(pTHX);
PERL_CALLCONV SV* Perl_save_scalar(pTHX_ GV* gv);
PERL_CALLCONV void Perl_save_pptr(pTHX_ char** pptr);
PERL_CALLCONV void Perl_save_vptr(pTHX_ void* pptr);
PERL_CALLCONV void Perl_save_re_context(pTHX);
PERL_CALLCONV void Perl_save_padsv(pTHX_ PADOFFSET off);
PERL_CALLCONV void Perl_save_sptr(pTHX_ SV** sptr);
PERL_CALLCONV SV* Perl_save_svref(pTHX_ SV** sptr);
PERL_CALLCONV SV** Perl_save_threadsv(pTHX_ PADOFFSET i);
PERL_CALLCONV OP* Perl_sawparens(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_scalar(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_scalarkids(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_scalarseq(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_scalarvoid(pTHX_ OP* o);
PERL_CALLCONV NV Perl_scan_bin(pTHX_ char* start, STRLEN len, STRLEN* retlen);
PERL_CALLCONV NV Perl_scan_hex(pTHX_ char* start, STRLEN len, STRLEN* retlen);
PERL_CALLCONV char* Perl_scan_num(pTHX_ char* s, YYSTYPE *lvalp);
PERL_CALLCONV NV Perl_scan_oct(pTHX_ char* start, STRLEN len, STRLEN* retlen);
PERL_CALLCONV OP* Perl_scope(pTHX_ OP* o);
PERL_CALLCONV char* Perl_screaminstr(pTHX_ SV* bigsv, SV* littlesv, I32 start_shift, I32 end_shift, I32 *state, I32 last);
#if !defined(VMS)
PERL_CALLCONV I32 Perl_setenv_getix(pTHX_ char* nam);
#endif
PERL_CALLCONV void Perl_setdefout(pTHX_ GV* gv);
PERL_CALLCONV HEK* Perl_share_hek(pTHX_ const char* sv, I32 len, U32 hash);
PERL_CALLCONV Signal_t Perl_sighandler(int sig);
PERL_CALLCONV Signal_t Perl_csighandler(int sig);
PERL_CALLCONV SV** Perl_stack_grow(pTHX_ SV** sp, SV**p, int n);
PERL_CALLCONV I32 Perl_start_subparse(pTHX_ I32 is_format, U32 flags);
PERL_CALLCONV void Perl_sub_crush_depth(pTHX_ CV* cv);
PERL_CALLCONV bool Perl_sv_2bool(pTHX_ SV* sv);
PERL_CALLCONV CV* Perl_sv_2cv(pTHX_ SV* sv, HV** st, GV** gvp, I32 lref);
PERL_CALLCONV IO* Perl_sv_2io(pTHX_ SV* sv);
PERL_CALLCONV IV Perl_sv_2iv(pTHX_ SV* sv);
PERL_CALLCONV SV* Perl_sv_2mortal(pTHX_ SV* sv);
PERL_CALLCONV NV Perl_sv_2nv(pTHX_ SV* sv);
/* PERL_CALLCONV char* sv_2pv(pTHX_ SV* sv, STRLEN* lp); */
PERL_CALLCONV char* Perl_sv_2pvutf8(pTHX_ SV* sv, STRLEN* lp);
PERL_CALLCONV char* Perl_sv_2pvbyte(pTHX_ SV* sv, STRLEN* lp);
PERL_CALLCONV char* Perl_sv_pvn_nomg(pTHX_ SV* sv, STRLEN* lp);
PERL_CALLCONV UV Perl_sv_2uv(pTHX_ SV* sv);
PERL_CALLCONV IV Perl_sv_iv(pTHX_ SV* sv);
PERL_CALLCONV UV Perl_sv_uv(pTHX_ SV* sv);
PERL_CALLCONV NV Perl_sv_nv(pTHX_ SV* sv);
PERL_CALLCONV char* Perl_sv_pvn(pTHX_ SV *sv, STRLEN *len);
PERL_CALLCONV char* Perl_sv_pvutf8n(pTHX_ SV *sv, STRLEN *len);
PERL_CALLCONV char* Perl_sv_pvbyten(pTHX_ SV *sv, STRLEN *len);
PERL_CALLCONV I32 Perl_sv_true(pTHX_ SV *sv);
PERL_CALLCONV void Perl_sv_add_arena(pTHX_ char* ptr, U32 size, U32 flags);
PERL_CALLCONV int Perl_sv_backoff(pTHX_ SV* sv);
PERL_CALLCONV SV* Perl_sv_bless(pTHX_ SV* sv, HV* stash);
PERL_CALLCONV void Perl_sv_catpvf(pTHX_ SV* sv, const char* pat, ...)
__attribute__format__(__printf__,pTHX_2,pTHX_3);
PERL_CALLCONV void Perl_sv_vcatpvf(pTHX_ SV* sv, const char* pat, va_list* args);
PERL_CALLCONV void Perl_sv_catpv(pTHX_ SV* sv, const char* ptr);
/* PERL_CALLCONV void sv_catpvn(pTHX_ SV* sv, const char* ptr, STRLEN len); */
/* PERL_CALLCONV void sv_catsv(pTHX_ SV* dsv, SV* ssv); */
PERL_CALLCONV void Perl_sv_chop(pTHX_ SV* sv, char* ptr);
PERL_CALLCONV I32 Perl_sv_clean_all(pTHX);
PERL_CALLCONV void Perl_sv_clean_objs(pTHX);
PERL_CALLCONV void Perl_sv_clear(pTHX_ SV* sv);
PERL_CALLCONV I32 Perl_sv_cmp(pTHX_ SV* sv1, SV* sv2);
PERL_CALLCONV I32 Perl_sv_cmp_locale(pTHX_ SV* sv1, SV* sv2);
#if defined(USE_LOCALE_COLLATE)
PERL_CALLCONV char* Perl_sv_collxfrm(pTHX_ SV* sv, STRLEN* nxp);
#endif
PERL_CALLCONV OP* Perl_sv_compile_2op(pTHX_ SV* sv, OP** startp, char* code, PAD** padp);
PERL_CALLCONV int Perl_getcwd_sv(pTHX_ SV* sv);
PERL_CALLCONV void Perl_sv_dec(pTHX_ SV* sv);
PERL_CALLCONV void Perl_sv_dump(pTHX_ SV* sv);
PERL_CALLCONV bool Perl_sv_derived_from(pTHX_ SV* sv, const char* name);
PERL_CALLCONV I32 Perl_sv_eq(pTHX_ SV* sv1, SV* sv2);
PERL_CALLCONV void Perl_sv_free(pTHX_ SV* sv);
PERL_CALLCONV void Perl_sv_free_arenas(pTHX);
PERL_CALLCONV char* Perl_sv_gets(pTHX_ SV* sv, PerlIO* fp, I32 append);
PERL_CALLCONV char* Perl_sv_grow(pTHX_ SV* sv, STRLEN newlen);
PERL_CALLCONV void Perl_sv_inc(pTHX_ SV* sv);
PERL_CALLCONV void Perl_sv_insert(pTHX_ SV* bigsv, STRLEN offset, STRLEN len, char* little, STRLEN littlelen);
PERL_CALLCONV int Perl_sv_isa(pTHX_ SV* sv, const char* name);
PERL_CALLCONV int Perl_sv_isobject(pTHX_ SV* sv);
PERL_CALLCONV STRLEN Perl_sv_len(pTHX_ SV* sv);
PERL_CALLCONV STRLEN Perl_sv_len_utf8(pTHX_ SV* sv);
PERL_CALLCONV void Perl_sv_magic(pTHX_ SV* sv, SV* obj, int how, const char* name, I32 namlen);
PERL_CALLCONV MAGIC * Perl_sv_magicext(pTHX_ SV* sv, SV* obj, int how, MGVTBL *vtbl, const char* name, I32 namlen );
PERL_CALLCONV SV* Perl_sv_mortalcopy(pTHX_ SV* oldsv);
PERL_CALLCONV SV* Perl_sv_newmortal(pTHX);
PERL_CALLCONV SV* Perl_sv_newref(pTHX_ SV* sv);
PERL_CALLCONV char* Perl_sv_peek(pTHX_ SV* sv);
PERL_CALLCONV void Perl_sv_pos_u2b(pTHX_ SV* sv, I32* offsetp, I32* lenp);
PERL_CALLCONV void Perl_sv_pos_b2u(pTHX_ SV* sv, I32* offsetp);
/* PERL_CALLCONV char* sv_pvn_force(pTHX_ SV* sv, STRLEN* lp); */
PERL_CALLCONV char* Perl_sv_pvutf8n_force(pTHX_ SV* sv, STRLEN* lp);
PERL_CALLCONV char* Perl_sv_pvbyten_force(pTHX_ SV* sv, STRLEN* lp);
PERL_CALLCONV char* Perl_sv_recode_to_utf8(pTHX_ SV* sv, SV *encoding);
PERL_CALLCONV bool Perl_sv_cat_decode(pTHX_ SV* dsv, SV *encoding, SV *ssv, int *offset, char* tstr, int tlen);
PERL_CALLCONV char* Perl_sv_reftype(pTHX_ SV* sv, int ob);
PERL_CALLCONV void Perl_sv_replace(pTHX_ SV* sv, SV* nsv);
PERL_CALLCONV void Perl_sv_report_used(pTHX);
PERL_CALLCONV void Perl_sv_reset(pTHX_ char* s, HV* stash);
PERL_CALLCONV void Perl_sv_setpvf(pTHX_ SV* sv, const char* pat, ...)
__attribute__format__(__printf__,pTHX_2,pTHX_3);
PERL_CALLCONV void Perl_sv_vsetpvf(pTHX_ SV* sv, const char* pat, va_list* args);
PERL_CALLCONV void Perl_sv_setiv(pTHX_ SV* sv, IV num);
PERL_CALLCONV void Perl_sv_setpviv(pTHX_ SV* sv, IV num);
PERL_CALLCONV void Perl_sv_setuv(pTHX_ SV* sv, UV num);
PERL_CALLCONV void Perl_sv_setnv(pTHX_ SV* sv, NV num);
PERL_CALLCONV SV* Perl_sv_setref_iv(pTHX_ SV* rv, const char* classname, IV iv);
PERL_CALLCONV SV* Perl_sv_setref_uv(pTHX_ SV* rv, const char* classname, UV uv);
PERL_CALLCONV SV* Perl_sv_setref_nv(pTHX_ SV* rv, const char* classname, NV nv);
PERL_CALLCONV SV* Perl_sv_setref_pv(pTHX_ SV* rv, const char* classname, void* pv);
PERL_CALLCONV SV* Perl_sv_setref_pvn(pTHX_ SV* rv, const char* classname, char* pv, STRLEN n);
PERL_CALLCONV void Perl_sv_setpv(pTHX_ SV* sv, const char* ptr);
PERL_CALLCONV void Perl_sv_setpvn(pTHX_ SV* sv, const char* ptr, STRLEN len);
/* PERL_CALLCONV void sv_setsv(pTHX_ SV* dsv, SV* ssv); */
PERL_CALLCONV void Perl_sv_taint(pTHX_ SV* sv);
PERL_CALLCONV bool Perl_sv_tainted(pTHX_ SV* sv);
PERL_CALLCONV int Perl_sv_unmagic(pTHX_ SV* sv, int type);
PERL_CALLCONV void Perl_sv_unref(pTHX_ SV* sv);
PERL_CALLCONV void Perl_sv_unref_flags(pTHX_ SV* sv, U32 flags);
PERL_CALLCONV void Perl_sv_untaint(pTHX_ SV* sv);
PERL_CALLCONV bool Perl_sv_upgrade(pTHX_ SV* sv, U32 mt);
PERL_CALLCONV void Perl_sv_usepvn(pTHX_ SV* sv, char* ptr, STRLEN len);
PERL_CALLCONV void Perl_sv_vcatpvfn(pTHX_ SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted);
PERL_CALLCONV void Perl_sv_vsetpvfn(pTHX_ SV* sv, const char* pat, STRLEN patlen, va_list* args, SV** svargs, I32 svmax, bool *maybe_tainted);
PERL_CALLCONV NV Perl_str_to_version(pTHX_ SV *sv);
PERL_CALLCONV SV* Perl_swash_init(pTHX_ char* pkg, char* name, SV* listsv, I32 minbits, I32 none);
PERL_CALLCONV UV Perl_swash_fetch(pTHX_ SV *sv, U8 *ptr, bool do_utf8);
PERL_CALLCONV void Perl_taint_env(pTHX);
PERL_CALLCONV void Perl_taint_proper(pTHX_ const char* f, const char* s);
PERL_CALLCONV UV Perl_to_utf8_case(pTHX_ U8 *p, U8* ustrp, STRLEN *lenp, SV **swash, char *normal, char *special);
PERL_CALLCONV UV Perl_to_utf8_lower(pTHX_ U8 *p, U8* ustrp, STRLEN *lenp);
PERL_CALLCONV UV Perl_to_utf8_upper(pTHX_ U8 *p, U8* ustrp, STRLEN *lenp);
PERL_CALLCONV UV Perl_to_utf8_title(pTHX_ U8 *p, U8* ustrp, STRLEN *lenp);
PERL_CALLCONV UV Perl_to_utf8_fold(pTHX_ U8 *p, U8* ustrp, STRLEN *lenp);
#if defined(UNLINK_ALL_VERSIONS)
PERL_CALLCONV I32 Perl_unlnk(pTHX_ char* f);
#endif
#if defined(USE_5005THREADS)
PERL_CALLCONV void Perl_unlock_condpair(pTHX_ void* svv);
#endif
PERL_CALLCONV I32 Perl_unpack_str(pTHX_ char *pat, char *patend, char *s, char *strbeg, char *strend, char **new_s, I32 ocnt, U32 flags);
PERL_CALLCONV I32 Perl_unpackstring(pTHX_ char *pat, char *patend, char *s, char *strend, U32 flags);
PERL_CALLCONV void Perl_unsharepvn(pTHX_ const char* sv, I32 len, U32 hash);
PERL_CALLCONV void Perl_unshare_hek(pTHX_ HEK* hek);
PERL_CALLCONV void Perl_utilize(pTHX_ int aver, I32 floor, OP* version, OP* idop, OP* arg);
PERL_CALLCONV U8* Perl_utf16_to_utf8(pTHX_ U8* p, U8 *d, I32 bytelen, I32 *newlen);
PERL_CALLCONV U8* Perl_utf16_to_utf8_reversed(pTHX_ U8* p, U8 *d, I32 bytelen, I32 *newlen);
PERL_CALLCONV STRLEN Perl_utf8_length(pTHX_ U8* s, U8 *e);
PERL_CALLCONV IV Perl_utf8_distance(pTHX_ U8 *a, U8 *b);
PERL_CALLCONV U8* Perl_utf8_hop(pTHX_ U8 *s, I32 off);
PERL_CALLCONV U8* Perl_utf8_to_bytes(pTHX_ U8 *s, STRLEN *len);
PERL_CALLCONV U8* Perl_bytes_from_utf8(pTHX_ U8 *s, STRLEN *len, bool *is_utf8);
PERL_CALLCONV U8* Perl_bytes_to_utf8(pTHX_ U8 *s, STRLEN *len);
PERL_CALLCONV UV Perl_utf8_to_uvchr(pTHX_ U8 *s, STRLEN* retlen);
PERL_CALLCONV UV Perl_utf8_to_uvuni(pTHX_ U8 *s, STRLEN* retlen);
PERL_CALLCONV UV Perl_utf8n_to_uvchr(pTHX_ U8 *s, STRLEN curlen, STRLEN* retlen, U32 flags);
PERL_CALLCONV UV Perl_utf8n_to_uvuni(pTHX_ U8 *s, STRLEN curlen, STRLEN* retlen, U32 flags);
PERL_CALLCONV U8* Perl_uvchr_to_utf8(pTHX_ U8 *d, UV uv);
PERL_CALLCONV U8* Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv);
PERL_CALLCONV U8* Perl_uvchr_to_utf8_flags(pTHX_ U8 *d, UV uv, UV flags);
PERL_CALLCONV U8* Perl_uvuni_to_utf8_flags(pTHX_ U8 *d, UV uv, UV flags);
PERL_CALLCONV char* Perl_pv_uni_display(pTHX_ SV *dsv, U8 *spv, STRLEN len, STRLEN pvlim, UV flags);
PERL_CALLCONV char* Perl_sv_uni_display(pTHX_ SV *dsv, SV *ssv, STRLEN pvlim, UV flags);
PERL_CALLCONV void Perl_vivify_defelem(pTHX_ SV* sv);
PERL_CALLCONV void Perl_vivify_ref(pTHX_ SV* sv, U32 to_what);
PERL_CALLCONV I32 Perl_wait4pid(pTHX_ Pid_t pid, int* statusp, int flags);
PERL_CALLCONV U32 Perl_parse_unicode_opts(pTHX_ char **popt);
PERL_CALLCONV U32 Perl_seed(pTHX);
PERL_CALLCONV UV Perl_get_hash_seed(pTHX);
PERL_CALLCONV void Perl_report_evil_fh(pTHX_ GV *gv, IO *io, I32 op);
PERL_CALLCONV void Perl_report_uninit(pTHX);
PERL_CALLCONV void Perl_warn(pTHX_ const char* pat, ...)
__attribute__format__(__printf__,pTHX_1,pTHX_2);
PERL_CALLCONV void Perl_vwarn(pTHX_ const char* pat, va_list* args);
PERL_CALLCONV void Perl_warner(pTHX_ U32 err, const char* pat, ...)
__attribute__format__(__printf__,pTHX_2,pTHX_3);
PERL_CALLCONV void Perl_vwarner(pTHX_ U32 err, const char* pat, va_list* args);
PERL_CALLCONV void Perl_watch(pTHX_ char** addr);
PERL_CALLCONV I32 Perl_whichsig(pTHX_ char* sig);
PERL_CALLCONV void Perl_write_to_stderr(pTHX_ const char* message, int msglen);
PERL_CALLCONV int Perl_yyerror(pTHX_ char* s);
#ifdef USE_PURE_BISON
PERL_CALLCONV int Perl_yylex_r(pTHX_ YYSTYPE *lvalp, int *lcharp);
#endif
PERL_CALLCONV int Perl_yylex(pTHX);
PERL_CALLCONV int Perl_yyparse(pTHX);
PERL_CALLCONV int Perl_yywarn(pTHX_ char* s);
#if defined(MYMALLOC)
PERL_CALLCONV void Perl_dump_mstats(pTHX_ char* s);
PERL_CALLCONV int Perl_get_mstats(pTHX_ perl_mstats_t *buf, int buflen, int level);
#endif
PERL_CALLCONV Malloc_t Perl_safesysmalloc(MEM_SIZE nbytes);
PERL_CALLCONV Malloc_t Perl_safesyscalloc(MEM_SIZE elements, MEM_SIZE size);
PERL_CALLCONV Malloc_t Perl_safesysrealloc(Malloc_t where, MEM_SIZE nbytes);
PERL_CALLCONV Free_t Perl_safesysfree(Malloc_t where);
#if defined(PERL_GLOBAL_STRUCT)
PERL_CALLCONV struct perl_vars * Perl_GetVars(pTHX);
#endif
PERL_CALLCONV int Perl_runops_standard(pTHX);
PERL_CALLCONV int Perl_runops_debug(pTHX);
#if defined(USE_5005THREADS)
PERL_CALLCONV SV* Perl_sv_lock(pTHX_ SV *sv);
#endif
PERL_CALLCONV void Perl_sv_catpvf_mg(pTHX_ SV *sv, const char* pat, ...)
__attribute__format__(__printf__,pTHX_2,pTHX_3);
PERL_CALLCONV void Perl_sv_vcatpvf_mg(pTHX_ SV* sv, const char* pat, va_list* args);
PERL_CALLCONV void Perl_sv_catpv_mg(pTHX_ SV *sv, const char *ptr);
PERL_CALLCONV void Perl_sv_catpvn_mg(pTHX_ SV *sv, const char *ptr, STRLEN len);
PERL_CALLCONV void Perl_sv_catsv_mg(pTHX_ SV *dstr, SV *sstr);
PERL_CALLCONV void Perl_sv_setpvf_mg(pTHX_ SV *sv, const char* pat, ...)
__attribute__format__(__printf__,pTHX_2,pTHX_3);
PERL_CALLCONV void Perl_sv_vsetpvf_mg(pTHX_ SV* sv, const char* pat, va_list* args);
PERL_CALLCONV void Perl_sv_setiv_mg(pTHX_ SV *sv, IV i);
PERL_CALLCONV void Perl_sv_setpviv_mg(pTHX_ SV *sv, IV iv);
PERL_CALLCONV void Perl_sv_setuv_mg(pTHX_ SV *sv, UV u);
PERL_CALLCONV void Perl_sv_setnv_mg(pTHX_ SV *sv, NV num);
PERL_CALLCONV void Perl_sv_setpv_mg(pTHX_ SV *sv, const char *ptr);
PERL_CALLCONV void Perl_sv_setpvn_mg(pTHX_ SV *sv, const char *ptr, STRLEN len);
PERL_CALLCONV void Perl_sv_setsv_mg(pTHX_ SV *dstr, SV *sstr);
PERL_CALLCONV void Perl_sv_usepvn_mg(pTHX_ SV *sv, char *ptr, STRLEN len);
PERL_CALLCONV MGVTBL* Perl_get_vtbl(pTHX_ int vtbl_id);
PERL_CALLCONV char* Perl_pv_display(pTHX_ SV *dsv, char *pv, STRLEN cur, STRLEN len, STRLEN pvlim);
PERL_CALLCONV void Perl_dump_indent(pTHX_ I32 level, PerlIO *file, const char* pat, ...)
__attribute__format__(__printf__,pTHX_3,pTHX_4);
PERL_CALLCONV void Perl_dump_vindent(pTHX_ I32 level, PerlIO *file, const char* pat, va_list *args);
PERL_CALLCONV void Perl_do_gv_dump(pTHX_ I32 level, PerlIO *file, char *name, GV *sv);
PERL_CALLCONV void Perl_do_gvgv_dump(pTHX_ I32 level, PerlIO *file, char *name, GV *sv);
PERL_CALLCONV void Perl_do_hv_dump(pTHX_ I32 level, PerlIO *file, char *name, HV *sv);
PERL_CALLCONV void Perl_do_magic_dump(pTHX_ I32 level, PerlIO *file, MAGIC *mg, I32 nest, I32 maxnest, bool dumpops, STRLEN pvlim);
PERL_CALLCONV void Perl_do_op_dump(pTHX_ I32 level, PerlIO *file, OP *o);
PERL_CALLCONV void Perl_do_pmop_dump(pTHX_ I32 level, PerlIO *file, PMOP *pm);
PERL_CALLCONV void Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bool dumpops, STRLEN pvlim);
PERL_CALLCONV void Perl_magic_dump(pTHX_ MAGIC *mg);
#if defined(PERL_FLEXIBLE_EXCEPTIONS)
PERL_CALLCONV void* Perl_default_protect(pTHX_ volatile JMPENV *je, int *excpt, protect_body_t body, ...);
PERL_CALLCONV void* Perl_vdefault_protect(pTHX_ volatile JMPENV *je, int *excpt, protect_body_t body, va_list *args);
#endif
PERL_CALLCONV void Perl_reginitcolors(pTHX);
PERL_CALLCONV char* Perl_sv_2pv_nolen(pTHX_ SV* sv);
PERL_CALLCONV char* Perl_sv_2pvutf8_nolen(pTHX_ SV* sv);
PERL_CALLCONV char* Perl_sv_2pvbyte_nolen(pTHX_ SV* sv);
/* PERL_CALLCONV char* sv_pv(pTHX_ SV *sv); */
/* PERL_CALLCONV char* sv_pvutf8(pTHX_ SV *sv); */
/* PERL_CALLCONV char* sv_pvbyte(pTHX_ SV *sv); */
/* PERL_CALLCONV STRLEN sv_utf8_upgrade(pTHX_ SV *sv); */
PERL_CALLCONV bool Perl_sv_utf8_downgrade(pTHX_ SV *sv, bool fail_ok);
PERL_CALLCONV void Perl_sv_utf8_encode(pTHX_ SV *sv);
PERL_CALLCONV bool Perl_sv_utf8_decode(pTHX_ SV *sv);
PERL_CALLCONV void Perl_sv_force_normal(pTHX_ SV *sv);
PERL_CALLCONV void Perl_sv_force_normal_flags(pTHX_ SV *sv, U32 flags);
PERL_CALLCONV void Perl_tmps_grow(pTHX_ I32 n);
PERL_CALLCONV SV* Perl_sv_rvweaken(pTHX_ SV *sv);
PERL_CALLCONV int Perl_magic_killbackrefs(pTHX_ SV *sv, MAGIC *mg);
PERL_CALLCONV OP* Perl_newANONATTRSUB(pTHX_ I32 floor, OP *proto, OP *attrs, OP *block);
PERL_CALLCONV CV* Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block);
PERL_CALLCONV void Perl_newMYSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block);
PERL_CALLCONV OP * Perl_my_attrs(pTHX_ OP *o, OP *attrs);
PERL_CALLCONV void Perl_boot_core_xsutils(pTHX);
#if defined(USE_ITHREADS)
PERL_CALLCONV PERL_CONTEXT* Perl_cx_dup(pTHX_ PERL_CONTEXT* cx, I32 ix, I32 max, CLONE_PARAMS* param);
PERL_CALLCONV PERL_SI* Perl_si_dup(pTHX_ PERL_SI* si, CLONE_PARAMS* param);
PERL_CALLCONV ANY* Perl_ss_dup(pTHX_ PerlInterpreter* proto_perl, CLONE_PARAMS* param);
PERL_CALLCONV void* Perl_any_dup(pTHX_ void* v, PerlInterpreter* proto_perl);
PERL_CALLCONV HE* Perl_he_dup(pTHX_ HE* e, bool shared, CLONE_PARAMS* param);
PERL_CALLCONV REGEXP* Perl_re_dup(pTHX_ REGEXP* r, CLONE_PARAMS* param);
PERL_CALLCONV PerlIO* Perl_fp_dup(pTHX_ PerlIO* fp, char type, CLONE_PARAMS* param);
PERL_CALLCONV DIR* Perl_dirp_dup(pTHX_ DIR* dp);
PERL_CALLCONV GP* Perl_gp_dup(pTHX_ GP* gp, CLONE_PARAMS* param);
PERL_CALLCONV MAGIC* Perl_mg_dup(pTHX_ MAGIC* mg, CLONE_PARAMS* param);
PERL_CALLCONV SV* Perl_sv_dup(pTHX_ SV* sstr, CLONE_PARAMS* param);
#if defined(HAVE_INTERP_INTERN)
PERL_CALLCONV void Perl_sys_intern_dup(pTHX_ struct interp_intern* src, struct interp_intern* dst);
#endif
PERL_CALLCONV PTR_TBL_t* Perl_ptr_table_new(pTHX);
PERL_CALLCONV void* Perl_ptr_table_fetch(pTHX_ PTR_TBL_t *tbl, void *sv);
PERL_CALLCONV void Perl_ptr_table_store(pTHX_ PTR_TBL_t *tbl, void *oldsv, void *newsv);
PERL_CALLCONV void Perl_ptr_table_split(pTHX_ PTR_TBL_t *tbl);
PERL_CALLCONV void Perl_ptr_table_clear(pTHX_ PTR_TBL_t *tbl);
PERL_CALLCONV void Perl_ptr_table_free(pTHX_ PTR_TBL_t *tbl);
#endif
#if defined(HAVE_INTERP_INTERN)
PERL_CALLCONV void Perl_sys_intern_clear(pTHX);
PERL_CALLCONV void Perl_sys_intern_init(pTHX);
#endif
PERL_CALLCONV char * Perl_custom_op_name(pTHX_ OP* op);
PERL_CALLCONV char * Perl_custom_op_desc(pTHX_ OP* op);
PERL_CALLCONV void Perl_sv_nosharing(pTHX_ SV *);
PERL_CALLCONV void Perl_sv_nolocking(pTHX_ SV *);
PERL_CALLCONV void Perl_sv_nounlocking(pTHX_ SV *);
PERL_CALLCONV int Perl_nothreadhook(pTHX);
END_EXTERN_C
#if defined(PERL_IN_AV_C) || defined(PERL_DECL_PROT)
STATIC I32 S_avhv_index_sv(pTHX_ SV* sv);
STATIC I32 S_avhv_index(pTHX_ AV* av, SV* sv, U32 hash);
#endif
#if defined(PERL_IN_DOOP_C) || defined(PERL_DECL_PROT)
STATIC I32 S_do_trans_simple(pTHX_ SV *sv);
STATIC I32 S_do_trans_count(pTHX_ SV *sv);
STATIC I32 S_do_trans_complex(pTHX_ SV *sv);
STATIC I32 S_do_trans_simple_utf8(pTHX_ SV *sv);
STATIC I32 S_do_trans_count_utf8(pTHX_ SV *sv);
STATIC I32 S_do_trans_complex_utf8(pTHX_ SV *sv);
#endif
#if defined(PERL_IN_GV_C) || defined(PERL_DECL_PROT)
STATIC void S_gv_init_sv(pTHX_ GV *gv, I32 sv_type);
STATIC void S_require_errno(pTHX_ GV *gv);
#endif
#if defined(PERL_IN_HV_C) || defined(PERL_DECL_PROT)
STATIC void S_hsplit(pTHX_ HV *hv);
STATIC void S_hfreeentries(pTHX_ HV *hv);
STATIC void S_more_he(pTHX);
STATIC HE* S_new_he(pTHX);
STATIC void S_del_he(pTHX_ HE *p);
STATIC HEK* S_save_hek_flags(pTHX_ const char *str, I32 len, U32 hash, int flags);
STATIC void S_hv_magic_check(pTHX_ HV *hv, bool *needs_copy, bool *needs_store);
STATIC void S_unshare_hek_or_pvn(pTHX_ HEK* hek, const char* sv, I32 len, U32 hash);
STATIC HEK* S_share_hek_flags(pTHX_ const char* sv, I32 len, U32 hash, int flags);
STATIC void S_hv_notallowed(pTHX_ int flags, const char *key, I32 klen, const char *msg);
#endif
#if defined(PERL_IN_MG_C) || defined(PERL_DECL_PROT)
STATIC void S_save_magic(pTHX_ I32 mgs_ix, SV *sv);
STATIC int S_magic_methpack(pTHX_ SV *sv, MAGIC *mg, char *meth);
STATIC int S_magic_methcall(pTHX_ SV *sv, MAGIC *mg, char *meth, I32 f, int n, SV *val);
#endif
#if defined(PERL_IN_OP_C) || defined(PERL_DECL_PROT)
STATIC I32 S_list_assignment(pTHX_ OP *o);
STATIC void S_bad_type(pTHX_ I32 n, char *t, char *name, OP *kid);
STATIC void S_cop_free(pTHX_ COP *cop);
STATIC OP* S_modkids(pTHX_ OP *o, I32 type);
STATIC void S_no_bareword_allowed(pTHX_ OP *o);
STATIC OP* S_no_fh_allowed(pTHX_ OP *o);
STATIC OP* S_scalarboolean(pTHX_ OP *o);
STATIC OP* S_too_few_arguments(pTHX_ OP *o, char* name);
STATIC OP* S_too_many_arguments(pTHX_ OP *o, char* name);
STATIC OP* S_newDEFSVOP(pTHX);
STATIC OP* S_new_logop(pTHX_ I32 type, I32 flags, OP **firstp, OP **otherp);
STATIC void S_simplify_sort(pTHX_ OP *o);
STATIC bool S_is_handle_constructor(pTHX_ OP *o, I32 argnum);
STATIC char* S_gv_ename(pTHX_ GV *gv);
STATIC bool S_scalar_mod_type(pTHX_ OP *o, I32 type);
STATIC OP * S_my_kid(pTHX_ OP *o, OP *attrs, OP **imopsp);
STATIC OP * S_dup_attrlist(pTHX_ OP *o);
STATIC void S_apply_attrs(pTHX_ HV *stash, SV *target, OP *attrs, bool for_my);
STATIC void S_apply_attrs_my(pTHX_ HV *stash, OP *target, OP *attrs, OP **imopsp);
#endif
#if defined(PL_OP_SLAB_ALLOC)
PERL_CALLCONV void* Perl_Slab_Alloc(pTHX_ int m, size_t sz);
PERL_CALLCONV void Perl_Slab_Free(pTHX_ void *op);
#endif
#if defined(PERL_IN_PERL_C) || defined(PERL_DECL_PROT)
STATIC void S_find_beginning(pTHX);
STATIC void S_forbid_setid(pTHX_ char *);
STATIC void S_incpush(pTHX_ char *, int, int, int);
STATIC void S_init_interp(pTHX);
STATIC void S_init_ids(pTHX);
STATIC void S_init_lexer(pTHX);
STATIC void S_init_main_stash(pTHX);
STATIC void S_init_perllib(pTHX);
STATIC void S_init_postdump_symbols(pTHX_ int, char **, char **);
STATIC void S_init_predump_symbols(pTHX);
STATIC void S_my_exit_jump(pTHX) __attribute__((noreturn));
STATIC void S_nuke_stacks(pTHX);
STATIC void S_open_script(pTHX_ char *, bool, SV *);
STATIC void S_usage(pTHX_ char *);
STATIC void S_validate_suid(pTHX_ char *, char*);
# if defined(IAMSUID)
STATIC int S_fd_on_nosuid_fs(pTHX_ int fd);
# endif
STATIC void* S_parse_body(pTHX_ char **env, XSINIT_t xsinit);
STATIC void* S_run_body(pTHX_ I32 oldscope);
STATIC void S_call_body(pTHX_ OP *myop, int is_eval);
STATIC void* S_call_list_body(pTHX_ CV *cv);
#if defined(PERL_FLEXIBLE_EXCEPTIONS)
STATIC void* S_vparse_body(pTHX_ va_list args);
STATIC void* S_vrun_body(pTHX_ va_list args);
STATIC void* S_vcall_body(pTHX_ va_list args);
STATIC void* S_vcall_list_body(pTHX_ va_list args);
#endif
# if defined(USE_5005THREADS)
STATIC struct perl_thread * S_init_main_thread(pTHX);
# endif
#endif
#if defined(PERL_IN_PP_C) || defined(PERL_DECL_PROT)
STATIC SV* S_refto(pTHX_ SV* sv);
#endif
#if defined(PERL_IN_PP_PACK_C) || defined(PERL_DECL_PROT)
STATIC I32 S_unpack_rec(pTHX_ tempsym_t* symptr, char *s, char *strbeg, char *strend, char **new_s);
STATIC SV ** S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist);
STATIC SV* S_mul128(pTHX_ SV *sv, U8 m);
STATIC I32 S_measure_struct(pTHX_ tempsym_t* symptr);
STATIC char * S_group_end(pTHX_ char *pat, char *patend, char ender);
STATIC char * S_get_num(pTHX_ char *ppat, I32 *);
STATIC bool S_next_symbol(pTHX_ tempsym_t* symptr);
STATIC void S_doencodes(pTHX_ SV* sv, char* s, I32 len);
STATIC SV* S_is_an_int(pTHX_ char *s, STRLEN l);
STATIC int S_div128(pTHX_ SV *pnum, bool *done);
#endif
#if defined(PERL_IN_PP_CTL_C) || defined(PERL_DECL_PROT)
STATIC OP* S_docatch(pTHX_ OP *o);
STATIC void* S_docatch_body(pTHX);
#if defined(PERL_FLEXIBLE_EXCEPTIONS)
STATIC void* S_vdocatch_body(pTHX_ va_list args);
#endif
STATIC OP* S_dofindlabel(pTHX_ OP *o, char *label, OP **opstack, OP **oplimit);
STATIC OP* S_doparseform(pTHX_ SV *sv);
STATIC bool S_num_overflow(NV value, I32 fldsize, I32 frcsize);
STATIC I32 S_dopoptoeval(pTHX_ I32 startingblock);
STATIC I32 S_dopoptolabel(pTHX_ char *label);
STATIC I32 S_dopoptoloop(pTHX_ I32 startingblock);
STATIC I32 S_dopoptosub(pTHX_ I32 startingblock);
STATIC I32 S_dopoptosub_at(pTHX_ PERL_CONTEXT* cxstk, I32 startingblock);
STATIC void S_save_lines(pTHX_ AV *array, SV *sv);
STATIC OP* S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq);
STATIC PerlIO * S_doopen_pm(pTHX_ const char *name, const char *mode);
STATIC bool S_path_is_absolute(pTHX_ char *name);
#endif
#if defined(PERL_IN_PP_HOT_C) || defined(PERL_DECL_PROT)
STATIC int S_do_maybe_phash(pTHX_ AV *ary, SV **lelem, SV **firstlelem, SV **relem, SV **lastrelem);
STATIC void S_do_oddball(pTHX_ HV *hash, SV **relem, SV **firstrelem);
STATIC CV* S_get_db_sub(pTHX_ SV **svp, CV *cv);
STATIC SV* S_method_common(pTHX_ SV* meth, U32* hashp);
#endif
#if defined(PERL_IN_PP_SYS_C) || defined(PERL_DECL_PROT)
STATIC OP* S_doform(pTHX_ CV *cv, GV *gv, OP *retop);
STATIC int S_emulate_eaccess(pTHX_ const char* path, Mode_t mode);
# if !defined(HAS_MKDIR) || !defined(HAS_RMDIR)
STATIC int S_dooneliner(pTHX_ char *cmd, char *filename);
# endif
#endif
#if defined(PERL_IN_REGCOMP_C) || defined(PERL_DECL_PROT)
STATIC regnode* S_reg(pTHX_ struct RExC_state_t*, I32, I32 *);
STATIC regnode* S_reganode(pTHX_ struct RExC_state_t*, U8, U32);
STATIC regnode* S_regatom(pTHX_ struct RExC_state_t*, I32 *);
STATIC regnode* S_regbranch(pTHX_ struct RExC_state_t*, I32 *, I32);
STATIC void S_reguni(pTHX_ struct RExC_state_t*, UV, char *, STRLEN*);
STATIC regnode* S_regclass(pTHX_ struct RExC_state_t*);
STATIC I32 S_regcurly(pTHX_ char *);
STATIC regnode* S_reg_node(pTHX_ struct RExC_state_t*, U8);
STATIC regnode* S_regpiece(pTHX_ struct RExC_state_t*, I32 *);
STATIC void S_reginsert(pTHX_ struct RExC_state_t*, U8, regnode *);
STATIC void S_regoptail(pTHX_ struct RExC_state_t*, regnode *, regnode *);
STATIC void S_regtail(pTHX_ struct RExC_state_t*, regnode *, regnode *);
STATIC char* S_regwhite(pTHX_ char *, char *);
STATIC char* S_nextchar(pTHX_ struct RExC_state_t*);
# ifdef DEBUGGING
STATIC regnode* S_dumpuntil(pTHX_ regnode *start, regnode *node, regnode *last, SV* sv, I32 l);
STATIC void S_put_byte(pTHX_ SV* sv, int c);
# endif
STATIC void S_scan_commit(pTHX_ struct RExC_state_t*, struct scan_data_t *data);
STATIC void S_cl_anything(pTHX_ struct RExC_state_t*, struct regnode_charclass_class *cl);
STATIC int S_cl_is_anything(pTHX_ struct regnode_charclass_class *cl);
STATIC void S_cl_init(pTHX_ struct RExC_state_t*, struct regnode_charclass_class *cl);
STATIC void S_cl_init_zero(pTHX_ struct RExC_state_t*, struct regnode_charclass_class *cl);
STATIC void S_cl_and(pTHX_ struct regnode_charclass_class *cl, struct regnode_charclass_class *and_with);
STATIC void S_cl_or(pTHX_ struct RExC_state_t*, struct regnode_charclass_class *cl, struct regnode_charclass_class *or_with);
STATIC I32 S_study_chunk(pTHX_ struct RExC_state_t*, regnode **scanp, I32 *deltap, regnode *last, struct scan_data_t *data, U32 flags);
STATIC I32 S_add_data(pTHX_ struct RExC_state_t*, I32 n, char *s);
STATIC void S_re_croak2(pTHX_ const char* pat1, const char* pat2, ...) __attribute__((noreturn));
STATIC I32 S_regpposixcc(pTHX_ struct RExC_state_t*, I32 value);
STATIC void S_checkposixcc(pTHX_ struct RExC_state_t*);
#endif
#if defined(PERL_IN_REGEXEC_C) || defined(PERL_DECL_PROT)
STATIC I32 S_regmatch(pTHX_ regnode *prog);
STATIC I32 S_regrepeat(pTHX_ regnode *p, I32 max);
STATIC I32 S_regrepeat_hard(pTHX_ regnode *p, I32 max, I32 *lp);
STATIC I32 S_regtry(pTHX_ regexp *prog, char *startpos);
STATIC bool S_reginclass(pTHX_ regnode *n, U8 *p, STRLEN *lenp, bool do_utf8sv_is_utf8);
STATIC CHECKPOINT S_regcppush(pTHX_ I32 parenfloor);
STATIC char* S_regcppop(pTHX);
STATIC char* S_regcp_set_to(pTHX_ I32 ss);
STATIC void S_cache_re(pTHX_ regexp *prog);
STATIC U8* S_reghop(pTHX_ U8 *pos, I32 off);
STATIC U8* S_reghop3(pTHX_ U8 *pos, I32 off, U8 *lim);
STATIC U8* S_reghopmaybe(pTHX_ U8 *pos, I32 off);
STATIC U8* S_reghopmaybe3(pTHX_ U8 *pos, I32 off, U8 *lim);
STATIC char* S_find_byclass(pTHX_ regexp * prog, regnode *c, char *s, char *strend, char *startpos, I32 norun);
STATIC void S_to_utf8_substr(pTHX_ regexp * prog);
STATIC void S_to_byte_substr(pTHX_ regexp * prog);
#endif
#if defined(PERL_IN_DUMP_C) || defined(PERL_DECL_PROT)
STATIC CV* S_deb_curcv(pTHX_ I32 ix);
STATIC void S_debprof(pTHX_ OP *o);
#endif
#if defined(PERL_IN_SCOPE_C) || defined(PERL_DECL_PROT)
STATIC SV* S_save_scalar_at(pTHX_ SV **sptr);
#endif
#if defined(PERL_IN_SV_C) || defined(PERL_DECL_PROT)
STATIC IV S_asIV(pTHX_ SV* sv);
STATIC UV S_asUV(pTHX_ SV* sv);
STATIC SV* S_more_sv(pTHX);
STATIC void S_more_xiv(pTHX);
STATIC void S_more_xnv(pTHX);
STATIC void S_more_xpv(pTHX);
STATIC void S_more_xpviv(pTHX);
STATIC void S_more_xpvnv(pTHX);
STATIC void S_more_xpvcv(pTHX);
STATIC void S_more_xpvav(pTHX);
STATIC void S_more_xpvhv(pTHX);
STATIC void S_more_xpvmg(pTHX);
STATIC void S_more_xpvlv(pTHX);
STATIC void S_more_xpvbm(pTHX);
STATIC void S_more_xrv(pTHX);
STATIC XPVIV* S_new_xiv(pTHX);
STATIC XPVNV* S_new_xnv(pTHX);
STATIC XPV* S_new_xpv(pTHX);
STATIC XPVIV* S_new_xpviv(pTHX);
STATIC XPVNV* S_new_xpvnv(pTHX);
STATIC XPVCV* S_new_xpvcv(pTHX);
STATIC XPVAV* S_new_xpvav(pTHX);
STATIC XPVHV* S_new_xpvhv(pTHX);
STATIC XPVMG* S_new_xpvmg(pTHX);
STATIC XPVLV* S_new_xpvlv(pTHX);
STATIC XPVBM* S_new_xpvbm(pTHX);
STATIC XRV* S_new_xrv(pTHX);
STATIC void S_del_xiv(pTHX_ XPVIV* p);
STATIC void S_del_xnv(pTHX_ XPVNV* p);
STATIC void S_del_xpv(pTHX_ XPV* p);
STATIC void S_del_xpviv(pTHX_ XPVIV* p);
STATIC void S_del_xpvnv(pTHX_ XPVNV* p);
STATIC void S_del_xpvcv(pTHX_ XPVCV* p);
STATIC void S_del_xpvav(pTHX_ XPVAV* p);
STATIC void S_del_xpvhv(pTHX_ XPVHV* p);
STATIC void S_del_xpvmg(pTHX_ XPVMG* p);
STATIC void S_del_xpvlv(pTHX_ XPVLV* p);
STATIC void S_del_xpvbm(pTHX_ XPVBM* p);
STATIC void S_del_xrv(pTHX_ XRV* p);
STATIC void S_sv_unglob(pTHX_ SV* sv);
STATIC void S_not_a_number(pTHX_ SV *sv);
STATIC I32 S_visit(pTHX_ SVFUNC_t f);
STATIC void S_sv_add_backref(pTHX_ SV *tsv, SV *sv);
STATIC void S_sv_del_backref(pTHX_ SV *sv);
# ifdef DEBUGGING
STATIC void S_del_sv(pTHX_ SV *p);
# endif
# if !defined(NV_PRESERVES_UV)
STATIC int S_sv_2iuv_non_preserve(pTHX_ SV *sv, I32 numtype);
# endif
STATIC I32 S_expect_number(pTHX_ char** pattern);
#
# if defined(USE_ITHREADS)
STATIC SV* S_gv_share(pTHX_ SV *sv, CLONE_PARAMS *param);
# endif
STATIC bool S_utf8_mg_pos(pTHX_ SV *sv, MAGIC **mgp, STRLEN **cachep, I32 i, I32 *offsetp, I32 uoff, U8 **sp, U8 *start, U8 *send);
STATIC bool S_utf8_mg_pos_init(pTHX_ SV *sv, MAGIC **mgp, STRLEN **cachep, I32 i, I32 *offsetp, U8 *s, U8 *start);
#endif
#if defined(PERL_IN_TOKE_C) || defined(PERL_DECL_PROT)
STATIC void S_check_uni(pTHX);
STATIC void S_force_next(pTHX_ I32 type);
STATIC char* S_force_version(pTHX_ char *start, int guessing);
STATIC char* S_force_word(pTHX_ char *start, int token, int check_keyword, int allow_pack, int allow_tick);
STATIC SV* S_tokeq(pTHX_ SV *sv);
STATIC int S_pending_ident(pTHX);
STATIC char* S_scan_const(pTHX_ char *start);
STATIC char* S_scan_formline(pTHX_ char *s);
STATIC char* S_scan_heredoc(pTHX_ char *s);
STATIC char* S_scan_ident(pTHX_ char *s, char *send, char *dest, STRLEN destlen, I32 ck_uni);
STATIC char* S_scan_inputsymbol(pTHX_ char *start);
STATIC char* S_scan_pat(pTHX_ char *start, I32 type);
STATIC char* S_scan_str(pTHX_ char *start, int keep_quoted, int keep_delims);
STATIC char* S_scan_subst(pTHX_ char *start);
STATIC char* S_scan_trans(pTHX_ char *start);
STATIC char* S_scan_word(pTHX_ char *s, char *dest, STRLEN destlen, int allow_package, STRLEN *slp);
STATIC char* S_skipspace(pTHX_ char *s);
STATIC char* S_swallow_bom(pTHX_ U8 *s);
STATIC void S_checkcomma(pTHX_ char *s, char *name, char *what);
STATIC void S_force_ident(pTHX_ char *s, int kind);
STATIC void S_incline(pTHX_ char *s);
STATIC int S_intuit_method(pTHX_ char *s, GV *gv);
STATIC int S_intuit_more(pTHX_ char *s);
STATIC I32 S_lop(pTHX_ I32 f, int x, char *s);
STATIC void S_missingterm(pTHX_ char *s);
STATIC void S_no_op(pTHX_ char *what, char *s);
STATIC void S_set_csh(pTHX);
STATIC I32 S_sublex_done(pTHX);
STATIC I32 S_sublex_push(pTHX);
STATIC I32 S_sublex_start(pTHX);
STATIC char * S_filter_gets(pTHX_ SV *sv, PerlIO *fp, STRLEN append);
STATIC HV * S_find_in_my_stash(pTHX_ char *pkgname, I32 len);
STATIC SV* S_new_constant(pTHX_ char *s, STRLEN len, const char *key, SV *sv, SV *pv, const char *type);
# if defined(DEBUGGING)
STATIC void S_tokereport(pTHX_ char *thing, char *s, I32 rv);
# endif
STATIC int S_ao(pTHX_ int toketype);
STATIC void S_depcom(pTHX);
STATIC char* S_incl_perldb(pTHX);
#if 0
STATIC I32 S_utf16_textfilter(pTHX_ int idx, SV *sv, int maxlen);
STATIC I32 S_utf16rev_textfilter(pTHX_ int idx, SV *sv, int maxlen);
#endif
# if defined(PERL_CR_FILTER)
STATIC I32 S_cr_textfilter(pTHX_ int idx, SV *sv, int maxlen);
# endif
#endif
#if defined(PERL_IN_UNIVERSAL_C) || defined(PERL_DECL_PROT)
STATIC SV* S_isa_lookup(pTHX_ HV *stash, const char *name, HV *name_stash, int len, int level);
#endif
#if defined(PERL_IN_LOCALE_C) || defined(PERL_DECL_PROT)
STATIC char* S_stdize_locale(pTHX_ char* locs);
#endif
#if defined(PERL_IN_UTIL_C) || defined(PERL_DECL_PROT)
STATIC COP* S_closest_cop(pTHX_ COP *cop, OP *o);
STATIC SV* S_mess_alloc(pTHX);
#endif
#if defined(PERL_IN_NUMERIC_C) || defined(PERL_DECL_PROT)
STATIC NV S_mulexp10(NV value, I32 exponent);
#endif
START_EXTERN_C
PERL_CALLCONV void Perl_sv_setsv_flags(pTHX_ SV* dsv, SV* ssv, I32 flags);
PERL_CALLCONV void Perl_sv_catpvn_flags(pTHX_ SV* sv, const char* ptr, STRLEN len, I32 flags);
PERL_CALLCONV void Perl_sv_catsv_flags(pTHX_ SV* dsv, SV* ssv, I32 flags);
PERL_CALLCONV STRLEN Perl_sv_utf8_upgrade_flags(pTHX_ SV *sv, I32 flags);
PERL_CALLCONV char* Perl_sv_pvn_force_flags(pTHX_ SV* sv, STRLEN* lp, I32 flags);
PERL_CALLCONV char* Perl_sv_2pv_flags(pTHX_ SV* sv, STRLEN* lp, I32 flags);
PERL_CALLCONV void Perl_sv_copypv(pTHX_ SV* dsv, SV* ssv);
PERL_CALLCONV char* Perl_my_atof2(pTHX_ const char *s, NV* value);
PERL_CALLCONV int Perl_my_socketpair(int family, int type, int protocol, int fd[2]);
#if defined(USE_PERLIO) && !defined(USE_SFIO)
PERL_CALLCONV int Perl_PerlIO_close(pTHX_ PerlIO *);
PERL_CALLCONV int Perl_PerlIO_fill(pTHX_ PerlIO *);
PERL_CALLCONV int Perl_PerlIO_fileno(pTHX_ PerlIO *);
PERL_CALLCONV int Perl_PerlIO_eof(pTHX_ PerlIO *);
PERL_CALLCONV int Perl_PerlIO_error(pTHX_ PerlIO *);
PERL_CALLCONV int Perl_PerlIO_flush(pTHX_ PerlIO *);
PERL_CALLCONV void Perl_PerlIO_clearerr(pTHX_ PerlIO *);
PERL_CALLCONV void Perl_PerlIO_set_cnt(pTHX_ PerlIO *, int);
PERL_CALLCONV void Perl_PerlIO_set_ptrcnt(pTHX_ PerlIO *, STDCHAR *, int);
PERL_CALLCONV void Perl_PerlIO_setlinebuf(pTHX_ PerlIO *);
PERL_CALLCONV SSize_t Perl_PerlIO_read(pTHX_ PerlIO *, void *, Size_t);
PERL_CALLCONV SSize_t Perl_PerlIO_write(pTHX_ PerlIO *, const void *, Size_t);
PERL_CALLCONV SSize_t Perl_PerlIO_unread(pTHX_ PerlIO *, const void *, Size_t);
PERL_CALLCONV Off_t Perl_PerlIO_tell(pTHX_ PerlIO *);
PERL_CALLCONV int Perl_PerlIO_seek(pTHX_ PerlIO *, Off_t, int);
PERL_CALLCONV STDCHAR * Perl_PerlIO_get_base(pTHX_ PerlIO *);
PERL_CALLCONV STDCHAR * Perl_PerlIO_get_ptr(pTHX_ PerlIO *);
PERL_CALLCONV int Perl_PerlIO_get_bufsiz(pTHX_ PerlIO *);
PERL_CALLCONV int Perl_PerlIO_get_cnt(pTHX_ PerlIO *);
PERL_CALLCONV PerlIO * Perl_PerlIO_stdin(pTHX);
PERL_CALLCONV PerlIO * Perl_PerlIO_stdout(pTHX);
PERL_CALLCONV PerlIO * Perl_PerlIO_stderr(pTHX);
#endif /* PERLIO_LAYERS */
PERL_CALLCONV void Perl_deb_stack_all(pTHX);
#ifdef PERL_IN_DEB_C
STATIC void S_deb_stack_n(pTHX_ SV** stack_base, I32 stack_min, I32 stack_max, I32 mark_min, I32 mark_max);
#endif
PERL_CALLCONV PADLIST* Perl_pad_new(pTHX_ int flags);
PERL_CALLCONV void Perl_pad_undef(pTHX_ CV* cv);
PERL_CALLCONV PADOFFSET Perl_pad_add_name(pTHX_ char *name, HV* typestash, HV* ourstash, bool clone);
PERL_CALLCONV PADOFFSET Perl_pad_add_anon(pTHX_ SV* sv, OPCODE op_type);
PERL_CALLCONV void Perl_pad_check_dup(pTHX_ char* name, bool is_our, HV* ourstash);
#ifdef DEBUGGING
PERL_CALLCONV void Perl_pad_setsv(pTHX_ PADOFFSET po, SV* sv);
#endif
PERL_CALLCONV void Perl_pad_block_start(pTHX_ int full);
PERL_CALLCONV void Perl_pad_tidy(pTHX_ padtidy_type type);
PERL_CALLCONV void Perl_do_dump_pad(pTHX_ I32 level, PerlIO *file, PADLIST *padlist, int full);
PERL_CALLCONV void Perl_pad_fixup_inner_anons(pTHX_ PADLIST *padlist, CV *old_cv, CV *new_cv);
PERL_CALLCONV void Perl_pad_push(pTHX_ PADLIST *padlist, int depth, int has_args);
#if defined(PERL_IN_PAD_C) || defined(PERL_DECL_PROT)
STATIC PADOFFSET S_pad_findlex(pTHX_ char* name, PADOFFSET newoff, CV* innercv);
# if defined(DEBUGGING)
STATIC void S_cv_dump(pTHX_ CV *cv, char *title);
# endif
STATIC CV* S_cv_clone2(pTHX_ CV *proto, CV *outside);
#endif
PERL_CALLCONV CV* Perl_find_runcv(pTHX_ U32 *db_seqp);
PERL_CALLCONV void Perl_free_tied_hv_pool(pTHX);
#if defined(DEBUGGING)
PERL_CALLCONV int Perl_get_debug_opts(pTHX_ char **s);
#endif
PERL_CALLCONV void Perl_hv_clear_placeholders(pTHX_ HV* hb);
#if defined(PERL_IN_HV_C) || defined(PERL_DECL_PROT)
STATIC SV* S_hv_delete_common(pTHX_ HV* tb, SV* key_sv, const char* key, STRLEN klen, int k_flags, I32 d_flags, U32 hash);
STATIC HE* S_hv_fetch_common(pTHX_ HV* tb, SV* key_sv, const char* key, STRLEN klen, int flags, int action, SV* val, U32 hash);
#endif
PERL_CALLCONV SV* Perl_hv_scalar(pTHX_ HV* hv);
PERL_CALLCONV SV* Perl_magic_scalarpack(pTHX_ HV* hv, MAGIC* mg);
END_EXTERN_C
| 55.360644 | 273 | 0.776183 |
d97c277b6b1941fa1742b8f290e913fa343712d8 | 1,692 | h | C | TTRabbit/Classes/UIKit/Util/NavigationBar/TTNavigationBar.h | rollingstoneW/TTRabbit | a2318c5ce58049fa76a669ad073ffcafb91743af | [
"MIT"
] | null | null | null | TTRabbit/Classes/UIKit/Util/NavigationBar/TTNavigationBar.h | rollingstoneW/TTRabbit | a2318c5ce58049fa76a669ad073ffcafb91743af | [
"MIT"
] | null | null | null | TTRabbit/Classes/UIKit/Util/NavigationBar/TTNavigationBar.h | rollingstoneW/TTRabbit | a2318c5ce58049fa76a669ad073ffcafb91743af | [
"MIT"
] | null | null | null | //
// TTNavigationBar.h
// TTKit
//
// Created by rollingstoneW on 2018/9/17.
// Copyright © 2018年 TTKit. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSUInteger, TTNavigationBarTitleAlignment) {
TTNavigationBarTitleAlignmentCenter = 0,
TTNavigationBarTitleAlignmentAfterLeftButtons,
};
@interface TTNavigationBar : UIView
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSDictionary *titleAttributes UI_APPEARANCE_SELECTOR; // default is {font:bold-17,color:333333}
@property (nonatomic, strong) UIView *titleView;
@property (nonatomic, assign) TTNavigationBarTitleAlignment titleAlignment;
@property (nonatomic, strong) UIImage *backImage UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong) UIImage *backHighlightedImage UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong, readonly) UIButton *backButton;
@property (nonatomic, assign) BOOL showBackButton; // default is YES
@property (nonatomic, strong) UIImage *backgroundImage;
@property (nonatomic, strong, readonly) UIView *shadowLine; // default is e5e5e5
@property (nonatomic, strong) NSArray<UIButton *> *leftButtons;
@property (nonatomic, strong) NSArray<UIButton *> *rightButtons;
@property (nonatomic, assign) CGFloat horiIndent UI_APPEARANCE_SELECTOR; // default is 15
@property (nonatomic, assign) CGFloat itemSpace UI_APPEARANCE_SELECTOR; // default is 10
@property (nonatomic, assign) BOOL ignoreCurrentUpdateConstraints; // for performance
- (void)addLeftButton:(nonnull UIButton *)item;
- (void)addRightButton:(nonnull UIButton *)item;
- (void)initializer NS_REQUIRES_SUPER; // for override
+ (CGFloat)statusBarHeight;
+ (CGFloat)barHeight;
@end
| 34.530612 | 125 | 0.780733 |
d98067cf1dbb72990c2219bd307219258ad2c4bc | 1,200 | c | C | lista.c | rafael2ll/labirinto | 7b37aedfb47d57afda38f6e01e8e394c88ae2cde | [
"Apache-2.0"
] | null | null | null | lista.c | rafael2ll/labirinto | 7b37aedfb47d57afda38f6e01e8e394c88ae2cde | [
"Apache-2.0"
] | null | null | null | lista.c | rafael2ll/labirinto | 7b37aedfb47d57afda38f6e01e8e394c88ae2cde | [
"Apache-2.0"
] | null | null | null | #include "lista.h"
Lista *makeLista(){
Lista *l = malloc(sizeof(Lista));
l->first = NULL;
l->last = NULL;
return l;
}
void insert(Lista *list, int l ,int c){
DeadEndPath *p = malloc(sizeof(DeadEndPath));
p->l = l;
p->c = c;
p->next = NULL;
if(list->first == NULL){
list->first = p;
}
if(list->last != NULL) list->last->next = p;
list->last = p;
}
int contains(Lista *list, int l, int c){
DeadEndPath *aux = list->first;
while(aux != NULL){
if(aux->c == c && aux->l == l)return 1;
aux = aux->next;
}
return 0;
}
void printList(Lista *list, FILE *f){
int i =0;
DeadEndPath *aux = list->first;
fprintf(f, "::Lista com elementos nao acessaveis::\n");
printf("::Lista com elementos nao acessaveis::\n");
while(aux != NULL){
printf("[%d][%d]\n", aux->l, aux->c);
fprintf(f, "[%d][%d]\t", aux->l, aux->c);
if((++i)%10 == 0)fprintf(f, "\n");
aux = aux->next;
}
}
void destroy(Lista *list){
DeadEndPath *aux = list->first;
DeadEndPath now;
while(aux != NULL){
now = *aux;
free(aux);
aux = now.next;
}
free(list);
} | 22.222222 | 59 | 0.514167 |
d980c5fe0f3d25f0e4439cae55dc9c617ad24d0d | 9,713 | h | C | camera.h | mhammady911/phd2 | b145e88baeca7126b117005736781de40eb65072 | [
"BSD-3-Clause"
] | 201 | 2015-06-25T05:58:54.000Z | 2022-03-18T11:48:04.000Z | camera.h | mhammady911/phd2 | b145e88baeca7126b117005736781de40eb65072 | [
"BSD-3-Clause"
] | 505 | 2015-06-25T04:05:14.000Z | 2022-03-19T20:52:27.000Z | camera.h | mhammady911/phd2 | b145e88baeca7126b117005736781de40eb65072 | [
"BSD-3-Clause"
] | 97 | 2015-06-25T09:00:30.000Z | 2022-03-21T21:30:52.000Z | /*
* camera.h
* PHD Guiding
*
* Created by Craig Stark.
* Copyright (c) 2006-2010 Craig Stark.
* All rights reserved.
*
* This source code is distributed under the following "BSD" license
* 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 Craig Stark, Stark Labs nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef CAMERA_H_INCLUDED
#define CAMERA_H_INCLUDED
typedef std::map<int, usImage *> ExposureImgMap; // map exposure to image
class DefectMap;
enum PropDlgType
{
PROPDLG_NONE = 0,
PROPDLG_WHEN_CONNECTED = (1 << 0), // property dialog available when connected
PROPDLG_WHEN_DISCONNECTED = (1 << 1), // property dialog available when disconnected
PROPDLG_ANY = (PROPDLG_WHEN_CONNECTED | PROPDLG_WHEN_DISCONNECTED),
};
extern wxSize UNDEFINED_FRAME_SIZE;
class GuideCamera;
class CameraConfigDialogPane : public ConfigDialogPane
{
public:
CameraConfigDialogPane(wxWindow *pParent, GuideCamera *pCamera);
virtual ~CameraConfigDialogPane() {};
void LayoutControls(GuideCamera *pCamera, BrainCtrlIdMap& CtrlMap);
virtual void LoadValues() {};
virtual void UnloadValues() {};
};
class CameraConfigDialogCtrlSet : public ConfigDialogCtrlSet
{
GuideCamera *m_pCamera;
wxCheckBox *m_pUseSubframes;
wxSpinCtrl *m_pCameraGain;
wxButton *m_resetGain;
wxSpinCtrl *m_timeoutVal;
wxChoice *m_pPortNum;
wxSpinCtrl *m_pDelay;
wxSpinCtrlDouble *m_pPixelSize;
wxChoice *m_binning;
wxCheckBox *m_coolerOn;
wxSpinCtrl *m_coolerSetpt;
wxTextCtrl *m_camSaturationADU;
wxRadioButton *m_SaturationByProfile;
wxRadioButton *m_SaturationByADU;
int m_prevBinning;
public:
CameraConfigDialogCtrlSet(wxWindow *pParent, GuideCamera *pCamera, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap);
virtual ~CameraConfigDialogCtrlSet() {};
virtual void LoadValues();
virtual void UnloadValues();
double GetPixelSize();
void SetPixelSize(double val);
int GetBinning();
void SetBinning(int val);
void OnSaturationChoiceChanged(wxCommandEvent& event);
};
enum CaptureOptionBits
{
CAPTURE_SUBTRACT_DARK = 1 << 0,
CAPTURE_RECON = 1 << 1, // debayer and/or deinterlace as required
CAPTURE_LIGHT = CAPTURE_SUBTRACT_DARK | CAPTURE_RECON,
CAPTURE_DARK = 0,
CAPTURE_BPM_REVIEW = CAPTURE_SUBTRACT_DARK,
};
class GuideCamera : public wxMessageBoxProxy, public OnboardST4
{
friend class CameraConfigDialogPane;
friend class CameraConfigDialogCtrlSet;
double m_pixelSize;
protected:
bool m_hasGuideOutput;
int m_timeoutMs;
bool m_saturationByADU;
unsigned short m_saturationADU;
public:
static const double UnknownPixelSize;
int GuideCameraGain;
wxString Name; // User-friendly name
wxSize FullSize; // Size of current image
bool Connected;
PropDlgType PropertyDialogType;
bool HasPortNum;
bool HasDelayParam;
bool HasGainControl;
bool HasShutter;
bool HasSubframes;
wxByte MaxBinning;
wxByte Binning;
short Port;
int ReadDelay;
bool ShutterClosed; // false=light, true=dark
bool UseSubframes;
bool HasCooler;
wxCriticalSection DarkFrameLock; // dark frames can be accessed in the main thread or the camera worker thread
usImage *CurrentDarkFrame;
ExposureImgMap Darks; // map exposure => dark frame
DefectMap *CurrentDefectMap;
static wxArrayString GuideCameraList();
static GuideCamera *Factory(const wxString& choice);
GuideCamera();
virtual ~GuideCamera();
virtual bool HasNonGuiCapture() = 0;
virtual wxByte BitsPerPixel() = 0;
static bool Capture(GuideCamera *camera, int duration, usImage& img, int captureOptions, const wxRect& subframe);
static bool Capture(GuideCamera *camera, int duration, usImage& img, int captureOptions) { return Capture(camera, duration, img, captureOptions, wxRect(0, 0, 0, 0)); }
virtual bool CanSelectCamera() const { return false; }
virtual bool HandleSelectCameraButtonClick(wxCommandEvent& evt);
static const wxString DEFAULT_CAMERA_ID;
virtual bool EnumCameras(wxArrayString& names, wxArrayString& ids);
// Opens up and connects to camera. cameraId identifies which camera to connect to if
// there is more than one camera present
virtual bool Connect(const wxString& cameraId) = 0;
virtual bool Disconnect() = 0; // Disconnects, unloading any DLLs loaded by Connect
virtual void InitCapture(); // Gets run at the start of any loop (e.g., reset stream, set gain, etc).
virtual bool ST4HasGuideOutput();
virtual bool ST4HostConnected();
virtual bool ST4HasNonGuiMove();
virtual bool ST4PulseGuideScope(int direction, int duration);
CameraConfigDialogPane *GetConfigDialogPane(wxWindow *pParent);
CameraConfigDialogCtrlSet *GetConfigDlgCtrlSet(wxWindow *pParent, GuideCamera *pCamera, AdvancedDialog *pAdvancedDialog, BrainCtrlIdMap& CtrlMap);
static void GetBinningOpts(int maxBin, wxArrayString *opts);
void GetBinningOpts(wxArrayString *opts);
bool SetBinning(int binning);
virtual void ShowPropertyDialog() { return; }
bool SetCameraPixelSize(double pixel_size);
double GetCameraPixelSize() const;
virtual bool GetDevicePixelSize(double *devPixelSize); // Value from device/driver or error return
virtual bool SetCoolerOn(bool on);
virtual bool SetCoolerSetpoint(double temperature);
virtual bool GetCoolerStatus(bool *on, double *setpoint, double *power, double *temperature);
virtual bool GetSensorTemperature(double *temperature);
virtual wxString GetSettingsSummary();
void AddDark(usImage *dark);
void SelectDark(int exposureDuration);
void SetDefectMap(DefectMap *newMap);
void ClearDefectMap();
void ClearDarks();
void SubtractDark(usImage& img);
void GetDarklibProperties(int *pNumDarks, double *pMinExp, double *pMaxExp);
virtual const wxSize& DarkFrameSize() { return FullSize; }
static double GetProfilePixelSize();
unsigned short GetSaturationADU() const;
bool IsSaturationByADU() const;
void SetSaturationByADU(bool saturationByADU, unsigned short saturationVal);
int GetCameraGain() const;
bool SetCameraGain(int cameraGain);
virtual int GetDefaultCameraGain();
virtual bool Capture(int duration, usImage& img, int captureOptions, const wxRect& subframe) = 0;
protected:
int GetTimeoutMs() const;
void SetTimeoutMs(int timeoutMs);
static bool CamConnectFailed(const wxString& errorMessage);
enum CaptureFailType {
CAPT_FAIL_MEMORY,
CAPT_FAIL_TIMEOUT,
};
enum ReconnectType {
NO_RECONNECT,
RECONNECT,
};
void DisconnectWithAlert(CaptureFailType type);
void DisconnectWithAlert(const wxString& msg, ReconnectType reconnect);
};
inline int GuideCamera::GetTimeoutMs() const
{
return m_timeoutMs;
}
inline void GuideCamera::GetBinningOpts(wxArrayString *opts)
{
GetBinningOpts(MaxBinning, opts);
}
inline double GuideCamera::GetCameraPixelSize() const
{
return m_pixelSize;
}
inline bool GuideCamera::GetDevicePixelSize(double *devPixelSize)
{
return true; // Return an error, the device/driver can't report pixel size
}
inline bool GuideCamera::IsSaturationByADU() const
{
return m_saturationByADU;
}
inline unsigned short GuideCamera::GetSaturationADU() const
{
return m_saturationByADU ? m_saturationADU : 0;
}
inline int GuideCamera::GetCameraGain() const
{
return GuideCameraGain;
}
#endif /* CAMERA_H_INCLUDED */
| 35.974074 | 172 | 0.687326 |
d981be138068b2c7bf0b7ecf36ee5f590814b899 | 1,264 | h | C | app/user/displayio.h | Yanye0xFF/ESP8266-SSD1306 | 28ec8ba4bd06f83693e99b36e590a6085ac2d928 | [
"Apache-2.0"
] | 1 | 2021-06-15T03:25:15.000Z | 2021-06-15T03:25:15.000Z | app/user/displayio.h | Yanye0xFF/ESP8266-SSD1306 | 28ec8ba4bd06f83693e99b36e590a6085ac2d928 | [
"Apache-2.0"
] | null | null | null | app/user/displayio.h | Yanye0xFF/ESP8266-SSD1306 | 28ec8ba4bd06f83693e99b36e590a6085ac2d928 | [
"Apache-2.0"
] | 2 | 2021-06-15T03:25:19.000Z | 2021-06-15T03:25:29.000Z | /*
* FileName: displayio.h
* @brief
* Created on: Jun 1, 2020
* Author: Yanye
*/
#ifndef _DISPLAYIO_H_
#define _DISPLAYIO_H_
#include "ssd1306.h"
/**
* @brief 底层绘制api,调用屏幕驱动
* */
void GuiDrawPixel(uint16_t x, uint16_t y, uint16_t color);
// void GuiFillData(uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t *data);
void GuiFillColor(uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t color);
/**
* @brief 高级图形api
* */
void GuiDrawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t c );
void GuiDrawRect(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t c );
void GuiDrawArc(int16_t x0, int16_t y0, int16_t r, uint8_t s, uint16_t color);
void GuiDrawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t c);
void GuiFillCircle(int16_t x0, int16_t y0, int16_t r, uint16_t c);
void GuiDrawRoundRect(int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t r, uint16_t c);
void GuiFillRoundRect(int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t r, uint16_t c);
void GuiDrawMesh(int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint16_t gridSize, uint16_t c);
//void GuiDrawChar(wchar ch, uint16_t x, uint16_t y, uint16_t foregroundColor, uint16_t backgroundColor, Font *font) ;
#endif
| 34.162162 | 118 | 0.749209 |
d983e16d6419fb5591fc91b18a77b93a92dc6318 | 2,624 | h | C | Sources/Internal/Reflection/Private/ReflectedObject_impl.h | stinvi/dava.engine | 2b396ca49cdf10cdc98ad8a9ffcf7768a05e285e | [
"BSD-3-Clause"
] | 26 | 2018-09-03T08:48:22.000Z | 2022-02-14T05:14:50.000Z | Sources/Internal/Reflection/Private/ReflectedObject_impl.h | ANHELL-blitz/dava.engine | ed83624326f000866e29166c7f4cccfed1bb41d4 | [
"BSD-3-Clause"
] | null | null | null | Sources/Internal/Reflection/Private/ReflectedObject_impl.h | ANHELL-blitz/dava.engine | ed83624326f000866e29166c7f4cccfed1bb41d4 | [
"BSD-3-Clause"
] | 45 | 2018-05-11T06:47:17.000Z | 2022-02-03T11:30:55.000Z | #pragma once
#include "Debug/DVAssert.h"
#ifndef __DAVA_Reflection__
#include "Reflection/Reflection.h"
#include "Reflection/ReflectedObject.h"
#endif
namespace DAVA
{
inline ReflectedObject::ReflectedObject(void* ptr_, const ReflectedType* rtype_)
: ptr(ptr_)
, reflectedType(ReflectedTypeDB::GetByPointer(ptr_, rtype_->GetType()))
{
if (nullptr == reflectedType)
{
reflectedType = rtype_;
}
}
template <typename T>
inline ReflectedObject::ReflectedObject(T* ptr_, bool isConst_)
: ptr(ptr_)
, isConst(isConst_)
, reflectedType(ReflectedTypeDB::GetByPointer(ptr_))
{
}
template <typename T>
inline ReflectedObject::ReflectedObject(const T* ptr_)
: ptr(const_cast<T*>(ptr_))
, reflectedType(ReflectedTypeDB::GetByPointer(ptr_))
, isConst(true)
{
}
inline bool ReflectedObject::operator==(const ReflectedObject& other) const
{
return ptr == other.ptr &&
reflectedType == other.reflectedType &&
isConst == other.isConst;
}
inline bool ReflectedObject::operator!=(const ReflectedObject& other) const
{
return ptr != other.ptr ||
reflectedType != other.reflectedType ||
isConst != other.isConst;
}
inline const ReflectedType* ReflectedObject::GetReflectedType() const
{
return reflectedType;
}
inline bool ReflectedObject::IsValid() const
{
return ((nullptr != ptr) && (nullptr != reflectedType));
}
inline bool ReflectedObject::IsConst() const
{
return isConst;
}
#if 0
// This is performance optimal GetPtr() implementation but it wouldn't
// work for classes with multiple inheritance or with virtual inheritance,
// so we are forced now to use other GetPtr implementation that is making
// appropriate pointer cast
template <typename T>
inline T* ReflectedObject::GetPtr() const
{
DVASSERT(IsValid());
DVASSERT(CanGet<T>());
return static_cast<T*>(ptr);
}
#else
template <typename T>
inline T* ReflectedObject::GetPtr() const // <-- GetPtrWithCast
{
DVASSERT(IsValid());
if (CanGet<T>())
{
return static_cast<T*>(ptr);
}
void* tmp = nullptr;
bool canCast = TypeInheritance::DownCast(reflectedType->GetType(), Type::Instance<T>(), ptr, &tmp);
#ifdef __DAVAENGINE_DEBUG__
DVASSERT(canCast);
#endif
return static_cast<T*>(tmp);
}
#endif
inline void* ReflectedObject::GetVoidPtr() const
{
return ptr;
}
template <typename T>
inline bool ReflectedObject::CanGet() const
{
const Type* reqType = Type::Instance<T>();
const Type* curType = reflectedType->GetType();
return ((reqType == curType) || (reqType->Decay() == curType));
}
} // namespace DAVA
| 21.68595 | 103 | 0.698552 |
d9846be90be09d66811f8288e1f56bee178a21fa | 1,142 | c | C | c/hd44780/7segment.c | mccreery/sandbox | 43e81c7f908feedd8e1b6e28ee07870d02012f4c | [
"Unlicense"
] | 1 | 2020-06-11T21:19:25.000Z | 2020-06-11T21:19:25.000Z | c/hd44780/7segment.c | mccreery/sandbox | 43e81c7f908feedd8e1b6e28ee07870d02012f4c | [
"Unlicense"
] | null | null | null | c/hd44780/7segment.c | mccreery/sandbox | 43e81c7f908feedd8e1b6e28ee07870d02012f4c | [
"Unlicense"
] | 1 | 2020-06-11T21:19:26.000Z | 2020-06-11T21:19:26.000Z | #include <stdint.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include "gpio.h"
const uint8_t *digits = "\xFC\x60\xDA\xF2\x66\xB6\xBE\xE0\xFE\xF6\xEE\x3E\x9C\x7A\x9E\x8E";
#define PIN0 5
void write_data(uint8_t val) {
int i;
for(i = 0; i < 8; i++) {
writep(PIN0 + i, (val >> (7 - i)) & 1);
}
writep(PIN0 + 8, !(val&1));
}
void outputDigit(uint8_t n, uint8_t msb) {
write_data(digits[n] | msb);
}
uint8_t buf[256];
uint16_t current = 0;
uint16_t end = 0;
void push(uint8_t n) {
buf[end >> 8] = n;
end += 256;
}
#define PERIOD (CLOCKS_PER_SEC / 128)
void update() {
static time_t lastTime = 0;
if(lastTime == 0) lastTime = clock();
time_t nextTime;
for(nextTime = clock(); nextTime > lastTime + PERIOD; lastTime += PERIOD) {
//if(current != end) {
if(current & 1) {
outputDigit(buf[current >> 8] >> 4, 1);
} else {
outputDigit(buf[current >> 8] & 0xF, 0);
}
current++;
//}
}
}
int main(int argc, char **argv) {
memset(buf, 0, 256);
int i;
for(i = PIN0; i < PIN0 + 9; i++) {
exportp(i);
directp(i, DIR_OUT);
}
for(i = 0; i < 256; i++) push(i);
while(1) {
update();
}
}
| 18.126984 | 91 | 0.587566 |
d985412e0781efb375c9a0d5bf21b0313f07db34 | 6,455 | h | C | include/datoviz/controls.h | windelbouwman/datoviz | 2a8c54c06185d9ebaa2d5323b9d064b58b60133d | [
"MIT"
] | null | null | null | include/datoviz/controls.h | windelbouwman/datoviz | 2a8c54c06185d9ebaa2d5323b9d064b58b60133d | [
"MIT"
] | null | null | null | include/datoviz/controls.h | windelbouwman/datoviz | 2a8c54c06185d9ebaa2d5323b9d064b58b60133d | [
"MIT"
] | null | null | null | #ifndef DVZ_GUI_HEADER
#define DVZ_GUI_HEADER
// NOTE: we separate between gui.h and controls.h to isolate C++ compilation units from the rest of
// the library
// This file should NOT import gui.h (C++)
#include "canvas.h"
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************************************************/
/* Constants */
/*************************************************************************************************/
#define CONTROL_MAX 32
#define MAX_TEXT_LENGTH 1024
/*************************************************************************************************/
/* Enums */
/*************************************************************************************************/
// GUI creation flags
typedef enum
{
DVZ_GUI_FLAGS_NONE = 0x0000,
DVZ_GUI_FLAGS_FIXED = 0x0001,
DVZ_GUI_FLAGS_CORNER_UL = 0x0010,
DVZ_GUI_FLAGS_CORNER_UR = 0x0020,
DVZ_GUI_FLAGS_CORNER_LR = 0x0040,
DVZ_GUI_FLAGS_CORNER_LL = 0x0030,
} DvzGuiFlags;
// GUI control type
typedef enum
{
DVZ_GUI_CONTROL_NONE,
DVZ_GUI_CONTROL_CHECKBOX,
DVZ_GUI_CONTROL_SLIDER_FLOAT,
DVZ_GUI_CONTROL_SLIDER_INT,
DVZ_GUI_CONTROL_INPUT_FLOAT,
DVZ_GUI_CONTROL_LABEL,
DVZ_GUI_CONTROL_TEXTBOX,
DVZ_GUI_CONTROL_BUTTON,
DVZ_GUI_CONTROL_COLORMAP,
} DvzGuiControlType;
/*************************************************************************************************/
/* Typedefs */
/*************************************************************************************************/
typedef struct DvzGui DvzGui;
typedef struct DvzGuiControl DvzGuiControl;
typedef struct DvzGuiControlSliderFloat DvzGuiControlSliderFloat;
typedef struct DvzGuiControlInputFloat DvzGuiControlInputFloat;
typedef struct DvzGuiControlSliderInt DvzGuiControlSliderInt;
typedef union DvzGuiControlUnion DvzGuiControlUnion;
// typedef struct DvzGuiControlLabel DvzGuiControlLabel;
/*************************************************************************************************/
/* Gui style */
/*************************************************************************************************/
struct DvzGuiControlSliderFloat
{
float vmin;
float vmax;
};
struct DvzGuiControlSliderInt
{
int vmin;
int vmax;
};
struct DvzGuiControlInputFloat
{
float step;
float step_fast;
};
union DvzGuiControlUnion
{
DvzGuiControlSliderFloat sf;
DvzGuiControlSliderInt si;
DvzGuiControlInputFloat f;
// DvzGuiControlLabel l;
};
// struct DvzGuiControlLabel
// {
// };
struct DvzGuiControl
{
DvzGui* gui;
const char* name;
int flags;
void* value;
DvzGuiControlType type;
DvzGuiControlUnion u;
};
struct DvzGui
{
DvzObject obj;
DvzCanvas* canvas;
const char* title;
int flags;
uint32_t control_count;
DvzGuiControl controls[CONTROL_MAX];
bool show_imgui_demo;
};
/*************************************************************************************************/
/* Gui functions */
/*************************************************************************************************/
/**
* Create a new GUI dialog.
*
* @param canvas the canvas
* @param title the GUI title
* @param flags optional flags
* @returns the GUI
*/
DVZ_EXPORT DvzGui* dvz_gui(DvzCanvas* canvas, const char* title, int flags);
/**
* Return the pointer to the control's value.
*
* @param control the GUI
* @returns the pointer to the value
*/
DVZ_EXPORT void* dvz_gui_value(DvzGuiControl* control);
/**
* Add a checkbox control.
*
* @param gui the GUI
* @param name the control label
* @param value whether the checkbox is initially checked
* @returns the control
*/
DVZ_EXPORT DvzGuiControl* dvz_gui_checkbox(DvzGui* gui, const char* name, bool value);
/**
* Add a slider for float number input.
*
* @param gui the GUI
* @param name the control label
* @param vmin the minimum value
* @param vmax the maximum value
* @param value the initial value
* @returns the control
*/
DVZ_EXPORT DvzGuiControl*
dvz_gui_slider_float(DvzGui* gui, const char* name, float vmin, float vmax, float value);
/**
* Add a slider for integer input.
*
* @param gui the GUI
* @param name the control label
* @param vmin the minimum value
* @param vmax the maximum value
* @param value the initial value
* @returns the control
*/
DVZ_EXPORT DvzGuiControl*
dvz_gui_slider_int(DvzGui* gui, const char* name, int vmin, int vmax, int value);
/**
* Add an input float control.
*
* @param gui the GUI
* @param name the control label
* @param step the step
* @param step_fast the step for fast scrolling
* @param value the initial value
* @returns the control
*/
DVZ_EXPORT DvzGuiControl*
dvz_gui_input_float(DvzGui* gui, const char* name, float step, float step_fast, float value);
/**
* Add a static, non-modifiable label.
*
* @param gui the GUI
* @param name the control label
* @param text the control text
* @returns the control
*/
DVZ_EXPORT DvzGuiControl* dvz_gui_label(DvzGui* gui, const char* name, char* text);
/**
* Add a textbox control for text input.
*
* @param gui the GUI
* @param name the control label
* @param value the initial text
* @returns the control
*/
DVZ_EXPORT DvzGuiControl* dvz_gui_textbox(DvzGui* gui, const char* name, char* value);
/**
* Add a button.
*
* @param gui the GUI
* @param name the control label
* @param flags optional flags
* @returns the control
*/
DVZ_EXPORT DvzGuiControl* dvz_gui_button(DvzGui* gui, const char* name, int flags);
/**
* Add a colormap image.
*
* @param gui the GUI
* @param cmap the colormap
* @returns the control
*/
DVZ_EXPORT DvzGuiControl* dvz_gui_colormap(DvzGui* gui, DvzColormap cmap);
/**
* Display the Dear ImGUI demo with all supported controls.
*
* @param gui the GUI
*/
DVZ_EXPORT void dvz_gui_demo(DvzGui* gui);
/**
* Destroy a GUI.
*
* @param gui the GUI
*/
DVZ_EXPORT void dvz_gui_destroy(DvzGui* gui);
#ifdef __cplusplus
}
#endif
#endif
| 23.472727 | 99 | 0.561735 |
d98603c5bd0184568f7c286c100f38bf3a86053c | 592 | c | C | llvm-gcc-4.2-2.9/gcc/testsuite/gcc.dg/tree-ssa/update-threading.c | vidkidz/crossbridge | ba0bf94aee0ce6cf7eb5be882382e52bc57ba396 | [
"MIT"
] | 1 | 2016-04-09T02:58:13.000Z | 2016-04-09T02:58:13.000Z | llvm-gcc-4.2-2.9/gcc/testsuite/gcc.dg/tree-ssa/update-threading.c | vidkidz/crossbridge | ba0bf94aee0ce6cf7eb5be882382e52bc57ba396 | [
"MIT"
] | null | null | null | llvm-gcc-4.2-2.9/gcc/testsuite/gcc.dg/tree-ssa/update-threading.c | vidkidz/crossbridge | ba0bf94aee0ce6cf7eb5be882382e52bc57ba396 | [
"MIT"
] | null | null | null | /* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
/* LLVM LOCAL test not applicable */
/* { dg-require-fdump "" } */
typedef struct { unsigned short a; } A;
extern void abort (void);
extern void exit (int);
void foo (unsigned int x)
{
if (x != 0x800 && x != 0x810)
abort ();
}
int
main (int argc, char **argv)
{
int i;
for (i = 0; i < 2; ++i)
foo (((A) { ((!(i >> 4) ? 8 : 64 + (i >> 4)) << 8) + (i << 4) } ).a);
exit (0);
}
/* { dg-final { scan-tree-dump-times "Invalid sum" 0 "optimized"} } */
/* { dg-final { cleanup-tree-dump "optimized" } } */
| 21.925926 | 73 | 0.525338 |
d98743c9f2c6b15f7a75a43752fd955a58157d87 | 626 | c | C | SGIPC practice contests/sgip.c contst 2/Credit checktst.c | YaminArafat/Vjudge | d8d2afc4b1a0fbada46d75cb080efc37965dfe9d | [
"Apache-2.0"
] | null | null | null | SGIPC practice contests/sgip.c contst 2/Credit checktst.c | YaminArafat/Vjudge | d8d2afc4b1a0fbada46d75cb080efc37965dfe9d | [
"Apache-2.0"
] | null | null | null | SGIPC practice contests/sgip.c contst 2/Credit checktst.c | YaminArafat/Vjudge | d8d2afc4b1a0fbada46d75cb080efc37965dfe9d | [
"Apache-2.0"
] | null | null | null | #include <stdio.h>
int main()
{
char ch[25];
int sum_doubled, sum_undoubled, i, j, digit, test_case;
scanf("%d", &test_case);
getchar();
for (j=0; j<test_case; j++)
{
gets(ch);
for(i=0, sum_doubled=0; i<18; i=i+2)
{
ch[i]*=2;
if(ch[i]>=10)
ch[i]=(ch[i]%10)+1;
sum_doubled+=ch[i];
}
for(i=1, sum_undoubled=0; i<19; i=i+2)
sum_undoubled+=ch[i];
if((sum_doubled+sum_undoubled)%10==0){
printf("Valid\n");
}
else {
printf("Invalid\n");
}
}
}
| 21.586207 | 59 | 0.434505 |
d988c2d2601efeba528bb7e5be233080873eea69 | 8,058 | c | C | test/unit/sunlark/test_binding_rm.c | obazl/sunlark | 5091eaab6153d99dc24c62327f15f5fad9613d58 | [
"BSD-2-Clause"
] | null | null | null | test/unit/sunlark/test_binding_rm.c | obazl/sunlark | 5091eaab6153d99dc24c62327f15f5fad9613d58 | [
"BSD-2-Clause"
] | null | null | null | test/unit/sunlark/test_binding_rm.c | obazl/sunlark | 5091eaab6153d99dc24c62327f15f5fad9613d58 | [
"BSD-2-Clause"
] | null | null | null | #include "log.h"
#include "utarray.h"
#include "utstring.h"
#include "unity.h"
#include "s7.h"
#include "sealark.h"
#include "sunlark.h"
#include "test_binding_rm.h"
char *build_file = "test/unit/sunlark/BUILD.binding_rm";
s7_scheme *s7;
/**************/
int main(void) {
UNITY_BEGIN();
/* RUN_TEST(test_remove_binding_by_int); */
RUN_TEST(test_remove_binding_by_sym);
/* RUN_TEST(test_local_remove_binding_by_int); */
/* RUN_TEST(test_rm_binding_val_item_by_int); */
return UNITY_END();
}
/* **************************************************************** */
void test_rm_binding_val_item_by_int(void)
{
pkg = sunlark_parse_build_file(s7,
s7_list(s7, 1,
s7_make_string(s7, build_file)));
form = "'(:> \"binding-rm-1\")";
path = s7_eval_c_string(s7, form);
target = s7_apply_function(s7, pkg, path);
TEST_ASSERT( s7_is_c_object(target) );
TEST_ASSERT( sunlark_node_tid(s7, target) == TK_Call_Expr );
dentry = s7_apply_function(s7, target,
s7_eval_c_string(s7, "'(:@ binding3)"));
TEST_ASSERT( s7_is_c_object(dentry) );
TEST_ASSERT( sunlark_node_tid(s7, dentry) == TK_Binding );
/* (let ((target (pkg :> "binding-rm-1"))
(dentry (target :@ 'binding3))
(set! (dentry :value :0) :null)) */
getter = s7_list(s7, 3, dentry,
s7_make_keyword(s7, "value"),
s7_make_keyword(s7, "0"));
s7_pointer result = s7_apply_function(s7, set_bang,
s7_list(s7, 2, getter,
s7_make_keyword(s7, "null")));
/* form = "'(:> \"string-list-dict\" :@ bdict)"; */
/* path = s7_eval_c_string(s7, form); */
/* result = s7_apply_function(s7, pkg, path); */
/* sealark_debug_log_ast_outline(s7_c_object_value(target), 0); */
sunlark_dispose(s7,pkg);
}
void test_remove_binding_by_int(void)
{
pkg = sunlark_parse_build_file(s7,
s7_list(s7, 1,
s7_make_string(s7, build_file)));
/* remove bool_attr attrib */
char *s = "'(:> \"binding-rm-1\")";
s7_pointer path = s7_eval_c_string(s7, s);
s7_pointer target = s7_apply_function(s7, pkg, path);
s7_pointer pred= s7_apply_function(s7, target,
s7_eval_c_string(s7, "'(:target?)"));
TEST_ASSERT( pred == s7_t(s7) );
s7_pointer attrs = s7_apply_function(s7, target,
s7_eval_c_string(s7, "'(:@@)"));
s7_pointer len = s7_apply_function(s7, attrs,
s7_eval_c_string(s7, "'(:length)"));
TEST_ASSERT_EQUAL_INT( 6, s7_integer(len) );
s7_pointer binding = s7_apply_function(s7, target,
s7_eval_c_string(s7, "'(:@ 1)"));
pred= s7_apply_function(s7, binding,
s7_eval_c_string(s7, "'(:binding?)"));
TEST_ASSERT( pred == s7_t(s7) );
/* (let ((target (pkg :> * "binding-rm-1"))
(set! (target :@ 1) :null))) */
s7_pointer getter = s7_list(s7, 3, target,
s7_make_keyword(s7,"@"),
s7_make_integer(s7,1));
s7_pointer res = s7_apply_function(s7, set_bang,
s7_list(s7, 2,
getter,
s7_make_keyword(s7,"null")));
attrs = NULL;
attrs = s7_apply_function(s7, target,
s7_eval_c_string(s7, "'(:@@)"));
len = NULL;
len = s7_apply_function(s7, attrs,
s7_eval_c_string(s7, "'(:length)"));
TEST_ASSERT_EQUAL_INT( 5, s7_integer(len) );
/* sealark_debug_log_ast_outline(s7_c_object_value(target), 0); */
/* s7_pointer target = s7_apply_function(s7, pkg, path); */
/* pred = NULL; */
/* pred= s7_apply_function(s7, binding, */
/* s7_eval_c_string(s7, "'(:binding?)")); */
/* TEST_ASSERT( pred == s7_t(s7) ); */
/* result = s7_apply_function(s7, set_bang, */
/* s7_list(s7, 2, getter, */
/* s7_make_keyword(s7, "null"))); */
/* val = s7_apply_function(s7, result, s7_eval_c_string(s7, "'(:$)")); */
/* val = s7_apply_function(s7, val, s7_eval_c_string(s7, "'(:$)")); */
/* TEST_ASSERT_EQUAL_INT( 99, s7_integer(val)); */
sunlark_dispose(s7,pkg);
}
void test_remove_binding_by_sym(void)
{
pkg = sunlark_parse_build_file(s7,
s7_list(s7, 1,
s7_make_string(s7, build_file)));
/* remove binding1 attrib */
char *bstr = "(pkg :> \"binding-rm-1\" :@ 'binding1)";
s7_pointer binding = s7_eval_c_string(s7, bstr);
TEST_ASSERT( s7_is_c_object(binding));
bstr = "(pkg :> \"binding-rm-1\" :@@)"; // NB: no quote!
s7_pointer bindings = s7_eval_c_string(s7, bstr);
s7_pointer len = s7_apply_function(s7, s7_name_to_value(s7,"length"),
s7_list(s7, 1, bindings));
TEST_ASSERT_EQUAL_INT( 6, s7_integer(len) );
/* NB: no quote on (set! ...) */
char *rm = "(set! (pkg :> \"binding-rm-1\" :@ 'binding1) :null)";
s7_pointer set = s7_eval_c_string(s7, rm);
len = NULL;
len = s7_apply_function(s7, s7_name_to_value(s7,"length"),
s7_list(s7, 1, bindings));
TEST_ASSERT_EQUAL_INT( 5, s7_integer(len) );
bstr = "(pkg :> \"binding-rm-1\" :@ 'binding1)";
binding = s7_eval_c_string(s7, bstr);
TEST_ASSERT( s7_is_null(s7,binding));
/* look for error messages */
/* errmsg = s7_get_output_string(s7, s7_current_error_port(s7)); */
/* if ((errmsg) && (*errmsg)) */
/* log_error("CAUGHT: [%s]", errmsg); */
sunlark_dispose(s7,pkg);
}
/* **************************************************************** */
void test_local_remove_binding_by_int(void)
{
pkg = sunlark_parse_build_file(s7,
s7_list(s7, 1,
s7_make_string(s7, build_file)));
char *s = "(define bb (make-binding 'akey '(1 2 3)))";
s7_pointer binding = s7_eval_c_string(s7, s);
s7_pointer pred= s7_apply_function(s7, binding,
s7_eval_c_string(s7, "'(:binding?)"));
TEST_ASSERT( pred == s7_t(s7) );
/* s7_pointer getter = s7_list(s7, 3, */
/* binding, */
/* s7_make_keyword(s7, "value"), */
/* s7_make_keyword(s7, "0")); */
/* s7_pointer result = s7_apply_function(s7, set_bang, */
/* s7_list(s7, 2, getter, */
/* s7_make_keyword(s7, "null"))); */
char *rm = "(set! (bb :$ :0) :null)";
s7_pointer set = s7_eval_c_string(s7, rm);
/* s7_pointer vec = s7_apply_function(s7, binding, */
/* s7_eval_c_string(s7, "'(:value)")); */
/* s7_pointer len = s7_apply_function(s7, vec, */
/* s7_eval_c_string(s7, "'(:length)")); */
/* TEST_ASSERT_EQUAL_INT( 2, s7_integer(len) ); */
sunlark_dispose(s7,pkg);
}
/* **************************************************************** */
void setUp(void) {
s7 = sunlark_init();
init_s7_syms(s7);
/* trap error messages */
old_port = s7_set_current_error_port(s7, s7_open_output_string(s7));
if (old_port != s7_nil(s7))
gc_loc = s7_gc_protect(s7, old_port);
pkg = sunlark_parse_build_file(s7,
s7_list(s7, 1,
s7_make_string(s7, build_file)));
s7_define_variable(s7, "pkg", pkg);
}
void tearDown(void) {
s7_quit(s7);
}
| 37.47907 | 80 | 0.510921 |
d9898703cc78f4e341b9b06aaa9fcdb5c77e5db8 | 6,180 | h | C | src/core/SkScalerCache.h | tornado12345/skia | 7a61e5d65399f8539e1d95e7c39eac0a63e595ff | [
"BSD-3-Clause"
] | 1 | 2022-03-11T02:34:47.000Z | 2022-03-11T02:34:47.000Z | src/core/SkScalerCache.h | Wal1e/skia | eda97288bdc8e87afea817b25d561724c2b6a2f8 | [
"BSD-3-Clause"
] | null | null | null | src/core/SkScalerCache.h | Wal1e/skia | eda97288bdc8e87afea817b25d561724c2b6a2f8 | [
"BSD-3-Clause"
] | null | null | null | /*
* Copyright 2006 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
*/
#ifndef SkStrike_DEFINED
#define SkStrike_DEFINED
#include "include/core/SkFontMetrics.h"
#include "include/core/SkFontTypes.h"
#include "include/private/SkMutex.h"
#include "include/private/SkTHash.h"
#include "include/private/SkTemplates.h"
#include "src/core/SkArenaAlloc.h"
#include "src/core/SkDescriptor.h"
#include "src/core/SkGlyph.h"
#include "src/core/SkGlyphRunPainter.h"
#include "src/core/SkStrikeForGPU.h"
#include <memory>
class SkScalerContext;
// This class represents a strike: a specific combination of typeface, size, matrix, etc., and
// holds the glyphs for that strike.
class SkScalerCache {
public:
SkScalerCache(std::unique_ptr<SkScalerContext> scaler,
const SkFontMetrics* metrics = nullptr);
// Lookup (or create if needed) the toGlyph using toID. If that glyph is not initialized with
// an image, then use the information in from to initialize the width, height top, left,
// format and image of the toGlyph. This is mainly used preserving the glyph if it was
// created by a search of desperation.
std::tuple<SkGlyph*, size_t> mergeGlyphAndImage(
SkPackedGlyphID toID, const SkGlyph& from) SK_EXCLUDES(fMu);
// If the path has never been set, then add a path to glyph.
std::tuple<const SkPath*, size_t> mergePath(
SkGlyph* glyph, const SkPath* path, bool hairline) SK_EXCLUDES(fMu);
// If the drawable has never been set, then add a drawble to glyph.
std::tuple<SkDrawable*, size_t> mergeDrawable(
SkGlyph* glyph, sk_sp<SkDrawable> drawable) SK_EXCLUDES(fMu);
/** Return the number of glyphs currently cached. */
int countCachedGlyphs() const SK_EXCLUDES(fMu);
/** If the advance axis intersects the glyph's path, append the positions scaled and offset
to the array (if non-null), and set the count to the updated array length.
*/
void findIntercepts(const SkScalar bounds[2], SkScalar scale, SkScalar xPos,
SkGlyph* , SkScalar* array, int* count) SK_EXCLUDES(fMu);
const SkFontMetrics& getFontMetrics() const {
return fFontMetrics;
}
std::tuple<SkSpan<const SkGlyph*>, size_t> metrics(
SkSpan<const SkGlyphID> glyphIDs, const SkGlyph* results[]) SK_EXCLUDES(fMu);
std::tuple<SkSpan<const SkGlyph*>, size_t> preparePaths(
SkSpan<const SkGlyphID> glyphIDs, const SkGlyph* results[]) SK_EXCLUDES(fMu);
std::tuple<SkSpan<const SkGlyph*>, size_t> prepareImages(
SkSpan<const SkPackedGlyphID> glyphIDs, const SkGlyph* results[]) SK_EXCLUDES(fMu);
std::tuple<SkSpan<const SkGlyph*>, size_t> prepareDrawables(
SkSpan<const SkGlyphID> glyphIDs, const SkGlyph* results[]) SK_EXCLUDES(fMu);
size_t prepareForDrawingMasksCPU(SkDrawableGlyphBuffer* accepted) SK_EXCLUDES(fMu);
// SkStrikeForGPU APIs
const SkGlyphPositionRoundingSpec& roundingSpec() const {
return fRoundingSpec;
}
size_t prepareForMaskDrawing(
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) SK_EXCLUDES(fMu);
size_t prepareForSDFTDrawing(
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) SK_EXCLUDES(fMu);
size_t prepareForPathDrawing(
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) SK_EXCLUDES(fMu);
size_t prepareForDrawableDrawing(
SkDrawableGlyphBuffer* accepted, SkSourceGlyphBuffer* rejected) SK_EXCLUDES(fMu);
void dump() const SK_EXCLUDES(fMu);
SkScalerContext* getScalerContext() const { return fScalerContext.get(); }
private:
template <typename Fn>
size_t commonFilterLoop(SkDrawableGlyphBuffer* accepted, Fn&& fn) SK_REQUIRES(fMu);
// Return a glyph. Create it if it doesn't exist, and initialize the glyph with metrics and
// advances using a scaler.
std::tuple<SkGlyph*, size_t> glyph(SkPackedGlyphID) SK_REQUIRES(fMu);
std::tuple<SkGlyphDigest, size_t> digest(SkPackedGlyphID) SK_REQUIRES(fMu);
// Generate the glyph digest information and update structures to add the glyph.
SkGlyphDigest addGlyph(SkGlyph* glyph) SK_REQUIRES(fMu);
std::tuple<const void*, size_t> prepareImage(SkGlyph* glyph) SK_REQUIRES(fMu);
// If the path has never been set, then use the scaler context to add the glyph.
size_t preparePath(SkGlyph*) SK_REQUIRES(fMu);
// If the drawable has never been set, then use the scaler context to add the glyph.
size_t prepareDrawable(SkGlyph*) SK_REQUIRES(fMu);
enum PathDetail {
kMetricsOnly,
kMetricsAndPath
};
// internalPrepare will only be called with a mutex already held.
std::tuple<SkSpan<const SkGlyph*>, size_t> internalPrepare(
SkSpan<const SkGlyphID> glyphIDs,
PathDetail pathDetail,
const SkGlyph** results) SK_REQUIRES(fMu);
const std::unique_ptr<SkScalerContext> fScalerContext;
const SkFontMetrics fFontMetrics;
const SkGlyphPositionRoundingSpec fRoundingSpec;
mutable SkMutex fMu;
// Map from a combined GlyphID and sub-pixel position to a SkGlyphDigest. The actual glyph is
// stored in the fAlloc. The pointer to the glyph is stored fGlyphForIndex. The
// SkGlyphDigest's fIndex field stores the index. This pointer provides an unchanging
// reference to the SkGlyph as long as the strike is alive, and fGlyphForIndex
// provides a dense index for glyphs.
SkTHashTable<SkGlyphDigest, uint32_t, SkGlyphDigest> fDigestForPackedGlyphID SK_GUARDED_BY(fMu);
std::vector<SkGlyph*> fGlyphForIndex SK_GUARDED_BY(fMu);
// so we don't grow our arrays a lot
inline static constexpr size_t kMinGlyphCount = 8;
inline static constexpr size_t kMinGlyphImageSize = 16 /* height */ * 8 /* width */;
inline static constexpr size_t kMinAllocAmount = kMinGlyphImageSize * kMinGlyphCount;
SkArenaAlloc fAlloc SK_GUARDED_BY(fMu) {kMinAllocAmount};
};
#endif // SkStrike_DEFINED
| 41.47651 | 100 | 0.718285 |
d989bb63cfc2038b5b413764d9e26406c10c045d | 5,291 | h | C | optimizers/NewMinuit.h | fermi-lat/optimizers | e67cd44c878b0654dd5cd812573733102263ecb2 | [
"BSD-3-Clause"
] | null | null | null | optimizers/NewMinuit.h | fermi-lat/optimizers | e67cd44c878b0654dd5cd812573733102263ecb2 | [
"BSD-3-Clause"
] | 1 | 2020-01-09T23:51:17.000Z | 2020-01-09T23:51:17.000Z | optimizers/NewMinuit.h | fermi-lat/optimizers | e67cd44c878b0654dd5cd812573733102263ecb2 | [
"BSD-3-Clause"
] | 1 | 2018-11-14T19:25:00.000Z | 2018-11-14T19:25:00.000Z | /**
* @file NewMinuit.h
* @brief Interface to the new C++ version of Minuit
* @author P. Nolan
* $Header$
*/
#ifndef optimizers_NEWMINUIT_H
#define optimizers_NEWMINUIT_H
#include <vector>
#include "optimizers/Optimizer.h"
#include "optimizers/Statistic.h"
#include "Minuit2/FCNGradientBase.h"
#include "Minuit2/MnStrategy.h"
#include "Minuit2/MnUserParameterState.h"
#include "Minuit2/FunctionMinimum.h"
#include "Minuit2/MinimumError.h"
namespace optimizers {
/**
* @class myFCN
* @brief The function minimized by Minuit
* @author P. Nolan
Minuit provides a base class for the function to be minimized.
This is the implementation using the Optimizer infrastructure.
Q: Would it be better to do this as a hidden class within NewMinuit?
*/
class myFCN : public ROOT::Minuit2::FCNGradientBase {
public:
myFCN(Statistic &);
virtual ~myFCN() {};
virtual double Up() const {return m_level;}
virtual double operator() (const std::vector<double> &) const;
virtual std::vector<double> Gradient(const std::vector<double> &) const;
virtual bool CheckGradient() const {return false;}
virtual void SetErrorDef(double level) {m_level=level;}
private:
Statistic * m_stat;
double m_level;
};
/**
* @class NewMinuit
* @brief Wrapper class for the Minuit optimizer from CERN
* @author P. Nolan
This class implements an Optimizer by using Minuit, a well-known
package from CERN. It uses only a few of Minuit's features.
It uses only the Migrad and Hesse algorithms. All variables are
treated as bounded. No user interaction is allowed. The new
C++ implementation of Minuit is used, which has no limits on the
number of free parameters. The older Fortran version of Minuit is
well known in the HEP community. It was developed at CERN over a
span of about 30 years.
*/
class NewMinuit : public Optimizer {
public:
NewMinuit(Statistic &);
virtual ~NewMinuit() {delete m_min;};
NewMinuit & operator=(const NewMinuit & rhs);
NewMinuit(const NewMinuit & x);
virtual int find_min(int verbose=0, double tole = 1e-5, int tolType = ABSOLUTE);
virtual int find_min_only(int verbose=0, double tole = 1e-5, int tolType = ABSOLUTE);
void setStrategy(unsigned int strat = 1) {
m_strategy_value = strat;
m_strategy=ROOT::Minuit2::MnStrategy(strat);
}
unsigned int getStrategy() const {
return m_strategy_value;
}
const ROOT::Minuit2::MnUserParameterState& userState() const;
const ROOT::Minuit2::MinimumError& minuitError() const;
std::vector<std::vector<double> > userCovariance() const;
const std::vector<double>& userGlobalCC() const;
// hessian (inverse of covariance matrix)
std::vector<std::vector<double> > userHessian() const;
// covariance matrix status (0 = not valid, 1 approximate, 2, full but made pos def, 3 accurate and not pos def
int userCovarianceStatus() const { return userState().CovarianceStatus(); }
bool userIsValid() const {return userState().IsValid();}
bool userHasCovariance() const {return userState().HasCovariance();}
bool userHasGlobalCC() const {return userState().HasGlobalCC();}
double userFval() const {return userState().Fval();}
double userEdm() const {return userState().Edm();}
unsigned int userNFcn() const {return userState().NFcn();}
double minuitDcovar() const {return minuitError().Dcovar();}
bool minuitIsAccurate() const {return minuitError().IsAccurate();}
bool minuitIsValid() const {return minuitError().IsValid();}
bool minuitIsPosDef() const {return minuitError().IsPosDef();}
bool minuitIsMadePosDef() const {return minuitError().IsMadePosDef();}
bool minuitHesseFailed() const {return minuitError().HesseFailed();}
bool minuitInvertFailed() const {return minuitError().InvertFailed();}
bool minuitIsAvailable() const {return minuitError().IsAvailable();}
std::vector<std::vector<double> > minuitInvHessian() const;
double getDistance(void) const {return m_distance;};
virtual const std::vector<double> & getUncertainty(bool useBase = false);
virtual std::vector<std::vector<double> > covarianceMatrix() const;
virtual std::ostream& put (std::ostream& s) const;
std::pair<double,double> Minos(unsigned int n, double level=1., bool numericDeriv=false);
/// Compute the lower bound error using Minos.
double minos_lower_error(unsigned int n, double level=1.,
double tol=1e-3);
/// Compute the upper bound error using Minos.
double minos_upper_error(unsigned int n, double level=1.,
double tol=1e-3);
/// Run a MNCONTOUR dynamic CONTOUR analysis
void MnContour(unsigned int par1, unsigned int par2,
double level=1., unsigned int npts=20);
private:
myFCN m_FCN;
double m_distance;
double m_tolerance;
ROOT::Minuit2::MnStrategy m_strategy;
ROOT::Minuit2::FunctionMinimum * m_min;
unsigned int m_strategy_value;
void setTolerance(double tol, int tolType);
void hesse(int verbose = 0);
int checkResults();
void checkParValues(unsigned int n, std::vector<double> & parValues) const;
};
}
#endif
| 36.743056 | 115 | 0.694765 |
d98ab41e3cd9a5ff75eab9c4008e35a8a1e8dd81 | 283 | h | C | HDJFKJ/HDJFKJ/LDFindPassViewController.h | huangjinping/test111 | 58a5a15c551d598557952ff9a2246f52ffa7cf7c | [
"MIT"
] | null | null | null | HDJFKJ/HDJFKJ/LDFindPassViewController.h | huangjinping/test111 | 58a5a15c551d598557952ff9a2246f52ffa7cf7c | [
"MIT"
] | null | null | null | HDJFKJ/HDJFKJ/LDFindPassViewController.h | huangjinping/test111 | 58a5a15c551d598557952ff9a2246f52ffa7cf7c | [
"MIT"
] | null | null | null | //
// LDFindPassViewController.h
// HDJFKJ
//
// Created by apple on 16/4/5.
// Copyright © 2016年 LDSmallCat. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface LDFindPassViewController : LDBaseUIViewController
@property (nonatomic, strong) NSString * fromWhere;
@end
| 18.866667 | 60 | 0.731449 |
d9914a0f37ff2059efe7fb16978bf760ad923ffb | 523 | h | C | Third/LearnFMDB/ZXGDBManager/ZXGDBWhereCondition.h | onzxgway/ZXGKit | 5e7dba8e70c55a63901475eda5c1433fa980cb5b | [
"MIT"
] | null | null | null | Third/LearnFMDB/ZXGDBManager/ZXGDBWhereCondition.h | onzxgway/ZXGKit | 5e7dba8e70c55a63901475eda5c1433fa980cb5b | [
"MIT"
] | null | null | null | Third/LearnFMDB/ZXGDBManager/ZXGDBWhereCondition.h | onzxgway/ZXGKit | 5e7dba8e70c55a63901475eda5c1433fa980cb5b | [
"MIT"
] | null | null | null | //
// ZXGDBWhereCondition.h
// LearnFMDB
//
// Created by 朱献国 on 2018/4/8.
// Copyright © 2018年 feizhu. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "ZXGDBConstDefine.h"
@interface ZXGDBWhereCondition : NSObject
/** 连接符类型*/
@property (nonatomic, assign) ZXGDBWhereOperationType operaType;
/** 字段名称*/
@property (nonatomic, copy ) NSString *columnName;
/** 字段值*/
@property (nonatomic, copy ) NSString *value;
/** sql*/
@property (nonatomic, copy , readonly) NSString *sqlWherePartStr;
@end
| 19.37037 | 66 | 0.707457 |
d991adb39569b49c49c07ff47f906d75dc78ff30 | 7,358 | c | C | tbsa-v8m/val/src/val_debug.c | gowthamsiddarthd/psa-arch-tests | 12833045acea77acd9629ceac47fb4e52e6d8157 | [
"Apache-2.0"
] | 1 | 2020-11-27T12:34:16.000Z | 2020-11-27T12:34:16.000Z | tbsa-v8m/val/src/val_debug.c | gowthamsiddarthd/psa-arch-tests | 12833045acea77acd9629ceac47fb4e52e6d8157 | [
"Apache-2.0"
] | 2 | 2021-05-20T23:02:07.000Z | 2021-09-28T05:44:30.000Z | tbsa-v8m/val/src/val_debug.c | gowthamsiddarthd/psa-arch-tests | 12833045acea77acd9629ceac47fb4e52e6d8157 | [
"Apache-2.0"
] | null | null | null | /** @file
* Copyright (c) 2018-2019, Arm Limited or its affiliates. All rights reserved.
* SPDX-License-Identifier : Apache-2.0
*
* 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 "val_debug.h"
#include "val_target.h"
#include "val_infra.h"
#include "val_pe.h"
static uint32_t g_debug_test_start = 0;
/**
@brief - This function will get the status of the debugger,
based on the access_type
@param - dbg_access - read/write/init
@return - error status
**/
tbsa_status_t val_debug_get_status(dbg_access_t dbg_access)
{
tbsa_status_t status;
dpm_desc_t *dpm_desc;
uint32_t timeout = DBG_TIMEOUT;
status = val_target_get_config(TARGET_CONFIG_CREATE_ID(GROUP_DPM, DPM_DPM, 0),
(uint8_t **)&dpm_desc, (uint32_t *)sizeof(dpm_desc_t));
if(status)
return status;
switch (dbg_access) {
case DBG_INIT:
if (!g_debug_test_start) {
if (DBG_INIT_SIGNATURE != *(uint32_t *)dpm_desc->data_addr) {
val_print(PRINT_WARN, "\n\r\tSkipping the test as External Debugger is not present", 0);
val_print(PRINT_DEBUG, "\n\r\tData present in the handshake address 0x%x", *(uint32_t *)dpm_desc->data_addr);
return TBSA_STATUS_SKIP;
}
g_debug_test_start++;
val_print(PRINT_INFO, "\n\r\tExternal Debugger initial handshake successful", 0);
} else {
if (DBG_NEXT_SIGNATURE != *(uint32_t *)dpm_desc->data_addr) {
val_print(PRINT_WARN, "\n\r\tSkipping the test as previous test corrupted handshake data", 0);
val_print(PRINT_DEBUG, "\n\r\tData present in the handshake address 0x%x", *(uint32_t *)dpm_desc->data_addr);
return TBSA_STATUS_SKIP;
}
val_print(PRINT_INFO, "\n\r\tExternal Debugger handshake successful", 0);
}
break;
case DBG_WRITE:
while (((DBG_FLAG_READY & *(uint32_t *)dpm_desc->flag_addr) != DBG_FLAG_READY) && (--timeout));
if (!timeout) {
val_print(PRINT_ERROR, "\n\r\tTimeout: External Debugger is not ready", 0);
return TBSA_STATUS_TIMEOUT;
}
timeout = DBG_TIMEOUT;
/* Poll for Txfull to be '0' before writing to the data register*/
while (((DBG_FLAG_TXFULL & *(uint32_t *)dpm_desc->flag_addr) == DBG_FLAG_TXFULL) && (--timeout));
if (!timeout) {
val_print(PRINT_ERROR, "\n\r\tTimeout while polling for TxFull=0", 0);
return TBSA_STATUS_TIMEOUT;
}
break;
case DBG_READ:
while (((DBG_FLAG_READY & *(uint32_t *)dpm_desc->flag_addr) != DBG_FLAG_READY) && (--timeout));
if (!timeout) {
val_print(PRINT_ERROR, "\n\r\tTimeout: External Debugger is not ready", 0);
return TBSA_STATUS_TIMEOUT;
}
timeout = DBG_TIMEOUT;
/* Poll for Rxfull to be '1' before reading the data updated by debugger*/
while (((DBG_FLAG_RXFULL & *(uint32_t *)dpm_desc->flag_addr) != DBG_FLAG_RXFULL) && (--timeout));
if (!timeout) {
val_print(PRINT_ERROR, "\n\r\tTimeout while polling for RxFull=1", 0);
return TBSA_STATUS_TIMEOUT;
}
break;
default:
return TBSA_STATUS_INCORRECT_VALUE;
}
return TBSA_STATUS_SUCCESS;
}
/**
@brief - This function will set the status of the debugger,
based on the access_type
@param - dbg_access : read/write/init
- dbg_seq_status : this will choose the sequence to be executed on debugger
@return - error status
**/
tbsa_status_t val_debug_set_status(dbg_access_t dbg_access, dbg_seq_status_t dbg_status)
{
tbsa_status_t status;
dpm_desc_t *dpm_desc;
uint32_t timeout = DBG_TIMEOUT;
status = val_target_get_config(TARGET_CONFIG_CREATE_ID(GROUP_DPM, DPM_DPM, 0),
(uint8_t **)&dpm_desc, (uint32_t *)sizeof(dpm_desc_t));
if(status)
return status;
switch (dbg_access) {
case DBG_INIT:
while (((DBG_FLAG_READY & *(uint32_t *)dpm_desc->flag_addr) != DBG_FLAG_READY) && (--timeout));
if (!timeout) {
val_print(PRINT_ERROR, "\n\r\tTimeout: External Debugger is not ready", 0);
return TBSA_STATUS_TIMEOUT;
}
*(uint32_t *)dpm_desc->flag_addr = dbg_status;
asm volatile("DSB");
asm volatile("ISB");
break;
case DBG_WRITE:
*(uint32_t *)dpm_desc->flag_addr = dbg_status | DBG_FLAG_TXFULL;
break;
case DBG_READ:
*(uint32_t *)dpm_desc->flag_addr &= ~DBG_FLAG_RXFULL;
asm volatile("DSB");
asm volatile("ISB");
break;
default:
return TBSA_STATUS_INCORRECT_VALUE;
}
return TBSA_STATUS_SUCCESS;
}
/**
@brief - This function will set the DPM state
@param - dpm_desc : dpm_desc_t
dpm_status : DPM status as per TBSA spec, defined in dpm_status_t
@return - error status
**/
tbsa_status_t val_dpm_set_state(dpm_desc_t *dpm_desc, dpm_status_t dpm_status)
{
switch(dpm_desc->unlock_token)
{
case TOKEN_PASSWD:
return pal_dpm_set_state(dpm_desc->index, dpm_status, dpm_desc->unlock_token, (void *)(dpm_desc->passwd));
case TOKEN_CERTIFICATE:
return pal_dpm_set_state(dpm_desc->index, dpm_status, dpm_desc->unlock_token, (void *)(dpm_desc->certificate_addr));
default:
return TBSA_STATUS_INVALID_ARGS;
}
}
/**
@brief - This function will set the DPM state
@param - index : DPM index
dpm_status : DPM status as per TBSA spec, can returned as logical OR of in relevant cases
DPM_LOCK_IMPLEMENTED/DPM_LOCK_VALUE
DPM_EN_IMPLEMENTED/DPM_EN_VALUE
@return - error status
**/
tbsa_status_t val_dpm_get_state(uint32_t index, uint32_t *dpm_status)
{
return pal_dpm_get_state(index, dpm_status);
}
/**
@brief - This function will set the debug permission based on the input arg
@param - index : DPM index
access_ns : TRUE - allow debug access only for non-secure address
FALSE - allow debug access to both secure and non-secure addresses
@return - error status
**/
tbsa_status_t val_dpm_set_access_ns_only(uint32_t index, bool_t access_ns)
{
return pal_dpm_set_access_ns_only(index, access_ns);
}
| 40.428571 | 129 | 0.607502 |
d991fc66d43bde4a84d7ae1f1f893ce3070686f0 | 1,177 | h | C | EaseIM/EaseIM/Class/Chat/ChatExtComponents/ChatToolBarComponents/ChatToolBarComponentsIncident/EMChatViewController+ChatToolBarIncident.h | MThrone/chat-ios | 7a6671981bb757c2978a89e4d901655bf02ac1bf | [
"Apache-2.0"
] | null | null | null | EaseIM/EaseIM/Class/Chat/ChatExtComponents/ChatToolBarComponents/ChatToolBarComponentsIncident/EMChatViewController+ChatToolBarIncident.h | MThrone/chat-ios | 7a6671981bb757c2978a89e4d901655bf02ac1bf | [
"Apache-2.0"
] | null | null | null | EaseIM/EaseIM/Class/Chat/ChatExtComponents/ChatToolBarComponents/ChatToolBarComponentsIncident/EMChatViewController+ChatToolBarIncident.h | MThrone/chat-ios | 7a6671981bb757c2978a89e4d901655bf02ac1bf | [
"Apache-2.0"
] | null | null | null | //
// EMChatViewController+ChatToolBarIncident.h
// EaseIM
//
// Created by 娜塔莎 on 2020/7/13.
// Copyright © 2020 娜塔莎. All rights reserved.
//
#import "EMChatViewController.h"
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, EMChatToolBarComponentType) {
EMChatToolBarPhotoAlbum = 0,
EMChatToolBarCamera,
EMChatToolBarSealRtc,
EMChatToolBarLocation,
EMChatToolBarFileOpen,
};
@interface EMChatViewController (ChatToolBarIncident)
- (void)chatToolBarComponentAction:(EMChatToolBarComponentType)toolBarComponentType;
@end
@interface EMChatViewController (ChatToolBarMeida) <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
@property (nonatomic, strong) UIImagePickerController *imagePicker;
- (void)chatToolBarComponentIncidentAction:(EMChatToolBarComponentType)componentType;
@end
@interface EMChatViewController (ChatToolBarSealRtc)
- (void)chatToolBarComponentSealRtcAction;
@end
@interface EMChatViewController (ChatToolBarLocation)
- (void)chatToolBarLocationAction;
@end
@interface EMChatViewController (ChatToolBarFileOpen) <UIDocumentPickerDelegate>
- (void)chatToolBarFileOpenAction;
@end
NS_ASSUME_NONNULL_END
| 23.078431 | 116 | 0.820731 |
d994e6702d86fe273a682a2c74c340df55d95c9e | 2,025 | c | C | libxlsxwriter/examples/chart_styles.c | White-116/xlsxd | b7f467cda76e93dd17bc7aaa2879e6c112ce4cf9 | [
"BSD-3-Clause"
] | 7 | 2019-07-24T14:25:45.000Z | 2022-03-06T04:29:39.000Z | libxlsxwriter/examples/chart_styles.c | White-116/xlsxd | b7f467cda76e93dd17bc7aaa2879e6c112ce4cf9 | [
"BSD-3-Clause"
] | 14 | 2019-07-03T11:03:05.000Z | 2022-01-18T13:55:13.000Z | libxlsxwriter/examples/chart_styles.c | White-116/xlsxd | b7f467cda76e93dd17bc7aaa2879e6c112ce4cf9 | [
"BSD-3-Clause"
] | 3 | 2019-08-06T21:35:29.000Z | 2021-07-08T08:11:34.000Z | /*
* An example showing all 48 default chart styles available in Excel 2007
* using the libxlsxwriter library. Note, these styles are not the same as the
* styles available in Excel 2013.
*
* Copyright 2014-2018, John McNamara, jmcnamara@cpan.org
*
*/
#include "xlsxwriter.h"
int main() {
int chart_types[] = {LXW_CHART_COLUMN, LXW_CHART_AREA, LXW_CHART_LINE, LXW_CHART_PIE};
char *chart_names[] = {"Column", "Area", "Line", "Pie"};
char chart_title[32] = {0};
int row_num, col_num, chart_num, style_num;
lxw_worksheet *worksheet;
lxw_chart *chart;
lxw_workbook *workbook = new_workbook("chart_styles.xlsx");
for (chart_num = 0; chart_num < 4; chart_num++) {
/* Add a worksheet for each chart type. */
worksheet = workbook_add_worksheet(workbook, chart_names[chart_num]);
worksheet_set_zoom(worksheet, 30);
/* Create 48 charts, each with a different style. */
style_num = 1;
for (row_num = 0; row_num < 90; row_num += 15) {
for (col_num = 0; col_num < 64; col_num += 8) {
chart = workbook_add_chart(workbook, chart_types[chart_num]);
sprintf(chart_title, "Style %d", style_num);
chart_add_series(chart, NULL, "=Data!$A$1:$A$6");
chart_title_set_name(chart, chart_title);
chart_set_style(chart, style_num);
worksheet_insert_chart(worksheet, row_num, col_num, chart);
style_num++;
}
}
}
/* Create a worksheet with data for the charts. */
worksheet = workbook_add_worksheet(workbook, "Data");
worksheet_write_number(worksheet, 0, 0, 10, NULL);
worksheet_write_number(worksheet, 1, 0, 40, NULL);
worksheet_write_number(worksheet, 2, 0, 50, NULL);
worksheet_write_number(worksheet, 3, 0, 20, NULL);
worksheet_write_number(worksheet, 4, 0, 10, NULL);
worksheet_write_number(worksheet, 5, 0, 50, NULL);
return workbook_close(workbook);
}
| 32.142857 | 93 | 0.637531 |
d9955a6381be4e465f48ae3744a6b4883743872c | 11,312 | c | C | apc_rfc1867.c | ss23/pecl-caching-apc | 6a904063fe753299e8c7c5b2c6658b1976a61de2 | [
"PHP-3.01"
] | null | null | null | apc_rfc1867.c | ss23/pecl-caching-apc | 6a904063fe753299e8c7c5b2c6658b1976a61de2 | [
"PHP-3.01"
] | null | null | null | apc_rfc1867.c | ss23/pecl-caching-apc | 6a904063fe753299e8c7c5b2c6658b1976a61de2 | [
"PHP-3.01"
] | 1 | 2019-10-07T17:10:50.000Z | 2019-10-07T17:10:50.000Z | /*
+----------------------------------------------------------------------+
| APC |
+----------------------------------------------------------------------+
| Copyright (c) 2006-2011 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Rasmus Lerdorf <rasmus@php.net> |
+----------------------------------------------------------------------+
This software was contributed to PHP by Community Connect Inc. in 2002
and revised in 2005 by Yahoo! Inc. to add support for PHP 5.1.
Future revisions and derivatives of this source code must acknowledge
Community Connect Inc. as the original contributor of this module by
leaving this note intact in the source code.
All other licensing and usage conditions are those of the PHP Group.
*/
/* $Id$*/
#include "apc.h"
#include "apc_globals.h"
#include "rfc1867.h"
#ifdef PHP_WIN32
#include "win32/time.h"
#endif
#ifdef MULTIPART_EVENT_FORMDATA
extern int _apc_store(char *strkey, int strkey_len, const zval *val, const uint ttl, const int exclusive TSRMLS_DC);
extern int _apc_update(char *strkey, int strkey_len, apc_cache_updater_t updater, void* data TSRMLS_DC);
static int update_bytes_processed(apc_cache_t* cache, apc_cache_entry_t* entry, void* data) {
int *bytes_ptr = (int*)data;
zval* val = entry->data.user.val;
if(Z_TYPE_P(val) == IS_ARRAY) {
HashTable *ht = val->value.ht;
Bucket* curr = NULL;
for (curr = ht->pListHead; curr != NULL; curr = curr->pListNext) {
if(curr->nKeyLength == 8 &&
(!memcmp(curr->arKey, "current", curr->nKeyLength))) {
zval* current = ((zval**)curr->pData)[0];
current->value.lval = *bytes_ptr;
return 1;
}
}
}
return 0;
}
static double my_time() {
struct timeval a;
double t;
gettimeofday(&a, NULL);
t = a.tv_sec + (a.tv_usec/1000000.00);
return t;
}
#define RFC1867_DATA(name) \
((request_data)->name)
int apc_rfc1867_progress(uint event, void *event_data, void **extra TSRMLS_DC) {
apc_rfc1867_data *request_data = &APCG(rfc1867_data);
zval *track = NULL;
switch (event) {
case MULTIPART_EVENT_START:
{
multipart_event_start *data = (multipart_event_start *) event_data;
RFC1867_DATA(content_length) = data->content_length;
RFC1867_DATA(tracking_key)[0] = '\0';
RFC1867_DATA(name)[0] = '\0';
RFC1867_DATA(cancel_upload) = 0;
RFC1867_DATA(temp_filename) = NULL;
RFC1867_DATA(filename)[0] = '\0';
RFC1867_DATA(key_length) = 0;
RFC1867_DATA(start_time) = my_time();
RFC1867_DATA(bytes_processed) = 0;
RFC1867_DATA(prev_bytes_processed) = 0;
RFC1867_DATA(rate) = 0;
RFC1867_DATA(update_freq) = (int) APCG(rfc1867_freq);
RFC1867_DATA(started) = 0;
if(RFC1867_DATA(update_freq) < 0) { // frequency is a percentage, not bytes
RFC1867_DATA(update_freq) = (int) (RFC1867_DATA(content_length) * APCG(rfc1867_freq) / 100);
}
}
break;
case MULTIPART_EVENT_FORMDATA:
{
int prefix_len = strlen(APCG(rfc1867_prefix));
multipart_event_formdata *data = (multipart_event_formdata *) event_data;
if(data->name && !strncasecmp(data->name, APCG(rfc1867_name), strlen(APCG(rfc1867_name)))
&& data->value && data->length) {
if(data->length >= sizeof(RFC1867_DATA(tracking_key)) - prefix_len) {
apc_warning("Key too long for '%s'. Maximum size is '%d' characters." TSRMLS_CC,
APCG(rfc1867_name),
sizeof(RFC1867_DATA(tracking_key)) - prefix_len);
break;
}
if(RFC1867_DATA(started)) {
apc_warning("Upload progress key '%s' should be before the file upload entry in the form." TSRMLS_CC,
APCG(rfc1867_name));
break;
}
strlcat(RFC1867_DATA(tracking_key), APCG(rfc1867_prefix), 63);
strlcat(RFC1867_DATA(tracking_key), *data->value, 63);
RFC1867_DATA(key_length) = data->length + prefix_len;
RFC1867_DATA(bytes_processed) = data->post_bytes_processed;
}
}
break;
case MULTIPART_EVENT_FILE_START:
{
RFC1867_DATA(started) = 1;
if(*RFC1867_DATA(tracking_key)) {
multipart_event_file_start *data = (multipart_event_file_start *) event_data;
RFC1867_DATA(bytes_processed) = data->post_bytes_processed;
strlcpy(RFC1867_DATA(filename),*data->filename,128);
RFC1867_DATA(temp_filename) = NULL;
strlcpy(RFC1867_DATA(name),data->name,64);
ALLOC_INIT_ZVAL(track);
array_init(track);
add_assoc_long(track, "total", RFC1867_DATA(content_length));
add_assoc_long(track, "current", RFC1867_DATA(bytes_processed));
add_assoc_string(track, "filename", RFC1867_DATA(filename), 1);
add_assoc_string(track, "name", RFC1867_DATA(name), 1);
add_assoc_long(track, "done", 0);
add_assoc_double(track, "start_time", RFC1867_DATA(start_time));
_apc_store(RFC1867_DATA(tracking_key), RFC1867_DATA(key_length)+1, track, APCG(rfc1867_ttl), 0 TSRMLS_CC);
zval_ptr_dtor(&track);
}
}
break;
case MULTIPART_EVENT_FILE_DATA:
if(*RFC1867_DATA(tracking_key)) {
multipart_event_file_data *data = (multipart_event_file_data *) event_data;
RFC1867_DATA(bytes_processed) = data->post_bytes_processed;
if(RFC1867_DATA(bytes_processed) - RFC1867_DATA(prev_bytes_processed) > (uint) RFC1867_DATA(update_freq)) {
if(!_apc_update(RFC1867_DATA(tracking_key), RFC1867_DATA(key_length), update_bytes_processed, &RFC1867_DATA(bytes_processed) TSRMLS_CC)) {
ALLOC_INIT_ZVAL(track);
array_init(track);
add_assoc_long(track, "total", RFC1867_DATA(content_length));
add_assoc_long(track, "current", RFC1867_DATA(bytes_processed));
add_assoc_string(track, "filename", RFC1867_DATA(filename), 1);
add_assoc_string(track, "name", RFC1867_DATA(name), 1);
add_assoc_long(track, "done", 0);
add_assoc_double(track, "start_time", RFC1867_DATA(start_time));
_apc_store(RFC1867_DATA(tracking_key), RFC1867_DATA(key_length)+1, track, APCG(rfc1867_ttl), 0 TSRMLS_CC);
zval_ptr_dtor(&track);
}
RFC1867_DATA(prev_bytes_processed) = RFC1867_DATA(bytes_processed);
}
}
break;
case MULTIPART_EVENT_FILE_END:
if(*RFC1867_DATA(tracking_key)) {
multipart_event_file_end *data = (multipart_event_file_end *) event_data;
RFC1867_DATA(bytes_processed) = data->post_bytes_processed;
RFC1867_DATA(cancel_upload) = data->cancel_upload;
if(data->temp_filename) {
RFC1867_DATA(temp_filename) = data->temp_filename;
} else {
RFC1867_DATA(temp_filename) = "";
}
ALLOC_INIT_ZVAL(track);
array_init(track);
add_assoc_long(track, "total", RFC1867_DATA(content_length));
add_assoc_long(track, "current", RFC1867_DATA(bytes_processed));
add_assoc_string(track, "filename", RFC1867_DATA(filename), 1);
add_assoc_string(track, "name", RFC1867_DATA(name), 1);
add_assoc_string(track, "temp_filename", RFC1867_DATA(temp_filename), 1);
add_assoc_long(track, "cancel_upload", RFC1867_DATA(cancel_upload));
add_assoc_long(track, "done", 0);
add_assoc_double(track, "start_time", RFC1867_DATA(start_time));
_apc_store(RFC1867_DATA(tracking_key), RFC1867_DATA(key_length)+1, track, APCG(rfc1867_ttl), 0 TSRMLS_CC);
zval_ptr_dtor(&track);
}
break;
case MULTIPART_EVENT_END:
if(*RFC1867_DATA(tracking_key)) {
double now = my_time();
multipart_event_end *data = (multipart_event_end *) event_data;
RFC1867_DATA(bytes_processed) = data->post_bytes_processed;
if(now>RFC1867_DATA(start_time)) RFC1867_DATA(rate) = 8.0*RFC1867_DATA(bytes_processed)/(now-RFC1867_DATA(start_time));
else RFC1867_DATA(rate) = 8.0*RFC1867_DATA(bytes_processed); /* Too quick */
ALLOC_INIT_ZVAL(track);
array_init(track);
add_assoc_long(track, "total", RFC1867_DATA(content_length));
add_assoc_long(track, "current", RFC1867_DATA(bytes_processed));
add_assoc_double(track, "rate", RFC1867_DATA(rate));
add_assoc_string(track, "filename", RFC1867_DATA(filename), 1);
add_assoc_string(track, "name", RFC1867_DATA(name), 1);
add_assoc_long(track, "cancel_upload", RFC1867_DATA(cancel_upload));
add_assoc_long(track, "done", 1);
add_assoc_double(track, "start_time", RFC1867_DATA(start_time));
_apc_store(RFC1867_DATA(tracking_key), RFC1867_DATA(key_length)+1, track, APCG(rfc1867_ttl), 0 TSRMLS_CC);
zval_ptr_dtor(&track);
}
break;
}
return SUCCESS;
}
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim>600: expandtab sw=4 ts=4 sts=4 fdm=marker
* vim<600: expandtab sw=4 ts=4 sts=4
*/
| 47.729958 | 158 | 0.54756 |
d9956f7905133f5435a903424ee785ca76a0ea86 | 32,707 | c | C | Software/Azure_RTOS_Example2/FileX/src/fx_file_extended_allocate.c | Indemsys/Backup-controller_BACKPMAN-v2.0 | e5b22f4bdd45fe04542fab6c1309de4ff3d3c009 | [
"MIT"
] | 4 | 2021-11-05T11:50:50.000Z | 2022-03-16T05:40:57.000Z | Software/Azure_RTOS_USB_MSC/Middlewares/ST/filex/common/src/fx_file_extended_allocate.c | Indemsys/Backup-controller_BACKPMAN-v2.0 | e5b22f4bdd45fe04542fab6c1309de4ff3d3c009 | [
"MIT"
] | null | null | null | Software/Azure_RTOS_USB_MSC/Middlewares/ST/filex/common/src/fx_file_extended_allocate.c | Indemsys/Backup-controller_BACKPMAN-v2.0 | e5b22f4bdd45fe04542fab6c1309de4ff3d3c009 | [
"MIT"
] | 2 | 2021-09-27T10:49:43.000Z | 2021-11-27T02:35:42.000Z | /**************************************************************************/
/* */
/* Copyright (c) Microsoft Corporation. All rights reserved. */
/* */
/* This software is licensed under the Microsoft Software License */
/* Terms for Microsoft Azure RTOS. Full text of the license can be */
/* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
/* and in the root directory of this software. */
/* */
/**************************************************************************/
/**************************************************************************/
/**************************************************************************/
/** */
/** FileX Component */
/** */
/** File */
/** */
/**************************************************************************/
/**************************************************************************/
#define FX_SOURCE_CODE
/* Include necessary system files. */
#include "fx_api.h"
#include "fx_system.h"
#include "fx_file.h"
#include "fx_utility.h"
#include "fx_directory.h"
#ifdef FX_ENABLE_FAULT_TOLERANT
#include "fx_fault_tolerant.h"
#endif /* FX_ENABLE_FAULT_TOLERANT */
/**************************************************************************/
/* */
/* FUNCTION RELEASE */
/* */
/* _fx_file_extended_allocate PORTABLE C */
/* 6.1 */
/* AUTHOR */
/* */
/* William E. Lamie, Microsoft Corporation */
/* */
/* DESCRIPTION */
/* */
/* This function attempts to allocate the number of consecutive */
/* clusters required to satisfy the user's request. If there are */
/* enough clusters, the clusters are allocated and linked to the file. */
/* Otherwise, if there are not enough consecutive clusters, an error */
/* code is returned to the caller. */
/* */
/* INPUT */
/* */
/* file_ptr File control block pointer */
/* size Number of bytes to allocate */
/* */
/* OUTPUT */
/* */
/* return status */
/* */
/* CALLS */
/* */
/* _fx_directory_entry_write Update directory entry */
/* _fx_utility_exFAT_bitmap_flush Flush exFAT allocation bitmap */
/* _fx_utility_exFAT_bitmap_free_cluster_find */
/* Find exFAT free cluster */
/* _fx_utility_exFAT_cluster_state_get Get cluster state */
/* _fx_utility_exFAT_cluster_state_set Set cluster state */
/* _fx_utility_FAT_entry_read Read a FAT entry */
/* _fx_utility_FAT_entry_write Write a FAT entry */
/* _fx_utility_FAT_flush Flush written FAT entries */
/* _fx_utility_logical_sector_flush Flush the written log sector */
/* _fx_fault_tolerant_transaction_start Start fault tolerant */
/* transaction */
/* _fx_fault_tolerant_transaction_end End fault tolerant transaction*/
/* _fx_fault_tolerant_recover Recover FAT chain */
/* _fx_fault_tolerant_reset_log_file Reset the log file */
/* _fx_fault_tolerant_set_FAT_chain Set data of FAT chain */
/* */
/* CALLED BY */
/* */
/* Application Code */
/* */
/* RELEASE HISTORY */
/* */
/* DATE NAME DESCRIPTION */
/* */
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
/* 09-30-2020 William E. Lamie Modified comment(s), */
/* resulting in version 6.1 */
/* */
/**************************************************************************/
UINT _fx_file_extended_allocate(FX_FILE *file_ptr, ULONG64 size)
{
UINT status;
ULONG i;
UINT found;
ULONG bytes_per_cluster;
ULONG FAT_index;
ULONG FAT_value;
ULONG clusters;
FX_MEDIA *media_ptr;
#ifdef FX_ENABLE_EXFAT
UCHAR cluster_state;
#endif /* FX_ENABLE_EXFAT */
#ifdef TX_ENABLE_EVENT_TRACE
TX_TRACE_BUFFER_ENTRY *trace_event;
ULONG trace_timestamp;
#endif
/* First, determine if the file is still open. */
if (file_ptr -> fx_file_id != FX_FILE_ID)
{
/* Return the file not open error status. */
return(FX_NOT_OPEN);
}
/* Setup pointer to media structure. */
media_ptr = file_ptr -> fx_file_media_ptr;
#ifndef FX_MEDIA_STATISTICS_DISABLE
/* Increment the number of times this service has been called. */
media_ptr -> fx_media_file_allocates++;
#endif
/* Make sure this file is open for writing. */
if (file_ptr -> fx_file_open_mode != FX_OPEN_FOR_WRITE)
{
/* Return the access error exception - a write was attempted from
a file opened for reading! */
return(FX_ACCESS_ERROR);
}
/* Determine if the requested allocation is for zero bytes. */
if (size == 0)
{
/* Return a successful completion - nothing needs to be done. */
return(FX_SUCCESS);
}
/* Setup pointer to associated media control block. */
media_ptr = file_ptr -> fx_file_media_ptr;
/* If trace is enabled, insert this event into the trace buffer. */
FX_TRACE_IN_LINE_INSERT(FX_TRACE_FILE_ALLOCATE, file_ptr, size, file_ptr -> fx_file_current_available_size, 0, FX_TRACE_FILE_EVENTS, &trace_event, &trace_timestamp)
/* Protect against other threads accessing the media. */
FX_PROTECT
#ifdef FX_ENABLE_FAULT_TOLERANT
/* Start transaction. */
_fx_fault_tolerant_transaction_start(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Check for write protect at the media level (set by driver). */
if (media_ptr -> fx_media_driver_write_protect)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Return write protect error. */
return(FX_WRITE_PROTECT);
}
/* Calculate the number of bytes per cluster. */
bytes_per_cluster = ((ULONG)media_ptr -> fx_media_bytes_per_sector) *
((ULONG)media_ptr -> fx_media_sectors_per_cluster);
/* Check for invalid value. */
if (bytes_per_cluster == 0)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Invalid media, return error. */
return(FX_MEDIA_INVALID);
}
/* Calculate the number of consecutive clusters needed to satisfy this
request. */
clusters = (ULONG)(((size + bytes_per_cluster - 1) / bytes_per_cluster));
/* Determine if cluster count is 0. */
if (clusters == 0)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Size overflow when rounding to the next cluster, return an error status. */
return(FX_NO_MORE_SPACE);
}
/* Determine if there are enough available clusters on the media. */
if (clusters > media_ptr -> fx_media_available_clusters)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Not enough clusters, return an error status. */
return(FX_NO_MORE_SPACE);
}
/* Determine if the requested file allocation would exceed the physical limit of the file. */
if (((file_ptr -> fx_file_current_available_size + (((ULONG64) clusters) * ((ULONG64) bytes_per_cluster))) < file_ptr -> fx_file_current_available_size) ||
((file_ptr -> fx_file_current_available_size + (((ULONG64) clusters) * ((ULONG64) bytes_per_cluster))) > 0xFFFFFFFFULL))
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Return the no more space error, since the new file size would be larger than
the 32-bit field to represent it in the file's directory entry. */
return(FX_NO_MORE_SPACE);
}
/* Now we need to find the consecutive clusters. */
FAT_index = FX_FAT_ENTRY_START;
found = FX_FALSE;
#ifdef FX_ENABLE_EXFAT
if ((file_ptr -> fx_file_dir_entry.fx_dir_entry_dont_use_fat & 1) &&
(file_ptr -> fx_file_last_physical_cluster > FX_FAT_ENTRY_START) &&
(file_ptr -> fx_file_last_physical_cluster < media_ptr -> fx_media_total_clusters - clusters + FX_FAT_ENTRY_START))
{
found = FX_TRUE;
/* Try to keep clusters consecutive. */
for (FAT_index = file_ptr -> fx_file_last_physical_cluster + 1;
FAT_index < clusters + file_ptr -> fx_file_last_physical_cluster + 1;
FAT_index++)
{
/* Get cluster state. */
status = _fx_utility_exFAT_cluster_state_get(media_ptr, FAT_index, &cluster_state);
/* Check for a successful status. */
if (status != FX_SUCCESS)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Return the error status. */
return(status);
}
/* Determine if the entry is free. */
if (cluster_state == FX_EXFAT_BITMAP_CLUSTER_OCCUPIED)
{
found = FX_FALSE;
break;
}
}
FAT_index = file_ptr -> fx_file_last_physical_cluster + 1;
}
if (!found)
{
#endif /* FX_ENABLE_EXFAT */
while (FAT_index <= (media_ptr -> fx_media_total_clusters - clusters + FX_FAT_ENTRY_START))
{
/* Determine if enough consecutive FAT entries are available. */
i = 0;
#ifdef FX_ENABLE_EXFAT
if (media_ptr -> fx_media_FAT_type == FX_exFAT)
{
do
{
/* Get cluster state. */
status = _fx_utility_exFAT_cluster_state_get(media_ptr, (FAT_index + i), &cluster_state);
/* Check for a successful status. */
if (status != FX_SUCCESS)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Return the error status. */
return(status);
}
/* Determine if the entry is free. */
if (cluster_state == FX_EXFAT_BITMAP_CLUSTER_OCCUPIED)
{
break;
}
/* Otherwise, increment the consecutive FAT indices. */
i++;
} while (i < clusters);
}
else
{
#endif /* FX_ENABLE_EXFAT */
do
{
/* Read a FAT entry. */
status = _fx_utility_FAT_entry_read(media_ptr, (FAT_index + i), &FAT_value);
/* Check for a successful status. */
if (status != FX_SUCCESS)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Return the error status. */
return(status);
}
/* Determine if the entry is free. */
if (FAT_value != FX_FREE_CLUSTER)
{
break;
}
/* Otherwise, increment the consecutive FAT indices. */
i++;
} while (i < clusters);
#ifdef FX_ENABLE_EXFAT
}
#endif /* FX_ENABLE_EXFAT */
/* Determine if we found enough FAT entries. */
if (i >= clusters)
{
/* Yes, we have found enough FAT entries - set the found
flag and get out of this loop. */
found = FX_TRUE;
break;
}
else
{
#ifdef FX_ENABLE_EXFAT
if (media_ptr -> fx_media_FAT_type == FX_exFAT)
{
/* Find free cluster from exFAT media. */
status = _fx_utility_exFAT_bitmap_free_cluster_find(media_ptr,
FAT_index + i + 1,
&FAT_value);
if (status != FX_SUCCESS)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Return the error status. */
return(status);
}
if (FAT_value < FAT_index + i + 1)
{
/* If we wrapped. */
FAT_index = media_ptr -> fx_media_total_clusters + FX_FAT_ENTRY_START;
}
else
{
FAT_index = FAT_value;
}
}
else
{
#endif /* FX_ENABLE_EXFAT */
/* Position to the next possibly free FAT entry. */
FAT_index = FAT_index + i + 1;
#ifdef FX_ENABLE_EXFAT
}
#endif /* FX_ENABLE_EXFAT */
}
}
#ifdef FX_ENABLE_EXFAT
}
#endif
/* Determine if we found enough consecutive clusters to satisfy the
request. */
if (found)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
if (media_ptr -> fx_media_fault_tolerant_enabled)
{
/* Record the action that is about to take place. This information
would aid the undo process should fault condition happens. */
media_ptr -> fx_media_fault_tolerant_state |= FX_FAULT_TOLERANT_STATE_SET_FAT_CHAIN;
_fx_fault_tolerant_set_FAT_chain(media_ptr, FX_FALSE, file_ptr -> fx_file_last_physical_cluster,
FAT_index, media_ptr -> fx_media_fat_last, media_ptr -> fx_media_fat_last);
}
#endif /* FX_ENABLE_FAULT_TOLERANT */
#ifdef FX_ENABLE_EXFAT
if (file_ptr -> fx_file_dir_entry.fx_dir_entry_dont_use_fat & 1)
{
if ((file_ptr -> fx_file_total_clusters) &&
(FAT_index != file_ptr -> fx_file_last_physical_cluster + 1))
{
/* Clusters are not consecutive. */
file_ptr -> fx_file_dir_entry.fx_dir_entry_dont_use_fat &= (CHAR)0xfe; /* Set 0bit to 0 */
/* Rebuild FAT. */
FAT_value = file_ptr -> fx_file_dir_entry.fx_dir_entry_cluster +
file_ptr -> fx_file_total_clusters - 1; /* Last cluster */
for (i = file_ptr -> fx_file_dir_entry.fx_dir_entry_cluster; i < FAT_value; ++i)
{
status = _fx_utility_FAT_entry_write(media_ptr, i, i + 1);
if (status != FX_SUCCESS)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Return the bad status. */
return(status);
}
}
/* Close chain. */
status = _fx_utility_FAT_entry_write(media_ptr, FAT_value, media_ptr -> fx_media_fat_last);
if (status != FX_SUCCESS)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Return the bad status. */
return(status);
}
#ifdef FX_ENABLE_FAULT_TOLERANT
if (media_ptr -> fx_media_fault_tolerant_enabled)
{
/* Clear undo phase. */
media_ptr -> fx_media_fault_tolerant_state &= (UCHAR)(~FX_FAULT_TOLERANT_STATE_SET_FAT_CHAIN & 0xff);
}
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Update stream. */
status = _fx_directory_exFAT_entry_write(
media_ptr, &(file_ptr -> fx_file_dir_entry), UPDATE_STREAM);
if (status != FX_SUCCESS)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Return the bad status. */
return(status);
}
#ifdef FX_ENABLE_FAULT_TOLERANT
if (media_ptr -> fx_media_fault_tolerant_enabled)
{
/* Set undo phase. */
media_ptr -> fx_media_fault_tolerant_state |= FX_FAULT_TOLERANT_STATE_SET_FAT_CHAIN;
}
#endif /* FX_ENABLE_FAULT_TOLERANT */
}
}
#endif /* FX_ENABLE_EXFAT */
/* Update the link pointers in the new clusters. */
for (i = 0; i < (clusters - 1); i++)
{
#ifdef FX_ENABLE_EXFAT
if (!(file_ptr -> fx_file_dir_entry.fx_dir_entry_dont_use_fat & 1)
#ifdef FX_ENABLE_FAULT_TOLERANT
|| (media_ptr -> fx_media_fault_tolerant_enabled == FX_TRUE)
#endif /* FX_ENABLE_FAULT_TOLERANT */
)
{
#endif /* FX_ENABLE_EXFAT */
/* Update the cluster links. Since the allocation is
sequential, we just have to link each FAT entry to the
next one. */
status = _fx_utility_FAT_entry_write(media_ptr, FAT_index + i, FAT_index + i + 1);
/* Check for a bad status. */
if (status != FX_SUCCESS)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Return the error status. */
return(status);
}
#ifdef FX_ENABLE_EXFAT
}
if (media_ptr -> fx_media_FAT_type == FX_exFAT)
{
/* Mark the cluster as used. */
status = _fx_utility_exFAT_cluster_state_set(media_ptr, FAT_index + i, FX_EXFAT_BITMAP_CLUSTER_OCCUPIED);
/* Check for a bad status. */
if (status != FX_SUCCESS)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Return the error status. */
return(status);
}
}
#endif /* FX_ENABLE_EXFAT */
}
#ifdef FX_ENABLE_EXFAT
if (!(file_ptr -> fx_file_dir_entry.fx_dir_entry_dont_use_fat & 1))
{
#endif /* FX_ENABLE_EXFAT */
/* Now place an EOF in the last cluster entry. */
status = _fx_utility_FAT_entry_write(media_ptr, FAT_index + clusters - 1, media_ptr -> fx_media_fat_last);
/* Check for a bad status. */
if (status != FX_SUCCESS)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Return the error status. */
return(status);
}
#ifdef FX_ENABLE_EXFAT
}
if (media_ptr -> fx_media_FAT_type == FX_exFAT)
{
/* Mark the cluster as used. */
status = _fx_utility_exFAT_cluster_state_set(media_ptr, FAT_index + clusters - 1, FX_EXFAT_BITMAP_CLUSTER_OCCUPIED);
/* Check for a bad status. */
if (status != FX_SUCCESS)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Return the error status. */
return(status);
}
}
#endif /* FX_ENABLE_EXFAT */
#ifdef FX_FAULT_TOLERANT
/* Flush the cached individual FAT entries */
_fx_utility_FAT_flush(media_ptr);
#ifdef FX_ENABLE_EXFAT
if (media_ptr -> fx_media_FAT_type == FX_exFAT)
{
_fx_utility_exFAT_bitmap_flush(media_ptr);
}
#endif /* FX_ENABLE_EXFAT */
#endif
/* Actually link up the new clusters to the file. */
/* Determine if there are already clusters allocated for this file. */
if (file_ptr -> fx_file_total_clusters)
{
#ifdef FX_ENABLE_EXFAT
if (!(file_ptr -> fx_file_dir_entry.fx_dir_entry_dont_use_fat & 1))
{
#endif /* FX_ENABLE_EXFAT */
/* Linkup the last cluster. */
status = _fx_utility_FAT_entry_write(media_ptr,
file_ptr -> fx_file_last_physical_cluster, FAT_index);
/* Check for a bad status. */
if (status != FX_SUCCESS)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Return the error status. */
return(status);
}
#ifdef FX_ENABLE_EXFAT
}
#endif /* FX_ENABLE_EXFAT */
/* Determine if we are adding a sector after a write filled the previously
allocated cluster exactly. */
if ((file_ptr -> fx_file_current_relative_sector >=
(media_ptr -> fx_media_sectors_per_cluster - 1)) &&
(file_ptr -> fx_file_current_logical_offset >=
media_ptr -> fx_media_bytes_per_sector))
{
/* Yes, we need to adjust all of the pertinent file parameters for
access into this newly allocated cluster. */
file_ptr -> fx_file_current_physical_cluster = FAT_index;
file_ptr -> fx_file_current_relative_cluster++;
file_ptr -> fx_file_current_relative_sector = 0;
file_ptr -> fx_file_current_logical_sector = ((ULONG)media_ptr -> fx_media_data_sector_start) +
(((ULONG64)(FAT_index - FX_FAT_ENTRY_START)) *
((ULONG)media_ptr -> fx_media_sectors_per_cluster));
file_ptr -> fx_file_current_logical_offset = 0;
}
}
else
{
/* These new clusters are also the first! Setup the initial
file parameters. */
file_ptr -> fx_file_first_physical_cluster = FAT_index;
file_ptr -> fx_file_current_physical_cluster = file_ptr -> fx_file_first_physical_cluster;
file_ptr -> fx_file_current_relative_cluster = 0;
file_ptr -> fx_file_current_logical_sector = ((ULONG)media_ptr -> fx_media_data_sector_start) +
(((ULONG64)(file_ptr -> fx_file_first_physical_cluster - FX_FAT_ENTRY_START)) *
((ULONG)media_ptr -> fx_media_sectors_per_cluster));
file_ptr -> fx_file_current_logical_offset = 0;
file_ptr -> fx_file_current_file_offset = 0;
/* Update the first cluster in the directory entry. */
file_ptr -> fx_file_dir_entry.fx_dir_entry_cluster = FAT_index;
}
/* Remember the last physical cluster. */
file_ptr -> fx_file_last_physical_cluster = FAT_index + clusters - 1;
#ifdef FX_ENABLE_EXFAT
if (file_ptr -> fx_file_current_available_size > (file_ptr -> fx_file_current_available_size + (bytes_per_cluster * clusters)))
{
/* 64-bit wrap around condition is present. Just set the available file size to all ones, which is
the maximum file size. */
file_ptr -> fx_file_current_available_size = 0xFFFFFFFFFFFFFFFFULL;
}
#endif /* FX_ENABLE_EXFAT */
/* Check for wrap-around when updating the available size. */
#ifdef FX_ENABLE_EXFAT
if ((media_ptr -> fx_media_FAT_type != FX_exFAT) &&
(file_ptr -> fx_file_current_available_size + (bytes_per_cluster * clusters) > 0xFFFFFFFFUL))
{
/* 32-bit wrap around condition is present. Just set the available file size to all ones, which is
the maximum file size. */
file_ptr -> fx_file_current_available_size = ((ULONG)0xFFFFFFFF);
}
else
{
/* Normal condition, update the available size. */
file_ptr -> fx_file_current_available_size =
file_ptr -> fx_file_current_available_size + (bytes_per_cluster * clusters);
}
#else
/* Update the available size. */
file_ptr -> fx_file_current_available_size =
file_ptr -> fx_file_current_available_size + (bytes_per_cluster * clusters);
#endif /* FX_ENABLE_EXFAT */
/* Increment the total clusters for this file. */
file_ptr -> fx_file_total_clusters =
file_ptr -> fx_file_total_clusters + clusters;
/* Decrease the available clusters on the media. */
media_ptr -> fx_media_available_clusters =
media_ptr -> fx_media_available_clusters - clusters;
#if defined(FX_UPDATE_FILE_SIZE_ON_ALLOCATE) || defined(FX_ENABLE_FAULT_TOLERANT)
/* Set the file size the current size plus what what was added. */
file_ptr -> fx_file_current_file_size += size;
/* Copy the new file size into the directory entry. */
file_ptr -> fx_file_dir_entry.fx_dir_entry_file_size = file_ptr -> fx_file_current_file_size;
#endif
#ifdef FX_ENABLE_FAULT_TOLERANT
if (media_ptr -> fx_media_fault_tolerant_enabled)
{
/* Clear undo phase. */
media_ptr -> fx_media_fault_tolerant_state &= (UCHAR)(~FX_FAULT_TOLERANT_STATE_SET_FAT_CHAIN & 0xff);
}
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Update the trace event with the new size. */
FX_TRACE_EVENT_UPDATE(trace_event, trace_timestamp, FX_TRACE_FILE_ALLOCATE, 0, 0, 0, file_ptr -> fx_file_current_file_size);
/* Write the directory entry to the media. */
#ifdef FX_ENABLE_EXFAT
if (media_ptr -> fx_media_FAT_type == FX_exFAT)
{
status = _fx_directory_exFAT_entry_write(
media_ptr, &(file_ptr -> fx_file_dir_entry), UPDATE_STREAM);
}
else
{
#endif /* FX_ENABLE_EXFAT */
status = _fx_directory_entry_write(media_ptr, &(file_ptr -> fx_file_dir_entry));
#ifdef FX_ENABLE_EXFAT
}
#endif /* FX_ENABLE_EXFAT */
/* Check for a good status. */
if (status != FX_SUCCESS)
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Return the error status. */
return(status);
}
}
else
{
#ifdef FX_ENABLE_FAULT_TOLERANT
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Not enough contiguous space on the media. Return error status. */
return(FX_NO_MORE_SPACE);
}
#ifdef FX_FAULT_TOLERANT
/* Flush the cached individual FAT entries */
_fx_utility_FAT_flush(media_ptr);
#endif
/* Flush the internal logical sector cache. */
status = _fx_utility_logical_sector_flush(media_ptr, ((ULONG64) 1), (ULONG64)(media_ptr -> fx_media_sectors_per_FAT), FX_FALSE);
#ifdef FX_ENABLE_FAULT_TOLERANT
/* Check for a bad status. */
if (status != FX_SUCCESS)
{
FX_FAULT_TOLERANT_TRANSACTION_FAIL(media_ptr);
/* Release media protection. */
FX_UNPROTECT
/* Return the bad status. */
return(status);
}
if (media_ptr -> fx_media_fault_tolerant_enabled)
{
/* Copy the new file size into the directory entry. */
file_ptr -> fx_file_dir_entry.fx_dir_entry_file_size = file_ptr -> fx_file_current_file_size;
}
/* End transaction. */
status = _fx_fault_tolerant_transaction_end(media_ptr);
#endif /* FX_ENABLE_FAULT_TOLERANT */
/* Release media protection. */
FX_UNPROTECT
/* Return status to the caller. */
return(status);
}
| 37.508028 | 168 | 0.513254 |
d996104e544e70d92c59a13204345bbbad59e299 | 338 | h | C | Engine/Source/Runtime/Core/Public/Math/Transform.h | windystrife/UnrealEngine_NVIDIAGameWork | b50e6338a7c5b26374d66306ebc7807541ff815e | [
"MIT"
] | 1 | 2022-01-29T18:36:12.000Z | 2022-01-29T18:36:12.000Z | Engine/Source/Runtime/Core/Public/Math/Transform.h | windystrife/UnrealEngine_NVIDIAGameWork | b50e6338a7c5b26374d66306ebc7807541ff815e | [
"MIT"
] | null | null | null | Engine/Source/Runtime/Core/Public/Math/Transform.h | windystrife/UnrealEngine_NVIDIAGameWork | b50e6338a7c5b26374d66306ebc7807541ff815e | [
"MIT"
] | null | null | null | // Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#pragma once
/**
* Include the current implementation of a FTransform, depending on the vector processing mode
*/
#include "CoreTypes.h"
#include "Math/Quat.h"
#include "Math/ScalarRegister.h"
#include "Math/TransformVectorized.h"
#include "Math/TransformNonVectorized.h"
| 24.142857 | 94 | 0.763314 |
d996bbae05c81a0482a2dc88de8c21f3bb0e71f2 | 234 | h | C | PirateHegemonyOnline/Utilities/ColorDefine.h | irons163/PirateHegemonyOnline | 42ececbf2bc9c249fcee8fb30e4bef170184cb57 | [
"MIT"
] | 5 | 2020-09-15T08:06:52.000Z | 2021-03-26T02:06:05.000Z | PirateHegemonyOnline/Utilities/ColorDefine.h | irons163/PirateHegemonyOnline | 42ececbf2bc9c249fcee8fb30e4bef170184cb57 | [
"MIT"
] | 2 | 2020-09-17T08:13:57.000Z | 2020-10-05T13:03:59.000Z | PirateHegemonyOnline/Utilities/ColorDefine.h | irons163/PirateHegemonyOnline | 42ececbf2bc9c249fcee8fb30e4bef170184cb57 | [
"MIT"
] | null | null | null | //
// ColorDefine.h
// Test
//
// Created by Phil on 2015/10/13.
// Copyright © 2015年 Phil. All rights reserved.
//
#define NavigationBarBGColor @"ffa7e7d9"
#define NavigationBarBGColor_OnLine @"00b4f5"
| 16.714286 | 55 | 0.628205 |
d99b3e1341989a81102fb9167b24659ffff6e360 | 46,965 | c | C | interfaces/tests/interlocked_int/interlocked_int.c | Azure/azure-c-pal | f7032c4bd4e62b9daff1f48d9d8cd838b32f07f5 | [
"MIT"
] | 1 | 2020-05-20T13:39:31.000Z | 2020-05-20T13:39:31.000Z | interfaces/tests/interlocked_int/interlocked_int.c | Azure/azure-c-pal | f7032c4bd4e62b9daff1f48d9d8cd838b32f07f5 | [
"MIT"
] | 10 | 2020-06-09T00:45:02.000Z | 2020-10-27T21:18:29.000Z | interfaces/tests/interlocked_int/interlocked_int.c | Azure/azure-c-pal | f7032c4bd4e62b9daff1f48d9d8cd838b32f07f5 | [
"MIT"
] | 2 | 2020-07-08T15:09:05.000Z | 2020-10-08T02:53:21.000Z | //Copyright(c) Microsoft.All rights reserved.
//Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include <stddef.h>
#include <stdint.h>
#include "testrunnerswitcher.h"
static TEST_MUTEX_HANDLE g_testByTest;
#include "c_pal/interlocked.h"
BEGIN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
TEST_SUITE_INITIALIZE(a)
{
g_testByTest = TEST_MUTEX_CREATE();
ASSERT_IS_NOT_NULL(g_testByTest);
}
TEST_SUITE_CLEANUP(b)
{
TEST_MUTEX_DESTROY(g_testByTest);
}
TEST_FUNCTION_INITIALIZE(c)
{
if (TEST_MUTEX_ACQUIRE(g_testByTest))
{
ASSERT_FAIL("our mutex is ABANDONED. Failure in test framework");
}
}
TEST_FUNCTION_CLEANUP(d)
{
TEST_MUTEX_RELEASE(g_testByTest);
}
/*Tests_SRS_INTERLOCKED_43_001: [ interlocked_add shall atomically add 32-bit integers *addend and value and store the result in *addend.]*/
/*Tests_SRS_INTERLOCKED_43_032: [interlocked_add shall return the result of the addition.]*/
TEST_FUNCTION(interlocked_add_does_addition)
{
///arrange
volatile_atomic int32_t addend;
interlocked_exchange(&addend, INT32_MAX);
int32_t value = INT32_MIN;
///act
int32_t return_val = interlocked_add(&addend, value);
///assert
ASSERT_ARE_EQUAL(int32_t, -1, interlocked_or(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int32_t, -1, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_001: [ interlocked_add shall atomically add 32-bit integers *addend and value and store the result in *addend.]*/
/*Tests_SRS_INTERLOCKED_43_032: [interlocked_add shall return the result of the addition.]*/
TEST_FUNCTION(interlocked_add_overflows_upper_bound)
{
///arrange
volatile_atomic int32_t addend;
interlocked_exchange(&addend, INT32_MAX);
int32_t value = 1;
///act
int32_t return_val = interlocked_add(&addend, value);
///assert
ASSERT_ARE_EQUAL(int32_t, INT32_MIN, interlocked_or(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int32_t, INT32_MIN, return_val, "Return value is incorrect.");
}
/*Tests_SRS_INTERLOCKED_43_001: [ interlocked_add shall atomically add 32-bit integers *addend and value and store the result in *addend.]*/
/*Tests_SRS_INTERLOCKED_43_032: [interlocked_add shall return the result of the addition.]*/
TEST_FUNCTION(interlocked_add_underflows_lower_bound)
{
///arrange
volatile_atomic int32_t addend;
interlocked_exchange(&addend, INT32_MIN);
int32_t value = -1;
///act
int32_t return_val = interlocked_add(&addend, value);
///assert
ASSERT_ARE_EQUAL(int32_t, INT32_MAX, interlocked_or(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int32_t, INT32_MAX, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_065: [ interlocked_add_64 shall atomically add 64-bit integers *addend and value and store the result in *addend. ]*/
/*Tests_SRS_INTERLOCKED_43_066: [ interlocked_add_64 shall return the result of the addition. ]*/
TEST_FUNCTION(interlocked_add_64_does_addition)
{
///arrange
volatile_atomic int64_t addend;
interlocked_exchange_64(&addend, INT64_MAX);
int64_t value = INT64_MIN;
///act
int64_t return_val = interlocked_add_64(&addend, value);
///assert
ASSERT_ARE_EQUAL(int64_t, -1, interlocked_or_64(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int64_t, -1, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_065: [ interlocked_add_64 shall atomically add 64-bit integers *addend and value and store the result in *addend. ]*/
/*Tests_SRS_INTERLOCKED_43_066: [ interlocked_add_64 shall return the result of the addition. ]*/
TEST_FUNCTION(interlocked_add_64_overflows_upper_bound)
{
///arrange
volatile_atomic int64_t addend;
interlocked_exchange_64(&addend, INT64_MAX);
int64_t value = 1;
///act
int64_t return_val = interlocked_add_64(&addend, value);
///assert
ASSERT_ARE_EQUAL(int64_t, INT64_MIN, interlocked_or_64(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int64_t, INT64_MIN, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_065: [ interlocked_add_64 shall atomically add 64-bit integers *addend and value and store the result in *addend. ]*/
/*Tests_SRS_INTERLOCKED_43_066: [ interlocked_add_64 shall return the result of the addition. ]*/
TEST_FUNCTION(interlocked_add_64_underflows_lower_bound)
{
///arrange
volatile_atomic int64_t addend;
interlocked_exchange_64(&addend, INT64_MIN);
int64_t value = -1;
///act
int64_t return_val = interlocked_add_64(&addend, value);
///assert
ASSERT_ARE_EQUAL(int64_t, INT64_MAX, interlocked_or_64(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int64_t, INT64_MAX, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_002: [interlocked_and shall perform an atomic bitwise AND operation on the 32 - bit integer values * destination and value and store the result in * destination.]*/
/*Tests_SRS_INTERLOCKED_43_033: [interlocked_and shall return the initial value of * destination.]*/
TEST_FUNCTION(interlocked_and_does_bitwise_and)
{
///arrange
volatile_atomic uint32_t destination;
interlocked_exchange((volatile_atomic int32_t*)&destination, (uint32_t)0xF0F0F0F0);
uint32_t value = 0x0F0F0FFF;
///act
uint32_t return_val = (uint32_t)interlocked_and((volatile_atomic int32_t*)&destination, (int32_t)value);
///assert
ASSERT_ARE_EQUAL(uint32_t, 0x000000F0, interlocked_or((volatile_atomic int32_t*)&destination, 0), "Result stored in *destination is incorrect.");
ASSERT_ARE_EQUAL(uint32_t, 0xF0F0F0F0, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_003: [ interlocked_and_16 shall perform an atomic bitwise AND operation on the 16-bit integer values *destination and value and store the result in *destination.]*/
/*Tests_SRS_INTERLOCKED_43_034: [ interlocked_and_16 shall return the initial value of *destination.]*/
TEST_FUNCTION(interlocked_and_16_does_bitwise_and)
{
///arrange
volatile_atomic uint16_t destination;
interlocked_exchange_16((volatile_atomic int16_t*)&destination, (uint16_t)0xF0F0);
uint16_t value = 0x0FFF;
///act
uint16_t return_val = (uint16_t)interlocked_and_16((volatile_atomic int16_t*)&destination, (int16_t)value);
///assert
ASSERT_ARE_EQUAL(uint16_t, 0x00F0, interlocked_or_16((volatile_atomic int16_t*)&destination, 0), "Result stored in *destination is incorrect.");
ASSERT_ARE_EQUAL(uint16_t, 0xF0F0, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_004: [ interlocked_and_64 shall perform an atomic bitwise AND operation on the 64-bit integer values *destination and value and store the result in *destination.]*/
/*Tests_SRS_INTERLOCKED_43_035: [ interlocked_and_64 shall return the initial value of *destination.]*/
TEST_FUNCTION(interlocked_and_64_does_bitwise_and)
{
///arrange
volatile_atomic uint64_t destination;
interlocked_exchange_64((volatile_atomic int64_t*)&destination, (uint64_t)0xF0F0F0F0F0F0F0F0);
uint64_t value = 0x0F0F0F0F0F0F0FFF;
///act
uint64_t return_val = (uint64_t)interlocked_and_64((volatile_atomic int64_t*)&destination, (int64_t)value);
///assert
ASSERT_ARE_EQUAL(uint64_t, 0x00000000000000F0, interlocked_or_64((volatile_atomic int64_t*)&destination, 0), "Result stored in *destination is incorrect.");
ASSERT_ARE_EQUAL(uint64_t, 0xF0F0F0F0F0F0F0F0, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_005: [ interlocked_and_8 shall perform an atomic bitwise AND operation on the 8-bit integer values *destination and value and store the result in *destination]*/
/*Tests_SRS_INTERLOCKED_43_036: [ interlocked_and_8 shall return the initial value of *destination. ]*/
TEST_FUNCTION(interlocked_and_8_does_bitwise_and)
{
///arrange
volatile_atomic uint8_t destination;
interlocked_exchange_8((volatile_atomic int8_t*)&destination, (uint8_t)0xF0);
uint8_t value = 0xAF;
///act
uint8_t return_val = (uint8_t)interlocked_and_8((volatile_atomic int8_t*)&destination, (int8_t)value);
///assert
ASSERT_ARE_EQUAL(uint8_t, 0xA0, interlocked_or_8((volatile_atomic int8_t*)&destination, 0), "Result stored in *destination is incorrect.");
ASSERT_ARE_EQUAL(uint8_t, 0xF0, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_006: [ interlocked_compare_exchange shall compare the 32-bit integers pointed to by destination and comperand. If they are equal, *destination is set to exchange. These operations are performed atomically.*]*/
/*Tests_SRS_INTERLOCKED_43_037: [ interlocked_compare_exchange shall return the initial value of *destination.]*/
TEST_FUNCTION(interlocked_compare_exchange_exchanges_when_equal)
{
///arrange
volatile_atomic int32_t destination;
interlocked_exchange(&destination, INT32_MAX);
int32_t comperand = INT32_MAX;
int32_t exchange = INT32_MIN;
///act
int32_t return_val = interlocked_compare_exchange(&destination, exchange, comperand);
///assert
ASSERT_ARE_EQUAL(int32_t, INT32_MIN, interlocked_or(&destination, 0), "*destination is not equal to exchange.");
ASSERT_ARE_EQUAL(int32_t, INT32_MAX, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_006: [ interlocked_compare_exchange shall compare the 32-bit integers pointed to by destination and comperand. If they are equal, *destination is set to exchange. These operations are performed atomically.*]*/
/*Tests_SRS_INTERLOCKED_43_037: [ interlocked_compare_exchange shall return the initial value of *destination.]*/
TEST_FUNCTION(interlocked_compare_exchange_does_not_exchange_when_not_equal)
{
///arrange
volatile_atomic int32_t destination;
interlocked_exchange(&destination, INT32_MAX);
int32_t comperand = INT32_MIN;
int32_t exchange = INT32_MIN;
///act
int32_t return_val = interlocked_compare_exchange(&destination, exchange, comperand);
///assert
ASSERT_ARE_EQUAL(int32_t, INT32_MAX, interlocked_or(&destination, 0), "*destination is not equal to the original value.");
ASSERT_ARE_EQUAL(int32_t, INT32_MAX, return_val, "Return value is incorrect");
}
#ifdef _WIN64
/*Tests_SRS_INTERLOCKED_43_007: [ interlocked_compare_exchange_128 shall compare *destination with *comperand_result. If they are equal, destination[0] is set to exchange_low and destination[1] is set to exchange_high. These operations are performed atomically.]*/
/*Tests_SRS_INTERLOCKED_43_039: [ interlocked_compare_exchange_128 shall store the initial value of *destination in *comperand_result regardless of the result of the comparison.` ]*/
/*Tests_SRS_INTERLOCKED_43_038: [ interlocked_compare_exchange_128 shall return true if *comperand_result equals the original value of *destination.]*/
TEST_FUNCTION(interlocked_compare_exchange_128_exchanges_when_equal)
{
///arrange
volatile_atomic int64_t* destination;
interlocked_exchange_pointer((void* volatile_atomic*)&destination, malloc(2 * sizeof(int64_t)));
int64_t* comperand_result = (int64_t*)malloc(2 * sizeof(int64_t));
destination[0] = INT64_MAX;
destination[1] = INT64_MIN;
comperand_result[0] = INT64_MAX;
comperand_result[1] = INT64_MIN;
int64_t exchange_high = 2;
int64_t exchange_low = 3;
///act
bool return_val = interlocked_compare_exchange_128(destination, exchange_high, exchange_low, comperand_result);
///assert
ASSERT_ARE_EQUAL(int64_t, 3, interlocked_or_64(&destination[0], 0), "destination[0] not equal to exchange_low.");
ASSERT_ARE_EQUAL(int64_t, 2, interlocked_or_64(&destination[1], 0), "destination[1] not equal to exchange_high.");
ASSERT_ARE_EQUAL(int64_t, INT64_MAX, comperand_result[0], "comperand_result[0] is not equal to destination[0].");
ASSERT_ARE_EQUAL(int64_t, INT64_MIN, comperand_result[1], "comperand_result[1] is not equal to destination[1].");
ASSERT_IS_TRUE(return_val, "Return value is incorrect");
///cleanup
free((void*)destination);
free(comperand_result);
}
/*Tests_SRS_INTERLOCKED_43_039: [ interlocked_compare_exchange_128 shall store the initial value of *destination in *comperand_result regardless of the result of the comparison.` ]*/
/*Tests_SRS_INTERLOCKED_43_063: [ interlocked_compare_exchange_128 shall return false if *comperand_result does not equal the original value of *destination. ]*/
TEST_FUNCTION(interlocked_compare_exchange_128_does_not_exchange_when_not_equal)
{
///arrange
volatile_atomic int64_t* destination;
interlocked_exchange_pointer((void* volatile_atomic*)&destination, malloc(2 * sizeof(int64_t)));
int64_t* comperand_result = (int64_t*)malloc(2 * sizeof(int64_t));
destination[0] = INT64_MAX;
destination[1] = INT64_MIN;
comperand_result[0] = INT64_MIN;
comperand_result[1] = INT64_MAX;
int64_t exchange_high = 2;
int64_t exchange_low = 3;
///act
bool return_val = interlocked_compare_exchange_128(destination, exchange_high, exchange_low, comperand_result);
///assert
ASSERT_ARE_EQUAL(int64_t, INT64_MAX, interlocked_or_64(&destination[0], 0), "destination[0] is not equal to original value.");
ASSERT_ARE_EQUAL(int64_t, INT64_MIN, interlocked_or_64(&destination[1], 0), "destination[1] is not equal to original value.");
ASSERT_ARE_EQUAL(int64_t, INT64_MAX, comperand_result[0], "comperand_result[0] is not equal to destination[0].");
ASSERT_ARE_EQUAL(int64_t, INT64_MIN, comperand_result[1], "comperand_result[1] is not equal to destination[1].");
ASSERT_IS_FALSE(return_val, "Return value is incorrect");
///cleanup
free((void*)destination);
free((void*)comperand_result);
}
#endif
/*Tests_SRS_INTERLOCKED_43_009: [interlocked_compare_exchange_16 shall compare the 16-bit integers pointed to by destination and comperand. If they are equal, *destination is set to exchange. These operations are performed atomically.]*/
/*Tests_SRS_INTERLOCKED_43_040: [ interlocked_compare_exchange_16 shall return the initial value of *destination. ]*/
TEST_FUNCTION(interlocked_compare_exchange_16_exchanges_when_equal)
{
///arrange
volatile_atomic int16_t destination;
interlocked_exchange_16(&destination, INT16_MAX);
int16_t comperand = INT16_MAX;
int16_t exchange = INT16_MIN;
///act
int16_t return_val = interlocked_compare_exchange_16(&destination, exchange, comperand);
///assert
ASSERT_ARE_EQUAL(int16_t, INT16_MIN, interlocked_or_16(&destination, 0), "*destination is not equal to exchange.");
ASSERT_ARE_EQUAL(int16_t, INT16_MAX, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_009: [interlocked_compare_exchange_16 shall compare the 16-bit integers pointed to by destination and comperand. If they are equal, *destination is set to exchange. These operations are performed atomically.]*/
/*Tests_SRS_INTERLOCKED_43_040: [ interlocked_compare_exchange_16 shall return the initial value of *destination. ]*/
TEST_FUNCTION(interlocked_compare_exchange_16_does_not_exchange_when_not_equal)
{
///arrange
volatile_atomic int16_t destination;
interlocked_exchange_16(&destination, INT16_MAX);
int16_t comperand = INT16_MIN;
int16_t exchange = INT16_MIN;
///act
int16_t return_val = interlocked_compare_exchange_16(&destination, exchange, comperand);
///assert
ASSERT_ARE_EQUAL(int16_t, INT16_MAX, interlocked_or_16(&destination, 0), "*destination is not equal to the original value.");
ASSERT_ARE_EQUAL(int16_t, INT16_MAX, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_008: [interlocked_compare_exchange_64 shall compare the 64-bit integers pointed to by destination and comperand. If they are equal, *destination is set to exchange. These operations are performed atomically.]*/
/*Tests_SRS_INTERLOCKED_43_041: [ interlocked_compare_exchange_64 shall return the initial value of *destination. ]*/
TEST_FUNCTION(interlocked_compare_exchange_64_exchanges_when_equal)
{
///arrange
volatile_atomic int64_t destination;
interlocked_exchange_64(&destination, INT64_MAX);
int64_t comperand = INT64_MAX;
int64_t exchange = INT64_MIN;
///act
int64_t return_val = interlocked_compare_exchange_64(&destination, exchange, comperand);
///assert
ASSERT_ARE_EQUAL(int64_t, INT64_MIN, interlocked_or_64(&destination, 0), "*destination is not equal to exchange.");
ASSERT_ARE_EQUAL(int64_t, INT64_MAX, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_008: [interlocked_compare_exchange_64 shall compare the 64-bit integers pointed to by destination and comperand. If they are equal, *destination is set to exchange. These operations are performed atomically.]*/
/*Tests_SRS_INTERLOCKED_43_041: [ interlocked_compare_exchange_64 shall return the initial value of *destination. ]*/
TEST_FUNCTION(interlocked_compare_exchange_64_does_not_exchange_when_not_equal)
{
///arrange
volatile_atomic int64_t destination;
interlocked_exchange_64(&destination, INT64_MAX);
int64_t comperand = INT64_MIN;
int64_t exchange = INT64_MIN;
///act
int64_t return_val = interlocked_compare_exchange_64(&destination, exchange, comperand);
///assert
ASSERT_ARE_EQUAL(int64_t, INT64_MAX, interlocked_or_64(&destination, 0), "*destination is not equal to the original value.");
ASSERT_ARE_EQUAL(int64_t, INT64_MAX, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_010: [interlocked_compare_exchange_pointer shall compare the pointers destination and comperand. If they are equal, *destination is set to exchange. These operations are performed atomically.]*/
/*Tests_SRS_INTERLOCKED_43_042: [ interlocked_compare_exchange_pointer shall return the initial value of *destination. ]*/
TEST_FUNCTION(interlocked_compare_exchange_pointer_exchanges_when_equal)
{
///arrange
int value1 = 1;
int value2 = 2;
void* volatile_atomic destination;
interlocked_exchange_pointer(&destination, &value1);
void* comperand = &value1;
void* exchange = &value2;
///act
void* return_val = interlocked_compare_exchange_pointer(&destination, exchange, comperand);
///assert
ASSERT_ARE_EQUAL(void_ptr, &value2, interlocked_compare_exchange_pointer(&destination, NULL, NULL), "*destination is not equal to exchange.");
ASSERT_ARE_EQUAL(void_ptr, &value1, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_010: [interlocked_compare_exchange_pointer shall compare the pointers destination and comperand. If they are equal, *destination is set to exchange. These operations are performed atomically.]*/
/*Tests_SRS_INTERLOCKED_43_042: [ interlocked_compare_exchange_pointer shall return the initial value of *destination. ]*/
TEST_FUNCTION(interlocked_compare_exchange_pointer_does_not_exchange_when_not_equal)
{
///arrange
int value1 = 1;
int value2 = 2;
void* volatile_atomic destination;
interlocked_exchange_pointer(&destination, &value1);
void* comperand = &value2;
void* exchange = &value2;
///act
void* return_val = interlocked_compare_exchange_pointer(&destination, exchange, comperand);
///assert
ASSERT_ARE_EQUAL(void_ptr, &value1, interlocked_compare_exchange_pointer(&destination, NULL, NULL), "*destination is not equal to original value.");
ASSERT_ARE_EQUAL(void_ptr, &value1, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_011: [ interlocked_decrement shall atomically decrement (decrease by one) the 32-bit variable *addend.]*/
/*Tests_SRS_INTERLOCKED_43_043: [ interlocked_decrement shall return the decremented value. ]*/
TEST_FUNCTION(interlocked_decrement_upper_bound)
{
///arrange
volatile_atomic int32_t addend;
interlocked_exchange(&addend, INT32_MAX);
///act
int32_t return_val = interlocked_decrement(&addend);
///assert
ASSERT_ARE_EQUAL(int32_t, INT32_MAX - 1, interlocked_or(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int32_t, INT32_MAX - 1, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_011: [ interlocked_decrement shall atomically decrement (decrease by one) the 32-bit variable *addend.]*/
/*Tests_SRS_INTERLOCKED_43_043: [ interlocked_decrement shall return the decremented value. ]*/
TEST_FUNCTION(interlocked_decrement_lower_bound)
{
///arrange
volatile_atomic int32_t addend;
interlocked_exchange(&addend, INT32_MIN + 1);
///act
int32_t return_val = interlocked_decrement(&addend);
///assert
ASSERT_ARE_EQUAL(int32_t, INT32_MIN, interlocked_or(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int32_t, INT32_MIN, return_val, "Return value is incorrect");
}
TEST_FUNCTION(interlocked_decrement_underflows_lower_bound)
{
///arrange
volatile_atomic int32_t addend;
interlocked_exchange(&addend, INT32_MIN);
///act
int32_t return_val = interlocked_decrement(&addend);
///assert
ASSERT_ARE_EQUAL(int32_t, INT32_MAX, interlocked_or(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int32_t, INT32_MAX, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_012: [ interlocked_decrement_16 shall atomically decrement (decrease by one) the 16-bit variable *addend.]*/
/*Tests_SRS_INTERLOCKED_43_044: [ interlocked_decrement_16 shall return the decremented value. ]*/
TEST_FUNCTION(interlocked_decrement_16_upper_bound)
{
///arrange
volatile_atomic int16_t addend;
interlocked_exchange_16(&addend, INT16_MAX);
///act
int16_t return_val = interlocked_decrement_16(&addend);
///assert
ASSERT_ARE_EQUAL(int16_t, INT16_MAX - 1, interlocked_or_16(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int16_t, INT16_MAX - 1, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_012: [ interlocked_decrement_16 shall atomically decrement (decrease by one) the 16-bit variable *addend.]*/
/*Tests_SRS_INTERLOCKED_43_044: [ interlocked_decrement_16 shall return the decremented value. ]*/
TEST_FUNCTION(interlocked_decrement_16_lower_bound)
{
///arrange
volatile_atomic int16_t addend;
interlocked_exchange_16(&addend, INT16_MIN + 1);
///act
int16_t return_val = interlocked_decrement_16(&addend);
///assert
ASSERT_ARE_EQUAL(int16_t, INT16_MIN, interlocked_or_16(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int16_t, INT16_MIN, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_012: [ interlocked_decrement_16 shall atomically decrement (decrease by one) the 16-bit variable *addend.]*/
/*Tests_SRS_INTERLOCKED_43_044: [ interlocked_decrement_16 shall return the decremented value. ]*/
TEST_FUNCTION(interlocked_decrement_16_underflows_lower_bound)
{
///arrange
volatile_atomic int16_t addend;
interlocked_exchange_16(&addend, INT16_MIN);
///act
int16_t return_val = interlocked_decrement_16(&addend);
///assert
ASSERT_ARE_EQUAL(int16_t, INT16_MAX, interlocked_or_16(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int16_t, INT16_MAX, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_013: [ interlocked_decrement_64 shall atomically decrement (decrease by one) the 64-bit variable *addend.]*/
/*Tests_SRS_INTERLOCKED_43_045: [ interlocked_decrement_64 shall return the decremented value. ]*/
TEST_FUNCTION(interlocked_decrement_64_upper_bound)
{
///arrange
volatile_atomic int64_t addend;
interlocked_exchange_64(&addend, INT64_MAX);
///act
int64_t return_val = interlocked_decrement_64(&addend);
///assert
ASSERT_ARE_EQUAL(int64_t, INT64_MAX - 1, interlocked_or_64(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int64_t, INT64_MAX - 1, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_013: [ interlocked_decrement_64 shall atomically decrement (decrease by one) the 64-bit variable *addend.]*/
/*Tests_SRS_INTERLOCKED_43_045: [ interlocked_decrement_64 shall return the decremented value. ]*/
TEST_FUNCTION(interlocked_decrement_64_lower_bound)
{
///arrange
volatile_atomic int64_t addend;
interlocked_exchange_64(&addend, INT64_MIN + 1);
///act
int64_t return_val = interlocked_decrement_64(&addend);
///assert
ASSERT_ARE_EQUAL(int64_t, INT64_MIN, interlocked_or_64(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int64_t, INT64_MIN, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_013: [ interlocked_decrement_64 shall atomically decrement (decrease by one) the 64-bit variable *addend.]*/
/*Tests_SRS_INTERLOCKED_43_045: [ interlocked_decrement_64 shall return the decremented value. ]*/
TEST_FUNCTION(interlocked_decrement_64_underflows_lower_bound)
{
///arrange
volatile_atomic int64_t addend;
interlocked_exchange_64(&addend, INT64_MIN);
///act
int64_t return_val = interlocked_decrement_64(&addend);
///assert
ASSERT_ARE_EQUAL(int64_t, INT64_MAX, interlocked_or_64(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int64_t, INT64_MAX, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_014: [ interlocked_exchange shall set the 32-bit variable pointed to by target to value as an atomic operation.]*/
/*Tests_SRS_INTERLOCKED_43_046: [ interlocked_exchange shall return the initial value pointed to by target. ]*/
TEST_FUNCTION(interlocked_exchange_sets_target)
{
///arrange
volatile_atomic int32_t target;
interlocked_exchange(&target, INT32_MIN);
int32_t value = INT32_MAX;
///act
int32_t return_val = interlocked_exchange(&target, value);
///assert
ASSERT_ARE_EQUAL(int32_t, INT32_MAX, interlocked_or(&target, 0), "Result stored in *target is incorrect.");
ASSERT_ARE_EQUAL(int32_t, INT32_MIN, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_015: [ interlocked_exchange_16 shall set the 16-bit variable pointed to by target to value as an atomic operation.]*/
/*Tests_SRS_INTERLOCKED_43_047: [ interlocked_exchange_16 shall return the initial value pointed to by target. ]*/
TEST_FUNCTION(interlocked_exchange_16_sets_target)
{
///arrange
volatile_atomic int16_t target;
interlocked_exchange_16(&target, INT16_MIN);
int16_t value = INT16_MAX;
///act
int16_t return_val = interlocked_exchange_16(&target, value);
///assert
ASSERT_ARE_EQUAL(int16_t, INT16_MAX, interlocked_or_16(&target, 0), "Result stored in *target is incorrect.");
ASSERT_ARE_EQUAL(int16_t, INT16_MIN, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_016: [ interlocked_exchange_64 shall set the 64-bit variable pointed to by target to value as an atomic operation.]*/
/*Tests_SRS_INTERLOCKED_43_048: [ interlocked_exchange_64 shall return the initial value pointed to by target. ]*/
TEST_FUNCTION(interlocked_exchange_64_sets_target)
{
///arrange
volatile_atomic int64_t target;
interlocked_exchange_64(&target, INT64_MIN);
int64_t value = INT64_MAX;
///act
int64_t return_val = interlocked_exchange_64(&target, value);
///assert
ASSERT_ARE_EQUAL(int64_t, INT64_MAX, interlocked_or_64(&target, 0), "Result stored in *target is incorrect.");
ASSERT_ARE_EQUAL(int64_t, INT64_MIN, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_017: [ interlocked_exchange_8 shall set the 8-bit variable pointed to by target to value as an atomic operation.]*/
/*Tests_SRS_INTERLOCKED_43_049: [ interlocked_exchange_8 shall return the initial value pointed to by target. ]*/
TEST_FUNCTION(interlocked_exchange_8_sets_target)
{
///arrange
volatile_atomic int8_t target;
interlocked_exchange_8(&target, INT8_MIN);
int8_t value = INT8_MAX;
///act
int8_t return_val = interlocked_exchange_8(&target, value);
///assert
ASSERT_ARE_EQUAL(int8_t, INT8_MAX, interlocked_or_8(&target, 0), "Result stored in *target is incorrect.");
ASSERT_ARE_EQUAL(int8_t, INT8_MIN, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_018: [ interlocked_exchange_add shall perform an atomic addition of the 32-bit values *addend and value and store the result in *addend.]*/
/*Tests_SRS_INTERLOCKED_43_050: [ interlocked_exchange_add shall return the initial value of *addend. ]*/
TEST_FUNCTION(interlocked_exchange_add_sets_target_to_sum)
{
///arrange
volatile_atomic int32_t addend;
interlocked_exchange(&addend, INT32_MIN);
int32_t value = INT32_MAX;
///act
int32_t return_val = interlocked_exchange_add(&addend, value);
///assert
ASSERT_ARE_EQUAL(int32_t, -1, interlocked_or(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int32_t, INT32_MIN, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_018: [ interlocked_exchange_add shall perform an atomic addition of the 32-bit values *addend and value and store the result in *addend.]*/
/*Tests_SRS_INTERLOCKED_43_050: [ interlocked_exchange_add shall return the initial value of *addend. ]*/
TEST_FUNCTION(interlocked_exchange_add_overflows_upper_bound)
{
///arrange
volatile_atomic int32_t addend;
interlocked_exchange(&addend, INT32_MAX);
int32_t value = 1;
///act
int32_t return_val = interlocked_exchange_add(&addend, value);
///assert
ASSERT_ARE_EQUAL(int32_t, INT32_MIN, interlocked_or(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int32_t, INT32_MAX, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_018: [ interlocked_exchange_add shall perform an atomic addition of the 32-bit values *addend and value and store the result in *addend.]*/
/*Tests_SRS_INTERLOCKED_43_050: [ interlocked_exchange_add shall return the initial value of *addend. ]*/
TEST_FUNCTION(interlocked_exchange_add_underflows_lower_bound)
{
///arrange
volatile_atomic int32_t addend;
interlocked_exchange(&addend, INT32_MIN);
int32_t value = -1;
///act
int32_t return_val = interlocked_exchange_add(&addend, value);
///assert
ASSERT_ARE_EQUAL(int32_t, INT32_MAX, interlocked_or(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int32_t, INT32_MIN, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_019: [ interlocked_exchange_add_64 shall perform an atomic addition of the 64-bit values *addend and value and store the result in *addend.]*/
/*Tests_SRS_INTERLOCKED_43_064: [ interlocked_exchange_add_64 shall return the initial value of *addend. ]*/
TEST_FUNCTION(interlocked_exchange_add_64_sets_target_to_sum)
{
///arrange
volatile_atomic int64_t addend;
interlocked_exchange_64(&addend, INT64_MIN);
int64_t value = INT64_MAX;
///act
int64_t return_val = interlocked_exchange_add_64(&addend, value);
///assert
ASSERT_ARE_EQUAL(int64_t, -1, interlocked_or_64(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int64_t, INT64_MIN, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_019: [ interlocked_exchange_add_64 shall perform an atomic addition of the 64-bit values *addend and value and store the result in *addend.]*/
/*Tests_SRS_INTERLOCKED_43_064: [ interlocked_exchange_add_64 shall return the initial value of *addend. ]*/
TEST_FUNCTION(interlocked_exchange_add_64_overflows_upper_bound)
{
///arrange
volatile_atomic int64_t addend;
interlocked_exchange_64(&addend, INT64_MAX);
int64_t value = 1;
///act
int64_t return_val = interlocked_exchange_add_64(&addend, value);
///assert
ASSERT_ARE_EQUAL(int64_t, INT64_MIN, interlocked_or_64(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int64_t, INT64_MAX, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_019: [ interlocked_exchange_add_64 shall perform an atomic addition of the 64-bit values *addend and value and store the result in *addend.]*/
/*Tests_SRS_INTERLOCKED_43_064: [ interlocked_exchange_add_64 shall return the initial value of *addend. ]*/
TEST_FUNCTION(interlocked_exchange_add_64_underflows_lower_bound)
{
///arrange
volatile_atomic int64_t addend;
interlocked_exchange_64(&addend, INT64_MIN);
int64_t value = -1;
///act
int64_t return_val = interlocked_exchange_add_64(&addend, value);
///assert
ASSERT_ARE_EQUAL(int64_t, INT64_MAX, interlocked_or_64(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int64_t, INT64_MIN, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_020: [ interlocked_exchange_pointer shall atomically set *target to value]*/
/*Tests_SRS_INTERLOCKED_43_051: [ interlocked_exchange_pointer shall return the initial value of *target. ]*/
TEST_FUNCTION(interlocked_exchange_pointer_sets_target)
{
///arrange
int value1 = 1;
int value2 = 2;
void* volatile_atomic target = &value1;
void* value = &value2;
///act
void* return_val = interlocked_exchange_pointer(&target, value);
///assert
ASSERT_ARE_EQUAL(void_ptr, &value2, interlocked_compare_exchange_pointer(&target, NULL, NULL));
ASSERT_ARE_EQUAL(void_ptr, &value1, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_021: [ interlocked_increment shall atomically increment (increase by one) the 32-bit variable *addend.]*/
/*Tests_SRS_INTERLOCKED_43_052: [ interlocked_increment shall return the incremented value. ]*/
TEST_FUNCTION(interlocked_increment_upper_bound)
{
///arrange
volatile_atomic int32_t addend;
interlocked_exchange(&addend, INT32_MAX-1);
///act
int32_t return_val = interlocked_increment(&addend);
///assert
ASSERT_ARE_EQUAL(int32_t, INT32_MAX, interlocked_or(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int32_t, INT32_MAX, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_021: [ interlocked_increment shall atomically increment (increase by one) the 32-bit variable *addend.]*/
/*Tests_SRS_INTERLOCKED_43_052: [ interlocked_increment shall return the incremented value. ]*/
TEST_FUNCTION(interlocked_increment_lower_bound)
{
///arrange
volatile_atomic int32_t addend;
interlocked_exchange(&addend, INT32_MIN);
///act
int32_t return_val = interlocked_increment(&addend);
///assert
ASSERT_ARE_EQUAL(int32_t, INT32_MIN + 1, interlocked_or(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int32_t, INT32_MIN + 1, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_021: [ interlocked_increment shall atomically increment (increase by one) the 32-bit variable *addend.]*/
/*Tests_SRS_INTERLOCKED_43_052: [ interlocked_increment shall return the incremented value. ]*/
TEST_FUNCTION(interlocked_increment_overflows_upper_bound)
{
///arrange
volatile_atomic int32_t addend;
interlocked_exchange(&addend, INT32_MAX);
///act
int32_t return_val = interlocked_increment(&addend);
///assert
ASSERT_ARE_EQUAL(int32_t, INT32_MIN, interlocked_or(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int32_t, INT32_MIN, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_022: [ interlocked_increment_16 shall atomically increment (increase by one) the 16-bit variable *addend.]*/
/*Tests_SRS_INTERLOCKED_43_053: [ interlocked_increment_16 shall return the incremented value. ]*/
TEST_FUNCTION(interlocked_increment_16_upper_bound)
{
///arrange
volatile_atomic int16_t addend;
interlocked_exchange_16(&addend, INT16_MAX - 1);
///act
int16_t return_val = interlocked_increment_16(&addend);
///assert
ASSERT_ARE_EQUAL(int16_t, INT16_MAX, interlocked_or_16(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int16_t, INT16_MAX, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_022: [ interlocked_increment_16 shall atomically increment (increase by one) the 16-bit variable *addend.]*/
/*Tests_SRS_INTERLOCKED_43_053: [ interlocked_increment_16 shall return the incremented value. ]*/
TEST_FUNCTION(interlocked_increment_16_lower_bound)
{
///arrange
volatile_atomic int16_t addend;
interlocked_exchange_16(&addend, INT16_MIN);
///act
int16_t return_val = interlocked_increment_16(&addend);
///assert
ASSERT_ARE_EQUAL(int16_t, INT16_MIN + 1, interlocked_or_16(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int16_t, INT16_MIN + 1, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_022: [ interlocked_increment_16 shall atomically increment (increase by one) the 16-bit variable *addend.]*/
/*Tests_SRS_INTERLOCKED_43_053: [ interlocked_increment_16 shall return the incremented value. ]*/
TEST_FUNCTION(interlocked_increment_16_overflows_upper_bound)
{
///arrange
volatile_atomic int16_t addend;
interlocked_exchange_16(&addend, INT16_MAX);
///act
int16_t return_val = interlocked_increment_16(&addend);
///assert
ASSERT_ARE_EQUAL(int16_t, INT16_MIN, interlocked_or_16(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int16_t, INT16_MIN, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_023: [ interlocked_increment_64 shall atomically increment (increase by one) the 64-bit variable *addend.]*/
/*Tests_SRS_INTERLOCKED_43_054: [ interlocked_increment_64 shall return the incremented value. ]*/
TEST_FUNCTION(interlocked_increment_64_upper_bound)
{
///arrange
volatile_atomic int64_t addend;
interlocked_exchange_64(&addend, INT64_MAX - 1);
///act
int64_t return_val = interlocked_increment_64(&addend);
///assert
ASSERT_ARE_EQUAL(int64_t, INT64_MAX, interlocked_or_64(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int64_t, INT64_MAX, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_023: [ interlocked_increment_64 shall atomically increment (increase by one) the 64-bit variable *addend.]*/
/*Tests_SRS_INTERLOCKED_43_054: [ interlocked_increment_64 shall return the incremented value. ]*/
TEST_FUNCTION(interlocked_increment_64_lower_bound)
{
///arrange
volatile_atomic int64_t addend;
interlocked_exchange_64(&addend, INT64_MIN);
///act
int64_t return_val = interlocked_increment_64(&addend);
///assert
ASSERT_ARE_EQUAL(int64_t, INT64_MIN + 1, interlocked_or_64(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int64_t, INT64_MIN + 1, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_023: [ interlocked_increment_64 shall atomically increment (increase by one) the 64-bit variable *addend.]*/
/*Tests_SRS_INTERLOCKED_43_054: [ interlocked_increment_64 shall return the incremented value. ]*/
TEST_FUNCTION(interlocked_increment_64_overflows_upper_bound)
{
///arrange
volatile_atomic int64_t addend;
interlocked_exchange_64(&addend, INT64_MAX);
///act
int64_t return_val = interlocked_increment_64(&addend);
///assert
ASSERT_ARE_EQUAL(int64_t, INT64_MIN, interlocked_or_64(&addend, 0), "Result stored in *addend is incorrect.");
ASSERT_ARE_EQUAL(int64_t, INT64_MIN, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_024: [ interlocked_or shall perform an atomic bitwise OR operation on the 32-bit integers *destination and value and store the result in destination.]*/
/*Tests_SRS_INTERLOCKED_43_055: [ interlocked_or shall return the initial value of *destination. ]*/
TEST_FUNCTION(interlocked_or_does_bitwise_or)
{
///arrange
volatile_atomic uint32_t destination;
interlocked_exchange((volatile_atomic int32_t*)&destination, (uint32_t)0xF0F0F0F0);
uint32_t value = 0x0F0F0F0F;
///act
uint32_t return_val = (uint32_t)interlocked_or((volatile_atomic int32_t*)&destination, (int32_t)value);
///assert
ASSERT_ARE_EQUAL(uint32_t, 0xFFFFFFFF, interlocked_or((volatile_atomic int32_t*)&destination, 0), "Result stored in *destination is incorrect.");
ASSERT_ARE_EQUAL(uint32_t, 0xF0F0F0F0, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_025: [ interlocked_or_16 shall perform an atomic bitwise OR operation on the 16-bit integers *destination and value and store the result in destination.]*/
/*Tests_SRS_INTERLOCKED_43_056: [ interlocked_or_16 shall return the initial value of *destination. ]*/
TEST_FUNCTION(interlocked_or_16_does_bitwise_or)
{
///arrange
volatile_atomic uint16_t destination;
interlocked_exchange_16((volatile_atomic int16_t*)&destination, (uint16_t)0xF0F0);
uint16_t value = 0x0F0F;
///act
uint16_t return_val = (uint16_t)interlocked_or_16((volatile_atomic int16_t*)&destination, (int16_t)value);
///assert
ASSERT_ARE_EQUAL(uint16_t, 0xFFFF, interlocked_or_16((volatile_atomic int16_t*)&destination, 0), "Result stored in *destination is incorrect.");
ASSERT_ARE_EQUAL(uint16_t, 0xF0F0, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_026: [ interlocked_or_64 shall perform an atomic bitwise OR operation on the 64-bit integers *destination and value and store the result in destination.]*/
/*Tests_SRS_INTERLOCKED_43_057: [ interlocked_or_64 shall return the initial value of *destination. ]*/
TEST_FUNCTION(interlocked_or_64_does_bitwise_or)
{
///arrange
volatile_atomic uint64_t destination;
interlocked_exchange_64((volatile_atomic int64_t*)&destination, (uint64_t)0xF0F0F0F0F0F0F0F0);
uint64_t value = 0x0F0F0F0F0F0F0F0F;
///act
uint64_t return_val = (uint64_t)interlocked_or_64((volatile_atomic int64_t*)&destination, (int64_t)value);
///assert
ASSERT_ARE_EQUAL(uint64_t, 0xFFFFFFFFFFFFFFFF, interlocked_or_64((volatile_atomic int64_t*)&destination, 0), "Result stored in *destination is incorrect.");
ASSERT_ARE_EQUAL(uint64_t, 0xF0F0F0F0F0F0F0F0, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_027: [ interlocked_or_8 shall perform an atomic bitwise OR operation on the 8-bit integers *destination and value and store the result in destination.]*/
/*Tests_SRS_INTERLOCKED_43_058: [ interlocked_or_8 shall return the initial value of *destination. ]*/
TEST_FUNCTION(interlocked_or_8_does_bitwise_or)
{
///arrange
volatile_atomic uint8_t destination;
interlocked_exchange_8((volatile_atomic int8_t*)&destination, (uint8_t)0xF0);
uint8_t value = 0x0F;
///act
uint8_t return_val = (uint8_t)interlocked_or_8((volatile_atomic int8_t*)&destination, (int8_t)value);
///assert
ASSERT_ARE_EQUAL(uint8_t, 0xFF, interlocked_or_8((volatile_atomic int8_t*)&destination, 0), "Result stored in *destination is incorrect.");
ASSERT_ARE_EQUAL(uint8_t, 0xF0, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_028: [ interlocked_xor shall perform an atomic bitwise XOR operation on the 32-bit integers *destination and value and store the result in destination.]*/
/*Tests_SRS_INTERLOCKED_43_059: [ interlocked_xor shall return the initial value of *destination. ]*/
TEST_FUNCTION(interlocked_xor_does_bitwise_xor)
{
///arrange
volatile_atomic uint32_t destination;
interlocked_exchange((volatile_atomic int32_t*)&destination, (uint32_t)0xF0F0F0FF);
uint32_t value = 0x0F0F0F0F;
///act
uint32_t return_val = (uint32_t)interlocked_xor((volatile_atomic int32_t*)&destination, (int32_t)value);
///assert
ASSERT_ARE_EQUAL(uint32_t, 0xFFFFFFF0, interlocked_or((volatile_atomic int32_t*)&destination, 0), "Result stored in *destination is incorrect.");
ASSERT_ARE_EQUAL(uint32_t, 0xF0F0F0FF, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_029: [ interlocked_xor_16 shall perform an atomic bitwise XOR operation on the 16-bit integers *destination and value and store the result in destination.]*/
/*Tests_SRS_INTERLOCKED_43_060: [ interlocked_xor_16 shall return the initial value of *destination. ]*/
TEST_FUNCTION(interlocked_xor_16_does_bitwise_xor)
{
///arrange
volatile_atomic uint16_t destination;
interlocked_exchange_16((volatile_atomic int16_t*)&destination, (uint16_t)0xF0FF);
uint16_t value = 0x0F0F;
///act
uint16_t return_val = (uint16_t)interlocked_xor_16((volatile_atomic int16_t*)&destination, (int16_t)value);
///assert
ASSERT_ARE_EQUAL(uint16_t, 0xFFF0, interlocked_or_16((volatile_atomic int16_t*)&destination, 0), "Result stored in *destination is incorrect.");
ASSERT_ARE_EQUAL(uint16_t, 0xF0FF, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_030: [ interlocked_xor_64 shall perform an atomic bitwise XOR operation on the 64-bit integers *destination and value and store the result in destination.]*/
/*Tests_SRS_INTERLOCKED_43_061: [ interlocked_xor_64 shall return the initial value of *destination. ]*/
TEST_FUNCTION(interlocked_xor_64_does_bitwise_xor)
{
///arrange
volatile_atomic uint64_t destination;
interlocked_exchange_64((volatile_atomic int64_t*)&destination, (uint64_t)0xF0F0F0F0F0F0F0FF);
uint64_t value = 0x0F0F0F0F0F0F0F0F;
///act
uint64_t return_val = (uint64_t)interlocked_xor_64((volatile_atomic int64_t*)&destination, (int64_t)value);
///assert
ASSERT_ARE_EQUAL(uint64_t, 0xFFFFFFFFFFFFFFF0, interlocked_or_64((volatile_atomic int64_t*)&destination, 0), "Result stored in *destination is incorrect.");
ASSERT_ARE_EQUAL(uint64_t, 0xF0F0F0F0F0F0F0FF, return_val, "Return value is incorrect");
}
/*Tests_SRS_INTERLOCKED_43_031: [ interlocked_xor_8 shall perform an atomic bitwise XOR operation on the 8-bit integers *destination and value and store the result in destination.]*/
/*Tests_SRS_INTERLOCKED_43_062: [ interlocked_xor_8 shall return the initial value of *destination. ]*/
TEST_FUNCTION(interlocked_xor_8_does_bitwise_xor)
{
///arrange
volatile_atomic uint8_t destination;
interlocked_exchange_8((volatile_atomic int8_t*)&destination, (uint8_t)0xFF);
uint8_t value = 0x0F;
///act
uint8_t return_val = (uint8_t)interlocked_xor_8((volatile_atomic int8_t*)&destination, (int8_t)value);
///assert
ASSERT_ARE_EQUAL(uint8_t, 0xF0, interlocked_or_8((volatile_atomic int8_t*)&destination, 0), "Result stored in *destination is incorrect.");
ASSERT_ARE_EQUAL(uint8_t, 0xFF, return_val, "Return value is incorrect");
}
END_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE)
| 44.899618 | 264 | 0.770361 |
d99b8662c0d6076df0fba1e80d92566654227ce6 | 10,504 | h | C | src/mplfe/common/include/fe_options.h | MapleSystem/OpenArkCompiler | fc250857642ca38ac8b83ae7486513fadf3ab742 | [
"MulanPSL-1.0"
] | null | null | null | src/mplfe/common/include/fe_options.h | MapleSystem/OpenArkCompiler | fc250857642ca38ac8b83ae7486513fadf3ab742 | [
"MulanPSL-1.0"
] | null | null | null | src/mplfe/common/include/fe_options.h | MapleSystem/OpenArkCompiler | fc250857642ca38ac8b83ae7486513fadf3ab742 | [
"MulanPSL-1.0"
] | null | null | null | /*
* Copyright (c) [2020-2021] Huawei Technologies Co.,Ltd.All rights reserved.
*
* OpenArkCompiler is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR
* FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
#ifndef MPLFE_INCLUDE_COMMON_FE_OPTIONS_H
#define MPLFE_INCLUDE_COMMON_FE_OPTIONS_H
#include <list>
#include <vector>
#include <string>
#include <set>
#include "mpl_logging.h"
#include "types_def.h"
namespace maple {
class FEOptions {
public:
static const int kDumpLevelDisable = 0;
static const int kDumpLevelInfo = 1;
static const int kDumpLevelInfoDetail = 2;
static const int kDumpLevelInfoDebug = 3;
enum ModeJavaStaticFieldName {
kNoType = 0, // without type
kAllType, // with type
kSmart // auto anti-proguard
};
enum ModeCollectDepTypes {
kAll = 0, // collect all dependent types
kFunc // collect func dependent types
};
enum ModeDepSameNamePolicy {
kSys = 0, // load type form sys when on-demand load same name type
kSrc // load type form src when on-demand load same name type
};
enum TypeInferKind {
kNo = 0,
kRoahAlgorithm,
kLinearScan
};
static FEOptions &GetInstance() {
return options;
}
void Init() {
isJBCUseImpreciseType = true;
}
// input control options
void AddInputClassFile(const std::string &fileName);
const std::list<std::string> &GetInputClassFiles() const {
return inputClassFiles;
}
void AddInputJarFile(const std::string &fileName);
const std::list<std::string> &GetInputJarFiles() const {
return inputJarFiles;
}
void AddInputDexFile(const std::string &fileName);
const std::vector<std::string> &GetInputDexFiles() const {
return inputDexFiles;
}
void AddInputASTFile(const std::string &fileName);
const std::vector<std::string> &GetInputASTFiles() const {
return inputASTFiles;
}
void AddInputMpltFileFromSys(const std::string &fileName) {
inputMpltFilesFromSys.push_back(fileName);
}
const std::list<std::string> &GetInputMpltFilesFromSys() const {
return inputMpltFilesFromSys;
}
void AddInputMpltFileFromApk(const std::string &fileName) {
inputMpltFilesFromApk.push_back(fileName);
}
const std::list<std::string> &GetInputMpltFilesFromApk() const {
return inputMpltFilesFromApk;
}
void AddInputMpltFile(const std::string &fileName) {
inputMpltFiles.push_back(fileName);
}
const std::list<std::string> &GetInputMpltFiles() const {
return inputMpltFiles;
}
// On Demand Type Creation
void SetXBootClassPath(const std::string &fileName) {
strXBootClassPath = fileName;
}
const std::string &GetXBootClassPath() const {
return strXBootClassPath;
}
void SetClassLoaderContext(const std::string &fileName) {
strClassLoaderContext = fileName;
}
const std::string &GetClassLoaderContext() const {
return strClassLoaderContext;
}
void SetCompileFileName(const std::string &fileName) {
strCompileFileName = fileName;
}
const std::string &GetCompileFileName() const {
return strCompileFileName;
}
void SetModeCollectDepTypes(ModeCollectDepTypes mode) {
modeCollectDepTypes = mode;
}
ModeCollectDepTypes GetModeCollectDepTypes() const {
return modeCollectDepTypes;
}
void SetModeDepSameNamePolicy(ModeDepSameNamePolicy mode) {
modeDepSameNamePolicy = mode;
}
ModeDepSameNamePolicy GetModeDepSameNamePolicy() const {
return modeDepSameNamePolicy;
}
// output control options
void SetIsGenMpltOnly(bool flag) {
isGenMpltOnly = flag;
}
bool IsGenMpltOnly() const {
return isGenMpltOnly;
}
void SetIsGenAsciiMplt(bool flag) {
isGenAsciiMplt = flag;
}
bool IsGenAsciiMplt() const {
return isGenAsciiMplt;
}
void SetOutputPath(const std::string &path) {
outputPath = path;
}
const std::string &GetOutputPath() const {
return outputPath;
}
void SetOutputName(const std::string &name) {
outputName = name;
}
const std::string &GetOutputName() const {
return outputName;
}
void EnableDumpInstComment() {
isDumpInstComment = true;
}
void DisableDumpInstComment() {
isDumpInstComment = false;
}
bool IsDumpInstComment() const {
return isDumpInstComment;
}
void SetNoMplFile() {
isNoMplFile = true;
}
bool IsNoMplFile() const {
return isNoMplFile;
}
// debug info control options
void SetDumpLevel(int level) {
dumpLevel = level;
}
int GetDumpLevel() const {
return dumpLevel;
}
void SetIsDumpTime(bool flag) {
isDumpTime = flag;
}
bool IsDumpTime() const {
return isDumpTime;
}
void SetIsDumpComment(bool flag) {
isDumpComment = flag;
}
bool IsDumpComment() const {
return isDumpComment;
}
void SetIsDumpLOC(bool flag) {
isDumpLOC = flag;
}
bool IsDumpLOC() const {
return isDumpLOC;
}
void SetIsDumpPhaseTime(bool flag) {
isDumpPhaseTime = flag;
}
bool IsDumpPhaseTime() const {
return isDumpPhaseTime;
}
void SetIsDumpPhaseTimeDetail(bool flag) {
isDumpPhaseTimeDetail = flag;
}
bool IsDumpPhaseTimeDetail() const {
return isDumpPhaseTimeDetail;
}
// java compiler options
void SetModeJavaStaticFieldName(ModeJavaStaticFieldName mode) {
modeJavaStaticField = mode;
}
ModeJavaStaticFieldName GetModeJavaStaticFieldName() const {
return modeJavaStaticField;
}
void SetIsJBCUseImpreciseType(bool flag) {
isJBCUseImpreciseType = flag;
}
bool IsJBCUseImpreciseType() const {
return isJBCUseImpreciseType;
}
void SetIsJBCInfoUsePathName(bool flag) {
isJBCInfoUsePathName = flag;
}
bool IsJBCInfoUsePathName() const {
return isJBCInfoUsePathName;
}
void SetIsDumpJBCStmt(bool flag) {
isDumpJBCStmt = flag;
}
bool IsDumpJBCStmt() const {
return isDumpJBCStmt;
}
void SetIsDumpJBCBB(bool flag) {
isDumpJBCBB = flag;
}
bool IsDumpJBCBB() const {
return isDumpJBCBB;
}
void SetIsDumpGeneralCFGGraph(bool flag) {
isDumpGenCFGGraph = flag;
}
bool IsDumpGeneralCFGGraph() const {
return isDumpGenCFGGraph;
}
void SetGeneralCFGGraphFileName(const std::string &fileName) {
genCFGGraphFileName = fileName;
}
const std::string GetJBCCFGGraphFileName() const {
return genCFGGraphFileName;
}
void SetIsDumpJBCAll(bool flag) {
isDumpJBCAll = flag;
}
bool IsDumpJBCAll() const {
return isDumpJBCAll;
}
void SetIsDumpJBCErrorOnly(bool flag) {
isDumpJBCErrorOnly = flag;
}
bool IsDumpJBCErrorOnly() const {
return isDumpJBCErrorOnly;
}
void SetIsEmitJBCLocalVarInfo(bool flag) {
isEmitJBCLocalVarInfo = flag;
}
bool IsEmitJBCLocalVarInfo() const {
return isEmitJBCLocalVarInfo;
}
// parallel
void SetNThreads(uint32 n) {
nthreads = n;
}
uint32 GetNThreads() const {
return nthreads;
}
void SetDumpThreadTime(bool arg) {
dumpThreadTime = arg;
}
bool IsDumpThreadTime() const {
return dumpThreadTime;
}
void AddDumpJBCFuncName(const std::string &funcName) {
if (!funcName.empty()) {
CHECK_FATAL(dumpJBCFuncNames.insert(funcName).second, "dumpJBCFuncNames insert failed");
}
}
const std::set<std::string> &GetDumpJBCFuncNames() const {
return dumpJBCFuncNames;
}
bool IsDumpJBCFuncName(const std::string &funcName) const {
return dumpJBCFuncNames.find(funcName) != dumpJBCFuncNames.end();
}
void SetTypeInferKind(TypeInferKind arg) {
typeInferKind = arg;
}
TypeInferKind GetTypeInferKind() const {
return typeInferKind;
}
bool IsRC() const {
return isRC;
}
void SetRC(bool arg) {
isRC = arg;
}
bool IsNoBarrier() const {
return isNoBarrier;
}
void SetNoBarrier(bool arg) {
isNoBarrier = arg;
}
bool HasJBC() const {
return ((inputClassFiles.size() != 0) || (inputJarFiles.size() != 0));
}
void SetIsAOT(bool flag) {
isAOT = flag;
}
bool IsAOT() const {
return isAOT;
}
void SetUseSignedChar(bool flag) {
useSignedChar = flag;
}
bool IsUseSignedChar() const {
return useSignedChar;
}
private:
static FEOptions options;
// input control options
std::list<std::string> inputClassFiles;
std::list<std::string> inputJarFiles;
std::vector<std::string> inputDexFiles;
std::vector<std::string> inputASTFiles;
std::list<std::string> inputMpltFilesFromSys;
std::list<std::string> inputMpltFilesFromApk;
std::list<std::string> inputMpltFiles;
// On Demand Type Creation
std::string strXBootClassPath;
std::string strClassLoaderContext;
std::string strCompileFileName;
ModeCollectDepTypes modeCollectDepTypes = ModeCollectDepTypes::kFunc;
ModeDepSameNamePolicy modeDepSameNamePolicy = ModeDepSameNamePolicy::kSys;
// output control options
bool isGenMpltOnly;
bool isGenAsciiMplt;
std::string outputPath;
std::string outputName;
bool isDumpInstComment = false;
bool isNoMplFile = false;
// debug info control options
int dumpLevel;
bool isDumpTime;
bool isDumpComment = false;
bool isDumpLOC = true;
bool isDumpPhaseTime = false;
bool isDumpPhaseTimeDetail = false;
// java compiler options
ModeJavaStaticFieldName modeJavaStaticField = ModeJavaStaticFieldName::kNoType;
bool isJBCUseImpreciseType = false;
bool isJBCInfoUsePathName = false;
bool isDumpJBCStmt = false;
bool isDumpJBCBB = false;
bool isDumpJBCAll = false;
bool isDumpJBCErrorOnly = false;
std::set<std::string> dumpJBCFuncNames;
bool isEmitJBCLocalVarInfo = false;
// bc compiler options
bool isRC = false;
bool isNoBarrier = false;
// ast compiler options
bool useSignedChar = false;
// general stmt/bb/cfg debug options
bool isDumpGenCFGGraph = false;
std::string genCFGGraphFileName = "";
// parallel
uint32 nthreads;
bool dumpThreadTime;
// type-infer
TypeInferKind typeInferKind = kLinearScan;
// symbol resolve
bool isAOT = false;
FEOptions();
~FEOptions() = default;
};
} // namespace maple
#endif // MPLFE_INCLUDE_COMMON_FE_OPTIONS_H
| 22.020964 | 94 | 0.703065 |
d99bdf7d05fb3d27f929b8540267dcb171232f35 | 3,224 | c | C | test/programs/fault_localization/benchmarks/tritype/TritypeKO2.c | Po-Chun-Chien/cpachecker | 4e3b8babb9e98704363efe8bed109ac05f464678 | [
"Apache-2.0"
] | 16 | 2015-01-19T15:52:14.000Z | 2015-11-30T14:12:31.000Z | test/programs/fault_localization/benchmarks/tritype/TritypeKO2.c | teodorov/cpachecker | 16e37b76c5b9e3d203992c6c7bf96b64da6fbae1 | [
"Apache-2.0"
] | null | null | null | test/programs/fault_localization/benchmarks/tritype/TritypeKO2.c | teodorov/cpachecker | 16e37b76c5b9e3d203992c6c7bf96b64da6fbae1 | [
"Apache-2.0"
] | 18 | 2015-02-17T19:22:41.000Z | 2015-11-24T09:12:39.000Z | /*
The program Tritype (implemented in function foo) takes as
input three integers (the sides of a triangle) and returns 3
if the input correspond to an equilateral triangle, 2 if
it correspond to an isosceles triangle, 1 if it correspond
to another type of triangle, 4 if it does not correspond
to a valid triangle.
The error in this program is in the condition
"(trityp == 1 && (i + k) > j)", the instruction should be
"(trityp == 2 && (i + k) > j)". By taking as input
the values {i=2,j=2,k=2}, the program returns 2 to indicate
that the triangle is isosceles, however, it shoudl return 4
to indicate that the input does not correspond to a valid
triangle.
SPDX-FileCopyrightText: Mohammed Bekkouche <http://www.i3s.unice.fr>
SPDX-License-Identifier: GPL-3.0-or-later
*/
extern int __VERIFIER_nondet_uint();
extern void __VERIFIER_error();
void __VERIFIER_assert(int cond) {
if (!(cond)) {
ERROR: __VERIFIER_error();
}
return;
}
/* program for triangle classification
* returns 1 if (i,j,k) are the sides of any triangle
* returns 2 if (i,j,k) are the sides of an isosceles triangle
* returns 3 if (i,j,k) are the sides of an equilateral triangle
* returns 4 if (i,j,k) are not the sides of a triangle
*
* an error has been inserted in the condition line 53
* when (i,j,k) = (2,2,4) returns 2 while it would return
* 4 since the triangular inequality 2+2>4 is not verified
*/
void foo (int i, int j, int k) {//__CPROVER_assume((i == 2) && (j == 2) && (k ==4));
int trityp;
if (i == 0 || j == 0 || k == 0) {
trityp = 4;
}
else {
trityp = 0;
if (i == j) {
trityp = trityp + 1;
}
if (i == k) {
trityp = trityp + 2;
}
if (j == k) {
trityp = trityp + 3;
}
if (trityp == 0) {
if ((i+j) <= k || (j+k) <= i || (i+k) <= j) {
trityp = 4;
}
else {
trityp = 1;
}
}
else {
if (trityp > 3) {
trityp = 3;
}
else {
if (trityp == 1 && (i+j) > k) {
trityp = 2;
}
else {
// error in the condition : trityp == 1 instead of trityp == 2
if (trityp == 1 && (i+k) > j) { // BUG
trityp = 2;
}
else {
if (trityp == 3 && (j+k) > i) {
trityp = 2;
}
else {
trityp = 4;
}
}
}
}
}
}
__VERIFIER_assert(trityp== ((i == 0 || j == 0 || k == 0)?4:( (i!=j && i!=k && j!=k)?( ((i+j)<=k || (j+k)<=i || (i+k)<=j)?4:1 ):( ((i==j && j==k) || (j==k && i==k))?3:( (i==j && i!=k && j!=k && (i+j)>k)?2:( (i!=j && j!=k && i==k && (i+k)>j)?2:( ( ((i!=j && j==k && i!=k) || (i==j && j!=k && i==k)) && (j+k)>i)?2:4 ) ) ) ) )) );
}
int main()
{
foo( __VERIFIER_nondet_int(),__VERIFIER_nondet_int(),__VERIFIER_nondet_int());
}
| 31.920792 | 335 | 0.46371 |
d99d1c083f945959a73892f350890e89832e6475 | 4,395 | h | C | components/bh1750/include/bh1750.h | CodorStelian/io-connect-esp-rainmaker | cd04bae066b55f16c35c81b9d177cf12e7b53005 | [
"BSD-2-Clause"
] | 1 | 2021-09-07T18:22:22.000Z | 2021-09-07T18:22:22.000Z | components/bh1750/include/bh1750.h | CodorStelian/io-connect-esp-rainmaker | cd04bae066b55f16c35c81b9d177cf12e7b53005 | [
"BSD-2-Clause"
] | 2 | 2021-09-07T18:43:53.000Z | 2022-03-23T15:34:46.000Z | components/bh1750/include/bh1750.h | CodorStelian/io-connect-esp-rainmaker | cd04bae066b55f16c35c81b9d177cf12e7b53005 | [
"BSD-2-Clause"
] | null | null | null | /*
* Copyright (c) 2017 Andrej Krutak <dev@andree.sk>
* Copyright (c) 2018 Ruslan V. Uss <unclerus@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holder nor the names of itscontributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file bh1750.h
* @defgroup bh1750 bh1750
* ESP-IDF driver for BH1750 light sensor
* Datasheet: ROHM Semiconductor bh1750fvi-e.pdf
* Ported from esp-open-rtos
* Copyright (c) 2017 Andrej Krutak <dev@andree.sk>\n
* Copyright (c) 2018 Ruslan V. Uss <unclerus@gmail.com>
* BSD Licensed as described in the file LICENSE
*/
#pragma once
#include <stdint.h>
#include <i2cdev.h>
#include <esp_err.h>
#ifdef __cplusplus
extern "C" {
#endif
#define BH1750_ADDR_LO 0x23 //!< I2C address when ADDR pin floating/low
#define BH1750_ADDR_HI 0x5c //!< I2C address when ADDR pin high
/**
* Measurement mode
*/
typedef enum
{
BH1750_MODE_ONE_TIME = 0, //!< One time measurement
BH1750_MODE_CONTINUOUS //!< Continuous measurement
} bh1750_mode_t;
/**
* Measurement resolution
*/
typedef enum
{
BH1750_RES_LOW = 0, //!< 4 lx resolution, measurement time is usually 16 ms
BH1750_RES_HIGH, //!< 1 lx resolution, measurement time is usually 120 ms
BH1750_RES_HIGH2 //!< 0.5 lx resolution, measurement time is usually 120 ms
} bh1750_resolution_t;
/**
* @brief Initialize device descriptor
*
* @param[out] dev Device descriptor
* @param[in] addr I2C address, ::BH1750_ADDR_LO or ::BH1750_ADDR_HI
* @param[in] port I2C port number
* @param[in] sda_gpio GPIO pin number for SDA
* @param[in] scl_gpio GPIO pin number for SCL
* @return `ESP_OK` on success
*/
esp_err_t bh1750_init_desc(i2c_dev_t *dev, uint8_t addr, i2c_port_t port, gpio_num_t sda_gpio, gpio_num_t scl_gpio);
/**
* @brief Free device descriptor
*
* @param dev Pointer to device descriptor
* @return `ESP_OK` on success
*/
esp_err_t bh1750_free_desc(i2c_dev_t *dev);
/**
* @brief Power down device
*
* @param dev Pointer to device descriptor
* @return `ESP_OK` on success
*/
esp_err_t bh1750_power_down(i2c_dev_t *dev);
/**
* @brief Power on device
*
* @param dev Pointer to device descriptor
* @return `ESP_OK` on success
*/
esp_err_t bh1750_power_on(i2c_dev_t *dev);
/**
* @brief Setup device parameters
*
* @param dev Pointer to device descriptor
* @param mode Measurement mode
* @param resolution Measurement resolution
* @return `ESP_OK` on success
*/
esp_err_t bh1750_setup(i2c_dev_t *dev, bh1750_mode_t mode, bh1750_resolution_t resolution);
/**
* @brief Set measurement time
*
* @param dev Pointer to device descriptor
* @param time Measurement time (see datasheet)
* @return `ESP_OK` on success
*/
esp_err_t bh1750_set_measurement_time(i2c_dev_t *dev, uint8_t time);
/**
* @brief Read LUX value from the device.
*
* @param dev Pointer to device descriptor
* @param[out] level read value in lux units
* @return `ESP_OK` on success
*/
esp_err_t bh1750_read(i2c_dev_t *dev, uint16_t *level);
#ifdef __cplusplus
}
#endif | 32.080292 | 116 | 0.738339 |
d99f4360703b838473b932e24f65bac861ddc660 | 31,166 | c | C | Read Only/gdb-7.12.1/gdb/fbsd-nat.c | samyvic/OS-Project | 1622bc1641876584964effd91d65ef02e92728e1 | [
"Apache-2.0"
] | null | null | null | Read Only/gdb-7.12.1/gdb/fbsd-nat.c | samyvic/OS-Project | 1622bc1641876584964effd91d65ef02e92728e1 | [
"Apache-2.0"
] | null | null | null | Read Only/gdb-7.12.1/gdb/fbsd-nat.c | samyvic/OS-Project | 1622bc1641876584964effd91d65ef02e92728e1 | [
"Apache-2.0"
] | null | null | null | /* Native-dependent code for FreeBSD.
Copyright (C) 2002-2017 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "gdbcore.h"
#include "inferior.h"
#include "regcache.h"
#include "regset.h"
#include "gdbcmd.h"
#include "gdbthread.h"
#include "gdb_wait.h"
#include <sys/types.h>
#include <sys/procfs.h>
#include <sys/ptrace.h>
#include <sys/sysctl.h>
#ifdef HAVE_KINFO_GETVMMAP
#include <sys/user.h>
#include <libutil.h>
#endif
#include "elf-bfd.h"
#include "fbsd-nat.h"
/* Return the name of a file that can be opened to get the symbols for
the child process identified by PID. */
static char *
fbsd_pid_to_exec_file (struct target_ops *self, int pid)
{
ssize_t len;
static char buf[PATH_MAX];
char name[PATH_MAX];
#ifdef KERN_PROC_PATHNAME
size_t buflen;
int mib[4];
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PATHNAME;
mib[3] = pid;
buflen = sizeof buf;
if (sysctl (mib, 4, buf, &buflen, NULL, 0) == 0)
return buf;
#endif
xsnprintf (name, PATH_MAX, "/proc/%d/exe", pid);
len = readlink (name, buf, PATH_MAX - 1);
if (len != -1)
{
buf[len] = '\0';
return buf;
}
return NULL;
}
#ifdef HAVE_KINFO_GETVMMAP
/* Iterate over all the memory regions in the current inferior,
calling FUNC for each memory region. OBFD is passed as the last
argument to FUNC. */
static int
fbsd_find_memory_regions (struct target_ops *self,
find_memory_region_ftype func, void *obfd)
{
pid_t pid = ptid_get_pid (inferior_ptid);
struct kinfo_vmentry *vmentl, *kve;
uint64_t size;
struct cleanup *cleanup;
int i, nitems;
vmentl = kinfo_getvmmap (pid, &nitems);
if (vmentl == NULL)
perror_with_name (_("Couldn't fetch VM map entries."));
cleanup = make_cleanup (free, vmentl);
for (i = 0; i < nitems; i++)
{
kve = &vmentl[i];
/* Skip unreadable segments and those where MAP_NOCORE has been set. */
if (!(kve->kve_protection & KVME_PROT_READ)
|| kve->kve_flags & KVME_FLAG_NOCOREDUMP)
continue;
/* Skip segments with an invalid type. */
if (kve->kve_type != KVME_TYPE_DEFAULT
&& kve->kve_type != KVME_TYPE_VNODE
&& kve->kve_type != KVME_TYPE_SWAP
&& kve->kve_type != KVME_TYPE_PHYS)
continue;
size = kve->kve_end - kve->kve_start;
if (info_verbose)
{
fprintf_filtered (gdb_stdout,
"Save segment, %ld bytes at %s (%c%c%c)\n",
(long) size,
paddress (target_gdbarch (), kve->kve_start),
kve->kve_protection & KVME_PROT_READ ? 'r' : '-',
kve->kve_protection & KVME_PROT_WRITE ? 'w' : '-',
kve->kve_protection & KVME_PROT_EXEC ? 'x' : '-');
}
/* Invoke the callback function to create the corefile segment.
Pass MODIFIED as true, we do not know the real modification state. */
func (kve->kve_start, size, kve->kve_protection & KVME_PROT_READ,
kve->kve_protection & KVME_PROT_WRITE,
kve->kve_protection & KVME_PROT_EXEC, 1, obfd);
}
do_cleanups (cleanup);
return 0;
}
#else
static int
fbsd_read_mapping (FILE *mapfile, unsigned long *start, unsigned long *end,
char *protection)
{
/* FreeBSD 5.1-RELEASE uses a 256-byte buffer. */
char buf[256];
int resident, privateresident;
unsigned long obj;
int ret = EOF;
/* As of FreeBSD 5.0-RELEASE, the layout is described in
/usr/src/sys/fs/procfs/procfs_map.c. Somewhere in 5.1-CURRENT a
new column was added to the procfs map. Therefore we can't use
fscanf since we need to support older releases too. */
if (fgets (buf, sizeof buf, mapfile) != NULL)
ret = sscanf (buf, "%lx %lx %d %d %lx %s", start, end,
&resident, &privateresident, &obj, protection);
return (ret != 0 && ret != EOF);
}
/* Iterate over all the memory regions in the current inferior,
calling FUNC for each memory region. OBFD is passed as the last
argument to FUNC. */
static int
fbsd_find_memory_regions (struct target_ops *self,
find_memory_region_ftype func, void *obfd)
{
pid_t pid = ptid_get_pid (inferior_ptid);
char *mapfilename;
FILE *mapfile;
unsigned long start, end, size;
char protection[4];
int read, write, exec;
struct cleanup *cleanup;
mapfilename = xstrprintf ("/proc/%ld/map", (long) pid);
cleanup = make_cleanup (xfree, mapfilename);
mapfile = fopen (mapfilename, "r");
if (mapfile == NULL)
error (_("Couldn't open %s."), mapfilename);
make_cleanup_fclose (mapfile);
if (info_verbose)
fprintf_filtered (gdb_stdout,
"Reading memory regions from %s\n", mapfilename);
/* Now iterate until end-of-file. */
while (fbsd_read_mapping (mapfile, &start, &end, &protection[0]))
{
size = end - start;
read = (strchr (protection, 'r') != 0);
write = (strchr (protection, 'w') != 0);
exec = (strchr (protection, 'x') != 0);
if (info_verbose)
{
fprintf_filtered (gdb_stdout,
"Save segment, %ld bytes at %s (%c%c%c)\n",
size, paddress (target_gdbarch (), start),
read ? 'r' : '-',
write ? 'w' : '-',
exec ? 'x' : '-');
}
/* Invoke the callback function to create the corefile segment.
Pass MODIFIED as true, we do not know the real modification state. */
func (start, size, read, write, exec, 1, obfd);
}
do_cleanups (cleanup);
return 0;
}
#endif
#ifdef KERN_PROC_AUXV
static enum target_xfer_status (*super_xfer_partial) (struct target_ops *ops,
enum target_object object,
const char *annex,
gdb_byte *readbuf,
const gdb_byte *writebuf,
ULONGEST offset,
ULONGEST len,
ULONGEST *xfered_len);
/* Implement the "to_xfer_partial target_ops" method. */
static enum target_xfer_status
fbsd_xfer_partial (struct target_ops *ops, enum target_object object,
const char *annex, gdb_byte *readbuf,
const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
{
pid_t pid = ptid_get_pid (inferior_ptid);
switch (object)
{
case TARGET_OBJECT_AUXV:
{
struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
unsigned char *buf;
size_t buflen;
int mib[4];
if (writebuf != NULL)
return TARGET_XFER_E_IO;
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_AUXV;
mib[3] = pid;
if (offset == 0)
{
buf = readbuf;
buflen = len;
}
else
{
buflen = offset + len;
buf = XCNEWVEC (unsigned char, buflen);
cleanup = make_cleanup (xfree, buf);
}
if (sysctl (mib, 4, buf, &buflen, NULL, 0) == 0)
{
if (offset != 0)
{
if (buflen > offset)
{
buflen -= offset;
memcpy (readbuf, buf + offset, buflen);
}
else
buflen = 0;
}
do_cleanups (cleanup);
*xfered_len = buflen;
return (buflen == 0) ? TARGET_XFER_EOF : TARGET_XFER_OK;
}
do_cleanups (cleanup);
return TARGET_XFER_E_IO;
}
default:
return super_xfer_partial (ops, object, annex, readbuf, writebuf, offset,
len, xfered_len);
}
}
#endif
#ifdef PT_LWPINFO
static int debug_fbsd_lwp;
static void (*super_resume) (struct target_ops *,
ptid_t,
int,
enum gdb_signal);
static ptid_t (*super_wait) (struct target_ops *,
ptid_t,
struct target_waitstatus *,
int);
static void
show_fbsd_lwp_debug (struct ui_file *file, int from_tty,
struct cmd_list_element *c, const char *value)
{
fprintf_filtered (file, _("Debugging of FreeBSD lwp module is %s.\n"), value);
}
#if defined(TDP_RFPPWAIT) || defined(HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME)
/* Fetch the external variant of the kernel's internal process
structure for the process PID into KP. */
static void
fbsd_fetch_kinfo_proc (pid_t pid, struct kinfo_proc *kp)
{
size_t len;
int mib[4];
len = sizeof *kp;
mib[0] = CTL_KERN;
mib[1] = KERN_PROC;
mib[2] = KERN_PROC_PID;
mib[3] = pid;
if (sysctl (mib, 4, kp, &len, NULL, 0) == -1)
perror_with_name (("sysctl"));
}
#endif
/*
FreeBSD's first thread support was via a "reentrant" version of libc
(libc_r) that first shipped in 2.2.7. This library multiplexed all
of the threads in a process onto a single kernel thread. This
library is supported via the bsd-uthread target.
FreeBSD 5.1 introduced two new threading libraries that made use of
multiple kernel threads. The first (libkse) scheduled M user
threads onto N (<= M) kernel threads (LWPs). The second (libthr)
bound each user thread to a dedicated kernel thread. libkse shipped
as the default threading library (libpthread).
FreeBSD 5.3 added a libthread_db to abstract the interface across
the various thread libraries (libc_r, libkse, and libthr).
FreeBSD 7.0 switched the default threading library from from libkse
to libpthread and removed libc_r.
FreeBSD 8.0 removed libkse and the in-kernel support for it. The
only threading library supported by 8.0 and later is libthr which
ties each user thread directly to an LWP. To simplify the
implementation, this target only supports LWP-backed threads using
ptrace directly rather than libthread_db.
FreeBSD 11.0 introduced LWP event reporting via PT_LWP_EVENTS.
*/
/* Return true if PTID is still active in the inferior. */
static int
fbsd_thread_alive (struct target_ops *ops, ptid_t ptid)
{
if (ptid_lwp_p (ptid))
{
struct ptrace_lwpinfo pl;
if (ptrace (PT_LWPINFO, ptid_get_lwp (ptid), (caddr_t) &pl, sizeof pl)
== -1)
return 0;
#ifdef PL_FLAG_EXITED
if (pl.pl_flags & PL_FLAG_EXITED)
return 0;
#endif
}
return 1;
}
/* Convert PTID to a string. Returns the string in a static
buffer. */
static char *
fbsd_pid_to_str (struct target_ops *ops, ptid_t ptid)
{
lwpid_t lwp;
lwp = ptid_get_lwp (ptid);
if (lwp != 0)
{
static char buf[64];
int pid = ptid_get_pid (ptid);
xsnprintf (buf, sizeof buf, "LWP %d of process %d", lwp, pid);
return buf;
}
return normal_pid_to_str (ptid);
}
#ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME
/* Return the name assigned to a thread by an application. Returns
the string in a static buffer. */
static const char *
fbsd_thread_name (struct target_ops *self, struct thread_info *thr)
{
struct ptrace_lwpinfo pl;
struct kinfo_proc kp;
int pid = ptid_get_pid (thr->ptid);
long lwp = ptid_get_lwp (thr->ptid);
static char buf[sizeof pl.pl_tdname + 1];
/* Note that ptrace_lwpinfo returns the process command in pl_tdname
if a name has not been set explicitly. Return a NULL name in
that case. */
fbsd_fetch_kinfo_proc (pid, &kp);
if (ptrace (PT_LWPINFO, lwp, (caddr_t) &pl, sizeof pl) == -1)
perror_with_name (("ptrace"));
if (strcmp (kp.ki_comm, pl.pl_tdname) == 0)
return NULL;
xsnprintf (buf, sizeof buf, "%s", pl.pl_tdname);
return buf;
}
#endif
/* Enable additional event reporting on new processes.
To catch fork events, PTRACE_FORK is set on every traced process
to enable stops on returns from fork or vfork. Note that both the
parent and child will always stop, even if system call stops are
not enabled.
To catch LWP events, PTRACE_EVENTS is set on every traced process.
This enables stops on the birth for new LWPs (excluding the "main" LWP)
and the death of LWPs (excluding the last LWP in a process). Note
that unlike fork events, the LWP that creates a new LWP does not
report an event. */
static void
fbsd_enable_proc_events (pid_t pid)
{
#ifdef PT_GET_EVENT_MASK
int events;
if (ptrace (PT_GET_EVENT_MASK, pid, (PTRACE_TYPE_ARG3)&events,
sizeof (events)) == -1)
perror_with_name (("ptrace"));
events |= PTRACE_FORK | PTRACE_LWP;
#ifdef PTRACE_VFORK
events |= PTRACE_VFORK;
#endif
if (ptrace (PT_SET_EVENT_MASK, pid, (PTRACE_TYPE_ARG3)&events,
sizeof (events)) == -1)
perror_with_name (("ptrace"));
#else
#ifdef TDP_RFPPWAIT
if (ptrace (PT_FOLLOW_FORK, pid, (PTRACE_TYPE_ARG3)0, 1) == -1)
perror_with_name (("ptrace"));
#endif
#ifdef PT_LWP_EVENTS
if (ptrace (PT_LWP_EVENTS, pid, (PTRACE_TYPE_ARG3)0, 1) == -1)
perror_with_name (("ptrace"));
#endif
#endif
}
/* Add threads for any new LWPs in a process.
When LWP events are used, this function is only used to detect existing
threads when attaching to a process. On older systems, this function is
called to discover new threads each time the thread list is updated. */
static void
fbsd_add_threads (pid_t pid)
{
struct cleanup *cleanup;
lwpid_t *lwps;
int i, nlwps;
gdb_assert (!in_thread_list (pid_to_ptid (pid)));
nlwps = ptrace (PT_GETNUMLWPS, pid, NULL, 0);
if (nlwps == -1)
perror_with_name (("ptrace"));
lwps = XCNEWVEC (lwpid_t, nlwps);
cleanup = make_cleanup (xfree, lwps);
nlwps = ptrace (PT_GETLWPLIST, pid, (caddr_t) lwps, nlwps);
if (nlwps == -1)
perror_with_name (("ptrace"));
for (i = 0; i < nlwps; i++)
{
ptid_t ptid = ptid_build (pid, lwps[i], 0);
if (!in_thread_list (ptid))
{
#ifdef PT_LWP_EVENTS
struct ptrace_lwpinfo pl;
/* Don't add exited threads. Note that this is only called
when attaching to a multi-threaded process. */
if (ptrace (PT_LWPINFO, lwps[i], (caddr_t) &pl, sizeof pl) == -1)
perror_with_name (("ptrace"));
if (pl.pl_flags & PL_FLAG_EXITED)
continue;
#endif
if (debug_fbsd_lwp)
fprintf_unfiltered (gdb_stdlog,
"FLWP: adding thread for LWP %u\n",
lwps[i]);
add_thread (ptid);
}
}
do_cleanups (cleanup);
}
/* Implement the "to_update_thread_list" target_ops method. */
static void
fbsd_update_thread_list (struct target_ops *ops)
{
#ifdef PT_LWP_EVENTS
/* With support for thread events, threads are added/deleted from the
list as events are reported, so just try deleting exited threads. */
delete_exited_threads ();
#else
prune_threads ();
fbsd_add_threads (ptid_get_pid (inferior_ptid));
#endif
}
#ifdef TDP_RFPPWAIT
/*
To catch fork events, PT_FOLLOW_FORK is set on every traced process
to enable stops on returns from fork or vfork. Note that both the
parent and child will always stop, even if system call stops are not
enabled.
After a fork, both the child and parent process will stop and report
an event. However, there is no guarantee of order. If the parent
reports its stop first, then fbsd_wait explicitly waits for the new
child before returning. If the child reports its stop first, then
the event is saved on a list and ignored until the parent's stop is
reported. fbsd_wait could have been changed to fetch the parent PID
of the new child and used that to wait for the parent explicitly.
However, if two threads in the parent fork at the same time, then
the wait on the parent might return the "wrong" fork event.
The initial version of PT_FOLLOW_FORK did not set PL_FLAG_CHILD for
the new child process. This flag could be inferred by treating any
events for an unknown pid as a new child.
In addition, the initial version of PT_FOLLOW_FORK did not report a
stop event for the parent process of a vfork until after the child
process executed a new program or exited. The kernel was changed to
defer the wait for exit or exec of the child until after posting the
stop event shortly after the change to introduce PL_FLAG_CHILD.
This could be worked around by reporting a vfork event when the
child event posted and ignoring the subsequent event from the
parent.
This implementation requires both of these fixes for simplicity's
sake. FreeBSD versions newer than 9.1 contain both fixes.
*/
struct fbsd_fork_info
{
struct fbsd_fork_info *next;
ptid_t ptid;
};
static struct fbsd_fork_info *fbsd_pending_children;
/* Record a new child process event that is reported before the
corresponding fork event in the parent. */
static void
fbsd_remember_child (ptid_t pid)
{
struct fbsd_fork_info *info = XCNEW (struct fbsd_fork_info);
info->ptid = pid;
info->next = fbsd_pending_children;
fbsd_pending_children = info;
}
/* Check for a previously-recorded new child process event for PID.
If one is found, remove it from the list and return the PTID. */
static ptid_t
fbsd_is_child_pending (pid_t pid)
{
struct fbsd_fork_info *info, *prev;
ptid_t ptid;
prev = NULL;
for (info = fbsd_pending_children; info; prev = info, info = info->next)
{
if (ptid_get_pid (info->ptid) == pid)
{
if (prev == NULL)
fbsd_pending_children = info->next;
else
prev->next = info->next;
ptid = info->ptid;
xfree (info);
return ptid;
}
}
return null_ptid;
}
#ifndef PTRACE_VFORK
static struct fbsd_fork_info *fbsd_pending_vfork_done;
/* Record a pending vfork done event. */
static void
fbsd_add_vfork_done (ptid_t pid)
{
struct fbsd_fork_info *info = XCNEW (struct fbsd_fork_info);
info->ptid = pid;
info->next = fbsd_pending_vfork_done;
fbsd_pending_vfork_done = info;
}
/* Check for a pending vfork done event for a specific PID. */
static int
fbsd_is_vfork_done_pending (pid_t pid)
{
struct fbsd_fork_info *info;
for (info = fbsd_pending_vfork_done; info != NULL; info = info->next)
{
if (ptid_get_pid (info->ptid) == pid)
return 1;
}
return 0;
}
/* Check for a pending vfork done event. If one is found, remove it
from the list and return the PTID. */
static ptid_t
fbsd_next_vfork_done (void)
{
struct fbsd_fork_info *info;
ptid_t ptid;
if (fbsd_pending_vfork_done != NULL)
{
info = fbsd_pending_vfork_done;
fbsd_pending_vfork_done = info->next;
ptid = info->ptid;
xfree (info);
return ptid;
}
return null_ptid;
}
#endif
#endif
static int
resume_one_thread_cb (struct thread_info *tp, void *data)
{
ptid_t *ptid = (ptid_t *) data;
int request;
if (ptid_get_pid (tp->ptid) != ptid_get_pid (*ptid))
return 0;
if (ptid_get_lwp (tp->ptid) == ptid_get_lwp (*ptid))
request = PT_RESUME;
else
request = PT_SUSPEND;
if (ptrace (request, ptid_get_lwp (tp->ptid), NULL, 0) == -1)
perror_with_name (("ptrace"));
return 0;
}
static int
resume_all_threads_cb (struct thread_info *tp, void *data)
{
ptid_t *filter = (ptid_t *) data;
if (!ptid_match (tp->ptid, *filter))
return 0;
if (ptrace (PT_RESUME, ptid_get_lwp (tp->ptid), NULL, 0) == -1)
perror_with_name (("ptrace"));
return 0;
}
/* Implement the "to_resume" target_ops method. */
static void
fbsd_resume (struct target_ops *ops,
ptid_t ptid, int step, enum gdb_signal signo)
{
#if defined(TDP_RFPPWAIT) && !defined(PTRACE_VFORK)
pid_t pid;
/* Don't PT_CONTINUE a process which has a pending vfork done event. */
if (ptid_equal (minus_one_ptid, ptid))
pid = ptid_get_pid (inferior_ptid);
else
pid = ptid_get_pid (ptid);
if (fbsd_is_vfork_done_pending (pid))
return;
#endif
if (debug_fbsd_lwp)
fprintf_unfiltered (gdb_stdlog,
"FLWP: fbsd_resume for ptid (%d, %ld, %ld)\n",
ptid_get_pid (ptid), ptid_get_lwp (ptid),
ptid_get_tid (ptid));
if (ptid_lwp_p (ptid))
{
/* If ptid is a specific LWP, suspend all other LWPs in the process. */
iterate_over_threads (resume_one_thread_cb, &ptid);
}
else
{
/* If ptid is a wildcard, resume all matching threads (they won't run
until the process is continued however). */
iterate_over_threads (resume_all_threads_cb, &ptid);
ptid = inferior_ptid;
}
super_resume (ops, ptid, step, signo);
}
/* Wait for the child specified by PTID to do something. Return the
process ID of the child, or MINUS_ONE_PTID in case of error; store
the status in *OURSTATUS. */
static ptid_t
fbsd_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *ourstatus,
int target_options)
{
ptid_t wptid;
while (1)
{
#ifndef PTRACE_VFORK
wptid = fbsd_next_vfork_done ();
if (!ptid_equal (wptid, null_ptid))
{
ourstatus->kind = TARGET_WAITKIND_VFORK_DONE;
return wptid;
}
#endif
wptid = super_wait (ops, ptid, ourstatus, target_options);
if (ourstatus->kind == TARGET_WAITKIND_STOPPED)
{
struct ptrace_lwpinfo pl;
pid_t pid;
int status;
pid = ptid_get_pid (wptid);
if (ptrace (PT_LWPINFO, pid, (caddr_t) &pl, sizeof pl) == -1)
perror_with_name (("ptrace"));
wptid = ptid_build (pid, pl.pl_lwpid, 0);
#ifdef PT_LWP_EVENTS
if (pl.pl_flags & PL_FLAG_EXITED)
{
/* If GDB attaches to a multi-threaded process, exiting
threads might be skipped during fbsd_post_attach that
have not yet reported their PL_FLAG_EXITED event.
Ignore EXITED events for an unknown LWP. */
if (in_thread_list (wptid))
{
if (debug_fbsd_lwp)
fprintf_unfiltered (gdb_stdlog,
"FLWP: deleting thread for LWP %u\n",
pl.pl_lwpid);
if (print_thread_events)
printf_unfiltered (_("[%s exited]\n"), target_pid_to_str
(wptid));
delete_thread (wptid);
}
if (ptrace (PT_CONTINUE, pid, (caddr_t) 1, 0) == -1)
perror_with_name (("ptrace"));
continue;
}
#endif
/* Switch to an LWP PTID on the first stop in a new process.
This is done after handling PL_FLAG_EXITED to avoid
switching to an exited LWP. It is done before checking
PL_FLAG_BORN in case the first stop reported after
attaching to an existing process is a PL_FLAG_BORN
event. */
if (in_thread_list (pid_to_ptid (pid)))
{
if (debug_fbsd_lwp)
fprintf_unfiltered (gdb_stdlog,
"FLWP: using LWP %u for first thread\n",
pl.pl_lwpid);
thread_change_ptid (pid_to_ptid (pid), wptid);
}
#ifdef PT_LWP_EVENTS
if (pl.pl_flags & PL_FLAG_BORN)
{
/* If GDB attaches to a multi-threaded process, newborn
threads might be added by fbsd_add_threads that have
not yet reported their PL_FLAG_BORN event. Ignore
BORN events for an already-known LWP. */
if (!in_thread_list (wptid))
{
if (debug_fbsd_lwp)
fprintf_unfiltered (gdb_stdlog,
"FLWP: adding thread for LWP %u\n",
pl.pl_lwpid);
add_thread (wptid);
}
ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
return wptid;
}
#endif
#ifdef TDP_RFPPWAIT
if (pl.pl_flags & PL_FLAG_FORKED)
{
#ifndef PTRACE_VFORK
struct kinfo_proc kp;
#endif
ptid_t child_ptid;
pid_t child;
child = pl.pl_child_pid;
ourstatus->kind = TARGET_WAITKIND_FORKED;
#ifdef PTRACE_VFORK
if (pl.pl_flags & PL_FLAG_VFORKED)
ourstatus->kind = TARGET_WAITKIND_VFORKED;
#endif
/* Make sure the other end of the fork is stopped too. */
child_ptid = fbsd_is_child_pending (child);
if (ptid_equal (child_ptid, null_ptid))
{
pid = waitpid (child, &status, 0);
if (pid == -1)
perror_with_name (("waitpid"));
gdb_assert (pid == child);
if (ptrace (PT_LWPINFO, child, (caddr_t)&pl, sizeof pl) == -1)
perror_with_name (("ptrace"));
gdb_assert (pl.pl_flags & PL_FLAG_CHILD);
child_ptid = ptid_build (child, pl.pl_lwpid, 0);
}
/* Enable additional events on the child process. */
fbsd_enable_proc_events (ptid_get_pid (child_ptid));
#ifndef PTRACE_VFORK
/* For vfork, the child process will have the P_PPWAIT
flag set. */
fbsd_fetch_kinfo_proc (child, &kp);
if (kp.ki_flag & P_PPWAIT)
ourstatus->kind = TARGET_WAITKIND_VFORKED;
#endif
ourstatus->value.related_pid = child_ptid;
return wptid;
}
if (pl.pl_flags & PL_FLAG_CHILD)
{
/* Remember that this child forked, but do not report it
until the parent reports its corresponding fork
event. */
fbsd_remember_child (wptid);
continue;
}
#ifdef PTRACE_VFORK
if (pl.pl_flags & PL_FLAG_VFORK_DONE)
{
ourstatus->kind = TARGET_WAITKIND_VFORK_DONE;
return wptid;
}
#endif
#endif
#ifdef PL_FLAG_EXEC
if (pl.pl_flags & PL_FLAG_EXEC)
{
ourstatus->kind = TARGET_WAITKIND_EXECD;
ourstatus->value.execd_pathname
= xstrdup (fbsd_pid_to_exec_file (NULL, pid));
return wptid;
}
#endif
/* Note that PL_FLAG_SCE is set for any event reported while
a thread is executing a system call in the kernel. In
particular, signals that interrupt a sleep in a system
call will report this flag as part of their event. Stops
explicitly for system call entry and exit always use
SIGTRAP, so only treat SIGTRAP events as system call
entry/exit events. */
if (pl.pl_flags & (PL_FLAG_SCE | PL_FLAG_SCX)
&& ourstatus->value.sig == SIGTRAP)
{
#ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE
if (catch_syscall_enabled ())
{
if (catching_syscall_number (pl.pl_syscall_code))
{
if (pl.pl_flags & PL_FLAG_SCE)
ourstatus->kind = TARGET_WAITKIND_SYSCALL_ENTRY;
else
ourstatus->kind = TARGET_WAITKIND_SYSCALL_RETURN;
ourstatus->value.syscall_number = pl.pl_syscall_code;
return wptid;
}
}
#endif
/* If the core isn't interested in this event, just
continue the process explicitly and wait for another
event. Note that PT_SYSCALL is "sticky" on FreeBSD
and once system call stops are enabled on a process
it stops for all system call entries and exits. */
if (ptrace (PT_CONTINUE, pid, (caddr_t) 1, 0) == -1)
perror_with_name (("ptrace"));
continue;
}
}
return wptid;
}
}
#ifdef TDP_RFPPWAIT
/* Target hook for follow_fork. On entry and at return inferior_ptid is
the ptid of the followed inferior. */
static int
fbsd_follow_fork (struct target_ops *ops, int follow_child,
int detach_fork)
{
if (!follow_child && detach_fork)
{
struct thread_info *tp = inferior_thread ();
pid_t child_pid = ptid_get_pid (tp->pending_follow.value.related_pid);
/* Breakpoints have already been detached from the child by
infrun.c. */
if (ptrace (PT_DETACH, child_pid, (PTRACE_TYPE_ARG3)1, 0) == -1)
perror_with_name (("ptrace"));
#ifndef PTRACE_VFORK
if (tp->pending_follow.kind == TARGET_WAITKIND_VFORKED)
{
/* We can't insert breakpoints until the child process has
finished with the shared memory region. The parent
process doesn't wait for the child process to exit or
exec until after it has been resumed from the ptrace stop
to report the fork. Once it has been resumed it doesn't
stop again before returning to userland, so there is no
reliable way to wait on the parent.
We can't stay attached to the child to wait for an exec
or exit because it may invoke ptrace(PT_TRACE_ME)
(e.g. if the parent process is a debugger forking a new
child process).
In the end, the best we can do is to make sure it runs
for a little while. Hopefully it will be out of range of
any breakpoints we reinsert. Usually this is only the
single-step breakpoint at vfork's return point. */
usleep (10000);
/* Schedule a fake VFORK_DONE event to report on the next
wait. */
fbsd_add_vfork_done (inferior_ptid);
}
#endif
}
return 0;
}
static int
fbsd_insert_fork_catchpoint (struct target_ops *self, int pid)
{
return 0;
}
static int
fbsd_remove_fork_catchpoint (struct target_ops *self, int pid)
{
return 0;
}
static int
fbsd_insert_vfork_catchpoint (struct target_ops *self, int pid)
{
return 0;
}
static int
fbsd_remove_vfork_catchpoint (struct target_ops *self, int pid)
{
return 0;
}
#endif
/* Implement the "to_post_startup_inferior" target_ops method. */
static void
fbsd_post_startup_inferior (struct target_ops *self, ptid_t pid)
{
fbsd_enable_proc_events (ptid_get_pid (pid));
}
/* Implement the "to_post_attach" target_ops method. */
static void
fbsd_post_attach (struct target_ops *self, int pid)
{
fbsd_enable_proc_events (pid);
fbsd_add_threads (pid);
}
#ifdef PL_FLAG_EXEC
/* If the FreeBSD kernel supports PL_FLAG_EXEC, then traced processes
will always stop after exec. */
static int
fbsd_insert_exec_catchpoint (struct target_ops *self, int pid)
{
return 0;
}
static int
fbsd_remove_exec_catchpoint (struct target_ops *self, int pid)
{
return 0;
}
#endif
#ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE
static int
fbsd_set_syscall_catchpoint (struct target_ops *self, int pid, int needed,
int any_count, int table_size, int *table)
{
/* Ignore the arguments. inf-ptrace.c will use PT_SYSCALL which
will catch all system call entries and exits. The system calls
are filtered by GDB rather than the kernel. */
return 0;
}
#endif
#endif
void
fbsd_nat_add_target (struct target_ops *t)
{
t->to_pid_to_exec_file = fbsd_pid_to_exec_file;
t->to_find_memory_regions = fbsd_find_memory_regions;
#ifdef KERN_PROC_AUXV
super_xfer_partial = t->to_xfer_partial;
t->to_xfer_partial = fbsd_xfer_partial;
#endif
#ifdef PT_LWPINFO
t->to_thread_alive = fbsd_thread_alive;
t->to_pid_to_str = fbsd_pid_to_str;
#ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_TDNAME
t->to_thread_name = fbsd_thread_name;
#endif
t->to_update_thread_list = fbsd_update_thread_list;
t->to_has_thread_control = tc_schedlock;
super_resume = t->to_resume;
t->to_resume = fbsd_resume;
super_wait = t->to_wait;
t->to_wait = fbsd_wait;
t->to_post_startup_inferior = fbsd_post_startup_inferior;
t->to_post_attach = fbsd_post_attach;
#ifdef TDP_RFPPWAIT
t->to_follow_fork = fbsd_follow_fork;
t->to_insert_fork_catchpoint = fbsd_insert_fork_catchpoint;
t->to_remove_fork_catchpoint = fbsd_remove_fork_catchpoint;
t->to_insert_vfork_catchpoint = fbsd_insert_vfork_catchpoint;
t->to_remove_vfork_catchpoint = fbsd_remove_vfork_catchpoint;
#endif
#ifdef PL_FLAG_EXEC
t->to_insert_exec_catchpoint = fbsd_insert_exec_catchpoint;
t->to_remove_exec_catchpoint = fbsd_remove_exec_catchpoint;
#endif
#ifdef HAVE_STRUCT_PTRACE_LWPINFO_PL_SYSCALL_CODE
t->to_set_syscall_catchpoint = fbsd_set_syscall_catchpoint;
#endif
#endif
add_target (t);
}
/* Provide a prototype to silence -Wmissing-prototypes. */
extern initialize_file_ftype _initialize_fbsd_nat;
void
_initialize_fbsd_nat (void)
{
#ifdef PT_LWPINFO
add_setshow_boolean_cmd ("fbsd-lwp", class_maintenance,
&debug_fbsd_lwp, _("\
Set debugging of FreeBSD lwp module."), _("\
Show debugging of FreeBSD lwp module."), _("\
Enables printf debugging output."),
NULL,
&show_fbsd_lwp_debug,
&setdebuglist, &showdebuglist);
#endif
}
| 27.926523 | 80 | 0.689983 |
d9a09d9e5f2ad83585674bbb93cf419dfd1d3227 | 9,376 | c | C | src/containers.c | violet2016/plcontainer | 95f50bab90b88fa85850d79c3e848327f52ec8e2 | [
"BSD-2-Clause-FreeBSD",
"BSD-3-Clause"
] | null | null | null | src/containers.c | violet2016/plcontainer | 95f50bab90b88fa85850d79c3e848327f52ec8e2 | [
"BSD-2-Clause-FreeBSD",
"BSD-3-Clause"
] | null | null | null | src/containers.c | violet2016/plcontainer | 95f50bab90b88fa85850d79c3e848327f52ec8e2 | [
"BSD-2-Clause-FreeBSD",
"BSD-3-Clause"
] | null | null | null | /*------------------------------------------------------------------------------
*
* Copyright (c) 2016-Present Pivotal Software, Inc
*
*------------------------------------------------------------------------------
*/
#include "postgres.h"
#include "miscadmin.h"
#include "utils/guc.h"
#ifndef PLC_PG
#include "cdb/cdbvars.h"
#include "utils/faultinjector.h"
#else
#include "catalog/pg_type.h"
#include "miscadmin.h"
#include "utils/guc.h"
#include <stdarg.h>
#endif
#include "storage/ipc.h"
#include "libpq/pqsignal.h"
#include "utils/ps_status.h"
#include <ctype.h>
#include <time.h>
#include <libgen.h>
#include <sys/wait.h>
#include <unistd.h>
#include "common/comm_channel.h"
#include "common/comm_connectivity.h"
#include "common/comm_dummy.h"
#include "common/messages/messages.h"
#include "plc/plc_configuration.h"
#include "plc/containers.h"
#include "plc/plc_backend_api.h"
typedef struct {
char *runtimeid;
plcContext *ctx;
} container_t;
#define MAX_CONTAINER_NUMBER 10
static container_t containers[MAX_CONTAINER_NUMBER];
static int containers_size = 0;
static int check_runtime_id(const char *id);
static char *get_coordinator_address(void);
static int get_new_container_from_coordinator(const char *runtime_id, plcContext *ctx);
static plcContext *get_new_container_ctx(const char *runtime_id);
static int init_container_connection(plcContext *ctx);
static void insert_container_ctx(const char *runtime_id, plcContext *ctx, int slot);
static void insert_container_ctx(const char *runtime_id, plcContext *ctx, int slot)
{
containers[slot].runtimeid = plc_top_strdup(runtime_id);
containers[slot].ctx = ctx;
}
plcContext *get_container_context(const char *runtime_id)
{
int i;
plcContext *newCtx = NULL;
#ifndef PLC_PG
SIMPLE_FAULT_INJECTOR("plcontainer_before_container_connected");
#endif
for (i = 0; i < containers_size; i++)
if (strcmp(containers[i].runtimeid, runtime_id) == 0)
return containers[i].ctx;
i = containers_size+1;
/* No connection available */
if (i >= MAX_CONTAINER_NUMBER)
plc_elog(ERROR, "too many plcontainer runtime in a session");
/* Container Context could not be NULL, otherwise an elog(ERROR) will be thrown out */
newCtx = get_new_container_ctx(runtime_id);
insert_container_ctx(runtime_id, newCtx, i);
containers_size++;
return newCtx;
}
// return a plcContext that connected to the server
// TODO: complete impl
static plcContext *get_new_container_ctx(const char *runtime_id)
{
plcContext *ctx = NULL;
int res = 0;
/* TODO: the initialize refactor? */
ctx = (plcContext*) palloc0(sizeof(plcContext));
plcContextInit(ctx);
res = get_new_container_from_coordinator(runtime_id, ctx);
if (res != 0){
/* TODO: Using errors instead of elog */
elog(ERROR, "Cannot find an available container");
}
res = init_container_connection(ctx);
if (res != 0)
{
/* TODO: Using errors instead of elog */
plcFreeContext(ctx);
elog(ERROR, "Cannot connect to container server");
}
return ctx;
}
/* TODO: using emun to instead of int? */
static int get_new_container_from_coordinator(const char *runtime_id, plcContext *ctx)
{
plcConn *conn; // a connection used to connect to coordinator
int ret = 0;
(void)runtime_id;
(void)ctx;
conn = (plcConn*) palloc0(sizeof(plcConn));
/* current only uds is supported */
conn->sock = plcDialToServer("unix", get_coordinator_address());
/* send message to coordinator */
/* release the connection */
plcDisconnect(conn);
return ret;
}
// This function is called by plcontainer only.
// when socket fd of plcConn is ready, make a shakehand to the server
// returns 0 if successfully, otherwise -1 if failed.
static int init_container_connection(plcContext *ctx)
{
plcMsgPing *mping = NULL;
plcConn *conn = (plcConn *)ctx;
unsigned int sleepus = 25000;
unsigned int sleepms = 0;
mping = (plcMsgPing*) palloc(sizeof(plcMsgPing));
mping->msgtype = MT_PING;
while (sleepms < CONTAINER_CONNECT_TIMEOUT_MS) {
int res = 0;
plcMessage *mresp = NULL;
res = plcontainer_channel_send(conn, (plcMessage *) mping);
if (res == 0)
{
res = plcontainer_channel_receive(conn, &mresp, MT_PING_BIT);
if (mresp != NULL)
pfree(mresp);
if (res == 0)
{
pfree(mping);
return 0;
}
else
{
plc_elog(DEBUG1, "Failed to receive pong from client.");
}
} else {
plc_elog(DEBUG1, "Failed to send ping to client.");
}
/*
* Note about the plcDisconnect(conn) code above:
*
* We saw the case that connection() + send() are ok, but rx
* fails with "reset by peer" while the client program has not started
* listen()-ing. That happens with the docker bridging + NAT network
* solution when the QE connects via the lo interface (i.e. 127.0.0.1).
* We did not try other solutions like macvlan, etc yet. It appears
* that this is caused by the docker proxy program. We could work
* around this by setting docker userland-proxy as false or connecting via
* non-localhost on QE, however to make our code tolerate various
* configurations, we allow reconnect here since that does not seemi
* to harm the normal case although since client will just accept()
* the tcp connection once reconnect should never happen.
*/
/* TODO: using pg_sleep()? */
usleep(sleepus);
plc_elog(DEBUG1, "Waiting for %u ms for before reconnecting", sleepus / 1000);
sleepms += sleepus / 1000;
sleepus = sleepus >= 200000 ? 200000 : sleepus * 2;
}
pfree(mping);
return -1;
}
// TODO: read shm to get the address of coordinator
static char *get_coordinator_address(void) {
return NULL;
}
void reset_containers() {
int i;
for (i = 0; i < containers_size; i++) {
if (containers[i].runtimeid != NULL) {
/*
* Disconnect at first so that container has chance to exit gracefully.
* When running code coverage for client code, client needs to
* have chance to flush the gcda files thus direct kill-9 is not
* proper.
*/
plcContext *ctx = containers[i].ctx;
char *runtimeid = containers[i].runtimeid;
containers[i].runtimeid = NULL;
containers[i].ctx = NULL;
if (ctx)
plcFreeContext(ctx);
pfree(runtimeid);
}
}
containers_size = 0;
memset((void *)containers, 0, sizeof(containers));
}
char *parse_container_meta(const char *source) {
int first, last, len;
char *runtime_id = NULL;
int regt;
first = 0;
len = strlen(source);
/* If the string is not starting with hash, fail */
/* Must call isspace() since there is heading '\n'. */
while (first < len && isspace(source[first]))
first++;
if (first == len || source[first] != '#') {
plc_elog(ERROR, "Runtime declaration format should be '#container: runtime_id': (No '#' is found): %d %d %d", first, len, (int) source[first]);
return runtime_id;
}
first++;
/* If the string does not proceed with "container", fail */
while (first < len && isblank(source[first]))
first++;
if (first == len || strncmp(&source[first], "container", strlen("container")) != 0) {
plc_elog(ERROR, "Runtime declaration format should be '#container: runtime_id': (Not 'container'): %d %d %d", first, len, (int) source[first]);
return runtime_id;
}
first += strlen("container");
/* If no colon found - bad declaration */
while (first < len && isblank(source[first]))
first++;
if (first == len || source[first] != ':') {
plc_elog(ERROR, "Runtime declaration format should be '#container: runtime_id': (No ':' is found after 'container'): %d %d %d", first, len, (int) source[first]);
return runtime_id;
}
first++;
/* Ignore blanks before runtime_id. */
while (first < len && isblank(source[first]))
first++;
if (first == len) {
plc_elog(ERROR, "Runtime declaration format should be '#container: runtime_id': (runtime id is empty)");
return runtime_id;
}
/* Read everything up to the first newline or end of string */
last = first;
while (last < len && source[last] != '\n' && source[last] != '\r')
last++;
if (last == len) {
plc_elog(ERROR, "Runtime declaration format should be '#container: runtime_id': (no carriage return in code)");
return runtime_id;
}
last--; /* For '\n' or '\r' */
/* Ignore whitespace in the end of the line */
while (last >= first && isblank(source[last]))
last--;
if (first > last) {
plc_elog(ERROR, "Runtime id cannot be empty");
return NULL;
}
/*
* Allocate container id variable and copy container id
* the character length of id is last-first.
*/
if (last - first + 1 + 1 > RUNTIME_ID_MAX_LENGTH) {
plc_elog(ERROR, "Runtime id should not be longer than 63 bytes.");
}
runtime_id = (char *) palloc(last - first + 1 + 1);
memcpy(runtime_id, &source[first], last - first + 1);
runtime_id[last - first + 1] = '\0';
regt = check_runtime_id(runtime_id);
if (regt == -1) {
plc_elog(ERROR, "Container id '%s' contains illegal character for container.", runtime_id);
}
return runtime_id;
}
/*
* check whether configuration id specified in function declaration
* satisfy the regex which follow docker container/image naming conventions.
*/
static int check_runtime_id(const char *id) {
int status;
regex_t re;
if (regcomp(&re, "^[a-zA-Z0-9][a-zA-Z0-9_.-]*$", REG_EXTENDED | REG_NOSUB | REG_NEWLINE) != 0) {
return -1;
}
status = regexec(&re, id, (size_t) 0, NULL, 0);
regfree(&re);
if (status != 0) {
return -1;
}
return 0;
}
| 28.412121 | 163 | 0.679288 |
d9a0a0b398b92cd19fcf9f18a818b120c8146a8a | 353 | c | C | gcc-gcc-7_3_0-release/gcc/testsuite/gcc.dg/torture/pr61383-1.c | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | 7 | 2020-05-02T17:34:05.000Z | 2021-10-17T10:15:18.000Z | gcc-gcc-7_3_0-release/gcc/testsuite/gcc.dg/torture/pr61383-1.c | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | null | null | null | gcc-gcc-7_3_0-release/gcc/testsuite/gcc.dg/torture/pr61383-1.c | best08618/asylo | 5a520a9f5c461ede0f32acc284017b737a43898c | [
"Apache-2.0"
] | 2 | 2020-07-27T00:22:36.000Z | 2021-04-01T09:41:02.000Z | /* { dg-do run } */
int a, b = 1, c, d, e, f, g;
int
fn1 ()
{
int h;
for (;;)
{
g = b;
g = g ? 0 : 1 % g;
e = a + 1;
for (; d < 1; d = e)
{
if (f == 0)
h = 0;
else
h = 1 % f;
if (f < 1)
c = 0;
else if (h)
break;
}
if (b)
return 0;
}
}
int
main ()
{
fn1 ();
return 0;
}
| 9.805556 | 28 | 0.300283 |
d9a0aacfe123bcdb95212bcda758743f2a8b52ee | 533 | h | C | DigiToWords6/DigiToWordsClassRus.h | angevad/DigiToWords | 5cacdaa7ac5d71798c19511bedd5aeffaf802924 | [
"MIT"
] | null | null | null | DigiToWords6/DigiToWordsClassRus.h | angevad/DigiToWords | 5cacdaa7ac5d71798c19511bedd5aeffaf802924 | [
"MIT"
] | null | null | null | DigiToWords6/DigiToWordsClassRus.h | angevad/DigiToWords | 5cacdaa7ac5d71798c19511bedd5aeffaf802924 | [
"MIT"
] | null | null | null | #pragma once
#include "DigiToWordsClass.h"
class CDigiToWordsRus : public CDigiToWords
{
protected:
virtual bool AddHundred (UINT uID);
virtual bool AddThousand (UINT uID);
virtual bool AddThousand2 (UINT uID);
virtual bool AddThousand3 (UINT uID);
virtual void ConvertThousand (int nSymbol);
virtual void ConvertHundred (int nSymbol);
virtual void ConvertDicker (int nSymbol);
virtual void ConvertUnit (int nSymbol);
}; | 35.533333 | 53 | 0.628518 |
d9a0cb10035c46b29178eefaf582437ebcc2eb8b | 1,521 | c | C | snapgear_linux/lib/libm/atanhf.c | impedimentToProgress/UCI-BlueChip | 53e5d48b79079eaf60d42f7cb65bb795743d19fc | [
"MIT"
] | null | null | null | snapgear_linux/lib/libm/atanhf.c | impedimentToProgress/UCI-BlueChip | 53e5d48b79079eaf60d42f7cb65bb795743d19fc | [
"MIT"
] | null | null | null | snapgear_linux/lib/libm/atanhf.c | impedimentToProgress/UCI-BlueChip | 53e5d48b79079eaf60d42f7cb65bb795743d19fc | [
"MIT"
] | 3 | 2016-06-13T13:20:56.000Z | 2019-12-05T02:31:23.000Z | /* atanhf.c
*
* Inverse hyperbolic tangent
*
*
*
* SYNOPSIS:
*
* float x, y, atanhf();
*
* y = atanhf( x );
*
*
*
* DESCRIPTION:
*
* Returns inverse hyperbolic tangent of argument in the range
* MINLOGF to MAXLOGF.
*
* If |x| < 0.5, a polynomial approximation is used.
* Otherwise,
* atanh(x) = 0.5 * log( (1+x)/(1-x) ).
*
*
*
* ACCURACY:
*
* Relative error:
* arithmetic domain # trials peak rms
* IEEE -1,1 100000 1.4e-7 3.1e-8
*
*/
/* atanh.c */
/*
Cephes Math Library Release 2.2: June, 1992
Copyright (C) 1987, 1992 by Stephen L. Moshier
Direct inquiries to 30 Frost Street, Cambridge, MA 02140
*/
/* Single precision inverse hyperbolic tangent
* test interval: [-0.5, +0.5]
* trials: 10000
* peak relative error: 8.2e-8
* rms relative error: 3.0e-8
*/
#include "mconf.h"
extern float MAXNUMF;
#ifdef ANSIC
float logf( float );
float atanhf( float xx )
#else
float logf();
float atanhf(xx)
double xx;
#endif
{
float x, z;
x = xx;
if( x < 0 )
z = -x;
else
z = x;
if( z >= 1.0 )
{
if( x == 1.0 )
return( MAXNUMF );
if( x == -1.0 )
return( -MAXNUMF );
mtherr( "atanhl", DOMAIN );
return( MAXNUMF );
}
if( z < 1.0e-4 )
return(x);
if( z < 0.5 )
{
z = x * x;
z =
(((( 1.81740078349E-1 * z
+ 8.24370301058E-2) * z
+ 1.46691431730E-1) * z
+ 1.99782164500E-1) * z
+ 3.33337300303E-1) * z * x
+ x;
}
else
{
z = 0.5 * logf( (1.0+x)/(1.0-x) );
}
return( z );
}
| 15.21 | 62 | 0.542406 |
d9a1f8f34bed297d1636860208549c4de0c01b99 | 1,567 | c | C | ffi/structs/structs_library/structs.c | filiph/samples-1 | 15d0f7dde76983992f087216b9e3ed1da18ce5a5 | [
"BSD-3-Clause"
] | 2 | 2020-09-23T12:02:57.000Z | 2020-10-11T23:06:29.000Z | ffi/structs/structs_library/structs.c | filiph/samples-1 | 15d0f7dde76983992f087216b9e3ed1da18ce5a5 | [
"BSD-3-Clause"
] | 2 | 2019-12-06T15:01:45.000Z | 2019-12-06T16:27:55.000Z | ffi/structs/structs_library/structs.c | filiph/samples-1 | 15d0f7dde76983992f087216b9e3ed1da18ce5a5 | [
"BSD-3-Clause"
] | null | null | null | // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include <stdio.h>
#include <stdlib.h>
#include "structs.h"
int main()
{
struct Coordinate *coord = create_coordinate(3.5, 4.5);
printf("Coordinate is lat %.2f, long %.2f\n", coord->latitude, coord->longitude);
struct Place *place = create_place("My Home", 1.0, 2.0);
printf("The name of my place is %s at %.2f, %.2f\n", place->name, place->coordinate->latitude, place->coordinate->longitude);
printf("%s\n", hello_world());
printf("%s\n", reverse("backwards", 9));
return 0;
}
struct Coordinate *create_coordinate(double latitude, double longitude)
{
struct Coordinate *coordinate = (struct Coordinate *)malloc(sizeof(struct Coordinate));
coordinate->latitude = latitude;
coordinate->longitude = longitude;
return coordinate;
}
struct Place *create_place(char *name, double latitude, double longitude)
{
struct Place *place = (struct Place *)malloc(sizeof(struct Place));
place->name = name;
place->coordinate = create_coordinate(latitude, longitude);
return place;
}
char *hello_world()
{
return "Hello World";
}
char *reverse(char *str, int length)
{
char *reversed_str = (char *)malloc((length + 1) * sizeof(char));
for (int i = 0; i < length; i++)
{
reversed_str[length - i - 1] = str[i];
}
reversed_str[length] = '\0';
return reversed_str;
} | 30.134615 | 129 | 0.67007 |
d9a23c9ebac8925492e0062ea36a613f999ab915 | 2,139 | h | C | src/linear_elastic.h | TTitscher/fenics-constitutive | 1d4917fe9fc52ca9babb4311f761ce8050a54e16 | [
"MIT"
] | 7 | 2021-01-03T01:36:42.000Z | 2022-02-12T02:15:47.000Z | src/linear_elastic.h | BAMresearch/fenics-constitutive | 760f9127bb81356d59b0577d23f313da1b6de9a6 | [
"MIT"
] | 13 | 2021-02-27T05:32:23.000Z | 2022-02-23T15:25:20.000Z | src/linear_elastic.h | TTitscher/fenics-constitutive | 1d4917fe9fc52ca9babb4311f761ce8050a54e16 | [
"MIT"
] | 1 | 2020-11-01T17:38:09.000Z | 2020-11-01T17:38:09.000Z | #pragma once
#include "interfaces.h"
template <Constraint TC>
M<TC> C(double E, double nu);
template <>
M<UNIAXIAL_STRAIN> C<UNIAXIAL_STRAIN>(double E, double nu)
{
return M<UNIAXIAL_STRAIN>::Constant(E);
}
template <>
M<UNIAXIAL_STRESS> C<UNIAXIAL_STRESS>(double E, double nu)
{
return M<UNIAXIAL_STRAIN>::Constant(E);
}
template <>
M<PLANE_STRESS> C<PLANE_STRESS>(double E, double nu)
{
const double C11 = E / (1 - nu * nu);
const double C12 = nu * C11;
const double C33 = (1 - nu) * 0.5 * C11;
M<PLANE_STRAIN> c;
c << C11, C12, 0, C12, C11, 0, 0, 0, C33;
return c;
}
template <>
M<PLANE_STRAIN> C<PLANE_STRAIN>(double E, double nu)
{
const double l = E * nu / (1 + nu) / (1 - 2 * nu);
const double m = E / (2.0 * (1 + nu));
M<PLANE_STRAIN> c = V<PLANE_STRAIN>({2 * m, 2 * m, m}).asDiagonal();
c.block<2, 2>(0, 0) += Eigen::Matrix2d::Constant(l);
return c;
}
template <>
M<FULL> C<FULL>(double E, double nu)
{
const double l = E * nu / (1 + nu) / (1 - 2 * nu);
const double m = E / (2.0 * (1 + nu));
V<FULL> diagonal;
diagonal.segment<3>(0) = Eigen::Vector3d::Constant(2 * m);
diagonal.segment<3>(3) = Eigen::Vector3d::Constant(m);
M<FULL> c = diagonal.asDiagonal();
c.block<3, 3>(0, 0) += Eigen::Matrix3d::Constant(l);
return c;
}
Eigen::MatrixXd C(double E, double nu, Constraint c)
{
if (c == UNIAXIAL_STRAIN)
return C<UNIAXIAL_STRAIN>(E, nu);
if (c == UNIAXIAL_STRESS)
return C<UNIAXIAL_STRESS>(E, nu);
if (c == PLANE_STRAIN)
return C<PLANE_STRAIN>(E, nu);
if (c == PLANE_STRESS)
return C<PLANE_STRESS>(E, nu);
if (c == FULL)
return C<FULL>(E, nu);
throw std::runtime_error("Stuffy");
}
class LinearElastic : public MechanicsLaw
{
public:
LinearElastic(double E, double nu, Constraint constraint)
: MechanicsLaw(constraint)
{
_C = C(E, nu, constraint);
}
std::pair<Eigen::VectorXd, Eigen::MatrixXd> Evaluate(const Eigen::VectorXd& strain, int i = 0) override
{
return {_C * strain, _C};
}
private:
Eigen::MatrixXd _C;
};
| 24.586207 | 107 | 0.59841 |
d9a2555240581273e347859bc22851fbe1d03719 | 3,007 | c | C | board/RHF0M0E5_STM32WLE5xx/BSP/Middlewares/LoRaWAN/Patterns/Basic/lorawan_info.c | rceet/TencentOS-tiny | 1830420984f21e7dfced30dcb6e8f9ef146f0226 | [
"Apache-2.0"
] | 5,547 | 2019-09-18T02:20:53.000Z | 2021-08-25T10:29:54.000Z | board/RHF0M0E5_STM32WLE5xx/BSP/Middlewares/LoRaWAN/Patterns/Basic/lorawan_info.c | rceet/TencentOS-tiny | 1830420984f21e7dfced30dcb6e8f9ef146f0226 | [
"Apache-2.0"
] | 103 | 2019-09-19T13:16:09.000Z | 2021-08-04T03:51:19.000Z | board/RHF0M0E5_STM32WLE5xx/BSP/Middlewares/LoRaWAN/Patterns/Basic/lorawan_info.c | rceet/TencentOS-tiny | 1830420984f21e7dfced30dcb6e8f9ef146f0226 | [
"Apache-2.0"
] | 1,445 | 2019-09-18T04:38:19.000Z | 2021-08-25T09:17:30.000Z | /**
******************************************************************************
* @file lorawan_info.c
* @author MCD Application Team
* @brief To give info to the application about LoraWAN configuration
******************************************************************************
* @attention
*
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under 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:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "lorawan_info.h"
#include "LoRaMac.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Exported variables --------------------------------------------------------*/
LoRaMacInfo_t LoRaMacInfoTable;
/* Exported functions --------------------------------------------------------*/
/**
* @brief initialises the LoraMacInfo capabilities table
* @param none
* @retval none
*/
void LoraMacInfo_Init(void)
{
LoRaMacInfoTable.Region = 0;
#ifdef REGION_AS923
LoRaMacInfoTable.Region |= (1<<LORAMAC_REGION_AS923) ;
#endif
#ifdef REGION_AU915
LoRaMacInfoTable.Region |= (1<<LORAMAC_REGION_AU915) ;
#endif
#ifdef REGION_CN470
LoRaMacInfoTable.Region |= (1<<LORAMAC_REGION_CN470) ;
#endif
#ifdef REGION_CN470ALI
LoRaMacInfoTable.Region |= (1<<LORAMAC_REGION_CN470ALI);
#endif
#ifdef REGION_CN779
LoRaMacInfoTable.Region |= (1<<LORAMAC_REGION_CN779) ;
#endif
#ifdef REGION_EU433
LoRaMacInfoTable.Region |= (1<<LORAMAC_REGION_EU433) ;
#endif
#ifdef REGION_EU868
LoRaMacInfoTable.Region |= (1<<LORAMAC_REGION_EU868) ;
#endif
#ifdef REGION_KR920
LoRaMacInfoTable.Region |= (1<<LORAMAC_REGION_KR920) ;
#endif
#ifdef REGION_IN865
LoRaMacInfoTable.Region |= (1<<LORAMAC_REGION_IN865) ;
#endif
#ifdef REGION_US915
LoRaMacInfoTable.Region |= (1<<LORAMAC_REGION_US915) ;
#endif
#ifdef REGION_RU864
LoRaMacInfoTable.Region |= (1<<LORAMAC_REGION_RU864) ;
#endif
#ifdef LORAMAC_CLASSB_ENABLED
LoRaMacInfoTable.ClassB = 1;
#else
LoRaMacInfoTable.ClassB = 0;
#endif
return;
}
/**
* @brief returns the pointer to the LoraMacInfo capabilities table
* @param none
* @retval LoRaMacInfoTable pointer
*/
LoRaMacInfo_t* LoraMacInfo_GetPtr(void)
{
return &LoRaMacInfoTable;
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
| 31 | 80 | 0.549052 |
d9a430f7a63c91671f20e17452e05e72152ffdf9 | 1,807 | c | C | ft_strnstr.c | kizombaciao/libft.a | 12cf2ee3658028f7488962dd175168f3162ef1f5 | [
"MIT"
] | null | null | null | ft_strnstr.c | kizombaciao/libft.a | 12cf2ee3658028f7488962dd175168f3162ef1f5 | [
"MIT"
] | null | null | null | ft_strnstr.c | kizombaciao/libft.a | 12cf2ee3658028f7488962dd175168f3162ef1f5 | [
"MIT"
] | null | null | null | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchao <cchao@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/10 16:29:23 by cchao #+# #+# */
/* Updated: 2019/05/12 09:53:52 by cchao ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strnstr(const char *hay, const char *needle, size_t n)
{
size_t len;
if (!*needle)
return ((char *)hay);
len = ft_strlen(needle);
while (*hay && n-- >= len)
{
if (*hay == *needle && ft_memcmp(hay, needle, len) == 0)
return ((char *)hay);
hay++;
}
return (NULL);
}
/*
** why did it fail the unit test???
** // && n - i) <- is this needed???
** The strstr() function locates the first occurrence of the null-terminated
** string needle in the null-terminated string haystack.
**
** The strnstr() function locates the first occurrence of the null-termi-
** nated string needle in the string haystack, where not more than len char-
** acters are searched. Characters that appear after a `\0' character are
** not searched. Since the strnstr() function is a FreeBSD specific API, it
** should only be used when portability is not a concern
*/
| 42.023256 | 80 | 0.380742 |