Mercurial > mplayer.hg
comparison loader/win32.c @ 597:d751f549f29f
no more warnings...
author | szabii |
---|---|
date | Mon, 23 Apr 2001 20:16:37 +0000 |
parents | f776e51e531c |
children | 9355b2ae634e |
comparison
equal
deleted
inserted
replaced
596:6a6b7c471c34 | 597:d751f549f29f |
---|---|
15 | 15 |
16 #include "win32.h" | 16 #include "win32.h" |
17 #include <stdio.h> | 17 #include <stdio.h> |
18 #include <pthread.h> | 18 #include <pthread.h> |
19 #include <errno.h> | 19 #include <errno.h> |
20 #include <ctype.h> | |
21 #include <stdlib.h> | |
20 #ifdef HAVE_MALLOC_H | 22 #ifdef HAVE_MALLOC_H |
21 #include <malloc.h> | 23 #include <malloc.h> |
22 #else | |
23 #include <stdlib.h> | |
24 #endif | 24 #endif |
25 #include <time.h> | 25 #include <time.h> |
26 #include <unistd.h> | 26 #include <unistd.h> |
27 #include <fcntl.h> | 27 #include <fcntl.h> |
28 #include <sys/types.h> | 28 #include <sys/types.h> |
221 if(to_zero) | 221 if(to_zero) |
222 memset(heap+heap_counter, 0, size); | 222 memset(heap+heap_counter, 0, size); |
223 heap_counter+=size; | 223 heap_counter+=size; |
224 return heap+heap_counter-size; | 224 return heap+heap_counter-size; |
225 } | 225 } |
226 int my_release(char* memory) | 226 int my_release(void* memory) |
227 { | 227 { |
228 // test_heap(); | 228 // test_heap(); |
229 if(memory==NULL) | 229 if(memory==NULL) |
230 { | 230 { |
231 printf("ERROR: free(0)\n"); | 231 printf("ERROR: free(0)\n"); |
245 #define GARBAGE | 245 #define GARBAGE |
246 #ifdef GARBAGE | 246 #ifdef GARBAGE |
247 struct alc_list_t; | 247 struct alc_list_t; |
248 typedef struct alc_list_t { | 248 typedef struct alc_list_t { |
249 int size; | 249 int size; |
250 int addr; | 250 void *addr; |
251 struct alc_list_t *prev; | 251 struct alc_list_t *prev; |
252 struct alc_list_t *next; | 252 struct alc_list_t *next; |
253 }alc_list; | 253 }alc_list; |
254 static alc_list *alclist=NULL; | 254 static alc_list *alclist=NULL; |
255 static alccnt=0; | 255 static int alccnt=0; |
256 #endif | 256 #endif |
257 | 257 |
258 void* my_mreq(int size, int to_zero) | 258 void* my_mreq(int size, int to_zero) |
259 { | 259 { |
260 void* answer; | 260 void* answer; |
278 alclist->addr=answer; | 278 alclist->addr=answer; |
279 alccnt++; | 279 alccnt++; |
280 #endif | 280 #endif |
281 return (int*)((int)answer+sizeof(int)); | 281 return (int*)((int)answer+sizeof(int)); |
282 } | 282 } |
283 int my_release(char* memory) | 283 int my_release(void* memory) |
284 { | 284 { |
285 #ifdef GARBAGE | 285 #ifdef GARBAGE |
286 alc_list* pp; | 286 alc_list* pp; |
287 if(memory==0)return 0; | 287 if(memory==0)return 0; |
288 if(alclist!=NULL) | 288 if(alclist!=NULL) |
305 alccnt--; | 305 alccnt--; |
306 break; | 306 break; |
307 } | 307 } |
308 } | 308 } |
309 if (pp == NULL) { | 309 if (pp == NULL) { |
310 printf("Not Found %x %d\n",memory-4,alccnt); | 310 printf("Not Found %p %d\n",memory-4,alccnt); |
311 return 0; | 311 return 0; |
312 } | 312 } |
313 } | 313 } |
314 } | 314 } |
315 #endif | 315 #endif |
433 result=(void*)(wm->module); | 433 result=(void*)(wm->module); |
434 } | 434 } |
435 if(!result) | 435 if(!result) |
436 { | 436 { |
437 if(strcasecmp(name, "kernel32")==0) | 437 if(strcasecmp(name, "kernel32")==0) |
438 result=0x120; | 438 result=(void *) 0x120; |
439 } | 439 } |
440 dbgprintf("GetModuleHandleA('%s') => 0x%x\n", name, result); | 440 dbgprintf("GetModuleHandleA('%s') => 0x%x\n", name, result); |
441 return result; | 441 return result; |
442 } | 442 } |
443 | 443 |
513 { | 513 { |
514 dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, 0x%x='%s') => 0x%x\n", | 514 dbgprintf("CreateEventA(0x%x, 0x%x, 0x%x, 0x%x='%s') => 0x%x\n", |
515 pSecAttr, bManualReset, bInitialState, name, name, pp->pm); | 515 pSecAttr, bManualReset, bInitialState, name, name, pp->pm); |
516 return pp->pm; | 516 return pp->pm; |
517 } | 517 } |
518 }while(pp=pp->prev); | 518 }while((pp=pp->prev)); |
519 } | 519 } |
520 pm=my_mreq(sizeof(pthread_mutex_t), 0); | 520 pm=my_mreq(sizeof(pthread_mutex_t), 0); |
521 pthread_mutex_init(pm, NULL); | 521 pthread_mutex_init(pm, NULL); |
522 pc=my_mreq(sizeof(pthread_cond_t), 0); | 522 pc=my_mreq(sizeof(pthread_cond_t), 0); |
523 pthread_cond_init(pc, NULL); | 523 pthread_cond_init(pc, NULL); |
589 // dbgprintf("WaitForSingleObject(0x%x, duration %d) =>\n",object, duration); | 589 // dbgprintf("WaitForSingleObject(0x%x, duration %d) =>\n",object, duration); |
590 do { | 590 do { |
591 if (pp == NULL) dbgprintf("WaitForSingleObject: NotFound\n"); | 591 if (pp == NULL) dbgprintf("WaitForSingleObject: NotFound\n"); |
592 if((pp->pm, mlist->pm)==0) | 592 if((pp->pm, mlist->pm)==0) |
593 break;; | 593 break;; |
594 }while(pp=pp->prev); | 594 }while((pp=pp->prev)); |
595 | 595 |
596 | 596 |
597 pthread_mutex_lock(ml->pm); | 597 pthread_mutex_lock(ml->pm); |
598 | 598 |
599 switch(ml->type) { | 599 switch(ml->type) { |
1163 { | 1163 { |
1164 dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0x%x='%s') => 0x%x", | 1164 dbgprintf("CreateSemaphoreA(0x%x, init_count %d, max_count %d, name 0x%x='%s') => 0x%x", |
1165 v1, init_count, max_count, name, name, mlist); | 1165 v1, init_count, max_count, name, name, mlist); |
1166 return (HANDLE)mlist; | 1166 return (HANDLE)mlist; |
1167 } | 1167 } |
1168 }while(pp=pp->prev); | 1168 }while((pp=pp->prev)); |
1169 } | 1169 } |
1170 pm=my_mreq(sizeof(pthread_mutex_t), 0); | 1170 pm=my_mreq(sizeof(pthread_mutex_t), 0); |
1171 pthread_mutex_init(pm, NULL); | 1171 pthread_mutex_init(pm, NULL); |
1172 pc=my_mreq(sizeof(pthread_cond_t), 0); | 1172 pc=my_mreq(sizeof(pthread_cond_t), 0); |
1173 pthread_cond_init(pc, NULL); | 1173 pthread_cond_init(pc, NULL); |
1598 { | 1598 { |
1599 int result=FreeLibrary(module); | 1599 int result=FreeLibrary(module); |
1600 dbgprintf("FreeLibrary(0x%x) => %d\n", module, result); | 1600 dbgprintf("FreeLibrary(0x%x) => %d\n", module, result); |
1601 return result; | 1601 return result; |
1602 } | 1602 } |
1603 void* LookupExternalByName(const char* library, const char* name); | |
1603 void* WINAPI expGetProcAddress(HMODULE mod, char* name) | 1604 void* WINAPI expGetProcAddress(HMODULE mod, char* name) |
1604 { | 1605 { |
1605 int result; | 1606 void *result; |
1606 if(mod!=0x120) | 1607 if(mod!=0x120) |
1607 result=GetProcAddress(mod, name); | 1608 result=GetProcAddress(mod, name); |
1608 else | 1609 else |
1609 result=LookupExternalByName("kernel32.dll", name); | 1610 result=LookupExternalByName("kernel32.dll", name); |
1610 dbgprintf("GetProcAddress(0x%x, '%s') => 0x%x\n", mod, name, result); | 1611 dbgprintf("GetProcAddress(0x%x, '%s') => 0x%x\n", mod, name, result); |
1845 { | 1846 { |
1846 int result=strlen(str); | 1847 int result=strlen(str); |
1847 dbgprintf("strlen(0x%x='%s') => %d\n", str, str, result); | 1848 dbgprintf("strlen(0x%x='%s') => %d\n", str, str, result); |
1848 return result; | 1849 return result; |
1849 } | 1850 } |
1850 int expstrcpy(char* str1, const char* str2) | 1851 void *expstrcpy(char* str1, const char* str2) |
1851 { | 1852 { |
1852 int result=strcpy(str1, str2); | 1853 void *result=strcpy(str1, str2); |
1853 dbgprintf("strcpy(0x%x, 0x%x='%s') => %d\n", str1, str2, str2, result); | 1854 dbgprintf("strcpy(0x%x, 0x%x='%s') => %p\n", str1, str2, str2, result); |
1854 return result; | 1855 return result; |
1855 } | 1856 } |
1856 int expstrcmp(const char* str1, const char* str2) | 1857 int expstrcmp(const char* str1, const char* str2) |
1857 { | 1858 { |
1858 int result=strcmp(str1, str2); | 1859 int result=strcmp(str1, str2); |
1859 dbgprintf("strcmp(0x%x='%s', 0x%x='%s') => %d\n", str1, str1, str2, str2, result); | 1860 dbgprintf("strcmp(0x%x='%s', 0x%x='%s') => %d\n", str1, str1, str2, str2, result); |
1860 return result; | 1861 return result; |
1861 } | 1862 } |
1862 int expstrcat(char* str1, const char* str2) | 1863 void *expstrcat(char* str1, const char* str2) |
1863 { | 1864 { |
1864 int result=strcat(str1, str2); | 1865 void *result=strcat(str1, str2); |
1865 dbgprintf("strcat(0x%x='%s', 0x%x='%s') => %d\n", str1, str1, str2, str2, result); | 1866 dbgprintf("strcat(0x%x='%s', 0x%x='%s') => %p\n", str1, str1, str2, str2, result); |
1866 return result; | 1867 return result; |
1867 } | 1868 } |
1868 int expmemmove(void* dest, void* src, int n) | 1869 void *expmemmove(void* dest, void* src, int n) |
1869 { | 1870 { |
1870 int result=memmove(dest, src, n); | 1871 void *result=memmove(dest, src, n); |
1871 dbgprintf("memmove(0x%x, 0x%x, %d) => %d\n", dest, src, n, result); | 1872 dbgprintf("memmove(0x%x, 0x%x, %d) => %p\n", dest, src, n, result); |
1872 return memmove; | 1873 return memmove; |
1873 } | 1874 } |
1874 int expmemcmp(void* dest, void* src, int n) | 1875 int expmemcmp(void* dest, void* src, int n) |
1875 { | 1876 { |
1876 int result=memcmp(dest, src, n); | 1877 int result=memcmp(dest, src, n); |
1877 dbgprintf("memcmp(0x%x, 0x%x, %d) => %d\n", dest, src, n, result); | 1878 dbgprintf("memcmp(0x%x, 0x%x, %d) => %d\n", dest, src, n, result); |
1878 return result; | 1879 return result; |
1879 } | 1880 } |
1880 int expmemcpy(void* dest, void* src, int n) | 1881 void *expmemcpy(void* dest, void* src, int n) |
1881 { | 1882 { |
1882 int result=memcpy(dest, src, n); | 1883 void *result=memcpy(dest, src, n); |
1883 dbgprintf("memcpy(0x%x, 0x%x, %d) => %x\n", dest, src, n, result); | 1884 dbgprintf("memcpy(0x%x, 0x%x, %d) => %p\n", dest, src, n, result); |
1884 return result; | 1885 return result; |
1885 } | 1886 } |
1886 time_t exptime(time_t* t) | 1887 time_t exptime(time_t* t) |
1887 { | 1888 { |
1888 time_t result=time(t); | 1889 time_t result=time(t); |
1890 return result; | 1891 return result; |
1891 } | 1892 } |
1892 | 1893 |
1893 int WINAPI expStringFromGUID2(GUID* guid, char* str, int cbMax) | 1894 int WINAPI expStringFromGUID2(GUID* guid, char* str, int cbMax) |
1894 { | 1895 { |
1895 int result=snprintf(str, cbMax, "%.8x-%.4x-%.4x-%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x", | 1896 int result=snprintf(str, cbMax, "%.8lx-%.4x-%.4x-%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x", |
1896 guid->f1, guid->f2, guid->f3, | 1897 guid->f1, guid->f2, guid->f3, |
1897 (unsigned char)guid->f4[0], (unsigned char)guid->f4[1], (unsigned char)guid->f4[2], (unsigned char)guid->f4[3], | 1898 (unsigned char)guid->f4[0], (unsigned char)guid->f4[1], (unsigned char)guid->f4[2], (unsigned char)guid->f4[3], |
1898 (unsigned char)guid->f4[4], (unsigned char)guid->f4[5], (unsigned char)guid->f4[6], (unsigned char)guid->f4[7]); | 1899 (unsigned char)guid->f4[4], (unsigned char)guid->f4[5], (unsigned char)guid->f4[6], (unsigned char)guid->f4[7]); |
1899 dbgprintf("StringFromGUID2(0x%x, 0x%x='%s', %d) => %d\n", guid, str, str, cbMax, result); | 1900 dbgprintf("StringFromGUID2(0x%x, 0x%x='%s', %d) => %d\n", guid, str, str, cbMax, result); |
1900 return result; | 1901 return result; |
2697 ppsv = pp; | 2698 ppsv = pp; |
2698 pp=pp->prev; | 2699 pp=pp->prev; |
2699 free(ppsv); | 2700 free(ppsv); |
2700 alccnt--; | 2701 alccnt--; |
2701 } | 2702 } |
2702 printf("Total Unfree %d bytes cnt %d [%x,%d]\n",unfree,unfreecnt,alclist,alccnt); | 2703 printf("Total Unfree %d bytes cnt %d [%p,%d]\n",unfree,unfreecnt,alclist,alccnt); |
2703 #endif | 2704 #endif |
2704 } | 2705 } |