9front - general discussion about 9front
 help / color / mirror / Atom feed
* Re: [9front] adding javascript enable to netsurf
@ 2020-03-13  4:33 kokamoto
  2020-03-13  4:58 ` ori
  0 siblings, 1 reply; 48+ messages in thread
From: kokamoto @ 2020-03-13  4:33 UTC (permalink / raw)
  To: 9front

> However, I'm now running it on 1GB rpi3, it corrupted.
> I'll compile netsurf on a 386 machine tommorrow.

I did it.
term% ls -l 8.nsfb
--rwxr-xr-x M 26 kokamoto kokamoto 46841407 Mar 13 11:20 8.nsfb

It's worse...

I got:
term% ./8.nsfb
INITING display!
8.nsfb 51407: suicide: sys: fp: invalid operation fppc=0xf8dc6 status=0xb8a3 pc=0x000e5026

I'll take a rest, and investigate what's going on here.

Kenji



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-13  4:33 [9front] adding javascript enable to netsurf kokamoto
@ 2020-03-13  4:58 ` ori
  0 siblings, 0 replies; 48+ messages in thread
From: ori @ 2020-03-13  4:58 UTC (permalink / raw)
  To: kokamoto, 9front

>> However, I'm now running it on 1GB rpi3, it corrupted.
>> I'll compile netsurf on a 386 machine tommorrow.
> 
> I did it.
> term% ls -l 8.nsfb
> --rwxr-xr-x M 26 kokamoto kokamoto 46841407 Mar 13 11:20 8.nsfb
> 
> It's worse...
> 
> I got:
> term% ./8.nsfb
> INITING display!
> 8.nsfb 51407: suicide: sys: fp: invalid operation fppc=0xf8dc6 status=0xb8a3 pc=0x000e5026
> 
> I'll take a rest, and investigate what's going on here.
> 
> Kenji

Plan 9 is stricter about floating point operations like division by zero. It can
be made to behave more like Unix by calling setfcr at the start of the program.
I think something like:

	setfcr(getfcr() & ~(FPINVAL|FPZDIV|FPOVFL));

will do the job.



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-04-18 17:11           ` Eli Cohen
  2020-04-18 17:15             ` telephil9
@ 2020-04-18 17:17             ` ori
  1 sibling, 0 replies; 48+ messages in thread
From: ori @ 2020-04-18 17:17 UTC (permalink / raw)
  To: echoline, 9front

> when I build the latest netsurf port, it gets stuck in a loop of
> fetching and loading, and never loads a page. what am I doing wrong?

sl_ ran into this too the other day -- we were missing a dependency
between 'mk install' and 'mk 9res', so we never actually copied the
data files it needs to run.

'mk 9res; mk install' will probably fix it.



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-04-18 17:11           ` Eli Cohen
@ 2020-04-18 17:15             ` telephil9
  2020-04-18 17:17             ` ori
  1 sibling, 0 replies; 48+ messages in thread
From: telephil9 @ 2020-04-18 17:15 UTC (permalink / raw)
  To: 9front

call 'mk 9res' before 'mk install'



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-04-18  1:19         ` ori
@ 2020-04-18 17:11           ` Eli Cohen
  2020-04-18 17:15             ` telephil9
  2020-04-18 17:17             ` ori
  0 siblings, 2 replies; 48+ messages in thread
From: Eli Cohen @ 2020-04-18 17:11 UTC (permalink / raw)
  To: 9front

when I build the latest netsurf port, it gets stuck in a loop of
fetching and loading, and never loads a page. what am I doing wrong?

On Fri, Apr 17, 2020 at 6:20 PM <ori@eigenstate.org> wrote:
>
> > Thanks, Ori.
> >
> > I nuked everything and rebuilt. Had to delete all the netsurf Lin directories and re-fetch too.
> >
> > It seems weird to me that syntax errors arise from old compilations, not linker errors. Are we doing code generation?
> >
> > Anyway, I have it building now. Thanks!
>
> I'm not sure why you're getting syntax errors; you shouldn't be. I'd have to glare
> at the preprocessed source to find out.
>


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-04-18  1:09       ` Kyle Nusbaum
@ 2020-04-18  1:19         ` ori
  2020-04-18 17:11           ` Eli Cohen
  0 siblings, 1 reply; 48+ messages in thread
From: ori @ 2020-04-18  1:19 UTC (permalink / raw)
  To: knusbaum, ori, jamos, 9front

> Thanks, Ori. 
> 
> I nuked everything and rebuilt. Had to delete all the netsurf Lin directories and re-fetch too.
> 
> It seems weird to me that syntax errors arise from old compilations, not linker errors. Are we doing code generation?
> 
> Anyway, I have it building now. Thanks!

I'm not sure why you're getting syntax errors; you shouldn't be. I'd have to glare
at the preprocessed source to find out.



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-04-15 20:24     ` ori
@ 2020-04-18  1:09       ` Kyle Nusbaum
  2020-04-18  1:19         ` ori
  0 siblings, 1 reply; 48+ messages in thread
From: Kyle Nusbaum @ 2020-04-18  1:09 UTC (permalink / raw)
  To: ori, jamos, 9front

Thanks, Ori. 

I nuked everything and rebuilt. Had to delete all the netsurf Lin directories and re-fetch too.

It seems weird to me that syntax errors arise from old compilations, not linker errors. Are we doing code generation?

Anyway, I have it building now. Thanks!

On April 15, 2020 3:24:39 PM CDT, ori@eigenstate.org wrote:
>> It seems that neither git9, nor netsurf, compiles on this latest 
>> configuration. For git9 I get "incompatible type signatures" (in
>lib9p I 
>> think, not completely sure). In netsurf I get errors in
>duktape.c:1155 
>> that it doesn't recognise the type duk_int64_t
>
>Yeah. That just means that we changed some of the types, but the
>code using them hasn't been recompiled. The commit that changed
>them is probably abeb350f0cb8 or 026c1d87dd3e The answer to that
>error is almost always:
>
>	cd /sys/src
>	mk clean
>	mk all
>
>to rebuild the libraries.

-- Kyle


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-04-15 20:05   ` jamos
@ 2020-04-15 20:24     ` ori
  2020-04-18  1:09       ` Kyle Nusbaum
  0 siblings, 1 reply; 48+ messages in thread
From: ori @ 2020-04-15 20:24 UTC (permalink / raw)
  To: jamos, 9front; +Cc: knusbaum, ori

> It seems that neither git9, nor netsurf, compiles on this latest 
> configuration. For git9 I get "incompatible type signatures" (in lib9p I 
> think, not completely sure). In netsurf I get errors in duktape.c:1155 
> that it doesn't recognise the type duk_int64_t

Yeah. That just means that we changed some of the types, but the
code using them hasn't been recompiled. The commit that changed
them is probably abeb350f0cb8 or 026c1d87dd3e The answer to that
error is almost always:

	cd /sys/src
	mk clean
	mk all

to rebuild the libraries.



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-04-14 21:53 ` Kyle Nusbaum
@ 2020-04-15 20:05   ` jamos
  2020-04-15 20:24     ` ori
  0 siblings, 1 reply; 48+ messages in thread
From: jamos @ 2020-04-15 20:05 UTC (permalink / raw)
  To: 9front; +Cc: knusbaum, ori

I think something happened in 9front. Netsurf compiles well on a "fairly 
recent" install here. So I decided to do a clean install of 7508 "No 
Thinkpad" plus a sysupdate.

It seems that neither git9, nor netsurf, compiles on this latest 
configuration. For git9 I get "incompatible type signatures" (in lib9p I 
think, not completely sure). In netsurf I get errors in duktape.c:1155 
that it doesn't recognise the type duk_int64_t.

So I did another clean install of 7508 this time without making a 
sysupdate. Then git9 compiles, but some other type-related problems 
arise in netsurf, as the current source assumes some changes to 9front 
that happened since 7508.

To answer your question, the installation instructions for netsurf 
hasn't changed. Only that one might need to invoke a 'mk 9res' in 
nsport/netsurf before 'mk install', but that is purely to prepare files 
for run-time, and doesn't affect compiling.

/Jonas

On 2020-04-15 00:53, Kyle Nusbaum wrote:

> I'm getting all kinds of compile errors with a clean checkout of 
> nsport. I'm running an up-to-date 9front and following the instructions 
> in the readme.
> 
> Do we have instructions on how to compile netsurf now?


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-04-14  5:04 kokamoto
@ 2020-04-14 21:53 ` Kyle Nusbaum
  2020-04-15 20:05   ` jamos
  0 siblings, 1 reply; 48+ messages in thread
From: Kyle Nusbaum @ 2020-04-14 21:53 UTC (permalink / raw)
  To: 9front, kokamoto

I'm getting all kinds of compile errors with a clean checkout of nsport. I'm running an up-to-date 9front and following the instructions in the readme. 

Do we have instructions on how to compile netsurf now? 

On April 14, 2020 12:04:01 AM CDT, kokamoto@hera.eonet.ne.jp wrote:
>> For me, the situation is the same as before.
>> ls -l /arm/bin/nsfbJP
>> --rwxrwxr-x M 26 sys sys 28115992 Apr 12 15:08 /arm/bin/nsfbJP
>
>I forgot!
>I didn't update the source tree from git server, because I'm
>changing the sources by myself, which makes me confusue
>if I mixed the other's change...
>
>Kenji

-- Kyle


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-04-14  5:04 kokamoto
  2020-04-14 21:53 ` Kyle Nusbaum
  0 siblings, 1 reply; 48+ messages in thread
From: kokamoto @ 2020-04-14  5:04 UTC (permalink / raw)
  To: 9front

> For me, the situation is the same as before.
> ls -l /arm/bin/nsfbJP
> --rwxrwxr-x M 26 sys sys 28115992 Apr 12 15:08 /arm/bin/nsfbJP

I forgot!
I didn't update the source tree from git server, because I'm
changing the sources by myself, which makes me confusue
if I mixed the other's change...

Kenji



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-04-13 23:46 kokamoto
  0 siblings, 0 replies; 48+ messages in thread
From: kokamoto @ 2020-04-13 23:46 UTC (permalink / raw)
  To: 9front

> Thank you for working with the netsurf port!
> 
> Have you tried a recent 5.nsfb on Rpi? 

For me, the situation is the same as before.
ls -l /arm/bin/nsfbJP
--rwxrwxr-x M 26 sys sys 28115992 Apr 12 15:08 /arm/bin/nsfbJP

As I got rpi4B (4GB) recently (not proper power supply yet), 
I'm abondanning arm (arm pi3B)...
For arm version, I think 
	noembed, script, style, title { display: none; }
in /sys/lib/netsurf/default.css is not recognized right.
However, I cannot point the place it occurs...

Kenji



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-04-06  5:48 kokamoto
@ 2020-04-13 12:44 ` jamos
  0 siblings, 0 replies; 48+ messages in thread
From: jamos @ 2020-04-13 12:44 UTC (permalink / raw)
  To: 9front; +Cc: kokamoto

Dear Kenji,

Thank you for working with the netsurf port!

Have you tried a recent 5.nsfb on Rpi? For me
it works a bit worse than before. It aborts
prematurely while loading any page. With the
help of acid(1) I tracked it down to a call of
free() in nsport/libcss/src/select/select.c:182.
If I uncomment the free() it runs into a loop of
loading and fetching. On 386 all works, and it
does not try to free anything during the build-up
of the page.

Jonas

On 2020-04-06 08:48, kokamoto@hera.eonet.ne.jp wrote:

> For the arm (rpi3B, 1GB), the problem (I reported
> it before) is not solved yet.


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-04-07  4:25 kokamoto
  0 siblings, 0 replies; 48+ messages in thread
From: kokamoto @ 2020-04-07  4:25 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 460 bytes --]

> Those sizes are as follows:
> --rwxrwxr-x M 26 sys sys 51058990 Apr  5 13:15 /386/bin/nsfbjs
> --rwxrwxr-x M 26 sys sys 56575079 Apr  5 13:17 /amd64/bin/nsfbjs
> --rwxrwxr-x M 26 sys sys 50496480 Apr  5 13:12 /arm/bin/nsfbjs

ls -l /arm64/bin/nsfbjs
--rwxrwxr-x M 26 sys sys 57713472 Apr  7 12:13 /arm64/bin/nsfbjs

However, 1GB rpi3B can not deal with this successfully.☺

Included is a polished version ( for using -D_$objtype in mkfile_duktape).

Kenji

[-- Attachment #2: Type: text/plain, Size: 40584 bytes --]

/*
 *  duk_config.h configuration header generated by genconfig.py.
 *
 *  Git commit: external
 *  Git describe: external
 *  Git branch: external
 *
 *  Supported platforms:
 *	- Plan9
 *      - Generic UNIX
 *      - Generic fallback
 *
 *  Supported architectures:
 *      - x86
 *      - x64
  *      - ARM 32-bit
 *      - ARM 64-bit
 
 *  Supported compilers:
 *      - Generic
 *
 */

#if !defined(DUK_CONFIG_H_INCLUDED)
#define DUK_CONFIG_H_INCLUDED

/*
 *  Intermediate helper defines
 */

/* DLL build detection */
/* not configured for DLL build */
#undef DUK_F_DLL_BUILD

/* Plan9 */
#if defined(__plan9ape__)
	#define DUK_F_PLAN9
#endif

/* Intel x86 (32-bit), x64 (64-bit) or x32 (64-bit but 32-bit pointers),
 * define only one of DUK_F_X86, DUK_F_X64, DUK_F_X32.
 * https://sites.google.com/site/x32abi/
 *
 * With DUK_F_OLD_SOLARIS the <sys/isa_defs.h> header must be included
 * before this.
 */
#if defined(_amd64)
	#define DUK_F_X64
#elif defined(_386)
	#define DUK_F_X86
#endif

/* ARM */
#if defined(_arm) || defined(_arm64)
	#define DUK_F_ARM
	#if defined (_arm64)
		#define DUK_F_ARM64
	#else
		#define DUK_F_ARM32
	#endif
#endif

/*************************************
 *  Platform autodetection
 *************************************/
#if defined(DUK_F_PLAN9)
	#define DUK_USE_DATE_NOW_GETTIMEOFDAY
	#define DUK_USE_DATE_TZO_GMTIME_R
	#define DUK_USE_DATE_PRS_STRPTIME
	#define DUK_USE_DATE_FMT_STRFTIME
	#define _REENTRANT_SOURCE
	#define DUK_DOUBLE_INFINITY Inf(1)
	#define DUK_DOUBLE_NAN       (NaN())
	#define DUK_SIZE_MAX SSIZE_MAX
	#define DUK_SINGLE_FILE
	#if defined(_386) || defined(_arm)
		#define DUK_F_32BIT_PTRS
		#if defined(_386)
			#define DUK_USE_INTEGER_LE
			#define DUK_USE_DOUBLE_LE
			#define DUK_USE_ARCH_STRING "x86"
		#else
			#define DUK_USE_INTEGER_LE  	/* integer endianness is little on purpose */
			#define DUK_USE_DOUBLE_ME
			#define DUK_USE_ARCH_STRING "arm32"
		#endif
	#elif defined(_amd64) || defined(_arm64)
		#define DUK_F_64BIT_PTRS
		#if defined(_amd64)
			#define DUK_USE_INTEGER_LE
			#define DUK_USE_DOUBLE_LE
			#define DUK_USE_ARCH_STRING "x64"
		#else
			#define DUK_USE_INTEGER_LE  	/* integer endianness is little on purpose */
			#define DUK_USE_DOUBLE_ME
			#define DUK_USE_ARCH_STRING "arm64"
		#endif
	#endif
	typedef int duk_int_t;
	#include <sys/types.h>
	#include <stdint.h>
	#include <sys/param.h>
	#include <time.h>
	#include <sys/time.h>
	#define DUK_USE_OS_STRING "plan9"
	typedef intptr_t duk_intptr_t;
	typedef unsigned short	duk_small_uint_fast_t;
	typedef unsigned int	duk_uint_fast_t;
	typedef int duk_int_fast_t;
#endif  /* autodetect platform */

/********************************************************
 *  End of Platform autodetection ******
 ********************************************************/

/*******************************************************************************
**************************** for all platforms ***********************************
********************************************************************************/
/* Shared includes: C89 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>  /* varargs */
#include <setjmp.h>
#include <stddef.h>  /* e.g. ptrdiff_t */
#include <math.h>
#include <limits.h>

/* Shared includes: stdint.h is C99 */
#include <stdint.h>

/* <exception> is only included if needed, based on DUK_USE_xxx flags. */

/***************************************************************************
 ********************End of  Architecture autodetection *********************
 ****************************************************************************/

/***************************************************************************
 *********************  Compiler autodetection *****************************
 ***************************************************************************/
										/* --- Generic --- */
#undef DUK_USE_BRANCH_HINTS
#if defined(DUK_F_CPP)
	#define DUK_USE_COMPILER_STRING "generic-c++"
#else
	#define DUK_USE_COMPILER_STRING "generic"
#endif
#undef DUK_USE_VARIADIC_MACROS
	/* C++ doesn't have standard designated union initializers ({ .foo = 1 }). */
#undef DUK_USE_UNION_INITIALIZERS
	/* Most portable, wastes space */
#define DUK_USE_FLEX_ONESIZE
	/* Most portable, potentially wastes space */
#define DUK_USE_PACK_DUMMY_MEMBER

/***************************************************************************
 *********************End of   Compiler autodetection **********************
 ***************************************************************************/

/*
 *  Wrapper typedefs and constants for integer types, also sanity check types.
 *
 *  C99 typedefs are quite good but not always available, and we want to avoid
 *  forcibly redefining the C99 typedefs.  So, there are Duktape wrappers for
 *  all C99 typedefs and Duktape code should only use these typedefs.  Type
 *  detection when C99 is not supported is best effort and may end up detecting
 *  some types incorrectly.
 *
 *  Pointer sizes are a portability problem: pointers to different types may
 *  have a different size and function pointers are very difficult to manage
 *  portably.
 *
 *  http://en.wikipedia.org/wiki/C_data_types#Fixed-width_integer_types
 *
 *  Note: there's an interesting corner case when trying to define minimum
 *  signed integer value constants which leads to the current workaround of
 *  defining e.g. -0x80000000 as (-0x7fffffffL - 1L).  See doc/code-issues.txt
 *  for a longer discussion.
 *
 *  Note: avoid typecasts and computations in macro integer constants as they
 *  can then no longer be used in macro relational expressions (such as
 *  #if DUK_SIZE_MAX < 0xffffffffUL).  There is internal code which relies on
 *  being able to compare DUK_SIZE_MAX against a limit.
 */

/* XXX: add feature options to force basic types from outside? */

#if !defined(INT_MAX)		/* defined in limits.h */
	#error INT_MAX not defined
#endif

/* Check that architecture is two's complement, standard C allows e.g.
 * INT_MIN to be -2**31+1 (instead of -2**31).
 */
#if defined(INT_MAX) && defined(INT_MIN)		/* Plan9 OK */
	#if INT_MAX != -(INT_MIN + 1)
		#error platform does not seem complement of two
	#endif
#else
	#error cannot check complement of two
#endif

/* Pointer size determination based on __WORDSIZE or architecture when
 * that's not available.
 */
#if defined(DUK_F_X86) || defined(DUK_F_ARM32)
	#define DUK_F_32BIT_PTRS		/* plan9ape OK */
#elif defined(DUK_F_X64) || defined(DUK_F_ARM64)
	#define DUK_F_64BIT_PTRS
#else
	/* not sure, not needed with C99 anyway */
#endif

/* Basic integer typedefs and limits, preferably from inttypes.h, otherwise
 * through automatic detection.
 */

/****************************************************************************************
********************* Start of C99 types ***plan9ape is here******************************
*****************************************************************************************/
/* When C99 types are not available, we use heuristic detection to get
 * the basic 8, 16, 32, and (possibly) 64 bit types.  The fast/least
 * types are then assumed to be exactly the same for now: these could
 * be improved per platform but C99 types are very often now available.
 * 64-bit types are not available on all platforms; this is OK at least
 * on 32-bit platforms.
 *
 * This detection code is necessarily a bit hacky and can provide typedefs
 * and defines that won't work correctly on some exotic platform.
 */
#if (defined(CHAR_BIT) && (CHAR_BIT == 8)) || \
   	 (defined(UCHAR_MAX) && (UCHAR_MAX == 255))
		typedef unsigned char duk_uint8_t;
		typedef signed char duk_int8_t;
#else
	#error cannot detect 8-bit type
#endif
#if defined(USHRT_MAX) && (USHRT_MAX == 65535UL)		/* plan9 is this K.Okamoto */
	typedef unsigned short duk_uint16_t;
	typedef signed short duk_int16_t;
#endif
#if defined(UINT_MAX) && (UINT_MAX == 4294967295UL)		/* plan9 is this K.Okamoto */
	typedef unsigned int duk_uint32_t;
	typedef signed int duk_int32_t;
#elif defined(ULONG_MAX) && (ULONG_MAX == 4294967295UL)
	/* On some platforms int is 16-bit but long is 32-bit (e.g. PureC) */
	typedef unsigned long duk_uint32_t;
	typedef signed long duk_int32_t;
#else
	#error cannot detect 32-bit type
#endif

/* 64-bit type detection is a bit tricky.
 *
 * ULLONG_MAX is a standard define.  __LONG_LONG_MAX__ and __ULONG_LONG_MAX__
 * are used by at least GCC (even if system headers don't provide ULLONG_MAX).
 * Some GCC variants may provide __LONG_LONG_MAX__ but not __ULONG_LONG_MAX__.
 *
 * ULL / LL constants are rejected / warned about by some compilers, even if
 * the compiler has a 64-bit type and the compiler/system headers provide an
 * unsupported constant (ULL/LL)!  Try to avoid using ULL / LL constants.
 * As a side effect we can only check that e.g. ULONG_MAX is larger than 32
 * bits but can't be sure it is exactly 64 bits.  Self tests will catch such
 * cases.
 */
#undef DUK_F_HAVE_64BIT
#if !defined(DUK_F_32BIT_PTR)
	#if !defined(DUK_F_HAVE_64BIT) && defined(ULLONG_MAX)		/*  ULLONG_MAX in limits.h K.Okamoto */
		#define DUK_F_HAVE_64BIT
		typedef unsigned long long duk_uint64_t;
		typedef long long duk_int64_t;
	#endif
#endif

typedef duk_uint8_t duk_uint_least8_t;
typedef duk_int8_t duk_int_least8_t;
typedef duk_uint16_t duk_uint_least16_t;
typedef duk_int16_t duk_int_least16_t;
typedef duk_uint32_t duk_uint_least32_t;
typedef duk_int32_t duk_int_least32_t;
typedef duk_uint8_t duk_uint_fast8_t;
typedef duk_int8_t duk_int_fast8_t;
typedef duk_uint16_t duk_uint_fast16_t;
typedef duk_int16_t duk_int_fast16_t;
typedef duk_uint32_t duk_uint_fast32_t;
typedef duk_int32_t duk_int_fast32_t;
#if defined(DUK_F_HAVE_64BIT)
	typedef duk_uint64_t duk_uint_least64_t;
	typedef duk_int64_t duk_int_least64_t;
	typedef duk_uint64_t duk_uint_fast64_t;
	typedef duk_int64_t duk_int_fast64_t;
#endif
#if defined(DUK_F_HAVE_64BIT)
	typedef duk_uint64_t duk_uintmax_t;
	typedef duk_int64_t duk_intmax_t;
#else
	typedef duk_uint32_t duk_uintmax_t;
	typedef duk_int32_t duk_intmax_t;
#endif

/* Note: the funny looking computations for signed minimum 16-bit, 32-bit, and
  * 64-bit values are intentional as the obvious forms (e.g. -0x80000000L) are
  * -not- portable.  See code-issues.txt for a detailed discussion.
  */
#define DUK_UINT8_MIN         0UL
#define DUK_UINT8_MAX         0xffUL
#define DUK_INT8_MIN          (-0x80L)
#define DUK_INT8_MAX          0x7fL
#define DUK_UINT_LEAST8_MIN   0UL
#define DUK_UINT_LEAST8_MAX   0xffUL
#define DUK_INT_LEAST8_MIN    (-0x80L)
#define DUK_INT_LEAST8_MAX    0x7fL
#define DUK_UINT_FAST8_MIN    0UL
#define DUK_UINT_FAST8_MAX    0xffUL
#define DUK_INT_FAST8_MIN     (-0x80L)
#define DUK_INT_FAST8_MAX     0x7fL
#define DUK_UINT16_MIN        0UL
#define DUK_UINT16_MAX        0xffffUL
#define DUK_INT16_MIN         (-0x7fffL - 1L)
#define DUK_INT16_MAX         0x7fffL
#define DUK_UINT_LEAST16_MIN  0UL
#define DUK_UINT_LEAST16_MAX  0xffffUL
#define DUK_INT_LEAST16_MIN   (-0x7fffL - 1L)
#define DUK_INT_LEAST16_MAX   0x7fffL
#define DUK_UINT_FAST16_MIN   0UL
#define DUK_UINT_FAST16_MAX   0xffffUL
#define DUK_INT_FAST16_MIN    (-0x7fffL - 1L)
#define DUK_INT_FAST16_MAX    0x7fffL
#define DUK_UINT32_MIN        0UL
#define DUK_UINT32_MAX        0xffffffffUL
#define DUK_INT32_MIN         (-0x7fffffffL - 1L)
#define DUK_INT32_MAX         0x7fffffffL
#define DUK_UINT_LEAST32_MIN  0UL
#define DUK_UINT_LEAST32_MAX  0xffffffffUL
#define DUK_INT_LEAST32_MIN   (-0x7fffffffL - 1L)
#define DUK_INT_LEAST32_MAX   0x7fffffffL
#define DUK_UINT_FAST32_MIN   0UL
#define DUK_UINT_FAST32_MAX   0xffffffffUL
#define DUK_INT_FAST32_MIN    (-0x7fffffffL - 1L)
#define DUK_INT_FAST32_MAX    0x7fffffffL

/* 64-bit constants.  Since LL / ULL constants are not always available,
 * use computed values.  These values can't be used in preprocessor
 * comparisons; flag them as such.
 */
#if defined(DUK_F_HAVE_64BIT)
	#define DUK_UINT64_MIN        ((duk_uint64_t) 0)
	#define DUK_UINT64_MAX        ((duk_uint64_t) -1)
	#define DUK_INT64_MIN         ((duk_int64_t) (~(DUK_UINT64_MAX >> 1)))
	#define DUK_INT64_MAX         ((duk_int64_t) (DUK_UINT64_MAX >> 1))
	#define DUK_UINT_LEAST64_MIN  DUK_UINT64_MIN
	#define DUK_UINT_LEAST64_MAX  DUK_UINT64_MAX
	#define DUK_INT_LEAST64_MIN   DUK_INT64_MIN
	#define DUK_INT_LEAST64_MAX   DUK_INT64_MAX
	#define DUK_UINT_FAST64_MIN   DUK_UINT64_MIN
	#define DUK_UINT_FAST64_MAX   DUK_UINT64_MAX
	#define DUK_INT_FAST64_MIN    DUK_INT64_MIN
	#define DUK_INT_FAST64_MAX    DUK_INT64_MAX
	#define DUK_UINT64_MIN_COMPUTED
	#define DUK_UINT64_MAX_COMPUTED
	#define DUK_INT64_MIN_COMPUTED
	#define DUK_INT64_MAX_COMPUTED
	#define DUK_UINT_LEAST64_MIN_COMPUTED
	#define DUK_UINT_LEAST64_MAX_COMPUTED
	#define DUK_INT_LEAST64_MIN_COMPUTED
	#define DUK_INT_LEAST64_MAX_COMPUTED
	#define DUK_UINT_FAST64_MIN_COMPUTED
	#define DUK_UINT_FAST64_MAX_COMPUTED
	#define DUK_INT_FAST64_MIN_COMPUTED
	#define DUK_INT_FAST64_MAX_COMPUTED
#endif

#if defined(DUK_F_HAVE_64BIT)
	#define DUK_UINTMAX_MIN       DUK_UINT64_MIN
	#define DUK_UINTMAX_MAX       DUK_UINT64_MAX
	#define DUK_INTMAX_MIN        DUK_INT64_MIN
	#define DUK_INTMAX_MAX        DUK_INT64_MAX
	#define DUK_UINTMAX_MIN_COMPUTED
	#define DUK_UINTMAX_MAX_COMPUTED
	#define DUK_INTMAX_MIN_COMPUTED
	#define DUK_INTMAX_MAX_COMPUTED
#else
	#define DUK_UINTMAX_MIN       0UL
	#define DUK_UINTMAX_MAX       0xffffffffUL
	#define DUK_INTMAX_MIN        (-0x7fffffffL - 1L)
	#define DUK_INTMAX_MAX        0x7fffffffL
#endif

/* This detection is not very reliable. */
#if defined(DUK_F_32BIT_PTRS)
	typedef duk_int32_t duk_intptr_t;
	typedef duk_uint32_t duk_uintptr_t;
	#define DUK_UINTPTR_MIN       DUK_UINT32_MIN
	#define DUK_UINTPTR_MAX       DUK_UINT32_MAX
	#define DUK_INTPTR_MIN        DUK_INT32_MIN
	#define DUK_INTPTR_MAX        DUK_INT32_MAX
#elif defined(DUK_F_64BIT_PTRS) && defined(DUK_F_HAVE_64BIT)
	typedef duk_int64_t duk_intptr_t;
	typedef duk_uint64_t duk_uintptr_t;
	#define DUK_UINTPTR_MIN       DUK_UINT64_MIN
	#define DUK_UINTPTR_MAX       DUK_UINT64_MAX
	#define DUK_INTPTR_MIN        DUK_INT64_MIN
	#define DUK_INTPTR_MAX        DUK_INT64_MAX
	#define DUK_UINTPTR_MIN_COMPUTED
	#define DUK_UINTPTR_MAX_COMPUTED
	#define DUK_INTPTR_MIN_COMPUTED
	#define DUK_INTPTR_MAX_COMPUTED
#else
	#error cannot determine intptr type
#endif

/* SIZE_MAX may be missing so use an approximate value for it. */
#undef DUK_SIZE_MAX_COMPUTED
#if !defined(SIZE_MAX) && !defined(SSIZE_MAX)	/* added by K.Okamoto */
	#define DUK_SIZE_MAX_COMPUTED
	#define SIZE_MAX              ((size_t) (-1))
#endif
#define DUK_SIZE_MIN          0

/****************************************************************************************
********************* End of C99 types ***plan9ape is there******************************
*****************************************************************************************/

/* A few types are assumed to always exist. */
typedef size_t duk_size_t;
typedef ptrdiff_t duk_ptrdiff_t;

/* The best type for an "all around int" in Duktape internals is "at least
 * 32 bit signed integer" which is most convenient.  Same for unsigned type.
 * Prefer 'int' when large enough, as it is almost always a convenient type.
 */
#if defined(UINT_MAX) && (UINT_MAX >= 0xffffffffUL)	/*plan9ape is here */
	typedef int duk_int_t;
	typedef unsigned int duk_uint_t;
	#define DUK_INT_MIN           INT_MIN
	#define DUK_INT_MAX           INT_MAX
	#define DUK_UINT_MIN          0
	#define DUK_UINT_MAX          UINT_MAX
#else
	typedef duk_int_fast32_t duk_int_t;
	typedef duk_uint_fast32_t duk_uint_t;
	#define DUK_INT_MIN           DUK_INT_FAST32_MIN
	#define DUK_INT_MAX           DUK_INT_FAST32_MAX
	#define DUK_UINT_MIN          DUK_UINT_FAST32_MIN
	#define DUK_UINT_MAX          DUK_UINT_FAST32_MAX
#endif


/* Small integers (16 bits or more) can fall back to the 'int' type, but
 * have a typedef so they are marked "small" explicitly.
 */
typedef int duk_small_int_t;
typedef unsigned int duk_small_uint_t;
#define DUK_SMALL_INT_MIN     INT_MIN
#define DUK_SMALL_INT_MAX     INT_MAX
#define DUK_SMALL_UINT_MIN    0
#define DUK_SMALL_UINT_MAX    UINT_MAX

/* Boolean values are represented with the platform 'unsigned int'. */
typedef duk_small_uint_t duk_bool_t;
#define DUK_BOOL_MIN              DUK_SMALL_UINT_MIN
#define DUK_BOOL_MAX              DUK_SMALL_UINT_MAX

/* Index values must have at least 32-bit signed range. */
typedef duk_int_t duk_idx_t;
#define DUK_IDX_MIN               DUK_INT_MIN
#define DUK_IDX_MAX               DUK_INT_MAX

/* Unsigned index variant. */
typedef duk_uint_t duk_uidx_t;
#define DUK_UIDX_MIN              DUK_UINT_MIN
#define DUK_UIDX_MAX              DUK_UINT_MAX

/* Array index values, could be exact 32 bits.
 * Currently no need for signed duk_arridx_t.
 */
typedef duk_uint_t duk_uarridx_t;
#define DUK_UARRIDX_MIN           DUK_UINT_MIN
#define DUK_UARRIDX_MAX           DUK_UINT_MAX

/* Duktape/C function return value, platform int is enough for now to
 * represent 0, 1, or negative error code.  Must be compatible with
 * assigning truth values (e.g. duk_ret_t rc = (foo == bar);).
 */
typedef duk_small_int_t duk_ret_t;
#define DUK_RET_MIN               DUK_SMALL_INT_MIN
#define DUK_RET_MAX               DUK_SMALL_INT_MAX

/* Error codes are represented with platform int.  High bits are used
 * for flags and such, so 32 bits are needed.
 */
typedef duk_int_t duk_errcode_t;
#define DUK_ERRCODE_MIN           DUK_INT_MIN
#define DUK_ERRCODE_MAX           DUK_INT_MAX

/* Codepoint type.  Must be 32 bits or more because it is used also for
 * internal codepoints.  The type is signed because negative codepoints
 * are used as internal markers (e.g. to mark EOF or missing argument).
 * (X)UTF-8/CESU-8 encode/decode take and return an unsigned variant to
 * ensure duk_uint32_t casts back and forth nicely.  Almost everything
 * else uses the signed one.
 */
typedef duk_int_t duk_codepoint_t;
typedef duk_uint_t duk_ucodepoint_t;
#define DUK_CODEPOINT_MIN         DUK_INT_MIN
#define DUK_CODEPOINT_MAX         DUK_INT_MAX
#define DUK_UCODEPOINT_MIN        DUK_UINT_MIN
#define DUK_UCODEPOINT_MAX        DUK_UINT_MAX

/* IEEE float/double typedef. */
typedef float duk_float_t;
typedef double duk_double_t;

/* We're generally assuming that we're working on a platform with a 32-bit
 * address space.  If DUK_SIZE_MAX is a typecast value (which is necessary
 * if SIZE_MAX is missing), the check must be avoided because the
 * preprocessor can't do a comparison.
 */
#if !defined(DUK_SIZE_MAX)
	#error DUK_SIZE_MAX is undefined, probably missing SIZE_MAX
#elif !defined(DUK_SIZE_MAX_COMPUTED)
	#if DUK_SIZE_MAX < 0xffffffffUL
		/* On some systems SIZE_MAX can be smaller than max unsigned 32-bit value
		 * which seems incorrect if size_t is (at least) an unsigned 32-bit type.
		 * However, it doesn't seem useful to error out compilation if this is the
		 * case.
		 */
	#endif
#endif

/* Type used in public API declarations and user code.  Typedef maps to
 * 'struct duk_hthread' like the 'duk_hthread' typedef which is used
 * exclusively in internals.
 */
typedef struct duk_hthread duk_context;

/* Check whether we should use 64-bit integers or not.
 *
 * Quite incomplete now.  Use 64-bit types if detected (C99 or other detection)
 * unless they are known to be unreliable.  For instance, 64-bit types are
 * available on VBCC but seem to misbehave.
 */
#define DUK_USE_64BIT_OPS

/*
 *  Fill-ins for platform, architecture, and compiler
 */

/* An abort()-like primitive is needed by the default fatal error handler. */
#if !defined(DUK_ABORT)
	#define DUK_ABORT             abort
#endif

#if !defined(DUK_SETJMP)
	#define DUK_JMPBUF_TYPE       jmp_buf
	#define DUK_SETJMP(jb)        setjmp((jb))
	#define DUK_LONGJMP(jb)       longjmp((jb), 1)
#endif

/* Special naming to avoid conflict with e.g. DUK_FREE() in duk_heap.h
 * (which is unfortunately named).  May sometimes need replacement, e.g.
 * some compilers don't handle zero length or NULL correctly in realloc().
 */
#define DUK_ANSI_MALLOC      malloc
#define DUK_ANSI_REALLOC     realloc
#define DUK_ANSI_CALLOC      calloc
#define DUK_ANSI_FREE        free

/* ANSI C (various versions) and some implementations require that the
 * pointer arguments to memset(), memcpy(), and memmove() be valid values
 * even when byte size is 0 (even a NULL pointer is considered invalid in
 * this context).  Zero-size operations as such are allowed, as long as their
 * pointer arguments point to a valid memory area.  The DUK_MEMSET(),
 * DUK_MEMCPY(), and DUK_MEMMOVE() macros require this same behavior, i.e.:
 * (1) pointers must be valid and non-NULL, (2) zero size must otherwise be
 * allowed.  If these are not fulfilled, a macro wrapper is needed.
 *
 *   http://stackoverflow.com/questions/5243012/is-it-guaranteed-to-be-safe-to-perform-memcpy0-0-0
 *   http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-October/011065.html
 *
 * Not sure what's the required behavior when a pointer points just past the
 * end of a buffer, which often happens in practice (e.g. zero size memmoves).
 * For example, if allocation size is 3, the following pointer would not
 * technically point to a valid memory byte:
 *
 *   <-- alloc -->
 *   | 0 | 1 | 2 | .....
 *                 ^-- p=3, points after last valid byte (2)
 */
#define DUK_MEMCPY       memcpy
#define DUK_MEMMOVE      memmove
#define DUK_MEMCMP       memcmp
#define DUK_MEMSET       memset
#define DUK_STRLEN       strlen
#define DUK_STRCMP       strcmp
#define DUK_STRNCMP      strncmp
#define DUK_SPRINTF      sprintf
#define DUK_SNPRINTF     snprintf
#define DUK_VSPRINTF     vsprintf
#define DUK_VSNPRINTF    vsnprintf
#define DUK_SSCANF       sscanf
#if !defined(DUK_MEMZERO)
	#define DUK_MEMZERO(p,n) DUK_MEMSET((p), 0, (n))
#endif

/* Many platforms are missing fpclassify() and friends, so use replacements
 * if necessary.  The replacement constants (FP_NAN etc) can be anything but
 * match Linux constants now.
 */

/* Complex condition broken into separate parts. */
#define DUK_USE_REPL_FPCLASSIFY
#define DUK_USE_REPL_SIGNBIT
#define DUK_USE_REPL_ISFINITE
#define DUK_USE_REPL_ISNAN
#define DUK_USE_REPL_ISINF
#define DUK_FPCLASSIFY       duk_repl_fpclassify
#define DUK_SIGNBIT          duk_repl_signbit
#define DUK_ISFINITE         duk_repl_isfinite
#define DUK_ISNAN            duk_repl_isnan
#define DUK_ISINF            duk_repl_isinf
#define DUK_FP_NAN           0
#define DUK_FP_INFINITE      1
#define DUK_FP_ZERO          2
#define DUK_FP_SUBNORMAL     3
#define DUK_FP_NORMAL        4

/* These functions don't currently need replacement but are wrapped for
 * completeness.  Because these are used as function pointers, they need
 * to be defined as concrete C functions (not macros).
 */
#define DUK_FABS             fabs		/* in math.h for plan9  */
#define DUK_FLOOR            floor	/* in math.h for plan9  */
#define DUK_CEIL             ceil		/* in math.h for plan9  */
#define DUK_FMOD             fmod	/* in math.h for plan9  */
#define DUK_POW              pow		/* in math.h for plan9  */
#define DUK_ACOS             acos	/* in math.h for plan9  */
#define DUK_ASIN             asin		/* in math.h for plan9  */
#define DUK_ATAN             atan	/* in math.h for plan9  */
#define DUK_ATAN2            atan2	/* in math.h for plan9  */
#define DUK_SIN              sin		/* in math.h for plan9  */
#define DUK_COS              cos		/* in math.h for plan9  */
#define DUK_TAN              tan		/* in math.h for plan9  */
#define DUK_EXP              exp		/* in math.h for plan9  */
#define DUK_LOG              log		/* in math.h for plan9  */
#define DUK_SQRT             sqrt		/* in math.h for plan9  */

#define DUK_LOG10            log10

/* Rely as little as possible on compiler behavior for NaN comparison,
 * signed zero handling, etc.  Currently never activated but may be needed
 * for broken compilers.
 */
#undef DUK_USE_PARANOID_MATH

#define DUK_USE_PARANOID_DATE_COMPUTATION

/* More or less standard endianness predefines provided by header files.
 * The ARM hybrid case is detected by assuming that __FLOAT_WORD_ORDER
 * will be big endian, see: http://lists.mysql.com/internals/443.
 * On some platforms some defines may be present with an empty value which
 * causes comparisons to fail: https://github.com/svaarala/duktape/issues/453.
 */

/*
 *  Alignment requirement and support for unaligned accesses
 *
 *  Assume unaligned accesses are not supported unless specifically allowed
 *  in the target platform.  Some platforms may support unaligned accesses
 *  but alignment to 4 or 8 may still be desirable.  Note that unaligned
 *  accesses (and even pointers) relative to natural alignment (regardless
 *  of target alignment) are technically undefined behavior and thus
 *  compiler/architecture specific.
 */

/* If not forced, use safe default for alignment. */
#if !defined(DUK_USE_ALIGN_BY)
	#define DUK_USE_ALIGN_BY 8
#endif

/* Compiler specific hackery needed to force struct size to match aligment,
 * see e.g. duk_hbuffer.h.
 *
 * http://stackoverflow.com/questions/11130109/c-struct-size-alignment
 * http://stackoverflow.com/questions/10951039/specifying-64-bit-alignment
 */

#define DUK_VA_COPY(dest,src) va_copy(dest,src)

#if !defined(DUK_MACRO_STRINGIFY)
	/* Macro hackery to convert e.g. __LINE__ to a string without formatting,
	 * see: http://stackoverflow.com/questions/240353/convert-a-preprocessor-token-to-a-string
	 */
	#define DUK_MACRO_STRINGIFY_HELPER(x)  #x
	#define DUK_MACRO_STRINGIFY(x)  DUK_MACRO_STRINGIFY_HELPER(x)
#endif

#if !defined(DUK_CAUSE_SEGFAULT)
	/* This can be used for testing; valgrind will then indicate the C call stack
	 * leading to the call site.
	 */
	#define DUK_CAUSE_SEGFAULT()  do { *((volatile duk_uint32_t *) NULL) = (duk_uint32_t) 0xdeadbeefUL; } while (0)
#endif

#if !defined(DUK_UNREF)
	/* Macro for suppressing warnings for potentially unreferenced variables.
	 * The variables can be actually unreferenced or unreferenced in some
	 * specific cases only; for instance, if a variable is only debug printed,
	 * it is unreferenced when debug printing is disabled.  May cause warnings
	 * for volatile arguments.
 	 */
	#define DUK_UNREF(x)  do { (void) (x); } while (0)
#endif

/* Fillin for DUK_NORETURN; DUK_WO_NORETURN() is used to insert dummy
 * dummy statements after noreturn calls to silence harmless compiler
 * warnings, e.g.:
 *
 *   DUK_ERROR_TYPE(thr, "aiee");
 *   DUK_WO_NORETURN(return 0;);
 *
 * Statements inside DUK_WO_NORETURN() must NEVER be actually reachable,
 * and they're only included to satisfy the compiler.
 */
#define DUK_NORETURN(decl) decl
//#define DUK_WO_NORETURN(smtp) smtp

/* Convert any input pointer into a "void *", losing a const qualifier.
 * This is not fully portable because casting through duk_uintptr_t may
 * not work on all architectures (e.g. those with long, segmented pointers).
 */
#define DUK_LOSE_CONST(src) ((void *) (duk_uintptr_t) (src))

#define DUK_LIKELY(x)    (x)
#define DUK_UNLIKELY(x)  (x)
#define DUK_UNPREDICTABLE(x)  (x)

#define DUK_NOINLINE       /*nop*/
#define DUK_INLINE         /*nop*/
#define DUK_ALWAYS_INLINE  /*nop*/

#define DUK_HOT            /*nop*/
#define DUK_COLD           /*nop*/
#define DUK_EXTERNAL_DECL  extern
#define DUK_EXTERNAL       /*empty*/
#if defined(DUK_SINGLE_FILE)
	#define DUK_INTERNAL_DECL  static
#else
	#define DUK_INTERNAL_DECL  extern
#endif
#if defined(DUK_SINGLE_FILE)
	#define DUK_INTERNAL       static
#else
	#define DUK_INTERNAL       /*empty*/
#endif
#define DUK_LOCAL_DECL     static
#define DUK_LOCAL          static


#if !defined(DUK_FILE_MACRO)
	#define DUK_FILE_MACRO  __FILE__
#endif
#if !defined(DUK_LINE_MACRO)
	#define DUK_LINE_MACRO  __LINE__
#endif
#if !defined(DUK_FUNC_MACRO)
	#if defined(DUK_F_C99) || defined(DUK_F_CPP11)
		#define DUK_FUNC_MACRO  __func__
	#elif defined(__FUNCTION__)
		#define DUK_FUNC_MACRO  __FUNCTION__
	#else
		#define DUK_FUNC_MACRO  "unknown"
	#endif
#endif

#if !defined(DUK_BSWAP32)		/* 1234<==>4321 K.Okamoto */
	#define DUK_BSWAP32(x) \
		((((duk_uint32_t) (x)) >> 24) | \
		 ((((duk_uint32_t) (x)) >> 8) & 0xff00UL) | \
		 ((((duk_uint32_t) (x)) << 8) & 0xff0000UL) | \
		 (((duk_uint32_t) (x)) << 24))
#endif
#if !defined(DUK_BSWAP16)		/* 12<==>21 K.Okamoto */
	#define DUK_BSWAP16(x) \
		((duk_uint16_t) (x) >> 8) | \
		((duk_uint16_t) (x) << 8)
#endif

#if !defined(DUK_U64_CONSTANT)
	#define DUK_U64_CONSTANT(x) x##ULL
#endif
#if !defined(DUK_I64_CONSTANT)
	#define DUK_I64_CONSTANT(x) x##LL
#endif

/*
 *  Check whether or not a packed duk_tval representation is possible.
 *  What's basically required is that pointers are 32-bit values
 *  (sizeof(void *) == 4).  Best effort check, not always accurate.
 *  If guess goes wrong, crashes may result; self tests also verify
 *  the guess.
 */

/* Explicit marker needed; may be 'defined', 'undefined, 'or 'not provided'. */

#if !defined(DUK_F_PACKED_TVAL_PROVIDED)
	#undef DUK_F_PACKED_TVAL_POSSIBLE
	/* Strict C99 case: DUK_UINTPTR_MAX (= UINTPTR_MAX) should be very reliable */
	#if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_UINTPTR_MAX)
		#if (DUK_UINTPTR_MAX <= 0xffffffffUL)
			#define DUK_F_PACKED_TVAL_POSSIBLE
		#endif
	#endif
		/* Non-C99 case, still relying on DUK_UINTPTR_MAX, as long as it is not a computed value */
	#if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_UINTPTR_MAX) && !defined(DUK_UINTPTR_MAX_COMPUTED)
		#if (DUK_UINTPTR_MAX <= 0xffffffffUL)
			#define DUK_F_PACKED_TVAL_POSSIBLE
		#endif
	#endif
		/* DUK_SIZE_MAX (= SIZE_MAX) is often reliable */
	#if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_SIZE_MAX) && !defined(DUK_SIZE_MAX_COMPUTED)
		#if (DUK_SIZE_MAX <= 0xffffffffUL)
			#define DUK_F_PACKED_TVAL_POSSIBLE
		#endif
	#endif
	#undef DUK_USE_PACKED_TVAL
	#if defined(DUK_F_PACKED_TVAL_POSSIBLE)
		#define DUK_USE_PACKED_TVAL
	#endif
	#undef DUK_F_PACKED_TVAL_POSSIBLE

#endif  /* DUK_F_PACKED_TVAL_PROVIDED */

/* Object property allocation layout has implications for memory and code
 * footprint and generated code size/speed.  The best layout also depends
 * on whether the platform has alignment requirements or benefits from
 * having mostly aligned accesses.
 */
#undef DUK_USE_HOBJECT_LAYOUT_1
#undef DUK_USE_HOBJECT_LAYOUT_2
#undef DUK_USE_HOBJECT_LAYOUT_3
#if (DUK_USE_ALIGN_BY == 1)
	/* On platforms without any alignment issues, layout 1 is preferable
	 * because it compiles to slightly less code and provides direct access
	 * to property keys.
	 */
	#define DUK_USE_HOBJECT_LAYOUT_1
#else
	/* On other platforms use layout 2, which requires some padding but
	 * is a bit more natural than layout 3 in ordering the entries.  Layout
	 * 3 is currently not used.
	 */
	#define DUK_USE_HOBJECT_LAYOUT_2
#endif

/*
 *  Autogenerated defaults
 */

#undef DUK_USE_ALLOW_UNDEFINED_BEHAVIOR
#define DUK_USE_ARRAY_BUILTIN
#define DUK_USE_ARRAY_FASTPATH
#define DUK_USE_ARRAY_PROP_FASTPATH
#undef DUK_USE_ASSERTIONS
#define DUK_USE_AUGMENT_ERROR_CREATE
#define DUK_USE_AUGMENT_ERROR_THROW
#define DUK_USE_AVOID_PLATFORM_FUNCPTRS
#define DUK_USE_BASE64_FASTPATH
#define DUK_USE_BASE64_SUPPORT
#define DUK_USE_BOOLEAN_BUILTIN
#define DUK_USE_BUFFEROBJECT_SUPPORT
#undef DUK_USE_BUFLEN16
#define DUK_USE_BYTECODE_DUMP_SUPPORT
#define DUK_USE_CACHE_ACTIVATION
#define DUK_USE_CACHE_CATCHER
#define DUK_USE_CALLSTACK_LIMIT 10000
#define DUK_USE_COMMONJS_MODULES
#define DUK_USE_COMPILER_RECLIMIT 2500
#define DUK_USE_COROUTINE_SUPPORT
#undef DUK_USE_CPP_EXCEPTIONS
#undef DUK_USE_DATAPTR16
#undef DUK_USE_DATAPTR_DEC16
#undef DUK_USE_DATAPTR_ENC16
#define DUK_USE_DATE_BUILTIN
#undef DUK_USE_DATE_FORMAT_STRING
#undef DUK_USE_DATE_GET_LOCAL_TZOFFSET
#undef DUK_USE_DATE_GET_NOW
#undef DUK_USE_DATE_PARSE_STRING
#undef DUK_USE_DATE_PRS_GETDATE
#undef DUK_USE_DEBUG
#undef DUK_USE_DEBUGGER_DUMPHEAP
#undef DUK_USE_DEBUGGER_INSPECT
#undef DUK_USE_DEBUGGER_PAUSE_UNCAUGHT
#undef DUK_USE_DEBUGGER_SUPPORT
#define DUK_USE_DEBUGGER_THROW_NOTIFY
#undef DUK_USE_DEBUGGER_TRANSPORT_TORTURE
#define DUK_USE_DEBUG_BUFSIZE 65536L
#define DUK_USE_DEBUG_LEVEL 0
#undef DUK_USE_DEBUG_WRITE
#define DUK_USE_DOUBLE_LINKED_HEAP
#define DUK_USE_DUKTAPE_BUILTIN
#define DUK_USE_ENCODING_BUILTINS
#define DUK_USE_ERRCREATE
#define DUK_USE_ERRTHROW
#define DUK_USE_ES6
#define DUK_USE_ES6_OBJECT_PROTO_PROPERTY
#define DUK_USE_ES6_OBJECT_SETPROTOTYPEOF
#define DUK_USE_ES6_PROXY
#define DUK_USE_ES6_REGEXP_SYNTAX
#define DUK_USE_ES6_UNICODE_ESCAPE
#define DUK_USE_ES7
#define DUK_USE_ES7_EXP_OPERATOR
#define DUK_USE_ES8
#define DUK_USE_ES9
#define DUK_USE_ESBC_LIMITS
#define DUK_USE_ESBC_MAX_BYTES 2147418112L
#define DUK_USE_ESBC_MAX_LINENUMBER 2147418112L
#undef DUK_USE_EXEC_FUN_LOCAL
#undef DUK_USE_EXEC_INDIRECT_BOUND_CHECK
#undef DUK_USE_EXEC_PREFER_SIZE
#define DUK_USE_EXEC_REGCONST_OPTIMIZE
#undef DUK_USE_EXEC_TIMEOUT_CHECK
#undef DUK_USE_EXPLICIT_NULL_INIT
#undef DUK_USE_EXTSTR_FREE
#undef DUK_USE_EXTSTR_INTERN_CHECK
#undef DUK_USE_FASTINT
#define DUK_USE_FAST_REFCOUNT_DEFAULT
#undef DUK_USE_FATAL_HANDLER
#define DUK_USE_FATAL_MAXLEN 128
#define DUK_USE_FINALIZER_SUPPORT
#undef DUK_USE_FINALIZER_TORTURE
#undef DUK_USE_FUNCPTR16
#undef DUK_USE_FUNCPTR_DEC16
#undef DUK_USE_FUNCPTR_ENC16
#define DUK_USE_FUNCTION_BUILTIN
#define DUK_USE_FUNC_FILENAME_PROPERTY
#define DUK_USE_FUNC_NAME_PROPERTY
#undef DUK_USE_GC_TORTURE
#undef DUK_USE_GET_MONOTONIC_TIME
#undef DUK_USE_GET_RANDOM_DOUBLE
#undef DUK_USE_GLOBAL_BINDING
#define DUK_USE_GLOBAL_BUILTIN
#undef DUK_USE_HEAPPTR16
#undef DUK_USE_HEAPPTR_DEC16
#undef DUK_USE_HEAPPTR_ENC16
#define DUK_USE_HEX_FASTPATH
#define DUK_USE_HEX_SUPPORT
#define DUK_USE_HOBJECT_ARRAY_ABANDON_LIMIT 2
#define DUK_USE_HOBJECT_ARRAY_FAST_RESIZE_LIMIT 9
#define DUK_USE_HOBJECT_ARRAY_MINGROW_ADD 16
#define DUK_USE_HOBJECT_ARRAY_MINGROW_DIVISOR 8
#define DUK_USE_HOBJECT_ENTRY_MINGROW_ADD 16
#define DUK_USE_HOBJECT_ENTRY_MINGROW_DIVISOR 8
#define DUK_USE_HOBJECT_HASH_PART
#define DUK_USE_HOBJECT_HASH_PROP_LIMIT 8
#define DUK_USE_HSTRING_ARRIDX
#define DUK_USE_HSTRING_CLEN
#undef DUK_USE_HSTRING_EXTDATA
#define DUK_USE_HSTRING_LAZY_CLEN
#define DUK_USE_HTML_COMMENTS
#define DUK_USE_IDCHAR_FASTPATH
#undef DUK_USE_INJECT_HEAP_ALLOC_ERROR
#undef DUK_USE_INTERRUPT_COUNTER
#undef DUK_USE_INTERRUPT_DEBUG_FIXUP
#define DUK_USE_JC
#define DUK_USE_JSON_BUILTIN
#define DUK_USE_JSON_DECNUMBER_FASTPATH
#define DUK_USE_JSON_DECSTRING_FASTPATH
#define DUK_USE_JSON_DEC_RECLIMIT 1000
#define DUK_USE_JSON_EATWHITE_FASTPATH
#define DUK_USE_JSON_ENC_RECLIMIT 1000
#define DUK_USE_JSON_QUOTESTRING_FASTPATH
#undef DUK_USE_JSON_STRINGIFY_FASTPATH
#define DUK_USE_JSON_SUPPORT
#define DUK_USE_JX
#define DUK_USE_LEXER_SLIDING_WINDOW
#undef DUK_USE_LIGHTFUNC_BUILTINS
#define DUK_USE_LITCACHE_SIZE 256
#define DUK_USE_MARK_AND_SWEEP_RECLIMIT 256
#define DUK_USE_MATH_BUILTIN
#define DUK_USE_NATIVE_CALL_RECLIMIT 1000
#define DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT
#undef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY
#undef DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY
#define DUK_USE_NONSTD_FUNC_STMT
#define DUK_USE_NONSTD_GETTER_KEY_ARGUMENT
#define DUK_USE_NONSTD_JSON_ESC_U2028_U2029
#define DUK_USE_NONSTD_SETTER_KEY_ARGUMENT
#define DUK_USE_NONSTD_STRING_FROMCHARCODE_32BIT
#define DUK_USE_NUMBER_BUILTIN
#define DUK_USE_OBJECT_BUILTIN
#undef DUK_USE_OBJSIZES16
#undef DUK_USE_PARANOID_ERRORS
#define DUK_USE_PERFORMANCE_BUILTIN
#undef DUK_USE_PREFER_SIZE
#undef DUK_USE_PROMISE_BUILTIN
#define DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS
#undef DUK_USE_REFCOUNT16
#define DUK_USE_REFCOUNT32
#define DUK_USE_REFERENCE_COUNTING
#define DUK_USE_REFLECT_BUILTIN
#define DUK_USE_REGEXP_CANON_BITMAP
#undef DUK_USE_REGEXP_CANON_WORKAROUND
#define DUK_USE_REGEXP_COMPILER_RECLIMIT 10000
#define DUK_USE_REGEXP_EXECUTOR_RECLIMIT 10000
#define DUK_USE_REGEXP_SUPPORT
#undef DUK_USE_ROM_GLOBAL_CLONE
#undef DUK_USE_ROM_GLOBAL_INHERIT
#undef DUK_USE_ROM_OBJECTS
#define DUK_USE_ROM_PTRCOMP_FIRST 63488L
#undef DUK_USE_ROM_STRINGS
#define DUK_USE_SECTION_B
#undef DUK_USE_SELF_TESTS
#define DUK_USE_SHEBANG_COMMENTS
#undef DUK_USE_SHUFFLE_TORTURE
#define DUK_USE_SOURCE_NONBMP
#undef DUK_USE_STRHASH16
#undef DUK_USE_STRHASH_DENSE
#define DUK_USE_STRHASH_SKIP_SHIFT 5
#define DUK_USE_STRICT_DECL
#undef DUK_USE_STRICT_UTF8_SOURCE
#define DUK_USE_STRING_BUILTIN
#undef DUK_USE_STRLEN16
#define DUK_USE_STRTAB_GROW_LIMIT 17
#define DUK_USE_STRTAB_MAXSIZE 268435456L
#define DUK_USE_STRTAB_MINSIZE 1024
#undef DUK_USE_STRTAB_PTRCOMP
#define DUK_USE_STRTAB_RESIZE_CHECK_MASK 255
#define DUK_USE_STRTAB_SHRINK_LIMIT 6
#undef DUK_USE_STRTAB_TORTURE
#undef DUK_USE_SYMBOL_BUILTIN
#define DUK_USE_TAILCALL
#define DUK_USE_TARGET_INFO "unknown"
#define DUK_USE_TRACEBACKS
#define DUK_USE_TRACEBACK_DEPTH 10
#define DUK_USE_USER_DECLARE() /* no user declarations */
#define DUK_USE_VALSTACK_GROW_SHIFT 2
#define DUK_USE_VALSTACK_LIMIT 1000000L
#define DUK_USE_VALSTACK_SHRINK_CHECK_SHIFT 2
#define DUK_USE_VALSTACK_SHRINK_SLACK_SHIFT 4
#undef DUK_USE_VALSTACK_UNSAFE

#undef DUK_USE_VERBOSE_ERRORS
#define DUK_USE_ALLOW_UNDEFINED_BEHAVIOR
#undef DUK_USE_VERBOSE_EXECUTOR_ERRORS
#define DUK_USE_VOLUNTARY_GC
#define DUK_USE_ZERO_BUFFER_DATA

/*
 *  Fixups
 */

#include "duk_custom.h"

/*
 *  You may add overriding #define/#undef directives below for
 *  customization.  You of course cannot un-#include or un-typedef
 *  anything; these require direct changes above.
 */

/* __OVERRIDE_DEFINES__ */

/*
 *  Conditional includes
 */

#if defined(DUK_F_CPP) && defined(DUK_USE_CPP_EXCEPTIONS)
	#include <exception>  /* std::exception */
	#include <stdexcept>  /* std::runtime_error */
#endif

/*
 *  Date provider selection
 *
 *  User may define DUK_USE_DATE_GET_NOW() etc directly, in which case we'll
 *  rely on an external provider.  If this is not done, revert to previous
 *  behavior and use Unix/Windows built-in provider.
 */

#if defined(DUK_COMPILING_DUKTAPE)

	#if defined(DUK_USE_DATE_GET_NOW)
		/* External provider already defined. */
	#elif defined(DUK_USE_DATE_NOW_GETTIMEOFDAY)
		#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_gettimeofday()
	#elif defined(DUK_USE_DATE_NOW_TIME)
		#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_time()
	#elif defined(DUK_USE_DATE_NOW_WINDOWS)
		#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_windows()
	#elif defined(DUK_USE_DATE_NOW_WINDOWS_SUBMS)
		#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_windows_subms()
	#else
		#error no provider for DUK_USE_DATE_GET_NOW()
	#endif

	#if defined(DUK_USE_DATE_GET_LOCAL_TZOFFSET)
		/* External provider already defined. */
	#elif defined(DUK_USE_DATE_TZO_GMTIME_R) || defined(DUK_USE_DATE_TZO_GMTIME_S) || defined(DUK_USE_DATE_TZO_GMTIME)
		#define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d)   duk_bi_date_get_local_tzoffset_gmtime((d))
	#elif defined(DUK_USE_DATE_TZO_WINDOWS)
		#define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d)   duk_bi_date_get_local_tzoffset_windows((d))
	#elif defined(DUK_USE_DATE_TZO_WINDOWS_NO_DST)
		#define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d)   duk_bi_date_get_local_tzoffset_windows_no_dst((d))
	#else
		#error no provider for DUK_USE_DATE_GET_LOCAL_TZOFFSET()
	#endif

	#if defined(DUK_USE_DATE_PARSE_STRING)
		/* External provider already defined. */
	#elif defined(DUK_USE_DATE_PRS_STRPTIME)
		#define DUK_USE_DATE_PARSE_STRING(ctx,str)   duk_bi_date_parse_string_strptime((ctx), (str))
	#elif defined(DUK_USE_DATE_PRS_GETDATE)
		#define DUK_USE_DATE_PARSE_STRING(ctx,str)   duk_bi_date_parse_string_getdate((ctx), (str))
	#else
		/* No provider for DUK_USE_DATE_PARSE_STRING(), fall back to ISO 8601 only. */
	#endif

	#if defined(DUK_USE_DATE_FORMAT_STRING)
		/* External provider already defined. */
	#elif defined(DUK_USE_DATE_FMT_STRFTIME)
		#define DUK_USE_DATE_FORMAT_STRING(ctx,parts,tzoffset,flags) \
		duk_bi_date_format_parts_strftime((ctx), (parts), (tzoffset), (flags))
	#else
		/* No provider for DUK_USE_DATE_FORMAT_STRING(), fall back to ISO 8601 only. */
	#endif

	#if defined(DUK_USE_GET_MONOTONIC_TIME)
		/* External provider already defined. */
	#elif defined(DUK_USE_GET_MONOTONIC_TIME_CLOCK_GETTIME)
		#define DUK_USE_GET_MONOTONIC_TIME(ctx)  duk_bi_date_get_monotonic_time_clock_gettime()
	#elif defined(DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC)
		#define DUK_USE_GET_MONOTONIC_TIME(ctx)  duk_bi_date_get_monotonic_time_windows_qpc()
	#else
		/* No provider for DUK_USE_GET_MONOTONIC_TIME(), fall back to DUK_USE_DATE_GET_NOW(). */
	#endif

#endif  /* DUK_COMPILING_DUKTAPE */


#endif  /* DUK_CONFIG_H_INCLUDED */

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-04-06  5:48 kokamoto
  2020-04-13 12:44 ` jamos
  0 siblings, 1 reply; 48+ messages in thread
From: kokamoto @ 2020-04-06  5:48 UTC (permalink / raw)
  To: 9front

> For the arm (rpi3B, 1GB), the problem (I reported it before) is not
> solved yet.

I made nsfbJP for arm64 on the same machine of rpi3B(1GB), and got no problem.
Javascript enabled version could not make, because of insuffient memory.☺

--rwxrwxr-x M 26 sys sys 51058990 Apr  5 13:15 /386/bin/nsfbjs
--rwxrwxr-x M 26 sys sys 56575079 Apr  5 13:17 /amd64/bin/nsfbjs
--rwxrwxr-x M 26 sys sys 50496480 Apr  5 13:12 /arm/bin/nsfbjs
--rwxr-xr-x M 26 sys sys 32518608 Apr  6 14:40 /arm64/bin/nsfbJP

I doubt something wrong with 5c compiler?

Kenji



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-04-05  4:52 kokamoto
  0 siblings, 0 replies; 48+ messages in thread
From: kokamoto @ 2020-04-05  4:52 UTC (permalink / raw)
  To: 9front

Those sizes are as follows:
--rwxrwxr-x M 26 sys sys 51058990 Apr  5 13:15 /386/bin/nsfbjs
--rwxrwxr-x M 26 sys sys 56575079 Apr  5 13:17 /amd64/bin/nsfbjs
--rwxrwxr-x M 26 sys sys 50496480 Apr  5 13:12 /arm/bin/nsfbjs

All the above are for Japanese fonts, and works very fime.
You can confirm it by https://eonet.jp, where if javascript isn't activated
the messages like "javascriptを有効にしてください"

Kenji



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-04-05  4:41 kokamoto
  0 siblings, 0 replies; 48+ messages in thread
From: kokamoto @ 2020-04-05  4:41 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 321 bytes --]

I think I got it to work for 386, amd64 and partially arm.
As the nersurf/content/handlers/javascript/duktape/duk_config.h is too big to me
(about 10KB, which are over my damaged brain memory.☺,)
I rewrited it as that of included.

For the arm (rpi3B, 1GB), the problem (I reported it before) is not
solved yet.

Kenji

[-- Attachment #2: Type: text/plain, Size: 43160 bytes --]

/*
 *  duk_config.h configuration header generated by genconfig.py.
 *
 *  Git commit: external
 *  Git describe: external
 *  Git branch: external
 *
 *  Supported platforms:
 *	- Plan9
 *      - Generic UNIX
 *      - Generic fallback
 *
 *  Supported architectures:
 *      - x86
 *      - x64
 *      - x32
 *      - ARM 32-bit
 *      - ARM 64-bit
 
 *  Supported compilers:
 *      - Generic
 *
 */

#if !defined(DUK_CONFIG_H_INCLUDED)
#define DUK_CONFIG_H_INCLUDED

/*
 *  Intermediate helper defines
 */

/* DLL build detection */
/* not configured for DLL build */
#undef DUK_F_DLL_BUILD

/* Plan9 */
#if defined(__plan9ape__)
	#define DUK_F_PLAN9
#endif

/* Intel x86 (32-bit), x64 (64-bit) or x32 (64-bit but 32-bit pointers),
 * define only one of DUK_F_X86, DUK_F_X64, DUK_F_X32.
 * https://sites.google.com/site/x32abi/
 *
 * With DUK_F_OLD_SOLARIS the <sys/isa_defs.h> header must be included
 * before this.
 */
#if defined(__amd64__) || defined(__amd64) || \
    defined(__x86_64__) || defined(__x86_64) || \
    defined(_M_X64) || defined(_M_AMD64)
	#if defined(__ILP32__) || defined(_ILP32)
		#define DUK_F_X32
	#else
		#define DUK_F_X64
	#endif
#elif defined(i386) || defined(__i386) || defined(__i386__) || defined(__386__) || \
      defined(__i486__) || defined(__i586__) || defined(__i686__) || \
      defined(__IA32__) || defined(_M_IX86) || defined(__X86__) || \
      defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__)
	#if defined(__LP64__) || defined(_LP64)
		/* This should not really happen, but would indicate x64. */
		#define DUK_F_X64
	#else
		#define DUK_F_X86
	#endif
#endif

/* ARM */
#if defined(__arm__) || defined(__thumb__) || defined(_ARM) || defined(_M_ARM) || defined(__aarch64__)
	#define DUK_F_ARM
	#if defined(__LP64__) || defined(_LP64) || defined(__arm64) || defined(__arm64__) || defined(__aarch64__)
		#define DUK_F_ARM64
	#else
		#define DUK_F_ARM32
	#endif
#endif

/*************************************
 *  Platform autodetection
 *************************************/
#if defined(DUK_F_PLAN9)
	#define DUK_USE_DATE_NOW_GETTIMEOFDAY
	#define DUK_USE_DATE_TZO_GMTIME_R
	#define DUK_USE_DATE_PRS_STRPTIME
	#define DUK_USE_DATE_FMT_STRFTIME
	#define _REENTRANT_SOURCE
	#define DUK_DOUBLE_INFINITY Inf(1)
	#define DUK_DOUBLE_NAN       (NaN())
	#define DUK_SIZE_MAX SSIZE_MAX
	#define DUK_SINGLE_FILE
	#if defined(__386__) || defined(__arm__)
		#define DUK_F_32BIT_PTRS
		#if defined(__386__)
			#define DUK_USE_INTEGER_LE
			#define DUK_USE_DOUBLE_LE
		#else
			#define DUK_USE_INTEGER_LE  	/* integer endianness is little on purpose */
			#define DUK_USE_DOUBLE_ME
		#endif
	#elif defined(__amd64__) || defined(__arm64__)
		#define DUK_F_64BIT_PTRS
		#if defined(__amd64__)
			#define DUK_USE_INTEGER_LE
			#define DUK_USE_DOUBLE_LE
		#else
			#define DUK_USE_INTEGER_LE  	/* integer endianness is little on purpose */
			#define DUK_USE_DOUBLE_ME
		#endif
	#endif
	typedef int duk_int_t;
	#include <sys/types.h>
	#include <stdint.h>
	#include <sys/param.h>
	#include <time.h>
	#include <sys/time.h>
	#define DUK_USE_OS_STRING "plan9"
	typedef intptr_t duk_intptr_t;
	typedef unsigned short	duk_small_uint_fast_t;
	typedef unsigned int	duk_uint_fast_t;
	typedef int duk_int_fast_t;
#endif  /* autodetect platform */

/********************************************************
 *  End of Platform autodetection ******
 ********************************************************/

/*******************************************************************************
**************************** for all platforms ***********************************
********************************************************************************/
/* Shared includes: C89 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>  /* varargs */
#include <setjmp.h>
#include <stddef.h>  /* e.g. ptrdiff_t */
#include <math.h>
#include <limits.h>

/* Shared includes: stdint.h is C99 */
#include <stdint.h>

/* <exception> is only included if needed, based on DUK_USE_xxx flags. */

/***************************************************************************
 ********************  Architecture autodetection ***************************
 ****************************************************************************/

#if defined(DUK_F_X86)						/* --- x86 --- */
	#define DUK_USE_ARCH_STRING "x86"
	#if !defined(DUK_USE_BYTEORDER)
		#define DUK_USE_BYTEORDER 1
	#endif
	#define DUK_USE_PACKED_TVAL

	/* FreeBSD, -m32, and clang prior to 5.0 has union aliasing issues which
	 * break duk_tval copying.  Disable packed duk_tval automatically.
	 */
	#if defined(DUK_F_FREEBSD) && defined(DUK_F_X86) && \
	    defined(__clang__) && defined(__clang_major__) && (__clang_major__ < 5)
		#undef DUK_USE_PACKED_TVAL
	#endif
	#define DUK_F_PACKED_TVAL_PROVIDED

#elif defined(DUK_F_X64)						/* --- x64 --- */
	#define DUK_USE_ARCH_STRING "x64"
	#if !defined(DUK_USE_BYTEORDER)
		#define DUK_USE_BYTEORDER 1
	#endif
	#undef DUK_USE_PACKED_TVAL
	#define DUK_F_PACKED_TVAL_PROVIDED

#elif defined(DUK_F_ARM32)					/* --- ARM 32-bit --- */
	#define DUK_USE_ARCH_STRING "arm32"
	/* Byte order varies, so rely on autodetect. */
	#define DUK_USE_PACKED_TVAL
	#define DUK_F_PACKED_TVAL_PROVIDED

#elif defined(DUK_F_ARM64)					/* --- ARM 64-bit --- */
	#define DUK_USE_ARCH_STRING "arm64"
	/* Byte order varies, so rely on autodetect. */
	#undef DUK_USE_PACKED_TVAL
	#define DUK_F_PACKED_TVAL_PROVIDED

#endif  /* autodetect architecture */

/***************************************************************************
 ********************End of  Architecture autodetection *********************
 ****************************************************************************/

/***************************************************************************
 *********************  Compiler autodetection *****************************
 ***************************************************************************/
										/* --- Generic --- */
#undef DUK_USE_BRANCH_HINTS
#if defined(DUK_F_CPP)
	#define DUK_USE_COMPILER_STRING "generic-c++"
#else
	#define DUK_USE_COMPILER_STRING "generic"
#endif
#undef DUK_USE_VARIADIC_MACROS
	/* C++ doesn't have standard designated union initializers ({ .foo = 1 }). */
#undef DUK_USE_UNION_INITIALIZERS
	/* Most portable, wastes space */
#define DUK_USE_FLEX_ONESIZE
	/* Most portable, potentially wastes space */
#define DUK_USE_PACK_DUMMY_MEMBER

/***************************************************************************
 *********************End of   Compiler autodetection **********************
 ***************************************************************************/

/*
 *  Wrapper typedefs and constants for integer types, also sanity check types.
 *
 *  C99 typedefs are quite good but not always available, and we want to avoid
 *  forcibly redefining the C99 typedefs.  So, there are Duktape wrappers for
 *  all C99 typedefs and Duktape code should only use these typedefs.  Type
 *  detection when C99 is not supported is best effort and may end up detecting
 *  some types incorrectly.
 *
 *  Pointer sizes are a portability problem: pointers to different types may
 *  have a different size and function pointers are very difficult to manage
 *  portably.
 *
 *  http://en.wikipedia.org/wiki/C_data_types#Fixed-width_integer_types
 *
 *  Note: there's an interesting corner case when trying to define minimum
 *  signed integer value constants which leads to the current workaround of
 *  defining e.g. -0x80000000 as (-0x7fffffffL - 1L).  See doc/code-issues.txt
 *  for a longer discussion.
 *
 *  Note: avoid typecasts and computations in macro integer constants as they
 *  can then no longer be used in macro relational expressions (such as
 *  #if DUK_SIZE_MAX < 0xffffffffUL).  There is internal code which relies on
 *  being able to compare DUK_SIZE_MAX against a limit.
 */

/* XXX: add feature options to force basic types from outside? */

#if !defined(INT_MAX)		/* defined in limits.h */
	#error INT_MAX not defined
#endif

/* Check that architecture is two's complement, standard C allows e.g.
 * INT_MIN to be -2**31+1 (instead of -2**31).
 */
#if defined(INT_MAX) && defined(INT_MIN)		/* Plan9 OK */
	#if INT_MAX != -(INT_MIN + 1)
		#error platform does not seem complement of two
	#endif
#else
	#error cannot check complement of two
#endif

/* Pointer size determination based on __WORDSIZE or architecture when
 * that's not available.
 */
#if defined(DUK_F_X86) || defined(DUK_F_X32) || \
    defined(DUK_F_M68K) || defined(DUK_F_PPC32) || \
    defined(DUK_F_BCC) || \
    (defined(__WORDSIZE) && (__WORDSIZE == 32)) || \
    ((defined(DUK_F_OLD_SOLARIS) || defined(DUK_F_AIX) || \
      defined(DUK_F_HPUX)) && defined(_ILP32)) || \
    defined(DUK_F_ARM32)
	#define DUK_F_32BIT_PTRS		/* plan9ape OK */
#elif defined(DUK_F_X64) || \
      (defined(__WORDSIZE) && (__WORDSIZE == 64)) || \
   ((defined(DUK_F_OLD_SOLARIS) || defined(DUK_F_AIX) || \
     defined(DUK_F_HPUX)) && defined(_LP64)) || \
    defined(DUK_F_ARM64)
	#define DUK_F_64BIT_PTRS
#else
	/* not sure, not needed with C99 anyway */
#endif

/* Basic integer typedefs and limits, preferably from inttypes.h, otherwise
 * through automatic detection.
 */

/****************************************************************************************
********************* Start of C99 types ***plan9ape is here******************************
*****************************************************************************************/
/* When C99 types are not available, we use heuristic detection to get
 * the basic 8, 16, 32, and (possibly) 64 bit types.  The fast/least
 * types are then assumed to be exactly the same for now: these could
 * be improved per platform but C99 types are very often now available.
 * 64-bit types are not available on all platforms; this is OK at least
 * on 32-bit platforms.
 *
 * This detection code is necessarily a bit hacky and can provide typedefs
 * and defines that won't work correctly on some exotic platform.
 */
#if (defined(CHAR_BIT) && (CHAR_BIT == 8)) || \
   	 (defined(UCHAR_MAX) && (UCHAR_MAX == 255))
		typedef unsigned char duk_uint8_t;
		typedef signed char duk_int8_t;
#else
	#error cannot detect 8-bit type
#endif
#if defined(USHRT_MAX) && (USHRT_MAX == 65535UL)		/* plan9 is this K.Okamoto */
	typedef unsigned short duk_uint16_t;
	typedef signed short duk_int16_t;
#endif
#if defined(UINT_MAX) && (UINT_MAX == 4294967295UL)		/* plan9 is this K.Okamoto */
	typedef unsigned int duk_uint32_t;
	typedef signed int duk_int32_t;
#elif defined(ULONG_MAX) && (ULONG_MAX == 4294967295UL)
	/* On some platforms int is 16-bit but long is 32-bit (e.g. PureC) */
	typedef unsigned long duk_uint32_t;
	typedef signed long duk_int32_t;
#else
	#error cannot detect 32-bit type
#endif

/* 64-bit type detection is a bit tricky.
 *
 * ULLONG_MAX is a standard define.  __LONG_LONG_MAX__ and __ULONG_LONG_MAX__
 * are used by at least GCC (even if system headers don't provide ULLONG_MAX).
 * Some GCC variants may provide __LONG_LONG_MAX__ but not __ULONG_LONG_MAX__.
 *
 * ULL / LL constants are rejected / warned about by some compilers, even if
 * the compiler has a 64-bit type and the compiler/system headers provide an
 * unsupported constant (ULL/LL)!  Try to avoid using ULL / LL constants.
 * As a side effect we can only check that e.g. ULONG_MAX is larger than 32
 * bits but can't be sure it is exactly 64 bits.  Self tests will catch such
 * cases.
 */
#undef DUK_F_HAVE_64BIT
#if !defined(DUK_F_32BIT_PTR)
	#if !defined(DUK_F_HAVE_64BIT) && defined(ULLONG_MAX)		/*  ULLONG_MAX in limits.h K.Okamoto */
		#define DUK_F_HAVE_64BIT
		typedef unsigned long long duk_uint64_t;
		typedef long long duk_int64_t;
	#endif
#endif

typedef duk_uint8_t duk_uint_least8_t;
typedef duk_int8_t duk_int_least8_t;
typedef duk_uint16_t duk_uint_least16_t;
typedef duk_int16_t duk_int_least16_t;
typedef duk_uint32_t duk_uint_least32_t;
typedef duk_int32_t duk_int_least32_t;
typedef duk_uint8_t duk_uint_fast8_t;
typedef duk_int8_t duk_int_fast8_t;
typedef duk_uint16_t duk_uint_fast16_t;
typedef duk_int16_t duk_int_fast16_t;
typedef duk_uint32_t duk_uint_fast32_t;
typedef duk_int32_t duk_int_fast32_t;
#if defined(DUK_F_HAVE_64BIT)
	typedef duk_uint64_t duk_uint_least64_t;
	typedef duk_int64_t duk_int_least64_t;
	typedef duk_uint64_t duk_uint_fast64_t;
	typedef duk_int64_t duk_int_fast64_t;
#endif
#if defined(DUK_F_HAVE_64BIT)
	typedef duk_uint64_t duk_uintmax_t;
	typedef duk_int64_t duk_intmax_t;
#else
	typedef duk_uint32_t duk_uintmax_t;
	typedef duk_int32_t duk_intmax_t;
#endif

/* Note: the funny looking computations for signed minimum 16-bit, 32-bit, and
  * 64-bit values are intentional as the obvious forms (e.g. -0x80000000L) are
  * -not- portable.  See code-issues.txt for a detailed discussion.
  */
#define DUK_UINT8_MIN         0UL
#define DUK_UINT8_MAX         0xffUL
#define DUK_INT8_MIN          (-0x80L)
#define DUK_INT8_MAX          0x7fL
#define DUK_UINT_LEAST8_MIN   0UL
#define DUK_UINT_LEAST8_MAX   0xffUL
	#define DUK_INT_LEAST8_MIN    (-0x80L)
	#define DUK_INT_LEAST8_MAX    0x7fL
	#define DUK_UINT_FAST8_MIN    0UL
	#define DUK_UINT_FAST8_MAX    0xffUL
	#define DUK_INT_FAST8_MIN     (-0x80L)
	#define DUK_INT_FAST8_MAX     0x7fL
	#define DUK_UINT16_MIN        0UL
	#define DUK_UINT16_MAX        0xffffUL
	#define DUK_INT16_MIN         (-0x7fffL - 1L)
	#define DUK_INT16_MAX         0x7fffL
	#define DUK_UINT_LEAST16_MIN  0UL
	#define DUK_UINT_LEAST16_MAX  0xffffUL
	#define DUK_INT_LEAST16_MIN   (-0x7fffL - 1L)
	#define DUK_INT_LEAST16_MAX   0x7fffL
	#define DUK_UINT_FAST16_MIN   0UL
	#define DUK_UINT_FAST16_MAX   0xffffUL
	#define DUK_INT_FAST16_MIN    (-0x7fffL - 1L)
	#define DUK_INT_FAST16_MAX    0x7fffL
	#define DUK_UINT32_MIN        0UL
	#define DUK_UINT32_MAX        0xffffffffUL
	#define DUK_INT32_MIN         (-0x7fffffffL - 1L)
	#define DUK_INT32_MAX         0x7fffffffL
	#define DUK_UINT_LEAST32_MIN  0UL
	#define DUK_UINT_LEAST32_MAX  0xffffffffUL
	#define DUK_INT_LEAST32_MIN   (-0x7fffffffL - 1L)
	#define DUK_INT_LEAST32_MAX   0x7fffffffL
	#define DUK_UINT_FAST32_MIN   0UL
	#define DUK_UINT_FAST32_MAX   0xffffffffUL
	#define DUK_INT_FAST32_MIN    (-0x7fffffffL - 1L)
	#define DUK_INT_FAST32_MAX    0x7fffffffL

	/* 64-bit constants.  Since LL / ULL constants are not always available,
	 * use computed values.  These values can't be used in preprocessor
	 * comparisons; flag them as such.
	 */
	#if defined(DUK_F_HAVE_64BIT)
		#define DUK_UINT64_MIN        ((duk_uint64_t) 0)
		#define DUK_UINT64_MAX        ((duk_uint64_t) -1)
		#define DUK_INT64_MIN         ((duk_int64_t) (~(DUK_UINT64_MAX >> 1)))
		#define DUK_INT64_MAX         ((duk_int64_t) (DUK_UINT64_MAX >> 1))
		#define DUK_UINT_LEAST64_MIN  DUK_UINT64_MIN
		#define DUK_UINT_LEAST64_MAX  DUK_UINT64_MAX
		#define DUK_INT_LEAST64_MIN   DUK_INT64_MIN
		#define DUK_INT_LEAST64_MAX   DUK_INT64_MAX
		#define DUK_UINT_FAST64_MIN   DUK_UINT64_MIN
		#define DUK_UINT_FAST64_MAX   DUK_UINT64_MAX
		#define DUK_INT_FAST64_MIN    DUK_INT64_MIN
		#define DUK_INT_FAST64_MAX    DUK_INT64_MAX
		#define DUK_UINT64_MIN_COMPUTED
		#define DUK_UINT64_MAX_COMPUTED
		#define DUK_INT64_MIN_COMPUTED
		#define DUK_INT64_MAX_COMPUTED
		#define DUK_UINT_LEAST64_MIN_COMPUTED
		#define DUK_UINT_LEAST64_MAX_COMPUTED
		#define DUK_INT_LEAST64_MIN_COMPUTED
		#define DUK_INT_LEAST64_MAX_COMPUTED
		#define DUK_UINT_FAST64_MIN_COMPUTED
		#define DUK_UINT_FAST64_MAX_COMPUTED
		#define DUK_INT_FAST64_MIN_COMPUTED
		#define DUK_INT_FAST64_MAX_COMPUTED
	#endif

	#if defined(DUK_F_HAVE_64BIT)
		#define DUK_UINTMAX_MIN       DUK_UINT64_MIN
		#define DUK_UINTMAX_MAX       DUK_UINT64_MAX
		#define DUK_INTMAX_MIN        DUK_INT64_MIN
		#define DUK_INTMAX_MAX        DUK_INT64_MAX
		#define DUK_UINTMAX_MIN_COMPUTED
		#define DUK_UINTMAX_MAX_COMPUTED
		#define DUK_INTMAX_MIN_COMPUTED
		#define DUK_INTMAX_MAX_COMPUTED
	#else
		#define DUK_UINTMAX_MIN       0UL
		#define DUK_UINTMAX_MAX       0xffffffffUL
		#define DUK_INTMAX_MIN        (-0x7fffffffL - 1L)
		#define DUK_INTMAX_MAX        0x7fffffffL
	#endif

		/* This detection is not very reliable. */
	#if defined(DUK_F_32BIT_PTRS)
		typedef duk_int32_t duk_intptr_t;
		typedef duk_uint32_t duk_uintptr_t;
		#define DUK_UINTPTR_MIN       DUK_UINT32_MIN
		#define DUK_UINTPTR_MAX       DUK_UINT32_MAX
		#define DUK_INTPTR_MIN        DUK_INT32_MIN
		#define DUK_INTPTR_MAX        DUK_INT32_MAX
	#elif defined(DUK_F_64BIT_PTRS) && defined(DUK_F_HAVE_64BIT)
		typedef duk_int64_t duk_intptr_t;
		typedef duk_uint64_t duk_uintptr_t;
		#define DUK_UINTPTR_MIN       DUK_UINT64_MIN
		#define DUK_UINTPTR_MAX       DUK_UINT64_MAX
		#define DUK_INTPTR_MIN        DUK_INT64_MIN
		#define DUK_INTPTR_MAX        DUK_INT64_MAX
		#define DUK_UINTPTR_MIN_COMPUTED
		#define DUK_UINTPTR_MAX_COMPUTED
		#define DUK_INTPTR_MIN_COMPUTED
		#define DUK_INTPTR_MAX_COMPUTED
	#else
		#error cannot determine intptr type
	#endif

	/* SIZE_MAX may be missing so use an approximate value for it. */
	#undef DUK_SIZE_MAX_COMPUTED
	#if !defined(SIZE_MAX) && !defined(SSIZE_MAX)	/* added by K.Okamoto */
		#define DUK_SIZE_MAX_COMPUTED
		#define SIZE_MAX              ((size_t) (-1))
	#endif
	#define DUK_SIZE_MIN          0

/****************************************************************************************
********************* End of C99 types ***plan9ape is there******************************
*****************************************************************************************/

/* A few types are assumed to always exist. */
typedef size_t duk_size_t;
typedef ptrdiff_t duk_ptrdiff_t;

/* The best type for an "all around int" in Duktape internals is "at least
 * 32 bit signed integer" which is most convenient.  Same for unsigned type.
 * Prefer 'int' when large enough, as it is almost always a convenient type.
 */
#if defined(UINT_MAX) && (UINT_MAX >= 0xffffffffUL)	/*plan9ape is here */
	typedef int duk_int_t;
	typedef unsigned int duk_uint_t;
	#define DUK_INT_MIN           INT_MIN
	#define DUK_INT_MAX           INT_MAX
	#define DUK_UINT_MIN          0
	#define DUK_UINT_MAX          UINT_MAX
#else
	typedef duk_int_fast32_t duk_int_t;
	typedef duk_uint_fast32_t duk_uint_t;
	#define DUK_INT_MIN           DUK_INT_FAST32_MIN
	#define DUK_INT_MAX           DUK_INT_FAST32_MAX
	#define DUK_UINT_MIN          DUK_UINT_FAST32_MIN
	#define DUK_UINT_MAX          DUK_UINT_FAST32_MAX
#endif


/* Small integers (16 bits or more) can fall back to the 'int' type, but
 * have a typedef so they are marked "small" explicitly.
 */
typedef int duk_small_int_t;
typedef unsigned int duk_small_uint_t;
#define DUK_SMALL_INT_MIN     INT_MIN
#define DUK_SMALL_INT_MAX     INT_MAX
#define DUK_SMALL_UINT_MIN    0
#define DUK_SMALL_UINT_MAX    UINT_MAX

/* Boolean values are represented with the platform 'unsigned int'. */
typedef duk_small_uint_t duk_bool_t;
#define DUK_BOOL_MIN              DUK_SMALL_UINT_MIN
#define DUK_BOOL_MAX              DUK_SMALL_UINT_MAX

/* Index values must have at least 32-bit signed range. */
typedef duk_int_t duk_idx_t;
#define DUK_IDX_MIN               DUK_INT_MIN
#define DUK_IDX_MAX               DUK_INT_MAX

/* Unsigned index variant. */
typedef duk_uint_t duk_uidx_t;
#define DUK_UIDX_MIN              DUK_UINT_MIN
#define DUK_UIDX_MAX              DUK_UINT_MAX

/* Array index values, could be exact 32 bits.
 * Currently no need for signed duk_arridx_t.
 */
typedef duk_uint_t duk_uarridx_t;
#define DUK_UARRIDX_MIN           DUK_UINT_MIN
#define DUK_UARRIDX_MAX           DUK_UINT_MAX

/* Duktape/C function return value, platform int is enough for now to
 * represent 0, 1, or negative error code.  Must be compatible with
 * assigning truth values (e.g. duk_ret_t rc = (foo == bar);).
 */
typedef duk_small_int_t duk_ret_t;
#define DUK_RET_MIN               DUK_SMALL_INT_MIN
#define DUK_RET_MAX               DUK_SMALL_INT_MAX

/* Error codes are represented with platform int.  High bits are used
 * for flags and such, so 32 bits are needed.
 */
typedef duk_int_t duk_errcode_t;
#define DUK_ERRCODE_MIN           DUK_INT_MIN
#define DUK_ERRCODE_MAX           DUK_INT_MAX

/* Codepoint type.  Must be 32 bits or more because it is used also for
 * internal codepoints.  The type is signed because negative codepoints
 * are used as internal markers (e.g. to mark EOF or missing argument).
 * (X)UTF-8/CESU-8 encode/decode take and return an unsigned variant to
 * ensure duk_uint32_t casts back and forth nicely.  Almost everything
 * else uses the signed one.
 */
typedef duk_int_t duk_codepoint_t;
typedef duk_uint_t duk_ucodepoint_t;
#define DUK_CODEPOINT_MIN         DUK_INT_MIN
#define DUK_CODEPOINT_MAX         DUK_INT_MAX
#define DUK_UCODEPOINT_MIN        DUK_UINT_MIN
#define DUK_UCODEPOINT_MAX        DUK_UINT_MAX

/* IEEE float/double typedef. */
typedef float duk_float_t;
typedef double duk_double_t;

/* We're generally assuming that we're working on a platform with a 32-bit
 * address space.  If DUK_SIZE_MAX is a typecast value (which is necessary
 * if SIZE_MAX is missing), the check must be avoided because the
 * preprocessor can't do a comparison.
 */
#if !defined(DUK_SIZE_MAX)
	#error DUK_SIZE_MAX is undefined, probably missing SIZE_MAX
#elif !defined(DUK_SIZE_MAX_COMPUTED)
	#if DUK_SIZE_MAX < 0xffffffffUL
		/* On some systems SIZE_MAX can be smaller than max unsigned 32-bit value
		 * which seems incorrect if size_t is (at least) an unsigned 32-bit type.
		 * However, it doesn't seem useful to error out compilation if this is the
		 * case.
		 */
	#endif
#endif

/* Type used in public API declarations and user code.  Typedef maps to
 * 'struct duk_hthread' like the 'duk_hthread' typedef which is used
 * exclusively in internals.
 */
typedef struct duk_hthread duk_context;

/* Check whether we should use 64-bit integers or not.
 *
 * Quite incomplete now.  Use 64-bit types if detected (C99 or other detection)
 * unless they are known to be unreliable.  For instance, 64-bit types are
 * available on VBCC but seem to misbehave.
 */
#define DUK_USE_64BIT_OPS

/*
 *  Fill-ins for platform, architecture, and compiler
 */

/* An abort()-like primitive is needed by the default fatal error handler. */
#if !defined(DUK_ABORT)
	#define DUK_ABORT             abort
#endif

#if !defined(DUK_SETJMP)
	#define DUK_JMPBUF_TYPE       jmp_buf
	#define DUK_SETJMP(jb)        setjmp((jb))
	#define DUK_LONGJMP(jb)       longjmp((jb), 1)
#endif

/* Special naming to avoid conflict with e.g. DUK_FREE() in duk_heap.h
 * (which is unfortunately named).  May sometimes need replacement, e.g.
 * some compilers don't handle zero length or NULL correctly in realloc().
 */
#define DUK_ANSI_MALLOC      malloc
#define DUK_ANSI_REALLOC     realloc
#define DUK_ANSI_CALLOC      calloc
#define DUK_ANSI_FREE        free

/* ANSI C (various versions) and some implementations require that the
 * pointer arguments to memset(), memcpy(), and memmove() be valid values
 * even when byte size is 0 (even a NULL pointer is considered invalid in
 * this context).  Zero-size operations as such are allowed, as long as their
 * pointer arguments point to a valid memory area.  The DUK_MEMSET(),
 * DUK_MEMCPY(), and DUK_MEMMOVE() macros require this same behavior, i.e.:
 * (1) pointers must be valid and non-NULL, (2) zero size must otherwise be
 * allowed.  If these are not fulfilled, a macro wrapper is needed.
 *
 *   http://stackoverflow.com/questions/5243012/is-it-guaranteed-to-be-safe-to-perform-memcpy0-0-0
 *   http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-October/011065.html
 *
 * Not sure what's the required behavior when a pointer points just past the
 * end of a buffer, which often happens in practice (e.g. zero size memmoves).
 * For example, if allocation size is 3, the following pointer would not
 * technically point to a valid memory byte:
 *
 *   <-- alloc -->
 *   | 0 | 1 | 2 | .....
 *                 ^-- p=3, points after last valid byte (2)
 */
#define DUK_MEMCPY       memcpy
#define DUK_MEMMOVE      memmove
#define DUK_MEMCMP       memcmp
#define DUK_MEMSET       memset
#define DUK_STRLEN       strlen
#define DUK_STRCMP       strcmp
#define DUK_STRNCMP      strncmp
#define DUK_SPRINTF      sprintf
#define DUK_SNPRINTF     snprintf
#define DUK_VSPRINTF     vsprintf
#define DUK_VSNPRINTF    vsnprintf
#define DUK_SSCANF       sscanf
#if !defined(DUK_MEMZERO)
	#define DUK_MEMZERO(p,n) DUK_MEMSET((p), 0, (n))
#endif

/* Many platforms are missing fpclassify() and friends, so use replacements
 * if necessary.  The replacement constants (FP_NAN etc) can be anything but
 * match Linux constants now.
 */

/* Complex condition broken into separate parts. */
#define DUK_USE_REPL_FPCLASSIFY
#define DUK_USE_REPL_SIGNBIT
#define DUK_USE_REPL_ISFINITE
#define DUK_USE_REPL_ISNAN
#define DUK_USE_REPL_ISINF
#define DUK_FPCLASSIFY       duk_repl_fpclassify
#define DUK_SIGNBIT          duk_repl_signbit
#define DUK_ISFINITE         duk_repl_isfinite
#define DUK_ISNAN            duk_repl_isnan
#define DUK_ISINF            duk_repl_isinf
#define DUK_FP_NAN           0
#define DUK_FP_INFINITE      1
#define DUK_FP_ZERO          2
#define DUK_FP_SUBNORMAL     3
#define DUK_FP_NORMAL        4

/* These functions don't currently need replacement but are wrapped for
 * completeness.  Because these are used as function pointers, they need
 * to be defined as concrete C functions (not macros).
 */
#define DUK_FABS             fabs		/* in math.h for plan9  */
#define DUK_FLOOR            floor	/* in math.h for plan9  */
#define DUK_CEIL             ceil		/* in math.h for plan9  */
#define DUK_FMOD             fmod	/* in math.h for plan9  */
#define DUK_POW              pow		/* in math.h for plan9  */
#define DUK_ACOS             acos	/* in math.h for plan9  */
#define DUK_ASIN             asin		/* in math.h for plan9  */
#define DUK_ATAN             atan	/* in math.h for plan9  */
#define DUK_ATAN2            atan2	/* in math.h for plan9  */
#define DUK_SIN              sin		/* in math.h for plan9  */
#define DUK_COS              cos		/* in math.h for plan9  */
#define DUK_TAN              tan		/* in math.h for plan9  */
#define DUK_EXP              exp		/* in math.h for plan9  */
#define DUK_LOG              log		/* in math.h for plan9  */
#define DUK_SQRT             sqrt		/* in math.h for plan9  */

#define DUK_LOG10            log10

/* Rely as little as possible on compiler behavior for NaN comparison,
 * signed zero handling, etc.  Currently never activated but may be needed
 * for broken compilers.
 */
#undef DUK_USE_PARANOID_MATH

#define DUK_USE_PARANOID_DATE_COMPUTATION

/* More or less standard endianness predefines provided by header files.
 * The ARM hybrid case is detected by assuming that __FLOAT_WORD_ORDER
 * will be big endian, see: http://lists.mysql.com/internals/443.
 * On some platforms some defines may be present with an empty value which
 * causes comparisons to fail: https://github.com/svaarala/duktape/issues/453.
 */

/*
 *  Alignment requirement and support for unaligned accesses
 *
 *  Assume unaligned accesses are not supported unless specifically allowed
 *  in the target platform.  Some platforms may support unaligned accesses
 *  but alignment to 4 or 8 may still be desirable.  Note that unaligned
 *  accesses (and even pointers) relative to natural alignment (regardless
 *  of target alignment) are technically undefined behavior and thus
 *  compiler/architecture specific.
 */

/* If not forced, use safe default for alignment. */
#if !defined(DUK_USE_ALIGN_BY)
	#define DUK_USE_ALIGN_BY 8
#endif

/* Compiler specific hackery needed to force struct size to match aligment,
 * see e.g. duk_hbuffer.h.
 *
 * http://stackoverflow.com/questions/11130109/c-struct-size-alignment
 * http://stackoverflow.com/questions/10951039/specifying-64-bit-alignment
 */

#define DUK_VA_COPY(dest,src) va_copy(dest,src)

#if !defined(DUK_MACRO_STRINGIFY)
	/* Macro hackery to convert e.g. __LINE__ to a string without formatting,
	 * see: http://stackoverflow.com/questions/240353/convert-a-preprocessor-token-to-a-string
	 */
	#define DUK_MACRO_STRINGIFY_HELPER(x)  #x
	#define DUK_MACRO_STRINGIFY(x)  DUK_MACRO_STRINGIFY_HELPER(x)
#endif

#if !defined(DUK_CAUSE_SEGFAULT)
	/* This can be used for testing; valgrind will then indicate the C call stack
	 * leading to the call site.
	 */
	#define DUK_CAUSE_SEGFAULT()  do { *((volatile duk_uint32_t *) NULL) = (duk_uint32_t) 0xdeadbeefUL; } while (0)
#endif

#if !defined(DUK_UNREF)
	/* Macro for suppressing warnings for potentially unreferenced variables.
	 * The variables can be actually unreferenced or unreferenced in some
	 * specific cases only; for instance, if a variable is only debug printed,
	 * it is unreferenced when debug printing is disabled.  May cause warnings
	 * for volatile arguments.
 	 */
	#define DUK_UNREF(x)  do { (void) (x); } while (0)
#endif

/* Fillin for DUK_NORETURN; DUK_WO_NORETURN() is used to insert dummy
 * dummy statements after noreturn calls to silence harmless compiler
 * warnings, e.g.:
 *
 *   DUK_ERROR_TYPE(thr, "aiee");
 *   DUK_WO_NORETURN(return 0;);
 *
 * Statements inside DUK_WO_NORETURN() must NEVER be actually reachable,
 * and they're only included to satisfy the compiler.
 */
#define DUK_NORETURN(decl) decl
//#define DUK_WO_NORETURN(smtp) smtp

/* Convert any input pointer into a "void *", losing a const qualifier.
 * This is not fully portable because casting through duk_uintptr_t may
 * not work on all architectures (e.g. those with long, segmented pointers).
 */
#define DUK_LOSE_CONST(src) ((void *) (duk_uintptr_t) (src))

#define DUK_LIKELY(x)    (x)
#define DUK_UNLIKELY(x)  (x)
#define DUK_UNPREDICTABLE(x)  (x)

#define DUK_NOINLINE       /*nop*/
#define DUK_INLINE         /*nop*/
#define DUK_ALWAYS_INLINE  /*nop*/

#define DUK_HOT            /*nop*/
#define DUK_COLD           /*nop*/
#define DUK_EXTERNAL_DECL  extern
#define DUK_EXTERNAL       /*empty*/
#if defined(DUK_SINGLE_FILE)
	#define DUK_INTERNAL_DECL  static
#else
	#define DUK_INTERNAL_DECL  extern
#endif
#if defined(DUK_SINGLE_FILE)
	#define DUK_INTERNAL       static
#else
	#define DUK_INTERNAL       /*empty*/
#endif
#define DUK_LOCAL_DECL     static
#define DUK_LOCAL          static


#if !defined(DUK_FILE_MACRO)
	#define DUK_FILE_MACRO  __FILE__
#endif
#if !defined(DUK_LINE_MACRO)
	#define DUK_LINE_MACRO  __LINE__
#endif
#if !defined(DUK_FUNC_MACRO)
	#if defined(DUK_F_C99) || defined(DUK_F_CPP11)
		#define DUK_FUNC_MACRO  __func__
	#elif defined(__FUNCTION__)
		#define DUK_FUNC_MACRO  __FUNCTION__
	#else
		#define DUK_FUNC_MACRO  "unknown"
	#endif
#endif

#if !defined(DUK_BSWAP32)
	#define DUK_BSWAP32(x) \
		((((duk_uint32_t) (x)) >> 24) | \
		 ((((duk_uint32_t) (x)) >> 8) & 0xff00UL) | \
		 ((((duk_uint32_t) (x)) << 8) & 0xff0000UL) | \
		 (((duk_uint32_t) (x)) << 24))
#endif
#if !defined(DUK_BSWAP16)
	#define DUK_BSWAP16(x) \
		((duk_uint16_t) (x) >> 8) | \
		((duk_uint16_t) (x) << 8)
#endif

#if !defined(DUK_U64_CONSTANT)
	#define DUK_U64_CONSTANT(x) x##ULL
#endif
#if !defined(DUK_I64_CONSTANT)
	#define DUK_I64_CONSTANT(x) x##LL
#endif

/*
 *  Check whether or not a packed duk_tval representation is possible.
 *  What's basically required is that pointers are 32-bit values
 *  (sizeof(void *) == 4).  Best effort check, not always accurate.
 *  If guess goes wrong, crashes may result; self tests also verify
 *  the guess.
 */

/* Explicit marker needed; may be 'defined', 'undefined, 'or 'not provided'. */

#if !defined(DUK_F_PACKED_TVAL_PROVIDED)
	#undef DUK_F_PACKED_TVAL_POSSIBLE
	/* Strict C99 case: DUK_UINTPTR_MAX (= UINTPTR_MAX) should be very reliable */
	#if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_UINTPTR_MAX)
		#if (DUK_UINTPTR_MAX <= 0xffffffffUL)
			#define DUK_F_PACKED_TVAL_POSSIBLE
		#endif
	#endif
		/* Non-C99 case, still relying on DUK_UINTPTR_MAX, as long as it is not a computed value */
	#if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_UINTPTR_MAX) && !defined(DUK_UINTPTR_MAX_COMPUTED)
		#if (DUK_UINTPTR_MAX <= 0xffffffffUL)
			#define DUK_F_PACKED_TVAL_POSSIBLE
		#endif
	#endif
		/* DUK_SIZE_MAX (= SIZE_MAX) is often reliable */
	#if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_SIZE_MAX) && !defined(DUK_SIZE_MAX_COMPUTED)
		#if (DUK_SIZE_MAX <= 0xffffffffUL)
			#define DUK_F_PACKED_TVAL_POSSIBLE
		#endif
	#endif
	#undef DUK_USE_PACKED_TVAL
	#if defined(DUK_F_PACKED_TVAL_POSSIBLE)
		#define DUK_USE_PACKED_TVAL
	#endif
	#undef DUK_F_PACKED_TVAL_POSSIBLE

#endif  /* DUK_F_PACKED_TVAL_PROVIDED */

/* Object property allocation layout has implications for memory and code
 * footprint and generated code size/speed.  The best layout also depends
 * on whether the platform has alignment requirements or benefits from
 * having mostly aligned accesses.
 */
#undef DUK_USE_HOBJECT_LAYOUT_1
#undef DUK_USE_HOBJECT_LAYOUT_2
#undef DUK_USE_HOBJECT_LAYOUT_3
#if (DUK_USE_ALIGN_BY == 1)
	/* On platforms without any alignment issues, layout 1 is preferable
	 * because it compiles to slightly less code and provides direct access
	 * to property keys.
	 */
	#define DUK_USE_HOBJECT_LAYOUT_1
#else
	/* On other platforms use layout 2, which requires some padding but
	 * is a bit more natural than layout 3 in ordering the entries.  Layout
	 * 3 is currently not used.
	 */
	#define DUK_USE_HOBJECT_LAYOUT_2
#endif

/*
 *  Autogenerated defaults
 */

#undef DUK_USE_ALLOW_UNDEFINED_BEHAVIOR
#define DUK_USE_ARRAY_BUILTIN
#define DUK_USE_ARRAY_FASTPATH
#define DUK_USE_ARRAY_PROP_FASTPATH
#undef DUK_USE_ASSERTIONS
#define DUK_USE_AUGMENT_ERROR_CREATE
#define DUK_USE_AUGMENT_ERROR_THROW
#define DUK_USE_AVOID_PLATFORM_FUNCPTRS
#define DUK_USE_BASE64_FASTPATH
#define DUK_USE_BASE64_SUPPORT
#define DUK_USE_BOOLEAN_BUILTIN
#define DUK_USE_BUFFEROBJECT_SUPPORT
#undef DUK_USE_BUFLEN16
#define DUK_USE_BYTECODE_DUMP_SUPPORT
#define DUK_USE_CACHE_ACTIVATION
#define DUK_USE_CACHE_CATCHER
#define DUK_USE_CALLSTACK_LIMIT 10000
#define DUK_USE_COMMONJS_MODULES
#define DUK_USE_COMPILER_RECLIMIT 2500
#define DUK_USE_COROUTINE_SUPPORT
#undef DUK_USE_CPP_EXCEPTIONS
#undef DUK_USE_DATAPTR16
#undef DUK_USE_DATAPTR_DEC16
#undef DUK_USE_DATAPTR_ENC16
#define DUK_USE_DATE_BUILTIN
#undef DUK_USE_DATE_FORMAT_STRING
#undef DUK_USE_DATE_GET_LOCAL_TZOFFSET
#undef DUK_USE_DATE_GET_NOW
#undef DUK_USE_DATE_PARSE_STRING
#undef DUK_USE_DATE_PRS_GETDATE
#undef DUK_USE_DEBUG
#undef DUK_USE_DEBUGGER_DUMPHEAP
#undef DUK_USE_DEBUGGER_INSPECT
#undef DUK_USE_DEBUGGER_PAUSE_UNCAUGHT
#undef DUK_USE_DEBUGGER_SUPPORT
#define DUK_USE_DEBUGGER_THROW_NOTIFY
#undef DUK_USE_DEBUGGER_TRANSPORT_TORTURE
#define DUK_USE_DEBUG_BUFSIZE 65536L
#define DUK_USE_DEBUG_LEVEL 0
#undef DUK_USE_DEBUG_WRITE
#define DUK_USE_DOUBLE_LINKED_HEAP
#define DUK_USE_DUKTAPE_BUILTIN
#define DUK_USE_ENCODING_BUILTINS
#define DUK_USE_ERRCREATE
#define DUK_USE_ERRTHROW
#define DUK_USE_ES6
#define DUK_USE_ES6_OBJECT_PROTO_PROPERTY
#define DUK_USE_ES6_OBJECT_SETPROTOTYPEOF
#define DUK_USE_ES6_PROXY
#define DUK_USE_ES6_REGEXP_SYNTAX
#define DUK_USE_ES6_UNICODE_ESCAPE
#define DUK_USE_ES7
#define DUK_USE_ES7_EXP_OPERATOR
#define DUK_USE_ES8
#define DUK_USE_ES9
#define DUK_USE_ESBC_LIMITS
#define DUK_USE_ESBC_MAX_BYTES 2147418112L
#define DUK_USE_ESBC_MAX_LINENUMBER 2147418112L
#undef DUK_USE_EXEC_FUN_LOCAL
#undef DUK_USE_EXEC_INDIRECT_BOUND_CHECK
#undef DUK_USE_EXEC_PREFER_SIZE
#define DUK_USE_EXEC_REGCONST_OPTIMIZE
#undef DUK_USE_EXEC_TIMEOUT_CHECK
#undef DUK_USE_EXPLICIT_NULL_INIT
#undef DUK_USE_EXTSTR_FREE
#undef DUK_USE_EXTSTR_INTERN_CHECK
#undef DUK_USE_FASTINT
#define DUK_USE_FAST_REFCOUNT_DEFAULT
#undef DUK_USE_FATAL_HANDLER
#define DUK_USE_FATAL_MAXLEN 128
#define DUK_USE_FINALIZER_SUPPORT
#undef DUK_USE_FINALIZER_TORTURE
#undef DUK_USE_FUNCPTR16
#undef DUK_USE_FUNCPTR_DEC16
#undef DUK_USE_FUNCPTR_ENC16
#define DUK_USE_FUNCTION_BUILTIN
#define DUK_USE_FUNC_FILENAME_PROPERTY
#define DUK_USE_FUNC_NAME_PROPERTY
#undef DUK_USE_GC_TORTURE
#undef DUK_USE_GET_MONOTONIC_TIME
#undef DUK_USE_GET_RANDOM_DOUBLE
#undef DUK_USE_GLOBAL_BINDING
#define DUK_USE_GLOBAL_BUILTIN
#undef DUK_USE_HEAPPTR16
#undef DUK_USE_HEAPPTR_DEC16
#undef DUK_USE_HEAPPTR_ENC16
#define DUK_USE_HEX_FASTPATH
#define DUK_USE_HEX_SUPPORT
#define DUK_USE_HOBJECT_ARRAY_ABANDON_LIMIT 2
#define DUK_USE_HOBJECT_ARRAY_FAST_RESIZE_LIMIT 9
#define DUK_USE_HOBJECT_ARRAY_MINGROW_ADD 16
#define DUK_USE_HOBJECT_ARRAY_MINGROW_DIVISOR 8
#define DUK_USE_HOBJECT_ENTRY_MINGROW_ADD 16
#define DUK_USE_HOBJECT_ENTRY_MINGROW_DIVISOR 8
#define DUK_USE_HOBJECT_HASH_PART
#define DUK_USE_HOBJECT_HASH_PROP_LIMIT 8
#define DUK_USE_HSTRING_ARRIDX
#define DUK_USE_HSTRING_CLEN
#undef DUK_USE_HSTRING_EXTDATA
#define DUK_USE_HSTRING_LAZY_CLEN
#define DUK_USE_HTML_COMMENTS
#define DUK_USE_IDCHAR_FASTPATH
#undef DUK_USE_INJECT_HEAP_ALLOC_ERROR
#undef DUK_USE_INTERRUPT_COUNTER
#undef DUK_USE_INTERRUPT_DEBUG_FIXUP
#define DUK_USE_JC
#define DUK_USE_JSON_BUILTIN
#define DUK_USE_JSON_DECNUMBER_FASTPATH
#define DUK_USE_JSON_DECSTRING_FASTPATH
#define DUK_USE_JSON_DEC_RECLIMIT 1000
#define DUK_USE_JSON_EATWHITE_FASTPATH
#define DUK_USE_JSON_ENC_RECLIMIT 1000
#define DUK_USE_JSON_QUOTESTRING_FASTPATH
#undef DUK_USE_JSON_STRINGIFY_FASTPATH
#define DUK_USE_JSON_SUPPORT
#define DUK_USE_JX
#define DUK_USE_LEXER_SLIDING_WINDOW
#undef DUK_USE_LIGHTFUNC_BUILTINS
#define DUK_USE_LITCACHE_SIZE 256
#define DUK_USE_MARK_AND_SWEEP_RECLIMIT 256
#define DUK_USE_MATH_BUILTIN
#define DUK_USE_NATIVE_CALL_RECLIMIT 1000
#define DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT
#undef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY
#undef DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY
#define DUK_USE_NONSTD_FUNC_STMT
#define DUK_USE_NONSTD_GETTER_KEY_ARGUMENT
#define DUK_USE_NONSTD_JSON_ESC_U2028_U2029
#define DUK_USE_NONSTD_SETTER_KEY_ARGUMENT
#define DUK_USE_NONSTD_STRING_FROMCHARCODE_32BIT
#define DUK_USE_NUMBER_BUILTIN
#define DUK_USE_OBJECT_BUILTIN
#undef DUK_USE_OBJSIZES16
#undef DUK_USE_PARANOID_ERRORS
#define DUK_USE_PERFORMANCE_BUILTIN
#undef DUK_USE_PREFER_SIZE
#undef DUK_USE_PROMISE_BUILTIN
#define DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS
#undef DUK_USE_REFCOUNT16
#define DUK_USE_REFCOUNT32
#define DUK_USE_REFERENCE_COUNTING
#define DUK_USE_REFLECT_BUILTIN
#define DUK_USE_REGEXP_CANON_BITMAP
#undef DUK_USE_REGEXP_CANON_WORKAROUND
#define DUK_USE_REGEXP_COMPILER_RECLIMIT 10000
#define DUK_USE_REGEXP_EXECUTOR_RECLIMIT 10000
#define DUK_USE_REGEXP_SUPPORT
#undef DUK_USE_ROM_GLOBAL_CLONE
#undef DUK_USE_ROM_GLOBAL_INHERIT
#undef DUK_USE_ROM_OBJECTS
#define DUK_USE_ROM_PTRCOMP_FIRST 63488L
#undef DUK_USE_ROM_STRINGS
#define DUK_USE_SECTION_B
#undef DUK_USE_SELF_TESTS
#define DUK_USE_SHEBANG_COMMENTS
#undef DUK_USE_SHUFFLE_TORTURE
#define DUK_USE_SOURCE_NONBMP
#undef DUK_USE_STRHASH16
#undef DUK_USE_STRHASH_DENSE
#define DUK_USE_STRHASH_SKIP_SHIFT 5
#define DUK_USE_STRICT_DECL
#undef DUK_USE_STRICT_UTF8_SOURCE
#define DUK_USE_STRING_BUILTIN
#undef DUK_USE_STRLEN16
#define DUK_USE_STRTAB_GROW_LIMIT 17
#define DUK_USE_STRTAB_MAXSIZE 268435456L
#define DUK_USE_STRTAB_MINSIZE 1024
#undef DUK_USE_STRTAB_PTRCOMP
#define DUK_USE_STRTAB_RESIZE_CHECK_MASK 255
#define DUK_USE_STRTAB_SHRINK_LIMIT 6
#undef DUK_USE_STRTAB_TORTURE
#undef DUK_USE_SYMBOL_BUILTIN
#define DUK_USE_TAILCALL
#define DUK_USE_TARGET_INFO "unknown"
#define DUK_USE_TRACEBACKS
#define DUK_USE_TRACEBACK_DEPTH 10
#define DUK_USE_USER_DECLARE() /* no user declarations */
#define DUK_USE_VALSTACK_GROW_SHIFT 2
#define DUK_USE_VALSTACK_LIMIT 1000000L
#define DUK_USE_VALSTACK_SHRINK_CHECK_SHIFT 2
#define DUK_USE_VALSTACK_SHRINK_SLACK_SHIFT 4
#undef DUK_USE_VALSTACK_UNSAFE

#undef DUK_USE_VERBOSE_ERRORS
#define DUK_USE_ALLOW_UNDEFINED_BEHAVIOR
#undef DUK_USE_VERBOSE_EXECUTOR_ERRORS
#define DUK_USE_VOLUNTARY_GC
#define DUK_USE_ZERO_BUFFER_DATA

/*
 *  Fixups
 */

#include "duk_custom.h"

/*
 *  You may add overriding #define/#undef directives below for
 *  customization.  You of course cannot un-#include or un-typedef
 *  anything; these require direct changes above.
 */

/* __OVERRIDE_DEFINES__ */

/*
 *  Conditional includes
 */

#if defined(DUK_F_CPP) && defined(DUK_USE_CPP_EXCEPTIONS)
	#include <exception>  /* std::exception */
	#include <stdexcept>  /* std::runtime_error */
#endif

/*
 *  Date provider selection
 *
 *  User may define DUK_USE_DATE_GET_NOW() etc directly, in which case we'll
 *  rely on an external provider.  If this is not done, revert to previous
 *  behavior and use Unix/Windows built-in provider.
 */

#if defined(DUK_COMPILING_DUKTAPE)

	#if defined(DUK_USE_DATE_GET_NOW)
		/* External provider already defined. */
	#elif defined(DUK_USE_DATE_NOW_GETTIMEOFDAY)
		#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_gettimeofday()
	#elif defined(DUK_USE_DATE_NOW_TIME)
		#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_time()
	#elif defined(DUK_USE_DATE_NOW_WINDOWS)
		#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_windows()
	#elif defined(DUK_USE_DATE_NOW_WINDOWS_SUBMS)
		#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_windows_subms()
	#else
		#error no provider for DUK_USE_DATE_GET_NOW()
	#endif

	#if defined(DUK_USE_DATE_GET_LOCAL_TZOFFSET)
		/* External provider already defined. */
	#elif defined(DUK_USE_DATE_TZO_GMTIME_R) || defined(DUK_USE_DATE_TZO_GMTIME_S) || defined(DUK_USE_DATE_TZO_GMTIME)
		#define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d)   duk_bi_date_get_local_tzoffset_gmtime((d))
	#elif defined(DUK_USE_DATE_TZO_WINDOWS)
		#define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d)   duk_bi_date_get_local_tzoffset_windows((d))
	#elif defined(DUK_USE_DATE_TZO_WINDOWS_NO_DST)
		#define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d)   duk_bi_date_get_local_tzoffset_windows_no_dst((d))
	#else
		#error no provider for DUK_USE_DATE_GET_LOCAL_TZOFFSET()
	#endif

	#if defined(DUK_USE_DATE_PARSE_STRING)
		/* External provider already defined. */
	#elif defined(DUK_USE_DATE_PRS_STRPTIME)
		#define DUK_USE_DATE_PARSE_STRING(ctx,str)   duk_bi_date_parse_string_strptime((ctx), (str))
	#elif defined(DUK_USE_DATE_PRS_GETDATE)
		#define DUK_USE_DATE_PARSE_STRING(ctx,str)   duk_bi_date_parse_string_getdate((ctx), (str))
	#else
		/* No provider for DUK_USE_DATE_PARSE_STRING(), fall back to ISO 8601 only. */
	#endif

	#if defined(DUK_USE_DATE_FORMAT_STRING)
		/* External provider already defined. */
	#elif defined(DUK_USE_DATE_FMT_STRFTIME)
		#define DUK_USE_DATE_FORMAT_STRING(ctx,parts,tzoffset,flags) \
		duk_bi_date_format_parts_strftime((ctx), (parts), (tzoffset), (flags))
	#else
		/* No provider for DUK_USE_DATE_FORMAT_STRING(), fall back to ISO 8601 only. */
	#endif

	#if defined(DUK_USE_GET_MONOTONIC_TIME)
		/* External provider already defined. */
	#elif defined(DUK_USE_GET_MONOTONIC_TIME_CLOCK_GETTIME)
		#define DUK_USE_GET_MONOTONIC_TIME(ctx)  duk_bi_date_get_monotonic_time_clock_gettime()
	#elif defined(DUK_USE_GET_MONOTONIC_TIME_WINDOWS_QPC)
		#define DUK_USE_GET_MONOTONIC_TIME(ctx)  duk_bi_date_get_monotonic_time_windows_qpc()
	#else
		/* No provider for DUK_USE_GET_MONOTONIC_TIME(), fall back to DUK_USE_DATE_GET_NOW(). */
	#endif

#endif  /* DUK_COMPILING_DUKTAPE */


#endif  /* DUK_CONFIG_H_INCLUDED */

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-03-22 23:47 kokamoto
  0 siblings, 0 replies; 48+ messages in thread
From: kokamoto @ 2020-03-22 23:47 UTC (permalink / raw)
  To: 9front

> It might be, as you suggested, something with the CSS handling. 

I checked all the files under libcss/src, and found all those are all
same as those of working Ubuntu's ones.  So, it's not css related...

I don't have whole view of netsurf sources...

Kenji



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-22 20:27 ` jamos
  2020-03-22 20:54   ` ori
@ 2020-03-22 20:54   ` ori
  1 sibling, 0 replies; 48+ messages in thread
From: ori @ 2020-03-22 20:54 UTC (permalink / raw)
  To: jamos, 9front

> I’d be interested in any ideas on how 
> to approach debugging this.

Also, I wouldn't worry too much about this until after
updating to the newest netsurf -- I tried pulling, and
there's a lot that changed.

It's probably about time to rebase to master.



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-22 20:27 ` jamos
@ 2020-03-22 20:54   ` ori
  2020-03-22 20:54   ` ori
  1 sibling, 0 replies; 48+ messages in thread
From: ori @ 2020-03-22 20:54 UTC (permalink / raw)
  To: jamos, 9front

> I’d be interested in any ideas on how 
> to approach debugging this.

Add some asserts with expected values. If you don't know
the expected values, put some log statements in places that
seem like they could be going wrong, and then diff the
values against a working version.



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-21  3:24 kokamoto
@ 2020-03-22 20:27 ` jamos
  2020-03-22 20:54   ` ori
  2020-03-22 20:54   ` ori
  0 siblings, 2 replies; 48+ messages in thread
From: jamos @ 2020-03-22 20:27 UTC (permalink / raw)
  To: 9front


> It appears on arm nsfb(5.nsfb), but not does on 386 or amd64 nsfb.
> It does not appear when I observe http://www.netsurf-browsers.org/,
> even on 5.nsfb.

Yes, it is a fact that 5.nsfb doesn’t render correctly. Web pages seem 
functional, but rendering and placement is off. I checked the 
framebuffer driver using the test cases and they work fine, which isn’t 
too surprising, given that the toolbar looks right.

It might be, as you suggested, something with the CSS handling. The 
question is: how to debug? If there is a crash, it is possible to make a 
stack trace. There are unit tests for CSS (and many other functions) but 
I have not tried to jumpstart them. I have also run the the browser in 
verbose mode (-v) and compared the output between 386 and arm, but 
nothing really sticks out for me. I’d be interested in any ideas on how 
to approach debugging this.

Jonas


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-03-22  2:19 kokamoto
  0 siblings, 0 replies; 48+ messages in thread
From: kokamoto @ 2020-03-22  2:19 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 358 bytes --]

This is another problem which occurred fromt the beginning (without javascrip).
I have unexpected text like included.
It appears on arm nsfb(5.nsfb), but not does on 386 or amd64 nsfb.
It does not appear when I observe http://www.netsurf-browsers.org/, 
even on 5.nsfb.

I'm searching what is the cause of this for a long time...

Anyone has anyhint?

Kenji

[-- Attachment #2: nsfb.bit --]
[-- Type: image/p9bit, Size: 333594 bytes --]

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-21  5:00       ` Jens Staal
@ 2020-03-21 12:24         ` Ethan Gardener
  0 siblings, 0 replies; 48+ messages in thread
From: Ethan Gardener @ 2020-03-21 12:24 UTC (permalink / raw)
  To: 9front

On Sat, Mar 21, 2020, at 5:00 AM, Jens Staal wrote:
> Back when I did APR I musl libc did not exist (or I was not aware of 
> it). Perhaps
> could the iconv function from that library be used?

we have an iconv, it's just called tcs and doesn't yet exist in library form.


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-20 18:54     ` jamos
@ 2020-03-21  5:00       ` Jens Staal
  2020-03-21 12:24         ` Ethan Gardener
  0 siblings, 1 reply; 48+ messages in thread
From: Jens Staal @ 2020-03-21  5:00 UTC (permalink / raw)
  To: 9front

On Fri, Mar 20, 2020 at 08:54:55PM +0200, jamos@oboj.net wrote:
> This one seem to be iconv(). We need a better one, but
> I just updated the "fake" iconv() so that outputs what
> comes in, and that seem to make google work (at least
> if you search for anything 7 bit ASCII). I uploaded it
> to 'nsport' but there seem something missing.
> 
> I see multiple options for iconv() ... 1) write something
> that uses tcs(1), 2) use the iconv() for RISCOS (separate
> netsurf repo) requires to implement some unicode routines.
> 3) find some suitable iconv() implementation; Jens Staal
> ported APR iconv() but it is quite big and a bit tricky to
> build. There is also gnulib in ports, but I rather not go
> that route. Iconv() is not connected to the framebuffer
> frontend, but generally needed for the browser. What do
> you all think? Do you know of a sleek iconv()
> implementation?
> 
> Jonas

Back when I did APR I musl libc did not exist (or I was not aware of it). Perhaps
could the iconv function from that library be used?




^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-03-21  3:24 kokamoto
  2020-03-22 20:27 ` jamos
  0 siblings, 1 reply; 48+ messages in thread
From: kokamoto @ 2020-03-21  3:24 UTC (permalink / raw)
  To: eekee57, 9front

[-- Attachment #1: Type: text/plain, Size: 358 bytes --]

This is another problem which occurred fromt the beginning (without javascrip).
I have unexpected text like included.
It appears on arm nsfb(5.nsfb), but not does on 386 or amd64 nsfb.
It does not appear when I observe http://www.netsurf-browsers.org/, 
even on 5.nsfb.

I'm searching what is the cause of this for a long time...

Anyone has anyhint?

Kenji

[-- Attachment #2: nsfb.bit --]
[-- Type: image/p9bit, Size: 333594 bytes --]

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-20 16:15   ` ori
  2020-03-20 17:12     ` telephil9
  2020-03-20 18:54     ` jamos
@ 2020-03-20 22:07     ` Kyle Nusbaum
  2 siblings, 0 replies; 48+ messages in thread
From: Kyle Nusbaum @ 2020-03-20 22:07 UTC (permalink / raw)
  To: ori, 9front, kokamoto

They are released when netsurf releases the resource handles, usually when it's done loading the page, but I'm not sure exactly what triggers it. Ideally the webfs handles would be released when the content was done being fetched.

I guess Google (and every other webform) is broken because of the iconv thing. I noticed this when I first started working on it. The problem doesn't come from within the webfs fetcher and I didn't take the time to track it down. Fixing that would really help make the existing netsurf useful. 



On March 20, 2020 11:15:24 AM CDT, ori@eigenstate.org wrote:
>> I think the error is due to a limitation of the webfs fetcher.
>Currently, the fetcher hangs on
>> to webfs handles until they're freed by netsurf, even after the data
>is
>> read, because after they're closed things like headers are
>unavailable.
>> This means tha webfs handles can be exhausted, at which point netsurf
>> starts to run into that error.
>> 
>> This can definitely be improved in the webfs fetcher, but maybe the
>> relatively low webfs handle limit could also be raised.
>> 
>
>Are they ever released, or are they effectively leaked?
>
>Also, searching on Google just.. doesn't work. It seems like we get
>a bogus URL.

-- Kyle


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-20 16:15   ` ori
  2020-03-20 17:12     ` telephil9
@ 2020-03-20 18:54     ` jamos
  2020-03-21  5:00       ` Jens Staal
  2020-03-20 22:07     ` Kyle Nusbaum
  2 siblings, 1 reply; 48+ messages in thread
From: jamos @ 2020-03-20 18:54 UTC (permalink / raw)
  To: 9front; +Cc: ori

On 2020-03-20 18:15, ori@eigenstate.org wrote:

> 
> Also, searching on Google just.. doesn't work. It seems like we get
> a bogus URL.

This one seem to be iconv(). We need a better one, but
I just updated the "fake" iconv() so that outputs what
comes in, and that seem to make google work (at least
if you search for anything 7 bit ASCII). I uploaded it
to 'nsport' but there seem something missing.

I see multiple options for iconv() ... 1) write something
that uses tcs(1), 2) use the iconv() for RISCOS (separate
netsurf repo) requires to implement some unicode routines.
3) find some suitable iconv() implementation; Jens Staal
ported APR iconv() but it is quite big and a bit tricky to
build. There is also gnulib in ports, but I rather not go
that route. Iconv() is not connected to the framebuffer
frontend, but generally needed for the browser. What do
you all think? Do you know of a sleek iconv()
implementation?

Jonas


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-20 17:12     ` telephil9
@ 2020-03-20 17:40       ` Jens Staal
  0 siblings, 0 replies; 48+ messages in thread
From: Jens Staal @ 2020-03-20 17:40 UTC (permalink / raw)
  To: 9front; +Cc: ori, knusbaum, kokamoto

On Fri, Mar 20, 2020 at 06:12:41PM +0100, telephil9@gmail.com wrote:
> On Fri Mar 20 17:16:38 CET 2020, ori@eigenstate.org wrote:
> > > I think the error is due to a limitation of the webfs fetcher. Currently, the fetcher hangs on
> > > to webfs handles until they're freed by netsurf, even after the data is
> > > read, because after they're closed things like headers are unavailable.
> > > This means tha webfs handles can be exhausted, at which point netsurf
> > > starts to run into that error.
> > > 
> > > This can definitely be improved in the webfs fetcher, but maybe the
> > > relatively low webfs handle limit could also be raised.
> > > 
> > 
> > Are they ever released, or are they effectively leaked?
> > 
> > Also, searching on Google just.. doesn't work. It seems like we get
> > a bogus URL.
> > 
> 
> I tracked this one down to iconv not being implemented (see posix/src/iconv.c).
> For the bogus URL, the reason is that when the form is submitted, its fields are encoded (form_encode_item() in netsurf/content/handlers/html/form.c) using iconv which returns null each time (hence the many =&=&=&=).
> Proper fix would be to implement the iconv() function, easy cheat is to return the unmodified item in the form_encode_item() function.
>

I remember ages ago when I built various netsurf libraries for Plan9, I used the
Apache (apr) version of iconv. I don't remember how I came to the conclusion that I
needed it.






^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-20 16:15   ` ori
@ 2020-03-20 17:12     ` telephil9
  2020-03-20 17:40       ` Jens Staal
  2020-03-20 18:54     ` jamos
  2020-03-20 22:07     ` Kyle Nusbaum
  2 siblings, 1 reply; 48+ messages in thread
From: telephil9 @ 2020-03-20 17:12 UTC (permalink / raw)
  To: ori, knusbaum, 9front, kokamoto

On Fri Mar 20 17:16:38 CET 2020, ori@eigenstate.org wrote:
> > I think the error is due to a limitation of the webfs fetcher. Currently, the fetcher hangs on
> > to webfs handles until they're freed by netsurf, even after the data is
> > read, because after they're closed things like headers are unavailable.
> > This means tha webfs handles can be exhausted, at which point netsurf
> > starts to run into that error.
> > 
> > This can definitely be improved in the webfs fetcher, but maybe the
> > relatively low webfs handle limit could also be raised.
> > 
> 
> Are they ever released, or are they effectively leaked?
> 
> Also, searching on Google just.. doesn't work. It seems like we get
> a bogus URL.
> 

I tracked this one down to iconv not being implemented (see posix/src/iconv.c).
For the bogus URL, the reason is that when the form is submitted, its fields are encoded (form_encode_item() in netsurf/content/handlers/html/form.c) using iconv which returns null each time (hence the many =&=&=&=).
Proper fix would be to implement the iconv() function, easy cheat is to return the unmodified item in the form_encode_item() function.



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-20 16:10 ` Kyle Nusbaum
@ 2020-03-20 16:15   ` ori
  2020-03-20 17:12     ` telephil9
                       ` (2 more replies)
  0 siblings, 3 replies; 48+ messages in thread
From: ori @ 2020-03-20 16:15 UTC (permalink / raw)
  To: knusbaum, 9front, kokamoto

> I think the error is due to a limitation of the webfs fetcher. Currently, the fetcher hangs on
> to webfs handles until they're freed by netsurf, even after the data is
> read, because after they're closed things like headers are unavailable.
> This means tha webfs handles can be exhausted, at which point netsurf
> starts to run into that error.
> 
> This can definitely be improved in the webfs fetcher, but maybe the
> relatively low webfs handle limit could also be raised.
> 

Are they ever released, or are they effectively leaked?

Also, searching on Google just.. doesn't work. It seems like we get
a bogus URL.



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-20  5:49 kokamoto
@ 2020-03-20 16:10 ` Kyle Nusbaum
  2020-03-20 16:15   ` ori
  0 siblings, 1 reply; 48+ messages in thread
From: Kyle Nusbaum @ 2020-03-20 16:10 UTC (permalink / raw)
  To: 9front, kokamoto

I think the error is due to a limitation of the webfs fetcher. Currently, the fetcher hangs on
to webfs handles until they're freed by netsurf, even after the data is
read, because after they're closed things like headers are unavailable.
This means tha webfs handles can be exhausted, at which point netsurf
starts to run into that error.

This can definitely be improved in the webfs fetcher, but maybe the
relatively low webfs handle limit could also be raised.

On March 20, 2020 12:49:35 AM CDT, kokamoto@hera.eonet.ne.jp wrote:
>I worked more on nsfb on arm.
>Yes, js codes are read successfully now, I have another
>unexpected text messages on the screen...
>
>But the way:
>What means "Failed to clone webfs: Error '/mnt/web/clone' no more
>client"
>I see this errors for 19 times, and then suicide
>
>Kenji

-- Kyle


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-03-20  5:49 kokamoto
  2020-03-20 16:10 ` Kyle Nusbaum
  0 siblings, 1 reply; 48+ messages in thread
From: kokamoto @ 2020-03-20  5:49 UTC (permalink / raw)
  To: 9front

I worked more on nsfb on arm.
Yes, js codes are read successfully now, I have another
unexpected text messages on the screen...

But the way:
What means "Failed to clone webfs: Error '/mnt/web/clone' no more client"
I see this errors for 19 times, and then suicide

Kenji



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-17 11:16 kokamoto
@ 2020-03-17 17:42 ` jamos
  0 siblings, 0 replies; 48+ messages in thread
From: jamos @ 2020-03-17 17:42 UTC (permalink / raw)
  To: 9front; +Cc: kokamoto

In Linux, it by defaults compiles Netsurf with the GTK
frontend. But you can build the framebuffer frontend
for Linux too. It works on the console, in X11 and in
VNC. You only have to set TARGET=framebuffer before
you invoke 'make'. Gives the 'nsfb' executable.

It makes sense to compare the framebuffer version for Linux
with the current plan 9, as it is also based on the framebuffer
driver. The 'gtk' frontend gives an hint of what a future
native frontend might be capable of, but it might look different,
as it would be up to potential netsurf/frontends/plan9/gui.c :-)

Jonas


On 2020-03-17 13:16, kokamoto@hera.eonet.ne.jp wrote:

> Yeah. for now, best option is to generate on Unix,
> I followed you, and got compiled netsurf-3.9 on my Ubuntu18.04.
> Now I have the vision of what is the goal of version 3.9.

I also got it for rpi3B (1GB memory) on ubuntu18.04.
This is on gtk2, ans the former is on gtk3.
The purpose of it is to check rpi3B capability.

Both are not so reliable, particulary to save a file,
where both segmentation faulted.

Kenji


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-03-17 11:16 kokamoto
  2020-03-17 17:42 ` jamos
  0 siblings, 1 reply; 48+ messages in thread
From: kokamoto @ 2020-03-17 11:16 UTC (permalink / raw)
  To: 9front

>> Yeah. for now, best option is to generate on Unix,
> 
> I followed you, and got compiled netsurf-3.9 on my Ubuntu18.04.
> Now I have the vision of what is the goal of version 3.9.

I also got it for rpi3B (1GB memory) on ubuntu18.04.
This is on gtk2, ans the former is on gtk3.
The purpose of it is to check rpi3B capability.

Both are not so reliable, particulary to save a file,
where both segmentation faulted.

Kenji



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-15 11:06 ` Steve Simon
  2020-03-15 11:38   ` Jens Staal
@ 2020-03-15 13:50   ` jamos
  1 sibling, 0 replies; 48+ messages in thread
From: jamos @ 2020-03-15 13:50 UTC (permalink / raw)
  To: 9front


That might be another way than we are taking now. The Amiga frontend can 
either be compiled natively or cross compiled from Linux (se building-* 
files here http://source.netsurf-browser.org/netsurf.git/tree/docs).

Anyhow, we already copy the autogenerated output from perl, flex, bison 
and python, right now. Ori’s suggestion to move the autogenerated files 
into the ‘nsport’ repository will probably make it easier to merge e.g. 
libcss with the upstream libcss, as our ‘patching’ will reside in nsport 
(which is not cloned from any upstream repo).

It is a pity that the lexer and parser generator require GNU tools 
(flex/bison), when Plan 9 already contains the original tools 
(lex/yacc). If someone is good in lex/flex and yacc/bison, it would be 
interesting to see if these files could be made to work in both 
environments. But maybe it is like with bash vs sh in Go, that the win 
is to keep with one well defined interface. An other alternative would 
be to write a translator, it doesn’t necessarily have to be complete.

Jonas

On 2020-03-15 13:06, Steve Simon wrote:

> Hi,
> 
> just a thought, but what is the hope of cross compiling on linux with 
> plan9 as a target?
> 
> it would need to include a /dev/draw backend and be statically linked, 
> but perhaps it might be a simpler path to a working browser.
> 
> -Steve
> 
> On 15 Mar 2020, at 9:42 am, kokamoto@hera.eonet.ne.jp wrote:
> 
> Yeah. for now, best option is to generate on Unix,
> I followed you, and got compiled netsurf-3.9 on my Ubuntu18.04.
> Now I have the vision of what is the goal of version 3.9.
> 
> Kenji


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-15 11:06 ` Steve Simon
@ 2020-03-15 11:38   ` Jens Staal
  2020-03-15 13:50   ` jamos
  1 sibling, 0 replies; 48+ messages in thread
From: Jens Staal @ 2020-03-15 11:38 UTC (permalink / raw)
  To: 9front

Has anyone tried compiling on Harvey?

On Sun, Mar 15, 2020 at 11:06:24AM +0000, Steve Simon wrote:
> 
> Hi,
> 
> just a thought, but what is the hope of cross compiling on linux with plan9 as a target?
> 
> it would need to include a /dev/draw backend and be statically linked, but perhaps it might be a simpler path to a working browser.
> 
> -Steve
> 
> > On 15 Mar 2020, at 9:42 am, kokamoto@hera.eonet.ne.jp wrote:
> > 
> > 
> >> 
> >> Yeah. for now, best option is to generate on Unix,
> > 
> > I followed you, and got compiled netsurf-3.9 on my Ubuntu18.04.
> > Now I have the vision of what is the goal of version 3.9.
> > 
> > Kenji
> 


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-15  9:42 kokamoto
@ 2020-03-15 11:06 ` Steve Simon
  2020-03-15 11:38   ` Jens Staal
  2020-03-15 13:50   ` jamos
  0 siblings, 2 replies; 48+ messages in thread
From: Steve Simon @ 2020-03-15 11:06 UTC (permalink / raw)
  To: 9front


Hi,

just a thought, but what is the hope of cross compiling on linux with plan9 as a target?

it would need to include a /dev/draw backend and be statically linked, but perhaps it might be a simpler path to a working browser.

-Steve

> On 15 Mar 2020, at 9:42 am, kokamoto@hera.eonet.ne.jp wrote:
> 
> 
>> 
>> Yeah. for now, best option is to generate on Unix,
> 
> I followed you, and got compiled netsurf-3.9 on my Ubuntu18.04.
> Now I have the vision of what is the goal of version 3.9.
> 
> Kenji



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-03-15  9:42 kokamoto
  2020-03-15 11:06 ` Steve Simon
  0 siblings, 1 reply; 48+ messages in thread
From: kokamoto @ 2020-03-15  9:42 UTC (permalink / raw)
  To: 9front

> Yeah. for now, best option is to generate on Unix,

I followed you, and got compiled netsurf-3.9 on my Ubuntu18.04.
Now I have the vision of what is the goal of version 3.9.

Kenji



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-14  1:49 kokamoto
@ 2020-03-14  2:09 ` ori
  0 siblings, 0 replies; 48+ messages in thread
From: ori @ 2020-03-14  2:09 UTC (permalink / raw)
  To: kokamoto, 9front

>> I can compile miniperl, but it suicides when I try
>> to do more than hello world. Building with debug
>> makes 6c suicide. miniperl is needed to build the
>> rest of perl.
>  I know what is miniperl, hmm.
> 
>> I can post what I have if you want to debug.
> 
> Probably I'll face the similler problem what I'm doing for duk_config.h.
> So, I don't have power to deal with it.(sigh)
> I'll do more for autogenerated_* files on 5.nsfb first.
> 
> Kenji

Yeah. for now, best option is to generate on Unix,
copy over, and commit to the nsport repository.
edit the mkfiles to copy the stuff in to the place
where we need it.

Eventually, I'll probably get perl to work, and we
can delete the hacks.



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-03-14  1:49 kokamoto
  2020-03-14  2:09 ` ori
  0 siblings, 1 reply; 48+ messages in thread
From: kokamoto @ 2020-03-14  1:49 UTC (permalink / raw)
  To: 9front

> I can compile miniperl, but it suicides when I try
> to do more than hello world. Building with debug
> makes 6c suicide. miniperl is needed to build the
> rest of perl.
 I know what is miniperl, hmm.

> I can post what I have if you want to debug.

Probably I'll face the similler problem what I'm doing for duk_config.h.
So, I don't have power to deal with it.(sigh)
I'll do more for autogenerated_* files on 5.nsfb first.

Kenji



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-14  1:19 kokamoto
@ 2020-03-14  1:34 ` ori
  0 siblings, 0 replies; 48+ messages in thread
From: ori @ 2020-03-14  1:34 UTC (permalink / raw)
  To: kokamoto, 9front

> Ori, you said earlier, you could compile perl for Plan9.
> Do you have one?

I can compile miniperl, but it suicides when I try
to do more than hello world. Building with debug
makes 6c suicide. miniperl is needed to build the
rest of perl.

I can post what I have if you want to debug.

Also, I realized that the changes to cpp are still
not quite right -- something like

	#define foo foo,bar
	#define baz(x) x
	#define nop(x) x

	baz(nop(foo))

doesn't affect any of our code, but still
gets expanded incorrectly -- I'll need to
track which ',' came from a macro expansion
in order to expand correctly, I think.



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-03-14  1:19 kokamoto
  2020-03-14  1:34 ` ori
  0 siblings, 1 reply; 48+ messages in thread
From: kokamoto @ 2020-03-14  1:19 UTC (permalink / raw)
  To: 9front

> I'll take a rest, and investigate what's going on here.

No, I can't take a rest. ☺

For 5.nsfb, I have problem to parse css (even not including javascript).
This could be solved by investgating libcss (probably parse/properties/autogenerated_* files.

For 8.nsfb, probably I have duk_config.h (not investigate enough for 386 or amd64 yet).

Both depend on perl.

Ori, you said earlier, you could compile perl for Plan9.
Do you have one?

Kenji



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-03-12  5:28 kokamoto
  0 siblings, 0 replies; 48+ messages in thread
From: kokamoto @ 2020-03-12  5:28 UTC (permalink / raw)
  To: 9front

Thanks a lot.

> I think they're saying that to turn on Javascript, you
> need to change it to this:
> 
> 	/** TODO: Forces JS on for our testing, needs changing before a release
> 	 * lest we incur the wrath of others.
> 	 */
> 	nsoption_set_bool(enable_javascript, true);

I first thought so, and did it (however javascrip_init error occurred again),
and I forgot it.
OK, I did it, and the results changed somehow.
However, I'm now running it on 1GB rpi3, it corrupted.
I'll compile netsurf on a 386 machine tommorrow.
(Today I'll have a visitor (Obosan お坊さん) here.

Kenji



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-12  2:20 kokamoto
@ 2020-03-12  2:43 ` ori
  0 siblings, 0 replies; 48+ messages in thread
From: ori @ 2020-03-12  2:43 UTC (permalink / raw)
  To: kokamoto, 9front

> However, it dosn't process javascript at now.☺

You mentioned this comment earlier:

	/** TODO: Forces JS on for our testing, needs changing before a release
	 * lest we incur the wrath of others.
	 */
	/* Disabled force-on for forthcoming release */
	/* nsoption_set_bool(enable_javascript, true);
	 */

I think they're saying that to turn on Javascript, you
need to change it to this:

	/** TODO: Forces JS on for our testing, needs changing before a release
	 * lest we incur the wrath of others.
	 */
	nsoption_set_bool(enable_javascript, true);



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-03-12  2:20 kokamoto
  2020-03-12  2:43 ` ori
  0 siblings, 1 reply; 48+ messages in thread
From: kokamoto @ 2020-03-12  2:20 UTC (permalink / raw)
  To: 9front

> Yes, it seems to hit my case.
> I'll see it tommorow.

Sorry, it was my careless mistake, that is I declared twice 
	content/handlers/javascript/content.$O \
in mkfile.

I got compiled 5.nsfb which size is
46,227,279
and normal 5.nsfb is
23,844,631.

However, it dosn't process javascript at now.☺

Kenji



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-03-11 23:59 kokamoto
  0 siblings, 0 replies; 48+ messages in thread
From: kokamoto @ 2020-03-11 23:59 UTC (permalink / raw)
  To: 9front

> Reverse engineering a Linux executable, there is indeed a
> javascript_init() defined. It looks like it comes form the
> following object file:

By the way, what is your Linux?
My Ubuntu 18.04 does not compile netsurf-3.9.

Kenji



^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
@ 2020-03-11 10:27 kokamoto
  0 siblings, 0 replies; 48+ messages in thread
From: kokamoto @ 2020-03-11 10:27 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 74 bytes --]

Thanks a lot!

Yes, it seems to hit my case.
I'll see it tommorow.

Kenji

[-- Attachment #2: Type: message/rfc822, Size: 3584 bytes --]

From: jamos@oboj.net
To: 9front@9front.org
Cc: kokamoto@hera.eonet.ne.jp
Subject: Re: [9front] adding javascript enable to netsurf
Date: Wed, 11 Mar 2020 10:29:03 +0100
Message-ID: <80e9edc42326584c4073d484bef78e14@oboj.net>

Reverse engineering a Linux executable, there is indeed a
javascript_init() defined. It looks like it comes form the
following object file:

nm netsurf/build/Linux-gtk/content_handlers_javascript_content.o | grep 
javascript_init
0000000000000150 T javascript_init

I cannot either find the proper declaration for the function
in the source, but maybe it is autogenerated somehow. In
'netsurf/content/content_factory.h' I find the macro:


#define CONTENT_FACTORY_REGISTER_TYPES(HNAME, HTYPELIST, HHANDLER)      
\
nserror HNAME##_init(void) { … }

That is used in 'netsurf/content/handlers/javascript/content.c':

CONTENT_FACTORY_REGISTER_TYPES(javascript, javascript_types, 
javascript_content_handler);

I don’t have the time right now to investigate further, but maybe
those findings can lead you a bit further. Duktape can be
enabled/disabled both in compile time and runtime too, I think.

Jonas

On 2020-03-11 07:36, kokamoto@hera.eonet.ne.jp wrote:

> I'm still struggling this.
> Error message says:
> javascript_init: redifinition: javascript_init
> (4481) TEXT javascript_init t0(SB). R0, $16
> 
> javascript_init is declared only once in
> ./netsurf/content/handlers/javascript/content.h:
> nserror javascript_init(void);
> 
> However, I cannot find the body of that function anywhere...
> 
> The javascript_init is called from 
> ./netsurf/content/handlers/javascript/duktape/dukky.c like:
> 
> /* exported interface documented in js.h */
> void js_initialise(void)
> {
> /** TODO: Forces JS on for our testing, needs changing before a release
> * lest we incur the wrath of others.
> */
> /* Disabled force-on for forthcoming release */
> /* nsoption_set_bool(enable_javascript, true);
> */
> javascript_init();  <====
> }
> 
> Please let me know the meaning of that comment, I'm not native English 
> user,
> then, it is difficult to understand why then javascript_init() is used 
> here...
> 
> Kenji

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [9front] adding javascript enable to netsurf
  2020-03-11  6:36 kokamoto
@ 2020-03-11  9:29 ` jamos
  0 siblings, 0 replies; 48+ messages in thread
From: jamos @ 2020-03-11  9:29 UTC (permalink / raw)
  To: 9front; +Cc: kokamoto

Reverse engineering a Linux executable, there is indeed a
javascript_init() defined. It looks like it comes form the
following object file:

nm netsurf/build/Linux-gtk/content_handlers_javascript_content.o | grep 
javascript_init
0000000000000150 T javascript_init

I cannot either find the proper declaration for the function
in the source, but maybe it is autogenerated somehow. In
'netsurf/content/content_factory.h' I find the macro:


#define CONTENT_FACTORY_REGISTER_TYPES(HNAME, HTYPELIST, HHANDLER)      
\
nserror HNAME##_init(void) { … }

That is used in 'netsurf/content/handlers/javascript/content.c':

CONTENT_FACTORY_REGISTER_TYPES(javascript, javascript_types, 
javascript_content_handler);

I don’t have the time right now to investigate further, but maybe
those findings can lead you a bit further. Duktape can be
enabled/disabled both in compile time and runtime too, I think.

Jonas

On 2020-03-11 07:36, kokamoto@hera.eonet.ne.jp wrote:

> I'm still struggling this.
> Error message says:
> javascript_init: redifinition: javascript_init
> (4481) TEXT javascript_init t0(SB). R0, $16
> 
> javascript_init is declared only once in
> ./netsurf/content/handlers/javascript/content.h:
> nserror javascript_init(void);
> 
> However, I cannot find the body of that function anywhere...
> 
> The javascript_init is called from 
> ./netsurf/content/handlers/javascript/duktape/dukky.c like:
> 
> /* exported interface documented in js.h */
> void js_initialise(void)
> {
> /** TODO: Forces JS on for our testing, needs changing before a release
> * lest we incur the wrath of others.
> */
> /* Disabled force-on for forthcoming release */
> /* nsoption_set_bool(enable_javascript, true);
> */
> javascript_init();  <====
> }
> 
> Please let me know the meaning of that comment, I'm not native English 
> user,
> then, it is difficult to understand why then javascript_init() is used 
> here...
> 
> Kenji


^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2020-04-18 17:17 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-13  4:33 [9front] adding javascript enable to netsurf kokamoto
2020-03-13  4:58 ` ori
  -- strict thread matches above, loose matches on Subject: below --
2020-04-14  5:04 kokamoto
2020-04-14 21:53 ` Kyle Nusbaum
2020-04-15 20:05   ` jamos
2020-04-15 20:24     ` ori
2020-04-18  1:09       ` Kyle Nusbaum
2020-04-18  1:19         ` ori
2020-04-18 17:11           ` Eli Cohen
2020-04-18 17:15             ` telephil9
2020-04-18 17:17             ` ori
2020-04-13 23:46 kokamoto
2020-04-07  4:25 kokamoto
2020-04-06  5:48 kokamoto
2020-04-13 12:44 ` jamos
2020-04-05  4:52 kokamoto
2020-04-05  4:41 kokamoto
2020-03-22 23:47 kokamoto
2020-03-22  2:19 kokamoto
2020-03-21  3:24 kokamoto
2020-03-22 20:27 ` jamos
2020-03-22 20:54   ` ori
2020-03-22 20:54   ` ori
2020-03-20  5:49 kokamoto
2020-03-20 16:10 ` Kyle Nusbaum
2020-03-20 16:15   ` ori
2020-03-20 17:12     ` telephil9
2020-03-20 17:40       ` Jens Staal
2020-03-20 18:54     ` jamos
2020-03-21  5:00       ` Jens Staal
2020-03-21 12:24         ` Ethan Gardener
2020-03-20 22:07     ` Kyle Nusbaum
2020-03-17 11:16 kokamoto
2020-03-17 17:42 ` jamos
2020-03-15  9:42 kokamoto
2020-03-15 11:06 ` Steve Simon
2020-03-15 11:38   ` Jens Staal
2020-03-15 13:50   ` jamos
2020-03-14  1:49 kokamoto
2020-03-14  2:09 ` ori
2020-03-14  1:19 kokamoto
2020-03-14  1:34 ` ori
2020-03-12  5:28 kokamoto
2020-03-12  2:20 kokamoto
2020-03-12  2:43 ` ori
2020-03-11 23:59 kokamoto
2020-03-11 10:27 kokamoto
2020-03-11  6:36 kokamoto
2020-03-11  9:29 ` [9front] " jamos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).