Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756630AbbHZNrC (ORCPT ); Wed, 26 Aug 2015 09:47:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52462 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756583AbbHZNq7 (ORCPT ); Wed, 26 Aug 2015 09:46:59 -0400 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , David Ahern , Ingo Molnar , Namhyung Kim , Peter Zijlstra , Matt Fleming , =?UTF-8?q?Rapha=C3=ABl=20Beamonte?= Subject: [PATCH 01/11] tools: Add err.h with ERR_PTR PTR_ERR interface Date: Wed, 26 Aug 2015 15:46:43 +0200 Message-Id: <1440596813-12844-2-git-send-email-jolsa@kernel.org> In-Reply-To: <1440596813-12844-1-git-send-email-jolsa@kernel.org> References: <1440596813-12844-1-git-send-email-jolsa@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1574 Lines: 57 Adding part of the kernel's interface: inline void * __must_check ERR_PTR(long error); inline long __must_check PTR_ERR(__force const void *ptr); inline bool __must_check IS_ERR(__force const void *ptr); it will be used to propagate error through pointers in following patches. Link: http://lkml.kernel.org/n/tip-ufgnyf683uab69anmmrabgdf@git.kernel.org Signed-off-by: Jiri Olsa --- tools/include/linux/err.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tools/include/linux/err.h diff --git a/tools/include/linux/err.h b/tools/include/linux/err.h new file mode 100644 index 000000000000..2df92df55cfe --- /dev/null +++ b/tools/include/linux/err.h @@ -0,0 +1,28 @@ +#ifndef __TOOLS_LINUX_ERR_H +#define __TOOLS_LINUX_ERR_H + +#include +#include + +#include + +#define MAX_ERRNO 4095 + +#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO) + +static inline void * __must_check ERR_PTR(long error) +{ + return (void *) error; +} + +static inline long __must_check PTR_ERR(__force const void *ptr) +{ + return (long) ptr; +} + +static inline bool __must_check IS_ERR(__force const void *ptr) +{ + return IS_ERR_VALUE((unsigned long)ptr); +} + +#endif /* _LINUX_ERR_H */ -- 2.4.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/