mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-22 00:48:53 +02:00
Added two new alloca-based function macros, g_strdup_a and g_strconcat_a.
* configure.in, glib.h: Added two new alloca-based function macros, g_strdup_a and g_strconcat_a. These are stack-based and much faster than their g_malloc-based counterparts. Kudos to Ulrich Drepper for help on this one.
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
Fri Jan 1 17:09:19 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* configure.in, glib.h:
|
||||||
|
Added two new alloca-based function macros, g_strdup_a and
|
||||||
|
g_strconcat_a. These are stack-based and much faster than
|
||||||
|
their g_malloc-based counterparts. Kudos to Ulrich Drepper
|
||||||
|
for help on this one.
|
||||||
|
|
||||||
Wed Dec 30 18:24:57 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
Wed Dec 30 18:24:57 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
* Released GLib 1.1.11
|
* Released GLib 1.1.11
|
||||||
|
@@ -1,3 +1,11 @@
|
|||||||
|
Fri Jan 1 17:09:19 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* configure.in, glib.h:
|
||||||
|
Added two new alloca-based function macros, g_strdup_a and
|
||||||
|
g_strconcat_a. These are stack-based and much faster than
|
||||||
|
their g_malloc-based counterparts. Kudos to Ulrich Drepper
|
||||||
|
for help on this one.
|
||||||
|
|
||||||
Wed Dec 30 18:24:57 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
Wed Dec 30 18:24:57 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
* Released GLib 1.1.11
|
* Released GLib 1.1.11
|
||||||
|
@@ -1,3 +1,11 @@
|
|||||||
|
Fri Jan 1 17:09:19 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* configure.in, glib.h:
|
||||||
|
Added two new alloca-based function macros, g_strdup_a and
|
||||||
|
g_strconcat_a. These are stack-based and much faster than
|
||||||
|
their g_malloc-based counterparts. Kudos to Ulrich Drepper
|
||||||
|
for help on this one.
|
||||||
|
|
||||||
Wed Dec 30 18:24:57 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
Wed Dec 30 18:24:57 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
* Released GLib 1.1.11
|
* Released GLib 1.1.11
|
||||||
|
@@ -1,3 +1,11 @@
|
|||||||
|
Fri Jan 1 17:09:19 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* configure.in, glib.h:
|
||||||
|
Added two new alloca-based function macros, g_strdup_a and
|
||||||
|
g_strconcat_a. These are stack-based and much faster than
|
||||||
|
their g_malloc-based counterparts. Kudos to Ulrich Drepper
|
||||||
|
for help on this one.
|
||||||
|
|
||||||
Wed Dec 30 18:24:57 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
Wed Dec 30 18:24:57 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
* Released GLib 1.1.11
|
* Released GLib 1.1.11
|
||||||
|
@@ -1,3 +1,11 @@
|
|||||||
|
Fri Jan 1 17:09:19 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* configure.in, glib.h:
|
||||||
|
Added two new alloca-based function macros, g_strdup_a and
|
||||||
|
g_strconcat_a. These are stack-based and much faster than
|
||||||
|
their g_malloc-based counterparts. Kudos to Ulrich Drepper
|
||||||
|
for help on this one.
|
||||||
|
|
||||||
Wed Dec 30 18:24:57 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
Wed Dec 30 18:24:57 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
* Released GLib 1.1.11
|
* Released GLib 1.1.11
|
||||||
|
@@ -1,3 +1,11 @@
|
|||||||
|
Fri Jan 1 17:09:19 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* configure.in, glib.h:
|
||||||
|
Added two new alloca-based function macros, g_strdup_a and
|
||||||
|
g_strconcat_a. These are stack-based and much faster than
|
||||||
|
their g_malloc-based counterparts. Kudos to Ulrich Drepper
|
||||||
|
for help on this one.
|
||||||
|
|
||||||
Wed Dec 30 18:24:57 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
Wed Dec 30 18:24:57 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
* Released GLib 1.1.11
|
* Released GLib 1.1.11
|
||||||
|
@@ -1,3 +1,11 @@
|
|||||||
|
Fri Jan 1 17:09:19 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* configure.in, glib.h:
|
||||||
|
Added two new alloca-based function macros, g_strdup_a and
|
||||||
|
g_strconcat_a. These are stack-based and much faster than
|
||||||
|
their g_malloc-based counterparts. Kudos to Ulrich Drepper
|
||||||
|
for help on this one.
|
||||||
|
|
||||||
Wed Dec 30 18:24:57 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
Wed Dec 30 18:24:57 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
* Released GLib 1.1.11
|
* Released GLib 1.1.11
|
||||||
|
@@ -1,3 +1,11 @@
|
|||||||
|
Fri Jan 1 17:09:19 EST 1999 Jeff Garzik <jgarzik@pobox.com>
|
||||||
|
|
||||||
|
* configure.in, glib.h:
|
||||||
|
Added two new alloca-based function macros, g_strdup_a and
|
||||||
|
g_strconcat_a. These are stack-based and much faster than
|
||||||
|
their g_malloc-based counterparts. Kudos to Ulrich Drepper
|
||||||
|
for help on this one.
|
||||||
|
|
||||||
Wed Dec 30 18:24:57 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
Wed Dec 30 18:24:57 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||||
|
|
||||||
* Released GLib 1.1.11
|
* Released GLib 1.1.11
|
||||||
|
47
configure.in
47
configure.in
@@ -168,6 +168,12 @@ AC_HEADER_STDC
|
|||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AC_FUNC_VPRINTF
|
AC_FUNC_VPRINTF
|
||||||
|
AC_FUNC_ALLOCA
|
||||||
|
if test "x$ac_cv_func_alloca_works" = xyes; then
|
||||||
|
glib_have_alloca=yes
|
||||||
|
else
|
||||||
|
glib_have_alloca=no
|
||||||
|
fi
|
||||||
|
|
||||||
AC_CHECK_FUNCS(atexit on_exit)
|
AC_CHECK_FUNCS(atexit on_exit)
|
||||||
|
|
||||||
@@ -245,6 +251,7 @@ AC_CHECK_HEADERS(sys/time.h, AC_DEFINE(HAVE_SYS_TIME_H))
|
|||||||
AC_CHECK_HEADERS(sys/times.h, AC_DEFINE(HAVE_SYS_TIMES_H))
|
AC_CHECK_HEADERS(sys/times.h, AC_DEFINE(HAVE_SYS_TIMES_H))
|
||||||
AC_CHECK_HEADERS(unistd.h, AC_DEFINE(HAVE_UNISTD_H))
|
AC_CHECK_HEADERS(unistd.h, AC_DEFINE(HAVE_UNISTD_H))
|
||||||
AC_CHECK_HEADERS(values.h, AC_DEFINE(HAVE_VALUES_H))
|
AC_CHECK_HEADERS(values.h, AC_DEFINE(HAVE_VALUES_H))
|
||||||
|
AC_CHECK_HEADER(alloca.h, glib_have_alloca_h=yes, glib_have_alloca_h=no)
|
||||||
|
|
||||||
# Check for some functions
|
# Check for some functions
|
||||||
AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf strcasecmp strncasecmp poll)
|
AC_CHECK_FUNCS(lstat strerror strsignal memmove vsnprintf strcasecmp strncasecmp poll)
|
||||||
@@ -866,6 +873,7 @@ _______EOF
|
|||||||
cat >>$outfile <<_______EOF
|
cat >>$outfile <<_______EOF
|
||||||
$glib_atexit
|
$glib_atexit
|
||||||
$glib_memmove
|
$glib_memmove
|
||||||
|
$glib_alloca
|
||||||
$glib_defines
|
$glib_defines
|
||||||
|
|
||||||
$glib_vacopy
|
$glib_vacopy
|
||||||
@@ -1129,6 +1137,45 @@ if test x$glib_working_wctype = xno; then
|
|||||||
#define G_HAVE_BROKEN_WCTYPE 1"
|
#define G_HAVE_BROKEN_WCTYPE 1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if test x$glib_have_alloca = xyes; then
|
||||||
|
glib_alloca="
|
||||||
|
|
||||||
|
/* alloca support */"
|
||||||
|
|
||||||
|
if test x$glib_have_alloca_h = xyes; then
|
||||||
|
glib_alloca="\$glib_alloca
|
||||||
|
#define G_HAVE_ALLOCA_H 1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
glib_alloca="\$glib_alloca
|
||||||
|
#define G_HAVE_ALLOCA 1
|
||||||
|
|
||||||
|
/* BEGIN autoconf 2.13 alloca incantation
|
||||||
|
NOTE: Do not un-indent the #pragma below. */
|
||||||
|
/* AIX requires this to be the first thing in the file. */
|
||||||
|
#ifdef __GNUC__
|
||||||
|
# ifndef alloca
|
||||||
|
# define alloca __builtin_alloca
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
# if G_HAVE_ALLOCA_H
|
||||||
|
# include <alloca.h>
|
||||||
|
# else
|
||||||
|
# ifdef _AIX
|
||||||
|
#pragma alloca
|
||||||
|
# else
|
||||||
|
# ifndef alloca /* predefined by HP cc +Olibcalls */
|
||||||
|
char *alloca ();
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
/* END autoconf 2.13 alloca incantation */
|
||||||
|
|
||||||
|
|
||||||
|
"
|
||||||
|
fi
|
||||||
|
|
||||||
case x$enable_threads in
|
case x$enable_threads in
|
||||||
xyes) g_enable_threads_def="#define";;
|
xyes) g_enable_threads_def="#define";;
|
||||||
*) g_enable_threads_def="#undef ";;
|
*) g_enable_threads_def="#undef ";;
|
||||||
|
31
glib.h
31
glib.h
@@ -1455,6 +1455,37 @@ gchar* g_strescape (gchar *string);
|
|||||||
gpointer g_memdup (gconstpointer mem,
|
gpointer g_memdup (gconstpointer mem,
|
||||||
guint byte_size);
|
guint byte_size);
|
||||||
|
|
||||||
|
/* Macros for dynamic strings via fast stack allocation
|
||||||
|
* All macros take a special first argument: the target gchar* string
|
||||||
|
*/
|
||||||
|
#if G_HAVE_ALLOCA
|
||||||
|
|
||||||
|
# define g_strdup_a(newstr,str) G_STMT_START { \
|
||||||
|
const char *__old = (str); \
|
||||||
|
char *__new; \
|
||||||
|
size_t __len = strlen (__old) + 1; \
|
||||||
|
__new = alloca (__len); \
|
||||||
|
memcpy (__new, __old, __len); \
|
||||||
|
(newstr) = __new; \
|
||||||
|
} G_STMT_END
|
||||||
|
|
||||||
|
# define g_strconcat_a(newstr,str1,str2,str3) G_STMT_START { \
|
||||||
|
size_t __len1 = ((str1) == (gchar*)NULL) ? 0 : strlen((str1)); \
|
||||||
|
size_t __len2 = ((str2) == (gchar*)NULL) ? 0 : strlen((str2)); \
|
||||||
|
size_t __len3 = ((str3) == (gchar*)NULL) ? 0 : strlen((str3)); \
|
||||||
|
char *__sptr, *__new = \
|
||||||
|
alloca (__len1 + __len2 + __len3 + 1); \
|
||||||
|
__sptr = __new; \
|
||||||
|
if (__len1){memcpy (__sptr, (str1), __len1); __sptr += __len1;} \
|
||||||
|
if (__len2){memcpy (__sptr, (str2), __len2); __sptr += __len2;} \
|
||||||
|
if (__len3){memcpy (__sptr, (str3), __len3); __sptr += __len3;} \
|
||||||
|
*__sptr = '\0'; \
|
||||||
|
(newstr) = __new; \
|
||||||
|
} G_STMT_END
|
||||||
|
|
||||||
|
#endif /* G_HAVE_ALLOCA */
|
||||||
|
|
||||||
|
|
||||||
/* NULL terminated string arrays.
|
/* NULL terminated string arrays.
|
||||||
* g_strsplit() splits up string into max_tokens tokens at delim and
|
* g_strsplit() splits up string into max_tokens tokens at delim and
|
||||||
* returns a newly allocated string array.
|
* returns a newly allocated string array.
|
||||||
|
31
glib/glib.h
31
glib/glib.h
@@ -1455,6 +1455,37 @@ gchar* g_strescape (gchar *string);
|
|||||||
gpointer g_memdup (gconstpointer mem,
|
gpointer g_memdup (gconstpointer mem,
|
||||||
guint byte_size);
|
guint byte_size);
|
||||||
|
|
||||||
|
/* Macros for dynamic strings via fast stack allocation
|
||||||
|
* All macros take a special first argument: the target gchar* string
|
||||||
|
*/
|
||||||
|
#if G_HAVE_ALLOCA
|
||||||
|
|
||||||
|
# define g_strdup_a(newstr,str) G_STMT_START { \
|
||||||
|
const char *__old = (str); \
|
||||||
|
char *__new; \
|
||||||
|
size_t __len = strlen (__old) + 1; \
|
||||||
|
__new = alloca (__len); \
|
||||||
|
memcpy (__new, __old, __len); \
|
||||||
|
(newstr) = __new; \
|
||||||
|
} G_STMT_END
|
||||||
|
|
||||||
|
# define g_strconcat_a(newstr,str1,str2,str3) G_STMT_START { \
|
||||||
|
size_t __len1 = ((str1) == (gchar*)NULL) ? 0 : strlen((str1)); \
|
||||||
|
size_t __len2 = ((str2) == (gchar*)NULL) ? 0 : strlen((str2)); \
|
||||||
|
size_t __len3 = ((str3) == (gchar*)NULL) ? 0 : strlen((str3)); \
|
||||||
|
char *__sptr, *__new = \
|
||||||
|
alloca (__len1 + __len2 + __len3 + 1); \
|
||||||
|
__sptr = __new; \
|
||||||
|
if (__len1){memcpy (__sptr, (str1), __len1); __sptr += __len1;} \
|
||||||
|
if (__len2){memcpy (__sptr, (str2), __len2); __sptr += __len2;} \
|
||||||
|
if (__len3){memcpy (__sptr, (str3), __len3); __sptr += __len3;} \
|
||||||
|
*__sptr = '\0'; \
|
||||||
|
(newstr) = __new; \
|
||||||
|
} G_STMT_END
|
||||||
|
|
||||||
|
#endif /* G_HAVE_ALLOCA */
|
||||||
|
|
||||||
|
|
||||||
/* NULL terminated string arrays.
|
/* NULL terminated string arrays.
|
||||||
* g_strsplit() splits up string into max_tokens tokens at delim and
|
* g_strsplit() splits up string into max_tokens tokens at delim and
|
||||||
* returns a newly allocated string array.
|
* returns a newly allocated string array.
|
||||||
|
Reference in New Issue
Block a user