1/* 2 See license.txt in the root of this project. 3*/ 4 5# ifndef LMT_TEXTYPES_H 6# define LMT_TEXTYPES_H 7 8# include <stdio.h> 9 10# define LMT_TOSTRING_INDEED(s) #s 11# define LMT_TOSTRING(s) LMT_TOSTRING_INDEED(s) 12 13/*tex 14 15 Here is the comment from the engine(s) that we started with. Keep in mind that \TEX\ originates 16 on other architectures and that it was written in \PASCAL. 17 18 In order to make efficient use of storage space, \TEX\ bases its major data structures on a 19 |memoryword|, which contains either a (signed) integer, possibly scaled, or a (signed) 20 |glue_ratio|, or a small number of fields that are one half or one quarter of the size used for 21 storing integers. More details about how we pack data in a memory word can be found in the 22 |memoryword| files. 23 24 If |x| is a variable of type |memoryword|, it contains up to four fields that can be referred 25 to as follows (\LUATEX\ differs a bit here but the principles remain): 26 27 \starttabulate 28 \NC |x.int| \NC an |integer| \NC \NR 29 \NC |x.sc | \NC a |scaled| integer \NC \NR 30 \NC |x.gr| \NC a |glueratio| \NC \NR 31 \NC |x.hh.lh|, |x.hh.rh| \NC two halfword fields) \NC \NR 32 \NC |x.hh.b0|, |x.hh.b1| \NC two quarterword fields \NC \NR 33 \NC |x.qqqq.b0| \unknown\ |x.qqqq.b3| \NC four quarterword fields \NC \NR 34 \stoptabulate 35 36 This is somewhat cumbersome to write, and not very readable either, but macros will be used to 37 make the notation shorter and more transparent. The |memoryword| file gives a formal definition 38 of |memoryword| and its subsidiary types, using packed variant records. \TEX\ makes no 39 assumptions about the relative positions of the fields within a word. 40 41 We are assuming 32-bit integers, a halfword must contain at least 32 bits, and a quarterword 42 must contain at least 16 bits. 43 44 The present implementation tries to accommodate as many variations as possible, so it makes few 45 assumptions. If integers having the subrange |min_quarterword .. max_quarterword| can be packed 46 into a quarterword, and if integers having the subrange |min_halfword .. max_halfword| can be 47 packed into a halfword, everything should work satisfactorily. 48 49 It is usually most efficient to have |min_quarterword = min_halfword = 0|, so one should try to 50 achieve this unless it causes a severe problem. The values defined here are recommended for most 51 32-bit computers. 52 53 We cannot use the full range of 32 bits in a halfword, because we have to allow negative values 54 for potential backend tricks like web2c's dynamic allocation, and parshapes pointers have to be 55 able to store at least twice the value |max_halfword| (see below). Therefore, |max_halfword| is 56 $2^{30}-1$ 57 58 Via the intermediate step if \WEBC\ we went from \PASCAL\ to \CCODE. As in the meantime we also 59 live in a 64 bit world the above model has been adapted a bit but the principles and names remain. 60 61 A |halfword| is a 32 bit integer and a |quarterword| a 16 bit one. The |scaled| type is used for 62 scaled integers but it's just another name for |halfword| or |int|. The code sometimes uses an 63 |int| instead of |scaled| or |halfword| (which might get fixed). By using the old type names we 64 sort of get an indication what we're dealing with. 65 66 If we even bump scaled to 64 bit we need to redo some code that now assumes that a scaled and 67 halfword are the same size (as in values). Instead we can then decide to go 64 bit for both. 68 69 The |internal_font_number| type is now also a |halfword| so it's no longer used as such. 70 71 We now use 64 memory words split into whatever pieces we need. This also means that we can use 72 a double as glueratio which us saves some casting. 73 74 In principle we can widen up the engine to use long instead of int because it is relatively easy 75 to adapt the nodes but it will take much more memory and we gain nothing. I might (re)introduce 76 the pointer as type instead of halfword just for clarity but the mixed usage doesn't really make 77 ot better. It's more about perception. I will do that when I have reason to check some code and 78 are in edit mode. 79 80*/ 81 82typedef int strnumber; 83typedef int halfword; 84typedef long long fullword; 85typedef unsigned short quarterword; /*tex It really is an unsigned one! But \MPLIB| had it signed. */ 86typedef unsigned char singleword; 87typedef int scaled; 88typedef double glueratio; /*tex This looks better in our (tex specific) syntax highlighting. */ 89typedef int pointer; /*tex Maybe I'll replace halfwords that act as pointer some day. */ 90typedef FILE *dumpstream; 91 92/* glueratio glue_ratio; */ /*tex one-word representation of a glue expansion factor */ 93/* unsigned char glue_ord; */ /*tex infinity to the 0, 1, 2, 3, or 4 power */ 94/* unsigned short group_code; */ /*tex |save_level| for a level boundary */ 95 96/*tex 97 98 The documentation refers to pointers and halfwords and scaled and all are in fact just integers. 99 Okay, one can wonder about negative pointers but we never reach the limits so we're okay wrr 100 wraparound. At some point we might just replace all by int as some of the helpers already do 101 that. For now we keep halfword and scaled but we removed (the not so often used) pointers 102 because they were already mixed with halfwords in similar usage. 103 104 So, again we use constants that reflect the original naming and also the related comments. 105 106 Here are some more constants. Others definitions can be font alongside where they make most 107 sense. For instance, these are used all over the place: |null|, |normal|, etc. However, over 108 time, with all these extensions it was not used consistently. So, I replaced the usage of 109 |normal| by more explicit identifiers, also because we have more subtypes in this engine. But 110 we kept most constants (but most in enums)! 111 112 Characters of text that have been converted to \TEX's internal form are said to be of type 113 |unsigned char|, which is a subrange of the integers. We are assuming that our runtime system 114 is able to read and write \UTF-8. 115 116 If constants in this file change, one also must change the format identifier! 117 118*/ 119 120typedef struct scaledwhd { 121 scaled wd; 122 scaled ht; 123 scaled dp; 124 union { 125 scaled ic; /* padding anyway */ 126 scaled ns; /* natural size */ 127 }; 128} scaledwhd; 129 130typedef struct scaledkrn { 131 scaled bl; 132 scaled br; 133 scaled tl; 134 scaled tr; 135} scaledkrn; 136 137extern halfword tex_badness( 138 scaled t, 139 scaled s 140); 141 142/*tex 143 We could use the 4 leftmost bits in tokens for [protected frozen tolerant permanent] flags but 144 it would mean way more shifting and checking so we don't to that. However, we already use 145 one nibble for the cstokenflag: 0x1FFFFFFF so we actually have no room. We also have a signed 146 unsigned issue because halfwords are integers so quite a bit needs to be adapted if we use all 147 32 bits. We have between 128 and 256 cmd codes so we need one byte for that. We also have to 148 deal with the max utf / unicode values. 149*/ 150 151# define cs_offset_bits 21 152# define cs_offset_value 0x00200000 // ((1 << STRING_OFFSET_BITS) - 1) 153# define cs_offset_max 0x001FFFFF 154# define cs_token_flag 0x1FFFFFFF 155 156# define max_cardinal 0xFFFFFFFF 157# define min_cardinal 0 158# define max_integer 0x7FFFFFFF /*tex aka |infinity| */ 159# define min_integer -0x7FFFFFFF /*tex aka |min_infinity| */ 160# define max_posit max_cardinal 161# define min_posit min_cardinal 162# define max_dimension 0x3FFFFFFF 163# define min_dimension -0x3FFFFFFF 164# define max_dimen max_dimension 165# define min_dimen min_dimension 166# define min_data_value 0 167# define max_data_value cs_offset_max 168# define max_half_value 32767 /*tex For instance sf codes.*/ 169 170# define one_bp 65781 171 172# define max_infinity 0x7FFFFFFF /*tex the largest positive value that \TEX\ knows */ 173# define min_infinity -0x7FFFFFFF 174# define awful_bad 0x3FFFFFFF /*tex more than a billion demerits |07777777777| */ 175# define infinite_bad 10000 /*tex infinitely bad value */ 176# define infinite_penalty infinite_bad /*tex infinite penalty value */ 177# define eject_penalty -infinite_penalty /*tex negatively infinite penalty value */ 178# define final_penalty -0x40000000 /*tex in the output routine */ 179# define deplorable 100000 /*tex more than |inf_bad|, but less than |awful_bad| */ 180# define extremely_deplorable 100000000 181# define large_width_excess 7230584 182# define small_stretchability 1663497 183# define loose_criterion 99 184# define semi_loose_criterion 12 /* same as |decent_criterion| */ 185# define decent_criterion 12 186# define semi_tight_criterion 12 /* same as |decent_criterion| */ 187# define max_calculated_badness 8189 188 189# define default_rule 26214 /*tex 0.4pt */ 190# define ignore_depth -65536000 /*tex The magic dimension value to mean \quote {ignore me}: -1000pt */ 191 192# define min_quarterword 0 /*tex The smallest allowable value in a |quarterword|. */ 193# define max_quarterword 65535 /*tex The largest allowable value in a |quarterword|. */ 194 195# define min_halfword -0x3FFFFFFF /*tex The smallest allowable value in a |halfword|. */ 196# define max_halfword 0x3FFFFFFF /*tex The largest allowable value in a |halfword|. */ 197 198# define null_flag -0x40000000 199# define zero_glue 0 200# define unity 0x10000 /*tex |0200000| or $2^{16}$, represents 1.00000 */ 201# define two 0x20000 /*tex |0400000| or $2^{17}$, represents 2.00000 */ 202# define null 0 203# define null_font 0 204 205# define unused_attribute_value -0x7FFFFFFF /*tex as low as it goes */ 206# define unused_state_value 0 /*tex 0 .. 0xFFFF */ 207# define unused_script_value 0 /*tex 0 .. 0xFFFF */ 208# define unused_scale_value 1000 209 210# define unused_math_style 0xFF 211# define unused_math_family 0xFF 212 213# define preset_rule_thickness 0x40000000 /*tex denotes |unset_rule_thickness|: |010000000000|. */ 214 215# define min_space_factor 0 /*tex watch out: |\spacefactor| cannot be zero but the sf code can!*/ 216# define max_space_factor 0x7FFF /*tex |077777| */ 217# define min_scale_factor 0 218# define max_scale_factor 100000 /*tex for now */ 219# define default_space_factor 1000 220# define space_factor_threshold 2000 221# define default_tolerance 10000 222# define default_hangafter 1 223# define default_deadcycles 25 224# define default_pre_display_gap 2000 225# define default_eqno_gap_step 1000 226 227# define default_output_box 255 228 229# define scaling_factor 1000 230# define scaling_factor_squared 1000000 231# define scaling_factor_double 1000.0 232//define scaling_multiplier_double 0.001 233 234# define max_math_scaling_factor 5000 235 236# define max_font_adjust_step 100 237# define max_font_adjust_stretch_factor 1000 238# define max_font_adjust_shrink_factor 500 239 240# define math_default_penalty (infinite_penalty+1) 241 242# define initial_alignment_state -1000000 243# define busy_alignment_state 1000000 244# define interwoven_alignment_threshold 500000 245 246/*tex 247 248 For practical reasons all these registers were max'd to 64K but that really makes no sense for 249 e.g. glue and mu glue and even attributes. Imagine using more than 8K attributes: we get long 250 linked lists, slow lookup, lots of copying, need plenty node memory. These large ranges also 251 demand more memory as we need these eqtb entries. So, when I was pondering specific ex and em 252 glue (behaving like mu glue in math) I realized that we can do that at no cost at all: we just 253 make some register ranges smaller. Keep in mind that we already have cheap integer, dimension, 254 and glue shortcuts that can be used instead of registers for storing constant values. 255 256 large : 7 * 64 = 448 3.584 Kb 257 medium : 4 * 64 + 2 * 32 + 1 * 16 = 336 2.688 Kb 258 small : 4 * 32 + 3 * 8 = 152 1.216 Kb 259 260 The memory saving is not that large but keep in mind that we have these huge eqtb arrays and 261 registers are accessed frequently so the more we have in the CPU cache the better. (We already 262 use less than in \LUATEX\ because we got rid of some parallel array so there it would have more 263 impact). 264 265 At some point we might actually drop these maxima indeed as we really don't need that many 266 if these registers and if (say) 16K is not enough, then nothing is. 267 268*/ 269 270# if 1 271 272 # define max_toks_register_index 0xFFFF /* 0xFFFF 0xFFFF 0x7FFF */ /* 64 64 32 */ 273 # define max_box_register_index 0xFFFF /* 0xFFFF 0xFFFF 0x7FFF */ /* 64 64 32 */ 274 # define max_integer_register_index 0xFFFF /* 0xFFFF 0xFFFF 0x3FFF */ /* 64 64 16 */ 275 # define max_dimension_register_index 0xFFFF /* 0xFFFF 0xFFFF 0x3FFF */ /* 64 64 16 */ 276 # define max_posit_register_index 0xFFFF /* 0xFFFF 0x7FFF 0x1FFF */ /* 64 32 8 */ 277 # define max_attribute_register_index 0xFFFF /* 0xFFFF 0x7FFF 0x1FFF */ /* 64 32 8 */ 278 # define max_glue_register_index 0xFFFF /* 0xFFFF 0x7FFF 0x1FFF */ /* 64 32 8 */ 279 # define max_muglue_register_index 0xFFFF /* 0xFFFF 0x3FFF 0x1FFF */ /* 64 16 8 */ 280 281# else 282 283 # define max_toks_register_index 0x1FFF // 8K 284 # define max_box_register_index 0x7FFF // 32K 285 # define max_integer_register_index 0x1FFF // 8k 286 # define max_dimension_register_index 0x1FFF // 8k 287 # define max_posit_register_index 0x1FFF // 8k 288 # define max_attribute_register_index 0x1FFF // 8k 289 # define max_glue_register_index 0x0FFF // 4k 290 # define max_muglue_register_index 0x0FFF // 4k 291 292# endif 293 294# define max_unit_register_index 26*26 295 296# define max_n_of_toks_registers (max_toks_register_index + 1) 297# define max_n_of_box_registers (max_box_register_index + 1) 298# define max_n_of_integer_registers (max_integer_register_index + 1) 299# define max_n_of_dimension_registers (max_dimension_register_index + 1) 300# define max_n_of_attribute_registers (max_attribute_register_index + 1) 301# define max_n_of_posit_registers (max_posit_register_index + 1) 302# define max_n_of_glue_registers (max_glue_register_index + 1) 303# define max_n_of_muglue_registers (max_muglue_register_index + 1) 304# define max_n_of_unit_registers (max_unit_register_index + 1) 305 306# define max_n_of_bytecodes 65536 /* dynamic */ 307# define max_n_of_math_families 64 308# define max_n_of_math_classes 64 309# define max_n_of_catcode_tables 256 310# define max_n_of_box_indices max_halfword 311 312# define max_character_code 0x10FFFF /*tex 1114111, the largest allowed character number; must be |< max_halfword| */ 313//define max_math_character_code 0x0FFFFF /*tex 1048575, for now this is plenty, otherwise we need to store differently */ 314# define max_math_character_code max_character_code /*tex part gets clipped when we convert to a number */ 315# define max_function_reference cs_offset_max 316# define min_iterator_value -0xFFFFF /* When we decide to generalize it might become 0xFFFF0 with */ 317# define max_iterator_value 0xFFFFF /* 0x0000F being a classifier so that we save cmd's */ 318# define max_category_code 15 319# define max_newline_character 127 /*tex This is an old constraint but there is no reason to change it. */ 320# define max_endline_character 127 /*tex To keep it simple we stick to the maximum single UTF character. */ 321# define max_box_axis 255 322# define max_size_of_word 1024 /*tex More than enough (esp. since this can end up on the stack. */ 323# define min_limited_scale 0 /*tex Zero is a signal too. */ 324# define max_limited_scale 1000 325# define min_math_style_scale 0 /*tex Zero is a signal too. */ 326# define max_math_style_scale 2000 327# define max_parameter_index 15 328 329# define max_mark_index (max_n_of_marks - 1) 330# define max_insert_index (max_n_of_inserts - 1) 331# define max_box_index (max_n_of_box_indices - 1) 332# define max_bytecode_index (max_n_of_bytecodes - 1) 333# define max_math_family_index (max_n_of_math_families - 1) 334# define max_math_class_code (max_n_of_math_classes - 1) 335# define max_math_property 0xFFFF 336# define max_math_group 0xFFFF 337# define max_math_index max_character_code 338# define max_math_discretionary 0xFF 339 340# define ascii_space 32 341# define ascii_max 127 342 343/*tex 344 345 This is very math specific: we used to pack info into an unsigned 32 bit integer: class, family 346 and character. We now use node for that (which also opend up the possibility to store more 347 info) but in case of a zero family we can also decide to use the older method of packing packing 348 a number: |FF+10FFFF| but the gain (at least on \CONTEXT) is litle: around 10K so here we only 349 mention it as consideration. We can consider anyway to omit the class part when we need a 350 numeric representation, although we don't really need (or like) that kind of abuse. 351 352*/ 353 354# define math_class_bits 6 355# define math_family_bits 6 356# define math_character_bits 20 357 358# define math_class_part(a) ((a >> 26) & 0x3F) 359# define math_family_part(a) ((a >> 20) & 0x3F) 360# define math_character_part(a) (a & 0xFFFFF) 361 362# define math_old_class_part(a) ((a >> 12) & 0x0F) 363# define math_old_family_part(a) ((a >> 8) & 0x0F) 364# define math_old_character_part(a) (a & 0xFF) 365 366# define math_old_class_mask(a) (a & 0x0F) 367# define math_old_family_mask(a) (a & 0x0F) 368# define math_old_character_mask(a) (a & 0xFF) 369 370# define math_packed_character(c,f,v) (((c & 0x3F) << 26) + ((f & 0x3F) << 20) + (v & 0xFFFFF)) 371# define math_old_packed_character(c,f,v) (((c & 0x0F) << 12) + ((f & 0x0F) << 8) + (v & 0x000FF)) 372 373# define rule_font_fam_offset 0xFFFFFF 374 375/*tex We put these here for consistency: */ 376 377# define too_big_char (max_character_code + 1) /*tex 1114112, |biggest_char + 1| */ 378# define special_char (max_character_code + 2) /*tex 1114113, |biggest_char + 2| */ 379# define number_chars (max_character_code + 3) /*tex 1114114, |biggest_char + 3| */ 380 381/*tex 382 383 As mentioned, because we're now in \CCODE\ we use a bit simplified memory mode. We don't do any 384 byte swapping related to endian properties as we don't share formats between architectures 385 anyway. A memory word is 64 bits and interpreted in several ways. So the memoryword is a bit 386 different. We also use the opportunity to squeeze eight characters into the word. 387 388 halfword : 32 bit integer (2) 389 quarterword : 16 bit integer (4) 390 singlechar : 8 bit unsigned char (8) 391 int : 32 bit integer (2) 392 glue : 64 bit double (1) 393 394 The names below still reflect the original \TEX\ names but we have simplified the model a bit. 395 Watch out: we still make |B0| and |B1| overlap |LH| which for instance is needed when a we 396 store the size of a node in the type and subtype field. The same is true for the overlapping 397 |CINT|s! Don't change this without also checking the macros elsewhere. 398 399 \starttyping 400 typedef union memoryword { 401 struct { 402 halfword H0, H1; 403 } h; 404 struct { 405 quarterword B0, B1, B2, B3; 406 } q; 407 struct { 408 unsigned char C0, C1, C2, C3, C4, C5, C6, C7; 409 } s; 410 struct { 411 glueratio GLUE; 412 } g; 413 } memoryword; 414 \stoptyping 415 416 The dual 32 bit model suits tokens well and for nodes is only needed because we store a double but 417 when we'd store a 32 bit float instead (which is cf tex) we could use a smaller single 32 bit word. 418 419 On the other hand. it might even make sense for nodes to move to a quad 32 bit variant because it 420 makes smaller node identifiers which might remove some limits. But as many nodes have an odd size 421 we will waste more memory. Of course for nodes we can at some point decide to go full dynamic and 422 use a pointer table but then we need to abstract the embedded subnodes (in disc and insert) first. 423 424 It is a bit tricky if we want to use a [8][8][16][32], [16][16][32] of similar mixing because of 425 endiannes, which is why we use a more stepwise definition of memoryword. This mixed scheme permits 426 packing more data in anode. 427 428*/ 429 430// typedef union memoryword { 431// halfword H[2]; /* 2 * 32 bit */ 432// unsigned int U[2]; 433// quarterword Q[4]; /* 4 * 16 bit */ 434// unsigned char C[8]; /* 8 * 8 bit */ 435// glueratio GLUE; /* 1 * 64 bit */ 436// long long L; 437// double D; 438// void *P; /* 1 * 64 bit or 32 bit */ 439// } memoryword; 440 441typedef union memorysplit { 442 quarterword Q; 443 singleword S[2]; 444} memorysplit; 445 446typedef union memoryalias { 447 halfword H; 448 unsigned int U; 449 /* quarterword Q[2]; */ 450 /* singleword S[4]; */ 451 memorysplit X[2]; 452} memoryalias; 453 454typedef union memoryword { 455 /* halfword H[2]; */ 456 /* unsigned int U[2]; */ 457 /* quarterword Q[4]; */ 458 memoryalias A[2]; 459 unsigned char C[8]; 460 glueratio GLUE; 461 long long L; 462 double D; 463 void *P; 464} memoryword; 465 466typedef union tokenword { 467 union { 468 halfword info; 469 halfword val; 470 struct { 471 int cmd:8; 472 int chr:24; 473 }; 474 }; 475 halfword link; 476} tokenword; 477 478/*tex 479 480 These symbolic names will be used in the definitions of tokens and nodes, the core data 481 structures of the \TEX\ machinery. In some cases halfs and quarters overlap. 482 483*/ 484 485# define half0 A[0].H 486# define half1 A[1].H 487 488# define hulf0 A[0].U 489# define hulf1 A[1].U 490 491// # define quart00 A[0].Q[0] 492// # define quart01 A[0].Q[1] 493// # define quart10 A[1].Q[0] 494// # define quart11 A[1].Q[1] 495 496# define quart00 A[0].X[0].Q 497# define quart01 A[0].X[1].Q 498# define quart10 A[1].X[0].Q 499# define quart11 A[1].X[1].Q 500 501// # define single00 A[0].S[0] 502// # define single01 A[0].S[1] 503// # define single02 A[0].S[2] 504// # define single03 A[0].S[3] 505// # define single10 A[1].S[0] 506// # define single11 A[1].S[1] 507// # define single12 A[1].S[2] 508// # define single13 A[1].S[3] 509 510# define single00 A[0].X[0].S[0] 511# define single01 A[0].X[0].S[1] 512# define single02 A[0].X[1].S[0] 513# define single03 A[0].X[1].S[1] 514# define single10 A[1].X[0].S[0] 515# define single11 A[1].X[0].S[1] 516# define single12 A[1].X[1].S[0] 517# define single13 A[1].X[1].S[1] 518 519# define glue0 GLUE 520# define long0 L 521# define double0 D 522 523/*tex 524 525 We're coming from \PASCAL\ which has a boolean type, while in \CCODE\ an |int| is used. However, 526 as we often have callbacks and and a connection with the \LUA\ end using |boolean|, |true| and 527 |false| is often somewhat inconstent. For that reason we now use |int| instead. It also prevents 528 interference with a different definition of |boolean|, something that we can into a few times in 529 the past with external code. 530 531 There were not that many explicit booleans used anyway so better be consistent in using integers 532 than have an inconsistent mix. 533 534*/ 535 536/*tex 537 538 The following parameters can be changed at compile time to extend or reduce \TEX's capacity. 539 They may have different values in |INITEX| and in production versions of \TEX. Some values can 540 be adapted at runtime. We start with those that influence memory management. Anyhow, some day 541 I will collect some statistics from runs and come up with (probably) lower defaults. 542 543*/ 544 545/*tex These do a stepwise allocation. */ 546 547/*tex The buffer is way too large ... only lines ... we could start out smaller */ 548 549/*define magic_maximum 2097151 */ /* (max string) Because we step 500K we will always be below this. */ 550//define magic_maximum 2000000 /* Looks nicer and we never need the real maximum anyway. */ 551# define magic_maximum cs_offset_value /* Looks nicer and we never need the real maximum anyway. */ 552 553# define max_hash_size magic_maximum /* This is one of these magic numbers. */ 554# define min_hash_size 150000 /* A reasonable default. */ 555# define siz_hash_size 250000 556# define stp_hash_size 100000 /* Often we have enough. */ 557 558# define max_pool_size magic_maximum /* stringsize ! */ 559# define min_pool_size 150000 560# define siz_pool_size 500000 561# define stp_pool_size 100000 562 563# define max_body_size 100000000 /* poolsize */ 564# define min_body_size 10000000 565# define siz_body_size 20000000 566# define stp_body_size 1000000 567 568# define max_node_size 100000000 /* Currently these are the memory words! */ 569//define siz_node_size 5000000 570# define siz_node_size 25000000 571# define min_node_size 2000000 /* Currently these are the memory words! */ 572# define stp_node_size 500000 /* Currently these are the memory words! */ 573 574# define max_token_size 10000000 /* If needed we can go much larger. */ 575# define siz_token_size 10000000 576# define min_token_size 1000000 /* The original 10000 is a bit cheap. */ 577# define stp_token_size 250000 578 579# define max_buffer_size 100000000 /* Let's be generous */ 580# define siz_buffer_size 10000000 581# define min_buffer_size 1000000 /* We often need quite a bit. */ 582# define stp_buffer_size 1000000 /* We use this step when we increase the table. */ 583 584# define max_nest_size 10000 /* The table will grow dynamically but the file system might have limitations. */ 585# define min_nest_size 1000 /* Quite a bit more that the old default 50. */ 586# define siz_nest_size 10000 /* Quite a bit more that the old default 50. */ 587# define stp_nest_size 1000 /* We use this step when we increase the table. */ 588 589# define max_in_open 2000 /* The table will grow dynamically but the file system might have limitations. */ 590# define min_in_open 500 /* This used to be 100, but who knows what users load. */ 591# define siz_in_open 2000 /* This used to be 100, but who knows what users load. */ 592# define stp_in_open 250 /* We use this step when we increase the table. */ 593 594# define max_parameter_size 100000 /* This should be plenty and if not there probably is an issue in the macro package. */ 595# define min_parameter_size 20000 /* The original value of 60 is definitely not enough when we nest macro calls. */ 596# define siz_parameter_size 100000 /* The original value of 60 is definitely not enough when we nest macro calls. */ 597# define stp_parameter_size 10000 /* We use this step when we increase the table. */ 598 599# define max_save_size 500000 /* The table will grow dynamically. */ 600# define min_save_size 100000 /* The original value was 5000, which is not that large for todays usage. */ 601# define siz_save_size 500000 /* The original value was 5000, which is not that large for todays usage. */ 602# define stp_save_size 10000 /* We use this step when we increase the table. */ 603 604# define max_stack_size 100000 /* The table will grow dynamically. */ 605# define min_stack_size 10000 /* The original value was 500, okay long ago, but not now. */ 606# define siz_stack_size 100000 /* The original value was 500, okay long ago, but not now. */ 607# define stp_stack_size 10000 /* We use this step when we increase the table. */ 608 609# define max_mark_size 10000 /*tex The 64K was rediculous (5 64K arrays of halfword). */ 610# define min_mark_size 50 611# define stp_mark_size 50 612 613# define max_insert_size 500 614# define min_insert_size 10 615# define stp_insert_size 10 616 617# define max_font_size 100000 /* We're now no longer hooked into the eqtb (saved 500+ K in the format too). */ 618# define min_font_size 250 619# define stp_font_size 250 620 621# define max_language_size 10000 /* We could bump this (as we merged the hj codes) but it makes no sense. */ 622# define min_language_size 250 623# define stp_language_size 250 624 625/*tex 626 Units. At some point these will be used in texscanning and lmtexlib (3 times replacement). 627*/ 628 629 630# define bp_numerator 7227 // base point 631# define bp_denonimator 7200 632 633# define cc_numerator 14856 // cicero 634# define cc_denonimator 1157 635 636# define cm_numerator 7227 // centimeter 637# define cm_denonimator 254 638 639# define dd_numerator 1238 // didot 640# define dd_denonimator 1157 641 642# define dk_numerator 49838 // knuth 643# define dk_denonimator 7739 644 645# define es_numerator 9176 // edith 646# define es_denonimator 129 647 648# define in_numerator 7227 // inch 649# define in_denonimator 100 650 651# define mm_numerator 7227 // millimeter 652# define mm_denonimator 2540 653 654# define pc_numerator 12 // pica 655# define pc_denonimator 1 656 657# define pt_numerator 1 // point 658# define pt_denonimator 1 659 660# define sp_numerator 1 // scaled point 661# define sp_denonimator 1 662 663# define ts_numerator 4588 // tove 664# define ts_denonimator 645 665 666# define eu_min_factor 1 667# define eu_max_factor 50 668# define eu_def_factor 10 669 670/*tex 671 672 These are used in the code, so when we want them to adapt, which is needed when we make them 673 configurable, we need to change this. 674 675*/ 676 677# define max_n_of_marks max_mark_size 678# define max_n_of_inserts max_insert_size 679# define max_n_of_fonts max_font_size 680# define max_n_of_languages max_language_size 681 682/*tex 683 684 The following settings are not related to memory management. Some day I will probably change 685 the error half stuff. There is already an indent related frozen setting here. 686 687*/ 688 689# define max_expand_depth 1000000 /* Just a number, no allocation. */ 690# define min_expand_depth 10000 691 692# define max_error_line 255 /* This also determines size of a (static) array */ 693# define min_error_line 132 /* Good old \TEX\ uses a value of 79. */ 694 695# define max_half_error_line 255 696# define min_half_error_line 80 /* Good old \TEX\ uses a value of 50. */ 697 698# define memory_data_unset -1 699 700typedef struct memory_data { 701 int ptr; /* the current pointer */ 702 int top; /* the maximum used pointer */ 703 int size; /* the used (optionally user asked) value */ 704 int allocated; /* the currently allocated amount */ 705 int step; /* the step used for growing */ 706 int minimum; /* the default mininum allocated, also the step */ 707 int maximum; /* the maximum possible */ 708 int itemsize; /* the itemsize */ 709 int initial; 710 int offset; /* offset of ptr and top */ 711} memory_data; 712 713typedef struct limits_data { 714 int size; /* the used (optionally user asked) value */ 715 int minimum; /* the default mininum allocated */ 716 int maximum; /* the maximum possible */ 717 int top; /* the maximum used */ 718} limits_data; 719 720extern void tex_dump_constants (dumpstream f); 721extern void tex_undump_constants (dumpstream f); 722 723/*tex 724 725This is an experimental feature, different approaces to the main command dispatcher: 726 727\starttabulate[|l|l|l|l|l|l] 728\BC n \BC method \BC [vhm]mode \BC binary \BC manual \BC comment \NC \NR 729\ML 730\NC 0 \NC jump table \NC cmd offsets \NC 2.691.584 \NC 10.719 \NC original method, selector: (cmd + mode) \NC \NR 731\NC 1 \NC case with modes \NC sequential \NC 2.697.216 \NC 10.638 \NC nicer modes, we can delegate more to runners \NC \NR 732\NC 2 \NC flat case \NC cmd offsets \NC 2.695.168 \NC 10.562 \NC variant on original \NC \NR 733\stoptabulate 734 735The second method can be codes differently where we can delegate more to runners (that then can get 736called with a mode argument). Maybe for a next iteration. Concerning performance: the differences 737can be neglected (no differences on the test suite) because the bottleneck in \CONTEXT\ is at the 738\LUA\ end. 739 740I occasionally test the variants. The last test showed that mode 1 gives a bit larger binary. There 741is no real difference in performance. 742 743Well, per end December 2022 we only have the case with modes left but one can always find the old 744code in the archive. 745 746*/ 747 748/*tex For the moment here. */ 749 750typedef struct line_break_properties { 751 halfword initial_par; 752 halfword display_math; 753 halfword tracing_paragraphs; 754 halfword paragraph_dir; 755 halfword parfill_left_skip; 756 halfword parfill_right_skip; 757 halfword parinit_left_skip; 758 halfword parinit_right_skip; 759 halfword emergency_left_skip; 760 halfword emergency_right_skip; 761 halfword pretolerance; 762 halfword tolerance; 763 halfword emergency_stretch; 764 halfword emergency_extra_stretch; 765 halfword looseness; 766 halfword adjust_spacing; 767 halfword protrude_chars; 768 halfword adj_demerits; 769 halfword double_adj_demerits; 770 halfword line_penalty; 771 halfword last_line_fit; 772 halfword double_hyphen_demerits; 773 halfword final_hyphen_demerits; 774 scaled hsize; 775 halfword left_skip; 776 halfword right_skip; 777 scaled hang_indent; 778 halfword hang_after; 779 halfword par_shape; 780 halfword inter_line_penalty; 781 halfword inter_line_penalties; 782 halfword club_penalty; 783 halfword club_penalties; 784 halfword widow_penalty; 785 halfword widow_penalties; 786 halfword display_widow_penalty; 787 halfword display_widow_penalties; 788 halfword orphan_penalty; 789 halfword orphan_penalties; 790 halfword broken_penalty; 791 halfword baseline_skip; 792 halfword line_skip; 793 halfword line_skip_limit; 794 halfword adjust_spacing_step; 795 halfword adjust_spacing_shrink; 796 halfword adjust_spacing_stretch; 797 halfword hyphenation_mode; 798 halfword shaping_penalties_mode; 799 halfword shaping_penalty; 800 halfword par_passes; 801 halfword tracing_passes; 802 halfword line_break_criterion; 803 halfword extra_hyphen_penalty; 804 halfword line_break_optional; 805 halfword optional_found; 806 halfword single_line_penalty; 807} line_break_properties; 808 809# endif 810 811 |