Changeset c1f3c2b8 in rtems for cpukit


Ignore:
Timestamp:
Nov 9, 2018, 10:20:09 AM (9 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
6efc831
Parents:
4539e307
git-author:
Sebastian Huber <sebastian.huber@…> (11/09/18 10:20:09)
git-committer:
Sebastian Huber <sebastian.huber@…> (11/12/18 12:26:22)
Message:

score: Add and use malloc() family attributes

Update #3583.

Location:
cpukit/include/rtems
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/rtems/malloc.h

    r4539e307 rc1f3c2b8  
    139139  uintptr_t alignment,
    140140  uintptr_t boundary
    141 );
     141) RTEMS_MALLOCLIKE RTEMS_ALLOC_SIZE(1) RTEMS_ALLOC_ALIGN(2)
     142  RTEMS_WARN_UNUSED_RESULT;
    142143
    143144/**
  • cpukit/include/rtems/score/basedefs.h

    r4539e307 rc1f3c2b8  
    236236#else
    237237  #define RTEMS_PRINTFLIKE( _format_pos, _ap_pos )
     238#endif
     239
     240/**
     241 * @brief Tells the compiler that this function is a memory allocation function
     242 * similar to malloc().
     243 */
     244#if defined(__GNUC__)
     245  #define RTEMS_MALLOCLIKE __attribute__((__malloc__))
     246#else
     247  #define RTEMS_MALLOCLIKE
     248#endif
     249
     250/**
     251 * @brief Tells the compiler the memory allocation size parameter of this
     252 * function similar to malloc().
     253 */
     254#if defined(__GNUC__)
     255  #define RTEMS_ALLOC_SIZE( _index ) __attribute__((__alloc_size__(_index)))
     256#else
     257  #define RTEMS_ALLOC_SIZE( _index )
     258#endif
     259
     260/**
     261 * @brief Tells the compiler the memory allocation item count and item size
     262 * parameter of this function similar to calloc().
     263 */
     264#if defined(__GNUC__)
     265  #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index ) \
     266     __attribute__((__alloc_size__(_count_index, _size_index)))
     267#else
     268  #define RTEMS_ALLOC_SIZE_2( _count_index, _size_index )
     269#endif
     270
     271/**
     272 * @brief Tells the compiler the memory allocation alignment parameter of this
     273 * function similar to aligned_alloc().
     274 */
     275#if defined(__GNUC__)
     276  #define RTEMS_ALLOC_ALIGN( _index ) __attribute__((__alloc_align__(_index)))
     277#else
     278  #define RTEMS_ALLOC_ALIGN( _index )
     279#endif
     280
     281/**
     282 * @brief Tells the compiler that the result of this function should be used.
     283 */
     284#if defined(__GNUC__)
     285  #define RTEMS_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__))
     286#else
     287  #define RTEMS_WARN_UNUSED_RESULT
    238288#endif
    239289
Note: See TracChangeset for help on using the changeset viewer.