Cleanup utilities. Introduce sxe-memory.h
[sxemacs] / src / lisp.h
index a858a9e..e60bc14 100644 (file)
@@ -31,6 +31,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 /* the old SXEmacs general includes and utility macros moved here: */
 #include "sxe-utils.h"
+#include "sxe-memory.h"
 
 /* ------------------------ dynamic arrays ------------------- */
 
@@ -672,6 +673,7 @@ do {                                                                        \
   Lisp_Object GELL_elt, GELL_tail;                                     \
   EXTERNAL_LIST_LOOP_4_NO_DECLARE (GELL_elt, list, GELL_tail, len)     \
     ;                                                                  \
+  (void)GELL_elt;                                                       \
 } while (0)
 
 /* For a list that's known to be in valid list format, where we may
@@ -1313,6 +1315,9 @@ extern_inline EMACS_INT XCHAR_OR_INT(Lisp_Object obj)
     x = wrong_type_argument (Qinteger_char_or_marker_p, x);    \
 } while (0)
 
+/* basic integer definitions, used quite a lot */
+#include "ent/ent-int.h"
+
 /*--------------------------- readonly objects -------------------------*/
 
 #define CHECK_C_WRITEABLE(obj)                                 \
@@ -2469,8 +2474,29 @@ void staticpro_nodump(Lisp_Object *);
 
 /* allocation goodies */
 #include "opaque.h"
-/* for size computation */
-#include "ent/ent.h"
+
+static inline EMACS_INT
+__attribute__((always_inline))
+__next_2power(EMACS_INT v)
+{
+/* compute the next 2-power of in */
+       v--;
+       v |= v >> 1;
+       v |= v >> 2;
+       v |= v >> 4;
+       v |= v >> 8;
+#if SIZEOF_EMACS_INT >= 4
+       v |= v >> 16;
+#endif /* sizeof(EMACS_INT) >= 4 */
+#if SIZEOF_EMACS_INT >= 8
+       v |= v >> 32;
+#endif /* sizeof(EMACS_INT) >= 8 */
+#if SIZEOF_EMACS_INT >= 16
+       v |= v >> 64;
+#endif /* sizeof(EMACS_INT) >= 16 */
+       v++;
+       return v;
+}
 
 /* also generally useful if you want to avoid arbitrary size limits
    but don't need a full dynamic array.  Assumes that BASEVAR points
@@ -2479,16 +2505,14 @@ void staticpro_nodump(Lisp_Object *);
    macro will realloc BASEVAR as necessary so that it can hold at
    least NEEDED_SIZE objects.  The reallocing is done by doubling,
    which ensures constant amortized time per element. */
-extern_inline EMACS_INT
-__alloc_size(EMACS_INT sz, EMACS_INT needed)
-       __attribute__((always_inline));
-extern_inline EMACS_INT
+static inline EMACS_INT
+__attribute__((always_inline))
 __alloc_size(EMACS_INT sz, EMACS_INT needed)
 {
        if (UNLIKELY(needed <= 32)) {
                return 32;
        }
-       return 1 << (1 + __ase_flsl(needed - 1));
+       return __next_2power(needed);
 }
 
 #define DO_REALLOC(basevar, sizevar, needed_size, type)                        \
@@ -2864,6 +2888,7 @@ Lisp_Object emacs_doprnt_string_lisp_2(const Bufbyte *, Lisp_Object,
 void uncache_home_directory(void);
 Extbyte *get_home_directory(void);
 char *user_login_name(uid_t *);
+char *user_group_name(gid_t *);
 Bufpos bufpos_clip_to_bounds(Bufpos, Bufpos, Bufpos);
 Bytind bytind_clip_to_bounds(Bytind, Bytind, Bytind);
 void buffer_insert1(struct buffer *, Lisp_Object);
@@ -3621,6 +3646,7 @@ EXFUN(Fupcase_initials_region, 3);
 EXFUN(Fupcase_region, 3);
 EXFUN(Fuser_home_directory, 0);
 EXFUN(Fuser_login_name, 1);
+EXFUN(Fuser_group_name, 1);
 EXFUN(Fvector, MANY);
 EXFUN(Fverify_visited_file_modtime, 1);
 EXFUN(Fvertical_motion, 3);