/usr/include/d/ldc/osx_tls.c is in libphobos2-ldc-dev 1:0.17.1-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | /**
* Helpers for determining TLS memory ranges on OS X.
*
* This unfortunately cannot be entirely done in D, as the OS X API uses
* the Apple-specific blocks C extension.
*
* Copyright: David Nadlinger, 2012.
* License: <a href="http://www.boost.org/LICENSE_1_0.txt">Boost License 1.0</a>.
* Authors: David Nadlinger
*/
#ifndef __BLOCKS__
#error "Need a C compiler with Apple Blocks support – not building on OS X?"
#endif
#include <assert.h>
#include <stddef.h>
#include <stdio.h>
/*
* Declarations from dyld_priv.h, available on 10.7+.
*/
enum dyld_tlv_states {
dyld_tlv_state_allocated = 10,
dyld_tlv_state_deallocated = 20
};
typedef struct {
size_t info_size;
void * tlv_addr;
size_t tlv_size;
} dyld_tlv_info;
typedef void (^dyld_tlv_state_change_handler)(enum dyld_tlv_states state, const dyld_tlv_info *info);
extern void dyld_register_tlv_state_change_handler(enum dyld_tlv_states state, dyld_tlv_state_change_handler handler);
extern void dyld_enumerate_tlv_storage(dyld_tlv_state_change_handler handler);
void _d_dyld_getTLSRange(void* arbitraryTLSSymbol, void** start, size_t* size) {
dyld_enumerate_tlv_storage(
^(enum dyld_tlv_states state, const dyld_tlv_info *info) {
assert(state == dyld_tlv_state_allocated);
if (info->tlv_addr <= arbitraryTLSSymbol &&
arbitraryTLSSymbol < (info->tlv_addr + info->tlv_size)
) {
// Found the range.
*start = info->tlv_addr;
*size = info->tlv_size;
}
}
);
}
|