mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-01-31 05:40:44 +00:00
- Maybe enable assembly on Intel Macs?
SVN r2527 (trunk)
This commit is contained in:
parent
4f03442a7a
commit
30ffe1d4b8
9 changed files with 109 additions and 16 deletions
|
@ -11,6 +11,11 @@ include( FindPkgConfig )
|
||||||
option( NO_ASM "Disable assembly code" )
|
option( NO_ASM "Disable assembly code" )
|
||||||
if( CMAKE_COMPILER_IS_GNUCXX )
|
if( CMAKE_COMPILER_IS_GNUCXX )
|
||||||
option( NO_STRIP "Do not strip Release or MinSizeRel builds" )
|
option( NO_STRIP "Do not strip Release or MinSizeRel builds" )
|
||||||
|
# At least some versions of Xcode fail if you strip with the linker
|
||||||
|
# instead of the separate strip utility.
|
||||||
|
if( APPLE )
|
||||||
|
set( NO_STRIP ON )
|
||||||
|
endif( APPLE )
|
||||||
endif( CMAKE_COMPILER_IS_GNUCXX )
|
endif( CMAKE_COMPILER_IS_GNUCXX )
|
||||||
|
|
||||||
if( CMAKE_SIZEOF_VOID_P MATCHES "8" )
|
if( CMAKE_SIZEOF_VOID_P MATCHES "8" )
|
||||||
|
@ -232,13 +237,6 @@ endif( FMOD_LIBRARY )
|
||||||
|
|
||||||
# Search for NASM
|
# Search for NASM
|
||||||
|
|
||||||
if( CMAKE_SYSTEM_PROCESSOR MATCHES powerpc OR CMAKE_OSX_ARCHITECTURES MATCHES ppc)
|
|
||||||
if( NOT NO_ASM )
|
|
||||||
message( STATUS "Disabling assembly code for PowerPC." )
|
|
||||||
set( NO_ASM ON )
|
|
||||||
endif( NOT NO_ASM )
|
|
||||||
endif( CMAKE_SYSTEM_PROCESSOR MATCHES powerpc OR CMAKE_OSX_ARCHITECTURES MATCHES ppc )
|
|
||||||
|
|
||||||
if( NOT NO_ASM )
|
if( NOT NO_ASM )
|
||||||
if( UNIX AND X64 )
|
if( UNIX AND X64 )
|
||||||
find_program( GAS_PATH as )
|
find_program( GAS_PATH as )
|
||||||
|
@ -297,7 +295,12 @@ if( NOT NO_ASM )
|
||||||
set( ASM_FLAGS )
|
set( ASM_FLAGS )
|
||||||
set( ASM_SOURCE_EXTENSION .s )
|
set( ASM_SOURCE_EXTENSION .s )
|
||||||
else( X64 )
|
else( X64 )
|
||||||
set( ASM_FLAGS -f elf -DM_TARGET_LINUX -i${CMAKE_CURRENT_SOURCE_DIR}/ )
|
if( APPLE )
|
||||||
|
set( ASM_FLAGS -fmacho -DM_TARGET_MACHO )
|
||||||
|
else( APPLE )
|
||||||
|
set( ASM_FLAGS -felf )
|
||||||
|
endif( APPLE )
|
||||||
|
set( ASM_FLAGS "${ASM_FLAGS}" -DM_TARGET_LINUX -i${CMAKE_CURRENT_SOURCE_DIR}/ )
|
||||||
set( ASM_SOURCE_EXTENSION .asm )
|
set( ASM_SOURCE_EXTENSION .asm )
|
||||||
endif( X64 )
|
endif( X64 )
|
||||||
else( UNIX )
|
else( UNIX )
|
||||||
|
|
|
@ -93,7 +93,16 @@ setupvlineasm:
|
||||||
selfmod premach3a, machvsh8+6
|
selfmod premach3a, machvsh8+6
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
%ifdef M_TARGET_MACHO
|
||||||
|
SECTION .text align=64
|
||||||
|
%else
|
||||||
SECTION .rtext progbits alloc exec write align=64
|
SECTION .rtext progbits alloc exec write align=64
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%ifdef M_TARGET_MACHO
|
||||||
|
GLOBAL rtext_a_start
|
||||||
|
rtext_a_start:
|
||||||
|
%endif
|
||||||
|
|
||||||
;eax = xscale
|
;eax = xscale
|
||||||
;ebx = palookupoffse
|
;ebx = palookupoffse
|
||||||
|
@ -538,3 +547,8 @@ ALIGN 16
|
||||||
mvcase0: jmp beginmvlineasm4
|
mvcase0: jmp beginmvlineasm4
|
||||||
|
|
||||||
align 16
|
align 16
|
||||||
|
|
||||||
|
%ifdef M_TARGET_MACHO
|
||||||
|
GLOBAL rtext_a_end
|
||||||
|
rtext_a_end:
|
||||||
|
%endif
|
||||||
|
|
|
@ -285,7 +285,16 @@ R_SetSpanSize_ASM:
|
||||||
|
|
||||||
aret: ret
|
aret: ret
|
||||||
|
|
||||||
|
%ifdef M_TARGET_MACHO
|
||||||
|
SECTION .text align=64
|
||||||
|
%else
|
||||||
SECTION .rtext progbits alloc exec write align=64
|
SECTION .rtext progbits alloc exec write align=64
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%ifdef M_TARGET_MACHO
|
||||||
|
GLOBAL rtext_tmap_start
|
||||||
|
rtext_tmap_start:
|
||||||
|
%endif
|
||||||
|
|
||||||
rtext_start:
|
rtext_start:
|
||||||
|
|
||||||
|
@ -1738,6 +1747,10 @@ ac4nil: pop edi
|
||||||
ret
|
ret
|
||||||
|
|
||||||
rtext_end:
|
rtext_end:
|
||||||
|
%ifdef M_TARGET_MACHO
|
||||||
|
GLOBAL rtext_tmap_end
|
||||||
|
rtext_tmap_end:
|
||||||
|
%endif
|
||||||
align 16
|
align 16
|
||||||
|
|
||||||
;************************
|
;************************
|
||||||
|
|
|
@ -216,7 +216,13 @@ SetTiltedSpanSize:
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
%ifndef M_TARGET_MACHO
|
||||||
SECTION .rtext progbits alloc exec write align=64
|
SECTION .rtext progbits alloc exec write align=64
|
||||||
|
%else
|
||||||
|
SECTION .text align=64
|
||||||
|
GLOBAL rtext_tmap2_start
|
||||||
|
rtext_tmap2_start:
|
||||||
|
%endif
|
||||||
|
|
||||||
rtext_start:
|
rtext_start:
|
||||||
|
|
||||||
|
@ -628,3 +634,7 @@ fetch10 mov al,[ebp+esi+SPACEFILLER4]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
rtext_end:
|
rtext_end:
|
||||||
|
%ifdef M_TARGET_MACHO
|
||||||
|
GLOBAL rtext_tmap2_end
|
||||||
|
rtext_tmap2_end:
|
||||||
|
%endif
|
||||||
|
|
|
@ -80,7 +80,13 @@ setupvlinetallasm:
|
||||||
selfmod shifter1, shift12+6
|
selfmod shifter1, shift12+6
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
%ifdef M_TARGET_MACHO
|
||||||
|
SECTION .text align=64
|
||||||
|
GLOBAL rtext_tmap3_start
|
||||||
|
rtext_tmap3_start:
|
||||||
|
%else
|
||||||
SECTION .rtext progbits alloc exec write align=64
|
SECTION .rtext progbits alloc exec write align=64
|
||||||
|
%endif
|
||||||
|
|
||||||
ALIGN 16
|
ALIGN 16
|
||||||
|
|
||||||
|
@ -331,3 +337,8 @@ shift12: shr ecx,16
|
||||||
pop ebx
|
pop ebx
|
||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
%ifdef M_TARGET_MACHO
|
||||||
|
GLOBAL rtext_tmap3_end
|
||||||
|
rtext_tmap3_end:
|
||||||
|
%endif
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#endif
|
#endif
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|
||||||
#ifdef unix
|
#if defined(unix) || defined(__APPLE__)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -44,12 +44,6 @@
|
||||||
|
|
||||||
// Since this file is included by everything, it seems an appropriate place
|
// Since this file is included by everything, it seems an appropriate place
|
||||||
// to check the NOASM/USEASM macros.
|
// to check the NOASM/USEASM macros.
|
||||||
#if defined(__APPLE__)
|
|
||||||
// The assembly code needs to be tweaked for Mach-O before enabled on Macs.
|
|
||||||
#ifndef NOASM
|
|
||||||
#define NOASM
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// There are three assembly-related macros:
|
// There are three assembly-related macros:
|
||||||
//
|
//
|
||||||
|
|
|
@ -3495,7 +3495,7 @@ inline int getshort (int *&pc)
|
||||||
#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__)
|
#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__)
|
||||||
inline int uallong(int &foo)
|
inline int uallong(int &foo)
|
||||||
{
|
{
|
||||||
return *foo;
|
return foo;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
inline int uallong(int &foo)
|
inline int uallong(int &foo)
|
||||||
|
|
|
@ -44,6 +44,10 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#endif
|
#endif
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
#if defined(__MACH__) && !defined(NOASM)
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "doomerrors.h"
|
#include "doomerrors.h"
|
||||||
#include "m_argv.h"
|
#include "m_argv.h"
|
||||||
|
@ -201,6 +205,46 @@ static int DoomSpecificInfo (char *buffer, char *end)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__MACH__) && !defined(NOASM)
|
||||||
|
// NASM won't let us create custom sections for Mach-O. Whether that's a limitation of NASM
|
||||||
|
// or of Mach-O, I don't know, but since we're using NASM for the assembly, it doesn't much
|
||||||
|
// matter.
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
extern void *rtext_a_start, *rtext_a_end;
|
||||||
|
extern void *rtext_tmap_start, *rtext_tmap_end;
|
||||||
|
extern void *rtext_tmap2_start, *rtext_tmap2_end;
|
||||||
|
extern void *rtext_tmap3_start, *rtext_tmap3_end;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void unprotect_pages(long pagesize, void *start, void *end)
|
||||||
|
{
|
||||||
|
char *page = (char *)((intptr_t)start & ~(pagesize - 1));
|
||||||
|
size_t len = (char *)end - (char *)start;
|
||||||
|
if (mprotect(page, len, PROT_READ|PROT_WRITE|PROT_EXEC) != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "mprotect failed\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void unprotect_rtext()
|
||||||
|
{
|
||||||
|
static void *const pages[] =
|
||||||
|
{
|
||||||
|
rtext_a_start, rtext_a_end,
|
||||||
|
rtext_tmap_start, rtext_tmap_end,
|
||||||
|
rtext_tmap2_start, rtext_tmap2_end,
|
||||||
|
rtext_tmap3_start, rtext_tmap3_end
|
||||||
|
};
|
||||||
|
long pagesize = sysconf(_SC_PAGESIZE);
|
||||||
|
for (void *const *p = pages; p < &pages[countof(pages)]; p += 2)
|
||||||
|
{
|
||||||
|
unprotect_pages(pagesize, p[0], p[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
printf(GAMENAME" v%s - SVN revision %s - SDL version\nCompiled on %s\n\n",
|
printf(GAMENAME" v%s - SVN revision %s - SDL version\nCompiled on %s\n\n",
|
||||||
|
@ -214,6 +258,10 @@ int main (int argc, char **argv)
|
||||||
seteuid (getuid ());
|
seteuid (getuid ());
|
||||||
std::set_new_handler (NewFailure);
|
std::set_new_handler (NewFailure);
|
||||||
|
|
||||||
|
#if defined(__MACH__) && !defined(NOASM)
|
||||||
|
unprotect_rtext();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef NO_GTK
|
#ifndef NO_GTK
|
||||||
GtkAvailable = gtk_init_check (&argc, &argv);
|
GtkAvailable = gtk_init_check (&argc, &argv);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue