]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
GRUB_FILE implementation
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 9 Feb 2010 14:32:42 +0000 (15:32 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 9 Feb 2010 14:32:42 +0000 (15:32 +0100)
ChangeLog.grub-file [new file with mode: 0644]
fs/reiserfs.c
genmk.rb
include/grub/list.h
include/grub/misc.h
include/grub/mm.h
include/grub/test.h
kern/mm.c
lib/libgcrypt_wrap/cipher_wrap.h

diff --git a/ChangeLog.grub-file b/ChangeLog.grub-file
new file mode 100644 (file)
index 0000000..6b3126a
--- /dev/null
@@ -0,0 +1,13 @@
+2010-02-09  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Don't use __FILE__.
+
+       * genmk.rb: Add -DGRUB_FILE to all C targets.
+       * fs/reiserfs.c: Replace __FILE__ with GRUB_FILE.
+       * include/grub/list.h: Likewise.
+       * include/grub/misc.h: Likewise.
+       * include/grub/mm.h: Likewise.
+       * include/grub/test.h: Likewise.
+       * kern/mm.c: Likewise.
+       * lib/libgcrypt_wrap/cipher_wrap.h: Likewise.
+
index c3db52f60573c43be640d7f3869dd1efbf6ad84d..5acd339c5ef7e6ee13894f4a249488f3ae156e6d 100644 (file)
@@ -62,7 +62,7 @@
 
 static grub_dl_t my_mod;
 
-#define assert(boolean) real_assert (boolean, __FILE__, __LINE__)
+#define assert(boolean) real_assert (boolean, GRUB_FILE, __LINE__)
 static inline void
 real_assert (int boolean, const char *file, const int line)
 {
index df03e1dfef6bf2eb9b001916b21428b54ff006ec..ac5252412a10d7db9f8b1efdea9a52015db27d39 100644 (file)
--- a/genmk.rb
+++ b/genmk.rb
@@ -91,7 +91,7 @@ endif
       dir = File.dirname(src)
 
       "#{obj}: #{src} $(#{src}_DEPENDENCIES)
-       $(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -MD -c -o $@ $<
+       $(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -DGRUB_FILE=\\\"#{src}\\\" -MD -c -o $@ $<
 -include #{dep}
 
 "
@@ -163,7 +163,7 @@ endif
        $(TARGET_CC) $(#{prefix}_LDFLAGS) $(TARGET_LDFLAGS) -Wl,-r,-d -o $@ #{objs_str}
 
 #{mod_obj}: #{mod_src}
-       $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(#{prefix}_CFLAGS) -c -o $@ $<
+       $(TARGET_CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(#{prefix}_CFLAGS) -DGRUB_FILE=\\\"#{mod_src}\\\" -c -o $@ $<
 
 #{mod_src}: $(builddir)/moddep.lst $(srcdir)/genmodsrc.sh
        sh $(srcdir)/genmodsrc.sh '#{mod_name}' $< > $@ || (rm -f $@; exit 1)
@@ -197,7 +197,7 @@ endif
       dir = File.dirname(src)
 
       "#{obj}: #{src} $(#{src}_DEPENDENCIES)
-       $(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -MD -c -o $@ $<
+       $(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -DGRUB_FILE=\\\"#{src}\\\" -MD -c -o $@ $<
 -include #{dep}
 
 clean-module-#{extra_target}.#{@rule_count}:
@@ -299,7 +299,7 @@ MOSTLYCLEAN_UTILITY_TARGETS += mostlyclean-utility-#{@name}.#{@rule_count}
       dir = File.dirname(src)
 
       "#{obj}: #{src} $(#{src}_DEPENDENCIES)
-       $(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -MD -c -o $@ $<
+       $(CC) -I#{dir} -I$(srcdir)/#{dir} $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1 $(#{prefix}_CFLAGS) -DGRUB_FILE=\\\"#{src}\\\" -MD -c -o $@ $<
 -include #{dep}
 
 "
@@ -346,7 +346,7 @@ endif
       dir = File.dirname(src)
 
       "#{obj}: #{src} $(#{src}_DEPENDENCIES)
-       $(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -MD -c -o $@ $<
+       $(TARGET_CC) -I#{dir} -I$(srcdir)/#{dir} $(TARGET_CPPFLAGS) #{extra_flags} $(TARGET_#{flag}) $(#{prefix}_#{flag}) -DGRUB_FILE=\\\"#{src}\\\" -MD -c -o $@ $<
 
 -include #{dep}
 
index b7703e214b1f95239511ed69d5f5ee45697630d0..5559158dc6042d9baa4e0dbb50b1324c88482646 100644 (file)
@@ -52,7 +52,7 @@ grub_bad_type_cast_real (int line, const char *file)
   return 0;
 }
 
-#define grub_bad_type_cast() grub_bad_type_cast_real(__LINE__, __FILE__)
+#define grub_bad_type_cast() grub_bad_type_cast_real(__LINE__, GRUB_FILE)
 
 #define GRUB_FIELD_MATCH(ptr, type, field) \
   ((char *) &(ptr)->field == (char *) &((type) (ptr))->field)
index dcbafba876f1cfd15384f4c84d9449c44963bb50..5b1477ed49f19dc4350e2b833fd2d3b946d7dd6e 100644 (file)
@@ -46,7 +46,7 @@
 #define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
 #define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; }
 
-#define grub_dprintf(condition, fmt, args...) grub_real_dprintf(__FILE__, __LINE__, condition, fmt, ## args)
+#define grub_dprintf(condition, fmt, args...) grub_real_dprintf(GRUB_FILE, __LINE__, condition, fmt, ## args)
 /* XXX: If grub_memmove is too slow, we must implement grub_memcpy.  */
 #define grub_memcpy(d,s,n)     grub_memmove ((d), (s), (n))
 
index 4caf80511d80387e195b2ae7c6db9c7e01a34f3d..acefd2ea709dc38fb24735f80c12da94fd4af930 100644 (file)
@@ -44,19 +44,19 @@ void grub_mm_dump_free (void);
 void grub_mm_dump (unsigned lineno);
 
 #define grub_malloc(size)      \
-  grub_debug_malloc (__FILE__, __LINE__, size)
+  grub_debug_malloc (GRUB_FILE, __LINE__, size)
 
 #define grub_zalloc(size)      \
-  grub_debug_zalloc (__FILE__, __LINE__, size)
+  grub_debug_zalloc (GRUB_FILE, __LINE__, size)
 
 #define grub_realloc(ptr,size) \
-  grub_debug_realloc (__FILE__, __LINE__, ptr, size)
+  grub_debug_realloc (GRUB_FILE, __LINE__, ptr, size)
 
 #define grub_memalign(align,size)      \
-  grub_debug_memalign (__FILE__, __LINE__, align, size)
+  grub_debug_memalign (GRUB_FILE, __LINE__, align, size)
 
 #define grub_free(ptr) \
-  grub_debug_free (__FILE__, __LINE__, ptr)
+  grub_debug_free (GRUB_FILE, __LINE__, ptr)
 
 void *EXPORT_FUNC(grub_debug_malloc) (const char *file, int line,
                                      grub_size_t size);
index a7d3a239949d4be63b9da4ae9d32d669e8eee7fd..27591cca2cf70fba7607259ce6cf50f1e1e9f327 100644 (file)
@@ -54,7 +54,7 @@ void grub_test_nonzero (int cond, const char *file,
 
 /* Macro to fill in location details and an optional error message.  */
 #define grub_test_assert(cond, ...)                            \
-  grub_test_nonzero(cond, __FILE__, __FUNCTION__, __LINE__,    \
+  grub_test_nonzero(cond, GRUB_FILE, __FUNCTION__, __LINE__,   \
                    ## __VA_ARGS__,                             \
                    "assert failed: %s", #cond)
 
index ef97b018e9d7e91928078d5408c050527071391a..3237b040c28fde5f7adc77fe24bd5609ea576746 100644 (file)
--- a/kern/mm.c
+++ b/kern/mm.c
@@ -388,7 +388,7 @@ grub_free (void *ptr)
       do
        {
          grub_printf ("%s:%d: q=%p, q->size=0x%x, q->magic=0x%x\n",
-                      __FILE__, __LINE__, q, q->size, q->magic);
+                      GRUB_FILE, __LINE__, q, q->size, q->magic);
          q = q->next;
        }
       while (q != r->first);
index e05f0cda99cc3b5eef734483c7cb9af5c7567f62..b4530c11236075bfbe608908d244053f5d8172bf 100644 (file)
@@ -59,7 +59,7 @@ typedef union {
     double g;
 } PROPERLY_ALIGNED_TYPE;
 
-#define gcry_assert(x) grub_assert_real(__FILE__, __LINE__, x)
+#define gcry_assert(x) grub_assert_real(GRUB_FILE, __LINE__, x)
 
 static inline void
 grub_assert_real (const char *file, int line, int cond)