hppa: Always enable PIE on 64-bit target
[official-gcc.git] / libobjc / objc-private / objc-list.h
blob44c5f0d092b037bc1cf260903bb65a37dcdea0b5
1 /* Generic single linked list to keep various information
2 Copyright (C) 1993-2024 Free Software Foundation, Inc.
3 Contributed by Kresten Krab Thorup.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 <http://www.gnu.org/licenses/>. */
26 #ifndef __GNU_OBJC_LIST_H
27 #define __GNU_OBJC_LIST_H
29 struct objc_list
31 void *head;
32 struct objc_list *tail;
35 /* Return a cons cell produced from (head . tail). */
36 static inline struct objc_list*
37 list_cons (void* head, struct objc_list* tail)
39 struct objc_list* cell;
41 cell = (struct objc_list*)objc_malloc (sizeof (struct objc_list));
42 cell->head = head;
43 cell->tail = tail;
44 return cell;
47 /* Remove the element at the head by replacing it by its
48 successor. */
49 static inline void
50 list_remove_head (struct objc_list** list)
52 if ((*list)->tail)
54 /* Fetch next. */
55 struct objc_list* tail = (*list)->tail;
57 /* Copy next to list head. */
58 *(*list) = *tail;
60 /* Free next. */
61 objc_free (tail);
63 else
65 /* Inly one element in list. */
66 objc_free (*list);
67 (*list) = 0;
72 /* Map FUNCTION over all elements in LIST. */
73 static inline void
74 list_mapcar (struct objc_list* list, void(*function)(void*))
76 while (list)
78 (*function) (list->head);
79 list = list->tail;
83 /* Free list (backwards recursive). */
84 static inline void
85 list_free (struct objc_list* list)
87 if(list)
89 list_free (list->tail);
90 objc_free (list);
94 #endif /* not __GNU_OBJC_LIST_H */