Re: [AD] Inline file function

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2005-06-25, Hrvoje Ban <spoofer255@xxxxxxxxxx> wrote:
> On 6/25/05, Peter Wang <tjaden@xxxxxxxxxx> wrote:
> > 
> > I pulled it out of file.inl on purpose. Those operations all go through
> > the vtable now, so there's nothing much to gain by inlining.
> 
> 
> Then why didn't you pull them all out?

You're right, I lied.  The ones that are inline now were inline before
my custom packfiles change.  Here's a patch to pull them out then.

Peter
Index: makefile.in
===================================================================
RCS file: /cvsroot/alleg/allegro/makefile.in,v
retrieving revision 1.75
diff -u -r1.75 makefile.in
--- makefile.in	7 Jun 2005 11:56:47 -0000	1.75
+++ makefile.in	25 Jun 2005 13:47:22 -0000
@@ -199,7 +199,6 @@
 	$(srcdir)/include/allegro/inline/asm.inl \
 	$(srcdir)/include/allegro/inline/color.inl \
 	$(srcdir)/include/allegro/inline/draw.inl \
-	$(srcdir)/include/allegro/inline/file.inl \
 	$(srcdir)/include/allegro/inline/fix.inl \
 	$(srcdir)/include/allegro/inline/fmaths.inl \
 	$(srcdir)/include/allegro/inline/gfx.inl \
Index: include/allegro/alinline.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/alinline.h,v
retrieving revision 1.32
diff -u -r1.32 alinline.h
--- include/allegro/alinline.h	2 Oct 2002 18:17:08 -0000	1.32
+++ include/allegro/alinline.h	25 Jun 2005 13:47:24 -0000
@@ -24,8 +24,6 @@
 
 #include "inline/draw.inl"
 
-#include "inline/file.inl"
-
 #include "inline/fmaths.inl"
 
 #include "inline/3dmaths.inl"
Index: include/allegro/file.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/file.h,v
retrieving revision 1.13
diff -u -r1.13 file.h
--- include/allegro/file.h	6 May 2005 14:40:29 -0000	1.13
+++ include/allegro/file.h	25 Jun 2005 13:47:26 -0000
@@ -143,6 +143,10 @@
 AL_FUNC(int, pack_fseek, (PACKFILE *f, int offset));
 AL_FUNC(PACKFILE *, pack_fopen_chunk, (PACKFILE *f, int pack));
 AL_FUNC(PACKFILE *, pack_fclose_chunk, (PACKFILE *f));
+AL_FUNC(int, pack_getc, (PACKFILE *f));
+AL_FUNC(int, pack_putc, (int c, PACKFILE *f));
+AL_FUNC(int, pack_feof, (PACKFILE *f));
+AL_FUNC(int, pack_ferror, (PACKFILE *f));
 AL_FUNC(int, pack_igetw, (PACKFILE *f));
 AL_FUNC(long, pack_igetl, (PACKFILE *f));
 AL_FUNC(int, pack_iputw, (int w, PACKFILE *f));
@@ -163,8 +167,6 @@
    }
 #endif
 
-#include "inline/file.inl"
-
 #endif          /* ifndef ALLEGRO_FILE_H */
 
 
Index: include/allegro/inline/file.inl
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/inline/file.inl,v
retrieving revision 1.2
diff -u -r1.2 file.inl
--- include/allegro/inline/file.inl	16 Jan 2005 12:35:12 -0000	1.2
+++ include/allegro/inline/file.inl	25 Jun 2005 13:47:26 -0000
@@ -1,71 +1,6 @@
-/*         ______   ___    ___
- *        /\  _  \ /\_ \  /\_ \
- *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___
- *         \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
- *          \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
- *           \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
- *            \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
- *                                           /\____/
- *                                           \_/__/
- *
- *      File inline functions (generic C).
- *
- *      By Shawn Hargreaves.
- *
- *      See readme.txt for copyright information.
- */
-
-
 #ifndef ALLEGRO_FILE_INL
 #define ALLEGRO_FILE_INL
 
-#ifdef __cplusplus
-   extern "C" {
-#endif
-
-AL_INLINE(int, pack_getc, (PACKFILE *f),
-{
-   ASSERT(f);
-   ASSERT(f->vtable);
-   ASSERT(f->vtable->pf_getc);
-
-   return f->vtable->pf_getc(f->userdata);
-})
-
-
-AL_INLINE(int, pack_putc, (int c, PACKFILE *f),
-{
-   ASSERT(f);
-   ASSERT(f->vtable);
-   ASSERT(f->vtable->pf_putc);
-
-   return f->vtable->pf_putc(c, f->userdata);
-})
-
-
-AL_INLINE(int, pack_feof, (PACKFILE *f),
-{
-   ASSERT(f);
-   ASSERT(f->vtable);
-   ASSERT(f->vtable->pf_feof);
-
-   return f->vtable->pf_feof(f->userdata);
-})
-
-
-AL_INLINE(int, pack_ferror, (PACKFILE *f),
-{
-   ASSERT(f);
-   ASSERT(f->vtable);
-   ASSERT(f->vtable->pf_ferror);
-
-   return f->vtable->pf_ferror(f->userdata);
-})
-
-#ifdef __cplusplus
-   }
-#endif
+#warning file.inl should no longer be referenced.
 
 #endif          /* ifndef ALLEGRO_FILE_INL */
-
-
Index: src/file.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/file.c,v
retrieving revision 1.59
diff -u -r1.59 file.c
--- src/file.c	6 May 2005 14:40:29 -0000	1.59
+++ src/file.c	25 Jun 2005 13:47:26 -0000
@@ -2098,6 +2098,66 @@
 
 
 
+/* pack_getc:
+ *  Returns the next character from the stream f, or EOF if the end of the
+ *  file has been reached.
+ */
+int pack_getc(PACKFILE *f)
+{
+   ASSERT(f);
+   ASSERT(f->vtable);
+   ASSERT(f->vtable->pf_getc);
+
+   return f->vtable->pf_getc(f->userdata);
+}
+
+
+
+/* pack_putc:
+ *  Puts a character in the stream f.
+ */
+int pack_putc(int c, PACKFILE *f)
+{
+   ASSERT(f);
+   ASSERT(f->vtable);
+   ASSERT(f->vtable->pf_putc);
+
+   return f->vtable->pf_putc(c, f->userdata);
+}
+
+
+
+/* pack_feof:
+ *  pack_feof() returns nonzero as soon as you reach the end of the file. It 
+ *  does not wait for you to attempt to read beyond the end of the file,
+ *  contrary to the ISO C feof() function.
+ */
+int pack_feof(PACKFILE *f)
+{
+   ASSERT(f);
+   ASSERT(f->vtable);
+   ASSERT(f->vtable->pf_feof);
+
+   return f->vtable->pf_feof(f->userdata);
+}
+
+
+
+/* pack_ferror:
+ *  Returns nonzero if the error indicator for the stream is set, indicating
+ *  that an error has occurred during a previous operation on the stream.
+ */
+int pack_ferror(PACKFILE *f)
+{
+   ASSERT(f);
+   ASSERT(f->vtable);
+   ASSERT(f->vtable->pf_ferror);
+
+   return f->vtable->pf_ferror(f->userdata);
+}
+
+
+
 /* pack_igetw:
  *  Reads a 16 bit word from a file, using intel byte ordering.
  */


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/