17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 2605c24214SIgor Kozhukhov /* 2705c24214SIgor Kozhukhov * Copyright 2015 EveryCity Ltd. All rights reserved. 2805c24214SIgor Kozhukhov */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #ifndef _SYS_CCOMPILE_H 317c478bd9Sstevel@tonic-gate #define _SYS_CCOMPILE_H 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate /* 347c478bd9Sstevel@tonic-gate * This file contains definitions designed to enable different compilers 357c478bd9Sstevel@tonic-gate * to be used harmoniously on Solaris systems. 367c478bd9Sstevel@tonic-gate */ 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifdef __cplusplus 397c478bd9Sstevel@tonic-gate extern "C" { 407c478bd9Sstevel@tonic-gate #endif 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * Allow for version tests for compiler bugs and features. 447c478bd9Sstevel@tonic-gate */ 457c478bd9Sstevel@tonic-gate #if defined(__GNUC__) 467c478bd9Sstevel@tonic-gate #define __GNUC_VERSION \ 477c478bd9Sstevel@tonic-gate (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) 487c478bd9Sstevel@tonic-gate #else 497c478bd9Sstevel@tonic-gate #define __GNUC_VERSION 0 507c478bd9Sstevel@tonic-gate #endif 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate #if defined(__ATTRIBUTE_IMPLEMENTED) || defined(__GNUC__) 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate /* 557c478bd9Sstevel@tonic-gate * analogous to lint's PRINTFLIKEn 567c478bd9Sstevel@tonic-gate */ 577c478bd9Sstevel@tonic-gate #define __sun_attr___PRINTFLIKE__(__n) \ 587c478bd9Sstevel@tonic-gate __attribute__((__format__(printf, __n, (__n)+1))) 597c478bd9Sstevel@tonic-gate #define __sun_attr___VPRINTFLIKE__(__n) \ 607c478bd9Sstevel@tonic-gate __attribute__((__format__(printf, __n, 0))) 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate /* 637c478bd9Sstevel@tonic-gate * Handle the kernel printf routines that can take '%b' too 647c478bd9Sstevel@tonic-gate */ 657c478bd9Sstevel@tonic-gate #if __GNUC_VERSION < 30402 667c478bd9Sstevel@tonic-gate /* 677c478bd9Sstevel@tonic-gate * XX64 at least this doesn't work correctly yet with 3.4.1 anyway! 687c478bd9Sstevel@tonic-gate */ 697c478bd9Sstevel@tonic-gate #define __sun_attr___KPRINTFLIKE__ __sun_attr___PRINTFLIKE__ 707c478bd9Sstevel@tonic-gate #define __sun_attr___KVPRINTFLIKE__ __sun_attr___VPRINTFLIKE__ 717c478bd9Sstevel@tonic-gate #else 727c478bd9Sstevel@tonic-gate #define __sun_attr___KPRINTFLIKE__(__n) \ 737c478bd9Sstevel@tonic-gate __attribute__((__format__(cmn_err, __n, (__n)+1))) 747c478bd9Sstevel@tonic-gate #define __sun_attr___KVPRINTFLIKE__(__n) \ 757c478bd9Sstevel@tonic-gate __attribute__((__format__(cmn_err, __n, 0))) 767c478bd9Sstevel@tonic-gate #endif 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate /* 797c478bd9Sstevel@tonic-gate * This one's pretty obvious -- the function never returns 807c478bd9Sstevel@tonic-gate */ 817c478bd9Sstevel@tonic-gate #define __sun_attr___noreturn__ __attribute__((__noreturn__)) 827c478bd9Sstevel@tonic-gate 836b7143d7SRichard Lowe /* 846b7143d7SRichard Lowe * The function is 'extern inline' and expects GNU C89 behaviour, not C99 856b7143d7SRichard Lowe * behaviour. 866b7143d7SRichard Lowe * 876b7143d7SRichard Lowe * Should only be used on 'extern inline' definitions for GCC. 886b7143d7SRichard Lowe */ 896a3e8e86SRichard Lowe #if __GNUC_VERSION >= 40200 906b7143d7SRichard Lowe #define __sun_attr___gnu_inline__ __attribute__((__gnu_inline__)) 916b7143d7SRichard Lowe #else 926b7143d7SRichard Lowe #define __sun_attr___gnu_inline__ 936b7143d7SRichard Lowe #endif 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate /* 966a3e8e86SRichard Lowe * The function has control flow such that it may return multiple times (in 976a3e8e86SRichard Lowe * the manner of setjmp or vfork) 986a3e8e86SRichard Lowe */ 996a3e8e86SRichard Lowe #if __GNUC_VERSION >= 40100 1006a3e8e86SRichard Lowe #define __sun_attr___returns_twice__ __attribute__((__returns_twice__)) 1016a3e8e86SRichard Lowe #else 1026a3e8e86SRichard Lowe #define __sun_attr___returns_twice__ 1036a3e8e86SRichard Lowe #endif 1046a3e8e86SRichard Lowe 1056a3e8e86SRichard Lowe /* 1067c478bd9Sstevel@tonic-gate * This is an appropriate label for functions that do not 1077c478bd9Sstevel@tonic-gate * modify their arguments, e.g. strlen() 1087c478bd9Sstevel@tonic-gate */ 1097c478bd9Sstevel@tonic-gate #define __sun_attr___pure__ __attribute__((__pure__)) 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate /* 1127c478bd9Sstevel@tonic-gate * This is a stronger form of __pure__. Can be used for functions 1137c478bd9Sstevel@tonic-gate * that do not modify their arguments and don't depend on global 1147c478bd9Sstevel@tonic-gate * memory. 1157c478bd9Sstevel@tonic-gate */ 1167c478bd9Sstevel@tonic-gate #define __sun_attr___const__ __attribute__((__const__)) 1177c478bd9Sstevel@tonic-gate 118*34f09ee1SToomas Soome #if __GNUC_VERSION >= 20700 119*34f09ee1SToomas Soome #define __aligned(x) __attribute__((__aligned__(x))) 12005c24214SIgor Kozhukhov /* 12105c24214SIgor Kozhukhov * This attribute, attached to a variable, means that the variable is meant to 12205c24214SIgor Kozhukhov * be possibly unused. GCC will not produce a warning for this variable. 12305c24214SIgor Kozhukhov */ 12405c24214SIgor Kozhukhov #define __sun_attr___unused__ __attribute__((__unused__)) 12505c24214SIgor Kozhukhov #endif 12605c24214SIgor Kozhukhov 1277c478bd9Sstevel@tonic-gate #define ___sun_attr_inner(__a) __sun_attr_##__a 1287c478bd9Sstevel@tonic-gate #define __sun_attr__(__a) ___sun_attr_inner __a 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate #else /* __ATTRIBUTE_IMPLEMENTED || __GNUC__ */ 1317c478bd9Sstevel@tonic-gate 132*34f09ee1SToomas Soome #define __aligned(x) 1337c478bd9Sstevel@tonic-gate #define __sun_attr__(__a) 134*34f09ee1SToomas Soome #define __sun_attr___unused__ 1357c478bd9Sstevel@tonic-gate 1367c478bd9Sstevel@tonic-gate #endif /* __ATTRIBUTE_IMPLEMENTED || __GNUC__ */ 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate /* 1397c478bd9Sstevel@tonic-gate * Shorthand versions for readability 1407c478bd9Sstevel@tonic-gate */ 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate #define __PRINTFLIKE(__n) __sun_attr__((__PRINTFLIKE__(__n))) 1437c478bd9Sstevel@tonic-gate #define __VPRINTFLIKE(__n) __sun_attr__((__VPRINTFLIKE__(__n))) 1447c478bd9Sstevel@tonic-gate #define __KPRINTFLIKE(__n) __sun_attr__((__KPRINTFLIKE__(__n))) 1457c478bd9Sstevel@tonic-gate #define __KVPRINTFLIKE(__n) __sun_attr__((__KVPRINTFLIKE__(__n))) 1467c478bd9Sstevel@tonic-gate #define __NORETURN __sun_attr__((__noreturn__)) 1476b7143d7SRichard Lowe #define __GNU_INLINE __inline__ __sun_attr__((__gnu_inline__)) 1486a3e8e86SRichard Lowe #define __RETURNS_TWICE __sun_attr__((__returns_twice__)) 1497c478bd9Sstevel@tonic-gate #define __CONST __sun_attr__((__const__)) 1507c478bd9Sstevel@tonic-gate #define __PURE __sun_attr__((__pure__)) 151*34f09ee1SToomas Soome #define __packed __attribute__((__packed__)) 152c702eacaSToomas Soome #define __unused __sun_attr__((__unused__)) 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1557c478bd9Sstevel@tonic-gate } 1567c478bd9Sstevel@tonic-gate #endif 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate #endif /* _SYS_CCOMPILE_H */ 159