~ubuntu-branches/ubuntu/quantal/open-vm-tools/quantal-201207201942

« back to all changes in this revision

Viewing changes to lib/include/vm_atomic.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-03-20 10:19:00 UTC
  • mfrom: (1.1.4 upstream) (2.4.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090320101900-1o604camiubq2de8
Tags: 2009.03.18-154848-2
Correcting patch system depends (Closes: #520493).

Show diffs side-by-side

added added

removed removed

Lines of Context:
196
196
AtomicEpilogue(void)
197
197
{
198
198
#ifdef ATOMIC_USE_FENCE
 
199
#ifdef VMM
 
200
      /* The monitor conditionally patches out the lfence when not needed.*/
 
201
      /* Construct a MonitorPatchTextEntry in the .patchtext section. */
 
202
   asm volatile ("1:\n\t"
 
203
                 "lfence\n\t"
 
204
                 "2:\n\t"
 
205
                 ".pushsection .patchtext\n\t"
 
206
#ifdef VMM32
 
207
                 ".long 1b\n\t"
 
208
                 ".long 0\n\t"
 
209
                 ".long 2b\n\t"
 
210
                 ".long 0\n\t"
 
211
#else 
 
212
                 ".quad 1b\n\t"
 
213
                 ".quad 2b\n\t"
 
214
#endif
 
215
                 ".popsection\n\t" ::: "memory");
 
216
#else
199
217
   if (UNLIKELY(AtomicUseFence)) {
200
218
      asm volatile ("lfence" ::: "memory");
201
219
   }
202
220
#endif
 
221
#endif
203
222
}
204
223
 
205
224
 
1417
1436
#endif
1418
1437
 
1419
1438
 
 
1439
#ifdef VMKERNEL
 
1440
/*
 
1441
 *-----------------------------------------------------------------------------
 
1442
 *
 
1443
 * CMPXCHG1B --
 
1444
 *
 
1445
 *      Compare and exchange a single byte.
 
1446
 *
 
1447
 * Results:
 
1448
 *      The value read from ptr.
 
1449
 *
 
1450
 * Side effects:
 
1451
 *      None
 
1452
 *
 
1453
 *-----------------------------------------------------------------------------
 
1454
 */
 
1455
static INLINE uint8
 
1456
CMPXCHG1B(volatile uint8 *ptr, // IN
 
1457
          uint8 oldVal,        // IN
 
1458
          uint8 newVal)        // IN
 
1459
{
 
1460
   uint8 val;
 
1461
   __asm__ __volatile__("lock; cmpxchgb %b2, %1"
 
1462
                        : "=a" (val),
 
1463
                          "+m" (*ptr)
 
1464
                        : "r" (newVal),
 
1465
                          "0" (oldVal)
 
1466
                        : "cc");
 
1467
   return val;
 
1468
}
 
1469
#endif
 
1470
 
 
1471
 
1420
1472
/*
1421
1473
 * Usage of this helper struct is strictly reserved to the following
1422
1474
 * function. --hpreg