Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

60 lignes
1.8 KiB

  1. /* Copyright (c) 2015, Google Inc.
  2. *
  3. * Permission to use, copy, modify, and/or distribute this software for any
  4. * purpose with or without fee is hereby granted, provided that the above
  5. * copyright notice and this permission notice appear in all copies.
  6. *
  7. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  10. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  12. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
  14. #include "internal.h"
  15. #include <stdio.h>
  16. #include <openssl/type_check.h>
  17. int main(int argc, char **argv) {
  18. CRYPTO_refcount_t count = 0;
  19. CRYPTO_refcount_inc(&count);
  20. if (count != 1) {
  21. fprintf(stderr, "Incrementing reference count did not work.\n");
  22. return 1;
  23. }
  24. if (!CRYPTO_refcount_dec_and_test_zero(&count) || count != 0) {
  25. fprintf(stderr, "Decrementing reference count to zero did not work.\n");
  26. return 1;
  27. }
  28. count = CRYPTO_REFCOUNT_MAX;
  29. CRYPTO_refcount_inc(&count);
  30. if (count != CRYPTO_REFCOUNT_MAX) {
  31. fprintf(stderr, "Count did not saturate correctly when incrementing.\n");
  32. return 1;
  33. }
  34. if (CRYPTO_refcount_dec_and_test_zero(&count) ||
  35. count != CRYPTO_REFCOUNT_MAX) {
  36. fprintf(stderr, "Count did not saturate correctly when decrementing.\n");
  37. return 1;
  38. }
  39. count = 2;
  40. if (CRYPTO_refcount_dec_and_test_zero(&count)) {
  41. fprintf(stderr, "Decrementing two resulted in zero!\n");
  42. return 1;
  43. }
  44. if (count != 1) {
  45. fprintf(stderr, "Decrementing two did not produce one!");
  46. return 1;
  47. }
  48. printf("PASS\n");
  49. return 0;
  50. }