/
cpu_type.c
67 lines (44 loc) · 1001 Bytes
/
cpu_type.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* Copyright (C) 2011, Parrot Foundation.
*/
/*
=head1 NAME
src/platform/generic/cpu_type.c
=head1 DESCRIPTION
Fetch CPU type for non-win32 systems
For win32, look in platform/win32/cpu_type.c
=head2 Functions
=cut
*/
#include "parrot/parrot.h"
#ifdef PARROT_HAS_HEADER_SYSUTSNAME
# include <sys/utsname.h>
#endif
/* HEADERIZER HFILE: none */
/*
=over 4
=item C<STRING * Parrot_get_cpu_type(Parrot_Interp interp)>
Fetch CPU type for non-win32 systems
For win32, look in platform/win32/misc.c
=back
=cut
*/
STRING *
Parrot_get_cpu_type(Parrot_Interp interp) {
struct utsname uname_info;
char *proc_arch;
#ifdef PARROT_HAS_HEADER_SYSUTSNAME
uname(&uname_info);
proc_arch = uname_info.machine;
#else
*proc_arch = '\0';
#endif
return Parrot_str_new_init(interp, proc_arch, strlen(proc_arch),
Parrot_ascii_encoding_ptr, 0);
}
/*
* Local variables:
* c-file-style: "parrot"
* End:
* vim: expandtab shiftwidth=4 cinoptions='\:2=2' :
*/