Author: petdance
Date: Thu Jun  7 21:42:30 2007
New Revision: 18868

Modified:
   trunk/config/gen/makefiles/root.in
   trunk/include/parrot/misc.h
   trunk/src/utils.c

Log:
headerizing misc.c

Modified: trunk/config/gen/makefiles/root.in
==============================================================================
--- trunk/config/gen/makefiles/root.in  (original)
+++ trunk/config/gen/makefiles/root.in  Thu Jun  7 21:42:30 2007
@@ -1842,6 +1842,7 @@
     src/intlist.o \
     src/datatypes.o \
     src/gc/resources.o \
+    src/utils.o \
 
 headerizer:
        $(PERL) $(BUILD_TOOLS_DIR)/headerize.pl $(HEADERIZER_O_FILES)

Modified: trunk/include/parrot/misc.h
==============================================================================
--- trunk/include/parrot/misc.h (original)
+++ trunk/include/parrot/misc.h Thu Jun  7 21:42:30 2007
@@ -1,5 +1,5 @@
 /* misc.h
- *  Copyright (C) 2001-2003, The Perl Foundation.
+ *  Copyright (C) 2001-2007, The Perl Foundation.
  *  SVN Info
  *     $Id$
  *  Overview:
@@ -25,33 +25,63 @@
 /*
  * utils.c
  */
+typedef int (*reg_move_func)(Interp*, unsigned char d, unsigned char s, void 
*);
 
-INTVAL   intval_mod(INTVAL i2, INTVAL i3);
-FLOATVAL floatval_mod(FLOATVAL n2, FLOATVAL n3);
+/* HEADERIZER BEGIN: src/utils.c */
 
-PARROT_API FLOATVAL Parrot_float_rand(INTVAL how_random);
-PARROT_API INTVAL Parrot_uint_rand(INTVAL how_random);
-PARROT_API INTVAL Parrot_int_rand(INTVAL how_random);
-PARROT_API INTVAL Parrot_range_rand(INTVAL from, INTVAL to, INTVAL how_random);
-PARROT_API void Parrot_srand(INTVAL seed);
-
-PARROT_API void *Parrot_make_la(Interp *, PMC *);
-PARROT_API void *Parrot_make_cpa(Interp *, PMC *);
-PARROT_API void Parrot_destroy_la(long *);
-PARROT_API void Parrot_destroy_cpa(char **);
-PMC* tm_to_array(Parrot_Interp interp, const struct tm *tm);
-PARROT_API INTVAL Parrot_byte_index(Interp *interp, const STRING *base,
-        const STRING *search, UINTVAL start_offset);
-PARROT_API INTVAL Parrot_byte_rindex(Interp *interp, const STRING *base,
-        const STRING *search, UINTVAL start_offset);
-typedef int (*reg_move_func)(Interp*, unsigned char d, unsigned char s, void 
*);
+PARROT_API INTVAL Parrot_byte_index( Interp *interp,
+    const STRING *base /*NN*/,
+    const STRING *search /*NN*/,
+    UINTVAL start_offset )
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3);
+
+PARROT_API INTVAL Parrot_byte_rindex( Interp *interp,
+    const STRING *base /*NN*/,
+    const STRING *search /*NN*/,
+    UINTVAL start_offset )
+        __attribute__nonnull__(2)
+        __attribute__nonnull__(3);
+
+PARROT_API void Parrot_destroy_la( long *array );
+PARROT_API FLOATVAL Parrot_float_rand( INTVAL how_random );
+PARROT_API INTVAL Parrot_int_rand( INTVAL how_random );
+PARROT_API void * Parrot_make_la( Interp *interp, PMC *array /*NN*/ )
+        __attribute__nonnull__(2)
+        __attribute__warn_unused_result__;
+
+PARROT_API INTVAL Parrot_range_rand(
+    INTVAL from,
+    INTVAL to,
+    INTVAL how_random );
+
+PARROT_API void Parrot_register_move( Interp *interp,
+    int n_regs,
+    unsigned char *dest_regs /*NN*/,
+    unsigned char *src_regs /*NN*/,
+    unsigned char temp_reg,
+    reg_move_func mov,
+    reg_move_func mov_alt,
+    void *info )
+        __attribute__nonnull__(3)
+        __attribute__nonnull__(4);
+
+PARROT_API void Parrot_srand( INTVAL seed );
+PARROT_API INTVAL Parrot_uint_rand( INTVAL how_random );
+FLOATVAL floatval_mod( FLOATVAL n2, FLOATVAL n3 )
+        __attribute__pure__
+        __attribute__warn_unused_result__;
+
+INTVAL intval_mod( INTVAL i2, INTVAL i3 )
+        __attribute__pure__
+        __attribute__warn_unused_result__;
+
+PARROT_API PMC* tm_to_array(
+    Parrot_Interp interp,
+    const struct tm *tm /*NN*/ )
+        __attribute__nonnull__(2);
 
-PARROT_API void Parrot_register_move(Interp *interp, int n_regs,
-        unsigned char *dest_regs, unsigned char *src_regs,
-        unsigned char temp_reg,
-        reg_move_func mov,
-        reg_move_func mov_alt,
-        void *info);
+/* HEADERIZER END: src/utils.c */
 
 /*
  * IMCC API

Modified: trunk/src/utils.c
==============================================================================
--- trunk/src/utils.c   (original)
+++ trunk/src/utils.c   Thu Jun  7 21:42:30 2007
@@ -14,14 +14,12 @@
 
 =head2 Functions
 
-=over 4
-
-=cut
-
 */
 
 #include "parrot/parrot.h"
 
+/* HEADER: include/parrot/misc.h */
+
 /* Parrot_register_move companion functions i and data */
 typedef struct parrot_prm_context {
     unsigned char *dest_regs;
@@ -36,13 +34,13 @@
     void *info;
 } parrot_prm_context;
 
-void rec_climb_back_and_mark(int regindex, parrot_prm_context* c);
-void process_cycle_without_exit(int regindex, parrot_prm_context* c);
-void move_reg(int from, int dest, parrot_prm_context* c);
+static void rec_climb_back_and_mark(int regindex, parrot_prm_context* c);
+static void process_cycle_without_exit(int regindex, parrot_prm_context* c);
+static void move_reg(int from, int dest, parrot_prm_context* c);
 
 /*
 
-=item C<INTVAL intval_mod(INTVAL i2, INTVAL i3)>
+FUNCDOC: intval_mod
 
 NOTE: This "corrected mod" algorithm is based on the C code on page 70
 of [1]. Assuming correct behavior of the built-in mod operator (%) with
@@ -62,12 +60,11 @@
 [2] Ronald L. Graham, Donald E. Knuth and Oren Patashnik, *Concrete
 Mathematics*, Second Edition. Addison-Wesley, 1994.
 
-=cut
-
 */
 
 INTVAL
 intval_mod(INTVAL i2, INTVAL i3)
+    /* PURE,WARN_UNUSED */
 {
     INTVAL y;
     INTVAL z = i3;
@@ -98,19 +95,17 @@
 
 /*
 
-=item C<FLOATVAL
-floatval_mod(FLOATVAL n2, FLOATVAL n3)>
+FUNCDOC: floatval_mod
 
 Returns C<n2 mod n3>.
 
 Includes a workaround for buggy code generation in the C<lcc> compiler.
 
-=cut
-
 */
 
 FLOATVAL
 floatval_mod(FLOATVAL n2, FLOATVAL n3)
+    /* PURE, WARN_UNUSED */
 {
 #ifdef __LCC__
 
@@ -132,16 +127,10 @@
 
 /*
 
-=back
-
 =head2 Random Number Generator
 
 Based on the C<rand48()> family of functions.
 
-=over 4
-
-=cut
-
 */
 
 /*
@@ -168,13 +157,10 @@
 
 /*
 
-=item C<static void
-next_rand(_rand_buf X)>
+FUNCDOC: next_rand
 
 Returns the next random number in C<X>.
 
-=cut
-
 */
 
 static void
@@ -201,13 +187,10 @@
 
 /*
 
-=item C<static FLOATVAL
-_erand48(_rand_buf buf)>
+FUNCDOC: _erand48
 
 Returns a C<double> in the interval C<[0.0, 1.0)>.
 
-=cut
-
 */
 
 static FLOATVAL
@@ -221,13 +204,10 @@
 
 /*
 
-=item C<static FLOATVAL
-_drand48(void)>
+FUNCDOC: _drand48
 
 Returns a C<double> in the interval C<[0.0, 1.0)>.
 
-=cut
-
 */
 
 static FLOATVAL
@@ -238,13 +218,10 @@
 
 /*
 
-=item C<static long
-_jrand48(_rand_buf buf)>
+FUNCDOC: _jrand48
 
 Returns a C<long> in the interval C<[-2^31, 2^31)>.
 
-=cut
-
 */
 
 static long
@@ -258,13 +235,10 @@
 
 /*
 
-=item C<static long
-_nrand48(_rand_buf buf)>
+FUNCDOC: _nrand48
 
 Returns a C<long> in the interval C<[0, 2^31)>.
 
-=cut
-
 */
 
 static long
@@ -275,13 +249,10 @@
 
 /*
 
-=item C<static long
-_lrand48(void)>
+FUNCDOC: _lrand48
 
 Returns a C<long> in the interval C<[0, 2^31)>.
 
-=cut
-
 */
 
 static long
@@ -292,13 +263,10 @@
 
 /*
 
-=item C<static long
-_mrand48(void)>
+FUNCDOC: _mrand48
 
 Returns a C<long> in the interval C<[-2^31, 2^31)>.
 
-=cut
-
 */
 
 static long
@@ -309,14 +277,11 @@
 
 /*
 
-=item C<static void
-_srand48(long seed)>
+FUNCDOC: _srand48
 
 Sets the high order 32 bits to the argument C<seed>. The low order 16
 bits are set to the arbitrary value 0x330e.
 
-=cut
-
 */
 
 static void
@@ -352,17 +317,15 @@
 
 /*
 
-=item C<FLOATVAL
-Parrot_float_rand(INTVAL how_random)>
+FUNCDOC: Parrot_float_rand
 
 Returns a C<FLOATVAL> in the interval C<[0.0, 1.0)>.
 
 C<how_random> is ignored.
 
-=cut
-
 */
 
+PARROT_API
 FLOATVAL
 Parrot_float_rand(INTVAL how_random)
 {
@@ -371,17 +334,15 @@
 
 /*
 
-=item C<INTVAL
-Parrot_uint_rand(INTVAL how_random)>
+FUNCDOC: Parrot_uint_rand
 
 Returns an C<INTVAL> in the interval C<[0, 2^31)>.
 
 C<how_random> is ignored.
 
-=cut
-
 */
 
+PARROT_API
 INTVAL
 Parrot_uint_rand(INTVAL how_random)
 {
@@ -390,17 +351,15 @@
 
 /*
 
-=item C<INTVAL
-Parrot_int_rand(INTVAL how_random)>
+FUNCDOC: Parrot_int_rand
 
 Returns an C<INTVAL> in the interval C<[-2^31, 2^31)>.
 
 C<how_random> is ignored.
 
-=cut
-
 */
 
+PARROT_API
 INTVAL
 Parrot_int_rand(INTVAL how_random)
 {
@@ -409,17 +368,15 @@
 
 /*
 
-=item C<INTVAL
-Parrot_range_rand(INTVAL from, INTVAL to, INTVAL how_random)>
+FUNCDOC: Parrot_range_rand
 
 Returns an C<INTVAL> in the range C<[from, to]>.
 
 C<how_random> is ignored.
 
-=cut
-
 */
 
+PARROT_API
 INTVAL
 Parrot_range_rand(INTVAL from, INTVAL to, INTVAL how_random)
 {
@@ -429,15 +386,13 @@
 
 /*
 
-=item C<void
-Parrot_srand(INTVAL seed)>
+FUNCDOC: Parrot_srand
 
 Seeds the random number generator with C<seed>.
 
-=cut
-
 */
 
+PARROT_API
 void
 Parrot_srand(INTVAL seed)
 {
@@ -446,14 +401,9 @@
 
 /*
 
-=back
-
 =head2 Array Functions
 
-=over
-
-=item C<void *
-Parrot_make_la(Interp *interp, PMC *array)>
+FUNCDOC: Parrot_make_la
 
 Creates a C array of C<long>s with one more element than the number of
 elements in C<*array>. The elements are then copied from C<*array> to
@@ -461,12 +411,13 @@
 
 Used in C<src/nci.c>.
 
-=cut
-
 */
 
+PARROT_API
 void *
-Parrot_make_la(Interp *interp, PMC *array) {
+Parrot_make_la(Interp *interp, PMC *array /*NN*/)
+    /* WARN_UNUSED */
+{
     const INTVAL arraylen = VTABLE_elements(interp, array);
     INTVAL cur;
 
@@ -487,15 +438,13 @@
 
 /*
 
-=item C<void
-Parrot_destroy_la(long *array)>
+FUNCDOC: Parrot_destroy_la
 
 Use this to destroy an array created with C<Parrot_make_la()>.
 
-=cut
-
 */
 
+PARROT_API
 void
 Parrot_destroy_la(long *array) {
     mem_sys_free(array);
@@ -503,8 +452,7 @@
 
 /*
 
-=item C<void *
-Parrot_make_cpa(Interp *interp, PMC *array)>
+FUNCDOC: Parrot_make_cpa
 
 Creates a C array of C<char *>s with one more element than the number of
 elements in C<*array>. The elements are then copied from C<*array> to
@@ -514,10 +462,9 @@
 
 Note that you need to free this array with C<Parrot_destroy_cpa()>.
 
-=cut
-
 */
 
+PARROT_API
 void *
 Parrot_make_cpa(Interp *interp, PMC *array) {
     const INTVAL arraylen = VTABLE_elements(interp, array);
@@ -546,17 +493,15 @@
 
 /*
 
-=item C<void
-Parrot_destroy_cpa(char **array)>
+FUNCDOC: Parrot_destroy_cpa
 
 Use this to destroy an array created with C<Parrot_make_cpa()>.
 
-=cut
-
 */
 
+PARROT_API
 void
-Parrot_destroy_cpa(char **array) {
+Parrot_destroy_cpa(char **array /*NN*/) {
     UINTVAL offset = 0;
     /* Free each piece */
     while (array[offset] != NULL) {
@@ -565,15 +510,6 @@
     /* And then the holding array */
     mem_sys_free(array);
 }
-/*
-
-=item C<PMC* tm_to_array(Parrot_Interp, struct tm *)>
-
-Helper to convert a B<struct tm *> to an Array
-
-=cut
-
-*/
 
 /* &gen_from_enum(tm.pasm) */
 typedef enum {
@@ -589,26 +525,38 @@
 } tm_struct_enum;
 /* &end_gen */
 
+/*
+
+FUNCDOC: tm_to_array
+
+Helper to convert a B<struct tm *> to an Array
+
+*/
+
+PARROT_API
 PMC*
-tm_to_array(Parrot_Interp interp, const struct tm *tm)
+tm_to_array(Parrot_Interp interp, const struct tm *tm /*NN*/)
 {
-  PMC * const Array = pmc_new(interp, enum_class_Array);
-  VTABLE_set_integer_native(interp, Array, 9);
-  VTABLE_set_integer_keyed_int(interp, Array, 0, tm->tm_sec);
-  VTABLE_set_integer_keyed_int(interp, Array, 1, tm->tm_min);
-  VTABLE_set_integer_keyed_int(interp, Array, 2, tm->tm_hour);
-  VTABLE_set_integer_keyed_int(interp, Array, 3, tm->tm_mday);
-  VTABLE_set_integer_keyed_int(interp, Array, 4, tm->tm_mon + 1);
-  VTABLE_set_integer_keyed_int(interp, Array, 5, tm->tm_year + 1900);
-  VTABLE_set_integer_keyed_int(interp, Array, 6, tm->tm_wday);
-  VTABLE_set_integer_keyed_int(interp, Array, 7, tm->tm_yday);
-  VTABLE_set_integer_keyed_int(interp, Array, 8, tm->tm_isdst);
-  return Array;
+    PMC * const Array = pmc_new(interp, enum_class_Array);
+
+    VTABLE_set_integer_native(interp, Array, 9);
+    VTABLE_set_integer_keyed_int(interp, Array, 0, tm->tm_sec);
+    VTABLE_set_integer_keyed_int(interp, Array, 1, tm->tm_min);
+    VTABLE_set_integer_keyed_int(interp, Array, 2, tm->tm_hour);
+    VTABLE_set_integer_keyed_int(interp, Array, 3, tm->tm_mday);
+    VTABLE_set_integer_keyed_int(interp, Array, 4, tm->tm_mon + 1);
+    VTABLE_set_integer_keyed_int(interp, Array, 5, tm->tm_year + 1900);
+    VTABLE_set_integer_keyed_int(interp, Array, 6, tm->tm_wday);
+    VTABLE_set_integer_keyed_int(interp, Array, 7, tm->tm_yday);
+    VTABLE_set_integer_keyed_int(interp, Array, 8, tm->tm_isdst);
+
+    return Array;
 }
 
+PARROT_API
 INTVAL
-Parrot_byte_index(Interp *interp, const STRING *base,
-        const STRING *search, UINTVAL start_offset)
+Parrot_byte_index(Interp *interp, const STRING *base /*NN*/,
+        const STRING *search /*NN*/, UINTVAL start_offset)
 {
     const INTVAL searchlen = search->strlen;
     const char * const search_start = search->strstart;
@@ -618,7 +566,7 @@
     for (current_offset = start_offset; current_offset <= max_possible_offset;
             current_offset++) {
         const char * const base_start = (char *)base->strstart + 
current_offset;
-        if (!memcmp(base_start, search_start, searchlen)) {
+        if (memcmp(base_start, search_start, searchlen) == 0) {
             return current_offset;
         }
     }
@@ -626,9 +574,10 @@
     return -1;
 }
 
+PARROT_API
 INTVAL
-Parrot_byte_rindex(Interp *interp, const STRING *base,
-        const STRING *search, UINTVAL start_offset)
+Parrot_byte_rindex(Interp *interp, const STRING *base /*NN*/,
+        const STRING *search /*NN*/, UINTVAL start_offset)
 {
     const INTVAL searchlen = search->strlen;
     const char * const search_start = search->strstart;
@@ -651,7 +600,7 @@
 
 /*
 
-=item C<void rec_climb_back_and_mark(int node_index, parrot_prm_context* c)>
+FUNCDOC: rec_climb_back_and_mark
 
 Recursive function, used by Parrot_register_move to
 climb back the graph of register moves operations.
@@ -670,10 +619,8 @@
   node_index  ... the index of a destination (i.e. with a pred.) register
   c           ... the graph and all the needed params : the context
 
-=cut
-
 */
-void
+static void
 rec_climb_back_and_mark(int node_index, parrot_prm_context* c) {
     const int node = c->dest_regs[node_index];
     const int pred = c->src_regs[node_index];
@@ -698,7 +645,7 @@
 
 /*
 
-=item C<void process_cycle_without_exit(int node_index, parrot_prm_context* c)>
+FUNCDOC: process_cycle_without_exit
 
 Recursive function, used by Parrot_register_move to handle the case
 of cycles without exits, that are cycles of move ops between registers
@@ -709,8 +656,7 @@
   node_index  ... the index of a destination (i.e. with a pred.) register
   c           ... the graph and all the needed params : the context
 
-=cut
- */
+*/
 
 void
 process_cycle_without_exit(int node_index, parrot_prm_context* c) {
@@ -744,16 +690,6 @@
 
 /*
 
-=item C<typedef int (*reg_move_func)(Interp*, unsigned char d,
-                                     unsigned char s, void *);>
-
-=item C<void Parrot_register_move(Interp *, int n_regs,
-        unsigned char *dest_regs, unsigned char *src_regs,
-        unsigned char temp_reg,
-        reg_move_func mov,
-        reg_move_func mov_alt,
-        void *info)>
-
 Move C<n_regs> from the given register list C<src_regs> to C<dest_regs>.
 
   n_regs    ... amount of registers to move
@@ -799,12 +735,12 @@
 
 TODO: Add tests for the above conditions.
 
-=cut
-
 */
+
+PARROT_API
 void
 Parrot_register_move(Interp *interp, int n_regs,
-                     unsigned char *dest_regs, unsigned char *src_regs,
+                     unsigned char *dest_regs /*NN*/, unsigned char *src_regs 
/*NN*/,
                      unsigned char temp_reg,
                      reg_move_func mov, reg_move_func mov_alt, void *info)
 {
@@ -890,14 +826,10 @@
 
 /*
 
-=back
-
 =head1 HISTORY
 
 Initial version by leo 2003.09.09.
 
-=cut
-
 */
 
 

Reply via email to