Skip to content

Instantly share code, notes, and snippets.

@gradha
Created December 3, 2014 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gradha/3022b3f3ca7c4bdf9b77 to your computer and use it in GitHub Desktop.
Save gradha/3022b3f3ca7c4bdf9b77 to your computer and use it in GitHub Desktop.
cpuinfo as module compiled with 0.9.6 compiler in debug mode
/* Generated by Nimrod Compiler v0.9.6 */
/* (c) 2014 Andreas Rumpf */
/* The generated code is subject to the original license. */
/* Compiled for: MacOSX, amd64, clang */
/* Command for C compiler:
clang -c -w -I/private/tmp/back/Nimrod/lib -o /private/tmp/back/Nimrod/nimcache/stdlib_cpuinfo.o /private/tmp/back/Nimrod/nimcache/stdlib_cpuinfo.c */
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
typedef int TY136001[4];
#include <sys/types.h>#include <sys/sysctl.h>N_NIMCALL(NI, ncpicountProcessors)(void);
static N_INLINE(void, nimFrame)(TFrame* s);
N_NOINLINE(void, stackoverflow_18001)(void);
static N_INLINE(void, popFrame)(void);
extern TFrame* frameptr_15442;
static N_INLINE(void, nimFrame)(TFrame* s) {
NI LOC1;
LOC1 = 0;
{
if (!(frameptr_15442 == NIM_NIL)) goto LA4;
LOC1 = 0;
}
goto LA2;
LA4: ;
{
LOC1 = ((NI) ((NI16)((*frameptr_15442).calldepth + ((NI16) 1))));
}
LA2: ;
(*s).calldepth = ((NI16) (LOC1));
(*s).prev = frameptr_15442;
frameptr_15442 = s;
{
if (!((*s).calldepth == ((NI16) 2000))) goto LA9;
stackoverflow_18001();
}
LA9: ;
}
static N_INLINE(void, popFrame)(void) {
frameptr_15442 = (*frameptr_15442).prev;
}
N_NIMCALL(NI, ncpicountProcessors)(void) {
NI result;
TY136001 mib;
NI numcpu;
size_t len;
int LOC1;
nimfr("countProcessors", "cpuinfo.nim")
result = 0;
memset((void*)mib, 0, sizeof(mib));
numcpu = 0;
len = 0;
nimln(51, "cpuinfo.nim");
mib[(0)- 0] = ((int) 6);
nimln(52, "cpuinfo.nim");
mib[(1)- 0] = ((int) 25);
nimln(53, "cpuinfo.nim");
len = 8;
nimln(54, "cpuinfo.nim");
nimln(54, "cpuinfo.nim");
LOC1 = 0;
LOC1 = sysctl(mib, ((int) 2), ((void*) (&numcpu)), &len, NIM_NIL, 0);
nimln(55, "cpuinfo.nim");
{
int LOC6;
nimln(55, "cpuinfo.nim");
if (!(numcpu < 1)) goto LA4;
nimln(56, "cpuinfo.nim");
mib[(1)- 0] = ((int) 3);
nimln(57, "cpuinfo.nim");
nimln(57, "cpuinfo.nim");
LOC6 = 0;
LOC6 = sysctl(mib, ((int) 2), ((void*) (&numcpu)), &len, NIM_NIL, 0);
}
LA4: ;
nimln(58, "cpuinfo.nim");
result = numcpu;
nimln(66, "cpuinfo.nim");
{
nimln(66, "cpuinfo.nim");
if (!(result <= 0)) goto LA9;
nimln(66, "cpuinfo.nim");
result = 1;
}
LA9: ;
popFrame();
return result;
}
N_NOINLINE(void, stdlib_cpuinfoInit)(void) {
nimfr("cpuinfo", "cpuinfo.nim")
nimln(23, "cpuinfo.nim");
nimln(31, "cpuinfo.nim");
popFrame();
}
N_NOINLINE(void, stdlib_cpuinfoDatInit)(void) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment