NO

Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
Windows questions / Re: Computing number of Pages to alloc usin VirtualAlloc
« Last post by TimoVJL on November 14, 2024, 03:23:37 PM »
test:
Code: [Select]
#include <stdio.h>

int __cdecl main(void)
{
unsigned long _dwSize, __dwSize;
__dwSize = 3456;
_dwSize = ((__dwSize + 4095) >> 12) << 12 ;
printf("%d\n", _dwSize);
return 0;
}
returns 4096
from podump
Code: [Select]
1: #include <stdio.h>
2:
3: int __cdecl main(void)

_main:
  [00000000] 55                     push              ebp
  [00000001] 89E5                   mov               ebp,esp
  [00000003] 83EC08                 sub               esp,8
4: {
5: unsigned long _dwSize, __dwSize;
6: __dwSize = 3456;
  [00000006] C745F8800D0000         mov               dword ptr [ebp-8],D80
7: _dwSize = ((__dwSize + 4095) >> 12) << 12 ;
  [0000000D] 8B45F8                 mov               eax,dword ptr [ebp-8]
  [00000010] 8D80FF0F0000           lea               eax,[eax+FFF]
  [00000016] C1E80C                 shr               eax,C
  [00000019] C1E00C                 shl               eax,C
  [0000001C] 8945FC                 mov               dword ptr [ebp-4],eax
8: printf("%d\n", _dwSize);
  [0000001F] FF75FC                 push              dword ptr [ebp-4]
  [00000022] 6800000000             push              @9
  [00000027] E800000000             call              _printf
  [0000002C] 83C408                 add               esp,8
9: return 0;
  [0000002F] B800000000             mov               eax,0
  [00000034] 89EC                   mov               esp,ebp
  [00000036] 5D                     pop               ebp
  [00000037] C3                     ret               
Code: [Select]
1: #include <stdio.h>
2:
3: int __cdecl main(void)

main:
  [0000000000000000] 4883EC28                     sub               rsp,28
4: {
5: unsigned long _dwSize, __dwSize;
6: __dwSize = 3456;
  [0000000000000004] C7442420800D0000             mov               dword ptr [rsp+20],D80
7: _dwSize = ((__dwSize + 4095) >> 12) << 12 ;
  [000000000000000C] 8B442420                     mov               eax,dword ptr [rsp+20]
  [0000000000000010] 678D80FF0F0000               lea               eax,[eax+FFF]
  [0000000000000017] C1E80C                       shr               eax,C
  [000000000000001A] C1E00C                       shl               eax,C
  [000000000000001D] 89442424                     mov               dword ptr [rsp+24],eax
8: printf("%d\n", _dwSize);
  [0000000000000021] 488D0D00000000               lea               rcx,[@9]
  [0000000000000028] 8B542424                     mov               edx,dword ptr [rsp+24]
  [000000000000002C] E800000000                   call              printf
9: return 0;
  [0000000000000031] B800000000                   mov               eax,0
  [0000000000000036] 4883C428                     add               rsp,28
  [000000000000003A] C3                           ret               
22
Windows questions / Computing number of Pages to alloc usin VirtualAlloc
« Last post by HellOfMice on November 14, 2024, 01:19:04 PM »
My formula is
_dwSize = ((__dwSize + 4095) >> 12) << 12 ;

is equivalent to (((__dwSize  + 4095) / 4096) * 4096)
Suppose __dwSize = 3456 bytes to alloc

(3456 + 4095) = 7551 bytes
7551 / 4096 = 1 (number of pages)
1 * 4096 = 4096 bytes really allocated

For me 4096 is not the same than 7551 or I must return to school. to old...
I proceed like this because I want a quantity representing full memory pages.
But Pelle does not understand

Code: [Select]
Building Utils.obj.
C:\Users\51966\Documents\#@# Programmation\DIF\Utils.c(111): warning #2287: Dead code removed (around here).
Done

My solution is
Code: [Select]
   _dwSize = (__dwSize + 4095) >> 12 ;
   _dwSize = _dwSize << 12 ;

I don't like

The project is in Release mode. Is it a bug?
23
Windows questions / MessageBow never disappears
« Last post by HellOfMice on November 14, 2024, 12:59:59 PM »
In case of errors my program displays a dialogbox (see image).
There is nothing special with that box but I can click on a button the box always stays.

Code: [Select]

int Error(HWND __hWnd,LPSTR __lpszMessage)
{
   MessageBox(__hWnd,__lpszMessage,"Error",MB_OK|MB_ICONERROR|MB_TOPMOST) ;

   return (0) ;
}

I don't understand.
But I can close my program!

I need your help please
Thank You

Philippe RIO
24
Windows questions / Status Bar Background Color
« Last post by HellOfMice on November 14, 2024, 12:46:21 PM »
It is an old discussion on MASM32 forum. Timo and Vortex should remember.


I tried the following simple solution on Windows 11.
My application is a dialogBox based


Code: [Select]
   hStatus = CreateStatusWindow(WS_CHILD|WS_VISIBLE,"Welcome",__hWnd,IDC_STATUSBAR_01) ;
   SetWindowTheme(hStatus,NULL,L" ") ;
   SendMessage(hStatus,SB_SETPARTS,(WPARAM) 2,(LPARAM) StatWidths) ;
   SendMessage(hStatus,(UINT) SB_SETBKCOLOR,0,(LPARAM) 255) ;
   SendMessage(hStatus,(UINT) SB_SETTEXT,(WPARAM)(INT) 0,(LPARAM) (LPSTR) "Welcome") ;
   ShowWindow(hStatus,SW_SHOW) ;

25
Bug reports / Re: Compiling using AVX2
« Last post by HellOfMice on November 06, 2024, 01:31:43 PM »
Hi Timo,


Just some words


I am reading AMD docs because I would like to compute average, deviation and std deviation.
But I can't find any instruction that insert 0 between rgb values and like this I could compute a sum
my program is slow when computing them in C
I tried the profiler and passed from 2.2% to 0.5%
I would like to try with SSE2.. SSE4.1 instructions
have you any idea?


Thank you for your help


Philippe
26
Bug reports / Re: Compiling using AVX2
« Last post by TimoVJL on November 06, 2024, 01:27:24 PM »
Merci I don't load the compiler
Only some of us needs several C compilers to verify code issues.
27
Bug reports / Re: Compiling using AVX2
« Last post by HellOfMice on November 05, 2024, 07:27:23 PM »
Merci I don't load the compiler
28
Bug reports / Re: Compiling using AVX2
« Last post by TimoVJL on November 05, 2024, 07:21:12 PM »
Example with Clang and Pelles C modified headers:
Code: [Select]
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c
(27,2): warning: format specifies type 'int' but the argument has type 'unsigned long long' [-Wformat]
        PRINTSIZE(GDIPLUSSTARTUPINPUT);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(14,58): note: expanded from macro 'PRINTSIZE'
#define PRINTSIZE(x)  printf("\n%-16s %d %Xh bytes\n",#x,sizeof(x),sizeof(x));
                                      ~~                 ^~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(27,2): warning: format specifies type 'unsigned int' but the argument has type 'unsigned long long' [-Wformat]
        PRINTSIZE(GDIPLUSSTARTUPINPUT);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(14,68): note: expanded from macro 'PRINTSIZE'
#define PRINTSIZE(x)  printf("\n%-16s %d %Xh bytes\n",#x,sizeof(x),sizeof(x));
                                         ~~                        ^~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(28,2): warning: cast to smaller integer type 'LONG' (aka 'long') from 'UINT32 *' (aka 'unsigned int *') [-Wpointer-to-int-cast]
        PRINTOFSSIZE(GDIPLUSSTARTUPINPUT,GdiplusVersion);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(15,67): note: expanded from macro 'PRINTOFSSIZE'
#define PRINTOFSSIZE(type,field) printf("%-16s +%Xh %Xh\n",#field,(LONG)&(((type *)0)->field),sizeof(((type *)0)->field));
                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(28,2): warning: format specifies type 'unsigned int' but the argument has type 'LONG' (aka 'long') [-Wformat]
        PRINTOFSSIZE(GDIPLUSSTARTUPINPUT,GdiplusVersion);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(15,67): note: expanded from macro 'PRINTOFSSIZE'
#define PRINTOFSSIZE(type,field) printf("%-16s +%Xh %Xh\n",#field,(LONG)&(((type *)0)->field),sizeof(((type *)0)->field));
                                                ~~                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(28,2): warning: format specifies type 'unsigned int' but the argument has type 'unsigned long long' [-Wformat]
        PRINTOFSSIZE(GDIPLUSSTARTUPINPUT,GdiplusVersion);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(15,95): note: expanded from macro 'PRINTOFSSIZE'
#define PRINTOFSSIZE(type,field) printf("%-16s +%Xh %Xh\n",#field,(LONG)&(((type *)0)->field),sizeof(((type *)0)->field));
                                                    ~~                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(29,2): warning: cast to smaller integer type 'LONG' (aka 'long') from 'void **' [-Wpointer-to-int-cast]
        PRINTOFSSIZE(GDIPLUSSTARTUPINPUT,DebugEventCallback);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(15,67): note: expanded from macro 'PRINTOFSSIZE'
#define PRINTOFSSIZE(type,field) printf("%-16s +%Xh %Xh\n",#field,(LONG)&(((type *)0)->field),sizeof(((type *)0)->field));
                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(29,2): warning: format specifies type 'unsigned int' but the argument has type 'LONG' (aka 'long') [-Wformat]
        PRINTOFSSIZE(GDIPLUSSTARTUPINPUT,DebugEventCallback);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(15,67): note: expanded from macro 'PRINTOFSSIZE'
#define PRINTOFSSIZE(type,field) printf("%-16s +%Xh %Xh\n",#field,(LONG)&(((type *)0)->field),sizeof(((type *)0)->field));
                                                ~~                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(29,2): warning: format specifies type 'unsigned int' but the argument has type 'unsigned long long' [-Wformat]
        PRINTOFSSIZE(GDIPLUSSTARTUPINPUT,DebugEventCallback);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(15,95): note: expanded from macro 'PRINTOFSSIZE'
#define PRINTOFSSIZE(type,field) printf("%-16s +%Xh %Xh\n",#field,(LONG)&(((type *)0)->field),sizeof(((type *)0)->field));
                                                    ~~                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(30,2): warning: cast to smaller integer type 'LONG' (aka 'long') from 'BOOL *' (aka 'int *') [-Wpointer-to-int-cast]
        PRINTOFSSIZE(GDIPLUSSTARTUPINPUT,SuppressBackgroundThread);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(15,67): note: expanded from macro 'PRINTOFSSIZE'
#define PRINTOFSSIZE(type,field) printf("%-16s +%Xh %Xh\n",#field,(LONG)&(((type *)0)->field),sizeof(((type *)0)->field));
                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(30,2): warning: format specifies type 'unsigned int' but the argument has type 'LONG' (aka 'long') [-Wformat]
        PRINTOFSSIZE(GDIPLUSSTARTUPINPUT,SuppressBackgroundThread);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(15,67): note: expanded from macro 'PRINTOFSSIZE'
#define PRINTOFSSIZE(type,field) printf("%-16s +%Xh %Xh\n",#field,(LONG)&(((type *)0)->field),sizeof(((type *)0)->field));
                                                ~~                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(30,2): warning: format specifies type 'unsigned int' but the argument has type 'unsigned long long' [-Wformat]
        PRINTOFSSIZE(GDIPLUSSTARTUPINPUT,SuppressBackgroundThread);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(15,95): note: expanded from macro 'PRINTOFSSIZE'
#define PRINTOFSSIZE(type,field) printf("%-16s +%Xh %Xh\n",#field,(LONG)&(((type *)0)->field),sizeof(((type *)0)->field));
                                                    ~~                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(31,2): warning: cast to smaller integer type 'LONG' (aka 'long') from 'BOOL *' (aka 'int *') [-Wpointer-to-int-cast]
        PRINTOFSSIZE(GDIPLUSSTARTUPINPUT,SuppressExternalCodecs);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(15,67): note: expanded from macro 'PRINTOFSSIZE'
#define PRINTOFSSIZE(type,field) printf("%-16s +%Xh %Xh\n",#field,(LONG)&(((type *)0)->field),sizeof(((type *)0)->field));
                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(31,2): warning: format specifies type 'unsigned int' but the argument has type 'LONG' (aka 'long') [-Wformat]
        PRINTOFSSIZE(GDIPLUSSTARTUPINPUT,SuppressExternalCodecs);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(15,67): note: expanded from macro 'PRINTOFSSIZE'
#define PRINTOFSSIZE(type,field) printf("%-16s +%Xh %Xh\n",#field,(LONG)&(((type *)0)->field),sizeof(((type *)0)->field));
                                                ~~                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(31,2): warning: format specifies type 'unsigned int' but the argument has type 'unsigned long long' [-Wformat]
        PRINTOFSSIZE(GDIPLUSSTARTUPINPUT,SuppressExternalCodecs);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\code\PellesC\_Forum\_test\StructInfo_GDI+.c(15,95): note: expanded from macro 'PRINTOFSSIZE'
#define PRINTOFSSIZE(type,field) printf("%-16s +%Xh %Xh\n",#field,(LONG)&(((type *)0)->field),sizeof(((type *)0)->field));
                                                    ~~                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
24
 warnings and 2 errors generated.
Done.
29
Bug reports / Re: Compiling using AVX2
« Last post by HellOfMice on November 05, 2024, 07:00:17 PM »
I only have Pelle's Compiler but I will try your advice
Thanks


Philippe
30
Bug reports / Re: Compiling using AVX2
« Last post by TimoVJL on November 05, 2024, 06:58:25 PM »
C compiler problem, so rearrange code and test it without / with optimization.
Also try another compiler, like Clang, as it can give lot of hints for code problems.
Pages: 1 2 [3] 4 5 ... 10