20 vfprintf(stdout, fmt, ap);
30 vfprintf(stdout, fmt, ap);
44 while (temp->
next != 0) {
53 if (ret >= 0 && (
unsigned)ret <
sizeof(out->
message)) {
64tw_printf(
const char *file,
int line,
const char *fmt, ...)
69 fprintf(stdout,
"%s:%i: ", file, line);
70 vfprintf(stdout, fmt, ap);
71 fprintf(stdout,
"\n");
77tw_error(
const char *file,
int line,
const char *fmt, ...)
82 fprintf(stdout,
"node: %ld: error: %s:%i: ",
g_tw_mynode, file, line);
83 vfprintf(stdout, fmt, ap);
84 fprintf(stdout,
"\n");
93tw_warning(
const char *file,
int line,
const char *fmt, ...)
98 fprintf(stdout,
"node: %ld: warning: %s:%i: ",
g_tw_mynode, file, line);
99 vfprintf(stdout, fmt, ap);
100 fprintf(stdout,
"\n");
125 size_t *bytes_wasted)
130 *bytes_wasted =
malloc_calls * (
sizeof(
void*) +
sizeof(
size_t));
138#ifdef ROSS_ALLOC_DEBUG
148 void *r = calloc(e_sz, n);
152 "Cannot allocate %lu bytes for %u %s",
186 p->
next_free = (
char *)((
size_t)32 + (
size_t)p);
187 if( 7 & (
size_t)(p->next_free) )
188 printf(
"pool_alloc: WARNING found pool start address (%p) NOT 8 byte aligned\n", p->next_free);
196 if( 7 & (
size_t)r || 7 & (
size_t)(p->
next_free) )
197 printf(
"pool_alloc: WARNING found return ptr (%p) or next_free (%p) NOT 8 bytes aligned\n", r, p->
next_free );
229 "Cannot allocate %lu bytes for %u %s"
230 " (need total of %lu KiB)",
266 fprintf(output,
"%s| hex output | bin output \n", prefix);
268 char output_line[70];
270 for (
int j = 0; j < 69; j++) {
271 output_line[j] =
' ';
273 output_line[0] =
'|';
274 output_line[50] =
'|';
275 output_line[68] =
'\n';
276 output_line[69] =
'\0';
278 char hexline[] =
"0123456789ABCDEF";
283 int const line_size = i + 16 <= size ? 16 : size - i;
286 for (; j < line_size; j++) {
287 char const val = ((
char *) array)[i+j];
288 output_line[j*3+2] = hexline[(val >> 4) & 0xF];
289 output_line[j*3+3] = hexline[val & 0xF];
290 output_line[j+52] = isprint(val) ? val :
'.';
293 for (; j < 16; j++) {
294 output_line[j*3+2] =
' ';
295 output_line[j*3+3] =
' ';
296 output_line[j+52] =
' ';
298 fprintf(output,
"%s%s", prefix, output_line);
tw_synch g_tw_synchronization_protocol
tw_out * tw_kp_grab_output_buffer(tw_kp *kp)
@ SEQUENTIAL_ROLLBACK_CHECK
struct mem_pool * next_pool
tw_out * out_msgs
Output messages.
tw_kpid id
ID number, otherwise its not available to the app.
tw_kp * kp
kp – Kernel process that we belong to (must match pe).
Rollback-aware output mechanism.
char message[256 - 2 *sizeof(void *)]
tw_event * cur_event
Current event being processed.
void * tw_calloc(const char *file, int line, const char *for_who, size_t e_sz, size_t n)
static unsigned malloc_calls
static void * my_malloc(size_t len)
static const size_t pool_align
void tw_calloc_stats(size_t *bytes_alloc, size_t *bytes_wasted)
static size_t total_allocated
void tw_fprint_binary_array(FILE *output, char const *prefix, void const *array, size_t size)
Prints content of memory into hexadecimal.
static struct mem_pool * main_pool
void tw_error(const char *file, int line, const char *fmt,...)
int tw_output(tw_lp *lp, const char *fmt,...)
static void * pool_alloc(size_t len)
void tw_printf(const char *file, int line, const char *fmt,...)
static const size_t pool_size
void tw_warning(const char *file, int line, const char *fmt,...)