comparison src/alloc.c @ 5581:56144c8593a8

Mechanically change INT to FIXNUM in our sources. src/ChangeLog addition: 2011-10-09 Aidan Kehoe <kehoea@parhasard.net> [...] Mechanically change INT (where it refers to non-bignum Lisp integers) to FIXNUM in our sources. Done for the following functions, enums, and macros: Lisp_Type_Int_Even, Lisp_Type_Int_Odd, INT_GCBITS, INT_VALBITS, make_int(), INTP(), XINT(), CHECK_INT(), XREALINT(), INT_PLUS(), INT_MINUS(), EMACS_INT_MAX (to MOST_POSITIVE_FIXNUM), EMACS_INT_MIN (to MOST_NEGATIVE_FIXNUM), NUMBER_FITS_IN_AN_EMACS_INT() to NUMBER_FITS_IN_A_FIXNUM(), XFLOATINT, XCHAR_OR_INT, INT_OR_FLOAT. The EMACS_INT typedef was not changed, it does not describe non-bignum Lisp integers. Script that did the change available in http://mid.gmane.org/20067.17650.181273.12014@parhasard.net . modules/ChangeLog addition: 2011-10-09 Aidan Kehoe <kehoea@parhasard.net> [...] Mechanically change INT to FIXNUM, where the usage describes non-bignum Lisp integers. See the src/ChangeLog entry for more details. man/ChangeLog addition: 2011-10-09 Aidan Kehoe <kehoea@parhasard.net> * internals/internals.texi (How Lisp Objects Are Represented in C): * internals/internals.texi (Integers and Characters): Mechanically change INT to FIXNUM, where the usage describes non-bignum Lisp integers.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 09 Oct 2011 09:51:57 +0100
parents 58b38d5b32d0
children 1a507c4c6c42
comparison
equal deleted inserted replaced
5580:a0e81357194e 5581:56144c8593a8
1581 (length, object)) 1581 (length, object))
1582 { 1582 {
1583 Lisp_Object val = Qnil; 1583 Lisp_Object val = Qnil;
1584 Elemcount size; 1584 Elemcount size;
1585 1585
1586 check_integer_range (length, Qzero, make_integer (EMACS_INT_MAX)); 1586 check_integer_range (length, Qzero, make_integer (MOST_POSITIVE_FIXNUM));
1587 1587
1588 size = XINT (length); 1588 size = XFIXNUM (length);
1589 1589
1590 while (size--) 1590 while (size--)
1591 val = Fcons (object, val); 1591 val = Fcons (object, val);
1592 1592
1593 return val; 1593 return val;
1860 Return a new vector of length LENGTH, with each element being OBJECT. 1860 Return a new vector of length LENGTH, with each element being OBJECT.
1861 See also the function `vector'. 1861 See also the function `vector'.
1862 */ 1862 */
1863 (length, object)) 1863 (length, object))
1864 { 1864 {
1865 check_integer_range (length, Qzero, make_int (ARRAY_DIMENSION_LIMIT)); 1865 check_integer_range (length, Qzero, make_fixnum (ARRAY_DIMENSION_LIMIT));
1866 return make_vector (XINT (length), object); 1866 return make_vector (XFIXNUM (length), object);
1867 } 1867 }
1868 1868
1869 DEFUN ("vector", Fvector, 0, MANY, 0, /* 1869 DEFUN ("vector", Fvector, 0, MANY, 0, /*
1870 Return a newly created vector with specified ARGS as elements. 1870 Return a newly created vector with specified ARGS as elements.
1871 Any number of arguments, even zero arguments, are allowed. 1871 Any number of arguments, even zero arguments, are allowed.
2042 Return a new bit vector of length LENGTH. with each bit set to BIT. 2042 Return a new bit vector of length LENGTH. with each bit set to BIT.
2043 BIT must be one of the integers 0 or 1. See also the function `bit-vector'. 2043 BIT must be one of the integers 0 or 1. See also the function `bit-vector'.
2044 */ 2044 */
2045 (length, bit)) 2045 (length, bit))
2046 { 2046 {
2047 check_integer_range (length, Qzero, make_int (ARRAY_DIMENSION_LIMIT)); 2047 check_integer_range (length, Qzero, make_fixnum (ARRAY_DIMENSION_LIMIT));
2048 return make_bit_vector (XINT (length), bit); 2048 return make_bit_vector (XFIXNUM (length), bit);
2049 } 2049 }
2050 2050
2051 DEFUN ("bit-vector", Fbit_vector, 0, MANY, 0, /* 2051 DEFUN ("bit-vector", Fbit_vector, 0, MANY, 0, /*
2052 Return a newly created bit vector with specified ARGS as elements. 2052 Return a newly created bit vector with specified ARGS as elements.
2053 Any number of arguments, even zero arguments, are allowed. 2053 Any number of arguments, even zero arguments, are allowed.
2133 Lisp_Object doc_string = (nargs > 4) ? args[4] : Qnil; 2133 Lisp_Object doc_string = (nargs > 4) ? args[4] : Qnil;
2134 Lisp_Object interactive = (nargs > 5) ? args[5] : Qunbound; 2134 Lisp_Object interactive = (nargs > 5) ? args[5] : Qunbound;
2135 2135
2136 if (nargs < 4 || nargs > 6) 2136 if (nargs < 4 || nargs > 6)
2137 return Fsignal (Qwrong_number_of_arguments, 2137 return Fsignal (Qwrong_number_of_arguments,
2138 list2 (intern ("make-byte-code"), make_int (nargs))); 2138 list2 (intern ("make-byte-code"), make_fixnum (nargs)));
2139 2139
2140 /* Check for valid formal parameter list now, to allow us to use 2140 /* Check for valid formal parameter list now, to allow us to use
2141 SPECBIND_FAST_UNSAFE() later in funcall_compiled_function(). */ 2141 SPECBIND_FAST_UNSAFE() later in funcall_compiled_function(). */
2142 { 2142 {
2143 EXTERNAL_LIST_LOOP_2 (symbol, arglist) 2143 EXTERNAL_LIST_LOOP_2 (symbol, arglist)
2156 /* `instructions' is a string or a cons (string . int) for a 2156 /* `instructions' is a string or a cons (string . int) for a
2157 lazy-loaded function. */ 2157 lazy-loaded function. */
2158 if (CONSP (instructions)) 2158 if (CONSP (instructions))
2159 { 2159 {
2160 CHECK_STRING (XCAR (instructions)); 2160 CHECK_STRING (XCAR (instructions));
2161 CHECK_INT (XCDR (instructions)); 2161 CHECK_FIXNUM (XCDR (instructions));
2162 } 2162 }
2163 else 2163 else
2164 { 2164 {
2165 CHECK_STRING (instructions); 2165 CHECK_STRING (instructions);
2166 } 2166 }
2168 2168
2169 if (!NILP (constants)) 2169 if (!NILP (constants))
2170 CHECK_VECTOR (constants); 2170 CHECK_VECTOR (constants);
2171 f->constants = constants; 2171 f->constants = constants;
2172 2172
2173 check_integer_range (stack_depth, Qzero, make_int (USHRT_MAX)); 2173 check_integer_range (stack_depth, Qzero, make_fixnum (USHRT_MAX));
2174 f->stack_depth = (unsigned short) XINT (stack_depth); 2174 f->stack_depth = (unsigned short) XFIXNUM (stack_depth);
2175 2175
2176 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK 2176 #ifdef COMPILED_FUNCTION_ANNOTATION_HACK
2177 f->annotated = Vload_file_name_internal; 2177 f->annotated = Vload_file_name_internal;
2178 #endif /* COMPILED_FUNCTION_ANNOTATION_HACK */ 2178 #endif /* COMPILED_FUNCTION_ANNOTATION_HACK */
2179 2179
2532 { 2532 {
2533 Lisp_Object *ptr = &XSTRING_PLIST (string); 2533 Lisp_Object *ptr = &XSTRING_PLIST (string);
2534 2534
2535 if (CONSP (*ptr) && EXTENT_INFOP (XCAR (*ptr))) 2535 if (CONSP (*ptr) && EXTENT_INFOP (XCAR (*ptr)))
2536 ptr = &XCDR (*ptr); 2536 ptr = &XCDR (*ptr);
2537 if (CONSP (*ptr) && INTP (XCAR (*ptr))) 2537 if (CONSP (*ptr) && FIXNUMP (XCAR (*ptr)))
2538 ptr = &XCDR (*ptr); 2538 ptr = &XCDR (*ptr);
2539 return ptr; 2539 return ptr;
2540 } 2540 }
2541 2541
2542 static Lisp_Object 2542 static Lisp_Object
3004 Return a new string consisting of LENGTH copies of CHARACTER. 3004 Return a new string consisting of LENGTH copies of CHARACTER.
3005 LENGTH must be a non-negative integer. 3005 LENGTH must be a non-negative integer.
3006 */ 3006 */
3007 (length, character)) 3007 (length, character))
3008 { 3008 {
3009 check_integer_range (length, Qzero, make_int (ARRAY_DIMENSION_LIMIT)); 3009 check_integer_range (length, Qzero, make_fixnum (ARRAY_DIMENSION_LIMIT));
3010 CHECK_CHAR_COERCE_INT (character); 3010 CHECK_CHAR_COERCE_INT (character);
3011 { 3011 {
3012 Ibyte init_str[MAX_ICHAR_LEN]; 3012 Ibyte init_str[MAX_ICHAR_LEN];
3013 int len = set_itext_ichar (init_str, XCHAR (character)); 3013 int len = set_itext_ichar (init_str, XCHAR (character));
3014 Lisp_Object val = make_uninit_string (len * XINT (length)); 3014 Lisp_Object val = make_uninit_string (len * XFIXNUM (length));
3015 3015
3016 if (len == 1) 3016 if (len == 1)
3017 { 3017 {
3018 /* Optimize the single-byte case */ 3018 /* Optimize the single-byte case */
3019 memset (XSTRING_DATA (val), XCHAR (character), XSTRING_LENGTH (val)); 3019 memset (XSTRING_DATA (val), XCHAR (character), XSTRING_LENGTH (val));
3020 XSET_STRING_ASCII_BEGIN (val, min (MAX_STRING_ASCII_BEGIN, 3020 XSET_STRING_ASCII_BEGIN (val, min (MAX_STRING_ASCII_BEGIN,
3021 len * XINT (length))); 3021 len * XFIXNUM (length)));
3022 } 3022 }
3023 else 3023 else
3024 { 3024 {
3025 EMACS_INT i; 3025 EMACS_INT i;
3026 Ibyte *ptr = XSTRING_DATA (val); 3026 Ibyte *ptr = XSTRING_DATA (val);
3027 3027
3028 for (i = XINT (length); i; i--) 3028 for (i = XFIXNUM (length); i; i--)
3029 { 3029 {
3030 Ibyte *init_ptr = init_str; 3030 Ibyte *init_ptr = init_str;
3031 switch (len) 3031 switch (len)
3032 { 3032 {
3033 case 4: *ptr++ = *init_ptr++; 3033 case 4: *ptr++ = *init_ptr++;
4044 gc_plist_hack (const Ascbyte *name, EMACS_INT value, Lisp_Object tail) 4044 gc_plist_hack (const Ascbyte *name, EMACS_INT value, Lisp_Object tail)
4045 { 4045 {
4046 /* C doesn't have local functions (or closures, or GC, or readable syntax, 4046 /* C doesn't have local functions (or closures, or GC, or readable syntax,
4047 or portable numeric datatypes, or bit-vectors, or characters, or 4047 or portable numeric datatypes, or bit-vectors, or characters, or
4048 arrays, or exceptions, or ...) */ 4048 arrays, or exceptions, or ...) */
4049 return cons3 (intern (name), make_int (value), tail); 4049 return cons3 (intern (name), make_fixnum (value), tail);
4050 } 4050 }
4051 4051
4052 /* Pluralize a lowercase English word stored in BUF, assuming BUF has 4052 /* Pluralize a lowercase English word stored in BUF, assuming BUF has
4053 enough space to hold the extra letters (at most 2). */ 4053 enough space to hold the extra letters (at most 2). */
4054 static void 4054 static void
4228 { 4228 {
4229 /* The things we do for backwards-compatibility */ 4229 /* The things we do for backwards-compatibility */
4230 #ifdef NEW_GC 4230 #ifdef NEW_GC
4231 return 4231 return
4232 list6 4232 list6
4233 (Fcons (make_int (lrecord_stats[lrecord_type_cons].instances_in_use), 4233 (Fcons (make_fixnum (lrecord_stats[lrecord_type_cons].instances_in_use),
4234 make_int (lrecord_stats[lrecord_type_cons] 4234 make_fixnum (lrecord_stats[lrecord_type_cons]
4235 .bytes_in_use_including_overhead)), 4235 .bytes_in_use_including_overhead)),
4236 Fcons (make_int (lrecord_stats[lrecord_type_symbol].instances_in_use), 4236 Fcons (make_fixnum (lrecord_stats[lrecord_type_symbol].instances_in_use),
4237 make_int (lrecord_stats[lrecord_type_symbol] 4237 make_fixnum (lrecord_stats[lrecord_type_symbol]
4238 .bytes_in_use_including_overhead)), 4238 .bytes_in_use_including_overhead)),
4239 Fcons (make_int (lrecord_stats[lrecord_type_marker].instances_in_use), 4239 Fcons (make_fixnum (lrecord_stats[lrecord_type_marker].instances_in_use),
4240 make_int (lrecord_stats[lrecord_type_marker] 4240 make_fixnum (lrecord_stats[lrecord_type_marker]
4241 .bytes_in_use_including_overhead)), 4241 .bytes_in_use_including_overhead)),
4242 make_int (lrecord_stats[lrecord_type_string] 4242 make_fixnum (lrecord_stats[lrecord_type_string]
4243 .bytes_in_use_including_overhead), 4243 .bytes_in_use_including_overhead),
4244 make_int (lrecord_stats[lrecord_type_vector] 4244 make_fixnum (lrecord_stats[lrecord_type_vector]
4245 .bytes_in_use_including_overhead), 4245 .bytes_in_use_including_overhead),
4246 object_memory_usage_stats (1)); 4246 object_memory_usage_stats (1));
4247 #else /* not NEW_GC */ 4247 #else /* not NEW_GC */
4248 return 4248 return
4249 list6 (Fcons (make_int (gc_count_num_cons_in_use), 4249 list6 (Fcons (make_fixnum (gc_count_num_cons_in_use),
4250 make_int (gc_count_num_cons_freelist)), 4250 make_fixnum (gc_count_num_cons_freelist)),
4251 Fcons (make_int (gc_count_num_symbol_in_use), 4251 Fcons (make_fixnum (gc_count_num_symbol_in_use),
4252 make_int (gc_count_num_symbol_freelist)), 4252 make_fixnum (gc_count_num_symbol_freelist)),
4253 Fcons (make_int (gc_count_num_marker_in_use), 4253 Fcons (make_fixnum (gc_count_num_marker_in_use),
4254 make_int (gc_count_num_marker_freelist)), 4254 make_fixnum (gc_count_num_marker_freelist)),
4255 make_int (gc_count_string_total_size), 4255 make_fixnum (gc_count_string_total_size),
4256 make_int (lrecord_stats[lrecord_type_vector].bytes_in_use + 4256 make_fixnum (lrecord_stats[lrecord_type_vector].bytes_in_use +
4257 lrecord_stats[lrecord_type_vector].bytes_freed + 4257 lrecord_stats[lrecord_type_vector].bytes_freed +
4258 lrecord_stats[lrecord_type_vector].bytes_on_free_list), 4258 lrecord_stats[lrecord_type_vector].bytes_on_free_list),
4259 object_memory_usage_stats (1)); 4259 object_memory_usage_stats (1));
4260 #endif /* not NEW_GC */ 4260 #endif /* not NEW_GC */
4261 } 4261 }
4316 4316
4317 xzero (object_stats); 4317 xzero (object_stats);
4318 lisp_object_storage_size (object, &object_stats); 4318 lisp_object_storage_size (object, &object_stats);
4319 4319
4320 val = Facons (Qobject_actually_requested, 4320 val = Facons (Qobject_actually_requested,
4321 make_int (object_stats.was_requested), val); 4321 make_fixnum (object_stats.was_requested), val);
4322 val = Facons (Qobject_malloc_overhead, 4322 val = Facons (Qobject_malloc_overhead,
4323 make_int (object_stats.malloc_overhead), val); 4323 make_fixnum (object_stats.malloc_overhead), val);
4324 assert (!object_stats.dynarr_overhead); 4324 assert (!object_stats.dynarr_overhead);
4325 assert (!object_stats.gap_overhead); 4325 assert (!object_stats.gap_overhead);
4326 4326
4327 if (!NILP (stats_list)) 4327 if (!NILP (stats_list))
4328 { 4328 {
4329 xzero (gustats); 4329 xzero (gustats);
4330 MAYBE_OBJECT_METH (object, memory_usage, (object, &gustats)); 4330 MAYBE_OBJECT_METH (object, memory_usage, (object, &gustats));
4331 4331
4332 val = Fcons (Qt, val); 4332 val = Fcons (Qt, val);
4333 val = Facons (Qother_memory_actually_requested, 4333 val = Facons (Qother_memory_actually_requested,
4334 make_int (gustats.u.was_requested), val); 4334 make_fixnum (gustats.u.was_requested), val);
4335 val = Facons (Qother_memory_malloc_overhead, 4335 val = Facons (Qother_memory_malloc_overhead,
4336 make_int (gustats.u.malloc_overhead), val); 4336 make_fixnum (gustats.u.malloc_overhead), val);
4337 if (gustats.u.dynarr_overhead) 4337 if (gustats.u.dynarr_overhead)
4338 val = Facons (Qother_memory_dynarr_overhead, 4338 val = Facons (Qother_memory_dynarr_overhead,
4339 make_int (gustats.u.dynarr_overhead), val); 4339 make_fixnum (gustats.u.dynarr_overhead), val);
4340 if (gustats.u.gap_overhead) 4340 if (gustats.u.gap_overhead)
4341 val = Facons (Qother_memory_gap_overhead, 4341 val = Facons (Qother_memory_gap_overhead,
4342 make_int (gustats.u.gap_overhead), val); 4342 make_fixnum (gustats.u.gap_overhead), val);
4343 val = Fcons (Qnil, val); 4343 val = Fcons (Qnil, val);
4344 4344
4345 i = 0; 4345 i = 0;
4346 { 4346 {
4347 LIST_LOOP_2 (item, stats_list) 4347 LIST_LOOP_2 (item, stats_list)
4348 { 4348 {
4349 if (NILP (item) || EQ (item, Qt)) 4349 if (NILP (item) || EQ (item, Qt))
4350 val = Fcons (item, val); 4350 val = Fcons (item, val);
4351 else 4351 else
4352 { 4352 {
4353 val = Facons (item, make_int (gustats.othervals[i]), val); 4353 val = Facons (item, make_fixnum (gustats.othervals[i]), val);
4354 i++; 4354 i++;
4355 } 4355 }
4356 } 4356 }
4357 } 4357 }
4358 } 4358 }
4484 This may be helpful in debugging XEmacs's memory usage. 4484 This may be helpful in debugging XEmacs's memory usage.
4485 See also `consing-since-gc' and `object-memory-usage-stats'. 4485 See also `consing-since-gc' and `object-memory-usage-stats'.
4486 */ 4486 */
4487 ()) 4487 ())
4488 { 4488 {
4489 return make_int (total_gc_usage + consing_since_gc); 4489 return make_fixnum (total_gc_usage + consing_since_gc);
4490 } 4490 }
4491 4491
4492 #endif /* ALLOC_TYPE_STATS */ 4492 #endif /* ALLOC_TYPE_STATS */
4493 4493
4494 4494
5538 5538
5539 If this value exceeds `gc-cons-threshold', a garbage collection happens. 5539 If this value exceeds `gc-cons-threshold', a garbage collection happens.
5540 */ 5540 */
5541 ()) 5541 ())
5542 { 5542 {
5543 return make_int (consing_since_gc); 5543 return make_fixnum (consing_since_gc);
5544 } 5544 }
5545 5545
5546 #if 0 5546 #if 0
5547 DEFUN ("memory-limit", Fmemory_limit, 0, 0, 0, /* 5547 DEFUN ("memory-limit", Fmemory_limit, 0, 0, 0, /*
5548 Return the address of the last byte XEmacs has allocated, divided by 1024. 5548 Return the address of the last byte XEmacs has allocated, divided by 1024.
5549 This may be helpful in debugging XEmacs's memory usage. 5549 This may be helpful in debugging XEmacs's memory usage.
5550 The value is divided by 1024 to make sure it will fit in a lisp integer. 5550 The value is divided by 1024 to make sure it will fit in a lisp integer.
5551 */ 5551 */
5552 ()) 5552 ())
5553 { 5553 {
5554 return make_int ((EMACS_INT) sbrk (0) / 1024); 5554 return make_fixnum ((EMACS_INT) sbrk (0) / 1024);
5555 } 5555 }
5556 #endif 5556 #endif
5557 5557
5558 DEFUN ("total-memory-usage", Ftotal_memory_usage, 0, 0, 0, /* 5558 DEFUN ("total-memory-usage", Ftotal_memory_usage, 0, 0, 0, /*
5559 Return the total number of bytes used by the data segment in XEmacs. 5559 Return the total number of bytes used by the data segment in XEmacs.
5562 value in a system-independent fashion. On Windows, for example, the 5562 value in a system-independent fashion. On Windows, for example, the
5563 returned number tends to be much greater than reality. 5563 returned number tends to be much greater than reality.
5564 */ 5564 */
5565 ()) 5565 ())
5566 { 5566 {
5567 return make_int (total_data_usage ()); 5567 return make_fixnum (total_data_usage ());
5568 } 5568 }
5569 5569
5570 #ifdef USE_VALGRIND 5570 #ifdef USE_VALGRIND
5571 DEFUN ("valgrind-leak-check", Fvalgrind_leak_check, 0, 0, "", /* 5571 DEFUN ("valgrind-leak-check", Fvalgrind_leak_check, 0, 0, "", /*
5572 Ask valgrind to perform a memory leak check. 5572 Ask valgrind to perform a memory leak check.
5598 /* Initialization */ 5598 /* Initialization */
5599 static void 5599 static void
5600 common_init_alloc_early (void) 5600 common_init_alloc_early (void)
5601 { 5601 {
5602 #ifndef Qzero 5602 #ifndef Qzero
5603 Qzero = make_int (0); /* Only used if Lisp_Object is a union type */ 5603 Qzero = make_fixnum (0); /* Only used if Lisp_Object is a union type */
5604 #endif 5604 #endif
5605 5605
5606 #ifndef Qnull_pointer 5606 #ifndef Qnull_pointer
5607 /* C guarantees that Qnull_pointer will be initialized to all 0 bits, 5607 /* C guarantees that Qnull_pointer will be initialized to all 0 bits,
5608 so the following is actually a no-op. */ 5608 so the following is actually a no-op. */