• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

STEllAR-GROUP / hpx / #882

31 Aug 2023 07:44PM UTC coverage: 41.798% (-44.7%) from 86.546%
#882

push

19442 of 46514 relevant lines covered (41.8%)

126375.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.35
/init/src/hpx_main.cpp
1
//  Copyright (c) 2007-2023 Hartmut Kaiser
2
//
3
//  SPDX-License-Identifier: BSL-1.0
4
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
5
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6

7
#include <hpx/config.hpp>
8
#include <hpx/hpx_init.hpp>
9
#include <hpx/modules/program_options.hpp>
10
#include <hpx/modules/runtime_local.hpp>
11

12
#include <cstddef>
13
#include <string>
14
#include <vector>
15

16
///////////////////////////////////////////////////////////////////////////////
17
int hpx_main(int argc, char* argv[]);
18

19
//////////////////////////////////////////////////////////////////////////////
20
// Forwarding of hpx_main, if necessary. This has to be in a separate
21
// translation unit to ensure the linker can pick or ignore this function,
22
// depending on whether the main executable defines this symbol or not.
23
HPX_WEAK_SYMBOL int hpx_main()
24
{
2✔
25
    std::string cmdline(
26
        hpx::get_config_entry("hpx.reconstructed_cmd_line", ""));
27

4✔
28
    using namespace hpx::program_options;
29
#if defined(HPX_WINDOWS)
30
    std::vector<std::string> args = split_winmain(cmdline);
31
#else
32
    std::vector<std::string> args = split_unix(cmdline);
33
#endif
4✔
34

35
    constexpr char hpx_prefix[] = "--hpx:";
36
    constexpr std::size_t hpx_prefix_len = std::size(hpx_prefix) - 1;
2✔
37

38
    constexpr char hpx_positional[] = "positional";
39
    constexpr std::size_t hpx_positional_len = std::size(hpx_positional) - 1;
2✔
40

41
    // Copy all arguments which are not hpx related to a temporary array
42
    std::vector<char*> argv(args.size() + 1);
43
    std::size_t argcount = 0;
2✔
44
    for (auto& argument : args)
45
    {
10✔
46
        if (0 != argument.compare(0, hpx_prefix_len, hpx_prefix))
47
        {
8✔
48
            argv[argcount++] = const_cast<char*>(argument.data());
49
        }
2✔
50
        else if (0 ==
51
            argument.compare(
6✔
52
                hpx_prefix_len, hpx_positional_len, hpx_positional))
6✔
53
        {
54
            std::string::size_type const p = argument.find_first_of('=');
55
            if (p != std::string::npos)
56
            {
×
57
                argument = argument.substr(p + 1);
58
                argv[argcount++] = const_cast<char*>(argument.data());
×
59
            }
×
60
        }
61
    }
62

63
    // add a single nullptr in the end as some application rely on that
64
    argv[argcount] = nullptr;
65

2✔
66
    // Invoke hpx_main
67
    return hpx_main(static_cast<int>(argcount), argv.data());
68
}
4✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc