+ get_threadvar_record() to get a recorddef representing a threadvar (index

and data in case of single threaded)

git-svn-id: trunk@31643 -
This commit is contained in:
Jonas Maebe 2015-09-12 23:33:07 +00:00
parent 4da34a6046
commit 83ae160057
2 changed files with 32 additions and 2 deletions

View File

@ -658,7 +658,8 @@ type
itp_rtti_ord_64bit,
itp_rtti_normal_array,
itp_rtti_dyn_array,
itp_rtti_proc_param
itp_rtti_proc_param,
itp_threadvar_record
);
{ The order is from low priority to high priority,
@ -779,7 +780,8 @@ inherited_objectoptions : tobjectoptions = [oo_has_virtual,oo_has_private,oo_has
'$rtti_ord_64bit$',
'$rtti_normal_array$',
'$rtti_dyn_array$',
'$rtti_proc_param$'
'$rtti_proc_param$',
'$threadvar_record$'
);

View File

@ -1137,6 +1137,8 @@ interface
function getansistringdef:tstringdef;
function getparaencoding(def:tdef):tstringencoding; inline;
function get_threadvar_record(def: tdef; out index_field, non_mt_data_field: tsym): trecorddef;
implementation
uses
@ -1211,6 +1213,32 @@ implementation
result:=0
end;
function get_threadvar_record(def: tdef; out index_field, non_mt_data_field: tsym): trecorddef;
var
typ: ttypesym;
name: string;
begin
name:=internaltypeprefixName[itp_threadvar_record]+tostr(def.defid);
typ:=try_search_current_module_type(name);
if assigned(typ) then
begin
result:=trecorddef(ttypesym(typ).typedef);
index_field:=tsym(result.symtable.symlist[0]);
non_mt_data_field:=tsym(result.symtable.symlist[1]);
exit;
end;
{ set recordalinmin to sizeof(pint), so the second field gets put at
offset = sizeof(pint) as expected }
result:=crecorddef.create_global_internal(
name,sizeof(pint),sizeof(pint),
init_settings.alignment.maxCrecordalign);
index_field:=result.add_field_by_def('',u32inttype);
non_mt_data_field:=result.add_field_by_def('',def);
{ no need to add alignment padding, we won't create arrays of these }
end;
function make_mangledname(const typeprefix:TSymStr;st:TSymtable;const suffix:TSymStr):TSymStr;
var
s,hs,