It probably would be better to modify the Linux 2.6.30 version to have something like the following:

```
#ifdef HAVE_KUIDGID_T
int cmp = __kgid_val(grp) - __kgid_val(GROUP_AT(group_info, mid));
#else
int cmp = grp - GROUP_AT(group_info, mid);
#endif
```

That would avoid code duplication and should work thanks to your include/sys/uidgid.h header.