[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 0/4] Use AF_ALG in checksum utilities

From: Bruno Haible
Subject: Re: [PATCH 0/4] Use AF_ALG in checksum utilities
Date: Tue, 24 Apr 2018 15:28:51 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-119-generic; KDE/5.18.0; x86_64; ; )

Hi Matteo,

> >   * As you already noticed, we need to avoid build failures and runtime 
> > failures
> >     on platforms where this is not supported.
> >
> I see "#ifdef __linux__" already in use in gnulibs, I assume this is
> the preferred way.

Not really. When being compiled on an older Linux machine, that does not have 
necessary include files, this "#ifdef __linux__" would lead to a compilation 

Therefore the preferred way is to test for the essential header files. For 
suppose AF_ALG gets defined by <linux/foobar.h> and is present in every version 
<linux/foobar.h> (even the oldest ones). Then in the Autoconf macro we would 


and in the code we would have


> >   * In the module description, section 'Include', you should not list all 
> > include
> >     files but only those that the user is supposed to include. In this case,
> >     I think, the af_alg business is invisible to the caller of the 4 
> > modules.
> >
> How to conditionally add files to lib_SOURCES depending on the system?
> I guess that such code snippet is pasted somewhere in the Makefile, so
> something like should work:
>     lib_SOURCES += sha1.c
>     UNAME_S := $(shell uname -s)
>     ifeq ($(UNAME_S),Linux)
>         lib_SOURCES += af_alg.c
>     endif
> or do you have a better solution?

This "solution" would not work when cross-compiling from Linux to non-Linux
platforms or vice versa.

It is better to rely only on the preprocessor defines, such as 

It is perfectly OK to have a compilation unit that looks like this:

  #include <config.h>

  #include <unistd.h>  /* or other general include files */


  # include <linux/foobar.h>

  ... Here comes the actual code ...


In the worst case, this generates a .o file without any function definition.
This is OK. (It generates a warning on AIX, IIRC, but that warning can be


reply via email to

[Prev in Thread] Current Thread [Next in Thread]