utils.c (a976c2951d8f376112361830aa7762beff83a205) utils.c (95f9b3af401f5b4daeb908a2c658e820e969f4e3)
1/*
2 * Copyright 2013-2015, Michael Ellerman, IBM Corp.
3 * Licensed under GPLv2.
4 */
5
6#define _GNU_SOURCE /* For CPU_ZERO etc. */
7
8#include <elf.h>
9#include <errno.h>
10#include <fcntl.h>
11#include <link.h>
12#include <sched.h>
13#include <stdio.h>
1/*
2 * Copyright 2013-2015, Michael Ellerman, IBM Corp.
3 * Licensed under GPLv2.
4 */
5
6#define _GNU_SOURCE /* For CPU_ZERO etc. */
7
8#include <elf.h>
9#include <errno.h>
10#include <fcntl.h>
11#include <link.h>
12#include <sched.h>
13#include <stdio.h>
14#include <string.h>
14#include <sys/stat.h>
15#include <sys/types.h>
15#include <sys/stat.h>
16#include <sys/types.h>
17#include <sys/utsname.h>
16#include <unistd.h>
17
18#include "utils.h"
19
20static char auxv[4096];
21
22int read_auxv(char *buf, ssize_t buf_size)
23{

--- 75 unchanged lines hidden (view full) ---

99 /* Search for anything, but in reverse */
100 for (cpu = CPU_SETSIZE - 1; cpu >= 0; cpu--)
101 if (CPU_ISSET(cpu, &mask))
102 return cpu;
103
104 printf("No cpus in affinity mask?!\n");
105 return -1;
106}
18#include <unistd.h>
19
20#include "utils.h"
21
22static char auxv[4096];
23
24int read_auxv(char *buf, ssize_t buf_size)
25{

--- 75 unchanged lines hidden (view full) ---

101 /* Search for anything, but in reverse */
102 for (cpu = CPU_SETSIZE - 1; cpu >= 0; cpu--)
103 if (CPU_ISSET(cpu, &mask))
104 return cpu;
105
106 printf("No cpus in affinity mask?!\n");
107 return -1;
108}
109
110bool is_ppc64le(void)
111{
112 struct utsname uts;
113 int rc;
114
115 errno = 0;
116 rc = uname(&uts);
117 if (rc) {
118 perror("uname");
119 return false;
120 }
121
122 return strcmp(uts.machine, "ppc64le") == 0;
123}