- Timestamp:
- Feb 7, 2019, 8:36:33 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/wolfssl/wolfcrypt/wc_port.h
r352 r372 20 20 */ 21 21 22 22 /*! 23 \file wolfssl/wolfcrypt/wc_port.h 24 */ 23 25 24 26 #ifndef WOLF_CRYPT_PORT_H … … 32 34 #endif 33 35 36 /* Detect if compiler supports C99. "NO_WOLF_C99" can be defined in 37 * user_settings.h to disable checking for C99 support. */ 38 #if !defined(WOLF_C99) && defined(__STDC_VERSION__) && \ 39 !defined(WOLFSSL_ARDUINO) && !defined(NO_WOLF_C99) 40 #if __STDC_VERSION__ >= 199901L 41 #define WOLF_C99 42 #endif 43 #endif 34 44 35 45 #ifdef USE_WINDOWS_API … … 65 75 #elif defined(FREESCALE_FREE_RTOS) 66 76 #include "fsl_os_abstraction.h" 77 #elif defined(WOLFSSL_VXWORKS) 78 #include <semLib.h> 67 79 #elif defined(WOLFSSL_uITRON4) 68 80 #include "stddef.h" … … 70 82 #elif defined(WOLFSSL_uTKERNEL2) 71 83 #include "tk/tkernel.h" 84 #elif defined(WOLFSSL_CMSIS_RTOS) 85 #include "cmsis_os.h" 72 86 #elif defined(WOLFSSL_MDK_ARM) 73 87 #if defined(WOLFSSL_MDK5) … … 86 100 #include <rt.h> 87 101 #include <io.h> 102 #elif defined(WOLFSSL_NUCLEUS_1_2) 103 /* NU_DEBUG needed struct access in nucleus_realloc */ 104 #define NU_DEBUG 105 #include "plus/nucleus.h" 106 #include "nucleus.h" 107 #elif defined(WOLFSSL_APACHE_MYNEWT) 108 /* do nothing */ 88 109 #else 89 110 #ifndef SINGLE_THREADED … … 133 154 #elif defined(FREESCALE_FREE_RTOS) 134 155 typedef mutex_t wolfSSL_Mutex; 156 #elif defined(WOLFSSL_VXWORKS) 157 typedef SEM_ID wolfSSL_Mutex; 135 158 #elif defined(WOLFSSL_uITRON4) 136 159 typedef struct wolfSSL_Mutex { … … 157 180 #elif defined(INTIME_RTOS) 158 181 typedef RTHANDLE wolfSSL_Mutex; 182 #elif defined(WOLFSSL_NUCLEUS_1_2) 183 typedef NU_SEMAPHORE wolfSSL_Mutex; 159 184 #else 160 185 #error Need a mutex type in multithreaded mode … … 185 210 #define wolfSSL_CryptHwMutexInit() 0 /* Success */ 186 211 #define wolfSSL_CryptHwMutexLock() 0 /* Success */ 187 #define wolfSSL_CryptHwMutexUnLock() 0 /* Success */212 #define wolfSSL_CryptHwMutexUnLock() (void)0 /* Success */ 188 213 #endif /* WOLFSSL_CRYPT_HW_MUTEX */ 189 214 … … 194 219 WOLFSSL_API int wc_LockMutex(wolfSSL_Mutex*); 195 220 WOLFSSL_API int wc_UnLockMutex(wolfSSL_Mutex*); 221 #if defined(OPENSSL_EXTRA) || defined(HAVE_WEBSERVER) 222 /* dynamiclly set which mutex to use. unlock / lock is controlled by flag */ 223 typedef void (mutex_cb)(int flag, int type, const char* file, int line); 224 225 WOLFSSL_API int wc_LockMutex_ex(int flag, int type, const char* file, int line); 226 WOLFSSL_API int wc_SetMutexCb(mutex_cb* cb); 227 #endif 196 228 197 229 /* main crypto initialization function */ … … 255 287 #define XBADFILE NULL 256 288 #define XFGETS(b,s,f) -2 /* Not ported yet */ 289 #elif defined(WOLFSSL_NUCLEUS_1_2) 290 #include "fal/inc/fal.h" 291 #define XFILE FILE* 292 #define XFOPEN fopen 293 #define XFSEEK fseek 294 #define XFTELL ftell 295 #define XREWIND rewind 296 #define XFREAD fread 297 #define XFWRITE fwrite 298 #define XFCLOSE fclose 299 #define XSEEK_END PSEEK_END 300 #define XBADFILE NULL 301 #elif defined(WOLFSSL_APACHE_MYNEWT) 302 #include <fs/fs.h> 303 #define XFILE struct fs_file* 304 305 #define XFOPEN mynewt_fopen 306 #define XFSEEK mynewt_fseek 307 #define XFTELL mynewt_ftell 308 #define XREWIND mynewt_rewind 309 #define XFREAD mynewt_fread 310 #define XFWRITE mynewt_fwrite 311 #define XFCLOSE mynewt_fclose 312 #define XSEEK_END 2 313 #define XBADFILE NULL 314 #define XFGETS(b,s,f) -2 /* Not ported yet */ 315 #elif defined(WOLFSSL_USER_FILESYSTEM) 316 /* To be defined in user_settings.h */ 257 317 #else 258 318 /* stdio, default case */ … … 275 335 #define XFGETS fgets 276 336 277 #if !defined(USE_WINDOWS_API) && !defined(NO_WOLFSSL_DIR) 337 #if !defined(USE_WINDOWS_API) && !defined(NO_WOLFSSL_DIR)\ 338 && !defined(WOLFSSL_NUCLEUS) && !defined(WOLFSSL_NUCLEUS_1_2) 278 339 #include <dirent.h> 279 340 #include <unistd.h> … … 289 350 #endif 290 351 291 #if !defined(NO_WOLFSSL_DIR) 352 #if !defined(NO_WOLFSSL_DIR) && !defined(WOLFSSL_NUCLEUS) && \ 353 !defined(WOLFSSL_NUCLEUS_1_2) 292 354 typedef struct ReadDirCtx { 293 355 #ifdef USE_WINDOWS_API … … 302 364 } ReadDirCtx; 303 365 366 #define WC_READDIR_NOFILE -1 367 304 368 WOLFSSL_API int wc_ReadDirFirst(ReadDirCtx* ctx, const char* path, char** name); 305 369 WOLFSSL_API int wc_ReadDirNext(ReadDirCtx* ctx, const char* path, char** name); … … 308 372 309 373 #endif /* !NO_FILESYSTEM */ 310 311 #ifdef USE_WOLF_STRTOK312 WOLFSSL_LOCAL char* wc_strtok(char *str, const char *delim, char **nextp);313 #endif314 374 315 375 /* Windows API defines its own min() macro. */ … … 323 383 #endif /* USE_WINDOWS_API */ 324 384 385 /* Time functions */ 386 #ifndef NO_ASN_TIME 387 #if defined(USER_TIME) 388 /* Use our gmtime and time_t/struct tm types. 389 Only needs seconds since EPOCH using XTIME function. 390 time_t XTIME(time_t * timer) {} 391 */ 392 #define WOLFSSL_GMTIME 393 #define USE_WOLF_TM 394 #define USE_WOLF_TIME_T 395 396 #elif defined(TIME_OVERRIDES) 397 /* Override XTIME() and XGMTIME() functionality. 398 Requires user to provide these functions: 399 time_t XTIME(time_t * timer) {} 400 struct tm* XGMTIME(const time_t* timer, struct tm* tmp) {} 401 */ 402 #ifndef HAVE_TIME_T_TYPE 403 #define USE_WOLF_TIME_T 404 #endif 405 #ifndef HAVE_TM_TYPE 406 #define USE_WOLF_TM 407 #endif 408 #define NEED_TMP_TIME 409 410 #elif defined(HAVE_RTP_SYS) 411 #include "os.h" /* dc_rtc_api needs */ 412 #include "dc_rtc_api.h" /* to get current time */ 413 414 /* uses parital <time.h> structures */ 415 #define XTIME(tl) (0) 416 #define XGMTIME(c, t) rtpsys_gmtime((c)) 417 418 #elif defined(MICRIUM) 419 #include <clk.h> 420 #include <time.h> 421 #define XTIME(t1) micrium_time((t1)) 422 #define WOLFSSL_GMTIME 423 424 #elif defined(MICROCHIP_TCPIP_V5) || defined(MICROCHIP_TCPIP) 425 #include <time.h> 426 #define XTIME(t1) pic32_time((t1)) 427 #define XGMTIME(c, t) gmtime((c)) 428 429 #elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) 430 #ifdef FREESCALE_MQX_4_0 431 #include <time.h> 432 extern time_t mqx_time(time_t* timer); 433 #else 434 #define HAVE_GMTIME_R 435 #endif 436 #define XTIME(t1) mqx_time((t1)) 437 438 #elif defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS) || defined(FREESCALE_KSDK_FREERTOS) 439 #include <time.h> 440 #ifndef XTIME 441 /*extern time_t ksdk_time(time_t* timer);*/ 442 #define XTIME(t1) ksdk_time((t1)) 443 #endif 444 #define XGMTIME(c, t) gmtime((c)) 445 446 #elif defined(WOLFSSL_ATMEL) && defined(WOLFSSL_ATMEL_TIME) 447 #define XTIME(t1) atmel_get_curr_time_and_date((t1)) 448 #define WOLFSSL_GMTIME 449 #define USE_WOLF_TM 450 #define USE_WOLF_TIME_T 451 452 #elif defined(IDIRECT_DEV_TIME) 453 /*Gets the timestamp from cloak software owned by VT iDirect 454 in place of time() from <time.h> */ 455 #include <time.h> 456 #define XTIME(t1) idirect_time((t1)) 457 #define XGMTIME(c, t) gmtime((c)) 458 459 #elif defined(_WIN32_WCE) 460 #include <windows.h> 461 #define XTIME(t1) windows_time((t1)) 462 #define WOLFSSL_GMTIME 463 464 #elif defined(WOLFSSL_APACHE_MYNEWT) 465 #include "os/os_time.h" 466 #define XTIME(t1) mynewt_time((t1)) 467 #define WOLFSSL_GMTIME 468 #define USE_WOLF_TM 469 #define USE_WOLF_TIME_T 470 #else 471 /* default */ 472 /* uses complete <time.h> facility */ 473 #include <time.h> 474 #if defined(HAVE_SYS_TIME_H) 475 #include <sys/time.h> 476 #endif 477 478 /* PowerPC time_t is int */ 479 #ifdef __PPC__ 480 #define TIME_T_NOT_64BIT 481 #endif 482 #endif 483 484 #ifdef SIZEOF_TIME_T 485 /* check if size of time_t from autoconf is less than 8 bytes (64bits) */ 486 #if SIZEOF_TIME_T < 8 487 #undef TIME_T_NOT_64BIT 488 #define TIME_T_NOT_64BIT 489 #endif 490 #endif 491 #ifdef TIME_T_NOT_LONG 492 /* one old reference to TIME_T_NOT_LONG in GCC-ARM example README 493 * this keeps support for the old macro name */ 494 #undef TIME_T_NOT_64BIT 495 #define TIME_T_NOT_64BIT 496 #endif 497 498 /* Map default time functions */ 499 #if !defined(XTIME) && !defined(TIME_OVERRIDES) && !defined(USER_TIME) 500 #define XTIME(tl) time((tl)) 501 #endif 502 #if !defined(XGMTIME) && !defined(TIME_OVERRIDES) 503 #if defined(WOLFSSL_GMTIME) || !defined(HAVE_GMTIME_R) || defined(WOLF_C99) 504 #define XGMTIME(c, t) gmtime((c)) 505 #else 506 #define XGMTIME(c, t) gmtime_r((c), (t)) 507 #define NEED_TMP_TIME 508 #endif 509 #endif 510 #if !defined(XVALIDATE_DATE) && !defined(HAVE_VALIDATE_DATE) 511 #define USE_WOLF_VALIDDATE 512 #define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t)) 513 #endif 514 515 /* wolf struct tm and time_t */ 516 #if defined(USE_WOLF_TM) 517 struct tm { 518 int tm_sec; /* seconds after the minute [0-60] */ 519 int tm_min; /* minutes after the hour [0-59] */ 520 int tm_hour; /* hours since midnight [0-23] */ 521 int tm_mday; /* day of the month [1-31] */ 522 int tm_mon; /* months since January [0-11] */ 523 int tm_year; /* years since 1900 */ 524 int tm_wday; /* days since Sunday [0-6] */ 525 int tm_yday; /* days since January 1 [0-365] */ 526 int tm_isdst; /* Daylight Savings Time flag */ 527 long tm_gmtoff; /* offset from CUT in seconds */ 528 char *tm_zone; /* timezone abbreviation */ 529 }; 530 #endif /* USE_WOLF_TM */ 531 #if defined(USE_WOLF_TIME_T) 532 typedef long time_t; 533 #endif 534 #if defined(USE_WOLF_SUSECONDS_T) 535 typedef long suseconds_t; 536 #endif 537 #if defined(USE_WOLF_TIMEVAL_T) 538 struct timeval 539 { 540 time_t tv_sec; 541 suseconds_t tv_usec; 542 }; 543 #endif 544 545 /* forward declarations */ 546 #if defined(USER_TIME) 547 struct tm* gmtime(const time_t* timer); 548 extern time_t XTIME(time_t * timer); 549 550 #ifdef STACK_TRAP 551 /* for stack trap tracking, don't call os gmtime on OS X/linux, 552 uses a lot of stack spce */ 553 extern time_t time(time_t * timer); 554 #define XTIME(tl) time((tl)) 555 #endif /* STACK_TRAP */ 556 557 #elif defined(TIME_OVERRIDES) 558 extern time_t XTIME(time_t * timer); 559 extern struct tm* XGMTIME(const time_t* timer, struct tm* tmp); 560 #elif defined(WOLFSSL_GMTIME) 561 struct tm* gmtime(const time_t* timer); 562 #endif 563 #endif /* NO_ASN_TIME */ 564 565 #ifndef WOLFSSL_LEANPSK 566 char* mystrnstr(const char* s1, const char* s2, unsigned int n); 567 #endif 568 569 #ifndef FILE_BUFFER_SIZE 570 #define FILE_BUFFER_SIZE 1024 /* default static file buffer size for input, 571 will use dynamic buffer if not big enough */ 572 #endif 573 325 574 326 575 #ifdef __cplusplus
Note:
See TracChangeset
for help on using the changeset viewer.