PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 line
2.5KB

  1. /**************************************************************************
  2. *
  3. * Copyright 2008-2018 by Andrey Butok. FNET Community.
  4. *
  5. ***************************************************************************
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License"); you may
  8. * not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. ***************************************************************************
  20. *
  21. * FNET memory pools API.
  22. *
  23. ***************************************************************************/
  24. #ifndef _FNET_MEMPOOL_H_
  25. #define _FNET_MEMPOOL_H_
  26. /**************************************************************************/ /*!
  27. * @internal
  28. * @brief Memory pool descriptor.
  29. * @see _fnet_mempool_init()
  30. ******************************************************************************/
  31. typedef fnet_int32_t fnet_mempool_desc_t;
  32. /* Memory pool unit header.*/
  33. FNET_COMP_PACKED_BEGIN
  34. typedef struct fnet_mempool_unit_header
  35. {
  36. fnet_size_t size FNET_COMP_PACKED; /* Unit size. */
  37. struct fnet_mempool_unit_header *ptr FNET_COMP_PACKED; /* Pointer to the next free block. */
  38. }
  39. fnet_mempool_unit_header_t;
  40. FNET_COMP_PACKED_END
  41. typedef enum
  42. {
  43. FNET_MEMPOOL_ALIGN_8 = (8u), /* Evenly divisible by 8.*/
  44. FNET_MEMPOOL_ALIGN_16 = (16u), /* Evenly divisible by 16.*/
  45. FNET_MEMPOOL_ALIGN_32 = (32u), /* Evenly divisible by 32.*/
  46. FNET_MEMPOOL_ALIGN_64 = (64u) /* Evenly divisible by 64.*/
  47. }
  48. fnet_mempool_align_t;
  49. #if defined(__cplusplus)
  50. extern "C" {
  51. #endif
  52. fnet_mempool_desc_t _fnet_mempool_init( void *pool_ptr, fnet_size_t pool_size, fnet_mempool_align_t alignment );
  53. void _fnet_mempool_release( fnet_mempool_desc_t mpool );
  54. void _fnet_mempool_free( fnet_mempool_desc_t mpool, void *ap );
  55. void *_fnet_mempool_malloc(fnet_mempool_desc_t mpool, fnet_size_t nbytes );
  56. fnet_size_t _fnet_mempool_free_mem_status( fnet_mempool_desc_t mpool);
  57. fnet_size_t _fnet_mempool_malloc_max( fnet_mempool_desc_t mpool );
  58. #if 0 /* For Debug needs.*/
  59. fnet_return_t _fnet_mempool_check( fnet_mempool_desc_t mpool );
  60. #endif
  61. #if defined(__cplusplus)
  62. }
  63. #endif
  64. #endif