Skip to content

Commit 9eea786

Browse files
authored
Merge pull request #355 from hannesbrandt/static
Do not mark functions in header files as 'static'.
2 parents 4071ac0 + 0c89437 commit 9eea786

20 files changed

Lines changed: 304 additions & 137 deletions

src/p4est.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4265,3 +4265,15 @@ p4est_source_ext (sc_io_source_t * src, sc_MPI_Comm mpicomm, size_t data_size,
42654265

42664266
return p4est;
42674267
}
4268+
4269+
/* definitions for inline functions */
4270+
p4est_tree_t *p4est_tree_array_index (sc_array_t * array,
4271+
p4est_topidx_t it);
4272+
p4est_quadrant_t *p4est_quadrant_array_index (sc_array_t * array,
4273+
size_t it);
4274+
p4est_quadrant_t *p4est_quadrant_array_push_copy (sc_array_t * array,
4275+
const p4est_quadrant_t *
4276+
qsrc);
4277+
p4est_quadrant_t *p4est_quadrant_array_push (sc_array_t * array);
4278+
p4est_quadrant_t *p4est_quadrant_mempool_alloc (sc_mempool_t * mempool);
4279+
p4est_quadrant_t *p4est_quadrant_list_pop (sc_list_t * list);

src/p4est.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,11 @@ p4est_t *p4est_load (const char *filename, sc_MPI_Comm mpicomm,
473473
p4est_connectivity_t ** connectivity);
474474

475475
/** Return a pointer to an array element indexed by a p4est_topidx_t.
476-
* \param [in] index needs to be in [0]..[elem_count-1].
476+
* \param [in] it needs to be in [0]..[elem_count-1].
477+
* \param [in] array Valid array, commonly the trees array of a
478+
* p4est.
477479
*/
478-
/*@unused@*/
479-
static inline p4est_tree_t *
480+
inline p4est_tree_t *
480481
p4est_tree_array_index (sc_array_t * array, p4est_topidx_t it)
481482
{
482483
P4EST_ASSERT (array->elem_size == sizeof (p4est_tree_t));
@@ -487,8 +488,7 @@ p4est_tree_array_index (sc_array_t * array, p4est_topidx_t it)
487488
}
488489

489490
/** Return a pointer to a quadrant array element indexed by a size_t. */
490-
/*@unused@*/
491-
static inline p4est_quadrant_t *
491+
inline p4est_quadrant_t *
492492
p4est_quadrant_array_index (sc_array_t * array, size_t it)
493493
{
494494
P4EST_ASSERT (array->elem_size == sizeof (p4est_quadrant_t));
@@ -505,7 +505,7 @@ p4est_quadrant_array_index (sc_array_t * array, size_t it)
505505
* This serves to make the function clean for valgrind.
506506
* \return Newly allocated quadrant with contents of \a qsrc.
507507
*/
508-
static inline p4est_quadrant_t *
508+
inline p4est_quadrant_t *
509509
p4est_quadrant_array_push_copy (sc_array_t * array,
510510
const p4est_quadrant_t *qsrc)
511511
{
@@ -524,8 +524,7 @@ p4est_quadrant_array_push_copy (sc_array_t * array,
524524
* In this case, we're writing to all bits of it.
525525
* This serves to make the quadrant clean for valgrind.
526526
*/
527-
/*@unused@*/
528-
static inline p4est_quadrant_t *
527+
inline p4est_quadrant_t *
529528
p4est_quadrant_array_push (sc_array_t * array)
530529
{
531530
p4est_quadrant_t *q;
@@ -538,8 +537,7 @@ p4est_quadrant_array_push (sc_array_t * array)
538537
}
539538

540539
/** Call sc_mempool_alloc for a mempool creating quadrants. */
541-
/*@unused@*/
542-
static inline p4est_quadrant_t *
540+
inline p4est_quadrant_t *
543541
p4est_quadrant_mempool_alloc (sc_mempool_t * mempool)
544542
{
545543
P4EST_ASSERT (mempool->elem_size == sizeof (p4est_quadrant_t));
@@ -548,8 +546,7 @@ p4est_quadrant_mempool_alloc (sc_mempool_t * mempool)
548546
}
549547

550548
/** Call sc_list pop for a quadrant array. */
551-
/*@unused@*/
552-
static inline p4est_quadrant_t *
549+
inline p4est_quadrant_t *
553550
p4est_quadrant_list_pop (sc_list_t * list)
554551
{
555552
return (p4est_quadrant_t *) sc_list_pop (list);

src/p4est_base.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,16 @@ p4est_version_minor (void)
150150
/* In rare cases SC_VERSION_MAJOR may be a non-numerical string */
151151
return sc_atoi (SC_TOSTRING (P4EST_VERSION_MINOR));
152152
}
153+
154+
/* definitions for inline functions */
155+
void p4est_log_indent_push (void);
156+
void p4est_log_indent_pop (void);
157+
unsigned p4est_topidx_hash2 (const p4est_topidx_t * tt);
158+
unsigned p4est_topidx_hash3 (const p4est_topidx_t * tt);
159+
unsigned p4est_topidx_hash4 (const p4est_topidx_t * tt);
160+
int p4est_topidx_is_sorted (p4est_topidx_t * t, int length);
161+
void p4est_topidx_bsort (p4est_topidx_t * t, int length);
162+
uint64_t p4est_partition_cut_uint64 (uint64_t global_num, int p,
163+
int num_procs);
164+
p4est_gloidx_t p4est_partition_cut_gloidx (p4est_gloidx_t global_num,
165+
int p, int num_procs);

src/p4est_base.h

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,15 @@ void P4EST_LERRORF (const char *fmt, ...)
325325
*/
326326
extern SC_DLL_PUBLIC int p4est_package_id;
327327

328-
static inline void
328+
/** Add one space to the start of p4est's default log format. */
329+
inline void
329330
p4est_log_indent_push (void)
330331
{
331332
sc_log_indent_push_count (p4est_package_id, 1);
332333
}
333334

334-
static inline void
335+
/** Remove one space from the start of p4est's default log format. */
336+
inline void
335337
p4est_log_indent_pop (void)
336338
{
337339
sc_log_indent_pop_count (p4est_package_id, 1);
@@ -377,8 +379,7 @@ int p4est_get_package_id (void);
377379
* \param [in] tt Array of (at least) two values.
378380
* \return An unsigned hash value.
379381
*/
380-
/*@unused@*/
381-
static inline unsigned
382+
inline unsigned
382383
p4est_topidx_hash2 (const p4est_topidx_t * tt)
383384
{
384385
uint32_t a, b, c;
@@ -403,8 +404,7 @@ p4est_topidx_hash2 (const p4est_topidx_t * tt)
403404
* \param [in] tt Array of (at least) three values.
404405
* \return An unsigned hash value.
405406
*/
406-
/*@unused@*/
407-
static inline unsigned
407+
inline unsigned
408408
p4est_topidx_hash3 (const p4est_topidx_t * tt)
409409
{
410410
uint32_t a, b, c;
@@ -431,8 +431,7 @@ p4est_topidx_hash3 (const p4est_topidx_t * tt)
431431
* \param [in] tt Array of (at least) four values.
432432
* \return An unsigned hash value.
433433
*/
434-
/*@unused@*/
435-
static inline unsigned
434+
inline unsigned
436435
p4est_topidx_hash4 (const p4est_topidx_t * tt)
437436
{
438437
uint32_t a, b, c;
@@ -460,8 +459,11 @@ p4est_topidx_hash4 (const p4est_topidx_t * tt)
460459
return (unsigned) c;
461460
}
462461

463-
/*@unused@*/
464-
static inline int
462+
/** Check if an array of p4est_topidx_t is sorted from lowest to highest.
463+
* \param [in] t Array of p4est_topidx_t.
464+
* \param [in] length The length of array \a t.
465+
* \return True, iff the array is correctly sorted. */
466+
inline int
465467
p4est_topidx_is_sorted (p4est_topidx_t * t, int length)
466468
{
467469
int i;
@@ -474,9 +476,11 @@ p4est_topidx_is_sorted (p4est_topidx_t * t, int length)
474476
return 1;
475477
}
476478

477-
/*@unused@*/
478-
static inline void
479-
p4est_topidx_bsort (p4est_topidx_t * t, int length)
479+
/** Sort an array of p4est_topidx_t from lowest to highest using bubble sort.
480+
* \param [in] t Array of p4est_topidx_t.
481+
* \param [in] length The length of array \a t. */
482+
inline void
483+
p4est_topidx_bsort (p4est_topidx_t *t, int length)
480484
{
481485
int i, j;
482486
p4est_topidx_t tswap;
@@ -495,8 +499,16 @@ p4est_topidx_bsort (p4est_topidx_t * t, int length)
495499
P4EST_ASSERT (p4est_topidx_is_sorted (t, length));
496500
}
497501

498-
/*@unused@*/
499-
static inline uint64_t
502+
/** For a uint64_t global number of elements return the offset of rank p in
503+
* their uniform partition.
504+
* \param [in] global_num The global number of elements to partition.
505+
* \param [in] p The rank in [0, \a num_procs] for which we compute the
506+
* offset.
507+
* \param [in] num_procs The total number of processes.
508+
* \return The index of the first element local to rank \a p in
509+
* in the uniform partition of the range
510+
* [0, \a global_num - 1]. */
511+
inline uint64_t
500512
p4est_partition_cut_uint64 (uint64_t global_num, int p, int num_procs)
501513
{
502514
uint64_t result;
@@ -522,8 +534,17 @@ p4est_partition_cut_uint64 (uint64_t global_num, int p, int num_procs)
522534
return result;
523535
}
524536

525-
/*@unused@*/
526-
static inline p4est_gloidx_t
537+
/** For a p4est_gloidxs_t global number of elements return the offset of rank p
538+
* in their uniform partition.
539+
* \param [in] global_num The global number of elements to partition.
540+
* \param [in] p The rank in [0, \a num_procs] for which we compute the
541+
* offset.
542+
* \param [in] num_procs The total number of processes.
543+
* \return The index of the first element local to rank \a p in
544+
* in the uniform partition of the range
545+
* [0, \a global_num - 1]. */
546+
547+
inline p4est_gloidx_t
527548
p4est_partition_cut_gloidx (p4est_gloidx_t global_num, int p, int num_procs)
528549
{
529550
p4est_gloidx_t result;

src/p4est_connectivity.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5945,3 +5945,7 @@ p4est_connectivity_coordinates_canonicalize (p4est_connectivity_t *conn,
59455945
P4EST_ASSERT (*treeid_out < treeid ||
59465946
p4est_coordinates_compare (coords_out, coords) <= 0);
59475947
}
5948+
5949+
/* definitions for inline functions */
5950+
p4est_corner_transform_t *p4est_corner_array_index (sc_array_t * array,
5951+
size_t it);

src/p4est_connectivity.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,8 +981,7 @@ int p4est_connectivity_is_equivalent (p4est_connectivity_t *
981981
conn2);
982982

983983
/** Return a pointer to a p4est_corner_transform_t array element. */
984-
/*@unused@*/
985-
static inline p4est_corner_transform_t *
984+
inline p4est_corner_transform_t *
986985
p4est_corner_array_index (sc_array_t * array, size_t it)
987986
{
988987
P4EST_ASSERT (array->elem_size == sizeof (p4est_corner_transform_t));

src/p4est_iterate.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3326,3 +3326,13 @@ p4est_iterate (p4est_t * p4est, p4est_ghost_t * Ghost_layer, void *user_data,
33263326
#endif
33273327
iter_corner, 0);
33283328
}
3329+
3330+
/* definitions for inline functions */
3331+
p4est_iter_corner_side_t *p4est_iter_cside_array_index_int (sc_array_t *
3332+
array, int it);
3333+
p4est_iter_corner_side_t *p4est_iter_cside_array_index (sc_array_t * array,
3334+
size_t it);
3335+
p4est_iter_face_side_t *p4est_iter_fside_array_index_int (sc_array_t * array,
3336+
int it);
3337+
p4est_iter_face_side_t *p4est_iter_fside_array_index (sc_array_t * array,
3338+
size_t it);

src/p4est_iterate.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,7 @@ void p4est_iterate (p4est_t * p4est,
246246

247247
/** Return a pointer to a iter_corner_side array element indexed by a int.
248248
*/
249-
/*@unused@*/
250-
static inline p4est_iter_corner_side_t *
249+
inline p4est_iter_corner_side_t *
251250
p4est_iter_cside_array_index_int (sc_array_t * array, int it)
252251
{
253252
P4EST_ASSERT (array->elem_size == sizeof (p4est_iter_corner_side_t));
@@ -259,8 +258,7 @@ p4est_iter_cside_array_index_int (sc_array_t * array, int it)
259258

260259
/** Return a pointer to a iter_corner_side array element indexed by a size_t.
261260
*/
262-
/*@unused@*/
263-
static inline p4est_iter_corner_side_t *
261+
inline p4est_iter_corner_side_t *
264262
p4est_iter_cside_array_index (sc_array_t * array, size_t it)
265263
{
266264
P4EST_ASSERT (array->elem_size == sizeof (p4est_iter_corner_side_t));
@@ -272,8 +270,7 @@ p4est_iter_cside_array_index (sc_array_t * array, size_t it)
272270

273271
/** Return a pointer to a iter_face_side array element indexed by a int.
274272
*/
275-
/*@unused@*/
276-
static inline p4est_iter_face_side_t *
273+
inline p4est_iter_face_side_t *
277274
p4est_iter_fside_array_index_int (sc_array_t * array, int it)
278275
{
279276
P4EST_ASSERT (array->elem_size == sizeof (p4est_iter_face_side_t));
@@ -285,8 +282,7 @@ p4est_iter_fside_array_index_int (sc_array_t * array, int it)
285282

286283
/** Return a pointer to a iter_face_side array element indexed by a size_t.
287284
*/
288-
/*@unused@*/
289-
static inline p4est_iter_face_side_t *
285+
inline p4est_iter_face_side_t *
290286
p4est_iter_fside_array_index (sc_array_t * array, size_t it)
291287
{
292288
P4EST_ASSERT (array->elem_size == sizeof (p4est_iter_face_side_t));

src/p4est_lnodes.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3719,3 +3719,19 @@ p4est_lnodes_buffer_destroy (p4est_lnodes_buffer_t * buffer)
37193719
}
37203720
P4EST_FREE (buffer);
37213721
}
3722+
3723+
/* definitions for inline functions */
3724+
#ifndef P4_TO_P8
3725+
int p4est_lnodes_decode (p4est_lnodes_code_t face_code,
3726+
int hanging_face[4]);
3727+
#else
3728+
int p8est_lnodes_decode (p8est_lnodes_code_t face_code,
3729+
int hanging_face[6],
3730+
int hanging_edge[12]);
3731+
#endif
3732+
p4est_lnodes_rank_t *p4est_lnodes_rank_array_index_int (sc_array_t * array,
3733+
int it);
3734+
p4est_lnodes_rank_t *p4est_lnodes_rank_array_index (sc_array_t * array,
3735+
size_t it);
3736+
p4est_gloidx_t p4est_lnodes_global_index (p4est_lnodes_t * lnodes,
3737+
p4est_locidx_t lidx);

src/p4est_lnodes.h

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ p4est_lnodes_rank_t;
197197
* note: not touched if there are no hanging faces.
198198
* \return true if any face is hanging, false otherwise.
199199
*/
200-
static inline int
200+
inline int
201201
p4est_lnodes_decode (p4est_lnodes_code_t face_code, int hanging_face[4])
202202
{
203203
P4EST_ASSERT (face_code >= 0);
@@ -335,12 +335,16 @@ p4est_lnodes_buffer_t *p4est_lnodes_share_owned_begin (sc_array_t * node_data,
335335
p4est_lnodes_t *
336336
lnodes);
337337

338+
/** p4est_lnodes_shared_owned_end
339+
*
340+
* Complete sharing of the owned node data between processes as initiated in
341+
* \ref p4est_lnodes_share_owned_begin. */
338342
void p4est_lnodes_share_owned_end (p4est_lnodes_buffer_t *
339343
buffer);
340344

341-
/** Equivalent to calling p4est_lnodes_share_owned_end directly after
342-
* p4est_lnodes_share_owned_begin. Use if there is no local work that can be
343-
* done to mask the communication cost.
345+
/** Equivalent to calling \ref p4est_lnodes_share_owned_end directly after
346+
* \ref p4est_lnodes_share_owned_begin. Use if there is no local work that can
347+
* be done to mask the communication cost.
344348
*/
345349
void p4est_lnodes_share_owned (sc_array_t * node_data,
346350
p4est_lnodes_t * lnodes);
@@ -354,7 +358,7 @@ void p4est_lnodes_share_owned (sc_array_t * node_data,
354358
* \a buffer->recv_buffers entry as described above. The user can then perform
355359
* some arbitrary work that requires the data from all processes that share a
356360
* node (such as reduce, max, min, etc.). When the work concludes, the
357-
* \a buffer should be destroyed with p4est_lnodes_buffer_destroy.
361+
* \a buffer should be destroyed with \ref p4est_lnodes_buffer_destroy.
358362
*
359363
* Values of \a node_data are not guaranteed to be sent, and
360364
* \a buffer->recv_buffer entries are not guaranteed to be received until
@@ -364,26 +368,31 @@ void p4est_lnodes_share_owned (sc_array_t * node_data,
364368
p4est_lnodes_buffer_t *p4est_lnodes_share_all_begin (sc_array_t * node_data,
365369
p4est_lnodes_t * lnodes);
366370

371+
/** p4est_lnodes_shared_all_end
372+
*
373+
* Complete sharing of the node data between all relevant processes as initiated
374+
* in \ref p4est_lnodes_share_all_begin. */
367375
void p4est_lnodes_share_all_end (p4est_lnodes_buffer_t *
368376
buffer);
369377

370-
/** Equivalent to calling p4est_lnodes_share_all_end directly after
371-
* p4est_lnodes_share_all_begin. Use if there is no local work that can be
378+
/** Equivalent to calling \ref p4est_lnodes_share_all_end directly after
379+
* \ref p4est_lnodes_share_all_begin. Use if there is no local work that can be
372380
* done to mask the communication cost.
373381
* \return A fully initialized buffer that contains the received data.
374382
* After processing this data, the buffer must be freed with
375-
* p4est_lnodes_buffer_destroy.
383+
* \ref p4est_lnodes_buffer_destroy.
376384
*/
377385
p4est_lnodes_buffer_t *p4est_lnodes_share_all (sc_array_t * node_data,
378386
p4est_lnodes_t * lnodes);
379387

388+
/** Destroy the buffer filled with node data during a call to
389+
* \ref p4est_lnodes_share_all_end or \ref p4est_lnodes_share_all.*/
380390
void p4est_lnodes_buffer_destroy (p4est_lnodes_buffer_t *
381391
buffer);
382392

383393
/** Return a pointer to a lnodes_rank array element indexed by a int.
384394
*/
385-
/*@unused@*/
386-
static inline p4est_lnodes_rank_t *
395+
inline p4est_lnodes_rank_t *
387396
p4est_lnodes_rank_array_index_int (sc_array_t * array, int it)
388397
{
389398
P4EST_ASSERT (array->elem_size == sizeof (p4est_lnodes_rank_t));
@@ -395,8 +404,7 @@ p4est_lnodes_rank_array_index_int (sc_array_t * array, int it)
395404

396405
/** Return a pointer to a lnodes_rank array element indexed by a size_t.
397406
*/
398-
/*@unused@*/
399-
static inline p4est_lnodes_rank_t *
407+
inline p4est_lnodes_rank_t *
400408
p4est_lnodes_rank_array_index (sc_array_t * array, size_t it)
401409
{
402410
P4EST_ASSERT (array->elem_size == sizeof (p4est_lnodes_rank_t));
@@ -407,8 +415,7 @@ p4est_lnodes_rank_array_index (sc_array_t * array, size_t it)
407415
}
408416

409417
/** Compute the global number of a local node number */
410-
/*@unused@*/
411-
static inline p4est_gloidx_t
418+
inline p4est_gloidx_t
412419
p4est_lnodes_global_index (p4est_lnodes_t * lnodes, p4est_locidx_t lidx)
413420
{
414421
p4est_locidx_t owned = lnodes->owned_count;

0 commit comments

Comments
 (0)