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 | #include "cr_error.h"
|
---|
8 | #include "cr_mem.h"
|
---|
9 | #include "packer.h"
|
---|
10 | #include <stdio.h>
|
---|
11 |
|
---|
12 | #ifdef CHROMIUM_THREADSAFE
|
---|
13 | CRtsd _PackerTSD;
|
---|
14 | int cr_packer_globals; /* dummy - for the sake of packer.def */
|
---|
15 | #else
|
---|
16 | int _PackerTSD; /* dummy - for the sake of packer.def */ /* drm1 */
|
---|
17 | DLLDATA(CRPackContext) cr_packer_globals;
|
---|
18 | #endif
|
---|
19 |
|
---|
20 | CRPackContext *crPackNewContext( int swapping )
|
---|
21 | {
|
---|
22 | #ifdef CHROMIUM_THREADSAFE
|
---|
23 | CRPackContext *pc = crCalloc(sizeof(CRPackContext));
|
---|
24 | if (!pc)
|
---|
25 | return NULL;
|
---|
26 | crInitMutex(&pc->mutex);
|
---|
27 | #else
|
---|
28 | GET_PACKER_CONTEXT(pc);
|
---|
29 | crMemZero( pc, sizeof(CRPackContext));
|
---|
30 | #endif
|
---|
31 | pc->swapping = swapping;
|
---|
32 | pc->Flush = NULL;
|
---|
33 | pc->SendHuge = NULL;
|
---|
34 | pc->updateBBOX = 0;
|
---|
35 | return pc;
|
---|
36 | }
|
---|
37 |
|
---|
38 | void crPackDeleteContext(CRPackContext *pc)
|
---|
39 | {
|
---|
40 | #ifdef CHROMIUM_THREADSAFE
|
---|
41 | crFreeMutex(&pc->mutex);
|
---|
42 | crFree(pc);
|
---|
43 | #endif
|
---|
44 | }
|
---|
45 |
|
---|
46 | /* Set packing context for the calling thread */
|
---|
47 | void crPackSetContext( CRPackContext *pc )
|
---|
48 | {
|
---|
49 | #ifdef CHROMIUM_THREADSAFE
|
---|
50 | crSetTSD( &_PackerTSD, pc );
|
---|
51 | #else
|
---|
52 | CRASSERT( pc == &cr_packer_globals );
|
---|
53 | (void)pc;
|
---|
54 | #endif
|
---|
55 | }
|
---|
56 |
|
---|
57 |
|
---|
58 | /* Return packing context for the calling thread */
|
---|
59 | CRPackContext *crPackGetContext( void )
|
---|
60 | {
|
---|
61 | #ifdef CHROMIUM_THREADSAFE
|
---|
62 | return (CRPackContext *) crGetTSD( &_PackerTSD );
|
---|
63 | #else
|
---|
64 | return &cr_packer_globals;
|
---|
65 | #endif
|
---|
66 | }
|
---|
67 |
|
---|