Skip to content

Commit 515e944

Browse files
committed
Apply editorial changes
1 parent b6cc0ad commit 515e944

File tree

6 files changed

+113
-150
lines changed

6 files changed

+113
-150
lines changed

lib/c.c

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ char *memcpy(char *dest, char *src, int count)
140140
return dest;
141141
}
142142

143-
/*
144-
* set 10 digits (32bit) without div
143+
/* set 10 digits (32bit) without div
145144
*
146145
* This function converts a given integer value to its string representation
147146
* in base-10 without using division operations. The method involves calculating
@@ -192,14 +191,12 @@ void __str_base10(char *pb, int val)
192191
void __str_base8(char *pb, int val)
193192
{
194193
int c = INT_BUF_LEN - 1, v;
195-
/*
196-
* Because every 3 binary digits can be converted
197-
* to 1 octal digit, here performs the conversion
198-
* 10 times, derived from 32 divided by 3.
194+
195+
/* Because every 3 binary digits can be converted to 1 octal digit, here
196+
* performs the conversion 10 times, derived from 32 divided by 3.
199197
*
200-
* Finally, the remaining 2 bits are processed after
201-
* the loop.
202-
* */
198+
* Finally, the remaining 2 bits are processed after the loop.
199+
*/
203200
int times = (sizeof(int) << 3) / 3;
204201
for (int i = 0; i < times; i++) {
205202
v = val & 0x7;
@@ -230,29 +227,24 @@ void __str_base16(char *pb, int val)
230227
}
231228
}
232229

233-
/*
234-
* The specification of snprintf() is defined in C99 7.19.6.5,
235-
* and its behavior and return value should comply with the
236-
* following description:
237-
*
230+
/* The specification of snprintf() is defined in C99 7.19.6.5, and its behavior
231+
* and return value should comply with the following description:
238232
* - If n is zero, nothing is written.
239233
* - Writes at most n bytes, including the null character.
240-
* - On success, the return value should be the length of the
241-
* entire converted string even if n is insufficient to store it.
242-
*
243-
* Therefore, the following code defines a structure called fmtbuf_t
244-
* to implement formatted output conversion for the functions in the
245-
* printf() family.
234+
* - On success, the return value should be the length of the entire converted
235+
* string even if n is insufficient to store it.
246236
*
237+
* Thus, a structure fmtbuf_t is defined for formatted output conversion for
238+
* the functions in the printf() family.
247239
* @buf: the current position of the buffer.
248240
* @n : the remaining space of the buffer.
249-
* @len: the number of characters that would have been written
250-
* had n been sufficiently large.
241+
* @len: the number of characters that would have been written (excluding the
242+
* null terminator) had n been sufficiently large.
251243
*
252-
* Once a write operation is performed, buf and n will be
253-
* respectively incremented and decremented by the actual written
254-
* size if n is sufficient, and len must be incremented to store
255-
* the length of the entire converted string.
244+
* Once a write operation is performed, buf and n will be respectively
245+
* incremented and decremented by the actual written size if n is sufficient,
246+
* and len must be incremented to store the length of the entire converted
247+
* string.
256248
*/
257249
typedef struct {
258250
char *buf;
@@ -264,8 +256,7 @@ void __fmtbuf_write_char(fmtbuf_t *fmtbuf, int val)
264256
{
265257
fmtbuf->len += 1;
266258

267-
/*
268-
* Write the given character when n is greater than 1.
259+
/* Write the given character when n is greater than 1.
269260
* This means preserving one position for the null character.
270261
*/
271262
if (fmtbuf->n <= 1)
@@ -281,16 +272,14 @@ void __fmtbuf_write_str(fmtbuf_t *fmtbuf, char *str, int l)
281272
{
282273
fmtbuf->len += l;
283274

284-
/*
285-
* Write the given string when n is greater than 1.
275+
/* Write the given string when n is greater than 1.
286276
* This means preserving one position for the null character.
287277
*/
288278
if (fmtbuf->n <= 1)
289279
return;
290280

291-
/*
292-
* If the remaining space is less than the length of the string,
293-
* write only n - 1 bytes.
281+
/* If the remaining space is less than the length of the string, write only
282+
* n - 1 bytes.
294283
*/
295284
int sz = fmtbuf->n - 1;
296285
l = l <= sz ? l : sz;
@@ -519,7 +508,8 @@ int fclose(FILE *stream)
519508
}
520509

521510
/* Read a byte from file descriptor. So the return value is either in the range
522-
* of 0 to 127 for the character, or -1 on the end of file. */
511+
* of 0 to 127 for the character, or -1 on the end of file.
512+
*/
523513
int fgetc(FILE *stream)
524514
{
525515
int buf = 0, r = __syscall(__syscall_read, stream, &buf, 1);

src/arm-codegen.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,10 @@ void emit_ph2_ir(ph2_ir_t *ph2_ir)
195195
int rm = ph2_ir->src1;
196196
int ofs;
197197

198-
/* Prepare this variable to reuse the same code for
199-
* the instruction sequence of
200-
* 1. division and modulo.
201-
* 2. load and store operations.
202-
* 3. address-of operations.
198+
/* Prepare this variable to reuse code for:
199+
* 1. division and modulo operations
200+
* 2. load and store operations
201+
* 3. address-of operations
203202
*/
204203
arm_reg interm;
205204

@@ -374,14 +373,13 @@ void emit_ph2_ir(ph2_ir_t *ph2_ir)
374373
emit(__srl_amt(__AL, 1, logic_rs, __r9, __r9, 1));
375374
emit(__srl_amt(__CC, 0, logic_rs, rm, rm, 1));
376375
emit(__b(__CC, -20));
377-
/* After completing the emulation, the quotient and remainder
378-
* will be stored in __r8 and __r9, respectively.
376+
/* After completing the emulation, the quotient and remainder will be
377+
* stored in __r8 and __r9, respectively.
379378
*
380-
* The original values of the dividend and divisor will be
381-
* restored in rn and rm.
379+
* The original values of the dividend and divisor will be restored in
380+
* rn and rm.
382381
*
383-
* Finally, the result (quotient or remainder) will be stored
384-
* in rd.
382+
* Finally, the result (quotient or remainder) will be stored in rd.
385383
*/
386384
emit(__mov_r(__AL, __r9, rn));
387385
emit(__ldm(__AL, 1, __sp, (1 << rn) | (1 << rm)));

src/defs.h

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ typedef struct block block_t;
341341
typedef struct basic_block basic_block_t;
342342

343343
/* Definition of a growable buffer for a mutable null-terminated string
344-
* size: Current number of elements in the array
345-
* capacity: Number of elements that can be stored without resizing
346-
* elements: Pointer to the array of characters
344+
* @size: Current number of elements in the array
345+
* @capacity: Number of elements that can be stored without resizing
346+
* @elements: Pointer to the array of characters
347347
*/
348348
typedef struct {
349349
int size;
@@ -456,10 +456,10 @@ struct basic_block {
456456
insn_list_t insn_list;
457457
ph2_ir_list_t ph2_ir_list;
458458
bb_connection_t prev[MAX_BB_PRED];
459-
char bb_label_name[MAX_VAR_LEN]; /* Used in instruction dumping when ir_dump
460-
is enabled. */
461-
struct basic_block *next; /* normal BB */
462-
struct basic_block *then_; /* conditional BB */
459+
/* Used in instruction dumping when ir_dump is enabled. */
460+
char bb_label_name[MAX_VAR_LEN];
461+
struct basic_block *next; /* normal BB */
462+
struct basic_block *then_; /* conditional BB */
463463
struct basic_block *else_;
464464
struct basic_block *idom;
465465
struct basic_block *r_idom;
@@ -496,11 +496,9 @@ struct ref_block {
496496
struct ref_block *next;
497497
};
498498

499-
/**
500-
* Syntatic representation of func, combines syntactic details
501-
* (e.g., return type, parameters) with SSA-related information
502-
* (e.g., basic blocks, control flow) to support parsing,
503-
* analysis, optimization, and code generation.
499+
/* Syntactic representation of func, combines syntactic details (e.g., return
500+
* type, parameters) with SSA-related information (e.g., basic blocks, control
501+
* flow) to support parsing, analysis, optimization, and code generation.
504502
*/
505503
struct func {
506504
/* Syntatic info */

0 commit comments

Comments
 (0)