Hi all,

Patch 1728247 is created under recognition where the SIZEOF_LONG_LONG
is defined when a platform has long long type. However the
net-snmp-config.h for MSVC has SIZEOF_LONG_LONG definition even if
MSVC doesn't have long long type.

To match the configure script behavior, it's better to remove the
definition. However, only removing the definition affects
snmplib/snmp_client.c. In case vars->val_len is the system
widest unsinged integer type, truncating integer routine doesn't work.
Then, I add routine for uintmax_t. When running at MSVC, uintmax_t
is defined as __int64 type.

I'd like to call for votes to include it in 5.4.1.

Thank you,
----
Mitsuru Chinen <[EMAIL PROTECTED]>


diff -upr net-snmp-5.4.1.rc1.orig/configure.in net-snmp-5.4.1.rc1/configure.in
--- net-snmp-5.4.1.rc1.orig/configure.in        2007-06-30 13:37:23.000000000 
+0900
+++ net-snmp-5.4.1.rc1/configure.in     2007-07-03 10:49:36.000000000 +0900
@@ -1337,6 +1337,7 @@ AC_CHECK_SIZEOF(short)
 AC_CHECK_SIZEOF(int)
 AC_CHECK_SIZEOF(long)
 AC_CHECK_SIZEOF(long long)
+AC_CHECK_SIZEOF(intmax_t)
 AC_CHECK_TYPES([int8_t,  uint8_t,  u_int8_t])
 AC_CHECK_TYPES([int16_t, uint16_t, u_int16_t])
 AC_CHECK_TYPES([int32_t, uint32_t, u_int32_t])
diff -upr net-snmp-5.4.1.rc1.orig/include/net-snmp/types.h 
net-snmp-5.4.1.rc1/include/net-snmp/types.h
--- net-snmp-5.4.1.rc1.orig/include/net-snmp/types.h    2007-06-11 
07:29:00.000000000 +0900
+++ net-snmp-5.4.1.rc1/include/net-snmp/types.h 2007-07-03 10:49:36.000000000 
+0900
@@ -151,6 +151,7 @@ typedef unsigned int     uint32_t;
 #endif
 #ifdef INT64_T
 typedef INT64_T int64_t;
+#define HAVE_INT64_T 1
 #endif
 #endif /* !HAVE_INT64_T */
 
@@ -160,22 +161,32 @@ typedef u_int64_t        uint64_t;
 #elif defined(INT64_T)
 typedef unsigned INT64_T uint64_t;
 #endif
+#define HAVE_UINT64_T 1
 #endif
 
 #ifndef HAVE_INTMAX_T
 #ifdef SIZEOF_LONG_LONG
 typedef long long intmax_t;
+#define SIZEOF_INTMAX_T SIZEOF_LONG_LONG
+#elif defined(HAVE_INT64_T) && !defined(_INT64_IS_NOT_64BIT)
+typedef int64_t   intmax_t;
+#define SIZEOF_INTMAX_T 8
 #else
 typedef long      intmax_t;
+#define SIZEOF_INTMAX_T SIZEOF_LONG
 #endif
+#define HAVE_INTMAX_T 1
 #endif
 
-#ifndef HAVE_INTMAX_T
+#ifndef HAVE_UINTMAX_T
 #ifdef SIZEOF_LONG_LONG
 typedef unsigned long long uintmax_t;
+#elif defined(HAVE_UINT64_T) && !defined(_INT64_IS_NOT_64BIT)
+typedef uint64_t           uintmax_t;
 #else
 typedef unsigned long      uintmax_t;
 #endif
+#define HAVE_UINTMAX_T 1
 #endif
 
 #ifndef HAVE_UINTPTR_T
diff -upr net-snmp-5.4.1.rc1.orig/snmplib/snmp_client.c 
net-snmp-5.4.1.rc1/snmplib/snmp_client.c
--- net-snmp-5.4.1.rc1.orig/snmplib/snmp_client.c       2007-06-06 
19:13:54.000000000 +0900
+++ net-snmp-5.4.1.rc1/snmplib/snmp_client.c    2007-07-03 10:49:36.000000000 
+0900
@@ -807,16 +807,10 @@ snmp_set_var_value(netsnmp_variable_list
                 }
             }
 #endif
-#if SIZEOF_LONG != SIZEOF_LONG_LONG
-#if defined (WIN32) && !defined (mingw32)
-            else if (vars->val_len == sizeof(__int64)){
-                const unsigned __int64   *val_ullong
-                    = (const unsigned __int64 *) value;
-#else
-                else if (vars->val_len == sizeof(long long)){
+#if defined(SIZEOF_LONG_LONG) && (SIZEOF_LONG != SIZEOF_LONG_LONG) && 
(SIZEOF_LONG_LONG != SIZEOF_INTMAX_T)
+            else if (vars->val_len == sizeof(long long)){
                 const unsigned long long   *val_ullong
                     = (const unsigned long long *) value;
-#endif
                 *(vars->val.integer) = (long) *val_ullong;
                 if (*(vars->val.integer) > 0xffffffff) {
                     snmp_log(LOG_ERR,"truncating integer value > 32 bits\n");
@@ -824,6 +818,17 @@ snmp_set_var_value(netsnmp_variable_list
                 }
             }
 #endif
+#if SIZEOF_LONG != SIZEOF_INTMAX_T
+            else if (vars->val_len == sizeof(intmax_t)){
+                const uintmax_t *val_uintmax_t
+                    = (const uintmax_t *) value;
+                *(vars->val.integer) = (long) *val_uintmax_t;
+                if (*(vars->val.integer) > 0xffffffff) {
+                    snmp_log(LOG_ERR,"truncating integer value > 32 bits\n");
+                    *(vars->val.integer) &= 0xffffffff;
+                }
+            }
+#endif
 #if SIZEOF_SHORT != SIZEOF_INT
             else if (vars->val_len == sizeof(short)) {
                 if (ASN_INTEGER == vars->type) {
diff -upr net-snmp-5.4.1.rc1.orig/win32/net-snmp/net-snmp-config.h 
net-snmp-5.4.1.rc1/win32/net-snmp/net-snmp-config.h
--- net-snmp-5.4.1.rc1.orig/win32/net-snmp/net-snmp-config.h    2007-06-08 
14:16:51.000000000 +0900
+++ net-snmp-5.4.1.rc1/win32/net-snmp/net-snmp-config.h 2007-07-03 
10:49:36.000000000 +0900
@@ -933,9 +933,6 @@
 /* The size of a `long', as computed by sizeof. */
 #define SIZEOF_LONG 4
 
-/* The size of a `long long', as computed by sizeof. */
-#define SIZEOF_LONG_LONG 8
-
 /* The size of a `short', as computed by sizeof. */
 #define SIZEOF_SHORT 2
 
diff -upr net-snmp-5.4.1.rc1.orig/win32/net-snmp/net-snmp-config.h.in 
net-snmp-5.4.1.rc1/win32/net-snmp/net-snmp-config.h.in
--- net-snmp-5.4.1.rc1.orig/win32/net-snmp/net-snmp-config.h.in 2007-06-08 
14:16:51.000000000 +0900
+++ net-snmp-5.4.1.rc1/win32/net-snmp/net-snmp-config.h.in      2007-07-03 
10:49:36.000000000 +0900
@@ -933,9 +933,6 @@
 /* The size of a `long', as computed by sizeof. */
 #define SIZEOF_LONG 4
 
-/* The size of a `long long', as computed by sizeof. */
-#define SIZEOF_LONG_LONG 8
-
 /* The size of a `short', as computed by sizeof. */
 #define SIZEOF_SHORT 2
 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to