FreeBSD Bugzilla – Attachment 202857 Details for
Bug 236351
games/ponscripter-sekai: fix build on powerpc, powerpc64
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
standalone test
test.cc (text/plain), 3.74 KB, created by
Jan Beich
on 2019-03-14 19:53:54 UTC
(
hide
)
Description:
standalone test
Filename:
MIME Type:
Creator:
Jan Beich
Created:
2019-03-14 19:53:54 UTC
Size:
3.74 KB
patch
obsolete
>#include <sys/types.h> >#include <stdio.h> > >#if defined(__i386__) || defined(__x86_64__) >#define USE_X86_GFX >#elif defined(__powerpc__) >#define USE_PPC_GFX >#endif > >#ifdef __APPLE__ >#define MACOSX >#endif > >#if defined (USE_X86_GFX) && !defined(MACOSX) >#include <cpuid.h> >#endif > >#if defined(USE_PPC_GFX) ># if defined(__linux__) || (defined(__FreeBSD__) && defined(__FreeBSD__) >= 12) ># ifdef __linux__ >#include <asm/cputable.h> ># else >#include <machine/cpu.h> ># endif >#include <sys/auxv.h> ># elif defined(MACOSX) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) ># if defined(__NetBSD__) || defined(__OpenBSD__) >#include <machine/cpu.h> ># endif >#include <sys/sysctl.h> ># endif >#endif > >class AnimationInfo { >public: > enum{ > CPUF_NONE = 0, > CPUF_X86_MMX = 1, > CPUF_X86_SSE = 2, > CPUF_X86_SSE2 = 4, > CPUF_PPC_ALTIVEC = 8 > }; > static void setCpufuncs(unsigned int func); >}; > >static unsigned int cpufuncs; >void AnimationInfo::setCpufuncs(unsigned int func) >{ > cpufuncs = func; >} > >static void test() >{ >#if defined (USE_X86_GFX) && !defined(MACOSX) > // determine what functions the cpu supports (Mion) > { > unsigned int func, eax, ebx, ecx, edx; > func = AnimationInfo::CPUF_NONE; > if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) != 0) { > printf("System info: Intel CPU, with functions: "); > if (edx & bit_MMX) { > func |= AnimationInfo::CPUF_X86_MMX; > printf("MMX "); > } > if (edx & bit_SSE) { > func |= AnimationInfo::CPUF_X86_SSE; > printf("SSE "); > } > if (edx & bit_SSE2) { > func |= AnimationInfo::CPUF_X86_SSE2; > printf("SSE2 "); > } > printf("\n"); > } > AnimationInfo::setCpufuncs(func); > } >#elif defined(USE_PPC_GFX) && (defined(__linux__) || (defined(__FreeBSD__) && defined(__FreeBSD__) >= 12)) > // Determine if this PPC CPU supports AltiVec > { > unsigned int func = AnimationInfo::CPUF_NONE; > unsigned long hwcap = 0; >#ifdef __linux__ > hwcap = getauxval(AT_HWCAP); >#else > elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); >#endif > if (hwcap & PPC_FEATURE_HAS_ALTIVEC) { > func |= AnimationInfo::CPUF_PPC_ALTIVEC; > printf("System info: PowerPC CPU, supports altivec\n"); > } else { > printf("System info: PowerPC CPU, DOES NOT support altivec\n"); > } > AnimationInfo::setCpufuncs(func); > } >#elif defined(USE_PPC_GFX) && (defined(MACOSX) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) > // Determine if this PPC CPU supports AltiVec (Roto) > { > unsigned int func = AnimationInfo::CPUF_NONE; > int altivec_present = 0; > > size_t length = sizeof(altivec_present); >#if defined(MACOSX) > int error = sysctlbyname("hw.optional.altivec", &altivec_present, &length, NULL, 0); >#elif defined(__FreeBSD__) > int error = sysctlbyname("hw.altivec", &altivec_present, &length, NULL, 0); >#else > int mib[] = { CTL_MACHDEP, CPU_ALTIVEC }; > int error = sysctl(mib, sizeof(mib)/sizeof(mib[0]), &altivec_present, &length, NULL, 0); >#endif > if(error) { > AnimationInfo::setCpufuncs(AnimationInfo::CPUF_NONE); > return; > } > if(altivec_present) { > func |= AnimationInfo::CPUF_PPC_ALTIVEC; > printf("System info: PowerPC CPU, supports altivec\n"); > } else { > printf("System info: PowerPC CPU, DOES NOT support altivec\n"); > } > AnimationInfo::setCpufuncs(func); > } >#else > AnimationInfo::setCpufuncs(AnimationInfo::CPUF_NONE); >#endif >} > >int main() >{ > test(); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 236351
:
202679
|
202854
| 202857