Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
test_pipe_cache_auto_destroy.c
Go to the documentation of this file.
1/*
2 This file is part of Ansel,
3 Copyright (C) 2026 Guillaume Stutin.
4
5 Ansel is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Ansel is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Ansel. If not, see <http://www.gnu.org/licenses/>.
17*/
18
29#include "system/atomic.h"
30
31#include <stdarg.h>
32#include <stddef.h>
33// cmocka.h declares `extern jmp_buf global_expect_assert_env' at file scope without including
34// <setjmp.h> itself. Same suppression as test_metadata_notify.c, and for the same reason.
35#include <setjmp.h> // NOLINT(misc-include-cleaner)
36#include <stdint.h>
37#include <cmocka.h>
38
39#define LINE_BYTES (256 * 1024)
40#define HASH_A 0x0A0A0A0A0A0A0A0Aull
41
42static int _setup(void **state __attribute__((unused)))
43{
44 return dt_dev_pixelpipe_cache_init((size_t)64 * 1024 * 1024, FALSE, FALSE) ? 0 : -1;
45}
46
47static int _teardown(void **state __attribute__((unused)))
48{
50 return 0;
51}
52
53/* Create a line the way a module creates a side-band output: referenced once and write-locked. */
55{
56 void *data = NULL;
58 assert_int_equal(dt_dev_pixelpipe_cache_get(HASH_A, LINE_BYTES, "test line", 0, TRUE, &data, &entry), 1);
59 assert_non_null(entry);
60 assert_non_null(data);
61 return entry;
62}
63
74
94
107
#define TRUE
Definition ashift_lsd.c:162
#define FALSE
Definition ashift_lsd.c:158
int dt_atomic_get_int(dt_atomic_int *var)
void dt_dev_pixelpipe_cache_wrlock_entry(gboolean lock, dt_pixel_cache_entry_t *cache_entry)
Lock or release the write lock on the entry.
void dt_dev_pixelpipe_cache_cleanup(void)
Release everything dt_dev_pixelpipe_cache_init() created, the instance included. Only after a success...
void dt_dev_pixelpipe_cache_ref_count_entry(gboolean lock, dt_pixel_cache_entry_t *cache_entry)
Take or release one reference on a cache line. A referenced line is never evicted,...
int dt_dev_pixelpipe_cache_get(const uint64_t hash, const size_t size, const char *name, const int id, const gboolean alloc, void **data, dt_pixel_cache_entry_t **entry)
Get a cache line from the cache.
dt_pixel_cache_entry_t * dt_dev_pixelpipe_cache_get_entry(const uint64_t hash)
Get an internal reference to the cache entry matching hash. If you are going to access this entry mor...
gboolean dt_dev_pixelpipe_cache_init(size_t max_memory, const gboolean verbose, const gboolean verbose_detail)
Reserve the cache's arena and start it.
gboolean dt_dev_pixelpipe_cache_ref_entry_by_hash(const uint64_t hash, void **data, dt_pixel_cache_entry_t **entry)
Resolve and retain an existing cache entry by hash.
void dt_dev_pixelpipe_cache_flag_auto_destroy(dt_pixel_cache_entry_t *cache_entry)
Flag a cache line as disposable (auto_destroy), for short-lived lines nothing will need again: the re...
Pixelpipe cache for storing intermediate results in the pixelpipe.
float dt_aligned_pixel_simd_t __attribute__((vector_size(16), aligned(16)))
Apply one channel's tone curve to each of the three colour channels, or pass the channel through unto...
Definition simd.h:55
const float uint32_t state[4]
dt_atomic_int refcount
static int _teardown(void **state __attribute__((unused)))
static void _flagged_line_goes_with_its_release(void **state __attribute__((unused)))
static void _unflagged_line_outlives_its_release(void **state __attribute__((unused)))
static int _setup(void **state __attribute__((unused)))
#define LINE_BYTES
static void _flagged_line_goes_with_its_last_holder(void **state __attribute__((unused)))
static dt_pixel_cache_entry_t * _create(void)