tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / rom / exec / addtail.c
blobbcee89bfffbe5c51a9b41cd26bca56dcfe1cda57
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Add a node at the end of a list.
6 Lang: english
7 */
8 #include <aros/debug.h>
9 #include <exec/lists.h>
10 #include <proto/exec.h>
12 /*****************************************************************************
14 NAME */
16 AROS_LH2I(void, AddTail,
18 /* SYNOPSIS */
19 AROS_LHA(struct List *, list, A0),
20 AROS_LHA(struct Node *, node, A1),
22 /* LOCATION */
23 struct ExecBase *, SysBase, 41, Exec)
25 /* FUNCTION
26 Insert Node node at the end of a list.
28 INPUTS
29 list - The list to insert the node into
30 node - This node is to be inserted
32 RESULT
34 NOTES
36 EXAMPLE
37 struct List * list;
38 struct Node * pred;
40 // Insert Node at end of the list
41 AddTail (list, node);
43 BUGS
45 SEE ALSO
47 INTERNALS
49 ******************************************************************************/
51 AROS_LIBFUNC_INIT
52 // ASSERT_VALID_PTR(node); argh! TypeOfMem() doesn't know about the data segment!
53 // ASSERT_VALID_PTR(list); argh! Infinite loop in TypeOfMem() if called from ObtainSemaphoreShared() in FindMem()!
56 Make the node point to the head of the list. Our predecessor is the
57 previous last node of the list.
59 node->ln_Succ = (struct Node *)&list->lh_Tail;
60 node->ln_Pred = list->lh_TailPred;
63 Now we are the last now. Make the old last node point to us
64 and the pointer to the last node, too.
66 list->lh_TailPred->ln_Succ = node;
67 list->lh_TailPred = node;
68 AROS_LIBFUNC_EXIT
69 } /* AddTail */