2005-01-27 Havoc Pennington <hp@redhat.com>
[platform/upstream/dbus.git] / dbus / dbus-internals.h
index 258c646..3f0a34f 100644 (file)
@@ -39,9 +39,6 @@ DBUS_BEGIN_DECLS
 
 void _dbus_warn               (const char *format,
                                ...) _DBUS_GNUC_PRINTF (1, 2);
-void _dbus_verbose_real       (const char *format,
-                               ...) _DBUS_GNUC_PRINTF (1, 2);
-void _dbus_verbose_reset_real (void);
 
 #if defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
 #define _DBUS_FUNCTION_NAME __func__
@@ -79,6 +76,11 @@ void _dbus_verbose_reset_real (void);
 #endif
 
 #ifdef DBUS_ENABLE_VERBOSE_MODE
+
+void _dbus_verbose_real       (const char *format,
+                               ...) _DBUS_GNUC_PRINTF (1, 2);
+void _dbus_verbose_reset_real (void);
+
 #  define _dbus_verbose _dbus_verbose_real
 #  define _dbus_verbose_reset _dbus_verbose_reset_real
 #else
@@ -100,9 +102,10 @@ const char* _dbus_strerror (int error_number);
 void _dbus_real_assert (dbus_bool_t  condition,
                         const char  *condition_text,
                         const char  *file,
-                        int          line);
+                        int          line,
+                        const char  *func);
 #define _dbus_assert(condition)                                         \
-  _dbus_real_assert ((condition) != 0, #condition, __FILE__, __LINE__)
+  _dbus_real_assert ((condition) != 0, #condition, __FILE__, __LINE__, _DBUS_FUNCTION_NAME)
 #endif /* !DBUS_DISABLE_ASSERT */
 
 #ifdef DBUS_DISABLE_ASSERT
@@ -122,6 +125,7 @@ void _dbus_real_assert_not_reached (const char *explanation,
 extern const char _dbus_return_if_fail_warning_format[];
 
 #define _dbus_return_if_fail(condition) do {                                            \
+   _dbus_assert ((*(const char*)_DBUS_FUNCTION_NAME) != '_');                           \
   if (!(condition)) {                                                                   \
     _dbus_warn (_dbus_return_if_fail_warning_format,                                    \
                 _dbus_getpid (), _DBUS_FUNCTION_NAME, #condition, __FILE__, __LINE__);  \
@@ -129,6 +133,7 @@ extern const char _dbus_return_if_fail_warning_format[];
   } } while (0)
 
 #define _dbus_return_val_if_fail(condition, val) do {                                   \
+   _dbus_assert ((*(const char*)_DBUS_FUNCTION_NAME) != '_');                           \
   if (!(condition)) {                                                                   \
     _dbus_warn (_dbus_return_if_fail_warning_format,                                    \
                 _dbus_getpid (), _DBUS_FUNCTION_NAME, #condition, __FILE__, __LINE__);  \
@@ -170,6 +175,7 @@ extern const char _dbus_return_if_fail_warning_format[];
 #define _DBUS_ALIGN_ADDRESS(this, boundary) \
   ((void*)_DBUS_ALIGN_VALUE(this, boundary))
 
+
 char*       _dbus_strdup                (const char  *str);
 void*       _dbus_memdup                (const void  *mem,
                                          size_t       n_bytes);
@@ -177,11 +183,18 @@ dbus_bool_t _dbus_string_array_contains (const char **array,
                                          const char  *str);
 char**      _dbus_dup_string_array      (const char **array);
 
-#define _DBUS_INT_MIN   (-_DBUS_INT_MAX - 1)
-#define _DBUS_INT_MAX   2147483647
-#define _DBUS_UINT_MAX  0xffffffff
+#define _DBUS_INT16_MIN         ((dbus_int16_t) 0x8000)
+#define _DBUS_INT16_MAX         ((dbus_int16_t) 0x7fff)
+#define _DBUS_UINT16_MAX ((dbus_uint16_t)0xffff)
+#define _DBUS_INT32_MIN         ((dbus_int32_t) 0x80000000)
+#define _DBUS_INT32_MAX         ((dbus_int32_t) 0x7fffffff)
+#define _DBUS_UINT32_MAX ((dbus_uint32_t)0xffffffff)
+/* using 32-bit here is sort of bogus */
+#define _DBUS_INT_MIN   _DBUS_INT32_MIN
+#define _DBUS_INT_MAX   _DBUS_INT32_MAX
+#define _DBUS_UINT_MAX  _DBUS_UINT32_MAX
 #ifdef DBUS_HAVE_INT64
-#define _DBUS_INT64_MAX         DBUS_INT64_CONSTANT (9223372036854775807)
+#define _DBUS_INT64_MAX         DBUS_INT64_CONSTANT  (0x7fffffffffffffff)
 #define _DBUS_UINT64_MAX DBUS_UINT64_CONSTANT (0xffffffffffffffff)
 #endif
 #define _DBUS_ONE_KILOBYTE 1024
@@ -198,6 +211,8 @@ char**      _dbus_dup_string_array      (const char **array);
 #undef ABS
 #define ABS(a)    (((a) < 0) ? -(a) : (a))
 
+#define _DBUS_ISASCII(c) ((c) != '\0' && (((c) & ~0x7f) == 0))
+
 typedef void (* DBusForeachFunction) (void *element,
                                       void *data);
 
@@ -205,13 +220,12 @@ dbus_bool_t _dbus_set_fd_nonblocking (int             fd,
                                       DBusError      *error);
 
 void _dbus_verbose_bytes           (const unsigned char *data,
-                                    int                  len);
+                                    int                  len,
+                                    int                  offset);
 void _dbus_verbose_bytes_of_string (const DBusString    *str,
                                     int                  start,
                                     int                  len);
 
-
-const char* _dbus_type_to_string         (int type);
 const char* _dbus_header_field_to_string (int header_field);
 
 extern const char _dbus_no_memory_message[];
@@ -265,7 +279,8 @@ _DBUS_DECLARE_GLOBAL_LOCK (atomic);
 _DBUS_DECLARE_GLOBAL_LOCK (bus);
 _DBUS_DECLARE_GLOBAL_LOCK (shutdown_funcs);
 _DBUS_DECLARE_GLOBAL_LOCK (system_users);
-#define _DBUS_N_GLOBAL_LOCKS (9)
+_DBUS_DECLARE_GLOBAL_LOCK (message_cache);
+#define _DBUS_N_GLOBAL_LOCKS (10)
 
 dbus_bool_t _dbus_threads_init_debug (void);