This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc43a53
commit 0f0dcde
Showing
1 changed file
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| /** | ||
| * This module provides OSX-specific support routines for memory.d. | ||
| * | ||
| * Copyright: Copyright Digital Mars 2008 - 2010. | ||
| * License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>. | ||
| * Authors: Walter Bright, Sean Kelly | ||
| */ | ||
|
|
||
| /* Copyright Digital Mars 2008 - 2010. | ||
| * Distributed under the Boost Software License, Version 1.0. | ||
| * (See accompanying file LICENSE_1_0.txt or copy at | ||
| * http://www.boost.org/LICENSE_1_0.txt) | ||
| */ | ||
| #ifdef __APPLE__ | ||
|
|
||
|
|
||
| #include <mach-o/dyld.h> | ||
| #include <mach-o/getsect.h> | ||
|
|
||
| void gc_addRange( void* p, size_t sz ); | ||
| void gc_removeRange( void* p ); | ||
|
|
||
| typedef struct | ||
| { | ||
| const char* seg; | ||
| const char* sect; | ||
| } seg_ref; | ||
|
|
||
| const static seg_ref data_segs[] = {{SEG_DATA, SECT_DATA}, | ||
| {SEG_DATA, SECT_BSS}, | ||
| {SEG_DATA, SECT_COMMON}, | ||
| // These two must match names used by compiler machobj.c | ||
| {SEG_DATA, "__tls_data"}, | ||
| {SEG_DATA, "__tlscoal_nt"}, | ||
| }; | ||
| const static int NUM_DATA_SEGS = sizeof(data_segs) / sizeof(seg_ref); | ||
|
|
||
|
|
||
| #if defined(__LP64__) | ||
| static void on_add_image( const struct mach_header_64* h, intptr_t slide ) | ||
| { | ||
| int i; | ||
|
|
||
| for( i = 0; i < NUM_DATA_SEGS; ++i ) | ||
| { | ||
| const struct section_64* sect = getsectbynamefromheader_64( h, | ||
| data_segs[i].seg, | ||
| data_segs[i].sect ); | ||
| if( sect == NULL || sect->size == 0 ) | ||
| continue; | ||
| gc_addRange( (void*) sect->addr + slide, | ||
| (void*) sect->addr + slide + sect->size ); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| static void on_remove_image( const struct mach_header_64* h, intptr_t slide ) | ||
| { | ||
| int i; | ||
|
|
||
| for( i = 0; i < NUM_DATA_SEGS; ++i ) | ||
| { | ||
| const struct section_64* sect = getsectbynamefromheader_64( h, | ||
| data_segs[i].seg, | ||
| data_segs[i].sect ); | ||
| if( sect == NULL || sect->size == 0 ) | ||
| continue; | ||
| gc_removeRange( (void*) sect->addr + slide ); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| void _d_osx_image_init() | ||
| { | ||
| _dyld_register_func_for_add_image( &on_add_image ); | ||
| _dyld_register_func_for_remove_image( &on_remove_image ); | ||
| } | ||
| #else | ||
| static void on_add_image( const struct mach_header* h, intptr_t slide ) | ||
| { | ||
| int i; | ||
|
|
||
| for( i = 0; i < NUM_DATA_SEGS; ++i ) | ||
| { | ||
| const struct section* sect = getsectbynamefromheader( h, | ||
| data_segs[i].seg, | ||
| data_segs[i].sect ); | ||
| if( sect == NULL || sect->size == 0 ) | ||
| continue; | ||
| gc_addRange( (void*) sect->addr + slide, sect->size ); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| static void on_remove_image( const struct mach_header* h, intptr_t slide ) | ||
| { | ||
| int i; | ||
|
|
||
| for( i = 0; i < NUM_DATA_SEGS; ++i ) | ||
| { | ||
| const struct section* sect = getsectbynamefromheader( h, | ||
| data_segs[i].seg, | ||
| data_segs[i].sect ); | ||
| if( sect == NULL || sect->size == 0 ) | ||
| continue; | ||
| gc_removeRange( (void*) sect->addr + slide ); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| void _d_osx_image_init() | ||
| { | ||
| _dyld_register_func_for_add_image( &on_add_image ); | ||
| _dyld_register_func_for_remove_image( &on_remove_image ); | ||
| } | ||
| #endif | ||
|
|
||
| #endif |
0f0dcdeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think your local repository is out of sync.. sean moved this .c file to be a .d file a couple days ago. You just revived it but the make files still point at the .d version.