87c2d27fcf
Refactor code to have Platform::StrError(int error_code) on all platforms. Use that to get better error messages on Windows as well. BUG= TEST= Review URL: http://codereview.chromium.org//8511001 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1344 260f80e4-7a28-3924-810f-c04153c831b5
32 lines
813 B
C++
32 lines
813 B
C++
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "bin/platform.h"
|
|
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
|
|
int Platform::NumberOfProcessors() {
|
|
return sysconf(_SC_NPROCESSORS_ONLN);
|
|
}
|
|
|
|
|
|
const char* Platform::OperatingSystem() {
|
|
return "linux";
|
|
}
|
|
|
|
|
|
char* Platform::StrError(int error_code) {
|
|
static const int kBufferSize = 1024;
|
|
char* error = static_cast<char*>(malloc(kBufferSize));
|
|
error[0] = '\0';
|
|
char* error_str = strerror_r(error_code, error, kBufferSize);
|
|
if (error_str != error) {
|
|
size_t written = snprintf(error, kBufferSize, "%s", error_str);
|
|
ASSERT(written == strlen(error_str));
|
|
}
|
|
return error;
|
|
}
|