From: Romain Pokrzywka Date: Tue, 23 Feb 2010 00:32:44 +0000 (-0800) Subject: fix potential crashes on windows with MSVC, due to badly exported variables X-Git-Tag: dbus-1.3.1~111 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fdcd044555dc51cd52e8e3e8626acd45489d4eb6;p=platform%2Fupstream%2Fdbus.git fix potential crashes on windows with MSVC, due to badly exported variables --- diff --git a/dbus/dbus-1-symbols.def.in b/dbus/dbus-1-symbols.def.in index 2398955..febfd42 100644 --- a/dbus/dbus-1-symbols.def.in +++ b/dbus/dbus-1-symbols.def.in @@ -96,7 +96,6 @@ _dbus_credentials_new_from_current_process _dbus_credentials_ref _dbus_credentials_same_user _dbus_credentials_unref -_dbus_current_generation DATA _dbus_daemon_publish_session_bus_address _dbus_daemon_unpublish_session_bus_address _dbus_data_slot_allocator_alloc @@ -217,21 +216,6 @@ _dbus_list_remove_last _dbus_list_remove_link _dbus_list_unlink _dbus_listen_tcp_socket -_dbus_lock_atomic DATA -_dbus_lock_bus DATA -_dbus_lock_bus_datas DATA -_dbus_lock_connection_slots DATA -_dbus_lock_list DATA -_dbus_lock_machine_uuid DATA -_dbus_lock_message_cache DATA -_dbus_lock_message_slots DATA -_dbus_lock_pending_call_slots DATA -_dbus_lock_server_slots DATA -_dbus_lock_shared_connections DATA -_dbus_lock_shutdown_funcs DATA -_dbus_lock_sid_atom_cache DATA -_dbus_lock_system_users DATA -_dbus_lock_win_fds DATA _dbus_make_file_world_readable _dbus_marshal_byteswap _dbus_marshal_read_basic @@ -268,7 +252,7 @@ _dbus_mutex_lock _dbus_mutex_new _dbus_mutex_new_at_location _dbus_mutex_unlock -_dbus_no_memory_message +_dbus_no_memory_message DATA _dbus_object_tree_dispatch_and_unlock _dbus_object_tree_free_all_unlocked _dbus_object_tree_get_user_data_unlocked @@ -313,7 +297,7 @@ _dbus_read_uuid_file _dbus_real_assert _dbus_real_assert_not_reached _dbus_register_shutdown_func -_dbus_return_if_fail_warning_format +_dbus_return_if_fail_warning_format DATA _dbus_send_credentials_socket _dbus_server_add_timeout _dbus_server_add_watch diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index 6b2f8cb..01f6247 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -55,6 +55,21 @@ void _dbus_warn_check_failed (const char *format, #endif /* + * This is necessary to access global variables outside the DLL with MSVC, + * just exporting them in the .def file still leads to linker errors + * note: dbus_1_EXPORTS is set automatically by CMake when the DLL is built + */ +#if defined(_MSC_VER) +# if defined(dbus_1_EXPORTS) +# define DBUS_EXTERN __declspec(dllexport) +# else +# define DBUS_EXTERN __declspec(dllimport) +# endif +#else +#define DBUS_EXTERN extern +#endif + +/* * (code from GLib) * * The _DBUS_LIKELY and _DBUS_UNLIKELY macros let the programmer give hints to @@ -146,7 +161,8 @@ void _dbus_real_assert_not_reached (const char *explanation, #define _dbus_return_if_fail(condition) #define _dbus_return_val_if_fail(condition, val) #else -extern const char *_dbus_return_if_fail_warning_format; + +DBUS_EXTERN const char *_dbus_return_if_fail_warning_format; #define _dbus_return_if_fail(condition) do { \ _dbus_assert ((*(const char*)_DBUS_FUNCTION_NAME) != '_'); \ @@ -260,7 +276,7 @@ void _dbus_verbose_bytes_of_string (const DBusString *str, const char* _dbus_header_field_to_string (int header_field); -extern const char *_dbus_no_memory_message; +DBUS_EXTERN const char *_dbus_no_memory_message; #define _DBUS_SET_OOM(error) dbus_set_error_const ((error), DBUS_ERROR_NO_MEMORY, _dbus_no_memory_message) #ifdef DBUS_BUILD_TESTS