APPROVE COMMIT
NOTE: This patch has been committed
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1531274778 -3600
# Wed Jul 11 03:06:18 2018 +0100
# Node ID dde704f40544aa0fe8eecbf2b92fbdbb7eeeb057
# Parent 8d3aef8af4dfcc40d85867e5494d24d8c637d5e9
Correct some bugs on bignum, non-bignum builds, lisp_to_uid_t()
src/ChangeLog addition:
2018-07-11 Aidan Kehoe <kehoea(a)parhasard.net>
* data.c:
* data.c (LISP_INTEGER_TO_C_TYPE):
* data.c (C_TYPE_TO_LISP_INTEGER):
* number.h:
* number.h (bignum_fits_emacs_uint_p):
Correct a couple of bugs in lisp_to_uid_t() on bignum, non-bignum
builds.
Provide lisp_to_gid_t(), gid_t_to_lisp() too, not yet used.
Add a couple of comments to make grepping for the definitions
easier.
diff -r 8d3aef8af4df -r dde704f40544 src/ChangeLog
--- a/src/ChangeLog Thu Jul 05 21:58:01 2018 +0100
+++ b/src/ChangeLog Wed Jul 11 03:06:18 2018 +0100
@@ -1,3 +1,16 @@
+2018-07-11 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * data.c:
+ * data.c (LISP_INTEGER_TO_C_TYPE):
+ * data.c (C_TYPE_TO_LISP_INTEGER):
+ * number.h:
+ * number.h (bignum_fits_emacs_uint_p):
+ Correct a couple of bugs in lisp_to_uid_t() on bignum, non-bignum
+ builds.
+ Provide lisp_to_gid_t(), gid_t_to_lisp() too, not yet used.
+ Add a couple of comments to make grepping for the definitions
+ easier.
+
2018-07-05 Aidan Kehoe <kehoea(a)parhasard.net>
* menubar.c (Fcompare_menu_text):
diff -r 8d3aef8af4df -r dde704f40544 src/data.c
--- a/src/data.c Thu Jul 05 21:58:01 2018 +0100
+++ b/src/data.c Wed Jul 11 03:06:18 2018 +0100
@@ -4039,6 +4039,14 @@
(objekt)); \
} \
\
+ if (sizeof (c_type) >= SIZEOF_EMACS_INT && \
+ (c_type) (-1) > 0 && \
+ bignum_fits_emacs_uint_p (XBIGNUM_DATA (objekt))) \
+ { \
+ return (c_type) bignum_to_emacs_uint (XBIGNUM_DATA \
+ (objekt)); \
+ } \
+ \
if (sizeof (c_type) >= sizeof (long long) && \
bignum_fits_llong_p (XBIGNUM_DATA (objekt))) \
{ \
@@ -4046,6 +4054,7 @@
} \
\
if (sizeof (c_type) >= sizeof (long long) && \
+ (c_type) (-1) > 0 && \
bignum_fits_ullong_p (XBIGNUM_DATA (objekt))) \
{ \
return (c_type) bignum_to_ullong (XBIGNUM_DATA (objekt)); \
@@ -4066,11 +4075,12 @@
{ \
EMACS_INT ival = XREALFIXNUM (objekt); \
\
- if (sizeof (c_type) >= sizeof (EMACS_INT) ? \
- ((c_type) ival < min_lisp_to_c_type || \
- (c_type) ival > max_lisp_to_c_type) : \
- (ival < (EMACS_INT) min_lisp_to_c_type || \
- ival > (EMACS_INT) max_lisp_to_c_type)) \
+ if (((c_type)(-1) > 0 && ival < 0) || \
+ (sizeof (c_type) >= sizeof (EMACS_INT) ? \
+ ((c_type) ival < min_lisp_to_c_type || \
+ (c_type) ival > max_lisp_to_c_type) : \
+ (ival < (EMACS_INT) min_lisp_to_c_type || \
+ ival > (EMACS_INT) max_lisp_to_c_type))) \
{ \
args_out_of_range_3 (objekt, \
make_float (min_lisp_to_c_type), \
@@ -4100,8 +4110,8 @@
\
while (value) \
{ \
+ result = Fcons (make_fixnum (value & 0xFFFF), result); \
value = value >> 16; \
- result = Fcons (make_fixnum (value & 0xFFFF), result); \
} \
\
if (negative) \
@@ -4224,9 +4234,14 @@
} \
visibility Lisp_Object c_type##_to_lisp (c_type)
-DEFINE_C_INTEGER_TYPE_LISP_CONVERSION (extern, OFF_T);
-
+/* Definitions for lisp_to_OFF_T, OFF_T_to_lisp: */
+DEFINE_C_INTEGER_TYPE_LISP_CONVERSION (extern, OFF_T);
+
+/* Definitions for lisp_to_uid_t, uid_t_to_lisp: */
DEFINE_C_INTEGER_TYPE_LISP_CONVERSION (extern, uid_t);
+
+/* Definitions for lisp_to_uid_t, uid_t_to_lisp: */
+DEFINE_C_INTEGER_TYPE_LISP_CONVERSION (extern, gid_t);
/************************************************************************/
/* initialization */
diff -r 8d3aef8af4df -r dde704f40544 src/number.h
--- a/src/number.h Thu Jul 05 21:58:01 2018 +0100
+++ b/src/number.h Wed Jul 11 03:06:18 2018 +0100
@@ -100,18 +100,21 @@
#if SIZEOF_EMACS_INT == SIZEOF_LONG
# define bignum_fits_emacs_int_p(b) bignum_fits_long_p(b)
+# define bignum_fits_emacs_uint_p(b) bignum_fits_ulong_p(b)
# define bignum_to_emacs_int(b) bignum_to_long(b)
# define bignum_to_emacs_uint(b) bignum_to_ulong(b)
# define bignum_set_emacs_int bignum_set_long
# define make_bignum_emacs_uint(b) make_bignum_un(b)
#elif SIZEOF_EMACS_INT == SIZEOF_INT
# define bignum_fits_emacs_int_p(b) bignum_fits_int_p(b)
+# define bignum_fits_emacs_uint_p(b) bignum_fits_uint_p(b)
# define bignum_to_emacs_int(b) bignum_to_int(b)
# define bignum_to_emacs_uint(b) bignum_to_uint(b)
# define bignum_set_emacs_int bignum_set_long
# define make_bignum_emacs_uint(b) make_bignum_un(b)
#else
# define bignum_fits_emacs_int_p(b) bignum_fits_llong_p(b)
+# define bignum_fits_emacs_uint_p(b) bignum_fits_ullong_p(b)
# define bignum_to_emacs_int(b) bignum_to_llong(b)
# define bignum_to_emacs_uint(b) bignum_to_ullong(b)
# define bignum_set_emacs_int bignum_set_llong
@@ -443,6 +446,9 @@
extern Lisp_Object uid_t_to_lisp (uid_t);
extern uid_t lisp_to_uid_t (Lisp_Object);
+extern Lisp_Object gid_t_to_lisp (gid_t);
+extern gid_t lisp_to_gid_t (Lisp_Object);
+
#ifdef WITH_NUMBER_TYPES
/* promote_args() *always* converts a marker argument to a fixnum.
--
‘As I sat looking up at the Guinness ad, I could never figure out /
How your man stayed up on the surfboard after forty pints of stout’
(C. Moore)
Show replies by date