Skip to content

Commit

Permalink
Merge pull request #174 from cesanta/gc_public
Browse files Browse the repository at this point in the history
Make mjs_gc public
  • Loading branch information
cpq authored Jun 3, 2021
2 parents 32172c4 + 076eed4 commit 52f4912
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 18 deletions.
8 changes: 2 additions & 6 deletions mjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2888,6 +2888,7 @@ struct gc_arena {
/* Amalgamated: #include "mjs_core.h" */
/* Amalgamated: #include "mjs_mm.h" */
/* Amalgamated: #include "mjs_internal.h" */
/* Amalgamated: #include "mjs_gc_public.h" */

#if defined(__cplusplus)
extern "C" {
Expand All @@ -2907,12 +2908,6 @@ struct gc_cell {
} head;
};

/*
* Perform garbage collection.
* Pass true to full in order to reclaim unused heap back to the OS.
*/
void mjs_gc(struct mjs *mjs, int full);

MJS_PRIVATE int gc_strings_is_gc_needed(struct mjs *mjs);

/* perform gc if not inhibited */
Expand Down Expand Up @@ -7251,6 +7246,7 @@ MJS_PRIVATE void mjs_bcode_commit(struct mjs *mjs) {
/* Amalgamated: #include "mjs_core.h" */
/* Amalgamated: #include "mjs_dataview.h" */
/* Amalgamated: #include "mjs_exec.h" */
/* Amalgamated: #include "mjs_gc.h" */
/* Amalgamated: #include "mjs_internal.h" */
/* Amalgamated: #include "mjs_json.h" */
/* Amalgamated: #include "mjs_object.h" */
Expand Down
24 changes: 24 additions & 0 deletions mjs.h
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,30 @@ void mjs_set_ffi_resolver(struct mjs *mjs, mjs_ffi_resolver_t *dlsym);

#endif /* MJS_FFI_PUBLIC_H_ */
#ifdef MJS_MODULE_LINES
#line 1 "src/mjs_gc_public.h"
#endif

#ifndef MJS_GC_PUBLIC_H_
#define MJS_GC_PUBLIC_H_

/* Amalgamated: #include "mjs_core_public.h" */

#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */

/*
* Perform garbage collection.
* Pass true to full in order to reclaim unused heap back to the OS.
*/
void mjs_gc(struct mjs *mjs, int full);

#if defined(__cplusplus)
}
#endif /* __cplusplus */

#endif /* MJS_GC_PUBLIC_H_ */
#ifdef MJS_MODULE_LINES
#line 1 "src/mjs_object_public.h"
#endif

Expand Down
32 changes: 26 additions & 6 deletions mjs_no_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,30 @@ struct gc_arena {

#endif /* MJS_MM_H_ */
#ifdef MJS_MODULE_LINES
#line 1 "src/mjs_gc_public.h"
#endif

#ifndef MJS_GC_PUBLIC_H_
#define MJS_GC_PUBLIC_H_

/* Amalgamated: #include "mjs_core_public.h" */

#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */

/*
* Perform garbage collection.
* Pass true to full in order to reclaim unused heap back to the OS.
*/
void mjs_gc(struct mjs *mjs, int full);

#if defined(__cplusplus)
}
#endif /* __cplusplus */

#endif /* MJS_GC_PUBLIC_H_ */
#ifdef MJS_MODULE_LINES
#line 1 "src/mjs_gc.h"
#endif

Expand All @@ -722,6 +746,7 @@ struct gc_arena {
/* Amalgamated: #include "mjs_core.h" */
/* Amalgamated: #include "mjs_mm.h" */
/* Amalgamated: #include "mjs_internal.h" */
/* Amalgamated: #include "mjs_gc_public.h" */

#if defined(__cplusplus)
extern "C" {
Expand All @@ -741,12 +766,6 @@ struct gc_cell {
} head;
};

/*
* Perform garbage collection.
* Pass true to full in order to reclaim unused heap back to the OS.
*/
void mjs_gc(struct mjs *mjs, int full);

MJS_PRIVATE int gc_strings_is_gc_needed(struct mjs *mjs);

/* perform gc if not inhibited */
Expand Down Expand Up @@ -2914,6 +2933,7 @@ MJS_PRIVATE void mjs_bcode_commit(struct mjs *mjs) {
/* Amalgamated: #include "mjs_core.h" */
/* Amalgamated: #include "mjs_dataview.h" */
/* Amalgamated: #include "mjs_exec.h" */
/* Amalgamated: #include "mjs_gc.h" */
/* Amalgamated: #include "mjs_internal.h" */
/* Amalgamated: #include "mjs_json.h" */
/* Amalgamated: #include "mjs_object.h" */
Expand Down
1 change: 1 addition & 0 deletions src/mjs_builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "mjs_core.h"
#include "mjs_dataview.h"
#include "mjs_exec.h"
#include "mjs_gc.h"
#include "mjs_internal.h"
#include "mjs_json.h"
#include "mjs_object.h"
Expand Down
7 changes: 1 addition & 6 deletions src/mjs_gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "mjs_core.h"
#include "mjs_mm.h"
#include "mjs_internal.h"
#include "mjs_gc_public.h"

#if defined(__cplusplus)
extern "C" {
Expand All @@ -28,12 +29,6 @@ struct gc_cell {
} head;
};

/*
* Perform garbage collection.
* Pass true to full in order to reclaim unused heap back to the OS.
*/
void mjs_gc(struct mjs *mjs, int full);

MJS_PRIVATE int gc_strings_is_gc_needed(struct mjs *mjs);

/* perform gc if not inhibited */
Expand Down
25 changes: 25 additions & 0 deletions src/mjs_gc_public.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2014 Cesanta Software Limited
* All rights reserved
*/

#ifndef MJS_GC_PUBLIC_H_
#define MJS_GC_PUBLIC_H_

#include "mjs_core_public.h"

#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */

/*
* Perform garbage collection.
* Pass true to full in order to reclaim unused heap back to the OS.
*/
void mjs_gc(struct mjs *mjs, int full);

#if defined(__cplusplus)
}
#endif /* __cplusplus */

#endif /* MJS_GC_PUBLIC_H_ */
1 change: 1 addition & 0 deletions src/mjs_sources.mk
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ MJS_PUBLIC_HEADERS = \
mjs_core_public.h \
mjs_exec_public.h \
mjs_ffi_public.h \
mjs_gc_public.h \
mjs_object_public.h \
mjs_primitive_public.h \
mjs_string_public.h \
Expand Down

0 comments on commit 52f4912

Please sign in to comment.