1 | # Copyright (c) 2001, Stanford University
|
---|
2 | # All rights reserved.
|
---|
3 | #
|
---|
4 | # See the file LICENSE.txt for information on redistributing this software.
|
---|
5 |
|
---|
6 | from __future__ import print_function
|
---|
7 | import sys
|
---|
8 | import apiutil
|
---|
9 |
|
---|
10 |
|
---|
11 | apiutil.CopyrightC()
|
---|
12 |
|
---|
13 | print("""
|
---|
14 |
|
---|
15 | /* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY spuchange.py SCRIPT */
|
---|
16 |
|
---|
17 | #include "cr_spu.h"
|
---|
18 | #include "cr_error.h"
|
---|
19 |
|
---|
20 | void crSPUChangeInterface(SPUDispatchTable *table, void *orig_func, void *new_func)
|
---|
21 | {
|
---|
22 | struct _copy_list_node *temp;
|
---|
23 | if (table->mark == 1)
|
---|
24 | {
|
---|
25 | return;
|
---|
26 | }
|
---|
27 | if (orig_func == new_func)
|
---|
28 | {
|
---|
29 | return;
|
---|
30 | }
|
---|
31 | table->mark = 1;
|
---|
32 | """)
|
---|
33 |
|
---|
34 | keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
|
---|
35 | for func_name in keys:
|
---|
36 | print('\tif ((uintptr_t)table->%s == (uintptr_t)orig_func)' % func_name)
|
---|
37 | print('\t{')
|
---|
38 | print('\t\ttable->%s = (%sFunc_t)(uintptr_t)new_func;' % (func_name, func_name))
|
---|
39 | print('\t\tfor (temp = table->copyList ; temp ; temp = temp->next)')
|
---|
40 | print('\t\t{')
|
---|
41 | print('\t\t\tcrSPUChangeInterface(temp->copy, orig_func, new_func);')
|
---|
42 | print('\t\t}')
|
---|
43 | print('\t}')
|
---|
44 |
|
---|
45 | print("""
|
---|
46 | if (table->copy_of != NULL)
|
---|
47 | {
|
---|
48 | crSPUChangeInterface(table->copy_of, orig_func, new_func);
|
---|
49 | }
|
---|
50 | for (temp = table->copyList; temp; temp = temp->next)
|
---|
51 | {
|
---|
52 | crSPUChangeInterface(temp->copy, orig_func, new_func);
|
---|
53 | }
|
---|
54 | table->mark = 0;
|
---|
55 | """)
|
---|
56 | print('}')
|
---|
57 |
|
---|
58 | print("""
|
---|
59 | void crSPUChangeDispatch(SPUDispatchTable *dispatch, const SPUNamedFunctionTable *newtable)
|
---|
60 | {
|
---|
61 | SPUGenericFunction func;
|
---|
62 | """)
|
---|
63 | keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
|
---|
64 | for func_name in keys:
|
---|
65 | print('\tfunc = crSPUFindFunction(newtable, "%s");' % func_name)
|
---|
66 | print('\tif (func && ((SPUGenericFunction)dispatch->%s!=func))' % func_name)
|
---|
67 | print('\t{')
|
---|
68 | print('\t\tcrDebug("%%s changed from %%p to %%p", "gl%s", (void *)(uintptr_t)dispatch->%s, (void *)(uintptr_t)func);' % (func_name, func_name))
|
---|
69 | print('\t\tcrSPUChangeInterface(dispatch, (void *)(uintptr_t)dispatch->%s, (void *)(uintptr_t)func);' % func_name)
|
---|
70 | print('\t}\n')
|
---|
71 | print("""
|
---|
72 | }
|
---|
73 | """)
|
---|