[Gc] [patch] darwin: clean up some code.

Andreas Tobler andreast-list at fgznet.ch
Fri Dec 7 13:12:18 PST 2007


Hi all,

this patch cleans up a sin I did earlier.

Ok for trunk?
Tested on all darwin platforms except ppc64.

Thanks,
Andreas

2007-12-07  Andreas Tobler  <a.tobler at schweiz.org>

	* dyn_load.c (GC_dyld_image_add): Remove ifdef clause and use the macro
	GC_GETSECTBYNAME instead.
	* include/private/gc_priv.h: Define GC_GETSECTBYNAME according to the
	architecture (Darwin).
-------------- next part --------------
Index: dyn_load.c
===================================================================
RCS file: /cvsroot/bdwgc/bdwgc/dyn_load.c,v
retrieving revision 1.13
diff -u -r1.13 dyn_load.c
--- dyn_load.c	4 Aug 2007 06:26:29 -0000	1.13
+++ dyn_load.c	7 Dec 2007 20:39:42 -0000
@@ -1064,13 +1064,8 @@
     const struct GC_MACH_SECTION *sec;
     if (GC_no_dls) return;
     for(i=0;i<sizeof(GC_dyld_sections)/sizeof(GC_dyld_sections[0]);i++) {
-#   if defined (__LP64__)
-      sec = getsectbynamefromheader_64(
-#   else
-      sec = getsectbynamefromheader(
-#   endif
-				    hdr, GC_dyld_sections[i].seg,
-				    GC_dyld_sections[i].sect);
+      sec = GC_GETSECTBYNAME(hdr, GC_dyld_sections[i].seg,
+			     GC_dyld_sections[i].sect);
       if(sec == NULL || sec->size == 0) continue;
       start = slide + sec->addr;
       end = start + sec->size;
@@ -1092,13 +1087,8 @@
     unsigned long start,end,i;
     const struct GC_MACH_SECTION *sec;
     for(i=0;i<sizeof(GC_dyld_sections)/sizeof(GC_dyld_sections[0]);i++) {
-#   if defined (__LP64__)
-      sec = getsectbynamefromheader_64(
-#   else
-      sec = getsectbynamefromheader(
-#   endif
-				    hdr, GC_dyld_sections[i].seg,
-				    GC_dyld_sections[i].sect);
+      sec = GC_GETSECTBYNAME(hdr, GC_dyld_sections[i].seg,
+			     GC_dyld_sections[i].sect);
       if(sec == NULL || sec->size == 0) continue;
       start = slide + sec->addr;
       end = start + sec->size;
Index: include/private/gc_priv.h
===================================================================
RCS file: /cvsroot/bdwgc/bdwgc/include/private/gc_priv.h,v
retrieving revision 1.15
diff -u -r1.15 gc_priv.h
--- include/private/gc_priv.h	4 Aug 2007 06:26:29 -0000	1.15
+++ include/private/gc_priv.h	7 Dec 2007 20:39:42 -0000
@@ -375,12 +375,14 @@
 #		  define GC_MACH_THREAD_STATE_COUNT PPC_THREAD_STATE_COUNT
 #		  define GC_MACH_HEADER mach_header
 #		  define GC_MACH_SECTION section
+#                 define GC_GETSECTBYNAME getsectbynamefromheader
 #	        else
 #                 define GC_THREAD_STATE_T ppc_thread_state64_t
 #		  define GC_MACH_THREAD_STATE PPC_THREAD_STATE64
 #		  define GC_MACH_THREAD_STATE_COUNT PPC_THREAD_STATE64_COUNT
 #		  define GC_MACH_HEADER mach_header_64
 #		  define GC_MACH_SECTION section_64
+#                 define GC_GETSECTBYNAME getsectbynamefromheader_64
 #		endif
 #	elif defined(I386) || defined(X86_64)
 #               if CPP_WORDSZ == 32
@@ -389,12 +391,14 @@
 #		  define GC_MACH_THREAD_STATE_COUNT x86_THREAD_STATE32_COUNT
 #		  define GC_MACH_HEADER mach_header
 #		  define GC_MACH_SECTION section
+#                 define GC_GETSECTBYNAME getsectbynamefromheader
 #               else
 #		  define GC_THREAD_STATE_T x86_thread_state64_t
 #		  define GC_MACH_THREAD_STATE x86_THREAD_STATE64
 #		  define GC_MACH_THREAD_STATE_COUNT x86_THREAD_STATE64_COUNT
 #		  define GC_MACH_HEADER mach_header_64
 #		  define GC_MACH_SECTION section_64
+#                 define GC_GETSECTBYNAME getsectbynamefromheader_64
 #               endif
 #	else
 #		error define GC_THREAD_STATE_T


More information about the Gc mailing list