Skip to content

Commit 1beef44

Browse files
committed
version 0.76_01
see Changes
1 parent ad198bc commit 1beef44

27 files changed

+1146
-447
lines changed

.gitignore

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
*.bs
22
*.c
3-
*.xsc
43
*.def
4+
*.i
5+
*.o
56
*.obj
7+
*.pdb
8+
*.xsc
69
Makefile
710
Makefile.old
811
blib
912
pm_to_blib
10-
vc90.pdb
1113
MANIFEST.bak
1214
Win32-API-*.tar.gz
1315
MYMETA.*

API.h

+86-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#define NEED_sv_2pv_flags
12+
#define NEED_newSVpvn_share
1213
#include "ppport.h"
1314

1415
/* see https://rt.cpan.org/Ticket/Display.html?id=80217
@@ -20,6 +21,10 @@
2021
# define _alloca(size) __builtin_alloca(size)
2122
#endif
2223

24+
/* old (5.8 ish) strawberry perls/Mingws somehow dont ever include malloc.h from
25+
perl.h, so this include is needed for alloca */
26+
#include <malloc.h>
27+
2328
/* some Mingw GCCs use Static TLS on all DLLs, DisableThreadLibraryCalls fails
2429
if DLL has Static TLS, todo, figure out how to disable Static TLS on Mingw
2530
Win32::API never uses it, also Win32::API never uses C++ish exception handling
@@ -44,6 +49,53 @@
4449

4550
// #define WIN32_API_DEBUG
4651

52+
#ifdef WIN32_API_DEBUG
53+
# define WIN32_API_DEBUGM(x) x
54+
#else
55+
# define WIN32_API_DEBUGM(x)
56+
#endif
57+
58+
59+
/* turns on profiling, use only for benchmark.t, DO NOT ENABLE in CPAN RELEASE
60+
not all return paths in Call() get the current time (incomplete
61+
implementation), VC only
62+
*/
63+
//#define WIN32_API_PROF
64+
65+
#ifdef WIN32_API_PROF
66+
# define WIN32_API_PROFF(x) x
67+
#else
68+
# define WIN32_API_PROFF(x)
69+
#endif
70+
71+
#ifdef WIN32_API_PROF
72+
LARGE_INTEGER my_freq = {0};
73+
LARGE_INTEGER start = {0};
74+
LARGE_INTEGER loopstart = {0};
75+
LARGE_INTEGER Call_asm_b4 = {0};
76+
LARGE_INTEGER Call_asm_after = {0};
77+
LARGE_INTEGER return_time = {0};
78+
LARGE_INTEGER return_time2 = {0};
79+
# ifndef WIN64
80+
__declspec( naked ) unsigned __int64 rdtsc () {
81+
__asm
82+
{
83+
mov eax, 80000000h
84+
push ebx
85+
cpuid
86+
_emit 0xf
87+
_emit 0x31
88+
pop ebx
89+
retn
90+
}
91+
}
92+
/* note: not CPU affinity locked on x86, visually discard high time iternations */
93+
# define W32A_Prof_GT(x) ((x)->QuadPart = rdtsc())
94+
# else
95+
# define W32A_Prof_GT(x) (QueryPerformanceCounter(x))
96+
# endif
97+
#endif
98+
4799
#ifdef _WIN64
48100
typedef unsigned long long long_ptr;
49101
#else
@@ -104,6 +156,22 @@ union {
104156
unsigned char t; //1 bytes, union is 8 bytes, put last to avoid padding
105157
} APIPARAM;
106158

159+
/* a version of APIPARAM without a "t" type member */
160+
typedef struct {
161+
union {
162+
LPBYTE b;
163+
char c;
164+
short s;
165+
char *p;
166+
long_ptr l; // 4 bytes on 32bit; 8 bytes on 64bbit; not sure if it is correct
167+
float f;
168+
double d;
169+
#ifdef T_QUAD
170+
__int64 q;
171+
#endif
172+
};
173+
} APIPARAM_U;
174+
107175
typedef struct {
108176
SV* object;
109177
int size;
@@ -114,9 +182,21 @@ typedef struct {
114182
} APICALLBACK;
115183

116184
#define STATIC_ASSERT(expr) ((void)sizeof(char[1 - 2*!!!(expr)]))
185+
/*
186+
because of unknown alignment where the sentinal is placed after the PV
187+
buffer, put 2 wide nulls, some permutation will be 1 aligned wide null char
117188
118-
//because of unknown alignment, put 2 wide nulls,
119-
//some permutation will be 1 wide null char
189+
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28679 bug on Strawberry Perl
190+
5.8.9 which includes "gcc (GCC) 3.4.5 (mingw-vista special r3)", reported as
191+
192+
In file included from API.c:28:
193+
API.h:122: warning: malformed '#pragma pack(push[, id], <n>)' - ignored
194+
API.h:130: warning: #pragma pack (pop) encountered without matching #pragma pack
195+
(push, <n>)
196+
197+
This causes 4 extra unused padding bytes to be placed after null2, which can
198+
be a performance degradation
199+
*/
120200
#pragma pack(push)
121201
#pragma pack(push, 1)
122202
typedef struct {
@@ -183,7 +263,6 @@ S_croak_xs_usage(pTHX_ const CV *const cv, const char *const params)
183263
Perl_croak_nocontext("Usage: CODE(0x%"UVxf")(%s)", PTR2UV(cv), params);
184264
}
185265
}
186-
#undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
187266

188267
#ifdef PERL_IMPLICIT_CONTEXT
189268
#define croak_xs_usage(a,b) S_croak_xs_usage(aTHX_ a,b)
@@ -192,3 +271,7 @@ S_croak_xs_usage(pTHX_ const CV *const cv, const char *const params)
192271
#endif
193272

194273
#endif
274+
275+
#define PERL_VERSION_LE(R, V, S) (PERL_REVISION < (R) || \
276+
(PERL_REVISION == (R) && (PERL_VERSION < (V) ||\
277+
(PERL_VERSION == (V) && (PERL_SUBVERSION <= (S))))))

0 commit comments

Comments
 (0)