xiaoxiang781216 commented on code in PR #3859:
URL: https://github.com/apache/nuttx-apps/pull/3859#discussion_r4329255108


##########
interpreters/duktape/duk_cmdline.patch:
##########
@@ -2,17 +2,74 @@ diff --color -ur duktape/examples/cmdline/duk_cmdline.c 
duktape-2.5.0-modifed/ex
 --- duktape/examples/cmdline/duk_cmdline.c     2019-11-25 06:04:27.000000000 
+0800
 +++ duktape-2.5.0-modifed/examples/cmdline/duk_cmdline.c       2020-08-07 
23:20:27.320000000 +0800
 @@ -103,7 +103,7 @@
+ 
  #define  MEM_LIMIT_NORMAL   (128*1024*1024)   /* 128 MB */
  #define  MEM_LIMIT_HIGH     (2047*1024*1024)  /* ~2 GB */
 -#define  LINEBUF_SIZE       65536
 +#define  LINEBUF_SIZE       256
  
  static int main_argc = 0;
  static char **main_argv = NULL;
-
-@@ -810,10 +810,12 @@
+@@ -167,14 +167,33 @@ static void set_resource_limits(rlim_t mem_limit_value) {
+ #endif  /* DUK_CMDLINE_RLIMIT */
+ 
+ #if defined(DUK_CMDLINE_SIGNAL)
++#include <signal.h>
++
++static volatile sig_atomic_t g_interrupted = 0;
++static volatile sig_atomic_t g_executing = 0;
++
++duk_bool_t duk_cmdline_timeout_check(void *udata) {
++      (void) udata;
++      if (g_interrupted && g_executing) {
++              g_executing = 0;
++              return 1;
++      }
++      return 0;
++}
++
+ static void my_sighandler(int x) {
+-      fprintf(stderr, "Got signal %d\n", x);
+-      fflush(stderr);
++      (void) x;
++      g_interrupted = 1;
+ }
+ static void set_sigint_handler(void) {
+       (void) signal(SIGINT, my_sighandler);
+       (void) signal(SIGPIPE, SIG_IGN);  /* avoid SIGPIPE killing process */
+ }
++#else
++duk_bool_t duk_cmdline_timeout_check(void *udata) {
++      (void) udata;
++      return 0;
++}
+ #endif  /* DUK_CMDLINE_SIGNAL */
+ 
+ static void cmdline_fatal_handler(void *udata, const char *msg) {
+@@ -284,7 +303,13 @@ static duk_ret_t wrapped_compile_execute(duk_context 
*ctx, void *udata) {
+ #endif
+ 
+       duk_push_global_object(ctx);  /* 'this' binding */
++#if defined(DUK_CMDLINE_SIGNAL)
++      g_executing = 1;

Review Comment:
   why need g_executing flag



##########
interpreters/duktape/duk_cmdline.patch:
##########
@@ -44,3 +124,33 @@ diff --color -ur duktape/src-noline/duk_config.h 
duktape-2.5.0-modifed/src-nolin
 -#define DUK_USE_DATE_PRS_STRPTIME
 +#undef DUK_USE_DATE_PRS_STRPTIME
  #define DUK_USE_DATE_FMT_STRFTIME
+ 
+ #if 0  /* XXX: safe condition? */
+@@ -2962,7 +2962,17 @@ typedef struct duk_hthread duk_context;
+ #undef DUK_USE_EXEC_INDIRECT_BOUND_CHECK

Review Comment:
   why add the unrelated macro



##########
interpreters/duktape/duk_cmdline.patch:
##########
@@ -44,3 +124,33 @@ diff --color -ur duktape/src-noline/duk_config.h 
duktape-2.5.0-modifed/src-nolin
 -#define DUK_USE_DATE_PRS_STRPTIME
 +#undef DUK_USE_DATE_PRS_STRPTIME
  #define DUK_USE_DATE_FMT_STRFTIME
+ 
+ #if 0  /* XXX: safe condition? */
+@@ -2962,7 +2962,17 @@ typedef struct duk_hthread duk_context;
+ #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
++#define DUK_USE_EXEC_TIMEOUT_CHECK(udata) duk_cmdline_timeout_check(udata)

Review Comment:
   return g_interrupted directly



##########
interpreters/duktape/duk_cmdline.patch:
##########
@@ -44,3 +124,33 @@ diff --color -ur duktape/src-noline/duk_config.h 
duktape-2.5.0-modifed/src-nolin
 -#define DUK_USE_DATE_PRS_STRPTIME
 +#undef DUK_USE_DATE_PRS_STRPTIME

Review Comment:
   why change



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to