fixed a few syntax issues with some old compilers.
added some code for os2
This commit is contained in:
parent
4a73109340
commit
b99f66996a
@ -47,11 +47,21 @@
|
|||||||
#elif defined(__OS2__)
|
#elif defined(__OS2__)
|
||||||
# define INCL_DOSMODULEMGR
|
# define INCL_DOSMODULEMGR
|
||||||
# define INCL_DOSPROCESS
|
# define INCL_DOSPROCESS
|
||||||
|
# define INCL_DOSEXCEPTIONS
|
||||||
# define INCL_DOSMISC
|
# define INCL_DOSMISC
|
||||||
# define INCL_DOSDATETIME
|
# define INCL_DOSDATETIME
|
||||||
# define INCL_DOSERRORS
|
# define INCL_DOSERRORS
|
||||||
# include <os2.h>
|
# include <os2.h>
|
||||||
# include <time.h>
|
# include <time.h>
|
||||||
|
# include <fcntl.h>
|
||||||
|
# include <io.h>
|
||||||
|
|
||||||
|
/* fake XPOLLXXX values */
|
||||||
|
# define XPOLLIN (1 << 0)
|
||||||
|
# define XPOLLOUT (1 << 1)
|
||||||
|
# define XPOLLERR (1 << 2)
|
||||||
|
# define XPOLLHUP (1 << 3)
|
||||||
|
|
||||||
#elif defined(__DOS__)
|
#elif defined(__DOS__)
|
||||||
# include <dos.h>
|
# include <dos.h>
|
||||||
# include <time.h>
|
# include <time.h>
|
||||||
@ -213,8 +223,8 @@ struct xtn_t
|
|||||||
const char* source_path; /* main source file */
|
const char* source_path; /* main source file */
|
||||||
int vm_running;
|
int vm_running;
|
||||||
|
|
||||||
int logfd;
|
|
||||||
moo_bitmask_t logmask;
|
moo_bitmask_t logmask;
|
||||||
|
int logfd;
|
||||||
int logfd_istty;
|
int logfd_istty;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
@ -546,7 +556,7 @@ static void free_heap (moo_t* moo, void* ptr)
|
|||||||
actual_ptr = (moo_oow_t*)ptr - 1;
|
actual_ptr = (moo_oow_t*)ptr - 1;
|
||||||
munmap (actual_ptr, *actual_ptr);
|
munmap (actual_ptr, *actual_ptr);
|
||||||
#else
|
#else
|
||||||
return MOO_MMGR_FREE(moo->mmgr, ptr);
|
MOO_MMGR_FREE(moo->mmgr, ptr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,6 +568,7 @@ static void free_heap (moo_t* moo, void* ptr)
|
|||||||
/* nothing to do */
|
/* nothing to do */
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static int write_all (int fd, const moo_bch_t* ptr, moo_oow_t len)
|
static int write_all (int fd, const moo_bch_t* ptr, moo_oow_t len)
|
||||||
{
|
{
|
||||||
while (len > 0)
|
while (len > 0)
|
||||||
@ -679,7 +690,6 @@ static void log_write (moo_t* moo, moo_bitmask_t mask, const moo_ooch_t* msg, mo
|
|||||||
if (mask & MOO_LOG_STDOUT) logfd = 1;
|
if (mask & MOO_LOG_STDOUT) logfd = 1;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
logfd = xtn->logfd;
|
logfd = xtn->logfd;
|
||||||
if (logfd <= -1) return;
|
if (logfd <= -1) return;
|
||||||
}
|
}
|
||||||
@ -703,8 +713,12 @@ static void log_write (moo_t* moo, moo_bitmask_t mask, const moo_ooch_t* msg, mo
|
|||||||
strcpy (ts, "0000-00-00 00:00:00 ");
|
strcpy (ts, "0000-00-00 00:00:00 ");
|
||||||
tslen = 20;
|
tslen = 20;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#if defined(__OS2__)
|
||||||
|
tmp = _localtime(&now, &tm);
|
||||||
#else
|
#else
|
||||||
tmp = localtime_r(&now, &tm);
|
tmp = localtime_r(&now, &tm);
|
||||||
|
#endif
|
||||||
#if defined(HAVE_STRFTIME_SMALL_Z)
|
#if defined(HAVE_STRFTIME_SMALL_Z)
|
||||||
tslen = strftime (ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp);
|
tslen = strftime (ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp);
|
||||||
#else
|
#else
|
||||||
@ -2091,6 +2105,9 @@ static void setup_tick (void)
|
|||||||
prev_timer_intr_handler = _dos_getvect (0x1C);
|
prev_timer_intr_handler = _dos_getvect (0x1C);
|
||||||
_dos_setvect (0x1C, timer_intr_handler);
|
_dos_setvect (0x1C, timer_intr_handler);
|
||||||
|
|
||||||
|
#elif defined(__OS2__)
|
||||||
|
/* TODO: */
|
||||||
|
|
||||||
#elif defined(macintosh)
|
#elif defined(macintosh)
|
||||||
|
|
||||||
GetCurrentProcess (&g_psn);
|
GetCurrentProcess (&g_psn);
|
||||||
@ -2127,6 +2144,9 @@ static void cancel_tick (void)
|
|||||||
|
|
||||||
_dos_setvect (0x1C, prev_timer_intr_handler);
|
_dos_setvect (0x1C, prev_timer_intr_handler);
|
||||||
|
|
||||||
|
#elif defined(__OS2__)
|
||||||
|
|
||||||
|
/* TODO: */
|
||||||
#elif defined(macintosh)
|
#elif defined(macintosh)
|
||||||
RmvTime ((QElem*)&g_tmtask);
|
RmvTime ((QElem*)&g_tmtask);
|
||||||
/*DisposeTimerProc (g_tmtask.tmAddr);*/
|
/*DisposeTimerProc (g_tmtask.tmAddr);*/
|
||||||
@ -2151,7 +2171,7 @@ static void cancel_tick (void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_term (int sig)
|
static MOO_INLINE void abort_moo (void)
|
||||||
{
|
{
|
||||||
if (g_moo)
|
if (g_moo)
|
||||||
{
|
{
|
||||||
@ -2163,12 +2183,61 @@ static void handle_term (int sig)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
static BOOL WINAPI handle_term (DWORD ctrl_type)
|
||||||
|
{
|
||||||
|
if (ctrl_type == CTRL_C_EVENT ||
|
||||||
|
ctrl_type == CTRL_CLOSE_EVENT)
|
||||||
|
{
|
||||||
|
abort_moo ();
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(__OS2__)
|
||||||
|
static EXCEPTIONREGISTRATIONRECORD os2_excrr = { 0 };
|
||||||
|
|
||||||
|
static ULONG _System handle_term (
|
||||||
|
PEXCEPTIONREPORTRECORD p1,
|
||||||
|
PEXCEPTIONREGISTRATIONRECORD p2,
|
||||||
|
PCONTEXTRECORD p3,
|
||||||
|
PVOID pv)
|
||||||
|
{
|
||||||
|
if (p1->ExceptionNum == XCPT_SIGNAL)
|
||||||
|
{
|
||||||
|
if (p1->ExceptionInfo[0] == XCPT_SIGNAL_INTR ||
|
||||||
|
p1->ExceptionInfo[0] == XCPT_SIGNAL_KILLPROC ||
|
||||||
|
p1->ExceptionInfo[0] == XCPT_SIGNAL_BREAK)
|
||||||
|
{
|
||||||
|
APIRET rc;
|
||||||
|
|
||||||
|
abort_moo ();
|
||||||
|
|
||||||
|
rc = DosAcknowledgeSignalException (p1->ExceptionInfo[0]);
|
||||||
|
return (rc != NO_ERROR)? 1: XCPT_CONTINUE_EXECUTION;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return XCPT_CONTINUE_SEARCH; /* exception not resolved */
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
static void handle_term (int sig)
|
||||||
|
{
|
||||||
|
abort_moo ();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static void setup_sigterm (void)
|
static void setup_sigterm (void)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
SetConsoleCtrlHandler (handle_term, TRUE);
|
SetConsoleCtrlHandler (handle_term, TRUE);
|
||||||
#elif defined(__OS2__)
|
#elif defined(__OS2__)
|
||||||
os2_excrr.ExceptionHandler = (ERR)__intr_handler;
|
os2_excrr.ExceptionHandler = (ERR)handle_term;
|
||||||
DosSetExceptionHandler (&os2_excrr); /* TODO: check if NO_ERROR is returned */
|
DosSetExceptionHandler (&os2_excrr); /* TODO: check if NO_ERROR is returned */
|
||||||
#elif defined(__DOS__)
|
#elif defined(__DOS__)
|
||||||
signal (SIGINT, handle_term);
|
signal (SIGINT, handle_term);
|
||||||
|
@ -23,6 +23,10 @@
|
|||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define MOO_ENABLE_STATIC_MODULE
|
||||||
|
#define MOO_ENABLE_DYNAMIC_MODULE
|
||||||
|
|
||||||
/* OS/2 for other platforms than x86?
|
/* OS/2 for other platforms than x86?
|
||||||
* If so, the endian should be defined selectively
|
* If so, the endian should be defined selectively
|
||||||
*/
|
*/
|
||||||
|
@ -89,7 +89,7 @@ static void* alloc_heap (moo_t* moo, moo_oow_t size)
|
|||||||
|
|
||||||
static void free_heap (moo_t* moo, void* ptr)
|
static void free_heap (moo_t* moo, void* ptr)
|
||||||
{
|
{
|
||||||
return MOO_MMGR_FREE(moo->mmgr, ptr);
|
MOO_MMGR_FREE(moo->mmgr, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int moo_init (moo_t* moo, moo_mmgr_t* mmgr, moo_oow_t heapsz, const moo_vmprim_t* vmprim)
|
int moo_init (moo_t* moo, moo_mmgr_t* mmgr, moo_oow_t heapsz, const moo_vmprim_t* vmprim)
|
||||||
|
@ -2214,14 +2214,14 @@ MOO_EXPORT moo_bch_t* moo_dupbchars (
|
|||||||
|
|
||||||
MOO_EXPORT moo_ooi_t moo_logbfmt (
|
MOO_EXPORT moo_ooi_t moo_logbfmt (
|
||||||
moo_t* moo,
|
moo_t* moo,
|
||||||
moo_log_mask_t mask,
|
moo_bitmask_t mask,
|
||||||
const moo_bch_t* fmt,
|
const moo_bch_t* fmt,
|
||||||
...
|
...
|
||||||
);
|
);
|
||||||
|
|
||||||
MOO_EXPORT moo_ooi_t moo_logufmt (
|
MOO_EXPORT moo_ooi_t moo_logufmt (
|
||||||
moo_t* moo,
|
moo_t* moo,
|
||||||
moo_log_mask_t mask,
|
moo_bitmask_t mask,
|
||||||
const moo_uch_t* fmt,
|
const moo_uch_t* fmt,
|
||||||
...
|
...
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user