[OpenAFS-devel] conflicting macro definitions with linux 2.4.9

Deke Clinger Deke Clinger <dclinger@qualcomm.com>
Fri, 17 Aug 2001 21:56:39 -0700 (PDT)


Greetings,

I apologize in advance if this has already been discussed here. I'm building
openafs 1.1.1 on top of the brand new Linux 2.4.9 kernel. The new kernel is in
/usr/src/linux-2.4.9 and openafs is in /usr/local/src/openafs-1.1.1. I ran:

./configure --with-afs-sysname=i386_linux24 \
--with-linux-kernel-headers=/usr/src/linux-2.4.9


My first build attempt failed with an error like this:

../afs/afs_server.c:1007:51: macro "min" requires 3 arguments, but only 2 given
../afs/afs_server.c:1009:50: macro "min" requires 3 arguments, but only 2 given
../afs/afs_server.c:1012:48: macro "min" requires 3 arguments, but only 2 given
../afs/afs_server.c: In function `afsi_SetServerIPRank':
../afs/afs_server.c:1007: `min' undeclared (first use in this function)
../afs/afs_server.c:1007: (Each undeclared identifier is reported only once
../afs/afs_server.c:1007: for each function it appears in.)
make[4]: *** [afs_server.o] Error 1
make[4]: Leaving directory
`/usr/local/src/openafs-1.1.1/src/libafs/MODLOAD-2.4.9-SP'
make[3]: *** [linux_compdirs] Error 2
make[3]: Leaving directory `/usr/local/src/openafs-1.1.1/src/libafs'
make[2]: *** [libafs] Error 2
make[2]: Leaving directory `/usr/local/src/openafs-1.1.1'
make[1]: *** [install] Error 2
make[1]: Leaving directory `/usr/local/src/openafs-1.1.1'
make: *** [all] Error 2

It seems this is happening because the new kernel #defines min thusly:


#define min(type,x,y) \
        ({ type __x = (x), __y = (y); __x < __y ? __x: __y; })


in /usr/src/linux-2.4.9/include/linux/kernel.h But openafs uses only two
arguments. Changing afs_server.c:

975c975
< #ifndef min
---
> /* #ifndef min */
977c977
< #endif 
---
> /* #endif */

gets the build going again until this error:


rxkad_common.c:457:58: macro "max" requires 3 arguments, but only 2
given../afs/rxkad_common.c: In function `rxkad_PreparePacket':
../afs/rxkad_common.c:456: `max' undeclared (first use in this function)
../afs/rxkad_common.c:456: (Each undeclared identifier is reported only once
../afs/rxkad_common.c:456: for each function it appears in.)
make[4]: *** [rxkad_common.o] Error 1
make[4]: Leaving directory

which was fixed by:

62c62
< #ifndef max
---
> /* #ifndef max */
64c64
< #endif /* max */
---
> /* #endif */

on all 3 copies of rxkad_common.c. The same kernel file as above defines max as:

#define max(type,x,y) \
        ({ type __x = (x), __y = (y); __x > __y ? __x: __y; })


After that everything built okay.

The changes above are not a thing of beauty, but I didn't want to put a lot of
effort into a patch since I'm not sure how you'll want to deal with this -
maybe changing the name of the min and max macros used in the openafs build.

I hope this is helpful. If you're interested, we're building a new Linux image
for deployment here with OpenAFS clients talking to our existing AFS cell.


Regards,

Deke Clinger
dkc@qualcomm.com