Skip to content

Commit 7bd379e

Browse files
demerphqrgs
authored andcommitted
Merge WinCE and Win32 directories -- Initial patch
Message-ID: <9b18b3110604271430k4de84685jec6535ded195ed94@mail.gmail.com> p4raw-id: //depot/perl@28003
1 parent ff235dd commit 7bd379e

File tree

9 files changed

+124
-11
lines changed

9 files changed

+124
-11
lines changed

win32/config_h.PL

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
BEGIN { warn "Running ".__FILE__."\n" };
33
BEGIN
44
{
5-
require "../lib/Config.pm";
6-
die "../Config.pm:$@" if $@;
5+
require "Config.pm";
6+
die "Config.pm:$@" if $@;
77
Config::->import;
88
}
99
use File::Compare qw(compare);
@@ -18,6 +18,7 @@ while (@ARGV && $ARGV[0] =~ /^([\w_]+)=(.*)$/)
1818
}
1919

2020
$opt{CONFIG_H} ||= 'config.h';
21+
$opt{CORE_DIR} ||= '../lib/CORE';
2122

2223
warn "Writing $opt{CONFIG_H}\n";
2324

@@ -76,9 +77,9 @@ close(H);
7677
close(SH);
7778

7879

79-
chmod(0666,"../lib/CORE/config.h");
80-
copy("$file.new","../lib/CORE/config.h") || die "Cannot copy:$!";
81-
chmod(0444,"../lib/CORE/config.h");
80+
chmod(0666,"$opt{CORE_DIR}/$opt{CONFIG_H}");
81+
copy("$file.new","$opt{CORE_DIR}/$opt{CONFIG_H}") || die "Cannot copy:$!";
82+
chmod(0444,"$opt{CORE_DIR}/$opt{CONFIG_H}");
8283

8384
if (compare("$file.new",$file))
8485
{

win32/dl_win32.xs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ dl_load_file(filename,flags=0)
119119
RETVAL = PerlProc_DynaLoad(filename);
120120
}
121121
else
122-
RETVAL = (void*) GetModuleHandle(NULL);
122+
RETVAL = (void*) Win_GetModuleHandle(NULL);
123123
DLDEBUG(2,PerlIO_printf(Perl_debug_log," libref=%x\n", RETVAL));
124124
ST(0) = sv_newmortal() ;
125125
if (RETVAL == NULL)

win32/include/sys/socket.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,50 @@
1010
extern "C" {
1111
#endif
1212

13+
#ifndef _WINCE
14+
1315
#define WIN32_LEAN_AND_MEAN
1416
#ifdef __GNUC__
1517
# define Win32_Winsock
1618
#endif
1719
#include <windows.h>
1820

21+
#else
22+
/*_WINCE*/
23+
#ifndef FAR
24+
#define FAR
25+
#endif
26+
27+
#define PASCAL __stdcall
28+
#define WINAPI __stdcall
29+
30+
#undef WORD
31+
typedef int BOOL;
32+
typedef unsigned short WORD;
33+
typedef void* HANDLE;
34+
typedef void* HWND;
35+
typedef int (FAR WINAPI *FARPROC)();
36+
37+
typedef unsigned long DWORD;
38+
typedef void *PVOID;
39+
40+
#define IN
41+
#define OUT
42+
43+
#ifndef UNDER_CE
44+
typedef struct _OVERLAPPED {
45+
DWORD Internal;
46+
DWORD InternalHigh;
47+
DWORD Offset;
48+
DWORD OffsetHigh;
49+
HANDLE hEvent;
50+
} OVERLAPPED, *LPOVERLAPPED;
51+
#endif
52+
53+
#undef HOST_NOT_FOUND
54+
55+
#endif /*_WINCE*/
56+
1957
/* Too late to include winsock2.h if winsock.h has already been loaded */
2058
#ifndef _WINSOCKAPI_
2159
# include <winsock2.h>

win32/makeico.pl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
binmode STDOUT;
1+
if (@ARGV) {
2+
open ICO, ">", shift or die $!;
3+
} else {
4+
*ICO= *STDOUT;
5+
}
6+
binmode ICO;
27
while (<DATA>) {
38
chomp;
4-
print pack "H*", $_;
9+
print ICO pack "H*", $_;
510
}
611

712
# Create new hex data with
@@ -98,3 +103,4 @@
98103
0000000000000000000000000000ffff9e5cfbb77420fd9b7865fd9b2074fd5b
99104
7320fd5b6e20fd137573f0017072e0036c65e0032077e4076e20e6076577c30f
100105
6720ff9f6520ffff6f6effff6e20
106+

win32/perlhost.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77
* License or the Artistic License, as specified in the README file.
88
*/
99

10+
#ifndef UNDER_CE
1011
#define CHECK_HOST_INTERP
12+
#endif
1113

1214
#ifndef ___PerlHost_H___
1315
#define ___PerlHost_H___
1416

17+
#ifndef UNDER_CE
1518
#include <signal.h>
19+
#endif
1620
#include "iperlsys.h"
1721
#include "vmem.h"
1822
#include "vdir.h"
@@ -823,6 +827,7 @@ PerlStdIOGetOSfhandle(struct IPerlStdIO* piPerl, int filenum)
823827
FILE*
824828
PerlStdIOFdupopen(struct IPerlStdIO* piPerl, FILE* pf)
825829
{
830+
#ifndef UNDER_CE
826831
FILE* pfdup;
827832
fpos_t pos;
828833
char mode[3];
@@ -870,6 +875,9 @@ PerlStdIOFdupopen(struct IPerlStdIO* piPerl, FILE* pf)
870875
fsetpos(pfdup, &pos);
871876
}
872877
return pfdup;
878+
#else
879+
return 0;
880+
#endif
873881
}
874882

875883
struct IPerlStdIO perlStdIO =
@@ -2132,6 +2140,10 @@ lookup(const void *arg1, const void *arg2)
21322140
LPSTR*
21332141
CPerlHost::Lookup(LPCSTR lpStr)
21342142
{
2143+
#ifdef UNDER_CE
2144+
if (!m_lppEnvList || !m_dwEnvCount)
2145+
return NULL;
2146+
#endif
21352147
if (!lpStr)
21362148
return NULL;
21372149
return (LPSTR*)bsearch(&lpStr, m_lppEnvList, m_dwEnvCount, sizeof(LPSTR), lookup);

win32/perllib.c

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ xs_init(pTHX)
4040

4141
#ifdef PERL_IMPLICIT_SYS
4242

43+
/* WINCE: include replaced by:
44+
extern "C" void win32_checkTLS(PerlInterpreter *host_perl);
45+
*/
4346
#include "perlhost.h"
4447

4548
void
@@ -48,11 +51,45 @@ win32_checkTLS(PerlInterpreter *host_perl)
4851
dTHX;
4952
if (host_perl != my_perl) {
5053
int *nowhere = NULL;
51-
*nowhere = 0;
54+
#ifdef _WIN_CE
55+
printf(" ... bad in win32_checkTLS\n");
56+
printf(" %08X ne %08X\n",host_perl,my_perl);
57+
#endif
5258
abort();
5359
}
5460
}
5561

62+
#ifdef UNDER_CE
63+
int GetLogicalDrives() {
64+
return 0; /* no logical drives on CE */
65+
}
66+
int GetLogicalDriveStrings(int size, char addr[]) {
67+
return 0; /* no logical drives on CE */
68+
}
69+
/* TBD */
70+
DWORD GetFullPathNameA(LPCSTR fn, DWORD blen, LPTSTR buf, LPSTR *pfile) {
71+
return 0;
72+
}
73+
/* TBD */
74+
DWORD GetFullPathNameW(CONST WCHAR *fn, DWORD blen, WCHAR * buf, WCHAR **pfile) {
75+
return 0;
76+
}
77+
/* TBD */
78+
DWORD SetCurrentDirectoryA(LPSTR pPath) {
79+
return 0;
80+
}
81+
/* TBD */
82+
DWORD SetCurrentDirectoryW(CONST WCHAR *pPath) {
83+
return 0;
84+
}
85+
int xcesetuid(uid_t id){return 0;}
86+
int xceseteuid(uid_t id){ return 0;}
87+
int xcegetuid() {return 0;}
88+
int xcegeteuid(){ return 0;}
89+
#endif
90+
91+
/* WINCE??: include "perlhost.h" */
92+
5693
EXTERN_C void
5794
perl_get_host_info(struct IPerlMemInfo* perlMemInfo,
5895
struct IPerlMemInfo* perlMemSharedInfo,
@@ -177,7 +214,7 @@ RunPerl(int argc, char **argv, char **env)
177214
* Borland's CRT does the right thing to argv[0] already. */
178215
char szModuleName[MAX_PATH];
179216

180-
GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
217+
Win_GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
181218
(void)win32_longpath(szModuleName);
182219
argv[0] = szModuleName;
183220
#endif
@@ -254,7 +291,11 @@ DllMain(HANDLE hModule, /* DLL module handle */
254291
setmode( fileno( stderr ), O_BINARY );
255292
_fmode = O_BINARY;
256293
#endif
294+
295+
#ifndef UNDER_CE
257296
DisableThreadLibraryCalls((HMODULE)hModule);
297+
#endif
298+
258299
w32_perldll_handle = hModule;
259300
set_w32_module_name();
260301
break;
@@ -290,6 +331,7 @@ DllMain(HANDLE hModule, /* DLL module handle */
290331
return TRUE;
291332
}
292333

334+
293335
#if defined(USE_ITHREADS) && defined(PERL_IMPLICIT_SYS)
294336
EXTERN_C PerlInterpreter *
295337
perl_clone_host(PerlInterpreter* proto_perl, UV flags) {

win32/vdir.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void VDir::Init(VDir* pDir, VMem *p)
150150
bManageDirectory = 0;
151151
driveBits = GetLogicalDrives();
152152
if (GetLogicalDriveStrings(sizeof(szBuffer), szBuffer)) {
153-
char* pEnv = GetEnvironmentStrings();
153+
char* pEnv = (char*)GetEnvironmentStrings();
154154
char* ptr = szBuffer;
155155
for (index = 0; index < driveCount; ++index) {
156156
if (driveBits & (1<<index)) {

win32/vmem.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
#ifndef ___VMEM_H_INC___
2222
#define ___VMEM_H_INC___
2323

24+
#ifndef _WIN_CE
2425
#define _USE_MSVCRT_MEM_ALLOC
26+
#endif
2527
#define _USE_LINKED_LIST
2628

2729
// #define _USE_BUDDY_BLOCKS

win32/win32.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,5 +563,17 @@ EXTERN_C _CRTIMP ioinfo* __pioinfo[];
563563
DllExport void *win32_signal_context(void);
564564
#define PERL_GET_SIG_CONTEXT win32_signal_context()
565565

566+
#ifdef _WIN_CE
567+
#define Win_GetModuleHandle XCEGetModuleHandleA
568+
#define Win_GetProcAddress XCEGetProcAddressA
569+
#define Win_GetModuleFileName XCEGetModuleFileNameA
570+
#define Win_CreateSemaphore CreateSemaphoreW
571+
#else
572+
#define Win_GetModuleHandle GetModuleHandle
573+
#define Win_GetProcAddress GetProcAddress
574+
#define Win_GetModuleFileName GetModuleFileName
575+
#define Win_CreateSemaphore CreateSemaphore
576+
#endif
577+
566578
#endif /* _INC_WIN32_PERL5 */
567579

0 commit comments

Comments
 (0)