2 * Copyright 2013, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
6 * Ingo Weinhold <ingo_weinhold@gmx.de>
10 #include <package/solver/Solver.h>
13 typedef BPackageKit::BSolver
* CreateSolverFunction();
20 static CreateSolverFunction
* sCreateSolver
= NULL
;
22 static pthread_once_t sLoadLibsolvSolverAddOnInitOnce
= PTHREAD_ONCE_INIT
;
26 load_libsolv_solver_add_on()
29 #ifdef HAIKU_TARGET_PLATFORM_HAIKU
30 void* imageHandle
= dlopen("libpackage-add-on-libsolv.so", flags
);
32 #ifdef HAIKU_HOST_PLATFORM_LINUX
33 flags
= RTLD_LAZY
| RTLD_LOCAL
;
35 void* imageHandle
= dlopen("libpackage-add-on-libsolv_build.so", flags
);
37 if (imageHandle
== NULL
)
40 sCreateSolver
= (CreateSolverFunction
*)dlsym(imageHandle
, "create_solver");
41 if (sCreateSolver
== NULL
)
46 namespace BPackageKit
{
60 BSolver::Create(BSolver
*& _solver
)
62 pthread_once(&sLoadLibsolvSolverAddOnInitOnce
, &load_libsolv_solver_add_on
);
63 if (sCreateSolver
== NULL
)
64 return B_NOT_SUPPORTED
;
66 BSolver
* solver
= sCreateSolver();
70 status_t error
= solver
->Init();
81 } // namespace BPackageKit