9fans / plan9port

Plan 9 from User Space
https://9fans.github.io/plan9port/
Other
1.63k stars 321 forks source link

kcmp in cmd/sort.c conflicts with FreeBSD system header file #648

Open VoxSciurorum opened 6 months ago

VoxSciurorum commented 6 months ago

Recent development versions of FreeBSD define a function kcmp in <unistd.h>

     kcmp(pid_t pid1, pid_t pid2, int type, uintptr_t idx1, uintptr_t idx2);

This conflicts with int kcmp(Key *ka, Key *kb) defined in src/cmd/sort.c causing a compilation error.

The kcmp system call also exists on Linux but there is no C library wrapper to conflict. kcmp(2): "Glibc does not provide a wrapper for this system call; call it using syscall(2)."

bakul commented 4 months ago

kcmp was added to /usr/include/unicode.h post FreeBSD-14.0.

As kcmp is local to src/cmd/sort.c , renaming it to keycmp would fix this without impacting anything else.

danfe commented 3 weeks ago

I'll rename it to ${PORTNAME}_kcmp() for the time being to unbreak the FreeBSD port, but admittedly keycmp() looks more descriptive. If it's local to sort.c, perhaps it could be also declared as static?

bakul commented 3 weeks ago

Declaring it static (and no name change) would work.