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: Fri, 27 Mar 2009 10:39:21 +0100

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






reply via email to

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