[Patches] [ python-Patches-566100 ] Rationalize DL_IMPORT and DL_EXPORT

noreply@sourceforge.net noreply@sourceforge.net
Fri, 19 Jul 2002 00:23:24 -0700


Patches item #566100, was opened at 2002-06-08 01:14
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=566100&group_id=5470

Category: Core (C code)
Group: None
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Mark Hammond (mhammond)
Assigned to: Mark Hammond (mhammond)
Summary: Rationalize DL_IMPORT and DL_EXPORT

Initial Comment:
Tim and I agreed that DL_IMPORT/DL_EXPORT is both sucky
and broken.  We have come up with purpose oriented
macros to replace them.

PyAPI_FUNC: public Python functions
PyAPI_DATA: public Python data
PyMODINIT_FUNC: extension module init functions.

These cover all existing cases of DL_IMPORT and
DL_EXPORT in the core.

This patch simply introduces the new macros (keeping
the old ones), and changes a small amount of code to
actually use these macros.  The vast majority of the
existing Python code using DL_IMPORT/DL_EXPORT has not
been touched.

I have a patch that changes the following:

* PC/pyconfig.h - creates the new PyAPI/MODINIT macros,
but also rationalizes this header file considerably. 
All common macros between the various compilers have
been moved to a common section.  This simplifies the
header significantly.

* Include/pyport.h - creates the new PyAPI/MODINIT
macros for non windows platforms.

* Include/import.h - move to the new macros.  I picked
this header file at random, mainly to prove that the
new macros do indeed work.

* PC/_winreg.c, Modules/_sre.c, Modules/pyexpat.c -
move to the PyMODINIT_FUNC macro.

Patch tested on Windows and Linux.

----------------------------------------------------------------------

>Comment By: Tim Peters (tim_one)
Date: 2002-07-19 03:23

Message:
Logged In: YES 
user_id=31435

Au contraire, thank you!

----------------------------------------------------------------------

Comment By: Mark Hammond (mhammond)
Date: 2002-07-19 02:57

Message:
Logged In: YES 
user_id=14198

Thanks all!

Checking in configure;
/cvsroot/python/python/dist/src/configure,v  <--  configure
new revision: 1.322; previous revision: 1.321
Checking in pyconfig.h.in;
/cvsroot/python/python/dist/src/pyconfig.h.in,v  <-- 
pyconfig.h.in
new revision: 1.43; previous revision: 1.42
Checking in configure.in;
/cvsroot/python/python/dist/src/configure.in,v  <-- 
configure.in
new revision: 1.333; previous revision: 1.332
Checking in Makefile.pre.in;
/cvsroot/python/python/dist/src/Makefile.pre.in,v  <-- 
Makefile.pre.in
new revision: 1.88; previous revision: 1.87
Checking in Include/pyport.h;
/cvsroot/python/python/dist/src/Include/pyport.h,v  <-- 
pyport.h
new revision: 2.52; previous revision: 2.51
Checking in Include/import.h;
/cvsroot/python/python/dist/src/Include/import.h,v  <-- 
import.h
new revision: 2.28; previous revision: 2.27
Checking in PC/pyconfig.h;
/cvsroot/python/python/dist/src/PC/pyconfig.h,v  <--  pyconfig.h
new revision: 1.14; previous revision: 1.13
Checking in PC/_winreg.c;
/cvsroot/python/python/dist/src/PC/_winreg.c,v  <--  _winreg.c
new revision: 1.11; previous revision: 1.10
Checking in Modules/_sre.c;
/cvsroot/python/python/dist/src/Modules/_sre.c,v  <--  _sre.c
new revision: 2.82; previous revision: 2.81
Checking in Modules/pyexpat.c;
/cvsroot/python/python/dist/src/Modules/pyexpat.c,v  <-- 
pyexpat.c
new revision: 2.70; previous revision: 2.69
Checking in Python/thread.c;
/cvsroot/python/python/dist/src/Python/thread.c,v  <--  thread.c
new revision: 2.45; previous revision: 2.44
Checking in Doc/ext/extending.tex;
/cvsroot/python/python/dist/src/Doc/ext/extending.tex,v  <--
 extending.tex
new revision: 1.22; previous revision: 1.21


----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2002-07-18 21:03

Message:
Logged In: YES 
user_id=33168

Add patch for configure.

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2002-07-15 18:33

Message:
Logged In: YES 
user_id=33168

Sorry, I forgot about this patch.
I just tested on Linux (RedHat 7.2).
No problems, all expected tests successful.

----------------------------------------------------------------------

Comment By: Mark Hammond (mhammond)
Date: 2002-07-05 20:41

Message:
Logged In: YES 
user_id=14198

My patch is after Martin's so hopefully I have the macros
correct (or at least haven't regressed anything of his!)

DL_*PORT still exists, but is deprecated.  Eventually every
header will change, but for now DL_*PORT still works as before.

And yes, finding autoconf-2.5.3 for my cygwin and linux
platforms is what took 1/2 the time of getting this patch
together :)

Another report of success on Linux would be great!  To date,
I have not heard of a single person trying this patch on any
platform.

Thanks.

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2002-07-05 14:45

Message:
Logged In: YES 
user_id=33168

I think Martin checked in the change to drop support for win16,
so some of the macros may have changed (MS_WINDOWS, MS_WIN32).
Won't all the files which use DL_*PORT (most headers in
Include) will have to change?
Michael's explanation of autoconf is what I do.  Make sure
you have version 2.53 though.
Let me know if you want me to test on linux.

----------------------------------------------------------------------

Comment By: Mark Hammond (mhammond)
Date: 2002-07-05 02:45

Message:
Logged In: YES 
user_id=14198

ok - thanks!  Attaching a new patch that works correctly
with autheader.  I'm gunna need help checking this in tho,
but one step at a time <0.1 wink>

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2002-07-04 08:28

Message:
Logged In: YES 
user_id=6656

pyconfig.h.in is a bit like configure.  when you edit
configure.in, you're expected to run autoconf to make the
configure script and check that in too.  same with
pyconfig.h.in, except that it is made by autoheader.

try running autoheader and see what happens.

(I hope someone -- Martin? -- will correct me if I have this
wrong).

----------------------------------------------------------------------

Comment By: Mark Hammond (mhammond)
Date: 2002-07-03 21:35

Message:
Logged In: YES 
user_id=14198

I'm a little confused by pyconfig.h.in.  Can someone please
explain the process to me?  What I see is:

* reverting my pyconfig.h.in change prevents the new symbol
from appearing in pyconfig.h

* A CVS log of pyconfig.h.in shows heavy editing, with at
least 6 well-commented checkins in June alone.

So, all the evidence points that pyconfig.h.in does need
modification.  Can someone please clarify?

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2002-07-02 06:16

Message:
Logged In: YES 
user_id=6656

Um, you are aware that pyconfig.h.in is auto-generated (by
autoheader)?

But if you've made edits to configure.in, you're probably ok.

----------------------------------------------------------------------

Comment By: Mark Hammond (mhammond)
Date: 2002-07-01 21:47

Message:
Logged In: YES 
user_id=14198

OK - here is a new ambitious patch ;)  It attempts to
rationalize all platforms, not just the PC.

* pyport.h now sets up most of the import/export magic.  It
looks for Py_ENABLE_SHARED and Py_BUILD_CORE (both new
macros) that control the behaviour.

* Py_ENABLE_SHARED has been added to pyconfig.h.in and
configure.in, so that this macro is created in pyconfig.h
whenever '--enable-shared' is passed to configure. 
Py_BUILD_CORE is passed via a "/D" option only when the core
itself is built (ie, not extensions etc)

* PC/pyconfig.h has been rationalized heavily.

* A couple of places in the core have been changed to use
the new macros - more to test that it actually works.

This has been tested on Windows using MSVC, Windows using
cygwin/gcc, and RH7 linux.  I consider it basically "done"
so please comment away.

----------------------------------------------------------------------

Comment By: Fredrik Lundh (effbot)
Date: 2002-07-01 14:03

Message:
Logged In: YES 
user_id=38376

+1 (possibly except for the MODINIT_FUNC name...)

and yes, _sre.c is supposed to compile under earlier versions 
as well, but I can fix that later on.

</F>

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2002-06-23 23:18

Message:
Logged In: YES 
user_id=33168

I like the idea, but haven't looked at the patch.
I hope to look soon and give better feedback.
But I'll wait until after you upload the new version. :-)

----------------------------------------------------------------------

Comment By: Mark Hammond (mhammond)
Date: 2002-06-21 01:20

Message:
Logged In: YES 
user_id=14198

Just incase anyone was going to have a look at this <wink>,
I am working on a better version by integrating some of the
cygwin autoconf work.  Just want to avoid wasting other's time

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=566100&group_id=5470