mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-22 02:02:10 +01:00
Added galloca.c.
Fri Jan 22 16:51:44 EST 1999 Jeff Garzik <jgarzik@pobox.com> * Makefile.am: Added galloca.c. * galloca.c: Compile even if G_NATIVE_ALLOCA is not defined. * tests/alloca-test.c: Always test internal alloca replacement too, even if we have a working alloca. Make tests a little bit better by adding recursion (more stack activity).
This commit is contained in:
parent
0d0f178c09
commit
9f88f52e57
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
|||||||
|
Fri Jan 22 16:51:44 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* Makefile.am:
|
||||||
|
Added galloca.c.
|
||||||
|
|
||||||
|
* galloca.c:
|
||||||
|
Compile even if G_NATIVE_ALLOCA is not defined.
|
||||||
|
|
||||||
|
* tests/alloca-test.c:
|
||||||
|
Always test internal alloca replacement too, even if we have a
|
||||||
|
working alloca.
|
||||||
|
Make tests a little bit better by adding recursion
|
||||||
|
(more stack activity).
|
||||||
|
|
||||||
Fri Jan 22 13:41:41 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
Fri Jan 22 13:41:41 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
* configure.in:
|
* configure.in:
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
Fri Jan 22 16:51:44 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* Makefile.am:
|
||||||
|
Added galloca.c.
|
||||||
|
|
||||||
|
* galloca.c:
|
||||||
|
Compile even if G_NATIVE_ALLOCA is not defined.
|
||||||
|
|
||||||
|
* tests/alloca-test.c:
|
||||||
|
Always test internal alloca replacement too, even if we have a
|
||||||
|
working alloca.
|
||||||
|
Make tests a little bit better by adding recursion
|
||||||
|
(more stack activity).
|
||||||
|
|
||||||
Fri Jan 22 13:41:41 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
Fri Jan 22 13:41:41 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
* configure.in:
|
* configure.in:
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
Fri Jan 22 16:51:44 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* Makefile.am:
|
||||||
|
Added galloca.c.
|
||||||
|
|
||||||
|
* galloca.c:
|
||||||
|
Compile even if G_NATIVE_ALLOCA is not defined.
|
||||||
|
|
||||||
|
* tests/alloca-test.c:
|
||||||
|
Always test internal alloca replacement too, even if we have a
|
||||||
|
working alloca.
|
||||||
|
Make tests a little bit better by adding recursion
|
||||||
|
(more stack activity).
|
||||||
|
|
||||||
Fri Jan 22 13:41:41 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
Fri Jan 22 13:41:41 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
* configure.in:
|
* configure.in:
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
Fri Jan 22 16:51:44 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* Makefile.am:
|
||||||
|
Added galloca.c.
|
||||||
|
|
||||||
|
* galloca.c:
|
||||||
|
Compile even if G_NATIVE_ALLOCA is not defined.
|
||||||
|
|
||||||
|
* tests/alloca-test.c:
|
||||||
|
Always test internal alloca replacement too, even if we have a
|
||||||
|
working alloca.
|
||||||
|
Make tests a little bit better by adding recursion
|
||||||
|
(more stack activity).
|
||||||
|
|
||||||
Fri Jan 22 13:41:41 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
Fri Jan 22 13:41:41 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
* configure.in:
|
* configure.in:
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
Fri Jan 22 16:51:44 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* Makefile.am:
|
||||||
|
Added galloca.c.
|
||||||
|
|
||||||
|
* galloca.c:
|
||||||
|
Compile even if G_NATIVE_ALLOCA is not defined.
|
||||||
|
|
||||||
|
* tests/alloca-test.c:
|
||||||
|
Always test internal alloca replacement too, even if we have a
|
||||||
|
working alloca.
|
||||||
|
Make tests a little bit better by adding recursion
|
||||||
|
(more stack activity).
|
||||||
|
|
||||||
Fri Jan 22 13:41:41 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
Fri Jan 22 13:41:41 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
* configure.in:
|
* configure.in:
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
Fri Jan 22 16:51:44 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* Makefile.am:
|
||||||
|
Added galloca.c.
|
||||||
|
|
||||||
|
* galloca.c:
|
||||||
|
Compile even if G_NATIVE_ALLOCA is not defined.
|
||||||
|
|
||||||
|
* tests/alloca-test.c:
|
||||||
|
Always test internal alloca replacement too, even if we have a
|
||||||
|
working alloca.
|
||||||
|
Make tests a little bit better by adding recursion
|
||||||
|
(more stack activity).
|
||||||
|
|
||||||
Fri Jan 22 13:41:41 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
Fri Jan 22 13:41:41 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
* configure.in:
|
* configure.in:
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
Fri Jan 22 16:51:44 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* Makefile.am:
|
||||||
|
Added galloca.c.
|
||||||
|
|
||||||
|
* galloca.c:
|
||||||
|
Compile even if G_NATIVE_ALLOCA is not defined.
|
||||||
|
|
||||||
|
* tests/alloca-test.c:
|
||||||
|
Always test internal alloca replacement too, even if we have a
|
||||||
|
working alloca.
|
||||||
|
Make tests a little bit better by adding recursion
|
||||||
|
(more stack activity).
|
||||||
|
|
||||||
Fri Jan 22 13:41:41 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
Fri Jan 22 13:41:41 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
* configure.in:
|
* configure.in:
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
Fri Jan 22 16:51:44 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* Makefile.am:
|
||||||
|
Added galloca.c.
|
||||||
|
|
||||||
|
* galloca.c:
|
||||||
|
Compile even if G_NATIVE_ALLOCA is not defined.
|
||||||
|
|
||||||
|
* tests/alloca-test.c:
|
||||||
|
Always test internal alloca replacement too, even if we have a
|
||||||
|
working alloca.
|
||||||
|
Make tests a little bit better by adding recursion
|
||||||
|
(more stack activity).
|
||||||
|
|
||||||
Fri Jan 22 13:41:41 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
Fri Jan 22 13:41:41 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
* configure.in:
|
* configure.in:
|
||||||
|
@ -27,6 +27,7 @@ EXTRA_DIST = \
|
|||||||
lib_LTLIBRARIES = libglib.la
|
lib_LTLIBRARIES = libglib.la
|
||||||
|
|
||||||
libglib_la_SOURCES = \
|
libglib_la_SOURCES = \
|
||||||
|
galloca.c \
|
||||||
garray.c \
|
garray.c \
|
||||||
gcache.c \
|
gcache.c \
|
||||||
gcompletion.c \
|
gcompletion.c \
|
||||||
|
@ -34,9 +34,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef G_NATIVE_ALLOCA
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* If your stack is a linked list of frames, you have to
|
/* If your stack is a linked list of frames, you have to
|
||||||
provide an "address metric" ADDRESS_FUNCTION macro. */
|
provide an "address metric" ADDRESS_FUNCTION macro. */
|
||||||
@ -150,7 +147,7 @@ _g_alloca (guint size)
|
|||||||
{
|
{
|
||||||
header *np = hp->h.next;
|
header *np = hp->h.next;
|
||||||
|
|
||||||
g_free ((gpointer) hp); /* Collect garbage. */
|
free ((gpointer) hp); /* Collect garbage. */
|
||||||
|
|
||||||
hp = np; /* -> next header. */
|
hp = np; /* -> next header. */
|
||||||
}
|
}
|
||||||
@ -168,7 +165,7 @@ _g_alloca (guint size)
|
|||||||
|
|
||||||
{
|
{
|
||||||
/* GLib: use mem chunks here? */
|
/* GLib: use mem chunks here? */
|
||||||
gpointer new = g_malloc (sizeof (header) + size);
|
gpointer new = malloc (sizeof (header) + size);
|
||||||
/* Address of header. */
|
/* Address of header. */
|
||||||
|
|
||||||
if (new == 0)
|
if (new == 0)
|
||||||
@ -453,4 +450,3 @@ i00afunc (long address)
|
|||||||
#endif /* not CRAY2 */
|
#endif /* not CRAY2 */
|
||||||
#endif /* CRAY */
|
#endif /* CRAY */
|
||||||
|
|
||||||
#endif /* !G_NATIVE_ALLOCA */
|
|
||||||
|
@ -27,6 +27,7 @@ EXTRA_DIST = \
|
|||||||
lib_LTLIBRARIES = libglib.la
|
lib_LTLIBRARIES = libglib.la
|
||||||
|
|
||||||
libglib_la_SOURCES = \
|
libglib_la_SOURCES = \
|
||||||
|
galloca.c \
|
||||||
garray.c \
|
garray.c \
|
||||||
gcache.c \
|
gcache.c \
|
||||||
gcompletion.c \
|
gcompletion.c \
|
||||||
|
@ -15,29 +15,75 @@ struct test_t {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void test_alloca (void)
|
void test_alloca (gint recursions)
|
||||||
{
|
{
|
||||||
gpointer data;
|
gpointer data;
|
||||||
struct test_t *t;
|
struct test_t *t;
|
||||||
|
|
||||||
data = g_alloca (15);
|
data = g_alloca (15);
|
||||||
|
g_assert (data != NULL);
|
||||||
strcpy ((char *) data, "blah blah blah");
|
strcpy ((char *) data, "blah blah blah");
|
||||||
g_assert (strcmp ((char *) data, "blah blah blah") == 0);
|
g_assert (strcmp ((char *) data, "blah blah blah") == 0);
|
||||||
|
|
||||||
t = g_alloca_new (struct test_t, 1);
|
t = g_alloca_new (struct test_t, 1);
|
||||||
|
g_assert (t != NULL);
|
||||||
t->age = 142;
|
t->age = 142;
|
||||||
t->stuph = 0xBEDAC0ED;
|
t->stuph = 0xBEDAC0ED;
|
||||||
strcpy (t->name, "nyognyou hoddypeak");
|
strcpy (t->name, "nyognyou hoddypeak");
|
||||||
g_assert (t->stuph == 0xBEDAC0ED);
|
g_assert (t->stuph == 0xBEDAC0ED);
|
||||||
g_assert (strcmp (t->name, "nyognyou hoddypeak") == 0);
|
g_assert (strcmp (t->name, "nyognyou hoddypeak") == 0);
|
||||||
|
|
||||||
|
if (recursions > 0)
|
||||||
|
test_alloca (recursions - 1);
|
||||||
|
|
||||||
|
g_assert (strcmp ((char *) data, "blah blah blah") == 0);
|
||||||
|
g_assert (t->stuph == 0xBEDAC0ED);
|
||||||
|
g_assert (strcmp (t->name, "nyognyou hoddypeak") == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* prototype in case we have regular alloca as well */
|
||||||
|
gpointer _g_alloca (guint size);
|
||||||
|
|
||||||
|
void test_alloca_replacement (gint recursions)
|
||||||
|
{
|
||||||
|
gpointer data;
|
||||||
|
struct test_t *t;
|
||||||
|
|
||||||
|
data = _g_alloca (15);
|
||||||
|
g_assert (data != NULL);
|
||||||
|
strcpy ((char *) data, "blah blah blah");
|
||||||
|
g_assert (strcmp ((char *) data, "blah blah blah") == 0);
|
||||||
|
|
||||||
|
t = (struct test_t *) _g_alloca (sizeof (struct test_t));
|
||||||
|
g_assert (t != NULL);
|
||||||
|
t->age = 142;
|
||||||
|
t->stuph = 0xBEDAC0ED;
|
||||||
|
strcpy (t->name, "nyognyou hoddypeak");
|
||||||
|
g_assert (t->stuph == 0xBEDAC0ED);
|
||||||
|
g_assert (strcmp (t->name, "nyognyou hoddypeak") == 0);
|
||||||
|
|
||||||
|
if (recursions > 0)
|
||||||
|
test_alloca_replacement (recursions - 1);
|
||||||
|
|
||||||
|
g_assert (strcmp ((char *) data, "blah blah blah") == 0);
|
||||||
|
g_assert (t->stuph == 0xBEDAC0ED);
|
||||||
|
g_assert (strcmp (t->name, "nyognyou hoddypeak") == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const int AllocaTestIterations = 3;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
test_alloca ();
|
int i;
|
||||||
|
|
||||||
g_alloca_gc ();
|
for (i = 0; i < AllocaTestIterations; i++) {
|
||||||
|
test_alloca (3);
|
||||||
|
test_alloca_replacement (3);
|
||||||
|
|
||||||
|
g_alloca_gc ();
|
||||||
|
_g_alloca (0);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user