[WIP] Refactoring platform-specific code in util.h/util.cpp #13209

pull glaksmono wants to merge 1 commits into bitcoin:master from glaksmono:bitcoin-12697 changing 100 files +450 −243
  1. glaksmono commented at 12:27 PM on May 10, 2018: contributor

    Take all of the functions that are specific to Windows or Unix, and create a common set of methods in a new header file, all combined in the src/util/ folder.

    The goal of this PR is to break src/util.cpp and src/util.h into the following files:

    For Across Platform:

    • src/util/platform_common.h
    • src/util/platform_common.cpp

    For Windows:

    • src/util/platform_windows.cpp

    For Mac & Linux:

    • src/util/platform_posix.cpp

    Issue Reference: #12697

    Discussion

    1. How should we handle "duplicate codes"? For example: this & this
    2. Certain things seems to be "very specific to a certain posix platform". How do we want to handle this? For example: this & this
  2. Refactoring platform-specific code in util.h/util.cpp da361f0410
  3. fanquake added the label Refactoring on May 10, 2018
  4. fanquake added the label Utils/log/libs on May 10, 2018
  5. practicalswift commented at 3:32 PM on May 10, 2018: contributor

    Concept ACK

  6. practicalswift commented at 3:59 PM on May 10, 2018: contributor

    FWIW, these are places where we use OS specific code after this PR:

    $ git checkout bitcoin-12697
    $ git grep -E "#if.*(__APPLE__|__DragonFly__|__FreeBSD__|__linux__|MAC_OSX|_MSC_VER|\
    __NetBSD__|__OpenBSD__|WIN32|_WIN32_IE|WIN32_LEAN_AND_MEAN|_WIN32_WINNT|_WIN64)" -- \
    "*.cpp" "*.h" | grep -vE '(src/secp256k1/|src/leveldb/)' | cut -f1 -d: | sort | uniq -c
          2 src/bitcoind.cpp
          1 src/compat/byteswap.h
          9 src/compat.h
          1 src/dbwrapper.cpp
          1 src/httpserver.cpp
         11 src/init.cpp
          7 src/netbase.cpp
          5 src/net.cpp
          1 src/net.h
          1 src/protocol.cpp
          4 src/qt/guiutil.cpp
          1 src/qt/test/test_main.cpp
          1 src/qt/utilitydialog.cpp
          1 src/qt/winshutdownmonitor.h
          8 src/random.cpp
          1 src/script/bitcoinconsensus.h
          2 src/support/cleanse.cpp
          5 src/support/lockedpool.cpp
          1 src/test/test_bitcoin_fuzzy.cpp
          4 src/test/util_tests.cpp
          1 src/tinyformat.h
          1 src/torcontrol.cpp
         14 src/util/platform_common.cpp
          2 src/util/platform_common.h
          8 src/util/platform_posix.cpp
          7 src/util/platform_windows.cpp
          2 src/utilstrencodings.cpp
          3 src/utiltime.cpp
          1 src/wallet/db.cpp
    

    And for QT OS dependence:

    $ git checkout bitcoin-12697
    $ git grep -E '#if.*Q_OS_' -- "*.cpp" "*.h" | cut -f1 -d: | sort | uniq -c
          3 src/qt/bitcoin.cpp
         12 src/qt/bitcoingui.cpp
          1 src/qt/bitcoingui.h
          2 src/qt/guiutil.cpp
          1 src/qt/guiutil.h
          4 src/qt/notificator.cpp
          1 src/qt/notificator.h
          2 src/qt/optionsdialog.cpp
          1 src/qt/rpcconsole.cpp
          1 src/qt/winshutdownmonitor.cpp
    
  7. jonasschnelli commented at 6:23 AM on May 14, 2018: contributor

    Your both points...

    1. How should we handle "duplicate codes"? For example: this & this
    2. Certain things seems to be "very specific to a certain posix platform". How do we want to handle this? For example: this & this

    ... make me think it's not worth the effort. Maybe it's better to keep it as it is since a clear separation without duplicating code seems not to be possible.

  8. glaksmono commented at 11:58 AM on May 14, 2018: contributor

    Closing the PR per #13209 (comment)

  9. glaksmono closed this on May 14, 2018

  10. glaksmono deleted the branch on May 14, 2018
  11. MarcoFalke 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: 2026-04-13 15:15 UTC

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