]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Application/ShellSortTestApp/ShellSortTestApp.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / ShellPkg / Application / ShellSortTestApp / ShellSortTestApp.c
1 /** @file
2 This is a test application that demonstrates how to use the sorting functions.
3
4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include <Uefi.h>
10 #include <Library/UefiLib.h>
11 #include <Library/DebugLib.h>
12 #include <Library/ShellCEntryLib.h>
13 #include <Library/SortLib.h>
14
15 /**
16 Test comparator.
17
18 @param[in] b1 The first INTN
19 @param[in] b2 The other INTN
20
21 @retval 0 They are the same.
22 @retval -1 b1 is less than b2
23 @retval 1 b1 is greater then b2
24 **/
25 INTN
26 EFIAPI
27 Test (
28 CONST VOID *b1,
29 CONST VOID *b2
30 )
31 {
32 if (*(INTN *)b1 == *(INTN *)b2) {
33 return (0);
34 }
35
36 if (*(INTN *)b1 < *(INTN *)b2) {
37 return (-1);
38 }
39
40 return (1);
41 }
42
43 /**
44 UEFI application entry point which has an interface similar to a
45 standard C main function.
46
47 The ShellCEntryLib library instance wrappers the actual UEFI application
48 entry point and calls this ShellAppMain function.
49
50 @param Argc Argument count
51 @param Argv The parsed arguments
52
53 @retval 0 The application exited normally.
54 @retval Other An error occurred.
55
56 **/
57 INTN
58 EFIAPI
59 ShellAppMain (
60 IN UINTN Argc,
61 IN CHAR16 **Argv
62 )
63 {
64 INTN Array[10];
65
66 Array[0] = 2;
67 Array[1] = 3;
68 Array[2] = 4;
69 Array[3] = 1;
70 Array[4] = 5;
71 Array[5] = 6;
72 Array[6] = 7;
73 Array[7] = 8;
74 Array[8] = 1;
75 Array[9] = 5;
76
77 Print (L"Array = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\r\n", Array[0], Array[1], Array[2], Array[3], Array[4], Array[5], Array[6], Array[7], Array[8], Array[9]);
78 PerformQuickSort (Array, 10, sizeof (INTN), Test);
79 Print (L"POST-SORT\r\n");
80 Print (L"Array = %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\r\n", Array[0], Array[1], Array[2], Array[3], Array[4], Array[5], Array[6], Array[7], Array[8], Array[9]);
81 return 0;
82 }