Skip to content

Commit 795d3bb

Browse files
committed
Remove deprecated linkedlist.h
list.h should be used instead. Signed-off-by: Davide Bettio <[email protected]>
1 parent 69c5177 commit 795d3bb

File tree

8 files changed

+22
-152
lines changed

8 files changed

+22
-152
lines changed

src/libAtomVM/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ set(HEADER_FILES
3838
iff.h
3939
interop.h
4040
list.h
41-
linkedlist.h
4241
listeners.h
4342
mailbox.h
4443
memory.h

src/libAtomVM/context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extern "C" {
3333
#endif
3434

3535
#include "globalcontext.h"
36-
#include "linkedlist.h"
36+
#include "list.h"
3737
#include "mailbox.h"
3838
#include "smp.h"
3939
#include "term.h"

src/libAtomVM/globalcontext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extern "C" {
3535
#include <stdint.h>
3636

3737
#include "atom.h"
38-
#include "linkedlist.h"
38+
#include "list.h"
3939
#include "smp.h"
4040
#include "synclist.h"
4141
#include "term.h"

src/libAtomVM/linkedlist.h

Lines changed: 0 additions & 146 deletions
This file was deleted.

src/libAtomVM/list.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,32 @@
2121
#ifndef _LIST_H_
2222
#define _LIST_H_
2323

24-
#include "linkedlist.h"
24+
/**
25+
* @brief gets a pointer to the struct that contains a certain list head
26+
*
27+
* @details This macro should be used to retrieve a pointer to the struct that is containing the given ListHead.
28+
*/
29+
#define GET_LIST_ENTRY(list_item, type, list_head_member) \
30+
((type *) (((char *) (list_item)) - ((unsigned long) &((type *) 0)->list_head_member)))
2531

2632
#define LIST_FOR_EACH(item, head) \
2733
for (item = (head)->next; item != (head); item = item->next)
2834

2935
#define MUTABLE_LIST_FOR_EACH(item, tmp, head) \
3036
for (item = (head)->next, tmp = item->next; item != (head); item = tmp, tmp = item->next)
3137

38+
/*
39+
* @brief a struct requires a ListHead member to be used with linked list manipulation functions.
40+
*
41+
* @detail Each struct that is going to be used as part of a linked list should have at least one ListHead,
42+
* each head can be used for a different linked list.
43+
*/
44+
struct ListHead
45+
{
46+
struct ListHead *next;
47+
struct ListHead *prev;
48+
};
49+
3250
static inline void list_insert(struct ListHead *new_item, struct ListHead *prev_head, struct ListHead *next_head)
3351
{
3452
new_item->prev = prev_head;

src/libAtomVM/memory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ extern "C" {
3131
// #define DEBUG_HEAP_ALLOC
3232

3333
#include <stdint.h>
34+
#include <stdlib.h>
3435
#ifdef DEBUG_HEAP_ALLOC
3536
#include <stdio.h>
3637
#endif

src/libAtomVM/scheduler.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ extern "C" {
3434

3535
#include "context.h"
3636
#include "globalcontext.h"
37-
#include "linkedlist.h"
3837

3938
#define DEFAULT_REDUCTIONS_AMOUNT 1024
4039

src/libAtomVM/sys.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ extern "C" {
3535
#endif
3636

3737
#include "globalcontext.h"
38-
#include "linkedlist.h"
3938
#include "module.h"
4039

4140
#include <stdint.h>

0 commit comments

Comments
 (0)