diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-07-15 19:40:55 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-07-24 21:20:13 +0000 |
commit | 092c340a2062fa98b7387fc5fd63578ddae7d0b6 (patch) | |
tree | 98ec96946eeb2ae709cb0528cc6998e21bb9b290 /firmware/test/buflib/test_main2.c | |
parent | 17f7cc92c258bc456a27c3e7c5a19c9409851879 (diff) | |
download | rockbox-092c340a2062fa98b7387fc5fd63578ddae7d0b6.tar.gz rockbox-092c340a2062fa98b7387fc5fd63578ddae7d0b6.zip |
[1/4] Remove SH support and all archos targets
This removes all code specific to SH targets
Change-Id: I7980523785d2596e65c06430f4638eec74a06061
Diffstat (limited to 'firmware/test/buflib/test_main2.c')
-rw-r--r-- | firmware/test/buflib/test_main2.c | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/firmware/test/buflib/test_main2.c b/firmware/test/buflib/test_main2.c deleted file mode 100644 index da6b1366e7..0000000000 --- a/firmware/test/buflib/test_main2.c +++ /dev/null | |||
@@ -1,108 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2011 Thomas Martitz | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include <stdio.h> | ||
22 | #include <stdlib.h> | ||
23 | #include "core_alloc.h" | ||
24 | #include "util.h" | ||
25 | |||
26 | /* | ||
27 | * Expected output (64-bit): | ||
28 | ------------------- | ||
29 | ------------------- | ||
30 | */ | ||
31 | |||
32 | #define error(...) do { printf(__VA_ARGS__); exit(1); } while(0) | ||
33 | static int move_callback(int handle, void* old, void* new) | ||
34 | { | ||
35 | printf("MOVED!\n"); | ||
36 | return BUFLIB_CB_OK; | ||
37 | } | ||
38 | |||
39 | static int shrink_callback(int handle, unsigned hints, void* start, size_t size) | ||
40 | { | ||
41 | char* buf = start; | ||
42 | |||
43 | size_t wanted = hints & BUFLIB_SHRINK_SIZE_MASK; | ||
44 | |||
45 | if (handle == 4) | ||
46 | { | ||
47 | buf+=1, size-=1; | ||
48 | memmove(buf, buf-1, (size < 20) ? size : 20); | ||
49 | core_shrink(handle, buf, size); | ||
50 | return BUFLIB_CB_OK; | ||
51 | } | ||
52 | return BUFLIB_CB_CANNOT_SHRINK; | ||
53 | } | ||
54 | |||
55 | static struct buflib_callbacks ops = { | ||
56 | .move_callback = move_callback, | ||
57 | .shrink_callback = shrink_callback, | ||
58 | }; | ||
59 | |||
60 | static struct buflib_callbacks ops2 = { | ||
61 | .move_callback = NULL, | ||
62 | .shrink_callback = shrink_callback, | ||
63 | }; | ||
64 | |||
65 | int main(void) | ||
66 | { | ||
67 | size_t size2, size4; | ||
68 | UT_core_allocator_init(); | ||
69 | |||
70 | printf("available: %zu\n", core_available()); | ||
71 | int first = core_alloc("first, fixed", 4<<10); | ||
72 | if (first <= 0) error("first failed\n"); | ||
73 | |||
74 | printf("available: %zu\n", core_available()); | ||
75 | int second = core_alloc_maximum("second, var", &size2, &ops); | ||
76 | if (second <= 0) error("second failed\n"); | ||
77 | printf("second size: %zu\n", size2); | ||
78 | |||
79 | strcpy(core_get_data(second), "begin"); | ||
80 | strcpy(core_get_data(second)+124, "end"); | ||
81 | printf("%s\n", core_get_name(second)); | ||
82 | if (!core_shrink(second, core_get_data(second), 128)) | ||
83 | error("shrink second failed\n"); | ||
84 | |||
85 | int third = core_alloc("third, fixed", 20<<10); | ||
86 | if (third <= 0) error("third failed"); | ||
87 | strcpy(core_get_data(third), "third"); | ||
88 | |||
89 | printf("available: %zu\n", core_available()); | ||
90 | int fourth = core_alloc_maximum("fourth", &size4, &ops2); | ||
91 | if (fourth <= 0) error("fourth failed\n"); | ||
92 | core_print_blocks(&print_simple); | ||
93 | if (!core_shrink(fourth, core_get_data(fourth)+(5<<10), size4-(5<<10))) | ||
94 | { | ||
95 | error("shrink fourth failed\n"); | ||
96 | } | ||
97 | sprintf(core_get_data(fourth), "fourth size: %zu", size4); | ||
98 | core_print_blocks(&print_simple); | ||
99 | |||
100 | int fifth = core_alloc("fifth, fixed", 6<<10); | ||
101 | if (fifth <= 0) error("fifth failed\n"); | ||
102 | |||
103 | printf("%s\n", core_get_data(fourth)); | ||
104 | core_print_blocks(&print_simple); | ||
105 | core_print_allocs(&print_simple); | ||
106 | |||
107 | return 0; | ||
108 | } | ||