This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 9891 for ps


Ignore:
Timestamp:
07/21/11 03:44:29 (13 years ago)
Author:
ben
Message:

Replaces architecture-dependent cpuid function with inline GCC assembly. Should fix #670 by eliminating nasm dependency.

Location:
ps/trunk/source/lib/sysdep/arch
Files:
6 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/source/lib/sysdep/arch/ia32/ia32.cpp

    r9871 r9891  
    1 /* Copyright (c) 2010 Wildfire Games
     1/* Copyright (c) 2011 Wildfire Games
    22 *
    33 * Permission is hereby granted, free of charge, to any person obtaining
     
    2929#include "lib/sysdep/cpu.h"
    3030#include "lib/sysdep/arch/ia32/ia32.h"
    31 #include "lib/sysdep/arch/ia32/ia32_asm.h"
    3231
    3332#if MSC_VERSION
  • ps/trunk/source/lib/sysdep/arch/x86_x64/x86_x64.cpp

    r9886 r9891  
    1 /* Copyright (c) 2010 Wildfire Games
     1/* Copyright (c) 2011 Wildfire Games
    22 *
    33 * Permission is hereby granted, free of charge, to any person obtaining
     
    4545#endif
    4646
    47 #define HAVE_CPUIDEX 0
    48 #if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 150030729    // __cpuidex available on VC10+ and VC9 SP1 (allows setting ecx beforehand)
    49 # undef HAVE_CPUIDEX
    50 # define HAVE_CPUIDEX 1
     47#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 150030729
     48// VC10+ and VC9 SP1: __cpuidex is already available
     49#elif GCC_VERSION
     50# define __cpuidex(regsArray, level, index)\
     51    __asm__ __volatile__ ("cpuid"\
     52    : "=a" ((regsArray)[0]), "=b" ((regsArray)[1]), "=c" ((regsArray)[2]), "=d" ((regsArray)[3])\
     53    : "0" (level), "2" (index));
    5154#else
    52 # if ARCH_AMD64
    53 #  include "lib/sysdep/arch/amd64/amd64_asm.h"
    54 # else
    55 #  include "lib/sysdep/arch/ia32/ia32_asm.h"
    56 # endif
     55# error "compiler not supported"
    5756#endif
    5857
     
    7372static void cpuid(x86_x64_CpuidRegs* regs)
    7473{
    75 #if HAVE_CPUIDEX
    7674    cassert(sizeof(regs->eax) == sizeof(int));
    7775    cassert(sizeof(*regs) == 4*sizeof(int));
    7876    __cpuidex((int*)regs, regs->eax, regs->ecx);
    79 #else
    80 # if ARCH_AMD64
    81     amd64_asm_cpuid(regs);
    82 # else
    83     ia32_asm_cpuid(regs);
    84 # endif
    85 #endif
    8677}
    8778
Note: See TracChangeset for help on using the changeset viewer.