Skip to content

Commit 0721b9a

Browse files
committed
Unixish.h, doshish.h: Reorder terminations; simplify
The IO and memory terminations need to be after other things. Add a comment so that future maintainers won't make the mistakes I did. Also refactor so that amiga os doesn't have a separate list to get out of sync I suspect that the amiga termination should be moved to earlier in the sequence, but absent any evidence; I'm leaving it unchanged. vms destruction was missing a bunch of things and I didn't see any reason to have special handling, so I changed it to just use the standard, presuming the discrepancies were due to changes in the standard not getting propagated to vms. The common definitions are also moved to perl.c which is the only place they are used (including cpan). This makes them available in all circumstances. Otherwise, the #ifdef's for including the relevant header files only include one, so there would be undefined macros.
1 parent 71ce8c7 commit 0721b9a

File tree

4 files changed

+60
-22
lines changed

4 files changed

+60
-22
lines changed

dosish.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,17 @@
2424
# define BIT_BUCKET "\\dev\\nul" /* "wanna be like, umm, Newlined, or somethin?" */
2525
#endif
2626

27+
/* Generally add things last-in first-terminated. IO and memory terminations
28+
* need to be generally last
29+
*
30+
* BEWARE that using PerlIO in these will be using freed memory, so may appear
31+
* to work, but must NOT be retained in production code. */
2732
#ifndef PERL_SYS_TERM_BODY
2833
# define PERL_SYS_TERM_BODY() \
34+
ENV_TERM; USER_PROP_MUTEX_TERM; LOCALE_TERM; \
2935
HINTS_REFCNT_TERM; KEYWORD_PLUGIN_MUTEX_TERM; \
30-
OP_CHECK_MUTEX_TERM; OP_REFCNT_TERM; PERLIO_TERM; \
31-
MALLOC_TERM; LOCALE_TERM; USER_PROP_MUTEX_TERM; \
32-
ENV_TERM;
36+
OP_CHECK_MUTEX_TERM; OP_REFCNT_TERM; \
37+
PERLIO_TERM; MALLOC_TERM;
3338
#endif
3439
#define dXSUB_SYS dNOOP
3540

perl.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,34 @@ S_init_tls_and_interp(PerlInterpreter *my_perl)
108108
}
109109

110110

111+
#ifndef PLATFORM_SYS_INIT_
112+
# define PLATFORM_SYS_INIT_ NOOP
113+
#endif
114+
115+
#ifndef PLATFORM_SYS_TERM_
116+
# define PLATFORM_SYS_TERM_ NOOP
117+
#endif
118+
119+
#ifndef PERL_SYS_INIT_BODY
120+
# define PERL_SYS_INIT_BODY(c,v) \
121+
MALLOC_CHECK_TAINT2(*c,*v) PERL_FPU_INIT; PERLIO_INIT; \
122+
MALLOC_INIT; PLATFORM_SYS_INIT_;
123+
#endif
124+
125+
/* Generally add things last-in first-terminated. IO and memory terminations
126+
* need to be generally last
127+
*
128+
* BEWARE that using PerlIO in these will be using freed memory, so may appear
129+
* to work, but must NOT be retained in production code. */
130+
#ifndef PERL_SYS_TERM_BODY
131+
# define PERL_SYS_TERM_BODY() \
132+
ENV_TERM; USER_PROP_MUTEX_TERM; LOCALE_TERM; \
133+
HINTS_REFCNT_TERM; KEYWORD_PLUGIN_MUTEX_TERM; \
134+
OP_CHECK_MUTEX_TERM; OP_REFCNT_TERM; \
135+
PERLIO_TERM; MALLOC_TERM; \
136+
PLATFORM_SYS_TERM_;
137+
#endif
138+
111139
/* these implement the PERL_SYS_INIT, PERL_SYS_INIT3, PERL_SYS_TERM macros */
112140

113141
void

unixish.h

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -136,28 +136,34 @@ int afstat(int fd, struct stat *statb);
136136
#define Mkdir(path,mode) mkdir((path),(mode))
137137

138138
#if defined(__amigaos4__)
139-
# define PERL_SYS_INIT_BODY(c,v) \
140-
MALLOC_CHECK_TAINT2(*c,*v) PERL_FPU_INIT; PERLIO_INIT; MALLOC_INIT; amigaos4_init_fork_array(); amigaos4_init_environ_sema();
141-
# define PERL_SYS_TERM_BODY() \
142-
HINTS_REFCNT_TERM; KEYWORD_PLUGIN_MUTEX_TERM; \
143-
OP_CHECK_MUTEX_TERM; OP_REFCNT_TERM; PERLIO_TERM; \
144-
MALLOC_TERM; LOCALE_TERM; USER_PROP_MUTEX_TERM; \
145-
ENV_TERM; \
146-
amigaos4_dispose_fork_array();
139+
# define PLATFORM_SYS_TERM_ amigaos4_dispose_fork_array()
140+
# define PLATFORM_SYS_INIT_ STMT_START { \
141+
amigaos4_init_fork_array(); \
142+
amigaos4_init_environ_sema(); \
143+
} STMT_END
144+
#else
145+
# define PLATFORM_SYS_TERM_ NOOP
146+
# define PLATFORM_SYS_INIT_ NOOP
147147
#endif
148148

149149
#ifndef PERL_SYS_INIT_BODY
150-
# define PERL_SYS_INIT_BODY(c,v) \
151-
MALLOC_CHECK_TAINT2(*c,*v) PERL_FPU_INIT; PERLIO_INIT; MALLOC_INIT
150+
#define PERL_SYS_INIT_BODY(c,v) \
151+
MALLOC_CHECK_TAINT2(*c,*v) PERL_FPU_INIT; PERLIO_INIT; \
152+
MALLOC_INIT; PLATFORM_SYS_INIT_;
152153
#endif
153154

155+
/* Generally add things last-in first-terminated. IO and memory terminations
156+
* need to be generally last
157+
*
158+
* BEWARE that using PerlIO in these will be using freed memory, so may appear
159+
* to work, but must NOT be retained in production code. */
154160
#ifndef PERL_SYS_TERM_BODY
155-
# define PERL_SYS_TERM_BODY() \
156-
HINTS_REFCNT_TERM; KEYWORD_PLUGIN_MUTEX_TERM; \
157-
OP_CHECK_MUTEX_TERM; OP_REFCNT_TERM; PERLIO_TERM; \
158-
MALLOC_TERM; LOCALE_TERM; USER_PROP_MUTEX_TERM; \
159-
ENV_TERM;
160-
161+
# define PERL_SYS_TERM_BODY() \
162+
ENV_TERM; USER_PROP_MUTEX_TERM; LOCALE_TERM; \
163+
HINTS_REFCNT_TERM; KEYWORD_PLUGIN_MUTEX_TERM; \
164+
OP_CHECK_MUTEX_TERM; OP_REFCNT_TERM; \
165+
PERLIO_TERM; MALLOC_TERM; \
166+
PLATFORM_SYS_TERM_;
161167
#endif
162168

163169
#define BIT_BUCKET "/dev/null"

vms/vmsish.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,8 @@ struct interp_intern {
309309

310310
#define BIT_BUCKET "/dev/null"
311311
#define PERL_SYS_INIT_BODY(c,v) MALLOC_CHECK_TAINT2(*c,*v) vms_image_init((c),(v)); PERLIO_INIT; MALLOC_INIT
312-
#define PERL_SYS_TERM_BODY() HINTS_REFCNT_TERM; OP_REFCNT_TERM; \
313-
PERLIO_TERM; MALLOC_TERM; LOCALE_TERM; \
314-
ENV_TERM;
312+
/* Use standard PERL_SYS_TERM_BODY */
313+
315314
#define dXSUB_SYS dNOOP
316315
#define HAS_KILL
317316
#define HAS_WAIT

0 commit comments

Comments
 (0)