~ubuntu-branches/ubuntu/maverick/blender/maverick

« back to all changes in this revision

Viewing changes to extern/fftw/simd/altivec.c

  • Committer: Bazaar Package Importer
  • Author(s): Khashayar Naderehvandi, Khashayar Naderehvandi, Alessio Treglia
  • Date: 2009-01-22 16:53:59 UTC
  • mfrom: (14.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090122165359-v0996tn7fbit64ni
Tags: 2.48a+dfsg-1ubuntu1
[ Khashayar Naderehvandi ]
* Merge from debian experimental (LP: #320045), Ubuntu remaining changes:
  - Add patch correcting header file locations.
  - Add libvorbis-dev and libgsm1-dev to Build-Depends.
  - Use avcodec_decode_audio2() in source/blender/src/hddaudio.c

[ Alessio Treglia ]
* Add missing previous changelog entries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2003, 2006 Matteo Frigo
 
3
 * Copyright (c) 2003, 2006 Massachusetts Institute of Technology
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or modify
 
6
 * it under the terms of the GNU General Public License as published by
 
7
 * the Free Software Foundation; either version 2 of the License, or
 
8
 * (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 *
 
19
 */
 
20
 
 
21
/* $Id: altivec.c,v 1.14 2006-01-05 03:04:27 stevenj Exp $ */
 
22
 
 
23
#include "ifftw.h"
 
24
#include "simd.h"
 
25
 
 
26
#if HAVE_ALTIVEC
 
27
 
 
28
#if HAVE_SYS_SYSCTL_H
 
29
#include <sys/sysctl.h>
 
30
#endif
 
31
 
 
32
#if HAVE_SYS_SYSCTL_H && HAVE_SYSCTL && defined(CTL_HW) && defined(HW_VECTORUNIT)
 
33
/* code for darwin */
 
34
static int really_have_altivec(void)
 
35
{
 
36
     int mib[2], altivecp;
 
37
     size_t len;
 
38
     mib[0] = CTL_HW;
 
39
     mib[1] = HW_VECTORUNIT;
 
40
     len = sizeof(altivecp);
 
41
     sysctl(mib, 2, &altivecp, &len, NULL, 0);
 
42
     return altivecp;
 
43
 
44
#else /* HAVE_SYS_SYSCTL_H etc. */
 
45
 
 
46
#include <signal.h>
 
47
#include <setjmp.h>
 
48
 
 
49
static jmp_buf jb;
 
50
 
 
51
static void sighandler(int x)
 
52
{
 
53
     longjmp(jb, 1);
 
54
}
 
55
 
 
56
static int really_have_altivec(void)
 
57
{
 
58
     void (*oldsig)(int);
 
59
     oldsig = signal(SIGILL, sighandler);
 
60
     if (setjmp(jb)) {
 
61
          signal(SIGILL, oldsig);
 
62
          return 0;
 
63
     } else {
 
64
          __asm__ __volatile__ (".long 0x10000484"); /* vor 0,0,0 */
 
65
          signal(SIGILL, oldsig);
 
66
          return 1;
 
67
     }
 
68
     return 0;
 
69
}
 
70
#endif
 
71
 
 
72
int RIGHT_CPU(void)
 
73
{
 
74
     static int init = 0, res;
 
75
     if (!init) {
 
76
          res = really_have_altivec();
 
77
          init = 1;
 
78
     }
 
79
     return res;
 
80
}
 
81
#endif