~n-muench/ubuntu/precise/open-vm-tools/open-vm-tools-precise.sid-merge1

« back to all changes in this revision

Viewing changes to lib/include/vm_basic_asm.h

  • Committer: Evan Broder
  • Date: 2010-03-21 23:26:53 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: broder@mit.edu-20100321232653-5a57r7v7ch4o6byv
Merging shared upstream rev into target branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
#define _VM_BASIC_ASM_H_
43
43
 
44
44
#define INCLUDE_ALLOW_USERLEVEL
45
 
#define INCLUDE_ALLOW_VMMEXT
 
45
 
46
46
#define INCLUDE_ALLOW_MODULE
47
47
#define INCLUDE_ALLOW_VMMON
48
48
#define INCLUDE_ALLOW_VMK_MODULE
110
110
 * compilers (13.01.2035 for _BitScanForward).
111
111
 */
112
112
unsigned char  _BitScanForward(unsigned long*, unsigned long);
 
113
unsigned char  _BitScanReverse(unsigned long*, unsigned long);
113
114
void           _mm_pause(void);
114
 
#pragma intrinsic(_BitScanForward, _mm_pause)
 
115
#pragma intrinsic(_BitScanForward, _BitScanReverse, _mm_pause)
115
116
#endif /* VM_X86_64 */
116
117
 
117
118
#ifdef __cplusplus
219
220
   __asm pop eax \
220
221
   __asm mov _eip, eax \
221
222
} while (0)
222
 
#endif
 
223
#endif // VM_X86_64
223
224
 
224
 
#else // }
225
 
#error 
226
 
#endif
 
225
#else // } {
 
226
#error
 
227
#endif // }
227
228
 
228
229
/* Sequence recommended by Intel for the Pentium 4. */
229
230
#define INTEL_MICROCODE_VERSION() (             \
247
248
#endif
248
249
   return idx+1;
249
250
}
 
251
 
 
252
static INLINE int
 
253
fls(uint32 bitVector)
 
254
{
 
255
   int idx;
 
256
   if (!bitVector) {
 
257
      return 0;
 
258
   }
 
259
#ifdef VM_X86_64
 
260
   _BitScanReverse((unsigned long*)&idx, (unsigned long)bitVector);
 
261
#else
 
262
   __asm bsr eax, bitVector
 
263
   __asm mov idx, eax
 
264
#endif
 
265
   return idx+1;
 
266
}
250
267
#endif
251
268
 
252
269
#ifdef __GNUC__
 
270
#if defined(__i386__) || defined(__x86_64__)
 
271
 
253
272
static INLINE void *
254
273
uint16set(void *dst, uint16 val, size_t count)
255
274
{
284
303
   return dst;
285
304
}
286
305
 
 
306
#else /* unknown system: rely on C to write */
 
307
static INLINE void *
 
308
uint16set(void *dst, uint16 val, size_t count)
 
309
{
 
310
   size_t i;
 
311
   for (i = 0; i < count; i++) {
 
312
     ((uint16 *) dst)[i] = val;
 
313
   }
 
314
   return dst;
 
315
}
 
316
 
 
317
static INLINE void *
 
318
uint32set(void *dst, uint32 val, size_t count)
 
319
{
 
320
   size_t i;
 
321
   for (i = 0; i < count; i++) {
 
322
     ((uint32 *) dst)[i] = val;
 
323
   }
 
324
   return dst;
 
325
}
 
326
#endif // defined(__i386__) || defined(__x86_64__)
287
327
#elif defined(_MSC_VER)
288
328
 
289
329
static INLINE void *
340
380
static INLINE uint32
341
381
Bswap32(uint32 v) // IN
342
382
{
343
 
#ifdef __GNUC__ // {
 
383
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) // {
344
384
   /* Checked against the Intel manual and GCC. --hpreg */
345
385
   __asm__(
346
386
      "bswap %0"
375
415
}
376
416
 
377
417
 
 
418
#if defined(__i386__) || defined(__x86_64__)
378
419
#ifdef __GNUC__ // {
379
420
/*
380
421
 * COMPILER_MEM_BARRIER prevents the compiler from re-ordering memory
477
518
#else
478
519
#define DEBUGBREAK()   __asm__ (" int $3 ")
479
520
#endif
 
521
#endif // defined(__i386__) || defined(__x86_64__)
480
522
 
481
 
#endif
 
523
#endif // _VM_BASIC_ASM_H_