17 vfprintf(stdout, fmt, ap);
27 vfprintf(stdout, fmt, ap);
41 while (temp->
next != 0) {
50 if (ret >= 0 && (
unsigned)ret <
sizeof(out->
message)) {
61 tw_printf(
const char *file,
int line,
const char *fmt, ...)
66 fprintf(stdout,
"%s:%i: ", file, line);
67 vfprintf(stdout, fmt, ap);
68 fprintf(stdout,
"\n");
74 tw_error(
const char *file,
int line,
const char *fmt, ...)
79 fprintf(stdout,
"node: %ld: error: %s:%i: ",
g_tw_mynode, file, line);
80 vfprintf(stdout, fmt, ap);
81 fprintf(stdout,
"\n");
90 tw_warning(
const char *file,
int line,
const char *fmt, ...)
95 fprintf(stdout,
"node: %ld: warning: %s:%i: ",
g_tw_mynode, file, line);
96 vfprintf(stdout, fmt, ap);
97 fprintf(stdout,
"\n");
122 size_t *bytes_wasted)
127 *bytes_wasted = malloc_calls * (
sizeof(
void*) +
sizeof(
size_t));
135 #ifdef ROSS_ALLOC_DEBUG
145 void *r = calloc(e_sz, n);
149 "Cannot allocate %lu bytes for %u %s",
170 if (len >= pool_size) {
183 p->
next_free = (
char *)((
size_t)32 + (size_t)p);
184 if( 7 & (
size_t)(p->next_free) )
185 printf(
"pool_alloc: WARNING found pool start address (%p) NOT 8 byte aligned\n", p->next_free);
193 if( 7 & (
size_t)r || 7 & (
size_t)(p->
next_free) )
194 printf(
"pool_alloc: WARNING found return ptr (%p) or next_free (%p) NOT 8 bytes aligned\n", r, p->
next_free );
198 total_allocated += len;
212 if(e_sz & (pool_align - 1))
214 e_sz += pool_align - (e_sz & (pool_align - 1));
226 "Cannot allocate %lu bytes for %u %s"
227 " (need total of %lu KiB)",
231 (
unsigned long)((total_allocated + e_sz) / 1024));
tw_synch g_tw_synchronization_protocol
void * tw_calloc(const char *file, int line, const char *for_who, size_t e_sz, size_t n)
char message[256-2 *sizeof(void *)]
int tw_output(tw_lp *lp, const char *fmt,...)
tw_out * out_msgs
Output messages.
struct mem_pool * next_pool
tw_kp * kp
kp – Kernel process that we belong to (must match pe).
tw_event * cur_event
Current event being processed.
void tw_error(const char *file, int line, const char *fmt,...)
void tw_printf(const char *file, int line, const char *fmt,...)
void tw_warning(const char *file, int line, const char *fmt,...)
void tw_calloc_stats(size_t *bytes_alloc, size_t *bytes_wasted)
static const size_t pool_align
static void * my_malloc(size_t len)
static unsigned malloc_calls
tw_kpid id
ID number, otherwise its not available to the app.
Rollback-aware output mechanism.
static size_t total_allocated
static const size_t pool_size
static struct mem_pool * main_pool
tw_out * tw_kp_grab_output_buffer(tw_kp *kp)
static void * pool_alloc(size_t len)