Kaydet (Commit) ab70e2ab authored tarafından Jesus Cea's avatar Jesus Cea

#16135: Removal of OS/2 support (posixmodule y platform dependent files)

üst f6c2e894
......@@ -22,15 +22,11 @@
#include <crtdbg.h>
#endif
#if (defined(PYOS_OS2) && !defined(PYCC_GCC)) || defined(MS_WINDOWS)
#if defined(MS_WINDOWS)
#define PYTHONHOMEHELP "<prefix>\\lib"
#else
#if defined(PYOS_OS2) && defined(PYCC_GCC)
#define PYTHONHOMEHELP "<prefix>/Lib"
#else
#define PYTHONHOMEHELP "<prefix>/pythonX.X"
#endif
#endif
#include "pygetopt.h"
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* -*- C -*- ***********************************************
Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
The Netherlands.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Stichting Mathematisch
Centrum or CWI or Corporation for National Research Initiatives or
CNRI not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
While CWI is the initial source for this software, a modified version
is made available by the Corporation for National Research Initiatives
(CNRI) at the Internet address ftp://ftp.python.org.
STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/* Module configuration */
/* This file contains the table of built-in modules.
See init_builtin() in import.c. */
#include "Python.h"
extern void initos2();
extern void initsignal();
#ifdef WITH_THREAD
extern void init_thread();
#endif
extern void init_codecs();
extern void init_csv();
extern void init_locale();
extern void init_random();
extern void init_sre();
extern void init_symtable();
extern void init_weakref();
extern void initarray();
extern void initbinascii();
extern void initcollections();
extern void initcmath();
extern void initdatetime();
extern void initdl();
extern void initerrno();
extern void initfcntl();
extern void init_functools();
extern void init_heapq();
extern void initimageop();
extern void inititertools();
extern void initmath();
extern void init_md5();
extern void initoperator();
extern void init_sha();
extern void init_sha256();
extern void init_sha512();
extern void init_struct();
extern void inittermios();
extern void inittime();
extern void initxxsubtype();
extern void initzipimport();
#if !HAVE_DYNAMIC_LOADING
extern void init_curses();
extern void init_curses_panel();
extern void init_testcapi();
extern void initbz2();
extern void initfpectl();
extern void initfpetest();
extern void initparser();
extern void initpwd();
extern void initunicodedata();
extern void initzlib();
#ifdef USE_SOCKET
extern void init_socket();
extern void initselect();
#endif
#endif
/* -- ADDMODULE MARKER 1 -- */
extern void PyMarshal_Init();
extern void initimp();
extern void initgc();
struct _inittab _PyImport_Inittab[] = {
{"os2", initos2},
{"signal", initsignal},
#ifdef WITH_THREAD
{"_thread", init_thread},
#endif
{"_codecs", init_codecs},
{"_csv", init_csv},
{"_locale", init_locale},
{"_random", init_random},
{"_sre", init_sre},
{"_symtable", init_symtable},
{"_weakref", init_weakref},
{"array", initarray},
{"binascii", initbinascii},
{"collections", initcollections},
{"cmath", initcmath},
{"datetime", initdatetime},
{"dl", initdl},
{"errno", initerrno},
{"fcntl", initfcntl},
{"_functools", init_functools},
{"_heapq", init_heapq},
{"imageop", initimageop},
{"itertools", inititertools},
{"math", initmath},
{"operator", initoperator},
{"_sha256", init_sha256},
{"_sha512", init_sha512},
{"_struct", init_struct},
{"termios", inittermios},
{"time", inittime},
{"xxsubtype", initxxsubtype},
{"zipimport", initzipimport},
#if !HAVE_DYNAMIC_LOADING
{"_curses", init_curses},
{"_curses_panel", init_curses_panel},
{"_testcapi", init_testcapi},
{"bz2", initbz2},
{"fpectl", initfpectl},
{"fpetest", initfpetest},
{"parser", initparser},
{"pwd", initpwd},
{"unicodedata", initunicodedata},
{"zlib", initzlib},
#ifdef USE_SOCKET
{"_socket", init_socket},
{"select", initselect},
#endif
#endif
/* -- ADDMODULE MARKER 2 -- */
/* This module "lives in" with marshal.c */
{"marshal", PyMarshal_Init},
/* This lives it with import.c */
{"_imp", initimp},
/* These entries are here for sys.builtin_module_names */
{"builtins", NULL},
{"sys", NULL},
/* This lives in gcmodule.c */
{"gc", initgc},
/* Sentinel */
{0, 0}
};
/* -*- C -*- ***********************************************
Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
The Netherlands.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Stichting Mathematisch
Centrum or CWI or Corporation for National Research Initiatives or
CNRI not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
While CWI is the initial source for this software, a modified version
is made available by the Corporation for National Research Initiatives
(CNRI) at the Internet address ftp://ftp.python.org.
STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/* This library implements dlopen() - Unix-like dynamic linking
* emulation functions for OS/2 using DosLoadModule() and company.
*/
#define INCL_DOS
#define INCL_DOSERRORS
#define INCL_DOSSESMGR
#define INCL_WINPROGRAMLIST
#define INCL_WINFRAMEMGR
#include <os2.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
typedef struct _track_rec {
char *name;
HMODULE handle;
void *id;
struct _track_rec *next;
} tDLLchain, *DLLchain;
static DLLchain dlload = NULL; /* A simple chained list of DLL names */
static char dlerr [256]; /* last error text string */
static void *last_id;
static DLLchain find_id(void *id)
{
DLLchain tmp;
for (tmp = dlload; tmp; tmp = tmp->next)
if (id == tmp->id)
return tmp;
return NULL;
}
/* load a dynamic-link library and return handle */
void *dlopen(char *filename, int flags)
{
HMODULE hm;
DLLchain tmp;
char err[256];
char *errtxt;
int rc = 0, set_chain = 0;
for (tmp = dlload; tmp; tmp = tmp->next)
if (strnicmp(tmp->name, filename, 999) == 0)
break;
if (!tmp)
{
tmp = (DLLchain) malloc(sizeof(tDLLchain));
if (!tmp)
goto nomem;
tmp->name = strdup(filename);
tmp->next = dlload;
set_chain = 1;
}
switch (rc = DosLoadModule((PSZ)&err, sizeof(err), filename, &hm))
{
case NO_ERROR:
tmp->handle = hm;
if (set_chain)
{
do
last_id++;
while ((last_id == 0) || (find_id(last_id)));
tmp->id = last_id;
dlload = tmp;
}
return tmp->id;
case ERROR_FILE_NOT_FOUND:
case ERROR_PATH_NOT_FOUND:
errtxt = "module `%s' not found";
break;
case ERROR_TOO_MANY_OPEN_FILES:
case ERROR_NOT_ENOUGH_MEMORY:
case ERROR_SHARING_BUFFER_EXCEEDED:
nomem:
errtxt = "out of system resources";
break;
case ERROR_ACCESS_DENIED:
errtxt = "access denied";
break;
case ERROR_BAD_FORMAT:
case ERROR_INVALID_SEGMENT_NUMBER:
case ERROR_INVALID_ORDINAL:
case ERROR_INVALID_MODULETYPE:
case ERROR_INVALID_EXE_SIGNATURE:
case ERROR_EXE_MARKED_INVALID:
case ERROR_ITERATED_DATA_EXCEEDS_64K:
case ERROR_INVALID_MINALLOCSIZE:
case ERROR_INVALID_SEGDPL:
case ERROR_AUTODATASEG_EXCEEDS_64K:
case ERROR_RELOCSRC_CHAIN_EXCEEDS_SEGLIMIT:
errtxt = "invalid module format";
break;
case ERROR_INVALID_NAME:
errtxt = "filename doesn't match module name";
break;
case ERROR_SHARING_VIOLATION:
case ERROR_LOCK_VIOLATION:
errtxt = "sharing violation";
break;
case ERROR_INIT_ROUTINE_FAILED:
errtxt = "module initialization failed";
break;
default:
errtxt = "cause `%s', error code = %d";
break;
}
snprintf(dlerr, sizeof(dlerr), errtxt, &err, rc);
if (tmp)
{
if (tmp->name)
free(tmp->name);
free(tmp);
}
return 0;
}
/* return a pointer to the `symbol' in DLL */
void *dlsym(void *handle, char *symbol)
{
int rc = 0;
PFN addr;
char *errtxt;
int symord = 0;
DLLchain tmp = find_id(handle);
if (!tmp)
goto inv_handle;
if (*symbol == '#')
symord = atoi(symbol + 1);
switch (rc = DosQueryProcAddr(tmp->handle, symord, symbol, &addr))
{
case NO_ERROR:
return (void *)addr;
case ERROR_INVALID_HANDLE:
inv_handle:
errtxt = "invalid module handle";
break;
case ERROR_PROC_NOT_FOUND:
case ERROR_INVALID_NAME:
errtxt = "no symbol `%s' in module";
break;
default:
errtxt = "symbol `%s', error code = %d";
break;
}
snprintf(dlerr, sizeof(dlerr), errtxt, symbol, rc);
return NULL;
}
/* free dynamically-linked library */
int dlclose(void *handle)
{
int rc;
DLLchain tmp = find_id(handle);
if (!tmp)
goto inv_handle;
switch (rc = DosFreeModule(tmp->handle))
{
case NO_ERROR:
free(tmp->name);
dlload = tmp->next;
free(tmp);
return 0;
case ERROR_INVALID_HANDLE:
inv_handle:
strcpy(dlerr, "invalid module handle");
return -1;
case ERROR_INVALID_ACCESS:
strcpy(dlerr, "access denied");
return -1;
default:
return -1;
}
}
/* return a string describing last occurred dl error */
char *dlerror()
{
return dlerr;
}
/* -*- C -*- ***********************************************
Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
The Netherlands.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Stichting Mathematisch
Centrum or CWI or Corporation for National Research Initiatives or
CNRI not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior
permission.
While CWI is the initial source for this software, a modified version
is made available by the Corporation for National Research Initiatives
(CNRI) at the Internet address ftp://ftp.python.org.
STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/* This library implements dlopen() - Unix-like dynamic linking
* emulation functions for OS/2 using DosLoadModule() and company.
*/
#ifndef _DLFCN_H
#define _DLFCN_H
/* load a dynamic-link library and return handle */
void *dlopen(char *filename, int flags);
/* return a pointer to the `symbol' in DLL */
void *dlsym(void *handle, char *symbol);
/* free dynamically-linked library */
int dlclose(void *handle);
/* return a string describing last occurred dl error */
char *dlerror(void);
#endif /* !_DLFCN_H */
/*
* This is the entry point for the Python 2.3 core DLL.
*/
#define NULL 0
#define REF(s) extern void s(); void *____ref_##s = &s;
/* Make references to imported symbols to pull them from static library */
REF(Py_Main);
#include <signal.h>
extern int _CRT_init(void);
extern void _CRT_term(void);
extern void __ctordtorInit(void);
extern void __ctordtorTerm(void);
unsigned long _DLL_InitTerm(unsigned long mod_handle, unsigned long flag)
{
switch (flag)
{
case 0:
if (_CRT_init())
return 0;
__ctordtorInit();
/* Ignore fatal signals */
signal(SIGSEGV, SIG_IGN);
signal(SIGFPE, SIG_IGN);
return 1;
case 1:
__ctordtorTerm();
_CRT_term();
return 1;
default:
return 0;
}
}
This diff is collapsed.
#ifndef Py_CONFIG_H
#define Py_CONFIG_H
#error "PEP 11: OS/2 is now unsupported, code will be removed in Python 3.4"
/* config.h.
* At some time in the past, generated automatically by/from configure.
* now maintained manually.
*/
/* build environment */
#define PLATFORM "os2emx"
#define COMPILER "[EMX GCC " __VERSION__ "]"
#define PYOS_OS2 1
#define PYCC_GCC 1
/* default location(s) */
#ifndef PREFIX
#define PREFIX ""
#endif
#ifndef PYTHONPATH
#define PYTHONPATH "./Lib;./Lib/plat-" PLATFORM \
";./Lib/lib-dynload;./Lib/site-packages"
#endif
/* Debugging */
#ifndef Py_DEBUG
/*#define Py_DEBUG 1*/
#endif
/* if building an extension or wrapper executable,
* mark Python API symbols "extern" so that symbols
* imported from the Python core DLL aren't duplicated.
*/
#ifdef Py_BUILD_CORE
# define PyAPI_FUNC(RTYPE) RTYPE
#else
# define PyAPI_FUNC(RTYPE) extern RTYPE
#endif
#define PyAPI_DATA(RTYPE) extern RTYPE
#define PyMODINIT_FUNC void
/* Use OS/2 flavour of threads */
#define WITH_THREAD 1
#define OS2_THREADS 1
/* We want sockets */
#define TCPIPV4 1
#define USE_SOCKET 1
#define socklen_t int
#define FD_SETSIZE 1024
/* enable the Python object allocator */
#define WITH_PYMALLOC 1
/* enable the GC module */
#define WITH_CYCLE_GC 1
/* Define if you want documentation strings in extension modules */
#define WITH_DOC_STRINGS 1
/* Unicode related */
#define PY_UNICODE_TYPE wchar_t
#define Py_UNICODE_SIZE SIZEOF_SHORT
/* EMX defines ssize_t */
#define HAVE_SSIZE_T 1
/* system capabilities */
#define HAVE_TTYNAME 1
#define HAVE_WAIT 1
#define HAVE_GETEGID 1
#define HAVE_GETEUID 1
#define HAVE_GETGID 1
#define HAVE_GETPPID 1
#define HAVE_GETUID 1
#define HAVE_OPENDIR 1
#define HAVE_PIPE 1
#define HAVE_POPEN 1
#define HAVE_SYSTEM 1
#define HAVE_TTYNAME 1
#define HAVE_DYNAMIC_LOADING 1
/* if port of GDBM installed, it includes NDBM emulation */
#define HAVE_NDBM_H 1
/* need this for spawnv code in posixmodule (cloned from WIN32 def'n) */
typedef long intptr_t;
/* we don't have tm_zone but do have the external array tzname */
#define HAVE_TZNAME 1
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Define this if you have the type long long. */
#define HAVE_LONG_LONG 1
/* Define if your compiler supports function prototypes. */
#define HAVE_PROTOTYPES 1
/* Define if your compiler supports variable length function prototypes
* (e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h>.
*/
#define HAVE_STDARG_PROTOTYPES 1
/* Define if malloc(0) returns a NULL pointer. */
#define MALLOC_ZERO_RETURNS_NULL 1
/* Define to force use of thread-safe errno, h_errno, and other functions. */
#define _REENTRANT 1
/* Define if you can safely include both <sys/select.h> and <sys/time.h>
* (which you can't on SCO ODT 3.0).
*/
#define SYS_SELECT_WITH_SYS_TIME 1
/* The number of bytes in an off_t. */
#define SIZEOF_OFF_T 4
/* The number of bytes in an time_t. */
#define SIZEOF_TIME_T 4
/* The number of bytes in a short. */
#define SIZEOF_SHORT 2
/* The number of bytes in a int. */
#define SIZEOF_INT 4
/* The number of bytes in a long. */
#define SIZEOF_LONG 4
/* The number of bytes in a long long. */
#define SIZEOF_LONG_LONG 8
/* The number of bytes in a void *. */
#define SIZEOF_VOID_P 4
/* The number of bytes in a size_t. */
#define SIZEOF_SIZE_T 4
/* Define if you have the alarm function. */
#define HAVE_ALARM 1
/* Define if you have the clock function. */
#define HAVE_CLOCK 1
/* Define if you have the dup2 function. */
#define HAVE_DUP2 1
/* Define if you have the execv function. */
#define HAVE_EXECV 1
/* Define if you have the spawnv function. */
#define HAVE_SPAWNV 1
/* Define if you have the flock function. */
#define HAVE_FLOCK 1
/* Define if you have the fork function. */
#define HAVE_FORK 1
/* Define if you have the fsync function. */
#define HAVE_FSYNC 1
/* Define if you have the ftime function. */
#define HAVE_FTIME 1
/* Define if you have the ftruncate function. */
#define HAVE_FTRUNCATE 1
/* Define if you have the getcwd function. */
#define HAVE_GETCWD 1
/* Define if you have the getpeername function. */
#define HAVE_GETPEERNAME 1
/* Define if you have the getpgrp function. */
#define HAVE_GETPGRP 1
/* Define if you have the getpid function. */
#define HAVE_GETPID 1
/* Define if you have the getpwent function. */
#define HAVE_GETPWENT 1
/* Define if you have the gettimeofday function. */
#define HAVE_GETTIMEOFDAY 1
/* Define if you have the getwd function. */
#define HAVE_GETWD 1
/* Define if you have the hypot function. */
#define HAVE_HYPOT 1
/* Define if you have the kill function. */
#define HAVE_KILL 1
/* Define if you have the memmove function. */
#define HAVE_MEMMOVE 1
/* Define if you have the mktime function. */
#define HAVE_MKTIME 1
/* Define if you have the pause function. */
#define HAVE_PAUSE 1
/* Define if you have the putenv function. */
#define HAVE_PUTENV 1
/* Define if you have the select function. */
#define HAVE_SELECT 1
/* Define if you have the setgid function. */
#define HAVE_SETGID 1
/* Define if you have the setlocale function. */
#define HAVE_SETLOCALE 1
/* Define if you have the setpgid function. */
#define HAVE_SETPGID 1
/* Define if you have the setuid function. */
#define HAVE_SETUID 1
/* Define if you have the setvbuf function. */
#define HAVE_SETVBUF 1
/* Define if you have the sigaction function. */
#define HAVE_SIGACTION 1
/* Define if you have the strerror function. */
#define HAVE_STRERROR 1
/* Define if you have the strftime function. */
#define HAVE_STRFTIME 1
/* Define if you have the tcgetpgrp function. */
#define HAVE_TCGETPGRP 1
/* Define if you have the tcsetpgrp function. */
#define HAVE_TCSETPGRP 1
/* Define if you have the tmpfile function. */
#define HAVE_TMPFILE 1
/* Define if you have the times function. */
#define HAVE_TIMES 1
/* Define if you have the truncate function. */
#define HAVE_TRUNCATE 1
/* Define if you have the uname function. */
#define HAVE_UNAME 1
/* Define if you have the waitpid function. */
#define HAVE_WAITPID 1
/* Define if you have the <conio.h> header file. */
#undef HAVE_CONIO_H
/* Define if you have the <direct.h> header file. */
#undef HAVE_DIRECT_H
/* Define if you have the <dirent.h> header file. */
#define HAVE_DIRENT_H 1
/* Define if you have the <errno.h> header file. */
#define HAVE_ERRNO_H 1
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define if you have the <io.h> header file. */
#undef HAVE_IO_H
/* Define if you have the <ncurses.h> header file. */
#define HAVE_NCURSES_H 1
/* Define to 1 if you have the <process.h> header file. */
#define HAVE_PROCESS_H 1
/* Define if you have the <signal.h> header file. */
#define HAVE_SIGNAL_H 1
/* Define if you have the <sys/file.h> header file. */
#define HAVE_SYS_FILE_H 1
/* Define if you have the <sys/param.h> header file. */
#define HAVE_SYS_PARAM_H 1
/* Define if you have the <sys/select.h> header file. */
#define HAVE_SYS_SELECT_H 1
/* Define if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define if you have the <sys/times.h> header file. */
#define HAVE_SYS_TIMES_H 1
/* Define if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define if you have the <sys/un.h> header file. */
#define HAVE_SYS_UN_H 1
/* Define if you have the <sys/utsname.h> header file. */
#define HAVE_SYS_UTSNAME_H 1
/* Define if you have the <sys/wait.h> header file. */
#define HAVE_SYS_WAIT_H 1
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define if you have the <utime.h> header file. */
#define HAVE_UTIME_H 1
/* EMX has an snprintf(). */
#define HAVE_SNPRINTF 1
#endif /* !Py_CONFIG_H */
This diff is collapsed.
/* OS/2 PM main program - creates a hidden window, and starts Python
* interpreter in a separate thread, so that Python scripts can be
* run in PM process space without a console Window. The interpreter
* is incorporated by linking in the Python DLL.
*
* As it stands, I don't think this is adequate for supporting Python
* GUI modules, as the Python thread doesn't have its own message
* queue - which is required of threads that want to create/use
* PM windows.
*
* This code owes a lot to "OS/2 Presentation Manager Programming", by
* Charles Petzold.
*
* Andrew MacIntyre <andymac@bullseye.apana.org.au>, August 2001.
* Released under the terms of the Python 2.1.1 licence - see the LICENCE
* file in the Python v2.1.1 (or later) source distribution.
* Copyright assigned to the Python Software Foundation, 2001.
*/
#define INCL_DOS
#define INCL_WIN
#include <os2.h>
#include <process.h>
#include "Python.h"
/* use structure to pass command line to Python thread */
typedef struct
{
int argc;
char **argv;
HWND Frame;
int running;
} arglist;
/* make this a global to simplify access.
* it should only be set from the Python thread, or by the code that
* initiates the Python thread when the thread cannot be created.
*/
int PythonRC;
extern DL_EXPORT(int) Py_Main(int, char **);
void PythonThread(void *);
int
main(int argc, char **argv)
{
ULONG FrameFlags = FCF_TITLEBAR |
FCF_SYSMENU |
FCF_SIZEBORDER |
FCF_HIDEBUTTON |
FCF_SHELLPOSITION |
FCF_TASKLIST;
HAB hab;
HMQ hmq;
HWND Client;
QMSG qmsg;
arglist args;
int python_tid;
/* init PM and create message queue */
hab = WinInitialize(0);
hmq = WinCreateMsgQueue(hab, 0);
/* create a (hidden) Window to house the window procedure */
args.Frame = WinCreateStdWindow(HWND_DESKTOP,
0,
&FrameFlags,
NULL,
"PythonPM",
0L,
0,
0,
&Client);
/* run Python interpreter in a thread */
args.argc = argc;
args.argv = argv;
args.running = 0;
if (-1 == (python_tid = _beginthread(PythonThread, NULL, 1024 * 1024, &args)))
{
/* couldn't start thread */
WinAlarm(HWND_DESKTOP, WA_ERROR);
PythonRC = 1;
}
else
{
/* process PM messages, until Python exits */
while (WinGetMsg(hab, &qmsg, NULLHANDLE, 0, 0))
WinDispatchMsg(hab, &qmsg);
if (args.running > 0)
DosKillThread(python_tid);
}
/* destroy window, shutdown message queue and PM */
WinDestroyWindow(args.Frame);
WinDestroyMsgQueue(hmq);
WinTerminate(hab);
return PythonRC;
}
void PythonThread(void *argl)
{
HAB hab;
arglist *args;
/* PM initialisation */
hab = WinInitialize(0);
/* start Python */
args = (arglist *)argl;
args->running = 1;
PythonRC = Py_Main(args->argc, args->argv);
/* enter a critical section and send the termination message */
DosEnterCritSec();
args->running = 0;
WinPostMsg(args->Frame, WM_QUIT, NULL, NULL);
/* shutdown PM and terminate thread */
WinTerminate(hab);
_endthread();
}
LIBRARY _TKINTER INITINSTANCE TERMINSTANCE
DESCRIPTION 'Python Extension DLL v1.0 for Access to Tcl/Tk Environment'
PROTMODE
DATA MULTIPLE NONSHARED
EXPORTS
init_tkinter
/* -*- C -*- ***********************************************
Copyright (c) 2000, BeOpen.com.
Copyright (c) 1995-2000, Corporation for National Research Initiatives.
Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
All rights reserved.
See the file "Misc/COPYRIGHT" for information on usage and
redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
******************************************************************/
/* Module configuration */
/* This file contains the table of built-in modules.
See init_builtin() in import.c. */
#include "Python.h"
extern void initarray(void);
extern void initaudioop(void);
extern void initbinascii(void);
extern void initcmath(void);
extern void initerrno(void);
extern void initimageop(void);
extern void initmath(void);
extern void initmd5(void);
extern void initnt(void);
extern void initos2(void);
extern void initoperator(void);
extern void initposix(void);
extern void initrgbimg(void);
extern void initsignal(void);
extern void initselect(void);
extern void init_socket(void);
extern void initstruct(void);
extern void inittime(void);
extern void init_thread(void);
extern void initpcre(void);
#ifdef WIN32
extern void initmsvcrt(void);
#endif
/* -- ADDMODULE MARKER 1 -- */
extern void PyMarshal_Init(void);
extern void initimp(void);
struct _inittab _PyImport_Inittab[] = {
{"array", initarray},
#ifdef M_I386
{"audioop", initaudioop},
#endif
{"binascii", initbinascii},
{"cmath", initcmath},
{"errno", initerrno},
// {"imageop", initimageop},
{"math", initmath},
{"md5", initmd5},
#if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__)
{"nt", initnt}, /* Use the NT os functions, not posix */
#else
#if defined(PYOS_OS2)
{"os2", initos2},
#else
{"posix", initposix},
#endif
#endif
{"operator", initoperator},
// {"rgbimg", initrgbimg},
{"signal", initsignal},
#ifdef USE_SOCKET
{"_socket", init_socket},
{"select", initselect},
#endif
{"struct", initstruct},
{"time", inittime},
#ifdef WITH_THREAD
{"_thread", init_thread},
#endif
{"pcre", initpcre},
#ifdef WIN32
{"msvcrt", initmsvcrt},
#endif
/* -- ADDMODULE MARKER 2 -- */
/* This module "lives in" with marshal.c */
{"marshal", PyMarshal_Init},
/* This lives it with import.c */
{"_imp", initimp},
/* These entries are here for sys.builtin_module_names */
{"builtins", NULL},
{"sys", NULL},
/* Sentinel */
{0, 0}
};
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
IBM VisualAge C/C++ for OS/2
============================
To build Python for OS/2, change into ./os2vacpp and issue an 'NMAKE'
command. This will build a PYTHON15.DLL containing the set of Python
modules listed in config.c and a small PYTHON.EXE to start the
interpreter.
By changing the C compiler flag /Gd- in the makefile to /Gd+, you can
reduce the size of these by causing Python to dynamically link to the
C runtime DLLs instead of including their bulk in your binaries.
However, this means that any system on which you run Python must have
the VAC++ compiler installed in order to have those DLLs available.
During the build process you may see a couple of harmless warnings:
From the C Compiler, "No function prototype given for XXX", which
comes from the use of K&R parameters within Python for portability.
From the ILIB librarian, "Module Not Found (XXX)", which comes
from its attempt to perform the (-+) operation, which removes and
then adds a .OBJ to the library. The first time a build is done,
it obviously cannot remove what is not yet built.
This build includes support for most Python functionality as well as
TCP/IP sockets. It omits the Posix ability to 'fork' a process but
supports threads using OS/2 native capabilities. I have tried to
support everything possible but here are a few usage notes.
-- os.popen() Usage Warnings
With respect to my implementation of popen() under OS/2:
import os
fd = os.popen("pkzip.exe -@ junk.zip", 'wb')
fd.write("file1.txt\n")
fd.write("file2.txt\n")
fd.write("file3.txt\n")
fd.write("\x1a") # Should Not Be Necessary But Is
fd.close()
There is a bug, either in the VAC++ compiler or OS/2 itself, where the
simple closure of the write-side of a pipe -to- a process does not
send an EOF to that process. I find I must explicitly write a
control-Z (EOF) before closing the pipe. This is not a problem when
using popen() in read mode.
One other slight difference with my popen() is that I return None
from the close(), instead of the Unix convention of the return code
of the spawned program. I could find no easy way to do this under
OS/2.
-- BEGINLIBPATH/ENDLIBPATH
With respect to environment variables, this OS/2 port supports the
special-to-OS/2 magic names of 'BEGINLIBPATH' and 'ENDLIBPATH' to
control where to load conventional DLLs from. Those names are
intercepted and converted to calls on the OS/2 kernel APIs and
are inherited by child processes, whether Python-based or not.
A few new attributes have been added to the os module:
os.meminstalled # Count of Bytes of RAM Installed on Machine
os.memkernel # Count of Bytes of RAM Reserved (Non-Swappable)
os.memvirtual # Count of Bytes of Virtual RAM Possible
os.timeslice # Duration of Scheduler Timeslice, in Milliseconds
os.maxpathlen # Maximum Length of a Path Specification, in chars
os.maxnamelen # Maximum Length of a Single Dir/File Name, in chars
os.version # Version of OS/2 Being Run e.g. "4.00"
os.revision # Revision of OS/2 Being Run (usually zero)
os.bootdrive # Drive that System Booted From e.g. "C:"
# (useful to find the CONFIG.SYS used to boot with)
-- Using Python as the Default OS/2 Batch Language
Note that OS/2 supports the Unix technique of putting the special
comment line at the time of scripts e.g. "#!/usr/bin/python" in
a different syntactic form. To do this, put your script into a file
with a .CMD extension and added 'extproc' to the top as follows:
extproc C:\Python\Python.exe -x
import os
print "Hello from Python"
The '-x' option tells Python to skip the first line of the file
while processing the rest as normal Python source.
-- Suggested Environment Variable Setup
With respect to the environment variables for Python, I use the
following setup:
Set PYTHONHOME=E:\Tau\Projects\Python;D:\DLLs
Set PYTHONPATH=.;E:\Tau\Projects\Python\Lib; \
E:\Tau\Projects\Python\Lib\plat-win
The EXEC_PREFIX (optional second pathspec on PYTHONHOME) is where
you put any Python extension DLLs you may create/obtain. There
are none provided with this release.
-- Contact Info
Jeff Rush is no longer supporting the VACPP port :-(
I don't have the VACPP compiler, so can't reliably maintain this port.
Anyone with VACPP who can contribute patches to keep this port buildable
should upload them to the Python Patch Manager at Sourceforge and
assign them to me for review/checkin.
Andrew MacIntyre
aimacintyre at users.sourceforge.net
August 18, 2002.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment