All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Andy Lutomirski <luto@amacapital.net>, Kui Zhang <kuizhang@gmail.com>
Cc: x86@kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Stefani Seibold <stefani@seibold.net>
Subject: Re: [PATCH 2/3] doc,vdso: Make vDSO examples more portable
Date: Thu, 12 Jun 2014 13:01:31 -0700	[thread overview]
Message-ID: <539A071B.2080101@zytor.com> (raw)
In-Reply-To: <87f62cc3db04047f9edbf7bacac059396d7112f1.1402598632.git.luto@amacapital.net>

On 06/12/2014 11:47 AM, Andy Lutomirski wrote:
>  
> +#include <asm/bitsperlong.h>
> +

This isn't portable in any way.  This is probably not the right way to
do this.

The portable way to do this would be something like:

#include <limits.h>

#if ULONG_MAX > 0xffffffffUL
# define ELF_BITS 64
#else
# define ELF_BITS 32
#endif

There is also the option of looking for either __LP64__ or __ILP32__
which isn't 100% portable but works with all newer versions of gcc:

#ifndef ELF_BITS
# ifdef __LP64__
#  define ELF_BITS 64
# elif defined(__ILP32__)
#  define ELF_BITS 32
# else
#  error "Unknown size, please define ELF_BITS"
# endif
#endif

... or something like that.

	-hpa


  reply	other threads:[~2014-06-12 20:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-12 18:47 [PATCH 0/3] vDSO reference parser updates and Go workaround Andy Lutomirski
2014-06-12 18:47 ` [PATCH 1/3] doc,vdso: Rename vdso_test.c to vdso_standalone_test_x86.c Andy Lutomirski
2014-06-12 18:47 ` [PATCH 2/3] doc,vdso: Make vDSO examples more portable Andy Lutomirski
2014-06-12 20:01   ` H. Peter Anvin [this message]
2014-06-12 18:47 ` [PATCH 3/3] x86,vdso: Hack to keep 64-bit Go programs working Andy Lutomirski
2014-06-12 20:21   ` H. Peter Anvin
2014-06-13  1:09     ` Andy Lutomirski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=539A071B.2080101@zytor.com \
    --to=hpa@zytor.com \
    --cc=kuizhang@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=stefani@seibold.net \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.