1 /* core.h                                          -*- mode:c; coding:utf-8; -*-
2  *
3  *   Copyright (c) 2010-2021  Takashi Kato <ktakashi@ymail.com>
4  *
5  *   Redistribution and use in source and binary forms, with or without
6  *   modification, are permitted provided that the following conditions
7  *   are met:
8  *
9  *   1. Redistributions of source code must retain the above copyright
10  *      notice, this list of conditions and the following disclaimer.
11  *
12  *   2. Redistributions in binary form must reproduce the above copyright
13  *      notice, this list of conditions and the following disclaimer in the
14  *      documentation and/or other materials provided with the distribution.
15  *
16  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22  *   TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23  *   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24  *   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25  *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  *   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  *  $Id: $
29  */
30 #ifndef SAGITTARIUS_PRIVATE_CORE_H_
31 #define SAGITTARIUS_PRIVATE_CORE_H_
32 
33 #include "sagittariusdefs.h"
34 #include <sagittarius/gc.h>
35 
36 /*
37    Main ans child thread must have different stack size
38    (At least on Cygwin it does)
39    Main  1M
40    Child 64KB
41  */
42 #define SG_MAIN_THREAD_STACK_SIZE_LIMIT  0x100000
43 #define SG_CHILD_THREAD_STACK_SIZE_LIMIT 0x10000
44 
45 SG_CDECL_BEGIN
46 
47 SG_EXTERN void  Sg_Init();
48 
49 SG_EXTERN SG_NO_RETURN void Sg_Exit(int code);
50 SG_EXTERN SG_NO_RETURN void Sg_EmergencyExit(int code);
51 SG_EXTERN void 	Sg_Cleanup();
52 SG_EXTERN void*	Sg_AddCleanupHandler(void (*proc)(void *data), void *data);
53 SG_EXTERN void	Sg_DeleteCleanupHandler(void *handle);
54 SG_EXTERN void 	Sg_Panic(const char* msg, ...);
55 SG_EXTERN void 	Sg_Abort(const char* msg);
56 /* gc wrappers */
57 SG_EXTERN void 	Sg_GC();
58 SG_EXTERN int   Sg_FinalizerRegisteredP(SgObject z);
59 
60 SG_EXTERN void 	Sg_RegisterDisappearingLink(void **p, void *value);
61 SG_EXTERN void 	Sg_UnregisterDisappearingLink(void **p);
62 SG_EXTERN void* Sg_GCBase(void *value);
63 SG_EXTERN size_t Sg_GetHeapSize();
64 SG_EXTERN size_t Sg_GetTotalBytes();
65 SG_EXTERN uintptr_t Sg_GcCount();
66 SG_EXTERN void  Sg_GCSetPrintWarning(int onP);
67 SG_EXTERN int   Sg_GCStackBase(uintptr_t *base);
68 /* this is intptr_t to return -1 */
69 SG_EXTERN intptr_t   Sg_AvailableStackSize(uintptr_t csp);
70 
71 /* experimental */
72 
73 /* cond-expand */
74 SG_EXTERN void  Sg_AddCondFeature(const SgChar *feature);
75 SG_EXTERN SgObject Sg_CondFeatures();
76 
77 /* convenient function to start */
78 SG_EXTERN void Sg_Start(SgObject in, SgObject args,
79 			const char *fmt, SgObject rest);
80 
81 
82 SG_CDECL_END
83 
84 #endif /* SAGITTARIUS_PRIVATE_CORE_H_ */
85 
86 /*
87   end of file
88   Local Variables:
89   coding: utf-8-unix
90   End:
91 */
92