lkml.org 
[lkml]   [2014]   [Jun]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/3] doc,vdso: Make vDSO examples more portable
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



\
 
 \ /
  Last update: 2014-06-12 22:41    [W:0.050 / U:8.964 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site