summaryrefslogtreecommitdiff
path: root/src/VBox/GuestHost/OpenGL/include/cr_unpack.h
blob: 1d22558ca3c554f25f3b760bc7cd7c1848996aa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* Copyright (c) 2001, Stanford University
 * All rights reserved.
 *
 * See the file LICENSE.txt for information on redistributing this software.
 */

#ifndef CR_UNPACK_H
#define CR_UNPACK_H

#include "cr_compiler.h"
#include "cr_spu.h"
#include "cr_protocol.h"
#include "cr_mem.h"

#include <iprt/types.h>

#ifdef __cplusplus
extern "C" {
#endif

extern SPUDispatchTable cr_unpackDispatch;
/*extern DLLDATA(const unsigned char *) cr_unpackData;*/
extern DECLEXPORT(const unsigned char *) cr_unpackData;

DECLEXPORT(void) crUnpackSetReturnPointer( CRNetworkPointer *ptr );
DECLEXPORT(void) crUnpackSetWritebackPointer( CRNetworkPointer *ptr );
DECLEXPORT(void) crUnpack( const void *data, const void *opcodes, unsigned int num_opcodes, SPUDispatchTable *table );
DECLEXPORT(void) crUnpackPush(void);
DECLEXPORT(void) crUnpackPop(void);

extern CRNetworkPointer * return_ptr;
extern CRNetworkPointer * writeback_ptr;

#if defined(LINUX) || defined(WINDOWS)
#define CR_UNALIGNED_ACCESS_OKAY
#else
#undef CR_UNALIGNED_ACCESS_OKAY
#endif
DECLEXPORT(double) crReadUnalignedDouble( const void *buffer );

#define READ_DATA( offset, type ) \
    *( (const type *) (cr_unpackData + (offset)))

#ifdef CR_UNALIGNED_ACCESS_OKAY
#define READ_DOUBLE( offset ) \
    READ_DATA( offset, GLdouble )
#else
#define READ_DOUBLE( offset ) \
    crReadUnalignedDouble( cr_unpackData + (offset) )
#endif

#define READ_NETWORK_POINTER( offset ) \
    ( cr_unpackData + (offset) )

/* XXX make this const */
#define DATA_POINTER( offset, type ) \
    ( (type *) (cr_unpackData + (offset)) )

#define INCR_DATA_PTR( delta ) \
    cr_unpackData += (delta)

#define INCR_DATA_PTR_NO_ARGS() \
    INCR_DATA_PTR( 4 )

#define INCR_VAR_PTR() \
    INCR_DATA_PTR( *((int *) cr_unpackData ) )

#define SET_RETURN_PTR( offset ) do { \
        CRDBGPTR_CHECKZ(return_ptr); \
        crMemcpy( return_ptr, cr_unpackData + (offset), sizeof( *return_ptr ) ); \
    } while (0);


#define SET_WRITEBACK_PTR( offset ) do { \
        CRDBGPTR_CHECKZ(writeback_ptr); \
        crMemcpy( writeback_ptr, cr_unpackData + (offset), sizeof( *writeback_ptr ) ); \
    } while (0);

#ifdef __cplusplus
}
#endif

#endif /* CR_UNPACK_H */