#260 missing _aligned_malloc etc.

Feature_requests
closed-fixed
Danny Smith
2004-08-24
2003-01-15
No

Hi, it looks like the mingw-runtime-2.3 is missing the
_aligned_malloc, _aligned_free, _aligned_realloc,
etcetera functions (the equivalent of memalign). See e.g.

http://msdn.microsoft.com/library/en-us/vclib/html/vclrf_aligned_malloc.asp

Discussion

  • Luke Dunstan
    Luke Dunstan
    2003-01-15

    Logged In: YES
    user_id=30442

    These functions do not appear to be in MSVCRT.DLL. Do you
    know which DLL they are in?

     
  • Logged In: YES
    user_id=6482

    I don't use Windows myself (I am using mingw for
    cross-compiling), so I can't check the DLL's. However, I'm
    told that _aligned_malloc and friends are in the "Processor
    Pack" for Visual C/C++:

    http://msdn.microsoft.com/vstudio/downloads/tools/ppack/default.asp

    (You need to allocate aligned blocks mainly for use with
    SIMD instructions.)

     
  • implementation of _aligned_malloc and friends, proposed for inclusion in MinGW

     
    Attachments
  • test program for align.c

     
    Attachments
  • Logged In: YES
    user_id=6482

    I've implemented the MS _aligned_malloc etcetera interfaces,
    based on MS's
    online documentation and the algorithm description helpfully
    provided by
    Wu Yongwei. See the attached align.c file.

    I've also attached a short test program tstalign.c, which I ran
    successfully under Linux (where malloc is also 8-byte
    aligned), and also
    under the valgrind memory debugger with no errors, leaks, or
    thermonuclear
    meltdowns.

    I hope that this code, or perhaps some derivation depending
    on your
    tastes, can be included in MinGW at some point (closing bug
    #668224).

    Cordially,
    Steven G. Johnson

     
  • Logged In: YES
    user_id=6482

    (For those who were not following the related thread in the
    mingw-users list, to summarize: malloc is in general only
    8-byte aligned, and _aligned_malloc etc. are not in any
    standard DLL but in an align.c file included with the MSVC
    processor pack.)

     
  • implementation of _aligned_malloc and friends, proposed for inclusion in MinGW (slight cleanup)

     
    Attachments
  • improved implementation after feedback by Wu Yongwei et al; fixes bug in stored pointer alignment

     
    Attachments
  • improved test program

     
    Attachments
  • Earnie Boyd
    Earnie Boyd
    2004-02-14

    Logged In: YES
    user_id=15438

    Danny,

    Do you feel this is of any use to mingw runtime?

    Earnie

     
  • Earnie Boyd
    Earnie Boyd
    2004-02-14

    • assigned_to: earnie --> dannysmith
     
  • Danny Smith
    Danny Smith
    2004-08-24

    • status: open --> closed
     
  • Danny Smith
    Danny Smith
    2004-08-24

    • status: closed --> closed-fixed
     
  • Danny Smith
    Danny Smith
    2004-08-24

    Logged In: YES
    user_id=11494

    Thanks Stephen.
    I've committed to CVS, changing indentation to math GNU
    style and uglifying functions with __mingw prefix.

    Danny