Commit Graph

4 Commits

Author SHA1 Message Date
Adam Simpkins
6c452184cb fix undefined behavior in bitmanipulation.h
Summary:
Previously some of this code had undefined behavior because it was performing
signed shifts that could overflow into the sign bit, as the result could not be
represented in a signed `int`.  This caused failures when built with UBSAN.

This updates the code to consistently use the built-in `_byteswap_*` functions
when compiling with Microsoft Visual Studio and the `__builtin_bswap*` when
compiling with gcc or clang.

Reviewed By: quark-zju

Differential Revision: D7008197

fbshipit-source-id: adbe22032f05a35468195922ee00ccc3ff5efff9
2018-04-13 21:51:13 -07:00
Augie Fackler
714a44cc5e bitmanipulation: reformat with clang-format
Mostly un-wrapping over-wrapped definitions.

Differential Revision: https://phab.mercurial-scm.org/D1069
2017-10-04 10:52:50 -04:00
Martin von Zweigbergk
4d9ae1bf1a bitmanipulation: add missing include of string.h
That's where memcpy() is declared.
2017-06-02 10:32:39 -07:00
Maciej Fijalkowski
8e7a874bdf internals: move the bitmanipulation routines into its own file
This is to allow more flexibility with the C sources -- now the
bitmanipulation routines can be safely imported without importing Python.h
2016-06-06 13:08:13 +02:00