Skip to content

Commit c8bf97f

Browse files
committed
Merge pull request atomvm#613 from bettio/remove-unused-code
Remove unused code These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents 69c5177 + 2438798 commit c8bf97f

File tree

9 files changed

+22
-288
lines changed

9 files changed

+22
-288
lines changed

src/libAtomVM/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ set(HEADER_FILES
2828
bif.h
2929
bitstring.h
3030
context.h
31-
ccontext.h
3231
debug.h
3332
defaultatoms.h
3433
dictionary.h
@@ -38,7 +37,6 @@ set(HEADER_FILES
3837
iff.h
3938
interop.h
4039
list.h
41-
linkedlist.h
4240
listeners.h
4341
mailbox.h
4442
memory.h

src/libAtomVM/ccontext.h

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

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)