0

ibv_modify_qp function has 2 different signatures for different version of the library. Both the libraries install the header files in same location. Below are the 2 versions.

int ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
              int attr_mask);
int ibv_modify_qp(struct ibv_qp *qp, struct ibv_qp_attr *attr,
              enum ibv_qp_attr_mask attr_mask);

In my library, I am passing the pointer of my driver specific function to the ibv_context_ops structure.

/*ibv_context_ops field contains function pointers to driver specific functions*/

static struct ibv_context_ops c4iw_ctx_ops = {
    .modify_qp = c4iw_modify_qp,
    }
int c4iw_modify_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr,
               int attr_mask);

So when the prototype matches I don't see any warning, but when the prototypes differ, warning will be generated. Right now I am using CFLAGS to conditionally compile as shown below.

#ifdef IBV_VER2

int c4iw_modify_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr,
               int attr_mask);

#else

int c4iw_modify_qp(struct ibv_qp *ibqp, struct ibv_qp_attr *attr,
               enum ibv_qp_attr_mask attr_mask);
#endif

Is there anyway I can make use of gnu automake to check for function prototype and substitute function arguments based on the function prototype defined in the library header file.

user207421
  • 305,947
  • 44
  • 307
  • 483
Hari
  • 93
  • 1
  • 3

1 Answers1

2

The function prototypes are virtually the same. There's no real difference between an integer and an enum value passed to a function. So in your case you don't need to do any compiler magic at all. I'll amend the answer if you provide more details of the compiler warning.

Is there anyway I can make use of gnu automake to check for function prototype and substitute function arguments based on the function prototype defined in the library header file.

If you really have different APIs, you can simply create a minimal program that only compiles with one of the versions. Whether the program compiles or not, can be then used as a basis for conditional compilation.

See: http://www.gnu.org/software/autoconf/manual/autoconf.html#Running-the-Compiler

Example: https://svn.apache.org/repos/asf/xerces/c/trunk/configure.ac

Pavel Šimerda
  • 5,783
  • 1
  • 31
  • 31