Skip to content

Commit 392a251

Browse files
committed
Fix redefinition of typedef 'ULONG_PTR'
closes hercules-390#245
1 parent d8c93bf commit 392a251

File tree

5 files changed

+29
-23
lines changed

5 files changed

+29
-23
lines changed

htypes.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ typedef uint8_t QWORD[16]; // unsigned quadword (16 bytes)
119119
#define BOOL int // (same as Windows)
120120
#endif
121121

122+
#if defined( _MSVC_ ) // (some code needs the following)
123+
#if defined( _WIN64 )
124+
typedef unsigned __int64 U_LONG_PTR; // name unique to Hercules
125+
#else // 32-bit x86
126+
typedef unsigned __int32 U_LONG_PTR; // name unique to Hercules
127+
#endif
128+
#else // Linux, etc
129+
typedef unsigned long U_LONG_PTR; // name unique to Hercules
130+
#endif
131+
122132
/*-------------------------------------------------------------------*/
123133
/* Socket stuff */
124134
/*-------------------------------------------------------------------*/

tcpip.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
#include "tcpip.h"
5555

56-
static u_int find_slot ( ULONG_PTR address ) {
56+
static u_int find_slot ( U_LONG_PTR address ) {
5757
u_int i;
5858
i = 0;
5959
obtain_lock (&tcpip_lock);
@@ -496,7 +496,7 @@ static void EZASOKET (u_int func, int aux1, int aux2, talk_ptr t) {
496496

497497
t->len_out = sizeof (Clocal_adx);
498498
t->buffer_out = (char *)malloc (t->len_out);
499-
t->buffer_out_slot = find_slot ((ULONG_PTR)&(t->buffer_out [0]));
499+
t->buffer_out_slot = find_slot ((U_LONG_PTR)&(t->buffer_out [0]));
500500
memcpy (t->buffer_out, &Slocal_adx, t->len_out);
501501
((SOCKADDR_IN *)(t->buffer_out))->sin_family = htons (((SOCKADDR_IN *)(t->buffer_out))->sin_family);
502502

@@ -540,7 +540,7 @@ static void EZASOKET (u_int func, int aux1, int aux2, talk_ptr t) {
540540
}
541541

542542
t->buffer_out = (char *)malloc (aux2);
543-
t->buffer_out_slot = find_slot ((ULONG_PTR)&(t->buffer_out [0]));
543+
t->buffer_out_slot = find_slot ((U_LONG_PTR)&(t->buffer_out [0]));
544544

545545
if ((size = recv (Ccom_han [aux1], t->buffer_out, aux2, 0)) == SOCKET_ERROR) { /* receive command */
546546

@@ -578,7 +578,7 @@ static void EZASOKET (u_int func, int aux1, int aux2, talk_ptr t) {
578578

579579
t->len_out = t->len_in;
580580
t->buffer_out = (char *)malloc (t->len_out);
581-
t->buffer_out_slot = find_slot ((ULONG_PTR)&(t->buffer_out [0]));
581+
t->buffer_out_slot = find_slot ((U_LONG_PTR)&(t->buffer_out [0]));
582582

583583
m = t->len_out;
584584
i = 0;
@@ -595,7 +595,7 @@ static void EZASOKET (u_int func, int aux1, int aux2, talk_ptr t) {
595595

596596
t->len_out = t->len_in;
597597
t->buffer_out = (char *)malloc (t->len_out);
598-
t->buffer_out_slot = find_slot ((ULONG_PTR)&(t->buffer_out [0]));
598+
t->buffer_out_slot = find_slot ((U_LONG_PTR)&(t->buffer_out [0]));
599599

600600
m = t->len_out;
601601
i = 0;
@@ -641,7 +641,7 @@ static void EZASOKET (u_int func, int aux1, int aux2, talk_ptr t) {
641641

642642
t->len_out = sizeof (Clocal_adx);
643643
t->buffer_out = (char *)malloc (t->len_out);
644-
t->buffer_out_slot = find_slot ((ULONG_PTR)&(t->buffer_out [0]));
644+
t->buffer_out_slot = find_slot ((U_LONG_PTR)&(t->buffer_out [0]));
645645

646646
isock = t->len_out;
647647
t->ret_cd = getsockname (Ccom_han [aux1], (struct sockaddr *)(t->buffer_out), &isock);
@@ -799,7 +799,7 @@ static void EZASOKET (u_int func, int aux1, int aux2, talk_ptr t) {
799799

800800
t->len_out = Cselect [m]->len;
801801
t->buffer_out = (char *)malloc (t->len_out);
802-
t->buffer_out_slot = find_slot ((ULONG_PTR)&(t->buffer_out [0]));
802+
t->buffer_out_slot = find_slot ((U_LONG_PTR)&(t->buffer_out [0]));
803803
memset (t->buffer_out, 0, t->len_out);
804804

805805
i = 0;
@@ -824,7 +824,7 @@ static void EZASOKET (u_int func, int aux1, int aux2, talk_ptr t) {
824824

825825
t->len_out = Cselect [m]->len;
826826
t->buffer_out = (char *)malloc (t->len_out);
827-
t->buffer_out_slot = find_slot ((ULONG_PTR)&(t->buffer_out [0]));
827+
t->buffer_out_slot = find_slot ((U_LONG_PTR)&(t->buffer_out [0]));
828828
memset (t->buffer_out, 0, t->len_out);
829829

830830
i = 0;
@@ -849,7 +849,7 @@ static void EZASOKET (u_int func, int aux1, int aux2, talk_ptr t) {
849849

850850
t->len_out = Cselect [m]->len;
851851
t->buffer_out = (char *)malloc (t->len_out);
852-
t->buffer_out_slot = find_slot ((ULONG_PTR)&(t->buffer_out [0]));
852+
t->buffer_out_slot = find_slot ((U_LONG_PTR)&(t->buffer_out [0]));
853853
memset (t->buffer_out, 0, t->len_out);
854854

855855
i = 0;
@@ -915,7 +915,7 @@ static void EZASOKET (u_int func, int aux1, int aux2, talk_ptr t) {
915915

916916
t->len_out = t->ret_cd;
917917
t->buffer_out = (char *) malloc (t->len_out);
918-
t->buffer_out_slot = find_slot ((ULONG_PTR)&(t->buffer_out [0]));
918+
t->buffer_out_slot = find_slot ((U_LONG_PTR)&(t->buffer_out [0]));
919919

920920
m = t->ret_cd;
921921
i = 0;
@@ -934,7 +934,7 @@ static void EZASOKET (u_int func, int aux1, int aux2, talk_ptr t) {
934934

935935
t->len_out = sizeof (Clocal_adx);
936936
t->buffer_out = (char *) malloc (t->len_out);
937-
t->buffer_out_slot = find_slot ((ULONG_PTR)&(t->buffer_out [0]));
937+
t->buffer_out_slot = find_slot ((U_LONG_PTR)&(t->buffer_out [0]));
938938

939939
isock = t->len_out;
940940
t->ret_cd = getpeername (Ccom_han [aux1], (struct sockaddr *)(t->buffer_out), &isock);
@@ -982,11 +982,11 @@ u_int lar_tcpip (u_int * regs) {
982982
if (get_reg (regs, 3) == 0) { /* Alloc memory for this communication. */
983983

984984
t = (talk_ptr)malloc (sizeof (talk));
985-
t->slot = find_slot ((ULONG_PTR)t);
985+
t->slot = find_slot ((U_LONG_PTR)t);
986986

987987
t->len_in = get_reg (regs, 1);
988988
t->buffer_in = (char *)malloc (t->len_in + 1);
989-
t->buffer_in_slot = find_slot ((ULONG_PTR)&(t->buffer_in [0]));
989+
t->buffer_in_slot = find_slot ((U_LONG_PTR)&(t->buffer_in [0]));
990990
t->buffer_in [t->len_in] = 0; /* NULL Terminator */
991991

992992
t->len_out = 0;

tcpip.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55

66
#define Ccom 1024 /* maximum number of concurrent connections + 1 */
77

8-
#ifndef _MSVC_
9-
typedef unsigned long ULONG_PTR;
10-
#endif
11-
128
#if !defined( _X75_C_ )
139
#ifndef _MSVC_
1410

@@ -284,5 +280,5 @@ static LOCK tcpip_lock;
284280

285281
static u_int tcpip_init_req = 1;
286282

287-
ULONG_PTR map32[Ccom];
283+
U_LONG_PTR map32[Ccom];
288284
#endif /*!defined( _X75_C_ )*/

w32util.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,11 +1427,11 @@ DLL_EXPORT int expand_environ_vars( const char* inbuff, char* outbuff, DWORD out
14271427
}
14281428

14291429
// Helper function to count set bits in the processor mask.
1430-
DWORD CountSetBits(ULONG_PTR bitMask)
1430+
DWORD CountSetBits(U_LONG_PTR bitMask)
14311431
{
1432-
DWORD LSHIFT = sizeof(ULONG_PTR)*8 - 1;
1432+
DWORD LSHIFT = sizeof(U_LONG_PTR)*8 - 1;
14331433
DWORD bitSetCount = 0;
1434-
ULONG_PTR bitTest = (ULONG_PTR)1 << LSHIFT;
1434+
U_LONG_PTR bitTest = (U_LONG_PTR)1 << LSHIFT;
14351435
DWORD i;
14361436

14371437
for (i = 0; i <= LSHIFT; ++i)
@@ -4495,7 +4495,7 @@ DLL_EXPORT void w32_set_thread_name( TID tid, const char* name )
44954495

44964496
__try
44974497
{
4498-
RaiseException( MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(DWORD), (const ULONG_PTR*)&info );
4498+
RaiseException( MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(DWORD), (const U_LONG_PTR*)&info );
44994499
}
45004500
__except ( EXCEPTION_CONTINUE_EXECUTION )
45014501
{

x75.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
/*-------------------------------------------------------------------*/
55

66
extern int lar_tcpip (DW * regs); /* function in tcpip.c */
7-
extern ULONG_PTR map32[Ccom]; /* map 64-bit host addresses */
7+
extern U_LONG_PTR map32[Ccom]; /* map 64-bit host addresses */
88
/* to 32-bit guest registers */

0 commit comments

Comments
 (0)