git.ucc.asn.au
/
tpg
/
acess2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
1104e2b
)
Usermode/libc - Fixing errors from clang, disabled heap for native build
author
John Hodge
<
[email protected]
>
Mon, 22 Jul 2013 12:08:01 +0000
(20:08 +0800)
committer
John Hodge
<
[email protected]
>
Mon, 22 Jul 2013 12:08:01 +0000
(20:08 +0800)
Usermode/Libraries/libc.so_src/Makefile
patch
|
blob
|
history
Usermode/Libraries/libc.so_src/errno.c
patch
|
blob
|
history
Usermode/Libraries/libc.so_src/include_exp/errno.h
patch
|
blob
|
history
Usermode/Libraries/libc.so_src/include_exp/stdlib.h
patch
|
blob
|
history
Usermode/Libraries/libc.so_src/printf.c
patch
|
blob
|
history
Usermode/Libraries/libc.so_src/scanf.c
patch
|
blob
|
history
Usermode/Libraries/libc.so_src/string.c
patch
|
blob
|
history
diff --git
a/Usermode/Libraries/libc.so_src/Makefile
b/Usermode/Libraries/libc.so_src/Makefile
index
1414b1c
..
c8f4e5d
100644
(file)
--- a/
Usermode/Libraries/libc.so_src/Makefile
+++ b/
Usermode/Libraries/libc.so_src/Makefile
@@
-18,7
+18,7
@@
OBJ += arch/$(ARCHDIR).ao
DEPFILES := $(OBJ:%.o=%.d)
\r
BIN = libc.so
\r
ifeq ($(ARCHDIR),native)
\r
DEPFILES := $(OBJ:%.o=%.d)
\r
BIN = libc.so
\r
ifeq ($(ARCHDIR),native)
\r
-
#
OBJ := $(filter-out heap.o,$(OBJ))
\r
+ OBJ := $(filter-out heap.o,$(OBJ))
\r
#LDFLAGS += -l c
\r
BIN = libc_acess.so
\r
endif
\r
#LDFLAGS += -l c
\r
BIN = libc_acess.so
\r
endif
\r
diff --git
a/Usermode/Libraries/libc.so_src/errno.c
b/Usermode/Libraries/libc.so_src/errno.c
index
f1c3c4d
..
b5fe958
100644
(file)
--- a/
Usermode/Libraries/libc.so_src/errno.c
+++ b/
Usermode/Libraries/libc.so_src/errno.c
@@
-8,13
+8,14
@@
#include "lib.h"
#include <errno.h>
#include <acess/sys.h>
#include "lib.h"
#include <errno.h>
#include <acess/sys.h>
+#include <string.h>
EXPORT int *libc_geterrno()
{
return &_errno;
}
EXPORT int *libc_geterrno()
{
return &_errno;
}
-EXPORT c
onst c
har *strerror(int errnum)
+EXPORT char *strerror(int errnum)
{
switch(errnum)
{
{
switch(errnum)
{
@@
-27,7
+28,18
@@
EXPORT const char *strerror(int errnum)
case EPERM: return "Permissions error";
default:
_SysDebug("strerror: errnum=%i unk", errnum);
case EPERM: return "Permissions error";
default:
_SysDebug("strerror: errnum=%i unk", errnum);
+ errno = EINVAL;
return "unknown error";
}
}
return "unknown error";
}
}
+EXPORT int strerror_r(int errnum, char *buf, size_t bufsiz)
+{
+ const char *str = strerror(errnum);
+ if(!str)
+ return -1;
+
+ strncpy(buf, str, bufsiz);
+ return 0;
+}
+
diff --git
a/Usermode/Libraries/libc.so_src/include_exp/errno.h
b/Usermode/Libraries/libc.so_src/include_exp/errno.h
index
a808379
..
f06706f
100644
(file)
--- a/
Usermode/Libraries/libc.so_src/include_exp/errno.h
+++ b/
Usermode/Libraries/libc.so_src/include_exp/errno.h
@@
-8,12
+8,13
@@
#ifndef _LIBC_ERRNO_H_
#define _LIBC_ERRNO_H_
#ifndef _LIBC_ERRNO_H_
#define _LIBC_ERRNO_H_
-// TODO: Fully implement errno.h, make sure it matches the kernel one
+#include <stddef.h> // size_t
extern int *libc_geterrno(void);
#define errno (*libc_geterrno())
extern int *libc_geterrno(void);
#define errno (*libc_geterrno())
-extern const char *strerror(int errnum);
+extern int strerror_r(int errnum, char *buf, size_t buflen);
+extern char *strerror(int errnum);
#include "errno.enum.h"
#include "errno.enum.h"
diff --git
a/Usermode/Libraries/libc.so_src/include_exp/stdlib.h
b/Usermode/Libraries/libc.so_src/include_exp/stdlib.h
index
f692ddd
..
bbf76eb
100644
(file)
--- a/
Usermode/Libraries/libc.so_src/include_exp/stdlib.h
+++ b/
Usermode/Libraries/libc.so_src/include_exp/stdlib.h
@@
-37,6
+37,12
@@
# define bsearch acess_bsearch
\r
# define qsort acess_qsort
\r
\r
# define bsearch acess_bsearch
\r
# define qsort acess_qsort
\r
\r
+# define free acess_free
\r
+# define malloc acess_malloc
\r
+# define calloc acess_calloc
\r
+# define realloc acess_realloc
\r
+# define IsHeap acess_IsHeap
\r
+
\r
# define srand acess_srand
\r
# define rand acess_rand
\r
# define rand_p acess_rand_p
\r
# define srand acess_srand
\r
# define rand acess_rand
\r
# define rand_p acess_rand_p
\r
diff --git
a/Usermode/Libraries/libc.so_src/printf.c
b/Usermode/Libraries/libc.so_src/printf.c
index
2568ae8
..
905f790
100644
(file)
--- a/
Usermode/Libraries/libc.so_src/printf.c
+++ b/
Usermode/Libraries/libc.so_src/printf.c
@@
-44,7
+44,6
@@
size_t _printf_ftoa(printf_puts_t puts_cb, void *puts_h, long double num, size_t
*/
EXPORT int _vcprintf_int(printf_puts_t puts_cb, void *puts_h, const char *format, va_list args)
{
*/
EXPORT int _vcprintf_int(printf_puts_t puts_cb, void *puts_h, const char *format, va_list args)
{
- char tmp[65];
int c, minSize, precision, len;
size_t pos = 0;
char *p;
int c, minSize, precision, len;
size_t pos = 0;
char *p;
@@
-60,8
+59,6
@@
EXPORT int _vcprintf_int(printf_puts_t puts_cb, void *puts_h, const char *format
pos ++; \
} while(0)
pos ++; \
} while(0)
- tmp[32] = '\0';
-
while((c = *format++) != 0)
{
// Non-control character
while((c = *format++) != 0)
{
// Non-control character
@@
-165,9
+162,6
@@
EXPORT int _vcprintf_int(printf_puts_t puts_cb, void *puts_h, const char *format
}
}
}
}
- // Just help things along later
- p = tmp;
-
// Get Type
switch( c )
{
// Get Type
switch( c )
{
diff --git
a/Usermode/Libraries/libc.so_src/scanf.c
b/Usermode/Libraries/libc.so_src/scanf.c
index
3d45ed1
..
6fff176
100644
(file)
--- a/
Usermode/Libraries/libc.so_src/scanf.c
+++ b/
Usermode/Libraries/libc.so_src/scanf.c
@@
-326,11
+326,11
@@
int _vcscanf(int (*__getc)(void*), void (*__rewind)(void*), void *h, const char
valtype = _VCSCANF_NOTYPE;
break;
// match a set of characters
valtype = _VCSCANF_NOTYPE;
break;
// match a set of characters
- case '[':
-
fch = *format++
;
- if(
fch
== '^' ) {
+ case '[':
{
+
int invert = 0
;
+ if(
*format++
== '^' ) {
// Invert
// Invert
-
fch = *format
;
+
invert = 1
;
}
set_start = format;
set_len = 0;
}
set_start = format;
set_len = 0;
@@
-344,7
+344,7
@@
int _vcscanf(int (*__getc)(void*), void (*__rewind)(void*), void *h, const char
if( maxlen == 0 )
maxlen = -1;
ich = 0;
if( maxlen == 0 )
maxlen = -1;
ich = 0;
- while( maxlen -- && (ich = __getc(h)) && memchr(set_start, set_len, ich) )
+ while( maxlen -- && (ich = __getc(h)) &&
invert == !
memchr(set_start, set_len, ich) )
{
if(ptr._char) *ptr._char++ = ich;
nch ++;
{
if(ptr._char) *ptr._char++ = ich;
nch ++;
@@
-354,6
+354,7
@@
int _vcscanf(int (*__getc)(void*), void (*__rewind)(void*), void *h, const char
if(ptr._char) *ptr._char++ = 0;
valtype = _VCSCANF_NOTYPE;
break;
if(ptr._char) *ptr._char++ = 0;
valtype = _VCSCANF_NOTYPE;
break;
+ }
case 'p': // read back printf("%p")
valtype = _VCSCANF_NOTYPE;
break;
case 'p': // read back printf("%p")
valtype = _VCSCANF_NOTYPE;
break;
diff --git
a/Usermode/Libraries/libc.so_src/string.c
b/Usermode/Libraries/libc.so_src/string.c
index
3d30f1c
..
2ab271f
100644
(file)
--- a/
Usermode/Libraries/libc.so_src/string.c
+++ b/
Usermode/Libraries/libc.so_src/string.c
@@
-200,13
+200,13
@@
EXPORT char *strrchr(const char *str, int character)
* \fn EXPORT char *strstr(char *str1, const char *str2)
* \brief Search a \a str1 for the first occurance of \a str2
*/
* \fn EXPORT char *strstr(char *str1, const char *str2)
* \brief Search a \a str1 for the first occurance of \a str2
*/
-EXPORT char *strstr(char *str1, const char *str2)
+EXPORT char *strstr(c
onst c
har *str1, const char *str2)
{
const char *test = str2;
for(;*str1;str1++)
{
{
const char *test = str2;
for(;*str1;str1++)
{
- if(*test == '\0') return str1;
+ if(*test == '\0') return
(char*)
str1;
if(*str1 == *test) test++;
else test = str2;
}
if(*str1 == *test) test++;
else test = str2;
}
UCC
git Repository :: git.ucc.asn.au