From 66cc843f3d70a38c44f49077bcc7663ad685aef4 Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Tue, 8 Sep 2015 17:14:08 +0200 Subject: libpayload: Revive ffs() Revive ffs() in a more fancy way (that is more likely to be accepted). We dropped it in 7a8a4ab lib: Unify log2() and related functions but there is at least one user: flashrom. Change-Id: I4e3fc15816b778e640bceea0d89cd9624d271c2e Signed-off-by: Nico Huber Signed-off-by: Julius Werner Reviewed-on: http://review.coreboot.org/11591 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber Reviewed-by: Stefan Reinauer --- payloads/libpayload/include/strings.h | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 payloads/libpayload/include/strings.h diff --git a/payloads/libpayload/include/strings.h b/payloads/libpayload/include/strings.h new file mode 100644 index 0000000000..e25a823df0 --- /dev/null +++ b/payloads/libpayload/include/strings.h @@ -0,0 +1,37 @@ +/* + * This file is part of the libpayload project. + * + * Copyright (C) 2011 secunet Security Networks AG + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _STRINGS_H +#define _STRINGS_H + +#include + +static inline int ffs(int i) { return __ffs(i) + 1; } + +#endif -- cgit v1.2.3