2 # Copyright (C) 2005 Free Software Foundation, Inc.
3 # Contributed by Richard Henderson <rth@redhat.com>.
5 # This file is part of the GNU OpenMP Library (libgomp).
7 # Libgomp is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU Lesser General Public License as published by
9 # the Free Software Foundation; either version 2.1 of the License, or
10 # (at your option) any later version.
12 # Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
17 # You should have received a copy of the GNU Lesser General Public License
18 # along with libgomp; see the file COPYING.LIB. If not, write to the
19 # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 # As a special exception, if you link this library with other files, some
23 # of which are compiled with GCC, to produce an executable, this library
24 # does not by itself cause the resulting executable to be covered by the
25 # GNU General Public License. This exception does not however invalidate
26 # any other reasons why the executable file might be covered by the GNU
27 # General Public License.
29 # This file fills in the blanks for omp.h.in, computing the size and
30 # alignment of the lock types that we export. We do this to avoid
31 # polluting the namespace with e.g. pthreads declarations.
37 $HEADER = "#include \"omp-lock.h\"\n";
39 # configure might put libtool specific options into $COMPILE.
40 $COMPILE =~ s/ -Wc,/ /g;
42 # Close stderr in order to discard compiler errors. Which we expect apleanty.
45 # Return true if the boolean expression evaluates true at compile-time.
49 open GCC
, "|$COMPILE -fsyntax-only -xc -";
51 print GCC
"char test[($expr) ? 1 : -1];\n";
55 # Return a number guaranteed to be larger than the integer epression.
61 while (compile_test
("($expr) >= $max")) {
68 # Return an exact number for the integer expression.
73 my $high = upper_bound
($expr);
75 while ($low < $high) {
76 my $mid = ($high + $low + 1) / 2;
77 if (compile_test
("($expr) >= $mid")) {
87 # Apply OP to TYPE, where OP is either sizeof or __alignof.
92 return binary_search
("$op($type)");
95 # Find all the constants we need.
96 $sizeof_omp_lock_t = resolve
("sizeof", "omp_lock_t");
97 $alignof_omp_lock_t = resolve
("__alignof", "omp_lock_t");
98 $sizeof_omp_nest_lock_t = resolve
("sizeof", "omp_nest_lock_t");
99 $alignof_omp_nest_lock_t = resolve
("__alignof", "omp_nest_lock_t");
100 $omp_lock_kind = $sizeof_omp_lock_t;
101 $omp_nest_lock_kind = $sizeof_omp_nest_lock_t;
102 if ($sizeof_omp_lock_t >= 8 || $alignof_omp_lock_t > $sizeof_omp_lock_t) {
105 if ($sizeof_omp_nest_lock_t >= 8 || $alignof_omp_nest_lock_t > $sizeof_omp_nest_lock_t) {
106 $omp_nest_lock_kind = 8;
109 # Edit the input template into the output.
110 open IN
, "<", $INFILE;
111 open OUT
, ">", $OUTFILE;
113 s/OMP_LOCK_SIZE/$sizeof_omp_lock_t/o;
114 s/OMP_LOCK_ALIGN/$alignof_omp_lock_t/o;
115 s/OMP_NEST_LOCK_SIZE/$sizeof_omp_nest_lock_t/o;
116 s/OMP_NEST_LOCK_ALIGN/$alignof_omp_nest_lock_t/o;
117 s/OMP_LOCK_KIND/$omp_lock_kind/o;
118 s/OMP_NEST_LOCK_KIND/$omp_nest_lock_kind/o;