*** ocaml-3.06/configure.release	Wed Oct  2 17:01:39 2002
--- ocaml-3.06/configure	Wed Oct  2 17:04:56 2002
***************
*** 558,567 ****
                         nativecccompopts="-D_XOPEN_SOURCE=500";;
    *,*,nextstep,*)      nativecccompopts="$gcc_warnings -U__GNUC__ -posix"
                         nativecclinkopts="-posix";;
! # SHRINKED_GNUC is not necessary for MacOS 10.1 (don't know about 10.0)
! # (but it doesn't matter for native code anyway)
    *,*,rhapsody,*)      nativecccompopts="$gcc_warnings -DSHRINKED_GNUC";;
- #  *,*,rhapsody,*)      nativecccompopts="$gcc_warnings";;
    *,gcc*,cygwin,*)     nativecccompopts="$gcc_warnings -U_WIN32";;
    *,gcc*,*,*)          nativecccompopts="$gcc_warnings";;
  esac
--- 558,565 ----
                         nativecccompopts="-D_XOPEN_SOURCE=500";;
    *,*,nextstep,*)      nativecccompopts="$gcc_warnings -U__GNUC__ -posix"
                         nativecclinkopts="-posix";;
!   *,*,rhapsody,*darwin6*) nativecccompopts="$gcc_warnings -DDARWIN_VERSION_6";;
    *,*,rhapsody,*)      nativecccompopts="$gcc_warnings -DSHRINKED_GNUC";;
    *,gcc*,cygwin,*)     nativecccompopts="$gcc_warnings -U_WIN32";;
    *,gcc*,*,*)          nativecccompopts="$gcc_warnings";;
  esac
***************
*** 610,618 ****
  binutils_nm=''
  
  if test "$arch" != "none"; then
    old_IFS="$IFS"
    IFS=':'
!   for d in ${binutils_dir}:${PATH}; do
      if test -z "$d"; then continue; fi
      if test -f "$d/objcopy" && test -f "$d/nm"; then
        echo "objcopy and nm found in $d"
--- 608,617 ----
  binutils_nm=''
  
  if test "$arch" != "none"; then
+   binutils_path="${binutils_dir}:${PATH}:/usr/libexec/binutils"
    old_IFS="$IFS"
    IFS=':'
!   for d in ${binutils_path}; do
      if test -z "$d"; then continue; fi
      if test -f "$d/objcopy" && test -f "$d/nm"; then
        echo "objcopy and nm found in $d"
*** ocaml-3.06/asmrun/signals.c.release	Mon Nov  4 17:16:02 2002
--- ocaml-3.06/asmrun/signals.c	Mon Nov  4 16:11:03 2002
***************
*** 11,23 ****
  /*                                                                     */
  /***********************************************************************/
  
! /* $Id: signals.c,v 1.64 2002/05/06 12:02:26 xleroy Exp $ */
  
  #include <signal.h>
! #include <stdio.h>
! #if (defined(TARGET_sparc) && defined(SYS_solaris))
  #include <ucontext.h>
  #endif
  #include "alloc.h"
  #include "callback.h"
  #include "memory.h"
--- 11,25 ----
  /*                                                                     */
  /***********************************************************************/
  
! /* $Id: signals.c,v 1.66 2002/11/07 11:51:39 doligez Exp $ */
  
  #include <signal.h>
! #if defined(TARGET_sparc) && defined(SYS_solaris)
  #include <ucontext.h>
  #endif
+ #if defined(TARGET_power) && defined(SYS_rhapsody) && defined(DARWIN_VERSION_6)
+ #include <sys/ucontext.h>
+ #endif
  #include "alloc.h"
  #include "callback.h"
  #include "memory.h"
***************
*** 32,37 ****
--- 34,41 ----
  #include <sys/resource.h>
  #endif
  
+ extern char * code_area_start, * code_area_end;
+ 
  #ifdef _WIN32
  typedef void (*sighandler)(int sig);
  extern sighandler win32_signal(int sig, sighandler action);
***************
*** 39,48 ****
  #endif
  
  #if defined(TARGET_power) && defined(SYS_rhapsody)
! /* Confer machdep/ppc/unix_signal.c and mach/ppc/thread_status.h
!    in the Darwin sources */
! #define CONTEXT_GPR(ctx, regno) \
!   (((unsigned long *)((ctx)->sc_regs))[2 + (regno)])
  #endif
  
  #if defined(TARGET_power) && defined(SYS_aix)
--- 43,69 ----
  #endif
  
  #if defined(TARGET_power) && defined(SYS_rhapsody)
!   #ifdef DARWIN_VERSION_6
!     /* cf. xnu/bsd/dev/ppc/unix_signal.c
!            xnu/osfmk/mach/ppc/thread_status.h
!            xnu/bsd/sys/ucontext.h
!            xnu/bsd/ppc/signal.h
!            etc. etc. etc.
!     */
!     #define STRUCT_SIGCONTEXT struct ucontext
!     #define CONTEXT_GPR(ctx, regno) \
!       (((unsigned long *)&((ctx)->uc_mcontext->ss))[2 + (regno)])
!     #define CONTEXT_PC(ctx) \
!       (((unsigned long *)&((ctx)->uc_mcontext->ss))[0])
!   #else
!     /* Confer machdep/ppc/unix_signal.c and mach/ppc/thread_status.h
!        in the Darwin sources */
!     #define STRUCT_SIGCONTEXT struct sigcontext
!     #define CONTEXT_GPR(ctx, regno) \
!       (((unsigned long *)((ctx)->sc_regs))[2 + (regno)])
!     #define CONTEXT_PC(ctx) \
!       (((unsigned long *)((ctx)->sc_regs))[0])
!   #endif
  #endif
  
  #if defined(TARGET_power) && defined(SYS_aix)
***************
*** 161,167 ****
  #elif defined(TARGET_power) && defined(SYS_elf)
  void handle_signal(int sig, struct sigcontext * context)
  #elif defined(TARGET_power) && defined(SYS_rhapsody)
! void handle_signal(int sig, int code, struct sigcontext * context)
  #else
  void handle_signal(int sig)
  #endif
--- 182,188 ----
  #elif defined(TARGET_power) && defined(SYS_elf)
  void handle_signal(int sig, struct sigcontext * context)
  #elif defined(TARGET_power) && defined(SYS_rhapsody)
! void handle_signal(int sig, int code, STRUCT_SIGCONTEXT * context)
  #else
  void handle_signal(int sig)
  #endif
***************
*** 184,211 ****
      /* Some ports cache young_limit in a register.
         Use the signal context to modify that register too, but not if
         we are inside C code (i.e. caml_last_return_address != 0). */
-     if (caml_last_return_address == 0) {
  #if defined(TARGET_alpha)
        /* Cached in register $14 */
        context->sc_regs[14] = (long) young_limit;
  #endif
  #if defined(TARGET_mips)
        /* Cached in register $23 */
        context->sc_regs[23] = (int) young_limit;
  #endif
  #if defined(TARGET_power) && defined(SYS_aix)
        /* Cached in register 30 */
        CONTEXT_GPR(context, 30) = (ulong_t) young_limit;
  #endif
  #if defined(TARGET_power) && defined(SYS_elf)
        /* Cached in register 30 */
        context->regs->gpr[30] = (unsigned long) young_limit;
  #endif
  #if defined(TARGET_power) && defined(SYS_rhapsody)
        /* Cached in register 30 */
        CONTEXT_GPR(context, 30) = (unsigned long) young_limit;
- #endif
      }
    }
  }
  
--- 205,241 ----
      /* Some ports cache young_limit in a register.
         Use the signal context to modify that register too, but not if
         we are inside C code (i.e. caml_last_return_address != 0). */
  #if defined(TARGET_alpha)
+     if (caml_last_return_address == 0) {
        /* Cached in register $14 */
        context->sc_regs[14] = (long) young_limit;
+     }
  #endif
  #if defined(TARGET_mips)
+     if (caml_last_return_address == 0) {
        /* Cached in register $23 */
        context->sc_regs[23] = (int) young_limit;
+     }
  #endif
  #if defined(TARGET_power) && defined(SYS_aix)
+     if (caml_last_return_address == 0) {
        /* Cached in register 30 */
        CONTEXT_GPR(context, 30) = (ulong_t) young_limit;
+     }
  #endif
  #if defined(TARGET_power) && defined(SYS_elf)
+     if (caml_last_return_address == 0) {
        /* Cached in register 30 */
        context->regs->gpr[30] = (unsigned long) young_limit;
+     }
  #endif
  #if defined(TARGET_power) && defined(SYS_rhapsody)
+     if (CONTEXT_PC(context) >= (unsigned long) code_area_start
+         && CONTEXT_PC(context) <= (unsigned long) code_area_end) {
        /* Cached in register 30 */
        CONTEXT_GPR(context, 30) = (unsigned long) young_limit;
      }
+ #endif
    }
  }
  
***************
*** 326,332 ****
--- 356,366 ----
  #ifdef POSIX_SIGNALS
    sigact.sa_handler = act;
    sigemptyset(&sigact.sa_mask);
+ #ifdef SYS_rhapsody
+   sigact.sa_flags = SA_SIGINFO;
+ #else
    sigact.sa_flags = 0;
+ #endif
    if (sigaction(sig, &sigact, &oldsigact) == -1) sys_error(NO_ARG);
    oldact = oldsigact.sa_handler;
  #else
***************
*** 429,435 ****
  #endif
  
  #if defined(TARGET_power) && defined(SYS_rhapsody)
! static void trap_handler(int sig, int code, struct sigcontext * context)
  {
    /* Unblock SIGTRAP */
    sigset_t mask;
--- 463,469 ----
  #endif
  
  #if defined(TARGET_power) && defined(SYS_rhapsody)
! static void trap_handler(int sig, int code, STRUCT_SIGCONTEXT * context)
  {
    /* Unblock SIGTRAP */
    sigset_t mask;
***************
*** 522,529 ****
      struct sigaction act;
      act.sa_handler = (void (*)(int)) trap_handler;
      sigemptyset(&act.sa_mask);
! #if defined(SYS_rhapsody) || defined(SYS_aix)
      act.sa_flags = 0;
  #else
      act.sa_flags = SA_NODEFER;
  #endif
--- 556,565 ----
      struct sigaction act;
      act.sa_handler = (void (*)(int)) trap_handler;
      sigemptyset(&act.sa_mask);
! #if defined (SYS_aix)
      act.sa_flags = 0;
+ #elif defined (SYS_rhapsody)
+     act.sa_flags = SA_SIGINFO;
  #else
      act.sa_flags = SA_NODEFER;
  #endif
*** ocaml-3.06/byterun/sys.c.release	Wed Oct  2 17:02:00 2002
--- ocaml-3.06/byterun/sys.c	Wed Oct  2 17:04:56 2002
***************
*** 254,266 ****
--- 254,312 ----
  extern int win32_system(char * command);
  #endif
  
+ #if defined(SYS_rhapsody)
+ int rhapsody_system(const char *string) {
+     int old_sigmask;
+     pid_t pid;
+ 
+     if (string == 0)
+ 	return 1;
+     old_sigmask = sigblock(sigmask(SIGQUIT));
+     pid = vfork();
+     if (pid < 0) {
+ 	/* vfork failed */
+ 	sigsetmask(old_sigmask);
+ 	return -1;
+     } else if (pid == 0) {
+ 	/* We are in the child process */
+ 	sigsetmask(old_sigmask);
+ 	execl("/bin/sh", "sh", "-c", string, 0);
+ 	_exit(127);
+ 	return -1;
+     } else {
+ 	/* We are in the parent process */
+ 	int status = 0;
+ 	void* old_sigint;
+ 	void* old_sigquit;
+ 	int result;
+ 
+ 	old_sigint = signal(SIGINT, 0);
+ 	old_sigquit = signal(SIGQUIT, 0);
+ 	do {
+ 	    result = waitpid(pid, &status, 0);
+ 	} while (result < 0 && errno == EINTR);
+ 	signal(SIGINT, old_sigint);
+ 	signal(SIGQUIT, old_sigquit);
+ 	sigsetmask(old_sigmask);
+ 	if (result < 0)
+ 	    return -1;
+ 	else
+ 	    return status;
+     }
+ }
+ #endif
+ 
  CAMLprim value sys_system_command(value command)
  {
    int status, retcode;
    
    enter_blocking_section ();
  #ifndef _WIN32
+ #if defined(SYS_rhapsody)
+   status = rhapsody_system(String_val(command));
+ #else
    status = system(String_val(command));
+ #endif
    if (WIFEXITED(status))
      retcode = WEXITSTATUS(status);
    else
*** ocaml-3.06/otherlibs/labltk/support/cltkImg.c	2002/07/23 14:11:59	1.3
--- ocaml-3.06/otherlibs/labltk/support/cltkImg.c	2002/10/24 03:19:38
***************
*** 99,105 ****
    pib.offset[0] = 0;
    pib.offset[1] = 1;
    pib.offset[2] = 2;
!   Tk_PhotoPutBlock(ph,&pib,Int_val(x),Int_val(y),Int_val(w),Int_val(h)); 
  }
  
  CAMLprim void camltk_setimgdata_bytecode(argv,argn)
--- 99,109 ----
    pib.offset[0] = 0;
    pib.offset[1] = 1;
    pib.offset[2] = 2;
!   Tk_PhotoPutBlock(ph,&pib,Int_val(x),Int_val(y),Int_val(w),Int_val(h)
! #if (TK_MAJOR_VERSION == 8 && TK_MINOR_VERSION >= 4 || TK_MAJOR_VERSION > 8)
!                    , TK_PHOTO_COMPOSITE_SET
! #endif
!     ); 
  }
  
  CAMLprim void camltk_setimgdata_bytecode(argv,argn)
*** ocaml-3.06/otherlibs/labltk/tkanim/tkAnimGIF.c	2002/07/23 14:12:00	1.4
--- ocaml-3.06/otherlibs/labltk/tkanim/tkAnimGIF.c	2002/10/24 03:19:38
***************
*** 335,342 ****
                  goto error;
              }
          }
!         Tk_PhotoPutBlock(photoHandle, &block, 0, 0, 
!                          imageWidth, imageHeight);
  #ifdef TKANIM_DEBUG
      fprintf(stderr, " Retrieving result\n");
  #endif
--- 335,345 ----
                  goto error;
              }
          }
!         Tk_PhotoPutBlock(photoHandle, &block, 0, 0, imageWidth, imageHeight
! #if (TK_MAJOR_VERSION == 8 && TK_MINOR_VERSION >= 4 || TK_MAJOR_VERSION > 8)
!                    , TK_PHOTO_COMPOSITE_SET
! #endif
!           );
  #ifdef TKANIM_DEBUG
      fprintf(stderr, " Retrieving result\n");
  #endif
