hercules-390 / hyperion

Hercules 390
Other
252 stars 68 forks source link

mlock() issue #149

Closed PeterCoghlan closed 8 years ago

PeterCoghlan commented 8 years ago

When compiling on my VMS system which does not have mlock(), I end up generating a call to mlock() from impl.c. Then, at link time, mlock() can't be found.

In hmalloc.h, at line 314, MLOCK is #defined to be mlock, regardless of whether HAVE_MLOCK is defined or not. The same applies munlock() although the issue does not arise here as MUNLOCK() is never invoked.

The following patch work around the problem for me, although there may be a more elegant solution:

--- old/hmalloc.h 2016-08-25 18:56:22 +0100
+++ new/hmalloc.h 2016-08-29 15:46:42 +0100
@@ -311,8 +311,13 @@
   #define      HPCALLOC(t,a)    PVALLOC(a)
   #define      HPCFREE(t,a)     PVFREE(a)
   #define      HPAGESIZE        getpagesize
-  #define      MLOCK            mlock
-  #define      MUNLOCK          munlock
+  #if defined(HAVE_MLOCK)
+    #define    MLOCK            mlock
+    #define    MUNLOCK          munlock
+  #else
+    #define    MLOCK(a,b)       0
+    #define    MUNLOCK(a,b)     0
+  #endif

 #else // defined( OPTION_CALLOC_GUESTMEM )
PeterCoghlan commented 8 years ago

Hi Fish,

Many thanks for your efforts on this one.

Unfortunately, it is still failing for me. MLOCK is now #defined as __noop.

In hmacros.h, for non-MSVC compilers which don't already have it defined, __noop(...) is #defined as "do{;}while(0)" which does not return a suitable value as required for:

VERIFY( MLOCK( &sysblk, sizeof( SYSBLK )) == 0);

(I am having different problems with noop in dbgtrace.h where I have simply removed it from #define ASSERT and #define TRACE for now. This shows up when compiling sr.c for example. I see it is also lurking in qeth.c but I am not compiling that at present. I can come up with a #define for noop which looks like it should work in dbgtrace.h and another which looks like it should work in hmalloc.h but I can't come up with one that would have a chance of working in both, hence my suggestion to #define MLOCK(a, b) as 0).

Fish-Git commented 8 years ago

Oops! Missed that. Sorry. I'll try to get that fixed for you right away. Re-opening...

Fish-Git commented 8 years ago

Should now be fixed by commit da69c7364d3d6a764a86e1ba4ca938a0c4276e50.

Peter? Can you confirm? Thanks.

PeterCoghlan commented 8 years ago

Many thanks.

The mlock issue is fixed now. I can compile impl.c without having to hack at hmalloc.h.

The new definition of noop may be a problem in dbgtrace.h and/or qeth.c but it's no worse for me than it was before so I'll leave that one for another day. I presume that noone else but me will pick up the #define of noop in hstructs.h so there should be no need to worry about anyone else being affected by this?

PeterCoghlan commented 8 years ago

I see there has been some further work on this and the problems which I had with dbgtrace.h which I briefly alluded to have now gone away. Thanks!

However, my mlock problem is back again:

VERIFY( MLOCK( &sysblk, sizeof( SYSBLK )) == 0);

....^ %CC-E-CALLNEEDSFUNC, In this statement, "0" is not a function. at line number 544 in file impl.c

Could "#define MLOCK 0" in hmalloc.h be changed to "#define MLOCK(a,b) 0" or "#define MLOCK(...) 0" or something similar?

jphartmann commented 8 years ago

Right, this is __noop gone berserk. Fish, are you fixing it?

Fish-Git commented 8 years ago

(Oops!) Typo. Sorry about that. s/b/ fixed now. Please try again. Thanks.

PeterCoghlan commented 8 years ago

It's working great now. Many thanks!