Ignore:
Timestamp:
Feb 21, 2008, 4:22:15 PM (13 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.