babl: fix some annotation to make the function usable in bindings.
[babl.git] / tests / concurrency-stress-test.c
blobbf0ffff6050d97fe7f5257b8557268e49eaaab04
1 /* babl - dynamically extendable universal pixel conversion library.
2 * Copyright (C) 2009 Martin Nordholts
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General
15 * Public License along with this library; if not, see
16 * <https://www.gnu.org/licenses/>.
20 #include "config.h"
22 #include <math.h>
23 #include <pthread.h>
25 #include "babl.h"
28 #define N_THREADS 10
29 #define N_ITERATIONS_PER_THREAD 100
32 static void *
33 babl_fish_path_stress_test_thread_func (void *not_used)
35 int i;
37 for (i = 0; i < N_ITERATIONS_PER_THREAD; i++)
39 /* Try to get a fish with an as complex conversion path as
40 * possible
42 const Babl *fish = babl_fish ("R'G'B'A u16", "YA double");
44 /* Just do something random with the fish */
45 babl_get_name (fish);
48 return NULL;
51 int
52 main (void)
54 pthread_t threads[N_THREADS];
55 int i;
57 babl_init ();
59 /* Run a few threads at the same time */
60 for (i = 0; i < N_THREADS; i++)
62 pthread_create (&threads[i],
63 NULL, /* attr */
64 babl_fish_path_stress_test_thread_func,
65 NULL /* arg */);
68 /* Wait for them all to finish */
69 for (i = 0; i < N_THREADS; i++)
71 pthread_join (threads[i],
72 NULL /* thread_return */);
75 babl_exit ();
77 /* If we didn't crash we assume we're OK. We might want to add more
78 * asserts in the test later
80 return 0;