예제 #1
0
파일: aos_rhino.c 프로젝트: wosayttn/aos
void *aos_malloc(unsigned int size)
{
    void *tmp = NULL;

    if (size == 0) {
        return NULL;
    }

#if (RHINO_CONFIG_MM_DEBUG > 0u && RHINO_CONFIG_GCC_RETADDR > 0u)
    if ((size & AOS_UNSIGNED_INT_MSB) == 0) {
        tmp = krhino_mm_alloc(size | AOS_UNSIGNED_INT_MSB);

#ifndef AOS_BINS
#if defined (__CC_ARM)
        krhino_owner_attach(g_kmm_head, tmp, __return_address());
#elif defined (__GNUC__)
        krhino_owner_attach(g_kmm_head, tmp, (size_t)__builtin_return_address(0));
#endif /* __CC_ARM */
#endif
    } else {
        tmp = krhino_mm_alloc(size);
    }

#else
    tmp = krhino_mm_alloc(size);
#endif

    return tmp;
}
예제 #2
0
/**
 * @brief create a task
 */
esp_err_t espos_task_create_on_cpu (
    espos_task_t *task,
    const char *name,
    void *arg,
    espos_prio_t prio,
    espos_tick_t ticks,
    espos_size_t stack_size,
    espos_task_entry_t entry,
    espos_opt_t opt,
    espos_cpu_t cpu_id
)
{
    kstat_t ret;
    ktask_t **ptask = (ktask_t **)task;
    uint8_t auto_run;
    extern void _cleanup_r(struct _reent* r);

    if (name == NULL) {
    	name = "default_task";
    }

    if (prio > ESPOS_TASK_PRIO_NUM)
        return espos_err_map(RHINO_BEYOND_MAX_PRI);

    if (ESPOS_TASK_CREATE_NORMAL == opt) {
        auto_run = 1;
    }
    else {
        auto_run = 0;
    }

    prio = ESPOS_TASK_PRIO_NUM - prio;
    prio = prio <= 0 ? 1 : prio;
    ret = krhino_task_dyn_create(ptask, name, arg, prio, ticks,
                        stack_size / sizeof(cpu_stack_t), entry, auto_run);

    /* The following code may open it later */
    #if 0
    if (ret == 0) {
        struct _reent *r;
        r = krhino_mm_alloc(sizeof(*r));
        esp_reent_init(r);
        ret = krhino_task_info_set(*ptask, 2, r);
    }
    #endif

    return espos_err_map(ret);
}
예제 #3
0
void *a_malloc(int32_t size, uint8_t id)
{
    void *addr;

    addr = (void *)krhino_mm_alloc(size);
    assert(addr);
    if (addr != NULL)
    {
        /*FIXME: !!!*/
//        PRINTF("SIZE = %d\r\n", size);
        g_totAlloc += size;
    }
    // UNUSED_ARGUMENT(id);

    return addr;
}