summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--driver/others/memory.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/driver/others/memory.c b/driver/others/memory.c
index 103c97077..38d063715 100644
--- a/driver/others/memory.c
+++ b/driver/others/memory.c
@@ -1052,7 +1052,7 @@ void *blas_memory_alloc(int procpos){
mypos = WhereAmI();
position = mypos;
- while (position > NUM_BUFFERS) position >>= 1;
+ while (position >= NUM_BUFFERS) position >>= 1;
do {
if (!memory[position].used && (memory[position].pos == mypos)) {
@@ -1201,8 +1201,8 @@ void blas_memory_free(void *free_area){
position = 0;
LOCK_COMMAND(&alloc_lock);
- while ((memory[position].addr != free_area)
- && (position < NUM_BUFFERS)) position++;
+ while ((position < NUM_BUFFERS) && (memory[position].addr != free_area))
+ position++;
if (memory[position].addr != free_area) goto error;
@@ -1516,12 +1516,30 @@ static int on_process_term(void)
#else
#pragma comment(linker, "/INCLUDE:__tls_used")
#endif
-#pragma data_seg(push, old_seg)
+
+#ifdef _WIN64
+#pragma const_seg(".CRT$XLB")
+#else
#pragma data_seg(".CRT$XLB")
+#endif
static void (APIENTRY *dll_callback)(HINSTANCE h, DWORD ul_reason_for_call, PVOID pv) = DllMain;
+#ifdef _WIN64
+#pragma const_seg()
+#else
+#pragma data_seg()
+#endif
+
+#ifdef _WIN64
+#pragma const_seg(".CRT$XTU")
+#else
#pragma data_seg(".CRT$XTU")
+#endif
static int(*p_process_term)(void) = on_process_term;
-#pragma data_seg(pop, old_seg)
+#ifdef _WIN64
+#pragma const_seg()
+#else
+#pragma data_seg()
+#endif
#endif
#if (defined(C_PGI) || (!defined(C_SUN) && defined(F_INTERFACE_SUN))) && (defined(ARCH_X86) || defined(ARCH_X86_64))