From patchwork Fri Jun 10 05:17:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Dilger X-Patchwork-Id: 99842 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41CB0B6FE9 for ; Fri, 10 Jun 2011 15:17:21 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751914Ab1FJFRT (ORCPT ); Fri, 10 Jun 2011 01:17:19 -0400 Received: from idcmail-mo1so.shaw.ca ([24.71.223.10]:13324 "EHLO idcmail-mo1so.shaw.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751671Ab1FJFRT (ORCPT ); Fri, 10 Jun 2011 01:17:19 -0400 Received: from pd2ml3so-ssvc.prod.shaw.ca ([10.0.141.148]) by pd4mo1so-svcs.prod.shaw.ca with ESMTP; 09 Jun 2011 23:17:18 -0600 X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=1h8qd3w5pbyJS47frJc7V6h9QwwiBhgsQMy9mbCO+wA= c=1 sm=1 a=0_z88nKC7FwA:10 a=CYDyCxVgLFAA:10 a=BLceEmwcHowA:10 a=c23vf5CSMVc0QQz9B4a6RA==:17 a=ySfo2T4IAAAA:8 a=TXjSo0JJuEB9SryPvJ4A:9 a=aEpeM8dgAnASlkHIeUIA:7 a=axWQYnUQhmgA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Received: from unknown (HELO sookie.dilger.int) ([68.147.195.121]) by pd2ml3so-dmz.prod.shaw.ca with ESMTP; 09 Jun 2011 23:17:18 -0600 From: Andreas Dilger To: tytso@mit.edu, linux-ext4@vger.kernel.org Cc: Andreas Dilger Subject: [PATCH] ext2fs: fix undeclared posix_memalign() warning Date: Thu, 9 Jun 2011 23:17:16 -0600 Message-Id: <1307683036-4564-1-git-send-email-adilger@whamcloud.com> X-Mailer: git-send-email 1.7.3.4 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Older distros do not define posix_memalign() by default in the headers. If ext2fs.h is included early in the headers, it is possible to "#define _XOPEN_SOURCE 600" so that the stdlib.h header will define it, but if ext2fs.h is included after stdlib.h there is no posix_memalign() declaration. Add a posix_memalign() declaration if stdlib.h didn't do it. This is a bit of a hack for GNU headers, but it works on Linux and OS/X without problems. Signed-off-by: Andreas Dilger --- lib/ext2fs/ext2fs.h | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index 9acccf2..975ab9d 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -29,6 +29,10 @@ extern "C" { #define NO_INLINE_FUNCS #endif +#ifndef _XOPEN_SOURCE +#define _XOPEN_SOURCE 600 /* for posix_memalign() */ +#endif + /* * Where the master copy of the superblock is located, and how big * superblocks are supposed to be. We define SUPERBLOCK_SIZE because @@ -37,7 +41,7 @@ extern "C" { * 1032 bytes long). */ #define SUPERBLOCK_OFFSET 1024 -#define SUPERBLOCK_SIZE 1024 +#define SUPERBLOCK_SIZE 1024 /* * The last ext2fs revision level that this version of the library is @@ -54,6 +58,13 @@ extern "C" { #include #include +#ifndef __USE_XOPEN2K +/* If the "#define _XOPEN_SOURCE 600" didn't succeed in declaring + * posix_memalign(), maybe due to or included beforej + * _XOPEN_SOURCE, declare it here to avoid compiler warnings. */ +extern int posix_memalign(void **__memptr, size_t __alignment, size_t __size); +#endif + #if EXT2_FLAT_INCLUDES #include "e2_types.h" #include "ext2_fs.h"