diff --git a/configure b/configure
index 062287e..a69a812 100755
--- a/configure
+++ b/configure
@@ -7743,7 +7743,7 @@ uninstall::
 
     APPKIT_LIBS="-framework AppKit"
 
-    LDEXECFLAGS="-image_base 0x7bf00000 -Wl,-segaddr,WINE_DOS,0x00001000,-segaddr,WINE_SHAREDHEAP,0x7f000000,-sectcreate,__TEXT,__info_plist,wine_info.plist"
+    LDEXECFLAGS="-image_base 0x7bf00000 -Wl,-segaddr,WINE_DOS,0x00001000,-segaddr,WINE_SHAREDHEAP,0x7f000000,-sectcreate,__TEXT,__info_plist,wine_info.plist,-pagezero_size,0x1000"
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports -Wl,-no_pie" >&5
 $as_echo_n "checking whether the compiler supports -Wl,-no_pie... " >&6; }
 if ${ac_cv_cflags__Wl__no_pie+:} false; then :
diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c
index 2eb2b94..3c05f21 100644
--- a/dlls/dbghelp/macho_module.c
+++ b/dlls/dbghelp/macho_module.c
@@ -43,7 +43,28 @@
 #include <mach-o/fat.h>
 #include <mach-o/loader.h>
 #include <mach-o/nlist.h>
+//HACK
+#if SH_SYS == SH_SYS_APPLE
+#include <stdlib.h>
+#include <AvailabilityMacros.h>
+#include <mach/task.h>
+#include <mach-o/dyld_images.h>
+#include <mach-o/loader.h>
+#include <mach-o/nlist.h>
 
+/* Define things from 10.6 SDK for older SDKs */
+#ifndef MAC_OS_X_VERSION_10_6
+//----
+struct task_dyld_info
+{
+    mach_vm_address_t all_image_info_addr;
+    mach_vm_size_t all_image_info_size;
+};
+typedef struct task_dyld_info task_dyld_info_data_t;
+#define TASK_DYLD_INFO 17
+#define TASK_DYLD_INFO_COUNT (sizeof(task_dyld_info_data_t) / sizeof(natural_t))
+#endif // MAC_OS_X_VERSION_10_6
+#endif // SH_SYS_APPLE
 #ifdef HAVE_MACH_O_DYLD_IMAGES_H
 #include <mach-o/dyld_images.h>
 #else
@@ -60,7 +81,21 @@ struct dyld_all_image_infos {
     void*                         notification;
     int                           processDetachedFromSharedRegion;
 };
+
+/*
+ * This is the symbol table entry structure for 64-bit architectures.
+ */
+struct my_nlist_64 {
+    union {
+        uint32_t  n_strx; /* index into the string table */
+    } n_un;
+    uint8_t n_type;        /* type flag, see below */
+    uint8_t n_sect;        /* section number or NO_SECT */
+    uint16_t n_desc;       /* see <mach-o/stab.h> */
+    uint64_t n_value;      /* value of this symbol (or stab offset) */
+};
 #endif
+//-----
 
 #include "winternl.h"
 #include "wine/library.h"
@@ -1002,10 +1037,24 @@ static BOOL macho_load_file(struct process* pcs, const WCHAR* filename,
                and we can find the dyld image infos address by looking up its symbol. */
             if (!dyld_all_image_infos_addr)
             {
+//HACK
                 struct nlist nl[2];
                 memset(nl, 0, sizeof(nl));
+                
+#if defined __APPLE__
+                task_dyld_info_data_t dyld_info;
+                mach_msg_type_number_t count = TASK_DYLD_INFO_COUNT;
+                task_info(mach_task_self(), TASK_DYLD_INFO, (task_info_t)&dyld_info, &count);
+                nl[0].n_un.n_strx = (struct dyld_all_image_infos *)dyld_info.all_image_info_addr;
+#else
                 nl[0].n_un.n_name = (char*)"_dyld_all_image_infos";
+#endif
+#if defined __APPLE__
+                if (!dlsym("/usr/lib/dyld", nl))
+#else
                 if (!nlist("/usr/lib/dyld", nl))
+#endif
+//---
                     dyld_all_image_infos_addr = (void*)nl[0].n_value;
             }
 
diff --git a/dlls/kernel32/thread.c b/dlls/kernel32/thread.c
index 5b9a683..0abfdf1 100644
--- a/dlls/kernel32/thread.c
+++ b/dlls/kernel32/thread.c
@@ -607,7 +607,7 @@ __ASM_STDCALL_FUNC( GetCurrentThreadId, 0, ".byte 0x64\n\tmovl 0x24,%eax\n\tret"
 /* HANDLE WINAPI GetProcessHeap(void) */
 __ASM_STDCALL_FUNC( GetProcessHeap, 0, ".byte 0x64\n\tmovl 0x30,%eax\n\tmovl 0x18(%eax),%eax\n\tret");
 
-#elif defined(__x86_64__)
+#elif defined(__x86_64__) && !defined(__APPLE__)
 
 /***********************************************************************
  *		SetLastError (KERNEL32.@)
diff --git a/dlls/msvcrt/math.c b/dlls/msvcrt/math.c
index 284924a..0ad0550 100644
--- a/dlls/msvcrt/math.c
+++ b/dlls/msvcrt/math.c
@@ -38,6 +38,14 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
 #define signbit(x) 0
 #endif
 
+//HACK
+#define finitef( x )   ( ( sizeof ( (x) ) == sizeof( float) ) ? \
+__isfinitef ( (float)(x) ) : __isfinited  ( (double)(x) ) )
+
+#define isnanf( x )      ( ( sizeof ( (x) ) == sizeof( float) ) ? \
+__isnanf ( (float)(x) ) : __isnand  ( (double)(x) ) )
+//----
+
 typedef int (CDECL *MSVCRT_matherr_func)(struct MSVCRT__exception *);
 typedef double LDOUBLE;  /* long double is just a double */
 
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index 51de6e7..c1f2ded 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -146,7 +146,7 @@
 @ stdcall NtCreateTimer(ptr long ptr long)
 @ stub NtCreateToken
 # @ stub NtCreateWaitablePort
-@ stdcall -arch=win32,arm64 NtCurrentTeb()
+@ stdcall -arch=win32,arm64,x86_64 NtCurrentTeb()
 # @ stub NtDebugActiveProcess
 # @ stub NtDebugContinue
 @ stdcall NtDelayExecution(long ptr)
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c
index 05581c2..495a099 100644
--- a/dlls/ntdll/signal_x86_64.c
+++ b/dlls/ntdll/signal_x86_64.c
@@ -68,6 +68,10 @@
 #include <valgrind/memcheck.h>
 #endif
 
+#ifdef __APPLE__
+#include <pthread.h>
+#endif
+
 WINE_DEFAULT_DEBUG_CHANNEL(seh);
 
 struct _DISPATCHER_CONTEXT;
@@ -236,6 +240,44 @@ static inline int arch_prctl( int func, void *ptr ) { return syscall( __NR_arch_
 #define ERROR_sig(context)  ((context)->uc_mcontext.__gregs[_REG_ERR])
 
 #define FPU_sig(context)   ((XMM_SAVE_AREA32 *)((context)->uc_mcontext.__fpregs))
+
+#elif defined(__APPLE__)
+static pthread_key_t teb_key;
+
+#define RAX_sig(context)    ((context)->uc_mcontext->__ss.__rax)
+#define RBX_sig(context)    ((context)->uc_mcontext->__ss.__rbx)
+#define RCX_sig(context)    ((context)->uc_mcontext->__ss.__rcx)
+#define RDX_sig(context)    ((context)->uc_mcontext->__ss.__rdx)
+#define RSI_sig(context)    ((context)->uc_mcontext->__ss.__rsi)
+#define RDI_sig(context)    ((context)->uc_mcontext->__ss.__rdi)
+#define RBP_sig(context)    ((context)->uc_mcontext->__ss.__rbp)
+#define R8_sig(context)     ((context)->uc_mcontext->__ss.__r8)
+#define R9_sig(context)     ((context)->uc_mcontext->__ss.__r9)
+#define R10_sig(context)    ((context)->uc_mcontext->__ss.__r10)
+#define R11_sig(context)    ((context)->uc_mcontext->__ss.__r11)
+#define R12_sig(context)    ((context)->uc_mcontext->__ss.__r12)
+#define R13_sig(context)    ((context)->uc_mcontext->__ss.__r13)
+#define R14_sig(context)    ((context)->uc_mcontext->__ss.__r14)
+#define R15_sig(context)    ((context)->uc_mcontext->__ss.__r15)
+
+#define CS_sig(context)     ((context)->uc_mcontext->__ss.__cs)
+//#define DS_sig(context)     ((context)->uc_mcontext->__ss.__ds)//not in x86_64
+//#define ES_sig(context)     ((context)->uc_mcontext->__ss.__es)//not in x86_64
+#define FS_sig(context)     ((context)->uc_mcontext->__ss.__fs)
+#define GS_sig(context)     ((context)->uc_mcontext->__ss.__gs)
+//#define SS_sig(context)     ((context)->uc_mcontext->__ss.__ss)//not in x86_64
+
+#define EFL_sig(context)    ((context)->uc_mcontext->__ss.__rflags)
+
+#define RIP_sig(context)    (*((unsigned long*)&(context)->uc_mcontext->__ss.__rip))	/* Program counter */
+#define RSP_sig(context)    (*((unsigned long*)&(context)->uc_mcontext->__ss.__rsp))
+
+#define TRAP_sig(context)   ((context)->uc_mcontext->__es.__trapno) /* number of  exception taken */
+#define ERROR_sig(context)  ((context)->uc_mcontext->__es.__err)
+
+#define FPU_sig(context)    ((XMM_SAVE_AREA32 *)&(context)->uc_mcontext->__fs.__fpu_fcw)
+
+
 #else
 #error You must define the signal context functions for your platform
 #endif
@@ -2521,6 +2563,17 @@ void signal_init_thread( TEB *teb )
     amd64_set_gsbase( teb );
 #elif defined(__NetBSD__)
     sysarch( X86_64_SET_GSBASE, &teb );
+#elif defined __APPLE__
+    {
+        static BOOL init_done;
+    
+        if (!init_done)
+        {
+            pthread_key_create( &teb_key, NULL );
+            init_done = TRUE;
+        }
+        pthread_setspecific( teb_key, teb );
+    }
 #else
 # error Please define setting %gs for your architecture
 #endif
@@ -3425,4 +3478,17 @@ __ASM_STDCALL_FUNC( DbgBreakPoint, 0, "int $3; ret")
  */
 __ASM_STDCALL_FUNC( DbgUserBreakPoint, 0, "int $3; ret")
 
+#ifdef __APPLE__
+
+/**********************************************************************
+ *           NtCurrentTeb   (NTDLL.@)
+ */
+TEB * WINAPI NtCurrentTeb(void)
+{
+    return pthread_getspecific( teb_key );
+}
+
+
+#endif /* __APPLE__ */
+
 #endif  /* __x86_64__ */
diff --git a/include/msvcrt/crtdefs.h b/include/msvcrt/crtdefs.h
index f2600ad..2a6f32d 100644
--- a/include/msvcrt/crtdefs.h
+++ b/include/msvcrt/crtdefs.h
@@ -76,7 +76,9 @@
 #endif /* __cdecl */
 
 #ifndef __ms_va_list
-# if defined(__x86_64__) && defined (__GNUC__)
+//HACK
+# if defined(__x86_64__) && defined (__GNUC__)&& !defined(__APPLE__)
+//---
 #  define __ms_va_list __builtin_ms_va_list
 #  define __ms_va_start(list,arg) __builtin_ms_va_start(list,arg)
 #  define __ms_va_end(list) __builtin_ms_va_end(list)
diff --git a/include/winbase.h b/include/winbase.h
index 5ac55b7..4c5e2a9 100644
--- a/include/winbase.h
+++ b/include/winbase.h
@@ -2783,7 +2783,7 @@ static FORCEINLINE LONG WINAPI InterlockedDecrement( LONG volatile *dest )
 
 /* A few optimizations for gcc */
 
-#if defined(__GNUC__) && !defined(__MINGW32__) && (defined(__i386__) || defined(__x86_64__)) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2)))
+#if defined(__GNUC__) && !defined(__MINGW32__) && (defined(__i386__) || defined(__x86_64__)) && ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 2))) && !defined(__APPLE__)
 
 static FORCEINLINE DWORD WINAPI GetLastError(void)
 {
diff --git a/include/windef.h b/include/windef.h
index e914726..55b1e47 100644
--- a/include/windef.h
+++ b/include/windef.h
@@ -85,7 +85,9 @@ extern "C" {
 #endif /* __cdecl */
 
 #ifndef __ms_va_list
-# if defined(__x86_64__) && defined (__GNUC__)
+//HACK
+# if defined(__x86_64__) && defined (__GNUC__) && !defined(__APPLE__)
+//---
 #  define __ms_va_list __builtin_ms_va_list
 #  define __ms_va_start(list,arg) __builtin_ms_va_start(list,arg)
 #  define __ms_va_end(list) __builtin_ms_va_end(list)
diff --git a/include/wine/test.h b/include/wine/test.h
index f8b608f..7227a5c 100644
--- a/include/wine/test.h
+++ b/include/wine/test.h
@@ -85,7 +85,9 @@ static inline int winetest_strcmpW( const WCHAR *str1, const WCHAR *str2 )
 #define START_TEST(name) void func_##name(void)
 #endif
 
-#if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
+//HACK
+#if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT) && !defined(__APPLE__)
+//---
 #define __winetest_cdecl __cdecl
 #define __winetest_va_list __builtin_ms_va_list
 #else
@@ -180,7 +182,9 @@ extern void __winetest_cdecl winetest_trace( const char *msg, ... );
 #include <stdio.h>
 #include <excpt.h>
 
-#if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
+//HACK
+#if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)&& !defined(__APPLE__)
+//----
 # define __winetest_va_start(list,arg) __builtin_ms_va_start(list,arg)
 # define __winetest_va_end(list) __builtin_ms_va_end(list)
 #else
diff --git a/include/winnt.h b/include/winnt.h
index 709a93f..4b06b2c 100644
--- a/include/winnt.h
+++ b/include/winnt.h
@@ -2284,7 +2284,7 @@ static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
   __asm mov teb, eax;
   return teb;
 }
-#elif defined(__x86_64__) && defined(__GNUC__)
+#elif defined(__x86_64__) && defined(__GNUC__) && !defined(__APPLE__)
 static FORCEINLINE struct _TEB * WINAPI NtCurrentTeb(void)
 {
     struct _TEB *teb;
diff --git a/server/mach.c b/server/mach.c
index 03c88ec..6a0dfa7 100644
--- a/server/mach.c
+++ b/server/mach.c
@@ -357,8 +357,10 @@ int write_process_memory( struct process *process, client_ptr_t ptr, data_size_t
     }
     region_address = aligned_address;
     info_size = sizeof(info);
-    ret = vm_region( process_port, &region_address, &region_size, VM_REGION_BASIC_INFO,
+//HACK
+    ret = mach_vm_region( process_port, &region_address, &region_size, VM_REGION_BASIC_INFO,
                      (vm_region_info_t)&info, &info_size, &dummy );
+//---
     if (ret != KERN_SUCCESS)
     {
         mach_set_error( ret );
diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c
index 35fe144..26a45fb 100644
--- a/tools/winebuild/spec32.c
+++ b/tools/winebuild/spec32.c
@@ -426,8 +426,8 @@ static void output_asm_constructor( const char *constructor )
     {
         /* Mach-O doesn't have an init section */
         output( "\n\t.mod_init_func\n" );
-        output( "\t.align %d\n", get_alignment(4) );
-        output( "\t.long %s\n", asm_name(constructor) );
+        output( "\t.align %d\n", get_alignment(8) );
+        output( "\t.quad %s\n", asm_name(constructor) );
     }
     else
     {
