mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-10-31 13:31:40 +01:00 
			
		
		
		
	Amiga/m68k: software atomic operations implementation for multithreading
git-svn-id: trunk@30901 -
This commit is contained in:
		
							parent
							
								
									e02e742997
								
							
						
					
					
						commit
						89aadb22c2
					
				
							
								
								
									
										1
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							| @ -8046,6 +8046,7 @@ rtl/amiga/doslibd.inc svneol=native#text/plain | |||||||
| rtl/amiga/m68k/doslibf.inc svneol=native#text/plain | rtl/amiga/m68k/doslibf.inc svneol=native#text/plain | ||||||
| rtl/amiga/m68k/execd.inc svneol=native#text/plain | rtl/amiga/m68k/execd.inc svneol=native#text/plain | ||||||
| rtl/amiga/m68k/execf.inc svneol=native#text/plain | rtl/amiga/m68k/execf.inc svneol=native#text/plain | ||||||
|  | rtl/amiga/m68k/m68kamiga.inc svneol=native#text/plain | ||||||
| rtl/amiga/m68k/prt0.as svneol=native#text/plain | rtl/amiga/m68k/prt0.as svneol=native#text/plain | ||||||
| rtl/amiga/m68k/utild1.inc svneol=native#text/plain | rtl/amiga/m68k/utild1.inc svneol=native#text/plain | ||||||
| rtl/amiga/m68k/utild2.inc svneol=native#text/plain | rtl/amiga/m68k/utild2.inc svneol=native#text/plain | ||||||
|  | |||||||
							
								
								
									
										66
									
								
								rtl/amiga/m68k/m68kamiga.inc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								rtl/amiga/m68k/m68kamiga.inc
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,66 @@ | |||||||
|  | { | ||||||
|  |     This file is part of the Free Pascal run time library. | ||||||
|  |     Copyright (c) 2015 by Karoly Balogh, | ||||||
|  |     member of the Free Pascal development team. | ||||||
|  | 
 | ||||||
|  |     m68k/Amiga atomic operations implementation | ||||||
|  | 
 | ||||||
|  |     See the file COPYING.FPC, included in this distribution, | ||||||
|  |     for details about the copyright. | ||||||
|  | 
 | ||||||
|  |     This program is distributed in the hope that it will be useful, | ||||||
|  |     but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||||
|  | 
 | ||||||
|  |  **********************************************************************} | ||||||
|  | 
 | ||||||
|  | { The Amiga hardware doesn't support the m68k CPU's atomic operations | ||||||
|  |   like TAS, CAS, CAS2 and so on. Therefore we must "emulate" them from | ||||||
|  |   software. The easiest way is the Forbid()/Permit() OS call pair around | ||||||
|  |   the ops themselves. It of course won't be hardware-atomic, but should | ||||||
|  |   be safe for multithreading. (KB) } | ||||||
|  | 
 | ||||||
|  | function InterLockedDecrement (var Target: longint) : longint; | ||||||
|  |   begin | ||||||
|  |     Forbid(); | ||||||
|  |     Dec(Target); | ||||||
|  |     Result := Target; | ||||||
|  |     Permit(); | ||||||
|  |   end; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | function InterLockedIncrement (var Target: longint) : longint; | ||||||
|  |   begin | ||||||
|  |     Forbid() | ||||||
|  |     Inc(Target); | ||||||
|  |     Result := Target; | ||||||
|  |     Permit(); | ||||||
|  |   end; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | function InterLockedExchange (var Target: longint;Source : longint) : longint; | ||||||
|  |   begin | ||||||
|  |     Forbid(); | ||||||
|  |     Result := Target; | ||||||
|  |     Target := Source; | ||||||
|  |     Permit(); | ||||||
|  |   end; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint; | ||||||
|  |   begin | ||||||
|  |     Forbid(); | ||||||
|  |     Result := Target; | ||||||
|  |     Target := Target + Source; | ||||||
|  |     Permit(); | ||||||
|  |   end; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | function InterlockedCompareExchange(var Target: longint; NewValue: longint; Comperand: longint): longint; | ||||||
|  |   begin | ||||||
|  |     Forbid(); | ||||||
|  |     Result := Target; | ||||||
|  |     if Target = Comperand then | ||||||
|  |       Target := NewValue; | ||||||
|  |     Permit(); | ||||||
|  |   end; | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Károly Balogh
						Károly Balogh