ltsmin: rework the dlsym interface to please GCC snapshot

* spot/ltsmin/ltsmin.cc: Avoid C-style function casts with
incompatible types.
This commit is contained in:
Alexandre Duret-Lutz 2018-01-09 22:00:49 +01:00
parent 31387e8f71
commit 91fdc5ecb2

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*- // -*- coding: utf-8 -*-
// Copyright (C) 2011, 2012, 2014, 2015, 2016, 2017 Laboratoire de // Copyright (C) 2011, 2012, 2014-2018 Laboratoire de
// Recherche et Développement de l'Epita (LRDE) // Recherche et Développement de l'Epita (LRDE)
// //
// This file is part of Spot, a model checking library. // This file is part of Spot, a model checking library.
@ -1034,64 +1034,45 @@ namespace spot
d->handle = h; d->handle = h;
auto sym = [&](const char* name) auto sym = [&](auto* dst, const char* name)
{ {
// Work around -Wpendantic complaining that pointer-to-objects // Work around -Wpendantic complaining that pointer-to-objects
// should not be converted to pointer-to-functions (we have to // should not be converted to pointer-to-functions (we have to
// assume they can for POSIX). // assume they can for POSIX).
void (*res)(void*); *reinterpret_cast<void**>(dst) = lt_dlsym(h, name);
*reinterpret_cast<void**>(&res) = lt_dlsym(h, name); if (dst == nullptr)
if (res == nullptr)
throw std::runtime_error(std::string("Failed to resolve symbol '") throw std::runtime_error(std::string("Failed to resolve symbol '")
+ name + "' in '" + file + "'."); + name + "' in '" + file + "'.");
return res;
}; };
// SpinS interface. // SpinS interface.
if (ext == ".spins") if (ext == ".spins")
{ {
d->get_initial_state = (void (*)(void*)) sym(&d->get_initial_state, "spins_get_initial_state");
sym("spins_get_initial_state");
d->have_property = nullptr; d->have_property = nullptr;
d->get_successors = (int (*)(void*, int*, TransitionCB, void*)) sym(&d->get_successors, "spins_get_successor_all");
sym("spins_get_successor_all"); sym(&d->get_state_size, "spins_get_state_size");
d->get_state_size = (int (*)()) sym("spins_get_state_size"); sym(&d->get_state_variable_name, "spins_get_state_variable_name");
d->get_state_variable_name = (const char* (*)(int)) sym(&d->get_state_variable_type, "spins_get_state_variable_type");
sym("spins_get_state_variable_name"); sym(&d->get_type_count, "spins_get_type_count");
d->get_state_variable_type = (int (*)(int)) sym(&d->get_type_name, "spins_get_type_name");
sym("spins_get_state_variable_type"); sym(&d->get_type_value_count, "spins_get_type_value_count");
d->get_type_count = (int (*)()) sym(&d->get_type_value_name, "spins_get_type_value_name");
sym("spins_get_type_count");
d->get_type_name = (const char* (*)(int))
sym("spins_get_type_name");
d->get_type_value_count = (int (*)(int))
sym("spins_get_type_value_count");
d->get_type_value_name = (const char* (*)(int, int))
sym("spins_get_type_value_name");
} }
// dve2 and gal2C interfaces. // dve2 and gal2C interfaces.
else else
{ {
d->get_initial_state = (void (*)(void*)) sym(&d->get_initial_state, "get_initial_state");
sym("get_initial_state");
*reinterpret_cast<void**>(&d->have_property) = *reinterpret_cast<void**>(&d->have_property) =
lt_dlsym(h, "have_property"); lt_dlsym(h, "have_property");
d->get_successors = (int (*)(void*, int*, TransitionCB, void*)) sym(&d->get_successors, "get_successors");
sym("get_successors"); sym(&d->get_state_size, "get_state_variable_count");
d->get_state_size = (int (*)()) sym(&d->get_state_variable_name, "get_state_variable_name");
sym("get_state_variable_count"); sym(&d->get_state_variable_type, "get_state_variable_type");
d->get_state_variable_name = (const char* (*)(int)) sym(&d->get_type_count, "get_state_variable_type_count");
sym("get_state_variable_name"); sym(&d->get_type_name, "get_state_variable_type_name");
d->get_state_variable_type = (int (*)(int)) sym(&d->get_type_value_count, "get_state_variable_type_value_count");
sym("get_state_variable_type"); sym(&d->get_type_value_name, "get_state_variable_type_value");
d->get_type_count = (int (*)())
sym("get_state_variable_type_count");
d->get_type_name = (const char* (*)(int))
sym("get_state_variable_type_name");
d->get_type_value_count = (int (*)(int))
sym("get_state_variable_type_value_count");
d->get_type_value_name = (const char* (*)(int, int))
sym("get_state_variable_type_value");
} }
if (d->have_property && d->have_property()) if (d->have_property && d->have_property())