Panda3D
contextSwitch.c
1 /* Filename: contextSwitch.c
2  * Created by: drose (21Jun07)
3  *
4  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
5  *
6  * PANDA 3D SOFTWARE
7  * Copyright (c) Carnegie Mellon University. All rights reserved.
8  *
9  * All use of this software is subject to the terms of the revised BSD
10  * license. You should have received a copy of this license along
11  * with this source code in a file named "LICENSE."
12  *
13  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
14 
15 #include "contextSwitch.h"
16 
17 #include <stdlib.h>
18 #include <stdio.h>
19 
20 #if defined(THREAD_SIMPLE_IMPL) && !defined(CPPPARSER)
21 
22 /* With OS_SIMPLE_THREADS, we will try to implement context-switching
23  using OS-provided threading constructs. This is via either Windows
24  or Posix threads. */
25 
26 #if defined(WIN32) && defined(OS_SIMPLE_THREADS)
27 
28 #include "contextSwitch_windows_src.c"
29 
30 #elif defined(HAVE_POSIX_THREADS) && defined(OS_SIMPLE_THREADS)
31 
32 #include "contextSwitch_posix_src.c"
33 
34 #elif defined(PHAVE_UCONTEXT_H)
35 
36 /* Without OS_SIMPLE_THREADS, or without Windows or Posix threads
37  libraries available, we have to implement context-switching
38  entirely in user space. First choice: the ucontext.h interface. */
39 
40 #include "contextSwitch_ucontext_src.c"
41 
42 #else
43 
44 /* Second choice: old fashioned setjmp/longjmp, with some a priori
45  hacks to make it switch stacks. */
46 
47 #include "contextSwitch_longjmp_src.c"
48 
49 #endif /* PHAVE_UCONTEXT_H */
50 
51 #endif /* THREAD_SIMPLE_IMPL */
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.