diff options
Diffstat (limited to 'src/include/gnunet_common.h')
-rw-r--r-- | src/include/gnunet_common.h | 558 |
1 files changed, 314 insertions, 244 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 4472d3ee8..c5885e7c4 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2006-2021 GNUnet e.V. | 3 | Copyright (C) 2006-2022 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | under the terms of the GNU Affero General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
@@ -19,6 +19,10 @@ | |||
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @addtogroup libgnunetutil | ||
23 | * Multi-function utilities library for GNUnet programs | ||
24 | * @{ | ||
25 | * | ||
22 | * @file include/gnunet_common.h | 26 | * @file include/gnunet_common.h |
23 | * @brief commonly used definitions; globals in this file | 27 | * @brief commonly used definitions; globals in this file |
24 | * are exempt from the rule that the module name ("common") | 28 | * are exempt from the rule that the module name ("common") |
@@ -36,28 +40,38 @@ | |||
36 | #ifndef GNUNET_COMMON_H | 40 | #ifndef GNUNET_COMMON_H |
37 | #define GNUNET_COMMON_H | 41 | #define GNUNET_COMMON_H |
38 | 42 | ||
43 | #include "gnunet_config.h" | ||
44 | |||
45 | #include <stdbool.h> | ||
39 | #include <stdlib.h> | 46 | #include <stdlib.h> |
40 | #if HAVE_SYS_SOCKET_H | ||
41 | #include <sys/socket.h> | 47 | #include <sys/socket.h> |
42 | #endif | 48 | #include <sys/un.h> |
43 | #if HAVE_NETINET_IN_H | ||
44 | #include <netinet/in.h> | 49 | #include <netinet/in.h> |
45 | #endif | 50 | #include <arpa/inet.h> |
46 | #ifdef HAVE_STDINT_H | ||
47 | #include <stdint.h> | 51 | #include <stdint.h> |
48 | #endif | ||
49 | #ifdef HAVE_STDARG_H | ||
50 | #include <stdarg.h> | 52 | #include <stdarg.h> |
51 | #endif | ||
52 | #ifdef HAVE_SYS_TYPES_H | ||
53 | #include <sys/types.h> | 53 | #include <sys/types.h> |
54 | #endif | ||
55 | #ifdef HAVE_SYS_SOCKET_H | ||
56 | #include <sys/socket.h> | ||
57 | #endif | ||
58 | 54 | ||
55 | #if defined(__FreeBSD__) | ||
56 | |||
57 | #include <sys/endian.h> | ||
58 | #define bswap_32(x) bswap32 (x) | ||
59 | #define bswap_64(x) bswap64 (x) | ||
60 | |||
61 | #elif defined(__OpenBSD__) | ||
62 | |||
63 | #define bswap_32(x) swap32 (x) | ||
64 | #define bswap_64(x) swap64 (x) | ||
59 | 65 | ||
60 | #ifdef HAVE_BYTESWAP_H | 66 | #elif defined(__NetBSD__) |
67 | |||
68 | #include <machine/bswap.h> | ||
69 | #if defined(__BSWAP_RENAME) && ! defined(__bswap_32) | ||
70 | #define bswap_32(x) bswap32 (x) | ||
71 | #define bswap_64(x) bswap64 (x) | ||
72 | #endif | ||
73 | |||
74 | #elif defined(__linux__) || defined(GNU) | ||
61 | #include <byteswap.h> | 75 | #include <byteswap.h> |
62 | #endif | 76 | #endif |
63 | 77 | ||
@@ -132,12 +146,6 @@ enum GNUNET_GenericReturnValue | |||
132 | #endif | 146 | #endif |
133 | 147 | ||
134 | /** | 148 | /** |
135 | * wrap va_arg for enums | ||
136 | */ | ||
137 | #define GNUNET_VA_ARG_ENUM(va, X) ((enum X) va_arg (va, int)) | ||
138 | |||
139 | |||
140 | /** | ||
141 | * @ingroup logging | 149 | * @ingroup logging |
142 | * define #GNUNET_EXTRA_LOGGING if using this header outside the GNUnet source | 150 | * define #GNUNET_EXTRA_LOGGING if using this header outside the GNUnet source |
143 | * tree where gnunet_config.h is unavailable | 151 | * tree where gnunet_config.h is unavailable |
@@ -150,8 +158,7 @@ enum GNUNET_GenericReturnValue | |||
150 | * Endian operations | 158 | * Endian operations |
151 | */ | 159 | */ |
152 | 160 | ||
153 | #if __BYTE_ORDER == __LITTLE_ENDIAN | 161 | #if defined(bswap_16) || defined(bswap_32) || defined(bswap_64) |
154 | #ifdef HAVE_BYTESWAP_H | ||
155 | #define BYTE_SWAP_16(x) bswap_16 (x) | 162 | #define BYTE_SWAP_16(x) bswap_16 (x) |
156 | #define BYTE_SWAP_32(x) bswap_32 (x) | 163 | #define BYTE_SWAP_32(x) bswap_32 (x) |
157 | #define BYTE_SWAP_64(x) bswap_64 (x) | 164 | #define BYTE_SWAP_64(x) bswap_64 (x) |
@@ -159,17 +166,22 @@ enum GNUNET_GenericReturnValue | |||
159 | #define BYTE_SWAP_16(x) ((((x) & 0x00ff) << 8) | (((x) & 0xff00) >> 8)) | 166 | #define BYTE_SWAP_16(x) ((((x) & 0x00ff) << 8) | (((x) & 0xff00) >> 8)) |
160 | 167 | ||
161 | #define BYTE_SWAP_32(x) \ | 168 | #define BYTE_SWAP_32(x) \ |
162 | ((((x) & 0x000000ffU) << 24) | (((x) & 0x0000ff00U) << 8) \ | 169 | ((((x) & 0x000000ffU) << 24) | (((x) & 0x0000ff00U) << 8) \ |
163 | | (((x) & 0x00ff0000U) >> 8) | (((x) & 0xff000000U) >> 24)) | 170 | | (((x) & 0x00ff0000U) >> 8) | (((x) & 0xff000000U) >> 24)) |
164 | 171 | ||
165 | #define BYTE_SWAP_64(x) \ | 172 | #define BYTE_SWAP_64(x) \ |
166 | ((((x) & 0x00000000000000ffUL) << 56) | (((x) & 0x000000000000ff00UL) << 40) \ | 173 | ((((x) & 0x00000000000000ffUL) << 56) | (((x) & 0x000000000000ff00UL) << \ |
167 | | (((x) & 0x0000000000ff0000UL) << 24) | (((x) & 0x00000000ff000000UL) << 8) \ | 174 | 40) \ |
168 | | (((x) & 0x000000ff00000000UL) >> 8) | (((x) & 0x0000ff0000000000UL) >> 24) \ | 175 | | (((x) & 0x0000000000ff0000UL) << 24) | (((x) & 0x00000000ff000000UL) \ |
169 | | (((x) & 0x00ff000000000000UL) >> 40) | (((x) & 0xff00000000000000UL) >> \ | 176 | << 8) \ |
170 | 56)) | 177 | | (((x) & 0x000000ff00000000UL) >> 8) | (((x) & 0x0000ff0000000000UL) \ |
178 | >> 24) \ | ||
179 | | (((x) & 0x00ff000000000000UL) >> 40) | (((x) & 0xff00000000000000UL) \ | ||
180 | >> \ | ||
181 | 56)) | ||
171 | #endif | 182 | #endif |
172 | 183 | ||
184 | #if __BYTE_ORDER == __LITTLE_ENDIAN | ||
173 | #define GNUNET_htobe16(x) BYTE_SWAP_16 (x) | 185 | #define GNUNET_htobe16(x) BYTE_SWAP_16 (x) |
174 | #define GNUNET_htole16(x) (x) | 186 | #define GNUNET_htole16(x) (x) |
175 | #define GNUNET_be16toh(x) BYTE_SWAP_16 (x) | 187 | #define GNUNET_be16toh(x) BYTE_SWAP_16 (x) |
@@ -471,7 +483,7 @@ GNUNET_get_log_call_status (int caller_level, | |||
471 | 483 | ||
472 | #endif | 484 | #endif |
473 | 485 | ||
474 | 486 | /* *INDENT-OFF* */ | |
475 | /** | 487 | /** |
476 | * @ingroup logging | 488 | * @ingroup logging |
477 | * Main log function. | 489 | * Main log function. |
@@ -481,13 +493,15 @@ GNUNET_get_log_call_status (int caller_level, | |||
481 | * @param ... arguments for format string | 493 | * @param ... arguments for format string |
482 | */ | 494 | */ |
483 | void | 495 | void |
484 | GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message, ...) | 496 | GNUNET_log_nocheck (enum GNUNET_ErrorType kind, |
497 | const char *message, | ||
498 | ...) | ||
485 | __attribute__ ((format (printf, 2, 3))); | 499 | __attribute__ ((format (printf, 2, 3))); |
486 | 500 | ||
487 | /* from glib */ | 501 | /* from glib */ |
488 | #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) | 502 | #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) |
489 | #define _GNUNET_BOOLEAN_EXPR(expr) \ | 503 | #define _GNUNET_BOOLEAN_EXPR(expr) \ |
490 | __extension__ ({ \ | 504 | __extension__ ({ \ |
491 | int _gnunet_boolean_var_; \ | 505 | int _gnunet_boolean_var_; \ |
492 | if (expr) \ | 506 | if (expr) \ |
493 | _gnunet_boolean_var_ = 1; \ | 507 | _gnunet_boolean_var_ = 1; \ |
@@ -505,6 +519,7 @@ __attribute__ ((format (printf, 2, 3))); | |||
505 | #if ! defined(GNUNET_LOG_CALL_STATUS) | 519 | #if ! defined(GNUNET_LOG_CALL_STATUS) |
506 | #define GNUNET_LOG_CALL_STATUS -1 | 520 | #define GNUNET_LOG_CALL_STATUS -1 |
507 | #endif | 521 | #endif |
522 | /* *INDENT-ON* */ | ||
508 | 523 | ||
509 | 524 | ||
510 | /** | 525 | /** |
@@ -526,56 +541,56 @@ __attribute__ ((format (printf, 3, 4))); | |||
526 | 541 | ||
527 | #if ! defined(GNUNET_CULL_LOGGING) | 542 | #if ! defined(GNUNET_CULL_LOGGING) |
528 | #define GNUNET_log_from(kind, comp, ...) \ | 543 | #define GNUNET_log_from(kind, comp, ...) \ |
529 | do \ | 544 | do \ |
530 | { \ | 545 | { \ |
531 | static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \ | 546 | static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \ |
532 | if ((GNUNET_EXTRA_LOGGING > 0) || \ | 547 | if ((GNUNET_EXTRA_LOGGING > 0) || \ |
533 | ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ | 548 | ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ |
534 | { \ | 549 | { \ |
535 | if (GN_UNLIKELY (log_call_enabled == -1)) \ | 550 | if (GN_UNLIKELY (log_call_enabled == -1)) \ |
536 | log_call_enabled = \ | 551 | log_call_enabled = \ |
537 | GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \ | 552 | GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \ |
538 | (comp), \ | 553 | (comp), \ |
539 | __FILE__, \ | 554 | __FILE__, \ |
540 | __FUNCTION__, \ | 555 | __FUNCTION__, \ |
541 | __LINE__); \ | 556 | __LINE__); \ |
542 | if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \ | 557 | if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \ |
543 | { \ | 558 | { \ |
544 | GNUNET_log_skip (-1, GNUNET_NO); \ | 559 | GNUNET_log_skip (-1, GNUNET_NO); \ |
545 | } \ | 560 | } \ |
546 | else \ | 561 | else \ |
547 | { \ | 562 | { \ |
548 | if (GN_UNLIKELY (log_call_enabled)) \ | 563 | if (GN_UNLIKELY (log_call_enabled)) \ |
549 | GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \ | 564 | GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \ |
550 | } \ | 565 | } \ |
551 | } \ | 566 | } \ |
552 | } while (0) | 567 | } while (0) |
553 | 568 | ||
554 | #define GNUNET_log(kind, ...) \ | 569 | #define GNUNET_log(kind, ...) \ |
555 | do \ | 570 | do \ |
556 | { \ | 571 | { \ |
557 | static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \ | 572 | static int log_call_enabled = GNUNET_LOG_CALL_STATUS; \ |
558 | if ((GNUNET_EXTRA_LOGGING > 0) || \ | 573 | if ((GNUNET_EXTRA_LOGGING > 0) || \ |
559 | ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ | 574 | ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) \ |
560 | { \ | 575 | { \ |
561 | if (GN_UNLIKELY (log_call_enabled == -1)) \ | 576 | if (GN_UNLIKELY (log_call_enabled == -1)) \ |
562 | log_call_enabled = \ | 577 | log_call_enabled = \ |
563 | GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \ | 578 | GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \ |
564 | NULL, \ | 579 | NULL, \ |
565 | __FILE__, \ | 580 | __FILE__, \ |
566 | __FUNCTION__, \ | 581 | __FUNCTION__, \ |
567 | __LINE__); \ | 582 | __LINE__); \ |
568 | if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \ | 583 | if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \ |
569 | { \ | 584 | { \ |
570 | GNUNET_log_skip (-1, GNUNET_NO); \ | 585 | GNUNET_log_skip (-1, GNUNET_NO); \ |
571 | } \ | 586 | } \ |
572 | else \ | 587 | else \ |
573 | { \ | 588 | { \ |
574 | if (GN_UNLIKELY (log_call_enabled)) \ | 589 | if (GN_UNLIKELY (log_call_enabled)) \ |
575 | GNUNET_log_nocheck ((kind), __VA_ARGS__); \ | 590 | GNUNET_log_nocheck ((kind), __VA_ARGS__); \ |
576 | } \ | 591 | } \ |
577 | } \ | 592 | } \ |
578 | } while (0) | 593 | } while (0) |
579 | #else | 594 | #else |
580 | #define GNUNET_log(...) | 595 | #define GNUNET_log(...) |
581 | #define GNUNET_log_from(...) | 596 | #define GNUNET_log_from(...) |
@@ -623,6 +638,31 @@ GNUNET_abort_ (void) GNUNET_NORETURN; | |||
623 | 638 | ||
624 | 639 | ||
625 | /** | 640 | /** |
641 | * Convert a buffer to an 8-character string | ||
642 | * representative of the contents. This is used | ||
643 | * for logging binary data when debugging. | ||
644 | * | ||
645 | * @param buf buffer to log | ||
646 | * @param buf_size number of bytes in @a buf | ||
647 | * @return text representation of buf, valid until next | ||
648 | * call to this function | ||
649 | */ | ||
650 | const char * | ||
651 | GNUNET_b2s (const void *buf, | ||
652 | size_t buf_size); | ||
653 | |||
654 | |||
655 | /** | ||
656 | * Convert a fixed-sized object to a string using | ||
657 | * #GNUNET_b2s(). | ||
658 | * | ||
659 | * @param obj address of object to convert | ||
660 | * @return string representing the binary obj buffer | ||
661 | */ | ||
662 | #define GNUNET_B2S(obj) GNUNET_b2s ((obj), sizeof (*(obj))) | ||
663 | |||
664 | |||
665 | /** | ||
626 | * @ingroup logging | 666 | * @ingroup logging |
627 | * Ignore the next @a n calls to the log function. | 667 | * Ignore the next @a n calls to the log function. |
628 | * | 668 | * |
@@ -642,8 +682,10 @@ GNUNET_log_skip (int n, int check_reset); | |||
642 | * @param logfile change logging to logfile (use NULL to keep stderr) | 682 | * @param logfile change logging to logfile (use NULL to keep stderr) |
643 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if logfile could not be opened | 683 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if logfile could not be opened |
644 | */ | 684 | */ |
645 | int | 685 | enum GNUNET_GenericReturnValue |
646 | GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile); | 686 | GNUNET_log_setup (const char *comp, |
687 | const char *loglevel, | ||
688 | const char *logfile); | ||
647 | 689 | ||
648 | 690 | ||
649 | /** | 691 | /** |
@@ -657,7 +699,8 @@ GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile); | |||
657 | * @param logger_cls closure for @a logger | 699 | * @param logger_cls closure for @a logger |
658 | */ | 700 | */ |
659 | void | 701 | void |
660 | GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls); | 702 | GNUNET_logger_add (GNUNET_Logger logger, |
703 | void *logger_cls); | ||
661 | 704 | ||
662 | 705 | ||
663 | /** | 706 | /** |
@@ -668,7 +711,8 @@ GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls); | |||
668 | * @param logger_cls closure for @a logger | 711 | * @param logger_cls closure for @a logger |
669 | */ | 712 | */ |
670 | void | 713 | void |
671 | GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls); | 714 | GNUNET_logger_remove (GNUNET_Logger logger, |
715 | void *logger_cls); | ||
672 | 716 | ||
673 | 717 | ||
674 | /** | 718 | /** |
@@ -883,36 +927,37 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
883 | * @ingroup logging | 927 | * @ingroup logging |
884 | * Use this for fatal errors that cannot be handled | 928 | * Use this for fatal errors that cannot be handled |
885 | */ | 929 | */ |
886 | #if __GNUC__ >= 6 || __clang_major__ >= 6 | 930 | #if __GNUC__ >= 6 || __clang_major__ >= 6 |
887 | #define GNUNET_assert(cond) \ | 931 | #define GNUNET_assert(cond) \ |
888 | do \ | 932 | do \ |
889 | { \ | 933 | { \ |
890 | _Pragma("GCC diagnostic push") \ | 934 | _Pragma("GCC diagnostic push") \ |
891 | _Pragma("GCC diagnostic ignored \"-Wtautological-compare\"") \ | 935 | _Pragma("GCC diagnostic ignored \"-Wtautological-compare\"") \ |
892 | if (! (cond)) \ | 936 | if (! (cond)) \ |
893 | { \ | 937 | { \ |
894 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ | 938 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ |
895 | dgettext ("gnunet", "Assertion failed at %s:%d. Aborting.\n"), \ | 939 | dgettext ("gnunet", "Assertion failed at %s:%d. Aborting.\n"), \ |
896 | __FILE__, \ | 940 | __FILE__, \ |
897 | __LINE__); \ | 941 | __LINE__); \ |
898 | GNUNET_abort_ (); \ | 942 | GNUNET_abort_ (); \ |
899 | } \ | 943 | } \ |
900 | _Pragma("GCC diagnostic pop") \ | 944 | _Pragma("GCC diagnostic pop") \ |
901 | } while (0) | 945 | } while (0) |
902 | #else | 946 | #else |
903 | /* older GCC/clangs do not support -Wtautological-compare */ | 947 | /* older GCC/clangs do not support -Wtautological-compare */ |
904 | #define GNUNET_assert(cond) \ | 948 | #define GNUNET_assert(cond) \ |
905 | do \ | 949 | do \ |
906 | { \ | 950 | { \ |
907 | if (! (cond)) \ | 951 | if (! (cond)) \ |
908 | { \ | 952 | { \ |
909 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ | 953 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ |
910 | dgettext ("gnunet", "Assertion failed at %s:%d. Aborting.\n"), \ | 954 | dgettext ("gnunet", \ |
911 | __FILE__, \ | 955 | "Assertion failed at %s:%d. Aborting.\n"), \ |
912 | __LINE__); \ | 956 | __FILE__, \ |
913 | GNUNET_abort_ (); \ | 957 | __LINE__); \ |
914 | } \ | 958 | GNUNET_abort_ (); \ |
915 | } while (0) | 959 | } \ |
960 | } while (0) | ||
916 | #endif | 961 | #endif |
917 | 962 | ||
918 | /** | 963 | /** |
@@ -920,17 +965,18 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
920 | * Use this for fatal errors that cannot be handled | 965 | * Use this for fatal errors that cannot be handled |
921 | */ | 966 | */ |
922 | #define GNUNET_assert_at(cond, f, l) \ | 967 | #define GNUNET_assert_at(cond, f, l) \ |
923 | do \ | 968 | do \ |
924 | { \ | 969 | { \ |
925 | if (! (cond)) \ | 970 | if (! (cond)) \ |
926 | { \ | 971 | { \ |
927 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ | 972 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ |
928 | dgettext ("gnunet", "Assertion failed at %s:%d. Aborting.\n"), \ | 973 | dgettext ("gnunet", \ |
929 | f, \ | 974 | "Assertion failed at %s:%d. Aborting.\n"), \ |
930 | l); \ | 975 | f, \ |
931 | GNUNET_abort_ (); \ | 976 | l); \ |
932 | } \ | 977 | GNUNET_abort_ (); \ |
933 | } while (0) | 978 | } \ |
979 | } while (0) | ||
934 | 980 | ||
935 | 981 | ||
936 | /** | 982 | /** |
@@ -941,21 +987,23 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
941 | * @param comp Component string to use for logging | 987 | * @param comp Component string to use for logging |
942 | */ | 988 | */ |
943 | #define GNUNET_assert_from(cond, comp) \ | 989 | #define GNUNET_assert_from(cond, comp) \ |
944 | do \ | 990 | do \ |
945 | { \ | 991 | { \ |
946 | if (! (cond)) \ | 992 | if (! (cond)) \ |
947 | { \ | 993 | { \ |
948 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, \ | 994 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, \ |
949 | comp, \ | 995 | comp, \ |
950 | dgettext ("gnunet", "Assertion failed at %s:%d. Aborting.\n"), \ | 996 | dgettext ("gnunet", \ |
951 | __FILE__, \ | 997 | "Assertion failed at %s:%d. Aborting.\n") \ |
952 | __LINE__); \ | 998 | , \ |
953 | GNUNET_abort_ (); \ | 999 | __FILE__, \ |
954 | } \ | 1000 | __LINE__); \ |
955 | } while (0) | 1001 | GNUNET_abort_ (); \ |
956 | 1002 | } \ | |
957 | 1003 | } while (0) | |
958 | #if HAVE_STATIC_ASSERT | 1004 | |
1005 | |||
1006 | #ifdef _Static_assert | ||
959 | /** | 1007 | /** |
960 | * Assertion to be checked (if supported by C compiler) at | 1008 | * Assertion to be checked (if supported by C compiler) at |
961 | * compile time, otherwise checked at runtime and resulting | 1009 | * compile time, otherwise checked at runtime and resulting |
@@ -983,16 +1031,16 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
983 | * not fatal (can be handled) but should not occur. | 1031 | * not fatal (can be handled) but should not occur. |
984 | */ | 1032 | */ |
985 | #define GNUNET_break(cond) \ | 1033 | #define GNUNET_break(cond) \ |
986 | do \ | 1034 | do \ |
987 | { \ | 1035 | { \ |
988 | if (! (cond)) \ | 1036 | if (! (cond)) \ |
989 | { \ | 1037 | { \ |
990 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ | 1038 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \ |
991 | dgettext ("gnunet", "Assertion failed at %s:%d.\n"), \ | 1039 | dgettext ("gnunet", "Assertion failed at %s:%d.\n"), \ |
992 | __FILE__, \ | 1040 | __FILE__, \ |
993 | __LINE__); \ | 1041 | __LINE__); \ |
994 | } \ | 1042 | } \ |
995 | } while (0) | 1043 | } while (0) |
996 | 1044 | ||
997 | 1045 | ||
998 | /** | 1046 | /** |
@@ -1005,16 +1053,17 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
1005 | * development and testing. "OP == other peer". | 1053 | * development and testing. "OP == other peer". |
1006 | */ | 1054 | */ |
1007 | #define GNUNET_break_op(cond) \ | 1055 | #define GNUNET_break_op(cond) \ |
1008 | do \ | 1056 | do \ |
1009 | { \ | 1057 | { \ |
1010 | if (! (cond)) \ | 1058 | if (! (cond)) \ |
1011 | { \ | 1059 | { \ |
1012 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, \ | 1060 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, \ |
1013 | dgettext ("gnunet", "External protocol violation detected at %s:%d.\n"), \ | 1061 | dgettext ("gnunet", \ |
1014 | __FILE__, \ | 1062 | "External protocol violation detected at %s:%d.\n"), \ |
1015 | __LINE__); \ | 1063 | __FILE__, \ |
1016 | } \ | 1064 | __LINE__); \ |
1017 | } while (0) | 1065 | } \ |
1066 | } while (0) | ||
1018 | 1067 | ||
1019 | 1068 | ||
1020 | /** | 1069 | /** |
@@ -1024,15 +1073,16 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
1024 | * by strerror(errno). | 1073 | * by strerror(errno). |
1025 | */ | 1074 | */ |
1026 | #define GNUNET_log_strerror(level, cmd) \ | 1075 | #define GNUNET_log_strerror(level, cmd) \ |
1027 | do \ | 1076 | do \ |
1028 | { \ | 1077 | { \ |
1029 | GNUNET_log (level, \ | 1078 | GNUNET_log (level, \ |
1030 | dgettext ("gnunet", "`%s' failed at %s:%d with error: %s\n"), \ | 1079 | dgettext ("gnunet", \ |
1031 | cmd, \ | 1080 | "`%s' failed at %s:%d with error: %s\n"), \ |
1032 | __FILE__, \ | 1081 | cmd, \ |
1033 | __LINE__, \ | 1082 | __FILE__, \ |
1034 | strerror (errno)); \ | 1083 | __LINE__, \ |
1035 | } while (0) | 1084 | strerror (errno)); \ |
1085 | } while (0) | ||
1036 | 1086 | ||
1037 | 1087 | ||
1038 | /** | 1088 | /** |
@@ -1042,16 +1092,17 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
1042 | * by strerror(errno). | 1092 | * by strerror(errno). |
1043 | */ | 1093 | */ |
1044 | #define GNUNET_log_from_strerror(level, component, cmd) \ | 1094 | #define GNUNET_log_from_strerror(level, component, cmd) \ |
1045 | do \ | 1095 | do \ |
1046 | { \ | 1096 | { \ |
1047 | GNUNET_log_from (level, \ | 1097 | GNUNET_log_from (level, \ |
1048 | component, \ | 1098 | component, \ |
1049 | dgettext ("gnunet", "`%s' failed at %s:%d with error: %s\n"), \ | 1099 | dgettext ("gnunet", \ |
1050 | cmd, \ | 1100 | "`%s' failed at %s:%d with error: %s\n"), \ |
1051 | __FILE__, \ | 1101 | cmd, \ |
1052 | __LINE__, \ | 1102 | __FILE__, \ |
1053 | strerror (errno)); \ | 1103 | __LINE__, \ |
1054 | } while (0) | 1104 | strerror (errno)); \ |
1105 | } while (0) | ||
1055 | 1106 | ||
1056 | 1107 | ||
1057 | /** | 1108 | /** |
@@ -1061,16 +1112,17 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
1061 | * by strerror(errno). | 1112 | * by strerror(errno). |
1062 | */ | 1113 | */ |
1063 | #define GNUNET_log_strerror_file(level, cmd, filename) \ | 1114 | #define GNUNET_log_strerror_file(level, cmd, filename) \ |
1064 | do \ | 1115 | do \ |
1065 | { \ | 1116 | { \ |
1066 | GNUNET_log (level, \ | 1117 | GNUNET_log (level, \ |
1067 | dgettext ("gnunet", "`%s' failed on file `%s' at %s:%d with error: %s\n"), \ | 1118 | dgettext ("gnunet", \ |
1068 | cmd, \ | 1119 | "`%s' failed on file `%s' at %s:%d with error: %s\n"), \ |
1069 | filename, \ | 1120 | cmd, \ |
1070 | __FILE__, \ | 1121 | filename, \ |
1071 | __LINE__, \ | 1122 | __FILE__, \ |
1072 | strerror (errno)); \ | 1123 | __LINE__, \ |
1073 | } while (0) | 1124 | strerror (errno)); \ |
1125 | } while (0) | ||
1074 | 1126 | ||
1075 | 1127 | ||
1076 | /** | 1128 | /** |
@@ -1080,17 +1132,18 @@ GNUNET_error_type_to_string (enum GNUNET_ErrorType kind); | |||
1080 | * by strerror(errno). | 1132 | * by strerror(errno). |
1081 | */ | 1133 | */ |
1082 | #define GNUNET_log_from_strerror_file(level, component, cmd, filename) \ | 1134 | #define GNUNET_log_from_strerror_file(level, component, cmd, filename) \ |
1083 | do \ | 1135 | do \ |
1084 | { \ | 1136 | { \ |
1085 | GNUNET_log_from (level, \ | 1137 | GNUNET_log_from (level, \ |
1086 | component, \ | 1138 | component, \ |
1087 | dgettext ("gnunet", "`%s' failed on file `%s' at %s:%d with error: %s\n"), \ | 1139 | dgettext ("gnunet", \ |
1088 | cmd, \ | 1140 | "`%s' failed on file `%s' at %s:%d with error: %s\n"), \ |
1089 | filename, \ | 1141 | cmd, \ |
1090 | __FILE__, \ | 1142 | filename, \ |
1091 | __LINE__, \ | 1143 | __FILE__, \ |
1092 | strerror (errno)); \ | 1144 | __LINE__, \ |
1093 | } while (0) | 1145 | strerror (errno)); \ |
1146 | } while (0) | ||
1094 | 1147 | ||
1095 | /* ************************* endianness conversion ****************** */ | 1148 | /* ************************* endianness conversion ****************** */ |
1096 | 1149 | ||
@@ -1183,7 +1236,7 @@ GNUNET_ntoh_double (double d); | |||
1183 | * the first element! | 1236 | * the first element! |
1184 | */ | 1237 | */ |
1185 | #define GNUNET_memcmp(a, b) \ | 1238 | #define GNUNET_memcmp(a, b) \ |
1186 | ({ \ | 1239 | ({ \ |
1187 | const typeof (*b) * _a = (a); \ | 1240 | const typeof (*b) * _a = (a); \ |
1188 | const typeof (*a) * _b = (b); \ | 1241 | const typeof (*a) * _b = (b); \ |
1189 | memcmp (_a, _b, sizeof(*a)); \ | 1242 | memcmp (_a, _b, sizeof(*a)); \ |
@@ -1212,7 +1265,7 @@ GNUNET_memcmp_ct_ (const void *b1, | |||
1212 | * the first element! | 1265 | * the first element! |
1213 | */ | 1266 | */ |
1214 | #define GNUNET_memcmp_priv(a, b) \ | 1267 | #define GNUNET_memcmp_priv(a, b) \ |
1215 | ({ \ | 1268 | ({ \ |
1216 | const typeof (*b) * _a = (a); \ | 1269 | const typeof (*b) * _a = (a); \ |
1217 | const typeof (*a) * _b = (b); \ | 1270 | const typeof (*a) * _b = (b); \ |
1218 | GNUNET_memcmp_ct_ (_a, _b, sizeof(*a)); \ | 1271 | GNUNET_memcmp_ct_ (_a, _b, sizeof(*a)); \ |
@@ -1225,9 +1278,9 @@ GNUNET_memcmp_ct_ (const void *b1, | |||
1225 | * @param a pointer to @a n bytes which should be tested for the | 1278 | * @param a pointer to @a n bytes which should be tested for the |
1226 | * entire memory being zero'ed out. | 1279 | * entire memory being zero'ed out. |
1227 | * @param n number of bytes in @a to be tested | 1280 | * @param n number of bytes in @a to be tested |
1228 | * @return GNUNET_YES if a is zero, GNUNET_NO otherwise | 1281 | * @return true if @a a is zero, false_NO otherwise |
1229 | */ | 1282 | */ |
1230 | enum GNUNET_GenericReturnValue | 1283 | bool |
1231 | GNUNET_is_zero_ (const void *a, | 1284 | GNUNET_is_zero_ (const void *a, |
1232 | size_t n); | 1285 | size_t n); |
1233 | 1286 | ||
@@ -1240,7 +1293,7 @@ GNUNET_is_zero_ (const void *a, | |||
1240 | * @return GNUNET_YES if a is zero, GNUNET_NO otherwise | 1293 | * @return GNUNET_YES if a is zero, GNUNET_NO otherwise |
1241 | */ | 1294 | */ |
1242 | #define GNUNET_is_zero(a) \ | 1295 | #define GNUNET_is_zero(a) \ |
1243 | GNUNET_is_zero_ (a, sizeof (*a)) | 1296 | GNUNET_is_zero_ ((a), sizeof (*(a))) |
1244 | 1297 | ||
1245 | 1298 | ||
1246 | /** | 1299 | /** |
@@ -1253,15 +1306,16 @@ GNUNET_is_zero_ (const void *a, | |||
1253 | * @param n number of bytes to copy | 1306 | * @param n number of bytes to copy |
1254 | */ | 1307 | */ |
1255 | #define GNUNET_memcpy(dst, src, n) \ | 1308 | #define GNUNET_memcpy(dst, src, n) \ |
1256 | do \ | 1309 | do \ |
1257 | { \ | 1310 | { \ |
1258 | if (0 != n) \ | 1311 | if (0 != n) \ |
1259 | { \ | 1312 | { \ |
1260 | (void) memcpy (dst, src, n); \ | 1313 | (void) memcpy (dst, src, n); \ |
1261 | } \ | 1314 | } \ |
1262 | } while (0) | 1315 | } while (0) |
1263 | 1316 | ||
1264 | 1317 | ||
1318 | /* *INDENT-OFF* */ | ||
1265 | /** | 1319 | /** |
1266 | * @ingroup memory | 1320 | * @ingroup memory |
1267 | * Allocate a size @a n array with structs or unions of the given @a type. | 1321 | * Allocate a size @a n array with structs or unions of the given @a type. |
@@ -1275,6 +1329,7 @@ GNUNET_is_zero_ (const void *a, | |||
1275 | GNUNET_assert (SIZE_MAX / sizeof (type) >= n); \ | 1329 | GNUNET_assert (SIZE_MAX / sizeof (type) >= n); \ |
1276 | (type *) GNUNET_malloc ((n) * sizeof(type)); \ | 1330 | (type *) GNUNET_malloc ((n) * sizeof(type)); \ |
1277 | }) | 1331 | }) |
1332 | /* *INDENT-ON* */ | ||
1278 | 1333 | ||
1279 | /** | 1334 | /** |
1280 | * @ingroup memory | 1335 | * @ingroup memory |
@@ -1286,7 +1341,7 @@ GNUNET_is_zero_ (const void *a, | |||
1286 | * @param type name of the struct or union, i.e. pass 'struct Foo'. | 1341 | * @param type name of the struct or union, i.e. pass 'struct Foo'. |
1287 | */ | 1342 | */ |
1288 | #define GNUNET_new_array_2d(n, m, type) \ | 1343 | #define GNUNET_new_array_2d(n, m, type) \ |
1289 | (type **) GNUNET_xnew_array_2d_ (n, m, sizeof(type), __FILE__, __LINE__) | 1344 | (type **) GNUNET_xnew_array_2d_ (n, m, sizeof(type), __FILE__, __LINE__) |
1290 | 1345 | ||
1291 | /** | 1346 | /** |
1292 | * @ingroup memory | 1347 | * @ingroup memory |
@@ -1299,7 +1354,8 @@ GNUNET_is_zero_ (const void *a, | |||
1299 | * @param type name of the struct or union, i.e. pass 'struct Foo'. | 1354 | * @param type name of the struct or union, i.e. pass 'struct Foo'. |
1300 | */ | 1355 | */ |
1301 | #define GNUNET_new_array_3d(n, m, o, type) \ | 1356 | #define GNUNET_new_array_3d(n, m, o, type) \ |
1302 | (type ***) GNUNET_xnew_array_3d_ (n, m, o, sizeof(type), __FILE__, __LINE__) | 1357 | (type ***) GNUNET_xnew_array_3d_ (n, m, o, sizeof(type), __FILE__, \ |
1358 | __LINE__) | ||
1303 | 1359 | ||
1304 | /** | 1360 | /** |
1305 | * @ingroup memory | 1361 | * @ingroup memory |
@@ -1331,7 +1387,7 @@ GNUNET_is_zero_ (const void *a, | |||
1331 | * @return pointer to size bytes of memory, NULL if we do not have enough memory | 1387 | * @return pointer to size bytes of memory, NULL if we do not have enough memory |
1332 | */ | 1388 | */ |
1333 | #define GNUNET_malloc_large(size) \ | 1389 | #define GNUNET_malloc_large(size) \ |
1334 | GNUNET_xmalloc_unchecked_ (size, __FILE__, __LINE__) | 1390 | GNUNET_xmalloc_unchecked_ (size, __FILE__, __LINE__) |
1335 | 1391 | ||
1336 | 1392 | ||
1337 | /** | 1393 | /** |
@@ -1344,7 +1400,7 @@ GNUNET_is_zero_ (const void *a, | |||
1344 | * @return pointer to size bytes of memory | 1400 | * @return pointer to size bytes of memory |
1345 | */ | 1401 | */ |
1346 | #define GNUNET_realloc(ptr, size) \ | 1402 | #define GNUNET_realloc(ptr, size) \ |
1347 | GNUNET_xrealloc_ (ptr, size, __FILE__, __LINE__) | 1403 | GNUNET_xrealloc_ (ptr, size, __FILE__, __LINE__) |
1348 | 1404 | ||
1349 | 1405 | ||
1350 | /** | 1406 | /** |
@@ -1371,8 +1427,8 @@ GNUNET_is_zero_ (const void *a, | |||
1371 | * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier. NULL is allowed. | 1427 | * been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier. NULL is allowed. |
1372 | */ | 1428 | */ |
1373 | #define GNUNET_free(ptr) do { \ | 1429 | #define GNUNET_free(ptr) do { \ |
1374 | GNUNET_xfree_ (ptr, __FILE__, __LINE__); \ | 1430 | GNUNET_xfree_ (ptr, __FILE__, __LINE__); \ |
1375 | ptr = NULL; \ | 1431 | ptr = NULL; \ |
1376 | } while (0) | 1432 | } while (0) |
1377 | 1433 | ||
1378 | 1434 | ||
@@ -1386,6 +1442,7 @@ GNUNET_is_zero_ (const void *a, | |||
1386 | */ | 1442 | */ |
1387 | #define GNUNET_strdup(a) GNUNET_xstrdup_ (a, __FILE__, __LINE__) | 1443 | #define GNUNET_strdup(a) GNUNET_xstrdup_ (a, __FILE__, __LINE__) |
1388 | 1444 | ||
1445 | |||
1389 | /** | 1446 | /** |
1390 | * @ingroup memory | 1447 | * @ingroup memory |
1391 | * Wrapper around #GNUNET_xstrndup_. Makes a partial copy of the string | 1448 | * Wrapper around #GNUNET_xstrndup_. Makes a partial copy of the string |
@@ -1396,7 +1453,7 @@ GNUNET_is_zero_ (const void *a, | |||
1396 | * @return a partial copy of the string including zero-termination | 1453 | * @return a partial copy of the string including zero-termination |
1397 | */ | 1454 | */ |
1398 | #define GNUNET_strndup(a, length) \ | 1455 | #define GNUNET_strndup(a, length) \ |
1399 | GNUNET_xstrndup_ (a, length, __FILE__, __LINE__) | 1456 | GNUNET_xstrndup_ (a, length, __FILE__, __LINE__) |
1400 | 1457 | ||
1401 | /** | 1458 | /** |
1402 | * @ingroup memory | 1459 | * @ingroup memory |
@@ -1434,12 +1491,12 @@ GNUNET_is_zero_ (const void *a, | |||
1434 | * free the vector (then, arr will be NULL afterwards). | 1491 | * free the vector (then, arr will be NULL afterwards). |
1435 | */ | 1492 | */ |
1436 | #define GNUNET_array_grow(arr, size, tsize) \ | 1493 | #define GNUNET_array_grow(arr, size, tsize) \ |
1437 | GNUNET_xgrow_ ((void **) &(arr), \ | 1494 | GNUNET_xgrow_ ((void **) &(arr), \ |
1438 | sizeof((arr)[0]), \ | 1495 | sizeof((arr)[0]), \ |
1439 | &size, \ | 1496 | &size, \ |
1440 | tsize, \ | 1497 | tsize, \ |
1441 | __FILE__, \ | 1498 | __FILE__, \ |
1442 | __LINE__) | 1499 | __LINE__) |
1443 | 1500 | ||
1444 | /** | 1501 | /** |
1445 | * @ingroup memory | 1502 | * @ingroup memory |
@@ -1455,12 +1512,12 @@ GNUNET_is_zero_ (const void *a, | |||
1455 | * @param element the element that will be appended to the array | 1512 | * @param element the element that will be appended to the array |
1456 | */ | 1513 | */ |
1457 | #define GNUNET_array_append(arr, len, element) \ | 1514 | #define GNUNET_array_append(arr, len, element) \ |
1458 | do \ | 1515 | do \ |
1459 | { \ | 1516 | { \ |
1460 | GNUNET_assert ((len) + 1 > (len)); \ | 1517 | GNUNET_assert ((len) + 1 > (len)); \ |
1461 | GNUNET_array_grow (arr, len, len + 1); \ | 1518 | GNUNET_array_grow (arr, len, len + 1); \ |
1462 | (arr) [len - 1] = element; \ | 1519 | (arr) [len - 1] = element; \ |
1463 | } while (0) | 1520 | } while (0) |
1464 | 1521 | ||
1465 | 1522 | ||
1466 | /** | 1523 | /** |
@@ -1481,21 +1538,21 @@ GNUNET_is_zero_ (const void *a, | |||
1481 | * will be updated to reflect the new address. The TYPE of | 1538 | * will be updated to reflect the new address. The TYPE of |
1482 | * arr is important since size is the number of elements and | 1539 | * arr is important since size is the number of elements and |
1483 | * not the size in bytes | 1540 | * not the size in bytes |
1484 | * @param len the number of elements in the existing vector (number | 1541 | * @param len2 the number of elements in the existing vector (number |
1485 | * of elements to copy over), will be updated with the new | 1542 | * of elements to copy over), will be updated with the new |
1486 | * array size | 1543 | * array size |
1487 | 1544 | ||
1488 | */ | 1545 | */ |
1489 | #define GNUNET_array_concatenate(arr1, len1, arr2, len2) \ | 1546 | #define GNUNET_array_concatenate(arr1, len1, arr2, len2) \ |
1490 | do \ | 1547 | do \ |
1491 | { \ | 1548 | { \ |
1492 | const typeof (*arr2) * _a1 = (arr1); \ | 1549 | const typeof (*arr2) * _a1 = (arr1); \ |
1493 | const typeof (*arr1) * _a2 = (arr2); \ | 1550 | const typeof (*arr1) * _a2 = (arr2); \ |
1494 | GNUNET_assert ((len1) + (len2) >= (len1)); \ | 1551 | GNUNET_assert ((len1) + (len2) >= (len1)); \ |
1495 | GNUNET_assert (SIZE_MAX / sizeof (*_a1) >= ((len1) + (len2))); \ | 1552 | GNUNET_assert (SIZE_MAX / sizeof (*_a1) >= ((len1) + (len2))); \ |
1496 | GNUNET_array_grow (arr1, len1, (len1) + (len2)); \ | 1553 | GNUNET_array_grow (arr1, len1, (len1) + (len2)); \ |
1497 | memcpy (&(arr1) [(len1) - (len2)], _a2, (len2) * sizeof (*arr1)); \ | 1554 | memcpy (&(arr1) [(len1) - (len2)], _a2, (len2) * sizeof (*arr1)); \ |
1498 | } while (0) | 1555 | } while (0) |
1499 | 1556 | ||
1500 | 1557 | ||
1501 | /** | 1558 | /** |
@@ -1546,7 +1603,9 @@ __attribute__ ((format (printf, 2, 3))); | |||
1546 | * @return allocated memory, never NULL | 1603 | * @return allocated memory, never NULL |
1547 | */ | 1604 | */ |
1548 | void * | 1605 | void * |
1549 | GNUNET_xmalloc_ (size_t size, const char *filename, int linenumber); | 1606 | GNUNET_xmalloc_ (size_t size, |
1607 | const char *filename, | ||
1608 | int linenumber); | ||
1550 | 1609 | ||
1551 | 1610 | ||
1552 | /** | 1611 | /** |
@@ -1626,7 +1685,9 @@ GNUNET_xmemdup_ (const void *buf, | |||
1626 | * @return pointer to size bytes of memory, NULL if we do not have enough memory | 1685 | * @return pointer to size bytes of memory, NULL if we do not have enough memory |
1627 | */ | 1686 | */ |
1628 | void * | 1687 | void * |
1629 | GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber); | 1688 | GNUNET_xmalloc_unchecked_ (size_t size, |
1689 | const char *filename, | ||
1690 | int linenumber); | ||
1630 | 1691 | ||
1631 | 1692 | ||
1632 | /** | 1693 | /** |
@@ -1634,7 +1695,10 @@ GNUNET_xmalloc_unchecked_ (size_t size, const char *filename, int linenumber); | |||
1634 | * memory is available. | 1695 | * memory is available. |
1635 | */ | 1696 | */ |
1636 | void * | 1697 | void * |
1637 | GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber); | 1698 | GNUNET_xrealloc_ (void *ptr, |
1699 | size_t n, | ||
1700 | const char *filename, | ||
1701 | int linenumber); | ||
1638 | 1702 | ||
1639 | 1703 | ||
1640 | /** | 1704 | /** |
@@ -1647,7 +1711,9 @@ GNUNET_xrealloc_ (void *ptr, size_t n, const char *filename, int linenumber); | |||
1647 | * @param linenumber line where this call is being made (for debugging) | 1711 | * @param linenumber line where this call is being made (for debugging) |
1648 | */ | 1712 | */ |
1649 | void | 1713 | void |
1650 | GNUNET_xfree_ (void *ptr, const char *filename, int linenumber); | 1714 | GNUNET_xfree_ (void *ptr, |
1715 | const char *filename, | ||
1716 | int linenumber); | ||
1651 | 1717 | ||
1652 | 1718 | ||
1653 | /** | 1719 | /** |
@@ -1658,7 +1724,9 @@ GNUNET_xfree_ (void *ptr, const char *filename, int linenumber); | |||
1658 | * @return the duplicated string | 1724 | * @return the duplicated string |
1659 | */ | 1725 | */ |
1660 | char * | 1726 | char * |
1661 | GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber); | 1727 | GNUNET_xstrdup_ (const char *str, |
1728 | const char *filename, | ||
1729 | int linenumber); | ||
1662 | 1730 | ||
1663 | /** | 1731 | /** |
1664 | * Dup partially a string. Don't call GNUNET_xstrndup_ directly. Use the #GNUNET_strndup macro. | 1732 | * Dup partially a string. Don't call GNUNET_xstrndup_ directly. Use the #GNUNET_strndup macro. |
@@ -1714,7 +1782,7 @@ GNUNET_copy_message (const struct GNUNET_MessageHeader *msg); | |||
1714 | * Set the async scope for the current thread. | 1782 | * Set the async scope for the current thread. |
1715 | * | 1783 | * |
1716 | * @param aid the async scope identifier | 1784 | * @param aid the async scope identifier |
1717 | * @param old_scope[out] location to save the old scope | 1785 | * @param[out] old_scope location to save the old scope |
1718 | */ | 1786 | */ |
1719 | void | 1787 | void |
1720 | GNUNET_async_scope_enter (const struct GNUNET_AsyncScopeId *aid, | 1788 | GNUNET_async_scope_enter (const struct GNUNET_AsyncScopeId *aid, |
@@ -1828,6 +1896,8 @@ enum GNUNET_SCHEDULER_Priority | |||
1828 | }; | 1896 | }; |
1829 | 1897 | ||
1830 | 1898 | ||
1899 | /* *INDENT-OFF* */ | ||
1900 | |||
1831 | #if 0 /* keep Emacsens' auto-indent happy */ | 1901 | #if 0 /* keep Emacsens' auto-indent happy */ |
1832 | { | 1902 | { |
1833 | #endif | 1903 | #endif |