XenevaOS
Loading...
Searching...
No Matches
sort.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _LINUX_SORT_H
3#define _LINUX_SORT_H
4
5#include <linux/types.h>
6
15#define cmp_int(l, r) (((l) > (r)) - ((l) < (r)))
16
17void sort_r(void *base, size_t num, size_t size,
18 cmp_r_func_t cmp_func,
19 swap_r_func_t swap_func,
20 const void *priv);
21
22void sort(void *base, size_t num, size_t size,
23 cmp_func_t cmp_func,
24 swap_func_t swap_func);
25
26/* Versions that periodically call cond_resched(): */
27
28void sort_r_nonatomic(void *base, size_t num, size_t size,
29 cmp_r_func_t cmp_func,
30 swap_r_func_t swap_func,
31 const void *priv);
32
33void sort_nonatomic(void *base, size_t num, size_t size,
34 cmp_func_t cmp_func,
35 swap_func_t swap_func);
36
37/*
38 * DCL delta -- retire <linux/minmax.h>'s swap() macro for this unit.
39 *
40 * Vendored lib/sort.c keeps a swap function pointer in a member named `swap`
41 * and calls it as `->swap(a, b, (int)size)` (sort.c:140). The preprocessor
42 * cannot tell a member call from an ordinary one, so minmax.h's two-argument
43 * swap(a, b) swallows that call and the build stops with "too many arguments
44 * provided to function-like macro invocation". mainline never meets this:
45 * its lib/sort.c opens with <linux/types.h>, <linux/export.h> and this
46 * header, and none of the three carries minmax.h. DCL's <linux/types.h> is
47 * a re-export of <linux/kernel.h> (types.h:49) and kernel.h:105 includes
48 * minmax.h, so every unit in the tree sees the macro.
49 *
50 * This header is where the retirement goes because it is the one header in
51 * that unit's include list that nothing else includes *for* the macro: the
52 * other two consumers of <linux/sort.h> (dma-fence-unwrap.c, drm_blend.c)
53 * call sort()/sort_r() with no swap function and never name swap() at all,
54 * while drm_crtc.c:688 and vkms_formats.c:267/:867-869 -- the calls the
55 * macro exists for -- do not include this header. Nothing in the tree today
56 * includes <linux/sort.h> and calls swap(); if one ever does, the failure is
57 * a compile error at the call, not a silent wrong expansion.
58 *
59 * The delta stays one block at the end so a re-port against a later kernel
60 * reads as upstream's file plus this.
61 */
62#undef swap
63
64#endif
void(* swap_func_t)(void *a, void *b, int size)
Definition types.h:90
int(* cmp_r_func_t)(const void *a, const void *b, const void *priv)
Definition types.h:91
int(* cmp_func_t)(const void *a, const void *b)
Definition types.h:92
void(* swap_r_func_t)(void *a, void *b, int size, const void *priv)
Definition types.h:89
size_t size
Definition drm_bridge.h:1299
struct i915_user_extension base
Definition i915_drm.h:0
void sort_r(void *base, size_t num, size_t size, cmp_r_func_t cmp_func, swap_r_func_t swap_func, const void *priv)
void sort_r_nonatomic(void *base, size_t num, size_t size, cmp_r_func_t cmp_func, swap_r_func_t swap_func, const void *priv)
void sort_nonatomic(void *base, size_t num, size_t size, cmp_func_t cmp_func, swap_func_t swap_func)
void sort(void *base, size_t num, size_t size, cmp_func_t cmp_func, swap_func_t swap_func)