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 |
|
---|
7 | #ifndef CR_UNPACK_H
|
---|
8 | #define CR_UNPACK_H
|
---|
9 |
|
---|
10 | #include "cr_compiler.h"
|
---|
11 | #include "cr_spu.h"
|
---|
12 | #include "cr_protocol.h"
|
---|
13 | #include "cr_mem.h"
|
---|
14 |
|
---|
15 | #include <iprt/types.h>
|
---|
16 |
|
---|
17 | #ifdef __cplusplus
|
---|
18 | extern "C" {
|
---|
19 | #endif
|
---|
20 |
|
---|
21 | extern SPUDispatchTable cr_unpackDispatch;
|
---|
22 | /*extern DLLDATA(const unsigned char *) cr_unpackData;*/
|
---|
23 | extern DECLEXPORT(const unsigned char *) cr_unpackData;
|
---|
24 |
|
---|
25 | DECLEXPORT(void) crUnpackSetReturnPointer( CRNetworkPointer *ptr );
|
---|
26 | DECLEXPORT(void) crUnpackSetWritebackPointer( CRNetworkPointer *ptr );
|
---|
27 | DECLEXPORT(void) crUnpack( const void *data, const void *opcodes, unsigned int num_opcodes, SPUDispatchTable *table );
|
---|
28 | DECLEXPORT(void) crUnpackPush(void);
|
---|
29 | DECLEXPORT(void) crUnpackPop(void);
|
---|
30 |
|
---|
31 | extern CRNetworkPointer * return_ptr;
|
---|
32 | extern CRNetworkPointer * writeback_ptr;
|
---|
33 |
|
---|
34 | #if defined(LINUX) || defined(WINDOWS)
|
---|
35 | #define CR_UNALIGNED_ACCESS_OKAY
|
---|
36 | #else
|
---|
37 | #undef CR_UNALIGNED_ACCESS_OKAY
|
---|
38 | #endif
|
---|
39 | DECLEXPORT(double) crReadUnalignedDouble( const void *buffer );
|
---|
40 |
|
---|
41 | #define READ_DATA( offset, type ) \
|
---|
42 | *( (const type *) (cr_unpackData + (offset)))
|
---|
43 |
|
---|
44 | #ifdef CR_UNALIGNED_ACCESS_OKAY
|
---|
45 | #define READ_DOUBLE( offset ) \
|
---|
46 | READ_DATA( offset, GLdouble )
|
---|
47 | #else
|
---|
48 | #define READ_DOUBLE( offset ) \
|
---|
49 | crReadUnalignedDouble( cr_unpackData + (offset) )
|
---|
50 | #endif
|
---|
51 |
|
---|
52 | #define READ_NETWORK_POINTER( offset ) \
|
---|
53 | ( cr_unpackData + (offset) )
|
---|
54 |
|
---|
55 | /* XXX make this const */
|
---|
56 | #define DATA_POINTER( offset, type ) \
|
---|
57 | ( (type *) (cr_unpackData + (offset)) )
|
---|
58 |
|
---|
59 | #define INCR_DATA_PTR( delta ) \
|
---|
60 | cr_unpackData += (delta)
|
---|
61 |
|
---|
62 | #define INCR_DATA_PTR_NO_ARGS() \
|
---|
63 | INCR_DATA_PTR( 4 )
|
---|
64 |
|
---|
65 | #define INCR_VAR_PTR() \
|
---|
66 | INCR_DATA_PTR( *((int *) cr_unpackData ) )
|
---|
67 |
|
---|
68 | #define SET_RETURN_PTR( offset ) \
|
---|
69 | crMemcpy( return_ptr, cr_unpackData + (offset), sizeof( *return_ptr ) );
|
---|
70 |
|
---|
71 | #define SET_WRITEBACK_PTR( offset ) \
|
---|
72 | crMemcpy( writeback_ptr, cr_unpackData + (offset), sizeof( *writeback_ptr ) );
|
---|
73 |
|
---|
74 | #ifdef __cplusplus
|
---|
75 | }
|
---|
76 | #endif
|
---|
77 |
|
---|
78 | #endif /* CR_UNPACK_H */
|
---|