From patchwork Sun Feb 19 18:51:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willy Tarreau X-Patchwork-Id: 59200 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp965600wrn; Sun, 19 Feb 2023 10:53:19 -0800 (PST) X-Google-Smtp-Source: AK7set+EO6Z9Hn0rqt6gtvYvs8Uou60h12BvKhRYYmYzGaSK1Z5GJgBSyGLvTyFi9IW3oEFjlV9r X-Received: by 2002:a05:6a20:430e:b0:bf:d67e:5517 with SMTP id h14-20020a056a20430e00b000bfd67e5517mr9454268pzk.42.1676832799532; Sun, 19 Feb 2023 10:53:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676832799; cv=none; d=google.com; s=arc-20160816; b=iMyc9PcDZTu2djTnu4pkDw5WaqJUeA6kPaiOzyshlVD1FN66cywL/8YmW/j4vBVnlk v/fmWRYdBR+xck3O1vC3TfToEoRFgHKnedBoc+UQIxKOequCdLLbpIq0KCAdQAscqP/0 zxv2CyzVcR8OimCToRMqhan0aYqFliMmJRtY/53cGun5Jx9/U8BBT22le8seIJKvVOz2 AMw8O/qrmBO8+NKLXMbcItYrekNlTgWgvVwa75r+3jqQ5Al8cgX6tRh9KQpq+PYuKSjY rPoVPkqkRR06de+Rm3a8J6Ovg1lK+oUcv9a+IV5fZdUa2TZA1+u8zLMQFgLHF082z78/ M0SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=sM99o03ncVKUGM/a7fhKTzpX9fKTQucCUTTptbbzi/0=; b=UgqB39GTuknrvfyvPEkDI+ro1IRkn+zoS7mDNEmsIB/NLBO0DiY/DKllRg97NtCtbv kZ/hzRHalc7BdPd3x0mjX9dAh2xxawibuRtzI3mu2UZMZiV6Ssh1sZk81qUjaAd5zfFV /W2v4aOhDhC0vimjotPvWSgsXlIRnwuccthj7F4laM2iRbERC5ATYeJZPmKtdCvnMcEK 9D4Gk/lnEU+LoNxEQAi0ZSIfXGFzNBwp6qUstEyVAXoayfzRQ4CL+Zg8XVaqzxm9Nlua IjOTuipKxxgcF6xGfGpfbGf7Yxhq3qToZLRvK1fn/Oist/rAx1Uicr9m2USYrnyF6uE/ +Gbw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n22-20020a056a0007d600b005a85d73f825si10904322pfu.125.2023.02.19.10.53.07; Sun, 19 Feb 2023 10:53:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231276AbjBSSv4 (ORCPT + 99 others); Sun, 19 Feb 2023 13:51:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230428AbjBSSvv (ORCPT ); Sun, 19 Feb 2023 13:51:51 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9C9D21449C for ; Sun, 19 Feb 2023 10:51:49 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 31JIpiRe014622; Sun, 19 Feb 2023 19:51:44 +0100 From: Willy Tarreau To: Vincent Dagonneau Cc: linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/4] tools/nolibc: add stdint.h Date: Sun, 19 Feb 2023 19:51:30 +0100 Message-Id: <20230219185133.14576-2-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20230219185133.14576-1-w@1wt.eu> References: <20230219185133.14576-1-w@1wt.eu> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758286629301847065?= X-GMAIL-MSGID: =?utf-8?q?1758286629301847065?= From: Vincent Dagonneau Nolibc works fine for small and limited program however most program expect integer types to be defined in stdint.h rather than std.h. This is a quick fix that moves the existing integer definitions in std.h to stdint.h. Signed-off-by: Vincent Dagonneau Signed-off-by: Willy Tarreau --- tools/include/nolibc/Makefile | 4 ++-- tools/include/nolibc/std.h | 15 +-------------- tools/include/nolibc/stdint.h | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 tools/include/nolibc/stdint.h diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile index cfd06764b5ae..ec57d3932506 100644 --- a/tools/include/nolibc/Makefile +++ b/tools/include/nolibc/Makefile @@ -25,8 +25,8 @@ endif nolibc_arch := $(patsubst arm64,aarch64,$(ARCH)) arch_file := arch-$(nolibc_arch).h -all_files := ctype.h errno.h nolibc.h signal.h std.h stdio.h stdlib.h string.h \ - sys.h time.h types.h unistd.h +all_files := ctype.h errno.h nolibc.h signal.h std.h stdint.h stdio.h stdlib.h \ + string.h sys.h time.h types.h unistd.h # install all headers needed to support a bare-metal compiler all: headers diff --git a/tools/include/nolibc/std.h b/tools/include/nolibc/std.h index 1747ae125392..933bc0be7e1c 100644 --- a/tools/include/nolibc/std.h +++ b/tools/include/nolibc/std.h @@ -18,20 +18,7 @@ #define NULL ((void *)0) #endif -/* stdint types */ -typedef unsigned char uint8_t; -typedef signed char int8_t; -typedef unsigned short uint16_t; -typedef signed short int16_t; -typedef unsigned int uint32_t; -typedef signed int int32_t; -typedef unsigned long long uint64_t; -typedef signed long long int64_t; -typedef unsigned long size_t; -typedef signed long ssize_t; -typedef unsigned long uintptr_t; -typedef signed long intptr_t; -typedef signed long ptrdiff_t; +#include "stdint.h" /* those are commonly provided by sys/types.h */ typedef unsigned int dev_t; diff --git a/tools/include/nolibc/stdint.h b/tools/include/nolibc/stdint.h new file mode 100644 index 000000000000..4ba264031df9 --- /dev/null +++ b/tools/include/nolibc/stdint.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */ +/* + * Standard definitions and types for NOLIBC + * Copyright (C) 2023 Vincent Dagonneau + */ + +#ifndef _NOLIBC_STDINT_H +#define _NOLIBC_STDINT_H + +typedef unsigned char uint8_t; +typedef signed char int8_t; +typedef unsigned short uint16_t; +typedef signed short int16_t; +typedef unsigned int uint32_t; +typedef signed int int32_t; +typedef unsigned long long uint64_t; +typedef signed long long int64_t; +typedef unsigned long size_t; +typedef signed long ssize_t; +typedef unsigned long uintptr_t; +typedef signed long intptr_t; +typedef signed long ptrdiff_t; + +#endif /* _NOLIBC_STDINT_H */