Commit c096c5cb authored by Fridrich Štrba's avatar Fridrich Štrba Committed by Ralf Habacker

Don't truncate pointers on Windows x64 platform

parent f578ad20
......@@ -120,7 +120,7 @@ get_connections_for_uid (BusConnections *connections,
/* val is NULL is 0 when it isn't in the hash yet */
val = _dbus_hash_table_lookup_ulong (connections->completed_by_user,
val = _dbus_hash_table_lookup_uintptr (connections->completed_by_user,
uid);
current_count = _DBUS_POINTER_TO_INT (val);
......@@ -149,14 +149,14 @@ adjust_connections_for_uid (BusConnections *connections,
if (current_count == 0)
{
_dbus_hash_table_remove_ulong (connections->completed_by_user, uid);
_dbus_hash_table_remove_uintptr (connections->completed_by_user, uid);
return TRUE;
}
else
{
dbus_bool_t retval;
retval = _dbus_hash_table_insert_ulong (connections->completed_by_user,
retval = _dbus_hash_table_insert_uintptr (connections->completed_by_user,
uid, _DBUS_INT_TO_POINTER (current_count));
/* only positive adjustment can fail as otherwise
......@@ -439,7 +439,7 @@ bus_connections_new (BusContext *context)
if (connections == NULL)
goto failed_1;
connections->completed_by_user = _dbus_hash_table_new (DBUS_HASH_ULONG,
connections->completed_by_user = _dbus_hash_table_new (DBUS_HASH_UINTPTR,
NULL, NULL);
if (connections->completed_by_user == NULL)
goto failed_2;
......
......@@ -169,13 +169,13 @@ bus_policy_new (void)
policy->refcount = 1;
policy->rules_by_uid = _dbus_hash_table_new (DBUS_HASH_ULONG,
policy->rules_by_uid = _dbus_hash_table_new (DBUS_HASH_UINTPTR,
NULL,
free_rule_list_func);
if (policy->rules_by_uid == NULL)
goto failed;
policy->rules_by_gid = _dbus_hash_table_new (DBUS_HASH_ULONG,
policy->rules_by_gid = _dbus_hash_table_new (DBUS_HASH_UINTPTR,
NULL,
free_rule_list_func);
if (policy->rules_by_gid == NULL)
......@@ -304,7 +304,7 @@ bus_policy_create_client_policy (BusPolicy *policy,
{
DBusList **list;
list = _dbus_hash_table_lookup_ulong (policy->rules_by_gid,
list = _dbus_hash_table_lookup_uintptr (policy->rules_by_gid,
groups[i]);
if (list != NULL)
......@@ -328,7 +328,7 @@ bus_policy_create_client_policy (BusPolicy *policy,
{
DBusList **list;
list = _dbus_hash_table_lookup_ulong (policy->rules_by_uid,
list = _dbus_hash_table_lookup_uintptr (policy->rules_by_uid,
uid);
if (list != NULL)
......@@ -518,7 +518,7 @@ get_list (DBusHashTable *hash,
{
DBusList **list;
list = _dbus_hash_table_lookup_ulong (hash, key);
list = _dbus_hash_table_lookup_uintptr (hash, key);
if (list == NULL)
{
......@@ -526,7 +526,7 @@ get_list (DBusHashTable *hash,
if (list == NULL)
return NULL;
if (!_dbus_hash_table_insert_ulong (hash, key, list))
if (!_dbus_hash_table_insert_uintptr (hash, key, list))
{
dbus_free (list);
return NULL;
......@@ -639,7 +639,7 @@ merge_id_hash (DBusHashTable *dest,
_dbus_hash_iter_init (to_absorb, &iter);
while (_dbus_hash_iter_next (&iter))
{
unsigned long id = _dbus_hash_iter_get_ulong_key (&iter);
unsigned long id = _dbus_hash_iter_get_uintptr_key (&iter);
DBusList **list = _dbus_hash_iter_get_value (&iter);
DBusList **target = get_list (dest, id);
......
......@@ -488,7 +488,7 @@ set (DBUS_INTERNAL_CLIENT_DEFINITIONS "-DDBUS_STATIC_BUILD")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dbus-env.bat.cmake ${CMAKE_BINARY_DIR}/bin/dbus-env.bat )
install_files(/bin FILES ${CMAKE_BINARY_DIR}/bin/dbus-env.bat)
add_definitions(-DHAVE_CONFIG_H=1)
########### subdirs ###############
......
......@@ -18,6 +18,7 @@ check_include_file(sys/syslimits.h HAVE_SYS_SYSLIMITS_H) # dbus-sysdeps-uni
check_include_file(errno.h HAVE_ERRNO_H) # dbus-sysdeps.c
check_include_file(signal.h HAVE_SIGNAL_H)
check_include_file(locale.h HAVE_LOCALE_H)
check_include_file(inttypes.h HAVE_INTTYPES_H) # dbus-pipe.h
check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE) # dbus-sysdeps.c, dbus-sysdeps-win.c
check_symbol_exists(getgrouplist "grp.h" HAVE_GETGROUPLIST) # dbus-sysdeps.c
......
......@@ -143,6 +143,9 @@
/* Define to 1 if you have locale.h */
#cmakedefine HAVE_LOCALE_H 1
/* Define to 1 if you have inttypes.h */
#cmakedefine HAVE_INTTYPES_H 1
// symbols
/* Define to 1 if you have backtrace */
#cmakedefine HAVE_BACKTRACE 1
......
......@@ -120,7 +120,7 @@
*
*/
#define RANDOM_INDEX(table, i) \
(((((long) (i))*1103515245) >> (table)->down_shift) & (table)->mask)
(((((intptr_t) (i))*1103515245) >> (table)->down_shift) & (table)->mask)
/**
* Initial number of buckets in hash table (hash table statically
......@@ -328,7 +328,7 @@ _dbus_hash_table_new (DBusHashType type,
{
case DBUS_HASH_INT:
case DBUS_HASH_POINTER:
case DBUS_HASH_ULONG:
case DBUS_HASH_UINTPTR:
table->find_function = find_direct_function;
break;
case DBUS_HASH_STRING:
......@@ -684,12 +684,12 @@ _dbus_hash_iter_get_int_key (DBusHashIter *iter)
/**
* Gets the key for the current entry.
* Only works for hash tables of type #DBUS_HASH_ULONG.
* Only works for hash tables of type #DBUS_HASH_UINTPTR.
*
* @param iter the hash table iterator.
*/
unsigned long
_dbus_hash_iter_get_ulong_key (DBusHashIter *iter)
uintptr_t
_dbus_hash_iter_get_uintptr_key (DBusHashIter *iter)
{
DBusRealHashIter *real;
......@@ -698,7 +698,7 @@ _dbus_hash_iter_get_ulong_key (DBusHashIter *iter)
_dbus_assert (real->table != NULL);
_dbus_assert (real->entry != NULL);
return (unsigned long) real->entry->key;
return (uintptr_t) real->entry->key;
}
/**
......@@ -1116,7 +1116,7 @@ rebuild_table (DBusHashTable *table)
#endif
break;
case DBUS_HASH_INT:
case DBUS_HASH_ULONG:
case DBUS_HASH_UINTPTR:
case DBUS_HASH_POINTER:
idx = RANDOM_INDEX (table, entry->key);
break;
......@@ -1245,7 +1245,7 @@ _dbus_hash_table_lookup_pointer (DBusHashTable *table,
/**
* Looks up the value for a given integer in a hash table
* of type #DBUS_HASH_ULONG. Returns %NULL if the value
* of type #DBUS_HASH_UINTPTR. Returns %NULL if the value
* is not present. (A not-present entry is indistinguishable
* from an entry with a value of %NULL.)
* @param table the hash table.
......@@ -1253,12 +1253,12 @@ _dbus_hash_table_lookup_pointer (DBusHashTable *table,
* @returns the value of the hash entry.
*/
void*
_dbus_hash_table_lookup_ulong (DBusHashTable *table,
unsigned long key)
_dbus_hash_table_lookup_uintptr (DBusHashTable *table,
uintptr_t key)
{
DBusHashEntry *entry;
_dbus_assert (table->key_type == DBUS_HASH_ULONG);
_dbus_assert (table->key_type == DBUS_HASH_UINTPTR);
entry = (* table->find_function) (table, (void*) key, FALSE, NULL, NULL);
......@@ -1394,13 +1394,13 @@ _dbus_hash_table_remove_pointer (DBusHashTable *table,
* @returns #TRUE if the entry existed
*/
dbus_bool_t
_dbus_hash_table_remove_ulong (DBusHashTable *table,
unsigned long key)
_dbus_hash_table_remove_uintptr (DBusHashTable *table,
uintptr_t key)
{
DBusHashEntry *entry;
DBusHashEntry **bucket;
_dbus_assert (table->key_type == DBUS_HASH_ULONG);
_dbus_assert (table->key_type == DBUS_HASH_UINTPTR);
entry = (* table->find_function) (table, (void*) key, FALSE, &bucket, NULL);
......@@ -1591,13 +1591,13 @@ _dbus_hash_table_insert_pointer (DBusHashTable *table,
* @param value the hash entry value.
*/
dbus_bool_t
_dbus_hash_table_insert_ulong (DBusHashTable *table,
unsigned long key,
void *value)
_dbus_hash_table_insert_uintptr (DBusHashTable *table,
uintptr_t key,
void *value)
{
DBusHashEntry *entry;
_dbus_assert (table->key_type == DBUS_HASH_ULONG);
_dbus_assert (table->key_type == DBUS_HASH_UINTPTR);
entry = (* table->find_function) (table, (void*) key, TRUE, NULL, NULL);
......@@ -1810,7 +1810,7 @@ _dbus_hash_test (void)
if (table2 == NULL)
goto out;
table3 = _dbus_hash_table_new (DBUS_HASH_ULONG,
table3 = _dbus_hash_table_new (DBUS_HASH_UINTPTR,
NULL, dbus_free);
if (table3 == NULL)
goto out;
......@@ -1853,7 +1853,7 @@ _dbus_hash_test (void)
if (value == NULL)
goto out;
if (!_dbus_hash_table_insert_ulong (table3,
if (!_dbus_hash_table_insert_uintptr (table3,
i, value))
goto out;
......@@ -1881,7 +1881,7 @@ _dbus_hash_test (void)
_dbus_assert (value != NULL);
_dbus_assert (strcmp (value, keys[i]) == 0);
value = _dbus_hash_table_lookup_ulong (table3, i);
value = _dbus_hash_table_lookup_uintptr (table3, i);
_dbus_assert (value != NULL);
_dbus_assert (strcmp (value, keys[i]) == 0);
......@@ -1900,7 +1900,7 @@ _dbus_hash_test (void)
_dbus_hash_table_remove_int (table2, i);
_dbus_hash_table_remove_ulong (table3, i);
_dbus_hash_table_remove_uintptr (table3, i);
_dbus_hash_table_remove_two_strings (table4,
keys[i]);
......
......@@ -24,6 +24,14 @@
#ifndef DBUS_HASH_H
#define DBUS_HASH_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <dbus/dbus-memory.h>
#include <dbus/dbus-types.h>
......@@ -61,7 +69,7 @@ typedef enum
DBUS_HASH_TWO_STRINGS, /**< Hash key is two strings in one memory block, i.e. foo\\0bar\\0 */
DBUS_HASH_INT, /**< Hash keys are integers. */
DBUS_HASH_POINTER, /**< Hash keys are pointers. */
DBUS_HASH_ULONG /**< Hash keys are unsigned long. */
DBUS_HASH_UINTPTR /**< Hash keys are integer capable to hold a pointer. */
} DBusHashType;
DBusHashTable* _dbus_hash_table_new (DBusHashType type,
......@@ -80,7 +88,7 @@ void _dbus_hash_iter_set_value (DBusHashIter *iter,
int _dbus_hash_iter_get_int_key (DBusHashIter *iter);
const char* _dbus_hash_iter_get_string_key (DBusHashIter *iter);
const char* _dbus_hash_iter_get_two_strings_key (DBusHashIter *iter);
unsigned long _dbus_hash_iter_get_ulong_key (DBusHashIter *iter);
uintptr_t _dbus_hash_iter_get_uintptr_key (DBusHashIter *iter);
dbus_bool_t _dbus_hash_iter_lookup (DBusHashTable *table,
void *key,
dbus_bool_t create_if_not_found,
......@@ -93,8 +101,8 @@ void* _dbus_hash_table_lookup_int (DBusHashTable *table,
int key);
void* _dbus_hash_table_lookup_pointer (DBusHashTable *table,
void *key);
void* _dbus_hash_table_lookup_ulong (DBusHashTable *table,
unsigned long key);
void* _dbus_hash_table_lookup_uintptr (DBusHashTable *table,
uintptr_t key);
dbus_bool_t _dbus_hash_table_remove_string (DBusHashTable *table,
const char *key);
dbus_bool_t _dbus_hash_table_remove_two_strings (DBusHashTable *table,
......@@ -103,8 +111,8 @@ dbus_bool_t _dbus_hash_table_remove_int (DBusHashTable *table,
int key);
dbus_bool_t _dbus_hash_table_remove_pointer (DBusHashTable *table,
void *key);
dbus_bool_t _dbus_hash_table_remove_ulong (DBusHashTable *table,
unsigned long key);
dbus_bool_t _dbus_hash_table_remove_uintptr (DBusHashTable *table,
uintptr_t key);
dbus_bool_t _dbus_hash_table_insert_string (DBusHashTable *table,
char *key,
void *value);
......@@ -117,8 +125,8 @@ dbus_bool_t _dbus_hash_table_insert_int (DBusHashTable *table,
dbus_bool_t _dbus_hash_table_insert_pointer (DBusHashTable *table,
void *key,
void *value);
dbus_bool_t _dbus_hash_table_insert_ulong (DBusHashTable *table,
unsigned long key,
dbus_bool_t _dbus_hash_table_insert_uintptr (DBusHashTable *table,
uintptr_t key,
void *value);
int _dbus_hash_table_get_n_entries (DBusHashTable *table);
......
......@@ -167,13 +167,13 @@ extern const char *_dbus_return_if_fail_warning_format;
#define _DBUS_N_ELEMENTS(array) ((int) (sizeof ((array)) / sizeof ((array)[0])))
#define _DBUS_POINTER_TO_INT(pointer) ((long)(pointer))
#define _DBUS_INT_TO_POINTER(integer) ((void*)((long)(integer)))
#define _DBUS_POINTER_TO_INT(pointer) ((intptr_t)(pointer))
#define _DBUS_INT_TO_POINTER(integer) ((void*)((intptr_t)(integer)))
#define _DBUS_ZERO(object) (memset (&(object), '\0', sizeof ((object))))
#define _DBUS_STRUCT_OFFSET(struct_type, member) \
((long) ((unsigned char*) &((struct_type*) 0)->member))
((intptr_t) ((unsigned char*) &((struct_type*) 0)->member))
#ifdef DBUS_DISABLE_CHECKS
/* this is an assert and not an error, but in the typical --disable-checks case (you're trying
......@@ -201,7 +201,7 @@ extern const char *_dbus_return_if_fail_warning_format;
*/
#define _DBUS_ALIGN_VALUE(this, boundary) \
(( ((unsigned long)(this)) + (((unsigned long)(boundary)) -1)) & (~(((unsigned long)(boundary))-1)))
(( ((uintptr_t)(this)) + (((uintptr_t)(boundary)) -1)) & (~(((uintptr_t)(boundary))-1)))
#define _DBUS_ALIGN_ADDRESS(this, boundary) \
((void*)_DBUS_ALIGN_VALUE(this, boundary))
......
......@@ -33,7 +33,7 @@
*/
void
_dbus_pipe_init (DBusPipe *pipe,
int fd)
intptr_t fd)
{
pipe->fd_or_handle = fd;
}
......
......@@ -25,16 +25,24 @@
#ifndef DBUS_PIPE_H
#define DBUS_PIPE_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <dbus/dbus-types.h>
#include <dbus/dbus-errors.h>
#include <dbus/dbus-string.h>
typedef struct {
int fd_or_handle;
intptr_t fd_or_handle;
} DBusPipe;
void _dbus_pipe_init (DBusPipe *pipe,
int fd);
intptr_t fd);
void _dbus_pipe_init_stdout (DBusPipe *pipe);
int _dbus_pipe_write (DBusPipe *pipe,
const DBusString *buffer,
......
......@@ -2599,7 +2599,7 @@ _dbus_disable_sigpipe (void)
* @param fd the file descriptor
*/
void
_dbus_fd_set_close_on_exec (int fd)
_dbus_fd_set_close_on_exec (intptr_t fd)
{
int val;
......
......@@ -325,7 +325,7 @@ _dbus_close_socket (int fd,
* @param fd the file descriptor
*/
void
_dbus_fd_set_close_on_exec (int handle)
_dbus_fd_set_close_on_exec (intptr_t handle)
{
if ( !SetHandleInformation( (HANDLE) handle,
HANDLE_FLAG_INHERIT | HANDLE_FLAG_PROTECT_FROM_CLOSE,
......@@ -2171,6 +2171,16 @@ static BOOL (WINAPI *pStackWalk)(
PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine,
PTRANSLATE_ADDRESS_ROUTINE TranslateAddress
);
#ifdef _WIN64
static DWORD64 (WINAPI *pSymGetModuleBase)(
HANDLE hProcess,
DWORD64 dwAddr
);
static PVOID (WINAPI *pSymFunctionTableAccess)(
HANDLE hProcess,
DWORD64 AddrBase
);
#else
static DWORD (WINAPI *pSymGetModuleBase)(
HANDLE hProcess,
DWORD dwAddr
......@@ -2179,6 +2189,7 @@ static PVOID (WINAPI *pSymFunctionTableAccess)(
HANDLE hProcess,
DWORD AddrBase
);
#endif
static BOOL (WINAPI *pSymInitialize)(
HANDLE hProcess,
PSTR UserSearchPath,
......@@ -2233,6 +2244,16 @@ PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine,
PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine,
PTRANSLATE_ADDRESS_ROUTINE TranslateAddress
))GetProcAddress (hmodDbgHelp, FUNC(StackWalk));
#ifdef _WIN64
pSymGetModuleBase=(DWORD64 (WINAPI *)(
HANDLE hProcess,
DWORD64 dwAddr
))GetProcAddress (hmodDbgHelp, FUNC(SymGetModuleBase));
pSymFunctionTableAccess=(PVOID (WINAPI *)(
HANDLE hProcess,
DWORD64 AddrBase
))GetProcAddress (hmodDbgHelp, FUNC(SymFunctionTableAccess));
#else
pSymGetModuleBase=(DWORD (WINAPI *)(
HANDLE hProcess,
DWORD dwAddr
......@@ -2241,6 +2262,7 @@ PTRANSLATE_ADDRESS_ROUTINE TranslateAddress
HANDLE hProcess,
DWORD AddrBase
))GetProcAddress (hmodDbgHelp, FUNC(SymFunctionTableAccess));
#endif
pSymInitialize = (BOOL (WINAPI *)(
HANDLE hProcess,
PSTR UserSearchPath,
......@@ -2685,7 +2707,6 @@ _dbus_get_autolaunch_address (DBusString *address,
{
printf ("please add the path to %s to your PATH environment variable\n", daemon_name);
printf ("or start the daemon manually\n\n");
printf ("");
goto out;
}
......
......@@ -332,7 +332,7 @@ void _dbus_directory_close (DBusDirIter *iter);
dbus_bool_t _dbus_check_dir_is_private_to_user (DBusString *dir,
DBusError *error);
void _dbus_fd_set_close_on_exec (int fd);
void _dbus_fd_set_close_on_exec (intptr_t fd);
const char* _dbus_get_tmpdir (void);
......
......@@ -226,7 +226,7 @@ _dbus_user_database_lookup_group (DBusUserDatabase *db,
#ifdef DBUS_ENABLE_USERDB_CACHE
if (gid != DBUS_GID_UNSET)
info = _dbus_hash_table_lookup_ulong (db->groups, gid);
info = _dbus_hash_table_lookup_uintptr (db->groups, gid);
else
info = _dbus_hash_table_lookup_string (db->groups_by_name,
_dbus_string_get_const_data (groupname));
......@@ -278,7 +278,7 @@ _dbus_user_database_lookup_group (DBusUserDatabase *db,
gid = DBUS_GID_UNSET;
groupname = NULL;
if (!_dbus_hash_table_insert_ulong (db->groups, info->gid, info))
if (!_dbus_hash_table_insert_uintptr (db->groups, info->gid, info))
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
_dbus_group_info_free_allocated (info);
......@@ -290,7 +290,7 @@ _dbus_user_database_lookup_group (DBusUserDatabase *db,
info->groupname,
info))
{
_dbus_hash_table_remove_ulong (db->groups, info->gid);
_dbus_hash_table_remove_uintptr (db->groups, info->gid);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
return NULL;
}
......
......@@ -146,7 +146,7 @@ _dbus_user_database_lookup (DBusUserDatabase *db,
#ifdef DBUS_ENABLE_USERDB_CACHE
if (uid != DBUS_UID_UNSET)
info = _dbus_hash_table_lookup_ulong (db->users, uid);
info = _dbus_hash_table_lookup_uintptr (db->users, uid);
else
info = _dbus_hash_table_lookup_string (db->users_by_name, _dbus_string_get_const_data (username));
......@@ -199,7 +199,7 @@ _dbus_user_database_lookup (DBusUserDatabase *db,
username = NULL;
/* insert into hash */
if (!_dbus_hash_table_insert_ulong (db->users, info->uid, info))
if (!_dbus_hash_table_insert_uintptr (db->users, info->uid, info))
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
_dbus_user_info_free_allocated (info);
......@@ -210,7 +210,7 @@ _dbus_user_database_lookup (DBusUserDatabase *db,
info->username,
info))
{
_dbus_hash_table_remove_ulong (db->users, info->uid);
_dbus_hash_table_remove_uintptr (db->users, info->uid);
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
return NULL;
}
......@@ -538,13 +538,13 @@ _dbus_user_database_new (void)
db->refcount = 1;
db->users = _dbus_hash_table_new (DBUS_HASH_ULONG,
db->users = _dbus_hash_table_new (DBUS_HASH_UINTPTR,
NULL, (DBusFreeFunction) _dbus_user_info_free_allocated);
if (db->users == NULL)
goto failed;
db->groups = _dbus_hash_table_new (DBUS_HASH_ULONG,
db->groups = _dbus_hash_table_new (DBUS_HASH_UINTPTR,
NULL, (DBusFreeFunction) _dbus_group_info_free_allocated);
if (db->groups == NULL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment