runtime: If O_CLOEXEC is not defined, define it as 0.
[gcc.git] / libgo / runtime / thread-linux.c
index dde4e707a2dd3b34f96964b095e2c66b951f045c..c08cc0dba2950b9ea16d1df4757d46d3bcff19fd 100644 (file)
@@ -62,11 +62,16 @@ runtime_futexwakeup(uint32 *addr, uint32 cnt)
        *(int32*)0x1006 = 0x1006;
 }
 
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#endif
+
 static int32
 getproccount(void)
 {
        int32 fd, rd, cnt, cpustrlen;
-       const byte *cpustr, *pos;
+       const char *cpustr;
+       const byte *pos;
        byte *bufpos;
        byte buf[256];
 
@@ -75,14 +80,14 @@ getproccount(void)
                return 1;
        cnt = 0;
        bufpos = buf;
-       cpustr = (const byte*)"\ncpu";
-       cpustrlen = runtime_findnull((const byte*)cpustr);
+       cpustr = "\ncpu";
+       cpustrlen = strlen(cpustr);
        for(;;) {
                rd = read(fd, bufpos, sizeof(buf)-cpustrlen);
                if(rd == -1)
                        break;
                bufpos[rd] = 0;
-               for(pos=buf; (pos=(const byte*)strstr((const char*)pos, (const char*)cpustr)) != nil; cnt++, pos++) {
+               for(pos=buf; (pos=(const byte*)strstr((const char*)pos, cpustr)) != nil; cnt++, pos++) {
                }
                if(rd < cpustrlen)
                        break;