Skip to content

Commit

Permalink
BugID:16846667: Added armcc_libc_uspace.c
Browse files Browse the repository at this point in the history
	modified:   libc/aos.mk
	new file:   libc/compilers/armlibc/armcc_libc_uspace.c

Change-Id: Ief41e5f81acdfaa38ef2667802d1c5a18652edc6
  • Loading branch information
yangwencheng authored and Cheng-SG committed Mar 10, 2019
1 parent c4d0734 commit 3c49fc0
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 1 deletion.
8 changes: 8 additions & 0 deletions utility/libc/aos.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ $(NAME)_SUMMARY := libc adaptation layer
$(NAME)_MBINS_TYPE := share

ifeq ($(COMPILER),armcc)
ifeq ($(MBINS),app)
ifeq ($(ENABLE_USPACE),1)
$(NAME)_SOURCES := compilers/armlibc/armcc_libc_uspace.c
else
$(NAME)_SOURCES := compilers/armlibc/armcc_libc.c
endif
else
$(NAME)_SOURCES := compilers/armlibc/armcc_libc.c
endif
GLOBAL_INCLUDES += compilers/armlibc
else ifeq ($(COMPILER),rvct)
$(NAME)_SOURCES := compilers/armlibc/armcc_libc.c
Expand Down
116 changes: 116 additions & 0 deletions utility/libc/compilers/armlibc/armcc_libc_uspace.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/*
* Copyright (C) 2015-2017 Alibaba Group Holding Limited
*/

#include <string.h>
#include <stdio.h>
#include <sys/time.h>
#include "k_config.h"
#include <aos/hal/hal.h>
#include <u_mm.h>

#if defined (__CC_ARM) && defined(__MICROLIB)
void __aeabi_assert(const char *expr, const char *file, int line)
{
while (1);
}

extern uint64_t krhino_sys_time_get(void);

int gettimeofday(struct timeval *tv, void *tzp)
{
uint64_t t;

t = krhino_sys_time_get();

tv->tv_sec = t / 1000;
tv->tv_usec = (t % 1000) * 1000;

return 0;
}

void *malloc(size_t size)
{
void *mem;
mem = umm_malloc(size);

return mem;
}

void free(void *mem)
{
umm_free(mem);
}

void *realloc(void *old, size_t newlen)
{
void *mem;

mem = umm_realloc(old, newlen);

return mem;
}

void *calloc(size_t len, size_t elsize)
{
void *mem;
mem = umm_malloc(elsize * len);

if (mem) {
memset(mem, 0, elsize * len);
}

return mem;
}

char * strdup(const char *s)
{
size_t len = strlen(s) +1;
void *dup_str = umm_malloc(len);
if (dup_str == NULL)
return NULL;

return (char *)memcpy(dup_str, s, len);
}

#pragma weak fputc
int fputc(int ch, FILE *f)
{
uart_dev_t uart_stdio;

memset(&uart_stdio, 0, sizeof(uart_stdio));
uart_stdio.port = 0;
/* Send data. */
return hal_uart_send(&uart_stdio, (uint8_t *)(&ch), 1, 1000);
}

/* referred from ota_socket.o */
void bzero()
{

}

/* referred from ssl_cli.o */
time_t time(time_t *t)
{
return 0;
}

/* referred from aos_network.o */
int accept(int sock, long *addr, long *addrlen)
{
return 0;
}

int listen(int sock, int backlog)
{
return 0;
}

/* referred from timing.o */
unsigned int alarm(unsigned int seconds)
{
return 0;
}

#endif
2 changes: 1 addition & 1 deletion utility/libc/newlib_stub_uspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <stdarg.h>
#include <k_api.h>
#include <aos/aos.h>

#include <aos/hal/uart.h>

#include <u_mm.h>

Expand Down

0 comments on commit 3c49fc0

Please sign in to comment.