Closed Bug 1531244 Opened 5 years ago Closed 5 years ago

Use __builtin_bswap64 in crypto_primitives.h

Categories

(NSS :: Libraries, enhancement)

ARM64
Android
enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: m_kato, Assigned: m_kato)

References

Details

Attachments

(1 file)

FREEBL_HTONLL dones't use builtin function when using gcc/clang on non-x86_64.

https://treeherder.mozilla.org/#/jobs?repo=nss-try&revision=768ef2cdd422c5d95c943852311719f3a958325c

Summary: Use __builtin_bswap64 in → Use __builtin_bswap64 in crypto_primitives.h

FREEBL_HTONLL dones't use builtin function when using gcc/clang on non-x86_64.
If __builtin_bswap64 is available, we should use it.

Depends on: 1536734

Though I've set Bug 15356734 as blocking this, I've landed these changes. They are an improvement and you aren't really responsible for the other bug.

https://hg.mozilla.org/projects/nss/rev/ca1e52ef02de3551713bd5cde0514580699248d5

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 3.44

This change broke GCC build (on SPARC). GCC doesn't implement __has_builtin yet (see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66970). But it still supports __builtin_bswap64. For now I have workaround it with:

-#define __has_builtin(x) 0
+#define __has_builtin(x) 1

Any suggestion for proper fix?

Oh yeah, that's unfortunate. We should be using the builtin with GCC too. The fix I can think of is to check for GCC version explicitly:

-#elif __has_builtin(__builtin_bswap64)
+#elif __has_builtin(__builtin_bswap64) || defined(GNUC) && GNUC > 4 || (GNUC == 4 && GNUC_MINOR >= 3)

According to the gcc docs, this builtin was added in GCC 4.3.

m_kato, does that look right to you?

Flags: needinfo?(m_kato)

(In reply to Martin Thomson [:mt:] from comment #4)

Oh yeah, that's unfortunate. We should be using the builtin with GCC too. The fix I can think of is to check for GCC version explicitly:

-#elif __has_builtin(__builtin_bswap64)
+#elif __has_builtin(__builtin_bswap64) || defined(GNUC) && GNUC > 4 || (GNUC == 4 && GNUC_MINOR >= 3)

According to the gcc docs, this builtin was added in GCC 4.3.

m_kato, does that look right to you?

Yes, right. GCC 4.3+ supports __builtin_bswap64.

Flags: needinfo?(m_kato)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: