cache_aligned_malloc.c

来自「RTEMS (Real-Time Executive for Multiproc」· C语言 代码 · 共 45 行

C
45
字号
/* *  RTEMS Cache Aligned Malloc * * *  COPYRIGHT (c) 1989-1999. *  On-Line Applications Research Corporation (OAR). * *  The license and distribution terms for this file may be *  found in the file LICENSE in this distribution or at *  http://www.rtems.com/license/LICENSE. * *  $Id: cache_aligned_malloc.c,v 1.3.6.1 2003/09/04 18:54:13 joel Exp $ */#include <rtems.h>#include <cache_.h>#include <stdlib.h>/* *  rtems_cache_aligned_malloc * *  DESCRIPTION: * *  This function is used to allocate storage that spans an *  integral number of cache blocks. */void *rtems_cache_aligned_malloc (  size_t nbytes){  /*   * Arrange to have the user storage start on the first cache   * block beyond the header.   */#if defined(CPU_DATA_CACHE_ALIGNMENT)  return (void *) ((((unsigned long)     malloc( nbytes + CPU_DATA_CACHE_ALIGNMENT - 1 ))        + CPU_DATA_CACHE_ALIGNMENT - 1 ) &(~(CPU_DATA_CACHE_ALIGNMENT - 1)) );#else  return malloc( nbytes );#endif}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?