From owner-svn-src-all@FreeBSD.ORG Sat Apr 25 18:17:09 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 57AE6601; Sat, 25 Apr 2015 18:17:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2C0C71B3B; Sat, 25 Apr 2015 18:17:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t3PIH9TE060177; Sat, 25 Apr 2015 18:17:09 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t3PIH9In060176; Sat, 25 Apr 2015 18:17:09 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201504251817.t3PIH9In060176@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Sat, 25 Apr 2015 18:17:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r281986 - head/sys/sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Apr 2015 18:17:09 -0000 Author: pfg Date: Sat Apr 25 18:17:08 2015 New Revision: 281986 URL: https://svnweb.freebsd.org/changeset/base/281986 Log: Cleanup a bit the clang attributes for type safety checking. Cleanup r281861 by moving the definitions to their own section but still leave the definitions out of lint. In addition to the 'argument_with_type_tag' attribute, bring 'type_tag_for_datatype' which is necessary for annotating the data types. Modified: head/sys/sys/cdefs.h Modified: head/sys/sys/cdefs.h ============================================================================== --- head/sys/sys/cdefs.h Sat Apr 25 16:15:01 2015 (r281985) +++ head/sys/sys/cdefs.h Sat Apr 25 18:17:08 2015 (r281986) @@ -212,7 +212,6 @@ #define __unused #define __packed #define __aligned(x) -#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) #define __section(x) #define __weak #else @@ -237,12 +236,6 @@ #define __aligned(x) __attribute__((__aligned__(x))) #define __section(x) __attribute__((__section__(x))) #endif -#if __has_attribute(argument_with_type_tag) -#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) \ - __attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx))) -#else -#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) -#endif #if defined(__INTEL_COMPILER) #define __dead2 __attribute__((__noreturn__)) #define __pure2 __attribute__((__const__)) @@ -776,6 +769,24 @@ #endif /* + * Type Safety Checking + * + * Clang provides additional attributes to enable checking type safety + * properties that cannot be enforced by the C type system. + */ + +#if __has_attribute(argument_with_type_tag) && \ + __has_attribute(type_tag_for_datatype) && !defined(lint) +#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) \ + __attribute__((__argument_with_type_tag__(arg_kind, arg_idx, type_tag_idx))) +#define __datatype_type_tag(kind, type) \ + __attribute__((__type_tag_for_datatype__(kind, type))) +#else +#define __arg_type_tag(arg_kind, arg_idx, type_tag_idx) +#define __datatype_type_tag(kind, type) +#endif + +/* * Lock annotations. * * Clang provides support for doing basic thread-safety tests at