Game Development Community

Minor X86UNIX Issues (reposted)

by Gary "ChunkyKs" Briggs · in Torque Game Builder · 12/19/2006 (1:04 pm) · 3 replies

I'm reposting this from the TGE forums since a lot of people probably can't read those.

1) engine/platformX86UNIX/x86UNIXFont.h, line 46
virtual bool create(const char *name, dsize_t size, U32 charset = TGE_ANSI_CHARSET);
Shouldn't be virtual, and the second arg should be U32:
bool create(const char *name, U32 size, U32 charset = TGE_ANSI_CHARSET);

So then you need to edit x86UNIXFont.cc to make the second argument U32, also:
bool x86UNIXFont::create(const char *name, U32 size, U32 charset)

2) engine/platformX86UNIX/x86UNIXStrings.cc, lines 203,248, 253
These functions have the wrong return type:
U32 dStrlen(const char *str)
U32 dStrspn(const char *str, const char *set)
U32 dStrcspn(const char *str, const char *set)
Should be:
dsize_t dStrlen(const char *str)
dsize_t dStrspn(const char *str, const char *set)
dsize_t dStrcspn(const char *str, const char *set)

3) engine/platformX86UNIX/x86UNIXProcessControl.cc, lines 120-139
Little presumptious here:
void ProcessControlInit()
{
   // JMQ: ignore IO signals background read/write terminal (so that we don't
   // get suspended in daemon mode)
   signal(SIGTTIN, SIG_IGN);
   signal(SIGTTOU, SIG_IGN);

   // we're not interested in the exit status of child processes, so this 
   // prevents zombies from accumulating.
#if defined(__FreeBSD__)
   signal(SIGCHLD, SIG_IGN);
#else
   signal(SIGCLD, SIG_IGN);
#endif

   // install signal handler for SIGSEGV, so that we can attempt
   // clean shutdown
   signal(SIGSEGV, &SignalHandler);
   signal(SIGTRAP, &SignalHandler);
}
try:
void ProcessControlInit()
{
   // JMQ: ignore IO signals background read/write terminal (so that we don't
   // get suspended in daemon mode)
   signal(SIGTTIN, SIG_IGN);
   signal(SIGTTOU, SIG_IGN);

   // we're not interested in the exit status of child processes, so this 
   // prevents zombies from accumulating.
#if defined(SIGCHLD) // CHUNKY CHANGED THIS BIT
   signal(SIGCHLD, SIG_IGN);
#else
   signal(SIGCLD, SIG_IGN);
#endif

   // install signal handler for SIGSEGV, so that we can attempt
   // clean shutdown
   signal(SIGSEGV, &SignalHandler);
   signal(SIGTRAP, &SignalHandler);
}

4) Final sniglet for the really cool kids: engine/platformX86UNIX/x86UNIXProcessControl.cc
include thus:
#ifdef __GLIBC__ 
#include <execinfo.h>
#endif
And in the SignalHandler function, where it catches the SIGSEGV:
static void SignalHandler(int sigtype)
{
   if (sigtype == SIGSEGV || sigtype == SIGTRAP)
   {
      signal(SIGSEGV, SIG_DFL);
      signal(SIGTRAP, SIG_DFL);
	  
#ifdef __GLIBC__
	  void *array[64]; int size, i;
	  char **syms;
	  
	  fprintf(stderr, "Process %d Stack dump:\n\n", (int)getpid());
	  size = backtrace(array, (sizeof array)/(sizeof array[0]));
	  syms = backtrace_symbols(array, size);
	  for ( i=1; i<size; ++i ) {
		  fprintf(stderr, "\t%s\n", syms[i]);
	  }
	  free(syms);
	  fprintf(stderr, "\n");
#endif
	  
      // restore the signal handling to default so that we don't get into 
      // a crash loop with ImmediateShutdown
      ImmediateShutdown(-sigtype, sigtype);
   }
   else
   {
      signal(sigtype, SIG_DFL);
      dPrintf("Unknown signal caught by SignalHandler: %d\n", sigtype);
      dFflushStdout();
      // exit to be safe
      ImmediateShutdown(1);
   }
}

Gary (-;

#1
12/19/2006 (1:09 pm)
I appreciate it man, these will be very helpful.
#2
12/21/2006 (1:54 am)
Thanks very much!

Strange thing, though: These are semi-pristine sources I have, and x86UNIXFont.cc already had the
right type. The header file still needed the change. Source version is 1.1.3.

The ProcessControlInit() function looking for FreeBSD was definitely a bit weird ;)
#3
12/24/2006 (2:20 am)
Quote:The ProcessControlInit() function looking for FreeBSD was definitely a bit weird ;)

Mostly since the only BSDs that anyone tries to compile torque on are normally just FreeBSD :-)

Gary (-;

PS In the end I did get Torque to compile and run as platformX86UNIX on OSX, but it required a few changes that I suspect GG wouldn't be keen to make to their internal repository, and it still didn't /really/ work since SDL refuses to easily compile for X11 on Mac.