Skip to content

Commit e3ea9cc

Browse files
committed
[runtime] Run clang-format to fix warnings; NFC
Fix -Wmisleading-indentation warnings in a number of files by running clang-format on the affected code sections with the following options, to stay close to the original Classic Flang style: BasedOnStyle: LLVM AlwaysBreakAfterDefinitionReturnType: TopLevel BreakBeforeBraces: WebKit SortIncludes: false This also removes tabs and extraneous spaces, and corrects non-compliant coding style.
1 parent 265edca commit e3ea9cc

File tree

8 files changed

+770
-751
lines changed

8 files changed

+770
-751
lines changed

runtime/flang/type.c

Lines changed: 224 additions & 221 deletions
Large diffs are not rendered by default.

runtime/flang/unf.c

Lines changed: 97 additions & 86 deletions
Large diffs are not rendered by default.

runtime/flangrti/llcrit.c

Lines changed: 102 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
*/
77

88
#include <stddef.h>
9-
#include <stdlib.h>
109
#include <stdint.h>
10+
#include <stdlib.h>
1111
#include <string.h>
1212
#ifndef _WIN64
1313
#include <pthread.h>
1414
#endif
15-
#include <stdioInterf.h>
1615
#include "komp.h"
16+
#include <stdioInterf.h>
1717

1818
/* This routine makes a simple omp library call to force lazy initialization of
1919
* kmpc to occur early.
@@ -71,7 +71,8 @@ static int is_init_nest = 0;
7171
static int is_init_nest_red = 0;
7272
static int is_atfork_registered = 0;
7373

74-
static void __llcrit_atfork(void)
74+
static void
75+
__llcrit_atfork(void)
7576
{
7677
is_init_nest = 0;
7778
is_init_nest_red = 0;
@@ -153,28 +154,27 @@ _mp_ecs_nest_red(void)
153154
void
154155
_mp_cdeclp(void *blk, void ***blk_tp, int size)
155156
{
156-
__kmpc_threadprivate_cached(0, __kmpc_global_thread_num(0), (void*)blk, (size_t)size, blk_tp);
157-
157+
__kmpc_threadprivate_cached(0, __kmpc_global_thread_num(0), (void *)blk,
158+
(size_t)size, blk_tp);
158159
}
159160

160161
void
161162
_mp_cdecli(void *blk, void ***blk_tp, int size)
162163
{
163-
__kmpc_threadprivate_cached(0, __kmpc_global_thread_num(0), (void*)blk, (size_t)size, blk_tp);
164-
164+
__kmpc_threadprivate_cached(0, __kmpc_global_thread_num(0), (void *)blk,
165+
(size_t)size, blk_tp);
165166
}
166167

167168
void
168169
_mp_cdecl(void *blk, void ***blk_tp, int size)
169170
{
170-
__kmpc_threadprivate_cached(0, __kmpc_global_thread_num(0), (void*)blk, (size_t)size, blk_tp);
171-
171+
__kmpc_threadprivate_cached(0, __kmpc_global_thread_num(0), (void *)blk,
172+
(size_t)size, blk_tp);
172173
}
173174

174175
static char *singadr;
175176
static long singlen;
176177

177-
178178
/* C/C++: copy a private stack or other other variable */
179179
void
180180
_mp_copypriv(char *adr, long len, int thread)
@@ -219,20 +219,21 @@ _mp_copypriv_move(void *blk_tp, int off, int size, int single_thread)
219219
char *to;
220220
char *garbage = 0;
221221

222-
if (single_thread != -1) { /* single thread */
223-
singadr = __kmpc_threadprivate_cached(0, single_thread, garbage, (size_t)size, blk_tp);
222+
if (single_thread != -1) { /* single thread */
223+
singadr = __kmpc_threadprivate_cached(0, single_thread, garbage,
224+
(size_t)size, blk_tp);
224225
singlen = size;
225226
}
226227
__kmpc_barrier(0, __kmpc_global_thread_num(0));
227-
if (single_thread == -1) { /* single thread */
228-
lcpu = __kmpc_global_thread_num(0);
229-
to = __kmpc_threadprivate_cached(0, lcpu, garbage, (size_t)size, blk_tp);
230-
memcpy(to, singadr, size);
228+
if (single_thread == -1) { /* single thread */
229+
lcpu = __kmpc_global_thread_num(0);
230+
to = __kmpc_threadprivate_cached(0, lcpu, garbage, (size_t)size, blk_tp);
231+
memcpy(to, singadr, size);
231232
}
232233
__kmpc_barrier(0, __kmpc_global_thread_num(0));
233234
}
234235

235-
/* C/C++: copy data from the threads' block to the other threads blocks.
236+
/* C/C++: copy data from the threads' block to the other threads blocks.
236237
* Use when experiment flag 69,0x80
237238
*/
238239

@@ -243,29 +244,29 @@ _mp_copypriv_move_tls(void **blk_tp, int off, int size, int single_thread)
243244
char *to;
244245
char *garbage = 0;
245246

246-
if (single_thread != -1) { /* single thread */
247+
if (single_thread != -1) { /* single thread */
247248
if (*blk_tp == 0)
248-
singadr = (char*)__kmpc_threadprivate(0, single_thread, garbage, (size_t)size);
249+
singadr =
250+
(char *)__kmpc_threadprivate(0, single_thread, garbage, (size_t)size);
249251
else
250252
singadr = *blk_tp;
251253
singlen = size;
252254
}
253255
__kmpc_barrier(0, __kmpc_global_thread_num(0));
254-
if (single_thread == -1) { /* single thread */
255-
lcpu = __kmpc_global_thread_num(0);
256-
if (*blk_tp == 0)
257-
to = __kmpc_threadprivate(0, lcpu, garbage, (size_t)size);
258-
else
259-
to = *blk_tp;
260-
memcpy(to, singadr, size);
256+
if (single_thread == -1) { /* single thread */
257+
lcpu = __kmpc_global_thread_num(0);
258+
if (*blk_tp == 0)
259+
to = __kmpc_threadprivate(0, lcpu, garbage, (size_t)size);
260+
else
261+
to = *blk_tp;
262+
memcpy(to, singadr, size);
261263
}
262264
__kmpc_barrier(0, __kmpc_global_thread_num(0));
263265
}
264266

265-
266-
/*C: copy data from the master's block to the other threads blocks
267+
/*C: copy data from the master's block to the other threads blocks
267268
* Don't use: keep for backward compatibility
268-
*/
269+
*/
269270

270271
void
271272
_mp_copyin_move(void *blk_tp, int off, int size)
@@ -274,18 +275,18 @@ _mp_copyin_move(void *blk_tp, int off, int size)
274275
char *to, *fr;
275276
char *garbage = 0;
276277

277-
lcpu =__kmpc_global_thread_num(0);
278+
lcpu = __kmpc_global_thread_num(0);
278279

279280
if (lcpu != 0) {
280-
fr = __kmpc_threadprivate_cached(0, 0, garbage, (size_t)size, blk_tp);
281-
to = __kmpc_threadprivate_cached(0, lcpu, garbage, (size_t)size, blk_tp);
281+
fr = __kmpc_threadprivate_cached(0, 0, garbage, (size_t)size, blk_tp);
282+
to = __kmpc_threadprivate_cached(0, lcpu, garbage, (size_t)size, blk_tp);
282283
if (to != fr)
283284
memcpy(to, fr, size);
284285
}
285286
__kmpc_barrier(0, __kmpc_global_thread_num(0));
286287
}
287288

288-
/* C: copy data from the master's block to the other threads blocks
289+
/* C: copy data from the master's block to the other threads blocks
289290
* Use when experiment flag 69,0x80
290291
*/
291292

@@ -296,65 +297,62 @@ _mp_copyin_move_tls(void *blk_tp, int off, int size)
296297
char *to, *fr;
297298
char *garbage = 0;
298299

299-
lcpu =__kmpc_global_thread_num(0);
300+
lcpu = __kmpc_global_thread_num(0);
300301

301302
if (lcpu != 0) {
302-
fr = __kmpc_threadprivate(0, 0, garbage, (size_t)size);
303-
to = __kmpc_threadprivate(0, lcpu, garbage, (size_t)size);
303+
fr = __kmpc_threadprivate(0, 0, garbage, (size_t)size);
304+
to = __kmpc_threadprivate(0, lcpu, garbage, (size_t)size);
304305
if (to != fr)
305306
memcpy(to, fr, size);
306307
}
307308
__kmpc_barrier(0, __kmpc_global_thread_num(0));
308309
}
309310

310-
typedef void (*assign_func_ptr) (void * , void * );
311+
typedef void (*assign_func_ptr)(void *, void *);
311312

312-
/* C++: copy data from the master's block to the other threads blocks
313-
using the assignment operator
314-
vector_size is 1 for non arrays
315-
n for array[n]
313+
/* C++: copy data from the master's block to the other threads blocks
314+
using the assignment operator
315+
vector_size is 1 for non arrays
316+
n for array[n]
316317
* Don't use: keep for backward compatibility
317318
*/
318319

319320
void
320-
_mp_copyin_move_cpp(void *blk_tp, int off, int class_size,
321-
int vector_size,assign_func_ptr assign_op)
321+
_mp_copyin_move_cpp(void *blk_tp, int off, int class_size, int vector_size,
322+
assign_func_ptr assign_op)
322323
{
323324
int lcpu;
324325
char *to, *fr;
325326
char *garbage = 0;
326327
int i;
327328

328-
lcpu =__kmpc_global_thread_num(0);
329+
lcpu = __kmpc_global_thread_num(0);
329330

330331
__kmpc_barrier(0, lcpu);
331332
if (lcpu != 0) {
332-
fr = __kmpc_threadprivate_cached(0, 0, garbage,
333-
(size_t) (class_size * vector_size),
334-
blk_tp);
335-
to = __kmpc_threadprivate_cached(0, lcpu, garbage,
336-
(size_t)(class_size * vector_size),
337-
blk_tp);
338-
339-
for(i = 0 ; i < vector_size; i++) {
340-
if (to != fr)
341-
(*assign_op)(to, fr);
342-
to += class_size;
343-
fr += class_size;
344-
}
333+
fr = __kmpc_threadprivate_cached(
334+
0, 0, garbage, (size_t)(class_size * vector_size), blk_tp);
335+
to = __kmpc_threadprivate_cached(
336+
0, lcpu, garbage, (size_t)(class_size * vector_size), blk_tp);
337+
338+
for (i = 0; i < vector_size; i++) {
339+
if (to != fr)
340+
(*assign_op)(to, fr);
341+
to += class_size;
342+
fr += class_size;
343+
}
345344
}
346345
__kmpc_barrier(0, lcpu);
347-
}
346+
}
348347

349-
/* C++: copy data from the master's block to the other threads blocks
350-
using the assignment operator
351-
vector_size is 1 for non arrays
348+
/* C++: copy data from the master's block to the other threads blocks
349+
using the assignment operator
350+
vector_size is 1 for non arrays
352351
n for array[n]
353352
*/
354353
void
355-
_mp_copyin_move_cpp_new(void *blk_tp, int off, int class_size,
356-
int vector_size,assign_func_ptr assign_op,
357-
char* fr)
354+
_mp_copyin_move_cpp_new(void *blk_tp, int off, int class_size, int vector_size,
355+
assign_func_ptr assign_op, char *fr)
358356
{
359357
int lcpu;
360358
char *to;
@@ -364,60 +362,60 @@ _mp_copyin_move_cpp_new(void *blk_tp, int off, int class_size,
364362
if (!fr)
365363
return;
366364

367-
lcpu =__kmpc_global_thread_num(0);
365+
lcpu = __kmpc_global_thread_num(0);
368366

369-
to = __kmpc_threadprivate_cached(0, lcpu, garbage,
370-
(size_t)(class_size * vector_size),
371-
blk_tp);
367+
to = __kmpc_threadprivate_cached(0, lcpu, garbage,
368+
(size_t)(class_size * vector_size), blk_tp);
372369

373-
for(i = 0 ; i < vector_size; i++) {
370+
for (i = 0; i < vector_size; i++) {
374371
if (to != fr)
375372
(*assign_op)(to, fr);
376-
to += class_size;
377-
fr += class_size;
373+
to += class_size;
374+
fr += class_size;
378375
}
379-
380-
}
376+
}
381377

382378
/*
383379
* Use when experiment flag 69,0x80
384380
*/
385381
void
386-
_mp_copyin_move_cpp_tls(void *master, void* slave, int class_size,
387-
int vector_size,assign_func_ptr assign_op)
382+
_mp_copyin_move_cpp_tls(void *master, void *slave, int class_size,
383+
int vector_size, assign_func_ptr assign_op)
388384
{
389385
char *to, *fr;
390386
int i;
391387

392-
fr = (char*)master;
393-
to = (char*)slave;
388+
fr = (char *)master;
389+
to = (char *)slave;
394390
if (fr && to) {
395-
for(i = 0 ; i < vector_size; i++) {
396-
(*assign_op)(to, fr);
397-
to += class_size;
398-
fr += class_size;
399-
}
391+
for (i = 0; i < vector_size; i++) {
392+
(*assign_op)(to, fr);
393+
to += class_size;
394+
fr += class_size;
395+
}
400396
}
401-
}
402-
403-
/* Copy multiple items from master to children threads.
397+
}
398+
399+
/* Copy multiple items from master to children threads.
404400
* Don't use: keep for backward compatibility
405401
*/
406402
void
407403
_mp_copyin_move_multiple(int n_entries, void *data)
408404
{
409405
int i;
410406
const int tid = __kmpc_global_thread_num(NULL);
411-
struct pair_t {size_t size; void *data;};
412-
407+
struct pair_t {
408+
size_t size;
409+
void *data;
410+
};
413411

414412
if (tid != 0) {
415-
for (i=0; i<n_entries; ++i) {
413+
for (i = 0; i < n_entries; ++i) {
416414
struct pair_t *item = (struct pair_t *)data + i;
417415
void *key = item->data;
418416
const size_t size = item->size;
419417
void *to = __kmpc_threadprivate_cached(NULL, tid, NULL, size, key);
420-
/* FIXME: Should this be 0 or the team master?
418+
/* FIXME: Should this be 0 or the team master?
421419
* I think the gtid of team master.
422420
*/
423421
void *fr = __kmpc_threadprivate_cached(NULL, 0, NULL, size, key);
@@ -440,8 +438,8 @@ _mp_copyin_move_al(void *blk_tp, int off, long size)
440438

441439
lcpu = __kmpc_global_thread_num(0);
442440
if (lcpu != 0) {
443-
fr = __kmpc_threadprivate_cached(0, 0, garbage, (size_t)size, blk_tp);
444-
to = __kmpc_threadprivate_cached(0, lcpu, garbage, (size_t)size, blk_tp);
441+
fr = __kmpc_threadprivate_cached(0, 0, garbage, (size_t)size, blk_tp);
442+
to = __kmpc_threadprivate_cached(0, lcpu, garbage, (size_t)size, blk_tp);
445443
if (to && to != fr) {
446444
memcpy(to, fr, size);
447445
}
@@ -455,25 +453,29 @@ _mp_copyin_move_al(void *blk_tp, int off, long size)
455453
void
456454
_mp_copypriv_kmpc(void *dest, void *src)
457455
{
458-
struct pair_t {size_t *size; void *data;};
459-
const struct pair_t *to = (struct pair_t *)dest;
456+
struct pair_t {
457+
size_t *size;
458+
void *data;
459+
};
460+
const struct pair_t *to = (struct pair_t *)dest;
460461
const struct pair_t *from = (struct pair_t *)src;
461462

462-
for ( ; from->size; ++from, ++to) {
463+
for (; from->size; ++from, ++to) {
463464
if (to->data != from->data)
464465
memcpy(to->data, from->data, *from->size);
465466
}
466467
}
467468

468-
/* duplicate kmpc_threadprivate_cached but we assume each thread has its own addr
469-
* in its own [tls] address space so that it does not need to access memory in other
470-
* thread's area. Use when experiment flag 69,0x80
469+
/* duplicate kmpc_threadprivate_cached but we assume each thread has its own
470+
* addr in its own [tls] address space so that it does not need to access memory
471+
* in other thread's area. Use when experiment flag 69,0x80
471472
*/
472-
void*
473-
_mp_get_threadprivate(ident_t * ident, kmp_int32 gtid, void* tpv, size_t size, void** addr)
473+
void *
474+
_mp_get_threadprivate(ident_t *ident, kmp_int32 gtid, void *tpv, size_t size,
475+
void **addr)
474476
{
475477
if (*addr == NULL) {
476-
*addr = __kmpc_threadprivate(ident, gtid, tpv, size);
478+
*addr = __kmpc_threadprivate(ident, gtid, tpv, size);
477479
}
478480
return *addr;
479481
}

0 commit comments

Comments
 (0)