Skip to content

Commit

Permalink
Let the libraries build as native binaries without 32-bit x86 depende…
Browse files Browse the repository at this point in the history
…ncies.

Obviously, this disables lx_loader, but you can compile a C program that
uses OS/2 APIs as a native 64-bit Linux app and run them.

So now we can do 2ine and 2inelib.  :)
  • Loading branch information
icculus committed Feb 28, 2018
1 parent aa8f842 commit 312b87c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
37 changes: 27 additions & 10 deletions CMakeLists.txt
Expand Up @@ -43,6 +43,11 @@ else()
add_definitions(-DRELEASE)
endif()

option(LX_LEGACY "Enable OS/2 binary support (vs just native apps)" TRUE)
if(NOT LX_LEGACY)
add_definitions(-DLX_LEGACY=0)
endif()

add_definitions(-std=c99 -Wall -ggdb3)
add_definitions(-D_FILE_OFFSET_BITS=64)

Expand All @@ -68,29 +73,41 @@ endif()
include_directories("/usr/local/include/SDL2")

add_library(2ine SHARED "lib2ine.c")
set_target_properties(2ine PROPERTIES COMPILE_FLAGS "-m32")
set_target_properties(2ine PROPERTIES LINK_FLAGS "-m32 -ggdb3")
if(LX_LEGACY)
set_target_properties(2ine PROPERTIES COMPILE_FLAGS "-m32")
set_target_properties(2ine PROPERTIES LINK_FLAGS "-m32 -ggdb3")
endif()
target_link_libraries(2ine "pthread")

foreach(_I doscalls;msg;nls;quecalls;viocalls;kbdcalls;sesmgr;som;pmwin;pmshapi;pmgpi;tcpip32)
add_library(${_I} SHARED "native/${_I}.c")
set_target_properties(${_I} PROPERTIES COMPILE_FLAGS "-m32")
set_target_properties(${_I} PROPERTIES LINK_FLAGS "-m32 -ggdb3")
if(LX_LEGACY)
set_target_properties(${_I} PROPERTIES COMPILE_FLAGS "-m32")
set_target_properties(${_I} PROPERTIES LINK_FLAGS "-m32 -ggdb3")
endif()
target_link_libraries(${_I} 2ine)
endforeach()

target_link_libraries(doscalls "pthread")
# FIXME target_link_libraries(viocalls ${CURSES_LIBRARIES})
target_link_libraries(viocalls ncursesw)
target_link_libraries(pmwin "${CMAKE_CURRENT_SOURCE_DIR}/libSDL2-2.0.so.0")

# !!! FIXME: clean this up/
if(LX_LEGACY)
target_link_libraries(pmwin "${CMAKE_CURRENT_SOURCE_DIR}/libSDL2-2.0.so.0")
else()
target_link_libraries(pmwin "SDL2")
endif()

add_executable(lx_dump lx_dump.c)

add_executable(lx_loader lx_loader.c)
target_link_libraries(lx_loader 2ine)
target_link_libraries(lx_loader "dl")
set_target_properties(lx_loader PROPERTIES COMPILE_FLAGS "-m32")
set_target_properties(lx_loader PROPERTIES LINK_FLAGS "-m32 -ggdb3")
if(LX_LEGACY)
add_executable(lx_loader lx_loader.c)
target_link_libraries(lx_loader 2ine)
target_link_libraries(lx_loader "dl")
set_target_properties(lx_loader PROPERTIES COMPILE_FLAGS "-m32")
set_target_properties(lx_loader PROPERTIES LINK_FLAGS "-m32 -ggdb3")
endif()

# end of CMakeLists.txt ...

9 changes: 9 additions & 0 deletions native/doscalls.c
Expand Up @@ -463,6 +463,9 @@ APIRET DosUnsetExceptionHandler(PEXCEPTIONREGISTRATIONRECORD rec)
return NO_ERROR;
} // DosSetExceptionHandler

#if !LX_LEGACY
ULONG DosFlatToSel(VOID) { return 0; }
#else
ULONG _DosFlatToSel(PVOID ptr)
{
TRACE_NATIVE("DosFlatToSel(%p)", ptr);
Expand Down Expand Up @@ -493,6 +496,7 @@ __asm__ (
" ret \n\t"
".size _DosFlatToSel, .-_DosFlatToSel \n\t"
);
#endif

APIRET DosSetSignalExceptionFocus(BOOL32 flag, PULONG pulTimes)
{
Expand Down Expand Up @@ -2710,6 +2714,9 @@ APIRET DosQueryThreadContext(TID tid, ULONG level, PCONTEXTRECORD pcxt)
return ERROR_INVALID_PARAMETER;
} // DosQueryThreadContext

#if !LX_LEGACY
ULONG DosSelToFlat(VOID) { return 0; }
#else
ULONG _DosSelToFlat(void *ptr)
{
TRACE_NATIVE("DosSelToFlat(%p)", ptr);
Expand All @@ -2718,6 +2725,7 @@ ULONG _DosSelToFlat(void *ptr)

// DosSelToFlat() passes its argument in %eax, so a little asm to bridge that...
__asm__ (
// !!! FIXME: this needs to protect more registers.
".globl DosSelToFlat \n\t"
".type DosSelToFlat, @function \n\t"
"DosSelToFlat: \n\t"
Expand All @@ -2727,6 +2735,7 @@ __asm__ (
" ret \n\t"
".size _DosSelToFlat, .-_DosSelToFlat \n\t"
);
#endif

static inline int trySpinLock(int *lock)
{
Expand Down

0 comments on commit 312b87c

Please sign in to comment.