Skip to content

Commit

Permalink
little formal changes
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonidGoltsblat committed Dec 13, 2024
1 parent bb1307d commit 9841571
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
11 changes: 5 additions & 6 deletions pjlib/include/pj/stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@

#endif // PJ_STACK_IMPLEMENTATION

#include <pj/stack.h>


PJ_BEGIN_DECL

Expand All @@ -64,7 +62,7 @@ PJ_BEGIN_DECL
* Stack in PJLIB is single-linked list with First In Last Out logic.
* Stack is thread safe. Common PJLIB stack implementation uses internal locking mechanism so is thread-safe.
* Implementation for Windows platform uses locking free Windows embeded single linked list implementation.
* The performance of pj_stack implementation for Windows platform is 2-5x higher than cross-platform.
* The performance of pj_stack implementation for Windows platform is considerably higher than cross-platform.
*
* By default pjlib compile and link os independent "cross-platform" implementation.
* To select implementation you may optionaly define PJ_STACK_IMPLEMENTATION as PJ_STACK_WIN32
Expand All @@ -77,13 +75,14 @@ PJ_BEGIN_DECL
*
* Windows single linked list implementation requires aligned data, both stack item and stack itself should
* be aligned by 8 (for x86) or 16 (for x64) byte.
* pjsip build system define PJ_POOL_ALIGNMENT macro to corresponding value.
* winnt.h define MEMORY_ALLOCATION_ALIGNMENT macro for this purpose.
* To use this macro in build system we recomend (this is optional) to add #include <windows.h>
* to your config_site.h.
* pjsip build system define PJ_POOL_ALIGNMENT macro to corresponding value.
* You may redefine PJ_POOL_ALIGNMENT in your config_site.h but to use PJ_STACK_WIN32 implementation
* PJ_POOL_ALIGNMENTshould not be less then MEMORY_ALLOCATION_ALIGNMENT
*
* To use MEMORY_ALLOCATION_ALIGNMENT macro in build system we recomend (this is optional) to add
* #include <windows.h> to your config_site.h.
*
* Stack won't require dynamic memory allocation (just as all PJLIB data structures). The stack here
* should be viewed more like a low level C stack instead of high level C++ stack
* (which normally are easier to use but require dynamic memory allocations),
Expand Down
6 changes: 0 additions & 6 deletions pjlib/src/pj/stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,6 @@ PJ_DEF(pj_stack_t*) pj_stack_pop(pj_stack_type *stack)
* Traverse the stack and get it's elements quantity.
* The return value of pj_stack_size should not be relied upon in multithreaded applications
* because the item count can be changed at any time by another thread.
* For Windows platform returns the number of entries in the stack modulo 65535. For example,
* if the specified stack contains 65536 entries, pj_stack_size returns zero.
*
* @param stack The target stack.
*
* @return Number of elements.
*/
PJ_DEF(pj_size_t) pj_stack_size(/*const*/ pj_stack_type *stack)
{
Expand Down
4 changes: 0 additions & 4 deletions pjlib/src/pj/stack_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@ PJ_DEF(pj_stack_t*) pj_stack_pop(pj_stack_type *stack)
* because the item count can be changed at any time by another thread.
* For Windows platform returns the number of entries in the stack modulo 65535. For example,
* if the specified stack contains 65536 entries, pj_stack_size returns zero.
*
* @param stack The target stack.
*
* @return Number of elements.
*/
PJ_DEF(pj_size_t) pj_stack_size(/*const*/ pj_stack_type *stack)
{
Expand Down
11 changes: 11 additions & 0 deletions pjlib/src/pjlib-test/stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@

#endif

/* define this variable to control multithreaded testing for other platforms */
#ifndef HAS_MT_STACK_STRESS_TEST
# ifdef PJ_WIN32
# define HAS_MT_STACK_STRESS_TEST 1
# endif
# define HAS_MT_STACK_STRESS_TEST 0
# endif
#endif

#define THIS_FILE "stack.c"
#define MAX_RESERVED 16
#define MAX_SLOTS 100
Expand Down Expand Up @@ -215,10 +224,12 @@ int stack_test()
rc = -55;
}

#ifdef HAS_MT_STACK_STRESS_TEST
for (i = 0; !rc && i < PJ_ARRAY_SIZE(tests); ++i) {
tests[i].state.pool = pool;
rc = stack_stress_test(&tests[i]);
}
#endif //HAS_MT_STACK_STRESS_TEST

if (pool)
pj_pool_release(pool);
Expand Down

0 comments on commit 9841571

Please sign in to comment.