klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

klispconf.h (7689B)


      1 /*
      2 ** klispconf.h
      3 ** This is a basic configuration file for klisp
      4 ** See Copyright Notice in klisp.h
      5 */
      6 
      7 /*
      8 ** SOURCE NOTE: this is from lua (greatly reduced)
      9 */
     10 
     11 #include <limits.h>
     12 #include <stddef.h>
     13 #include <stdint.h>
     14 #include <stdbool.h>
     15 
     16 /*
     17 ** ==================================================================
     18 ** Search for "@@" to find all configurable definitions.
     19 ** ===================================================================
     20 */
     21 
     22 /*
     23   @@ KLISP_ANSI controls the use of non-ansi features.
     24   ** CHANGE it (define it) if you want Klisp to avoid the use of any
     25   ** non-ansi feature or library.
     26   */
     27 #if defined(__STRICT_ANSI__)
     28 /* XXX currently unused */
     29 #define KLISP_ANSI
     30 #endif
     31 
     32 
     33 #if !defined(KLISP_ANSI) && defined(_WIN32)
     34 #define KLISP_WIN
     35 #endif
     36 
     37 #if defined(KLISP_USE_LINUX)
     38 #define KLISP_USE_POSIX
     39 #define KLISP_USE_DLOPEN		/* needs an extra library: -ldl */
     40 /* XXX currently unused */
     41 #define KLISP_USE_READLINE	/* needs some extra libraries */
     42 #endif
     43 
     44 #if defined(KLISP_USE_MACOSX)
     45 #define KLISP_USE_POSIX
     46 /* XXX currently unused */
     47 #define KLISP_DL_DYLD		/* does not need extra library */
     48 #endif
     49 
     50 /*
     51   @@ KLISP_PROGNAME is the default name for the stand-alone klisp program.
     52   ** CHANGE it if your stand-alone interpreter has a different name and
     53   ** your system is not able to detect that name automatically.
     54   */
     55 #define KLISP_PROGNAME		"klisp"
     56 
     57 /*
     58   @@ KLISP_QL describes how error messages quote program elements.
     59   ** CHANGE it if you want a different appearance.
     60   */
     61 #define KLISP_QL(x)	"'" x "'"
     62 #define KLISP_QS	KLISP_QL("%s")
     63 
     64 /*
     65   @@ KLISP_USE_POSIX includes all functionallity listed as X/Open System
     66   @* Interfaces Extension (XSI).
     67   ** CHANGE it (define it) if your system is XSI compatible.
     68   */
     69 #if defined(KLISP_USE_POSIX)
     70 #define KLISP_USE_MKSTEMP
     71 #define KLISP_USE_ISATTY
     72 #define KLISP_USE_POPEN
     73 #define KLISP_USE_ULONGJMP
     74 #endif
     75 
     76 /*
     77   @@ KLISP_PATH and KLISP_CPATH are the names of the environment variables that
     78   @* Klisp check to set its paths.
     79   @@ KLISP_INIT is the name of the environment variable that Klisp
     80   @* checks for initialization code.
     81   ** CHANGE them if you want different names.
     82   */
     83 #define KLISP_PATH           "KLISP_PATH"
     84 #define KLISP_CPATH          "KLISP_CPATH"
     85 #define KLISP_INIT	"KLISP_INIT"
     86 
     87 
     88 /*
     89   @@ KLISP_PATH_DEFAULT is the default path that Klisp uses to look for
     90   @* Klisp libraries.
     91   @@ KLISP_CPATH_DEFAULT is the default path that Klisp uses to look for
     92   @* C libraries.
     93   ** CHANGE them if your machine has a non-conventional directory
     94   ** hierarchy or if you want to install your libraries in
     95   ** non-conventional directories.
     96   */
     97 #if defined(_WIN32)
     98 /*
     99 ** In Windows, any exclamation mark ('!') in the path is replaced by the
    100 ** path of the directory of the executable file of the current process.
    101 */
    102 #define KLISP_LDIR	"!\\klisp\\"
    103 #define KLISP_CDIR	"!\\"
    104 #define KLISP_PATH_DEFAULT						\
    105     ".\\?.k;" ".\\?"							\
    106     KLISP_LDIR"?.k;" KLISP_LDIR"?;"             \
    107     KLISP_CDIR"?.k;" KLISP_CDIR"?;"  
    108 /* XXX Not used for now */
    109 #define KLISP_CPATH_DEFAULT                                 \
    110 	".\\?.dll;"  KLISP_CDIR"?.dll;" KLISP_CDIR"loadall.dll"
    111 
    112 #else
    113 #define KLISP_ROOT	"/usr/local/"
    114 #define KLISP_LDIR	KLISP_ROOT "share/klisp/0.3/"
    115 #define KLISP_CDIR	KLISP_ROOT "lib/klisp/0.3/"
    116 #define KLISP_PATH_DEFAULT						\
    117     "./?.k;./?;"								\
    118     KLISP_LDIR"?.k;" KLISP_LDIR"?;"             \
    119     KLISP_CDIR"?;"  KLISP_CDIR"?.k"
    120 /* XXX Not used for now */
    121 #define KLISP_CPATH_DEFAULT                             \
    122 	"./?.so;"  KLISP_CDIR"?.so;" KLISP_CDIR"loadall.so"
    123 #endif
    124 
    125 
    126 /*
    127   @@ KLISP_DIRSEP is the directory separator (for submodules).
    128   ** XXX KLISP_DIRSEP is not currently used
    129   ** This allows naturally looking paths in windows while still using
    130   ** CHANGE it if your machine does not use "/" as the directory separator
    131   ** and is not Windows. (On Windows Klisp automatically uses "\".)
    132   */
    133 #if defined(_WIN32)
    134 #define KLISP_DIRSEP	"\\"
    135 #else
    136 #define KLISP_DIRSEP	"/"
    137 #endif
    138 
    139 
    140 /*
    141   @@ KLISP_PATHSEP is the character that separates templates in a path.
    142   @@ KLISP_PATH_MARK is the string that marks the substitution points in a
    143   @* template.
    144   @@ KLISP_EXECDIR in a Windows path is replaced by the executable's
    145   @* directory.
    146   @@ XXX KLISP_IGMARK is not currently used in klisp.
    147   @@ KLISP_IGMARK is a mark to ignore all before it when bulding the
    148   @* klispopen_ function name.
    149   ** CHANGE them if for some reason your system cannot use those
    150   ** characters. (E.g., if one of those characters is a common character
    151   ** in file/directory names.) Probably you do not need to change them.
    152   */
    153 #define KLISP_PATHSEP	";"
    154 #define KLISP_PATH_MARK	"?"
    155 #define KLISP_EXECDIR	"!"
    156 #define KLISP_IGMARK	"-"
    157 
    158 /*
    159   @@ klisp_stdin_is_tty detects whether the standard input is a 'tty' (that
    160   @* is, whether we're running klisp interactively).
    161   ** CHANGE it if you have a better definition for non-POSIX/non-Windows
    162   ** systems.
    163   */
    164 #if defined(KLISP_USE_ISATTY)
    165 #include <unistd.h>
    166 #define klisp_stdin_is_tty()	isatty(0)
    167 #elif defined(KLISP_WIN)
    168 #include <io.h>
    169 #include <stdio.h>
    170 #define klisp_stdin_is_tty()	_isatty(_fileno(stdin))
    171 #else
    172 #define klisp_stdin_is_tty()	1  /* assume stdin is a tty */
    173 #endif
    174 
    175 /*
    176   @@ KLISP_PROMPT is the default prompt used by stand-alone Klisp.
    177   @@ KLISP_PROMPT2 is not currently used.
    178   ** CHANGE them if you want different prompts. 
    179   */
    180 #define KLISP_PROMPT		"klisp> "
    181 /* XXX not used for now */
    182 #define KLISP_PROMPT2		">> "
    183 
    184 /* temp defines till gc is stabilized */
    185 #define KUSE_GC 1
    186 /* Print msgs when starting and ending gc */
    187 /* #define KDEBUG_GC 1 */
    188 
    189 /*
    190   #define KTRACK_MARKS true
    191 */
    192 
    193 /* TODO use this defines everywhere */
    194 #define KTRACK_NAMES true
    195 #define KTRACK_SI true
    196 
    197 /* These are unused for now, but will be once incremental collection is 
    198    activated */
    199 /* TEMP: for now the threshold is set manually at the start and then
    200    manually adjusted after every collection to override the intenal
    201    calculation done with KLISPI_GCPAUSE */
    202 /*
    203   @@ KLISPI_GCPAUSE defines the default pause between garbage-collector cycles
    204   @* as a percentage.
    205   ** CHANGE it if you want the GC to run faster or slower (higher values
    206   ** mean larger pauses which mean slower collection.) You can also change
    207   ** this value dynamically.
    208   */
    209 
    210 /* In lua that has incremental gc this is setted to 200, in
    211    klisp as we don't yet have incremental gc, we set it to 400 */
    212 #define KLISPI_GCPAUSE	400  /* 400% (wait memory to quadruple before next GC) */
    213 
    214 
    215 /*
    216   @@ KLISPI_GCMUL defines the default speed of garbage collection relative to
    217   @* memory allocation as a percentage.
    218   ** CHANGE it if you want to change the granularity of the garbage
    219   ** collection. (Higher values mean coarser collections. 0 represents
    220   ** infinity, where each step performs a full collection.) You can also
    221   ** change this value dynamically.
    222   */
    223 #define KLISPI_GCMUL	200 /* GC runs 'twice the speed' of memory allocation */
    224 
    225 /*
    226   @@ KLISP_API is a mark for all core API functions.
    227   @@ KLISPLIB_API is a mark for all standard library functions.
    228   ** CHANGE them if you need to define those functions in some special way.
    229   ** For instance, if you want to create one Windows DLL with the core and
    230   ** the libraries, you may want to use the following definition (define
    231   ** KLISP_BUILD_AS_DLL to get it).
    232   */
    233 #if defined(KLISP_BUILD_AS_DLL)
    234 
    235 #if defined(KLISP_CORE) || defined(KLISP_LIB)
    236 #define KLISP_API __declspec(dllexport)
    237 #else
    238 #define KLISP_API __declspec(dllimport)
    239 #endif
    240 
    241 #else
    242 
    243 #define KLISP_API		extern
    244 
    245 #endif
    246 
    247 /* more often than not the libs go together with the core */
    248 #define KLISPLIB_API	KLISP_API
    249 
    250 /* TODO: add klisp_core/lib defines... see lua */