Commit 8e34544b authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

Moved stdio and string functions to POSIX platform file.

Review URL: http://codereview.chromium.org/45063

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1626 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1a823e82
......@@ -83,69 +83,6 @@ void OS::Setup() {
}
FILE* OS::FOpen(const char* path, const char* mode) {
return fopen(path, mode);
}
void OS::Print(const char* format, ...) {
va_list args;
va_start(args, format);
VPrint(format, args);
va_end(args);
}
void OS::VPrint(const char* format, va_list args) {
vprintf(format, args);
}
void OS::PrintError(const char* format, ...) {
va_list args;
va_start(args, format);
VPrintError(format, args);
va_end(args);
}
void OS::VPrintError(const char* format, va_list args) {
vfprintf(stderr, format, args);
}
int OS::SNPrintF(Vector<char> str, const char* format, ...) {
va_list args;
va_start(args, format);
int result = VSNPrintF(str, format, args);
va_end(args);
return result;
}
int OS::VSNPrintF(Vector<char> str,
const char* format,
va_list args) {
int n = vsnprintf(str.start(), str.length(), format, args);
if (n < 0 || n >= str.length()) {
str[str.length() - 1] = '\0';
return -1;
} else {
return n;
}
}
char* OS::StrChr(char* str, int c) {
return strchr(str, c);
}
void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
strncpy(dest.start(), src, n);
}
double OS::nan_value() {
return NAN;
}
......
......@@ -81,69 +81,6 @@ void OS::Setup() {
}
FILE* OS::FOpen(const char* path, const char* mode) {
return fopen(path, mode);
}
void OS::Print(const char* format, ...) {
va_list args;
va_start(args, format);
VPrint(format, args);
va_end(args);
}
void OS::VPrint(const char* format, va_list args) {
vprintf(format, args);
}
void OS::PrintError(const char* format, ...) {
va_list args;
va_start(args, format);
VPrintError(format, args);
va_end(args);
}
void OS::VPrintError(const char* format, va_list args) {
vfprintf(stderr, format, args);
}
int OS::SNPrintF(Vector<char> str, const char* format, ...) {
va_list args;
va_start(args, format);
int result = VSNPrintF(str, format, args);
va_end(args);
return result;
}
int OS::VSNPrintF(Vector<char> str,
const char* format,
va_list args) {
int n = vsnprintf(str.start(), str.length(), format, args);
if (n < 0 || n >= str.length()) {
str[str.length() - 1] = '\0';
return -1;
} else {
return n;
}
}
char* OS::StrChr(char* str, int c) {
return strchr(str, c);
}
void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
strncpy(dest.start(), src, n);
}
double OS::nan_value() {
return NAN;
}
......
......@@ -86,69 +86,6 @@ void OS::Setup() {
}
FILE* OS::FOpen(const char* path, const char* mode) {
return fopen(path, mode);
}
void OS::Print(const char* format, ...) {
va_list args;
va_start(args, format);
VPrint(format, args);
va_end(args);
}
void OS::VPrint(const char* format, va_list args) {
vprintf(format, args);
}
void OS::PrintError(const char* format, ...) {
va_list args;
va_start(args, format);
VPrintError(format, args);
va_end(args);
}
void OS::VPrintError(const char* format, va_list args) {
vfprintf(stderr, format, args);
}
int OS::SNPrintF(Vector<char> str, const char* format, ...) {
va_list args;
va_start(args, format);
int result = VSNPrintF(str, format, args);
va_end(args);
return result;
}
int OS::VSNPrintF(Vector<char> str,
const char* format,
va_list args) {
int n = vsnprintf(str.start(), str.length(), format, args);
if (n < 0 || n >= str.length()) {
str[str.length() - 1] = '\0';
return -1;
} else {
return n;
}
}
char* OS::StrChr(char* str, int c) {
return strchr(str, c);
}
void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
strncpy(dest.start(), src, n);
}
// We keep the lowest and highest addresses mapped as a quick way of
// determining that pointers are outside the heap (used mostly in assertions
// and verification). The estimate is conservative, ie, not all addresses in
......
......@@ -104,6 +104,77 @@ double OS::LocalTimeOffset() {
}
// ----------------------------------------------------------------------------
// POSIX stdio support.
//
FILE* OS::FOpen(const char* path, const char* mode) {
return fopen(path, mode);
}
void OS::Print(const char* format, ...) {
va_list args;
va_start(args, format);
VPrint(format, args);
va_end(args);
}
void OS::VPrint(const char* format, va_list args) {
vprintf(format, args);
}
void OS::PrintError(const char* format, ...) {
va_list args;
va_start(args, format);
VPrintError(format, args);
va_end(args);
}
void OS::VPrintError(const char* format, va_list args) {
vfprintf(stderr, format, args);
}
int OS::SNPrintF(Vector<char> str, const char* format, ...) {
va_list args;
va_start(args, format);
int result = VSNPrintF(str, format, args);
va_end(args);
return result;
}
int OS::VSNPrintF(Vector<char> str,
const char* format,
va_list args) {
int n = vsnprintf(str.start(), str.length(), format, args);
if (n < 0 || n >= str.length()) {
str[str.length() - 1] = '\0';
return -1;
} else {
return n;
}
}
// ----------------------------------------------------------------------------
// POSIX string support.
//
char* OS::StrChr(char* str, int c) {
return strchr(str, c);
}
void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
strncpy(dest.start(), src, n);
}
// ----------------------------------------------------------------------------
// POSIX socket support.
//
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment