got rid of outdated dmalloc support. provide g_try_malloc() and

Thu Dec 28 10:21:46 2000  Tim Janik  <timj@gtk.org>

        * gmem.[hc]: got rid of outdated dmalloc support. provide g_try_malloc()
        and g_try_realloc() which _may_ fail and return NULL.
        nuked g_mem_check(), provided GMemVTable for memory function
        virtualization, alterable at program startup with g_mem_set_vtable().
        provided glib_mem_profiler_table and g_mem_profile() to support limited
        profiling information out of the box (uses mprotect() for free()ed areas
        on linux).
        provide globally visible G_MEM_ALIGN.
        buncha cleanups.

        * docs/macros.txt: file to get a clue about the various configuration
        macros.

        * docs/debugging.txt: explain debugging traps.

        * configure.in: got rid of --enable-mem-check and --enable-mem-profile,
        define GLIB_SIZEOF_VOID_P and GLIB_SIZEOF_LONG. check malloc prototypes
        and define SANE_MALLOC_PROTOS is we can use them.
        <boy, is this file a mess>

        * gutils.c, gscanner.c: fix up compatibility warnings, use g_message().


Thu Dec 28 11:36:44 2000  Tim Janik  <timj@gtk.org>

        * gbsearcharray.c (upper_power2): disable G_BSEARCH_ALIGN_POWER2
        fucntionality if DISABLE_MEM_POOLS is defined.

        * gtype.c: honour DISABLE_MEM_POOLS.

        * gsignal.c (g_signal_init): flag signal key bsearch array with
        G_BSEARCH_ALIGN_POWER2 to avoid excessive growth time. honour
        DISABLE_MEM_POOLS.

        * gparam.h: added G_PARAM_READWRITE alias for (G_PARAM_READABLE |
                                                       G_PARAM_WRITABLE).
This commit is contained in:
Tim Janik
2000-12-29 02:16:51 +00:00
committed by Tim Janik
parent ab31e0c3ce
commit 782a8e2e7c
31 changed files with 1845 additions and 1158 deletions

28
docs/debugging.txt Normal file
View File

@@ -0,0 +1,28 @@
G_BREAKPOINT () traps for the debugger
======================================
Some code portions contain trap variables that can be set during
debugging time if G_ENABLE_DEBUG has been defined upon compilation
(use the --enable-debug=yes option to configure for this, macros.txt
covers more details).
Such traps lead to immediate code halts to examine the current
program state and backtrace.
Currently, the following trap variables exist:
static volatile gulong glib_trap_free_size;
static volatile gulong glib_trap_realloc_size;
static volatile gulong glib_trap_malloc_size;
If set to a size > 0, g_free(), g_realloc() and g_malloc()
respectively, will be intercepted if the size matches the
size of the corresponding memory block to free/reallocate/allocate.
This will only work with g_mem_set_vtable (glib_mem_profiler_table)
upon startup though, because memory profiling is required to match
on the memory block sizes.
static volatile GObject *glib_trap_object_ref;
If set to a valid object pointer, ref/unref will be intercepted
with G_BREAKPOINT ();
2000/12/28 Tim Janik

79
docs/macros.txt Normal file
View File

@@ -0,0 +1,79 @@
GLib's configure options and corresponding macros
=================================================
--enable-debug=no
-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS
--enable-debug=minimum [default for stable branches]
none
--enable-debug=yes [default for development branches]
-DG_ENABLE_DEBUG -g
--enable-gc-friendly=yes
#define ENABLE_GC_FRIENDLY 1
--disable-mem-pools=yes
#define DISABLE_MEM_POOLS 1
Besides these, there are some local feature specific options, but my main
focus here is to concentrate on macros that affect overall GLib behaviour
and/or third party code.
Notes on GLib's internal and global macros
==========================================
ENABLE_GC_FRIENDLY
Newly allocated memory that isn't directly initialized, as well
as memory being freed should be reset to 0. The point here is to
allow memory checkers and similar programs that use bohem GC alike
algorithms to produce more accurate results.
DISABLE_MEM_POOLS
Many small chunks of memory are often allocated via collective pools
in GLib and are cached after release to speed up reallocations.
For sparse memory systems this behaviour is often inferior, so
memory pools can be disabled to avoid excessive caching and force
atomic maintenance of chunks through the g_malloc/g_free.
Code currently affected by this macro:
- GList, GSList, GNode allocations
- GMemChunks become basically non-effective
- GSignal disables all caching (potentially very slow)
- GType doesn't honour the GTypeInfo n_preallocs field anymore
- the GBSearchArray flag G_BSEARCH_ALIGN_POWER2 becomes non-functional
G_DISABLE_ASSERT
The g_assert() and g_assert_not_reached() become non-functional
with this define. The motivation is to speed up end-user apps by
avoiding expensive checks.
This macro can affect third-party code. --enable-debug=no will only
disable the assertion macros for GLib itself, but third-party code
that passes -DG_DISABLE_ASSERT to the compiler upon its own build
will end up with the non-functional variants after including glib.h
as well.
NOTE: Code inside the assertion macros should not have side effects
that affect the operation of the program.
G_DISABLE_CHECKS
This macro is similar to G_DISABLE_ASSERT, it affects third-party
code as mentioned above and the NOTE about G_DISABLE_ASSERT applies
too. The macros that become non-functional here are
g_return_if_fail(), g_return_val_if_fail(), g_return_if_reached() and
g_return_val_if_reached().
Additionally the glib_mem_profiler_table and g_mem_profile() from
gmem.h become non-functional if this macro is supplied.
This macro also switches off certain checks in the GSignal code.
G_ENABLE_DEBUG
Quite a bit of additional debugging code is compiled into GLib for this
macro, and since it is a globally visible define, third-party code may
be affected by it similar to G_DISABLE_ASSERT.
The additional code executed/compiled for this macro currently involve:
- extra validity checks for GDate
- memory profiling traps in gmem.c (consult debugging.txt for details)
- BREAKPOINT abortion for fatal log levels in gmessage.c instead of
plain abort() to allow debuggers trapping and overriding them
- added verbosity of gscanner.c to catch deprecated code paths
- added verbosity of gutils.c to catch deprecated code paths
- object ref/unref traps (consult debugging.txt) and object bookkeeping
in gobject.c
- extra validity checks in gsignal.c
2000/12/28 Tim Janik

View File

@@ -422,74 +422,6 @@ dates must be valid.
greater than zero if @lhs is greater than @rhs
<!-- ##### FUNCTION g_date_get_day ##### -->
<para>
Return the day of the month; the #GDate must be valid.
</para>
@date: Date to extract the day of the month from
@Returns: Day of the month
<!-- ##### FUNCTION g_date_get_month ##### -->
<para>
Accessor for the month of the year. Date must be valid.
</para>
@date: Date to get the month from
@Returns: A #GDateMonth
<!-- ##### FUNCTION g_date_get_year ##### -->
<para>
Accessor; returns the year of a #GDate. The date must be valid.
</para>
@date: Date
@Returns: Year in which the date falls
<!-- ##### FUNCTION g_date_get_julian ##### -->
<para>
Accessor, returns the Julian day or "serial number" of the #GDate. The
Julian day is simply the number of days since January 1, Year 1; i.e.,
January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2,
etc. Date must be valid.
</para>
@date: Date to extract the Julian day from
@Returns: Julian day
<!-- ##### FUNCTION g_date_get_weekday ##### -->
<para>
Returns the day of the week for a #GDate. The date must be valid.
</para>
@date: Date
@Returns: Day of the week as a #GDateWeekday
<!-- ##### FUNCTION g_date_get_day_of_year ##### -->
<para>
Return the day of the year, where Jan 1 is the first day of the
year. Date must be valid.
</para>
@date: Date to extract day of year from
@Returns: Day of the year
<!-- ##### FUNCTION g_date_get_days_in_month ##### -->
<para>
Return the number of days in a month, taking leap years into account.
</para>
@month: Month
@year: Year
@Returns: Number of days in @month during the year @year.
<!-- ##### FUNCTION g_date_is_first_of_month ##### -->
<para>
Returns TRUE if the date is on the first of a month. Date must be valid.
@@ -517,56 +449,6 @@ Returns TRUE if the year is a leap year
@Returns: Boolean, if the year is a leap year
<!-- ##### FUNCTION g_date_get_monday_week_of_year ##### -->
<para>
Return the week of the year, where weeks are understood to start on
Monday. If the date is before the first Monday of the year, return
0. Date must be valid.
</para>
@date: Date to use
@Returns: Week of the year
<!-- ##### FUNCTION g_date_get_monday_weeks_in_year ##### -->
<para>
Return the number of weeks in the year, where weeks are taken to start
on Monday. Will be 52 or 53. Date must be valid. (Years always have 52
7-day periods, plus 1 or 2 extra days depending on whether it's a leap
year. This function is basically telling you how many Mondays are in
the year, i.e. there are 53 Mondays if one of the extra days happens
to be a Monday.)
</para>
@year: Year
@Returns: Number of Mondays in the year
<!-- ##### FUNCTION g_date_get_sunday_week_of_year ##### -->
<para>
Week of the year during which this date falls, if weeks are understood
to being on Sunday. Date must be valid. Can return 0 if the day is
before the first Sunday of the year.
</para>
@date: Date
@Returns: Week number
<!-- ##### FUNCTION g_date_get_sunday_weeks_in_year ##### -->
<para>
Return the number of weeks in the year, where weeks are taken to start
on Sunday. Will be 52 or 53. Date must be valid. (Years always have 52
7-day periods, plus 1 or 2 extra days depending on whether it's a leap
year. This function is basically telling you how many Sundays are in
the year, i.e. there are 53 Sundays if one of the extra days happens
to be a Sunday.)
</para>
@year: Year to count weeks in
@Returns: Number of weeks
<!-- ##### FUNCTION g_date_strftime ##### -->
<para>
Generate a printed representation of the date, in a locale-specific

View File

@@ -1,3 +1,11 @@
<!-- ##### FUNCTION g_date_get_day ##### -->
<para>
Return the day of the month; the #GDate must be valid.
</para>
@date: Date to extract the day of the month from
@Returns: Day of the month
<!-- ##### FUNCTION g_markup_parse_context_parse ##### -->
<para>
@@ -24,6 +32,19 @@
@callback_data:
@callback_funcs:
<!-- ##### FUNCTION g_date_get_sunday_weeks_in_year ##### -->
<para>
Return the number of weeks in the year, where weeks are taken to start
on Sunday. Will be 52 or 53. Date must be valid. (Years always have 52
7-day periods, plus 1 or 2 extra days depending on whether it's a leap
year. This function is basically telling you how many Sundays are in
the year, i.e. there are 53 Sundays if one of the extra days happens
to be a Sunday.)
</para>
@year: Year to count weeks in
@Returns: Number of weeks
<!-- ##### FUNCTION g_locale_to_utf8 ##### -->
<para>
@@ -55,6 +76,26 @@
@source:
@can_recurse:
<!-- ##### FUNCTION g_date_get_days_in_month ##### -->
<para>
Return the number of days in a month, taking leap years into account.
</para>
@month: Month
@year: Year
@Returns: Number of days in @month during the year @year.
<!-- ##### FUNCTION g_date_get_julian ##### -->
<para>
Accessor, returns the Julian day or "serial number" of the #GDate. The
Julian day is simply the number of days since January 1, Year 1; i.e.,
January 1, Year 1 is Julian day 1; January 2, Year 1 is Julian day 2,
etc. Date must be valid.
</para>
@date: Date to extract the Julian day from
@Returns: Julian day
<!-- ##### MACRO pclose ##### -->
<para>
@@ -192,6 +233,16 @@ See #G_PRIORITY_DEFAULT, #G_PRIORITY_DEFAULT_IDLE, #G_PRIORITY_HIGH,
@struct_size:
@Returns:
<!-- ##### FUNCTION g_date_get_monday_week_of_year ##### -->
<para>
Return the week of the year, where weeks are understood to start on
Monday. If the date is before the first Monday of the year, return
0. Date must be valid.
</para>
@date: Date to use
@Returns: Week of the year
<!-- ##### MACRO getpid ##### -->
<para>
@@ -225,6 +276,14 @@ type of source.
@source:
@Returns:
<!-- ##### FUNCTION g_date_get_year ##### -->
<para>
Accessor; returns the year of a #GDate. The date must be valid.
</para>
@date: Date
@Returns: Year in which the date falls
<!-- ##### FUNCTION g_mkstemp ##### -->
<para>
@@ -233,6 +292,14 @@ type of source.
@tmpl:
@Returns:
<!-- ##### FUNCTION g_date_get_month ##### -->
<para>
Accessor for the month of the year. Date must be valid.
</para>
@date: Date to get the month from
@Returns: A #GDateMonth
<!-- ##### FUNCTION g_main_context_get_poll_func ##### -->
<para>
@@ -255,14 +322,6 @@ type of source.
</para>
<!-- ##### FUNCTION g_source_get_current_time ##### -->
<para>
</para>
@source:
@timeval:
<!-- ##### USER_FUNCTION GCompletionStrcmpFunc ##### -->
<para>
@@ -272,6 +331,14 @@ type of source.
@s2:
@Returns:
<!-- ##### FUNCTION g_source_get_current_time ##### -->
<para>
</para>
@source:
@timeval:
<!-- ##### FUNCTION g_main_loop_new ##### -->
<para>
@@ -309,6 +376,14 @@ type of source.
@array:
@compare_func:
<!-- ##### MACRO G_MODULE_SUFFIX ##### -->
<para>
Expands to the proper shared library suffix for the current platform
without the leading dot. For the most Unices and Linux this is "so",
for some HPUX versions this is "sl" and for Windows this is "dll".
</para>
<!-- ##### FUNCTION g_markup_parse_context_get_position ##### -->
<para>
@@ -387,6 +462,15 @@ type of source.
@source:
@fd:
<!-- ##### FUNCTION g_date_get_day_of_year ##### -->
<para>
Return the day of the year, where Jan 1 is the first day of the
year. Date must be valid.
</para>
@date: Date to extract day of year from
@Returns: Day of the year
<!-- ##### FUNCTION g_tree_new_with_data ##### -->
<para>
@@ -446,6 +530,16 @@ type of source.
@priority:
@Returns:
<!-- ##### FUNCTION g_date_get_sunday_week_of_year ##### -->
<para>
Week of the year during which this date falls, if weeks are understood
to being on Sunday. Date must be valid. Can return 0 if the day is
before the first Sunday of the year.
</para>
@date: Date
@Returns: Week number
<!-- ##### FUNCTION g_source_set_priority ##### -->
<para>
@@ -473,6 +567,19 @@ type of source.
@user_data:
@Returns:
<!-- ##### FUNCTION g_date_get_monday_weeks_in_year ##### -->
<para>
Return the number of weeks in the year, where weeks are taken to start
on Monday. Will be 52 or 53. Date must be valid. (Years always have 52
7-day periods, plus 1 or 2 extra days depending on whether it's a leap
year. This function is basically telling you how many Mondays are in
the year, i.e. there are 53 Mondays if one of the extra days happens
to be a Monday.)
</para>
@year: Year
@Returns: Number of Mondays in the year
<!-- ##### FUNCTION g_main_context_find_source_by_user_data ##### -->
<para>
@@ -496,6 +603,15 @@ type of source.
</para>
<!-- ##### MACRO g_rand_boolean ##### -->
<para>
Return a random #gboolean from @rand. This corresponds to a unbiased
coin toss.
</para>
@rand: a #GRand.
@Returns: a random #gboolean.
<!-- ##### FUNCTION g_io_create_watch ##### -->
<para>
@@ -540,13 +656,6 @@ Removes a file descriptor from the list being polled.
</para>
<!-- ##### MACRO g_string ##### -->
<para>
Turns the argument into a string literal by using the '#' stringizing operator.
</para>
@x: text to convert to a literal string.
<!-- ##### FUNCTION g_idle_source_new ##### -->
<para>
@@ -554,6 +663,13 @@ Turns the argument into a string literal by using the '#' stringizing operator.
@Returns:
<!-- ##### MACRO g_string ##### -->
<para>
Turns the argument into a string literal by using the '#' stringizing operator.
</para>
@x: text to convert to a literal string.
<!-- ##### FUNCTION g_main_context_pending ##### -->
<para>
@@ -576,6 +692,14 @@ Turns the argument into a string literal by using the '#' stringizing operator.
@loop:
<!-- ##### FUNCTION g_date_get_weekday ##### -->
<para>
Returns the day of the week for a #GDate. The date must be valid.
</para>
@date: Date
@Returns: Day of the week as a #GDateWeekday
<!-- ##### MACRO read ##### -->
<para>
@@ -611,6 +735,13 @@ There are no flags right now
@G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG:
<!-- ##### MACRO g_random_boolean ##### -->
<para>
Return a random #gboolean. This corresponds to a unbiased coin toss.
</para>
@Returns: a random #gboolean.
<!-- ##### FUNCTION g_slist_sort_with_data ##### -->
<para>

View File

@@ -195,15 +195,6 @@ It is passed the #GModule structure.
@module: the module about to be unloaded.
<!-- ##### MACRO G_MODULE_SUFFIX ##### -->
<para>
Expands to the proper shared library suffix for the current platform
without the leading dot. For the most Unices and Linux this is "so",
for some HPUX versions this is "sl" and for Windows this is "dll".
</para>
<!-- ##### MACRO G_MODULE_EXPORT ##### -->
<para>
Used to declare functions exported by modules.

View File

@@ -70,16 +70,6 @@ accessed through the g_rand_* functions.
@seed:
<!-- ##### MACRO g_rand_boolean ##### -->
<para>
Return a random #gboolean from @rand. This corresponds to a unbiased
coin toss.
</para>
@rand: a #GRand.
@Returns: a random #gboolean.
<!-- ##### FUNCTION g_rand_int ##### -->
@@ -91,9 +81,12 @@ coin toss.
@rand:
@min:
@max:
@Returns:
<!-- # Unused Parameters # -->
@begin:
@end:
@Returns:
<!-- ##### FUNCTION g_rand_double ##### -->
@@ -107,9 +100,12 @@ coin toss.
@rand:
@min:
@max:
@Returns:
<!-- # Unused Parameters # -->
@begin:
@end:
@Returns:
<!-- ##### FUNCTION g_random_set_seed ##### -->
@@ -118,14 +114,6 @@ coin toss.
@seed:
<!-- ##### MACRO g_random_boolean ##### -->
<para>
Return a random #gboolean. This corresponds to a unbiased coin toss.
</para>
@Returns: a random #gboolean.
<!-- ##### FUNCTION g_random_int ##### -->
@@ -135,9 +123,12 @@ Return a random #gboolean. This corresponds to a unbiased coin toss.
<!-- ##### FUNCTION g_random_int_range ##### -->
@min:
@max:
@Returns:
<!-- # Unused Parameters # -->
@begin:
@end:
@Returns:
<!-- ##### FUNCTION g_random_double ##### -->
@@ -149,8 +140,11 @@ Return a random #gboolean. This corresponds to a unbiased coin toss.
<!-- ##### FUNCTION g_random_double_range ##### -->
@min:
@max:
@Returns:
<!-- # Unused Parameters # -->
@begin:
@end:
@Returns: