当前位置: 首页>>代码示例>>C++>>正文


C++ LWIP_MEM_ALIGN函数代码示例

本文整理汇总了C++中LWIP_MEM_ALIGN函数的典型用法代码示例。如果您正苦于以下问题:C++ LWIP_MEM_ALIGN函数的具体用法?C++ LWIP_MEM_ALIGN怎么用?C++ LWIP_MEM_ALIGN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了LWIP_MEM_ALIGN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: memp_overflow_init

/**
 * Initialize the restricted areas of all memp elements in every pool.
 */
static void
memp_overflow_init(void)
{
  u16_t i, j;
  struct memp *p;
  u8_t *m;

#if !MEMP_SEPARATE_POOLS
  p = (struct memp *)LWIP_MEM_ALIGN(memp_memory);
#endif /* !MEMP_SEPARATE_POOLS */
  for (i = 0; i < MEMP_MAX; ++i) {
#if MEMP_SEPARATE_POOLS
    p = (struct memp *)(memp_bases[i]);
#endif /* MEMP_SEPARATE_POOLS */
    for (j = 0; j < memp_num[i]; ++j) {
#if MEMP_SANITY_REGION_BEFORE_ALIGNED > 0
      m = (u8_t*)p + MEMP_SIZE - MEMP_SANITY_REGION_BEFORE_ALIGNED;
      memset(m, 0xcd, MEMP_SANITY_REGION_BEFORE_ALIGNED);
#endif
#if MEMP_SANITY_REGION_AFTER_ALIGNED > 0
      m = (u8_t*)p + MEMP_SIZE + memp_sizes[i];
      memset(m, 0xcd, MEMP_SANITY_REGION_AFTER_ALIGNED);
#endif
      p = (struct memp*)((u8_t*)p + MEMP_SIZE + memp_sizes[i] + MEMP_SANITY_REGION_AFTER_ALIGNED);
    }
  }
}
开发者ID:michas2,项目名称:l4re-snapshot,代码行数:30,代码来源:memp.c

示例2: mem_init

/**
 * Zero the heap and initialize start, end and lowest-free
 */
void
mem_init(void)
{
  struct mem *mem;

  LWIP_ASSERT("Sanity check alignment",
    (SIZEOF_STRUCT_MEM & (MEM_ALIGNMENT-1)) == 0);

  /* align the heap */
  ram = LWIP_MEM_ALIGN(ram_heap);
  /* initialize the start of the heap */
  mem = (struct mem *)ram;
  mem->next = MEM_SIZE_ALIGNED;
  mem->prev = 0;
  mem->used = 0;
  /* initialize the end of the heap */
  ram_end = (struct mem *)&ram[MEM_SIZE_ALIGNED];
  ram_end->used = 1;
  ram_end->next = MEM_SIZE_ALIGNED;
  ram_end->prev = MEM_SIZE_ALIGNED;

  mem_sem = sys_sem_new(1);

  /* initialize the lowest-free pointer to the start of the heap */
  lfree = (struct mem *)ram;

  MEM_STATS_AVAIL(avail, MEM_SIZE_ALIGNED);
}
开发者ID:InSoonPark,项目名称:asf,代码行数:31,代码来源:mem.c

示例3: memp_init

/**
 * Initialize this module.
 *
 * Carves out memp_memory into linked lists for each pool-type.
 */
void
memp_init(void)
{
  struct memp *memp;
  u16_t i, j;

#if MEMP_STATS
  for (i = 0; i < MEMP_MAX; ++i) {
    lwip_stats.memp[i].used = lwip_stats.memp[i].max =
      lwip_stats.memp[i].err = 0;
    lwip_stats.memp[i].avail = memp_num[i];
  }
#endif /* MEMP_STATS */

  memp = LWIP_MEM_ALIGN(memp_memory);
  /* for every pool: */
  for (i = 0; i < MEMP_MAX; ++i) {
    memp_tab[i] = NULL;
    /* create a linked list of memp elements */
    for (j = 0; j < memp_num[i]; ++j) {
      memp->next = memp_tab[i];
      memp_tab[i] = memp;
      memp = (struct memp *)((u8_t *)memp + MEMP_SIZE + memp_sizes[i]);
    }
  }
#if MEMP_OVERFLOW_CHECK
  memp_overflow_init();
  /* check everything a first time to see if it worked */
  memp_overflow_check_all();
#endif /* MEMP_OVERFLOW_CHECK */
}
开发者ID:BlueSkyGjj,项目名称:nRF52,代码行数:36,代码来源:memp.c

示例4: memp_init

/**
 * Initialize this module.
 * 
 * Carves out memp_memory into linked lists for each pool-type.
 */
void
memp_init(void)
{
  struct memp *memp;
  u16_t i, j;

  for (i = 0; i < MEMP_MAX; ++i) {
    MEMP_STATS_AVAIL(used, i, 0);
    MEMP_STATS_AVAIL(max, i, 0);
    MEMP_STATS_AVAIL(err, i, 0);
    MEMP_STATS_AVAIL(avail, i, memp_num[i]);
  }

  memp = LWIP_MEM_ALIGN(memp_memory);
  /* for every pool: */
  for (i = 0; i < MEMP_MAX; ++i) {
    memp_tab[i] = NULL;
    /* create a linked list of memp elements */
    for (j = 0; j < memp_num[i]; ++j) {
      memp->next = memp_tab[i];
      memp_tab[i] = memp;
      memp = (struct memp *)((u8_t *)memp + MEMP_SIZE + memp_sizes[i]
#if MEMP_OVERFLOW_CHECK
        + MEMP_SANITY_REGION_AFTER_ALIGNED
#endif
      );
    }
  }
#if MEMP_OVERFLOW_CHECK
  memp_overflow_init();
  /* check everything a first time to see if it worked */
  memp_overflow_check_all();
#endif /* MEMP_OVERFLOW_CHECK */
}
开发者ID:7h0ma5,项目名称:kiss-avraprs,代码行数:39,代码来源:memp.c

示例5: mem_free

/**
 * Free memory previously allocated by mem_malloc. Loads the pool number
 * and calls memp_free with that pool number to put the element back into
 * its pool
 *
 * @param rmem the memory element to free
 */
void
mem_free(void *rmem) {
	struct memp_malloc_helper *hmem = (struct memp_malloc_helper *)rmem;

	LWIP_ASSERT("rmem != NULL", (rmem != NULL));
	LWIP_ASSERT("rmem == MEM_ALIGN(rmem)", (rmem == LWIP_MEM_ALIGN(rmem)));

	/* get the original struct memp_malloc_helper */
	hmem--;

	LWIP_ASSERT("hmem != NULL", (hmem != NULL));
	LWIP_ASSERT("hmem == MEM_ALIGN(hmem)", (hmem == LWIP_MEM_ALIGN(hmem)));
	LWIP_ASSERT("hmem->poolnr < MEMP_MAX", (hmem->poolnr < MEMP_MAX));

	/* and put it in the pool we saved earlier */
	memp_free(hmem->poolnr, hmem);
}
开发者ID:Itachihi,项目名称:esp8266_car,代码行数:24,代码来源:mem.c

示例6: mem_free

/**
 * Free memory previously allocated by mem_malloc. Loads the pool number
 * and calls memp_free with that pool number to put the element back into
 * its pool
 *
 * @param rmem the memory element to free
 */
void
mem_free(void *rmem)
{
  struct memp_malloc_helper *hmem;

  LWIP_ASSERT("rmem != NULL", (rmem != NULL));
  LWIP_ASSERT("rmem == MEM_ALIGN(rmem)", (rmem == LWIP_MEM_ALIGN(rmem)));

  /* get the original struct memp_malloc_helper */
  hmem = (struct memp_malloc_helper*)(void*)((u8_t*)rmem - LWIP_MEM_ALIGN_SIZE(sizeof(struct memp_malloc_helper)));

  LWIP_ASSERT("hmem != NULL", (hmem != NULL));
  LWIP_ASSERT("hmem == MEM_ALIGN(hmem)", (hmem == LWIP_MEM_ALIGN(hmem)));
  LWIP_ASSERT("hmem->poolnr < MEMP_MAX", (hmem->poolnr < MEMP_MAX));

  /* and put it in the pool we saved earlier */
    fprintf(stderr,"mem_free ###################\n");
  memp_free(hmem->poolnr, hmem);
}
开发者ID:networkextension,项目名称:A.BIG.T,代码行数:26,代码来源:mem.c

示例7: mem_free

/** Put memory back on the heap
 *
 * @param rmem is the pointer as returned by a previous call to mem_malloc()
 */
void
mem_free(void *rmem)
{
  LWIP_ASSERT("rmem != NULL", (rmem != NULL));
  LWIP_ASSERT("rmem == MEM_ALIGN(rmem)", (rmem == LWIP_MEM_ALIGN(rmem)));
#if LWIP_STATS && MEM_STATS
  rmem = (u8_t*)rmem - MEM_LIBC_STATSHELPER_SIZE;
  MEM_STATS_DEC_USED(used, *(mem_size_t*)rmem);
#endif
  mem_clib_free(rmem);
}
开发者ID:SolarTeamEindhoven,项目名称:mbed,代码行数:15,代码来源:lwip_mem.c

示例8: memp_initialize_pbuf_list

void memp_initialize_pbuf_list(void)
{
    assert(memp_memory != NULL);
    struct memp *memp;
    uintptr_t uimemp;
    u16_t k, i, j;
    for (i = 0; i < MEMP_MAX; ++i) {
        MEMP_STATS_AVAIL(used, i, 0);
        MEMP_STATS_AVAIL(max, i, 0);
        MEMP_STATS_AVAIL(err, i, 0);
        MEMP_STATS_AVAIL(avail, i, memp_num[i]);
    }
    memp = LWIP_MEM_ALIGN(memp_memory);
/*    printf("memp_init: total types of pools %d\n", MEMP_MAX );
    printf("memp_init: total types of pools %d, memp_mem %p\n",
            MEMP_MAX, memp_memory);
    printf("memp_init: total types of pools %d, memp %p\n", MEMP_MAX, memp);
*/
    memp->next = NULL;
    /* for every pool: */
    for (k = 0; k < MEMP_MAX; ++k) {
        i = memp_sorted[k];
        memp_tab[i] = NULL;


        // Align memp to element size
        uimemp = (uintptr_t) memp;
        if (uimemp % memp_sizes[i] > 0) {
            uimemp += memp_sizes[i] - (uimemp % memp_sizes[i]);
        }
        memp = (struct memp *) uimemp;

        /* create a linked list of memp elements */
        for (j = 0; j < memp_num[i]; ++j) {
            memp->next = NULL;
            memp->next = memp_tab[i];
            memp_tab[i] = memp;
            memp = (struct memp *) ((u8_t *) memp + memp_sizes[i]);
        }
    }
    // Set how many free pbuf_pools are there
//    printf("memp_num[PBUF_POOL] %" PRIu16 "\n", memp_num[MEMP_MAX - 1]);
    pbuf_pool_counter = 0;
#if MEMP_OVERFLOW_CHECK
    memp_overflow_init();
    /* check everything a first time to see if it worked */
    memp_overflow_check_all();
#endif                          /* MEMP_OVERFLOW_CHECK */

//    mem_barrelfish_register_buf(RX_BUFFER_ID, memp_memory_size);
}
开发者ID:Karamax,项目名称:arrakis,代码行数:51,代码来源:memp.c

示例9: pbuf_alloced_custom

/** Initialize a custom pbuf (already allocated).
 *
 * @param layer flag to define header size
 * @param length size of the pbuf's payload
 * @param type type of the pbuf (only used to treat the pbuf accordingly, as
 *        this function allocates no memory)
 * @param p pointer to the custom pbuf to initialize (already allocated)
 * @param payload_mem pointer to the buffer that is used for payload and headers,
 *        must be at least big enough to hold 'length' plus the header size,
 *        may be NULL if set later
 * @param payload_mem_len the size of the 'payload_mem' buffer, must be at least
 *        big enough to hold 'length' plus the header size
 */
struct pbuf*
pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type, struct pbuf_custom *p,
		void *payload_mem, u16_t payload_mem_len)
{
	u16_t offset;
	LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_TRACE, ("pbuf_alloced_custom(length=%"U16_F")\n", length));

	/* determine header offset */
	offset = 0;
	switch (l)
	{
		case PBUF_TRANSPORT:
		/* add room for transport (often TCP) layer header */
		offset += PBUF_TRANSPORT_HLEN;
		/* FALLTHROUGH */
		case PBUF_IP:
		/* add room for IP layer header */
		offset += PBUF_IP_HLEN;
		/* FALLTHROUGH */
		case PBUF_LINK:
		/* add room for link layer header */
		offset += PBUF_LINK_HLEN;
		break;
		case PBUF_RAW:
		break;
		default:
		LWIP_ASSERT("pbuf_alloced_custom: bad pbuf layer", 0);
		return NULL;
	}

	if (LWIP_MEM_ALIGN_SIZE(offset) + length < payload_mem_len)
	{
		LWIP_DEBUGF(PBUF_DEBUG | LWIP_DBG_LEVEL_WARNING, ("pbuf_alloced_custom(length=%"U16_F") buffer too short\n", length));
		return NULL;
	}

	p->pbuf.next = NULL;
	if (payload_mem != NULL)
	{
		p->pbuf.payload = LWIP_MEM_ALIGN((void *)((u8_t *)payload_mem + offset));
	}
	else
	{
		p->pbuf.payload = NULL;
	}
	p->pbuf.flags = PBUF_FLAG_IS_CUSTOM;
	p->pbuf.len = p->pbuf.tot_len = length;
	p->pbuf.type = type;
	p->pbuf.ref = 1;
	return &p->pbuf;
}
开发者ID:Intelligent-Productions,项目名称:UDP_SPI_project,代码行数:64,代码来源:pbuf.c

示例10: memp_overflow_check_all

/**
 * Do an overflow check for all elements in every pool.
 *
 * @see memp_overflow_check_element for a description of the check
 */
static void ICACHE_FLASH_ATTR
memp_overflow_check_all(void)
{
  u16_t i, j;
  struct memp *p;

  p = (struct memp *)LWIP_MEM_ALIGN(memp_memory);
  for (i = 0; i < MEMP_MAX; ++i) {
    p = p;
    for (j = 0; j < memp_num[i]; ++j) {
      memp_overflow_check_element_overflow(p, i);
      p = (struct memp*)((u8_t*)p + MEMP_SIZE + memp_sizes[i] + MEMP_SANITY_REGION_AFTER_ALIGNED);
    }
  }
  p = (struct memp *)LWIP_MEM_ALIGN(memp_memory);
  for (i = 0; i < MEMP_MAX; ++i) {
    p = p;
    for (j = 0; j < memp_num[i]; ++j) {
      memp_overflow_check_element_underflow(p, i);
      p = (struct memp*)((u8_t*)p + MEMP_SIZE + memp_sizes[i] + MEMP_SANITY_REGION_AFTER_ALIGNED);
    }
  }
}
开发者ID:AbuShaqra,项目名称:nodemcu-firmware,代码行数:28,代码来源:memp.c

示例11: pbuf_alloc

struct pbuf *
pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type)
{
  struct pbuf *p;
  u16_t offset = 0;
  offset += 16;
  
    /* If pbuf is to be allocated in RAM, allocate memory for it. */
  p = (struct pbuf*)rt_malloc(LWIP_MEM_ALIGN_SIZE(SIZEOF_STRUCT_PBUF + offset) + LWIP_MEM_ALIGN_SIZE(length));
  if (p == RT_NULL)  return RT_NULL; 
    /* Set up internal structure of the pbuf. */
  p->payload = LWIP_MEM_ALIGN((void *)((u8_t *)p + SIZEOF_STRUCT_PBUF + offset));
  p->len = length;   
  return p;
}
开发者ID:634351070,项目名称:rt-thread,代码行数:15,代码来源:uip_pbuf.c

示例12: memp_overflow_check_all

/**
 * Do an overflow check for all elements in every pool.
 *
 * @see memp_overflow_check_element for a description of the check
 */
static void
memp_overflow_check_all(void)
{
  u16_t i, j;
  struct memp *p;

#if !MEMP_SEPARATE_POOLS
  p = (struct memp *)LWIP_MEM_ALIGN(memp_memory);
#endif /* !MEMP_SEPARATE_POOLS */

  for (i = 0; i < MEMP_MAX; ++i) {
#if MEMP_SEPARATE_POOLS
    p = (struct memp*)memp_bases[i];
#endif /* MEMP_SEPARATE_POOLS */
    p = p;
    for (j = 0; j < memp_num[i]; ++j) {
      memp_overflow_check_element_overflow(p, i);
      p = (struct memp*)((u8_t*)p + MEMP_SIZE + memp_sizes[i] + MEMP_SANITY_REGION_AFTER_ALIGNED);
    }
  }

#if !MEMP_SEPARATE_POOLS
  p = (struct memp *)LWIP_MEM_ALIGN(memp_memory);
#endif /* !MEMP_SEPARATE_POOLS */

  for (i = 0; i < MEMP_MAX; ++i) {
#if MEMP_SEPARATE_POOLS
    p = (struct memp*)memp_bases[i];
#endif /* MEMP_SEPARATE_POOLS */
    p = p;
    for (j = 0; j < memp_num[i]; ++j) {
      memp_overflow_check_element_underflow(p, i);
      p = (struct memp*)((u8_t*)p + MEMP_SIZE + memp_sizes[i] + MEMP_SANITY_REGION_AFTER_ALIGNED);
    }
  }
}
开发者ID:119,项目名称:bcm-wiced-sdk,代码行数:41,代码来源:memp.c

示例13: memp_overflow_check_all

/**
 * Do an overflow check for all elements in every pool.
 *
 * @see memp_overflow_check_element for a description of the check
 */
static void
memp_overflow_check_all(void)
{
  u16_t i, j;
  struct memp *p;

  p = LWIP_MEM_ALIGN(memp_memory);
  for (i = 0; i < MEMP_MAX; ++i) {
    p = p;
    for (j = 0; j < memp_num[i]; ++j) {
      memp_overflow_check_element(p, memp_sizes[i]);
      p = (struct memp*)((u8_t*)p + MEMP_SIZE + memp_sizes[i]);
    }
  }
}
开发者ID:BlueSkyGjj,项目名称:nRF52,代码行数:20,代码来源:memp.c

示例14: memp_initialize_pbuf_list

void memp_initialize_pbuf_list(void)
{

    assert(memp_memory != NULL);
    struct memp *memp;
    u16_t i, j;
    for (i = 0; i < MEMP_MAX; ++i) {
        MEMP_STATS_AVAIL(used, i, 0);
        MEMP_STATS_AVAIL(max, i, 0);
        MEMP_STATS_AVAIL(err, i, 0);
        MEMP_STATS_AVAIL(avail, i, memp_num[i]);
    }
    memp = LWIP_MEM_ALIGN(memp_memory);
/*    printf("memp_init: total types of pools %d\n", MEMP_MAX );
    printf("memp_init: total types of pools %d, memp_mem %p\n",
            MEMP_MAX, memp_memory);
    printf("memp_init: total types of pools %d, memp %p\n", MEMP_MAX, memp);
*/
    memp->next = NULL;
    /* for every pool: */
    for (i = 0; i < MEMP_MAX; ++i) {
        memp_tab[i] = NULL;
/*      printf("memp_init: %" PRIu16 "(%s) size %" PRIu16 " num %" PRIu16 "\n",
               i, memp_desc[i], memp_sizes[i], memp_num[i]);
*/
        /* create a linked list of memp elements */
        for (j = 0; j < memp_num[i]; ++j) {
            memp->next = NULL;
            memp->next = memp_tab[i];
            memp_tab[i] = memp;
            memp = (struct memp *) ((u8_t *) memp + MEMP_SIZE + memp_sizes[i]
#if MEMP_OVERFLOW_CHECK
                                    + MEMP_SANITY_REGION_AFTER_ALIGNED
#endif
              );
        }
    }
    // Set how many free pbuf_pools are there
//    printf("memp_num[PBUF_POOL] %" PRIu16 "\n", memp_num[MEMP_MAX - 1]);
    pbuf_pool_counter = 0;
#if MEMP_OVERFLOW_CHECK
    memp_overflow_init();
    /* check everything a first time to see if it worked */
    memp_overflow_check_all();
#endif                          /* MEMP_OVERFLOW_CHECK */

//    mem_barrelfish_register_buf(RX_BUFFER_ID, memp_memory_size);
}
开发者ID:CoryXie,项目名称:BarrelfishOS,代码行数:48,代码来源:memp.c

示例15: mem_malloc

/**
 * Allocate a block of memory with a minimum of 'size' bytes.
 *
 * @param size is the minimum size of the requested block in bytes.
 * @return pointer to allocated memory or NULL if no free memory was found.
 *
 * Note that the returned value must always be aligned (as defined by MEM_ALIGNMENT).
 */
void *
mem_malloc(mem_size_t size)
{
  void* ret = mem_clib_malloc(size + MEM_LIBC_STATSHELPER_SIZE);
  if (ret == NULL) {
    MEM_STATS_INC(err);
  } else {
    LWIP_ASSERT("malloc() must return aligned memory", LWIP_MEM_ALIGN(ret) == ret);
#if LWIP_STATS && MEM_STATS
    *(mem_size_t*)ret = size;
    ret = (u8_t*)ret + MEM_LIBC_STATSHELPER_SIZE;
    MEM_STATS_INC_USED(used, size);
#endif
  }
  return ret;
}
开发者ID:SolarTeamEindhoven,项目名称:mbed,代码行数:24,代码来源:lwip_mem.c


注:本文中的LWIP_MEM_ALIGN函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。