Skip to content

Commit a290527

Browse files
committed
Excise DL_IMPORT/EXPORT from object.h, and related files. This patch
also adds 'extern' to PyAPI_DATA rather than at each declaration, as discussed with Tim and Guido.
1 parent f4ad4ce commit a290527

7 files changed

Lines changed: 97 additions & 97 deletions

File tree

Include/import.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m);
2121
PyAPI_FUNC(void) PyImport_Cleanup(void);
2222
PyAPI_FUNC(int) PyImport_ImportFrozenModule(char *);
2323

24-
extern PyAPI_FUNC(PyObject *)_PyImport_FindExtension(char *, char *);
25-
extern PyAPI_FUNC(PyObject *)_PyImport_FixupExtension(char *, char *);
24+
PyAPI_FUNC(PyObject *)_PyImport_FindExtension(char *, char *);
25+
PyAPI_FUNC(PyObject *)_PyImport_FixupExtension(char *, char *);
2626

2727
struct _inittab {
2828
char *name;
2929
void (*initfunc)(void);
3030
};
3131

32-
extern PyAPI_DATA(struct _inittab *) PyImport_Inittab;
32+
PyAPI_DATA(struct _inittab *) PyImport_Inittab;
3333

34-
extern PyAPI_FUNC(int) PyImport_AppendInittab(char *name, void (*initfunc)(void));
35-
extern PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
34+
PyAPI_FUNC(int) PyImport_AppendInittab(char *name, void (*initfunc)(void));
35+
PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
3636

3737
struct _frozen {
3838
char *name;
@@ -43,7 +43,7 @@ struct _frozen {
4343
/* Embedding apps may change this pointer to point to their favorite
4444
collection of frozen modules: */
4545

46-
extern PyAPI_DATA(struct _frozen *) PyImport_FrozenModules;
46+
PyAPI_DATA(struct _frozen *) PyImport_FrozenModules;
4747

4848
#ifdef __cplusplus
4949
}

Include/object.h

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -327,52 +327,52 @@ typedef struct _typeobject {
327327

328328

329329
/* Generic type check */
330-
extern DL_IMPORT(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *);
330+
PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *);
331331
#define PyObject_TypeCheck(ob, tp) \
332332
((ob)->ob_type == (tp) || PyType_IsSubtype((ob)->ob_type, (tp)))
333333

334-
extern DL_IMPORT(PyTypeObject) PyType_Type; /* built-in 'type' */
335-
extern DL_IMPORT(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */
336-
extern DL_IMPORT(PyTypeObject) PySuper_Type; /* built-in 'super' */
334+
PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */
335+
PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */
336+
PyAPI_DATA(PyTypeObject) PySuper_Type; /* built-in 'super' */
337337

338338
#define PyType_Check(op) PyObject_TypeCheck(op, &PyType_Type)
339339
#define PyType_CheckExact(op) ((op)->ob_type == &PyType_Type)
340340

341-
extern DL_IMPORT(int) PyType_Ready(PyTypeObject *);
342-
extern DL_IMPORT(PyObject *) PyType_GenericAlloc(PyTypeObject *, int);
343-
extern DL_IMPORT(PyObject *) PyType_GenericNew(PyTypeObject *,
341+
PyAPI_FUNC(int) PyType_Ready(PyTypeObject *);
342+
PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, int);
343+
PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *,
344344
PyObject *, PyObject *);
345-
extern DL_IMPORT(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *);
345+
PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *);
346346

347347
/* Generic operations on objects */
348-
extern DL_IMPORT(int) PyObject_Print(PyObject *, FILE *, int);
349-
extern DL_IMPORT(void) _PyObject_Dump(PyObject *);
350-
extern DL_IMPORT(PyObject *) PyObject_Repr(PyObject *);
351-
extern DL_IMPORT(PyObject *) PyObject_Str(PyObject *);
348+
PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int);
349+
PyAPI_FUNC(void) _PyObject_Dump(PyObject *);
350+
PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *);
351+
PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *);
352352
#ifdef Py_USING_UNICODE
353-
extern DL_IMPORT(PyObject *) PyObject_Unicode(PyObject *);
353+
PyAPI_FUNC(PyObject *) PyObject_Unicode(PyObject *);
354354
#endif
355-
extern DL_IMPORT(int) PyObject_Compare(PyObject *, PyObject *);
356-
extern DL_IMPORT(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int);
357-
extern DL_IMPORT(int) PyObject_RichCompareBool(PyObject *, PyObject *, int);
358-
extern DL_IMPORT(PyObject *) PyObject_GetAttrString(PyObject *, char *);
359-
extern DL_IMPORT(int) PyObject_SetAttrString(PyObject *, char *, PyObject *);
360-
extern DL_IMPORT(int) PyObject_HasAttrString(PyObject *, char *);
361-
extern DL_IMPORT(PyObject *) PyObject_GetAttr(PyObject *, PyObject *);
362-
extern DL_IMPORT(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *);
363-
extern DL_IMPORT(int) PyObject_HasAttr(PyObject *, PyObject *);
364-
extern DL_IMPORT(PyObject **) _PyObject_GetDictPtr(PyObject *);
365-
extern DL_IMPORT(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *);
366-
extern DL_IMPORT(int) PyObject_GenericSetAttr(PyObject *,
355+
PyAPI_FUNC(int) PyObject_Compare(PyObject *, PyObject *);
356+
PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int);
357+
PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int);
358+
PyAPI_FUNC(PyObject *) PyObject_GetAttrString(PyObject *, char *);
359+
PyAPI_FUNC(int) PyObject_SetAttrString(PyObject *, char *, PyObject *);
360+
PyAPI_FUNC(int) PyObject_HasAttrString(PyObject *, char *);
361+
PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *);
362+
PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *);
363+
PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *);
364+
PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *);
365+
PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *);
366+
PyAPI_FUNC(int) PyObject_GenericSetAttr(PyObject *,
367367
PyObject *, PyObject *);
368-
extern DL_IMPORT(long) PyObject_Hash(PyObject *);
369-
extern DL_IMPORT(int) PyObject_IsTrue(PyObject *);
370-
extern DL_IMPORT(int) PyObject_Not(PyObject *);
371-
extern DL_IMPORT(int) PyCallable_Check(PyObject *);
372-
extern DL_IMPORT(int) PyNumber_Coerce(PyObject **, PyObject **);
373-
extern DL_IMPORT(int) PyNumber_CoerceEx(PyObject **, PyObject **);
368+
PyAPI_FUNC(long) PyObject_Hash(PyObject *);
369+
PyAPI_FUNC(int) PyObject_IsTrue(PyObject *);
370+
PyAPI_FUNC(int) PyObject_Not(PyObject *);
371+
PyAPI_FUNC(int) PyCallable_Check(PyObject *);
372+
PyAPI_FUNC(int) PyNumber_Coerce(PyObject **, PyObject **);
373+
PyAPI_FUNC(int) PyNumber_CoerceEx(PyObject **, PyObject **);
374374

375-
extern DL_IMPORT(void) PyObject_ClearWeakRefs(PyObject *);
375+
PyAPI_FUNC(void) PyObject_ClearWeakRefs(PyObject *);
376376

377377
/* A slot function whose address we need to compare */
378378
extern int _PyObject_SlotCompare(PyObject *, PyObject *);
@@ -383,16 +383,16 @@ extern int _PyObject_SlotCompare(PyObject *, PyObject *);
383383
returning the names of the current locals. In this case, if there are
384384
no current locals, NULL is returned, and PyErr_Occurred() is false.
385385
*/
386-
extern DL_IMPORT(PyObject *) PyObject_Dir(PyObject *);
386+
PyAPI_FUNC(PyObject *) PyObject_Dir(PyObject *);
387387

388388

389389
/* Helpers for printing recursive container types */
390-
extern DL_IMPORT(int) Py_ReprEnter(PyObject *);
391-
extern DL_IMPORT(void) Py_ReprLeave(PyObject *);
390+
PyAPI_FUNC(int) Py_ReprEnter(PyObject *);
391+
PyAPI_FUNC(void) Py_ReprLeave(PyObject *);
392392

393393
/* Helpers for hash functions */
394-
extern DL_IMPORT(long) _Py_HashDouble(double);
395-
extern DL_IMPORT(long) _Py_HashPointer(void*);
394+
PyAPI_FUNC(long) _Py_HashDouble(double);
395+
PyAPI_FUNC(long) _Py_HashPointer(void*);
396396

397397
/* Helper for passing objects to printf and the like */
398398
#define PyObject_REPR(obj) PyString_AS_STRING(PyObject_Repr(obj))
@@ -521,8 +521,8 @@ environment the global variable trick is not safe.)
521521
* #ifdefs (we used to do that -- it was impenetrable).
522522
*/
523523
#ifdef Py_REF_DEBUG
524-
extern DL_IMPORT(long) _Py_RefTotal;
525-
extern DL_IMPORT(void) _Py_NegativeRefcount(const char *fname,
524+
PyAPI_DATA(long) _Py_RefTotal;
525+
PyAPI_FUNC(void) _Py_NegativeRefcount(const char *fname,
526526
int lineno, PyObject *op);
527527
#define _Py_INC_REFTOTAL _Py_RefTotal++
528528
#define _Py_DEC_REFTOTAL _Py_RefTotal--
@@ -540,7 +540,7 @@ extern DL_IMPORT(void) _Py_NegativeRefcount(const char *fname,
540540
#endif /* Py_REF_DEBUG */
541541

542542
#ifdef COUNT_ALLOCS
543-
extern DL_IMPORT(void) inc_count(PyTypeObject *);
543+
PyAPI_FUNC(void) inc_count(PyTypeObject *);
544544
#define _Py_INC_TPALLOCS(OP) inc_count((OP)->ob_type)
545545
#define _Py_INC_TPFREES(OP) (OP)->ob_type->tp_frees++
546546
#define _Py_DEC_TPFREES(OP) (OP)->ob_type->tp_frees--
@@ -554,11 +554,11 @@ extern DL_IMPORT(void) inc_count(PyTypeObject *);
554554

555555
#ifdef Py_TRACE_REFS
556556
/* Py_TRACE_REFS is such major surgery that we call external routines. */
557-
extern DL_IMPORT(void) _Py_NewReference(PyObject *);
558-
extern DL_IMPORT(void) _Py_ForgetReference(PyObject *);
559-
extern DL_IMPORT(void) _Py_Dealloc(PyObject *);
560-
extern DL_IMPORT(void) _Py_PrintReferences(FILE *);
561-
extern DL_IMPORT(void) _Py_ResetReferences(void);
557+
PyAPI_FUNC(void) _Py_NewReference(PyObject *);
558+
PyAPI_FUNC(void) _Py_ForgetReference(PyObject *);
559+
PyAPI_FUNC(void) _Py_Dealloc(PyObject *);
560+
PyAPI_FUNC(void) _Py_PrintReferences(FILE *);
561+
PyAPI_FUNC(void) _Py_ResetReferences(void);
562562

563563
#else
564564
/* Without Py_TRACE_REFS, there's little enough to do that we expand code
@@ -597,14 +597,14 @@ where NULL (nil) is not suitable (since NULL often means 'error').
597597
598598
Don't forget to apply Py_INCREF() when returning this value!!!
599599
*/
600-
extern DL_IMPORT(PyObject) _Py_NoneStruct; /* Don't use this directly */
600+
PyAPI_DATA(PyObject) _Py_NoneStruct; /* Don't use this directly */
601601
#define Py_None (&_Py_NoneStruct)
602602

603603
/*
604604
Py_NotImplemented is a singleton used to signal that an operation is
605605
not implemented for a given type combination.
606606
*/
607-
extern DL_IMPORT(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */
607+
PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */
608608
#define Py_NotImplemented (&_Py_NotImplementedStruct)
609609

610610
/* Rich comparison opcodes */
@@ -720,10 +720,10 @@ chain of N deallocations is broken into N / PyTrash_UNWIND_LEVEL pieces,
720720
with the call stack never exceeding a depth of PyTrash_UNWIND_LEVEL.
721721
*/
722722

723-
extern DL_IMPORT(void) _PyTrash_deposit_object(PyObject*);
724-
extern DL_IMPORT(void) _PyTrash_destroy_chain(void);
725-
extern DL_IMPORT(int) _PyTrash_delete_nesting;
726-
extern DL_IMPORT(PyObject *) _PyTrash_delete_later;
723+
PyAPI_FUNC(void) _PyTrash_deposit_object(PyObject*);
724+
PyAPI_FUNC(void) _PyTrash_destroy_chain(void);
725+
PyAPI_DATA(int) _PyTrash_delete_nesting;
726+
PyAPI_DATA(PyObject *) _PyTrash_delete_later;
727727

728728
#define PyTrash_UNWIND_LEVEL 50
729729

Include/pydebug.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@
55
extern "C" {
66
#endif
77

8-
extern DL_IMPORT(int) Py_DebugFlag;
9-
extern DL_IMPORT(int) Py_VerboseFlag;
10-
extern DL_IMPORT(int) Py_InteractiveFlag;
11-
extern DL_IMPORT(int) Py_OptimizeFlag;
12-
extern DL_IMPORT(int) Py_NoSiteFlag;
13-
extern DL_IMPORT(int) Py_UseClassExceptionsFlag;
14-
extern DL_IMPORT(int) Py_FrozenFlag;
15-
extern DL_IMPORT(int) Py_TabcheckFlag;
16-
extern DL_IMPORT(int) Py_UnicodeFlag;
17-
extern DL_IMPORT(int) Py_IgnoreEnvironmentFlag;
18-
extern DL_IMPORT(int) Py_DivisionWarningFlag;
8+
PyAPI_DATA(int) Py_DebugFlag;
9+
PyAPI_DATA(int) Py_VerboseFlag;
10+
PyAPI_DATA(int) Py_InteractiveFlag;
11+
PyAPI_DATA(int) Py_OptimizeFlag;
12+
PyAPI_DATA(int) Py_NoSiteFlag;
13+
PyAPI_DATA(int) Py_UseClassExceptionsFlag;
14+
PyAPI_DATA(int) Py_FrozenFlag;
15+
PyAPI_DATA(int) Py_TabcheckFlag;
16+
PyAPI_DATA(int) Py_UnicodeFlag;
17+
PyAPI_DATA(int) Py_IgnoreEnvironmentFlag;
18+
PyAPI_DATA(int) Py_DivisionWarningFlag;
1919
/* _XXX Py_QnewFlag should go away in 2.3. It's true iff -Qnew is passed,
2020
on the command line, and is used in 2.2 by ceval.c to make all "/" divisions
2121
true divisions (which they will be in 2.3). */
22-
extern DL_IMPORT(int) _Py_QnewFlag;
22+
PyAPI_DATA(int) _Py_QnewFlag;
2323

2424
/* this is a wrapper around getenv() that pays attention to
2525
Py_IgnoreEnvironmentFlag. It should be used for getting variables like
2626
PYTHONPATH and PYTHONHOME from the environment */
2727
#define Py_GETENV(s) (Py_IgnoreEnvironmentFlag ? NULL : getenv(s))
2828

29-
DL_IMPORT(void) Py_FatalError(const char *message);
29+
PyAPI_FUNC(void) Py_FatalError(const char *message);
3030

3131
#ifdef __cplusplus
3232
}

Include/pyport.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -405,14 +405,14 @@ and both these use __declspec()
405405
# if defined(HAVE_DECLSPEC_DLL)
406406
# ifdef Py_BUILD_CORE
407407
# define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE
408-
# define PyAPI_DATA(RTYPE) __declspec(dllexport) RTYPE
408+
# define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RTYPE
409409
/* module init functions inside the core need no external linkage */
410410
# define PyMODINIT_FUNC void
411411
# else /* Py_BUILD_CORE */
412412
/* Building an extension module, or an embedded situation */
413413
/* public Python functions and data are imported */
414414
# define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE
415-
# define PyAPI_DATA(RTYPE) __declspec(dllimport) RTYPE
415+
# define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE
416416
/* module init functions outside the core must be exported */
417417
# if defined(__cplusplus)
418418
# define PyMODINIT_FUNC extern "C" __declspec(dllexport) void
@@ -428,7 +428,7 @@ and both these use __declspec()
428428
# define PyAPI_FUNC(RTYPE) RTYPE
429429
#endif
430430
#ifndef PyAPI_DATA
431-
# define PyAPI_DATA(RTYPE) RTYPE
431+
# define PyAPI_DATA(RTYPE) extern RTYPE
432432
#endif
433433
#ifndef PyMODINIT_FUNC
434434
# if defined(__cplusplus)

Include/pythonrun.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -79,35 +79,35 @@ DL_IMPORT(void) Py_Exit(int);
7979
DL_IMPORT(int) Py_FdIsInteractive(FILE *, char *);
8080

8181
/* In getpath.c */
82-
DL_IMPORT(char *) Py_GetProgramFullPath(void);
83-
DL_IMPORT(char *) Py_GetPrefix(void);
84-
DL_IMPORT(char *) Py_GetExecPrefix(void);
85-
DL_IMPORT(char *) Py_GetPath(void);
82+
PyAPI_FUNC(char *) Py_GetProgramFullPath(void);
83+
PyAPI_FUNC(char *) Py_GetPrefix(void);
84+
PyAPI_FUNC(char *) Py_GetExecPrefix(void);
85+
PyAPI_FUNC(char *) Py_GetPath(void);
8686

8787
/* In their own files */
88-
DL_IMPORT(const char *) Py_GetVersion(void);
89-
DL_IMPORT(const char *) Py_GetPlatform(void);
90-
DL_IMPORT(const char *) Py_GetCopyright(void);
91-
DL_IMPORT(const char *) Py_GetCompiler(void);
92-
DL_IMPORT(const char *) Py_GetBuildInfo(void);
88+
PyAPI_FUNC(const char *) Py_GetVersion(void);
89+
PyAPI_FUNC(const char *) Py_GetPlatform(void);
90+
PyAPI_FUNC(const char *) Py_GetCopyright(void);
91+
PyAPI_FUNC(const char *) Py_GetCompiler(void);
92+
PyAPI_FUNC(const char *) Py_GetBuildInfo(void);
9393

9494
/* Internal -- various one-time initializations */
9595
DL_IMPORT(PyObject *) _PyBuiltin_Init(void);
9696
DL_IMPORT(PyObject *) _PySys_Init(void);
9797
DL_IMPORT(void) _PyImport_Init(void);
98-
DL_IMPORT(void) _PyExc_Init(void);
98+
PyAPI_FUNC(void) _PyExc_Init(void);
9999

100100
/* Various internal finalizers */
101-
DL_IMPORT(void) _PyExc_Fini(void);
102-
DL_IMPORT(void) _PyImport_Fini(void);
103-
DL_IMPORT(void) PyMethod_Fini(void);
104-
DL_IMPORT(void) PyFrame_Fini(void);
105-
DL_IMPORT(void) PyCFunction_Fini(void);
106-
DL_IMPORT(void) PyTuple_Fini(void);
107-
DL_IMPORT(void) PyString_Fini(void);
108-
DL_IMPORT(void) PyInt_Fini(void);
109-
DL_IMPORT(void) PyFloat_Fini(void);
110-
DL_IMPORT(void) PyOS_FiniInterrupts(void);
101+
PyAPI_FUNC(void) _PyExc_Fini(void);
102+
PyAPI_FUNC(void) _PyImport_Fini(void);
103+
PyAPI_FUNC(void) PyMethod_Fini(void);
104+
PyAPI_FUNC(void) PyFrame_Fini(void);
105+
PyAPI_FUNC(void) PyCFunction_Fini(void);
106+
PyAPI_FUNC(void) PyTuple_Fini(void);
107+
PyAPI_FUNC(void) PyString_Fini(void);
108+
PyAPI_FUNC(void) PyInt_Fini(void);
109+
PyAPI_FUNC(void) PyFloat_Fini(void);
110+
PyAPI_FUNC(void) PyOS_FiniInterrupts(void);
111111

112112
/* Stuff with no proper home (yet) */
113113
DL_IMPORT(char *) PyOS_Readline(char *);

Objects/object.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
#endif
99

1010
#ifdef Py_REF_DEBUG
11-
DL_IMPORT(long) _Py_RefTotal;
11+
long _Py_RefTotal;
1212
#endif
1313

14-
DL_IMPORT(int) Py_DivisionWarningFlag;
14+
int Py_DivisionWarningFlag;
1515

1616
/* Object allocation routines used by NEWOBJ and NEWVAROBJ macros.
1717
These are used by the individual routines for object creation.

Python/exceptions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ static struct {
10501050

10511051

10521052

1053-
DL_EXPORT(void)
1053+
void
10541054
_PyExc_Init(void)
10551055
{
10561056
char *modulename = "exceptions";
@@ -1146,7 +1146,7 @@ _PyExc_Init(void)
11461146
}
11471147

11481148

1149-
DL_EXPORT(void)
1149+
void
11501150
_PyExc_Fini(void)
11511151
{
11521152
int i;

0 commit comments

Comments
 (0)