summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKumar Gala <kumar.gala@linaro.org>2016-06-07 14:15:23 -0500
committerAnas Nashif <nashif@linux.intel.com>2016-06-09 16:22:28 +0000
commit7fdd4f758df224fad83573768b1cd34b645b870a (patch)
tree99bd25d2c8c41a1230cf8d422f89920d1de007ea /lib
parentab5614ed9e8b2bd0a98e782931574620863fcc73 (diff)
newlib: Support both namespace protected & nonprotected stubs
Some variants of newlib build and expect namespace protected stubs (typically having an underscore prefix). To support such newlib variants change all the stubs to the namespace protect version and use function aliases to support the nonprotected namespace version. Change-Id: I6a4162eca949afec96b152ffe6f60b87c4496c4d Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/newlib/libc-hooks.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/lib/libc/newlib/libc-hooks.c b/lib/libc/newlib/libc-hooks.c
index 34b538db7..d9d965115 100644
--- a/lib/libc/newlib/libc-hooks.c
+++ b/lib/libc/newlib/libc-hooks.c
@@ -58,7 +58,7 @@ void __stdin_hook_install(unsigned char (*hook)(void))
_stdin_hook = hook;
}
-int read(int fd, char *buf, int nbytes)
+int _read(int fd, char *buf, int nbytes)
{
int i = 0;
@@ -71,8 +71,9 @@ int read(int fd, char *buf, int nbytes)
}
return i;
}
+FUNC_ALIAS(_read, read, int);
-int write(int fd, char *buf, int nbytes)
+int _write(int fd, char *buf, int nbytes)
{
int i;
@@ -84,54 +85,60 @@ int write(int fd, char *buf, int nbytes)
}
return nbytes;
}
+FUNC_ALIAS(_write, write, int);
-int isatty(int file)
+int _isatty(int file)
{
return 1;
}
+FUNC_ALIAS(_isatty, isatty, int);
-
-int kill(int i, int j)
+int _kill(int i, int j)
{
return 0;
}
+FUNC_ALIAS(_kill, kill, int);
-int getpid(void)
+int _getpid(void)
{
return 0;
}
+FUNC_ALIAS(_getpid, getpid, int);
-int fstat(int file, struct stat *st)
+int _fstat(int file, struct stat *st)
{
st->st_mode = S_IFCHR;
return 0;
}
-
+FUNC_ALIAS(_fstat, fstat, int);
void _exit(int status)
{
- write(1, "exit", 4);
+ _write(1, "exit", 4);
while (1) {
;
}
}
-int open(const char *name, int mode)
+int _open(const char *name, int mode)
{
return -1;
}
+FUNC_ALIAS(_open, open, int);
-int close(int file)
+int _close(int file)
{
return -1;
}
+FUNC_ALIAS(_close, close, int);
-int lseek(int file, int ptr, int dir)
+int _lseek(int file, int ptr, int dir)
{
return 0;
}
+FUNC_ALIAS(_lseek, lseek, int);
-void *sbrk(int count)
+void *_sbrk(int count)
{
void *ptr = heap_base + heap_sz;
@@ -142,3 +149,4 @@ void *sbrk(int count)
return (void *)-1;
}
}
+FUNC_ALIAS(_sbrk, sbrk, void *);