Author: petdance
Date: Fri Jun 8 14:14:02 2007
New Revision: 18886
Modified:
trunk/config/gen/makefiles/root.in
trunk/include/parrot/headers.h
trunk/src/headers.c
Log:
headers.c is now headerized, albeit with one missing header
Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in (original)
+++ trunk/config/gen/makefiles/root.in Fri Jun 8 14:14:02 2007
@@ -1843,6 +1843,7 @@
src/datatypes.o \
src/gc/resources.o \
src/utils.o \
+ src/headers.o \
headerizer:
$(PERL) $(BUILD_TOOLS_DIR)/headerize.pl $(HEADERIZER_O_FILES)
Modified: trunk/include/parrot/headers.h
==============================================================================
--- trunk/include/parrot/headers.h (original)
+++ trunk/include/parrot/headers.h Fri Jun 8 14:14:02 2007
@@ -35,31 +35,6 @@
#define WORD_ALIGN_1 (sizeof (void *) - 1)
#define WORD_ALIGN_MASK ~WORD_ALIGN_1
-/* pool creation and access functions */
-struct Small_Object_Pool *new_pmc_pool(Interp *interp);
-struct Small_Object_Pool *new_bufferlike_pool(Interp *interp, size_t
unit_size);
-struct Small_Object_Pool *new_buffer_pool(Interp *interp);
-struct Small_Object_Pool *new_string_pool(Interp *interp, INTVAL constant);
-struct Small_Object_Pool *get_bufferlike_pool(Interp *interp, size_t
unit_size);
-
-struct Small_Object_Pool *make_bufferlike_pool(Interp *interp, size_t
unit_size);
-/* header creation functions */
-PMC *new_pmc_header(Interp *interp, UINTVAL flags);
-void add_pmc_ext(Interp *interp, PMC *pmc);
-void add_pmc_sync(Interp *interp, PMC *pmc);
-STRING *new_string_header(Interp *interp, UINTVAL flags);
-Buffer *new_buffer_header(Interp *interp);
-void *new_bufferlike_header(Interp *interp, size_t size);
-
-size_t get_max_buffer_address(Interp *interp);
-size_t get_min_buffer_address(Interp *interp);
-size_t get_max_pmc_address(Interp *interp);
-size_t get_min_pmc_address(Interp *interp);
-int is_buffer_ptr(Interp *, void *);
-int is_pmc_ptr(Interp *, void *);
-
-void gc_pmc_ext_pool_init(Interp *, struct Small_Object_Pool *pool);
-
/* pool iteration */
typedef enum {
POOL_PMC = 0x01,
@@ -69,13 +44,98 @@
} pool_iter_enum;
typedef int (*pool_iter_fn)(Interp *, struct Small_Object_Pool *, int, void*);
-int Parrot_forall_header_pools(Interp *, int, void *arg, pool_iter_fn func);
-/* miscellaneous functions */
-void Parrot_initialize_header_pools(Interp *);
-void Parrot_destroy_header_pools(Interp *interp);
-void Parrot_merge_header_pools(Interp *dest, Interp *source);
+/* HEADERIZER BEGIN: src/headers.c */
+
+void Parrot_destroy_header_pools( Interp *interp );
+int Parrot_forall_header_pools( Interp *interp,
+ int flag,
+ void *arg,
+ pool_iter_fn func /*NN*/ )
+ __attribute__nonnull__(4);
+
+void Parrot_initialize_header_pool_names( Interp *interp );
+void Parrot_initialize_header_pools( Interp *interp /*NN*/ )
+ __attribute__nonnull__(1);
+
+void Parrot_merge_header_pools( Interp *dest_interp /*NN*/,
+ Interp *source_interp /*NN*/ )
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+void add_pmc_ext( Interp *interp /*NN*/, PMC *pmc /*NN*/ )
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+void add_pmc_sync( Interp *interp, PMC *pmc /*NN*/ )
+ __attribute__nonnull__(2);
+
+Small_Object_Pool * get_bufferlike_pool( Interp *interp /*NN*/,
+ size_t buffer_size )
+ __attribute__nonnull__(1)
+ __attribute__warn_unused_result__;
+
+size_t get_max_buffer_address( Interp *interp /*NN*/ )
+ __attribute__nonnull__(1)
+ __attribute__pure__
+ __attribute__warn_unused_result__;
+
+size_t get_max_pmc_address( const Interp *interp /*NN*/ )
+ __attribute__nonnull__(1)
+ __attribute__pure__
+ __attribute__warn_unused_result__;
+
+size_t get_min_buffer_address( Interp *interp /*NN*/ )
+ __attribute__nonnull__(1)
+ __attribute__pure__
+ __attribute__warn_unused_result__;
+
+size_t get_min_pmc_address( Interp *interp /*NN*/ )
+ __attribute__nonnull__(1)
+ __attribute__pure__
+ __attribute__warn_unused_result__;
+
+int is_buffer_ptr( Interp *interp, void *ptr );
+int is_pmc_ptr( Interp *interp, void *ptr );
+Small_Object_Pool * make_bufferlike_pool( Interp *interp /*NN*/,
+ size_t buffer_size )
+ __attribute__nonnull__(1)
+ __attribute__warn_unused_result__;
+
+Buffer * new_buffer_header( Interp *interp /*NN*/ )
+ __attribute__nonnull__(1)
+ __attribute__warn_unused_result__;
+
+Small_Object_Pool * new_buffer_pool( Interp *interp )
+ __attribute__warn_unused_result__;
+
+void * new_bufferlike_header( Interp *interp, size_t size )
+ __attribute__warn_unused_result__;
+
+Small_Object_Pool * new_bufferlike_pool( Interp *interp /*NN*/,
+ size_t actual_buffer_size )
+ __attribute__nonnull__(1)
+ __attribute__warn_unused_result__;
+
+PMC * new_pmc_header( Interp *interp /*NN*/, UINTVAL flags )
+ __attribute__nonnull__(1)
+ __attribute__warn_unused_result__;
+
+Small_Object_Pool * new_pmc_pool( Interp *interp /*NN*/ )
+ __attribute__nonnull__(1)
+ __attribute__warn_unused_result__;
+
+STRING * new_string_header( Interp *interp /*NN*/, UINTVAL flags )
+ __attribute__nonnull__(1)
+ __attribute__warn_unused_result__;
+
+Small_Object_Pool * new_string_pool( Interp *interp /*NN*/, INTVAL constant )
+ __attribute__nonnull__(1)
+ __attribute__warn_unused_result__;
+
+/* HEADERIZER END: src/headers.c */
+
#endif /* PARROT_HEADERS_H_GUARD */
Modified: trunk/src/headers.c
==============================================================================
--- trunk/src/headers.c (original)
+++ trunk/src/headers.c Fri Jun 8 14:14:02 2007
@@ -10,13 +10,14 @@
Handles getting of various headers, and pool creation.
-=cut
-
*/
#include "parrot/parrot.h"
+#include "parrot/headers.h"
#include <assert.h>
+/* HEADER: include/parrot/headers.h */
+
#ifndef GC_IS_MALLOC
# define PMC_HEADERS_PER_ALLOC 512
# define BUFFER_HEADERS_PER_ALLOC 256
@@ -34,19 +35,15 @@
=head2 Buffer Header Functions for small-object lookup table
-=over 4
-
-=item C<static void *
-get_free_buffer(Interp *interp, Small_Object_Pool *pool)>
+FUNCDOC: get_free_buffer
Gets a free C<Buffer> from C<pool> and returns it. Memory is cleared.
-=cut
-
*/
static void *
-get_free_buffer(Interp *interp, Small_Object_Pool *pool)
+get_free_buffer(Interp *interp, Small_Object_Pool *pool /*NN*/)
+ /* WARN_UNUSED */
{
PObj * const buffer = (PObj *)pool->get_free_object(interp, pool);
@@ -62,21 +59,17 @@
/*
-=back
-
=head2 Header Pool Creation Functions
-=over 4
-
-=item C<Small_Object_Pool * new_pmc_pool(Interp *interp)>
+FUNCDOC: new_pmc_pool
Creates an new pool for PMCs and returns it.
-=cut
-
*/
-Small_Object_Pool * new_pmc_pool(Interp *interp)
+Small_Object_Pool *
+new_pmc_pool(Interp *interp /*NN*/)
+ /* WARN_UNUSED */
{
const int num_headers = PMC_HEADERS_PER_ALLOC;
Small_Object_Pool * const pmc_pool =
@@ -89,19 +82,16 @@
/*
-=item C<Small_Object_Pool *
-new_bufferlike_pool(Interp *interp, size_t actual_buffer_size)>
+FUNCDOC: new_bufferlike_pool
Creates a new pool for buffer-like structures. Usually you would need
C<make_bufferlike_pool()>.
-=cut
-
*/
Small_Object_Pool *
-new_bufferlike_pool(Interp *interp,
- size_t actual_buffer_size)
+new_bufferlike_pool(Interp *interp /*NN*/, size_t actual_buffer_size)
+ /* WARN_UNUSED */
{
const int num_headers = BUFFER_HEADERS_PER_ALLOC;
const size_t buffer_size =
@@ -116,34 +106,30 @@
/*
-=item C<Small_Object_Pool *
-new_buffer_pool(Interp *interp)>
+FUNCDOC: new_buffer_pool
Non-constant strings and plain Buffers are in the sized header pools.
-=cut
-
*/
Small_Object_Pool *
new_buffer_pool(Interp *interp)
+ /* WARN_UNUSED */
{
return make_bufferlike_pool(interp, sizeof (Buffer));
}
/*
-=item C<Small_Object_Pool *
-new_string_pool(Interp *interp, INTVAL constant)>
+FUNCDOC: new_string_pool
Creates a new pool for C<STRINGS> and returns it.
-=cut
-
*/
Small_Object_Pool *
-new_string_pool(Interp *interp, INTVAL constant)
+new_string_pool(Interp *interp /*NN*/, INTVAL constant)
+ /* WARN_UNUSED */
{
Small_Object_Pool *pool;
if (constant) {
@@ -158,17 +144,15 @@
/*
-=item C<Small_Object_Pool *
-make_bufferlike_pool(Interp *interp, size_t buffer_size)>
+FUNCDOC: make_bufferlike_pool
Make and return a bufferlike header pool.
-=cut
-
*/
Small_Object_Pool *
-make_bufferlike_pool(Interp *interp, size_t buffer_size)
+make_bufferlike_pool(Interp *interp /*NN*/, size_t buffer_size)
+ /* WARN_UNUSED */
{
const UINTVAL num_old = interp->arena_base->num_sized;
Small_Object_Pool **sized_pools =
@@ -196,17 +180,15 @@
/*
-=item C<Small_Object_Pool *
-get_bufferlike_pool(Interp *interp, size_t buffer_size)>
+FUNCDOC: get_bufferlike_pool
Return a bufferlike header pool, it must exist.
-=cut
-
*/
Small_Object_Pool *
-get_bufferlike_pool(Interp *interp, size_t buffer_size)
+get_bufferlike_pool(Interp *interp /*NN*/, size_t buffer_size)
+ /* WARN_UNUSED */
{
Small_Object_Pool ** const sized_pools =
interp->arena_base->sized_header_pools;
@@ -216,19 +198,17 @@
/*
-=item C<PMC *
-new_pmc_header(Interp *interp)>
+FUNCDOC: new_pmc_header
Get a header.
-=cut
-
*/
static PMC_EXT * new_pmc_ext(Parrot_Interp);
PMC *
-new_pmc_header(Interp *interp, UINTVAL flags)
+new_pmc_header(Interp *interp /*NN*/, UINTVAL flags)
+ /* WARN_UNUSED */
{
Small_Object_Pool * const pool =
flags & PObj_constant_FLAG
@@ -256,17 +236,15 @@
/*
-=item C<PMC_EXT *
-new_pmc_ext(Interp *interp)>
+FUNCDOC: new_pmc_ext
Creates a new C<PMC_EXT> and returns it.
-=cut
-
*/
static PMC_EXT *
-new_pmc_ext(Interp *interp)
+new_pmc_ext(Interp *interp /*NN*/)
+ /* WARN_UNUSED */
{
Small_Object_Pool * const pool = interp->arena_base->pmc_ext_pool;
PMC_EXT *ptr;
@@ -284,17 +262,14 @@
/*
-=item C<void
-add_pmc_ext(Interp *interp, PMC *pmc)>
+FUNCDOC: add_pmc_ext
Adds a new C<PMC_EXT> to C<pmc>.
-=cut
-
*/
void
-add_pmc_ext(Interp *interp, PMC *pmc)
+add_pmc_ext(Interp *interp /*NN*/, PMC *pmc /*NN*/)
{
pmc->pmc_ext = new_pmc_ext(interp);
PObj_is_PMC_EXT_SET(pmc);
@@ -311,17 +286,14 @@
/*
-=item C<PMC *
-add_pmc_sync(Interp *interp, PMC *pmc)>
+FUNCDOC: add_pmc_sync
Adds a PMC_sync field to C<pmc>.
-=cut
-
*/
void
-add_pmc_sync(Interp *interp, PMC *pmc)
+add_pmc_sync(Interp *interp, PMC *pmc /*NN*/)
{
if (!PObj_is_PMC_EXT_TEST(pmc)) {
add_pmc_ext(interp, pmc);
@@ -333,17 +305,15 @@
/*
-=item C<STRING *
-new_string_header(Interp *interp, UINTVAL flags)>
+FUNCDOC: new_string_header
Returns a new C<STRING> header.
-=cut
-
*/
STRING *
-new_string_header(Interp *interp, UINTVAL flags)
+new_string_header(Interp *interp /*NN*/, UINTVAL flags)
+ /* WARN_UNUSED */
{
STRING * const string = (STRING *)get_free_buffer(interp,
(flags & PObj_constant_FLAG)
@@ -360,17 +330,15 @@
/*
-=item C<Buffer *
-new_buffer_header(Interp *interp)>
+FUNCDOC: new_buffer_header
Creates and returns a new C<Buffer>.
-=cut
-
*/
Buffer *
-new_buffer_header(Interp *interp)
+new_buffer_header(Interp *interp /*NN*/)
+ /* WARN_UNUSED */
{
return (Buffer *)get_free_buffer(interp,
interp->arena_base->buffer_header_pool);
@@ -379,17 +347,15 @@
/*
-=item C<void *
-new_bufferlike_header(Interp *interp, size_t size)>
+FUNCDOC: new_bufferlike_header
Creates and returns a new buffer-like header.
-=cut
-
*/
void *
new_bufferlike_header(Interp *interp, size_t size)
+ /* WARN_UNUSED */
{
Small_Object_Pool * const pool = get_bufferlike_pool(interp, size);
@@ -398,17 +364,15 @@
/*
-=item C<size_t
-get_max_buffer_address(Interp *interp)>
+FUNCDOC: get_max_buffer_address
Calculates the maximum buffer address and returns it.
-=cut
-
*/
size_t
-get_max_buffer_address(Interp *interp)
+get_max_buffer_address(Interp *interp /*NN*/)
+ /* PURE, WARN_UNUSED */
{
UINTVAL i;
size_t max = 0;
@@ -426,17 +390,15 @@
/*
-=item C<size_t
-get_min_buffer_address(Interp *interp)>
+FUNCDOC: get_min_buffer_address
Calculates the minimum buffer address and returns it.
-=cut
-
*/
size_t
-get_min_buffer_address(Interp *interp)
+get_min_buffer_address(Interp *interp /*NN*/)
+ /* PURE, WARN_UNUSED */
{
UINTVAL i;
Arenas * const arena_base = interp->arena_base;
@@ -454,47 +416,40 @@
/*
-=item C<size_t
-get_max_pmc_address(Interp *interp)>
+FUNCDOC: get_max_pmc_address
Calculates the maximum PMC address and returns it.
-=cut
-
*/
size_t
-get_max_pmc_address(Interp *interp)
+get_max_pmc_address(const Interp *interp /*NN*/)
+ /* PURE, WARN_UNUSED */
{
return interp->arena_base->pmc_pool->end_arena_memory;
}
/*
-=item C<size_t
-get_min_pmc_address(Interp *interp)>
+FUNCDOC: get_min_pmc_address
Calculates the maximum PMC address and returns it.
-=cut
-
*/
size_t
-get_min_pmc_address(Interp *interp)
+get_min_pmc_address(Interp *interp /*NN*/)
+ /* PURE, WARN_UNUSED */
{
return interp->arena_base->pmc_pool->start_arena_memory;
}
/*
-=item C<int
-is_buffer_ptr(Interp *interp, void *ptr)>
+FUNCDOC: is_buffer_ptr
Checks that C<ptr> is actually a C<Buffer>.
-=cut
-
*/
int
@@ -515,36 +470,30 @@
/*
-=item C<int
-is_pmc_ptr(Interp *interp, void *ptr)>
+FUNCDOC: is_pmc_ptr
Checks that C<ptr> is actually a PMC.
-=cut
-
*/
int
is_pmc_ptr(Interp *interp, void *ptr) /* XXX Const this */
+ /* PURE, WARN_UNUSED */
{
- return contained_in_pool(interp,
- interp->arena_base->pmc_pool, ptr);
+ return contained_in_pool(interp, interp->arena_base->pmc_pool, ptr);
}
/*
-=item C<void
-Parrot_initialize_header_pools(Interp *interp)>
+FUNCDOC: Parrot_initialize_header_pools
Initialize the pools for the tracked resources.
-=cut
-
*/
void
-Parrot_initialize_header_pools(Interp *interp)
+Parrot_initialize_header_pools(Interp *interp /*NN*/)
{
Arenas * const arena_base = interp->arena_base;
@@ -590,8 +539,7 @@
/*
-=item C<int Parrot_forall_header_pools(Interp *, int flag,
- void *arg, pool_iter_fn)>
+FUNCDOC: Parrot_forall_header_pools
Iterate through all header pools by calling the passed function. Returns
zero if the iteration didn't stop or the returned value.
@@ -618,14 +566,10 @@
=back
-
-=cut
-
*/
int
-Parrot_forall_header_pools(Interp *interp, int flag, void *arg,
- pool_iter_fn func)
+Parrot_forall_header_pools(Interp *interp, int flag, void *arg, pool_iter_fn
func /*NN*/)
{
Arenas * const arena_base = interp->arena_base;
int i;
@@ -662,17 +606,14 @@
/*
-=item C<void
-Parrot_destroy_header_pools(Interp *interp)>
+FUNCDOC: Parrot_destroy_header_pools
Destroys the header pools.
-=cut
-
*/
static void
-free_pool(Interp *interp, Small_Object_Pool *pool)
+free_pool(Interp *interp, Small_Object_Pool *pool /*NN*/)
{
Small_Object_Arena *cur_arena;
@@ -742,18 +683,6 @@
mem_internal_free(interp->arena_base->sized_header_pools);
}
-/*
-
-=item C<void
-Parrot_merge_header_pools(Interp *dest_interp, Interp *source_interp)>
-
-Merge the header pools of C<source_interp> into those of C<dest_interp>.
-(Used to deal with shared objects left after interpreter destruction.)
-
-=cut
-
-*/
-
static void fix_pmc_syncs(Interp *dest_interp, Small_Object_Pool *pool) {
/* XXX largely copied from dod_sweep */
Small_Object_Arena *cur_arena;
@@ -786,8 +715,17 @@
}
}
+/*
+
+FUNCDOC: Parrot_merge_header_pools
+
+Merge the header pools of C<source_interp> into those of C<dest_interp>.
+(Used to deal with shared objects left after interpreter destruction.)
+
+*/
+
void
-Parrot_merge_header_pools(Interp *dest_interp, Interp *source_interp) {
+Parrot_merge_header_pools(Interp *dest_interp /*NN*/, Interp *source_interp
/*NN*/) {
UINTVAL i;
Arenas * const dest_arena = dest_interp->arena_base;
@@ -830,13 +768,10 @@
/*
-=item C<void
Parrot_initialize_header_pool_names(Interp *interp)>
If we want these names, they must be added in DOD.
-=cut
-
*/
void
@@ -864,8 +799,6 @@
/*
-=back
-
=head1 SEE ALSO
F<include/parrot/headers.h>.
@@ -874,8 +807,6 @@
Initial version by Mike Lambert on 2002.05.27.
-=cut
-
*/