View Issue Details

IDProjectCategoryView StatusLast Update
0001631libmicrohttpdportabilitypublic2010-12-25 23:22
Reporterbplant Assigned ToChristian Grothoff  
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionfixed 
Summary0001631: Type long long isn't supported by all printfs
DescriptionI'm attempting to use libmicrohttp on the ARM cortex m3 with the IAR compiler. The IAR printf doesn't support %llu in the format string. The attached patch allows the long long type to be replaced with just the long type or even a short by adding the following #defines to platform.h:

#define LONG_LONG long
#define LONG_LONG_PRINTF l
TagsNo tags attached.
Attached Files
long_long.patch (2,720 bytes)   
Index: src/daemon/connection.c
===================================================================
--- src/daemon/connection.c	(revision 550)
+++ src/daemon/connection.c	(working copy)
@@ -526,8 +526,8 @@
                                             MHD_HTTP_HEADER_CONTENT_LENGTH))
     {
       SPRINTF (buf,
-               "%llu",
-	       (unsigned long long)connection->response->total_size);
+               "%" LONG_LONG_PRINTF "u",
+	       (unsigned LONG_LONG)connection->response->total_size);
       MHD_add_response_header (connection->response,
                                MHD_HTTP_HEADER_CONTENT_LENGTH, buf);
     }
@@ -1641,7 +1641,7 @@
 parse_connection_headers (struct MHD_Connection *connection)
 {
   const char *clen;
-  unsigned long long cval;
+  unsigned LONG_LONG cval;
   struct MHD_Response *response;
   const char *enc;
 
@@ -1675,7 +1675,7 @@
                                       MHD_HTTP_HEADER_CONTENT_LENGTH);
   if (clen != NULL)
     {
-      if (1 != SSCANF (clen, "%llu", &cval))
+      if (1 != SSCANF (clen, "%" LONG_LONG_PRINTF "u", &cval))
         {
 #if HAVE_MESSAGES
           MHD_DLOG (connection->daemon,
Index: src/daemon/daemon.c
===================================================================
--- src/daemon/daemon.c	(revision 550)
+++ src/daemon/daemon.c	(working copy)
@@ -1042,7 +1042,7 @@
  *        necessiate the use of a timeout right now).
  */
 int
-MHD_get_timeout (struct MHD_Daemon *daemon, unsigned long long *timeout)
+MHD_get_timeout (struct MHD_Daemon *daemon, unsigned LONG_LONG *timeout)
 {
   time_t earliest_deadline;
   time_t now;
@@ -1094,7 +1094,7 @@
   fd_set es;
   int max;
   struct timeval timeout;
-  unsigned long long ltimeout;
+  unsigned LONG_LONG ltimeout;
   int ds;
 
   timeout.tv_sec = 0;
Index: src/include/microhttpd.h
===================================================================
--- src/include/microhttpd.h	(revision 550)
+++ src/include/microhttpd.h	(working copy)
@@ -141,6 +141,17 @@
 #define MHD_CONTENT_READER_END_WITH_ERROR (((size_t) -1LL) - 1)
 #endif
 
+/**
+ * Not all architectures and printf's support the long long type.
+ * This gives the ability to replace long long with just a long,
+ * standard int or a short.
+ */
+#ifndef LONG_LONG
+#define LONG_LONG long long
+#endif
+#ifndef LONG_LONG_PRINTF
+#define LONG_LONG_PRITNF ll
+#endif
 
 /**
  * HTTP response codes.
@@ -1027,7 +1038,7 @@
  *        not used (or no connections exist that would
  *        necessiate the use of a timeout right now).
  */
-int MHD_get_timeout (struct MHD_Daemon *daemon, unsigned long long *timeout);
+int MHD_get_timeout (struct MHD_Daemon *daemon, unsigned LONG_LONG *timeout);
 
 
 /**
long_long.patch (2,720 bytes)   

Activities

Christian Grothoff

2010-12-20 21:25

manager   ~0004210

Committed as SVN #13950 (with additional updates to documentation, comments, testcases and typo correction).

Issue History

Date Modified Username Field Change
2010-12-14 11:00 bplant New Issue
2010-12-14 11:00 bplant File Added: long_long.patch
2010-12-20 21:25 Christian Grothoff Note Added: 0004210
2010-12-20 21:25 Christian Grothoff Status new => resolved
2010-12-20 21:25 Christian Grothoff Resolution open => fixed
2010-12-20 21:25 Christian Grothoff Assigned To => Christian Grothoff
2010-12-25 23:22 Christian Grothoff Status resolved => closed