[U-Boot] DECLARE_GLOBAL_DATA_PTR : move from source to Makefile

Hi, all, I find this macro is found anywhere in the source, nearly one thousand in the source, looks odd sometime. I have a idea about this:
1. remove DECLARE_GLOBAL_DATA_PTR from source about one thousand DECLARE_GLOBAL_DATA_PTR in the source
2. add a file like, same as other archs. arch/arm/include/asm/declare_global_data_ptr.h - - - - #ifndef __DECLARE_GLOBAL_DATA_PTR_H #define __DECLARE_GLOBAL_DATA_PTR_H
#ifdef CONFIG_ARM64 #define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("x18") #else #define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("r9") #endif
#endif - - - -
3. modify top level Makefile - - - - UBOOTINCLUDE := \ -Iinclude \ $(if $(KBUILD_SRC), -I$(srctree)/include) \ -I$(srctree)/arch/$(ARCH)/include \ -include $(srctree)/include/linux/kconfig.h \ + -include $(srctree)/arch/$(ARCH)/include/asm/global_data.h - - - -
... Du Huanpeng (+86)13719074147

Hi Kevin.
On Fri, 31 Oct 2014 13:04:38 +0800 Kevin Du Huanpeng u74147@gmail.com wrote:
Hi, all, I find this macro is found anywhere in the source, nearly one thousand in the source, looks odd sometime.
Only one thousand. We have more than 6000 source files.
yamada@beagle:~/workspace/u-boot$ find . -name '*.[ch]' | wc 6158 6158 198875 yamada@beagle:~/workspace/u-boot$ find . -name '*.[ch]' | xargs grep DECLARE_GLOBAL_DATA_PTR | wc 944 1099 54674
I have a idea about this:
remove DECLARE_GLOBAL_DATA_PTR from source about one thousand DECLARE_GLOBAL_DATA_PTR in the source
add a file like, same as other archs.
arch/arm/include/asm/declare_global_data_ptr.h
#ifndef __DECLARE_GLOBAL_DATA_PTR_H #define __DECLARE_GLOBAL_DATA_PTR_H
#ifdef CONFIG_ARM64 #define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("x18") #else #define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("r9") #endif
#endif
- modify top level Makefile
UBOOTINCLUDE := \ -Iinclude \ $(if $(KBUILD_SRC), -I$(srctree)/include) \ -I$(srctree)/arch/$(ARCH)/include \ -include $(srctree)/include/linux/kconfig.h \
-include $(srctree)/arch/$(ARCH)/include/asm/global_data.h
I do not like this idea. I think a source file should only include needed headers.
Best Regards Masahiro Yamada

Hi, Yamada, thanks for your reply, your reasons for keep this are: 1. 973/6535 = 10.60% in your opinion, 10.60 % is good. - - - - du@sailor:~/u-boot$ grep -R DECLARE_GLOBAL_DATA_PTR ./ | wc -l 973 du@sailor:~/openas/u-boot$ find -name "*.[chS]" | wc -l 6535 - - - -
2. a source file should only include needed headers I agree with this, but as its name it's a GLOBAL DATA, maybe my method is not the best way to fix this, so forget about it.
- - - - anyway, we focus on this question "shall u-boot keep this macro in 10% source files?"
... duhuanpeng (+86)138 232 25852 (+86)137 190 74147
2014-10-31 15:22 GMT+08:00 Masahiro Yamada yamada.m@jp.panasonic.com:
Hi Kevin.
On Fri, 31 Oct 2014 13:04:38 +0800 Kevin Du Huanpeng u74147@gmail.com wrote:
Hi, all, I find this macro is found anywhere in the source, nearly one thousand in the source, looks odd sometime.
Only one thousand. We have more than 6000 source files.
yamada@beagle:~/workspace/u-boot$ find . -name '*.[ch]' | wc 6158 6158 198875 yamada@beagle:~/workspace/u-boot$ find . -name '*.[ch]' | xargs grep DECLARE_GLOBAL_DATA_PTR | wc 944 1099 54674
I have a idea about this:
remove DECLARE_GLOBAL_DATA_PTR from source about one thousand DECLARE_GLOBAL_DATA_PTR in the source
add a file like, same as other archs.
arch/arm/include/asm/declare_global_data_ptr.h
#ifndef __DECLARE_GLOBAL_DATA_PTR_H #define __DECLARE_GLOBAL_DATA_PTR_H
#ifdef CONFIG_ARM64 #define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("x18") #else #define DECLARE_GLOBAL_DATA_PTR register volatile gd_t *gd asm ("r9") #endif
#endif
- modify top level Makefile
UBOOTINCLUDE := \ -Iinclude \ $(if $(KBUILD_SRC), -I$(srctree)/include) \ -I$(srctree)/arch/$(ARCH)/include \ -include $(srctree)/include/linux/kconfig.h \
-include $(srctree)/arch/$(ARCH)/include/asm/global_data.h
I do not like this idea. I think a source file should only include needed headers.
Best Regards Masahiro Yamada
participants (2)
-
Kevin Du Huanpeng
-
Masahiro Yamada