comparison src/lisp.h @ 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 873d7425c1ad
comparison
equal deleted inserted replaced
5580:a0e81357194e 5581:56144c8593a8
1656 /* This is the set of Lisp data types */ 1656 /* This is the set of Lisp data types */
1657 1657
1658 enum Lisp_Type 1658 enum Lisp_Type
1659 { 1659 {
1660 Lisp_Type_Record, 1660 Lisp_Type_Record,
1661 Lisp_Type_Int_Even, 1661 Lisp_Type_Fixnum_Even,
1662 Lisp_Type_Char, 1662 Lisp_Type_Char,
1663 Lisp_Type_Int_Odd 1663 Lisp_Type_Fixnum_Odd
1664 }; 1664 };
1665 1665
1666 #define POINTER_TYPE_P(type) ((type) == Lisp_Type_Record) 1666 #define POINTER_TYPE_P(type) ((type) == Lisp_Type_Record)
1667 1667
1668 /* Overridden by m/next.h */ 1668 /* Overridden by m/next.h */
1671 #endif 1671 #endif
1672 1672
1673 #define GCMARKBITS 0 1673 #define GCMARKBITS 0
1674 #define GCTYPEBITS 2 1674 #define GCTYPEBITS 2
1675 #define GCBITS 2 1675 #define GCBITS 2
1676 #define INT_GCBITS 1 1676 #define FIXNUM_GCBITS 1
1677 1677
1678 #define INT_VALBITS (BITS_PER_EMACS_INT - INT_GCBITS) 1678 #define FIXNUM_VALBITS (BITS_PER_EMACS_INT - FIXNUM_GCBITS)
1679 #define VALBITS (BITS_PER_EMACS_INT - GCBITS) 1679 #define VALBITS (BITS_PER_EMACS_INT - GCBITS)
1680 /* This is badly named; it's not the maximum value that an EMACS_INT can 1680 /* This is badly named; it's not the maximum value that an EMACS_INT can
1681 have, it's the maximum value that a Lisp-visible fixnum can have (half 1681 have, it's the maximum value that a Lisp-visible fixnum can have (half
1682 the maximum value an EMACS_INT can have) and as such would be better 1682 the maximum value an EMACS_INT can have) and as such would be better
1683 called MOST_POSITIVE_FIXNUM. Similarly for MOST_NEGATIVE_FIXNUM. */ 1683 called MOST_POSITIVE_FIXNUM. Similarly for MOST_NEGATIVE_FIXNUM. */
1684 #define EMACS_INT_MAX ((EMACS_INT) ((1UL << (INT_VALBITS - 1)) -1UL)) 1684 #define MOST_POSITIVE_FIXNUM ((EMACS_INT) ((1UL << (FIXNUM_VALBITS - 1)) -1UL))
1685 #define EMACS_INT_MIN (-(EMACS_INT_MAX) - 1) 1685 #define MOST_NEGATIVE_FIXNUM (-(MOST_POSITIVE_FIXNUM) - 1)
1686 /* WARNING: evaluates its arg twice. */ 1686 /* WARNING: evaluates its arg twice. */
1687 #define NUMBER_FITS_IN_AN_EMACS_INT(num) \ 1687 #define NUMBER_FITS_IN_A_FIXNUM(num) \
1688 ((num) <= EMACS_INT_MAX && (num) >= EMACS_INT_MIN) 1688 ((num) <= MOST_POSITIVE_FIXNUM && (num) >= MOST_NEGATIVE_FIXNUM)
1689 1689
1690 #ifdef USE_UNION_TYPE 1690 #ifdef USE_UNION_TYPE
1691 # include "lisp-union.h" 1691 # include "lisp-union.h"
1692 #else /* !USE_UNION_TYPE */ 1692 #else /* !USE_UNION_TYPE */
1693 # include "lisp-disunion.h" 1693 # include "lisp-disunion.h"
1698 /* Close your eyes now lest you vomit or spontaneously combust ... */ 1698 /* Close your eyes now lest you vomit or spontaneously combust ... */
1699 1699
1700 #define HACKEQ_UNSAFE(obj1, obj2) \ 1700 #define HACKEQ_UNSAFE(obj1, obj2) \
1701 (EQ (obj1, obj2) || (!POINTER_TYPE_P (XTYPE (obj1)) \ 1701 (EQ (obj1, obj2) || (!POINTER_TYPE_P (XTYPE (obj1)) \
1702 && !POINTER_TYPE_P (XTYPE (obj2)) \ 1702 && !POINTER_TYPE_P (XTYPE (obj2)) \
1703 && XCHAR_OR_INT (obj1) == XCHAR_OR_INT (obj2))) 1703 && XCHAR_OR_FIXNUM (obj1) == XCHAR_OR_FIXNUM (obj2)))
1704 1704
1705 #ifdef DEBUG_XEMACS 1705 #ifdef DEBUG_XEMACS
1706 extern MODULE_API int debug_issue_ebola_notices; 1706 extern MODULE_API int debug_issue_ebola_notices;
1707 MODULE_API int eq_with_ebola_notice (Lisp_Object, Lisp_Object); 1707 MODULE_API int eq_with_ebola_notice (Lisp_Object, Lisp_Object);
1708 #define EQ_WITH_EBOLA_NOTICE(obj1, obj2) \ 1708 #define EQ_WITH_EBOLA_NOTICE(obj1, obj2) \
1742 ) 1742 )
1743 { 1743 {
1744 EMACS_UINT p = (EMACS_UINT) ptr; 1744 EMACS_UINT p = (EMACS_UINT) ptr;
1745 1745
1746 type_checking_assert ((p & 1) == 0); 1746 type_checking_assert ((p & 1) == 0);
1747 return make_int (p >> 1); 1747 return make_fixnum (p >> 1);
1748 } 1748 }
1749 1749
1750 DECLARE_INLINE_HEADER ( 1750 DECLARE_INLINE_HEADER (
1751 void * 1751 void *
1752 GET_VOID_FROM_LISP (Lisp_Object obj) 1752 GET_VOID_FROM_LISP (Lisp_Object obj)
2738 #define wrap_bit_vector(p) wrap_record (p, bit_vector) 2738 #define wrap_bit_vector(p) wrap_record (p, bit_vector)
2739 #define BIT_VECTORP(x) RECORDP (x, bit_vector) 2739 #define BIT_VECTORP(x) RECORDP (x, bit_vector)
2740 #define CHECK_BIT_VECTOR(x) CHECK_RECORD (x, bit_vector) 2740 #define CHECK_BIT_VECTOR(x) CHECK_RECORD (x, bit_vector)
2741 #define CONCHECK_BIT_VECTOR(x) CONCHECK_RECORD (x, bit_vector) 2741 #define CONCHECK_BIT_VECTOR(x) CONCHECK_RECORD (x, bit_vector)
2742 2742
2743 #define BITP(x) (INTP (x) && (XINT (x) == 0 || XINT (x) == 1)) 2743 #define BITP(x) (FIXNUMP (x) && (XFIXNUM (x) == 0 || XFIXNUM (x) == 1))
2744 2744
2745 #define CHECK_BIT(x) do { \ 2745 #define CHECK_BIT(x) do { \
2746 if (!BITP (x)) \ 2746 if (!BITP (x)) \
2747 dead_wrong_type_argument (Qbitp, x);\ 2747 dead_wrong_type_argument (Qbitp, x);\
2748 } while (0) 2748 } while (0)
2936 #define MARKERP(x) RECORDP (x, marker) 2936 #define MARKERP(x) RECORDP (x, marker)
2937 #define CHECK_MARKER(x) CHECK_RECORD (x, marker) 2937 #define CHECK_MARKER(x) CHECK_RECORD (x, marker)
2938 #define CONCHECK_MARKER(x) CONCHECK_RECORD (x, marker) 2938 #define CONCHECK_MARKER(x) CONCHECK_RECORD (x, marker)
2939 2939
2940 /* The second check was looking for GCed markers still in use */ 2940 /* The second check was looking for GCed markers still in use */
2941 /* assert (!INTP (XMARKER (x)->lheader.next.v)); */ 2941 /* assert (!FIXNUMP (XMARKER (x)->lheader.next.v)); */
2942 2942
2943 #define marker_next(m) ((m)->next) 2943 #define marker_next(m) ((m)->next)
2944 #define marker_prev(m) ((m)->prev) 2944 #define marker_prev(m) ((m)->prev)
2945 2945
2946 /*-------------------basic int (no connection to char)------------------*/ 2946 /*-------------------basic int (no connection to char)------------------*/
2947 2947
2948 #define ZEROP(x) EQ (x, Qzero) 2948 #define ZEROP(x) EQ (x, Qzero)
2949 2949
2950 #ifdef ERROR_CHECK_TYPES 2950 #ifdef ERROR_CHECK_TYPES
2951 2951
2952 #define XINT(x) XINT_1 (x, __FILE__, __LINE__) 2952 #define XFIXNUM(x) XFIXNUM_1 (x, __FILE__, __LINE__)
2953 2953
2954 DECLARE_INLINE_HEADER ( 2954 DECLARE_INLINE_HEADER (
2955 EMACS_INT 2955 EMACS_INT
2956 XINT_1 (Lisp_Object obj, const Ascbyte *file, int line) 2956 XFIXNUM_1 (Lisp_Object obj, const Ascbyte *file, int line)
2957 ) 2957 )
2958 { 2958 {
2959 assert_at_line (INTP (obj), file, line); 2959 assert_at_line (FIXNUMP (obj), file, line);
2960 return XREALINT (obj); 2960 return XREALFIXNUM (obj);
2961 } 2961 }
2962 2962
2963 #else /* not ERROR_CHECK_TYPES */ 2963 #else /* not ERROR_CHECK_TYPES */
2964 2964
2965 #define XINT(obj) XREALINT (obj) 2965 #define XFIXNUM(obj) XREALFIXNUM (obj)
2966 2966
2967 #endif /* (not) ERROR_CHECK_TYPES */ 2967 #endif /* (not) ERROR_CHECK_TYPES */
2968 2968
2969 #define CHECK_INT(x) do { \ 2969 #define CHECK_FIXNUM(x) do { \
2970 if (!INTP (x)) \ 2970 if (!FIXNUMP (x)) \
2971 dead_wrong_type_argument (Qfixnump, x); \ 2971 dead_wrong_type_argument (Qfixnump, x); \
2972 } while (0) 2972 } while (0)
2973 2973
2974 #define CONCHECK_INT(x) do { \ 2974 #define CONCHECK_FIXNUM(x) do { \
2975 if (!INTP (x)) \ 2975 if (!FIXNUMP (x)) \
2976 x = wrong_type_argument (Qfixnump, x); \ 2976 x = wrong_type_argument (Qfixnump, x); \
2977 } while (0) 2977 } while (0)
2978 2978
2979 END_C_DECLS 2979 END_C_DECLS
2980 2980
3052 3052
3053 /*------------------------- int-char connection ------------------------*/ 3053 /*------------------------- int-char connection ------------------------*/
3054 3054
3055 #ifdef ERROR_CHECK_TYPES 3055 #ifdef ERROR_CHECK_TYPES
3056 3056
3057 #define XCHAR_OR_INT(x) XCHAR_OR_INT_1 (x, __FILE__, __LINE__) 3057 #define XCHAR_OR_FIXNUM(x) XCHAR_OR_FIXNUM_1 (x, __FILE__, __LINE__)
3058 3058
3059 DECLARE_INLINE_HEADER ( 3059 DECLARE_INLINE_HEADER (
3060 EMACS_INT 3060 EMACS_INT
3061 XCHAR_OR_INT_1 (Lisp_Object obj, const Ascbyte *file, int line) 3061 XCHAR_OR_FIXNUM_1 (Lisp_Object obj, const Ascbyte *file, int line)
3062 ) 3062 )
3063 { 3063 {
3064 assert_at_line (INTP (obj) || CHARP (obj), file, line); 3064 assert_at_line (FIXNUMP (obj) || CHARP (obj), file, line);
3065 return CHARP (obj) ? XCHAR (obj) : XINT (obj); 3065 return CHARP (obj) ? XCHAR (obj) : XFIXNUM (obj);
3066 } 3066 }
3067 3067
3068 #else /* no error checking */ 3068 #else /* no error checking */
3069 3069
3070 /* obj is multiply eval'ed and not an lvalue; use an inline function instead 3070 /* obj is multiply eval'ed and not an lvalue; use an inline function instead
3071 of a macro. */ 3071 of a macro. */
3072 DECLARE_INLINE_HEADER ( 3072 DECLARE_INLINE_HEADER (
3073 EMACS_INT 3073 EMACS_INT
3074 XCHAR_OR_INT (Lisp_Object obj) 3074 XCHAR_OR_FIXNUM (Lisp_Object obj)
3075 ) 3075 )
3076 { 3076 {
3077 return CHARP (obj) ? XCHAR (obj) : XINT (obj); 3077 return CHARP (obj) ? XCHAR (obj) : XFIXNUM (obj);
3078 } 3078 }
3079 3079
3080 #endif /* no error checking */ 3080 #endif /* no error checking */
3081 3081
3082 /* True of X is an integer whose value is the valid integral equivalent of a 3082 /* True of X is an integer whose value is the valid integral equivalent of a
3083 character. */ 3083 character. */
3084 3084
3085 #define CHAR_INTP(x) (INTP (x) && valid_ichar_p (XINT (x))) 3085 #define CHAR_INTP(x) (FIXNUMP (x) && valid_ichar_p (XFIXNUM (x)))
3086 3086
3087 /* True of X is a character or an integral value that can be converted into a 3087 /* True of X is a character or an integral value that can be converted into a
3088 character. */ 3088 character. */
3089 #define CHAR_OR_CHAR_INTP(x) (CHARP (x) || CHAR_INTP (x)) 3089 #define CHAR_OR_CHAR_INTP(x) (CHARP (x) || CHAR_INTP (x))
3090 3090
3091 DECLARE_INLINE_HEADER ( 3091 DECLARE_INLINE_HEADER (
3092 Ichar 3092 Ichar
3093 XCHAR_OR_CHAR_INT (Lisp_Object obj) 3093 XCHAR_OR_CHAR_INT (Lisp_Object obj)
3094 ) 3094 )
3095 { 3095 {
3096 return CHARP (obj) ? XCHAR (obj) : XINT (obj); 3096 return CHARP (obj) ? XCHAR (obj) : XFIXNUM (obj);
3097 } 3097 }
3098 3098
3099 /* Signal an error if CH is not a valid character or integer Lisp_Object. 3099 /* Signal an error if CH is not a valid character or integer Lisp_Object.
3100 If CH is an integer Lisp_Object, convert it to a character Lisp_Object, 3100 If CH is an integer Lisp_Object, convert it to a character Lisp_Object,
3101 but merely by repackaging, without performing tests for char validity. 3101 but merely by repackaging, without performing tests for char validity.
3103 3103
3104 #define CHECK_CHAR_COERCE_INT(x) do { \ 3104 #define CHECK_CHAR_COERCE_INT(x) do { \
3105 if (CHARP (x)) \ 3105 if (CHARP (x)) \
3106 ; \ 3106 ; \
3107 else if (CHAR_INTP (x)) \ 3107 else if (CHAR_INTP (x)) \
3108 x = make_char (XINT (x)); \ 3108 x = make_char (XFIXNUM (x)); \
3109 else \ 3109 else \
3110 x = wrong_type_argument (Qcharacterp, x); \ 3110 x = wrong_type_argument (Qcharacterp, x); \
3111 } while (0) 3111 } while (0)
3112 3112
3113 /* next three always continuable because they coerce their arguments. */ 3113 /* next three always continuable because they coerce their arguments. */
3114 #define CHECK_INT_COERCE_CHAR(x) do { \ 3114 #define CHECK_FIXNUM_COERCE_CHAR(x) do { \
3115 if (INTP (x)) \ 3115 if (FIXNUMP (x)) \
3116 ; \ 3116 ; \
3117 else if (CHARP (x)) \ 3117 else if (CHARP (x)) \
3118 x = make_int (XCHAR (x)); \ 3118 x = make_fixnum (XCHAR (x)); \
3119 else \ 3119 else \
3120 x = wrong_type_argument (Qinteger_or_char_p, x); \ 3120 x = wrong_type_argument (Qinteger_or_char_p, x); \
3121 } while (0) 3121 } while (0)
3122 3122
3123 #define CHECK_INT_COERCE_MARKER(x) do { \ 3123 #define CHECK_FIXNUM_COERCE_MARKER(x) do { \
3124 if (INTP (x)) \ 3124 if (FIXNUMP (x)) \
3125 ; \ 3125 ; \
3126 else if (MARKERP (x)) \ 3126 else if (MARKERP (x)) \
3127 x = make_int (marker_position (x)); \ 3127 x = make_fixnum (marker_position (x)); \
3128 else \ 3128 else \
3129 x = wrong_type_argument (Qinteger_or_marker_p, x); \ 3129 x = wrong_type_argument (Qinteger_or_marker_p, x); \
3130 } while (0) 3130 } while (0)
3131 3131
3132 #define CHECK_INT_COERCE_CHAR_OR_MARKER(x) do { \ 3132 #define CHECK_FIXNUM_COERCE_CHAR_OR_MARKER(x) do { \
3133 if (INTP (x)) \ 3133 if (FIXNUMP (x)) \
3134 ; \ 3134 ; \
3135 else if (CHARP (x)) \ 3135 else if (CHARP (x)) \
3136 x = make_int (XCHAR (x)); \ 3136 x = make_fixnum (XCHAR (x)); \
3137 else if (MARKERP (x)) \ 3137 else if (MARKERP (x)) \
3138 x = make_int (marker_position (x)); \ 3138 x = make_fixnum (marker_position (x)); \
3139 else \ 3139 else \
3140 x = wrong_type_argument (Qinteger_char_or_marker_p, x); \ 3140 x = wrong_type_argument (Qinteger_char_or_marker_p, x); \
3141 } while (0) 3141 } while (0)
3142 3142
3143 /*------------------------------ float ---------------------------------*/ 3143 /*------------------------------ float ---------------------------------*/
3162 #define CONCHECK_FLOAT(x) CONCHECK_RECORD (x, float) 3162 #define CONCHECK_FLOAT(x) CONCHECK_RECORD (x, float)
3163 3163
3164 #define float_data(f) ((f)->data.d) 3164 #define float_data(f) ((f)->data.d)
3165 #define XFLOAT_DATA(x) float_data (XFLOAT (x)) 3165 #define XFLOAT_DATA(x) float_data (XFLOAT (x))
3166 3166
3167 #define XFLOATINT(n) extract_float (n) 3167 #define XFLOATFIXNUM(n) extract_float (n)
3168 3168
3169 #define CHECK_INT_OR_FLOAT(x) do { \ 3169 #define CHECK_FIXNUM_OR_FLOAT(x) do { \
3170 if (!INT_OR_FLOATP (x)) \ 3170 if (!FIXNUM_OR_FLOATP (x)) \
3171 dead_wrong_type_argument (Qnumberp, x); \ 3171 dead_wrong_type_argument (Qnumberp, x); \
3172 } while (0) 3172 } while (0)
3173 3173
3174 #define CONCHECK_INT_OR_FLOAT(x) do { \ 3174 #define CONCHECK_FIXNUM_OR_FLOAT(x) do { \
3175 if (!INT_OR_FLOATP (x)) \ 3175 if (!FIXNUM_OR_FLOATP (x)) \
3176 x = wrong_type_argument (Qnumberp, x); \ 3176 x = wrong_type_argument (Qnumberp, x); \
3177 } while (0) 3177 } while (0)
3178 3178
3179 # define INT_OR_FLOATP(x) (INTP (x) || FLOATP (x)) 3179 # define FIXNUM_OR_FLOATP(x) (FIXNUMP (x) || FLOATP (x))
3180 3180
3181 /* #### change for 64-bit machines */ 3181 /* #### change for 64-bit machines */
3182 #define FLOAT_HASHCODE_FROM_DOUBLE(dbl) \ 3182 #define FLOAT_HASHCODE_FROM_DOUBLE(dbl) \
3183 (unsigned long)(fmod (dbl, 4e9)) 3183 (unsigned long)(fmod (dbl, 4e9))
3184 3184
3583 keyword_defaults) \ 3583 keyword_defaults) \
3584 PARSE_KEYWORDS_8 (intern_massaging_name (1 + #function), nargs, args, \ 3584 PARSE_KEYWORDS_8 (intern_massaging_name (1 + #function), nargs, args, \
3585 keyword_count, keywords, keyword_defaults, \ 3585 keyword_count, keywords, keyword_defaults, \
3586 /* Can't XSUBR (Fsymbol_function (...))->min_args, \ 3586 /* Can't XSUBR (Fsymbol_function (...))->min_args, \
3587 the function may be advised. */ \ 3587 the function may be advised. */ \
3588 XINT (Ffunction_min_args \ 3588 XFIXNUM (Ffunction_min_args \
3589 (intern_massaging_name (1 + #function))), \ 3589 (intern_massaging_name (1 + #function))), \
3590 0); \ 3590 0); \
3591 assert (0 == strcmp (__func__, #function)) 3591 assert (0 == strcmp (__func__, #function))
3592 #else /* defined (DEBUG_XEMACS) && ... */ 3592 #else /* defined (DEBUG_XEMACS) && ... */
3593 #define PARSE_KEYWORDS(function, nargs, args, keyword_count, keywords, \ 3593 #define PARSE_KEYWORDS(function, nargs, args, keyword_count, keywords, \
4363 MODULE_API Lisp_Object listu (Lisp_Object, ...); 4363 MODULE_API Lisp_Object listu (Lisp_Object, ...);
4364 DECLARE_DOESNT_RETURN (memory_full (void)); 4364 DECLARE_DOESNT_RETURN (memory_full (void));
4365 void disksave_object_finalization (void); 4365 void disksave_object_finalization (void);
4366 void finish_object_memory_usage_stats (void); 4366 void finish_object_memory_usage_stats (void);
4367 extern int purify_flag; 4367 extern int purify_flag;
4368 #define ARRAY_DIMENSION_LIMIT EMACS_INT_MAX 4368 #define ARRAY_DIMENSION_LIMIT MOST_POSITIVE_FIXNUM
4369 extern Fixnum Varray_dimension_limit; 4369 extern Fixnum Varray_dimension_limit;
4370 #ifndef NEW_GC 4370 #ifndef NEW_GC
4371 extern EMACS_INT gc_generation_number[1]; 4371 extern EMACS_INT gc_generation_number[1];
4372 #endif /* not NEW_GC */ 4372 #endif /* not NEW_GC */
4373 int c_readonly (Lisp_Object); 4373 int c_readonly (Lisp_Object);