guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Inlining `scm_is_pair ()'


From: Ludovic Courtès
Subject: [PATCH] Inlining `scm_is_pair ()'
Date: Tue, 24 Jan 2006 09:37:06 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

Hi,

address@hidden (Ludovic Courtès) writes:

> Since, I consider compilers that don't support inlining unimportant, I'd
> happily live without the `inline.c' stuff.  I.e., I'd put this in
> `pairs.h':
>
>   static SCM_C_INLINE int
>   scm_is_pair (...)
>
> With compilers not supporting inlining, this would lead to the creation
> of several instances of the function.  But who cares?

The following patch makes `scm_is_pair ()' an inline --- the macro was
indeed a bad idea because there are places (e.g., async.c:208) where its
argument is an assignment.

I'm not sure that's the only reason, but I'm now unable to compile Guile
with `-O0': when doing so, I get a "stack overflow" error when trying to
run the REPL.  Perhaps we should also declare the function with
`__attribute__ ((always_inline))'?

What about non-inlining compilers, are there still a lot of them?  I'd
suspect GCC is now used 40% of the time on proprietary Unices;
hopefully, the proprietary compilers used the rest of the time do
support the `inline' keyword [0], some of them even support C99 [1].
OTOH, it seems that Compaq's only supports `inline' as a pragma [2].

How about MSVC?

Thanks,
Ludovic.

[0] http://docs.hp.com/en/5990-8153/ch10s05.html
[1] 
http://developers.sun.com/prodtech/cc/documentation/ss9_docs/mr/READMEs/c.html
[2] http://h30097.www3.hp.com/dtk/Compaq_C_Compiler/doc/lrm/DOCU0030.HTM


2006-01-24  Ludovic Courtès  <address@hidden>

        * pairs.c (scm_is_pair): Removed.

        * pairs.h (scm_is_pair): Defined as `static inline'.

        * socket.c: Include "pairs.h".


--- orig/libguile/pairs.c
+++ mod/libguile/pairs.c
@@ -78,11 +78,6 @@
 }
 #undef FUNC_NAME
 
-int
-scm_is_pair (SCM x)
-{
-  return SCM_I_CONSP (x);
-}
 
 SCM
 scm_car (SCM pair)


--- orig/libguile/pairs.h
+++ mod/libguile/pairs.h
@@ -23,6 +23,7 @@
 
 
 #include "libguile/__scm.h"
+#include "libguile/gc.h"  /* SCM_CELL_TYPE */
 
 
 
@@ -78,7 +79,12 @@
 SCM_API void scm_error_pair_access (SCM);
 #endif
 
-SCM_API int scm_is_pair (SCM x);
+static SCM_C_INLINE int
+scm_is_pair (SCM obj)
+{
+  return (SCM_I_CONSP (obj));
+}
+
 
 SCM_API SCM scm_cons (SCM x, SCM y);
 SCM_API SCM scm_cons2 (SCM w, SCM x, SCM y);


--- orig/libguile/socket.c
+++ mod/libguile/socket.c
@@ -35,6 +35,7 @@
 
 #include "libguile/validate.h"
 #include "libguile/socket.h"
+#include "libguile/pairs.h"
 
 #ifdef __MINGW32__
 #include "win32-socket.h"





reply via email to

[Prev in Thread] Current Thread [Next in Thread]