本文整理汇总了C++中check函数的典型用法代码示例。如果您正苦于以下问题:C++ check函数的具体用法?C++ check怎么用?C++ check使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: check
double RootMeanSquaredError::calculate_performance(void) const
{
// Control sentence
#ifdef __OPENNN_DEBUG__
check();
#endif
// Neural network stuff
const MultilayerPerceptron* multilayer_perceptron_pointer = neural_network_pointer->get_multilayer_perceptron_pointer();
const size_t inputs_number = multilayer_perceptron_pointer->get_inputs_number();
const size_t outputs_number = multilayer_perceptron_pointer->get_outputs_number();
// Data set stuff
const Matrix<double>& data = data_set_pointer->get_data();
const Instances& instances = data_set_pointer->get_instances();
const size_t training_instances_number = instances.count_training_instances_number();
const Vector<size_t> training_indices = instances.arrange_training_indices();
size_t training_index;
const Variables& variables = data_set_pointer->get_variables();
const Vector<size_t> inputs_indices = variables.arrange_inputs_indices();
const Vector<size_t> targets_indices = variables.arrange_targets_indices();
// Root mean squared error
Vector<double> inputs(inputs_number);
Vector<double> outputs(outputs_number);
Vector<double> targets(outputs_number);
double sum_squared_error = 0.0;
int i = 0;
#pragma omp parallel for private(i, training_index, inputs, outputs, targets) reduction(+:sum_squared_error)
for(i = 0; i < (int)training_instances_number; i++)
{
training_index = training_indices[i];
// Input vector
inputs = data_set_pointer->get_instance(training_index, inputs_indices);
// Output vector
outputs = multilayer_perceptron_pointer->calculate_outputs(inputs);
// Target vector
// targets = data_set_pointer->get_instance(training_index, targets_indices);
// Sum squaresd error
// sum_squared_error += outputs.calculate_sum_squared_error(targets);
sum_squared_error += outputs.calculate_sum_squared_error(data, training_index, targets_indices);
}
return(sqrt(sum_squared_error/(double)training_instances_number));
}
开发者ID:Grace,项目名称:OpenNN,代码行数:71,代码来源:root_mean_squared_error.cpp
示例2: LH_ITERATE_PATCHED_WORDS_NAME
void LH_ITERATE_PATCHED_WORDS_NAME(const unichar *buf, size_t bufsize, lh_word_check_t *check, lh_word_patch_t *patch, lh_word_callback_t *callback, void *userdata)
{
size_t pos = 0;
size_t word_start;
size_t word_length;
unichar patch_buf[WORD_MAX_CHARS];
const unichar *arg_begin;
size_t arg_length;
utf8char word_buf[BUFSIZEOF__UTF8_WORD];
utf8char *hugeword_buf = NULL;
size_t hugeword_buf_size = 0;
utf8char *word_end;
int prop;
#ifdef LH_ITERATOR_DEBUG
int wordctr = 0, wordcount = LH_COUNT_WORDS_NAME (buf, bufsize, check);
#define wordctr_INC1 wordctr++
#else
#define wordctr_INC1
#endif
while (pos < bufsize)
{
prop = UNICHAR_GETPROPS_EXPN(buf,bufsize,pos);
if (prop & UCP_ALPHA)
{
word_start = pos;
do pos++; while ((pos < bufsize) && (UNICHAR_GETPROPS_EXPN(buf,bufsize,pos) & UCP_ALPHA));
word_length = pos - word_start;
if (WORD_MAX_CHARS < word_length)
continue;
if (NULL!=check && 0 == check(buf+word_start, word_length))
{
DBG_PRINTF_NOISE_WORD(word_start,word_length);
continue;
}
if (NULL != patch)
{ /* word should be patched */
if (0 == patch (buf+word_start, word_length, patch_buf, &arg_length))
{
DBG_PRINTF_PATCH_FAILED(word_start,word_length);
continue;
}
arg_begin = patch_buf;
}
else
{ /* argument should be taken right from \c buf */
arg_begin = buf+word_start;
arg_length = word_length;
}
word_end = (utf8char *)eh_encode_buffer__UTF8 (arg_begin, arg_begin+arg_length, (char *)(word_buf), (char *)(word_buf+BUFSIZEOF__UTF8_WORD));
if (NULL != word_end)
{
callback (word_buf, word_end-word_buf, userdata);
wordctr_INC1;
continue;
}
if (hugeword_buf_size<(word_length*MAX_UTF8_CHAR))
{ /* overflow danger detected */
if (hugeword_buf_size)
dk_free (hugeword_buf, hugeword_buf_size);
hugeword_buf_size = word_length*MAX_UTF8_CHAR;
hugeword_buf = (utf8char *) dk_alloc (hugeword_buf_size);
}
word_end = (utf8char *)eh_encode_buffer__UTF8 (arg_begin, arg_begin+arg_length, (char *)(hugeword_buf), (char *)(hugeword_buf+hugeword_buf_size));
callback (hugeword_buf, word_end-hugeword_buf, userdata);
wordctr_INC1;
continue;
}
if (prop & UCP_IDEO)
{
word_start = pos;
pos++;
word_length = pos - word_start;
if (NULL!=check && 0 == check(buf+word_start, word_length))
{
DBG_PRINTF_NOISE_IDEO(word_start,word_length);
continue;
}
if (NULL != patch)
{ /* word should be patched */
if (0 == patch (buf+word_start, word_length, patch_buf, &arg_length))
{
DBG_PRINTF_IDEO_PATCH_FAILED(word_start,word_length);
continue;
}
arg_begin = patch_buf;
}
else
{ /* argument should be taken right from \c buf */
arg_begin = buf+word_start;
arg_length = word_length;
}
word_end = (utf8char *)eh_encode_buffer__UTF8 (arg_begin, arg_begin+arg_length, (char *)(word_buf), (char *)(word_buf+BUFSIZEOF__UTF8_WORD));
callback (word_buf, word_end-word_buf, userdata);
wordctr_INC1;
continue;
}
pos++;
}
if (hugeword_buf_size)
dk_free (hugeword_buf, hugeword_buf_size);
//.........这里部分代码省略.........
开发者ID:China-ls,项目名称:virtuoso-opensource,代码行数:101,代码来源:langfunc_templ.c
示例3: test1
static int
test1 (void)
{
const char * in =
"{\n"
" \"headers\": {\n"
" \"type\": \"request\",\n"
" \"tag\": 666\n"
" },\n"
" \"body\": {\n"
" \"name\": \"torrent-info\",\n"
" \"arguments\": {\n"
" \"ids\": [ 7, 10 ]\n"
" }\n"
" }\n"
"}\n";
tr_variant top, *headers, *body, *args, *ids;
const char * str;
int64_t i;
const int err = tr_variantFromJson (&top, in, strlen(in));
check (!err);
check (tr_variantIsDict (&top));
check ((headers = tr_variantDictFind (&top, tr_quark_new("headers",7))));
check (tr_variantIsDict (headers));
check (tr_variantDictFindStr (headers, tr_quark_new("type",4), &str, NULL));
check_streq ("request", str);
check (tr_variantDictFindInt (headers, TR_KEY_tag, &i));
check_int_eq (666, i);
check ((body = tr_variantDictFind (&top, tr_quark_new("body",4))));
check (tr_variantDictFindStr (body, TR_KEY_name, &str, NULL));
check_streq ("torrent-info", str);
check ((args = tr_variantDictFind (body, tr_quark_new("arguments",9))));
check (tr_variantIsDict (args));
check ((ids = tr_variantDictFind (args, TR_KEY_ids)));
check (tr_variantIsList (ids));
check_int_eq (2, tr_variantListSize (ids));
check (tr_variantGetInt (tr_variantListChild (ids, 0), &i));
check_int_eq (7, i);
check (tr_variantGetInt (tr_variantListChild (ids, 1), &i));
check_int_eq (10, i);
tr_variantFree (&top);
return 0;
}
开发者ID:Javierortizc,项目名称:transmission,代码行数:45,代码来源:json-test.c
示例4: check
void AWalkerAIController::Possess(APawn *aPawn)
{
Super::Possess(aPawn);
check(aPawn != nullptr);
aPawn->OnTakeAnyDamage.AddDynamic(this, &AWalkerAIController::OnPawnTookDamage);
}
开发者ID:cyy1991,项目名称:carla,代码行数:6,代码来源:WalkerAIController.cpp
示例5: FrpSeqAllocatorWaitForSwap
//.........这里部分代码省略.........
else
{
std::wstring wideText = ToWide(text);
// parse colors and the lot
std::wstring noColorTextString;
std::vector<DWRITE_TEXT_RANGE> textRanges;
std::vector<RGBA> textColors;
{
std::wstringstream noColorText;
int count = 0;
static const RGBA colors[] = {
RGBA(0, 0, 0),
RGBA(255, 0, 0),
RGBA(0, 255, 0),
RGBA(255, 255, 0),
RGBA(0, 0, 255),
RGBA(0, 255, 255),
RGBA(255, 0, 255),
RGBA(255, 255, 255),
RGBA(100, 0, 0),
RGBA(0, 0, 100)
};
textRanges.reserve(50);
textColors.reserve(50);
textRanges.push_back({ 0, UINT32_MAX });
textColors.push_back(color);
for (int i = 0; i < wideText.length(); i++)
{
if (wideText[i] == '^' && (i + 1) < wideText.length() && isdigit(wideText[i + 1]))
{
textRanges.back().length = count - textRanges.back().startPosition;
textRanges.push_back({ (UINT32)count, UINT32_MAX });
textColors.push_back(colors[wideText[i + 1] - '0']);
++i;
continue;
}
noColorText << wideText[i];
++count;
}
textRanges.back().length = count - textRanges.back().startPosition;
noColorTextString = noColorText.str();
}
m_dwFactory->CreateTextLayout(noColorTextString.c_str(), static_cast<UINT32>(noColorTextString.length()), textFormat.Get(), rect.Width(), rect.Height(), textLayout.GetAddressOf());
m_textLayoutCache[layoutKey] = textLayout;
// set effect
for (size_t i : irange(textRanges.size()))
{
DWRITE_TEXT_RANGE effectRange = textRanges[i];
RGBA color = textColors[i];
static thread_local std::map<uint32_t, ComPtr<FrDrawingEffect>> effects;
auto it = effects.find(color.AsARGB());
if (it == effects.end())
{
ComPtr<FrDrawingEffect> effect = Make<FrDrawingEffect>();
effect->SetColor(textColors[i]);
it = effects.insert({ color.AsARGB(), effect }).first;
}
check(SUCCEEDED(textLayout->SetDrawingEffect((IUnknown*)it->second.Get(), effectRange)));
}
}
// draw
auto drawingContext = new FrDrawingContext();
textLayout->Draw(drawingContext, m_textRenderer.Get(), rect.Left(), rect.Top());
auto numRuns = drawingContext->glyphRuns.size();
if (numRuns)
{
for (auto& run : drawingContext->glyphRuns)
{
m_queuedRenderables.push_back(std::make_unique<FrGlyphRunRenderable>(run));
//m_queuedGlyphRuns.push_back(run);
}
}
delete drawingContext;
m_mutex.unlock();
}
开发者ID:amd-design,项目名称:krtcore,代码行数:101,代码来源:FontRendererImpl.cpp
示例6: check
void SInlineEditableTextBlock::Construct( const FArguments& InArgs )
{
check(InArgs._Style);
OnBeginTextEditDelegate = InArgs._OnBeginTextEdit;
OnTextCommittedDelegate = InArgs._OnTextCommitted;
IsSelected = InArgs._IsSelected;
OnVerifyTextChanged= InArgs._OnVerifyTextChanged;
Text = InArgs._Text;
bIsReadOnly = InArgs._IsReadOnly;
bIsMultiLine = InArgs._MultiLine;
DoubleSelectDelay = 0.0f;
ChildSlot
[
SAssignNew(HorizontalBox, SHorizontalBox)
+SHorizontalBox::Slot()
.VAlign(VAlign_Center)
[
SAssignNew(TextBlock, STextBlock)
.Text(Text)
.TextStyle( &InArgs._Style->TextStyle )
.Font(InArgs._Font)
.ColorAndOpacity( InArgs._ColorAndOpacity )
.ShadowColorAndOpacity( InArgs._ShadowColorAndOpacity )
.ShadowOffset( InArgs._ShadowOffset )
.HighlightText( InArgs._HighlightText )
.ToolTipText( InArgs._ToolTipText )
.WrapTextAt( InArgs._WrapTextAt )
.Justification( InArgs._Justification )
.LineBreakPolicy( InArgs._LineBreakPolicy )
]
];
if( bIsMultiLine )
{
SAssignNew(MultiLineTextBox, SMultiLineEditableTextBox)
.Text(InArgs._Text)
.Style(&InArgs._Style->EditableTextBoxStyle)
.Font(InArgs._Font)
.ToolTipText( InArgs._ToolTipText )
.OnTextChanged(this, &SInlineEditableTextBlock::OnTextChanged)
.OnTextCommitted(this, &SInlineEditableTextBlock::OnTextBoxCommitted)
.SelectAllTextWhenFocused(true)
.ClearKeyboardFocusOnCommit(true)
.RevertTextOnEscape(true)
.ModiferKeyForNewLine(InArgs._ModiferKeyForNewLine);
}
else
{
SAssignNew(TextBox, SEditableTextBox)
.Text(InArgs._Text)
.Style(&InArgs._Style->EditableTextBoxStyle)
.Font(InArgs._Font)
.ToolTipText( InArgs._ToolTipText )
.OnTextChanged( this, &SInlineEditableTextBlock::OnTextChanged )
.OnTextCommitted(this, &SInlineEditableTextBlock::OnTextBoxCommitted)
.SelectAllTextWhenFocused(true)
.ClearKeyboardFocusOnCommit(false);
}
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:62,代码来源:SInlineEditableTextBlock.cpp
示例7: while
uint32 FSoundFileDecoder::Run()
{
while (bIsDecoding)
{
for (int32 DataIndex = 0; DataIndex < Settings.NumDecodeBuffers; ++DataIndex)
{
FSoundFileDecodeData& Data = DecodeData[DataIndex];
// If the data is not active, continue
if (!Data.bIsActive)
{
continue;
}
int32 CurrentWriteBufferIndex = Data.CurrentWriteBufferIndex.GetValue();
while (CurrentWriteBufferIndex != Data.CurrentReadBufferIndex.GetValue())
{
TArray<float>& DecodeBuffer = Data.DecodedBuffers[CurrentWriteBufferIndex];
SoundFileCount RequestedNumSamples = (SoundFileCount)DecodeBuffer.Num();
SoundFileCount NumSamplesActuallyRead = 0;
// If the data is looping, then we need to keep reading samples from the file until we've reached the number of requested
// samples. For *very* short duration sounds (or for long-duration decode buffers), we may have an edge case where
// the sound file needs to seek from the beginning multiple times to fulfill the decode buffer size request
if (Data.bIsLooping)
{
// Keep looping until we've read everything we requested
while (true)
{
ESoundFileError::Type Result = Data.SoundFileReader->ReadSamples(DecodeBuffer.GetData(), RequestedNumSamples, NumSamplesActuallyRead);
check(Result == ESoundFileError::NONE);
// If we've read all the samples we wanted, then we're good
if (RequestedNumSamples == NumSamplesActuallyRead)
{
break;
}
// ... otherwise, we need to seek back to the beginning of the file and try to read samples that are left
else
{
// Seek to beginning of file
SoundFileCount OutFrameOffset = 0;
Data.SoundFileReader->SeekFrames(0, ESoundFileSeekMode::FROM_START, OutFrameOffset);
// Calculate samples left we need to read
RequestedNumSamples -= NumSamplesActuallyRead;
}
}
}
else
{
ESoundFileError::Type Result = Data.SoundFileReader->ReadSamples(DecodeBuffer.GetData(), RequestedNumSamples, NumSamplesActuallyRead);
check(Result == ESoundFileError::NONE);
// if the number of samples we read was not the number we requested, then we've reached the end of the file
if (RequestedNumSamples != NumSamplesActuallyRead)
{
// tell the data that this entry is no longer active
Data.bIsActive = false;
// and what our last sample index is
Data.LastSampleIndex = NumSamplesActuallyRead;
}
}
// Increment the buffer index
CurrentWriteBufferIndex = CurrentWriteBufferIndex % Settings.NumDecodeBuffers;
// Publish results by writing setting buffer index so other thread can read it
Data.CurrentWriteBufferIndex.Set(CurrentWriteBufferIndex);
}
}
// Once we're done decoding everything, then put this thread to sleep
// Any new requests (or any shutdowns) will trigger this thread to wake up.
ThreadDecodeEvent->Wait((uint32)-1);
}
return true;
}
开发者ID:colwalder,项目名称:unrealengine,代码行数:81,代码来源:UnrealAudioDecode.cpp
示例8: check
bool check(const php::Program& p) {
for (DEBUG_ONLY auto& u : p.units) assert(check(*u));
return true;
}
开发者ID:2bj,项目名称:hhvm,代码行数:4,代码来源:check.cpp
示例9: AndroidGetAssetFD
void AudioStream_Ogg::open(const std::string &path, int startTime, int inLoops, const SoundTransform &inTransform) {
if (openal_is_shutdown) return;
int result;
mPath = std::string(path.c_str());
mStartTime = startTime;
mLoops = inLoops;
mIsValid = true;
mSuspend = false;
#ifdef ANDROID
mInfo = AndroidGetAssetFD(path.c_str());
oggFile = fdopen(mInfo.fd, "rb");
fseek(oggFile, mInfo.offset, 0);
ov_callbacks callbacks;
callbacks.read_func = &nme::AudioStream_Ogg::read_func;
callbacks.seek_func = &nme::AudioStream_Ogg::seek_func;
callbacks.close_func = &nme::AudioStream_Ogg::close_func;
callbacks.tell_func = &nme::AudioStream_Ogg::tell_func;
#else
oggFile = fopen(path.c_str(), "rb");
#endif
if(!oggFile) {
//throw std::string("Could not open Ogg file.");
LOG_SOUND("Could not open Ogg file.");
mIsValid = false;
return;
}
oggStream = new OggVorbis_File();
#ifdef ANDROID
result = ov_open_callbacks(this, oggStream, NULL, 0, callbacks);
#else
result = ov_open(oggFile, oggStream, NULL, 0);
#endif
if(result < 0) {
fclose(oggFile);
oggFile = 0;
//throw std::string("Could not open Ogg stream. ") + errorString(result);
LOG_SOUND("Could not open Ogg stream.");
//LOG_SOUND(errorString(result).c_str());
mIsValid = false;
return;
}
vorbisInfo = ov_info(oggStream, -1);
vorbisComment = ov_comment(oggStream, -1);
if(vorbisInfo->channels == 1) {
format = AL_FORMAT_MONO16;
} else {
format = AL_FORMAT_STEREO16;
}
if (startTime != 0)
{
double seek = startTime * 0.001;
ov_time_seek(oggStream, seek);
}
alGenBuffers(2, buffers);
check();
alGenSources(1, &source);
check();
alSource3f(source, AL_POSITION, 0.0, 0.0, 0.0);
alSource3f(source, AL_VELOCITY, 0.0, 0.0, 0.0);
alSource3f(source, AL_DIRECTION, 0.0, 0.0, 0.0);
alSourcef (source, AL_ROLLOFF_FACTOR, 0.0 );
alSourcei (source, AL_SOURCE_RELATIVE, AL_TRUE );
setTransform(inTransform);
} //open
开发者ID:Beeblerox,项目名称:nme,代码行数:84,代码来源:OpenALSound.cpp
示例10: ReturnToPool
void ReturnToPool(FEvent* Event)
{
check(Event);
Pool.Push(Event);
}
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:5,代码来源:ThreadingBase.cpp
示例11: BufferType
BufferType* FD3D12Adapter::CreateRHIBuffer(FRHICommandListImmediate* RHICmdList,
const D3D12_RESOURCE_DESC& InDesc,
uint32 Alignment,
uint32 Stride,
uint32 Size,
uint32 InUsage,
FRHIResourceCreateInfo& CreateInfo,
bool SkipCreate)
{
const bool bIsDynamic = (InUsage & BUF_AnyDynamic) ? true : false;
BufferType* BufferOut = CreateLinkedObject<BufferType>([&](FD3D12Device* Device)
{
BufferType* NewBuffer = new BufferType(Device, Stride, Size, InUsage);
NewBuffer->BufferAlignment = Alignment;
if (SkipCreate == false)
{
AllocateBuffer(Device, InDesc, Size, InUsage, CreateInfo, Alignment, NewBuffer->ResourceLocation);
}
return NewBuffer;
});
if (CreateInfo.ResourceArray)
{
if (bIsDynamic == false && BufferOut->ResourceLocation.IsValid())
{
check(Size == CreateInfo.ResourceArray->GetResourceDataSize());
// Get an upload heap and initialize data
FD3D12ResourceLocation SrcResourceLoc(BufferOut->GetParentDevice());
void* pData = SrcResourceLoc.GetParentDevice()->GetDefaultFastAllocator().Allocate<FD3D12ScopeLock>(Size, 4UL, &SrcResourceLoc);
check(pData);
FMemory::Memcpy(pData, CreateInfo.ResourceArray->GetResourceData(), Size);
const auto& pfnUpdateBuffer = [&]()
{
BufferType* CurrentBuffer = BufferOut;
while (CurrentBuffer != nullptr)
{
FD3D12Resource* Destination = CurrentBuffer->ResourceLocation.GetResource();
FD3D12Device* Device = Destination->GetParentDevice();
FD3D12CommandListHandle& hCommandList = Device->GetDefaultCommandContext().CommandListHandle;
// Copy from the temporary upload heap to the default resource
{
// Writable structured bufferes are sometimes initialized with inital data which means they sometimes need tracking.
FConditionalScopeResourceBarrier ConditionalScopeResourceBarrier(hCommandList, Destination, D3D12_RESOURCE_STATE_COPY_DEST, 0);
Device->GetDefaultCommandContext().numCopies++;
hCommandList->CopyBufferRegion(
Destination->GetResource(),
CurrentBuffer->ResourceLocation.GetOffsetFromBaseOfResource(),
SrcResourceLoc.GetResource()->GetResource(),
SrcResourceLoc.GetOffsetFromBaseOfResource(), Size);
hCommandList.UpdateResidency(Destination);
}
CurrentBuffer = CurrentBuffer->GetNextObject();
}
};
//TODO: This should be a deferred op like the buffer lock/unlocks
// We only need to synchronize when creating default resource buffers (because we need a command list to initialize them)
if (RHICmdList)
{
FScopedRHIThreadStaller StallRHIThread(*RHICmdList);
pfnUpdateBuffer();
}
else
{
pfnUpdateBuffer();
}
}
// Discard the resource array's contents.
CreateInfo.ResourceArray->Discard();
}
return BufferOut;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:83,代码来源:D3D12Buffer.cpp
示例12: rm_tree
static void
rm_tree(char **argv)
{
FTS *fts;
FTSENT *p;
int needstat;
int flags;
int rval;
/*
* Remove a file hierarchy. If forcing removal (-f), or interactive
* (-i) or can't ask anyway (stdin_ok), don't stat the file.
*/
needstat = !uid || (!fflag && !iflag && stdin_ok);
/*
* If the -i option is specified, the user can skip on the pre-order
* visit. The fts_number field flags skipped directories.
*/
#define SKIPPED 1
flags = FTS_PHYSICAL;
if (!needstat)
flags |= FTS_NOSTAT;
if (Wflag)
flags |= FTS_WHITEOUT;
if (xflag)
flags |= FTS_XDEV;
if (!(fts = fts_open(argv, flags, NULL))) {
if (fflag && errno == ENOENT)
return;
err(1, "fts_open");
}
while ((p = fts_read(fts)) != NULL) {
switch (p->fts_info) {
case FTS_DNR:
if (!fflag || p->fts_errno != ENOENT) {
warnx("%s: %s",
p->fts_path, strerror(p->fts_errno));
eval = 1;
}
continue;
case FTS_ERR:
errx(1, "%s: %s", p->fts_path, strerror(p->fts_errno));
case FTS_NS:
/*
* Assume that since fts_read() couldn't stat the
* file, it can't be unlinked.
*/
if (!needstat)
break;
if (!fflag || p->fts_errno != ENOENT) {
warnx("%s: %s",
p->fts_path, strerror(p->fts_errno));
eval = 1;
}
continue;
case FTS_D:
/* Pre-order: give user chance to skip. */
if (!fflag && !check(p->fts_path, p->fts_accpath,
p->fts_statp)) {
(void)fts_set(fts, p, FTS_SKIP);
p->fts_number = SKIPPED;
}
else if (!uid &&
(p->fts_statp->st_flags & (UF_APPEND|UF_IMMUTABLE)) &&
!(p->fts_statp->st_flags & (SF_APPEND|SF_IMMUTABLE)) &&
lchflags(p->fts_accpath,
p->fts_statp->st_flags &= ~(UF_APPEND|UF_IMMUTABLE)) < 0)
goto err;
continue;
case FTS_DP:
/* Post-order: see if user skipped. */
if (p->fts_number == SKIPPED)
continue;
break;
default:
if (!fflag &&
!check(p->fts_path, p->fts_accpath, p->fts_statp))
continue;
}
rval = 0;
if (!uid &&
(p->fts_statp->st_flags & (UF_APPEND|UF_IMMUTABLE)) &&
!(p->fts_statp->st_flags & (SF_APPEND|SF_IMMUTABLE)))
rval = lchflags(p->fts_accpath,
p->fts_statp->st_flags &= ~(UF_APPEND|UF_IMMUTABLE));
if (rval == 0) {
/*
* If we can't read or search the directory, may still be
* able to remove it. Don't print out the un{read,search}able
* message unless the remove fails.
*/
switch (p->fts_info) {
case FTS_DP:
case FTS_DNR:
rval = rmdir(p->fts_accpath);
if (rval == 0 || (fflag && errno == ENOENT)) {
if (rval == 0 && vflag)
//.........这里部分代码省略.........
开发者ID:0mp,项目名称:freebsd,代码行数:101,代码来源:rm.c
示例13: SCOPE_CYCLE_COUNTER
void* FD3D12DynamicRHI::LockBuffer(FRHICommandListImmediate* RHICmdList, BufferType* Buffer, uint32 Offset, uint32 Size, EResourceLockMode LockMode)
{
#if STATS
LockBufferCalls++;
SCOPE_CYCLE_COUNTER(STAT_D3D12LockBufferTime);
INC_DWORD_STAT_BY(STAT_D3D12LockBufferCalls, LockBufferCalls);
#endif
FD3D12LockedResource& LockedData = Buffer->LockedData;
check(LockedData.bLocked == false);
FD3D12Device* Device = GetRHIDevice();
FD3D12Adapter& Adapter = GetAdapter();
// Determine whether the buffer is dynamic or not.
const bool bIsDynamic = (Buffer->GetUsage() & BUF_AnyDynamic) ? true : false;
void* Data = nullptr;
if (bIsDynamic)
{
check(LockMode == RLM_WriteOnly);
BufferType* CurrentBuffer = Buffer;
// Update all of the resources in the LDA chain
while (CurrentBuffer)
{
// Allocate a new resource
// If on the RenderThread, queue up a command on the RHIThread to rename this buffer at the correct time
if (ShouldDeferBufferLockOperation(RHICmdList))
{
FRHICommandRenameUploadBuffer<BufferType>* Command = new (RHICmdList->AllocCommand<FRHICommandRenameUploadBuffer<BufferType>>()) FRHICommandRenameUploadBuffer<BufferType>(CurrentBuffer, Device);
Data = Adapter.GetUploadHeapAllocator().AllocUploadResource(Buffer->GetSize(), Buffer->BufferAlignment, Command->NewResource);
}
else
{
FD3D12ResourceLocation Location(CurrentBuffer->GetParentDevice());
Data = Adapter.GetUploadHeapAllocator().AllocUploadResource(Buffer->GetSize(), Buffer->BufferAlignment, Location);
CurrentBuffer->Rename(Location);
}
CurrentBuffer = CurrentBuffer->GetNextObject();
}
}
else
{
FD3D12Resource* pResource = Buffer->ResourceLocation.GetResource();
// Locking for read must occur immediately so we can't queue up the operations later.
if (LockMode == RLM_ReadOnly)
{
LockedData.bLockedForReadOnly = true;
// If the static buffer is being locked for reading, create a staging buffer.
FD3D12Resource* StagingBuffer = nullptr;
const GPUNodeMask Node = Device->GetNodeMask();
VERIFYD3D12RESULT(Adapter.CreateBuffer(D3D12_HEAP_TYPE_READBACK, Node, Node, Offset + Size, &StagingBuffer));
// Copy the contents of the buffer to the staging buffer.
{
const auto& pfnCopyContents = [&]()
{
FD3D12CommandContext& DefaultContext = Device->GetDefaultCommandContext();
FD3D12CommandListHandle& hCommandList = DefaultContext.CommandListHandle;
FScopeResourceBarrier ScopeResourceBarrierSource(hCommandList, pResource, pResource->GetDefaultResourceState(), D3D12_RESOURCE_STATE_COPY_SOURCE, 0);
// Don't need to transition upload heaps
DefaultContext.numCopies++;
hCommandList->CopyBufferRegion(
StagingBuffer->GetResource(),
0,
pResource->GetResource(),
Offset, Size);
hCommandList.UpdateResidency(StagingBuffer);
hCommandList.UpdateResidency(pResource);
DefaultContext.FlushCommands(true);
};
if (ShouldDeferBufferLockOperation(RHICmdList))
{
// Sync when in the render thread implementation
check(IsInRHIThread() == false);
RHICmdList->ImmediateFlush(EImmediateFlushType::FlushRHIThread);
pfnCopyContents();
}
else
{
check(IsInRHIThread());
pfnCopyContents();
}
}
LockedData.ResourceLocation.AsStandAlone(StagingBuffer, Size);
//.........这里部分代码省略.........
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:101,代码来源:D3D12Buffer.cpp
示例14: rm_file
static void
rm_file(char **argv)
{
struct stat sb;
int rval;
char *f;
/*
* Remove a file. POSIX 1003.2 states that, by default, attempting
* to remove a directory is an error, so must always stat the file.
*/
while ((f = *argv++) != NULL) {
/* Assume if can't stat the file, can't unlink it. */
if (lstat(f, &sb)) {
if (Wflag) {
sb.st_mode = S_IFWHT|S_IWUSR|S_IRUSR;
} else {
if (!fflag || errno != ENOENT) {
warn("%s", f);
eval = 1;
}
continue;
}
} else if (Wflag) {
warnx("%s: %s", f, strerror(EEXIST));
eval = 1;
continue;
}
if (S_ISDIR(sb.st_mode) && !dflag) {
warnx("%s: is a directory", f);
eval = 1;
continue;
}
if (!fflag && !S_ISWHT(sb.st_mode) && !check(f, f, &sb))
continue;
rval = 0;
if (!uid && !S_ISWHT(sb.st_mode) &&
(sb.st_flags & (UF_APPEND|UF_IMMUTABLE)) &&
!(sb.st_flags & (SF_APPEND|SF_IMMUTABLE)))
rval = lchflags(f, sb.st_flags & ~(UF_APPEND|UF_IMMUTABLE));
if (rval == 0) {
if (S_ISWHT(sb.st_mode))
rval = undelete(f);
else if (S_ISDIR(sb.st_mode))
rval = rmdir(f);
else {
if (Pflag)
if (!rm_overwrite(f, &sb))
continue;
rval = unlink(f);
}
}
if (rval && (!fflag || errno != ENOENT)) {
warn("%s", f);
eval = 1;
}
if (vflag && rval == 0)
(void)printf("%s\n", f);
if (info && rval == 0) {
info = 0;
(void)printf("%s\n", f);
}
}
}
开发者ID:0mp,项目名称:freebsd,代码行数:65,代码来源:rm.c
示例15: check
void FSoundFileDecoder::Signal()
{
check(ThreadDecodeEvent != nullptr);
ThreadDecodeEvent->Trigger();
}
开发者ID:colwalder,项目名称:unrealengine,代码行数:5,代码来源:UnrealAudioDecode.cpp
示例16: check
void FSlateOpenGLVS::Create( const FString& Filename )
{
check( ShaderID==0 );
// Compile the vertex shader
CompileShader( Filename, GL_VERTEX_SHADER );
}
开发者ID:JustDo1989,项目名称:UnrealEngine4.11-HairWorks,代码行数:6,代码来源:SlateOpenGLShaders.cpp
示例17: main
int main(int argc, char* argv[])
{
// check for correct number of args
if (argc != 2 && argc != 3)
{
printf("Usage: speller [dictionary] text\n");
return 1;
}
// structs for timing data
struct rusage before, after;
// benchmarks
double time_load = 0.0, time_check = 0.0, time_size = 0.0, time_unload = 0.0;
// determine dictionary to use
char* dictionary = (argc == 3) ? argv[1] : DICTIONARY;
// load dictionary
getrusage(RUSAGE_SELF, &before);
bool loaded = load(dictionary);
getrusage(RUSAGE_SELF, &after);
// abort if dictionary not loaded
if (!loaded)
{
printf("Could not load %s.\n", dictionary);
return 1;
}
// calculate time to load dictionary
time_load = calculate(&before, &after);
// try to open text
char* text = (argc == 3) ? argv[2] : argv[1];
FILE* fp = fopen(text, "r");
if (fp == NULL)
{
printf("Could not open %s.\n", text);
unload();
return 1;
}
// prepare to report misspellings
printf("\nMISSPELLED WORDS\n\n");
// prepare to spell-check
int index = 0, misspellings = 0, words = 0;
char word[LENGTH+1];
// spell-check each word in text
for (int c = fgetc(fp); c != EOF; c = fgetc(fp))
{
// allow only alphabetical characters and apostrophes
if (isalpha(c) || (c == '\'' && index > 0))
{
// append character to word
word[index] = c;
index++;
// ignore alphabetical strings too long to be words
if (index > LENGTH)
{
// consume remainder of alphabetical string
while ((c = fgetc(fp)) != EOF && isalpha(c));
// prepare for new word
index = 0;
}
}
// ignore words with numbers (like MS Word can)
else if (isdigit(c))
{
// consume remainder of alphanumeric string
while ((c = fgetc(fp)) != EOF && isalnum(c));
// prepare for new word
index = 0;
}
// we must have found a whole word
else if (index > 0)
{
// terminate current word
word[index] = '\0';
// update counter
words++;
// check word's spelling
getrusage(RUSAGE_SELF, &before);
bool misspelled = !check(word);
getrusage(RUSAGE_SELF, &after);
// update benchmark
time_check += calculate(&before, &after);
// print word if misspelled
if (misspelled)
//.........这里部分代码省略.........
开发者ID:tomjacob,项目名称:CS50,代码行数:101,代码来源:speller.c
示例18: GetForwardSpeed
static float GetForwardSpeed(const AWheeledVehicle &Vehicle)
{
const auto *MovementComponent = Vehicle.GetVehicleMovementComponent();
check(nullptr != MovementComponent);
return MovementComponent->GetForwardSpeed();
}
开发者ID:cyy1991,项目名称:carla,代码行数:6,代码来源:WalkerAIController.cpp
示例19: glCreateShader
void FSlateOpenGLShader::CompileShader( const FString& Filename, GLenum ShaderType )
{
// Create a new shader ID.
ShaderID = glCreateShader( ShaderType );
GLint CompileStatus = GL_FALSE;
check( ShaderID );
// Load the file to a string
FString Source;
bool bFileFound = FFileHelper::LoadFileToString( Source, *Filename );
check(bFileFound);
FString Header;
// pass the #define along to the shader
#if PLATFORM_USES_ES2
Header.Append("#define PLATFORM_USES_ES2 1\n");
#elif PLATFORM_LINUX
#if LINUX_USE_OPENGL_3_2
Header.Append("#version 150\n#define PLATFORM_USES_ES2 0\n");
#else
Header.Append("#version 120\n#define PLATFORM_USES_ES2 0\n");
#endif // LINUX_USE_OPENGL_3_2
#else
Header.Append("#version 120\n#define PLATFORM_USES_ES2 0\n");
#endif
#if PLATFORM_LINUX
Header.Append("#define PLATFORM_LINUX 1\n");
#else
Header.Append("#define PLATFORM_LINUX 0\n");
#endif
#if PLATFORM_MAC
Header.Append("#define PLATFORM_MAC 1\n");
#else
Header.Append("#define PLATFORM_MAC 0\n");
#endif
#if USE_709
Header.Append("#define USE_709 1\n");
#else
Header.Append("#define USE_709 0\n");
#endif
// Allocate a buffer big enough to store the string in ascii format
ANSICHAR* Chars[2] = {0};
Chars[0] = new ANSICHAR[Header.Len()+1];
FCStringAnsi::Strcpy(Chars[0], Header.Len() + 1, TCHAR_TO_ANSI(*Header));
Chars[1] = new ANSICHAR[Source.Len()+1];
FCStringAnsi::Strcpy(Chars[1], Source.Len() + 1, TCHAR_TO_ANSI(*Source));
// give opengl the source code for the shader
glShaderSource( ShaderID, 2, (const ANSICHAR**)Chars, NULL );
delete[] Chars[0];
delete[] Chars[1];
// Compile the shader and check for success
glCompileShader( ShaderID );
glGetShaderiv( ShaderID, GL_COMPILE_STATUS, &CompileStatus );
if( CompileStatus == GL_FALSE )
{
// The shader did not compile. Display why it failed.
FString Log = GetGLSLShaderLog( ShaderID );
checkf(false, TEXT("Failed to compile shader: %s\n%s"), *Filename, *Log );
// Delete the shader since it failed.
glDeleteShader( ShaderID );
ShaderID = 0;
}
}
开发者ID:JustDo1989,项目名称:UnrealEngine4.11-HairWorks,代码行数:76,代码来源:SlateOpenGLShaders.cpp
示例20: check
Distance Distance::operator -(const Distance& _distance) const
{
/// @todo
check(false,"note yet implemented") ;
}
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:5,代码来源:distance.cpp
注:本文中的check函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论