Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 6ab8697 in mainline


Ignore:
Timestamp:
2009-10-07T14:03:35Z (11 years ago)
Author:
Martin Decky <martin@…>
Branches:
master
Children:
2088dfc
Parents:
7a53208
Message:

use builtin_va_* for va_* functions and va_list type
(this is probably safer than our own implementation since it respects the particular ABI used by the compiler)
this fixes kernel printf() when using clang

Files:
11 deleted
17 edited

Legend:

Unmodified
Added
Removed
  • kernel/Makefile

    r7a53208 r6ab8697  
    4949GCC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros ../config.h \
    5050        -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
    51         -finput-charset=UTF-8 -fno-builtin -Wall -Wextra -Wno-unused-parameter \
    52         -Wmissing-prototypes -Werror -nostdlib -nostdinc -pipe
     51        -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
     52        -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes -Werror \
     53        -pipe
    5354
    5455ICC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros ../config.h \
    55         -fno-builtin -Wall -Wmissing-prototypes -Werror \
    56         -nostdlib -nostdinc -wd170
     56        -ffreestanding -fno-builtin -nostdlib -nostdinc -Wall -Wmissing-prototypes \
     57        -Werror -wd170
    5758
    5859SUNCC_CFLAGS = -I$(INCLUDES) -xO$(OPTIMIZATION) \
     
    6263CLANG_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros ../config.h \
    6364        -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
    64         -finput-charset=UTF-8 -fno-builtin -Wall -Wextra -Wno-unused-parameter \
    65         -Wmissing-prototypes -nostdlib -nostdinc -pipe
     65        -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
     66        -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes -pipe \
     67        -arch $(CLANG_ARCH)
    6668
    6769LFLAGS = -M
  • kernel/arch/amd64/Makefile.inc

    r7a53208 r6ab8697  
    3434BFD = binary
    3535TARGET = amd64-linux-gnu
     36CLANG_ARCH = x86_64
    3637TOOLCHAIN_DIR = $(CROSS_PREFIX)/amd64
    3738
  • kernel/arch/ia32/Makefile.inc

    r7a53208 r6ab8697  
    3434BFD = binary
    3535TARGET = i686-pc-linux-gnu
     36CLANG_ARCH = i386
    3637TOOLCHAIN_DIR = $(CROSS_PREFIX)/ia32
    3738
  • kernel/generic/include/print.h

    r7a53208 r6ab8697  
    3737
    3838#include <arch/types.h>
    39 #include <arch/arg.h>
     39#include <stdarg.h>
    4040
    4141#define EOF (-1)
  • kernel/generic/include/printf/printf_core.h

    r7a53208 r6ab8697  
    3737
    3838#include <typedefs.h>
    39 #include <arch/arg.h>
     39#include <stdarg.h>
    4040
    4141/** Structure for specifying output methods for different printf clones. */
  • kernel/generic/include/stdarg.h

    r7a53208 r6ab8697  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3737 * for all architectures with compiler support for __builtin_va_*.
    3838 */
    39  
     39
    4040#ifndef KERN_STDARG_H_
    4141#define KERN_STDARG_H_
     
    4343typedef __builtin_va_list va_list;
    4444
    45 #define va_start(ap, last)              __builtin_va_start(ap, last)
    46 #define va_arg(ap, type)                __builtin_va_arg(ap, type)
    47 #define va_end(ap)                      __builtin_va_end(ap)
    48 #define va_copy(dst, src)               __builtin_va_copy(dst, src)
     45#define va_start(ap, last)  __builtin_va_start(ap, last)
     46#define va_arg(ap, type)    __builtin_va_arg(ap, type)
     47#define va_end(ap)          __builtin_va_end(ap)
     48#define va_copy(dst, src)   __builtin_va_copy(dst, src)
    4949
    5050#endif
  • kernel/generic/src/printf/printf_core.c

    r7a53208 r6ab8697  
    3939#include <printf/printf_core.h>
    4040#include <print.h>
    41 #include <arch/arg.h>
     41#include <stdarg.h>
    4242#include <macros.h>
    4343#include <string.h>
  • uspace/lib/libc/Makefile.toolchain

    r7a53208 r6ab8697  
    2727#
    2828
    29 CFLAGS = -I$(LIBC_PREFIX)/include -O3 -imacros $(LIBC_PREFIX)/../../../config.h \
     29GCC_CFLAGS = -I$(LIBC_PREFIX)/include -O3 -imacros $(LIBC_PREFIX)/../../../config.h \
    3030        -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
    31         -finput-charset=UTF-8 -fno-builtin -Wall -Wextra -Wno-unused-parameter \
    32         -Wmissing-prototypes -Werror-implicit-function-declaration -nostdlib \
    33         -nostdinc -pipe -g -D__$(ENDIANESS)__
     31        -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
     32        -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
     33        -Werror-implicit-function-declaration -pipe -g -D__$(ENDIANESS)__
     34
     35ICC_CFLAGS = -I$(LIBC_PREFIX)/include -O3 -imacros $(LIBC_PREFIX)/../../../config.h \
     36        -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
     37        -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
     38        -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
     39        -Werror-implicit-function-declaration -pipe -g -D__$(ENDIANESS)__
     40
     41CLANG_CFLAGS = -I$(LIBC_PREFIX)/include -O3 -imacros $(LIBC_PREFIX)/../../../config.h \
     42        -fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
     43        -finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
     44        -Wall -Wextra -Wno-unused-parameter -Wmissing-prototypes \
     45        -Werror-implicit-function-declaration -pipe -g -arch $(CLANG_ARCH) \
     46        -D__$(ENDIANESS)__
     47
    3448LFLAGS = -M -N $(SOFTINT_PREFIX)/libsoftint.a
    3549AFLAGS =
     
    7286        OBJCOPY = $(TOOLCHAIN_DIR)/$(TARGET)-objcopy
    7387        OBJDUMP = $(TOOLCHAIN_DIR)/$(TARGET)-objdump
     88        CFLAGS = $(GCC_CFLAGS)
    7489        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    7590endif
     
    8398        OBJCOPY = $(BINUTILS_PREFIX)objcopy
    8499        OBJDUMP = $(BINUTILS_PREFIX)objdump
     100        CFLAGS = $(GCC_CFLAGS)
    85101        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    86102endif
     
    94110        OBJCOPY = objcopy
    95111        OBJDUMP = objdump
     112        CFLAGS = $(ICC_CFLAGS)
    96113        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    97114endif
     
    105122        OBJCOPY = $(BINUTILS_PREFIX)objcopy
    106123        OBJDUMP = $(BINUTILS_PREFIX)objdump
     124        CFLAGS = $(CLANG_CFLAGS)
    107125        DEPEND_DEFS = $(DEFS) $(CONFIG_DEFS)
    108126endif
  • uspace/lib/libc/arch/amd64/Makefile.inc

    r7a53208 r6ab8697  
    3131
    3232TARGET = amd64-linux-gnu
     33CLANG_ARCH = x86_64
    3334TOOLCHAIN_DIR = $(CROSS_PREFIX)/amd64/bin
    3435
  • uspace/lib/libc/arch/arm32/Makefile.inc

    r7a53208 r6ab8697  
    3939        arch/$(UARCH)/src/eabi.S
    4040
    41 CFLAGS += -ffixed-r9 -mtp=soft
     41GCC_CFLAGS += -ffixed-r9 -mtp=soft
    4242LFLAGS += -N $(SOFTINT_PREFIX)/libsoftint.a
    4343
  • uspace/lib/libc/arch/ia32/Makefile.inc

    r7a53208 r6ab8697  
    3131
    3232TARGET = i686-pc-linux-gnu
     33CLANG_ARCH = i386
    3334TOOLCHAIN_DIR = $(CROSS_PREFIX)/ia32/bin
    3435
  • uspace/lib/libc/arch/ia64/Makefile.inc

    r7a53208 r6ab8697  
    3838        arch/$(UARCH)/src/ddi.c
    3939
    40 CFLAGS += -fno-unwind-tables
     40GCC_CFLAGS += -fno-unwind-tables
    4141LFLAGS += -N $(SOFTINT_PREFIX)/libsoftint.a
    4242
  • uspace/lib/libc/arch/mips32/Makefile.inc

    r7a53208 r6ab8697  
    3737        arch/$(UARCH)/src/tls.c
    3838
    39 CFLAGS += -mips3
     39GCC_CFLAGS += -mips3
    4040
    4141ENDIANESS = LE
  • uspace/lib/libc/arch/mips32eb/Makefile.inc

    r7a53208 r6ab8697  
    3434
    3535ARCH_SOURCES += arch/$(UARCH)/src/syscall.c \
    36                 arch/$(UARCH)/src/fibril.S \
    37                 arch/$(UARCH)/src/tls.c
     36        arch/$(UARCH)/src/fibril.S \
     37        arch/$(UARCH)/src/tls.c
    3838
    39 CFLAGS += -mips3
     39GCC_CFLAGS += -mips3
    4040LFLAGS += -N
    4141
  • uspace/lib/libc/arch/ppc32/Makefile.inc

    r7a53208 r6ab8697  
    3737        arch/$(UARCH)/src/tls.c
    3838
    39 CFLAGS += -mcpu=powerpc -msoft-float -m32
     39GCC_CFLAGS += -mcpu=powerpc -msoft-float -m32
    4040AFLAGS += -a32
    4141LFLAGS += -N
  • uspace/lib/libc/arch/sparc64/Makefile.inc

    r7a53208 r6ab8697  
    3636        arch/$(UARCH)/src/tls.c
    3737
    38 CFLAGS += -mcpu=ultrasparc -m64
     38GCC_CFLAGS += -mcpu=ultrasparc -m64
    3939LFLAGS += -no-check-sections -N
    4040
  • uspace/lib/libc/include/stdarg.h

    r7a53208 r6ab8697  
    3737
    3838#include <sys/types.h>
    39 #include <libarch/stackarg.h>
    40 
    41 #ifndef __VARARGS_DEFINED
    42 # define __VARARGS_DEFINED
    4339
    4440typedef __builtin_va_list va_list;
    4541
    46 # define va_start(ap, last)             __builtin_va_start(ap, last)
    47 # define va_arg(ap, type)               __builtin_va_arg(ap, type)
    48 # define va_end(ap)                     __builtin_va_end(ap)
    49 
    50 # endif
     42#define va_start(ap, last)  __builtin_va_start(ap, last)
     43#define va_arg(ap, type)    __builtin_va_arg(ap, type)
     44#define va_end(ap)          __builtin_va_end(ap)
    5145
    5246#endif
Note: See TracChangeset for help on using the changeset viewer.