Define _LP64 or _ILP32 for all architectures.

Rather than write out a table for each architecture, rely on the C
compiler to define _LP64 for 64-bit ones, on the assumption that
anything not LP64 is ILP32, and on CTASSERTs to verify this
assumption so that if it's wrong it'll fail safely with a noisy build
failure.

Gives zfs half a chance of building on, e.g., powerpc.
This commit is contained in:
riastradh 2018-11-14 17:09:08 +00:00
parent 51aec893ad
commit 44773f2a69
1 changed files with 19 additions and 21 deletions

View File

@ -1,12 +1,9 @@
/* $NetBSD: isa_defs.h,v 1.2 2015/02/21 15:00:30 ozaki-r Exp $ */
/* $NetBSD: isa_defs.h,v 1.3 2018/11/14 17:09:08 riastradh Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
* Copyright (c) 2018 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -29,23 +26,24 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#ifndef _OSNET_SYS_ISA_DEFS_H_
#define _OSNET_SYS_ISA_DEFS_H_
#if defined(__i386__)
#if !defined(_ILP32)
#define _ILP32
#endif
#elif defined(__amd64__)
#if !defined(_LP64)
#define _LP64
#endif
#elif defined(__arm__)
#if !defined(_ILP32)
#define _ILP32
#endif
#include <sys/cdefs.h>
#ifdef _LP64
__CTASSERT(sizeof(int) == 4);
__CTASSERT(sizeof(long) == 8);
__CTASSERT(sizeof(void *) == 8);
#else
#error "architecture not supported"
/*
* For 64-bit architectures the compiler defines _LP64. All else in
* NetBSD is ILP32 for now.
*/
__CTASSERT(sizeof(int) == 4);
__CTASSERT(sizeof(long) == 4);
__CTASSERT(sizeof(void *) == 4);
#define _ILP32 1
#endif
#endif /* _OSNET_SYS_ISA_DEFS_H_ */