[pypy-commit] pypy win64_gborg: Adjusted 'long' in most c/src files, but tried carefully not to mix up things where CPython is involved.

ctismer noreply at buildbot.pypy.org
Sun Nov 6 14:18:57 CET 2011


Author: Christian Tismer <tismer at stackless.com>
Branch: win64_gborg
Changeset: r48824:0944b1ca1861
Date: 2011-11-06 14:13 +0100
http://bitbucket.org/pypy/pypy/changeset/0944b1ca1861/

Log:	Adjusted 'long' in most c/src files, but tried carefully not to mix
	up things where CPython is involved.

diff --git a/pypy/translator/c/src/address.h b/pypy/translator/c/src/address.h
--- a/pypy/translator/c/src/address.h
+++ b/pypy/translator/c/src/address.h
@@ -16,5 +16,5 @@
 #define OP_ADR_LT(x,y,r)	  r = ((x) <  (y))
 #define OP_ADR_GE(x,y,r)	  r = ((x) >= (y))
 
-#define OP_CAST_ADR_TO_INT(x, mode, r)   r = ((long)x)
+#define OP_CAST_ADR_TO_INT(x, mode, r)   r = ((new_long)x)
 #define OP_CAST_INT_TO_ADR(x, r)         r = ((void *)(x))
diff --git a/pypy/translator/c/src/asm_gcc_x86_64.h b/pypy/translator/c/src/asm_gcc_x86_64.h
--- a/pypy/translator/c/src/asm_gcc_x86_64.h
+++ b/pypy/translator/c/src/asm_gcc_x86_64.h
@@ -2,7 +2,7 @@
  */
 
 #define READ_TIMESTAMP(val) do {                        \
-    unsigned long _rax, _rdx;                           \
+    unsigned new_long _rax, _rdx;                           \
     asm volatile("rdtsc" : "=a"(_rax), "=d"(_rdx)); \
     val = (_rdx << 32) | _rax;                          \
 } while (0)
diff --git a/pypy/translator/c/src/float.h b/pypy/translator/c/src/float.h
--- a/pypy/translator/c/src/float.h
+++ b/pypy/translator/c/src/float.h
@@ -31,8 +31,8 @@
 
 /*** conversions ***/
 
-#define OP_CAST_FLOAT_TO_INT(x,r)    r = (long)(x)
-#define OP_CAST_FLOAT_TO_UINT(x,r)   r = (unsigned long)(x)
+#define OP_CAST_FLOAT_TO_INT(x,r)    r = (new_long)(x)
+#define OP_CAST_FLOAT_TO_UINT(x,r)   r = (unsigned new_long)(x)
 #define OP_CAST_INT_TO_FLOAT(x,r)    r = (double)(x)
 #define OP_CAST_UINT_TO_FLOAT(x,r)   r = (double)(x)
 #define OP_CAST_LONGLONG_TO_FLOAT(x,r) r = (double)(x)
diff --git a/pypy/translator/c/src/g_prerequisite.h b/pypy/translator/c/src/g_prerequisite.h
--- a/pypy/translator/c/src/g_prerequisite.h
+++ b/pypy/translator/c/src/g_prerequisite.h
@@ -11,11 +11,9 @@
 #ifdef _WIN64
 #  define new_long __int64
 #  define NEW_LONG_MIN LLONG_MIN
-#  define NEW_LONG_MAX LLONG_MAX
 #else
-#  define new_log long
+#  define new_long long
 #  define NEW_LONG_MIN LONG_MIN
-#  define NEW_LONG_MAX LONG_MAX
 #endif
 
 #ifdef _WIN32
diff --git a/pypy/translator/c/src/int.h b/pypy/translator/c/src/int.h
--- a/pypy/translator/c/src/int.h
+++ b/pypy/translator/c/src/int.h
@@ -6,9 +6,16 @@
 /*** unary operations ***/
 
 /************ win64 support:
+
    'new_long' must be defined as
-   __int64          in case of win64
-   long             in all other cases
+
+       __int64          in case of win64
+       long             in all other cases
+
+   'NEW_LONG_MIN' must be defined as
+
+       LLONG_MIN        in case of win64
+       LONG_MIN         in all other cases
  */
 
 #define OP_INT_IS_TRUE(x,r)   r = ((x) != 0)
diff --git a/pypy/translator/c/src/mem.h b/pypy/translator/c/src/mem.h
--- a/pypy/translator/c/src/mem.h
+++ b/pypy/translator/c/src/mem.h
@@ -53,7 +53,7 @@
 extern void* __gcmapstart;
 extern void* __gcmapend;
 extern char* __gccallshapes;
-extern long pypy_asm_stackwalk(void*, void*);
+extern new_long pypy_asm_stackwalk(void*, void*);
 
 /* With the msvc Microsoft Compiler, the optimizer seems free to move
    any code (even asm) that involves local memory (registers and stack).
@@ -66,7 +66,7 @@
 pypy_asm_gcroot(void* _r1)
 {
 	static volatile int _constant_always_one_ = 1;
-	(long)_r1 *= _constant_always_one_;
+	(new_long)_r1 *= _constant_always_one_;
 	_ReadWriteBarrier();
     return _r1;
 }
@@ -86,7 +86,7 @@
 
 
 /* used by pypy.rlib.rstack, but also by asmgcc */
-#define OP_STACK_CURRENT(r)  r = (long)&r
+#define OP_STACK_CURRENT(r)  r = (new_long)&r
 
 
 #define RAW_MALLOC_ZERO_FILLED 0
diff --git a/pypy/translator/c/src/obmalloc.c b/pypy/translator/c/src/obmalloc.c
--- a/pypy/translator/c/src/obmalloc.c
+++ b/pypy/translator/c/src/obmalloc.c
@@ -224,10 +224,10 @@
 #define uint			unsigned int	/* assuming >= 16 bits */
 
 #undef  ulong
-#define ulong			unsigned long	/* assuming >= 32 bits */
+#define ulong			unsigned new_long	/* assuming >= 32 bits */
 
 #undef uptr
-#define uptr			unsigned long
+#define uptr			unsigned new_long
 
 /* When you say memory, my mind reasons in terms of (pointers to) blocks */
 typedef uchar block;
diff --git a/pypy/translator/c/src/rtyper.h b/pypy/translator/c/src/rtyper.h
--- a/pypy/translator/c/src/rtyper.h
+++ b/pypy/translator/c/src/rtyper.h
@@ -30,7 +30,7 @@
 
 char *RPyString_AsCharP(RPyString *rps)
 {
-	long len = RPyString_Size(rps);
+	new_long len = RPyString_Size(rps);
 	struct _RPyString_dump_t *dump = \
 			malloc(sizeof(struct _RPyString_dump_t) + len);
 	if (!dump)
diff --git a/pypy/translator/c/src/signals.h b/pypy/translator/c/src/signals.h
--- a/pypy/translator/c/src/signals.h
+++ b/pypy/translator/c/src/signals.h
@@ -54,7 +54,7 @@
 /* When a signal is received, pypysig_counter is set to -1. */
 /* This is a struct for the JIT. See interp_signal.py. */
 struct pypysig_long_struct {
-    long value;
+    new_long value;
 };
 extern struct pypysig_long_struct pypysig_counter;
 
diff --git a/pypy/translator/c/src/stack.h b/pypy/translator/c/src/stack.h
--- a/pypy/translator/c/src/stack.h
+++ b/pypy/translator/c/src/stack.h
@@ -12,17 +12,17 @@
 #include "thread.h"
 
 extern char *_LLstacktoobig_stack_end;
-extern long _LLstacktoobig_stack_length;
+extern new_long _LLstacktoobig_stack_length;
 extern char _LLstacktoobig_report_error;
 
-char LL_stack_too_big_slowpath(long);    /* returns 0 (ok) or 1 (too big) */
+char LL_stack_too_big_slowpath(new_long);    /* returns 0 (ok) or 1 (too big) */
 void LL_stack_set_length_fraction(double);
 
 /* some macros referenced from pypy.rlib.rstack */
-#define LL_stack_get_end() ((long)_LLstacktoobig_stack_end)
+#define LL_stack_get_end() ((new_long)_LLstacktoobig_stack_end)
 #define LL_stack_get_length() _LLstacktoobig_stack_length
-#define LL_stack_get_end_adr()    ((long)&_LLstacktoobig_stack_end)   /* JIT */
-#define LL_stack_get_length_adr() ((long)&_LLstacktoobig_stack_length)/* JIT */
+#define LL_stack_get_end_adr()    ((new_long)&_LLstacktoobig_stack_end)   /* JIT */
+#define LL_stack_get_length_adr() ((new_long)&_LLstacktoobig_stack_length)/* JIT */
 
 #define LL_stack_criticalcode_start()  (_LLstacktoobig_report_error = 0)
 #define LL_stack_criticalcode_stop()   (_LLstacktoobig_report_error = 1)
@@ -41,18 +41,18 @@
 /* the current stack is in the interval [end-length:end].  We assume a
    stack that grows downward here. */
 char *_LLstacktoobig_stack_end = NULL;
-long _LLstacktoobig_stack_length = MAX_STACK_SIZE;
+new_long _LLstacktoobig_stack_length = MAX_STACK_SIZE;
 char _LLstacktoobig_report_error = 1;
 static RPyThreadStaticTLS end_tls_key;
 
 void LL_stack_set_length_fraction(double fraction)
 {
-	_LLstacktoobig_stack_length = (long)(MAX_STACK_SIZE * fraction);
+	_LLstacktoobig_stack_length = (new_long)(MAX_STACK_SIZE * fraction);
 }
 
-char LL_stack_too_big_slowpath(long current)
+char LL_stack_too_big_slowpath(new_long current)
 {
-	long diff, max_stack_size;
+	new_long diff, max_stack_size;
 	char *baseptr, *curptr = (char*)current;
 
 	/* The stack_end variable is updated to match the current value
@@ -81,12 +81,12 @@
 	}
 	else {
 		diff = baseptr - curptr;
-		if (((unsigned long)diff) <= (unsigned long)max_stack_size) {
+		if (((unsigned new_long)diff) <= (unsigned new_long)max_stack_size) {
 			/* within bounds, probably just had a thread switch */
 			_LLstacktoobig_stack_end = baseptr;
 			return 0;
 		}
-		if (((unsigned long)-diff) <= (unsigned long)max_stack_size) {
+		if (((unsigned new_long)-diff) <= (unsigned new_long)max_stack_size) {
 			/* stack underflowed: the initial estimation of
 			   the stack base must be revised */
 		}
diff --git a/pypy/translator/c/src/thread.h b/pypy/translator/c/src/thread.h
--- a/pypy/translator/c/src/thread.h
+++ b/pypy/translator/c/src/thread.h
@@ -37,8 +37,8 @@
 
 #endif
 
-long RPyGilAllocate(void);
-long RPyGilYieldThread(void);
+new_long RPyGilAllocate(void);
+new_long RPyGilYieldThread(void);
 void RPyGilRelease(void);
 void RPyGilAcquire(void);
 
diff --git a/pypy/translator/c/src/thread_nt.h b/pypy/translator/c/src/thread_nt.h
--- a/pypy/translator/c/src/thread_nt.h
+++ b/pypy/translator/c/src/thread_nt.h
@@ -17,7 +17,7 @@
 
 typedef struct {
 	void (*func)(void);
-	long id;
+	new_long id;
 	HANDLE done;
 } callobj;
 
@@ -28,7 +28,7 @@
 } NRMUTEX, *PNRMUTEX ;
 
 /* prototypes */
-long RPyThreadStart(void (*func)(void));
+new_long RPyThreadStart(void (*func)(void));
 BOOL InitializeNonRecursiveMutex(PNRMUTEX mutex);
 VOID DeleteNonRecursiveMutex(PNRMUTEX mutex);
 DWORD EnterNonRecursiveMutex(PNRMUTEX mutex, BOOL wait);
@@ -36,15 +36,15 @@
 void RPyOpaqueDealloc_ThreadLock(struct RPyOpaque_ThreadLock *lock);
 int RPyThreadAcquireLock(struct RPyOpaque_ThreadLock *lock, int waitflag);
 void RPyThreadReleaseLock(struct RPyOpaque_ThreadLock *lock);
-long RPyThreadGetStackSize(void);
-long RPyThreadSetStackSize(long);
+new_long RPyThreadGetStackSize(void);
+new_long RPyThreadSetStackSize(new_long);
 
 
 /* implementations */
 
 #ifndef PYPY_NOT_MAIN_FILE
 
-static long _pypythread_stacksize = 0;
+static new_long _pypythread_stacksize = 0;
 
 /*
  * Return the thread Id instead of an handle. The Id is said to uniquely
@@ -67,9 +67,9 @@
 	func();
 }
 
-long RPyThreadStart(void (*func)(void))
+new_long RPyThreadStart(void (*func)(void))
 {
-	unsigned long rv;
+	unsigned new_long rv;
 	callobj obj;
 
 	obj.id = -1;	/* guilty until proved innocent */
@@ -79,7 +79,7 @@
 		return -1;
 
 	rv = _beginthread(bootstrap, _pypythread_stacksize, &obj);
-	if (rv == (unsigned long)-1) {
+	if (rv == (unsigned new_long)-1) {
 		/* I've seen errno == EAGAIN here, which means "there are
 		 * too many threads".
 		 */
@@ -100,12 +100,12 @@
 #define THREAD_MIN_STACKSIZE    0x8000      /* 32kB */
 #define THREAD_MAX_STACKSIZE    0x10000000  /* 256MB */
 
-long RPyThreadGetStackSize(void)
+new_long RPyThreadGetStackSize(void)
 {
 	return _pypythread_stacksize;
 }
 
-long RPyThreadSetStackSize(long newsize)
+new_long RPyThreadSetStackSize(new_long newsize)
 {
 	if (newsize == 0) {    /* set to default */
 		_pypythread_stacksize = 0;
@@ -229,7 +229,7 @@
 static CRITICAL_SECTION mutex_gil;
 static HANDLE cond_gil;
 
-long RPyGilAllocate(void)
+new_long RPyGilAllocate(void)
 {
     pending_acquires = 0;
     InitializeCriticalSection(&mutex_gil);
@@ -238,7 +238,7 @@
     return 1;
 }
 
-long RPyGilYieldThread(void)
+new_long RPyGilYieldThread(void)
 {
     /* can be called even before RPyGilAllocate(), but in this case,
        pending_acquires will be -1 */


More information about the pypy-commit mailing list