@@ -774,59 +774,51 @@ void scanSegments(in ref dl_phdr_info info, DSO* pdso) nothrow @nogc
774
774
775
775
/* *************************
776
776
* Input:
777
- * result where the output is to be written; dl_phdr_info is a Linux struct
777
+ * result where the output is to be written; dl_phdr_info is an OS struct
778
778
* Returns:
779
779
* true if found, and *result is filled in
780
780
* References:
781
781
* http://linux.die.net/man/3/dl_iterate_phdr
782
782
*/
783
- version ( linux ) bool findDSOInfoForAddr(in void * addr, dl_phdr_info* result=null ) nothrow @nogc
783
+ bool findDSOInfoForAddr (in void * addr, dl_phdr_info* result=null ) nothrow @nogc
784
784
{
785
- static struct DG { const (void )* addr; dl_phdr_info* result; }
785
+ version (linux ) enum IterateManually = true ;
786
+ else version (NetBSD ) enum IterateManually = true ;
787
+ else enum IterateManually = false ;
786
788
787
- extern ( C ) int callback(dl_phdr_info * info, size_t sz, void * arg) nothrow @nogc
789
+ static if (IterateManually)
788
790
{
789
- auto p = cast (DG * )arg;
790
- if (findSegmentForAddr(* info, p.addr))
791
+ static struct DG { const (void )* addr; dl_phdr_info* result; }
792
+
793
+ extern (C ) int callback(dl_phdr_info* info, size_t sz, void * arg) nothrow @nogc
791
794
{
792
- if (p.result ! is null ) * p.result = * info;
793
- return 1 ; // break;
795
+ auto p = cast (DG * )arg;
796
+ if (findSegmentForAddr(* info, p.addr))
797
+ {
798
+ if (p.result ! is null ) * p.result = * info;
799
+ return 1 ; // break;
800
+ }
801
+ return 0 ; // continue iteration
794
802
}
795
- return 0 ; // continue iteration
796
- }
797
-
798
- auto dg = DG (addr, result);
799
803
800
- /* Linux function that walks through the list of an application's shared objects and
801
- * calls 'callback' once for each object, until either all shared objects
802
- * have been processed or 'callback' returns a nonzero value.
803
- */
804
- return dl_iterate_phdr (&callback, &dg) != 0 ;
805
- }
806
- else version (FreeBSD ) bool findDSOInfoForAddr(in void * addr, dl_phdr_info* result=null ) nothrow @nogc
807
- {
808
- return !! _rtld_addr_phdr(addr, result);
809
- }
810
- else version (NetBSD ) bool findDSOInfoForAddr(in void * addr, dl_phdr_info* result=null ) nothrow @nogc
811
- {
812
- static struct DG { const (void )* addr; dl_phdr_info* result; }
804
+ auto dg = DG (addr, result);
813
805
814
- extern (C ) int callback(dl_phdr_info* info, size_t sz, void * arg) nothrow @nogc
806
+ /* OS function that walks through the list of an application's shared objects and
807
+ * calls 'callback' once for each object, until either all shared objects
808
+ * have been processed or 'callback' returns a nonzero value.
809
+ */
810
+ return dl_iterate_phdr (&callback, &dg) != 0 ;
811
+ }
812
+ else version (FreeBSD )
815
813
{
816
- auto p = cast (DG * )arg;
817
- if (findSegmentForAddr(* info, p.addr))
818
- {
819
- if (p.result ! is null ) * p.result = * info;
820
- return 1 ; // break;
821
- }
822
- return 0 ; // continue iteration
814
+ return !! _rtld_addr_phdr(addr, result);
823
815
}
824
- auto dg = DG (addr, result);
825
- return dl_iterate_phdr (&callback, &dg) != 0 ;
826
- }
827
- else version ( DragonFlyBSD ) bool findDSOInfoForAddr( in void * addr, dl_phdr_info * result= null ) nothrow @nogc
828
- {
829
- return !! _rtld_addr_phdr(addr, result );
816
+ else version ( DragonFlyBSD )
817
+ {
818
+ return !! _rtld_addr_phdr(addr, result);
819
+ }
820
+ else
821
+ static assert ( 0 , " unimplemented " );
830
822
}
831
823
832
824
/* ********************************
0 commit comments