Back to index

numactl  2.0.8~rc4
Defines | Functions
util.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define err(x)   perror("numactl: " x),exit(1)
#define array_len(x)   (sizeof(x)/sizeof(*(x)))
#define round_up(x, y)   (((x) + (y) - 1) & ~((y)-1))

Functions

void printmask (char *name, struct bitmask *mask)
void printcpumask (char *name, struct bitmask *mask)
struct bitmasknodemask (char *s)
struct bitmaskcpumask (char *s, int *ncpus)
int read_sysctl (char *name)
void complain (char *fmt,...)
void nerror (char *fmt,...)
void usage (void)
long memsize (char *s)
int parse_policy (char *name, char *arg)
void print_policies (void)
char * policy_name (int policy)

Define Documentation

#define array_len (   x)    (sizeof(x)/sizeof(*(x)))

Definition at line 18 of file util.h.

#define err (   x)    perror("numactl: " x),exit(1)

Definition at line 17 of file util.h.

#define round_up (   x,
 
)    (((x) + (y) - 1) & ~((y)-1))

Definition at line 20 of file util.h.


Function Documentation

void complain ( char *  fmt,
  ... 
)

Definition at line 50 of file util.c.

{
       va_list ap;
       va_start(ap, fmt);
       fprintf(stderr, "numactl: ");
       vfprintf(stderr,fmt,ap);
       putchar('\n');
       va_end(ap);
       exit(1);
}

Here is the caller graph for this function:

struct bitmask* cpumask ( char *  s,
int *  ncpus 
) [read]
long memsize ( char *  s)

Definition at line 452 of file numademo.c.

{
       char *end;
       long length = strtoul(s,&end,0);
       switch (toupper(*end)) {
       case 'G': length *= 1024;  /*FALL THROUGH*/
       case 'M': length *= 1024;  /*FALL THROUGH*/
       case 'K': length *= 1024; break;
       }
       return length;
}

Here is the caller graph for this function:

void nerror ( char *  fmt,
  ... 
)

Definition at line 61 of file util.c.

{
       int err = errno;
       va_list ap;
       va_start(ap,fmt);
       fprintf(stderr, "numactl: ");
       vfprintf(stderr, fmt, ap);
       va_end(ap);
       if (err)
              fprintf(stderr,": %s\n", strerror(err));
       else
              fputc('\n', stderr);
       exit(1);
}

Here is the caller graph for this function:

struct bitmask* nodemask ( char *  s) [read]

Here is the caller graph for this function:

int parse_policy ( char *  name,
char *  arg 
)

Definition at line 113 of file util.c.

{
       int k;
       struct policy *p = NULL;
       if (!name)
              return MPOL_DEFAULT;
       for (k = 0; policies[k].name; k++) {
              p = &policies[k];
              if (!strcmp(p->name, name))
                     break;
       }
       if (!p || !p->name || (!arg && !p->noarg))
              usage();
    return p->policy;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* policy_name ( int  policy)

Definition at line 103 of file util.c.

{
       static char buf[32];
       if (policy >= array_len(policy_names)) {
              sprintf(buf, "[%d]", policy);
              return buf;
       }
       return policy_names[policy];
}

Here is the caller graph for this function:

void print_policies ( void  )

Definition at line 129 of file util.c.

{
       int i;
       printf("Policies:");
       for (i = 0; policies[i].name; i++)
              printf(" %s", policies[i].name);
       printf("\n");
}

Here is the caller graph for this function:

void printcpumask ( char *  name,
struct bitmask mask 
)

Definition at line 39 of file util.c.

{
       int i;
       printf("%s: ", name);
       for (i = 0; i < mask->size; i++) {
              if (numa_bitmask_isbitset(mask, i))
                     printf("%d ", i);
       }
       putchar('\n');
}

Here is the call graph for this function:

Here is the caller graph for this function:

void printmask ( char *  name,
struct bitmask mask 
)

Definition at line 28 of file util.c.

{
       int i;

       printf("%s: ", name);
       for (i = 0; i <= mask->size; i++)
              if (numa_bitmask_isbitset(mask, i))
                     printf("%d ", i);
       putchar('\n');
}

Here is the call graph for this function:

Here is the caller graph for this function:

int read_sysctl ( char *  name)
void usage ( void  )

Definition at line 40 of file memhog.c.

{
       printf("memhog [-rNUM] size[kmg] [policy [nodeset]]\n");
       printf("-rNUM repeat memset NUM times\n");
       printf("-H disable transparent hugepages\n");
       print_policies();
       exit(1);
}

Here is the call graph for this function:

Here is the caller graph for this function: