Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(995)

Unified Diff: src/utils.h

Issue 18842: Experimental: periodic merge of the bleeding_edge branch to the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/usage-analyzer.cc ('k') | src/utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils.h
===================================================================
--- src/utils.h (revision 1168)
+++ src/utils.h (working copy)
@@ -224,10 +224,10 @@
char* ReadLine(const char* prompt);
-// Read and return the raw chars in a file. the size of the buffer is returned
+// Read and return the raw bytes in a file. the size of the buffer is returned
// in size.
-// The returned buffer is not 0-terminated. It must be freed by the caller.
-char* ReadChars(const char* filename, int* size, bool verbose = true);
+// The returned buffer must be freed by the caller.
+byte* ReadBytes(const char* filename, int* size, bool verbose = true);
// Write size chars from str to the file given by filename.
@@ -238,6 +238,14 @@
bool verbose = true);
+// Write size bytes to the file given by filename.
+// The file is overwritten. Returns the number of bytes written.
+int WriteBytes(const char* filename,
+ const byte* bytes,
+ int size,
+ bool verbose = true);
+
+
// Write the C code
// const char* <varname> = "<str>";
// const int <varname>_len = <len>;
@@ -421,7 +429,7 @@
// Simple support to read a file into a 0-terminated C-string.
// The returned buffer must be freed by the caller.
-// On return, *exits tells whether the file exisited.
+// On return, *exits tells whether the file existed.
Vector<const char> ReadFile(const char* filename,
bool* exists,
bool verbose = true);
@@ -527,55 +535,6 @@
}
-static inline int Load16(const byte* ptr) {
-#ifdef CAN_READ_UNALIGNED
- return *reinterpret_cast<const uint16_t*>(ptr);
-#else
- uint32_t word;
- word = ptr[1];
- word |= ptr[0] << 8;
- return word;
-#endif
-}
-
-
-static inline int Load32(const byte* ptr) {
-#ifdef CAN_READ_UNALIGNED
- return *reinterpret_cast<const uint32_t*>(ptr);
-#else
- uint32_t word;
- word = ptr[3];
- word |= ptr[2] << 8;
- word |= ptr[1] << 16;
- word |= ptr[0] << 24;
- return word;
-#endif
-}
-
-
-static inline void Store16(byte* ptr, uint16_t value) {
-#ifdef CAN_READ_UNALIGNED
- *reinterpret_cast<uint16_t*>(ptr) = value;
-#else
- // Cast to avoid warning C4244 when compiling with Microsoft Visual C++.
- ptr[1] = static_cast<byte>(value);
- ptr[0] = value >> 8;
-#endif
-}
-
-
-static inline void Store32(byte* ptr, uint32_t value) {
-#ifdef CAN_READ_UNALIGNED
- *reinterpret_cast<uint32_t*>(ptr) = value;
-#else
- ptr[3] = value;
- ptr[2] = value >> 8;
- ptr[1] = value >> 16;
- ptr[0] = value >> 24;
-#endif
-}
-
-
} } // namespace v8::internal
#endif // V8_UTILS_H_
« no previous file with comments | « src/usage-analyzer.cc ('k') | src/utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698