/* ------------------------------------------------------------------------- */
/* "memory" : Memory management and ICL memory setting commands */
/* */
-/* Part of Inform 6.40 */
-/* copyright (c) Graham Nelson 1993 - 2022 */
+/* Part of Inform 6.42 */
+/* copyright (c) Graham Nelson 1993 - 2024 */
/* */
/* Inform is free software: you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* Wrappers for malloc(), realloc(), etc.
- Note that all of these functions call memory_out_error() on failure.
+ Note that all of these functions call fatalerror_memory_out() on failure.
This is a fatal error and does not return. However, we check my_malloc()
return values anyway as a matter of good habit.
*/
if (size==0) return(NULL);
c=(char _huge *)halloc(size,1);
malloced_bytes+=size;
- if (c==0) memory_out_error(size, 1, whatfor);
+ if (c==0) fatalerror_memory_out(size, 1, whatfor);
return(c);
}
}
c=halloc(size,1);
malloced_bytes+=(size-oldsize);
- if (c==0) memory_out_error(size, 1, whatfor);
+ if (c==0) fatalerror_memory_out(size, 1, whatfor);
if (memout_switch)
printf("Increasing allocation from %ld to %ld bytes for %s was (%08lx) now (%08lx)\n",
(long int) oldsize, (long int) size, whatfor,
if ((size*howmany) == 0) return(NULL);
c=(void _huge *)halloc(howmany*size,1);
malloced_bytes+=size*howmany;
- if (c==0) memory_out_error(size, howmany, whatfor);
+ if (c==0) fatalerror_memory_out(size, howmany, whatfor);
return(c);
}
}
c=(void _huge *)halloc(size*howmany,1);
malloced_bytes+=size*(howmany-oldhowmany);
- if (c==0) memory_out_error(size, howmany, whatfor);
+ if (c==0) fatalerror_memory_out(size, howmany, whatfor);
if (memout_switch)
printf("Increasing allocation from %ld to %ld bytes: array (%ld entries size %ld) for %s was (%08lx) now (%08lx)\n",
((long int)size) * ((long int)oldhowmany),
if (size==0) return(NULL);
c=malloc(size);
malloced_bytes+=size;
- if (c==0) memory_out_error(size, 1, whatfor);
+ if (c==0) fatalerror_memory_out(size, 1, whatfor);
if (memout_switch)
- printf("Allocating %ld bytes for %s at (%08lx)\n",
- (long int) size,whatfor,(long int) c);
+ printf("Allocating %ld bytes for %s at (%p)\n",
+ (long int) size, whatfor, c);
return(c);
}
}
c=realloc(*(int **)pointer, size);
malloced_bytes+=(size-oldsize);
- if (c==0) memory_out_error(size, 1, whatfor);
+ if (c==0) fatalerror_memory_out(size, 1, whatfor);
if (memout_switch)
- printf("Increasing allocation from %ld to %ld bytes for %s was (%08lx) now (%08lx)\n",
- (long int) oldsize, (long int) size, whatfor,
- (long int) (*(int **)pointer),
- (long int) c);
+ printf("Increasing allocation from %ld to %ld bytes for %s was (%p) now (%p)\n",
+ (long int) oldsize, (long int) size, whatfor, pointer, c);
*(int **)pointer = c;
}
if (size*howmany==0) return(NULL);
c=calloc(howmany, size);
malloced_bytes+=size*howmany;
- if (c==0) memory_out_error(size, howmany, whatfor);
+ if (c==0) fatalerror_memory_out(size, howmany, whatfor);
if (memout_switch)
printf("Allocating %ld bytes: array (%ld entries size %ld) \
-for %s at (%08lx)\n",
+for %s at (%p)\n",
((long int)size) * ((long int)howmany),
- (long int)howmany,(long int)size,whatfor,
- (long int) c);
+ (long int)howmany,(long int)size, whatfor, c);
return(c);
}
}
c=realloc(*(int **)pointer, size*howmany);
malloced_bytes+=size*(howmany-oldhowmany);
- if (c==0) memory_out_error(size, howmany, whatfor);
+ if (c==0) fatalerror_memory_out(size, howmany, whatfor);
if (memout_switch)
- printf("Increasing allocation from %ld to %ld bytes: array (%ld entries size %ld) for %s was (%08lx) now (%08lx)\n",
+ printf("Increasing allocation from %ld to %ld bytes: array (%ld entries size %ld) for %s was (%p) now (%p)\n",
((long int)size) * ((long int)oldhowmany),
((long int)size) * ((long int)howmany),
(long int)howmany, (long int)size, whatfor,
- (long int) *(int **)pointer, (long int) c);
+ pointer, c);
*(int **)pointer = c;
}
{
if (*(int **)pointer != NULL)
{ if (memout_switch)
- printf("Freeing memory for %s at (%08lx)\n",
- whatitwas, (long int) (*(int **)pointer));
+ printf("Freeing memory for %s at (%p)\n",
+ whatitwas, pointer);
#ifdef PC_QUICKC
hfree(*(int **)pointer);
#else
int ZCODE_HEADER_EXT_WORDS; /* (zcode 1.0) requested header extension size */
int ZCODE_HEADER_FLAGS_3; /* (zcode 1.1) value to place in Flags 3 word */
int ZCODE_LESS_DICT_DATA; /* (zcode) use 2 data bytes per dict word instead of 3 */
+int ZCODE_MAX_INLINE_STRING; /* (zcode) length of string literals that can be inlined */
int NUM_ATTR_BYTES;
int GLULX_OBJECT_EXT_BYTES; /* (glulx) extra bytes for each object record */
int32 MAX_STACK_SIZE;
int WARN_UNUSED_ROUTINES; /* 0: no, 1: yes except in system files, 2: yes always */
int OMIT_UNUSED_ROUTINES; /* 0: no, 1: yes */
int STRIP_UNREACHABLE_LABELS; /* 0: no, 1: yes (default) */
+int OMIT_SYMBOL_TABLE; /* 0: no, 1: yes */
+int LONG_DICT_FLAG_BUG; /* 0: no bug, 1: bug (default for historic reasons) */
int TRANSCRIPT_FORMAT; /* 0: classic, 1: prefixed */
/* The way memory sizes are set causes great nuisance for those parameters
printf("| %25s = %-7d |\n","ZCODE_HEADER_FLAGS_3",ZCODE_HEADER_FLAGS_3);
if (!glulx_mode)
printf("| %25s = %-7d |\n","ZCODE_LESS_DICT_DATA",ZCODE_LESS_DICT_DATA);
+ if (!glulx_mode)
+ printf("| %25s = %-7d |\n","ZCODE_MAX_INLINE_STRING",ZCODE_MAX_INLINE_STRING);
printf("| %25s = %-7d |\n","INDIV_PROP_START", INDIV_PROP_START);
if (glulx_mode)
printf("| %25s = %-7d |\n","MEMORY_MAP_EXTENSION",
printf("| %25s = %-7d |\n","WARN_UNUSED_ROUTINES",WARN_UNUSED_ROUTINES);
printf("| %25s = %-7d |\n","OMIT_UNUSED_ROUTINES",OMIT_UNUSED_ROUTINES);
printf("| %25s = %-7d |\n","STRIP_UNREACHABLE_LABELS",STRIP_UNREACHABLE_LABELS);
+ printf("| %25s = %-7d |\n","OMIT_SYMBOL_TABLE",OMIT_SYMBOL_TABLE);
+ printf("| %25s = %-7d |\n","LONG_DICT_FLAG_BUG",LONG_DICT_FLAG_BUG);
printf("+--------------------------------------+\n");
}
ZCODE_HEADER_EXT_WORDS = 3;
ZCODE_HEADER_FLAGS_3 = 0;
ZCODE_LESS_DICT_DATA = 0;
+ ZCODE_MAX_INLINE_STRING = 32;
GLULX_OBJECT_EXT_BYTES = 0;
MEMORY_MAP_EXTENSION = 0;
/* We estimate the default Glulx stack size at 4096. That's about
OMIT_UNUSED_ROUTINES = 0;
WARN_UNUSED_ROUTINES = 0;
STRIP_UNREACHABLE_LABELS = 1;
+ OMIT_SYMBOL_TABLE = 0;
+ LONG_DICT_FLAG_BUG = 1;
TRANSCRIPT_FORMAT = 0;
adjust_memory_sizes();
rather than three. (Z-code only.)\n");
return;
}
+ if (strcmp(command,"ZCODE_MAX_INLINE_STRING")==0)
+ { printf(
+" ZCODE_MAX_INLINE_STRING is the length beyond which string literals cannot\n\
+ be inlined in assembly opcodes. (Z-code only.)\n");
+ return;
+ }
if (strcmp(command,"GLULX_OBJECT_EXT_BYTES")==0)
{ printf(
" GLULX_OBJECT_EXT_BYTES is an amount of additional space to add to each \n\
will be compiled, at the cost of less optimized code. The default is 1.\n");
return;
}
+ if (strcmp(command,"OMIT_SYMBOL_TABLE")==0)
+ {
+ printf(
+" OMIT_SYMBOL_TABLE, if set to 1, will skip compiling debug symbol names \n\
+ into the game file.\n");
+ return;
+ }
+ if (strcmp(command,"LONG_DICT_FLAG_BUG")==0)
+ {
+ printf(
+" LONG_DICT_FLAG_BUG, if set to 0, will fix the old bug which ignores \n\
+ the '//p' flag in long dictionary words. If 1, the buggy behavior is \n\
+ retained.\n");
+ return;
+ }
if (strcmp(command,"SERIAL")==0)
{
printf(
printf(" FINDABBREVS: show selection decisions during abbreviation optimization\n (only meaningful with -u)\n");
printf(" FINDABBREVS=2: also show three-letter-block decisions\n");
printf(" FREQ: show how efficient abbreviations were (same as -f)\n (only meaningful with -e)\n");
- printf(" LINKER: show module linking info\n");
- printf(" LINKER=2: more verbose (or 3, 4 for even more)\n");
printf(" MAP: print memory map of the virtual machine (same as -z)\n");
printf(" MAP=2: also show percentage of VM that each segment occupies\n");
+ printf(" MAP=3: also show number of bytes that each segment occupies\n");
printf(" MEM: show internal memory allocations\n");
printf(" OBJECTS: display the object table\n");
printf(" PROPS: show attributes and properties defined\n");
else if (strcmp(command, "FREQUENCY")==0 || strcmp(command, "FREQUENCIES")==0 || strcmp(command, "FREQ")==0) {
frequencies_setting = value;
}
- else if (strcmp(command, "LINK")==0 || strcmp(command, "LINKER")==0) {
- linker_trace_setting = value;
- }
else if (strcmp(command, "MAP")==0) {
memory_map_setting = value;
}
ZCODE_HEADER_FLAGS_3=j, flag=1;
if (strcmp(command,"ZCODE_LESS_DICT_DATA")==0)
ZCODE_LESS_DICT_DATA=j, flag=1;
+ if (strcmp(command,"ZCODE_MAX_INLINE_STRING")==0)
+ ZCODE_MAX_INLINE_STRING=j, flag=1;
if (strcmp(command,"GLULX_OBJECT_EXT_BYTES")==0)
GLULX_OBJECT_EXT_BYTES=j, flag=1;
if (strcmp(command,"MAX_STATIC_DATA")==0)
if (STRIP_UNREACHABLE_LABELS > 1 || STRIP_UNREACHABLE_LABELS < 0)
STRIP_UNREACHABLE_LABELS = 1;
}
+ if (strcmp(command,"OMIT_SYMBOL_TABLE")==0)
+ {
+ OMIT_SYMBOL_TABLE=j, flag=1;
+ if (OMIT_SYMBOL_TABLE > 1 || OMIT_SYMBOL_TABLE < 0)
+ OMIT_SYMBOL_TABLE = 1;
+ }
+ if (strcmp(command,"LONG_DICT_FLAG_BUG")==0)
+ {
+ LONG_DICT_FLAG_BUG=j, flag=1;
+ if (LONG_DICT_FLAG_BUG > 1 || LONG_DICT_FLAG_BUG < 0)
+ LONG_DICT_FLAG_BUG = 1;
+ }
if (strcmp(command,"SERIAL")==0)
{
if (j >= 0 && j <= 999999)