Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp808292lqt; Thu, 6 Jun 2024 21:34:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVuDIY2IF+7yr9stTdKE7pXgxkjyUQQ00wDb+PTMt4UNBJ50BL7oj1kU8ORh8gEg/X7V5dbi3m8ZEIHemrLqKnefreGIRTzUN1+RHX1bA== X-Google-Smtp-Source: AGHT+IE0O2+WEl6kM7lv29WRtqlScgfGGTIdueUGrUe8yHx2HV6Mop1UAiVkzw+KWaPRWRCl6Rmj X-Received: by 2002:a17:906:1409:b0:a6c:7181:4ffe with SMTP id a640c23a62f3a-a6cdc0e0dc0mr76090666b.66.1717734866712; Thu, 06 Jun 2024 21:34:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717734866; cv=pass; d=google.com; s=arc-20160816; b=bNBk7mUE+AY57KNnukjMZ9hTYz3gHE2m0dOFccVHMG5Ojhkcok6A/o1g2uaywNgKSC BTHVGsF+MIvpIjrl8l0s6PDanYoBcxVytl0qOTWvOpAMSpnCxKLzV9Ja8g6ccf1Fz35C o4x2jDmAz5XEkLYtrwtS7VopmkA5d2yZ0YVgB4NCcK4PVcoOioAjnjmc7L7QoiCBnQ8O 1HNslzSGFUzn4VQVhlQINzX5YC83KIsB45i2b1L77RYNUZoKxYoTlDvk8vxoT87hdxj5 8662z7dh9/rBF7wQyxxsGJ2em9DKX5diSB4IBc3UxfN499sO48LYIO0Tsbw9K0XMQ2uh yp2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=26duKQDb3/3zu8+hJPCkuvcAwrmA6RoIziuWkbMq9cQ=; fh=yXYChwFvQA/NaaLzCC0IJdkW11OhjXgO4DHXzVmnGFw=; b=McNgHKoCAPlBDpf5cKKp4mAPdG3RuSgFLbuyTZAkGNxrabGH33prbDUgEdx7ZF0CCp 54EXhBCp9ItZgmlUNf51/f4cvR+3qUkjvb4bm/nJybvCAza0xXhcuJ//G38nB3H6O1/T wBE0nGoezHku9RQLstI09knwPg0jPaEDhjWJAKgrz4hr3lGblfsdsj+P6gFIBTcnZG7H bacXv1qwe+UE1wRtcujRYomo4kXWmT0dw1+Mc/bbeQM/yuCLV5du32M7V+yAaOaN4ac/ diPH/Yo17ArqwLE3XNF9zBO1KhCi5agZly2h12kcvf8b86qAIhDrrXqZeKWi8NFMKLT3 GvUg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-205313-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205313-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a6c8070bf0csi136255566b.568.2024.06.06.21.34.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 21:34:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-205313-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-205313-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-205313-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6883A1F25FC8 for ; Fri, 7 Jun 2024 04:34:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A5BAC155757; Fri, 7 Jun 2024 04:27:15 +0000 (UTC) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44D5E13E3EA for ; Fri, 7 Jun 2024 04:27:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717734433; cv=none; b=kRuBO76tXMJjqvrfZxKX6VcrghfJ73xYNCkH2tyijqHWnLptL+Ffhk3IFYAY0Xq4B/XHNxR2h3XXitiDI1qxawFTDP18X75fG3aE+3SGxOV7Ew1ocQK8Ym0w0zWJ8KtmELXobyOAy6yeSfsRudZHcGF07EYM0YGH6HYVV+ywLh0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717734433; c=relaxed/simple; bh=mfsoppF1Qw60Y53W+7G69oz+2Y1v7+YgU4N9F0B40GA=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bNV270Zv0udUraX+WTkw1miZJL10dfY9kHvhvQG5jDt+lDMXMv40gE6vJ9SMkiL9Djyp1sAhgQcdxKf9oTomi0dAkDfSUfSDoRwo+kDQ2K2FWCpA9pzyFXX7M5h3VhEakFsa8EzUpMPNUqfMwPx2d/amW41nByExLgHbT4aROjg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VwSj649CMzmYRT; Fri, 7 Jun 2024 12:22:34 +0800 (CST) Received: from kwepemm600013.china.huawei.com (unknown [7.193.23.68]) by mail.maildlp.com (Postfix) with ESMTPS id 618D4180085; Fri, 7 Jun 2024 12:27:10 +0800 (CST) Received: from huawei.com (10.175.104.67) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Fri, 7 Jun 2024 12:26:50 +0800 From: Zhihao Cheng To: , , , , , CC: , Subject: [RFC PATCH mtd-utils 032/110] ubifs-utils: Add common definitions in linux kernel Date: Fri, 7 Jun 2024 12:24:57 +0800 Message-ID: <20240607042615.2069840-33-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240607042615.2069840-1-chengzhihao1@huawei.com> References: <20240607042615.2069840-1-chengzhihao1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600013.china.huawei.com (7.193.23.68) Add common definitions in linux kernel, which are used in UBIFS linux kernel libs. This is a preparation for replacing implementation of UBIFS utils with linux kernel libs. Signed-off-by: Zhihao Cheng --- ubifs-utils/common/defs.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/ubifs-utils/common/defs.h b/ubifs-utils/common/defs.h index 548d9dfb..506f752c 100644 --- a/ubifs-utils/common/defs.h +++ b/ubifs-utils/common/defs.h @@ -11,8 +11,11 @@ #include #include #include +#include +#include #include +#include "linux_types.h" #include "ubifs.h" /* common.h requires the PROGRAM_NAME macro */ @@ -76,8 +79,41 @@ static inline void dump_stack(void) free(strings); } +static inline u32 get_random_u32(void) +{ + srand(time(NULL)); + return rand(); +} + +static inline time_t ktime_get_seconds() +{ + return time(NULL); +} + +#define likely(x) (x) #define unlikely(x) (x) +#define cond_resched() do {} while(0) + +#define BUG() do { \ + assert(0); \ +} while(0) +#define BUG_ON(cond) do { \ + assert(!cond); \ +} while(0) + +#define smp_wmb() do {} while(0) +#define smp_rmb() do {} while(0) +#define smp_mb__before_atomic() do {} while(0) +#define smp_mb__after_atomic() do {} while(0) + +#define min3(x, y, z) min((typeof(x))min(x, y), z) + +static inline u64 div_u64(u64 dividend, u32 divisor) +{ + return dividend / divisor; +} + #define do_div(n,base) ({ \ int __res; \ __res = ((unsigned long) n) % (unsigned) base; \ -- 2.13.6