14
14
#include <stdint.h> /* For uint16_t, UINT64_MAX etc. */
15
15
#include <stdlib.h> /* For size_t */
16
16
17
+ #ifdef CONFIG_MEM_TRACE
18
+ #include <stdio.h>
19
+ #endif
20
+
17
21
/**
18
22
* @addtogroup error
19
23
* @{
@@ -169,8 +173,18 @@ typedef struct ssm_trigger {
169
173
*
170
174
* @throws SSM_EXHAUSTED_MEMORY out of memory.
171
175
*/
172
- ssm_act_t * ssm_enter (size_t size , ssm_stepf_t step , ssm_act_t * parent ,
173
- ssm_priority_t priority , ssm_depth_t depth );
176
+ ssm_act_t * ssm_enter_int (size_t size , ssm_stepf_t step , ssm_act_t * parent ,
177
+ ssm_priority_t priority , ssm_depth_t depth );
178
+
179
+ #ifdef CONFIG_MEM_TRACE
180
+ #define ssm_enter (si , st , pa , pr , de ) \
181
+ (fprintf(stderr, "%s:%d:ssm_enter(%lu,_,_,_,_,_)\n", __FILE__, __LINE__, \
182
+ (si)), \
183
+ ssm_enter_int((si), (st), (pa), (pr), (de)))
184
+ #else
185
+ #define ssm_enter (si , st , pa , pr , de ) \
186
+ ssm_enter_int((si), (st), (pa), (pr), (de))
187
+ #endif
174
188
175
189
/** @brief Destroy the activation record of a routine before leaving.
176
190
*
@@ -426,8 +440,17 @@ ssm_time_t ssm_now(void);
426
440
*
427
441
* @param time what the heap-allocated @a time field is initialized to.
428
442
* @returns #ssm_value_t pointing to the heap-allocated #ssm_time.
443
+ *
444
+ * ssm_value_t ssm_new_time(ssm_time_t time)
429
445
*/
430
- ssm_value_t ssm_new_time (ssm_time_t time );
446
+ extern ssm_value_t ssm_new_time_int (ssm_time_t time );
447
+ #ifdef CONFIG_MEM_TRACE
448
+ #define ssm_new_time (t ) \
449
+ (fprintf(stderr, "%s:%d:ssm_new_time()\n", __FILE__, __LINE__), \
450
+ ssm_new_time_int(t))
451
+ #else
452
+ #define ssm_new_time (t ) ssm_new_time_int(t)
453
+ #endif
431
454
432
455
/** @brief Read the heap-allocated time pointed to by an #ssm_value_t.
433
456
*
@@ -483,7 +506,16 @@ struct ssm_adt1 {
483
506
* @param tag the tag of the ADT object, stored in the #ssm_mm header.
484
507
* @returns #ssm_value_t poining to the ADT object on the heap.
485
508
*/
486
- ssm_value_t ssm_new_adt (uint8_t field_count , uint8_t tag );
509
+ extern ssm_value_t ssm_new_adt_int (uint8_t field_count , uint8_t tag );
510
+
511
+ #ifdef CONFIG_MEM_TRACE
512
+ #define ssm_new_adt (fc , tag ) \
513
+ (fprintf(stderr, "%s:%d:ssm_new_adt(%d, %d)\n", __FILE__, __LINE__, (fc), \
514
+ (tag)), \
515
+ ssm_new_adt_int((fc), (tag)))
516
+ #else
517
+ #define ssm_new_adt (fc , tag ) ssm_new_adt_int((fc), (tag))
518
+ #endif
487
519
488
520
/** @brief Access the field of an ADT object.
489
521
*
@@ -572,7 +604,14 @@ typedef struct ssm_sv {
572
604
* @param val the initial value of the scheduled variable.
573
605
* @returns #ssm_value_t pointing to the #ssm_sv on the heap.
574
606
*/
575
- ssm_value_t ssm_new_sv (ssm_value_t val );
607
+ extern ssm_value_t ssm_new_sv_int (ssm_value_t val );
608
+ #ifdef CONFIG_MEM_TRACE
609
+ #define ssm_new_sv (v ) \
610
+ (fprintf(stderr, "%s:%d:ssm_new_sv()\n", __FILE__, __LINE__), \
611
+ ssm_new_sv_int(v))
612
+ #else
613
+ #define ssm_new_sv (v ) ssm_new_sv_int(v)
614
+ #endif
576
615
577
616
/** @brief Retrieve #ssm_sv pointer pointed to by an #ssm_value_t.
578
617
*
@@ -837,7 +876,15 @@ struct ssm_closure1 {
837
876
* @param arg_cap the number of arguments the closure should accommodate.
838
877
* @returns a value pointing to the heap-allocated closure.
839
878
*/
840
- ssm_value_t ssm_new_closure (ssm_func_t f , uint8_t arg_cap );
879
+ extern ssm_value_t ssm_new_closure_int (ssm_func_t f , uint8_t arg_cap );
880
+ #ifdef CONFIG_MEM_TRACE
881
+ #define ssm_new_closure (f , args ) \
882
+ (fprintf(stderr, "%s:%d:ssm_new_closure(_, %d)\n", __FILE__, __LINE__, \
883
+ (args)), \
884
+ ssm_new_closure_int((f), (args)))
885
+ #else
886
+ #define ssm_new_closure (f , args ) ssm_new_closure_int((f), (args))
887
+ #endif
841
888
842
889
/** @brief Create a copy of a closure.
843
890
*
@@ -999,7 +1046,16 @@ struct ssm_array1 {
999
1046
* @param count number of #ssm_value_t elements to be stored in the array.
1000
1047
* @returns #ssm_value_t pointing to heap-allocated array.
1001
1048
*/
1002
- ssm_value_t ssm_new_array (uint16_t count );
1049
+
1050
+ extern ssm_value_t ssm_new_array_int (uint16_t count );
1051
+ #ifdef CONFIG_MEM_TRACE
1052
+ #define ssm_new_array (c ) \
1053
+ (fprintf(stderr,"%s:%d:ssm_new_array(%d)\n", \
1054
+ __FILE__, __LINE__, (c)), \
1055
+ ssm_new_array_int(c)
1056
+ #else
1057
+ #define ssm_new_array (c ) ssm_new_array_int(c)
1058
+ #endif
1003
1059
1004
1060
/** @} */
1005
1061
@@ -1048,7 +1104,8 @@ struct ssm_blob1 {
1048
1104
* @param size scaled size of the blob's payload.
1049
1105
* @returns size that a blob of @a size payload occupies in the heap.
1050
1106
*/
1051
- #define ssm_blob_size (size ) (sizeof(struct ssm_blob1) + (size)-SSM_BLOB_SIZE_SCALE)
1107
+ #define ssm_blob_size (size ) \
1108
+ (sizeof(struct ssm_blob1) - SSM_BLOB_SIZE_SCALE + (size))
1052
1109
1053
1110
/** @brief Compute the size a blob in the heap.
1054
1111
*
@@ -1067,7 +1124,14 @@ struct ssm_blob1 {
1067
1124
* @param size size of the payload to the allocated.
1068
1125
* @returns #ssm_value_t pointing to heap-allocated blob.
1069
1126
*/
1070
- ssm_value_t ssm_new_blob (uint16_t size );
1127
+ extern ssm_value_t ssm_new_blob_int (uint16_t size );
1128
+ #ifdef CONFIG_MEM_TRACE
1129
+ #define ssm_new_blob (s ) \
1130
+ (fprintf(stderr, "%s:%d:ssm_new_blob(%lu)\n", __FILE__, __LINE__, (size)), \
1131
+ ssm_new_blob_int(size))
1132
+ #else
1133
+ #define ssm_new_blob (s ) ssm_new_blob_int(s)
1134
+ #endif
1071
1135
1072
1136
/** @} */
1073
1137
0 commit comments