Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0c83348d
Commit
0c83348d
authored
Apr 22, 2003
by
Andrew MacIntyre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor cleanups and whitespace normalisation
parent
699cbb76
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
81 deletions
+82
-81
PC/os2emx/dlfcn.c
PC/os2emx/dlfcn.c
+37
-38
PC/os2emx/dlfcn.h
PC/os2emx/dlfcn.h
+9
-8
PC/os2emx/dllentry.c
PC/os2emx/dllentry.c
+16
-17
PC/os2emx/getpathp.c
PC/os2emx/getpathp.c
+20
-18
No files found.
PC/os2emx/dlfcn.c
View file @
0c83348d
...
...
@@ -29,10 +29,9 @@ PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/*
This library implements dlopen() - functions for OS/2 using
DosLoadModule() and company.
*/
/* This library implements dlopen() - Unix-like dynamic linking
* emulation functions for OS/2 using DosLoadModule() and company.
*/
#define INCL_DOS
#define INCL_DOSERRORS
...
...
@@ -46,8 +45,6 @@ PERFORMANCE OF THIS SOFTWARE.
#include <string.h>
#include <malloc.h>
/*-------------------------------------- Unix-like dynamic linking emulation -*/
typedef
struct
_track_rec
{
char
*
name
;
HMODULE
handle
;
...
...
@@ -55,8 +52,8 @@ typedef struct _track_rec {
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
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
)
...
...
@@ -65,13 +62,13 @@ static DLLchain find_id(void *id)
for
(
tmp
=
dlload
;
tmp
;
tmp
=
tmp
->
next
)
if
(
id
==
tmp
->
id
)
return
(
tmp
)
;
return
tmp
;
return
(
NULL
)
;
return
NULL
;
}
/* load a dynamic-link library and return handle */
void
*
dlopen
(
char
*
filename
,
int
flags
)
void
*
dlopen
(
char
*
filename
,
int
flags
)
{
HMODULE
hm
;
DLLchain
tmp
;
...
...
@@ -85,10 +82,10 @@ void *dlopen (char *filename, int flags)
if
(
!
tmp
)
{
tmp
=
(
DLLchain
)
malloc
(
sizeof
(
tDLLchain
));
tmp
=
(
DLLchain
)
malloc
(
sizeof
(
tDLLchain
));
if
(
!
tmp
)
goto
nomem
;
tmp
->
name
=
strdup
(
filename
);
tmp
->
name
=
strdup
(
filename
);
tmp
->
next
=
dlload
;
set_chain
=
1
;
}
...
...
@@ -97,14 +94,15 @@ void *dlopen (char *filename, int flags)
{
case
NO_ERROR
:
tmp
->
handle
=
hm
;
if
(
set_chain
)
{
do
{
if
(
set_chain
)
{
do
last_id
++
;
}
while
((
last_id
==
0
)
||
(
find_id
(
last_id
)));
while
((
last_id
==
0
)
||
(
find_id
(
last_id
)));
tmp
->
id
=
last_id
;
dlload
=
tmp
;
}
return
(
tmp
->
id
)
;
return
tmp
->
id
;
case
ERROR_FILE_NOT_FOUND
:
case
ERROR_PATH_NOT_FOUND
:
errtxt
=
"module `%s' not found"
;
...
...
@@ -145,34 +143,35 @@ nomem:
errtxt
=
"cause `%s', error code = %d"
;
break
;
}
snprintf
(
dlerr
,
sizeof
(
dlerr
),
errtxt
,
&
err
,
rc
);
if
(
tmp
)
{
snprintf
(
dlerr
,
sizeof
(
dlerr
),
errtxt
,
&
err
,
rc
);
if
(
tmp
)
{
if
(
tmp
->
name
)
free
(
tmp
->
name
);
free
(
tmp
);
free
(
tmp
);
}
return
(
0
)
;
return
0
;
}
/* return a pointer to the `symbol' in DLL */
void
*
dlsym
(
void
*
handle
,
char
*
symbol
)
void
*
dlsym
(
void
*
handle
,
char
*
symbol
)
{
int
rc
=
0
;
PFN
addr
;
char
*
errtxt
;
int
symord
=
0
;
DLLchain
tmp
=
find_id
(
handle
);
DLLchain
tmp
=
find_id
(
handle
);
if
(
!
tmp
)
goto
inv_handle
;
if
(
*
symbol
==
'#'
)
symord
=
atoi
(
symbol
+
1
);
symord
=
atoi
(
symbol
+
1
);
switch
(
rc
=
DosQueryProcAddr
(
tmp
->
handle
,
symord
,
symbol
,
&
addr
))
{
case
NO_ERROR
:
return
(
(
void
*
)
addr
)
;
return
(
void
*
)
addr
;
case
ERROR_INVALID_HANDLE
:
inv_handle:
errtxt
=
"invalid module handle"
;
...
...
@@ -185,40 +184,40 @@ inv_handle:
errtxt
=
"symbol `%s', error code = %d"
;
break
;
}
snprintf
(
dlerr
,
sizeof
(
dlerr
),
errtxt
,
symbol
,
rc
);
return
(
NULL
)
;
snprintf
(
dlerr
,
sizeof
(
dlerr
),
errtxt
,
symbol
,
rc
);
return
NULL
;
}
/* free dynamicaly-linked library */
int
dlclose
(
void
*
handle
)
int
dlclose
(
void
*
handle
)
{
int
rc
;
DLLchain
tmp
=
find_id
(
handle
);
DLLchain
tmp
=
find_id
(
handle
);
if
(
!
tmp
)
goto
inv_handle
;
switch
(
rc
=
DosFreeModule
(
tmp
->
handle
))
switch
(
rc
=
DosFreeModule
(
tmp
->
handle
))
{
case
NO_ERROR
:
free
(
tmp
->
name
);
free
(
tmp
->
name
);
dlload
=
tmp
->
next
;
free
(
tmp
);
return
(
0
)
;
free
(
tmp
);
return
0
;
case
ERROR_INVALID_HANDLE
:
inv_handle:
strcpy
(
dlerr
,
"invalid module handle"
);
return
(
-
1
)
;
return
-
1
;
case
ERROR_INVALID_ACCESS
:
strcpy
(
dlerr
,
"access denied"
);
return
(
-
1
)
;
strcpy
(
dlerr
,
"access denied"
);
return
-
1
;
default:
return
(
-
1
)
;
return
-
1
;
}
}
/* return a string describing last occured dl error */
char
*
dlerror
()
{
return
(
dlerr
)
;
return
dlerr
;
}
PC/os2emx/dlfcn.h
View file @
0c83348d
...
...
@@ -29,21 +29,22 @@ PERFORMANCE OF THIS SOFTWARE.
******************************************************************/
/*
This library implements dlopen() - functions for OS/2 using
DosLoadModule() and company.
*/
/* This library implements dlopen() - Unix-like dynamic linking
* emulation functions for OS/2 using DosLoadModule() and company.
*/
#ifndef _DLFCN_H
#define _DLFCN_H
/*-------------------------------------- Unix-like dynamic linking emulation -*/
/* load a dynamic-link library and return handle */
void
*
dlopen
(
char
*
filename
,
int
flags
);
void
*
dlopen
(
char
*
filename
,
int
flags
);
/* return a pointer to the `symbol' in DLL */
void
*
dlsym
(
void
*
handle
,
char
*
symbol
);
void
*
dlsym
(
void
*
handle
,
char
*
symbol
);
/* free dynamicaly-linked library */
int
dlclose
(
void
*
handle
);
int
dlclose
(
void
*
handle
);
/* return a string describing last occured dl error */
char
*
dlerror
(
void
);
...
...
PC/os2emx/dllentry.c
View file @
0c83348d
/*
This is the entry point for Python DLL(s).
It also provides an getenv() function that works from within DLLs.
*/
* This is the entry point for the Python 2.3 core DLL.
*/
#define NULL 0
/* Make references to imported symbols to pull them from static library */
#define REF(s) extern void s (); void *____ref_##s = &s;
#define REF(s) extern void s(); void *____ref_##s = &s;
REF
(
Py_Main
);
/* 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
);
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
)
unsigned
long
_DLL_InitTerm
(
unsigned
long
mod_handle
,
unsigned
long
flag
)
{
switch
(
flag
)
{
case
0
:
if
(
_CRT_init
())
if
(
_CRT_init
())
return
0
;
__ctordtorInit
();
__ctordtorInit
();
/* Ignore fatal signals */
signal
(
SIGSEGV
,
SIG_IGN
);
signal
(
SIGFPE
,
SIG_IGN
);
signal
(
SIGSEGV
,
SIG_IGN
);
signal
(
SIGFPE
,
SIG_IGN
);
return
1
;
case
1
:
__ctordtorTerm
();
_CRT_term
();
__ctordtorTerm
();
_CRT_term
();
return
1
;
default:
...
...
PC/os2emx/getpathp.c
View file @
0c83348d
...
...
@@ -94,9 +94,9 @@ is_sep(char ch) /* determine if "ch" is a separator character */
#endif
}
/* assumes 'dir' null terminated in bounds.
Never writes
beyond existing terminator.
*/
/* assumes 'dir' null terminated in bounds.
* Never writes
beyond existing terminator.
*/
static
void
reduce
(
char
*
dir
)
{
...
...
@@ -113,11 +113,12 @@ exists(char *filename)
return
stat
(
filename
,
&
buf
)
==
0
;
}
/* Assumes 'filename' MAXPATHLEN+1 bytes long -
may extend 'filename' by one character.
*/
/* Is module (check for .pyc/.pyo too)
* Assumes 'filename' MAXPATHLEN+1 bytes long -
* may extend 'filename' by one character.
*/
static
int
ismodule
(
char
*
filename
)
/* Is module -- check for .pyc/.pyo too */
ismodule
(
char
*
filename
)
{
if
(
exists
(
filename
))
return
1
;
...
...
@@ -151,9 +152,9 @@ join(char *buffer, char *stuff)
}
/* gotlandmark only called by search_for_prefix, which ensures
'prefix' is null terminated in bounds. join() ensures
'landmark' can not overflow prefix if too long.
*/
*
'prefix' is null terminated in bounds. join() ensures
*
'landmark' can not overflow prefix if too long.
*/
static
int
gotlandmark
(
char
*
landmark
)
{
...
...
@@ -167,7 +168,8 @@ gotlandmark(char *landmark)
}
/* assumes argv0_path is MAXPATHLEN+1 bytes long, already \0 term'd.
assumption provided by only caller, calculate_path() */
* assumption provided by only caller, calculate_path()
*/
static
int
search_for_prefix
(
char
*
argv0_path
,
char
*
landmark
)
{
...
...
@@ -283,13 +285,13 @@ calculate_path(void)
}
/* We need to construct a path from the following parts.
(1) the PYTHONPATH environment variable, if set;
(2) the zip archive file path;
(3) the PYTHONPATH config macro, with the leading "."
of each component replaced with pythonhome, if set;
(4) the directory containing the executable (argv0_path).
The length calculation calculates #3 first.
*/
*
(1) the PYTHONPATH environment variable, if set;
*
(2) the zip archive file path;
*
(3) the PYTHONPATH config macro, with the leading "."
*
of each component replaced with pythonhome, if set;
*
(4) the directory containing the executable (argv0_path).
*
The length calculation calculates #3 first.
*/
/* Calculate size of return buffer */
if
(
pythonhome
!=
NULL
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment