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

IntelPython / dpctl / 16270219306

14 Jul 2025 02:53PM UTC coverage: 85.89%. Remained the same
16270219306

Pull #2123

github

web-flow
Merge 4947f5cfd into e2789db9a
Pull Request #2123: Allow type casting of zero-sized array to any dtype

3227 of 3878 branches covered (83.21%)

Branch coverage included in aggregate %.

3 of 3 new or added lines in 1 file covered. (100.0%)

2 existing lines in 2 files now uncovered.

12235 of 14124 relevant lines covered (86.63%)

6889.19 hits per line

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

59.52
/libsyclinterface/helper/include/dpctl_dynamic_lib_helper.h
1
//===--- dpctl_dynamic_lib_helper.h - Dynamic library helper     -*-C++-*- ===//
2
//
3
//                      Data Parallel Control (dpctl)
4
//
5
// Copyright 2020-2025 Intel Corporation
6
//
7
// Licensed under the Apache License, Version 2.0 (the "License");
8
// you may not use this file except in compliance with the License.
9
// You may obtain a copy of the License at
10
//
11
//    http://www.apache.org/licenses/LICENSE-2.0
12
//
13
// Unless required by applicable law or agreed to in writing, software
14
// distributed under the License is distributed on an "AS IS" BASIS,
15
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
// See the License for the specific language governing permissions and
17
// limitations under the License.
18
//
19
//===----------------------------------------------------------------------===//
20
///
21
/// \file
22
/// Helper for dynamic libs management.
23
//===----------------------------------------------------------------------===//
24

25
#ifndef __DPCTL_DYNAMIC_LIB_HELPER_H__
26
#define __DPCTL_DYNAMIC_LIB_HELPER_H__
27

28
#if defined(__linux__) || defined(_WIN32) || defined(_WIN64)
29

30
#ifdef __linux__
31

32
#include <dlfcn.h>
33

34
#elif defined(_WIN32) || defined(_WIN64)
35

36
#define NOMINMAX
37
#include <windows.h>
38

39
#endif // __linux__
40

41
#include "dpctl_error_handlers.h"
42
#include <cstdint>
43

44
namespace dpctl
45
{
46

47
class DynamicLibHelper final
48
{
49
public:
50
    DynamicLibHelper &operator=(const DynamicLibHelper &) = delete;
51
    DynamicLibHelper() = delete;
52
    DynamicLibHelper(const DynamicLibHelper &) = delete;
53
    DynamicLibHelper(const char *libName, int flag)
54
    {
2✔
55

56
#ifdef __linux__
2✔
57
        _handle = dlopen(libName, flag);
2✔
58
#elif defined(_WIN32) || defined(_WIN64)
59
        _handle =
60
            LoadLibraryExA(libName, nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
61
#endif
62
    }
2✔
63

64
    ~DynamicLibHelper()
65
    {
2✔
66
#ifdef __linux__
2✔
67
        dlclose(_handle);
2✔
68
#elif defined(_WIN32) || defined(_WIN64)
69
        FreeLibrary((HMODULE)_handle);
70
#endif
71
    };
2✔
72

73
    template <typename T> T getSymbol(const char *symName)
74
    {
8✔
75
#ifdef __linux__
8✔
76
        void *sym = dlsym(_handle, symName);
8✔
77
        char *error = dlerror();
8✔
78

79
        if (nullptr != error) {
8!
80
            error_handler("Could not retrieve symbol " + std::string(symName) +
×
81
                              ". Error encountered: " + std::string(error),
×
82
                          __FILE__, __func__, __LINE__);
×
83
            return nullptr;
×
84
        }
×
85
#elif defined(_WIN32) || defined(_WIN64)
86
        void *sym = (void *)GetProcAddress((HMODULE)_handle, symName);
87

88
        if (nullptr == sym) {
89
            error_handler("Could not retrieve symbol " + std::string(symName) +
90
                              ".",
91
                          __FILE__, __func__, __LINE__);
92
            return nullptr;
93
        }
94
#endif
95

96
        return (T)sym;
8✔
97
    }
8✔
98

99
    bool opened() const
100
    {
2✔
101
        if (!_handle)
2!
102
            return false;
×
103
        else
2✔
104
            return true;
2✔
105
    }
2✔
106

107
private:
108
    void *_handle = nullptr;
109
};
110

111
} // namespace dpctl
112

113
#endif // #if defined(__linux__) || defined(_WIN32) || defined(_WIN64)
114
#endif // __DPCTL_DYNAMIC_LIB_HELPER_H__
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