Skip to content

Remove all function definitions from header files #728

Closed
petdance opened this Issue Mar 5, 2012 · 7 comments

5 participants

@petdance
petdance commented Mar 5, 2012

There are a number of header files that have functions declared in them. Move these to their own .c files.

@Util
Parrot Virtual Machine member
Util commented Mar 5, 2012

FYI, I see 17 functions in 2 header files.

include/parrot/pointer_array.h :
#define ASSERT_ARGS_allocate_more_chunks __attribute__unused__ int _ASSERT_ARGS_CHECK = (PARROT_ASSERT_ARG(interp), PARROT_ASSERT_ARG(self))
    static void   allocate_more_chunks(PARROT_INTERP, Parrot_Pointer_Array *self)
    static void * Parrot_pa_insert(    PARROT_INTERP, Parrot_Pointer_Array *self, void *ptr)
    static void   Parrot_pa_remove(    PARROT_INTERP, Parrot_Pointer_Array *self, void *ptr)

src/packfile/byteorder.h :
    static INTVAL fetch_iv_le(INTVAL w)
    static INTVAL fetch_iv_be(INTVAL w)
    static opcode_t fetch_op_be(opcode_t w)
    static opcode_t fetch_op_le(opcode_t w)
    static void fetch_buf_be_4( unsigned char *rb, const unsigned char *b)
    static void fetch_buf_le_4( unsigned char *rb, const unsigned char *b)
    static void fetch_buf_be_8( unsigned char *rb, const unsigned char *b)
    static void fetch_buf_le_8( unsigned char *rb, const unsigned char *b)
    static void fetch_buf_le_12(unsigned char *rb, const unsigned char *b)
    static void fetch_buf_be_12(unsigned char *rb, const unsigned char *b)
    static void fetch_buf_le_16(unsigned char *rb, const unsigned char *b)
    static void fetch_buf_be_16(unsigned char *rb, const unsigned char *b)
    static void fetch_buf_le_32(unsigned char *rb, const unsigned char *b)
    static void fetch_buf_be_32(unsigned char *rb, const unsigned char *b)
@gerdr
gerdr commented Mar 5, 2012

Moving the functions out of the headers means that C compilers without link-time optimization can no longer inline the code. At least some of these functions (possibly all) should remain where they are.

@petdance
petdance commented Mar 5, 2012

The byteorder functions are all static and should be moved to the one file that uses them, src/packfile/pf_items.c. They will inline there just fine.

@petdance
petdance commented Mar 5, 2012

The Parrot_pa_* functions are also static, although defined in the header. That means that each file that includes the headers is making its own copy of the same static functions.

@bacek
Parrot Virtual Machine member
bacek commented Mar 5, 2012

Yes, Parrot_pa_* functions are declared in header file on purpose. They are heavily used in GC and have to be inlined.

@petdance petdance added a commit that referenced this issue Mar 6, 2012
@petdance petdance Eliminated packfile/byteorder.h and put the static functions in it in…
… packfile/pf_items.c. This is part GitHub #728 #728
4cb2d3b
@petdance
petdance commented Mar 6, 2012

byteorder functions are now inlined on commit 4cb2d3b

@petdance petdance closed this Mar 6, 2012
@petdance petdance reopened this Mar 6, 2012
@rurban
Parrot Virtual Machine member
rurban commented Mar 11, 2014

There are no todo item left. pf is done, and pa is there on purpose.

@rurban rurban closed this Mar 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.