From: robertc <> Date: Fri, 9 Aug 2002 16:57:41 +0000 (+0000) Subject: Clean up the squid code to consistenly use [u_]int_t throughout, rather than... X-Git-Tag: SQUID_3_0_PRE1~859 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a924568641a53009f0bea563294f6107dfcca7ca;p=thirdparty%2Fsquid.git Clean up the squid code to consistenly use [u_]int_t throughout, rather than some [u_]num and some [u_]_t instances. This also makes the autoconf 2.5 patch less intrusive, and thus easier to maintain as a long term branch. --- diff --git a/.cvsignore b/.cvsignore index 04290fcd2e..b21545c109 100644 --- a/.cvsignore +++ b/.cvsignore @@ -2,3 +2,4 @@ Makefile config.cache config.log config.status +autom4te.cache diff --git a/ChangeLog b/ChangeLog index ff3a39832d..04bceea75b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ Changes to squid-2.6 (): - 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 (): diff --git a/doc/Programming-Guide/prog-guide.sgml b/doc/Programming-Guide/prog-guide.sgml index cb45cdd724..0f0cf26c10 100644 --- a/doc/Programming-Guide/prog-guide.sgml +++ b/doc/Programming-Guide/prog-guide.sgml @@ -2,7 +2,7 @@
Squid Programmers Guide Squid Developers -$Id: prog-guide.sgml,v 1.50 2002/06/19 06:29:45 hno Exp $ +$Id: prog-guide.sgml,v 1.51 2002/08/09 10:57:41 robertc Exp $ Squid is a WWW Cache application developed by the National Laboratory @@ -64,6 +64,27 @@ or improve it. structures and their members will be written in an italicized font, such as Coding Conventions + +Infrastructure + +

+ Most custom types and tools are documented in the code or the relevant + portions of this manual. Some key points apply globally however. + +Fixed width types +

+ 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". + + int16_t - 16 bit signed. + u_int16_t - 16 bit unsigned. + int32t - 32 bit signed. + u_int32_t - 32 bit unsigned. + int64_t - 64 bit signed. + u_int64_t - 64 bit unsigned. + Overview of Squid Components diff --git a/include/squid_types.h b/include/squid_types.h index 43c94cdf13..134649f016 100644 --- a/include/squid_types.h +++ b/include/squid_types.h @@ -1,5 +1,5 @@ /* - * $Id: squid_types.h,v 1.4 2002/06/17 18:28:13 hno Exp $ + * $Id: squid_types.h,v 1.5 2002/08/09 10:57:42 robertc Exp $ * * * * * * * * * Legal stuff * * * * * * * * @@ -56,6 +56,9 @@ #include "autoconf.h" /* This should be in synch with what we have in acinclude.m4 */ +#if HAVE_SYS_TYPES_H +#include +#endif #if STDC_HEADERS #include #include @@ -63,9 +66,6 @@ #if HAVE_INTTYPES_H #include #endif -#if HAVE_SYS_TYPES_H -#include -#endif #if HAVE_SYS_BITYPES_H #include #endif diff --git a/lib/MemPool.c b/lib/MemPool.c index f2e5d74eb0..daa6bf2254 100644 --- a/lib/MemPool.c +++ b/lib/MemPool.c @@ -1,6 +1,6 @@ /* - * $Id: MemPool.c,v 1.11 2002/04/16 00:33:29 hno Exp $ + * $Id: MemPool.c,v 1.12 2002/08/09 10:57:42 robertc Exp $ * * DEBUG: section 63 Low Level Memory Pool Management * AUTHOR: Alex Rousskov, Andres Kroonmaa @@ -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 -#include "config.h" #if HAVE_STRING_H #include #endif diff --git a/lib/md5.c b/lib/md5.c index 66b84df9f2..4b8322498a 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -1,5 +1,5 @@ /* - * $Id: md5.c,v 1.14 2001/11/21 23:47:12 hno Exp $ + * $Id: md5.c,v 1.15 2002/08/09 10:57:42 robertc Exp $ */ /* taken from RFC-1321/Appendix A.3 */ @@ -30,14 +30,12 @@ * documentation and/or software. */ -#include "config.h" +#include "md5.h" #if HAVE_STRING_H #include #endif -#include "md5.h" - /* * Constants for MD5Transform routine. */ diff --git a/src/CacheDigest.cc b/src/CacheDigest.cc index 90cb5b6fe6..70f9302c70 100644 --- a/src/CacheDigest.cc +++ b/src/CacheDigest.cc @@ -1,6 +1,6 @@ /* - * $Id: CacheDigest.cc,v 1.32 2001/01/12 00:37:13 wessels Exp $ + * $Id: CacheDigest.cc,v 1.33 2002/08/09 10:57:43 robertc Exp $ * * DEBUG: section 70 Cache Digest * AUTHOR: Alex Rousskov @@ -49,7 +49,7 @@ typedef struct { 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) diff --git a/src/acl.cc b/src/acl.cc index ca7da67fd0..cbd2ee3fb1 100644 --- a/src/acl.cc +++ b/src/acl.cc @@ -1,6 +1,6 @@ /* - * $Id: acl.cc,v 1.280 2002/06/23 13:32:23 hno Exp $ + * $Id: acl.cc,v 1.281 2002/08/09 10:57:43 robertc Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -394,7 +394,7 @@ aclParseMethodList(void *curlist) 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 @@ decode_addr(const char *asc, struct in_addr *addr, struct in_addr *mask) 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)) diff --git a/src/fs/aufs/store_dir_aufs.cc b/src/fs/aufs/store_dir_aufs.cc index dd3262cc10..369b1acfdf 100644 --- a/src/fs/aufs/store_dir_aufs.cc +++ b/src/fs/aufs/store_dir_aufs.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_aufs.cc,v 1.47 2002/07/21 00:25:45 hno Exp $ + * $Id: store_dir_aufs.cc,v 1.48 2002/08/09 10:57:44 robertc Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -87,8 +87,8 @@ static StoreEntry *storeAufsDirAddDiskRestore(SwapDir * SD, const cache_key * ke 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 @@ storeAufsDirAddDiskRestore(SwapDir * SD, const cache_key * key, 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; diff --git a/src/fs/coss/store_dir_coss.cc b/src/fs/coss/store_dir_coss.cc index 75e91eac86..011339d3f8 100644 --- a/src/fs/coss/store_dir_coss.cc +++ b/src/fs/coss/store_dir_coss.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_coss.cc,v 1.37 2002/07/21 00:25:45 hno Exp $ + * $Id: store_dir_coss.cc,v 1.38 2002/08/09 10:57:45 robertc Exp $ * * DEBUG: section 47 Store COSS Directory Routines * AUTHOR: Eric Stern @@ -68,8 +68,8 @@ static StoreEntry *storeCossAddDiskRestore(SwapDir * SD, const cache_key * key, 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 @@ storeCossAddDiskRestore(SwapDir * SD, const cache_key * key, 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; diff --git a/src/fs/diskd/store_dir_diskd.cc b/src/fs/diskd/store_dir_diskd.cc index bb56a05ae8..edc64f811c 100644 --- a/src/fs/diskd/store_dir_diskd.cc +++ b/src/fs/diskd/store_dir_diskd.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_diskd.cc,v 1.69 2002/07/21 00:25:46 hno Exp $ + * $Id: store_dir_diskd.cc,v 1.70 2002/08/09 10:57:46 robertc Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -91,8 +91,8 @@ static StoreEntry *storeDiskdDirAddDiskRestore(SwapDir * SD, const cache_key * k 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 @@ storeDiskdDirAddDiskRestore(SwapDir * SD, const cache_key * key, 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; diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index fefe6bcedc..f7ad79d93e 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -1,6 +1,6 @@ /* - * $Id: store_dir_ufs.cc,v 1.47 2002/07/22 00:05:20 hno Exp $ + * $Id: store_dir_ufs.cc,v 1.48 2002/08/09 10:57:46 robertc Exp $ * * DEBUG: section 47 Store Directory Routines * AUTHOR: Duane Wessels @@ -85,8 +85,8 @@ static StoreEntry *storeUfsDirAddDiskRestore(SwapDir * SD, const cache_key * key 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 @@ storeUfsDirAddDiskRestore(SwapDir * SD, const cache_key * key, 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; diff --git a/src/htcp.cc b/src/htcp.cc index 3bcf2c5bef..d422d3d723 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -1,6 +1,6 @@ /* - * $Id: htcp.cc,v 1.40 2002/04/30 07:59:49 hno Exp $ + * $Id: htcp.cc,v 1.41 2002/08/09 10:57:43 robertc Exp $ * * DEBUG: section 31 Hypertext Caching Protocol * AUTHOR: Duane Wesssels @@ -44,18 +44,18 @@ typedef struct _htcpSpecifier htcpSpecifier; 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 @@ struct _htcpDataHeader { 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 @@ struct _htcpDataHeader { /* 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 @@ struct _htcpStuff { int rr; int f1; int response; - u_num32 msg_id; + u_int32_t msg_id; htcpSpecifier S; htcpDetail D; }; @@ -150,7 +150,7 @@ enum { 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 @@ htcpBuildAuth(char *buf, size_t buflen) { 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 @@ htcpBuildAuth(char *buf, size_t buflen) 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 @@ htcpBuildCountstr(char *buf, size_t buflen, const char *s) len = 0; debug(31, 3) ("htcpBuildCountstr: LENGTH = %d\n", len); debug(31, 3) ("htcpBuildCountstr: TEXT = {%s}\n", s ? s : ""); - 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 @@ htcpBuildData(char *buf, size_t buflen, htcpStuff * stuff) 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 @@ htcpBuildPacket(htcpStuff * stuff, ssize_t * len) 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 @@ htcpFreeDetail(htcpDetail * d) 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"); diff --git a/src/icp_v2.cc b/src/icp_v2.cc index 0b633945ec..74774fb9c2 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -1,6 +1,6 @@ /* - * $Id: icp_v2.cc,v 1.66 2001/05/04 13:37:42 hno Exp $ + * $Id: icp_v2.cc,v 1.67 2002/08/09 10:57:43 robertc Exp $ * * DEBUG: section 12 Internet Cache Protocol * AUTHOR: Duane Wessels @@ -97,19 +97,19 @@ icpCreateMessage( 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 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len) 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 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len) 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 @@ icpHandleUdp(int sock, void *data) void icpConnectionsOpen(void) { - u_short port; + u_int16_t port; struct in_addr addr; struct sockaddr_in xaddr; int x; diff --git a/src/icp_v3.cc b/src/icp_v3.cc index 2e9e42bb5a..9eb727f251 100644 --- a/src/icp_v3.cc +++ b/src/icp_v3.cc @@ -1,6 +1,6 @@ /* - * $Id: icp_v3.cc,v 1.33 2001/01/12 00:37:18 wessels Exp $ + * $Id: icp_v3.cc,v 1.34 2002/08/09 10:57:43 robertc Exp $ * * DEBUG: section 12 Internet Cache Protocol * AUTHOR: Duane Wessels @@ -65,7 +65,7 @@ icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len) 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); diff --git a/src/squid.h b/src/squid.h index 060c24770d..5050d505e6 100644 --- a/src/squid.h +++ b/src/squid.h @@ -1,6 +1,6 @@ /* - * $Id: squid.h,v 1.220 2002/05/19 14:32:09 hno Exp $ + * $Id: squid.h,v 1.221 2002/08/09 10:57:43 robertc Exp $ * * AUTHOR: Duane Wessels * @@ -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 #endif diff --git a/src/structs.h b/src/structs.h index 4b6f9c884e..d8ffa169eb 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.422 2002/06/23 14:50:07 hno Exp $ + * $Id: structs.h,v 1.423 2002/08/09 10:57:43 robertc Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1403,10 +1403,10 @@ struct _icp_common_t { 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 _FwdState { struct _htcpReplyData { int hit; HttpHeader hdr; - u_num32 msg_id; + u_int32_t msg_id; double version; struct { /* cache-to-origin */