Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 603c683

Browse files
committed
SF patch 473749 compile under OS/2 VA C++, from Michael Muller.
Changes enabling Python to compile under OS/2 Visual Age C++.
1 parent c444039 commit 603c683

7 files changed

Lines changed: 68 additions & 36 deletions

File tree

Modules/socketmodule.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,16 @@ Socket methods:
142142
#include <netdb.h>
143143
#include <sys/socket.h>
144144
#include <netinet/in.h>
145-
#if !(defined(__BEOS__) || defined(__CYGWIN__))
145+
#if !(defined(__BEOS__) || defined(__CYGWIN__) || (defined(PYOS_OS2) && defined(PYCC_VACPP)))
146146
#include <netinet/tcp.h>
147147
#endif
148148

149149
/* Headers needed for inet_ntoa() and inet_addr() */
150150
#ifdef __BEOS__
151151
#include <net/netdb.h>
152+
#elif defined(PYOS_OS2) && defined(PYCC_VACPP)
153+
#include <netdb.h>
154+
typedef size_t socklen_t;
152155
#else
153156
#ifndef USE_GUSI1
154157
#include <arpa/inet.h>

PC/os2vacpp/config.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ extern void initrotor(void);
3434
extern void initsignal(void);
3535
extern void initselect(void);
3636
extern void init_socket(void);
37-
extern void initsoundex(void);
3837
extern void initstrop(void);
3938
extern void initstruct(void);
4039
extern void inittime(void);
@@ -82,7 +81,6 @@ struct _inittab _PyImport_Inittab[] = {
8281
{"_socket", init_socket},
8382
{"select", initselect},
8483
#endif
85-
{"soundex", initsoundex},
8684
{"strop", initstrop},
8785
{"struct", initstruct},
8886
{"time", inittime},

PC/os2vacpp/makefile

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ MKMF_SRCS = $(PY_MODULES)\*.c $(PY_OBJECTS)\*.c $(PY_PARSER)\*.c $(PY_PYTHON)\*.
6565

6666
#.HDRPATH.c := $(PROJINCLUDE,;= ) $(.HDRPATH.c)
6767
#.PATH.c = .;$(PY_MODULES);$(PY_OBJECTS);$(PY_PARSER);$(PY_PYTHON)
68-
OTHERLIBS = $(OS2TCPIP)\lib\so32dll.lib $(OS2TCPIP)\lib\tcp32dll.lib \
69-
$(TCLTK)\Lib\Tcl76.lib $(TCLTK)\Lib\Tk42.lib
68+
OTHERLIBS = so32dll.lib tcp32dll.lib # Tcl76.lib Tk42.lib
7069

7170
#################
7271
# Inference Rules
@@ -121,7 +120,14 @@ PYTHON = \
121120
$(PATHOBJ)\SysModule.obj \
122121
$(PATHOBJ)\Thread.obj \
123122
$(PATHOBJ)\TraceBack.obj \
124-
$(PATHOBJ)\FrozenMain.obj
123+
$(PATHOBJ)\FrozenMain.obj \
124+
$(PATHOBJ)\exceptions.obj \
125+
$(PATHOBJ)\symtable.obj \
126+
$(PATHOBJ)\codecs.obj \
127+
$(PATHOBJ)\future.obj \
128+
$(PATHOBJ)\dynload_os2.obj \
129+
$(PATHOBJ)\mysnprintf.obj \
130+
$(PATHOBJ)\iterobject.obj
125131

126132
# Python's Internal Parser
127133
PARSER = \
@@ -154,7 +160,13 @@ OBJECTS = \
154160
$(PATHOBJ)\SliceObject.obj \
155161
$(PATHOBJ)\StringObject.obj \
156162
$(PATHOBJ)\TupleObject.obj \
157-
$(PATHOBJ)\TypeObject.obj
163+
$(PATHOBJ)\TypeObject.obj \
164+
$(PATHOBJ)\unicodeobject.obj \
165+
$(PATHOBJ)\unicodectype.obj \
166+
$(PATHOBJ)\cellobject.obj \
167+
$(PATHOBJ)\descrobject.obj \
168+
$(PATHOBJ)\weakrefobject.obj \
169+
$(PATHOBJ)\structseq.obj
158170

159171
# Extension Modules (Built-In or as Separate DLLs)
160172
MODULES = \
@@ -181,12 +193,13 @@ MODULES = \
181193
$(PATHOBJ)\SelectModule.obj \
182194
$(PATHOBJ)\SignalModule.obj \
183195
$(PATHOBJ)\SocketModule.obj \
184-
$(PATHOBJ)\SoundEx.obj \
185196
$(PATHOBJ)\StropModule.obj \
186197
$(PATHOBJ)\StructModule.obj \
187198
$(PATHOBJ)\TimeModule.obj \
188199
$(PATHOBJ)\ThreadModule.obj \
189-
$(PATHOBJ)\YUVConvert.obj
200+
$(PATHOBJ)\YUVConvert.obj \
201+
$(PATHOBJ)\bufferobject.obj \
202+
$(PATHOBJ)\gcmodule.obj
190203

191204
# Standalone Parser Generator Program (Shares Some of Python's Modules)
192205
PGEN = \
@@ -211,7 +224,7 @@ _GEN = /G4 /Gm /Gd-
211224
# /Gm = Use Multithread Runtime
212225
# /Gd = Dynamically Load Runtime
213226
# /Ms = Use _System Calling Convention (vs _Optlink)
214-
# (to allow non-VAC++ code to call into Python15.dll)
227+
# (to allow non-VAC++ code to call into Python22.dll)
215228

216229
_OPT = /O /Gl
217230
# /O = Enable Speed-Optimizations
@@ -246,8 +259,8 @@ CFLAGS = $(_BASE) $(_GEN) $(_OPT) $(_DBG) $(_OUT) $(_EXE) /Ss
246259
###################
247260
# Primary Target(s)
248261
###################
249-
All: obj noise PyCore.lib Python15.lib PGen.exe \
250-
Python.exe PythonPM.exe Python15.dll _tkinter.dll
262+
All: obj noise PyCore.lib Python22.lib PGen.exe \
263+
Python.exe PythonPM.exe Python22.dll # _tkinter.dll
251264

252265
Modules: $(MODULES)
253266
Objects: $(OBJECTS)
@@ -267,43 +280,43 @@ noise:
267280
##############
268281

269282
# Python Extension DLL: Tcl/Tk Interface
270-
_tkinter.dll: $(PATHOBJ)\_tkinter.obj Python15.lib _tkinter.def
271-
@ Echo Linking $@ As DLL
272-
@ $(CC) $(CFLAGS) /B"/NOE" $(_DLL) /Fe$@ $(_MAP) $** $(OTHERLIBS) >>$(ERRS)
283+
#_tkinter.dll: $(PATHOBJ)\_tkinter.obj Python22.lib _tkinter.def
284+
# @ Echo Linking $@ As DLL
285+
# @ $(CC) $(CFLAGS) /B"/NOE" $(_DLL) /Fe$@ $(_MAP) $** $(OTHERLIBS) >>$(ERRS)
273286

274-
$(PATHOBJ)\_tkinter.obj: $(PY_MODULES)\_tkinter.c
275-
@ Echo Compiling $**
276-
@ $(CC) -c $(CFLAGS) $(_DLL) -Fo$@ $** >>$(ERRS)
287+
#$(PATHOBJ)\_tkinter.obj: $(PY_MODULES)\_tkinter.c
288+
# @ Echo Compiling $**
289+
# @ $(CC) -c $(CFLAGS) $(_DLL) -Fo$@ $** >>$(ERRS)
277290

278291
# Object Library of All Essential Python Routines
279292
PyCore.lib: $(MODULES) $(OBJECTS) $(PARSER) $(PYTHON) $(PATHOBJ)\Config.obj
280293
@ Echo Adding Updated Object Files to Link Library $@
281294
@ ! ILIB $@ /NOLOGO /NOBACKUP -+$? ; >>$(ERRS)
282295

283-
Python15.dll: $(PATHOBJ)\Compile.obj PyCore.lib Python.def
296+
Python22.dll: $(PATHOBJ)\Compile.obj PyCore.lib Python.def
284297
@ Echo Linking $@ As DLL
285298
@ $(CC) $(CFLAGS) /B"/NOE" $(_DLL) /Fe$@ $(_MAP) $** $(OTHERLIBS) >>$(ERRS)
286-
@ Echo Compressing $@ with LxLite
287-
@ lxlite $@
299+
# @ Echo Compressing $@ with LxLite
300+
# @ lxlite $@
288301

289302
# IBM Linker Requires One Explicit .OBJ To Build a .DLL from a .LIB
290303
$(PATHOBJ)\Compile.obj: $(PY_PYTHON)\Compile.c
291304
@ Echo Compiling $**
292305
@ $(CC) -c $(CFLAGS) $(_DLL) -Fo$@ $** >>$(ERRS)
293306

294-
# Import Library for Using the Python15.dll
295-
Python15.lib: Python.def
307+
# Import Library for Using the Python22.dll
308+
Python22.lib: Python.def
296309
@ Echo Making $@
297310
@ IMPLIB /NOLOGO /NOIGNORE $@ $** >>$(ERRS)
298311
@ ILIB /NOLOGO /CONVFORMAT /NOEXTDICTIONARY /NOBROWSE /NOBACKUP $@; >>$(ERRS)
299312

300-
# Small Command-Line Program to Start Interpreter in Python15.dll
301-
Python.exe: $(PATHOBJ)\Python.obj Python15.lib
313+
# Small Command-Line Program to Start Interpreter in Python22.dll
314+
Python.exe: $(PATHOBJ)\Python.obj Python22.lib
302315
@ Echo Linking $@ As EXE
303316
@ $(CC) $(CFLAGS) $(_EXE) /B"/PM:VIO /STACK:360000" /Fe$@ $(_MAP) $** $(OTHERLIBS) >>$(ERRS)
304317

305-
# Small PM-GUI Program to Start Interpreter in Python15.dll
306-
PythonPM.exe: $(PATHOBJ)\Python.obj Python15.lib
318+
# Small PM-GUI Program to Start Interpreter in Python22.dll
319+
PythonPM.exe: $(PATHOBJ)\Python.obj Python22.lib
307320
@ Echo Linking $@ As EXE
308321
@ $(CC) $(CFLAGS) $(_EXE) /B"/PM:PM /STACK:360000" /Fe$@ $(_MAP) $** $(OTHERLIBS) >>$(ERRS)
309322

@@ -323,13 +336,13 @@ clean:
323336

324337
# Remove All Targets, Including Final Binaries
325338
distclean: clean
326-
-- Del /Q PyCore.lib Python15.lib >NUL 2>&1
327-
-- Del /Q Python15.dll Python.exe PGen.exe >NUL 2>&1
339+
-- Del /Q PyCore.lib Python22.lib >NUL 2>&1
340+
-- Del /Q Python22.dll Python.exe PGen.exe >NUL 2>&1
328341

329-
release: Python.exe Python15.dll Python15.lib
342+
release: Python.exe Python22.dll Python22.lib
330343
-- @Echo Y | copy /U Python.exe D:\EXEs
331-
-- @Echo Y | copy /U Python15.dll D:\DLLs
332-
-- @Echo Y | copy /U Python15.lib E:\Tau\Lib
344+
-- @Echo Y | copy /U Python22.dll D:\DLLs
345+
-- @Echo Y | copy /U Python22.lib E:\Tau\Lib
333346
-- @Echo Y | copy /U _tkinter.dll D:\Python
334347

335348
test:

PC/os2vacpp/pyconfig.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
/* Provide a default library so writers of extension modules
5555
* won't have to explicitly specify it anymore
5656
*/
57-
#pragma library("Python15.lib")
57+
#pragma library("Python22.lib")
5858

5959
/***************************************************/
6060
/* 32-Bit IBM VisualAge C/C++ v3.0 for OS/2 */
@@ -79,6 +79,14 @@
7979
/* #define HAVE_LONG_LONG 1 */ /* VAC++ does not support (long long) */
8080
/* #define SIZEOF_LONG_LONG 8 */ /* Count of Bytes in a (long long) */
8181

82+
/* unicode definines */
83+
#define Py_USING_UNICODE
84+
#define PY_UNICODE_TYPE wchar_t
85+
#define Py_UNICODE_SIZE SIZEOF_SHORT
86+
87+
/* dynamic loading */
88+
#define HAVE_DYNAMIC_LOADING 1
89+
8290
/* Define if type char is unsigned and you are not using gcc. */
8391
#ifndef __CHAR_UNSIGNED__
8492
/* #undef __CHAR_UNSIGNED__ */
@@ -188,7 +196,7 @@ typedef int pid_t;
188196
/* #define HAVE_GETUID 1 */
189197

190198
/* Unix-Specific */
191-
#define HAVE_SYS_UN_H 1 /* #include <sys/un.h> */
199+
/* #define HAVE_SYS_UN_H 1 /* #include <sys/un.h> */
192200
/* #define HAVE_SYS_UTSNAME_H 1 */ /* #include <sys/utsname.h> */
193201
/* #define HAVE_SYS_WAIT_H 1 */ /* #include <sys/wait.h> */
194202
/* #define HAVE_UNISTD_H 1 */ /* #include <unistd.h> */

PC/os2vacpp/python.def

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
LIBRARY PYTHON15 INITINSTANCE TERMINSTANCE
2-
DESCRIPTION 'Python 1.5 Core DLL'
1+
LIBRARY PYTHON22 INITINSTANCE TERMINSTANCE
2+
DESCRIPTION 'Python 2.2 Core DLL'
33
PROTMODE
44
DATA MULTIPLE NONSHARED
55

@@ -472,4 +472,9 @@ EXPORTS
472472
_Py_re_search
473473
_Py_re_set_syntax
474474
; _Py_samebitset
475+
PyBuffer_Type
476+
PyBuffer_FromObject
477+
PyBuffer_FromMemory
478+
PyBuffer_FromReadWriteMemory
479+
PyBuffer_New
475480

Python/bltinmodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,11 @@ builtin_execfile(PyObject *self, PyObject *args)
567567
#ifndef RISCOS
568568
if (!stat(filename, &s)) {
569569
if (S_ISDIR(s.st_mode))
570+
#if defined(PYOS_OS2) && defined(PYCC_VACPP)
571+
errno = EOS2ERR;
572+
#else
570573
errno = EISDIR;
574+
#endif
571575
else
572576
exists = 1;
573577
}

Python/importdl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ extern PyObject *_PyImport_LoadDynamicModule(char *name, char *pathname,
3838
typedef FARPROC dl_funcptr;
3939
#else
4040
#ifdef PYOS_OS2
41+
#include <os2def.h>
4142
typedef int (* APIENTRY dl_funcptr)();
4243
#else
4344
typedef void (*dl_funcptr)(void);

0 commit comments

Comments
 (0)