Skip to content

Commit

Permalink
FEAT: add check_gcc_function_attribute check.
Browse files Browse the repository at this point in the history
  • Loading branch information
cournape committed Jul 6, 2014
1 parent 66c792b commit 4769fe7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
3 changes: 1 addition & 2 deletions numpy/core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ def check_funcs(funcs_name):
moredefs.append((fname2def(f), 1))

for dec, fn in OPTIONAL_FUNCTION_ATTRIBUTES:
if config.check_func(fn, decl='int %s %s(void *);' % (dec, fn),
call=False):
if config.check_gcc_function_attribute(dec, fn):
moredefs.append((fname2def(fn), 1))

for fn in OPTIONAL_VARIABLE_ATTRIBUTES:
Expand Down
17 changes: 17 additions & 0 deletions numpy/distutils/command/autodist.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,20 @@ def check_compiler_gcc4(cmd):
}
"""
return cmd.try_compile(body, None, None)


def check_gcc_function_attribute(cmd, attribute, name):
"""Return True if the given function attribute is supported."""
cmd._check_compiler()
body = """
int %s %s(void*);
int
main()
{
}
""" % (attribute, name)
ret, output = cmd.try_output_compile(body, None, None)
if not ret or len(output) > 0:
return False
return True
6 changes: 5 additions & 1 deletion numpy/distutils/command/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
import distutils
from numpy.distutils.exec_command import exec_command
from numpy.distutils.mingw32ccompiler import generate_manifest
from numpy.distutils.command.autodist import check_inline, check_compiler_gcc4
from numpy.distutils.command.autodist import (check_gcc_function_attribute,
check_inline, check_compiler_gcc4)
from numpy.distutils.compat import get_exception

LANG_EXT['f77'] = '.f'
Expand Down Expand Up @@ -422,6 +423,9 @@ def check_compiler_gcc4(self):
"""Return True if the C compiler is gcc >= 4."""
return check_compiler_gcc4(self)

def check_gcc_function_attribute(self, attribute, name):
return check_gcc_function_attribute(self, attribute, name)

def get_output(self, body, headers=None, include_dirs=None,
libraries=None, library_dirs=None,
lang="c", use_tee=None):
Expand Down

0 comments on commit 4769fe7

Please sign in to comment.