[Python-checkins] CVS: python/dist/src/Include pyport.h,2.2,2.3

Tim Peters python-dev@python.org
Sun, 23 Jul 2000 11:10:20 -0700


Update of /cvsroot/python/python/dist/src/Include
In directory slayer.i.sourceforge.net:/tmp/cvs-serv28920/python/dist/src/Include

Modified Files:
	pyport.h 
Log Message:
Recent ANSIfication introduced a couple instances of
    #if RETSIGTYPE != void
That isn't C, and MSVC properly refuses to compile it.
Introduced new Py_RETURN_FROM_SIGNAL_HANDLER macro in pyport.h
to expand to the correct thing based on RETSIGTYPE.  However,
only void is ANSI!  Do we still have platforms that return int?
The Unix config mess appears to #define RETSIGTYPE by magic
without being asked to, so I assume it's "a problem" across
Unices still.


Index: pyport.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/pyport.h,v
retrieving revision 2.2
retrieving revision 2.3
diff -C2 -r2.2 -r2.3
*** pyport.h	2000/07/10 04:59:49	2.2
--- pyport.h	2000/07/23 18:10:16	2.3
***************
*** 12,16 ****
  /**************************************************************************
  Symbols and macros to supply platform-independent interfaces to basic
! C-language operations whose spellings vary across platforms.
  
  Please try to make documentation here as clear as possible:  by definition,
--- 12,16 ----
  /**************************************************************************
  Symbols and macros to supply platform-independent interfaces to basic
! C language & library operations whose spellings vary across platforms.
  
  Please try to make documentation here as clear as possible:  by definition,
***************
*** 23,26 ****
--- 23,31 ----
            signed integral type and i < 0.
  Used in:  Py_ARITHMETIC_RIGHT_SHIFT
+ 
+ RETSIGTYPE
+ Meaning:  Expands to void or int, depending on what the platform wants
+           signal handlers to return.  Note that only void is ANSI!
+ Used in:  Py_RETURN_FROM_SIGNAL_HANDLER
  **************************************************************************/
  
***************
*** 50,53 ****
--- 55,77 ----
  #define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J))
  #endif
+ 
+ /* Py_FORCE_EXPANSION
+  * "Simply" returns its argument.  However, macro expansions within the
+  * argument are evaluated.  This unfortunate trickery is needed to get
+  * token-pasting to work as desired in some cases.
+  */
+ #define Py_FORCE_EXPANSION(X) X
+ 
+ /* Py_RETURN_FROM_SIGNAL_HANDLER
+  * The return from a signal handler varies depending on whether RETSIGTYPE
+  * is int or void.  The macro Py_RETURN_FROM_SIGNAL_HANDLER(VALUE) expands
+  * to
+  *     return VALUE
+  * if RETSIGTYPE is int, else to nothing if RETSIGTYPE is void.
+  */
+ #define int_PySIGRETURN(VALUE) return VALUE
+ #define void_PySIGRETURN(VALUE)
+ #define Py_RETURN_FROM_SIGNAL_HANDLER(VALUE) \
+         Py_FORCE_EXPANSION(RETSIGTYPE) ## _PySIGRETURN(VALUE)
  
  #ifdef __cplusplus