text stringlengths 1 1.05M |
|---|
#include "File_Analyzer.h"
File_Analyzer::File_Analyzer(const std::string & fileDictionary)
{
dictionary.createTrie(fileDictionary);
}
File_Analyzer::~File_Analyzer()
{
rFile.close();
}
void File_Analyzer::openFile(const std::string & file)
{
if (rFile.is_open())
rFile.close();
rFile.open(file);
if (!rFile)
throw std::runtime_error("Couldn't open the file");
}
double File_Analyzer::analyzeFile(const std::string& file)
{
openFile(file);
std::string word;
int wordCounter = 0, sum = 0;
while (rFile>>word)
{
wordCounter++;
sum += dictionary.rateWord(word);
}
return static_cast<double>(sum) / wordCounter;
}
|
<%
from pwnlib.shellcraft.amd64.linux import syscall
%>
<%page args="path, buf, length"/>
<%docstring>
Invokes the syscall readlink. See 'man 2 readlink' for more information.
Arguments:
path(char): path
buf(char): buf
len(size_t): len
</%docstring>
${syscall('SYS_readlink', path, buf, length)}
|
/* file: cholesky_dense_default_batch_fpt_dispatcher.cpp */
/*******************************************************************************
* Copyright 2014-2020 Intel Corporation
*
* 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.
*******************************************************************************/
//++
// Implementation of cholesky calculation algorithm container.
//--
#include "cholesky_batch_container.h"
namespace daal
{
namespace algorithms
{
__DAAL_INSTANTIATE_DISPATCH_CONTAINER(cholesky::BatchContainer, batch, DAAL_FPTYPE, cholesky::defaultDense)
}
} // namespace daal
|
#include "pch.h"
/////////////////////////////////////////////////////////////////////////////
//
// IPopup
//
/////////////////////////////////////////////////////////////////////////////
void IPopup::SetContainer(IPopupContainer* pcontainer)
{
m_pcontainer = pcontainer;
}
void IPopup::SetOwner(IPopup* ppopupOwner)
{
m_ppopupOwner = ppopupOwner;
}
void IPopup::OnClose()
{
}
void IPopup::ClosePopup(IPopup* ppopup)
{
m_pcontainer->ClosePopup(ppopup);
}
TRef<Image> IPopup::GetImage(Engine* pengine)
{
return CreatePaneImage(pengine, SurfaceType3D(), true, GetPane());
}
Rect IPopup::GetRect()
{
TRef<Pane> ppane = GetPane();
ppane->UpdateLayout();
return Rect(Point(0, 0), Point::Cast(ppane->GetSize()));
}
//////////////////////////////////////////////////////////////////////////////
//
// PanePopup
//
//////////////////////////////////////////////////////////////////////////////
class PanePopup : public IPopup {
private:
TRef<Pane> m_ppane;
public:
PanePopup(Pane* ppane) :
m_ppane(ppane)
{
}
//
// IPopup methods
//
Pane* GetPane()
{
return m_ppane;
}
};
TRef<IPopup> CreatePanePopup(Pane* ppane)
{
return new PanePopup(ppane);
}
/////////////////////////////////////////////////////////////////////////////
//
// IPopupContainerImpl
//
/////////////////////////////////////////////////////////////////////////////
class PopupContainerImpl :
public IPopupContainerPrivate,
public WrapImage
{
private:
/////////////////////////////////////////////////////////////////////////////
//
// Types
//
/////////////////////////////////////////////////////////////////////////////
class PickImage : public Image {
private:
PopupContainerImpl* m_pppic;
public:
PickImage(PopupContainerImpl* pppic) :
m_pppic(pppic)
{
}
MouseResult HitTest(IInputProvider* pprovider, const Point& point, bool bCaptured)
{
return m_pppic->HitTest();
}
MouseResult Button(
IInputProvider* pprovider,
const Point& point,
int button,
bool bCaptured,
bool bInside,
bool bDown
) {
if (bDown) {
m_pppic->Picked();
}
return MouseResult();
}
ZString GetFunctionName() { return "ImagePopupContainer"; }
};
class PopupData : public IObject {
public:
TRef<PopupData> m_pdataNext;
TRef<IPopup> m_ppopup;
TRef<Image> m_pimage;
TRef<Image> m_ppickImage;
bool m_bCloseAll;
};
/////////////////////////////////////////////////////////////////////////////
//
// Members
//
/////////////////////////////////////////////////////////////////////////////
TRef<PopupData> m_pdata;
TRef<Engine> m_pengine;
TRef<GroupImage> m_pgroup;
TRef<RectValue> m_prectValue;
bool m_bCascadeRight;
/////////////////////////////////////////////////////////////////////////////
//
// Methods
//
/////////////////////////////////////////////////////////////////////////////
public:
PopupContainerImpl() :
WrapImage(Image::GetEmpty()),
m_bCascadeRight(true)
{
m_pgroup = new GroupImage();
SetImage(m_pgroup);
}
MouseResult HitTest()
{
return (m_pdata != NULL) ? MouseResultHit() : MouseResult();
}
void Picked()
{
//
// Picked outside close all the popups
//
while (m_pdata && m_pdata->m_bCloseAll) {
ClosePopup(m_pdata->m_ppopup);
}
EngineWindow::DoHitTest();
}
/////////////////////////////////////////////////////////////////////////////
//
// IPopupContainerPrivate methods
//
/////////////////////////////////////////////////////////////////////////////
void Initialize(
Engine* pengine,
RectValue* prectValue
) {
m_pengine = pengine;
m_prectValue = prectValue;
}
/////////////////////////////////////////////////////////////////////////////
//
// IPopupContainer
//
/////////////////////////////////////////////////////////////////////////////
void OpenPopup(IPopup* ppopup, const Point& point, bool bCloseAll, IPopup* ppopupOwner)
{
OpenPopup(ppopup, new PointValue(point), bCloseAll, ppopupOwner);
}
void OpenPopup(IPopup* ppopup, PointValue* ppoint, bool bCloseAll, IPopup* ppopupOwner)
{
//
// Open the popup
//
TRef<PopupData> pdata = new PopupData();
pdata->m_ppopup = ppopup;
pdata->m_bCloseAll = bCloseAll;
pdata->m_pimage =
new TransformImage(
ppopup->GetImage(m_pengine),
new TranslateTransform2(
ppoint
)
);
pdata->m_pdataNext = m_pdata;
m_pdata = pdata;
if (ppopupOwner == NULL) {
pdata->m_ppickImage = new PickImage(this);
m_pgroup->AddImageToTop(pdata->m_ppickImage);
}
m_pgroup->AddImageToTop(pdata->m_pimage);
ppopup->SetContainer(this);
if (ppopupOwner != NULL) {
ppopup->SetOwner(ppopupOwner);
}
//EngineWindow::DoHitTest(); // TE: Commented to prevent mouse from triggering quickchats prematurely
}
void OpenPopup(IPopup* ppopup, const Rect& rect, bool bCloseAll, bool bCascadeDown, IPopup* ppopupOwner)
{
//
// Figure out where the popup should go
//
Rect rectPopup = ppopup->GetRect();
Rect rectContainer = m_prectValue->GetValue();
Point point;
//
// x position
//
if (m_bCascadeRight) {
if (rect.XMax() + rectPopup.XSize() > rectContainer.XMax()) {
point.SetX(rect.XMin() - rectPopup.XSize());
} else {
point.SetX(rect.XMax());
}
} else {
if (rect.XMin() - rectPopup.XSize() < 0) {
point.SetX(rect.XMax());
} else {
point.SetX(rect.XMin() - rectPopup.XSize());
}
}
//
// Make sure we actually stay on the screen
//
if (point.X() + rectPopup.XSize() > rectContainer.XMax()) {
point.SetX(rectContainer.XMax() - rectPopup.XSize());
}
if (point.X() < 0) {
point.SetX(0);
}
//
// Check if going up or down would go off the screen
//
if (bCascadeDown) {
if (rect.YMax() - rectPopup.YSize() < 0) {
bCascadeDown = false;
}
} else {
if (rect.YMin() + rectPopup.YSize() > rectContainer.YMax()) {
bCascadeDown = true;
}
}
//
// y position
//
if (bCascadeDown) {
if (rect.YMax() - rectPopup.YSize() < 0) {
point.SetY(0);
} else {
point.SetY(rect.YMax() - rectPopup.YSize());
}
} else {
if (rect.YMin() + rectPopup.YSize() > rectContainer.YMax()) {
point.SetY(rectContainer.YMax() - rectPopup.YSize());
} else {
point.SetY(rect.YMin());
}
}
//
// Open the popup
//
OpenPopup(ppopup, point, bCloseAll, ppopupOwner);
}
class CenterRectPoint : public PointValue {
private:
const Rect& GetContainerRect() { return RectValue::Cast(GetChild(0))->GetValue(); }
const Rect& GetRect() { return RectValue::Cast(GetChild(1))->GetValue(); }
public:
CenterRectPoint(RectValue* prectContainer, RectValue* prect) :
PointValue(prectContainer, prect)
{
}
void Evaluate()
{
GetValueInternal() = (GetContainerRect().Size() - GetRect().Size()) / 2;
}
};
void OpenPopup(IPopup* ppopup, bool bCloseAll, IPopup* ppopupOwner)
{
OpenPopup(
ppopup,
new CenterRectPoint(m_prectValue, new RectValue(ppopup->GetRect())),
bCloseAll,
ppopupOwner
);
}
void ClosePopup(IPopup* ppopup)
{
while (m_pdata) {
m_pgroup->RemoveImage(m_pdata->m_pimage);
m_pgroup->RemoveImage(m_pdata->m_ppickImage);
m_pdata->m_ppopup->OnClose();
if (m_pdata->m_ppopup == ppopup) {
m_pdata = m_pdata->m_pdataNext;
break;
}
m_pdata = m_pdata->m_pdataNext;
}
//
// If this is the first popup start cascading to the right
//
if (m_pdata == NULL) {
m_bCascadeRight = true;
}
EngineWindow::DoHitTest();
}
bool IsEmpty()
{
return (m_pdata == NULL);
}
Image* GetImage()
{
return this;
}
/////////////////////////////////////////////////////////////////////////////
//
// IKeyboardInput
//
/////////////////////////////////////////////////////////////////////////////
bool OnChar(IInputProvider* pprovider, const KeyState& ks)
{
if (m_pdata != NULL) {
m_pdata->m_ppopup->OnChar(pprovider, ks);
return true;
}
return false;
}
bool OnKey(IInputProvider* pprovider, const KeyState& ks, bool& fForceTranslate)
{
if (m_pdata != NULL) {
m_pdata->m_ppopup->OnKey(pprovider, ks, fForceTranslate);
//
// The popup container eats all of the keyboard
// messages if a popup is up.
//
return true;
}
return false;
}
};
TRef<IPopupContainerPrivate> CreatePopupContainer()
{
return new PopupContainerImpl();
}
|
/**
@author Shin'ichiro Nakaoka
*/
#include "JointStateView.h"
#include "LinkDeviceTreeWidget.h"
#include "BodySelectionManager.h"
#include <cnoid/BodyItem>
#include <cnoid/Body>
#include <cnoid/ConnectionSet>
#include <cnoid/EigenUtil>
#include <cnoid/ExtraBodyStateAccessor>
#include <cnoid/LazyCaller>
#include <cnoid/ViewManager>
#include <QBoxLayout>
#include <QHeaderView>
#include "gettext.h"
using namespace std;
using namespace cnoid;
namespace {
const bool TRACE_FUNCTIONS = false;
const bool doColumnStretch = true;
}
namespace cnoid {
class JointStateView::Impl
{
public:
JointStateView* self;
LinkDeviceTreeWidget treeWidget;
int qColumn;
int uColumn;
BodyPtr currentBody;
PolymorphicReferencedArray<ExtraBodyStateAccessor> accessors;
vector< vector<int> > jointStateColumnMap;
Array2D<ExtraBodyStateAccessor::Value> jointState;
bool isKinematicStateChanged;
bool isExtraJointStateChanged;
LazyCaller updateViewLater;
ConnectionSet connections;
ConnectionSet connectionsToBody;
Impl(JointStateView* self);
~Impl();
void clearSignalConnections();
void onActivated(bool on);
void setCurrentBodyItem(BodyItem* bodyItem);
void updateJointList();
void onKinematicStateChanged();
void onExtraJointStateChanged();
void updateView();
void updateJointItem(int index, LinkDeviceTreeItem* item, const vector<int>& columnMap);
};
}
void JointStateView::initializeClass(ExtensionManager* ext)
{
ext->viewManager().registerClass<JointStateView>(N_("JointStateView"), N_("Joint State"));
}
JointStateView::JointStateView()
{
impl = new Impl(this);
}
JointStateView::Impl::Impl(JointStateView* self)
: self(self)
{
self->setDefaultLayoutArea(BottomCenterArea);
QVBoxLayout* vbox = new QVBoxLayout();
vbox->setSpacing(0);
treeWidget.setLinkItemVisible(false);
treeWidget.setJointItemVisible(true);
treeWidget.setNumberColumnMode(LinkDeviceTreeWidget::Identifier);
treeWidget.setSelectionMode(QAbstractItemView::NoSelection);
treeWidget.setAlternatingRowColors(true);
treeWidget.setVerticalGridLineShown(true);
treeWidget.setAllColumnsShowFocus(true);
QHeaderView* header = treeWidget.header();
header->setDefaultAlignment(Qt::AlignHCenter);
qColumn = treeWidget.addColumn(_("Displacement"));
uColumn = treeWidget.addColumn(_("Torque"));
QTreeWidgetItem* headerItem = treeWidget.headerItem();
headerItem->setTextAlignment(qColumn, Qt::AlignRight);
headerItem->setTextAlignment(uColumn, Qt::AlignRight);
treeWidget.setHeaderSectionResizeMode(treeWidget.nameColumn(), QHeaderView::ResizeToContents);
treeWidget.setHeaderSectionResizeMode(treeWidget.numberColumn(), QHeaderView::ResizeToContents);
if(doColumnStretch){
treeWidget.setHeaderSectionResizeMode(qColumn, QHeaderView::Stretch);
treeWidget.setHeaderSectionResizeMode(uColumn, QHeaderView::Stretch);
} else {
treeWidget.setHeaderSectionResizeMode(qColumn, QHeaderView::ResizeToContents);
treeWidget.setHeaderSectionResizeMode(uColumn, QHeaderView::ResizeToContents);
}
int lastColumn = treeWidget.addColumn();
if(doColumnStretch){
treeWidget.setHeaderSectionResizeMode(lastColumn, QHeaderView::Fixed);
header->resizeSection(lastColumn, 0);
} else {
treeWidget.setHeaderSectionResizeMode(lastColumn, QHeaderView::Stretch);
}
treeWidget.sigUpdateRequest().connect([&](bool){ updateJointList(); });
vbox->addWidget(&treeWidget);
self->setLayout(vbox);
self->sigActivated().connect([&](){ onActivated(true); });
self->sigDeactivated().connect([&](){ onActivated(false); });
updateViewLater.setFunction([&](){ updateView(); });
//self->enableFontSizeZoomKeys(true);
}
JointStateView::~JointStateView()
{
delete impl;
}
JointStateView::Impl::~Impl()
{
clearSignalConnections();
}
void JointStateView::Impl::clearSignalConnections()
{
connections.disconnect();
connectionsToBody.disconnect();
}
void JointStateView::Impl::onActivated(bool on)
{
clearSignalConnections();
if(!on){
setCurrentBodyItem(0);
} else {
auto bsm = BodySelectionManager::instance();
connections.add(
bsm->sigCurrentBodyItemChanged().connect(
[&](BodyItem* bodyItem){ setCurrentBodyItem(bodyItem); }));
setCurrentBodyItem(bsm->currentBodyItem());
}
}
void JointStateView::Impl::setCurrentBodyItem(BodyItem* bodyItem)
{
connectionsToBody.disconnect();
treeWidget.setNumColumns(uColumn + 1);
jointStateColumnMap.clear();
if(!bodyItem){
currentBody.reset();
accessors.clear();
} else {
currentBody = bodyItem->body();
vector<string> names;
currentBody->getCaches(accessors, names);
vector<int> columnMap;
for(size_t i=0; i < accessors.size(); ++i){
ExtraBodyStateAccessor& accessor = *accessors[i];
const int n = accessor.getNumJointStateItems();
if(n > 0){
columnMap.clear();
for(int j=0; j < n; ++j){
const char* itemName = accessor.getJointStateItemName(j);
if(strcmp(itemName, "Pos") == 0){
columnMap.push_back(qColumn);
} else {
columnMap.push_back(treeWidget.addColumn(accessor.getJointStateItemLabel(j)));
}
}
jointStateColumnMap.push_back(columnMap);
}
}
const int m = treeWidget.columnCount();
for(int i = qColumn; i < m; ++i){
if(doColumnStretch){
treeWidget.setHeaderSectionResizeMode(i, QHeaderView::Stretch);
} else {
treeWidget.setHeaderSectionResizeMode(i, QHeaderView::ResizeToContents);
}
}
}
const int lastColumn = treeWidget.addColumn();
if(doColumnStretch){
treeWidget.setHeaderSectionResizeMode(lastColumn, QHeaderView::Fixed);
treeWidget.header()->resizeSection(lastColumn, 0);
} else {
treeWidget.setHeaderSectionResizeMode(lastColumn, QHeaderView::Stretch);
}
treeWidget.setBodyItem(bodyItem);
if(bodyItem){
connectionsToBody.add(
bodyItem->sigKinematicStateChanged().connect(
[&](){ onKinematicStateChanged(); }));
}
for(size_t i=0; i < accessors.size(); ++i){
connectionsToBody.add(
accessors[i]->sigStateChanged().connect(
[&](){ onExtraJointStateChanged(); }));
}
}
void JointStateView::Impl::updateJointList()
{
// The current body item should be gotten from the treeWidget because
// this function is first called from it when the body item is detached.
BodyItem* bodyItem = treeWidget.bodyItem();
if(bodyItem){
QTreeWidgetItem* headerItem = treeWidget.headerItem();
const int n = treeWidget.columnCount();
for(int i = uColumn + 1; i < n; ++i){
headerItem->setTextAlignment(i, Qt::AlignRight);
}
BodyPtr body = bodyItem->body();
int nameColumn = treeWidget.nameColumn();
for(int i = 0; i < currentBody->numJoints(); ++i){
Link* joint = currentBody->joint(i);
if(joint){
if(auto item = treeWidget.itemOfLink(joint->index())){
item->setTextAlignment(nameColumn, Qt::AlignHCenter);
item->setTextAlignment(qColumn, Qt::AlignRight);
item->setTextAlignment(uColumn, Qt::AlignRight);
}
}
}
for(size_t i=0; i < accessors.size(); ++i){
ExtraBodyStateAccessor& accessor = *accessors[i];
const vector<int>& columnMap = jointStateColumnMap[i];
jointState.clear();
accessor.getJointState(jointState);
const int nc = jointState.colSize();
const int nj = jointState.rowSize();
if(nj > 0){
for(int j=0; j < nc; ++j){
const int column = columnMap[j];
Array2D<ExtraBodyStateAccessor::Value>::Column js = jointState.column(j);
const ExtraBodyStateAccessor::Value& v = js[0];
Qt::Alignment alignment = Qt::AlignHCenter;
int type = v.which();
if(type == ExtraBodyStateAccessor::INT ||
type == ExtraBodyStateAccessor::DOUBLE ||
type == ExtraBodyStateAccessor::ANGLE){
alignment = Qt::AlignRight;
}
headerItem->setTextAlignment(column, alignment);
for(int k=0; k < nj; ++k){
Link* joint = currentBody->joint(k);
if(joint){
if(auto item = treeWidget.itemOfLink(joint->index())){
item->setTextAlignment(column, alignment);
}
}
}
}
}
}
isKinematicStateChanged = true;
isExtraJointStateChanged = true;
updateView();
}
}
void JointStateView::Impl::onKinematicStateChanged()
{
isKinematicStateChanged = true;
updateViewLater();
}
void JointStateView::Impl::onExtraJointStateChanged()
{
isExtraJointStateChanged = true;
updateViewLater();
}
void JointStateView::Impl::updateView()
{
if(!currentBody){
return;
}
if(isKinematicStateChanged){
for(int i = 0; i < currentBody->numJoints(); ++i){
Link* joint = currentBody->joint(i);
if(joint){
if(auto item = treeWidget.itemOfLink(joint->index())){
if(joint->jointType() == Link::ROTATIONAL_JOINT){
item->setText(qColumn, QString::number(degree(joint->q()), 'f', 2));
} else {
item->setText(qColumn, QString::number(joint->q(), 'f', 2));
}
item->setText(uColumn, QString::number(joint->u(), 'f', 2));
}
}
}
isKinematicStateChanged = false;
}
if(isExtraJointStateChanged){
for(size_t i=0; i < accessors.size(); ++i){
ExtraBodyStateAccessor& accessor = *accessors[i];
const vector<int>& columnMap = jointStateColumnMap[i];
jointState.clear();
accessor.getJointState(jointState);
const int n = jointState.rowSize();
for(int j=0; j < n; ++j){
if(auto joint = currentBody->joint(j)){
if(auto item = treeWidget.itemOfLink(joint->index())){
updateJointItem(j, item, columnMap);
}
}
}
}
isExtraJointStateChanged = false;
}
}
void JointStateView::Impl::updateJointItem(int index, LinkDeviceTreeItem* item, const vector<int>& columnMap)
{
auto js = jointState.row(index);
const int n = jointState.colSize();
for(int i=0; i < n; ++i){
bool isValid = true;
const int column = columnMap[i];
const ExtraBodyStateAccessor::Value& v = js[i];
switch(v.which()){
case ExtraBodyStateAccessor::BOOL:
item->setText(column, v.getBool() ? _("ON") : _("OFF"));
break;
case ExtraBodyStateAccessor::INT:
item->setText(column, QString::number(v.getInt()));
break;
case ExtraBodyStateAccessor::DOUBLE:
item->setText(column, QString::number(v.getDouble()));
break;
case ExtraBodyStateAccessor::ANGLE:
item->setText(column, QString::number(degree(v.getAngle()), 'f', 1));
break;
case ExtraBodyStateAccessor::STRING:
item->setText(column, v.getString().c_str());
break;
//case ExtraBodyStateAccessor::VECTOR2:
case ExtraBodyStateAccessor::VECTOR3:
case ExtraBodyStateAccessor::VECTORX:
item->setText(column, "...");
break;
default:
item->setText(column, "");
isValid = false;
break;
}
if(isValid){
const int attr = v.attribute();
if(attr == ExtraBodyStateAccessor::NORMAL){
item->setData(column, Qt::ForegroundRole, QVariant());
} else if(attr | ExtraBodyStateAccessor::WARNING){
item->setData(column, Qt::ForegroundRole, QBrush(Qt::red));
}
}
}
}
bool JointStateView::storeState(Archive& archive)
{
return true;
}
bool JointStateView::restoreState(const Archive& archive)
{
return true;
}
|
LMDiamond7 label byte
word C_BLACK
Bitmap <71,100,BMC_PACKBITS,BMF_MONO>
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0x01, 0x0f, 0xf8, 0xfa, 0x00
db 0x01, 0x0f, 0xf8, 0xfc, 0x00, 0x01, 0x04, 0x00
db 0x01, 0x0c, 0x18, 0xfc, 0x00, 0x01, 0x0e, 0x00
db 0x01, 0x0c, 0x38, 0xfc, 0x00, 0x01, 0x1b, 0x00
db 0x01, 0x00, 0x30, 0xfc, 0x00, 0x01, 0x35, 0x80
db 0x01, 0x00, 0x60, 0xfc, 0x00, 0x01, 0x2a, 0x80
db 0x01, 0x00, 0x60, 0xfc, 0x00, 0x01, 0x55, 0x40
db 0x08, 0x00, 0xc0, 0x00, 0x80, 0x00, 0x02, 0x00,
0x2a, 0x80
db 0x08, 0x00, 0xc0, 0x01, 0xc0, 0x00, 0x07, 0x00,
0x35, 0x80
db 0x08, 0x01, 0x80, 0x03, 0x60, 0x00, 0x0d, 0x80,
0x1b, 0x00
db 0x08, 0x01, 0x80, 0x06, 0xb0, 0x00, 0x1a, 0xc0,
0x0e, 0x00
db 0x08, 0x01, 0x80, 0x0d, 0x58, 0x00, 0x35, 0x60,
0x04, 0x00
db 0x08, 0x01, 0x80, 0x1a, 0xac, 0x00, 0x6a, 0xb0,
0x00, 0x00
db 0x08, 0x01, 0x80, 0x15, 0x54, 0x00, 0x55, 0x50,
0x00, 0x00
db 0x08, 0x01, 0x80, 0x2a, 0xaa, 0x00, 0xaa, 0xa8,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x15, 0x54, 0x00, 0x55, 0x50,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x1a, 0xac, 0x00, 0x6a, 0xb0,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x0d, 0x58, 0x00, 0x35, 0x60,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x06, 0xb0, 0x00, 0x1a, 0xc0,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x03, 0x60, 0x00, 0x0d, 0x80,
0x00, 0x00
db 0x05, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x07, 0xfe,
0x00
db 0xfe, 0x00, 0x02, 0x80, 0x00, 0x02, 0xfe, 0x00
db 0xf8, 0x00
db 0xfd, 0x00, 0x00, 0x10, 0xfd, 0x00
db 0xfd, 0x00, 0x00, 0x38, 0xfd, 0x00
db 0xfd, 0x00, 0x00, 0x6c, 0xfd, 0x00
db 0xfd, 0x00, 0x00, 0xd6, 0xfd, 0x00
db 0xfe, 0x00, 0x01, 0x01, 0xab, 0xfd, 0x00
db 0xfe, 0x00, 0x02, 0x03, 0x55, 0x80, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x02, 0xaa, 0x80, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x05, 0x55, 0x40, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x02, 0xaa, 0x80, 0xfe, 0x00
db 0xfe, 0x00, 0x02, 0x03, 0x55, 0x80, 0xfe, 0x00
db 0xfe, 0x00, 0x01, 0x01, 0xab, 0xfd, 0x00
db 0xfd, 0x00, 0x00, 0xd6, 0xfd, 0x00
db 0xfd, 0x00, 0x00, 0x6c, 0xfd, 0x00
db 0xfd, 0x00, 0x00, 0x38, 0xfd, 0x00
db 0xfd, 0x00, 0x00, 0x10, 0xfd, 0x00
db 0xf8, 0x00
db 0xfe, 0x00, 0x02, 0x80, 0x00, 0x02, 0xfe, 0x00
db 0x05, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x07, 0xfe,
0x00
db 0x08, 0x00, 0x00, 0x03, 0x60, 0x00, 0x0d, 0x80,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x06, 0xb0, 0x00, 0x1a, 0xc0,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x0d, 0x58, 0x00, 0x35, 0x60,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x1a, 0xac, 0x00, 0x6a, 0xb0,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x15, 0x54, 0x00, 0x55, 0x50,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x2a, 0xaa, 0x00, 0xaa, 0xa8,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x15, 0x54, 0x00, 0x55, 0x50,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x1a, 0xac, 0x00, 0x6a, 0xb0,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x0d, 0x58, 0x00, 0x35, 0x60,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x06, 0xb0, 0x00, 0x1a, 0xc0,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x03, 0x60, 0x00, 0x0d, 0x80,
0x00, 0x00
db 0x05, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x07, 0xfe,
0x00
db 0xfe, 0x00, 0x02, 0x80, 0x00, 0x02, 0xfe, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xfe, 0x00, 0x02, 0x80, 0x00, 0x02, 0xfe, 0x00
db 0x05, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x07, 0xfe,
0x00
db 0x08, 0x00, 0x00, 0x03, 0x60, 0x00, 0x0d, 0x80,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x06, 0xb0, 0x00, 0x1a, 0xc0,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x0d, 0x58, 0x00, 0x35, 0x60,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x1a, 0xac, 0x00, 0x6a, 0xb0,
0x00, 0x00
db 0x08, 0x00, 0x00, 0x15, 0x54, 0x00, 0x55, 0x50,
0x03, 0x00
db 0x08, 0x00, 0x00, 0x2a, 0xaa, 0x00, 0xaa, 0xa8,
0x03, 0x00
db 0x08, 0x00, 0x00, 0x15, 0x54, 0x00, 0x55, 0x50,
0x03, 0x00
db 0x08, 0x00, 0x40, 0x1a, 0xac, 0x00, 0x6a, 0xb0,
0x03, 0x00
db 0x08, 0x00, 0xe0, 0x0d, 0x58, 0x00, 0x35, 0x60,
0x03, 0x00
db 0x08, 0x01, 0xb0, 0x06, 0xb0, 0x00, 0x1a, 0xc0,
0x03, 0x00
db 0x08, 0x03, 0x58, 0x03, 0x60, 0x00, 0x0d, 0x80,
0x06, 0x00
db 0x08, 0x02, 0xa8, 0x01, 0xc0, 0x00, 0x07, 0x00,
0x06, 0x00
db 0x08, 0x05, 0x54, 0x00, 0x80, 0x00, 0x02, 0x00,
0x0c, 0x00
db 0x01, 0x02, 0xa8, 0xfc, 0x00, 0x01, 0x0c, 0x00
db 0x01, 0x03, 0x58, 0xfc, 0x00, 0x01, 0x18, 0x00
db 0x01, 0x01, 0xb0, 0xfc, 0x00, 0x01, 0x38, 0x60
db 0x01, 0x00, 0xe0, 0xfc, 0x00, 0x01, 0x30, 0x60
db 0x01, 0x00, 0x40, 0xfc, 0x00, 0x01, 0x3f, 0xe0
db 0xfa, 0x00, 0x01, 0x3f, 0xe0
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
db 0xf8, 0x00
|
.size 8000
.text@48
jp lstatint
.text@100
jp lbegin
.data@143
c0
.text@150
lbegin:
ld a, 00
ldff(ff), a
ld a, 30
ldff(00), a
ld a, 01
ldff(4d), a
stop, 00
ld a, ff
ldff(45), a
ld b, 96
call lwaitly_b
ld a, 80
ldff(68), a
ld a, ff
ld c, 69
ldff(c), a
ldff(c), a
ldff(c), a
ldff(c), a
ldff(c), a
ldff(c), a
xor a, a
ldff(c), a
ldff(c), a
ld a, 40
ldff(41), a
ld a, 02
ldff(ff), a
xor a, a
ldff(0f), a
ei
ld a, b
inc a
inc a
ldff(45), a
ld c, 0f
.text@1000
lstatint:
ld a, 20
ldff(41), a
xor a, a
ldff(c), a
.text@11bc
ldff a, (c)
jp lprint_a
.text@7000
lprint_a:
push af
ld b, 91
call lwaitly_b
xor a, a
ldff(40), a
ld bc, 7a00
ld hl, 8000
ld d, 00
lprint_copytiles:
ld a, (bc)
inc bc
ld(hl++), a
dec d
jrnz lprint_copytiles
pop af
ld b, a
srl a
srl a
srl a
srl a
ld(9800), a
ld a, b
and a, 0f
ld(9801), a
ld a, c0
ldff(47), a
ld a, 80
ldff(68), a
ld a, ff
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
ldff(69), a
xor a, a
ldff(69), a
ldff(69), a
ldff(43), a
ld a, 91
ldff(40), a
lprint_limbo:
jr lprint_limbo
.text@7400
lwaitly_b:
ld c, 44
lwaitly_b_loop:
ldff a, (c)
cmp a, b
jrnz lwaitly_b_loop
ret
.data@7a00
00 00 7f 7f 41 41 41 41
41 41 41 41 41 41 7f 7f
00 00 08 08 08 08 08 08
08 08 08 08 08 08 08 08
00 00 7f 7f 01 01 01 01
7f 7f 40 40 40 40 7f 7f
00 00 7f 7f 01 01 01 01
3f 3f 01 01 01 01 7f 7f
00 00 41 41 41 41 41 41
7f 7f 01 01 01 01 01 01
00 00 7f 7f 40 40 40 40
7e 7e 01 01 01 01 7e 7e
00 00 7f 7f 40 40 40 40
7f 7f 41 41 41 41 7f 7f
00 00 7f 7f 01 01 02 02
04 04 08 08 10 10 10 10
00 00 3e 3e 41 41 41 41
3e 3e 41 41 41 41 3e 3e
00 00 7f 7f 41 41 41 41
7f 7f 01 01 01 01 7f 7f
00 00 08 08 22 22 41 41
7f 7f 41 41 41 41 41 41
00 00 7e 7e 41 41 41 41
7e 7e 41 41 41 41 7e 7e
00 00 3e 3e 41 41 40 40
40 40 40 40 41 41 3e 3e
00 00 7e 7e 41 41 41 41
41 41 41 41 41 41 7e 7e
00 00 7f 7f 40 40 40 40
7f 7f 40 40 40 40 7f 7f
00 00 7f 7f 40 40 40 40
7f 7f 40 40 40 40 40 40
|
; A082639: Numbers n such that 2*n*(n+2) is a square.
; 0,2,16,98,576,3362,19600,114242,665856,3880898,22619536,131836322,768398400,4478554082,26102926096,152139002498,886731088896,5168247530882,30122754096400,175568277047522,1023286908188736
mov $2,1
lpb $0
sub $0,1
add $1,$2
add $2,$1
add $2,$1
add $1,$2
lpe
mov $0,$2
sub $0,1
|
.global s_prepare_buffers
s_prepare_buffers:
push %r14
push %r15
push %r8
push %r9
push %rcx
push %rdi
push %rsi
lea addresses_WT_ht+0xb1e3, %rsi
lea addresses_D_ht+0x4a72, %rdi
and $31194, %r9
mov $9, %rcx
rep movsb
nop
nop
nop
add $2426, %r8
lea addresses_WT_ht+0x1339b, %r14
clflush (%r14)
nop
nop
nop
sub $37159, %r15
vmovups (%r14), %ymm5
vextracti128 $1, %ymm5, %xmm5
vpextrq $1, %xmm5, %rsi
nop
nop
nop
cmp %r14, %r14
pop %rsi
pop %rdi
pop %rcx
pop %r9
pop %r8
pop %r15
pop %r14
ret
.global s_faulty_load
s_faulty_load:
push %r12
push %r14
push %r8
push %r9
push %rbx
push %rdx
push %rsi
// Store
mov $0x5e099800000005ad, %r9
clflush (%r9)
nop
nop
nop
xor %r8, %r8
mov $0x5152535455565758, %rbx
movq %rbx, %xmm4
movups %xmm4, (%r9)
nop
nop
nop
nop
nop
and %rdx, %rdx
// Store
lea addresses_WT+0x1fb9b, %rbx
nop
nop
nop
nop
sub $16185, %rsi
mov $0x5152535455565758, %rdx
movq %rdx, %xmm2
movups %xmm2, (%rbx)
nop
nop
nop
nop
inc %r12
// Faulty Load
lea addresses_US+0x5b9b, %r9
nop
nop
and $52995, %r14
mov (%r9), %ebx
lea oracles, %r8
and $0xff, %rbx
shlq $12, %rbx
mov (%r8,%rbx,1), %rbx
pop %rsi
pop %rdx
pop %rbx
pop %r9
pop %r8
pop %r14
pop %r12
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_US'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_NC'}}
{'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_WT'}}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 4, 'NT': False, 'type': 'addresses_US'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 3, 'same': False, 'type': 'addresses_WT_ht'}, 'OP': 'REPM', 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_D_ht'}}
{'src': {'congruent': 9, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'}
{'58': 21829}
58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58 58
*/
|
; A203170: Sum of the fourth powers of the first n odd-indexed Fibonacci numbers.
; Submitted by Jamie Morken(s4)
; 0,1,17,642,29203,1365539,64107780,3011403301,141469813301,6646055880582,312223061019703,14667837157106759,689076118833981960,32371909717271872585,1520790680382055836761,71444790066793903279242
mov $2,$0
mov $3,$0
lpb $3
mov $0,$2
add $2,1
sub $3,1
sub $0,$3
seq $0,45 ; Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1.
pow $0,4
add $1,$0
lpe
mov $0,$1
|
; A224880: a(n) = 2n + sum of divisors of n.
; 3,7,10,15,16,24,22,31,31,38,34,52,40,52,54,63,52,75,58,82,74,80,70,108,81,94,94,112,88,132,94,127,114,122,118,163,112,136,134,170,124,180,130,172,168,164,142,220,155,193,174,202,160,228,182,232,194,206,178,288,184,220,230,255,214,276,202,262,234,284,214,339,220,262,274,292,250,324,238,346,283,290,250,392,278,304,294,356,268,414,294,352,314,332,310,444,292,367,354,417,304,420,310,418,402,374,322,496,328,436,374,472,340,468,374,442,416,416,382,600,375,430,414,472,406,564,382,511,434,512,394,600,426,472,510,542,412,564,418,616,474,500,454,691,470,514,522,562,448,672,454,604,540,596,502,704,472,556,534,698,514,687,490,622,618,584,502,816,521,664,602,652,520,708,598,724,594,626,538,906,544,700,614,728,598,756,590,712,698,740,574,892,580,682,726,791,592,864,598,865,674,710,646,912,662,724,726,850,658,996,634,802,714,752,694,1032,690,766,734,944,694,900,670,952,853,794,682,1016,688,892,846,914,700,1014,758,892,794,908,718,1224,724,883,850,922,832,996,774,976,834,968
mov $14,$0
mov $16,2
mov $18,$0
lpb $16
clr $0,14
mov $0,$14
sub $16,1
add $0,$16
sub $0,1
mov $11,$0
mov $13,$0
lpb $13
mov $0,$11
sub $13,1
sub $0,$13
mov $7,$0
mov $9,2
lpb $9
clr $0,7
mov $0,$7
sub $9,1
add $0,$9
sub $0,1
mov $2,$0
mov $3,$0
lpb $2
add $6,2
lpb $6
add $0,$2
trn $6,$2
lpe
sub $2,1
mov $6,$3
lpe
mov $1,$0
mov $10,$9
lpb $10
mov $8,$1
sub $10,1
lpe
lpe
lpb $7
mov $7,0
sub $8,$1
lpe
mov $1,$8
add $1,1
add $12,$1
lpe
mov $1,$12
mov $17,$16
lpb $17
mov $15,$1
sub $17,1
lpe
lpe
lpb $14
mov $14,0
sub $15,$1
lpe
mov $1,$15
trn $1,1
add $1,3
add $1,$18
|
/*
* Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
*/
#include <cmn/agent_cmn.h>
#include <ksync/ksync_index.h>
#include <ksync/ksync_entry.h>
#include <ksync/ksync_object.h>
#include <vnc_cfg_types.h>
#include <bgp_schema_types.h>
#include <agent_types.h>
#include <oper/peer.h>
#include <oper/vrf.h>
#include <oper/interface_common.h>
#include <oper/nexthop.h>
#include <oper/tunnel_nh.h>
#include <oper/multicast.h>
#include <oper/vn.h>
#include <oper/mirror_table.h>
#include <oper/vxlan.h>
#include <oper/mpls.h>
#include <oper/route_common.h>
#include <oper/bridge_route.h>
#include "ksync_vxlan.h"
#include "ksync_vxlan_bridge.h"
#include "ksync_vxlan_port.h"
#include "ksync_vxlan_route.h"
/**************************************************************************
**************************************************************************/
KSyncVxlanRouteEntry::KSyncVxlanRouteEntry(KSyncVxlanRouteObject *obj,
const KSyncVxlanRouteEntry *entry) :
KSyncDBEntry(), vrf_id_(entry->vrf_id()), ksync_obj_(obj) {
}
KSyncVxlanRouteEntry::KSyncVxlanRouteEntry(KSyncVxlanRouteObject *obj,
const AgentRoute *route) :
KSyncDBEntry(), vrf_id_(route->vrf_id()), ksync_obj_(obj) {
}
KSyncVxlanRouteEntry::~KSyncVxlanRouteEntry() {
}
KSyncDBObject *KSyncVxlanRouteEntry::GetObject() {
return ksync_obj_;
}
bool KSyncVxlanRouteEntry::IsLess(const KSyncEntry &rhs) const {
const KSyncVxlanRouteEntry &rhs_route =
static_cast<const KSyncVxlanRouteEntry &>(rhs);
Agent::RouteTableType lhs_type = ksync_obj_->route_table()->GetTableType();
Agent::RouteTableType rhs_type =
rhs_route.ksync_obj_->route_table()->GetTableType();
if (lhs_type != rhs_type)
return lhs_type < rhs_type;
if (vrf_id_ != rhs_route.vrf_id_)
return vrf_id_ < rhs_route.vrf_id_;
return CompareRoute(rhs_route);
}
/**************************************************************************
**************************************************************************/
KSyncVxlanFdbEntry::KSyncVxlanFdbEntry(KSyncVxlanRouteObject *obj,
const KSyncVxlanFdbEntry *entry) :
KSyncVxlanRouteEntry(obj, entry), bridge_(entry->bridge_),
mac_(entry->mac_), port_(entry->port_), tunnel_dest_(entry->tunnel_dest_) {
}
KSyncVxlanFdbEntry::KSyncVxlanFdbEntry(KSyncVxlanRouteObject *obj,
const BridgeRouteEntry *route) :
KSyncVxlanRouteEntry(obj, route), bridge_(NULL), mac_(route->mac()),
port_(NULL), tunnel_dest_() {
}
KSyncVxlanFdbEntry::~KSyncVxlanFdbEntry() {
}
bool KSyncVxlanFdbEntry::CompareRoute(const KSyncVxlanRouteEntry &rhs) const {
const KSyncVxlanFdbEntry &entry = static_cast
<const KSyncVxlanFdbEntry &>(rhs);
return (mac_.CompareTo(entry.mac_) < 0);
}
std::string KSyncVxlanFdbEntry::ToString() const {
std::stringstream s;
s << "FDB : ";
return s.str();
}
bool KSyncVxlanFdbEntry::Sync(DBEntry *e) {
bool ret = false;
KSyncVxlanBridgeEntry *bridge = bridge_;
uint32_t new_vxlan_id = VxLanTable::kInvalidvxlan_id;
uint32_t old_vxlan_id = VxLanTable::kInvalidvxlan_id;
BridgeRouteEntry *fdb = static_cast<BridgeRouteEntry *>(e);
KSyncVxlanRouteObject *obj =
static_cast<KSyncVxlanRouteObject *>(GetObject());
Agent *agent = obj->ksync()->agent();
const AgentPath *path = fdb->GetActivePath();
if (path) {
new_vxlan_id = path->vxlan_id();
}
if (bridge_) {
old_vxlan_id = bridge_->vxlan_id();
}
if (old_vxlan_id != new_vxlan_id) {
KSyncVxlanBridgeObject *bridge_obj =
ksync_object()->ksync()->bridge_obj();
VxLanIdKey key(new_vxlan_id);
VxLanId *vxlan = static_cast<VxLanId *>
(agent->vxlan_table()->FindActiveEntry(&key));
if (vxlan) {
KSyncEntry *vxlan_key = bridge_obj->DBToKSyncEntry(vxlan);
bridge = static_cast<KSyncVxlanBridgeEntry *>
(bridge_obj->GetReference(vxlan_key));
delete vxlan_key;
assert(bridge);
}
}
if (bridge_ != bridge) {
bridge_ = bridge;
ret = true;
}
// Look for change in nexthop
KSyncVxlanPortEntry *port = NULL;
Ip4Address tunnel_dest = Ip4Address(0);
const NextHop *nh = fdb->GetActiveNextHop();
if (nh != NULL) {
if (nh->GetType() == NextHop::INTERFACE) {
const InterfaceNH *intf_nh = static_cast<const InterfaceNH *>(nh);
KSyncVxlanPortObject *port_obj =
ksync_object()->ksync()->port_obj();
KSyncEntry *port_key =
port_obj->DBToKSyncEntry(intf_nh->GetInterface());
port = static_cast<KSyncVxlanPortEntry *>
(port_obj->GetReference(port_key));
delete port_key;
assert(port);
}
if (nh->GetType() == NextHop::TUNNEL) {
const TunnelNH *tunnel_nh = static_cast<const TunnelNH *>(nh);
tunnel_dest = *tunnel_nh->GetDip();
}
}
if (port_ != port) {
port_ = port;
ret = true;
}
if (tunnel_dest_ != tunnel_dest) {
tunnel_dest_ = tunnel_dest;
ret = true;
}
return ret;
}
KSyncEntry *KSyncVxlanFdbEntry::UnresolvedReference() {
if (bridge_ == NULL) {
return KSyncVxlan::defer_entry();
}
if (bridge_->IsResolved() == false) {
return bridge_;
}
if (port_ == NULL && tunnel_dest_.to_ulong() == 0) {
return KSyncVxlan::defer_entry();
}
if (port_ && port_->IsResolved() == false) {
return port_;
}
return NULL;
}
/**************************************************************************
**************************************************************************/
KSyncVxlanRouteObject::KSyncVxlanRouteObject(KSyncVxlanVrfObject *vrf,
AgentRouteTable *rt_table) :
KSyncDBObject("KSyncVxlanRouteObject"),
ksync_(vrf->ksync()),
marked_delete_(false),
table_delete_ref_(this, rt_table->deleter()) {
rt_table_ = rt_table;
RegisterDb(rt_table);
}
KSyncVxlanRouteObject::~KSyncVxlanRouteObject() {
UnregisterDb(GetDBTable());
table_delete_ref_.Reset(NULL);
}
void KSyncVxlanRouteObject::Unregister() {
if (IsEmpty() == true && marked_delete_ == true) {
ksync_->vrf_obj()->DelFromVrfMap(this);
KSyncObjectManager::Unregister(this);
}
}
void KSyncVxlanRouteObject::ManagedDelete() {
marked_delete_ = true;
Unregister();
}
void KSyncVxlanRouteObject::EmptyTable() {
if (marked_delete_ == true) {
Unregister();
}
}
/****************************************************************************
* VRF Notification handler
* Creates a KSyncVxlanRouteObject for every VRF that is created
* The RouteObject is stored in VrfRouteObjectMap
***************************************************************************/
KSyncVxlanVrfObject::KSyncVxlanVrfObject(KSyncVxlan *ksync) : ksync_(ksync) {
}
KSyncVxlanVrfObject::~KSyncVxlanVrfObject() {
}
// Register to the VRF table
void KSyncVxlanVrfObject::RegisterDBClients() {
vrf_listener_id_ = ksync_->agent()->vrf_table()->Register
(boost::bind(&KSyncVxlanVrfObject::VrfNotify, this, _1, _2));
}
KSyncVxlanRouteObject *KSyncVxlanVrfObject::GetRouteKSyncObject(uint32_t vrf_id)
const {
VrfRouteObjectMap::const_iterator it;
it = vrf_fdb_object_map_.find(vrf_id);
if (it != vrf_fdb_object_map_.end()) {
return it->second;
}
}
void KSyncVxlanVrfObject::AddToVrfMap(uint32_t vrf_id,
KSyncVxlanRouteObject *rt) {
vrf_fdb_object_map_.insert(make_pair(vrf_id, rt));
}
void KSyncVxlanVrfObject::DelFromVrfMap(KSyncVxlanRouteObject *rt) {
VrfRouteObjectMap::iterator it;
for (it = vrf_fdb_object_map_.begin(); it != vrf_fdb_object_map_.end();
++it) {
if (it->second == rt) {
vrf_fdb_object_map_.erase(it);
return;
}
}
}
void KSyncVxlanVrfObject::VrfNotify(DBTablePartBase *partition, DBEntryBase *e){
VrfEntry *vrf = static_cast<VrfEntry *>(e);
VrfState *state = static_cast<VrfState *>
(vrf->GetState(partition->parent(), vrf_listener_id_));
if (vrf->IsDeleted()) {
if (state) {
vrf->ClearState(partition->parent(), vrf_listener_id_);
delete state;
}
return;
}
if (state == NULL) {
state = new VrfState();
state->seen_ = true;
vrf->SetState(partition->parent(), vrf_listener_id_, state);
AddToVrfMap(vrf->vrf_id(), AllocBridgeRouteTable(vrf));
}
return;
}
void KSyncVxlanVrfObject::Init() {
}
void KSyncVxlanVrfObject::Shutdown() {
ksync_->agent()->vrf_table()->Unregister(vrf_listener_id_);
vrf_listener_id_ = -1;
}
|
; A007486: a(n) = a(n-1) + a(n-2) + a(n-3).
; Submitted by Jamie Morken(s2)
; 1,3,4,8,15,27,50,92,169,311,572,1052,1935,3559,6546,12040,22145,40731,74916,137792,253439,466147,857378,1576964,2900489,5334831,9812284,18047604,33194719,61054607,112296930,206546256,379897793,698740979,1285185028,2363823800,4347749807,7996758635,14708332242,27052840684,49757931561,91519104487,168329876732,309606912780,569455893999,1047392683511,1926455490290,3543304067800,6517152241601,11986911799691,22047368109092,40551432150384,74585712059167,137184512318643,252321656528194,464091880906004
mov $1,1
mov $2,1
lpb $0
sub $0,1
add $1,$2
add $1,$3
sub $3,$1
add $1,$3
add $1,$3
sub $2,$3
add $3,$2
lpe
mov $0,$2
|
; A252076: Numbers n such that the sum of the heptagonal numbers H(n) and H(n+1) is equal to the hexagonal number X(m) for some m.
; Submitted by Jon Maiga
; 0,486,701100,1010986002,1457841114072,2102205875506110,3031379414638696836,4371247013703125331690,6303335162380492089600432,9089404932905655890078491542,13106915609914793413001095203420,18900163220092199195891689204840386,27254022256457341325682402832284633480,39300281193648266099434828992465236638062,56670978227218543258043697724732038947452212,81719511303367945729832912684234607696989451930,117839478628478350523875802046968579567019842231136
mul $0,2
lpb $0
sub $0,1
add $2,1
mov $1,$2
mul $1,36
add $3,$1
add $2,$3
add $2,26
lpe
mov $0,$2
div $0,5
|
; A187110: Decimal expansion of sqrt(3/8).
; Submitted by Jon Maiga
; 6,1,2,3,7,2,4,3,5,6,9,5,7,9,4,5,2,4,5,4,9,3,2,1,0,1,8,6,7,6,4,7,2,8,4,7,9,9,1,4,8,6,8,7,0,1,6,4,1,6,7,5,3,2,1,0,8,1,7,3,1,4,1,8,1,2,7,4,0,0,9,4,3,6,4,3,2,8,7,5,6,6,3,4,9,6,4,8,5,8
mov $1,1
mov $2,1
mov $3,$0
add $3,8
mov $4,$0
add $4,3
mul $4,2
mov $7,10
pow $7,$4
mov $9,10
lpb $3
mov $4,$2
pow $4,2
mul $4,75
div $4,2
mov $5,$1
pow $5,2
add $4,$5
mov $6,$1
mov $1,$4
mul $6,$2
mul $6,2
mov $2,$6
mov $8,$4
div $8,$7
max $8,2
div $1,$8
div $2,$8
sub $3,2
lpe
mov $3,$9
pow $3,$0
div $2,$3
div $1,$2
mod $1,$9
mov $0,$1
|
/* Copyright (c) 2005, Regents of Massachusetts Institute of Technology,
* Brandeis University, Brown University, and University of Massachusetts
* Boston. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of Massachusetts Institute of Technology,
* Brandeis University, Brown University, or University of
* Massachusetts Boston 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.
*/
/*
* BAggMinNode.cpp
* cstore
*
* Created by Nga Tran on 3/30/05.
*
* Min node with group by
*/
#include "BAggMinNode.h"
#include <iostream>
// Default
BAggMinNode::BAggMinNode() : BAggNode()
{
m_lpMergeOp = NULL;
}
// Initialize with column to be aggregated
BAggMinNode::BAggMinNode(Node* lpAggCol, int iAggColIndex, Node* lpAggGroup, int iGroupColIndex) : BAggNode(lpAggCol, iAggColIndex, lpAggGroup, iGroupColIndex)
{
m_lpMergeOp = NULL;
}
// Deallocate memory
BAggMinNode::~BAggMinNode()
{
Log::writeToLog("BAggMinNode", 10, "~BAggMinNode");
if (m_lpROSReturnOp != NULL)
{
delete m_lpROSReturnOp;
m_lpROSReturnOp = NULL;
}
if (m_lpWOSReturnOp != NULL)
{
delete m_lpWOSReturnOp;
m_lpWOSReturnOp = NULL;
}
if (m_lpReturnOp != NULL)
{
delete m_lpReturnOp;
m_lpReturnOp = NULL;
}
if (m_lpROSIdHashFunction != NULL)
{
delete m_lpROSIdHashFunction;
m_lpROSIdHashFunction = NULL;
}
if (m_lpWOSIdHashFunction != NULL)
{
delete m_lpWOSIdHashFunction;
m_lpWOSIdHashFunction = NULL;
}
}
// Merge ROS and WOS operators
Operator* BAggMinNode::mergeROSandWOS()
{
if (m_lpReturnOp != NULL)
{
// Has been merged
return m_lpReturnOp;
}
if ( (m_lpROSReturnOp != NULL) && (m_lpWOSReturnOp != NULL) )
{
// Merge them
m_lpReturnOp = new MergeSortedGroups( m_lpROSReturnOp,
m_lpWOSReturnOp,
2, // num columns
0); // merge by col index
((MergeSortedGroups*) m_lpReturnOp)->setMergeOp(new MergeMinOp());
return m_lpReturnOp;
}
if (m_lpROSReturnOp != NULL)
{
return m_lpROSReturnOp;
}
if (m_lpWOSReturnOp != NULL)
{
return m_lpWOSReturnOp;
}
return m_lpReturnOp;
}
// Run ROS only
Operator* BAggMinNode::runROS()
{
// The operator exists, only return it
if (m_lpROSReturnOp != NULL)
{
return m_lpROSReturnOp;
}
// Left is group, right is aggregate
Operator* lpLeft = NULL;
Operator* lpRight = NULL;
if (m_lpLeft != NULL)
{
lpLeft = m_lpLeft->runROS();
}
if (m_lpRight != NULL)
{
lpRight = m_lpRight->runROS();
}
if ( (lpLeft != NULL) && (lpRight != NULL) )
{
if (m_bUnsortedGroupBy)
{
// Unsorted groupy column, use hash aggregate
m_lpROSReturnOp = new HashMin(lpRight, m_iAggColIndex, lpLeft, m_iGroupColIndex);
m_lpROSIdHashFunction = new IdentityHashFunction(m_iHashTableSize);
((HashAggregator*) m_lpROSReturnOp)->setHashFunction(m_lpROSIdHashFunction);
((HashAggregator*) m_lpROSReturnOp)->setHashTableSize(m_iHashTableSize);
}
else
{
m_lpROSReturnOp = new Min(lpRight, m_iAggColIndex, lpLeft, m_iGroupColIndex);
}
}
return m_lpROSReturnOp;
}
// Run WOS only
Operator* BAggMinNode::runWOS()
{
// The operator exists, only return it
if (m_lpWOSReturnOp != NULL)
{
return m_lpWOSReturnOp;
}
// Left is group, right is aggregate
Operator* lpLeft = NULL;
Operator* lpRight = NULL;
if (m_lpLeft != NULL)
{
lpLeft = m_lpLeft->runWOS();
}
if (m_lpRight != NULL)
{
lpRight = m_lpRight->runWOS();
}
if ( (lpLeft != NULL) && (lpRight != NULL) )
{
if (m_bUnsortedGroupBy)
{
// Unsorted groupy column, use hash aggregate
m_lpWOSReturnOp = new HashMin(lpRight, m_iAggColIndex, lpLeft, m_iGroupColIndex);
m_lpWOSIdHashFunction = new IdentityHashFunction(m_iHashTableSize);
((HashAggregator*) m_lpWOSReturnOp)->setHashFunction(m_lpWOSIdHashFunction);
((HashAggregator*) m_lpWOSReturnOp)->setHashTableSize(m_iHashTableSize);
}
else
{
m_lpWOSReturnOp = new Min(lpRight, m_iAggColIndex, lpLeft, m_iGroupColIndex);
}
}
return m_lpWOSReturnOp;
}
// show what operator this node will run
void BAggMinNode::showROS(int* lpNodeID, ofstream* lpOfstream)
{
// The operator exists
if (m_bROSHasShown)
{
return;
}
commonShowROS(lpNodeID, "Min", lpOfstream);
}
// show what operator this node will run
void BAggMinNode::showWOS(int* lpNodeID, ofstream* lpOfstream)
{
// The operator exists
if (m_bWOSHasShown)
{
return;
}
commonShowWOS(lpNodeID, "Min", lpOfstream);
}
// show merge operators
void BAggMinNode::showMerge(ofstream* lpOfstream)
{
commonShowMerge("Min", lpOfstream);
}
// show tree presentation
void BAggMinNode::showTree(string sTabs)
{
// The operator exists
if (m_bTreeHasShown)
{
cout << endl;
cout << sTabs << "MIN AGGREGATE - The operator was created before" << endl;
return;
}
m_bTreeHasShown = 1;
// Show its information first
cout << endl;
cout << sTabs << "MIN AGGREGATE" << endl;
commonShowTree("Min", sTabs);
sTabs = sTabs + " ";
// Show child's information
if (m_lpLeft != NULL)
{
m_lpLeft->showTree(sTabs);
}
if (m_lpRight != NULL)
{
m_lpRight->showTree(sTabs);
}
}
//---------------------------------------------------------------
// Memory management functions
// New a node and put it in the m_lpList
BAggMinNode* BAggMinNode::create()
{
Log::writeToLog("BAggMinNode", 10, "Create without arguments");
BAggMinNode* lpNode = new BAggMinNode();
pushBack(lpNode);
return lpNode;
}
// New a node and put it in the m_lpList
BAggMinNode* BAggMinNode::create(Node* lpAggCol, int iAggColIndex, Node* lpAggGroup, int iGroupColIndex)
{
Log::writeToLog("BAggMinNode", 10, "Create with arguments: Node* lpAggCol, int iAggColIndex, Node* lpAggGroup, int iGroupColIndex");
BAggMinNode* lpNode = new BAggMinNode(lpAggCol, iAggColIndex, lpAggGroup, iGroupColIndex);
pushBack(lpNode);
return lpNode;
}
|
; A271017: Number of active (ON,black) cells at stage 2^n-1 of the two-dimensional cellular automaton defined by "Rule 251", based on the 5-celled von Neumann neighborhood.
; 1,5,41,185,761,3065,12281,49145,196601,786425,3145721,12582905,50331641,201326585,805306361,3221225465
mul $0,2
mov $1,2
pow $1,$0
mul $1,3
trn $1,8
div $1,4
mul $1,4
add $1,1
mov $0,$1
|
// -----------------------------------------------------------------------------------------
// QSVEnc/NVEnc by rigaya
// -----------------------------------------------------------------------------------------
// The MIT License
//
// Copyright (c) 2011-2016 rigaya
//
// 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 <stdio.h>
#include <vector>
#include <numeric>
#include <memory>
#include <sstream>
#include <algorithm>
#include <type_traits>
#ifndef _MSC_VER
#include <sys/sysinfo.h>
#include <sys/utsname.h>
#include <sys/wait.h>
#include <iconv.h>
#endif
#include "rgy_util.h"
#include "rgy_tchar.h"
#include "rgy_osdep.h"
#include "ram_speed.h"
#include "rgy_version.h"
#pragma warning (push)
#pragma warning (disable: 4100)
#if defined(_WIN32) || defined(_WIN64)
unsigned int wstring_to_string(const wchar_t *wstr, std::string& str, uint32_t codepage) {
if (wstr == nullptr) {
str = "";
return 0;
}
uint32_t flags = (codepage == CP_UTF8) ? 0 : WC_NO_BEST_FIT_CHARS;
int multibyte_length = WideCharToMultiByte(codepage, flags, wstr, -1, nullptr, 0, nullptr, nullptr);
str.resize(multibyte_length, 0);
if (0 == WideCharToMultiByte(codepage, flags, wstr, -1, &str[0], multibyte_length, nullptr, nullptr)) {
str.clear();
return 0;
}
return multibyte_length;
}
#else
unsigned int wstring_to_string(const wchar_t *wstr, std::string& str, uint32_t codepage) {
if (wstr == nullptr) {
str = "";
return 0;
}
auto ic = iconv_open("UTF-8", "wchar_t"); //to, from
auto input_len = wcslen(wstr) * 2;
auto output_len = input_len * 6;
std::vector<char> buf(output_len, 0);
char *outbuf = buf.data();
iconv(ic, (char **)&wstr, &input_len, &outbuf, &output_len);
iconv_close(ic);
str = buf.data();
return output_len;
}
#endif //#if defined(_WIN32) || defined(_WIN64)
std::string wstring_to_string(const wchar_t *wstr, uint32_t codepage) {
if (wstr == nullptr) {
return "";
}
std::string str;
wstring_to_string(wstr, str, codepage);
return str;
}
std::string wstring_to_string(const std::wstring& wstr, uint32_t codepage) {
std::string str;
wstring_to_string(wstr.c_str(), str, codepage);
return str;
}
unsigned int tchar_to_string(const TCHAR *tstr, std::string& str, uint32_t codepage) {
#if UNICODE
return wstring_to_string(tstr, str, codepage);
#else
str = (tstr) ? std::string(tstr) : "";
return (unsigned int)str.length();
#endif
}
std::string tchar_to_string(const TCHAR *tstr, uint32_t codepage) {
if (tstr == nullptr) {
return "";
}
std::string str;
tchar_to_string(tstr, str, codepage);
return str;
}
std::wstring tchar_to_wstring(const tstring& tstr, uint32_t codepage) {
#if UNICODE
return std::wstring(tstr);
#else
return char_to_wstring(tstr, codepage);
#endif
}
std::wstring tchar_to_wstring(const TCHAR *tstr, uint32_t codepage) {
if (tstr == nullptr) {
return L"";
}
return tchar_to_wstring(tstring(tstr), codepage);
}
std::string tchar_to_string(const tstring& tstr, uint32_t codepage) {
std::string str;
tchar_to_string(tstr.c_str(), str, codepage);
return str;
}
unsigned int wstring_to_tstring(const WCHAR *wstr, tstring& tstr, uint32_t codepage) {
if (wstr == nullptr) {
tstr = _T("");
return 0;
}
#if UNICODE
tstr = std::wstring(wstr);
#else
return wstring_to_string(wstr, tstr, codepage);
#endif
return (unsigned int)tstr.length();
}
tstring wstring_to_tstring(const WCHAR *wstr, uint32_t codepage) {
if (wstr == nullptr) {
return _T("");
}
tstring tstr;
wstring_to_tstring(wstr, tstr, codepage);
return tstr;
}
tstring wstring_to_tstring(const std::wstring& wstr, uint32_t codepage) {
tstring tstr;
wstring_to_tstring(wstr.c_str(), tstr, codepage);
return tstr;
}
#if defined(_WIN32) || defined(_WIN64)
unsigned int char_to_wstring(std::wstring& wstr, const char *str, uint32_t codepage) {
if (str == nullptr) {
wstr = L"";
return 0;
}
int widechar_length = MultiByteToWideChar(codepage, 0, str, -1, nullptr, 0);
wstr.resize(widechar_length, 0);
if (0 == MultiByteToWideChar(codepage, 0, str, -1, &wstr[0], (int)wstr.size())) {
wstr.clear();
return 0;
}
return widechar_length;
}
#else
unsigned int char_to_wstring(std::wstring& wstr, const char *str, uint32_t codepage) {
if (str == nullptr) {
wstr = L"";
return 0;
}
auto ic = iconv_open("wchar_t", "UTF-8"); //to, from
if ((int64_t)ic == -1) {
fprintf(stderr, "iconv_error\n");
}
auto input_len = strlen(str);
std::vector<char> buf(input_len + 1);
strcpy(buf.data(), str);
auto output_len = (input_len + 1) * 8;
std::vector<char> bufout(output_len, 0);
char *inbuf = buf.data();
char *outbuf = bufout.data();
iconv(ic, &inbuf, &input_len, &outbuf, &output_len);
iconv_close(ic);
wstr = std::wstring((WCHAR *)bufout.data());
return wstr.length();
}
#endif //#if defined(_WIN32) || defined(_WIN64)
std::wstring char_to_wstring(const char *str, uint32_t codepage) {
if (str == nullptr) {
return L"";
}
std::wstring wstr;
char_to_wstring(wstr, str, codepage);
return wstr;
}
std::wstring char_to_wstring(const std::string& str, uint32_t codepage) {
std::wstring wstr;
char_to_wstring(wstr, str.c_str(), codepage);
return wstr;
}
unsigned int char_to_tstring(tstring& tstr, const char *str, uint32_t codepage) {
#if UNICODE
return char_to_wstring(tstr, str, codepage);
#else
tstr = (str) ? std::string(str) : _T("");
return (unsigned int)tstr.length();
#endif
}
tstring char_to_tstring(const char *str, uint32_t codepage) {
if (str == nullptr) {
return _T("");
}
tstring tstr;
char_to_tstring(tstr, str, codepage);
return tstr;
}
tstring char_to_tstring(const std::string& str, uint32_t codepage) {
tstring tstr;
char_to_tstring(tstr, str.c_str(), codepage);
return tstr;
}
std::string strsprintf(const char* format, ...) {
if (format == nullptr) {
return "";
}
va_list args;
va_start(args, format);
const size_t len = _vscprintf(format, args) + 1;
std::vector<char> buffer(len, 0);
vsprintf(buffer.data(), format, args);
va_end(args);
std::string retStr = std::string(buffer.data());
return retStr;
}
#if defined(_WIN32) || defined(_WIN64)
std::wstring strsprintf(const WCHAR* format, ...) {
if (format == nullptr) {
return L"";
}
va_list args;
va_start(args, format);
const size_t len = _vscwprintf(format, args) + 1;
std::vector<WCHAR> buffer(len, 0);
vswprintf(buffer.data(), format, args);
va_end(args);
std::wstring retStr = std::wstring(buffer.data());
return retStr;
}
#endif //#if defined(_WIN32) || defined(_WIN64)
std::string str_replace(std::string str, const std::string& from, const std::string& to) {
std::string::size_type pos = 0;
while(pos = str.find(from, pos), pos != std::string::npos) {
str.replace(pos, from.length(), to);
pos += to.length();
}
return std::move(str);
}
#if defined(_WIN32) || defined(_WIN64)
std::wstring str_replace(std::wstring str, const std::wstring& from, const std::wstring& to) {
std::wstring::size_type pos = 0;
while (pos = str.find(from, pos), pos != std::wstring::npos) {
str.replace(pos, from.length(), to);
pos += to.length();
}
return std::move(str);
}
#endif //#if defined(_WIN32) || defined(_WIN64)
#pragma warning (pop)
#if defined(_WIN32) || defined(_WIN64)
std::vector<std::wstring> split(const std::wstring &str, const std::wstring &delim, bool bTrim) {
std::vector<std::wstring> res;
size_t current = 0, found, delimlen = delim.size();
while (std::wstring::npos != (found = str.find(delim, current))) {
auto segment = std::wstring(str, current, found - current);
if (bTrim) {
segment = trim(segment);
}
if (!bTrim || segment.length()) {
res.push_back(segment);
}
current = found + delimlen;
}
auto segment = std::wstring(str, current, str.size() - current);
if (bTrim) {
segment = trim(segment);
}
if (!bTrim || segment.length()) {
res.push_back(std::wstring(segment.c_str()));
}
return res;
}
#endif //#if defined(_WIN32) || defined(_WIN64)
std::vector<std::string> split(const std::string &str, const std::string &delim, bool bTrim) {
std::vector<std::string> res;
size_t current = 0, found, delimlen = delim.size();
while (std::string::npos != (found = str.find(delim, current))) {
auto segment = std::string(str, current, found - current);
if (bTrim) {
segment = trim(segment);
}
if (!bTrim || segment.length()) {
res.push_back(segment);
}
current = found + delimlen;
}
auto segment = std::string(str, current, str.size() - current);
if (bTrim) {
segment = trim(segment);
}
if (!bTrim || segment.length()) {
res.push_back(std::string(segment.c_str()));
}
return res;
}
std::string lstrip(const std::string& string, const char* trim) {
auto result = string;
auto left = string.find_first_not_of(trim);
if (left != std::string::npos) {
result = string.substr(left, 0);
}
return result;
}
std::string rstrip(const std::string& string, const char* trim) {
auto result = string;
auto right = string.find_last_not_of(trim);
if (right != std::string::npos) {
result = string.substr(0, right);
}
return result;
}
std::string trim(const std::string& string, const char* trim) {
auto result = string;
auto left = string.find_first_not_of(trim);
if (left != std::string::npos) {
auto right = string.find_last_not_of(trim);
result = string.substr(left, right - left + 1);
}
return result;
}
std::wstring lstrip(const std::wstring& string, const WCHAR* trim) {
auto result = string;
auto left = string.find_first_not_of(trim);
if (left != std::string::npos) {
result = string.substr(left, 0);
}
return result;
}
std::wstring rstrip(const std::wstring& string, const WCHAR* trim) {
auto result = string;
auto right = string.find_last_not_of(trim);
if (right != std::string::npos) {
result = string.substr(0, right);
}
return result;
}
std::wstring trim(const std::wstring& string, const WCHAR* trim) {
auto result = string;
auto left = string.find_first_not_of(trim);
if (left != std::string::npos) {
auto right = string.find_last_not_of(trim);
result = string.substr(left, right - left + 1);
}
return result;
}
std::string GetFullPath(const char *path) {
#if defined(_WIN32) || defined(_WIN64)
if (PathIsRelativeA(path) == FALSE)
return std::string(path);
#endif //#if defined(_WIN32) || defined(_WIN64)
std::vector<char> buffer(strlen(path) + 1024, 0);
_fullpath(buffer.data(), path, buffer.size());
return std::string(buffer.data());
}
#if defined(_WIN32) || defined(_WIN64)
std::wstring GetFullPath(const WCHAR *path) {
if (PathIsRelativeW(path) == FALSE)
return std::wstring(path);
std::vector<WCHAR> buffer(wcslen(path) + 1024, 0);
_wfullpath(buffer.data(), path, buffer.size());
return std::wstring(buffer.data());
}
//ルートディレクトリを取得
std::string PathGetRoot(const char *path) {
auto fullpath = GetFullPath(path);
std::vector<char> buffer(fullpath.length() + 1, 0);
memcpy(buffer.data(), fullpath.c_str(), fullpath.length() * sizeof(fullpath[0]));
PathStripToRootA(buffer.data());
return buffer.data();
}
std::wstring PathGetRoot(const WCHAR *path) {
auto fullpath = GetFullPath(path);
std::vector<WCHAR> buffer(fullpath.length() + 1, 0);
memcpy(buffer.data(), fullpath.c_str(), fullpath.length() * sizeof(fullpath[0]));
PathStripToRootW(buffer.data());
return buffer.data();
}
//パスのルートが存在するかどうか
static bool PathRootExists(const char *path) {
if (path == nullptr)
return false;
return PathIsDirectoryA(PathGetRoot(path).c_str()) != 0;
}
static bool PathRootExists(const WCHAR *path) {
if (path == nullptr)
return false;
return PathIsDirectoryW(PathGetRoot(path).c_str()) != 0;
}
#endif //#if defined(_WIN32) || defined(_WIN64)
std::pair<int, std::string> PathRemoveFileSpecFixed(const std::string& path) {
const char *ptr = path.c_str();
const char *qtr = PathFindFileNameA(ptr);
if (qtr == ptr) {
return std::make_pair(0, path);
}
std::string newPath = path.substr(0, qtr - ptr - 1);
return std::make_pair((int)(path.length() - newPath.length()), newPath);
}
#if defined(_WIN32) || defined(_WIN64)
std::pair<int, std::wstring> PathRemoveFileSpecFixed(const std::wstring& path) {
const WCHAR *ptr = path.c_str();
WCHAR *qtr = PathFindFileNameW(ptr);
if (qtr == ptr) {
return std::make_pair(0, path);
}
std::wstring newPath = path.substr(0, qtr - ptr - 1);
return std::make_pair((int)(path.length() - newPath.length()), newPath);
}
#endif //#if defined(_WIN32) || defined(_WIN64)
std::string PathRemoveExtensionS(const std::string& path) {
const char *ptr = path.c_str();
const char *qtr = PathFindExtensionA(ptr);
if (qtr == ptr || qtr == nullptr) {
return path;
}
return path.substr(0, qtr - ptr);
}
#if defined(_WIN32) || defined(_WIN64)
std::wstring PathRemoveExtensionS(const std::wstring& path) {
const WCHAR *ptr = path.c_str();
WCHAR *qtr = PathFindExtensionW(ptr);
if (qtr == ptr || qtr == nullptr) {
return path;
}
return path.substr(0, qtr - ptr);
}
std::string PathCombineS(const std::string& dir, const std::string& filename) {
std::vector<char> buffer(dir.length() + filename.length() + 128, '\0');
PathCombineA(buffer.data(), dir.c_str(), filename.c_str());
return std::string(buffer.data());
}
std::wstring PathCombineS(const std::wstring& dir, const std::wstring& filename) {
std::vector<WCHAR> buffer(dir.length() + filename.length() + 128, '\0');
PathCombineW(buffer.data(), dir.c_str(), filename.c_str());
return std::wstring(buffer.data());
}
#endif //#if defined(_WIN32) || defined(_WIN64)
//フォルダがあればOK、なければ作成する
bool CreateDirectoryRecursive(const char *dir) {
if (PathIsDirectoryA(dir)) {
return true;
}
#if defined(_WIN32) || defined(_WIN64)
if (!PathRootExists(dir)) {
return false;
}
#endif //#if defined(_WIN32) || defined(_WIN64)
auto ret = PathRemoveFileSpecFixed(dir);
if (ret.first == 0) {
return false;
}
if (!CreateDirectoryRecursive(ret.second.c_str())) {
return false;
}
return CreateDirectoryA(dir, NULL) != 0;
}
#if defined(_WIN32) || defined(_WIN64)
bool CreateDirectoryRecursive(const WCHAR *dir) {
if (PathIsDirectoryW(dir)) {
return true;
}
if (!PathRootExists(dir)) {
return false;
}
auto ret = PathRemoveFileSpecFixed(dir);
if (ret.first == 0) {
return false;
}
if (!CreateDirectoryRecursive(ret.second.c_str())) {
return false;
}
return CreateDirectoryW(dir, NULL) != 0;
}
#endif //#if defined(_WIN32) || defined(_WIN64)
bool check_ext(const TCHAR *filename, const std::vector<const char*>& ext_list) {
const TCHAR *target = PathFindExtension(filename);
if (target) {
for (auto ext : ext_list) {
if (0 == _tcsicmp(target, char_to_tstring(ext).c_str())) {
return true;
}
}
}
return false;
}
bool check_ext(const tstring& filename, const std::vector<const char*>& ext_list) {
return check_ext(filename.c_str(), ext_list);
}
bool rgy_get_filesize(const char *filepath, uint64_t *filesize) {
#if defined(_WIN32) || defined(_WIN64)
WIN32_FILE_ATTRIBUTE_DATA fd = { 0 };
bool ret = (GetFileAttributesExA(filepath, GetFileExInfoStandard, &fd)) ? true : false;
*filesize = (ret) ? (((UINT64)fd.nFileSizeHigh) << 32) + (UINT64)fd.nFileSizeLow : NULL;
return ret;
#else //#if defined(_WIN32) || defined(_WIN64)
struct stat stat;
FILE *fp = fopen(filepath, "rb");
if (fp == NULL || fstat(fileno(fp), &stat)) {
*filesize = 0;
return 1;
}
if (fp) {
fclose(fp);
}
*filesize = stat.st_size;
return 0;
#endif //#if defined(_WIN32) || defined(_WIN64)
}
#if defined(_WIN32) || defined(_WIN64)
bool rgy_get_filesize(const WCHAR *filepath, uint64_t *filesize) {
WIN32_FILE_ATTRIBUTE_DATA fd = { 0 };
bool ret = (GetFileAttributesExW(filepath, GetFileExInfoStandard, &fd)) ? true : false;
*filesize = (ret) ? (((UINT64)fd.nFileSizeHigh) << 32) + (UINT64)fd.nFileSizeLow : NULL;
return ret;
}
#endif //#if defined(_WIN32) || defined(_WIN64)
tstring print_time(double time) {
int sec = (int)time;
time -= sec;
int miniute = (int)(sec / 60);
sec -= miniute * 60;
int hour = miniute / 60;
miniute -= hour * 60;
tstring frac = strsprintf(_T("%.3f"), time);
return strsprintf(_T("%d:%02d:%02d%s"), hour, miniute, sec, frac.substr(frac.find_first_of(_T("."))).c_str());
}
int rgy_print_stderr(int log_level, const TCHAR *mes, HANDLE handle) {
#if defined(_WIN32) || defined(_WIN64)
CONSOLE_SCREEN_BUFFER_INFO csbi = { 0 };
static const WORD LOG_COLOR[] = {
FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_BLUE, //水色
FOREGROUND_INTENSITY | FOREGROUND_GREEN, //緑
FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,
FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE,
FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED, //黄色
FOREGROUND_INTENSITY | FOREGROUND_RED //赤
};
if (handle == NULL) {
handle = GetStdHandle(STD_ERROR_HANDLE);
}
if (handle && log_level != RGY_LOG_INFO) {
GetConsoleScreenBufferInfo(handle, &csbi);
SetConsoleTextAttribute(handle, LOG_COLOR[clamp(log_level, RGY_LOG_TRACE, RGY_LOG_ERROR) - RGY_LOG_TRACE] | (csbi.wAttributes & 0x00f0));
}
//このfprintfで"%"が消えてしまわないよう置換する
int ret = _ftprintf(stderr, (nullptr == _tcschr(mes, _T('%'))) ? mes : str_replace(tstring(mes), _T("%"), _T("%%")).c_str());
if (handle && log_level != RGY_LOG_INFO) {
SetConsoleTextAttribute(handle, csbi.wAttributes); //元に戻す
}
#else
static const char *const LOG_COLOR[] = {
"\x1b[36m", //水色
"\x1b[32m", //緑
"\x1b[39m", //デフォルト
"\x1b[39m", //デフォルト
"\x1b[33m", //黄色
"\x1b[31m", //赤
};
int ret = _ftprintf(stderr, "%s%s%s", LOG_COLOR[clamp(log_level, RGY_LOG_TRACE, RGY_LOG_ERROR) - RGY_LOG_TRACE], mes, LOG_COLOR[RGY_LOG_INFO - RGY_LOG_TRACE]);
#endif //#if defined(_WIN32) || defined(_WIN64)
fflush(stderr);
return ret;
}
size_t malloc_degeneracy(void **ptr, size_t nSize, size_t nMinSize) {
*ptr = nullptr;
nMinSize = (std::max<size_t>)(nMinSize, 1);
//確保できなかったら、サイズを小さくして再度確保を試みる (最終的に1MBも確保できなかったら諦める)
while (nSize >= nMinSize) {
void *qtr = malloc(nSize);
if (qtr != nullptr) {
*ptr = qtr;
return nSize;
}
size_t nNextSize = 0;
for (size_t i = nMinSize; i < nSize; i<<=1) {
nNextSize = i;
}
nSize = nNextSize;
}
return 0;
}
#if defined(_WIN32) || defined(_WIN64)
#include <Windows.h>
#include <process.h>
#include <VersionHelpers.h>
typedef void (WINAPI *RtlGetVersion_FUNC)(OSVERSIONINFOEXW*);
static int getRealWindowsVersion(DWORD *major, DWORD *minor, DWORD *build) {
*major = 0;
*minor = 0;
OSVERSIONINFOEXW osver;
HMODULE hModule = NULL;
RtlGetVersion_FUNC func = NULL;
int ret = 1;
if ( NULL != (hModule = LoadLibrary(_T("ntdll.dll")))
&& NULL != (func = (RtlGetVersion_FUNC)GetProcAddress(hModule, "RtlGetVersion"))) {
func(&osver);
*major = osver.dwMajorVersion;
*minor = osver.dwMinorVersion;
*build = osver.dwBuildNumber;
ret = 0;
}
if (hModule) {
FreeLibrary(hModule);
}
return ret;
}
#endif //#if defined(_WIN32) || defined(_WIN64)
BOOL check_OS_Win8orLater() {
#if defined(_WIN32) || defined(_WIN64)
#if (_MSC_VER >= 1800)
return IsWindows8OrGreater();
#else
OSVERSIONINFO osvi = { 0 };
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
return ((osvi.dwPlatformId == VER_PLATFORM_WIN32_NT) && ((osvi.dwMajorVersion == 6 && osvi.dwMinorVersion >= 2) || osvi.dwMajorVersion > 6));
#endif //(_MSC_VER >= 1800)
#else //#if defined(_WIN32) || defined(_WIN64)
return FALSE;
#endif //#if defined(_WIN32) || defined(_WIN64)
}
#if defined(_WIN32) || defined(_WIN64)
tstring getOSVersion(OSVERSIONINFOEXW *osinfo) {
const TCHAR *ptr = _T("Unknown");
OSVERSIONINFOW info = { 0 };
OSVERSIONINFOEXW infoex = { 0 };
info.dwOSVersionInfoSize = sizeof(info);
infoex.dwOSVersionInfoSize = sizeof(infoex);
GetVersionExW(&info);
switch (info.dwPlatformId) {
case VER_PLATFORM_WIN32_WINDOWS:
if (4 <= info.dwMajorVersion) {
switch (info.dwMinorVersion) {
case 0: ptr = _T("Windows 95"); break;
case 10: ptr = _T("Windows 98"); break;
case 90: ptr = _T("Windows Me"); break;
default: break;
}
}
break;
case VER_PLATFORM_WIN32_NT:
if (info.dwMajorVersion >= 6 || (info.dwMajorVersion == 5 && info.dwMinorVersion >= 2)) {
GetVersionExW((OSVERSIONINFOW *)&infoex);
} else {
memcpy(&infoex, &info, sizeof(info));
}
if (info.dwMajorVersion == 6) {
getRealWindowsVersion(&infoex.dwMajorVersion, &infoex.dwMinorVersion, &infoex.dwBuildNumber);
}
if (osinfo) {
memcpy(osinfo, &infoex, sizeof(infoex));
}
switch (infoex.dwMajorVersion) {
case 3:
switch (infoex.dwMinorVersion) {
case 0: ptr = _T("Windows NT 3"); break;
case 1: ptr = _T("Windows NT 3.1"); break;
case 5: ptr = _T("Windows NT 3.5"); break;
case 51: ptr = _T("Windows NT 3.51"); break;
default: break;
}
break;
case 4:
if (0 == infoex.dwMinorVersion)
ptr = _T("Windows NT 4.0");
break;
case 5:
switch (infoex.dwMinorVersion) {
case 0: ptr = _T("Windows 2000"); break;
case 1: ptr = _T("Windows XP"); break;
case 2: ptr = _T("Windows Server 2003"); break;
default: break;
}
break;
case 6:
switch (infoex.dwMinorVersion) {
case 0: ptr = (infoex.wProductType == VER_NT_WORKSTATION) ? _T("Windows Vista") : _T("Windows Server 2008"); break;
case 1: ptr = (infoex.wProductType == VER_NT_WORKSTATION) ? _T("Windows 7") : _T("Windows Server 2008 R2"); break;
case 2: ptr = (infoex.wProductType == VER_NT_WORKSTATION) ? _T("Windows 8") : _T("Windows Server 2012"); break;
case 3: ptr = (infoex.wProductType == VER_NT_WORKSTATION) ? _T("Windows 8.1") : _T("Windows Server 2012 R2"); break;
case 4: ptr = (infoex.wProductType == VER_NT_WORKSTATION) ? _T("Windows 10") : _T("Windows Server 2016"); break;
default:
if (5 <= infoex.dwMinorVersion) {
ptr = _T("Later than Windows 10");
}
break;
}
break;
case 10:
ptr = (infoex.wProductType == VER_NT_WORKSTATION) ? _T("Windows 10") : _T("Windows Server 2016"); break;
default:
if (10 <= infoex.dwMajorVersion) {
ptr = _T("Later than Windows 10");
}
break;
}
break;
default:
break;
}
return tstring(ptr);
#else //#if defined(_WIN32) || defined(_WIN64)
tstring getOSVersion() {
std::string str = "";
FILE *fp = popen("/usr/bin/lsb_release -a", "r");
if (fp != NULL) {
char buffer[2048];
while (NULL != fgets(buffer, _countof(buffer), fp)) {
str += buffer;
}
pclose(fp);
if (str.length() > 0) {
auto sep = split(str, "\n");
for (auto line : sep) {
if (line.find("Description") != std::string::npos) {
std::string::size_type pos = line.find(":");
if (pos == std::string::npos) {
pos = std::string("Description").length();
}
pos++;
str = line.substr(pos);
break;
}
}
}
}
if (str.length() == 0) {
struct utsname buf;
uname(&buf);
str += buf.sysname;
str += " ";
str += buf.release;
}
return char_to_tstring(trim(str));
#endif //#if defined(_WIN32) || defined(_WIN64)
}
BOOL rgy_is_64bit_os() {
#if defined(_WIN32) || defined(_WIN64)
SYSTEM_INFO sinfo = { 0 };
GetNativeSystemInfo(&sinfo);
return sinfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64;
#else //#if defined(_WIN32) || defined(_WIN64)
struct utsname buf;
uname(&buf);
return NULL != strstr(buf.machine, "x64")
|| NULL != strstr(buf.machine, "x86_64")
|| NULL != strstr(buf.machine, "amd64");
#endif //#if defined(_WIN32) || defined(_WIN64)
}
uint64_t getPhysicalRamSize(uint64_t *ramUsed) {
#if defined(_WIN32) || defined(_WIN64)
MEMORYSTATUSEX msex ={ 0 };
msex.dwLength = sizeof(msex);
GlobalMemoryStatusEx(&msex);
if (NULL != ramUsed) {
*ramUsed = msex.ullTotalPhys - msex.ullAvailPhys;
}
return msex.ullTotalPhys;
#else //#if defined(_WIN32) || defined(_WIN64)
struct sysinfo info;
sysinfo(&info);
if (NULL != ramUsed) {
*ramUsed = info.totalram - info.freeram;
}
return info.totalram;
#endif //#if defined(_WIN32) || defined(_WIN64)
}
tstring getEnviromentInfo(bool add_ram_info) {
tstring buf;
TCHAR cpu_info[1024] = { 0 };
getCPUInfo(cpu_info, _countof(cpu_info));
TCHAR gpu_info[1024] = { 0 };
getGPUInfo(GPU_VENDOR, gpu_info, _countof(gpu_info));
uint64_t UsedRamSize = 0;
uint64_t totalRamsize = getPhysicalRamSize(&UsedRamSize);
buf += _T("Environment Info\n");
#if defined(_WIN32) || defined(_WIN64)
OSVERSIONINFOEXW osversioninfo = { 0 };
tstring osversionstr = getOSVersion(&osversioninfo);
buf += strsprintf(_T("OS : %s %s (%d)\n"), osversionstr.c_str(), rgy_is_64bit_os() ? _T("x64") : _T("x86"), osversioninfo.dwBuildNumber);
#else
buf += strsprintf(_T("OS : %s %s\n"), getOSVersion().c_str(), rgy_is_64bit_os() ? _T("x64") : _T("x86"));
#endif
buf += strsprintf(_T("CPU: %s\n"), cpu_info);
if (add_ram_info) {
cpu_info_t cpuinfo;
get_cpu_info(&cpuinfo);
auto write_rw_speed = [&](const TCHAR *type, int test_size) {
if (test_size) {
auto ram_read_speed_list = ram_speed_mt_list(test_size, RAM_SPEED_MODE_READ);
auto ram_write_speed_list = ram_speed_mt_list(test_size, RAM_SPEED_MODE_WRITE);
double max_read = *std::max_element(ram_read_speed_list.begin(), ram_read_speed_list.end()) * (1.0 / 1024.0);
double max_write = *std::max_element(ram_write_speed_list.begin(), ram_write_speed_list.end()) * (1.0 / 1024.0);
buf += strsprintf(_T("%s: Read:%7.2fGB/s, Write:%7.2fGB/s\n"), type, max_read, max_write);
}
return test_size > 0;
};
add_ram_info = false;
add_ram_info |= write_rw_speed(_T("L1 "), cpuinfo.caches[0].size / 1024 / 8);
add_ram_info |= write_rw_speed(_T("L2 "), cpuinfo.caches[1].size / 1024 / 2);
add_ram_info |= write_rw_speed(_T("L3 "), cpuinfo.caches[2].size / 1024 / 2);
add_ram_info |= write_rw_speed(_T("RAM"), (cpuinfo.max_cache_level) ? cpuinfo.caches[cpuinfo.max_cache_level-1].size / 1024 * 8 : 96 * 1024);
}
buf += strsprintf(_T("%s Used %d MB, Total %d MB\n"), (add_ram_info) ? _T(" ") : _T("RAM:"), (uint32_t)(UsedRamSize >> 20), (uint32_t)(totalRamsize >> 20));
buf += strsprintf(_T("GPU: %s\n"), gpu_info);
return buf;
}
struct sar_option_t {
int key;
int sar[2];
};
static const sar_option_t SAR_LIST[] = {
{ 0, { 0, 0 } },
{ 1, { 1, 1 } },
{ 2, { 12, 11 } },
{ 3, { 10, 11 } },
{ 4, { 16, 11 } },
{ 5, { 40, 33 } },
{ 6, { 24, 11 } },
{ 7, { 20, 11 } },
{ 8, { 32, 11 } },
{ 9, { 80, 33 } },
{ 10, { 18, 11 } },
{ 11, { 15, 11 } },
{ 12, { 64, 33 } },
{ 13, {160, 99 } },
{ 14, { 4, 3 } },
{ 15, { 3, 2 } },
{ 16, { 2, 1 } }
};
std::pair<int, int> get_h264_sar(int idx) {
for (int i = 0; i < _countof(SAR_LIST); i++) {
if (SAR_LIST[i].key == idx)
return std::make_pair(SAR_LIST[i].sar[0], SAR_LIST[i].sar[1]);
}
return std::make_pair(0, 0);
}
int get_h264_sar_idx(std::pair<int, int> sar) {
if (0 != sar.first && 0 != sar.second) {
rgy_reduce(sar);
}
for (int i = 0; i < _countof(SAR_LIST); i++) {
if (SAR_LIST[i].sar[0] == sar.first && SAR_LIST[i].sar[1] == sar.second) {
return SAR_LIST[i].key;
}
}
return -1;
}
void adjust_sar(int *sar_w, int *sar_h, int width, int height) {
int aspect_w = *sar_w;
int aspect_h = *sar_h;
//正負チェック
if (aspect_w * aspect_h <= 0)
aspect_w = aspect_h = 0;
else if (aspect_w < 0) {
//負で与えられている場合はDARでの指定
//SAR比に変換する
int dar_x = -1 * aspect_w;
int dar_y = -1 * aspect_h;
int x = dar_x * height;
int y = dar_y * width;
//多少のづれは容認する
if (abs(y - x) > 16 * dar_y) {
//gcd
int a = x, b = y, c;
while ((c = a % b) != 0)
a = b, b = c;
*sar_w = x / b;
*sar_h = y / b;
} else {
*sar_w = *sar_h = 1;
}
} else {
//sarも一応gcdをとっておく
int a = aspect_w, b = aspect_h, c;
while ((c = a % b) != 0)
a = b, b = c;
*sar_w = aspect_w / b;
*sar_h = aspect_h / b;
}
}
void get_dar_pixels(unsigned int* width, unsigned int* height, int sar_w, int sar_h) {
int w = *width;
int h = *height;
if (0 != (w * h * sar_w * sar_h)) {
int x = w * sar_w;
int y = h * sar_h;
int a = x, b = y, c;
while ((c = a % b) != 0)
a = b, b = c;
x /= b;
y /= b;
const double ratio = (sar_w >= sar_h) ? h / (double)y : w / (double)x;
*width = (int)(x * ratio + 0.5);
*height = (int)(y * ratio + 0.5);
}
}
std::pair<int, int> get_sar(unsigned int width, unsigned int height, unsigned int darWidth, unsigned int darHeight) {
int x = darWidth * height;
int y = darHeight * width;
int a = x, b = y, c;
while ((c = a % b) != 0)
a = b, b = c;
return std::make_pair<int, int>(x / b, y / b);
}
#include "rgy_simd.h"
#include <immintrin.h>
RGY_NOINLINE int rgy_avx_dummy_if_avail(int bAVXAvail) {
int ret = 1;
if (bAVXAvail) {
return ret;
}
__m256 y0 = _mm256_castsi256_ps(_mm256_castsi128_si256(_mm_cvtsi32_si128(bAVXAvail)));
y0 = _mm256_xor_ps(y0, y0);
ret = _mm_cvtsi128_si32(_mm256_castsi256_si128(_mm256_castps_si256(y0)));
_mm256_zeroupper();
return ret;
}
|
; A081343: a(n) = (10^n + 4^n)/2.
; 1,7,58,532,5128,50512,502048,5008192,50032768,500131072,5000524288,50002097152,500008388608,5000033554432,50000134217728,500000536870912,5000002147483648,50000008589934592,500000034359738368,5000000137438953472,50000000549755813888,500000002199023255552,5000000008796093022208,50000000035184372088832,500000000140737488355328,5000000000562949953421312,50000000002251799813685248,500000000009007199254740992,5000000000036028797018963968,50000000000144115188075855872,500000000000576460752303423488
mov $1,4
pow $1,$0
mov $2,10
pow $2,$0
add $1,$2
mov $0,$1
div $0,2
|
; A236916: The first "octad" is 0, 1, 2, 2, 2, 2, 3, 3; thereafter add 4 to get the next octad.
; 0,1,2,2,2,2,3,3,4,5,6,6,6,6,7,7,8,9,10,10,10,10,11,11,12,13,14,14,14,14,15,15,16,17,18,18,18,18,19,19,20,21,22,22,22,22,23,23,24,25,26,26,26,26,27,27,28,29,30,30,30,30,31,31,32,33,34,34,34,34,35,35,36,37,38,38,38,38,39,39,40,41,42,42
add $0,2
mov $2,4
add $2,$0
mov $3,$2
lpb $0
trn $0,4
mov $1,4
sub $1,$0
sub $0,1
trn $0,3
trn $1,1
add $1,1
sub $3,4
lpe
add $1,$3
sub $1,6
|
BITS 32
;TEST_FILE_META_BEGIN
;TEST_TYPE=TEST_F
;TEST_IGNOREFLAGS=
;TEST_FILE_META_END
; convert 1 to a single precision float and store in xmm0
mov ecx, 1
cvtsi2ss xmm0, ecx
;TEST_BEGIN_RECORDING
; load 1 in single floating point form
lea ecx, [esp-8]
movss [ecx], xmm0
; value should appear in eax for testing
mov eax, [ecx]
mov ecx, 0
;TEST_END_RECORDING
xor ecx, ecx
cvtsi2ss xmm0, ecx
cvtsi2ss xmm1, ecx
|
//------------------------------------
// parse.cpp
// (c) Bartosz Milewski, 1994
//------------------------------------
#include "parse.h"
#include "scan.h"
#include "tree.h"
#include "symtab.h"
#include "store.h"
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
Parser::Parser (Scanner & scanner,
Store & store,
FunctionTable & funTab,
SymbolTable & symTab )
: _scanner (scanner),
_pTree (0),
_status (stOk),
_funTab (funTab),
_store (store),
_symTab (symTab)
{
}
Parser::~Parser ()
{
delete _pTree;
}
Status Parser::Eval ()
{
Parse ();
if (_status == stOk)
Execute ();
else
_status = stQuit;
return _status;
}
void Parser::Execute ()
{
if (_pTree)
{
double result = _pTree->Calc ();
cout << " " << result << endl;
}
}
void Parser::Parse ()
{
_pTree = Expr ();
}
Node * Parser::Expr()
{
Node * pNode = Term ();
EToken token = _scanner.Token ();
if (token == tPlus)
{
_scanner.Accept ();
Node * pRight = Expr ();
pNode = new AddNode (pNode, pRight);
}
else if (token == tMinus)
{
_scanner.Accept ();
Node * pRight = Expr ();
pNode = new SubNode (pNode, pRight);
}
else if (token == tAssign)
{
_scanner.Accept ();
Node * pRight = Expr ();
if (pNode->IsLvalue ())
{
pNode = new AssignNode (pNode, pRight);
}
else
{
_status = stError;
delete pNode;
pNode = Expr ();
}
}
return pNode;
}
Node * Parser::Term ()
{
Node * pNode = Factor ();
if (_scanner.Token () == tMult)
{
_scanner.Accept ();
Node * pRight = Term ();
pNode = new MultNode (pNode, pRight);
}
else if (_scanner.Token() == tDivide)
{
_scanner.Accept ();
Node * pRight = Term ();
pNode = new DivideNode (pNode, pRight);
}
return pNode;
}
Node * Parser::Factor ()
{
Node * pNode;
EToken token = _scanner.Token ();
if (token == tLParen)
{
_scanner.Accept (); // accept '('
pNode = Expr ();
if (_scanner.Token () != tRParen)
_status = stError;
_scanner.Accept (); // accept ')'
}
else if (token == tNumber)
{
pNode = new NumNode (_scanner.Number ());
_scanner.Accept ();
}
else if (token == tIdent)
{
char strSymbol [maxSymLen];
int lenSym = maxSymLen;
// copy the symbol into strSymbol
_scanner.GetSymbolName (strSymbol, lenSym);
int id = _symTab.Find (strSymbol, lenSym);
_scanner.Accept ();
if (_scanner.Token () == tLParen) // function call
{
_scanner.Accept (); // accept '('
pNode = Expr ();
if (_scanner.Token () == tRParen)
_scanner.Accept (); // accept ')'
else
_status = stError;
if (id != idNotFound && id < _funTab.Size ())
{
pNode = new FunNode (
_funTab.GetFun (id), pNode);
}
else
{
cout << "Unknown function \"";
cout << strSymbol << "\"" << endl;
}
}
else
{
if (id == idNotFound)
id = _symTab.ForceAdd (strSymbol, lenSym);
pNode = new VarNode (id, _store);
}
}
else if (token == tMinus) // unary minus
{
_scanner.Accept (); // accept minus
pNode = new UMinusNode (Factor ());
}
else
{
_scanner.Accept ();
_status = stError;
pNode = 0;
}
return pNode;
}
const int maxBuf = 100;
const int maxSymbols = 40;
int main ()
{
// Notice all these local objects.
// A clear sign that there should be
// a top level object, say, the Calculator.
// Back to the drawing board!
char buf [maxBuf];
Status status;
SymbolTable symTab (maxSymbols);
FunctionTable funTab (symTab, funArr);
Store store (maxSymbols, symTab);
do
{
cout << "> "; // prompt
cin.getline (buf, maxBuf);
Scanner scanner (buf);
Parser parser (scanner, store, funTab, symTab);
Parser parser2 (parser);
status = parser.Eval ();
} while (status != stQuit);
return 0;
}
|
; A047470: Numbers that are congruent to {0, 3} mod 8.
; 0,3,8,11,16,19,24,27,32,35,40,43,48,51,56,59,64,67,72,75,80,83,88,91,96,99,104,107,112,115,120,123,128,131,136,139,144,147,152,155,160,163,168,171,176,179,184,187,192,195,200,203,208,211,216,219,224,227,232,235,240,243,248,251,256,259,264,267,272,275,280,283,288,291,296,299,304,307,312,315,320,323,328,331,336,339,344,347,352,355,360,363,368,371,376,379,384,387,392,395,400,403,408,411,416,419,424,427,432,435,440,443,448,451,456,459,464,467,472,475,480,483,488,491,496,499,504,507,512,515,520,523,528,531,536,539,544,547,552,555,560,563,568,571,576,579,584,587,592,595,600,603,608,611,616,619,624,627,632,635,640,643,648,651,656,659,664,667,672,675,680,683,688,691,696,699,704,707,712,715,720,723,728,731,736,739,744,747,752,755,760,763,768,771,776,779,784,787,792,795,800,803,808,811,816,819,824,827,832,835,840,843,848,851,856,859,864,867,872,875,880,883,888,891,896,899,904,907,912,915,920,923,928,931,936,939,944,947,952,955,960,963,968,971,976,979,984,987,992,995
mov $1,4
mul $1,$0
mod $0,2
sub $1,$0
|
;
; Sound effects driver for GB
;
; Copyright 2018, 2019 Damian Yerrick
;
; This software is provided 'as-is', without any express or implied
; warranty. In no event will the authors be held liable for any damages
; arising from the use of this software.
;
; Permission is granted to anyone to use this software for any purpose,
; including commercial applications, and to alter it and redistribute it
; freely, subject to the following restrictions:
;
; 1. The origin of this software must not be misrepresented; you must not
; claim that you wrote the original software. If you use this software
; in a product, an acknowledgment in the product documentation would be
; appreciated but is not required.
; 2. Altered source versions must be plainly marked as such, and must not be
; misrepresented as being the original software.
; 3. This notice may not be removed or altered from any source distribution.
;
; Alterations made by Dave VanEe:
; - New sound effect data for Shock Lobster, replacing Libbet sounds
; - Additional comments regarding the structure of the sfx_table
; - Additional comments detailing the quick/deep/pitch paramters for
; sound effects
; - Addition of duty and volume envelope defines to streamline effect
; definition
; - Muting/unmuting of hUGEDriver channels during sound effect playback
; - Change from using Libbet's pitch_table to hUGEDriver's note_table
; - Removal of global.inc import (used for sharing of local HRAM variables)
; - Commented out unused wavebank data
include "hardware.inc/hardware.inc"
;include "src/global.inc"
LOG_SIZEOF_CHANNEL equ 3
LOG_SIZEOF_SFX equ 2
NUM_CHANNELS equ 4
ENVB_DPAR equ 5
ENVB_PITCH equ 4
ENVF_QPAR equ $C0
ENVF_DPAR equ $20
ENVF_PITCH equ $10
ENVF_DURATION equ $0F
section "audio_wram", WRAM0, ALIGN[LOG_SIZEOF_CHANNEL]
audio_channels: ds NUM_CHANNELS << LOG_SIZEOF_CHANNEL
Channel_envseg_cd = 0
Channel_envptr = 1
Channel_envpitch = 3
section "wavebank", ROM0, ALIGN[4]
wavebank:
; DVE: Commented out since it's unused
;db $FF,$EE,$DD,$CC,$BB,$AA,$99,$88,$77,$66,$55,$44,$33,$22,$11,$00
; Notes on sfx_table:
; - First byte is the channel to use for the effect (0-4)
; - Second byte is currently padding so each table entry is 4 bytes
; - Final word is the address of the effect segments
SECTION "Sound Effect Index", ROM0
; The battle music tries to leave ch0 open as much as possible so we can
; use it for SFX without clobbering the music. In cases where we want SFX
; to not clobber each other we resort to ch1 for them, giving up music
; to ensure the SFX is heard (clarity being the main example).
sfx_table:
db 0, 0
dw fx_jet
db 0, 0
dw fx_jet_upgraded
db 0, 0
dw fx_zap
db 3, 0
dw fx_discharge
db 0, 0
dw fx_shock
db 0, 0
dw fx_empower
db 3, 0
dw fx_electrify
db 0, 0
dw fx_focus
db 0, 0
dw fx_invigorate
db 1, 0 ; played on channel 1 since it's uncommon and shouldn't overlap skill FX
dw fx_clarity
db 0, 0
dw fx_first_strike
db 0, 0
dw fx_blitz
db 3, 0
dw fx_final_word
db 0, 0
dw fx_second_wind
db 0, 0
dw fx_pearl
db 1, 0 ; played on channel 1 since it's uncommon and shouldn't overlap skill FX
dw fx_enemy_defeated
db 0, 0
dw fx_venture_forth
db 0, 0
dw fx_start_battle
db 0, 0
dw fx_descr_show
db 0, 0
dw fx_descr_hide
db 0, 0
dw fx_cursor_move
db 0, 0
dw fx_confirm
db 0, 0
dw fx_cancel
db 0, 0
dw fx_unlock
db 0, 0
dw fx_error
db 0, 0
dw fx_pause
db 0, 0
dw fx_unpause
SECTION "Sound Effect Data", ROM0
sgb_sfx_table:
; To be filled in later
; Notes on FX:
; - Each sound effect is comprised of segments
; - There are up to 3 possible bytes for a segment:
; - The first byte contains the 'quick parameter' as well as flags
; indicating if deep paramter and/or pitch bytes are present
; - The second/third bytes are the deep parameter and pitch, in that
; order, if their flags are set (ENVF_DPAR and ENVF_PITCH)
; - Segment events with values from $F0-$FF are 'special', but all of them
; just end the effect right now and act like $FF
; - The noise channel has no quick parameter (only a deep parameter and pitch),
; although the duration is still used to decide when to advance segments
; - Although pulse 1 & 2 channels allow for 6 bits of length in the sound
; registers, only 4 bits are exposed in this sound effect driver
; - The sweep feature is disabled for channel, making channel 1 & 2
; essentially identical.
; Pulse 1 channel:
; - Quick parameter: Duty (rNR11)
; 7654 3210
; ||||-++++- Sound length data
; |||+------ Pitch flag (ENVF_PITCH)
; ||+------- Deep parameter flag (ENVF_DPAR)
; ++-------- Wave pattern duty (12.5%, 25%, 50%, 75%)
; - Deep parameter: Volume envelope (rNR12)
; 7654 3210
; ||||-|+++- Envelope sweep speed
; ||||-+---- Envelope direction
; ++++------ Initial envelope volume
; - Pitch:
; Pulse 2 channel:
; - Quick parameter: Duty (rNR21)
; 7654 3210
; ||||-++++- Sound length data
; |||+------ Pitch flag (ENVF_PITCH)
; ||+------- Deep parameter flag (ENVF_DPAR)
; ++-------- Wave pattern duty (12.5%, 25%, 50%, 75%)
; - Deep parameter: Volume envelope (rNR22)
; 7654 3210
; ||||-|+++- Envelope sweep speed
; ||||-+---- Envelope direction
; ++++------ Initial envelope volume
; - Pitch:
; Wave channel:
; - Quick parameter: Volume
; 7654 3210
; ||||-||++- Volume level (0%, 100%, 50%, 25%) (NR32 bits 6-5)
; ||||-++--- Unused (???)
; |||+------ Pitch flag (ENVF_PITCH)
; ||+------- Deep parameter flag (ENVF_DPAR)
; - Deep parameter: New wave data to copy (index, I think?)
; - Pitch: Lower 8 bits of 11 bit frequency (rNR33)
; Noise channel:
; - Quick parameter: Duration only
; 7654 3210
; ||||-++++- Sound length data
; ++++------ Unused
; - Deep parameter: Volume envelope sweep + shift clock frequency (rNR42)
; 7654 3210
; ||||-|+++- Frequency dividing ratio
; ||||-+---- Width (7bit or 16bit)
; ++++------ Shift clock frequency
; - Pitch: (rNR43)
; Defines to help with effect creation (added by Dave Van Ee)
; Pulse Channels
DEF DUTY_12_5 EQU $00
DEF DUTY_25 EQU $40
DEF DUTY_50 EQU $80
DEF DUTY_75 EQU $C0
DEF VOLUME_ENVELOPE_DECREASE EQU $00
DEF VOLUME_ENVELOPE_INCREASE EQU $08
DEF VOLUME_ENVELOPE_SPEED_0 EQU $00
DEF VOLUME_ENVELOPE_SPEED_1 EQU $01
DEF VOLUME_ENVELOPE_SPEED_2 EQU $02
DEF VOLUME_ENVELOPE_SPEED_3 EQU $03
DEF VOLUME_ENVELOPE_SPEED_4 EQU $04
DEF VOLUME_ENVELOPE_SPEED_5 EQU $05
DEF VOLUME_ENVELOPE_SPEED_6 EQU $06
DEF VOLUME_ENVELOPE_SPEED_7 EQU $07
; Wave Channel
; Noise Channel
; Shock Lobster sounds
; These are sorted by which channel they're used with to make
; understanding the values easier.
; channel 1&2 (pulse)
fx_jet:
DEF BASE_PITCH EQU 19
db ENVF_DPAR|ENVF_PITCH|DUTY_50|0, $59, BASE_PITCH
db ENVF_PITCH|DUTY_50|0, BASE_PITCH+2
db ENVF_PITCH|DUTY_50|0, BASE_PITCH+3
db ENVF_DPAR|ENVF_PITCH|DUTY_50|0, $81, BASE_PITCH+4
db ENVF_PITCH|DUTY_50|0, BASE_PITCH+5
db ENVF_PITCH|DUTY_50|0, BASE_PITCH+7
PURGE BASE_PITCH
db $FF
fx_jet_upgraded:
DEF BASE_PITCH EQU 24
db ENVF_DPAR|ENVF_PITCH|DUTY_50|0, $59, BASE_PITCH
db ENVF_PITCH|DUTY_50|0, BASE_PITCH+2
db ENVF_PITCH|DUTY_50|0, BASE_PITCH+3
db ENVF_DPAR|ENVF_PITCH|DUTY_50|0, $81, BASE_PITCH+4
db ENVF_PITCH|DUTY_50|0, BASE_PITCH+5
db ENVF_PITCH|DUTY_50|0, BASE_PITCH+7
db ENVF_PITCH|DUTY_50|0, BASE_PITCH+9
db ENVF_PITCH|DUTY_50|0, BASE_PITCH+11
PURGE BASE_PITCH
db $FF
fx_zap:
DEF BASE_PITCH EQU 38
db ENVF_DPAR|ENVF_PITCH|DUTY_50|3, $78, BASE_PITCH
db ENVF_PITCH|DUTY_50|2, BASE_PITCH+1
db ENVF_PITCH|DUTY_50|1, BASE_PITCH-2
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $7B, BASE_PITCH+5
PURGE BASE_PITCH
db $FF
fx_shock:
DEF BASE_PITCH EQU 80
db ENVF_DPAR|ENVF_PITCH|DUTY_50|1, $59, BASE_PITCH
db ENVF_PITCH|DUTY_50|1, BASE_PITCH-10
db ENVF_PITCH|DUTY_50|1, BASE_PITCH-6
db ENVF_PITCH|DUTY_50|1, BASE_PITCH-16
db ENVF_PITCH|DUTY_50|1, BASE_PITCH-12
db ENVF_PITCH|DUTY_50|1, BASE_PITCH-22
PURGE BASE_PITCH
db $FF
fx_empower:
DEF BASE_PITCH EQU 20
db ENVF_DPAR|ENVF_PITCH|DUTY_50|3, $59, BASE_PITCH
db ENVF_PITCH|DUTY_50|3, BASE_PITCH+10
db ENVF_PITCH|DUTY_50|3, BASE_PITCH+15
db ENVF_PITCH|DUTY_50|3, BASE_PITCH+20
db ENVF_PITCH|DUTY_50|3, BASE_PITCH+15
db ENVF_PITCH|DUTY_50|3, BASE_PITCH+20
db ENVF_PITCH|DUTY_50|3, BASE_PITCH+25
db ENVF_PITCH|DUTY_50|3, BASE_PITCH+20
db ENVF_PITCH|DUTY_50|3, BASE_PITCH+25
db ENVF_PITCH|DUTY_50|3, BASE_PITCH+30
PURGE BASE_PITCH
db $FF
fx_focus:
DEF BASE_PITCH EQU 40
db ENVF_DPAR|ENVF_PITCH|DUTY_25|1, $F1, BASE_PITCH
db ENVF_DPAR|ENVF_PITCH|DUTY_25|1, $F1, BASE_PITCH+9
db ENVF_DPAR|ENVF_PITCH|DUTY_25|1, $F1, BASE_PITCH-4
db ENVF_DPAR|ENVF_PITCH|DUTY_25|1, $F1, BASE_PITCH-5
db ENVF_DPAR|ENVF_PITCH|DUTY_25|1, $F1, BASE_PITCH-5+9
db ENVF_DPAR|ENVF_PITCH|DUTY_25|1, $F1, BASE_PITCH-5-4
db ENVF_DPAR|ENVF_PITCH|DUTY_25|1, $F1, BASE_PITCH+7
db ENVF_DPAR|ENVF_PITCH|DUTY_25|1, $F1, BASE_PITCH+7+9
db ENVF_DPAR|ENVF_PITCH|DUTY_25|1, $F1, BASE_PITCH+7-4
PURGE BASE_PITCH
db $FF
fx_invigorate:
DEF BASE_PITCH EQU 50
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $E3, BASE_PITCH
db ENVF_PITCH|DUTY_50|4, BASE_PITCH+2
db ENVF_PITCH|DUTY_50|4, BASE_PITCH+4
db ENVF_PITCH|DUTY_50|4, BASE_PITCH+2
db ENVF_PITCH|DUTY_50|4, BASE_PITCH+4
db ENVF_PITCH|DUTY_50|4, BASE_PITCH+6
PURGE BASE_PITCH
db $FF
fx_clarity:
db ENVF_DPAR|ENVF_PITCH|DUTY_50|$0, $F1, 45
db ENVF_PITCH|DUTY_50|$0, 49
db ENVF_PITCH|DUTY_50|$2, 60
db ENVF_PITCH|DUTY_50|$3, 55
db ENVF_PITCH|DUTY_50|$3, 55
db $FF
fx_first_strike:
DEF BASE_PITCH EQU 25
db ENVF_DPAR|ENVF_PITCH|DUTY_25|3, $F1, BASE_PITCH
db ENVF_DPAR|ENVF_PITCH|DUTY_25|3, $F1, BASE_PITCH+9
db ENVF_DPAR|ENVF_PITCH|DUTY_25|3, $F1, BASE_PITCH+4
db ENVF_DPAR|ENVF_PITCH|DUTY_25|3, $F1, BASE_PITCH+3
db ENVF_DPAR|ENVF_PITCH|DUTY_25|3, $F1, BASE_PITCH+3+9
db ENVF_DPAR|ENVF_PITCH|DUTY_25|3, $F1, BASE_PITCH+3+4
PURGE BASE_PITCH
db $FF
fx_blitz:
DEF BASE_PITCH EQU 25
db ENVF_DPAR|ENVF_PITCH|DUTY_25|2, $F1, BASE_PITCH
db ENVF_DPAR|ENVF_PITCH|DUTY_25|2, $F1, BASE_PITCH+9
db ENVF_DPAR|ENVF_PITCH|DUTY_25|2, $F1, BASE_PITCH+4
db ENVF_DPAR|ENVF_PITCH|DUTY_25|2, $F1, BASE_PITCH-3
db ENVF_DPAR|ENVF_PITCH|DUTY_25|2, $F1, BASE_PITCH-3+9
db ENVF_DPAR|ENVF_PITCH|DUTY_25|2, $F1, BASE_PITCH-3+4
db ENVF_DPAR|ENVF_PITCH|DUTY_25|2, $F1, BASE_PITCH+6
db ENVF_DPAR|ENVF_PITCH|DUTY_25|2, $F1, BASE_PITCH+6+9
db ENVF_DPAR|ENVF_PITCH|DUTY_25|2, $F1, BASE_PITCH+6+4
PURGE BASE_PITCH
db $FF
fx_second_wind:
DEF BASE_PITCH EQU 27
db ENVF_DPAR|ENVF_PITCH|DUTY_50|5, $F9, BASE_PITCH
db ENVF_DPAR|DUTY_50|1, 0
db ENVF_DPAR|ENVF_PITCH|DUTY_50|5, $F9, BASE_PITCH
db ENVF_DPAR|DUTY_50|1, 0
db ENVF_DPAR|ENVF_PITCH|DUTY_50|3, $F9, BASE_PITCH+5
db ENVF_PITCH|DUTY_50|3, BASE_PITCH+7
db ENVF_PITCH|DUTY_50|3, BASE_PITCH+10
db ENVF_PITCH|DUTY_50|3, BASE_PITCH+14
db ENVF_PITCH|DUTY_50|3, BASE_PITCH+19
db ENVF_PITCH|DUTY_50|2, BASE_PITCH+1
db ENVF_PITCH|DUTY_50|2, BASE_PITCH+5
db ENVF_PITCH|DUTY_50|2, BASE_PITCH+11
db ENVF_PITCH|DUTY_50|2, BASE_PITCH+19
db ENVF_PITCH|DUTY_50|2, BASE_PITCH+27
PURGE BASE_PITCH
db $FF
fx_pearl:
DEF BASE_PITCH EQU 35
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $71, BASE_PITCH
db ENVF_DPAR|ENVF_PITCH|DUTY_50|8, $71, BASE_PITCH+5
PURGE BASE_PITCH
db $FF
fx_enemy_defeated:
DEF BASE_PITCH EQU 15
db ENVF_DPAR|ENVF_PITCH|DUTY_50|5, $F9, BASE_PITCH
db ENVF_PITCH|DUTY_50|4, BASE_PITCH+4
db ENVF_PITCH|DUTY_50|3, BASE_PITCH+8
db ENVF_PITCH|DUTY_50|5, BASE_PITCH+2
db ENVF_PITCH|DUTY_50|4, BASE_PITCH+6
db ENVF_PITCH|DUTY_50|3, BASE_PITCH+10
db ENVF_PITCH|DUTY_50|5, BASE_PITCH+4
db ENVF_PITCH|DUTY_50|4, BASE_PITCH+8
db ENVF_PITCH|DUTY_50|5, BASE_PITCH+12
PURGE BASE_PITCH
db $FF
fx_venture_forth:
DEF BASE_PITCH EQU 20
db ENVF_DPAR|ENVF_PITCH|DUTY_50|6, $59, BASE_PITCH
db ENVF_PITCH|DUTY_50|6, BASE_PITCH+5
db ENVF_PITCH|DUTY_50|4, BASE_PITCH+0
db ENVF_PITCH|DUTY_50|4, BASE_PITCH+2
db ENVF_PITCH|DUTY_50|10, BASE_PITCH+10
PURGE BASE_PITCH
db $FF
fx_start_battle:
DEF BASE_PITCH EQU 25
db ENVF_DPAR|ENVF_PITCH|DUTY_50|6, $59, BASE_PITCH
db ENVF_PITCH|DUTY_50|6, BASE_PITCH+5
db ENVF_PITCH|DUTY_50|4, BASE_PITCH+0
db ENVF_PITCH|DUTY_50|4, BASE_PITCH+2
db ENVF_PITCH|DUTY_50|10, BASE_PITCH+10
PURGE BASE_PITCH
db $FF
fx_descr_show:
DEF BASE_PITCH EQU 33
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $C1, BASE_PITCH
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $C1, BASE_PITCH+3
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $C1, BASE_PITCH+4
PURGE BASE_PITCH
db $FF
fx_descr_hide:
DEF BASE_PITCH EQU 33
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $C1, BASE_PITCH+4
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $C1, BASE_PITCH+3
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $C1, BASE_PITCH
PURGE BASE_PITCH
db $FF
fx_cursor_move:
DEF BASE_PITCH EQU 33
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $C1, BASE_PITCH
PURGE BASE_PITCH
db $FF
fx_confirm:
DEF BASE_PITCH EQU 30
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $A1, BASE_PITCH
db ENVF_DPAR|ENVF_PITCH|DUTY_50|8, $A1, BASE_PITCH+5
PURGE BASE_PITCH
db $FF
fx_cancel:
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $C1, 22
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $C1, 24
db $FF
fx_unlock:
DEF BASE_PITCH EQU 30
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $F1, BASE_PITCH
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $F1, BASE_PITCH-10
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $F1, BASE_PITCH+9
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $F1, BASE_PITCH-7
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $F1, BASE_PITCH+12
PURGE BASE_PITCH
db $FF
fx_error:
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $C1, 30
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $C1, 25
db ENVF_DPAR|ENVF_PITCH|DUTY_50|8, $C1, 20
db $FF
fx_pause:
DEF BASE_PITCH EQU 40
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $C3, BASE_PITCH
db ENVF_PITCH|DUTY_50|4, BASE_PITCH-5
db ENVF_PITCH|DUTY_50|6, BASE_PITCH+2
PURGE BASE_PITCH
db $FF
fx_unpause:
DEF BASE_PITCH EQU 40
db ENVF_DPAR|ENVF_PITCH|DUTY_50|4, $C3, BASE_PITCH
db ENVF_PITCH|DUTY_50|4, BASE_PITCH-5
db ENVF_PITCH|DUTY_50|6, BASE_PITCH-7
PURGE BASE_PITCH
db $FF
; channel 3 (noise)
fx_electrify:
db ENVF_DPAR|ENVF_PITCH|3, $94, $53
db ENVF_PITCH|6, $59
db ENVF_DPAR|ENVF_PITCH|2, $A6, $58
db ENVF_DPAR|ENVF_PITCH|4, $93, $2A
db ENVF_DPAR|ENVF_PITCH|2, $82, $58
db ENVF_DPAR|ENVF_PITCH|1, $71, $38
db ENVF_PITCH|7, $64
db ENVF_PITCH|5, $57
db $FF
fx_final_word:
db ENVF_DPAR|ENVF_PITCH|$04, $F2, $81
db ENVF_DPAR|ENVF_PITCH|$0F, $F2, $91
; fall through to discharge sound, so sneaky
fx_discharge:
db ENVF_DPAR|ENVF_PITCH|$06, $F2, $71
db ENVF_DPAR|ENVF_PITCH|$04, $F2, $81
db ENVF_DPAR|ENVF_PITCH|$0F, $F2, $91
db $FF
section "audioengine", ROM0
; Starting sequences ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
audio_init::
; Init PSG
ld a,$80
ldh [rNR52],a ; bring audio out of reset
ld a,$FF
ldh [rNR51],a ; set panning
ld a,$77
ldh [rNR50],a
ld a,$08
ldh [rNR10],a ; disable sweep
; Silence all channels
xor a
ldh [rNR12],a
ldh [rNR22],a
ldh [rNR32],a
ldh [rNR42],a
ld a,$80
ldh [rNR14],a
ldh [rNR24],a
ldh [rNR34],a
ldh [rNR44],a
; Clear sound effect state
xor a
ld hl,audio_channels
ld c,NUM_CHANNELS << LOG_SIZEOF_CHANNEL
jp MemsetSmall
;;
; Plays sound effect A.
; Trashes ABCHLE
audio_play_fx::
ld h,high(sfx_table >> 2)
add low(sfx_table >> 2)
jr nc,.nohlwrap
inc h
.nohlwrap:
ld l,a
add hl,hl
add hl,hl
ld a,[hl+] ; channel ID
inc l
; Mute channel for hUGEDriver music playback
ld b, a ; channel to update
ld c, 1 ; 1=mute channel
push af ; protect A (channel)
push hl ; protect HL (pointer to effect)
call hUGE_mute_channel ; also trashes E
pop hl
pop af
ld c,[hl] ; ptr lo
inc l
ld b,[hl] ; ptr hi
; Get pointer to channel
rept LOG_SIZEOF_CHANNEL
add a
endr
add low(audio_channels+Channel_envseg_cd)
ld l,a
ld a,0
adc high(audio_channels)
ld h,a
xor a ; begin effect immediately
ld [hl+],a
ld a,c
ld [hl+],a
ld [hl],b
ret
; Sequence reading ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
audio_update::
ld a,0
call audio_update_ch_a
ld a,1
call audio_update_ch_a
ld a,2
call audio_update_ch_a
ld a,3
audio_update_ch_a:
; Get pointer to current position in effect
ld l,a
ld h,0
rept LOG_SIZEOF_CHANNEL
add hl,hl
endr
ld de,audio_channels+Channel_envseg_cd
add hl,de
; Each segment has a duration in frames. If this segment's
; duration has not expired, do nothing.
ld a,[hl]
or a
jr z,.read_next_segment
dec [hl]
ret
.read_next_segment:
inc l
ld e,[hl]
inc l
ld a,[hl-]
ld d,a
or e
ret z ; address $0000: no playback
; HL points at low byte of effect position
; DE = effect pointer
ld a,[de]
cp $F0
jr c,.not_special
; Currently all specials mean stop playback
xor a
ld [hl+],a
ld [hl+],a ; Clear pointer to sound sequence
ld d,a
; Unmute channel for hUGEDriver
; To do so we need the channel ID, which would normally be calculated
; in .call_updater. Instead we duplicate that code here, unmute the
; channel, and jump past it to continue.
; Seek to the appropriate audio channel's updater
ld a,l
sub low(audio_channels)
; rgbasm's nightmare of a parser can't subtract.
; Parallels to lack of "sub hl,*"?
rept LOG_SIZEOF_CHANNEL + (-1)
rra
endr
and $06
push af ; preserve A for .call_updater_late_entry
rrca
ld b, a ; channel to update
ld c, 0 ; 0=unmute channel
call hUGE_mute_channel
pop af
ld bc,($C0 | ENVF_DPAR) << 8
jr .call_updater_late_entry
.not_special:
inc de
; Save this envelope segment's duration
ld b,a
and ENVF_DURATION
dec l
ld [hl+],a
; Is there a deep parameter?
bit ENVB_DPAR,b
jr z,.nodeep
ld a,[de]
inc de
ld c,a
.nodeep:
bit ENVB_PITCH,b
jr z,.nopitch
ld a,[de]
inc de
inc l
inc l
ld [hl-],a
dec l
.nopitch:
; Write back envelope position
ld [hl],e
inc l
ld [hl],d
inc l
ld d,[hl]
; Regmap:
; B: quick parameter and flags
; C: deep parameter valid if BIT 5, B
; D: pitch, which changed if BIT 4, B
.call_updater:
; Seek to the appropriate audio channel's updater
ld a,l
sub low(audio_channels)
; rgbasm's nightmare of a parser can't subtract.
; Parallels to lack of "sub hl,*"?
rept LOG_SIZEOF_CHANNEL + (-1)
rra
endr
and $06
.call_updater_late_entry:
ld hl,channel_writing_jumptable
add l
jr nc,.nohlwrap
inc h
.nohlwrap:
ld l,a
jp hl
; Channel hardware updaters ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
update_noise:
; Noise has no quick parameter. Change pitch and timbre first
ld a,d
ldh [rNR43],a
; If no deep parameter, return quickly
bit ENVB_DPAR,b
ret z
; New deep parameter
ld a,c
ldh [rNR42],a
; See note below about turning off the DAC
ld a,8
cp c
jr c,.no_vol8fix
ldh [rNR42],a
.no_vol8fix:
ld a,$80
ldh [rNR44],a
ret
update_pulse1:
ld hl,rNR11
jr update_pulse_hl
update_pulse2:
ld hl,rNR21
update_pulse_hl:
ld [hl],b ; Quick parameter is duty
inc l
bit ENVB_DPAR,b
jr z,.no_new_volume
; Deep parameter is volume envelope
; APU turns off the DAC if the starting volume (bit 7-4) is 0
; and increase mode (bit 3) is off, which corresponds to NRx2
; values $00-$07. Turning off the DAC makes a clicking sound as
; the level gradually returns to 7.5 as the current leaks out.
; But LIJI32 in gbdev Discord pointed out that if the DAC is off
; for only a few microseconds, it doesn't have time to leak out
; appreciably.
ld a,8
cp c
ld [hl],c
jr c,.no_vol8fix
ld [hl],a
.no_vol8fix:
.no_new_volume:
inc l
set_pitch_hl_to_d:
; Write pitch
ld a,d
add a
ld de,note_table
add e
ld e,a
jr nc,.nodewrap
inc d
.nodewrap:
ld a,[de]
inc de
ld [hl+],a
ld a,[de]
bit ENVB_DPAR,b
jr z,.no_restart_note
set 7,a
.no_restart_note:
ld [hl+],a
ret
;;
; @param B quick parameter and flags
; @param C deep parameter if valid
; @param D current pitch
channel_writing_jumptable:
jr update_pulse1
jr update_pulse2
jr update_wave
jr update_noise
update_wave:
; First update volume (quick parameter)
ld a,b
add $40
rra
ldh [rNR32],a
; Update wave 9
bit ENVB_DPAR,b
jr z,.no_new_wave
; Get address of wave C
ld h,high(wavebank >> 4)
ld a,low(wavebank >> 4)
add c
ld l,a
add hl,hl
add hl,hl
add hl,hl
add hl,hl
; Copy wave
xor a
ldh [rNR30],a ; give CPU access to waveram
WAVEPTR set _AUD3WAVERAM
rept 16
ld a,[hl+]
ldh [WAVEPTR],a
WAVEPTR set WAVEPTR+1
endr
ld a,$80
ldh [rNR30],a ; give APU access to waveram
.no_new_wave:
ld hl,rNR33
jr set_pitch_hl_to_d |
Sound2B_Swish_Header:
smpsHeaderStartSong 2
smpsHeaderVoiceNull
smpsHeaderTempoSFX $01
smpsHeaderChanSFX $01
smpsHeaderSFXChannel cPSG3, Sound2B_Swish_PSG3, $00, $00
; PSG3 Data
Sound2B_Swish_PSG3:
smpsPSGvoice $00
smpsPSGform $E7
dc.b nMaxPSG, $03, nRst, $03, nMaxPSG, $01, smpsNoAttack
Sound2B_Swish_Loop00:
dc.b $01
smpsPSGAlterVol $01
dc.b smpsNoAttack
smpsLoop $00, $15, Sound2B_Swish_Loop00
smpsStop
|
//就我个人的实际提交体验来看
//CSDN有人提出:要想把fgets()接收的字符串变得和gets()一样还需要str[len - 2] = '\0';因为fgets()会把空格也接收到
//但经过我的实际提交,这样的做法会导致答案错误
//故我还是保持原来的做法
//只取其中的语句即可
void fgetstogets(char * str) {
int len = strlen(str); //这个len的长度是包括换行符的,真正的字符串长度还要小1
if(str[len - 1] == '\n' && str[len] == '\0') { //把最后接受到的换行符替换为'\0'空字符
str[len - 1] = '\0';
}
return; //一般用getline会比较合适,因为fgets会收入换行符,即便是改为空字符后,len也要重新获取,或者len--才能得到真正的len长度
}
//if的判断条件中,str[len - 1] == '\n'是最重要的
//语句向表达的核心意思也就是把最后接受到的换行符替换为'\0'
//&& str[len] == '\0'不加也能AC,我个人一般都是不加的
|
; A000792: a(n) = max{(n - i)*a(i) : i < n}; a(0) = 1.
; 1,1,2,3,4,6,9,12,18,27,36,54,81,108,162,243,324,486,729,972,1458,2187,2916,4374,6561,8748,13122,19683,26244,39366,59049,78732,118098,177147,236196,354294,531441,708588,1062882,1594323,2125764,3188646,4782969,6377292,9565938,14348907,19131876,28697814,43046721,57395628,86093442,129140163,172186884,258280326,387420489,516560652,774840978,1162261467,1549681956,2324522934,3486784401,4649045868,6973568802,10460353203,13947137604,20920706406,31381059609,41841412812,62762119218,94143178827
max $1,$0
max $1,1
seq $1,7601 ; Positions where A007600 increases.
sub $1,1
mov $0,$1
|
;
; This file contains an 'Intel Peripheral Driver' and is
; licensed for Intel CPUs and chipsets under the terms of your
; license agreement with Intel or your vendor. This file may
; be modified by the user, subject to additional terms of the
; license agreement
;; @file
; This is the code that goes from real-mode to protected mode.
; It consumes the reset vector, calls TempRamInit API from FSP binary.
;
; Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
;;
SECTION .text
global ASM_PFX(BoardBeforeTempRamInit)
ASM_PFX(BoardBeforeTempRamInit):
;
; This hook is called before FSP TempRamInit API call
; ESI, EDI need to be preserved
; ESP contains return address
;
jmp esp
|
; A058481: a(n) = 3^n - 2.
; 1,7,25,79,241,727,2185,6559,19681,59047,177145,531439,1594321,4782967,14348905,43046719,129140161,387420487,1162261465,3486784399,10460353201,31381059607,94143178825,282429536479,847288609441,2541865828327,7625597484985,22876792454959,68630377364881,205891132094647,617673396283945,1853020188851839,5559060566555521
mov $1,3
pow $1,$0
mul $1,3
sub $1,2
|
; Licensed to the .NET Foundation under one or more agreements.
; The .NET Foundation licenses this file to you under the MIT license.
include AsmMacros.inc
include asmconstants.inc
extern JIT_InternalThrow:proc
extern NDirectImportWorker:proc
extern ThePreStub:proc
extern ProfileEnter:proc
extern ProfileLeave:proc
extern ProfileTailcall:proc
extern OnHijackWorker:proc
extern JIT_RareDisableHelperWorker:proc
ifdef _DEBUG
extern DebugCheckStubUnwindInfoWorker:proc
endif
GenerateArrayOpStubExceptionCase macro ErrorCaseName, ExceptionName
NESTED_ENTRY ErrorCaseName&_RSIRDI_ScratchArea, _TEXT
; account for scratch area, rsi, rdi already on the stack
.allocstack 38h
END_PROLOGUE
mov rcx, CORINFO_&ExceptionName&_ASM
; begin epilogue
add rsp, 28h ; pop callee scratch area
pop rdi
pop rsi
jmp JIT_InternalThrow
NESTED_END ErrorCaseName&_RSIRDI_ScratchArea, _TEXT
NESTED_ENTRY ErrorCaseName&_ScratchArea, _TEXT
; account for scratch area already on the stack
.allocstack 28h
END_PROLOGUE
mov rcx, CORINFO_&ExceptionName&_ASM
; begin epilogue
add rsp, 28h ; pop callee scratch area
jmp JIT_InternalThrow
NESTED_END ErrorCaseName&_ScratchArea, _TEXT
NESTED_ENTRY ErrorCaseName&_RSIRDI, _TEXT
; account for rsi, rdi already on the stack
.allocstack 10h
END_PROLOGUE
mov rcx, CORINFO_&ExceptionName&_ASM
; begin epilogue
pop rdi
pop rsi
jmp JIT_InternalThrow
NESTED_END ErrorCaseName&_RSIRDI, _TEXT
LEAF_ENTRY ErrorCaseName, _TEXT
mov rcx, CORINFO_&ExceptionName&_ASM
; begin epilogue
jmp JIT_InternalThrow
LEAF_END ErrorCaseName, _TEXT
endm
GenerateArrayOpStubExceptionCase ArrayOpStubNullException, NullReferenceException
GenerateArrayOpStubExceptionCase ArrayOpStubRangeException, IndexOutOfRangeException
GenerateArrayOpStubExceptionCase ArrayOpStubTypeMismatchException, ArrayTypeMismatchException
; EXTERN_C int __fastcall HelperMethodFrameRestoreState(
; INDEBUG_COMMA(HelperMethodFrame *pFrame)
; MachState *pState
; )
LEAF_ENTRY HelperMethodFrameRestoreState, _TEXT
ifdef _DEBUG
mov rcx, rdx
endif
; Check if the MachState is valid
xor eax, eax
cmp qword ptr [rcx + OFFSETOF__MachState___pRetAddr], rax
jne @F
REPRET
@@:
;
; If a preserved register were pushed onto the stack between
; the managed caller and the H_M_F, m_pReg will point to its
; location on the stack and it would have been updated on the
; stack by the GC already and it will be popped back into the
; appropriate register when the appropriate epilog is run.
;
; Otherwise, the register is preserved across all the code
; in this HCALL or FCALL, so we need to update those registers
; here because the GC will have updated our copies in the
; frame.
;
; So, if m_pReg points into the MachState, we need to update
; the register here. That's what this macro does.
;
RestoreReg macro reg, regnum
lea rax, [rcx + OFFSETOF__MachState__m_Capture + 8 * regnum]
mov rdx, [rcx + OFFSETOF__MachState__m_Ptrs + 8 * regnum]
cmp rax, rdx
cmove reg, [rax]
endm
; regnum has to match ENUM_CALLEE_SAVED_REGISTERS macro
RestoreReg Rdi, 0
RestoreReg Rsi, 1
RestoreReg Rbx, 2
RestoreReg Rbp, 3
RestoreReg R12, 4
RestoreReg R13, 5
RestoreReg R14, 6
RestoreReg R15, 7
xor eax, eax
ret
LEAF_END HelperMethodFrameRestoreState, _TEXT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; NDirectImportThunk
;;
;; In addition to being called by the EE, this function can be called
;; directly from code generated by JIT64 for CRT optimized direct
;; P/Invoke calls. If it is modified, the JIT64 compiler's code
;; generation will need to altered accordingly.
;;
; EXTERN_C VOID __stdcall NDirectImportThunk();
NESTED_ENTRY NDirectImportThunk, _TEXT
;
; Allocate space for XMM parameter registers and callee scratch area.
;
alloc_stack 68h
;
; Save integer parameter registers.
; Make sure to preserve r11 as well as it is used to pass the stack argument size from JIT
;
save_reg_postrsp rcx, 70h
save_reg_postrsp rdx, 78h
save_reg_postrsp r8, 80h
save_reg_postrsp r9, 88h
save_reg_postrsp r11, 60h
save_xmm128_postrsp xmm0, 20h
save_xmm128_postrsp xmm1, 30h
save_xmm128_postrsp xmm2, 40h
save_xmm128_postrsp xmm3, 50h
END_PROLOGUE
;
; Call NDirectImportWorker w/ the NDirectMethodDesc*
;
mov rcx, METHODDESC_REGISTER
call NDirectImportWorker
;
; Restore parameter registers
;
mov rcx, [rsp + 70h]
mov rdx, [rsp + 78h]
mov r8, [rsp + 80h]
mov r9, [rsp + 88h]
mov r11, [rsp + 60h]
movdqa xmm0, [rsp + 20h]
movdqa xmm1, [rsp + 30h]
movdqa xmm2, [rsp + 40h]
movdqa xmm3, [rsp + 50h]
;
; epilogue, rax contains the native target address
;
add rsp, 68h
TAILJMP_RAX
NESTED_END NDirectImportThunk, _TEXT
;------------------------------------------------
; JIT_RareDisableHelper
;
; The JIT expects this helper to preserve all
; registers that can be used for return values
;
NESTED_ENTRY JIT_RareDisableHelper, _TEXT
alloc_stack 38h
END_PROLOGUE
movdqa [rsp+20h], xmm0 ; Save xmm0
mov [rsp+30h], rax ; Save rax
call JIT_RareDisableHelperWorker
movdqa xmm0, [rsp+20h] ; Restore xmm0
mov rax, [rsp+30h] ; Restore rax
add rsp, 38h
ret
NESTED_END JIT_RareDisableHelper, _TEXT
; extern "C" void setFPReturn(int fpSize, INT64 retVal);
LEAF_ENTRY setFPReturn, _TEXT
cmp ecx, 4
je setFPReturn4
cmp ecx, 8
jne setFPReturnNot8
mov [rsp+10h], rdx
movsd xmm0, real8 ptr [rsp+10h]
setFPReturnNot8:
REPRET
setFPReturn4:
mov [rsp+10h], rdx
movss xmm0, real4 ptr [rsp+10h]
ret
LEAF_END setFPReturn, _TEXT
; extern "C" void getFPReturn(int fpSize, INT64 *retval);
LEAF_ENTRY getFPReturn, _TEXT
cmp ecx, 4
je getFPReturn4
cmp ecx, 8
jne getFPReturnNot8
movsd real8 ptr [rdx], xmm0
getFPReturnNot8:
REPRET
getFPReturn4:
movss real4 ptr [rdx], xmm0
ret
LEAF_END getFPReturn, _TEXT
ifdef _DEBUG
NESTED_ENTRY DebugCheckStubUnwindInfo, _TEXT
;
; rax is pushed on the stack before being trashed by the "mov rax,
; target/jmp rax" code generated by X86EmitNearJump. This stack slot
; will be reused later in the epilogue. This slot is left there to
; align rsp.
;
.allocstack 8
mov rax, [rsp]
;
; Create a CONTEXT structure. DebugCheckStubUnwindInfoWorker will
; fill in the flags.
;
alloc_stack 20h + SIZEOF__CONTEXT
mov r10, rbp
set_frame rbp, 20h
mov [rbp + OFFSETOF__CONTEXT__Rbp], r10
.savereg rbp, OFFSETOF__CONTEXT__Rbp
save_reg_frame rbx, rbp, OFFSETOF__CONTEXT__Rbx
save_reg_frame rsi, rbp, OFFSETOF__CONTEXT__Rsi
save_reg_frame rdi, rbp, OFFSETOF__CONTEXT__Rdi
save_reg_frame r12, rbp, OFFSETOF__CONTEXT__R12
save_reg_frame r13, rbp, OFFSETOF__CONTEXT__R13
save_reg_frame r14, rbp, OFFSETOF__CONTEXT__R14
save_reg_frame r15, rbp, OFFSETOF__CONTEXT__R15
save_xmm128_frame xmm6, rbp, OFFSETOF__CONTEXT__Xmm6
save_xmm128_frame xmm7, rbp, OFFSETOF__CONTEXT__Xmm7
save_xmm128_frame xmm8, rbp, OFFSETOF__CONTEXT__Xmm8
save_xmm128_frame xmm9, rbp, OFFSETOF__CONTEXT__Xmm9
save_xmm128_frame xmm10, rbp, OFFSETOF__CONTEXT__Xmm10
save_xmm128_frame xmm11, rbp, OFFSETOF__CONTEXT__Xmm11
save_xmm128_frame xmm12, rbp, OFFSETOF__CONTEXT__Xmm12
save_xmm128_frame xmm13, rbp, OFFSETOF__CONTEXT__Xmm13
save_xmm128_frame xmm14, rbp, OFFSETOF__CONTEXT__Xmm14
save_xmm128_frame xmm15, rbp, OFFSETOF__CONTEXT__Xmm15
END_PROLOGUE
mov [rbp + OFFSETOF__CONTEXT__Rax], rax
mov [rbp + OFFSETOF__CONTEXT__Rcx], rcx
mov [rbp + OFFSETOF__CONTEXT__Rdx], rdx
mov [rbp + OFFSETOF__CONTEXT__R8], r8
mov [rbp + OFFSETOF__CONTEXT__R9], r9
mov [rbp + OFFSETOF__CONTEXT__R10], r10
mov [rbp + OFFSETOF__CONTEXT__R11], r11
movdqa [rbp + OFFSETOF__CONTEXT__Xmm0], xmm0
movdqa [rbp + OFFSETOF__CONTEXT__Xmm1], xmm1
movdqa [rbp + OFFSETOF__CONTEXT__Xmm2], xmm2
movdqa [rbp + OFFSETOF__CONTEXT__Xmm3], xmm3
movdqa [rbp + OFFSETOF__CONTEXT__Xmm4], xmm4
movdqa [rbp + OFFSETOF__CONTEXT__Xmm5], xmm5
mov rax, [rbp+SIZEOF__CONTEXT+8]
mov [rbp+OFFSETOF__CONTEXT__Rip], rax
lea rax, [rbp+SIZEOF__CONTEXT+8+8]
mov [rbp+OFFSETOF__CONTEXT__Rsp], rax
;
; Align rsp
;
and rsp, -16
;
; Verify that unwinding works from the stub's CONTEXT.
;
mov rcx, rbp
call DebugCheckStubUnwindInfoWorker
;
; Restore stub's registers. rbp will be restored using "pop" in the
; epilogue.
;
mov rax, [rbp+OFFSETOF__CONTEXT__Rbp]
mov [rbp+SIZEOF__CONTEXT], rax
mov rax, [rbp+OFFSETOF__CONTEXT__Rax]
mov rbx, [rbp+OFFSETOF__CONTEXT__Rbx]
mov rcx, [rbp+OFFSETOF__CONTEXT__Rcx]
mov rdx, [rbp+OFFSETOF__CONTEXT__Rdx]
mov rsi, [rbp+OFFSETOF__CONTEXT__Rsi]
mov rdi, [rbp+OFFSETOF__CONTEXT__Rdi]
mov r8, [rbp+OFFSETOF__CONTEXT__R8]
mov r9, [rbp+OFFSETOF__CONTEXT__R9]
mov r10, [rbp+OFFSETOF__CONTEXT__R10]
mov r11, [rbp+OFFSETOF__CONTEXT__R11]
mov r12, [rbp+OFFSETOF__CONTEXT__R12]
mov r13, [rbp+OFFSETOF__CONTEXT__R13]
mov r14, [rbp+OFFSETOF__CONTEXT__R14]
mov r15, [rbp+OFFSETOF__CONTEXT__R15]
movdqa xmm0, [rbp+OFFSETOF__CONTEXT__Xmm0]
movdqa xmm1, [rbp+OFFSETOF__CONTEXT__Xmm1]
movdqa xmm2, [rbp+OFFSETOF__CONTEXT__Xmm2]
movdqa xmm3, [rbp+OFFSETOF__CONTEXT__Xmm3]
movdqa xmm4, [rbp+OFFSETOF__CONTEXT__Xmm4]
movdqa xmm5, [rbp+OFFSETOF__CONTEXT__Xmm5]
movdqa xmm6, [rbp+OFFSETOF__CONTEXT__Xmm6]
movdqa xmm7, [rbp+OFFSETOF__CONTEXT__Xmm7]
movdqa xmm8, [rbp+OFFSETOF__CONTEXT__Xmm8]
movdqa xmm9, [rbp+OFFSETOF__CONTEXT__Xmm9]
movdqa xmm10, [rbp+OFFSETOF__CONTEXT__Xmm10]
movdqa xmm11, [rbp+OFFSETOF__CONTEXT__Xmm11]
movdqa xmm12, [rbp+OFFSETOF__CONTEXT__Xmm12]
movdqa xmm13, [rbp+OFFSETOF__CONTEXT__Xmm13]
movdqa xmm14, [rbp+OFFSETOF__CONTEXT__Xmm14]
movdqa xmm15, [rbp+OFFSETOF__CONTEXT__Xmm15]
;
; epilogue
;
lea rsp, [rbp + SIZEOF__CONTEXT]
pop rbp
ret
NESTED_END DebugCheckStubUnwindInfo, _TEXT
endif ; _DEBUG
; A JITted method's return address was hijacked to return to us here.
; VOID OnHijackTripThread()
NESTED_ENTRY OnHijackTripThread, _TEXT
; Don't fiddle with this unless you change HijackFrame::UpdateRegDisplay
; and HijackArgs
mov rdx, rsp
push rax ; make room for the real return address (Rip)
push rdx
PUSH_CALLEE_SAVED_REGISTERS
push_vol_reg rax
mov rcx, rsp
alloc_stack 38h ; make extra room for xmm0, argument home slots and align the SP
save_xmm128_postrsp xmm0, 20h
END_PROLOGUE
call OnHijackWorker
movdqa xmm0, [rsp + 20h]
add rsp, 38h
pop rax
POP_CALLEE_SAVED_REGISTERS
pop rdx
ret ; return to the correct place, adjusted by our caller
NESTED_END OnHijackTripThread, _TEXT
;
; typedef struct _PROFILE_PLATFORM_SPECIFIC_DATA
; {
; FunctionID *functionId; // function ID comes in the r11 register
; void *rbp;
; void *probersp;
; void *ip;
; void *profiledRsp;
; UINT64 rax;
; LPVOID hiddenArg;
; UINT64 flt0;
; UINT64 flt1;
; UINT64 flt2;
; UINT64 flt3;
; UINT32 flags;
; } PROFILE_PLATFORM_SPECIFIC_DATA, *PPROFILE_PLATFORM_SPECIFIC_DATA;
;
SIZEOF_PROFILE_PLATFORM_SPECIFIC_DATA equ 8h*11 + 4h*2 ; includes fudge to make FP_SPILL right
SIZEOF_OUTGOING_ARGUMENT_HOMES equ 8h*4
SIZEOF_FP_ARG_SPILL equ 10h*1
; Need to be careful to keep the stack 16byte aligned here, since we are pushing 3
; arguments that will align the stack and we just want to keep it aligned with our
; SIZEOF_STACK_FRAME
OFFSETOF_PLATFORM_SPECIFIC_DATA equ SIZEOF_OUTGOING_ARGUMENT_HOMES
; we'll just spill into the PROFILE_PLATFORM_SPECIFIC_DATA structure
OFFSETOF_FP_ARG_SPILL equ SIZEOF_OUTGOING_ARGUMENT_HOMES + \
SIZEOF_PROFILE_PLATFORM_SPECIFIC_DATA
SIZEOF_STACK_FRAME equ SIZEOF_OUTGOING_ARGUMENT_HOMES + \
SIZEOF_PROFILE_PLATFORM_SPECIFIC_DATA + \
SIZEOF_MAX_FP_ARG_SPILL
PROFILE_ENTER equ 1h
PROFILE_LEAVE equ 2h
PROFILE_TAILCALL equ 4h
; ***********************************************************
; NOTE:
;
; Register preservation scheme:
;
; Preserved:
; - all non-volatile registers
; - rax
; - xmm0
;
; Not Preserved:
; - integer argument registers (rcx, rdx, r8, r9)
; - floating point argument registers (xmm1-3)
; - volatile integer registers (r10, r11)
; - volatile floating point registers (xmm4-5)
;
; ***********************************************************
; void JIT_ProfilerEnterLeaveTailcallStub(UINT_PTR ProfilerHandle)
LEAF_ENTRY JIT_ProfilerEnterLeaveTailcallStub, _TEXT
REPRET
LEAF_END JIT_ProfilerEnterLeaveTailcallStub, _TEXT
;EXTERN_C void ProfileEnterNaked(FunctionIDOrClientID functionIDOrClientID, size_t profiledRsp);
NESTED_ENTRY ProfileEnterNaked, _TEXT
push_nonvol_reg rax
; Upon entry :
; rcx = clientInfo
; rdx = profiledRsp
lea rax, [rsp + 10h] ; caller rsp
mov r10, [rax - 8h] ; return address
alloc_stack SIZEOF_STACK_FRAME
; correctness of return value in structure doesn't matter for enter probe
; setup ProfilePlatformSpecificData structure
xor r8, r8;
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 0h], r8 ; r8 is null -- struct functionId field
save_reg_postrsp rbp, OFFSETOF_PLATFORM_SPECIFIC_DATA + 8h ; -- struct rbp field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 10h], rax ; caller rsp -- struct probeRsp field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 18h], r10 ; return address -- struct ip field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 20h], rdx ; -- struct profiledRsp field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 28h], r8 ; r8 is null -- struct rax field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 30h], r8 ; r8 is null -- struct hiddenArg field
movsd real8 ptr [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 38h], xmm0 ; -- struct flt0 field
movsd real8 ptr [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 40h], xmm1 ; -- struct flt1 field
movsd real8 ptr [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 48h], xmm2 ; -- struct flt2 field
movsd real8 ptr [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 50h], xmm3 ; -- struct flt3 field
mov r10, PROFILE_ENTER
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 58h], r10d ; flags ; -- struct flags field
; we need to be able to restore the fp return register
save_xmm128_postrsp xmm0, OFFSETOF_FP_ARG_SPILL + 0h
END_PROLOGUE
; rcx already contains the clientInfo
lea rdx, [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA]
call ProfileEnter
; restore fp return register
movdqa xmm0, [rsp + OFFSETOF_FP_ARG_SPILL + 0h]
; begin epilogue
add rsp, SIZEOF_STACK_FRAME
pop rax
ret
NESTED_END ProfileEnterNaked, _TEXT
;EXTERN_C void ProfileLeaveNaked(FunctionIDOrClientID functionIDOrClientID, size_t profiledRsp);
NESTED_ENTRY ProfileLeaveNaked, _TEXT
push_nonvol_reg rax
; Upon entry :
; rcx = clientInfo
; rdx = profiledRsp
; need to be careful with rax here because it contains the return value which we want to harvest
lea r10, [rsp + 10h] ; caller rsp
mov r11, [r10 - 8h] ; return address
alloc_stack SIZEOF_STACK_FRAME
; correctness of argument registers in structure doesn't matter for leave probe
; setup ProfilePlatformSpecificData structure
xor r8, r8;
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 0h], r8 ; r8 is null -- struct functionId field
save_reg_postrsp rbp, OFFSETOF_PLATFORM_SPECIFIC_DATA + 8h ; -- struct rbp field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 10h], r10 ; caller rsp -- struct probeRsp field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 18h], r11 ; return address -- struct ip field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 20h], rdx ; -- struct profiledRsp field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 28h], rax ; return value -- struct rax field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 30h], r8 ; r8 is null -- struct hiddenArg field
movsd real8 ptr [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 38h], xmm0 ; -- struct flt0 field
movsd real8 ptr [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 40h], xmm1 ; -- struct flt1 field
movsd real8 ptr [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 48h], xmm2 ; -- struct flt2 field
movsd real8 ptr [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 50h], xmm3 ; -- struct flt3 field
mov r10, PROFILE_LEAVE
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 58h], r10d ; flags -- struct flags field
; we need to be able to restore the fp return register
save_xmm128_postrsp xmm0, OFFSETOF_FP_ARG_SPILL + 0h
END_PROLOGUE
; rcx already contains the clientInfo
lea rdx, [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA]
call ProfileLeave
; restore fp return register
movdqa xmm0, [rsp + OFFSETOF_FP_ARG_SPILL + 0h]
; begin epilogue
add rsp, SIZEOF_STACK_FRAME
pop rax
ret
NESTED_END ProfileLeaveNaked, _TEXT
;EXTERN_C void ProfileTailcallNaked(FunctionIDOrClientID functionIDOrClientID, size_t profiledRsp);
NESTED_ENTRY ProfileTailcallNaked, _TEXT
push_nonvol_reg rax
; Upon entry :
; rcx = clientInfo
; rdx = profiledRsp
lea rax, [rsp + 10h] ; caller rsp
mov r11, [rax - 8h] ; return address
alloc_stack SIZEOF_STACK_FRAME
; correctness of return values and argument registers in structure
; doesn't matter for tailcall probe
; setup ProfilePlatformSpecificData structure
xor r8, r8;
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 0h], r8 ; r8 is null -- struct functionId field
save_reg_postrsp rbp, OFFSETOF_PLATFORM_SPECIFIC_DATA + 8h ; -- struct rbp field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 10h], rax ; caller rsp -- struct probeRsp field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 18h], r11 ; return address -- struct ip field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 20h], rdx ; -- struct profiledRsp field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 28h], r8 ; r8 is null -- struct rax field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 30h], r8 ; r8 is null -- struct hiddenArg field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 38h], r8 ; r8 is null -- struct flt0 field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 40h], r8 ; r8 is null -- struct flt1 field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 48h], r8 ; r8 is null -- struct flt2 field
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 50h], r8 ; r8 is null -- struct flt3 field
mov r10, PROFILE_TAILCALL
mov [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA + 58h], r10d ; flags -- struct flags field
; we need to be able to restore the fp return register
save_xmm128_postrsp xmm0, OFFSETOF_FP_ARG_SPILL + 0h
END_PROLOGUE
; rcx already contains the clientInfo
lea rdx, [rsp + OFFSETOF_PLATFORM_SPECIFIC_DATA]
call ProfileTailcall
; restore fp return register
movdqa xmm0, [rsp + OFFSETOF_FP_ARG_SPILL + 0h]
; begin epilogue
add rsp, SIZEOF_STACK_FRAME
pop rax
ret
NESTED_END ProfileTailcallNaked, _TEXT
;; extern "C" DWORD __stdcall xmmYmmStateSupport();
LEAF_ENTRY xmmYmmStateSupport, _TEXT
mov ecx, 0 ; Specify xcr0
xgetbv ; result in EDX:EAX
and eax, 06H
cmp eax, 06H ; check OS has enabled both XMM and YMM state support
jne not_supported
mov eax, 1
jmp done
not_supported:
mov eax, 0
done:
ret
LEAF_END xmmYmmStateSupport, _TEXT
; EXTERN_C void moveOWord(LPVOID* src, LPVOID* target);
; <NOTE>
; MOVDQA is not an atomic operation. You need to call this function in a crst.
; </NOTE>
LEAF_ENTRY moveOWord, _TEXT
movdqa xmm0, [rcx]
movdqa [rdx], xmm0
ret
LEAF_END moveOWord, _TEXT
extern JIT_InternalThrowFromHelper:proc
LEAF_ENTRY SinglecastDelegateInvokeStub, _TEXT
test rcx, rcx
jz NullObject
mov rax, [rcx + OFFSETOF__DelegateObject___methodPtr]
mov rcx, [rcx + OFFSETOF__DelegateObject___target] ; replace "this" pointer
jmp rax
NullObject:
mov rcx, CORINFO_NullReferenceException_ASM
jmp JIT_InternalThrow
LEAF_END SinglecastDelegateInvokeStub, _TEXT
ifdef FEATURE_TIERED_COMPILATION
extern OnCallCountThresholdReached:proc
NESTED_ENTRY OnCallCountThresholdReachedStub, _TEXT
PROLOG_WITH_TRANSITION_BLOCK
lea rcx, [rsp + __PWTB_TransitionBlock] ; TransitionBlock *
mov rdx, rax ; stub-identifying token, see OnCallCountThresholdReachedStub
call OnCallCountThresholdReached
EPILOG_WITH_TRANSITION_BLOCK_TAILCALL
TAILJMP_RAX
NESTED_END OnCallCountThresholdReachedStub, _TEXT
endif ; FEATURE_TIERED_COMPILATION
end
|
#pragma once
namespace SmartIotInternals {
// config mode
const char PROGMEM_CONFIG_APPLICATION_JSON[] PROGMEM = "application/json";
const char PROGMEM_CONFIG_JSON_SUCCESS[] PROGMEM = "{\"success\":true}";
const char PROGMEM_CONFIG_JSON_FAILURE_BEGINNING[] PROGMEM = "{\"success\":false,\"error\":\"";
const char PROGMEM_CONFIG_JSON_FAILURE_END[] PROGMEM = "\"}";
}
|
; A254663: Numbers of n-length words on alphabet {0,1,...,7} with no subwords ii, where i is from {0,1,...,5}.
; 1,8,58,422,3070,22334,162478,1182014,8599054,62557406,455099950,3310814462,24085901134,175222936862,1274732360302,9273572395838,67464471491470,490798445231966,3570518059606702,25975223307710846
mov $1,1
lpb $0,1
sub $0,1
mov $2,$1
mul $1,2
add $2,1
add $3,2
add $3,$1
mov $1,$3
mul $1,2
add $2,$3
mov $3,$2
sub $3,1
add $3,$1
sub $3,2
lpe
|
MVI B,13H
MVI C,17H
ADD B
ADD C
ADI 16H
ADI 14H
|
//*****************************************************************************
// Copyright 2017-2021 Intel Corporation
//
// 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 "itt.hpp"
#include "ngraph/op/acos.hpp"
#include "ngraph/axis_set.hpp"
#include "ngraph/op/broadcast.hpp"
#include "ngraph/op/constant.hpp"
#include "ngraph/op/divide.hpp"
#include "ngraph/op/multiply.hpp"
#include "ngraph/op/negative.hpp"
#include "ngraph/op/sqrt.hpp"
#include "ngraph/op/subtract.hpp"
#include "ngraph/runtime/host_tensor.hpp"
#include "ngraph/runtime/reference/acos.hpp"
#include <string>
using namespace std;
using namespace ngraph;
constexpr NodeTypeInfo op::Acos::type_info;
op::Acos::Acos(const Output<Node>& arg)
: UnaryElementwiseArithmetic(arg)
{
constructor_validate_and_infer_types();
}
shared_ptr<Node> op::Acos::clone_with_new_inputs(const OutputVector& new_args) const
{
NGRAPH_OP_SCOPE(v0_Acos_clone_with_new_inputs);
check_new_args_count(this, new_args);
return make_shared<Acos>(new_args.at(0));
}
namespace acosop
{
template <element::Type_t ET>
inline bool evaluate(const HostTensorPtr& arg0, const HostTensorPtr& out, const size_t count)
{
using T = typename element_type_traits<ET>::value_type;
runtime::reference::acos<T>(arg0->get_data_ptr<ET>(), out->get_data_ptr<ET>(), count);
return true;
}
bool evaluate_acos(const HostTensorPtr& arg0, const HostTensorPtr& out, const size_t count)
{
bool rc = true;
out->set_unary(arg0);
switch (arg0->get_element_type())
{
NGRAPH_TYPE_CASE(evaluate_acos, boolean, arg0, out, count);
NGRAPH_TYPE_CASE(evaluate_acos, i32, arg0, out, count);
NGRAPH_TYPE_CASE(evaluate_acos, i64, arg0, out, count);
NGRAPH_TYPE_CASE(evaluate_acos, u32, arg0, out, count);
NGRAPH_TYPE_CASE(evaluate_acos, u64, arg0, out, count);
NGRAPH_TYPE_CASE(evaluate_acos, f16, arg0, out, count);
NGRAPH_TYPE_CASE(evaluate_acos, f32, arg0, out, count);
default: rc = false; break;
}
return rc;
}
}
bool op::Acos::evaluate(const HostTensorVector& outputs, const HostTensorVector& inputs) const
{
NGRAPH_OP_SCOPE(v0_Acos_evaluate);
return acosop::evaluate_acos(inputs[0], outputs[0], shape_size(get_output_shape(0)));
}
|
// Copyright (c) 2009-2014 The Bitcoin developers
// Copyright (c) 2014-2015 The Dash developers
// Copyright (c) 2015-2017 The PIVX developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "bip38.h"
#include "init.h"
#include "main.h"
#include "rpcserver.h"
#include "script/script.h"
#include "script/standard.h"
#include "sync.h"
#include "util.h"
#include "utilstrencodings.h"
#include "utiltime.h"
#include "wallet.h"
#include <fstream>
#include <secp256k1.h>
#include <stdint.h>
#include <boost/algorithm/string.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <openssl/aes.h>
#include <openssl/sha.h>
#include "json/json_spirit_value.h"
using namespace json_spirit;
using namespace std;
void EnsureWalletIsUnlocked();
std::string static EncodeDumpTime(int64_t nTime)
{
return DateTimeStrFormat("%Y-%m-%dT%H:%M:%SZ", nTime);
}
int64_t static DecodeDumpTime(const std::string& str)
{
static const boost::posix_time::ptime epoch = boost::posix_time::from_time_t(0);
static const std::locale loc(std::locale::classic(),
new boost::posix_time::time_input_facet("%Y-%m-%dT%H:%M:%SZ"));
std::istringstream iss(str);
iss.imbue(loc);
boost::posix_time::ptime ptime(boost::date_time::not_a_date_time);
iss >> ptime;
if (ptime.is_not_a_date_time())
return 0;
return (ptime - epoch).total_seconds();
}
std::string static EncodeDumpString(const std::string& str)
{
std::stringstream ret;
BOOST_FOREACH (unsigned char c, str) {
if (c <= 32 || c >= 128 || c == '%') {
ret << '%' << HexStr(&c, &c + 1);
} else {
ret << c;
}
}
return ret.str();
}
std::string DecodeDumpString(const std::string& str)
{
std::stringstream ret;
for (unsigned int pos = 0; pos < str.length(); pos++) {
unsigned char c = str[pos];
if (c == '%' && pos + 2 < str.length()) {
c = (((str[pos + 1] >> 6) * 9 + ((str[pos + 1] - '0') & 15)) << 4) |
((str[pos + 2] >> 6) * 9 + ((str[pos + 2] - '0') & 15));
pos += 2;
}
ret << c;
}
return ret.str();
}
Value importprivkey(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 3)
throw runtime_error(
"importprivkey \"stablecoinprivkey\" ( \"label\" rescan )\n"
"\nAdds a private key (as returned by dumpprivkey) to your wallet.\n"
"\nArguments:\n"
"1. \"stablecoinprivkey\" (string, required) The private key (see dumpprivkey)\n"
"2. \"label\" (string, optional, default=\"\") An optional label\n"
"3. rescan (boolean, optional, default=true) Rescan the wallet for transactions\n"
"\nNote: This call can take minutes to complete if rescan is true.\n"
"\nExamples:\n"
"\nDump a private key\n" +
HelpExampleCli("dumpprivkey", "\"myaddress\"") +
"\nImport the private key with rescan\n" + HelpExampleCli("importprivkey", "\"mykey\"") +
"\nImport using a label and without rescan\n" + HelpExampleCli("importprivkey", "\"mykey\" \"testing\" false") +
"\nAs a JSON-RPC call\n" + HelpExampleRpc("importprivkey", "\"mykey\", \"testing\", false"));
EnsureWalletIsUnlocked();
string strSecret = params[0].get_str();
string strLabel = "";
if (params.size() > 1)
strLabel = params[1].get_str();
// Whether to perform rescan after import
bool fRescan = true;
if (params.size() > 2)
fRescan = params[2].get_bool();
CBitcoinSecret vchSecret;
bool fGood = vchSecret.SetString(strSecret);
if (!fGood) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key encoding");
CKey key = vchSecret.GetKey();
if (!key.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Private key outside allowed range");
CPubKey pubkey = key.GetPubKey();
assert(key.VerifyPubKey(pubkey));
CKeyID vchAddress = pubkey.GetID();
{
pwalletMain->MarkDirty();
pwalletMain->SetAddressBook(vchAddress, strLabel, "receive");
// Don't throw error in case a key is already there
if (pwalletMain->HaveKey(vchAddress))
return Value::null;
pwalletMain->mapKeyMetadata[vchAddress].nCreateTime = 1;
if (!pwalletMain->AddKeyPubKey(key, pubkey))
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet");
// whenever a key is imported, we need to scan the whole chain
pwalletMain->nTimeFirstKey = 1; // 0 would be considered 'no value'
if (fRescan) {
pwalletMain->ScanForWalletTransactions(chainActive.Genesis(), true);
}
}
return Value::null;
}
Value importaddress(const Array& params, bool fHelp)
{
if (fHelp || params.size() < 1 || params.size() > 3)
throw runtime_error(
"importaddress \"address\" ( \"label\" rescan )\n"
"\nAdds an address or script (in hex) that can be watched as if it were in your wallet but cannot be used to spend.\n"
"\nArguments:\n"
"1. \"address\" (string, required) The address\n"
"2. \"label\" (string, optional, default=\"\") An optional label\n"
"3. rescan (boolean, optional, default=true) Rescan the wallet for transactions\n"
"\nNote: This call can take minutes to complete if rescan is true.\n"
"\nExamples:\n"
"\nImport an address with rescan\n" +
HelpExampleCli("importaddress", "\"myaddress\"") +
"\nImport using a label without rescan\n" + HelpExampleCli("importaddress", "\"myaddress\" \"testing\" false") +
"\nAs a JSON-RPC call\n" + HelpExampleRpc("importaddress", "\"myaddress\", \"testing\", false"));
CScript script;
CBitcoinAddress address(params[0].get_str());
if (address.IsValid()) {
script = GetScriptForDestination(address.Get());
} else if (IsHex(params[0].get_str())) {
std::vector<unsigned char> data(ParseHex(params[0].get_str()));
script = CScript(data.begin(), data.end());
} else {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid StableCoin address or script");
}
string strLabel = "";
if (params.size() > 1)
strLabel = params[1].get_str();
// Whether to perform rescan after import
bool fRescan = true;
if (params.size() > 2)
fRescan = params[2].get_bool();
{
if (::IsMine(*pwalletMain, script) == ISMINE_SPENDABLE)
throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the private key for this address or script");
// add to address book or update label
if (address.IsValid())
pwalletMain->SetAddressBook(address.Get(), strLabel, "receive");
// Don't throw error in case an address is already there
if (pwalletMain->HaveWatchOnly(script))
return Value::null;
pwalletMain->MarkDirty();
if (!pwalletMain->AddWatchOnly(script))
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet");
if (fRescan) {
pwalletMain->ScanForWalletTransactions(chainActive.Genesis(), true);
pwalletMain->ReacceptWalletTransactions();
}
}
return Value::null;
}
Value importwallet(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"importwallet \"filename\"\n"
"\nImports keys from a wallet dump file (see dumpwallet).\n"
"\nArguments:\n"
"1. \"filename\" (string, required) The wallet file\n"
"\nExamples:\n"
"\nDump the wallet\n" +
HelpExampleCli("dumpwallet", "\"test\"") +
"\nImport the wallet\n" + HelpExampleCli("importwallet", "\"test\"") +
"\nImport using the json rpc call\n" + HelpExampleRpc("importwallet", "\"test\""));
EnsureWalletIsUnlocked();
ifstream file;
file.open(params[0].get_str().c_str(), std::ios::in | std::ios::ate);
if (!file.is_open())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
int64_t nTimeBegin = chainActive.Tip()->GetBlockTime();
bool fGood = true;
int64_t nFilesize = std::max((int64_t)1, (int64_t)file.tellg());
file.seekg(0, file.beg);
pwalletMain->ShowProgress(_("Importing..."), 0); // show progress dialog in GUI
while (file.good()) {
pwalletMain->ShowProgress("", std::max(1, std::min(99, (int)(((double)file.tellg() / (double)nFilesize) * 100))));
std::string line;
std::getline(file, line);
if (line.empty() || line[0] == '#')
continue;
std::vector<std::string> vstr;
boost::split(vstr, line, boost::is_any_of(" "));
if (vstr.size() < 2)
continue;
CBitcoinSecret vchSecret;
if (!vchSecret.SetString(vstr[0]))
continue;
CKey key = vchSecret.GetKey();
CPubKey pubkey = key.GetPubKey();
assert(key.VerifyPubKey(pubkey));
CKeyID keyid = pubkey.GetID();
if (pwalletMain->HaveKey(keyid)) {
LogPrintf("Skipping import of %s (key already present)\n", CBitcoinAddress(keyid).ToString());
continue;
}
int64_t nTime = DecodeDumpTime(vstr[1]);
std::string strLabel;
bool fLabel = true;
for (unsigned int nStr = 2; nStr < vstr.size(); nStr++) {
if (boost::algorithm::starts_with(vstr[nStr], "#"))
break;
if (vstr[nStr] == "change=1")
fLabel = false;
if (vstr[nStr] == "reserve=1")
fLabel = false;
if (boost::algorithm::starts_with(vstr[nStr], "label=")) {
strLabel = DecodeDumpString(vstr[nStr].substr(6));
fLabel = true;
}
}
LogPrintf("Importing %s...\n", CBitcoinAddress(keyid).ToString());
if (!pwalletMain->AddKeyPubKey(key, pubkey)) {
fGood = false;
continue;
}
pwalletMain->mapKeyMetadata[keyid].nCreateTime = nTime;
if (fLabel)
pwalletMain->SetAddressBook(keyid, strLabel, "receive");
nTimeBegin = std::min(nTimeBegin, nTime);
}
file.close();
pwalletMain->ShowProgress("", 100); // hide progress dialog in GUI
CBlockIndex* pindex = chainActive.Tip();
while (pindex && pindex->pprev && pindex->GetBlockTime() > nTimeBegin - 7200)
pindex = pindex->pprev;
if (!pwalletMain->nTimeFirstKey || nTimeBegin < pwalletMain->nTimeFirstKey)
pwalletMain->nTimeFirstKey = nTimeBegin;
LogPrintf("Rescanning last %i blocks\n", chainActive.Height() - pindex->nHeight + 1);
pwalletMain->ScanForWalletTransactions(pindex);
pwalletMain->MarkDirty();
if (!fGood)
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding some keys to wallet");
return Value::null;
}
Value dumpprivkey(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"dumpprivkey \"stablecoinaddress\"\n"
"\nReveals the private key corresponding to 'stablecoinaddress'.\n"
"Then the importprivkey can be used with this output\n"
"\nArguments:\n"
"1. \"stablecoinaddress\" (string, required) The stablecoin address for the private key\n"
"\nResult:\n"
"\"key\" (string) The private key\n"
"\nExamples:\n" +
HelpExampleCli("dumpprivkey", "\"myaddress\"") + HelpExampleCli("importprivkey", "\"mykey\"") + HelpExampleRpc("dumpprivkey", "\"myaddress\""));
EnsureWalletIsUnlocked();
string strAddress = params[0].get_str();
CBitcoinAddress address;
if (!address.SetString(strAddress))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid StableCoin address");
CKeyID keyID;
if (!address.GetKeyID(keyID))
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key");
CKey vchSecret;
if (!pwalletMain->GetKey(keyID, vchSecret))
throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known");
return CBitcoinSecret(vchSecret).ToString();
}
Value dumpwallet(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 1)
throw runtime_error(
"dumpwallet \"filename\"\n"
"\nDumps all wallet keys in a human-readable format.\n"
"\nArguments:\n"
"1. \"filename\" (string, required) The filename\n"
"\nExamples:\n" +
HelpExampleCli("dumpwallet", "\"test\"") + HelpExampleRpc("dumpwallet", "\"test\""));
EnsureWalletIsUnlocked();
ofstream file;
file.open(params[0].get_str().c_str());
if (!file.is_open())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
std::map<CKeyID, int64_t> mapKeyBirth;
std::set<CKeyID> setKeyPool;
pwalletMain->GetKeyBirthTimes(mapKeyBirth);
pwalletMain->GetAllReserveKeys(setKeyPool);
// sort time/key pairs
std::vector<std::pair<int64_t, CKeyID> > vKeyBirth;
for (std::map<CKeyID, int64_t>::const_iterator it = mapKeyBirth.begin(); it != mapKeyBirth.end(); it++) {
vKeyBirth.push_back(std::make_pair(it->second, it->first));
}
mapKeyBirth.clear();
std::sort(vKeyBirth.begin(), vKeyBirth.end());
// produce output
file << strprintf("# Wallet dump created by StableCoin %s (%s)\n", CLIENT_BUILD, CLIENT_DATE);
file << strprintf("# * Created on %s\n", EncodeDumpTime(GetTime()));
file << strprintf("# * Best block at time of backup was %i (%s),\n", chainActive.Height(), chainActive.Tip()->GetBlockHash().ToString());
file << strprintf("# mined on %s\n", EncodeDumpTime(chainActive.Tip()->GetBlockTime()));
file << "\n";
for (std::vector<std::pair<int64_t, CKeyID> >::const_iterator it = vKeyBirth.begin(); it != vKeyBirth.end(); it++) {
const CKeyID& keyid = it->second;
std::string strTime = EncodeDumpTime(it->first);
std::string strAddr = CBitcoinAddress(keyid).ToString();
CKey key;
if (pwalletMain->GetKey(keyid, key)) {
if (pwalletMain->mapAddressBook.count(keyid)) {
file << strprintf("%s %s label=%s # addr=%s\n", CBitcoinSecret(key).ToString(), strTime, EncodeDumpString(pwalletMain->mapAddressBook[keyid].name), strAddr);
} else if (setKeyPool.count(keyid)) {
file << strprintf("%s %s reserve=1 # addr=%s\n", CBitcoinSecret(key).ToString(), strTime, strAddr);
} else {
file << strprintf("%s %s change=1 # addr=%s\n", CBitcoinSecret(key).ToString(), strTime, strAddr);
}
}
}
file << "\n";
file << "# End of dump\n";
file.close();
return Value::null;
}
Value bip38encrypt(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 2)
throw runtime_error(
"bip38encrypt \"stablecoinaddress\"\n"
"\nEncrypts a private key corresponding to 'stablecoinaddress'.\n"
"\nArguments:\n"
"1. \"stablecoinaddress\" (string, required) The stablecoin address for the private key (you must hold the key already)\n"
"2. \"passphrase\" (string, required) The passphrase you want the private key to be encrypted with - Valid special chars: !#$%&'()*+,-./:;<=>?`{|}~ \n"
"\nResult:\n"
"\"key\" (string) The encrypted private key\n"
"\nExamples:\n");
EnsureWalletIsUnlocked();
string strAddress = params[0].get_str();
string strPassphrase = params[1].get_str();
CBitcoinAddress address;
if (!address.SetString(strAddress))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid StableCoin address");
CKeyID keyID;
if (!address.GetKeyID(keyID))
throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key");
CKey vchSecret;
if (!pwalletMain->GetKey(keyID, vchSecret))
throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known");
uint256 privKey = vchSecret.GetPrivKey_256();
string encryptedOut = BIP38_Encrypt(strAddress, strPassphrase, privKey, vchSecret.IsCompressed());
Object result;
result.push_back(Pair("Addess", strAddress));
result.push_back(Pair("Encrypted Key", encryptedOut));
return result;
}
Value bip38decrypt(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 2)
throw runtime_error(
"bip38decrypt \"stablecoinaddress\"\n"
"\nDecrypts and then imports password protected private key.\n"
"\nArguments:\n"
"1. \"encryptedkey\" (string, required) The encrypted private key\n"
"2. \"passphrase\" (string, required) The passphrase you want the private key to be encrypted with\n"
"\nResult:\n"
"\"key\" (string) The decrypted private key\n"
"\nExamples:\n");
EnsureWalletIsUnlocked();
/** Collect private key and passphrase **/
string strKey = params[0].get_str();
string strPassphrase = params[1].get_str();
uint256 privKey;
bool fCompressed;
if (!BIP38_Decrypt(strPassphrase, strKey, privKey, fCompressed))
throw JSONRPCError(RPC_WALLET_ERROR, "Failed To Decrypt");
Object result;
result.push_back(Pair("privatekey", HexStr(privKey)));
CKey key;
key.Set(privKey.begin(), privKey.end(), fCompressed);
if (!key.IsValid())
throw JSONRPCError(RPC_WALLET_ERROR, "Private Key Not Valid");
CPubKey pubkey = key.GetPubKey();
pubkey.IsCompressed();
assert(key.VerifyPubKey(pubkey));
result.push_back(Pair("Address", CBitcoinAddress(pubkey.GetID()).ToString()));
CKeyID vchAddress = pubkey.GetID();
{
pwalletMain->MarkDirty();
pwalletMain->SetAddressBook(vchAddress, "", "receive");
// Don't throw error in case a key is already there
if (pwalletMain->HaveKey(vchAddress))
throw JSONRPCError(RPC_WALLET_ERROR, "Key already held by wallet");
pwalletMain->mapKeyMetadata[vchAddress].nCreateTime = 1;
if (!pwalletMain->AddKeyPubKey(key, pubkey))
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet");
// whenever a key is imported, we need to scan the whole chain
pwalletMain->nTimeFirstKey = 1; // 0 would be considered 'no value'
pwalletMain->ScanForWalletTransactions(chainActive.Genesis(), true);
}
return result;
}
|
INCLUDE "sdk/hardware.inc"
; http://www.devrs.com/gb/files/sndtab.html
DEF NOTE_C_3 EQU 44
DEF NOTE_Cs3 EQU 156
DEF NOTE_D_3 EQU 262
DEF NOTE_Ds3 EQU 363
DEF NOTE_E_3 EQU 457
DEF NOTE_F_3 EQU 547
DEF NOTE_Fs3 EQU 631
DEF NOTE_G_3 EQU 710
DEF NOTE_Gs3 EQU 786
DEF NOTE_A_3 EQU 854
DEF NOTE_As3 EQU 923
DEF NOTE_B_3 EQU 986
DEF NOTE_C_4 EQU 1046
DEF NOTE_Cs4 EQU 1102
DEF NOTE_D_4 EQU 1155
DEF NOTE_Ds4 EQU 1205
DEF NOTE_E_4 EQU 1253
DEF NOTE_F_4 EQU 1297
DEF NOTE_Fs4 EQU 1339
DEF NOTE_G_4 EQU 1379
DEF NOTE_Gs4 EQU 1417
DEF NOTE_A_4 EQU 1452
DEF NOTE_As4 EQU 1486
DEF NOTE_B_4 EQU 1517
DEF NOTE_C_5 EQU 1546
DEF NOTE_Cs5 EQU 1575
DEF NOTE_D_5 EQU 1602
DEF NOTE_Ds5 EQU 1627
DEF NOTE_E_5 EQU 1650
DEF NOTE_F_5 EQU 1673
DEF NOTE_Fs5 EQU 1694
DEF NOTE_G_5 EQU 1714
DEF NOTE_Gs5 EQU 1732
DEF NOTE_A_5 EQU 1750
DEF NOTE_As5 EQU 1767
DEF NOTE_B_5 EQU 1783
DEF NOTE_C_6 EQU 1798
DEF NOTE_Cs6 EQU 1812
DEF NOTE_D_6 EQU 1825
DEF NOTE_Ds6 EQU 1837
DEF NOTE_E_6 EQU 1849
DEF NOTE_F_6 EQU 1860
DEF NOTE_Fs6 EQU 1871
DEF NOTE_G_6 EQU 1881
DEF NOTE_Gs6 EQU 1890
DEF NOTE_A_6 EQU 1899
DEF NOTE_As6 EQU 1907
DEF NOTE_B_6 EQU 1915
DEF NOTE_C_7 EQU 1923
DEF NOTE_Cs7 EQU 1930
DEF NOTE_D_7 EQU 1936
DEF NOTE_Ds7 EQU 1943
DEF NOTE_E_7 EQU 1949
DEF NOTE_F_7 EQU 1954
DEF NOTE_Fs7 EQU 1959
DEF NOTE_G_7 EQU 1964
DEF NOTE_Gs7 EQU 1969
DEF NOTE_A_7 EQU 1974
DEF NOTE_As7 EQU 1978
DEF NOTE_B_7 EQU 1982
DEF NOTE_C_8 EQU 1985
DEF NOTE_Cs8 EQU 1988
DEF NOTE_D_8 EQU 1992
DEF NOTE_Ds8 EQU 1995
DEF NOTE_E_8 EQU 1998
DEF NOTE_F_8 EQU 2001
DEF NOTE_Fs8 EQU 2004
DEF NOTE_G_8 EQU 2006
DEF NOTE_Gs8 EQU 2009
DEF NOTE_A_8 EQU 2011
DEF NOTE_As8 EQU 2013
DEF NOTE_B_8 EQU 2015
DEF SOUND_END EQU $FF
DEF CHANGE_PRIORITY EQU $FE
DEF PAN_CH1 EQU $FD
DEF PAN_CH2 EQU $FC
DEF PAN_CH3 EQU $FB
DEF PAN_CH4 EQU $FA
DEF SET_MUSIC_MUTE EQU $F9
DEF MUTE_CH1 EQU 0 << 4
DEF MUTE_CH2 EQU 1 << 4
DEF MUTE_CH3 EQU 2 << 4
DEF MUTE_CH4 EQU 3 << 4
DEF MUSIC_MUTE EQU 1
DEF MUSIC_UNMUTE EQU 0
DEF AUDHIGH_NO_RESTART EQU 0 ; missing from hardware.inc (counterpart to AUDHIGH_RESTART)
; --- Channel 2 ---
; \1 = Duty (use the AUDLEN_DUTY definitions from hardware.inc)
; \2 = Sound Length (0-63)
; \3 = Frame Wait (0-255)
MACRO CH2_LENGTH_DUTY
DB LOW(rNR21), \1 | \2, \3
ENDM
; \1 = Initial Volume (0-$F)
; \2 = Envelope Direction (use the AUDENV definitions from hardware.inc)
; \3 = Number of envelope sweep (0-7)
; \4 = Frame Wait (0-255)
MACRO CH2_VOLENV
DB LOW(rNR22), (\1 << 4) | \2 | \3, \4
ENDM
; \1 = Frequency (use the NOTE definitions)
; \2 = Stop sound after length expires (use the AUDHIGH_LENGTH defs from hardware.inc)
; \3 = If sound should be restarted (use the AUDHIGH defs)
; \4 = Number of frames to wait after effect (0-255)
MACRO CH2_FREQ
DB LOW(rNR23), LOW(\1), 0
DB LOW(rNR24), HIGH(\1) | \2 | \3, \4
ENDM
; --- Channel 4 ---
; \1 = Sound Length (0-63)
; \2 = Frame Wait (0-255)
MACRO CH4_LENGTH
DB LOW(rNR41), \1, \2
ENDM
; \1 = Initial Volume (0-$F)
; \2 = Envelope Direction (use the AUDENV definitions from hardware.inc)
; \3 = Number of envelope sweep (0-7)
; \4 = Frame Wait (0-255)
MACRO CH4_VOLENV
DB LOW(rNR42), (\1 << 4) | \2 | \3, \4
ENDM
; \1 = Counter Width (use the AUD4POLY defs)
; \2 = Shift Clock Frequency (0-15)
; \3 = Frequency Dividing Ratio (0-7)
; \4 = Frame Wait (0-255)
MACRO CH4_POLYCT
DB LOW(rNR43), \1 | (\2 << 4) | \3, \4
ENDM
; \1 = Stop sound after length expires (use the AUDHIGH_LENGTH defs from hardware.inc)
; \2 = If sound should be restarted (use the AUDHIGH defs)
; \3 = Frame Wait (0-255)
MACRO CH4_RESTART
DB LOW(rNR44), \1 | \2, \3
ENDM
SECTION "Sound FX", ROM0
; https://daid.github.io/gbsfx-studio/
_FX_FireworkShoot:: ; (CH4) Played when a firework is launched
DB 0 ; Starting priority byte
DB PAN_CH4, AUDTERM_4_LEFT | AUDTERM_4_RIGHT, 0
CH4_VOLENV $4, AUDENV_DOWN, 1, 0
CH4_POLYCT AUD4POLY_15STEP, $5, $1, 0
CH4_RESTART AUDHIGH_LENGTH_OFF, AUDHIGH_RESTART, 0
DB SOUND_END
_FX_FireworkExplode:: ; (CH4) Played when a firework explodes
DB 0 ; Starting priority byte
DB PAN_CH4, AUDTERM_4_LEFT | AUDTERM_4_RIGHT, 0
CH4_VOLENV $B, AUDENV_DOWN, 2, 0
CH4_POLYCT AUD4POLY_15STEP, $4, $6, 0
CH4_RESTART AUDHIGH_LENGTH_OFF, AUDHIGH_RESTART, 0
DB SOUND_END
_FX_MenuBip:: ; (CH2) The small bip when moving between menu items
DB 0 ; Starting priority byte
DB PAN_CH2, AUDTERM_2_LEFT | AUDTERM_2_RIGHT, 0
CH2_LENGTH_DUTY AUDLEN_DUTY_12_5, 0, 0
CH2_VOLENV $3, AUDENV_DOWN, 2, 0
CH2_FREQ NOTE_A_3, AUDHIGH_LENGTH_OFF, AUDHIGH_RESTART, 0
DB SOUND_END
_FX_WinJingle:: ; (CH2) Sound that plays when you win a level
DB 1 ; Starting priority byte
DB PAN_CH2, AUDTERM_2_LEFT | AUDTERM_2_RIGHT, 0
CH2_LENGTH_DUTY AUDLEN_DUTY_50, 0, 0
CH2_VOLENV $8, AUDENV_DOWN, 2, 0
CH2_FREQ NOTE_D_5, AUDHIGH_LENGTH_OFF, AUDHIGH_RESTART, 7
CH2_FREQ NOTE_C_5, AUDHIGH_LENGTH_OFF, AUDHIGH_RESTART, 7
CH2_FREQ NOTE_A_4, AUDHIGH_LENGTH_OFF, AUDHIGH_RESTART, 7 * 4
CH2_FREQ NOTE_Cs5, AUDHIGH_LENGTH_OFF, AUDHIGH_RESTART, 7 * 2
CH2_FREQ NOTE_D_5, AUDHIGH_LENGTH_OFF, AUDHIGH_RESTART, 0
DB SOUND_END
_FX_Draw:: ; (CH2) Played when drawing lines
DB 0 ; Starting priority byte
DB PAN_CH2, AUDTERM_2_LEFT | AUDTERM_2_RIGHT, 0
CH2_LENGTH_DUTY AUDLEN_DUTY_50, 55, 0
CH2_VOLENV $6, AUDENV_DOWN, 1, 0
CH2_FREQ NOTE_D_4, AUDHIGH_LENGTH_ON, AUDHIGH_RESTART, 0
DB SOUND_END
_FX_Delete:: ; (CH4) Played when erasing lines
DB 0 ; Starting priority byte
DB PAN_CH4, AUDTERM_4_LEFT | AUDTERM_4_RIGHT, 0
CH4_VOLENV $8, AUDENV_DOWN, 1, 0
CH4_POLYCT AUD4POLY_15STEP, $6, $4, 0
CH4_RESTART AUDHIGH_LENGTH_OFF, AUDHIGH_RESTART, 0
DB SOUND_END
_FX_Pause:: ; (CH2) Played when pause menu is opened
DB 0 ; Starting priority byte
DB PAN_CH2, AUDTERM_2_LEFT | AUDTERM_2_RIGHT, 0
CH2_LENGTH_DUTY AUDLEN_DUTY_50, 0, 0
CH2_VOLENV $7, AUDENV_DOWN, 1, 0
CH2_FREQ NOTE_C_4, AUDHIGH_LENGTH_OFF, AUDHIGH_RESTART, 5
CH2_FREQ NOTE_E_4, AUDHIGH_LENGTH_OFF, AUDHIGH_RESTART, 0
DB SOUND_END
_FX_Unpause:: ; (CH2) Played when pause menu is closed
DB 0 ; Starting priority byte
DB PAN_CH2, AUDTERM_2_LEFT | AUDTERM_2_RIGHT, 0
CH2_LENGTH_DUTY AUDLEN_DUTY_50, 0, 0
CH2_VOLENV $7, AUDENV_DOWN, 1, 0
CH2_FREQ NOTE_E_4, AUDHIGH_LENGTH_OFF, AUDHIGH_RESTART, 5
CH2_FREQ NOTE_C_4, AUDHIGH_LENGTH_OFF, AUDHIGH_RESTART, 0
DB SOUND_END
_FX_Reset:: ; (CH4) Played when a level is reset
DB 0 ; Starting priority byte
DB PAN_CH4, AUDTERM_4_LEFT | AUDTERM_4_RIGHT, 0
CH4_VOLENV $8, AUDENV_DOWN, 5, 0
CH4_POLYCT AUD4POLY_15STEP, $6, $4, 0
CH4_RESTART AUDHIGH_LENGTH_OFF, AUDHIGH_RESTART, 0
DB SOUND_END
|
;/*!
; @file
;
; @ingroup fapi
;
; @brief DosSetVerify DOS wrapper
;
; (c) osFree Project 2018, <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)
;
;--------D-212E--DL00-------------------------
;INT 21 - DOS 1+ - SET VERIFY FLAG
; AH = 2Eh
; DL = 00h (DOS 1.x/2.x only)
; AL = new state of verify flag
; 00h off
; 01h on
;Notes: default state at system boot is OFF
; when ON, all disk writes are verified provided the device driver
; supports read-after-write verification
;SeeAlso: AH=54h
;
;
;*/
.8086
; Helpers
INCLUDE helpers.inc
INCLUDE dos.inc
_TEXT SEGMENT BYTE PUBLIC 'CODE' USE16
@PROLOG DOSSETVERIFY
VERIFYSETTING DW ?
@START DOSSETVERIFY
XOR DL, DL
MOV AX, [DS:BP].ARGS.VERIFYSETTING
VERIFY AL
XOR AX, AX
@EPILOG DOSSETVERIFY
_TEXT ENDS
END
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r13
push %r8
push %r9
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x10313, %rsi
lea addresses_D_ht+0x1ac9b, %rdi
nop
nop
nop
cmp %r11, %r11
mov $40, %rcx
rep movsw
nop
nop
nop
nop
nop
cmp $63512, %r9
lea addresses_WT_ht+0x1de87, %rbp
nop
nop
nop
add %rdi, %rdi
movb (%rbp), %r9b
nop
nop
nop
nop
dec %rcx
lea addresses_normal_ht+0xff29, %rbp
nop
nop
inc %r8
movl $0x61626364, (%rbp)
nop
nop
nop
nop
sub %rcx, %rcx
lea addresses_A_ht+0x1ccd5, %rsi
lea addresses_WT_ht+0x5113, %rdi
clflush (%rsi)
nop
nop
nop
and $38655, %rbp
mov $32, %rcx
rep movsl
nop
nop
nop
nop
nop
xor $58729, %r11
lea addresses_WC_ht+0x155d7, %r11
nop
nop
nop
sub %rbp, %rbp
mov (%r11), %rsi
nop
nop
nop
inc %rsi
lea addresses_A_ht+0x1d513, %r9
nop
nop
add $47391, %rdi
movw $0x6162, (%r9)
nop
nop
nop
nop
cmp $28336, %r9
lea addresses_WC_ht+0x1c053, %rbp
dec %rcx
movups (%rbp), %xmm2
vpextrq $0, %xmm2, %rsi
nop
nop
nop
nop
xor $9931, %rbp
lea addresses_D_ht+0xf77e, %rsi
lea addresses_WT_ht+0x1bc33, %rdi
clflush (%rsi)
nop
xor $19308, %r13
mov $36, %rcx
rep movsw
nop
nop
and %r13, %r13
lea addresses_A_ht+0x11393, %rsi
lea addresses_UC_ht+0x16113, %rdi
nop
nop
nop
nop
dec %r13
mov $25, %rcx
rep movsw
and %r9, %r9
lea addresses_UC_ht+0x15993, %r8
nop
sub %rdi, %rdi
vmovups (%r8), %ymm5
vextracti128 $0, %ymm5, %xmm5
vpextrq $1, %xmm5, %rbp
inc %rsi
lea addresses_WC_ht+0x2501, %rbp
nop
nop
nop
nop
and %rsi, %rsi
mov (%rbp), %r8
sub $49104, %r11
lea addresses_UC_ht+0x7593, %rdi
nop
nop
nop
nop
mfence
mov $0x6162636465666768, %rbp
movq %rbp, %xmm3
movups %xmm3, (%rdi)
nop
nop
nop
nop
xor %r11, %r11
lea addresses_normal_ht+0x70d3, %rcx
nop
nop
cmp %rbp, %rbp
mov (%rcx), %di
nop
nop
nop
cmp $61727, %rdi
lea addresses_UC_ht+0xc8d3, %rsi
lea addresses_WT_ht+0x8283, %rdi
clflush (%rdi)
nop
add $22489, %r13
mov $62, %rcx
rep movsw
nop
nop
nop
and $19554, %r13
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r9
pop %r8
pop %r13
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r14
push %r8
push %rax
push %rbp
push %rdx
// Load
lea addresses_D+0x5713, %r10
nop
nop
nop
sub $43723, %r13
mov (%r10), %edx
nop
nop
nop
nop
and %r8, %r8
// Load
lea addresses_RW+0x1e203, %rbp
nop
nop
nop
and $42190, %rax
movb (%rbp), %dl
nop
nop
nop
inc %r10
// Store
mov $0x5f21420000000f13, %r13
sub $27262, %r10
mov $0x5152535455565758, %rbp
movq %rbp, (%r13)
nop
nop
nop
nop
add %r8, %r8
// Faulty Load
lea addresses_D+0x5713, %rdx
nop
nop
add $45006, %r13
mov (%rdx), %r8d
lea oracles, %r10
and $0xff, %r8
shlq $12, %r8
mov (%r10,%r8,1), %r8
pop %rdx
pop %rbp
pop %rax
pop %r8
pop %r14
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'src': {'same': False, 'congruent': 0, 'NT': True, 'type': 'addresses_D', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_RW', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_NC', 'size': 8, 'AVXalign': False}}
[Faulty Load]
{'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_D', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_D_ht', 'congruent': 2, 'same': False}}
{'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_WT_ht', 'size': 1, 'AVXalign': True}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': False}}
{'src': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}}
{'src': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': True, 'congruent': 9, 'NT': False, 'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_WC_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': True}}
{'src': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 7, 'same': False}}
{'src': {'same': True, 'congruent': 6, 'NT': False, 'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'}
{'src': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': False}}
{'src': {'same': False, 'congruent': 6, 'NT': False, 'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': True}, 'OP': 'LOAD'}
{'src': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}}
{'36': 3980}
36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36
*/
|
; A014068: a(n) = binomial(n*(n+1)/2, n).
; 1,1,3,20,210,3003,54264,1184040,30260340,886163135,29248649430,1074082795968,43430966148115,1917283000904460,91748617512913200,4730523156632595024,261429178502421685800,15415916972482007401455,966121413245991846673830,64123483527473864490450300,4493328435856148676833725680,331488223958251318888250434410,25681474500876263139852989106900,2084633151901356196159615812153600,176926190348085904875214147177736550,15670395194667906178067980466292384888,1445884606690623391125728175836628921939
sub $1,$0
bin $1,2
bin $1,$0
mov $0,$1
|
.p816
.feature c_comments
.include "macros.inc"
.rodata
ball0_tile_set: .incbin "tiles-256.bin"
ball1_tile_set: .incbin "tiles-224.bin"
ball2_tile_set: .incbin "tiles-192.bin"
ball3_tile_set: .incbin "tiles-160.bin"
bmp_1: .incbin "grid-00000.bin"
bmp_2: .incbin "grid-10000.bin"
bmp_3: .incbin "grid-20000.bin"
bmp_4: .incbin "grid-30000.bin"
bmp_5: .incbin "grid-40000.bin"
lut_4: .incbin "grid.col"
.bss
ROW_CLEAR_BLOCK: .res 16
.zeropage
Ball0_x: .res 2 ; x position
Ball1_x: .res 2 ; x position
Ball2_x: .res 2 ; x position
Ball3_x: .res 2 ; x position
Ball0_y: .res 2 ; y position
Ball1_y: .res 2 ; y position
Ball2_y: .res 2 ; y position
Ball3_y: .res 2 ; y position
Ball0_ay: .res 2 ; y acceleration
Ball1_ay: .res 2 ; y acceleration
Ball2_ay: .res 2 ; y acceleration
Ball3_ay: .res 2 ; y acceleration
Ball0_dx: .res 2 ; x delta
Ball1_dx: .res 2 ; x delta
Ball2_dx: .res 2 ; x delta
Ball3_dx: .res 2 ; x delta
Ball0_dy: .res 2 ; y delta
Ball1_dy: .res 2 ; y delta
Ball2_dy: .res 2 ; y delta
Ball3_dy: .res 2 ; y delta
Ball0_sx: .res 2 ; x delta sign
Ball1_sx: .res 2 ; x delta sign
Ball2_sx: .res 2 ; x delta sign
Ball3_sx: .res 2 ; x delta sign
Ball0_sy: .res 2 ; y delta sign
Ball1_sy: .res 2 ; y delta sign
Ball2_sy: .res 2 ; y delta sign
Ball3_sy: .res 2 ; y delta sign
Param1Addr: .res 3
Param2Addr: .res 3
Param1Word: .res 2
Param2Word: .res 2
Lut0CycleLo: .res 3
Lut1CycleLo: .res 3
Lut2CycleLo: .res 3
Lut3CycleLo: .res 3
Lut0CycleHi: .res 3
Lut1CycleHi: .res 3
Lut2CycleHi: .res 3
Lut3CycleHi: .res 3
COLOR_SAVE_RG: .res 2 ; tmp storage for color values
COLOR_SAVE_BA: .res 2 ; tmp storage for color values
RC: .res 1
GC: .res 1
BC: .res 1
.code
INT_PENDING_REG0 = $000140
FNX0_INT00_SOF = $01
BORDER_CTRL_REG = $af0004
VICKY_CTRL_REG = $af0000
BG_R = $af0008
BG_G = $af0009
BG_B = $af000a
BMAP_CTRL = $af0140
BMAP_ADDR = $af0141
TILE_0_REG = $af0100
TILE_1_REG = $af0108
TILE_2_REG = $af0110
TILE_3_REG = $af0118
TILE_0_MAP = $af50
TILE_1_MAP = $af58
TILE_2_MAP = $af60
TILE_3_MAP = $af68
LUT_0 = $af20
LUT_1 = $af24
LUT_2 = $af28
LUT_3 = $af2c
; for tiles
BALL_0_DST = $b00000
BALL_1_DST = $b10000
BALL_2_DST = $b20000
BALL_3_DST = $b30000
; for background bitmap
; BMAP_HI/MD/LO must point to video ram relative to $000000
BMAP_HI = $04
BMAP_MD = $00
BMAP_LO = $00
BMAP_1 = $b40000
BMAP_2 = $b50000
BMAP_3 = $b60000
BMAP_4 = $b70000
BMAP_5 = $b80000
BMAP_LUT = $af3000
; The structure of a tile
.struct Tile
ctrl_reg .byte
start_addr .word
start_addr_page .byte
x_offset .byte ; x offset
y_offset .byte ; y offset
.endstruct
.import __ZEROPAGE_LOAD__ ; symbol defining the start of the ZP
begin:
jmp init
.include "place_tiles.asm"
.include "clear_tiles.asm"
.include "set_lut.asm"
.include "ball.asm"
init:
; set zero page to $fe00
acc16i16
lda #__ZEROPAGE_LOAD__
tcd
; stop IRQ handling
sei
;; copy the tile set data into $b0;
;; can't just use one MVP as this spans across the bank into the next
acc8i16
CopyBlock ball0_tile_set, BALL_0_DST, 0 ; 64k
CopyBlock ball1_tile_set, BALL_1_DST, 0 ; 64k
CopyBlock ball2_tile_set, BALL_2_DST, 0 ; 64k
CopyBlock ball3_tile_set, BALL_3_DST, 0 ; 64k
lda #(1 | 4 << 4) ; turn on bitmap with lut 4
; Point bitmap to where background data went
sta BMAP_CTRL
lda #BMAP_LO
sta BMAP_ADDR
lda #BMAP_MD
sta BMAP_ADDR+1
lda #BMAP_HI
sta BMAP_ADDR+2
CopyBlock bmp_1, BMAP_1, 0 ; 64k
CopyBlock bmp_2, BMAP_2, 0 ; 64k
CopyBlock bmp_3, BMAP_3, 0 ; 64k
CopyBlock bmp_4, BMAP_4, 0 ; 64k
CopyBlock bmp_5, BMAP_5, $b000
CopyBlock lut_4, BMAP_LUT, $400
; turn off border
lda #0
sta BORDER_CTRL_REG
; set tile and bitmap mode
lda #$18
sta VICKY_CTRL_REG
; black background
lda #$0
sta BG_R
sta BG_G
sta BG_B
; Enable tiles + options + desired LUT for each
EnableTiles TILE_0_REG, 0, $0000, $00
EnableTiles TILE_1_REG, 1, $0000, $01
EnableTiles TILE_2_REG, 2, $0000, $02
EnableTiles TILE_3_REG, 3, $0000, $03
; BallNum, XPos, YPos, XVelocity, YVelocity, YAccel
SetBallParameters 0, 32, 48, 1, 0, 1
SetBallParameters 1, 64, 64, 2, 0, 1
SetBallParameters 2, 128, 16, 2, 0, 1
SetBallParameters 3, 192, 86, 3, 0, 1
; Init LUT tables: LUTAddr, R, G, B
SetColorLut LUT_0, 127, 0, 0 ; Red
SetColorLut LUT_1, 0, 127, 0 ; Green
SetColorLut LUT_2, 127, 127, 0 ; Purple
SetColorLut LUT_3, 0, 0, 127 ; Blue
; Pre-compute lut hi/lo addresses for lut cycle macros
SetLUTAddress LUT_0, Lut0CycleHi, Lut0CycleLo
SetLUTAddress LUT_1, Lut1CycleHi, Lut1CycleLo
SetLUTAddress LUT_2, Lut2CycleHi, Lut2CycleLo
SetLUTAddress LUT_3, Lut3CycleHi, Lut3CycleLo
loop:
ClearBall TILE_0_MAP, Ball0_x, Ball0_y
BallPhysics 0
CycleLut Lut0CycleHi, Lut0CycleLo
DrawBall TILE_0_MAP, Ball0_x, Ball0_y
SetTileXScroll Ball0_x, TILE_0_REG
SetTileYScroll Ball0_y, TILE_0_REG
ClearBall TILE_1_MAP, Ball1_x, Ball1_y
BallPhysics 1
CycleLut Lut1CycleHi, Lut1CycleLo
DrawBall TILE_1_MAP, Ball1_x, Ball1_y
SetTileXScroll Ball1_x, TILE_1_REG
SetTileYScroll Ball1_y, TILE_1_REG
ClearBall TILE_2_MAP, Ball2_x, Ball2_y
BallPhysics 2
CycleLut Lut2CycleHi, Lut2CycleLo
DrawBall TILE_2_MAP, Ball2_x, Ball2_y
SetTileXScroll Ball2_x, TILE_2_REG
SetTileYScroll Ball2_y, TILE_2_REG
ClearBall TILE_3_MAP, Ball3_x, Ball3_y
BallPhysics 3
CycleLut Lut3CycleHi, Lut3CycleLo
DrawBall TILE_3_MAP, Ball3_x, Ball3_y
SetTileXScroll Ball3_x, TILE_3_REG
SetTileYScroll Ball3_y, TILE_3_REG
delay:
lda f:INT_PENDING_REG0 ; have to use far because DBR keeps
; getting clobbered
and #FNX0_INT00_SOF
cmp #FNX0_INT00_SOF ; check for SOF interrupt
bne delay ; not there, spin
sta f:INT_PENDING_REG0 ; if so, clear the interrupt
jmp loop ; and then cycle loop
|
; A023515: a(n) = prime(n)*prime(n-1) - 1.
; 1,5,14,34,76,142,220,322,436,666,898,1146,1516,1762,2020,2490,3126,3598,4086,4756,5182,5766,6556,7386,8632,9796,10402,11020,11662,12316,14350,16636,17946,19042,20710,22498,23706,25590,27220,28890,30966,32398,34570,36862,38020,39202,41988,47052,50620,51982,53356,55686,57598,60490,64506,67590,70746,72898,75066,77836,79522,82918,89950,95476,97342,99220,104926,111546,116938,121102,123196,126726,131752,136890,141366,145156,148986,154432,159196,164008,171370,176398,181450,186622,190086,194476,198906
seq $0,8578 ; Prime numbers at the beginning of the 20th century (today 1 is no longer regarded as a prime).
seq $0,13636 ; n*nextprime(n).
sub $0,1
|
# MIPS executa linha por linha
# Começa em .text, main é considerado padrão para começar
.text # programa vai embaixo de .text, o que vai rodar
# label
main:
# registradores armazenam informação
# no MARS, podemos ver os registradores na direita ($)
# Carregar valores em um registrador:
li $t0, 5 # load immediate, registrador <- valor
li $v0, 10 # valores armazenados em hex (10 = A)
# Operandos
add $t0, $t1, $t2 # t0 <- t1 + t2
sub $t0, $t1, $t2 # t0 <- t1 - t2
mul $t0, $t1, $t2 # t0 <- t1 * t2
# div $t0, $t1, $t2 # t0 <- t1 / t2
# Encerrar execução do programa
li $v0, 10
syscall
.data # dados vão embaixo de .data, variáveis, labels, words
# 0x10010000 - Primeiro endereço
cake: .ascii "the cake is a lie" # string
.data
str: .asciiz "the answer = "
.text
li $v0, 4 # $system call code for print_str
la $a0, str # $address of string to print
syscall # print the string
li $v0, 1 # $system call code for print_int
li $a0, 5 # $integer to print
syscall # print it
|
/***********************************************************************************************************************
* OpenStudio(R), Copyright (c) 2008-2017, Alliance for Sustainable Energy, LLC. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following
* disclaimer.
*
* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other materials provided with the distribution.
*
* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote
* products derived from this software without specific prior written permission from the respective party.
*
* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative
* works may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without
* specific prior written permission from Alliance for Sustainable Energy, LLC.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES GOVERNMENT, OR ANY 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 "IddFixture.hpp"
#include <utilities/idd/IddEnums.hxx>
using openstudio::FileLogSink;
using openstudio::toPath;
void IddFixture::SetUpTestCase()
{
// set up logging
logFile = FileLogSink(toPath("./IddFixture.log"));
logFile->setLogLevel(Debug);
// load from factory and time it
openstudio::Time start = openstudio::Time::currentTime();
epIddFile = openstudio::IddFactory::instance().getIddFile(openstudio::IddFileType::EnergyPlus);
iddLoadTime = openstudio::Time::currentTime() - start;
LOG(Info, "EnergyPlus IddFile load time (from IddFactory) = " << iddLoadTime);
start = openstudio::Time::currentTime();
osIddFile = openstudio::IddFactory::instance().getIddFile(openstudio::IddFileType::OpenStudio);
iddLoadTime = openstudio::Time::currentTime() - start;
LOG(Info, "OpenStudio IddFile load time (from IddFactory) = " << iddLoadTime);
}
void IddFixture::TearDownTestCase() {
logFile->disable();
}
openstudio::IddFile IddFixture::epIddFile;
openstudio::IddFile IddFixture::osIddFile;
openstudio::Time IddFixture::iddLoadTime;
boost::optional<openstudio::FileLogSink> IddFixture::logFile;
|
; A032196: Number of necklaces with 11 black beads and n-11 white beads.
; 1,1,6,26,91,273,728,1768,3978,8398,16796,32066,58786,104006,178296,297160,482885,766935,1193010,1820910,2731365,4032015,5864750,8414640,11920740,16689036,23107896,31666376,42975796
mov $2,$0
mov $0,4
mov $1,10
add $1,$2
bin $1,10
mul $1,4
mov $3,11
lpb $0,1
mov $0,1
sub $1,1
div $1,4
div $1,$3
add $1,2
lpe
sub $1,1
|
object_const_def ; object_event constants
const VICTORYROADGATE_OFFICER
const VICTORYROADGATE_OFFICER2
const VICTORYROADGATE_COOLTRAINERF
VictoryRoadGate_MapScripts:
db 2 ; scene scripts
scene_script .DummyScene0 ; SCENE_VICTORYROADGATE_NOTHING
scene_script .DummyScene1 ; SCENE_VICTORYROADGATE_CHECKBADGE
db 0 ; callbacks
.DummyScene0:
end
.DummyScene1:
end
VictoryRoadGateBadgeCheckScene:
turnobject PLAYER, RIGHT
turnobject VICTORYROADGATE_OFFICER, LEFT
sjump VictoryRoadGateBadgeCheckScript
VictoryRoadGateOfficerScript:
faceplayer
VictoryRoadGateBadgeCheckScript:
opentext
writetext VictoryRoadGateOfficerText
buttonsound
checkevent ENGINE_BOULDERBADGE
iftrue .CanGoThrough
writetext VictoryRoadGateNotEnoughBadgesText
waitbutton
closetext
applymovement PLAYER, VictoryRoadGateStepDownMovement
setmapscene VIRIDIAN_CITY, SCENE_VIRIDIANCITY_GYM_LOCKED
clearevent EVENT_VIRIDIAN_GRAMPS_OKAY
setevent EVENT_VIRIDIAN_GRAMPS_GRUMPY
checkevent ENGINE_POKEGEAR
iffalse .SetRedBattle
end
.SetRedBattle:
; checkevent EVENT_BATTLED_RED_ROUTE_22
; iftrue .DoNothing
setmapscene ROUTE_22, SCENE_ROUTE22_RED_BATTLE_1
end
.DoNothing:
end
.CanGoThrough:
writetext VictoryRoadGateEightBadgesText
waitbutton
closetext
setscene SCENE_FINISHED
end
VictoryRoadGateOfficer2Script:
jumptextfaceplayer VictoryRoadGateOfficer2Text
VictoryRoadGateCooltrainerFScript:
jumptextfaceplayer VictoryRoadGateCooltrainerFText
VictoryRoadGateStepDownMovement:
step DOWN
step_end
VictoryRoadGateOfficerText:
text "Only trainers who"
line "have proven them-"
cont "selves by earning"
cont "the BOULDERBADGE"
cont "may pass."
done
VictoryRoadGateNotEnoughBadgesText:
text "You don't have the"
line "BOULDERBADGE."
para "I'm sorry, but I"
line "can't let you go"
cont "through."
done
VictoryRoadGateEightBadgesText:
text "Oh! That's the"
line "BOULDERBADGE!"
para "Please, go right"
line "on through!"
done
VictoryRoadGateOfficer2Text:
text "Off to the #MON"
line "LEAGUE, are you?"
para "The ELITE FOUR are"
line "so strong it's"
para "scary, and they're"
line "ready for you!"
done
VictoryRoadGateCooltrainerFText:
text "If you want to pass"
line "through this gate,"
cont "you'll need the"
cont "BOULDERBADGE."
para "That's the BADGE"
line "from PEWTER's GYM."
para "I think there are"
line "more officers like"
cont "this one all over"
cont "ROUTE 23, too."
done
VictoryRoadGate_MapEvents:
db 0, 0 ; filler
db 4 ; warp events
warp_event 4, 7, ROUTE_22, 1
warp_event 5, 7, ROUTE_22, 1
warp_event 4, 0, ROUTE_23, 2
warp_event 5, 0, ROUTE_23, 3
db 1 ; coord events
coord_event 4, 2, SCENE_VICTORYROADGATE_CHECKBADGE, VictoryRoadGateBadgeCheckScene
db 0 ; bg events
db 3 ; object events
object_event 5, 2, SPRITE_OFFICER, SPRITEMOVEDATA_SPINRANDOM_SLOW, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, VictoryRoadGateOfficerScript, -1
object_event 2, 2, SPRITE_OFFICER, SPRITEMOVEDATA_SPINRANDOM_FAST, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, VictoryRoadGateOfficer2Script, -1
object_event 7, 5, SPRITE_COOLTRAINER_F, SPRITEMOVEDATA_WANDER, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, VictoryRoadGateCooltrainerFScript, -1
|
bits 64
default rel
section .text
global pal_execute_read_cs
pal_execute_read_cs :
xor rax, rax
mov ax, cs
ret
|
#ifndef EE_SYSTEM_IOSTREAMDEFLATE_HPP
#define EE_SYSTEM_IOSTREAMDEFLATE_HPP
#include <eepp/system/compression.hpp>
#include <eepp/system/iostream.hpp>
#include <eepp/system/scopedbuffer.hpp>
namespace EE { namespace System {
struct LocalStreamData;
/** @brief Implementation of a deflating stream */
class EE_API IOStreamDeflate : public IOStream {
public:
static IOStreamDeflate* New( IOStream& inOutStream, Compression::Mode mode,
const Compression::Config& config = Compression::Config() );
/** @brief Use a stream as a input or output buffer
** @param inOutStream Stream where the results will ve loaded or saved.
** It must be used only for reading or writing, can't mix both calls.
** @param mode Compression method used
** @param config Compression configuration
*/
IOStreamDeflate( IOStream& inOutStream, Compression::Mode mode,
const Compression::Config& config = Compression::Config() );
virtual ~IOStreamDeflate();
virtual ios_size read( char* data, ios_size size );
virtual ios_size write( const char* data, ios_size size );
virtual ios_size seek( ios_size position );
virtual ios_size tell();
virtual ios_size getSize();
virtual bool isOpen();
const Compression::Mode& getMode() const;
protected:
IOStream& mStream;
Compression::Mode mMode;
ScopedBuffer mBuffer;
LocalStreamData* mLocalStream;
};
}} // namespace EE::System
#endif // EE_SYSTEM_IOSTREAMDEFLATE_HPP
|
; A265611: a(n) = a(n-1) + floor((n-1)/2) - (-1)^n + 2 for n>=2, a(0)=1, a(1)=3.
; 1,3,4,8,10,15,18,24,28,35,40,48,54,63,70,80,88,99,108,120,130,143,154,168,180,195,208,224,238,255,270,288,304,323,340,360,378,399,418,440,460,483,504,528,550,575,598,624,648,675,700,728,754,783,810,840,868,899,928,960,990,1023,1054,1088,1120,1155,1188,1224,1258,1295,1330,1368,1404,1443,1480,1520,1558,1599,1638,1680,1720,1763,1804,1848,1890,1935,1978,2024,2068,2115,2160,2208,2254,2303,2350,2400,2448,2499,2548,2600,2650,2703,2754,2808,2860,2915,2968,3024,3078,3135,3190,3248,3304,3363,3420,3480,3538,3599,3658,3720,3780,3843,3904,3968,4030,4095,4158,4224,4288,4355,4420,4488,4554,4623,4690,4760,4828,4899,4968,5040,5110,5183,5254,5328,5400,5475,5548,5624,5698,5775,5850,5928,6004,6083,6160,6240,6318,6399,6478,6560,6640,6723,6804,6888,6970,7055,7138,7224,7308,7395,7480,7568,7654,7743,7830,7920,8008,8099,8188,8280,8370,8463,8554,8648,8740,8835,8928,9024,9118,9215,9310,9408,9504,9603,9700,9800,9898,9999,10098,10200,10300,10403,10504,10608,10710,10815,10918,11024,11128,11235,11340,11448,11554,11663,11770,11880,11988,12099,12208,12320,12430,12543,12654,12768,12880,12995,13108,13224,13338,13455,13570,13688,13804,13923,14040,14160,14278,14399,14518,14640,14760,14883,15004,15128,15250,15375,15498,15624,15748,15875
lpb $0
add $0,2
add $1,$0
trn $0,4
lpe
trn $1,1
add $1,1
|
#include <bits/stdc++.h>
using namespace std;
inline long long read()
{
long long x = 0;
int f = 1;
char ch = getchar();
while (ch < '0' || ch>'9')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
void write(const long long& x)
{
if (!x)
{
putchar('0');
return;
}
char f[100];
long long tmp = x;
if (tmp < 0)
{
tmp = -tmp;
putchar('-');
}
long long s = 0;
while (tmp > 0)
{
f[s++] = tmp % 10 + '0';
tmp /= 10;
}
while (s > 0)
{
putchar(f[--s]);
}
}
inline double dread()
{
double r;
double x=0,t=0;
int s=0,f=1;
char c=getchar();
for (;!isdigit(c);c=getchar())
{
if (c=='-')
{
f=-1;
}
if (c=='.')
{
goto readt;
}
}
for (;isdigit(c)&&c!='.';c=getchar())
{
x=x*10+c-'0';
}
readt:
for (;c=='.';c=getchar());
for (;isdigit(c);c=getchar())
{
t=t*10+c-'0';
++s;
}
r=(x+t/pow(10,s))*f;
return r;
}
inline void dwrite(long long x)
{
if (x == 0)
{
putchar(48);
return;
}
int bit[20], p = 0, i;
for (; x; x /= 10)
bit[++p] = x % 10;
for (i = p; i > 0; --i)
putchar(bit[i] + 48);
}
inline void write(double x,int k)
{
static int n = pow(10, k);
if (x == 0)
{
putchar('0');
putchar('.');
for (int i = 1; i <= k; ++i)
putchar('0');
return;
}
if (x < 0) putchar('-'), x = -x;
long long y = (long long) (x * n) % n;
x = (long long) x;
dwrite(x), putchar('.');
int bit[10], p = 0, i;
for (; p < k; y /= 10)
bit[++p] = y % 10;
for (i = p; i > 0; i--)
putchar(bit[i] + 48);
}
int totN,totM;
int que[650000];
int a[650000];
int sum[650000];
int DP[650000];
int A(int j,int k)
{
return (DP[j] + sum[j] * sum[j]) - (DP[k] + sum[k] * sum[k]);
}
int B(int j,int k)
{
return 2*(sum[j]-sum[k]);
}
int Val(int i,int j)
{
return DP[j] + (sum[i] - sum[j]) * (sum[i] - sum[j]) + totM;
}
int main()
{
while(~scanf("%d%d", &totN, &totM))
{
sum[0]=0;
memset(DP, 0, sizeof(DP));
memset(que,0,sizeof(que));
for(int i=1; i <= totN; i++)scanf("%d", &a[i]);
for(int i=1; i <= totN; i++)sum[i]= sum[i - 1] + a[i];
int head=0,tot=0;
que[tot++]=0;
for(int i=1; i <= totN; i++)
{
while(head+1<tot&&A(que[head+1],que[head])<=sum[i]*B(que[head+1],que[head]))head++;
DP[i]=Val(i, que[head]);
while(head+1<tot&&A(i,que[tot-1])*B(que[tot-1],que[tot-2])<=A(que[tot-1],que[tot-2])*B(i,que[tot-1]))tot--;
que[tot++]=i;
}
write(DP[totN]);
}
} |
; void sp1_InitCharStruct(struct sp1_cs *cs, void *drawf, uchar type, void *graphic, uchar plane)
; 05.2007 aralbrec, Sprite Pack v3.0
; sinclair spectrum version
SECTION code_clib
SECTION code_temp_sp1
PUBLIC asm_sp1_InitCharStruct
EXTERN _sp1_struct_cs_prototype
EXTERN SP1V_ROTTBL
asm_sp1_InitCharStruct:
; enter : a' = plane
; a = type
; hl = struct sp1_cs *
; de = address of sprite draw function
; bc = graphic
; uses : af, bc, de, hl, af', bc', de', hl'
push bc ; save graphic
push de ; save draw function
ex de,hl ; de = struct sp1_cs *
ld hl,_sp1_struct_cs_prototype
ld bc,24
ldir ; copy prototype struct sp1_cs into sp1_cs
ld hl,-5
add hl,de ; hl = & sp1_cs.draw + 1b
pop de
dec de ; de = & last byte of draw function data
ex de,hl
ldd ; copy draw function data into struct sp1_cs
ldd
ldd
dec hl
dec hl
dec de
dec de
ldd
ldd
pop bc ; bc = graphic
ex de,hl
ld (hl),b
dec hl
ld (hl),c
dec hl
dec de
dec de
ex de,hl
ldd
ex de,hl ; hl = & sp1_cs.ss_draw + 1b
ld (hl),sp1_ss_embedded / 256
dec hl
ld (hl),sp1_ss_embedded % 256
dec hl
dec hl
dec hl ; hl = & sp1_cs.type
ld (hl),a ; store type
dec hl
ex af,af
ld (hl),a ; store plane
ret
sp1_ss_embedded:
ld a,SP1V_ROTTBL/256 + 8 ; use rotation of four pixels if user selects a non-NR draw function
ld bc,0
ex de,hl
jp (hl)
|
; SBAS_IDATA - DATA Statement Handling 1994 Tony Tebby
section sbas
xdef bo_readf ; READ
xdef bo_read
xdef bo_readd
xdef bo_restore
xdef sb_dpset
xdef sb_dlsiset
xref sb_ierset
xref sb_fint
xref sb_adddst
xref sb_dstadd
include 'dev8_keys_sbasic'
include 'dev8_keys_err4'
include 'dev8_mac_assert'
;+++
; Within this routine
;
; D6 is limit of arithmetic stack (with some bytes spare)
; A1 is pointer to arithmetic stack
; A2 is entry address
; A3 is pointer to name table
; A4 is pointer to program
; A5 address of next token loop
; A6 is pointer to system variables
;---
;------------------------------------------------------------------
bo_restore
cmp.w #ar.int,(a1)+ ; is it an integer already?
beq.s brst_chk ; ... yes
jsr sb_fint
brst_chk
move.w (a1)+,d0
bgt.s brst_set
moveq #1,d0 ; always start at 1
brst_set
swap d0
move.w #$100,d0 ; line and item number
move.l d0,sb_dline(a6)
move.l a5,-(sp)
;+++
; Set data item pointer (points to parameter of preceding RTS2)
;---
sb_dpset
move.l sb_dtstb(a6),d0 ; any data statements?
beq.s sdp_end ; ... no
move.l sb_dline(a6),d0 ; next line, statement, item
jsr sb_dstadd
bmi.s sdp_end
move.l d0,a0
move.b sb_ditem(a6),d1 ; number of items to skip
bra.s sdp_check
sdp_item
add.w d0,a0 ; next item
sdp_check
move.w -2(a0),d0 ; length of next item
beq.s sdp_end
subq.b #1,d1
bcc.s sdp_item
move.l a0,sb_ndata(a6) ; next data item
rts
sdp_end
moveq #-1,d0
move.l d0,sb_ndata(a6) ; mark end of data
rts
;--------------------------------------------------- READ
bo_readf
tst.l sb_readp(a6) ; program pointer saved?
bne.s bor_recr ; ... yes, recursive reads!
bsr.s sb_dpset ; find first data item
move.l sb_ndata(a6),sb_readd(a6) ; save data pointer
;---------------------------------------------------
bo_read
move.l a4,sb_readp(a6) ; save program pointer
move.l sb_ndata(a6),d0
bmi.s bor_eod ; end of data
move.l d0,a4
move.l a4,a0
move.w -2(a4),d0 ; length of this item
beq.s bor_eod ; end of file
add.w d0,a0 ; next item
move.l a0,sb_ndata(a6) ; save it
jsr (a5) ; evaluate next data value
move.l sb_readp(a6),a4
jmp (a5) ; and continue
bor_eod
move.l sb_readp(a6),a4 ; failure address
clr.l sb_readp(a6)
moveq #ern4.eod,d0
jmp sb_ierset
bor_recr
clr.l sb_readp(a6) ; clear read to get error address
moveq #ern4.recr,d0
jmp sb_ierset
;--------------------------------------------------------
bo_readd
clr.l sb_readp(a6) ; no longer in read
move.l a5,-(sp)
sb_dlsiset
tst.l sb_dttbb(a6) ; any data statement table?
beq.s sdl_rts ; ... no
move.l sb_ndata(a6),d0 ; pointer to next data item
bmi.s sdl_eod ; end of data
move.l d0,d4
jsr sb_adddst ; convert to statement
tst.l d0 ; it exists?
bmi.s sdl_eod
bra.s sdl_eloop
sdl_loop
addq.b #1,d0 ; next item
add.w d1,a2 ; where it is
sdl_eloop
move.w -2(a2),d1
beq.s sdl_eod
cmp.l d4,a2 ; here yet?
blt.s sdl_loop
move.l d0,sb_dline(a6) ; save it
rts
sdl_eod
move.l sb_dttbp(a6),a0 ; last data statement
move.l st_line-st.len(a0),d0
addq.b #1,d0 ; next statement
lsl.w #8,d0
move.l d0,sb_dline(a6) ; next data item off end of data
moveq #-1,d0
move.l d0,sb_ndata(a6)
sdl_rts
rts
end
|
; A293547: a(n) is the integer k that minimizes |k/Fibonacci(n) - 2/3|.
; 0,1,1,1,2,3,5,9,14,23,37,59,96,155,251,407,658,1065,1723,2787,4510,7297,11807,19105,30912,50017,80929,130945,211874,342819,554693,897513,1452206,2349719,3801925,6151643,9953568,16105211,26058779,42163991,68222770,110386761,178609531,288996291,467605822,756602113,1224207935,1980810049,3205017984,5185828033,8390846017,13576674049,21967520066,35544194115,57511714181,93055908297,150567622478,243623530775,394191153253,637814684027,1032005837280,1669820521307,2701826358587,4371646879895,7073473238482,11445120118377,18518593356859,29963713475235,48482306832094,78446020307329,126928327139423,205374347446753,332302674586176,537677022032929,869979696619105,1407656718652033,2277636415271138,3685293133923171,5962929549194309
mov $1,3
mov $2,7
lpb $0
sub $0,1
sub $1,1
mov $4,$2
add $2,$1
sub $2,2
mov $3,2
add $3,$4
mov $1,$3
sub $1,2
lpe
div $1,6
|
/*-------------------------------------------------------------------------
* Vulkan Conformance Tests
* ------------------------
*
* Copyright (c) 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*//*!
* \file
* \brief YCbCr Format Tests
*//*--------------------------------------------------------------------*/
#include "vktYCbCrFormatTests.hpp"
#include "vktTestCaseUtil.hpp"
#include "vktTestGroupUtil.hpp"
#include "vktShaderExecutor.hpp"
#include "vktYCbCrUtil.hpp"
#include "vkStrUtil.hpp"
#include "vkRef.hpp"
#include "vkRefUtil.hpp"
#include "vkTypeUtil.hpp"
#include "vkQueryUtil.hpp"
#include "vkMemUtil.hpp"
#include "vkImageUtil.hpp"
#include "tcuTestLog.hpp"
#include "tcuVectorUtil.hpp"
#include "deStringUtil.hpp"
#include "deSharedPtr.hpp"
#include "deUniquePtr.hpp"
#include "deRandom.hpp"
#include "deSTLUtil.hpp"
namespace vkt
{
namespace ycbcr
{
namespace
{
// \todo [2017-05-24 pyry] Extend:
// * VK_IMAGE_TILING_LINEAR
// * Other shader types
using namespace vk;
using namespace shaderexecutor;
using tcu::UVec2;
using tcu::Vec2;
using tcu::Vec4;
using tcu::TestLog;
using de::MovePtr;
using de::UniquePtr;
using std::vector;
using std::string;
typedef de::SharedPtr<Allocation> AllocationSp;
typedef de::SharedPtr<vk::Unique<VkBuffer> > VkBufferSp;
Move<VkImage> createTestImage (const DeviceInterface& vkd,
VkDevice device,
VkFormat format,
const UVec2& size,
VkImageCreateFlags createFlags,
VkImageTiling tiling,
VkImageLayout layout)
{
const VkImageCreateInfo createInfo =
{
VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
DE_NULL,
createFlags,
VK_IMAGE_TYPE_2D,
format,
makeExtent3D(size.x(), size.y(), 1u),
1u, // mipLevels
1u, // arrayLayers
VK_SAMPLE_COUNT_1_BIT,
tiling,
VK_IMAGE_USAGE_TRANSFER_DST_BIT|VK_IMAGE_USAGE_SAMPLED_BIT,
VK_SHARING_MODE_EXCLUSIVE,
0u,
(const deUint32*)DE_NULL,
layout,
};
return createImage(vkd, device, &createInfo);
}
Move<VkImageView> createImageView (const DeviceInterface& vkd,
VkDevice device,
VkImage image,
VkFormat format,
VkSamplerYcbcrConversionKHR conversion)
{
const VkSamplerYcbcrConversionInfoKHR conversionInfo =
{
VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO_KHR,
DE_NULL,
conversion
};
const VkImageViewCreateInfo viewInfo =
{
VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
&conversionInfo,
(VkImageViewCreateFlags)0,
image,
VK_IMAGE_VIEW_TYPE_2D,
format,
{
VK_COMPONENT_SWIZZLE_IDENTITY,
VK_COMPONENT_SWIZZLE_IDENTITY,
VK_COMPONENT_SWIZZLE_IDENTITY,
VK_COMPONENT_SWIZZLE_IDENTITY,
},
{ VK_IMAGE_ASPECT_COLOR_BIT, 0u, 1u, 0u, 1u },
};
return createImageView(vkd, device, &viewInfo);
}
Move<VkDescriptorSetLayout> createDescriptorSetLayout (const DeviceInterface& vkd, VkDevice device, VkSampler sampler)
{
const VkDescriptorSetLayoutBinding binding =
{
0u, // binding
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
1u, // descriptorCount
VK_SHADER_STAGE_ALL,
&sampler
};
const VkDescriptorSetLayoutCreateInfo layoutInfo =
{
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
DE_NULL,
(VkDescriptorSetLayoutCreateFlags)0u,
1u,
&binding,
};
return createDescriptorSetLayout(vkd, device, &layoutInfo);
}
Move<VkDescriptorPool> createDescriptorPool (const DeviceInterface& vkd, VkDevice device)
{
const VkDescriptorPoolSize poolSizes[] =
{
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1u },
};
const VkDescriptorPoolCreateInfo poolInfo =
{
VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
DE_NULL,
(VkDescriptorPoolCreateFlags)VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
1u, // maxSets
DE_LENGTH_OF_ARRAY(poolSizes),
poolSizes,
};
return createDescriptorPool(vkd, device, & poolInfo);
}
Move<VkDescriptorSet> createDescriptorSet (const DeviceInterface& vkd,
VkDevice device,
VkDescriptorPool descPool,
VkDescriptorSetLayout descLayout,
VkImageView imageView,
VkSampler sampler)
{
Move<VkDescriptorSet> descSet;
{
const VkDescriptorSetAllocateInfo allocInfo =
{
VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
DE_NULL,
descPool,
1u,
&descLayout,
};
descSet = allocateDescriptorSet(vkd, device, &allocInfo);
}
{
const VkDescriptorImageInfo imageInfo =
{
sampler,
imageView,
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
};
const VkWriteDescriptorSet descriptorWrite =
{
VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
DE_NULL,
*descSet,
0u, // dstBinding
0u, // dstArrayElement
1u, // descriptorCount
VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
&imageInfo,
(const VkDescriptorBufferInfo*)DE_NULL,
(const VkBufferView*)DE_NULL,
};
vkd.updateDescriptorSets(device, 1u, &descriptorWrite, 0u, DE_NULL);
}
return descSet;
}
struct TestParameters
{
VkFormat format;
UVec2 size;
VkImageCreateFlags flags;
VkImageTiling tiling;
glu::ShaderType shaderType;
bool useMappedMemory;
TestParameters (VkFormat format_,
const UVec2& size_,
VkImageCreateFlags flags_,
VkImageTiling tiling_,
glu::ShaderType shaderType_,
bool useMappedMemory_)
: format (format_)
, size (size_)
, flags (flags_)
, tiling (tiling_)
, shaderType (shaderType_)
, useMappedMemory (useMappedMemory_)
{
}
TestParameters (void)
: format (VK_FORMAT_UNDEFINED)
, flags (0u)
, tiling (VK_IMAGE_TILING_OPTIMAL)
, shaderType (glu::SHADERTYPE_LAST)
, useMappedMemory (false)
{
}
};
ShaderSpec getShaderSpec (const TestParameters&)
{
ShaderSpec spec;
spec.inputs.push_back(Symbol("texCoord", glu::VarType(glu::TYPE_FLOAT_VEC2, glu::PRECISION_HIGHP)));
spec.outputs.push_back(Symbol("result", glu::VarType(glu::TYPE_FLOAT_VEC4, glu::PRECISION_HIGHP)));
spec.globalDeclarations =
"layout(binding = 0, set = 1) uniform highp sampler2D u_image;\n";
spec.source =
"result = texture(u_image, texCoord);\n";
return spec;
}
void checkSupport (Context& context, const TestParameters& params)
{
checkImageSupport(context, params.format, params.flags, params.tiling);
}
void generateLookupCoordinates (const UVec2& imageSize, vector<Vec2>* dst)
{
dst->resize(imageSize.x() * imageSize.y());
for (deUint32 texelY = 0; texelY < imageSize.y(); ++texelY)
for (deUint32 texelX = 0; texelX < imageSize.x(); ++texelX)
{
const float x = ((float)texelX + 0.5f) / (float)imageSize.x();
const float y = ((float)texelY + 0.5f) / (float)imageSize.y();
(*dst)[texelY*imageSize.x() + texelX] = Vec2(x, y);
}
}
tcu::TestStatus testFormat (Context& context, TestParameters params)
{
checkSupport(context, params);
const DeviceInterface& vkd = context.getDeviceInterface();
const VkDevice device = context.getDevice();
const VkFormat format = params.format;
const PlanarFormatDescription formatInfo = getPlanarFormatDescription(format);
const UVec2 size = params.size;
const VkImageCreateFlags createFlags = params.flags;
const VkImageTiling tiling = params.tiling;
const bool mappedMemory = params.useMappedMemory;
const Unique<VkImage> image (createTestImage(vkd, device, format, size, createFlags, tiling, mappedMemory ? VK_IMAGE_LAYOUT_PREINITIALIZED : VK_IMAGE_LAYOUT_UNDEFINED));
const vector<AllocationSp> allocations (allocateAndBindImageMemory(vkd, device, context.getDefaultAllocator(), *image, format, createFlags, mappedMemory ? MemoryRequirement::HostVisible : MemoryRequirement::Any));
const VkSamplerYcbcrConversionCreateInfoKHR conversionInfo =
{
VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO_KHR,
DE_NULL,
format,
VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY_KHR,
VK_SAMPLER_YCBCR_RANGE_ITU_FULL_KHR,
{
VK_COMPONENT_SWIZZLE_IDENTITY,
VK_COMPONENT_SWIZZLE_IDENTITY,
VK_COMPONENT_SWIZZLE_IDENTITY,
VK_COMPONENT_SWIZZLE_IDENTITY,
},
VK_CHROMA_LOCATION_MIDPOINT_KHR,
VK_CHROMA_LOCATION_MIDPOINT_KHR,
VK_FILTER_NEAREST,
VK_FALSE, // forceExplicitReconstruction
};
const Unique<VkSamplerYcbcrConversionKHR> conversion (createSamplerYcbcrConversionKHR(vkd, device, &conversionInfo));
const Unique<VkImageView> imageView (createImageView(vkd, device, *image, format, *conversion));
const VkSamplerYcbcrConversionInfoKHR samplerConversionInfo =
{
VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO_KHR,
DE_NULL,
*conversion,
};
const VkSamplerCreateInfo samplerInfo =
{
VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
&samplerConversionInfo,
0u,
VK_FILTER_NEAREST, // magFilter
VK_FILTER_NEAREST, // minFilter
VK_SAMPLER_MIPMAP_MODE_NEAREST, // mipmapMode
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // addressModeU
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // addressModeV
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, // addressModeW
0.0f, // mipLodBias
VK_FALSE, // anisotropyEnable
1.0f, // maxAnisotropy
VK_FALSE, // compareEnable
VK_COMPARE_OP_ALWAYS, // compareOp
0.0f, // minLod
0.0f, // maxLod
VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK, // borderColor
VK_FALSE, // unnormalizedCoords
};
const Unique<VkSampler> sampler (createSampler(vkd, device, &samplerInfo));
const Unique<VkDescriptorSetLayout> descLayout (createDescriptorSetLayout(vkd, device, *sampler));
const Unique<VkDescriptorPool> descPool (createDescriptorPool(vkd, device));
const Unique<VkDescriptorSet> descSet (createDescriptorSet(vkd, device, *descPool, *descLayout, *imageView, *sampler));
MultiPlaneImageData imageData (format, size);
// Prepare texture data
fillGradient(&imageData, Vec4(0.0f), Vec4(1.0f));
if (mappedMemory)
{
// Fill and prepare image
fillImageMemory(vkd,
device,
context.getUniversalQueueFamilyIndex(),
*image,
allocations,
imageData,
(VkAccessFlags)VK_ACCESS_SHADER_READ_BIT,
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
}
else
{
// Upload and prepare image
uploadImage(vkd,
device,
context.getUniversalQueueFamilyIndex(),
context.getDefaultAllocator(),
*image,
imageData,
(VkAccessFlags)VK_ACCESS_SHADER_READ_BIT,
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
}
{
vector<Vec2> texCoord;
vector<Vec4> result;
vector<Vec4> reference;
bool allOk = true;
Vec4 threshold (0.02f);
generateLookupCoordinates(size, &texCoord);
result.resize(texCoord.size());
reference.resize(texCoord.size());
{
UniquePtr<ShaderExecutor> executor (createExecutor(context, params.shaderType, getShaderSpec(params), *descLayout));
const void* inputs[] = { texCoord[0].getPtr() };
void* outputs[] = { result[0].getPtr() };
executor->execute((int)texCoord.size(), inputs, outputs, *descSet);
}
for (deUint32 channelNdx = 0; channelNdx < 4; channelNdx++)
{
if (formatInfo.hasChannelNdx(channelNdx))
{
const tcu::ConstPixelBufferAccess channelAccess = imageData.getChannelAccess(channelNdx);
const tcu::Sampler refSampler = mapVkSampler(samplerInfo);
const tcu::Texture2DView refTexView (1u, &channelAccess);
for (size_t ndx = 0; ndx < texCoord.size(); ++ndx)
{
const Vec2& coord = texCoord[ndx];
reference[ndx][channelNdx] = refTexView.sample(refSampler, coord.x(), coord.y(), 0.0f)[0];
}
}
else
{
for (size_t ndx = 0; ndx < texCoord.size(); ++ndx)
reference[ndx][channelNdx] = channelNdx == 3 ? 1.0f : 0.0f;
}
}
for (size_t ndx = 0; ndx < texCoord.size(); ++ndx)
{
if (boolAny(greaterThanEqual(abs(result[ndx] - reference[ndx]), threshold)))
{
context.getTestContext().getLog()
<< TestLog::Message << "ERROR: At " << texCoord[ndx]
<< ": got " << result[ndx]
<< ", expected " << reference[ndx]
<< TestLog::EndMessage;
allOk = false;
}
}
if (allOk)
return tcu::TestStatus::pass("All samples passed");
else
{
const tcu::ConstPixelBufferAccess refAccess (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::FLOAT),
tcu::IVec3((int)size.x(), (int)size.y(), 1u),
reference[0].getPtr());
const tcu::ConstPixelBufferAccess resAccess (tcu::TextureFormat(tcu::TextureFormat::RGBA, tcu::TextureFormat::FLOAT),
tcu::IVec3((int)size.x(), (int)size.y(), 1u),
result[0].getPtr());
context.getTestContext().getLog()
<< TestLog::Image("Result", "Result Image", resAccess, Vec4(1.0f), Vec4(0.0f))
<< TestLog::Image("Reference", "Reference Image", refAccess, Vec4(1.0f), Vec4(0.0f));
return tcu::TestStatus::fail("Got invalid results");
}
}
}
void initPrograms (SourceCollections& dst, TestParameters params)
{
const ShaderSpec spec = getShaderSpec(params);
generateSources(params.shaderType, spec, dst);
}
void populatePerFormatGroup (tcu::TestCaseGroup* group, VkFormat format)
{
const UVec2 size (66, 32);
const struct
{
const char* name;
glu::ShaderType value;
} shaderTypes[] =
{
{ "vertex", glu::SHADERTYPE_VERTEX },
{ "fragment", glu::SHADERTYPE_FRAGMENT },
{ "geometry", glu::SHADERTYPE_GEOMETRY },
{ "tess_control", glu::SHADERTYPE_TESSELLATION_CONTROL },
{ "tess_eval", glu::SHADERTYPE_TESSELLATION_EVALUATION },
{ "compute", glu::SHADERTYPE_COMPUTE }
};
const struct
{
const char* name;
VkImageTiling value;
} tilings[] =
{
{ "optimal", VK_IMAGE_TILING_OPTIMAL },
{ "linear", VK_IMAGE_TILING_LINEAR }
};
for (int shaderTypeNdx = 0; shaderTypeNdx < DE_LENGTH_OF_ARRAY(shaderTypes); shaderTypeNdx++)
for (int tilingNdx = 0; tilingNdx < DE_LENGTH_OF_ARRAY(tilings); tilingNdx++)
{
const VkImageTiling tiling = tilings[tilingNdx].value;
const char* const tilingName = tilings[tilingNdx].name;
const glu::ShaderType shaderType = shaderTypes[shaderTypeNdx].value;
const char* const shaderTypeName = shaderTypes[shaderTypeNdx].name;
const string name = string(shaderTypeName) + "_" + tilingName;
addFunctionCaseWithPrograms(group, name, "", initPrograms, testFormat, TestParameters(format, size, 0u, tiling, shaderType, false));
if (getPlaneCount(format) > 1)
addFunctionCaseWithPrograms(group, name + "_disjoint", "", initPrograms, testFormat, TestParameters(format, size, (VkImageCreateFlags)VK_IMAGE_CREATE_DISJOINT_BIT_KHR, tiling, shaderType, false));
if (tiling == VK_IMAGE_TILING_LINEAR)
{
addFunctionCaseWithPrograms(group, name + "_mapped", "", initPrograms, testFormat, TestParameters(format, size, 0u, tiling, shaderType, true));
if (getPlaneCount(format) > 1)
addFunctionCaseWithPrograms(group, name + "_disjoint_mapped", "", initPrograms, testFormat, TestParameters(format, size, (VkImageCreateFlags)VK_IMAGE_CREATE_DISJOINT_BIT_KHR, tiling, shaderType, true));
}
}
}
void populateFormatGroup (tcu::TestCaseGroup* group)
{
for (int formatNdx = VK_YCBCR_FORMAT_FIRST; formatNdx < VK_YCBCR_FORMAT_LAST; formatNdx++)
{
const VkFormat format = (VkFormat)formatNdx;
const string formatName = de::toLower(de::toString(format).substr(10));
group->addChild(createTestGroup<VkFormat>(group->getTestContext(), formatName, "", populatePerFormatGroup, format));
}
}
} // namespace
tcu::TestCaseGroup* createFormatTests (tcu::TestContext& testCtx)
{
return createTestGroup(testCtx, "format", "YCbCr Format Tests", populateFormatGroup);
}
} // ycbcr
} // vkt
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rdx
push %rsi
lea addresses_D_ht+0x10eba, %rdi
nop
nop
nop
nop
dec %rbx
movb $0x61, (%rdi)
nop
nop
nop
inc %rsi
lea addresses_UC_ht+0x1c4dc, %rsi
lea addresses_UC_ht+0x11dfa, %rdi
nop
nop
sub %rbx, %rbx
mov $104, %rcx
rep movsq
nop
inc %rbx
lea addresses_WT_ht+0xf31a, %r11
nop
nop
xor %rax, %rax
mov $0x6162636465666768, %rdi
movq %rdi, (%r11)
nop
nop
nop
nop
nop
sub %rdi, %rdi
lea addresses_A_ht+0xf3ba, %r9
nop
cmp $62547, %r11
mov (%r9), %si
nop
nop
nop
and $21268, %rsi
lea addresses_UC_ht+0x30ba, %r11
nop
xor %rbx, %rbx
movl $0x61626364, (%r11)
nop
nop
nop
nop
sub $41857, %rax
lea addresses_WT_ht+0x101ba, %rsi
lea addresses_WT_ht+0x940e, %rdi
nop
nop
nop
add %rdx, %rdx
mov $92, %rcx
rep movsw
nop
xor $58529, %rbx
lea addresses_normal_ht+0x13d3a, %rsi
nop
nop
nop
add %r9, %r9
movw $0x6162, (%rsi)
nop
xor $16972, %r11
lea addresses_D_ht+0x131ba, %rax
sub %r11, %r11
vmovups (%rax), %ymm4
vextracti128 $1, %ymm4, %xmm4
vpextrq $0, %xmm4, %r9
nop
nop
nop
nop
nop
add %r11, %r11
lea addresses_D_ht+0xfae2, %rsi
lea addresses_WT_ht+0x1d93a, %rdi
cmp $51455, %rbx
mov $108, %rcx
rep movsl
nop
and $2358, %rsi
pop %rsi
pop %rdx
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r13
push %r14
push %rbp
push %rdi
push %rsi
// Store
lea addresses_normal+0x10c3a, %r14
nop
nop
nop
nop
nop
and %r12, %r12
movl $0x51525354, (%r14)
nop
nop
nop
nop
lfence
// Load
lea addresses_WT+0x13fba, %r13
nop
nop
nop
nop
xor %rbp, %rbp
movb (%r13), %r11b
nop
nop
xor $30513, %r13
// Store
lea addresses_PSE+0x67ba, %r14
nop
nop
nop
nop
and %rdi, %rdi
mov $0x5152535455565758, %rbp
movq %rbp, %xmm4
vmovups %ymm4, (%r14)
xor $46579, %r14
// Store
lea addresses_WC+0x1c6fa, %r12
nop
nop
nop
sub %r13, %r13
movb $0x51, (%r12)
nop
nop
sub $48416, %r13
// Faulty Load
lea addresses_D+0xc3ba, %r11
clflush (%r11)
nop
nop
nop
nop
nop
xor %r12, %r12
mov (%r11), %r13
lea oracles, %rdi
and $0xff, %r13
shlq $12, %r13
mov (%rdi,%r13,1), %r13
pop %rsi
pop %rdi
pop %rbp
pop %r14
pop %r13
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal', 'NT': True, 'AVXalign': False, 'size': 4, 'congruent': 7}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT', 'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 6}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 9}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 6}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 8}}
{'OP': 'REPM', 'src': {'same': True, 'congruent': 1, 'type': 'addresses_UC_ht'}, 'dst': {'same': True, 'congruent': 6, 'type': 'addresses_UC_ht'}}
{'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 3}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 10}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 7}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_WT_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 5}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 9}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_WT_ht'}}
{'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
*/
|
clc
lda {m2}
adc {c1},x
sta {m1}
lda {m2}+1
adc {c1}+1,x
sta {m1}+1 |
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r13
push %r14
push %r8
push %rcx
push %rdi
push %rsi
lea addresses_D_ht+0x1312d, %rsi
lea addresses_UC_ht+0x1efbf, %rdi
nop
nop
and %r12, %r12
mov $43, %rcx
rep movsl
nop
nop
inc %r14
lea addresses_normal_ht+0x137ed, %rsi
lea addresses_WC_ht+0x5c53, %rdi
nop
nop
nop
nop
nop
xor %r8, %r8
mov $68, %rcx
rep movsl
nop
nop
cmp %r12, %r12
lea addresses_WT_ht+0x93b1, %rsi
nop
nop
nop
nop
nop
sub %r13, %r13
mov (%rsi), %r14w
nop
add $25805, %rdi
lea addresses_D_ht+0x2fed, %rcx
nop
nop
nop
nop
nop
and %r14, %r14
movl $0x61626364, (%rcx)
nop
xor $37458, %rdi
lea addresses_WT_ht+0x1d9ed, %r8
clflush (%r8)
sub %rsi, %rsi
movb $0x61, (%r8)
nop
nop
nop
nop
add $51338, %rsi
lea addresses_D_ht+0x1bfed, %rsi
lea addresses_normal_ht+0x2ded, %rdi
nop
nop
nop
xor %r11, %r11
mov $60, %rcx
rep movsb
nop
nop
nop
nop
nop
inc %rdi
lea addresses_A_ht+0x4461, %rsi
clflush (%rsi)
nop
sub %r12, %r12
movb $0x61, (%rsi)
nop
nop
nop
and %r8, %r8
lea addresses_WT_ht+0xf2dd, %rsi
lea addresses_normal_ht+0x10395, %rdi
nop
nop
nop
nop
nop
sub %r11, %r11
mov $77, %rcx
rep movsl
nop
nop
nop
nop
nop
dec %r13
lea addresses_UC_ht+0xf6ed, %r11
inc %rsi
mov (%r11), %di
sub %r13, %r13
pop %rsi
pop %rdi
pop %rcx
pop %r8
pop %r14
pop %r13
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r12
push %r8
push %rbx
push %rdi
push %rdx
push %rsi
// Store
lea addresses_WC+0xe5a9, %rdi
nop
cmp %r11, %r11
movb $0x51, (%rdi)
nop
nop
nop
nop
cmp $24483, %rdx
// Faulty Load
lea addresses_PSE+0x33ed, %rsi
nop
nop
nop
cmp $22666, %r8
movups (%rsi), %xmm2
vpextrq $1, %xmm2, %r11
lea oracles, %r8
and $0xff, %r11
shlq $12, %r11
mov (%r8,%r11,1), %r11
pop %rsi
pop %rdx
pop %rdi
pop %rbx
pop %r8
pop %r12
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 2}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': True, 'congruent': 6, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_UC_ht'}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 10, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 1, 'type': 'addresses_WC_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 5}}
{'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 8}}
{'OP': 'REPM', 'src': {'same': True, 'congruent': 7, 'type': 'addresses_D_ht'}, 'dst': {'same': True, 'congruent': 6, 'type': 'addresses_normal_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 1}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_normal_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 5}}
{'33': 21829}
33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33
*/
|
/* i | %1 (ID: 4) | mem2reg */
void foo(int* a) {
*a += 42;
}
int main() {
int i = 10;
foo(&i);
return 0;
} |
/* ====================================================================
* The Vovida Software License, Version 1.0
*
* Copyright (c) 2000-2003 Vovida Networks, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The names "VOCAL", "Vovida Open Communication Application Library",
* and "Vovida Open Communication Application Library (VOCAL)" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact vocal@vovida.org.
*
* 4. Products derived from this software may not be called "VOCAL", nor
* may "VOCAL" appear in their name, without prior written
* permission of Vovida Networks, Inc.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
* NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
* NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
* IN EXCESS OF $1,000, NOR FOR ANY 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.
*
* ====================================================================
*
* This software consists of voluntary contributions made by Vovida
* Networks, Inc. and many individuals on behalf of Vovida Networks,
* Inc. For more information on Vovida Networks, Inc., please see
* <http://www.vovida.org/>.
*
*/
static const char* const recvRegisterVersion =
"$Id: recvRegister.cxx,v 1.1 2004/05/01 04:15:25 greear Exp $";
#include <cstdlib>
#include <fstream>
#include "cpLog.h"
#include "Sptr.hxx"
#include "Data.hxx"
#include "VovidaSipStack.hxx"
#include "RegisterMsg.hxx"
#include "StatusMsg.hxx"
#include "TimeFunc.hxx"
using namespace Vocal;
///
int
main( int argc, char* argv[] )
{
if ( argc < 3 )
{
cerr << "Usage: "
<< argv[0]
<< " <local_SIP_port>"
<< " [ s|d ]"
<< endl;
exit( -1 );
}
Data logFile = "/tmp/rtr";
// logFile += getpid();
// logFile += ".log";
cpLogOpen( logFile.logData() );
if ( argc >= 3 )
{
cpLogSetPriority( ( *(argv[2]) == 's' ? LOG_DEBUG_STACK : LOG_DEBUG ) );
}
// SipTransceiverFilter stack( atoi( argv[1] ) );
SipTransceiver stack( "", atoi( argv[1] ) );
cout << "\t<<< Recieve Register Message test >>>\n" << endl;
cout << " Local SIP Port : " << argv[1] << endl;
cout << " Log File : " << logFile.logData() << endl << endl;
// Counters
int i = 0; // Register
int r = 0; // Response
Sptr < SipMsgQueue > sipRcv;
Sptr < SipMsg > sipMsg;
Sptr < RegisterMsg > registerMsg;
// FunctionTimer tReply;
// FunctionTimer tCheck;
// tCheck.start();
// TODO Add registration
while ( 1 )
{
sipRcv = stack.receive();
if ( sipRcv != 0 )
{
sipMsg = sipRcv->back();
if ( sipMsg != 0 )
{
registerMsg.dynamicCast( sipMsg );
if ( registerMsg == 0 )
{
cpLog( LOG_ERR, "Not a register message" );
}
else
{
++i;
++r;
if ( i % 100 == 0 )
{
cout << "I:" << i << " R:" << r << " ";
// tCheck.end();
// tCheck.print( "tCheck" );
// tCheck.start();
cout.flush();
}
// cout << "\rRegister " << i << " Response " << r << " Ack " << a;
// cout.flush();
StatusMsg statusMsg( *registerMsg, 200 );
// tReply.start();
stack.sendReply( statusMsg );
// tReply.end();
// tReply.print( "tReply" );
}
}
}
else
{
cpLog( LOG_ERR, "Received NULL from stack" );
}
}
cout << endl << endl;
return 0;
}
|
; A184591: floor[(n*(pi-1)-1]; complement of A184592.
; 1,3,5,7,9,11,13,16,18,20,22,24,26,28,31,33,35,37,39,41,43,46,48,50,52,54,56,58,61,63,65,67,69,71,73,76,78,80,82,84,86,88,91,93,95,97,99,101,103,106,108,110,112,114,116,118,121,123,125,127,129,131,133,136,138,140,142,144,146,148,151,153,155,157,159,161,163,166,168,170,172,174,176,178,181,183,185,187,189,191,193,196,198,200,202,204,206,208,211,213,215,217,219,221,223,226,228,230,232,234,236,238,240,243,245,247,249,251,253,255
mov $1,5
mov $4,$0
add $0,6
lpb $0
add $1,$0
sub $0,3
add $2,1
add $3,4
sub $1,$3
trn $1,6
mov $5,$2
sub $5,$0
mov $0,$1
add $0,4
trn $5,1
mov $1,$5
mov $3,1
lpe
mov $1,5
sub $2,2
add $1,$2
sub $1,1
lpb $4
add $1,2
sub $4,1
lpe
sub $1,3
|
;.word 0,0,0, NMI, RESET, IRQ
lda #$80
sta $8000
jmp RESET
.word NMI,$FFF2,IRQ
|
_mkdir: file format elf64-x86-64
Disassembly of section .text:
0000000000001000 <main>:
#include "stat.h"
#include "user.h"
int
main(int argc, char *argv[])
{
1000: f3 0f 1e fa endbr64
1004: 55 push %rbp
1005: 48 89 e5 mov %rsp,%rbp
1008: 48 83 ec 20 sub $0x20,%rsp
100c: 89 7d ec mov %edi,-0x14(%rbp)
100f: 48 89 75 e0 mov %rsi,-0x20(%rbp)
int i;
if(argc < 2){
1013: 83 7d ec 01 cmpl $0x1,-0x14(%rbp)
1017: 7f 2c jg 1045 <main+0x45>
printf(2, "Usage: mkdir files...\n");
1019: 48 be 20 1e 00 00 00 movabs $0x1e20,%rsi
1020: 00 00 00
1023: bf 02 00 00 00 mov $0x2,%edi
1028: b8 00 00 00 00 mov $0x0,%eax
102d: 48 ba 06 17 00 00 00 movabs $0x1706,%rdx
1034: 00 00 00
1037: ff d2 callq *%rdx
exit();
1039: 48 b8 0f 14 00 00 00 movabs $0x140f,%rax
1040: 00 00 00
1043: ff d0 callq *%rax
}
for(i = 1; i < argc; i++){
1045: c7 45 fc 01 00 00 00 movl $0x1,-0x4(%rbp)
104c: eb 6a jmp 10b8 <main+0xb8>
if(mkdir(argv[i]) < 0){
104e: 8b 45 fc mov -0x4(%rbp),%eax
1051: 48 98 cltq
1053: 48 8d 14 c5 00 00 00 lea 0x0(,%rax,8),%rdx
105a: 00
105b: 48 8b 45 e0 mov -0x20(%rbp),%rax
105f: 48 01 d0 add %rdx,%rax
1062: 48 8b 00 mov (%rax),%rax
1065: 48 89 c7 mov %rax,%rdi
1068: 48 b8 b8 14 00 00 00 movabs $0x14b8,%rax
106f: 00 00 00
1072: ff d0 callq *%rax
1074: 85 c0 test %eax,%eax
1076: 79 3c jns 10b4 <main+0xb4>
printf(2, "mkdir: %s failed to create\n", argv[i]);
1078: 8b 45 fc mov -0x4(%rbp),%eax
107b: 48 98 cltq
107d: 48 8d 14 c5 00 00 00 lea 0x0(,%rax,8),%rdx
1084: 00
1085: 48 8b 45 e0 mov -0x20(%rbp),%rax
1089: 48 01 d0 add %rdx,%rax
108c: 48 8b 00 mov (%rax),%rax
108f: 48 89 c2 mov %rax,%rdx
1092: 48 be 37 1e 00 00 00 movabs $0x1e37,%rsi
1099: 00 00 00
109c: bf 02 00 00 00 mov $0x2,%edi
10a1: b8 00 00 00 00 mov $0x0,%eax
10a6: 48 b9 06 17 00 00 00 movabs $0x1706,%rcx
10ad: 00 00 00
10b0: ff d1 callq *%rcx
break;
10b2: eb 0c jmp 10c0 <main+0xc0>
for(i = 1; i < argc; i++){
10b4: 83 45 fc 01 addl $0x1,-0x4(%rbp)
10b8: 8b 45 fc mov -0x4(%rbp),%eax
10bb: 3b 45 ec cmp -0x14(%rbp),%eax
10be: 7c 8e jl 104e <main+0x4e>
}
}
exit();
10c0: 48 b8 0f 14 00 00 00 movabs $0x140f,%rax
10c7: 00 00 00
10ca: ff d0 callq *%rax
00000000000010cc <stosb>:
"cc");
}
static inline void
stosb(void *addr, int data, int cnt)
{
10cc: f3 0f 1e fa endbr64
10d0: 55 push %rbp
10d1: 48 89 e5 mov %rsp,%rbp
10d4: 48 83 ec 10 sub $0x10,%rsp
10d8: 48 89 7d f8 mov %rdi,-0x8(%rbp)
10dc: 89 75 f4 mov %esi,-0xc(%rbp)
10df: 89 55 f0 mov %edx,-0x10(%rbp)
asm volatile("cld; rep stosb" :
10e2: 48 8b 4d f8 mov -0x8(%rbp),%rcx
10e6: 8b 55 f0 mov -0x10(%rbp),%edx
10e9: 8b 45 f4 mov -0xc(%rbp),%eax
10ec: 48 89 ce mov %rcx,%rsi
10ef: 48 89 f7 mov %rsi,%rdi
10f2: 89 d1 mov %edx,%ecx
10f4: fc cld
10f5: f3 aa rep stos %al,%es:(%rdi)
10f7: 89 ca mov %ecx,%edx
10f9: 48 89 fe mov %rdi,%rsi
10fc: 48 89 75 f8 mov %rsi,-0x8(%rbp)
1100: 89 55 f0 mov %edx,-0x10(%rbp)
"=D" (addr), "=c" (cnt) :
"0" (addr), "1" (cnt), "a" (data) :
"memory", "cc");
}
1103: 90 nop
1104: c9 leaveq
1105: c3 retq
0000000000001106 <strcpy>:
#include "user.h"
#include "x86.h"
char*
strcpy(char *s, char *t)
{
1106: f3 0f 1e fa endbr64
110a: 55 push %rbp
110b: 48 89 e5 mov %rsp,%rbp
110e: 48 83 ec 20 sub $0x20,%rsp
1112: 48 89 7d e8 mov %rdi,-0x18(%rbp)
1116: 48 89 75 e0 mov %rsi,-0x20(%rbp)
char *os;
os = s;
111a: 48 8b 45 e8 mov -0x18(%rbp),%rax
111e: 48 89 45 f8 mov %rax,-0x8(%rbp)
while((*s++ = *t++) != 0)
1122: 90 nop
1123: 48 8b 55 e0 mov -0x20(%rbp),%rdx
1127: 48 8d 42 01 lea 0x1(%rdx),%rax
112b: 48 89 45 e0 mov %rax,-0x20(%rbp)
112f: 48 8b 45 e8 mov -0x18(%rbp),%rax
1133: 48 8d 48 01 lea 0x1(%rax),%rcx
1137: 48 89 4d e8 mov %rcx,-0x18(%rbp)
113b: 0f b6 12 movzbl (%rdx),%edx
113e: 88 10 mov %dl,(%rax)
1140: 0f b6 00 movzbl (%rax),%eax
1143: 84 c0 test %al,%al
1145: 75 dc jne 1123 <strcpy+0x1d>
;
return os;
1147: 48 8b 45 f8 mov -0x8(%rbp),%rax
}
114b: c9 leaveq
114c: c3 retq
000000000000114d <strcmp>:
int
strcmp(const char *p, const char *q)
{
114d: f3 0f 1e fa endbr64
1151: 55 push %rbp
1152: 48 89 e5 mov %rsp,%rbp
1155: 48 83 ec 10 sub $0x10,%rsp
1159: 48 89 7d f8 mov %rdi,-0x8(%rbp)
115d: 48 89 75 f0 mov %rsi,-0x10(%rbp)
while(*p && *p == *q)
1161: eb 0a jmp 116d <strcmp+0x20>
p++, q++;
1163: 48 83 45 f8 01 addq $0x1,-0x8(%rbp)
1168: 48 83 45 f0 01 addq $0x1,-0x10(%rbp)
while(*p && *p == *q)
116d: 48 8b 45 f8 mov -0x8(%rbp),%rax
1171: 0f b6 00 movzbl (%rax),%eax
1174: 84 c0 test %al,%al
1176: 74 12 je 118a <strcmp+0x3d>
1178: 48 8b 45 f8 mov -0x8(%rbp),%rax
117c: 0f b6 10 movzbl (%rax),%edx
117f: 48 8b 45 f0 mov -0x10(%rbp),%rax
1183: 0f b6 00 movzbl (%rax),%eax
1186: 38 c2 cmp %al,%dl
1188: 74 d9 je 1163 <strcmp+0x16>
return (uchar)*p - (uchar)*q;
118a: 48 8b 45 f8 mov -0x8(%rbp),%rax
118e: 0f b6 00 movzbl (%rax),%eax
1191: 0f b6 d0 movzbl %al,%edx
1194: 48 8b 45 f0 mov -0x10(%rbp),%rax
1198: 0f b6 00 movzbl (%rax),%eax
119b: 0f b6 c0 movzbl %al,%eax
119e: 29 c2 sub %eax,%edx
11a0: 89 d0 mov %edx,%eax
}
11a2: c9 leaveq
11a3: c3 retq
00000000000011a4 <strlen>:
uint
strlen(char *s)
{
11a4: f3 0f 1e fa endbr64
11a8: 55 push %rbp
11a9: 48 89 e5 mov %rsp,%rbp
11ac: 48 83 ec 18 sub $0x18,%rsp
11b0: 48 89 7d e8 mov %rdi,-0x18(%rbp)
int n;
for(n = 0; s[n]; n++)
11b4: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
11bb: eb 04 jmp 11c1 <strlen+0x1d>
11bd: 83 45 fc 01 addl $0x1,-0x4(%rbp)
11c1: 8b 45 fc mov -0x4(%rbp),%eax
11c4: 48 63 d0 movslq %eax,%rdx
11c7: 48 8b 45 e8 mov -0x18(%rbp),%rax
11cb: 48 01 d0 add %rdx,%rax
11ce: 0f b6 00 movzbl (%rax),%eax
11d1: 84 c0 test %al,%al
11d3: 75 e8 jne 11bd <strlen+0x19>
;
return n;
11d5: 8b 45 fc mov -0x4(%rbp),%eax
}
11d8: c9 leaveq
11d9: c3 retq
00000000000011da <memset>:
void*
memset(void *dst, int c, uint n)
{
11da: f3 0f 1e fa endbr64
11de: 55 push %rbp
11df: 48 89 e5 mov %rsp,%rbp
11e2: 48 83 ec 10 sub $0x10,%rsp
11e6: 48 89 7d f8 mov %rdi,-0x8(%rbp)
11ea: 89 75 f4 mov %esi,-0xc(%rbp)
11ed: 89 55 f0 mov %edx,-0x10(%rbp)
stosb(dst, c, n);
11f0: 8b 55 f0 mov -0x10(%rbp),%edx
11f3: 8b 4d f4 mov -0xc(%rbp),%ecx
11f6: 48 8b 45 f8 mov -0x8(%rbp),%rax
11fa: 89 ce mov %ecx,%esi
11fc: 48 89 c7 mov %rax,%rdi
11ff: 48 b8 cc 10 00 00 00 movabs $0x10cc,%rax
1206: 00 00 00
1209: ff d0 callq *%rax
return dst;
120b: 48 8b 45 f8 mov -0x8(%rbp),%rax
}
120f: c9 leaveq
1210: c3 retq
0000000000001211 <strchr>:
char*
strchr(const char *s, char c)
{
1211: f3 0f 1e fa endbr64
1215: 55 push %rbp
1216: 48 89 e5 mov %rsp,%rbp
1219: 48 83 ec 10 sub $0x10,%rsp
121d: 48 89 7d f8 mov %rdi,-0x8(%rbp)
1221: 89 f0 mov %esi,%eax
1223: 88 45 f4 mov %al,-0xc(%rbp)
for(; *s; s++)
1226: eb 17 jmp 123f <strchr+0x2e>
if(*s == c)
1228: 48 8b 45 f8 mov -0x8(%rbp),%rax
122c: 0f b6 00 movzbl (%rax),%eax
122f: 38 45 f4 cmp %al,-0xc(%rbp)
1232: 75 06 jne 123a <strchr+0x29>
return (char*)s;
1234: 48 8b 45 f8 mov -0x8(%rbp),%rax
1238: eb 15 jmp 124f <strchr+0x3e>
for(; *s; s++)
123a: 48 83 45 f8 01 addq $0x1,-0x8(%rbp)
123f: 48 8b 45 f8 mov -0x8(%rbp),%rax
1243: 0f b6 00 movzbl (%rax),%eax
1246: 84 c0 test %al,%al
1248: 75 de jne 1228 <strchr+0x17>
return 0;
124a: b8 00 00 00 00 mov $0x0,%eax
}
124f: c9 leaveq
1250: c3 retq
0000000000001251 <gets>:
char*
gets(char *buf, int max)
{
1251: f3 0f 1e fa endbr64
1255: 55 push %rbp
1256: 48 89 e5 mov %rsp,%rbp
1259: 48 83 ec 20 sub $0x20,%rsp
125d: 48 89 7d e8 mov %rdi,-0x18(%rbp)
1261: 89 75 e4 mov %esi,-0x1c(%rbp)
int i, cc;
char c;
for(i=0; i+1 < max; ){
1264: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
126b: eb 4f jmp 12bc <gets+0x6b>
cc = read(0, &c, 1);
126d: 48 8d 45 f7 lea -0x9(%rbp),%rax
1271: ba 01 00 00 00 mov $0x1,%edx
1276: 48 89 c6 mov %rax,%rsi
1279: bf 00 00 00 00 mov $0x0,%edi
127e: 48 b8 36 14 00 00 00 movabs $0x1436,%rax
1285: 00 00 00
1288: ff d0 callq *%rax
128a: 89 45 f8 mov %eax,-0x8(%rbp)
if(cc < 1)
128d: 83 7d f8 00 cmpl $0x0,-0x8(%rbp)
1291: 7e 36 jle 12c9 <gets+0x78>
break;
buf[i++] = c;
1293: 8b 45 fc mov -0x4(%rbp),%eax
1296: 8d 50 01 lea 0x1(%rax),%edx
1299: 89 55 fc mov %edx,-0x4(%rbp)
129c: 48 63 d0 movslq %eax,%rdx
129f: 48 8b 45 e8 mov -0x18(%rbp),%rax
12a3: 48 01 c2 add %rax,%rdx
12a6: 0f b6 45 f7 movzbl -0x9(%rbp),%eax
12aa: 88 02 mov %al,(%rdx)
if(c == '\n' || c == '\r')
12ac: 0f b6 45 f7 movzbl -0x9(%rbp),%eax
12b0: 3c 0a cmp $0xa,%al
12b2: 74 16 je 12ca <gets+0x79>
12b4: 0f b6 45 f7 movzbl -0x9(%rbp),%eax
12b8: 3c 0d cmp $0xd,%al
12ba: 74 0e je 12ca <gets+0x79>
for(i=0; i+1 < max; ){
12bc: 8b 45 fc mov -0x4(%rbp),%eax
12bf: 83 c0 01 add $0x1,%eax
12c2: 39 45 e4 cmp %eax,-0x1c(%rbp)
12c5: 7f a6 jg 126d <gets+0x1c>
12c7: eb 01 jmp 12ca <gets+0x79>
break;
12c9: 90 nop
break;
}
buf[i] = '\0';
12ca: 8b 45 fc mov -0x4(%rbp),%eax
12cd: 48 63 d0 movslq %eax,%rdx
12d0: 48 8b 45 e8 mov -0x18(%rbp),%rax
12d4: 48 01 d0 add %rdx,%rax
12d7: c6 00 00 movb $0x0,(%rax)
return buf;
12da: 48 8b 45 e8 mov -0x18(%rbp),%rax
}
12de: c9 leaveq
12df: c3 retq
00000000000012e0 <stat>:
int
stat(char *n, struct stat *st)
{
12e0: f3 0f 1e fa endbr64
12e4: 55 push %rbp
12e5: 48 89 e5 mov %rsp,%rbp
12e8: 48 83 ec 20 sub $0x20,%rsp
12ec: 48 89 7d e8 mov %rdi,-0x18(%rbp)
12f0: 48 89 75 e0 mov %rsi,-0x20(%rbp)
int fd;
int r;
fd = open(n, O_RDONLY);
12f4: 48 8b 45 e8 mov -0x18(%rbp),%rax
12f8: be 00 00 00 00 mov $0x0,%esi
12fd: 48 89 c7 mov %rax,%rdi
1300: 48 b8 77 14 00 00 00 movabs $0x1477,%rax
1307: 00 00 00
130a: ff d0 callq *%rax
130c: 89 45 fc mov %eax,-0x4(%rbp)
if(fd < 0)
130f: 83 7d fc 00 cmpl $0x0,-0x4(%rbp)
1313: 79 07 jns 131c <stat+0x3c>
return -1;
1315: b8 ff ff ff ff mov $0xffffffff,%eax
131a: eb 2f jmp 134b <stat+0x6b>
r = fstat(fd, st);
131c: 48 8b 55 e0 mov -0x20(%rbp),%rdx
1320: 8b 45 fc mov -0x4(%rbp),%eax
1323: 48 89 d6 mov %rdx,%rsi
1326: 89 c7 mov %eax,%edi
1328: 48 b8 9e 14 00 00 00 movabs $0x149e,%rax
132f: 00 00 00
1332: ff d0 callq *%rax
1334: 89 45 f8 mov %eax,-0x8(%rbp)
close(fd);
1337: 8b 45 fc mov -0x4(%rbp),%eax
133a: 89 c7 mov %eax,%edi
133c: 48 b8 50 14 00 00 00 movabs $0x1450,%rax
1343: 00 00 00
1346: ff d0 callq *%rax
return r;
1348: 8b 45 f8 mov -0x8(%rbp),%eax
}
134b: c9 leaveq
134c: c3 retq
000000000000134d <atoi>:
int
atoi(const char *s)
{
134d: f3 0f 1e fa endbr64
1351: 55 push %rbp
1352: 48 89 e5 mov %rsp,%rbp
1355: 48 83 ec 18 sub $0x18,%rsp
1359: 48 89 7d e8 mov %rdi,-0x18(%rbp)
int n;
n = 0;
135d: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
while('0' <= *s && *s <= '9')
1364: eb 28 jmp 138e <atoi+0x41>
n = n*10 + *s++ - '0';
1366: 8b 55 fc mov -0x4(%rbp),%edx
1369: 89 d0 mov %edx,%eax
136b: c1 e0 02 shl $0x2,%eax
136e: 01 d0 add %edx,%eax
1370: 01 c0 add %eax,%eax
1372: 89 c1 mov %eax,%ecx
1374: 48 8b 45 e8 mov -0x18(%rbp),%rax
1378: 48 8d 50 01 lea 0x1(%rax),%rdx
137c: 48 89 55 e8 mov %rdx,-0x18(%rbp)
1380: 0f b6 00 movzbl (%rax),%eax
1383: 0f be c0 movsbl %al,%eax
1386: 01 c8 add %ecx,%eax
1388: 83 e8 30 sub $0x30,%eax
138b: 89 45 fc mov %eax,-0x4(%rbp)
while('0' <= *s && *s <= '9')
138e: 48 8b 45 e8 mov -0x18(%rbp),%rax
1392: 0f b6 00 movzbl (%rax),%eax
1395: 3c 2f cmp $0x2f,%al
1397: 7e 0b jle 13a4 <atoi+0x57>
1399: 48 8b 45 e8 mov -0x18(%rbp),%rax
139d: 0f b6 00 movzbl (%rax),%eax
13a0: 3c 39 cmp $0x39,%al
13a2: 7e c2 jle 1366 <atoi+0x19>
return n;
13a4: 8b 45 fc mov -0x4(%rbp),%eax
}
13a7: c9 leaveq
13a8: c3 retq
00000000000013a9 <memmove>:
void*
memmove(void *vdst, void *vsrc, int n)
{
13a9: f3 0f 1e fa endbr64
13ad: 55 push %rbp
13ae: 48 89 e5 mov %rsp,%rbp
13b1: 48 83 ec 28 sub $0x28,%rsp
13b5: 48 89 7d e8 mov %rdi,-0x18(%rbp)
13b9: 48 89 75 e0 mov %rsi,-0x20(%rbp)
13bd: 89 55 dc mov %edx,-0x24(%rbp)
char *dst, *src;
dst = vdst;
13c0: 48 8b 45 e8 mov -0x18(%rbp),%rax
13c4: 48 89 45 f8 mov %rax,-0x8(%rbp)
src = vsrc;
13c8: 48 8b 45 e0 mov -0x20(%rbp),%rax
13cc: 48 89 45 f0 mov %rax,-0x10(%rbp)
while(n-- > 0)
13d0: eb 1d jmp 13ef <memmove+0x46>
*dst++ = *src++;
13d2: 48 8b 55 f0 mov -0x10(%rbp),%rdx
13d6: 48 8d 42 01 lea 0x1(%rdx),%rax
13da: 48 89 45 f0 mov %rax,-0x10(%rbp)
13de: 48 8b 45 f8 mov -0x8(%rbp),%rax
13e2: 48 8d 48 01 lea 0x1(%rax),%rcx
13e6: 48 89 4d f8 mov %rcx,-0x8(%rbp)
13ea: 0f b6 12 movzbl (%rdx),%edx
13ed: 88 10 mov %dl,(%rax)
while(n-- > 0)
13ef: 8b 45 dc mov -0x24(%rbp),%eax
13f2: 8d 50 ff lea -0x1(%rax),%edx
13f5: 89 55 dc mov %edx,-0x24(%rbp)
13f8: 85 c0 test %eax,%eax
13fa: 7f d6 jg 13d2 <memmove+0x29>
return vdst;
13fc: 48 8b 45 e8 mov -0x18(%rbp),%rax
}
1400: c9 leaveq
1401: c3 retq
0000000000001402 <fork>:
mov $SYS_ ## name, %rax; \
mov %rcx, %r10 ;\
syscall ;\
ret
SYSCALL(fork)
1402: 48 c7 c0 01 00 00 00 mov $0x1,%rax
1409: 49 89 ca mov %rcx,%r10
140c: 0f 05 syscall
140e: c3 retq
000000000000140f <exit>:
SYSCALL(exit)
140f: 48 c7 c0 02 00 00 00 mov $0x2,%rax
1416: 49 89 ca mov %rcx,%r10
1419: 0f 05 syscall
141b: c3 retq
000000000000141c <wait>:
SYSCALL(wait)
141c: 48 c7 c0 03 00 00 00 mov $0x3,%rax
1423: 49 89 ca mov %rcx,%r10
1426: 0f 05 syscall
1428: c3 retq
0000000000001429 <pipe>:
SYSCALL(pipe)
1429: 48 c7 c0 04 00 00 00 mov $0x4,%rax
1430: 49 89 ca mov %rcx,%r10
1433: 0f 05 syscall
1435: c3 retq
0000000000001436 <read>:
SYSCALL(read)
1436: 48 c7 c0 05 00 00 00 mov $0x5,%rax
143d: 49 89 ca mov %rcx,%r10
1440: 0f 05 syscall
1442: c3 retq
0000000000001443 <write>:
SYSCALL(write)
1443: 48 c7 c0 10 00 00 00 mov $0x10,%rax
144a: 49 89 ca mov %rcx,%r10
144d: 0f 05 syscall
144f: c3 retq
0000000000001450 <close>:
SYSCALL(close)
1450: 48 c7 c0 15 00 00 00 mov $0x15,%rax
1457: 49 89 ca mov %rcx,%r10
145a: 0f 05 syscall
145c: c3 retq
000000000000145d <kill>:
SYSCALL(kill)
145d: 48 c7 c0 06 00 00 00 mov $0x6,%rax
1464: 49 89 ca mov %rcx,%r10
1467: 0f 05 syscall
1469: c3 retq
000000000000146a <exec>:
SYSCALL(exec)
146a: 48 c7 c0 07 00 00 00 mov $0x7,%rax
1471: 49 89 ca mov %rcx,%r10
1474: 0f 05 syscall
1476: c3 retq
0000000000001477 <open>:
SYSCALL(open)
1477: 48 c7 c0 0f 00 00 00 mov $0xf,%rax
147e: 49 89 ca mov %rcx,%r10
1481: 0f 05 syscall
1483: c3 retq
0000000000001484 <mknod>:
SYSCALL(mknod)
1484: 48 c7 c0 11 00 00 00 mov $0x11,%rax
148b: 49 89 ca mov %rcx,%r10
148e: 0f 05 syscall
1490: c3 retq
0000000000001491 <unlink>:
SYSCALL(unlink)
1491: 48 c7 c0 12 00 00 00 mov $0x12,%rax
1498: 49 89 ca mov %rcx,%r10
149b: 0f 05 syscall
149d: c3 retq
000000000000149e <fstat>:
SYSCALL(fstat)
149e: 48 c7 c0 08 00 00 00 mov $0x8,%rax
14a5: 49 89 ca mov %rcx,%r10
14a8: 0f 05 syscall
14aa: c3 retq
00000000000014ab <link>:
SYSCALL(link)
14ab: 48 c7 c0 13 00 00 00 mov $0x13,%rax
14b2: 49 89 ca mov %rcx,%r10
14b5: 0f 05 syscall
14b7: c3 retq
00000000000014b8 <mkdir>:
SYSCALL(mkdir)
14b8: 48 c7 c0 14 00 00 00 mov $0x14,%rax
14bf: 49 89 ca mov %rcx,%r10
14c2: 0f 05 syscall
14c4: c3 retq
00000000000014c5 <chdir>:
SYSCALL(chdir)
14c5: 48 c7 c0 09 00 00 00 mov $0x9,%rax
14cc: 49 89 ca mov %rcx,%r10
14cf: 0f 05 syscall
14d1: c3 retq
00000000000014d2 <dup>:
SYSCALL(dup)
14d2: 48 c7 c0 0a 00 00 00 mov $0xa,%rax
14d9: 49 89 ca mov %rcx,%r10
14dc: 0f 05 syscall
14de: c3 retq
00000000000014df <getpid>:
SYSCALL(getpid)
14df: 48 c7 c0 0b 00 00 00 mov $0xb,%rax
14e6: 49 89 ca mov %rcx,%r10
14e9: 0f 05 syscall
14eb: c3 retq
00000000000014ec <sbrk>:
SYSCALL(sbrk)
14ec: 48 c7 c0 0c 00 00 00 mov $0xc,%rax
14f3: 49 89 ca mov %rcx,%r10
14f6: 0f 05 syscall
14f8: c3 retq
00000000000014f9 <sleep>:
SYSCALL(sleep)
14f9: 48 c7 c0 0d 00 00 00 mov $0xd,%rax
1500: 49 89 ca mov %rcx,%r10
1503: 0f 05 syscall
1505: c3 retq
0000000000001506 <uptime>:
SYSCALL(uptime)
1506: 48 c7 c0 0e 00 00 00 mov $0xe,%rax
150d: 49 89 ca mov %rcx,%r10
1510: 0f 05 syscall
1512: c3 retq
0000000000001513 <aread>:
SYSCALL(aread)
1513: 48 c7 c0 16 00 00 00 mov $0x16,%rax
151a: 49 89 ca mov %rcx,%r10
151d: 0f 05 syscall
151f: c3 retq
0000000000001520 <putc>:
#include <stdarg.h>
static void
putc(int fd, char c)
{
1520: f3 0f 1e fa endbr64
1524: 55 push %rbp
1525: 48 89 e5 mov %rsp,%rbp
1528: 48 83 ec 10 sub $0x10,%rsp
152c: 89 7d fc mov %edi,-0x4(%rbp)
152f: 89 f0 mov %esi,%eax
1531: 88 45 f8 mov %al,-0x8(%rbp)
write(fd, &c, 1);
1534: 48 8d 4d f8 lea -0x8(%rbp),%rcx
1538: 8b 45 fc mov -0x4(%rbp),%eax
153b: ba 01 00 00 00 mov $0x1,%edx
1540: 48 89 ce mov %rcx,%rsi
1543: 89 c7 mov %eax,%edi
1545: 48 b8 43 14 00 00 00 movabs $0x1443,%rax
154c: 00 00 00
154f: ff d0 callq *%rax
}
1551: 90 nop
1552: c9 leaveq
1553: c3 retq
0000000000001554 <print_x64>:
static char digits[] = "0123456789abcdef";
static void
print_x64(int fd, addr_t x)
{
1554: f3 0f 1e fa endbr64
1558: 55 push %rbp
1559: 48 89 e5 mov %rsp,%rbp
155c: 48 83 ec 20 sub $0x20,%rsp
1560: 89 7d ec mov %edi,-0x14(%rbp)
1563: 48 89 75 e0 mov %rsi,-0x20(%rbp)
int i;
for (i = 0; i < (sizeof(addr_t) * 2); i++, x <<= 4)
1567: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
156e: eb 35 jmp 15a5 <print_x64+0x51>
putc(fd, digits[x >> (sizeof(addr_t) * 8 - 4)]);
1570: 48 8b 45 e0 mov -0x20(%rbp),%rax
1574: 48 c1 e8 3c shr $0x3c,%rax
1578: 48 ba 90 21 00 00 00 movabs $0x2190,%rdx
157f: 00 00 00
1582: 0f b6 04 02 movzbl (%rdx,%rax,1),%eax
1586: 0f be d0 movsbl %al,%edx
1589: 8b 45 ec mov -0x14(%rbp),%eax
158c: 89 d6 mov %edx,%esi
158e: 89 c7 mov %eax,%edi
1590: 48 b8 20 15 00 00 00 movabs $0x1520,%rax
1597: 00 00 00
159a: ff d0 callq *%rax
for (i = 0; i < (sizeof(addr_t) * 2); i++, x <<= 4)
159c: 83 45 fc 01 addl $0x1,-0x4(%rbp)
15a0: 48 c1 65 e0 04 shlq $0x4,-0x20(%rbp)
15a5: 8b 45 fc mov -0x4(%rbp),%eax
15a8: 83 f8 0f cmp $0xf,%eax
15ab: 76 c3 jbe 1570 <print_x64+0x1c>
}
15ad: 90 nop
15ae: 90 nop
15af: c9 leaveq
15b0: c3 retq
00000000000015b1 <print_x32>:
static void
print_x32(int fd, uint x)
{
15b1: f3 0f 1e fa endbr64
15b5: 55 push %rbp
15b6: 48 89 e5 mov %rsp,%rbp
15b9: 48 83 ec 20 sub $0x20,%rsp
15bd: 89 7d ec mov %edi,-0x14(%rbp)
15c0: 89 75 e8 mov %esi,-0x18(%rbp)
int i;
for (i = 0; i < (sizeof(uint) * 2); i++, x <<= 4)
15c3: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
15ca: eb 36 jmp 1602 <print_x32+0x51>
putc(fd, digits[x >> (sizeof(uint) * 8 - 4)]);
15cc: 8b 45 e8 mov -0x18(%rbp),%eax
15cf: c1 e8 1c shr $0x1c,%eax
15d2: 89 c2 mov %eax,%edx
15d4: 48 b8 90 21 00 00 00 movabs $0x2190,%rax
15db: 00 00 00
15de: 89 d2 mov %edx,%edx
15e0: 0f b6 04 10 movzbl (%rax,%rdx,1),%eax
15e4: 0f be d0 movsbl %al,%edx
15e7: 8b 45 ec mov -0x14(%rbp),%eax
15ea: 89 d6 mov %edx,%esi
15ec: 89 c7 mov %eax,%edi
15ee: 48 b8 20 15 00 00 00 movabs $0x1520,%rax
15f5: 00 00 00
15f8: ff d0 callq *%rax
for (i = 0; i < (sizeof(uint) * 2); i++, x <<= 4)
15fa: 83 45 fc 01 addl $0x1,-0x4(%rbp)
15fe: c1 65 e8 04 shll $0x4,-0x18(%rbp)
1602: 8b 45 fc mov -0x4(%rbp),%eax
1605: 83 f8 07 cmp $0x7,%eax
1608: 76 c2 jbe 15cc <print_x32+0x1b>
}
160a: 90 nop
160b: 90 nop
160c: c9 leaveq
160d: c3 retq
000000000000160e <print_d>:
static void
print_d(int fd, int v)
{
160e: f3 0f 1e fa endbr64
1612: 55 push %rbp
1613: 48 89 e5 mov %rsp,%rbp
1616: 48 83 ec 30 sub $0x30,%rsp
161a: 89 7d dc mov %edi,-0x24(%rbp)
161d: 89 75 d8 mov %esi,-0x28(%rbp)
char buf[16];
int64 x = v;
1620: 8b 45 d8 mov -0x28(%rbp),%eax
1623: 48 98 cltq
1625: 48 89 45 f8 mov %rax,-0x8(%rbp)
if (v < 0)
1629: 83 7d d8 00 cmpl $0x0,-0x28(%rbp)
162d: 79 04 jns 1633 <print_d+0x25>
x = -x;
162f: 48 f7 5d f8 negq -0x8(%rbp)
int i = 0;
1633: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%rbp)
do {
buf[i++] = digits[x % 10];
163a: 48 8b 4d f8 mov -0x8(%rbp),%rcx
163e: 48 ba 67 66 66 66 66 movabs $0x6666666666666667,%rdx
1645: 66 66 66
1648: 48 89 c8 mov %rcx,%rax
164b: 48 f7 ea imul %rdx
164e: 48 c1 fa 02 sar $0x2,%rdx
1652: 48 89 c8 mov %rcx,%rax
1655: 48 c1 f8 3f sar $0x3f,%rax
1659: 48 29 c2 sub %rax,%rdx
165c: 48 89 d0 mov %rdx,%rax
165f: 48 c1 e0 02 shl $0x2,%rax
1663: 48 01 d0 add %rdx,%rax
1666: 48 01 c0 add %rax,%rax
1669: 48 29 c1 sub %rax,%rcx
166c: 48 89 ca mov %rcx,%rdx
166f: 8b 45 f4 mov -0xc(%rbp),%eax
1672: 8d 48 01 lea 0x1(%rax),%ecx
1675: 89 4d f4 mov %ecx,-0xc(%rbp)
1678: 48 b9 90 21 00 00 00 movabs $0x2190,%rcx
167f: 00 00 00
1682: 0f b6 14 11 movzbl (%rcx,%rdx,1),%edx
1686: 48 98 cltq
1688: 88 54 05 e0 mov %dl,-0x20(%rbp,%rax,1)
x /= 10;
168c: 48 8b 4d f8 mov -0x8(%rbp),%rcx
1690: 48 ba 67 66 66 66 66 movabs $0x6666666666666667,%rdx
1697: 66 66 66
169a: 48 89 c8 mov %rcx,%rax
169d: 48 f7 ea imul %rdx
16a0: 48 c1 fa 02 sar $0x2,%rdx
16a4: 48 89 c8 mov %rcx,%rax
16a7: 48 c1 f8 3f sar $0x3f,%rax
16ab: 48 29 c2 sub %rax,%rdx
16ae: 48 89 d0 mov %rdx,%rax
16b1: 48 89 45 f8 mov %rax,-0x8(%rbp)
} while(x != 0);
16b5: 48 83 7d f8 00 cmpq $0x0,-0x8(%rbp)
16ba: 0f 85 7a ff ff ff jne 163a <print_d+0x2c>
if (v < 0)
16c0: 83 7d d8 00 cmpl $0x0,-0x28(%rbp)
16c4: 79 32 jns 16f8 <print_d+0xea>
buf[i++] = '-';
16c6: 8b 45 f4 mov -0xc(%rbp),%eax
16c9: 8d 50 01 lea 0x1(%rax),%edx
16cc: 89 55 f4 mov %edx,-0xc(%rbp)
16cf: 48 98 cltq
16d1: c6 44 05 e0 2d movb $0x2d,-0x20(%rbp,%rax,1)
while (--i >= 0)
16d6: eb 20 jmp 16f8 <print_d+0xea>
putc(fd, buf[i]);
16d8: 8b 45 f4 mov -0xc(%rbp),%eax
16db: 48 98 cltq
16dd: 0f b6 44 05 e0 movzbl -0x20(%rbp,%rax,1),%eax
16e2: 0f be d0 movsbl %al,%edx
16e5: 8b 45 dc mov -0x24(%rbp),%eax
16e8: 89 d6 mov %edx,%esi
16ea: 89 c7 mov %eax,%edi
16ec: 48 b8 20 15 00 00 00 movabs $0x1520,%rax
16f3: 00 00 00
16f6: ff d0 callq *%rax
while (--i >= 0)
16f8: 83 6d f4 01 subl $0x1,-0xc(%rbp)
16fc: 83 7d f4 00 cmpl $0x0,-0xc(%rbp)
1700: 79 d6 jns 16d8 <print_d+0xca>
}
1702: 90 nop
1703: 90 nop
1704: c9 leaveq
1705: c3 retq
0000000000001706 <printf>:
// Print to the given fd. Only understands %d, %x, %p, %s.
void
printf(int fd, char *fmt, ...)
{
1706: f3 0f 1e fa endbr64
170a: 55 push %rbp
170b: 48 89 e5 mov %rsp,%rbp
170e: 48 81 ec f0 00 00 00 sub $0xf0,%rsp
1715: 89 bd 1c ff ff ff mov %edi,-0xe4(%rbp)
171b: 48 89 b5 10 ff ff ff mov %rsi,-0xf0(%rbp)
1722: 48 89 95 60 ff ff ff mov %rdx,-0xa0(%rbp)
1729: 48 89 8d 68 ff ff ff mov %rcx,-0x98(%rbp)
1730: 4c 89 85 70 ff ff ff mov %r8,-0x90(%rbp)
1737: 4c 89 8d 78 ff ff ff mov %r9,-0x88(%rbp)
173e: 84 c0 test %al,%al
1740: 74 20 je 1762 <printf+0x5c>
1742: 0f 29 45 80 movaps %xmm0,-0x80(%rbp)
1746: 0f 29 4d 90 movaps %xmm1,-0x70(%rbp)
174a: 0f 29 55 a0 movaps %xmm2,-0x60(%rbp)
174e: 0f 29 5d b0 movaps %xmm3,-0x50(%rbp)
1752: 0f 29 65 c0 movaps %xmm4,-0x40(%rbp)
1756: 0f 29 6d d0 movaps %xmm5,-0x30(%rbp)
175a: 0f 29 75 e0 movaps %xmm6,-0x20(%rbp)
175e: 0f 29 7d f0 movaps %xmm7,-0x10(%rbp)
va_list ap;
int i, c;
char *s;
va_start(ap, fmt);
1762: c7 85 20 ff ff ff 10 movl $0x10,-0xe0(%rbp)
1769: 00 00 00
176c: c7 85 24 ff ff ff 30 movl $0x30,-0xdc(%rbp)
1773: 00 00 00
1776: 48 8d 45 10 lea 0x10(%rbp),%rax
177a: 48 89 85 28 ff ff ff mov %rax,-0xd8(%rbp)
1781: 48 8d 85 50 ff ff ff lea -0xb0(%rbp),%rax
1788: 48 89 85 30 ff ff ff mov %rax,-0xd0(%rbp)
for (i = 0; (c = fmt[i] & 0xff) != 0; i++) {
178f: c7 85 4c ff ff ff 00 movl $0x0,-0xb4(%rbp)
1796: 00 00 00
1799: e9 41 03 00 00 jmpq 1adf <printf+0x3d9>
if (c != '%') {
179e: 83 bd 3c ff ff ff 25 cmpl $0x25,-0xc4(%rbp)
17a5: 74 24 je 17cb <printf+0xc5>
putc(fd, c);
17a7: 8b 85 3c ff ff ff mov -0xc4(%rbp),%eax
17ad: 0f be d0 movsbl %al,%edx
17b0: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
17b6: 89 d6 mov %edx,%esi
17b8: 89 c7 mov %eax,%edi
17ba: 48 b8 20 15 00 00 00 movabs $0x1520,%rax
17c1: 00 00 00
17c4: ff d0 callq *%rax
continue;
17c6: e9 0d 03 00 00 jmpq 1ad8 <printf+0x3d2>
}
c = fmt[++i] & 0xff;
17cb: 83 85 4c ff ff ff 01 addl $0x1,-0xb4(%rbp)
17d2: 8b 85 4c ff ff ff mov -0xb4(%rbp),%eax
17d8: 48 63 d0 movslq %eax,%rdx
17db: 48 8b 85 10 ff ff ff mov -0xf0(%rbp),%rax
17e2: 48 01 d0 add %rdx,%rax
17e5: 0f b6 00 movzbl (%rax),%eax
17e8: 0f be c0 movsbl %al,%eax
17eb: 25 ff 00 00 00 and $0xff,%eax
17f0: 89 85 3c ff ff ff mov %eax,-0xc4(%rbp)
if (c == 0)
17f6: 83 bd 3c ff ff ff 00 cmpl $0x0,-0xc4(%rbp)
17fd: 0f 84 0f 03 00 00 je 1b12 <printf+0x40c>
break;
switch(c) {
1803: 83 bd 3c ff ff ff 25 cmpl $0x25,-0xc4(%rbp)
180a: 0f 84 74 02 00 00 je 1a84 <printf+0x37e>
1810: 83 bd 3c ff ff ff 25 cmpl $0x25,-0xc4(%rbp)
1817: 0f 8c 82 02 00 00 jl 1a9f <printf+0x399>
181d: 83 bd 3c ff ff ff 78 cmpl $0x78,-0xc4(%rbp)
1824: 0f 8f 75 02 00 00 jg 1a9f <printf+0x399>
182a: 83 bd 3c ff ff ff 63 cmpl $0x63,-0xc4(%rbp)
1831: 0f 8c 68 02 00 00 jl 1a9f <printf+0x399>
1837: 8b 85 3c ff ff ff mov -0xc4(%rbp),%eax
183d: 83 e8 63 sub $0x63,%eax
1840: 83 f8 15 cmp $0x15,%eax
1843: 0f 87 56 02 00 00 ja 1a9f <printf+0x399>
1849: 89 c0 mov %eax,%eax
184b: 48 8d 14 c5 00 00 00 lea 0x0(,%rax,8),%rdx
1852: 00
1853: 48 b8 60 1e 00 00 00 movabs $0x1e60,%rax
185a: 00 00 00
185d: 48 01 d0 add %rdx,%rax
1860: 48 8b 00 mov (%rax),%rax
1863: 3e ff e0 notrack jmpq *%rax
case 'c':
putc(fd, va_arg(ap, int));
1866: 8b 85 20 ff ff ff mov -0xe0(%rbp),%eax
186c: 83 f8 2f cmp $0x2f,%eax
186f: 77 23 ja 1894 <printf+0x18e>
1871: 48 8b 85 30 ff ff ff mov -0xd0(%rbp),%rax
1878: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
187e: 89 d2 mov %edx,%edx
1880: 48 01 d0 add %rdx,%rax
1883: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
1889: 83 c2 08 add $0x8,%edx
188c: 89 95 20 ff ff ff mov %edx,-0xe0(%rbp)
1892: eb 12 jmp 18a6 <printf+0x1a0>
1894: 48 8b 85 28 ff ff ff mov -0xd8(%rbp),%rax
189b: 48 8d 50 08 lea 0x8(%rax),%rdx
189f: 48 89 95 28 ff ff ff mov %rdx,-0xd8(%rbp)
18a6: 8b 00 mov (%rax),%eax
18a8: 0f be d0 movsbl %al,%edx
18ab: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
18b1: 89 d6 mov %edx,%esi
18b3: 89 c7 mov %eax,%edi
18b5: 48 b8 20 15 00 00 00 movabs $0x1520,%rax
18bc: 00 00 00
18bf: ff d0 callq *%rax
break;
18c1: e9 12 02 00 00 jmpq 1ad8 <printf+0x3d2>
case 'd':
print_d(fd, va_arg(ap, int));
18c6: 8b 85 20 ff ff ff mov -0xe0(%rbp),%eax
18cc: 83 f8 2f cmp $0x2f,%eax
18cf: 77 23 ja 18f4 <printf+0x1ee>
18d1: 48 8b 85 30 ff ff ff mov -0xd0(%rbp),%rax
18d8: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
18de: 89 d2 mov %edx,%edx
18e0: 48 01 d0 add %rdx,%rax
18e3: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
18e9: 83 c2 08 add $0x8,%edx
18ec: 89 95 20 ff ff ff mov %edx,-0xe0(%rbp)
18f2: eb 12 jmp 1906 <printf+0x200>
18f4: 48 8b 85 28 ff ff ff mov -0xd8(%rbp),%rax
18fb: 48 8d 50 08 lea 0x8(%rax),%rdx
18ff: 48 89 95 28 ff ff ff mov %rdx,-0xd8(%rbp)
1906: 8b 10 mov (%rax),%edx
1908: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
190e: 89 d6 mov %edx,%esi
1910: 89 c7 mov %eax,%edi
1912: 48 b8 0e 16 00 00 00 movabs $0x160e,%rax
1919: 00 00 00
191c: ff d0 callq *%rax
break;
191e: e9 b5 01 00 00 jmpq 1ad8 <printf+0x3d2>
case 'x':
print_x32(fd, va_arg(ap, uint));
1923: 8b 85 20 ff ff ff mov -0xe0(%rbp),%eax
1929: 83 f8 2f cmp $0x2f,%eax
192c: 77 23 ja 1951 <printf+0x24b>
192e: 48 8b 85 30 ff ff ff mov -0xd0(%rbp),%rax
1935: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
193b: 89 d2 mov %edx,%edx
193d: 48 01 d0 add %rdx,%rax
1940: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
1946: 83 c2 08 add $0x8,%edx
1949: 89 95 20 ff ff ff mov %edx,-0xe0(%rbp)
194f: eb 12 jmp 1963 <printf+0x25d>
1951: 48 8b 85 28 ff ff ff mov -0xd8(%rbp),%rax
1958: 48 8d 50 08 lea 0x8(%rax),%rdx
195c: 48 89 95 28 ff ff ff mov %rdx,-0xd8(%rbp)
1963: 8b 10 mov (%rax),%edx
1965: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
196b: 89 d6 mov %edx,%esi
196d: 89 c7 mov %eax,%edi
196f: 48 b8 b1 15 00 00 00 movabs $0x15b1,%rax
1976: 00 00 00
1979: ff d0 callq *%rax
break;
197b: e9 58 01 00 00 jmpq 1ad8 <printf+0x3d2>
case 'p':
print_x64(fd, va_arg(ap, addr_t));
1980: 8b 85 20 ff ff ff mov -0xe0(%rbp),%eax
1986: 83 f8 2f cmp $0x2f,%eax
1989: 77 23 ja 19ae <printf+0x2a8>
198b: 48 8b 85 30 ff ff ff mov -0xd0(%rbp),%rax
1992: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
1998: 89 d2 mov %edx,%edx
199a: 48 01 d0 add %rdx,%rax
199d: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
19a3: 83 c2 08 add $0x8,%edx
19a6: 89 95 20 ff ff ff mov %edx,-0xe0(%rbp)
19ac: eb 12 jmp 19c0 <printf+0x2ba>
19ae: 48 8b 85 28 ff ff ff mov -0xd8(%rbp),%rax
19b5: 48 8d 50 08 lea 0x8(%rax),%rdx
19b9: 48 89 95 28 ff ff ff mov %rdx,-0xd8(%rbp)
19c0: 48 8b 10 mov (%rax),%rdx
19c3: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
19c9: 48 89 d6 mov %rdx,%rsi
19cc: 89 c7 mov %eax,%edi
19ce: 48 b8 54 15 00 00 00 movabs $0x1554,%rax
19d5: 00 00 00
19d8: ff d0 callq *%rax
break;
19da: e9 f9 00 00 00 jmpq 1ad8 <printf+0x3d2>
case 's':
if ((s = va_arg(ap, char*)) == 0)
19df: 8b 85 20 ff ff ff mov -0xe0(%rbp),%eax
19e5: 83 f8 2f cmp $0x2f,%eax
19e8: 77 23 ja 1a0d <printf+0x307>
19ea: 48 8b 85 30 ff ff ff mov -0xd0(%rbp),%rax
19f1: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
19f7: 89 d2 mov %edx,%edx
19f9: 48 01 d0 add %rdx,%rax
19fc: 8b 95 20 ff ff ff mov -0xe0(%rbp),%edx
1a02: 83 c2 08 add $0x8,%edx
1a05: 89 95 20 ff ff ff mov %edx,-0xe0(%rbp)
1a0b: eb 12 jmp 1a1f <printf+0x319>
1a0d: 48 8b 85 28 ff ff ff mov -0xd8(%rbp),%rax
1a14: 48 8d 50 08 lea 0x8(%rax),%rdx
1a18: 48 89 95 28 ff ff ff mov %rdx,-0xd8(%rbp)
1a1f: 48 8b 00 mov (%rax),%rax
1a22: 48 89 85 40 ff ff ff mov %rax,-0xc0(%rbp)
1a29: 48 83 bd 40 ff ff ff cmpq $0x0,-0xc0(%rbp)
1a30: 00
1a31: 75 41 jne 1a74 <printf+0x36e>
s = "(null)";
1a33: 48 b8 58 1e 00 00 00 movabs $0x1e58,%rax
1a3a: 00 00 00
1a3d: 48 89 85 40 ff ff ff mov %rax,-0xc0(%rbp)
while (*s)
1a44: eb 2e jmp 1a74 <printf+0x36e>
putc(fd, *(s++));
1a46: 48 8b 85 40 ff ff ff mov -0xc0(%rbp),%rax
1a4d: 48 8d 50 01 lea 0x1(%rax),%rdx
1a51: 48 89 95 40 ff ff ff mov %rdx,-0xc0(%rbp)
1a58: 0f b6 00 movzbl (%rax),%eax
1a5b: 0f be d0 movsbl %al,%edx
1a5e: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
1a64: 89 d6 mov %edx,%esi
1a66: 89 c7 mov %eax,%edi
1a68: 48 b8 20 15 00 00 00 movabs $0x1520,%rax
1a6f: 00 00 00
1a72: ff d0 callq *%rax
while (*s)
1a74: 48 8b 85 40 ff ff ff mov -0xc0(%rbp),%rax
1a7b: 0f b6 00 movzbl (%rax),%eax
1a7e: 84 c0 test %al,%al
1a80: 75 c4 jne 1a46 <printf+0x340>
break;
1a82: eb 54 jmp 1ad8 <printf+0x3d2>
case '%':
putc(fd, '%');
1a84: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
1a8a: be 25 00 00 00 mov $0x25,%esi
1a8f: 89 c7 mov %eax,%edi
1a91: 48 b8 20 15 00 00 00 movabs $0x1520,%rax
1a98: 00 00 00
1a9b: ff d0 callq *%rax
break;
1a9d: eb 39 jmp 1ad8 <printf+0x3d2>
default:
// Print unknown % sequence to draw attention.
putc(fd, '%');
1a9f: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
1aa5: be 25 00 00 00 mov $0x25,%esi
1aaa: 89 c7 mov %eax,%edi
1aac: 48 b8 20 15 00 00 00 movabs $0x1520,%rax
1ab3: 00 00 00
1ab6: ff d0 callq *%rax
putc(fd, c);
1ab8: 8b 85 3c ff ff ff mov -0xc4(%rbp),%eax
1abe: 0f be d0 movsbl %al,%edx
1ac1: 8b 85 1c ff ff ff mov -0xe4(%rbp),%eax
1ac7: 89 d6 mov %edx,%esi
1ac9: 89 c7 mov %eax,%edi
1acb: 48 b8 20 15 00 00 00 movabs $0x1520,%rax
1ad2: 00 00 00
1ad5: ff d0 callq *%rax
break;
1ad7: 90 nop
for (i = 0; (c = fmt[i] & 0xff) != 0; i++) {
1ad8: 83 85 4c ff ff ff 01 addl $0x1,-0xb4(%rbp)
1adf: 8b 85 4c ff ff ff mov -0xb4(%rbp),%eax
1ae5: 48 63 d0 movslq %eax,%rdx
1ae8: 48 8b 85 10 ff ff ff mov -0xf0(%rbp),%rax
1aef: 48 01 d0 add %rdx,%rax
1af2: 0f b6 00 movzbl (%rax),%eax
1af5: 0f be c0 movsbl %al,%eax
1af8: 25 ff 00 00 00 and $0xff,%eax
1afd: 89 85 3c ff ff ff mov %eax,-0xc4(%rbp)
1b03: 83 bd 3c ff ff ff 00 cmpl $0x0,-0xc4(%rbp)
1b0a: 0f 85 8e fc ff ff jne 179e <printf+0x98>
}
}
}
1b10: eb 01 jmp 1b13 <printf+0x40d>
break;
1b12: 90 nop
}
1b13: 90 nop
1b14: c9 leaveq
1b15: c3 retq
0000000000001b16 <free>:
static Header base;
static Header *freep;
void
free(void *ap)
{
1b16: f3 0f 1e fa endbr64
1b1a: 55 push %rbp
1b1b: 48 89 e5 mov %rsp,%rbp
1b1e: 48 83 ec 18 sub $0x18,%rsp
1b22: 48 89 7d e8 mov %rdi,-0x18(%rbp)
Header *bp, *p;
bp = (Header*)ap - 1;
1b26: 48 8b 45 e8 mov -0x18(%rbp),%rax
1b2a: 48 83 e8 10 sub $0x10,%rax
1b2e: 48 89 45 f0 mov %rax,-0x10(%rbp)
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1b32: 48 b8 c0 21 00 00 00 movabs $0x21c0,%rax
1b39: 00 00 00
1b3c: 48 8b 00 mov (%rax),%rax
1b3f: 48 89 45 f8 mov %rax,-0x8(%rbp)
1b43: eb 2f jmp 1b74 <free+0x5e>
if(p >= p->s.ptr && (bp > p || bp < p->s.ptr))
1b45: 48 8b 45 f8 mov -0x8(%rbp),%rax
1b49: 48 8b 00 mov (%rax),%rax
1b4c: 48 39 45 f8 cmp %rax,-0x8(%rbp)
1b50: 72 17 jb 1b69 <free+0x53>
1b52: 48 8b 45 f0 mov -0x10(%rbp),%rax
1b56: 48 3b 45 f8 cmp -0x8(%rbp),%rax
1b5a: 77 2f ja 1b8b <free+0x75>
1b5c: 48 8b 45 f8 mov -0x8(%rbp),%rax
1b60: 48 8b 00 mov (%rax),%rax
1b63: 48 39 45 f0 cmp %rax,-0x10(%rbp)
1b67: 72 22 jb 1b8b <free+0x75>
for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr)
1b69: 48 8b 45 f8 mov -0x8(%rbp),%rax
1b6d: 48 8b 00 mov (%rax),%rax
1b70: 48 89 45 f8 mov %rax,-0x8(%rbp)
1b74: 48 8b 45 f0 mov -0x10(%rbp),%rax
1b78: 48 3b 45 f8 cmp -0x8(%rbp),%rax
1b7c: 76 c7 jbe 1b45 <free+0x2f>
1b7e: 48 8b 45 f8 mov -0x8(%rbp),%rax
1b82: 48 8b 00 mov (%rax),%rax
1b85: 48 39 45 f0 cmp %rax,-0x10(%rbp)
1b89: 73 ba jae 1b45 <free+0x2f>
break;
if(bp + bp->s.size == p->s.ptr){
1b8b: 48 8b 45 f0 mov -0x10(%rbp),%rax
1b8f: 8b 40 08 mov 0x8(%rax),%eax
1b92: 89 c0 mov %eax,%eax
1b94: 48 c1 e0 04 shl $0x4,%rax
1b98: 48 89 c2 mov %rax,%rdx
1b9b: 48 8b 45 f0 mov -0x10(%rbp),%rax
1b9f: 48 01 c2 add %rax,%rdx
1ba2: 48 8b 45 f8 mov -0x8(%rbp),%rax
1ba6: 48 8b 00 mov (%rax),%rax
1ba9: 48 39 c2 cmp %rax,%rdx
1bac: 75 2d jne 1bdb <free+0xc5>
bp->s.size += p->s.ptr->s.size;
1bae: 48 8b 45 f0 mov -0x10(%rbp),%rax
1bb2: 8b 50 08 mov 0x8(%rax),%edx
1bb5: 48 8b 45 f8 mov -0x8(%rbp),%rax
1bb9: 48 8b 00 mov (%rax),%rax
1bbc: 8b 40 08 mov 0x8(%rax),%eax
1bbf: 01 c2 add %eax,%edx
1bc1: 48 8b 45 f0 mov -0x10(%rbp),%rax
1bc5: 89 50 08 mov %edx,0x8(%rax)
bp->s.ptr = p->s.ptr->s.ptr;
1bc8: 48 8b 45 f8 mov -0x8(%rbp),%rax
1bcc: 48 8b 00 mov (%rax),%rax
1bcf: 48 8b 10 mov (%rax),%rdx
1bd2: 48 8b 45 f0 mov -0x10(%rbp),%rax
1bd6: 48 89 10 mov %rdx,(%rax)
1bd9: eb 0e jmp 1be9 <free+0xd3>
} else
bp->s.ptr = p->s.ptr;
1bdb: 48 8b 45 f8 mov -0x8(%rbp),%rax
1bdf: 48 8b 10 mov (%rax),%rdx
1be2: 48 8b 45 f0 mov -0x10(%rbp),%rax
1be6: 48 89 10 mov %rdx,(%rax)
if(p + p->s.size == bp){
1be9: 48 8b 45 f8 mov -0x8(%rbp),%rax
1bed: 8b 40 08 mov 0x8(%rax),%eax
1bf0: 89 c0 mov %eax,%eax
1bf2: 48 c1 e0 04 shl $0x4,%rax
1bf6: 48 89 c2 mov %rax,%rdx
1bf9: 48 8b 45 f8 mov -0x8(%rbp),%rax
1bfd: 48 01 d0 add %rdx,%rax
1c00: 48 39 45 f0 cmp %rax,-0x10(%rbp)
1c04: 75 27 jne 1c2d <free+0x117>
p->s.size += bp->s.size;
1c06: 48 8b 45 f8 mov -0x8(%rbp),%rax
1c0a: 8b 50 08 mov 0x8(%rax),%edx
1c0d: 48 8b 45 f0 mov -0x10(%rbp),%rax
1c11: 8b 40 08 mov 0x8(%rax),%eax
1c14: 01 c2 add %eax,%edx
1c16: 48 8b 45 f8 mov -0x8(%rbp),%rax
1c1a: 89 50 08 mov %edx,0x8(%rax)
p->s.ptr = bp->s.ptr;
1c1d: 48 8b 45 f0 mov -0x10(%rbp),%rax
1c21: 48 8b 10 mov (%rax),%rdx
1c24: 48 8b 45 f8 mov -0x8(%rbp),%rax
1c28: 48 89 10 mov %rdx,(%rax)
1c2b: eb 0b jmp 1c38 <free+0x122>
} else
p->s.ptr = bp;
1c2d: 48 8b 45 f8 mov -0x8(%rbp),%rax
1c31: 48 8b 55 f0 mov -0x10(%rbp),%rdx
1c35: 48 89 10 mov %rdx,(%rax)
freep = p;
1c38: 48 ba c0 21 00 00 00 movabs $0x21c0,%rdx
1c3f: 00 00 00
1c42: 48 8b 45 f8 mov -0x8(%rbp),%rax
1c46: 48 89 02 mov %rax,(%rdx)
}
1c49: 90 nop
1c4a: c9 leaveq
1c4b: c3 retq
0000000000001c4c <morecore>:
static Header*
morecore(uint nu)
{
1c4c: f3 0f 1e fa endbr64
1c50: 55 push %rbp
1c51: 48 89 e5 mov %rsp,%rbp
1c54: 48 83 ec 20 sub $0x20,%rsp
1c58: 89 7d ec mov %edi,-0x14(%rbp)
char *p;
Header *hp;
if(nu < 4096)
1c5b: 81 7d ec ff 0f 00 00 cmpl $0xfff,-0x14(%rbp)
1c62: 77 07 ja 1c6b <morecore+0x1f>
nu = 4096;
1c64: c7 45 ec 00 10 00 00 movl $0x1000,-0x14(%rbp)
p = sbrk(nu * sizeof(Header));
1c6b: 8b 45 ec mov -0x14(%rbp),%eax
1c6e: 48 c1 e0 04 shl $0x4,%rax
1c72: 48 89 c7 mov %rax,%rdi
1c75: 48 b8 ec 14 00 00 00 movabs $0x14ec,%rax
1c7c: 00 00 00
1c7f: ff d0 callq *%rax
1c81: 48 89 45 f8 mov %rax,-0x8(%rbp)
if(p == (char*)-1)
1c85: 48 83 7d f8 ff cmpq $0xffffffffffffffff,-0x8(%rbp)
1c8a: 75 07 jne 1c93 <morecore+0x47>
return 0;
1c8c: b8 00 00 00 00 mov $0x0,%eax
1c91: eb 36 jmp 1cc9 <morecore+0x7d>
hp = (Header*)p;
1c93: 48 8b 45 f8 mov -0x8(%rbp),%rax
1c97: 48 89 45 f0 mov %rax,-0x10(%rbp)
hp->s.size = nu;
1c9b: 48 8b 45 f0 mov -0x10(%rbp),%rax
1c9f: 8b 55 ec mov -0x14(%rbp),%edx
1ca2: 89 50 08 mov %edx,0x8(%rax)
free((void*)(hp + 1));
1ca5: 48 8b 45 f0 mov -0x10(%rbp),%rax
1ca9: 48 83 c0 10 add $0x10,%rax
1cad: 48 89 c7 mov %rax,%rdi
1cb0: 48 b8 16 1b 00 00 00 movabs $0x1b16,%rax
1cb7: 00 00 00
1cba: ff d0 callq *%rax
return freep;
1cbc: 48 b8 c0 21 00 00 00 movabs $0x21c0,%rax
1cc3: 00 00 00
1cc6: 48 8b 00 mov (%rax),%rax
}
1cc9: c9 leaveq
1cca: c3 retq
0000000000001ccb <malloc>:
void*
malloc(uint nbytes)
{
1ccb: f3 0f 1e fa endbr64
1ccf: 55 push %rbp
1cd0: 48 89 e5 mov %rsp,%rbp
1cd3: 48 83 ec 30 sub $0x30,%rsp
1cd7: 89 7d dc mov %edi,-0x24(%rbp)
Header *p, *prevp;
uint nunits;
nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1;
1cda: 8b 45 dc mov -0x24(%rbp),%eax
1cdd: 48 83 c0 0f add $0xf,%rax
1ce1: 48 c1 e8 04 shr $0x4,%rax
1ce5: 83 c0 01 add $0x1,%eax
1ce8: 89 45 ec mov %eax,-0x14(%rbp)
if((prevp = freep) == 0){
1ceb: 48 b8 c0 21 00 00 00 movabs $0x21c0,%rax
1cf2: 00 00 00
1cf5: 48 8b 00 mov (%rax),%rax
1cf8: 48 89 45 f0 mov %rax,-0x10(%rbp)
1cfc: 48 83 7d f0 00 cmpq $0x0,-0x10(%rbp)
1d01: 75 4a jne 1d4d <malloc+0x82>
base.s.ptr = freep = prevp = &base;
1d03: 48 b8 b0 21 00 00 00 movabs $0x21b0,%rax
1d0a: 00 00 00
1d0d: 48 89 45 f0 mov %rax,-0x10(%rbp)
1d11: 48 ba c0 21 00 00 00 movabs $0x21c0,%rdx
1d18: 00 00 00
1d1b: 48 8b 45 f0 mov -0x10(%rbp),%rax
1d1f: 48 89 02 mov %rax,(%rdx)
1d22: 48 b8 c0 21 00 00 00 movabs $0x21c0,%rax
1d29: 00 00 00
1d2c: 48 8b 00 mov (%rax),%rax
1d2f: 48 ba b0 21 00 00 00 movabs $0x21b0,%rdx
1d36: 00 00 00
1d39: 48 89 02 mov %rax,(%rdx)
base.s.size = 0;
1d3c: 48 b8 b0 21 00 00 00 movabs $0x21b0,%rax
1d43: 00 00 00
1d46: c7 40 08 00 00 00 00 movl $0x0,0x8(%rax)
}
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1d4d: 48 8b 45 f0 mov -0x10(%rbp),%rax
1d51: 48 8b 00 mov (%rax),%rax
1d54: 48 89 45 f8 mov %rax,-0x8(%rbp)
if(p->s.size >= nunits){
1d58: 48 8b 45 f8 mov -0x8(%rbp),%rax
1d5c: 8b 40 08 mov 0x8(%rax),%eax
1d5f: 39 45 ec cmp %eax,-0x14(%rbp)
1d62: 77 65 ja 1dc9 <malloc+0xfe>
if(p->s.size == nunits)
1d64: 48 8b 45 f8 mov -0x8(%rbp),%rax
1d68: 8b 40 08 mov 0x8(%rax),%eax
1d6b: 39 45 ec cmp %eax,-0x14(%rbp)
1d6e: 75 10 jne 1d80 <malloc+0xb5>
prevp->s.ptr = p->s.ptr;
1d70: 48 8b 45 f8 mov -0x8(%rbp),%rax
1d74: 48 8b 10 mov (%rax),%rdx
1d77: 48 8b 45 f0 mov -0x10(%rbp),%rax
1d7b: 48 89 10 mov %rdx,(%rax)
1d7e: eb 2e jmp 1dae <malloc+0xe3>
else {
p->s.size -= nunits;
1d80: 48 8b 45 f8 mov -0x8(%rbp),%rax
1d84: 8b 40 08 mov 0x8(%rax),%eax
1d87: 2b 45 ec sub -0x14(%rbp),%eax
1d8a: 89 c2 mov %eax,%edx
1d8c: 48 8b 45 f8 mov -0x8(%rbp),%rax
1d90: 89 50 08 mov %edx,0x8(%rax)
p += p->s.size;
1d93: 48 8b 45 f8 mov -0x8(%rbp),%rax
1d97: 8b 40 08 mov 0x8(%rax),%eax
1d9a: 89 c0 mov %eax,%eax
1d9c: 48 c1 e0 04 shl $0x4,%rax
1da0: 48 01 45 f8 add %rax,-0x8(%rbp)
p->s.size = nunits;
1da4: 48 8b 45 f8 mov -0x8(%rbp),%rax
1da8: 8b 55 ec mov -0x14(%rbp),%edx
1dab: 89 50 08 mov %edx,0x8(%rax)
}
freep = prevp;
1dae: 48 ba c0 21 00 00 00 movabs $0x21c0,%rdx
1db5: 00 00 00
1db8: 48 8b 45 f0 mov -0x10(%rbp),%rax
1dbc: 48 89 02 mov %rax,(%rdx)
return (void*)(p + 1);
1dbf: 48 8b 45 f8 mov -0x8(%rbp),%rax
1dc3: 48 83 c0 10 add $0x10,%rax
1dc7: eb 4e jmp 1e17 <malloc+0x14c>
}
if(p == freep)
1dc9: 48 b8 c0 21 00 00 00 movabs $0x21c0,%rax
1dd0: 00 00 00
1dd3: 48 8b 00 mov (%rax),%rax
1dd6: 48 39 45 f8 cmp %rax,-0x8(%rbp)
1dda: 75 23 jne 1dff <malloc+0x134>
if((p = morecore(nunits)) == 0)
1ddc: 8b 45 ec mov -0x14(%rbp),%eax
1ddf: 89 c7 mov %eax,%edi
1de1: 48 b8 4c 1c 00 00 00 movabs $0x1c4c,%rax
1de8: 00 00 00
1deb: ff d0 callq *%rax
1ded: 48 89 45 f8 mov %rax,-0x8(%rbp)
1df1: 48 83 7d f8 00 cmpq $0x0,-0x8(%rbp)
1df6: 75 07 jne 1dff <malloc+0x134>
return 0;
1df8: b8 00 00 00 00 mov $0x0,%eax
1dfd: eb 18 jmp 1e17 <malloc+0x14c>
for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){
1dff: 48 8b 45 f8 mov -0x8(%rbp),%rax
1e03: 48 89 45 f0 mov %rax,-0x10(%rbp)
1e07: 48 8b 45 f8 mov -0x8(%rbp),%rax
1e0b: 48 8b 00 mov (%rax),%rax
1e0e: 48 89 45 f8 mov %rax,-0x8(%rbp)
if(p->s.size >= nunits){
1e12: e9 41 ff ff ff jmpq 1d58 <malloc+0x8d>
}
}
1e17: c9 leaveq
1e18: c3 retq
|
// Copyright 2016 Etix Labs
//
// 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 <tasks/mapping.h>
namespace etix {
namespace cameradar {
// The first command checks if dpkg finds nmap in the system by cutting the
// result and grepping
// nmap from it.
//
// The second command checks the version of nmap, right now it needs to be the
// 6.47 but this could
// be changed to 6 or greater depending on the needs. In a docker container
// this should not be a
// problem.
bool
nmap_is_ok() {
return (
(system("dpkg -l | cut -c 5-9 | grep nmap") == 0)
&& launch_command("mkdir -p /tmp/scans")); // Creates the directory in which the scans will be stored
}
// Launches and checks the return of the nmap command
// Uses the target specified in the conf file to launch nmap
bool
mapping::run() const {
if (nmap_is_ok()) {
std::string target = this->conf.target;
std::replace(target.begin(), target.end(), ',', ' ');
LOG_INFO_("Nmap 6.0 or greater found", "mapping");
LOG_INFO_("Beginning mapping task. This may take a while.", "mapping");
std::string cmd =
"nmap -T4 -A " + target + " -p " + this->conf.ports + " -oX " + nmap_output;
LOG_DEBUG_("Launching nmap : " + cmd, "mapping");
bool ret = launch_command(cmd);
if (ret)
LOG_INFO_("Nmap XML output successfully generated in file: " + nmap_output, "mapping");
else
LOG_ERR_("Nmap command failed", "mapping");
return ret;
} else {
LOG_ERR_("Nmap 6.0 or greater is required to launch Cameradar", "mapping");
return false;
}
}
}
}
|
// Copyright (c) 2009-2016 Vladimir Batov.
// Use, modification and distribution are subject to the Boost Software License,
// Version 1.0. See http://www.boost.org/LICENSE_1_0.txt.
#ifndef BOOST_CONVERT_DETAIL_IS_CHAR_HPP
#define BOOST_CONVERT_DETAIL_IS_CHAR_HPP
#include <boost/convert/detail/config.hpp>
#include <type_traits>
#include <cctype>
#include <cwctype>
namespace boost { namespace cnv
{
using char_type = char;
using uchar_type = unsigned char;
using wchar_type = wchar_t;
namespace detail
{
template<typename> struct is_char : std::false_type {};
template<> struct is_char< char_type> : std:: true_type {};
template<> struct is_char<wchar_type> : std:: true_type {};
}
template <typename T> struct is_char : detail::is_char<typename boost::remove_const<T>::type> {};
template<typename char_type> bool is_space(char_type);
template<typename char_type> char_type to_upper(char_type);
template<> bool is_space ( char_type c) { return bool(std::isspace(static_cast<uchar_type>(c))); }
template<> bool is_space (uchar_type c) { return bool(std::isspace(c)); }
template<> bool is_space (wchar_type c) { return bool(std::iswspace(c)); }
template<> char_type to_upper ( char_type c) { return std::toupper(static_cast<uchar_type>(c)); }
template<> uchar_type to_upper (uchar_type c) { return std::toupper(c); }
template<> wchar_type to_upper (wchar_type c) { return std::towupper(c); }
}}
#endif // BOOST_CONVERT_DETAIL_IS_CHAR_HPP
|
// ../MemoryAccess/PointerTest/PointerTest.vm
@3030
D=A
@SP
A=M
M=D
@SP
AM=M+1
@0
D=A
@R3
AD=D+A
@R13
M=D
@SP
AM=M-1
D=M
@R13
A=M
M=D
@3040
D=A
@SP
A=M
M=D
@SP
AM=M+1
@1
D=A
@R3
AD=D+A
@R13
M=D
@SP
AM=M-1
D=M
@R13
A=M
M=D
@32
D=A
@SP
A=M
M=D
@SP
AM=M+1
@2
D=A
@THIS
AD=D+M
@R13
M=D
@SP
AM=M-1
D=M
@R13
A=M
M=D
@46
D=A
@SP
A=M
M=D
@SP
AM=M+1
@6
D=A
@THAT
AD=D+M
@R13
M=D
@SP
AM=M-1
D=M
@R13
A=M
M=D
@0
D=A
@R3
AD=D+A
D=M
@SP
A=M
M=D
@SP
AM=M+1
@1
D=A
@R3
AD=D+A
D=M
@SP
A=M
M=D
@SP
AM=M+1
@SP
AM=M-1
D=M
@SP
AM=M-1
M=D+M
@SP
AM=M+1
@2
D=A
@THIS
AD=D+M
D=M
@SP
A=M
M=D
@SP
AM=M+1
@SP
AM=M-1
D=M
@SP
AM=M-1
M=M-D
@SP
AM=M+1
@6
D=A
@THAT
AD=D+M
D=M
@SP
A=M
M=D
@SP
AM=M+1
@SP
AM=M-1
D=M
@SP
AM=M-1
M=D+M
@SP
AM=M+1
(END)
@END
0;JMP
|
extern scanf, printf
global main
section .data
msg db "%d", 0AH, 0H
section .text
main:
mov ecx, 1000; Inicio
repetir:
xor edx, edx; Dividendo
mov eax, ecx; Dividendo
mov ebx, 11; Divisor
div ebx
cmp edx, 5
je imprimir
avalicao:
inc ecx
cmp ecx, 2000
jl repetir
fim:
mov eax, 1
xor ecx, ecx
int 80h
imprimir:
push ecx
push ecx
push msg
call printf
add esp, 8
pop ecx
jmp avalicao
|
.global s_prepare_buffers
s_prepare_buffers:
push %r12
push %r13
push %r15
push %r8
push %rbp
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x19ca5, %rdi
nop
inc %r13
mov (%rdi), %r8w
nop
nop
nop
add %rbp, %rbp
lea addresses_UC_ht+0xe025, %r15
sub $38203, %r8
mov $0x6162636465666768, %r12
movq %r12, (%r15)
nop
xor $22331, %r13
lea addresses_UC_ht+0xa08b, %rsi
lea addresses_WC_ht+0x8325, %rdi
nop
nop
nop
inc %rbp
mov $20, %rcx
rep movsl
nop
nop
nop
nop
nop
sub $44850, %rcx
lea addresses_WT_ht+0x1af65, %r13
clflush (%r13)
nop
nop
nop
nop
nop
sub $53901, %rbp
movw $0x6162, (%r13)
nop
nop
nop
and $60383, %rbp
lea addresses_WC_ht+0x1e7e5, %rsi
lea addresses_WC_ht+0xc725, %rdi
nop
nop
nop
xor $63063, %r15
mov $23, %rcx
rep movsw
cmp $37641, %rbp
lea addresses_WC_ht+0x1aa2e, %rsi
lea addresses_WC_ht+0x12565, %rdi
nop
add $25742, %r15
mov $106, %rcx
rep movsw
inc %r15
pop %rsi
pop %rdi
pop %rcx
pop %rbp
pop %r8
pop %r15
pop %r13
pop %r12
ret
.global s_faulty_load
s_faulty_load:
push %r11
push %r9
push %rbx
push %rdi
push %rdx
// Faulty Load
mov $0x1405c40000000725, %r9
clflush (%r9)
nop
nop
nop
nop
nop
add %rbx, %rbx
movb (%r9), %r11b
lea oracles, %rdi
and $0xff, %r11
shlq $12, %r11
mov (%rdi,%r11,1), %r11
pop %rdx
pop %rdi
pop %rbx
pop %r9
pop %r11
ret
/*
<gen_faulty_load>
[REF]
{'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_NC'}, 'OP': 'LOAD'}
[Faulty Load]
{'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 1, 'NT': False, 'type': 'addresses_NC'}, 'OP': 'LOAD'}
<gen_prepare_buffer>
{'src': {'congruent': 7, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_normal_ht'}, 'OP': 'LOAD'}
{'OP': 'STOR', 'dst': {'congruent': 8, 'AVXalign': True, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_UC_ht'}}
{'src': {'congruent': 0, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_WC_ht'}}
{'OP': 'STOR', 'dst': {'congruent': 4, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_WT_ht'}}
{'src': {'congruent': 4, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 10, 'same': True, 'type': 'addresses_WC_ht'}}
{'src': {'congruent': 0, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_WC_ht'}}
{'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
*/
|
; A162274: a(n) = ((2+sqrt(3))*(4+sqrt(3))^n + (2-sqrt(3))*(4-sqrt(3))^n)/2.
; Submitted by Jamie Morken(s4)
; 2,11,62,353,2018,11555,66206,379433,2174786,12465659,71453054,409570865,2347677218,13456996499,77136168158,442148390777,2534416940162,14527406441195,83271831307454,477318366724097
mov $3,1
lpb $0
sub $0,$3
add $2,1
add $4,1
mov $1,$4
mul $1,6
sub $4,$2
add $2,1
add $2,$1
add $4,$1
lpe
mov $0,$4
div $0,2
mul $0,3
add $0,2
|
; A028365: Order of general affine group over GF(2), AGL(n,2).
; Submitted by Jamie Morken(s1.)
; 1,2,24,1344,322560,319979520,1290157424640,20972799094947840,1369104324918194995200,358201502736997192984166400,375234700595146883504949480652800,1573079924978208093254925489963584716800,26385458351250481733136055834218002085052416000,1770481986396919364617154013905548534404418268823552000,475231131781377719509366115693602433255794024417464359583744000,510259969886794669593834275239764653850381608487716607442306323185664000
mov $2,1
mov $4,1
lpb $0
sub $0,1
add $3,$2
mul $4,$3
mul $4,$2
mul $2,2
lpe
mul $4,$2
mov $0,$4
|
; A021189: Decimal expansion of 1/185.
; 0,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5,4,0,5
mov $2,6
lpb $0
sub $0,1
mod $0,3
mov $1,$3
sub $2,1
mov $3,$2
lpe
mov $0,$1
|
; code for an interrupt serviced data buffer. similar code is used to drive the XY
; stepper motors on a plotter with new position information every 5mS and also to
; allow pen up/down movement time of 70mS
*= $B000 ; set origin (buffer and variables must be in RAM)
Buffer ; 256 byte buffer (must start at page edge)
.word $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
.word $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
.word $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
.word $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
.word $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
.word $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
.word $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
.word $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
.word $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
.word $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
.word $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
.word $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
.word $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
.word $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
.word $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
.word $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
BRindx ; buffer read index
.byte $00
BWindx ; buffer write index
.byte $00
Sendf ; am sending flag
.byte $00
WByte ; temp store for the byte to be sent
.byte $00
; write the data to the buffer a byte at a time and increment the pointer.
; the routine is called with the byte to write in A. If the interrupt device
; is idle when this routine is called it will wake it up by doing a BRK
; before it exits
;
; destroys the Y register
*= $C000 ; set origin (can be ROM or RAM)
Incwritb
STA WByte ; save byte to write
LDA BRindx ; get read index
SEC ; set carry for subtract
SBC BWindx ; subtract write index
BEQ Dowrite ; if equal then buffer empty so do write
CMP #$02 ; need at least n+1 bytes to avoid rollover
BCC Incwritb ; loop if no space
; construct and write data to buffer
Dowrite
LDY BWindx ; get write index
LDA WByte ; get byte to write
STA Buffer,Y ; save it
INY ; increment index to next byte
STY BWindx ; save new write index byte
; now see if the interrupt service routine is already running or if it's idle
LDA Sendf ; get the sending flag
BNE Doingit ; skip call if running
BRK ; software call to interrupt routine
NOP ; need this as return from BRK is +1 byte!
CLI ; enable the interrupts
Doingit
RTS
; this is the interrupt service routine. takes a byte a time from the buffer
; and does some thing with it. also sets up the device(s) for the next interrupt
; no registers altered
BuffIRQ
PHA ; save A
TXA ; copy X
PHA ; save X
TYA ; copy Y
PHA ; save Y
; insert code here to ensure this is the interrupt you want. if it isn't then just exit
; quietly via ResExit the end of the routine
Getnext
JSR Increadb ; increment pointer and read byte from buffer
BCS ExitIRQ ; branch if no byte to do
; here would be the guts of the routine such as sending the byte to the ACIA or a
; printer port or some other byte device. it will also ensure the device is set to
; generate an interrupt when it's completed it's task
LDA #$FF ; set byte
STA Sendf ; set sending flag
JMP ResExit ; restore the registers & exit
; all done so clear the flag restore the regs & exit
ExitIRQ
LDA #$00 ; clear byte
STA Sendf ; clear sending flag
ResExit
PLA ; pull Y
TAY ; restore it
PLA ; pull X
TAX ; restore it
PLA ; restore A
RTI ; this was an interrupt service so exit properly
; get byte from the buffer and increment the pointer. If the buffer is empty then
; exit with the carry flag set else exit with carry clear and the byte in A
Increadb
LDY BRindx ; get buffer read index
CPY BWindx ; compare write index
BEQ NOktoread ; branch if empty (= sets carry)
LDA Buffer,Y ; get byte from buffer
INY ; increment pointer
STY BRindx ; save buffer read index
CLC ; clear not ok flag
NOktoread
RTS |
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's 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.
//
// * The name of the copyright holders may not 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 Intel Corporation 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.
//
//M*/
#include "test_precomp.hpp"
#include "opencv2/videoio/videoio_c.h"
#include "opencv2/highgui.hpp"
#include <cstdio>
using namespace cv;
using namespace std;
using namespace std::tr1;
class Videoio_Test_Base
{
protected:
string ext;
string video_file;
int apiPref;
protected:
Videoio_Test_Base() {}
virtual ~Videoio_Test_Base() {}
virtual void checkFrameContent(Mat &, int) {}
virtual void checkFrameCount(int &) {}
void checkFrameRead(int idx, VideoCapture & cap)
{
//int frameID = (int)cap.get(CAP_PROP_POS_FRAMES);
Mat img; cap >> img;
//std::cout << "idx=" << idx << " img=" << img.size() << " frameID=" << frameID << std::endl;
ASSERT_FALSE(img.empty()) << "idx=" << idx;
checkFrameContent(img, idx);
}
void checkFrameSeek(int idx, VideoCapture & cap)
{
bool canSeek = cap.set(CAP_PROP_POS_FRAMES, idx);
if (!canSeek)
{
std::cout << "Seek to frame '" << idx << "' is not supported. SKIP." << std::endl;
return;
}
EXPECT_EQ(idx, (int)cap.get(CAP_PROP_POS_FRAMES));
checkFrameRead(idx, cap);
}
public:
void doTest()
{
if (apiPref == CAP_AVFOUNDATION)
{
// TODO: fix this backend
std::cout << "SKIP test: AVFoundation backend returns invalid frame count" << std::endl;
return;
}
else if (apiPref == CAP_VFW)
{
// TODO: fix this backend
std::cout << "SKIP test: Video for Windows backend not open files" << std::endl;
return;
}
VideoCapture cap(video_file, apiPref);
if (!cap.isOpened())
{
std::cout << "SKIP test: backend " << apiPref << " can't open the video: " << video_file << std::endl;
return;
}
int n_frames = (int)cap.get(CAP_PROP_FRAME_COUNT);
if (n_frames > 0)
{
ASSERT_GT(n_frames, 0);
checkFrameCount(n_frames);
}
else
{
std::cout << "CAP_PROP_FRAME_COUNT is not supported by backend. Assume 50 frames." << std::endl;
n_frames = 50;
}
{
SCOPED_TRACE("consecutive read");
for (int k = 0; k < n_frames; ++k)
{
checkFrameRead(k, cap);
}
}
bool canSeek = cap.set(CAP_PROP_POS_FRAMES, 0);
if (!canSeek)
{
std::cout << "Seek to frame '0' is not supported. SKIP all 'seek' tests." << std::endl;
return;
}
if (ext != "wmv")
{
SCOPED_TRACE("progressive seek");
ASSERT_TRUE(cap.set(CAP_PROP_POS_FRAMES, 0));
for (int k = 0; k < n_frames; k += 20)
{
checkFrameSeek(k, cap);
}
}
if (ext != "mpg" && ext != "wmv")
{
SCOPED_TRACE("random seek");
ASSERT_TRUE(cap.set(CAP_PROP_POS_FRAMES, 0));
for (int k = 0; k < 10; ++k)
{
checkFrameSeek(cvtest::TS::ptr()->get_rng().uniform(0, n_frames), cap);
}
}
}
};
//==================================================================================================
typedef tuple<string, int> Backend_Type_Params;
class Videoio_Bunny : public Videoio_Test_Base, public testing::TestWithParam<Backend_Type_Params>
{
public:
Videoio_Bunny()
{
ext = get<0>(GetParam());
apiPref = get<1>(GetParam());
video_file = cvtest::TS::ptr()->get_data_path() + "video/big_buck_bunny." + ext;
}
void doFrameCountTest()
{
if (apiPref == CAP_AVFOUNDATION)
{
// TODO: fix this backend
std::cout << "SKIP test: AVFoundation backend returns invalid frame count" << std::endl;
return;
}
else if (apiPref == CAP_VFW)
{
// TODO: fix this backend
std::cout << "SKIP test: Video for Windows backend not open files" << std::endl;
return;
}
VideoCapture cap(video_file, apiPref);
if (!cap.isOpened())
{
std::cout << "SKIP test: backend " << apiPref << " can't open the video: " << video_file << std::endl;
return;
}
const int width_gt = 672;
const int height_gt = 384;
const int fps_gt = 24;
const double time_gt = 5.21;
const int count_gt = cvRound(fps_gt * time_gt); // 5.21 sec * 24 fps
EXPECT_EQ(width_gt, cap.get(CAP_PROP_FRAME_WIDTH));
EXPECT_EQ(height_gt, cap.get(CAP_PROP_FRAME_HEIGHT));
double fps_prop = cap.get(CAP_PROP_FPS);
if (fps_prop > 0)
EXPECT_NEAR(fps_prop, fps_gt, 1);
else
std::cout << "FPS is not available. SKIP check." << std::endl;
int count_prop = 0;
count_prop = (int)cap.get(CAP_PROP_FRAME_COUNT);
// mpg file reports 5.08 sec * 24 fps => property returns 122 frames
// but actual number of frames returned is 125
if (ext != "mpg")
{
if (count_prop > 0)
{
EXPECT_EQ(count_gt, count_prop);
}
}
int count_actual = 0;
while (cap.isOpened())
{
Mat frame;
cap >> frame;
if (frame.empty())
break;
EXPECT_EQ(width_gt, frame.cols);
EXPECT_EQ(height_gt, frame.rows);
count_actual += 1;
}
if (count_prop > 0)
{
EXPECT_NEAR(count_gt, count_actual, 1);
}
else
std::cout << "Frames counter is not available. Actual frames: " << count_actual << ". SKIP check." << std::endl;
}
};
typedef tuple<string, string, float, int> Ext_Fourcc_PSNR;
typedef tuple<Size, Ext_Fourcc_PSNR> Size_Ext_Fourcc_PSNR;
class Videoio_Synthetic : public Videoio_Test_Base, public testing::TestWithParam<Size_Ext_Fourcc_PSNR>
{
Size frame_size;
int fourcc;
float PSNR_GT;
int frame_count;
double fps;
public:
Videoio_Synthetic()
{
frame_size = get<0>(GetParam());
const Ext_Fourcc_PSNR ¶m = get<1>(GetParam());
ext = get<0>(param);
fourcc = fourccFromString(get<1>(param));
PSNR_GT = get<2>(param);
video_file = cv::tempfile((fourccToString(fourcc) + "." + ext).c_str());
frame_count = 100;
fps = 25.;
apiPref = get<3>(param);
}
void SetUp()
{
if (apiPref == CAP_AVFOUNDATION)
{
// TODO: fix this backend
std::cout << "SKIP test: AVFoundation backend can not write video" << std::endl;
return;
}
else if (apiPref == CAP_VFW)
{
// TODO: fix this backend
std::cout << "SKIP test: Video for Windows backend not open files" << std::endl;
return;
}
Mat img(frame_size, CV_8UC3);
VideoWriter writer(video_file, apiPref, fourcc, fps, frame_size, true);
ASSERT_TRUE(writer.isOpened());
for(int i = 0; i < frame_count; ++i )
{
generateFrame(i, frame_count, img);
writer << img;
}
writer.release();
}
void TearDown()
{
remove(video_file.c_str());
}
virtual void checkFrameContent(Mat & img, int idx)
{
Mat imgGT(frame_size, CV_8UC3);
generateFrame(idx, frame_count, imgGT);
double psnr = cvtest::PSNR(img, imgGT);
ASSERT_GT(psnr, PSNR_GT) << "frame " << idx;
}
virtual void checkFrameCount(int &actual)
{
Range expected_frame_count = Range(frame_count, frame_count);
// Hack! Newer FFmpeg versions in this combination produce a file
// whose reported duration is one frame longer than needed, and so
// the calculated frame count is also off by one. Ideally, we'd want
// to fix both writing (to produce the correct duration) and reading
// (to correctly report frame count for such files), but I don't know
// how to do either, so this is a workaround for now.
if (fourcc == VideoWriter::fourcc('M', 'P', 'E', 'G') && ext == "mkv")
expected_frame_count.end += 1;
ASSERT_LE(expected_frame_count.start, actual);
ASSERT_GE(expected_frame_count.end, actual);
actual = expected_frame_count.start; // adjust actual frame boundary to possible minimum
}
};
//==================================================================================================
int backend_params[] = {
#ifdef HAVE_QUICKTIME
CAP_QT,
#endif
#ifdef HAVE_AVFOUNDATION
CAP_AVFOUNDATION,
#endif
#ifdef HAVE_MSMF
CAP_MSMF,
#endif
#ifdef HAVE_VFW
CAP_VFW,
#endif
#ifdef HAVE_GSTREAMER
CAP_GSTREAMER,
#endif
#ifdef HAVE_FFMPEG
CAP_FFMPEG,
#endif
CAP_OPENCV_MJPEG
// CAP_INTEL_MFX
};
string bunny_params[] = {
#ifdef HAVE_VIDEO_INPUT
string("wmv"),
string("mov"),
string("mp4"),
string("mpg"),
string("avi"),
#endif
string("mjpg.avi")
};
TEST_P(Videoio_Bunny, read_position) { doTest(); }
TEST_P(Videoio_Bunny, frame_count) { doFrameCountTest(); }
INSTANTIATE_TEST_CASE_P(videoio, Videoio_Bunny,
testing::Combine(
testing::ValuesIn(bunny_params),
testing::ValuesIn(backend_params)));
//==================================================================================================
inline Ext_Fourcc_PSNR makeParam(const char * ext, const char * fourcc, float psnr, int apipref)
{
return make_tuple(string(ext), string(fourcc), (float)psnr, (int)apipref);
}
Ext_Fourcc_PSNR synthetic_params[] = {
#ifdef HAVE_MSMF
#if !defined(_M_ARM)
makeParam("wmv", "WMV1", 30.f, CAP_MSMF),
makeParam("wmv", "WMV2", 30.f, CAP_MSMF),
#endif
makeParam("wmv", "WMV3", 30.f, CAP_MSMF),
makeParam("wmv", "WVC1", 30.f, CAP_MSMF),
makeParam("avi", "H264", 30.f, CAP_MSMF),
makeParam("avi", "MJPG", 30.f, CAP_MSMF),
#endif
#ifdef HAVE_VFW
#if !defined(_M_ARM)
makeParam("wmv", "WMV1", 30.f, CAP_VFW),
makeParam("wmv", "WMV2", 30.f, CAP_VFW),
#endif
makeParam("wmv", "WMV3", 30.f, CAP_VFW),
makeParam("wmv", "WVC1", 30.f, CAP_VFW),
makeParam("avi", "H264", 30.f, CAP_VFW),
makeParam("avi", "MJPG", 30.f, CAP_VFW),
#endif
#ifdef HAVE_QUICKTIME
makeParam("mov", "mp4v", 30.f, CAP_QT),
makeParam("avi", "XVID", 30.f, CAP_QT),
makeParam("avi", "MPEG", 30.f, CAP_QT),
makeParam("avi", "IYUV", 30.f, CAP_QT),
makeParam("avi", "MJPG", 30.f, CAP_QT),
makeParam("mkv", "XVID", 30.f, CAP_QT),
makeParam("mkv", "MPEG", 30.f, CAP_QT),
makeParam("mkv", "MJPG", 30.f, CAP_QT),
#endif
#ifdef HAVE_AVFOUNDATION
makeParam("mov", "mp4v", 30.f, CAP_AVFOUNDATION),
makeParam("avi", "XVID", 30.f, CAP_AVFOUNDATION),
makeParam("avi", "MPEG", 30.f, CAP_AVFOUNDATION),
makeParam("avi", "IYUV", 30.f, CAP_AVFOUNDATION),
makeParam("avi", "MJPG", 30.f, CAP_AVFOUNDATION),
makeParam("mkv", "XVID", 30.f, CAP_AVFOUNDATION),
makeParam("mkv", "MPEG", 30.f, CAP_AVFOUNDATION),
makeParam("mkv", "MJPG", 30.f, CAP_AVFOUNDATION),
#endif
#ifdef HAVE_FFMPEG
makeParam("avi", "XVID", 30.f, CAP_FFMPEG),
makeParam("avi", "MPEG", 30.f, CAP_FFMPEG),
makeParam("avi", "IYUV", 30.f, CAP_FFMPEG),
makeParam("avi", "MJPG", 30.f, CAP_FFMPEG),
makeParam("mkv", "XVID", 30.f, CAP_FFMPEG),
makeParam("mkv", "MPEG", 30.f, CAP_FFMPEG),
makeParam("mkv", "MJPG", 30.f, CAP_FFMPEG),
#endif
#ifdef HAVE_GSTREAMER
// makeParam("avi", "XVID", 30.f, CAP_GSTREAMER), - corrupted frames, broken indexes
makeParam("avi", "MPEG", 30.f, CAP_GSTREAMER),
makeParam("avi", "IYUV", 30.f, CAP_GSTREAMER),
makeParam("avi", "MJPG", 30.f, CAP_GSTREAMER),
makeParam("avi", "H264", 30.f, CAP_GSTREAMER),
// makeParam("mkv", "XVID", 30.f, CAP_GSTREAMER),
makeParam("mkv", "MPEG", 30.f, CAP_GSTREAMER),
makeParam("mkv", "MJPG", 30.f, CAP_GSTREAMER),
#endif
makeParam("avi", "MJPG", 30.f, CAP_OPENCV_MJPEG),
};
Size all_sizes[] = {
Size(640, 480),
Size(976, 768)
};
TEST_P(Videoio_Synthetic, write_read_position) { doTest(); }
INSTANTIATE_TEST_CASE_P(videoio, Videoio_Synthetic,
testing::Combine(
testing::ValuesIn(all_sizes),
testing::ValuesIn(synthetic_params)));
|
<%
from pwnlib.shellcraft.aarch64.linux import syscall
%>
<%page args="mqdes, msg_ptr, msg_len, msg_prio, abs_timeout"/>
<%docstring>
Invokes the syscall mq_timedsend. See 'man 2 mq_timedsend' for more information.
Arguments:
mqdes(mqd_t): mqdes
msg_ptr(char): msg_ptr
msg_len(size_t): msg_len
msg_prio(unsigned): msg_prio
abs_timeout(timespec): abs_timeout
</%docstring>
${syscall('SYS_mq_timedsend', mqdes, msg_ptr, msg_len, msg_prio, abs_timeout)}
|
;;
;; 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/reg_sizes.asm"
%include "include/crc32_const.inc"
%include "include/clear_regs.asm"
[bits 64]
default rel
%ifdef LINUX
%define arg1 rdi
%define arg2 rsi
%define arg3 rdx
%define arg4 rcx
%else
%define arg1 rcx
%define arg2 rdx
%define arg3 r8
%define arg4 r9
%endif
struc STACK_FRAME
_xmm_save: resq 8 * 2
_rsp_save: resq 1
endstruc
section .text
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; arg1 - buffer pointer
;; arg2 - buffer size in bytes
;; Returns CRC value through RAX
align 32
MKGLOBAL(crc32_wimax_ofdma_data_avx, function,)
crc32_wimax_ofdma_data_avx:
%ifdef SAFE_PARAM
or arg1, arg1
jz .wrong_param
%endif
%ifndef LINUX
mov rax, rsp
sub rsp, STACK_FRAME_size
and rsp, -16
mov [rsp + _rsp_save], rax
vmovdqa [rsp + _xmm_save + 16*0], xmm6
vmovdqa [rsp + _xmm_save + 16*1], xmm7
vmovdqa [rsp + _xmm_save + 16*2], xmm8
vmovdqa [rsp + _xmm_save + 16*3], xmm9
vmovdqa [rsp + _xmm_save + 16*4], xmm10
vmovdqa [rsp + _xmm_save + 16*5], xmm11
vmovdqa [rsp + _xmm_save + 16*6], xmm12
vmovdqa [rsp + _xmm_save + 16*7], xmm13
%endif
lea arg4, [rel crc32_wimax_ofdma_data_const]
mov arg3, arg2
mov arg2, arg1
mov DWORD(arg1), 0xffff_ffff
call crc32_by8_avx
not eax
%ifdef SAFE_DATA
clear_scratch_xmms_avx_asm
%endif
%ifndef LINUX
vmovdqa xmm6, [rsp + _xmm_save + 16*0]
vmovdqa xmm7, [rsp + _xmm_save + 16*1]
vmovdqa xmm8, [rsp + _xmm_save + 16*2]
vmovdqa xmm9, [rsp + _xmm_save + 16*3]
vmovdqa xmm10, [rsp + _xmm_save + 16*4]
vmovdqa xmm11, [rsp + _xmm_save + 16*5]
vmovdqa xmm12, [rsp + _xmm_save + 16*6]
vmovdqa xmm13, [rsp + _xmm_save + 16*7]
mov rsp, [rsp + _rsp_save]
%endif
.wrong_param:
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; arg1 - buffer pointer
;; arg2 - buffer size in bytes
;; Returns CRC value through RAX
align 32
MKGLOBAL(crc8_wimax_ofdma_hcs_avx, function,)
crc8_wimax_ofdma_hcs_avx:
%ifdef SAFE_PARAM
or arg1, arg1
jz .wrong_param
%endif
%ifndef LINUX
mov rax, rsp
sub rsp, STACK_FRAME_size
and rsp, -16
mov [rsp + _rsp_save], rax
vmovdqa [rsp + _xmm_save + 16*0], xmm6
vmovdqa [rsp + _xmm_save + 16*1], xmm7
vmovdqa [rsp + _xmm_save + 16*2], xmm8
vmovdqa [rsp + _xmm_save + 16*3], xmm9
vmovdqa [rsp + _xmm_save + 16*4], xmm10
vmovdqa [rsp + _xmm_save + 16*5], xmm11
vmovdqa [rsp + _xmm_save + 16*6], xmm12
vmovdqa [rsp + _xmm_save + 16*7], xmm13
%endif
lea arg4, [rel crc32_wimax_ofdma_hcs8_const]
mov arg3, arg2
mov arg2, arg1
xor DWORD(arg1), DWORD(arg1)
call crc32_by8_avx
shr eax, 24 ; adjust for 8-bit poly
%ifdef SAFE_DATA
clear_scratch_xmms_avx_asm
%endif
%ifndef LINUX
vmovdqa xmm6, [rsp + _xmm_save + 16*0]
vmovdqa xmm7, [rsp + _xmm_save + 16*1]
vmovdqa xmm8, [rsp + _xmm_save + 16*2]
vmovdqa xmm9, [rsp + _xmm_save + 16*3]
vmovdqa xmm10, [rsp + _xmm_save + 16*4]
vmovdqa xmm11, [rsp + _xmm_save + 16*5]
vmovdqa xmm12, [rsp + _xmm_save + 16*6]
vmovdqa xmm13, [rsp + _xmm_save + 16*7]
mov rsp, [rsp + _rsp_save]
%endif
.wrong_param:
ret
%ifdef LINUX
section .note.GNU-stack noalloc noexec nowrite progbits
%endif
|
;================================================================================
; Service Request Support Code
;--------------------------------------------------------------------------------
; $7F5300 - $7F53FF - Multiworld Block
; $00 - $5F - RX Buffer
; $60 - $7E - Reserved
; $7F - RX Status
; $80 - $EF - TX Buffer
; $E0 - $FE - Reserved
; $FF - TX Status
;--------------------------------------------------------------------------------
; Status Codes
; #$00 - Idle
; #$01 - Local Read/Write
; #$02 - Ready for External Read/Write
;--------------------------------------------------------------------------------
; Block Commands
; #$00 - Wait
; #$01 - Signal Item-Seen
; #$02 - Signal Item-Get
; #$03 - Prompt Text
;--------------------------------------------------------------------------------
!RX_BUFFER = "$7F5300"
!RX_STATUS = "$7F537F"
!RX_SEQUENCE = "$7EF4A0"
!TX_BUFFER = "$7F5380"
!TX_STATUS = "$7F53FF"
!TX_SEQUENCE = "$7EF4A0"
;--------------------------------------------------------------------------------
PollService:
LDA !RX_STATUS : BEQ + : SEC : RTL : + ; return fail if we don't have the lock
LDA #$01 : STA !RX_STATUS ; mark busy
LDA !RX_BUFFER+1 : STA !RX_SEQUENCE ; mark this as handled
LDA !RX_BUFFER+2 : STA !RX_SEQUENCE+1
LDA !RX_BUFFER : CMP.b #03 : BNE +
LDA.l !RX_BUFFER+8 : TAX
LDA.l !RX_BUFFER+9 : STA $7E012E, X ; set sound effect, could possibly make this STA not-long
REP #$30 ; set 16-bit accumulator and index registers
LDA !RX_BUFFER+10 : TAX
LDA !RX_BUFFER+12
JSL.l DoToast
SEP #$30 ; set 8-bit accumulator and index registers
+
LDA #$00 : STA !RX_STATUS ; release lock
CLC ; mark request as successful
RTL
;--------------------------------------------------------------------------------
macro ServiceRequest(type)
LDA !TX_STATUS : BEQ + : SEC : RTL : + ; return fail if we don't have the lock
LDA #$01 : STA !TX_STATUS ; mark busy
LDA $7B : STA !TX_BUFFER+1 ; world
LDA $1B : STA !TX_BUFFER+2 ; indoor/outdoor
LDA $A0 : STA !TX_BUFFER+3 ; roomid low
LDA $A1 : STA !TX_BUFFER+4 ; roomid high
LDA $76 : STA !TX_BUFFER+5 ; object index (type 2 only)
LDA <type> : STA !TX_BUFFER ; item get
LDA #$00 : STA !TX_STATUS ; release lock
CLC ; mark request as successful
RTL
endmacro
;--------------------------------------------------------------------------------
ItemVisualServiceRequest:
%ServiceRequest(#$01)
;--------------------------------------------------------------------------------
ItemGetServiceRequest:
%ServiceRequest(#$02)
;-------------------------------------------------------------------------------- |
; size_t w_vector_erase_range(w_vector_t *v, size_t idx_first, size_t idx_last)
SECTION code_clib
SECTION code_adt_w_vector
PUBLIC w_vector_erase_range_callee
EXTERN w_array_erase_range_callee
defc w_vector_erase_range_callee = w_array_erase_range_callee
|
; The MIT License (MIT)
;
; Copyright (c) 2014 Microsoft
;
; 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.
;
; Author: Mark Gottscho <mgottscho@ucla.edu>
.code
win_x86_64_asm_revStride4Read_Word256 proc
; Arguments:
; rcx is address of the last 256-bit word in the array
; rdx is address of the first 256-bit word in the array
; rax holds number of words accessed
; rcx holds the last 256-bit word address
; rdx holds the target total number of words to access
; xmm0 holds result from reading the memory 256-bit wide
mov rax,rcx ; Temporarily save last word address
sub rcx,rdx ; Get total number of 256-bit words between starting and ending addresses
shr rcx,5
mov rdx,rcx ; Set target number of words
mov rcx,rax ; Restore last word address
xor rax,rax ; initialize number of words accessed to 0
cmp rax,rdx ; have we completed the target total number of words to access?
jae done ; if the number of words accessed >= the target number, then we are done
myloop:
; Unroll 32 loads of 256-bit words (32 bytes is 20h) in strides of 4 words before checking loop condition.
vmovdqa ymm0, ymmword ptr [rcx-0000h]
vmovdqa ymm0, ymmword ptr [rcx-0080h]
vmovdqa ymm0, ymmword ptr [rcx-0100h]
vmovdqa ymm0, ymmword ptr [rcx-0180h]
vmovdqa ymm0, ymmword ptr [rcx-0200h]
vmovdqa ymm0, ymmword ptr [rcx-0280h]
vmovdqa ymm0, ymmword ptr [rcx-0300h]
vmovdqa ymm0, ymmword ptr [rcx-0380h]
vmovdqa ymm0, ymmword ptr [rcx-0400h]
vmovdqa ymm0, ymmword ptr [rcx-0480h]
vmovdqa ymm0, ymmword ptr [rcx-0500h]
vmovdqa ymm0, ymmword ptr [rcx-0580h]
vmovdqa ymm0, ymmword ptr [rcx-0600h]
vmovdqa ymm0, ymmword ptr [rcx-0680h]
vmovdqa ymm0, ymmword ptr [rcx-0700h]
vmovdqa ymm0, ymmword ptr [rcx-0780h]
vmovdqa ymm0, ymmword ptr [rcx-0800h]
vmovdqa ymm0, ymmword ptr [rcx-0880h]
vmovdqa ymm0, ymmword ptr [rcx-0900h]
vmovdqa ymm0, ymmword ptr [rcx-0980h]
vmovdqa ymm0, ymmword ptr [rcx-0A00h]
vmovdqa ymm0, ymmword ptr [rcx-0A80h]
vmovdqa ymm0, ymmword ptr [rcx-0B00h]
vmovdqa ymm0, ymmword ptr [rcx-0B80h]
vmovdqa ymm0, ymmword ptr [rcx-0C00h]
vmovdqa ymm0, ymmword ptr [rcx-0C80h]
vmovdqa ymm0, ymmword ptr [rcx-0D00h]
vmovdqa ymm0, ymmword ptr [rcx-0D80h]
vmovdqa ymm0, ymmword ptr [rcx-0E00h]
vmovdqa ymm0, ymmword ptr [rcx-0E80h]
vmovdqa ymm0, ymmword ptr [rcx-0F00h]
vmovdqa ymm0, ymmword ptr [rcx-0F80h]
add rax,32 ; Just did 32 accesses
cmp rax,rdx ; have we completed the target number of accesses in total yet?
jb myloop ; make another unrolled pass on the memory
done:
xor eax,eax ; return 0
ret
win_x86_64_asm_revStride4Read_Word256 endp
end
|
; A147685: Squares and centered square numbers interleaved.
; 0,1,1,5,4,13,9,25,16,41,25,61,36,85,49,113,64,145,81,181,100,221,121,265,144,313,169,365,196,421,225,481,256,545,289,613,324,685,361,761,400,841,441,925,484,1013,529,1105,576,1201,625,1301,676,1405,729,1513,784,1625,841,1741,900,1861,961,1985,1024,2113,1089,2245,1156,2381,1225,2521,1296,2665,1369,2813,1444,2965,1521,3121,1600,3281,1681,3445,1764,3613,1849,3785,1936,3961,2025,4141,2116,4325,2209,4513,2304,4705,2401,4901,2500,5101,2601,5305,2704,5513,2809,5725,2916,5941,3025,6161,3136,6385,3249,6613,3364,6845,3481,7081,3600,7321,3721,7565,3844,7813,3969,8065,4096,8321,4225,8581,4356,8845,4489,9113,4624,9385,4761,9661,4900,9941,5041,10225,5184,10513,5329,10805,5476,11101,5625,11401,5776,11705,5929,12013,6084,12325,6241,12641,6400,12961,6561,13285,6724,13613,6889,13945,7056,14281,7225,14621,7396,14965,7569,15313,7744,15665,7921,16021,8100,16381,8281,16745,8464,17113,8649,17485,8836,17861,9025,18241,9216,18625,9409,19013,9604,19405,9801,19801,10000,20201,10201,20605,10404,21013,10609,21425,10816,21841,11025,22261,11236,22685,11449,23113,11664,23545,11881,23981,12100,24421,12321,24865,12544,25313,12769,25765,12996,26221,13225,26681,13456,27145,13689,27613,13924,28085,14161,28561,14400,29041,14641,29525,14884,30013,15129,30505,15376,31001
pow $0,2
add $0,1
mov $1,$0
gcd $1,2
mul $1,$0
div $1,4
|
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Author: kenton@google.com (Kenton Varda)
// Based on original Protocol Buffers design by
// Sanjay Ghemawat, Jeff Dean, and others.
#include <google/protobuf/compiler/cpp/cpp_enum_field.h>
#include <google/protobuf/compiler/cpp/cpp_helpers.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/wire_format.h>
#include <google/protobuf/stubs/strutil.h>
namespace google {
namespace protobuf {
namespace compiler {
namespace cpp {
namespace {
void SetEnumVariables(const FieldDescriptor* descriptor,
map<string, string>* variables,
const Options& options) {
SetCommonFieldVariables(descriptor, variables, options);
const EnumValueDescriptor* default_value = descriptor->default_value_enum();
(*variables)["type"] = ClassName(descriptor->enum_type(), true);
(*variables)["default"] = Int32ToString(default_value->number());
(*variables)["full_name"] = descriptor->full_name();
}
} // namespace
// ===================================================================
EnumFieldGenerator::EnumFieldGenerator(const FieldDescriptor* descriptor,
const Options& options)
: FieldGenerator(options), descriptor_(descriptor) {
SetEnumVariables(descriptor, &variables_, options);
}
EnumFieldGenerator::~EnumFieldGenerator() {}
void EnumFieldGenerator::
GeneratePrivateMembers(io::Printer* printer) const {
printer->Print(variables_, "int $name$_;\n");
}
void EnumFieldGenerator::
GenerateAccessorDeclarations(io::Printer* printer) const {
printer->Print(variables_,
"$deprecated_attr$$type$ $name$() const;\n"
"$deprecated_attr$void set_$name$($type$ value);\n");
}
void EnumFieldGenerator::
GenerateInlineAccessorDefinitions(io::Printer* printer,
bool is_inline) const {
map<string, string> variables(variables_);
variables["inline"] = is_inline ? "inline" : "";
printer->Print(variables,
"$inline$ $type$ $classname$::$name$() const {\n"
" // @@protoc_insertion_point(field_get:$full_name$)\n"
" return static_cast< $type$ >($name$_);\n"
"}\n"
"$inline$ void $classname$::set_$name$($type$ value) {\n");
if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) {
printer->Print(variables,
" assert($type$_IsValid(value));\n");
}
printer->Print(variables,
" $set_hasbit$\n"
" $name$_ = value;\n"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n");
}
void EnumFieldGenerator::
GenerateClearingCode(io::Printer* printer) const {
printer->Print(variables_, "$name$_ = $default$;\n");
}
void EnumFieldGenerator::
GenerateMergingCode(io::Printer* printer) const {
printer->Print(variables_, "set_$name$(from.$name$());\n");
}
void EnumFieldGenerator::
GenerateSwappingCode(io::Printer* printer) const {
printer->Print(variables_, "std::swap($name$_, other->$name$_);\n");
}
void EnumFieldGenerator::
GenerateConstructorCode(io::Printer* printer) const {
printer->Print(variables_, "$name$_ = $default$;\n");
}
void EnumFieldGenerator::
GenerateMergeFromCodedStream(io::Printer* printer) const {
printer->Print(variables_,
"int value;\n"
"DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n"
" int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n"
" input, &value)));\n");
if (HasPreservingUnknownEnumSemantics(descriptor_->file())) {
printer->Print(variables_,
"set_$name$(static_cast< $type$ >(value));\n");
} else {
printer->Print(variables_,
"if ($type$_IsValid(value)) {\n"
" set_$name$(static_cast< $type$ >(value));\n");
if (UseUnknownFieldSet(descriptor_->file(), options_)) {
printer->Print(variables_,
"} else {\n"
" mutable_unknown_fields()->AddVarint($number$, value);\n");
} else {
printer->Print(
"} else {\n"
" unknown_fields_stream.WriteVarint32($tag$);\n"
" unknown_fields_stream.WriteVarint32(value);\n",
"tag", SimpleItoa(internal::WireFormat::MakeTag(descriptor_)));
}
printer->Print(variables_,
"}\n");
}
}
void EnumFieldGenerator::
GenerateSerializeWithCachedSizes(io::Printer* printer) const {
printer->Print(variables_,
"::google::protobuf::internal::WireFormatLite::WriteEnum(\n"
" $number$, this->$name$(), output);\n");
}
void EnumFieldGenerator::
GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
printer->Print(variables_,
"target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n"
" $number$, this->$name$(), target);\n");
}
void EnumFieldGenerator::
GenerateByteSize(io::Printer* printer) const {
printer->Print(variables_,
"total_size += $tag_size$ +\n"
" ::google::protobuf::internal::WireFormatLite::EnumSize(this->$name$());\n");
}
// ===================================================================
EnumOneofFieldGenerator::
EnumOneofFieldGenerator(const FieldDescriptor* descriptor,
const Options& options)
: EnumFieldGenerator(descriptor, options) {
SetCommonOneofFieldVariables(descriptor, &variables_);
}
EnumOneofFieldGenerator::~EnumOneofFieldGenerator() {}
void EnumOneofFieldGenerator::
GenerateInlineAccessorDefinitions(io::Printer* printer,
bool is_inline) const {
map<string, string> variables(variables_);
variables["inline"] = is_inline ? "inline" : "";
printer->Print(variables,
"$inline$ $type$ $classname$::$name$() const {\n"
" // @@protoc_insertion_point(field_get:$full_name$)\n"
" if (has_$name$()) {\n"
" return static_cast< $type$ >($oneof_prefix$$name$_);\n"
" }\n"
" return static_cast< $type$ >($default$);\n"
"}\n"
"$inline$ void $classname$::set_$name$($type$ value) {\n");
if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) {
printer->Print(variables,
" assert($type$_IsValid(value));\n");
}
printer->Print(variables,
" if (!has_$name$()) {\n"
" clear_$oneof_name$();\n"
" set_has_$name$();\n"
" }\n"
" $oneof_prefix$$name$_ = value;\n"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n");
}
void EnumOneofFieldGenerator::
GenerateClearingCode(io::Printer* printer) const {
printer->Print(variables_, "$oneof_prefix$$name$_ = $default$;\n");
}
void EnumOneofFieldGenerator::
GenerateSwappingCode(io::Printer* printer) const {
// Don't print any swapping code. Swapping the union will swap this field.
}
void EnumOneofFieldGenerator::
GenerateConstructorCode(io::Printer* printer) const {
printer->Print(variables_,
" $classname$_default_oneof_instance_->$name$_ = $default$;\n");
}
// ===================================================================
RepeatedEnumFieldGenerator::RepeatedEnumFieldGenerator(
const FieldDescriptor* descriptor, const Options& options)
: FieldGenerator(options), descriptor_(descriptor) {
SetEnumVariables(descriptor, &variables_, options);
}
RepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() {}
void RepeatedEnumFieldGenerator::
GeneratePrivateMembers(io::Printer* printer) const {
printer->Print(variables_,
"::google::protobuf::RepeatedField<int> $name$_;\n");
if (descriptor_->is_packed() &&
HasGeneratedMethods(descriptor_->file(), options_)) {
printer->Print(variables_,
"mutable int _$name$_cached_byte_size_;\n");
}
}
void RepeatedEnumFieldGenerator::
GenerateAccessorDeclarations(io::Printer* printer) const {
printer->Print(variables_,
"$deprecated_attr$$type$ $name$(int index) const;\n"
"$deprecated_attr$void set_$name$(int index, $type$ value);\n"
"$deprecated_attr$void add_$name$($type$ value);\n");
printer->Print(variables_,
"$deprecated_attr$const ::google::protobuf::RepeatedField<int>& $name$() const;\n"
"$deprecated_attr$::google::protobuf::RepeatedField<int>* mutable_$name$();\n");
}
void RepeatedEnumFieldGenerator::
GenerateInlineAccessorDefinitions(io::Printer* printer,
bool is_inline) const {
map<string, string> variables(variables_);
variables["inline"] = is_inline ? "inline" : "";
printer->Print(variables,
"$inline$ $type$ $classname$::$name$(int index) const {\n"
" // @@protoc_insertion_point(field_get:$full_name$)\n"
" return static_cast< $type$ >($name$_.Get(index));\n"
"}\n"
"$inline$ void $classname$::set_$name$(int index, $type$ value) {\n");
if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) {
printer->Print(variables,
" assert($type$_IsValid(value));\n");
}
printer->Print(variables,
" $name$_.Set(index, value);\n"
" // @@protoc_insertion_point(field_set:$full_name$)\n"
"}\n"
"$inline$ void $classname$::add_$name$($type$ value) {\n");
if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) {
printer->Print(variables,
" assert($type$_IsValid(value));\n");
}
printer->Print(variables,
" $name$_.Add(value);\n"
" // @@protoc_insertion_point(field_add:$full_name$)\n"
"}\n");
printer->Print(variables,
"$inline$ const ::google::protobuf::RepeatedField<int>&\n"
"$classname$::$name$() const {\n"
" // @@protoc_insertion_point(field_list:$full_name$)\n"
" return $name$_;\n"
"}\n"
"$inline$ ::google::protobuf::RepeatedField<int>*\n"
"$classname$::mutable_$name$() {\n"
" // @@protoc_insertion_point(field_mutable_list:$full_name$)\n"
" return &$name$_;\n"
"}\n");
}
void RepeatedEnumFieldGenerator::
GenerateClearingCode(io::Printer* printer) const {
printer->Print(variables_, "$name$_.Clear();\n");
}
void RepeatedEnumFieldGenerator::
GenerateMergingCode(io::Printer* printer) const {
printer->Print(variables_, "$name$_.MergeFrom(from.$name$_);\n");
}
void RepeatedEnumFieldGenerator::
GenerateSwappingCode(io::Printer* printer) const {
printer->Print(variables_, "$name$_.UnsafeArenaSwap(&other->$name$_);\n");
}
void RepeatedEnumFieldGenerator::
GenerateConstructorCode(io::Printer* printer) const {
// Not needed for repeated fields.
}
void RepeatedEnumFieldGenerator::
GenerateMergeFromCodedStream(io::Printer* printer) const {
// Don't use ReadRepeatedPrimitive here so that the enum can be validated.
printer->Print(variables_,
"int value;\n"
"DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n"
" int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n"
" input, &value)));\n");
if (HasPreservingUnknownEnumSemantics(descriptor_->file())) {
printer->Print(variables_,
"add_$name$(static_cast< $type$ >(value));\n");
} else {
printer->Print(variables_,
"if ($type$_IsValid(value)) {\n"
" add_$name$(static_cast< $type$ >(value));\n");
if (UseUnknownFieldSet(descriptor_->file(), options_)) {
printer->Print(variables_,
"} else {\n"
" mutable_unknown_fields()->AddVarint($number$, value);\n");
} else {
printer->Print(
"} else {\n"
" unknown_fields_stream.WriteVarint32(tag);\n"
" unknown_fields_stream.WriteVarint32(value);\n");
}
printer->Print("}\n");
}
}
void RepeatedEnumFieldGenerator::
GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const {
if (!descriptor_->is_packed()) {
// This path is rarely executed, so we use a non-inlined implementation.
if (HasPreservingUnknownEnumSemantics(descriptor_->file())) {
printer->Print(variables_,
"DO_((::google::protobuf::internal::"
"WireFormatLite::ReadPackedEnumPreserveUnknowns(\n"
" input,\n"
" $number$,\n"
" NULL,\n"
" NULL,\n"
" this->mutable_$name$())));\n");
} else if (UseUnknownFieldSet(descriptor_->file(), options_)) {
printer->Print(variables_,
"DO_((::google::protobuf::internal::WireFormat::ReadPackedEnumPreserveUnknowns(\n"
" input,\n"
" $number$,\n"
" $type$_IsValid,\n"
" mutable_unknown_fields(),\n"
" this->mutable_$name$())));\n");
} else {
printer->Print(variables_,
"DO_((::google::protobuf::internal::"
"WireFormatLite::ReadPackedEnumPreserveUnknowns(\n"
" input,\n"
" $number$,\n"
" $type$_IsValid,\n"
" &unknown_fields_stream,\n"
" this->mutable_$name$())));\n");
}
} else {
printer->Print(variables_,
"::google::protobuf::uint32 length;\n"
"DO_(input->ReadVarint32(&length));\n"
"::google::protobuf::io::CodedInputStream::Limit limit = "
"input->PushLimit(length);\n"
"while (input->BytesUntilLimit() > 0) {\n"
" int value;\n"
" DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n"
" int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n"
" input, &value)));\n");
if (HasPreservingUnknownEnumSemantics(descriptor_->file())) {
printer->Print(variables_,
" add_$name$(static_cast< $type$ >(value));\n");
} else {
printer->Print(variables_,
" if ($type$_IsValid(value)) {\n"
" add_$name$(static_cast< $type$ >(value));\n"
" } else {\n");
if (UseUnknownFieldSet(descriptor_->file(), options_)) {
printer->Print(variables_,
" mutable_unknown_fields()->AddVarint($number$, value);\n");
} else {
printer->Print(variables_,
" unknown_fields_stream.WriteVarint32(tag);\n"
" unknown_fields_stream.WriteVarint32(value);\n");
}
printer->Print(
" }\n");
}
printer->Print(variables_,
"}\n"
"input->PopLimit(limit);\n");
}
}
void RepeatedEnumFieldGenerator::
GenerateSerializeWithCachedSizes(io::Printer* printer) const {
if (descriptor_->is_packed()) {
// Write the tag and the size.
printer->Print(variables_,
"if (this->$name$_size() > 0) {\n"
" ::google::protobuf::internal::WireFormatLite::WriteTag(\n"
" $number$,\n"
" ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n"
" output);\n"
" output->WriteVarint32(_$name$_cached_byte_size_);\n"
"}\n");
}
printer->Print(variables_,
"for (int i = 0; i < this->$name$_size(); i++) {\n");
if (descriptor_->is_packed()) {
printer->Print(variables_,
" ::google::protobuf::internal::WireFormatLite::WriteEnumNoTag(\n"
" this->$name$(i), output);\n");
} else {
printer->Print(variables_,
" ::google::protobuf::internal::WireFormatLite::WriteEnum(\n"
" $number$, this->$name$(i), output);\n");
}
printer->Print("}\n");
}
void RepeatedEnumFieldGenerator::
GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {
if (descriptor_->is_packed()) {
// Write the tag and the size.
printer->Print(variables_,
"if (this->$name$_size() > 0) {\n"
" target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(\n"
" $number$,\n"
" ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n"
" target);\n"
" target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray("
" _$name$_cached_byte_size_, target);\n"
"}\n");
}
printer->Print(variables_,
"for (int i = 0; i < this->$name$_size(); i++) {\n");
if (descriptor_->is_packed()) {
printer->Print(variables_,
" target = ::google::protobuf::internal::WireFormatLite::WriteEnumNoTagToArray(\n"
" this->$name$(i), target);\n");
} else {
printer->Print(variables_,
" target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n"
" $number$, this->$name$(i), target);\n");
}
printer->Print("}\n");
}
void RepeatedEnumFieldGenerator::
GenerateByteSize(io::Printer* printer) const {
printer->Print(variables_,
"{\n"
" int data_size = 0;\n");
printer->Indent();
printer->Print(variables_,
"for (int i = 0; i < this->$name$_size(); i++) {\n"
" data_size += ::google::protobuf::internal::WireFormatLite::EnumSize(\n"
" this->$name$(i));\n"
"}\n");
if (descriptor_->is_packed()) {
printer->Print(variables_,
"if (data_size > 0) {\n"
" total_size += $tag_size$ +\n"
" ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n"
"}\n"
"GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n"
"_$name$_cached_byte_size_ = data_size;\n"
"GOOGLE_SAFE_CONCURRENT_WRITES_END();\n"
"total_size += data_size;\n");
} else {
printer->Print(variables_,
"total_size += $tag_size$ * this->$name$_size() + data_size;\n");
}
printer->Outdent();
printer->Print("}\n");
}
} // namespace cpp
} // namespace compiler
} // namespace protobuf
} // namespace google
|
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main() {
int n1, n2, test=1;
cin >> n1 >> n2;
while (n1 + n2 != 0) {
vector<int> v;
for (int i = 0; i < n1; i++) {
int temp;
cin >> temp;
v.push_back(temp);
}
int total = 0;
for (int i = 0; i < n2; i++)
total += v[i];
int max = (total / n2);
int min = (total / n2);
for (int i = n2; i < n1; i++) {
total -= v[i-n2];
total += v[i];
int media = total / n2;
if (media > max) max = media;
if (media < min) min = media;
}
cout << "Teste " << test << endl;
cout << min << " " << max << endl << endl;
test++;
cin >> n1 >> n2;
}
return 0;
} |
BITS 32
;TEST_FILE_META_BEGIN
;TEST_TYPE=TEST_F
;TEST_IGNOREFLAGS=FLAG_CF|FLAG_OF|FLAG_SF|FLAG_AF|FLAG_PF
;TEST_FILE_META_END
;TEST_BEGIN_RECORDING
lea ecx, [esp-0x20]
mov dword [ecx], 0x114400
bsf eax, [ecx]
mov ecx, 0
;TEST_END_RECORDING
|
# x86 mpn_divrem_1 -- mpn by limb division extending to fractional quotient.
#
# cycles/limb
# K7 42
# K6 20
# P6 40
# P5 44
# 486 approx 43 maybe
# Copyright (C) 1999, 2000 Free Software Foundation, Inc.
#
# This file is part of the GNU MP Library.
#
# The GNU MP Library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Library General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# The GNU MP Library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
# License for more details.
#
# You should have received a copy of the GNU Library General Public License
# along with the GNU MP Library; see the file COPYING.LIB. If not, write to
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
# MA 02111-1307, USA.
include(`../config.m4')
# mp_limb_t mpn_divrem_1 (mp_ptr dst, mp_size_t xsize,
# mp_srcptr src, mp_size_t size, mp_limb_t divisor);
# mp_limb_t mpn_divrem_1c (mp_ptr dst, mp_size_t xsize,
# mp_srcptr src, mp_size_t size, mp_limb_t divisor);
#
# Divide src,size by divisor and store the quotient in dst+xsize,size.
# Extend the division to fractional quotient limbs in dst,xsize. Return the
# remainder. Either or both xsize and size can be 0.
#
# mpn_divrem_1c takes a carry parameter which is an initial high limb,
# effectively one extra limb at the top of src,size. Must have
# carry<divisor.
#
#
# Essentially the code is the same as the division based part of
# mpn/generic/divrem_1.c, but has the following advantages.
#
# - If gcc isn't being used then divrem_1.c will get the generic C
# udiv_qrnnd() and be rather slow.
#
# - On K6, using the loop instruction is a 10% speedup, but gcc doesn't
# generate that instruction (as of 2.95 at least).
#
# A test is done to see if the high limb is less the the divisor, and if so
# one less div is done. A div is between 20 and 40 cycles on the various
# x86s, so assuming high<divisor about half the time, then this test saves
# half that amount. The branch misprediction penalty on each chip is less
# than half a div.
#
#
# K6: Back-to-back div instructions run at 20 cycles, the same as the loop
# here, so it seems there's nothing to gain by rearranging the loop.
# Pairing the mov and loop instructions was found to gain nothing. (The
# same is true of the mpn/x86/mod_1.asm loop.)
#
# With a "decl/jnz" rather than a "loop" this code runs at 22 cycles.
# The loop_or_decljnz macro is an easy way to get a 10% speedup.
#
# P5: Moving the load down to pair with the store might save 1 cycle, but
# that doesn't seem worth bothering with, since it'd be only a 2.2%
# saving.
#
# K7: New code doing a multiply by inverse is in progress and promises to
# run at about 25 cycles. The code here is just something reasonable to
# use for now.
#
# P6: Multiply by inverse is going to be looked at for this too.
defframe(PARAM_CARRY, 24)
defframe(PARAM_DIVISOR,20)
defframe(PARAM_SIZE, 16)
defframe(PARAM_SRC, 12)
defframe(PARAM_XSIZE, 8)
defframe(PARAM_DST, 4)
.text
ALIGN(16)
PROLOGUE(mpn_divrem_1c)
deflit(`FRAME',0)
movl PARAM_SIZE, %ecx
pushl %edi
FRAME_pushl()
movl PARAM_SRC, %edi
pushl %esi
FRAME_pushl()
movl PARAM_DIVISOR, %esi
pushl %ebx
FRAME_pushl()
movl PARAM_DST, %ebx
pushl %ebp
FRAME_pushl()
movl PARAM_XSIZE, %ebp
orl %ecx, %ecx
movl PARAM_CARRY, %edx
jz LF(mpn_divrem_1,fraction)
leal -4(%ebx,%ebp,4), %ebx # dst one limb below integer part
jmp LF(mpn_divrem_1,integer_top)
EPILOGUE()
PROLOGUE(mpn_divrem_1)
deflit(`FRAME',0)
movl PARAM_SIZE, %ecx
pushl %edi
FRAME_pushl()
movl PARAM_SRC, %edi
pushl %esi
FRAME_pushl()
movl PARAM_DIVISOR, %esi
orl %ecx,%ecx
jz L(size_zero)
pushl %ebx
FRAME_pushl()
movl -4(%edi,%ecx,4), %eax # src high limb
xorl %edx, %edx
movl PARAM_DST, %ebx
pushl %ebp
FRAME_pushl()
movl PARAM_XSIZE, %ebp
cmpl %esi, %eax
leal -4(%ebx,%ebp,4), %ebx # dst one limb below integer part
jae L(integer_entry)
# high<divisor, so high of dst is zero, and avoid one div
movl %edx, (%ebx,%ecx,4)
decl %ecx
movl %eax, %edx
jz L(fraction)
L(integer_top):
# eax scratch (quotient)
# ebx dst+4*xsize-4
# ecx counter
# edx scratch (remainder)
# esi divisor
# edi src
# ebp xsize
movl -4(%edi,%ecx,4), %eax
L(integer_entry):
divl %esi
movl %eax, (%ebx,%ecx,4)
loop_or_decljnz L(integer_top)
L(fraction):
orl %ebp, %ecx
jz L(done)
movl PARAM_DST, %ebx
L(fraction_top):
# eax scratch (quotient)
# ebx dst
# ecx counter
# edx scratch (remainder)
# esi divisor
# edi
# ebp
xorl %eax, %eax
divl %esi
movl %eax, -4(%ebx,%ecx,4)
loop_or_decljnz L(fraction_top)
L(done):
popl %ebp
movl %edx, %eax
popl %ebx
popl %esi
popl %edi
ret
L(size_zero):
deflit(`FRAME',8)
movl PARAM_XSIZE, %ecx
xorl %eax, %eax
movl PARAM_DST, %edi
cld # better safe than sorry, see mpn/x86/README.family
rep
stosl
popl %esi
popl %edi
ret
EPILOGUE()
|
// Copyright (c) by respective owners including Yahoo!, Microsoft, and
// individual contributors. All rights reserved. Released under a BSD (revised)
// license as described in the file LICENSE.
#ifdef _WIN32
# pragma warning(disable : 4996) // generated by inner_product use
#endif
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include "correctedMath.h"
#include "vw_versions.h"
#include "vw.h"
#include "mwt.h"
#include <cstring>
#include <cstdio>
#include <cassert>
#include "no_label.h"
#include "gd.h"
#include "rand48.h"
#include "reductions.h"
#include "array_parameters.h"
#include "vw_exception.h"
#include "io/logger.h"
#include "shared_data.h"
#include <boost/version.hpp>
#include <boost/math/special_functions/digamma.hpp>
#include <boost/math/special_functions/gamma.hpp>
#if BOOST_VERSION >= 105600
# include <boost/align/is_aligned.hpp>
#endif
using namespace VW::config;
using namespace VW::LEARNER;
namespace logger = VW::io::logger;
enum class lda_math_mode : int
{
USE_SIMD = 0,
USE_PRECISE,
USE_FAST_APPROX
};
class index_feature
{
public:
uint32_t document;
feature f;
bool operator<(const index_feature b) const { return f.weight_index < b.f.weight_index; }
};
struct lda
{
size_t topics = 0;
float lda_alpha = 0.f;
float lda_rho = 0.f;
float lda_D = 0.f;
float lda_epsilon = 0.f;
size_t minibatch = 0;
lda_math_mode mmode;
size_t finish_example_count = 0;
v_array<float> Elogtheta;
v_array<float> decay_levels;
v_array<float> total_new;
v_array<example *> examples;
v_array<float> total_lambda;
v_array<int> doc_lengths;
v_array<float> digammas;
v_array<float> v;
std::vector<index_feature> sorted_features;
bool compute_coherence_metrics = false;
// size by 1 << bits
std::vector<uint32_t> feature_counts;
std::vector<std::vector<size_t>> feature_to_example_map;
bool total_lambda_init = false;
double example_t;
VW::workspace* all = nullptr; // regressor, lda
static constexpr float underflow_threshold = 1.0e-10f;
inline float digamma(float x);
inline float lgamma(float x);
inline float powf(float x, float p);
inline void expdigammify(VW::workspace& all, float* gamma);
inline void expdigammify_2(VW::workspace& all, float* gamma, float* norm);
};
// #define VW_NO_INLINE_SIMD
namespace ldamath
{
inline float fastlog2(float x)
{
uint32_t mx;
memcpy(&mx, &x, sizeof(uint32_t));
mx = (mx & 0x007FFFFF) | (0x7e << 23);
float mx_f;
memcpy(&mx_f, &mx, sizeof(float));
uint32_t vx;
memcpy(&vx, &x, sizeof(uint32_t));
float y = static_cast<float>(vx);
y *= 1.0f / static_cast<float>(1 << 23);
return y - 124.22544637f - 1.498030302f * mx_f - 1.72587999f / (0.3520887068f + mx_f);
}
inline float fastlog(float x) { return 0.69314718f * fastlog2(x); }
inline float fastpow2(float p)
{
float offset = (p < 0) * 1.0f;
float clipp = (p < -126.0) ? -126.0f : p;
int w = static_cast<int>(clipp);
float z = clipp - w + offset;
uint32_t approx =
static_cast<uint32_t>((1 << 23) * (clipp + 121.2740838f + 27.7280233f / (4.84252568f - z) - 1.49012907f * z));
float v;
memcpy(&v, &approx, sizeof(uint32_t));
return v;
}
inline float fastexp(float p) { return fastpow2(1.442695040f * p); }
inline float fastpow(float x, float p) { return fastpow2(p * fastlog2(x)); }
inline float fastlgamma(float x)
{
float logterm = fastlog(x * (1.0f + x) * (2.0f + x));
float xp3 = 3.0f + x;
return -2.081061466f - x + 0.0833333f / xp3 - logterm + (2.5f + x) * fastlog(xp3);
}
inline float fastdigamma(float x)
{
float twopx = 2.0f + x;
float logterm = fastlog(twopx);
return -(1.0f + 2.0f * x) / (x * (1.0f + x)) - (13.0f + 6.0f * x) / (12.0f * twopx * twopx) + logterm;
}
#if !defined(VW_NO_INLINE_SIMD)
# if defined(__SSE2__) || defined(__SSE3__) || defined(__SSE4_1__)
namespace
{
inline bool is_aligned16(void* ptr)
{
# if BOOST_VERSION >= 105600
return boost::alignment::is_aligned(16, ptr);
# else
return ((reinterpret_cast<uintptr_t>(ptr) & 0x0f) == 0);
# endif
}
} // namespace
// Include headers for the various SSE versions:
# if defined(__SSE2__)
# include <emmintrin.h>
# endif
# if defined(__SSE3__)
# include <tmmintrin.h>
# endif
# if defined(__SSE4_1__)
# include <smmintrin.h>
# endif
# define HAVE_SIMD_MATHMODE
typedef __m128 v4sf;
using v4si = __m128i;
inline v4sf v4si_to_v4sf(v4si x) { return _mm_cvtepi32_ps(x); }
inline v4si v4sf_to_v4si(v4sf x) { return _mm_cvttps_epi32(x); }
// Extract v[idx]
template <const int idx>
float v4sf_index(const v4sf x)
{
# if defined(__SSE4_1__)
float ret;
uint32_t val;
val = _mm_extract_ps(x, idx);
// Portably convert uint32_t bit pattern to float. Optimizers will generally
// make this disappear.
memcpy(&ret, &val, sizeof(uint32_t));
return ret;
# else
return _mm_cvtss_f32(_mm_shuffle_ps(x, x, _MM_SHUFFLE(idx, idx, idx, idx)));
# endif
}
// Specialization for the 0'th element
template <>
float v4sf_index<0>(const v4sf x)
{
return _mm_cvtss_f32(x);
}
inline v4sf v4sfl(const float x) { return _mm_set1_ps(x); }
inline v4si v4sil(const uint32_t x) { return _mm_set1_epi32(x); }
# ifdef _WIN32
inline __m128 operator+(const __m128 a, const __m128 b) { return _mm_add_ps(a, b); }
inline __m128 operator-(const __m128 a, const __m128 b) { return _mm_sub_ps(a, b); }
inline __m128 operator*(const __m128 a, const __m128 b) { return _mm_mul_ps(a, b); }
inline __m128 operator/(const __m128 a, const __m128 b) { return _mm_div_ps(a, b); }
# endif
inline v4sf vfastpow2(const v4sf p)
{
v4sf ltzero = _mm_cmplt_ps(p, v4sfl(0.0f));
v4sf offset = _mm_and_ps(ltzero, v4sfl(1.0f));
v4sf lt126 = _mm_cmplt_ps(p, v4sfl(-126.0f));
v4sf clipp = _mm_andnot_ps(lt126, p) + _mm_and_ps(lt126, v4sfl(-126.0f));
v4si w = v4sf_to_v4si(clipp);
v4sf z = clipp - v4si_to_v4sf(w) + offset;
const v4sf c_121_2740838 = v4sfl(121.2740838f);
const v4sf c_27_7280233 = v4sfl(27.7280233f);
const v4sf c_4_84252568 = v4sfl(4.84252568f);
const v4sf c_1_49012907 = v4sfl(1.49012907f);
v4sf v = v4sfl(1 << 23) * (clipp + c_121_2740838 + c_27_7280233 / (c_4_84252568 - z) - c_1_49012907 * z);
return _mm_castsi128_ps(v4sf_to_v4si(v));
}
inline v4sf vfastexp(const v4sf p)
{
const v4sf c_invlog_2 = v4sfl(1.442695040f);
return vfastpow2(c_invlog_2 * p);
}
inline v4sf vfastlog2(v4sf x)
{
v4si vx_i = _mm_castps_si128(x);
v4sf mx_f = _mm_castsi128_ps(_mm_or_si128(_mm_and_si128(vx_i, v4sil(0x007FFFFF)), v4sil(0x3f000000)));
v4sf y = v4si_to_v4sf(vx_i) * v4sfl(1.1920928955078125e-7f);
const v4sf c_124_22551499 = v4sfl(124.22551499f);
const v4sf c_1_498030302 = v4sfl(1.498030302f);
const v4sf c_1_725877999 = v4sfl(1.72587999f);
const v4sf c_0_3520087068 = v4sfl(0.3520887068f);
return y - c_124_22551499 - c_1_498030302 * mx_f - c_1_725877999 / (c_0_3520087068 + mx_f);
}
inline v4sf vfastlog(v4sf x)
{
const v4sf c_0_69314718 = v4sfl(0.69314718f);
return c_0_69314718 * vfastlog2(x);
}
inline v4sf vfastdigamma(v4sf x)
{
v4sf twopx = v4sfl(2.0f) + x;
v4sf logterm = vfastlog(twopx);
return (v4sfl(-48.0f) + x * (v4sfl(-157.0f) + x * (v4sfl(-127.0f) - v4sfl(30.0f) * x))) /
(v4sfl(12.0f) * x * (v4sfl(1.0f) + x) * twopx * twopx) +
logterm;
}
void vexpdigammify(VW::workspace& all, float* gamma, const float underflow_threshold)
{
float extra_sum = 0.0f;
v4sf sum = v4sfl(0.0f);
float *fp;
const float *fpend = gamma + all.lda;
// Iterate through the initial part of the array that isn't 128-bit SIMD
// aligned.
for (fp = gamma; fp < fpend && !is_aligned16(fp); ++fp)
{
extra_sum += *fp;
*fp = fastdigamma(*fp);
}
// Rip through the aligned portion...
for (; is_aligned16(fp) && fp + 4 < fpend; fp += 4)
{
v4sf arg = _mm_load_ps(fp);
sum = sum + arg;
arg = vfastdigamma(arg);
_mm_store_ps(fp, arg);
}
for (; fp < fpend; ++fp)
{
extra_sum += *fp;
*fp = fastdigamma(*fp);
}
# if defined(__SSE3__) || defined(__SSE4_1__)
// Do two horizontal adds on sum, extract the total from the 0 element:
sum = _mm_hadd_ps(sum, sum);
sum = _mm_hadd_ps(sum, sum);
extra_sum += v4sf_index<0>(sum);
# else
extra_sum += v4sf_index<0>(sum) + v4sf_index<1>(sum) + v4sf_index<2>(sum) + v4sf_index<3>(sum);
# endif
extra_sum = fastdigamma(extra_sum);
sum = v4sfl(extra_sum);
for (fp = gamma; fp < fpend && !is_aligned16(fp); ++fp) { *fp = fmax(underflow_threshold, fastexp(*fp - extra_sum)); }
for (; is_aligned16(fp) && fp + 4 < fpend; fp += 4)
{
v4sf arg = _mm_load_ps(fp);
arg = arg - sum;
arg = vfastexp(arg);
arg = _mm_max_ps(v4sfl(underflow_threshold), arg);
_mm_store_ps(fp, arg);
}
for (; fp < fpend; ++fp) { *fp = fmax(underflow_threshold, fastexp(*fp - extra_sum)); }
}
void vexpdigammify_2(VW::workspace& all, float* gamma, const float* norm, const float underflow_threshold)
{
float *fp = gamma;
const float *np;
const float *fpend = gamma + all.lda;
for (np = norm; fp < fpend && !is_aligned16(fp); ++fp, ++np)
*fp = fmax(underflow_threshold, fastexp(fastdigamma(*fp) - *np));
for (; is_aligned16(fp) && fp + 4 < fpend; fp += 4, np += 4)
{
v4sf arg = _mm_load_ps(fp);
arg = vfastdigamma(arg);
v4sf vnorm = _mm_loadu_ps(np);
arg = arg - vnorm;
arg = vfastexp(arg);
arg = _mm_max_ps(v4sfl(underflow_threshold), arg);
_mm_store_ps(fp, arg);
}
for (; fp < fpend; ++fp, ++np) *fp = fmax(underflow_threshold, fastexp(fastdigamma(*fp) - *np));
}
# else
// PLACEHOLDER for future ARM NEON code
// Also remember to define HAVE_SIMD_MATHMODE
# endif
#endif // !VW_NO_INLINE_SIMD
// Templates for common code shared between the three math modes (SIMD, fast approximations
// and accurate).
//
// The generic template takes a type and a specialization flag, mtype.
//
// mtype == USE_PRECISE: Use the accurate computation for lgamma, digamma.
// mtype == USE_FAST_APPROX: Use the fast approximations for lgamma, digamma.
// mtype == USE_SIMD: Use CPU SIMD instruction
//
// The generic template is specialized for the particular accuracy setting.
// Log gamma:
template <typename T, const lda_math_mode mtype>
inline T lgamma(T /* x */)
{
BOOST_STATIC_ASSERT_MSG(true, "ldamath::lgamma is not defined for this type and math mode.");
}
// Digamma:
template <typename T, const lda_math_mode mtype>
inline T digamma(T /* x */)
{
BOOST_STATIC_ASSERT_MSG(true, "ldamath::digamma is not defined for this type and math mode.");
}
// Exponential
template <typename T, lda_math_mode mtype>
inline T exponential(T /* x */)
{
BOOST_STATIC_ASSERT_MSG(true, "ldamath::exponential is not defined for this type and math mode.");
}
// Powf
template <typename T, lda_math_mode mtype>
inline T powf(T /* x */, T /* p */)
{
BOOST_STATIC_ASSERT_MSG(true, "ldamath::powf is not defined for this type and math mode.");
}
// High accuracy float specializations:
template <>
inline float lgamma<float, lda_math_mode::USE_PRECISE>(float x)
{
return boost::math::lgamma(x);
}
template <>
inline float digamma<float, lda_math_mode::USE_PRECISE>(float x)
{
return boost::math::digamma(x);
}
template <>
inline float exponential<float, lda_math_mode::USE_PRECISE>(float x)
{
return correctedExp(x);
}
template <>
inline float powf<float, lda_math_mode::USE_PRECISE>(float x, float p)
{
return std::pow(x, p);
}
// Fast approximation float specializations:
template <>
inline float lgamma<float, lda_math_mode::USE_FAST_APPROX>(float x)
{
return fastlgamma(x);
}
template <>
inline float digamma<float, lda_math_mode::USE_FAST_APPROX>(float x)
{
return fastdigamma(x);
}
template <>
inline float exponential<float, lda_math_mode::USE_FAST_APPROX>(float x)
{
return fastexp(x);
}
template <>
inline float powf<float, lda_math_mode::USE_FAST_APPROX>(float x, float p)
{
return fastpow(x, p);
}
// SIMD specializations:
template <>
inline float lgamma<float, lda_math_mode::USE_SIMD>(float x)
{
return lgamma<float, lda_math_mode::USE_FAST_APPROX>(x);
}
template <>
inline float digamma<float, lda_math_mode::USE_SIMD>(float x)
{
return digamma<float, lda_math_mode::USE_FAST_APPROX>(x);
}
template <>
inline float exponential<float, lda_math_mode::USE_SIMD>(float x)
{
return exponential<float, lda_math_mode::USE_FAST_APPROX>(x);
}
template <>
inline float powf<float, lda_math_mode::USE_SIMD>(float x, float p)
{
return powf<float, lda_math_mode::USE_FAST_APPROX>(x, p);
}
template <typename T, const lda_math_mode mtype>
inline void expdigammify(VW::workspace& all, T* gamma, T threshold, T initial)
{
T sum = digamma<T, mtype>(std::accumulate(gamma, gamma + all.lda, initial));
std::transform(gamma, gamma + all.lda, gamma,
[sum, threshold](T g) { return fmax(threshold, exponential<T, mtype>(digamma<T, mtype>(g) - sum)); });
}
template <>
inline void expdigammify<float, lda_math_mode::USE_SIMD>(vw& all, float* gamma, float threshold, float)
{
#if defined(HAVE_SIMD_MATHMODE)
vexpdigammify(all, gamma, threshold);
#else
// Do something sensible if SIMD math isn't available:
expdigammify<float, lda_math_mode::USE_FAST_APPROX>(all, gamma, threshold, 0.0);
#endif
}
template <typename T, const lda_math_mode mtype>
inline void expdigammify_2(VW::workspace& all, float* gamma, T* norm, const T threshold)
{
std::transform(gamma, gamma + all.lda, norm, gamma,
[threshold](float g, float n) { return fmax(threshold, exponential<T, mtype>(digamma<T, mtype>(g) - n)); });
}
template <>
inline void expdigammify_2<float, lda_math_mode::USE_SIMD>(vw& all, float* gamma, float* norm, const float threshold)
{
#if defined(HAVE_SIMD_MATHMODE)
vexpdigammify_2(all, gamma, norm, threshold);
#else
// Do something sensible if SIMD math isn't available:
expdigammify_2<float, lda_math_mode::USE_FAST_APPROX>(all, gamma, norm, threshold);
#endif
}
} // namespace ldamath
float lda::digamma(float x)
{
switch (mmode)
{
case lda_math_mode::USE_FAST_APPROX:
return ldamath::digamma<float, lda_math_mode::USE_FAST_APPROX>(x);
case lda_math_mode::USE_PRECISE:
return ldamath::digamma<float, lda_math_mode::USE_PRECISE>(x);
case lda_math_mode::USE_SIMD:
return ldamath::digamma<float, lda_math_mode::USE_SIMD>(x);
default:
// Should not happen.
logger::errlog_critical("lda::digamma: Trampled or invalid math mode, aborting");
abort();
return 0.0f;
}
}
float lda::lgamma(float x)
{
switch (mmode)
{
case lda_math_mode::USE_FAST_APPROX:
return ldamath::lgamma<float, lda_math_mode::USE_FAST_APPROX>(x);
case lda_math_mode::USE_PRECISE:
return ldamath::lgamma<float, lda_math_mode::USE_PRECISE>(x);
case lda_math_mode::USE_SIMD:
return ldamath::lgamma<float, lda_math_mode::USE_SIMD>(x);
default:
logger::errlog_critical("lda::lgamma: Trampled or invalid math mode, aborting");
abort();
return 0.0f;
}
}
float lda::powf(float x, float p)
{
switch (mmode)
{
case lda_math_mode::USE_FAST_APPROX:
return ldamath::powf<float, lda_math_mode::USE_FAST_APPROX>(x, p);
case lda_math_mode::USE_PRECISE:
return ldamath::powf<float, lda_math_mode::USE_PRECISE>(x, p);
case lda_math_mode::USE_SIMD:
return ldamath::powf<float, lda_math_mode::USE_SIMD>(x, p);
default:
logger::errlog_critical("lda::powf: Trampled or invalid math mode, aborting");
abort();
return 0.0f;
}
}
void lda::expdigammify(VW::workspace& all_, float* gamma)
{
switch (mmode)
{
case lda_math_mode::USE_FAST_APPROX:
ldamath::expdigammify<float, lda_math_mode::USE_FAST_APPROX>(all_, gamma, underflow_threshold, 0.0f);
break;
case lda_math_mode::USE_PRECISE:
ldamath::expdigammify<float, lda_math_mode::USE_PRECISE>(all_, gamma, underflow_threshold, 0.0f);
break;
case lda_math_mode::USE_SIMD:
ldamath::expdigammify<float, lda_math_mode::USE_SIMD>(all_, gamma, underflow_threshold, 0.0f);
break;
default:
logger::errlog_critical("lda::expdigammify: Trampled or invalid math mode, aborting");
abort();
}
}
void lda::expdigammify_2(VW::workspace& all_, float* gamma, float* norm)
{
switch (mmode)
{
case lda_math_mode::USE_FAST_APPROX:
ldamath::expdigammify_2<float, lda_math_mode::USE_FAST_APPROX>(all_, gamma, norm, underflow_threshold);
break;
case lda_math_mode::USE_PRECISE:
ldamath::expdigammify_2<float, lda_math_mode::USE_PRECISE>(all_, gamma, norm, underflow_threshold);
break;
case lda_math_mode::USE_SIMD:
ldamath::expdigammify_2<float, lda_math_mode::USE_SIMD>(all_, gamma, norm, underflow_threshold);
break;
default:
logger::errlog_critical("lda::expdigammify_2: Trampled or invalid math mode, aborting");
abort();
}
}
static inline float average_diff(VW::workspace& all, float* oldgamma, float* newgamma)
{
float sum;
float normalizer;
// This warps the normal sense of "inner product", but it accomplishes the same
// thing as the "plain old" for loop. clang does a good job of reducing the
// common subexpressions.
sum = std::inner_product(
oldgamma, oldgamma + all.lda, newgamma, 0.0f, [](float accum, float absdiff) { return accum + absdiff; },
[](float old_g, float new_g) { return std::abs(old_g - new_g); });
normalizer = std::accumulate(newgamma, newgamma + all.lda, 0.0f);
return sum / normalizer;
}
// Returns E_q[log p(\theta)] - E_q[log q(\theta)].
float theta_kl(lda &l, v_array<float> &Elogtheta, float *gamma)
{
float gammasum = 0;
Elogtheta.clear();
for (size_t k = 0; k < l.topics; k++)
{
Elogtheta.push_back(l.digamma(gamma[k]));
gammasum += gamma[k];
}
float digammasum = l.digamma(gammasum);
gammasum = l.lgamma(gammasum);
float kl = -(l.topics * l.lgamma(l.lda_alpha));
kl += l.lgamma(l.lda_alpha * l.topics) - gammasum;
for (size_t k = 0; k < l.topics; k++)
{
Elogtheta[k] -= digammasum;
kl += (l.lda_alpha - gamma[k]) * Elogtheta[k];
kl += l.lgamma(gamma[k]);
}
return kl;
}
static inline float find_cw(lda &l, float *u_for_w, float *v)
{
return 1.0f / std::inner_product(u_for_w, u_for_w + l.topics, v, 0.0f);
}
namespace
{
// Effectively, these are static and not visible outside the compilation unit.
v_array<float> new_gamma;
v_array<float> old_gamma;
} // namespace
// Returns an estimate of the part of the variational bound that
// doesn't have to do with beta for the entire corpus for the current
// setting of lambda based on the document passed in. The value is
// divided by the total number of words in the document This can be
// used as a (possibly very noisy) estimate of held-out likelihood.
float lda_loop(lda &l, v_array<float> &Elogtheta, float *v, example *ec, float)
{
parameters &weights = l.all->weights;
new_gamma.clear();
old_gamma.clear();
for (size_t i = 0; i < l.topics; i++)
{
new_gamma.push_back(1.f);
old_gamma.push_back(0.f);
}
size_t num_words = 0;
for (features &fs : *ec) num_words += fs.size();
float xc_w = 0;
float score = 0;
float doc_length = 0;
do
{
memcpy(v, new_gamma.begin(), sizeof(float) * l.topics);
l.expdigammify(*l.all, v);
memcpy(old_gamma.begin(), new_gamma.begin(), sizeof(float) * l.topics);
memset(new_gamma.begin(), 0, sizeof(float) * l.topics);
score = 0;
size_t word_count = 0;
doc_length = 0;
for (features &fs : *ec)
{
for (features::iterator &f : fs)
{
float *u_for_w = &(weights[f.index()]) + l.topics + 1;
float c_w = find_cw(l, u_for_w, v);
xc_w = c_w * f.value();
score += -f.value() * log(c_w);
size_t max_k = l.topics;
for (size_t k = 0; k < max_k; k++, ++u_for_w) new_gamma[k] += xc_w * *u_for_w;
word_count++;
doc_length += f.value();
}
}
for (size_t k = 0; k < l.topics; k++) new_gamma[k] = new_gamma[k] * v[k] + l.lda_alpha;
} while (average_diff(*l.all, old_gamma.begin(), new_gamma.begin()) > l.lda_epsilon);
ec->pred.scalars.clear();
ec->pred.scalars.resize_but_with_stl_behavior(l.topics);
memcpy(ec->pred.scalars.begin(), new_gamma.begin(), l.topics * sizeof(float));
score += theta_kl(l, Elogtheta, new_gamma.begin());
return score / doc_length;
}
size_t next_pow2(size_t x)
{
int i = 0;
x = x > 0 ? x - 1 : 0;
while (x > 0)
{
x >>= 1;
i++;
}
return (static_cast<size_t>(1)) << i;
}
struct initial_weights
{
weight _initial;
weight _initial_random;
bool _random;
uint32_t _lda;
uint32_t _stride;
};
void save_load(lda &l, io_buf &model_file, bool read, bool text)
{
VW::workspace& all = *(l.all);
uint64_t length = static_cast<uint64_t>(1) << all.num_bits;
if (read)
{
initialize_regressor(all);
initial_weights init{all.initial_t, static_cast<float>(l.lda_D / all.lda / all.length() * 200.f),
all.random_weights, all.lda, all.weights.stride()};
auto initial_lda_weight_initializer = [init](weight *weights, uint64_t index) {
uint32_t lda = init._lda;
weight initial_random = init._initial_random;
if (init._random)
{
for (size_t i = 0; i != lda; ++i, ++index)
{ weights[i] = static_cast<float>(-std::log(merand48(index) + 1e-6) + 1.0f) * initial_random; }
}
weights[lda] = init._initial;
};
all.weights.set_default(initial_lda_weight_initializer);
}
if (model_file.num_files() != 0)
{
uint64_t i = 0;
std::stringstream msg;
size_t brw = 1;
do
{
brw = 0;
size_t K = all.lda;
if (!read && text) msg << i << " ";
if (!read || all.model_file_ver >= VW::version_definitions::VERSION_FILE_WITH_HEADER_ID)
brw += bin_text_read_write_fixed(model_file, reinterpret_cast<char*>(&i), sizeof(i), read, msg, text);
else
{
// support 32bit build models
uint32_t j;
brw += bin_text_read_write_fixed(model_file, reinterpret_cast<char*>(&j), sizeof(j), read, msg, text);
i = j;
}
if (brw != 0)
{
weight *w = &(all.weights.strided_index(i));
for (uint64_t k = 0; k < K; k++)
{
weight *v = w + k;
if (!read && text) msg << *v + l.lda_rho << " ";
brw += bin_text_read_write_fixed(model_file, reinterpret_cast<char*>(v), sizeof(*v), read, msg, text);
}
}
if (text)
{
if (!read) msg << "\n";
brw += bin_text_read_write_fixed(model_file, nullptr, 0, read, msg, text);
}
if (!read) ++i;
} while ((!read && i < length) || (read && brw > 0));
}
}
void return_example(VW::workspace& all, example& ec)
{
all.sd->update(ec.test_only, true, ec.loss, ec.weight, ec.get_num_features());
for (auto &sink : all.final_prediction_sink) { MWT::print_scalars(sink.get(), ec.pred.scalars, ec.tag); }
if (all.sd->weighted_examples() >= all.sd->dump_interval && !all.logger.quiet)
all.sd->print_update(*all.trace_message, all.holdout_set_off, all.current_pass, "none", 0, ec.get_num_features(),
all.progress_add, all.progress_arg);
VW::finish_example(all, ec);
}
void learn_batch(lda &l)
{
parameters &weights = l.all->weights;
assert(l.finish_example_count == (l.examples.size() - 1));
if (l.sorted_features.empty()) // FAST-PASS for real "true"
{
// This can happen when the socket connection is dropped by the client.
// If l.sorted_features is empty, then l.sorted_features[0] does not
// exist, so we should not try to take its address in the beginning of
// the for loops down there. Since it seems that there's not much to
// do in this case, we just return.
for (size_t d = 0; d < l.examples.size(); d++)
{
l.examples[d]->pred.scalars.clear();
l.examples[d]->pred.scalars.resize_but_with_stl_behavior(l.topics);
memset(l.examples[d]->pred.scalars.begin(), 0, l.topics * sizeof(float));
l.examples[d]->pred.scalars.clear();
if (l.finish_example_count > 0)
{
return_example(*l.all, *l.examples[d]);
l.finish_example_count--;
}
}
l.examples.clear();
return;
}
float eta = -1;
float minuseta = -1;
if (l.total_lambda.empty())
{
for (size_t k = 0; k < l.all->lda; k++) l.total_lambda.push_back(0.f);
// This part does not work with sparse parameters
size_t stride = weights.stride();
for (size_t i = 0; i <= weights.mask(); i += stride)
{
weight *w = &(weights[i]);
for (size_t k = 0; k < l.all->lda; k++) l.total_lambda[k] += w[k];
}
}
l.example_t++;
l.total_new.clear();
for (size_t k = 0; k < l.all->lda; k++) l.total_new.push_back(0.f);
size_t batch_size = l.examples.size();
sort(l.sorted_features.begin(), l.sorted_features.end());
eta = l.all->eta * l.powf(static_cast<float>(l.example_t), -l.all->power_t);
minuseta = 1.0f - eta;
eta *= l.lda_D / batch_size;
l.decay_levels.push_back(l.decay_levels.back() + log(minuseta));
l.digammas.clear();
float additional = static_cast<float>(l.all->length()) * l.lda_rho;
for (size_t i = 0; i < l.all->lda; i++) l.digammas.push_back(l.digamma(l.total_lambda[i] + additional));
auto last_weight_index = std::numeric_limits<uint64_t>::max();
for (index_feature *s = &l.sorted_features[0]; s <= &l.sorted_features.back(); s++)
{
if (last_weight_index == s->f.weight_index) continue;
last_weight_index = s->f.weight_index;
// float *weights_for_w = &(weights[s->f.weight_index]);
float *weights_for_w = &(weights[s->f.weight_index & weights.mask()]);
float decay_component = l.decay_levels.end()[-2] -
l.decay_levels.end()[static_cast<int>(-1 - l.example_t + *(weights_for_w + l.all->lda))];
float decay = fmin(1.0f, correctedExp(decay_component));
float *u_for_w = weights_for_w + l.all->lda + 1;
*(weights_for_w + l.all->lda) = static_cast<float>(l.example_t);
for (size_t k = 0; k < l.all->lda; k++)
{
weights_for_w[k] *= decay;
u_for_w[k] = weights_for_w[k] + l.lda_rho;
}
l.expdigammify_2(*l.all, u_for_w, l.digammas.begin());
}
for (size_t d = 0; d < batch_size; d++)
{
float score = lda_loop(l, l.Elogtheta, &(l.v[d * l.all->lda]), l.examples[d], l.all->power_t);
if (l.all->audit) GD::print_audit_features(*l.all, *l.examples[d]);
// If the doc is empty, give it loss of 0.
if (l.doc_lengths[d] > 0)
{
l.all->sd->sum_loss -= score;
l.all->sd->sum_loss_since_last_dump -= score;
}
if (l.finish_example_count > 0)
{
return_example(*l.all, *l.examples[d]);
l.finish_example_count--;
}
}
// -t there's no need to update weights (especially since it's a noop)
if (eta != 0)
{
for (index_feature *s = &l.sorted_features[0]; s <= &l.sorted_features.back();)
{
index_feature *next = s + 1;
while (next <= &l.sorted_features.back() && next->f.weight_index == s->f.weight_index) next++;
float *word_weights = &(weights[s->f.weight_index]);
for (size_t k = 0; k < l.all->lda; k++, ++word_weights)
{
float new_value = minuseta * *word_weights;
*word_weights = new_value;
}
for (; s != next; s++)
{
float *v_s = &(l.v[s->document * l.all->lda]);
float *u_for_w = &(weights[s->f.weight_index]) + l.all->lda + 1;
float c_w = eta * find_cw(l, u_for_w, v_s) * s->f.x;
word_weights = &(weights[s->f.weight_index]);
for (size_t k = 0; k < l.all->lda; k++, ++u_for_w, ++word_weights)
{
float new_value = *u_for_w * v_s[k] * c_w;
l.total_new[k] += new_value;
*word_weights += new_value;
}
}
}
for (size_t k = 0; k < l.all->lda; k++)
{
l.total_lambda[k] *= minuseta;
l.total_lambda[k] += l.total_new[k];
}
}
l.sorted_features.resize(0);
l.examples.clear();
l.doc_lengths.clear();
}
void learn(lda& l, base_learner&, example& ec)
{
uint32_t num_ex = static_cast<uint32_t>(l.examples.size());
l.examples.push_back(&ec);
l.doc_lengths.push_back(0);
for (features &fs : ec)
{
for (features::iterator &f : fs)
{
index_feature temp = {num_ex, feature(f.value(), f.index())};
l.sorted_features.push_back(temp);
l.doc_lengths[num_ex] += static_cast<int>(f.value());
}
}
if (++num_ex == l.minibatch) learn_batch(l);
}
void learn_with_metrics(lda& l, base_learner& base, example& ec)
{
if (l.all->passes_complete == 0)
{
// build feature to example map
uint64_t stride_shift = l.all->weights.stride_shift();
uint64_t weight_mask = l.all->weights.mask();
for (features &fs : ec)
{
for (features::iterator &f : fs)
{
uint64_t idx = (f.index() & weight_mask) >> stride_shift;
l.feature_counts[idx] += static_cast<uint32_t>(f.value());
l.feature_to_example_map[idx].push_back(ec.example_counter);
}
}
}
learn(l, base, ec);
}
// placeholder
void predict(lda& l, base_learner& base, example& ec) { learn(l, base, ec); }
void predict_with_metrics(lda& l, base_learner& base, example& ec) { learn_with_metrics(l, base, ec); }
struct word_doc_frequency
{
// feature/word index
uint64_t idx;
// document count
uint32_t count;
};
// cooccurence of 2 features/words
struct feature_pair
{
// feature/word 1
uint64_t f1;
// feature/word 2
uint64_t f2;
feature_pair(uint64_t _f1, uint64_t _f2) : f1(_f1), f2(_f2) {}
};
template <class T>
void get_top_weights(VW::workspace* all, int top_words_count, int topic, std::vector<feature>& output, T& weights)
{
uint64_t length = static_cast<uint64_t>(1) << all->num_bits;
// get top features for this topic
auto cmp = [](feature left, feature right) { return left.x > right.x; };
std::priority_queue<feature, std::vector<feature>, decltype(cmp)> top_features(cmp);
typename T::iterator iter = weights.begin();
for (uint64_t i = 0; i < std::min(static_cast<uint64_t>(top_words_count), length); i++, ++iter)
top_features.push({(&(*iter))[topic], iter.index()});
for (uint64_t i = top_words_count; i < length; i++, ++iter)
{
weight v = (&(*iter))[topic];
if (v > top_features.top().x)
{
top_features.pop();
top_features.push({v, i});
}
}
// extract idx and sort descending
output.resize(top_features.size());
for (int i = (int)top_features.size() - 1; i >= 0; i--)
{
output[i] = top_features.top();
top_features.pop();
}
}
void get_top_weights(VW::workspace* all, int top_words_count, int topic, std::vector<feature>& output)
{
if (all->weights.sparse)
get_top_weights(all, top_words_count, topic, output, all->weights.sparse_weights);
else
get_top_weights(all, top_words_count, topic, output, all->weights.dense_weights);
}
template <class T>
void compute_coherence_metrics(lda &l, T &weights)
{
uint64_t length = static_cast<uint64_t>(1) << l.all->num_bits;
std::vector<std::vector<feature_pair>> topics_word_pairs;
topics_word_pairs.resize(l.topics);
int top_words_count = 10; // parameterize and check
for (size_t topic = 0; topic < l.topics; topic++)
{
// get top features for this topic
auto cmp = [](feature &left, feature &right) { return left.x > right.x; };
std::priority_queue<feature, std::vector<feature>, decltype(cmp)> top_features(cmp);
typename T::iterator iter = weights.begin();
for (uint64_t i = 0; i < std::min(static_cast<uint64_t>(top_words_count), length); i++, ++iter)
top_features.push(feature((&(*iter))[topic], iter.index()));
for (typename T::iterator v = weights.begin(); v != weights.end(); ++v)
if ((&(*v))[topic] > top_features.top().x)
{
top_features.pop();
top_features.push(feature((&(*v))[topic], v.index()));
}
// extract idx and sort descending
std::vector<uint64_t> top_features_idx;
top_features_idx.resize(top_features.size());
for (int i = (int)top_features.size() - 1; i >= 0; i--)
{
top_features_idx[i] = top_features.top().weight_index;
top_features.pop();
}
auto &word_pairs = topics_word_pairs[topic];
for (size_t i = 0; i < top_features_idx.size(); i++)
for (size_t j = i + 1; j < top_features_idx.size(); j++)
word_pairs.emplace_back(top_features_idx[i], top_features_idx[j]);
}
// compress word pairs and create record for storing frequency
std::map<uint64_t, std::vector<word_doc_frequency>> coWordsDFSet;
for (auto &vec : topics_word_pairs)
{
for (auto &wp : vec)
{
auto f1 = wp.f1;
auto f2 = wp.f2;
auto wdf = coWordsDFSet.find(f1);
if (wdf != coWordsDFSet.end())
{
// http://stackoverflow.com/questions/5377434/does-stdmapiterator-return-a-copy-of-value-or-a-value-itself
// if (wdf->second.find(f2) == wdf->second.end())
if (std::find_if(wdf->second.begin(), wdf->second.end(),
[&f2](const word_doc_frequency &v) { return v.idx == f2; }) != wdf->second.end())
{
wdf->second.push_back({f2, 0});
// printf(" add %d %d\n", f1, f2);
}
}
else
{
std::vector<word_doc_frequency> tmp_vec = {{f2, 0}};
coWordsDFSet.insert(std::make_pair(f1, tmp_vec));
}
}
}
// this.GetWordPairsDocumentFrequency(coWordsDFSet);
for (auto &pair : coWordsDFSet)
{
auto &examples_for_f1 = l.feature_to_example_map[pair.first];
for (auto &wdf : pair.second)
{
auto &examples_for_f2 = l.feature_to_example_map[wdf.idx];
// assumes examples_for_f1 and examples_for_f2 are orderd
size_t i = 0;
size_t j = 0;
while (i < examples_for_f1.size() && j < examples_for_f2.size())
{
if (examples_for_f1[i] == examples_for_f2[j])
{
wdf.count++;
i++;
j++;
}
else if (examples_for_f2[j] < examples_for_f1[i])
j++;
else
i++;
}
}
}
float epsilon = 1e-6f; // TODO
float avg_coherence = 0;
for (size_t topic = 0; topic < l.topics; topic++)
{
float coherence = 0;
for (auto &pairs : topics_word_pairs[topic])
{
auto f1 = pairs.f1;
if (l.feature_counts[f1] == 0) continue;
auto f2 = pairs.f2;
auto &co_feature = coWordsDFSet[f1];
auto co_feature_df = std::find_if(
co_feature.begin(), co_feature.end(), [&f2](const word_doc_frequency &v) { return v.idx == f2; });
if (co_feature_df != co_feature.end())
{
// printf("(%d:%d + eps)/(%d:%d)\n", f2, co_feature_df->count, f1, l.feature_counts[f1]);
coherence += logf((co_feature_df->count + epsilon) / l.feature_counts[f1]);
}
}
printf("Topic %3d coherence: %f\n", static_cast<int>(topic), coherence);
// TODO: expose per topic coherence
// TODO: good vs. bad topics
avg_coherence += coherence;
}
avg_coherence /= l.topics;
printf("Avg topic coherence: %f\n", avg_coherence);
}
void compute_coherence_metrics(lda &l)
{
if (l.all->weights.sparse)
compute_coherence_metrics(l, l.all->weights.sparse_weights);
else
compute_coherence_metrics(l, l.all->weights.dense_weights);
}
void end_pass(lda &l)
{
if (!l.examples.empty()) learn_batch(l);
if (l.compute_coherence_metrics && l.all->passes_complete == l.all->numpasses)
{
compute_coherence_metrics(l);
// FASTPASS return;
}
}
template <class T>
void end_examples(lda &l, T &weights)
{
for (typename T::iterator iter = weights.begin(); iter != weights.end(); ++iter)
{
float decay_component =
l.decay_levels.back() - l.decay_levels.end()[(int)(-1 - l.example_t + (&(*iter))[l.all->lda])];
float decay = fmin(1.f, correctedExp(decay_component));
weight *wp = &(*iter);
for (size_t i = 0; i < l.all->lda; ++i) wp[i] *= decay;
}
}
void end_examples(lda &l)
{
if (l.all->weights.sparse)
end_examples(l, l.all->weights.sparse_weights);
else
end_examples(l, l.all->weights.dense_weights);
}
void finish_example(VW::workspace& all, lda& l, example& e)
{
if (l.minibatch <= 1) { return return_example(all, e); }
if (l.examples.size() > 0)
{
// if there's still examples to be queued, inc only to finish later
l.finish_example_count++;
}
else
{
// return now since it has been processed (example size = 0)
return_example(all, e);
}
assert(l.finish_example_count <= l.minibatch);
}
std::istream &operator>>(std::istream &in, lda_math_mode &mmode)
{
std::string token;
in >> token;
if (token == "simd")
mmode = lda_math_mode::USE_SIMD;
else if (token == "accuracy" || token == "precise")
mmode = lda_math_mode::USE_PRECISE;
else if (token == "fast-approx" || token == "approx")
mmode = lda_math_mode::USE_FAST_APPROX;
else
THROW_EX(VW::vw_unrecognised_option_exception, token);
return in;
}
base_learner* lda_setup(VW::setup_base_i& stack_builder)
{
options_i& options = *stack_builder.get_options();
VW::workspace& all = *stack_builder.get_all_pointer();
auto ld = VW::make_unique<lda>();
option_group_definition new_options("Latent Dirichlet Allocation");
int math_mode;
new_options.add(make_option("lda", ld->topics).keep().necessary().help("Run lda with <int> topics"))
.add(make_option("lda_alpha", ld->lda_alpha)
.keep()
.default_value(0.1f)
.help("Prior on sparsity of per-document topic weights"))
.add(make_option("lda_rho", ld->lda_rho)
.keep()
.default_value(0.1f)
.help("Prior on sparsity of topic distributions"))
.add(make_option("lda_D", ld->lda_D).default_value(10000.0f).help("Number of documents"))
.add(make_option("lda_epsilon", ld->lda_epsilon).default_value(0.001f).help("Loop convergence threshold"))
.add(make_option("minibatch", ld->minibatch).default_value(1).help("Minibatch size, for LDA"))
.add(make_option("math-mode", math_mode)
.default_value(static_cast<int>(lda_math_mode::USE_SIMD))
.one_of({0, 1, 2})
.help("Math mode: 0=simd, 1=accuracy, 2=fast-approx"))
.add(make_option("metrics", ld->compute_coherence_metrics).help("Compute metrics"));
if (!options.add_parse_and_check_necessary(new_options)) return nullptr;
// Convert from int to corresponding enum value.
ld->mmode = static_cast<lda_math_mode>(math_mode);
ld->finish_example_count = 0;
all.lda = static_cast<uint32_t>(ld->topics);
ld->sorted_features = std::vector<index_feature>();
ld->total_lambda_init = false;
ld->all = &all;
ld->example_t = all.initial_t;
if (ld->compute_coherence_metrics)
{
ld->feature_counts.resize(static_cast<uint32_t>(UINT64_ONE << all.num_bits));
ld->feature_to_example_map.resize(static_cast<uint32_t>(UINT64_ONE << all.num_bits));
}
float temp = ceilf(logf(static_cast<float>(all.lda * 2 + 1)) / logf(2.f));
all.weights.stride_shift(static_cast<size_t>(temp));
all.random_weights = true;
all.add_constant = false;
if (all.eta > 1.)
{
logger::errlog_warn("your learning rate is too high, setting it to 1");
all.eta = std::min(all.eta, 1.f);
}
size_t minibatch2 = next_pow2(ld->minibatch);
if (minibatch2 > all.example_parser->ring_size)
{
bool previous_strict_parse = all.example_parser->strict_parse;
delete all.example_parser;
all.example_parser = new parser{minibatch2, previous_strict_parse};
all.example_parser->_shared_data = all.sd;
}
ld->v.resize_but_with_stl_behavior(all.lda * ld->minibatch);
ld->decay_levels.push_back(0.f);
all.example_parser->lbl_parser = no_label::no_label_parser;
auto* l = make_base_learner(std::move(ld), ld->compute_coherence_metrics ? learn_with_metrics : learn,
ld->compute_coherence_metrics ? predict_with_metrics : predict, stack_builder.get_setupfn_name(lda_setup),
VW::prediction_type_t::scalars, VW::label_type_t::nolabel)
.set_params_per_weight(UINT64_ONE << all.weights.stride_shift())
.set_learn_returns_prediction(true)
.set_save_load(save_load)
.set_finish_example(finish_example)
.set_end_examples(end_examples)
.set_end_pass(end_pass)
.build();
return make_base(*l);
}
|
; QLSD boot string
section banner
xdef banner
xref.l qlsd_vers
banner
dc.w txt_end-*-2
dc.b 'QLSD WIN driver '
dc.l qlsd_vers
dc.b ' WL + MK 2020',$a
; 'QLSD WIN driver 0.00 WL + MK 2020',$a
; ' (max 35 chars) ',$0A
txt_end
end
|
; A097337: Integer part of the edge of a cube that has space-diagonal n.
; 0,1,1,2,2,3,4,4,5,5,6,6,7,8,8,9,9,10,10,11,12,12,13,13,14,15,15,16,16,17,17,18,19,19,20,20,21,21,22,23,23,24,24,25,25,26,27,27,28,28,29,30,30,31,31,32,32,33,34,34,35,35,36,36,37,38,38,39,39,40,40,41,42,42,43,43,44,45,45,46,46,47,47,48,49,49,50,50,51,51,52,53,53,54,54,55,56,56,57,57
add $0,1
mov $1,$0
mov $0,0
pow $1,2
div $1,3
lpb $1
add $0,2
sub $1,1
trn $1,$0
lpe
div $0,2
|
PresetsMenuPkrd:
dw #presets_goto_pkrd_crateria
dw #presets_goto_pkrd_brinstar
dw #presets_goto_pkrd_wrecked_ship
dw #presets_goto_pkrd_red_brinstar_revisit
dw #presets_goto_pkrd_kraid
dw #presets_goto_pkrd_upper_norfair
dw #presets_goto_pkrd_lower_norfair
dw #presets_goto_pkrd_maridia
dw #presets_goto_pkrd_backtracking
dw #presets_goto_pkrd_tourian
dw #$0000
%cm_header("PRESETS FOR ANY% PKRD")
presets_goto_pkrd_crateria:
%cm_submenu("Crateria", #presets_submenu_pkrd_crateria)
presets_goto_pkrd_brinstar:
%cm_submenu("Brinstar", #presets_submenu_pkrd_brinstar)
presets_goto_pkrd_wrecked_ship:
%cm_submenu("Wrecked Ship", #presets_submenu_pkrd_wrecked_ship)
presets_goto_pkrd_red_brinstar_revisit:
%cm_submenu("Red Brinstar Revisit", #presets_submenu_pkrd_red_brinstar_revisit)
presets_goto_pkrd_kraid:
%cm_submenu("Kraid", #presets_submenu_pkrd_kraid)
presets_goto_pkrd_upper_norfair:
%cm_submenu("Upper Norfair", #presets_submenu_pkrd_upper_norfair)
presets_goto_pkrd_lower_norfair:
%cm_submenu("Lower Norfair", #presets_submenu_pkrd_lower_norfair)
presets_goto_pkrd_maridia:
%cm_submenu("Maridia", #presets_submenu_pkrd_maridia)
presets_goto_pkrd_backtracking:
%cm_submenu("Backtracking", #presets_submenu_pkrd_backtracking)
presets_goto_pkrd_tourian:
%cm_submenu("Tourian", #presets_submenu_pkrd_tourian)
presets_submenu_pkrd_crateria:
dw #presets_pkrd_crateria_ceres_elevator
dw #presets_pkrd_crateria_ceres_escape
dw #presets_pkrd_crateria_ceres_last_3_rooms
dw #presets_pkrd_crateria_ship
dw #presets_pkrd_crateria_parlor
dw #presets_pkrd_crateria_parlor_downback
dw #presets_pkrd_crateria_climb_down
dw #presets_pkrd_crateria_pit_room
dw #presets_pkrd_crateria_morph
dw #presets_pkrd_crateria_construction_zone_down
dw #presets_pkrd_crateria_construction_zone_up
dw #presets_pkrd_crateria_pit_room_revisit
dw #presets_pkrd_crateria_climb_up
dw #presets_pkrd_crateria_parlor_revisit
dw #presets_pkrd_crateria_flyway
dw #presets_pkrd_crateria_bomb_torizo
dw #presets_pkrd_crateria_alcatraz
dw #presets_pkrd_crateria_terminator
dw #presets_pkrd_crateria_green_pirate_shaft
dw #$0000
%cm_header("CRATERIA")
presets_submenu_pkrd_brinstar:
dw #presets_pkrd_brinstar_green_brinstar_elevator
dw #presets_pkrd_brinstar_early_supers
dw #presets_pkrd_brinstar_dachora_room
dw #presets_pkrd_brinstar_big_pink
dw #presets_pkrd_brinstar_green_hill_zone
dw #presets_pkrd_brinstar_noob_bridge
dw #presets_pkrd_brinstar_red_tower
dw #presets_pkrd_brinstar_hellway
dw #presets_pkrd_brinstar_caterpillars_down
dw #presets_pkrd_brinstar_alpha_power_bombs
dw #presets_pkrd_brinstar_caterpillars_up
dw #presets_pkrd_brinstar_crateria_kihunters
dw #presets_pkrd_brinstar_continuous_wall_jump
dw #presets_pkrd_brinstar_horizontal_bomb_jump
dw #presets_pkrd_brinstar_ocean
dw #$0000
%cm_header("BRINSTAR")
presets_submenu_pkrd_wrecked_ship:
dw #presets_pkrd_wrecked_ship_shaft_down
dw #presets_pkrd_wrecked_ship_basement
dw #presets_pkrd_wrecked_ship_phantoon
dw #presets_pkrd_wrecked_ship_leaving_phantoon
dw #presets_pkrd_wrecked_ship_shaft_to_supers
dw #presets_pkrd_wrecked_ship_shaft_up
dw #presets_pkrd_wrecked_ship_attic
dw #presets_pkrd_wrecked_ship_upper_west_ocean
dw #presets_pkrd_wrecked_ship_pancakes_and_wavers
dw #presets_pkrd_wrecked_ship_bowling_alley
dw #presets_pkrd_wrecked_ship_leaving_gravity
dw #presets_pkrd_wrecked_ship_reverse_moat
dw #presets_pkrd_wrecked_ship_crateria_kihunters_return
dw #$0000
%cm_header("WRECKED SHIP")
presets_submenu_pkrd_red_brinstar_revisit:
dw #presets_pkrd_red_brinstar_revisit_red_brinstar_elevator
dw #presets_pkrd_red_brinstar_revisit_hellway_revisit
dw #presets_pkrd_red_brinstar_revisit_red_tower_down
dw #presets_pkrd_red_brinstar_revisit_skree_boost
dw #presets_pkrd_red_brinstar_revisit_below_spazer
dw #presets_pkrd_red_brinstar_revisit_leaving_spazer
dw #presets_pkrd_red_brinstar_revisit_breaking_tube
dw #$0000
%cm_header("RED BRINSTAR REVISIT")
presets_submenu_pkrd_kraid:
dw #presets_pkrd_kraid_entering_kraids_lair
dw #presets_pkrd_kraid_kraid_kihunters
dw #presets_pkrd_kraid_mini_kraid
dw #presets_pkrd_kraid_kraid_2
dw #presets_pkrd_kraid_leaving_varia
dw #presets_pkrd_kraid_mini_kraid_revisit
dw #presets_pkrd_kraid_kraid_kihunters_revisit
dw #presets_pkrd_kraid_kraid_etank
dw #presets_pkrd_kraid_leaving_kraids_lair
dw #$0000
%cm_header("KRAID")
presets_submenu_pkrd_upper_norfair:
dw #presets_pkrd_upper_norfair_business_center
dw #presets_pkrd_upper_norfair_hi_jump_etank
dw #presets_pkrd_upper_norfair_leaving_hi_jump
dw #presets_pkrd_upper_norfair_business_center_2
dw #presets_pkrd_upper_norfair_ice_beam_gates
dw #presets_pkrd_upper_norfair_ice_maze_up
dw #presets_pkrd_upper_norfair_ice_maze_down
dw #presets_pkrd_upper_norfair_ice_escape
dw #presets_pkrd_upper_norfair_precathedral
dw #presets_pkrd_upper_norfair_cathedral
dw #presets_pkrd_upper_norfair_rising_tide
dw #presets_pkrd_upper_norfair_bubble_mountain
dw #presets_pkrd_upper_norfair_bat_cave
dw #presets_pkrd_upper_norfair_leaving_speedbooster
dw #presets_pkrd_upper_norfair_single_chamber
dw #presets_pkrd_upper_norfair_double_chamber
dw #presets_pkrd_upper_norfair_double_chamber_revisited
dw #presets_pkrd_upper_norfair_single_chamber_revisited
dw #presets_pkrd_upper_norfair_volcano_room
dw #presets_pkrd_upper_norfair_kronic_boost
dw #presets_pkrd_upper_norfair_lava_spark
dw #$0000
%cm_header("UPPER NORFAIR")
presets_submenu_pkrd_lower_norfair:
dw #presets_pkrd_lower_norfair_ln_main_hall
dw #presets_pkrd_lower_norfair_prepillars
dw #presets_pkrd_lower_norfair_worst_room_in_the_game
dw #presets_pkrd_lower_norfair_amphitheatre
dw #presets_pkrd_lower_norfair_kihunter_stairs_down
dw #presets_pkrd_lower_norfair_wasteland
dw #presets_pkrd_lower_norfair_metal_ninja_pirates
dw #presets_pkrd_lower_norfair_plowerhouse
dw #presets_pkrd_lower_norfair_ridley_farming_room
dw #presets_pkrd_lower_norfair_ridley
dw #presets_pkrd_lower_norfair_leaving_ridley
dw #presets_pkrd_lower_norfair_reverse_plowerhouse
dw #presets_pkrd_lower_norfair_wasteland_revisit
dw #presets_pkrd_lower_norfair_kihunter_stairs_up
dw #presets_pkrd_lower_norfair_fire_flea_room
dw #presets_pkrd_lower_norfair_springball_maze
dw #presets_pkrd_lower_norfair_three_musketeers
dw #presets_pkrd_lower_norfair_single_chamber_final
dw #presets_pkrd_lower_norfair_bubble_mountain_final
dw #presets_pkrd_lower_norfair_frog_speedway
dw #presets_pkrd_lower_norfair_business_center_final
dw #$0000
%cm_header("LOWER NORFAIR")
presets_submenu_pkrd_maridia:
dw #presets_pkrd_maridia_maridia_tube_revisit
dw #presets_pkrd_maridia_fish_tank
dw #presets_pkrd_maridia_mt_everest
dw #presets_pkrd_maridia_crab_shaft
dw #presets_pkrd_maridia_botwoon_hallway
dw #presets_pkrd_maridia_botwoon
dw #presets_pkrd_maridia_botwoon_etank
dw #presets_pkrd_maridia_halfie_setup
dw #presets_pkrd_maridia_draygon
dw #presets_pkrd_maridia_spikesuit_reverse_halfie
dw #presets_pkrd_maridia_reverse_colosseum
dw #presets_pkrd_maridia_reverse_halfie_climb
dw #presets_pkrd_maridia_reverse_botwoon_etank
dw #presets_pkrd_maridia_reverse_botwoon_hallway
dw #presets_pkrd_maridia_reverse_crab_shaft
dw #presets_pkrd_maridia_mt_everest_revisit
dw #$0000
%cm_header("MARIDIA")
presets_submenu_pkrd_backtracking:
dw #presets_pkrd_backtracking_red_brinstar_green_gate
dw #presets_pkrd_backtracking_crateria_kihunters_final
dw #presets_pkrd_backtracking_parlor_return
dw #presets_pkrd_backtracking_terminator_revisit
dw #presets_pkrd_backtracking_green_pirate_shaft_revisit
dw #presets_pkrd_backtracking_g4_hallway
dw #presets_pkrd_backtracking_g4_elevator
dw #$0000
%cm_header("BACKTRACKING")
presets_submenu_pkrd_tourian:
dw #presets_pkrd_tourian_tourian_elevator_room
dw #presets_pkrd_tourian_metroids_1
dw #presets_pkrd_tourian_metroids_2
dw #presets_pkrd_tourian_metroids_3
dw #presets_pkrd_tourian_metroids_4
dw #presets_pkrd_tourian_giant_hoppers
dw #presets_pkrd_tourian_baby_skip
dw #presets_pkrd_tourian_gadora_room
dw #presets_pkrd_tourian_rinka_shaft
dw #presets_pkrd_tourian_zeb_skip
dw #presets_pkrd_tourian_mother_brain_2
dw #presets_pkrd_tourian_mother_brain_3
dw #presets_pkrd_tourian_zebes_escape
dw #presets_pkrd_tourian_escape_room_3
dw #presets_pkrd_tourian_escape_room_4
dw #presets_pkrd_tourian_escape_climb
dw #presets_pkrd_tourian_escape_parlor
dw #$0000
%cm_header("TOURIAN")
; Crateria
presets_pkrd_crateria_ceres_elevator:
%cm_preset("Ceres Elevator", #preset_pkrd_crateria_ceres_elevator)
presets_pkrd_crateria_ceres_escape:
%cm_preset("Ceres Escape", #preset_pkrd_crateria_ceres_escape)
presets_pkrd_crateria_ceres_last_3_rooms:
%cm_preset("Ceres Last 3 rooms", #preset_pkrd_crateria_ceres_last_3_rooms)
presets_pkrd_crateria_ship:
%cm_preset("Ship", #preset_pkrd_crateria_ship)
presets_pkrd_crateria_parlor:
%cm_preset("Parlor", #preset_pkrd_crateria_parlor)
presets_pkrd_crateria_parlor_downback:
%cm_preset("Parlor Downback", #preset_pkrd_crateria_parlor_downback)
presets_pkrd_crateria_climb_down:
%cm_preset("Climb Down", #preset_pkrd_crateria_climb_down)
presets_pkrd_crateria_pit_room:
%cm_preset("Pit Room", #preset_pkrd_crateria_pit_room)
presets_pkrd_crateria_morph:
%cm_preset("Morph", #preset_pkrd_crateria_morph)
presets_pkrd_crateria_construction_zone_down:
%cm_preset("Construction Zone Down", #preset_pkrd_crateria_construction_zone_down)
presets_pkrd_crateria_construction_zone_up:
%cm_preset("Construction Zone Up", #preset_pkrd_crateria_construction_zone_up)
presets_pkrd_crateria_pit_room_revisit:
%cm_preset("Pit Room Revisit", #preset_pkrd_crateria_pit_room_revisit)
presets_pkrd_crateria_climb_up:
%cm_preset("Climb Up", #preset_pkrd_crateria_climb_up)
presets_pkrd_crateria_parlor_revisit:
%cm_preset("Parlor Revisit", #preset_pkrd_crateria_parlor_revisit)
presets_pkrd_crateria_flyway:
%cm_preset("Flyway", #preset_pkrd_crateria_flyway)
presets_pkrd_crateria_bomb_torizo:
%cm_preset("Bomb Torizo", #preset_pkrd_crateria_bomb_torizo)
presets_pkrd_crateria_alcatraz:
%cm_preset("Alcatraz", #preset_pkrd_crateria_alcatraz)
presets_pkrd_crateria_terminator:
%cm_preset("Terminator", #preset_pkrd_crateria_terminator)
presets_pkrd_crateria_green_pirate_shaft:
%cm_preset("Green Pirate Shaft", #preset_pkrd_crateria_green_pirate_shaft)
; Brinstar
presets_pkrd_brinstar_green_brinstar_elevator:
%cm_preset("Green Brinstar Elevator", #preset_pkrd_brinstar_green_brinstar_elevator)
presets_pkrd_brinstar_early_supers:
%cm_preset("Early Supers", #preset_pkrd_brinstar_early_supers)
presets_pkrd_brinstar_dachora_room:
%cm_preset("Dachora Room", #preset_pkrd_brinstar_dachora_room)
presets_pkrd_brinstar_big_pink:
%cm_preset("Big Pink", #preset_pkrd_brinstar_big_pink)
presets_pkrd_brinstar_green_hill_zone:
%cm_preset("Green Hill Zone", #preset_pkrd_brinstar_green_hill_zone)
presets_pkrd_brinstar_noob_bridge:
%cm_preset("Noob Bridge", #preset_pkrd_brinstar_noob_bridge)
presets_pkrd_brinstar_red_tower:
%cm_preset("Red Tower", #preset_pkrd_brinstar_red_tower)
presets_pkrd_brinstar_hellway:
%cm_preset("Hellway", #preset_pkrd_brinstar_hellway)
presets_pkrd_brinstar_caterpillars_down:
%cm_preset("Caterpillars Down", #preset_pkrd_brinstar_caterpillars_down)
presets_pkrd_brinstar_alpha_power_bombs:
%cm_preset("Alpha Power Bombs", #preset_pkrd_brinstar_alpha_power_bombs)
presets_pkrd_brinstar_caterpillars_up:
%cm_preset("Caterpillars Up", #preset_pkrd_brinstar_caterpillars_up)
presets_pkrd_brinstar_crateria_kihunters:
%cm_preset("Crateria Kihunters", #preset_pkrd_brinstar_crateria_kihunters)
presets_pkrd_brinstar_continuous_wall_jump:
%cm_preset("Continuous Wall Jump", #preset_pkrd_brinstar_continuous_wall_jump)
presets_pkrd_brinstar_horizontal_bomb_jump:
%cm_preset("Horizontal Bomb Jump", #preset_pkrd_brinstar_horizontal_bomb_jump)
presets_pkrd_brinstar_ocean:
%cm_preset("Ocean", #preset_pkrd_brinstar_ocean)
; Wrecked Ship
presets_pkrd_wrecked_ship_shaft_down:
%cm_preset("Shaft Down", #preset_pkrd_wrecked_ship_shaft_down)
presets_pkrd_wrecked_ship_basement:
%cm_preset("Basement", #preset_pkrd_wrecked_ship_basement)
presets_pkrd_wrecked_ship_phantoon:
%cm_preset("Phantoon", #preset_pkrd_wrecked_ship_phantoon)
presets_pkrd_wrecked_ship_leaving_phantoon:
%cm_preset("Leaving Phantoon", #preset_pkrd_wrecked_ship_leaving_phantoon)
presets_pkrd_wrecked_ship_shaft_to_supers:
%cm_preset("Shaft to Supers", #preset_pkrd_wrecked_ship_shaft_to_supers)
presets_pkrd_wrecked_ship_shaft_up:
%cm_preset("Shaft Up", #preset_pkrd_wrecked_ship_shaft_up)
presets_pkrd_wrecked_ship_attic:
%cm_preset("Attic", #preset_pkrd_wrecked_ship_attic)
presets_pkrd_wrecked_ship_upper_west_ocean:
%cm_preset("Upper West Ocean", #preset_pkrd_wrecked_ship_upper_west_ocean)
presets_pkrd_wrecked_ship_pancakes_and_wavers:
%cm_preset("Pancakes and Wavers", #preset_pkrd_wrecked_ship_pancakes_and_wavers)
presets_pkrd_wrecked_ship_bowling_alley:
%cm_preset("Bowling Alley", #preset_pkrd_wrecked_ship_bowling_alley)
presets_pkrd_wrecked_ship_leaving_gravity:
%cm_preset("Leaving Gravity", #preset_pkrd_wrecked_ship_leaving_gravity)
presets_pkrd_wrecked_ship_reverse_moat:
%cm_preset("Reverse Moat", #preset_pkrd_wrecked_ship_reverse_moat)
presets_pkrd_wrecked_ship_crateria_kihunters_return:
%cm_preset("Crateria Kihunters Return", #preset_pkrd_wrecked_ship_crateria_kihunters_return)
; Red Brinstar Revisit
presets_pkrd_red_brinstar_revisit_red_brinstar_elevator:
%cm_preset("Red Brinstar Elevator", #preset_pkrd_red_brinstar_revisit_red_brinstar_elevator)
presets_pkrd_red_brinstar_revisit_hellway_revisit:
%cm_preset("Hellway Revisit", #preset_pkrd_red_brinstar_revisit_hellway_revisit)
presets_pkrd_red_brinstar_revisit_red_tower_down:
%cm_preset("Red Tower Down", #preset_pkrd_red_brinstar_revisit_red_tower_down)
presets_pkrd_red_brinstar_revisit_skree_boost:
%cm_preset("Skree Boost", #preset_pkrd_red_brinstar_revisit_skree_boost)
presets_pkrd_red_brinstar_revisit_below_spazer:
%cm_preset("Below Spazer", #preset_pkrd_red_brinstar_revisit_below_spazer)
presets_pkrd_red_brinstar_revisit_leaving_spazer:
%cm_preset("Leaving Spazer", #preset_pkrd_red_brinstar_revisit_leaving_spazer)
presets_pkrd_red_brinstar_revisit_breaking_tube:
%cm_preset("Breaking Tube", #preset_pkrd_red_brinstar_revisit_breaking_tube)
; Kraid
presets_pkrd_kraid_entering_kraids_lair:
%cm_preset("Entering Kraids Lair", #preset_pkrd_kraid_entering_kraids_lair)
presets_pkrd_kraid_kraid_kihunters:
%cm_preset("Kraid Kihunters", #preset_pkrd_kraid_kraid_kihunters)
presets_pkrd_kraid_mini_kraid:
%cm_preset("Mini Kraid", #preset_pkrd_kraid_mini_kraid)
presets_pkrd_kraid_kraid_2:
%cm_preset("Kraid", #preset_pkrd_kraid_kraid_2)
presets_pkrd_kraid_leaving_varia:
%cm_preset("Leaving Varia", #preset_pkrd_kraid_leaving_varia)
presets_pkrd_kraid_mini_kraid_revisit:
%cm_preset("Mini Kraid Revisit", #preset_pkrd_kraid_mini_kraid_revisit)
presets_pkrd_kraid_kraid_kihunters_revisit:
%cm_preset("Kraid Kihunters Revisit", #preset_pkrd_kraid_kraid_kihunters_revisit)
presets_pkrd_kraid_kraid_etank:
%cm_preset("Kraid E-tank", #preset_pkrd_kraid_kraid_etank)
presets_pkrd_kraid_leaving_kraids_lair:
%cm_preset("Leaving Kraids Lair", #preset_pkrd_kraid_leaving_kraids_lair)
; Upper Norfair
presets_pkrd_upper_norfair_business_center:
%cm_preset("Business Center", #preset_pkrd_upper_norfair_business_center)
presets_pkrd_upper_norfair_hi_jump_etank:
%cm_preset("Hi Jump E-tank", #preset_pkrd_upper_norfair_hi_jump_etank)
presets_pkrd_upper_norfair_leaving_hi_jump:
%cm_preset("Leaving Hi Jump", #preset_pkrd_upper_norfair_leaving_hi_jump)
presets_pkrd_upper_norfair_business_center_2:
%cm_preset("Business Center 2", #preset_pkrd_upper_norfair_business_center_2)
presets_pkrd_upper_norfair_ice_beam_gates:
%cm_preset("Ice Beam Gates", #preset_pkrd_upper_norfair_ice_beam_gates)
presets_pkrd_upper_norfair_ice_maze_up:
%cm_preset("Ice Maze Up", #preset_pkrd_upper_norfair_ice_maze_up)
presets_pkrd_upper_norfair_ice_maze_down:
%cm_preset("Ice Maze Down", #preset_pkrd_upper_norfair_ice_maze_down)
presets_pkrd_upper_norfair_ice_escape:
%cm_preset("Ice Escape", #preset_pkrd_upper_norfair_ice_escape)
presets_pkrd_upper_norfair_precathedral:
%cm_preset("Pre-Cathedral", #preset_pkrd_upper_norfair_precathedral)
presets_pkrd_upper_norfair_cathedral:
%cm_preset("Cathedral", #preset_pkrd_upper_norfair_cathedral)
presets_pkrd_upper_norfair_rising_tide:
%cm_preset("Rising Tide", #preset_pkrd_upper_norfair_rising_tide)
presets_pkrd_upper_norfair_bubble_mountain:
%cm_preset("Bubble Mountain", #preset_pkrd_upper_norfair_bubble_mountain)
presets_pkrd_upper_norfair_bat_cave:
%cm_preset("Bat Cave", #preset_pkrd_upper_norfair_bat_cave)
presets_pkrd_upper_norfair_leaving_speedbooster:
%cm_preset("Leaving Speedbooster", #preset_pkrd_upper_norfair_leaving_speedbooster)
presets_pkrd_upper_norfair_single_chamber:
%cm_preset("Single Chamber", #preset_pkrd_upper_norfair_single_chamber)
presets_pkrd_upper_norfair_double_chamber:
%cm_preset("Double Chamber", #preset_pkrd_upper_norfair_double_chamber)
presets_pkrd_upper_norfair_double_chamber_revisited:
%cm_preset("Double Chamber Revisited", #preset_pkrd_upper_norfair_double_chamber_revisited)
presets_pkrd_upper_norfair_single_chamber_revisited:
%cm_preset("Single Chamber Revisited", #preset_pkrd_upper_norfair_single_chamber_revisited)
presets_pkrd_upper_norfair_volcano_room:
%cm_preset("Volcano Room", #preset_pkrd_upper_norfair_volcano_room)
presets_pkrd_upper_norfair_kronic_boost:
%cm_preset("Kronic Boost", #preset_pkrd_upper_norfair_kronic_boost)
presets_pkrd_upper_norfair_lava_spark:
%cm_preset("Lava Spark", #preset_pkrd_upper_norfair_lava_spark)
; Lower Norfair
presets_pkrd_lower_norfair_ln_main_hall:
%cm_preset("LN Main Hall", #preset_pkrd_lower_norfair_ln_main_hall)
presets_pkrd_lower_norfair_prepillars:
%cm_preset("Pre-Pillars", #preset_pkrd_lower_norfair_prepillars)
presets_pkrd_lower_norfair_worst_room_in_the_game:
%cm_preset("Worst Room in the Game", #preset_pkrd_lower_norfair_worst_room_in_the_game)
presets_pkrd_lower_norfair_amphitheatre:
%cm_preset("Amphitheatre", #preset_pkrd_lower_norfair_amphitheatre)
presets_pkrd_lower_norfair_kihunter_stairs_down:
%cm_preset("Kihunter Stairs Down", #preset_pkrd_lower_norfair_kihunter_stairs_down)
presets_pkrd_lower_norfair_wasteland:
%cm_preset("Wasteland", #preset_pkrd_lower_norfair_wasteland)
presets_pkrd_lower_norfair_metal_ninja_pirates:
%cm_preset("Metal Ninja Pirates", #preset_pkrd_lower_norfair_metal_ninja_pirates)
presets_pkrd_lower_norfair_plowerhouse:
%cm_preset("Plowerhouse", #preset_pkrd_lower_norfair_plowerhouse)
presets_pkrd_lower_norfair_ridley_farming_room:
%cm_preset("Ridley Farming Room", #preset_pkrd_lower_norfair_ridley_farming_room)
presets_pkrd_lower_norfair_ridley:
%cm_preset("Ridley", #preset_pkrd_lower_norfair_ridley)
presets_pkrd_lower_norfair_leaving_ridley:
%cm_preset("Leaving Ridley", #preset_pkrd_lower_norfair_leaving_ridley)
presets_pkrd_lower_norfair_reverse_plowerhouse:
%cm_preset("Reverse Plowerhouse", #preset_pkrd_lower_norfair_reverse_plowerhouse)
presets_pkrd_lower_norfair_wasteland_revisit:
%cm_preset("Wasteland Revisit", #preset_pkrd_lower_norfair_wasteland_revisit)
presets_pkrd_lower_norfair_kihunter_stairs_up:
%cm_preset("Kihunter Stairs Up", #preset_pkrd_lower_norfair_kihunter_stairs_up)
presets_pkrd_lower_norfair_fire_flea_room:
%cm_preset("Fire Flea Room", #preset_pkrd_lower_norfair_fire_flea_room)
presets_pkrd_lower_norfair_springball_maze:
%cm_preset("Springball Maze", #preset_pkrd_lower_norfair_springball_maze)
presets_pkrd_lower_norfair_three_musketeers:
%cm_preset("Three Musketeers", #preset_pkrd_lower_norfair_three_musketeers)
presets_pkrd_lower_norfair_single_chamber_final:
%cm_preset("Single Chamber Final", #preset_pkrd_lower_norfair_single_chamber_final)
presets_pkrd_lower_norfair_bubble_mountain_final:
%cm_preset("Bubble Mountain Final", #preset_pkrd_lower_norfair_bubble_mountain_final)
presets_pkrd_lower_norfair_frog_speedway:
%cm_preset("Frog Speedway", #preset_pkrd_lower_norfair_frog_speedway)
presets_pkrd_lower_norfair_business_center_final:
%cm_preset("Business Center Final", #preset_pkrd_lower_norfair_business_center_final)
; Maridia
presets_pkrd_maridia_maridia_tube_revisit:
%cm_preset("Maridia Tube Revisit", #preset_pkrd_maridia_maridia_tube_revisit)
presets_pkrd_maridia_fish_tank:
%cm_preset("Fish Tank", #preset_pkrd_maridia_fish_tank)
presets_pkrd_maridia_mt_everest:
%cm_preset("Mt Everest", #preset_pkrd_maridia_mt_everest)
presets_pkrd_maridia_crab_shaft:
%cm_preset("Crab Shaft", #preset_pkrd_maridia_crab_shaft)
presets_pkrd_maridia_botwoon_hallway:
%cm_preset("Botwoon Hallway", #preset_pkrd_maridia_botwoon_hallway)
presets_pkrd_maridia_botwoon:
%cm_preset("Botwoon", #preset_pkrd_maridia_botwoon)
presets_pkrd_maridia_botwoon_etank:
%cm_preset("Botwoon E-tank", #preset_pkrd_maridia_botwoon_etank)
presets_pkrd_maridia_halfie_setup:
%cm_preset("Halfie Setup", #preset_pkrd_maridia_halfie_setup)
presets_pkrd_maridia_draygon:
%cm_preset("Draygon", #preset_pkrd_maridia_draygon)
presets_pkrd_maridia_spikesuit_reverse_halfie:
%cm_preset("Spikesuit Reverse Halfie", #preset_pkrd_maridia_spikesuit_reverse_halfie)
presets_pkrd_maridia_reverse_colosseum:
%cm_preset("Reverse Colosseum", #preset_pkrd_maridia_reverse_colosseum)
presets_pkrd_maridia_reverse_halfie_climb:
%cm_preset("Reverse Halfie Climb", #preset_pkrd_maridia_reverse_halfie_climb)
presets_pkrd_maridia_reverse_botwoon_etank:
%cm_preset("Reverse Botwoon E-tank", #preset_pkrd_maridia_reverse_botwoon_etank)
presets_pkrd_maridia_reverse_botwoon_hallway:
%cm_preset("Reverse Botwoon Hallway", #preset_pkrd_maridia_reverse_botwoon_hallway)
presets_pkrd_maridia_reverse_crab_shaft:
%cm_preset("Reverse Crab Shaft", #preset_pkrd_maridia_reverse_crab_shaft)
presets_pkrd_maridia_mt_everest_revisit:
%cm_preset("Mt Everest Revisit", #preset_pkrd_maridia_mt_everest_revisit)
; Backtracking
presets_pkrd_backtracking_red_brinstar_green_gate:
%cm_preset("Red Brinstar Green Gate", #preset_pkrd_backtracking_red_brinstar_green_gate)
presets_pkrd_backtracking_crateria_kihunters_final:
%cm_preset("Crateria Kihunters Final", #preset_pkrd_backtracking_crateria_kihunters_final)
presets_pkrd_backtracking_parlor_return:
%cm_preset("Parlor Return", #preset_pkrd_backtracking_parlor_return)
presets_pkrd_backtracking_terminator_revisit:
%cm_preset("Terminator Revisit", #preset_pkrd_backtracking_terminator_revisit)
presets_pkrd_backtracking_green_pirate_shaft_revisit:
%cm_preset("Green Pirate Shaft Revisit", #preset_pkrd_backtracking_green_pirate_shaft_revisit)
presets_pkrd_backtracking_g4_hallway:
%cm_preset("G4 Hallway", #preset_pkrd_backtracking_g4_hallway)
presets_pkrd_backtracking_g4_elevator:
%cm_preset("G4 Elevator", #preset_pkrd_backtracking_g4_elevator)
; Tourian
presets_pkrd_tourian_tourian_elevator_room:
%cm_preset("Tourian Elevator Room", #preset_pkrd_tourian_tourian_elevator_room)
presets_pkrd_tourian_metroids_1:
%cm_preset("Metroids 1", #preset_pkrd_tourian_metroids_1)
presets_pkrd_tourian_metroids_2:
%cm_preset("Metroids 2", #preset_pkrd_tourian_metroids_2)
presets_pkrd_tourian_metroids_3:
%cm_preset("Metroids 3", #preset_pkrd_tourian_metroids_3)
presets_pkrd_tourian_metroids_4:
%cm_preset("Metroids 4", #preset_pkrd_tourian_metroids_4)
presets_pkrd_tourian_giant_hoppers:
%cm_preset("Giant Hoppers", #preset_pkrd_tourian_giant_hoppers)
presets_pkrd_tourian_baby_skip:
%cm_preset("Baby Skip", #preset_pkrd_tourian_baby_skip)
presets_pkrd_tourian_gadora_room:
%cm_preset("Gadora Room", #preset_pkrd_tourian_gadora_room)
presets_pkrd_tourian_rinka_shaft:
%cm_preset("Rinka Shaft", #preset_pkrd_tourian_rinka_shaft)
presets_pkrd_tourian_zeb_skip:
%cm_preset("Zeb Skip", #preset_pkrd_tourian_zeb_skip)
presets_pkrd_tourian_mother_brain_2:
%cm_preset("Mother Brain 2", #preset_pkrd_tourian_mother_brain_2)
presets_pkrd_tourian_mother_brain_3:
%cm_preset("Mother Brain 3", #preset_pkrd_tourian_mother_brain_3)
presets_pkrd_tourian_zebes_escape:
%cm_preset("Zebes Escape", #preset_pkrd_tourian_zebes_escape)
presets_pkrd_tourian_escape_room_3:
%cm_preset("Escape Room 3", #preset_pkrd_tourian_escape_room_3)
presets_pkrd_tourian_escape_room_4:
%cm_preset("Escape Room 4", #preset_pkrd_tourian_escape_room_4)
presets_pkrd_tourian_escape_climb:
%cm_preset("Escape Climb", #preset_pkrd_tourian_escape_climb)
presets_pkrd_tourian_escape_parlor:
%cm_preset("Escape Parlor", #preset_pkrd_tourian_escape_parlor)
|
; double __CALLEE__ scalbn(double x, int n)
SECTION code_fp_math48
PUBLIC cm48_sccz80_scalbn_callee
EXTERN am48_scalbn
cm48_sccz80_scalbn_callee:
pop af
pop hl ; hl = n
exx
pop hl ; AC'= x
pop de
pop bc
exx
push af
jp am48_scalbn
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r14
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_UC_ht+0x114f6, %rsi
lea addresses_A_ht+0x15a76, %rdi
clflush (%rdi)
nop
nop
nop
nop
nop
inc %rbx
mov $19, %rcx
rep movsb
nop
nop
nop
add %rcx, %rcx
lea addresses_WT_ht+0x1a486, %rbx
nop
nop
nop
nop
lfence
mov $0x6162636465666768, %rax
movq %rax, %xmm5
vmovups %ymm5, (%rbx)
inc %rbx
lea addresses_WC_ht+0x15926, %rdi
nop
nop
nop
nop
nop
cmp $63086, %r14
mov $0x6162636465666768, %rcx
movq %rcx, %xmm0
movups %xmm0, (%rdi)
nop
cmp $28431, %rcx
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r14
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %rax
push %rbp
push %rdx
push %rsi
// Faulty Load
lea addresses_WT+0x14126, %rsi
clflush (%rsi)
nop
nop
nop
nop
nop
sub %rbp, %rbp
mov (%rsi), %r10
lea oracles, %rdx
and $0xff, %r10
shlq $12, %r10
mov (%rdx,%r10,1), %r10
pop %rsi
pop %rdx
pop %rbp
pop %rax
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WT', 'NT': True, 'AVXalign': False, 'size': 1, 'congruent': 0}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_WT', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_A_ht'}}
{'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 4}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 10}}
{'39': 21829}
39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39 39
*/
|
; A200887: Number of 0..n arrays x(0..3) of 4 elements without any interior element greater than both neighbors.
; 12,51,144,325,636,1127,1856,2889,4300,6171,8592,11661,15484,20175,25856,32657,40716,50179,61200,73941,88572,105271,124224,145625,169676,196587,226576,259869,296700,337311,381952,430881,484364,542675,606096,674917,749436,829959,916800,1010281,1110732,1218491,1333904,1457325,1589116,1729647,1879296,2038449,2207500,2386851,2576912,2778101,2990844,3215575,3452736,3702777,3966156,4243339,4534800,4841021,5162492,5499711,5853184,6223425,6610956,7016307,7440016,7882629,8344700,8826791,9329472,9853321
add $0,2
mov $1,3
add $1,$0
mul $1,$0
sub $1,1
mul $1,$0
mul $0,$1
div $0,3
|
.global s_prepare_buffers
s_prepare_buffers:
push %r11
push %r12
push %r14
push %r9
push %rax
push %rbx
push %rcx
push %rdi
push %rsi
lea addresses_normal_ht+0x1bb66, %r14
nop
nop
nop
nop
nop
cmp %r9, %r9
mov (%r14), %bx
dec %rcx
lea addresses_A_ht+0x8e68, %r11
nop
nop
inc %r12
mov $0x6162636465666768, %r9
movq %r9, %xmm7
vmovups %ymm7, (%r11)
nop
sub %rcx, %rcx
lea addresses_normal_ht+0x1ec68, %r9
nop
sub $48289, %rax
movups (%r9), %xmm5
vpextrq $0, %xmm5, %rbx
dec %rbx
lea addresses_UC_ht+0x17c68, %r14
dec %rbx
movw $0x6162, (%r14)
nop
nop
nop
dec %rcx
lea addresses_D_ht+0x175dc, %r9
nop
cmp %r14, %r14
vmovups (%r9), %ymm6
vextracti128 $1, %ymm6, %xmm6
vpextrq $0, %xmm6, %rax
nop
nop
nop
xor $58637, %r12
lea addresses_D_ht+0x1e5d8, %rax
nop
nop
and $38335, %rbx
movb $0x61, (%rax)
nop
nop
inc %rbx
lea addresses_normal_ht+0x1be68, %rsi
lea addresses_D_ht+0x186e8, %rdi
nop
nop
nop
dec %rax
mov $50, %rcx
rep movsq
nop
nop
nop
nop
cmp $4235, %r11
lea addresses_WT_ht+0x10868, %r9
nop
nop
nop
and $36889, %rbx
movl $0x61626364, (%r9)
nop
cmp %r9, %r9
lea addresses_D_ht+0x19568, %rsi
lea addresses_WC_ht+0x12118, %rdi
nop
nop
nop
nop
nop
dec %r11
mov $112, %rcx
rep movsq
nop
nop
nop
nop
and $35876, %rax
lea addresses_UC_ht+0xb980, %rsi
nop
and $21825, %rcx
mov (%rsi), %r12d
nop
nop
nop
nop
and $39582, %r12
pop %rsi
pop %rdi
pop %rcx
pop %rbx
pop %rax
pop %r9
pop %r14
pop %r12
pop %r11
ret
.global s_faulty_load
s_faulty_load:
push %r10
push %r13
push %r14
push %r8
push %r9
push %rax
push %rsi
// Store
lea addresses_D+0x2768, %r14
clflush (%r14)
nop
nop
nop
sub %r13, %r13
mov $0x5152535455565758, %r8
movq %r8, %xmm1
movntdq %xmm1, (%r14)
nop
nop
nop
cmp $56825, %r14
// Load
lea addresses_A+0x7d38, %rsi
nop
nop
nop
nop
nop
cmp %r10, %r10
movups (%rsi), %xmm5
vpextrq $0, %xmm5, %r13
nop
cmp $37265, %r14
// Store
lea addresses_A+0x19152, %r8
nop
nop
nop
cmp $19142, %r9
movb $0x51, (%r8)
nop
nop
nop
nop
xor $49326, %r8
// Store
lea addresses_US+0x183f4, %r14
nop
nop
nop
nop
cmp $39370, %r8
movb $0x51, (%r14)
nop
nop
nop
xor $13372, %r13
// Load
mov $0x3994040000000668, %r14
nop
nop
nop
nop
xor %r9, %r9
mov (%r14), %esi
nop
and %rsi, %rsi
// Store
lea addresses_RW+0x5a68, %r10
nop
nop
nop
sub %rsi, %rsi
mov $0x5152535455565758, %r13
movq %r13, %xmm1
vmovups %ymm1, (%r10)
inc %r9
// Store
lea addresses_US+0x18668, %rax
nop
nop
nop
nop
cmp %r10, %r10
movb $0x51, (%rax)
nop
xor $30675, %r10
// Faulty Load
mov $0x3994040000000668, %r10
nop
nop
and %r8, %r8
mov (%r10), %r14
lea oracles, %r9
and $0xff, %r14
shlq $12, %r14
mov (%r9,%r14,1), %r14
pop %rsi
pop %rax
pop %r9
pop %r8
pop %r14
pop %r13
pop %r10
ret
/*
<gen_faulty_load>
[REF]
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D', 'NT': True, 'AVXalign': False, 'size': 16, 'congruent': 8}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 3}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 1}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 2}}
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_RW', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 9}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_US', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 11}}
[Faulty Load]
{'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}}
<gen_prepare_buffer>
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}}
{'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 10}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 9}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_UC_ht', 'NT': True, 'AVXalign': False, 'size': 2, 'congruent': 9}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 2}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 3}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 7, 'type': 'addresses_D_ht'}}
{'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 9}}
{'OP': 'REPM', 'src': {'same': False, 'congruent': 8, 'type': 'addresses_D_ht'}, 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_WC_ht'}}
{'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 1}}
{'51': 384, '00': 1033}
51 00 51 00 00 51 51 00 00 51 51 00 00 00 00 51 00 51 51 00 51 51 00 00 00 00 00 00 00 51 51 00 51 00 51 51 00 00 00 51 00 51 51 51 51 51 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 51 51 51 00 00 00 00 00 00 51 00 00 00 51 00 51 00 51 51 00 00 51 51 00 00 00 51 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 51 00 00 51 00 00 00 00 00 00 51 00 51 51 00 51 00 00 51 51 00 51 00 51 00 00 00 00 00 00 00 00 00 00 00 51 00 00 51 51 00 00 00 51 51 00 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 51 51 51 00 51 00 51 00 51 00 51 00 51 51 00 51 00 00 00 51 51 51 00 51 00 51 00 00 00 00 00 00 51 00 00 00 00 51 51 00 00 00 51 00 00 00 00 00 00 51 51 00 00 51 00 00 00 00 51 51 00 00 51 00 00 00 00 51 51 51 51 00 00 00 00 00 00 00 00 00 00 00 00 00 51 51 00 00 51 51 00 00 00 00 00 00 00 00 00 51 51 51 51 51 00 00 00 51 00 00 00 51 00 51 00 00 00 51 51 00 00 00 00 51 00 51 51 00 00 00 00 51 51 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 51 51 00 00 00 00 51 51 51 00 00 00 00 00 00 00 00 00 00 00 51 00 00 51 51 00 00 00 00 00 51 00 00 51 51 51 51 51 51 00 00 00 00 00 51 51 51 51 00 00 00 00 00 00 51 51 51 51 00 00 00 00 00 51 00 51 00 00 00 51 51 51 00 00 00 00 00 00 00 00 51 00 51 51 00 00 51 00 00 00 51 00 00 51 00 00 51 00 00 00 00 00 00 00 00 51 00 00 51 00 51 51 51 00 00 00 00 00 00 51 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 51 51 51 51 00 00 00 51 00 00 00 00 00 00 00 00 51 00 51 00 00 00 00 51 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 51 51 00 51 00 00 00 00 51 00 00 00 00 00 00 51 51 00 00 00 00 51 00 51 00 51 00 00 51 51 51 00 51 51 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 00 00 51 00 00 00 00 00 00 00 51 00 00 00 00 00 51 51 00 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 51 00 00 00 00 00 00 00 00 00 00 51 51 00 00 51 51 51 00 51 51 00 00 51 00 51 00 51 00 00 00 00 00 00 00 51 51 00 00 00 51 51 51 00 00 00 00 00 51 00 00 00 00 00 51 51 00 51 00 00 00 51 51 00 00 00 51 00 00 00 51 00 00 00 51 51 51 00 00 00 51 51 00 00 51 00 00 00 00 00 51 00 00 51 00 51 00 00 00 51 51 00 00 00 00 00 00 51 00 00 51 51 00 00 00 00 51 00 51 00 51 00 00 51 51 51 51 00 00 00 00 51 00 51 00 00 00 00 51 00 00 51 00 51 00 00 00 51 00 51 51 00 51 00 00 00 00 00 00 51 00 00 00 00 00 00 00 51 00 00 00 00 51 00 51 00 00 00 00 00 51 00 00 00 51 00 51 00 00 00 51 51 00 00 00 51 51 51 00 00 51 51 00 00 51 00 51 00 00 00 00 00 00 00 00 00 51 00 51 00 00 51 51 51 00 00 00 51 51 51 00 51 00 00 00 00 51 51 51 51 51 00 00 00 00 00 00 00 51 00 00 00 51 00 00 00 00 00 51 00 00 51 00 00 00 00 51 00 00 00 51 51 00 00 00 00 00 00 00 00 00 00 51 00 00 51 00 00 51 00 00 51 00 51 00 00 00 00 51 00 00 00 00 00 00 51 00 00 00 00 00 51 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 00 00 00 51 00 00 51 51 00 00 00 00 00 00 00 51 00 00 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 51 51 51 51 00 00
*/
|
<%
import collections
import pwnlib.abi
import pwnlib.constants
import pwnlib.shellcraft
import six
%>
<%docstring>socketcall_setsockopt(vararg_0, vararg_1, vararg_2, vararg_3, vararg_4) -> str
Invokes the syscall socketcall_setsockopt.
See 'man 2 socketcall_setsockopt' for more information.
Arguments:
vararg(int): vararg
Returns:
long
</%docstring>
<%page args="vararg_0=None, vararg_1=None, vararg_2=None, vararg_3=None, vararg_4=None"/>
<%
abi = pwnlib.abi.ABI.syscall()
stack = abi.stack
regs = abi.register_arguments[1:]
allregs = pwnlib.shellcraft.registers.current()
can_pushstr = []
can_pushstr_array = []
argument_names = ['vararg_0', 'vararg_1', 'vararg_2', 'vararg_3', 'vararg_4']
argument_values = [vararg_0, vararg_1, vararg_2, vararg_3, vararg_4]
# Load all of the arguments into their destination registers / stack slots.
register_arguments = dict()
stack_arguments = collections.OrderedDict()
string_arguments = dict()
dict_arguments = dict()
array_arguments = dict()
syscall_repr = []
for name, arg in zip(argument_names, argument_values):
if arg is not None:
syscall_repr.append('%s=%r' % (name, arg))
# If the argument itself (input) is a register...
if arg in allregs:
index = argument_names.index(name)
if index < len(regs):
target = regs[index]
register_arguments[target] = arg
elif arg is not None:
stack_arguments[index] = arg
# The argument is not a register. It is a string value, and we
# are expecting a string value
elif name in can_pushstr and isinstance(arg, (six.binary_type, six.text_type)):
if isinstance(arg, six.text_type):
arg = arg.encode('utf-8')
string_arguments[name] = arg
# The argument is not a register. It is a dictionary, and we are
# expecting K:V paris.
elif name in can_pushstr_array and isinstance(arg, dict):
array_arguments[name] = ['%s=%s' % (k,v) for (k,v) in arg.items()]
# The arguent is not a register. It is a list, and we are expecting
# a list of arguments.
elif name in can_pushstr_array and isinstance(arg, (list, tuple)):
array_arguments[name] = arg
# The argument is not a register, string, dict, or list.
# It could be a constant string ('O_RDONLY') for an integer argument,
# an actual integer value, or a constant.
else:
index = argument_names.index(name)
if index < len(regs):
target = regs[index]
register_arguments[target] = arg
elif arg is not None:
stack_arguments[target] = arg
# Some syscalls have different names on various architectures.
# Determine which syscall number to use for the current architecture.
for syscall in ['SYS_socketcall_setsockopt']:
if hasattr(pwnlib.constants, syscall):
break
else:
raise Exception("Could not locate any syscalls: %r" % syscalls)
%>
/* socketcall_setsockopt(${', '.join(syscall_repr)}) */
%for name, arg in string_arguments.items():
${pwnlib.shellcraft.pushstr(arg, append_null=(b'\x00' not in arg))}
${pwnlib.shellcraft.mov(regs[argument_names.index(name)], abi.stack)}
%endfor
%for name, arg in array_arguments.items():
${pwnlib.shellcraft.pushstr_array(regs[argument_names.index(name)], arg)}
%endfor
%for name, arg in stack_arguments.items():
${pwnlib.shellcraft.push(arg)}
%endfor
${pwnlib.shellcraft.setregs(register_arguments)}
${pwnlib.shellcraft.syscall(syscall)} |
; A129343: a(2n) = a(n), a(2n+1) = 4n+1.
; 0,1,1,5,1,9,5,13,1,17,9,21,5,25,13,29,1,33,17,37,9,41,21,45,5,49,25,53,13,57,29,61,1,65,33,69,17,73,37,77,9,81,41,85,21,89,45,93,5,97,49,101,25,105,53,109,13,113,57,117,29,121,61,125,1,129,65,133,33,137
mul $0,2
mov $1,1
lpb $0
mov $1,$0
dif $0,2
lpe
sub $1,1
|
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you 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 "olap/rowset/column_data.h"
#include "olap/rowset/segment_reader.h"
#include "olap/olap_cond.h"
#include "olap/row_block.h"
#include "olap/storage_engine.h"
namespace doris {
ColumnData* ColumnData::create(SegmentGroup* segment_group) {
ColumnData* data = new(std::nothrow) ColumnData(segment_group);
return data;
}
ColumnData::ColumnData(SegmentGroup* segment_group)
: _segment_group(segment_group),
_eof(false),
_conditions(nullptr),
_col_predicates(nullptr),
_delete_status(DEL_NOT_SATISFIED),
_runtime_state(nullptr),
_schema(segment_group->get_tablet_schema()),
_is_using_cache(false),
_segment_reader(nullptr),
_lru_cache(nullptr) {
if (StorageEngine::instance() != nullptr) {
_lru_cache = StorageEngine::instance()->index_stream_lru_cache();
} else {
// for independent usage, eg: unit test/segment tool
_lru_cache = FileHandler::get_fd_cache();
}
_num_rows_per_block = _segment_group->get_num_rows_per_row_block();
}
ColumnData::~ColumnData() {
_segment_group->release();
SAFE_DELETE(_segment_reader);
}
OLAPStatus ColumnData::init() {
_segment_group->acquire();
auto res = _short_key_cursor.init(_segment_group->short_key_columns());
if (res != OLAP_SUCCESS) {
LOG(WARNING) << "key cursor init failed, res:" << res;
return res;
}
return res;
}
OLAPStatus ColumnData::get_next_block(RowBlock** row_block) {
SCOPED_RAW_TIMER(&_stats->block_fetch_ns);
_is_normal_read = true;
auto res = _get_block(false);
if (res != OLAP_SUCCESS) {
if (res != OLAP_ERR_DATA_EOF) {
LOG(WARNING) << "Get next block failed.";
}
*row_block = nullptr;
return res;
}
*row_block = _read_block.get();
return OLAP_SUCCESS;
}
OLAPStatus ColumnData::_next_row(const RowCursor** row, bool without_filter) {
_read_block->pos_inc();
do {
if (_read_block->has_remaining()) {
// 1. get one row for vectorized_row_batch
size_t pos = _read_block->pos();
_read_block->get_row(pos, &_cursor);
if (without_filter) {
*row = &_cursor;
return OLAP_SUCCESS;
}
// when without_filter is true, _include_blocks is nullptr
if (_read_block->block_status() == DEL_NOT_SATISFIED) {
*row = &_cursor;
return OLAP_SUCCESS;
} else {
DCHECK(_read_block->block_status() == DEL_PARTIAL_SATISFIED);
bool row_del_filter = _delete_handler->is_filter_data(
_segment_group->version().second, _cursor);
if (!row_del_filter) {
*row = &_cursor;
return OLAP_SUCCESS;
}
// This row is filtered, continue to process next row
_stats->rows_del_filtered++;
_read_block->pos_inc();
}
} else {
// get_next_block
auto res = _get_block(without_filter);
if (res != OLAP_SUCCESS) {
return res;
}
}
} while (true);
return OLAP_SUCCESS;
}
OLAPStatus ColumnData::_seek_to_block(const RowBlockPosition& block_pos, bool without_filter) {
// TODO(zc): _segment_readers???
// open segment reader if needed
if (_segment_reader == nullptr || block_pos.segment != _current_segment) {
if (block_pos.segment >= _segment_group->num_segments() ||
(_end_key_is_set && block_pos.segment > _end_segment)) {
_eof = true;
return OLAP_ERR_DATA_EOF;
}
SAFE_DELETE(_segment_reader);
std::string file_name;
file_name = segment_group()->construct_data_file_path(block_pos.segment);
_segment_reader = new(std::nothrow) SegmentReader(
file_name, segment_group(), block_pos.segment,
_seek_columns, _load_bf_columns, _conditions,
_delete_handler, _delete_status, _lru_cache, _runtime_state, _stats);
if (_segment_reader == nullptr) {
OLAP_LOG_WARNING("fail to malloc segment reader.");
return OLAP_ERR_MALLOC_ERROR;
}
_current_segment = block_pos.segment;
auto res = _segment_reader->init(_is_using_cache);
if (OLAP_SUCCESS != res) {
OLAP_LOG_WARNING("fail to init segment reader. [res=%d]", res);
return res;
}
}
uint32_t end_block;
if (_end_key_is_set && block_pos.segment == _end_segment) {
end_block = _end_block;
} else {
end_block = _segment_reader->block_count() - 1;
}
VLOG(3) << "seek from " << block_pos.data_offset << " to " << end_block;
return _segment_reader->seek_to_block(
block_pos.data_offset, end_block, without_filter, &_next_block, &_segment_eof);
}
OLAPStatus ColumnData::_find_position_by_short_key(
const RowCursor& key, bool find_last_key, RowBlockPosition *position) {
RowBlockPosition tmp_pos;
auto res = _segment_group->find_short_key(key, &_short_key_cursor, find_last_key, &tmp_pos);
if (res != OLAP_SUCCESS) {
if (res == OLAP_ERR_INDEX_EOF) {
res = OLAP_ERR_DATA_EOF;
} else {
OLAP_LOG_WARNING("find row block failed. [res=%d]", res);
}
return res;
}
res = segment_group()->find_prev_point(tmp_pos, position);
if (res != OLAP_SUCCESS) {
OLAP_LOG_WARNING("find prev row block failed. [res=%d]", res);
return res;
}
return OLAP_SUCCESS;
}
OLAPStatus ColumnData::_find_position_by_full_key(
const RowCursor& key, bool find_last_key, RowBlockPosition *position) {
RowBlockPosition tmp_pos;
auto res = _segment_group->find_short_key(key, &_short_key_cursor, false, &tmp_pos);
if (res != OLAP_SUCCESS) {
if (res == OLAP_ERR_INDEX_EOF) {
res = OLAP_ERR_DATA_EOF;
} else {
OLAP_LOG_WARNING("find row block failed. [res=%d]", res);
}
return res;
}
RowBlockPosition start_position;
res = segment_group()->find_prev_point(tmp_pos, &start_position);
if (res != OLAP_SUCCESS) {
OLAP_LOG_WARNING("find prev row block failed. [res=%d]", res);
return res;
}
RowBlockPosition end_position;
res = _segment_group->find_short_key(key, &_short_key_cursor, true, &end_position);
if (res != OLAP_SUCCESS) {
if (res == OLAP_ERR_INDEX_EOF) {
res = OLAP_ERR_DATA_EOF;
} else {
OLAP_LOG_WARNING("find row block failed. [res=%d]", res);
}
return res;
}
// choose min value of end_position and m_end_key_block_position as real end_position
if (_end_key_is_set) {
RowBlockPosition end_key_position;
end_key_position.segment = _end_segment;
end_key_position.data_offset = _end_block;
if (end_position > end_key_position) {
OLAPIndexOffset index_offset;
index_offset.segment = _end_segment;
index_offset.offset = _end_block;
res = segment_group()->get_row_block_position(index_offset, &end_position);
if (res != OLAP_SUCCESS) {
OLAP_LOG_WARNING("fail to get row block position. [res=%d]", res);
return res;
}
}
}
// ????end_position
uint32_t distance = segment_group()->compute_distance(start_position, end_position);
BinarySearchIterator it_start(0u);
BinarySearchIterator it_end(distance + 1);
BinarySearchIterator it_result(0u);
ColumnDataComparator comparator(
start_position,
this,
segment_group());
try {
if (!find_last_key) {
it_result = std::lower_bound(it_start, it_end, key, comparator);
} else {
it_result = std::upper_bound(it_start, it_end, key, comparator);
}
VLOG(3) << "get result iterator. offset=" << *it_result
<< ", start_pos=" << start_position.to_string();
} catch (std::exception& e) {
LOG(WARNING) << "exception happens when doing seek. exception=" << e.what();
return OLAP_ERR_STL_ERROR;
}
if (*it_result != *it_start) {
it_result -= 1;
}
if (OLAP_SUCCESS != (res = segment_group()->advance_row_block(*it_result,
&start_position))) {
OLAP_LOG_WARNING("fail to advance row_block. [res=%d it_offset=%u "
"start_pos='%s']", res, *it_result,
start_position.to_string().c_str());
return res;
}
if (_end_key_is_set) {
RowBlockPosition end_key_position;
end_key_position.segment = _end_segment;
end_key_position.data_offset = _end_block;
if (end_position > end_key_position) {
return OLAP_ERR_DATA_EOF;
}
}
*position = start_position;
return OLAP_SUCCESS;
}
OLAPStatus ColumnData::_seek_to_row(const RowCursor& key, bool find_last_key, bool is_end_key) {
RowBlockPosition position;
OLAPStatus res = OLAP_SUCCESS;
const TabletSchema& tablet_schema = _segment_group->get_tablet_schema();
FieldType type = tablet_schema.column(key.field_count() - 1).type();
if (key.field_count() > _segment_group->get_num_short_key_columns() || OLAP_FIELD_TYPE_VARCHAR == type) {
res = _find_position_by_full_key(key, find_last_key, &position);
} else {
res = _find_position_by_short_key(key, find_last_key, &position);
}
if (res != OLAP_SUCCESS) {
if (res != OLAP_ERR_DATA_EOF) {
LOG(WARNING) << "Fail to find the key.[res=" << res << " key=" << key.to_string()
<< " find_last_key=" << find_last_key << "]";
}
return res;
}
bool without_filter = is_end_key;
res = _seek_to_block(position, without_filter);
if (res != OLAP_SUCCESS) {
OLAP_LOG_WARNING("fail to get row block. "
"[res=%d segment=%d block_size=%d data_offset=%d index_offset=%d]",
res,
position.segment, position.block_size,
position.data_offset, position.index_offset);
return res;
}
res = _get_block(without_filter);
if (res != OLAP_SUCCESS) {
if (res != OLAP_ERR_DATA_EOF) {
LOG(WARNING) << "Fail to find the key.[res=" << res
<< " key=" << key.to_string() << " find_last_key=" << find_last_key << "]";
}
return res;
}
const RowCursor* row_cursor = _current_row();
if (!find_last_key) {
// 不找last key。 那么应该返回大于等于这个key的第一个,也就是
// row_cursor >= key
// 此处比较2个block的行数,是存在一种极限情况:若未找到满足的block,
// Index模块会返回倒数第二个block,此时key可能是最后一个block的最后一行
while (res == OLAP_SUCCESS && compare_row_key(*row_cursor, key) < 0) {
res = _next_row(&row_cursor, without_filter);
}
} else {
// 找last key。返回大于这个key的第一个。也就是
// row_cursor > key
while (res == OLAP_SUCCESS && compare_row_key(*row_cursor,key) <= 0) {
res = _next_row(&row_cursor, without_filter);
}
}
return res;
}
const RowCursor* ColumnData::seek_and_get_current_row(const RowBlockPosition& position) {
auto res = _seek_to_block(position, true);
if (res != OLAP_SUCCESS) {
LOG(WARNING) << "Fail to seek to block in seek_and_get_current_row, res=" << res
<< ", segment:" << position.segment << ", block:" << position.data_offset;
return nullptr;
}
res = _get_block(true, 1);
if (res != OLAP_SUCCESS) {
LOG(WARNING) << "Fail to get block in seek_and_get_current_row, res=" << res
<< ", segment:" << position.segment << ", block:" << position.data_offset;
return nullptr;
}
return _current_row();
}
OLAPStatus ColumnData::prepare_block_read(
const RowCursor* start_key, bool find_start_key,
const RowCursor* end_key, bool find_end_key,
RowBlock** first_block) {
SCOPED_RAW_TIMER(&_stats->block_fetch_ns);
set_eof(false);
_end_key_is_set = false;
_is_normal_read = false;
// set end position
if (end_key != nullptr) {
auto res = _seek_to_row(*end_key, find_end_key, true);
if (res == OLAP_SUCCESS) {
// we find a
_end_segment = _current_segment;
_end_block = _current_block;
_end_row_index = _read_block->pos();
_end_key_is_set = true;
} else if (res != OLAP_ERR_DATA_EOF) {
LOG(WARNING) << "Find end key failed.key=" << end_key->to_string();
return res;
}
// res == OLAP_ERR_DATA_EOF means there is no end key, then we read to
// the end of this ColumnData
}
set_eof(false);
if (start_key != nullptr) {
auto res = _seek_to_row(*start_key, !find_start_key, false);
if (res == OLAP_SUCCESS) {
*first_block = _read_block.get();
} else if (res == OLAP_ERR_DATA_EOF) {
_eof = true;
*first_block = nullptr;
return res;
} else {
LOG(WARNING) << "start_key can't be found.key=" << start_key->to_string();
return res;
}
} else {
// This is used to
_is_normal_read = true;
RowBlockPosition pos;
pos.segment = 0u;
pos.data_offset = 0u;
auto res = _seek_to_block(pos, false);
if (res != OLAP_SUCCESS) {
LOG(WARNING) << "failed to seek to block in, res=" << res
<< ", segment:" << pos.segment << ", block:" << pos.data_offset;
return res;
}
res = _get_block(false);
if (res != OLAP_SUCCESS) {
LOG(WARNING) << "failed to get block in , res=" << res
<< ", segment:" << pos.segment << ", block:" << pos.data_offset;
return res;
}
*first_block = _read_block.get();
}
return OLAP_SUCCESS;
}
// ColumnData向上返回的列至少由几部分组成:
// 1. return_columns中要求返回的列,即Fetch命令中指定要查询的列.
// 2. condition中涉及的列, 绝大多数情况下这些列都已经在return_columns中.
// 在这个函数里,合并上述几种情况
void ColumnData::set_read_params(
const std::vector<uint32_t>& return_columns,
const std::vector<uint32_t>& seek_columns,
const std::set<uint32_t>& load_bf_columns,
const Conditions& conditions,
const std::vector<ColumnPredicate*>& col_predicates,
bool is_using_cache,
RuntimeState* runtime_state) {
_conditions = &conditions;
_col_predicates = &col_predicates;
_need_eval_predicates = !col_predicates.empty();
_is_using_cache = is_using_cache;
_runtime_state = runtime_state;
_return_columns = return_columns;
_seek_columns = seek_columns;
_load_bf_columns = load_bf_columns;
auto res = _cursor.init(_segment_group->get_tablet_schema(), _seek_columns);
if (res != OLAP_SUCCESS) {
LOG(WARNING) << "fail to init row_cursor";
}
_read_vector_batch.reset(new VectorizedRowBatch(
&(_segment_group->get_tablet_schema()), _return_columns, _num_rows_per_block));
_seek_vector_batch.reset(new VectorizedRowBatch(
&(_segment_group->get_tablet_schema()), _seek_columns, _num_rows_per_block));
_read_block.reset(new RowBlock(&(_segment_group->get_tablet_schema())));
RowBlockInfo block_info;
block_info.row_num = _num_rows_per_block;
block_info.null_supported = true;
block_info.column_ids = _seek_columns;
_read_block->init(block_info);
}
OLAPStatus ColumnData::get_first_row_block(RowBlock** row_block) {
DCHECK(!_end_key_is_set) << "end key is set while use block interface.";
_is_normal_read = true;
_eof = false;
// to be same with OLAPData, we use segment_group.
RowBlockPosition block_pos;
OLAPStatus res = segment_group()->find_first_row_block(&block_pos);
if (res != OLAP_SUCCESS) {
if (res == OLAP_ERR_INDEX_EOF) {
*row_block = nullptr;
_eof = true;
return res;
}
OLAP_LOG_WARNING("fail to find first row block with SegmentGroup.");
return res;
}
res = _seek_to_block(block_pos, false);
if (res != OLAP_SUCCESS) {
if (res != OLAP_ERR_DATA_EOF) {
OLAP_LOG_WARNING("seek to block fail. [res=%d]", res);
}
*row_block = nullptr;
return res;
}
res = _get_block(false);
if (res != OLAP_SUCCESS) {
if (res != OLAP_ERR_DATA_EOF) {
LOG(WARNING) << "fail to load data to row block. res=" << res
<< ", version=" << version().first
<< "-" << version().second;
}
*row_block = nullptr;
return res;
}
*row_block = _read_block.get();
return OLAP_SUCCESS;
}
bool ColumnData::rowset_pruning_filter() {
if (empty() || zero_num_rows()) {
return true;
}
if (!_segment_group->has_zone_maps()) {
return false;
}
return _conditions->rowset_pruning_filter(_segment_group->get_zone_maps());
}
int ColumnData::delete_pruning_filter() {
if (empty() || zero_num_rows()) {
// should return DEL_NOT_SATISFIED, because that when creating rollup tablet,
// the delete version file should preserved for filter data.
return DEL_NOT_SATISFIED;
}
int num_zone_maps = _schema.keys_type() == KeysType::DUP_KEYS ? _schema.num_columns() : _schema.num_key_columns();
// _segment_group->get_zone_maps().size() < num_zone_maps for a table is schema changed from older version that not support
// generate zone map for duplicated mode value column, using DEL_PARTIAL_SATISFIED
if (!_segment_group->has_zone_maps() || _segment_group->get_zone_maps().size() < num_zone_maps) {
/*
* if segment_group has no column statistics, we cannot judge whether the data can be filtered or not
*/
return DEL_PARTIAL_SATISFIED;
}
/*
* the relationship between delete condition A and B is A || B.
* if any delete condition is satisfied, the data can be filtered.
* elseif all delete condition is not satifsified, the data can't be filtered.
* else is the partial satisfied.
*/
int ret = DEL_PARTIAL_SATISFIED;
bool del_partial_stastified = false;
bool del_stastified = false;
for (auto& delete_condtion : _delete_handler->get_delete_conditions()) {
if (delete_condtion.filter_version <= _segment_group->version().first) {
continue;
}
Conditions* del_cond = delete_condtion.del_cond;
int del_ret = del_cond->delete_pruning_filter(_segment_group->get_zone_maps());
if (DEL_SATISFIED == del_ret) {
del_stastified = true;
break;
} else if (DEL_PARTIAL_SATISFIED == del_ret) {
del_partial_stastified = true;
} else {
continue;
}
}
if (del_stastified) {
ret = DEL_SATISFIED;
} else if (del_partial_stastified) {
ret = DEL_PARTIAL_SATISFIED;
} else {
ret = DEL_NOT_SATISFIED;
}
return ret;
}
uint64_t ColumnData::get_filted_rows() {
return _stats->rows_del_filtered;
}
OLAPStatus ColumnData::schema_change_init() {
_is_using_cache = false;
for (int i = 0; i < _segment_group->get_tablet_schema().num_columns(); ++i) {
_return_columns.push_back(i);
_seek_columns.push_back(i);
}
auto res = _cursor.init(_segment_group->get_tablet_schema());
if (res != OLAP_SUCCESS) {
OLAP_LOG_WARNING("fail to init row_cursor");
return res;
}
_read_vector_batch.reset(new VectorizedRowBatch(
&(_segment_group->get_tablet_schema()), _return_columns, _num_rows_per_block));
_read_block.reset(new RowBlock(&(_segment_group->get_tablet_schema())));
RowBlockInfo block_info;
block_info.row_num = _num_rows_per_block;
block_info.null_supported = true;
_read_block->init(block_info);
return OLAP_SUCCESS;
}
OLAPStatus ColumnData::_get_block_from_reader(
VectorizedRowBatch** got_batch, bool without_filter, int rows_read) {
VectorizedRowBatch* vec_batch = nullptr;
if (_is_normal_read) {
vec_batch = _read_vector_batch.get();
} else {
vec_batch = _seek_vector_batch.get();
}
// If this is normal read
do {
#if 0
LOG(INFO) << "_current_segment is " << _current_segment
<< ", _next_block:" << _next_block
<< ", _end_segment::" << _end_segment
<< ", _end_block:" << _end_block
<< ", _end_row_index:" << _end_row_index
<< ", _segment_eof:" << _segment_eof;
#endif
vec_batch->clear();
if (rows_read > 0) {
vec_batch->set_limit(rows_read);
}
// If we are going to read last block, we need to set batch limit to the end of key
// if without_filter is true and _end_key_is_set is true, this must seek to start row's
// block, we must load the entire block.
if (OLAP_UNLIKELY(!without_filter &&
_end_key_is_set &&
_next_block == _end_block &&
_current_segment == _end_segment)) {
vec_batch->set_limit(_end_row_index);
if (_end_row_index == 0) {
_segment_eof = true;
}
}
if (!_segment_eof) {
_current_block = _next_block;
auto res = _segment_reader->get_block(vec_batch, &_next_block, &_segment_eof);
if (res != OLAP_SUCCESS) {
return res;
}
// Normal case
*got_batch = vec_batch;
return OLAP_SUCCESS;
}
// When this segment is read over, we reach here.
// Seek to next segment
RowBlockPosition block_pos;
block_pos.segment = _current_segment + 1;
block_pos.data_offset = 0;
auto res = _seek_to_block(block_pos, without_filter);
if (res != OLAP_SUCCESS) {
return res;
}
} while (true);
return OLAP_SUCCESS;
}
OLAPStatus ColumnData::_get_block(bool without_filter, int rows_read) {
do {
VectorizedRowBatch* vec_batch = nullptr;
auto res = _get_block_from_reader(&vec_batch, without_filter, rows_read);
if (res != OLAP_SUCCESS) {
return res;
}
// evaluate predicates
if (!without_filter && _need_eval_predicates) {
SCOPED_RAW_TIMER(&_stats->vec_cond_ns);
size_t old_size = vec_batch->size();
for (auto pred : *_col_predicates) {
pred->evaluate(vec_batch);
}
_stats->rows_vec_cond_filtered += old_size - vec_batch->size();
}
// if vector is empty after predicate evaluate, get next block
if (vec_batch->size() == 0) {
continue;
}
SCOPED_RAW_TIMER(&_stats->block_convert_ns);
// when reach here, we have already read a block successfully
_read_block->clear();
vec_batch->dump_to_row_block(_read_block.get());
return OLAP_SUCCESS;
} while (true);
return OLAP_SUCCESS;
}
} // namespace doris
|
// Copyright (c) 2011-2014 The Bitcoin developers
// Copyright (c) 2014-2016 The Dash developers
// Copyright (c) 2016-2018 The Bithost developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "transactiontablemodel.h"
#include "addresstablemodel.h"
#include "guiconstants.h"
#include "guiutil.h"
#include "optionsmodel.h"
#include "transactiondesc.h"
#include "transactionrecord.h"
#include "walletmodel.h"
#include "main.h"
#include "sync.h"
#include "uint256.h"
#include "util.h"
#include "wallet.h"
#include <QColor>
#include <QDateTime>
#include <QDebug>
#include <QIcon>
#include <QList>
// Amount column is right-aligned it contains numbers
static int column_alignments[] = {
Qt::AlignLeft | Qt::AlignVCenter, /* status */
Qt::AlignLeft | Qt::AlignVCenter, /* watchonly */
Qt::AlignLeft | Qt::AlignVCenter, /* date */
Qt::AlignLeft | Qt::AlignVCenter, /* type */
Qt::AlignLeft | Qt::AlignVCenter, /* address */
Qt::AlignRight | Qt::AlignVCenter /* amount */
};
// Comparison operator for sort/binary search of model tx list
struct TxLessThan {
bool operator()(const TransactionRecord& a, const TransactionRecord& b) const
{
return a.hash < b.hash;
}
bool operator()(const TransactionRecord& a, const uint256& b) const
{
return a.hash < b;
}
bool operator()(const uint256& a, const TransactionRecord& b) const
{
return a < b.hash;
}
};
// Private implementation
class TransactionTablePriv
{
public:
TransactionTablePriv(CWallet* wallet, TransactionTableModel* parent) : wallet(wallet),
parent(parent)
{
}
CWallet* wallet;
TransactionTableModel* parent;
/* Local cache of wallet.
* As it is in the same order as the CWallet, by definition
* this is sorted by sha256.
*/
QList<TransactionRecord> cachedWallet;
/* Query entire wallet anew from core.
*/
void refreshWallet()
{
qDebug() << "TransactionTablePriv::refreshWallet";
cachedWallet.clear();
{
LOCK2(cs_main, wallet->cs_wallet);
for (std::map<uint256, CWalletTx>::iterator it = wallet->mapWallet.begin(); it != wallet->mapWallet.end(); ++it) {
if (TransactionRecord::showTransaction(it->second))
cachedWallet.append(TransactionRecord::decomposeTransaction(wallet, it->second));
}
}
}
/* Update our model of the wallet incrementally, to synchronize our model of the wallet
with that of the core.
Call with transaction that was added, removed or changed.
*/
void updateWallet(const uint256& hash, int status, bool showTransaction)
{
qDebug() << "TransactionTablePriv::updateWallet : " + QString::fromStdString(hash.ToString()) + " " + QString::number(status);
// Find bounds of this transaction in model
QList<TransactionRecord>::iterator lower = qLowerBound(
cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());
QList<TransactionRecord>::iterator upper = qUpperBound(
cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());
int lowerIndex = (lower - cachedWallet.begin());
int upperIndex = (upper - cachedWallet.begin());
bool inModel = (lower != upper);
if (status == CT_UPDATED) {
if (showTransaction && !inModel)
status = CT_NEW; /* Not in model, but want to show, treat as new */
if (!showTransaction && inModel)
status = CT_DELETED; /* In model, but want to hide, treat as deleted */
}
qDebug() << " inModel=" + QString::number(inModel) +
" Index=" + QString::number(lowerIndex) + "-" + QString::number(upperIndex) +
" showTransaction=" + QString::number(showTransaction) + " derivedStatus=" + QString::number(status);
switch (status) {
case CT_NEW:
if (inModel) {
qWarning() << "TransactionTablePriv::updateWallet : Warning: Got CT_NEW, but transaction is already in model";
break;
}
if (showTransaction) {
LOCK2(cs_main, wallet->cs_wallet);
// Find transaction in wallet
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(hash);
if (mi == wallet->mapWallet.end()) {
qWarning() << "TransactionTablePriv::updateWallet : Warning: Got CT_NEW, but transaction is not in wallet";
break;
}
// Added -- insert at the right position
QList<TransactionRecord> toInsert =
TransactionRecord::decomposeTransaction(wallet, mi->second);
if (!toInsert.isEmpty()) /* only if something to insert */
{
parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex + toInsert.size() - 1);
int insert_idx = lowerIndex;
foreach (const TransactionRecord& rec, toInsert) {
cachedWallet.insert(insert_idx, rec);
insert_idx += 1;
}
parent->endInsertRows();
}
}
break;
case CT_DELETED:
if (!inModel) {
qWarning() << "TransactionTablePriv::updateWallet : Warning: Got CT_DELETED, but transaction is not in model";
break;
}
// Removed -- remove entire transaction from table
parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex - 1);
cachedWallet.erase(lower, upper);
parent->endRemoveRows();
break;
case CT_UPDATED:
// Miscellaneous updates -- nothing to do, status update will take care of this, and is only computed for
// visible transactions.
break;
}
}
int size()
{
return cachedWallet.size();
}
TransactionRecord* index(int idx)
{
if (idx >= 0 && idx < cachedWallet.size()) {
TransactionRecord* rec = &cachedWallet[idx];
// Get required locks upfront. This avoids the GUI from getting
// stuck if the core is holding the locks for a longer time - for
// example, during a wallet rescan.
//
// If a status update is needed (blocks came in since last check),
// update the status of this transaction from the wallet. Otherwise,
// simply re-use the cached status.
TRY_LOCK(cs_main, lockMain);
if (lockMain) {
TRY_LOCK(wallet->cs_wallet, lockWallet);
if (lockWallet && rec->statusUpdateNeeded()) {
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
if (mi != wallet->mapWallet.end()) {
rec->updateStatus(mi->second);
}
}
}
return rec;
}
return 0;
}
QString describe(TransactionRecord* rec, int unit)
{
{
LOCK2(cs_main, wallet->cs_wallet);
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(rec->hash);
if (mi != wallet->mapWallet.end()) {
return TransactionDesc::toHTML(wallet, mi->second, rec, unit);
}
}
return QString();
}
};
TransactionTableModel::TransactionTableModel(CWallet* wallet, WalletModel* parent) : QAbstractTableModel(parent),
wallet(wallet),
walletModel(parent),
priv(new TransactionTablePriv(wallet, this)),
fProcessingQueuedTransactions(false)
{
columns << QString() << QString() << tr("Date") << tr("Type") << tr("Address") << BitcoinUnits::getAmountColumnTitle(walletModel->getOptionsModel()->getDisplayUnit());
priv->refreshWallet();
connect(walletModel->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
subscribeToCoreSignals();
}
TransactionTableModel::~TransactionTableModel()
{
unsubscribeFromCoreSignals();
delete priv;
}
/** Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table headers to react. */
void TransactionTableModel::updateAmountColumnTitle()
{
columns[Amount] = BitcoinUnits::getAmountColumnTitle(walletModel->getOptionsModel()->getDisplayUnit());
emit headerDataChanged(Qt::Horizontal, Amount, Amount);
}
void TransactionTableModel::updateTransaction(const QString& hash, int status, bool showTransaction)
{
uint256 updated;
updated.SetHex(hash.toStdString());
priv->updateWallet(updated, status, showTransaction);
}
void TransactionTableModel::updateConfirmations()
{
// Blocks came in since last poll.
// Invalidate status (number of confirmations) and (possibly) description
// for all rows. Qt is smart enough to only actually request the data for the
// visible rows.
emit dataChanged(index(0, Status), index(priv->size() - 1, Status));
emit dataChanged(index(0, ToAddress), index(priv->size() - 1, ToAddress));
}
int TransactionTableModel::rowCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
return priv->size();
}
int TransactionTableModel::columnCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
return columns.length();
}
QString TransactionTableModel::formatTxStatus(const TransactionRecord* wtx) const
{
QString status;
switch (wtx->status.status) {
case TransactionStatus::OpenUntilBlock:
status = tr("Open for %n more block(s)", "", wtx->status.open_for);
break;
case TransactionStatus::OpenUntilDate:
status = tr("Open until %1").arg(GUIUtil::dateTimeStr(wtx->status.open_for));
break;
case TransactionStatus::Offline:
status = tr("Offline");
break;
case TransactionStatus::Unconfirmed:
status = tr("Unconfirmed");
break;
case TransactionStatus::Confirming:
status = tr("Confirming (%1 of %2 recommended confirmations)").arg(wtx->status.depth).arg(TransactionRecord::RecommendedNumConfirmations);
break;
case TransactionStatus::Confirmed:
status = tr("Confirmed (%1 confirmations)").arg(wtx->status.depth);
break;
case TransactionStatus::Conflicted:
status = tr("Conflicted");
break;
case TransactionStatus::Immature:
status = tr("Immature (%1 confirmations, will be available after %2)").arg(wtx->status.depth).arg(wtx->status.depth + wtx->status.matures_in);
break;
case TransactionStatus::MaturesWarning:
status = tr("This block was not received by any other nodes and will probably not be accepted!");
break;
case TransactionStatus::NotAccepted:
status = tr("Orphan Block - Generated but not accepted. This does not impact your holdings.");
break;
}
return status;
}
QString TransactionTableModel::formatTxDate(const TransactionRecord* wtx) const
{
if (wtx->time) {
return GUIUtil::dateTimeStr(wtx->time);
}
return QString();
}
/* Look up address in address book, if found return label (address)
otherwise just return (address)
*/
QString TransactionTableModel::lookupAddress(const std::string& address, bool tooltip) const
{
QString label = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(address));
QString description;
if (!label.isEmpty()) {
description += label;
}
if (label.isEmpty() || tooltip) {
description += QString(" (") + QString::fromStdString(address) + QString(")");
}
return description;
}
QString TransactionTableModel::formatTxType(const TransactionRecord* wtx) const
{
switch (wtx->type) {
case TransactionRecord::RecvWithAddress:
return tr("Received with");
case TransactionRecord::MNReward:
return tr("Masternode Reward");
case TransactionRecord::RecvFromOther:
return tr("Received from");
case TransactionRecord::RecvWithObfuscation:
return tr("Received via Obfuscation");
case TransactionRecord::SendToAddress:
case TransactionRecord::SendToOther:
return tr("Sent to");
case TransactionRecord::SendToSelf:
return tr("Payment to yourself");
case TransactionRecord::StakeMint:
return tr("BIH Stake");
case TransactionRecord::StakeZBIH:
return tr("zBIH Stake");
case TransactionRecord::Generated:
return tr("Mined");
case TransactionRecord::ObfuscationDenominate:
return tr("Obfuscation Denominate");
case TransactionRecord::ObfuscationCollateralPayment:
return tr("Obfuscation Collateral Payment");
case TransactionRecord::ObfuscationMakeCollaterals:
return tr("Obfuscation Make Collateral Inputs");
case TransactionRecord::ObfuscationCreateDenominations:
return tr("Obfuscation Create Denominations");
case TransactionRecord::Obfuscated:
return tr("Obfuscated");
case TransactionRecord::ZerocoinMint:
return tr("Converted BIH to zBIH");
case TransactionRecord::ZerocoinSpend:
return tr("Spent zBIH");
case TransactionRecord::RecvFromZerocoinSpend:
return tr("Received BIH from zBIH");
case TransactionRecord::ZerocoinSpend_Change_zBih:
return tr("Minted Change as zBIH from zBIH Spend");
case TransactionRecord::ZerocoinSpend_FromMe:
return tr("Converted zBIH to BIH");
default:
return QString();
}
}
QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord* wtx) const
{
switch (wtx->type) {
case TransactionRecord::Generated:
case TransactionRecord::StakeMint:
case TransactionRecord::StakeZBIH:
case TransactionRecord::MNReward:
return QIcon(":/icons/tx_mined");
case TransactionRecord::RecvWithObfuscation:
case TransactionRecord::RecvWithAddress:
case TransactionRecord::RecvFromOther:
case TransactionRecord::RecvFromZerocoinSpend:
return QIcon(":/icons/tx_input");
case TransactionRecord::SendToAddress:
case TransactionRecord::SendToOther:
case TransactionRecord::ZerocoinSpend:
return QIcon(":/icons/tx_output");
default:
return QIcon(":/icons/tx_inout");
}
}
QString TransactionTableModel::formatTxToAddress(const TransactionRecord* wtx, bool tooltip) const
{
QString watchAddress;
if (tooltip) {
// Mark transactions involving watch-only addresses by adding " (watch-only)"
watchAddress = wtx->involvesWatchAddress ? QString(" (") + tr("watch-only") + QString(")") : "";
}
switch (wtx->type) {
case TransactionRecord::RecvFromOther:
return QString::fromStdString(wtx->address) + watchAddress;
case TransactionRecord::RecvWithAddress:
case TransactionRecord::MNReward:
case TransactionRecord::RecvWithObfuscation:
case TransactionRecord::SendToAddress:
case TransactionRecord::Generated:
case TransactionRecord::StakeMint:
case TransactionRecord::ZerocoinSpend:
case TransactionRecord::ZerocoinSpend_FromMe:
case TransactionRecord::RecvFromZerocoinSpend:
return lookupAddress(wtx->address, tooltip);
case TransactionRecord::Obfuscated:
return lookupAddress(wtx->address, tooltip) + watchAddress;
case TransactionRecord::SendToOther:
return QString::fromStdString(wtx->address) + watchAddress;
case TransactionRecord::ZerocoinMint:
case TransactionRecord::ZerocoinSpend_Change_zBih:
return tr("Anonymous (zBIH Transaction)");
case TransactionRecord::StakeZBIH:
return tr("Anonymous (zBIH Stake)");
case TransactionRecord::SendToSelf:
default:
return tr("(n/a)") + watchAddress;
}
}
QVariant TransactionTableModel::addressColor(const TransactionRecord* wtx) const
{
switch (wtx->type) {
// Show addresses without label in a less visible color
case TransactionRecord::RecvWithAddress:
case TransactionRecord::SendToAddress:
case TransactionRecord::Generated:
case TransactionRecord::MNReward: {
QString label = walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(wtx->address));
if (label.isEmpty())
return COLOR_BAREADDRESS;
}
case TransactionRecord::SendToSelf:
default:
// To avoid overriding above conditional formats a default text color for this QTableView is not defined in stylesheet,
// so we must always return a color here
return COLOR_BLACK;
}
}
QString TransactionTableModel::formatTxAmount(const TransactionRecord* wtx, bool showUnconfirmed, BitcoinUnits::SeparatorStyle separators) const
{
QString str = BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), wtx->credit + wtx->debit, false, separators);
if (showUnconfirmed) {
if (!wtx->status.countsForBalance) {
str = QString("[") + str + QString("]");
}
}
return QString(str);
}
QVariant TransactionTableModel::txStatusDecoration(const TransactionRecord* wtx) const
{
switch (wtx->status.status) {
case TransactionStatus::OpenUntilBlock:
case TransactionStatus::OpenUntilDate:
return COLOR_TX_STATUS_OPENUNTILDATE;
case TransactionStatus::Offline:
return COLOR_TX_STATUS_OFFLINE;
case TransactionStatus::Unconfirmed:
return QIcon(":/icons/transaction_0");
case TransactionStatus::Confirming:
switch (wtx->status.depth) {
case 1:
return QIcon(":/icons/transaction_1");
case 2:
return QIcon(":/icons/transaction_2");
case 3:
return QIcon(":/icons/transaction_3");
case 4:
return QIcon(":/icons/transaction_4");
default:
return QIcon(":/icons/transaction_5");
};
case TransactionStatus::Confirmed:
return QIcon(":/icons/transaction_confirmed");
case TransactionStatus::Conflicted:
return QIcon(":/icons/transaction_conflicted");
case TransactionStatus::Immature: {
int total = wtx->status.depth + wtx->status.matures_in;
int part = (wtx->status.depth * 4 / total) + 1;
return QIcon(QString(":/icons/transaction_%1").arg(part));
}
case TransactionStatus::MaturesWarning:
case TransactionStatus::NotAccepted:
return QIcon(":/icons/transaction_0");
default:
return COLOR_BLACK;
}
}
QVariant TransactionTableModel::txWatchonlyDecoration(const TransactionRecord* wtx) const
{
if (wtx->involvesWatchAddress)
return QIcon(":/icons/eye");
else
return QVariant();
}
QString TransactionTableModel::formatTooltip(const TransactionRecord* rec) const
{
QString tooltip = formatTxStatus(rec) + QString("\n") + formatTxType(rec);
if (rec->type == TransactionRecord::RecvFromOther || rec->type == TransactionRecord::SendToOther ||
rec->type == TransactionRecord::SendToAddress || rec->type == TransactionRecord::RecvWithAddress || rec->type == TransactionRecord::MNReward) {
tooltip += QString(" ") + formatTxToAddress(rec, true);
}
return tooltip;
}
QVariant TransactionTableModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid())
return QVariant();
TransactionRecord* rec = static_cast<TransactionRecord*>(index.internalPointer());
switch (role) {
case Qt::DecorationRole:
switch (index.column()) {
case Status:
return txStatusDecoration(rec);
case Watchonly:
return txWatchonlyDecoration(rec);
case ToAddress:
return txAddressDecoration(rec);
}
break;
case Qt::DisplayRole:
switch (index.column()) {
case Date:
return formatTxDate(rec);
case Type:
return formatTxType(rec);
case ToAddress:
return formatTxToAddress(rec, false);
case Amount:
return formatTxAmount(rec, true, BitcoinUnits::separatorAlways);
}
break;
case Qt::EditRole:
// Edit role is used for sorting, so return the unformatted values
switch (index.column()) {
case Status:
return QString::fromStdString(rec->status.sortKey);
case Date:
return rec->time;
case Type:
return formatTxType(rec);
case Watchonly:
return (rec->involvesWatchAddress ? 1 : 0);
case ToAddress:
return formatTxToAddress(rec, true);
case Amount:
return qint64(rec->credit + rec->debit);
}
break;
case Qt::ToolTipRole:
return formatTooltip(rec);
case Qt::TextAlignmentRole:
return column_alignments[index.column()];
case Qt::ForegroundRole:
// Minted
if (rec->type == TransactionRecord::Generated || rec->type == TransactionRecord::StakeMint ||
rec->type == TransactionRecord::StakeZBIH || rec->type == TransactionRecord::MNReward) {
if (rec->status.status == TransactionStatus::Conflicted || rec->status.status == TransactionStatus::NotAccepted)
return COLOR_ORPHAN;
else
return COLOR_STAKE;
}
// Conflicted tx
if (rec->status.status == TransactionStatus::Conflicted || rec->status.status == TransactionStatus::NotAccepted) {
return COLOR_CONFLICTED;
}
// Unconfimed or immature
if ((rec->status.status == TransactionStatus::Unconfirmed) || (rec->status.status == TransactionStatus::Immature)) {
return COLOR_UNCONFIRMED;
}
if (index.column() == Amount && (rec->credit + rec->debit) < 0) {
return COLOR_NEGATIVE;
}
if (index.column() == ToAddress) {
return addressColor(rec);
}
// To avoid overriding above conditional formats a default text color for this QTableView is not defined in stylesheet,
// so we must always return a color here
return COLOR_BLACK;
case TypeRole:
return rec->type;
case DateRole:
return QDateTime::fromTime_t(static_cast<uint>(rec->time));
case WatchonlyRole:
return rec->involvesWatchAddress;
case WatchonlyDecorationRole:
return txWatchonlyDecoration(rec);
case LongDescriptionRole:
return priv->describe(rec, walletModel->getOptionsModel()->getDisplayUnit());
case AddressRole:
return QString::fromStdString(rec->address);
case LabelRole:
return walletModel->getAddressTableModel()->labelForAddress(QString::fromStdString(rec->address));
case AmountRole:
return qint64(rec->credit + rec->debit);
case TxIDRole:
return rec->getTxID();
case TxHashRole:
return QString::fromStdString(rec->hash.ToString());
case ConfirmedRole:
return rec->status.countsForBalance;
case FormattedAmountRole:
// Used for copy/export, so don't include separators
return formatTxAmount(rec, false, BitcoinUnits::separatorNever);
case StatusRole:
return rec->status.status;
}
return QVariant();
}
QVariant TransactionTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal) {
if (role == Qt::DisplayRole) {
return columns[section];
} else if (role == Qt::TextAlignmentRole) {
return column_alignments[section];
} else if (role == Qt::ToolTipRole) {
switch (section) {
case Status:
return tr("Transaction status. Hover over this field to show number of confirmations.");
case Date:
return tr("Date and time that the transaction was received.");
case Type:
return tr("Type of transaction.");
case Watchonly:
return tr("Whether or not a watch-only address is involved in this transaction.");
case ToAddress:
return tr("Destination address of transaction.");
case Amount:
return tr("Amount removed from or added to balance.");
}
}
}
return QVariant();
}
QModelIndex TransactionTableModel::index(int row, int column, const QModelIndex& parent) const
{
Q_UNUSED(parent);
TransactionRecord* data = priv->index(row);
if (data) {
return createIndex(row, column, priv->index(row));
}
return QModelIndex();
}
void TransactionTableModel::updateDisplayUnit()
{
// emit dataChanged to update Amount column with the current unit
updateAmountColumnTitle();
emit dataChanged(index(0, Amount), index(priv->size() - 1, Amount));
}
// queue notifications to show a non freezing progress dialog e.g. for rescan
struct TransactionNotification {
public:
TransactionNotification() {}
TransactionNotification(uint256 hash, ChangeType status, bool showTransaction) : hash(hash), status(status), showTransaction(showTransaction) {}
void invoke(QObject* ttm)
{
QString strHash = QString::fromStdString(hash.GetHex());
qDebug() << "NotifyTransactionChanged : " + strHash + " status= " + QString::number(status);
QMetaObject::invokeMethod(ttm, "updateTransaction", Qt::QueuedConnection,
Q_ARG(QString, strHash),
Q_ARG(int, status),
Q_ARG(bool, showTransaction));
}
private:
uint256 hash;
ChangeType status;
bool showTransaction;
};
static bool fQueueNotifications = false;
static std::vector<TransactionNotification> vQueueNotifications;
static void NotifyTransactionChanged(TransactionTableModel* ttm, CWallet* wallet, const uint256& hash, ChangeType status)
{
// Find transaction in wallet
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(hash);
// Determine whether to show transaction or not (determine this here so that no relocking is needed in GUI thread)
bool inWallet = mi != wallet->mapWallet.end();
bool showTransaction = (inWallet && TransactionRecord::showTransaction(mi->second));
TransactionNotification notification(hash, status, showTransaction);
if (fQueueNotifications) {
vQueueNotifications.push_back(notification);
return;
}
notification.invoke(ttm);
}
static void ShowProgress(TransactionTableModel* ttm, const std::string& title, int nProgress)
{
if (nProgress == 0)
fQueueNotifications = true;
if (nProgress == 100) {
fQueueNotifications = false;
if (vQueueNotifications.size() > 10) // prevent balloon spam, show maximum 10 balloons
QMetaObject::invokeMethod(ttm, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, true));
for (unsigned int i = 0; i < vQueueNotifications.size(); ++i) {
if (vQueueNotifications.size() - i <= 10)
QMetaObject::invokeMethod(ttm, "setProcessingQueuedTransactions", Qt::QueuedConnection, Q_ARG(bool, false));
vQueueNotifications[i].invoke(ttm);
}
std::vector<TransactionNotification>().swap(vQueueNotifications); // clear
}
}
void TransactionTableModel::subscribeToCoreSignals()
{
// Connect signals to wallet
wallet->NotifyTransactionChanged.connect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3));
wallet->ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2));
}
void TransactionTableModel::unsubscribeFromCoreSignals()
{
// Disconnect signals from wallet
wallet->NotifyTransactionChanged.disconnect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3));
wallet->ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2));
}
|
CreditsTextPointers:
dw CredVersion
dw CredTajiri
dw CredTaOota
dw CredMorimoto
dw CredWatanabe
dw CredMasuda
dw CredNisino
dw CredSugimori
dw CredNishida
dw CredMiyamoto
dw CredKawaguchi
dw CredIshihara
dw CredYamauchi
dw CredZinnai
dw CredHishida
dw CredSakai
dw CredYamaguchi
dw CredYamamoto
dw CredTaniguchi
dw CredNonomura
dw CredFuziwara
dw CredMatsusima
dw CredTomisawa
dw CredKawamoto
dw CredKakei
dw CredTsuchiya
dw CredTaNakamura
dw CredYuda
dw CredMon
dw CredDirector
dw CredProgrammers
dw CredCharDesign
dw CredMusic
dw CredSoundEffects
dw CredGameDesign
dw CredMonsterDesign
dw CredGameScene
dw CredParam
dw CredMap
dw CredTest
dw CredSpecial
dw CredProducers
dw CredProducer
dw CredExecutive
dw CredTamada
dw CredSaOota
dw CredYoshikawa
dw CredToOota
dw CredUSStaff
dw CredUSCoord
dw CredTilden
dw CredKawakami
dw CredHiNakamura
dw CredGiese
dw CredOsborne
dw CredTrans
dw CredOgasawara
dw CredIwata
dw CredIzushi
dw CredHarada
dw CredMurakawa
dw CredFukui
dw CredClub
dw CredPAAD
CredVersion: ; this 1 byte difference makes all bank addresses offset by 1 in the blue version
IF DEF(_RED)
db -8, "RED VERSION STAFF@"
ENDC
IF DEF(_BLUE)
db -8, "BLUE VERSION STAFF@"
ENDC
CredTajiri:
db -6, "SATOSHI TAJIRI@"
CredTaOota:
db -6, "TAKENORI OOTA@"
CredMorimoto:
db -7, "SHIGEKI MORIMOTO@"
CredWatanabe:
db -7, "TETSUYA WATANABE@"
CredMasuda:
db -6, "JUNICHI MASUDA@"
CredNisino:
db -5, "KOHJI NISINO@"
CredSugimori:
db -5, "KEN SUGIMORI@"
CredNishida:
db -6, "ATSUKO NISHIDA@"
CredMiyamoto:
db -7, "SHIGERU MIYAMOTO@"
CredKawaguchi:
db -8, "TAKASHI KAWAGUCHI@"
CredIshihara:
db -8, "TSUNEKAZU ISHIHARA@"
CredYamauchi:
db -7, "HIROSHI YAMAUCHI@"
CredZinnai:
db -7, "HIROYUKI ZINNAI@"
CredHishida:
db -7, "TATSUYA HISHIDA@"
CredSakai:
db -6, "YASUHIRO SAKAI@"
CredYamaguchi:
db -7, "WATARU YAMAGUCHI@"
CredYamamoto:
db -8, "KAZUYUKI YAMAMOTO@"
CredTaniguchi:
db -8, "RYOHSUKE TANIGUCHI@"
CredNonomura:
db -8, "FUMIHIRO NONOMURA@"
CredFuziwara:
db -7, "MOTOFUMI FUZIWARA@"
CredMatsusima:
db -7, "KENJI MATSUSIMA@"
CredTomisawa:
db -7, "AKIHITO TOMISAWA@"
CredKawamoto:
db -7, "HIROSHI KAWAMOTO@"
CredKakei:
db -6, "AKIYOSHI KAKEI@"
CredTsuchiya:
db -7, "KAZUKI TSUCHIYA@"
CredTaNakamura:
db -6, "TAKEO NAKAMURA@"
CredYuda:
db -6, "MASAMITSU YUDA@"
CredMon:
db -3, "#MON@"
CredDirector:
db -3, "DIRECTOR@"
CredProgrammers:
db -5, "PROGRAMMERS@"
CredCharDesign:
db -7, "CHARACTER DESIGN@"
CredMusic:
db -2, "MUSIC@"
CredSoundEffects:
db -6, "SOUND EFFECTS@"
CredGameDesign:
db -5, "GAME DESIGN@"
CredMonsterDesign:
db -6, "MONSTER DESIGN@"
CredGameScene:
db -6, "GAME SCENARIO@"
CredParam:
db -8, "PARAMETRIC DESIGN@"
CredMap:
db -4, "MAP DESIGN@"
CredTest:
db -7, "PRODUCT TESTING@"
CredSpecial:
db -6, "SPECIAL THANKS@"
CredProducers:
db -4, "PRODUCERS@"
CredProducer:
db -4, "PRODUCER@"
CredExecutive:
db -8, "EXECUTIVE PRODUCER@"
CredTamada:
db -6, "SOUSUKE TAMADA@"
CredSaOota:
db -5, "SATOSHI OOTA@"
CredYoshikawa:
db -6, "RENA YOSHIKAWA@"
CredToOota:
db -6, "TOMOMICHI OOTA@"
CredUSStaff:
db -7, "US VERSION STAFF@"
CredUSCoord:
db -7, "US COORDINATION@"
CredTilden:
db -5, "GAIL TILDEN@"
CredKawakami:
db -6, "NAOKO KAWAKAMI@"
CredHiNakamura:
db -6, "HIRO NAKAMURA@"
CredGiese:
db -6, "WILLIAM GIESE@"
CredOsborne:
db -5, "SARA OSBORNE@"
CredTrans:
db -7, "TEXT TRANSLATION@"
CredOgasawara:
db -6, "NOB OGASAWARA@"
CredIwata:
db -5, "SATORU IWATA@"
CredIzushi:
db -7, "TAKEHIRO IZUSHI@"
CredHarada:
db -7, "TAKAHIRO HARADA@"
CredMurakawa:
db -7, "TERUKI MURAKAWA@"
CredFukui:
db -5, "KOHTA FUKUI@"
CredClub:
db -9, "NCL SUPER MARIO CLUB@"
CredPAAD:
db -5, "PAAD TESTING@"
|
; float _negf (float number) __z88dk_fastcall
SECTION code_clib
SECTION code_fp_math32
PUBLIC asm_dneg
EXTERN m32_fsneg
; negate DEHL'
;
; enter : DEHL'= double x
;
; exit : DEHL'= -x
;
; uses :
.asm_dneg
exx
call m32_fsneg
exx
ret
|
/*
Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
Copyright (c) 2010 ACCESS CO., LTD. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "CachedImage.h"
#include "BitmapImage.h"
#include "Cache.h"
#include "CachedResourceClient.h"
#include "CachedResourceClientWalker.h"
#include "DocLoader.h"
#include "Frame.h"
#include "FrameLoaderTypes.h"
#include "FrameView.h"
#include "Request.h"
#include "Settings.h"
#include <wtf/CurrentTime.h>
#include <wtf/StdLibExtras.h>
#include <wtf/Vector.h>
#if PLATFORM(CG)
#include "PDFDocumentImage.h"
#endif
#if ENABLE(SVG_AS_IMAGE)
#include "SVGImage.h"
#endif
using std::max;
namespace WebCore {
CachedImage::CachedImage(const String& url)
: CachedResource(url, ImageResource)
, m_image(0)
, m_decodedDataDeletionTimer(this, &CachedImage::decodedDataDeletionTimerFired)
, m_httpStatusCodeErrorOccurred(false)
{
m_status = Unknown;
}
CachedImage::CachedImage(Image* image)
: CachedResource(String(), ImageResource)
, m_image(image)
, m_decodedDataDeletionTimer(this, &CachedImage::decodedDataDeletionTimerFired)
, m_httpStatusCodeErrorOccurred(false)
{
m_status = Cached;
m_loading = false;
}
CachedImage::~CachedImage()
{
}
void CachedImage::decodedDataDeletionTimerFired(Timer<CachedImage>*)
{
ASSERT(!hasClients());
destroyDecodedData();
}
void CachedImage::load(DocLoader* docLoader)
{
if (!docLoader || docLoader->autoLoadImages())
CachedResource::load(docLoader, true, DoSecurityCheck, true);
else
m_loading = false;
}
void CachedImage::didAddClient(CachedResourceClient* c)
{
if (m_decodedDataDeletionTimer.isActive())
m_decodedDataDeletionTimer.stop();
if (m_data && !m_image && !m_errorOccurred) {
createImage();
m_image->setData(m_data, true);
}
if (m_image && !m_image->isNull())
c->imageChanged(this);
if (!m_loading)
c->notifyFinished(this);
}
void CachedImage::allClientsRemoved()
{
if (m_image && !m_errorOccurred)
m_image->resetAnimation();
if (double interval = cache()->deadDecodedDataDeletionInterval())
m_decodedDataDeletionTimer.startOneShot(interval);
}
#if PLATFORM(WKC)
static Image* gBrokenImage = 0;
static BitmapImage* gNullImage = 0;
static Image* brokenImage()
{
if (!gBrokenImage) {
Image*& img = *(new Image*(Image::loadPlatformResource("missingImage").releaseRef()));
gBrokenImage = img;
}
return gBrokenImage;
}
static Image* nullImage()
{
if (!gNullImage) {
BitmapImage*& img = *(new BitmapImage*(BitmapImage::create().releaseRef()));
gNullImage = img;
}
return gNullImage;
}
#else
static Image* brokenImage()
{
DEFINE_STATIC_LOCAL(RefPtr<Image>, brokenImage, (Image::loadPlatformResource("missingImage")));
return brokenImage.get();
}
static Image* nullImage()
{
DEFINE_STATIC_LOCAL(RefPtr<BitmapImage>, nullImage, (BitmapImage::create()));
return nullImage.get();
}
#endif
Image* CachedImage::image() const
{
ASSERT(!isPurgeable());
if (m_errorOccurred)
return brokenImage();
if (m_image)
return m_image.get();
return nullImage();
}
void CachedImage::setImageContainerSize(const IntSize& containerSize)
{
if (m_image)
m_image->setContainerSize(containerSize);
}
bool CachedImage::usesImageContainerSize() const
{
if (m_image)
return m_image->usesContainerSize();
return false;
}
bool CachedImage::imageHasRelativeWidth() const
{
if (m_image)
return m_image->hasRelativeWidth();
return false;
}
bool CachedImage::imageHasRelativeHeight() const
{
if (m_image)
return m_image->hasRelativeHeight();
return false;
}
IntSize CachedImage::imageSize(float multiplier) const
{
ASSERT(!isPurgeable());
if (!m_image)
return IntSize();
if (multiplier == 1.0f)
return m_image->size();
// Don't let images that have a width/height >= 1 shrink below 1 when zoomed.
bool hasWidth = m_image->size().width() > 0;
bool hasHeight = m_image->size().height() > 0;
int width = m_image->size().width() * (m_image->hasRelativeWidth() ? 1.0f : multiplier);
int height = m_image->size().height() * (m_image->hasRelativeHeight() ? 1.0f : multiplier);
if (hasWidth)
width = max(1, width);
if (hasHeight)
height = max(1, height);
return IntSize(width, height);
}
IntRect CachedImage::imageRect(float multiplier) const
{
ASSERT(!isPurgeable());
if (!m_image)
return IntRect();
if (multiplier == 1.0f || (!m_image->hasRelativeWidth() && !m_image->hasRelativeHeight()))
return m_image->rect();
float widthMultiplier = (m_image->hasRelativeWidth() ? 1.0f : multiplier);
float heightMultiplier = (m_image->hasRelativeHeight() ? 1.0f : multiplier);
// Don't let images that have a width/height >= 1 shrink below 1 when zoomed.
bool hasWidth = m_image->rect().width() > 0;
bool hasHeight = m_image->rect().height() > 0;
int width = static_cast<int>(m_image->rect().width() * widthMultiplier);
int height = static_cast<int>(m_image->rect().height() * heightMultiplier);
if (hasWidth)
width = max(1, width);
if (hasHeight)
height = max(1, height);
int x = static_cast<int>(m_image->rect().x() * widthMultiplier);
int y = static_cast<int>(m_image->rect().y() * heightMultiplier);
return IntRect(x, y, width, height);
}
void CachedImage::notifyObservers(const IntRect* changeRect)
{
CachedResourceClientWalker w(m_clients);
while (CachedResourceClient* c = w.next())
c->imageChanged(this, changeRect);
}
void CachedImage::clear()
{
destroyDecodedData();
m_image = 0;
setEncodedSize(0);
}
inline void CachedImage::createImage()
{
// Create the image if it doesn't yet exist.
if (m_image)
return;
#if PLATFORM(CG)
if (m_response.mimeType() == "application/pdf") {
m_image = PDFDocumentImage::create();
return;
}
#endif
#if ENABLE(SVG_AS_IMAGE)
if (m_response.mimeType() == "image/svg+xml") {
m_image = SVGImage::create(this);
return;
}
#endif
m_image = BitmapImage::create(this);
}
size_t CachedImage::maximumDecodedImageSize()
{
Frame* frame = m_request ? m_request->docLoader()->frame() : 0;
if (!frame)
return 0;
Settings* settings = frame->settings();
return settings ? settings->maximumDecodedImageSize() : 0;
}
void CachedImage::data(PassRefPtr<SharedBuffer> data, bool allDataReceived)
{
m_data = data;
createImage();
bool sizeAvailable = false;
// Have the image update its data from its internal buffer.
// It will not do anything now, but will delay decoding until
// queried for info (like size or specific image frames).
sizeAvailable = m_image->setData(m_data, allDataReceived);
// Go ahead and tell our observers to try to draw if we have either
// received all the data or the size is known. Each chunk from the
// network causes observers to repaint, which will force that chunk
// to decode.
if (sizeAvailable || allDataReceived) {
size_t maxDecodedImageSize = maximumDecodedImageSize();
IntSize s = imageSize(1.0f);
size_t estimatedDecodedImageSize = s.width() * s.height() * 4; // no overflow check
if (m_image->isNull() || (maxDecodedImageSize > 0 && estimatedDecodedImageSize > maxDecodedImageSize)) {
error();
if (inCache())
cache()->remove(this);
return;
}
// It would be nice to only redraw the decoded band of the image, but with the current design
// (decoding delayed until painting) that seems hard.
notifyObservers();
if (m_image)
setEncodedSize(m_image->data() ? m_image->data()->size() : 0);
}
if (allDataReceived) {
m_loading = false;
checkNotify();
}
}
void CachedImage::error()
{
clear();
m_errorOccurred = true;
m_data.clear();
notifyObservers();
m_loading = false;
checkNotify();
}
void CachedImage::checkNotify()
{
if (m_loading)
return;
CachedResourceClientWalker w(m_clients);
while (CachedResourceClient* c = w.next())
c->notifyFinished(this);
}
void CachedImage::destroyDecodedData()
{
bool canDeleteImage = !m_image || (m_image->hasOneRef() && m_image->isBitmapImage());
if (isSafeToMakePurgeable() && canDeleteImage && !m_loading) {
// Image refs the data buffer so we should not make it purgeable while the image is alive.
// Invoking addClient() will reconstruct the image object.
m_image = 0;
setDecodedSize(0);
makePurgeable(true);
} else if (m_image && !m_errorOccurred)
m_image->destroyDecodedData();
}
void CachedImage::decodedSizeChanged(const Image* image, int delta)
{
if (image != m_image)
return;
setDecodedSize(decodedSize() + delta);
}
void CachedImage::didDraw(const Image* image)
{
if (image != m_image)
return;
double timeStamp = FrameView::currentPaintTimeStamp();
if (!timeStamp) // If didDraw is called outside of a Frame paint.
timeStamp = currentTime();
CachedResource::didAccessDecodedData(timeStamp);
}
bool CachedImage::shouldPauseAnimation(const Image* image)
{
if (image != m_image)
return false;
CachedResourceClientWalker w(m_clients);
while (CachedResourceClient* c = w.next()) {
if (c->willRenderImage(this))
return false;
}
return true;
}
void CachedImage::animationAdvanced(const Image* image)
{
if (image == m_image)
notifyObservers();
}
void CachedImage::changedInRect(const Image* image, const IntRect& rect)
{
if (image == m_image)
notifyObservers(&rect);
}
#if PLATFORM(WKC)
void CachedImage::deleteSharedInstance()
{
delete gBrokenImage;
delete gNullImage;
}
void CachedImage::resetVariables()
{
gBrokenImage = 0;
gNullImage = 0;
}
#endif
} //namespace WebCore
|
; Startup Code for Sega Master System
;
; Haroldo O. Pinheiro February 2006
;
; $Id: sms_crt0.asm,v 1.2 2007/06/02 22:33:59 dom Exp $
;
DEFC ROM_Start = $0000
DEFC INT_Start = $0038
DEFC NMI_Start = $0066
DEFC CODE_Start = $0100
DEFC RAM_Start = $C000
DEFC RAM_Length = $2000
DEFC Stack_Top = $dff0
MODULE sms_crt0
;-------
; Include zcc_opt.def to find out information about us
;-------
INCLUDE "zcc_opt.def"
;-------
; Some general scope declarations
;-------
XREF _main ;main() is always external to crt0 code
XDEF cleanup ;jp'd to by exit()
XDEF l_dcal ;jp(hl)
XDEF _std_seed ;Integer rand() seed
XDEF exitsp ;Pointer to atexit() stack
XDEF exitcount ;Number of atexit() functions registered
XDEF __sgoioblk ;std* control block
XDEF heaplast ;Near malloc heap variables
XDEF heapblocks ;
XDEF _vfprintf ;jp to printf() core routine
XDEF fputc_vdp_offs ;Current character pointer
XDEF aPLibMemory_bits;apLib support variable
XDEF aPLibMemory_byte;apLib support variable
XDEF aPLibMemory_LWM ;apLib support variable
XDEF aPLibMemory_R0 ;apLib support variable
XDEF raster_procs ;Raster interrupt handlers
XDEF pause_procs ;Pause interrupt handlers
XDEF timer ;This is incremented every time a VBL/HBL interrupt happens
XDEF _pause_flag ;This alternates between 0 and 1 every time pause is pressed
org ROM_Start
jp start
defm "Sega Master System"
;-------
; Interrupt handlers
;-------
.filler1
defs (INT_Start - filler1)
.int_RASTER
push hl
ld a, ($BF)
or a
jp p, int_not_VBL ; Bit 7 not set
jr int_VBL
.int_not_VBL
pop hl
reti
.int_VBL
ld hl, timer
ld a, (hl)
inc a
ld (hl), a
inc hl
ld a, (hl)
adc a, 1
ld (hl), a ;Increments the timer
ld hl, raster_procs
jr int_handler
.filler2
defs (NMI_Start - filler2)
.int_PAUSE
push hl
ld hl, _pause_flag
ld a, (hl)
xor a, 1
ld (hl), a
ld hl, pause_procs
jr int_handler
.int_handler
push af
push bc
push de
.int_loop
ld a, (hl)
inc hl
or (hl)
jr z, int_done
push hl
ld a, (hl)
dec hl
ld l, (hl)
ld h, a
call call_int_handler
pop hl
inc hl
jr int_loop
.int_done
pop de
pop bc
pop af
pop hl
ei
reti
.call_int_handler
jp (hl)
;-------
; Beginning of the actual code
;-------
.filler3
defs (CODE_Start - filler3)
.start
; Make room for the atexit() stack
ld hl,Stack_Top-64
ld sp,hl
; Clear static memory
ld hl,RAM_Start
ld de,RAM_Start+1
ld bc,RAM_Length-1
ld (hl),0
ldir
ld (exitsp),sp
IF !DEFINED_nostreams
IF DEFINED_ANSIstdio
; Set up the std* stuff so we can be called again
ld hl,__sgoioblk+2
ld (hl),19 ;stdin
ld hl,__sgoioblk+6
ld (hl),21 ;stdout
ld hl,__sgoioblk+10
ld (hl),21 ;stderr
ENDIF
ENDIF
ld hl,$8080
ld (fp_seed),hl
xor a
ld (exitcount),a
call DefaultInitialiseVDP
im 1
ei
; Entry to the user code
call _main
.cleanup
;
; Deallocate memory which has been allocated here!
;
push hl
IF !DEFINED_nostreams
IF DEFINED_ANSIstdio
LIB closeall
call closeall
ENDIF
ENDIF
.endloop
jr endloop
.l_dcal
jp (hl)
;---------------------------------
; VDP Initialization
;---------------------------------
.DefaultInitialiseVDP
push hl
push bc
ld hl,_Data
ld b,_End-_Data
ld c,$bf
otir
pop bc
pop hl
ret
DEFC SpriteSet = 0 ; 0 for sprites to use tiles 0-255, 1 for 256+
DEFC NameTableAddress = $3800 ; must be a multiple of $800; usually $3800; fills $700 bytes (unstretched)
DEFC SpriteTableAddress = $3f00 ; must be a multiple of $100; usually $3f00; fills $100 bytes
_Data:
defb @00000100,$80
; |||||||`- Disable synch
; ||||||`-- Enable extra height modes
; |||||`--- SMS mode instead of SG
; ||||`---- Shift sprites left 8 pixels
; |||`----- Enable line interrupts
; ||`------ Blank leftmost column for scrolling
; |`------- Fix top 2 rows during horizontal scrolling
; `-------- Fix right 8 columns during vertical scrolling
defb @10000100,$81
; |||| |`- Zoomed sprites -> 16x16 pixels
; |||| `-- Doubled sprites -> 2 tiles per sprite, 8x16
; |||`---- 30 row/240 line mode
; ||`----- 28 row/224 line mode
; |`------ Enable VBlank interrupts
; `------- Enable display
defb (NameTableAddress/2^10) |@11110001,$82
defb (SpriteTableAddress/2^7)|@10000001,$85
defb (SpriteSet/2^2) |@11111011,$86
defb $f|$f0,$87
; `-------- Border palette colour (sprite palette)
defb $00,$88
; ``------- Horizontal scroll
defb $00,$89
; ``------- Vertical scroll
defb $ff,$8a
; ``------- Line interrupt spacing ($ff to disable)
_End:
;---------------------------------
; Select which printf core we want
;---------------------------------
._vfprintf
IF DEFINED_floatstdio
LIB vfprintf_fp
jp vfprintf_fp
ELSE
IF DEFINED_complexstdio
LIB vfprintf_comp
jp vfprintf_comp
ELSE
IF DEFINED_ministdio
LIB vfprintf_mini
jp vfprintf_mini
ENDIF
ENDIF
ENDIF
; Static variables kept in safe workspace
DEFVARS RAM_Start
{
__sgoioblk ds.b 40 ;stdio control block
_std_seed ds.w 1 ;Integer seed
exitsp ds.w 1 ;atexit() stack
exitcount ds.b 1 ;Number of atexit() routines
fp_seed ds.w 3 ;Floating point seed (not used ATM)
extra ds.w 3 ;Floating point spare register
fa ds.w 3 ;Floating point accumulator
fasign ds.b 1 ;Floating point variable
heapblocks ds.w 1 ;Number of free blocks
heaplast ds.w 1 ;Pointer to linked blocks
fputc_vdp_offs ds.w 1 ;Current character pointer
aPLibMemory_bits ds.b 1 ;apLib support variable
aPLibMemory_byte ds.b 1 ;apLib support variable
aPLibMemory_LWM ds.b 1 ;apLib support variable
aPLibMemory_R0 ds.w 1 ;apLib support variable
raster_procs ds.w 8 ;Raster interrupt handlers
pause_procs ds.w 8 ;Pause interrupt handlers
timer ds.w 1 ;This is incremented every time a VBL/HBL interrupt happens
_pause_flag ds.b 1 ;This alternates between 0 and 1 every time pause is pressed
}
;--------
; Now, include the math routines if needed..
;--------
IF NEED_floatpack
; INCLUDE "#float.asm"
ENDIF
|
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "test_base.hpp"
namespace Azure { namespace Storage { namespace Test {
TEST_F(ClientSecretCredentialTest, ClientSecretCredentialWorks)
{
auto containerClient = GetClientForTest(GetTestName());
EXPECT_NO_THROW(containerClient.Create());
EXPECT_NO_THROW(containerClient.Delete());
}
}}} // namespace Azure::Storage::Test |
INCLUDE "graphics/grafix.inc"
SECTION code_graphics
PUBLIC plotpixel
EXTERN pixeladdress
EXTERN __gfx_coords
;
; $Id: plotpixl.asm,v 1.7 2016-07-02 09:01:35 dom Exp $
;
; ******************************************************************
;
; Plot pixel at (x,y) coordinate.
;
; Design & programming by Gunther Strube, Copyright (C) InterLogic 1995
;
; The (0,0) origin is placed at the top left corner.
;
; in: hl = (x,y) coordinate of pixel (h,l)
;
; registers changed after return:
; ..bc..../ixiy same
; af..dehl/.... different
;
.plotpixel
IF maxx <> 256
ld a,h
cp maxx
ret nc
ENDIF
ld a,l
cp maxy
ret nc ; y0 out of range
ld (__gfx_coords),hl
push bc
call pixeladdress
ld b,a
ld a,1
jr z, or_pixel ; pixel is at bit 0...
.plot_position rlca
djnz plot_position
.or_pixel ex de,hl
or (hl)
ld (hl),a
pop bc
ret
|
;------------------------------------------------------------------------------ ;
; Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Module Name:
;
; ExceptionHandlerAsm.Asm
;
; Abstract:
;
; x64 CPU Exception Handler
;
; Notes:
;
;------------------------------------------------------------------------------
;
; CommonExceptionHandler()
;
%define VC_EXCEPTION 29
extern ASM_PFX(mErrorCodeFlag) ; Error code flags for exceptions
extern ASM_PFX(mDoFarReturnFlag) ; Do far return flag
extern ASM_PFX(CommonExceptionHandler)
SECTION .data
DEFAULT REL
SECTION .text
ALIGN 8
AsmIdtVectorBegin:
%rep 32
db 0x6a ; push #VectorNum
db ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd - AsmIdtVectorBegin) / 32) ; VectorNum
push rax
mov rax, ASM_PFX(CommonInterruptEntry)
jmp rax
%endrep
AsmIdtVectorEnd:
HookAfterStubHeaderBegin:
db 0x6a ; push
@VectorNum:
db 0 ; 0 will be fixed
push rax
mov rax, HookAfterStubHeaderEnd
jmp rax
HookAfterStubHeaderEnd:
mov rax, rsp
and sp, 0xfff0 ; make sure 16-byte aligned for exception context
sub rsp, 0x18 ; reserve room for filling exception data later
push rcx
mov rcx, [rax + 8]
bt [ASM_PFX(mErrorCodeFlag)], ecx
jnc .0
push qword [rsp] ; push additional rcx to make stack alignment
.0:
xchg rcx, [rsp] ; restore rcx, save Exception Number in stack
push qword [rax] ; push rax into stack to keep code consistence
;---------------------------------------;
; CommonInterruptEntry ;
;---------------------------------------;
; The follow algorithm is used for the common interrupt routine.
; Entry from each interrupt with a push eax and eax=interrupt number
; Stack frame would be as follows as specified in IA32 manuals:
;
; +---------------------+ <-- 16-byte aligned ensured by processor
; + Old SS +
; +---------------------+
; + Old RSP +
; +---------------------+
; + RFlags +
; +---------------------+
; + CS +
; +---------------------+
; + RIP +
; +---------------------+
; + Error Code +
; +---------------------+
; + Vector Number +
; +---------------------+
; + RBP +
; +---------------------+ <-- RBP, 16-byte aligned
; The follow algorithm is used for the common interrupt routine.
global ASM_PFX(CommonInterruptEntry)
ASM_PFX(CommonInterruptEntry):
cli
pop rax
;
; All interrupt handlers are invoked through interrupt gates, so
; IF flag automatically cleared at the entry point
;
xchg rcx, [rsp] ; Save rcx into stack and save vector number into rcx
and rcx, 0xFF
cmp ecx, 32 ; Intel reserved vector for exceptions?
jae NoErrorCode
bt [ASM_PFX(mErrorCodeFlag)], ecx
jc HasErrorCode
NoErrorCode:
;
; Push a dummy error code on the stack
; to maintain coherent stack map
;
push qword [rsp]
mov qword [rsp + 8], 0
HasErrorCode:
push rbp
mov rbp, rsp
push 0 ; clear EXCEPTION_HANDLER_CONTEXT.OldIdtHandler
push 0 ; clear EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag
;
; Stack:
; +---------------------+ <-- 16-byte aligned ensured by processor
; + Old SS +
; +---------------------+
; + Old RSP +
; +---------------------+
; + RFlags +
; +---------------------+
; + CS +
; +---------------------+
; + RIP +
; +---------------------+
; + Error Code +
; +---------------------+
; + RCX / Vector Number +
; +---------------------+
; + RBP +
; +---------------------+ <-- RBP, 16-byte aligned
;
;
; Since here the stack pointer is 16-byte aligned, so
; EFI_FX_SAVE_STATE_X64 of EFI_SYSTEM_CONTEXT_x64
; is 16-byte aligned
;
;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax;
;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15;
push r15
push r14
push r13
push r12
push r11
push r10
push r9
push r8
push rax
push qword [rbp + 8] ; RCX
push rdx
push rbx
push qword [rbp + 48] ; RSP
push qword [rbp] ; RBP
push rsi
push rdi
;; UINT64 Gs, Fs, Es, Ds, Cs, Ss; insure high 16 bits of each is zero
movzx rax, word [rbp + 56]
push rax ; for ss
movzx rax, word [rbp + 32]
push rax ; for cs
mov rax, ds
push rax
mov rax, es
push rax
mov rax, fs
push rax
mov rax, gs
push rax
mov [rbp + 8], rcx ; save vector number
;; UINT64 Rip;
push qword [rbp + 24]
;; UINT64 Gdtr[2], Idtr[2];
xor rax, rax
push rax
push rax
sidt [rsp]
mov bx, word [rsp]
mov rax, qword [rsp + 2]
mov qword [rsp], rax
mov word [rsp + 8], bx
xor rax, rax
push rax
push rax
sgdt [rsp]
mov bx, word [rsp]
mov rax, qword [rsp + 2]
mov qword [rsp], rax
mov word [rsp + 8], bx
;; UINT64 Ldtr, Tr;
xor rax, rax
str ax
push rax
sldt ax
push rax
;; UINT64 RFlags;
push qword [rbp + 40]
;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8;
mov rax, cr8
push rax
mov rax, cr4
or rax, 0x208
mov cr4, rax
push rax
mov rax, cr3
push rax
mov rax, cr2
push rax
xor rax, rax
push rax
mov rax, cr0
push rax
;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
cmp qword [rbp + 8], VC_EXCEPTION
je VcDebugRegs ; For SEV-ES (#VC) Debug registers ignored
mov rax, dr7
push rax
mov rax, dr6
push rax
mov rax, dr3
push rax
mov rax, dr2
push rax
mov rax, dr1
push rax
mov rax, dr0
push rax
jmp DrFinish
VcDebugRegs:
;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7 are skipped for #VC to avoid exception recursion
xor rax, rax
push rax
push rax
push rax
push rax
push rax
push rax
DrFinish:
;; FX_SAVE_STATE_X64 FxSaveState;
sub rsp, 512
mov rdi, rsp
db 0xf, 0xae, 0x7 ;fxsave [rdi]
;; UEFI calling convention for x64 requires that Direction flag in EFLAGs is clear
cld
;; UINT32 ExceptionData;
push qword [rbp + 16]
;; Prepare parameter and call
mov rcx, [rbp + 8]
mov rdx, rsp
;
; Per X64 calling convention, allocate maximum parameter stack space
; and make sure RSP is 16-byte aligned
;
sub rsp, 4 * 8 + 8
mov rax, ASM_PFX(CommonExceptionHandler)
call rax
add rsp, 4 * 8 + 8
cli
;; UINT64 ExceptionData;
add rsp, 8
;; FX_SAVE_STATE_X64 FxSaveState;
mov rsi, rsp
db 0xf, 0xae, 0xE ; fxrstor [rsi]
add rsp, 512
;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
;; Skip restoration of DRx registers to support in-circuit emualators
;; or debuggers set breakpoint in interrupt/exception context
add rsp, 8 * 6
;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8;
pop rax
mov cr0, rax
add rsp, 8 ; not for Cr1
pop rax
mov cr2, rax
pop rax
mov cr3, rax
pop rax
mov cr4, rax
pop rax
mov cr8, rax
;; UINT64 RFlags;
pop qword [rbp + 40]
;; UINT64 Ldtr, Tr;
;; UINT64 Gdtr[2], Idtr[2];
;; Best not let anyone mess with these particular registers...
add rsp, 48
;; UINT64 Rip;
pop qword [rbp + 24]
;; UINT64 Gs, Fs, Es, Ds, Cs, Ss;
pop rax
; mov gs, rax ; not for gs
pop rax
; mov fs, rax ; not for fs
; (X64 will not use fs and gs, so we do not restore it)
pop rax
mov es, rax
pop rax
mov ds, rax
pop qword [rbp + 32] ; for cs
pop qword [rbp + 56] ; for ss
;; UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax;
;; UINT64 R8, R9, R10, R11, R12, R13, R14, R15;
pop rdi
pop rsi
add rsp, 8 ; not for rbp
pop qword [rbp + 48] ; for rsp
pop rbx
pop rdx
pop rcx
pop rax
pop r8
pop r9
pop r10
pop r11
pop r12
pop r13
pop r14
pop r15
mov rsp, rbp
pop rbp
add rsp, 16
cmp qword [rsp - 32], 0 ; check EXCEPTION_HANDLER_CONTEXT.OldIdtHandler
jz DoReturn
cmp qword [rsp - 40], 1 ; check EXCEPTION_HANDLER_CONTEXT.ExceptionDataFlag
jz ErrorCode
jmp qword [rsp - 32]
ErrorCode:
sub rsp, 8
jmp qword [rsp - 24]
DoReturn:
cmp qword [ASM_PFX(mDoFarReturnFlag)], 0 ; Check if need to do far return instead of IRET
jz DoIret
push rax
mov rax, rsp ; save old RSP to rax
mov rsp, [rsp + 0x20]
push qword [rax + 0x10] ; save CS in new location
push qword [rax + 0x8] ; save EIP in new location
push qword [rax + 0x18] ; save EFLAGS in new location
mov rax, [rax] ; restore rax
popfq ; restore EFLAGS
DB 0x48 ; prefix to composite "retq" with next "retf"
retf ; far return
DoIret:
iretq
;-------------------------------------------------------------------------------------
; GetTemplateAddressMap (&AddressMap);
;-------------------------------------------------------------------------------------
; comments here for definition of address map
global ASM_PFX(AsmGetTemplateAddressMap)
ASM_PFX(AsmGetTemplateAddressMap):
mov rax, AsmIdtVectorBegin
mov qword [rcx], rax
mov qword [rcx + 0x8], (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32
mov rax, HookAfterStubHeaderBegin
mov qword [rcx + 0x10], rax
ret
;-------------------------------------------------------------------------------------
; AsmVectorNumFixup (*NewVectorAddr, VectorNum, *OldVectorAddr);
;-------------------------------------------------------------------------------------
global ASM_PFX(AsmVectorNumFixup)
ASM_PFX(AsmVectorNumFixup):
mov rax, rdx
mov [rcx + (@VectorNum - HookAfterStubHeaderBegin)], al
ret
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.