Mail Archives: djgpp/1997/04/26/14:53:22
Gregary J Boyles wrote:
>
> Excuse the size of the file below - you can ignore most of it.
>
> Down near the bottom of the file there is a function called DoLocking
> which calls Allego style macros for locking code and data. It causes a
> general protection fault because if I comment it out the problem
> disappears. Any sugestions?
>
> #define START_FUNC(x) void x##_start(){}
> #define END_FUNC(x) void x##_end(){}
> #define LOCK_FUNC(x) _go32_dpmi_lock_code(x##_start,(long)x##_end-(long)x##_start);
> #define LOCK_DATA(x) _go32_dpmi_lock_data(x,sizeof(x));
>
> #include <dos.h>
> #include <iostream.h>
> #include <stdlib.h>
> #include "string.hh"
> #include "misc.hh"
>
phewwww ... try to post something shorter the next time.
first, include the correct header files: you absolutely need dpmi.h and
probably go.32.h.
the main problem is how pointers to class member functions are
implemented in c++. basically,
// Destructor.
START_FUNCTION(Func2);
TimeC::~TimeC()
this won't give you what you need to pass to the locking functions
because pointers to member functions are implemented as simple offset
values. as strostrup writes in the ARM:
"note that &S.i yields the address of i in the specific object S,
whereas &S::i yields a representation of i's relative position in all
objects of class S" (p.156)
i think there is a discussion going on regarding this in
comp.lang.c++.moderated.
you might want to lock the whole area your object takes, but then, i am
no expert in this stuff.
-- Sinan
*******************************************************************
A. Sinan Unur WWWWWW
|--O+O
mailto:sinan DOT unur AT cornell DOT edu C ^
http://www.people.cornell.edu/pages/asu1/ \ ~/
*******************************************************************
- Raw text -