24783
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
7200
|
3 |
"
|
|
4 |
COPYRIGHT (c) 2003 by eXept Software AG
|
10409
|
5 |
All Rights Reserved
|
7200
|
6 |
|
|
7 |
This software is furnished under a license and may be used
|
|
8 |
only in accordance with the terms of that license and with the
|
|
9 |
inclusion of the above copyright notice. This software may not
|
|
10 |
be provided or otherwise made available to, or used by, any
|
|
11 |
other person. No title to or ownership of the software is
|
|
12 |
hereby transferred.
|
|
13 |
"
|
24783
|
14 |
"{ Package: 'stx:libbasic' }"
|
7200
|
15 |
|
24783
|
16 |
"{ NameSpace: Smalltalk }"
|
7183
|
17 |
|
|
18 |
ExternalBytes subclass:#MappedExternalBytes
|
|
19 |
instanceVariableNames:''
|
|
20 |
classVariableNames:''
|
|
21 |
poolDictionaries:''
|
|
22 |
category:'System-Support'
|
|
23 |
!
|
|
24 |
|
7200
|
25 |
!MappedExternalBytes class methodsFor:'documentation'!
|
|
26 |
|
|
27 |
copyright
|
|
28 |
"
|
|
29 |
COPYRIGHT (c) 2003 by eXept Software AG
|
10409
|
30 |
All Rights Reserved
|
7200
|
31 |
|
|
32 |
This software is furnished under a license and may be used
|
|
33 |
only in accordance with the terms of that license and with the
|
|
34 |
inclusion of the above copyright notice. This software may not
|
|
35 |
be provided or otherwise made available to, or used by, any
|
|
36 |
other person. No title to or ownership of the software is
|
|
37 |
hereby transferred.
|
|
38 |
"
|
|
39 |
!
|
|
40 |
|
|
41 |
documentation
|
|
42 |
"
|
|
43 |
Much like externalBytes - however, instances of MappedExternalBytes are created
|
|
44 |
by mapping virtual memory (i.e. mmap).
|
10409
|
45 |
For now, this class provides only the minimum required protocol to support
|
7200
|
46 |
the VideoForLinux API for video grabbing.
|
|
47 |
(actually, all that is found here is a redefined finalization method, as my instances
|
24783
|
48 |
must be freed by unmapping the underlying memory, as opposed to instances of my superclass,
|
|
49 |
which must be freed using malloc).
|
7200
|
50 |
|
24783
|
51 |
For now, instance's memory is coming from elsewhere - there is no support to allocate mmaped memory (yet).
|
7200
|
52 |
More will (might be required) be added in the future.
|
|
53 |
|
|
54 |
[authors:]
|
24783
|
55 |
Claus Gittinger
|
7200
|
56 |
"
|
|
57 |
! !
|
7183
|
58 |
|
|
59 |
!MappedExternalBytes methodsFor:'freeing'!
|
|
60 |
|
|
61 |
finalize
|
|
62 |
"some MappedExternalBytes object was finalized;
|
|
63 |
free the associated heap memory with it"
|
|
64 |
|
|
65 |
%{ /* NOCONTEXT */
|
|
66 |
#if defined(HAS_MMAP)
|
|
67 |
|
|
68 |
char *_mem = (char *)(__INST(address_));
|
|
69 |
OBJ sz = __INST(size);
|
|
70 |
|
|
71 |
# ifdef SUPERDEBUG
|
10409
|
72 |
console_fprintf(stderr, "MappedExternalBytes finalize\n");
|
7183
|
73 |
# endif
|
|
74 |
if (__isSmallInteger(sz)) {
|
10409
|
75 |
if (_mem && (OBJ)_mem != nil) {
|
7183
|
76 |
# ifdef SUPERDEBUG
|
10409
|
77 |
console_fprintf(stderr, "MappedExternalBytes munmap (%x, %d)\n", _mem, __intVal(sz));
|
7183
|
78 |
# endif
|
10409
|
79 |
munmap (_mem, __intVal(sz));
|
|
80 |
}
|
|
81 |
__INST(address_) = __INST(size) = nil;
|
7183
|
82 |
}
|
|
83 |
#endif /* HAS_MMAP */
|
|
84 |
%}
|
|
85 |
! !
|
|
86 |
|
|
87 |
!MappedExternalBytes class methodsFor:'documentation'!
|
|
88 |
|
|
89 |
version
|
24783
|
90 |
^ '$Header$'
|
7183
|
91 |
! !
|
24783
|
92 |
|