Blame gl/tests/signature.h

Packit Service 4684c1
/* Macro for checking that a function declaration is compliant.
Packit Service 4684c1
   Copyright (C) 2009-2020 Free Software Foundation, Inc.
Packit Service 4684c1
Packit Service 4684c1
   This program is free software: you can redistribute it and/or modify
Packit Service 4684c1
   it under the terms of the GNU General Public License as published by
Packit Service 4684c1
   the Free Software Foundation; either version 3 of the License, or
Packit Service 4684c1
   (at your option) any later version.
Packit Service 4684c1
Packit Service 4684c1
   This program is distributed in the hope that it will be useful,
Packit Service 4684c1
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 4684c1
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 4684c1
   GNU General Public License for more details.
Packit Service 4684c1
Packit Service 4684c1
   You should have received a copy of the GNU General Public License
Packit Service 4684c1
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
Packit Service 4684c1
Packit Service 4684c1
#ifndef SIGNATURE_CHECK
Packit Service 4684c1
Packit Service 4684c1
/* Check that the function FN takes the specified arguments ARGS with
Packit Service 4684c1
   a return type of RET.  This header is designed to be included after
Packit Service 4684c1
   <config.h> and the one system header that is supposed to contain
Packit Service 4684c1
   the function being checked, but prior to any other system headers
Packit Service 4684c1
   that are necessary for the unit test.  Therefore, this file does
Packit Service 4684c1
   not include any system headers, nor reference anything outside of
Packit Service 4684c1
   the macro arguments.  For an example, if foo.h should provide:
Packit Service 4684c1
Packit Service 4684c1
   extern int foo (char, float);
Packit Service 4684c1
Packit Service 4684c1
   then the unit test named test-foo.c would start out with:
Packit Service 4684c1
Packit Service 4684c1
   #include <config.h>
Packit Service 4684c1
   #include <foo.h>
Packit Service 4684c1
   #include "signature.h"
Packit Service 4684c1
   SIGNATURE_CHECK (foo, int, (char, float));
Packit Service 4684c1
   #include <other.h>
Packit Service 4684c1
   ...
Packit Service 4684c1
*/
Packit Service 4684c1
# define SIGNATURE_CHECK(fn, ret, args) \
Packit Service 4684c1
  SIGNATURE_CHECK1 (fn, ret, args, __LINE__)
Packit Service 4684c1
Packit Service 4684c1
/* Necessary to allow multiple SIGNATURE_CHECK lines in a unit test.
Packit Service 4684c1
   Note that the checks must not occupy the same line.  */
Packit Service 4684c1
# define SIGNATURE_CHECK1(fn, ret, args, id) \
Packit Service 4684c1
  SIGNATURE_CHECK2 (fn, ret, args, id) /* macroexpand line */
Packit Service 4684c1
# define SIGNATURE_CHECK2(fn, ret, args, id) \
Packit Service 4684c1
  static ret (* _GL_UNUSED signature_check ## id) args = fn
Packit Service 4684c1
Packit Service 4684c1
#endif /* SIGNATURE_CHECK */