1 /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
4 * This file is part of Gromacs Copyright (c) 1991-2010
5 * David van der Spoel, Erik Lindahl, Berk Hess, University of Groningen.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * To help us fund GROMACS development, we humbly ask that you cite
13 * the research papers on the package. Check out http://www.gromacs.org
16 * Gnomes, ROck Monsters And Chili Sauce
23 * @brief Portable implementation of thread-safe sort routines.
26 * This module provides a Gromacs version of the qsort() routine defined.
27 * It is not highly optimized, but it is thread safe, i.e. multiple threads
28 * can simultaneously call gmx_qsort with different data.
38 } /* fixes auto-indentation problems */
43 * @param base Pointer to first element in list to sort
44 * @param nmemb Number of elements in list
45 * @param size Size in bytes of each element
46 * @param compar Comparison function that takes two pointers to elements
47 * being compared as arguments. The function should return an
48 * integer less than, equal to, or greater than zero if the
49 * first argument is considered to be respectively less than,
50 * equal to, or greater than the second.
53 gmx_qsort(void * base
,
56 int (*compar
)(const void *, const void *));
60 /* Some implementations of qsort are not threadsafe.
61 * For instance qsort in glibc contains a bug which makes it non-threadsafe:
62 * http://sources.redhat.com/bugzilla/show_bug.cgi?id=11655
64 #define qsort_threadsafe gmx_qsort
66 /* System qsort might be faster than our own */
67 #define qsort_threadsafe qsort
76 #endif /* _GMX_SORT_H_ */