4 * include the license notice into the dynamic library to "reproduce the
5 * copyright notice" automatically, so the application developer does not have
6 * to care about this term
8 const char *d0_bsd_license_notice D0_USED = "\n"
11 " * AUTHOR: Rudolf Polzer - divVerent@xonotic.org\n"
13 " * Copyright (c) 2010, Rudolf Polzer\n"
14 " * All rights reserved.\n"
16 " * Redistribution and use in source and binary forms, with or without\n"
17 " * modification, are permitted provided that the following conditions\n"
19 " * 1. Redistributions of source code must retain the above copyright\n"
20 " * notice, this list of conditions and the following disclaimer.\n"
21 " * 2. Redistributions in binary form must reproduce the above copyright\n"
22 " * notice, this list of conditions and the following disclaimer in the\n"
23 " * documentation and/or other materials provided with the distribution.\n"
24 " * 3. Neither the name of the copyright holder nor the names of contributors\n"
25 " * may be used to endorse or promote products derived from this software\n"
26 " * without specific prior written permission.\n"
28 " * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND\n"
29 " * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n"
30 " * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n"
31 " * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE\n"
32 " * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n"
33 " * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n"
34 " * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n"
35 " * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n"
36 " * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n"
37 " * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n"
40 " * $Format:commit %H$\n"
49 #define NUM_MUTEXES 1024
51 static mutexarray[NUM_MUTEXES];
52 static int mutexpos = 0;
53 static void *dummy_createmutex(void)
55 if(mutexpos >= NUM_MUTEXES)
57 printf("We don't support creating so many mutexes here\n");
60 return &mutexarray[mutexpos++];
62 static void dummy_destroymutex(void *m)
65 printf("Destroying in-use mutex\n");
68 static int dummy_lockmutex(void *m)
71 printf("Locking in-use mutex\n");
75 static int dummy_unlockmutex(void *m)
78 printf("Unlocking not-in-use mutex\n");
83 static void *dummy_createmutex(void)
85 return (void *) 1; // some dummy non-NULL pointer
87 static void dummy_destroymutex(void *m)
90 static int dummy_lockmutex(void *m)
94 static int dummy_unlockmutex(void *m)
100 d0_malloc_t *d0_malloc = NULL;
101 d0_free_t *d0_free = NULL;
102 d0_createmutex_t *d0_createmutex = NULL;
103 d0_destroymutex_t *d0_destroymutex = NULL;
104 d0_lockmutex_t *d0_lockmutex = NULL;
105 d0_unlockmutex_t *d0_unlockmutex = NULL;
107 void d0_setmallocfuncs(d0_malloc_t *m, d0_free_t *f)
109 d0_malloc = (m ? m : malloc);
110 d0_free = (f ? f : free);
113 void d0_setmutexfuncs(d0_createmutex_t *c, d0_destroymutex_t *d, d0_lockmutex_t *l, d0_unlockmutex_t *u)
115 d0_createmutex = (c ? c : dummy_createmutex);
116 d0_destroymutex = (d ? d : dummy_destroymutex);
117 d0_lockmutex = (l ? l : dummy_lockmutex);
118 d0_unlockmutex = (u ? u : dummy_unlockmutex);
121 void d0_initfuncs(void)
123 d0_setmallocfuncs(d0_malloc, d0_free);
124 d0_setmutexfuncs(d0_createmutex, d0_destroymutex, d0_lockmutex, d0_unlockmutex);