From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0AFBC433EF for ; Mon, 6 Jun 2022 06:12:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229865AbiFFGMk (ORCPT ); Mon, 6 Jun 2022 02:12:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229806AbiFFGMk (ORCPT ); Mon, 6 Jun 2022 02:12:40 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E1FA55B0 for ; Sun, 5 Jun 2022 23:12:38 -0700 (PDT) Received: from integral2.. (unknown [36.73.79.120]) by gnuweeb.org (Postfix) with ESMTPSA id 3B2677FA0A; Mon, 6 Jun 2022 06:12:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1654495958; bh=g0hFM7Sftj3Glht2ZLdg1dGmI4JnKxkQ3//5BI8JNPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cKO6rFzYp/xP/ebXzpg8ubu/ZmFA2p20lgu9w8QsubV+cbKs+ALWuWaAR4nk8rvBH X0uB2SnP5lslZvhtnLKGBHnYpnK25LxAPI066nxDRUs6FNV6qCaW9UY2bP+zpBecHo 6F5jBL8x4TSQoEz4/pdIxsFPqyNg/+hJgAs9EMSOG5iIj/szUg32KGdFtRvmk5fLOm RNkvSep4+jm6jNe6JWl44zHWSSvDdltnSKEz22NsxfM2/214yNMAv1xbbjdocTZSJD LLc3qNE2/kmDphaEeRnPW2BsYkaOKHSzmKoP3+SS3ErjNyzf7scLtS2/tC0fZBFkxn hxIb9PNPNch7w== From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , Pavel Begunkov , "Fernanda Ma'rouf" , Hao Xu , Alviro Iskandar Setiawan , io-uring Mailing List , GNU/Weeb Mailing List Subject: [RFC PATCH v1 2/5] lib: Add `BUILD_BUG_ON()` macro Date: Mon, 6 Jun 2022 13:12:06 +0700 Message-Id: <20220606061209.335709-3-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220606061209.335709-1-ammarfaizi2@gnuweeb.org> References: <20220606061209.335709-1-ammarfaizi2@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org The first use case of this macro is for data structure assertion at compile time. It's like what we do in the io_uring.c in the kernel. Signed-off-by: Ammar Faizi --- src/lib.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib.h b/src/lib.h index 5dabd28..40e2817 100644 --- a/src/lib.h +++ b/src/lib.h @@ -5,6 +5,7 @@ #include #include #include +#include #define __INTERNAL__LIBURING_LIB_H #if defined(__x86_64__) || defined(__i386__) @@ -21,6 +22,9 @@ #endif #undef __INTERNAL__LIBURING_LIB_H +#ifndef BUILD_BUG_ON +#define BUILD_BUG_ON(EXPR) static_assert(!(EXPR), "!(" #EXPR ") failed") +#endif #ifndef offsetof #define offsetof(TYPE, FIELD) ((size_t) &((TYPE *)0)->FIELD) -- Ammar Faizi