diff options
author | Akira TAGOH <akira@tagoh.org> | 2011-01-12 20:30:28 +0900 |
---|---|---|
committer | Akira TAGOH <akira@tagoh.org> | 2011-01-12 20:30:28 +0900 |
commit | 57511fd271834f6f6f7b6f396c451afd6241a6c4 (patch) | |
tree | 5735cc4dbaba877bcaf9e1696a3697af6715bea0 | |
parent | aaf15a22d1ec70e3be81443e147e0523f2f5cb5c (diff) |
clean up hgmacros.h
45 files changed, 128 insertions, 70 deletions
diff --git a/devices/cairo/Makefile.am b/devices/cairo/Makefile.am index 8047536..c2824d1 100644 --- a/devices/cairo/Makefile.am +++ b/devices/cairo/Makefile.am @@ -6,6 +6,7 @@ INCLUDES = \ $(CAIRO_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/hieroglyph \ + -DHG_COMPILATION \ $(NULL) LIBS = \ @LDFLAGS@ \ diff --git a/devices/cairo/cairo-main.c b/devices/cairo/cairo-main.c index 912c541..8a07e15 100644 --- a/devices/cairo/cairo-main.c +++ b/devices/cairo/cairo-main.c @@ -29,6 +29,8 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <cairo/cairo-xlib.h> +/* GLib is still needed for the mutex lock */ +#include <glib.h> #include "hgarray.h" #include "hgerror.h" #include "hggstate.h" diff --git a/hieroglyph/Makefile.am b/hieroglyph/Makefile.am index 53daeaf..c5dc90e 100644 --- a/hieroglyph/Makefile.am +++ b/hieroglyph/Makefile.am @@ -122,9 +122,10 @@ LEX_OUTPUT_ROOT=lex.$(basename $<) ## # Local Rules -$(hg_proto_files): $(hg_lex_sources) $(hg_sources) $(top_srcdir)/build_tools/genfuncdecls.sh Makefile .c.proto: - $(AM_V_GEN)[[ ! -f $(<:.c=.l) ]] && $(top_srcdir)/build_tools/genfuncdecls.sh $< > $@ || $(top_srcdir)/build_tools/genfuncdecls.sh $(<:.c=.l) > $@ + $(AM_V_GEN)[[ ! -f $(<:.c=.l) ]] && $(top_srcdir)/build_tools/genfuncdecls.sh $< > gfp || $(top_srcdir)/build_tools/genfuncdecls.sh $(<:.c=.l) > gfp; \ + (cmp -s gfp $@ || cp gfp $@) \ + && rm -f gfp ## # Target platform diff --git a/hieroglyph/hgallocator-private.h b/hieroglyph/hgallocator-private.h index 1abd30f..1b09b3c 100644 --- a/hieroglyph/hgallocator-private.h +++ b/hieroglyph/hgallocator-private.h @@ -74,12 +74,6 @@ enum _hg_allocator_type_bit_t { HG_ALLOC_TYPE_BIT_END }; -#define hg_get_allocated_object(x) \ - (gpointer)((gchar *)(x) + hg_mem_aligned_size(sizeof (hg_allocator_block_t))) -#define hg_get_allocator_block(x) \ - (hg_allocator_block_t *)((gchar *)(x) - hg_mem_aligned_size(sizeof (hg_allocator_block_t))) - - struct _hg_allocator_bitmap_t { guint32 **bitmaps; gsize *size; @@ -108,11 +102,18 @@ struct _hg_allocator_snapshot_private_t { }; -G_INLINE_FUNC hg_quark_t _hg_allocator_quark_build (gint32 page, - guint32 idx); -G_INLINE_FUNC guint32 _hg_allocator_quark_get_page (hg_quark_t qdata); -G_INLINE_FUNC guint32 _hg_allocator_quark_get_index (hg_quark_t qdata); +G_INLINE_FUNC hg_allocator_block_t *_hg_allocator_get_block (hg_pointer_t *p); +G_INLINE_FUNC hg_quark_t _hg_allocator_quark_build (gint32 page, + guint32 idx); +G_INLINE_FUNC guint32 _hg_allocator_quark_get_page (hg_quark_t qdata); +G_INLINE_FUNC guint32 _hg_allocator_quark_get_index(hg_quark_t qdata); + +G_INLINE_FUNC hg_allocator_block_t * +_hg_allocator_get_block(hg_pointer_t *p) +{ + return (hg_allocator_block_t *)((gchar *)(p) - HG_ALIGNED_TO_POINTER (sizeof (hg_allocator_block_t))); +} G_INLINE_FUNC hg_quark_t _hg_allocator_quark_build(gint32 page, diff --git a/hieroglyph/hgallocator.c b/hieroglyph/hgallocator.c index 4a025da..979b14d 100644 --- a/hieroglyph/hgallocator.c +++ b/hieroglyph/hgallocator.c @@ -1,7 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * hgallocator.c - * Copyright (C) 2006-2010 Akira TAGOH + * Copyright (C) 2006-2011 Akira TAGOH * * Authors: * Akira TAGOH <akira@tagoh.org> @@ -27,6 +27,8 @@ #include <stdlib.h> #include <string.h> +/* GLib is still needed for the mutex lock */ +#include <glib.h> #include "hgerror.h" #include "hgquark.h" #include "hgallocator.h" @@ -72,6 +74,12 @@ hg_allocator_get_max_page(void) return retval; } +G_INLINE_FUNC hg_pointer_t +hg_allocator_get_allocated_object(hg_allocator_block_t *block) +{ + return (hg_pointer_t)((gchar *)(block) - HG_ALIGNED_TO_POINTER (sizeof (hg_allocator_block_t))); +} + /** bitmap operation **/ G_INLINE_FUNC hg_allocator_bitmap_t * _hg_allocator_bitmap_new(gsize size) @@ -83,8 +91,8 @@ _hg_allocator_bitmap_new(gsize size) hg_return_val_if_fail (size > 0, NULL); hg_return_val_if_fail (size <= hg_allocator_get_page_size() * BLOCK_SIZE, NULL); - aligned_size = hg_mem_aligned_to (size, BLOCK_SIZE); - bitmap_size = hg_mem_aligned_to (aligned_size / BLOCK_SIZE, sizeof (guint32)); + aligned_size = HG_ALIGNED_TO (size, BLOCK_SIZE); + bitmap_size = HG_ALIGNED_TO (aligned_size / BLOCK_SIZE, sizeof (guint32)); retval = g_new0(hg_allocator_bitmap_t, 1); if (retval) { retval->bitmaps = g_new0(guint32 *, max_page); @@ -163,8 +171,8 @@ _hg_allocator_bitmap_add_page_to(hg_allocator_bitmap_t *bitmap, G_LOCK (bitmap); - aligned_size = hg_mem_aligned_to (size, BLOCK_SIZE); - bitmap_size = hg_mem_aligned_to (aligned_size / BLOCK_SIZE, sizeof (guint32)); + aligned_size = HG_ALIGNED_TO (size, BLOCK_SIZE); + bitmap_size = HG_ALIGNED_TO (aligned_size / BLOCK_SIZE, sizeof (guint32)); if (page >= 0) { bitmap->bitmaps[page] = g_new0(guint32, bitmap_size / sizeof (guint32)); bitmap->size[page] = bitmap_size; @@ -184,7 +192,7 @@ _hg_allocator_bitmap_alloc(hg_allocator_bitmap_t *bitmap, guint32 i, j, idx = 0; gboolean retry = FALSE; - aligned_size = hg_mem_aligned_to(size, BLOCK_SIZE) / BLOCK_SIZE; + aligned_size = HG_ALIGNED_TO (size, BLOCK_SIZE) / BLOCK_SIZE; page = bitmap->last_page; #if defined(HG_DEBUG) && defined(HG_MEM_DEBUG) @@ -244,8 +252,8 @@ _hg_allocator_bitmap_realloc(hg_allocator_bitmap_t *bitmap, hg_return_val_if_fail (index_ != Qnil, Qnil); hg_return_val_if_fail (size > 0, Qnil); - aligned_size = hg_mem_aligned_to(size, BLOCK_SIZE) / BLOCK_SIZE; - old_aligned_size = hg_mem_aligned_to(old_size, BLOCK_SIZE) / BLOCK_SIZE; + aligned_size = HG_ALIGNED_TO (size, BLOCK_SIZE) / BLOCK_SIZE; + old_aligned_size = HG_ALIGNED_TO (old_size, BLOCK_SIZE) / BLOCK_SIZE; page = _hg_allocator_quark_get_page(index_); idx = _hg_allocator_quark_get_index(index_); #if defined(HG_DEBUG) && defined(HG_MEM_DEBUG) @@ -304,7 +312,7 @@ _hg_allocator_bitmap_free(hg_allocator_bitmap_t *bitmap, hg_return_if_fail (index_ > 0); hg_return_if_fail (size > 0); - aligned_size = hg_mem_aligned_to(size, BLOCK_SIZE) / BLOCK_SIZE; + aligned_size = HG_ALIGNED_TO (size, BLOCK_SIZE) / BLOCK_SIZE; page = _hg_allocator_quark_get_page(index_); idx = _hg_allocator_quark_get_index(index_); @@ -522,7 +530,7 @@ _hg_allocator_alloc(hg_allocator_data_t *data, priv = (hg_allocator_private_t *)data; - obj_size = hg_mem_aligned_size (sizeof (hg_allocator_block_t) + size); + obj_size = HG_ALIGNED_TO_POINTER (sizeof (hg_allocator_block_t) + size); index_ = _hg_allocator_bitmap_alloc(priv->bitmap, obj_size); if (index_ != Qnil) { /* Update the used size */ @@ -539,7 +547,7 @@ _hg_allocator_alloc(hg_allocator_data_t *data, * VM manages. otherwise it will be swept by GC. */ if (ret) - *ret = hg_get_allocated_object (block); + *ret = hg_allocator_get_allocated_object(block); else _hg_allocator_real_unlock_object(block); } @@ -562,7 +570,7 @@ _hg_allocator_realloc(hg_allocator_data_t *data, priv = (hg_allocator_private_t *)data; - obj_size = hg_mem_aligned_size (sizeof (hg_allocator_block_t) + size); + obj_size = HG_ALIGNED_TO_POINTER (sizeof (hg_allocator_block_t) + size); block = _hg_allocator_real_lock_object(data, qdata); if (G_LIKELY (block)) { volatile gint make_sure_if_no_referrer; @@ -587,7 +595,7 @@ _hg_allocator_realloc(hg_allocator_data_t *data, retval = index_; if (ret) - *ret = hg_get_allocated_object (new_block); + *ret = hg_allocator_get_allocated_object(new_block); else _hg_allocator_real_unlock_object(new_block); } else { @@ -704,7 +712,7 @@ _hg_allocator_lock_object(hg_allocator_data_t *data, G_UNLOCK (allocator); if (retval) - return hg_get_allocated_object (retval); + return hg_allocator_get_allocated_object(retval); return NULL; } @@ -789,7 +797,7 @@ _hg_allocator_gc_mark(hg_allocator_data_t *data, if (block) { page = _hg_allocator_quark_get_page(index_); idx = _hg_allocator_quark_get_index(index_); - aligned_size = hg_mem_aligned_to(block->size, BLOCK_SIZE) / BLOCK_SIZE; + aligned_size = HG_ALIGNED_TO (block->size, BLOCK_SIZE) / BLOCK_SIZE; if (_hg_allocator_bitmap_range_mark(priv->slave_bitmap, page, &idx, aligned_size)) { #if defined(HG_DEBUG) && defined(HG_GC_DEBUG) g_print("GC: Marked index %ld, size: %ld\n", index_, aligned_size); @@ -872,7 +880,7 @@ _hg_allocator_gc_finish(hg_allocator_data_t *data, break; } } - aligned_size = hg_mem_aligned_to(block->size, BLOCK_SIZE) / BLOCK_SIZE; + aligned_size = HG_ALIGNED_TO (block->size, BLOCK_SIZE) / BLOCK_SIZE; j += aligned_size - 1; } } @@ -972,7 +980,7 @@ _hg_allocator_restore_snapshot(hg_allocator_data_t *data, goto error; } } - aligned_size = hg_mem_aligned_to(b1->size, BLOCK_SIZE) / BLOCK_SIZE; + aligned_size = HG_ALIGNED_TO (b1->size, BLOCK_SIZE) / BLOCK_SIZE; j += aligned_size - 1; } else if (f1 && !f2) { hg_allocator_block_t *b1; @@ -988,7 +996,7 @@ _hg_allocator_restore_snapshot(hg_allocator_data_t *data, #endif goto error; } - aligned_size = hg_mem_aligned_to(b1->size, BLOCK_SIZE) / BLOCK_SIZE; + aligned_size = HG_ALIGNED_TO (b1->size, BLOCK_SIZE) / BLOCK_SIZE; j += aligned_size - 1; } else if (!f1 && f2) { hg_allocator_block_t *b2; @@ -996,7 +1004,7 @@ _hg_allocator_restore_snapshot(hg_allocator_data_t *data, gsize idx = j * BLOCK_SIZE; b2 = (hg_allocator_block_t *)((gulong)spriv->heaps[i] + idx); - check_size = aligned_size = hg_mem_aligned_to(b2->size, BLOCK_SIZE) / BLOCK_SIZE; + check_size = aligned_size = HG_ALIGNED_TO (b2->size, BLOCK_SIZE) / BLOCK_SIZE; check_size--; for (k = j + 1; check_size > 0 && k < priv->bitmap->size[i]; k++) { if (_hg_allocator_bitmap_is_marked(priv->bitmap, i, k + 1)) { @@ -1031,7 +1039,7 @@ _hg_allocator_restore_snapshot(hg_allocator_data_t *data, (((gchar *)spriv->heaps[i]) + j * BLOCK_SIZE), block->size); } - aligned_size = hg_mem_aligned_to(block->size, BLOCK_SIZE) / BLOCK_SIZE; + aligned_size = HG_ALIGNED_TO (block->size, BLOCK_SIZE) / BLOCK_SIZE; j += aligned_size - 1; } } diff --git a/hieroglyph/hgarray.c b/hieroglyph/hgarray.c index 6a47a0e..127f9c9 100644 --- a/hieroglyph/hgarray.c +++ b/hieroglyph/hgarray.c @@ -26,6 +26,7 @@ #endif #include <string.h> +#include <glib.h> #include "hgerror.h" #include "hgmatrix.h" #include "hgmem.h" @@ -47,7 +48,7 @@ HG_DEFINE_VTABLE_WITH (array, NULL, NULL, NULL); static gsize _hg_object_array_get_capsulated_size(void) { - return hg_mem_aligned_size (sizeof (hg_array_t)); + return HG_ALIGNED_TO_POINTER (sizeof (hg_array_t)); } static guint diff --git a/hieroglyph/hgdevice.c b/hieroglyph/hgdevice.c index 507afc4..6949221 100644 --- a/hieroglyph/hgdevice.c +++ b/hieroglyph/hgdevice.c @@ -26,6 +26,7 @@ #endif #include <string.h> +#include <glib.h> #include "hgarray.h" #include "hgbool.h" #include "hgdict.h" diff --git a/hieroglyph/hgdict.c b/hieroglyph/hgdict.c index da3bfa4..7a9ad41 100644 --- a/hieroglyph/hgdict.c +++ b/hieroglyph/hgdict.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include <glib.h> #include "hgerror.h" #include "hgmem.h" #include "hgstring.h" @@ -60,7 +61,7 @@ static gsize __hg_dict_node_size = HG_DICT_NODE_SIZE; static gsize _hg_object_dict_get_capsulated_size(void) { - return hg_mem_aligned_size (sizeof (hg_dict_t)); + return HG_ALIGNED_TO_POINTER (sizeof (hg_dict_t)); } static guint @@ -214,7 +215,7 @@ _hg_object_dict_get_attributes(hg_object_t *object) static gsize _hg_object_dict_node_get_capsulated_size(void) { - return hg_mem_aligned_size (sizeof (hg_dict_node_t)); + return HG_ALIGNED_TO_POINTER (sizeof (hg_dict_node_t)); } static guint diff --git a/hieroglyph/hgencoding.c b/hieroglyph/hgencoding.c index 3f8aee4..3a5dd89 100644 --- a/hieroglyph/hgencoding.c +++ b/hieroglyph/hgencoding.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include <glib.h> #include "hgerror.h" #include "hgencoding.h" diff --git a/hieroglyph/hgerror.c b/hieroglyph/hgerror.c index eec3efe..7fa6732 100644 --- a/hieroglyph/hgerror.c +++ b/hieroglyph/hgerror.c @@ -27,6 +27,7 @@ #include <execinfo.h> #include <stdlib.h> +#include <glib.h> #include "hgerror.h" diff --git a/hieroglyph/hgfile.c b/hieroglyph/hgfile.c index 0e650ed..3ae97e8 100644 --- a/hieroglyph/hgfile.c +++ b/hieroglyph/hgfile.c @@ -32,6 +32,7 @@ #include <sys/stat.h> #include <sys/types.h> #include <unistd.h> +#include <glib.h> #include "hglineedit.h" #include "hgmem.h" #include "hgfile.h" @@ -112,7 +113,7 @@ HG_DEFINE_VTABLE (file); static gsize _hg_object_file_get_capsulated_size(void) { - return hg_mem_aligned_size (sizeof (hg_file_t)); + return HG_ALIGNED_TO_POINTER (sizeof (hg_file_t)); } static guint diff --git a/hieroglyph/hggstate.c b/hieroglyph/hggstate.c index 59d8763..7ca9a8b 100644 --- a/hieroglyph/hggstate.c +++ b/hieroglyph/hggstate.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include <glib.h> #include "hgarray.h" #include "hgint.h" #include "hgmem.h" @@ -39,7 +40,7 @@ HG_DEFINE_VTABLE_WITH (gstate, NULL, NULL, NULL); static gsize _hg_object_gstate_get_capsulated_size(void) { - return hg_mem_aligned_size (sizeof (hg_gstate_t)); + return HG_ALIGNED_TO_POINTER (sizeof (hg_gstate_t)); } static guint diff --git a/hieroglyph/hglineedit.l b/hieroglyph/hglineedit.l index 8736859..50b2c0d 100644 --- a/hieroglyph/hglineedit.l +++ b/hieroglyph/hglineedit.l @@ -26,6 +26,7 @@ #include "config.h" #endif +#include <glib.h> #include "hgerror.h" #include "hgmem.h" #include "hglineedit.h" diff --git a/hieroglyph/hgmacros.h b/hieroglyph/hgmacros.h index b871759..4364742 100644 --- a/hieroglyph/hgmacros.h +++ b/hieroglyph/hgmacros.h @@ -1,7 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * hgmacros.h - * Copyright (C) 2006-2010 Akira TAGOH + * Copyright (C) 2006-2011 Akira TAGOH * * Authors: * Akira TAGOH <akira@tagoh.org> @@ -21,26 +21,45 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ -#ifndef __HIEROGLYPH_HGMACROS_H__ -#define __HIEROGLYPH_HGMACROS_H__ +#if !defined (__HG_H_INSIDE__) && !defined (HG_COMPILATION) +#error "Only <hieroglyph/hg.h> can be included directly." +#endif -#include <glib.h> +#include <stddef.h> -G_BEGIN_DECLS +#ifndef __HIEROGLYPH_HGMACROS_H__ +#define __HIEROGLYPH_HGMACROS_H__ +/* enable a debugging code */ #if defined(GNOME_ENABLE_DEBUG) || defined(DEBUG) #define HG_DEBUG +#define hg_d(x) x +#else +#define hg_d(x) #endif /* GNOME_ENABLE_DEBUG || DEBUG */ -#define HGPOINTER_TO_QUARK(p) ((hg_quark_t)(gulong)(p)) -#define HGQUARK_TO_POINTER(q) ((gpointer)(gulong)(q)) +/* Guard C code in headers, while including them from C++ */ +#ifdef __cplusplus +#define HG_BEGIN_DECLS extern "C" { +#define HG_END_DECLS } +#else +#define HG_BEGIN_DECLS +#define HG_END_DECLS +#endif + +/* boolean */ +#define HG_FALSE (0) +#define HG_TRUE (!HG_FALSE) -#define hg_mem_aligned_to(x,y) \ - (((x) + (y) - 1) & ~((y) - 1)) -#define hg_mem_aligned_size(x) \ - hg_mem_aligned_to(x, ALIGNOF_VOID_P) +/* interconversion between hg_quark_t and hg_pointer_t */ +#define HGPOINTER_TO_QUARK(_p_) ((hg_quark_t)(_p_)) +#define HGQUARK_TO_POINTER(_q_) ((hg_pointer_t)(hg_quark_t)(_q_)) +/* Macros to adjust an alignment */ +#define HG_ALIGNED_TO(_x_,_y_) \ + (((_x_) + (_y_) - 1) & ~((_y_) - 1)) +#define HG_ALIGNED_TO_POINTER(_x_) \ + HG_ALIGNED_TO ((_x_), ALIGNOF_VOID_P) -G_END_DECLS #endif /* __HIEROGLYPH_HGMACROS_H__ */ diff --git a/hieroglyph/hgmatrix.c b/hieroglyph/hgmatrix.c index 9a58a69..ba9dde3 100644 --- a/hieroglyph/hgmatrix.c +++ b/hieroglyph/hgmatrix.c @@ -27,6 +27,7 @@ #include <math.h> #include <string.h> +#include <glib.h> #include "hgerror.h" #include "hgmatrix.h" diff --git a/hieroglyph/hgmem.c b/hieroglyph/hgmem.c index e018337..f122089 100644 --- a/hieroglyph/hgmem.c +++ b/hieroglyph/hgmem.c @@ -26,6 +26,7 @@ #endif /* HAVE_CONFIG_H */ #include <math.h> +#include <glib.h> #include "hgallocator.h" #include "hgerror.h" #include "hgquark.h" diff --git a/hieroglyph/hgname.c b/hieroglyph/hgname.c index 3517630..36cf7ee 100644 --- a/hieroglyph/hgname.c +++ b/hieroglyph/hgname.c @@ -26,6 +26,7 @@ #endif #include <string.h> +#include <glib.h> #include "hgerror.h" #include "hgquark.h" #include "hgname.h" diff --git a/hieroglyph/hgobject.c b/hieroglyph/hgobject.c index d52368f..4d669fc 100644 --- a/hieroglyph/hgobject.c +++ b/hieroglyph/hgobject.c @@ -26,6 +26,7 @@ #endif #include <string.h> +#include <glib.h> #include "hgerror.h" #include "hgmark.h" #include "hgmem.h" @@ -161,7 +162,7 @@ hg_object_new(hg_mem_t *mem, v = __hg_object_vtables[type]; size = v->get_capsulated_size(); - index = _hg_object_new(mem, type, size + hg_mem_aligned_size (preallocated_size), &retval); + index = _hg_object_new(mem, type, size + HG_ALIGNED_TO_POINTER (preallocated_size), &retval); if (index == Qnil) return Qnil; diff --git a/hieroglyph/hgoperator.c b/hieroglyph/hgoperator.c index 57a4dc8..c445ea6 100644 --- a/hieroglyph/hgoperator.c +++ b/hieroglyph/hgoperator.c @@ -27,6 +27,7 @@ #include <stdlib.h> #include <sys/stat.h> +#include <glib.h> #include "hgerror.h" #include "hgbool.h" #include "hgdevice.h" diff --git a/hieroglyph/hgpath.c b/hieroglyph/hgpath.c index 17bc34e..e9c082d 100644 --- a/hieroglyph/hgpath.c +++ b/hieroglyph/hgpath.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include <glib.h> #include "hgmem.h" #include "hgpath.h" @@ -46,7 +47,7 @@ HG_DEFINE_VTABLE_WITH (path, NULL, NULL, NULL); static gsize _hg_object_path_get_capsulated_size(void) { - return hg_mem_aligned_size (sizeof (hg_path_t)); + return HG_ALIGNED_TO_POINTER (sizeof (hg_path_t)); } static guint diff --git a/hieroglyph/hgplugin.c b/hieroglyph/hgplugin.c index 8a5bdc5..de7cb1d 100644 --- a/hieroglyph/hgplugin.c +++ b/hieroglyph/hgplugin.c @@ -26,6 +26,7 @@ #endif #include <string.h> +#include <glib.h> #include "hgmem.h" #include "hgplugin.h" diff --git a/hieroglyph/hgsnapshot.c b/hieroglyph/hgsnapshot.c index b8f3b36..c193e05 100644 --- a/hieroglyph/hgsnapshot.c +++ b/hieroglyph/hgsnapshot.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include <glib.h> #include "hgmem.h" #include "hgsnapshot.h" @@ -42,7 +43,7 @@ HG_DEFINE_VTABLE (snapshot); static gsize _hg_object_snapshot_get_capsulated_size(void) { - return hg_mem_aligned_size (sizeof (hg_snapshot_t)); + return HG_ALIGNED_TO_POINTER (sizeof (hg_snapshot_t)); } static guint diff --git a/hieroglyph/hgstack.c b/hieroglyph/hgstack.c index 2492e25..a4d60e4 100644 --- a/hieroglyph/hgstack.c +++ b/hieroglyph/hgstack.c @@ -26,6 +26,7 @@ #endif #include <stdlib.h> +#include <glib.h> #include "hgerror.h" #include "hgmem.h" #include "hgstack-private.h" @@ -41,7 +42,7 @@ HG_DEFINE_VTABLE_WITH (stack, NULL, NULL, NULL); static gsize _hg_object_stack_get_capsulated_size(void) { - return hg_mem_aligned_size (sizeof (hg_stack_t)); + return HG_ALIGNED_TO_POINTER (sizeof (hg_stack_t)); } static guint diff --git a/hieroglyph/hgstring.c b/hieroglyph/hgstring.c index 55676bb..797f24b 100644 --- a/hieroglyph/hgstring.c +++ b/hieroglyph/hgstring.c @@ -27,6 +27,7 @@ #include <ctype.h> #include <string.h> +#include <glib.h> #include "hgerror.h" #include "hgmem.h" #include "hgquark.h" @@ -44,7 +45,7 @@ HG_DEFINE_VTABLE_WITH (string, NULL, NULL, NULL); static gsize _hg_object_string_get_capsulated_size(void) { - return hg_mem_aligned_size (sizeof (hg_string_t)); + return HG_ALIGNED_TO_POINTER (sizeof (hg_string_t)); } static guint diff --git a/hieroglyph/hgtypes.h b/hieroglyph/hgtypes.h index 28004b2..338ec41 100644 --- a/hieroglyph/hgtypes.h +++ b/hieroglyph/hgtypes.h @@ -32,6 +32,7 @@ G_BEGIN_DECLS /* hgquark.h */ typedef gint64 hg_quark_t; +typedef gpointer hg_pointer_t; /* hgmem.h */ typedef struct _hg_mem_t hg_mem_t; diff --git a/hieroglyph/hgvm.c b/hieroglyph/hgvm.c index 3eb06eb..e30cd03 100644 --- a/hieroglyph/hgvm.c +++ b/hieroglyph/hgvm.c @@ -26,6 +26,7 @@ #endif #include <stdlib.h> +#include <glib.h> #include "hgbool.h" #include "hgdevice.h" #include "hgdict.h" diff --git a/plugins/libedit/Makefile.am b/plugins/libedit/Makefile.am index 7cc9ff5..a245d04 100644 --- a/plugins/libedit/Makefile.am +++ b/plugins/libedit/Makefile.am @@ -6,6 +6,7 @@ INCLUDES = \ $(LIBEDIT_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/hieroglyph \ + -DHG_COMPILATION \ $(NULL) LIBS = \ @LDFLAGS@ \ diff --git a/plugins/libedit/libedit-main.c b/plugins/libedit/libedit-main.c index d1b83ea..1bfc5cc 100644 --- a/plugins/libedit/libedit-main.c +++ b/plugins/libedit/libedit-main.c @@ -30,6 +30,7 @@ #endif #include <readline.h> +#include <glib.h> #define PLUGIN #include "hgdict.h" #include "hgplugin.h" diff --git a/plugins/unittest/Makefile.am b/plugins/unittest/Makefile.am index ea615e3..8b30185 100644 --- a/plugins/unittest/Makefile.am +++ b/plugins/unittest/Makefile.am @@ -5,6 +5,7 @@ INCLUDES = \ $(GLIB_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/hieroglyph \ + -DHG_COMPILATION \ $(NULL) LIBS = \ @LDFLAGS@ \ diff --git a/plugins/unittest/unittest-main.c b/plugins/unittest/unittest-main.c index 57fd83d..09856fd 100644 --- a/plugins/unittest/unittest-main.c +++ b/plugins/unittest/unittest-main.c @@ -25,6 +25,7 @@ #include "config.h" #endif +#include <glib.h> #define PLUGIN #include "hgbool.h" #include "hgdict.h" diff --git a/src/hgs/Makefile.am b/src/hgs/Makefile.am index 27fe200..a4331d0 100644 --- a/src/hgs/Makefile.am +++ b/src/hgs/Makefile.am @@ -4,6 +4,7 @@ NULL = INCLUDES = \ $(GLIB_CFLAGS) \ -I$(top_srcdir) \ + -DHG_COMPILATION \ $(NULL) LIBS = \ @LDFLAGS@ \ diff --git a/tests/Makefile.am b/tests/Makefile.am index f825300..91017f4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -8,6 +8,7 @@ INCLUDES = \ $(CHECK_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/hieroglyph \ + -DHG_COMPILATION \ $(NULL) DEPS = \ $(top_builddir)/hieroglyph/libhieroglyph.la \ diff --git a/tests/hgallocator.c b/tests/hgallocator.c index 5fd6ced..2287545 100644 --- a/tests/hgallocator.c +++ b/tests/hgallocator.c @@ -25,10 +25,10 @@ #include "config.h" #endif +#include "main.h" #include "hgallocator.h" #include "hgallocator-private.h" #include "hgquark.h" -#include "main.h" hg_mem_vtable_t *vtable = NULL; @@ -209,17 +209,17 @@ TDEF (lock_object) t = vtable->alloc(retval, 128, 0, &p2); fail_unless(t != Qnil, "Unable to allocate the memory."); - b = hg_get_allocator_block (p2); + b = _hg_allocator_get_block(p2); fail_unless(b->lock_count == 1, "Detected inconsistency in the lock count"); p = vtable->lock_object(retval, t); - b = hg_get_allocator_block (p); + b = _hg_allocator_get_block(p); fail_unless(p != NULL, "Unable to obtain the object address."); fail_unless(p == p2, "Obtaining the different object address."); fail_unless(b->lock_count == 2, "Failed to lock the object."); p = vtable->lock_object(retval, t); - b = hg_get_allocator_block (p); + b = _hg_allocator_get_block(p); fail_unless(p != NULL, "Unable to obtain the object address."); fail_unless(b->lock_count == 3, "Failed to lock the object."); diff --git a/tests/hgarray.c b/tests/hgarray.c index 2e64dad..e9736dd 100644 --- a/tests/hgarray.c +++ b/tests/hgarray.c @@ -25,11 +25,11 @@ #include "config.h" #endif +#include "main.h" #include "hgarray.h" #include "hgint.h" #include "hgmem.h" #include "hgnull.h" -#include "main.h" hg_mem_t *mem = NULL; diff --git a/tests/hgbool.c b/tests/hgbool.c index e509415..b42eb70 100644 --- a/tests/hgbool.c +++ b/tests/hgbool.c @@ -25,8 +25,8 @@ #include "config.h" #endif -#include "hgbool.h" #include "main.h" +#include "hgbool.h" /** common **/ diff --git a/tests/hgdict.c b/tests/hgdict.c index d5ddf1e..84c6e2e 100644 --- a/tests/hgdict.c +++ b/tests/hgdict.c @@ -25,10 +25,10 @@ #include "config.h" #endif +#include "main.h" #include "hgmem.h" #include "hgdict-private.h" #include "hgdict.h" -#include "main.h" void tree2string(hg_mem_t *mem, diff --git a/tests/hgencoding.c b/tests/hgencoding.c index 84e7542..a77947f 100644 --- a/tests/hgencoding.c +++ b/tests/hgencoding.c @@ -26,8 +26,8 @@ #endif #include <string.h> -#include "hgencoding.h" #include "main.h" +#include "hgencoding.h" /** common **/ diff --git a/tests/hgint.c b/tests/hgint.c index 0a70365..2571a6e 100644 --- a/tests/hgint.c +++ b/tests/hgint.c @@ -25,8 +25,8 @@ #include "config.h" #endif -#include "hgint.h" #include "main.h" +#include "hgint.h" /** common **/ diff --git a/tests/hgmark.c b/tests/hgmark.c index 7ae2388..0598faf 100644 --- a/tests/hgmark.c +++ b/tests/hgmark.c @@ -25,8 +25,8 @@ #include "config.h" #endif -#include "hgmark.h" #include "main.h" +#include "hgmark.h" /** common **/ diff --git a/tests/hgname.c b/tests/hgname.c index 7112c09..f39f7eb 100644 --- a/tests/hgname.c +++ b/tests/hgname.c @@ -25,8 +25,8 @@ #include "config.h" #endif -#include "hgname.h" #include "main.h" +#include "hgname.h" hg_name_t *name = NULL; diff --git a/tests/hgnull.c b/tests/hgnull.c index 67c8711..102da30 100644 --- a/tests/hgnull.c +++ b/tests/hgnull.c @@ -25,8 +25,8 @@ #include "config.h" #endif -#include "hgnull.h" #include "main.h" +#include "hgnull.h" /** common **/ diff --git a/tests/hgquark.c b/tests/hgquark.c index c0a7496..976c511 100644 --- a/tests/hgquark.c +++ b/tests/hgquark.c @@ -25,8 +25,8 @@ #include "config.h" #endif -#include "hgquark.h" #include "main.h" +#include "hgquark.h" /** common **/ void diff --git a/tests/hgreal.c b/tests/hgreal.c index e2d52c9..191f2f4 100644 --- a/tests/hgreal.c +++ b/tests/hgreal.c @@ -25,8 +25,8 @@ #include "config.h" #endif -#include "hgreal.h" #include "main.h" +#include "hgreal.h" /** common **/ diff --git a/tests/hgstack.c b/tests/hgstack.c index 3c7e0b0..9701506 100644 --- a/tests/hgstack.c +++ b/tests/hgstack.c @@ -25,11 +25,11 @@ #include "config.h" #endif +#include "main.h" #include "hgint.h" #include "hgstack-private.h" #include "hgstack.h" #include "hgmem.h" -#include "main.h" hg_mem_t *mem = NULL; diff --git a/tests/hgstring.c b/tests/hgstring.c index 995993a..eba3114 100644 --- a/tests/hgstring.c +++ b/tests/hgstring.c @@ -25,9 +25,9 @@ #include "config.h" #endif +#include "main.h" #include "hgstring.h" #include "hgmem.h" -#include "main.h" hg_mem_t *mem = NULL; |