[milters] Archive

Lists Index Date Thread Search

Article: 707
From: Anthony Howe
Date: 2005-08-27 12:51:38 -0400
Subject: Re: libsnert/milter-ahead on AMD64

Removal...........: milters-request@milter.info?subject=remove
More information..: http://www.milter.info/#Support
--------------------------------------------------------

Kevin Rosenberg wrote:
>>I've also just noticed that OpenBSD 3.6, which I use as a reference 
>>[...]
>>      inet_ntop(int af, const void *src, char *dst, size_t size);
>>while the Single Unix Specification Version 3 defines:
>>      const char *inet_ntop(int af, const void *restrict src,
>>	 char *restrict dst, socklen_t size);
> 
> 
> Ugh, indeed. I'd say that the OpenBSD definition is broken, unless
>   1. they really want network addresses longer than 4GB on 64-bit
>   systems
> or,
>   2. they want to limit size_t (one definition being "a type to define
>   sizes of strings and memory blocks") to 32-bits on 64-bit systems

Actually OpenBSD is wrong for not following the SUSv3, but correct in 
following the BSD standards and correct in that the size argument 
denotes the size of the dst argument, which is a chunk of memory to 
store the printable version of the address. The socklen_t is actually 
misleading and misapplied here I think.

Also the ANSI C89 standard states that:

	size_t is the unsigned integral type returned by the
	sizeof operator.

Therefore size_t should be able to represent the size of the largest 
possible memory chunk, since:

	void *malloc(size_t size)

Now I'm surprised that sizeof (size_t) != sizeof (socklen_t), because 
they both describe the size of memory objects. Someone else has provided 
me with an AMD 64 Gentoo account and the following test shows

	sizeof (size_t) > sizeof (socklen_t)

achowe@kali$ cat x.c
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>

int main(int argc, char **argv)
{
         printf("%d %d\n", sizeof (size_t), sizeof (socklen_t));

         return 0;
}
achowe@kali$ ./a.out
8 4

Which is counter intuitive.

Anyways. There are indeed several isses related to the size of a "long" 
type on AMD 64, which is 8 bytes instead of 4. I think I've always 
understand teh C standard to define char as 8 bits, short as 16, long as 
32, and the common type extension "long long" as 64.

Anyways, because of this I've already fixed Dns.c and I'm going through 
some of the other LibSnert functions making corrections concerning AMD 64.

-- 
Anthony C Howe                                 +33 6 11 89 73 78
http://www.snert.com/       ICQ:
7116561         AIM: Sir Wumpus

Sendmail Anti-Spam Solutions           http://www.snertsoft.com/
                                             We Serve Your Server

Lists Index Date Thread Search