This patch implements some of the coding standards in an earlier PDD.
Functions such as Allocate_Aligned were changed to lowercase, and all
functions in memory.{h,c} had mem_ prepended to them. The only thing I
didn't really try to fix were the #define's being lowercase (such as
sys_memcopy). I changed the name to mem_sys_memcopy, but I didn't uppercase
it because I thought it might be changed to a function sometime in the
future and we wouldn't want to have to go through and lowercase it then. If
ya'll would like, I can uppercase it. Also, functions such as
int main()
were changed to:
int
main()
according to the PDD.
I'll keep looking for other coding standard changes.
Thanks!
Tanton
Index: bytecode.c
===================================================================
RCS file: /home/perlcvs/parrot/bytecode.c,v
retrieving revision 1.5
diff -u -r1.5 bytecode.c
--- bytecode.c 2001/09/12 09:54:46 1.5
+++ bytecode.c 2001/09/13 18:52:14
@@ -72,7 +72,7 @@
num = GRAB_IV(program_code);
len -= sizeof(IV);
- Parrot_string_constants = Allocate_Aligned(num * sizeof(STRING*));
+ Parrot_string_constants = mem_allocate_aligned(num * sizeof(STRING*));
while (len > 0) {
IV flags = GRAB_IV(program_code);
Index: global_setup.c
===================================================================
RCS file: /home/perlcvs/parrot/global_setup.c,v
retrieving revision 1.2
diff -u -r1.2 global_setup.c
--- global_setup.c 2001/09/10 09:53:14 1.2
+++ global_setup.c 2001/09/13 18:52:14
@@ -9,6 +9,7 @@
#define INSIDE_GLOBAL_SETUP
#include "parrot.h"
-void init_world() {
+void
+init_world() {
string_init(); /* Set up the string subsystem */
}
Index: interpreter.c
===================================================================
RCS file: /home/perlcvs/parrot/interpreter.c,v
retrieving revision 1.6
diff -u -r1.6 interpreter.c
--- interpreter.c 2001/09/11 22:21:17 1.6
+++ interpreter.c 2001/09/13 18:52:14
@@ -8,7 +8,8 @@
#include "parrot.h"
#include "interp_guts.h"
-void runops (struct Perl_Interp *interpreter, IV *code) {
+void
+runops (struct Perl_Interp *interpreter, IV *code) {
/* Move these out of the inner loop. No need to redeclare 'em each
time through */
IV *(*func)();
@@ -18,18 +19,19 @@
}
}
-struct Perl_Interp *make_interpreter() {
+struct Perl_Interp *
+make_interpreter() {
struct Perl_Interp *interpreter;
/* Get an empty interpreter from system memory */
- interpreter = Sys_Allocate(sizeof(struct Perl_Interp));
+ interpreter = mem_sys_allocate(sizeof(struct Perl_Interp));
/* Set up the memory allocation system */
- Setup_Allocator(interpreter);
+ mem_setup_allocator(interpreter);
/* Set up the initial register chunks */
- interpreter->int_reg_base = Allocate_Aligned(sizeof(struct IRegChunk));
- interpreter->num_reg_base = Allocate_Aligned(sizeof(struct NRegChunk));
- interpreter->string_reg_base = Allocate_Aligned(sizeof(struct
SRegChunk));
- interpreter->pmc_reg_base = Allocate_Aligned(sizeof(struct PRegChunk));
+ interpreter->int_reg_base = mem_allocate_aligned(sizeof(struct
IRegChunk));
+ interpreter->num_reg_base = mem_allocate_aligned(sizeof(struct
NRegChunk));
+ interpreter->string_reg_base = mem_allocate_aligned(sizeof(struct
SRegChunk));
+ interpreter->pmc_reg_base = mem_allocate_aligned(sizeof(struct
PRegChunk));
/* Set up the initial register frame pointers */
interpreter->int_reg = &interpreter->int_reg_base->IReg[0];
@@ -64,15 +66,15 @@
Parrot_clear_p(interpreter);
/* Need a default stack */
- interpreter->stack_base = Allocate_New_Stack();
+ interpreter->stack_base = mem_allocate_new_stack();
/* Need an empty stash */
- interpreter->perl_stash = Allocate_New_Stash();
+ interpreter->perl_stash = mem_allocate_new_stash();
/* The default opcode function table would be a good thing here... */
{
void **foo;
- foo = Sys_Allocate(2048 * sizeof(void *));
+ foo = mem_sys_allocate(2048 * sizeof(void *));
BUILD_TABLE(foo);
Index: memory.c
===================================================================
RCS file: /home/perlcvs/parrot/memory.c,v
retrieving revision 1.3
diff -u -r1.3 memory.c
--- memory.c 2001/09/12 17:58:55 1.3
+++ memory.c 2001/09/13 18:52:14
@@ -7,7 +7,8 @@
#include "parrot.h"
/* Allocate a chunk of memory aligned on a power-of-2 boundary */
-void *Allocate_Aligned(IV size) {
+void *
+mem_allocate_aligned(IV size) {
IV max_to_alloc;
IV mask;
IV i;
@@ -31,11 +32,13 @@
return mem;
}
-void *Sys_Allocate(IV size) {
+void *
+mem_sys_allocate(IV size) {
return malloc(size);
}
-void Setup_Allocator(struct Perl_Interp *interpreter) {
+void
+mem_setup_allocator(struct Perl_Interp *interpreter) {
}
Index: memory.h
===================================================================
RCS file: /home/perlcvs/parrot/memory.h,v
retrieving revision 1.2
diff -u -r1.2 memory.h
--- memory.h 2001/09/10 09:51:52 1.2
+++ memory.h 2001/09/13 18:52:14
@@ -7,16 +7,16 @@
#if !defined(PARROT_MEMORY_H_GUARD)
#define PARROT_MEMORY_H_GUARD
-void *Allocate_Aligned(IV);
+void *mem_allocate_aligned(IV);
-void *Sys_Allocate(IV);
+void *mem_sys_allocate(IV);
-void Setup_Allocator(struct Perl_Interp *);
+void mem_setup_allocator(struct Perl_Interp *);
-#define Allocate_New_Stash() NULL
-#define Allocate_New_Stack() NULL
-#define Sys_Memcopy memcpy
-#define Sys_Realloc realloc
-#define Sys_Free free
+#define mem_allocate_new_stash() NULL
+#define mem_allocate_new_stack() NULL
+#define mem_sys_memcopy memcpy
+#define mem_sys_realloc realloc
+#define mem_sys_free free
#endif
Index: register.c
===================================================================
RCS file: /home/perlcvs/parrot/register.c,v
retrieving revision 1.3
diff -u -r1.3 register.c
--- register.c 2001/09/10 21:40:33 1.3
+++ register.c 2001/09/13 18:52:14
@@ -6,7 +6,8 @@
#include "parrot.h"
-void Parrot_push_i(struct Perl_Interp *interpreter) {
+void
+Parrot_push_i(struct Perl_Interp *interpreter) {
struct IRegChunk *chunk_base;
chunk_base = CHUNK_BASE(interpreter->int_reg);
@@ -18,7 +19,7 @@
/* Nope, so plan B time. Allocate a new chunk of integer register frames
*/
else {
struct IRegChunk *new_chunk;
- new_chunk = Allocate_Aligned(sizeof(struct IRegChunk));
+ new_chunk = mem_allocate_aligned(sizeof(struct IRegChunk));
new_chunk->used = 1;
new_chunk->free = FRAMES_PER_INT_REG_CHUNK - 1;
new_chunk->next = NULL;
@@ -28,7 +29,8 @@
}
}
-void Parrot_pop_i(struct Perl_Interp *interpreter) {
+void
+Parrot_pop_i(struct Perl_Interp *interpreter) {
struct IRegChunk *chunk_base;
chunk_base = CHUNK_BASE(interpreter->int_reg);
/* Is there more than one register frame in use? */
@@ -53,14 +55,16 @@
}
}
-void Parrot_clear_i(struct Perl_Interp *interpreter) {
+void
+Parrot_clear_i(struct Perl_Interp *interpreter) {
int i;
for (i=0; i<NUM_REGISTERS; i++) {
INT_REG(i) = 0;
}
}
-void Parrot_push_s(struct Perl_Interp *interpreter) {
+void
+Parrot_push_s(struct Perl_Interp *interpreter) {
struct SRegChunk *chunk_base;
chunk_base = CHUNK_BASE(interpreter->string_reg);
@@ -72,7 +76,7 @@
/* Nope, so plan B time. Allocate a new chunk of string register frames
*/
else {
struct SRegChunk *new_chunk;
- new_chunk = Allocate_Aligned(sizeof(struct SRegChunk));
+ new_chunk = mem_allocate_aligned(sizeof(struct SRegChunk));
new_chunk->used = 1;
new_chunk->free = FRAMES_PER_STR_REG_CHUNK - 1;
new_chunk->next = NULL;
@@ -82,7 +86,8 @@
}
}
-void Parrot_pop_s(struct Perl_Interp *interpreter) {
+void
+Parrot_pop_s(struct Perl_Interp *interpreter) {
struct SRegChunk *chunk_base;
chunk_base = CHUNK_BASE(interpreter->string_reg);
/* Is there more than one register frame in use? */
@@ -107,14 +112,16 @@
}
}
-void Parrot_clear_s(struct Perl_Interp *interpreter) {
+void
+Parrot_clear_s(struct Perl_Interp *interpreter) {
int i;
for (i=0; i<NUM_REGISTERS; i++) {
STR_REG(i) = NULL;
}
}
-void Parrot_push_n(struct Perl_Interp *interpreter) {
+void
+Parrot_push_n(struct Perl_Interp *interpreter) {
struct NRegChunk *chunk_base;
chunk_base = CHUNK_BASE(interpreter->num_reg);
@@ -126,7 +133,7 @@
/* Nope, so plan B time. Allocate a new chunk of float register frames */
else {
struct NRegChunk *new_chunk;
- new_chunk = Allocate_Aligned(sizeof(struct NRegChunk));
+ new_chunk = mem_allocate_aligned(sizeof(struct NRegChunk));
new_chunk->used = 1;
new_chunk->free = FRAMES_PER_NUM_REG_CHUNK - 1;
new_chunk->next = NULL;
@@ -136,7 +143,8 @@
}
}
-void Parrot_pop_n(struct Perl_Interp *interpreter) {
+void
+Parrot_pop_n(struct Perl_Interp *interpreter) {
struct NRegChunk *chunk_base;
chunk_base = CHUNK_BASE(interpreter->num_reg);
/* Is there more than one register frame in use? */
@@ -161,14 +169,16 @@
}
}
-void Parrot_clear_n(struct Perl_Interp *interpreter) {
+void
+Parrot_clear_n(struct Perl_Interp *interpreter) {
int i;
for (i=0; i<NUM_REGISTERS; i++) {
NUM_REG(i) = 0;
}
}
-void Parrot_push_p(struct Perl_Interp *interpreter) {
+void
+Parrot_push_p(struct Perl_Interp *interpreter) {
struct PRegChunk *chunk_base;
chunk_base = CHUNK_BASE(interpreter->pmc_reg);
@@ -180,7 +190,7 @@
/* Nope, so plan B time. Allocate a new chunk of float register frames */
else {
struct PRegChunk *new_chunk;
- new_chunk = Allocate_Aligned(sizeof(struct PRegChunk));
+ new_chunk = mem_allocate_aligned(sizeof(struct PRegChunk));
new_chunk->used = 1;
new_chunk->free = FRAMES_PER_PMC_REG_CHUNK - 1;
new_chunk->next = NULL;
@@ -190,7 +200,8 @@
}
}
-void Parrot_pop_p(struct Perl_Interp *interpreter) {
+void
+Parrot_pop_p(struct Perl_Interp *interpreter) {
struct PRegChunk *chunk_base;
chunk_base = CHUNK_BASE(interpreter->pmc_reg);
/* Is there more than one register frame in use? */
@@ -215,15 +226,18 @@
}
}
-void Parrot_clear_p(struct Perl_Interp *interpreter) {
+void
+Parrot_clear_p(struct Perl_Interp *interpreter) {
int i;
for (i=0; i<NUM_REGISTERS; i++) {
PMC_REG(i) = NULL;
}
}
-void Parrot_push_on_stack(void *thing, IV size, IV type) {
+void
+Parrot_push_on_stack(void *thing, IV size, IV type) {
}
-void Parrot_pop_off_stack(void *thing, IV type) {
+void
+Parrot_pop_off_stack(void *thing, IV type) {
}
Index: string.c
===================================================================
RCS file: /home/perlcvs/parrot/string.c,v
retrieving revision 1.4
diff -u -r1.4 string.c
--- string.c 2001/09/13 07:14:24 1.4
+++ string.c 2001/09/13 18:52:14
@@ -15,9 +15,9 @@
STRING *
string_make(void *buffer, IV buflen, IV encoding, IV flags, IV type) {
- STRING *s = Sys_Allocate(sizeof(STRING));
- s->bufstart = Sys_Allocate(buflen);
- Sys_Memcopy(s->bufstart, buffer, buflen);
+ STRING *s = mem_sys_allocate(sizeof(STRING));
+ s->bufstart = mem_sys_allocate(buflen);
+ mem_sys_memcopy(s->bufstart, buffer, buflen);
s->encoding = &(Parrot_string_vtable[encoding]);
s->buflen = s->bufused = buflen;
s->flags = flags;
@@ -30,14 +30,14 @@
string_grow(STRING* s, IV newsize) {
IV newsize_in_bytes = string_max_bytes(s, newsize);
if (s->buflen < newsize_in_bytes)
- Sys_Realloc(s->bufstart, newsize_in_bytes);
+ mem_sys_realloc(s->bufstart, newsize_in_bytes);
s->buflen = newsize_in_bytes;
}
void
string_destroy(STRING *s) {
- Sys_Free(s->bufstart);
- Sys_Free(s);
+ mem_sys_free(s->bufstart);
+ mem_sys_free(s);
}
/* Ordinary user-visible string operations */
Index: strnative.c
===================================================================
RCS file: /home/perlcvs/parrot/strnative.c,v
retrieving revision 1.5
diff -u -r1.5 strnative.c
--- strnative.c 2001/09/13 08:44:08 1.5
+++ strnative.c 2001/09/13 18:52:14
@@ -26,7 +26,7 @@
/* b is now in native format */
string_grow(a, a->strlen + b->strlen);
- Sys_Memcopy(a->bufstart + a->strlen, b->bufstart, b->strlen);
+ mem_sys_memcopy(a->bufstart + a->strlen, b->bufstart, b->strlen);
a->strlen = a->bufused = a->strlen + b->strlen;
return a;
}
@@ -47,7 +47,7 @@
/* Offset and length have already been "normalized" */
string_grow(dest, src->strlen - length);
- Sys_Memcopy(dest->bufstart, src->bufstart + offset, length);
+ mem_sys_memcopy(dest->bufstart, src->bufstart + offset, length);
dest->strlen = dest->bufused = length;
return dest;
Index: test_main.c
===================================================================
RCS file: /home/perlcvs/parrot/test_main.c,v
retrieving revision 1.4
diff -u -r1.4 test_main.c
--- test_main.c 2001/09/13 08:44:08 1.4
+++ test_main.c 2001/09/13 18:52:14
@@ -19,7 +19,8 @@
6 /* exit */
};
-int main(int argc, char **argv) {
+int
+main(int argc, char **argv) {
struct Perl_Interp *interpreter;
init_world();