This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Rationalize DL_IMPORT and DL_EXPORT
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: mhammond Nosy List: effbot, mhammond, mwh, nnorwitz, skip.montanaro, tim.peters
Priority: normal Keywords: patch

Created on 2002-06-08 05:14 by mhammond, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
dl_import.patch mhammond, 2002-07-05 06:45 Updated patch - requires autoheader and autoconf to work.
cfg.diff nnorwitz, 2002-07-19 01:03 Updated configure to match new configure.in
dl_export.diff skip.montanaro, 2002-07-31 15:54
Messages (16)
msg40241 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2002-06-08 05:14
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.
msg40242 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2002-06-21 05:20
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
msg40243 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-06-24 03:18
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. :-)
msg40244 - (view) Author: Fredrik Lundh (effbot) * (Python committer) Date: 2002-07-01 18:03
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>
msg40245 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2002-07-02 01:47
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.
msg40246 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2002-07-02 10:16
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.
msg40247 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2002-07-04 01:35
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?
msg40248 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2002-07-04 12:28
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).
msg40249 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2002-07-05 06:45
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>
msg40250 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-07-05 18:45
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.
msg40251 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2002-07-06 00:41
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.
msg40252 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-07-15 22:33
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.
msg40253 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2002-07-19 01:03
Logged In: YES 
user_id=33168

Add patch for configure.
msg40254 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2002-07-19 06:57
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
msg40255 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2002-07-19 07:23
Logged In: YES 
user_id=31435

Au contraire, thank you!
msg40256 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2002-07-31 15:54
Logged In: YES 
user_id=44345

Here's a cut at the mods to Modules/*.c and Include/*.h that Mark 
requested.  Potential issues:

* cPickle.c and cStringIO.c had some #ifndef DL_* stuff.  That probably 
needs to be checked.

* There's a DL_EXPORT in Modules/python.c.  The straightforward 
replacement didn't work, so I left it alone.  (It clearly doesn't fall into 
Mark's description of "mindless editing".  I tried to keep my mind turned 
off during this exercise. ;-)

Skip
History
Date User Action Args
2022-04-10 16:05:24adminsetgithub: 36712
2002-06-08 05:14:56mhammondcreate