Mercurial > libavcodec.hg
comparison ppc/check_altivec.c @ 12473:06abedae2906 libavcodec
Merge has_altivec() function into mm_support(), remove it and use
mm_support() instead.
Reduce complexity and simplify pending move to libavutil.
author | stefano |
---|---|
date | Wed, 08 Sep 2010 10:02:40 +0000 |
parents | fdafbcef52f5 |
children |
comparison
equal
deleted
inserted
replaced
12472:9c9be94124f8 | 12473:06abedae2906 |
---|---|
41 /** | 41 /** |
42 * This function MAY rely on signal() or fork() in order to make sure AltiVec | 42 * This function MAY rely on signal() or fork() in order to make sure AltiVec |
43 * is present. | 43 * is present. |
44 */ | 44 */ |
45 | 45 |
46 int has_altivec(void) | 46 int mm_support(void) |
47 { | 47 { |
48 #if HAVE_ALTIVEC | |
48 #ifdef __AMIGAOS4__ | 49 #ifdef __AMIGAOS4__ |
49 ULONG result = 0; | 50 ULONG result = 0; |
50 extern struct ExecIFace *IExec; | 51 extern struct ExecIFace *IExec; |
51 | 52 |
52 IExec->GetCPUInfoTags(GCIT_VectorUnit, &result, TAG_DONE); | 53 IExec->GetCPUInfoTags(GCIT_VectorUnit, &result, TAG_DONE); |
53 if (result == VECTORTYPE_ALTIVEC) return 1; | 54 if (result == VECTORTYPE_ALTIVEC) |
55 return AV_CPU_FLAG_ALTIVEC; | |
54 return 0; | 56 return 0; |
55 #elif defined(__APPLE__) || defined(__OpenBSD__) | 57 #elif defined(__APPLE__) || defined(__OpenBSD__) |
56 #ifdef __OpenBSD__ | 58 #ifdef __OpenBSD__ |
57 int sels[2] = {CTL_MACHDEP, CPU_ALTIVEC}; | 59 int sels[2] = {CTL_MACHDEP, CPU_ALTIVEC}; |
58 #else | 60 #else |
62 size_t len = sizeof(has_vu); | 64 size_t len = sizeof(has_vu); |
63 int err; | 65 int err; |
64 | 66 |
65 err = sysctl(sels, 2, &has_vu, &len, NULL, 0); | 67 err = sysctl(sels, 2, &has_vu, &len, NULL, 0); |
66 | 68 |
67 if (err == 0) return has_vu != 0; | 69 if (err == 0) |
70 return has_vu ? AV_CPU_FLAG_ALTIVEC : 0; | |
68 return 0; | 71 return 0; |
69 #elif CONFIG_RUNTIME_CPUDETECT | 72 #elif CONFIG_RUNTIME_CPUDETECT |
70 int proc_ver; | 73 int proc_ver; |
71 // Support of mfspr PVR emulation added in Linux 2.6.17. | 74 // Support of mfspr PVR emulation added in Linux 2.6.17. |
72 __asm__ volatile("mfspr %0, 287" : "=r" (proc_ver)); | 75 __asm__ volatile("mfspr %0, 287" : "=r" (proc_ver)); |
74 if (proc_ver & 0x8000 || | 77 if (proc_ver & 0x8000 || |
75 proc_ver == 0x000c || | 78 proc_ver == 0x000c || |
76 proc_ver == 0x0039 || proc_ver == 0x003c || | 79 proc_ver == 0x0039 || proc_ver == 0x003c || |
77 proc_ver == 0x0044 || proc_ver == 0x0045 || | 80 proc_ver == 0x0044 || proc_ver == 0x0045 || |
78 proc_ver == 0x0070) | 81 proc_ver == 0x0070) |
79 return 1; | 82 return AV_CPU_FLAG_ALTIVEC; |
80 return 0; | 83 return 0; |
81 #else | 84 #else |
82 // Since we were compiled for AltiVec, just assume we have it | 85 // Since we were compiled for AltiVec, just assume we have it |
83 // until someone comes up with a proper way (not involving signal hacks). | 86 // until someone comes up with a proper way (not involving signal hacks). |
84 return 1; | 87 return AV_CPU_FLAG_ALTIVEC; |
85 #endif /* __AMIGAOS4__ */ | 88 #endif /* __AMIGAOS4__ */ |
89 #endif /* HAVE_ALTIVEC */ | |
90 return 0; | |
86 } | 91 } |
87 | 92 |