Added .gitignore for kernel generation
[gromacs.git] / include / gmx_sort.h
blobda7408caa7131f1732dde89ee45a29822ee10c85
1 /* -*- mode: c; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; c-file-style: "stroustrup"; -*-
3 *
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
15 * And Hey:
16 * Gnomes, ROck Monsters And Chili Sauce
18 #ifndef _GMX_SORT_H_
19 #define _GMX_SORT_H_
21 #include "visibility.h"
23 /** @file gmx_sort.h
25 * @brief Portable implementation of thread-safe sort routines.
28 * This module provides a Gromacs version of the qsort() routine defined.
29 * It is not highly optimized, but it is thread safe, i.e. multiple threads
30 * can simultaneously call gmx_qsort with different data.
33 #include <stdlib.h>
35 #ifdef __cplusplus
36 extern "C"
38 #endif
39 #if 0
40 } /* fixes auto-indentation problems */
41 #endif
45 * @param base Pointer to first element in list to sort
46 * @param nmemb Number of elements in list
47 * @param size Size in bytes of each element
48 * @param compar Comparison function that takes two pointers to elements
49 * being compared as arguments. The function should return an
50 * integer less than, equal to, or greater than zero if the
51 * first argument is considered to be respectively less than,
52 * equal to, or greater than the second.
54 GMX_LIBGMX_EXPORT
55 void
56 gmx_qsort(void * base,
57 size_t nmemb,
58 size_t size,
59 int (*compar)(const void *, const void *));
62 #ifdef GMX_THREAD_MPI
63 /* Some implementations of qsort are not threadsafe.
64 * For instance qsort in glibc contains a bug which makes it non-threadsafe:
65 * http://sources.redhat.com/bugzilla/show_bug.cgi?id=11655
67 #define qsort_threadsafe gmx_qsort
68 #else
69 /* System qsort might be faster than our own */
70 #define qsort_threadsafe qsort
71 #endif
74 #ifdef __cplusplus
76 #endif
79 #endif /* _GMX_SORT_H_ */