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

Side by Side Diff: src/shared/platform/posix/nacl_error.c

Issue 788193003: Create a build_config header file. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 6 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2014 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "native_client/src/include/nacl_defines.h"
10 #include "native_client/src/shared/platform/nacl_error.h" 11 #include "native_client/src/shared/platform/nacl_error.h"
11 12
12 int NaClGetLastErrorString(char* buffer, size_t length) { 13 int NaClGetLastErrorString(char* buffer, size_t length) {
13 #if defined(__native_client__) || (NACL_LINUX && !NACL_ANDROID) 14 #if defined(__native_client__) || (NACL_LINUX && !NACL_ANDROID)
14 char* message; 15 char* message;
15 /* 16 /*
16 * Note some Linux distributions and newlib provide only the GNU version of 17 * Note some Linux distributions and newlib provide only the GNU version of
17 * strerror_r(). 18 * strerror_r().
18 */ 19 */
19 if (buffer == NULL || length == 0) { 20 if (buffer == NULL || length == 0) {
20 errno = ERANGE; 21 errno = ERANGE;
21 return -1; 22 return -1;
22 } 23 }
23 message = strerror_r(errno, buffer, length); 24 message = strerror_r(errno, buffer, length);
24 if (message != buffer) { 25 if (message != buffer) {
25 size_t message_bytes = strlen(message) + 1; 26 size_t message_bytes = strlen(message) + 1;
26 if (message_bytes < length) { 27 if (message_bytes < length) {
27 length = message_bytes; 28 length = message_bytes;
28 } 29 }
29 memmove(buffer, message, length); 30 memmove(buffer, message, length);
30 buffer[length - 1] = '\0'; 31 buffer[length - 1] = '\0';
31 } 32 }
32 return 0; 33 return 0;
33 #else 34 #else
34 return strerror_r(errno, buffer, length); 35 return strerror_r(errno, buffer, length);
35 #endif 36 #endif
36 } 37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698