guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Again on Windows support


From: carlo\.bramix
Subject: Re: Again on Windows support
Date: Thu, 2 Apr 2009 19:41:42 +0200

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]