メインページ | アルファベット順一覧 | 構成 | ファイル一覧 | 構成メンバ | ファイルメンバ | 関連ページ

# dkcOSIndependent.h

説明を見る。

    00001
    00008 #ifndef DKUTIL_C_OS_INDEPENDENT_H
    00009 #define DKUTIL_C_OS_INDEPENDENT_H
    00010
    00011
    00012
    00013
    00014
    00015 #if defined(_MSC_VER) && (_MSC_VER >= 1020)
    00016 #   pragma once
    00017 #else
    00018
    00019
    00020 #endif
    00021
    00022 #ifdef __cplusplus //C++のみ
    00023
    00024 #   include <limits>
    00025
    00026
    00027 #endif
    00028
    00029
    00030 #include "dkcDefined.h"
    00031 #include <limits.h>
    00032 #include <float.h>
    00033 #include <assert.h>
    00034
    00035 /*
    00036 #define DKUTIL_C_USE_DKUTIL_CSTD
    00037 #ifdef DKUTIL_C_USE_DKUTIL_CSTD
    00038 #define DKUTIL_CSTD_NOT_DEFINE_STDLIB_MACRO
    00039 #   include "dkutil_cstd/stdlib.h"
    00040 #else
    00041 #   include <stdlib.h>
    00042 #endif
    00043 */
    00044 #define DKUTIL_CSTD_NOT_DEFINE_STDLIB_MACRO
    00045 #   include "dkutil_cstd/stdlib.h"
    00046 #   include <stdlib.h>
    00047
    00048 #ifdef __BORLANDC__
    00049 #   include <dir.h>
    00050 #else
    00051 #   include <direct.h>
    00052 #endif
    00053
    00054 #if defined(_WIN32) || defined(__WIN32__)
    00055 #   ifndef WIN32
    00056 #       define WIN32
    00057 #   endif
    00058 #endif
    00059
    00060 //**********************************************************
    00061 //型定義
    00062
    00063 #if defined(_MSC_VER) || defined(WIN32)
    00064     typedef unsigned __int64 QWORD;
    00065 #else
    00066     typedef unsigned long long QWORD;
    00067 #endif
    00068
    00070 typedef unsigned char dkctBOOL;
    00071 /*
    00072 #ifndef uint32
    00073 typedef unsigned long uint32;
    00074 #endif
    00075
    00076 #ifndef uint16
    00077 typedef unsigned short uint16;
    00078 #endif
    00079
    00080 #ifndef uint8
    00081 typedef unsigned char uint8;
    00082 #endif
    00083 */
    00084
    00085 #ifndef WIN32
    00086
    00087
    00088
    00089 #ifndef DWORD
    00090 #   define DWORD        uint32
    00091 #endif
    00092 #ifndef WORD
    00093 #   define WORD         uint16
    00094 #endif
    00095 #ifndef BYTE
    00096 #   define BYTE         uint8
    00097 #endif
    00098
    00099
    00100 #ifndef ULONGLONG
    00101 #   define ULONGLONG unsigned long long int
    00102 #endif
    00103
    00104 #ifndef LONGLONG
    00105 #   define LONGLONG long long int
    00106 #endif
    00107
    00108
    00109 #ifndef TRUE
    00110 #   define TRUE 1
    00111 #endif
    00112 #ifndef FALSE
    00113 #   define FALSE 0
    00114 #endif
    00115
    00116 #ifndef NULL
    00117 #   define NULL 0
    00118 #endif
    00119
    00120 #   define dkcdPATH_SEP '/'
    00121 #   define dkcdPATH_SEP_STR "/"
    00122 #   define dkcdPATH_LIST_SEP ':'
    00123 #   define dkcdPATH_LIST_SEP_STR ":"
    00124 #   define dkcmIS_PATH_SEP(c) (dkcdPATH_SEP==(c))
    00125 /*.,:;*/
    00126 #   define dkcmIS_INVALID_FILENAME_CHAR(c) ( ((c) =='\\') || ((c)=='/') || ((c)=='*') || ((c)=='?') \
    00127         || ((c)== '"') || ((c) == '<') || ((c) == '>') || ((c) == '|') )
    00128
    00129 #   define dkcmIS_INVALID_FOLDERNAME_CHAR(c) \
    00130     dkcmIS_INVALID_FILENAME_CHAR(c)
    00131
    00132 #define dkcmIS_INVALID_PATH_CHAR(c) \
    00133     ( ( (c)=='\\') || ((c)=='*') || ((c)=='?') || ((c)== '"') || \
    00134     ((c) == '<') || ((c) == '>') || ((c) == '|') )
    00135
    00136 //reallocの関数の型
    00137 typedef void *(*DKC_REALLOC_F_TYPE)(void *,size_t);
    00138
    00139 typedef int BOOL;
    00140 //typedef unsigned char BYTE;
    00141
    00142
    00143
    00144
    00145 #ifndef CALLBACK
    00146 #   define CALLBACK
    00147 #endif
    00148 #ifndef WINAPI
    00149 #   define WINAPI
    00150 #endif
    00151
    00152 #else //else of WIN32
    00153
    00154 #ifdef _MSC_VER
    00155 #   ifdef _DEBUG
    00156 #       ifndef DEBUG
    00157 #           define DEBUG
    00158 #       endif
    00159 #   else
    00160 #       ifndef NDEBUG
    00161 #           define NDEBUG
    00162 #       endif
    00163 #   endif
    00164
    00165 #   pragma warning(disable:4115)//union{ } struct{ }
    00166 #   pragma warning(disable:4100)//引数が関数の本体で 1 度も参照されません。
    00167 #   pragma warning(disable:4206)//プリプロセス後のファイルが空です。 #if 0 #endif
    00168 #   pragma warning(disable:4710)//場合によってはｲﾝﾗｲﾝ処理を行いません。
    00169 #   pragma warning(disable:4505)//参照されていないﾛｰｶﾙ関数は削除されました。
    00170 #endif
    00171
    00172 # include <windows.h>
    00173
    00174
    00175
    00176
    00177 #   ifndef CALLBACK
    00178 #       define CALLBACK __stdcall
    00179 #   endif
    00180 #   ifndef WINAPI
    00181 #       define WINAPI __stdcall
    00182 #   endif
    00183
    00184
    00185
    00186 #   define dkcdPATH_SEP '\\'
    00187 #   define dkcdPATH_SEP_STR "\\"
    00188 #   define dkcdPATH_LIST_SEP ';'
    00189 #   define dkcdPATH_LIST_SEP_STR ";"
    00190 #   define dkcmIS_PATH_SEP(c) (dkcdPATH_SEP==(c) || '/'==(c))
    00191
    00193 #   define dkcmIS_INVALID_FILENAME_CHAR(c) ( ((c) =='\\') || ((c)=='/') || ((c)=='*') || ((c)=='?') \
    00194         || ((c)== '"') || ((c) == '<') || ((c) == '>') || ((c) == '|') || (':'== (c)) )
    00195
    00196 #   define dkcmIS_INVALID_FOLDERNAME_CHAR(c) \
    00197     dkcmIS_INVALID_FILENAME_CHAR(c)
    00198
    00200 #   define dkcmIS_INVALID_PATH_CHAR(c) \
    00201     ((c)=='*') || ((c)=='?') || ((c)== '"') || \
    00202     ((c) == '<') || ((c) == '>') || ((c) == '|')
    00203
    00204 #ifdef _MT
    00205 #   define dkcdMultiThread
    00206 #endif
    00207
    00208 #ifdef _MSC_VER
    00209 #   include <crtdbg.h>
    00210 #   ifdef DEBUG
    00211 #       pragma comment(linker,"/NODEFAULTLIB:LIBC")
    00212 #       pragma comment(linker,"/NODEFAULTLIB:LIBCMT")
    00213 #   ifdef dkcdMultiThread
    00214 #       pragma comment(linker,"/NODEFAULTLIB:LIBCD")
    00215 #   else
    00216 #       pragma comment(linker,"/NODEFAULTLIB:LIBCMTD")
    00217 #   endif
    00218 #else
    00219 #       pragma comment(linker,"/NODEFAULTLIB:LIBCD")
    00220 #       pragma comment(linker,"/NODEFAULTLIB:LIBCMTD")
    00221 #   ifdef dkcdMultiThread
    00222 #       pragma comment(linker,"/NODEFAULTLIB:LIBC")
    00223 #   else
    00224 #       pragma comment(linker,"/NODEFAULTLIB:LIBCMT")
    00225 #   endif
    00226 #endif
    00227 #endif //end of _MSC_VER
    00228
    00229 #endif //end of  #ifndef WIN32
    00230
    00231
    00232
    00233 #ifdef WIN32//Windowsならば
    00234
    00235 #define ORDER_DCBA  // chosing Intel in this case
    00236 #define dkcdLITTLE_ENDIAN 1
    00237 #define dkcdBIG_ENDIAN 0
    00238 #else //macとかならば
    00239 #define dkcdLITTLE_ENDIAN 0
    00240 #define dkcdBIG_ENDIAN 1
    00241 //#define ORDER_ABCD //motorola (Macとか)
    00242 #endif
    00243
    00244 #ifdef ORDER_DCBA   // DCBA - little endian - intel
    00245
    00246     union aword {
    00247       DWORD dword;
    00248       BYTE byte [4];
    00249       struct {
    00250         unsigned int byte3:8;
    00251         unsigned int byte2:8;
    00252         unsigned int byte1:8;
    00253         unsigned int byte0:8;
    00254       } w;
    00255     };
    00256
    00257 union dkc4ByteUnionLittleEndianBase{
    00258     DWORD dword;
    00259     BYTE byte [4];
    00260     struct {
    00261       unsigned int byte0:8;
    00262       unsigned int byte1:8;
    00263       unsigned int byte2:8;
    00264       unsigned int byte3:8;
    00265     } w;
    00266 };
    00267 #endif
    00268
    00269 #ifdef ORDER_ABCD   // ABCD - big endian - motorola
    00270     union aword {
    00271       DWORD dword;
    00272       BYTE byte [4];
    00273       struct {
    00274         unsigned int byte0:8;
    00275         unsigned int byte1:8;
    00276         unsigned int byte2:8;
    00277         unsigned int byte3:8;
    00278       } w;
    00279     };
    00280     union dkc4ByteUnionLittleEndianBase{
    00281         DWORD dword;
    00282         BYTE byte [4];
    00283         struct {
    00284             unsigned int byte3:8;
    00285         unsigned int byte2:8;
    00286         unsigned int byte1:8;
    00287         unsigned int byte0:8;
    00288         } w;
    00289 };
    00290 #endif
    00291
    00292 #ifdef ORDER_BADC   // BADC - vax
    00293     union aword {
    00294       DWORD dword;
    00295       BYTE byte [4];
    00296       struct {
    00297         unsigned int byte1:8;
    00298         unsigned int byte0:8;
    00299         unsigned int byte3:8;
    00300         unsigned int byte2:8;
    00301       } w;
    00302 };
    00303 #endif
    00304
    00305 typedef union aword DKC_4BYTE_UNION_BIG_ENDIAN_BASE;
    00306
    00307 typedef union dkc4ByteUnionLittleEndianBase DKC_4BYTE_UNION_LITTLE_ENDIAN_BASE;
    00308 /*
    00309 #ifdef WIN32
    00310     typedef DKC_4BYTE_UNION_LITTLE_ENDIAN_BASE DKC_4BYTE_UNION;
    00311 */
    00312
    00313
    00314
    00315 #ifdef WIN32
    00316
    00317     typedef void *(WINAPIV *DKC_REALLOC_F_TYPE)(void *,size_t);
    00319     //typedef int (WINAPI *PROC)();
    00320     typedef PROC DKC_WINAPI_PROC_F_TYPE ;
    00321 #else
    00322
    00323     typedef void *(*DKC_REALLOC_F_TYPE)(void *,size_t);
    00324     typedef void *DKC_WINAPI_PROC_F_TYPE;
    00325 #endif
    00326
    00328 typedef BOOL (*DKC_STD_CALLBACK)(void *peculiar,void *user);
    00329
    00330
    00331 //**********************************************************
    00332 //limits
    00333
    00334 #ifndef ULONGLONG_MAX
    00335 #   define ULONGLONG_MAX DKINGYO_ULONGLONG_MAX
    00336 #endif
    00337 #ifndef LONGLONG_MAX
    00338 #   define LONGLONG_MAX DKINGYO_LONGLONG_MAX
    00339 #endif
    00340 #ifndef LONGLONG_MIN
    00341 #   define LONGLONG_MIN DKINGYO_LONGLONG_MIN
    00342 #endif
    00343
    00344
    00345 #ifndef dkcdMAXPATH
    00346 #   if defined(PATH_MAX)
    00347 #       define dkcdMAXPATH   PATH_MAX
    00348
    00349 #   elif defined(MAX_PATH)
    00350 #       define dkcdMAXPATH   MAX_PATH
    00351
    00352 #   elif  defined(_MAX_PATH)
    00353 #       define dkcdMAXPATH   _MAX_PATH
    00354
    00355 #   else
    00356 #       define dkcdMAXPATH   1024
    00357
    00358 #   endif
    00359 #endif
    00360
    00361 #ifndef dkcdMAXPATH_LEN
    00362 #   define dkcdMAXPATH_LEN dkcdMAXPATH
    00363 #endif
    00364
    00365 /* 何事も例外を考えるのが大切だ。って事でbufferは普通の２倍取得する･･･。（ｵｲ
    00366     追記：
    00367     見事に予想は的中してバッファサイズは約２倍無いと危ない条件がある事が分かった。
    00368     */
    00369
    00370
    00371 #ifndef dkcdMAXPATH_BUFFER
    00372
    00377
    00378 #   define dkcdMAXPATH_BUFFER (dkcdMAXPATH * 2 + 2)
    00379 #endif
    00380
    00381
    00382 #ifndef dkcdMAXPATH_FIXED_SIZE
    00383
    00384 #   define dkcdMAXPATH_FIXED_SIZE 2050
    00385
    00386 #endif
    00387
    00388 #ifndef MAYBE
    00389 #   define MAYBE 2
    00390 #endif
    00391
    00392
    00394 #define dkcmGETBYTE(x, y)       ((x)>>(8*(y)))
    00395 #define dkcmGETBYTE8(x,y)               (uint8)dkcmGETBYTE(x,y)
    00396 #define dkcmGETBYTE16(x,y)              (uint16)dkcmGETBYTE(x,y)
    00397 #define dkcmGETBYTE32(x,y)  (uint32)dkcmGETBYTE8(x,y)
    00398
    00399
    00400 typedef struct dkc_4char{
    00401     signed char mode1,mode2,mode3,mode4;
    00402 }DKC_4CHAR;
    00403
    00404
    00405
    00406
    00407 #ifdef __cplusplus
    00408
    00409 namespace dkutil{
    00410
    00411
    00421
    00422 inline bool SaveBinary(const void *data,size_t size,const char *fname,const char *mode="wb"){//="wb"
    00423     FILE *fp;
    00424     fp = fopen( fname , mode ) ;//wb
    00425     if(fp==NULL) return false;
    00426     fwrite( data , size  , 1 , fp ) ;
    00427     //fwrite( data , sizeof(size)  , 1 , fp ) ;
    00428     fclose( fp ) ;
    00429     return true;
    00430 }
    00431
    00439
    00440 inline bool LoadBinary(void *data,size_t size,const char *fname,const char *mode="rb" ){//="rb"
    00441     FILE *fp ;
    00442     fp = fopen( fname , mode ) ;//rb
    00443     if(fp==NULL)return false;
    00444     fread( data ,  size , 1 , fp ) ;
    00445     //fread( data , sizeof(size)  , 1 , fp ) ;
    00446     fclose( fp ) ;
    00447     return true;
    00448 }
    00449
    00450 inline bool SaveText(const char *text,size_t length,const char *fname,const char *mode="wt"){
    00451     return SaveBinary(text,length,fname,mode);
    00452 }
    00453 inline bool LoadText(char *text,size_t length,const char *fname,const char *mode="rt"){
    00454     return LoadBinary(text,length,fname,mode);
    00455 }
    00456
    00457
    00458
    00459 }//end of dkutil namespace
    00460
    00461
    00462 #else //for c lang
    00463
    00464
    00465 #endif //end of __cplusplus
    00466
    00468 DKC_EXTERN BOOL WINAPI dkcIsNativePathString(const char *s,size_t size);
    00469
    00470
    00471
    00472 /*
    00473 @param OldSize[in] 元のメモリ領域のサイズ
    00474 @param ExpandSize[in] 足りないメモリ領域のサイズ
    00475 @return 多分、理想系のサイズ？カナ？
    00476 @note reallocする時の最適なメモリサイズを計算する。
    00477 (内部実装はちょくちょく変わります。
    00478 */
    00479
    00480 DKC_EXTERN  size_t dkcReallocateSizeFunction(size_t OldSize,size_t ExpandSize);
    00481
    00483 typedef void *( WINAPIV *DKC_ALLOC_FUNC_TYPE)(size_t);
    00485 typedef void (WINAPIV *DKC_FREE_FUNC_TYPE)(void *);
    00486
    00487 DKC_EXTERN void *WINAPIV dkcMallocAdapter(size_t);
    00488
    00489 DKC_EXTERN void WINAPIV dkcFreeAdapter(void *);
    00490
    00491 DKC_EXTERN  void* WINAPIV dkcAllocate(size_t size);
    00492
    00493 DKC_EXTERN  int WINAPIV dkcFree(void **p);
    00494
    00495 DKC_EXTERN void *WINAPIV dkcAllocateFast(size_t size);
    00496
    00497 DKC_EXTERN void *WINAPIV dkcAllocateFill(size_t size,BYTE fill);
    00498
    00499 DKC_EXTERN  int WINAPI dkcReallocate(
    00500     void **NewPtr,size_t NewSize,void **OldPtr
    00501 );
    00502
    00510
    00511 DKC_EXTERN int WINAPI dkcReallocateEx(
    00512     DKC_REALLOC_F_TYPE your_realloc,void **NewPtr,size_t NewSize,
    00513     void **OldPtr
    00514 );
    00515
    00525 DKC_EXTERN int WINAPI dkcReallocateAutoExpand(
    00526     DKC_REALLOC_F_TYPE your_realloc,void **NewPtr,
    00527     void **OldPtr,size_t OldSize,size_t *reallocated_size
    00528 );
    00529
    00533 DKC_EXTERN void WINAPI
    00534     dkcSwap(void *p1,void *p2,size_t size);
    00541 DKC_EXTERN BOOL WINAPI dkcSwapFast(void *p1,void *p2,size_t size);
    00542
    00550 DKC_EXTERN void WINAPI dkcSwap64(ULONGLONG *p1,ULONGLONG *p2,size_t size);
    00551
    00552
    00553 //#define dkcSwap(p1_,p2_,size) dkcSwap64(p1_,p2_,size)
    00554 /*
    00555 #define dkcSwapFast(p1,p2,size) dkcSwap64(p1,p2,size)
    00556 */
    00557
    00558
    00560 DKC_EXTERN BOOL dkcIs_foepn_mode(const char *s);
    00562 DKC_EXTERN FILE * WINAPI dkcFOpen(const char *filename,const char *mode);
    00564 DKC_EXTERN int WINAPI dkcFClose(FILE **ptr);
    00565
    00567 DKC_EXTERN size_t WINAPI dkcFReadAll(void *,size_t size,FILE *fp);
    00569 DKC_EXTERN size_t WINAPI dkcFWriteAll(const void *,size_t size,FILE *fp);
    00571 DKC_EXTERN size_t WINAPI dkcFSize(FILE *fp);
    00572
    00573
    00575 DKC_EXTERN int WINAPI dkcSaveBinary(const void *data,size_t size,const char *fname);
    00577 DKC_EXTERN int WINAPI dkcLoadBinary(void *data,size_t size,const char *fname,size_t *readsize);
    00579 DKC_EXTERN int WINAPI dkcSaveText(const char *text,size_t length,const char *fname);
    00581 DKC_EXTERN int WINAPI dkcLoadText(char *text,size_t length,const char *fname,size_t *readsize);
    00583 DKC_EXTERN BOOL WINAPI dkcCreateEmptyFile(const char *filename);
    00585 DKC_EXTERN int WINAPI dkcInitFileFast( const char *filename );
    00587 DKC_EXTERN  int WINAPI dkcAddLogFile( const char *filename,const char *str , ... );
    00588
    00589 DKC_EXTERN void WINAPI dkcTwoDWORDToULONGLONG(ULONGLONG *dest,DWORD high,DWORD low);
    00590
    00591 DKC_EXTERN void WINAPI dkcULONGLONGToTwoDWORD(DWORD *dhigh,DWORD *dlow,ULONGLONG src);
    00592
    00593 DKC_EXTERN void WINAPI dkcLONGLONGToTwoLONG(LONG *high,LONG *low,LONGLONG src);
    00594
    00595 DKC_EXTERN void WINAPI dkcTwoLONGToLONGLONG(LONGLONG *dest,LONG high,LONG low);
    00596
    00597
    00598
    00599 DKC_EXTERN int WINAPI dkcOutputDebugString(const char *str,...);
    00603 DKC_EXTERN int WINAPI dkcErrorMessage(const char *expression,
    00604                                          const char *filename,size_t line,const char *message,...);
    00605
    00606
    00607
    00608 #if defined(DEBUG) || defined(DKUTIL_DEBUG)
    00609 #   define dkcmNOT_ASSERT(ex) ( (ex) && dkcErrorMessage(#ex,__FILE__,__LINE__,NULL) )
    00610 #   define dkcmASSERT(ex) ( (ex) || dkcErrorMessage(#ex,__FILE__,__LINE__,NULL) )
    00611 #   define dkcmNOT_ASSERT_MESSAGE(ex,mes) ( (ex) && dkcErrorMessage(#ex,__FILE__,__LINE__,mes) )
    00612 #   define dkcmASSERT_MESSAGE(ex,mes) ( (ex) || dkcErrorMessage(#ex,__FILE__,__LINE__,mes) )
    00613 #else
    00614 #   define dkcmNOT_ASSERT_MESSAGE(ex,mes) ((void)0)
    00615 #   define dkcmASSERT_MESSAGE(ex,mes) ((void)0)
    00616 #   define dkcmNOT_ASSERT(ex) ((void)0)
    00617 #   define dkcmASSERT(ex) ((void)0)
    00618 #endif
    00619
    00620 #   define dkcmFORCE_NOT_ASSERT(ex) ( (ex) && dkcErrorMessage(#ex,__FILE__,__LINE__,NULL) )
    00621 #   define dkcmFORCE_ASSERT(ex) ( (ex) || dkcErrorMessage(#ex,__FILE__,__LINE__,NULL) )
    00622 #   define dkcmFORCE_NOT_ASSERT_MESSAGE(ex,mes) ( (ex) && dkcErrorMessage(#ex,__FILE__,__LINE__,mes) )
    00623 #   define dkcmFORCE_ASSERT_MESSAGE(ex,mes) ( (ex) || dkcErrorMessage(#ex,__FILE__,__LINE__,mes) )
    00624
    00626 DKC_EXTERN const char *WINAPI dkcGetPathSep();
    00627
    00632 DKC_EXTERN int dkcDynamicCheckEnvironment(BOOL isForceExit);
    00634 DKC_EXTERN void WINAPI dkcCheckMemoryLeak(BOOL flag);
    00636 DKC_EXTERN BOOL WINAPI dkcIsMMX();
    00637
    00638
    00639
    00640 #define dkcmREVERSE_ENDIAN16(x) ( (USHORT)( (x >> 8) | (x << 8) ) )
    00641
    00642 #define dkcmREVERSE_ENDIAN32(x) \
    00643     ( (x << 24) | ( (x & 0x0000ff00) << 8) | ( (x & 0x00ff0000) >> 8 ) | (x >> 24) )
    00644
    00645 #ifdef WIN32
    00646 #   define dkcmREVERSE_ENDIAN64(x) (\
    00647         (ULONGLONG)dkcReverseEndian32( (DWORD) (x & 0x00000000ffffffff) ) << 32 )\
    00648         | \
    00649         dkcReverseEndian32((DWORD)(x >> 32)\
    00650     )
    00651 #else
    00652 #   define dkcmREVERSE_ENDIAN64(x) dkcReverseEndian64(x)
    00653
    00654 #endif
    00655
    00656 DKC_EXTERN ULONG dkcReverseEndian32(ULONG x);
    00658 DKC_EXTERN ULONGLONG dkcReverseEndian64(ULONGLONG x);
    00660 DKC_EXTERN USHORT dkcReverseEndian16(USHORT x);
    00661
    00663 DKC_EXTERN BOOL dkcIsLittleEndian();
    00665 #define dkcIsBigEndian() (!dkcIsLittleEndian())
    00666
    00667
    00669 DKC_EXTERN BOOL dkcCheckOverflowULONG(ULONG a1,ULONG a2);
    00670
    00671 #define dkcCheckOverflow32(a,b) dkcCheckOverflowULONG(a,b)
    00672
    00673
    00674
    00675 typedef int (WINAPIV *DKC_COMPARE_TYPE)(const void *,const void *);
    00676
    00700
    00701 DKC_EXTERN int WINAPI dkcSelect(void *dest,const void *a_src,size_t n,int k,size_t width ,DKC_COMPARE_TYPE comp);
    00702
    00707 DKC_EXTERN int WINAPI dkcSelectMax(void *dest,const void *a, size_t n,size_t width ,DKC_COMPARE_TYPE comp);
    00712 DKC_EXTERN int WINAPI dkcSelectMin(void *dest,const void *a, size_t n,size_t width ,DKC_COMPARE_TYPE comp);
    00713
    00714
    00715 DKC_INLINE int dkcRotateShiftRightMemoryLogic(void *dest,size_t size,size_t n,void *workbuff,size_t worksize);
    00716
    00717
    00718 DKC_EXTERN int WINAPI dkcRotateShiftRightMemory(void *dest,size_t size,size_t n);
    00719
    00720 /*
    00721 DKC_EXTERN void dkcSetAllocateMode(int flag);
    00722
    00723 DKC_EXTERN void *dkcDebugAlloc
    00724 */
    00725
    00726
    00727
    00728 #if DKC_HAVE_INLINE==1
    00729
    00730 DKC_FORCE_INLINE void *WINAPI dkcSecureFillMemory (void * Destination,size_t Length,uint8 Fill){
    00731     volatile uint8 *vptr = (volatile uint8 *)Destination;
    00732     while(Length){
    00733         *vptr = Fill;
    00734         vptr++;
    00735         Length--;
    00736     }
    00737     return Destination;
    00738 }
    00739
    00740 DKC_FORCE_INLINE void *dkcSecureZeroMemory(void  *ptr, size_t cnt)
    00741 {
    00742     /*volatile char *vptr = (volatile char *)ptr;
    00743     while (cnt) {
    00744         *vptr = 0;
    00745         vptr++;
    00746         cnt--;
    00747     }
    00748     return ptr;*/
    00749     return dkcSecureFillMemory(ptr,cnt,0);
    00750 }
    00751
    00752
    00753 #else
    00754
    00755 // WINAPI ...
    00756
    00757 #endif
    00758
    00759
    00760 #endif //end of include once