Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build on FreeBSD/powerpc #616

Merged
merged 4 commits into from Feb 25, 2020
Merged

Fix build on FreeBSD/powerpc #616

merged 4 commits into from Feb 25, 2020

Conversation

kgotlinux
Copy link
Contributor

Only glibc has __ppc_get_timebase(), __ppc_get_timebase_freq() and sys/platform/ppc.h. For TBR and TBR frequency, FreeBSD doesn't have equivalent functions.

Only glibc has __ppc_get_timebase(), __ppc_get_timebase_freq() and sys/platform/ppc.h.
return __ppc_get_timebase();
#elif defined(__FreeBSD__)
union { long long complete; unsigned int part[2]; } ticks;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though you sometimes see it, type-punning through a union is undefined behavior in C++. See https://adriann.github.io/undefined_behavior.html for example.

#elif defined(__FreeBSD__)
double timebaseFrequency = 0;
size_t length = sizeof(timebaseFrequency);
sysctlbyname("kern.timecounter.tc.timebase.frequency", &timebaseFrequency, &length, NULL, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you cache this value using some sort of "once" initialization? I don't think Abseil calls the code at all, but other (internal) code calls it very often.

For various reasons you'll need to use absl::base_internal::LowLevelCallOnce in this context.

template <typename Callable, typename... Args>
void LowLevelCallOnce(absl::once_flag* flag, Callable&& fn, Args&&... args) {
std::atomic<uint32_t>* once = base_internal::ControlWord(flag);
uint32_t s = once->load(std::memory_order_acquire);
if (ABSL_PREDICT_FALSE(s != base_internal::kOnceDone)) {
base_internal::CallOnceImpl(once, base_internal::SCHEDULE_KERNEL_ONLY,
std::forward<Callable>(fn),
std::forward<Args>(args)...);
}
}

return __ppc_get_timebase_freq();
#elif defined(__FreeBSD__)
double timebaseFrequency = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://google.github.io/styleguide/cppguide.html#Variable_Names

Variable names are lower-case with underscore in Google C++ style.

return __ppc_get_timebase();
#elif defined(__FreeBSD__)
union { long long complete; unsigned int part[2]; } ticks;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://google.github.io/styleguide/cppguide.html#Integer_Types

This is a case where you should use fixed-width integer types like int64_t.

1. Add optimized version for powerpc64.
2. Cache timebase_frequency.
@kgotlinux
Copy link
Contributor Author

Please check if it's ok now.

absl/base/internal/unscaledcycleclock.cc Outdated Show resolved Hide resolved
absl/base/internal/unscaledcycleclock.cc Outdated Show resolved Hide resolved
absl/base/internal/unscaledcycleclock.cc Show resolved Hide resolved
@derekmauro
Copy link
Member

I pushed changes to your branch to resolve the comments.

@derekmauro derekmauro merged commit 0033c9e into abseil:master Feb 25, 2020
absl-federation-github pushed a commit that referenced this pull request Feb 25, 2020
  - 0033c9e Fix build on FreeBSD/powerpc (#616) by kgotlinux <60880393+kgotlinux@users.noreply.github.com>
  - 0d5ce27 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - b69c7d8 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 2a5633f Merge "Export of internal Abseil changes" by Xiaoyi Zhang <zhangxy@google.com>
  - f9b3d6e Add RISCV support to GetProgramCounter() (#621) by Khem Raj <raj.khem@gmail.com>
  - 0232c87 Add missing ABSL_HAVE_VDSO_SUPPORT conditional (#622) by Sinan Kaya <41809318+franksinankaya@users.noreply.github.com>
  - 3c81410 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - c44657f Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 98eb410 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - bf78e97 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - d95d156 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 24713a7 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 72382c2 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 08a7e7b Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 36bcd95 Fix pointer format specifier in documentation (#614) by Andre Nguyen <andre-nguyen@users.noreply.github.com>
  - 0f86336 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - c512f11 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 37dd256 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 4442770 fix: Add support for more ARM processors detection (#608) by Andre Nguyen <andre-nguyen@users.noreply.github.com>
  - 159bf2b Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - a2e6ade Use https links. (#586) by nlewycky <nicholas@mxc.ca>
  - 564001a Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - b3aaac8 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 63ee2f8 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - a048203 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 1de0166 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - ad904b6 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 2923513 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - bf86cfe Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 12bc53e Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 1e39f86 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 77f8700 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - d659fe5 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - a4b757b Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 0514227 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 7f4fe64 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 16d9fd5 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - bcaae60 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 8ba96a8 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 2103fd9 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 3df7b52 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - fa8c751 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 85092b4 Fix Conan builds (#400) by Adrian Ostrowski <adr.ostrowski@gmail.com>
  - e96ae22 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 20de2db Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 846e5db Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 8207907 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 078b89b Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 19b021c Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - ecc0033 Always enable proper symbolize implementation on Windows ... by Loo Rong Jie <loorongjie@gmail.com>
  - 2796d50 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - e4c8d0e Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - a15364c Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - ab3552a Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - e9f9000 Fix ABSL_WAITER_MODE detection for mingw (#342) by Joe Sylve <Joe.Sylve@gmail.com>
  - abea769 Fix ABSL_HAVE_ALARM check on mingw (#341) by Joe Sylve <Joe.Sylve@gmail.com>
  - 25597bd Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - aad33fe Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 8fe7214 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - debac94 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 882b350 Fix spelling errors (#384) by Sungmann Cho <55860394+chosungmann@users.noreply.github.com>
  - 502efe6 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - ccdd1d5 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - ddf8e52 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 6ec1362 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - ac78ffc Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 5374c56 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 97c1664 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 325fd7b Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 83c1d65 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - eb6b7bd Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 9ddac55 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 1948f6f Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - a0d1e09 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 2d2d7fb Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 0302d1e supppress unused variable warning for gcc (#372) by Martin <pizzard@users.noreply.github.com>
  - 262d74b Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - f0afae0 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 0e7afdc Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 9a41ffd Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 36910d3 [bazel] Add fixes for --incompatible_load_cc_rules_from_b... by Yannic <contact@yannic-bonenberger.com>
  - aae8143 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - d9aa92d Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 321ab53 Export of internal Abseil changes by Abseil Team <absl-team@google.com>
  - 4ef5740 Export of internal Abseil changes by Abseil Team <absl-team@google.com>

GitOrigin-RevId: 0033c9e
Change-Id: I8a2b70063cb3ab40c6943a6db0fe40cae71ed8d7
absl-federation-github pushed a commit that referenced this pull request Feb 28, 2020
--
09c1e7877210fe85c43631538303af801c233e89 by Gennadiy Rozental <rogeeff@google.com>:

Change CordRep::length to size_t to be compatible with ChunkIterator.

PiperOrigin-RevId: 297901255

--
226d5e79fb4e20fb09d75f034624d5be770f4ece by Derek Mauro <dmauro@google.com>:

Makes absl::string_view::substr constexpr for std::string_view compatibility
Fixes #627

PiperOrigin-RevId: 297872778

--
851aa24a22d0ba5552098bf7e5735c95e4a8d4f7 by Abseil Team <absl-team@google.com>:

Reformat one line.

PiperOrigin-RevId: 297839574

--
4f449c462583797455375fa6f1365a6b2cfa7e0a by Benjamin Barenblat <bbaren@google.com>:

Internal change

PiperOrigin-RevId: 297677173

--
2d41a250e9a8f272946bc3262463e4025d88fba3 by Abseil Team <absl-team@google.com>:

Internal change

PiperOrigin-RevId: 297537076

--
6e7fbe1e90999a58556d41955bef44033c61876c by Gennadiy Rozental <rogeeff@google.com>:

Internal change

PiperOrigin-RevId: 297376994

--
5acf79338191b31cec158b06cd96ca8dfa3e81fe by Derek Mauro <dmauro@google.com>:

Add a debug-mode bounds-check on absl::Span::operator[].

PiperOrigin-RevId: 297355826

--
1c540d06a56c7e92bb07b90f16b4e00b014ef18f by CJ Johnson <johnsoncj@google.com>:

Adding new LTS to the list

PiperOrigin-RevId: 297235265

--
696ce48bea6927436ff89f59b887e5869b1b0f38 by Derek Mauro <dmauro@google.com>:

Fix build on FreeBSD/powerpc (implement UnscaledCycleClock)

Merges/Fixes GitHub #616

PiperOrigin-RevId: 297188640
GitOrigin-RevId: 09c1e7877210fe85c43631538303af801c233e89
Change-Id: I5d97b16bb6378792d2fcf7d29080cca18aa7729a
rongjiecomputer pushed a commit to rongjiecomputer/abseil-cpp that referenced this pull request Oct 8, 2020
* Fix build on FreeBSD/powerpc

Only glibc has __ppc_get_timebase(), __ppc_get_timebase_freq() and sys/platform/ppc.h.
rongjiecomputer pushed a commit to rongjiecomputer/abseil-cpp that referenced this pull request Oct 8, 2020
--
09c1e7877210fe85c43631538303af801c233e89 by Gennadiy Rozental <rogeeff@google.com>:

Change CordRep::length to size_t to be compatible with ChunkIterator.

PiperOrigin-RevId: 297901255

--
226d5e79fb4e20fb09d75f034624d5be770f4ece by Derek Mauro <dmauro@google.com>:

Makes absl::string_view::substr constexpr for std::string_view compatibility
Fixes abseil#627

PiperOrigin-RevId: 297872778

--
851aa24a22d0ba5552098bf7e5735c95e4a8d4f7 by Abseil Team <absl-team@google.com>:

Reformat one line.

PiperOrigin-RevId: 297839574

--
4f449c462583797455375fa6f1365a6b2cfa7e0a by Benjamin Barenblat <bbaren@google.com>:

Internal change

PiperOrigin-RevId: 297677173

--
2d41a250e9a8f272946bc3262463e4025d88fba3 by Abseil Team <absl-team@google.com>:

Internal change

PiperOrigin-RevId: 297537076

--
6e7fbe1e90999a58556d41955bef44033c61876c by Gennadiy Rozental <rogeeff@google.com>:

Internal change

PiperOrigin-RevId: 297376994

--
5acf79338191b31cec158b06cd96ca8dfa3e81fe by Derek Mauro <dmauro@google.com>:

Add a debug-mode bounds-check on absl::Span::operator[].

PiperOrigin-RevId: 297355826

--
1c540d06a56c7e92bb07b90f16b4e00b014ef18f by CJ Johnson <johnsoncj@google.com>:

Adding new LTS to the list

PiperOrigin-RevId: 297235265

--
696ce48bea6927436ff89f59b887e5869b1b0f38 by Derek Mauro <dmauro@google.com>:

Fix build on FreeBSD/powerpc (implement UnscaledCycleClock)

Merges/Fixes GitHub abseil#616

PiperOrigin-RevId: 297188640
GitOrigin-RevId: 09c1e7877210fe85c43631538303af801c233e89
Change-Id: I5d97b16bb6378792d2fcf7d29080cca18aa7729a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants