[llvm-commits] CVS: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
Misha Brukman
brukman at cs.uiuc.edu
Wed Sep 24 17:05:00 PDT 2003
Changes in directory llvm/lib/Bytecode/Reader:
ReaderWrappers.cpp updated: 1.5 -> 1.6
---
Log message:
* Eliminate BytecodeBufferReader::Length member variable
* Kill unused ALIN_PTRS #define
* Set the error string if user passed it in to be compatible with former API
---
Diffs of the changes:
Index: llvm/lib/Bytecode/Reader/ReaderWrappers.cpp
diff -u llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.5 llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.6
--- llvm/lib/Bytecode/Reader/ReaderWrappers.cpp:1.5 Tue Sep 23 16:19:11 2003
+++ llvm/lib/Bytecode/Reader/ReaderWrappers.cpp Wed Sep 24 17:04:02 2003
@@ -76,7 +76,6 @@
class BytecodeBufferReader : public BytecodeParser {
private:
const unsigned char *Buffer;
- int Length;
bool MustDelete;
BytecodeBufferReader(const BytecodeBufferReader&); // Do not implement
@@ -91,26 +90,23 @@
}
BytecodeBufferReader::BytecodeBufferReader(const unsigned char *Buf,
- unsigned Len,
+ unsigned Length,
const std::string &ModuleID)
{
// If not aligned, allocate a new buffer to hold the bytecode...
const unsigned char *ParseBegin = 0;
- unsigned Offset = 0;
if ((intptr_t)Buf & 3) {
- Length = Len+4;
- Buffer = new unsigned char[Length];
- Offset = 4 - ((intptr_t)Buf & 3); // Make sure it's aligned
+ Buffer = new unsigned char[Length+4];
+ unsigned Offset = 4 - ((intptr_t)Buf & 3); // Make sure it's aligned
ParseBegin = Buffer + Offset;
- memcpy((unsigned char*)ParseBegin, Buf, Len); // Copy it over
+ memcpy((unsigned char*)ParseBegin, Buf, Length); // Copy it over
MustDelete = true;
} else {
// If we don't need to copy it over, just use the caller's copy
ParseBegin = Buffer = Buf;
- Length = Len;
MustDelete = false;
}
- ParseBytecode(ParseBegin, Len, ModuleID);
+ ParseBytecode(ParseBegin, Length, ModuleID);
}
BytecodeBufferReader::~BytecodeBufferReader() {
@@ -131,12 +127,9 @@
public:
BytecodeStdinReader();
- ~BytecodeStdinReader();
};
}
-#define ALIGN_PTRS 0
-
BytecodeStdinReader::BytecodeStdinReader() {
int BlockSize;
unsigned char Buffer[4096*4];
@@ -152,24 +145,10 @@
if (FileData.empty())
throw std::string("Standard Input empty!");
-#if ALIGN_PTRS
- FileBuf = (unsigned char*)mmap(0, FileData.size(), PROT_READ|PROT_WRITE,
- MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
- assert((Buf != (unsigned char*)-1) && "mmap returned error!");
- memcpy(Buf, &FileData[0], FileData.size());
-#else
FileBuf = &FileData[0];
-#endif
-
ParseBytecode(FileBuf, FileData.size(), "<stdin>");
}
-BytecodeStdinReader::~BytecodeStdinReader() {
-#if ALIGN_PTRS
- munmap((char*)FileBuf, FileData.size()); // Free mmap'd data area
-#endif
-}
-
/////////////////////////////////////////////////////////////////////////////
//
// Wrapper functions
@@ -195,6 +174,7 @@
M = AMP->releaseModule();
delete AMP;
} catch (std::string &err) {
+ if (ErrorStr) ErrorStr = err;
return 0;
}
return M;
@@ -219,6 +199,7 @@
M = AMP->releaseModule();
delete AMP;
} catch (std::string &err) {
+ if (ErrorStr) ErrorStr = err;
return 0;
}
return M;
More information about the llvm-commits
mailing list