add new tc-has-openmp helper func #320215 by Samuli Suominen
authorMike Frysinger <vapier@gentoo.org>
Sun, 23 May 2010 02:00:17 +0000 (02:00 +0000)
committerMike Frysinger <vapier@gentoo.org>
Sun, 23 May 2010 02:00:17 +0000 (02:00 +0000)
eclass/toolchain-funcs.eclass

index 8811c8b64ef893c810e4cfbe7218f310b7ea6d8f..11683ad752cddddcd0d67e465bc29bc56d1ddae9 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2007 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.99 2010/04/22 18:28:11 armin76 Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-funcs.eclass,v 1.100 2010/05/23 02:00:17 vapier Exp $
 
 # @ECLASS: toolchain-funcs.eclass
 # @MAINTAINER:
@@ -191,6 +191,30 @@ tc-is-static-only() {
        return $([[ ${host} == *-mint* ]])
 }
 
+# @FUNCTION: tc-has-openmp
+# @USAGE: [toolchain prefix]
+# @DESCRIPTION:
+# See if the toolchain supports OpenMP.
+tc-has-openmp() {
+       local base="${T}/test-tc-openmp"
+       cat <<-EOF > "${base}.c"
+       #include <omp.h>
+       int main() {
+               int nthreads, tid, ret = 0;
+               #pragma omp parallel private(nthreads, tid)
+               {
+               tid = omp_get_thread_num();
+               nthreads = omp_get_num_threads(); ret += tid + nthreads;
+               }
+               return ret;
+       }
+       EOF
+       $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" >&/dev/null
+       local ret=$?
+       rm -f "${base}"*
+       return ${ret}
+}
+
 # @FUNCTION: tc-has-tls
 # @USAGE: [-s|-c|-l] [toolchain prefix]
 # @DESCRIPTION: