Initial Alloy implementation.
This is a regression in functionality and performance, but a much better foundation for the future of the project (I think). It can run basic apps under an SSA interpreter but doesn't support some of the features required to do real 360 apps yet.
This commit is contained in:
51
src/alloy/tracing/channels/file_channel.cc
Normal file
51
src/alloy/tracing/channels/file_channel.cc
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include <alloy/tracing/channels/file_channel.h>
|
||||
|
||||
using namespace alloy;
|
||||
using namespace alloy::tracing;
|
||||
using namespace alloy::tracing::channels;
|
||||
|
||||
|
||||
FileChannel::FileChannel(const char* path) {
|
||||
lock_ = AllocMutex(10000);
|
||||
path_ = xestrdupa(path);
|
||||
file_ = fopen(path, "wb");
|
||||
}
|
||||
|
||||
FileChannel::~FileChannel() {
|
||||
LockMutex(lock_);
|
||||
fclose(file_);
|
||||
file_ = 0;
|
||||
free(path_);
|
||||
path_ = 0;
|
||||
UnlockMutex(lock_);
|
||||
FreeMutex(lock_);
|
||||
}
|
||||
|
||||
void FileChannel::Write(
|
||||
size_t buffer_count,
|
||||
size_t buffer_lengths[], const uint8_t* buffers[]) {
|
||||
LockMutex(lock_);
|
||||
if (file_) {
|
||||
for (size_t n = 0; n < buffer_count; n++) {
|
||||
fwrite(buffers[n], buffer_lengths[n], 1, file_);
|
||||
}
|
||||
}
|
||||
UnlockMutex(lock_);
|
||||
}
|
||||
|
||||
void FileChannel::Flush() {
|
||||
LockMutex(lock_);
|
||||
if (file_) {
|
||||
fflush(file_);
|
||||
}
|
||||
UnlockMutex(lock_);
|
||||
}
|
||||
46
src/alloy/tracing/channels/file_channel.h
Normal file
46
src/alloy/tracing/channels/file_channel.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2013 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef ALLOY_TRACING_CHANNELS_FILE_CHANNEL_H_
|
||||
#define ALLOY_TRACING_CHANNELS_FILE_CHANNEL_H_
|
||||
|
||||
#include <alloy/core.h>
|
||||
|
||||
#include <alloy/tracing/channel.h>
|
||||
|
||||
|
||||
namespace alloy {
|
||||
namespace tracing {
|
||||
namespace channels {
|
||||
|
||||
|
||||
class FileChannel : public Channel {
|
||||
public:
|
||||
FileChannel(const char* path);
|
||||
virtual ~FileChannel();
|
||||
|
||||
virtual void Write(
|
||||
size_t buffer_count,
|
||||
size_t buffer_lengths[], const uint8_t* buffers[]);
|
||||
|
||||
virtual void Flush();
|
||||
|
||||
private:
|
||||
char* path_;
|
||||
FILE* file_;
|
||||
Mutex* lock_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace channels
|
||||
} // namespace tracing
|
||||
} // namespace alloy
|
||||
|
||||
|
||||
#endif // ALLOY_TRACING_CHANNELS_FILE_CHANNEL_H_
|
||||
7
src/alloy/tracing/channels/sources.gypi
Normal file
7
src/alloy/tracing/channels/sources.gypi
Normal file
@@ -0,0 +1,7 @@
|
||||
# Copyright 2013 Ben Vanik. All Rights Reserved.
|
||||
{
|
||||
'sources': [
|
||||
'file_channel.cc',
|
||||
'file_channel.h',
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user