Multi-ApplicationOnlineProfiling  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Buffered_LIFO.h
Go to the documentation of this file.
1 /* ############################ MALP License ############################## */
2 /* # Fri Jan 18 14:00:00 CET 2013 # */
3 /* # Copyright or (C) or Copr. Commissariat a l'Energie Atomique # */
4 /* # # */
5 /* # This software is governed by the CeCILL-C license under French law # */
6 /* # and abiding by the rules of distribution of free software. You can # */
7 /* # use, modify and/ or redistribute the software under the terms of # */
8 /* # the CeCILL-C license as circulated by CEA, CNRS and INRIA at the # */
9 /* # following URL http://www.cecill.info. # */
10 /* # # */
11 /* # The fact that you are presently reading this means that you have # */
12 /* # had knowledge of the CeCILL-C license and that you accept its # */
13 /* # terms. # */
14 /* # # */
15 /* # Authors: # */
16 /* # - BESNARD Jean-Baptiste jean-baptiste.besnard@cea.fr # */
17 /* # # */
18 /* ######################################################################## */
19 #ifndef BUFFERED_LIFO_H
20 #define BUFFERED_LIFO_H
21 
33 #ifdef __cplusplus
34  extern "C"
35  {
36 #endif
37 
38 
39 #include <stdint.h>
40 #include <stdlib.h>
41 #include "Spinlock.h"
42 
51 {
52  uint64_t offset;
54  char elems[0];
55 };
56 
64 struct Buffered_LIFO_chunk * Buffered_LIFO_chunk_new( size_t sizeof_payload, uint64_t chunk_size, struct Buffered_LIFO_chunk * prev );
65 
72 void Buffered_LIFO_chunk_release( struct Buffered_LIFO_chunk * chunk, size_t sizeof_payload, void (*free_func)( void *) );
73 
82  void * elem, size_t sizeof_payload, uint64_t chunk_size );
83 
93  size_t sizeof_payload, uint64_t chunk_size,
94  void * elem, int *did_ret );
100 void * Buffered_LIFO_chunk_head( struct Buffered_LIFO_chunk * chunk, size_t sizeof_payload );
101 
114 {
115  size_t sizeof_payload;
116  uint64_t chunk_size;
121 };
122 
128 void Buffered_LIFO_init( struct Buffered_LIFO *lifo, size_t sizeof_payload, uint64_t chunk_size );
129 
136 void Buffered_LIFO_release( struct Buffered_LIFO *lifo, void (*free_func)( void *) );
137 
143 void Buffered_LIFO_push( struct Buffered_LIFO *lifo, void * elem );
144 
151 void * Buffered_LIFO_pop( struct Buffered_LIFO *lifo, void * elem );
152 
161 void * Buffered_LIFO_head( struct Buffered_LIFO *lifo );
162 
171 void * Buffered_LIFO_head_locked( struct Buffered_LIFO *lifo );
172 
177 void Buffered_LIFO_head_unlock( struct Buffered_LIFO *lifo );
178 
179 #ifdef __cplusplus
180  }
181 #endif
182 
183 #endif /* BUFFERED_LIFO_H */
184 
uint64_t offset
offset in current chunk
Definition: Buffered_LIFO.h:52
struct Buffered_LIFO_chunk * Buffered_LIFO_chunk_pop(struct Buffered_LIFO_chunk *chunk, size_t sizeof_payload, uint64_t chunk_size, void *elem, int *did_ret)
Get an element from the Buffered_LIFO_chunk.
Definition: Buffered_LIFO.c:88
size_t sizeof_payload
Sizeof a payload element.
Structure defining a chunk of LIFO. A buffered lifo consists in several chunks which are stacked in a...
Definition: Buffered_LIFO.h:50
struct Buffered_LIFO_chunk * next
A pointer to the next chunk (NULL if none)
Definition: Buffered_LIFO.h:53
void Buffered_LIFO_head_unlock(struct Buffered_LIFO *lifo)
Unlocks the Buffered_LIFO after a call to Buffered_LIFO_head.
void * Buffered_LIFO_head(struct Buffered_LIFO *lifo)
Get a reference to the head element of the Buffered_LIFO note that as no lock is held this reference ...
void Buffered_LIFO_push(struct Buffered_LIFO *lifo, void *elem)
Push an element of size sizeof_payload in the Buffered_LIFO.
struct Buffered_LIFO_chunk * Buffered_LIFO_chunk_new(size_t sizeof_payload, uint64_t chunk_size, struct Buffered_LIFO_chunk *prev)
Allocates an empty Buffered_LIFO_chunk pointing to prev.
Definition: Buffered_LIFO.c:23
char elems[0]
A dummy pointer to the data which is piggybacked.
Definition: Buffered_LIFO.h:54
void Buffered_LIFO_chunk_release(struct Buffered_LIFO_chunk *chunk, size_t sizeof_payload, void(*free_func)(void *))
Releases a Buffered_LIFO_chunk note that it does not recurses over previous chunks.
Definition: Buffered_LIFO.c:39
volatile unsigned int MALP_Spinlock
The type of spinlocks in MALP.
Definition: Spinlock.h:63
void * Buffered_LIFO_pop(struct Buffered_LIFO *lifo, void *elem)
Push an element of size sizeof_payload in the Buffered_LIFO.
void Buffered_LIFO_release(struct Buffered_LIFO *lifo, void(*free_func)(void *))
Releases a Buffered_LIFO and all its chunks.
uint64_t chunk_size
Maximum number of elems in a chunk.
void Buffered_LIFO_init(struct Buffered_LIFO *lifo, size_t sizeof_payload, uint64_t chunk_size)
Initializes a Buffered_LIFO ready to contains elems of size sizeof_payload with chunk_size chunks...
void * Buffered_LIFO_chunk_head(struct Buffered_LIFO_chunk *chunk, size_t sizeof_payload)
Get a pointer to the Buffered_LIFO_chunk head eleme (NULL if none)
MALP_Spinlock lock
A spinlock to protect the LIFO.
struct Buffered_LIFO_chunk * Buffered_LIFO_chunk_push(struct Buffered_LIFO_chunk *chunk, void *elem, size_t sizeof_payload, uint64_t chunk_size)
Push a new elem in the Buffered_LIFO_chunk.
Definition: Buffered_LIFO.c:62
void * Buffered_LIFO_head_locked(struct Buffered_LIFO *lifo)
Get a reference to the head element of the Buffered_LIFO but keeps the LIFO locked in order to allow ...
Structure defining buffered LIFO.
struct Buffered_LIFO_chunk * head
A pointer to the first chunk.