SDL  2.0
SDL_quit.c File Reference
#include "../SDL_internal.h"
#include "SDL_hints.h"
#include "SDL_assert.h"
#include "SDL_events.h"
#include "SDL_events_c.h"
+ Include dependency graph for SDL_quit.c:

Go to the source code of this file.

Macros

#define HAVE_SIGNAL_SUPPORT   1
 

Functions

static void SDL_HandleSIG (int sig)
 
static void SDL_EventSignal_Init (const int sig)
 
static void SDL_EventSignal_Quit (const int sig)
 
static int SDL_QuitInit_Internal (void)
 
static void SDL_QuitQuit_Internal (void)
 
int SDL_QuitInit (void)
 
void SDL_QuitQuit (void)
 
void SDL_SendPendingSignalEvents (void)
 
int SDL_SendQuit (void)
 

Variables

static SDL_bool disable_signals = SDL_FALSE
 
static SDL_bool send_quit_pending = SDL_FALSE
 

Macro Definition Documentation

◆ HAVE_SIGNAL_SUPPORT

#define HAVE_SIGNAL_SUPPORT   1

Definition at line 36 of file SDL_quit.c.

Function Documentation

◆ SDL_EventSignal_Init()

static void SDL_EventSignal_Init ( const int  sig)
static

Definition at line 76 of file SDL_quit.c.

77 {
78 #ifdef HAVE_SIGACTION
79  struct sigaction action;
80 
81  sigaction(sig, NULL, &action);
82 #ifdef HAVE_SA_SIGACTION
83  if ( action.sa_handler == SIG_DFL && (void (*)(int))action.sa_sigaction == SIG_DFL ) {
84 #else
85  if ( action.sa_handler == SIG_DFL ) {
86 #endif
87  action.sa_handler = SDL_HandleSIG;
88  sigaction(sig, &action, NULL);
89  }
90 #elif HAVE_SIGNAL_H
91  void (*ohandler) (int) = signal(sig, SDL_HandleSIG);
92  if (ohandler != SIG_DFL) {
93  signal(sig, ohandler);
94  }
95 #endif
96 }

References action, NULL, SDL_HandleSIG(), and void.

Referenced by SDL_QuitInit_Internal().

◆ SDL_EventSignal_Quit()

static void SDL_EventSignal_Quit ( const int  sig)
static

Definition at line 99 of file SDL_quit.c.

100 {
101 #ifdef HAVE_SIGACTION
102  struct sigaction action;
103  sigaction(sig, NULL, &action);
104  if ( action.sa_handler == SDL_HandleSIG ) {
105  action.sa_handler = SIG_DFL;
106  sigaction(sig, &action, NULL);
107  }
108 #elif HAVE_SIGNAL_H
109  void (*ohandler) (int) = signal(sig, SIG_DFL);
110  if (ohandler != SDL_HandleSIG) {
111  signal(sig, ohandler);
112  }
113 #endif /* HAVE_SIGNAL_H */
114 }

References action, NULL, SDL_HandleSIG(), and void.

Referenced by SDL_QuitQuit_Internal().

◆ SDL_HandleSIG()

static void SDL_HandleSIG ( int  sig)
static

Definition at line 51 of file SDL_quit.c.

52 {
53  /* Reset the signal handler */
54  signal(sig, SDL_HandleSIG);
55 
56  /* Send a quit event next time the event loop pumps. */
57  /* We can't send it in signal handler; malloc() might be interrupted! */
58  if ((sig == SIGINT) || (sig == SIGTERM)) {
60  }
61 
62  #ifdef SDL_BACKGROUNDING_SIGNAL
63  else if (sig == SDL_BACKGROUNDING_SIGNAL) {
64  send_backgrounding_pending = SDL_TRUE;
65  }
66  #endif
67 
68  #ifdef SDL_FOREGROUNDING_SIGNAL
69  else if (sig == SDL_FOREGROUNDING_SIGNAL) {
70  send_foregrounding_pending = SDL_TRUE;
71  }
72  #endif
73 }

References SDL_TRUE, and send_quit_pending.

Referenced by SDL_EventSignal_Init(), and SDL_EventSignal_Quit().

◆ SDL_QuitInit()

int SDL_QuitInit ( void  )

Definition at line 154 of file SDL_quit.c.

155 {
156 #ifdef HAVE_SIGNAL_SUPPORT
158  return SDL_QuitInit_Internal();
159  }
160 #endif
161  return 0;
162 }

References SDL_FALSE, SDL_GetHintBoolean, SDL_HINT_NO_SIGNAL_HANDLERS, and SDL_QuitInit_Internal().

Referenced by SDL_EventsInit().

◆ SDL_QuitInit_Internal()

static int SDL_QuitInit_Internal ( void  )
static

Definition at line 118 of file SDL_quit.c.

119 {
120  /* Both SIGINT and SIGTERM are translated into quit interrupts */
121  /* and SDL can be built to simulate iOS/Android semantics with arbitrary signals. */
122  SDL_EventSignal_Init(SIGINT);
123  SDL_EventSignal_Init(SIGTERM);
124 
125  #ifdef SDL_BACKGROUNDING_SIGNAL
126  SDL_EventSignal_Init(SDL_BACKGROUNDING_SIGNAL);
127  #endif
128 
129  #ifdef SDL_FOREGROUNDING_SIGNAL
130  SDL_EventSignal_Init(SDL_FOREGROUNDING_SIGNAL);
131  #endif
132 
133  /* That's it! */
134  return 0;
135 }

References SDL_EventSignal_Init().

Referenced by SDL_QuitInit().

◆ SDL_QuitQuit()

void SDL_QuitQuit ( void  )

Definition at line 165 of file SDL_quit.c.

166 {
167 #ifdef HAVE_SIGNAL_SUPPORT
168  if (!disable_signals) {
170  }
171 #endif
172 }

References disable_signals, and SDL_QuitQuit_Internal().

Referenced by SDL_EventsQuit().

◆ SDL_QuitQuit_Internal()

static void SDL_QuitQuit_Internal ( void  )
static

Definition at line 138 of file SDL_quit.c.

139 {
140  SDL_EventSignal_Quit(SIGINT);
141  SDL_EventSignal_Quit(SIGTERM);
142 
143  #ifdef SDL_BACKGROUNDING_SIGNAL
144  SDL_EventSignal_Quit(SDL_BACKGROUNDING_SIGNAL);
145  #endif
146 
147  #ifdef SDL_FOREGROUNDING_SIGNAL
148  SDL_EventSignal_Quit(SDL_FOREGROUNDING_SIGNAL);
149  #endif
150 }

References SDL_EventSignal_Quit().

Referenced by SDL_QuitQuit().

◆ SDL_SendPendingSignalEvents()

void SDL_SendPendingSignalEvents ( void  )

Definition at line 175 of file SDL_quit.c.

176 {
177 #ifdef HAVE_SIGNAL_SUPPORT
178  if (send_quit_pending) {
179  SDL_SendQuit();
181  }
182 
183  #ifdef SDL_BACKGROUNDING_SIGNAL
184  if (send_backgrounding_pending) {
185  send_backgrounding_pending = SDL_FALSE;
187  }
188  #endif
189 
190  #ifdef SDL_FOREGROUNDING_SIGNAL
191  if (send_foregrounding_pending) {
192  send_foregrounding_pending = SDL_FALSE;
194  }
195  #endif
196 #endif
197 }

References SDL_assert, SDL_FALSE, SDL_OnApplicationDidBecomeActive, SDL_OnApplicationWillResignActive, SDL_SendQuit(), and send_quit_pending.

Referenced by SDL_PumpEvents().

◆ SDL_SendQuit()

int SDL_SendQuit ( void  )

Definition at line 201 of file SDL_quit.c.

202 {
203 #ifdef HAVE_SIGNAL_SUPPORT
205 #endif
206  return SDL_SendAppEvent(SDL_QUIT);
207 }

References SDL_FALSE, SDL_QUIT, SDL_SendAppEvent(), and send_quit_pending.

Referenced by SDL_SendPendingSignalEvents(), and SDL_SendWindowEvent().

Variable Documentation

◆ disable_signals

SDL_bool disable_signals = SDL_FALSE
static

Definition at line 39 of file SDL_quit.c.

Referenced by SDL_QuitQuit().

◆ send_quit_pending

SDL_bool send_quit_pending = SDL_FALSE
static

Definition at line 40 of file SDL_quit.c.

Referenced by SDL_HandleSIG(), SDL_SendPendingSignalEvents(), and SDL_SendQuit().

disable_signals
static SDL_bool disable_signals
Definition: SDL_quit.c:39
SDL_QuitQuit_Internal
static void SDL_QuitQuit_Internal(void)
Definition: SDL_quit.c:138
NULL
#define NULL
Definition: begin_code.h:167
SDL_HandleSIG
static void SDL_HandleSIG(int sig)
Definition: SDL_quit.c:51
SDL_EventSignal_Init
static void SDL_EventSignal_Init(const int sig)
Definition: SDL_quit.c:76
SDL_GetHintBoolean
#define SDL_GetHintBoolean
Definition: SDL_dynapi_overrides.h:608
SDL_QUIT
@ SDL_QUIT
Definition: SDL_events.h:60
SDL_SendQuit
int SDL_SendQuit(void)
Definition: SDL_quit.c:201
SDL_TRUE
@ SDL_TRUE
Definition: SDL_stdinc.h:164
SDL_assert
#define SDL_assert(condition)
Definition: SDL_assert.h:169
SDL_EventSignal_Quit
static void SDL_EventSignal_Quit(const int sig)
Definition: SDL_quit.c:99
action
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF base if bpp PF set rept prefetch_distance PF set OFFSET endr endif endm macro preload_leading_step2 base if bpp ifc DST PF PF else if bpp lsl PF PF lsl PF PF lsl PF PF PF else PF lsl PF lsl PF lsl PF endif SIZE macro preload_middle scratch_holds_offset if bpp if else PF PF endif endif endif endm macro preload_trailing base if bpp if bpp *pix_per_block PF PF lsl PF PF PF PF PF else PF lsl PF lsl PF PF PF PF PF base if bpp if narrow_case &&bpp<=dst_w_bpp) PF bic, WK0, base, #31 PF pld,[WK0] PF add, WK1, base, X, LSL #bpp_shift PF sub, WK1, WK1, #1 PF bic, WK1, WK1, #31 PF cmp, WK1, WK0 PF beq, 90f PF pld,[WK1]90:.else PF bic, WK0, base, #31 PF pld,[WK0] PF add, WK1, base, X, lsl #bpp_shift PF sub, WK1, WK1, #1 PF bic, WK1, WK1, #31 PF cmp, WK1, WK0 PF beq, 92f91:PF add, WK0, WK0, #32 PF cmp, WK0, WK1 PF pld,[WK0] PF bne, 91b92:.endif .endif.endm.macro conditional_process1_helper cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx process_head cond, numbytes, firstreg, unaligned_src, unaligned_mask, 0 .if decrementx sub &cond X, X, #8 *numbytes/dst_w_bpp .endif process_tail cond, numbytes, firstreg .if !((flags) &FLAG_PROCESS_DOES_STORE) pixst cond, numbytes, firstreg, DST .endif.endm.macro conditional_process1 cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx .if(flags) &FLAG_BRANCH_OVER .ifc cond, mi bpl 100f .endif .ifc cond, cs bcc 100f .endif .ifc cond, ne beq 100f .endif conditional_process1_helper, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx100:.else conditional_process1_helper cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx .endif.endm.macro conditional_process2 test, cond1, cond2, process_head, process_tail, numbytes1, numbytes2, firstreg1, firstreg2, unaligned_src, unaligned_mask, decrementx .if(flags) &(FLAG_DST_READWRITE|FLAG_BRANCH_OVER|FLAG_PROCESS_CORRUPTS_PSR|FLAG_PROCESS_DOES_STORE) test conditional_process1 cond1, process_head, process_tail, numbytes1, firstreg1, unaligned_src, unaligned_mask, decrementx .if(flags) &FLAG_PROCESS_CORRUPTS_PSR test .endif conditional_process1 cond2, process_head, process_tail, numbytes2, firstreg2, unaligned_src, unaligned_mask, decrementx .else test process_head cond1, numbytes1, firstreg1, unaligned_src, unaligned_mask, 0 process_head cond2, numbytes2, firstreg2, unaligned_src, unaligned_mask, 0 .if decrementx sub &cond1 X, X, #8 *numbytes1/dst_w_bpp sub &cond2 X, X, #8 *numbytes2/dst_w_bpp .endif process_tail cond1, numbytes1, firstreg1 process_tail cond2, numbytes2, firstreg2 pixst cond1, numbytes1, firstreg1, DST pixst cond2, numbytes2, firstreg2, DST .endif.endm.macro test_bits_1_0_ptr .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 movs SCRATCH, X, lsl #32-1 .else movs SCRATCH, WK0, lsl #32-1 .endif.endm.macro test_bits_3_2_ptr .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 movs SCRATCH, X, lsl #32-3 .else movs SCRATCH, WK0, lsl #32-3 .endif.endm.macro leading_15bytes process_head, process_tail .set DECREMENT_X, 1 .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 .set DECREMENT_X, 0 sub X, X, WK0, lsr #dst_bpp_shift str X,[sp, #LINE_SAVED_REG_COUNT *4] mov X, WK0 .endif .if dst_w_bpp==8 conditional_process2 test_bits_1_0_ptr, mi, cs, process_head, process_tail, 1, 2, 1, 2, 1, 1, DECREMENT_X .elseif dst_w_bpp==16 test_bits_1_0_ptr conditional_process1 cs, process_head, process_tail, 2, 2, 1, 1, DECREMENT_X .endif conditional_process2 test_bits_3_2_ptr, mi, cs, process_head, process_tail, 4, 8, 1, 2, 1, 1, DECREMENT_X .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 ldr X,[sp, #LINE_SAVED_REG_COUNT *4] .endif.endm.macro test_bits_3_2_pix movs SCRATCH, X, lsl #dst_bpp_shift+32-3.endm.macro test_bits_1_0_pix .if dst_w_bpp==8 movs SCRATCH, X, lsl #dst_bpp_shift+32-1 .else movs SCRATCH, X, lsr #1 .endif.endm.macro trailing_15bytes process_head, process_tail, unaligned_src, unaligned_mask conditional_process2 test_bits_3_2_pix, cs, mi, process_head, process_tail, 8, 4, 0, 2, unaligned_src, unaligned_mask, 0 .if dst_w_bpp==16 test_bits_1_0_pix conditional_process1 cs, process_head, process_tail, 2, 0, unaligned_src, unaligned_mask, 0 .elseif dst_w_bpp==8 conditional_process2 test_bits_1_0_pix, cs, mi, process_head, process_tail, 2, 1, 0, 1, unaligned_src, unaligned_mask, 0 .endif.endm.macro wide_case_inner_loop process_head, process_tail, unaligned_src, unaligned_mask, dst_alignment110:.set SUBBLOCK, 0 .rept pix_per_block *dst_w_bpp/128 process_head, 16, 0, unaligned_src, unaligned_mask, 1 .if(src_bpp > 0) &&(mask_bpp==0) &&((flags) &FLAG_PROCESS_PRESERVES_SCRATCH) preload_middle src_bpp, SRC, 1 .elseif(src_bpp==0) &&(mask_bpp > 0) &&((flags) &FLAG_PROCESS_PRESERVES_SCRATCH) preload_middle mask_bpp, MASK, 1 .else preload_middle src_bpp, SRC, 0 preload_middle mask_bpp, MASK, 0 .endif .if(dst_r_bpp > 0) &&((SUBBLOCK % 2)==0) &&(((flags) &FLAG_NO_PRELOAD_DST)==0) PF pld,[DST, #32 *prefetch_distance - dst_alignment] .endif process_tail, 16, 0 .if !((flags) &FLAG_PROCESS_DOES_STORE) pixst, 16, 0, DST .endif .set SUBBLOCK, SUBBLOCK+1 .endr subs X, X, #pix_per_block bhs 110b.endm.macro wide_case_inner_loop_and_trailing_pixels process_head, process_tail, process_inner_loop, exit_label, unaligned_src, unaligned_mask .if dst_r_bpp > tst bne process_inner_loop DST_PRELOAD_BIAS endif preload_trailing SRC preload_trailing MASK DST endif add medium_case_inner_loop_and_trailing_pixels unaligned_mask endm macro medium_case_inner_loop_and_trailing_pixels DST endif subs bhs tst beq exit_label trailing_15bytes unaligned_mask endm macro narrow_case_inner_loop_and_trailing_pixels unaligned_mask tst conditional_process1 trailing_15bytes unaligned_mask endm macro switch_on_alignment action
Definition: pixman-arm-simd-asm.h:510
SDL_HINT_NO_SIGNAL_HANDLERS
#define SDL_HINT_NO_SIGNAL_HANDLERS
Tell SDL not to catch the SIGINT or SIGTERM signals.
Definition: SDL_hints.h:1007
SDL_QuitInit_Internal
static int SDL_QuitInit_Internal(void)
Definition: SDL_quit.c:118
SDL_OnApplicationWillResignActive
#define SDL_OnApplicationWillResignActive
Definition: SDL_dynapi_overrides.h:744
send_quit_pending
static SDL_bool send_quit_pending
Definition: SDL_quit.c:40
SDL_FALSE
@ SDL_FALSE
Definition: SDL_stdinc.h:163
void
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
Definition: SDL_dynapi_procs.h:89
SDL_SendAppEvent
int SDL_SendAppEvent(SDL_EventType eventType)
Definition: SDL_events.c:972
SDL_OnApplicationDidBecomeActive
#define SDL_OnApplicationDidBecomeActive
Definition: SDL_dynapi_overrides.h:747