Skip to content

Commit 61cd39d

Browse files
natoscottlpereira
authored andcommitted
Resolve complation issues with -fno-common (default from gcc-10)
Extends the MakeHeader script to auto-generate correct "extern" function declarations in some cases that it currently does not. Related to hishamhm#981
1 parent 402e46b commit 61cd39d

File tree

5 files changed

+31
-27
lines changed

5 files changed

+31
-27
lines changed

CRT.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ typedef enum ColorElements_ {
131131
LAST_COLORELEMENT
132132
} ColorElements;
133133
134-
void CRT_fatalError(const char* note) __attribute__ ((noreturn));
134+
extern void CRT_fatalError(const char* note) __attribute__ ((noreturn));
135135
136-
void CRT_handleSIGSEGV(int sgn);
136+
extern void CRT_handleSIGSEGV(int sgn);
137137
138138
#define KEY_ALT(x) (KEY_F(64 - 26) + (x - 'A'))
139139

CRT.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ typedef enum ColorElements_ {
119119
LAST_COLORELEMENT
120120
} ColorElements;
121121

122-
void CRT_fatalError(const char* note) __attribute__ ((noreturn));
122+
extern void CRT_fatalError(const char* note) __attribute__ ((noreturn));
123123

124-
void CRT_handleSIGSEGV(int sgn);
124+
extern void CRT_handleSIGSEGV(int sgn);
125125

126126
#define KEY_ALT(x) (KEY_F(64 - 26) + (x - 'A'))
127127

@@ -140,7 +140,7 @@ extern const char **CRT_treeStr;
140140

141141
extern int CRT_delay;
142142

143-
int* CRT_colors;
143+
extern int* CRT_colors;
144144

145145
extern int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT];
146146

@@ -150,21 +150,21 @@ extern int CRT_scrollHAmount;
150150

151151
extern int CRT_scrollWheelVAmount;
152152

153-
char* CRT_termType;
153+
extern char* CRT_termType;
154154

155155
// TODO move color scheme to Settings, perhaps?
156156

157157
extern int CRT_colorScheme;
158158

159-
void *backtraceArray[128];
159+
extern void *backtraceArray[128];
160160

161161
#if HAVE_SETUID_ENABLED
162162

163163
#define DIE(msg) do { CRT_done(); fprintf(stderr, msg); exit(1); } while(0)
164164

165-
void CRT_dropPrivileges();
165+
extern void CRT_dropPrivileges();
166166

167-
void CRT_restorePrivileges();
167+
extern void CRT_restorePrivileges();
168168

169169
#else
170170

@@ -179,18 +179,18 @@ void CRT_restorePrivileges();
179179

180180
// TODO: pass an instance of Settings instead.
181181

182-
void CRT_init(int delay, int colorScheme);
182+
extern void CRT_init(int delay, int colorScheme);
183183

184-
void CRT_done();
184+
extern void CRT_done();
185185

186-
void CRT_fatalError(const char* note);
186+
extern void CRT_fatalError(const char* note);
187187

188-
int CRT_readKey();
188+
extern int CRT_readKey();
189189

190-
void CRT_disableDelay();
190+
extern void CRT_disableDelay();
191191

192-
void CRT_enableDelay();
192+
extern void CRT_enableDelay();
193193

194-
void CRT_setColors(int colorScheme);
194+
extern void CRT_setColors(int colorScheme);
195195

196196
#endif

linux/LinuxProcess.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ typedef struct LinuxProcess_ {
154154
155155
}*/
156156

157-
long long btime; /* semi-global */
157+
/* semi-global */
158+
long long btime;
158159

159160
ProcessFieldData Process_fields[] = {
160161
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },

linux/LinuxProcess.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,18 @@ typedef struct LinuxProcess_ {
144144
#endif
145145

146146

147-
long long btime; /* semi-global */
147+
/* semi-global */
148+
extern long long btime;
148149

149150
extern ProcessFieldData Process_fields[];
150151

151152
extern ProcessPidColumn Process_pidColumns[];
152153

153154
extern ProcessClass LinuxProcess_class;
154155

155-
LinuxProcess* LinuxProcess_new(Settings* settings);
156+
extern LinuxProcess* LinuxProcess_new(Settings* settings);
156157

157-
void Process_delete(Object* cast);
158+
extern void Process_delete(Object* cast);
158159

159160
/*
160161
[1] Note that before kernel 2.6.26 a process that has not asked for
@@ -166,19 +167,19 @@ extern io_priority;
166167
*/
167168
#define LinuxProcess_effectiveIOPriority(p_) (IOPriority_class(p_->ioPriority) == IOPRIO_CLASS_NONE ? IOPriority_tuple(IOPRIO_CLASS_BE, (p_->super.nice + 20) / 5) : p_->ioPriority)
168169

169-
IOPriority LinuxProcess_updateIOPriority(LinuxProcess* this);
170+
extern IOPriority LinuxProcess_updateIOPriority(LinuxProcess* this);
170171

171-
bool LinuxProcess_setIOPriority(LinuxProcess* this, IOPriority ioprio);
172+
extern bool LinuxProcess_setIOPriority(LinuxProcess* this, IOPriority ioprio);
172173

173174
#ifdef HAVE_DELAYACCT
174-
void LinuxProcess_printDelay(float delay_percent, char* buffer, int n);
175+
extern void LinuxProcess_printDelay(float delay_percent, char* buffer, int n);
175176
#endif
176177

177-
void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field);
178+
extern void LinuxProcess_writeField(Process* this, RichString* str, ProcessField field);
178179

179-
long LinuxProcess_compare(const void* v1, const void* v2);
180+
extern long LinuxProcess_compare(const void* v1, const void* v2);
180181

181-
bool Process_isThread(Process* this);
182+
extern bool Process_isThread(Process* this);
182183

183184

184185
#endif

scripts/MakeHeader.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@
5454
elif line.startswith("typedef struct"):
5555
state = SKIP
5656
elif line[-1] == "{":
57-
out.write( line[:-2].replace("inline", "extern") + ";\n" )
57+
out.write("extern " + line[:-2].replace("inline ", "") + ";\n")
5858
state = SKIP
59+
elif line[-1] == ";":
60+
out.write("extern " + line + "\n")
5961
else:
6062
out.write( line + "\n")
6163
is_blank = False

0 commit comments

Comments
 (0)