From: "A. Sinan Unur" Newsgroups: comp.os.msdos.djgpp Subject: Re: Function locking problem (for ISR). Date: Sat, 26 Apr 1997 14:06:44 -0400 Organization: Cornell University http://www.cornell.edu Lines: 55 Sender: asu1 AT cornell DOT edu (Verified) Message-ID: <33624434.1596@cornell.edu> References: <5jss1o$alv AT lion DOT cs DOT latrobe DOT edu DOT au> Reply-To: asu1 AT cornell DOT edu NNTP-Posting-Host: cu-dialup-0011.cit.cornell.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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 > #include > #include > #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/ \ ~/ *******************************************************************