some more code cleanup
This commit is contained in:
parent
a20587537e
commit
9f89bd7c1b
16
bin/main.c
16
bin/main.c
@ -24,8 +24,9 @@
|
|||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "hcl-prv.h"
|
#include <hcl.h>
|
||||||
#include "hcl-opt.h"
|
#include <hcl-utl.h>
|
||||||
|
#include <hcl-opt.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -47,6 +48,7 @@
|
|||||||
# define INCL_DOSPROCESS
|
# define INCL_DOSPROCESS
|
||||||
# define INCL_DOSERRORS
|
# define INCL_DOSERRORS
|
||||||
# include <os2.h>
|
# include <os2.h>
|
||||||
|
# include <signal.h>
|
||||||
|
|
||||||
#elif defined(__DOS__)
|
#elif defined(__DOS__)
|
||||||
# include <dos.h>
|
# include <dos.h>
|
||||||
@ -91,7 +93,7 @@ struct xtn_t
|
|||||||
|
|
||||||
int vm_running;
|
int vm_running;
|
||||||
int reader_istty;
|
int reader_istty;
|
||||||
hcl_oop_t sym_errstr;
|
/*hcl_oop_t sym_errstr;*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -424,7 +426,7 @@ static void vm_checkbc (hcl_t* hcl, hcl_oob_t bcode)
|
|||||||
static void gc_hcl (hcl_t* hcl)
|
static void gc_hcl (hcl_t* hcl)
|
||||||
{
|
{
|
||||||
xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);
|
xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);
|
||||||
if (xtn->sym_errstr) xtn->sym_errstr = hcl_moveoop(hcl, xtn->sym_errstr);
|
/*if (xtn->sym_errstr) xtn->sym_errstr = hcl_moveoop(hcl, xtn->sym_errstr);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
@ -807,6 +809,7 @@ int main (int argc, char* argv[])
|
|||||||
goto oops;
|
goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
{
|
{
|
||||||
hcl_ooch_t errstr[] = { 'E', 'R', 'R', 'S', 'T', 'R' };
|
hcl_ooch_t errstr[] = { 'E', 'R', 'R', 'S', 'T', 'R' };
|
||||||
xtn->sym_errstr = hcl_makesymbol(hcl, errstr, 6);
|
xtn->sym_errstr = hcl_makesymbol(hcl, errstr, 6);
|
||||||
@ -817,6 +820,7 @@ int main (int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
HCL_OBJ_SET_FLAGS_KERNEL (xtn->sym_errstr, 1);
|
HCL_OBJ_SET_FLAGS_KERNEL (xtn->sym_errstr, 1);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/* -- from this point onward, any failure leads to jumping to the oops label
|
/* -- from this point onward, any failure leads to jumping to the oops label
|
||||||
* -- instead of returning -1 immediately. --*/
|
* -- instead of returning -1 immediately. --*/
|
||||||
@ -913,7 +917,7 @@ count++;
|
|||||||
hcl_decode (hcl, 0, hcl_getbclen(hcl));
|
hcl_decode (hcl, 0, hcl_getbclen(hcl));
|
||||||
HCL_LOG0 (hcl, HCL_LOG_MNEMONIC, "------------------------------------------\n");
|
HCL_LOG0 (hcl, HCL_LOG_MNEMONIC, "------------------------------------------\n");
|
||||||
g_hcl = hcl;
|
g_hcl = hcl;
|
||||||
//setup_tick ();
|
/*setup_tick ();*/
|
||||||
|
|
||||||
retv = hcl_execute(hcl);
|
retv = hcl_execute(hcl);
|
||||||
|
|
||||||
@ -940,7 +944,7 @@ count++;
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
//cancel_tick();
|
/*cancel_tick();*/
|
||||||
g_hcl = HCL_NULL;
|
g_hcl = HCL_NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,9 @@
|
|||||||
# if !defined(HAVE_SNPRINTF)
|
# if !defined(HAVE_SNPRINTF)
|
||||||
# define HAVE_SNPRINTF
|
# define HAVE_SNPRINTF
|
||||||
# endif
|
# endif
|
||||||
|
# if defined(__OS2__) && defined(__BORLANDC__)
|
||||||
|
# undef HAVE_SNPRINTF
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_QUADMATH_H)
|
#if defined(HAVE_QUADMATH_H)
|
||||||
# include <quadmath.h> /* for quadmath_snprintf() */
|
# include <quadmath.h> /* for quadmath_snprintf() */
|
||||||
@ -87,7 +90,7 @@
|
|||||||
* hcl_intmax_t in base 2, plus NUL byte. */
|
* hcl_intmax_t in base 2, plus NUL byte. */
|
||||||
#define MAXNBUF (HCL_SIZEOF(hcl_intmax_t) * HCL_BITS_PER_BYTE + 1)
|
#define MAXNBUF (HCL_SIZEOF(hcl_intmax_t) * HCL_BITS_PER_BYTE + 1)
|
||||||
|
|
||||||
enum
|
enum fmt_spec_t
|
||||||
{
|
{
|
||||||
/* integer */
|
/* integer */
|
||||||
LF_C = (1 << 0),
|
LF_C = (1 << 0),
|
||||||
|
@ -32,15 +32,15 @@
|
|||||||
/*#define HCL_HAVE_CFG_H*/
|
/*#define HCL_HAVE_CFG_H*/
|
||||||
|
|
||||||
#if defined(HCL_HAVE_CFG_H)
|
#if defined(HCL_HAVE_CFG_H)
|
||||||
# include "hcl-cfg.h"
|
# include <hcl-cfg.h>
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
# 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__)
|
||||||
# include "hcl-dos.h"
|
# include <hcl-dos.h>
|
||||||
#elif defined(macintosh)
|
#elif defined(macintosh)
|
||||||
# include "hcl-mac.h" /* class mac os */
|
# include <hcl-mac.h> /* classic mac os */
|
||||||
#else
|
#else
|
||||||
# error UNSUPPORTED SYSTEM
|
# error UNSUPPORTED SYSTEM
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#ifndef _HCL_FMT_H_
|
#ifndef _HCL_FMT_H_
|
||||||
#define _HCL_FMT_H_
|
#define _HCL_FMT_H_
|
||||||
|
|
||||||
#include "hcl-cmn.h"
|
#include <hcl-cmn.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
/** \file
|
/** \file
|
||||||
|
@ -1347,7 +1347,6 @@ hcl_cnode_t* hcl_makecnodecons (hcl_t* hcl, const hcl_ioloc_t* loc, hcl_cnode_t*
|
|||||||
hcl_cnode_t* hcl_makecnodeelist (hcl_t* hcl, const hcl_ioloc_t* loc, hcl_concode_t type);
|
hcl_cnode_t* hcl_makecnodeelist (hcl_t* hcl, const hcl_ioloc_t* loc, hcl_concode_t type);
|
||||||
hcl_cnode_t* hcl_makecnodeshell (hcl_t* hcl, const hcl_ioloc_t* loc, hcl_cnode_t* obj);
|
hcl_cnode_t* hcl_makecnodeshell (hcl_t* hcl, const hcl_ioloc_t* loc, hcl_cnode_t* obj);
|
||||||
void hcl_freesinglecnode (hcl_t* hcl, hcl_cnode_t* c);
|
void hcl_freesinglecnode (hcl_t* hcl, hcl_cnode_t* c);
|
||||||
void hcl_freecnode (hcl_t* hcl, hcl_cnode_t* c);
|
|
||||||
hcl_oow_t hcl_countcnodecons (hcl_t* hcl, hcl_cnode_t* cons);
|
hcl_oow_t hcl_countcnodecons (hcl_t* hcl, hcl_cnode_t* cons);
|
||||||
|
|
||||||
|
|
||||||
|
18
lib/hcl.h
18
lib/hcl.h
@ -1992,6 +1992,10 @@ HCL_EXPORT hcl_cnode_t* hcl_read (
|
|||||||
hcl_t* hcl
|
hcl_t* hcl
|
||||||
);
|
);
|
||||||
|
|
||||||
|
HCL_EXPORT void hcl_freecnode (
|
||||||
|
hcl_t* hcl,
|
||||||
|
hcl_cnode_t* cnode
|
||||||
|
);
|
||||||
|
|
||||||
HCL_EXPORT int hcl_print (
|
HCL_EXPORT int hcl_print (
|
||||||
hcl_t* hcl,
|
hcl_t* hcl,
|
||||||
@ -2324,13 +2328,6 @@ HCL_EXPORT hcl_oop_t hcl_makebigint (
|
|||||||
hcl_oow_t len
|
hcl_oow_t len
|
||||||
);
|
);
|
||||||
|
|
||||||
#if (HCL_SIZEOF_UINTMAX_T == HCL_SIZEOF_OOW_T)
|
|
||||||
# define hcl_inttouintmax hcl_inttooow
|
|
||||||
# define hcl_inttointmax hcl_inttoooi
|
|
||||||
# define hcl_uintmaxtoint hcl_oowtoint
|
|
||||||
# define hcl_intmaxtoint hcl_ooitoint
|
|
||||||
#else
|
|
||||||
|
|
||||||
HCL_EXPORT hcl_oop_t hcl_oowtoint (
|
HCL_EXPORT hcl_oop_t hcl_oowtoint (
|
||||||
hcl_t* hcl,
|
hcl_t* hcl,
|
||||||
hcl_oow_t w
|
hcl_oow_t w
|
||||||
@ -2353,6 +2350,13 @@ HCL_EXPORT int hcl_inttoooi (
|
|||||||
hcl_ooi_t* i
|
hcl_ooi_t* i
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#if (HCL_SIZEOF_UINTMAX_T == HCL_SIZEOF_OOW_T)
|
||||||
|
# define hcl_inttouintmax hcl_inttooow
|
||||||
|
# define hcl_inttointmax hcl_inttoooi
|
||||||
|
# define hcl_uintmaxtoint hcl_oowtoint
|
||||||
|
# define hcl_intmaxtoint hcl_ooitoint
|
||||||
|
#else
|
||||||
|
|
||||||
HCL_EXPORT hcl_oop_t hcl_intmaxtoint (
|
HCL_EXPORT hcl_oop_t hcl_intmaxtoint (
|
||||||
hcl_t* hcl,
|
hcl_t* hcl,
|
||||||
hcl_intmax_t i
|
hcl_intmax_t i
|
||||||
|
34
lib/std.c
34
lib/std.c
@ -283,6 +283,7 @@ struct xtn_t
|
|||||||
DWORD tc_overflow;
|
DWORD tc_overflow;
|
||||||
#elif defined(__OS2__)
|
#elif defined(__OS2__)
|
||||||
ULONG tc_last;
|
ULONG tc_last;
|
||||||
|
ULONG tc_overflow;
|
||||||
hcl_ntime_t tc_last_ret;
|
hcl_ntime_t tc_last_ret;
|
||||||
#elif defined(__DOS__)
|
#elif defined(__DOS__)
|
||||||
clock_t tc_last;
|
clock_t tc_last;
|
||||||
@ -1122,9 +1123,11 @@ void vm_gettime (hcl_t* hcl, hcl_ntime_t* now)
|
|||||||
|
|
||||||
#elif defined(__OS2__)
|
#elif defined(__OS2__)
|
||||||
xtn_t* xtn = GET_XTN(hcl);
|
xtn_t* xtn = GET_XTN(hcl);
|
||||||
hcl_uint64_t bigsec, bigmsec;
|
|
||||||
ULONG msec;
|
ULONG msec;
|
||||||
|
|
||||||
|
#if (HCL_SIZEOF_UINT64_T > 0)
|
||||||
|
hcl_uint64_t bigsec, bigmsec;
|
||||||
|
|
||||||
/* TODO: use DosTmrQueryTime() and DosTmrQueryFreq()? */
|
/* TODO: use DosTmrQueryTime() and DosTmrQueryFreq()? */
|
||||||
DosQuerySysInfo (QSV_MS_COUNT, QSV_MS_COUNT, &msec, HCL_SIZEOF(msec)); /* milliseconds */
|
DosQuerySysInfo (QSV_MS_COUNT, QSV_MS_COUNT, &msec, HCL_SIZEOF(msec)); /* milliseconds */
|
||||||
/* it must return NO_ERROR */
|
/* it must return NO_ERROR */
|
||||||
@ -1139,6 +1142,32 @@ void vm_gettime (hcl_t* hcl, hcl_ntime_t* now)
|
|||||||
bigsec = HCL_MSEC_TO_SEC(bigmsec);
|
bigsec = HCL_MSEC_TO_SEC(bigmsec);
|
||||||
bigmsec -= HCL_SEC_TO_MSEC(bigsec);
|
bigmsec -= HCL_SEC_TO_MSEC(bigsec);
|
||||||
HCL_INIT_NTIME (now, bigsec, HCL_MSEC_TO_NSEC(bigmsec));
|
HCL_INIT_NTIME (now, bigsec, HCL_MSEC_TO_NSEC(bigmsec));
|
||||||
|
#else
|
||||||
|
hcl_uint32_t bigsec, bigmsec;
|
||||||
|
|
||||||
|
DosQuerySysInfo (QSV_MS_COUNT, QSV_MS_COUNT, &msec, HCL_SIZEOF(msec));
|
||||||
|
bigsec = HCL_MSEC_TO_SEC(msec);
|
||||||
|
bigmsec = msec - HCL_SEC_TO_MSEC(bigsec);
|
||||||
|
if (msec < xtn->tc_last)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
hcl_uint32_t inc;
|
||||||
|
|
||||||
|
xtn->tc_overflow++;
|
||||||
|
inc = HCL_MSEC_TO_SEC(HCL_TYPE_MAX(hcl_uint32_t));
|
||||||
|
for (i = 0; i < xtn->tc_overflow; i++)
|
||||||
|
{
|
||||||
|
ULONG max = HCL_TYPE_MAX(hcl_uint32_t) - bigsec;
|
||||||
|
if (max > inc)
|
||||||
|
{
|
||||||
|
bigsec = HCL_TYPE_MAX(hcl_uint32_t);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bigsec += inc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HCL_INIT_NTIME (now, bigsec, HCL_MSEC_TO_NSEC(bigmsec));
|
||||||
|
#endif
|
||||||
|
|
||||||
#elif defined(__DOS__) && (defined(_INTELC32_) || defined(__WATCOMC__))
|
#elif defined(__DOS__) && (defined(_INTELC32_) || defined(__WATCOMC__))
|
||||||
clock_t c;
|
clock_t c;
|
||||||
@ -2679,6 +2708,8 @@ static int open_pipes (hcl_t* hcl, int p[2])
|
|||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
if (_pipe(p, 256, _O_BINARY | _O_NOINHERIT) == -1)
|
if (_pipe(p, 256, _O_BINARY | _O_NOINHERIT) == -1)
|
||||||
|
#elif defined(__OS2__)
|
||||||
|
if (_pipe(p, 256, 10) == -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)
|
||||||
#else
|
#else
|
||||||
@ -2708,6 +2739,7 @@ static int open_pipes (hcl_t* hcl, int p[2])
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void close_pipes (hcl_t* hcl, int p[2])
|
static void close_pipes (hcl_t* hcl, int p[2])
|
||||||
{
|
{
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user