summaryrefslogtreecommitdiff
path: root/compiler/x86/cgx86.pas
diff options
context:
space:
mode:
authorflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2006-01-03 12:49:29 +0000
committerflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2006-01-03 12:49:29 +0000
commit21a0f67106d753a8f8f7b8c7aead47a11560cbed (patch)
treea51a06a24f75ec4e4eb1412ba085c063860673c8 /compiler/x86/cgx86.pas
parentb896a8b8fe71c5024ab4f59dc3671b9637c87dc3 (diff)
downloadfpc-21a0f67106d753a8f8f7b8c7aead47a11560cbed.tar.gz
* cleaned up segmented thread variables
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@2135 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/x86/cgx86.pas')
-rw-r--r--compiler/x86/cgx86.pas49
1 files changed, 35 insertions, 14 deletions
diff --git a/compiler/x86/cgx86.pas b/compiler/x86/cgx86.pas
index 2d861b11cc..e891c70e02 100644
--- a/compiler/x86/cgx86.pas
+++ b/compiler/x86/cgx86.pas
@@ -766,20 +766,41 @@ unit cgx86;
make_simple_ref(list,tmpref);
list.concat(Taicpu.op_ref_reg(A_LEA,tcgsize2opsize[OS_ADDR],tmpref,r));
end;
- if (segment<>NR_NO) then
- if segment=NR_GS then
- begin
-{$ifdef segment_threadvars}
- {Convert thread local address to a process global addres
- as we cannot handle far pointers.}
- reference_reset_symbol(tmpref,objectlibrary.newasmsymbol(
- '___fpc_threadvar_offset',AB_EXTERNAL,AT_DATA),0);
- tmpref.segment:=NR_GS;
- list.concat(Taicpu.op_ref_reg(A_ADD,tcgsize2opsize[OS_ADDR],tmpref,r));
-{$endif}
- end
- else
- cgmessage(cg_e_cant_use_far_pointer_there);
+ if segment<>NR_NO then
+ begin
+ if (tf_section_threadvars in target_info.flags) then
+ begin
+ { Convert thread local address to a process global addres
+ as we cannot handle far pointers.}
+ case target_info.system of
+ system_i386_linux:
+ if segment=NR_GS then
+ begin
+ reference_reset_symbol(tmpref,objectlibrary.newasmsymbol(
+ '___fpc_threadvar_offset',AB_EXTERNAL,AT_DATA),0);
+ tmpref.segment:=NR_GS;
+ list.concat(Taicpu.op_ref_reg(A_ADD,tcgsize2opsize[OS_ADDR],tmpref,r));
+ end
+ else
+ cgmessage(cg_e_cant_use_far_pointer_there);
+ system_i386_win32:
+ if segment=NR_FS then
+ begin
+ allocallcpuregisters(list);
+ a_call_name(list,'GetTls');
+ deallocallcpuregisters(list);
+ list.concat(Taicpu.op_reg_reg(A_ADD,tcgsize2opsize[OS_ADDR],NR_EAX,r));
+ end
+ else
+ cgmessage(cg_e_cant_use_far_pointer_there);
+
+ else
+ cgmessage(cg_e_cant_use_far_pointer_there);
+ end;
+ end
+ else
+ cgmessage(cg_e_cant_use_far_pointer_there);
+ end;
end;
end;