eliminate [u_]num32 types

From: Robert Collins <robertc@dont-contact.us>
Date: 29 Jul 2002 09:47:51 +1000

Any objection my committing the attached to HEAD? It cleans up the squid
code to consistenly use [u_]int<len>_t throughout, rather than some
[u_]num<len> and some [u_]<len>_t instances.

This makes the autoconf 2.5 patch less intrusive, and thus easier to
maintain as a long term branch as well.

Rob

Patch file generated Sun Jul 28 20:45:44 EST 2002 from
CVS branch autoconf-25
CVS repository: rbcollins@cvs.devel.squid-cache.org:/cvsroot/squid
CVS module: squid

Index: squid/.cvsignore
diff -u squid/.cvsignore:1.1 squid/.cvsignore:1.1.72.1
--- squid/.cvsignore:1.1 Wed Oct 10 15:19:49 2001
+++ squid/.cvsignore Wed Jul 24 16:51:20 2002
@@ -5,3 +5,4 @@
 aclocal.m4
 configure
 merge.log
+autom4te.cache
Index: squid/ChangeLog
diff -u squid/ChangeLog:1.29 squid/ChangeLog:1.29.4.1
--- squid/ChangeLog:1.29 Sun Jul 21 14:48:10 2002
+++ squid/ChangeLog Thu Jul 25 04:29:49 2002
@@ -8,6 +8,8 @@
         - http_port is now optional, allowing for SSL only operation
         - Satellite and other high latency peering relations enhancements
           (Robert Cohren)
+ - Nuked num32 types, and made type detection more robust by the
+ use of typedefs rather than #defines.
 
 Changes to squid-2.5 ():
 
Index: squid/doc/Programming-Guide/prog-guide.sgml
diff -u squid/doc/Programming-Guide/prog-guide.sgml:1.20 squid/doc/Programming-Guide/prog-guide.sgml:1.20.4.1
--- squid/doc/Programming-Guide/prog-guide.sgml:1.20 Wed Jun 19 08:57:07 2002
+++ squid/doc/Programming-Guide/prog-guide.sgml Thu Jul 25 04:29:50 2002
@@ -64,6 +64,27 @@
         structures and their members will be written in an italicized
         font, such as <em/StoreEntry/.
 
+<sect>Coding Conventions
+
+<sect1>Infrastructure
+
+ <P>
+ Most custom types and tools are documented in the code or the relevant
+ portions of this manual. Some key points apply globally however.
+
+<sect2>Fixed width types
+ <P>
+ If you need to use specific width types - such as
+ a 16 bit unsigned integer, use one of the following types. To access
+ them simply include "config.h".
+ <enum>
+ <item>int16_t - 16 bit signed.
+ <item>u_int16_t - 16 bit unsigned.
+ <item>int32t - 32 bit signed.
+ <item>u_int32_t - 32 bit unsigned.
+ <item>int64_t - 64 bit signed.
+ <item>u_int64_t - 64 bit unsigned.
+ </enum>
 
 <sect>Overview of Squid Components
 
Index: squid/include/squid_types.h
diff -u squid/include/squid_types.h:1.4 squid/include/squid_types.h:1.4.4.1
--- squid/include/squid_types.h:1.4 Mon Jun 17 14:02:48 2002
+++ squid/include/squid_types.h Thu Jul 25 04:29:51 2002
@@ -56,15 +56,15 @@
 #include "autoconf.h"
 
 /* This should be in synch with what we have in acinclude.m4 */
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
 #if STDC_HEADERS
 #include <stdlib.h>
 #include <stddef.h>
 #endif
 #if HAVE_INTTYPES_H
 #include <inttypes.h>
-#endif
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
 #endif
 #if HAVE_SYS_BITYPES_H
 #include <sys/bitypes.h>
Index: squid/lib/MemPool.c
diff -u squid/lib/MemPool.c:1.6 squid/lib/MemPool.c:1.6.14.2
--- squid/lib/MemPool.c:1.6 Mon Apr 15 18:12:41 2002
+++ squid/lib/MemPool.c Thu Jul 25 05:50:09 2002
@@ -80,12 +80,13 @@
  * Andres Kroonmaa.
  */
 
+#include "config.h"
+
 #define FLUSH_LIMIT 1000 /* Flush memPool counters to memMeters after flush limit calls */
 #define MEM_MAX_MMAP_CHUNKS 2048
 
 #include <assert.h>
 
-#include "config.h"
 #if HAVE_STRING_H
 #include <string.h>
 #endif
Index: squid/lib/md5.c
diff -u squid/lib/md5.c:1.7 squid/lib/md5.c:1.7.30.1
--- squid/lib/md5.c:1.7 Wed Nov 21 15:48:57 2001
+++ squid/lib/md5.c Thu Jul 25 04:29:51 2002
@@ -30,13 +30,11 @@
  * documentation and/or software.
  */
 
-#include "config.h"
+#include "md5.h"
 
 #if HAVE_STRING_H
 #include <string.h>
 #endif
-
-#include "md5.h"
 
 /*
  * Constants for MD5Transform routine.
Index: squid/src/CacheDigest.c
diff -u squid/src/CacheDigest.c:1.4 squid/src/CacheDigest.c:1.4.86.1
--- squid/src/CacheDigest.c:1.4 Fri Jan 12 00:20:31 2001
+++ squid/src/CacheDigest.c Thu Jul 25 04:29:51 2002
@@ -49,7 +49,7 @@
 static void cacheDigestHashKey(const CacheDigest * cd, const cache_key * key);
 
 /* static array used by cacheDigestHashKey for optimization purposes */
-static u_num32 hashed_keys[4];
+static u_int32_t hashed_keys[4];
 
 static void
 cacheDigestInit(CacheDigest * cd, int capacity, int bpe)
Index: squid/src/acl.c
diff -u squid/src/acl.c:1.53 squid/src/acl.c:1.53.4.1
--- squid/src/acl.c:1.53 Sun Jun 23 06:38:03 2002
+++ squid/src/acl.c Thu Jul 25 04:29:51 2002
@@ -394,7 +394,7 @@
 static int
 decode_addr(const char *asc, struct in_addr *addr, struct in_addr *mask)
 {
- u_num32 a;
+ u_int32_t a;
     int a1 = 0, a2 = 0, a3 = 0, a4 = 0;
 
     switch (sscanf(asc, "%d.%d.%d.%d", &a1, &a2, &a3, &a4)) {
@@ -417,7 +417,7 @@
     if (mask != NULL) { /* mask == NULL if called to decode a netmask */
 
         /* Guess netmask */
- a = (u_num32) ntohl(addr->s_addr);
+ a = (u_int32_t) ntohl(addr->s_addr);
         if (!(a & 0xFFFFFFFFul))
             mask->s_addr = htonl(0x00000000ul);
         else if (!(a & 0x00FFFFFF))
Index: squid/src/htcp.c
diff -u squid/src/htcp.c:1.11 squid/src/htcp.c:1.11.6.1
--- squid/src/htcp.c:1.11 Tue Apr 30 14:41:09 2002
+++ squid/src/htcp.c Thu Jul 25 04:29:51 2002
@@ -44,18 +44,18 @@
 typedef struct _htcpDetail htcpDetail;
 
 struct _Countstr {
- u_short length;
+ u_int16_t length;
     char *text;
 };
 
 struct _htcpHeader {
- u_short length;
+ u_int16_t length;
     u_char major;
     u_char minor;
 };
 
 struct _htcpDataHeader {
- u_short length;
+ u_int16_t length;
 #if !WORDS_BIGENDIAN
     unsigned int opcode:4;
     unsigned int response:4;
@@ -72,7 +72,7 @@
     unsigned int F1:1;
     unsigned int reserved:6;
 #endif
- u_num32 msg_id;
+ u_int32_t msg_id;
 };
 
     /* RR == 0 --> F1 = RESPONSE DESIRED FLAG */
@@ -81,7 +81,7 @@
     /* RR == 1 --> RESPONSE */
 
 struct _htcpAuthHeader {
- u_short length;
+ u_int16_t length;
     time_t sig_time;
     time_t sig_expire;
     Countstr key_name;
@@ -106,7 +106,7 @@
     int rr;
     int f1;
     int response;
- u_num32 msg_id;
+ u_int32_t msg_id;
     htcpSpecifier S;
     htcpDetail D;
 };
@@ -150,7 +150,7 @@
     RR_RESPONSE
 };
 
-static u_num32 msg_id_counter = 0;
+static u_int32_t msg_id_counter = 0;
 static int htcpInSocket = -1;
 static int htcpOutSocket = -1;
 #define N_QUERIED_KEYS 256
@@ -214,7 +214,7 @@
 {
     htcpAuthHeader auth;
     size_t copy_sz = 0;
- assert(2 == sizeof(u_short));
+ assert(2 == sizeof(u_int16_t));
     auth.length = htons(2);
     copy_sz += 2;
     assert(buflen >= copy_sz);
@@ -225,7 +225,7 @@
 static ssize_t
 htcpBuildCountstr(char *buf, size_t buflen, const char *s)
 {
- u_short length;
+ u_int16_t length;
     size_t len;
     off_t off = 0;
     if (buflen - off < 2)
@@ -236,7 +236,7 @@
         len = 0;
     debug(31, 3) ("htcpBuildCountstr: LENGTH = %d\n", len);
     debug(31, 3) ("htcpBuildCountstr: TEXT = {%s}\n", s ? s : "<NULL>");
- length = htons((u_short) len);
+ length = htons((u_int16_t) len);
     xmemcpy(buf + off, &length, 2);
     off += 2;
     if (buflen - off < len)
@@ -344,7 +344,7 @@
         return op_data_sz;
     off += op_data_sz;
     debug(31, 3) ("htcpBuildData: hdr.length = %d\n", (int) off);
- hdr.length = (u_short) off;
+ hdr.length = (u_int16_t) off;
     hdr.opcode = stuff->op;
     hdr.response = stuff->response;
     hdr.RR = stuff->rr;
@@ -385,7 +385,7 @@
         return NULL;
     }
     off += s;
- hdr.length = htons((u_short) off);
+ hdr.length = htons((u_int16_t) off);
     hdr.major = 0;
     hdr.minor = 0;
     xmemcpy(buf, &hdr, hdr_sz);
@@ -436,7 +436,7 @@
 static int
 htcpUnpackCountstr(char *buf, int sz, char **str)
 {
- u_short l;
+ u_int16_t l;
     debug(31, 3) ("htcpUnpackCountstr: sz = %d\n", sz);
     if (sz < 2) {
         debug(31, 3) ("htcpUnpackCountstr: sz < 2\n");
Index: squid/src/icp_v2.c
diff -u squid/src/icp_v2.c:1.5 squid/src/icp_v2.c:1.5.44.1
--- squid/src/icp_v2.c:1.5 Fri May 4 06:39:12 2001
+++ squid/src/icp_v2.c Thu Jul 25 04:29:51 2002
@@ -97,19 +97,19 @@
     int buf_len;
     buf_len = sizeof(icp_common_t) + strlen(url) + 1;
     if (opcode == ICP_QUERY)
- buf_len += sizeof(u_num32);
+ buf_len += sizeof(u_int32_t);
     buf = xcalloc(buf_len, 1);
     headerp = (icp_common_t *) (void *) buf;
     headerp->opcode = (char) opcode;
     headerp->version = ICP_VERSION_CURRENT;
- headerp->length = (u_short) htons(buf_len);
+ headerp->length = (u_int16_t) htons(buf_len);
     headerp->reqnum = htonl(reqnum);
     headerp->flags = htonl(flags);
     headerp->pad = htonl(pad);
     headerp->shostid = theOutICPAddr.s_addr;
     urloffset = buf + sizeof(icp_common_t);
     if (opcode == ICP_QUERY)
- urloffset += sizeof(u_num32);
+ urloffset += sizeof(u_int32_t);
     xmemcpy(urloffset, url, strlen(url));
     return buf;
 }
@@ -190,7 +190,7 @@
     aclCheck_t checklist;
     icp_common_t *reply;
     int src_rtt = 0;
- u_num32 flags = 0;
+ u_int32_t flags = 0;
     int rtt = 0;
     int hops = 0;
     xmemcpy(&header, buf, sizeof(icp_common_t));
@@ -211,7 +211,7 @@
     switch (header.opcode) {
     case ICP_QUERY:
         /* We have a valid packet */
- url = buf + sizeof(icp_common_t) + sizeof(u_num32);
+ url = buf + sizeof(icp_common_t) + sizeof(u_int32_t);
         if (strpbrk(url, w_space)) {
             url = rfc1738_escape(url);
             reply = icpCreateMessage(ICP_ERR, 0, url, header.reqnum, 0);
@@ -401,7 +401,7 @@
 void
 icpConnectionsOpen(void)
 {
- u_short port;
+ u_int16_t port;
     struct in_addr addr;
     struct sockaddr_in xaddr;
     int x;
Index: squid/src/icp_v3.c
diff -u squid/src/icp_v3.c:1.4 squid/src/icp_v3.c:1.4.86.1
--- squid/src/icp_v3.c:1.4 Fri Jan 12 00:20:33 2001
+++ squid/src/icp_v3.c Thu Jul 25 04:29:51 2002
@@ -65,7 +65,7 @@
     switch (header.opcode) {
     case ICP_QUERY:
         /* We have a valid packet */
- url = buf + sizeof(icp_common_t) + sizeof(u_num32);
+ url = buf + sizeof(icp_common_t) + sizeof(u_int32_t);
         if (strpbrk(url, w_space)) {
             url = rfc1738_escape(url);
             reply = icpCreateMessage(ICP_ERR, 0, url, header.reqnum, 0);
Index: squid/src/squid.h
diff -u squid/src/squid.h:1.17 squid/src/squid.h:1.17.6.1
--- squid/src/squid.h:1.17 Sun May 19 18:02:23 2002
+++ squid/src/squid.h Thu Jul 25 04:29:51 2002
@@ -103,12 +103,6 @@
 #define assert(EX) ((EX)?((void)0):xassert("EX", __FILE__, __LINE__))
 #endif
 
-
-/* 32 bit integer compatability */
-#include "squid_types.h"
-#define num32 int32_t
-#define u_num32 u_int32_t
-
 #if HAVE_UNISTD_H
 #include <unistd.h>
 #endif
Index: squid/src/structs.h
diff -u squid/src/structs.h:1.61 squid/src/structs.h:1.61.4.1
--- squid/src/structs.h:1.61 Sun Jun 23 07:57:13 2002
+++ squid/src/structs.h Thu Jul 25 04:29:51 2002
@@ -1403,10 +1403,10 @@
     unsigned char opcode; /* opcode */
     unsigned char version; /* version number */
     unsigned short length; /* total length (bytes) */
- u_num32 reqnum; /* req number (req'd for UDP) */
- u_num32 flags;
- u_num32 pad;
- u_num32 shostid; /* sender host id */
+ u_int32_t reqnum; /* req number (req'd for UDP) */
+ u_int32_t flags;
+ u_int32_t pad;
+ u_int32_t shostid; /* sender host id */
 };
 
 struct _iostats {
@@ -1967,7 +1967,7 @@
 struct _htcpReplyData {
     int hit;
     HttpHeader hdr;
- u_num32 msg_id;
+ u_int32_t msg_id;
     double version;
     struct {
         /* cache-to-origin */
Index: squid/src/fs/aufs/store_dir_aufs.c
diff -u squid/src/fs/aufs/store_dir_aufs.c:1.30 squid/src/fs/aufs/store_dir_aufs.c:1.30.4.1
--- squid/src/fs/aufs/store_dir_aufs.c:1.30 Sat Jul 20 18:06:08 2002
+++ squid/src/fs/aufs/store_dir_aufs.c Thu Jul 25 04:29:52 2002
@@ -87,8 +87,8 @@
     time_t timestamp,
     time_t lastref,
     time_t lastmod,
- u_num32 refcount,
- u_short flags,
+ u_int32_t refcount,
+ u_int16_t flags,
     int clean);
 static void storeAufsDirRebuild(SwapDir * sd);
 static void storeAufsDirCloseTmpSwapLog(SwapDir * sd);
@@ -783,8 +783,8 @@
     time_t timestamp,
     time_t lastref,
     time_t lastmod,
- u_num32 refcount,
- u_short flags,
+ u_int32_t refcount,
+ u_int16_t flags,
     int clean)
 {
     StoreEntry *e = NULL;
Index: squid/src/fs/coss/store_dir_coss.c
diff -u squid/src/fs/coss/store_dir_coss.c:1.23 squid/src/fs/coss/store_dir_coss.c:1.23.4.1
--- squid/src/fs/coss/store_dir_coss.c:1.23 Sat Jul 20 18:06:10 2002
+++ squid/src/fs/coss/store_dir_coss.c Thu Jul 25 04:29:52 2002
@@ -68,8 +68,8 @@
     time_t timestamp,
     time_t lastref,
     time_t lastmod,
- u_num32 refcount,
- u_short flags,
+ u_int32_t refcount,
+ u_int16_t flags,
     int clean);
 static void storeCossDirRebuild(SwapDir * sd);
 static void storeCossDirCloseTmpSwapLog(SwapDir * sd);
@@ -305,8 +305,8 @@
     time_t timestamp,
     time_t lastref,
     time_t lastmod,
- u_num32 refcount,
- u_short flags,
+ u_int32_t refcount,
+ u_int16_t flags,
     int clean)
 {
     StoreEntry *e = NULL;
Index: squid/src/fs/diskd/store_dir_diskd.c
diff -u squid/src/fs/diskd/store_dir_diskd.c:1.41 squid/src/fs/diskd/store_dir_diskd.c:1.41.4.1
--- squid/src/fs/diskd/store_dir_diskd.c:1.41 Sat Jul 20 18:06:10 2002
+++ squid/src/fs/diskd/store_dir_diskd.c Thu Jul 25 04:29:52 2002
@@ -91,8 +91,8 @@
     time_t timestamp,
     time_t lastref,
     time_t lastmod,
- u_num32 refcount,
- u_short flags,
+ u_int32_t refcount,
+ u_int16_t flags,
     int clean);
 static void storeDiskdDirRebuild(SwapDir * sd);
 static void storeDiskdDirCloseTmpSwapLog(SwapDir * sd);
@@ -970,8 +970,8 @@
     time_t timestamp,
     time_t lastref,
     time_t lastmod,
- u_num32 refcount,
- u_short flags,
+ u_int32_t refcount,
+ u_int16_t flags,
     int clean)
 {
     StoreEntry *e = NULL;
Index: squid/src/fs/ufs/store_dir_ufs.c
diff -u squid/src/fs/ufs/store_dir_ufs.c:1.29 squid/src/fs/ufs/store_dir_ufs.c:1.29.4.1
--- squid/src/fs/ufs/store_dir_ufs.c:1.29 Sun Jul 21 19:08:11 2002
+++ squid/src/fs/ufs/store_dir_ufs.c Thu Jul 25 04:29:52 2002
@@ -85,8 +85,8 @@
     time_t timestamp,
     time_t lastref,
     time_t lastmod,
- u_num32 refcount,
- u_short flags,
+ u_int32_t refcount,
+ u_int16_t flags,
     int clean);
 static void storeUfsDirRebuild(SwapDir * sd);
 static void storeUfsDirCloseTmpSwapLog(SwapDir * sd);
@@ -782,8 +782,8 @@
     time_t timestamp,
     time_t lastref,
     time_t lastmod,
- u_num32 refcount,
- u_short flags,
+ u_int32_t refcount,
+ u_int16_t flags,
     int clean)
 {
     StoreEntry *e = NULL;

Received on Sun Jul 28 2002 - 17:47:55 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:15:54 MST