diff -crN libpcl-1.6.orig/config.sub libpcl-1.6/config.sub
*** libpcl-1.6.orig/config.sub	2006-01-03 11:21:35.000000000 +0900
--- libpcl-1.6/config.sub	2007-05-12 15:07:06.000000000 +0900
***************
*** 1318,1323 ****
--- 1318,1325 ----
  	-zvmoe)
  		os=-zvmoe
  		;;
+ 	-brightv)
+ 		;;
  	-none)
  		;;
  	*)
diff -crN libpcl-1.6.orig/configure libpcl-1.6/configure
*** libpcl-1.6.orig/configure	2006-01-03 11:21:35.000000000 +0900
--- libpcl-1.6/configure	2007-05-12 15:07:06.000000000 +0900
***************
*** 7787,7792 ****
--- 7787,7796 ----
  #
  # Do we need to explicitly link libc?
  #
+ case $target in
+ *-brightv)
+   archive_cmds_need_lc=no
+ esac
  case "x$archive_cmds_need_lc" in
  x|xyes)
    # Assume -lc should be added
diff -crN libpcl-1.6.orig/pcat/makefile.setup libpcl-1.6/pcat/makefile.setup
*** libpcl-1.6.orig/pcat/makefile.setup	1970-01-01 09:00:00.000000000 +0900
--- libpcl-1.6/pcat/makefile.setup	2007-05-12 15:07:06.000000000 +0900
***************
*** 0 ****
--- 1,19 ----
+ BD = /usr/local/brightv
+ include $(BD)/appl/etc/makerules
+ 
+ CPPFLAGS += -D__BRIGHTV__
+ LDFLAGS += $(LDLIBS)
+ 
+ setup:
+ 	CC="$(CC)"			\
+ 	CFLAGS="$(CFLAGS)"		\
+ 	LDFLAGS="$(LDFLAGS)"		\
+ 	CPPFLAGS="$(CPPFLAGS)"		\
+ 	CPP="$(CPP)"			\
+ 	CXX="$(CXX)"			\
+ 	CXXFLAGS="$(CXXFLAGS)"		\
+ 	../configure			\
+ 	--build=i386-unknown-brightv	\
+ 	--host=i386-pc-linux-gnu	\
+ 	--target=i386-unknown-brightv	\
+ 	$(NULL)
diff -crN libpcl-1.6.orig/pcl/pcl.c libpcl-1.6/pcl/pcl.c
*** libpcl-1.6.orig/pcl/pcl.c	2006-01-03 11:21:35.000000000 +0900
--- libpcl-1.6/pcl/pcl.c	2007-05-12 15:07:06.000000000 +0900
***************
*** 117,124 ****
--- 117,129 ----
  static void co_switch_context(co_ctx_t *octx, co_ctx_t *nctx) {
  
  	if (swapcontext(&octx->cc, &nctx->cc) < 0) {
+ #if defined(__BRIGHTV__)
+ 		printf("[PCL] Context switch failed: curr=%x\n",
+ 		       co_curr);
+ #else
  		fprintf(stderr, "[PCL] Context switch failed: curr=%p\n",
  			co_curr);
+ #endif
  		exit(1);
  	}
  }
***************
*** 173,180 ****
--- 178,190 ----
  	 */
  	ctx_starting_func();
  
+ #if defined(__BRIGHTV__)
+ 	printf("[PCL] Hmm, you really shouldn't reach this point: curr=%x\n",
+ 	       co_curr);
+ #else
  	fprintf(stderr, "[PCL] Hmm, you really shouldn't reach this point: curr=%p\n",
  		co_curr);
+ #endif
  	exit(1);
  }
  
***************
*** 352,357 ****
--- 362,370 ----
      && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 0 && (defined(__powerpc64__) || defined(__powerpc__))
  	ctx->cc[0].__jmpbuf[JB_LR] = (int) func;
  	ctx->cc[0].__jmpbuf[JB_GPR1] = (int) stack;
+ #elif defined(__BRIGHTV__)
+ 	ctx->cc[0]._jb[5] = (int) func;
+ 	ctx->cc[0]._jb[4] = (int) stack;
  #else
  #error "PCL: Unsupported setjmp/longjmp platform. Please report to <davidel@xmailserver.org>"
  #endif
***************
*** 412,419 ****
--- 425,437 ----
  	coroutine *co = (coroutine *) coro;
  
  	if (co == co_curr) {
+ #if defined(__BRIGHTV__)
+ 		printf("[PCL] Cannot delete itself: curr=%x\n",
+ 		       co_curr);
+ #else
  		fprintf(stderr, "[PCL] Cannot delete itself: curr=%p\n",
  			co_curr);
+ #endif
  		exit(1);
  	}
  	if (co->alloc)
***************
*** 447,454 ****
--- 465,477 ----
  		co_delete(co_curr->caller);
  		co_call((coroutine_t) cdh);
  		if (!co_dhelper) {
+ #if defined(__BRIGHTV__)
+ 			printf("[PCL] Resume to delete helper coroutine: curr=%x\n",
+ 			       co_curr);
+ #else
  			fprintf(stderr, "[PCL] Resume to delete helper coroutine: curr=%p\n",
  				co_curr);
+ #endif
  			exit(1);
  		}
  	}
***************
*** 462,469 ****
--- 485,497 ----
  
  	if (!dchelper &&
  	    !(dchelper = co_create(co_del_helper, NULL, stk, sizeof(stk)))) {
+ #if defined(__BRIGHTV__)
+ 		printf("[PCL] Unable to create delete helper coroutine: curr=%x\n",
+ 			co_curr);
+ #else
  		fprintf(stderr, "[PCL] Unable to create delete helper coroutine: curr=%p\n",
  			co_curr);
+ #endif
  		exit(1);
  	}
  
***************
*** 471,478 ****
--- 499,511 ----
   
  	co_call((coroutine_t) dchelper);
  
+ #if defined(__BRIGHTV__)
+ 	printf("[PCL] Stale coroutine called: curr=%x\n",
+ 	       co_curr);
+ #else
  	fprintf(stderr, "[PCL] Stale coroutine called: curr=%p\n",
  		co_curr);
+ #endif
  	exit(1);
  }
  
diff -crN libpcl-1.6.orig/test/cobench.c libpcl-1.6/test/cobench.c
*** libpcl-1.6.orig/test/cobench.c	2006-01-03 11:21:35.000000000 +0900
--- libpcl-1.6/test/cobench.c	2007-05-12 15:07:06.000000000 +0900
***************
*** 27,32 ****
--- 27,36 ----
  #include <unistd.h>
  #include <pcl.h>
  
+ #if defined(__BRIGHTV__)
+ #include <bsys/unixemu.h>
+ #endif
+ 
  
  #define MIN_MEASURE_TIME 2000000ULL
  #define CO_STACK_SIZE (8 * 1024)
***************
*** 40,46 ****
--- 44,54 ----
  static unsigned long long getustime(void) {
  	struct timeval tm;
  
+ #if defined(__BRIGHTV__)
+ 	u_gettimeofday(&tm, NULL);
+ #else
  	gettimeofday(&tm, NULL);
+ #endif
  	return (unsigned long long) tm.tv_sec * 1000000ULL + (unsigned long long) tm.tv_usec;
  }
  
***************
*** 60,67 ****
--- 68,79 ----
  	unsigned long nswitches;
  	unsigned long long ts, te;
  
+ #if defined(__BRIGHTV__)
+ 	printf("measuring co_create+co_delete performance ... ");
+ #else
  	fprintf(stdout, "measuring co_create+co_delete performance ... ");
  	fflush(stdout);
+ #endif
  
  	ntimes = 10000;
  	do {
***************
*** 75,86 ****
--- 87,107 ----
  		ntimes *= 4;
  	} while ((te - ts) < MIN_MEASURE_TIME);
  
+ #if defined(__BRIGHTV__)
+ 	printf("%g usec\n",
+ 	       (double) (te - ts) / (double) ntimes);
+ #else
  	fprintf(stdout, "%g usec\n",
  		(double) (te - ts) / (double) ntimes);
+ #endif
  
  	if ((coro = co_create(switch_bench, NULL, NULL, CO_STACK_SIZE)) != NULL) {
+ #if defined(__BRIGHTV__)
+ 		printf("measuring switch performance ... ");
+ #else
  		fprintf(stdout, "measuring switch performance ... ");
  		fflush(stdout);
+ #endif
  
  		sw_counter = nswitches = 10000;
  		do {
***************
*** 91,98 ****
--- 112,124 ----
  			sw_counter = (nswitches *= 4);
  		} while ((te - ts) < MIN_MEASURE_TIME);
  
+ #if defined(__BRIGHTV__)
+ 		printf("%g usec\n",
+ 		       (double) (te - ts) / (double) (2 * nswitches));
+ #else
  		fprintf(stdout, "%g usec\n",
  			(double) (te - ts) / (double) (2 * nswitches));
+ #endif
  
  		co_delete(coro);
  	}
diff -crN libpcl-1.6.orig/test/cothread.c libpcl-1.6/test/cothread.c
*** libpcl-1.6.orig/test/cothread.c	2006-01-03 11:21:35.000000000 +0900
--- libpcl-1.6/test/cothread.c	2007-05-12 15:07:06.000000000 +0900
***************
*** 6,11 ****
--- 6,15 ----
  #include <unistd.h>
  #include <pcl.h>
  
+ #if defined(__BRIGHTV__)
+ #include <bsys/unixemu.h>
+ #endif
+ 
  /*
    Implements a simple cooperative multi-threading environment.
  
***************
*** 228,236 ****
--- 232,246 ----
  		if (q->mintime)
  			q->mintime = tvsub(tv, q->mintime, glbl->ctime);
  
+ #if defined(__BRIGHTV__)
+ 		while (u_select(q->maxfd, q->rp, q->wp, q->ep, q->mintime) == -1)
+ 			;
+ 		u_gettimeofday(glbl->ctime, 0);
+ #else
  		while (select(q->maxfd, q->rp, q->wp, q->ep, q->mintime) == -1)
  			;
  		gettimeofday(glbl->ctime, 0);
+ #endif
  	}
  
  	return 0;
***************
*** 266,272 ****
--- 276,286 ----
  
  void cothread_init() {
  
+ #if defined(__BRIGHTV__)
+ 	u_gettimeofday(glbl->ctime, 0);
+ #else
  	gettimeofday(glbl->ctime, 0);
+ #endif
  	glbl->active = glbl->queues;
  	glbl->wait = glbl->queues + 1;
  	memset(glbl->queues, 0, sizeof(glbl->queues));
