Menu

#26 Rework lib startup

closed-wont-integrate
nobody
None
5
2014-03-27
2011-09-21
Thomas Gall
No

The enclosed patch change libjpeg-turbo to call libjpeg_general_init when the library is loaded. This function in turn calls architecture specific routines to query for processor capabilities etc as would be appropriate.

So on arm for example this means the auxv is examined for neon.

In all cases the init_simd code is now just called once when the as part of the libjpeg_general_init -> libjpeg_arch_specific_init path. The noted race condition involving init_simd is eliminated with this patch.

Further copious calls to init_simd found in simd/jsimd_arm.c and simd/jsimd_i386.c are removed.

make; make test passes on linux arm and linux x86_64. While code exists to support OSX, Windows and Linux i386 they have not been specifically tested.

Discussion

  • Thomas Gall

    Thomas Gall - 2011-09-21
     
  • Thomas Gall

    Thomas Gall - 2011-09-21

    Makefile.am | 2
    jlibinit.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
    jsimd.h | 2
    simd/jsimd_arm.c | 148 ++++++-----------------------------------------------
    simd/jsimd_i386.c | 48 -----------------
    5 files changed, 170 insertions(+), 179 deletions(-)

     
  • DRC

    DRC - 2011-09-26

    I have several problems with this proposed modification:

    -- It introduces significant ELF dependencies. The current code at least theoretically builds and runs on non-ELF x86 systems.

    -- It doesn't work on OS X. (see above.) OS X is a non-ELF system.

    -- It is not likely to work with non-GCC compilers.

    -- It could create problems when statically linking libjpeg-turbo into a dynamic library,

    -- Does this work if libjpeg-turbo is statically linked into an application? If so, I don't see how.

    -- It fixes a problem which isn't really a problem. I am open to being convinced otherwise, but unless the init_simd() function has an identifiable problem with idempotency, I don't see the danger in accidentally calling it 2 or 3 times (which would only happen in multi-threaded situations.) I do, however, see a lot of potential dangers with relying on the dynamic loader to initialize things for us.

     
  • DRC

    DRC - 2012-02-02

    Closing as WNF for now. Please feel free to add additional comments.

     
  • DRC

    DRC - 2014-03-27
    • status: closed --> closed-wont-integrate
     

Log in to post a comment.