2 #include "libtest_porting_abstraction_layer_internal.h"
4 /* TRD : libtest_pal_malloc() and libtest_pal_free() are used for and only for
7 if either is not implemented, the test will not run
9 that's the only impact of their presence or absence
16 /****************************************************************************/
17 #if( defined _MSC_VER )
19 /* TRD : MSVC compiler
21 an unfortunately necessary hack for MSVC
22 MSVC only defines __STDC__ if /Za is given, where /Za turns off MSVC C extensions -
23 which prevents Windows header files from compiling.
27 #define __STDC_HOSTED__ 1
34 /****************************************************************************/
35 #if( defined __STDC__ && defined __STDC_HOSTED__ && __STDC_HOSTED__ == 1 && !defined KERNEL_MODE )
37 #ifdef LIBTEST_PAL_MALLOC
38 #error More than one porting abstraction layer matches the current platform in "libtest_porting_abstraction_layer_malloc.c".
41 #define LIBTEST_PAL_MALLOC
43 void *libtest_pal_malloc( lfds710_pal_uint_t size )
48 // TRD : size can be any value in its range
50 rv = malloc( (size_t) size );
61 /****************************************************************************/
62 #if( defined _WIN32 && defined KERNEL_MODE )
64 #ifdef LIBTEST_PAL_MALLOC
65 #error More than one porting abstraction layer matches the current platform in "libtest_porting_abstraction_layer_malloc.c".
68 #define LIBTEST_PAL_MALLOC
70 void *libtest_pal_malloc( lfds710_pal_uint_t size )
75 // TRD : size can be any value in its range
77 /* TRD : if it assumed if lock-free data structures are being used
78 it is because they will be accessed at DISPATCH_LEVEL
79 and so the hard coded memory type is NonPagedPool
82 rv = ExAllocatePoolWithTag( NonPagedPool, size, 'sdfl' );
94 /****************************************************************************/
95 #if( defined __linux__ && defined KERNEL_MODE )
97 #ifdef LIBTEST_PAL_MALLOC
98 #error More than one porting abstraction layer matches the current platform in "libtest_porting_abstraction_layer_malloc.c".
101 #define LIBTEST_PAL_MALLOC
103 void *libtest_pal_malloc( lfds710_pal_uint_t size )
108 // TRD : size can be any value in its range
110 rv = vmalloc( (int long unsigned) size );
121 /****************************************************************************/
122 #if( !defined LIBTEST_PAL_MALLOC )
124 void *libtest_pal_malloc( lfds710_pal_uint_t size )
126 // TRD : size can be any value in its range