This commit is contained in:
parent
2243a1357d
commit
5f91536a38
2
lib/gc.c
2
lib/gc.c
@ -745,7 +745,7 @@ hcl_oop_t hcl_shallowcopy (hcl_t* hcl, hcl_oop_t oop)
|
|||||||
total_bytes = HCL_SIZEOF(hcl_obj_t) + hcl_getobjpayloadbytes(hcl, oop);
|
total_bytes = HCL_SIZEOF(hcl_obj_t) + hcl_getobjpayloadbytes(hcl, oop);
|
||||||
|
|
||||||
hcl_pushvolat (hcl, &oop);
|
hcl_pushvolat (hcl, &oop);
|
||||||
z = (hcl_oop_t)hcl_allocbytes (hcl, total_bytes);
|
z = (hcl_oop_t)hcl_allocbytes(hcl, total_bytes);
|
||||||
hcl_popvolat(hcl);
|
hcl_popvolat(hcl);
|
||||||
|
|
||||||
HCL_MEMCPY (z, oop, total_bytes);
|
HCL_MEMCPY (z, oop, total_bytes);
|
||||||
|
@ -35,7 +35,10 @@
|
|||||||
# include <hcl-msw.h>
|
# include <hcl-msw.h>
|
||||||
#elif defined(__OS2__)
|
#elif defined(__OS2__)
|
||||||
# include <hcl-os2.h>
|
# include <hcl-os2.h>
|
||||||
#elif defined(__DOS__)
|
#elif defined(__DOS__) || defined(__MSDOS__)
|
||||||
|
# if defined(__MSDOS__) && !defined(__DOS__)
|
||||||
|
# define __DOS__ __MSDOS__
|
||||||
|
# endif
|
||||||
# include <hcl-dos.h>
|
# include <hcl-dos.h>
|
||||||
#elif defined(macintosh)
|
#elif defined(macintosh)
|
||||||
# include <hcl-mac.h> /* classic mac os */
|
# include <hcl-mac.h> /* classic mac os */
|
||||||
@ -756,9 +759,9 @@ typedef void (*hcl_mmgr_free_t) (hcl_mmgr_t* mmgr, void* ptr);
|
|||||||
*/
|
*/
|
||||||
struct hcl_mmgr_t
|
struct hcl_mmgr_t
|
||||||
{
|
{
|
||||||
hcl_mmgr_alloc_t alloc; /**< allocation function */
|
hcl_mmgr_alloc_t allocmem; /**< allocation function */
|
||||||
hcl_mmgr_realloc_t realloc; /**< resizing function */
|
hcl_mmgr_realloc_t reallocmem; /**< resizing function */
|
||||||
hcl_mmgr_free_t free; /**< disposal function */
|
hcl_mmgr_free_t freemem; /**< disposal function */
|
||||||
void* ctx; /**< user-defined data pointer */
|
void* ctx; /**< user-defined data pointer */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -766,18 +769,18 @@ struct hcl_mmgr_t
|
|||||||
* The HCL_MMGR_ALLOC() macro allocates a memory block of the \a size bytes
|
* The HCL_MMGR_ALLOC() macro allocates a memory block of the \a size bytes
|
||||||
* using the \a mmgr memory manager.
|
* using the \a mmgr memory manager.
|
||||||
*/
|
*/
|
||||||
#define HCL_MMGR_ALLOC(mmgr,size) ((mmgr)->alloc(mmgr,size))
|
#define HCL_MMGR_ALLOC(mmgr,size) ((mmgr)->allocmem(mmgr,size))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The HCL_MMGR_REALLOC() macro resizes a memory block pointed to by \a ptr
|
* The HCL_MMGR_REALLOC() macro resizes a memory block pointed to by \a ptr
|
||||||
* to the \a size bytes using the \a mmgr memory manager.
|
* to the \a size bytes using the \a mmgr memory manager.
|
||||||
*/
|
*/
|
||||||
#define HCL_MMGR_REALLOC(mmgr,ptr,size) ((mmgr)->realloc(mmgr,ptr,size))
|
#define HCL_MMGR_REALLOC(mmgr,ptr,size) ((mmgr)->reallocmem(mmgr,ptr,size))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The HCL_MMGR_FREE() macro deallocates the memory block pointed to by \a ptr.
|
* The HCL_MMGR_FREE() macro deallocates the memory block pointed to by \a ptr.
|
||||||
*/
|
*/
|
||||||
#define HCL_MMGR_FREE(mmgr,ptr) ((mmgr)->free(mmgr,ptr))
|
#define HCL_MMGR_FREE(mmgr,ptr) ((mmgr)->freemem(mmgr,ptr))
|
||||||
|
|
||||||
|
|
||||||
/* =========================================================================
|
/* =========================================================================
|
||||||
|
@ -79,7 +79,7 @@
|
|||||||
# define HCL_SIZEOF_MBSTATE_T HCL_SIZEOF_LONG
|
# define HCL_SIZEOF_MBSTATE_T HCL_SIZEOF_LONG
|
||||||
# define HCL_MBLEN_MAX 8
|
# define HCL_MBLEN_MAX 8
|
||||||
|
|
||||||
#elif defined(__TURBOC__)
|
#elif defined(__TURBOC__) || defined(_MSC_VER)
|
||||||
/* TODO: be more version specific wchar_t may be available in newer BCC */
|
/* TODO: be more version specific wchar_t may be available in newer BCC */
|
||||||
# define HCL_SIZEOF_CHAR 1
|
# define HCL_SIZEOF_CHAR 1
|
||||||
# define HCL_SIZEOF_SHORT 2
|
# define HCL_SIZEOF_SHORT 2
|
||||||
|
@ -93,9 +93,9 @@ hcl_heap_t* hcl_makeheap (hcl_t* hcl, hcl_oow_t size)
|
|||||||
return HCL_NULL;
|
return HCL_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
heap->xmmgr.alloc = xma_alloc;
|
heap->xmmgr.allocmem = xma_alloc;
|
||||||
heap->xmmgr.realloc = xma_realloc;
|
heap->xmmgr.reallocmem = xma_realloc;
|
||||||
heap->xmmgr.free = xma_free;
|
heap->xmmgr.freemem = xma_free;
|
||||||
heap->xmmgr.ctx = heap->xma;
|
heap->xmmgr.ctx = heap->xma;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
61
lib/std.c
61
lib/std.c
@ -108,10 +108,14 @@
|
|||||||
# include <fcntl.h>
|
# include <fcntl.h>
|
||||||
# include <conio.h> /* inp, outp */
|
# include <conio.h> /* inp, outp */
|
||||||
|
|
||||||
# if defined(_INTELC32_)
|
|
||||||
# define DOS_EXIT 0x4C
|
# define DOS_EXIT 0x4C
|
||||||
|
# if defined(_INTELC32_)
|
||||||
# include <i32.h>
|
# include <i32.h>
|
||||||
# include <stk.h>
|
# include <stk.h>
|
||||||
|
# elif defined(_MSC_VER)
|
||||||
|
# include <malloc.h>
|
||||||
|
# define malloc(x) halloc(x, 1)
|
||||||
|
# define free(x) hfree(x)
|
||||||
# else
|
# else
|
||||||
# include <dosfunc.h>
|
# include <dosfunc.h>
|
||||||
# endif
|
# endif
|
||||||
@ -413,26 +417,26 @@ struct xtn_t
|
|||||||
* BASIC MEMORY MANAGER
|
* BASIC MEMORY MANAGER
|
||||||
* ----------------------------------------------------------------- */
|
* ----------------------------------------------------------------- */
|
||||||
|
|
||||||
static void* sys_alloc (hcl_mmgr_t* mmgr, hcl_oow_t size)
|
static void* sys_allocmem (hcl_mmgr_t* mmgr, hcl_oow_t size)
|
||||||
{
|
{
|
||||||
return malloc(size);
|
return malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* sys_realloc (hcl_mmgr_t* mmgr, void* ptr, hcl_oow_t size)
|
static void* sys_reallocmem (hcl_mmgr_t* mmgr, void* ptr, hcl_oow_t size)
|
||||||
{
|
{
|
||||||
return realloc(ptr, size);
|
return realloc(ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sys_free (hcl_mmgr_t* mmgr, void* ptr)
|
static void sys_freemem (hcl_mmgr_t* mmgr, void* ptr)
|
||||||
{
|
{
|
||||||
free (ptr);
|
free (ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static hcl_mmgr_t sys_mmgr =
|
static hcl_mmgr_t sys_mmgr =
|
||||||
{
|
{
|
||||||
sys_alloc,
|
sys_allocmem,
|
||||||
sys_realloc,
|
sys_reallocmem,
|
||||||
sys_free,
|
sys_freemem,
|
||||||
HCL_NULL
|
HCL_NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -923,38 +927,6 @@ static void _assertfail (hcl_t* hcl, const hcl_bch_t* expr, const hcl_bch_t* fil
|
|||||||
* SYSTEM DEPENDENT HEADERS
|
* SYSTEM DEPENDENT HEADERS
|
||||||
* -------------------------------------------------------------------------- */
|
* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
# include <windows.h>
|
|
||||||
# include <errno.h>
|
|
||||||
#elif defined(__OS2__)
|
|
||||||
|
|
||||||
# define INCL_DOSERRORS
|
|
||||||
# include <os2.h>
|
|
||||||
#elif defined(__DOS__)
|
|
||||||
# include <dos.h>
|
|
||||||
# if defined(_INTELC32_)
|
|
||||||
# define DOS_EXIT 0x4C
|
|
||||||
# else
|
|
||||||
# include <dosfunc.h>
|
|
||||||
# endif
|
|
||||||
# include <errno.h>
|
|
||||||
#elif defined(vms) || defined(__vms)
|
|
||||||
# define __NEW_STARLET 1
|
|
||||||
# include <starlet.h> /* (SYS$...) */
|
|
||||||
# include <ssdef.h> /* (SS$...) */
|
|
||||||
# include <lib$routines.h> /* (lib$...) */
|
|
||||||
#elif defined(macintosh)
|
|
||||||
# include <MacErrors.h>
|
|
||||||
# include <Process.h>
|
|
||||||
# include <Dialogs.h>
|
|
||||||
# include <TextUtils.h>
|
|
||||||
#else
|
|
||||||
# include <sys/types.h>
|
|
||||||
# include <unistd.h>
|
|
||||||
# include <signal.h>
|
|
||||||
# include <errno.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(HCL_ENABLE_LIBUNWIND)
|
#if defined(HCL_ENABLE_LIBUNWIND)
|
||||||
#include <libunwind.h>
|
#include <libunwind.h>
|
||||||
static void backtrace_stack_frames (hcl_t* hcl)
|
static void backtrace_stack_frames (hcl_t* hcl)
|
||||||
@ -1245,11 +1217,11 @@ void vm_gettime (hcl_t* hcl, hcl_ntime_t* now)
|
|||||||
HCL_INIT_NTIME (now, bigsec, HCL_MSEC_TO_NSEC(bigmsec));
|
HCL_INIT_NTIME (now, bigsec, HCL_MSEC_TO_NSEC(bigmsec));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(__DOS__) && (defined(_INTELC32_) || defined(__WATCOMC__))
|
#elif defined(__DOS__)
|
||||||
clock_t c;
|
clock_t c;
|
||||||
|
|
||||||
/* TODO: handle overflow?? */
|
/* TODO: handle overflow?? */
|
||||||
c = clock ();
|
c = clock();
|
||||||
now->sec = c / CLOCKS_PER_SEC;
|
now->sec = c / CLOCKS_PER_SEC;
|
||||||
#if (CLOCKS_PER_SEC == 100)
|
#if (CLOCKS_PER_SEC == 100)
|
||||||
now->nsec = HCL_MSEC_TO_NSEC((c % CLOCKS_PER_SEC) * 10);
|
now->nsec = HCL_MSEC_TO_NSEC((c % CLOCKS_PER_SEC) * 10);
|
||||||
@ -2277,6 +2249,8 @@ static void vm_muxwait (hcl_t* hcl, const hcl_ntime_t* dur, hcl_vmprim_muxwait_c
|
|||||||
# elif defined(__WATCOMC__)
|
# elif defined(__WATCOMC__)
|
||||||
void _halt_cpu (void);
|
void _halt_cpu (void);
|
||||||
# pragma aux _halt_cpu = "hlt"
|
# pragma aux _halt_cpu = "hlt"
|
||||||
|
# elif defined(_MSC_VER)
|
||||||
|
static void _halt_cpu (void) { _asm { hlt } }
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2307,7 +2281,7 @@ static int vm_sleep (hcl_t* hcl, const hcl_ntime_t* dur)
|
|||||||
|
|
||||||
/* TODO: ... */
|
/* TODO: ... */
|
||||||
|
|
||||||
#elif defined(__DOS__) && (defined(_INTELC32_) || defined(__WATCOMC__))
|
#elif defined(__DOS__)
|
||||||
|
|
||||||
clock_t c;
|
clock_t c;
|
||||||
|
|
||||||
@ -2862,6 +2836,9 @@ static int open_pipes (hcl_t* hcl, int p[2])
|
|||||||
hcl_seterrbfmtwithsyserr (hcl, 2, sock_errno(), "unable to create pipes");
|
hcl_seterrbfmtwithsyserr (hcl, 2, sock_errno(), "unable to create pipes");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#elif defined(__DOS__)
|
||||||
|
hcl_seterrbfmt (hcl, HCL_ENOIMPL, "unable to create pipes - not supported");
|
||||||
|
return -1;
|
||||||
#elif defined(HAVE_PIPE2) && defined(O_CLOEXEC) && defined(O_NONBLOCK)
|
#elif defined(HAVE_PIPE2) && defined(O_CLOEXEC) && defined(O_NONBLOCK)
|
||||||
if (pipe2(p, O_CLOEXEC | O_NONBLOCK) == -1)
|
if (pipe2(p, O_CLOEXEC | O_NONBLOCK) == -1)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user