Changeset 3556 in CLRX


Ignore:
Timestamp:
Dec 15, 2017, 8:11:21 PM (12 months ago)
Author:
matszpk
Message:

CLRadeonExtender: Utils: Add bool operators and isLoaded to check whether library is loaded.
DynLibrary::load throws exception when if dynlibrary already loaded.

Location:
CLRadeonExtender/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/CLRX/utils/Utilities.h

    r3396 r3556  
    134134    /// get symbol
    135135    void* getSymbol(const char* symbolName);
     136   
     137    /// returns true if  loaded
     138    operator bool() const
     139    { return handle!=nullptr; }
     140   
     141    /// returns true if not loaded
     142    bool operator!() const
     143    { return handle==nullptr; }
     144   
     145    // return true if loaded
     146    bool isLoaded() const
     147    { return handle!=nullptr; }
    136148};
    137149
  • CLRadeonExtender/trunk/utils/Utilities.cpp

    r3406 r3556  
    9797{
    9898    std::lock_guard<std::mutex> lock(mutex);
     99    // if already loaded
     100    if (handle != nullptr)
     101        throw Exception("DynLibrary already loaded");
    99102#if defined(HAVE_LINUX) || defined(HAVE_BSD)
    100     dlerror(); // clear old errors
     103    // clear old errors
     104    dlerror();
    101105    int outFlags = (flags & DYNLIB_GLOBAL) ? RTLD_GLOBAL : RTLD_LOCAL;
    102106    if ((flags & DYNLIB_MODE1_MASK) == DYNLIB_LAZY)
Note: See TracChangeset for help on using the changeset viewer.