noporpoise / sort_r

Portable qsort_r / qsort_s

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nallow _SORT_R_BSD condition

obache opened this issue · comments

In this context, _SORT_R_BSD means qsort_r from FreeBSD,
so it must be defined only for FreeBSD, its forks (DragonFly) and having userland from it (MacOS X).

Could you submit a pull request? Thanks.

My memory may not be clean for public domain, sorry.

I've pushed a commit, thanks for pointing out the issue. I'll close this issue now but feel free to re-open if the code isn't quite right.

Fwiw, since this commit, sort_r (used in https://github.com/pgpointcloud/pointcloud) doesn't build on OpenBSD - ok we don't have sort_r() so we don't need to define _SORT_R_BSD, and we fallback to build sort_r_simple(), but it fails to build as _SORT_R_INLINE isn't defined.

Since the latter is 'inline' everywhere but on windows, the following inline (..) patch fixes it for me:

+#  define _SORT_R_INLINE inline
 #if (defined __APPLE__ || defined __MACH__ || defined __DARWIN__ || \
      defined __FreeBSD__ || defined __DragonFly__)
 #  define _SORT_R_BSD
-#  define _SORT_R_INLINE inline
 #elif (defined _GNU_SOURCE || defined __gnu_hurd__ || defined __GNU__ || \
        defined __linux__ || (defined __MINGW32__ && !defined __MINGW64_VERSION_MAJOR) || defined __GLIBC__)
 #  define _SORT_R_LINUX
-#  define _SORT_R_INLINE inline
 #elif (defined _WIN32 || defined _WIN64 || defined __WINDOWS__)
 #  define _SORT_R_WINDOWS
 #  define _SORT_R_INLINE __inline

If you want a proper PR i can do one.

Thanks @landryb - I've pushed a commit (1eb3da5) to fix the issue. I added an #undef to avoid errors redefining _SORT_R_INLINE on windows. Please let me know if you still have issues.