mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 06/20] app: add some utils
Date: Wed, 6 Mar 2013 22:21:29 +0100	[thread overview]
Message-ID: <20130306212129.GN1906@pengutronix.de> (raw)
In-Reply-To: <1362562189-17783-6-git-send-email-plagnioj@jcrosoft.com>

On Wed, Mar 06, 2013 at 10:29:35AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
>  - getchar_timeout
>  - term (try to detect terminal size, position, ansi helper)
>  - list
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
> diff --git a/apps/include/utils/list.h b/apps/include/utils/list.h
> new file mode 100644
> index 0000000..8a18dae
> --- /dev/null
> +++ b/apps/include/utils/list.h
> @@ -0,0 +1,114 @@
> +/*
> + * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
> + *
> + * Under GPLv2 only
> + *
> + * As a special exception, if other files instantiate templates or use macros
> + * or inline functions from this file, or you compile this file and link it
> + * with other works to produce a work based on this file, this file does not
> + * by itself cause the resulting work to be covered by the GNU General Public
> + * License. However the source code for this file must still be made available
> + * in accordance with section (3) of the GNU General Public License.
> +
> + * This exception does not invalidate any other reasons why a work based on
> + * this file might be covered by the GNU General Public License.
> + */

This looks suspiciously like the Linux list implementation which I think you
haven't written. Also who gives you the right to add this licence
exception to code you do not own?

Sascha

> +
> +#ifndef __UTILS_LIST_H__
> +#define __UTILS_LIST_H__
> +
> +struct list_entry {
> +	struct list_entry *prev;
> +	struct list_entry *next;
> +};
> +
> +struct list {
> +	struct list_entry head;
> +};
> +
> +#define LIST_HEAD_INIT(name) \
> +	{ \
> +		.head = { \
> +			.prev = &(name).head, \
> +			.next = &(name).head \
> +		} \
> +	}
> +
> +#define LIST_HEAD(name) \
> +	struct list name = LIST_HEAD_INIT(name)
> +
> +#define container_of(ptr, type, member) \
> +	((type *) (((void *)(ptr)) - ((void *) &(((type *)0)->member))))
> +
> +#define list_entry(ptr, type, member) \
> +	container_of(ptr, type, member)
> +
> +#define list_first_entry(ptr, type, member) \
> +	list_entry((ptr)->head.next, type, member)
> +
> +#define list_last_entry(head, type, member) \
> +	list_entry((head)->head.prev, type, member)
> +
> +#define list_for_each(pos, list) \
> +	for (pos = (list).head.next; pos != &(list).head; pos = pos->next)
> +
> +#define list_foreach_safe(pos, n, list) \
> +	for (pos = (list).head.next, *n = pos->next; \
> +		pos != &(list).head; pos = n, n = pos->next)
> +
> +#define list_for_each_entry(pos, list, member)				\
> +	for (pos = list_entry((list)->head.next, typeof(*pos), member);	\
> +	      &pos->member != (&(list)->head);				\
> +	     pos = list_entry(pos->member.next, typeof(*pos), member))
> +
> +
> +#define list_for_each_entry_safe(pos, n, list, member)			\
> +	for (pos = list_entry((list)->head.next, typeof(*pos), member),	\
> +		n = list_entry(pos->member.next, typeof(*pos), member);	\
> +	     &pos->member != (&(list)->head);				\
> +	     pos = n, n = list_entry(n->member.next, typeof(*n), member))
> +
> +
> +static inline bool list_empty(struct list *list)
> +{
> +	struct list_entry *head = &list->head;
> +
> +	return head->next == head;
> +}
> +
> +static inline void __list_add(struct list_entry *new,
> +			      struct list_entry *prev,
> +			      struct list_entry *next)
> +{
> +	next->prev = new;
> +	new->next = next;
> +	new->prev = prev;
> +	prev->next = new;
> +}
> +
> +static inline void list_add(struct list_entry *new, struct list *list)
> +{
> +	struct list_entry *head = &list->head;
> +
> +	__list_add(new, head, head->next);
> +}
> +
> +static inline void list_add_tail(struct list_entry *new, struct list *list)
> +{
> +	struct list_entry *head = &list->head;
> +
> +	__list_add(new, head->prev, head);
> +}
> +
> +static inline void list_del(struct list_entry *entry)
> +{
> +	struct list_entry *prev = entry->prev;
> +	struct list_entry *next = entry->next;
> +
> +	next->prev = prev;
> +	prev->next = next;
> +	entry->next = NULL;
> +	entry->prev = NULL;
> +}
> +	
> +#endif /* __UTILS_LIST_H__ */
-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2013-03-06 21:21 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-06  9:26 [RFC PATCH 00/20] introduce application support Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29 ` [PATCH 01/20] Makefile: x_flags prepare for apps support Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29   ` [PATCH 02/20] tlsf_malloc: drop duplicate include Jean-Christophe PLAGNIOL-VILLARD
2013-03-07  7:37     ` Sascha Hauer
2013-03-06  9:29   ` [PATCH 03/20] kbuild: add application (app) target Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29   ` [PATCH 04/20] Introduce application (app) support Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29   ` [PATCH 05/20] app: Introduce libc support Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29   ` [PATCH 06/20] app: add some utils Jean-Christophe PLAGNIOL-VILLARD
2013-03-06 21:21     ` Sascha Hauer [this message]
2013-03-06 21:34       ` Jean-Christophe PLAGNIOL-VILLARD
2013-03-07  7:45         ` Sascha Hauer
2013-03-07  9:17           ` Alexander Aring
2013-03-06  9:29   ` [PATCH 07/20] app: Introduce example application Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29   ` [PATCH 08/20] filetype: add barebox arm application Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29   ` [PATCH 09/20] arm: add application support Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:59     ` Alexander Shiyan
2013-03-06 10:13       ` Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29   ` [PATCH 10/20] app: printf: use HelenOS verison with wide char support Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29   ` [PATCH 11/20] app: printf: add version from contiki Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29   ` [PATCH 12/20] app: add tinycurses support Jean-Christophe PLAGNIOL-VILLARD
2013-03-06 11:31     ` Sascha Hauer
2013-03-06 13:04       ` Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29   ` [PATCH 13/20] app: curses: add pdcurses Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29   ` [PATCH 14/20] app: add test curses Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29   ` [PATCH 15/20] app: pdcurses: add libmenu Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29   ` [PATCH 16/20] app: pdcurses: add libform Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29   ` [PATCH 17/20] app: curses: add menu example Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29   ` [PATCH 18/20] app: curses: add panel example Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29   ` [PATCH 19/20] app: curses: add form example Jean-Christophe PLAGNIOL-VILLARD
2013-03-06  9:29   ` [PATCH 20/20] highbank: enable application support Jean-Christophe PLAGNIOL-VILLARD
2013-03-07  7:36 ` [RFC PATCH 00/20] introduce " Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130306212129.GN1906@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=plagnioj@jcrosoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox