Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86, boot: Move memset() definition in compressed/string.c

Currently compressed/misc.c needs to link against memset(). I think one of
the reasons of this need is inclusion of various header files which define
static inline functions and use memset() inside these. For example,
include/linux/bitmap.h

I think trying to include "../string.h" and using builtin version of memset
does not work because by the time "#define memset" shows up, it is too
late. Some other header file has already used memset() and expects to
find a definition during link phase.

Currently we have a C definitoin of memset() in misc.c. Move it to
compressed/string.c so that others can use it if need be.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Link: http://lkml.kernel.org/r/1395170800-11059-6-git-send-email-vgoyal@redhat.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>

authored by

Vivek Goyal and committed by
H. Peter Anvin
04999550 fb4cac57

+17 -13
+7 -13
arch/x86/boot/compressed/misc.c
··· 98 98 */ 99 99 #define STATIC static 100 100 101 - #undef memset 102 101 #undef memcpy 102 + 103 + /* 104 + * Use a normal definition of memset() from string.c. There are already 105 + * included header files which expect a definition of memset() and by 106 + * the time we define memset macro, it is too late. 107 + */ 108 + #undef memset 103 109 #define memzero(s, n) memset((s), 0, (n)) 104 110 105 111 ··· 115 109 * This is set up by the setup-routine at boot-time 116 110 */ 117 111 struct boot_params *real_mode; /* Pointer to real-mode data */ 118 - 119 - void *memset(void *s, int c, size_t n); 120 112 121 113 memptr free_mem_ptr; 122 114 memptr free_mem_end_ptr; ··· 218 214 outb(0xff & (pos >> 9), vidport+1); 219 215 outb(15, vidport); 220 216 outb(0xff & (pos >> 1), vidport+1); 221 - } 222 - 223 - void *memset(void *s, int c, size_t n) 224 - { 225 - int i; 226 - char *ss = s; 227 - 228 - for (i = 0; i < n; i++) 229 - ss[i] = c; 230 - return s; 231 217 } 232 218 233 219 static void error(char *x)
+10
arch/x86/boot/compressed/string.c
··· 33 33 return dest; 34 34 } 35 35 #endif 36 + 37 + void *memset(void *s, int c, size_t n) 38 + { 39 + int i; 40 + char *ss = s; 41 + 42 + for (i = 0; i < n; i++) 43 + ss[i] = c; 44 + return s; 45 + }