Commits

Kota UENISHI committed 133de32 Merge

merge

Comments (0)

Files changed (6)

 # If so, define the subdirectory targets and uncomment this section.
 #
 
-.SUBDIRS: omake cerl c
+.SUBDIRS: omake cerl c c++
 
 ########################################################################
 # C configuration.
   setvar(this.HAVE_$(libname), $(Check_header_library $(lib), $(header), $(func)))
   export
 
+CProg. = 
+  class CProg
+  target =
+  source =
+  options=
+
+  new(t,s,ldf) =
+    this.target = $(t)
+    this.source = $(s)
+    this.ldflags = $(ldf)
+    return $(this)
+
+  dep() =
+    CFLAGS += $(this.ldflags)
+    .DEFAULT: $(CProgram $(this.t), $(this.s))
+
+CXXProg. = 
+  class CXXProg
+  target =
+  source =
+  options=
+
+  new(t,s,ldf) =
+    this.target = $(t)
+    this.source = $(s)
+    this.ldflags = $(ldf)
+    return $(this)
+
+  dep() =
+    CXXFLAGS += $(this.ldflags)
+    .DEFAULT: $(CXXProgram $(this.t), $(this.s))
+
 #
 # The command-line variables are defined *after* the
 # standard configuration has been loaded.
 # You will usually need to modify this file for your project.
 
 # Delete this line once you have configured this file
-eprintln($(CWD)/OMakefile is not configured)
+# eprintln($(CWD)/OMakefile is not configured)
 
 ########################################################################
 # Phony targets are scoped, so you probably want to declare them first.
 #
 
-# .PHONY: all install clean
+.PHONY: all install clean
 
 ########################################################################
 # Subdirectories.
 # Uncomment the following section if you want
 # to build a C program in the current directory.
 #
+DEPS[] = 
+    $(CXXProg.new where.out, where, '')
+    $(CXXProg.new vector_test.out, vector_test, '')
+    $(CXXProg.new sandwitch.out, sandwitch, '')
+    $(CXXProg.new checkRandomness.out, checkRandomness, '')
+
+DEPS.foreach(prog)
+    prog.dep()
+    export
 
 # CFILES[] =
 #    file1
 # to build a C program in the current directory.
 #
 
-Prog. = 
-  class Prog
-  target =
-  source =
-  options=
-
-  new(t,s,ldf) =
-    this.target = $(t)
-    this.source = $(s)
-    this.ldflags = $(ldf)
-    return $(this)
-
-  dep() =
-    CFLAGS += $(this.ldflags)
-    .DEFAULT: $(CProgram $(this.t), $(this.s))
-
 DEPS[] = 
-    $(Prog.new autoquote.out, autoquote, '')
-    $(Prog.new comptest2.out, comptest2, -lz)
-    $(Prog.new getaddrinfo_test.out, getaddrinfo_test, '')
-    $(Prog.new jmp.out, jmp, '')
-    $(Prog.new loop.out, loop, '')
-    $(Prog.new make_temp.out, make_temp, '')
-    $(Prog.new malloc_test.out, malloc_test, '')
-    $(Prog.new memtest.out, memtest, '')
-    $(Prog.new memtime.out, memtime, '')
-    $(Prog.new printftest.out, printftest, '')
-    $(Prog.new rand.out, rand, '')
-    $(Prog.new mychroot.out, mychroot, '')
-    $(Prog.new myfsevent.out, myfsevent, -framework CoreServices)
-    $(Prog.new myregex.out, myregex, '')
+    $(CProg.new autoquote.out, autoquote, '')
+    $(CProg.new comptest2.out, comptest2, -lz)
+    $(CProg.new getaddrinfo_test.out, getaddrinfo_test, '')
+    $(CProg.new jmp.out, jmp, '')
+    $(CProg.new loop.out, loop, '')
+    $(CProg.new make_temp.out, make_temp, '')
+    $(CProg.new malloc_test.out, malloc_test, '')
+    $(CProg.new memtest.out, memtest, '')
+    $(CProg.new memtime.out, memtime, '')
+    $(CProg.new printftest.out, printftest, '')
+    $(CProg.new rand.out, rand, '')
+    $(CProg.new mychroot.out, mychroot, '')
+    $(CProg.new myfsevent.out, myfsevent, -framework CoreServices)
+    $(CProg.new myregex.out, myregex, '')
+    $(CProg.new getloadavg.out, getloadavg, '')
 
 DEPS.foreach(prog)
     prog.dep()
+#include <stdio.h>
+#include <stdlib.h>
+
+#define N 3
+
+int main(){
+  double loadavg[N];
+  int nelem=N;
+
+  int nproc = getloadavg(loadavg, nelem);
+  int i;
+  for(i=0; i<nproc; ++i){
+    printf("%f\n", loadavg[i]);
+  }
+}
 // see http://blog.majide.com/2009/03/c-regex-sample-code/
 int main(int args, char ** argv){
   regex_t reg;
-  const char * regex = "regex";
+  const char * regex = "^hogehage$";
   int i;
   size_t nmatch = 5;
   regmatch_t pmatch[5];
 
   regcomp(&reg, regex, REG_EXTENDED|REG_NEWLINE);
   printf("match for '%s':\n", regex);
-  for(i=0; i<args; ++i){
+  for(i=1; i<args; ++i){
     printf("'%s': ", argv[i]);
     if(regexec( &reg, argv[i], nmatch, pmatch, 0) != 0){
-      printf("No match.\n");
+      printf("doesn't match: %s\n", argv[i]);
     }else{
-      printf("matched: ");
+      printf("matched      : ");
       int j, k;
       for(j=0;j<nmatch;++j){
 	if (pmatch[j].rm_so >= 0 && pmatch[j].rm_eo >= 0) {
-	  printf("from %d to %d\n", pmatch[j].rm_so, pmatch[j].rm_eo);
+	  printf("from %d to %d\n", (int)pmatch[j].rm_so, (int)pmatch[j].rm_eo);
 	  //	  for (k = pmatch[j].rm_so ; k < pmatch[j].rm_eo; k++) {
 	  //	    putchar(argv[i][k]);
 	}