Run regressiontests from build
[gromacs.git] / include / gmx_sort.h
blob64e1b90191a4719987d81642a1d1d6d622f81aa9
1 /*
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.
37 #ifndef _GMX_SORT_H_
38 #define _GMX_SORT_H_
40 #include "visibility.h"
42 /** @file gmx_sort.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.
52 #include <stdlib.h>
54 #ifdef __cplusplus
55 extern "C"
57 #endif
58 #if 0
59 } /* fixes auto-indentation problems */
60 #endif
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.
73 GMX_LIBGMX_EXPORT
74 void
75 gmx_qsort(void * base,
76 size_t nmemb,
77 size_t size,
78 int (*compar)(const void *, const void *));
81 #ifdef GMX_THREAD_MPI
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
87 #else
88 /* System qsort might be faster than our own */
89 #define qsort_threadsafe qsort
90 #endif
93 #ifdef __cplusplus
95 #endif
98 #endif /* _GMX_SORT_H_ */