changeset 678:1e5c655bad25 HEAD

Renamed largest_t to uintmax_t which already exists in C99.
author Timo Sirainen <tss@iki.fi>
date Tue, 26 Nov 2002 15:07:53 +0200
parents 3089685bbb7e
children 78966c511e57
files acconfig.h configure.in src/imap/mail-storage-callbacks.c src/lib-index/mbox/mbox-rewrite.c src/lib-storage/index/index-search.c src/lib/compat.h src/lib/hostpid.c src/lib/lib.h src/lib/strfuncs.c src/lib/strfuncs.h
diffstat 10 files changed, 51 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/acconfig.h	Tue Nov 26 14:28:11 2002 +0200
+++ b/acconfig.h	Tue Nov 26 15:07:53 2002 +0200
@@ -63,9 +63,11 @@
 /* printf()-format for size_t, eg. "u" or "llu" */
 #undef PRIuSIZE_T
 
-/* What type should be used for largest_t */
-#undef LARGEST_T_LONG
-#undef LARGEST_T_LONG_LONG
+/* Define if you have uintmax_t (C99 type) */
+#undef HAVE_UINTMAX_T
+
+/* Define if you have socklen_t */
+#undef HAVE_SOCKLEN_T
 
 /* Define if you have Linux-compatible mremap() */
 #undef HAVE_LINUX_MREMAP
--- a/configure.in	Tue Nov 26 14:28:11 2002 +0200
+++ b/configure.in	Tue Nov 26 15:07:53 2002 +0200
@@ -13,7 +13,7 @@
 AC_ARG_PROGRAM
 AM_PROG_LIBTOOL
 
-AC_CHECK_HEADERS(string.h stdlib.h unistd.h dirent.h)
+AC_CHECK_HEADERS(string.h stdlib.h stdint.h unistd.h dirent.h)
 AC_CHECK_HEADERS(sys/uio.h iconv.h linux/mman.h)
 
 # check posix headers
@@ -164,6 +164,9 @@
 	AC_DEFINE(IOLOOP_SELECT)
 ])
 
+dnl * memory alignment
+AC_DEFINE_UNQUOTED(MEM_ALIGN_SIZE, $mem_align)
+
 dnl * gcc specific options
 if test "x$ac_cv_prog_gcc" = "xyes"; then
 	# -Wchar-subscripts -Wpointer-arith -Wcast-qual -Wcast-align -Wconversion -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
@@ -293,30 +296,28 @@
     ;;
 esac
 
-if test x$ac_cv_sizeof_long_long != x0; then
-  AC_DEFINE(LARGEST_T_LONG_LONG)
-else
-  AC_DEFINE(LARGEST_T_LONG)
+AC_DEFUN(AC_CHECKTYPE2, [
+  AC_MSG_CHECKING([for $1])
+  AC_CACHE_VAL(i_cv_type_$1,
+  [AC_TRY_COMPILE([
+  #include <sys/types.h>
+  $2],
+  [$1 t;],
+  i_cv_type_$1=yes,
+  i_cv_type_$1=no,
+  )])
+  AC_MSG_RESULT($i_cv_type_$1)
+])
+
+AC_CHECKTYPE2(uintmax_t, [#include <stdint.h>])
+if test $i_cv_type_uintmax_t = yes; then
+  AC_DEFINE(HAVE_UINTMAX_T)
 fi
 
-dnl * memory alignment
-AC_DEFINE_UNQUOTED(MEM_ALIGN_SIZE, $mem_align)
-
-dnl * socklen_t - AC_CHECK_TYPE() would be _really_ useful if it only would
-dnl * accept header files where to find the typedef..
-AC_MSG_CHECKING([for socklen_t])
-AC_CACHE_VAL(i_cv_type_socklen_t,
-[AC_TRY_COMPILE([
-#include <sys/types.h>
-#include <sys/socket.h>],
-[socklen_t t;],
-i_cv_type_socklen_t=yes,
-i_cv_type_socklen_t=no,
-)])
-if test $i_cv_type_socklen_t = no; then
-	AC_DEFINE(socklen_t, int, Define to 'int' if <sys/socket.h> doesn't define.)
+AC_CHECKTYPE2(socklen_t, [#include <sys/socket.h>])
+if test $i_cv_type_socklen_t = yes; then
+  AC_DEFINE(HAVE_SOCKLEN_T)
 fi
-AC_MSG_RESULT($i_cv_type_socklen_t)
 
 dnl * do we have tm_gmtoff
 AC_MSG_CHECKING([for tm_gmtoff])
--- a/src/imap/mail-storage-callbacks.c	Tue Nov 26 14:28:11 2002 +0200
+++ b/src/imap/mail-storage-callbacks.c	Tue Nov 26 15:07:53 2002 +0200
@@ -34,7 +34,7 @@
 static void expunge(Mailbox *mailbox, unsigned int seq, void *context)
 {
 	Client *client = context;
-	char str[MAX_LARGEST_T_STRLEN+20];
+	char str[MAX_INT_STRLEN+20];
 
 	if (client->mailbox != mailbox)
 		return;
@@ -71,7 +71,7 @@
 			 unsigned int recent_count, void *context)
 {
 	Client *client = context;
-	char str[MAX_LARGEST_T_STRLEN+20];
+	char str[MAX_INT_STRLEN+20];
 
 	if (client->mailbox != mailbox)
 		return;
--- a/src/lib-index/mbox/mbox-rewrite.c	Tue Nov 26 14:28:11 2002 +0200
+++ b/src/lib-index/mbox/mbox-rewrite.c	Tue Nov 26 15:07:53 2002 +0200
@@ -185,7 +185,7 @@
 
 static int mbox_write_content_length(MboxRewriteContext *ctx)
 {
-	char str[MAX_LARGEST_T_STRLEN+30];
+	char str[MAX_INT_STRLEN+30];
 
 	i_snprintf(str, sizeof(str), "Content-Length: %"PRIuUOFF_T"\n",
 		   ctx->content_length);
--- a/src/lib-storage/index/index-search.c	Tue Nov 26 14:28:11 2002 +0200
+++ b/src/lib-storage/index/index-search.c	Tue Nov 26 15:07:53 2002 +0200
@@ -758,7 +758,7 @@
         MailSearchArg *arg;
 	const ModifyLogExpunge *expunges;
 	unsigned int first_uid, last_uid, client_seq, expunges_before;
-	char num[MAX_LARGEST_T_STRLEN+10];
+	char num[MAX_INT_STRLEN+10];
 	int found, failed;
 
 	if (ibox->synced_messages_count == 0)
--- a/src/lib/compat.h	Tue Nov 26 14:28:11 2002 +0200
+++ b/src/lib/compat.h	Tue Nov 26 15:07:53 2002 +0200
@@ -17,12 +17,16 @@
 #  error uoff_t size not set
 #endif
 
-#if defined (LARGEST_T_LONG)
-typedef unsigned long largest_t;
-#elif defined (LARGEST_T_LONG_LONG)
-typedef unsigned long long largest_t;
-#else
-#  error largest_t size not set
+#ifndef HAVE_UINTMAX_T
+#  if SIZEOF_LONG_LONG > 0
+typedef unsigned long long uintmax_t;
+#  else
+typedef unsigned long uintmax_t;
+#  endif
+#endif
+
+#ifndef HAVE_SOCKLEN_T
+typedef int socklen_t;
 #endif
 
 /* memmove() */
--- a/src/lib/hostpid.c	Tue Nov 26 14:28:11 2002 +0200
+++ b/src/lib/hostpid.c	Tue Nov 26 15:07:53 2002 +0200
@@ -33,7 +33,7 @@
 
 void hostpid_init(void)
 {
-	static char hostname[256], pid[MAX_LARGEST_T_STRLEN];
+	static char hostname[256], pid[MAX_INT_STRLEN];
 
 	if (my_hostname == NULL) {
 		hostname[sizeof(hostname)-1] = '\0';
--- a/src/lib/lib.h	Tue Nov 26 14:28:11 2002 +0200
+++ b/src/lib/lib.h	Tue Nov 26 15:07:53 2002 +0200
@@ -13,6 +13,10 @@
 #include <errno.h> /* error checking is good */
 #include <sys/types.h> /* many other includes want this */
 
+#ifdef HAVE_STDINT_H
+#  include <stdint.h> /* C99 int types, we mostly need uintmax_t */
+#endif
+
 typedef struct _IOLoop *IOLoop;
 typedef struct _IO *IO;
 typedef struct _Timeout *Timeout;
--- a/src/lib/strfuncs.c	Tue Nov 26 14:28:11 2002 +0200
+++ b/src/lib/strfuncs.c	Tue Nov 26 15:07:53 2002 +0200
@@ -883,7 +883,7 @@
 }
 
 static size_t dec2str_recurse(char *buffer, size_t pos, size_t size,
-			      largest_t number)
+			      uintmax_t number)
 {
 	if (number == 0)
 		return 0;
@@ -894,7 +894,7 @@
 	return pos + 1;
 }
 
-void dec2str(char *buffer, size_t size, largest_t number)
+void dec2str(char *buffer, size_t size, uintmax_t number)
 {
 	size_t pos;
 
--- a/src/lib/strfuncs.h	Tue Nov 26 14:28:11 2002 +0200
+++ b/src/lib/strfuncs.h	Tue Nov 26 15:07:53 2002 +0200
@@ -55,8 +55,8 @@
 const char *t_strjoin_replace(char *const args[], char separator,
 			      int replacearg, const char *replacedata);
 
-#define MAX_LARGEST_T_STRLEN ((sizeof(largest_t) * CHAR_BIT + 2) / 3 + 1)
-void dec2str(char *buffer, size_t size, largest_t number);
+#define MAX_INT_STRLEN ((sizeof(uintmax_t) * CHAR_BIT + 2) / 3 + 1)
+void dec2str(char *buffer, size_t size, uintmax_t number);
 
 /* INTERNAL */
 const char *temp_strconcat(const char *str1, va_list args, size_t *ret_len);