VirtualBox

Changeset 28357 in vbox


Ignore:
Timestamp:
Apr 15, 2010 1:11:23 PM (15 years ago)
Author:
vboxsync
Message:

Runtime: generalise the code used to load libdbus at runtime to a template for loading shared libraries

Location:
trunk
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/dbus-calls.h

    r25477 r28357  
    3030 */
    3131
    32 #ifndef VBOX_PROXY_STUB
    33 # error This file is a private header, intended to be included in specific places only
     32/** The file name of the DBus library */
     33#define RT_RUNTIME_LOADER_LIB_NAME "libdbus-1.so.3"
     34
     35/** The name of the loader function */
     36#define RT_RUNTIME_LOADER_FUNCTION RTDBusLoadLib
     37
     38/** The following are the symbols which we need from the DBus library. */
     39#define RT_RUNTIME_LOADER_INSERT_SYMBOLS \
     40 RT_PROXY_STUB(dbus_error_init, void, (DBusError *error), \
     41                 (error)) \
     42 RT_PROXY_STUB(dbus_error_is_set, dbus_bool_t, (const DBusError *error), \
     43                 (error)) \
     44 RT_PROXY_STUB(dbus_bus_get, DBusConnection *, \
     45                 (DBusBusType type, DBusError *error), (type, error)) \
     46 RT_PROXY_STUB(dbus_bus_get_private, DBusConnection *, \
     47                 (DBusBusType type, DBusError *error), (type, error)) \
     48 RT_PROXY_STUB(dbus_error_free, void, (DBusError *error), \
     49                 (error)) \
     50 RT_PROXY_STUB(dbus_connection_unref, void, (DBusConnection *connection), \
     51                 (connection)) \
     52 RT_PROXY_STUB(dbus_connection_close, void, (DBusConnection *connection), \
     53                 (connection)) \
     54 RT_PROXY_STUB(dbus_connection_send, dbus_bool_t, \
     55                 (DBusConnection *connection, DBusMessage *message, dbus_uint32_t *serial), \
     56                 (connection, message, serial)) \
     57 RT_PROXY_STUB(dbus_connection_flush, void, (DBusConnection *connection), \
     58                 (connection)) \
     59 RT_PROXY_STUB(dbus_connection_set_exit_on_disconnect, void, \
     60                 (DBusConnection *connection, dbus_bool_t boolean), \
     61                 (connection, boolean)) \
     62 RT_PROXY_STUB(dbus_bus_name_has_owner, dbus_bool_t, \
     63                 (DBusConnection *connection, const char *string, DBusError *error), \
     64                 (connection, string, error)) \
     65 RT_PROXY_STUB(dbus_bus_add_match, void, \
     66                 (DBusConnection *connection, const char *string, \
     67                  DBusError *error), \
     68                 (connection, string, error)) \
     69 RT_PROXY_STUB(dbus_bus_remove_match, void, \
     70                 (DBusConnection *connection, const char *string, \
     71                  DBusError *error), \
     72                 (connection, string, error)) \
     73 RT_PROXY_STUB(dbus_message_append_args_valist, dbus_bool_t, \
     74                 (DBusMessage *message, int first_arg_type, va_list var_args), \
     75                 (message, first_arg_type, var_args)) \
     76 RT_PROXY_STUB(dbus_message_iter_open_container, dbus_bool_t, \
     77                 (DBusMessageIter *iter, int type, const char *contained_signature, DBusMessageIter *sub), \
     78                 (iter, type, contained_signature, sub)) \
     79 RT_PROXY_STUB(dbus_message_iter_close_container, dbus_bool_t, \
     80                 (DBusMessageIter *iter, DBusMessageIter *sub), \
     81                 (iter, sub)) \
     82 RT_PROXY_STUB(dbus_message_iter_append_fixed_array, dbus_bool_t, \
     83                 (DBusMessageIter *iter, int element_type, const void *value, int n_elements), \
     84                 (iter, element_type, value, n_elements)) \
     85 RT_PROXY_STUB(dbus_message_unref, void, (DBusMessage *message), \
     86                 (message)) \
     87 RT_PROXY_STUB(dbus_message_new_method_call, DBusMessage*, \
     88                 (const char *string1, const char *string2, const char *string3, \
     89                  const char *string4), \
     90                 (string1, string2, string3, string4)) \
     91 RT_PROXY_STUB(dbus_message_iter_init_append, void, \
     92                 (DBusMessage *message, DBusMessageIter *iter), \
     93                 (message, iter)) \
     94 RT_PROXY_STUB(dbus_message_iter_append_basic, dbus_bool_t, \
     95                 (DBusMessageIter *iter, int val, const void *string), \
     96                 (iter, val, string)) \
     97 RT_PROXY_STUB(dbus_connection_send_with_reply_and_block, DBusMessage *, \
     98                 (DBusConnection *connection, DBusMessage *message, int val, \
     99                  DBusError *error), \
     100                 (connection, message, val, error)) \
     101 RT_PROXY_STUB(dbus_message_iter_init, dbus_bool_t, \
     102                 (DBusMessage *message, DBusMessageIter *iter), \
     103                 (message, iter)) \
     104 RT_PROXY_STUB(dbus_message_iter_get_arg_type, int, (DBusMessageIter *iter), \
     105                 (iter)) \
     106 RT_PROXY_STUB(dbus_message_iter_get_element_type, int, \
     107                 (DBusMessageIter *iter), (iter)) \
     108 RT_PROXY_STUB(dbus_message_iter_recurse, void, \
     109                 (DBusMessageIter *iter1, DBusMessageIter *iter2), \
     110                 (iter1, iter2)) \
     111 RT_PROXY_STUB(dbus_message_iter_get_basic, void, \
     112                 (DBusMessageIter *iter, void *pvoid), (iter, pvoid)) \
     113 RT_PROXY_STUB(dbus_message_iter_next, dbus_bool_t, (DBusMessageIter *iter), \
     114                 (iter)) \
     115 RT_PROXY_STUB(dbus_connection_add_filter, dbus_bool_t, \
     116                 (DBusConnection *connection, \
     117                  DBusHandleMessageFunction function1, void *pvoid, \
     118                  DBusFreeFunction function2), \
     119                 (connection, function1, pvoid, function2)) \
     120 RT_PROXY_STUB(dbus_connection_remove_filter, void, \
     121                 (DBusConnection *connection, \
     122                  DBusHandleMessageFunction function, void *pvoid), \
     123                 (connection, function, pvoid)) \
     124 RT_PROXY_STUB(dbus_connection_read_write_dispatch, dbus_bool_t, \
     125                 (DBusConnection *connection, int val), (connection, val)) \
     126 RT_PROXY_STUB(dbus_message_is_signal, dbus_bool_t, \
     127                 (DBusMessage *message, const char *string1, \
     128                  const char *string2), \
     129                 (message, string1, string2)) \
     130 RT_PROXY_STUB(dbus_connection_pop_message, DBusMessage *, \
     131                 (DBusConnection *connection), (connection))
     132
     133#ifdef VBOX_DBUS_GENERATE_HEADER
     134# define RT_RUNTIME_LOADER_GENERATE_HEADER
     135# define RT_RUNTIME_LOADER_GENERATE_DECLS
     136# include <iprt/runtime-loader.h>
     137# undef RT_RUNTIME_LOADER_GENERATE_HEADER
     138# undef RT_RUNTIME_LOADER_GENERATE_DECLS
     139#elif defined (VBOX_DBUS_GENERATE_BODY)
     140# define RT_RUNTIME_LOADER_GENERATE_BODY_STUBS
     141# include <iprt/runtime-loader.h>
     142# undef RT_RUNTIME_LOADER_GENERATE_BODY_STUBS
     143#else
     144# error This file should only be included to generate stubs for loading the \
     145DBus library at runtime
    34146#endif
    35147
    36 /** The following are the symbols which we need from libdbus-1. */
    37 VBOX_PROXY_STUB(dbus_error_init, void, (DBusError *error),
    38                 (error))
    39 VBOX_PROXY_STUB(dbus_error_is_set, dbus_bool_t, (const DBusError *error),
    40                 (error))
    41 VBOX_PROXY_STUB(dbus_bus_get, DBusConnection *,
    42                 (DBusBusType type, DBusError *error), (type, error))
    43 VBOX_PROXY_STUB(dbus_bus_get_private, DBusConnection *,
    44                 (DBusBusType type, DBusError *error), (type, error))
    45 VBOX_PROXY_STUB(dbus_error_free, void, (DBusError *error),
    46                 (error))
    47 VBOX_PROXY_STUB(dbus_connection_unref, void, (DBusConnection *connection),
    48                 (connection))
    49 VBOX_PROXY_STUB(dbus_connection_close, void, (DBusConnection *connection),
    50                 (connection))
    51 VBOX_PROXY_STUB(dbus_connection_send, dbus_bool_t,
    52                 (DBusConnection *connection, DBusMessage *message, dbus_uint32_t *serial),
    53                 (connection, message, serial))
    54 VBOX_PROXY_STUB(dbus_connection_flush, void, (DBusConnection *connection),
    55                 (connection))
    56 VBOX_PROXY_STUB(dbus_connection_set_exit_on_disconnect, void,
    57                 (DBusConnection *connection, dbus_bool_t boolean),
    58                 (connection, boolean))
    59 VBOX_PROXY_STUB(dbus_bus_name_has_owner, dbus_bool_t,
    60                 (DBusConnection *connection, const char *string, DBusError *error),
    61                 (connection, string, error))
    62 VBOX_PROXY_STUB(dbus_bus_add_match, void,
    63                 (DBusConnection *connection, const char *string,
    64                  DBusError *error),
    65                 (connection, string, error))
    66 VBOX_PROXY_STUB(dbus_bus_remove_match, void,
    67                 (DBusConnection *connection, const char *string,
    68                  DBusError *error),
    69                 (connection, string, error))
    70 VBOX_PROXY_STUB(dbus_message_append_args_valist, dbus_bool_t,
    71                 (DBusMessage *message, int first_arg_type, va_list var_args),
    72                 (message, first_arg_type, var_args))
    73 VBOX_PROXY_STUB(dbus_message_iter_open_container, dbus_bool_t,
    74                 (DBusMessageIter *iter, int type, const char *contained_signature, DBusMessageIter *sub),
    75                 (iter, type, contained_signature, sub))
    76 VBOX_PROXY_STUB(dbus_message_iter_close_container, dbus_bool_t,
    77                 (DBusMessageIter *iter, DBusMessageIter *sub),
    78                 (iter, sub))
    79 VBOX_PROXY_STUB(dbus_message_iter_append_fixed_array, dbus_bool_t,
    80                 (DBusMessageIter *iter, int element_type, const void *value, int n_elements),
    81                 (iter, element_type, value, n_elements))
    82 VBOX_PROXY_STUB(dbus_message_unref, void, (DBusMessage *message),
    83                 (message))
    84 VBOX_PROXY_STUB(dbus_message_new_method_call, DBusMessage*,
    85                 (const char *string1, const char *string2, const char *string3,
    86                  const char *string4),
    87                 (string1, string2, string3, string4))
    88 VBOX_PROXY_STUB(dbus_message_iter_init_append, void,
    89                 (DBusMessage *message, DBusMessageIter *iter),
    90                 (message, iter))
    91 VBOX_PROXY_STUB(dbus_message_iter_append_basic, dbus_bool_t,
    92                 (DBusMessageIter *iter, int val, const void *string),
    93                 (iter, val, string))
    94 VBOX_PROXY_STUB(dbus_connection_send_with_reply_and_block, DBusMessage *,
    95                 (DBusConnection *connection, DBusMessage *message, int val,
    96                  DBusError *error),
    97                 (connection, message, val, error))
    98 VBOX_PROXY_STUB(dbus_message_iter_init, dbus_bool_t,
    99                 (DBusMessage *message, DBusMessageIter *iter),
    100                 (message, iter))
    101 VBOX_PROXY_STUB(dbus_message_iter_get_arg_type, int, (DBusMessageIter *iter),
    102                 (iter))
    103 VBOX_PROXY_STUB(dbus_message_iter_get_element_type, int,
    104                 (DBusMessageIter *iter), (iter))
    105 VBOX_PROXY_STUB(dbus_message_iter_recurse, void,
    106                 (DBusMessageIter *iter1, DBusMessageIter *iter2),
    107                 (iter1, iter2))
    108 VBOX_PROXY_STUB(dbus_message_iter_get_basic, void,
    109                 (DBusMessageIter *iter, void *pvoid), (iter, pvoid))
    110 VBOX_PROXY_STUB(dbus_message_iter_next, dbus_bool_t, (DBusMessageIter *iter),
    111                 (iter))
    112 VBOX_PROXY_STUB(dbus_connection_add_filter, dbus_bool_t,
    113                 (DBusConnection *connection,
    114                  DBusHandleMessageFunction function1, void *pvoid,
    115                  DBusFreeFunction function2),
    116                 (connection, function1, pvoid, function2))
    117 VBOX_PROXY_STUB(dbus_connection_remove_filter, void,
    118                 (DBusConnection *connection,
    119                  DBusHandleMessageFunction function, void *pvoid),
    120                 (connection, function, pvoid))
    121 VBOX_PROXY_STUB(dbus_connection_read_write_dispatch, dbus_bool_t,
    122                 (DBusConnection *connection, int val), (connection, val))
    123 VBOX_PROXY_STUB(dbus_message_is_signal, dbus_bool_t,
    124                 (DBusMessage *message, const char *string1,
    125                  const char *string2),
    126                 (message, string1, string2))
    127 VBOX_PROXY_STUB(dbus_connection_pop_message, DBusMessage *,
    128                 (DBusConnection *connection), (connection))
    129 
     148#undef RT_RUNTIME_LOADER_LIB_NAME
     149#undef RT_RUNTIME_LOADER_INSERT_SYMBOLS
  • trunk/include/VBox/dbus.h

    r25477 r28357  
    3535#include <iprt/types.h>
    3636#include <iprt/stdarg.h>
    37 
    38 #define VBOX_DBUS_1_3_LIB "libdbus-1.so.3"
    3937
    4038/** Types and defines from the dbus header files which we need.  These are
     
    109107
    110108/* Declarations of the functions that we need from libdbus-1 */
    111 #define VBOX_PROXY_STUB(function, rettype, signature, shortsig) \
    112     RTR3DECL(rettype) ( function ) signature ;
     109#define VBOX_DBUS_GENERATE_HEADER
    113110
    114111#include <VBox/dbus-calls.h>
    115112
    116 #undef VBOX_PROXY_STUB
    117 
    118 /**
    119  * Try to dynamically load the DBus library.  This function should be called
    120  * before attempting to use any of the DBus functions.  It is safe to call this
    121  * function multiple times.
    122  *
    123  * @returns iprt status code
    124  */
    125 RTR3DECL(int) RTDBusLoadLib(void);
     113#undef VBOX_DBUS_GENERATE_HEADER
    126114
    127115#endif /* ___VBox_DBus_h not defined */
  • trunk/include/iprt/runtime-loader.h

    r28315 r28357  
    11/** @file
    2  *
    3  * Module to dynamically load libdbus and load all symbols
    4  * which are needed by VirtualBox.
     2 * IPRT - runtime loader generation
    53 */
    64
     
    3028 */
    3129
    32 #define LOG_GROUP LOG_GROUP_MAIN
    33 #include <VBox/log.h>
    34 #include <VBox/dbus.h>
    35 #include <VBox/err.h>
     30/* How to use this loader generator
     31 *
     32 * This loader generator can be used to generate stub code for loading a shared
     33 * library and its functions at runtime, or for generating a header file with
     34 * the declaration of the loader function and optionally declarations for the
     35 * functions loaded.  It should be included in a header file or a C source
     36 * file, after defining certain macros which it makes use of.
     37 *
     38 * To generate the C source code for function proxy stubs and the library
     39 * loader function, you should define the following macros in your source file
     40 * before including this header:
     41 *
     42 *  RT_RUNTIME_LOADER_LIB_NAME       - the file name of the library to load
     43 *  RT_RUNTIME_LOADER_FUNCTION       - the name of the loader function
     44 *  RT_RUNTIME_LOADER_INSERT_SYMBOLS - a macro containing the names of the
     45 *                                     functions to be loaded, defined in the
     46 *                                     following pattern:
     47 *
     48 * #define RT_RUNTIME_LOADER_INSERT_SYMBOLS \
     49 *  RT_PROXY_STUB(func_name, ret_type, (long_param_list), (short_param_list)) \
     50 *  RT_PROXY_STUB(func_name2, ret_type2, (long_param_list2), (short_param_list2)) \
     51 *  ...
     52 *
     53 * where long_param_list is a paramter list for declaring the function of the
     54 * form (type1 arg1, type2 arg2, ...) and short_param_list for calling it, of
     55 * the form (arg1, arg2, ...).
     56 *
     57 * To generate the header file, you should define RT_RUNTIME_LOADER_FUNCTION
     58 * and if you wish to generate declarations for the functions you should
     59 * additionally define RT_RUNTIME_LOADER_INSERT_SYMBOLS as above and
     60 * RT_RUNTIME_LOADER_GENERATE_DECLS (without a value) before including this
     61 * file.
     62 */
     63/** @todo this is far too complicated.  A script for generating the files would
     64 * probably be preferable. */
    3665
     66#include <iprt/asm.h>
     67#include <iprt/assert.h>
     68#include <iprt/cdefs.h>
     69#include <iprt/err.h>
    3770#include <iprt/ldr.h>
    38 #include <iprt/assert.h>
    39 #include <iprt/once.h>
     71#include <iprt/log.h>
     72#include <iprt/thread.h>
     73#include <iprt/types.h>
    4074
    41 /** The following are the symbols which we need from libdbus. */
    42 #define VBOX_PROXY_STUB(function, rettype, signature, shortsig) \
    43 void (*function ## _fn)(void); \
    44 RTR3DECL(rettype) function signature \
    45 { return ( (rettype (*) signature) function ## _fn ) shortsig; }
     75#ifdef RT_RUNTIME_LOADER_GENERATE_BODY_STUBS
     76/** The following are the symbols which we need from the library. */
     77# define RT_PROXY_STUB(function, rettype, signature, shortsig) \
     78 void (*function ## _fn)(void); \
     79 RTR3DECL(rettype) function signature \
     80 { return ( (rettype (*) signature) function ## _fn ) shortsig; }
    4681
    47 #include <VBox/dbus-calls.h>
     82RT_RUNTIME_LOADER_INSERT_SYMBOLS
    4883
    49 #undef VBOX_PROXY_STUB
     84# undef RT_PROXY_STUB
    5085
    51 /* Now comes a table of functions to be loaded from libdbus-1 */
     86/* Now comes a table of functions to be loaded from the library */
    5287typedef struct
    5388{
     
    5691} SHARED_FUNC;
    5792
    58 #define VBOX_PROXY_STUB(s, dummy1, dummy2, dummy3 ) { #s , & s ## _fn } ,
     93# define RT_PROXY_STUB(s, dummy1, dummy2, dummy3 ) { #s , & s ## _fn } ,
    5994static SHARED_FUNC SharedFuncs[] =
    6095{
    61 #include <VBox/dbus-calls.h>
     96RT_RUNTIME_LOADER_INSERT_SYMBOLS
    6297    { NULL, NULL }
    6398};
    64 #undef VBOX_PROXY_STUB
     99# undef RT_PROXY_STUB
    65100
    66 /* The function which does the actual work for RTDBusLoadLib, serialised for
    67  * thread safety. */
    68 DECLINLINE(int) loadDBusLibOnce(void *, void *)
     101enum RT_RTLDR_LOAD_STATE
    69102{
    70     int rc = VINF_SUCCESS;
    71     RTLDRMOD hLib;
     103    UNLOADED = 0,
     104    LOADING,
     105    DONE
     106};
     107
     108static uint32_t rtldrState = UNLOADED;
     109static uint32_t rtldrRC = VERR_WRONG_ORDER;
     110
     111/** Load the shared library RT_RUNTIME_LOADER_LIB_NAME and resolve the symbols
     112 * pointed to by RT_RUNTIME_LOADER_INSERT_SYMBOLS.  May safely be called from
     113 * multiple threads and will not return until the library is loaded or has
     114 * failed to load. */
     115RTR3DECL(int) RT_RUNTIME_LOADER_FUNCTION(void)
     116{
     117    int rc;
    72118
    73119    LogFlowFunc(("\n"));
    74     rc = RTLdrLoad(VBOX_DBUS_1_3_LIB, &hLib);
    75     if (RT_FAILURE(rc))
    76         LogRelFunc(("Failed to load library %s\n", VBOX_DBUS_1_3_LIB));
    77     for (unsigned i = 0; RT_SUCCESS(rc) && SharedFuncs[i].name != NULL; ++i)
    78         rc = RTLdrGetSymbol(hLib, SharedFuncs[i].name, (void**)SharedFuncs[i].fn);
     120    if (ASMAtomicCmpXchgU32(&rtldrState, LOADING, UNLOADED))
     121    {
     122        RTLDRMOD hLib;
     123
     124        rc = RTLdrLoad(RT_RUNTIME_LOADER_LIB_NAME, &hLib);
     125        for (unsigned i = 0; RT_SUCCESS(rc) && SharedFuncs[i].name != NULL; ++i)
     126            rc = RTLdrGetSymbol(hLib, SharedFuncs[i].name, (void**)SharedFuncs[i].fn);
     127        rtldrRC = rc;
     128        rtldrState = DONE;
     129    }
     130    else
     131    {
     132        while(rtldrState == LOADING)
     133            RTThreadYield();
     134        rc = rtldrRC;
     135    }
     136    Assert(rtldrState == DONE);
    79137    LogFlowFunc(("rc = %Rrc\n", rc));
    80138    return rc;
    81139}
     140#elif defined(RT_RUNTIME_LOADER_GENERATE_HEADER)
     141# ifdef RT_RUNTIME_LOADER_GENERATE_DECLS
     142/* Declarations of the functions that we need from
     143 * RT_RUNTIME_LOADER_LIB_NAME */
     144#  define RT_PROXY_STUB(function, rettype, signature, shortsig) \
     145    RTR3DECL(rettype) ( function ) signature ;
    82146
    83 RTR3DECL(int) RTDBusLoadLib(void)
    84 {
    85     static RTONCE sOnce = RTONCE_INITIALIZER;
     147RT_RUNTIME_LOADER_INSERT_SYMBOLS
    86148
    87     LogFlowFunc(("\n"));
    88     int rc = RTOnce (&sOnce, loadDBusLibOnce, NULL, NULL);
    89     LogFlowFunc(("rc = %Rrc\n", rc));
    90     return rc;
    91 }
     149#  undef RT_PROXY_STUB
     150# endif /* RT_RUNTIME_LOADER_GENERATE_DECLS */
     151
     152/**
     153 * Try to dynamically load the library.  This function should be called before
     154 * attempting to use any of the library functions.  It is safe to call this
     155 * function multiple times.
     156 *
     157 * @returns iprt status code
     158 */
     159RTR3DECL(int) RT_RUNTIME_LOADER_FUNCTION(void);
     160#else
     161# error One of RT_RUNTIME_LOADER_GENERATE_HEADER or \
     162RT_RUNTIME_LOADER_GENERATE_BODY_STUBS must be defined when including this file
     163#endif
  • trunk/src/VBox/Runtime/VBox/dbus.cpp

    r24409 r28357  
    3030 */
    3131
    32 #define LOG_GROUP LOG_GROUP_MAIN
    33 #include <VBox/log.h>
     32#define LOG_GROUP RTLOGGROUP_LDR
    3433#include <VBox/dbus.h>
    35 #include <VBox/err.h>
    3634
    37 #include <iprt/ldr.h>
    38 #include <iprt/assert.h>
    39 #include <iprt/once.h>
    40 
    41 /** The following are the symbols which we need from libdbus. */
    42 #define VBOX_PROXY_STUB(function, rettype, signature, shortsig) \
    43 void (*function ## _fn)(void); \
    44 RTR3DECL(rettype) function signature \
    45 { return ( (rettype (*) signature) function ## _fn ) shortsig; }
    46 
     35/* Declarations of the functions that we need from libdbus-1 */
     36#define VBOX_DBUS_GENERATE_BODY
    4737#include <VBox/dbus-calls.h>
    48 
    49 #undef VBOX_PROXY_STUB
    50 
    51 /* Now comes a table of functions to be loaded from libdbus-1 */
    52 typedef struct
    53 {
    54     const char *name;
    55     void (**fn)(void);
    56 } SHARED_FUNC;
    57 
    58 #define VBOX_PROXY_STUB(s, dummy1, dummy2, dummy3 ) { #s , & s ## _fn } ,
    59 static SHARED_FUNC SharedFuncs[] =
    60 {
    61 #include <VBox/dbus-calls.h>
    62     { NULL, NULL }
    63 };
    64 #undef VBOX_PROXY_STUB
    65 
    66 /* The function which does the actual work for RTDBusLoadLib, serialised for
    67  * thread safety. */
    68 DECLINLINE(int) loadDBusLibOnce(void *, void *)
    69 {
    70     int rc = VINF_SUCCESS;
    71     RTLDRMOD hLib;
    72 
    73     LogFlowFunc(("\n"));
    74     rc = RTLdrLoad(VBOX_DBUS_1_3_LIB, &hLib);
    75     if (RT_FAILURE(rc))
    76         LogRelFunc(("Failed to load library %s\n", VBOX_DBUS_1_3_LIB));
    77     for (unsigned i = 0; RT_SUCCESS(rc) && SharedFuncs[i].name != NULL; ++i)
    78         rc = RTLdrGetSymbol(hLib, SharedFuncs[i].name, (void**)SharedFuncs[i].fn);
    79     LogFlowFunc(("rc = %Rrc\n", rc));
    80     return rc;
    81 }
    82 
    83 RTR3DECL(int) RTDBusLoadLib(void)
    84 {
    85     static RTONCE sOnce = RTONCE_INITIALIZER;
    86 
    87     LogFlowFunc(("\n"));
    88     int rc = RTOnce (&sOnce, loadDBusLibOnce, NULL, NULL);
    89     LogFlowFunc(("rc = %Rrc\n", rc));
    90     return rc;
    91 }
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette