Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Diff of /libop/op_cpu_type.c [3b11e2] .. [6ee980] Maximize Restore

  Switch to unified view

a/libop/op_cpu_type.c b/libop/op_cpu_type.c
...
...
196
        }
196
        }
197
        else {
197
        else {
198
            auxv_temp = (ElfW(auxv_t) *)malloc(page_size);
198
            auxv_temp = (ElfW(auxv_t) *)malloc(page_size);
199
            if (!auxv_temp) {
199
            if (!auxv_temp) {
200
                perror("Allocation of space for auxv failed.");
200
                perror("Allocation of space for auxv failed.");
201
              close(auxv_f);
201
                return NULL;
202
                return NULL;
202
            }
203
            }
203
            bytes = read(auxv_f, (void *)auxv_temp, page_size);
204
            bytes = read(auxv_f, (void *)auxv_temp, page_size);
204
205
205
            if (bytes <= 0) {
206
            if (bytes <= 0) {
...
...
212
            if (close(auxv_f)) {
213
            if (close(auxv_f)) {
213
                perror("Error close failed");
214
                perror("Error close failed");
214
                fprintf(stderr, "Recoverable error. Continuing.\n");
215
                fprintf(stderr, "Recoverable error. Continuing.\n");
215
            }
216
            }
216
        }
217
        }
218
      auxv_buf = auxv_temp;
217
    }
219
    }
218
    return (ElfW(auxv_t) *)auxv_temp;
220
    return (ElfW(auxv_t) *)auxv_temp;
219
}
221
}
220
222
221
223
...
...
235
        }
237
        }
236
        i++;
238
        i++;
237
    } while (my_auxv[i].a_type != AT_NULL);
239
    } while (my_auxv[i].a_type != AT_NULL);
238
240
239
    return platform;
241
    return platform;
242
}
243
244
static void release_at_hw_platform(void)
245
{
246
  ElfW(auxv_t) * my_auxv = NULL;
247
248
  if ((my_auxv = (ElfW(auxv_t)*) _auxv_fetch()))
249
      free(my_auxv);
240
}
250
}
241
251
242
static op_cpu _try_ppc64_arch_generic_cpu(void)
252
static op_cpu _try_ppc64_arch_generic_cpu(void)
243
{
253
{
244
    const char * platform, * base_platform;
254
    const char * platform, * base_platform;
...
...
247
    platform = fetch_at_hw_platform(AT_PLATFORM);
257
    platform = fetch_at_hw_platform(AT_PLATFORM);
248
    base_platform = fetch_at_hw_platform(AT_BASE_PLATFORM);
258
    base_platform = fetch_at_hw_platform(AT_BASE_PLATFORM);
249
    if (!platform || !base_platform) {
259
    if (!platform || !base_platform) {
250
        fprintf(stderr, "NULL returned for one or both of AT_PLATFORM/AT_BASE_PLATFORM\n");
260
        fprintf(stderr, "NULL returned for one or both of AT_PLATFORM/AT_BASE_PLATFORM\n");
251
        fprintf(stderr, "AT_PLATFORM: %s; \tAT_BASE_PLATFORM: %s\n", platform, base_platform);
261
        fprintf(stderr, "AT_PLATFORM: %s; \tAT_BASE_PLATFORM: %s\n", platform, base_platform);
262
      release_at_hw_platform();
252
        return cpu_type;
263
        return cpu_type;
253
    }
264
    }
254
    // FIXME whenever a new IBM Power processor is added -- need to ensure
265
    // FIXME whenever a new IBM Power processor is added -- need to ensure
255
    // we're returning the correct version of the architected events file.
266
    // we're returning the correct version of the architected events file.
256
    if (strcmp(platform, base_platform)) {
267
    if (strcmp(platform, base_platform)) {
...
...
269
        if (!platforms_are_equivalent) {
280
        if (!platforms_are_equivalent) {
270
            if (strcmp(platform, "power7") == 0)
281
            if (strcmp(platform, "power7") == 0)
271
                cpu_type = CPU_PPC64_ARCH_V1;
282
                cpu_type = CPU_PPC64_ARCH_V1;
272
        }
283
        }
273
    }
284
    }
285
  release_at_hw_platform();
274
    return cpu_type;
286
    return cpu_type;
275
}
287
}
276
288
277
static op_cpu _get_ppc64_cpu_type(void)
289
static op_cpu _get_ppc64_cpu_type(void)
278
{
290
{