2 * This file is part of the GROMACS molecular simulation package.
4 * This file is part of Gromacs Copyright (c) 1991-2010
5 * David van der Spoel, Erik Lindahl, Berk Hess, University of Groningen.
6 * Copyright (c) 2012, by the GROMACS development team, led by
7 * David van der Spoel, Berk Hess, Erik Lindahl, and including many
8 * others, as listed in the AUTHORS file in the top-level source
9 * directory and at http://www.gromacs.org.
11 * GROMACS is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * GROMACS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with GROMACS; if not, see
23 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * If you want to redistribute modifications to GROMACS, please
27 * consider that scientific software is very special. Version
28 * control is crucial - bugs must be traceable. We will be happy to
29 * consider code for inclusion in the official distribution, but
30 * derived work must not be called official GROMACS. Details are found
31 * in the README & COPYING files - if they are missing, get the
32 * official version at http://www.gromacs.org.
34 * To help us fund GROMACS development, we humbly ask that you cite
35 * the research papers on the package. Check out http://www.gromacs.org.
40 #include "visibility.h"
44 * @brief Portable implementation of thread-safe sort routines.
47 * This module provides a Gromacs version of the qsort() routine defined.
48 * It is not highly optimized, but it is thread safe, i.e. multiple threads
49 * can simultaneously call gmx_qsort with different data.
59 } /* fixes auto-indentation problems */
64 * @param base Pointer to first element in list to sort
65 * @param nmemb Number of elements in list
66 * @param size Size in bytes of each element
67 * @param compar Comparison function that takes two pointers to elements
68 * being compared as arguments. The function should return an
69 * integer less than, equal to, or greater than zero if the
70 * first argument is considered to be respectively less than,
71 * equal to, or greater than the second.
75 gmx_qsort(void * base
,
78 int (*compar
)(const void *, const void *));
82 /* Some implementations of qsort are not threadsafe.
83 * For instance qsort in glibc contains a bug which makes it non-threadsafe:
84 * http://sources.redhat.com/bugzilla/show_bug.cgi?id=11655
86 #define qsort_threadsafe gmx_qsort
88 /* System qsort might be faster than our own */
89 #define qsort_threadsafe qsort
98 #endif /* _GMX_SORT_H_ */