From owner-freebsd-current@freebsd.org Mon Aug 13 05:30:44 2018 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B696310665C0 for ; Mon, 13 Aug 2018 05:30:44 +0000 (UTC) (envelope-from FreeBSD@shaneware.biz) Received: from ipmail06.adl2.internode.on.net (ipmail06.adl2.internode.on.net [150.101.137.129]) by mx1.freebsd.org (Postfix) with ESMTP id ED6DA8AE00 for ; Mon, 13 Aug 2018 05:30:43 +0000 (UTC) (envelope-from FreeBSD@shaneware.biz) Received: from unknown (HELO leader.local) ([118.211.111.37]) by ipmail06.adl2.internode.on.net with ESMTP; 13 Aug 2018 13:56:10 +0930 Subject: Re: FreeBSD elf_machine_id To: blubee blubeeme Cc: FreeBSD current References: From: Shane Ambler Message-ID: <69ca3709-fea2-efad-b108-b9173261eefd@ShaneWare.Biz> Date: Mon, 13 Aug 2018 13:56:05 +0930 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-AU Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Aug 2018 05:30:44 -0000 On 12/8/18 11:32 pm, blubee blubeeme wrote: > On Sun, Aug 12, 2018 at 9:59 PM blubee blubeeme wrote: > >> >> >> On Sun, Aug 12, 2018 at 7:43 PM Dimitry Andric wrote: >> >>> On 12 Aug 2018, at 13:21, blubee blubeeme wrote: >>>> >>>> What's the elf_machine_id for FreeBSD amd64 systems? >>>> >>>> How can I find this info? >>> >>> There isn't any FreeBSD-specific machine ID, just a machine ID for >>> x86-64 (aka amd64) in general: >>> >>> $ grep x86-64 /usr/include/sys/elf_common.h >>> #define EM_X86_64 62 /* Advanced Micro Devices x86-64 */ >>> #define EM_AMD64 EM_X86_64 /* Advanced Micro Devices x86-64 >>> (compat) */ >>> >>> -Dimitry >>> >>> Thank you for the clarification. >> >> I think in this case I was looking for 62. >> >> Best, >> Owen >> > Actually I had another quick question along these lines. > > if x86_64 is already defined should I bother changing those to amd64 or > just use x86_64 and make FreeBSD modifications where Linux specifics are > defined? As I understand it, AMD designed the 64bit extensions and early adopters referred to it as amd64, then when Intel adopted it they needed a more generic term, so x86_64 was started, now usually both __X86_64__ and __amd64__ are compiler defined based on the target. So it may depend on why you are asking for the elf_machine_id. For general C/C++ programming - #if defined(__x86_64__) // 64bit code #else // 32 bit code #endif or to be safe you can check all variations #if defined(__X86_64__) || defined(__amd64__) For freebsd specific changes - #if defined(__FreeBSD__) #include #if __FreeBSD_version < 1101000 // version specific see porters handbook for version list #endif #endif If you want to see all the compiler defined environment macros run clang++ -dM -E -x c /dev/null or clang++ -dM -E -x c++ /dev/null or for a 32bit env clang++ -dM -E -m32 -x c++ /dev/null works for clang and gcc. I believe when multiple variations exist, the __xx__ macros are most common eg use __x86_64__ not __x86_64 -- FreeBSD - the place to B...Software Developing Shane Ambler