1ff7af0d3SToomas Soome /* 2ff7af0d3SToomas Soome * This file and its contents are supplied under the terms of the 3ff7af0d3SToomas Soome * Common Development and Distribution License ("CDDL"), version 1.0. 4ff7af0d3SToomas Soome * You may only use this file in accordance with the terms of version 5ff7af0d3SToomas Soome * 1.0 of the CDDL. 6ff7af0d3SToomas Soome * 7ff7af0d3SToomas Soome * A full copy of the text of the CDDL should have accompanied this 8ff7af0d3SToomas Soome * source. A copy of the CDDL is also available via the Internet at 9ff7af0d3SToomas Soome * http://www.illumos.org/license/CDDL. 10ff7af0d3SToomas Soome */ 11ff7af0d3SToomas Soome 12ff7af0d3SToomas Soome /* 13ff7af0d3SToomas Soome * Copyright 2017 Toomas Soome <tsoome@me.com> 14ff7af0d3SToomas Soome */ 15ff7af0d3SToomas Soome 16ff7af0d3SToomas Soome #ifndef _SYS_STDDEF_H 17ff7af0d3SToomas Soome #define _SYS_STDDEF_H 18ff7af0d3SToomas Soome 19ff7af0d3SToomas Soome /* 20ff7af0d3SToomas Soome * Commonly used macros and definitions. 21ff7af0d3SToomas Soome */ 22ff7af0d3SToomas Soome 23ff7af0d3SToomas Soome #ifdef __cplusplus 24ff7af0d3SToomas Soome extern "C" { 25ff7af0d3SToomas Soome #endif 26ff7af0d3SToomas Soome 27ff7af0d3SToomas Soome #if !defined(offsetof) 28*0ed46b36SToomas Soome #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) 29ff7af0d3SToomas Soome #define offsetof(s, m) __builtin_offsetof(s, m) 30ff7af0d3SToomas Soome #else 31ff7af0d3SToomas Soome #if __cplusplus >= 199711L 32ff7af0d3SToomas Soome #define offsetof(s, m) (std::size_t)(&(((s *)NULL)->m)) 33ff7af0d3SToomas Soome #else 34ff7af0d3SToomas Soome #define offsetof(s, m) ((size_t)(&(((s *)NULL)->m))) 35ff7af0d3SToomas Soome #endif 36ff7af0d3SToomas Soome #endif 37ff7af0d3SToomas Soome #endif /* !offsetof */ 38ff7af0d3SToomas Soome 39ff7af0d3SToomas Soome #ifdef __cplusplus 40ff7af0d3SToomas Soome } 41ff7af0d3SToomas Soome #endif 42ff7af0d3SToomas Soome 43ff7af0d3SToomas Soome #endif /* _SYS_STDDEF_H */ 44