Permalink
Browse files

Move Parrot_cpu_type function out of src/platform/misc.c.

This way, it doesn't need to be repeated elsewhere.  For symmetry,
also remove it out of win32/misc.c and give it its own file there as well.

Patch supplied by Andy Dougherty++.
  • Loading branch information...
1 parent 938d2c2 commit 89ce26c8d02abd4f2bd3db809ddd537a7e843e4a @jkeenan jkeenan committed Aug 4, 2012
View
@@ -1294,6 +1294,7 @@ src/platform/ansi/time.c []
src/platform/cygwin/math.c []
src/platform/darwin/hires_timer.c []
src/platform/darwin/sysmem.c []
+src/platform/generic/cpu_type.c []
src/platform/generic/dl.c []
src/platform/generic/encoding.c []
src/platform/generic/entropy.c []
@@ -1316,6 +1317,7 @@ src/platform/netbsd/misc.c []
src/platform/openbsd/math.c []
src/platform/solaris/math.c []
src/platform/solaris/time.c []
+src/platform/win32/cpu_type.c []
src/platform/win32/dl.c []
src/platform/win32/entropy.c []
src/platform/win32/env.c []
@@ -46,6 +46,7 @@ sub _set_implementations {
time.c
encoding.c
env.c
+ cpu_type.c
dl.c
math.c
itimer.c
@@ -1734,6 +1734,8 @@ src/platform/darwin/hires_timer$(O) : src/platform/darwin/hires_timer.c $(PARROT
src/platform/darwin/sysmem$(O) : src/platform/darwin/sysmem.c $(PARROT_H_HEADERS)
+src/platform/generic/cpu_type$(O) : src/platform/generic/cpu_type.c $(PARROT_H_HEADERS)
+
src/platform/generic/dl$(O) : src/platform/generic/dl.c $(PARROT_H_HEADERS)
src/platform/generic/encoding$(O) : src/platform/generic/encoding.c $(PARROT_H_HEADERS)
@@ -1780,6 +1782,8 @@ src/platform/solaris/math$(O) : src/platform/solaris/math.c $(PARROT_H_HEADERS)
src/platform/solaris/time$(O) : src/platform/solaris/time.c $(PARROT_H_HEADERS)
+src/platform/win32/cpu_type$(O) : src/platform/win32/cpu_type.c $(PARROT_H_HEADERS)
+
src/platform/win32/dl$(O) : src/platform/win32/dl.c $(PARROT_H_HEADERS)
src/platform/win32/env$(O) : src/platform/win32/env.c $(PARROT_H_HEADERS)
@@ -0,0 +1,65 @@
+/*
+ * 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)>
+
+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;
+#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' :
+ */
+
@@ -12,6 +12,10 @@ src/platform/generic/misc.c
Miscellaneous helper functions.
+Please avoid adding to this file. Individual families of functions
+should normally go in individual files. Platform-specific overrides
+then go in the platform-specific directories.
+
=head2 Functions
=cut
@@ -20,10 +24,6 @@ Miscellaneous helper functions.
#include "parrot/parrot.h"
-#ifdef PARROT_HAS_HEADER_SYSUTSNAME
-# include <sys/utsname.h>
-#endif
-
/* HEADERIZER HFILE: none */
/*
@@ -44,33 +44,6 @@ Parrot_platform_init_code(void)
}
/*
-
-=item C<STRING *Parrot_get_cpu_type(Parrot_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;
-#endif
- return Parrot_str_new_init(interp, proc_arch, strlen(proc_arch),
- Parrot_ascii_encoding_ptr, 0);
-
-}
-
-/*
* Local variables:
* c-file-style: "parrot"
* End:
@@ -22,10 +22,6 @@ Miscellaneous helper functions that are specific to NetBSD.
#include "parrot/parrot.h"
-#ifdef PARROT_HAS_HEADER_SYSUTSNAME
-# include <sys/utsname.h>
-#endif
-
/* HEADERIZER HFILE: none */
/*
@@ -57,30 +53,6 @@ Parrot_platform_init_code(void)
/*
-=item C<STRING *Parrot_get_cpu_type(Parrot_Interp)>
-
-Fetch CPU type.
-
-=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;
-#endif
- return Parrot_str_new_init(interp, proc_arch, strlen(proc_arch),
- Parrot_ascii_encoding_ptr, 0);
-
-}
-
-/*
-
=back
=cut
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2004-2006, Parrot Foundation.
+ */
+
+/*
+
+=head1 NAME
+
+src\platform\win32\cpu_type.c
+
+=head1 DESCRIPTION
+
+Fetch CPU type for win32 systems.
+
+=head2 Functions
+
+=over 4
+
+=cut
+
+*/
+
+#include <ws2tcpip.h>
+#undef CONST
+
+#include "parrot/parrot.h"
+
+/* HEADERIZER HFILE: none */
+
+/*
+
+=item C<STRING * Parrot_get_cpu_type(Parrot_Interp interp)>
+
+Fetch CPU type for win32 systems
+
+=back
+
+=cut
+
+*/
+
+STRING *
+Parrot_get_cpu_type(Parrot_Interp interp) {
+ SYSTEM_INFO sys_info;
+ WORD arch_type;
+ char *proc_arch;
+
+ GetSystemInfo(&sys_info);
+
+ arch_type = sys_info.wProcessorArchitecture;
+ switch (arch_type) {
+ case PROCESSOR_ARCHITECTURE_AMD64:
+ proc_arch = "x64";
+ break;
+ case PROCESSOR_ARCHITECTURE_IA64:
+ proc_arch ="IA64";
+ break;
+ case PROCESSOR_ARCHITECTURE_INTEL:
+ proc_arch ="x86";
+ break;
+ case PROCESSOR_ARCHITECTURE_UNKNOWN:
+ proc_arch ="unknown";
+ break;
+ default:
+ proc_arch ="unknown";
+ break;
+ }
+
+ 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' :
+ */
+
@@ -56,51 +56,6 @@ Parrot_platform_init_code(void)
}
/*
-
-=item C<STRING * Parrot_get_cpu_type(Parrot_Interp interp)>
-
-Fetch CPU type for win32 systems
-
-=back
-
-=cut
-
-*/
-
-STRING *
-Parrot_get_cpu_type(Parrot_Interp interp) {
- SYSTEM_INFO sys_info;
- WORD arch_type;
- char *proc_arch;
-
- GetSystemInfo(&sys_info);
-
- arch_type = sys_info.wProcessorArchitecture;
- switch (arch_type) {
- case PROCESSOR_ARCHITECTURE_AMD64:
- proc_arch = "x64";
- break;
- case PROCESSOR_ARCHITECTURE_IA64:
- proc_arch ="IA64";
- break;
- case PROCESSOR_ARCHITECTURE_INTEL:
- proc_arch ="x86";
- break;
- case PROCESSOR_ARCHITECTURE_UNKNOWN:
- proc_arch ="unknown";
- break;
- default:
- proc_arch ="unknown";
- break;
- }
-
- return Parrot_str_new_init(interp, proc_arch, strlen(proc_arch),
- Parrot_ascii_encoding_ptr, 0);
-
-}
-
-
-/*
* Local variables:
* c-file-style: "parrot"
* End:

0 comments on commit 89ce26c

Please sign in to comment.