Message ID | 20170823192244.18914-1-anatol.pomozov@gmail.com |
---|---|
State | New |
Headers | show |
Hi Anatol, On 08/23/2017 04:22 PM, Anatol Pomozov wrote: > * explicitly disable SSE as clang enables it by default for 32bit code > * add memset() implementation. Clang complains that the function is > absent, gcc seems provides default built-in. > --- > tests/multiboot/Makefile | 2 +- > tests/multiboot/libc.c | 9 +++++++++ > tests/multiboot/libc.h | 2 ++ > 3 files changed, 12 insertions(+), 1 deletion(-) > > diff --git a/tests/multiboot/Makefile b/tests/multiboot/Makefile > index 856e76682a..7fadbca33a 100644 > --- a/tests/multiboot/Makefile > +++ b/tests/multiboot/Makefile > @@ -1,5 +1,5 @@ > CC=gcc > -CCFLAGS=-m32 -Wall -Wextra -Werror -fno-stack-protector -nostdinc -fno-builtin > +CCFLAGS=-m32 -Wall -Wextra -Werror -fno-stack-protector -nostdinc -fno-builtin -mno-sse What about using -march=i586 instead? so no need to disable each next features clang decide to default enable. Even cleaner IMHO, use -march=pentium in CFLAGS and add "-cpu pentium" in run_test.sh so we are sure the generated code matches, what do you think? Regards, Phil. > ASFLAGS=-m32 > > LD=ld > diff --git a/tests/multiboot/libc.c b/tests/multiboot/libc.c > index 6df9bda96d..512fccd7fa 100644 > --- a/tests/multiboot/libc.c > +++ b/tests/multiboot/libc.c > @@ -33,6 +33,15 @@ void* memcpy(void *dest, const void *src, int n) > > return dest; > } > +void *memset(void *s, int c, size_t n) > +{ > + size_t i; > + char *d = s; > + for (i = 0; i < n; i++) { > + *d++ = c; > + } > + return s; > +} > > static void print_char(char c) > { > diff --git a/tests/multiboot/libc.h b/tests/multiboot/libc.h > index 04c9922c27..44b71350dd 100644 > --- a/tests/multiboot/libc.h > +++ b/tests/multiboot/libc.h > @@ -36,6 +36,7 @@ typedef signed short int16_t; > typedef signed char int8_t; > > typedef uint32_t uintptr_t; > +typedef uint32_t size_t; > > > /* stdarg.h */ > @@ -58,5 +59,6 @@ static inline void outb(uint16_t port, uint8_t data) > > void printf(const char *fmt, ...); > void* memcpy(void *dest, const void *src, int n); > +void *memset(void *s, int c, size_t n); > > #endif >
On Wed, Aug 23, 2017 at 4:44 PM, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote: > Hi Anatol, > > On 08/23/2017 04:22 PM, Anatol Pomozov wrote: >> >> * explicitly disable SSE as clang enables it by default for 32bit code >> * add memset() implementation. Clang complains that the function is >> absent, gcc seems provides default built-in. >> --- >> tests/multiboot/Makefile | 2 +- >> tests/multiboot/libc.c | 9 +++++++++ >> tests/multiboot/libc.h | 2 ++ >> 3 files changed, 12 insertions(+), 1 deletion(-) >> >> diff --git a/tests/multiboot/Makefile b/tests/multiboot/Makefile >> index 856e76682a..7fadbca33a 100644 >> --- a/tests/multiboot/Makefile >> +++ b/tests/multiboot/Makefile >> @@ -1,5 +1,5 @@ >> CC=gcc >> -CCFLAGS=-m32 -Wall -Wextra -Werror -fno-stack-protector -nostdinc >> -fno-builtin >> +CCFLAGS=-m32 -Wall -Wextra -Werror -fno-stack-protector -nostdinc >> -fno-builtin -mno-sse > > > What about using -march=i586 instead? so no need to disable each next > features clang decide to default enable. > > Even cleaner IMHO, use -march=pentium in CFLAGS and add "-cpu pentium" in > run_test.sh so we are sure the generated code matches, what do you think? It sounds reasonable. Just sent an updated patch. Works with gcc 6.3 and clang 3.8.
diff --git a/tests/multiboot/Makefile b/tests/multiboot/Makefile index 856e76682a..7fadbca33a 100644 --- a/tests/multiboot/Makefile +++ b/tests/multiboot/Makefile @@ -1,5 +1,5 @@ CC=gcc -CCFLAGS=-m32 -Wall -Wextra -Werror -fno-stack-protector -nostdinc -fno-builtin +CCFLAGS=-m32 -Wall -Wextra -Werror -fno-stack-protector -nostdinc -fno-builtin -mno-sse ASFLAGS=-m32 LD=ld diff --git a/tests/multiboot/libc.c b/tests/multiboot/libc.c index 6df9bda96d..512fccd7fa 100644 --- a/tests/multiboot/libc.c +++ b/tests/multiboot/libc.c @@ -33,6 +33,15 @@ void* memcpy(void *dest, const void *src, int n) return dest; } +void *memset(void *s, int c, size_t n) +{ + size_t i; + char *d = s; + for (i = 0; i < n; i++) { + *d++ = c; + } + return s; +} static void print_char(char c) { diff --git a/tests/multiboot/libc.h b/tests/multiboot/libc.h index 04c9922c27..44b71350dd 100644 --- a/tests/multiboot/libc.h +++ b/tests/multiboot/libc.h @@ -36,6 +36,7 @@ typedef signed short int16_t; typedef signed char int8_t; typedef uint32_t uintptr_t; +typedef uint32_t size_t; /* stdarg.h */ @@ -58,5 +59,6 @@ static inline void outb(uint16_t port, uint8_t data) void printf(const char *fmt, ...); void* memcpy(void *dest, const void *src, int n); +void *memset(void *s, int c, size_t n); #endif