VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/spu_loader/dispatch.py@ 63939

最後變更 在這個檔案從63939是 63939,由 vboxsync 提交於 8 年 前

Build/scripts (bugref:6627): Python build scripts updated to generate the same code when used with Python 2 and 3.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id
檔案大小: 2.7 KB
 
1# Copyright (c) 2001, Stanford University
2# All rights reserved.
3#
4# See the file LICENSE.txt for information on redistributing this software.
5
6from __future__ import print_function
7import sys
8import apiutil
9
10
11apiutil.CopyrightC()
12
13print("""
14
15/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY dispatch.py SCRIPT */
16
17#include "cr_spu.h"
18#include "cr_string.h"
19#include "cr_error.h"
20
21
22static SPUGenericFunction __findFunc( char *name, SPU *spu )
23{
24 SPUNamedFunctionTable *temp;
25
26 if (spu == NULL)
27 return NULL;
28
29 for (temp = spu->function_table->table ; temp->name != NULL ; temp++)
30 {
31 if (!crStrcmp( name, temp->name ) )
32 {
33 return temp->fn;
34 }
35 }
36 return __findFunc( name, spu->superSPU );
37}
38
39
40/*
41 * This function is not public outside the loader SPU.
42 */
43extern void __buildDispatch( SPU *spu );
44
45void __buildDispatch( SPU *spu )
46{""")
47
48keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
49for func_name in keys:
50 print('\tspu->dispatch_table.%s = (%sFunc_t) __findFunc( "%s", spu );' % (func_name,func_name,func_name))
51print('}')
52
53
54print("""
55
56/*
57 * Public function:
58 * Search a SPU named function table for a specific function. Return
59 * a pointer to it or NULL if not found.
60 */
61SPUGenericFunction crSPUFindFunction( const SPUNamedFunctionTable *table, const char *fname )
62{
63 const SPUNamedFunctionTable *temp;
64
65 for (temp = table ; temp->name != NULL ; temp++)
66 {
67 if (!crStrcmp( fname, temp->name ) )
68 {
69 return temp->fn;
70 }
71 }
72 return NULL;
73}
74
75
76/*
77 * Public function:
78 * Initializes the pointers in an SPUDispatchTable by looking for functions
79 * in an SPUNamedFunctionTable.
80 * It doesn't know anything about SPUs and SPU inheritance.
81 */
82void crSPUInitDispatch( SPUDispatchTable *dispatch, const SPUNamedFunctionTable *table )
83{""")
84
85for func_name in keys:
86 print('\tdispatch->%s = (%sFunc_t) crSPUFindFunction(table, "%s");' % (func_name, func_name, func_name))
87print('}')
88
89
90
91print("""
92/*
93 * Generic no-op function
94 */
95static int NopFunction(void)
96{
97/*
98 crWarning("Calling generic no-op function in dispatch.c");
99*/
100 return 0;
101}
102
103
104/*
105 * Scan the given dispatch table for NULL pointers. Hook in the generic
106 * no-op function wherever we find a NULL pointer.
107 */
108void crSPUInitDispatchNops(SPUDispatchTable *table)
109{
110 /*
111 * This is a bit tricky. We walk over all the function pointers in
112 * the SPUDispatchTable struct, checking for NULL and setting NULL
113 * pointers to point to NopFunction().
114 * But we have to stop when we get to the copyList pointer!
115 */
116 const int numEntries = (void **) &(table->copyList) - (void **) &(table->Accum);
117 void **ptr = (void **) table;
118 int i;
119 for (i = 0; i < numEntries; i++) {
120 if (ptr[i] == NULL) {
121 /*printf("!!!!!!!Warning entry[%d] = NULL\n", i);*/
122 ptr[i] = (void *)(uintptr_t)NopFunction;
123 }
124 }
125}
126""")
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette