Skip to content

Commit

Permalink
Fixes in base for [P]NaCl port of remoting client
Browse files Browse the repository at this point in the history
Various minor fixes in base needed for [P]NaCl port of remoting client:
  - added base_i18n_untrusted target
  - md5 is included in base_untrusted.
  - base/metrics is compiled in base_untrusted (src/net depends on it).
  - enabled PNaCl build of base_untrusted
  - __builtin_extract_return_addr() is not allowed in PNaCl (validator
    rejects it).
  - sys_byteorder.h now works in NaCl.

BUG=276739

Review URL: https://codereview.chromium.org/116803005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@242270 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
sergeyu@chromium.org committed Dec 21, 2013
1 parent 2e5f3a0 commit 9e18f3e
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 88 deletions.
41 changes: 3 additions & 38 deletions base/base.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,6 @@
'event_recorder_win.cc',
'linux_util.cc',
'linux_util.h',
'md5.cc',
'md5.h',
'message_loop/message_pump_android.cc',
'message_loop/message_pump_android.h',
'message_loop/message_pump_glib.cc',
Expand Down Expand Up @@ -287,6 +285,7 @@
'variables': {
'enable_wexit_time_destructors': 1,
'optimize': 'max',
'base_i18n_target': 1,
},
'dependencies': [
'base',
Expand All @@ -311,42 +310,8 @@
'export_dependent_settings': [
'base',
],
'defines': [
'BASE_I18N_IMPLEMENTATION',
],
'sources': [
'i18n/base_i18n_export.h',
'i18n/bidi_line_iterator.cc',
'i18n/bidi_line_iterator.h',
'i18n/break_iterator.cc',
'i18n/break_iterator.h',
'i18n/char_iterator.cc',
'i18n/char_iterator.h',
'i18n/case_conversion.cc',
'i18n/case_conversion.h',
'i18n/file_util_icu.cc',
'i18n/file_util_icu.h',
'i18n/i18n_constants.cc',
'i18n/i18n_constants.h',
'i18n/icu_encoding_detection.cc',
'i18n/icu_encoding_detection.h',
'i18n/icu_string_conversions.cc',
'i18n/icu_string_conversions.h',
'i18n/icu_util.cc',
'i18n/icu_util.h',
'i18n/number_formatting.cc',
'i18n/number_formatting.h',
'i18n/rtl.cc',
'i18n/rtl.h',
'i18n/string_compare.cc',
'i18n/string_compare.h',
'i18n/string_search.cc',
'i18n/string_search.h',
'i18n/time_formatting.cc',
'i18n/time_formatting.h',
'i18n/timezone.cc',
'i18n/timezone.h',
],


},
{
'target_name': 'base_message_loop_tests',
Expand Down
43 changes: 41 additions & 2 deletions base/base.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'target_defaults': {
'variables': {
'base_target': 0,
'base_i18n_target': 0,
},
'target_conditions': [
# This part is shared between the targets defined below.
Expand Down Expand Up @@ -291,6 +292,8 @@
'mac/scoped_sending_event.h',
'mac/scoped_sending_event.mm',
'mac/sdk_forward_declarations.h',
'md5.cc',
'md5.h',
'memory/aligned_memory.cc',
'memory/aligned_memory.h',
'memory/discardable_memory.h',
Expand Down Expand Up @@ -772,8 +775,6 @@
'third_party/dynamic_annotations/dynamic_annotations.c',
],
'sources/': [
# Metrics won't work in the NaCl sandbox.
['exclude', '^metrics/'],
['include', '^threading/platform_thread_linux\\.cc$'],
],
}],
Expand Down Expand Up @@ -949,6 +950,44 @@
}],
],
}],
['base_i18n_target==1', {
'defines': [
'BASE_I18N_IMPLEMENTATION',
],
'sources': [
'i18n/base_i18n_export.h',
'i18n/bidi_line_iterator.cc',
'i18n/bidi_line_iterator.h',
'i18n/break_iterator.cc',
'i18n/break_iterator.h',
'i18n/char_iterator.cc',
'i18n/char_iterator.h',
'i18n/case_conversion.cc',
'i18n/case_conversion.h',
'i18n/file_util_icu.cc',
'i18n/file_util_icu.h',
'i18n/i18n_constants.cc',
'i18n/i18n_constants.h',
'i18n/icu_encoding_detection.cc',
'i18n/icu_encoding_detection.h',
'i18n/icu_string_conversions.cc',
'i18n/icu_string_conversions.h',
'i18n/icu_util.cc',
'i18n/icu_util.h',
'i18n/number_formatting.cc',
'i18n/number_formatting.h',
'i18n/rtl.cc',
'i18n/rtl.h',
'i18n/string_compare.cc',
'i18n/string_compare.h',
'i18n/string_search.cc',
'i18n/string_search.h',
'i18n/time_formatting.cc',
'i18n/time_formatting.h',
'i18n/timezone.cc',
'i18n/timezone.h',
],
}]
],
},
}
27 changes: 27 additions & 0 deletions base/base_untrusted.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
'build_glibc': 1,
'build_newlib': 1,
'build_irt': 1,
'build_pnacl_newlib': 1,
'sources': [
'base_switches.cc',
'base_switches.h',
Expand All @@ -35,6 +36,32 @@
'<(DEPTH)/native_client/tools.gyp:prep_toolchain',
],
},
{
'target_name': 'base_i18n_untrusted',
'type': 'none',
'variables': {
'base_i18n_target': 1,
'nacl_untrusted_build': 1,
'nlib_target': 'libbase_i18n_untrusted.a',
'build_glibc': 0,
'build_newlib': 1,
'build_irt': 0,
'build_pnacl_newlib': 1,
'sources': [
'base_switches.cc',
'base_switches.h',
'strings/string16.cc',
'sync_socket_nacl.cc',
'time/time_posix.cc',
],
},
'dependencies': [
'<(DEPTH)/third_party/icu/icu_untrusted.gyp:icudata_untrusted',
'<(DEPTH)/third_party/icu/icu_untrusted.gyp:icui18n_untrusted',
'<(DEPTH)/third_party/icu/icu_untrusted.gyp:icuuc_untrusted',
'<(DEPTH)/native_client/tools.gyp:prep_toolchain',
],
},
],
}],
],
Expand Down
3 changes: 1 addition & 2 deletions base/location.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ __declspec(noinline)
BASE_EXPORT const void* GetProgramCounter() {
#if defined(COMPILER_MSVC)
return _ReturnAddress();
#elif defined(COMPILER_GCC)
#elif defined(COMPILER_GCC) && !defined(OS_NACL)
return __builtin_extract_return_addr(__builtin_return_address(0));
#endif // COMPILER_GCC

return NULL;
}

Expand Down
58 changes: 13 additions & 45 deletions base/sys_byteorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,59 +20,27 @@
#include <arpa/inet.h>
#endif

// Include headers to provide byteswap for all platforms.
#if defined(COMPILER_MSVC)
#include <stdlib.h>
#elif defined(OS_MACOSX)
#include <libkern/OSByteOrder.h>
#elif defined(OS_BSD)
#include <sys/endian.h>
#else
#include <byteswap.h>
#endif


namespace base {

// Returns a value with all bytes in |x| swapped, i.e. reverses the endianness.
inline uint16 ByteSwap(uint16 x) {
#if defined(COMPILER_MSVC)
return _byteswap_ushort(x);
#elif defined(OS_MACOSX)
return OSSwapInt16(x);
#elif defined(OS_OPENBSD)
return swap16(x);
#elif defined(OS_FREEBSD)
return bswap16(x);
#else
return bswap_16(x);
#endif
return ((x & 0x00ff) << 8) | ((x & 0xff00) >> 8);
}

inline uint32 ByteSwap(uint32 x) {
#if defined(COMPILER_MSVC)
return _byteswap_ulong(x);
#elif defined(OS_MACOSX)
return OSSwapInt32(x);
#elif defined(OS_OPENBSD)
return swap32(x);
#elif defined(OS_FREEBSD)
return bswap32(x);
#else
return bswap_32(x);
#endif
return ((x & 0x000000fful) << 24) | ((x & 0x0000ff00ul) << 8) |
((x & 0x00ff0000ul) >> 8) | ((x & 0xff000000ul) >> 24);
}

inline uint64 ByteSwap(uint64 x) {
#if defined(COMPILER_MSVC)
return _byteswap_uint64(x);
#elif defined(OS_MACOSX)
return OSSwapInt64(x);
#elif defined(OS_OPENBSD)
return swap64(x);
#elif defined(OS_FREEBSD)
return bswap64(x);
#else
return bswap_64(x);
#endif
return ((x & 0x00000000000000ffull) << 56) |
((x & 0x000000000000ff00ull) << 40) |
((x & 0x0000000000ff0000ull) << 24) |
((x & 0x00000000ff000000ull) << 8) |
((x & 0x000000ff00000000ull) >> 8) |
((x & 0x0000ff0000000000ull) >> 24) |
((x & 0x00ff000000000000ull) >> 40) |
((x & 0xff00000000000000ull) >> 56);
}

// Converts the bytes in |x| from host order (endianness) to little endian, and
Expand Down
2 changes: 1 addition & 1 deletion base/third_party/nspr/prcpucfg_nacl.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3

#elif defined(__i386__)
#elif defined(__i386__) || defined(__pnacl__)

#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
Expand Down

0 comments on commit 9e18f3e

Please sign in to comment.