Pass same CFLAGS for libc

This commit is contained in:
K. Lange 2018-04-25 21:39:55 +09:00 committed by Kevin Lange
parent 5004ea8c5d
commit df277155c4
8 changed files with 20 additions and 27 deletions

View File

@ -23,7 +23,7 @@ TARGET_TRIPLET=i686-pc-toaru
CC=$(TARGET_TRIPLET)-gcc
AR=$(TARGET_TRIPLET)-ar
CFLAGS= -O3 -m32 -Wa,--32 -g -std=c99 -I. -Iapps -pipe -mfpmath=sse -mmmx -msse -msse2 -fplan9-extensions -Wall -Wextra -Wno-unused-parameter
CFLAGS= -O3 -g -std=gnu99 -I. -Iapps -pipe -mfpmath=sse -mmmx -msse -msse2 -fplan9-extensions -Wall -Wextra -Wno-unused-parameter
LIBC_OBJS=$(patsubst %.c,%.o,$(wildcard libc/*.c))
LC=base/lib/libc.so
@ -119,7 +119,7 @@ base/lib/crt%.o: libc/crt%.s
yasm -f elf -o $@ $<
libc/%.o: libc/%.c
$(CC) -fPIC -c -m32 -Wa,--32 -O3 -o $@ $<
$(CC) $(CFLAGS) -fPIC -c -o $@ $<
base/lib/libc.a: ${LIBC_OBJS} | dirs crts
$(AR) cr $@ $^

View File

@ -20,9 +20,7 @@ int execvp(const char *file, char *const argv[]) {
path = DEFAULT_PATH;
}
char * xpath = strdup(path);
int found = 0;
char * p, * tokens[10], * last;
int i = 0;
char * p, * last;
for ((p = strtok_r(xpath, ":", &last)); p; p = strtok_r(NULL, ":", &last)) {
int r;
struct stat stat_buf;

View File

@ -61,7 +61,6 @@ struct tm *localtime(const time_t *timep) {
fprintf(stderr, "Hello world?\n");
long seconds = 0; // this needs to be bigger, but whatever
int year = 0;
long year_sec = 0;

View File

@ -192,7 +192,7 @@ void free(void * ptr) {
/*
* Adjust bin size in bin_size call to proper bounds.
*/
static uintptr_t inline __attribute__ ((always_inline, pure)) klmalloc_adjust_bin(uintptr_t bin)
static inline uintptr_t __attribute__ ((always_inline, pure)) klmalloc_adjust_bin(uintptr_t bin)
{
if (bin <= (uintptr_t)SMALLEST_BIN_LOG)
{
@ -209,7 +209,7 @@ static uintptr_t inline __attribute__ ((always_inline, pure)) klmalloc_adjust_bi
* Given a size value, find the correct bin
* to place the requested allocation in.
*/
static uintptr_t inline __attribute__ ((always_inline, pure)) klmalloc_bin_size(uintptr_t size) {
static inline uintptr_t __attribute__ ((always_inline, pure)) klmalloc_bin_size(uintptr_t size) {
uintptr_t bin = sizeof(size) * CHAR_BIT - __builtin_clzl(size);
bin += !!(size & (size - 1));
return klmalloc_adjust_bin(bin);
@ -270,7 +270,7 @@ static klmalloc_big_bin_header * klmalloc_newest_big = NULL; /* Newest big bin
* position in the list by linking
* its neighbors to eachother.
*/
static void inline __attribute__ ((always_inline)) klmalloc_list_decouple(klmalloc_bin_header_head *head, klmalloc_bin_header *node) {
static inline void __attribute__ ((always_inline)) klmalloc_list_decouple(klmalloc_bin_header_head *head, klmalloc_bin_header *node) {
klmalloc_bin_header *next = node->next;
head->first = next;
node->next = NULL;
@ -283,7 +283,7 @@ static void inline __attribute__ ((always_inline)) klmalloc_list_decouple(klmall
* elements are updated to point back
* to it (our list is doubly linked).
*/
static void inline __attribute__ ((always_inline)) klmalloc_list_insert(klmalloc_bin_header_head *head, klmalloc_bin_header *node) {
static inline void __attribute__ ((always_inline)) klmalloc_list_insert(klmalloc_bin_header_head *head, klmalloc_bin_header *node) {
node->next = head->first;
head->first = node;
}
@ -330,7 +330,7 @@ static uint32_t __attribute__ ((pure)) klmalloc_skip_rand(void) {
/*
* Generate a random level for a skip node
*/
static int inline __attribute__ ((pure, always_inline)) klmalloc_random_level(void) {
static inline int __attribute__ ((pure, always_inline)) klmalloc_random_level(void) {
int level = 0;
/*
* Keep trying to check rand() against 50% of its maximum.
@ -572,7 +572,7 @@ static void klmalloc_stack_push(klmalloc_bin_header *header, void *ptr) {
* stack, so there is no more free
* space available in the block.
*/
static int inline __attribute__ ((always_inline)) klmalloc_stack_empty(klmalloc_bin_header *header) {
static inline int __attribute__ ((always_inline)) klmalloc_stack_empty(klmalloc_bin_header *header) {
return header->head == NULL;
}

View File

@ -2,12 +2,8 @@
#include <string.h>
int puts(const char *s) {
size_t l = strlen(s);
if (fwrite(s, 1, strlen(s), stdout) < 0) {
return EOF;
}
if (fwrite("\n", 1, 1, stdout) < 0) {
return EOF;
}
/* eof? */
fwrite(s, 1, strlen(s), stdout);
fwrite("\n", 1, 1, stdout);
return 0;
}

View File

@ -90,7 +90,7 @@ size_t fread(void *ptr, size_t size, size_t nmemb, FILE * stream) {
return -1;
}
tracking += r;
if (r < size) {
if (r < (int)size) {
return i;
}
}
@ -106,7 +106,7 @@ size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE * stream) {
return -1;
}
tracking += r;
if (r < size) {
if (r < (int)size) {
return i;
}
}
@ -122,9 +122,8 @@ int fflush(FILE * stream) {
}
int fputs(const char *s, FILE *stream) {
if (fwrite(s, strlen(s), 1, stream) < 0) {
return EOF;
}
fwrite(s, strlen(s), 1, stream);
/* eof? */
return 0;
}
@ -137,7 +136,6 @@ int fputc(int c, FILE *stream) {
int fgetc(FILE * stream) {
char buf[1];
int r;
_try_again:
r = fread(buf, 1, 1, stream);
if (r < 0) {
return EOF;

View File

@ -56,6 +56,8 @@ size_t strftime(char *s, size_t max, const char *fmt, const struct tm *tm) {
_alto = 1;
++f;
}
(void)_alte; /* TODO: Implement these */
(void)_alto;
switch (*f) {
case 'a':
b += sprintf(b, "%s", weekdays_short[tm->tm_wday]);
@ -177,7 +179,7 @@ size_t strftime(char *s, size_t max, const char *fmt, const struct tm *tm) {
b += sprintf(b, "UTC");
break;
case '%':
b += sprintf(b, "%");
b += sprintf(b, "%c", '%');
break;
case 'V':
case 'W':

View File

@ -19,7 +19,7 @@ DECL_SYSCALL3(readlink, char *, char *, int);
int open(const char *name, int flags, ...) {
va_list argp;
int mode;
int mode = 0;
int result;
va_start(argp, flags);
if (flags & O_CREAT) mode = va_arg(argp, int);