~steve-sk2/mingw-w64/oneiric

« back to all changes in this revision

Viewing changes to mingw-w64-crt/intrincs/ilockexch64.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen Kitt
  • Date: 2010-11-18 00:04:46 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20101118000446-xe24b423su55onyl
Tags: 1.0+20101003-1
* New maintainer. (Closes: #594371.)
* New upstream snapshot:
  - Includes getopt.h. (Closes: #569914.)
* Build g++ for Win64. (Closes: #600451.)
* Standards-Version 3.9.1 (new packaging).
* Include patch from
  http://mingw-w64.svn.sourceforge.net/viewvc/mingw-w64?view=revision&revision=3715
  as suggested by Rafaël Carré.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include <intrin.h>
2
2
 
 
3
#ifdef _WIN64
3
4
__int64 _InterlockedExchange64(__int64 volatile *Target, __int64 Value)
4
5
{
5
6
  __asm__ __volatile("lock ; xchgq %0,%1"
8
9
    : "memory");
9
10
  return Value;
10
11
}
 
12
#else
 
13
__int64 __stdcall InterlockedCompareExchange64(__int64 volatile *Destination,
 
14
  __int64 Exchange, __int64 Comperand);
 
15
__int64 _InterlockedExchange64(__int64 volatile *Target,__int64 Value);
 
16
__int64 _InterlockedExchange64(__int64 volatile *Target,__int64 Value)
 
17
{
 
18
  __int64 Old;
 
19
  do {
 
20
    Old = *Target;
 
21
  } while(InterlockedCompareExchange64(Target,Value,Old)!=Old);
 
22
  return Old;
 
23
}
 
24
#endif
11
25
 
 
26
#ifdef _WIN64
12
27
__int64 InterlockedExchange64(__int64 volatile *, __int64) __attribute__((alias("_InterlockedExchange64")));
 
28
#else
 
29
__int64 __stdcall InterlockedExchange64(__int64 volatile *Target, __int64 Value)
 
30
{
 
31
  return _InterlockedExchange64(Target, Value);
 
32
}
 
33
#endif
13
34