G'day Michel,

If you have any success with the fli, vpi I'd certainly be interested.
I started looking at the profiling options as well but had problems and run out of time to investigate further.

Regards
Phil

michel agoyan wrote:
Hi Tristan,
Again ... I know ;-) .
Just to say  that  the build of  ghdl -026 fails under cygwin.
Something is wrong with the configuration in order to use the win32 fiber api. I tried to use the default implementation using pthread without success. In this case I can build ghdl but I have an error during the run time ( wait inside sensitive process and obviously this not the case ! ). This error suggests me that there is actually an error with the implementation of the grt and with the use of pthread.
In fact the issue is the way  the pthreads are implemented under cygwin.
As Phil Reid (Thanks Phil ;-) ) suggested fews month ago I apply his patch ( call pthead_mutexattr_settype to set the type of mutex to PTHREAD_MUTEX_DEFAULT)
And it ... works :-) .

I plan to try to solve the issue with the configuration in order to be able to use the win32 fiber .
I let you inform if  there is any progress.

In the meantime it should be nice to apply the Phil's patch to the code since it only impacts the cygwin configuration.

I just remind (for those that don't understand why I want a cygwin version) that the cywin version of ghdl is able to build object (.o) files and probably ( I hope , I have to test ...) allows us to use fli , vpi ( maybe we have to do some modification to be able to load a shared library). The win32 native version of ghdl is not able to do that .....

Regards

Michel Agoyan

===========================================================================
Hereafter few lines describing how to compile ghdl-026 under cygwin :

1)be sure that the Devel/gcc-ada package is installed ( obviously you need also Devel/gcc)

2) cd /tmp
retrieve the ghdl source : wget http://ghdl.free.fr/ghdl-0.26.tar.bz2 retrieve the gcc source : wget ftp://ftp.gnu.org/pub/gnu/gcc/gcc-4.1.2/gcc-core-4.1.2.tar.bz2 wget ftp://ftp.gnu.org/pub/gnu/gcc/gcc-4.1.2/gcc-ada-4.1.2.tar.bz2

  tar -xjvf  ghdl-0.26.tar.bz2
  tar -xjvf  gcc-core-4.1.2.tar.bz2
  tar -xjvf  gcc-ada-4.1.2.tar.bz2

3) Build gcc-4.1.2 (the last version of gcc under cygwin is gcc-3.4.4 and we need gcc-4.x.x in oder to build ghdl.)
cd  gcc-4.1.2
 ./configure  --prefix=/usr/local/gcc-4.1.2  --enable-languages=c,c++,ada
This builds a Makefile to place the new gcc into the directory /usr/local/gcc-4.1.2

Something is wrong with the ada configuration , we have to set the environment variable HOST_SUBDIR :
export HOST_SUBDIR=host-i686-pc-cygiwin  (depends on your own host !)

make
make install

4) Now we have a gcc-4.1.2 tools chain (c,c++,ada) under /usr/local/gcc-4.1.2) modify your path in order to use this version : export PATH=/usr/local/gcc-4.1.2/bin:$PATH

cd /tmp
rm -r gcc-4.1.2
tar -xjvf  gcc-core-4.1.2.tar.bz2
tar -xjvf  gcc-ada-4.1.2.tar.bz2

Apply the Phil's Patch (https://mail.gna.org/public/ghdl-discuss/2006-10/msg00001.html) , I have regenerate the patchs for the version 026 and enclosed them to this email
cd  /tmp/ghdl-0.26/vhdl/grt/config
patch pthread.c < pthread.patch
cd  /tmp/ghdl-0.26/vhdl
patch Makefile.in < Makefile.in.patch

cd  /tmp
cp -R  ghdl-0.26/vhdl/  gcc-4.1.2/gcc/
./configure  --prefix=/usr/local/ghdl --enable-languages=vhdl
make
make install


Add /usr/local/ghdl to your PATH.


*
*
------------------------------------------------------------------------

--- pthread.c   2006-03-10 02:49:44.000000000 +0100
+++ pthread_new.c       2007-05-16 21:21:45.219848900 +0200
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <setjmp.h>
+#include <assert.h>
//#define INFO printf
 #define INFO (void)
@@ -37,6 +38,9 @@
typedef struct { pthread_t thread; // stack's thread
        pthread_mutex_t     mutex;          // mutex to suspend/resume thread
+#if defined(__CYGWIN__)
+    pthread_mutexattr_t mxAttr;
+#endif
        void                (*Func)(void*); // stack's FUNC
        void*               Arg;            // ARG passed to FUNC
 } Stack_Type_t, *Stack_Type;
@@ -54,10 +58,16 @@
 {      INFO("grt_stack_init\n");
        INFO("  main_stack_context=0x%08x\n", &main_stack_context);
        
-       pthread_mutex_init(&(main_stack_context.mutex), NULL);
+#if defined(__CYGWIN__)
+    assert(pthread_mutexattr_init(&(main_stack_context.mxAttr)) == 0);
+    
assert(pthread_mutexattr_settype(&(main_stack_context.mxAttr),PTHREAD_MUTEX_DEFAULT)
 == 0);
+    
assert(pthread_mutex_init(&(main_stack_context.mutex),&(main_stack_context.mxAttr))
 == 0);
+#else
+    assert(pthread_mutex_init(&(main_stack_context.mutex), NULL) == 0);
+#endif
        // lock the mutex, as we are currently running
-       pthread_mutex_lock(&(main_stack_context.mutex));
+       assert(pthread_mutex_lock(&(main_stack_context.mutex))== 0);
        
        current = &main_stack_context;
@@ -105,10 +115,17 @@
        newStack->Arg=  Arg;
        
        // create mutex
-       pthread_mutex_init(&(newStack->mutex), NULL);
+
+#if defined(__CYGWIN__)
+     assert(pthread_mutexattr_init(&(newStack->mxAttr)) == 0);
+     assert(pthread_mutexattr_settype(&(newStack->mxAttr), 
PTHREAD_MUTEX_DEFAULT) == 0);
+     assert(pthread_mutex_init(&(newStack->mutex), &(newStack->mxAttr)) == 0);
+#else
+     assert(pthread_mutex_init(&(newStack->mutex), NULL) == 0);
+#endif
        
        // block the mutex, so that thread will blocked in grt_stack_loop
-       pthread_mutex_lock(&(newStack->mutex));
+       assert(pthread_mutex_lock(&(newStack->mutex)) == 0);
        
        INFO("  newStack=0x%08x\n", newStack);
        
@@ -135,12 +152,12 @@
        // unlock 'To' mutex. this will make the other thread either
        // - starts for first time in grt_stack_loop
        // - resumes at lock below
-       pthread_mutex_unlock(&(To->mutex));
+       assert(pthread_mutex_unlock(&(To->mutex))==0);
                
        // block until 'From' mutex becomes available again
        // as we are running, our mutex is locked and we block here
        // when stacks are switched, with above unlock, we may proceed
-       pthread_mutex_lock(&(From->mutex));
+       assert(pthread_mutex_lock(&(From->mutex))==0);
if (From == &main_stack_context && need_longjmp != 0)
          longjmp (run_env, need_longjmp);
------------------------------------------------------------------------

--- Makefile.in 2007-04-08 18:46:39.000000000 +0200
+++ Makefile_new.in     2007-05-16 21:35:14.251098900 +0200
@@ -472,7 +472,9 @@
   GRT_TARGET_OBJS=win32.o clock.o
 endif
 ifeq ($(filter-out i%86 cygwin,$(arch) $(osys)),)
-  GRT_TARGET_OBJS=win32.o clock.o
+#  GRT_TARGET_OBJS=win32.o clock.o
+  GRT_TARGET_OBJS=pthread.o times.o
+  GRT_EXTRA_LIB=-lpthread -ldl -lm
 endif
 # Fall-back: use a generic implementation based on pthreads.
 ifndef GRT_TARGET_OBJS
------------------------------------------------------------------------

_______________________________________________
Ghdl-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/ghdl-discuss
_______________________________________________
Ghdl-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/ghdl-discuss

Reply via email to