text stringlengths 1 1.05M |
|---|
#include "dmzJsModuleUiV8QtBasic.h"
#include <dmzJsV8UtilConvert.h>
#include "dmzV8QtTabWidget.h"
#include "dmzV8QtUtil.h"
#include <QtGui/QAbstractButton>
#include <QtGui/QTabWidget>
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tab_widget_add (const v8::Arguments &Args) {
v8::HandleScope scope;
V8Value result = v8::Undefined ();
JsModuleUiV8QtBasic *self = _to_self (Args);
if (self) {
QTabWidget *tw = self->v8_to_qobject<QTabWidget>(Args.This ());
QWidget *qw = self->_to_qwidget (Args[0]);
String label = v8_to_string(Args[1]);
if (tw && qw) {
if (Args.Length () == 2) {
result = v8::Number::New (tw->addTab (qw, label.get_buffer ()));
}
else if (Args.Length () > 2) {
result = v8::Number::New (
tw->insertTab (v8_to_int32 (Args[2]), qw, label.get_buffer ()));
}
}
}
return scope.Close (result);
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tab_widget_remove (const v8::Arguments &Args) {
v8::HandleScope scope;
V8Value result = v8::Undefined ();
JsModuleUiV8QtBasic *self = _to_self (Args);
if (self) {
QTabWidget *tw = self->v8_to_qobject<QTabWidget>(Args.This ());
if (tw) {
tw->removeTab (v8_to_int32 (Args[0]));
}
}
return scope.Close (result);
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tab_widget_count (const v8::Arguments &Args) {
v8::HandleScope scope;
V8Value result = v8::Undefined ();
JsModuleUiV8QtBasic *self = _to_self (Args);
if (self) {
QTabWidget *tw = self->v8_to_qobject<QTabWidget>(Args.This ());
if (tw) {
result = v8::Number::New (tw->count ());
}
}
return scope.Close (result);
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tab_widget_current_index (const v8::Arguments &Args) {
v8::HandleScope scope;
V8Value result = v8::Undefined ();
JsModuleUiV8QtBasic *self = _to_self (Args);
if (self) {
QTabWidget *tw = self->v8_to_qobject<QTabWidget>(Args.This ());
if (tw) {
if (Args.Length () > 0) {
tw->setCurrentIndex (v8_to_int32 (Args[0]));
}
result = v8::Number::New (tw->currentIndex ());
}
}
return scope.Close (result);
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tab_widget_current_widget (const v8::Arguments &Args) {
v8::HandleScope scope;
V8Value result = v8::Undefined ();
JsModuleUiV8QtBasic *self = _to_self (Args);
if (self) {
QTabWidget *tw = self->v8_to_qobject<QTabWidget>(Args.This ());
if (tw) {
QWidget *qw = 0;
if (Args.Length () > 0) {
qw = self->_to_qwidget (Args[0]);
if (qw) {
tw->setCurrentWidget (qw);
}
}
qw = tw->currentWidget ();
if (qw) {
result = self->create_v8_qwidget (qw);
}
}
}
return scope.Close (result);
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tab_widget_at (const v8::Arguments &Args) {
v8::HandleScope scope;
V8Value result = v8::Undefined ();
JsModuleUiV8QtBasic *self = _to_self (Args);
if (self) {
QTabWidget *tw = self->v8_to_qobject<QTabWidget>(Args.This ());
if (tw && (Args.Length () > 0)) {
QWidget *qw = tw->widget(v8_to_int32 (Args[0]));
if (qw) {
result = self->create_v8_qwidget (qw);
}
}
}
return scope.Close (result);
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tab_widget_index_of (const v8::Arguments &Args) {
v8::HandleScope scope;
V8Value result = v8::Undefined ();
JsModuleUiV8QtBasic *self = _to_self (Args);
if (self) {
QTabWidget *tw = self->v8_to_qobject<QTabWidget>(Args.This ());
QWidget *qw = self->_to_qwidget (Args[0]);
if (tw && qw) {
result = v8::Number::New (tw->indexOf (qw));
}
}
return scope.Close (result);
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tab_widget_tab_text (const v8::Arguments &Args) {
v8::HandleScope scope;
V8Value result = v8::Undefined ();
JsModuleUiV8QtBasic *self = _to_self (Args);
if (self) {
QTabWidget *tw = self->v8_to_qobject<QTabWidget>(Args.This ());
if (tw && (Args.Length () > 0)) {
int index = v8_to_int32 (Args[0]);
if (Args.Length () > 1) {
String label = v8_to_string (Args[1]);
if (label) {
tw->setTabText (index, label.get_buffer ());
}
}
result = qstring_to_v8 (tw->tabText (index));
}
}
return scope.Close (result);
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_tab_widget_clear (const v8::Arguments &Args) {
v8::HandleScope scope;
V8Value result = v8::Undefined ();
JsModuleUiV8QtBasic *self = _to_self (Args);
if (self) {
QTabWidget *tw = self->v8_to_qobject<QTabWidget>(Args.This ());
if (tw) { tw->clear (); }
}
return scope.Close (result);
}
dmz::V8Value
dmz::JsModuleUiV8QtBasic::_create_tab_widget (const v8::Arguments &Args) {
v8::HandleScope scope;
V8Value result = v8::Undefined ();
JsModuleUiV8QtBasic *self = _to_self (Args);
if (self) {
QWidget *parent = 0;
if (Args.Length ()) { parent = self->_to_qwidget (Args[0]); }
QTabWidget *widget = new QTabWidget (parent);
result = self->create_v8_qobject (widget);
}
return scope.Close (result);
}
void
dmz::JsModuleUiV8QtBasic::_init_tab_widget () {
v8::HandleScope scope;
_tabWidgetTemp = V8FunctionTemplatePersist::New (v8::FunctionTemplate::New ());
_tabWidgetTemp->Inherit (_widgetTemp);
V8ObjectTemplate instance = _tabWidgetTemp->InstanceTemplate ();
instance->SetInternalFieldCount (1);
V8ObjectTemplate proto = _tabWidgetTemp->PrototypeTemplate ();
proto->Set ("add", v8::FunctionTemplate::New (_tab_widget_add, _self));
proto->Set ("remove", v8::FunctionTemplate::New (_tab_widget_remove, _self));
proto->Set ("count", v8::FunctionTemplate::New (_tab_widget_count, _self));
proto->Set (
"currentIndex",
v8::FunctionTemplate::New (_tab_widget_current_index, _self));
proto->Set (
"currentWidget",
v8::FunctionTemplate::New (_tab_widget_current_widget, _self));
proto->Set ("at", v8::FunctionTemplate::New (_tab_widget_at, _self));
proto->Set ("indexOf", v8::FunctionTemplate::New (_tab_widget_index_of, _self));
proto->Set ("tabText", v8::FunctionTemplate::New (_tab_widget_tab_text, _self));
proto->Set ("clear", v8::FunctionTemplate::New (_tab_widget_clear, _self));
_tabApi.add_function ("create", _create_tab_widget, _self);
}
|
/*
* Programming language 'Chatra' reference implementation
*
* Copyright(C) 2019-2020 Chatra Project Team
*
* 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.
*
* author: Satoshi Hosokawa (chatra.hosokawa@gmail.com)
*/
#include "Classes.h"
namespace chatra {
static ClassTable embeddedClasses;
static std::forward_list<std::shared_ptr<Node>> embeddedClassesNode;
static std::forward_list<std::unique_ptr<Class>> embeddedClassesPtr;
static std::unique_ptr<Class> clAsync;
static std::unique_ptr<Class> clString;
static std::unique_ptr<Class> clArray;
static std::unique_ptr<Class> clDict;
static std::unordered_map<StringId, Node*> nodeMap;
// note: Any tokens used in embedded scripts must be pre-defined in StringTable.
// note: Do not use inner functions because these are not scanned during restoring state.
// TODO Some method should be native method to gain more performance
static const char* initIterator = R"***(
class Iterator
)***";
static const char* initKeyedIterator = R"***(
class KeyedIterator extends Iterator
def init()
super()
)***";
static const char* initIndexSet = R"***(
class IndexSet
)***";
static const char* initRangeIterator = R"***(
class RangeIterator extends Iterator
var m1, m2, m3
def init(a0, a1, a2)
super()
m1 = a0
m2 = a1
m3 = a2
def hasNext()
return m1 != m2
def next()
t0 = m1
m1 += m3
return value: t0
)***";
static const char* initKeyedRangeIterator = R"***(
class KeyedRangeIterator extends KeyedIterator
var m0: 0
var m1, m2, m3
def init(a0, a1, a2)
super()
m1 = a0
m2 = a1
m3 = a2
def hasNext()
return m1 != m2
def next()
t0 = m1
m1 += m3
return key: m0++, value: t0
)***";
static const char* initRange = R"***(
class Range extends IndexSet
var m1, m2, m3
def init(last: Int)
super()
if last < 0
throw IllegalArgumentException()
m1 = 0
m2 = last
m3 = 1
def init(first: Int, last: Int; step: Int(1))
super()
if step == 0 or (step > 0 and first > last) or (step < 0 and first < last)
throw IllegalArgumentException()
m1 = first
m2 = first + (last - first) /+ step * step
m3 = step
def (position: Int)
return m1 + m3 * position
def iterator()
return RangeIterator(m1, m2, m3)
def keyedIterator()
return KeyedRangeIterator(m1, m2, m3)
def size()
return (m2 - m1) / m3
def first()
return m1
def last()
return m2
def step()
return m3
def ascend()
return m3 > 0
def reverse()
return Range(m2 - m3, m1 - m3, step: -m3)
def toString()
return 'Range('.append(m1).append(', ').append(m2).append(', step: ').append(m3).append(')')
)***";
static const char* initArrayIterator = R"***(
class ArrayIterator extends Iterator
var m0
var m1: 0
def init(a0)
super()
m0 = a0
def hasNext()
return m1 < m0.size
def next()
return value: m0[m1++]
def remove()
return m0.remove(--m1)
)***";
static const char* initArrayKeyedIterator = R"***(
class ArrayKeyedIterator extends KeyedIterator
var m0
var m1: 0
def init(a0)
super()
m0 = a0
def hasNext()
return m1 < m0.size()
def next()
t0: m1++
return key: t0, value: m0[t0]
def remove()
return m0.remove(--m1)
)***";
static const char* initDictIterator = R"***(
class DictIterator extends Iterator
var m0, m1
var m2: 0
def init(a0)
super()
m0 = a0
m1 = a0.keys()
def hasNext()
return m2 < m1.size()
def next()
t0: m1[m2++]
return value: m0[t0]
def remove()
return m0.remove(m1[m2 - 1])
)***";
static const char* initDictKeyedIterator = R"***(
class DictKeyedIterator extends KeyedIterator
var m0, m1
var m2: 0
def init(a0)
super()
m0 = a0
m1 = a0.keys()
def hasNext()
return m2 < m1.size()
def next()
t0: m1[m2++]
return key: t0, value: m0[t0]
def remove()
return m0.remove(m1[m2 - 1])
)***";
static const char* initSequence = R"***(
class Sequence
)***";
static const char* initVariableLengthSequence = R"***(
class VariableLengthSequence extends Sequence
def init()
super()
)***";
static const char* initArrayView = R"***(
class ArrayView extends Sequence
var m0, m1
def init(a0, a1: IndexSet)
super()
m0 = a0
m1 = a1
def size()
return m1.size()
def (a0: Int)
return m0[m1[a0]]
def (a0: Int).set(r)
return m0[m1[a0]] = r
def clone()
return ArrayView(m0, m1)
def equals(a0)
if a0 == null or !(a0 is Sequence)
return false
if size != a0.size
return false
t0 = size
t1 = 0
while t1 < t0
if self[t1] != a0[t1]
return false
t1++
return true
def sub(a0: IndexSet)
return ArrayView(self, a0)
def iterator()
return ArrayIterator(self)
def keyedIterator()
return ArrayKeyedIterator(self)
def toArray()
t0 = Array()
t1 = m1.size()
t2 = 0
while t2 < t1
t0.add(m0[m1[t2++]])
return t0
def toString()
t0 = m0.toString()
t0.append('.sub(')
t0.append(m1.toString())
return t0.append(')')
)***";
void EventObject::registerWatcher(void* tag, EventWatcher watcher) {
std::lock_guard<SpinLock> lock(lockWatchers);
registered.emplace(tag, watcher);
}
void EventObject::activateWatcher(void* tag) {
bool shouldRestore = false;
EventWatcher watcher;
{
std::lock_guard<SpinLock> lock(lockWatchers);
auto it = registered.find(tag);
if (it == registered.cend())
return;
watcher = it->second;
registered.erase(it);
if (count == 0) {
activated.emplace(tag, watcher);
return;
}
if (count != std::numeric_limits<unsigned>::max()) {
count--;
shouldRestore = true;
}
}
if (!watcher(tag) && shouldRestore)
notifyOne();
}
bool EventObject::unregisterWatcher(void* tag) {
std::lock_guard<SpinLock> lock(lockWatchers);
return registered.erase(tag) + activated.erase(tag) != 0;
}
void EventObject::notifyOne() {
for (;;) {
void* tag;
EventWatcher watcher;
{
std::lock_guard<SpinLock> lock(lockWatchers);
chatra_assert(count != std::numeric_limits<unsigned>::max());
if (activated.empty()) {
count++;
return;
}
auto it = activated.cbegin();
tag = it->first;
watcher = it->second;
activated.erase(it);
}
if (watcher(tag))
return;
}
}
void EventObject::notifyAll() {
std::unordered_map<void*, EventWatcher> watchersCopy;
{
std::lock_guard<SpinLock> lock(lockWatchers);
count = std::numeric_limits<unsigned>::max();
std::swap(activated, watchersCopy);
}
for (auto& e : watchersCopy)
e.second(e.first);
}
void EventObject::saveEventObject(Writer& w) const {
w.out(count);
}
void EventObject::restoreEventObject(Reader& r) {
r.in(count);
}
const Class* Async::getClassStatic() {
return clAsync.get();
}
static const char* initAsync = R"***(
class Async
var m0
def init()
def _native_updated() as native
def finished()
return _native_updated()
def result()
if !_native_updated()
throw UnsupportedOperationException()
return m0
def result().set(r)
throw UnsupportedOperationException()
)***";
[[noreturn]] static void createAsync(const Class* cl, Reference ref) {
(void)cl;
(void)ref;
chatra_assert(cl == clAsync.get());
throw RuntimeException(StringId::UnsupportedOperationException);
}
void Async::native_updated(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
ret.setBool(self.updated);
}
void Async::updateResult(Reference ref) {
chatra_assert(Async::getClassStatic()->refMethods().find(nullptr, StringId::m0, StringId::Invalid, {}, {})->position == 0);
this->ref(0).setWithoutLock(ref);
updated = true;
notifyAll();
}
bool Async::save(Writer& w) const {
w.out(updated.load());
saveEventObject(w);
return false;
}
Async::Async(Reader& r) noexcept : ObjectBase(typeId_Async, getClassStatic()) {
(void)r;
}
bool Async::restore(Reader& r) {
updated.store(r.read<bool>());
restoreEventObject(r);
return false;
}
static void createString(const Class* cl, Reference ref) {
(void)cl;
chatra_assert(cl == clString.get());
ref.allocate<String>();
}
static inline unsigned uc(char c) {
return static_cast<unsigned>(c);
}
char32_t String::getCharOrThrow(const std::string& str, size_t index) {
auto c = uc(str[index]);
if ((c & 0x80U) == 0)
return static_cast<char32_t>(c);
if ((c & 0xE0U) == 0xC0U)
return static_cast<char32_t>((c & 0x1FU) << 6U | (uc(str[index + 1]) & 0x3FU));
if ((c & 0xF0U) == 0xE0U) {
return static_cast<char32_t>((c & 0x0FU) << 12U | (uc(str[index + 1]) & 0x3FU) << 6U |
(uc(str[index + 2]) & 0x3FU));
}
if ((c & 0xF8U) == 0xF0U) {
return static_cast<char32_t>((c & 0x07U) << 18U | (uc(str[index + 1]) & 0x3FU) << 12U |
(uc(str[index + 2]) & 0x3FU) << 6U | (uc(str[index + 3]) & 0x3FU));
}
throw RuntimeException(StringId::IllegalArgumentException);
}
size_t String::extractCharOrThrow(char32_t c, char* dest) {
size_t count = extractChar(c, dest);
if (count == 0)
throw RuntimeException(StringId::IllegalArgumentException);
return count;
}
size_t String::fetchIndex(const Reference& ref, bool allowBoundary) const {
auto rawIndex = static_cast<ptrdiff_t>(ref.getInt());
auto index = static_cast<size_t>(rawIndex >= 0 ? rawIndex : length + rawIndex);
if (index >= length) {
if (index == length && allowBoundary)
return index;
throw RuntimeException(StringId::IllegalArgumentException);
}
return index;
}
size_t String::getPosition(size_t index) const {
if (index == 0)
return 0;
size_t position = positionHash[index / positionHashPitch];
size_t left = index % positionHashPitch;
for (size_t i = 0; i < left; i++)
position += byteCount(value, position);
return position;
}
void String::rehash() {
length = 0;
positionHash.clear();
positionHash.reserve(value.size() / positionHashPitch);
for (size_t i = 0; i < value.size(); length++) {
size_t count = byteCount(value, i);
if (count == 0)
throw RuntimeException(StringId::IllegalArgumentException);
if (length % positionHashPitch == 0)
positionHash.emplace_back(i);
i += count;
}
}
const Class* String::getClassStatic() {
return clString.get();
}
bool String::save(Writer& w) const {
w.out(value);
return true;
}
String::String(Reader& r) noexcept : ObjectBase(typeId_String, getClassStatic()) {
(void)r;
}
bool String::restore(chatra::Reader& r) {
r.in(value);
rehash();
return true;
}
static const char* initString = R"***(
class String extends VariableLengthSequence
def init()
def init.fromString(a0: String) as native
def init.fromChar(a0: Int) as native
def size() as native
def set(a0: String) as native
def add(a0...;)
t0 = a0.size()
t1 = 0
while t1 < t0
t2 = a0[t1++]
if !(t2 is Int)
throw IllegalArgumentException()
_native_add(t2)
return self
def _native_add(a0) as native
def add(a0: Int)
_native_add(a0)
return self
def add(a0: String)
_native_insert(size, a0)
return self
def insert(position: Int, a0...;)
t0 = a0.size()
t1 = 0
while t1 < t0
t2 = a0[t1]
if !(t2 is Int)
throw IllegalArgumentException()
_native_insert(position + t1, t2)
t1++
return self
def _native_insert(a0, a1) as native
def insert(position: Int, a0: Int)
_native_insert(position, a0)
return self
def insert(position: Int, a0: String)
_native_insert(position, a0)
return self
def _native_append(a0) as native
def append(a0)
if a0 == null
_native_append("null")
else if a0 is String or a0 is Bool or a0 is Int or a0 is Float
_native_append(a0)
else
_native_append(a0.toString())
return self
def _native_at(a0) as native
def (a0: Int)
return _native_at(a0)
def _native_at(a0, a1) as native
def (a0: Int).set(r: Int)
return _native_at(a0, r)
def remove(position: Int) as native
def remove(a0: IndexSet)
t0 = ''
if a0.first == a0.last
return t0
t2 = size
if a0.ascend
for t1 in a0.reverse
t0.insert(0, remove(t1 >= 0 ? t1 : t2 + t1))
else
for t1 in a0
t0.add(remove(t1 >= 0 ? t1 : t2 + t1))
return t0
def clear()
set('')
return self
def clone() as native
def equals(a0) as native
def _native_sub(a0, a1) as native
def sub(first: Int)
return _native_sub(first, size)
def sub(first: Int, last: Int)
return _native_sub(first, last)
def iterator()
return ArrayIterator(self)
def keyedIterator()
return ArrayKeyedIterator(self)
def toArray()
return Array().append(self)
def toString()
return clone()
)***";
void String::native_initFromString(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
auto& r = args.ref(0).deref<String>();
self.value = r.value;
self.length = r.length;
self.positionHash = r.positionHash;
}
void String::native_initFromChar(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
auto c = args.ref(0).getInt();
char buffer[4];
size_t count = extractCharOrThrow(static_cast<char32_t>(c), buffer);
self.value.insert(self.value.cbegin(), buffer, buffer + count);
self.length = 1;
self.positionHash.emplace_back(0);
}
void String::native_size(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
ret.setInt(static_cast<int64_t>(self.length));
}
void String::native_set(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
native_initFromString(CHATRA_NATIVE_ARGS_FORWARD);
}
void String::native_add(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
char buffer[4];
size_t count = extractCharOrThrow(static_cast<char32_t>(args.ref(0).getInt()), buffer);
self.value.append(buffer, buffer + count);
self.rehash();
}
void String::native_insert(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
size_t position = self.getPosition(self.fetchIndex(args.ref(0), true));
auto ref = args.ref(1);
switch (ref.valueType()) {
case ReferenceValueType::Int: {
char buffer[4];
size_t count = extractCharOrThrow(static_cast<char32_t>(ref.getInt()), buffer);
self.value.insert(self.value.cbegin() + position, buffer, buffer + count);
break;
}
case ReferenceValueType::Object: {
if (ref.deref<ObjectBase>().getClass() != String::getClassStatic())
throw RuntimeException(StringId::IllegalArgumentException);
self.value.insert(position, ref.deref<String>().value);
break;
}
default:
throw RuntimeException(StringId::IllegalArgumentException);
}
self.rehash();
}
void String::native_append(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
auto ref = args.ref(0);
switch (ref.valueType()) {
case ReferenceValueType::Bool: self.value += (ref.getBool() ? "true" : "false"); break;
case ReferenceValueType::Int: self.value += std::to_string(ref.getInt()); break;
case ReferenceValueType::Float: self.value += std::to_string(ref.getFloat()); break;
default:
if (ref.deref<ObjectBase>().getClass() != String::getClassStatic())
throw RuntimeException(StringId::IllegalArgumentException);
self.value += ref.deref<String>().value;
break;
}
self.rehash();
}
void String::native_at(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
size_t position = self.getPosition(self.fetchIndex(args.ref(0)));
char32_t c0 = getCharOrThrow(self.value, position);
if (args.size() == 1) {
ret.setInt(static_cast<int64_t>(c0));
return;
}
char32_t c1 = static_cast<char32_t>(args.ref(1).getInt());
ret.setInt(static_cast<int64_t>(c1));
size_t c0Count = byteCount(self.value, position);
char buffer[4];
size_t c1Count = extractCharOrThrow(c1, buffer);
self.value.replace(self.value.cbegin() + position, self.value.cbegin() + position + c0Count, buffer, buffer + c1Count);
self.rehash();
}
void String::native_remove(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
size_t position = self.getPosition(self.fetchIndex(args.ref(0)));
ret.setInt(static_cast<int64_t>(getCharOrThrow(self.value, position)));
size_t count = byteCount(self.value, position);
self.value.erase(position, count);
self.rehash();
}
void String::native_clone(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
ret.allocate<String>().setValue(self.value);
}
void String::native_equals(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
auto value = args.ref(0);
if (value.isNull() || value.valueType() != ReferenceValueType::Object ||
value.deref<ObjectBase>().getClass() != getClassStatic()) {
ret.setBool(false);
return;
}
std::string lValue;
{
std::lock_guard<SpinLock> lock(self.lockValue);
lValue = self.value;
}
std::string rValue;
{
auto& target = value.deref<String>();
std::lock_guard<SpinLock> lock(target.lockValue);
rValue = target.value;
}
ret.setBool(lValue == rValue);
}
void String::native_sub(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
size_t position0 = self.getPosition(self.fetchIndex(args.ref(0)));
size_t position1 = self.getPosition(self.fetchIndex(args.ref(1), true));
if (position0 > position1)
throw RuntimeException(StringId::IllegalArgumentException);
ret.allocate<String>().setValue(self.value.substr(position0, position1 - position0));
}
ContainerBody::ContainerBody(Storage& storage, size_t capacity) noexcept
: Object(storage, typeId_ContainerBody, capacity, Object::ElementsAreExclusive()) {}
bool ContainerBody::save(Writer& w) const {
(void)w;
return false;
}
ContainerBody::ContainerBody(Reader& r) noexcept : Object(typeId_ContainerBody) {
(void)r;
}
bool ContainerBody::restore(Reader& r) {
(void)r;
return false;
}
void ContainerBase::extend(size_t required) {
if (required <= capacity)
return;
if (capacity == 0) {
capacity = ref(0).deref().size();
if (required <= capacity)
return;
}
capacity = std::max(required, capacity * 3 / 2);
auto& o1 = ref(1).allocate<ContainerBody>(capacity);
auto& o0 = ref(0).deref();
for (size_t i = 0; i < length; i++)
o1.ref(i).set(o0.ref(i));
ref(0).set(ref(1));
}
Object& ContainerBase::container() const {
return ref(0).deref();
}
ContainerBase::ContainerBase(Storage& storage, TypeId typeId, const Class* cl) noexcept
: ObjectBase(storage, typeId, cl, 2, ObjectBase::ElementsAreExclusive()) {
ref(0).allocate<ContainerBody>(capacity);
}
ContainerBase::ContainerBase(TypeId typeId, const Class* cl) noexcept : ObjectBase(typeId, cl), capacity(0) {
}
static void createArray(const Class* cl, Reference ref) {
(void)cl;
chatra_assert(cl == clArray.get());
ref.allocate<Array>();
}
size_t Array::fetchIndex(const Reference& ref, bool allowBoundary) const {
auto rawIndex = static_cast<ptrdiff_t>(ref.getInt());
auto index = static_cast<size_t>(rawIndex >= 0 ? rawIndex : length + rawIndex);
if (index >= length) {
if (index == length && allowBoundary)
return index;
throw RuntimeException(StringId::IllegalArgumentException);
}
return index;
}
const Class* Array::getClassStatic() {
return clArray.get();
}
void Array::add(Reference ref) {
std::lock_guard<SpinLock> lock(lockValue);
extend(length + 1);
container().ref(length++).set(ref);
}
bool Array::save(Writer& w) const {
w.out(length);
return false;
}
Array::Array(Reader& r) noexcept : ContainerBase(typeId_Array, getClassStatic()) {
(void)r;
}
bool Array::restore(Reader& r) {
r.in(length);
return false;
}
static const char* initArray = R"***(
class Array extends VariableLengthSequence
def init()
def size() as native
def has(a0)
t0 = size()
t1 = 0
while t1 < t0
if _native_at(t1++) == a0
return true
return false
def _native_add(a0) as native
def add(a0...;)
t0 = a0.size()
t1 = 0
while t1 < t0
_native_add(a0[t1++])
return self
def add(a0)
_native_add(a0)
return self
def insert(position: Int, a0...;)
t0 = a0.size()
t1 = 0
while t1 < t0
_native_insert(position + t1, a0[t1])
t1++
return self
def _native_insert(a0, a1) as native
def insert(position: Int, a0)
_native_insert(position, a0)
return self
def append(a0)
if a0 == null
return self
for t0 in a0
add(t0)
return self
def _native_at(a0) as native
def (position: Int)
return _native_at(position)
def _native_at(a0, a1) as native
def (position: Int).set(r)
return _native_at(position, r)
def remove(position: Int) as native
def remove(a0: IndexSet)
t0 = Array()
if a0.first == a0.last
return t0
t2 = size
if a0.ascend
for t1 in a0.reverse
t0.insert(0, remove(t1 >= 0 ? t1 : t2 + t1))
else
for t1 in a0
t0.add(remove(t1 >= 0 ? t1 : t2 + t1))
return t0
def clear()
while size > 0
remove(size - 1)
return self
def clone()
return Array().append(self)
def equals(a0)
if a0 == null or !(a0 is Sequence)
return false
if size != a0.size
return false
t0 = size
t1 = 0
while t1 < t0
if self[t1] != a0[t1]
return false
t1++
return true
def sub(a0: IndexSet)
return ArrayView(self, a0)
def iterator()
return ArrayIterator(self)
def keyedIterator()
return ArrayKeyedIterator(self)
def toArray()
return clone()
def toString()
t0 = '{'
if size > 0
t3 = self[0]
if t3 is String
t0.append('"').append(t3).append('"')
else
t0.append(t3)
t1 = size()
t2 = 1
while t2 < t1
t0.append(', ')
t3 = self[t2++]
if t3 is String
t0.append('"').append(t3).append('"')
else
t0.append(t3)
return t0.append('}')
)***";
void Array::native_size(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
ret.setInt(static_cast<int64_t>(self.length));
}
void Array::native_add(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
self.extend(self.length + 1);
self.container().ref(self.length++).set(args.ref(0));
}
void Array::native_insert(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
auto index = self.fetchIndex(args.ref(0), true);
self.extend(self.length + 1);
auto& c = self.container();
for (auto i = self.length; i-- > index; )
c.ref(i + 1).set(c.ref(i));
c.ref(index).set(args.ref(1));
self.length++;
}
void Array::native_remove(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
auto index = self.fetchIndex(args.ref(0));
auto& c = self.container();
ret.set(c.ref(index));
while (++index < self.length)
c.ref(index - 1).set(c.ref(index));
c.ref(--self.length).setNull();
}
void Array::native_at(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
auto index = self.fetchIndex(args.ref(0));
auto ref0 = self.container().ref(index);
if (args.size() == 1) {
ret.set(ref0);
return;
}
ref0.set(args.ref(1));
ret.set(ref0);
}
static void createDict(const Class* cl, Reference ref) {
(void)cl;
chatra_assert(cl == clDict.get());
ref.allocate<Dict>();
}
const Class* Dict::getClassStatic() {
return clDict.get();
}
void Dict::add(std::string key, Reference ref) {
std::lock_guard<SpinLock> lock(lockValue);
auto it = keyToIndex.find(key);
if (it != keyToIndex.cend()) {
container().ref(it->second).set(ref);
return;
}
size_t index;
if (freeIndexes.empty()) {
index = keyToIndex.size();
extend(index + 1);
}
else {
index = freeIndexes.back();
freeIndexes.pop_back();
}
keyToIndex.emplace(std::move(key), index);
length++;
container().ref(index).set(ref);
}
bool Dict::remove(const std::string& key, Reference& ret) {
std::lock_guard<SpinLock> lock(lockValue);
auto it = keyToIndex.find(key);
if (it == keyToIndex.cend())
return false;
size_t index = it->second;
auto ref = container().ref(index);
ret.set(ref);
ref.setNull();
keyToIndex.erase(it);
freeIndexes.emplace_back(index);
length--;
return true;
}
bool Dict::save(Writer& w) const {
w.out(length);
w.out(keyToIndex, [&](const std::pair<std::string, size_t>& e) {
w.out(e.first);
w.out(e.second);
});
size_t maxIndex = 0;
for (auto& e : keyToIndex)
maxIndex = std::max(maxIndex, e.second);
for (auto index : freeIndexes)
maxIndex = std::max(maxIndex, index);
w.out(maxIndex);
return false;
}
Dict::Dict(Reader& r) noexcept : ContainerBase(typeId_Dict, getClassStatic()) {
(void)r;
}
bool Dict::restore(Reader& r) {
r.in(length);
r.inList([&]() {
auto key = r.read<std::string>();
auto index = r.read<size_t>();
keyToIndex.emplace(std::move(key), index);
});
auto maxIndex = r.read<size_t>();
std::vector<bool> indexes(maxIndex + 1, false);
for (auto& e : keyToIndex)
indexes[e.second] = true;
for (size_t i = 0; i <= maxIndex; i++) {
if (!indexes[i])
freeIndexes.emplace_back(i);
}
return false;
}
static const char* initDict = R"***(
class Dict
def init()
def size() as native
def has(a0: String) as native
def add(; a0...)
t0 = a0.keys()
for t1 in t0
_native_add(t1, a0[t1])
return self
def _native_add(a0: String, a1) as native
def add(key : String, value)
_native_add(key, value)
return self
def append(a0)
if a0 == null
return self
for key, value in a0
if !(key is String)
throw IllegalArgumentException()
add(key, value)
return self
def _native_at(a0) as native
def (key: String)
if key == null
throw IllegalArgumentException()
return _native_at(key)
def (key: String).set(r)
_native_add(key, r)
return r
def remove(a0)
t0 = Dict()
for t1 in a0
if !(t1 is String)
throw IllegalArgumentException()
t0.add(t1, remove(t1))
return t0
def remove(key: String) as native
def clear()
remove(keys())
return self
def clone()
return Dict().append(self)
def equals(a0)
if a0 == null or !(a0 is Dict)
return false
if size != a0.size
return false
for t0 in keys
if !a0.has(t0) or self[t0] != a0[t0]
return false
return true
def iterator()
return DictIterator(self)
def keyedIterator()
return DictKeyedIterator(self)
def keys() as native
def values() as native
def toDict()
return clone()
def toString()
t0 = '{'
t1 = 0
for key, value in self
if t1++ != 0
t0.append(', ')
t0.append('"').append(key).append('": ')
if value is String
t0.append('"').append(value).append('"')
else
t0.append(value)
return t0.append('}')
)***";
void Dict::native_size(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
ret.setInt(static_cast<int64_t>(self.length));
}
void Dict::native_has(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
auto it = self.keyToIndex.find(args.ref(0).deref<String>().getValue());
ret.setBool(it != self.keyToIndex.cend());
}
void Dict::native_add(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
self.add(args.ref(0).deref<String>().getValue(), args.ref(1));
}
void Dict::native_at(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
auto key = args.ref(0).deref<String>().getValue();
auto it = self.keyToIndex.find(key);
if (it == self.keyToIndex.cend())
throw RuntimeException(StringId::IllegalArgumentException);
else
ret.set(self.container().ref(it->second));
}
void Dict::native_remove(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
if (!self.remove(args.ref(0).deref<String>().getValue(), ret))
throw RuntimeException(StringId::IllegalArgumentException);
}
void Dict::native_keys(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
auto& retValue = ret.allocate<Array>(self.keyToIndex.size());
size_t index = 0;
for (auto& e : self.keyToIndex)
retValue.container().ref(index++).allocate<String>().setValue(e.first);
}
void Dict::native_values(CHATRA_NATIVE_ARGS) {
CHATRA_NATIVE_SELF;
std::lock_guard<SpinLock> lock(self.lockValue);
auto& retValue = ret.allocate<Array>(self.keyToIndex.size());
size_t index = 0;
for (auto& e : self.keyToIndex)
retValue.container().ref(index++).set(self.container().ref(e.second));
}
template <StringId name>
static void createException(const Class* cl, Reference ref) {
(void)cl;
ref.allocate<Exception<name>>();
}
template <StringId name>
static void registerException() {
auto* cl = PreDefined<Exception<name>, name>::getWritableClassStatic();
cl->addDefaultConstructor(createException<name>);
embeddedClasses.add(cl);
}
template <StringId name, StringId baseName>
static void registerException_Derived() {
auto* cl = PreDefined<Exception<name>, name>::getWritableClassStatic();
cl->addDefaultConstructor(createException<name>);
cl->addParentClass(PreDefined<Exception<baseName>, baseName>::getClassStatic());
embeddedClasses.add(cl);
}
static std::unique_ptr<Class> createEmbeddedClass(ParserWorkingSet& ws, IErrorReceiver& errorReceiver,
std::shared_ptr<StringTable>& sTable, IClassFinder& classFinder, std::string script,
ObjectBuilder nativeConstructor, const std::vector<NativeMethod>& nativeMethods) {
auto lines = parseLines(errorReceiver, sTable, "(internal-classes)", 1, std::move(script));
auto node = groupScript(errorReceiver, sTable, lines);
structureInnerNode(errorReceiver, sTable, node.get(), true);
parseInnerNode(ws, errorReceiver, sTable, node.get(), true);
chatra_assert(node->blockNodes.size() == 1 && node->blockNodes[0]->type == NodeType::Class);
nodeMap.emplace(node->blockNodes[0]->sid, node.get());
std::unique_ptr<Class> cl(new Class(errorReceiver, sTable.get(), classFinder, nullptr, node->blockNodes[0].get(),
nativeConstructor, nativeMethods));
embeddedClasses.add(cl.get());
embeddedClassesNode.emplace_front(std::move(node));
return cl;
}
void initializeEmbeddedClasses() {
registerException<StringId::Exception>();
registerException_Derived<StringId::RuntimeException, StringId::Exception>();
registerException_Derived<StringId::ArithmeticException, StringId::RuntimeException>();
registerException_Derived<StringId::ParserErrorException, StringId::Exception>();
registerException_Derived<StringId::UnsupportedOperationException, StringId::Exception>();
registerException_Derived<StringId::PackageNotFoundException, StringId::Exception>();
registerException_Derived<StringId::ClassNotFoundException, StringId::Exception>();
registerException_Derived<StringId::MemberNotFoundException, StringId::Exception>();
registerException_Derived<StringId::IncompleteExpressionException, StringId::Exception>();
registerException_Derived<StringId::TypeMismatchException, StringId::Exception>();
registerException_Derived<StringId::NullReferenceException, StringId::RuntimeException>();
registerException_Derived<StringId::OverflowException, StringId::ArithmeticException>();
registerException_Derived<StringId::DivideByZeroException, StringId::ArithmeticException>();
registerException_Derived<StringId::IllegalArgumentException, StringId::RuntimeException>();
registerException_Derived<StringId::NativeException, StringId::Exception>();
embeddedClasses.add(Bool::getClassStatic());
embeddedClasses.add(Int::getClassStatic());
embeddedClasses.add(Float::getClassStatic());
ParserWorkingSet ws;
IAssertionNullErrorReceiver nullErrorReceiver;
IErrorReceiverBridge errorReceiver(nullErrorReceiver);
std::shared_ptr<StringTable> sTable = StringTable::newInstance();
struct ClassFinder : public IClassFinder {
const Class* findClass(StringId name) override {
return embeddedClasses.find(name);
}
const Class* findPackageClass(StringId packageName, StringId name) override {
(void)packageName;
(void)name;
return nullptr;
}
} classFinder;
auto addClass = [&](const char* init) {
embeddedClassesPtr.emplace_front(
createEmbeddedClass(ws, errorReceiver, sTable, classFinder, init, nullptr, {}));
};
addClass(initIterator);
addClass(initKeyedIterator);
addClass(initIndexSet);
addClass(initRangeIterator);
addClass(initKeyedRangeIterator);
addClass(initRange);
addClass(initArrayIterator);
addClass(initArrayKeyedIterator);
addClass(initDictIterator);
addClass(initDictKeyedIterator);
addClass(initSequence);
addClass(initVariableLengthSequence);
addClass(initArrayView);
/*embeddedClassesPtr.emplace_front(
createEmbeddedClass(ws, errorReceiver, sTable, classFinder, initArrayIterator, nullptr, {}));
embeddedClassesPtr.emplace_front(
createEmbeddedClass(ws, errorReceiver, sTable, classFinder, initArrayKeyedIterator, nullptr, {}));
*/
clAsync = createEmbeddedClass(ws, errorReceiver, sTable, classFinder, initAsync, createAsync, {
{StringId::_native_updated, StringId::Invalid, &Async::native_updated},
});
clString = createEmbeddedClass(ws, errorReceiver, sTable, classFinder, initString, createString, {
{StringId::Init, StringId::fromString, &String::native_initFromString},
{StringId::Init, StringId::fromChar, &String::native_initFromChar},
{StringId::size, StringId::Invalid, &String::native_size},
{StringId::Set, StringId::Invalid, &String::native_set},
{StringId::_native_add, StringId::Invalid, &String::native_add},
{StringId::_native_insert, StringId::Invalid, &String::native_insert},
{StringId::_native_append, StringId::Invalid, &String::native_append},
{StringId::_native_at, StringId::Invalid, &String::native_at},
{StringId::remove, StringId::Invalid, &String::native_remove},
{StringId::clone, StringId::Invalid, &String::native_clone},
{StringId::equals, StringId::Invalid, &String::native_equals},
{StringId::_native_sub, StringId::Invalid, &String::native_sub}
});
clArray = createEmbeddedClass(ws, errorReceiver, sTable, classFinder, initArray, createArray, {
{StringId::size, StringId::Invalid, &Array::native_size},
{StringId::_native_add, StringId::Invalid, &Array::native_add},
{StringId::_native_insert, StringId::Invalid, &Array::native_insert},
{StringId::remove, StringId::Invalid, &Array::native_remove},
{StringId::_native_at, StringId::Invalid, &Array::native_at}
});
clDict = createEmbeddedClass(ws, errorReceiver, sTable, classFinder, initDict, createDict, {
{StringId::size, StringId::Invalid, &Dict::native_size},
{StringId::has, StringId::Invalid, &Dict::native_has},
{StringId::_native_add, StringId::Invalid, &Dict::native_add},
{StringId::_native_at, StringId::Invalid, &Dict::native_at},
{StringId::remove, StringId::Invalid, &Dict::native_remove},
{StringId::keys, StringId::Invalid, &Dict::native_keys},
{StringId::values, StringId::Invalid, &Dict::native_values}
});
// Add embedded conversions
Bool::getWritableClassStatic()->addConvertingConstructor(Int::getClassStatic());
Bool::getWritableClassStatic()->addConvertingConstructor(clString.get());
Int::getWritableClassStatic()->addConvertingConstructor(Bool::getClassStatic());
Int::getWritableClassStatic()->addConvertingConstructor(Float::getClassStatic());
Int::getWritableClassStatic()->addConvertingConstructor(clString.get());
Float::getWritableClassStatic()->addConvertingConstructor(Bool::getClassStatic());
Float::getWritableClassStatic()->addConvertingConstructor(Int::getClassStatic());
Float::getWritableClassStatic()->addConvertingConstructor(clString.get());
if (errorReceiver.hasError())
throw InternalError();
if (sTable->getVersion() != 0) {
#ifndef CHATRA_NDEBUG
printf("Additional strings:");
for (auto i = static_cast<size_t>(StringId::PredefinedStringIds); i < sTable->validIdCount(); i++)
printf(" %s", sTable->ref(static_cast<StringId>(i)).c_str());
printf("\n");
#endif
throw InternalError();
}
}
ClassTable& refEmbeddedClassTable() {
return embeddedClasses;
}
void registerEmbeddedClasses(ClassTable& classes) {
classes.add(embeddedClasses);
}
const std::unordered_map<StringId, Node*>& refNodeMapForEmbeddedClasses() {
return nodeMap;
}
#ifndef CHATRA_NDEBUG
void String::dump(const std::shared_ptr<chatra::StringTable>& sTable) const {
printf("String: value=\"%s\" ", value.c_str());
ObjectBase::dump(sTable);
}
void Array::dump(const std::shared_ptr<chatra::StringTable>& sTable) const {
printf("Array: capacity=%u, length=%u ", static_cast<unsigned>(getCapacity()), static_cast<unsigned>(length));
container().dump(sTable);
}
void Dict::dump(const std::shared_ptr<chatra::StringTable>& sTable) const {
printf("Dict: capacity=%u, length=%u, free=%u ", static_cast<unsigned>(getCapacity()), static_cast<unsigned>(length),
static_cast<unsigned>(freeIndexes.size()));
container().dump(sTable);
std::vector<std::pair<size_t, std::string>> indexToKey;
for (auto& e : keyToIndex)
indexToKey.emplace_back(e.second, e.first);
std::sort(indexToKey.begin(), indexToKey.end(), [](const std::pair<size_t, std::string>& a, const std::pair<size_t, std::string>& b) {
return a.first < b.first;
});
for (auto& e : indexToKey)
printf(" [%u] <- \"%s\"\n", static_cast<unsigned>(e.first), e.second.c_str());
}
#endif // !CHATRA_NDEBUG
} // namespace chatra
|
dnl AMD64 mpn_mul_basecase optimised for AMD Zen.
dnl Copyright 2012, 2013, 2017 Free Software Foundation, Inc.
dnl This file is part of the GNU MP Library.
dnl
dnl The GNU MP Library is free software; you can redistribute it and/or modify
dnl it under the terms of either:
dnl
dnl * the GNU Lesser General Public License as published by the Free
dnl Software Foundation; either version 3 of the License, or (at your
dnl option) any later version.
dnl
dnl or
dnl
dnl * the GNU General Public License as published by the Free Software
dnl Foundation; either version 2 of the License, or (at your option) any
dnl later version.
dnl
dnl or both in parallel, as here.
dnl
dnl The GNU MP Library is distributed in the hope that it will be useful, but
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
dnl for more details.
dnl
dnl You should have received copies of the GNU General Public License and the
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
dnl see https://www.gnu.org/licenses/.
include(`../config.m4')
C TODO
C * Try 2x unrolling instead of current 4x, at least for mul_1. Else consider
C shallower sw pipelining of mul_1/addmul_1 loops, allowing 4 or 6 instead
C of 8 product registers.
C * Split up mul_1 into 4 loops in order to fall into the addmul_1 loops
C without branch tree.
C * Improve the overlapped software pipelining. The mulx in the osp block now
C suffers from write/read conflicts, in particular the 1 mod 4 case. Also,
C mul_1 could osp into addmul_1.
C * Let vn_param be vn to save a copy.
C * Re-allocate to benefit more from 32-bit encoding.
C * Poor performance for e.g. n = 12,16.
define(`rp', `%rdi')
define(`up', `%rsi')
define(`un_param', `%rdx')
define(`vp_param', `%rcx')
define(`vn_param', `%r8')
define(`un', `%r14')
define(`vp', `%rbp')
define(`v0', `%rdx')
define(`n', `%rcx')
define(`vn', `%r15')
ABI_SUPPORT(DOS64)
ABI_SUPPORT(STD64)
ASM_START()
TEXT
ALIGN(32)
PROLOGUE(mpn_mul_basecase)
FUNC_ENTRY(4)
IFDOS(` mov 56(%rsp), %r8d ')
cmp $2, un_param
ja L(gen)
mov (vp_param), %rdx
mulx( (up), %rax, %r9) C 0 1
je L(s2x)
L(s11): mov %rax, (rp)
mov %r9, 8(rp)
FUNC_EXIT()
ret
L(s2x): cmp $2, vn_param
mulx( 8,(up), %r8, %r10) C 1 2
je L(s22)
L(s21): add %r8, %r9
adc $0, %r10
mov %rax, (rp)
mov %r9, 8(rp)
mov %r10, 16(rp)
FUNC_EXIT()
ret
L(s22): add %r8, %r9 C 1
adc $0, %r10 C 2
mov 8(vp_param), %rdx
mov %rax, (rp)
mulx( (up), %r8, %r11) C 1 2
mulx( 8,(up), %rax, %rdx) C 2 3
add %r11, %rax C 2
adc $0, %rdx C 3
add %r8, %r9 C 1
adc %rax, %r10 C 2
adc $0, %rdx C 3
mov %r9, 8(rp)
mov %r10, 16(rp)
mov %rdx, 24(rp)
FUNC_EXIT()
ret
L(gen): push %r15
push %r14
push %r13
push %r12
push %rbp
push %rbx
mov un_param, un
mov vp_param, vp
mov vn_param, vn
mov (up), %r9
mov (vp), v0
lea (up,un,8), up
lea -32(rp,un,8), rp
neg un
mov un, n
test $1, R8(un)
jz L(mx0)
L(mx1): test $2, R8(un)
jz L(mb3)
L(mb1): mulx( %r9, %rbx, %rax)
inc n
.byte 0xc4,0x22,0xb3,0xf6,0x44,0xf6,0x08 C mulx 8(up,un,8), %r9, %r8
.byte 0xc4,0x22,0xa3,0xf6,0x54,0xf6,0x10 C mulx 16(up,un,8), %r11, %r10
jmp L(mlo1)
L(mb3): mulx( %r9, %r11, %r10)
.byte 0xc4,0x22,0x93,0xf6,0x64,0xf6,0x08 C mulx 8(up,un,8), %r13, %r12
.byte 0xc4,0xa2,0xe3,0xf6,0x44,0xf6,0x10 C mulx 16(up,un,8), %rbx, %rax
sub $-3, n
jz L(mwd3)
test R32(%rdx), R32(%rdx)
jmp L(mlo3)
L(mx0): test $2, R8(un)
jz L(mb0)
L(mb2): mulx( %r9, %r13, %r12)
.byte 0xc4,0xa2,0xe3,0xf6,0x44,0xf6,0x08 C mulx 8(up,un,8), %rbx, %rax
lea 2(n), n
.byte 0xc4,0x22,0xb3,0xf6,0x44,0xf6,0x10 C mulx 16(up,un,8), %r9, %r8
jmp L(mlo2)
L(mb0): mulx( %r9, %r9, %r8)
.byte 0xc4,0x22,0xa3,0xf6,0x54,0xf6,0x08 C mulx 8(up,un,8), %r11, %r10
.byte 0xc4,0x22,0x93,0xf6,0x64,0xf6,0x10 C mulx 16(up,un,8), %r13, %r12
jmp L(mlo0)
L(mtop):jrcxz L(mend)
adc %r8, %r11
mov %r9, (rp,n,8)
L(mlo3):.byte 0xc4,0x62,0xb3,0xf6,0x04,0xce C mulx (up,n,8), %r9, %r8
adc %r10, %r13
mov %r11, 8(rp,n,8)
L(mlo2):.byte 0xc4,0x62,0xa3,0xf6,0x54,0xce,0x08 C mulx 8(up,n,8), %r11, %r10
adc %r12, %rbx
mov %r13, 16(rp,n,8)
L(mlo1):.byte 0xc4,0x62,0x93,0xf6,0x64,0xce,0x10 C mulx 16(up,n,8), %r13, %r12
adc %rax, %r9
mov %rbx, 24(rp,n,8)
L(mlo0):.byte 0xc4,0xe2,0xe3,0xf6,0x44,0xce,0x18 C mulx 24(up,n,8), %rbx, %rax
lea 4(n), n
jmp L(mtop)
L(mend):mov %r9, (rp)
adc %r8, %r11
L(mwd3):mov %r11, 8(rp)
adc %r10, %r13
mov %r13, 16(rp)
adc %r12, %rbx
adc $0, %rax
mov %rbx, 24(rp)
mov %rax, 32(rp)
add $8, vp
dec vn
jz L(end)
C The rest of the file are 4 osp loops around addmul_1
test $1, R8(un)
jnz L(0x1)
L(0x0): test $2, R8(un)
jnz L(oloop2_entry)
L(oloop0_entry):
C initial feed-in block
mov (vp), %rdx
add $8, vp
mov un, n
add $8, rp
.byte 0xc4,0x22,0xb3,0xf6,0x04,0xf6 C mulx (up,un,8), %r9, %r8
.byte 0xc4,0x22,0xa3,0xf6,0x54,0xf6,0x08 C mulx 8(up,un,8), %r11, %r10
.byte 0xc4,0x22,0x93,0xf6,0x64,0xf6,0x10 C mulx 16(up,un,8), %r13, %r12
.byte 0xc4,0xa2,0xe3,0xf6,0x44,0xf6,0x18 C mulx 24(up,un,8), %rbx, %rax
add %r8, %r11
jmp L(lo0)
L(oloop0):
C overlapped software pipelining block
mov (vp), %rdx C new
add $8, vp
add %r9, (rp) C prev
.byte 0xc4,0x22,0xb3,0xf6,0x04,0xf6 C mulx (%rsi,%r14,8),%r9,%r8
adc %r11, 8(rp) C prev
.byte 0xc4,0x22,0xa3,0xf6,0x54,0xf6,0x08 C mulx 0x8(%rsi,%r14,8),%r11,%r10
adc %r13, 16(rp) C prev
.byte 0xc4,0x22,0x93,0xf6,0x64,0xf6,0x10 C mulx 0x10(%rsi,%r14,8),%r13,%r12
adc %rbx, 24(rp) C prev
mov un, n
adc $0, %rax C prev
mov %rax, 32(rp) C prev
add $8, rp
.byte 0xc4,0xa2,0xe3,0xf6,0x44,0xf6,0x18 C mulx 0x18(%rsi,%r14,8),%rbx,%rax
add %r8, %r11 C new
jmp L(lo0)
ALIGN(16)
L(tp0): add %r9, (rp,n,8)
.byte 0xc4,0x62,0xb3,0xf6,0x04,0xce C mulx (up,n,8), %r9, %r8
adc %r11, 8(rp,n,8)
.byte 0xc4,0x62,0xa3,0xf6,0x54,0xce,0x08 C mulx 8(up,n,8), %r11, %r10
adc %r13, 16(rp,n,8)
.byte 0xc4,0x62,0x93,0xf6,0x64,0xce,0x10 C mulx 16(up,n,8), %r13, %r12
adc %rbx, 24(rp,n,8)
adc %rax, %r9
.byte 0xc4,0xe2,0xe3,0xf6,0x44,0xce,0x18 C mulx 24(up,n,8), %rbx, %rax
adc %r8, %r11
L(lo0): adc %r10, %r13
adc %r12, %rbx
adc $0, %rax
add $4, n
jnz L(tp0)
dec vn
jne L(oloop0)
jmp L(final_wind_down)
L(oloop2_entry):
mov (vp), %rdx
add $8, vp
lea 2(un), n
add $8, rp
.byte 0xc4,0x22,0x93,0xf6,0x24,0xf6 C mulx (up,un,8), %r13, %r12
.byte 0xc4,0xa2,0xe3,0xf6,0x44,0xf6,0x08 C mulx 8(up,un,8), %rbx, %rax
add %r12, %rbx
adc $0, %rax
.byte 0xc4,0x22,0xb3,0xf6,0x44,0xf6,0x10 C mulx 16(up,un,8), %r9, %r8
.byte 0xc4,0x62,0xa3,0xf6,0x54,0xce,0x08 C mulx 8(up,n,8), %r11, %r10
add %r13, 16(rp,n,8)
jmp L(lo2)
L(oloop2):
mov (vp), %rdx
add $8, vp
add %r9, (rp)
adc %r11, 8(rp)
adc %r13, 16(rp)
.byte 0xc4,0x22,0x93,0xf6,0x24,0xf6 C mulx (up,un,8), %r13, %r12
adc %rbx, 24(rp)
adc $0, %rax
mov %rax, 32(rp)
.byte 0xc4,0xa2,0xe3,0xf6,0x44,0xf6,0x08 C mulx 8(up,un,8), %rbx, %rax
lea 2(un), n
add $8, rp
.byte 0xc4,0x22,0xb3,0xf6,0x44,0xf6,0x10 C mulx 16(up,un,8), %r9, %r8
add %r12, %rbx
adc $0, %rax
.byte 0xc4,0x22,0xa3,0xf6,0x54,0xf6,0x18 C mulx 0x18(%rsi,%r14,8),%r11,%r10
add %r13, 16(rp,n,8)
jmp L(lo2)
ALIGN(16)
L(tp2): add %r9, (rp,n,8)
.byte 0xc4,0x62,0xb3,0xf6,0x04,0xce C mulx (up,n,8), %r9, %r8
adc %r11, 8(rp,n,8)
.byte 0xc4,0x62,0xa3,0xf6,0x54,0xce,0x08 C mulx 8(up,n,8), %r11, %r10
adc %r13, 16(rp,n,8)
L(lo2): .byte 0xc4,0x62,0x93,0xf6,0x64,0xce,0x10 C mulx 16(up,n,8), %r13, %r12
adc %rbx, 24(rp,n,8)
adc %rax, %r9
.byte 0xc4,0xe2,0xe3,0xf6,0x44,0xce,0x18 C mulx 24(up,n,8), %rbx, %rax
adc %r8, %r11
adc %r10, %r13
adc %r12, %rbx
adc $0, %rax
add $4, n
jnz L(tp2)
dec vn
jne L(oloop2)
jmp L(final_wind_down)
L(0x1): test $2, R8(un)
jz L(oloop3_entry)
L(oloop1_entry):
mov (vp), %rdx
add $8, vp
lea 1(un), n
add $8, rp
.byte 0xc4,0xa2,0xe3,0xf6,0x04,0xf6 C mulx (up,un,8), %rbx, %rax
.byte 0xc4,0x22,0xb3,0xf6,0x44,0xf6,0x08 C mulx 8(up,un,8), %r9, %r8
.byte 0xc4,0x22,0xa3,0xf6,0x54,0xf6,0x10 C mulx 16(up,un,8), %r11, %r10
.byte 0xc4,0x62,0x93,0xf6,0x64,0xce,0x10 C mulx 16(up,n,8), %r13, %r12
add %rbx, 24(rp,n,8)
jmp L(lo1)
L(oloop1):
mov (vp), %rdx
add $8, vp
add %r9, (rp)
.byte 0xc4,0x22,0xb3,0xf6,0x44,0xf6,0x08 C mulx 8(up,un,8), %r9, %r8
adc %r11, 8(rp)
.byte 0xc4,0x22,0xa3,0xf6,0x54,0xf6,0x10 C mulx 16(up,un,8), %r11, %r10
adc %r13, 16(rp)
.byte 0xc4,0x22,0x93,0xf6,0x64,0xf6,0x18 C mulx 0x18(%rsi,%r14,8),%r13,%r12
adc %rbx, 24(rp)
adc $0, %rax
mov %rax, 32(rp)
.byte 0xc4,0xa2,0xe3,0xf6,0x04,0xf6 C mulx (up,un,8), %rbx, %rax
lea 1(un), n
add $8, rp
add %rbx, 24(rp,n,8)
jmp L(lo1)
ALIGN(16)
L(tp1): add %r9, (rp,n,8)
.byte 0xc4,0x62,0xb3,0xf6,0x04,0xce C mulx (up,n,8), %r9, %r8
adc %r11, 8(rp,n,8)
.byte 0xc4,0x62,0xa3,0xf6,0x54,0xce,0x08 C mulx 8(up,n,8), %r11, %r10
adc %r13, 16(rp,n,8)
.byte 0xc4,0x62,0x93,0xf6,0x64,0xce,0x10 C mulx 16(up,n,8), %r13, %r12
adc %rbx, 24(rp,n,8)
L(lo1): adc %rax, %r9
.byte 0xc4,0xe2,0xe3,0xf6,0x44,0xce,0x18 C mulx 24(up,n,8), %rbx, %rax
adc %r8, %r11
adc %r10, %r13
adc %r12, %rbx
adc $0, %rax
add $4, n
jnz L(tp1)
dec vn
jne L(oloop1)
jmp L(final_wind_down)
L(oloop3_entry):
mov (vp), %rdx
add $8, vp
lea 3(un), n
add $8, rp
.byte 0xc4,0x22,0xa3,0xf6,0x14,0xf6 C mulx (up,un,8), %r11, %r10
.byte 0xc4,0x22,0x93,0xf6,0x64,0xf6,0x08 C mulx 8(up,un,8), %r13, %r12
.byte 0xc4,0xa2,0xe3,0xf6,0x44,0xf6,0x10 C mulx 16(up,un,8), %rbx, %rax
add %r10, %r13
adc %r12, %rbx
adc $0, %rax
test n, n
jz L(wd3)
.byte 0xc4,0x62,0xb3,0xf6,0x04,0xce C mulx (up,n,8), %r9, %r8
add %r11, 8(rp,n,8)
jmp L(lo3)
L(oloop3):
mov (vp), %rdx
add $8, vp
add %r9, (rp)
adc %r11, 8(rp)
.byte 0xc4,0x22,0xa3,0xf6,0x14,0xf6 C mulx (up,un,8), %r11, %r10
adc %r13, 16(rp)
.byte 0xc4,0x22,0x93,0xf6,0x64,0xf6,0x08 C mulx 8(up,un,8), %r13, %r12
adc %rbx, 24(rp)
adc $0, %rax
mov %rax, 32(rp)
.byte 0xc4,0xa2,0xe3,0xf6,0x44,0xf6,0x10 C mulx 16(up,un,8), %rbx, %rax
lea 3(un), n
add $8, rp
add %r10, %r13
.byte 0xc4,0x62,0xb3,0xf6,0x04,0xce C mulx (up,n,8), %r9, %r8
adc %r12, %rbx
adc $0, %rax
add %r11, 8(rp,n,8)
jmp L(lo3)
ALIGN(16)
L(tp3): add %r9, (rp,n,8)
.byte 0xc4,0x62,0xb3,0xf6,0x04,0xce C mulx (up,n,8), %r9, %r8
adc %r11, 8(rp,n,8)
L(lo3): .byte 0xc4,0x62,0xa3,0xf6,0x54,0xce,0x08 C mulx 8(up,n,8), %r11, %r10
adc %r13, 16(rp,n,8)
.byte 0xc4,0x62,0x93,0xf6,0x64,0xce,0x10 C mulx 16(up,n,8), %r13, %r12
adc %rbx, 24(rp,n,8)
adc %rax, %r9
.byte 0xc4,0xe2,0xe3,0xf6,0x44,0xce,0x18 C mulx 24(up,n,8), %rbx, %rax
adc %r8, %r11
adc %r10, %r13
adc %r12, %rbx
adc $0, %rax
add $4, n
jnz L(tp3)
dec vn
jne L(oloop3)
L(final_wind_down):
add %r9, (rp)
adc %r11, 8(rp)
adc %r13, 16(rp)
adc %rbx, 24(rp)
adc $0, %rax
mov %rax, 32(rp)
L(end): pop %rbx
pop %rbp
pop %r12
pop %r13
pop %r14
pop %r15
FUNC_EXIT()
ret
L(3): mov (vp), %rdx
add $8, vp
add $8, rp
.byte 0xc4,0x22,0xa3,0xf6,0x14,0xf6 C mulx (up,un,8), %r11, %r10
.byte 0xc4,0x22,0x93,0xf6,0x64,0xf6,0x08 C mulx 8(up,un,8), %r13, %r12
.byte 0xc4,0xa2,0xe3,0xf6,0x44,0xf6,0x10 C mulx 16(up,un,8), %rbx, %rax
add %r10, %r13
adc %r12, %rbx
adc $0, %rax
L(wd3): adc %r11, 8(rp)
adc %r13, 16(rp)
adc %rbx, 24(rp)
adc $0, %rax
mov %rax, 32(rp)
dec vn
jne L(3)
jmp L(end)
EPILOGUE()
|
Underground_Coll:: INCBIN "gfx/tilesets/underground.tilecoll"
Overworld_Coll:: INCBIN "gfx/tilesets/overworld.tilecoll"
RedsHouse1_Coll::
RedsHouse2_Coll:: INCBIN "gfx/tilesets/reds_house.tilecoll"
Mart_Coll::
Pokecenter_Coll:: INCBIN "gfx/tilesets/pokecenter.tilecoll"
Dojo_Coll::
Gym_Coll:: INCBIN "gfx/tilesets/gym.tilecoll"
Forest_Coll:: INCBIN "gfx/tilesets/forest.tilecoll"
House_Coll:: INCBIN "gfx/tilesets/house.tilecoll"
ForestGate_Coll::
Museum_Coll::
Gate_Coll:: INCBIN "gfx/tilesets/gate.tilecoll"
Ship_Coll:: INCBIN "gfx/tilesets/ship.tilecoll"
ShipPort_Coll:: INCBIN "gfx/tilesets/ship_port.tilecoll"
Cemetery_Coll:: INCBIN "gfx/tilesets/cemetery.tilecoll"
Interior_Coll:: INCBIN "gfx/tilesets/interior.tilecoll"
Cavern_Coll:: INCBIN "gfx/tilesets/cavern.tilecoll"
Lobby_Coll:: INCBIN "gfx/tilesets/lobby.tilecoll"
Mansion_Coll:: INCBIN "gfx/tilesets/mansion.tilecoll"
Lab_Coll:: INCBIN "gfx/tilesets/lab.tilecoll"
Club_Coll:: INCBIN "gfx/tilesets/club.tilecoll"
Facility_Coll:: INCBIN "gfx/tilesets/facility.tilecoll"
Plateau_Coll:: INCBIN "gfx/tilesets/plateau.tilecoll"
BeachHouse_Coll:: INCBIN "gfx/tilesets/beachhouse.tilecoll"
|
; A030002: (prime(n)-5)(prime(n)-7)(prime(n)-9)/48.
; 0,0,1,4,20,35,84,220,286,560,816,969,1330,2024,2925,3276,4495,5456,5984,7770,9139,11480,15180,17296,18424,20825,22100,24804,35990,39711,45760,47905,59640,62196,70300,79079,85320,95284,105995,109736,129766,134044,142880,147440,176851,209934,221815,227920,240464,260130,266916,302621,325500,349504,374660,383306,410040,428536,437989,487344,562475,585276,596904,620620,708561,748660,818805,833340,862924,908600,971970,1021384,1072445,1107414,1161280,1235780,1274196,1353400,1456935,1478256,1587986,1610564,1679580,1726669,1798940,1898400,1949476,1975354,2027795,2190670,2303960,2362041,2481115,2542124,2635500,2829056,2862209,3172316,3280455,3466100
add $0,1
seq $0,98090 ; Numbers k such that 2k-3 is prime.
sub $0,4
bin $0,3
|
; A176916: 5^n + 5n + 1.
; 2,11,36,141,646,3151,15656,78161,390666,1953171,9765676,48828181,244140686,1220703191,6103515696,30517578201,152587890706,762939453211,3814697265716,19073486328221,95367431640726,476837158203231
mov $1,5
pow $1,$0
mov $2,$0
mul $2,5
add $1,$2
add $1,1
mov $0,$1
|
; SPIR-V
; Version: 1.0
; Generator: Khronos Glslang Reference Front End; 10
; Bound: 89
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %4 "main" %30 %76
OpExecutionMode %4 OriginUpperLeft
OpSource ESSL 320
OpName %4 "main"
OpName %7 "buf2"
OpMemberName %7 0 "one"
OpName %9 ""
OpName %18 "buf0"
OpMemberName %18 0 "_GLF_uniform_float_values"
OpName %20 ""
OpName %30 "gl_FragCoord"
OpName %49 "buf1"
OpMemberName %49 0 "_GLF_uniform_int_values"
OpName %51 ""
OpName %76 "_GLF_color"
OpMemberDecorate %7 0 Offset 0
OpDecorate %7 Block
OpDecorate %9 DescriptorSet 0
OpDecorate %9 Binding 2
OpDecorate %17 ArrayStride 16
OpMemberDecorate %18 0 Offset 0
OpDecorate %18 Block
OpDecorate %20 DescriptorSet 0
OpDecorate %20 Binding 0
OpDecorate %30 BuiltIn FragCoord
OpDecorate %48 ArrayStride 16
OpMemberDecorate %49 0 Offset 0
OpDecorate %49 Block
OpDecorate %51 DescriptorSet 0
OpDecorate %51 Binding 1
OpDecorate %76 Location 0
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%6 = OpTypeFloat 32
%7 = OpTypeStruct %6
%8 = OpTypePointer Uniform %7
%9 = OpVariable %8 Uniform
%10 = OpTypeInt 32 1
%11 = OpConstant %10 0
%12 = OpTypePointer Uniform %6
%15 = OpTypeInt 32 0
%16 = OpConstant %15 1
%17 = OpTypeArray %6 %16
%18 = OpTypeStruct %17
%19 = OpTypePointer Uniform %18
%20 = OpVariable %19 Uniform
%23 = OpTypeBool
%28 = OpTypeVector %6 4
%29 = OpTypePointer Input %28
%30 = OpVariable %29 Input
%31 = OpConstant %15 0
%32 = OpTypePointer Input %6
%35 = OpConstant %6 0
%47 = OpConstant %15 2
%48 = OpTypeArray %10 %47
%49 = OpTypeStruct %48
%50 = OpTypePointer Uniform %49
%51 = OpVariable %50 Uniform
%52 = OpConstant %10 1
%53 = OpTypePointer Uniform %10
%75 = OpTypePointer Output %28
%76 = OpVariable %75 Output
%77 = OpConstant %6 1
%78 = OpConstantComposite %28 %77 %35 %35 %77
%81 = OpConstantFalse %23
%84 = OpConstantTrue %23
%4 = OpFunction %2 None %3
%5 = OpLabel
OpSelectionMerge %79 None
OpSwitch %31 %80
%80 = OpLabel
%13 = OpAccessChain %12 %9 %11
%14 = OpLoad %6 %13
%21 = OpAccessChain %12 %20 %11 %11
%22 = OpLoad %6 %21
%24 = OpFOrdGreaterThan %23 %14 %22
OpSelectionMerge %26 None
OpBranchConditional %24 %25 %26
%25 = OpLabel
OpBranch %79
%26 = OpLabel
%33 = OpAccessChain %32 %30 %31
%34 = OpLoad %6 %33
%36 = OpFOrdLessThan %23 %34 %35
OpSelectionMerge %38 None
OpBranchConditional %36 %37 %38
%37 = OpLabel
OpSelectionMerge %43 None
OpBranchConditional %36 %42 %43
%42 = OpLabel
OpBranch %79
%43 = OpLabel
%54 = OpAccessChain %53 %51 %11 %52
%55 = OpLoad %10 %54
OpBranch %56
%56 = OpLabel
%87 = OpPhi %10 %55 %43 %74 %59
%62 = OpAccessChain %53 %51 %11 %11
%63 = OpLoad %10 %62
%64 = OpSLessThan %23 %87 %63
OpLoopMerge %58 %59 None
OpBranchConditional %64 %57 %58
%57 = OpLabel
%69 = OpFOrdLessThan %23 %34 %22
OpSelectionMerge %71 None
OpBranchConditional %69 %70 %71
%70 = OpLabel
OpBranch %58
%71 = OpLabel
OpBranch %59
%59 = OpLabel
%74 = OpIAdd %10 %87 %52
OpBranch %56
%58 = OpLabel
%88 = OpPhi %23 %81 %56 %84 %70
OpSelectionMerge %85 None
OpBranchConditional %88 %79 %85
%85 = OpLabel
OpBranch %38
%38 = OpLabel
OpStore %76 %78
OpBranch %79
%79 = OpLabel
OpReturn
OpFunctionEnd
|
iny
tya |
/*
* Copyright (c) 2013-2014 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
* not be construed as granting a license to any other intellectual
* property including but not limited to intellectual property relating
* to a hardware implementation of the functionality of the software
* licensed hereunder. You may use the software subject to the license
* terms below provided that you ensure that this notice is replicated
* unmodified and in its entirety in all distributions of the software,
* modified or unmodified, in source code or in binary form.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met: redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer;
* redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution;
* neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Andrew Bardsley
*/
/**
* @file
*
* Fetch1 is responsible for fetching "lines" from memory and passing
* them to Fetch2
*/
#ifndef __CPU_MINOR_FETCH1_HH__
#define __CPU_MINOR_FETCH1_HH__
#include "cpu/minor/buffers.hh"
#include "cpu/minor/cpu.hh"
#include "cpu/minor/pipe_data.hh"
#include "cpu/base.hh"
#include "mem/packet.hh"
// JONGHO
#include "base/softerror.hh"
namespace Minor
{
/** A stage responsible for fetching "lines" from memory and passing
* them to Fetch2 */
class Fetch1 : public Named
{
// JONGHO
public:
bool injReady() { return injRegistered && (!injDone) && curTick() >= injTime; }
void registerInj(unsigned int time, unsigned int loc, SoftError::InjComp comp)
{
injRegistered = true;
injTime = time;
injLoc = loc % 32;
injComp = comp;
}
bool injRegistered = false;
bool injDone = false;
bool injReallyDone = false;
unsigned int injTime;
unsigned int injLoc;
SoftError::InjComp injComp;
protected:
/** Exposable fetch port */
class IcachePort : public MinorCPU::MinorCPUPort
{
protected:
/** My owner */
Fetch1 &fetch;
public:
IcachePort(std::string name, Fetch1 &fetch_, MinorCPU &cpu) :
MinorCPU::MinorCPUPort(name, cpu), fetch(fetch_)
{ }
protected:
bool recvTimingResp(PacketPtr pkt)
{ return fetch.recvTimingResp(pkt); }
void recvReqRetry() { fetch.recvReqRetry(); }
};
/** Memory access queuing.
*
* A request can be submitted by pushing it onto the requests queue after
* issuing an ITLB lookup (state becomes InTranslation) with a
* FetchSenderState senderState containing the current lineSeqNum and
* stream/predictionSeqNum.
*
* Translated packets (state becomes Translation) are then passed to the
* memory system and the transfers queue (state becomes RequestIssuing).
* Retries are handled by leaving the packet on the requests queue and
* changing the state to IcacheNeedsRetry).
*
* Responses from the memory system alter the request object (state
* become Complete). Responses can be picked up from the head of the
* transfers queue to pass on to Fetch2. */
/** Structure to hold SenderState info through
* translation and memory accesses. */
class FetchRequest :
public BaseTLB::Translation, /* For TLB lookups */
public Packet::SenderState /* For packing into a Packet */
{
protected:
/** Owning fetch unit */
Fetch1 &fetch;
public:
/** Progress of this request through address translation and
* memory */
enum FetchRequestState
{
NotIssued, /* Just been made */
InTranslation, /* Issued to ITLB, must wait for reqply */
Translated, /* Translation complete */
RequestIssuing, /* Issued to memory, must wait for response */
Complete /* Complete. Either a fault, or a fetched line */
};
FetchRequestState state;
/** Identity of the line that this request will generate */
InstId id;
/** FetchRequests carry packets while they're in the requests and
* transfers responses queues. When a Packet returns from the memory
* system, its request needs to have its packet updated as this may
* have changed in flight */
PacketPtr packet;
/** The underlying request that this fetch represents */
Request request;
/** PC to fixup with line address */
TheISA::PCState pc;
/** Fill in a fault if one happens during fetch, check this by
* picking apart the response packet */
Fault fault;
/** Make a packet to use with the memory transaction */
void makePacket();
/** Report interface */
void reportData(std::ostream &os) const;
/** Is this line out of date with the current stream/prediction
* sequence and can it be discarded without orphaning in flight
* TLB lookups/memory accesses? */
bool isDiscardable() const;
/** Is this a complete read line or fault */
bool isComplete() const { return state == Complete; }
protected:
/** BaseTLB::Translation interface */
/** Interface for ITLB responses. We can handle delay, so don't
* do anything */
void markDelayed() { }
/** Interface for ITLB responses. Populates self and then passes
* the request on to the ports' handleTLBResponse member
* function */
void finish(const Fault &fault_, RequestPtr request_,
ThreadContext *tc, BaseTLB::Mode mode);
public:
FetchRequest(Fetch1 &fetch_, InstId id_, TheISA::PCState pc_) :
SenderState(),
fetch(fetch_),
state(NotIssued),
id(id_),
packet(NULL),
request(),
pc(pc_),
fault(NoFault)
{ }
~FetchRequest();
};
typedef FetchRequest *FetchRequestPtr;
protected:
/** Construction-assigned data members */
/** Pointer back to the containing CPU */
MinorCPU &cpu;
/** Input port carrying branch requests from Execute */
Latch<BranchData>::Output inp;
/** Output port carrying read lines to Fetch2 */
Latch<ForwardLineData>::Input out;
/** Input port carrying branch predictions from Fetch2 */
Latch<BranchData>::Output prediction;
/** Interface to reserve space in the next stage */
std::vector<InputBuffer<ForwardLineData>> &nextStageReserve;
/** IcachePort to pass to the CPU. Fetch1 is the only module that uses
* it. */
IcachePort icachePort;
/** Line snap size in bytes. All fetches clip to make their ends not
* extend beyond this limit. Setting this to the machine L1 cache line
* length will result in fetches never crossing line boundaries. */
unsigned int lineSnap;
/** Maximum fetch width in bytes. Setting this (and lineSnap) to the
* machine L1 cache line length will result in fetches of whole cache
* lines. Setting this to sizeof(MachInst) will result it fetches of
* single instructions (except near the end of lineSnap lines) */
unsigned int maxLineWidth;
/** Maximum number of fetches allowed in flight (in queues or memory) */
unsigned int fetchLimit;
protected:
/** Cycle-by-cycle state */
/** State of memory access for head instruction fetch */
enum FetchState
{
FetchHalted, /* Not fetching, waiting to be woken by transition
to FetchWaitingForPC. The PC is not valid in this state */
FetchWaitingForPC, /* Not fetching, waiting for stream change.
This doesn't stop issued fetches from being returned and
processed or for branches to change the state to Running. */
FetchRunning /* Try to fetch, when possible */
};
/** Stage cycle-by-cycle state */
struct Fetch1ThreadInfo {
/** Consturctor to initialize all fields. */
Fetch1ThreadInfo() :
state(FetchWaitingForPC),
pc(TheISA::PCState(0)),
streamSeqNum(InstId::firstStreamSeqNum),
predictionSeqNum(InstId::firstPredictionSeqNum),
blocked(false),
wakeupGuard(false)
{ }
Fetch1ThreadInfo(const Fetch1ThreadInfo& other) :
state(other.state),
pc(other.pc),
streamSeqNum(other.streamSeqNum),
predictionSeqNum(other.predictionSeqNum),
blocked(other.blocked)
{ }
FetchState state;
/** Fetch PC value. This is updated by branches from Execute, branch
* prediction targets from Fetch2 and by incrementing it as we fetch
* lines subsequent to those two sources. */
TheISA::PCState pc;
/** Stream sequence number. This changes on request from Execute and is
* used to tag instructions by the fetch stream to which they belong.
* Execute originates new prediction sequence numbers. */
InstSeqNum streamSeqNum;
/** Prediction sequence number. This changes when requests from Execute
* or Fetch2 ask for a change of fetch address and is used to tag lines
* by the prediction to which they belong. Fetch2 originates
* prediction sequence numbers. */
InstSeqNum predictionSeqNum;
/** Blocked indication for report */
bool blocked;
/** Signal to guard against sleeping first cycle of wakeup */
bool wakeupGuard;
};
std::vector<Fetch1ThreadInfo> fetchInfo;
ThreadID threadPriority;
/** State of memory access for head instruction fetch */
enum IcacheState
{
IcacheRunning, /* Default. Step icache queues when possible */
IcacheNeedsRetry /* Request rejected, will be asked to retry */
};
typedef Queue<FetchRequestPtr,
ReportTraitsPtrAdaptor<FetchRequestPtr>,
NoBubbleTraits<FetchRequestPtr> >
FetchQueue;
/** Queue of address translated requests from Fetch1 */
FetchQueue requests;
/** Queue of in-memory system requests and responses */
FetchQueue transfers;
/** Retry state of icache_port */
IcacheState icacheState;
/** Sequence number for line fetch used for ordering lines to flush */
InstSeqNum lineSeqNum;
/** Count of the number fetches which have left the transfers queue
* and are in the 'wild' in the memory system. Try not to rely on
* this value, it's better to code without knowledge of the number
* of outstanding accesses */
unsigned int numFetchesInMemorySystem;
/** Number of requests inside the ITLB rather than in the queues.
* All requests so located *must* have reserved space in the
* transfers queue */
unsigned int numFetchesInITLB;
protected:
friend std::ostream &operator <<(std::ostream &os,
Fetch1::FetchState state);
/** Start fetching from a new address. */
void changeStream(const BranchData &branch);
/** Update streamSeqNum and predictionSeqNum from the given branch (and
* assume these have changed and discard (on delivery) all lines in
* flight) */
void updateExpectedSeqNums(const BranchData &branch);
/** Convert a response to a ForwardLineData */
void processResponse(FetchRequestPtr response,
ForwardLineData &line);
friend std::ostream &operator <<(std::ostream &os,
IcacheState state);
/** Use the current threading policy to determine the next thread to
* fetch from. */
ThreadID getScheduledThread();
/** Insert a line fetch into the requests. This can be a partial
* line request where the given address has a non-0 offset into a
* line. */
void fetchLine(ThreadID tid);
/** Try and issue a fetch for a translated request at the
* head of the requests queue. Also tries to move the request
* between queues */
void tryToSendToTransfers(FetchRequestPtr request);
/** Try to send (or resend) a memory request's next/only packet to
* the memory system. Returns true if the fetch was successfully
* sent to memory */
bool tryToSend(FetchRequestPtr request);
/** Move a request between queues */
void moveFromRequestsToTransfers(FetchRequestPtr request);
/** Step requests along between requests and transfers queues */
void stepQueues();
/** Pop a request from the given queue and correctly deallocate and
* discard it. */
void popAndDiscard(FetchQueue &queue);
/** Handle pushing a TLB response onto the right queue */
void handleTLBResponse(FetchRequestPtr response);
/** Returns the total number of queue occupancy, in-ITLB and
* in-memory system fetches */
unsigned int numInFlightFetches();
/** Print the appropriate MinorLine line for a fetch response */
void minorTraceResponseLine(const std::string &name,
FetchRequestPtr response) const;
/** Memory interface */
virtual bool recvTimingResp(PacketPtr pkt);
virtual void recvReqRetry();
public:
Fetch1(const std::string &name_,
MinorCPU &cpu_,
MinorCPUParams ¶ms,
Latch<BranchData>::Output inp_,
Latch<ForwardLineData>::Input out_,
Latch<BranchData>::Output prediction_,
std::vector<InputBuffer<ForwardLineData>> &next_stage_input_buffer);
public:
/** Returns the IcachePort owned by this Fetch1 */
MinorCPU::MinorCPUPort &getIcachePort() { return icachePort; }
/** Pass on input/buffer data to the output if you can */
void evaluate();
/** Initiate fetch1 fetching */
void wakeupFetch(ThreadID tid);
void minorTrace() const;
/** Is this stage drained? For Fetch1, draining is initiated by
* Execute signalling a branch with the reason HaltFetch */
bool isDrained();
};
}
#endif /* __CPU_MINOR_FETCH1_HH__ */
|
; A055789: a(n) = binomial(n, round(sqrt(n))).
; 1,1,2,3,6,10,15,35,56,84,120,165,220,715,1001,1365,1820,2380,3060,3876,4845,20349,26334,33649,42504,53130,65780,80730,98280,118755,142506,736281,906192,1107568,1344904,1623160,1947792,2324784,2760681,3262623,3838380,4496388,5245786,32224114,38320568,45379620,53524680,62891499,73629072,85900584,99884400,115775100,133784560,154143080,177100560,202927725,231917400,1652411475,1916797311,2217471399,2558620845,2944827765,3381098545,3872894697,4426165368,5047381560,5743572120,6522361560,7392009768
mov $1,$0
seq $1,194 ; n appears 2n times, for n >= 1; also nearest integer to square root of n.
bin $0,$1
|
/*
*********************************************************************************************************
* uC/OS-III
* The Real-Time Kernel
*
* Copyright 2009-2020 Silicon Laboratories Inc. www.silabs.com
*
* SPDX-License-Identifier: APACHE-2.0
*
* This software is subject to an open source license and is distributed by
* Silicon Laboratories Inc. pursuant to the terms of the Apache License,
* Version 2.0 available at www.apache.org/licenses/LICENSE-2.0.
*
*********************************************************************************************************
*/
/*
*********************************************************************************************************
*
* uCOS-III port for Analog Device's Blackfin 533
*
* Visual DSP++ 5.0
*
* This port was made with a large contribution of Analog Devices Inc
* development team
*
* File : os_cpu_a.asm
* Version : V3.08.00
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* INCLUDE FILES
*********************************************************************************************************
*/
#include <os_cfg.h>
#include <os_cpu.h>
/*
*********************************************************************************************************
* LOCAL MACROS
*********************************************************************************************************
*/
#define UPPER_( x ) (((x) >> 16) & 0x0000FFFF)
#define LOWER_( x ) ((x) & 0x0000FFFF)
#define LOAD(x, y) x##.h = UPPER_(y); x##.l = LOWER_(y)
#define LOADA(x, y) x##.h = y; x##.l = y
/*
*********************************************************************************************************
* PUBLIC FUNCTIONS
*********************************************************************************************************
*/
.global _OS_CPU_EnableIntEntry;
.global _OS_CPU_DisableIntEntry;
.global _OS_CPU_NESTING_ISR;
.global _OS_CPU_NON_NESTING_ISR;
.global _OS_CPU_ISR_Entry;
.global _OS_CPU_ISR_Exit;
.global _OSStartHighRdy;
.global _OSCtxSw;
.global _OSIntCtxSw;
.global _OS_CPU_Invalid_Task_Return;
/*
*********************************************************************************************************
* Blackfin C Run-Time stack/frame Macros
*********************************************************************************************************
*/
#define INIT_C_RUNTIME_STACK(frame_size) \
LINK frame_size; \
SP += -12; /* make space for outgoing arguments */
/* when calling C-functions */
#define DEL_C_RUNTIME_STACK() \
UNLINK;
/*
*********************************************************************************************************
* WORKAROUND for Anomaly 05-00-0283 Macro
*********************************************************************************************************
*/
#define WORKAROUND_05000283() \
CC = R0 == R0; /* always true */ \
P0.L = 0x14; /* MMR space - CHIPID */ \
P0.H = 0xffc0; \
IF CC JUMP 4; \
R0 = [ P0 ]; /* bogus MMR read that is speculatively */
/* read and killed - never executed */
/*
*********************************************************************************************************
* EXTERNAL FUNCTIONS
*********************************************************************************************************
*/
.extern _OS_CPU_IntHandler;
.extern _OSTaskSwHook;
.extern _OSIntEnter;
.extern _OSIntExit;
/*
*********************************************************************************************************
* EXTERNAL VARIABLES
*********************************************************************************************************
*/
.extern _OSIntNestingCtr;
.extern _OSPrioCur;
.extern _OSPrioHighRdy;
.extern _OSRunning;
.extern _OSTCBCurPtr;
.extern _OSTCBHighRdyPtr;
.section program;
/*
*********************************************************************************************************
* OS_CPU_EnableIntEntry();
*
* Description : Enables an interrupt entry. Interrupt vector to enable is represented by the argument
* passed to this function.
*
*
*
* Arguments : Interrupt vector number (0 to 15) passed into R0 register
*
* Returns : None
*
* Note(s) : None
*********************************************************************************************************
*/
_OS_CPU_EnableIntEntry:
R1 = 1;
R1 <<= R0;
CLI R0;
R1 = R1 | R0;
STI R1;
_OS_CPU_EnableIntEntry.end:
RTS;
/*
*********************************************************************************************************
* OS_CPU_DisableIntEntry();
*
* Description : Disables an interrupt entry. Interrupt vector to disable is represented by the argument
* passed to this function.
*
*
*
* Arguments : Interrupt vector number (0 to 15) passed into R0 register
*
* Returns : None
*
* Note(s) : None
*********************************************************************************************************
*/
_OS_CPU_DisableIntEntry:
R1 = 1;
R1 <<= R0;
R1 = ~R1;
CLI R0;
R1 = R1 & R0;
STI R1;
_OS_CPU_DisableIntEntry.end:
RTS;
/*
*********************************************************************************************************
* NESTING INTERRUPTS HANDLER
* OS_CPU_NESTING_ISR();
*
* Description : This routine is intented to the target of the interrupt processing functionality with
* nesting support.
*
* It saves the current Task context (see _OS_CPU_ISR_Entry),
* and calls the application interrupt handler OS_CPU_IntHandler (see os_cpu_c.c)
*
*
* Arguments : None
*
* Returns : None
*
* Note(s) : None
*********************************************************************************************************
*/
_OS_CPU_NESTING_ISR:
[ -- SP ] = R0;
[ -- SP ] = P1;
[ -- SP ] = RETS;
R0 = NESTED; /* To indicate that this ISR supports nesting */
CALL.X _OS_CPU_ISR_Entry;
WORKAROUND_05000283()
INIT_C_RUNTIME_STACK(0x0)
CALL.X _OS_CPU_IntHandler; /* See os_cpu_c.c */
SP += -4; /* Disable interrupts by this artificial pop */
RETI = [ SP++ ]; /* of RETI register. Restore context need to */
CALL.X _OSIntExit; /* be done while interrupts are disabled */
DEL_C_RUNTIME_STACK()
JUMP.X _OS_CPU_ISR_Exit;
_OS_CPU_NESTING_ISR.end:
NOP;
/*
*********************************************************************************************************
* NON NESTING INTERRUPTS HANDLER
* OS_CPU_NON_NESTING_ISR();
*
* Description : This routine is intented to the target of the interrupt processing functionality without
* nesting support.
*
* It saves the current Task context (see _OS_CPU_ISR_Entry),
* and calls the application interrupt handler OS_CPU_IntHandler (see os_cpu_c.c)
*
*
* Arguments : None
*
* Returns : None
*
* Note(s) : None
*********************************************************************************************************
*/
_OS_CPU_NON_NESTING_ISR:
[ -- SP ] = R0;
[ -- SP ] = P1;
[ -- SP ] = RETS;
R0 = NOT_NESTED; /* This ISR doesn't support nesting */
CALL.X _OS_CPU_ISR_Entry;
WORKAROUND_05000283()
INIT_C_RUNTIME_STACK(0x0)
CALL.X _OS_CPU_IntHandler; /* See os_cpu_c.c */
CALL.X _OSIntExit;
DEL_C_RUNTIME_STACK()
JUMP.X _OS_CPU_ISR_Exit;
_OS_CPU_NON_NESTING_ISR.end:
NOP;
/*
*********************************************************************************************************
* OS_CPU_ISR_Entry()
*
* Description : This routine serves as the interrupt entry function for ISRs.
*
*
* __OS_CPU_ISR_Entry consists of
*
* 1.'uCOS Interrupt Entry management' - incremements OSIntNesting and saves SP in the TCB if
* OSIntNesting == 1.
* 2.'CPU context save' - After OSIntNesting is incremented, it is safe to re-enable interrupts.
* Then the rest of the processor's context is saved.
*
* Refer to VisualDSP++ C/C++ Compiler and Library Manual for Blackfin Processors
* and ADSP-BF53x/BF56x Blackfin� Processor Programming Reference Manual.
*
* The convention for the task frame (after context save is complete) is as follows:
* (stack represented from high to low memory as per convention)
* (*** High memory ***) R0
* P1
* RETS (function return address of thread)
* R1
* R2
* P0
* P2
* ASTAT
* RETI (interrupt return address: $PC of thread)
* R7:3 (R7 is lower than R3)
* P5:3 (P5 is lower than P3)
* FP (frame pointer)
* I3:0 (I3 is lower than I0)
* B3:0 (B3 is lower than B0)
* L3:0 (L3 is lower than L0)
* M3:0 (M3 is lower than M0)
* A0.x
* A0.w
* A1.x
* A1.w
* LC1:0 (LC1 is lower than LC0)
* LT1:0 (LT1 is lower than LT0)
* OSTCBHighRdy--> OSTCBStkPtr --> (*** Low memory ***)LB1:0 (LB1 is lower than LB0)
*
* Arguments : RO is set to NESTED or NOT_NESTED constant.
*
* Returns : None
*
* Note(s) : None
*********************************************************************************************************
*/
_OS_CPU_ISR_Entry:
ucos_ii_interrupt_entry_mgmt:
[ -- SP ] = R1;
[ -- SP ] = R2;
[ -- SP ] = P0;
[ -- SP ] = P2;
[ -- SP ] = ASTAT;
LOADA(P0 , _OSRunning);
R2 = B [ P0 ] ( Z );
CC = R2 == 1; /* Is OSRunning set */
IF ! CC JUMP ucos_ii_interrupt_entry_mgmt.end;
LOADA(P0, _OSIntNestingCtr);
R2 = B [ P0 ] ( Z );
R1 = 255 ( X );
CC = R2 < R1; /* Nesting < 255 */
IF ! CC JUMP ucos_ii_interrupt_entry_mgmt.end;
R2 = R2.B (X);
R2 += 1; /* Increment OSIntNesting */
B [ P0 ] = R2;
CC = R2 == 1; /* Save SP if OSIntNesting == 1 */
IF ! CC JUMP ucos_ii_interrupt_entry_mgmt.end;
LOADA(P2, _OSTCBCurPtr);
P0 = [ P2 ];
R2 = SP;
R1 = 144;
R2 = R2 - R1;
[ P0 ] = R2;
ucos_ii_interrupt_entry_mgmt.end:
NOP;
interrupt_cpu_save_context:
CC = R0 == NESTED;
IF !CC JUMP non_reetrant_isr;
reetrant_isr:
[ -- SP ] = RETI; /* If ISR is REENTRANT, then simply push RETI onto stack */
/* IPEND[4] is currently set, globally disabling interrupts */
/* IPEND[4] will be cleared when RETI is pushed onto stack */
JUMP save_remaining_context;
non_reetrant_isr:
R1 = RETI; /* If ISR is NON-REENTRANT, then save RETI through R1 */
[ -- SP ] = R1; /* IPEND[4] is currently set, globally disabling interrupts */
/* IPEND[4] will stay set when RETI is saved through R1 */
save_remaining_context:
[ -- SP ] = (R7:3, P5:3);
[ -- SP ] = FP;
[ -- SP ] = I0;
[ -- SP ] = I1;
[ -- SP ] = I2;
[ -- SP ] = I3;
[ -- SP ] = B0;
[ -- SP ] = B1;
[ -- SP ] = B2;
[ -- SP ] = B3;
[ -- SP ] = L0;
[ -- SP ] = L1;
[ -- SP ] = L2;
[ -- SP ] = L3;
[ -- SP ] = M0;
[ -- SP ] = M1;
[ -- SP ] = M2;
[ -- SP ] = M3;
R1.L = A0.x;
[ -- SP ] = R1;
R1 = A0.w;
[ -- SP ] = R1;
R1.L = A1.x;
[ -- SP ] = R1;
R1 = A1.w;
[ -- SP ] = R1;
[ -- SP ] = LC0;
R3 = 0;
LC0 = R3;
[ -- SP ] = LC1;
R3 = 0;
LC1 = R3;
[ -- SP ] = LT0;
[ -- SP ] = LT1;
[ -- SP ] = LB0;
[ -- SP ] = LB1;
L0 = 0 ( X );
L1 = 0 ( X );
L2 = 0 ( X );
L3 = 0 ( X );
interrupt_cpu_save_context.end:
_OS_CPU_ISR_Entry.end:
RTS;
/*
*********************************************************************************************************
* OS_CPU_ISR_Exit ()
*
*
* Description : ThIS routine serves as the interrupt exit function for all ISRs (whether reentrant
* (nested) or non-reentrant (non-nested)). RETI is populated by a stack pop for both nested
* as well non-nested interrupts.
*
* This is a straigtforward implementation restoring the processor's context as per the
* following task stack frame convention, returns from the interrupt with the RTI instruction.
*
* Refer to VisualDSP++ C/C++ Compiler and Library Manual for Blackfin Processors
* and ADSP-BF53x/BF56x Blackfin� Processor Programming Reference Manual.
*
* The convention for the task frame (after context save is complete) is as follows:
* (stack represented from high to low memory as per convention)
* (*** High memory ***) R0
* P1
* RETS (function return address of thread)
* R1
* R2
* P0
* P2
* ASTAT
* RETI (interrupt return address: $PC of thread)
* R7:3 (R7 is lower than R3)
* P5:3 (P5 is lower than P3)
* FP (frame pointer)
* I3:0 (I3 is lower than I0)
* B3:0 (B3 is lower than B0)
* L3:0 (L3 is lower than L0)
* M3:0 (M3 is lower than M0)
* A0.x
* A0.w
* A1.x
* A1.w
* LC1:0 (LC1 is lower than LC0)
* LT1:0 (LT1 is lower than LT0)
* OSTCBHighRdy--> OSTCBStkPtr --> (*** Low memory ***)LB1:0 (LB1 is lower than LB0)
*
* Arguments : None
*
* Returns : None
*
* Note(s) : None
*********************************************************************************************************
*/
_OS_CPU_ISR_Exit:
interrupt_cpu_restore_context:
LB1 = [ SP ++ ];
LB0 = [ SP ++ ];
LT1 = [ SP ++ ];
LT0 = [ SP ++ ];
LC1 = [ SP ++ ];
LC0 = [ SP ++ ];
R0 = [ SP ++ ];
A1.w = R0;
R0 = [ SP ++ ];
A1.x = R0.L;
R0 = [ SP ++ ];
A0.w = R0;
R0 = [ SP ++ ];
A0.x = R0.L;
M3 = [ SP ++ ];
M2 = [ SP ++ ];
M1 = [ SP ++ ];
M0 = [ SP ++ ];
L3 = [ SP ++ ];
L2 = [ SP ++ ];
L1 = [ SP ++ ];
L0 = [ SP ++ ];
B3 = [ SP ++ ];
B2 = [ SP ++ ];
B1 = [ SP ++ ];
B0 = [ SP ++ ];
I3 = [ SP ++ ];
I2 = [ SP ++ ];
I1 = [ SP ++ ];
I0 = [ SP ++ ];
FP = [ SP ++ ];
(R7:3, P5:3) = [ SP ++ ];
RETI = [ SP ++ ]; /* IPEND[4] will stay set when RETI popped from stack */
ASTAT = [ SP ++ ];
P2 = [ SP ++ ];
P0 = [ SP ++ ];
R2 = [ SP ++ ];
R1 = [ SP ++ ];
RETS = [ SP ++ ];
P1 = [ SP ++ ];
interrupt_cpu_restore_context.end:
R0 = [ SP ++ ];
RTI; /* Reenable interrupts via IPEND[4] bit after RTI executes. */
NOP; /* Return to task */
NOP;
_OS_CPU_ISR_Exit.end:
NOP;
/*
*********************************************************************************************************
* START MULTITASKING
* OSStartHighRdy()
*
* Description: Starts the highest priority task that is available to run.OSStartHighRdy() MUST:
*
* a) Call OSTaskSwHook() then,
* b) Set OSRunning to TRUE,
* c) Switch to the highest priority task.
*
* Refer to VisualDSP++ C/C++ Compiler and Library Manual for Blackfin Processors
* and ADSP-BF53x/BF56x Blackfin� Processor Programming Reference Manual.
*
* The convention for the task frame (after context save is complete) is as follows:
* (stack represented from high to low memory as per convention)
*
* (*** High memory ***) R0
* P1
* RETS (function return address of thread)
* R1
* R2
* P0
* P2
* ASTAT
* RETI (interrupt return address: $PC of thread)
* R7:3 (R7 is lower than R3)
* P5:3 (P5 is lower than P3)
* FP (frame pointer)
* I3:0 (I3 is lower than I0)
* B3:0 (B3 is lower than B0)
* L3:0 (L3 is lower than L0)
* M3:0 (M3 is lower than M0)
* A0.x
* A0.w
* A1.x
* A1.w
* LC1:0 (LC1 is lower than LC0)
* LT1:0 (LT1 is lower than LT0)
* OSTCBHighRdy--> OSTCBStkPtr --> (*** Low memory ***)LB1:0 (LB1 is lower than LB0)
*
* Arguments : None
*
* Returns : None
*
* Note(s) : None
*********************************************************************************************************
*/
_OSStartHighRdy:
LOADA(P1, _OSTCBHighRdyPtr); /* Get the SP for the highest ready task */
P2 = [ P1 ];
SP = [ P2 ];
/* Restore CPU context without popping off RETI */
P1 = 140; /* Skipping over LB1:0, LT1:0, LC1:0, A1:0, M3:0, */
SP = SP + P1; /* L3:0, B3:0, I3:0, FP, P5:3, R7:3 */
RETS = [ SP ++ ]; /* Pop off RETI value into RETS */
SP += 12; /* Skipping over ASAT, P2, P0 */
R1 = 0; /* Zap loop counters to zero, to make sure */
LC0 = R1; LC1 = R1; /* that hw loops are disabled */
L0 = R1; L1 = R1; /* Clear the DAG Length regs too, so that it's safe */
L2 = R1; L3 = R1; /* to use I-regs without them wrapping around. */
R2 = [ SP ++ ]; /* Loading the 3rd argument of the C function - R2 */
R1 = [ SP ++ ]; /* Loading the 2nd argument of the C function - R1 */
SP += 8; /* Skipping over RETS, P1 */
R0 = [ SP ++ ]; /* Loading the 1st argument of the C function - R0 */
/* Return to high ready task */
_OSStartHighRdy.end:
RTS;
/*
*********************************************************************************************************
* O/S CPU Context Switch
* OSCtxSw()
*
* Description : This function is called to switch the context of the current running task
* This function is registered as the IVG14 handler and will be called to handle both
* interrupt and task level context switches.
*
* Refer to VisualDSP++ C/C++ Compiler and Library Manual for Blackfin Processors
* and ADSP-BF53x/BF56x Blackfin� Processor Programming Reference Manual.
*
* The convention for the task frame (after context save is complete) is as follows:
* (stack represented from high to low memory as per convention)
* (*** High memory ***) R0
* P1
* RETS (function return address of thread)
* R1
* R2
* P0
* P2
* ASTAT
* RETI (interrupt return address: $PC of thread)
* R7:3 (R7 is lower than R3)
* P5:3 (P5 is lower than P3)
* FP (frame pointer)
* I3:0 (I3 is lower than I0)
* B3:0 (B3 is lower than B0)
* L3:0 (L3 is lower than L0)
* M3:0 (M3 is lower than M0)
* A0.x
* A0.w
* A1.x
* A1.w
* LC1:0 (LC1 is lower than LC0)
* LT1:0 (LT1 is lower than LT0)
* OSTCBHighRdy--> OSTCBStkPtr --> (*** Low memory ***)LB1:0 (LB1 is lower than LB0)
*
* Arguments : None
*
* Returns : None
*
* Note(s) : None
*********************************************************************************************************
*/
_OSCtxSw:
/* Save context, interrupts disabled by IPEND[4] bit */
[ -- SP ] = R0;
[ -- SP ] = P1;
[ -- SP ] = RETS;
[ -- SP ] = R1;
[ -- SP ] = R2;
[ -- SP ] = P0;
[ -- SP ] = P2;
[ -- SP ] = ASTAT;
R1 = RETI; /* IPEND[4] is currently set, globally disabling interrupts */
/* IPEND[4] will stay set when RETI is saved through R1 */
[ -- SP ] = R1;
[ -- SP ] = (R7:3, P5:3);
[ -- SP ] = FP;
[ -- SP ] = I0;
[ -- SP ] = I1;
[ -- SP ] = I2;
[ -- SP ] = I3;
[ -- SP ] = B0;
[ -- SP ] = B1;
[ -- SP ] = B2;
[ -- SP ] = B3;
[ -- SP ] = L0;
[ -- SP ] = L1;
[ -- SP ] = L2;
[ -- SP ] = L3;
[ -- SP ] = M0;
[ -- SP ] = M1;
[ -- SP ] = M2;
[ -- SP ] = M3;
R1.L = A0.x;
[ -- SP ] = R1;
R1 = A0.w;
[ -- SP ] = R1;
R1.L = A1.x;
[ -- SP ] = R1;
R1 = A1.w;
[ -- SP ] = R1;
[ -- SP ] = LC0;
R3 = 0;
LC0 = R3;
[ -- SP ] = LC1;
R3 = 0;
LC1 = R3;
[ -- SP ] = LT0;
[ -- SP ] = LT1;
[ -- SP ] = LB0;
[ -- SP ] = LB1;
L0 = 0 ( X );
L1 = 0 ( X );
L2 = 0 ( X );
L3 = 0 ( X );
/* Note: OSCtxSw uses call-preserved registers (R4:7, P3:5) */
/* unlike OSIntCtxSw to allow calling _OSTaskSwHook. */
LOADA(P3, _OSPrioHighRdy); /* Get a high ready task priority */
R4 = B[ P3 ](Z);
LOADA(P3, _OSPrioCur); /* Get a current task priority */
R5 = B[ P3 ](Z);
LOADA(P4, _OSTCBCurPtr); /* Get a pointer to the current task's TCB */
P5 = [ P4 ];
[ P5 ] = SP; /* Context save done so save SP in the TCB */
B[ P3 ] = R4; /* OSPrioCur = OSPrioHighRdy */
LOADA(P3, _OSTCBHighRdyPtr); /* Get a pointer to the high ready task's TCB */
P5 = [ P3 ];
[ P4 ] = P5; /* OSTCBCur = OSTCBHighRdy */
_OSCtxSw_modify_SP:
SP = [ P5 ]; /* Make it the current task by switching the stack pointer */
_AbortOSCtxSw:
_CtxSwRestoreCtx:
_OSCtxSw.end:
/* Restoring CPU context and return to task */
LB1 = [ SP ++ ];
LB0 = [ SP ++ ];
LT1 = [ SP ++ ];
LT0 = [ SP ++ ];
LC1 = [ SP ++ ];
LC0 = [ SP ++ ];
R0 = [ SP ++ ];
A1.w = R0;
R0 = [ SP ++ ];
A1.x = R0.L;
R0 = [ SP ++ ];
A0.w = R0;
R0 = [ SP ++ ];
A0.x = R0.L;
M3 = [ SP ++ ];
M2 = [ SP ++ ];
M1 = [ SP ++ ];
M0 = [ SP ++ ];
L3 = [ SP ++ ];
L2 = [ SP ++ ];
L1 = [ SP ++ ];
L0 = [ SP ++ ];
B3 = [ SP ++ ];
B2 = [ SP ++ ];
B1 = [ SP ++ ];
B0 = [ SP ++ ];
I3 = [ SP ++ ];
I2 = [ SP ++ ];
I1 = [ SP ++ ];
I0 = [ SP ++ ];
FP = [ SP ++ ];
(R7:3, P5:3) = [ SP ++ ];
RETI = [ SP ++ ]; /* IPEND[4] will stay set when RETI popped from stack */
ASTAT = [ SP ++ ];
P2 = [ SP ++ ];
P0 = [ SP ++ ];
R2 = [ SP ++ ];
R1 = [ SP ++ ];
RETS = [ SP ++ ];
P1 = [ SP ++ ];
R0 = [ SP ++ ];
RTI; /* Reenable interrupts via IPEND[4] bit after RTI executes. */
/* Return to task */
/*
*********************************************************************************************************
* OSIntCtxSw()
*
* Description : Performs the Context Switch from an ISR.
*
* OSIntCtxSw() must implement the following pseudo-code:
*
* OSTaskSwHook();
* OSPrioCur = OSPrioHighRdy;
* OSTCBCur = OSTCBHighRdy;
* SP = OSTCBHighRdy->OSTCBStkPtr;
*
*
*
* Arguments : None
*
* Returns : None
*
* Note(s) : OSIntCtxSw uses scratch registers (R0:3, P0:2, ASTAT)
* unlike OSCtxSw because it is called from OSIntExit and will
* return back to OSIntExit through an RTS.
*********************************************************************************************************
*/
_OSIntCtxSw:
LOADA(P0, _OSPrioCur); /* Get a current task priority */
LOADA(P1, _OSPrioHighRdy); /* Get a high ready task priority */
R0 = B[ P1 ](Z);
B[ P0 ] = R0; /* OSPrioCur = OSPrioHighRdy */
LOADA(P0, _OSTCBCurPtr); /* Get a pointer to the current task's TCB */
LOADA(P1, _OSTCBHighRdyPtr); /* Get a pointer to the high ready task's TCB */
P2 = [ P1 ];
[ P0 ] = P2; /* OSTCBCur = OSTCBHighRdy */
_OSIntCtxSw_modify_SP:
/* Load stack pointer into P0 from task TCB. Do not modify SP because we return to */
/* OSIntExit, which modifies SP through the the UNLINK instruction. Instead, we */
/* modify the FP of the ISR frame. This essentially 'moves the frame of the ISR */
/* 'above' the frame the of the new task. Thus, when the UNLINK instruction that */
/* unlinks the frame of the ISR, the SP of the new task is loaded. Thus, the new */
/* context is restored. */
R0 = [ P2 ]; /* Get stack pointer to the high ready task */
R0 += -8; /* Subtract 2 stack items for FP, RETS (LINK instruction */
/* pushes FP, RETS onto stack) */
[ FP ] = R0; /* Modify the FP of ISR with the task's SP. */
SP += -4; /* Interrupts are re-enabled when OSIntCtxSw() returns */
RETI = [ SP++ ]; /* to OSIntExit() (where OS_EXIT_CRITICAL() restores */
/* original IMASK value). */
/* However, the context restore process must be */
/* uninterruptible - we accomplish this by an artificial'*/
/* stack pop into the RETI register, thus setting the */
/* global interrupts disable bit (IPEND[4]) */
/* Before the stack pop, adjust the stack pointer. */
_OSIntCtxSw.end:
RTS;
/*
*********************************************************************************************************
* _OS_Invalid_Task_Return ()
*
* Description : All tasks (threads) within �COS-II are while(1) loops - once done with it's operations,
* task can supsend, delete itself etc. to yield the processor. Under NO circumstances can
* a task return with a RTS. However, in case of a return, the following function serves
* as a placeholder for debugging purposes.
*
* Arguments : None
*
* Returns : None
*
* Note(s) : None
*********************************************************************************************************
*/
_OS_CPU_Invalid_Task_Return:
_OS_CPU_Invalid_Task_Return.end: /* Stay here */
JUMP 0;
|
; ===============================================================
; Apr 2014
; ===============================================================
;
; void heap_info(void *heap, void *callback)
;
; Visit each block in the heap and pass information about
; the block to the callback function.
;
; ===============================================================
INCLUDE "config_private.inc"
SECTION code_clib
SECTION code_alloc_malloc
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IF __CLIB_OPT_MULTITHREAD & $01
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC asm_heap_info
EXTERN asm_heap_info_unlocked
EXTERN __heap_lock_acquire, __heap_lock_release_0, error_enolck_zc
asm_heap_info:
; enter : ix = void *callback
; de = void *heap
;
; exit : none
;
; uses : af, bc, de, hl + callback
call __heap_lock_acquire
jp c, error_enolck_zc
push de ; save void *heap
call asm_heap_info_unlocked
jp __heap_lock_release_0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ELSE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
PUBLIC asm_heap_info
EXTERN asm_heap_info_unlocked
defc asm_heap_info = asm_heap_info_unlocked
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ENDIF
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;
;; Copyright (c) 2020, Intel Corporation
;;
;; Redistribution and use in source and binary forms, with or without
;; modification, are permitted provided that the following conditions are met:
;;
;; * Redistributions of source code must retain the above copyright notice,
;; this list of conditions and the following disclaimer.
;; * Redistributions in binary form must reproduce the above copyright
;; notice, this list of conditions and the following disclaimer in the
;; documentation and/or other materials provided with the distribution.
;; * Neither the name of Intel Corporation nor the names of its contributors
;; may be used to endorse or promote products derived from this software
;; without specific prior written permission.
;;
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
;; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
;; SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
;; CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;; OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
;;
%include "include/os.asm"
%include "include/imb_job.asm"
%include "include/mb_mgr_datastruct.asm"
%include "include/cet.inc"
%include "include/reg_sizes.asm"
%include "include/const.inc"
%define NUM_LANES 8
%ifndef AES_CBCS_ENC_X8
%define AES_CBCS_ENC_X8 aes_cbcs_1_9_enc_128_x8
%define SUBMIT_JOB_AES_CBCS_ENC submit_job_aes128_cbcs_1_9_enc_avx
%endif
; void aes_cbcs_1_9_enc_128_x8(AES_ARGS *args, UINT64 len_in_bytes);
extern AES_CBCS_ENC_X8
section .text
%ifdef LINUX
%define arg1 rdi
%define arg2 rsi
%else
%define arg1 rcx
%define arg2 rdx
%endif
%define state arg1
%define job arg2
%define len2 arg2
%define job_rax rax
; idx needs to be in rbp
%define len rbp
%define idx rbp
%define tmp rbp
%define lane r8
%define tmp2 r8
%define iv r9
%define tmp3 r9
%define unused_lanes rbx
; STACK_SPACE needs to be an odd multiple of 8
; This routine and its callee clobbers all GPRs
struc STACK
_gpr_save: resq 8
_rsp_save: resq 1
endstruc
; JOB* submit_job_aes128_cbcs_1_9_enc_avx(MB_MGR_AES_OOO *state, IMB_JOB *job)
; arg 1 : state
; arg 2 : job
MKGLOBAL(SUBMIT_JOB_AES_CBCS_ENC,function,internal)
SUBMIT_JOB_AES_CBCS_ENC:
endbranch64
mov rax, rsp
sub rsp, STACK_size
and rsp, -16
mov [rsp + _gpr_save + 8*0], rbx
mov [rsp + _gpr_save + 8*1], rbp
mov [rsp + _gpr_save + 8*2], r12
mov [rsp + _gpr_save + 8*3], r13
mov [rsp + _gpr_save + 8*4], r14
mov [rsp + _gpr_save + 8*5], r15
%ifndef LINUX
mov [rsp + _gpr_save + 8*6], rsi
mov [rsp + _gpr_save + 8*7], rdi
%endif
mov [rsp + _rsp_save], rax ; original SP
mov unused_lanes, [state + _aes_unused_lanes]
mov lane, unused_lanes
and lane, 0xF
shr unused_lanes, 4
mov len, [job + _msg_len_to_cipher_in_bytes]
and len, -16 ; Buffer might not be aligned to block size
mov iv, [job + _iv]
mov [state + _aes_unused_lanes], unused_lanes
mov [state + _aes_job_in_lane + lane*8], job
mov [state + _aes_lens_64 + lane*8], len
mov tmp, [job + _src]
add tmp, [job + _cipher_start_src_offset_in_bytes]
vmovdqu xmm0, [iv]
mov [state + _aes_args_in + lane*8], tmp
mov tmp, [job + _enc_keys]
mov [state + _aes_args_keys + lane*8], tmp
mov tmp, [job + _dst]
mov [state + _aes_args_out + lane*8], tmp
shl lane, 4 ; multiply by 16
vmovdqa [state + _aes_args_IV + lane], xmm0
cmp unused_lanes, 0xf
jne return_null
; Find min length
mov len2, [state + _aes_lens_64 + 8*0]
xor idx, idx
mov tmp2, 1
%assign I 1
%rep 7
cmp len2, [state + _aes_lens_64 + 8*I]
cmova len2, [state + _aes_lens_64 + 8*I]
cmova idx, tmp2
%if I != 7
inc tmp2
%endif
%assign I (I+1)
%endrep
or len2, len2
jz len_is_0
; Round up to multiple of 16*10
; N = (length + 159) / 160 --> Number of 160-byte blocks
mov rax, len2
xor rdx, rdx ;; zero rdx for div
add rax, 159
mov tmp2, 160
div tmp2
; Number of 160-byte blocks in rax
mov tmp2, 160
mul tmp2
; Number of bytes to process in rax
mov len2, rax
xor tmp2, tmp2
%assign I 0
%rep NUM_LANES
mov tmp3, [state + _aes_lens_64 + 8*I]
sub tmp3, len2
cmovs tmp3, tmp2 ; 0 if negative number
mov [state + _aes_lens_64 + 8*I], tmp3
%assign I (I+1)
%endrep
; "state" and "args" are the same address, arg1
; len is arg2
call AES_CBCS_ENC_X8
; state and idx are intact
len_is_0:
; process completed job "idx"
mov job_rax, [state + _aes_job_in_lane + idx*8]
mov unused_lanes, [state + _aes_unused_lanes]
mov qword [state + _aes_job_in_lane + idx*8], 0
or dword [job_rax + _status], IMB_STATUS_COMPLETED_CIPHER
shl unused_lanes, 4
or unused_lanes, idx
mov [state + _aes_unused_lanes], unused_lanes
%ifdef SAFE_DATA
;; Clear IV
vpxor xmm0, xmm0
shl idx, 3 ; multiply by 8
vmovdqa [state + _aes_args_IV + idx*2], xmm0
mov qword [state + _aes_args_keys + idx], 0
%endif
return:
endbranch64
mov rbx, [rsp + _gpr_save + 8*0]
mov rbp, [rsp + _gpr_save + 8*1]
mov r12, [rsp + _gpr_save + 8*2]
mov r13, [rsp + _gpr_save + 8*3]
mov r14, [rsp + _gpr_save + 8*4]
mov r15, [rsp + _gpr_save + 8*5]
%ifndef LINUX
mov rsi, [rsp + _gpr_save + 8*6]
mov rdi, [rsp + _gpr_save + 8*7]
%endif
mov rsp, [rsp + _rsp_save] ; original SP
ret
return_null:
xor job_rax, job_rax
jmp return
%ifdef LINUX
section .note.GNU-stack noalloc noexec nowrite progbits
%endif
|
; A085602: Numbers of the form (2n+1)^(2n+1) + 1.
; 2,28,3126,823544,387420490,285311670612,302875106592254,437893890380859376,827240261886336764178,1978419655660313589123980,5842587018385982521381124422,20880467999847912034355032910568,88817841970012523233890533447265626,443426488243037769948249630619149892804,2567686153161211134561828214731016126483470,17069174130723235958610643029059314756044734432,129110040087761027839616029934664535539337183380514,1102507499354148695951786433413508348166942596435546876
mul $0,2
add $0,1
pow $0,$0
add $0,1
|
; Buffering (get multi-byte) utility V2.00 1989 Tony Tebby QJUMP
section iou
xdef iob_gmul
xref iob_gbyt
include 'dev8_keys_buf'
;+++
; This routine gets multiple bytes from an IO buffer. If it needs a
; new buffer, the old buffer is added to the linked list of throwaways.
;
; If it is end of file, the buffer is thrown away and A2 is returned as
; either the next list of buffers or zero. The end of file flag is put in
; (A1), but neither D1 nor A1 are incremented.
;
; When A2 is modified, the corresponding current output queue pointer is
; updated.
;
; This routine can be called from an interrupt server.
;
; This is a clean routine.
;
; d0 r status: 0, err.nc or +1 for end of file
; d1 c u byte count
; d2 c p number of bytes to transfer
; a1 c u destination for bytes transferred
; a2 c u pointer to buffer header, updated if new buffer or eof
; a6 c p pointer to system variables
; all other registers preserved
;--
iob_gmul
moveq #0,d0
cmp.l d1,d2 ; number of bytes to read
ble.s ibgm_done
move.l d1,-(sp)
jsr iob_gbyt
bne.s ibgm_bad
move.b d1,(a1)+
move.l (sp)+,d1
addq.l #1,d1
bra.s iob_gmul
ibgm_bad
blt.s ibgm_rest
move.b d1,(a1) ; set eoff
ibgm_rest
move.l (sp)+,d1
ibgm_done
tst.l d0
rts
end
|
; A288465: a(n) = 2*a(n-1) - a(n-4), where a(0) = 2, a(1) = 4, a(2) = 6, a(3) = 10.
; 2,4,6,10,18,32,58,106,194,356,654,1202,2210,4064,7474,13746,25282,46500,85526,157306,289330,532160,978794,1800282,3311234,6090308,11201822,20603362,37895490,69700672,128199522,235795682,433695874,797691076,1467182630,2698569578,4963443282,9129195488,16791208346,30883847114,56804250946,104479306404,192167404462,353450961810,650097672674,1195716038944,2199264673426,4045078385042,7440059097410,13684402155876,25169539638326,46294000891610,85147942685810,156611483215744,288053426793162,529812852694714,974477762703618,1792344042191492,3296634657589822,6063456462484930,11152435162266242,20512526282340992,37728417907092162,69393379351699394,127634323541132546,234756120799924100,431783823692756038,794174268033812682,1460714212526492818,2686672304253061536,4941560784813367034,9088947301592921386,16717180390659349954,30747688477065638372,56553816169317909710,104018685037042898034,191320189683426446114,351892690889787253856,647231565610256598002,1190444446183470297970,2189568702683514149826,4027244714477241045796,7407257863344225493590,13624071280504980689210,25058573858326447228594,46089903002175653411392,84772548141007081329194,155921025001509181969178,286783476144691916709762,527477049287208180008132,970181550433409278687070,1784442075865309375404962,3282100675585926834100162,6036724301884645488192192,11103267053335881697697314,20422092030806454019989666,37562083386026981205879170,69087442470169316923566148,127071617887002752149434982,233721143743199050278880298
lpb $0
mov $2,$0
trn $0,3
seq $2,232508 ; Number of (n+1) X (1+1) 0..2 arrays with every element next to itself plus and minus one within the range 0..2 horizontally, diagonally or antidiagonally, with no adjacent elements equal.
add $1,$2
lpe
div $1,2
add $1,2
mov $0,$1
|
; void __CALLEE__ sp1_PrintAtInv_callee(uchar row, uchar col, uint tile)
; 01.2008 aralbrec, Sprite Pack v3.0
; ts2068 hi-res version
PUBLIC sp1_PrintAtInv_callee
PUBLIC ASMDISP_SP1_PRINTATINV_CALLEE
EXTERN sp1_GetUpdateStruct_callee, sp1_PrintAt_callee
EXTERN ASMDISP_SP1_GETUPDATESTRUCT_CALLEE, ASMDISP_SP1_PRINTAT_CALLEE
EXTERN SP1V_UPDATELISTT
.sp1_PrintAtInv_callee
pop af
pop bc
pop de
pop hl
ld d,l
push af
.asmentry
; Print tile and colour to given coordinate and invalidate
; the tile so that it is redrawn in the next update.
;
; enter : d = row coord
; e = col coord
; bc = tile code
; uses : af, bc, de, hl
.SP1PrintAtInv
call sp1_GetUpdateStruct_callee + ASMDISP_SP1_GETUPDATESTRUCT_CALLEE
ld a,(hl)
xor $80
jp p, sp1_PrintAt_callee + ASMDISP_SP1_PRINTAT_CALLEE + 3 ; if already marked for invalidation just do PrintAt
ld (hl),a ; mark struct_sp1_update as invalidated
ld e,l
ld d,h ; de = & struct sp1_update
inc hl
ld (hl),c ; write tile
inc hl
ld (hl),b
inc hl
inc hl
inc hl
ld (hl),0 ; mark no struct sp1_update following in invalidated list
ld hl,(SP1V_UPDATELISTT) ; current last sp1_update in invalidated list
ld bc,5
add hl,bc
ld (hl),d ; store this new sp1_update into current tail
inc hl
ld (hl),e
ld (SP1V_UPDATELISTT),de ; this new struct sp1_update is now the tail in invalidated list
ret
DEFC ASMDISP_SP1_PRINTATINV_CALLEE = asmentry - sp1_PrintAtInv_callee
|
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// 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.
//-----------------------------------------------------------------------------
#include "platform/platform.h"
#include "core/util/zip/compressor.h"
#include "core/resizeStream.h"
namespace Zip
{
ImplementCompressor(Stored, Stored);
CompressorCreateReadStream(Stored)
{
ResizeFilterStream *resStream = new ResizeFilterStream;
resStream->attachStream(zipStream);
resStream->setStreamOffset(zipStream->getPosition(), cdir->mCompressedSize);
return resStream;
}
CompressorCreateWriteStream(Stored)
{
return zipStream;
}
} // end namespace Zip
|
; A207836: a(n) = n*A052530(n)/2.
; 0,3,16,75,336,1463,6240,26199,108640,445995,1815792,7341347,29505840,117982815,469672384,1862393775,7359403968,28991540051,113892526800,446305331451,1744950085648,6808253393415,26513475730464,103072540115975,400058834841120,1550464509091707,6000723890790832,23194828101288915,89549252013968880,345342436905785519,1330410859914364800,5120322203021241183,19688372388943678336,75639123899576218275,290354454959879100816,1113718066395189063083,4268788960691354757840,16350583006196891515479
lpb $0
sub $0,1
add $1,1
add $2,$1
add $1,1
add $1,$2
add $1,$0
add $2,$1
lpe
mov $0,$1
|
;
; Amstrad CPC library
; (CALLER linkage for function pointers)
;
; set color palette, flashing is useless so we forget the second color
;
; void __LIB__ __CALLEE__ cpc_Uncrunch(int src, int dst);
;
; $Id: cpc_Uncrunch.asm $
;
SECTION code_clib
PUBLIC cpc_Uncrunch
PUBLIC _cpc_Uncrunch
EXTERN cpc_Uncrunch_callee
EXTERN ASMDISP_CPC_UNCRUNCH_CALLEE
.cpc_Uncrunch
._cpc_Uncrunch
pop bc
pop hl
pop de
push de
push hl
push bc
jp cpc_Uncrunch_callee + ASMDISP_CPC_UNCRUNCH_CALLEE
|
; unsigned char zx_tape_load_block(void *dst, unsigned int len, unsigned char type)
SECTION code_clib
SECTION code_arch
PUBLIC zx_tape_load_block_callee
EXTERN asm_zx_tape_load_block
zx_tape_load_block_callee:
pop af
pop bc
pop de
pop ix
push af
ld a,c
jp asm_zx_tape_load_block
|
INCLUDE "config_private.inc"
SECTION code_driver
SECTION code_driver_terminal_output
PUBLIC console_01_output_char_oterm_msg_putc
PUBLIC console_01_output_char_oterm_msg_putc_raw
EXTERN l_jpix
EXTERN console_01_output_char_proc_putchar_scroll
EXTERN console_01_output_char_proc_linefeed
console_01_output_char_oterm_msg_putc:
; enter : c = char to output
; can use: af, bc, de, hl
; char to print is coming from stdio
bit 5,(ix+6)
jr z, cooked ; if cook is disabled
; tty emulation is enabled
ld a,OTERM_MSG_TTY
call l_jpix ; carry reset if tty absorbed char
ret nc ; if tty absorbed char
ld a,c
cp CHAR_BELL
jr nz, cooked
putchar_bell:
ld a,OTERM_MSG_BELL
jp (ix)
cooked:
ld b,255 ; b = parameter (255 = undefined)
; b = parameter
; c = ascii code
bit 4,(ix+6)
jr z, crlf_done ; if not processing crlf
ld a,c
cp CHAR_CR
ret z ; ignore cr
crlf_done:
console_01_output_char_oterm_msg_putc_raw:
; b = parameter
; c = ascii code
ld a,c
cp CHAR_LF
jp z, console_01_output_char_proc_linefeed
; do not check for control chars here
putchar_ok:
; check print coordinates
ld e,(ix+14)
ld d,(ix+15)
; b = parameter
; c = ascii code
; e = x coord
; d = y coord
ld a,e
cp (ix+17)
jr c, x_ok ; if x < width
ld e,0 ; x = 0
inc d ; y++
x_ok:
ld a,d
sub (ix+19) ; a = y - height
jr c, y_ok ; if y < height
; scroll upward
push bc ; save param, char
push de ; save x
inc a
call console_01_output_char_proc_putchar_scroll
pop de ; e = x
pop bc ; b = param, c = char
ld d,(ix+19)
dec d ; d = y = window.height - 1
jr nc, y_ok ; if no cls
ld d,0
y_ok:
inc e ; advance x coord
ld (ix+14),e ; store next x coord
ld (ix+15),d ; store next y coord
dec e
ld l,(ix+16) ; l = window.left coord
ld h,(ix+18) ; h = window.top coord
add hl,de ; hl = absolute character coords
; b = parameter
; c = ascii code
; l = absolute x coord
; h = absolute y coord
ld a,OTERM_MSG_PRINTC
jp (ix)
|
org 24576
INCLUDE "input.asm"
INCLUDE "im2.asm"
INCLUDE "entities.asm"
INCLUDE "depack.asm"
INCLUDE "rambank.asm"
END_P1:
org $8000
IM2table: ds 257 ; IM2 table (reserved)
start_game:
set_interrupt:
ld a, 0x9a
ld hl, 0x8000
ld de, ISR
call SetIM2
pre_begin:
xor a
call LoadLevel
ld hl, marco
call depack_to_both_screens
call setscreen0
call InitSprCacheList
call PrerotateTiles
call InitEntities
call InitPlayer
call MoveCamera
ld a, (curx_tile) ; bit 0-1 is the displacement, bit 2 the start tile
call PrepareMapUpdate
begin:
ld a, (current_screen_bank)
ld b, a
call setrambank_with_di
; Draw current frame
di
; ld a, 3
; out ($fe), a
call DrawBkg
ei
; ld a, 2
; out ($fe), a
call DrawEntities
; xor a
; out ($fe), a
ld b, 0
call setrambank_with_di ; For the rest of the frame, we want to use RAM bank 0
; Prepare next frame
ld a, 3
ld hl, key_defs
call get_joystick ; we get the result in A
ld (joystick_state), a
and 1
jr nz, begin_noack
xor a
ld (jump_ack), a
begin_noack:
call ProcessActions
call ApplyGravity
call MoveEntities
ld ix, EntityList ; Use the player as reference
call MoveCamera ; Finally, adjust camera to keep player in centre
halt
call switchscreen
ld a, (current_screen_bank)
xor 2 ; switch from 5 to 7
ld (current_screen_bank), a
jr begin
ISR:
ret
; Random routine from http://wikiti.brandonw.net/index.php?title=Z80_Routines:Math:Random
;-----> Generate a random number
; ouput a=answer 0<=a<=255
; all registers are preserved except: af
random:
push hl
push de
ld hl,(randData)
ld a,r
ld d,a
ld e,(hl)
add hl,de
add a,l
xor h
ld (randData),hl
pop de
pop hl
ret
; Load level
; INPUT:
; - A: level to load
LoadLevel:
push af
call setscreen0
call switchscreen
ld b, 6
call setrambank_with_di
pop af
add a, a
ld e, a
ld d, 0
ld hl, 49152
add hl, de
ld e, (hl)
inc hl
ld d, (hl)
ex de, hl ; HL points to the packed level
ld de, 16384
call depack
ld b, 0
call setrambank_with_di
ld hl, 16384
ld de, $c000 ;$d000
ld bc, 4096
ldir
call setscreen0
ret
current_screen_bank: db 7
jump_ack: db 0
joystick_state: db 0
key_defs: dw KEY_Q, KEY_A, KEY_O, KEY_P, KEY_SPACE, KEY_CAPS
randData: dw 42
INCLUDE "engine.asm"
INCLUDE "drawsprite.asm"
END_P2:
org $9800 ;Aligned on Memory to have same high byte per line
line1:
ds 64
line2:
ds 64
line3:
ds 64
line4:
ds 64
line5:
ds 64
line6:
ds 64
line7:
ds 64
line8:
ds 64
org $9A2C ;Used by Draw_Sprite, moved here to have it aliged on High Byte
Multiply_by_96 dw 0,96,192,288,384,480,576,672,768,864,960,1056,1152
dw 1248,1344,1440,1536,1632,1728,1824,1920,2016
dw 2112,2208,2304,2400,2496,2592,2688,2784,2880
dw 2976,3072,3168,3264,3360,3456,3552,3648,3744,3840,3936
org $9AC0
tiletable:
; Code address, tile1 address, tile2 address, (lastline, rows)
dw line1, $0000, $0000, $0010
dw line2, $0000, $0000, $0010
dw line3, $0000, $0000, $0010
dw line4, $0000, $0000, $0010
dw line5, $0000, $0000, $0010
dw line6, $0000, $0000, $0010
dw line7, $0000, $0000, $0010
dw line8, $0000, $0000, $0100
dw $0000
org $a000
tiles:
INCLUDE "tile1.asm"
org $a180 ; 384 bytes per 48x16 tile (with 4 different rotations)
INCLUDE "tile2.asm"
org $a300
INCLUDE "tile3.asm"
org $a480
INCLUDE "tile4.asm"
org $a600
INCLUDE "tile5.asm"
org $a780
INCLUDE "tile6.asm"
org $a900
INCLUDE "tile7.asm"
org $aa80
INCLUDE "tile8.asm"
org $ac00
INCLUDE "tile9.asm"
org $ad80
INCLUDE "tile10.asm"
org $c000
mapwidth: db 0
mapheight: db 0
start_x: dw 0
start_y: dw 0
ptr_levelscript: dw 0
levelmap: ds 4096-8
org $e000
marco:
INCBIN "marco.pck"
|
#include "Exercise.h"
namespace Algorithms {
// 初始化
std::vector<const Exercise*> Exercise::exercises;
Exercise::Exercise (const Exercise* exercise)
{
exercises.push_back (exercise);
}
void Exercise::ExecExercise ()
{
for (auto exercise : exercises)
{
std::cout << "===== " << exercise->Name () << std::endl;
exercise->Execute ();
std::cout << "===== " << exercise->Name () << std::endl;
std::cout << std::endl;
}
}
Exercise::~Exercise ()
{
}
std::vector<int> GenerateElement (int size) {
std::vector<int> vec;
for (int i = 0; i < size; i++)
{
int element = std::rand () % 100 + 1;
vec.push_back (element);
}
return vec;
}
} |
.global s_prepare_buffers
s_prepare_buffers:
push %r15
push %r8
push %r9
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_normal_ht+0x1080c, %r9
nop
nop
nop
nop
sub %rbp, %rbp
vmovups (%r9), %ymm2
vextracti128 $1, %ymm2, %xmm2
vpextrq $1, %xmm2, %rdx
nop
nop
nop
nop
nop
and $4660, %r15
lea addresses_normal_ht+0x2eec, %rsi
lea addresses_A_ht+0x25cc, %rdi
nop
nop
nop
add %r8, %r8
mov $86, %rcx
rep movsl
nop
nop
nop
add $16537, %r8
lea addresses_normal_ht+0xfdcc, %rdi
nop
and $6932, %rdx
mov $0x6162636465666768, %rbp
movq %rbp, (%rdi)
nop
nop
nop
nop
nop
add %rcx, %rcx
lea addresses_WT_ht+0x639c, %rsi
lea addresses_UC_ht+0x1907c, %rdi
nop
nop
nop
dec %r9
mov $125, %rcx
rep movsq
nop
nop
nop
xor %rsi, %rsi
lea addresses_WT_ht+0x18336, %rsi
clflush (%rsi)
nop
nop
nop
nop
nop
and $28267, %r9
mov (%rsi), %bp
nop
nop
add $4075, %r8
lea addresses_A_ht+0x9c0c, %rbp
nop
nop
nop
xor %rdx, %rdx
movups (%rbp), %xmm7
vpextrq $0, %xmm7, %r15
nop
nop
nop
inc %r8
lea addresses_normal_ht+0x16b1c, %rcx
nop
nop
xor $58456, %r15
movl $0x61626364, (%rcx)
nop
sub $14733, %rdx
lea addresses_A_ht+0x45cc, %rdx
nop
cmp %rdi, %rdi
vmovups (%rdx), %ymm2
vextracti128 $1, %ymm2, %xmm2
vpextrq $0, %xmm2, %rsi
nop
nop
add $31476, %r9
lea addresses_UC_ht+0x15b24, %r9
nop
nop
nop
nop
nop
dec %rcx
movw $0x6162, (%r9)
xor %rbp, %rbp
lea addresses_UC_ht+0x5acc, %rbp
nop
add %r8, %r8
vmovups (%rbp), %ymm7
vextracti128 $1, %ymm7, %xmm7
vpextrq $1, %xmm7, %rdi
nop
nop
nop
sub $53685, %r15
lea addresses_A_ht+0x18dcc, %rdx
nop
inc %r8
movw $0x6162, (%rdx)
inc %rbp
lea addresses_WC_ht+0x139cc, %rsi
lea addresses_WT_ht+0x13cd4, %rdi
nop
nop
nop
xor %r9, %r9
mov $87, %rcx
rep movsl
nop
nop
dec %rbp
lea addresses_WC_ht+0xb2fa, %rsi
lea addresses_A_ht+0x196bc, %rdi
nop
nop
nop
nop
sub $43657, %rbp
mov $86, %rcx
rep movsq
nop
nop
nop
nop
cmp $63251, %r8
lea addresses_WC_ht+0x10fcc, %rsi
lea addresses_D_ht+0x151cc, %rdi
nop
nop
nop
nop
nop
dec %r9
mov $114, %rcx
rep movsw
nop
nop
sub $53010, %r8
lea addresses_UC_ht+0x78ac, %rsi
lea addresses_normal_ht+0x14ccc, %rdi
cmp %rdx, %rdx
mov $84, %rcx
rep movsw
nop
nop
sub %r8, %r8
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r8
pop %r15
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r13
push %r14
push %r15
push %r9
push %rcx
push %rdi
// Load
lea addresses_A+0x114ce, %r14
nop
add $48460, %r13
vmovntdqa (%r14), %ymm7
vextracti128 $0, %ymm7, %xmm7
vpextrq $1, %xmm7, %r9
nop
nop
nop
nop
nop
xor $40503, %r9
// Store
lea addresses_RW+0xa7cc, %r9
dec %rdi
movb $0x51, (%r9)
nop
nop
nop
and $55073, %rcx
// Load
lea addresses_PSE+0x75cc, %r11
clflush (%r11)
nop
cmp $21826, %rdi
mov (%r11), %ecx
nop
nop
sub $8805, %r14
// Faulty Load
lea addresses_PSE+0x75cc, %rcx
nop
nop
nop
xor %r15, %r15
mov (%rcx), %rdi
lea oracles, %rcx
and $0xff, %rdi
shlq $12, %rdi
mov (%rcx,%rdi,1), %rdi
pop %rdi
pop %rcx
pop %r9
pop %r15
pop %r14
pop %r13
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A', 'size': 32, 'AVXalign': False, 'NT': True, 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 8, 'AVXalign': False, 'NT': True, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 10, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 3, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': True}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 1, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 1, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}}
{'33': 21332}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
.file "tools.c"
.section .rodata
.align 32
.local named
.type named, @object
named:
.long 1
.long 2
.LC2:
.string "test\n"
.size named, 8
# ----------------------
.text
.globl main
.type main, @function
main:
ret
.size main, .-main
# ----------------------
.local other
.type other, @function
other:
pushl %ebp
movl %esp, %ebp
pushl %edi
pushl %esi
pushl %ebx
call __i686.get_pc_thunk.bx
addl $_GLOBAL_OFFSET_TABLE_, %ebx
movl named@GOTOFF+4(%ebx), %eax
leal .LC2@GOTOFF(%ebx), %eax
popl %ebx
popl %esi
popl %edi
popl %ebp
ret
.size other, .-other
# ----------------------
.section .text.__i686.get_pc_thunk.bx,"axG",@progbits,__i686.get_pc_thunk.bx,comdat
.hidden __i686.get_pc_thunk.bx
.globl __i686.get_pc_thunk.bx
.type __i686.get_pc_thunk.bx, @function
__i686.get_pc_thunk.bx:
movl (%esp), %ebx
ret
# ----------------------
.ident "GCC: (GNU) 4.1.1 20070105 (Red Hat 4.1.1-51)"
.section .note.GNU-stack,"",@progbits
|
; ===============================================================
; Dec 2013
; ===============================================================
;
; size_t strlen(const char *s)
;
; Return length of string s.
;
; ===============================================================
SECTION code_clib
SECTION code_string
PUBLIC asm_strlen
asm_strlen:
; enter: hl = char *s
;
; exit : hl = length
; bc = -(length + 1)
; a = 0
; z flag set if 0 length
; carry reset
;
; uses : af, bc, hl
xor a
ld c,a
ld b,a
IF __CPU_INTEL__ || __CPU_GBZ80__
loop:
ld a,(hl)
inc hl
dec bc
and a
jr Z,matched
ld a,b
or c
jr NZ,loop
matched:
push af
ld a,$ff
sub c
ld l,a
ld a,$ff
sbc b
ld h,a
pop af
ld a,0
ELSE
cpir
ld hl,$ffff
sbc hl,bc
ENDIF
ret
|
; A003132: Sum of squares of digits of n.
; 0,1,4,9,16,25,36,49,64,81,1,2,5,10,17,26,37,50,65,82,4,5,8,13,20,29,40,53,68,85,9,10,13,18,25,34,45,58,73,90,16,17,20,25,32,41,52,65,80,97,25,26,29,34,41,50,61,74,89,106,36,37,40,45,52,61,72,85,100,117,49,50,53,58,65,74,85,98,113,130,64,65,68,73,80,89,100,113,128,145,81,82,85,90,97,106,117,130,145,162
mov $1,3
lpb $0
mov $2,$0
div $0,10
mod $2,10
pow $2,2
add $1,$2
lpe
sub $1,3
mov $0,$1
|
; A007972: Number of permutations that are 2 "block reversals" away from 12...n.
; 2,15,52,129,266,487,820,1297,1954,2831,3972,5425,7242,9479,12196,15457,19330,23887,29204,35361,42442,50535,59732,70129,81826,94927,109540,125777,143754,163591,185412,209345,235522,264079,295156,328897,365450,404967,447604
mov $4,$0
lpb $0
mov $1,$0
sub $0,1
gcd $3,2
add $2,$3
add $2,$1
lpe
add $1,$2
pow $1,2
mul $1,2
div $1,3
add $1,2
mov $5,$4
mov $6,$4
mul $6,2
add $1,$6
mul $5,$4
add $1,$5
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r13
push %r15
push %r8
push %rax
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0xfd37, %rcx
nop
nop
nop
xor %r15, %r15
mov (%rcx), %r13w
xor %r12, %r12
lea addresses_A_ht+0xc85d, %rax
nop
nop
nop
nop
nop
sub $50320, %r8
movups (%rax), %xmm7
vpextrq $1, %xmm7, %r11
nop
nop
cmp %r12, %r12
lea addresses_UC_ht+0x8dbf, %rsi
lea addresses_WC_ht+0x11f6f, %rdi
clflush (%rsi)
nop
cmp $60059, %r12
mov $11, %rcx
rep movsw
nop
nop
nop
xor $8111, %rdi
lea addresses_normal_ht+0x2551, %rcx
nop
nop
nop
nop
nop
and $15681, %rax
movw $0x6162, (%rcx)
nop
nop
and $56215, %rsi
lea addresses_A_ht+0x3eef, %r15
nop
nop
nop
nop
nop
inc %r12
movw $0x6162, (%r15)
nop
nop
nop
add $38110, %rdi
lea addresses_D_ht+0x156f, %rsi
lea addresses_WC_ht+0x111d5, %rdi
nop
and %r12, %r12
mov $81, %rcx
rep movsl
nop
nop
nop
nop
sub $51499, %r8
lea addresses_A_ht+0x10d6f, %rsi
lea addresses_WT_ht+0x1db4f, %rdi
nop
nop
and %rax, %rax
mov $50, %rcx
rep movsb
and $50933, %r8
lea addresses_D_ht+0x118bf, %rsi
lea addresses_A_ht+0x16947, %rdi
nop
nop
nop
nop
nop
xor %rax, %rax
mov $87, %rcx
rep movsq
nop
nop
nop
sub $50316, %r13
lea addresses_A_ht+0xa16f, %rdi
nop
sub %r8, %r8
mov $0x6162636465666768, %rax
movq %rax, %xmm3
movups %xmm3, (%rdi)
nop
nop
nop
nop
and %r13, %r13
lea addresses_WC_ht+0x19c67, %rsi
lea addresses_WC_ht+0x2aef, %rdi
nop
dec %rax
mov $95, %rcx
rep movsq
nop
nop
add %rcx, %rcx
lea addresses_normal_ht+0xab6f, %rcx
clflush (%rcx)
nop
dec %r13
vmovups (%rcx), %ymm6
vextracti128 $1, %ymm6, %xmm6
vpextrq $1, %xmm6, %r15
nop
nop
nop
nop
add %r8, %r8
lea addresses_WC_ht+0x2eef, %r15
nop
nop
nop
nop
nop
cmp $27728, %r12
movups (%r15), %xmm1
vpextrq $1, %xmm1, %rax
nop
nop
sub %r12, %r12
pop %rsi
pop %rdi
pop %rcx
pop %rax
pop %r8
pop %r15
pop %r13
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r14
push %r8
push %rax
push %rbx
push %rcx
push %rdx
// Load
lea addresses_normal+0x11901, %rax
clflush (%rax)
nop
nop
nop
dec %rcx
mov (%rax), %rbx
nop
and $1603, %r14
// Store
mov $0xbe3, %rdx
dec %r8
mov $0x5152535455565758, %rcx
movq %rcx, %xmm3
movntdq %xmm3, (%rdx)
nop
add %rdx, %rdx
// Store
lea addresses_RW+0x10b6f, %rbx
dec %r10
movl $0x51525354, (%rbx)
nop
nop
and $47149, %rbx
// Store
lea addresses_PSE+0x1c237, %rax
nop
nop
nop
add %r10, %r10
mov $0x5152535455565758, %r8
movq %r8, (%rax)
xor %rdx, %rdx
// Store
mov $0xc36f20000000d6f, %rcx
nop
nop
nop
nop
sub %rbx, %rbx
mov $0x5152535455565758, %rax
movq %rax, %xmm5
vmovups %ymm5, (%rcx)
nop
nop
cmp %r8, %r8
// Store
mov $0x14fb9b000000016f, %rdx
and %rax, %rax
movl $0x51525354, (%rdx)
cmp %r14, %r14
// Faulty Load
mov $0x14fb9b000000016f, %rbx
clflush (%rbx)
nop
nop
nop
nop
nop
sub $61755, %rax
mov (%rbx), %r10w
lea oracles, %rdx
and $0xff, %r10
shlq $12, %r10
mov (%rdx,%r10,1), %r10
pop %rdx
pop %rcx
pop %rbx
pop %rax
pop %r8
pop %r14
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'AVXalign': False, 'congruent': 1, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_P', 'AVXalign': False, 'congruent': 1, 'size': 16, 'same': False, 'NT': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 9, 'size': 4, 'same': False, 'NT': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'AVXalign': False, 'congruent': 0, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 10, 'size': 32, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 4, 'same': True, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_NC', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 2, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 0, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': True, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 7, 'size': 2, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 0, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': True}}
{'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'AVXalign': False, 'congruent': 10, 'size': 16, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 4, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'AVXalign': False, 'congruent': 8, 'size': 32, 'same': True, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 7, 'size': 16, 'same': False, 'NT': False}}
{'12': 1, '54': 21564, '00': 264}
54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 00 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 00 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 00 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 00 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 00 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 00 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 00 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 00 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 00 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 00 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 00 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54 54
*/
|
#include "ApplicationHandler.hpp"
#include "../../ext/FullScreenTriangle/FullScreenTriangle.h"
#include "../../ext/ScreenShot/ScreenShot.h"
#include <irr/asset/filters/kernels/CGaussianImageFilterKernel.h>
#include <irr/asset/filters/kernels/CDerivativeImageFilterKernel.h>
#include <irr/asset/filters/kernels/CBoxImageFilterKernel.h>
#include <irr/asset/filters/kernels/CChannelIndependentImageFilterKernel.h>
#include <irr/asset/filters/CMipMapGenerationImageFilter.h>
using namespace irr;
using namespace core;
using namespace asset;
using namespace video;
ApplicationHandler::ApplicationHandler()
{
status = initializeApplication();
fetchTestingImagePaths();
}
void ApplicationHandler::executeColorSpaceTest()
{
for (const auto& pathToAnImage : imagePaths)
performImageTest(pathToAnImage);
}
void ApplicationHandler::fetchTestingImagePaths()
{
std::ifstream list(testingImagePathsFile.data());
if (list.is_open())
{
std::string line;
for (; std::getline(list, line); )
{
if (line != "" && line[0] != ';')
imagePaths.push_back(line);
}
}
}
void ApplicationHandler::presentImageOnTheScreen(irr::core::smart_refctd_ptr<irr::video::IGPUImageView> gpuImageView, std::string currentHandledImageFileName, std::string currentHandledImageExtension)
{
auto samplerDescriptorSet3 = driver->createGPUDescriptorSet(core::smart_refctd_ptr(gpuDescriptorSetLayout3));
IGPUDescriptorSet::SDescriptorInfo info;
{
info.desc = gpuImageView;
ISampler::SParams samplerParams = { ISampler::ETC_CLAMP_TO_EDGE, ISampler::ETC_CLAMP_TO_EDGE, ISampler::ETC_CLAMP_TO_EDGE, ISampler::ETBC_FLOAT_OPAQUE_BLACK, ISampler::ETF_LINEAR, ISampler::ETF_LINEAR, ISampler::ESMM_LINEAR, 0u, false, ECO_ALWAYS };
info.image.sampler = driver->createGPUSampler(samplerParams);
info.image.imageLayout = EIL_SHADER_READ_ONLY_OPTIMAL;
}
IGPUDescriptorSet::SWriteDescriptorSet write;
write.dstSet = samplerDescriptorSet3.get();
write.binding = 0u;
write.arrayElement = 0u;
write.count = 1u;
write.descriptorType = EDT_COMBINED_IMAGE_SAMPLER;
write.info = &info;
driver->updateDescriptorSets(1u, &write, 0u, nullptr);
std::wostringstream characterStream;
characterStream << L"Color Space Test Demo - Irrlicht Engine [" << driver->getName() << "] - CURRENT IMAGE: " << currentHandledImageFileName.c_str() << " - EXTENSION: " << currentHandledImageExtension.c_str();
device->setWindowCaption(characterStream.str().c_str());
auto startPoint = std::chrono::high_resolution_clock::now();
while (device->run())
{
auto aPoint = std::chrono::high_resolution_clock::now();
if (std::chrono::duration_cast<std::chrono::milliseconds>(aPoint - startPoint).count() > SWITCH_IMAGES_PER_X_MILISECONDS)
break;
driver->beginScene(true, true);
driver->bindGraphicsPipeline(currentGpuPipelineFor2D.get());
driver->bindDescriptorSets(EPBP_GRAPHICS, currentGpuPipelineFor2D->getLayout(), 3u, 1u, &samplerDescriptorSet3.get(), nullptr);
driver->drawMeshBuffer(currentGpuMeshBuffer.get());
driver->blitRenderTargets(nullptr, screenShotFrameBuffer, false, false);
driver->endScene();
}
ext::ScreenShot::createScreenShot(device, screenShotFrameBuffer->getAttachment(video::EFAP_COLOR_ATTACHMENT0), "screenShot_" + currentHandledImageFileName + ".png");
}
namespace
{
template<class Kernel>
class MyKernel : public asset::CFloatingPointSeparableImageFilterKernelBase<MyKernel<Kernel>>
{
using Base = asset::CFloatingPointSeparableImageFilterKernelBase<MyKernel<Kernel>>;
Kernel kernel;
float multiplier;
public:
using value_type = typename Base::value_type;
MyKernel(Kernel&& k, float _imgExtent) : Base(k.negative_support.x, k.positive_support.x), kernel(std::move(k)), multiplier(_imgExtent) {}
// no special user data by default
inline const asset::IImageFilterKernel::UserData* getUserData() const { return nullptr; }
inline float weight(float x, int32_t channel) const
{
return kernel.weight(x, channel) * multiplier;
}
// we need to ensure to override the default behaviour of `CFloatingPointSeparableImageFilterKernelBase` which applies the weight along every axis
template<class PreFilter, class PostFilter>
struct sample_functor_t
{
sample_functor_t(const MyKernel* _this, PreFilter& _preFilter, PostFilter& _postFilter) :
_this(_this), preFilter(_preFilter), postFilter(_postFilter) {}
inline void operator()(value_type* windowSample, core::vectorSIMDf& relativePos, const core::vectorSIMDi32& globalTexelCoord, const IImageFilterKernel::UserData* userData)
{
preFilter(windowSample, relativePos, globalTexelCoord, userData);
auto* scale = IImageFilterKernel::ScaleFactorUserData::cast(userData);
for (int32_t i=0; i<MaxChannels; i++)
{
// this differs from the `CFloatingPointSeparableImageFilterKernelBase`
windowSample[i] *= _this->weight(relativePos.x, i);
if (scale)
windowSample[i] *= scale->factor[i];
}
postFilter(windowSample, relativePos, globalTexelCoord, userData);
}
private:
const MyKernel* _this;
PreFilter& preFilter;
PostFilter& postFilter;
};
_IRR_STATIC_INLINE_CONSTEXPR bool has_derivative = false;
IRR_DECLARE_DEFINE_CIMAGEFILTER_KERNEL_PASS_THROUGHS(Base)
};
template<class Kernel>
class SeparateOutXAxisKernel : public asset::CFloatingPointSeparableImageFilterKernelBase<SeparateOutXAxisKernel<Kernel>>
{
using Base = asset::CFloatingPointSeparableImageFilterKernelBase<SeparateOutXAxisKernel<Kernel>>;
Kernel kernel;
public:
// passthrough everything
using value_type = typename Kernel::value_type;
_IRR_STATIC_INLINE_CONSTEXPR auto MaxChannels = Kernel::MaxChannels; // derivative map only needs 2 channels
SeparateOutXAxisKernel(Kernel&& k) : Base(k.negative_support.x, k.positive_support.x), kernel(std::move(k)) {}
IRR_DECLARE_DEFINE_CIMAGEFILTER_KERNEL_PASS_THROUGHS(Base)
// we need to ensure to override the default behaviour of `CFloatingPointSeparableImageFilterKernelBase` which applies the weight along every axis
template<class PreFilter, class PostFilter>
struct sample_functor_t
{
sample_functor_t(const SeparateOutXAxisKernel<Kernel>* _this, PreFilter& _preFilter, PostFilter& _postFilter) :
_this(_this), preFilter(_preFilter), postFilter(_postFilter) {}
inline void operator()(value_type* windowSample, core::vectorSIMDf& relativePos, const core::vectorSIMDi32& globalTexelCoord, const IImageFilterKernel::UserData* userData)
{
preFilter(windowSample, relativePos, globalTexelCoord, userData);
auto* scale = IImageFilterKernel::ScaleFactorUserData::cast(userData);
for (int32_t i=0; i<MaxChannels; i++)
{
// this differs from the `CFloatingPointSeparableImageFilterKernelBase`
windowSample[i] *= _this->kernel.weight(relativePos.x, i);
if (scale)
windowSample[i] *= scale->factor[i];
}
postFilter(windowSample, relativePos, globalTexelCoord, userData);
}
private:
const SeparateOutXAxisKernel<Kernel>* _this;
PreFilter& preFilter;
PostFilter& postFilter;
};
// the method all kernels must define and overload
template<class PreFilter, class PostFilter>
inline auto create_sample_functor_t(PreFilter& preFilter, PostFilter& postFilter) const
{
return sample_functor_t(this,preFilter,postFilter);
}
};
}
static core::smart_refctd_ptr<asset::ICPUImage> createDerivMapFromHeightMap(asset::ICPUImage* _inImg, asset::ISampler::E_TEXTURE_CLAMP _uwrap, asset::ISampler::E_TEXTURE_CLAMP _vwrap, asset::ISampler::E_TEXTURE_BORDER_COLOR _borderColor)
{
using namespace asset;
#define DERIV_MAP_FLOAT32
auto getRGformat = [](asset::E_FORMAT f) -> asset::E_FORMAT {
const uint32_t bytesPerChannel = (getBytesPerPixel(f) * core::rational(1, getFormatChannelCount(f))).getIntegerApprox();
switch (bytesPerChannel)
{
case 1u:
#ifndef DERIV_MAP_FLOAT32
return asset::EF_R8G8_UNORM;
#else
_IRR_FALLTHROUGH;
#endif
case 2u:
#ifndef DERIV_MAP_FLOAT32
return asset::EF_R16G16_SFLOAT;
#else
_IRR_FALLTHROUGH;
#endif
case 4u:
return asset::EF_R32G32_SFLOAT;
case 8u:
return asset::EF_R64G64_SFLOAT;
default:
return asset::EF_UNKNOWN;
}
};
using ReconstructionKernel = CGaussianImageFilterKernel<>; // or Mitchell
using DerivKernel_ = CDerivativeImageFilterKernel<ReconstructionKernel>;
using DerivKernel = MyKernel<DerivKernel_>;
using XDerivKernel_ = CChannelIndependentImageFilterKernel<DerivKernel, CBoxImageFilterKernel>;
using YDerivKernel_ = CChannelIndependentImageFilterKernel<CBoxImageFilterKernel, DerivKernel>;
using XDerivKernel = SeparateOutXAxisKernel<XDerivKernel_>;
using YDerivKernel = SeparateOutXAxisKernel<YDerivKernel_>;
using DerivativeMapFilter = CBlitImageFilter
<
false, false, DefaultSwizzle, IdentityDither, // (Criss, look at impl::CSwizzleAndConvertImageFilterBase)
XDerivKernel,
YDerivKernel,
CBoxImageFilterKernel
>;
const auto extent = _inImg->getCreationParameters().extent;
const float mlt = static_cast<float>(std::max(extent.width, extent.height));
XDerivKernel xderiv(XDerivKernel_( DerivKernel(DerivKernel_(ReconstructionKernel()), mlt), CBoxImageFilterKernel() ));
YDerivKernel yderiv(YDerivKernel_( CBoxImageFilterKernel(), DerivKernel(DerivKernel_(ReconstructionKernel()), mlt) ));
using swizzle_t = asset::ICPUImageView::SComponentMapping;
DerivativeMapFilter::state_type state(std::move(xderiv), std::move(yderiv), CBoxImageFilterKernel());
state.swizzle = { swizzle_t::ES_R, swizzle_t::ES_R, swizzle_t::ES_R, swizzle_t::ES_R };
const auto& inParams = _inImg->getCreationParameters();
auto outParams = inParams;
outParams.format = getRGformat(outParams.format);
const uint32_t pitch = IImageAssetHandlerBase::calcPitchInBlocks(outParams.extent.width, asset::getTexelOrBlockBytesize(outParams.format));
auto buffer = core::make_smart_refctd_ptr<asset::ICPUBuffer>(asset::getTexelOrBlockBytesize(outParams.format) * pitch * outParams.extent.height);
asset::ICPUImage::SBufferCopy region;
region.imageOffset = { 0,0,0 };
region.imageExtent = outParams.extent;
region.imageSubresource.baseArrayLayer = 0u;
region.imageSubresource.layerCount = 1u;
region.imageSubresource.mipLevel = 0u;
region.bufferRowLength = pitch;
region.bufferImageHeight = 0u;
region.bufferOffset = 0u;
auto outImg = asset::ICPUImage::create(std::move(outParams));
outImg->setBufferAndRegions(std::move(buffer), core::make_refctd_dynamic_array<core::smart_refctd_dynamic_array<IImage::SBufferCopy>>(1ull, region));
state.inOffset = { 0,0,0 };
state.inBaseLayer = 0u;
state.outOffset = { 0,0,0 };
state.outBaseLayer = 0u;
state.inExtent = inParams.extent;
state.outExtent = state.inExtent;
state.inLayerCount = 1u;
state.outLayerCount = 1u;
state.inMipLevel = 0u;
state.outMipLevel = 0u;
state.inImage = _inImg;
state.outImage = outImg.get();
state.axisWraps[0] = _uwrap;
state.axisWraps[1] = _vwrap;
state.axisWraps[2] = asset::ISampler::ETC_CLAMP_TO_EDGE;
state.borderColor = _borderColor;
state.scratchMemoryByteSize = DerivativeMapFilter::getRequiredScratchByteSize(&state);
state.scratchMemory = reinterpret_cast<uint8_t*>(_IRR_ALIGNED_MALLOC(state.scratchMemoryByteSize, _IRR_SIMD_ALIGNMENT));
DerivativeMapFilter::execute(&state);
_IRR_ALIGNED_FREE(state.scratchMemory);
return outImg;
}
void ApplicationHandler::performImageTest(std::string path)
{
os::Printer::log("Reading", path);
auto assetManager = device->getAssetManager();
smart_refctd_ptr<ICPUImageView> cpuImageView;
IAssetLoader::SAssetLoadParams lp(0ull,nullptr,IAssetLoader::ECF_DONT_CACHE_REFERENCES);
auto cpuTexture = assetManager->getAsset(path, lp);
auto cpuTextureContents = cpuTexture.getContents();
if (cpuTextureContents.begin() == cpuTextureContents.end())
{
os::Printer::log("CANNOT PERFORM THE TEST - SKIPPING. LOADING WENT WRONG", ELL_WARNING);
return;
}
io::path filename, extension, finalFileNameWithExtension;
core::splitFilename(path.c_str(), nullptr, &filename, &extension);
finalFileNameWithExtension = filename + ".";
finalFileNameWithExtension += extension;
smart_refctd_ptr<ICPUImageView> copyImageView;
auto asset = *cpuTextureContents.begin();
assert(asset->getAssetType()==IAsset::ET_IMAGE);
auto cpuimage = core::smart_refctd_ptr_static_cast<ICPUImage>(std::move(asset));
cpuimage = createDerivMapFromHeightMap(cpuimage.get(), ISampler::ETC_CLAMP_TO_EDGE, ISampler::ETC_CLAMP_TO_EDGE, ISampler::ETBC_FLOAT_OPAQUE_BLACK);
core::smart_refctd_ptr<video::IGPUImageView> gpuImageView;
{
ICPUImageView::SCreationParams viewParams;
viewParams.flags = static_cast<ICPUImageView::E_CREATE_FLAGS>(0u);
viewParams.image = cpuimage;
viewParams.format = viewParams.image->getCreationParameters().format;
viewParams.viewType = IImageView<ICPUImage>::ET_2D;
viewParams.subresourceRange.baseArrayLayer = 0u;
viewParams.subresourceRange.layerCount = 1u;
viewParams.subresourceRange.baseMipLevel = 0u;
viewParams.subresourceRange.levelCount = 1u;
cpuImageView = ICPUImageView::create(std::move(viewParams));
}
copyImageView = core::smart_refctd_ptr_static_cast<ICPUImageView>(cpuImageView->clone());
gpuImageView = driver->getGPUObjectsFromAssets(&cpuImageView.get(), &cpuImageView.get() + 1u)->front();
if (gpuImageView)
presentImageOnTheScreen(gpuImageView, std::string(filename.c_str()), std::string(extension.c_str()));
auto tryToWrite = [&](asset::IAsset* asset)
{
asset::IAssetWriter::SAssetWriteParams wparams(asset);
return assetManager->writeAsset((io::path("imageAsset_") + finalFileNameWithExtension).c_str(), wparams);
};
if(!tryToWrite(copyImageView->getCreationParameters().image.get()))
if(!tryToWrite(copyImageView.get()))
os::Printer::log("An unexcepted error occoured while trying to write the asset!", irr::ELL_WARNING);
assetManager->removeCachedGPUObject(cpuImageView.get(), gpuImageView);
assetManager->removeAssetFromCache(cpuTexture);
}
bool ApplicationHandler::initializeApplication()
{
irr::SIrrlichtCreationParameters params;
params.Bits = 24;
params.ZBufferBits = 24;
params.DriverType = video::EDT_OPENGL;
params.WindowSize = dimension2d<uint32_t>(1600, 900);
params.Fullscreen = false;
device = createDeviceEx(params);
if (!device)
return false;
driver = device->getVideoDriver();
screenShotFrameBuffer = ext::ScreenShot::createDefaultFBOForScreenshoting(device);
auto fullScreenTriangle = ext::FullScreenTriangle::createFullScreenTriangle(device->getAssetManager(), device->getVideoDriver());
IGPUDescriptorSetLayout::SBinding binding{ 0u, EDT_COMBINED_IMAGE_SAMPLER, 1u, IGPUSpecializedShader::ESS_FRAGMENT, nullptr };
gpuDescriptorSetLayout3 = driver->createGPUDescriptorSetLayout(&binding, &binding + 1u);
auto createGPUPipeline = [&](IImageView<ICPUImage>::E_TYPE type) -> gpuPipeline
{
auto getPathToFragmentShader = [&]()
{
switch (type)
{
case IImageView<ICPUImage>::E_TYPE::ET_2D:
return "../present2D.frag";
case IImageView<ICPUImage>::E_TYPE::ET_2D_ARRAY:
return "../present2DArray.frag";
case IImageView<ICPUImage>::E_TYPE::ET_CUBE_MAP:
return "../presentCubemap.frag";
default:
{
os::Printer::log("Not supported image view in the example!", ELL_ERROR);
return "";
}
}
};
IAssetLoader::SAssetLoadParams lp;
auto fs_bundle = device->getAssetManager()->getAsset(getPathToFragmentShader(), lp);
auto fs_contents = fs_bundle.getContents();
if (fs_contents.begin() == fs_contents.end())
return false;
ICPUSpecializedShader* fs = static_cast<ICPUSpecializedShader*>(fs_contents.begin()->get());
auto fragShader = driver->getGPUObjectsFromAssets(&fs, &fs + 1)->front();
if (!fragShader)
return {};
IGPUSpecializedShader* shaders[2] = { std::get<0>(fullScreenTriangle).get(),fragShader.get() };
SBlendParams blendParams;
blendParams.logicOpEnable = false;
blendParams.logicOp = ELO_NO_OP;
for (size_t i = 0ull; i < SBlendParams::MAX_COLOR_ATTACHMENT_COUNT; i++)
blendParams.blendParams[i].attachmentEnabled = (i == 0ull);
SRasterizationParams rasterParams;
rasterParams.faceCullingMode = EFCM_NONE;
rasterParams.depthCompareOp = ECO_ALWAYS;
rasterParams.minSampleShading = 1.f;
rasterParams.depthWriteEnable = false;
rasterParams.depthTestEnable = false;
auto gpuPipelineLayout = driver->createGPUPipelineLayout(nullptr, nullptr, nullptr, nullptr, nullptr, core::smart_refctd_ptr(gpuDescriptorSetLayout3));
return driver->createGPURenderpassIndependentPipeline(nullptr, std::move(gpuPipelineLayout), shaders, shaders + sizeof(shaders) / sizeof(IGPUSpecializedShader*),
std::get<SVertexInputParams>(fullScreenTriangle), blendParams,
std::get<SPrimitiveAssemblyParams>(fullScreenTriangle), rasterParams);
};
currentGpuPipelineFor2D = createGPUPipeline(IImageView<ICPUImage>::E_TYPE::ET_2D);
{
SBufferBinding<IGPUBuffer> idxBinding{ 0ull, nullptr };
currentGpuMeshBuffer = core::make_smart_refctd_ptr<IGPUMeshBuffer>(nullptr, nullptr, nullptr, std::move(idxBinding));
currentGpuMeshBuffer->setIndexCount(3u);
currentGpuMeshBuffer->setInstanceCount(1u);
}
return true;
} |
lhu $4,8($0)
lw $6,0($0)
sltu $4,$3,$3
lbu $5,0($0)
and $3,$3,$3
srl $5,$3,21
subu $3,$1,$3
sh $3,4($0)
subu $4,$5,$3
sra $5,$3,30
lb $6,1($0)
addu $3,$5,$3
srav $3,$5,$3
subu $4,$4,$3
srlv $5,$2,$3
nor $4,$4,$3
srav $3,$5,$3
sw $4,4($0)
subu $4,$1,$3
addu $5,$4,$3
srlv $3,$4,$3
subu $0,$4,$3
sb $3,4($0)
xori $0,$0,34512
sltu $4,$3,$3
nor $1,$3,$3
sb $4,6($0)
sb $4,7($0)
ori $3,$2,41061
sb $5,4($0)
ori $1,$3,15326
or $4,$3,$3
sllv $5,$0,$3
xor $1,$3,$3
sw $5,16($0)
srlv $5,$4,$3
lw $3,4($0)
srlv $4,$6,$3
sltu $3,$3,$3
addu $6,$6,$3
addu $1,$4,$3
xori $3,$5,34879
or $4,$5,$3
sll $4,$6,13
xori $3,$1,63074
sltu $5,$0,$3
nor $4,$4,$3
sh $4,16($0)
lhu $4,8($0)
ori $3,$0,35485
srl $3,$4,13
addu $5,$1,$3
and $5,$6,$3
addiu $4,$4,28597
sra $4,$4,23
addu $3,$3,$3
lb $1,2($0)
addiu $4,$2,7124
xori $0,$0,43103
addu $5,$5,$3
xori $3,$3,45825
sb $1,16($0)
slti $4,$2,19963
lb $3,5($0)
andi $3,$1,17399
sllv $6,$3,$3
addiu $4,$4,-18463
sltiu $3,$1,30750
sltiu $3,$4,-27637
sra $4,$5,27
lw $3,16($0)
srav $3,$1,$3
subu $5,$3,$3
srlv $4,$4,$3
or $1,$1,$3
sb $5,14($0)
sltu $6,$5,$3
lh $3,8($0)
nor $4,$4,$3
sh $6,10($0)
lh $4,6($0)
addu $4,$4,$3
addiu $3,$1,13876
ori $1,$3,40662
sltu $4,$3,$3
addu $5,$4,$3
srav $3,$5,$3
xor $5,$5,$3
sw $3,0($0)
andi $4,$4,25085
srl $1,$4,8
sltiu $2,$2,-5138
sb $2,10($0)
subu $3,$1,$3
and $4,$3,$3
nor $3,$5,$3
sra $6,$3,8
addu $4,$2,$3
lw $5,12($0)
srl $3,$3,18
subu $5,$5,$3
sh $6,2($0)
addiu $6,$3,30310
ori $6,$3,17754
addiu $4,$5,-17998
lhu $1,12($0)
or $4,$4,$3
sw $5,8($0)
addu $4,$4,$3
slt $0,$0,$3
lbu $3,16($0)
slt $4,$5,$3
and $5,$4,$3
slti $6,$3,32416
addu $3,$4,$3
srav $1,$1,$3
addiu $1,$2,-5816
addiu $3,$3,-26978
sb $3,5($0)
lb $3,13($0)
lh $5,10($0)
sltiu $1,$5,-24683
srlv $5,$0,$3
xor $4,$3,$3
xori $5,$4,34943
sh $3,12($0)
sh $0,12($0)
addiu $5,$1,-2530
sh $3,4($0)
nor $1,$0,$3
sra $5,$5,5
subu $3,$1,$3
subu $0,$3,$3
subu $4,$4,$3
nor $4,$4,$3
lbu $3,8($0)
lhu $0,6($0)
srav $6,$4,$3
lw $4,12($0)
subu $3,$6,$3
sb $3,4($0)
lh $1,8($0)
sra $0,$4,30
srav $3,$3,$3
or $5,$5,$3
sw $5,0($0)
sll $4,$4,13
sb $4,0($0)
slti $1,$1,-14664
lhu $1,2($0)
slt $2,$2,$3
srl $1,$5,10
sllv $5,$3,$3
addu $4,$1,$3
subu $3,$4,$3
addu $4,$3,$3
sra $3,$3,3
addiu $3,$4,-2127
lw $3,4($0)
sltiu $4,$6,-302
ori $4,$5,51764
andi $5,$2,8924
addiu $5,$1,3592
andi $1,$4,31208
or $0,$0,$3
sb $4,7($0)
addiu $5,$1,12700
andi $3,$3,7718
addu $5,$3,$3
xori $6,$5,51545
addu $6,$0,$3
slt $0,$3,$3
sh $5,12($0)
addiu $6,$5,5677
srl $5,$4,20
srav $4,$4,$3
lh $4,10($0)
lhu $4,2($0)
addiu $0,$3,-6863
xor $0,$4,$3
subu $6,$3,$3
addu $4,$2,$3
sll $3,$3,6
lbu $4,16($0)
nor $3,$1,$3
addu $3,$4,$3
sll $4,$4,30
ori $4,$6,38850
sb $0,3($0)
lhu $4,16($0)
lh $5,4($0)
lbu $6,15($0)
and $3,$4,$3
subu $5,$5,$3
lh $3,14($0)
sw $4,4($0)
sllv $0,$4,$3
addu $1,$1,$3
and $1,$4,$3
sltu $4,$4,$3
addu $3,$3,$3
sw $6,12($0)
slt $3,$6,$3
lbu $5,14($0)
nor $4,$6,$3
or $1,$4,$3
srav $3,$3,$3
srlv $1,$4,$3
sb $3,5($0)
sll $4,$4,23
slt $3,$4,$3
srav $5,$4,$3
sltiu $4,$1,2478
sll $1,$1,23
lh $3,12($0)
slt $3,$1,$3
ori $1,$0,3312
sll $4,$3,12
andi $3,$3,32396
xori $4,$1,64946
lbu $4,5($0)
lh $5,12($0)
addu $5,$3,$3
sllv $4,$4,$3
andi $3,$1,52981
sll $4,$5,22
srav $3,$4,$3
srl $1,$4,0
sltiu $1,$5,21255
ori $4,$0,48503
lhu $5,0($0)
lhu $4,2($0)
sltiu $5,$4,8801
sw $1,16($0)
srav $3,$0,$3
sllv $6,$3,$3
addu $3,$3,$3
sll $5,$4,0
or $3,$3,$3
slti $3,$3,8201
lbu $1,5($0)
srlv $1,$3,$3
nor $3,$4,$3
sw $3,4($0)
srlv $4,$1,$3
addu $1,$0,$3
lbu $1,11($0)
andi $1,$3,56671
sw $6,16($0)
addu $0,$1,$3
sb $1,8($0)
sh $4,16($0)
srlv $3,$1,$3
lh $3,2($0)
sllv $3,$3,$3
nor $3,$0,$3
xor $5,$3,$3
lw $6,4($0)
slti $1,$4,-5144
xor $3,$1,$3
subu $4,$3,$3
addiu $5,$5,14876
sllv $4,$4,$3
addiu $3,$1,4725
sllv $4,$3,$3
sltu $3,$3,$3
sltu $1,$3,$3
slt $5,$3,$3
addu $1,$4,$3
subu $3,$5,$3
srlv $4,$3,$3
or $0,$4,$3
addu $6,$6,$3
lbu $3,0($0)
slti $0,$4,-14099
ori $3,$1,38453
srlv $5,$5,$3
lh $5,8($0)
sltu $5,$5,$3
lb $3,2($0)
srlv $5,$3,$3
subu $5,$3,$3
srlv $4,$4,$3
addu $0,$4,$3
xor $3,$3,$3
addiu $4,$5,7072
sw $0,0($0)
xori $4,$3,7343
addu $5,$4,$3
srlv $4,$3,$3
subu $1,$3,$3
andi $4,$4,18830
srlv $3,$4,$3
sllv $5,$3,$3
sh $3,16($0)
sh $1,14($0)
andi $3,$4,49557
sll $5,$1,21
addu $5,$5,$3
sltiu $5,$5,-7559
and $5,$2,$3
slt $5,$1,$3
addu $5,$5,$3
xori $3,$3,21385
sw $4,0($0)
ori $6,$6,33282
sllv $3,$1,$3
subu $4,$4,$3
sra $3,$3,26
sra $3,$4,0
addiu $4,$3,-14058
sh $5,16($0)
andi $1,$4,16129
lh $1,4($0)
sra $1,$1,4
subu $4,$3,$3
xori $1,$3,64352
slt $1,$3,$3
nor $3,$3,$3
subu $3,$1,$3
lh $3,0($0)
or $4,$3,$3
slti $4,$3,-31066
addiu $1,$2,-27429
lbu $4,3($0)
slti $1,$3,-18609
sll $5,$3,3
subu $3,$4,$3
addu $4,$4,$3
or $0,$0,$3
lb $3,2($0)
nor $6,$6,$3
lh $1,4($0)
sllv $1,$1,$3
lb $4,2($0)
addu $5,$4,$3
srav $0,$0,$3
sltu $4,$3,$3
sll $3,$3,3
addiu $0,$0,-31673
lh $6,8($0)
subu $0,$0,$3
sra $4,$2,24
lhu $4,16($0)
sllv $4,$5,$3
sltu $1,$4,$3
andi $0,$0,1381
or $3,$1,$3
and $5,$1,$3
xori $1,$1,43868
addu $3,$1,$3
or $6,$6,$3
sw $1,16($0)
lb $5,13($0)
subu $3,$4,$3
sra $3,$4,15
sra $3,$3,24
subu $1,$1,$3
lb $3,3($0)
sh $6,14($0)
xor $4,$3,$3
addiu $3,$3,-2211
addiu $1,$1,22311
xor $4,$1,$3
addiu $3,$3,8583
sb $6,10($0)
srav $4,$0,$3
slti $3,$4,24750
sw $4,4($0)
subu $0,$4,$3
srav $3,$1,$3
sw $4,8($0)
ori $1,$4,7562
andi $5,$5,63911
or $5,$5,$3
slti $6,$6,25999
subu $1,$3,$3
srl $6,$2,14
lb $1,13($0)
sra $5,$3,14
srlv $6,$3,$3
sb $0,4($0)
sra $4,$0,17
sltu $6,$3,$3
addu $5,$3,$3
xor $1,$5,$3
lh $4,8($0)
sltiu $3,$3,14058
andi $3,$4,39264
sh $5,4($0)
slti $4,$4,20004
sw $5,4($0)
lbu $5,4($0)
sll $5,$3,22
andi $6,$3,29359
lh $4,0($0)
srlv $1,$3,$3
sltu $1,$3,$3
srlv $2,$2,$3
addu $3,$5,$3
sllv $3,$3,$3
slti $4,$3,27543
slti $5,$5,13585
addu $1,$1,$3
andi $6,$1,53977
or $3,$4,$3
srl $6,$3,6
srav $0,$0,$3
lb $4,6($0)
sb $0,3($0)
sw $3,12($0)
sltu $6,$1,$3
addiu $3,$3,-24327
or $0,$3,$3
addu $4,$1,$3
lhu $4,14($0)
sb $1,5($0)
srl $3,$6,6
xor $3,$4,$3
or $1,$1,$3
ori $6,$3,22921
nor $1,$1,$3
andi $1,$4,53521
subu $1,$6,$3
and $4,$4,$3
addiu $3,$3,-23813
srl $4,$4,21
nor $4,$4,$3
lw $6,12($0)
lw $5,4($0)
srl $2,$2,31
lw $4,16($0)
addiu $3,$0,16193
lb $3,14($0)
sltiu $4,$1,-29863
sw $1,12($0)
srlv $0,$3,$3
lh $3,2($0)
sltiu $5,$1,2863
nor $1,$4,$3
xori $6,$3,51325
sllv $1,$3,$3
xori $4,$5,46177
addiu $5,$1,-15252
sltiu $1,$5,-3227
andi $3,$4,16729
xor $0,$3,$3
and $4,$3,$3
sra $1,$0,21
slt $5,$3,$3
nor $3,$3,$3
sllv $4,$3,$3
lb $5,2($0)
sltu $3,$3,$3
addiu $4,$3,-32456
andi $1,$4,16528
lbu $1,10($0)
addiu $4,$3,28425
srav $1,$5,$3
srav $3,$3,$3
srl $3,$3,31
lh $3,16($0)
lw $3,4($0)
slti $0,$5,11235
addu $3,$3,$3
sw $3,0($0)
lbu $0,3($0)
lh $4,2($0)
andi $5,$1,3525
sw $4,8($0)
addiu $3,$4,11364
srav $4,$3,$3
addu $1,$1,$3
nor $6,$3,$3
sw $0,0($0)
and $3,$3,$3
sb $5,14($0)
srav $3,$4,$3
srav $0,$0,$3
sllv $0,$3,$3
ori $3,$3,10159
lw $3,0($0)
sw $4,4($0)
lbu $4,15($0)
sltu $4,$0,$3
sw $4,16($0)
addu $3,$0,$3
sllv $5,$5,$3
sb $6,12($0)
slti $1,$3,21895
and $4,$1,$3
and $3,$4,$3
lw $1,8($0)
xor $0,$5,$3
addiu $4,$4,-14912
sh $4,4($0)
lh $0,16($0)
sra $5,$1,1
nor $1,$4,$3
lh $1,16($0)
xor $5,$3,$3
subu $3,$1,$3
lhu $3,16($0)
sh $1,14($0)
slti $0,$0,-26284
lh $3,0($0)
sb $3,15($0)
lw $3,12($0)
sllv $1,$3,$3
srlv $5,$3,$3
lh $3,10($0)
addiu $6,$6,3258
subu $3,$3,$3
lbu $1,3($0)
nor $4,$6,$3
srl $5,$5,21
addiu $4,$3,-1710
lbu $5,10($0)
addu $1,$3,$3
subu $3,$3,$3
subu $4,$1,$3
andi $1,$0,44728
sltu $3,$3,$3
addu $6,$1,$3
sllv $1,$4,$3
lhu $1,0($0)
subu $1,$0,$3
sb $1,0($0)
srav $3,$3,$3
sb $0,4($0)
srl $1,$3,31
subu $3,$0,$3
lh $0,2($0)
slt $5,$5,$3
sllv $1,$4,$3
addiu $5,$3,15788
slti $4,$3,30954
sltu $5,$0,$3
and $1,$3,$3
xor $4,$1,$3
sllv $6,$3,$3
or $4,$6,$3
nor $5,$5,$3
or $3,$3,$3
sll $5,$1,24
srav $1,$4,$3
nor $3,$3,$3
slti $3,$1,-22762
srl $4,$4,1
xori $3,$6,36339
addiu $3,$4,-23758
addu $3,$3,$3
sllv $3,$4,$3
addu $3,$1,$3
slt $6,$3,$3
sw $1,4($0)
addu $6,$5,$3
sb $5,2($0)
srlv $5,$4,$3
sll $5,$5,8
nor $3,$3,$3
xor $4,$6,$3
subu $4,$3,$3
sllv $4,$3,$3
andi $0,$2,11356
sllv $4,$3,$3
slti $3,$3,2951
srav $3,$4,$3
addu $3,$3,$3
addu $5,$3,$3
xor $3,$3,$3
lhu $0,2($0)
sh $1,2($0)
lw $1,0($0)
sll $0,$4,27
lw $1,12($0)
addu $5,$1,$3
addiu $3,$4,27274
xori $1,$3,14304
and $5,$1,$3
sb $3,4($0)
slti $1,$1,-31275
subu $4,$4,$3
srav $0,$4,$3
xori $5,$1,31831
ori $4,$5,60401
sb $5,11($0)
subu $4,$4,$3
addu $4,$3,$3
lb $3,1($0)
xori $3,$1,57091
xori $0,$1,48987
or $4,$5,$3
andi $3,$3,14056
xori $0,$3,52804
lh $4,6($0)
nor $4,$4,$3
sllv $3,$5,$3
srl $3,$1,10
srl $6,$3,13
or $4,$5,$3
sltu $4,$4,$3
sb $5,7($0)
sh $3,6($0)
lhu $6,0($0)
lw $4,8($0)
subu $4,$5,$3
xor $1,$0,$3
addiu $0,$6,-18439
sllv $4,$1,$3
xor $5,$5,$3
sra $5,$3,27
addu $3,$6,$3
slti $4,$1,32179
xori $5,$1,23519
sll $5,$1,8
or $4,$5,$3
lb $1,14($0)
andi $1,$5,39773
nor $4,$0,$3
sh $5,14($0)
lh $3,2($0)
and $3,$1,$3
sh $3,14($0)
lw $3,4($0)
or $4,$4,$3
sw $3,12($0)
lw $4,12($0)
and $0,$2,$3
slt $5,$3,$3
srlv $3,$4,$3
or $0,$3,$3
sw $5,0($0)
srl $3,$0,17
srav $4,$3,$3
sb $1,8($0)
sw $3,16($0)
lb $3,6($0)
sb $5,2($0)
lbu $4,12($0)
addiu $4,$3,3418
srav $3,$1,$3
xori $4,$5,6637
srlv $4,$4,$3
sh $3,0($0)
addu $3,$6,$3
and $2,$2,$3
lhu $4,8($0)
addiu $3,$4,-3612
slti $3,$3,-19473
addiu $5,$4,-5942
srl $4,$4,7
subu $1,$1,$3
sra $1,$2,23
srlv $4,$4,$3
lbu $5,11($0)
addiu $5,$2,-16808
subu $4,$3,$3
addu $0,$6,$3
nor $5,$5,$3
sw $1,16($0)
ori $5,$3,24621
and $3,$3,$3
and $4,$5,$3
sb $0,7($0)
andi $1,$3,46211
lh $0,6($0)
sll $0,$5,16
subu $4,$4,$3
sra $4,$4,23
lh $0,10($0)
addiu $1,$3,1781
sb $3,0($0)
and $5,$5,$3
sh $3,0($0)
srlv $1,$1,$3
or $4,$4,$3
lhu $3,4($0)
and $6,$5,$3
or $5,$4,$3
sllv $3,$3,$3
sll $6,$1,11
sh $4,6($0)
subu $3,$0,$3
addu $1,$1,$3
subu $5,$5,$3
sra $3,$3,27
addu $3,$3,$3
lh $5,8($0)
sra $1,$1,11
srav $3,$5,$3
slt $5,$4,$3
and $5,$2,$3
lhu $4,14($0)
and $3,$1,$3
addiu $6,$1,19780
srl $3,$3,20
sltiu $1,$1,-2805
subu $3,$4,$3
sltiu $5,$3,28739
nor $5,$5,$3
addu $1,$4,$3
srlv $4,$1,$3
srav $4,$5,$3
sw $3,12($0)
subu $4,$4,$3
addiu $4,$4,5545
and $3,$0,$3
sra $6,$0,17
ori $0,$0,24998
addiu $4,$0,31799
and $1,$5,$3
sra $4,$1,24
sll $1,$3,3
lbu $0,12($0)
sra $3,$5,17
nor $1,$3,$3
lhu $1,10($0)
xori $3,$4,65454
sb $5,3($0)
srlv $5,$2,$3
ori $4,$3,2329
addiu $4,$4,14626
or $4,$2,$3
or $4,$4,$3
xori $4,$3,2136
addiu $0,$3,12991
sllv $5,$3,$3
srl $4,$5,19
sh $3,16($0)
addiu $1,$1,790
sltu $4,$6,$3
subu $3,$5,$3
sh $1,4($0)
or $1,$4,$3
addiu $4,$4,-8404
lh $5,12($0)
sh $4,8($0)
sra $1,$1,22
sltu $0,$6,$3
sltu $4,$0,$3
sw $1,16($0)
srav $5,$4,$3
lh $5,0($0)
and $1,$0,$3
addiu $5,$5,6531
nor $3,$6,$3
slti $3,$4,-9249
lh $3,2($0)
sh $0,14($0)
ori $3,$3,2683
sll $4,$0,25
ori $1,$0,55347
lb $6,5($0)
addiu $4,$4,11839
sra $3,$4,6
or $0,$1,$3
sltiu $1,$4,25558
andi $5,$5,25380
addiu $0,$0,6711
subu $0,$3,$3
nor $4,$4,$3
addiu $4,$5,17950
srl $3,$3,21
or $5,$3,$3
subu $0,$5,$3
sb $3,12($0)
addu $4,$3,$3
subu $6,$3,$3
addiu $3,$0,5130
srav $4,$6,$3
addu $6,$5,$3
or $0,$0,$3
srl $6,$1,14
subu $3,$3,$3
andi $3,$3,16367
andi $5,$5,36568
srlv $5,$4,$3
lhu $3,6($0)
lw $3,8($0)
nor $3,$3,$3
addiu $3,$3,-9602
sllv $1,$1,$3
lb $1,6($0)
sb $5,6($0)
slt $0,$5,$3
or $3,$4,$3
or $3,$3,$3
lbu $3,6($0)
sltu $4,$4,$3
xori $3,$3,31874
xor $3,$5,$3
xori $1,$1,28520
srl $3,$5,20
or $4,$3,$3
lhu $3,0($0)
sltu $5,$5,$3
addiu $6,$1,-1282
nor $5,$6,$3
sltiu $3,$4,-20225
lhu $5,12($0)
lw $4,8($0)
addu $6,$4,$3
lbu $4,11($0)
srav $3,$3,$3
lhu $3,0($0)
lhu $4,4($0)
or $5,$5,$3
sltu $3,$3,$3
sw $3,16($0)
xor $4,$5,$3
xor $4,$1,$3
sb $1,3($0)
lbu $4,8($0)
sllv $3,$3,$3
srl $4,$1,3
lbu $1,2($0)
subu $3,$4,$3
addu $5,$5,$3
slti $5,$5,-17552
ori $3,$1,63510
addiu $5,$4,21437
sw $0,0($0)
slti $1,$4,6598
xor $4,$4,$3
andi $5,$5,29451
or $4,$6,$3
lbu $3,3($0)
slti $5,$1,-21006
sltu $4,$0,$3
lw $1,16($0)
lb $3,0($0)
lbu $5,12($0)
sra $3,$1,27
addiu $3,$3,31809
subu $5,$0,$3
lbu $5,0($0)
sllv $5,$1,$3
sltiu $0,$3,5087
xor $4,$1,$3
nor $0,$5,$3
srav $1,$1,$3
addu $4,$4,$3
lw $5,16($0)
ori $4,$3,56140
lbu $5,1($0)
slt $0,$3,$3
slti $4,$5,-4663
xor $5,$3,$3
subu $3,$4,$3
andi $5,$5,23895
lb $3,2($0)
xori $5,$3,60625
sltu $6,$1,$3
subu $0,$0,$3
xor $3,$4,$3
addu $5,$5,$3
lh $6,12($0)
addu $0,$0,$3
sltu $1,$1,$3
subu $3,$3,$3
andi $5,$1,36201
lbu $5,5($0)
sw $4,0($0)
lbu $6,11($0)
ori $0,$6,11804
slti $3,$3,10560
sra $3,$4,22
sltiu $3,$1,-1910
lhu $4,0($0)
srav $3,$1,$3
srav $5,$4,$3
and $4,$1,$3
lb $4,10($0)
srlv $6,$6,$3
subu $4,$1,$3
sra $3,$5,21
srl $4,$3,19
addiu $4,$4,-6850
slt $4,$0,$3
srlv $4,$3,$3
lbu $3,6($0)
sb $5,12($0)
xori $6,$1,51547
lh $4,16($0)
sra $4,$4,26
lh $6,8($0)
sra $1,$5,19
|
;; Copyright 2019 Chris Smeele
;;
;; 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
;;
;; https://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.
[bits 16]
extern stage2_main
;; Stage2 entrypoint (at 0x7e00).
;; This calls a C++ main function.
stage2_start:
call dword stage2_main
cli
hlt
|
;
; Startup for the CCE MC-1000
;
; Stefano Bodrato - Feb. 2013
;
; $Id: mc1000_crt0.asm,v 1.22 2016-07-15 21:03:25 dom Exp $
;
; There are a couple of #pragma optimization directives
; this file:
;
; #pragma output nostreams - No stdio disc files
MODULE mc1000_crt0
;--------
; Include zcc_opt.def to find out some info
;--------
defc crt0 = 1
INCLUDE "zcc_opt.def"
;--------
; Some scope definitions
;--------
EXTERN _main ;main() is always external to crt0 code
PUBLIC cleanup ;jp'd to by exit()
PUBLIC l_dcal ;jp(hl)
defc CONSOLE_COLUMNS = 32
IF NEED_ansiterminal
defc CONSOLE_ROWS = 24
ELSE
defc CONSOLE_ROWS = 16
ENDIF
IF !DEFINED_CRT_ORG_CODE
IF (startup=2)
defc CRT_ORG_CODE = $100 ; Direct M/C mode, including system variables on top 100h bytes
ELSE
defc CRT_ORG_CODE = 981 ; BASIC startup mode (correct location TBD)
ENDIF
ENDIF
defc TAR__clib_exit_stack_size = 32
defc TAR__register_sp = 0 ; 0 = autodetect
defc __CPU_CLOCK = 3579545
INCLUDE "crt/classic/crt_rules.inc"
INCLUDE "target/mc1000/def/maths_mbf.def"
org CRT_ORG_CODE
IF (startup=2)
; native M/C startup mode
; "TLOAD" mode
;
defb $ff,$ff,$ff
MC_PGM:
MC_PGN:
MC_MUSIC:
defb $ff
MC_PLAY:
defb $01
MC_PLAYMX:
defb $01
MC_HEAD:
defb $00
MC_RANDOM:
defw $ffff
MC_RCRDPT:
defw MC_RECORD
MC_RECORD:
defb $00,$00
defb $00,$00
defb $00,$00
defb $00,$00
defb $00,$00
defb $00,$00
defb $00,$00
defb $00,$00
MC_KEY0:
defb $ff,$ff,$ff,$ff
;
defb $ff
MC_JOB:
ret
defb $ff,$ff
MC_SCOREA:
defb $00
MC_SCOREB:
defb $00
MC_SHAPE0:
defb $ff
;
defb $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
defb $ff,$ff
MC_JOBM:
ret
defb $ff,$ff
;
defb $ff,$ff
MC_TABLE:
MC_NSA:
defw $ffff
MC_NAA:
defw $ffff
MC_AVALUE:
defb $00
VOICEA:
defb $ff
MC_INTRPA:
defb $ff
MC_TEMPA:
defb $ff
MC_INTA:
defb $ff
MC_NSB:
defw $ffff
MC_NBB:
defw $ffff
MC_BVALUE:
defb $00
MC_VOICEB:
defb $ff
MC_INTRPB:
defb $ff
MC_TEMPB:
defb $ff
MC_INTB:
defb $ff
MC_NSC:
defw $ffff
MC_NCC:
defw $ffff
MC_CVALUE:
defb $00
MC_VOICEC:
defb $ff
MC_INTRPC:
defb $ff
MC_TEMPC:
defb $ff
MC_INTC:
defb $ff
MC_ENABLE:
defb $ff
MC_AMPLIT:
defb $ff
MC_REGIST:
defw $ffff
MC_DEFIN:
defb $ff
MC_ONAMP:
defw $ffff
MC_LPLAY:
defb $ff
;
defb $ff,$ff,$ff,$ff,$ff,$ff
MC_CHECK:
defb $00
;
defb $ff,$ff,$ff,$ff
MC_DSNAM:
defw $8000
MC_DENAM:
defw $8200
MC_HISCOR:
defw $ffff
MC_TEMP:
defb $ff
;
defb $ff,$ff
MC_RIGHTJ:
defb $ff
MC_CHANA:
defw $ffff
;
defb $ff,$ff,$ff
MC_TONEA:
defb $ff
MC_CHANB:
defw $ffff
;
defb $ff,$ff,$ff
MC_TONEB:
defb $ff
MC_CHANC:
defw $ffff
;
defb $ff,$ff,$ff
MC_TONEC:
defb $ff
MC_OBUF:
defb $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
defb $ff,$ff,$ff,$ff,$ff,$ff
MC_FILNAM:
defb $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
defb $ff,$ff,$ff,$ff,$ff,$ff
;
defb $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
defb $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
defb $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
defb $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
defb $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
defb $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
defb $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
defb $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
defb $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
defb $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
defb $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
defb $ff,$ff,$ff,$ff,$ff,$ff,$ff,$ff
defb $ff,$ff,$ff,$ff,$ff
; ; At position 200h different 'topics' (entries)
; ; can be defined; user can choose the topic CTRL-H
; jp start
;..on the other side the first topic can be directly
; the main program entry point, so no need for a jump table :P
ELSE
; BASIC startup mode
defw nxt_basic_line
defw 0 ; BASIC Line number
defb $a2 ; Token for CALL.
defm "992" ; this BASIC caller stub is 11 bytes long
defb 0 ; End of line
nxt_basic_line:
defw 0
ENDIF
start:
ld hl,($39)
ld (irq_hndl+1),hl
ld hl,mc_irq
ld ($39),hl
;CALL $CEBA
;LD ($0128),A
;LD ($0357),A
;LD ($0360),A
;LD ($0358),A
;LD ($0352),A
;LD ($0361),A
;DEC A
;LD ($0106),A
;LD ($0353),A
;LD ($106),a
;ld hl,$106
;ld (hl),255 ; disable gaming mode (shouldn't this work by putting 255??)
ld (start1+1),sp
IF __register_sp == 0
ld hl,$bfff ; 48K ?
ld (hl),$55
ld a,$AA
or (hl)
inc a
jr z,has48k
ld hl,$3fff ; 48K.
has48k:
ld sp,hl
UNDEFINE __register_sp
defc __register_sp = -1
ENDIF
;ei
;xor a
;out ($80),a
;call $c021 ; setup text page (ptr in HL)
INCLUDE "crt/classic/crt_init_sp.asm"
INCLUDE "crt/classic/crt_init_atexit.asm"
call crt0_init_bss
ld (exitsp),sp
IF DEFINED_USING_amalloc
INCLUDE "crt/classic/crt_init_amalloc.asm"
ENDIF
call _main
cleanup:
;
; Deallocate memory which has been allocated here!
;
push hl
call crt0_exit
pop bc
start1:
ld sp,0
IF (startup=2)
;jp $C000 ; BASIC entry (COLD RESET)
jp $C003 ; BASIC entry (WARM RESET)
ELSE
ld hl,(irq_hndl+1)
ld ($39),hl
ret
ENDIF
l_dcal:
jp (hl)
; IRQ stub to get a time counter
mc_irq:
di
push hl
push af
ld hl,(FRAMES)
inc hl
ld (FRAMES),hl
ld a,h
or l
jr nz,irq_hndl
ld hl,(FRAMES+2)
inc hl
ld (FRAMES+2),hl
irq_hndl:
ld hl,0
;jp $7f
pop af
ex (sp),hl
ret
; If we were given an address for the BSS then use it
IF DEFINED_CRT_ORG_BSS
defc __crt_org_bss = CRT_ORG_BSS
ENDIF
INCLUDE "crt/classic/crt_runtime_selection.asm"
INCLUDE "crt/classic/crt_section.asm"
SECTION bss_crt
PUBLIC FRAMES
FRAMES:
defw 0
defw 0
|
; A037105: Trajectory of 3 under map n->15n+1 if n odd, n->n/2 if n even
; Submitted by Jon Maiga
; 3,46,23,346,173,2596,1298,649,9736,4868,2434,1217,18256,9128,4564,2282,1141,17116,8558,4279,64186,32093,481396,240698,120349,1805236,902618,451309,6769636,3384818,1692409
add $0,1
mov $1,$0
mov $0,3
lpb $1
mov $2,$0
mod $2,2
add $3,1
sub $3,$2
mov $4,$0
lpb $2
mul $0,5
add $0,1
mul $0,3
sub $0,2
sub $2,1
lpe
lpb $3
div $0,2
sub $3,1
lpe
sub $1,1
lpe
mov $0,$4
|
#ifndef INCLUDED_SROOK_UTILITY_EXCHANGE_HPP
#define INCLUDED_SROOK_UTILITY_EXCHANGE_HPP
#include <srook/config/feature/inline_namespace.hpp>
#include <srook/config/noexcept_detection.hpp>
#include <srook/type_traits/is_nothrow_move_constructible.hpp>
#include <srook/type_traits/is_nothrow_assignable.hpp>
#include <srook/utility/forward.hpp>
#include <srook/utility/move.hpp>
namespace srook {
namespace utility {
SROOK_INLINE_NAMESPACE(v1)
template <class T, class U = T>
inline T exchange(T& o, U&& new_value)
SROOK_NOEXCEPT(
is_nothrow_move_constructible<T>::value &&
is_nothrow_move_constructible<U>::value &&
is_nothrow_assignable<T>::value
)
{
T oldval = srook::move(o);
o = srook::forward<U>(new_value);
return oldval;
}
SROOK_INLINE_NAMESPACE_END
} // utility
using utility::exchange;
} // namespace srook
#endif
|
;
; MicroBEE pseudo graphics routines
;
; cls () -- clear screen
;
; Stefano Bodrato - 2016
;
;
; $Id: w_clg_320.asm,v 1.3 2017/01/02 21:51:24 aralbrec Exp $
;
SECTION code_clib
PUBLIC clg
PUBLIC _clg
EXTERN cleargraphics
EXTERN swapgfxbk
.vdutab ; 40x24
defb $35,40,$2D,$24,$1b,$05,$19,$1a,$48,$0a,$2a,$0a,$20,0,0,0
.clg
._clg
call swapgfxbk
defb $3E, 1, $DB, 9 ;{HALVES VIDEO CLOCK SPEED}
; Set 80x25 mode
LD HL,vdutab
LD C,0
LD B,16
.vdloop
LD A,C
OUT ($0C),A
LD A,(HL)
OUT ($0D),A
INC HL
INC C
DJNZ vdloop
ld a,128
out ($1c),a ; Enable Premium Graphics
; Init character and attribute map
ld hl,$f000
ld de,40
xor a ; bank #0
;ld a,64 ; "Inverse" attribute bit, start on bank #0
ex af,af
ld b,8 ; 16K mode: 8 banks (5 columns per bank)
.bank
;xor a ; chr 0
ld a,128 ; PCG character #0
push bc
ld c,5
.five_col
push hl
ld b,25
.one_col
ld (hl),a
inc a
push af
ld a,128+16
out ($1c),a ; attribute page
ex af,af
ld (hl),a
ex af,af
ld a,128
out ($1c),a ; back to txt page
pop af
add hl,de
djnz one_col
pop hl
inc hl ; next column
dec c
jr nz,five_col
pop bc
ex af,af
inc a ; point to next bank
ex af,af
djnz bank
jp cleargraphics
|
;/*!
; @file
;
; @ingroup fapi
;
; @brief DosCreateThread DOS wrapper
;
; (c) osFree Project 2022, <http://www.osFree.org>
; for licence see licence.txt in root directory, or project website
;
; This is Family API implementation for DOS, used with BIND tools
; to link required API
;
; @author Yuri Prokushev (yuri.prokushev@gmail.com)
;
;
;
;*/
.8086
; Helpers
INCLUDE HELPERS.INC
_TEXT SEGMENT BYTE PUBLIC 'CODE' USE16
@PROLOG DOSCREATETHREAD
@START DOSCREATETHREAD
XOR AX, AX
EXIT:
@EPILOG DOSCREATETHREAD
_TEXT ENDS
END
|
/*
___ ___ __ __ ____________
| | | | |__|__|__ ___/ Ubiquitout Internet @ IIT-CNR
| | | | /__/ / / / C++ ETSI MEC library
| | | |/__/ / / / https://github.com/ccicconetti/wsk/
|_______|__|__/__/ /__/
Licensed under the MIT License <http://opensource.org/licenses/MIT>.
Copyright (c) 2019 Claudio Cicconetti https://ccicconetti.github.io/
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.
*/
#include "lister.h"
#include "Rest/client.h"
#include <glog/logging.h>
#include <stdexcept>
namespace uiiit {
namespace wsk {
Lister::Lister(const std::string& aApiRoot, const std::string& aAuth)
: Command(aApiRoot, aAuth) {
// noop
}
std::map<ActionKey, Action> Lister::operator()(const size_t aLimit,
const size_t aSkip) const {
VLOG(1) << "request to list " << theApiRoot << " with limit " << aLimit
<< ", skip " << aSkip;
std::map<ActionKey, Action> ret;
rest::Client myClient(theApiRoot, true);
myClient.changeHeader("Authorization", theAuth);
const auto res = myClient.get(thePath + "_/actions/", makeQuery(aLimit, aSkip));
if (res.first != web::http::status_codes::OK) {
throw std::runtime_error("unexpected HTTP response: " +
std::to_string(res.first));
} else if (not res.second.is_array()) {
throw std::runtime_error("unexpected response: not an array");
}
for (const auto& elem : res.second.as_array()) {
if (not elem.is_object() or not elem.has_string_field("name") or
not elem.has_string_field("namespace") or
not elem.has_number_field("updated") or
not elem.has_string_field("version")) {
throw std::runtime_error("unexpected response: mandatory field missing");
}
const Action myAction(elem.at("namespace").as_string(),
elem.at("name").as_string(),
elem.at("updated").as_number().to_uint64(),
elem.at("version").as_string());
ret.emplace(myAction.key(), myAction);
}
return ret;
}
std::string Lister::makeQuery(const size_t aLimit, const size_t aSkip) {
return std::string("limit=") + std::to_string(aLimit) +
"&skip=" + std::to_string(aSkip);
}
} // namespace wsk
} // namespace uiiit
|
/***************************************************************************
* Name: Casey Cole
* Email: coleca@email.sc.edu
* Function: Main driver for Account object
*
* Copyright (C) 2020 by Casey Cole *
* *
***************************************************************************/
#include <cstdlib>
#include <iostream>
#include <string>
#include "Account.h"
float* insert(float*,int&,int,float);
int main(int argc, char** argv)
{
Account acct1;
Account acct2(1000, "Casey");
acct1.print();
acct2.print();
Account acct3(acct1);
acct3.print();
return 0;
}
|
; A134986: a(n) = smallest integer m not equal to n such that n = (floor(n^2/m) + m)/2.
; 2,3,2,3,4,5,5,6,7,8,9,10,10,11,12,13,14,15,16,17,17,18,19,20,21,22,23,24,25,26,26,27,28,29,30,31,32,33,34,35,36,37,37,38,39,40,41,42,43,44,45,46,47,48,49,50,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,82,83,84,85,86,87,88,89,90,91
mov $1,$0
mov $2,4
lpb $1,2
sub $0,1
trn $1,2
sub $2,2
add $1,$2
lpe
add $0,2
|
; A141974: Primes congruent to 23 mod 28.
; 23,79,107,163,191,331,359,443,499,751,863,919,947,1031,1087,1171,1283,1367,1423,1451,1619,1759,1787,1871,2011,2039,2179,2207,2347,2459,2543,2683,2711,2767,2851,2879,2963,3019,3187,3271,3299,3467,3607,3691,3719,3803,3943,4027,4111,4139,4363,4391,4447,4643,4783,4951,5119,5147,5231,5399,5483,5623,5651,5791,5903,5987,6043,6211,6323,6379,6491,6547,6659,6827,6883,6911,6967,7079,7219,7247,7331,7499,7583,7639,7723,7919,8059,8087,8171,8311,8423,8563,8647,8731,9011,9067,9151,9319,9403,9431
mov $2,$0
add $2,1
pow $2,2
lpb $2
add $1,22
sub $2,1
mov $3,$1
seq $3,10051 ; Characteristic function of primes: 1 if n is prime, else 0.
sub $0,$3
add $1,6
mov $4,$0
max $4,0
cmp $4,$0
mul $2,$4
lpe
div $1,2
sub $1,22
mul $1,2
add $1,39
mov $0,$1
|
#include <iostream>
#include "DisplayMessage.h"
int main() {
std::cout << "Welcome!" << std::endl;
displayMessage();
return 0;
}
|
; A080522: Leading diagonal of triangle in A080521.
; 1,3,5,10,22,49,107,228,476,979,1993,4030,8114,16293,32663,65416,130936,261991,524117,1048386,2096942,4194073,8388355,16776940,33554132,67108539,134217377,268435078,536870506,1073741389,2147483183,4294966800,8589934064,17179868623,34359737773,68719476106,137438952806,274877906241,549755813147,1099511626996,2199023254732,4398046510243,8796093021305,17592186043470,35184372087842,70368744176629,140737488354247,281474976709528,562949953420136,1125899906841399,2251799813683973,4503599627369170,9007199254739614
mov $1,1
lpb $0
mul $1,2
add $1,1
add $3,$0
sub $0,1
mov $2,4
lpe
add $2,1
add $1,$2
trn $1,5
add $1,3
sub $1,$3
sub $1,2
|
println "begin"
println 42, 1 2 3 4
for n, 5
println "start {d:n}"
println syntax error
println "finish {d:n}"
endr
println "end {d:n}"
|
; ==================================================================================================
; === STACK MACROS
; ==================================================================================================
macro m6_popbuffer
pop af ; 10
pop bc ; 10
pop de ; 10
pop hl ; 10
exx ; 4
pop bc ; 10
pop de ; 10
pop hl ; 10
pop ix ; 14
endm ; 88 total
macro m6_pushbuffer
push ix ; 15
push hl ; 11
push de ; 11
push bc ; 11
exx ; 4
push hl ; 11
push de ; 11
push bc ; 11
push af ; 11
endm ; 96 total
; ==================================================================================================
; === COPY 3D BUFFER TO SCREEN
; ==================================================================================================
m6_buffercopy:
; Copies the contents of the view buffer to the screen.
; Timings given below do not account for memory contention.
; Thanks to Jonathan Cauldwell for the double-buffering chapter of his Spectrum programming
; tutorial, without which I probably would've wound up using a less efficient method.
di ; 4
ld (m6_buffercopy_sp+1),sp ; 20 - Preserve stack pointer for later use
; LINE 00 ==========================================================================================
ld sp,m6_gfxbuffer+1248 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg1+c6+p0+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg1+c6+p1+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+1248+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg1+c6+p0+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg1+c6+p1+h2 ; 10
m6_pushbuffer ; 96
; LINE 01 ==========================================================================================
ld sp,m6_gfxbuffer+1216 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg1+c6+p2+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg1+c6+p3+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+1216+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg1+c6+p2+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg1+c6+p3+h2 ; 10
m6_pushbuffer ; 96
; LINE 02 ==========================================================================================
ld sp,m6_gfxbuffer+1184 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg1+c6+p4+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg1+c6+p5+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+1184+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg1+c6+p4+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg1+c6+p5+h2 ; 10
m6_pushbuffer ; 96
; LINE 03 ==========================================================================================
ld sp,m6_gfxbuffer+1152 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg1+c6+p6+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg1+c6+p7+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+1152+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg1+c6+p6+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg1+c6+p7+h2 ; 10
m6_pushbuffer ; 96
; LINE 04 ==========================================================================================
ld sp,m6_gfxbuffer+1120 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg1+c7+p0+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg1+c7+p1+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+1120+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg1+c7+p0+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg1+c7+p1+h2 ; 10
m6_pushbuffer ; 96
; LINE 05 ==========================================================================================
ld sp,m6_gfxbuffer+1088 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg1+c7+p2+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg1+c7+p3+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+1088+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg1+c7+p2+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg1+c7+p3+h2 ; 10
m6_pushbuffer ; 96
; LINE 06 ==========================================================================================
ld sp,m6_gfxbuffer+1056 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg1+c7+p4+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg1+c7+p5+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+1056+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg1+c7+p4+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg1+c7+p5+h2 ; 10
m6_pushbuffer ; 96
; LINE 07 ==========================================================================================
ld sp,m6_gfxbuffer+1024 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg1+c7+p6+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg1+c7+p7+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+1024+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg1+c7+p6+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg1+c7+p7+h2 ; 10
m6_pushbuffer ; 96
; LINE 08 ==========================================================================================
ld sp,m6_gfxbuffer+992 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c0+p0+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c0+p1+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+992+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c0+p0+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c0+p1+h2 ; 10
m6_pushbuffer ; 96
; LINE 09 ==========================================================================================
ld sp,m6_gfxbuffer+960 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c0+p2+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c0+p3+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+960+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c0+p2+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c0+p3+h2 ; 10
m6_pushbuffer ; 96
; LINE 10 ==========================================================================================
ld sp,m6_gfxbuffer+928 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c0+p4+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c0+p5+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+928+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c0+p4+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c0+p5+h2 ; 10
m6_pushbuffer ; 96
; LINE 11 ==========================================================================================
ld sp,m6_gfxbuffer+896 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c0+p6+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c0+p7+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+896+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c0+p6+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c0+p7+h2 ; 10
m6_pushbuffer ; 96
; LINE 12 ==========================================================================================
ld sp,m6_gfxbuffer+864 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c1+p0+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c1+p1+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+864+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c1+p0+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c1+p1+h2 ; 10
m6_pushbuffer ; 96
; LINE 13 ==========================================================================================
ld sp,m6_gfxbuffer+832 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c1+p2+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c1+p3+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+832+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c1+p2+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c1+p3+h2 ; 10
m6_pushbuffer ; 96
; LINE 14 ==========================================================================================
ld sp,m6_gfxbuffer+800 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c1+p4+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c1+p5+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+800+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c1+p4+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c1+p5+h2 ; 10
m6_pushbuffer ; 96
; LINE 15 ==========================================================================================
ld sp,m6_gfxbuffer+768 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c1+p6+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c1+p7+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+768+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c1+p6+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c1+p7+h2 ; 10
m6_pushbuffer ; 96
; LINE 16 ==========================================================================================
ld sp,m6_gfxbuffer+736 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c2+p0+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c2+p1+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+736+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c2+p0+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c2+p1+h2 ; 10
m6_pushbuffer ; 96
; LINE 17 ==========================================================================================
ld sp,m6_gfxbuffer+704 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c2+p2+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c2+p3+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+704+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c2+p2+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c2+p3+h2 ; 10
m6_pushbuffer ; 96
; LINE 18 ==========================================================================================
ld sp,m6_gfxbuffer+672 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c2+p4+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c2+p5+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+672+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c2+p4+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c2+p5+h2 ; 10
m6_pushbuffer ; 96
; LINE 19 ==========================================================================================
ld sp,m6_gfxbuffer+640 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c2+p6+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c2+p7+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+640+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c2+p6+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c2+p7+h2 ; 10
m6_pushbuffer ; 96
; LINE 20 ==========================================================================================
ld sp,m6_gfxbuffer+608 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c3+p0+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c3+p1+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+608+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c3+p0+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c3+p1+h2 ; 10
m6_pushbuffer ; 96
; LINE 21 ==========================================================================================
ld sp,m6_gfxbuffer+576 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c3+p2+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c3+p3+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+576+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c3+p2+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c3+p3+h2 ; 10
m6_pushbuffer ; 96
; LINE 22 ==========================================================================================
ld sp,m6_gfxbuffer+544 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c3+p4+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c3+p5+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+544+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c3+p4+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c3+p5+h2 ; 10
m6_pushbuffer ; 96
; LINE 23 ==========================================================================================
ld sp,m6_gfxbuffer+512 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c3+p6+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c3+p7+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+512+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c3+p6+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c3+p7+h2 ; 10
m6_pushbuffer ; 96
; LINE 24 ==========================================================================================
ld sp,m6_gfxbuffer+480 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c4+p0+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c4+p1+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+480+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c4+p0+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c4+p1+h2 ; 10
m6_pushbuffer ; 96
; LINE 25 ==========================================================================================
ld sp,m6_gfxbuffer+448 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c4+p2+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c4+p3+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+448+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c4+p2+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c4+p3+h2 ; 10
m6_pushbuffer ; 96
; LINE 26 ==========================================================================================
ld sp,m6_gfxbuffer+416 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c4+p4+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c4+p5+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+416+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c4+p4+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c4+p5+h2 ; 10
m6_pushbuffer ; 96
; LINE 27 ==========================================================================================
ld sp,m6_gfxbuffer+384 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c4+p6+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c4+p7+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+384+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c4+p6+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c4+p7+h2 ; 10
m6_pushbuffer ; 96
; LINE 28 ==========================================================================================
ld sp,m6_gfxbuffer+352 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c5+p0+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c5+p1+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+352+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c5+p0+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c5+p1+h2 ; 10
m6_pushbuffer ; 96
; LINE 29 ==========================================================================================
ld sp,m6_gfxbuffer+320 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c5+p2+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c5+p3+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+320+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c5+p2+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c5+p3+h2 ; 10
m6_pushbuffer ; 96
; LINE 30 ==========================================================================================
ld sp,m6_gfxbuffer+288 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c5+p4+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c5+p5+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+288+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c5+p4+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c5+p5+h2 ; 10
m6_pushbuffer ; 96
; LINE 31 ==========================================================================================
ld sp,m6_gfxbuffer+256 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c5+p6+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c5+p7+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+256+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c5+p6+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c5+p7+h2 ; 10
m6_pushbuffer ; 96
; LINE 32 ==========================================================================================
ld sp,m6_gfxbuffer+224 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c6+p0+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c6+p1+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+224+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c6+p0+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c6+p1+h2 ; 10
m6_pushbuffer ; 96
; LINE 33 ==========================================================================================
ld sp,m6_gfxbuffer+192 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c6+p2+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c6+p3+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+192+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c6+p2+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c6+p3+h2 ; 10
m6_pushbuffer ; 96
; LINE 34 ==========================================================================================
ld sp,m6_gfxbuffer+160 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c6+p4+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c6+p5+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+160+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c6+p4+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c6+p5+h2 ; 10
m6_pushbuffer ; 96
; LINE 35 ==========================================================================================
ld sp,m6_gfxbuffer+128 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c6+p6+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c6+p7+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+128+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c6+p6+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c6+p7+h2 ; 10
m6_pushbuffer ; 96
; LINE 36 ==========================================================================================
ld sp,m6_gfxbuffer+96 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c7+p0+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c7+p1+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+96+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c7+p0+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c7+p1+h2 ; 10
m6_pushbuffer ; 96
; LINE 37 ==========================================================================================
ld sp,m6_gfxbuffer+64 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c7+p2+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c7+p3+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+64+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c7+p2+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c7+p3+h2 ; 10
m6_pushbuffer ; 96
; LINE 38 ==========================================================================================
ld sp,m6_gfxbuffer+32 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c7+p4+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c7+p5+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+32+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c7+p4+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c7+p5+h2 ; 10
m6_pushbuffer ; 96
; LINE 39 ==========================================================================================
ld sp,m6_gfxbuffer ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c7+p6+h1 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c7+p7+h1 ; 10
m6_pushbuffer ; 96
ld sp,m6_gfxbuffer+16 ; 10
m6_popbuffer ; 88
ld sp,m6_screen+seg2+c7+p6+h2 ; 10
m6_pushbuffer ; 96
exx ; 4
ld sp,m6_screen+seg2+c7+p7+h2 ; 10
m6_pushbuffer ; 96
m6_buffercopy_sp:
ld sp,0 ; 10 - Restore stack pointer
ei ; 4
ret ; 10
; 25168 T-states total (w/o contention)
; ==================================================================================================
; === BUFFER COPY CONSTANTS
; ==================================================================================================
m6_screen: equ 16384
seg0: equ 0
seg1: equ 2048
seg2: equ 4096
c0: equ 0
c1: equ 32
c2: equ 64
c3: equ 96
c4: equ 128
c5: equ 160
c6: equ 192
c7: equ 224
p0: equ 0
p1: equ 256
p2: equ 512
p3: equ 768
p4: equ 1024
p5: equ 1280
p6: equ 1536
p7: equ 1792
h1: equ 16
h2: equ 32
|
// Copyright 2021 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include <string>
#include <utility>
#include <base/files/file_util.h>
#include <base/memory/scoped_refptr.h>
#include <base/test/task_environment.h>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "rmad/proto_bindings/rmad.pb.h"
#include "rmad/state_handler/state_handler_test_common.h"
#include "rmad/state_handler/welcome_screen_state_handler.h"
#include "rmad/system/mock_hardware_verifier_client.h"
#include "rmad/utils/json_store.h"
using testing::_;
using testing::Invoke;
using testing::NiceMock;
using testing::Return;
using testing::StrictMock;
namespace rmad {
class WelcomeScreenStateHandlerTest : public StateHandlerTest {
public:
// Helper class to mock the callback function to send signal.
class SignalSender {
public:
MOCK_METHOD(void,
SendHardwareVerificationResultSignal,
(const HardwareVerificationResult&),
(const));
};
scoped_refptr<WelcomeScreenStateHandler> CreateStateHandler(
int hw_verification_result) {
// Mock |HardwareVerifierClient|.
auto mock_hardware_verifier_client =
std::make_unique<NiceMock<MockHardwareVerifierClient>>();
ON_CALL(*mock_hardware_verifier_client, GetHardwareVerificationResult(_))
.WillByDefault(
[hw_verification_result](HardwareVerificationResult* result) {
if (hw_verification_result == 0) {
result->set_is_compliant(false);
result->set_error_str("mock_hardware_verifier_error_string");
return true;
} else if (hw_verification_result == 1) {
result->set_is_compliant(true);
result->set_error_str("mock_hardware_verifier_error_string");
return true;
} else {
return false;
}
});
auto handler = base::MakeRefCounted<WelcomeScreenStateHandler>(
json_store_, std::move(mock_hardware_verifier_client));
auto callback =
base::BindRepeating(&SignalSender::SendHardwareVerificationResultSignal,
base::Unretained(&signal_sender_));
handler->RegisterSignalSender(callback);
return handler;
}
protected:
StrictMock<SignalSender> signal_sender_;
// Variables for TaskRunner.
base::test::TaskEnvironment task_environment_;
};
TEST_F(WelcomeScreenStateHandlerTest,
InitializeState_Success_VerificationPass_DoGetStateTask) {
auto handler = CreateStateHandler(1);
EXPECT_EQ(handler->InitializeState(), RMAD_ERROR_OK);
EXPECT_CALL(signal_sender_, SendHardwareVerificationResultSignal(_))
.WillOnce(Invoke([](const HardwareVerificationResult& result) {
EXPECT_EQ(result.is_compliant(), true);
EXPECT_EQ(result.error_str(), "mock_hardware_verifier_error_string");
}));
RmadState state = handler->GetState(true);
task_environment_.RunUntilIdle();
}
TEST_F(WelcomeScreenStateHandlerTest,
InitializeState_Success_VerificationPass_NoGetStateTask) {
auto handler = CreateStateHandler(1);
EXPECT_EQ(handler->InitializeState(), RMAD_ERROR_OK);
RmadState state = handler->GetState();
}
TEST_F(WelcomeScreenStateHandlerTest,
InitializeState_Success_VerificationFail) {
auto handler = CreateStateHandler(0);
EXPECT_EQ(handler->InitializeState(), RMAD_ERROR_OK);
}
TEST_F(WelcomeScreenStateHandlerTest,
InitializeState_Success_VerificationCallFail) {
auto handler = CreateStateHandler(-1);
EXPECT_EQ(handler->InitializeState(), RMAD_ERROR_OK);
task_environment_.RunUntilIdle();
}
TEST_F(WelcomeScreenStateHandlerTest, GetNextStateCase_Success) {
auto handler = CreateStateHandler(-1);
EXPECT_EQ(handler->InitializeState(), RMAD_ERROR_OK);
auto welcome = std::make_unique<WelcomeState>();
welcome->set_choice(WelcomeState::RMAD_CHOICE_FINALIZE_REPAIR);
RmadState state;
state.set_allocated_welcome(welcome.release());
auto [error, state_case] = handler->GetNextStateCase(state);
EXPECT_EQ(error, RMAD_ERROR_OK);
EXPECT_EQ(state_case, RmadState::StateCase::kComponentsRepair);
task_environment_.RunUntilIdle();
}
TEST_F(WelcomeScreenStateHandlerTest, GetNextStateCase_MissingState) {
auto handler = CreateStateHandler(-1);
EXPECT_EQ(handler->InitializeState(), RMAD_ERROR_OK);
// No WelcomeScreenState.
RmadState state;
auto [error, state_case] = handler->GetNextStateCase(state);
EXPECT_EQ(error, RMAD_ERROR_REQUEST_INVALID);
EXPECT_EQ(state_case, RmadState::StateCase::kWelcome);
task_environment_.RunUntilIdle();
}
TEST_F(WelcomeScreenStateHandlerTest, GetNextStateCase_MissingArgs) {
auto handler = CreateStateHandler(-1);
EXPECT_EQ(handler->InitializeState(), RMAD_ERROR_OK);
auto welcome = std::make_unique<WelcomeState>();
welcome->set_choice(WelcomeState::RMAD_CHOICE_UNKNOWN);
RmadState state;
state.set_allocated_welcome(welcome.release());
auto [error, state_case] = handler->GetNextStateCase(state);
EXPECT_EQ(error, RMAD_ERROR_REQUEST_ARGS_MISSING);
EXPECT_EQ(state_case, RmadState::StateCase::kWelcome);
task_environment_.RunUntilIdle();
}
} // namespace rmad
|
; float __schar2fs_callee(signed char sc)
SECTION code_fp_math48
PUBLIC cm48_sdcciyp_schar2ds_callee
EXTERN am48_double8, cm48_sdcciyp_m482d
cm48_sdcciyp_schar2ds_callee:
; signed char to double
;
; enter : stack = signed char sc, ret
;
; exit : dehl = sdcc_float(sc)
;
; uses : af, bc, de, hl, bc', de', hl'
pop af
pop hl
dec sp
push af
call am48_double8
jp cm48_sdcciyp_m482d
|
#include "NonIndirectLayout.h"
#include "Device.h"
#include "VulkanInitializers.h"
#include "VulkanGltf.h"
#include "Texture.h"
#include "Buffer.h"
#include "VulkanDebug.h"
namespace genesis
{
NonIndirectLayout::NonIndirectLayout(Device* device)
: _device(device)
{
// nothing else to do
}
NonIndirectLayout::~NonIndirectLayout()
{
vkDestroyDescriptorPool(_device->vulkanDevice(), _descriptorPool, nullptr);
vkDestroyDescriptorSetLayout(_device->vulkanDevice(), _descriptorSetLayout, nullptr);
}
void NonIndirectLayout::build(const VulkanGltfModel* model)
{
setupDescriptorPool(model);
setupDescriptorSetLayout(model);
updateDescriptorSets(model);
}
void NonIndirectLayout::setupDescriptorPool(const VulkanGltfModel* model)
{
std::vector<VkDescriptorPoolSize> poolSizes = {};
const std::vector<Texture*>& textures = model->textures();
poolSizes.push_back(genesis::VulkanInitializers::descriptorPoolSize(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, (uint32_t)textures.size()));
const uint32_t maxSets = (uint32_t)textures.size();
VkDescriptorPoolCreateInfo descriptorPoolCreateInfo = genesis::VulkanInitializers::descriptorPoolCreateInfo(poolSizes, maxSets);
VK_CHECK_RESULT(vkCreateDescriptorPool(_device->vulkanDevice(), &descriptorPoolCreateInfo, nullptr, &_descriptorPool));
}
void NonIndirectLayout::setupDescriptorSetLayout(const VulkanGltfModel* model)
{
std::vector<VkDescriptorSetLayoutBinding> setBindings = {};
uint32_t bindingIndex = 0;
VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo;
setBindings.push_back(genesis::VulkanInitializers::descriptorSetLayoutBinding(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_SHADER_STAGE_FRAGMENT_BIT, bindingIndex++));
descriptorSetLayoutCreateInfo = genesis::VulkanInitializers::descriptorSetLayoutCreateInfo(setBindings.data(), static_cast<uint32_t>(setBindings.size()));
VK_CHECK_RESULT(vkCreateDescriptorSetLayout(_device->vulkanDevice(), &descriptorSetLayoutCreateInfo, nullptr, &_descriptorSetLayout));
}
void NonIndirectLayout::updateDescriptorSets(const VulkanGltfModel* model)
{
const std::vector<Texture*>& textures = model->textures();
for (int i = 0; i < textures.size(); ++i)
{
const VkDescriptorSetAllocateInfo descriptorSetAllocateInfo = genesis::VulkanInitializers::descriptorSetAllocateInfo(_descriptorPool, &_descriptorSetLayout, 1);
// allocate a set
VkDescriptorSet descriptorSet;
vkAllocateDescriptorSets(_device->vulkanDevice(), &descriptorSetAllocateInfo, &descriptorSet);
std::vector<VkWriteDescriptorSet> writeDescriptorSets =
{
genesis::VulkanInitializers::writeDescriptorSet(descriptorSet, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 0, &textures[i]->descriptor())
};
vkUpdateDescriptorSets(_device->vulkanDevice(), static_cast<uint32_t>(writeDescriptorSets.size()), writeDescriptorSets.data(), 0, nullptr);
_vecDescriptorSets.push_back(descriptorSet);
}
}
void NonIndirectLayout::draw(VkCommandBuffer commandBuffer, VkPipelineLayout pipelineLayout, const Node* node, const VulkanGltfModel* model) const
{
if (node->_mesh == nullptr)
{
return;
}
const auto& materials = model->materials();
for (const Primitive& primitive : node->_mesh->primitives)
{
if (primitive.indexCount > 0)
{
const Material& material = materials[primitive.materialIndex];
const int textureIndex = material.baseColorTextureIndex;
// Bind descriptor sets describing shader binding points
vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 1, 1, &_vecDescriptorSets[textureIndex], 0, nullptr);
vkCmdDrawIndexed(commandBuffer, primitive.indexCount, 1, primitive.firstIndex, 0, 0);
}
}
// draw the children
for (const auto& child : node->_children) {
draw(commandBuffer, pipelineLayout, child, model);
}
}
void NonIndirectLayout::draw(VkCommandBuffer commandBuffer, VkPipelineLayout pipelineLayout, const VulkanGltfModel* model) const
{
for (const Node* node : model->linearNodes())
{
draw(commandBuffer, pipelineLayout, node, model);
}
}
} |
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Weapon data file parsing, shared by game & client dlls.
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include <KeyValues.h>
#include <tier0/mem.h>
#include "filesystem.h"
#include "utldict.h"
#include "ammodef.h"
#include "playerclass_info_parse.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
static CUtlDict< FilePlayerClassInfo_t*, unsigned short > m_PlayerClassInfoDatabase;
#define MAX_PLAYERCLASSES 32
#ifdef _DEBUG
// used to track whether or not two player classes have been mistakenly assigned the same slot
bool g_bUsedPlayerClassSlots[MAX_PLAYERCLASSES] = { 0 };
#endif
#ifdef DEBUG
void CC_ReloadPlayerClasses_f (void)
{
//ResetFilePlayerClassInfoDatabase();
}
static ConCommand dod_reloadplayerclasses("dod_reloadplayerclasses", CC_ReloadPlayerClasses_f, "Reset player class info cache" );
#endif
//-----------------------------------------------------------------------------
// Purpose:
// Input : *name -
// Output : FilePlayerClassInfo_t
//-----------------------------------------------------------------------------
static PLAYERCLASS_FILE_INFO_HANDLE FindPlayerClassInfoSlot( const char *name )
{
// Complain about duplicately defined metaclass names...
unsigned short lookup = m_PlayerClassInfoDatabase.Find( name );
if ( lookup != m_PlayerClassInfoDatabase.InvalidIndex() )
{
return lookup;
}
FilePlayerClassInfo_t *insert = CreatePlayerClassInfo();
lookup = m_PlayerClassInfoDatabase.Insert( name, insert );
Assert( lookup != m_PlayerClassInfoDatabase.InvalidIndex() );
return lookup;
}
// Find a class slot, assuming the weapon's data has already been loaded.
PLAYERCLASS_FILE_INFO_HANDLE LookupPlayerClassInfoSlot( const char *name )
{
return m_PlayerClassInfoDatabase.Find( name );
}
// FIXME, handle differently?
static FilePlayerClassInfo_t gNullPlayerClassInfo;
//-----------------------------------------------------------------------------
// Purpose:
// Input : handle -
// Output : FilePlayerClassInfo_t
//-----------------------------------------------------------------------------
FilePlayerClassInfo_t *GetFilePlayerClassInfoFromHandle( PLAYERCLASS_FILE_INFO_HANDLE handle )
{
if ( handle == GetInvalidPlayerClassInfoHandle() )
{
Assert( !"bad index into playerclass info UtlDict" );
return &gNullPlayerClassInfo;
}
return m_PlayerClassInfoDatabase[ handle ];
}
//-----------------------------------------------------------------------------
// Purpose:
// Output : PLAYERCLASS_FILE_INFO_HANDLE
//-----------------------------------------------------------------------------
PLAYERCLASS_FILE_INFO_HANDLE GetInvalidPlayerClassInfoHandle( void )
{
return (PLAYERCLASS_FILE_INFO_HANDLE)m_PlayerClassInfoDatabase.InvalidIndex();
}
void ResetFilePlayerClassInfoDatabase( void )
{
m_PlayerClassInfoDatabase.PurgeAndDeleteElements();
#ifdef _DEBUG
memset(g_bUsedPlayerClassSlots, 0, sizeof(g_bUsedPlayerClassSlots));
#endif
}
#ifndef _XBOX
KeyValues* ReadEncryptedKVPlayerClassFile( IFileSystem *pFilesystem, const char *szFilenameWithoutExtension, const unsigned char *pICEKey )
{
Assert( strchr( szFilenameWithoutExtension, '.' ) == NULL );
char szFullName[512];
// Open the weapon data file, and abort if we can't
KeyValues *pKV = new KeyValues( "PlayerClassDatafile" );
Q_snprintf(szFullName,sizeof(szFullName), "%s.txt", szFilenameWithoutExtension);
if ( !pKV->LoadFromFile( pFilesystem, szFullName, "GAME" ) ) // try to load the normal .txt file first
{
if ( pICEKey )
{
Q_snprintf(szFullName,sizeof(szFullName), "%s.ctx", szFilenameWithoutExtension); // fall back to the .ctx file
FileHandle_t f = pFilesystem->Open( szFullName, "rb", "GAME");
if (!f)
{
pKV->deleteThis();
return NULL;
}
// load file into a null-terminated buffer
int fileSize = pFilesystem->Size(f);
char *buffer = (char*)MemAllocScratch(fileSize + 1);
Assert(buffer);
pFilesystem->Read(buffer, fileSize, f); // read into local buffer
buffer[fileSize] = 0; // null terminate file as EOF
pFilesystem->Close( f ); // close file after reading
UTIL_DecodeICE( (unsigned char*)buffer, fileSize, pICEKey );
bool retOK = pKV->LoadFromBuffer( szFullName, buffer, pFilesystem );
MemFreeScratch();
if ( !retOK )
{
pKV->deleteThis();
return NULL;
}
}
else
{
pKV->deleteThis();
return NULL;
}
}
return pKV;
}
#endif
//-----------------------------------------------------------------------------
// Purpose: Read data on weapon from script file
// Output: true - if data2 successfully read
// false - if data load fails
//-----------------------------------------------------------------------------
bool ReadPlayerClassDataFromFileForSlot( IFileSystem* pFilesystem, const char *szPlayerClassName, PLAYERCLASS_FILE_INFO_HANDLE *phandle, const unsigned char *pICEKey )
{
if ( !phandle )
{
Assert( 0 );
return false;
}
*phandle = FindPlayerClassInfoSlot( szPlayerClassName );
FilePlayerClassInfo_t *pFileInfo = GetFilePlayerClassInfoFromHandle( *phandle );
Assert( pFileInfo );
if ( pFileInfo->m_bParsedScript )
return true;
char sz[128];
Q_snprintf( sz, sizeof( sz ), "scripts/playerclass_%s", szPlayerClassName );
KeyValues *pKV = ReadEncryptedKVFile( pFilesystem, sz, pICEKey );
if ( !pKV )
return false;
pFileInfo->Parse( pKV, szPlayerClassName );
pKV->deleteThis();
return true;
}
//-----------------------------------------------------------------------------
// FilePlayerClassInfo_t implementation.
//-----------------------------------------------------------------------------
FilePlayerClassInfo_t::FilePlayerClassInfo_t()
{
m_bParsedScript = false;
m_szPlayerClassName[0] = 0;
m_szPrintName[0] = 0;
m_szPlayerModel[0] = 0;
m_szSelectCmd[0] = 0;
}
void FilePlayerClassInfo_t::Parse( KeyValues *pKeyValuesData, const char *szPlayerClassName )
{
// Okay, we tried at least once to look this up...
m_bParsedScript = true;
// Classname
Q_strncpy( m_szPlayerClassName, szPlayerClassName, MAX_WEAPON_STRING );
// Printable name
Q_strncpy( m_szPrintName, pKeyValuesData->GetString( "printname", "!! Missing printname on Player Class" ), MAX_PLAYERCLASS_NAME_LENGTH );
// Player Model
Q_strncpy( m_szPlayerModel, pKeyValuesData->GetString( "playermodel", "!! Missing playermodel on Player Class" ), MAX_PLAYERCLASS_NAME_LENGTH );
// Select command
Q_strncpy( m_szSelectCmd, pKeyValuesData->GetString( "selectcmd", "!! Missing selectcmd on Player Class" ), 32 );
#if defined(_DEBUG) && defined(HL2_CLIENT_DLL)
// Use this for class select keys
/*
// make sure two weapons aren't in the same slot & position
if (g_bUsedPlayerClassSlots[iSlot])
{
Msg( "Weapon slot info: %s (%d, %d)\n", szPrintName, iSlot, iPosition );
Warning( "Duplicately assigned weapon to slots in selection hud\n" );
}
g_bUsedPlayerClassSlots[iSlot][iPosition] = true;
*/
#endif
}
|
//
// Created by elad on 13/06/2020.
//
#include <cstddef>
#include <cassert>
#include <vector>
#ifndef MATALA5_CONTAINERS_RANGE_H
#define MATALA5_CONTAINERS_RANGE_H
#endif //MATALA5_CONTAINERS_RANGE_H
namespace itertools {
template<typename T = size_t>
class range {
const T kStart, kEnd, step;
public:
range(const T Start, const T End, const T Step = 1) : kStart(Start), kEnd(End), step(Step) {
// checking if the offset isn't 0
// checking legal input
assert(kStart >= 0 && kEnd > 0 && kStart <= kEnd && step > 0);
}
// default constructor.
range(const T End) : kStart(0), kEnd(End), step(1) {
assert(kEnd > 0);
}
///// until now its for the range
///// now we build its iterator.
public:
class iterator {
T val;
const T step;
public:
iterator(T Val, const T Step) : val(Val), step(Step) {}
operator T const() { return val; }
operator const T &() { return val; }
const T operator*() const { return val; }
const iterator &operator++() {
val += step;
return *this;
}
bool operator!=(const iterator &ri) const {
// checking first if val<0 (range on negative numbers) if not range on positive numbers.
return val < 0 ? val > ri.val : val < ri.val;
}
bool operator==(const iterator &ri) const {
return !operator!=(ri);
}
};
iterator begin() const { return iterator(kStart, step); }
iterator end() const { return iterator(kEnd, step); }
typedef int value_type;
// public:
//
// // Conversion to any vector< T >
// operator std::vector< T > ( void )
// {
// std::vector< T > retRange;
// for( T i = kStart; i < kEnd; i += step )
// retRange.push_back( i );
// return retRange; // use move semantics here
// }
};
}
|
; A046667: a(n) = A046666(n)/2.
; Submitted by Christian Krause
; 0,0,1,0,2,0,3,3,4,0,5,0,6,6,7,0,8,0,9,9,10,0,11,10,12,12,13,0,14,0,15,15,16,15,17,0,18,18,19,0,20,0,21,21,22,0,23,21,24,24,25,0,26,25,27,27,28,0,29,0,30,30,31,30,32,0,33,33,34,0,35,0,36,36,37,35,38,0,39,39,40,0,41,40,42,42,43,0,44,42,45,45,46,45,47,0,48,48,49,0
mov $1,-2
lpb $0
dif $0,$1
sub $0,1
sub $1,1
lpe
div $0,2
|
/**
* Autogenerated by Thrift for src/module.thrift
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
#include "thrift/compiler/test/fixtures/basic-annotations/gen-cpp2/MyServicePrioParent.h"
#include "thrift/compiler/test/fixtures/basic-annotations/gen-cpp2/MyServicePrioParent.tcc"
#include "thrift/compiler/test/fixtures/basic-annotations/gen-cpp2/module_metadata.h"
#include <thrift/lib/cpp2/gen/service_cpp.h>
namespace cpp2 {
std::unique_ptr<apache::thrift::AsyncProcessor> MyServicePrioParentSvIf::getProcessor() {
return std::make_unique<MyServicePrioParentAsyncProcessor>(this);
}
void MyServicePrioParentSvIf::ping() {
apache::thrift::detail::si::throw_app_exn_unimplemented("ping");
}
folly::SemiFuture<folly::Unit> MyServicePrioParentSvIf::semifuture_ping() {
return apache::thrift::detail::si::semifuture([&] {
return ping();
});
}
folly::Future<folly::Unit> MyServicePrioParentSvIf::future_ping() {
return apache::thrift::detail::si::future(semifuture_ping(), getThreadManager());
}
void MyServicePrioParentSvIf::async_tm_ping(std::unique_ptr<apache::thrift::HandlerCallback<void>> callback) {
apache::thrift::detail::si::async_tm(this, std::move(callback), [&] {
return future_ping();
});
}
void MyServicePrioParentSvIf::pong() {
apache::thrift::detail::si::throw_app_exn_unimplemented("pong");
}
folly::SemiFuture<folly::Unit> MyServicePrioParentSvIf::semifuture_pong() {
return apache::thrift::detail::si::semifuture([&] {
return pong();
});
}
folly::Future<folly::Unit> MyServicePrioParentSvIf::future_pong() {
return apache::thrift::detail::si::future(semifuture_pong(), getThreadManager());
}
void MyServicePrioParentSvIf::async_tm_pong(std::unique_ptr<apache::thrift::HandlerCallback<void>> callback) {
apache::thrift::detail::si::async_tm(this, std::move(callback), [&] {
return future_pong();
});
}
void MyServicePrioParentSvNull::ping() {
return;
}
void MyServicePrioParentSvNull::pong() {
return;
}
const char* MyServicePrioParentAsyncProcessor::getServiceName() {
return "MyServicePrioParent";
}
void MyServicePrioParentAsyncProcessor::getServiceMetadata(apache::thrift::metadata::ThriftServiceMetadataResponse& response) {
::apache::thrift::detail::md::ServiceMetadata<MyServicePrioParentSvIf>::gen(*response.metadata_ref(), *response.context_ref());
}
void MyServicePrioParentAsyncProcessor::processSerializedRequest(apache::thrift::ResponseChannelRequest::UniquePtr req, apache::thrift::SerializedRequest&& serializedRequest, apache::thrift::protocol::PROTOCOL_TYPES protType, apache::thrift::Cpp2RequestContext* context, folly::EventBase* eb, apache::thrift::concurrency::ThreadManager* tm) {
apache::thrift::detail::ap::process(this, std::move(req), std::move(serializedRequest), protType, context, eb, tm);
}
std::shared_ptr<folly::RequestContext> MyServicePrioParentAsyncProcessor::getBaseContextForRequest() {
return iface_->getBaseContextForRequest();
}
const MyServicePrioParentAsyncProcessor::ProcessMap& MyServicePrioParentAsyncProcessor::getBinaryProtocolProcessMap() {
return binaryProcessMap_;
}
const MyServicePrioParentAsyncProcessor::ProcessMap MyServicePrioParentAsyncProcessor::binaryProcessMap_ {
{"ping", &MyServicePrioParentAsyncProcessor::setUpAndProcess_ping<apache::thrift::BinaryProtocolReader, apache::thrift::BinaryProtocolWriter>},
{"pong", &MyServicePrioParentAsyncProcessor::setUpAndProcess_pong<apache::thrift::BinaryProtocolReader, apache::thrift::BinaryProtocolWriter>},
};
const MyServicePrioParentAsyncProcessor::ProcessMap& MyServicePrioParentAsyncProcessor::getCompactProtocolProcessMap() {
return compactProcessMap_;
}
const MyServicePrioParentAsyncProcessor::ProcessMap MyServicePrioParentAsyncProcessor::compactProcessMap_ {
{"ping", &MyServicePrioParentAsyncProcessor::setUpAndProcess_ping<apache::thrift::CompactProtocolReader, apache::thrift::CompactProtocolWriter>},
{"pong", &MyServicePrioParentAsyncProcessor::setUpAndProcess_pong<apache::thrift::CompactProtocolReader, apache::thrift::CompactProtocolWriter>},
};
} // cpp2
|
/*
* Copyright (C) 2005-2013 Team XBMC
* http://xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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 XBMC; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#include "VideoInfoScanner.h"
#include <utility>
#include "dialogs/GUIDialogExtendedProgressBar.h"
#include "dialogs/GUIDialogOK.h"
#include "dialogs/GUIDialogProgress.h"
#include "events/EventLog.h"
#include "events/MediaLibraryEvent.h"
#include "FileItem.h"
#include "filesystem/DirectoryCache.h"
#include "filesystem/File.h"
#include "filesystem/MultiPathDirectory.h"
#include "filesystem/StackDirectory.h"
#include "GUIInfoManager.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/LocalizeStrings.h"
#include "GUIUserMessages.h"
#include "interfaces/AnnouncementManager.h"
#include "messaging/ApplicationMessenger.h"
#include "messaging/helpers/DialogHelper.h"
#include "NfoFile.h"
#include "settings/AdvancedSettings.h"
#include "settings/Settings.h"
#include "TextureCache.h"
#include "threads/SystemClock.h"
#include "URL.h"
#include "Util.h"
#include "utils/log.h"
#include "utils/md5.h"
#include "utils/RegExp.h"
#include "utils/StringUtils.h"
#include "utils/URIUtils.h"
#include "utils/Variant.h"
#include "video/VideoLibraryQueue.h"
#include "video/VideoThumbLoader.h"
#include "VideoInfoDownloader.h"
using namespace XFILE;
using namespace ADDON;
using namespace KODI::MESSAGING;
using KODI::MESSAGING::HELPERS::DialogResponse;
namespace VIDEO
{
CVideoInfoScanner::CVideoInfoScanner()
{
m_bStop = false;
m_bRunning = false;
m_handle = NULL;
m_showDialog = false;
m_bCanInterrupt = false;
m_currentItem = 0;
m_itemCount = 0;
m_bClean = false;
m_scanAll = false;
}
CVideoInfoScanner::~CVideoInfoScanner()
{
}
void CVideoInfoScanner::Process()
{
m_bStop = false;
try
{
if (m_showDialog && !CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOLIBRARY_BACKGROUNDUPDATE))
{
CGUIDialogExtendedProgressBar* dialog =
(CGUIDialogExtendedProgressBar*)g_windowManager.GetWindow(WINDOW_DIALOG_EXT_PROGRESS);
if (dialog)
m_handle = dialog->GetHandle(g_localizeStrings.Get(314));
}
// check if we only need to perform a cleaning
if (m_bClean && m_pathsToScan.empty())
{
std::set<int> paths;
CVideoLibraryQueue::GetInstance().CleanLibrary(paths, false, m_handle);
if (m_handle)
m_handle->MarkFinished();
m_handle = NULL;
m_bRunning = false;
return;
}
unsigned int tick = XbmcThreads::SystemClockMillis();
m_database.Open();
m_bCanInterrupt = true;
CLog::Log(LOGNOTICE, "VideoInfoScanner: Starting scan ..");
ANNOUNCEMENT::CAnnouncementManager::GetInstance().Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnScanStarted");
// Reset progress vars
m_currentItem = 0;
m_itemCount = -1;
// Database operations should not be canceled
// using Interupt() while scanning as it could
// result in unexpected behaviour.
m_bCanInterrupt = false;
bool bCancelled = false;
while (!bCancelled && !m_pathsToScan.empty())
{
/*
* A copy of the directory path is used because the path supplied is
* immediately removed from the m_pathsToScan set in DoScan(). If the
* reference points to the entry in the set a null reference error
* occurs.
*/
std::string directory = *m_pathsToScan.begin();
if (!CDirectory::Exists(directory))
{
/*
* Note that this will skip clean (if m_bClean is enabled) if the directory really
* doesn't exist rather than a NAS being switched off. A manual clean from settings
* will still pick up and remove it though.
*/
CLog::Log(LOGWARNING, "%s directory '%s' does not exist - skipping scan%s.", __FUNCTION__, CURL::GetRedacted(directory).c_str(), m_bClean ? " and clean" : "");
m_pathsToScan.erase(m_pathsToScan.begin());
}
else if (!DoScan(directory))
bCancelled = true;
}
if (!bCancelled)
{
if (m_bClean)
CVideoLibraryQueue::GetInstance().CleanLibrary(m_pathsToClean, false, m_handle);
else
{
if (m_handle)
m_handle->SetTitle(g_localizeStrings.Get(331));
m_database.Compress(false);
}
}
g_infoManager.ResetLibraryBools();
m_database.Close();
tick = XbmcThreads::SystemClockMillis() - tick;
CLog::Log(LOGNOTICE, "VideoInfoScanner: Finished scan. Scanning for video info took %s", StringUtils::SecondsToTimeString(tick / 1000).c_str());
}
catch (...)
{
CLog::Log(LOGERROR, "VideoInfoScanner: Exception while scanning.");
}
m_bRunning = false;
ANNOUNCEMENT::CAnnouncementManager::GetInstance().Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnScanFinished");
if (m_handle)
m_handle->MarkFinished();
m_handle = NULL;
}
void CVideoInfoScanner::Start(const std::string& strDirectory, bool scanAll)
{
m_strStartDir = strDirectory;
m_scanAll = scanAll;
m_pathsToScan.clear();
m_pathsToClean.clear();
m_database.Open();
if (strDirectory.empty())
{ // scan all paths in the database. We do this by scanning all paths in the db, and crossing them off the list as
// we go.
m_database.GetPaths(m_pathsToScan);
}
else
{ // scan all the paths of this subtree that is in the database
std::vector<std::string> rootDirs;
if (URIUtils::IsMultiPath(strDirectory))
CMultiPathDirectory::GetPaths(strDirectory, rootDirs);
else
rootDirs.push_back(strDirectory);
for (std::vector<std::string>::const_iterator it = rootDirs.begin(); it < rootDirs.end(); ++it)
{
m_pathsToScan.insert(*it);
std::vector<std::pair<int, std::string>> subpaths;
m_database.GetSubPaths(*it, subpaths);
for (std::vector<std::pair<int, std::string>>::iterator it = subpaths.begin(); it < subpaths.end(); ++it)
m_pathsToScan.insert(it->second);
}
}
m_database.Close();
m_bClean = g_advancedSettings.m_bVideoLibraryCleanOnUpdate;
m_bRunning = true;
Process();
}
void CVideoInfoScanner::Stop()
{
if (m_bCanInterrupt)
m_database.Interupt();
m_bStop = true;
}
static void OnDirectoryScanned(const std::string& strDirectory)
{
CGUIMessage msg(GUI_MSG_DIRECTORY_SCANNED, 0, 0, 0);
msg.SetStringParam(strDirectory);
g_windowManager.SendThreadMessage(msg);
}
bool CVideoInfoScanner::IsExcluded(const std::string& strDirectory) const
{
std::string noMediaFile = URIUtils::AddFileToFolder(strDirectory, ".nomedia");
return CFile::Exists(noMediaFile);
}
bool CVideoInfoScanner::DoScan(const std::string& strDirectory)
{
if (m_handle)
{
m_handle->SetText(g_localizeStrings.Get(20415));
}
/*
* Remove this path from the list we're processing. This must be done prior to
* the check for file or folder exclusion to prevent an infinite while loop
* in Process().
*/
std::set<std::string>::iterator it = m_pathsToScan.find(strDirectory);
if (it != m_pathsToScan.end())
m_pathsToScan.erase(it);
// load subfolder
CFileItemList items;
bool foundDirectly = false;
bool bSkip = false;
SScanSettings settings;
ScraperPtr info = m_database.GetScraperForPath(strDirectory, settings, foundDirectly);
CONTENT_TYPE content = info ? info->Content() : CONTENT_NONE;
// exclude folders that match our exclude regexps
const std::vector<std::string> ®exps = content == CONTENT_TVSHOWS ? g_advancedSettings.m_tvshowExcludeFromScanRegExps
: g_advancedSettings.m_moviesExcludeFromScanRegExps;
if (CUtil::ExcludeFileOrFolder(strDirectory, regexps))
return true;
if (IsExcluded(strDirectory))
{
CLog::Log(LOGWARNING, "Skipping item '%s' with '.nomedia' file in parent directory, it won't be added to the library.", CURL::GetRedacted(strDirectory).c_str());
return true;
}
bool ignoreFolder = !m_scanAll && settings.noupdate;
if (content == CONTENT_NONE || ignoreFolder)
return true;
std::string hash, dbHash;
if (content == CONTENT_MOVIES ||content == CONTENT_MUSICVIDEOS)
{
if (m_handle)
{
int str = content == CONTENT_MOVIES ? 20317:20318;
m_handle->SetTitle(StringUtils::Format(g_localizeStrings.Get(str).c_str(), info->Name().c_str()));
}
std::string fastHash;
if (g_advancedSettings.m_bVideoLibraryUseFastHash)
fastHash = GetFastHash(strDirectory, regexps);
if (m_database.GetPathHash(strDirectory, dbHash) && !fastHash.empty() && fastHash == dbHash)
{ // fast hashes match - no need to process anything
hash = fastHash;
}
else
{ // need to fetch the folder
CDirectory::GetDirectory(strDirectory, items, g_advancedSettings.m_videoExtensions);
items.Stack();
// check whether to re-use previously computed fast hash
if (!CanFastHash(items, regexps) || fastHash.empty())
GetPathHash(items, hash);
else
hash = fastHash;
}
if (hash == dbHash)
{ // hash matches - skipping
CLog::Log(LOGDEBUG, "VideoInfoScanner: Skipping dir '%s' due to no change%s", CURL::GetRedacted(strDirectory).c_str(), !fastHash.empty() ? " (fasthash)" : "");
bSkip = true;
}
else if (hash.empty())
{ // directory empty or non-existent - add to clean list and skip
CLog::Log(LOGDEBUG, "VideoInfoScanner: Skipping dir '%s' as it's empty or doesn't exist - adding to clean list", CURL::GetRedacted(strDirectory).c_str());
if (m_bClean)
m_pathsToClean.insert(m_database.GetPathId(strDirectory));
bSkip = true;
}
else if (dbHash.empty())
{ // new folder - scan
CLog::Log(LOGDEBUG, "VideoInfoScanner: Scanning dir '%s' as not in the database", CURL::GetRedacted(strDirectory).c_str());
}
else
{ // hash changed - rescan
CLog::Log(LOGDEBUG, "VideoInfoScanner: Rescanning dir '%s' due to change (%s != %s)", CURL::GetRedacted(strDirectory).c_str(), dbHash.c_str(), hash.c_str());
}
}
else if (content == CONTENT_TVSHOWS)
{
if (m_handle)
m_handle->SetTitle(StringUtils::Format(g_localizeStrings.Get(20319).c_str(), info->Name().c_str()));
if (foundDirectly && !settings.parent_name_root)
{
CDirectory::GetDirectory(strDirectory, items, g_advancedSettings.m_videoExtensions);
items.SetPath(strDirectory);
GetPathHash(items, hash);
bSkip = true;
if (!m_database.GetPathHash(strDirectory, dbHash) || dbHash != hash)
bSkip = false;
else
items.Clear();
}
else
{
CFileItemPtr item(new CFileItem(URIUtils::GetFileName(strDirectory)));
item->SetPath(strDirectory);
item->m_bIsFolder = true;
items.Add(item);
items.SetPath(URIUtils::GetParentPath(item->GetPath()));
}
}
if (!bSkip)
{
if (RetrieveVideoInfo(items, settings.parent_name_root, content))
{
if (!m_bStop && (content == CONTENT_MOVIES || content == CONTENT_MUSICVIDEOS))
{
m_database.SetPathHash(strDirectory, hash);
if (m_bClean)
m_pathsToClean.insert(m_database.GetPathId(strDirectory));
CLog::Log(LOGDEBUG, "VideoInfoScanner: Finished adding information from dir %s", CURL::GetRedacted(strDirectory).c_str());
}
}
else
{
if (m_bClean)
m_pathsToClean.insert(m_database.GetPathId(strDirectory));
CLog::Log(LOGDEBUG, "VideoInfoScanner: No (new) information was found in dir %s", CURL::GetRedacted(strDirectory).c_str());
}
}
else if (hash != dbHash && (content == CONTENT_MOVIES || content == CONTENT_MUSICVIDEOS))
{ // update the hash either way - we may have changed the hash to a fast version
m_database.SetPathHash(strDirectory, hash);
}
if (m_handle)
OnDirectoryScanned(strDirectory);
for (int i = 0; i < items.Size(); ++i)
{
CFileItemPtr pItem = items[i];
if (m_bStop)
break;
// if we have a directory item (non-playlist) we then recurse into that folder
// do not recurse for tv shows - we have already looked recursively for episodes
if (pItem->m_bIsFolder && !pItem->IsParentFolder() && !pItem->IsPlayList() && settings.recurse > 0 && content != CONTENT_TVSHOWS)
{
if (!DoScan(pItem->GetPath()))
{
m_bStop = true;
}
}
}
return !m_bStop;
}
bool CVideoInfoScanner::RetrieveVideoInfo(CFileItemList& items, bool bDirNames, CONTENT_TYPE content, bool useLocal, CScraperUrl* pURL, bool fetchEpisodes, CGUIDialogProgress* pDlgProgress)
{
if (pDlgProgress)
{
if (items.Size() > 1 || (items[0]->m_bIsFolder && fetchEpisodes))
{
pDlgProgress->ShowProgressBar(true);
pDlgProgress->SetPercentage(0);
}
else
pDlgProgress->ShowProgressBar(false);
pDlgProgress->Progress();
}
m_database.Open();
bool FoundSomeInfo = false;
std::vector<int> seenPaths;
for (int i = 0; i < (int)items.Size(); ++i)
{
m_nfoReader.Close();
CFileItemPtr pItem = items[i];
// we do this since we may have a override per dir
ScraperPtr info2 = m_database.GetScraperForPath(pItem->m_bIsFolder ? pItem->GetPath() : items.GetPath());
if (!info2) // skip
continue;
// Discard all exclude files defined by regExExclude
if (CUtil::ExcludeFileOrFolder(pItem->GetPath(), (content == CONTENT_TVSHOWS) ? g_advancedSettings.m_tvshowExcludeFromScanRegExps
: g_advancedSettings.m_moviesExcludeFromScanRegExps))
continue;
if (info2->Content() == CONTENT_MOVIES || info2->Content() == CONTENT_MUSICVIDEOS)
{
if (m_handle)
m_handle->SetPercentage(i*100.f/items.Size());
}
// clear our scraper cache
info2->ClearCache();
INFO_RET ret = INFO_CANCELLED;
if (info2->Content() == CONTENT_TVSHOWS)
ret = RetrieveInfoForTvShow(pItem.get(), bDirNames, info2, useLocal, pURL, fetchEpisodes, pDlgProgress);
else if (info2->Content() == CONTENT_MOVIES)
ret = RetrieveInfoForMovie(pItem.get(), bDirNames, info2, useLocal, pURL, pDlgProgress);
else if (info2->Content() == CONTENT_MUSICVIDEOS)
ret = RetrieveInfoForMusicVideo(pItem.get(), bDirNames, info2, useLocal, pURL, pDlgProgress);
else
{
CLog::Log(LOGERROR, "VideoInfoScanner: Unknown content type %d (%s)", info2->Content(), CURL::GetRedacted(pItem->GetPath()).c_str());
FoundSomeInfo = false;
break;
}
if (ret == INFO_CANCELLED || ret == INFO_ERROR)
{
FoundSomeInfo = false;
break;
}
if (ret == INFO_ADDED || ret == INFO_HAVE_ALREADY)
FoundSomeInfo = true;
else if (ret == INFO_NOT_FOUND)
{
CLog::Log(LOGWARNING, "No information found for item '%s', it won't be added to the library.", CURL::GetRedacted(pItem->GetPath()).c_str());
MediaType mediaType = MediaTypeMovie;
if (info2->Content() == CONTENT_TVSHOWS)
mediaType = MediaTypeTvShow;
else if (info2->Content() == CONTENT_MUSICVIDEOS)
mediaType = MediaTypeMusicVideo;
CEventLog::GetInstance().Add(EventPtr(new CMediaLibraryEvent(
mediaType, pItem->GetPath(), 24145,
StringUtils::Format(g_localizeStrings.Get(24147).c_str(), mediaType.c_str(), URIUtils::GetFileName(pItem->GetPath()).c_str()),
pItem->GetArt("thumb"), CURL::GetRedacted(pItem->GetPath()), EventLevelWarning)));
}
pURL = NULL;
// Keep track of directories we've seen
if (m_bClean && pItem->m_bIsFolder)
seenPaths.push_back(m_database.GetPathId(pItem->GetPath()));
}
if (content == CONTENT_TVSHOWS && ! seenPaths.empty())
{
std::vector<std::pair<int, std::string>> libPaths;
m_database.GetSubPaths(items.GetPath(), libPaths);
for (std::vector<std::pair<int, std::string> >::iterator i = libPaths.begin(); i < libPaths.end(); ++i)
{
if (find(seenPaths.begin(), seenPaths.end(), i->first) == seenPaths.end())
m_pathsToClean.insert(i->first);
}
}
if(pDlgProgress)
pDlgProgress->ShowProgressBar(false);
m_database.Close();
return FoundSomeInfo;
}
INFO_RET CVideoInfoScanner::RetrieveInfoForTvShow(CFileItem *pItem, bool bDirNames, ScraperPtr &info2, bool useLocal, CScraperUrl* pURL, bool fetchEpisodes, CGUIDialogProgress* pDlgProgress)
{
long idTvShow = -1;
if (pItem->m_bIsFolder)
idTvShow = m_database.GetTvShowId(pItem->GetPath());
else
{
std::string strPath = URIUtils::GetDirectory(pItem->GetPath());
idTvShow = m_database.GetTvShowId(strPath);
}
if (idTvShow > -1 && (fetchEpisodes || !pItem->m_bIsFolder))
{
INFO_RET ret = RetrieveInfoForEpisodes(pItem, idTvShow, info2, useLocal, pDlgProgress);
if (ret == INFO_ADDED)
m_database.SetPathHash(pItem->GetPath(), pItem->GetProperty("hash").asString());
return ret;
}
if (ProgressCancelled(pDlgProgress, pItem->m_bIsFolder ? 20353 : 20361, pItem->GetLabel()))
return INFO_CANCELLED;
if (m_handle)
m_handle->SetText(pItem->GetMovieName(bDirNames));
CNfoFile::NFOResult result=CNfoFile::NO_NFO;
CScraperUrl scrUrl;
// handle .nfo files
if (useLocal)
result = CheckForNFOFile(pItem, bDirNames, info2, scrUrl);
if (result == CNfoFile::FULL_NFO)
{
pItem->GetVideoInfoTag()->Reset();
m_nfoReader.GetDetails(*pItem->GetVideoInfoTag());
long lResult = AddVideo(pItem, info2->Content(), bDirNames, useLocal);
if (lResult < 0)
return INFO_ERROR;
if (fetchEpisodes)
{
INFO_RET ret = RetrieveInfoForEpisodes(pItem, lResult, info2, useLocal, pDlgProgress);
if (ret == INFO_ADDED)
m_database.SetPathHash(pItem->GetPath(), pItem->GetProperty("hash").asString());
return ret;
}
return INFO_ADDED;
}
if (result == CNfoFile::URL_NFO || result == CNfoFile::COMBINED_NFO)
pURL = &scrUrl;
CScraperUrl url;
int retVal = 0;
if (pURL)
url = *pURL;
else if ((retVal = FindVideo(pItem->GetMovieName(bDirNames), info2, url, pDlgProgress)) <= 0)
return retVal < 0 ? INFO_CANCELLED : INFO_NOT_FOUND;
long lResult=-1;
if (GetDetails(pItem, url, info2, result == CNfoFile::COMBINED_NFO ? &m_nfoReader : NULL, pDlgProgress))
{
if ((lResult = AddVideo(pItem, info2->Content(), false, useLocal)) < 0)
return INFO_ERROR;
}
if (fetchEpisodes)
{
INFO_RET ret = RetrieveInfoForEpisodes(pItem, lResult, info2, useLocal, pDlgProgress);
if (ret == INFO_ADDED)
m_database.SetPathHash(pItem->GetPath(), pItem->GetProperty("hash").asString());
}
return INFO_ADDED;
}
INFO_RET CVideoInfoScanner::RetrieveInfoForMovie(CFileItem *pItem, bool bDirNames, ScraperPtr &info2, bool useLocal, CScraperUrl* pURL, CGUIDialogProgress* pDlgProgress)
{
if (pItem->m_bIsFolder || !pItem->IsVideo() || pItem->IsNFO() ||
(pItem->IsPlayList() && !URIUtils::HasExtension(pItem->GetPath(), ".strm")))
return INFO_NOT_NEEDED;
if (ProgressCancelled(pDlgProgress, 198, pItem->GetLabel()))
return INFO_CANCELLED;
if (m_database.HasMovieInfo(pItem->GetPath()))
return INFO_HAVE_ALREADY;
if (m_handle)
m_handle->SetText(pItem->GetMovieName(bDirNames));
CNfoFile::NFOResult result=CNfoFile::NO_NFO;
CScraperUrl scrUrl;
// handle .nfo files
if (useLocal)
result = CheckForNFOFile(pItem, bDirNames, info2, scrUrl);
if (result == CNfoFile::FULL_NFO)
{
pItem->GetVideoInfoTag()->Reset();
m_nfoReader.GetDetails(*pItem->GetVideoInfoTag());
if (AddVideo(pItem, info2->Content(), bDirNames, true) < 0)
return INFO_ERROR;
return INFO_ADDED;
}
if (result == CNfoFile::URL_NFO || result == CNfoFile::COMBINED_NFO)
pURL = &scrUrl;
CScraperUrl url;
int retVal = 0;
if (pURL)
url = *pURL;
else if ((retVal = FindVideo(pItem->GetMovieName(bDirNames), info2, url, pDlgProgress)) <= 0)
return retVal < 0 ? INFO_CANCELLED : INFO_NOT_FOUND;
if (GetDetails(pItem, url, info2, result == CNfoFile::COMBINED_NFO ? &m_nfoReader : NULL, pDlgProgress))
{
if (AddVideo(pItem, info2->Content(), bDirNames, useLocal) < 0)
return INFO_ERROR;
return INFO_ADDED;
}
// TODO: This is not strictly correct as we could fail to download information here or error, or be cancelled
return INFO_NOT_FOUND;
}
INFO_RET CVideoInfoScanner::RetrieveInfoForMusicVideo(CFileItem *pItem, bool bDirNames, ScraperPtr &info2, bool useLocal, CScraperUrl* pURL, CGUIDialogProgress* pDlgProgress)
{
if (pItem->m_bIsFolder || !pItem->IsVideo() || pItem->IsNFO() ||
(pItem->IsPlayList() && !URIUtils::HasExtension(pItem->GetPath(), ".strm")))
return INFO_NOT_NEEDED;
if (ProgressCancelled(pDlgProgress, 20394, pItem->GetLabel()))
return INFO_CANCELLED;
if (m_database.HasMusicVideoInfo(pItem->GetPath()))
return INFO_HAVE_ALREADY;
if (m_handle)
m_handle->SetText(pItem->GetMovieName(bDirNames));
CNfoFile::NFOResult result=CNfoFile::NO_NFO;
CScraperUrl scrUrl;
// handle .nfo files
if (useLocal)
result = CheckForNFOFile(pItem, bDirNames, info2, scrUrl);
if (result == CNfoFile::FULL_NFO)
{
pItem->GetVideoInfoTag()->Reset();
m_nfoReader.GetDetails(*pItem->GetVideoInfoTag());
if (AddVideo(pItem, info2->Content(), bDirNames, true) < 0)
return INFO_ERROR;
return INFO_ADDED;
}
if (result == CNfoFile::URL_NFO || result == CNfoFile::COMBINED_NFO)
pURL = &scrUrl;
CScraperUrl url;
int retVal = 0;
if (pURL)
url = *pURL;
else if ((retVal = FindVideo(pItem->GetMovieName(bDirNames), info2, url, pDlgProgress)) <= 0)
return retVal < 0 ? INFO_CANCELLED : INFO_NOT_FOUND;
if (GetDetails(pItem, url, info2, result == CNfoFile::COMBINED_NFO ? &m_nfoReader : NULL, pDlgProgress))
{
if (AddVideo(pItem, info2->Content(), bDirNames, useLocal) < 0)
return INFO_ERROR;
return INFO_ADDED;
}
// TODO: This is not strictly correct as we could fail to download information here or error, or be cancelled
return INFO_NOT_FOUND;
}
INFO_RET CVideoInfoScanner::RetrieveInfoForEpisodes(CFileItem *item, long showID, const ADDON::ScraperPtr &scraper, bool useLocal, CGUIDialogProgress *progress)
{
// enumerate episodes
EPISODELIST files;
if (!EnumerateSeriesFolder(item, files))
return INFO_HAVE_ALREADY;
if (files.size() == 0) // no update or no files
return INFO_NOT_NEEDED;
if (m_bStop || (progress && progress->IsCanceled()))
return INFO_CANCELLED;
CVideoInfoTag showInfo;
m_database.GetTvShowInfo("", showInfo, showID);
INFO_RET ret = OnProcessSeriesFolder(files, scraper, useLocal, showInfo, progress);
if (ret == INFO_ADDED)
{
std::map<int, std::map<std::string, std::string>> seasonArt;
m_database.GetTvShowSeasonArt(showID, seasonArt);
bool updateSeasonArt = false;
for (std::map<int, std::map<std::string, std::string>>::const_iterator i = seasonArt.begin(); i != seasonArt.end(); ++i)
{
if (i->second.empty())
{
updateSeasonArt = true;
break;
}
}
if (updateSeasonArt)
{
CVideoInfoDownloader loader(scraper);
loader.GetArtwork(showInfo);
GetSeasonThumbs(showInfo, seasonArt, CVideoThumbLoader::GetArtTypes(MediaTypeSeason), useLocal);
for (std::map<int, std::map<std::string, std::string> >::const_iterator i = seasonArt.begin(); i != seasonArt.end(); ++i)
{
int seasonID = m_database.AddSeason(showID, i->first);
m_database.SetArtForItem(seasonID, MediaTypeSeason, i->second);
}
}
}
return ret;
}
bool CVideoInfoScanner::EnumerateSeriesFolder(CFileItem* item, EPISODELIST& episodeList)
{
CFileItemList items;
const std::vector<std::string> ®exps = g_advancedSettings.m_tvshowExcludeFromScanRegExps;
bool bSkip = false;
if (item->m_bIsFolder)
{
/*
* Note: DoScan() will not remove this path as it's not recursing for tvshows.
* Remove this path from the list we're processing in order to avoid hitting
* it twice in the main loop.
*/
std::set<std::string>::iterator it = m_pathsToScan.find(item->GetPath());
if (it != m_pathsToScan.end())
m_pathsToScan.erase(it);
std::string hash, dbHash;
if (g_advancedSettings.m_bVideoLibraryUseFastHash)
hash = GetRecursiveFastHash(item->GetPath(), regexps);
if (m_database.GetPathHash(item->GetPath(), dbHash) && !hash.empty() && dbHash == hash)
{
// fast hashes match - no need to process anything
bSkip = true;
}
// fast hash cannot be computed or we need to rescan. fetch the listing.
if (!bSkip)
{
int flags = DIR_FLAG_DEFAULTS;
if (!hash.empty())
flags |= DIR_FLAG_NO_FILE_INFO;
CUtil::GetRecursiveListing(item->GetPath(), items, g_advancedSettings.m_videoExtensions, flags);
// fast hash failed - compute slow one
if (hash.empty())
{
GetPathHash(items, hash);
if (dbHash == hash)
{
// slow hashes match - no need to process anything
bSkip = true;
}
}
}
if (bSkip)
{
CLog::Log(LOGDEBUG, "VideoInfoScanner: Skipping dir '%s' due to no change", CURL::GetRedacted(item->GetPath()).c_str());
// update our dialog with our progress
if (m_handle)
OnDirectoryScanned(item->GetPath());
return false;
}
if (dbHash.empty())
CLog::Log(LOGDEBUG, "VideoInfoScanner: Scanning dir '%s' as not in the database", CURL::GetRedacted(item->GetPath()).c_str());
else
CLog::Log(LOGDEBUG, "VideoInfoScanner: Rescanning dir '%s' due to change (%s != %s)", CURL::GetRedacted(item->GetPath()).c_str(), dbHash.c_str(), hash.c_str());
if (m_bClean)
{
m_pathsToClean.insert(m_database.GetPathId(item->GetPath()));
m_database.GetPathsForTvShow(m_database.GetTvShowId(item->GetPath()), m_pathsToClean);
}
item->SetProperty("hash", hash);
}
else
{
CFileItemPtr newItem(new CFileItem(*item));
items.Add(newItem);
}
/*
stack down any dvd folders
need to sort using the full path since this is a collapsed recursive listing of all subdirs
video_ts.ifo files should sort at the top of a dvd folder in ascending order
/foo/bar/video_ts.ifo
/foo/bar/vts_x_y.ifo
/foo/bar/vts_x_y.vob
*/
// since we're doing this now anyway, should other items be stacked?
items.Sort(SortByPath, SortOrderAscending);
int x = 0;
while (x < items.Size())
{
if (items[x]->m_bIsFolder)
{
x++;
continue;
}
std::string strPathX, strFileX;
URIUtils::Split(items[x]->GetPath(), strPathX, strFileX);
//CLog::Log(LOGDEBUG,"%i:%s:%s", x, strPathX.c_str(), strFileX.c_str());
const int y = x + 1;
if (StringUtils::EqualsNoCase(strFileX, "VIDEO_TS.IFO"))
{
while (y < items.Size())
{
std::string strPathY, strFileY;
URIUtils::Split(items[y]->GetPath(), strPathY, strFileY);
//CLog::Log(LOGDEBUG," %i:%s:%s", y, strPathY.c_str(), strFileY.c_str());
if (StringUtils::EqualsNoCase(strPathY, strPathX))
/*
remove everything sorted below the video_ts.ifo file in the same path.
understandbly this wont stack correctly if there are other files in the the dvd folder.
this should be unlikely and thus is being ignored for now but we can monitor the
where the path changes and potentially remove the items above the video_ts.ifo file.
*/
items.Remove(y);
else
break;
}
}
x++;
}
// enumerate
for (int i=0;i<items.Size();++i)
{
if (items[i]->m_bIsFolder)
continue;
std::string strPath = URIUtils::GetDirectory(items[i]->GetPath());
URIUtils::RemoveSlashAtEnd(strPath); // want no slash for the test that follows
if (StringUtils::EqualsNoCase(URIUtils::GetFileName(strPath), "sample"))
continue;
// Discard all exclude files defined by regExExcludes
if (CUtil::ExcludeFileOrFolder(items[i]->GetPath(), regexps))
continue;
/*
* Check if the media source has already set the season and episode or original air date in
* the VideoInfoTag. If it has, do not try to parse any of them from the file path to avoid
* any false positive matches.
*/
if (ProcessItemByVideoInfoTag(items[i].get(), episodeList))
continue;
if (!EnumerateEpisodeItem(items[i].get(), episodeList))
CLog::Log(LOGDEBUG, "VideoInfoScanner: Could not enumerate file %s", CURL::GetRedacted(CURL::Decode(items[i]->GetPath())).c_str());
}
return true;
}
bool CVideoInfoScanner::ProcessItemByVideoInfoTag(const CFileItem *item, EPISODELIST &episodeList)
{
if (!item->HasVideoInfoTag())
return false;
const CVideoInfoTag* tag = item->GetVideoInfoTag();
/*
* First check the season and episode number. This takes precedence over the original air
* date and episode title. Must be a valid season and episode number combination.
*/
if (tag->m_iSeason > -1 && tag->m_iEpisode > 0)
{
EPISODE episode;
episode.strPath = item->GetPath();
episode.iSeason = tag->m_iSeason;
episode.iEpisode = tag->m_iEpisode;
episode.isFolder = false;
episodeList.push_back(episode);
CLog::Log(LOGDEBUG, "%s - found match for: %s. Season %d, Episode %d", __FUNCTION__,
CURL::GetRedacted(episode.strPath).c_str(), episode.iSeason, episode.iEpisode);
return true;
}
/*
* Next preference is the first aired date. If it exists use that for matching the TV Show
* information. Also set the title in case there are multiple matches for the first aired date.
*/
if (tag->m_firstAired.IsValid())
{
EPISODE episode;
episode.strPath = item->GetPath();
episode.strTitle = tag->m_strTitle;
episode.isFolder = false;
/*
* Set season and episode to -1 to indicate to use the aired date.
*/
episode.iSeason = -1;
episode.iEpisode = -1;
/*
* The first aired date string must be parseable.
*/
episode.cDate = item->GetVideoInfoTag()->m_firstAired;
episodeList.push_back(episode);
CLog::Log(LOGDEBUG, "%s - found match for: '%s', firstAired: '%s' = '%s', title: '%s'",
__FUNCTION__, CURL::GetRedacted(episode.strPath).c_str(), tag->m_firstAired.GetAsDBDateTime().c_str(),
episode.cDate.GetAsLocalizedDate().c_str(), episode.strTitle.c_str());
return true;
}
/*
* Next preference is the episode title. If it exists use that for matching the TV Show
* information.
*/
if (!tag->m_strTitle.empty())
{
EPISODE episode;
episode.strPath = item->GetPath();
episode.strTitle = tag->m_strTitle;
episode.isFolder = false;
/*
* Set season and episode to -1 to indicate to use the title.
*/
episode.iSeason = -1;
episode.iEpisode = -1;
episodeList.push_back(episode);
CLog::Log(LOGDEBUG,"%s - found match for: '%s', title: '%s'", __FUNCTION__,
CURL::GetRedacted(episode.strPath).c_str(), episode.strTitle.c_str());
return true;
}
/*
* There is no further episode information available if both the season and episode number have
* been set to 0. Return the match as true so no further matching is attempted, but don't add it
* to the episode list.
*/
if (tag->m_iSeason == 0 && tag->m_iEpisode == 0)
{
CLog::Log(LOGDEBUG,"%s - found exclusion match for: %s. Both Season and Episode are 0. Item will be ignored for scanning.",
__FUNCTION__, CURL::GetRedacted(item->GetPath()).c_str());
return true;
}
return false;
}
bool CVideoInfoScanner::EnumerateEpisodeItem(const CFileItem *item, EPISODELIST& episodeList)
{
SETTINGS_TVSHOWLIST expression = g_advancedSettings.m_tvshowEnumRegExps;
std::string strLabel;
// remove path to main file if it's a bd or dvd folder to regex the right (folder) name
if (item->IsOpticalMediaFile())
{
strLabel = item->GetLocalMetadataPath();
URIUtils::RemoveSlashAtEnd(strLabel);
}
else
strLabel = item->GetPath();
// URLDecode in case an episode is on a http/https/dav/davs:// source and URL-encoded like foo%201x01%20bar.avi
strLabel = CURL::Decode(strLabel);
for (unsigned int i=0;i<expression.size();++i)
{
CRegExp reg(true, CRegExp::autoUtf8);
if (!reg.RegComp(expression[i].regexp))
continue;
int regexppos, regexp2pos;
//CLog::Log(LOGDEBUG,"running expression %s on %s",expression[i].regexp.c_str(),strLabel.c_str());
if ((regexppos = reg.RegFind(strLabel.c_str())) < 0)
continue;
EPISODE episode;
episode.strPath = item->GetPath();
episode.iSeason = -1;
episode.iEpisode = -1;
episode.cDate.SetValid(false);
episode.isFolder = false;
bool byDate = expression[i].byDate ? true : false;
int defaultSeason = expression[i].defaultSeason;
if (byDate)
{
if (!GetAirDateFromRegExp(reg, episode))
continue;
CLog::Log(LOGDEBUG, "VideoInfoScanner: Found date based match %s (%s) [%s]", CURL::GetRedacted(episode.strPath).c_str(),
episode.cDate.GetAsLocalizedDate().c_str(), expression[i].regexp.c_str());
}
else
{
if (!GetEpisodeAndSeasonFromRegExp(reg, episode, defaultSeason))
continue;
CLog::Log(LOGDEBUG, "VideoInfoScanner: Found episode match %s (s%ie%i) [%s]", CURL::GetRedacted(episode.strPath).c_str(),
episode.iSeason, episode.iEpisode, expression[i].regexp.c_str());
}
// Grab the remainder from first regexp run
// as second run might modify or empty it.
std::string remainder(reg.GetMatch(3));
/*
* Check if the files base path is a dedicated folder that contains
* only this single episode. If season and episode match with the
* actual media file, we set episode.isFolder to true.
*/
std::string strBasePath = item->GetBaseMoviePath(true);
URIUtils::RemoveSlashAtEnd(strBasePath);
strBasePath = URIUtils::GetFileName(strBasePath);
if (reg.RegFind(strBasePath.c_str()) > -1)
{
EPISODE parent;
if (byDate)
{
GetAirDateFromRegExp(reg, parent);
if (episode.cDate == parent.cDate)
episode.isFolder = true;
}
else
{
GetEpisodeAndSeasonFromRegExp(reg, parent, defaultSeason);
if (episode.iSeason == parent.iSeason && episode.iEpisode == parent.iEpisode)
episode.isFolder = true;
}
}
// add what we found by now
episodeList.push_back(episode);
CRegExp reg2(true, CRegExp::autoUtf8);
// check the remainder of the string for any further episodes.
if (!byDate && reg2.RegComp(g_advancedSettings.m_tvshowMultiPartEnumRegExp))
{
int offset = 0;
// we want "long circuit" OR below so that both offsets are evaluated
while (((regexp2pos = reg2.RegFind(remainder.c_str() + offset)) > -1) | ((regexppos = reg.RegFind(remainder.c_str() + offset)) > -1))
{
if (((regexppos <= regexp2pos) && regexppos != -1) ||
(regexppos >= 0 && regexp2pos == -1))
{
GetEpisodeAndSeasonFromRegExp(reg, episode, defaultSeason);
CLog::Log(LOGDEBUG, "VideoInfoScanner: Adding new season %u, multipart episode %u [%s]",
episode.iSeason, episode.iEpisode,
g_advancedSettings.m_tvshowMultiPartEnumRegExp.c_str());
episodeList.push_back(episode);
remainder = reg.GetMatch(3);
offset = 0;
}
else if (((regexp2pos < regexppos) && regexp2pos != -1) ||
(regexp2pos >= 0 && regexppos == -1))
{
episode.iEpisode = atoi(reg2.GetMatch(1).c_str());
CLog::Log(LOGDEBUG, "VideoInfoScanner: Adding multipart episode %u [%s]",
episode.iEpisode, g_advancedSettings.m_tvshowMultiPartEnumRegExp.c_str());
episodeList.push_back(episode);
offset += regexp2pos + reg2.GetFindLen();
}
}
}
return true;
}
return false;
}
bool CVideoInfoScanner::GetEpisodeAndSeasonFromRegExp(CRegExp ®, EPISODE &episodeInfo, int defaultSeason)
{
std::string season(reg.GetMatch(1));
std::string episode(reg.GetMatch(2));
if (!season.empty() || !episode.empty())
{
char* endptr = NULL;
if (season.empty() && !episode.empty())
{ // no season specified -> assume defaultSeason
episodeInfo.iSeason = defaultSeason;
if ((episodeInfo.iEpisode = CUtil::TranslateRomanNumeral(episode.c_str())) == -1)
episodeInfo.iEpisode = strtol(episode.c_str(), &endptr, 10);
}
else if (!season.empty() && episode.empty())
{ // no episode specification -> assume defaultSeason
episodeInfo.iSeason = defaultSeason;
if ((episodeInfo.iEpisode = CUtil::TranslateRomanNumeral(season.c_str())) == -1)
episodeInfo.iEpisode = atoi(season.c_str());
}
else
{ // season and episode specified
episodeInfo.iSeason = atoi(season.c_str());
episodeInfo.iEpisode = strtol(episode.c_str(), &endptr, 10);
}
if (endptr)
{
if (isalpha(*endptr))
episodeInfo.iSubepisode = *endptr - (islower(*endptr) ? 'a' : 'A') + 1;
else if (*endptr == '.')
episodeInfo.iSubepisode = atoi(endptr+1);
}
return true;
}
return false;
}
bool CVideoInfoScanner::GetAirDateFromRegExp(CRegExp ®, EPISODE &episodeInfo)
{
std::string param1(reg.GetMatch(1));
std::string param2(reg.GetMatch(2));
std::string param3(reg.GetMatch(3));
if (!param1.empty() && !param2.empty() && !param3.empty())
{
// regular expression by date
int len1 = param1.size();
int len2 = param2.size();
int len3 = param3.size();
if (len1==4 && len2==2 && len3==2)
{
// yyyy mm dd format
episodeInfo.cDate.SetDate(atoi(param1.c_str()), atoi(param2.c_str()), atoi(param3.c_str()));
}
else if (len1==2 && len2==2 && len3==4)
{
// mm dd yyyy format
episodeInfo.cDate.SetDate(atoi(param3.c_str()), atoi(param1.c_str()), atoi(param2.c_str()));
}
}
return episodeInfo.cDate.IsValid();
}
long CVideoInfoScanner::AddVideo(CFileItem *pItem, const CONTENT_TYPE &content, bool videoFolder /* = false */, bool useLocal /* = true */, const CVideoInfoTag *showInfo /* = NULL */, bool libraryImport /* = false */)
{
// ensure our database is open (this can get called via other classes)
if (!m_database.Open())
return -1;
if (!libraryImport)
GetArtwork(pItem, content, videoFolder, useLocal, showInfo ? showInfo->m_strPath : "");
// ensure the art map isn't completely empty by specifying an empty thumb
std::map<std::string, std::string> art = pItem->GetArt();
if (art.empty())
art["thumb"] = "";
CVideoInfoTag &movieDetails = *pItem->GetVideoInfoTag();
if (movieDetails.m_basePath.empty())
movieDetails.m_basePath = pItem->GetBaseMoviePath(videoFolder);
movieDetails.m_parentPathID = m_database.AddPath(URIUtils::GetParentPath(movieDetails.m_basePath));
movieDetails.m_strFileNameAndPath = pItem->GetPath();
if (pItem->m_bIsFolder)
movieDetails.m_strPath = pItem->GetPath();
std::string strTitle(movieDetails.m_strTitle);
if (showInfo && content == CONTENT_TVSHOWS)
{
strTitle = StringUtils::Format("%s - %ix%i - %s", showInfo->m_strTitle.c_str(), movieDetails.m_iSeason, movieDetails.m_iEpisode, strTitle.c_str());
}
std::string redactPath(CURL::GetRedacted(CURL::Decode(pItem->GetPath())));
CLog::Log(LOGDEBUG, "VideoInfoScanner: Adding new item to %s:%s", TranslateContent(content).c_str(), redactPath.c_str());
long lResult = -1;
if (content == CONTENT_MOVIES)
{
// find local trailer first
std::string strTrailer = pItem->FindTrailer();
if (!strTrailer.empty())
movieDetails.m_strTrailer = strTrailer;
lResult = m_database.SetDetailsForMovie(pItem->GetPath(), movieDetails, art);
movieDetails.m_iDbId = lResult;
movieDetails.m_type = MediaTypeMovie;
// setup links to shows if the linked shows are in the db
for (unsigned int i=0; i < movieDetails.m_showLink.size(); ++i)
{
CFileItemList items;
m_database.GetTvShowsByName(movieDetails.m_showLink[i], items);
if (items.Size())
m_database.LinkMovieToTvshow(lResult, items[0]->GetVideoInfoTag()->m_iDbId, false);
else
CLog::Log(LOGDEBUG, "VideoInfoScanner: Failed to link movie %s to show %s", movieDetails.m_strTitle.c_str(), movieDetails.m_showLink[i].c_str());
}
}
else if (content == CONTENT_TVSHOWS)
{
if (pItem->m_bIsFolder)
{
/*
multipaths are not stored in the database, so in the case we have one,
we split the paths, and compute the parent paths in each case.
*/
std::vector<std::string> multipath;
if (!URIUtils::IsMultiPath(pItem->GetPath()) || !CMultiPathDirectory::GetPaths(pItem->GetPath(), multipath))
multipath.push_back(pItem->GetPath());
std::vector<std::pair<std::string, std::string> > paths;
for (std::vector<std::string>::const_iterator i = multipath.begin(); i != multipath.end(); ++i)
paths.push_back(std::make_pair(*i, URIUtils::GetParentPath(*i)));
std::map<int, std::map<std::string, std::string> > seasonArt;
if (!libraryImport)
GetSeasonThumbs(movieDetails, seasonArt, CVideoThumbLoader::GetArtTypes(MediaTypeSeason), useLocal);
lResult = m_database.SetDetailsForTvShow(paths, movieDetails, art, seasonArt);
movieDetails.m_iDbId = lResult;
movieDetails.m_type = MediaTypeTvShow;
}
else
{
// we add episode then set details, as otherwise set details will delete the
// episode then add, which breaks multi-episode files.
int idShow = showInfo ? showInfo->m_iDbId : -1;
int idEpisode = m_database.AddEpisode(idShow, pItem->GetPath());
lResult = m_database.SetDetailsForEpisode(pItem->GetPath(), movieDetails, art, idShow, idEpisode);
movieDetails.m_iDbId = lResult;
movieDetails.m_type = MediaTypeEpisode;
movieDetails.m_strShowTitle = showInfo ? showInfo->m_strTitle : "";
if (movieDetails.m_fEpBookmark > 0)
{
movieDetails.m_strFileNameAndPath = pItem->GetPath();
CBookmark bookmark;
bookmark.timeInSeconds = movieDetails.m_fEpBookmark;
bookmark.seasonNumber = movieDetails.m_iSeason;
bookmark.episodeNumber = movieDetails.m_iEpisode;
m_database.AddBookMarkForEpisode(movieDetails, bookmark);
}
}
}
else if (content == CONTENT_MUSICVIDEOS)
{
lResult = m_database.SetDetailsForMusicVideo(pItem->GetPath(), movieDetails, art);
movieDetails.m_iDbId = lResult;
movieDetails.m_type = MediaTypeMusicVideo;
}
if (g_advancedSettings.m_bVideoLibraryImportWatchedState || libraryImport)
m_database.SetPlayCount(*pItem, movieDetails.m_playCount, movieDetails.m_lastPlayed);
if ((g_advancedSettings.m_bVideoLibraryImportResumePoint || libraryImport) &&
movieDetails.m_resumePoint.IsSet())
m_database.AddBookMarkToFile(pItem->GetPath(), movieDetails.m_resumePoint, CBookmark::RESUME);
m_database.Close();
CFileItemPtr itemCopy = CFileItemPtr(new CFileItem(*pItem));
CVariant data;
if (m_bRunning)
data["transaction"] = true;
ANNOUNCEMENT::CAnnouncementManager::GetInstance().Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnUpdate", itemCopy, data);
return lResult;
}
std::string ContentToMediaType(CONTENT_TYPE content, bool folder)
{
switch (content)
{
case CONTENT_MOVIES:
return MediaTypeMovie;
case CONTENT_MUSICVIDEOS:
return MediaTypeMusicVideo;
case CONTENT_TVSHOWS:
return folder ? MediaTypeTvShow : MediaTypeEpisode;
default:
return "";
}
}
std::string CVideoInfoScanner::GetArtTypeFromSize(unsigned int width, unsigned int height)
{
std::string type = "thumb";
if (width*5 < height*4)
type = "poster";
else if (width*1 > height*4)
type = "banner";
return type;
}
void CVideoInfoScanner::GetArtwork(CFileItem *pItem, const CONTENT_TYPE &content, bool bApplyToDir, bool useLocal, const std::string &actorArtPath)
{
CVideoInfoTag &movieDetails = *pItem->GetVideoInfoTag();
movieDetails.m_fanart.Unpack();
movieDetails.m_strPictureURL.Parse();
CGUIListItem::ArtMap art = pItem->GetArt();
// get and cache thumb images
std::vector<std::string> artTypes = CVideoThumbLoader::GetArtTypes(ContentToMediaType(content, pItem->m_bIsFolder));
std::vector<std::string>::iterator i = find(artTypes.begin(), artTypes.end(), "fanart");
if (i != artTypes.end())
artTypes.erase(i); // fanart is handled below
bool lookForThumb = find(artTypes.begin(), artTypes.end(), "thumb") == artTypes.end() &&
art.find("thumb") == art.end();
// find local art
if (useLocal)
{
for (std::vector<std::string>::const_iterator i = artTypes.begin(); i != artTypes.end(); ++i)
{
if (art.find(*i) == art.end())
{
std::string image = CVideoThumbLoader::GetLocalArt(*pItem, *i, bApplyToDir);
if (!image.empty())
art.insert(std::make_pair(*i, image));
}
}
// find and classify the local thumb (backcompat) if available
if (lookForThumb)
{
std::string image = CVideoThumbLoader::GetLocalArt(*pItem, "thumb", bApplyToDir);
if (!image.empty())
{ // cache the image and determine sizing
CTextureDetails details;
if (CTextureCache::GetInstance().CacheImage(image, details))
{
std::string type = GetArtTypeFromSize(details.width, details.height);
if (art.find(type) == art.end())
art.insert(std::make_pair(type, image));
}
}
}
}
// find online art
for (std::vector<std::string>::const_iterator i = artTypes.begin(); i != artTypes.end(); ++i)
{
if (art.find(*i) == art.end())
{
std::string image = GetImage(pItem, false, bApplyToDir, *i);
if (!image.empty())
art.insert(std::make_pair(*i, image));
}
}
// use the first piece of online art as the first art type if no thumb type is available yet
if (art.empty() && lookForThumb)
{
std::string image = GetImage(pItem, false, bApplyToDir, "thumb");
if (!image.empty())
art.insert(std::make_pair(artTypes.front(), image));
}
// get & save fanart image (treated separately due to it being stored in m_fanart)
bool isEpisode = (content == CONTENT_TVSHOWS && !pItem->m_bIsFolder);
if (!isEpisode && art.find("fanart") == art.end())
{
std::string fanart = GetFanart(pItem, useLocal);
if (!fanart.empty())
art.insert(std::make_pair("fanart", fanart));
}
for (CGUIListItem::ArtMap::const_iterator i = art.begin(); i != art.end(); ++i)
CTextureCache::GetInstance().BackgroundCacheImage(i->second);
pItem->SetArt(art);
// parent folder to apply the thumb to and to search for local actor thumbs
std::string parentDir = URIUtils::GetBasePath(pItem->GetPath());
if (CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOLIBRARY_ACTORTHUMBS))
FetchActorThumbs(movieDetails.m_cast, actorArtPath.empty() ? parentDir : actorArtPath);
if (bApplyToDir)
ApplyThumbToFolder(parentDir, art["thumb"]);
}
std::string CVideoInfoScanner::GetImage(CFileItem *pItem, bool useLocal, bool bApplyToDir, const std::string &type)
{
std::string thumb;
if (useLocal)
thumb = CVideoThumbLoader::GetLocalArt(*pItem, type, bApplyToDir);
if (thumb.empty())
{
thumb = CScraperUrl::GetThumbURL(pItem->GetVideoInfoTag()->m_strPictureURL.GetFirstThumb(type));
if (!thumb.empty())
{
if (thumb.find("http://") == std::string::npos &&
thumb.find("/") == std::string::npos &&
thumb.find("\\") == std::string::npos)
{
std::string strPath = URIUtils::GetDirectory(pItem->GetPath());
thumb = URIUtils::AddFileToFolder(strPath, thumb);
}
}
}
return thumb;
}
std::string CVideoInfoScanner::GetFanart(CFileItem *pItem, bool useLocal)
{
if (!pItem)
return "";
std::string fanart = pItem->GetArt("fanart");
if (fanart.empty() && useLocal)
fanart = pItem->FindLocalArt("fanart.jpg", true);
if (fanart.empty())
fanart = pItem->GetVideoInfoTag()->m_fanart.GetImageURL();
return fanart;
}
INFO_RET CVideoInfoScanner::OnProcessSeriesFolder(EPISODELIST& files, const ADDON::ScraperPtr &scraper, bool useLocal, const CVideoInfoTag& showInfo, CGUIDialogProgress* pDlgProgress /* = NULL */)
{
if (pDlgProgress)
{
pDlgProgress->SetLine(1, CVariant{showInfo.m_strTitle});
pDlgProgress->SetLine(2, CVariant{20361});
pDlgProgress->SetPercentage(0);
pDlgProgress->ShowProgressBar(true);
pDlgProgress->Progress();
}
EPISODELIST episodes;
bool hasEpisodeGuide = false;
int iMax = files.size();
int iCurr = 1;
for (EPISODELIST::iterator file = files.begin(); file != files.end(); ++file)
{
m_nfoReader.Close();
if (pDlgProgress)
{
pDlgProgress->SetLine(2, CVariant{20361});
pDlgProgress->SetPercentage((int)((float)(iCurr++)/iMax*100));
pDlgProgress->Progress();
}
if (m_handle)
m_handle->SetPercentage(100.f*iCurr++/iMax);
if ((pDlgProgress && pDlgProgress->IsCanceled()) || m_bStop)
return INFO_CANCELLED;
if (m_database.GetEpisodeId(file->strPath, file->iEpisode, file->iSeason) > -1)
{
if (m_handle)
m_handle->SetText(g_localizeStrings.Get(20415));
continue;
}
CFileItem item;
item.SetPath(file->strPath);
// handle .nfo files
CNfoFile::NFOResult result=CNfoFile::NO_NFO;
CScraperUrl scrUrl;
ScraperPtr info(scraper);
item.GetVideoInfoTag()->m_iEpisode = file->iEpisode;
if (useLocal)
result = CheckForNFOFile(&item, false, info,scrUrl);
if (result == CNfoFile::FULL_NFO)
{
m_nfoReader.GetDetails(*item.GetVideoInfoTag());
// override with episode and season number from file if available
if (file->iEpisode > -1)
{
item.GetVideoInfoTag()->m_iEpisode = file->iEpisode;
item.GetVideoInfoTag()->m_iSeason = file->iSeason;
}
if (AddVideo(&item, CONTENT_TVSHOWS, file->isFolder, true, &showInfo) < 0)
return INFO_ERROR;
continue;
}
if (!hasEpisodeGuide)
{
// fetch episode guide
if (!showInfo.m_strEpisodeGuide.empty())
{
CScraperUrl url;
url.ParseEpisodeGuide(showInfo.m_strEpisodeGuide);
if (pDlgProgress)
{
pDlgProgress->SetLine(2, CVariant{20354});
pDlgProgress->Progress();
}
CVideoInfoDownloader imdb(scraper);
if (!imdb.GetEpisodeList(url, episodes))
return INFO_NOT_FOUND;
hasEpisodeGuide = true;
}
}
if (episodes.empty())
{
CLog::Log(LOGERROR, "VideoInfoScanner: Asked to lookup episode %s"
" online, but we have no episode guide. Check your tvshow.nfo and make"
" sure the <episodeguide> tag is in place.", CURL::GetRedacted(file->strPath).c_str());
continue;
}
EPISODE key(file->iSeason, file->iEpisode, file->iSubepisode);
EPISODE backupkey(file->iSeason, file->iEpisode, 0);
bool bFound = false;
EPISODELIST::iterator guide = episodes.begin();
EPISODELIST matches;
for (; guide != episodes.end(); ++guide )
{
if ((file->iEpisode!=-1) && (file->iSeason!=-1))
{
if (key==*guide)
{
bFound = true;
break;
}
else if ((file->iSubepisode!=0) && (backupkey==*guide))
{
matches.push_back(*guide);
continue;
}
}
if (file->cDate.IsValid() && guide->cDate.IsValid() && file->cDate==guide->cDate)
{
matches.push_back(*guide);
continue;
}
if (!guide->cScraperUrl.strTitle.empty() && StringUtils::EqualsNoCase(guide->cScraperUrl.strTitle, file->strTitle))
{
bFound = true;
break;
}
}
if (!bFound)
{
/*
* If there is only one match or there are matches but no title to compare with to help
* identify the best match, then pick the first match as the best possible candidate.
*
* Otherwise, use the title to further refine the best match.
*/
if (matches.size() == 1 || (file->strTitle.empty() && matches.size() > 1))
{
guide = matches.begin();
bFound = true;
}
else if (!file->strTitle.empty())
{
double minscore = 0; // Default minimum score is 0 to find whatever is the best match.
EPISODELIST *candidates;
if (matches.empty()) // No matches found using earlier criteria. Use fuzzy match on titles across all episodes.
{
minscore = 0.8; // 80% should ensure a good match.
candidates = &episodes;
}
else // Multiple matches found. Use fuzzy match on the title with already matched episodes to pick the best.
candidates = &matches;
std::vector<std::string> titles;
for (guide = candidates->begin(); guide != candidates->end(); ++guide)
{
StringUtils::ToLower(guide->cScraperUrl.strTitle);
titles.push_back(guide->cScraperUrl.strTitle);
}
double matchscore;
std::string loweredTitle(file->strTitle);
StringUtils::ToLower(loweredTitle);
int index = StringUtils::FindBestMatch(loweredTitle, titles, matchscore);
if (matchscore >= minscore)
{
guide = candidates->begin() + index;
bFound = true;
CLog::Log(LOGDEBUG,"%s fuzzy title match for show: '%s', title: '%s', match: '%s', score: %f >= %f",
__FUNCTION__, showInfo.m_strTitle.c_str(), file->strTitle.c_str(), titles[index].c_str(), matchscore, minscore);
}
}
}
if (bFound)
{
CVideoInfoDownloader imdb(scraper);
CFileItem item;
item.SetPath(file->strPath);
if (!imdb.GetEpisodeDetails(guide->cScraperUrl, *item.GetVideoInfoTag(), pDlgProgress))
return INFO_NOT_FOUND; // TODO: should we just skip to the next episode?
// Only set season/epnum from filename when it is not already set by a scraper
if (item.GetVideoInfoTag()->m_iSeason == -1)
item.GetVideoInfoTag()->m_iSeason = guide->iSeason;
if (item.GetVideoInfoTag()->m_iEpisode == -1)
item.GetVideoInfoTag()->m_iEpisode = guide->iEpisode;
if (AddVideo(&item, CONTENT_TVSHOWS, file->isFolder, useLocal, &showInfo) < 0)
return INFO_ERROR;
}
else
{
CLog::Log(LOGDEBUG,"%s - no match for show: '%s', season: %d, episode: %d.%d, airdate: '%s', title: '%s'",
__FUNCTION__, showInfo.m_strTitle.c_str(), file->iSeason, file->iEpisode, file->iSubepisode,
file->cDate.GetAsLocalizedDate().c_str(), file->strTitle.c_str());
}
}
return INFO_ADDED;
}
std::string CVideoInfoScanner::GetnfoFile(CFileItem *item, bool bGrabAny) const
{
std::string nfoFile;
// Find a matching .nfo file
if (!item->m_bIsFolder)
{
if (URIUtils::IsInRAR(item->GetPath())) // we have a rarred item - we want to check outside the rars
{
CFileItem item2(*item);
CURL url(item->GetPath());
std::string strPath = URIUtils::GetDirectory(url.GetHostName());
item2.SetPath(URIUtils::AddFileToFolder(strPath, URIUtils::GetFileName(item->GetPath())));
return GetnfoFile(&item2, bGrabAny);
}
// grab the folder path
std::string strPath = URIUtils::GetDirectory(item->GetPath());
if (bGrabAny && !item->IsStack())
{ // looking up by folder name - movie.nfo takes priority - but not for stacked items (handled below)
nfoFile = URIUtils::AddFileToFolder(strPath, "movie.nfo");
if (CFile::Exists(nfoFile))
return nfoFile;
}
// try looking for .nfo file for a stacked item
if (item->IsStack())
{
// first try .nfo file matching first file in stack
CStackDirectory dir;
std::string firstFile = dir.GetFirstStackedFile(item->GetPath());
CFileItem item2;
item2.SetPath(firstFile);
nfoFile = GetnfoFile(&item2, bGrabAny);
// else try .nfo file matching stacked title
if (nfoFile.empty())
{
std::string stackedTitlePath = dir.GetStackedTitlePath(item->GetPath());
item2.SetPath(stackedTitlePath);
nfoFile = GetnfoFile(&item2, bGrabAny);
}
}
else
{
// already an .nfo file?
if (URIUtils::HasExtension(item->GetPath(), ".nfo"))
nfoFile = item->GetPath();
// no, create .nfo file
else
nfoFile = URIUtils::ReplaceExtension(item->GetPath(), ".nfo");
}
// test file existence
if (!nfoFile.empty() && !CFile::Exists(nfoFile))
nfoFile.clear();
if (nfoFile.empty()) // final attempt - strip off any cd1 folders
{
URIUtils::RemoveSlashAtEnd(strPath); // need no slash for the check that follows
CFileItem item2;
if (StringUtils::EndsWithNoCase(strPath, "cd1"))
{
strPath.erase(strPath.size() - 3);
item2.SetPath(URIUtils::AddFileToFolder(strPath, URIUtils::GetFileName(item->GetPath())));
return GetnfoFile(&item2, bGrabAny);
}
}
if (nfoFile.empty() && item->IsOpticalMediaFile())
{
CFileItem parentDirectory(item->GetLocalMetadataPath(), true);
nfoFile = GetnfoFile(&parentDirectory, true);
}
}
// folders (or stacked dvds) can take any nfo file if there's a unique one
if (item->m_bIsFolder || item->IsOpticalMediaFile() || (bGrabAny && nfoFile.empty()))
{
// see if there is a unique nfo file in this folder, and if so, use that
CFileItemList items;
CDirectory dir;
std::string strPath;
if (item->m_bIsFolder)
strPath = item->GetPath();
else
strPath = URIUtils::GetDirectory(item->GetPath());
if (dir.GetDirectory(strPath, items, ".nfo") && items.Size())
{
int numNFO = -1;
for (int i = 0; i < items.Size(); i++)
{
if (items[i]->IsNFO())
{
if (numNFO == -1)
numNFO = i;
else
{
numNFO = -1;
break;
}
}
}
if (numNFO > -1)
return items[numNFO]->GetPath();
}
}
return nfoFile;
}
bool CVideoInfoScanner::GetDetails(CFileItem *pItem, CScraperUrl &url, const ScraperPtr& scraper, CNfoFile *nfoFile, CGUIDialogProgress* pDialog /* = NULL */)
{
CVideoInfoTag movieDetails;
if (m_handle && !url.strTitle.empty())
m_handle->SetText(url.strTitle);
CVideoInfoDownloader imdb(scraper);
bool ret = imdb.GetDetails(url, movieDetails, pDialog);
if (ret)
{
if (nfoFile)
nfoFile->GetDetails(movieDetails,NULL,true);
if (m_handle && url.strTitle.empty())
m_handle->SetText(movieDetails.m_strTitle);
if (pDialog)
{
pDialog->SetLine(1, CVariant{movieDetails.m_strTitle});
pDialog->Progress();
}
*pItem->GetVideoInfoTag() = movieDetails;
return true;
}
return false; // no info found, or cancelled
}
void CVideoInfoScanner::ApplyThumbToFolder(const std::string &folder, const std::string &imdbThumb)
{
// copy icon to folder also;
if (!imdbThumb.empty())
{
CFileItem folderItem(folder, true);
CThumbLoader loader;
loader.SetCachedImage(folderItem, "thumb", imdbThumb);
}
}
int CVideoInfoScanner::GetPathHash(const CFileItemList &items, std::string &hash)
{
// Create a hash based on the filenames, filesize and filedate. Also count the number of files
if (0 == items.Size()) return 0;
XBMC::XBMC_MD5 md5state;
int count = 0;
for (int i = 0; i < items.Size(); ++i)
{
const CFileItemPtr pItem = items[i];
md5state.append(pItem->GetPath());
md5state.append((unsigned char *)&pItem->m_dwSize, sizeof(pItem->m_dwSize));
FILETIME time = pItem->m_dateTime;
md5state.append((unsigned char *)&time, sizeof(FILETIME));
if (pItem->IsVideo() && !pItem->IsPlayList() && !pItem->IsNFO())
count++;
}
hash = md5state.getDigest();
return count;
}
bool CVideoInfoScanner::CanFastHash(const CFileItemList &items, const std::vector<std::string> &excludes) const
{
if (!g_advancedSettings.m_bVideoLibraryUseFastHash)
return false;
for (int i = 0; i < items.Size(); ++i)
{
if (items[i]->m_bIsFolder && !CUtil::ExcludeFileOrFolder(items[i]->GetPath(), excludes))
return false;
}
return true;
}
std::string CVideoInfoScanner::GetFastHash(const std::string &directory,
const std::vector<std::string> &excludes) const
{
XBMC::XBMC_MD5 md5state;
if (excludes.size())
md5state.append(StringUtils::Join(excludes, "|"));
struct __stat64 buffer;
if (XFILE::CFile::Stat(directory, &buffer) == 0)
{
int64_t time = buffer.st_mtime;
if (!time)
time = buffer.st_ctime;
if (time)
{
md5state.append((unsigned char *)&time, sizeof(time));
return md5state.getDigest();
}
}
return "";
}
std::string CVideoInfoScanner::GetRecursiveFastHash(const std::string &directory,
const std::vector<std::string> &excludes) const
{
CFileItemList items;
items.Add(CFileItemPtr(new CFileItem(directory, true)));
CUtil::GetRecursiveDirsListing(directory, items, DIR_FLAG_NO_FILE_DIRS | DIR_FLAG_NO_FILE_INFO);
XBMC::XBMC_MD5 md5state;
if (excludes.size())
md5state.append(StringUtils::Join(excludes, "|"));
int64_t time = 0;
for (int i=0; i < items.Size(); ++i)
{
int64_t stat_time = 0;
struct __stat64 buffer;
if (XFILE::CFile::Stat(items[i]->GetPath(), &buffer) == 0)
{
// TODO: some filesystems may return the mtime/ctime inline, in which case this is
// unnecessarily expensive. Consider supporting Stat() in our directory cache?
stat_time = buffer.st_mtime ? buffer.st_mtime : buffer.st_ctime;
time += stat_time;
}
if (!stat_time)
return "";
}
if (time)
{
md5state.append((unsigned char *)&time, sizeof(time));
return md5state.getDigest();
}
return "";
}
void CVideoInfoScanner::GetSeasonThumbs(const CVideoInfoTag &show,
std::map<int, std::map<std::string, std::string>> &seasonArt, const std::vector<std::string> &artTypes, bool useLocal)
{
bool lookForThumb = find(artTypes.begin(), artTypes.end(), "thumb") == artTypes.end();
// find the maximum number of seasons we have thumbs for (local + remote)
int maxSeasons = show.m_strPictureURL.GetMaxSeasonThumb();
CFileItemList items;
CDirectory::GetDirectory(show.m_strPath, items, ".png|.jpg|.tbn", DIR_FLAG_NO_FILE_DIRS | DIR_FLAG_NO_FILE_INFO);
CRegExp reg;
if (items.Size() && reg.RegComp("season([0-9]+)(-[a-z]+)?\\.(tbn|jpg|png)"))
{
for (int i = 0; i < items.Size(); i++)
{
std::string name = URIUtils::GetFileName(items[i]->GetPath());
if (reg.RegFind(name) > -1)
{
int season = atoi(reg.GetMatch(1).c_str());
if (season > maxSeasons)
maxSeasons = season;
}
}
}
for (int season = -1; season <= maxSeasons; season++)
{
// skip if we already have some art
std::map<int, std::map<std::string, std::string>>::const_iterator it = seasonArt.find(season);
if (it != seasonArt.end() && !it->second.empty())
continue;
std::map<std::string, std::string> art;
if (useLocal)
{
std::string basePath;
if (season == -1)
basePath = "season-all";
else if (season == 0)
basePath = "season-specials";
else
basePath = StringUtils::Format("season%02i", season);
CFileItem artItem(URIUtils::AddFileToFolder(show.m_strPath, basePath), false);
for (std::vector<std::string>::const_iterator i = artTypes.begin(); i != artTypes.end(); ++i)
{
std::string image = CVideoThumbLoader::GetLocalArt(artItem, *i, false);
if (!image.empty())
art.insert(std::make_pair(*i, image));
}
// find and classify the local thumb (backcompat) if available
if (lookForThumb)
{
std::string image = CVideoThumbLoader::GetLocalArt(artItem, "thumb", false);
if (!image.empty())
{ // cache the image and determine sizing
CTextureDetails details;
if (CTextureCache::GetInstance().CacheImage(image, details))
{
std::string type = GetArtTypeFromSize(details.width, details.height);
if (art.find(type) == art.end())
art.insert(std::make_pair(type, image));
}
}
}
}
// find online art
for (std::vector<std::string>::const_iterator i = artTypes.begin(); i != artTypes.end(); ++i)
{
if (art.find(*i) == art.end())
{
std::string image = CScraperUrl::GetThumbURL(show.m_strPictureURL.GetSeasonThumb(season, *i));
if (!image.empty())
art.insert(std::make_pair(*i, image));
}
}
// use the first piece of online art as the first art type if no thumb type is available yet
if (art.empty() && lookForThumb)
{
std::string image = CScraperUrl::GetThumbURL(show.m_strPictureURL.GetSeasonThumb(season, "thumb"));
if (!image.empty())
art.insert(std::make_pair(artTypes.front(), image));
}
seasonArt[season] = art;
}
}
void CVideoInfoScanner::FetchActorThumbs(std::vector<SActorInfo>& actors, const std::string& strPath)
{
CFileItemList items;
std::string actorsDir = URIUtils::AddFileToFolder(strPath, ".actors");
if (CDirectory::Exists(actorsDir))
CDirectory::GetDirectory(actorsDir, items, ".png|.jpg|.tbn", DIR_FLAG_NO_FILE_DIRS |
DIR_FLAG_NO_FILE_INFO);
for (std::vector<SActorInfo>::iterator i = actors.begin(); i != actors.end(); ++i)
{
if (i->thumb.empty())
{
std::string thumbFile = i->strName;
StringUtils::Replace(thumbFile, ' ', '_');
for (int j = 0; j < items.Size(); j++)
{
std::string compare = URIUtils::GetFileName(items[j]->GetPath());
URIUtils::RemoveExtension(compare);
if (!items[j]->m_bIsFolder && compare == thumbFile)
{
i->thumb = items[j]->GetPath();
break;
}
}
if (i->thumb.empty() && !i->thumbUrl.GetFirstThumb().m_url.empty())
i->thumb = CScraperUrl::GetThumbURL(i->thumbUrl.GetFirstThumb());
if (!i->thumb.empty())
CTextureCache::GetInstance().BackgroundCacheImage(i->thumb);
}
}
}
CNfoFile::NFOResult CVideoInfoScanner::CheckForNFOFile(CFileItem* pItem, bool bGrabAny, ScraperPtr& info, CScraperUrl& scrUrl)
{
std::string strNfoFile;
if (info->Content() == CONTENT_MOVIES || info->Content() == CONTENT_MUSICVIDEOS
|| (info->Content() == CONTENT_TVSHOWS && !pItem->m_bIsFolder))
strNfoFile = GetnfoFile(pItem, bGrabAny);
else if (info->Content() == CONTENT_TVSHOWS && pItem->m_bIsFolder)
strNfoFile = URIUtils::AddFileToFolder(pItem->GetPath(), "tvshow.nfo");
CNfoFile::NFOResult result=CNfoFile::NO_NFO;
if (!strNfoFile.empty() && CFile::Exists(strNfoFile))
{
if (info->Content() == CONTENT_TVSHOWS && !pItem->m_bIsFolder)
result = m_nfoReader.Create(strNfoFile,info,pItem->GetVideoInfoTag()->m_iEpisode);
else
result = m_nfoReader.Create(strNfoFile,info);
std::string type;
switch(result)
{
case CNfoFile::COMBINED_NFO:
type = "Mixed";
break;
case CNfoFile::FULL_NFO:
type = "Full";
break;
case CNfoFile::URL_NFO:
type = "URL";
break;
case CNfoFile::NO_NFO:
type = "";
break;
default:
type = "malformed";
}
if (result != CNfoFile::NO_NFO)
CLog::Log(LOGDEBUG, "VideoInfoScanner: Found matching %s NFO file: %s", type.c_str(), CURL::GetRedacted(strNfoFile).c_str());
if (result == CNfoFile::FULL_NFO)
{
if (info->Content() == CONTENT_TVSHOWS)
info = m_nfoReader.GetScraperInfo();
}
else if (result != CNfoFile::NO_NFO && result != CNfoFile::ERROR_NFO)
{
scrUrl = m_nfoReader.ScraperUrl();
info = m_nfoReader.GetScraperInfo();
StringUtils::RemoveCRLF(scrUrl.m_url[0].m_url);
CLog::Log(LOGDEBUG, "VideoInfoScanner: Fetching url '%s' using %s scraper (content: '%s')",
scrUrl.m_url[0].m_url.c_str(), info->Name().c_str(), TranslateContent(info->Content()).c_str());
if (result == CNfoFile::COMBINED_NFO)
m_nfoReader.GetDetails(*pItem->GetVideoInfoTag());
}
}
else
CLog::Log(LOGDEBUG, "VideoInfoScanner: No NFO file found. Using title search for '%s'", CURL::GetRedacted(pItem->GetPath()).c_str());
return result;
}
bool CVideoInfoScanner::DownloadFailed(CGUIDialogProgress* pDialog)
{
if (g_advancedSettings.m_bVideoScannerIgnoreErrors)
return true;
if (pDialog)
{
CGUIDialogOK::ShowAndGetInput(CVariant{20448}, CVariant{20449});
return false;
}
return HELPERS::ShowYesNoDialogText(CVariant{20448}, CVariant{20450}) == DialogResponse::YES;
}
bool CVideoInfoScanner::ProgressCancelled(CGUIDialogProgress* progress, int heading, const std::string &line1)
{
if (progress)
{
progress->SetHeading(CVariant{heading});
progress->SetLine(0, CVariant{line1});
progress->SetLine(2, CVariant{""});
progress->Progress();
return progress->IsCanceled();
}
return m_bStop;
}
int CVideoInfoScanner::FindVideo(const std::string &videoName, const ScraperPtr &scraper, CScraperUrl &url, CGUIDialogProgress *progress)
{
MOVIELIST movielist;
CVideoInfoDownloader imdb(scraper);
int returncode = imdb.FindMovie(videoName, movielist, progress);
if (returncode < 0 || (returncode == 0 && (m_bStop || !DownloadFailed(progress))))
{ // scraper reported an error, or we had an error and user wants to cancel the scan
m_bStop = true;
return -1; // cancelled
}
if (returncode > 0 && movielist.size())
{
url = movielist[0];
return 1; // found a movie
}
return 0; // didn't find anything
}
}
|
#include <Components/PlayerComp.h>
#include <Core/GameObjectManager.h>
#include <Components/ModelComp.h>
#include <Components/BoxColliderComp.h>
#include <Components/TransformComp.h>
#include <Utils/Ray.h>
#include <Components/RigidBodyComp.h>
void Components::PlayerComp::ProcessKeyInput(Core::GameObjectManager& p_gameManager, const double & p_deltaTime)
{
Rendering::Managers::InputManager* inputManager = &*Rendering::Managers::InputManager::GetInstance();
if (inputManager->GetKey(Rendering::Managers::InputManager::KeyCode::W)) //move forward
{
MovePlayer(m_camera->GetFront() * static_cast<float>(p_deltaTime));
}
if (inputManager->GetKey(Rendering::Managers::InputManager::KeyCode::S)) //move backward
{
MovePlayer(-m_camera->GetFront() * static_cast<float>(p_deltaTime));
}
if (inputManager->GetKey(Rendering::Managers::InputManager::KeyCode::A)) //move left
{
MovePlayer(-m_camera->GetRight() * static_cast<float>(p_deltaTime));
}
if (inputManager->GetKey(Rendering::Managers::InputManager::KeyCode::D)) //move right
{
MovePlayer(m_camera->GetRight() * static_cast<float>(p_deltaTime));
}
if (Rendering::Managers::InputManager::GetInstance()->GetKeyDown(Rendering::Managers::InputManager::KeyCode::Mouse0))
{
if (m_gameObject.GetComponent<RigidBodyComp>() != nullptr)
{
m_gameObject.GetComponent<RigidBodyComp>()->AddForce({ 0, 15, 0 });
}
std::shared_ptr<Core::GameObject> collision = Utils::RayCast(m_gameObject, m_camera->GetFront(), p_gameManager, 1000);
if (collision != nullptr)
{
p_gameManager.RemoveGameObject(collision);
}
}
}
void Components::PlayerComp::Update()
{
m_camera->SetPosition(m_gameObject.GetComponent<TransformComp>()->GetTransform()->GetPosition());
}
std::shared_ptr<Core::GameObject> Components::PlayerComp::RayCast(Core::GameObjectManager& p_gameManager, int p_maxDistance = 100) const
{
glm::vec3 currPos = m_gameObject.GetComponent<TransformComp>()->GetTransform()->GetPosition() + m_camera->GetFront();
glm::vec3 cameraFront = glm::normalize(m_camera->GetFront());
cameraFront.x /= 10.0f;
cameraFront.y /= 10.0f;
cameraFront.z /= 10.0f;
for (int i = 0; i < p_maxDistance; ++i)
{
for (auto& gameObject : p_gameManager.GetGameObjects())
{
if (&*gameObject == &m_gameObject ||
glm::distance(gameObject->GetComponent<TransformComp>()->GetTransform()->GetPosition(),
m_gameObject.GetComponent<TransformComp>()->GetTransform()->GetPosition()) > p_maxDistance ||
gameObject->GetComponent<TransformComp>() == nullptr ||
gameObject->GetComponent<ModelComp>() == nullptr ||
gameObject->GetComponent<BoxColliderComp>() == nullptr ||
gameObject->GetTag() == "NonDestructable")
continue;
currPos = currPos + cameraFront;
glm::vec4 minVec = gameObject->GetComponent<BoxColliderComp>()->GetCollider()->GetMinVec();
glm::vec4 maxVec = gameObject->GetComponent<BoxColliderComp>()->GetCollider()->GetMaxVec();
if (maxVec.x > currPos.x && minVec.x < currPos.x &&
maxVec.y > currPos.y && minVec.y < currPos.y &&
maxVec.z > currPos.z && minVec.z < currPos.z)
{
std::cout << m_gameObject.GetName() << " raycast collision with " << gameObject->GetName() << '\n';
return gameObject;
}
}
}
return {};
}
void Components::PlayerComp::MovePlayer(const glm::vec3& p_direction) const
{
if (m_gameObject.GetComponent<Components::RigidBodyComp>() != nullptr)
m_gameObject.GetComponent<Components::RigidBodyComp>()->GetRigidBody()->SetPosition(m_camera->GetPosition() + p_direction * m_camera->GetMovementSpeed());
else
m_gameObject.GetComponent<Components::TransformComp>()->GetTransform()->SetPosition(m_camera->GetPosition() + p_direction * m_camera->GetMovementSpeed());
}
void Components::PlayerComp::Serialize(XMLElement* p_compSegment, XMLDocument& p_xmlDoc) const noexcept
{
std::cout << "[PLAYER_COMP] Function not implemented\n";
}
void Components::PlayerComp::Deserialize(XMLElement* p_compSegment) const noexcept
{
std::cout << "[PLAYER_COMP] Function not implemented\n";
}
|
; A258648: Eighth arithmetic derivative of n.
; 0,0,0,0,4,0,0,0,1520,0,0,0,3424,0,0,752,8592,0,0,0,3120,0,0,0,8144,0,368,27,8592,0,0,0,20096,0,0,1520,8976,0,0,3424,2176,0,0,0,16304,1520,0,0,32624,0,752,1552,8976,0,10260,3424,22288,0,0,0,22288,0,0,608,12976128,0,0,0,7744,176,0,0,24640,0,1520,1520,20096,0,0,0,70464,23112,0,0,169216,0,752,8592,245760,0,3120,1552,47872,0,0,3120,198656,0,0,752
seq $0,258647 ; Seventh arithmetic derivative of n.
seq $0,3415 ; a(n) = n' = arithmetic derivative of n: a(0) = a(1) = 0, a(prime) = 1, a(mn) = m*a(n) + n*a(m).
|
format PE64 GUI 5.0
entry start
; from chapter 5 of Ruslan Ablyazovs book
include 'win64a.inc'
section '.data' data readable writeable
main_hwnd dq ?
msg MSG
wc WNDCLASS
hInst dq ?
szTitleName db 'Window work sample Win64',0
szClassName db 'ASMCLASS32',0
button_class db 'BUTTON',0
AboutTitle db 'About',0
AboutText db 'First win64 window program',0;
ExitTitle db 'Exit',0
AboutBtnHandle dq ?
ExitBtnHandle dq ?
section '.code' code executable readable
start:
sub rsp, 8*5 ; align stack and alloc space for 4 parameters
xor rcx, rcx
call [GetModuleHandle]
mov [hInst], rax
mov [wc.style], CS_HREDRAW + CS_VREDRAW + CS_GLOBALCLASS
mov rbx, WndProc
mov [wc.lpfnWndProc], rbx
mov [wc.cbClsExtra], 0
mov [wc.cbWndExtra], 0
mov [wc.hInstance], rax
mov rdx, IDI_APPLICATION
xor rcx, rcx
call [LoadIcon]
mov [wc.hIcon], rax
mov rdx, IDC_ARROW
xor rcx, rcx
call [LoadCursor]
mov [wc.hCursor], rax
mov [wc.hbrBackground], COLOR_BACKGROUND+1
mov qword [wc.lpszMenuName], 0
mov rbx, szClassName
mov qword [wc.lpszClassName], rbx
mov rcx, wc
call [RegisterClass]
sub rsp, 8*8 ; alloc place in stack for 8 parameters
xor rcx, rcx
mov rdx, szClassName
mov r8, szTitleName
mov r9, WS_OVERLAPPEDWINDOW
mov qword [rsp+8*4], 50
mov qword [rsp+8*5], 50
mov qword [rsp+8*6], 300
mov qword [rsp+8*7], 250
mov qword [rsp+8*8], rcx
mov qword [rsp+8*9], rcx
mov rbx, [hInst]
mov [rsp+8*10], rbx
mov [rsp+8*11], rcx
call [CreateWindowEx]
mov [main_hwnd], rax
xor rcx, rcx
mov rdx, button_class
mov r8, AboutTitle
mov r9, WS_CHILD
mov qword [rsp+8*4], 50
mov qword [rsp+8*5], 50
mov qword [rsp+8*6], 200
mov qword [rsp+8*7], 50
mov rbx, [main_hwnd]
mov qword [rsp+8*8], rbx
mov qword [rsp+8*9], rcx
mov rbx, [hInst]
mov [rsp+8*10], rbx
mov [rsp+8*11], rcx
call [CreateWindowEx]
mov [AboutBtnHandle], rax
xor rcx, rcx
mov rdx, button_class
mov r8, ExitTitle
mov r9, WS_CHILD
mov qword [rsp+8*4], 50
mov qword [rsp+8*5], 150
mov qword [rsp+8*6], 200
mov qword [rsp+8*7], 50
mov rbx, [main_hwnd]
mov qword [rsp+8*8], rbx
mov qword [rsp+8*9], rcx
mov rbx, [hInst]
mov [rsp+8*10], rbx
mov [rsp+8*11], rcx
call [CreateWindowEx]
mov [ExitBtnHandle], rax
add rsp, 8*8 ; free place in stack
mov rdx, SW_SHOWNORMAL
mov rcx, [main_hwnd]
call [ShowWindow]
mov rcx, [main_hwnd]
call [UpdateWindow]
mov rdx, SW_SHOWNORMAL
mov rcx, [AboutBtnHandle]
call [ShowWindow]
mov rdx, SW_SHOWNORMAL
mov rcx, [ExitBtnHandle]
call [ShowWindow]
msg_loop:
xor r9, r9
xor r8, r8
xor rdx, rdx
mov rcx, msg
call [GetMessage]
cmp rax,1
jb end_loop
jne msg_loop
mov rcx, msg
call [TranslateMessage]
mov rcx, msg
call [DispatchMessage]
jmp msg_loop
end_loop:
xor rcx, rcx
call [ExitProcess]
proc WndProc hwnd, wmsg, wparam, lparam ; proc macro contains prologue (push rbp; mov rbp, rsp) etc.
;
; rdx = wmsg
; r8 = wparam
; r9 = lparam
; stack aligned! because code that calls WndProc, uses 16-byte aligned stack
; when call return addr (8bytes) pushed, and after that prologue of WndProc pushes (rbp)
; and stack becomes 16-byte aligned again
sub rsp, 8*4 ; alloc space for 4 parameters
cmp rdx, WM_DESTROY
je .wmdestroy
cmp rdx, WM_COMMAND
jne .default
mov rax, r8
shr rax, 16
cmp rax, BN_CLICKED
jne .default
cmp r9, [AboutBtnHandle]
je .about
cmp r9, [ExitBtnHandle]
je .wmdestroy
.default:
call [DefWindowProc]
jmp .finish
.about:
xor rcx, rcx
mov rdx, AboutText
mov r8, AboutTitle
xor r9, r9
call [MessageBox]
jmp .finish
.wmdestroy:
xor rcx, rcx
call [ExitProcess]
.finish:
add rsp, 8*4 ; restore stack
ret
endp
section '.relocs' fixups readable writeable
section '.idata' import data readable writeable
library kernel,'KERNEL32.DLL',\
user,'USER32.DLL'
import kernel,\
GetModuleHandle,'GetModuleHandleA',\
ExitProcess,'ExitProcess'
import user,\
RegisterClass,'RegisterClassA',\
CreateWindowEx,'CreateWindowExA',\
DefWindowProc,'DefWindowProcA',\
GetMessage,'GetMessageA',\
TranslateMessage,'TranslateMessage',\
DispatchMessage,'DispatchMessageA',\
LoadCursor,'LoadCursorA',\
LoadIcon,'LoadIconA',\
ShowWindow,'ShowWindow',\
UpdateWindow,'UpdateWindow',\
MessageBox,'MessageBoxA' |
; A197691: Decimal expansion of Pi/(4 + 4*Pi).
; Submitted by Jamie Morken(l1)
; 1,8,9,6,3,6,7,4,8,2,4,8,6,9,4,0,3,6,3,3,6,1,0,7,6,7,2,2,6,1,2,2,3,2,1,6,0,3,4,6,0,6,5,9,1,4,1,0,1,3,2,7,4,9,1,6,7,2,4,7,0,5,3,4,4,5,6,3,7,0,3,4,2,7,5,2,3,9,3,4,4,0,8,0,1,5,8,2,9,3,5,0,3,8,3,8,9,4,3
add $0,1
mov $2,1
mov $3,$0
mul $3,5
lpb $3
mul $1,$3
mov $5,$3
mul $5,2
add $5,1
mul $2,$5
add $1,$2
div $1,$0
div $2,$0
sub $3,1
lpe
mul $1,2
add $2,$1
mul $2,4
mov $4,10
pow $4,$0
div $2,$4
div $1,$2
mov $0,$1
mod $0,10
|
; A121204: -2n+7^n-5^n.
; 0,0,20,212,1768,13672,102012,745404,5374160,38400464,272709604,1928498596,13597146552,95668307256,672119557196,4717043931788,33080342678944,231867574534048,1624598900644788,11379821699044980,79696898865971336,558069026925080840,3907436862791972380,27356826411125838172,191521626735791023728,1340770596440087947632,9385990221528369539972,65704911782937356311364,459949283641755341836120,3219719491298256631134424,22538408968117642609347564,157770725421972729222464556,1104404391179555259342408512
sub $1,$0
mov $2,$0
seq $2,81200 ; 6th binomial transform of (0,1,0,1,0,1,...), A000035.
add $1,$2
div $1,2
mul $1,4
mov $0,$1
|
/*
* Copyright 2013 Southwest Research Institute
*
* 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 "mtconnect_task_parser/task_parser.h"
#include "boost/make_shared.hpp"
#include <gtest/gtest.h>
TEST(TaskParser, util)
{
//TODO Should do some testing of the internal task parsing algorithms
}
TEST(MotionGroup, from_xml)
{
using namespace std;
const string xml_string =
"<motion_group name=\"my_name\" joint_names=\"joint_1 joint_2 \
joint_3 joint_4 joint_5 joint_6\"/>";
TiXmlDocument xml_doc;
xml_doc.Parse(xml_string.c_str());
TiXmlElement *xml_mg = xml_doc.FirstChildElement("motion_group");
ASSERT_TRUE(xml_mg);
mtconnect::MotionGroup mg;
ASSERT_TRUE(mtconnect::fromXml(mg, xml_mg));
// Check that group name correctly id'ed
EXPECT_EQ("my_name", mg.name_);
// The order of joint names is important, so we test order and equivalence
EXPECT_EQ("joint_1", mg.joint_names_[0]);
EXPECT_EQ("joint_2", mg.joint_names_[1]);
EXPECT_EQ("joint_3", mg.joint_names_[2]);
EXPECT_EQ("joint_4", mg.joint_names_[3]);
EXPECT_EQ("joint_5", mg.joint_names_[4]);
EXPECT_EQ("joint_6", mg.joint_names_[5]);
}
TEST(JointPoint, from_xml)
{
using namespace std;
using namespace mtconnect;
const string xml_string = "<joint_point joint_values=\"0 10 0 5 0 6\" group_name=\"group_1\"/>";
boost::shared_ptr<MotionGroup> group_ptr = boost::make_shared<MotionGroup>();
group_ptr->joint_names_.push_back("joint_1");
group_ptr->joint_names_.push_back("joint_2");
group_ptr->joint_names_.push_back("joint_3");
group_ptr->joint_names_.push_back("joint_4");
group_ptr->joint_names_.push_back("joint_5");
group_ptr->joint_names_.push_back("joint_6");
group_ptr->name_ = "group_1";
map<string, boost::shared_ptr<MotionGroup> > group_map;
group_map[group_ptr->name_] = group_ptr;
TiXmlDocument xml_doc;
xml_doc.Parse(xml_string.c_str());
TiXmlElement *xml_jp = xml_doc.FirstChildElement("joint_point");
ASSERT_TRUE(xml_jp);
JointPoint jp;
ASSERT_TRUE(fromXml(jp, xml_jp, group_map));
//Parsing XML should fail with an empty group map
group_map.clear();
ASSERT_FALSE(fromXml(jp, xml_jp, group_map));
}
TEST(JointMove, from_xml)
{
using namespace std;
using namespace mtconnect;
const string xml_string = "<joint_move> <joint_point joint_values=\"1 2 3\" group_name=\"group_1\"/></joint_move>";
boost::shared_ptr<MotionGroup> group_ptr = boost::make_shared<MotionGroup>();
group_ptr->joint_names_.push_back("joint_1");
group_ptr->joint_names_.push_back("joint_2");
group_ptr->joint_names_.push_back("joint_3");
group_ptr->name_ = "group_1";
map<string, boost::shared_ptr<MotionGroup> > group_map;
group_map[group_ptr->name_] = group_ptr;
TiXmlDocument xml_doc;
xml_doc.Parse(xml_string.c_str());
TiXmlElement *xml_jm = xml_doc.FirstChildElement("joint_move");
ASSERT_TRUE(xml_jm);
JointMove jm;
ASSERT_TRUE(fromXml(jm, xml_jm, group_map));
}
TEST(Path, from_xml)
{
using namespace std;
using namespace mtconnect;
const string xml_string = "<path name=\"path_1\">"
"<joint_move>"
"<joint_point joint_values=\"1 2 3\" group_name=\"group_1\"/>"
"</joint_move>"
"<joint_move>"
"<joint_point joint_values=\"4 5 6\" group_name=\"group_1\"/>"
"</joint_move>"
"</path>";
boost::shared_ptr<MotionGroup> group_ptr = boost::make_shared<MotionGroup>();
group_ptr->joint_names_.push_back("joint_1");
group_ptr->joint_names_.push_back("joint_2");
group_ptr->joint_names_.push_back("joint_3");
group_ptr->name_ = "group_1";
map<string, boost::shared_ptr<MotionGroup> > group_map;
group_map[group_ptr->name_] = group_ptr;
TiXmlDocument xml_doc;
xml_doc.Parse(xml_string.c_str());
TiXmlElement *xml_p = xml_doc.FirstChildElement("path");
ASSERT_TRUE(xml_p);
Path p;
ASSERT_TRUE(fromXml(p, xml_p, group_map));
//Testing that data got initialized as expected
ASSERT_EQ(2, p.moves_.size());
ASSERT_EQ(3, p.moves_.front().point_->values_.size());
//Confirm values for first point
EXPECT_DOUBLE_EQ(1.0, p.moves_.front().point_->values_[0]);
EXPECT_DOUBLE_EQ(2.0, p.moves_.front().point_->values_[1]);
EXPECT_DOUBLE_EQ(3.0, p.moves_.front().point_->values_[2]);
//Confirm values for last point
EXPECT_DOUBLE_EQ(4.0, p.moves_.back().point_->values_[0]);
EXPECT_DOUBLE_EQ(5.0, p.moves_.back().point_->values_[1]);
EXPECT_DOUBLE_EQ(6.0, p.moves_.back().point_->values_[2]);
}
TEST(Task, from_xml)
{
using namespace std;
using namespace mtconnect;
const string xml_string = "<task>"
"<joint_point name=home joint_values=\"1 2 3\" group_name=\"group_1\"/>"
"<joint_point name=safe joint_values=\"4 5 6\" group_name=\"group_2\"/>"
"<motion_group name=\"group_1\" joint_names=\"joint_1 joint_2 joint_3\"/>"
"<motion_group name=\"group_2\" joint_names=\"joint_4 joint_5 joint_6\"/>"
"<path name=\"path_1\">"
"<joint_move>"
"<joint_point joint_values=\"1 2 3\" group_name=\"group_1\"/>"
"</joint_move>"
"<joint_move>"
"<joint_point joint_values=\"4 5 6\" group_name=\"group_2\"/>"
"</joint_move>"
"</path>"
"<path name=\"path_2\">"
"<joint_move>"
"<joint_point joint_values=\"1 2 3\" group_name=\"group_2\"/>"
"</joint_move>"
"<joint_move>"
"<joint_point joint_values=\"4 5 6\" group_name=\"group_1\"/>"
"</joint_move>"
"</path>"
"</task>";
Task task;
TiXmlDocument xml_doc;
xml_doc.Parse(xml_string.c_str());
TiXmlElement *xml_t = xml_doc.FirstChildElement("task");
ASSERT_TRUE(fromXml(task, xml_t));
ASSERT_EQ(2, task.points_.size());
ASSERT_EQ(2, task.motion_groups_.size());
ASSERT_EQ(2, task.paths_.size());
boost::shared_ptr<MotionGroup> group_ptr = task.motion_groups_["group_1"];
ASSERT_TRUE(group_ptr);
boost::shared_ptr<Path> path_ptr = task.paths_["path_1"];
ASSERT_EQ(path_ptr->moves_.front().point_->group_, group_ptr);
boost::shared_ptr<JointPoint> joint_point_ptr = task.points_["home"];
ASSERT_TRUE(joint_point_ptr);
ASSERT_TRUE(fromXml(task, xml_string));
}
// Run all the tests that were declared with TEST()
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
|
#include "Mcu.inc"
#include "InitialisationChain.inc"
#include "TestDoubles.inc"
radix decimal
udata
global calledInitialiseAfterUi
calledInitialiseAfterUi res 1
InitialiseAfterUiMock code
global initialiseInitialiseAfterUiMock
global INITIALISE_AFTER_UI
initialiseInitialiseAfterUiMock:
banksel calledInitialiseAfterUi
clrf calledInitialiseAfterUi
return
INITIALISE_AFTER_UI:
mockCalled calledInitialiseAfterUi
return
end
|
/*
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
#include <fstream>
#include <string>
#include <vector>
#include <gtest/gtest.h>
#include <rosbag_cloud_recorders/utils/file_utils.h>
#include <rosbag_cloud_recorders/utils/periodic_file_deleter.h>
using namespace Aws::Rosbag::Utils;
class PeriodicFileDeleterTest : public ::testing::Test
{
public:
std::vector<std::string> GetFiles() {
get_files_count += 1;
return delete_files;
};
protected:
std::vector<std::string> files;
std::vector<std::string> delete_files;
std::unique_ptr<PeriodicFileDeleter> deleter;
int get_files_count;
std::string CreateTempFile() {
char file_path[] = "/tmp/PeriodicFileDeleterTestXXXXXX";
int fd = mkstemp(file_path);
close(fd);
auto file = std::string(file_path);
// Track files so that they can be cleaned up after the test
files.push_back(file);
return file;
}
void CreateDeleteFiles(int num_files) {
for (int i = 0; i < num_files; ++i) {
delete_files.push_back(CreateTempFile());
}
}
bool FileExists(std::string file_path) {
std::ifstream file(file_path);
return file.good();
}
void SetUp() override
{
get_files_count = 0;
deleter = std::make_unique<PeriodicFileDeleter>(boost::bind(&PeriodicFileDeleterTest::GetFiles, this));
}
void TearDown() override
{
// In case a test fails, delete all files
for (const auto& file: files) {
Aws::Rosbag::Utils::DeleteFile(file.c_str());
}
}
};
TEST_F(PeriodicFileDeleterTest, TestIsActive)
{
ASSERT_FALSE(deleter->IsActive());
deleter->Start();
ASSERT_TRUE(deleter->IsActive());
// Shouldn't do anything
deleter->Start();
ASSERT_TRUE(deleter->IsActive());
deleter->Stop();
ASSERT_FALSE(deleter->IsActive());
}
TEST_F(PeriodicFileDeleterTest, TestDeletesFilesSucceeds)
{
int num_files = 3;
CreateDeleteFiles(num_files);
// Sanity check that files were created
ASSERT_EQ(num_files, delete_files.size());
for (const auto& file: delete_files) {
ASSERT_TRUE(FileExists(file));
}
deleter->Start();
// Deleter won't call GetFiles again until it's completed the first batch
while (get_files_count < 2) {
sleep(1);
}
for (const auto& file: delete_files) {
EXPECT_FALSE(FileExists(file));
}
}
TEST_F(PeriodicFileDeleterTest, TestIgnoresFailedFileDeletion)
{
int num_files = 3;
CreateDeleteFiles(num_files);
// Sanity check that files were created
ASSERT_EQ(num_files, delete_files.size());
for (const auto& file: delete_files) {
ASSERT_TRUE(FileExists(file));
}
// Delete a file before the deleter can
DeleteFile(delete_files.at(1));
deleter->Start();
// Deleter won't call GetFiles again until it's completed the first batch
while (get_files_count < 2) {
sleep(1.0);
}
// All files should still be succesfully deleted
for (const auto& file: delete_files) {
EXPECT_FALSE(FileExists(file));
}
} |
BITS 32
pop eax
pop esp
ret |
; A157108: Triangle, read by rows, T(n, k) = binomial(n*binomial(n, k), k).
; Submitted by Christian Krause
; 1,1,1,1,4,1,1,9,36,1,1,16,276,560,1,1,25,1225,19600,12650,1,1,36,4005,280840,2555190,376992,1,1,49,10731,2421090,146475945,534017484,13983816,1,1,64,24976,14885696,4053946260,147055790784,163995687856,621216192,1,1,81,52326,71728020,68539472001,15489920672226,254191105762776,69669979308864,32164253550,1,1,100,101025,287280400,808024270725,843523216578504,118271051188865400,698593069584867600,39174677916258600,1902231808400,1,1,121,182710,994856555,7222660235505,28192736431618836
lpb $0
add $1,1
add $1,$2
add $2,1
sub $0,$2
bin $1,$0
mul $1,$2
lpe
bin $1,$0
mov $0,$1
|
; A157262: a(n) = 36*n^2 - 55*n + 21.
; 2,55,180,377,646,987,1400,1885,2442,3071,3772,4545,5390,6307,7296,8357,9490,10695,11972,13321,14742,16235,17800,19437,21146,22927,24780,26705,28702,30771,32912,35125,37410,39767,42196,44697,47270,49915,52632,55421,58282,61215,64220,67297,70446,73667,76960,80325,83762,87271,90852,94505,98230,102027,105896,109837,113850,117935,122092,126321,130622,134995,139440,143957,148546,153207,157940,162745,167622,172571,177592,182685,187850,193087,198396,203777,209230,214755,220352,226021,231762,237575,243460,249417,255446,261547,267720,273965,280282,286671,293132,299665,306270,312947,319696,326517,333410,340375,347412,354521,361702,368955,376280,383677,391146,398687,406300,413985,421742,429571,437472,445445,453490,461607,469796,478057,486390,494795,503272,511821,520442,529135,537900,546737,555646,564627,573680,582805,592002,601271,610612,620025,629510,639067,648696,658397,668170,678015,687932,697921,707982,718115,728320,738597,748946,759367,769860,780425,791062,801771,812552,823405,834330,845327,856396,867537,878750,890035,901392,912821,924322,935895,947540,959257,971046,982907,994840,1006845,1018922,1031071,1043292,1055585,1067950,1080387,1092896,1105477,1118130,1130855,1143652,1156521,1169462,1182475,1195560,1208717,1221946,1235247,1248620,1262065,1275582,1289171,1302832,1316565,1330370,1344247,1358196,1372217,1386310,1400475,1414712,1429021,1443402,1457855,1472380,1486977,1501646,1516387,1531200,1546085,1561042,1576071,1591172,1606345,1621590,1636907,1652296,1667757,1683290,1698895,1714572,1730321,1746142,1762035,1778000,1794037,1810146,1826327,1842580,1858905,1875302,1891771,1908312,1924925,1941610,1958367,1975196,1992097,2009070,2026115,2043232,2060421,2077682,2095015,2112420,2129897,2147446,2165067,2182760,2200525,2218362,2236271
mov $1,$0
mul $1,6
pow $1,2
add $1,2
mov $2,$0
mul $2,17
add $1,$2
|
; A099363: An inverse Chebyshev transform of 1-x.
; Submitted by Jamie Morken(s4)
; 1,-1,1,-2,2,-5,5,-14,14,-42,42,-132,132,-429,429,-1430,1430,-4862,4862,-16796,16796,-58786,58786,-208012,208012,-742900,742900,-2674440,2674440,-9694845,9694845,-35357670,35357670,-129644790,129644790,-477638700,477638700,-1767263190,1767263190
mov $1,$0
div $0,2
mov $2,$1
add $1,1
bin $1,$0
add $0,1
bin $2,$0
mul $2,2
sub $1,$2
mov $0,$1
|
; File: Int128x64.asm
; build obj-file with
; ml64 /nologo /c /Zf /Fo$(IntDir)Int128x64.obj Int128x64.asm
.CODE
;void int128sum(_int128 &dst, cnost _int128 &x, const _int128 &y);
int128sum PROC
push rbx
mov rax, qword ptr[rdx]
add rax, qword ptr[r8]
mov rbx, qword ptr[rdx+8]
adc rbx, qword ptr[r8+8]
mov qword ptr[rcx], rax
mov qword ptr[rcx+8], rbx
pop rbx
ret
int128sum ENDP
;void int128dif( _int128 &dst, const _int128 &x, const _int128 &y);
int128dif PROC
push rbx
mov rax, qword ptr[rdx]
sub rax, qword ptr[r8]
mov rbx, qword ptr[rdx+8]
sbb rbx, qword ptr[r8+8]
mov qword ptr[rcx] , rax
mov qword ptr[rcx+8], rbx
pop rbx
ret
int128dif ENDP
;void int128mul(_int128 &dst, const _int128 &x, const _int128 &y);
int128mul PROC
push rbx
mov rax, qword ptr[rdx+8] ; rax = x.hi
mov rbx, qword ptr[r8+8] ; rbx = y.hi
or rbx, rax ; rbx = x.hi | y.hi
mov rbx, qword ptr[r8] ; rbx = y.lo
jne Hard ; if(x.hi|y.hi) goto Hard
; simple int64 multiplication
mov rax, qword ptr[rdx] ; rax = x.lo
mul rbx ; rdx:rax = rax * rbx
mov qword ptr[rcx] , rax ; dst.lo = rax
mov qword ptr[rcx+8], rdx ; dst.hi = rdx
pop rbx
ret
Hard: ; assume rax = x.hi, rbx = y.lo
push rsi
mov rsi, rdx ; need rdx for highend of mul, so rsi=&x
mul rbx ; rdx:rax = x.hi * y.lo
mov r9 , rax ;
mov rax, qword ptr[rsi] ; rax = x.lo
mul qword ptr[r8+8] ; rdx:rax = x.lo * y.hi
add r9, rax ; r9 = lo(x.hi*y.lo+x.lo*y.hi);
mov rax, qword ptr[rsi] ; rax = x.lo
mul rbx ; rdx:rax = x.lo * y.lo
add rdx, r9
mov qword ptr[rcx] , rax
mov qword ptr[rcx+8], rdx
pop rsi
pop rbx
ret
int128mul ENDP
;void int128div(_int128 &dst, const _int128 &x, const _int128 &y);
int128div PROC
push rdi
push rsi
push rbx
push rcx
mov r9, rdx
xor rdi, rdi
mov rax, qword ptr[r9+8]
or rax, rax
jge L1
inc rdi
mov rdx, qword ptr[r9]
neg rax
neg rdx
sbb rax, 0
mov qword ptr[r9+8], rax
mov qword ptr[r9], rdx
L1:
mov rax, qword ptr[r8+8]
or rax, rax
jge L2
inc rdi
mov rdx, qword ptr[r8]
neg rax
neg rdx
sbb rax,0
mov qword ptr[r8+8], rax
mov qword ptr[r8], rdx
L2:
or rax, rax
jne L3
mov rcx, qword ptr[r8]
mov rax, qword ptr[r9+8]
xor rdx, rdx
div rcx
mov rbx, rax
mov rax, qword ptr[r9]
div rcx
mov rdx, rbx
jmp L4
L3:
mov rbx,rax
mov rcx,qword ptr[r8]
mov rdx,qword ptr[r9+8]
mov rax,qword ptr[r9]
L5:
shr rbx, 1
rcr rcx, 1
shr rdx, 1
rcr rax, 1
or rbx, rbx
jne L5
div rcx
mov rsi, rax
mul qword ptr[r8+8]
mov rcx, rax
mov rax, qword ptr[r8]
mul rsi
add rdx, rcx
jb L6
cmp rdx, qword ptr[r9+8]
ja L6
jb L7
cmp rax, qword ptr[rdx]
jbe L7
L6:
dec rsi
L7:
xor rdx, rdx
mov rax, rsi
L4:
dec rdi
jne L8
neg rdx
neg rax
sbb rdx, 0
L8:
pop rcx
pop rbx
pop rsi
pop rdi
mov qword ptr[rcx], rax
mov qword ptr[rcx+8], rdx
ret
int128div ENDP
;void int128rem( _int128 &dst, const _int128 &x, const _int128 &y);
int128rem PROC
push rbx
push rdi
push rcx
mov r9, rdx
xor rdi, rdi
mov rax, qword ptr[r9+8]
or rax, rax
jge L1
inc rdi
mov rdx, qword ptr[r9]
neg rax
neg rdx
sbb rax, 0
mov qword ptr[r9+8], rax
mov qword ptr[r9], rdx
L1:
mov rax, qword ptr[r8+8]
or rax, rax
jge L2
mov rdx, qword ptr[r8]
neg rax
neg rdx
sbb rax, 0
mov qword ptr[r8+8], rax
mov qword ptr[r8], rdx
L2:
or rax, rax
jne L3
mov rcx, qword ptr[r8]
mov rax, qword ptr[r9+8]
xor rdx, rdx
div rcx
mov rax, qword ptr[r9]
div rcx
mov rax, rdx
xor rdx, rdx
dec rdi
jns L4
jmp L8
L3:
mov rbx, rax
mov rcx, qword ptr[r8]
mov rdx, qword ptr[r9+8]
mov rax, qword ptr[r9]
L5:
shr rbx, 1
rcr rcx, 1
shr rdx, 1
rcr rax, 1
or rbx, rbx
jne L5
div rcx
mov rcx, rax
mul qword ptr[r8+8]
xchg rax, rcx
mul qword ptr[r8]
add rdx, rcx
jb L6
cmp rdx, qword ptr[r9+8]
ja L6
jb L7
cmp rax, qword ptr[r9]
jbe L7
L6:
sub rax, qword ptr[r8]
sbb rdx, qword ptr[r8+8]
L7:
sub rax, qword ptr[r9]
sbb rdx, qword ptr[r9+8]
dec rdi
jns L8
L4:
neg rdx
neg rax
sbb rdx, 0
L8:
pop rcx
pop rdi
pop rbx
mov qword ptr[rcx], rax
mov qword ptr[rcx+8], rdx
ret
int128rem ENDP
;void int128neg( _int128 &dst, const _int128 &x);
int128neg PROC
mov rax,qword ptr[rdx]
neg rax
mov r8, qword ptr[rdx+8]
adc r8, 0
neg r8
mov qword ptr[rcx], rax
mov qword ptr[rcx+8], r8
ret
int128neg ENDP
;int int128cmp(const _int128 &n1, const _int128 &n2);
int128cmp PROC
mov rax, qword ptr[rcx+8] ; n1.hi
cmp rax, qword ptr[rdx+8] ; n2.hi
jl lessthan ; signed compare of n1.hi and n2.hi
jg greaterthan
mov rax, qword ptr[rcx] ; n2.lo
cmp rax, qword ptr[rdx] ; n2.lo
jb lessthan ; unsigned compare of n1.lo and n2.lo
ja greaterthan
mov rax, 0 ; they are equal
ret
greaterthan:
mov rax, 1
ret
lessthan:
mov rax, -1
ret
int128cmp ENDP
;END
; File:UInt128x64.asm
; build obj-file with
; ml64 /nologo /c /Zf /Fo$(IntDir)UInt128x64.obj UInt128x64.asm
;.CODE
;void uint128div(_uint128 &dst, const _uint128 &x, const _uint128 &y);
uint128div PROC
push rbx
push rsi
push rcx
mov r9, rdx
mov rax, qword ptr[r8+8]
or rax, rax
jne L1
mov rcx, qword ptr[r8]
mov rax, qword ptr[r9+8]
xor rdx, rdx
div rcx
mov rbx, rax
mov rax, qword ptr[r9]
div rcx
mov rdx, rbx
jmp L2
L1:
mov rcx, rax
mov rbx, qword ptr[r8]
mov rdx, qword ptr[r9+8]
mov rax, qword ptr[r9]
L3:
shr rcx, 1
rcr rbx, 1
shr rdx, 1
rcr rax, 1
or rcx, rcx
jne L3
div rbx
mov rsi, rax
mul qword ptr[r8+8]
mov rcx, rax
mov rax, qword ptr[r8]
mul rsi
add rdx, rcx
jb L4
cmp rdx, qword ptr[r9+8]
ja L4
jb L5
cmp rax, qword ptr[r9]
jbe L5
L4:
dec rsi
L5:
xor rdx, rdx
mov rax, rsi
L2:
pop rcx
pop rsi
pop rbx
mov qword ptr[rcx], rax
mov qword ptr[rcx+8], rdx
ret
uint128div ENDP
;void uint128rem(_uint128 &dst, const _uint128 &x, const _uint128 &y);
uint128rem PROC
push rbx
push rcx
mov r9, rdx
mov rax, qword ptr[r8+8]
or rax, rax
jne L1
mov rcx, qword ptr[r8]
mov rax, qword ptr[r9+8]
xor rdx, rdx
div rcx
mov rax, qword ptr[r9]
div rcx
mov rax, rdx
xor rdx, rdx
jmp L2
L1:
mov rcx, rax
mov rbx, qword ptr[r8]
mov rdx, qword ptr[r9+8]
mov rax, qword ptr[r9]
L3:
shr rcx, 1
rcr rbx, 1
shr rdx, 1
rcr rax, 1
or rcx, rcx
jne L3
div rbx
mov rcx, rax
mul qword ptr[r8+8]
xchg rax, rcx
mul qword ptr[r8]
add rdx, rcx
jb L4
cmp rdx, qword ptr[r9+8]
ja L4
jb L5
cmp rax, qword ptr[r9]
jbe L5
L4:
sub rax, qword ptr[r8]
sbb rdx, qword ptr[r8+8]
L5:
sub rax, qword ptr[r9]
sbb rdx, qword ptr[r9+8]
neg rdx
neg rax
sbb rdx, 0
L2:
pop rcx
pop rbx
mov qword ptr[rcx], rax
mov qword ptr[rcx+8], rdx
ret
uint128rem ENDP
;int uint128cmp(const _uint128 &n1, const _uint128 &n2);
uint128cmp PROC
mov rax, qword ptr[rcx+8] ; n1.hi
cmp rax, qword ptr[rdx+8] ; n2.hi
jb lessthan ; usigned compare of n1.hi and n2.hi
ja greaterthan
mov rax, qword ptr[rcx] ; n2.lo
cmp rax, qword ptr[rdx] ; n2.lo
jb lessthan ; unsigned compare of n1.lo and n2.lo
ja greaterthan
mov rax, 0 ; they are equal
ret
greaterthan:
mov rax, 1
ret
lessthan:
mov rax, -1
ret
uint128cmp ENDP
END
|
/**@addtogroup Stemming
@brief Library for stemming words down to their root words.
@date 2003-2015
@copyright Oleander Software, Ltd.
@author Oleander Software, Ltd.
@details This program is free software; you can redistribute it and/or modify
it under the terms of the BSD License.
* @{*/
#ifndef __RUSSIAN_STEM_H__
#define __RUSSIAN_STEM_H__
#include "stemming.hpp"
namespace stemming
{
static const wchar_t RUSSIAN_VOWELS[] = {
0x0410, 0x0430, 0x0415, 0x0435, 0x0418, 0x0438, 0x041E,
0x043E, 0x423, 0x0443, 0x042B, 0x044B, 0x042D, 0x044D,
0x042E, 0x044E, 0x042F, 0x044F, 0};
static const wchar_t RUSSIAN_A_UPPER = 0x0410;
static const wchar_t RUSSIAN_A_LOWER = 0x0430;
static const wchar_t RUSSIAN_BE_UPPER = 0x0411;
static const wchar_t RUSSIAN_BE_LOWER = 0x0431;
static const wchar_t RUSSIAN_VE_UPPER = 0x0412;
static const wchar_t RUSSIAN_VE_LOWER = 0x0432;
static const wchar_t RUSSIAN_GHE_UPPER = 0x0413;
static const wchar_t RUSSIAN_GHE_LOWER = 0x0433;
static const wchar_t RUSSIAN_DE_UPPER = 0x0414;
static const wchar_t RUSSIAN_DE_LOWER = 0x0434;
static const wchar_t RUSSIAN_IE_UPPER = 0x0415;
static const wchar_t RUSSIAN_IE_LOWER = 0x0435;
static const wchar_t RUSSIAN_ZHE_UPPER = 0x0416;
static const wchar_t RUSSIAN_ZHE_LOWER = 0x0436;
static const wchar_t RUSSIAN_ZE_UPPER = 0x0417;
static const wchar_t RUSSIAN_ZE_LOWER = 0x0437;
static const wchar_t RUSSIAN_I_UPPER = 0x0418;
static const wchar_t RUSSIAN_I_LOWER = 0x0438;
static const wchar_t RUSSIAN_SHORT_I_UPPER = 0x0419;
static const wchar_t RUSSIAN_SHORT_I_LOWER = 0x0439;
static const wchar_t RUSSIAN_KA_UPPER = 0x041A;
static const wchar_t RUSSIAN_KA_LOWER = 0x043A;
static const wchar_t RUSSIAN_EL_UPPER = 0x041B;
static const wchar_t RUSSIAN_EL_LOWER = 0x043B;
static const wchar_t RUSSIAN_EM_UPPER = 0x041C;
static const wchar_t RUSSIAN_EM_LOWER = 0x043C;
static const wchar_t RUSSIAN_EN_UPPER = 0x041D;
static const wchar_t RUSSIAN_EN_LOWER = 0x043D;
static const wchar_t RUSSIAN_O_UPPER = 0x041E;
static const wchar_t RUSSIAN_O_LOWER = 0x043E;
static const wchar_t RUSSIAN_PE_UPPER = 0x041F;
static const wchar_t RUSSIAN_PE_LOWER = 0x043F;
static const wchar_t RUSSIAN_ER_UPPER = 0x0420;
static const wchar_t RUSSIAN_ER_LOWER = 0x0440;
static const wchar_t RUSSIAN_ES_UPPER = 0x0421;
static const wchar_t RUSSIAN_ES_LOWER = 0x0441;
static const wchar_t RUSSIAN_TE_UPPER = 0x0422;
static const wchar_t RUSSIAN_TE_LOWER = 0x0442;
static const wchar_t RUSSIAN_U_UPPER = 0x0423;
static const wchar_t RUSSIAN_U_LOWER = 0x0443;
static const wchar_t RUSSIAN_EF_UPPER = 0x0424;
static const wchar_t RUSSIAN_EF_LOWER = 0x0444;
static const wchar_t RUSSIAN_HA_UPPER = 0x0425;
static const wchar_t RUSSIAN_HA_LOWER = 0x0445;
static const wchar_t RUSSIAN_TSE_UPPER = 0x0426;
static const wchar_t RUSSIAN_TSE_LOWER = 0x0446;
static const wchar_t RUSSIAN_CHE_UPPER = 0x0427;
static const wchar_t RUSSIAN_CHE_LOWER = 0x0447;
static const wchar_t RUSSIAN_SHA_UPPER = 0x0428;
static const wchar_t RUSSIAN_SHA_LOWER = 0x0448;
static const wchar_t RUSSIAN_SHCHA_UPPER = 0x0429;
static const wchar_t RUSSIAN_SHCHA_LOWER = 0x0449;
static const wchar_t RUSSIAN_HARD_SIGN_UPPER = 0x042A;
static const wchar_t RUSSIAN_HARD_SIGN_LOWER = 0x044A;
static const wchar_t RUSSIAN_YERU_UPPER = 0x042B;
static const wchar_t RUSSIAN_YERU_LOWER = 0x044B;
static const wchar_t RUSSIAN_SOFT_SIGN_UPPER = 0x042C;
static const wchar_t RUSSIAN_SOFT_SIGN_LOWER = 0x044C;
static const wchar_t RUSSIAN_E_UPPER = 0x042D;
static const wchar_t RUSSIAN_E_LOWER = 0x044D;
static const wchar_t RUSSIAN_YU_UPPER = 0x042E;
static const wchar_t RUSSIAN_YU_LOWER = 0x044E;
static const wchar_t RUSSIAN_YA_UPPER = 0x042F;
static const wchar_t RUSSIAN_YA_LOWER = 0x044F;
/**
@brief Russian stemmer.
@date 2010
@par Algorithm:
PERFECTIVE GERUND:
- Group 1: в вши вшись
- Group 2: ив ивши ившись ыв ывши ывшись
Group 1 endings must follow 'а' or 'я'.
REFLEXIVE:
- ся сь
NOUN:
- а ев ов ие ье е иями ями ами еи ии и ией ей ой ий й иям ям ием ем ам ом о
у ах иях ях ы ь ию ью ю ия ья я
@par Algorithm:
<b>Step 1:</b>
Search for a PERFECTIVE GERUND ending. If one is found remove it,
and that is then the end of step 1. Otherwise try and remove a REFLEXIVE
ending, and then search in turn for:
-# an ADJECTIVAL,
-# a VERB or
-# a NOUN ending.
As soon as one of the endings (1) to (3) is found remove it, and terminate
step 1.
<b>Step 2:</b>
If the word ends with 'и', then remove it.
<b>Step 3:</b>
Search for a DERIVATIONAL (ост, ость) ending in R2 (i.e., the entire ending
must lie in R2), and if one is found, then remove it.
<b>Step 4:</b>
-# Undouble 'н', or
-# if the word ends with a SUPERLATIVE (ейш or ейше) ending, remove it and
undouble 'н', or
-# if the word ends 'ь', then remove it.
*/
template <typename string_typeT = std::wstring>
class russian_stem : public stem<string_typeT>
{
public:
//---------------------------------------------
/**@param[in,out] text string to stem*/
void operator()(string_typeT & text)
{
if (text.length() < 2)
{
return;
}
// reset internal data
stem<string_typeT>::reset_r_values();
stem<string_typeT>::find_r1(text, RUSSIAN_VOWELS);
stem<string_typeT>::find_r2(text, RUSSIAN_VOWELS);
stem<string_typeT>::find_russian_rv(text, RUSSIAN_VOWELS);
// change 33rd letter ('ё') to 'е'
for (size_t i = 0; i < text.length(); ++i)
{
if (text[i] == 0x0451)
{
text[i] = RUSSIAN_IE_LOWER;
}
else if (text[i] == 0x0401)
{
text[i] = RUSSIAN_IE_UPPER;
}
}
step_1(text);
step_2(text);
step_3(text);
step_4(text);
}
private:
void step_1(string_typeT & text)
{
// search for a perfect gerund
// group 2
if (stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YERU_LOWER, RUSSIAN_YERU_UPPER, RUSSIAN_VE_LOWER,
RUSSIAN_VE_UPPER, RUSSIAN_SHA_LOWER, RUSSIAN_SHA_UPPER,
RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_ES_LOWER,
RUSSIAN_ES_UPPER, RUSSIAN_SOFT_SIGN_LOWER,
RUSSIAN_SOFT_SIGN_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_VE_LOWER,
RUSSIAN_VE_UPPER, RUSSIAN_SHA_LOWER, RUSSIAN_SHA_UPPER,
RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_ES_LOWER,
RUSSIAN_ES_UPPER, RUSSIAN_SOFT_SIGN_LOWER,
RUSSIAN_SOFT_SIGN_UPPER, false))
{
return;
}
// group 1
else if (stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_VE_LOWER, RUSSIAN_VE_UPPER,
RUSSIAN_SHA_LOWER, RUSSIAN_SHA_UPPER, RUSSIAN_I_LOWER,
RUSSIAN_I_UPPER, RUSSIAN_ES_LOWER, RUSSIAN_ES_UPPER,
RUSSIAN_SOFT_SIGN_LOWER, RUSSIAN_SOFT_SIGN_UPPER))
{
if (stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_A_LOWER, RUSSIAN_A_UPPER, RUSSIAN_VE_LOWER,
RUSSIAN_VE_UPPER, RUSSIAN_SHA_LOWER, RUSSIAN_SHA_UPPER,
RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_ES_LOWER,
RUSSIAN_ES_UPPER, RUSSIAN_SOFT_SIGN_LOWER,
RUSSIAN_SOFT_SIGN_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_YA_LOWER, RUSSIAN_YA_UPPER, RUSSIAN_VE_LOWER,
RUSSIAN_VE_UPPER, RUSSIAN_SHA_LOWER, RUSSIAN_SHA_UPPER,
RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_ES_LOWER,
RUSSIAN_ES_UPPER, RUSSIAN_SOFT_SIGN_LOWER,
RUSSIAN_SOFT_SIGN_UPPER))
{
text.erase(text.end() - 5, text.end());
stem<string_typeT>::update_r_sections(text);
return;
}
}
// group 2
else if (
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_VE_LOWER,
RUSSIAN_VE_UPPER, RUSSIAN_SHA_LOWER, RUSSIAN_SHA_UPPER,
RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YERU_LOWER, RUSSIAN_YERU_UPPER, RUSSIAN_VE_LOWER,
RUSSIAN_VE_UPPER, RUSSIAN_SHA_LOWER, RUSSIAN_SHA_UPPER,
RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, false))
{
return;
}
// group 1
else if (stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_VE_LOWER, RUSSIAN_VE_UPPER,
RUSSIAN_SHA_LOWER, RUSSIAN_SHA_UPPER, RUSSIAN_I_LOWER,
RUSSIAN_I_UPPER))
{
if (stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_A_LOWER, RUSSIAN_A_UPPER, RUSSIAN_VE_LOWER,
RUSSIAN_VE_UPPER, RUSSIAN_SHA_LOWER, RUSSIAN_SHA_UPPER,
RUSSIAN_I_LOWER, RUSSIAN_I_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_YA_LOWER, RUSSIAN_YA_UPPER, RUSSIAN_VE_LOWER,
RUSSIAN_VE_UPPER, RUSSIAN_SHA_LOWER, RUSSIAN_SHA_UPPER,
RUSSIAN_I_LOWER, RUSSIAN_I_UPPER))
{
text.erase(text.end() - 3, text.end());
stem<string_typeT>::update_r_sections(text);
return;
}
}
// group 2
else if (
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_VE_LOWER,
RUSSIAN_VE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YERU_LOWER, RUSSIAN_YERU_UPPER, RUSSIAN_VE_LOWER,
RUSSIAN_VE_UPPER, false))
{
return;
}
// group 1
else if (stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_VE_LOWER, RUSSIAN_VE_UPPER))
{
if (stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_A_LOWER, RUSSIAN_A_UPPER, RUSSIAN_VE_LOWER,
RUSSIAN_VE_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_YA_LOWER, RUSSIAN_YA_UPPER, RUSSIAN_VE_LOWER,
RUSSIAN_VE_UPPER))
{
text.erase(text.end() - 1, text.end());
stem<string_typeT>::update_r_sections(text);
return;
}
}
// reflexive
if (stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_ES_LOWER, RUSSIAN_ES_UPPER, RUSSIAN_YA_LOWER,
RUSSIAN_YA_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_ES_LOWER, RUSSIAN_ES_UPPER,
RUSSIAN_SOFT_SIGN_LOWER, RUSSIAN_SOFT_SIGN_UPPER, false))
{ /*NOOP*/
}
// adjectival
if (stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YERU_UPPER, RUSSIAN_YERU_LOWER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_GHE_LOWER,
RUSSIAN_GHE_UPPER, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, RUSSIAN_GHE_LOWER,
RUSSIAN_GHE_UPPER, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER, RUSSIAN_U_LOWER, RUSSIAN_U_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER, RUSSIAN_U_LOWER, RUSSIAN_U_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_IE_LOWER,
RUSSIAN_IE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_IE_LOWER,
RUSSIAN_IE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YERU_LOWER, RUSSIAN_YERU_UPPER, RUSSIAN_IE_LOWER,
RUSSIAN_IE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, RUSSIAN_IE_LOWER,
RUSSIAN_IE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER,
RUSSIAN_SHORT_I_LOWER, RUSSIAN_SHORT_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_SHORT_I_LOWER,
RUSSIAN_SHORT_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YERU_LOWER, RUSSIAN_YERU_UPPER,
RUSSIAN_SHORT_I_LOWER, RUSSIAN_SHORT_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, RUSSIAN_SHORT_I_LOWER,
RUSSIAN_SHORT_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YERU_LOWER, RUSSIAN_YERU_UPPER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_HA_LOWER,
RUSSIAN_HA_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YERU_LOWER, RUSSIAN_YERU_UPPER, RUSSIAN_HA_LOWER,
RUSSIAN_HA_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_U_LOWER, RUSSIAN_U_UPPER, RUSSIAN_YU_LOWER,
RUSSIAN_YU_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YU_LOWER, RUSSIAN_YU_UPPER, RUSSIAN_YU_LOWER,
RUSSIAN_YU_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_A_LOWER, RUSSIAN_A_UPPER, RUSSIAN_YA_LOWER,
RUSSIAN_YA_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YA_LOWER, RUSSIAN_YA_UPPER, RUSSIAN_YA_LOWER,
RUSSIAN_YA_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, RUSSIAN_YU_LOWER,
RUSSIAN_YU_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_YU_LOWER,
RUSSIAN_YU_UPPER, false))
{
// delete participles
// group 2
if (stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_VE_LOWER,
RUSSIAN_VE_UPPER, RUSSIAN_SHA_LOWER, RUSSIAN_SHA_UPPER,
false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YERU_LOWER, RUSSIAN_YERU_UPPER,
RUSSIAN_VE_LOWER, RUSSIAN_VE_UPPER, RUSSIAN_SHA_LOWER,
RUSSIAN_SHA_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_U_LOWER, RUSSIAN_U_UPPER, RUSSIAN_YU_LOWER,
RUSSIAN_YU_UPPER, RUSSIAN_SHCHA_LOWER, RUSSIAN_SHCHA_UPPER,
false))
{ /*NOOP*/
}
// group 1
else if (
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_EN_LOWER, RUSSIAN_EN_UPPER, RUSSIAN_EN_LOWER,
RUSSIAN_EN_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_VE_LOWER, RUSSIAN_VE_UPPER,
RUSSIAN_SHA_LOWER, RUSSIAN_SHA_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_YU_LOWER, RUSSIAN_YU_UPPER,
RUSSIAN_SHCHA_LOWER, RUSSIAN_SHCHA_UPPER))
{
if (text.length() >= 3 &&
stem<string_typeT>::get_rv() <= text.length() - 3 &&
(is_either<wchar_t>(
text[text.length() - 3], RUSSIAN_A_LOWER,
RUSSIAN_A_UPPER) ||
is_either<wchar_t>(
text[text.length() - 3], RUSSIAN_YA_LOWER,
RUSSIAN_YA_UPPER)))
{
text.erase(text.end() - 2, text.end());
stem<string_typeT>::update_r_sections(text);
return;
}
}
else if (stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_SHCHA_LOWER, RUSSIAN_SHCHA_UPPER))
{
if (text.length() >= 2 &&
stem<string_typeT>::get_rv() <= text.length() - 2 &&
(is_either<wchar_t>(
text[text.length() - 2], RUSSIAN_A_LOWER,
RUSSIAN_A_UPPER) ||
is_either<wchar_t>(
text[text.length() - 2], RUSSIAN_YA_LOWER,
RUSSIAN_YA_UPPER)))
{
text.erase(text.end() - 1, text.end());
stem<string_typeT>::update_r_sections(text);
return;
}
}
return;
}
// verb
// group 2
else if (
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER,
RUSSIAN_SHORT_I_LOWER, RUSSIAN_SHORT_I_UPPER, RUSSIAN_TE_LOWER,
RUSSIAN_TE_UPPER, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER,
false) || /*4*/
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_U_LOWER, RUSSIAN_U_UPPER, RUSSIAN_SHORT_I_LOWER,
RUSSIAN_SHORT_I_UPPER, RUSSIAN_TE_LOWER, RUSSIAN_TE_UPPER,
RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER,
RUSSIAN_SHORT_I_LOWER, RUSSIAN_SHORT_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_U_LOWER, RUSSIAN_U_UPPER, RUSSIAN_SHORT_I_LOWER,
RUSSIAN_SHORT_I_UPPER, false))
{
return;
}
// group 1
if (stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_TE_LOWER,
RUSSIAN_TE_UPPER, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_SHORT_I_LOWER, RUSSIAN_SHORT_I_UPPER,
RUSSIAN_TE_LOWER, RUSSIAN_TE_UPPER, RUSSIAN_IE_LOWER,
RUSSIAN_IE_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_SHA_LOWER,
RUSSIAN_SHA_UPPER, RUSSIAN_SOFT_SIGN_LOWER,
RUSSIAN_SOFT_SIGN_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_EN_LOWER, RUSSIAN_EN_UPPER, RUSSIAN_EN_LOWER,
RUSSIAN_EN_UPPER, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER))
{
if (text.length() >= 4 &&
stem<string_typeT>::get_rv() <= text.length() - 4 &&
(is_either<wchar_t>(
text[text.length() - 4], RUSSIAN_A_LOWER,
RUSSIAN_A_UPPER) ||
is_either<wchar_t>(
text[text.length() - 4], RUSSIAN_YA_LOWER,
RUSSIAN_YA_UPPER)))
{
text.erase(text.end() - 3, text.end());
stem<string_typeT>::update_r_sections(text);
return;
}
}
// group 2
else if (
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_EL_LOWER,
RUSSIAN_EL_UPPER, RUSSIAN_A_LOWER, RUSSIAN_A_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YERU_LOWER, RUSSIAN_YERU_UPPER, RUSSIAN_EL_LOWER,
RUSSIAN_EL_UPPER, RUSSIAN_A_LOWER, RUSSIAN_A_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_EN_LOWER,
RUSSIAN_EN_UPPER, RUSSIAN_A_LOWER, RUSSIAN_A_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_TE_LOWER,
RUSSIAN_TE_UPPER, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_EL_LOWER,
RUSSIAN_EL_UPPER, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YERU_LOWER, RUSSIAN_YERU_UPPER, RUSSIAN_EL_LOWER,
RUSSIAN_EL_UPPER, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_EL_LOWER,
RUSSIAN_EL_UPPER, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YERU_LOWER, RUSSIAN_YERU_UPPER, RUSSIAN_EL_LOWER,
RUSSIAN_EL_UPPER, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_EN_LOWER,
RUSSIAN_EN_UPPER, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_U_LOWER, RUSSIAN_U_UPPER, RUSSIAN_IE_LOWER,
RUSSIAN_IE_UPPER, RUSSIAN_TE_LOWER, RUSSIAN_TE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_U_LOWER, RUSSIAN_U_UPPER, RUSSIAN_YU_LOWER,
RUSSIAN_YU_UPPER, RUSSIAN_TE_LOWER, RUSSIAN_TE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_EN_LOWER,
RUSSIAN_EN_UPPER, RUSSIAN_YERU_LOWER, RUSSIAN_YERU_UPPER,
false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_TE_LOWER,
RUSSIAN_TE_UPPER, RUSSIAN_SOFT_SIGN_LOWER,
RUSSIAN_SOFT_SIGN_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YERU_LOWER, RUSSIAN_YERU_UPPER, RUSSIAN_TE_LOWER,
RUSSIAN_TE_UPPER, RUSSIAN_SOFT_SIGN_LOWER,
RUSSIAN_SOFT_SIGN_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_SHA_LOWER,
RUSSIAN_SHA_UPPER, RUSSIAN_SOFT_SIGN_LOWER,
RUSSIAN_SOFT_SIGN_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_EL_LOWER,
RUSSIAN_EL_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YERU_LOWER, RUSSIAN_YERU_UPPER, RUSSIAN_EL_LOWER,
RUSSIAN_EL_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YERU_LOWER, RUSSIAN_YERU_UPPER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_EN_LOWER,
RUSSIAN_EN_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YA_LOWER, RUSSIAN_YA_UPPER, RUSSIAN_TE_LOWER,
RUSSIAN_TE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_TE_LOWER,
RUSSIAN_TE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YERU_LOWER, RUSSIAN_YERU_UPPER, RUSSIAN_TE_LOWER,
RUSSIAN_TE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_U_LOWER, RUSSIAN_U_UPPER, RUSSIAN_YU_LOWER,
RUSSIAN_YU_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YU_LOWER, RUSSIAN_YU_UPPER, false))
{
return;
}
// group 1
else if (
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_EL_LOWER, RUSSIAN_EL_UPPER, RUSSIAN_A_LOWER,
RUSSIAN_A_UPPER) || /*2*/
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_EN_LOWER, RUSSIAN_EN_UPPER, RUSSIAN_A_LOWER,
RUSSIAN_A_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_EL_LOWER, RUSSIAN_EL_UPPER, RUSSIAN_I_LOWER,
RUSSIAN_I_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_EL_LOWER, RUSSIAN_EL_UPPER, RUSSIAN_O_LOWER,
RUSSIAN_O_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_EN_LOWER, RUSSIAN_EN_UPPER, RUSSIAN_O_LOWER,
RUSSIAN_O_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_TE_LOWER,
RUSSIAN_TE_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_YU_LOWER, RUSSIAN_YU_UPPER, RUSSIAN_TE_LOWER,
RUSSIAN_TE_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_EN_LOWER, RUSSIAN_EN_UPPER, RUSSIAN_YERU_LOWER,
RUSSIAN_YERU_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_TE_LOWER, RUSSIAN_TE_UPPER,
RUSSIAN_SOFT_SIGN_LOWER, RUSSIAN_SOFT_SIGN_UPPER))
{
if (text.length() >= 3 &&
stem<string_typeT>::get_rv() <= text.length() - 3 &&
(is_either<wchar_t>(
text[text.length() - 3], RUSSIAN_A_LOWER,
RUSSIAN_A_UPPER) ||
is_either<wchar_t>(
text[text.length() - 3], RUSSIAN_YA_LOWER,
RUSSIAN_YA_UPPER)))
{
text.erase(text.end() - 2, text.end());
stem<string_typeT>::update_r_sections(text);
return;
}
}
if (stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_SHORT_I_LOWER, RUSSIAN_SHORT_I_UPPER) || /*1*/
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_EL_LOWER, RUSSIAN_EL_UPPER) ||
stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_EN_LOWER, RUSSIAN_EN_UPPER))
{
if (text.length() >= 2 &&
stem<string_typeT>::get_rv() <= text.length() - 2 &&
(is_either<wchar_t>(
text[text.length() - 2], RUSSIAN_A_LOWER,
RUSSIAN_A_UPPER) ||
is_either<wchar_t>(
text[text.length() - 2], RUSSIAN_YA_LOWER,
RUSSIAN_YA_UPPER)))
{
text.erase(text.end() - 1, text.end());
stem<string_typeT>::update_r_sections(text);
return;
}
}
// noun
if (stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_YA_LOWER,
RUSSIAN_YA_UPPER, RUSSIAN_EM_LOWER, RUSSIAN_EM_UPPER,
RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_YA_LOWER,
RUSSIAN_YA_UPPER, RUSSIAN_HA_LOWER, RUSSIAN_HA_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YA_LOWER, RUSSIAN_YA_UPPER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_A_LOWER, RUSSIAN_A_UPPER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_YA_LOWER,
RUSSIAN_YA_UPPER, RUSSIAN_EM_LOWER, RUSSIAN_EM_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_IE_LOWER,
RUSSIAN_IE_UPPER, RUSSIAN_EM_LOWER, RUSSIAN_EM_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_VE_LOWER,
RUSSIAN_VE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, RUSSIAN_VE_LOWER,
RUSSIAN_VE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_IE_LOWER,
RUSSIAN_IE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_SOFT_SIGN_LOWER, RUSSIAN_SOFT_SIGN_UPPER,
RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_I_LOWER,
RUSSIAN_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER,
RUSSIAN_SHORT_I_LOWER, RUSSIAN_SHORT_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_I_LOWER,
RUSSIAN_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_IE_LOWER,
RUSSIAN_IE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_I_LOWER,
RUSSIAN_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_A_LOWER, RUSSIAN_A_UPPER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_YU_LOWER,
RUSSIAN_YU_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_SOFT_SIGN_LOWER, RUSSIAN_SOFT_SIGN_UPPER,
RUSSIAN_YU_LOWER, RUSSIAN_YU_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_YA_LOWER,
RUSSIAN_YA_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_SOFT_SIGN_LOWER, RUSSIAN_SOFT_SIGN_UPPER,
RUSSIAN_YA_LOWER, RUSSIAN_YA_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, RUSSIAN_VE_LOWER,
RUSSIAN_VE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, RUSSIAN_VE_LOWER,
RUSSIAN_VE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_A_LOWER, RUSSIAN_A_UPPER, RUSSIAN_HA_LOWER,
RUSSIAN_HA_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_IE_LOWER,
RUSSIAN_IE_UPPER, RUSSIAN_SHORT_I_LOWER, RUSSIAN_SHORT_I_UPPER,
false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, RUSSIAN_SHORT_I_LOWER,
RUSSIAN_SHORT_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, RUSSIAN_SHORT_I_LOWER,
RUSSIAN_SHORT_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_SOFT_SIGN_LOWER, RUSSIAN_SOFT_SIGN_UPPER,
RUSSIAN_YA_LOWER, RUSSIAN_YA_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YA_LOWER, RUSSIAN_YA_UPPER, RUSSIAN_EM_LOWER,
RUSSIAN_EM_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YA_LOWER, RUSSIAN_YA_UPPER, RUSSIAN_HA_LOWER,
RUSSIAN_HA_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_LOWER, RUSSIAN_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_A_LOWER, RUSSIAN_A_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_U_LOWER, RUSSIAN_U_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YU_LOWER, RUSSIAN_YU_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YA_LOWER, RUSSIAN_YA_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_SOFT_SIGN_LOWER, RUSSIAN_SOFT_SIGN_UPPER,
false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_YERU_LOWER, RUSSIAN_YERU_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_SHORT_I_LOWER, RUSSIAN_SHORT_I_UPPER, false) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER, false))
{
return;
}
}
void step_2(string_typeT & text)
{
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_I_UPPER, RUSSIAN_I_LOWER);
}
void step_3(string_typeT & text)
{
if (stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, RUSSIAN_ES_LOWER,
RUSSIAN_ES_UPPER, RUSSIAN_TE_LOWER, RUSSIAN_TE_UPPER,
RUSSIAN_SOFT_SIGN_LOWER, RUSSIAN_SOFT_SIGN_UPPER))
{
stem<string_typeT>::delete_if_is_in_r2(
text, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, RUSSIAN_ES_LOWER,
RUSSIAN_ES_UPPER, RUSSIAN_TE_LOWER, RUSSIAN_TE_UPPER,
RUSSIAN_SOFT_SIGN_LOWER, RUSSIAN_SOFT_SIGN_UPPER);
}
else if (stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, RUSSIAN_ES_LOWER,
RUSSIAN_ES_UPPER, RUSSIAN_TE_LOWER, RUSSIAN_TE_UPPER))
{
stem<string_typeT>::delete_if_is_in_r2(
text, RUSSIAN_O_LOWER, RUSSIAN_O_UPPER, RUSSIAN_ES_LOWER,
RUSSIAN_ES_UPPER, RUSSIAN_TE_LOWER, RUSSIAN_TE_UPPER);
}
}
void step_4(string_typeT & text)
{
if (stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_EN_LOWER, RUSSIAN_EN_UPPER, RUSSIAN_EN_LOWER,
RUSSIAN_EN_UPPER))
{
text.erase(text.end() - 1, text.end());
stem<string_typeT>::update_r_sections(text);
}
else if (
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER,
RUSSIAN_SHORT_I_LOWER, RUSSIAN_SHORT_I_UPPER,
RUSSIAN_SHA_LOWER, RUSSIAN_SHA_UPPER, RUSSIAN_IE_LOWER,
RUSSIAN_IE_UPPER) ||
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_IE_LOWER, RUSSIAN_IE_UPPER,
RUSSIAN_SHORT_I_LOWER, RUSSIAN_SHORT_I_UPPER,
RUSSIAN_SHA_LOWER, RUSSIAN_SHA_UPPER))
{
if (stem<string_typeT>::is_suffix_in_rv(
text, RUSSIAN_EN_LOWER, RUSSIAN_EN_UPPER, RUSSIAN_EN_LOWER,
RUSSIAN_EN_UPPER))
{
text.erase(text.end() - 1, text.end());
stem<string_typeT>::update_r_sections(text);
}
}
else
{
stem<string_typeT>::delete_if_is_in_rv(
text, RUSSIAN_SOFT_SIGN_LOWER, RUSSIAN_SOFT_SIGN_UPPER);
}
}
};
} // namespace stemming
/** @}*/
#endif //__RUSSIAN_STEM_H__
|
TITLE BUF - MSDOS buffer management
NAME BUF
;
; Microsoft Confidential
; Copyright (C) Microsoft Corporation 1991
; All Rights Reserved.
;
;** BUF.ASM - Low level routines for buffer cache management
;
; GETCURHEAD
; ScanPlace
; PLACEBUF
; PLACEHEAD
; PointComp
; GETBUFFR
; GETBUFFRB
; FlushBuf
; BufWrite
; SET_RQ_SC_PARMS
;
; Revision history:
;
; AN000 version 4.00 Jan. 1988
; A004 PTM 3765 -- Disk reset failed
; M039 DB 10/17/90 - Disk write optimization
; I001 5.0 PTR 722211 - Preserve CY when in buffer in HMA
.xlist
.xcref
include version.inc
INCLUDE dosseg.inc
INCLUDE DOSSYM.INC
include dpb.inc
INCLUDE DEVSYM.INC
.cref
.list
Installed = TRUE
i_need PreRead,WORD
i_need LastBuffer,DWORD
i_need CurBuf,DWORD
i_need WPErr,BYTE
i_need ALLOWED,BYTE
i_need FAILERR,BYTE
i_need HIGH_SECTOR,WORD ; DOS 4.00 >32mb ;AN000;
i_need BufferQueue,DWORD
i_need DirtyBufferCount,WORD
i_need SC_CACHE_PTR,DWORD ; DOS 4.00 seconadary cache table ;AN000;
i_need SC_CACHE_COUNT,WORD ; DOS 4.00 secondary cache entries ;AN000;
i_need SC_SECTOR_SIZE,WORD ; DOS 4.00 sector size ;AN000;
i_need SC_DRIVE,BYTE ; DOS 4.00 drive ;AN000;
i_need DOS34_FLAG,WORD ; DOS 4.00 common flag ;AN000;
i_need FIRST_BUFF_ADDR,WORD ; DOS 4.00 beginning of the chain ;AN000;
i_need BuffInHMA,byte
i_need LoMemBuff,dword
DOSCODE SEGMENT
ASSUME SS:DOSDATA,CS:DOSCODE
Break <GETCURHEAD -- Get current buffer header>
;----------------------------------------------------------------------------
; Procedure Name : GetCurHead
; Inputs:
; No Inputs
; Function:
; Returns the pointer to the first buffer in Queue
; and updates FIRST_BUFF_ADDR
; and invalidates LASTBUFFER (recency pointer)
; Outputs:
; DS:DI = pointer to the first buffer in Queue
; FIRST_BUFF_ADDR = offset ( DI ) of First buffer in Queue
; LASTBUFFER = -1
; No other registers altered
;----------------------------------------------------------------------------
procedure GETCURHEAD,NEAR
lds di, BufferQueue ; Pointer to the first buffer;smr;SS Override
mov word ptr [LASTBUFFER],-1; invalidate last buffer;smr;SS Override
mov [FIRST_BUFF_ADDR],di ;save first buffer addr;smr;SS Override
ret
EndProc GETCURHEAD
Break <SCANPLACE, PLACEBUF -- PUT A BUFFER BACK IN THE POOL>
;----------------------------------------------------------------------------
; Procedure Name : ScanPlace
; Inputs:
; Same as PLACEBUF
; Function:
; Save scan location and call PLACEBUF
; Outputs:
; DS:DI Points to saved scan location
; All registers, except DS:DI, preserved.
;----------------------------------------------------------------------------
;M039: Rewritten to preserve registers.
procedure ScanPlace,near
push [di].buf_next ;Save scan location
call PLACEBUF
pop di
ret
EndProc ScanPlace
;----------------------------------------------------------------------------
; Procedure Name : PlaceBuf
; Input:
; DS:DI points to buffer (DS->BUFFINFO array, DI=offset in array)
; Function:
; Remove buffer from queue and re-insert it in proper place.
; NO registers altered
;----------------------------------------------------------------------------
procedure PLACEBUF,NEAR
push AX ;Save only regs we modify ;AN000;
push BX ;AN000;
push SI ;AN000;
mov ax, [di].BUF_NEXT
mov bx, word ptr[BufferQueue] ; bx = offset of head of list;smr;SS Override
cmp ax,bx ;Buf = last? ;AN000;
je nret ;Yes, special case ;AN000;
cmp di,bx ;Buf = first? ;AN000;
jne not_first ;Yes, special case ;AN000;
mov word ptr [BufferQueue],ax ;smr;SS Override
jmp short nret ;Continue with repositioning;AN000;
not_first:
mov SI,[DI].BUF_PREV ;No, SI = prior Buf ;AN000;
mov [SI].BUF_NEXT,AX ; ax has di->buf_next ;AN000;
xchg si, ax
mov [SI].BUF_PREV,AX ; ;AN000;
mov SI,[BX].BUF_PREV ;SI-> last buffer ;AN000;
mov [SI].BUF_NEXT,DI ;Add Buf to end of list ;AN000;
mov [BX].BUF_PREV,DI ;AN000;
mov [DI].BUF_PREV,SI ;Update link in Buf too ;AN000;
mov [DI].BUF_NEXT,BX ;AN000;
nret: ;AN000;
pop SI ;AN000;
pop BX ;AN000;
pop AX ;AN000;
;AN000;
cmp [di.buf_ID],-1 ; Buffer FREE? ;AN000;
jne pbx ; M039: -no, jump.
mov WORD PTR [BufferQueue],di ; M039: -yes, make it LRU.
pbx: ret ;AN000;
EndProc PLACEBUF
;M039 - Removed PLACEHEAD.
;----------------------------------------------------------------------------
; places buffer at head
; NOTE:::::: ASSUMES THAT BUFFER IS CURRENTLY THE LAST
; ONE IN THE LIST!!!!!!!
; BUGBUG ---- this routine can be removed because it has only
; BUGBUG ---- one instruction. This routine is called from
; BUGBUG ---- 3 places. ( Size = 3*3+6 = 15 bytes )
; BUGBUG ---- if coded in line = 3 * 5 = 15 bytes
; BUGBUG ---- But kept as it is for modularity
;----------------------------------------------------------------------------
;procedure PLACEHEAD,NEAR
; mov word ptr [BufferQueue], di
; ret
;EndProc PLACEHEAD
;M039
Break <POINTCOMP -- 20 BIT POINTER COMPARE>
;----------------------------------------------------------------------------
;
; Procedure Name : PointComp
; Inputs:
; DS:SI & ES:DI
; Function:
; Checks for ((SI==DI) && (ES==DS))
; Assumes that pointers are normalized for the
; same segment
;
; Compare DS:SI to ES:DI (or DS:DI to ES:SI) for equality
; DO NOT USE FOR < or >
; No Registers altered
;
;----------------------------------------------------------------------------
procedure PointComp,NEAR
CMP SI,DI
jnz ret_label ; return if nz
PUSH CX
PUSH DX
MOV CX,DS
MOV DX,ES
CMP CX,DX
POP DX
POP CX
ret_label:
return
EndProc PointComp
Break <GETBUFFR, GETBUFFRB -- GET A SECTOR INTO A BUFFER>
;** GetBuffr - Get a non-FAT Sector into a Buffer
;
; GetBuffr does normal ( non-FAT ) sector buffering
; It gets the specified local sector into one of the I/O buffers
; and shuffles the queue
;
; ENTRY (AL) = 0 means sector must be pre-read
; ELSE no pre-read
; (DX) = Desired physical sector number (LOW)
; HIGH_SECTOR = Desired physical sector number (HIGH)
; (ES:BP) = Pointer to drive parameters
; ALLOWED set in case of INT 24
; EXIT 'C' set if error (user FAIL response to INT24)
; 'C' clear if OK
; CURBUF Points to the Buffer for the sector
; the buffer type bits OF buf_flags = 0, caller must set it
; USES AX, BX, CX, SI, DI, Flags
;** GetBuffrb - Get a FAT Sector into a Buffer
;
; GetBuffr reads a sector from the FAT file system's FAT table.
; It gets the specified sector into one of the I/O buffers
; and shuffles the queue. We need a special entry point so that
; we can read the alternate FAT sector if the first read fails, also
; so we can mark the buffer as a FAT sector.
;
; ENTRY (AL) = 0 means sector must be pre-read
; ELSE no pre-read
; (DX) = Desired physical sector number (LOW)
; (SI) != 0
; HIGH_SECTOR = Desired physical sector number (HIGH)
; (ES:BP) = Pointer to drive parameters
; ALLOWED set in case of INT 24
; EXIT 'C' set if error (user FAIL response to INT24)
; 'C' clear if OK
; CURBUF Points to the Buffer for the sector
; the buffer type bits OF buf_flags = 0, caller must set it
; USES AX, BX, CX, SI, DI, Flags
procedure GETBUFFR,NEAR
DOSAssume <DS>,"GetBuffr"
XOR SI,SI
; This entry point is called for FAT buffering with SI != 0
entry GETBUFFRB
Assert ISDPB,<ES,BP>,"GetBuffr"
MOV PREREAD,AX ; save pre-read flag
MOV AL,ES:[BP].DPB_DRIVE
LDS DI,LASTBUFFER ; Get the recency pointer
ASSUME DS:NOTHING
;hkn; SS override
MOV CX,HIGH_SECTOR ; F.C. >32mb ;AN000;
; See if this is the buffer that was most recently returned.
; A big performance win if it is.
CMP DI,-1 ; Recency pointer valid?
je getb5 ; No
CMP DX,WORD PTR [DI].BUF_SECTOR
JNZ getb5 ; Wrong sector
CMP CX,WORD PTR [DI].BUF_SECTOR+2 ; F.C. >32mb ;AN000;
JNZ getb5 ; F.C. >32mb ;AN000;
CMP AL,[DI.buf_ID]
LJZ getb35 ; Just asked for same buffer
; It's not the buffer most recently returned. See if it's in the
; cache.
;
; (cx:dx) = sector #
; (al) = drive #
; (si) = 0 iff non fat sector, != 0 if FAT sector read
; ??? list may be incomplete ???
getb5: CALL GETCURHEAD ; get Q Head
getb10: CMP DX,WORD PTR [DI].BUF_SECTOR
jne getb12 ; wrong sector lo
CMP CX,WORD PTR [DI].BUF_SECTOR+2
jne getb12 ; wrong sector hi
CMP AL,[DI.buf_ID]
jne @f
jmp getb25 ; Found the requested sector
@@:
getb12: mov DI,[DI].BUF_NEXT
cmp DI,FIRST_BUFF_ADDR ; back at the front again?
jne getb10 ; no, continue looking
; The requested sector is not available in the buffers. DS:DI now points
; to the first buffer in the Queue. Flush the first buffer & read in the
; new sector into it.
;
; BUGBUG - what goes on here? Isn't the first guy the most recently
; used guy? Shuld be for fast lookup. If he is, we shouldn't take
; him, we should take LRU. And the above lookup shouldn't be
; down a chain, but should be hashed.
;
; (DS:DI) = first buffer in the queue
; (CX:DX) = sector # we want
; (si) = 0 iff non fat sector, != 0 if FAT sector read
;hkn; SS override
PUSH cx
SAVE <si, dx, bp, es>
CALL BUFWRITE ; Write out the dirty buffer
RESTORE <es, bp, dx, si>
POP HIGH_SECTOR
jnc @f
jmp getbx ; if got hard error
@@:
CALL SET_RQ_SC_PARMS ; set parms for secondary cache
; We're ready to read in the buffer, if need be. If the caller
; wanted to just *write* the buffer then we'll skip reading it in.
XOR AH,AH ; initial flags
;hkn; SS override
CMP BYTE PTR PREREAD,ah ; am to Read in the new sector?
JNZ getb20 ; no, we're done
LEA BX,[DI].BufInSiz ; (ds:bx) = data address
MOV CX,1
SAVE <si, di, dx, es>
; Note: As far as I can tell, all disk reads into buffers go through
; this point. -mrw 10/88
cmp BuffInHMA, 0 ; is buffers in HMA?
jz @f
push ds
push bx
lds bx, dword ptr LoMemBuff ; Then let's read it into scratch buff
@@:
;M039: Eliminated redundant HMA code.
OR SI,SI ; FAT sector ?
JZ getb15
invoke FATSECRD
MOV AH,buf_isFAT ; Set buf_flags
JMP SHORT getb17 ; Buffer is marked free if read barfs
getb15:
invoke DREAD ; Buffer is marked free if read barfs
MOV AH,0 ; Set buf_flags to no type, DO NOT XOR!
getb17: ;I001
pushf ;I001
cmp BuffInHMA, 0 ; did we read into scratch buff ? ;I001
jz not_in_hma ; no ;I001
mov cx, es:[bp].DPB_SECTOR_SIZE ;I001
shr cx, 1 ;I001
popf ; Retreive possible CY from DREAD ;I001
mov si, bx ;I001
pop di ;I001
pop es ;I001
cld ;I001
pushf ; Preserve possible CY from DREAD ;I001
rep movsw ; move the contents of scratch buf;I001
push es ;I001
pop ds ;I001
not_in_hma: ;I001
popf ;I001
RESTORE <es, dx, di, si>
JC getbx
; The buffer has the data setup in it (if we were to read)
; Setup the various buffer fields
;
; (ds:di) = buffer address
; (es:bp) = DPB address
; (HIGH_SECTOR:DX) = sector #
; (ah) = BUF_FLAGS value
; (si) = 0 iff non fat sector, != 0 if FAT sector read
;hkn; SS override
getb20: MOV CX,HIGH_SECTOR
MOV WORD PTR [DI].BUF_SECTOR+2,CX
MOV WORD PTR [DI].BUF_SECTOR,DX
MOV WORD PTR [DI].buf_DPB,BP
MOV WORD PTR [DI].buf_DPB+2,ES
MOV AL,ES:[BP].DPB_DRIVE
FOLLOWS BUF_FLAGS, BUF_ID, 1
MOV WORD PTR [DI].BUF_ID,AX ; Set ID and Flags
getb25: MOV [DI].BUF_WRTCNT,1 ; Default to not a FAT sector ;AC000;
XOR AX,AX
OR SI,SI ; FAT sector ?
JZ getb30
MOV AL,ES:[BP].DPB_FAT_COUNT ; update number of copies of
MOV [DI.buf_WRTCNT],AL ; this sector present on disk
MOV AX,ES:[BP].DPB_FAT_SIZE ; offset of identical FAT
; sectors
; BUGBUG - dos 6 can clean this up by not setting wrtcntinc unless wrtcnt
; is set
getb30: MOV [DI.buf_wrtcntinc],AX
CALL PLACEBUF
;hkn; SS override for next 4
getb35: MOV WORD PTR CURBUF+2,DS
MOV WORD PTR LASTBUFFER+2,DS
MOV WORD PTR CURBUF,DI
MOV WORD PTR LASTBUFFER,DI
CLC
; Return with 'C' set appropriately
;
; (dx) = caller's original value
getbx: Context DS
return
EndProc GETBUFFR
Break <FLUSHBUF -- WRITE OUT DIRTY BUFFERS>
;----------------------------------------------------------------------------
; Input:
; DS = DOSGROUP
; AL = Physical unit number local buffers only
; = -1 for all units and all remote buffers
; Function:
; Write out all dirty buffers for unit, and flag them as clean
; Carry set if error (user FAILed to I 24)
; Flush operation completed.
; DS Preserved, all others destroyed (ES too)
;----------------------------------------------------------------------------
procedure FlushBuf,NEAR
DOSAssume <DS>,"FlushBuf"
call GetCurHead
ASSUME DS:NOTHING
TESTB [DOS34_FLAG], FROM_DISK_RESET ; from disk reset ? ;hkn;
jnz scan_buf_queue
cmp [DirtyBufferCount], 0 ;hkn;
je end_scan
scan_buf_queue:
call CheckFlush
mov ah, [di].buf_ID
cmp byte ptr [wperr], ah ;hkn;
je free_the_buf
TESTB [DOS34_FLAG], FROM_DISK_RESET ; from disk reset ? ;hkn;
jz dont_free_the_buf
free_the_buf:
mov word ptr [di].buf_ID, 00ffh
dont_free_the_buf:
mov di, [di].buf_next
cmp di, [FIRST_BUFF_ADDR] ;hkn;
jne scan_buf_queue
end_scan:
Context DS
cmp [FAILERR], 0
jne bad_flush
ret
bad_flush:
stc
ret
EndProc FlushBuf
;----------------------------------------------------------------------------
;
; Procedure Name : CHECKFLUSH
;
; Inputs : AL - Drive number, -1 means do not check for drive
; DS:DI - pointer to buffer
;
; Function : Write out a buffer if it is dirty
;
; Carry set if problem (currently user FAILed to I 24)
;
;----------------------------------------------------------------------------
procedure CHECKFLUSH,NEAR
Assert ISBUF,<DS,DI>,"CheckFlush"
mov ah, -1
CMP [DI.buf_ID],AH
retz ; Skip free buffer, carry clear
CMP AH,AL ;
JZ DOBUFFER ; do this buffer
CMP AL,[DI.buf_ID]
CLC
retnz ; Buffer not for this unit or SFT
DOBUFFER:
TESTB [DI.buf_flags],buf_dirty
retz ; Buffer not dirty, carry clear by TEST
PUSH AX
PUSH WORD PTR [DI.buf_ID]
CALL BUFWRITE
POP AX
JC LEAVE_BUF ; Leave buffer marked free (lost).
AND AH,NOT buf_dirty ; Buffer is clean, clears carry
MOV WORD PTR [DI.buf_ID],AX
LEAVE_BUF:
POP AX ; Search info
return
EndProc CHECKFLUSH
Break <BUFWRITE -- WRITE OUT A BUFFER IF DIRTY>
;** BufWrite - Write out Dirty Buffer
;
; BufWrite writes a buffer to the disk, iff it's dirty.
;
; ENTRY DS:DI Points to the buffer
;
; EXIT Buffer marked free
; Carry set if error (currently user FAILed to I 24)
;
; USES All buf DS:DI
; HIGH_SECTOR
procedure BufWrite,NEAR
Assert ISBUF,<DS,DI>,"BufWrite"
MOV AX,00FFH
XCHG AX,WORD PTR [DI.buf_ID] ; Free, in case write barfs
CMP AL,0FFH
retz ; Buffer is free, carry clear.
test AH,buf_dirty
retz ; Buffer is clean, carry clear.
invoke DEC_DIRTY_COUNT ; LB. decrement dirty count
;hkn; SS override
CMP AL,BYTE PTR [WPERR]
retz ; If in WP error zap buffer
;hkn; SS override
MOV [SC_DRIVE],AL ;LB. set it for invalidation ;AN000;
LES BP,[DI.buf_DPB]
LEA BX,[DI.BufInSiz] ; Point at buffer
MOV DX,WORD PTR [DI].BUF_SECTOR ;F.C. >32mb ;AN000;
MOV CX,WORD PTR [DI].BUF_SECTOR+2 ;F.C. >32mb ;AN000;
;hkn; SS override
MOV [HIGH_SECTOR],CX ;F.C. >32mb ;AN000;
MOV CL,[DI.buf_wrtcnt] ;>32mb ;AC000;
; MOV AL,CH ; [DI.buf_wrtcntinc]
XOR CH,CH
;hkn; SS override for ALLOWED
MOV [ALLOWED],allowed_RETRY + allowed_FAIL
test AH, buf_isDATA
JZ NO_IGNORE
OR [ALLOWED],allowed_IGNORE
NO_IGNORE:
MOV AX,[DI.buf_wrtcntinc] ;>32mb ;AC000;
PUSH DI ; Save buffer pointer
XOR DI,DI ; Indicate failure
push ds
push bx
WRTAGAIN:
SAVE <DI,CX,AX>
MOV CX,1
SAVE <BX,DX,DS>
; Note: As far as I can tell, all disk reads into buffers go through this point. -mrw 10/88
cmp BuffInHMA, 0
jz @f
push cx
push es
mov si, bx
mov cx, es:[bp].DPB_SECTOR_SIZE
shr cx, 1
les di, dword ptr LoMemBuff
mov bx, di
cld
rep movsw
push es
pop ds
pop es
pop cx
@@:
invoke DWRITE ; Write out the dirty buffer
RESTORE <DS,DX,BX>
RESTORE <AX,CX,DI>
JC NOSET
INC DI ; If at least ONE write succeedes, the operation
NOSET: ; succeedes.
ADD DX,AX
LOOP WRTAGAIN
pop bx
pop ds
OR DI,DI ; Clears carry
JNZ BWROK ; At least one write worked
STC ; DI never got INCed, all writes failed.
BWROK: POP DI
return
EndProc BufWrite
Break <SET_RQ_SC_PARMS-set requesting drive for SC>
;** Set_RQ_SC_Parms - Set Secondary Cache Parameters
;
; Set_RQ_SC_Parms sets the sector size and drive number value
; for the secondary cache. This updates SC_SECTOR_SIZE &
; SC_DRIVE even if SC is disabled to save the testing
; code and time
;
; ENTRY ES:BP = drive parameter block
;
; EXIT [SC_SECTOR_SIZE]= drive sector size
; [SC_DRIVE]= drive #
;
; USES Flags
procedure SET_RQ_SC_PARMS,NEAR
;hkn; SS override for all variables used in this procedure.
SAVE <ax>
MOV ax,ES:[BP].DPB_SECTOR_SIZE ; save sector size
MOV SC_SECTOR_SIZE,ax
MOV al,ES:[BP].DPB_DRIVE ; save drive #
MOV SC_DRIVE,al
RESTORE <ax>
srspx: return
EndProc SET_RQ_SC_PARMS ;LB. return
Break <INC_DIRTY_COUNT-increment dirty count>
;----------------------------------------------------------------------------
; Input:
; none
; Function:
; increment dirty buffers count
; Output:
; dirty buffers count is incremented
;
; All registers preserved
;----------------------------------------------------------------------------
procedure INC_DIRTY_COUNT,NEAR
; BUGBUG ---- remove this routine
; BUGBUG ---- only one instruction is needed (speed win, space loose)
inc [DirtyBufferCount] ;hkn;
ret
EndProc INC_DIRTY_COUNT
Break <DEC_DIRTY_COUNT-decrement dirty count>
;----------------------------------------------------------------------------
; Input:
; none
; Function:
; decrement dirty buffers count
; Output:
; dirty buffers count is decremented
;
; All registers preserved
;----------------------------------------------------------------------------
procedure DEC_DIRTY_COUNT,NEAR
cmp [DirtyBufferCount], 0 ;hkn;
jz ddcx ; BUGBUG - shouldn't it be an
dec [DirtyBufferCount] ; error condition to underflow here? ;hkn;
ddcx: ret
EndProc DEC_DIRTY_COUNT
DOSCODE ENDS
END
|
//===--------------------------------------------------------------------------------*- C++ -*-===//
// _ _
// | | | |
// __ _| |_ ___| | __ _ _ __ __ _
// / _` | __/ __| |/ _` | '_ \ / _` |
// | (_| | || (__| | (_| | | | | (_| |
// \__, |\__\___|_|\__,_|_| |_|\__, | - GridTools Clang DSL
// __/ | __/ |
// |___/ |___/
//
//
// This file is distributed under the MIT License (MIT).
// See LICENSE.txt for details.
//
//===------------------------------------------------------------------------------------------===//
// RUN: %gtclang% %file% -fno-codegen -freport-pass-stage-reordering -max-halo=3
// EXPECTED_FILE: OUTPUT:%filename%_before.json,%filename%_after.json REFERENCE:%filename%_before_ref.json,%filename%_after_ref.json
#include "gtclang_dsl_defs/gtclang_dsl.hpp"
using namespace gtclang::dsl;
stencil Test {
storage field_a0, field_a1, field_a2, field_a3, field_a4, field_a5, field_a6, field_a7;
Do {
vertical_region(k_start, k_end) {
field_a1 = field_a0(i + 1);
field_a2 = field_a1(i + 1);
field_a3 = field_a2(i + 1);
field_a4 = field_a3(i + 1);
field_a5 = field_a4(i + 1);
field_a6 = field_a5(i + 1);
field_a7 = field_a6(i + 1);
}
}
};
int main() {}
|
#include <iostream>
#include <limits>
#include <new>
#include <cassert>
#include <adobe/algorithm.hpp>
#include <adobe/forest.hpp>
#include <boost/range.hpp>
template <typename R> // R is a depth adaptor range
void output(const R& f)
{
typedef typename boost::range_iterator<R>::type iterator;
for (iterator first(boost::begin(f)), last(boost::end(f)); first != last; ++first)
{
for (typename iterator::difference_type i(first.depth()); i != 0; --i)
{
std::cout << "\t";
}
if (first.edge() == adobe::forest_leading_edge)
{
std::cout << "<" << *first << ">" << std::endl;
}
else
{
std::cout << "</" << *first << ">" << std::endl;
}
}
}
int main()
{
typedef adobe::forest<std::string> forest;
typedef forest::iterator iterator;
std::cout << "<- default construction and insert ->" << std::endl;
forest f;
iterator i (f.begin());
i = adobe::trailing_of(f.insert(i, "grandmother"));
{
iterator p (adobe::trailing_of(f.insert(i, "mother")));
f.insert(p, "me");
f.insert(p, "sister");
f.insert(p, "brother");
}
{
iterator p (adobe::trailing_of(f.insert(i, "aunt")));
f.insert(p, "cousin");
}
f.insert(i, "uncle");
output(adobe::depth_range(f));
std::cout << "<- copy construction and reverse ->" << std::endl;
forest f2(f);
iterator f2_grandmother(adobe::find(adobe::preorder_range(f2), "grandmother").base());
f2.reverse(adobe::child_begin(f2_grandmother), adobe::child_end(f2_grandmother));
output(adobe::depth_range(f2));
std::cout << "<- reverse iterator ->" << std::endl;
output(adobe::depth_range(adobe::reverse_fullorder_range(f)));
std::cout << "<- node deletion ->" << std::endl;
forest f3(f);
iterator f3_aunt(adobe::find(adobe::preorder_range(f3), "aunt").base());
iterator f3_uncle(adobe::find(adobe::preorder_range(f3), "uncle").base());
f3.erase(adobe::leading_of(f3_aunt), ++(adobe::trailing_of(f3_uncle)));
output(adobe::depth_range(f3));
std::cout << "<- splicing 1 ->" << std::endl;
forest f4(f);
forest f5(f);
iterator f4_aunt(adobe::find(adobe::preorder_range(f4), "aunt").base());
std::cout << "Size of f4 pre-splice: " << static_cast<unsigned long>(f4.size()) << std::endl;
std::cout << "Size of f5 pre-splice: " << static_cast<unsigned long>(f5.size()) << std::endl;
// Note that because f4_aunt is on the leading edge, the spliced forest's
// top nodes will be siblings to f4_aunt.
f4.splice(f4_aunt, f5);
output(adobe::depth_range(f4));
std::cout << "Size of f4 post-splice: " << static_cast<unsigned long>(f4.size()) << std::endl;
std::cout << "Size of f5 post-splice: " << static_cast<unsigned long>(f5.size()) << std::endl;
std::cout << "<- splicing 2 ->" << std::endl;
forest f6(f);
forest f7(f);
iterator f6_aunt(adobe::find(adobe::preorder_range(f6), "aunt").base());
std::cout << "Size of f6 pre-splice: " << static_cast<unsigned long>(f6.size()) << std::endl;
std::cout << "Size of f7 pre-splice: " << static_cast<unsigned long>(f7.size()) << std::endl;
f6_aunt = adobe::trailing_of(f6_aunt);
// Note that because f6_aunt is on the trailing edge, the spliced forest's
// top nodes will be children to f6_aunt.
f6.splice(f6_aunt, f7);
output(adobe::depth_range(f6));
std::cout << "Size of f6 post-splice: " << static_cast<unsigned long>(f6.size()) << std::endl;
std::cout << "Size of f7 post-splice: " << static_cast<unsigned long>(f7.size()) << std::endl;
return 0;
}
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %r15
push %r8
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x7f90, %rsi
lea addresses_UC_ht+0x17650, %rdi
nop
nop
add %r14, %r14
mov $40, %rcx
rep movsb
nop
nop
nop
nop
nop
add $5554, %r15
lea addresses_UC_ht+0x1da10, %rdi
nop
nop
nop
nop
nop
add %r11, %r11
mov (%rdi), %r15w
nop
nop
nop
add $2244, %rcx
lea addresses_WC_ht+0x9790, %rsi
lea addresses_WC_ht+0xd010, %rdi
clflush (%rdi)
nop
nop
nop
xor %r14, %r14
mov $83, %rcx
rep movsb
nop
nop
nop
add $11345, %rsi
lea addresses_UC_ht+0xe54a, %r11
nop
nop
nop
sub $40902, %r14
vmovups (%r11), %ymm6
vextracti128 $1, %ymm6, %xmm6
vpextrq $1, %xmm6, %r15
nop
nop
nop
nop
nop
cmp $15576, %rcx
lea addresses_A_ht+0xe250, %r11
xor %r8, %r8
movw $0x6162, (%r11)
inc %rdi
pop %rsi
pop %rdi
pop %rcx
pop %r8
pop %r15
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r9
push %rbx
push %rdx
push %rsi
// Faulty Load
lea addresses_D+0xe210, %rdx
nop
cmp $7541, %r13
mov (%rdx), %rbx
lea oracles, %rsi
and $0xff, %rbx
shlq $12, %rbx
mov (%rsi,%rbx,1), %rbx
pop %rsi
pop %rdx
pop %rbx
pop %r9
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 4, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': True}}
{'36': 21829}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r13
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_A_ht+0x2e87, %rbx
sub %r13, %r13
mov $0x6162636465666768, %r12
movq %r12, %xmm7
movups %xmm7, (%rbx)
nop
nop
nop
nop
xor $17025, %r11
lea addresses_WC_ht+0x14c37, %r13
sub $28273, %rax
movb (%r13), %cl
nop
nop
nop
nop
sub %r12, %r12
lea addresses_UC_ht+0x1bcdf, %rcx
nop
xor %r12, %r12
mov (%rcx), %r11d
xor $5924, %rax
lea addresses_WT_ht+0x1d7af, %rsi
lea addresses_D_ht+0x1133f, %rdi
nop
nop
add %r13, %r13
mov $70, %rcx
rep movsq
nop
nop
nop
mfence
lea addresses_WC_ht+0x1b6a1, %rsi
lea addresses_A_ht+0x1653f, %rdi
nop
nop
cmp $17715, %r11
mov $89, %rcx
rep movsb
nop
cmp %r13, %r13
lea addresses_D_ht+0xff9f, %rsi
lea addresses_A_ht+0xae8f, %rdi
sub %rax, %rax
mov $77, %rcx
rep movsb
nop
nop
nop
nop
and $62943, %rdi
lea addresses_A_ht+0x160df, %r13
nop
sub $46507, %rdi
mov $0x6162636465666768, %rcx
movq %rcx, (%r13)
nop
nop
sub %rsi, %rsi
lea addresses_A_ht+0x1e41f, %r13
nop
nop
add $3273, %rbx
mov (%r13), %ecx
nop
nop
nop
nop
dec %rdi
lea addresses_D_ht+0x1241f, %rax
cmp $27675, %rbx
mov $0x6162636465666768, %r11
movq %r11, %xmm7
vmovups %ymm7, (%rax)
nop
nop
nop
sub $38723, %rbx
lea addresses_WT_ht+0xb7cf, %r13
inc %rdi
movb (%r13), %bl
nop
nop
nop
nop
inc %r11
lea addresses_WT_ht+0x1b0df, %rsi
lea addresses_WC_ht+0x9bfb, %rdi
dec %r12
mov $97, %rcx
rep movsq
xor %rcx, %rcx
lea addresses_UC_ht+0x1208b, %rax
clflush (%rax)
nop
nop
inc %r11
mov $0x6162636465666768, %r12
movq %r12, (%rax)
nop
nop
nop
nop
xor %rcx, %rcx
lea addresses_WT_ht+0xf05f, %rdi
nop
nop
nop
nop
cmp %rbx, %rbx
movb $0x61, (%rdi)
nop
nop
cmp $17833, %rsi
lea addresses_WC_ht+0x16ddf, %rcx
nop
nop
nop
nop
dec %r11
mov $0x6162636465666768, %r13
movq %r13, %xmm6
movups %xmm6, (%rcx)
nop
nop
nop
nop
cmp %r13, %r13
lea addresses_WT_ht+0x409f, %rdi
nop
nop
nop
nop
cmp $58060, %rsi
mov (%rdi), %r12d
nop
nop
nop
nop
nop
and $4800, %rsi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r13
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %rbp
push %rbx
push %rdi
push %rsi
// Faulty Load
lea addresses_RW+0xcdf, %rsi
cmp %rbp, %rbp
mov (%rsi), %r12d
lea oracles, %rsi
and $0xff, %r12
shlq $12, %r12
mov (%rsi,%r12,1), %r12
pop %rsi
pop %rdi
pop %rbx
pop %rbp
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_RW', 'same': False, 'AVXalign': False, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_RW', 'same': True, 'AVXalign': False, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 2}}
{'OP': 'LOAD', 'src': {'size': 4, 'NT': True, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 10}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 3}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 3}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 1}, 'dst': {'same': True, 'type': 'addresses_A_ht', 'congruent': 4}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_D_ht', 'congruent': 5}, 'dst': {'same': False, 'type': 'addresses_A_ht', 'congruent': 1}}
{'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 9}}
{'OP': 'LOAD', 'src': {'size': 4, 'NT': True, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 3}}
{'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 4}}
{'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WT_ht', 'congruent': 8}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 0}}
{'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_UC_ht', 'same': False, 'AVXalign': False, 'congruent': 2}}
{'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 7}}
{'OP': 'STOR', 'dst': {'size': 16, 'NT': False, 'type': 'addresses_WC_ht', 'same': True, 'AVXalign': False, 'congruent': 8}}
{'OP': 'LOAD', 'src': {'size': 4, 'NT': True, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': True, 'congruent': 6}}
{'32': 21829}
32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
*/
|
; A099821: Odd positive integers in base 2 (bisection of A007088).
; 1,11,101,111,1001,1011,1101,1111,10001,10011,10101,10111,11001,11011,11101,11111,100001,100011,100101,100111,101001,101011,101101,101111,110001,110011,110101,110111,111001,111011,111101,111111,1000001,1000011,1000101,1000111,1001001,1001011,1001101,1001111,1010001,1010011,1010101,1010111,1011001,1011011,1011101,1011111,1100001,1100011,1100101,1100111,1101001,1101011,1101101,1101111,1110001,1110011,1110101,1110111,1111001,1111011,1111101,1111111,10000001,10000011,10000101,10000111,10001001,10001011,10001101,10001111,10010001,10010011,10010101,10010111,10011001,10011011,10011101,10011111,10100001,10100011,10100101,10100111,10101001,10101011,10101101,10101111,10110001,10110011,10110101,10110111,10111001,10111011,10111101,10111111,11000001,11000011,11000101,11000111,11001001,11001011,11001101,11001111,11010001,11010011,11010101,11010111,11011001,11011011,11011101,11011111,11100001,11100011,11100101,11100111,11101001,11101011,11101101,11101111,11110001,11110011,11110101,11110111,11111001,11111011,11111101,11111111,100000001,100000011,100000101,100000111,100001001,100001011,100001101,100001111,100010001,100010011,100010101,100010111,100011001,100011011,100011101,100011111,100100001,100100011,100100101,100100111,100101001,100101011,100101101,100101111,100110001,100110011,100110101,100110111,100111001,100111011,100111101,100111111,101000001,101000011,101000101,101000111,101001001,101001011,101001101,101001111,101010001,101010011,101010101,101010111,101011001,101011011,101011101,101011111,101100001,101100011,101100101,101100111,101101001,101101011,101101101,101101111,101110001,101110011,101110101,101110111,101111001,101111011,101111101,101111111,110000001,110000011,110000101,110000111,110001001,110001011,110001101,110001111,110010001,110010011,110010101,110010111,110011001,110011011,110011101,110011111,110100001,110100011,110100101,110100111,110101001,110101011,110101101,110101111,110110001,110110011,110110101,110110111,110111001,110111011,110111101,110111111,111000001,111000011,111000101,111000111,111001001,111001011,111001101,111001111,111010001,111010011,111010101,111010111,111011001,111011011,111011101,111011111,111100001,111100011,111100101,111100111,111101001,111101011,111101101,111101111,111110001,111110011
mov $3,$0
mul $0,2
cal $0,228071 ; Write n in binary and interpret as a decimal number; a(n) is this quantity minus n.
mov $1,$0
add $1,1
mov $2,$3
mul $2,2
add $1,$2
|
; A110665: Sequence is {a(0,n)}, where a(m,0)=0, a(m,n) = a(m-1,n)+a(m,n-1) and a(0,n) is such that a(n,n) = n for all n.
; 0,1,0,-3,-4,0,6,7,0,-9,-10,0,12,13,0,-15,-16,0,18,19,0,-21,-22,0,24,25,0,-27,-28,0,30,31,0,-33,-34,0,36,37,0,-39,-40,0,42,43,0,-45,-46,0,48,49,0,-51,-52,0,54,55,0,-57,-58,0,60,61,0,-63,-64,0,66,67,0,-69,-70,0,72,73,0,-75,-76,0,78,79,0,-81,-82,0,84,85,0,-87,-88,0,90,91,0,-93,-94,0,96,97,0,-99,-100,0,102,103,0,-105,-106,0,108,109,0,-111,-112,0,114,115,0,-117,-118,0,120,121,0,-123,-124,0,126,127,0,-129,-130,0,132,133,0,-135,-136,0,138,139,0,-141,-142,0,144,145,0,-147,-148,0,150,151,0,-153,-154,0,156,157,0,-159,-160,0,162,163,0,-165,-166,0,168,169,0,-171,-172,0,174,175,0,-177,-178,0,180,181,0,-183,-184,0,186,187,0,-189,-190,0,192,193,0,-195,-196,0,198,199,0,-201,-202,0,204,205,0,-207,-208,0,210,211,0,-213,-214,0,216,217,0,-219,-220,0,222,223,0,-225,-226,0,228,229,0,-231,-232,0,234,235,0,-237,-238,0,240,241,0,-243,-244,0,246,247,0,-249
mov $1,$0
sub $0,1
lpb $0
sub $0,1
add $2,$1
sub $1,$2
lpe
|
.ORG 0
.BLOCK 65537
.END
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.
#include "db/log_reader.h"
#include "db/log_writer.h"
#include "leveldb/env.h"
#include "util/coding.h"
#include "util/crc32c.h"
#include "util/random.h"
#include "util/testharness.h"
namespace leveldb {
namespace log {
// Construct a string of the specified length made out of the supplied
// partial string.
static std::string BigString(const std::string& partial_string, size_t n) {
std::string result;
while (result.size() < n) {
result.append(partial_string);
}
result.resize(n);
return result;
}
// Construct a string from a number
static std::string NumberString(int n) {
char buf[50];
snprintf(buf, sizeof(buf), "%d.", n);
return std::string(buf);
}
// Return a skewed potentially long string
static std::string RandomSkewedString(int i, Random* rnd) {
return BigString(NumberString(i), rnd->Skewed(17));
}
class LogTest {
private:
class StringDest : public WritableFile {
public:
std::string contents_;
virtual Status Close() { return Status::OK(); }
virtual Status Flush() { return Status::OK(); }
virtual Status Sync() { return Status::OK(); }
virtual Status Append(const Slice& slice) {
contents_.append(slice.data(), slice.size());
return Status::OK();
}
};
class StringSource : public SequentialFile {
public:
Slice contents_;
bool force_error_;
bool returned_partial_;
StringSource() : force_error_(false), returned_partial_(false) { }
virtual Status Read(size_t n, Slice* result, char* scratch) {
ASSERT_TRUE(!returned_partial_) << "must not Read() after eof/error";
if (force_error_) {
force_error_ = false;
returned_partial_ = true;
return Status::Corruption("read error");
}
if (contents_.size() < n) {
n = contents_.size();
returned_partial_ = true;
}
*result = Slice(contents_.data(), n);
contents_.remove_prefix(n);
return Status::OK();
}
virtual Status Skip(uint64_t n) {
if (n > contents_.size()) {
contents_.clear();
return Status::NotFound("in-memory file skipped past end");
}
contents_.remove_prefix(n);
return Status::OK();
}
};
class ReportCollector : public Reader::Reporter {
public:
size_t dropped_bytes_;
std::string message_;
ReportCollector() : dropped_bytes_(0) { }
virtual void Corruption(size_t bytes, const Status& status) {
dropped_bytes_ += bytes;
message_.append(status.ToString());
}
};
StringDest dest_;
StringSource source_;
ReportCollector report_;
bool reading_;
Writer* writer_;
Reader* reader_;
// Record metadata for testing initial offset functionality
static size_t initial_offset_record_sizes_[];
static uint64_t initial_offset_last_record_offsets_[];
static int num_initial_offset_records_;
public:
LogTest() : reading_(false),
writer_(new Writer(&dest_)),
reader_(new Reader(&source_, &report_, true/*checksum*/,
0/*initial_offset*/)) {
}
~LogTest() {
delete writer_;
delete reader_;
}
void ReopenForAppend() {
delete writer_;
writer_ = new Writer(&dest_, dest_.contents_.size());
}
void Write(const std::string& msg) {
ASSERT_TRUE(!reading_) << "Write() after starting to read";
writer_->AddRecord(Slice(msg));
}
size_t WrittenBytes() const {
return dest_.contents_.size();
}
std::string Read() {
if (!reading_) {
reading_ = true;
source_.contents_ = Slice(dest_.contents_);
}
std::string scratch;
Slice record;
if (reader_->ReadRecord(&record, &scratch)) {
return record.ToString();
} else {
return "EOF";
}
}
void IncrementByte(int offset, int delta) {
dest_.contents_[offset] += delta;
}
void SetByte(int offset, char new_byte) {
dest_.contents_[offset] = new_byte;
}
void ShrinkSize(int bytes) {
dest_.contents_.resize(dest_.contents_.size() - bytes);
}
void FixChecksum(int header_offset, int len) {
// Compute crc of type/len/data
uint32_t crc = crc32c::Value(&dest_.contents_[header_offset+6], 1 + len);
crc = crc32c::Mask(crc);
EncodeFixed32(&dest_.contents_[header_offset], crc);
}
void ForceError() {
source_.force_error_ = true;
}
size_t DroppedBytes() const {
return report_.dropped_bytes_;
}
std::string ReportMessage() const {
return report_.message_;
}
// Returns OK iff recorded error message contains "msg"
std::string MatchError(const std::string& msg) const {
if (report_.message_.find(msg) == std::string::npos) {
return report_.message_;
} else {
return "OK";
}
}
void WriteInitialOffsetLog() {
for (int i = 0; i < num_initial_offset_records_; i++) {
std::string record(initial_offset_record_sizes_[i],
static_cast<char>('a' + i));
Write(record);
}
}
void StartReadingAt(uint64_t initial_offset) {
delete reader_;
reader_ = new Reader(&source_, &report_, true/*checksum*/, initial_offset);
}
void CheckOffsetPastEndReturnsNoRecords(uint64_t offset_past_end) {
WriteInitialOffsetLog();
reading_ = true;
source_.contents_ = Slice(dest_.contents_);
Reader* offset_reader = new Reader(&source_, &report_, true/*checksum*/,
WrittenBytes() + offset_past_end);
Slice record;
std::string scratch;
ASSERT_TRUE(!offset_reader->ReadRecord(&record, &scratch));
delete offset_reader;
}
void CheckInitialOffsetRecord(uint64_t initial_offset,
int expected_record_offset) {
WriteInitialOffsetLog();
reading_ = true;
source_.contents_ = Slice(dest_.contents_);
Reader* offset_reader = new Reader(&source_, &report_, true/*checksum*/,
initial_offset);
// Read all records from expected_record_offset through the last one.
ASSERT_LT(expected_record_offset, num_initial_offset_records_);
for (; expected_record_offset < num_initial_offset_records_;
++expected_record_offset) {
Slice record;
std::string scratch;
ASSERT_TRUE(offset_reader->ReadRecord(&record, &scratch));
ASSERT_EQ(initial_offset_record_sizes_[expected_record_offset],
record.size());
ASSERT_EQ(initial_offset_last_record_offsets_[expected_record_offset],
offset_reader->LastRecordOffset());
ASSERT_EQ((char)('a' + expected_record_offset), record.data()[0]);
}
delete offset_reader;
}
};
size_t LogTest::initial_offset_record_sizes_[] =
{20000, // Two sizable records in first block
20000,
2 * log::kBlockSize - 1000, // Span three blocks
1,
13716, // Consume all but two bytes of block 3.
log::kBlockSize - kHeaderSize, // Consume the entirety of block 4.
};
uint64_t LogTest::initial_offset_last_record_offsets_[] =
{0,
kHeaderSize + 20000,
2 * (kHeaderSize + 20000),
2 * (kHeaderSize + 20000) +
(2 * log::kBlockSize - 1000) + 3 * kHeaderSize,
2 * (kHeaderSize + 20000) +
(2 * log::kBlockSize - 1000) + 3 * kHeaderSize
+ kHeaderSize + 1,
3 * log::kBlockSize,
};
// LogTest::initial_offset_last_record_offsets_ must be defined before this.
int LogTest::num_initial_offset_records_ =
sizeof(LogTest::initial_offset_last_record_offsets_)/sizeof(uint64_t);
TEST(LogTest, Empty) {
ASSERT_EQ("EOF", Read());
}
TEST(LogTest, ReadWrite) {
Write("foo");
Write("bar");
Write("");
Write("xxxx");
ASSERT_EQ("foo", Read());
ASSERT_EQ("bar", Read());
ASSERT_EQ("", Read());
ASSERT_EQ("xxxx", Read());
ASSERT_EQ("EOF", Read());
ASSERT_EQ("EOF", Read()); // Make sure reads at eof work
}
TEST(LogTest, ManyBlocks) {
for (int i = 0; i < 100000; i++) {
Write(NumberString(i));
}
for (int i = 0; i < 100000; i++) {
ASSERT_EQ(NumberString(i), Read());
}
ASSERT_EQ("EOF", Read());
}
TEST(LogTest, Fragmentation) {
Write("small");
Write(BigString("medium", 50000));
Write(BigString("large", 100000));
ASSERT_EQ("small", Read());
ASSERT_EQ(BigString("medium", 50000), Read());
ASSERT_EQ(BigString("large", 100000), Read());
ASSERT_EQ("EOF", Read());
}
TEST(LogTest, MarginalTrailer) {
// Make a trailer that is exactly the same length as an empty record.
const int n = kBlockSize - 2*kHeaderSize;
Write(BigString("foo", n));
ASSERT_EQ(kBlockSize - kHeaderSize, WrittenBytes());
Write("");
Write("bar");
ASSERT_EQ(BigString("foo", n), Read());
ASSERT_EQ("", Read());
ASSERT_EQ("bar", Read());
ASSERT_EQ("EOF", Read());
}
TEST(LogTest, MarginalTrailer2) {
// Make a trailer that is exactly the same length as an empty record.
const int n = kBlockSize - 2*kHeaderSize;
Write(BigString("foo", n));
ASSERT_EQ(kBlockSize - kHeaderSize, WrittenBytes());
Write("bar");
ASSERT_EQ(BigString("foo", n), Read());
ASSERT_EQ("bar", Read());
ASSERT_EQ("EOF", Read());
ASSERT_EQ(0, DroppedBytes());
ASSERT_EQ("", ReportMessage());
}
TEST(LogTest, ShortTrailer) {
const int n = kBlockSize - 2*kHeaderSize + 4;
Write(BigString("foo", n));
ASSERT_EQ(kBlockSize - kHeaderSize + 4, WrittenBytes());
Write("");
Write("bar");
ASSERT_EQ(BigString("foo", n), Read());
ASSERT_EQ("", Read());
ASSERT_EQ("bar", Read());
ASSERT_EQ("EOF", Read());
}
TEST(LogTest, AlignedEof) {
const int n = kBlockSize - 2*kHeaderSize + 4;
Write(BigString("foo", n));
ASSERT_EQ(kBlockSize - kHeaderSize + 4, WrittenBytes());
ASSERT_EQ(BigString("foo", n), Read());
ASSERT_EQ("EOF", Read());
}
TEST(LogTest, OpenForAppend) {
Write("hello");
ReopenForAppend();
Write("world");
ASSERT_EQ("hello", Read());
ASSERT_EQ("world", Read());
ASSERT_EQ("EOF", Read());
}
TEST(LogTest, RandomRead) {
const int N = 500;
Random write_rnd(301);
for (int i = 0; i < N; i++) {
Write(RandomSkewedString(i, &write_rnd));
}
Random read_rnd(301);
for (int i = 0; i < N; i++) {
ASSERT_EQ(RandomSkewedString(i, &read_rnd), Read());
}
ASSERT_EQ("EOF", Read());
}
// Tests of all the error paths in log_reader.cc follow:
TEST(LogTest, ReadError) {
Write("foo");
ForceError();
ASSERT_EQ("EOF", Read());
ASSERT_EQ(kBlockSize, DroppedBytes());
ASSERT_EQ("OK", MatchError("read error"));
}
TEST(LogTest, BadRecordType) {
Write("foo");
// Type is stored in header[6]
IncrementByte(6, 100);
FixChecksum(0, 3);
ASSERT_EQ("EOF", Read());
ASSERT_EQ(3, DroppedBytes());
ASSERT_EQ("OK", MatchError("unknown record type"));
}
TEST(LogTest, TruncatedTrailingRecordIsIgnored) {
Write("foo");
ShrinkSize(4); // Drop all payload as well as a header byte
ASSERT_EQ("EOF", Read());
// Truncated last record is ignored, not treated as an error.
ASSERT_EQ(0, DroppedBytes());
ASSERT_EQ("", ReportMessage());
}
TEST(LogTest, BadLength) {
const int kPayloadSize = kBlockSize - kHeaderSize;
Write(BigString("bar", kPayloadSize));
Write("foo");
// Least significant size byte is stored in header[4].
IncrementByte(4, 1);
ASSERT_EQ("foo", Read());
ASSERT_EQ(kBlockSize, DroppedBytes());
ASSERT_EQ("OK", MatchError("bad record length"));
}
TEST(LogTest, BadLengthAtEndIsIgnored) {
Write("foo");
ShrinkSize(1);
ASSERT_EQ("EOF", Read());
ASSERT_EQ(0, DroppedBytes());
ASSERT_EQ("", ReportMessage());
}
TEST(LogTest, ChecksumMismatch) {
Write("foo");
IncrementByte(0, 10);
ASSERT_EQ("EOF", Read());
ASSERT_EQ(10, DroppedBytes());
ASSERT_EQ("OK", MatchError("checksum mismatch"));
}
TEST(LogTest, UnexpectedMiddleType) {
Write("foo");
SetByte(6, kMiddleType);
FixChecksum(0, 3);
ASSERT_EQ("EOF", Read());
ASSERT_EQ(3, DroppedBytes());
ASSERT_EQ("OK", MatchError("missing start"));
}
TEST(LogTest, UnexpectedLastType) {
Write("foo");
SetByte(6, kLastType);
FixChecksum(0, 3);
ASSERT_EQ("EOF", Read());
ASSERT_EQ(3, DroppedBytes());
ASSERT_EQ("OK", MatchError("missing start"));
}
TEST(LogTest, UnexpectedFullType) {
Write("foo");
Write("bar");
SetByte(6, kFirstType);
FixChecksum(0, 3);
ASSERT_EQ("bar", Read());
ASSERT_EQ("EOF", Read());
ASSERT_EQ(3, DroppedBytes());
ASSERT_EQ("OK", MatchError("partial record without end"));
}
TEST(LogTest, UnexpectedFirstType) {
Write("foo");
Write(BigString("bar", 100000));
SetByte(6, kFirstType);
FixChecksum(0, 3);
ASSERT_EQ(BigString("bar", 100000), Read());
ASSERT_EQ("EOF", Read());
ASSERT_EQ(3, DroppedBytes());
ASSERT_EQ("OK", MatchError("partial record without end"));
}
TEST(LogTest, MissingLastIsIgnored) {
Write(BigString("bar", kBlockSize));
// Remove the LAST block, including header.
ShrinkSize(14);
ASSERT_EQ("EOF", Read());
ASSERT_EQ("", ReportMessage());
ASSERT_EQ(0, DroppedBytes());
}
TEST(LogTest, PartialLastIsIgnored) {
Write(BigString("bar", kBlockSize));
// Cause a bad record length in the LAST block.
ShrinkSize(1);
ASSERT_EQ("EOF", Read());
ASSERT_EQ("", ReportMessage());
ASSERT_EQ(0, DroppedBytes());
}
TEST(LogTest, SkipIntoMultiRecord) {
// Consider a fragmented record:
// first(R1), middle(R1), last(R1), first(R2)
// If initial_offset points to a record after first(R1) but before first(R2)
// incomplete fragment errors are not actual errors, and must be suppressed
// until a new first or full record is encountered.
Write(BigString("foo", 3*kBlockSize));
Write("correct");
StartReadingAt(kBlockSize);
ASSERT_EQ("correct", Read());
ASSERT_EQ("", ReportMessage());
ASSERT_EQ(0, DroppedBytes());
ASSERT_EQ("EOF", Read());
}
TEST(LogTest, ErrorJoinsRecords) {
// Consider two fragmented records:
// first(R1) last(R1) first(R2) last(R2)
// where the middle two fragments disappear. We do not want
// first(R1),last(R2) to get joined and returned as a valid record.
// Write records that span two blocks
Write(BigString("foo", kBlockSize));
Write(BigString("bar", kBlockSize));
Write("correct");
// Wipe the middle block
for (int offset = kBlockSize; offset < 2*kBlockSize; offset++) {
SetByte(offset, 'x');
}
ASSERT_EQ("correct", Read());
ASSERT_EQ("EOF", Read());
const size_t dropped = DroppedBytes();
ASSERT_LE(dropped, 2*kBlockSize + 100);
ASSERT_GE(dropped, 2*kBlockSize);
}
TEST(LogTest, ReadStart) {
CheckInitialOffsetRecord(0, 0);
}
TEST(LogTest, ReadSecondOneOff) {
CheckInitialOffsetRecord(1, 1);
}
TEST(LogTest, ReadSecondTenThousand) {
CheckInitialOffsetRecord(20000, 1);
}
TEST(LogTest, ReadSecondStart) {
CheckInitialOffsetRecord(10007, 1);
}
TEST(LogTest, ReadThirdOneOff) {
CheckInitialOffsetRecord(10008, 2);
}
TEST(LogTest, ReadThirdStart) {
CheckInitialOffsetRecord(20014, 2);
}
TEST(LogTest, ReadFourthOneOff) {
CheckInitialOffsetRecord(20015, 3);
}
TEST(LogTest, ReadFourthFirstBlockTrailer) {
CheckInitialOffsetRecord(log::kBlockSize - 4, 3);
}
TEST(LogTest, ReadFourthMiddleBlock) {
CheckInitialOffsetRecord(log::kBlockSize + 1, 3);
}
TEST(LogTest, ReadFourthLastBlock) {
CheckInitialOffsetRecord(2 * log::kBlockSize + 1, 3);
}
TEST(LogTest, ReadFourthStart) {
CheckInitialOffsetRecord(
2 * (kHeaderSize + 1000) + (2 * log::kBlockSize - 1000) + 3 * kHeaderSize,
3);
}
TEST(LogTest, ReadInitialOffsetIntoBlockPadding) {
CheckInitialOffsetRecord(3 * log::kBlockSize - 3, 5);
}
TEST(LogTest, ReadEnd) {
CheckOffsetPastEndReturnsNoRecords(0);
}
TEST(LogTest, ReadPastEnd) {
CheckOffsetPastEndReturnsNoRecords(5);
}
} // namespace log
} // namespace leveldb
int main(int argc, char** argv) {
return leveldb::test::RunAllTests();
}
|
/* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#include "tensorflow/core/platform/cloud/file_block_cache.h"
#include <cstring>
#include "tensorflow/core/lib/core/blocking_counter.h"
#include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/platform/cloud/now_seconds_env.h"
#include "tensorflow/core/platform/env.h"
#include "tensorflow/core/platform/notification.h"
#include "tensorflow/core/platform/test.h"
namespace tensorflow {
namespace {
TEST(FileBlockCacheTest, PassThrough) {
const string want_filename = "foo/bar";
const size_t want_offset = 42;
const size_t want_n = 1024;
int calls = 0;
auto fetcher = [&calls, want_filename, want_offset, want_n](
const string& got_filename, size_t got_offset,
size_t got_n, std::vector<char>* out) {
EXPECT_EQ(got_filename, want_filename);
EXPECT_EQ(got_offset, want_offset);
EXPECT_EQ(got_n, want_n);
calls++;
out->resize(got_n, 'x');
return Status::OK();
};
// If block_size, max_bytes, or both are zero, the cache is a pass-through.
FileBlockCache cache1(1, 0, 0, fetcher);
FileBlockCache cache2(0, 1, 0, fetcher);
FileBlockCache cache3(0, 0, 0, fetcher);
std::vector<char> out;
TF_EXPECT_OK(cache1.Read(want_filename, want_offset, want_n, &out));
EXPECT_EQ(calls, 1);
TF_EXPECT_OK(cache2.Read(want_filename, want_offset, want_n, &out));
EXPECT_EQ(calls, 2);
TF_EXPECT_OK(cache3.Read(want_filename, want_offset, want_n, &out));
EXPECT_EQ(calls, 3);
}
TEST(FileBlockCacheTest, BlockAlignment) {
// Initialize a 256-byte buffer. This is the file underlying the reads we'll
// do in this test.
const size_t size = 256;
std::vector<char> buf;
for (int i = 0; i < size; i++) {
buf.push_back(i);
}
// The fetcher just fetches slices of the buffer.
auto fetcher = [&buf](const string& filename, size_t offset, size_t n,
std::vector<char>* out) {
if (offset < buf.size()) {
if (offset + n > buf.size()) {
out->insert(out->end(), buf.begin() + offset, buf.end());
} else {
out->insert(out->end(), buf.begin() + offset, buf.begin() + offset + n);
}
}
return Status::OK();
};
for (size_t block_size = 2; block_size <= 4; block_size++) {
// Make a cache of N-byte block size (1 block) and verify that reads of
// varying offsets and lengths return correct data.
FileBlockCache cache(block_size, block_size, 0, fetcher);
for (size_t offset = 0; offset < 10; offset++) {
for (size_t n = block_size - 2; n <= block_size + 2; n++) {
std::vector<char> got;
TF_EXPECT_OK(cache.Read("", offset, n, &got));
// Verify the size of the read.
if (offset + n <= size) {
// Expect a full read.
EXPECT_EQ(got.size(), n) << "block size = " << block_size
<< ", offset = " << offset << ", n = " << n;
} else {
// Expect a partial read.
EXPECT_EQ(got.size(), size - offset)
<< "block size = " << block_size << ", offset = " << offset
<< ", n = " << n;
}
// Verify the contents of the read.
std::vector<char>::const_iterator begin = buf.begin() + offset;
std::vector<char>::const_iterator end =
offset + n > buf.size() ? buf.end() : begin + n;
std::vector<char> want(begin, end);
EXPECT_EQ(got, want) << "block size = " << block_size
<< ", offset = " << offset << ", n = " << n;
}
}
}
}
TEST(FileBlockCacheTest, CacheHits) {
const size_t block_size = 16;
std::set<size_t> calls;
auto fetcher = [&calls, block_size](const string& filename, size_t offset,
size_t n, std::vector<char>* out) {
EXPECT_EQ(n, block_size);
EXPECT_EQ(offset % block_size, 0);
EXPECT_EQ(calls.find(offset), calls.end()) << "at offset " << offset;
calls.insert(offset);
out->resize(n, 'x');
return Status::OK();
};
const uint32 block_count = 256;
FileBlockCache cache(block_size, block_count * block_size, 0, fetcher);
std::vector<char> out;
// The cache has space for `block_count` blocks. The loop with i = 0 should
// fill the cache, and the loop with i = 1 should be all cache hits. The
// fetcher checks that it is called once and only once for each offset (to
// fetch the corresponding block).
for (int i = 0; i < 2; i++) {
for (int j = 0; j < block_count; j++) {
TF_EXPECT_OK(cache.Read("", block_size * j, block_size, &out));
}
}
}
TEST(FileBlockCacheTest, OutOfRange) {
// Tests reads of a 24-byte file with block size 16.
const size_t block_size = 16;
const size_t file_size = 24;
bool first_block = false;
bool second_block = false;
auto fetcher = [block_size, file_size, &first_block, &second_block](
const string& filename, size_t offset, size_t n,
std::vector<char>* out) {
EXPECT_EQ(n, block_size);
EXPECT_EQ(offset % block_size, 0);
if (offset == 0) {
// The first block (16 bytes) of the file.
out->resize(n, 'x');
first_block = true;
} else if (offset == block_size) {
// The second block (8 bytes) of the file.
out->resize(file_size - block_size, 'x');
second_block = true;
}
return Status::OK();
};
FileBlockCache cache(block_size, block_size, 0, fetcher);
std::vector<char> out;
// Reading the first 16 bytes should be fine.
TF_EXPECT_OK(cache.Read("", 0, block_size, &out));
EXPECT_TRUE(first_block);
EXPECT_EQ(out.size(), block_size);
// Reading at offset file_size + 4 will read the second block (since the read
// at file_size + 4 = 28 will be aligned to an offset of 16) but will return
// OutOfRange because the offset is past the end of the 24-byte file.
Status status = cache.Read("", file_size + 4, 4, &out);
EXPECT_EQ(status.code(), error::OUT_OF_RANGE);
EXPECT_TRUE(second_block);
EXPECT_EQ(out.size(), 0);
// Reading the second full block will return 8 bytes, from a cache hit.
second_block = false;
TF_EXPECT_OK(cache.Read("", block_size, block_size, &out));
EXPECT_FALSE(second_block);
EXPECT_EQ(out.size(), file_size - block_size);
}
TEST(FileBlockCacheTest, Inconsistent) {
// Tests the detection of interrupted reads leading to partially filled blocks
// where we expected complete blocks.
const size_t block_size = 16;
// This fetcher returns OK but only fills in one byte for any offset.
auto fetcher = [block_size](const string& filename, size_t offset, size_t n,
std::vector<char>* out) {
EXPECT_EQ(n, block_size);
EXPECT_EQ(offset % block_size, 0);
out->resize(1, 'x');
return Status::OK();
};
FileBlockCache cache(block_size, 2 * block_size, 0, fetcher);
std::vector<char> out;
// Read the second block; this should yield an OK status and a single byte.
TF_EXPECT_OK(cache.Read("", block_size, block_size, &out));
EXPECT_EQ(out.size(), 1);
// Now read the first block; this should yield an INTERNAL error because we
// had already cached a partial block at a later position.
Status status = cache.Read("", 0, block_size, &out);
EXPECT_EQ(status.code(), error::INTERNAL);
}
TEST(FileBlockCacheTest, LRU) {
const size_t block_size = 16;
std::list<size_t> calls;
auto fetcher = [&calls, block_size](const string& filename, size_t offset,
size_t n, std::vector<char>* out) {
EXPECT_EQ(n, block_size);
EXPECT_FALSE(calls.empty()) << "at offset = " << offset;
if (!calls.empty()) {
EXPECT_EQ(offset, calls.front());
calls.pop_front();
}
out->resize(n, 'x');
return Status::OK();
};
const uint32 block_count = 2;
FileBlockCache cache(block_size, block_count * block_size, 0, fetcher);
std::vector<char> out;
// Read blocks from the cache, and verify the LRU behavior based on the
// fetcher calls that the cache makes.
calls.push_back(0);
// Cache miss - drains an element from `calls`.
TF_EXPECT_OK(cache.Read("", 0, 1, &out));
// Cache hit - does not drain an element from `calls`.
TF_EXPECT_OK(cache.Read("", 0, 1, &out));
calls.push_back(block_size);
// Cache miss followed by cache hit.
TF_EXPECT_OK(cache.Read("", block_size, 1, &out));
TF_EXPECT_OK(cache.Read("", block_size, 1, &out));
calls.push_back(2 * block_size);
// Cache miss followed by cache hit. Causes eviction of LRU element.
TF_EXPECT_OK(cache.Read("", 2 * block_size, 1, &out));
TF_EXPECT_OK(cache.Read("", 2 * block_size, 1, &out));
// LRU element was at offset 0. Cache miss.
calls.push_back(0);
TF_EXPECT_OK(cache.Read("", 0, 1, &out));
// Element at 2 * block_size is still in cache, and this read should update
// its position in the LRU list so it doesn't get evicted by the next read.
TF_EXPECT_OK(cache.Read("", 2 * block_size, 1, &out));
// Element at block_size was evicted. Reading this element will also cause
// the LRU element (at 0) to be evicted.
calls.push_back(block_size);
TF_EXPECT_OK(cache.Read("", block_size, 1, &out));
// Element at 0 was evicted again.
calls.push_back(0);
TF_EXPECT_OK(cache.Read("", 0, 1, &out));
}
TEST(FileBlockCacheTest, MaxStaleness) {
int calls = 0;
auto fetcher = [&calls](const string& filename, size_t offset, size_t n,
std::vector<char>* out) {
calls++;
out->resize(n, 'x');
return Status::OK();
};
std::vector<char> out;
std::unique_ptr<NowSecondsEnv> env(new NowSecondsEnv);
// Create a cache with max staleness of 2 seconds, and verify that it works as
// expected.
FileBlockCache cache1(8, 16, 2 /* max staleness */, fetcher, env.get());
// Execute the first read to load the block.
TF_EXPECT_OK(cache1.Read("", 0, 1, &out));
EXPECT_EQ(calls, 1);
// Now advance the clock one second at a time and redo the read. The call
// count should advance every 3 seconds (i.e. every time the staleness is
// greater than 2).
for (int i = 1; i <= 10; i++) {
env->SetNowSeconds(i + 1);
TF_EXPECT_OK(cache1.Read("", 0, 1, &out));
EXPECT_EQ(calls, 1 + i / 3);
}
// Now create a cache with max staleness of 0, and verify that it also works
// as expected.
calls = 0;
env->SetNowSeconds(0);
FileBlockCache cache2(8, 16, 0 /* max staleness */, fetcher, env.get());
// Execute the first read to load the block.
TF_EXPECT_OK(cache2.Read("", 0, 1, &out));
EXPECT_EQ(calls, 1);
// Advance the clock by a huge amount and verify that the cached block is
// used to satisfy the read.
env->SetNowSeconds(365 * 24 * 60 * 60); // ~1 year, just for fun.
TF_EXPECT_OK(cache2.Read("", 0, 1, &out));
EXPECT_EQ(calls, 1);
}
TEST(FileBlockCacheTest, RemoveFile) {
int calls = 0;
auto fetcher = [&calls](const string& filename, size_t offset, size_t n,
std::vector<char>* out) {
calls++;
char c = (filename == "a") ? 'a' : (filename == "b") ? 'b' : 'x';
if (offset > 0) {
// The first block is lower case and all subsequent blocks are upper case.
c = toupper(c);
}
out->clear();
out->resize(n, c);
return Status::OK();
};
// This cache has space for 4 blocks; we'll read from two files.
const size_t n = 3;
FileBlockCache cache(8, 32, 0, fetcher);
std::vector<char> out;
std::vector<char> a(n, 'a');
std::vector<char> b(n, 'b');
std::vector<char> A(n, 'A');
std::vector<char> B(n, 'B');
// Fill the cache.
TF_EXPECT_OK(cache.Read("a", 0, n, &out));
EXPECT_EQ(out, a);
EXPECT_EQ(calls, 1);
TF_EXPECT_OK(cache.Read("a", 8, n, &out));
EXPECT_EQ(out, A);
EXPECT_EQ(calls, 2);
TF_EXPECT_OK(cache.Read("b", 0, n, &out));
EXPECT_EQ(out, b);
EXPECT_EQ(calls, 3);
TF_EXPECT_OK(cache.Read("b", 8, n, &out));
EXPECT_EQ(out, B);
EXPECT_EQ(calls, 4);
// All four blocks should be in the cache now.
TF_EXPECT_OK(cache.Read("a", 0, n, &out));
EXPECT_EQ(out, a);
TF_EXPECT_OK(cache.Read("a", 8, n, &out));
EXPECT_EQ(out, A);
TF_EXPECT_OK(cache.Read("b", 0, n, &out));
EXPECT_EQ(out, b);
TF_EXPECT_OK(cache.Read("b", 8, n, &out));
EXPECT_EQ(out, B);
EXPECT_EQ(calls, 4);
// Remove the blocks from "a".
cache.RemoveFile("a");
// Both blocks from "b" should still be there.
TF_EXPECT_OK(cache.Read("b", 0, n, &out));
EXPECT_EQ(out, b);
TF_EXPECT_OK(cache.Read("b", 8, n, &out));
EXPECT_EQ(out, B);
EXPECT_EQ(calls, 4);
// The blocks from "a" should not be there.
TF_EXPECT_OK(cache.Read("a", 0, n, &out));
EXPECT_EQ(out, a);
EXPECT_EQ(calls, 5);
TF_EXPECT_OK(cache.Read("a", 8, n, &out));
EXPECT_EQ(out, A);
EXPECT_EQ(calls, 6);
}
TEST(FileBlockCacheTest, Prune) {
int calls = 0;
auto fetcher = [&calls](const string& filename, size_t offset, size_t n,
std::vector<char>* out) {
calls++;
out->clear();
out->resize(n, 'x');
return Status::OK();
};
std::vector<char> out;
// Our fake environment is initialized with the current timestamp.
std::unique_ptr<NowSecondsEnv> env(new NowSecondsEnv);
uint64 now = Env::Default()->NowSeconds();
env->SetNowSeconds(now);
FileBlockCache cache(8, 32, 1 /* max staleness */, fetcher, env.get());
// Read three blocks into the cache, and advance the timestamp by one second
// with each read. Start with a block of "a" at the current timestamp `now`.
TF_EXPECT_OK(cache.Read("a", 0, 1, &out));
// Now load a block of a different file "b" at timestamp `now` + 1
env->SetNowSeconds(now + 1);
TF_EXPECT_OK(cache.Read("b", 0, 1, &out));
// Now load a different block of file "a" at timestamp `now` + 1. When the
// first block of "a" expires, this block should also be removed because it
// also belongs to file "a".
TF_EXPECT_OK(cache.Read("a", 8, 1, &out));
// Ensure that all blocks are in the cache (i.e. reads are cache hits).
EXPECT_EQ(cache.CacheSize(), 24);
EXPECT_EQ(calls, 3);
TF_EXPECT_OK(cache.Read("a", 0, 1, &out));
TF_EXPECT_OK(cache.Read("b", 0, 1, &out));
TF_EXPECT_OK(cache.Read("a", 8, 1, &out));
EXPECT_EQ(calls, 3);
// Advance the fake timestamp so that "a" becomes stale via its first block.
env->SetNowSeconds(now + 2);
// The pruning thread periodically compares env->NowSeconds() with the oldest
// block's timestamp to see if it should evict any files. At the current fake
// timestamp of `now` + 2, file "a" is stale because its first block is stale,
// but file "b" is not stale yet. Thus, once the pruning thread wakes up (in
// one second of wall time), it should remove "a" and leave "b" alone.
uint64 start = Env::Default()->NowSeconds();
do {
Env::Default()->SleepForMicroseconds(100000);
} while (cache.CacheSize() == 24 && Env::Default()->NowSeconds() - start < 3);
// There should be one block left in the cache, and it should be the first
// block of "b".
EXPECT_EQ(cache.CacheSize(), 8);
TF_EXPECT_OK(cache.Read("b", 0, 1, &out));
EXPECT_EQ(calls, 3);
// Advance the fake time to `now` + 3, at which point "b" becomes stale.
env->SetNowSeconds(now + 3);
// Wait for the pruner to remove "b".
start = Env::Default()->NowSeconds();
do {
Env::Default()->SleepForMicroseconds(100000);
} while (cache.CacheSize() == 8 && Env::Default()->NowSeconds() - start < 3);
// The cache should now be empty.
EXPECT_EQ(cache.CacheSize(), 0);
}
TEST(FileBlockCacheTest, ParallelReads) {
// This fetcher won't respond until either `callers` threads are calling it
// concurrently (at which point it will respond with success to all callers),
// or 10 seconds have elapsed (at which point it will respond with an error).
const int callers = 4;
BlockingCounter counter(callers);
auto fetcher = [&counter](const string& filename, size_t offset, size_t n,
std::vector<char>* out) {
counter.DecrementCount();
if (!counter.WaitFor(std::chrono::seconds(10))) {
// This avoids having the test time out, which is harder to debug.
return errors::FailedPrecondition("desired concurrency not reached");
}
out->clear();
out->resize(n, 'x');
return Status::OK();
};
const int block_size = 8;
FileBlockCache cache(block_size, 2 * callers * block_size, 0, fetcher);
std::vector<std::unique_ptr<Thread>> threads;
for (int i = 0; i < callers; i++) {
threads.emplace_back(
Env::Default()->StartThread({}, "caller", [&cache, i, block_size]() {
std::vector<char> out;
TF_EXPECT_OK(cache.Read("a", i * block_size, block_size, &out));
std::vector<char> x(block_size, 'x');
EXPECT_EQ(out, x);
}));
}
// The `threads` destructor blocks until the threads can be joined, once their
// respective reads finish (which happens once they are all concurrently being
// executed, or 10 seconds have passed).
}
TEST(FileBlockCacheTest, CoalesceConcurrentReads) {
// Concurrent reads to the same file blocks should be de-duplicated.
const size_t block_size = 16;
int num_requests = 0;
Notification notification;
auto fetcher = [&num_requests, ¬ification, block_size](
const string& filename, size_t offset, size_t n,
std::vector<char>* out) {
EXPECT_EQ(n, block_size);
EXPECT_EQ(offset, 0);
num_requests++;
out->resize(n, 'x');
notification.Notify();
// Wait for other thread to issue read.
Env::Default()->SleepForMicroseconds(100000); // 0.1 secs
return Status::OK();
};
FileBlockCache cache(block_size, block_size, 0, fetcher);
// Fork off thread for parallel read.
std::unique_ptr<Thread> concurrent(
Env::Default()->StartThread({}, "concurrent", [&cache] {
std::vector<char> out;
TF_EXPECT_OK(cache.Read("", 0, block_size / 2, &out));
EXPECT_EQ(out.size(), block_size / 2);
}));
EXPECT_TRUE(WaitForNotificationWithTimeout(¬ification, 10000))
<< "Timeout waiting for concurrent thread to start.";
std::vector<char> out;
TF_EXPECT_OK(cache.Read("", block_size / 2, block_size / 2, &out));
EXPECT_EQ(out.size(), block_size / 2);
EXPECT_EQ(1, num_requests);
}
} // namespace
} // namespace tensorflow
|
.global s_prepare_buffers
s_prepare_buffers:
push %r13
push %r15
push %rax
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x18d1f, %rsi
lea addresses_D_ht+0xf697, %rdi
and $1717, %rax
mov $72, %rcx
rep movsb
nop
nop
cmp $38080, %r13
lea addresses_UC_ht+0x18707, %rbp
nop
cmp %r15, %r15
mov $0x6162636465666768, %rcx
movq %rcx, (%rbp)
nop
nop
xor $17589, %rax
lea addresses_D_ht+0x45b7, %rdi
nop
nop
and %r15, %r15
mov (%rdi), %rbp
nop
nop
nop
nop
dec %rbp
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r15
pop %r13
ret
.global s_faulty_load
s_faulty_load:
push %r15
push %r8
push %r9
push %rax
push %rbx
push %rdi
push %rdx
// Store
lea addresses_WT+0x19b1f, %rdx
nop
nop
nop
nop
cmp %rax, %rax
movl $0x51525354, (%rdx)
nop
nop
nop
add $16800, %rdi
// Store
lea addresses_normal+0x1fd27, %r15
nop
nop
lfence
mov $0x5152535455565758, %r9
movq %r9, %xmm0
vmovups %ymm0, (%r15)
nop
nop
nop
nop
and %rdi, %rdi
// Store
mov $0x687, %rax
nop
nop
nop
nop
nop
and %rdi, %rdi
mov $0x5152535455565758, %r15
movq %r15, (%rax)
cmp %rdx, %rdx
// Store
lea addresses_RW+0x17e07, %r8
nop
nop
nop
nop
sub $20217, %rdi
mov $0x5152535455565758, %rbx
movq %rbx, %xmm3
movups %xmm3, (%r8)
nop
cmp %r15, %r15
// Faulty Load
lea addresses_A+0x1ebb7, %r15
nop
sub $51738, %r8
movntdqa (%r15), %xmm6
vpextrq $0, %xmm6, %rdi
lea oracles, %r15
and $0xff, %rdi
shlq $12, %rdi
mov (%r15,%rdi,1), %rdi
pop %rdx
pop %rdi
pop %rbx
pop %rax
pop %r9
pop %r8
pop %r15
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_WT', 'size': 4, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_normal', 'size': 32, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_P', 'size': 8, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_RW', 'size': 16, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': True, 'type': 'addresses_A', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_normal_ht', 'congruent': 3, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_UC_ht', 'size': 8, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_D_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
{'00': 21829}
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*/
|
frame 1, 08
frame 0, 08
frame 1, 08
endanim |
/*This file is part of the FEBio source code and is licensed under the MIT license
listed below.
See Copyright-FEBio.txt for details.
Copyright (c) 2019 University of Utah, The Trustees of Columbia University in
the City of New York, and others.
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.*/
#include "stdafx.h"
#include "FECarterHayes.h"
#include "FEMultiphasic.h"
//-----------------------------------------------------------------------------
// define the material parameters
BEGIN_PARAMETER_LIST(FECarterHayes, FEElasticMaterial)
ADD_PARAMETER2(m_E0 , FE_PARAM_DOUBLE, FE_RANGE_GREATER(0.0) , "E0" );
ADD_PARAMETER2(m_rho0, FE_PARAM_DOUBLE, FE_RANGE_GREATER(0.0) , "rho0" );
ADD_PARAMETER2(m_g , FE_PARAM_DOUBLE, FE_RANGE_GREATER_OR_EQUAL(0.0), "gamma");
ADD_PARAMETER2(m_v , FE_PARAM_DOUBLE, FE_RANGE_RIGHT_OPEN(-1.0, 0.5), "v" );
ADD_PARAMETER(m_sbm, FE_PARAM_INT, "sbm");
END_PARAMETER_LIST();
//-----------------------------------------------------------------------------
bool FECarterHayes::Init()
{
if (FEElasticMaterial::Init() == false) return false;
// get the parent material which must be a multiphasic material
FEMultiphasic* pMP = dynamic_cast<FEMultiphasic*> (GetParent());
if (pMP == 0) return MaterialError("Parent material must be multiphasic");
// extract the local id of the SBM whose density controls Young's modulus from the global id
m_lsbm = pMP->FindLocalSBMID(m_sbm);
if (m_lsbm == -1) return MaterialError("Invalid value for sbm");
return true;
}
//-----------------------------------------------------------------------------
void FECarterHayes::Serialize(DumpStream& ar)
{
FEElasticMaterial::Serialize(ar);
if (ar.IsShallow() == false)
{
if (ar.IsSaving())
{
ar << m_lsbm;
}
else
{
ar >> m_lsbm;
}
}
}
//-----------------------------------------------------------------------------
//! Create material point data
FEMaterialPoint* FECarterHayes::CreateMaterialPointData()
{
return new FERemodelingMaterialPoint(new FEElasticMaterialPoint);
}
//-----------------------------------------------------------------------------
double FECarterHayes::StrainEnergy(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
FESolutesMaterialPoint& spt = *mp.ExtractData<FESolutesMaterialPoint>();
double detF = pt.m_J;
double lndetF = log(detF);
// calculate left Cauchy-Green tensor
mat3ds b = pt.LeftCauchyGreen();
double I1 = b.tr();
// lame parameters
double rhor = spt.m_sbmr[m_lsbm];
double m_E = YoungModulus(rhor);
double lam = m_v*m_E/((1+m_v)*(1-2*m_v));
double mu = 0.5*m_E/(1+m_v);
double sed = mu*((I1-3)/2 - lndetF)+lam*lndetF*lndetF/2;
return sed;
}
//-----------------------------------------------------------------------------
mat3ds FECarterHayes::Stress(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
FESolutesMaterialPoint& spt = *mp.ExtractData<FESolutesMaterialPoint>();
double detF = pt.m_J;
double detFi = 1.0/detF;
double lndetF = log(detF);
// evaluate the strain energy
FERemodelingMaterialPoint& rpt = *mp.ExtractData<FERemodelingMaterialPoint>();
rpt.m_sed = StrainEnergy(mp);
// calculate left Cauchy-Green tensor
mat3ds b = pt.LeftCauchyGreen();
// lame parameters
double rhor = spt.m_sbmr[m_lsbm];
double m_E = YoungModulus(rhor);
double lam = m_v*m_E/((1+m_v)*(1-2*m_v));
double mu = 0.5*m_E/(1+m_v);
// Identity
mat3dd I(1);
// calculate stress
mat3ds s = (b - I)*(mu*detFi) + I*(lam*lndetF*detFi);
return s;
}
//-----------------------------------------------------------------------------
tens4ds FECarterHayes::Tangent(FEMaterialPoint& mp)
{
FEElasticMaterialPoint& pt = *mp.ExtractData<FEElasticMaterialPoint>();
FESolutesMaterialPoint& spt = *mp.ExtractData<FESolutesMaterialPoint>();
// deformation gradient
double detF = pt.m_J;
// lame parameters
double rhor = spt.m_sbmr[m_lsbm];
double m_E = YoungModulus(rhor);
double lam = m_v*m_E/((1+m_v)*(1-2*m_v));
double mu = 0.5*m_E/(1+m_v);
double lam1 = lam / detF;
double mu1 = (mu - lam*log(detF)) / detF;
double D[6][6] = {0};
D[0][0] = lam1+2.*mu1; D[0][1] = lam1 ; D[0][2] = lam1 ;
D[1][0] = lam1 ; D[1][1] = lam1+2.*mu1; D[1][2] = lam1 ;
D[2][0] = lam1 ; D[2][1] = lam1 ; D[2][2] = lam1+2.*mu1;
D[3][3] = mu1;
D[4][4] = mu1;
D[5][5] = mu1;
return tens4ds(D);
}
//-----------------------------------------------------------------------------
//! calculate tangent of strain energy density with mass density
double FECarterHayes::Tangent_SE_Density(FEMaterialPoint& mp)
{
FESolutesMaterialPoint& spt = *mp.ExtractData<FESolutesMaterialPoint>();
double rhor = spt.m_sbmr[m_lsbm];
return StrainEnergy(mp)*m_g/rhor;
}
//-----------------------------------------------------------------------------
//! calculate tangent of stress with mass density
mat3ds FECarterHayes::Tangent_Stress_Density(FEMaterialPoint& mp)
{
FESolutesMaterialPoint& spt = *mp.ExtractData<FESolutesMaterialPoint>();
double rhor = spt.m_sbmr[m_lsbm];
return Stress(mp)*m_g/rhor;
}
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r14
push %r9
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x4705, %r12
nop
nop
nop
and $32944, %r14
mov (%r12), %si
nop
nop
nop
nop
and $65238, %rbx
lea addresses_normal_ht+0xed05, %rsi
clflush (%rsi)
nop
nop
nop
nop
sub %rbx, %rbx
movb $0x61, (%rsi)
add $58677, %rbx
lea addresses_WT_ht+0x1ab05, %rsi
lea addresses_UC_ht+0x3be5, %rdi
nop
nop
nop
nop
add %rbx, %rbx
mov $97, %rcx
rep movsw
nop
nop
nop
nop
nop
sub %rdi, %rdi
lea addresses_WT_ht+0x9d05, %r14
cmp %r12, %r12
mov $0x6162636465666768, %rcx
movq %rcx, %xmm6
movups %xmm6, (%r14)
nop
nop
nop
cmp %rcx, %rcx
lea addresses_WT_ht+0x17f05, %r14
nop
inc %rsi
mov $0x6162636465666768, %rdi
movq %rdi, %xmm7
vmovups %ymm7, (%r14)
nop
nop
nop
add $13472, %r12
lea addresses_WT_ht+0x1b1dd, %r12
nop
nop
nop
nop
nop
and $27621, %rsi
movb (%r12), %r14b
nop
nop
nop
nop
nop
dec %r9
lea addresses_D_ht+0x17685, %rsi
lea addresses_D_ht+0xff05, %rdi
nop
and $49590, %r14
mov $26, %rcx
rep movsl
nop
cmp $56567, %rdi
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %r9
pop %r14
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r11
push %rbp
push %rcx
push %rdi
push %rdx
push %rsi
// REPMOV
lea addresses_normal+0x11305, %rsi
lea addresses_normal+0x11305, %rdi
nop
add $17382, %rbp
mov $102, %rcx
rep movsq
nop
xor %rbp, %rbp
// Store
lea addresses_normal+0x9be5, %rbp
nop
nop
nop
nop
nop
and %rdx, %rdx
mov $0x5152535455565758, %r10
movq %r10, %xmm1
movups %xmm1, (%rbp)
nop
nop
nop
add %rsi, %rsi
// Store
lea addresses_normal+0x11305, %rsi
nop
nop
nop
and %r11, %r11
movb $0x51, (%rsi)
nop
nop
nop
nop
and $18485, %r10
// Store
mov $0x403, %rcx
nop
nop
nop
nop
nop
add $9671, %rdi
movw $0x5152, (%rcx)
nop
nop
nop
add %r10, %r10
// Store
lea addresses_UC+0x190d, %rsi
nop
sub %rcx, %rcx
movl $0x51525354, (%rsi)
nop
nop
nop
nop
nop
and %r10, %r10
// Faulty Load
lea addresses_normal+0x11305, %r10
nop
nop
nop
cmp $58009, %rbp
vmovups (%r10), %ymm3
vextracti128 $0, %ymm3, %xmm3
vpextrq $0, %xmm3, %rdx
lea oracles, %rdi
and $0xff, %rdx
shlq $12, %rdx
mov (%rdi,%rdx,1), %rdx
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %r11
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_normal', 'congruent': 0, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_normal', 'congruent': 0, 'same': True}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_normal', 'size': 16, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 1, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_P', 'size': 2, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_UC', 'size': 4, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_normal', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'same': False, 'congruent': 10, 'NT': True, 'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False}}
{'src': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 5, 'same': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False}}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 5, 'same': True}}
{'51': 21829}
51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51
*/
|
<%
from pwnlib.shellcraft.aarch64.linux import syscall
%>
<%page args="oldfd, old, newfd, new"/>
<%docstring>
Invokes the syscall renameat. See 'man 2 renameat' for more information.
Arguments:
oldfd(int): oldfd
old(char): old
newfd(int): newfd
new(char): new
</%docstring>
${syscall('SYS_renameat', oldfd, old, newfd, new)}
|
; Listing generated by Microsoft (R) Optimizing Compiler Version 16.00.40219.01
TITLE D:\Projects\TaintAnalysis\AntiTaint\Epilog\src\struct-align.c
.686P
.XMM
include listing.inc
.model flat
INCLUDELIB MSVCRT
INCLUDELIB OLDNAMES
_DATA SEGMENT
$SG3571 DB '%d %d %d', 00H
ORG $+3
$SG3580 DB '%s %d %d %d', 0aH, 00H
_DATA ENDS
PUBLIC _fill
EXTRN __imp__scanf:PROC
; Function compile flags: /Odtpy
; File d:\projects\taintanalysis\antitaint\epilog\src\struct-align.c
_TEXT SEGMENT
_c$ = -12 ; size = 4
_b$ = -8 ; size = 4
_a$ = -4 ; size = 4
_s$ = 8 ; size = 4
_fill PROC
; 21 : {
push ebp
mov ebp, esp
sub esp, 12 ; 0000000cH
; 22 : int a, b, c;
; 23 : scanf("%d %d %d", &a, &b, &c);
lea eax, DWORD PTR _c$[ebp]
push eax
lea ecx, DWORD PTR _b$[ebp]
push ecx
lea edx, DWORD PTR _a$[ebp]
push edx
push OFFSET $SG3571
call DWORD PTR __imp__scanf
add esp, 16 ; 00000010H
; 24 : s->a = a;
mov eax, DWORD PTR _a$[ebp]
cdq
mov ecx, DWORD PTR _s$[ebp]
mov DWORD PTR [ecx], eax
mov DWORD PTR [ecx+4], edx
; 25 : s->b = b;
mov eax, DWORD PTR _b$[ebp]
cdq
mov ecx, DWORD PTR _s$[ebp]
mov DWORD PTR [ecx+8], eax
mov DWORD PTR [ecx+12], edx
; 26 : s->c = c;
mov eax, DWORD PTR _c$[ebp]
cdq
mov ecx, DWORD PTR _s$[ebp]
mov DWORD PTR [ecx+16], eax
mov DWORD PTR [ecx+20], edx
; 27 : }
mov esp, ebp
pop ebp
ret 0
_fill ENDP
_TEXT ENDS
PUBLIC _func
EXTRN __imp__printf:PROC
EXTRN __imp__gets:PROC
; Function compile flags: /Odtpy
_TEXT SEGMENT
_s$ = -64 ; size = 32
_buf$ = -8 ; size = 8
_func PROC
; 30 : {
push ebp
mov ebp, esp
and esp, -32 ; ffffffe0H
sub esp, 64 ; 00000040H
; 31 : struct S s;
; 32 : char buf[8];
; 33 : gets(buf);
lea eax, DWORD PTR _buf$[esp+64]
push eax
call DWORD PTR __imp__gets
add esp, 4
; 34 : fill(&s);
lea ecx, DWORD PTR _s$[esp+64]
push ecx
call _fill
add esp, 4
; 35 : printf("%s %d %d %d\n", buf, (int)s.a, (int)s.b, (int)s.c);
mov edx, DWORD PTR _s$[esp+80]
push edx
mov eax, DWORD PTR _s$[esp+76]
push eax
mov ecx, DWORD PTR _s$[esp+72]
push ecx
lea edx, DWORD PTR _buf$[esp+76]
push edx
push OFFSET $SG3580
call DWORD PTR __imp__printf
add esp, 20 ; 00000014H
; 36 : }
mov esp, ebp
pop ebp
ret 0
_func ENDP
_TEXT ENDS
PUBLIC _main
; Function compile flags: /Odtpy
_TEXT SEGMENT
_main PROC
; 39 : {
push ebp
mov ebp, esp
; 40 : func();
call _func
; 41 : return 0;
xor eax, eax
; 42 : }
pop ebp
ret 0
_main ENDP
_TEXT ENDS
END
|
leaw $R0,%A
movw (%A),%D
leaw $R3,%A
movw %D,(%A) ;valor R0 salvo em R3.
leaw $R1,%A
movw (%A),%D ; d com valor de R1
leaw $R4,%A
movw %D,(%A) ; R1 em R4
while1:
leaw $R3, %A
movw (%A),%D
leaw $R4, %A
subw %D,(%A),%S
leaw $R3,%A
movw %S,(%A)
leaw $R5,%A
movw (%A),%D
incw %D
leaw $R5,%A
movw %D,(%A)
leaw $RESULT0,%A
je %S
nop
leaw $RESULTNEG,%A
jl %S
nop
leaw $while1,%A
jmp
nop
RESULTNEG:
leaw $R2,%A
subw %D,$1,%S
movw %S,(%A)
leaw $END,%A
jmp
nop
RESULT0:
leaw $R2,%A
movw %D,(%A)
END:
nop |
; A128054: Count, omitting numbers of the form 6k+4 and doubling multiples of 6.
; 0,0,1,2,3,5,6,6,7,8,9,11,12,12,13,14,15,17,18,18,19,20,21,23,24,24,25,26,27,29,30,30,31,32,33,35,36,36,37,38,39,41,42,42,43,44,45,47,48,48,49,50,51,53,54,54,55,56,57,59,60,60,61,62,63,65,66,66
trn $0,1
lpb $0,1
add $1,$0
mod $0,6
div $0,4
lpe
|
; A230774: Number of primes less than first prime above square root of n.
; 1,1,1,1,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5
seq $0,196 ; Integer part of square root of n. Or, number of positive squares <= n. Or, n appears 2n+1 times.
seq $0,230980 ; Number of primes <= n, starting at n=0.
add $0,1
|
0x0a, 0x0a, 0x2f, 0x2f, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
0x3d, 0x3d, 0x0a, 0x2f, 0x2f, 0x20, 0x42, 0x6c, 0x75, 0x72, 0x73, 0x0a, 0x0a, 0x2f, 0x2a, 0x2a,
0x0a, 0x20, 0x2a, 0x20, 0xe5, 0x91, 0xa8, 0xe8, 0xbe, 0xba, 0x20, 0x35, 0x2a, 0x35, 0x20, 0xe3,
0x83, 0x94, 0xe3, 0x82, 0xaf, 0xe3, 0x82, 0xbb, 0xe3, 0x83, 0xab, 0xe3, 0x81, 0xae, 0xe5, 0xb9,
0xb3, 0xe5, 0x9d, 0x87, 0xe3, 0x81, 0xa7, 0xe8, 0xa8, 0x88, 0xe7, 0xae, 0x97, 0xe3, 0x81, 0x99,
0xe3, 0x82, 0x8b, 0xe3, 0x83, 0x96, 0xe3, 0x83, 0xa9, 0xe3, 0x83, 0xbc, 0xe9, 0x96, 0xa2, 0xe6,
0x95, 0xb0, 0xe3, 0x81, 0xa7, 0xe3, 0x81, 0x99, 0xe3, 0x80, 0x82, 0x0a, 0x20, 0x2a, 0x2f, 0x0a,
0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x4c, 0x4e, 0x5f, 0x41, 0x76, 0x65, 0x72, 0x61, 0x67,
0x65, 0x42, 0x6c, 0x75, 0x72, 0x35, 0x78, 0x35, 0x28, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72,
0x32, 0x44, 0x20, 0x73, 0x2c, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x69, 0x6e, 0x76,
0x53, 0x69, 0x7a, 0x65, 0x2c, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x75, 0x76, 0x29,
0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x74, 0x65,
0x78, 0x65, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x20, 0x3d, 0x20, 0x69, 0x6e, 0x76, 0x53, 0x69, 0x7a,
0x65, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x72, 0x65,
0x73, 0x75, 0x6c, 0x74, 0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x28, 0x30, 0x2e,
0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30,
0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x28, 0x69, 0x6e, 0x74,
0x20, 0x69, 0x3d, 0x2d, 0x32, 0x3b, 0x20, 0x69, 0x3c, 0x3d, 0x32, 0x3b, 0x20, 0x69, 0x2b, 0x2b,
0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x72, 0x20,
0x28, 0x69, 0x6e, 0x74, 0x20, 0x6a, 0x3d, 0x2d, 0x32, 0x3b, 0x20, 0x6a, 0x3c, 0x3d, 0x32, 0x3b,
0x20, 0x6a, 0x2b, 0x2b, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65,
0x74, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x28, 0x66, 0x6c, 0x6f,
0x61, 0x74, 0x28, 0x69, 0x29, 0x2c, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x28, 0x6a, 0x29, 0x29, 0x29,
0x2a, 0x74, 0x65, 0x78, 0x65, 0x6c, 0x53, 0x69, 0x7a, 0x65, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20,
0x2b, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x32, 0x44, 0x28, 0x73, 0x2c, 0x20, 0x75, 0x76, 0x20, 0x2b,
0x20, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x7d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72,
0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x20, 0x2f, 0x20, 0x28,
0x35, 0x2e, 0x30, 0x2a, 0x35, 0x2e, 0x30, 0x29, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x2f, 0x2a, 0x2a,
0x0a, 0x20, 0x2a, 0x20, 0x35, 0x20, 0xe7, 0x82, 0xb9, 0xe3, 0x82, 0xb5, 0xe3, 0x83, 0xb3, 0xe3,
0x83, 0x97, 0xe3, 0x83, 0xaa, 0xe3, 0x83, 0xb3, 0xe3, 0x82, 0xb0, 0xe3, 0x81, 0xae, 0xe3, 0x82,
0xb7, 0xe3, 0x83, 0xb3, 0xe3, 0x83, 0x97, 0xe3, 0x83, 0xab, 0xe3, 0x81, 0xaa, 0xe3, 0x82, 0xac,
0xe3, 0x82, 0xa6, 0xe3, 0x82, 0xb9, 0xe3, 0x83, 0x96, 0xe3, 0x83, 0xa9, 0xe3, 0x83, 0xbc, 0xe9,
0x96, 0xa2, 0xe6, 0x95, 0xb0, 0xe3, 0x81, 0xa7, 0xe3, 0x81, 0x99, 0xe3, 0x80, 0x82, 0x0a, 0x20,
0x2a, 0x0a, 0x20, 0x2a, 0x20, 0x75, 0x76, 0x20, 0xe3, 0x81, 0xa7, 0xe6, 0x8c, 0x87, 0xe5, 0xae,
0x9a, 0xe3, 0x81, 0x97, 0xe3, 0x81, 0x9f, 0xe4, 0xb8, 0xad, 0xe5, 0xbf, 0x83, 0xe7, 0x82, 0xb9,
0xe3, 0x81, 0xae, 0x20, 0x31, 0x20, 0xe7, 0x82, 0xb9, 0xe3, 0x80, 0x82, 0x0a, 0x20, 0x2a, 0x20,
0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x70, 0x78, 0x20, 0xe5, 0x8d, 0x98,
0xe4, 0xbd, 0x8d, 0x29, 0x20, 0xe6, 0x96, 0xb9, 0xe5, 0x90, 0x91, 0xe3, 0x81, 0xa8, 0xe3, 0x80,
0x81, 0xe3, 0x81, 0x9d, 0xe3, 0x81, 0xae, 0xe9, 0x80, 0x86, 0xe6, 0x96, 0xb9, 0xe5, 0x90, 0x91,
0xe3, 0x81, 0xab, 0x20, 0x32, 0x20, 0xe7, 0x82, 0xb9, 0xe3, 0x81, 0x9a, 0xe3, 0x81, 0xa4, 0xe3,
0x80, 0x82, 0x0a, 0x20, 0x2a, 0x2f, 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x4c, 0x4e,
0x5f, 0x47, 0x61, 0x75, 0x73, 0x73, 0x69, 0x61, 0x6e, 0x42, 0x6c, 0x75, 0x72, 0x35, 0x28, 0x73,
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x73, 0x2c, 0x20, 0x66, 0x6c, 0x6f, 0x61,
0x74, 0x32, 0x20, 0x69, 0x6e, 0x76, 0x53, 0x69, 0x7a, 0x65, 0x2c, 0x20, 0x66, 0x6c, 0x6f, 0x61,
0x74, 0x32, 0x20, 0x75, 0x76, 0x2c, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x64, 0x69,
0x72, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66,
0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x66, 0x6c,
0x6f, 0x61, 0x74, 0x34, 0x28, 0x30, 0x2c, 0x20, 0x30, 0x2c, 0x20, 0x30, 0x2c, 0x20, 0x30, 0x29,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x6f, 0x66, 0x66,
0x31, 0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x28, 0x31, 0x2e, 0x33, 0x38, 0x34,
0x36, 0x31, 0x35, 0x33, 0x38, 0x34, 0x36, 0x2c, 0x20, 0x31, 0x2e, 0x33, 0x38, 0x34, 0x36, 0x31,
0x35, 0x33, 0x38, 0x34, 0x36, 0x29, 0x20, 0x2a, 0x20, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69,
0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x6f,
0x66, 0x66, 0x32, 0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x28, 0x33, 0x2e, 0x32,
0x33, 0x30, 0x37, 0x36, 0x39, 0x32, 0x33, 0x30, 0x38, 0x2c, 0x20, 0x33, 0x2e, 0x32, 0x33, 0x30,
0x37, 0x36, 0x39, 0x32, 0x33, 0x30, 0x38, 0x29, 0x20, 0x2a, 0x20, 0x64, 0x69, 0x72, 0x65, 0x63,
0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20,
0x2b, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x32, 0x44, 0x28, 0x73, 0x2c, 0x20, 0x75, 0x76, 0x29, 0x20,
0x2a, 0x20, 0x30, 0x2e, 0x32, 0x32, 0x37, 0x30, 0x32, 0x37, 0x30, 0x32, 0x37, 0x30, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x2b, 0x3d, 0x20, 0x74, 0x65, 0x78,
0x32, 0x44, 0x28, 0x73, 0x2c, 0x20, 0x75, 0x76, 0x20, 0x2b, 0x20, 0x28, 0x6f, 0x66, 0x66, 0x31,
0x20, 0x2a, 0x20, 0x69, 0x6e, 0x76, 0x53, 0x69, 0x7a, 0x65, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30,
0x2e, 0x33, 0x31, 0x36, 0x32, 0x31, 0x36, 0x32, 0x31, 0x36, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x2b, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x32, 0x44, 0x28,
0x73, 0x2c, 0x20, 0x75, 0x76, 0x20, 0x2d, 0x20, 0x28, 0x6f, 0x66, 0x66, 0x31, 0x20, 0x2a, 0x20,
0x69, 0x6e, 0x76, 0x53, 0x69, 0x7a, 0x65, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x33, 0x31,
0x36, 0x32, 0x31, 0x36, 0x32, 0x31, 0x36, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f,
0x6c, 0x6f, 0x72, 0x20, 0x2b, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x32, 0x44, 0x28, 0x73, 0x2c, 0x20,
0x75, 0x76, 0x20, 0x2b, 0x20, 0x28, 0x6f, 0x66, 0x66, 0x32, 0x20, 0x2a, 0x20, 0x69, 0x6e, 0x76,
0x53, 0x69, 0x7a, 0x65, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x30, 0x37, 0x30, 0x32, 0x37,
0x30, 0x32, 0x37, 0x30, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6c, 0x6f, 0x72,
0x20, 0x2b, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x32, 0x44, 0x28, 0x73, 0x2c, 0x20, 0x75, 0x76, 0x20,
0x2d, 0x20, 0x28, 0x6f, 0x66, 0x66, 0x32, 0x20, 0x2a, 0x20, 0x69, 0x6e, 0x76, 0x53, 0x69, 0x7a,
0x65, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x30, 0x37, 0x30, 0x32, 0x37, 0x30, 0x32, 0x37,
0x30, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x63,
0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x0a, 0x2f, 0x2f, 0x3d, 0x3d, 0x3d, 0x3d,
0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x0a, 0x2f, 0x2f, 0x20, 0x46, 0x58,
0x41, 0x41, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x69, 0x63, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74,
0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x46, 0x78, 0x61, 0x61, 0x53, 0x75, 0x62, 0x70, 0x69,
0x78, 0x53, 0x68, 0x69, 0x66, 0x74, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x2f, 0x34, 0x2e, 0x30,
0x3b, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x55, 0x73, 0x65, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x56,
0x53, 0x0a, 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x46, 0x78, 0x61, 0x61, 0x54, 0x65,
0x78, 0x4f, 0x66, 0x66, 0x28, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x74,
0x65, 0x78, 0x2c, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x69, 0x6e, 0x76, 0x54, 0x65,
0x78, 0x53, 0x69, 0x7a, 0x65, 0x2c, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x70, 0x6f,
0x73, 0x2c, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74,
0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x74,
0x65, 0x78, 0x32, 0x44, 0x28, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x70, 0x6f, 0x73, 0x20, 0x2b, 0x20,
0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x20, 0x2a, 0x20, 0x69, 0x6e, 0x76, 0x54, 0x65, 0x78, 0x53,
0x69, 0x7a, 0x65, 0x20, 0x2b, 0x20, 0x28, 0x69, 0x6e, 0x76, 0x54, 0x65, 0x78, 0x53, 0x69, 0x7a,
0x65, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x35, 0x29, 0x29, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x66, 0x6c,
0x6f, 0x61, 0x74, 0x20, 0x46, 0x78, 0x61, 0x61, 0x4c, 0x75, 0x6d, 0x61, 0x28, 0x66, 0x6c, 0x6f,
0x61, 0x74, 0x33, 0x20, 0x72, 0x67, 0x62, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63,
0x6f, 0x6e, 0x73, 0x74, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x6c, 0x75, 0x6d, 0x61,
0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x28, 0x30, 0x2e, 0x32, 0x39, 0x39, 0x2c,
0x20, 0x30, 0x2e, 0x35, 0x38, 0x37, 0x2c, 0x20, 0x30, 0x2e, 0x31, 0x31, 0x34, 0x29, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x64, 0x6f, 0x74, 0x28, 0x72,
0x67, 0x62, 0x2c, 0x20, 0x6c, 0x75, 0x6d, 0x61, 0x29, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x66, 0x6c,
0x6f, 0x61, 0x74, 0x34, 0x20, 0x46, 0x78, 0x61, 0x61, 0x54, 0x65, 0x78, 0x4c, 0x6f, 0x64, 0x28,
0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x66,
0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x69, 0x6e, 0x76, 0x54, 0x65, 0x78, 0x53, 0x69, 0x7a, 0x65,
0x2c, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x70, 0x6f, 0x73, 0x29, 0x0a, 0x7b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x74, 0x65, 0x78, 0x32, 0x44,
0x28, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x70, 0x6f, 0x73, 0x20, 0x2b, 0x20, 0x28, 0x69, 0x6e, 0x76,
0x54, 0x65, 0x78, 0x53, 0x69, 0x7a, 0x65, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x35, 0x29, 0x29, 0x3b,
0x0a, 0x7d, 0x0a, 0x0a, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x46, 0x78, 0x61, 0x61, 0x50,
0x69, 0x78, 0x65, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x28, 0x73, 0x61, 0x6d, 0x70, 0x6c,
0x65, 0x72, 0x32, 0x44, 0x20, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34,
0x20, 0x70, 0x6f, 0x73, 0x50, 0x6f, 0x73, 0x2c, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20,
0x72, 0x63, 0x70, 0x46, 0x72, 0x61, 0x6d, 0x65, 0x2c, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32,
0x20, 0x69, 0x6e, 0x76, 0x54, 0x65, 0x78, 0x53, 0x69, 0x7a, 0x65, 0x29, 0x0a, 0x7b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x4e, 0x4f, 0x54, 0x45, 0x3a, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x2f, 0x2f, 0x20, 0x20, 0x20, 0x20, 0x20, 0x4e, 0x57, 0x20, 0x4e, 0x20, 0x4e, 0x45, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x20, 0x20, 0x20, 0x20, 0x57, 0x20, 0x20, 0x4d, 0x20, 0x20,
0x45, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x20, 0x20, 0x20, 0x20, 0x53, 0x57, 0x20,
0x53, 0x20, 0x53, 0x45, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33,
0x20, 0x72, 0x67, 0x62, 0x4e, 0x57, 0x20, 0x3d, 0x20, 0x46, 0x78, 0x61, 0x61, 0x54, 0x65, 0x78,
0x4f, 0x66, 0x66, 0x28, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x69, 0x6e, 0x76, 0x54, 0x65, 0x78, 0x53,
0x69, 0x7a, 0x65, 0x2c, 0x20, 0x70, 0x6f, 0x73, 0x50, 0x6f, 0x73, 0x2e, 0x7a, 0x77, 0x2c, 0x20,
0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x28, 0x30, 0x2c, 0x20, 0x30, 0x29, 0x29, 0x2e, 0x78, 0x79,
0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x72, 0x67,
0x62, 0x4e, 0x45, 0x20, 0x3d, 0x20, 0x46, 0x78, 0x61, 0x61, 0x54, 0x65, 0x78, 0x4f, 0x66, 0x66,
0x28, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x69, 0x6e, 0x76, 0x54, 0x65, 0x78, 0x53, 0x69, 0x7a, 0x65,
0x2c, 0x20, 0x70, 0x6f, 0x73, 0x50, 0x6f, 0x73, 0x2e, 0x7a, 0x77, 0x2c, 0x20, 0x66, 0x6c, 0x6f,
0x61, 0x74, 0x32, 0x28, 0x31, 0x2c, 0x20, 0x30, 0x29, 0x29, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x72, 0x67, 0x62, 0x53, 0x57,
0x20, 0x3d, 0x20, 0x46, 0x78, 0x61, 0x61, 0x54, 0x65, 0x78, 0x4f, 0x66, 0x66, 0x28, 0x74, 0x65,
0x78, 0x2c, 0x20, 0x69, 0x6e, 0x76, 0x54, 0x65, 0x78, 0x53, 0x69, 0x7a, 0x65, 0x2c, 0x20, 0x70,
0x6f, 0x73, 0x50, 0x6f, 0x73, 0x2e, 0x7a, 0x77, 0x2c, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32,
0x28, 0x30, 0x2c, 0x20, 0x31, 0x29, 0x29, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x72, 0x67, 0x62, 0x53, 0x45, 0x20, 0x3d, 0x20,
0x46, 0x78, 0x61, 0x61, 0x54, 0x65, 0x78, 0x4f, 0x66, 0x66, 0x28, 0x74, 0x65, 0x78, 0x2c, 0x20,
0x69, 0x6e, 0x76, 0x54, 0x65, 0x78, 0x53, 0x69, 0x7a, 0x65, 0x2c, 0x20, 0x70, 0x6f, 0x73, 0x50,
0x6f, 0x73, 0x2e, 0x7a, 0x77, 0x2c, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x28, 0x31, 0x2c,
0x20, 0x31, 0x29, 0x29, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c,
0x6f, 0x61, 0x74, 0x33, 0x20, 0x72, 0x67, 0x62, 0x4d, 0x20, 0x20, 0x3d, 0x20, 0x46, 0x78, 0x61,
0x61, 0x54, 0x65, 0x78, 0x4c, 0x6f, 0x64, 0x28, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x69, 0x6e, 0x76,
0x54, 0x65, 0x78, 0x53, 0x69, 0x7a, 0x65, 0x2c, 0x20, 0x70, 0x6f, 0x73, 0x50, 0x6f, 0x73, 0x2e,
0x78, 0x79, 0x29, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c,
0x6f, 0x61, 0x74, 0x20, 0x6c, 0x75, 0x6d, 0x61, 0x4e, 0x57, 0x20, 0x3d, 0x20, 0x46, 0x78, 0x61,
0x61, 0x4c, 0x75, 0x6d, 0x61, 0x28, 0x72, 0x67, 0x62, 0x4e, 0x57, 0x29, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x6c, 0x75, 0x6d, 0x61, 0x4e, 0x45, 0x20, 0x3d,
0x20, 0x46, 0x78, 0x61, 0x61, 0x4c, 0x75, 0x6d, 0x61, 0x28, 0x72, 0x67, 0x62, 0x4e, 0x45, 0x29,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x6c, 0x75, 0x6d, 0x61,
0x53, 0x57, 0x20, 0x3d, 0x20, 0x46, 0x78, 0x61, 0x61, 0x4c, 0x75, 0x6d, 0x61, 0x28, 0x72, 0x67,
0x62, 0x53, 0x57, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20,
0x6c, 0x75, 0x6d, 0x61, 0x53, 0x45, 0x20, 0x3d, 0x20, 0x46, 0x78, 0x61, 0x61, 0x4c, 0x75, 0x6d,
0x61, 0x28, 0x72, 0x67, 0x62, 0x53, 0x45, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c,
0x6f, 0x61, 0x74, 0x20, 0x6c, 0x75, 0x6d, 0x61, 0x4d, 0x20, 0x20, 0x3d, 0x20, 0x46, 0x78, 0x61,
0x61, 0x4c, 0x75, 0x6d, 0x61, 0x28, 0x72, 0x67, 0x62, 0x4d, 0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x6c, 0x75, 0x6d, 0x61, 0x4d, 0x69, 0x6e, 0x20,
0x3d, 0x20, 0x6d, 0x69, 0x6e, 0x28, 0x6c, 0x75, 0x6d, 0x61, 0x4d, 0x2c, 0x20, 0x6d, 0x69, 0x6e,
0x28, 0x6d, 0x69, 0x6e, 0x28, 0x6c, 0x75, 0x6d, 0x61, 0x4e, 0x57, 0x2c, 0x20, 0x6c, 0x75, 0x6d,
0x61, 0x4e, 0x45, 0x29, 0x2c, 0x20, 0x6d, 0x69, 0x6e, 0x28, 0x6c, 0x75, 0x6d, 0x61, 0x53, 0x57,
0x2c, 0x20, 0x6c, 0x75, 0x6d, 0x61, 0x53, 0x45, 0x29, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x6c, 0x75, 0x6d, 0x61, 0x4d, 0x61, 0x78, 0x20, 0x3d,
0x20, 0x6d, 0x61, 0x78, 0x28, 0x6c, 0x75, 0x6d, 0x61, 0x4d, 0x2c, 0x20, 0x6d, 0x61, 0x78, 0x28,
0x6d, 0x61, 0x78, 0x28, 0x6c, 0x75, 0x6d, 0x61, 0x4e, 0x57, 0x2c, 0x20, 0x6c, 0x75, 0x6d, 0x61,
0x4e, 0x45, 0x29, 0x2c, 0x20, 0x6d, 0x61, 0x78, 0x28, 0x6c, 0x75, 0x6d, 0x61, 0x53, 0x57, 0x2c,
0x20, 0x6c, 0x75, 0x6d, 0x61, 0x53, 0x45, 0x29, 0x29, 0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x64, 0x69, 0x72, 0x53, 0x77, 0x4d, 0x69, 0x6e, 0x75,
0x73, 0x4e, 0x65, 0x20, 0x3d, 0x20, 0x6c, 0x75, 0x6d, 0x61, 0x53, 0x57, 0x20, 0x2d, 0x20, 0x6c,
0x75, 0x6d, 0x61, 0x4e, 0x45, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74,
0x20, 0x64, 0x69, 0x72, 0x53, 0x65, 0x4d, 0x69, 0x6e, 0x75, 0x73, 0x4e, 0x77, 0x20, 0x3d, 0x20,
0x6c, 0x75, 0x6d, 0x61, 0x53, 0x45, 0x20, 0x2d, 0x20, 0x6c, 0x75, 0x6d, 0x61, 0x4e, 0x57, 0x3b,
0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x64, 0x69, 0x72,
0x20, 0x3d, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x28, 0x64, 0x69, 0x72, 0x53, 0x77, 0x4d,
0x69, 0x6e, 0x75, 0x73, 0x4e, 0x65, 0x20, 0x2b, 0x20, 0x64, 0x69, 0x72, 0x53, 0x65, 0x4d, 0x69,
0x6e, 0x75, 0x73, 0x4e, 0x77, 0x2c, 0x20, 0x64, 0x69, 0x72, 0x53, 0x77, 0x4d, 0x69, 0x6e, 0x75,
0x73, 0x4e, 0x65, 0x20, 0x2d, 0x20, 0x64, 0x69, 0x72, 0x53, 0x65, 0x4d, 0x69, 0x6e, 0x75, 0x73,
0x4e, 0x77, 0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20,
0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x46, 0x78, 0x61, 0x61, 0x52, 0x65, 0x64, 0x75, 0x63, 0x65,
0x4d, 0x69, 0x6e, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x2f, 0x31, 0x32, 0x38, 0x2e, 0x30, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74,
0x20, 0x46, 0x78, 0x61, 0x61, 0x52, 0x65, 0x64, 0x75, 0x63, 0x65, 0x4d, 0x75, 0x6c, 0x20, 0x3d,
0x20, 0x31, 0x2e, 0x30, 0x2f, 0x38, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x63, 0x6f,
0x6e, 0x73, 0x74, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x46, 0x78, 0x61, 0x61, 0x53, 0x70,
0x61, 0x6e, 0x4d, 0x61, 0x78, 0x20, 0x3d, 0x20, 0x38, 0x2e, 0x30, 0x3b, 0x0a, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x20, 0x64, 0x69, 0x72, 0x52, 0x65, 0x64, 0x75, 0x63,
0x65, 0x20, 0x3d, 0x20, 0x6d, 0x61, 0x78, 0x28, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x28, 0x6c, 0x75, 0x6d, 0x61, 0x4e, 0x57, 0x20, 0x2b, 0x20, 0x6c, 0x75, 0x6d, 0x61, 0x4e,
0x45, 0x20, 0x2b, 0x20, 0x6c, 0x75, 0x6d, 0x61, 0x53, 0x57, 0x20, 0x2b, 0x20, 0x6c, 0x75, 0x6d,
0x61, 0x53, 0x45, 0x29, 0x20, 0x2a, 0x20, 0x28, 0x30, 0x2e, 0x32, 0x35, 0x20, 0x2a, 0x20, 0x46,
0x78, 0x61, 0x61, 0x52, 0x65, 0x64, 0x75, 0x63, 0x65, 0x4d, 0x75, 0x6c, 0x29, 0x2c, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x46, 0x78, 0x61, 0x61, 0x52, 0x65, 0x64, 0x75, 0x63,
0x65, 0x4d, 0x69, 0x6e, 0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61,
0x74, 0x20, 0x72, 0x63, 0x70, 0x44, 0x69, 0x72, 0x4d, 0x69, 0x6e, 0x20, 0x3d, 0x20, 0x31, 0x2e,
0x30, 0x20, 0x2f, 0x20, 0x28, 0x6d, 0x69, 0x6e, 0x28, 0x61, 0x62, 0x73, 0x28, 0x64, 0x69, 0x72,
0x2e, 0x78, 0x29, 0x2c, 0x20, 0x61, 0x62, 0x73, 0x28, 0x64, 0x69, 0x72, 0x2e, 0x79, 0x29, 0x29,
0x20, 0x2b, 0x20, 0x64, 0x69, 0x72, 0x52, 0x65, 0x64, 0x75, 0x63, 0x65, 0x29, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x64, 0x69, 0x72, 0x20, 0x3d, 0x20, 0x63, 0x6c, 0x61, 0x6d, 0x70, 0x28, 0x6d,
0x75, 0x6c, 0x28, 0x64, 0x69, 0x72, 0x2c, 0x20, 0x72, 0x63, 0x70, 0x44, 0x69, 0x72, 0x4d, 0x69,
0x6e, 0x29, 0x2c, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x28, 0x2d, 0x46, 0x78, 0x61, 0x61,
0x53, 0x70, 0x61, 0x6e, 0x4d, 0x61, 0x78, 0x2c, 0x20, 0x2d, 0x46, 0x78, 0x61, 0x61, 0x53, 0x70,
0x61, 0x6e, 0x4d, 0x61, 0x78, 0x29, 0x2c, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x28, 0x46,
0x78, 0x61, 0x61, 0x53, 0x70, 0x61, 0x6e, 0x4d, 0x61, 0x78, 0x2c, 0x20, 0x46, 0x78, 0x61, 0x61,
0x53, 0x70, 0x61, 0x6e, 0x4d, 0x61, 0x78, 0x29, 0x29, 0x20, 0x2a, 0x20, 0x72, 0x63, 0x70, 0x46,
0x72, 0x61, 0x6d, 0x65, 0x2e, 0x78, 0x79, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c,
0x6f, 0x61, 0x74, 0x33, 0x20, 0x72, 0x67, 0x62, 0x4e, 0x31, 0x20, 0x3d, 0x20, 0x46, 0x78, 0x61,
0x61, 0x54, 0x65, 0x78, 0x4c, 0x6f, 0x64, 0x28, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x69, 0x6e, 0x76,
0x54, 0x65, 0x78, 0x53, 0x69, 0x7a, 0x65, 0x2c, 0x20, 0x70, 0x6f, 0x73, 0x50, 0x6f, 0x73, 0x2e,
0x78, 0x79, 0x20, 0x2b, 0x20, 0x64, 0x69, 0x72, 0x20, 0x2a, 0x20, 0x28, 0x31, 0x2e, 0x30, 0x2f,
0x33, 0x2e, 0x30, 0x20, 0x2d, 0x20, 0x30, 0x2e, 0x35, 0x29, 0x29, 0x2e, 0x78, 0x79, 0x7a, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x72, 0x67, 0x62, 0x50,
0x31, 0x20, 0x3d, 0x20, 0x46, 0x78, 0x61, 0x61, 0x54, 0x65, 0x78, 0x4c, 0x6f, 0x64, 0x28, 0x74,
0x65, 0x78, 0x2c, 0x20, 0x69, 0x6e, 0x76, 0x54, 0x65, 0x78, 0x53, 0x69, 0x7a, 0x65, 0x2c, 0x20,
0x70, 0x6f, 0x73, 0x50, 0x6f, 0x73, 0x2e, 0x78, 0x79, 0x20, 0x2b, 0x20, 0x64, 0x69, 0x72, 0x20,
0x2a, 0x20, 0x28, 0x32, 0x2e, 0x30, 0x2f, 0x33, 0x2e, 0x30, 0x20, 0x2d, 0x20, 0x30, 0x2e, 0x35,
0x29, 0x29, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f,
0x61, 0x74, 0x33, 0x20, 0x72, 0x67, 0x62, 0x4e, 0x32, 0x20, 0x3d, 0x20, 0x46, 0x78, 0x61, 0x61,
0x54, 0x65, 0x78, 0x4c, 0x6f, 0x64, 0x28, 0x74, 0x65, 0x78, 0x2c, 0x20, 0x69, 0x6e, 0x76, 0x54,
0x65, 0x78, 0x53, 0x69, 0x7a, 0x65, 0x2c, 0x20, 0x70, 0x6f, 0x73, 0x50, 0x6f, 0x73, 0x2e, 0x78,
0x79, 0x20, 0x2b, 0x20, 0x64, 0x69, 0x72, 0x20, 0x2a, 0x20, 0x28, 0x30, 0x2e, 0x30, 0x2f, 0x33,
0x2e, 0x30, 0x20, 0x2d, 0x20, 0x30, 0x2e, 0x35, 0x29, 0x29, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x72, 0x67, 0x62, 0x50, 0x32,
0x20, 0x3d, 0x20, 0x46, 0x78, 0x61, 0x61, 0x54, 0x65, 0x78, 0x4c, 0x6f, 0x64, 0x28, 0x74, 0x65,
0x78, 0x2c, 0x20, 0x69, 0x6e, 0x76, 0x54, 0x65, 0x78, 0x53, 0x69, 0x7a, 0x65, 0x2c, 0x20, 0x70,
0x6f, 0x73, 0x50, 0x6f, 0x73, 0x2e, 0x78, 0x79, 0x20, 0x2b, 0x20, 0x64, 0x69, 0x72, 0x20, 0x2a,
0x20, 0x28, 0x33, 0x2e, 0x30, 0x2f, 0x33, 0x2e, 0x30, 0x20, 0x2d, 0x20, 0x30, 0x2e, 0x35, 0x29,
0x29, 0x2e, 0x78, 0x79, 0x7a, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61,
0x74, 0x33, 0x20, 0x72, 0x67, 0x62, 0x41, 0x20, 0x3d, 0x20, 0x28, 0x72, 0x67, 0x62, 0x4e, 0x31,
0x20, 0x2b, 0x20, 0x72, 0x67, 0x62, 0x50, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66,
0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x72, 0x67, 0x62, 0x42, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x72,
0x67, 0x62, 0x4e, 0x32, 0x20, 0x2b, 0x20, 0x72, 0x67, 0x62, 0x50, 0x32, 0x29, 0x20, 0x2a, 0x20,
0x30, 0x2e, 0x32, 0x35, 0x29, 0x20, 0x2b, 0x20, 0x28, 0x72, 0x67, 0x62, 0x41, 0x20, 0x2a, 0x20,
0x30, 0x2e, 0x32, 0x35, 0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61,
0x74, 0x20, 0x6c, 0x75, 0x6d, 0x61, 0x42, 0x20, 0x3d, 0x20, 0x46, 0x78, 0x61, 0x61, 0x4c, 0x75,
0x6d, 0x61, 0x28, 0x72, 0x67, 0x62, 0x42, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66,
0x20, 0x28, 0x28, 0x6c, 0x75, 0x6d, 0x61, 0x42, 0x20, 0x3c, 0x20, 0x6c, 0x75, 0x6d, 0x61, 0x4d,
0x69, 0x6e, 0x29, 0x20, 0x7c, 0x7c, 0x20, 0x28, 0x6c, 0x75, 0x6d, 0x61, 0x42, 0x20, 0x3e, 0x20,
0x6c, 0x75, 0x6d, 0x61, 0x4d, 0x61, 0x78, 0x29, 0x29, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x72, 0x67, 0x62, 0x42, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x72,
0x67, 0x62, 0x41, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x35, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x7d, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x28, 0x72, 0x67, 0x62, 0x42, 0x2c, 0x20, 0x31, 0x2e,
0x30, 0x29, 0x3b, 0x0a, 0x7d, 0x0a, |
// Copyright 1996-2019 Cyberbotics Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "WbRadio.hpp"
#include "WbRadioPlugin.hpp"
#include "WbSFInt.hpp"
#include "WbSensor.hpp"
#include <QtCore/QDataStream>
#include <cassert>
#include "../../../include/plugins/radio.h"
#include "../../lib/Controller/api/messages.h"
static QList<WbRadio *> radioList; // list of radio nodes
static bool pluginLoadFailed = false;
void WbRadio::init() {
mSensor = NULL;
mID = -1;
mReceivedEvents.clear();
mNeedUpdateSetup = false;
mProtocol = findSFString("protocol");
mTxPowerMin = findSFDouble("txPowerMin");
mTxPowerMax = findSFDouble("txPowerMax");
mAddress = findSFString("address");
mRxSensitivity = findSFDouble("rxSensitivity");
mTxPower = findSFDouble("txPower");
mFrequency = findSFDouble("frequency");
mChannel = findSFInt("channel");
mBitrate = findSFInt("bitrate");
radioList.append(this); // add self
}
WbRadio::WbRadio(WbTokenizer *tokenizer) : WbSolidDevice("Radio", tokenizer) {
init();
}
WbRadio::WbRadio(const WbRadio &other) : WbSolidDevice(other) {
init();
}
WbRadio::WbRadio(const WbNode &other) : WbSolidDevice(other) {
init();
}
WbRadio::~WbRadio() {
radioList.removeAll(this); // remove self
WbRadioPlugin *plugin = WbRadioPlugin::instance();
if (plugin) {
// delete matching object in the plugin
plugin->deleteRadio(mID);
// when the last radio node is destroyed: unload plugin
if (!radioList.isEmpty()) {
WbRadioPlugin::cleanupAndUnload();
pluginLoadFailed = false;
}
}
delete mSensor;
}
void WbRadio::preFinalize() {
WbSolidDevice::preFinalize();
mSensor = new WbSensor();
}
void WbRadio::postFinalize() {
WbSolidDevice::postFinalize();
// try to load the plugin
if (!WbRadioPlugin::instance() && !pluginLoadFailed) {
WbRadioPlugin::loadAndInit("omnet");
if (!WbRadioPlugin::instance())
pluginLoadFailed = true;
}
connect(mProtocol, &WbSFString::changed, this, &WbRadio::updateSetup);
connect(mAddress, &WbSFString::changed, this, &WbRadio::updateSetup);
connect(mFrequency, &WbSFDouble::changed, this, &WbRadio::updateSetup);
connect(mChannel, &WbSFInt::changed, this, &WbRadio::updateSetup);
connect(mBitrate, &WbSFInt::changed, this, &WbRadio::updateSetup);
connect(mRxSensitivity, &WbSFDouble::changed, this, &WbRadio::updateSetup);
connect(mTxPower, &WbSFDouble::changed, this, &WbRadio::updateSetup);
}
void WbRadio::updateSetup() {
// some test on the value can eventually be added here
// force to resend the 'C_CONFIGURE'
mNeedUpdateSetup = true;
// update parameter of this radio in the plugin
WbRadioPlugin *plugin = WbRadioPlugin::instance();
if (!plugin)
return;
assert(mID != -1);
plugin->setProtocol(mID, mProtocol->value().toStdString().c_str());
plugin->setAddress(mID, mAddress->value().toStdString().c_str());
plugin->setFrequency(mID, mFrequency->value());
plugin->setChannel(mID, mChannel->value());
plugin->setBitrate(mID, mBitrate->value());
plugin->setRxSensitivity(mID, mRxSensitivity->value());
plugin->setTxPower(mID, mTxPower->value());
}
void WbRadio::handleMessage(QDataStream &stream) {
WbRadioPlugin *plugin = WbRadioPlugin::instance();
unsigned char command;
stream >> command;
switch (command) {
case C_SET_SAMPLING_PERIOD:
short refreshRate;
stream >> refreshRate;
mSensor->setRefreshRate(refreshRate);
return;
case C_RADIO_SET_ADDRESS: {
int adressSize = 0;
stream >> adressSize;
char *address = new char[adressSize];
stream.readRawData(address, adressSize);
mAddress->setValue(address);
if (plugin)
plugin->setAddress(mID, address);
delete[] address;
return;
}
case C_RADIO_SET_FREQUENCY:
double frequency;
stream >> frequency;
mFrequency->setValue(frequency);
if (plugin)
plugin->setFrequency(mID, frequency);
return;
case C_RADIO_SET_CHANNEL:
int channel;
stream >> channel;
mChannel->setValue(channel);
if (plugin)
plugin->setChannel(mID, channel);
return;
case C_RADIO_SET_BITRATE:
int bitrate;
stream >> bitrate;
mBitrate->setValue(bitrate);
if (plugin)
plugin->setBitrate(mID, bitrate);
return;
case C_RADIO_SET_RX_SENSITIVITY:
double rxSensitivity;
stream >> rxSensitivity;
mRxSensitivity->setValue(rxSensitivity);
if (plugin)
plugin->setRxSensitivity(mID, rxSensitivity);
return;
case C_RADIO_SET_TX_POWER:
double txPower;
stream >> txPower;
mTxPower->setValue(txPower);
if (plugin)
plugin->setTxPower(mID, txPower);
return;
case C_RADIO_SEND: {
int destSize = 0;
stream >> destSize;
char *dest = new char[destSize];
stream.readRawData(dest, destSize);
int dataSize = 0;
stream >> dataSize;
char *data = new char[dataSize]; // 'void *' previously
stream.readRawData(data, dataSize);
double delay;
stream >> delay;
if (plugin)
plugin->send(mID, dest, data, dataSize, delay);
delete[] dest;
delete[] data;
return;
}
default:
assert(0);
}
}
void WbRadio::RADIO_SET_SAMPLING_PERIOD(int refreshRate) {
mSensor->setRefreshRate(refreshRate);
}
void WbRadio::RADIO_SET_ADDRESS(const QString &address) {
WbRadioPlugin *plugin = WbRadioPlugin::instance();
mAddress->setValue(address);
if (plugin)
plugin->setAddress(mID, address.toLatin1().constData());
}
void WbRadio::RADIO_SET_FREQUENCY(double frequency) {
WbRadioPlugin *plugin = WbRadioPlugin::instance();
mFrequency->setValue(frequency);
if (plugin)
plugin->setFrequency(mID, frequency);
}
void WbRadio::RADIO_SET_CHANNEL(int channel) {
WbRadioPlugin *plugin = WbRadioPlugin::instance();
mChannel->setValue(channel);
if (plugin)
plugin->setChannel(mID, channel);
}
void WbRadio::RADIO_SET_BITRATE(int bitrate) {
WbRadioPlugin *plugin = WbRadioPlugin::instance();
mBitrate->setValue(bitrate);
if (plugin)
plugin->setBitrate(mID, bitrate);
}
void WbRadio::RADIO_SET_RX_SENSITIVITY(double rxSensitivity) {
WbRadioPlugin *plugin = WbRadioPlugin::instance();
mRxSensitivity->setValue(rxSensitivity);
if (plugin)
plugin->setRxSensitivity(mID, rxSensitivity);
}
void WbRadio::RADIO_SET_TX_POWER(double txPower) {
WbRadioPlugin *plugin = WbRadioPlugin::instance();
mTxPower->setValue(txPower);
if (plugin)
plugin->setTxPower(mID, txPower);
}
void WbRadio::RADIO_SEND(const QString &dest, const QByteArray &data, double delay) {
WbRadioPlugin *plugin = WbRadioPlugin::instance();
if (plugin)
plugin->send(mID, dest.toLatin1().constData(), reinterpret_cast<const void*>(data.constData()), data.size(), delay);
}
void WbRadio::writeConfigure(QDataStream &stream) {
stream << tag();
stream << (unsigned char)C_CONFIGURE;
QByteArray address = mAddress->value().toUtf8();
stream.writeRawData(address.constData(), address.size() + 1);
stream << (double)mFrequency->value();
stream << (int)mChannel->value();
stream << (int)mBitrate->value();
stream << (double)mRxSensitivity->value();
stream << (double)mTxPower->value();
}
// called from WbWorld.cpp
void WbRadio::createAndSetupPluginObjects() {
WbRadioPlugin *plugin = WbRadioPlugin::instance();
if (!plugin)
return;
// initialize plugin data structures
plugin->init();
// create plugin objects
int radioNB = radioList.count();
for (int i = 0; i < radioNB; ++i) {
WbRadio *radio = radioList.at(i);
assert(radio->mID == -1);
radio->mID = plugin->newRadio();
}
// setup plugin objects
for (int i = 0; i < radioNB; ++i) {
WbRadio *radio = radioList.at(i);
assert(radio->mID != -1);
plugin->setProtocol(radio->mID, radio->mProtocol->value().toStdString().c_str());
plugin->setAddress(radio->mID, radio->mAddress->value().toStdString().c_str());
plugin->setFrequency(radio->mID, radio->mFrequency->value());
plugin->setChannel(radio->mID, radio->mChannel->value());
plugin->setBitrate(radio->mID, radio->mBitrate->value());
plugin->setRxSensitivity(radio->mID, radio->mRxSensitivity->value());
plugin->setTxPower(radio->mID, radio->mTxPower->value());
plugin->setCallback(radio->mID, radio, &WbRadio::staticReceiveCallback);
}
}
void WbRadio::runPlugin(double ms) {
WbRadioPlugin *plugin = WbRadioPlugin::instance();
if (!plugin)
return;
plugin->run(ms / 1000.0);
}
void WbRadio::postPhysicsStep() {
WbSolidDevice::postPhysicsStep();
WbRadioPlugin *plugin = WbRadioPlugin::instance();
if (!plugin)
return;
const WbVector3 &trans = matrix().translation();
plugin->move(mID, trans.x(), trans.y(), trans.z());
}
void WbRadio::staticReceiveCallback(const int radio, const struct WebotsRadioEvent *event) {
int radioNB = radioList.count();
for (int i = 0; i < radioNB; ++i) {
WbRadio *r = radioList.at(i);
if (r->mID == radio) {
r->receiveCallback(event);
break;
}
}
}
// copy WebotsRadioEvent and duplicate substructures
static struct WebotsRadioEvent *radio_event_duplicate(const struct WebotsRadioEvent *orig) {
struct WebotsRadioEvent *copy = new struct WebotsRadioEvent;
copy->type = orig->type;
copy->data = new char[orig->data_size];
memcpy((void *)copy->data, orig->data, orig->data_size);
copy->data_size = orig->data_size;
copy->from = orig->from;
copy->rssi = orig->rssi;
return copy;
}
// destroy WebotsRadioEvent and substructures
static void radio_event_destroy(struct WebotsRadioEvent *p) {
delete[] p->data;
//delete[] p->from;
delete p;
}
void WbRadio::receiveCallback(const struct WebotsRadioEvent *event) {
// yvan: Radio N>2 bug was fixed here: a *deep* copy of WebotsRadioEvent is required
struct WebotsRadioEvent *copy = radio_event_duplicate(event);
mReceivedEvents.append(copy);
}
void WbRadio::writeAnswer(QDataStream &stream) {
if (mNeedUpdateSetup) {
writeConfigure(stream);
mNeedUpdateSetup = false;
}
if (mSensor->needToRefresh()) {
int receivedEventsNB = mReceivedEvents.count();
for (int i = 0; i < receivedEventsNB; ++i) {
struct WebotsRadioEvent *event = mReceivedEvents.at(i);
stream << tag();
stream << (unsigned char)C_RADIO_RECEIVE;
stream << (double)event->rssi;
QByteArray from = QString(event->from.c_str()).toUtf8();
stream.writeRawData(from.constData(), from.size() + 1);
stream << (int)event->data_size;
stream.writeRawData(event->data, event->data_size);
radio_event_destroy(event);
}
mReceivedEvents.clear();
}
}
|
; A173455: Row sums of triangle A027751.
; 1,1,1,3,1,6,1,7,4,8,1,16,1,10,9,15,1,21,1,22,11,14,1,36,6,16,13,28,1,42,1,31,15,20,13,55,1,22,17,50,1,54,1,40,33,26,1,76,8,43,21,46,1,66,17,64,23,32,1,108,1,34,41,63,19,78,1,58,27,74,1,123,1,40,49,64,19,90,1,106,40,44,1,140,23,46,33,92,1,144,21,76,35,50,25,156,1,73,57,117,1,114,1,106,87,56,1,172,1,106,41,136,1,126,29,94,65,62,25,240,12,64,45,100,31,186,1,127,47,122,1,204,27,70,105,134,1,150,1,196,51,74,25,259,35,76,81,118,1,222,1,148,81,134,37,236,1,82,57,218,31,201,1,130,123,86,1,312,14,154,89,136,1,186,73,196,63,92,1,366,1,154,65,176,43,198,29,148,131,170,1,316,1,100,141,203,1,270,1,265,71,104,37,300,47,106,105,226,31,366,1,166,75,110,49,384,39,112,77,284,31,234,1,280,178,116,1,332,1,202,153,218,1,312,53,184,83,194,1,504,1,157,121,190,97,258,33,232,87,218
mov $3,2
mov $5,$0
lpb $3
mov $0,$5
sub $3,1
add $0,$3
sub $0,1
cal $0,244049 ; Sum of all proper divisors of all positive integers <= n.
mov $2,$3
mov $4,$0
mul $4,2
mov $6,$4
lpb $2
mov $1,$6
sub $2,1
lpe
lpe
lpb $5
sub $1,$6
mov $5,0
lpe
div $1,2
add $1,1
|
; A291521: The arithmetic function uhat(n,4,6).
; -11,-12,-11,-12,-11,-12,-11,-12,-11,-12,-11,-12,-13,-14,-15,-16,-17,-18,-19,-20,-21,-22,-23,-24,-25,-26,-27,-28,-29,-30,-31,-32,-33,-34,-35,-36,-37,-38,-39,-40,-41,-42,-43,-44,-45,-46,-47,-48,-49,-50,-51,-52,-53,-54,-55,-56,-57,-58,-59,-60,-61,-62,-63,-64,-65,-66,-67,-68,-69,-70
mov $3,$0
mov $0,5
mov $2,$3
sub $2,5
sub $0,$2
add $0,1
lpb $0
sub $0,2
lpe
sub $0,12
mov $1,$0
|
[bits 16]
[section .text]
extern __virtine_main
global _start
_start:
cli
mov eax, gdtr32
lgdt [eax]
mov eax, cr0
or al, 1
mov cr0, eax
jmp 08h:.trampoline
[bits 32]
.trampoline:
mov esp, 0x1000
mov ebp, esp
push dword 0
call __virtine_main
out 0xFA, ax ;; call the exit hypercall
global hcall
hcall:
push ebp
mov ebp, esp
mov eax, [ebp + 8]
mov ebx, [ebp + 12]
out 0xFF, eax,
pop ebp
ret
[section .data]
gdt32:
dq 0x0000000000000000
dq 0x00cf9a000000ffff
dq 0x00cf92000000ffff
gdtr32:
dw 23
dd gdt32
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_WT_ht+0xe5a7, %rsi
lea addresses_WC_ht+0xfba7, %rdi
nop
nop
nop
nop
and %rdx, %rdx
mov $80, %rcx
rep movsl
nop
nop
and $31746, %rdx
lea addresses_UC_ht+0x24a7, %rbx
nop
nop
cmp $42915, %r9
movb $0x61, (%rbx)
nop
nop
xor %rdi, %rdi
lea addresses_D_ht+0x2ba7, %rdx
nop
nop
nop
inc %rax
mov $0x6162636465666768, %r9
movq %r9, (%rdx)
nop
nop
nop
nop
nop
add %r9, %r9
lea addresses_UC_ht+0x503a, %rcx
nop
nop
nop
nop
nop
and %rsi, %rsi
movb $0x61, (%rcx)
nop
nop
nop
nop
xor $5797, %rcx
lea addresses_D_ht+0x150c7, %rdx
nop
nop
nop
cmp %rcx, %rcx
mov $0x6162636465666768, %rbx
movq %rbx, (%rdx)
nop
nop
nop
sub %rdi, %rdi
lea addresses_A_ht+0x43a7, %rsi
lea addresses_A_ht+0xa592, %rdi
nop
add %r12, %r12
mov $64, %rcx
rep movsb
nop
nop
nop
xor $18517, %r9
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r8
push %rax
push %rbp
push %rcx
push %rdi
push %rdx
// Store
lea addresses_UC+0x1dba7, %r8
nop
nop
nop
cmp $19697, %rcx
movw $0x5152, (%r8)
and %rcx, %rcx
// Load
lea addresses_RW+0xf3a7, %rax
nop
nop
nop
inc %rdi
mov (%rax), %r8
nop
nop
xor %r12, %r12
// Store
lea addresses_UC+0x1dba7, %r12
nop
xor %r8, %r8
movb $0x51, (%r12)
and $20875, %rbp
// Faulty Load
lea addresses_UC+0x1dba7, %rcx
nop
nop
nop
nop
sub $35351, %r8
mov (%rcx), %dx
lea oracles, %rdi
and $0xff, %rdx
shlq $12, %rdx
mov (%rdi,%rdx,1), %rdx
pop %rdx
pop %rdi
pop %rcx
pop %rbp
pop %rax
pop %r8
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': True, 'NT': False}}
{'OP': 'LOAD', 'src': {'type': 'addresses_RW', 'AVXalign': False, 'congruent': 9, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': True, 'NT': False}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'AVXalign': False, 'congruent': 0, 'size': 2, 'same': True, 'NT': False}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 11, 'same': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 6, 'size': 1, 'same': True, 'NT': True}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 11, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': False, 'NT': False}}
{'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 4, 'size': 8, 'same': False, 'NT': False}}
{'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 0, 'same': True}}
{'a0': 129, '51': 21700}
51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 a0 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 a0 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 a0 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 a0 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 a0 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 a0 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 a0 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51
*/
|
; A268226: Complement of A056991.
; 2,3,5,6,8,11,12,14,15,17,20,21,23,24,26,29,30,32,33,35,38,39,41,42,44,47,48,50,51,53,56,57,59,60,62,65,66,68,69,71,74,75,77,78,80,83,84,86,87,89,92,93,95,96,98,101,102,104,105,107,110,111,113,114,116,119,120,122,123,125,128,129,131,132,134,137,138,140,141,143,146,147,149,150,152,155,156,158,159,161,164,165,167,168,170,173,174,176,177,179,182,183,185,186,188,191,192,194,195,197,200,201,203,204,206,209,210,212,213,215,218,219,221,222,224,227,228,230,231,233,236,237,239,240,242,245,246,248,249,251,254,255,257,258,260,263,264,266,267,269,272,273,275,276,278,281,282,284,285,287,290,291,293,294,296,299,300,302,303,305,308,309,311,312,314,317,318,320,321,323,326,327,329,330,332,335,336,338,339,341,344,345,347,348,350,353,354,356,357,359,362,363,365,366,368,371,372,374,375,377,380,381,383,384,386,389,390,392,393,395,398,399,401,402,404,407,408,410,411,413,416,417,419,420,422,425,426,428,429,431,434,435,437,438,440,443,444,446,447,449
mov $1,$0
mul $1,6
div $1,5
mul $1,3
div $1,2
add $1,2
|
; Variables
x: equ 5
; code
ld a,x ; copy 5 into the A register
ld a,a
ld b,a
ld c,a
ld d,a
ld e,a
ld h,a
ld l,a
|
Marts:
; entries correspond to MART_* constants
dw Mart0Badge
dw Mart1Badge
dw Mart3Badge
dw Mart5Badge
dw Mart7Badge
dw Mart8Badge
dw MartJubilife
dw MartOreburgh
.End
Mart0Badge:
db 4 ; # items
db POKE_BALL
db POTION
db ANTIDOTE
db PARLYZ_HEAL
db -1 ; end
Mart1Badge:
db 10 ; # items
db POKE_BALL
db POTION
db SUPER_POTION
db ANTIDOTE
db PARLYZ_HEAL
db AWAKENING
db BURN_HEAL
db ICE_HEAL
db ESCAPE_ROPE
db REPEL
db -1 ; end
Mart3Badge:
db 13 ; # items
db POKE_BALL
db GREAT_BALL
db POTION
db SUPER_POTION
db REVIVE
db ANTIDOTE
db PARLYZ_HEAL
db AWAKENING
db BURN_HEAL
db ICE_HEAL
db ESCAPE_ROPE
db REPEL
db SUPER_REPEL
db -1 ; end
Mart5Badge:
db 16 ; # items
db POKE_BALL
db GREAT_BALL
db ULTRA_BALL
db POTION
db SUPER_POTION
db HYPER_POTION
db REVIVE
db ANTIDOTE
db PARLYZ_HEAL
db AWAKENING
db BURN_HEAL
db ICE_HEAL
db FULL_HEAL
db ESCAPE_ROPE
db REPEL
db SUPER_REPEL
db -1 ; end
Mart7Badge:
db 18 ; # items
db POKE_BALL
db GREAT_BALL
db ULTRA_BALL
db POTION
db SUPER_POTION
db HYPER_POTION
db MAX_POTION
db REVIVE
db ANTIDOTE
db PARLYZ_HEAL
db AWAKENING
db BURN_HEAL
db ICE_HEAL
db FULL_HEAL
db ESCAPE_ROPE
db REPEL
db SUPER_REPEL
db MAX_REPEL
db -1 ; end
Mart8Badge:
db 19 ; # items
db POKE_BALL
db GREAT_BALL
db ULTRA_BALL
db POTION
db SUPER_POTION
db HYPER_POTION
db MAX_POTION
db FULL_RESTORE
db REVIVE
db ANTIDOTE
db PARLYZ_HEAL
db AWAKENING
db BURN_HEAL
db ICE_HEAL
db FULL_HEAL
db ESCAPE_ROPE
db REPEL
db SUPER_REPEL
db MAX_REPEL
db -1 ; end
MartJubilife:
db 2 ; # items
db BLUESKY_MAIL
db HEAL_BALL
db -1 ; end
MartOreburgh:
db 3 ; # items
db LITEBLUEMAIL
db HEAL_BALL
db NET_BALL
db -1 ; end
DefaultMart:
db 2 ; # items
db POKE_BALL
db POTION
db -1 ; end
|
#include "Platform.inc"
#include "FarCalls.inc"
#include "Flash.inc"
#include "SunriseSunset.inc"
#include "States.inc"
radix decimal
defineSunriseSunsetState SUN_STATE_SUNSET_LOADLOOKUPS
call loadLookupIndexIntoFlashAddress
call loadLookupTableEntryFromFlash
setSunriseSunsetNextState SUN_STATE_SUNSET_LOADLOOKUPS2
setSunriseSunsetState SUN_STATE_LOADLOOKUPS
returnFromSunriseSunsetState
defineSunriseSunsetStateInSameSection SUN_STATE_SUNSET_LOADLOOKUPS2
call loadLookupIndexIntoFlashAddress
call loadLookupTableEntryFromFlash
setSunriseSunsetStoreState SUN_STATE_SUNSET_STORE
setSunriseSunsetState SUN_STATE_LOADLOOKUPS3
returnFromSunriseSunsetState
loadLookupIndexIntoFlashAddress:
.knownBank sunriseSunsetState
.setBankFor lookupIndexLow
bcf STATUS, C
rlf lookupIndexLow, W
.setBankFor EEADR
addlw low(sunsetLookupTable)
movwf EEADR
.setBankFor EEADRH
movlw high(sunsetLookupTable)
movwf EEADRH
btfsc STATUS, C
incf EEADRH
.setBankFor lookupIndexHigh
rlf lookupIndexLow, W
rlf lookupIndexHigh, W
.setBankFor EEADRH
addwf EEADRH
return
end
|
#ifndef _UI_H
#define _UI_H
#ifdef __APPLE__
#include <OpenGL/gl3.h>
#define NANOVG_GL3_IMPLEMENTATION
#define nvgCreate nvgCreateGL3
#else
#include <GLES3/gl3.h>
#include <EGL/egl.h>
#define NANOVG_GLES3_IMPLEMENTATION
#define nvgCreate nvgCreateGLES3
#endif
#include <pthread.h>
#include "nanovg.h"
#include "common/mat.h"
#include "common/visionipc.h"
#include "common/visionimg.h"
#include "common/framebuffer.h"
#include "common/modeldata.h"
#include "messaging.hpp"
#include "cereal/gen/c/log.capnp.h"
#include "sound.hpp"
#define STATUS_STOPPED 0
#define STATUS_DISENGAGED 1
#define STATUS_ENGAGED 2
#define STATUS_WARNING 3
#define STATUS_ALERT 4
#define ALERTSIZE_NONE 0
#define ALERTSIZE_SMALL 1
#define ALERTSIZE_MID 2
#define ALERTSIZE_FULL 3
#ifndef QCOM
#define UI_60FPS
#endif
#define UI_BUF_COUNT 4
//#define SHOW_SPEEDLIMIT 1
//#define DEBUG_TURN
const int vwp_w = 1920;
const int vwp_h = 1080;
const int nav_w = 640;
const int nav_ww= 760;
const int sbr_w = 300;
//const int bdr_s = 30; //bg bdr color default
//const int bdr_s = 0; //bg bdr remove
const int bdr_s = 10;
const int bdr_is = 30;
const int box_x = sbr_w+bdr_s;
const int box_y = bdr_s;
const int box_w = vwp_w-sbr_w-(bdr_s*2);
const int box_h = vwp_h-(bdr_s*2);
const int viz_w = vwp_w-(bdr_s*2);
const int header_h = 420;
const int footer_h = 280;
const int footer_y = vwp_h-bdr_s-footer_h;
const int UI_FREQ = 30; // Hz
const int MODEL_PATH_MAX_VERTICES_CNT = 98;
const int MODEL_LANE_PATH_CNT = 3;
const int TRACK_POINTS_MAX_CNT = 50 * 2;
const int SET_SPEED_NA = 255;
const uint8_t bg_colors[][4] = {
[STATUS_STOPPED] = {0x07, 0x23, 0x39, 0xff},
[STATUS_DISENGAGED] = {0x17, 0x33, 0x49, 0xff},
[STATUS_ENGAGED] = {0x17, 0x86, 0x44, 0x0f},
[STATUS_WARNING] = {0xDA, 0x6F, 0x25, 0x0f},
[STATUS_ALERT] = {0xC9, 0x22, 0x31, 0xff},
//[STATUS_ENGAGED] = {0x17, 0x86, 0x44, 0xff},
//[STATUS_WARNING] = {0xDA, 0x6F, 0x25, 0xff},
};
typedef struct UIScene {
int frontview;
int fullview;
int transformed_width, transformed_height;
ModelData model;
float mpc_x[50];
float mpc_y[50];
bool world_objects_visible;
mat4 extrinsic_matrix; // Last row is 0 so we can use mat4.
float v_cruise;
uint64_t v_cruise_update_ts;
float v_ego;
bool decel_for_model;
float speedlimit;
float angleSteers;
float speedlimitaheaddistance;
bool speedlimitahead_valid;
bool speedlimit_valid;
bool map_valid;
bool brakeLights;
bool leftBlinker;
bool rightBlinker;
int blinker_blinkingrate;
float curvature;
int engaged;
bool engageable;
bool monitoring_active;
bool uilayout_sidebarcollapsed;
bool uilayout_mapenabled;
// responsive layout
int ui_viz_rx;
int ui_viz_rw;
int ui_viz_ro;
int lead_status;
float lead_d_rel, lead_y_rel, lead_v_rel;
int front_box_x, front_box_y, front_box_width, front_box_height;
uint64_t alert_ts;
char alert_text1[1024];
char alert_text2[1024];
uint8_t alert_size;
float alert_blinkingrate;
float awareness_status;
bool recording;
// pathcoloring
float output_scale;
bool steerOverride;
// Used to show gps planner status
bool gps_planner_active;
// dev ui
uint16_t maxCpuTemp;
uint32_t maxBatTemp;
uint64_t started_ts;
float angleSteersDes;
float pa0;
float freeSpace;
} UIScene;
typedef struct {
float x, y;
}vertex_data;
typedef struct {
vertex_data v[MODEL_PATH_MAX_VERTICES_CNT];
int cnt;
} model_path_vertices_data;
typedef struct {
vertex_data v[TRACK_POINTS_MAX_CNT];
int cnt;
} track_vertices_data;
typedef struct UIState {
pthread_mutex_t lock;
pthread_cond_t bg_cond;
// framebuffer
FramebufferState *fb;
int fb_w, fb_h;
// NVG
NVGcontext *vg;
// fonts and images
int font_courbd;
int font_sans_regular;
int font_sans_semibold;
int font_sans_bold;
int img_wheel;
int img_turn;
int img_face;
int img_map;
int img_brake;
// sockets
Context *ctx;
SubSocket *model_sock;
SubSocket *controlsstate_sock;
SubSocket *livecalibration_sock;
SubSocket *radarstate_sock;
SubSocket *map_data_sock;
SubSocket *uilayout_sock;
SubSocket *carstate_sock;
SubSocket *livempc_sock;
Poller * poller;
int active_app;
// vision state
bool vision_connected;
bool vision_connect_firstrun;
int ipc_fd;
VIPCBuf bufs[UI_BUF_COUNT];
VIPCBuf front_bufs[UI_BUF_COUNT];
int cur_vision_idx;
int cur_vision_front_idx;
GLuint frame_program;
GLuint frame_texs[UI_BUF_COUNT];
EGLImageKHR khr[UI_BUF_COUNT];
void *priv_hnds[UI_BUF_COUNT];
GLuint frame_front_texs[UI_BUF_COUNT];
EGLImageKHR khr_front[UI_BUF_COUNT];
void *priv_hnds_front[UI_BUF_COUNT];
GLint frame_pos_loc, frame_texcoord_loc;
GLint frame_texture_loc, frame_transform_loc;
int rgb_width, rgb_height, rgb_stride;
size_t rgb_buf_len;
mat4 rgb_transform;
int rgb_front_width, rgb_front_height, rgb_front_stride;
size_t rgb_front_buf_len;
UIScene scene;
bool awake;
// timeouts
int awake_timeout;
int volume_timeout;
int controls_timeout;
int alert_sound_timeout;
int speed_lim_off_timeout;
int is_metric_timeout;
int longitudinal_control_timeout;
int limit_set_speed_timeout;
bool controls_seen;
int status;
bool is_metric;
bool longitudinal_control;
bool limit_set_speed;
float speed_lim_off;
bool is_ego_over_limit;
char alert_type[64];
AudibleAlert alert_sound;
int alert_size;
float alert_blinking_alpha;
bool alert_blinked;
float light_sensor;
int touch_fd;
// Hints for re-calculations and redrawing
bool model_changed;
bool livempc_or_radarstate_changed;
GLuint frame_vao[2], frame_vbo[2], frame_ibo[2];
mat4 rear_frame_mat, front_frame_mat;
model_path_vertices_data model_path_vertices[MODEL_LANE_PATH_CNT * 2];
track_vertices_data track_vertices[2];
// dev ui
SubSocket *thermal_sock;
} UIState;
// API
void ui_draw_vision_alert(UIState *s, int va_size, int va_color,
const char* va_text1, const char* va_text2);
void ui_draw(UIState *s);
void ui_nvg_init(UIState *s);
#endif
|
; A008622: Expansion of 1/((1-x^4)*(1-x^6)*(1-x^7)).
; 1,0,0,0,1,0,1,1,1,0,1,1,2,1,2,1,2,1,3,2,3,2,3,2,4,3,4,3,5,3,5,4,6,4,6,5,7,5,7,6,8,6,9,7,9,7,10,8,11,9,11,9,12,10,13,11,14,11,14,12,16,13,16,14,17,14,18,16,19,16,20,17,21,18,22,19,23,20,24,21,25,22,26,23,28,24,28,25,30,26,31,28,32,28,33,30,35,31,36,32
mov $3,$0
mov $5,2
lpb $5
mov $0,$3
sub $5,1
add $0,$5
trn $0,1
seq $0,29070 ; Expansion of 1/((1-x)*(1-x^4)*(1-x^6)*(1-x^7)).
mov $4,$5
mul $4,$0
add $1,$4
mov $2,$0
lpe
min $3,1
mul $3,$2
sub $1,$3
mov $0,$1
|
; A016791: a(n) = (3*n + 2)^3.
; 8,125,512,1331,2744,4913,8000,12167,17576,24389,32768,42875,54872,68921,85184,103823,125000,148877,175616,205379,238328,274625,314432,357911,405224,456533,512000,571787,636056,704969,778688,857375,941192,1030301,1124864,1225043,1331000,1442897,1560896,1685159,1815848,1953125,2097152,2248091,2406104,2571353,2744000,2924207,3112136,3307949,3511808,3723875,3944312,4173281,4410944,4657463,4913000,5177717,5451776,5735339,6028568,6331625,6644672,6967871,7301384,7645373,8000000,8365427,8741816,9129329
mul $0,3
add $0,2
pow $0,3
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.