Changeset 8547


Ignore:
Timestamp:
Feb 21, 2008, 4:22:15 PM (12 years ago)
Author:
andreas
Message:

Big #ifdef WINDOWS hack&slash: stub out every function that references
things unimplemented on Windows. This is mainly exception (a.k.a.
signal handling) stuff, pthread-related things and memory management.

Using this code, and the compiler from:


http://downloads.sourceforge.net/mingw-w64/mingw-w64-bin_x86_64-linux_20080203.tar.bz2?modtime=1202034209&big_mirror=0

I am able to cross-compile a Win64 executable from my Ubuntu. Of
course, it crashes pretty soon, but this was to be expected.

Location:
trunk/source/lisp-kernel
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/Threads.h

    r8539 r8547  
    1616
    1717#include <stdlib.h>
     18#ifndef WINDOWS
    1819#include <unistd.h>
    19 #ifndef WINDOWS
    2020#include <sys/mman.h>
    2121#endif
     
    8686#ifdef USE_WINDOWS_SEMAPHORES
    8787
     88/* Unimplemented */
     89
    8890typedef void * SEMAPHORE;
     91#define SEM_WAIT(s)
     92#define SEM_RAISE(s)
     93#define SEM_BROADCAST(s, count)
     94#define SEM_TIMEDWAIT(s,t)
    8995
    9096#endif
     
    113119#ifdef USE_MACH_SEMAPHORES
    114120#define SEM_WAIT_FOREVER(s) sem_wait_forever((SEMAPHORE)(natural)s)
     121#endif
     122
     123#ifdef USE_WINDOWS_SEMAPHORES
     124#define SEM_WAIT_FOREVER(s) sem_wait_forever((SEMAPHORE)s)
    115125#endif
    116126
  • trunk/source/lisp-kernel/image.c

    r8496 r8547  
    163163}
    164164
     165#ifdef WINDOWS
     166void
     167load_image_section(int fd, openmcl_image_section_header *sect)
     168{
     169}
     170#else
    165171void
    166172load_image_section(int fd, openmcl_image_section_header *sect)
     
    236242  lseek(fd, pos+advance, SEEK_SET);
    237243}
    238    
     244#endif
     245
     246#ifdef WINDOWS
     247LispObj
     248load_openmcl_image(int fd, openmcl_image_file_header *h)
     249{
     250}
     251#else
    239252LispObj
    240253load_openmcl_image(int fd, openmcl_image_file_header *h)
     
    319332  return image_nil;
    320333}
    321      
     334#endif
     335 
    322336void
    323337prepare_to_write_dynamic_space()
     
    518532  trailer.delta = (int) (header_pos-eof_pos);
    519533  if (write(fd, &trailer, sizeof(trailer)) == sizeof(trailer)) {
     534#ifndef WINDOWS
    520535    fsync(fd);
     536#endif
    521537    close(fd);
    522538    return 0;
  • trunk/source/lisp-kernel/lisp-debug.c

    r8415 r8547  
    6969#if defined(LINUX) || defined(SOLARIS)
    7070#define fpurge __fpurge
     71#endif
     72
     73#ifdef WINDOWS
     74void
     75fpurge (FILE* file)
     76{
     77}
    7178#endif
    7279
     
    111118                     "rbp", "rsp", "r8 ", "r9 ", "r10", "r11", "r12", "r13",
    112119                     "r14", "r15", "rip", "rfl"};
     120#endif
     121#ifdef WINDOWS
     122/* is this correct? */
     123char* Iregnames[] = {"r8 ","r9 ","r10","r11","r12","r13","r14","r15",
     124                     "rdi","rsi","rbp", "rbx", "rdx", "rax", "rcx","rsp"};
    113125#endif
    114126#endif
     
    531543     
    532544
     545#ifdef WINDOWS
     546debug_command_return
     547debug_set_gpr(ExceptionInformation *xp, siginfo_t *info, int arg)
     548{
     549}
     550#else
    533551debug_command_return
    534552debug_set_gpr(ExceptionInformation *xp, siginfo_t *info, int arg)
     
    542560  return debug_continue;
    543561}
    544 
     562#endif
    545563
    546564debug_command_return
     
    619637  struct xmm *xmmp = (struct xmm *)(xpFPRvector(xp));
    620638#endif
     639#ifdef WINDOWS
     640  struct xmm {
     641    char fpdata[16];
     642  };
     643  struct xmm *xmmp; /* XXX: actually get them */
     644#endif
    621645#ifdef FREEBSD
    622646  struct xmmacc *xmmp = xpXMMregs(xp);
     
    640664#ifdef FREEBSD
    641665          (((struct savefpu *)(&(xp)->uc_mcontext.mc_fpstate))->sv_env.en_mxcsr)
     666#endif
     667#ifdef WINDOWS
     668          0 /* XXX: get from somewhere */
    642669#endif
    643670          );
  • trunk/source/lisp-kernel/lisp-exceptions.h

    r7835 r8547  
    9797#define debug_entry_dbg -2
    9898
     99#ifdef WINDOWS
     100#define ALLOW_EXCEPTIONS(context) // blank stare for now
     101#else
    99102#define ALLOW_EXCEPTIONS(context) \
    100103  pthread_sigmask(SIG_SETMASK, &context->uc_sigmask, NULL);
    101 
     104#endif
    102105
    103106void
  • trunk/source/lisp-kernel/lisptypes.h

    r7828 r8547  
    3030
    3131
    32 #include <stdint.h>
    33 
    3432#ifdef WIN64
    3533#include <windows.h>
     
    4341typedef unsigned char u8_t;
    4442#else
     43
     44#include <stdint.h>
     45
    4546#ifdef SOLARIS
    4647/* Solaris doesn't laugh and play like the other children */
  • trunk/source/lisp-kernel/macros.h

    r4348 r8547  
    7575#endif
    7676
    77 
     77#ifdef VC
     78#define inline
     79#define __attribute__(x)
     80#endif
    7881
    7982/* lfuns */
  • trunk/source/lisp-kernel/memory.c

    r8475 r8547  
    616616}
    617617
     618#ifdef WINDOWS
     619void
     620release_readonly_area()
     621{
     622}
     623#else
    618624void
    619625release_readonly_area()
     
    625631  pure_space_active = pure_space_start;
    626632}
     633#endif
  • trunk/source/lisp-kernel/pmcl-kernel.c

    r8408 r8547  
    3636#include <fcntl.h>
    3737#include <signal.h>
    38 #include <unistd.h>
    3938#include <errno.h>
    4039#ifndef WINDOWS
    4140#include <sys/utsname.h>
     41#include <unistd.h>
    4242#endif
    4343
     
    420420*/
    421421
     422#ifdef WINDOWS
     423void
     424uncommit_pages(void *start, size_t len)
     425{
     426}
     427#else
    422428void
    423429uncommit_pages(void *start, size_t len)
     
    437443  }
    438444}
     445#endif
    439446
    440447#define TOUCH_PAGES_ON_COMMIT 0
     
    458465}
    459466
     467#ifdef WINDOWS
     468Boolean
     469commit_pages(void *start, size_t len)
     470{
     471}
     472#else
    460473Boolean
    461474commit_pages(void *start, size_t len)
     
    489502  }
    490503}
     504#endif
    491505
    492506area *
     
    503517}
    504518
     519#ifdef WINDOWS
     520area *
     521extend_readonly_area(unsigned more)
     522{
     523}
     524#else
    505525area *
    506526extend_readonly_area(unsigned more)
     
    532552  return NULL;
    533553}
     554#endif
    534555
    535556LispObj image_base=0;
     
    599620
    600621
    601 
     622#ifdef WINDOWS
     623area *
     624create_reserved_area(natural totalsize)
     625{
     626}
     627#else
    602628area *
    603629create_reserved_area(natural totalsize)
     
    705731  return reserved;
    706732}
    707 
     733#endif
    708734
    709735void *
     
    12031229pid_t main_thread_pid = (pid_t)0;
    12041230
     1231#ifdef WINDOWS
     1232void
     1233terminate_lisp()
     1234{
     1235}
     1236#else
    12051237void
    12061238terminate_lisp()
     
    12091241  _exit(-1);
    12101242}
     1243#endif
    12111244
    12121245#ifdef DARWIN
     
    12791312
    12801313#ifdef X8664
     1314#ifdef WINDOWS
     1315void
     1316remap_spjump()
     1317{
     1318}
     1319#else
    12811320void
    12821321remap_spjump()
     
    12961335  memmove(new, old, 0x1000);
    12971336}
     1337#endif
    12981338#endif
    12991339
     
    15941634#endif
    15951635  tcr->prev = tcr->next = tcr;
     1636#ifndef WINDOWS
    15961637  lisp_global(INTERRUPT_SIGNAL) = (LispObj) box_fixnum(SIGNAL_FOR_PROCESS_INTERRUPT);
     1638#endif
    15971639  tcr->vs_area->active -= node_size;
    15981640  *(--tcr->save_vsp) = nrs_TOPLFUNC.vcell;
     
    16511693#ifndef DARWIN
    16521694#ifdef WINDOWS
     1695void *
     1696xGetSharedLibrary(char *path, int mode)
     1697{
     1698}
    16531699#else
    16541700void *
     
    17851831}
    17861832
     1833#ifdef WINDOWS
    17871834int
    17881835do_fd_is_set(int fd, fd_set *fdsetp)
    17891836{
     1837}
     1838#else
     1839int
     1840do_fd_is_set(int fd, fd_set *fdsetp)
     1841{
    17901842  return FD_ISSET(fd,fdsetp);
    17911843}
     1844#endif
    17921845
    17931846void
     
    19241977
    19251978#else
    1926 #ifndef WINDOWS
     1979#ifdef WINDOWS
     1980void
     1981sample_paging_info(paging_info *stats)
     1982{
     1983}
     1984
     1985void
     1986report_paging_info_delta(FILE *out, paging_info *start, paging_info *stop)
     1987{
     1988}
     1989#else
    19271990void
    19281991sample_paging_info(paging_info *stats)
  • trunk/source/lisp-kernel/thread_manager.c

    r8408 r8547  
    5252#endif
    5353
     54#ifdef WINDOWS
     55int
     56raise_thread_interrupt(TCR *target)
     57{
     58}
     59#else
    5460int
    5561raise_thread_interrupt(TCR *target)
     
    6268 return pthread_kill((pthread_t)target->osid, SIGNAL_FOR_PROCESS_INTERRUPT);
    6369}
     70#endif
    6471
    6572signed_natural
     
    108115      }
    109116    }
     117#ifndef WINDOWS
    110118    sched_yield();
     119#endif
    111120  }
    112121}
     
    385394
    386395 
     396#ifdef WINDOWS
    387397LispObj
    388398current_thread_osid()
    389399{
     400}
     401#else
     402LispObj
     403current_thread_osid()
     404{
    390405  return (LispObj)ptr_to_lispobj(pthread_self());
    391406}
    392 
     407#endif
    393408
    394409
     
    478493*/
    479494 
     495#ifdef WINDOWS
     496void
     497os_get_stack_bounds(LispObj q,void **base, natural *size)
     498{
     499}
     500#else
    480501void
    481502os_get_stack_bounds(LispObj q,void **base, natural *size)
     
    508529
    509530}
     531#endif
    510532
    511533void *
     
    572594}
    573595
     596#ifdef WINDOWS
    574597void
    575598tsd_set(LispObj key, void *datum)
    576599{
    577   pthread_setspecific((pthread_key_t)key, datum);
    578600}
    579601
     
    581603tsd_get(LispObj key)
    582604{
     605}
     606#else
     607void
     608tsd_set(LispObj key, void *datum)
     609{
     610  pthread_setspecific((pthread_key_t)key, datum);
     611}
     612
     613void *
     614tsd_get(LispObj key)
     615{
    583616  return pthread_getspecific((pthread_key_t)key);
    584617}
     618#endif
    585619
    586620void
     
    690724  Caller must hold the area_lock.
    691725*/
     726#ifdef WINDOWS
     727TCR *
     728new_tcr(natural vstack_size, natural tstack_size)
     729{
     730}
     731#else
    692732TCR *
    693733new_tcr(natural vstack_size, natural tstack_size)
     
    758798  return tcr;
    759799}
     800#endif
    760801
    761802void
     
    858899          pthread_self()
    859900#endif
     901#ifdef WINDOWS
     902          /* ThreadSelf() */ 23
     903#endif
    860904          );
    861905}
     
    921965#endif
    922966
     967#ifdef WINDOWS
     968Ptr
     969create_stack(int size)
     970{
     971}
     972#else
    923973Ptr
    924974create_stack(int size)
     
    940990
    941991}
    942  
     992#endif
     993
    943994void *
    944995allocate_stack(unsigned size)
     
    947998}
    948999
     1000#ifdef WINDOWS
     1001void
     1002free_stack(void *s)
     1003{
     1004}
     1005#else
    9491006void
    9501007free_stack(void *s)
     
    9531010  munmap(s, size);
    9541011}
     1012#endif
    9551013
    9561014Boolean threads_initialized = false;
    9571015
    9581016#ifndef USE_FUTEX
     1017#ifdef WINDOWS
     1018void
     1019count_cpus()
     1020{
     1021}
     1022#else
    9591023void
    9601024count_cpus()
     
    9811045}
    9821046#endif
    983 
    984 
     1047#endif
     1048
     1049#ifdef WINDOWS
     1050void
     1051init_threads(void * stack_base, TCR *tcr)
     1052{
     1053}
     1054void *
     1055lisp_thread_entry(void *param)
     1056{
     1057}
     1058#else
    9851059void
    9861060init_threads(void * stack_base, TCR *tcr)
     
    10251099
    10261100}
    1027 
     1101#endif
    10281102
    10291103void *
     
    10661140}
    10671141
    1068 
     1142#ifdef WINDOWS
     1143OSErr
     1144xDisposeThread(TCR *tcr)
     1145{
     1146}
     1147#else
    10691148OSErr
    10701149xDisposeThread(TCR *tcr)
     
    10781157  return -50;
    10791158}
     1159#endif
    10801160
    10811161OSErr
     
    10941174
    10951175
    1096 
     1176#ifdef WINDOWS
    10971177LispObj
    10981178create_system_thread(size_t stack_size,
     
    11011181                     void* param)
    11021182{
     1183}
     1184#else
     1185LispObj
     1186create_system_thread(size_t stack_size,
     1187                     void* stackaddr,
     1188                     void* (*start_routine)(void *),
     1189                     void* param)
     1190{
    11031191  pthread_attr_t attr;
    11041192  pthread_t returned_thread = (pthread_t) 0;
     
    11291217  return (LispObj) ptr_to_lispobj(returned_thread);
    11301218}
     1219#endif
    11311220
    11321221TCR *
     
    11511240    register_thread_tcr(current);
    11521241#ifdef DEBUG_TCR_CREATION
     1242#ifndef WINDOWS
    11531243    fprintf(stderr, "\ncreating TCR for pthread 0x%x", pthread_self());
     1244#endif
    11541245#endif
    11551246    current->vs_area->active -= node_size;
     
    11781269}
    11791270
    1180 
     1271#ifdef WINDOWS
     1272Boolean
     1273suspend_tcr(TCR *tcr)
     1274{
     1275}
     1276#else
    11811277Boolean
    11821278suspend_tcr(TCR *tcr)
     
    12091305  return false;
    12101306}
     1307#endif
    12111308
    12121309Boolean
  • trunk/source/lisp-kernel/win64/Makefile

    r8387 r8547  
    1919# gcc64, as64: until there's a real win64 gcc, assume that gcc and gas
    2020# are installed under these names
    21 CC = gcc64
    22 AS = as64
     21CC = x86_64-pc-mingw32-gcc
     22AS = x86_64-pc-mingw32-as
    2323M4 = m4
    24 LD = ld
    25 ASFLAGS = --64
     24LD = x86_64-pc-mingw32-ld
     25ASFLAGS = -g --64
    2626M4FLAGS = -DWIN64 -DWINDOWS -DX86 -DX8664 -DHAVE_TLS -DEMUTLS
    2727CDEFINES = -DWIN64 -DWINDOWS -D_REENTRANT -DX86 -DX8664 -D_GNU_SOURCE -DHAVE_TLS -DEMUTLS #-DDISABLE_EGC
     
    6363
    6464KSPOBJ = $(SPOBJ)
    65 all:    ../../wx86cl64
     65all:    ../../wx86cl64.exe
    6666
    6767
    68 OSLIBS = -ldl -lm -lpthread
     68OSLIBS =
    6969
    7070
    71 ../../wx86cl64: $(KSPOBJ) $(KERNELOBJ) $(DEBUGOBJ) Makefile
     71../../wx86cl64.exe:     $(KSPOBJ) $(KERNELOBJ) $(DEBUGOBJ) Makefile
    7272        $(CC)  -m64 $(CDEBUG)  -Wl,--export-dynamic $(HASH_STYLE) -o $@ $(USE_LINK_MAP) $(KSPOBJ) $(KERNELOBJ) $(DEBUGOBJ) $(OSLIBS)
    7373
     
    8080
    8181cclean:
    82         $(RM) -f $(KERNELOBJ) $(DEBUGOBJ) ../../wx86cl64
     82        $(RM) -f $(KERNELOBJ) $(DEBUGOBJ) ../../wx86cl64.exe
    8383
    8484clean:  cclean
    8585        $(RM) -f $(SPOBJ)
    8686
    87 strip:  ../../wx86cl64
    88         strip -g ../../wx86cl64
     87strip:  ../../wx86cl64.exe
     88        strip -g ../../wx86cl64.exe
  • trunk/source/lisp-kernel/x86-constants64.h

    r8397 r8547  
    9696#define Isp         REG_RSP
    9797#define Iip         REG_RIP
    98 #ifdef LINUX
     98#if defined(LINUX) || defined(WINDOWS)
    9999#define Iflags      REG_EFL
    100100#endif
  • trunk/source/lisp-kernel/x86-exceptions.c

    r8540 r8547  
    441441                  natural arg1, natural arg2, natural arg3, natural arg4, natural arg5)
    442442{
    443   sigset_t mask;
    444443  natural  callback_ptr, i;
    445444  int delta;
     
    627626}
    628627
     628#ifdef WINDOWS
     629Boolean
     630handle_fault(TCR *tcr, ExceptionInformation *xp, siginfo_t *info, int old_valence)
     631{
     632}
     633
     634Boolean
     635handle_floating_point_exception(TCR *tcr, ExceptionInformation *xp, siginfo_t *info)
     636{
     637}
     638#else
    629639Boolean
    630640handle_fault(TCR *tcr, ExceptionInformation *xp, siginfo_t *info, int old_valence)
     
    689699  }
    690700}
     701#endif
    691702
    692703Boolean
     
    791802}
    792803
     804#ifdef WINDOWS
     805Boolean
     806handle_exception(int signum, siginfo_t *info, ExceptionInformation  *context, TCR *tcr, int old_valence)
     807{
     808}
     809#else
    793810Boolean
    794811handle_exception(int signum, siginfo_t *info, ExceptionInformation  *context, TCR *tcr, int old_valence)
     
    913930  }
    914931}
    915 
     932#endif
    916933
    917934/*
     
    966983   that the thread sees it as soon as it's able to run.
    967984*/
     985#ifdef WINDOWS
     986void
     987raise_pending_interrupt(TCR *tcr)
     988{
     989}
     990void
     991exit_signal_handler(TCR *tcr, int old_valence)
     992{
     993}
     994void
     995signal_handler(int signum, siginfo_t *info, ExceptionInformation  *context, TCR *tcr, int old_valence)
     996{
     997}
     998#else
    968999void
    9691000raise_pending_interrupt(TCR *tcr)
     
    10291060#endif
    10301061}
     1062#endif
    10311063
    10321064#ifdef DARWIN
     
    10911123#endif
    10921124
     1125#ifdef WINDOWS
     1126LispObj *
     1127copy_ucontext(ExceptionInformation *context, LispObj *current, copy_ucontext_last_arg_t fp)
     1128{
     1129}
     1130#else
    10931131LispObj *
    10941132copy_ucontext(ExceptionInformation *context, LispObj *current, copy_ucontext_last_arg_t fp)
     
    11091147  return (LispObj *)dest;
    11101148}
     1149#endif
    11111150
    11121151LispObj *
     
    12401279}
    12411280
     1281#ifdef WINDOWS
     1282void
     1283interrupt_handler (int signum, siginfo_t *info, ExceptionInformation *context)
     1284{
     1285}
     1286#else
    12421287void
    12431288interrupt_handler (int signum, siginfo_t *info, ExceptionInformation *context)
     
    13101355  SIGRETURN(context);
    13111356}
     1357#endif
    13121358
    13131359#ifndef USE_SIGALTSTACK
     
    13641410#endif
    13651411
    1366 
     1412#ifdef WINDOWS
     1413void
     1414install_signal_handler(int signo, void * handler)
     1415{
     1416}
     1417#else
    13671418void
    13681419install_signal_handler(int signo, void * handler)
     
    13891440  sigaction(signo, &sa, NULL);
    13901441}
    1391 
    1392 
     1442#endif
     1443
     1444#ifdef WINDOWS
     1445void
     1446install_pmcl_exception_handlers()
     1447{
     1448}
     1449#else
    13931450void
    13941451install_pmcl_exception_handlers()
     
    14271484  signal(SIGPIPE, SIG_IGN);
    14281485}
     1486#endif
    14291487
    14301488#ifndef USE_SIGALTSTACK
     
    14861544#endif
    14871545
     1546#ifdef WINDOWS
     1547void
     1548quit_handler(int signum, siginfo_t *info, ExceptionInformation *xp)
     1549{
     1550}
     1551#else
    14881552void
    14891553quit_handler(int signum, siginfo_t *info, ExceptionInformation *xp)
     
    15181582  pthread_exit(NULL);
    15191583}
     1584#endif
    15201585
    15211586#ifndef USE_SIGALTSTACK
     
    15831648#endif
    15841649
     1650#ifdef WINDOWS
     1651void
     1652thread_signal_setup()
     1653{
     1654}
     1655#else
    15851656void
    15861657thread_signal_setup()
     
    15911662  install_signal_handler(SIGQUIT, (void *)QUIT_HANDLER);
    15921663}
    1593 
     1664#endif
    15941665
    15951666void
     
    17101781}
    17111782     
    1712  
     1783#ifdef WINDOWS 
     1784void
     1785pc_luser_xp(ExceptionInformation *xp, TCR *tcr, signed_natural *interrupt_displacement)
     1786{
     1787}
     1788#else
    17131789void
    17141790pc_luser_xp(ExceptionInformation *xp, TCR *tcr, signed_natural *interrupt_displacement)
     
    18731949  }
    18741950}
     1951#endif
    18751952
    18761953void
  • trunk/source/lisp-kernel/x86-gc.c

    r8475 r8547  
    22652265}
    22662266
     2267#ifdef WINDOWS
     2268int
     2269impurify(TCR *tcr, signed_natural param)
     2270{
     2271}
     2272#else
    22672273int
    22682274impurify(TCR *tcr, signed_natural param)
     
    23082314  return -1;
    23092315}
     2316#endif
  • trunk/source/lisp-kernel/x86-spentry64.s

    r8526 r8547  
    44834483        __ifdef([HAVE_TLS])
    44844484         /* TCR initialized for lisp ?   */
     4485         __ifndef([WINDOWS]) /* FIXME */
    44854486         __(movq %fs:current_tcr@TPOFF+tcr.linear,%rax)
     4487         __endif
    44864488         __(testq %rax,%rax)
    44874489         __(jne 1f)
Note: See TracChangeset for help on using the changeset viewer.