Skip to content
This repository

Remove all function definitions from header files #728

Closed
petdance opened this Issue March 05, 2012 · 7 comments

5 participants

Andy Lester Reini Urban Bruce Gray Gerhard R. Vasily Chekalkin
Andy Lester

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

Bruce Gray
Owner
Util commented March 05, 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)
Gerhard R.
gerdr commented March 05, 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.

Andy Lester

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.

Andy Lester

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.

Vasily Chekalkin
Collaborator
bacek commented March 05, 2012

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

Andy Lester petdance referenced this issue from a commit March 05, 2012
Andy Lester Eliminated packfile/byteorder.h and put the static functions in it in…
… packfile/pf_items.c. This is part GitHub #728 #728
4cb2d3b
Andy Lester petdance closed this March 05, 2012
Andy Lester

byteorder functions are now inlined on commit 4cb2d3b

Andy Lester petdance reopened this March 05, 2012
Reini Urban
Collaborator

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

Reini Urban rurban closed this March 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.