···11+/**
22+ * This file is part of Darling.
33+ *
44+ * Copyright (C) 2020 Lubos Dolezel
55+ *
66+ * Darling is free software: you can redistribute it and/or modify
77+ * it under the terms of the GNU General Public License as published by
88+ * the Free Software Foundation, either version 3 of the License, or
99+ * (at your option) any later version.
1010+ *
1111+ * Darling is distributed in the hope that it will be useful,
1212+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+ * GNU General Public License for more details.
1515+ *
1616+ * You should have received a copy of the GNU General Public License
1717+ * along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+ */
1919+2020+#ifndef _CACHE_CACHE_H_
2121+#define _CACHE_CACHE_H_
2222+2323+#ifdef __cplusplus
2424+extern "C" {
2525+#endif
2626+2727+void* cache_create(void);
2828+void* cache_destroy(void);
2929+void* cache_get(void);
3030+void* cache_get_and_retain(void);
3131+void* cache_get_cost_hint(void);
3232+void* cache_get_count_hint(void);
3333+void* cache_get_info(void);
3434+void* cache_get_info_for_key(void);
3535+void* cache_get_info_for_keys(void);
3636+void* cache_get_minimum_values_hint(void);
3737+void* cache_get_name(void);
3838+void* cache_hash_byte_string(void);
3939+void* cache_invoke(void);
4040+void* cache_key_hash_cb_cstring(void);
4141+void* cache_key_hash_cb_integer(void);
4242+void* cache_key_is_equal_cb_cstring(void);
4343+void* cache_key_is_equal_cb_integer(void);
4444+void* cache_print(void);
4545+void* cache_print_stats(void);
4646+void* cache_release_cb_free(void);
4747+void* cache_release_value(void);
4848+void* cache_remove(void);
4949+void* cache_remove_all(void);
5050+void* cache_remove_with_block(void);
5151+void* cache_set_and_retain(void);
5252+void* cache_set_cost_hint(void);
5353+void* cache_set_count_hint(void);
5454+void* cache_set_minimum_values_hint(void);
5555+void* cache_set_name(void);
5656+void* cache_simulate_memory_warning_event(void);
5757+void* cache_value_make_nonpurgeable_cb(void);
5858+void* cache_value_make_purgeable_cb(void);
5959+6060+#ifdef __cplusplus
6161+};
6262+#endif
6363+6464+#endif // _CACHE_CACHE_H_
+221
src/libcache/src/cache.c
···11+/**
22+ * This file is part of Darling.
33+ *
44+ * Copyright (C) 2020 Lubos Dolezel
55+ *
66+ * Darling is free software: you can redistribute it and/or modify
77+ * it under the terms of the GNU General Public License as published by
88+ * the Free Software Foundation, either version 3 of the License, or
99+ * (at your option) any later version.
1010+ *
1111+ * Darling is distributed in the hope that it will be useful,
1212+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+ * GNU General Public License for more details.
1515+ *
1616+ * You should have received a copy of the GNU General Public License
1717+ * along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+ */
1919+2020+#include <cache/cache.h>
2121+#include <stdlib.h>
2222+#include <stdio.h>
2323+2424+static int verbose = 0;
2525+2626+__attribute__((constructor))
2727+static void initme(void) {
2828+ verbose = getenv("STUB_VERBOSE") != NULL;
2929+}
3030+3131+void* cache_create(void)
3232+{
3333+ if (verbose) puts("STUB: cache_create called");
3434+ return NULL;
3535+}
3636+3737+void* cache_destroy(void)
3838+{
3939+ if (verbose) puts("STUB: cache_destroy called");
4040+ return NULL;
4141+}
4242+4343+void* cache_get(void)
4444+{
4545+ if (verbose) puts("STUB: cache_get called");
4646+ return NULL;
4747+}
4848+4949+void* cache_get_and_retain(void)
5050+{
5151+ if (verbose) puts("STUB: cache_get_and_retain called");
5252+ return NULL;
5353+}
5454+5555+void* cache_get_cost_hint(void)
5656+{
5757+ if (verbose) puts("STUB: cache_get_cost_hint called");
5858+ return NULL;
5959+}
6060+6161+void* cache_get_count_hint(void)
6262+{
6363+ if (verbose) puts("STUB: cache_get_count_hint called");
6464+ return NULL;
6565+}
6666+6767+void* cache_get_info(void)
6868+{
6969+ if (verbose) puts("STUB: cache_get_info called");
7070+ return NULL;
7171+}
7272+7373+void* cache_get_info_for_key(void)
7474+{
7575+ if (verbose) puts("STUB: cache_get_info_for_key called");
7676+ return NULL;
7777+}
7878+7979+void* cache_get_info_for_keys(void)
8080+{
8181+ if (verbose) puts("STUB: cache_get_info_for_keys called");
8282+ return NULL;
8383+}
8484+8585+void* cache_get_minimum_values_hint(void)
8686+{
8787+ if (verbose) puts("STUB: cache_get_minimum_values_hint called");
8888+ return NULL;
8989+}
9090+9191+void* cache_get_name(void)
9292+{
9393+ if (verbose) puts("STUB: cache_get_name called");
9494+ return NULL;
9595+}
9696+9797+void* cache_hash_byte_string(void)
9898+{
9999+ if (verbose) puts("STUB: cache_hash_byte_string called");
100100+ return NULL;
101101+}
102102+103103+void* cache_invoke(void)
104104+{
105105+ if (verbose) puts("STUB: cache_invoke called");
106106+ return NULL;
107107+}
108108+109109+void* cache_key_hash_cb_cstring(void)
110110+{
111111+ if (verbose) puts("STUB: cache_key_hash_cb_cstring called");
112112+ return NULL;
113113+}
114114+115115+void* cache_key_hash_cb_integer(void)
116116+{
117117+ if (verbose) puts("STUB: cache_key_hash_cb_integer called");
118118+ return NULL;
119119+}
120120+121121+void* cache_key_is_equal_cb_cstring(void)
122122+{
123123+ if (verbose) puts("STUB: cache_key_is_equal_cb_cstring called");
124124+ return NULL;
125125+}
126126+127127+void* cache_key_is_equal_cb_integer(void)
128128+{
129129+ if (verbose) puts("STUB: cache_key_is_equal_cb_integer called");
130130+ return NULL;
131131+}
132132+133133+void* cache_print(void)
134134+{
135135+ if (verbose) puts("STUB: cache_print called");
136136+ return NULL;
137137+}
138138+139139+void* cache_print_stats(void)
140140+{
141141+ if (verbose) puts("STUB: cache_print_stats called");
142142+ return NULL;
143143+}
144144+145145+void* cache_release_cb_free(void)
146146+{
147147+ if (verbose) puts("STUB: cache_release_cb_free called");
148148+ return NULL;
149149+}
150150+151151+void* cache_release_value(void)
152152+{
153153+ if (verbose) puts("STUB: cache_release_value called");
154154+ return NULL;
155155+}
156156+157157+void* cache_remove(void)
158158+{
159159+ if (verbose) puts("STUB: cache_remove called");
160160+ return NULL;
161161+}
162162+163163+void* cache_remove_all(void)
164164+{
165165+ if (verbose) puts("STUB: cache_remove_all called");
166166+ return NULL;
167167+}
168168+169169+void* cache_remove_with_block(void)
170170+{
171171+ if (verbose) puts("STUB: cache_remove_with_block called");
172172+ return NULL;
173173+}
174174+175175+void* cache_set_and_retain(void)
176176+{
177177+ if (verbose) puts("STUB: cache_set_and_retain called");
178178+ return NULL;
179179+}
180180+181181+void* cache_set_cost_hint(void)
182182+{
183183+ if (verbose) puts("STUB: cache_set_cost_hint called");
184184+ return NULL;
185185+}
186186+187187+void* cache_set_count_hint(void)
188188+{
189189+ if (verbose) puts("STUB: cache_set_count_hint called");
190190+ return NULL;
191191+}
192192+193193+void* cache_set_minimum_values_hint(void)
194194+{
195195+ if (verbose) puts("STUB: cache_set_minimum_values_hint called");
196196+ return NULL;
197197+}
198198+199199+void* cache_set_name(void)
200200+{
201201+ if (verbose) puts("STUB: cache_set_name called");
202202+ return NULL;
203203+}
204204+205205+void* cache_simulate_memory_warning_event(void)
206206+{
207207+ if (verbose) puts("STUB: cache_simulate_memory_warning_event called");
208208+ return NULL;
209209+}
210210+211211+void* cache_value_make_nonpurgeable_cb(void)
212212+{
213213+ if (verbose) puts("STUB: cache_value_make_nonpurgeable_cb called");
214214+ return NULL;
215215+}
216216+217217+void* cache_value_make_purgeable_cb(void)
218218+{
219219+ if (verbose) puts("STUB: cache_value_make_purgeable_cb called");
220220+ return NULL;
221221+}