From owner-freebsd-hackers@FreeBSD.ORG Tue May 31 23:07:32 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 39E7C1065670 for ; Tue, 31 May 2011 23:07:32 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id C56608FC08 for ; Tue, 31 May 2011 23:07:31 +0000 (UTC) Received: by wyf23 with SMTP id 23so5012303wyf.13 for ; Tue, 31 May 2011 16:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:date:x-google-sender-auth :message-id:subject:from:to:content-type; bh=0fJJrJeEiLX9xxDrS0BHyoCA0IXpn2PRvGikxdjLHFc=; b=QqnceRi6/CTb+JAOni/hTq4kyJz97v/SdVu9474ZfpDpeJJv5x8bchPKUPr1BNzN8r YNs7QpHFfJugxCj2jtgwftIttx3fJbwMLNuSN+XSOxLmib+BJjlMMpjpyFg1JXeAn2iI fGcKR20xUUG8o0ElT71GfUVhOD7mx+hmLSfBg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=RzFfqgkFkrUXStgjCys9r46JHIQCnII6bUQnX+eihERwcdxU8RxazKwMOpedrWBc1/ 7ouue1WPfiZXtydM6spBjjhvujkd8YHOaNO8H9MEKTW8aUQm2qYTFJHyHQa/k01re8Pu vT3WbP0NrYuSdlF2oLLbaM8y8pLHqwM6X0yJM= MIME-Version: 1.0 Received: by 10.216.221.158 with SMTP id r30mr4234207wep.50.1306883249998; Tue, 31 May 2011 16:07:29 -0700 (PDT) Sender: mdf356@gmail.com Received: by 10.216.93.193 with HTTP; Tue, 31 May 2011 16:07:29 -0700 (PDT) Date: Tue, 31 May 2011 16:07:29 -0700 X-Google-Sender-Auth: qVe6tI0JN3lDWH5oujhYOTEMak8 Message-ID: From: mdf@FreeBSD.org To: freebsd-hackers , Bruce Evans Content-Type: text/plain; charset=ISO-8859-1 Cc: Subject: sizeof(function pointer) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 May 2011 23:07:32 -0000 I am looking into potentially MFC'ing r212367 and related, that adds drains to sbufs. The reason for MFC is that several pieces of new code in CURRENT are using the drain functionality and it would make MFCing those changes much easier. The problem is that r212367 added a pointer to a drain function in the sbuf (it replaced a pointer to void). The C standard doesn't guarantee that a void * and a function pointer have the same size, though its true on amd64, i386 and I believe PPC. What I'm wondering is, though not guaranteed by the standard, is it *practically* true that sizeof(void *) == sizeof(int(*)(void)), such that an MFC won't break binary compatibility for any supported architecture? (The standard does guarantee, though not in words, that all function pointers have the same size, since it guarantees that pointers to functions can be cast to other pointers to functions and back without changing the value). Another possibility is to malloc a blob that is sizeof(int(*)(void)) and store that in a renamed s_unused; this is a bit messier but guaranteed to work. I'd just rather the code be an MCF instead of a partial re-write. Thanks, matthew