Saancreed / wine-nvml

NVIDIA Management Library wrapper for Wine
GNU Lesser General Public License v2.1
27 stars 5 forks source link

Use the Unix call helpers #15

Closed SveSop closed 1 year ago

SveSop commented 1 year ago

Currently not loading nvml.so for 32-bit "wow64 experimental" compiled wine version.

This is preparation work hopefully for implementation of Wine's "wow64 mode" talked about in #14

SveSop commented 1 year ago

It could be an idea to add a WARN or ERR to the if statement here

            DisableThreadLibraryCalls(instance);
            if (__wine_init_unix_call())
                return FALSE;

To indicate a possible reason nvml is not working, although it could be misleading as it would also print for ANY failed reason.. Just thought something in the lines of

            DisableThreadLibraryCalls(instance);
            if (__wine_init_unix_call()){
                WARN("NVML not loaded - Possibly using wow64 experimental mode\n");
                return FALSE;
           }

But i did not add it, as it could be more noise than use perhaps? Could always pop that in some time later if it seems needed.

Saancreed commented 1 year ago

It could be an idea to add a WARN or ERR to the if statement here

            DisableThreadLibraryCalls(instance);
            if (__wine_init_unix_call())
                return FALSE;

To indicate a possible reason nvml is not working, although it could be misleading as it would also print for ANY failed reason.. Just thought something in the lines of

            DisableThreadLibraryCalls(instance);
            if (__wine_init_unix_call()){
                WARN("NVML not loaded - Possibly using wow64 experimental mode\n");
                return FALSE;
           }

But i did not add it, as it could be more noise than use perhaps? Could always pop that in some time later if it seems needed.

Sure, that sounds useful. But I would go with slightly different error message (because it can fail for other reasons), something like

BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
{
    NTSTATUS status;

    TRACE("(%p, %lu, %p)\n", instance, (unsigned long)reason, reserved);

    switch (reason)
    {
        case DLL_PROCESS_ATTACH:
            DisableThreadLibraryCalls(instance);
            if ((status = __wine_init_unix_call()))
            {
                ERR("Failed to load unixlib, status %#lx\n", status);
                return FALSE;
            }
            if ((status = NVML_CALL(attach, NULL)))
            {
                ERR("Failed to attach unixlib, status %#lx\n", status);
                return FALSE;
            }
SveSop commented 1 year ago

I did not want to use that "status" thing, cos i needed to actually make a declaration for that if that was the case.. So imo better suited for a separate PR? 😏