Fix compilation when compiler do not support __builtin_clz* #12573

pull 532479301 wants to merge 1 commits into bitcoin:master from 532479301:vs2017 changing 1 files +2 −2
  1. 532479301 commented at 9:23 am on March 1, 2018: contributor
    #ifdef is not correct since defination is defined to 0 or 1. Should change to #if
  2. Consensus: Fix bug when compiler do not support __builtin_clz*
    #ifdef is not correct since defination is defined to 0 or 1. Should change to #if
    18307849b4
  3. laanwj commented at 9:32 am on March 1, 2018: member

    This change seems to be correct. These macros are defined like this in src/config/bitcoin-config.h:

    0/* Define to 1 if you have the declaration of `__builtin_clzl', and to 0 if
    1   you don't. */
    2#define HAVE_DECL___BUILTIN_CLZL 0
    

    I’m curious why some defines in that file use #undef/#define and others #define XXX 0 versus #define XXX 1, but this is certainly the latter. That seems to be the cause of the confusion here (are there others?). Adding @theuni as reviewer.

  4. laanwj requested review from theuni on Mar 1, 2018
  5. laanwj added the label Build system on Mar 1, 2018
  6. laanwj renamed this:
    Consensus: Fix bug when compiler do not support __builtin_clz*
    Fix compilation when compiler do not support __builtin_clz*
    on Mar 1, 2018
  7. theuni approved
  8. theuni commented at 4:25 pm on March 5, 2018: member

    @laanwj Huh, yep, that’s really annoying. The docs even point out that the behavior is wonky: https://www.gnu.org/software/autoconf/manual/autoconf-2.62/html_node/Generic-Declarations.html

    I confirmed that we manage to get the others right, though to be 100% safe in the non-autoconf case (msvc builds that don’t use a config.h, for example) we would need to use a construct like #if defined(foo) && foo.

    utACK 18307849b405f9e2067eaa8091b105838f413707

  9. fanquake commented at 5:37 pm on March 5, 2018: member
    utACK 1830784
  10. laanwj commented at 5:38 pm on March 5, 2018: member

    we would need to use a construct like #if defined(foo) && foo.

    I think using #if X is better in that case. At least it will fail when X is not defined, which aids in discoverability of the option.

  11. laanwj merged this on Mar 5, 2018
  12. laanwj closed this on Mar 5, 2018

  13. laanwj referenced this in commit cbc1fcf576 on Mar 5, 2018
  14. luke-jr referenced this in commit 0951b70fb4 on Mar 8, 2018
  15. MarcoFalke referenced this in commit da0afd021a on Apr 20, 2018
  16. MarcoFalke referenced this in commit e4c8f44685 on May 24, 2018
  17. MarcoFalke referenced this in commit 2be19e1330 on May 24, 2018
  18. MarcoFalke referenced this in commit 5e3b8c8426 on May 29, 2018
  19. MarcoFalke referenced this in commit 88d1a649a2 on Jul 13, 2018
  20. HashUnlimited referenced this in commit 4445ff5a26 on Jan 11, 2019
  21. PastaPastaPasta referenced this in commit ab07102bc8 on Apr 12, 2020
  22. PastaPastaPasta referenced this in commit 8929e68a89 on Apr 16, 2020
  23. PastaPastaPasta referenced this in commit 2a3df4d54c on Apr 16, 2020
  24. jasonbcox referenced this in commit fb25120158 on Oct 31, 2020
  25. ckti referenced this in commit 4d0b2ed24b on Mar 28, 2021
  26. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-18 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me