]> pd.if.org Git - liblfds/blob - liblfds/liblfds7.1.0/test_and_benchmark/libtest/src/libtest_porting_abstraction_layer/libtest_porting_abstraction_layer_malloc.c
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds7.1.0 / test_and_benchmark / libtest / src / libtest_porting_abstraction_layer / libtest_porting_abstraction_layer_malloc.c
1 /***** includes *****/
2 #include "libtest_porting_abstraction_layer_internal.h"
3
4 /* TRD : libtest_pal_malloc() and libtest_pal_free() are used for and only for
5          one queue_umm test
6
7          if either is not implemented, the test will not run
8
9          that's the only impact of their presence or absence
10 */
11
12
13
14
15
16 /****************************************************************************/
17 #if( defined _MSC_VER )
18
19   /* TRD : MSVC compiler
20
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.
24   */
25
26   #define __STDC__         1
27   #define __STDC_HOSTED__  1
28 #endif
29
30
31
32
33
34 /****************************************************************************/
35 #if( defined __STDC__ && defined __STDC_HOSTED__ && __STDC_HOSTED__ == 1 && !defined KERNEL_MODE )
36
37   #ifdef LIBTEST_PAL_MALLOC
38     #error More than one porting abstraction layer matches the current platform in "libtest_porting_abstraction_layer_malloc.c".
39   #endif
40
41   #define LIBTEST_PAL_MALLOC
42
43   void *libtest_pal_malloc( lfds710_pal_uint_t size )
44   {
45     void
46       *rv;
47
48     // TRD : size can be any value in its range
49
50     rv = malloc( (size_t) size );
51
52     return rv;
53   }
54
55 #endif
56
57
58
59
60
61 /****************************************************************************/
62 #if( defined _WIN32 && defined KERNEL_MODE )
63
64   #ifdef LIBTEST_PAL_MALLOC
65     #error More than one porting abstraction layer matches the current platform in "libtest_porting_abstraction_layer_malloc.c".
66   #endif
67
68   #define LIBTEST_PAL_MALLOC
69
70   void *libtest_pal_malloc( lfds710_pal_uint_t size )
71   {
72     void
73       *rv;
74
75     // TRD : size can be any value in its range
76
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
80     */
81
82     rv = ExAllocatePoolWithTag( NonPagedPool, size, 'sdfl' );
83
84     return rv;
85   }
86
87 #endif
88
89
90
91
92
93
94 /****************************************************************************/
95 #if( defined __linux__ && defined KERNEL_MODE )
96
97   #ifdef LIBTEST_PAL_MALLOC
98     #error More than one porting abstraction layer matches the current platform in "libtest_porting_abstraction_layer_malloc.c".
99   #endif
100
101   #define LIBTEST_PAL_MALLOC
102
103   void *libtest_pal_malloc( lfds710_pal_uint_t size )
104   {
105     void
106       *rv;
107
108     // TRD : size can be any value in its range
109
110     rv = vmalloc( (int long unsigned) size );
111
112     return rv;
113   }
114
115 #endif
116
117
118
119
120
121 /****************************************************************************/
122 #if( !defined LIBTEST_PAL_MALLOC )
123
124   void *libtest_pal_malloc( lfds710_pal_uint_t size )
125   {
126     // TRD : size can be any value in its range
127
128     return NULL;
129   }
130
131 #endif
132