code: def check_math_capabilities(config, ext, moredefs, mathlibs):
      def check_func(
          func_name,
          decl=False,
          headers=[
              "feature_detection_math.h",
              "feature_detection_cmath.h",
          ],
      ):
          return config.check_func(
              func_name,
              libraries=mathlibs,
              decl=decl,
              call=True,
              call_args=FUNC_CALL_ARGS[func_name],
              headers=headers,
          )
  
      def check_funcs_once(
          funcs_name,
          headers=[
              "feature_detection_math.h",
              "feature_detection_cmath.h",
          ],
          add_to_moredefs=True,
      ):
          call = dict([(f, True) for f in funcs_name])
          call_args = dict([(f, FUNC_CALL_ARGS[f]) for f in funcs_name])
          st = config.check_funcs_once(
              funcs_name,
              libraries=mathlibs,
              decl=False,
              call=call,
              call_args=call_args,
              headers=headers,
          )
          if st and add_to_moredefs:
              moredefs.extend([(fname2def(f), 1) for f in funcs_name])
          return st
  
      def check_funcs(
          funcs_name,
          headers=[
              "feature_detection_math.h",
              "feature_detection_cmath.h",
          ],
      ):
          # Use check_funcs_once first, and if it does not work, test func per
          # func. Return success only if all the functions are available
          if not check_funcs_once(funcs_name, headers=headers):
              # Global check failed, check func per func
              for f in funcs_name:
                  if check_func(f, headers=headers):
                      moredefs.append((fname2def(f), 1))
              return 0
          else:
              return 1
  
      # use_msvc = config.check_decl("_MSC_VER")
      if not check_funcs_once(MANDATORY_FUNCS, add_to_moredefs=False):
          raise SystemError(
              "One of the required function to build numpy is not"
              " available (the list is %s)." % str(MANDATORY_FUNCS)
          )
  
      # Standard functions which may not be available and for which we have a
      # replacement implementation. Note that some of these are C99 functions.
  
      # XXX: hack to circumvent cpp pollution from python: python put its
      # config.h in the public namespace, so we have a clash for the common
      # functions we test. We remove every function tested by python's
      # autoconf, hoping their own test are correct
      for f in OPTIONAL_FUNCS_MAYBE:
          if config.check_decl(fname2def(f), headers=["Python.h"]):
              OPTIONAL_FILE_FUNCS.remove(f)
  
      check_funcs(
          OPTIONAL_FILE_FUNCS, headers=["feature_detection_stdio.h"]
      )
      check_funcs(
          OPTIONAL_MISC_FUNCS, headers=["feature_detection_misc.h"]
      )
  
      for h in OPTIONAL_HEADERS:
          if config.check_func("", decl=False, call=False, headers=[h]):
              h = h.replace(".", "_").replace(os.path.sep, "_")
              moredefs.append((fname2def(h), 1))
  
      # Try with both "locale.h" and "xlocale.h"
      locale_headers = [
          "stdlib.h",
          "xlocale.h",
          "feature_detection_locale.h",
      ]
      if not check_funcs(OPTIONAL_LOCALE_FUNCS, headers=locale_headers):
          # It didn't work with xlocale.h, maybe it will work with locale.h?
          locale_headers[1] = "locale.h"
          check_funcs(OPTIONAL_LOCALE_FUNCS, headers=locale_headers)
  
      for tup in OPTIONAL_INTRINSICS:
          headers = None
          if len(tup) == 2:
              f, args, m = tup[0], tup[1], fname2def(tup[0])
          elif len(tup) == 3:
              f, args, headers, m = (
                  tup[0],
                  tup[1],
                  [tup[2]],
                  fname2def(tup[0]),
              )
          else:
              f, args, headers, m = (
                  tup[0],
                  tup[1],
                  [tup[2]],
                  fname2def(tup[3]),
              )
          if config.check_func(
              f, decl=False, call=True, call_args=args, headers=headers
          ):
              moredefs.append((m, 1))
  
      for dec, fn in OPTIONAL_FUNCTION_ATTRIBUTES:
          if config.check_gcc_function_attribute(dec, fn):
              moredefs.append((fname2def(fn), 1))
  
      platform = sysconfig.get_platform()
      for fn in OPTIONAL_VARIABLE_ATTRIBUTES:
          if config.check_gcc_variable_attribute(fn):
              m = fn.replace("(", "_").replace(")", "_")
              moredefs.append((fname2def(m), 1))
  
imports: import os
  import sys
  import sysconfig
  import pickle
  import copy
  import warnings
  import textwrap
  import glob
  from os.path import join
  from numpy.distutils import log
  from numpy.distutils.msvccompiler import lib_opts_if_msvc
  from distutils.dep_util import newer
  from sysconfig import get_config_var
  from numpy.compat import npy_load_module
  from setup_common import *
label_desc: Use image node_id 8 for calling a global function with example usage: check_math_capabilities(config, ext, moredefs, mathlibs) and returns: config, st, int, int