* Again on Windows support
@ 2009-03-18 11:05 carlo.bramix
2009-03-19 10:54 ` Andy Wingo
0 siblings, 1 reply; 9+ messages in thread
From: carlo.bramix @ 2009-03-18 11:05 UTC (permalink / raw)
To: guile-devel
Hello,
I saw there was a try for fixing the bug with guile and pthreads-w32.
I just wanted to say, although the fix seems to work, in my opinion this is the wrong way to proceed.
"struct timespec" does not exist under Windows, this is the truth.
It has been added as an hack into pthreads-w32 just for prototype compatibility with some functions.
I do not think it is a good idea to rely on that.
I believe it's MUCH better and safe to have it declared as "struct scm_t_timespec".
BTW, beside this problem, Guile 1.8.6 has still troubles when linking under mingw.
It cannot create shared libraries because (unexisting) problems with Winsock library.
It says:
"*** Warning: linker path does not have real file for library -lws2_32."
Perhaps you are using too old stuff or something because I fixed this problem by using a recent stable version of autotools and libtool.
I deleted all generated files and I reconfigured everything with:
autoconf 2.61
automake 1.10.1
libtool 1.5.26
and it worked fine.
With a number of difficulties that I prefer to not tell, I was able to get a recent snapshot of your GIT repository on my Windows PC.
Then I tried to compile.
Here there are some fixes and some problems still unresolved.
I understand that a patch would be better, but at the time of writing GIT and Windows do not seem to be good friends.
So I hope that a good soul will be able to do some of the very simple fixes described here:
LIBGUILE/GSUBR.C
================
function alloca() is undefined because under Windows the intrinsic function is called _alloca().
The compatibility is got by adding:
#if HAVE_MALLOC_H
# include <malloc.h>
#endif
Hopefully, the presence of malloc.h is already tested by configure script.
LIBGUILE/OBJCODES.C
===================
sys/mmap.h is absent.
We need to modify in this file:
#if HAVE_SYS_MMAN_H
# include <sys/mman.h>
#endif
and add the check of presence into configure script.
-------------------
'ulong' is undefined. I temporary added its declaration in this file for allowing the compilation.
-------------------
compilation of function make_objcode_by_mmap() fails because function mmap() does not exist.
There is already a macro called USE_MMAP that may help us.
I fixed the function by writing a thing like this one:
#ifdef USE_MMAP
...
#else
SCM_SYSERROR;
#endif
LIBGUILE/STIME.C
================
I got a conflict type with tzname[] because it enters into #ifndef tzname ... #endif for SGI.
Into Windows includes, this vector is declared with dllimport and here it is not, that's why they conflict.
I believe it would be better remove that test and leave the detection of tzname[] to configure script.
#if !defined HAVE_TZNAME && !defined __MINGW32__
extern char *tzname[];
#endif
LIBGUILE/THREADS.C
==================
I was not able to compile Guile without threads.
If you do it, you get these warnings (since there is -Werror, compilation is halted).
../../guile-git/libguile/threads.c: In function `scm_i_with_guile_and_parent':
../../guile-git/libguile/threads.c:850: warning: statement with no effect
../../guile-git/libguile/threads.c:852: warning: statement with no effect
../../guile-git/libguile/threads.c: In function `scm_cancel_thread':
../../guile-git/libguile/threads.c:1059: warning: statement with no effect
I had to force --with-threads for bypassing this trouble.
Normally the threads are not enabled under Windows because you must use -lpthreadGC2 instead of -lpthread, that's why I had to force the option and add LIBS="-lpthreadGC2"
LIBGUILE/VM.C
=============
I have not really understood this error:
../../guile-git/libguile/vm-engine.c: In function `vm_regular_engine':
../../guile-git/libguile/vm-engine.c:277: error: unable to find a register to spill in class `SIREG'
../../guile-git/libguile/vm-engine.c:277: error: this is the insn:
(insn:HI 1398 1397 1399 72 ../../guile-git/libguile/vm-i-system.c:167 (parallel [
(set (reg:SI 2 cx [398])
(const_int 0 [0x0]))
(set (reg/f:SI 1 dx [396])
(plus:SI (ashift:SI (reg:SI 2 cx [398])
(const_int 2 [0x2]))
(reg/f:SI 1 dx [396])))
(set (reg:SI 3 bx [orig:397 sp ] [397])
(plus:SI (ashift:SI (reg:SI 2 cx [398])
(const_int 2 [0x2]))
(reg:SI 3 bx [orig:397 sp ] [397])))
(set (mem:BLK (reg/f:SI 1 dx [396]) [0 A8])
(mem:BLK (reg:SI 3 bx [orig:397 sp ] [397]) [0 A8]))
(use (reg:SI 2 cx [398]))
(use (reg:SI 19 dirflag))
]) 447 {*rep_movsi} (insn_list 1396 (insn_list 1397 (nil)))
(expr_list:REG_DEAD (reg:SI 19 dirflag)
(expr_list:REG_UNUSED (reg:SI 3 bx [orig:397 sp ] [397])
(expr_list:REG_UNUSED (reg/f:SI 1 dx [396])
(expr_list:REG_UNUSED (reg:SI 2 cx [398])
(nil))))))
../../guile-git/libguile/vm-engine.c:277: confused by earlier errors, bailing out
make[3]: *** [libguile_la-vm.lo] Error 1
It happens with GCC3.4.5, GCC4.1.3 and GCC4.3.0.
LIBGUILE/__SCM.h
================
I was able to compile with attribute "internal" only with GCC3.
GCC 4.x says that it's ignored and compilation is interrupted.
why not checking it too with configure script?
That's all for now.
I hope you will find it useful.
Sincerely,
Carlo Bramini.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Again on Windows support
2009-03-18 11:05 Again on Windows support carlo.bramix
@ 2009-03-19 10:54 ` Andy Wingo
0 siblings, 0 replies; 9+ messages in thread
From: Andy Wingo @ 2009-03-19 10:54 UTC (permalink / raw)
To: carlo.bramix; +Cc: guile-devel
Hi Carlo,
Thanks for doing this testing. I do not know of anyone who has built
Guile with the VM on Windows, so some of these problems are interesting.
I can't speak to all of your issues, but regarding some of them:
On Wed 18 Mar 2009 12:05, "carlo.bramix" <carlo.bramix@libero.it> writes:
> LIBGUILE/GSUBR.C
> ================
> function alloca() is undefined because under Windows the intrinsic
> function is called _alloca().
Hm, I thought the Gnulib alloca thing should have fixed this. Does
adding #include <alloca.h> in gsubr.c not fix this?
> LIBGUILE/OBJCODES.C
> ===================
> sys/mmap.h is absent.
This is unfortunate. But I understand that windows has ways of mapping
files to memory, and we should use those. Do you know what those calls
are?
> 'ulong' is undefined.
Ah, I wonder how this got there. Fixed.
> compilation of function make_objcode_by_mmap() fails because function
> mmap() does not exist.
I would rather implement this properly on windows than make a new, hacky
function. This is a very important function, actually.
> LIBGUILE/VM.C
> =============
> I have not really understood this error:
>
> ../../guile-git/libguile/vm-engine.c: In function `vm_regular_engine':
> ../../guile-git/libguile/vm-engine.c:277: error: unable to find a register to spill in class `SIREG'
This is because in the VM we declare some variables to be in registers,
but this confuses some gccs, especially on win32. I don't know what the
real answer is -- perhaps we shouldn't force register allocation for
these variables.
> It happens with GCC3.4.5, GCC4.1.3 and GCC4.3.0.
That is good to know, thank you for testing with all of these. For the
record I have only seen this problem with GCC 4.1.2 on Linux; e.g. 4.3.0
works for me. So there must be more register pressure on windows or
something.
We can work around it by setting vm-engine.h:72 to be:
#if defined(__i386__) && !defined(__windows__)
But I need to know the right thing to put there for __windows__.
> I hope you will find it useful.
Thank you!
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Again on Windows support
@ 2009-03-20 19:37 carlo.bramix
2009-03-24 20:32 ` Neil Jerram
0 siblings, 1 reply; 9+ messages in thread
From: carlo.bramix @ 2009-03-20 19:37 UTC (permalink / raw)
To: guile-devel
Hello!
> > LIBGUILE/GSUBR.C
> > ================
> > function alloca() is undefined because under Windows the intrinsic
> > function is called _alloca().
>
> Hm, I thought the Gnulib alloca thing should have fixed this. Does
> adding #include <alloca.h> in gsubr.c not fix this?
>
<alloca.h> does not exists here.
Unfortunately, we (Windows users) have no other choice than including malloc.h
> > LIBGUILE/OBJCODES.C
> > ===================
> > sys/mmap.h is absent.
>
> This is unfortunate. But I understand that windows has ways of mapping
> files to memory, and we should use those. Do you know what those calls
> are?
>
it can be done in this manner:
1) add presence check of windows.h into configure script.
2) on top of objcodes.c add:
#if HAVE_WINDOWS_H
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
and:
#if HAVE_IO_H
# include <io.h>
#endif
Hopefully, io.h is already tested by configure.
3) Now you can modify the function in this manner:
static SCM
make_objcode_by_mmap (int fd)
#define FUNC_NAME "make_objcode_by_mmap"
{
int ret;
char *addr;
struct stat st;
SCM sret = SCM_BOOL_F;
struct scm_objcode *data;
#ifdef HAVE_WINSOCK2_H
HANDLE hFile, hMapFile;
#endif
ret = fstat (fd, &st);
if (ret < 0)
SCM_SYSERROR;
if (st.st_size <= sizeof (struct scm_objcode) + strlen (OBJCODE_COOKIE))
scm_misc_error (FUNC_NAME, "object file too small (~a bytes)",
SCM_LIST1 (SCM_I_MAKINUM (st.st_size)));
#ifdef HAVE_WINSOCK2_H
/* Retrieve system handle from fd */
hFile = (HANDLE)_get_osfhandle(fd);
if (hFile == INVALID_HANDLE_VALUE)
SCM_SYSERROR;
/* Create mapping object */
hMapFile = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
if (hMapFile == INVALID_HANDLE_VALUE)
SCM_SYSERROR;
/* Select which portions of the file we need (entire file) */
addr = (char *)MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, 0);
if (addr == NULL) {
/* Free the mapping object */
CloseHandle(hMapFile);
SCM_SYSERROR;
}
#else
addr = mmap (0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (addr == MAP_FAILED)
SCM_SYSERROR;
#endif
if (memcmp (addr, OBJCODE_COOKIE, strlen (OBJCODE_COOKIE)))
SCM_SYSERROR;
....
Everything else is the same.
I'm wondering: who frees the mapper object?
If we want to free it on Windows too, we must preserve "hMapFile" handle somewhere for closing it.
> > compilation of function make_objcode_by_mmap() fails because function
> > mmap() does not exist.
>
> I would rather implement this properly on windows than make a new, hacky
> function. This is a very important function, actually.
>
I did the change described above, it compiles fine.
Although it is very simple, I verified that the Win32 code works fine separately with a simple test programme.
> > LIBGUILE/VM.C
> > =============
> > I have not really understood this error:
> >
> > ../../guile-git/libguile/vm-engine.c: In function `vm_regular_engine':
> > ../../guile-git/libguile/vm-engine.c:277: error: unable to find a register to spill in class `SIREG'
>
> This is because in the VM we declare some variables to be in registers,
> but this confuses some gccs, especially on win32. I don't know what the
> real answer is -- perhaps we shouldn't force register allocation for
> these variables.
>
Ah, I understood.
I removed hardwired registers and now it compiles even with old GCC3.4.5
Instead of manually patching every GCC release, perhaps it's better to leave that choice to the user.
For example if, at configure time, the user adds something like "--disable-vm-hardregs" or "--enable-vm-hardregs" then it will be possible to recover a working build (normally, those register variables will be always enabled).
And it will be available for all architectures and all cpus, not only i386 and/or mingw32.
Now I advanced my compilation but, sigh, it seems I have not big luck...
After a while this is the error I'm getting:
make[4]: Entering directory `/home/Carlo/guile/doc/ref'
restore=: && backupdir=".am$$" && \
am__cwd=`pwd` && cd ../../../guile-git/doc/ref && \
rm -rf $backupdir && mkdir $backupdir && \
if (/bin/sh /home/Carlo/guile-git/build-aux/missing --run makeinfo --version) >/dev/null 2>&1; then \
for f in ../../../guile-git/doc/ref/guile.info ../../../guile-git/doc/ref/guile.info-[0-9] ../../../guile-git/doc/ref/guile.info-[0-9][0-9] ../../../guile-git/doc/ref/guile.i[0-9] ../../../guile-git/doc/ref/guile.i[0-9][0-9]; do \
if test -f $f; then mv $f $backupdir; restore=mv; else :; fi; \
done; \
else :; fi && \
cd "$am__cwd"; \
if /bin/sh /home/Carlo/guile-git/build-aux/missing --run makeinfo -I ../../../guile-git/doc/ref \
-o ../../../guile-git/doc/ref/guile.info ../../../guile-git/doc/ref/guile.texi; \
then \
rc=0; \
cd ../../../guile-git/doc/ref; \
else \
rc=$?; \
cd ../../../guile-git/doc/ref && \
$restore $backupdir/* `echo "./../../../guile-git/doc/ref/guile.info" | sed 's|[^/]*$||'`; \
fi; \
rm -rf $backupdir; exit $rc
../../../guile-git/doc/ref/compiler.texi:54: Unknown command `'.
makeinfo: Removing output file `../../../guile-git/doc/ref/guile.info' due to errors; use --force to preserve.
make[4]: *** [../../../guile-git/doc/ref/guile.info] Error 1
Sincerely,
Carlo Bramini.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Again on Windows support
2009-03-20 19:37 carlo.bramix
@ 2009-03-24 20:32 ` Neil Jerram
2009-03-24 22:39 ` Ludovic Courtès
0 siblings, 1 reply; 9+ messages in thread
From: Neil Jerram @ 2009-03-24 20:32 UTC (permalink / raw)
To: carlo.bramix; +Cc: guile-devel
"carlo.bramix" <carlo.bramix@libero.it> writes:
> Hello!
>
>> > LIBGUILE/GSUBR.C
>> > ================
>> > function alloca() is undefined because under Windows the intrinsic
>> > function is called _alloca().
>>
>> Hm, I thought the Gnulib alloca thing should have fixed this. Does
>> adding #include <alloca.h> in gsubr.c not fix this?
>>
>
> <alloca.h> does not exists here.
> Unfortunately, we (Windows users) have no other choice than including malloc.h
There should be an <alloca.h> in the "lib" subdirectory of the
distribution. My one includes:
#ifndef alloca
# ifdef __GNUC__
# define alloca __builtin_alloca
# elif defined _AIX
# define alloca __alloca
# elif defined _MSC_VER
# include <malloc.h>
# define alloca _alloca
...
So, if compiling with GCC, it should be picking up __builtin_alloca.
If compiling with MSVC, it should be including malloc.h as you
suggest.
Neil
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Again on Windows support
2009-03-24 20:32 ` Neil Jerram
@ 2009-03-24 22:39 ` Ludovic Courtès
0 siblings, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2009-03-24 22:39 UTC (permalink / raw)
To: guile-devel
Hello,
Neil Jerram <neil@ossau.uklinux.net> writes:
> "carlo.bramix" <carlo.bramix@libero.it> writes:
>
>> Hello!
>>
>>> > LIBGUILE/GSUBR.C
>>> > ================
>>> > function alloca() is undefined because under Windows the intrinsic
>>> > function is called _alloca().
>>>
>>> Hm, I thought the Gnulib alloca thing should have fixed this. Does
>>> adding #include <alloca.h> in gsubr.c not fix this?
>>>
>>
>> <alloca.h> does not exists here.
>> Unfortunately, we (Windows users) have no other choice than including malloc.h
>
> There should be an <alloca.h> in the "lib" subdirectory of the
> distribution. My one includes:
Oops, it was not included. Fixed:
http://git.savannah.gnu.org/cgit/guile.git/commit/?id=020348bb87860c8294be64a17b7de732c8265fbc
Thanks,
Ludo'.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Again on Windows support
@ 2009-03-27 9:39 carlo.bramix
2009-03-29 6:15 ` Andy Wingo
0 siblings, 1 reply; 9+ messages in thread
From: carlo.bramix @ 2009-03-27 9:39 UTC (permalink / raw)
To: guile-devel
Hello,
I did a patch in the usual way instead of using GIT.
I hope it will be ok anyways.
Actually this patch adds the fixes described into the previous emails (still need to know if the mapping created in function make_objcode_by_mmap() needs to be freed somewhere or not!); I was not really ablt to bypass the error when it tried to create documentation, so I bypassed it by doing a little hack into generated Makefile.
After that, compilation continued until it said that there was an error with "restrict" keyword. I was forced to change it to "__restrict" or "__restrict__" otherwise it did not work.
It is already included into my patch too.
I think it has been almost compiled now... unfortunately it still fails with another error:
I do not know what it means...
make[3]: Entering directory `/home/Carlo/g/module'
/bin/mkdir -p `dirname system/base/pmatch.go`
../pre-inst-guile-env ../guile-tools compile -o "system/base/pmatch.go" "../../guile/module/system/base/pmatch.scm"
ERROR: In procedure dynamic-func:
ERROR: symbol not found
make[3]: *** [system/base/pmatch.go] Error 1
Sincerely,
Carlo Bramini.
========================================
diff -r -u guile-old/configure.in guile-new/configure.in
--- guile-old/configure.in Wed Mar 25 09:10:31 2009
+++ guile-new/configure.in Wed Mar 25 09:47:52 2009
@@ -627,7 +627,7 @@
regex.h rxposix.h rx/rxposix.h sys/dir.h sys/ioctl.h sys/select.h \
sys/time.h sys/timeb.h sys/times.h sys/stdtypes.h sys/types.h \
sys/utime.h time.h unistd.h utime.h pwd.h grp.h sys/utsname.h \
-direct.h langinfo.h nl_types.h])
+sys/mman.h direct.h langinfo.h nl_types.h windows.h])
# "complex double" is new in C99, and "complex" is only a keyword if
# <complex.h> is included
diff -r -u guile-old/lib/time.in.h guile-new/lib/time.in.h
--- guile-old/lib/time.in.h Wed Mar 25 09:10:31 2009
+++ guile-new/lib/time.in.h Fri Mar 27 08:55:17 2009
@@ -74,10 +74,10 @@
# define localtime_r rpl_localtime_r
# undef gmtime_r
# define gmtime_r rpl_gmtime_r
-struct tm *localtime_r (time_t const *restrict __timer,
- struct tm *restrict __result);
-struct tm *gmtime_r (time_t const *restrict __timer,
- struct tm *restrict __result);
+struct tm *localtime_r (time_t const * __restrict __timer,
+ struct tm * __restrict __result);
+struct tm *gmtime_r (time_t const * __restrict __timer,
+ struct tm * __restrict __result);
# endif
/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
@@ -86,8 +86,8 @@
# if @REPLACE_STRPTIME@
# undef strptime
# define strptime rpl_strptime
-char *strptime (char const *restrict __buf, char const *restrict __format,
- struct tm *restrict __tm);
+char *strptime (char const * __restrict __buf, char const * __restrict __format,
+ struct tm * __restrict __tm);
# endif
/* Convert TM to a time_t value, assuming UTC. */
Only in guile-new/lib: time.in.h.bak
diff -r -u guile-old/libguile/null-threads.h guile-new/libguile/null-threads.h
--- guile-old/libguile/null-threads.h Wed Mar 25 09:10:32 2009
+++ guile-new/libguile/null-threads.h Wed Mar 25 09:36:49 2009
@@ -33,18 +33,20 @@
*/
#include <errno.h>
+
+static inline int scm_i_pthread_dummy(void) { return 0; }
/* Threads
*/
#define scm_i_pthread_t int
-#define scm_i_pthread_self() 0
+#define scm_i_pthread_self() scm_i_pthread_dummy()
#define scm_i_pthread_create(t,a,f,d) (*(t)=0, (void)(f), ENOSYS)
#define scm_i_pthread_detach(t) do { } while (0)
#define scm_i_pthread_exit(v) exit(0)
-#define scm_i_pthread_cancel(t) 0
-#define scm_i_pthread_cleanup_push(t,v) 0
-#define scm_i_pthread_cleanup_pop(e) 0
-#define scm_i_sched_yield() 0
+#define scm_i_pthread_cancel(t) scm_i_pthread_dummy()
+#define scm_i_pthread_cleanup_push(t,v) scm_i_pthread_dummy()
+#define scm_i_pthread_cleanup_pop(e) scm_i_pthread_dummy()
+#define scm_i_sched_yield() scm_i_pthread_dummy()
/* Signals
*/
@@ -59,7 +61,7 @@
#define scm_i_pthread_mutex_trylock(m) ((*(m))++)
#define scm_i_pthread_mutex_lock(m) ((*(m))++)
#define scm_i_pthread_mutex_unlock(m) ((*(m))--)
-#define scm_i_pthread_mutexattr_recursive 0
+#define scm_i_pthread_mutexattr_recursive scm_i_pthread_dummy()
/* Condition variables
*/
diff -r -u guile-old/libguile/objcodes.c guile-new/libguile/objcodes.c
--- guile-old/libguile/objcodes.c Wed Mar 25 09:10:32 2009
+++ guile-new/libguile/objcodes.c Wed Mar 25 09:18:46 2009
@@ -43,10 +43,20 @@
# include <config.h>
#endif
+#if HAVE_WINDOWS_H
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+#endif
+
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
-#include <sys/mman.h>
+#if HAVE_IO_H
+# include <io.h>
+#endif
+#if HAVE_SYS_MMAN_H
+# include <sys/mman.h>
+#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <assert.h>
@@ -74,6 +84,9 @@
struct stat st;
SCM sret = SCM_BOOL_F;
struct scm_objcode *data;
+#ifdef HAVE_WINDOWS_H
+ HANDLE hFile, hMapFile;
+#endif
ret = fstat (fd, &st);
if (ret < 0)
@@ -83,9 +96,28 @@
scm_misc_error (FUNC_NAME, "object file too small (~a bytes)",
SCM_LIST1 (SCM_I_MAKINUM (st.st_size)));
+#ifdef HAVE_WINDOWS_H
+ /* Retrieve system handle from fd */
+ hFile = (HANDLE)_get_osfhandle(fd);
+ if (hFile == INVALID_HANDLE_VALUE)
+ SCM_SYSERROR;
+
+ /* Create mapping object */
+ hMapFile = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
+ if (hMapFile == INVALID_HANDLE_VALUE)
+ SCM_SYSERROR;
+
+ /* Select which portions of the file we need (entire file) */
+ addr = (char *)MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, 0);
+ if (addr == NULL) {
+ CloseHandle(hMapFile);
+ SCM_SYSERROR;
+ }
+#else
addr = mmap (0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (addr == MAP_FAILED)
SCM_SYSERROR;
+#endif
if (memcmp (addr, OBJCODE_COOKIE, strlen (OBJCODE_COOKIE)))
SCM_SYSERROR;
diff -r -u guile-old/libguile/stime.c guile-new/libguile/stime.c
--- guile-old/libguile/stime.c Wed Mar 25 09:10:32 2009
+++ guile-new/libguile/stime.c Wed Mar 25 09:39:24 2009
@@ -81,11 +81,11 @@
#include <crt_externs.h> /* for Darwin _NSGetEnviron */
#endif
-#ifndef tzname /* For SGI. */
-extern char *tzname[]; /* RS6000 and others reject char **tzname. */
-#endif
#if defined (__MINGW32__)
# define tzname _tzname
+#endif
+#ifndef tzname /* For SGI. */
+extern char *tzname[]; /* RS6000 and others reject char **tzname. */
#endif
#if ! HAVE_DECL_STRPTIME
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Again on Windows support
@ 2009-03-27 11:02 carlo.bramix
0 siblings, 0 replies; 9+ messages in thread
From: carlo.bramix @ 2009-03-27 11:02 UTC (permalink / raw)
To: guile-devel
Hello,
I confirm that the problem on undeclared alloca() function has been fixed after this change.
Sincerely,
Carlo Bramini.
---------- Initial Header -----------
From : guile-devel-bounces+carlo.bramix=libero.it@gnu.org
To : guile-devel@gnu.org
Cc :
Date : Tue, 24 Mar 2009 23:39:43 +0100
Subject : Re: Again on Windows support
> Hello,
>
> Neil Jerram <neil@ossau.uklinux.net> writes:
>
> > "carlo.bramix" <carlo.bramix@libero.it> writes:
> >
> >> Hello!
> >>
> >>> > LIBGUILE/GSUBR.C
> >>> > ================
> >>> > function alloca() is undefined because under Windows the intrinsic
> >>> > function is called _alloca().
> >>>
> >>> Hm, I thought the Gnulib alloca thing should have fixed this. Does
> >>> adding #include <alloca.h> in gsubr.c not fix this?
> >>>
> >>
> >> <alloca.h> does not exists here.
> >> Unfortunately, we (Windows users) have no other choice than including malloc.h
> >
> > There should be an <alloca.h> in the "lib" subdirectory of the
> > distribution. My one includes:
>
> Oops, it was not included. Fixed:
>
> http://git.savannah.gnu.org/cgit/guile.git/commit/?id=020348bb87860c8294be64a17b7de732c8265fbc
>
> Thanks,
> Ludo'.
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Again on Windows support
2009-03-27 9:39 carlo.bramix
@ 2009-03-29 6:15 ` Andy Wingo
0 siblings, 0 replies; 9+ messages in thread
From: Andy Wingo @ 2009-03-29 6:15 UTC (permalink / raw)
To: carlo.bramix; +Cc: guile-devel
Hi Carlo,
On Fri 27 Mar 2009 02:39, "carlo.bramix" <carlo.bramix@libero.it> writes:
> Hello,
> I did a patch in the usual way instead of using GIT.
It's good to have the patch inline to review. It looks fine to me but I
will punt to Neil or Ludovic for the final review. Also, thanks for
taking care of the mmap issue.
> (still need to know if the mapping created in function
> make_objcode_by_mmap() needs to be freed somewhere or not!)
Guile never unmaps these files. I suppose it's possible, but if it is a
bug it's a Guile bug and not specific to the win32 side of things.
> After that, compilation continued until it said that there was an
> error with "restrict" keyword. I was forced to change it to
> "__restrict" or "__restrict__" otherwise it did not work.
Odd, but your fix has no negative effects that I can see.
> make[3]: Entering directory `/home/Carlo/g/module'
> /bin/mkdir -p `dirname system/base/pmatch.go`
> ../pre-inst-guile-env ../guile-tools compile -o "system/base/pmatch.go" "../../guile/module/system/base/pmatch.scm"
> ERROR: In procedure dynamic-func:
> ERROR: symbol not found
So, if you've gotten this far, you should be able to run ./meta/guile,
or ./pre-inst-guile (depending on how up-to-date your git is). If that
doesn't work then perhaps set this as the equivalent of ~/.guile:
(debug-enable 'backtrace)
(debug-set! depth 80)
and re-run guile; you should get a Scheme backtrace that you can paste
here. Try also ./meta/guile -c 1 or ./meta/guile -c '(display "foo")'.
Let us know how it goes!
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Again on Windows support
@ 2009-04-02 17:41 carlo.bramix
0 siblings, 0 replies; 9+ messages in thread
From: carlo.bramix @ 2009-04-02 17:41 UTC (permalink / raw)
To: guile-devel
Hello,
I feel a bit stupid because I was not able to create such log file...
I put those two lines into a ".guile" file.
I have $HOME variable correctly declared (which is normal: afterall msys aims to be a full posix-like enviroment) and I also tried to put that file into multiple places, but without success.
While I was feeling so defeated, I also tried to compile the newest sources of guile under cygwin and I discovered some interesting surprises.
First of all I discovered that there was a little problem with the mmap replacement (the one that I suggested in previous email) for Windows and cygwin: it said that _get_osfhandle() was undeclared.
The problem came from the fact that cygwin has two "io.h" files and just one file is the right one.
So I fixed it and if cygwin is detected it will fall down to the usual mmap(), which is in my opinion the most correct approach for this enviroment.
Next, it failed into libguile/i18n.c.
It said that nl_item was undeclared at line 1373, function s_scm_nl_langinfo.
It happened that cygwin seems to have langinfo.h but not nl_types.h.
Since the source includes both files together, if one of them was missing, then none is included.
I inspected the include files of cygwin and "nl_item" was declared into langinfo.h, no need of nl_types.h.
So my proposed fix is to split the inclusion of these two files into two tests, as you can see from attached patch.
After that, it continued to compile, it arrived at the same point of msys and...
Same error!
make[3]: Entering directory `/home/Carlo/guile/module'
/usr/bin/mkdir -p `dirname system/base/pmatch.go`
../pre-inst-guile-env ../guile-tools compile -o "system/base/pmatch.go" "/cygdrive/c/msys/1.0/home/Carlo/guile/module/system/base/pmatch.scm"
ERROR: In procedure dynamic-func:
ERROR: No error
make[3]: *** [system/base/pmatch.go] Error 1
I tried again to put everywhere the .guile file with suggested lines without success.
Last test: I also compiled these sources under Debian 5.0 and it compiled everything successful.
I also tried to put the .guile file into the home and into other directories, but guile was not printing anything new even under linux.
I'm evidently doing something wrong on every platform for getting the backtrace.
I hope somebody could correct my stupidity... :|
Sincerely,
Carlo Bramini.
==============================
diff -r -u guile-old/configure.in guile-new/configure.in
--- guile-old/configure.in Wed Mar 25 09:10:31 2009
+++ guile-new/configure.in Wed Mar 25 09:47:52 2009
@@ -627,7 +627,7 @@
regex.h rxposix.h rx/rxposix.h sys/dir.h sys/ioctl.h sys/select.h \
sys/time.h sys/timeb.h sys/times.h sys/stdtypes.h sys/types.h \
sys/utime.h time.h unistd.h utime.h pwd.h grp.h sys/utsname.h \
-direct.h langinfo.h nl_types.h])
+sys/mman.h direct.h langinfo.h nl_types.h windows.h])
# "complex double" is new in C99, and "complex" is only a keyword if
# <complex.h> is included
diff -r -u guile-old/lib/time.in.h guile-new/lib/time.in.h
--- guile-old/lib/time.in.h Wed Mar 25 09:10:31 2009
+++ guile-new/lib/time.in.h Fri Mar 27 08:55:17 2009
@@ -74,10 +74,10 @@
# define localtime_r rpl_localtime_r
# undef gmtime_r
# define gmtime_r rpl_gmtime_r
-struct tm *localtime_r (time_t const *restrict __timer,
- struct tm *restrict __result);
-struct tm *gmtime_r (time_t const *restrict __timer,
- struct tm *restrict __result);
+struct tm *localtime_r (time_t const * __restrict __timer,
+ struct tm * __restrict __result);
+struct tm *gmtime_r (time_t const * __restrict __timer,
+ struct tm * __restrict __result);
# endif
/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
@@ -86,8 +86,8 @@
# if @REPLACE_STRPTIME@
# undef strptime
# define strptime rpl_strptime
-char *strptime (char const *restrict __buf, char const *restrict __format,
- struct tm *restrict __tm);
+char *strptime (char const * __restrict __buf, char const * __restrict __format,
+ struct tm * __restrict __tm);
# endif
/* Convert TM to a time_t value, assuming UTC. */
Only in guile-new/lib: time.in.h.bak
diff -r -u guile-old/libguile/i18n.c guile-new/libguile/i18n.c
--- guile-old/libguile/i18n.c Wed Mar 25 09:10:32 2009
+++ guile-new/libguile/i18n.c Thu Apr 2 16:23:34 2009
@@ -59,8 +59,10 @@
#include "libguile/posix.h" /* for `scm_i_locale_mutex' */
-#if (defined HAVE_LANGINFO_H) && (defined HAVE_NL_TYPES_H)
+#ifdef HAVE_LANGINFO_H
# include <langinfo.h>
+#endif
+#ifdef HAVE_NL_TYPES_H
# include <nl_types.h>
#endif
diff -r -u guile-old/libguile/null-threads.h guile-new/libguile/null-threads.h
--- guile-old/libguile/null-threads.h Wed Mar 25 09:10:32 2009
+++ guile-new/libguile/null-threads.h Wed Mar 25 09:36:49 2009
@@ -33,18 +33,20 @@
*/
#include <errno.h>
+
+static inline int scm_i_pthread_dummy(void) { return 0; }
/* Threads
*/
#define scm_i_pthread_t int
-#define scm_i_pthread_self() 0
+#define scm_i_pthread_self() scm_i_pthread_dummy()
#define scm_i_pthread_create(t,a,f,d) (*(t)=0, (void)(f), ENOSYS)
#define scm_i_pthread_detach(t) do { } while (0)
#define scm_i_pthread_exit(v) exit(0)
-#define scm_i_pthread_cancel(t) 0
-#define scm_i_pthread_cleanup_push(t,v) 0
-#define scm_i_pthread_cleanup_pop(e) 0
-#define scm_i_sched_yield() 0
+#define scm_i_pthread_cancel(t) scm_i_pthread_dummy()
+#define scm_i_pthread_cleanup_push(t,v) scm_i_pthread_dummy()
+#define scm_i_pthread_cleanup_pop(e) scm_i_pthread_dummy()
+#define scm_i_sched_yield() scm_i_pthread_dummy()
/* Signals
*/
@@ -59,7 +61,7 @@
#define scm_i_pthread_mutex_trylock(m) ((*(m))++)
#define scm_i_pthread_mutex_lock(m) ((*(m))++)
#define scm_i_pthread_mutex_unlock(m) ((*(m))--)
-#define scm_i_pthread_mutexattr_recursive 0
+#define scm_i_pthread_mutexattr_recursive scm_i_pthread_dummy()
/* Condition variables
*/
diff -r -u guile-old/libguile/objcodes.c guile-new/libguile/objcodes.c
--- guile-old/libguile/objcodes.c Wed Mar 25 09:10:32 2009
+++ guile-new/libguile/objcodes.c Thu Apr 2 16:25:01 2009
@@ -43,10 +43,20 @@
# include <config.h>
#endif
+#if HAVE_WINDOWS_H
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+#endif
+
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
-#include <sys/mman.h>
+#if HAVE_IO_H
+# include <io.h>
+#endif
+#if HAVE_SYS_MMAN_H
+# include <sys/mman.h>
+#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <assert.h>
@@ -74,6 +84,9 @@
struct stat st;
SCM sret = SCM_BOOL_F;
struct scm_objcode *data;
+#if defined(HAVE_WINDOWS_H) && !defined(__CYGWIN__)
+ HANDLE hFile, hMapFile;
+#endif
ret = fstat (fd, &st);
if (ret < 0)
@@ -83,9 +96,28 @@
scm_misc_error (FUNC_NAME, "object file too small (~a bytes)",
SCM_LIST1 (SCM_I_MAKINUM (st.st_size)));
+#if defined(HAVE_WINDOWS_H) && !defined(__CYGWIN__)
+ /* Retrieve system handle from fd */
+ hFile = (HANDLE)_get_osfhandle(fd);
+ if (hFile == INVALID_HANDLE_VALUE)
+ SCM_SYSERROR;
+
+ /* Create mapping object */
+ hMapFile = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
+ if (hMapFile == INVALID_HANDLE_VALUE)
+ SCM_SYSERROR;
+
+ /* Select which portions of the file we need (entire file) */
+ addr = (char *)MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, 0);
+ if (addr == NULL) {
+ CloseHandle(hMapFile);
+ SCM_SYSERROR;
+ }
+#else
addr = mmap (0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (addr == MAP_FAILED)
SCM_SYSERROR;
+#endif
if (memcmp (addr, OBJCODE_COOKIE, strlen (OBJCODE_COOKIE)))
SCM_SYSERROR;
Only in guile-new/libguile: objcodes.c.bak
diff -r -u guile-old/libguile/stime.c guile-new/libguile/stime.c
--- guile-old/libguile/stime.c Wed Mar 25 09:10:32 2009
+++ guile-new/libguile/stime.c Wed Mar 25 09:39:24 2009
@@ -81,11 +81,11 @@
#include <crt_externs.h> /* for Darwin _NSGetEnviron */
#endif
-#ifndef tzname /* For SGI. */
-extern char *tzname[]; /* RS6000 and others reject char **tzname. */
-#endif
#if defined (__MINGW32__)
# define tzname _tzname
+#endif
+#ifndef tzname /* For SGI. */
+extern char *tzname[]; /* RS6000 and others reject char **tzname. */
#endif
#if ! HAVE_DECL_STRPTIME
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-04-02 17:41 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-18 11:05 Again on Windows support carlo.bramix
2009-03-19 10:54 ` Andy Wingo
-- strict thread matches above, loose matches on Subject: below --
2009-03-20 19:37 carlo.bramix
2009-03-24 20:32 ` Neil Jerram
2009-03-24 22:39 ` Ludovic Courtès
2009-03-27 9:39 carlo.bramix
2009-03-29 6:15 ` Andy Wingo
2009-03-27 11:02 carlo.bramix
2009-04-02 17:41 carlo.bramix
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).