2 * include the license notice into the dynamic library to "reproduce the
3 * copyright notice" automatically, so the application developer does not have
4 * to care about this term
6 const char *d0_bsd_license_notice = "\n"
9 " * AUTHOR: Rudolf Polzer - divVerent@xonotic.org\n"
11 " * Copyright (c) 2010, Rudolf Polzer\n"
12 " * All rights reserved.\n"
14 " * Redistribution and use in source and binary forms, with or without\n"
15 " * modification, are permitted provided that the following conditions\n"
17 " * 1. Redistributions of source code must retain the above copyright\n"
18 " * notice, this list of conditions and the following disclaimer.\n"
19 " * 2. Redistributions in binary form must reproduce the above copyright\n"
20 " * notice, this list of conditions and the following disclaimer in the\n"
21 " * documentation and/or other materials provided with the distribution.\n"
22 " * 3. Neither the name of the copyright holder nor the names of contributors\n"
23 " * may be used to endorse or promote products derived from this software\n"
24 " * without specific prior written permission.\n"
26 " * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND\n"
27 " * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n"
28 " * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n"
29 " * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE\n"
30 " * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n"
31 " * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n"
32 " * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n"
33 " * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n"
34 " * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n"
35 " * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n"
38 " * $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);