Back to index

numactl  2.0.8~rc4
Classes | Functions | Variables
util.c File Reference
#include "numa.h"
#include "numaif.h"
#include "util.h"
#include "bitops.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
#include <errno.h>
#include <unistd.h>

Go to the source code of this file.

Classes

struct  policy

Functions

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

Variables

static struct policy policies []
static char * policy_names [] = { "default", "preferred", "bind", "interleave" }

Class Documentation

struct policy

Definition at line 89 of file util.c.

Class Members
char * name
int noarg
int policy

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:

long memsize ( char *  s)

Definition at line 76 of file util.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;
}
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:

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:


Variable Documentation

struct policy policies[] [static]
char* policy_names[] = { "default", "preferred", "bind", "interleave" } [static]

Definition at line 101 of file util.c.