/* 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);
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
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;
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)
{
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)
{
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)
{
DBusList **list;
- list = _dbus_hash_table_lookup_ulong (hash, key);
+ list = _dbus_hash_table_lookup_uintptr (hash, key);
if (list == NULL)
{
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;
_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);
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 ###############
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
/* 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
*
*/
#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
{
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:
/**
* 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;
_dbus_assert (real->table != NULL);
_dbus_assert (real->entry != NULL);
- return (unsigned long) real->entry->key;
+ return (uintptr_t) real->entry->key;
}
/**
#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;
/**
* 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.
* @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);
* @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);
* @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);
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;
if (value == NULL)
goto out;
- if (!_dbus_hash_table_insert_ulong (table3,
+ if (!_dbus_hash_table_insert_uintptr (table3,
i, value))
goto out;
_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);
_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]);
#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>
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,
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,
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,
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);
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);
#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
*/
#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))
*/
void
_dbus_pipe_init (DBusPipe *pipe,
- int fd)
+ intptr_t fd)
{
pipe->fd_or_handle = fd;
}
#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,
* @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;
* @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,
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
HANDLE hProcess,
DWORD AddrBase
);
+#endif
static BOOL (WINAPI *pSymInitialize)(
HANDLE hProcess,
PSTR UserSearchPath,
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
HANDLE hProcess,
DWORD AddrBase
))GetProcAddress (hmodDbgHelp, FUNC(SymFunctionTableAccess));
+#endif
pSymInitialize = (BOOL (WINAPI *)(
HANDLE hProcess,
PSTR UserSearchPath,
{
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;
}
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);
#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));
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);
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;
}
#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));
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);
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;
}
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)