[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple compile errors on MacOS X (Lion)



Hi,
here's the rest.

> 
> 2. It appears malloc(3) is supposed to come from <stdlib.h>
>   in POSIX systems, so I will remove all malloc.h includes.
That's what I found as well.


> 
> 4. hiios I/O engine currently supports Linux epoll(2) and Solaris
>   /dev/poll. It does not support BSD kqueue or Windows IO
>   completion ports. I suspect the kqueue support would not
>   be difficult to add, but I would appreciate a contribution.
> 

Unfortunately, I have no clue what that code does. If it was not
essential functionality, one could maybe exclude it from compilation
if the preconditions are not met?

>   Else you will need to wait until I have need to deploy
>   on BSD kqueue machine.
No problem with waiting because I guess I don't need this. Otherwise I can test stuff or 
give you the
manpage of kqueue, but that is about it. 

>   Basically patching EPOLL anything does not make sense unless
>   MacOS somehow supports them.
> 
>   The whole poll issue only affects zxbusd and not the
>   rest of the zxid code base.

I think there was a little more in hiios.c that could go wrong, even without 
understanding what the code does.
In hiios.c line 213, function hi_in_out:

#ifdef SUNOS
#define EPOLLHUP (POLLHUP)  /* 0x010 */
#define EPOLLERR (POLLERR)  /* 0x008 */
#define EPOLLOUT (POLLOUT)  /* 0x004 */
#define EPOLLIN  (POLLIN)   /* 0x001 */
#endif
  if (io->events & (EPOLLHUP | EPOLLERR)) /* compile fails here */
...

So EPOLLHUP is defined only for SUNOS, but used later in the code. To compile,
I have blindly put the #endif towards the end of the function, such that it does nothing,
hoping that it wasn't important anyway.

> 
> 5. Please investigate how MacOS wants the signals and wait(2)
>   included. I notice that linux manpage documents that
>   the correct niclude is <sys/wait.h> rather than <wait.h>.
>   Perhaps this is enough to fix?
> 
from man 2 wait:

NAME
     wait, wait3, wait4, waitpid -- wait for process termination

SYNOPSIS
     #include <sys/wait.h>


     pid_t
     wait(int *stat_loc);

     pid_t
     wait3(int *stat_loc, int options, struct rusage *rusage);

     pid_t
     wait4(pid_t pid, int *stat_loc, int options, struct rusage *rusage);

     pid_t
     waitpid(pid_t pid, int *stat_loc, int options);
[....]

so sys/wait.h should be it, similar to linux which doesn't have wait3, wait4:
NAME
       wait, waitpid - wait for process to change state

SYNOPSIS
       #include <sys/types.h>
       #include <sys/wait.h>

> 7. Warnings like
> 
>     zxlibdec.c:639: warning: cast from pointer to integer of different size
> 
>   come from errmac.h:637
> 
>      #  define UNLOCK(l,lk) MB ASSERTOPI((l).thr, ==, pthread_self()); /*(l).func = __FUNCTION__; (l).line = __LINE__;*/ (l).thr = 0; if (pthread_mutex_unlock(&(l).ptmut)) NEVERNEVER("UNLOCK-ERR(%s)", (lk)); ME
> 
>   This macro was recently expanded to capture the thread and line
>   information for debugging purposes. It does not throw warning
>   on Linux x86 (32bit) or x86_64 with gcc-4.6.1.
> 
>   About the only assignment seems to be (l).thr = 0;
>   Can you try manually expanding the macro to pinpoint
>   better where it is going wrong?

here:

 (int)((c->mx).thr)), /* zxlibdec.c:651: warning: cast from pointer to integer of different size */

I think it should be long. If I change:

"t%lx %10s:%-3d %-16s %s E %s" "ASSERTOP FAIL: " "(c->mx).thr" "==" "pthread_self()" " %x" "\n",
to:
"t%lx %10s:%-3d %-16s %s E %s" "ASSERTOP FAIL: " "(c->mx).thr" "==" "pthread_self()" " %lx" "\n",

and
(int)((c->mx).thr))
to:
(long)((c->mx).thr))

there is no more warning for this file.


The fully expanded macro:


 /* UNLOCK(c->mx, func); */

  do { 
    do { 
      if (!(((c->mx).thr) == (pthread_self()))) 
	{ 
	  (fprintf((zx_debug_log?zx_debug_log:(__stderrp)),
		   "t%lx %10s:%-3d %-16s %s E %s" "ASSERTOP FAIL: " "(c->mx).thr" "==" "pthread_self()" " %x" "\n",
		   (long)pthread_self(), 
		   "zxlibdec.c", 
		   642, __FUNCTION__, zx_instance, zx_indent, 
		   (int)((c->mx).thr)), /* zxlibdec.c:651: warning: cast from pointer to integer of different size */
	   fflush((zx_debug_log?zx_debug_log:(__stderrp)))); 
	  do { 
	    fprintf((zx_debug_log?zx_debug_log:(__stderrp)), assert_msg, zx_instance); 
	    if (assert_nonfatal == 0) { *((int*)0xffffffff) = 1; } }
	  while(0);
	} 
    } while(0); 
    (c->mx).thr = 0;
    if (pthread_mutex_unlock(&(c->mx).ptmut)) 
      do {
	(fprintf((zx_debug_log?zx_debug_log:(__stderrp)), "t%lx %10s:%-3d %-16s %s E %s" "UNLOCK-ERR(%s)" "\n", (long)pthread_self(), "zxlibdec.c", 642, __FUNCTION__, zx_instance, zx_indent, ((func))), fflush((zx_debug_log?zx_debug_log:(__stderrp))));
	fflush(__stdoutp); fflush((zx_debug_log?zx_debug_log:(__stderrp))); 
	do { 
	  if (!(0)) { 
	    (fprintf((zx_debug_log?zx_debug_log:(__stderrp)), "t%lx %10s:%-3d %-16s %s E %s" "ASSERT FAIL: " "0" " %d" "\n", (long)pthread_self(), "zxlibdec.c", 642, __FUNCTION__, zx_instance, zx_indent, 0), fflush((zx_debug_log?zx_debug_log:(__stderrp))));

	    do { fprintf((zx_debug_log?zx_debug_log:(__stderrp)), assert_msg, zx_instance); 
	      if (assert_nonfatal == 0) { *((int*)0xffffffff) = 1; } } 
	    while(0);
	  } 
	} 
	while(0);
      } 
      while(0); 
  } while(0);
  



Cheers
Michael






> 
> Cheers,
> --Sampo