Panda3D

contextSwitch.c

00001 /* Filename: contextSwitch.c
00002  * Created by:  drose (21Jun07)
00003  *
00004  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00005  *
00006  * PANDA 3D SOFTWARE
00007  * Copyright (c) Carnegie Mellon University.  All rights reserved.
00008  *
00009  * All use of this software is subject to the terms of the revised BSD
00010  * license.  You should have received a copy of this license along
00011  * with this source code in a file named "LICENSE."
00012  *
00013  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00014 
00015 #include "contextSwitch.h"
00016 
00017 #include <stdlib.h>
00018 #include <stdio.h>
00019 
00020 #if defined(THREAD_SIMPLE_IMPL) && !defined(CPPPARSER)
00021 
00022 /* With OS_SIMPLE_THREADS, we will try to implement context-switching
00023    using OS-provided threading constructs.  This is via either Windows
00024    or Posix threads. */
00025 
00026 #if defined(WIN32) && defined(OS_SIMPLE_THREADS)
00027 
00028 #include "contextSwitch_windows_src.c"
00029 
00030 #elif defined(HAVE_POSIX_THREADS) && defined(OS_SIMPLE_THREADS)
00031 
00032 #include "contextSwitch_posix_src.c"
00033 
00034 #elif defined(PHAVE_UCONTEXT_H)
00035 
00036 /* Without OS_SIMPLE_THREADS, or without Windows or Posix threads
00037    libraries available, we have to implement context-switching
00038    entirely in user space.  First choice: the ucontext.h interface. */
00039 
00040 #include "contextSwitch_ucontext_src.c"
00041 
00042 #else
00043 
00044 /* Second choice: old fashioned setjmp/longjmp, with some a priori
00045    hacks to make it switch stacks. */
00046 
00047 #include "contextSwitch_longjmp_src.c"
00048 
00049 #endif  /* PHAVE_UCONTEXT_H */
00050 
00051 #endif  /* THREAD_SIMPLE_IMPL */
 All Classes Functions Variables Enumerations